示例#1
0
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])
示例#2
0
def main():
    parser = optparse.OptionParser()
    parser.add_option('--apk-path', help='Path to .apk to install.')
    parser.add_option(
        '--split-apk-path',
        help='Path to .apk splits (can specify multiple times, causes '
        '--install-multiple to be used.',
        action='append')
    parser.add_option('--android-sdk-tools',
                      help='Path to the Android SDK build tools folder. ' +
                      'Required when using --split-apk-path.')
    parser.add_option(
        '--install-record',
        help='Path to install record (touched only when APK is installed).')
    parser.add_option('--build-device-configuration',
                      help='Path to build device configuration.')
    parser.add_option('--stamp', help='Path to touch on success.')
    parser.add_option('--configuration-name',
                      help='The build CONFIGURATION_NAME')
    parser.add_option('--output-directory', help='The output directory.')
    options, _ = parser.parse_args()

    constants.SetBuildType(options.configuration_name)

    devil_chromium.Initialize(
        output_directory=os.path.abspath(options.output_directory))

    device = build_device.GetBuildDeviceFromPath(
        options.build_device_configuration)
    if not device:
        return

    serial_number = device.GetSerialNumber()
    apk_package = apk_helper.GetPackageName(options.apk_path)

    metadata_path = '%s.%s.device.time.stamp' % (options.apk_path,
                                                 serial_number)

    # If the APK on the device does not match the one that was last installed by
    # the build, then the APK has to be installed (regardless of the md5 record).
    force_install = HasInstallMetadataChanged(device, apk_package,
                                              metadata_path)

    def Install():
        if options.split_apk_path:
            device.InstallSplitApk(options.apk_path, options.split_apk_path)
        else:
            device.Install(options.apk_path, reinstall=True)

        RecordInstallMetadata(device, apk_package, metadata_path)
        build_utils.Touch(options.install_record)

    record_path = '%s.%s.md5.stamp' % (options.apk_path, serial_number)
    md5_check.CallAndRecordIfStale(Install,
                                   record_path=record_path,
                                   input_paths=[options.apk_path],
                                   force=force_install)

    if options.stamp:
        build_utils.Touch(options.stamp)
示例#3
0
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([(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)
示例#4
0
def DoPush(options):
    libraries = build_utils.ReadJson(options.libraries_json)

    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)
                needs_directory[:] = []  # = False
            device.PushIfNeeded(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])
示例#5
0
def main():
    parser = optparse.OptionParser()
    parser.add_option('--apk-path', help='Path to .apk to install.')
    parser.add_option(
        '--split-apk-path',
        help='Path to .apk splits (can specify multiple times, causes '
        '--install-multiple to be used.',
        action='append')
    parser.add_option(
        '--install-record',
        help='Path to install record (touched only when APK is installed).')
    parser.add_option('--build-device-configuration',
                      help='Path to build device configuration.')
    parser.add_option('--stamp', help='Path to touch on success.')
    parser.add_option('--configuration-name',
                      help='The build CONFIGURATION_NAME')
    options, _ = parser.parse_args()

    device = build_device.GetBuildDeviceFromPath(
        options.build_device_configuration)
    if not device:
        return

    constants.SetBuildType(options.configuration_name)

    serial_number = device.GetSerialNumber()
    apk_package = apk_helper.GetPackageName(options.apk_path)

    metadata_path = '%s.%s.device.time.stamp' % (options.apk_path,
                                                 serial_number)

    # If the APK on the device does not match the one that was last installed by
    # the build, then the APK has to be installed (regardless of the md5 record).
    force_install = HasInstallMetadataChanged(device, apk_package,
                                              metadata_path)

    def Install():
        # TODO: Filter splits using split-select.
        active_splits = options.split_apk_path
        if active_splits:
            device.adb.InstallMultiple([options.apk_path] + active_splits,
                                       reinstall=True)
        else:
            device.Install(options.apk_path, reinstall=True)

        RecordInstallMetadata(device, apk_package, metadata_path)
        build_utils.Touch(options.install_record)

    record_path = '%s.%s.md5.stamp' % (options.apk_path, serial_number)
    md5_check.CallAndRecordIfStale(Install,
                                   record_path=record_path,
                                   input_paths=[options.apk_path],
                                   force=force_install)

    if options.stamp:
        build_utils.Touch(options.stamp)
示例#6
0
def main(argv):
    parser = optparse.OptionParser()
    parser.add_option('--android-sdk-tools', help='Path to Android SDK tools.')
    parser.add_option('--apk-path', help='Path to .apk to install.')
    parser.add_option(
        '--install-record',
        help='Path to install record (touched only when APK is installed).')
    parser.add_option('--build-device-configuration',
                      help='Path to build device configuration.')
    parser.add_option('--stamp', help='Path to touch on success.')
    options, _ = parser.parse_args()

    device = build_device.GetBuildDeviceFromPath(
        options.build_device_configuration)
    if not device:
        return

    serial_number = device.GetSerialNumber()
    apk_package = apk_helper.GetPackageName(options.apk_path)

    metadata_path = '%s.%s.device.time.stamp' % (options.apk_path,
                                                 serial_number)

    # If the APK on the device does not match the one that was last installed by
    # the build, then the APK has to be installed (regardless of the md5 record).
    force_install = HasInstallMetadataChanged(device, apk_package,
                                              metadata_path)

    def Install():
        device.Install(options.apk_path, reinstall=True)
        RecordInstallMetadata(device, apk_package, metadata_path)
        build_utils.Touch(options.install_record)

    record_path = '%s.%s.md5.stamp' % (options.apk_path, serial_number)
    md5_check.CallAndRecordIfStale(Install,
                                   record_path=record_path,
                                   input_paths=[options.apk_path],
                                   force=force_install)

    if options.stamp:
        build_utils.Touch(options.stamp)
示例#7
0
def main():
    parser = optparse.OptionParser()
    parser.add_option('--apk-path', help='Path to .apk to install.')
    parser.add_option(
        '--split-apk-path',
        help='Path to .apk splits (can specify multiple times, causes '
        '--install-multiple to be used.',
        action='append')
    parser.add_option('--android-sdk-tools',
                      help='Path to the Android SDK build tools folder. ' +
                      'Required when using --split-apk-path.')
    parser.add_option(
        '--install-record',
        help='Path to install record (touched only when APK is installed).')
    parser.add_option('--build-device-configuration',
                      help='Path to build device configuration.')
    parser.add_option('--stamp', help='Path to touch on success.')
    parser.add_option('--configuration-name',
                      help='The build CONFIGURATION_NAME')
    options, _ = parser.parse_args()

    device = build_device.GetBuildDeviceFromPath(
        options.build_device_configuration)
    if not device:
        return

    constants.SetBuildType(options.configuration_name)

    serial_number = device.GetSerialNumber()
    apk_package = apk_helper.GetPackageName(options.apk_path)

    metadata_path = '%s.%s.device.time.stamp' % (options.apk_path,
                                                 serial_number)

    # If the APK on the device does not match the one that was last installed by
    # the build, then the APK has to be installed (regardless of the md5 record).
    force_install = HasInstallMetadataChanged(device, apk_package,
                                              metadata_path)

    def SelectSplits(target_config, base_apk, split_apks, android_sdk_tools):
        cmd = [
            os.path.join(android_sdk_tools, 'split-select'),
            '--target',
            target_config,
            '--base',
            base_apk,
        ]
        for split in split_apks:
            cmd.extend(('--split', split))

        # split-select outputs one path per line and a blank line at the end.
        output = build_utils.CheckOutput(cmd)
        return [x for x in output.split('\n') if x]

    def Install():
        if options.split_apk_path:
            requiredSdkVersion = constants.ANDROID_SDK_VERSION_CODES.LOLLIPOP
            actualSdkVersion = device.device.build_version_sdk
            if actualSdkVersion < requiredSdkVersion:
                raise Exception(
                    ('--split-apk-path requires sdk version %s. Device has '
                     'version %s') % (requiredSdkVersion, actualSdkVersion))
            device_config = RetrieveDeviceConfig(device.device)
            active_splits = SelectSplits(device_config, options.apk_path,
                                         options.split_apk_path,
                                         options.android_sdk_tools)

            all_apks = [options.apk_path] + active_splits
            device.device.adb.InstallMultiple(all_apks, reinstall=True)
        else:
            device.Install(options.apk_path, reinstall=True)

        RecordInstallMetadata(device, apk_package, metadata_path)
        build_utils.Touch(options.install_record)

    record_path = '%s.%s.md5.stamp' % (options.apk_path, serial_number)
    md5_check.CallAndRecordIfStale(Install,
                                   record_path=record_path,
                                   input_paths=[options.apk_path],
                                   force=force_install)

    if options.stamp:
        build_utils.Touch(options.stamp)