Skip to content

Commit

Permalink
Merge pull request #300 from RyanJarv/fixup
Browse files Browse the repository at this point in the history
Cleanup for #229
  • Loading branch information
RyanJarv authored Jun 18, 2018
2 parents 1448a6f + bebedae commit 09eb9b7
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 21 deletions.
2 changes: 1 addition & 1 deletion build/lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const build = (buildConfig = config.defaultBuildConfig, options) => {
util.updateBranding()
}

util.buildMuon('brave')
util.buildTarget()
}

module.exports = build
11 changes: 7 additions & 4 deletions build/lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const Config = function () {
this.buildConfig = this.defaultBuildConfig
this.projectNames = []
this.projects = {}
this.buildTarget = 'brave'
this.rootDir = path.join(path.dirname(__filename), '..')
this.scriptDir = path.join(this.rootDir, 'scripts')
this.depotToolsDir = path.join(this.rootDir, 'vendor', 'depot_tools')
Expand Down Expand Up @@ -181,7 +182,8 @@ Config.prototype.buildProjects = function () {
url: getNPMConfig(['projects', projectName, 'repository', 'url']),
gclientName: getNPMConfig(['projects', projectName, 'dir']),
dir: path.join(this.rootDir, getNPMConfig(['projects', projectName, 'dir'])),
custom_deps: packages.config.projects[projectName].custom_deps
custom_deps: packages.config.projects[projectName].custom_deps,
arg_name: projectName.replace('-', '_')
}
})
}
Expand Down Expand Up @@ -248,12 +250,13 @@ Config.prototype.update = function (options) {

this.projectNames.forEach((projectName) => {
// don't update refs for projects that have them
if (!this.projects[projectName].ref)
let project = this.projects[projectName]
if (!project.ref)
return

let ref = options[projectName + '_ref']
let ref = options[project.arg_name + '_ref']
if (ref && ref !== 'default' && ref !== '') {
this.projects[projectName].ref = ref
project.ref = ref
}
})
}
Expand Down
3 changes: 2 additions & 1 deletion build/lib/createDist.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const createDist = (buildConfig = config.defaultBuildConfig, options) => {
}

fs.removeSync(path.join(config.outputDir, 'dist'))
util.buildMuon('create_dist')
config.buildTarget = 'create_dist'
util.buildTarget()

renameLinuxDistr(options)
}
Expand Down
8 changes: 4 additions & 4 deletions build/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const config = require('./config')
const fs = require('fs-extra')

const runGClient = (args, options = {}) => {
if (options.verbose) args.push('--verbose')
if (config.gClientVerbose) args.push('--verbose')
options.cwd = options.cwd || config.rootDir
options = mergeWithDefault(options)
options.env.GCLIENT_FILE = config.gClientFile
Expand Down Expand Up @@ -73,12 +73,12 @@ const util = {
fs.copySync(path.join(braveAppDir, 'strings'), path.join(chromeComponentsDir, 'strings'))
},

buildMuon: (target = 'brave', options = config.defaultOptions) => {
console.log('building ' + target + '...')
buildTarget: (options = config.defaultOptions) => {
console.log('building ' + config.buildTarget + '...')

const args = util.buildArgsToString(config.buildArgs())
util.run('gn', ['gen', config.outputDir, '--args="' + args + '"'], options)
util.run('ninja', ['-C', config.outputDir, target], options)
util.run('ninja', ['-C', config.outputDir, config.buildTarget], options)
},

submoduleSync: (options = {}) => {
Expand Down
23 changes: 12 additions & 11 deletions build/scripts/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,40 @@ program
.option('--submodule_sync', 'run submodule sync')
.option('--init', 'initialize all dependencies')
.option('--all', 'update all projects')
projectNames.forEach((project) => {
project = project.replace('-', '_')
program.option('--' + project + '_ref <ref>', project + ' ref to checkout')
projectNames.forEach((name) => {
let project = config.projects[name]
program.option('--' + project.arg_name + '_ref <ref>', name + ' ref to checkout')
})

program.parse(process.argv)
config.update(program)

if (program.init || program.submodule_sync) {
util.submoduleSync({verbose: config.gClientVerbose})
util.submoduleSync()
}

if (program.init) {
util.buildGClientConfig({verbose: config.gClientVerbose})
util.buildGClientConfig()
}

if (program.init) {
util.gclientSync({verbose: config.gClientVerbose})
util.gclientSync()
}

let updatedVersion = false

projectNames.forEach((project) => {
if (program.init || program.all || program[project.replace('-', '_') + '_ref']) {
projectNames.forEach((name) => {
let project = config.projects[name]
if (program.init || program.all || program[project.arg_name + '_ref']) {
updatedVersion = true
util.setDepVersion(config.projects[project].dir, config.projects[project].ref)
util.setDepVersion(project.dir, project.ref)
}
})

if (updatedVersion || program.init || program.run_sync) {
util.gclientSync({verbose: config.gClientVerbose})
util.gclientSync()
}

if (updatedVersion || program.init || program.run_hooks) {
util.gclientRunhooks({verbose: config.gClientVerbose})
util.gclientRunhooks()
}

0 comments on commit 09eb9b7

Please sign in to comment.