update
This commit is contained in:
parent
6245631894
commit
bdbfec40f9
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"cSpell.words": [
|
||||
"Zengtudor"
|
||||
]
|
||||
}
|
@ -24,6 +24,7 @@
|
||||
"typescript": "^5.5.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"minimist": "^1.2.8"
|
||||
"minimist": "^1.2.8",
|
||||
"ts-node": "^10.9.2"
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,14 @@
|
||||
import GppCompiler from "../Compiler/GppCompiler";
|
||||
import HaveCompiler from "./interface/HaveCompiler";
|
||||
import Optimize from "./interface/Optimize";
|
||||
import SourceFiles from "./interface/SourceFiles";
|
||||
import Project from "./Project";
|
||||
|
||||
export default class CppProject implements Project , SourceFiles {
|
||||
export default class CppProject implements Project , SourceFiles,HaveCompiler,Optimize {
|
||||
name: string;
|
||||
compiler: GppCompiler;
|
||||
sourceFiles: string[]=[];
|
||||
optimize: "fast" | "fastest" | "normal" = "fast"
|
||||
|
||||
constructor(name:string)
|
||||
constructor(name:string,compiler:GppCompiler)
|
||||
@ -17,5 +20,6 @@ export default class CppProject implements Project , SourceFiles {
|
||||
this.compiler=new GppCompiler()
|
||||
}
|
||||
this.name=name
|
||||
|
||||
}
|
||||
}
|
@ -2,5 +2,4 @@ import Compiler from "../Compiler/Compiler"
|
||||
|
||||
export default interface Project{
|
||||
name:string
|
||||
compiler:Compiler
|
||||
}
|
5
src/Project/interface/HaveCompiler.ts
Normal file
5
src/Project/interface/HaveCompiler.ts
Normal file
@ -0,0 +1,5 @@
|
||||
import Compiler from "../../Compiler/Compiler";
|
||||
|
||||
export default interface HaveCompiler{
|
||||
compiler:Compiler
|
||||
}
|
3
src/Project/interface/Optimize.ts
Normal file
3
src/Project/interface/Optimize.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export default interface Optimize{
|
||||
optimize:"fast"|"fastest"|"normal"
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
const printDebug = (m:string)=>{
|
||||
const printDebug = (...m:string[])=>{
|
||||
if((global as any).isDebug){
|
||||
console.log(`[Debug] ${m}`)
|
||||
m.forEach(e=>{
|
||||
console.log(`[Debug] ${e}`)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,8 +2,10 @@ import getPathsFromEnv from "./GetPathsFromEnv";
|
||||
|
||||
const getExecutablePathsFromEnv = (name:string):string[]=>{
|
||||
const ret:string[]=[];
|
||||
getPathsFromEnv(name).forEach(e=>ret.push(e))
|
||||
getPathsFromEnv(`${name}.exe`).forEach(e=>ret.push(e))
|
||||
const suffixes:string[] = ["",".exe"]
|
||||
suffixes.forEach(v=>{
|
||||
getPathsFromEnv(`${name}${v}`).forEach(e=>ret.push(e))
|
||||
})
|
||||
return ret
|
||||
}
|
||||
export default getExecutablePathsFromEnv
|
16
src/Tools/PrintErrorOrDebug.ts
Normal file
16
src/Tools/PrintErrorOrDebug.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { exit } from "process"
|
||||
|
||||
const printErrorOrDebug = (...m:string[])=>{
|
||||
let str = ""
|
||||
m.forEach(v=>{
|
||||
str=str+"\n"+v
|
||||
})
|
||||
if((global as any).isDebug){
|
||||
throw Error(str)
|
||||
}else{
|
||||
console.error(`error :${str}`)
|
||||
exit(-1)
|
||||
}
|
||||
}
|
||||
|
||||
export default printErrorOrDebug
|
@ -1,7 +1,6 @@
|
||||
import { exec, execSync } from "child_process"
|
||||
import printDebug from "./DebugPrint";
|
||||
import util from "util";
|
||||
const execPromise =util.promisify(exec);
|
||||
|
||||
const tryGetCompilerVersion =(path:string,command:string):string=>{
|
||||
const exec_command = `${path} ${command}`
|
||||
|
26
src/index.ts
26
src/index.ts
@ -1,2 +1,26 @@
|
||||
const argv = require('minimist')(process.argv.slice(2));
|
||||
import path from "path";
|
||||
import printDebug from "./Tools/DebugPrint";
|
||||
import { existsSync } from "fs";
|
||||
import printErrorOrDebug from "./Tools/PrintErrorOrDebug";
|
||||
|
||||
const argv = require('minimist')(process.argv.slice(2))
|
||||
|
||||
let nmakeFileName = "nmake.ts"
|
||||
if(argv["v"])(global as any).isDebug=true
|
||||
if (argv["f"]) {nmakeFileName = argv["f"];printDebug(`setting nmake file name to ${argv["f"]}`)}
|
||||
|
||||
const nmakeFilePath = path.join(process.cwd(),nmakeFileName)
|
||||
printDebug(`file path is ${nmakeFilePath}`)
|
||||
|
||||
|
||||
printDebug("finding nmake file at "+nmakeFilePath)
|
||||
if(!existsSync(nmakeFilePath))printErrorOrDebug(`cannot find file ${nmakeFilePath}`)
|
||||
printDebug("found nmake file")
|
||||
|
||||
printDebug("adding ts-node")
|
||||
require("ts-node").register()
|
||||
|
||||
printDebug(`running file ${nmakeFilePath}`)
|
||||
require(nmakeFilePath)
|
||||
printDebug(`run completion!`,nmakeFilePath)
|
||||
|
||||
|
1
tests/test2/nmake.ts
Normal file
1
tests/test2/nmake.ts
Normal file
@ -0,0 +1 @@
|
||||
console.log("hello world")
|
Loading…
Reference in New Issue
Block a user