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",
"license": "MIT",
"devDependencies": {
"@types/lodash": "^4.17.7",
"@types/minimist": "^1.2.5",
"@types/node": "^22.2.0",
"typescript": "^5.5.4"
},
"dependencies": {
"lodash": "^4.17.21",
"minimist": "^1.2.8",
"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"
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)
callback()
(global as any).nmake = oldGlobal
}
export default project

View File

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