From d52819082dfa7dd21f336688482bbb49bd99e0f3 Mon Sep 17 00:00:00 2001 From: Andrew Grieve Date: Thu, 10 Aug 2017 19:09:02 +0000 Subject: [PATCH] Delete a bunch of GYP-only Android build scripts These are all unreferenced. Change-Id: I67a51c0eb85c58f8f1705436345c6b22f2f827d6 Reviewed-on: https://chromium-review.googlesource.com/610262 Reviewed-by: John Budorick Commit-Queue: Andrew Grieve Cr-Original-Commit-Position: refs/heads/master@{#493486} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: e111333d1cfd0625b9bb20627533eff5cc1e835d --- android/gyp/apk_obfuscate.py | 185 --------------------- android/gyp/configure_multidex.py | 87 ---------- android/gyp/create_device_library_links.py | 121 -------------- android/gyp/create_placeholder_files.py | 35 ---- android/gyp/create_standalone_apk.py | 60 ------- android/gyp/generate_copy_ex_outputs.py | 33 ---- android/gyp/get_device_configuration.py | 78 --------- android/gyp/jar_toc.py | 120 ------------- android/gyp/push_libraries.py | 85 ---------- android/gyp/touch.py | 16 -- android/gyp/util/build_device.py | 102 ------------ android/gyp/zip.py | 26 --- 12 files changed, 948 deletions(-) delete mode 100755 android/gyp/apk_obfuscate.py delete mode 100755 android/gyp/configure_multidex.py delete mode 100755 android/gyp/create_device_library_links.py delete mode 100755 android/gyp/create_placeholder_files.py delete mode 100755 android/gyp/create_standalone_apk.py delete mode 100755 android/gyp/generate_copy_ex_outputs.py delete mode 100755 android/gyp/get_device_configuration.py delete mode 100755 android/gyp/jar_toc.py delete mode 100755 android/gyp/push_libraries.py delete mode 100755 android/gyp/touch.py delete mode 100644 android/gyp/util/build_device.py delete mode 100755 android/gyp/zip.py diff --git a/android/gyp/apk_obfuscate.py b/android/gyp/apk_obfuscate.py deleted file mode 100755 index 04a04b3dd..000000000 --- a/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/android/gyp/configure_multidex.py b/android/gyp/configure_multidex.py deleted file mode 100755 index 63c74f07b..000000000 --- a/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/android/gyp/create_device_library_links.py b/android/gyp/create_device_library_links.py deleted file mode 100755 index 542030678..000000000 --- a/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/android/gyp/create_placeholder_files.py b/android/gyp/create_placeholder_files.py deleted file mode 100755 index 103e1df7f..000000000 --- a/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/android/gyp/create_standalone_apk.py b/android/gyp/create_standalone_apk.py deleted file mode 100755 index c56059928..000000000 --- a/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/android/gyp/generate_copy_ex_outputs.py b/android/gyp/generate_copy_ex_outputs.py deleted file mode 100755 index e425b4a6a..000000000 --- a/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/android/gyp/get_device_configuration.py b/android/gyp/get_device_configuration.py deleted file mode 100755 index 0ec08ef95..000000000 --- a/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/android/gyp/jar_toc.py b/android/gyp/jar_toc.py deleted file mode 100755 index 540a3439a..000000000 --- a/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/android/gyp/push_libraries.py b/android/gyp/push_libraries.py deleted file mode 100755 index 1a64f3dc9..000000000 --- a/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/android/gyp/touch.py b/android/gyp/touch.py deleted file mode 100755 index 7b4375e40..000000000 --- a/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/android/gyp/util/build_device.py b/android/gyp/util/build_device.py deleted file mode 100644 index 6a703c64e..000000000 --- a/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/android/gyp/zip.py b/android/gyp/zip.py deleted file mode 100755 index 51322dfd5..000000000 --- a/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())