Skip to content

Commit

Permalink
Update build configurations to latest
Browse files Browse the repository at this point in the history
  • Loading branch information
zcbenz committed Sep 19, 2020
1 parent 850d5dc commit dc2681f
Show file tree
Hide file tree
Showing 109 changed files with 2,228 additions and 1,717 deletions.
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
- job: windows_build
displayName: 'Build for Windows'
pool:
vmImage: 'VS2017-Win2016'
vmImage: 'windows-2019'
strategy:
matrix:
x64:
Expand Down
11 changes: 11 additions & 0 deletions build/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import("//build/buildflag_header.gni")
import("//build/config/chrome_build.gni")
import("//build/config/chromecast_build.gni")
import("//build/config/chromeos/args.gni")
import("//build/config/chromeos/ui_mode.gni")

source_set("buildflag_header_h") {
sources = [ "buildflag.h" ]
Expand All @@ -31,3 +33,12 @@ buildflag_header("chromecast_buildflags") {

flags = [ "IS_CHROMECAST=$is_chromecast" ]
}

buildflag_header("chromeos_buildflags") {
header = "chromeos_buildflags.h"

flags = [
"IS_CHROMEOS_DEVICE=$is_chromeos_device",
"IS_LACROS=$chromeos_is_browser_only",
]
}
4 changes: 4 additions & 0 deletions build/apple/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
mark@chromium.org
rohitrao@chromium.org
rsesek@chromium.org
sdefresne@chromium.org
12 changes: 12 additions & 0 deletions build/apple/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# About

`//build/apple` contains:
* GN templates and configurations shared by Apple platforms
* Python build scripts shared by Apple platforms

This directory should only contain templates, configurations and scripts
that are used exclusively on Apple platforms (currently iOS and macOS).
They must also be independent of the specific platform.

If a template, configuration or script is limited to only iOS or macOS,
then they should instead be located in `//build/ios` or `//build/mac`.
86 changes: 86 additions & 0 deletions build/apple/tweak_info_plist.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/util/lastchange.gni")

# Template to run the tweak_info_plist.py script on a plist.
#
# Arguments:
#
# info_plist:
# (optional), string, the plist to tweak.
#
# info_plists:
# (optional), list of string, the plist files to merge and tweak.
#
# args:
# (optional), list of string, the arguments to pass to the
# tweak_info_plist.py script.
#
# Callers should use get_target_outputs() to get the output name. One of
# info_plist or info_plists must be specified.
template("tweak_info_plist") {
_output_name = "$target_gen_dir/${target_name}_tweaked.plist"

if (defined(invoker.info_plists)) {
assert(!defined(invoker.info_plist),
"Cannot have both info_plist and info_plists for $target_name")

_source_name = "$target_gen_dir/${target_name}_merged.plist"
_deps = [ ":" + target_name + "_merge_plist" ]

action(target_name + "_merge_plist") {
forward_variables_from(invoker,
[
"testonly",
"deps",
])
script = "//build/config/mac/plist_util.py"
sources = invoker.info_plists
outputs = [ _source_name ]
args = [
"merge",
"-f=xml1",
"-o=" + rebase_path(_source_name, root_build_dir),
] + rebase_path(invoker.info_plists, root_build_dir)
}
} else {
assert(defined(invoker.info_plist),
"The info_plist must be specified in $target_name")

_source_name = invoker.info_plist
_deps = []
if (defined(invoker.deps)) {
_deps += invoker.deps
}
}

action(target_name) {
forward_variables_from(invoker,
[
"args",
"testonly",
])
script = "//build/apple/tweak_info_plist.py"
inputs = [
script,
"//build/util/version.py",
lastchange_file,
"//chrome/VERSION",
]
sources = [ _source_name ]
outputs = [ _output_name ]
if (!defined(args)) {
args = []
}
args += [
"--plist",
rebase_path(_source_name, root_build_dir),
"--output",
rebase_path(_output_name, root_build_dir),
"--platform=$current_os",
]
deps = _deps
}
}
155 changes: 93 additions & 62 deletions build/mac/tweak_info_plist.py → build/apple/tweak_info_plist.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ def _GetOutputNoError(args):
the child (like file not found), the exception will be caught and (None, 1)
will be returned to mimic quiet failure."""
try:
proc = subprocess.Popen(args, stdout=subprocess.PIPE,
proc = subprocess.Popen(args,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
except OSError:
return (None, 1)
Expand Down Expand Up @@ -101,17 +102,18 @@ def _GetVersion(version_format, values, overrides=None):
return result


def _AddVersionKeys(
plist, version_format_for_key, version=None, overrides=None):
def _AddVersionKeys(plist, version_format_for_key, version=None,
overrides=None):
"""Adds the product version number into the plist. Returns True on success and
False on error. The error will be printed to stderr."""
if not version:
# Pull in the Chrome version number.
VERSION_TOOL = os.path.join(TOP, 'build/util/version.py')
VERSION_FILE = os.path.join(TOP, 'chrome/VERSION')
(stdout, retval) = _GetOutput([
VERSION_TOOL, '-f', VERSION_FILE,
'-t', '@MAJOR@.@MINOR@.@BUILD@.@PATCH@'])
VERSION_TOOL, '-f', VERSION_FILE, '-t',
'@MAJOR@.@MINOR@.@BUILD@.@PATCH@'
])

# If the command finished with a non-zero return code, then report the
# error up.
Expand Down Expand Up @@ -144,8 +146,8 @@ def _DoSCMKeys(plist, add_keys):
# Pull in the Chrome revision number.
VERSION_TOOL = os.path.join(TOP, 'build/util/version.py')
LASTCHANGE_FILE = os.path.join(TOP, 'build/util/LASTCHANGE')
(stdout, retval) = _GetOutput([VERSION_TOOL, '-f', LASTCHANGE_FILE, '-t',
'@LASTCHANGE@'])
(stdout, retval) = _GetOutput(
[VERSION_TOOL, '-f', LASTCHANGE_FILE, '-t', '@LASTCHANGE@'])
if retval:
return False
scm_revision = stdout.rstrip()
Expand Down Expand Up @@ -178,20 +180,15 @@ def _AddBreakpadKeys(plist, branding, platform, staging):

def _RemoveBreakpadKeys(plist):
"""Removes any set Breakpad keys."""
_RemoveKeys(plist,
'BreakpadURL',
'BreakpadReportInterval',
'BreakpadProduct',
'BreakpadProductDisplay',
'BreakpadVersion',
'BreakpadSendAndExit',
'BreakpadSkipConfirm')
_RemoveKeys(plist, 'BreakpadURL', 'BreakpadReportInterval', 'BreakpadProduct',
'BreakpadProductDisplay', 'BreakpadVersion',
'BreakpadSendAndExit', 'BreakpadSkipConfirm')


def _TagSuffixes():
# Keep this list sorted in the order that tag suffix components are to
# appear in a tag value. That is to say, it should be sorted per ASCII.
components = ('full',)
components = ('full', )
assert tuple(sorted(components)) == components

components_len = len(components)
Expand Down Expand Up @@ -221,10 +218,7 @@ def _AddKeystoneKeys(plist, bundle_identifier):

def _RemoveKeystoneKeys(plist):
"""Removes any set Keystone keys."""
_RemoveKeys(plist,
'KSVersion',
'KSProductID',
'KSUpdateURL')
_RemoveKeys(plist, 'KSVersion', 'KSProductID', 'KSUpdateURL')

tag_keys = []
for tag_suffix in _TagSuffixes():
Expand All @@ -234,36 +228,72 @@ def _RemoveKeystoneKeys(plist):

def Main(argv):
parser = optparse.OptionParser('%prog [options]')
parser.add_option('--plist', dest='plist_path', action='store',
type='string', default=None, help='The path of the plist to tweak.')
parser.add_option('--plist',
dest='plist_path',
action='store',
type='string',
default=None,
help='The path of the plist to tweak.')
parser.add_option('--output', dest='plist_output', action='store',
type='string', default=None, help='If specified, the path to output ' + \
'the tweaked plist, rather than overwriting the input.')
parser.add_option('--breakpad', dest='use_breakpad', action='store',
type='int', default=False, help='Enable Breakpad [1 or 0]')
parser.add_option('--breakpad_staging', dest='use_breakpad_staging',
action='store_true', default=False,
parser.add_option('--breakpad',
dest='use_breakpad',
action='store',
type='int',
default=False,
help='Enable Breakpad [1 or 0]')
parser.add_option(
'--breakpad_staging',
dest='use_breakpad_staging',
action='store_true',
default=False,
help='Use staging breakpad to upload reports. Ignored if --breakpad=0.')
parser.add_option('--keystone', dest='use_keystone', action='store',
type='int', default=False, help='Enable Keystone [1 or 0]')
parser.add_option('--scm', dest='add_scm_info', action='store', type='int',
default=True, help='Add SCM metadata [1 or 0]')
parser.add_option('--branding', dest='branding', action='store',
type='string', default=None, help='The branding of the binary')
parser.add_option('--bundle_id', dest='bundle_identifier',
action='store', type='string', default=None,
help='The bundle id of the binary')
parser.add_option('--platform', choices=('ios', 'mac'), default='mac',
help='The target platform of the bundle')
parser.add_option('--version-overrides', action='append',
parser.add_option('--keystone',
dest='use_keystone',
action='store',
type='int',
default=False,
help='Enable Keystone [1 or 0]')
parser.add_option('--scm',
dest='add_scm_info',
action='store',
type='int',
default=True,
help='Add SCM metadata [1 or 0]')
parser.add_option('--branding',
dest='branding',
action='store',
type='string',
default=None,
help='The branding of the binary')
parser.add_option('--bundle_id',
dest='bundle_identifier',
action='store',
type='string',
default=None,
help='The bundle id of the binary')
parser.add_option('--platform',
choices=('ios', 'mac'),
default='mac',
help='The target platform of the bundle')
parser.add_option(
'--version-overrides',
action='append',
help='Key-value pair to override specific component of version '
'like key=value (can be passed multiple time to configure '
'more than one override)')
parser.add_option('--format', choices=('binary1', 'xml1', 'json'),
default='xml1', help='Format to use when writing property list '
'(default: %(default)s)')
parser.add_option('--version', dest='version', action='store', type='string',
default=None, help='The version string [major.minor.build.patch]')
'like key=value (can be passed multiple time to configure '
'more than one override)')
parser.add_option('--format',
choices=('binary1', 'xml1', 'json'),
default='xml1',
help='Format to use when writing property list '
'(default: %(default)s)')
parser.add_option('--version',
dest='version',
action='store',
type='string',
default=None,
help='The version string [major.minor.build.patch]')
(options, args) = parser.parse_args(argv)

if len(args) > 0:
Expand Down Expand Up @@ -297,32 +327,33 @@ def Main(argv):

if options.platform == 'mac':
version_format_for_key = {
# Add public version info so "Get Info" works.
'CFBundleShortVersionString': '@MAJOR@.@MINOR@.@BUILD@.@PATCH@',

# Honor the 429496.72.95 limit. The maximum comes from splitting 2^32 - 1
# into 6, 2, 2 digits. The limitation was present in Tiger, but it could
# have been fixed in later OS release, but hasn't been tested (it's easy
# enough to find out with "lsregister -dump).
# http://lists.apple.com/archives/carbon-dev/2006/Jun/msg00139.html
# BUILD will always be an increasing value, so BUILD_PATH gives us
# something unique that meetings what LS wants.
'CFBundleVersion': '@BUILD@.@PATCH@',
# Add public version info so "Get Info" works.
'CFBundleShortVersionString': '@MAJOR@.@MINOR@.@BUILD@.@PATCH@',

# Honor the 429496.72.95 limit. The maximum comes from splitting
# 2^32 - 1 into 6, 2, 2 digits. The limitation was present in Tiger,
# but it could have been fixed in later OS release, but hasn't been
# tested (it's easy enough to find out with "lsregister -dump).
# http://lists.apple.com/archives/carbon-dev/2006/Jun/msg00139.html
# BUILD will always be an increasing value, so BUILD_PATH gives us
# something unique that meetings what LS wants.
'CFBundleVersion': '@BUILD@.@PATCH@',
}
else:
version_format_for_key = {
'CFBundleShortVersionString': '@MAJOR@.@BUILD@.@PATCH@',
'CFBundleVersion': '@MAJOR@.@MINOR@.@BUILD@.@PATCH@'
'CFBundleShortVersionString': '@MAJOR@.@BUILD@.@PATCH@',
'CFBundleVersion': '@MAJOR@.@MINOR@.@BUILD@.@PATCH@'
}

if options.use_breakpad:
version_format_for_key['BreakpadVersion'] = \
'@MAJOR@.@MINOR@.@BUILD@.@PATCH@'

# Insert the product version.
if not _AddVersionKeys(
plist, version_format_for_key, version=options.version,
overrides=overrides):
if not _AddVersionKeys(plist,
version_format_for_key,
version=options.version,
overrides=overrides):
return 2

# Add Breakpad if configured to do so.
Expand All @@ -334,7 +365,7 @@ def Main(argv):
# to the platform as known by breakpad.
platform = {'mac': 'Mac', 'ios': 'iOS'}[options.platform]
_AddBreakpadKeys(plist, options.branding, platform,
options.use_breakpad_staging)
options.use_breakpad_staging)
else:
_RemoveBreakpadKeys(plist)

Expand Down
Loading

0 comments on commit dc2681f

Please sign in to comment.