From 9edf6e2d87e3acec560c92936f0efbbe9f526249 Mon Sep 17 00:00:00 2001 From: chenqy930 Date: Wed, 26 Oct 2022 17:41:16 +0800 Subject: [PATCH] Enable hotfix Related issue:https://gitee.com/open_harmony/dashboard?issue_id=I5XPTY Change-Id: I96ca9db9bb63c10d842675d37eeb67848bbb60e1 Signed-off-by: chenqy930 --- compiler/src/gen_merged_abc.ts | 33 +++++++++++++++++++++++++++++---- compiler/src/pre_define.ts | 1 + 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/compiler/src/gen_merged_abc.ts b/compiler/src/gen_merged_abc.ts index c847d2e00..cd67da5d7 100644 --- a/compiler/src/gen_merged_abc.ts +++ b/compiler/src/gen_merged_abc.ts @@ -25,7 +25,8 @@ import { FILESINFO_TXT, MODULES_CACHE, NPMENTRIES_TXT, - NODE_MODULES + NODE_MODULES, + PATCH_SYMBOL_TABLE } from './pre_define'; import { EntryInfo, @@ -41,6 +42,9 @@ import { const red: string = '\u001b[31m'; const reset: string = '\u001b[39m'; +projectConfig.patch = false +projectConfig.enableMap = false + function generateCompileFilesInfo(moduleInfos: Array) { const tempModuleInfos: ModuleInfo[] = Array(); moduleInfos.forEach((item) => { @@ -88,8 +92,23 @@ export function generateMergedAbc(moduleInfos: Array, entryInfos: Ma validateFilePathLength(cacheFilePath); const fileThreads = os.cpus().length < 16 ? os.cpus().length : 16; mkdirsSync(projectConfig.buildPath); - const genAbcCmd: string = - `${initAbcEnv().join(' ')} "@${filesInfoPath}" --npm-module-entry-list "${npmEntriesInfoPath}" --cache-file "${cacheFilePath}" --output "${outputABCPath}" --file-threads "${fileThreads}"`; + let genAbcCmd: string = + `${initAbcEnv().join(' ')} "@${filesInfoPath}" --npm-module-entry-list "${npmEntriesInfoPath}" --output "${outputABCPath}" --file-threads "${fileThreads}"`; + + projectConfig.inOldSymbolTablePath = projectConfig.projectRootPath; // temp symbol table path for hot patch + if (projectConfig.patch) { + let oldHapSymbolTable = path.join(projectConfig.inOldSymbolTablePath, PATCH_SYMBOL_TABLE); + genAbcCmd += ` --input-symbol-table "${oldHapSymbolTable}" --generate-patch`; + } + + if (!projectConfig.enableMap) { + genAbcCmd += ` --cache-file "${cacheFilePath}"`; + } else { + // when generating map, cache is forbiden to avoid uncomplete symbol table + let oldHapSymbolTable = path.join(projectConfig.inOldSymbolTablePath, PATCH_SYMBOL_TABLE); + genAbcCmd += ` --dump-symbol-table "${oldHapSymbolTable}"`; + } + logger.debug('gen abc cmd is: ', genAbcCmd); try { if (process.env.watchMode === 'true') { @@ -109,7 +128,13 @@ export function generateMergedAbc(moduleInfos: Array, entryInfos: Ma }); child.stderr.on('data', (data: any) => { - logger.debug(red, data.toString(), reset); + if (projectConfig.patch) { + let patchErr :string[] = + data.split(os.EOL).filter(line => line.includes("[Patch]") || line.includes("Error:")); + logger.error(red, patchErr.join(os.EOL), reset); + } else { + logger.debug(red, data.toString(), reset); + } }); } } catch (e) { diff --git a/compiler/src/pre_define.ts b/compiler/src/pre_define.ts index e356f095e..804579ef8 100644 --- a/compiler/src/pre_define.ts +++ b/compiler/src/pre_define.ts @@ -273,6 +273,7 @@ export const EXTNAME_CJS: string = '.cjs'; export const EXTNAME_D_TS: string = '.d.ts'; export const EXTNAME_ABC: string = '.abc'; export const EXTNAME_PROTO_BIN: string = '.protoBin'; +export const PATCH_SYMBOL_TABLE: string = "symbol.txt"; export const SUCCESS: number = 0; export const FAIL: number = 1; -- Gitee