From 0a71dc89de5ce607b6e70fb0fc0d87ba2caa9967 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=9F=E6=88=98?= <40414978+PatriceJiang@users.noreply.github.com> Date: Tue, 5 Jul 2022 15:41:01 +0800 Subject: [PATCH] V3.6 fix warning log & space in path (#11851) --- .../native-pack-tool/source/base/default.ts | 4 ++-- .../native-pack-tool/source/platforms/ios.ts | 12 +++++------ .../native-pack-tool/source/platforms/mac.ts | 8 ++++---- scripts/native-pack-tool/source/utils.ts | 20 ++++++++++++++----- 4 files changed, 27 insertions(+), 17 deletions(-) diff --git a/scripts/native-pack-tool/source/base/default.ts b/scripts/native-pack-tool/source/base/default.ts index 36ddc994d9..a5ca1d9c90 100644 --- a/scripts/native-pack-tool/source/base/default.ts +++ b/scripts/native-pack-tool/source/base/default.ts @@ -133,7 +133,7 @@ export abstract class NativePackTool { protected tryReadProjectTemplateVersion(): { version: string, skipCheck: boolean | undefined } | null { const versionJsonPath = this.projEngineVersionPath; if (!fs.existsSync(versionJsonPath)) { - console.warn(`${versionJsonPath} not exists`); + console.log(`warning: ${versionJsonPath} not exists`); return null; } try { @@ -255,7 +255,7 @@ export abstract class NativePackTool { const newerThanEngineVersion = this.versionParser.parse(`>${engineVersion}`); if (newerThanEngineVersion.match(projEngineVersion)) { - console.warn(`warning: ${projEngineVersion} is newer than engine version ${engineVersion}`); + console.log(`warning: ${projEngineVersion} is newer than engine version ${engineVersion}`); } return true; } diff --git a/scripts/native-pack-tool/source/platforms/ios.ts b/scripts/native-pack-tool/source/platforms/ios.ts index 70370ac2ec..b43668fd2e 100644 --- a/scripts/native-pack-tool/source/platforms/ios.ts +++ b/scripts/native-pack-tool/source/platforms/ios.ts @@ -98,7 +98,7 @@ export class IOSPackTool extends MacOSPackTool { this.appendCmakeResDirArgs(ext); const ver = toolHelper.getXcodeMajorVerion() >= 12 ? "12" : "1"; - await toolHelper.runCmake(['-S', `${this.paths.platformTemplateDirInPrj}`, '-GXcode', `-B${nativePrjDir}`, '-T', `buildsystem=${ver}`, + await toolHelper.runCmake(['-S', `"${this.paths.platformTemplateDirInPrj}"`, '-GXcode', `-B"${nativePrjDir}"`, '-T', `buildsystem=${ver}`, '-DCMAKE_SYSTEM_NAME=iOS'].concat(ext)); await this.skipUpdateXcodeProject(); @@ -137,7 +137,7 @@ export class IOSPackTool extends MacOSPackTool { } } else { - const projCompileParams = `--build ${nativePrjDir} --config ${this.params.debug ? 'Debug' : 'Release'} -- -allowProvisioningUpdates -quiet`; + const projCompileParams = `--build "${nativePrjDir}" --config ${this.params.debug ? 'Debug' : 'Release'} -- -allowProvisioningUpdates -quiet`; if (options.iphoneos) { await toolHelper.runCmake([projCompileParams, '-sdk', 'iphoneos', `-arch arm64`]); } @@ -269,7 +269,7 @@ export class IOSPackTool extends MacOSPackTool { async runIosDevice(): Promise { const buildDir = this.paths.nativePrjDir; - const foundApps = execSync(`find ${buildDir} -name "*.app"`) + const foundApps = execSync(`find "${buildDir}" -name "*.app"`) .toString('utf-8') .split('\n') .filter((x) => x.trim().length > 0); @@ -281,7 +281,7 @@ export class IOSPackTool extends MacOSPackTool { if (foundApps.length > 0) { const cwd = fs.mkdtempSync(ps.join(os.tmpdir(), this.params.projectName)); await cchelper.runCmd( - 'xcrun', ['xctrace', 'record', '--template', `'App Launch'`, '--device', `'${deviceId}'`, '--launch', '--', `${foundApps[0]}`], + 'xcrun', ['xctrace', 'record', '--template', `'App Launch'`, '--device', `'${deviceId}'`, '--launch', '--', `"${foundApps[0]}"`], false, cwd); } return true; @@ -294,7 +294,7 @@ export class IOSPackTool extends MacOSPackTool { console.log(` - build dir ${buildDir} - simId ${simId}`); console.log(` - bundle id ${bundleId}`); - const foundApps = execSync(`find ${buildDir} -name "*.app"`) + const foundApps = execSync(`find "${buildDir}" -name "*.app"`) .toString('utf-8') .split('\n') .filter((x) => x.trim().length > 0); @@ -305,7 +305,7 @@ export class IOSPackTool extends MacOSPackTool { 'open', ['`xcode-select -p`/Applications/Simulator.app'], true); await cchelper.runCmd('xcrun', ['simctl', 'boot', simId], true); await cchelper.runCmd( - 'xcrun', ['simctl', 'install', simId, foundApps[0].trim()], false); + 'xcrun', ['simctl', 'install', simId, `"${foundApps[0].trim()}"`], false); await cchelper.runCmd( 'xcrun', ['simctl', 'launch', simId, `"${bundleId}"`], false); } diff --git a/scripts/native-pack-tool/source/platforms/mac.ts b/scripts/native-pack-tool/source/platforms/mac.ts index f93ebc6afe..b946ee59a1 100644 --- a/scripts/native-pack-tool/source/platforms/mac.ts +++ b/scripts/native-pack-tool/source/platforms/mac.ts @@ -33,8 +33,8 @@ export class MacPackTool extends MacOSPackTool { } const ver = toolHelper.getXcodeMajorVerion() >= 12 ? "12" : "1"; - const cmakeArgs = ['-S', `${this.paths.platformTemplateDirInPrj}`, '-GXcode', '-T', `buildsystem=${ver}`, - `-B${nativePrjDir}`, '-DCMAKE_SYSTEM_NAME=Darwin']; + const cmakeArgs = ['-S', `"${this.paths.platformTemplateDirInPrj}"`, '-GXcode', '-T', `buildsystem=${ver}`, + `-B"${nativePrjDir}"`, '-DCMAKE_SYSTEM_NAME=Darwin']; this.appendCmakeResDirArgs(cmakeArgs); await toolHelper.runCmake(cmakeArgs); @@ -47,7 +47,7 @@ export class MacPackTool extends MacOSPackTool { const nativePrjDir = this.paths.nativePrjDir; const platform = this.isAppleSilicon() ? `-arch arm64` : `-arch x86_64`; - await toolHelper.runCmake(["--build", `${nativePrjDir}`, "--config", this.params.debug ? 'Debug' : 'Release', "--", "-quiet", platform]); + await toolHelper.runCmake(["--build", `"${nativePrjDir}"`, "--config", this.params.debug ? 'Debug' : 'Release', "--", "-quiet", platform]); return true; } @@ -59,7 +59,7 @@ export class MacPackTool extends MacOSPackTool { private macOpen(app: string) { return new Promise((resolve, reject) => { console.log(`open ${app}`); - const cp = spawn(`open`, [app], { + const cp = spawn(`open`, [`"${app}"`], { shell: true, env: process.env, }); diff --git a/scripts/native-pack-tool/source/utils.ts b/scripts/native-pack-tool/source/utils.ts index e080016198..3407525135 100644 --- a/scripts/native-pack-tool/source/utils.ts +++ b/scripts/native-pack-tool/source/utils.ts @@ -90,7 +90,7 @@ export class cchelper { await this.copyFileAsync(srcDir, dst); } catch (e) { await this.delay(10); - // console.warn(`error: retry copying ${srcDir} -> to ${dst} ... ${e}`); + // console.log(`error: retry copying ${srcDir} -> to ${dst} ... ${e}`); await this.copyFileAsync(srcDir, dst); } } @@ -146,7 +146,7 @@ export class cchelper { if (fs.existsSync(srcFile)) { copyAsync(srcFile, ps.join(dstDir, f)); } else { - console.warn(`warning: copyFile: ${srcFile} not exists!`); + console.log(`warning: copyFile: ${srcFile} not exists!`); } } if (files.length === 0 && runningTasks === 0) { @@ -359,7 +359,7 @@ export class cchelper { static checkJavaHome(): boolean { if (!process.env.JAVA_HOME) { - console.warn('$JAVA_HOME is not set!'); + console.log('warning: $JAVA_HOME is not set!'); } const javaPath = cchelper.which('java'); if (!javaPath) { @@ -442,10 +442,20 @@ export const toolHelper = { shell: true, }); cp.stdout.on('data', (data: any) => { - console.log(`[cmake] ${iconv.decode(data, 'gbk').toString()}`); + const msg = iconv.decode(data, 'gbk').toString(); + if(/warning/i.test(msg)) { + console.warn(`[cmake-warn] ${msg}`); + } else { + console.log(`[cmake] ${msg}`); + } }); cp.stderr.on('data', (data: any) => { - console.error(`[cmake-err] ${iconv.decode(data, 'gbk').toString()}`); + const msg = iconv.decode(data, 'gbk').toString(); + if(/CMake Warning/.test(msg) || /warning/i.test(msg)) { + console.warn(`[cmake-warn] ${msg}`); + }else{ + console.error(`[cmake-err] ${msg}`); + } }); cp.on('close', (code: number, sig: any) => { if (code !== 0) {