Skip to content

Commit

Permalink
Don't replace BRANDING files twice.
Browse files Browse the repository at this point in the history
  • Loading branch information
goodov committed Nov 19, 2022
1 parent 3f7f9e9 commit 67940dc
Showing 1 changed file with 21 additions and 27 deletions.
48 changes: 21 additions & 27 deletions build/commands/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.`)
Expand All @@ -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)
Expand All @@ -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();
Expand Down

0 comments on commit 67940dc

Please sign in to comment.