This commit is contained in:
Zengtudor 2024-08-11 22:59:13 +08:00
parent 1ff07a2dd4
commit 347a0758e0
5 changed files with 33 additions and 12 deletions

View File

@ -19,11 +19,13 @@
"author": "Zengtudor", "author": "Zengtudor",
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"@types/lodash": "^4.17.7",
"@types/minimist": "^1.2.5", "@types/minimist": "^1.2.5",
"@types/node": "^22.2.0", "@types/node": "^22.2.0",
"typescript": "^5.5.4" "typescript": "^5.5.4"
}, },
"dependencies": { "dependencies": {
"lodash": "^4.17.21",
"minimist": "^1.2.8", "minimist": "^1.2.8",
"ts-node": "^10.9.2" "ts-node": "^10.9.2"
} }

View File

@ -1,8 +1,14 @@
import { cloneDeep } from "lodash"
import NmakeGlobal from "../interface/NmakeGlobal"
import printDebug from "../Tools/DebugPrint" import printDebug from "../Tools/DebugPrint"
const project = (name:string,callback:Function) =>{ const project = (name:string,callback:Function) =>{
const oldGlobal = (global as any).nmake as unknown as NmakeGlobal
const nGlobal = cloneDeep(((global as any).nmake as unknown as NmakeGlobal));
(global as any).nmake = nGlobal
printDebug("adding project :"+name) printDebug("adding project :"+name)
callback() callback()
(global as any).nmake = oldGlobal
} }
export default project export default project

View File

@ -1,9 +1,9 @@
import NmakeGlobal from "../interface/NmakeGlobal" import NmakeGlobal from "../interface/NmakeGlobal"
import { getGlobalNmake, Global } from "./GlobalStack"
const constructGlobal = ()=>{ const constructGlobal = ()=>{
(global as any).projects = []; Global.nmake = {}
const nmakeGlobal = global as unknown as NmakeGlobal Global.nmake.projects = {} as NmakeGlobal[]
} }
export default constructGlobal export default constructGlobal

22
src/Tools/GlobalStack.ts Normal file
View File

@ -0,0 +1,22 @@
import { cloneDeep } from "lodash"
import NmakeGlobal from "../interface/NmakeGlobal"
import printDebug from "./DebugPrint"
export const Global = global as any
let globalNmakeStacks = Global.globalStacks as NmakeGlobal[]
export const pushGlobalStack = () =>{
if(!Global.globalStacks){Global.globalStacks = [];globalNmakeStacks = Global.globalStacks as NmakeGlobal[]}
printDebug("pushing global stack")
globalNmakeStacks.push(Global.nmake)
Global.nmake = cloneDeep(Global.nmake)
}
export const popGlobalStack = ()=>{
Global.nmake = globalNmakeStacks[globalNmakeStacks.length-1]
globalNmakeStacks.pop()
}
export const getGlobalNmake=():NmakeGlobal=>{
return Global.nmake
}

View File

@ -1,9 +0,0 @@
import { execSync } from "child_process";
import GppCompiler from "../../src/Compiler/GppCompiler";
(global as any).isDebug=true;
// const a = new GppCompiler()
// console.log(a.compilerVersion)
console.log(execSync("g++ -v").toLocaleString())
// console.log(execSync("g++ --version").toString().trim())