Update: MicroPython使用AST构建下py文件抽象语法树以精确解析模块依赖

This commit is contained in:
王立帮
2024-12-03 10:44:30 +08:00
parent faa8430208
commit d97c70fb36
42 changed files with 2938 additions and 40 deletions

View File

@@ -100,26 +100,29 @@ if (fs_plus.isDirectorySync(DEFAULT_SRC_DIR)) {
}
}
const DEFAULT_DIR = path.resolve(ORIGIN_DIR, 'boards/default');
if (fs_plus.isDirectorySync(DEFAULT_DIR)) {
const names = fs.readdirSync(DEFAULT_DIR);
for (let name of names) {
if (!['all', name].includes(options.type)) {
continue;
if (!!options.obfuscate) {
const DEFAULT_DIR = path.resolve(ORIGIN_DIR, 'boards/default');
if (fs_plus.isDirectorySync(DEFAULT_DIR)) {
const names = fs.readdirSync(DEFAULT_DIR);
for (let name of names) {
if (!['all', name].includes(options.type)) {
continue;
}
const now = path.resolve(DEFAULT_DIR, name);
if (!fs_plus.isDirectorySync(now)) {
continue;
}
const examplesPath = path.resolve(now, 'examples');
if (!fs_plus.isDirectorySync(examplesPath)) {
continue;
}
let outputPath = path.resolve(examplesPath, 'map.json');
let output = getExamples(examplesPath, !!options.obfuscate);
fs_extra.outputJsonSync(outputPath, output, {
spaces: ' '
});
}
const now = path.resolve(DEFAULT_DIR, name);
if (!fs_plus.isDirectorySync(now)) {
continue;
}
const examplesPath = path.resolve(now, 'examples');
if (!fs_plus.isDirectorySync(examplesPath)) {
continue;
}
let outputPath = path.resolve(examplesPath, 'map.json');
let output = getExamples(examplesPath, !!options.obfuscate);
fs_extra.outputJsonSync(outputPath, output, {
spaces: ' '
});
}
}