From 11d6663429e4fec4e50cc765368deeca2f31a08e Mon Sep 17 00:00:00 2001 From: Zengtudor Date: Tue, 13 Aug 2024 00:21:10 +0800 Subject: [PATCH] update --- package.json | 13 ++++++++----- src/Project/CppProject.ts | 4 +++- src/Tools/GetAbsolutePath.ts | 11 +++++++++++ src/index.ts | 22 ++++++++++++---------- tsconfig.json | 2 +- 5 files changed, 35 insertions(+), 17 deletions(-) create mode 100644 src/Tools/GetAbsolutePath.ts diff --git a/package.json b/package.json index 03247c1..bbba26f 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/Project/CppProject.ts b/src/Project/CppProject.ts index 3db5f69..93c3686 100644 --- a/src/Project/CppProject.ts +++ b/src/Project/CppProject.ts @@ -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) diff --git a/src/Tools/GetAbsolutePath.ts b/src/Tools/GetAbsolutePath.ts new file mode 100644 index 0000000..6ab8e9b --- /dev/null +++ b/src/Tools/GetAbsolutePath.ts @@ -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 \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 52684a4..6aab7d9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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; // } -// } \ No newline at end of file +// } + +export { + addProject, + CppProject +} diff --git a/tsconfig.json b/tsconfig.json index 85cb07f..753161e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -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. */