Skip to content

Commit

Permalink
Merge branch 'master' into reword-website-section
Browse files Browse the repository at this point in the history
  • Loading branch information
srirambv authored Jun 27, 2018
2 parents 2c320a3 + 70bafa0 commit 9e40070
Show file tree
Hide file tree
Showing 16 changed files with 282 additions and 60 deletions.
15 changes: 9 additions & 6 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,28 @@ PLEASE USE THE TEMPLATE BELOW TO PROVIDE INFORMATION ABOUT THE ISSUE.
INSUFFICIENT INFO WILL GET THE ISSUE CLOSED. IT WILL ONLY BE REOPENED AFTER SUFFICIENT INFO IS PROVIDED-->

## Description
<!--Proivde a brief description of the issue-->
<!--Provide a brief description of the issue-->


## Steps to Reproduce
<!--Please add a series of steps to reproduce the issue-->

1.
2.
3.

## Actual result:
<!-- Please add screenshots if needed -->
## Actual result:
<!--Please add screenshots if needed-->


## Expected result:


## Reproduces how often:
<!--[Easily reproduced/Intermittent issue/No steps to reproduce]-->


## Brave version (about:brave info)
## Brave version (about:brave info)
<!--Please use the clipboard button in about:brave and paste the complete information here-->


Expand All @@ -31,8 +34,8 @@ INSUFFICIENT INFO WILL GET THE ISSUE CLOSED. IT WILL ONLY BE REOPENED AFTER SUFF


### Website problems only:
- Does the issue resolve itself when disabling Brave Shields?
- Is the issue reproducible on the latest version of Chrome?
- Does the issue resolve itself when disabling Brave Shields?
- Is the issue reproducible on the latest version of Chrome?

### Additional Information
<!--Any additional information, related issues, extra QA steps, configuration or data that might be necessary to reproduce the issue-->
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ src
npm-debug.log
.gclient
.sccache
**.sw[po]
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ RUN apt-get update && apt-get install -y \
libgnome-keyring-dev \
libnotify-dev \
libssl-dev \
lsb-release \
ninja-build \
python-pip \
sudo
Expand Down
50 changes: 49 additions & 1 deletion lib/build.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,63 @@
const config = require('../lib/config')
const util = require('../lib/util')
const path = require('path')
const fs = require('fs-extra')

const touchOverriddenFiles = (filter) => {
console.log('touch original files overridden by chromium_src...')

// Return true when original file of |file| should be touched.
const applyFileFilter = (file) => {
// Exclude test files
if (file.indexOf('browsertest') > -1 || file.indexOf('unittest') > -1) { return false }

// Only includes cc and h files.
const ext = path.extname(file)
if (ext !== '.cc' && ext !== '.h' && ext !== '.mm') { return false }

// Touch all overridden files.
if (filter === '*') { return true }

return file.match(filter)
}

const walkSync = (dir, filelist = []) => {
fs.readdirSync(dir).forEach(file => {
if (fs.statSync(path.join(dir, file)).isDirectory()) {
filelist = walkSync(path.join(dir, file), filelist)
} else if (applyFileFilter(file)) {
filelist = filelist.concat(path.join(dir, file))
}
})
return filelist
}

const chromiumSrcDir = path.join(config.srcDir, 'brave', 'chromium_src')
var sourceFiles = walkSync(chromiumSrcDir)

// Touch original files by updating mtime.
const chromiumSrcDirLen = chromiumSrcDir.length
sourceFiles.forEach(file => {
const targetOriginalFile = path.join(config.srcDir, file.slice(chromiumSrcDirLen))
const date = new Date()
fs.utimesSync(targetOriginalFile, date, date)
console.log(targetOriginalFile + ' is touched.')
})
}

const build = (buildConfig = config.defaultBuildConfig, options) => {
config.buildConfig = buildConfig
config.update(options)

if (options.touch_overridden_files) {
touchOverriddenFiles(options.touch_overridden_files)
}

if (!options.no_branding_update) {
util.updateBranding()
}

util.buildMuon()
util.buildTarget()
}

module.exports = build
13 changes: 13 additions & 0 deletions lib/chromiumRebaseL10n.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

const config = require('../lib/config')
const util = require('../lib/util')
const {rebaseBraveStringFilesOnChromiumL10nFiles} = require('./l10nUtil')

const chromiumRebaseL10n = (options) => {
rebaseBraveStringFilesOnChromiumL10nFiles()
}

module.exports = chromiumRebaseL10n
61 changes: 47 additions & 14 deletions 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 All @@ -25,16 +26,22 @@ const Config = function () {
this.resourcesDir = path.join(this.rootDir, 'resources')
this.defaultGClientFile = path.join(this.rootDir, '.gclient')
this.gClientFile = process.env.BRAVE_GCLIENT_FILE || this.defaultGClientFile
this.gClientVerbose = getNPMConfig(['gclient_verbose']) || false
this.gClientCacheDir = getNPMConfig(['gclient_cachedir']) || false
this.targetArch = 'x64'
this.gypTargetArch = 'x64'
this.officialBuild = true
this.debugBuild = JSON.parse(getNPMConfig(['brave_debug_build']) || false)
this.googleApiKey = getNPMConfig(['brave_google_api_key']) || 'AIzaSyAQfxPJiounkhOjODEO5ZieffeBv6yft2Q'
this.braveGoogleApiKey = getNPMConfig(['brave_google_api_key']) || 'AIzaSyAQfxPJiounkhOjODEO5ZieffeBv6yft2Q'
this.googleApiKey = getNPMConfig(['google_api_key']) || 'AIzaSyAH90V94EcZBP5oH7oc-mXQrSKgASVxER8'
this.googleApiEndpoint = getNPMConfig(['brave_google_api_endpoint']) || 'https://www.googleapis.com/geolocation/v1/geolocate?key='
this.safeBrowsingApiEndpoint = getNPMConfig(['safe_browsing_api_endpoint']) || 'safebrowsing.brave.com'
this.buildProjects()
const braveCoreDirPackage = path.join(this.projects['brave-core'].dir, 'package')
this.braveCoreVersion = getNPMConfig(['brave_version']) || (fs.existsSync(braveCoreDirPackage + '.json') && require(braveCoreDirPackage)['version']) || ''
this.releaseTag = this.braveCoreVersion.split('+')[0]
this.mac_signing_identifier = getNPMConfig(['mac_signing_identifier']) || ''
this.mac_signing_keychain = getNPMConfig(['mac_signing_keychain']) || 'login'
this.channel = ''
}

Expand All @@ -44,7 +51,11 @@ Config.prototype.buildArgs = function () {
version_parts = version_parts.split('.')

let args = {
safe_browsing_mode: 1,
root_extra_deps: [ "//brave" ],
// TODO: Re-enable when chromium_src overrides work for files in relative
// paths like widevine_cmdm_compoennt_installer.cc
// use_jumbo_build: !this.officialBuild,
is_component_build: this.buildConfig !== 'Release',
proprietary_codecs: true,
ffmpeg_branding: "Chrome",
Expand All @@ -56,17 +67,20 @@ Config.prototype.buildArgs = function () {
is_debug: this.buildConfig !== 'Release',
dcheck_always_on: this.buildConfig !== 'Release',
brave_channel: this.channel,
brave_google_api_key: this.googleApiKey,
brave_google_api_endpoint: this.googleApiEndpoint,
brave_product_name: getNPMConfig(['brave_product_name']) || "brave-core",
brave_project_name: getNPMConfig(['brave_project_name']) || "brave-core",
brave_version_major: version_parts[0],
brave_version_minor: version_parts[1],
brave_version_build: version_parts[2],
google_api_key: this.googleApiKey,
brave_google_api_key: this.braveGoogleApiKey,
brave_google_api_endpoint: this.googleApiEndpoint,
brave_product_name: getNPMConfig(['brave_product_name']) || "brave-core",
brave_project_name: getNPMConfig(['brave_project_name']) || "brave-core",
brave_version_major: version_parts[0],
brave_version_minor: version_parts[1],
brave_version_build: version_parts[2],
safebrowsing_api_endpoint: this.safeBrowsingApiEndpoint,
}

if (process.platform === 'darwin') {
args.mac_signing_identifier = getNPMConfig(['mac_signing_identifier']) || ''
args.mac_signing_identifier = this.mac_signing_identifier
args.mac_signing_keychain = this.mac_signing_keychain
}

if (this.debugBuild) {
Expand Down Expand Up @@ -171,7 +185,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 All @@ -197,13 +212,17 @@ Config.prototype.update = function (options) {
}

if (options.brave_google_api_key) {
this.googleApiKey = options.brave_google_api_key
this.braveGoogleApiKey = options.brave_google_api_key
}

if (options.brave_google_api_endpoint) {
this.googleApiEndpoint = options.brave_google_api_endpoint
}

if (options.safebrowsing_api_endpoint) {
this.safeBrowsingApiEndpoint = options.safebrowsing_api_endpoint
}

if (options.debug_build !== null && options.debug_build !== undefined) {
this.debugBuild = JSON.parse(options.debug_build)
} else {
Expand All @@ -223,14 +242,27 @@ Config.prototype.update = function (options) {
if (options.channel !== 'release')
this.channel = options.channel

if (options.mac_signing_identifier)
this.mac_signing_identifier = options.mac_signing_identifier

if (options.mac_signing_keychain)
this.mac_signing_keychain = options.mac_signing_keychain

if (options.gclient_verbose)
this.gClientVerbose = options.gclient_verbose

if (options.gclient_cachedir)
this.gClientCacheDir = options.gclient_cachedir

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 Expand Up @@ -262,6 +294,7 @@ Object.defineProperty(Config.prototype, 'defaultOptions', {
stdio: 'inherit',
cwd: this.srcDir,
shell: true,
git_cwd: '.',
}
},
})
Expand Down
10 changes: 4 additions & 6 deletions lib/createDist.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@ const util = require('../lib/util')
const path = require('path')
const fs = require('fs-extra')

const createDist = (options) => {
const createDist = (buildConfig = config.defaultBuildConfig, options) => {
config.buildConfig = buildConfig
config.update(options)

let cmdOptions = config.defaultOptions
const args = util.buildArgsToString(config.buildArgs())

if (!options.no_branding_update) {
util.updateBranding()
}

fs.removeSync(path.join(config.outputDir, 'dist'))
util.run('gn', ['gen', config.outputDir, '--args="' + args + '"'], cmdOptions)
util.run('ninja', ['-C', config.outputDir, 'create_dist'], cmdOptions)
config.buildTarget = 'create_dist'
util.buildTarget()

renameLinuxDistr(options)
}
Expand Down
73 changes: 68 additions & 5 deletions lib/l10nUtil.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,78 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

const path = require('path')
const fs = require('fs')

const srcDir = path.resolve(path.join(__dirname, '..', 'src'))

// Brave string paths
const braveStringsPath = path.resolve(path.join(srcDir, 'brave', 'app', 'brave_strings.grd'))
const braveSettingsPartPath = path.resolve(path.join(srcDir, 'brave', 'app', 'settings_brave_strings.grdp'))
const braveComponentsStringsPath = path.resolve(path.join(srcDir, 'brave', 'app', 'components_brave_strings.grd'))
const braveExtensionMessagesPath = path.resolve(path.join(srcDir, 'brave', 'vendor', 'brave-extension', 'app', '_locales', 'en_US', 'messages.json'))
const braveSpecificGeneratedResourcesPath = path.resolve(path.join(srcDir, 'brave', 'app', 'brave_generated_resources.grd'))
const braveComponentsResourcesPath = path.resolve(path.join(srcDir, 'brave', 'components', 'resources', 'brave_components_resources.grd'))

const braveGeneratedResourcesPath = path.resolve(path.join(srcDir, 'brave', 'app', 'generated_resources.grd'))
const braveBookmarksPartPath = path.resolve(path.join(srcDir, 'brave', 'app', 'bookmarks_strings.grdp'))
const braveMediaRouterPartPath = path.resolve(path.join(srcDir, 'brave', 'app', 'media_router_strings.grdp'))
const braveSettingsStringsPartPath = path.resolve(path.join(srcDir, 'brave', 'app', 'settings_strings.grdp'))
const braveMdExtensionsPartPath = path.resolve(path.join(srcDir, 'brave', 'app', 'md_extensions_strings.grdp'))

const braveExtensionsResourcesPath = path.resolve(path.join(srcDir, 'brave', 'browser', 'resources', 'md_extensions', 'extensions_resources.grd'))
const braveSettingsResourcesPath = path.resolve(path.join(srcDir, 'brave', 'browser', 'resources', 'settings', 'settings_resources.grd'))

// Chromium string paths
const chromiumStringsPath = path.resolve(path.join(srcDir, 'chrome', 'app', 'chromium_strings.grd'))
const chroimumSettingsPartPath = path.resolve(path.join(srcDir, 'chrome', 'app', 'settings_chromium_strings.grdp'))
const chromiumComponentsStringsPath = path.resolve(path.join(srcDir, 'components', 'components_chromium_strings.grd'))

const chromiumGeneratedResourcesPath = path.resolve(path.join(srcDir, 'chrome', 'app', 'generated_resources.grd'))
const chromiumBookmarksPartPath = path.resolve(path.join(srcDir, 'chrome', 'app', 'bookmarks_strings.grdp'))
const chromiumMediaRouterPartPath = path.resolve(path.join(srcDir, 'chrome', 'app', 'media_router_strings.grdp'))
const chromiumSettingsStringsPartPath = path.resolve(path.join(srcDir, 'chrome', 'app', 'settings_strings.grdp'))
const chromiumMdExtensionsPartPath = path.resolve(path.join(srcDir, 'chrome', 'app', 'md_extensions_strings.grdp'))

const chromiumExtensionsResourcesPath = path.resolve(path.join(srcDir, 'chrome', 'browser', 'resources', 'md_extensions', 'extensions_resources.grd'))
const chromiumSettingsResourcesPath = path.resolve(path.join(srcDir, 'chrome', 'browser', 'resources', 'settings', 'settings_resources.grd'))

module.exports.getSourceStringPaths = () => {
return [
path.resolve(path.join(srcDir, 'brave', 'vendor', 'brave-extension', 'app', '_locales', 'en_US', 'messages.json')),
path.resolve(path.join(srcDir, 'brave', 'app', 'brave_strings.grd')),
path.resolve(path.join(srcDir, 'brave', 'app', 'components_brave_strings.grd')),
path.resolve(path.join(srcDir, 'brave', 'components', 'resources', 'brave_components_resources.grd'))
braveStringsPath,
braveComponentsStringsPath,
braveExtensionMessagesPath,
braveSpecificGeneratedResourcesPath,
braveComponentsResourcesPath,
braveGeneratedResourcesPath,
// No strings for now, uncomment if strings are added
// path.resolve(path.join(srcDir, 'brave', 'browser', 'resources', 'brave_extension.grd')),
// path.resolve(path.join(srcDir, 'brave', 'common', 'extensions', 'api', 'brave_api_resources.grd')),
]

}

module.exports.rebaseBraveStringFilesOnChromiumL10nFiles = (path) =>
Object.entries({
[chromiumStringsPath]: braveStringsPath,
[chroimumSettingsPartPath]: braveSettingsPartPath,
[chromiumComponentsStringsPath]: braveComponentsStringsPath,
[chromiumGeneratedResourcesPath]: braveGeneratedResourcesPath,
[chromiumBookmarksPartPath]: braveBookmarksPartPath,
[chromiumMediaRouterPartPath]: braveMediaRouterPartPath,
[chromiumSettingsStringsPartPath]: braveSettingsStringsPartPath,
[chromiumMdExtensionsPartPath]: braveMdExtensionsPartPath,
[chromiumExtensionsResourcesPath]: braveExtensionsResourcesPath,
[chromiumSettingsResourcesPath]: braveSettingsResourcesPath
}).forEach(([sourcePath, destPath]) =>
fs.writeFileSync(destPath,
fs.readFileSync(sourcePath, 'utf8')
.replace('<structure name="IDR_MD_EXTENSIONS_SIDEBAR_HTML"', '<structure name="IDR_MD_EXTENSIONS_SIDEBAR_HTML" preprocess="true"')
.replace('<structure name="IDR_SETTINGS_APPEARANCE_FONTS_PAGE_HTML"', '<structure name="IDR_SETTINGS_APPEARANCE_FONTS_PAGE_HTML" preprocess="true"')
.replace('<structure name="IDR_SETTINGS_PASSWORDS_SECTION_HTML"', '<structure name="IDR_SETTINGS_PASSWORDS_SECTION_HTML" preprocess="true"')
.replace(/settings_chromium_strings.grdp/g, 'settings_brave_strings.grdp')
.replace(/The Chromium Authors/g, 'Brave Software Inc')
.replace(/Google Chrome/g, 'Brave')
.replace(/Chromium/g, 'Brave')
.replace(/Chrome/g, 'Brave')
.replace(/Google/g, 'Brave'), 'utf8'))
3 changes: 3 additions & 0 deletions lib/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ const start = (buildConfig = config.defaultBuildConfig, options) => {
if (options.disable_brave_extension) {
braveArgs.push('--disable-brave-extension')
}
if (options.disable_pdfjs_extension) {
braveArgs.push('--disable-pdfjs-extension')
}

let cmdOptions = {
stdio: 'inherit',
Expand Down
Loading

0 comments on commit 9e40070

Please sign in to comment.