From 5a9319446e5a6a6ad933ad2a8bdf1e3e32501e38 Mon Sep 17 00:00:00 2001 From: Aleksey Khoroshilov Date: Sat, 19 Nov 2022 12:52:30 +0700 Subject: [PATCH 1/3] Test command shouldn't update branding. --- build/commands/lib/build.js | 3 ++- build/commands/lib/test.js | 2 +- build/commands/lib/util.js | 7 +++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build/commands/lib/build.js b/build/commands/lib/build.js index dd4ea98ddd2c..112fe2d63923 100644 --- a/build/commands/lib/build.js +++ b/build/commands/lib/build.js @@ -23,7 +23,8 @@ const build = (buildConfig = config.defaultBuildConfig, options) => { config.update(options) checkVersionsMatch() - util.touchOverriddenFilesAndUpdateBranding() + util.touchOverriddenFiles() + util.updateBranding() if (config.xcode_gen_target) { util.generateXcodeWorkspace() diff --git a/build/commands/lib/test.js b/build/commands/lib/test.js index 27ed5891235e..59bd0a2415d9 100644 --- a/build/commands/lib/test.js +++ b/build/commands/lib/test.js @@ -107,7 +107,7 @@ const test = (passthroughArgs, suite, buildConfig = config.defaultBuildConfig, o } else { config.buildTarget = suite } - util.touchOverriddenFilesAndUpdateBranding() + util.touchOverriddenFiles() util.buildTarget() // Filter out upstream tests that are known to fail for Brave diff --git a/build/commands/lib/util.js b/build/commands/lib/util.js index 958f5e20de7d..79571924c5d2 100644 --- a/build/commands/lib/util.js +++ b/build/commands/lib/util.js @@ -405,7 +405,7 @@ const util = { } }, - touchOverriddenFiles: () => { + touchOverriddenChromiumSrcFiles: () => { console.log('touch original files overridden by chromium_src...') // Return true when original file of |file| should be touched. @@ -465,10 +465,9 @@ const util = { }) }, - touchOverriddenFilesAndUpdateBranding: () => { - util.touchOverriddenFiles() + touchOverriddenFiles: () => { + util.touchOverriddenChromiumSrcFiles() util.touchOverriddenVectorIconFiles() - util.updateBranding() }, // Chromium compares pre-installed midl files and generated midl files from IDL during the build to check integrity. From 3f7f9e9922678cfcb8b0d61b6ceb10851d22c5e0 Mon Sep 17 00:00:00 2001 From: Aleksey Khoroshilov Date: Sat, 19 Nov 2022 13:13:16 +0700 Subject: [PATCH 2/3] Touch overridden files in create_dist command. --- build/commands/lib/createDist.js | 1 + 1 file changed, 1 insertion(+) diff --git a/build/commands/lib/createDist.js b/build/commands/lib/createDist.js index 08c1288d9e04..6372ed10b6a2 100644 --- a/build/commands/lib/createDist.js +++ b/build/commands/lib/createDist.js @@ -6,6 +6,7 @@ const fs = require('fs-extra') const createDist = (buildConfig = config.defaultBuildConfig, options) => { config.buildConfig = buildConfig config.update(options) + util.touchOverriddenFiles() util.updateBranding() // On Android CI does two builds sequentially: for aab and for apk. // Symbols are uploaded after 2nd build, but we need to preserve the symbols From 67940dcb372dcbb5462786938380cff2e26a4463 Mon Sep 17 00:00:00 2001 From: Aleksey Khoroshilov Date: Sat, 19 Nov 2022 13:51:17 +0700 Subject: [PATCH 3/3] Don't replace BRANDING files twice. --- build/commands/lib/util.js | 48 +++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 27 deletions(-) diff --git a/build/commands/lib/util.js b/build/commands/lib/util.js index 79571924c5d2..2eae9886756f 100644 --- a/build/commands/lib/util.js +++ b/build/commands/lib/util.js @@ -252,6 +252,24 @@ const util = { fileMap.add([path.join(config.braveCoreDir, 'ui', 'webui', 'resources', 'css', 'text_defaults_md.css'), path.join(config.srcDir, 'ui', 'webui', 'resources', 'css', 'text_defaults_md.css')]) + let explicitSourceFiles = new Set() + if (process.platform === 'darwin') { + // Set proper mac app icon for channel to chrome/app/theme/mac/app.icns. + // Each channel's app icons are stored in brave/app/theme/$channel/app.icns. + // With this copying, we don't need to modify chrome/BUILD.gn for this. + const iconSource = path.join(braveAppDir, 'theme', 'brave', 'mac', config.channel, 'app.icns') + const iconDest = path.join(chromeAppDir, 'theme', 'brave', 'mac', 'app.icns') + explicitSourceFiles[iconDest] = iconSource + + // Set proper branding file. + let branding_file_name = 'BRANDING' + if (config.channel) + branding_file_name = branding_file_name + '.' + config.channel + const brandingSource = path.join(braveAppDir, 'theme', 'brave', branding_file_name) + const brandingDest = path.join(chromeAppDir, 'theme', 'brave', 'BRANDING') + explicitSourceFiles[brandingDest] = brandingSource + } + for (const [source, output] of fileMap) { if (!fs.existsSync(source)) { console.warn(`Warning: The following file-system entry was not found for copying contents to a chromium destination: ${source}. Consider removing the entry from the file-map, or investigating whether the correct source code reference is checked out.`) @@ -267,8 +285,9 @@ const util = { sourceFiles = [source] } - for (const sourceFile of sourceFiles) { - let destinationFile = path.join(output, path.relative(source, sourceFile)) + for (let sourceFile of sourceFiles) { + const destinationFile = path.join(output, path.relative(source, sourceFile)) + sourceFile = explicitSourceFiles[destinationFile] || sourceFile if (!fs.existsSync(destinationFile) || util.calculateFileChecksum(sourceFile) != util.calculateFileChecksum(destinationFile)) { fs.copySync(sourceFile, destinationFile) @@ -277,31 +296,6 @@ const util = { } } - if (process.platform === 'darwin') { - // Copy proper mac app icon for channel to chrome/app/theme/mac/app.icns. - // Each channel's app icons are stored in brave/app/theme/$channel/app.icns. - // With this copying, we don't need to modify chrome/BUILD.gn for this. - const iconSource = path.join(braveAppDir, 'theme', 'brave', 'mac', config.channel, 'app.icns') - const iconDest = path.join(chromeAppDir, 'theme', 'brave', 'mac', 'app.icns') - if (!fs.existsSync(iconDest) || - util.calculateFileChecksum(iconSource) != util.calculateFileChecksum(iconDest)) { - console.log('copy app icon') - fs.copySync(iconSource, iconDest) - } - - // Copy branding file - let branding_file_name = 'BRANDING' - if (config.channel) - branding_file_name = branding_file_name + '.' + config.channel - - const brandingSource = path.join(braveAppDir, 'theme', 'brave', branding_file_name) - const brandingDest = path.join(chromeAppDir, 'theme', 'brave', 'BRANDING') - if (!fs.existsSync(brandingDest) || - util.calculateFileChecksum(brandingSource) != util.calculateFileChecksum(brandingDest)) { - console.log('copy branding file') - fs.copySync(brandingSource, brandingDest) - } - } if (config.targetOS === 'android') { let braveOverwrittenFiles = new Set();