update
This commit is contained in:
parent
db5a419af8
commit
e43cd81e7c
@ -1,18 +1,30 @@
|
|||||||
|
import path from "path";
|
||||||
import GppCompiler from "../Compiler/GppCompiler";
|
import GppCompiler from "../Compiler/GppCompiler";
|
||||||
import printDebug from "../Tools/DebugPrint";
|
import printDebug from "../Tools/DebugPrint";
|
||||||
import { getDefaultCompiler, setDefaultCompiler } from "../Tools/DefaultCompiler";
|
import setGetDefaultCompiler from "../Tools/SetGetDefaultCompiler";
|
||||||
import setGetDefaultCompiler from "../Tools/setGetDefaultCompiler";
|
|
||||||
import HaveCompiler from "./interface/HaveCompiler";
|
import HaveCompiler from "./interface/HaveCompiler";
|
||||||
import Optimize from "./interface/Optimize";
|
import Optimize from "./interface/Optimize";
|
||||||
import SourceFiles from "./interface/SourceFiles";
|
import SourceFiles from "./interface/SourceFiles";
|
||||||
import Project from "./Project";
|
import Project from "./Project";
|
||||||
|
import { getNmakePath } from "../Tools/NmakePath";
|
||||||
|
import { getNmakeDir } from "../Tools/NmakeDir";
|
||||||
|
|
||||||
export default class CppProject implements Project , SourceFiles,HaveCompiler,Optimize {
|
export default class CppProject implements Project , SourceFiles,HaveCompiler,Optimize {
|
||||||
name: string;
|
name: string;
|
||||||
compiler: GppCompiler;
|
compiler: GppCompiler;
|
||||||
sourceFiles: string[]=[];
|
sourceFilesPath: string[]=[];
|
||||||
optimize: "fast" | "fastest" | "normal" = "fast"
|
optimize: "fast" | "fastest" | "normal" = "fast"
|
||||||
typeName: string = "cpp";
|
typeName: string = "cpp";
|
||||||
|
addFiles = (...files: string[]):CppProject =>{
|
||||||
|
printDebug("adding source files "+files)
|
||||||
|
files.forEach(v=>{
|
||||||
|
this.sourceFilesPath.push(
|
||||||
|
path.join(getNmakeDir(),v)
|
||||||
|
)
|
||||||
|
});
|
||||||
|
printDebug("all files in "+this.name+" :"+this.sourceFilesPath)
|
||||||
|
return this
|
||||||
|
};
|
||||||
|
|
||||||
constructor(name:string)
|
constructor(name:string)
|
||||||
constructor(name:string,compiler:GppCompiler)
|
constructor(name:string,compiler:GppCompiler)
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
import Project from "../Project"
|
||||||
|
|
||||||
export default interface SourceFiles{
|
export default interface SourceFiles{
|
||||||
sourceFiles:string[]
|
sourceFilesPath:string[]
|
||||||
|
addFiles:{(...files:string[]):Project}
|
||||||
}
|
}
|
11
src/Tools/AddProject.ts
Normal file
11
src/Tools/AddProject.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import Project from "../Project/Project";
|
||||||
|
import printErrorOrDebug from "./PrintErrorOrDebug";
|
||||||
|
import { getGlobalProjects } from "./Projects";
|
||||||
|
|
||||||
|
export const addProject = (f:{():Project}) =>{
|
||||||
|
const project = f()
|
||||||
|
if(getGlobalProjects()[project.name]){
|
||||||
|
printErrorOrDebug(`the project ${project.name} was used please rename it`)
|
||||||
|
}
|
||||||
|
getGlobalProjects()[project.name] = project
|
||||||
|
}
|
8
src/Tools/GlobalNmake.ts
Normal file
8
src/Tools/GlobalNmake.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
const Global = (global as any)
|
||||||
|
|
||||||
|
export const getGlobalNmake = ():any=>{
|
||||||
|
if(Global.nmake==undefined){
|
||||||
|
Global.nmake={}
|
||||||
|
}
|
||||||
|
return Global.nmake
|
||||||
|
}
|
9
src/Tools/NmakeDir.ts
Normal file
9
src/Tools/NmakeDir.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import path from "path"
|
||||||
|
import { getNmakePath } from "./NmakePath"
|
||||||
|
import printDebug from "./DebugPrint"
|
||||||
|
|
||||||
|
export const getNmakeDir =():string=>{
|
||||||
|
let nmakeDir = path.join(getNmakePath(),"../")
|
||||||
|
printDebug("getting nmake dir "+nmakeDir)
|
||||||
|
return nmakeDir
|
||||||
|
}
|
17
src/Tools/NmakePath.ts
Normal file
17
src/Tools/NmakePath.ts
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import printDebug from "./DebugPrint";
|
||||||
|
import { getGlobalNmake } from "./GlobalNmake"
|
||||||
|
import printErrorOrDebug from "./PrintErrorOrDebug";
|
||||||
|
|
||||||
|
|
||||||
|
export const setNmakePath = (path:string)=>{
|
||||||
|
printDebug("setting nmake path "+path)
|
||||||
|
getGlobalNmake().nmakePath = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getNmakePath = ():string=>{
|
||||||
|
printDebug("getting nmake path")
|
||||||
|
if(getGlobalNmake().nmakePath==undefined){
|
||||||
|
printErrorOrDebug("cannot get nmake path")
|
||||||
|
}
|
||||||
|
return getGlobalNmake().nmakePath
|
||||||
|
}
|
@ -8,7 +8,7 @@ const printErrorOrDebug = (...m:string[])=>{
|
|||||||
if((global as any).isDebug){
|
if((global as any).isDebug){
|
||||||
throw Error(str)
|
throw Error(str)
|
||||||
}else{
|
}else{
|
||||||
console.error(`error :${str}`)
|
console.error(`[Error] :${str}`)
|
||||||
exit(-1)
|
exit(-1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
9
src/Tools/Projects.ts
Normal file
9
src/Tools/Projects.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import Project from "../Project/Project"
|
||||||
|
import { getGlobalNmake } from "./GlobalNmake"
|
||||||
|
|
||||||
|
export const getGlobalProjects = ():{[key:string]:Project}=>{
|
||||||
|
if(getGlobalNmake().projects==undefined){
|
||||||
|
getGlobalNmake().projects = []
|
||||||
|
}
|
||||||
|
return getGlobalNmake().projects as {[key:string]:Project}
|
||||||
|
}
|
@ -2,6 +2,7 @@ import path from "path";
|
|||||||
import printDebug from "./Tools/DebugPrint";
|
import printDebug from "./Tools/DebugPrint";
|
||||||
import { existsSync } from "fs";
|
import { existsSync } from "fs";
|
||||||
import printErrorOrDebug from "./Tools/PrintErrorOrDebug";
|
import printErrorOrDebug from "./Tools/PrintErrorOrDebug";
|
||||||
|
import { setNmakePath } from "./Tools/NmakePath";
|
||||||
|
|
||||||
const argv = require('minimist')(process.argv.slice(2))
|
const argv = require('minimist')(process.argv.slice(2))
|
||||||
|
|
||||||
@ -17,11 +18,14 @@ printDebug("finding nmake file at "+nmakeFilePath)
|
|||||||
if(!existsSync(nmakeFilePath))printErrorOrDebug(`cannot find file ${nmakeFilePath}`)
|
if(!existsSync(nmakeFilePath))printErrorOrDebug(`cannot find file ${nmakeFilePath}`)
|
||||||
printDebug("found nmake file")
|
printDebug("found nmake file")
|
||||||
|
|
||||||
|
setNmakePath(nmakeFilePath)
|
||||||
|
|
||||||
printDebug("adding ts-node")
|
printDebug("adding ts-node")
|
||||||
require("ts-node").register()
|
require("ts-node").register()
|
||||||
|
|
||||||
printDebug("adding global values")
|
printDebug("adding global values")
|
||||||
|
|
||||||
|
console.log("running nmake file "+nmakeFilePath)
|
||||||
printDebug(`running file ${nmakeFilePath}`)
|
printDebug(`running file ${nmakeFilePath}`)
|
||||||
require(nmakeFilePath)
|
require(nmakeFilePath)
|
||||||
printDebug(`run completion!`,nmakeFilePath)
|
printDebug(`run completion!`,nmakeFilePath)
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
import GppCompiler from "../../src/Compiler/GppCompiler";
|
|
||||||
import CppProject from "../../src/Project/CppProject";
|
import CppProject from "../../src/Project/CppProject";
|
||||||
|
import { addProject } from "../../src/Tools/AddProject";
|
||||||
|
|
||||||
// const compiler = new GppCompiler()
|
// const compiler = new GppCompiler()
|
||||||
|
|
||||||
new CppProject("hello");
|
addProject(()=>{
|
||||||
|
return new CppProject("hello")
|
||||||
|
})
|
||||||
|
|
||||||
new CppProject("hello");
|
new CppProject("hello")
|
||||||
|
|
||||||
new CppProject("hello");
|
new CppProject("hello")
|
||||||
|
Loading…
Reference in New Issue
Block a user