This commit is contained in:
Zengtudor 2024-08-13 00:21:10 +08:00
parent c9db0716d7
commit 11d6663429
5 changed files with 35 additions and 17 deletions

View File

@ -1,15 +1,18 @@
{
"name": "cnmake",
"version": "0.0.7",
"version": "0.0.12",
"description": "一个用Nodejs作为框架编译C/C++的代码库,未来可能会支持更多语言",
"main": "./src/index.ts",
"main": "./dist/src/index.js",
"type": "module",
"types": "./src/index.ts",
"types": "./dist/src/index.d.ts",
"bin": {
"cnmake": "./dist/index.js"
"cnmake": "./dist/src/index.js"
},
"files": [
"dist", "LICENSE", "README.md", "package.json"
],
"scripts": {
"dev": "tsc && node ./build/index.js"
"dev": "tsc && node ./dist/src/index.js -v"
},
"repository": {
"type": "git",

View File

@ -11,6 +11,8 @@ import { getNmakeDir } from "../Tools/NmakeDir.js";
import { getBuildDir } from "../Tools/BuildDir.js";
import printErrorOrDebug from "../Tools/PrintErrorOrDebug.js";
import protectPath from "../Tools/ProtectPath.js";
import getAbsolute from "../Tools/GetAbsolutePath.js";
import getAbsolutePath from "../Tools/GetAbsolutePath.js";
export default class CppProject implements Project , SourceFiles,HaveCompiler,Optimize {
name: string;
@ -41,7 +43,7 @@ export default class CppProject implements Project , SourceFiles,HaveCompiler,Op
printDebug("adding source files "+files)
files.forEach(v=>{
this.sourceFilesPath.push(
path.join(getNmakeDir(),v)
getAbsolutePath(getNmakeDir(),v)
)
});
printDebug("all files in "+this.name+" :"+this.sourceFilesPath)

View File

@ -0,0 +1,11 @@
import path from "path"
const getAbsolutePath = (basePath:string,p:string):string=>{
if(path.isAbsolute(p)){
return p
}else{
return path.join(basePath,p)
}
}
export default getAbsolutePath

View File

@ -7,16 +7,12 @@ import { setNmakePath } from "./Tools/NmakePath.js";
import CppBuilder from "./Builder/CppBuilder.js";
import CppProject from "./Project/CppProject.js";
export{
addProject,
CppProject,
}
// const argv = require('minimist')(process.argv.slice(2))
import minimist from "minimist";
const argv = minimist(process.argv.slice(2))
let nmakeFileName = "nmake.js"
let nmakeFileName = "cnmake.js"
if(argv["v"])(global as any).isDebug=true
if (argv["f"]) {nmakeFileName = argv["f"];printDebug(`setting nmake file name to ${argv["f"]}`)}
@ -45,10 +41,11 @@ printDebug(`running file ${nmakeFilePath}`)
await import(pathToFileURL(nmakeFilePath).toString())
printDebug(`run completion!`,nmakeFilePath)
if(argv["b"]){
printDebug("will build the project")
await new CppBuilder().build()
}
await new CppBuilder().build()
// if(argv["b"]){
// printDebug("will build the project")
// }
// if (argv[0]) {
// switch (argv[0]) {
@ -59,4 +56,9 @@ if(argv["b"]){
// default:
// break;
// }
// }
// }
export {
addProject,
CppProject
}

View File

@ -26,7 +26,7 @@
/* Modules */
"module": "NodeNext", /* Specify what module code is generated. */
// "rootDir": "./src", /* Specify the root folder within your source files. */
"rootDir": "./src", /* Specify the root folder within your source files. */
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */