mirror of
https://gitee.com/openharmony/napi_generator
synced 2024-11-26 18:20:35 +00:00
!448 [napi_tool] 修复h2dtscpp工具输出bug
Merge pull request !448 from 苟晶晶/master
This commit is contained in:
commit
582eaa7293
@ -90,20 +90,14 @@ ${CJSON_LIB_PATH}/libcjson.so
|
||||
1.2在命令行使用 以下命令运行脚本
|
||||
|
||||
```
|
||||
native_gen-win.exe -f 接口文件路径 -o 生成路径 -t 测试文件路径 -i 声明文件路径
|
||||
native_gen-win.exe -f 接口文件路径 -o 生成路径
|
||||
```
|
||||
|
||||
其中,参数详情如下:
|
||||
|
||||
-f, 必选参数,待转换的.h文件;如cJSON.h。
|
||||
|
||||
-t, 可选参数,测试用例文件Ability.test.ets文件路径,默认路径为.h文件目录下testout文件夹下创建的xxxAbility.test.ets文件路径(如:testout/cJSONAbility.test.ets)。
|
||||
|
||||
-i, 可选参数,ts声明文件index.s.ts文件路径,默认路径为.h文件目录下tsout文件夹下创建的index.d.ts文件路径(如:tsout/index.d.ts)
|
||||
|
||||
index.d.ts文件路径;
|
||||
|
||||
-o, 可选参数,生成的.cpp文件所在路径,默认路径为.h文件目录下创建的cppout文件夹路径;
|
||||
-o, 可选参数,生成路径,默认路径为.h文件所在路径;
|
||||
|
||||
例如:
|
||||
|
||||
|
@ -34,13 +34,7 @@ node main.js -f cJSON.h
|
||||
|
||||
-f, 必选参数,待转换的.h文件;如cJSON.h。
|
||||
|
||||
-t, 可选参数,测试用例文件Ability.test.ets文件路径,默认路径为.h文件目录下testout文件夹下创建的xxxAbility.test.ets文件路径(如:testout/cJSONAbility.test.ets)。
|
||||
|
||||
-i, 可选参数,ts声明文件index.s.ts文件路径,默认路径为.h文件目录下tsout文件夹下创建的index.d.ts文件路径(如:tsout/index.d.ts)
|
||||
|
||||
index.d.ts文件路径;
|
||||
|
||||
-o, 可选参数,生成的.cpp文件所在路径,默认路径为.h文件目录下创建的cppout文件夹路径;
|
||||
-o, 可选参数,生成路径,默认路径为.h文件所在路径;
|
||||
|
||||
6.执行成功后在napi_generator/src/cli/h2dtscpp/src/src目录下生成以下文件夹
|
||||
|
||||
|
@ -20,36 +20,33 @@ const main = require('./TsGen/tsMain');
|
||||
let ops = stdio.getopt({
|
||||
// 输入的.h文件路径,必填
|
||||
'filename': { key: 'f', args: 1, description: '.h file', default: '' },
|
||||
// 可选参数,测试文件路径
|
||||
'testFilename': { key: 't', args: 1, description: 'Ability.test.ets file', default: '' },
|
||||
// 可选参数, 声明文件路径
|
||||
'indexFilename': { key: 'i', args: 1, description: 'index.d.ts file', default: '' },
|
||||
// 可选参数, cpp文件路径
|
||||
'outCppPath': { key: 'o', args: 1, description: '.cpp dir path', default: '' },
|
||||
// 输出路径,选填
|
||||
'out': { key: 'o', args: 1, description: 'out path', default: '' },
|
||||
});
|
||||
|
||||
// 获取命令行参数 .h文件路径
|
||||
let filePath = ops.filename;
|
||||
let testFilePath = ops.testFilename;
|
||||
let tsFilePath = ops.indexFilename;
|
||||
let cppFilePath = ops.outCppPath;
|
||||
let outPath = ops.out;
|
||||
let testFilePath = '';
|
||||
let tsFilePath = '';
|
||||
let cppFilePath = '';
|
||||
// 读取文件内容 判断参数是否为空
|
||||
if (filePath !== '') {
|
||||
// 若用户没有提供路径 则程序提供默认路径
|
||||
if (!tsFilePath) {
|
||||
createDirectorySync(path.join(filePath, '../tsout'));
|
||||
tsFilePath = path.join(filePath, '../tsout/index.d.ts');
|
||||
}
|
||||
if (!testFilePath) {
|
||||
testFilePath = path.join(filePath, '../testout');
|
||||
createDirectorySync(testFilePath);
|
||||
}
|
||||
if (!cppFilePath) {
|
||||
// 若用户未给定cpp生成路径,则在.h路径下直接生成out路径
|
||||
cppFilePath = path.join(filePath, '../cppout');
|
||||
createDirectorySync(cppFilePath);
|
||||
let genDir = path.join(filePath, '..');
|
||||
if (outPath !== '') {
|
||||
genDir = outPath;
|
||||
}
|
||||
|
||||
createDirectorySync(path.join(genDir, './tsout'));
|
||||
tsFilePath = path.join(genDir, './tsout/index.d.ts');
|
||||
|
||||
testFilePath = path.join(genDir, './testout');
|
||||
createDirectorySync(testFilePath);
|
||||
|
||||
cppFilePath = path.join(genDir, './cppout');
|
||||
createDirectorySync(cppFilePath);
|
||||
|
||||
main.doGenerate(filePath, testFilePath, tsFilePath, cppFilePath);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user