From ca0cfd8eab4544452af0ec194e47e2b9d7686a28 Mon Sep 17 00:00:00 2001 From: lizhouze Date: Tue, 23 Aug 2022 10:12:09 +0800 Subject: [PATCH 1/2] lizhouze@huawei.com Signed-off-by: lizhouze --- compiler/main.js | 32 ++++++++++++++++++++++++++++++++ compiler/webpack.config.js | 11 +++-------- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/compiler/main.js b/compiler/main.js index 8276b81..47ce1bb 100644 --- a/compiler/main.js +++ b/compiler/main.js @@ -65,6 +65,7 @@ function initProjectConfig(projectConfig) { projectConfig.cachePath = projectConfig.cachePath || process.env.cachePath || path.resolve(__dirname, 'node_modules/.cache'); projectConfig.aceSoPath = projectConfig.aceSoPath || process.env.aceSoPath; + projectConfig.xtsMode = /ets_loader_ark$/.test(__dirname); } function loadEntryObj(projectConfig) { @@ -337,6 +338,36 @@ function hashProjectPath(projectPath) { return process.env.hashProjectPath; } +function checkAppResourcePath(appResourcePath, config) { + if (appResourcePath) { + readAppResource(resources, appResourcePath); + if (fs.existsSync(appResourcePath) && config.cache) { + config.cache.buildDependencies.config.push(appResourcePath); + } + if (!projectConfig.xtsMode) { + saveAppResourcePath(appResourcePath, appResourcePathSavePath); + if (fs.existsSync(appResourcePathSavePath) && config.cache) { + config.cache.buildDependencies.config.push(appResourcePathSavePath); + } + } + } +} + +function saveAppResourcePath(appResourcePath, appResourcePathSavePath) { + let isSave = false; + if (fs.existsSync(appResourcePathSavePath)) { + const saveContent = fs.readFileSync(appResourcePathSavePath); + if (appResourcePath !== saveContent) { + isSave = true; + } + } else { + isSave = true; + } + if (isSave) { + fs.writeFileSync(appResourcePathSavePath, appResourcePath); + } +} + const globalProgram = { program: null, watchProgram: null @@ -351,3 +382,4 @@ exports.loadWorker = loadWorker; exports.abilityConfig = abilityConfig; exports.readWorkerFile = readWorkerFile; exports.systemModules = systemModules; +exports.checkAppResourcePath = checkAppResourcePath; diff --git a/compiler/webpack.config.js b/compiler/webpack.config.js index 6ff54d0..8d5d3f5 100644 --- a/compiler/webpack.config.js +++ b/compiler/webpack.config.js @@ -24,10 +24,10 @@ const { projectConfig, loadEntryObj, readAppResource, - resources, loadWorker, abilityConfig, - readWorkerFile + readWorkerFile, + checkAppResourcePath } = require('./main'); const { ResultStates } = require('./lib/compile_info'); const { processUISyntax } = require('./lib/process_ui_syntax'); @@ -349,12 +349,7 @@ module.exports = (env, argv) => { } const appResourcePath = env.appResource || process.env.appResource; - if (appResourcePath) { - readAppResource(resources, appResourcePath); - if (fs.existsSync(appResourcePath) && config.cache) { - config.cache.buildDependencies.config.push(appResourcePath) - } - } + checkAppResourcePath(appResourcePath, config); config.output.library = projectConfig.hashProjectPath; return config; } \ No newline at end of file From a1d98f021ebb7c354b6cd9e1a36c3833c65bdeb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A1=E5=93=A5?= Date: Tue, 23 Aug 2022 07:43:00 +0000 Subject: [PATCH 2/2] update compiler/main.js. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 卡哥 --- compiler/main.js | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/main.js b/compiler/main.js index 47ce1bb..68374ba 100644 --- a/compiler/main.js +++ b/compiler/main.js @@ -345,6 +345,7 @@ function checkAppResourcePath(appResourcePath, config) { config.cache.buildDependencies.config.push(appResourcePath); } if (!projectConfig.xtsMode) { + const appResourcePathSavePath = path.resolve(projectConfig.cachePath, 'resource_path.txt'); saveAppResourcePath(appResourcePath, appResourcePathSavePath); if (fs.existsSync(appResourcePathSavePath) && config.cache) { config.cache.buildDependencies.config.push(appResourcePathSavePath);