Files
cocos4/native/utils/compile_file.js
T
minggo 5410a48a58 Implement more logic in native (#4131)
Co-authored-by: bofeng.song <bofeng.song@chukong-inc.com>
Co-authored-by: dumganhar <dumganhar@gmail.com>
Co-authored-by: mmyduckx <308303735@qq.com>
Co-authored-by: Patrice Jiang <397136899@qq.com>
Co-authored-by: 江战 <40414978+PatriceJiang@users.noreply.github.com>
2022-01-07 18:39:40 +08:00

33 lines
859 B
JavaScript

const fs = require('fs');
const path = require('path');
const child_process = require('child_process');
const fp = path.join(__dirname, '..', 'compile_commands.json');
if(!fs.existsSync(fp)) {
console.error(`File ${fp} is not exists!`);
process.exit(-1);
}
const db = JSON.parse(fs.readFileSync(fp).toString('utf8'));
let fileName = process.argv[2];
if(!fileName) {
console.error(`argument: file not provided!`);
process.exit(-1);
}
fileName = path.normalize(fileName);
for(let item of db) {
let up = path.normalize(item.file);
if(up.indexOf(fileName) > -1) {
console.log(`compiling file ${up}`);
let result = child_process.execSync(item.command, {cwd: item.directory, shell: true});
console.log(result.toString('utf-8'));
process.exit(-1);
}
}
console.error(' file not found '+ fileName);