Skip to content

Commit

Permalink
Merge pull request #2795 from /issues/2794
Browse files Browse the repository at this point in the history
add support for building/running signed app in development
  • Loading branch information
tmancey authored Jan 8, 2019
2 parents bf81cfa + f74b42e commit ddfba3c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
3 changes: 3 additions & 0 deletions build/commands/lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ const build = (buildConfig = config.defaultBuildConfig, options) => {
util.updateBranding()

util.buildTarget()
if (config.shouldSign()) {
util.signApp()
}
}

module.exports = build
20 changes: 9 additions & 11 deletions build/commands/lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const Config = function () {
this.buildConfig = this.defaultBuildConfig
this.projectNames = []
this.projects = {}
this.signTarget = 'sign_app'
this.buildTarget = 'brave'
this.rootDir = path.join(path.dirname(__filename), '..')
this.scriptDir = path.join(this.rootDir, 'scripts')
Expand All @@ -45,6 +46,7 @@ const Config = function () {
this.mac_signing_identifier = getNPMConfig(['mac_signing_identifier']) || ''
this.mac_installer_signing_identifier = getNPMConfig(['mac_installer_signing_identifier']) || ''
this.mac_signing_keychain = getNPMConfig(['mac_signing_keychain']) || 'login'
this.mac_signing_output_prefix = 'signing'
this.channel = ''
this.sccache = getNPMConfig(['sccache'])
this.braveReferralsApiKey = getNPMConfig(['brave_referrals_api_key']) || ''
Expand Down Expand Up @@ -93,6 +95,7 @@ Config.prototype.buildArgs = function () {
args.mac_signing_identifier = this.mac_signing_identifier
args.mac_installer_signing_identifier = this.mac_installer_signing_identifier
args.mac_signing_keychain = this.mac_signing_keychain
args.mac_signing_output_prefix = this.mac_signing_output_prefix
}

if (process.platform === 'win32' && this.build_omaha) {
Expand Down Expand Up @@ -132,6 +135,12 @@ Config.prototype.buildArgs = function () {
return args
}

Config.prototype.shouldSign = function () {
// it doesn't make sense to sign debug builds because the restrictions on loading
// dynamic libs prevents them from working anyway
return this.mac_signing_identifier !== '' && this.buildConfig === 'Release'
}

Config.prototype.prependPath = function (oldPath, addPath) {
let newPath = oldPath.split(path.delimiter)
newPath.unshift(addPath)
Expand Down Expand Up @@ -310,17 +319,6 @@ Config.prototype.update = function (options) {
})
}

if (process.platform === 'darwin') {
Config.prototype.macAppName = function () {
let app_name = 'Brave\\ Browser'
if (this.channel) {
// Capitalize channel name and append it to make app name like Brave Browser Beta
app_name = app_name + '\\ ' + this.channel.charAt(0).toUpperCase() + this.channel.slice(1)
}
return app_name
}
}

Object.defineProperty(Config.prototype, 'defaultOptions', {
get: function () {
let env = Object.assign({}, process.env)
Expand Down
8 changes: 7 additions & 1 deletion build/commands/lib/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,13 @@ const start = (passthroughArgs, buildConfig = config.defaultBuildConfig, options
let outputPath = options.output_path
if (!outputPath) {
if (process.platform === 'darwin') {
outputPath = path.join(config.outputDir, config.macAppName() + '.app', 'Contents', 'MacOS', config.macAppName())
let outputDir = config.outputDir
if (config.shouldSign()) {
outputDir = path.join(outputDir, config.mac_signing_output_prefix)
}
outputPath = path.join(outputDir,
'Brave\\ Browser\\ Development.app', 'Contents', 'MacOS',
'Brave\\ Browser\\ Development')
} else if (process.platform === 'win32') {
outputPath = path.join(config.outputDir, 'brave.exe')
} else {
Expand Down
6 changes: 6 additions & 0 deletions build/commands/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ const util = {
fs.copySync(srcDir, dstDir)
},

signApp: (options = config.defaultOptions) => {
console.log('signing ...')

util.run('ninja', ['-C', config.outputDir, config.signTarget], options)
},

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

Expand Down

0 comments on commit ddfba3c

Please sign in to comment.