summaryrefslogtreecommitdiffstats
path: root/chromium/build/android/gyp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2017-11-20 10:33:36 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2017-11-22 11:45:12 +0000
commitbe59a35641616a4cf23c4a13fa0632624b021c1b (patch)
tree9da183258bdf9cc413f7562079d25ace6955467f /chromium/build/android/gyp
parentd702e4b6a64574e97fc7df8fe3238cde70242080 (diff)
BASELINE: Update Chromium to 62.0.3202.101
Change-Id: I2d5eca8117600df6d331f6166ab24d943d9814ac Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/build/android/gyp')
-rwxr-xr-xchromium/build/android/gyp/aar.py149
-rwxr-xr-xchromium/build/android/gyp/apk_obfuscate.py185
-rwxr-xr-xchromium/build/android/gyp/configure_multidex.py87
-rwxr-xr-xchromium/build/android/gyp/create_apk_operations_script.py28
-rwxr-xr-xchromium/build/android/gyp/create_device_library_links.py121
-rwxr-xr-xchromium/build/android/gyp/create_placeholder_files.py35
-rwxr-xr-xchromium/build/android/gyp/create_standalone_apk.py60
-rwxr-xr-xchromium/build/android/gyp/create_test_runner_script.py19
-rwxr-xr-xchromium/build/android/gyp/desugar.py73
-rwxr-xr-xchromium/build/android/gyp/generate_copy_ex_outputs.py33
-rwxr-xr-xchromium/build/android/gyp/get_device_configuration.py78
-rwxr-xr-xchromium/build/android/gyp/jar_toc.py120
-rwxr-xr-xchromium/build/android/gyp/javac.py9
-rwxr-xr-xchromium/build/android/gyp/merge_manifest.py8
-rwxr-xr-xchromium/build/android/gyp/package_resources.py16
-rwxr-xr-xchromium/build/android/gyp/process_resources.py12
-rwxr-xr-xchromium/build/android/gyp/push_libraries.py85
-rwxr-xr-xchromium/build/android/gyp/retrolambda.py68
-rwxr-xr-xchromium/build/android/gyp/touch.py16
-rw-r--r--chromium/build/android/gyp/util/build_device.py102
-rwxr-xr-xchromium/build/android/gyp/write_build_config.py39
-rwxr-xr-xchromium/build/android/gyp/zip.py26
22 files changed, 235 insertions, 1134 deletions
diff --git a/chromium/build/android/gyp/aar.py b/chromium/build/android/gyp/aar.py
index 6c0bc892b0d..e8196e5aec9 100755
--- a/chromium/build/android/gyp/aar.py
+++ b/chromium/build/android/gyp/aar.py
@@ -38,76 +38,97 @@ def _IsManifestEmpty(manifest_str):
return True
+def _CreateInfo(aar_file):
+ data = {}
+ data['aidl'] = []
+ data['assets'] = []
+ data['resources'] = []
+ data['subjars'] = []
+ data['subjar_tuples'] = []
+ data['has_classes_jar'] = False
+ data['has_proguard_flags'] = False
+ data['has_native_libraries'] = False
+ data['has_r_text_file'] = False
+ with zipfile.ZipFile(aar_file) as z:
+ data['is_manifest_empty'] = (
+ _IsManifestEmpty(z.read('AndroidManifest.xml')))
+
+ for name in z.namelist():
+ if name.endswith('/'):
+ continue
+ if name.startswith('aidl/'):
+ data['aidl'].append(name)
+ elif name.startswith('res/'):
+ data['resources'].append(name)
+ elif name.startswith('libs/') and name.endswith('.jar'):
+ label = posixpath.basename(name)[:-4]
+ label = re.sub(r'[^a-zA-Z0-9._]', '_', label)
+ data['subjars'].append(name)
+ data['subjar_tuples'].append([label, name])
+ elif name.startswith('assets/'):
+ data['assets'].append(name)
+ elif name.startswith('jni/'):
+ data['has_native_libraries'] = True
+ elif name == 'classes.jar':
+ data['has_classes_jar'] = True
+ elif name == 'proguard.txt':
+ data['has_proguard_flags'] = True
+ elif name == 'R.txt':
+ # Some AARs, e.g. gvr_controller_java, have empty R.txt. Such AARs
+ # have no resources as well. We treat empty R.txt as having no R.txt.
+ data['has_r_text_file'] = (z.read('R.txt').strip() != '')
+
+ return """\
+# Generated by //build/android/gyp/aar.py
+# To regenerate, use "update_android_aar_prebuilts = true" and run "gn gen".
+
+""" + gn_helpers.ToGNString(data)
+
+
+def _AddCommonArgs(parser):
+ parser.add_argument('aar_file',
+ help='Path to the AAR file.',
+ type=os.path.normpath)
+
+
def main():
parser = argparse.ArgumentParser(description=__doc__)
- parser.add_argument('--input-file',
- help='Path to the AAR file.',
- required=True,
- metavar='FILE')
- parser.add_argument('--extract',
- help='Extract the files to output directory.',
- action='store_true')
- parser.add_argument('--list',
- help='List all the resource and jar files.',
- action='store_true')
- parser.add_argument('--output-dir',
- help='Output directory for the extracted files. Must '
- 'be set if --extract is set.',
- metavar='DIR')
+ command_parsers = parser.add_subparsers(dest='command')
+ subp = command_parsers.add_parser(
+ 'list', help='Output a GN scope describing the contents of the .aar.')
+ _AddCommonArgs(subp)
+ subp.add_argument('--output',
+ help='Output file.',
+ type=argparse.FileType('w'),
+ default='-')
+
+ subp = command_parsers.add_parser('extract', help='Extracts the .aar')
+ _AddCommonArgs(subp)
+ subp.add_argument('--output-dir',
+ help='Output directory for the extracted files.',
+ required=True,
+ type=os.path.normpath)
+ subp.add_argument('--assert-info-file',
+ help='Path to .info file. Asserts that it matches what '
+ '"list" would output.',
+ type=argparse.FileType('r'))
args = parser.parse_args()
- if not args.extract and not args.list:
- parser.error('Either --extract or --list has to be specified.')
-
- aar_file = args.input_file
- output_dir = args.output_dir
- if args.extract:
+ if args.command == 'extract':
+ if args.assert_info_file:
+ expected = _CreateInfo(args.aar_file)
+ actual = args.assert_info_file.read()
+ if actual != expected:
+ raise Exception('android_aar_prebuilt() cached .info file is '
+ 'out-of-date. Run gn gen with '
+ 'update_android_aar_prebuilts=true to update it.')
# Clear previously extracted versions of the AAR.
- shutil.rmtree(output_dir, True)
- build_utils.ExtractAll(aar_file, path=output_dir)
-
- if args.list:
- data = {}
- data['aidl'] = []
- data['assets'] = []
- data['resources'] = []
- data['subjars'] = []
- data['subjar_tuples'] = []
- data['has_classes_jar'] = False
- data['has_proguard_flags'] = False
- data['has_native_libraries'] = False
- data['has_r_text_file'] = False
- with zipfile.ZipFile(aar_file) as z:
- data['is_manifest_empty'] = (
- _IsManifestEmpty(z.read('AndroidManifest.xml')))
-
- for name in z.namelist():
- if name.endswith('/'):
- continue
- if name.startswith('aidl/'):
- data['aidl'].append(name)
- elif name.startswith('res/'):
- data['resources'].append(name)
- elif name.startswith('libs/') and name.endswith('.jar'):
- label = posixpath.basename(name)[:-4]
- label = re.sub(r'[^a-zA-Z0-9._]', '_', label)
- data['subjars'].append(name)
- data['subjar_tuples'].append([label, name])
- elif name.startswith('assets/'):
- data['assets'].append(name)
- elif name.startswith('jni/'):
- data['has_native_libraries'] = True
- elif name == 'classes.jar':
- data['has_classes_jar'] = True
- elif name == 'proguard.txt':
- data['has_proguard_flags'] = True
- elif name == 'R.txt':
- # Some AARs, e.g. gvr_controller_java, have empty R.txt. Such AARs
- # have no resources as well. We treat empty R.txt as having no R.txt.
- data['has_r_text_file'] = (z.read('R.txt').strip() != '')
-
- print gn_helpers.ToGNString(data)
+ shutil.rmtree(args.output_dir, True)
+ build_utils.ExtractAll(args.aar_file, path=args.output_dir)
+
+ elif args.command == 'list':
+ args.output.write(_CreateInfo(args.aar_file))
if __name__ == '__main__':
diff --git a/chromium/build/android/gyp/apk_obfuscate.py b/chromium/build/android/gyp/apk_obfuscate.py
deleted file mode 100755
index 04a04b3dd86..00000000000
--- a/chromium/build/android/gyp/apk_obfuscate.py
+++ /dev/null
@@ -1,185 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2014 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.
-
-"""Generates the obfuscated jar and test jar for an apk.
-
-If proguard is not enabled or 'Release' is not in the configuration name,
-obfuscation will be a no-op.
-"""
-
-import json
-import optparse
-import os
-import sys
-import tempfile
-
-from util import build_utils
-from util import proguard_util
-
-
-_PROGUARD_KEEP_CLASS = '''-keep class %s {
- *;
-}
-'''
-
-
-def ParseArgs(argv):
- parser = optparse.OptionParser()
- parser.add_option('--android-sdk', help='path to the Android SDK folder')
- parser.add_option('--android-sdk-tools',
- help='path to the Android SDK build tools folder')
- parser.add_option('--android-sdk-jar',
- help='path to Android SDK\'s android.jar')
- parser.add_option('--proguard-jar-path',
- help='Path to proguard.jar in the sdk')
- parser.add_option('--input-jars-paths',
- help='Path to jars to include in obfuscated jar')
-
- parser.add_option('--proguard-configs',
- help='Paths to proguard config files')
-
- parser.add_option('--configuration-name',
- help='Gyp configuration name (i.e. Debug, Release)')
-
- parser.add_option('--debug-build-proguard-enabled', action='store_true',
- help='--proguard-enabled takes effect on release '
- 'build, this flag enable the proguard on debug '
- 'build.')
- parser.add_option('--proguard-enabled', action='store_true',
- help='Set if proguard is enabled for this target.')
-
- parser.add_option('--obfuscated-jar-path',
- help='Output path for obfuscated jar.')
-
- parser.add_option('--testapp', action='store_true',
- help='Set this if building an instrumentation test apk')
- parser.add_option('--tested-apk-obfuscated-jar-path',
- help='Path to obfusctated jar of the tested apk')
- parser.add_option('--test-jar-path',
- help='Output path for jar containing all the test apk\'s '
- 'code.')
-
- parser.add_option('--stamp', help='File to touch on success')
-
- parser.add_option('--main-dex-list-path',
- help='The list of classes to retain in the main dex. '
- 'These will not be obfuscated.')
- parser.add_option('--multidex-configuration-path',
- help='A JSON file containing multidex build configuration.')
- parser.add_option('--verbose', '-v', action='store_true',
- help='Print all proguard output')
-
- (options, args) = parser.parse_args(argv)
-
- if args:
- parser.error('No positional arguments should be given. ' + str(args))
-
- # Check that required options have been provided.
- required_options = (
- 'android_sdk',
- 'android_sdk_tools',
- 'android_sdk_jar',
- 'proguard_jar_path',
- 'input_jars_paths',
- 'configuration_name',
- 'obfuscated_jar_path',
- )
-
- if options.testapp:
- required_options += (
- 'test_jar_path',
- )
-
- build_utils.CheckOptions(options, parser, required=required_options)
- return options, args
-
-
-def DoProguard(options):
- proguard = proguard_util.ProguardCmdBuilder(options.proguard_jar_path)
- proguard.outjar(options.obfuscated_jar_path)
-
- input_jars = build_utils.ParseGnList(options.input_jars_paths)
-
- exclude_paths = []
- configs = build_utils.ParseGnList(options.proguard_configs)
- if options.tested_apk_obfuscated_jar_path:
- # configs should only contain the process_resources.py generated config.
- assert len(configs) == 1, (
- 'test apks should not have custom proguard configs: ' + str(configs))
- proguard.tested_apk_info(options.tested_apk_obfuscated_jar_path + '.info')
-
- proguard.libraryjars([options.android_sdk_jar])
- proguard_injars = [p for p in input_jars if p not in exclude_paths]
- proguard.injars(proguard_injars)
-
- multidex_config = _PossibleMultidexConfig(options)
- if multidex_config:
- configs.append(multidex_config)
-
- proguard.configs(configs)
- proguard.verbose(options.verbose)
- proguard.CheckOutput()
-
-
-def _PossibleMultidexConfig(options):
- if not options.multidex_configuration_path:
- return None
-
- with open(options.multidex_configuration_path) as multidex_config_file:
- multidex_config = json.loads(multidex_config_file.read())
-
- if not (multidex_config.get('enabled') and options.main_dex_list_path):
- return None
-
- main_dex_list_config = ''
- with open(options.main_dex_list_path) as main_dex_list:
- for clazz in (l.strip() for l in main_dex_list):
- if clazz.endswith('.class'):
- clazz = clazz[:-len('.class')]
- clazz = clazz.replace('/', '.')
- main_dex_list_config += (_PROGUARD_KEEP_CLASS % clazz)
- with tempfile.NamedTemporaryFile(
- delete=False,
- dir=os.path.dirname(options.main_dex_list_path),
- prefix='main_dex_list_proguard',
- suffix='.flags') as main_dex_config_file:
- main_dex_config_file.write(main_dex_list_config)
- return main_dex_config_file.name
-
-
-def main(argv):
- options, _ = ParseArgs(argv)
-
- input_jars = build_utils.ParseGnList(options.input_jars_paths)
-
- if options.testapp:
- dependency_class_filters = [
- '*R.class', '*R$*.class', '*Manifest.class', '*BuildConfig.class']
- build_utils.MergeZips(
- options.test_jar_path, input_jars, dependency_class_filters)
-
- if ((options.configuration_name == 'Release' and options.proguard_enabled) or
- (options.configuration_name == 'Debug' and
- options.debug_build_proguard_enabled)):
- DoProguard(options)
- else:
- output_files = [
- options.obfuscated_jar_path,
- options.obfuscated_jar_path + '.info',
- options.obfuscated_jar_path + '.dump',
- options.obfuscated_jar_path + '.seeds',
- options.obfuscated_jar_path + '.usage',
- options.obfuscated_jar_path + '.mapping']
- for f in output_files:
- if os.path.exists(f):
- os.remove(f)
- build_utils.Touch(f)
-
- if options.stamp:
- build_utils.Touch(options.stamp)
-
-if __name__ == '__main__':
- sys.exit(main(sys.argv[1:]))
diff --git a/chromium/build/android/gyp/configure_multidex.py b/chromium/build/android/gyp/configure_multidex.py
deleted file mode 100755
index 63c74f07be7..00000000000
--- a/chromium/build/android/gyp/configure_multidex.py
+++ /dev/null
@@ -1,87 +0,0 @@
-#!/usr/bin/env python
-# Copyright 2015 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 argparse
-import json
-import os
-import sys
-
-from util import build_utils
-
-
-_GCC_PREPROCESS_PATH = os.path.join(
- os.path.dirname(__file__), 'gcc_preprocess.py')
-
-
-def ParseArgs():
- parser = argparse.ArgumentParser()
- parser.add_argument('--configuration-name', required=True,
- help='The build CONFIGURATION_NAME.')
- parser.add_argument('--enable-multidex', action='store_true', default=False,
- help='If passed, multidex may be enabled.')
- parser.add_argument('--enabled-configurations', default=[],
- help='The configuration(s) for which multidex should be '
- 'enabled. If not specified and --enable-multidex is '
- 'passed, multidex will be enabled for all '
- 'configurations.')
- parser.add_argument('--multidex-configuration-path', required=True,
- help='The path to which the multidex configuration JSON '
- 'should be saved.')
- parser.add_argument('--multidex-config-java-file', required=True)
- parser.add_argument('--multidex-config-java-stamp', required=True)
- parser.add_argument('--multidex-config-java-template', required=True)
-
- args = parser.parse_args()
-
- if args.enabled_configurations:
- args.enabled_configurations = build_utils.ParseGnList(
- args.enabled_configurations)
-
- return args
-
-
-def _WriteConfigJson(multidex_enabled, multidex_configuration_path):
- config = {
- 'enabled': multidex_enabled,
- }
-
- with open(multidex_configuration_path, 'w') as f:
- f.write(json.dumps(config))
-
-
-def _GenerateMultidexConfigJava(multidex_enabled, args):
- gcc_preprocess_cmd = [
- sys.executable, _GCC_PREPROCESS_PATH,
- '--include-path=',
- '--template', args.multidex_config_java_template,
- '--stamp', args.multidex_config_java_stamp,
- '--output', args.multidex_config_java_file,
- ]
- if multidex_enabled:
- gcc_preprocess_cmd += [
- '--defines', 'ENABLE_MULTIDEX',
- ]
-
- build_utils.CheckOutput(gcc_preprocess_cmd)
-
-
-def main():
- args = ParseArgs()
-
- multidex_enabled = (
- args.enable_multidex
- and (not args.enabled_configurations
- or args.configuration_name in args.enabled_configurations))
-
- _WriteConfigJson(multidex_enabled, args.multidex_configuration_path)
- _GenerateMultidexConfigJava(multidex_enabled, args)
-
- return 0
-
-
-if __name__ == '__main__':
- sys.exit(main())
-
diff --git a/chromium/build/android/gyp/create_apk_operations_script.py b/chromium/build/android/gyp/create_apk_operations_script.py
index 534b4cc076d..7fa94c1a3ad 100755
--- a/chromium/build/android/gyp/create_apk_operations_script.py
+++ b/chromium/build/android/gyp/create_apk_operations_script.py
@@ -24,11 +24,19 @@ def main():
script_directory, p))
sys.path.append(resolve(${APK_OPERATIONS_DIR}))
import apk_operations
- apk_operations.Run(output_directory=resolve(${OUTPUT_DIR}),
- apk_path=resolve(${APK_PATH}),
- inc_apk_path=resolve(${INC_APK_PATH}),
- inc_install_script=resolve(${INC_INSTALL_SCRIPT}),
- command_line_flags_file=${FLAGS_FILE})
+ output_dir = resolve(${OUTPUT_DIR})
+ try:
+ apk_operations.Run(output_dir,
+ resolve(${APK_PATH}),
+ resolve(${INC_JSON_PATH}),
+ ${FLAGS_FILE},
+ target_cpu=${TARGET_CPU})
+ except TypeError:
+ rel_output_dir = os.path.relpath(output_dir)
+ rel_script_path = os.path.relpath(sys.argv[0], output_dir)
+ sys.stderr.write('Script out-of-date. Rebuild via:\\n')
+ sys.stderr.write(' ninja -C %s %s\\n' % (rel_output_dir, rel_script_path))
+ return 1
if __name__ == '__main__':
@@ -41,9 +49,9 @@ def main(args):
parser.add_argument('--script-output-path',
help='Output path for executable script.')
parser.add_argument('--apk-path')
- parser.add_argument('--incremental-apk-path')
- parser.add_argument('--incremental-install-script')
+ parser.add_argument('--incremental-install-json-path')
parser.add_argument('--command-line-flags-file')
+ parser.add_argument('--target-cpu')
args = parser.parse_args(args)
def relativize(path):
@@ -57,11 +65,11 @@ def main(args):
with open(args.script_output_path, 'w') as script:
script_dict = {
'APK_OPERATIONS_DIR': repr(apk_operations_dir),
- 'OUTPUT_DIR': repr('.'),
+ 'OUTPUT_DIR': repr(relativize('.')),
'APK_PATH': repr(relativize(args.apk_path)),
- 'INC_APK_PATH': repr(relativize(args.incremental_apk_path)),
- 'INC_INSTALL_SCRIPT': repr(relativize(args.incremental_install_script)),
+ 'INC_JSON_PATH': repr(relativize(args.incremental_install_json_path)),
'FLAGS_FILE': repr(args.command_line_flags_file),
+ 'TARGET_CPU': repr(args.target_cpu),
}
script.write(SCRIPT_TEMPLATE.substitute(script_dict))
os.chmod(args.script_output_path, 0750)
diff --git a/chromium/build/android/gyp/create_device_library_links.py b/chromium/build/android/gyp/create_device_library_links.py
deleted file mode 100755
index 542030678ef..00000000000
--- a/chromium/build/android/gyp/create_device_library_links.py
+++ /dev/null
@@ -1,121 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2013 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.
-
-"""Creates symlinks to native libraries for an APK.
-
-The native libraries should have previously been pushed to the device (in
-options.target_dir). This script then creates links in an apk's lib/ folder to
-those native libraries.
-"""
-
-import optparse
-import os
-import sys
-
-from util import build_device
-from util import build_utils
-
-BUILD_ANDROID_DIR = os.path.abspath(
- os.path.join(os.path.dirname(__file__), '..'))
-sys.path.append(BUILD_ANDROID_DIR)
-
-import devil_chromium
-from devil.android import apk_helper
-from pylib import constants
-
-def RunShellCommand(device, cmd):
- output = device.RunShellCommand(cmd, check_return=True)
-
- if output:
- raise Exception(
- 'Unexpected output running command: ' + cmd + '\n' +
- '\n'.join(output))
-
-
-def CreateSymlinkScript(options):
- libraries = build_utils.ParseGnList(options.libraries)
-
- link_cmd = (
- 'rm $APK_LIBRARIES_DIR/%(lib_basename)s > /dev/null 2>&1 \n'
- 'ln -s $STRIPPED_LIBRARIES_DIR/%(lib_basename)s '
- '$APK_LIBRARIES_DIR/%(lib_basename)s \n'
- )
-
- script = '#!/bin/sh \n'
-
- for lib in libraries:
- script += link_cmd % { 'lib_basename': lib }
-
- with open(options.script_host_path, 'w') as scriptfile:
- scriptfile.write(script)
-
-
-def TriggerSymlinkScript(options):
- device = build_device.GetBuildDeviceFromPath(
- options.build_device_configuration)
- if not device:
- return
-
- apk_package = apk_helper.GetPackageName(options.apk)
- apk_libraries_dir = '/data/data/%s/lib' % apk_package
-
- device_dir = os.path.dirname(options.script_device_path)
- mkdir_cmd = ('if [ ! -e %(dir)s ]; then mkdir -p %(dir)s; fi ' %
- { 'dir': device_dir })
- RunShellCommand(device, mkdir_cmd)
- device.PushChangedFiles([(os.path.abspath(options.script_host_path),
- options.script_device_path)])
-
- trigger_cmd = (
- 'APK_LIBRARIES_DIR=%(apk_libraries_dir)s; '
- 'STRIPPED_LIBRARIES_DIR=%(target_dir)s; '
- '. %(script_device_path)s'
- ) % {
- 'apk_libraries_dir': apk_libraries_dir,
- 'target_dir': options.target_dir,
- 'script_device_path': options.script_device_path
- }
- RunShellCommand(device, trigger_cmd)
-
-
-def main(args):
- args = build_utils.ExpandFileArgs(args)
- parser = optparse.OptionParser()
- parser.add_option('--apk', help='Path to the apk.')
- parser.add_option('--script-host-path',
- help='Path on the host for the symlink script.')
- parser.add_option('--script-device-path',
- help='Path on the device to push the created symlink script.')
- parser.add_option('--libraries',
- help='List of native libraries.')
- parser.add_option('--target-dir',
- help='Device directory that contains the target libraries for symlinks.')
- parser.add_option('--stamp', help='Path to touch on success.')
- parser.add_option('--build-device-configuration',
- help='Path to build device configuration.')
- parser.add_option('--configuration-name',
- help='The build CONFIGURATION_NAME')
- parser.add_option('--output-directory',
- help='The output directory')
- options, _ = parser.parse_args(args)
-
- required_options = ['apk', 'libraries', 'script_host_path',
- 'script_device_path', 'target_dir', 'configuration_name']
- build_utils.CheckOptions(options, parser, required=required_options)
- constants.SetBuildType(options.configuration_name)
-
- devil_chromium.Initialize(
- output_directory=os.path.abspath(options.output_directory))
-
- CreateSymlinkScript(options)
- TriggerSymlinkScript(options)
-
- if options.stamp:
- build_utils.Touch(options.stamp)
-
-
-if __name__ == '__main__':
- sys.exit(main(sys.argv[1:]))
diff --git a/chromium/build/android/gyp/create_placeholder_files.py b/chromium/build/android/gyp/create_placeholder_files.py
deleted file mode 100755
index 103e1df7f2d..00000000000
--- a/chromium/build/android/gyp/create_placeholder_files.py
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/usr/bin/env python
-# Copyright 2014 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.
-
-"""Create placeholder files.
-"""
-
-import optparse
-import os
-import sys
-
-from util import build_utils
-
-def main():
- parser = optparse.OptionParser()
- parser.add_option(
- '--dest-lib-dir',
- help='Destination directory to have placeholder files.')
- parser.add_option(
- '--stamp',
- help='Path to touch on success')
-
- options, args = parser.parse_args()
-
- for name in args:
- target_path = os.path.join(options.dest_lib_dir, name)
- build_utils.Touch(target_path)
-
- if options.stamp:
- build_utils.Touch(options.stamp)
-
-if __name__ == '__main__':
- sys.exit(main())
-
diff --git a/chromium/build/android/gyp/create_standalone_apk.py b/chromium/build/android/gyp/create_standalone_apk.py
deleted file mode 100755
index c5605992860..00000000000
--- a/chromium/build/android/gyp/create_standalone_apk.py
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2013 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.
-
-"""Combines stripped libraries and incomplete APK into single standalone APK.
-
-"""
-
-import optparse
-import os
-import shutil
-import sys
-import tempfile
-
-from util import build_utils
-from util import md5_check
-
-def CreateStandaloneApk(options):
- def DoZip():
- with tempfile.NamedTemporaryFile(suffix='.zip') as intermediate_file:
- intermediate_path = intermediate_file.name
- shutil.copy(options.input_apk_path, intermediate_path)
- apk_path_abs = os.path.abspath(intermediate_path)
- build_utils.CheckOutput(
- ['zip', '-r', '-1', apk_path_abs, 'lib'],
- cwd=options.libraries_top_dir)
- shutil.copy(intermediate_path, options.output_apk_path)
-
- input_paths = [options.input_apk_path, options.libraries_top_dir]
- record_path = '%s.standalone.stamp' % options.input_apk_path
- md5_check.CallAndRecordIfStale(
- DoZip,
- record_path=record_path,
- input_paths=input_paths)
-
-
-def main():
- parser = optparse.OptionParser()
- parser.add_option('--libraries-top-dir',
- help='Top directory that contains libraries '
- '(i.e. library paths are like '
- 'libraries_top_dir/lib/android_app_abi/foo.so).')
- parser.add_option('--input-apk-path', help='Path to incomplete APK.')
- parser.add_option('--output-apk-path', help='Path for standalone APK.')
- parser.add_option('--stamp', help='Path to touch on success.')
- options, _ = parser.parse_args()
-
- required_options = ['libraries_top_dir', 'input_apk_path', 'output_apk_path']
- build_utils.CheckOptions(options, parser, required=required_options)
-
- CreateStandaloneApk(options)
-
- if options.stamp:
- build_utils.Touch(options.stamp)
-
-
-if __name__ == '__main__':
- sys.exit(main())
diff --git a/chromium/build/android/gyp/create_test_runner_script.py b/chromium/build/android/gyp/create_test_runner_script.py
index 69c821f4e80..a67da8825fe 100755
--- a/chromium/build/android/gyp/create_test_runner_script.py
+++ b/chromium/build/android/gyp/create_test_runner_script.py
@@ -70,18 +70,19 @@ def main(args):
group.add_argument('--additional-apk-incremental', action='append',
dest='additional_apks_incremental', default=[])
group.add_argument('--apk-under-test')
- group.add_argument('--apk-under-test-incremental-install-script')
+ group.add_argument('--apk-under-test-incremental-install-json')
group.add_argument('--executable-dist-dir')
group.add_argument('--isolate-file-path')
group.add_argument('--output-directory')
group.add_argument('--runtime-deps-path')
group.add_argument('--test-apk')
group.add_argument('--test-jar')
- group.add_argument('--test-apk-incremental-install-script')
+ group.add_argument('--test-apk-incremental-install-json')
group.add_argument('--coverage-dir')
group.add_argument('--android-manifest-path')
group.add_argument('--resource-zips')
group.add_argument('--robolectric-runtime-deps-dir')
+ group.add_argument('--enable-relocation-packing')
args, test_runner_args = parser.parse_known_args(
build_utils.ExpandFileArgs(args))
@@ -94,6 +95,8 @@ def main(args):
test_runner_path = RelativizePathToScript(test_runner_path)
test_runner_path_args = []
+ if args.enable_relocation_packing and args.enable_relocation_packing == "1":
+ test_runner_args.append('--enable-relocation-packing')
if args.additional_apk_list:
args.additional_apks.extend(
build_utils.ParseGnList(args.additional_apk_list))
@@ -109,11 +112,11 @@ def main(args):
if args.apk_under_test:
test_runner_path_args.append(
('--apk-under-test', RelativizePathToScript(args.apk_under_test)))
- if args.apk_under_test_incremental_install_script:
+ if args.apk_under_test_incremental_install_json:
test_runner_path_args.append(
- ('--apk-under-test-incremental-install-script',
+ ('--apk-under-test-incremental-install-json',
RelativizePathToScript(
- args.apk_under_test_incremental_install_script)))
+ args.apk_under_test_incremental_install_json)))
if args.executable_dist_dir:
test_runner_path_args.append(
('--executable-dist-dir',
@@ -133,10 +136,10 @@ def main(args):
if args.test_jar:
test_runner_path_args.append(
('--test-jar', RelativizePathToScript(args.test_jar)))
- if args.test_apk_incremental_install_script:
+ if args.test_apk_incremental_install_json:
test_runner_path_args.append(
- ('--test-apk-incremental-install-script',
- RelativizePathToScript(args.test_apk_incremental_install_script)))
+ ('--test-apk-incremental-install-json',
+ RelativizePathToScript(args.test_apk_incremental_install_json)))
if args.coverage_dir:
test_runner_path_args.append(
('--coverage-dir', RelativizePathToScript(args.coverage_dir)))
diff --git a/chromium/build/android/gyp/desugar.py b/chromium/build/android/gyp/desugar.py
new file mode 100755
index 00000000000..bf51b0073d6
--- /dev/null
+++ b/chromium/build/android/gyp/desugar.py
@@ -0,0 +1,73 @@
+#!/usr/bin/env python
+#
+# Copyright 2017 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 argparse
+import os
+import sys
+
+from util import build_utils
+
+
+_SRC_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__),
+ '..', '..', '..'))
+_DESUGAR_JAR_PATH = os.path.normpath(os.path.join(
+ _SRC_ROOT, 'third_party', 'bazel', 'desugar', 'Desugar.jar'))
+
+
+def _OnStaleMd5(input_jar, output_jar, classpath, bootclasspath_entry):
+ cmd = [
+ 'java',
+ '-jar',
+ _DESUGAR_JAR_PATH,
+ '--input',
+ input_jar,
+ '--bootclasspath_entry',
+ bootclasspath_entry,
+ '--output',
+ output_jar,
+ # Don't include try-with-resources files in every .jar. Instead, they
+ # are included via //third_party/bazel/desugar:desugar_runtime_java.
+ '--desugar_try_with_resources_omit_runtime_classes',
+ ]
+ for path in classpath:
+ cmd += ['--classpath_entry', path]
+ build_utils.CheckOutput(cmd, print_stdout=False)
+
+
+def main():
+ args = build_utils.ExpandFileArgs(sys.argv[1:])
+ parser = argparse.ArgumentParser()
+ build_utils.AddDepfileOption(parser)
+ parser.add_argument('--input-jar', required=True,
+ help='Jar input path to include .class files from.')
+ parser.add_argument('--output-jar', required=True,
+ help='Jar output path.')
+ parser.add_argument('--classpath', required=True,
+ help='Classpath.')
+ parser.add_argument('--bootclasspath-entry', required=True,
+ help='Path to javac bootclasspath interface jar.')
+ options = parser.parse_args(args)
+
+ options.classpath = build_utils.ParseGnList(options.classpath)
+ input_paths = options.classpath + [
+ options.bootclasspath_entry,
+ options.input_jar,
+ ]
+ output_paths = [options.output_jar]
+ depfile_deps = options.classpath + [_DESUGAR_JAR_PATH]
+
+ build_utils.CallAndWriteDepfileIfStale(
+ lambda: _OnStaleMd5(options.input_jar, options.output_jar,
+ options.classpath, options.bootclasspath_entry),
+ options,
+ input_paths=input_paths,
+ input_strings=[],
+ output_paths=output_paths,
+ depfile_deps=depfile_deps)
+
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/chromium/build/android/gyp/generate_copy_ex_outputs.py b/chromium/build/android/gyp/generate_copy_ex_outputs.py
deleted file mode 100755
index e425b4a6afe..00000000000
--- a/chromium/build/android/gyp/generate_copy_ex_outputs.py
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (c) 2015 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.
-#
-# Generate outputs according source files and destination path for
-# copy_ex.gypi
-
-import argparse
-import os
-import sys
-
-def DoMain(argv):
- parser = argparse.ArgumentParser(prog='generate_copy_ex_outputs')
- parser.add_argument('--src-files',
- nargs = '+',
- help = 'a list of files to copy')
- parser.add_argument('--dest-path',
- required = True,
- help = 'the directory to copy file to')
- options = parser.parse_args(argv)
- # Quote each element so filename spaces don't mess up gyp's attempt to parse
- # it into a list.
- return ' '.join('"%s"' % os.path.join(options.dest_path,
- os.path.basename(src))
- for src in options.src_files)
-
-if __name__ == '__main__':
- results = DoMain(sys.argv[1:])
- if results:
- print results
-
diff --git a/chromium/build/android/gyp/get_device_configuration.py b/chromium/build/android/gyp/get_device_configuration.py
deleted file mode 100755
index 0ec08ef95d6..00000000000
--- a/chromium/build/android/gyp/get_device_configuration.py
+++ /dev/null
@@ -1,78 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2013 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.
-
-"""Gets and writes the configurations of the attached devices.
-
-This configuration is used by later build steps to determine which devices to
-install to and what needs to be installed to those devices.
-"""
-
-import optparse
-import os
-import sys
-
-from util import build_device
-from util import build_utils
-
-BUILD_ANDROID_DIR = os.path.abspath(
- os.path.join(os.path.dirname(__file__), '..'))
-sys.path.append(BUILD_ANDROID_DIR)
-
-import devil_chromium
-
-
-def main(argv):
- parser = optparse.OptionParser()
- parser.add_option('--stamp', action='store')
- parser.add_option('--output', action='store')
- parser.add_option('--output-directory', action='store')
- options, _ = parser.parse_args(argv)
-
- devil_chromium.Initialize(
- output_directory=os.path.abspath(options.output_directory))
-
- devices = build_device.GetAttachedDevices()
-
- device_configurations = []
- for d in devices:
- configuration, is_online, has_root = (
- build_device.GetConfigurationForDevice(d))
-
- if not is_online:
- build_utils.PrintBigWarning(
- '%s is not online. Skipping managed install for this device. '
- 'Try rebooting the device to fix this warning.' % d)
- continue
-
- if not has_root:
- build_utils.PrintBigWarning(
- '"adb root" failed on device: %s\n'
- 'Skipping managed install for this device.'
- % configuration['description'])
- continue
-
- device_configurations.append(configuration)
-
- if len(device_configurations) == 0:
- build_utils.PrintBigWarning(
- 'No valid devices attached. Skipping managed install steps.')
- elif len(devices) > 1:
- # Note that this checks len(devices) and not len(device_configurations).
- # This way, any time there are multiple devices attached it is
- # explicitly stated which device we will install things to even if all but
- # one device were rejected for other reasons (e.g. two devices attached,
- # one w/o root).
- build_utils.PrintBigWarning(
- 'Multiple devices attached. '
- 'Installing to the preferred device: '
- '%(id)s (%(description)s)' % (device_configurations[0]))
-
-
- build_device.WriteConfigurations(device_configurations, options.output)
-
-
-if __name__ == '__main__':
- sys.exit(main(sys.argv))
diff --git a/chromium/build/android/gyp/jar_toc.py b/chromium/build/android/gyp/jar_toc.py
deleted file mode 100755
index 540a3439a68..00000000000
--- a/chromium/build/android/gyp/jar_toc.py
+++ /dev/null
@@ -1,120 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2013 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.
-
-"""Creates a TOC file from a Java jar.
-
-The TOC file contains the non-package API of the jar. This includes all
-public/protected/package classes/functions/members and the values of static
-final variables (members with package access are kept because in some cases we
-have multiple libraries with the same package, particularly test+non-test). Some
-other information (major/minor javac version) is also included.
-
-This TOC file then can be used to determine if a dependent library should be
-rebuilt when this jar changes. I.e. any change to the jar that would require a
-rebuild, will have a corresponding change in the TOC file.
-"""
-
-import optparse
-import os
-import re
-import sys
-import zipfile
-
-from util import build_utils
-from util import md5_check
-
-
-def GetClassesInZipFile(zip_file):
- classes = []
- files = zip_file.namelist()
- for f in files:
- if f.endswith('.class'):
- # f is of the form org/chromium/base/Class$Inner.class
- classes.append(f.replace('/', '.')[:-6])
- return classes
-
-
-def CallJavap(classpath, classes):
- javap_cmd = [
- 'javap',
- '-package', # Show public/protected/package.
- # -verbose is required to get constant values (which can be inlined in
- # dependents).
- '-verbose',
- '-J-XX:NewSize=4m',
- '-classpath', classpath
- ] + classes
- return build_utils.CheckOutput(javap_cmd)
-
-
-def ExtractToc(disassembled_classes):
- # javap output is structured by indent (2-space) levels.
- good_patterns = [
- '^[^ ]', # This includes all class signatures.
- '^ SourceFile:',
- '^ minor version:',
- '^ major version:',
- '^ Constant value:',
- '^ public ',
- '^ protected ',
- ]
- bad_patterns = [
- '^const #', # Matches the constant pool (i.e. literals used in the class).
- ]
-
- def JavapFilter(line):
- return (re.match('|'.join(good_patterns), line) and
- not re.match('|'.join(bad_patterns), line))
- toc = filter(JavapFilter, disassembled_classes.split('\n'))
-
- return '\n'.join(toc)
-
-
-def UpdateToc(jar_path, toc_path):
- classes = GetClassesInZipFile(zipfile.ZipFile(jar_path))
- toc = ''
- if len(classes) != 0:
- javap_output = CallJavap(classpath=jar_path, classes=classes)
- toc = ExtractToc(javap_output)
-
- with open(toc_path, 'w') as tocfile:
- tocfile.write(toc)
-
-
-def DoJarToc(options):
- jar_path = options.jar_path
- toc_path = options.toc_path
- record_path = '%s.md5.stamp' % toc_path
- md5_check.CallAndRecordIfStale(
- lambda: UpdateToc(jar_path, toc_path),
- record_path=record_path,
- input_paths=[jar_path],
- force=not os.path.exists(toc_path),
- )
- build_utils.Touch(toc_path, fail_if_missing=True)
-
-
-def main():
- parser = optparse.OptionParser()
- build_utils.AddDepfileOption(parser)
-
- parser.add_option('--jar-path', help='Input .jar path.')
- parser.add_option('--toc-path', help='Output .jar.TOC path.')
- parser.add_option('--stamp', help='Path to touch on success.')
-
- options, _ = parser.parse_args()
-
- DoJarToc(options)
-
- if options.depfile:
- build_utils.WriteDepfile(options.depfile, options.toc_path)
-
- if options.stamp:
- build_utils.Touch(options.stamp)
-
-
-if __name__ == '__main__':
- sys.exit(main())
diff --git a/chromium/build/android/gyp/javac.py b/chromium/build/android/gyp/javac.py
index 51d1b8dd3a6..3ca6bd51d0b 100755
--- a/chromium/build/android/gyp/javac.py
+++ b/chromium/build/android/gyp/javac.py
@@ -217,7 +217,7 @@ def _OnStaleMd5(changes, options, javac_cmd, java_files, classpath_inputs):
jar_srcs = _FilterJavaFiles(jar_srcs, options.javac_includes)
java_files.extend(jar_srcs)
if changed_paths:
- # Set the mtime of all sources to 0 since we use the absense of .class
+ # Set the mtime of all sources to 0 since we use the absence of .class
# files to tell jmake which files are stale.
for path in jar_srcs:
os.utime(path, (0, 0))
@@ -371,8 +371,11 @@ def _ParseOptions(argv):
if options.java_version == '1.8' and options.bootclasspath:
# Android's boot jar doesn't contain all java 8 classes.
# See: https://github.com/evant/gradle-retrolambda/issues/23.
- javac_path = os.path.realpath(distutils.spawn.find_executable('javac'))
- jdk_dir = os.path.dirname(os.path.dirname(javac_path))
+ # Get the path of the jdk folder by searching for the 'jar' executable. We
+ # cannot search for the 'javac' executable because goma provides a custom
+ # version of 'javac'.
+ jar_path = os.path.realpath(distutils.spawn.find_executable('jar'))
+ jdk_dir = os.path.dirname(os.path.dirname(jar_path))
rt_jar = os.path.join(jdk_dir, 'jre', 'lib', 'rt.jar')
options.bootclasspath.append(rt_jar)
diff --git a/chromium/build/android/gyp/merge_manifest.py b/chromium/build/android/gyp/merge_manifest.py
index 93769e19dc4..43fef824ca4 100755
--- a/chromium/build/android/gyp/merge_manifest.py
+++ b/chromium/build/android/gyp/merge_manifest.py
@@ -64,6 +64,7 @@ def _BuildManifestMergerClasspath(build_vars):
def main(argv):
argv = build_utils.ExpandFileArgs(argv)
parser = argparse.ArgumentParser(description=__doc__)
+ build_utils.AddDepfileOption(parser)
parser.add_argument('--build-vars',
help='Path to GN build vars file',
required=True)
@@ -75,10 +76,12 @@ def main(argv):
help='GN list of additional manifest to merge')
args = parser.parse_args(argv)
+ classpath = _BuildManifestMergerClasspath(
+ build_utils.ReadBuildVars(args.build_vars))
cmd = [
'java',
'-cp',
- _BuildManifestMergerClasspath(build_utils.ReadBuildVars(args.build_vars)),
+ classpath,
MANIFEST_MERGER_MAIN_CLASS,
'--out', args.output,
]
@@ -94,6 +97,9 @@ def main(argv):
# a nonzero exit code for failures.
fail_func=lambda returncode, stderr: returncode != 0 or
build_utils.IsTimeStale(args.output, [root_manifest] + extras))
+ if args.depfile:
+ inputs = extras + classpath.split(':')
+ build_utils.WriteDepfile(args.depfile, args.output, inputs=inputs)
if __name__ == '__main__':
diff --git a/chromium/build/android/gyp/package_resources.py b/chromium/build/android/gyp/package_resources.py
index c2ba88938a8..8b16f1764be 100755
--- a/chromium/build/android/gyp/package_resources.py
+++ b/chromium/build/android/gyp/package_resources.py
@@ -45,7 +45,7 @@ _CHROME_TO_ANDROID_LOCALE_MAP = {
# unzip -l $FILE_AP_ | cut -c31- | grep res/draw | cut -d'/' -f 2 | sort \
# | uniq | grep -- -tvdpi- | cut -c10-
# and then manually sorted.
-# Note that we can't just do a cross-product of dimentions because the filenames
+# Note that we can't just do a cross-product of dimensions because the filenames
# become too big and aapt fails to create the files.
# This leaves all default drawables (mdpi) in the main apk. Android gets upset
# though if any drawables are missing from the default drawables/ directory.
@@ -106,10 +106,9 @@ def _ParseArgs(args):
help='path to the Android SDK jar.')
parser.add_option('--aapt-path',
help='path to the Android aapt tool')
-
- parser.add_option('--configuration-name',
- help='Gyp\'s configuration name (Debug or Release).')
-
+ parser.add_option('--debuggable',
+ action='store_true',
+ help='Whether to add android:debuggable="true"')
parser.add_option('--android-manifest', help='AndroidManifest.xml path')
parser.add_option('--version-code', help='Version code for apk.')
parser.add_option('--version-name', help='Version name for apk.')
@@ -160,9 +159,8 @@ def _ParseArgs(args):
parser.error('No positional arguments should be given.')
# Check that required options have been provided.
- required_options = ('android_sdk_jar', 'aapt_path', 'configuration_name',
- 'android_manifest', 'version_code', 'version_name',
- 'apk_path')
+ required_options = ('android_sdk_jar', 'aapt_path', 'android_manifest',
+ 'version_code', 'version_name', 'apk_path')
build_utils.CheckOptions(options, parser, required=required_options)
@@ -308,7 +306,7 @@ def _ConstructMostAaptArgs(options):
for lang in options.language_splits:
package_command.extend(('--split', lang))
- if 'Debug' in options.configuration_name:
+ if options.debuggable:
package_command += ['--debug-mode']
if options.locale_whitelist:
diff --git a/chromium/build/android/gyp/process_resources.py b/chromium/build/android/gyp/process_resources.py
index c7c0a56d906..e249f103c83 100755
--- a/chromium/build/android/gyp/process_resources.py
+++ b/chromium/build/android/gyp/process_resources.py
@@ -69,8 +69,6 @@ def _ParseArgs(args):
parser.add_option('--resource-zip-out',
help='Path for output zipped resources.')
- parser.add_option('--R-dir',
- help='directory to hold generated R.java.')
parser.add_option('--srcjar-out',
help='Path to srcjar to contain generated R.java.')
parser.add_option('--r-text-out',
@@ -127,9 +125,6 @@ def _ParseArgs(args):
)
build_utils.CheckOptions(options, parser, required=required_options)
- if (options.R_dir is None) == (options.srcjar_out is None):
- raise Exception('Exactly one of --R-dir or --srcjar-out must be specified.')
-
options.resource_dirs = build_utils.ParseGnList(options.resource_dirs)
options.dependencies_res_zips = (
build_utils.ParseGnList(options.dependencies_res_zips))
@@ -507,10 +502,7 @@ def _OnStaleMd5(options):
CombineZips([options.resource_zip_out] + dep_zips,
options.all_resources_zip_out)
- if options.R_dir:
- build_utils.DeleteDirectory(options.R_dir)
- shutil.copytree(srcjar_dir, options.R_dir)
- else:
+ if options.srcjar_out:
build_utils.ZipDir(options.srcjar_out, srcjar_dir)
if options.r_text_out:
@@ -570,8 +562,6 @@ def main(args):
input_paths=input_paths,
input_strings=input_strings,
output_paths=output_paths,
- # TODO(agrieve): Remove R_dir when it's no longer used (used only by GYP).
- force=options.R_dir,
depfile_deps=depfile_deps)
diff --git a/chromium/build/android/gyp/push_libraries.py b/chromium/build/android/gyp/push_libraries.py
deleted file mode 100755
index 1a64f3dc9b0..00000000000
--- a/chromium/build/android/gyp/push_libraries.py
+++ /dev/null
@@ -1,85 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2013 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.
-
-"""Pushes native libraries to a device.
-
-"""
-
-import optparse
-import os
-import sys
-
-from util import build_device
-from util import build_utils
-from util import md5_check
-
-BUILD_ANDROID_DIR = os.path.abspath(
- os.path.join(os.path.dirname(__file__), os.pardir))
-sys.path.append(BUILD_ANDROID_DIR)
-
-import devil_chromium
-from pylib import constants
-
-def DoPush(options):
- libraries = build_utils.ParseGnList(options.libraries)
-
- device = build_device.GetBuildDeviceFromPath(
- options.build_device_configuration)
- if not device:
- return
-
- serial_number = device.GetSerialNumber()
- # A list so that it is modifiable in Push below.
- needs_directory = [True]
- for lib in libraries:
- device_path = os.path.join(options.device_dir, lib)
- host_path = os.path.join(options.libraries_dir, lib)
-
- def Push():
- if needs_directory:
- device.RunShellCommand(
- ['mkdir', '-p', options.device_dir], check_return=True)
- needs_directory[:] = [] # = False
- device.PushChangedFiles([(os.path.abspath(host_path), device_path)])
-
- record_path = '%s.%s.push.md5.stamp' % (host_path, serial_number)
- md5_check.CallAndRecordIfStale(
- Push,
- record_path=record_path,
- input_paths=[host_path],
- input_strings=[device_path])
-
-
-def main(args):
- args = build_utils.ExpandFileArgs(args)
- parser = optparse.OptionParser()
- parser.add_option('--libraries-dir',
- help='Directory that contains stripped libraries.')
- parser.add_option('--device-dir',
- help='Device directory to push the libraries to.')
- parser.add_option('--libraries',
- help='List of native libraries.')
- parser.add_option('--stamp', help='Path to touch on success.')
- parser.add_option('--build-device-configuration',
- help='Path to build device configuration.')
- parser.add_option('--output-directory',
- help='The output directory.')
- options, _ = parser.parse_args(args)
-
- required_options = ['libraries', 'device_dir', 'libraries']
- build_utils.CheckOptions(options, parser, required=required_options)
-
- devil_chromium.Initialize(
- output_directory=os.path.abspath(options.output_directory))
-
- DoPush(options)
-
- if options.stamp:
- build_utils.Touch(options.stamp)
-
-
-if __name__ == '__main__':
- sys.exit(main(sys.argv[1:]))
diff --git a/chromium/build/android/gyp/retrolambda.py b/chromium/build/android/gyp/retrolambda.py
deleted file mode 100755
index 90e189a5a52..00000000000
--- a/chromium/build/android/gyp/retrolambda.py
+++ /dev/null
@@ -1,68 +0,0 @@
-#!/usr/bin/env python
-#
-# 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 argparse
-import os
-import shutil
-import sys
-import tempfile
-
-from util import build_utils
-
-
-_SRC_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__),
- '..', '..', '..'))
-_RETROLAMBDA_JAR_PATH = os.path.normpath(os.path.join(
- _SRC_ROOT, 'third_party', 'retrolambda', 'retrolambda-2.5.1.jar'))
-
-
-def _OnStaleMd5(input_jar, output_jar, classpath, android_sdk_jar):
- with build_utils.TempDir() as temp_dir:
- build_utils.ExtractAll(input_jar, path=temp_dir)
- cmd = [
- 'java',
- '-Dretrolambda.inputDir=' + temp_dir,
- '-Dretrolambda.classpath=' +
- ':'.join([temp_dir] + classpath + [android_sdk_jar]),
- '-javaagent:' + _RETROLAMBDA_JAR_PATH,
- '-jar',
- _RETROLAMBDA_JAR_PATH,
- ]
-
- build_utils.CheckOutput(cmd, print_stdout=False)
- build_utils.ZipDir(output_jar + '.tmp', temp_dir)
- shutil.move(output_jar + '.tmp', output_jar)
-
-
-def main():
- args = build_utils.ExpandFileArgs(sys.argv[1:])
- parser = argparse.ArgumentParser()
- build_utils.AddDepfileOption(parser)
- parser.add_argument('--input-jar', required=True,
- help='Jar input path to include .class files from.')
- parser.add_argument('--output-jar', required=True,
- help='Jar output path.')
- parser.add_argument('--classpath', required=True,
- help='Classpath.')
- parser.add_argument('--android-sdk-jar', required=True,
- help='Android sdk jar path.')
- options = parser.parse_args(args)
-
- options.classpath = build_utils.ParseGnList(options.classpath)
- input_paths = options.classpath + [options.input_jar]
- output_paths = [options.output_jar]
-
- build_utils.CallAndWriteDepfileIfStale(
- lambda: _OnStaleMd5(options.input_jar, options.output_jar,
- options.classpath, options.android_sdk_jar),
- options,
- input_paths=input_paths,
- input_strings=[],
- output_paths=output_paths)
-
-
-if __name__ == '__main__':
- sys.exit(main())
diff --git a/chromium/build/android/gyp/touch.py b/chromium/build/android/gyp/touch.py
deleted file mode 100755
index 7b4375e40ab..00000000000
--- a/chromium/build/android/gyp/touch.py
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2014 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 sys
-
-from util import build_utils
-
-def main(argv):
- for f in argv[1:]:
- build_utils.Touch(f)
-
-if __name__ == '__main__':
- sys.exit(main(sys.argv))
diff --git a/chromium/build/android/gyp/util/build_device.py b/chromium/build/android/gyp/util/build_device.py
deleted file mode 100644
index 6a703c64e6f..00000000000
--- a/chromium/build/android/gyp/util/build_device.py
+++ /dev/null
@@ -1,102 +0,0 @@
-# Copyright 2013 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.
-
-""" A simple device interface for build steps.
-
-"""
-
-import logging
-import os
-import re
-import sys
-
-from util import build_utils
-
-from devil.android import device_errors
-from devil.android import device_utils
-from devil.android.sdk import adb_wrapper
-
-
-def GetAttachedDevices():
- return [a.GetDeviceSerial()
- for a in adb_wrapper.AdbWrapper.Devices()]
-
-
-class BuildDevice(object):
- def __init__(self, configuration):
- self.id = configuration['id']
- self.description = configuration['description']
- self.install_metadata = configuration['install_metadata']
- assert all(isinstance(entry, dict) for entry in self.install_metadata), (
- 'Invalid BuildDevice configuration')
- self.device = device_utils.DeviceUtils(self.id)
-
- def RunShellCommand(self, *args, **kwargs):
- return self.device.RunShellCommand(*args, **kwargs)
-
- def PushChangedFiles(self, *args, **kwargs):
- return self.device.PushChangedFiles(*args, **kwargs)
-
- def GetSerialNumber(self):
- return self.id
-
- def Install(self, *args, **kwargs):
- return self.device.Install(*args, **kwargs)
-
- def InstallSplitApk(self, *args, **kwargs):
- return self.device.InstallSplitApk(*args, **kwargs)
-
- def GetInstallMetadata(self, apk_package, refresh=False):
- """Gets the metadata on the device for a given apk.
-
- Args:
- apk_package: A string with the package name for which to get metadata.
- refresh: A boolean indicating whether to re-read package metadata from
- the device, or use the values from the current configuration.
- """
- if refresh:
- self.install_metadata = self.device.StatDirectory(
- '/data/app/', as_root=True)
- # Matches names like: org.chromium.chrome.apk, org.chromium.chrome-1.apk
- apk_pattern = re.compile('%s(-[0-9]*)?(.apk)?$' % re.escape(apk_package))
- return next(
- (entry for entry in self.install_metadata
- if apk_pattern.match(entry['filename'])),
- None)
-
-
-def GetConfigurationForDevice(device_id):
- device = device_utils.DeviceUtils(device_id)
- configuration = None
- has_root = False
- is_online = device.IsOnline()
- if is_online:
- has_root = device.HasRoot()
- configuration = {
- 'id': device_id,
- 'description': device.build_description,
- 'install_metadata': device.StatDirectory('/data/app/', as_root=True),
- }
- return configuration, is_online, has_root
-
-
-def WriteConfigurations(configurations, path):
- # Currently we only support installing to the first device.
- build_utils.WriteJson(configurations[:1], path, only_if_changed=True)
-
-
-def ReadConfigurations(path):
- return build_utils.ReadJson(path)
-
-
-def GetBuildDevice(configurations):
- assert len(configurations) == 1
- return BuildDevice(configurations[0])
-
-
-def GetBuildDeviceFromPath(path):
- configurations = ReadConfigurations(path)
- if len(configurations) > 0:
- return GetBuildDevice(ReadConfigurations(path))
- return None
diff --git a/chromium/build/android/gyp/write_build_config.py b/chromium/build/android/gyp/write_build_config.py
index c2dee9a5156..4294c7900e1 100755
--- a/chromium/build/android/gyp/write_build_config.py
+++ b/chromium/build/android/gyp/write_build_config.py
@@ -222,7 +222,9 @@ def _ExtractSharedLibsFromRuntimeDeps(runtime_deps_files):
line = line.rstrip()
if not line.endswith('.so'):
continue
- ret.append(os.path.normpath(line))
+ # Only unstripped .so files are listed in runtime deps.
+ # Convert to the stripped .so by going up one directory.
+ ret.append(os.path.normpath(line.replace('lib.unstripped/', '')))
ret.reverse()
return ret
@@ -305,14 +307,16 @@ def main(argv):
parser.add_option('--secondary-abi-shared-libraries-runtime-deps',
help='Path to file containing runtime deps for secondary '
'abi shared libraries.')
+ parser.add_option('--enable-relocation-packing',
+ help='Whether relocation packing is enabled.')
# apk options
parser.add_option('--apk-path', help='Path to the target\'s apk output.')
parser.add_option('--incremental-apk-path',
help="Path to the target's incremental apk output.")
- parser.add_option('--incremental-install-script-path',
+ parser.add_option('--incremental-install-json-path',
help="Path to the target's generated incremental install "
- "script.")
+ "json.")
parser.add_option('--tested-apk-config',
help='Path to the build config of the tested apk (for an instrumentation '
@@ -470,10 +474,16 @@ def main(argv):
if options.type == 'android_apk':
deps_info['apk_path'] = options.apk_path
deps_info['incremental_apk_path'] = options.incremental_apk_path
- deps_info['incremental_install_script_path'] = (
- options.incremental_install_script_path)
+ deps_info['incremental_install_json_path'] = (
+ options.incremental_install_json_path)
+ deps_info['enable_relocation_packing'] = options.enable_relocation_packing
- if options.type in ('java_binary', 'java_library', 'android_apk', 'dist_jar'):
+ requires_javac_classpath = options.type in (
+ 'java_binary', 'java_library', 'android_apk', 'dist_jar')
+ requires_full_classpath = (
+ options.type == 'java_prebuilt' or requires_javac_classpath)
+
+ if requires_javac_classpath:
# Classpath values filled in below (after applying tested_apk_config).
config['javac'] = {}
@@ -569,8 +579,9 @@ def main(argv):
if options.type in ['android_apk', 'deps_dex']:
deps_dex_files = [c['dex_path'] for c in all_library_deps]
- if options.type in ('java_binary', 'java_library', 'android_apk', 'dist_jar'):
+ if requires_javac_classpath:
javac_classpath = [c['jar_path'] for c in direct_library_deps]
+ if requires_full_classpath:
java_full_classpath = [c['jar_path'] for c in all_library_deps]
if options.extra_classpath_jars:
@@ -648,12 +659,17 @@ def main(argv):
dex_config = config['final_dex']
dex_config['dependency_dex_files'] = deps_dex_files
- if options.type in ('java_binary', 'java_library', 'android_apk', 'dist_jar'):
+ if requires_javac_classpath:
config['javac']['classpath'] = javac_classpath
- config['javac']['interface_classpath'] = [
- _AsInterfaceJar(p) for p in javac_classpath]
+ javac_interface_classpath = [
+ _AsInterfaceJar(p) for p in javac_classpath
+ if p not in deps_info.get('extra_classpath_jars', [])]
+ javac_interface_classpath += deps_info.get('extra_classpath_jars', [])
+ config['javac']['interface_classpath'] = javac_interface_classpath
+
+ if requires_full_classpath:
deps_info['java'] = {
- 'full_classpath': java_full_classpath
+ 'full_classpath': java_full_classpath,
}
if options.type in ('android_apk', 'dist_jar'):
@@ -668,7 +684,6 @@ def main(argv):
}
if options.type == 'android_apk':
- dependency_jars = [c['jar_path'] for c in all_library_deps]
manifest = AndroidManifest(options.android_manifest)
deps_info['package_name'] = manifest.GetPackageName()
if not options.tested_apk_config and manifest.GetInstrumentationElements():
diff --git a/chromium/build/android/gyp/zip.py b/chromium/build/android/gyp/zip.py
deleted file mode 100755
index 51322dfd5b2..00000000000
--- a/chromium/build/android/gyp/zip.py
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2014 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.
-
-"""Archives a set of files.
-"""
-
-import optparse
-import sys
-
-from util import build_utils
-
-def main():
- parser = optparse.OptionParser()
- parser.add_option('--input-dir', help='Directory of files to archive.')
- parser.add_option('--output', help='Path to output archive.')
- options, _ = parser.parse_args()
-
- inputs = build_utils.FindInDirectory(options.input_dir, '*')
- build_utils.DoZip(inputs, options.output, options.input_dir)
-
-
-if __name__ == '__main__':
- sys.exit(main())