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)
示例#2
0
def main(argv):
  try:
    args = argv[1:]
    stdout = build_utils.CheckOutput(['ant'] + args)
  except build_utils.CalledProcessError:
    # It is very difficult to diagnose ant failures without the '-verbose'
    # argument. So, when an ant command fails, re-run it with '-verbose' so that
    # the cause of the failure is easier to identify.
    verbose_args = ['-verbose'] + [a for a in argv[1:] if a != '-quiet']
    try:
      stdout = build_utils.CheckOutput(['ant'] + verbose_args)
    except build_utils.CalledProcessError:
      traceback.print_exc()
      sys.exit(1)

    # If this did sys.exit(1), building again would succeed (which would be
    # awkward). Instead, just print a big warning.
    build_utils.PrintBigWarning(
        'This is unexpected. `ant ' + ' '.join(args) + '` failed.' +
        'But, running `ant ' + ' '.join(verbose_args) + '` passed.')

  stdout = stdout.strip().split('\n')
  for line in stdout:
    if line.strip() == 'BUILD SUCCESSFUL':
      break
    print line
def main(argv):
    if not build_utils.IsDeviceReady():
        build_utils.PrintBigWarning(
            'Zero (or multiple) devices attached. Skipping creating symlinks.')
        return

    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-json',
                      help='Path to the json 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.')
    options, _ = parser.parse_args()

    required_options = [
        'apk', 'libraries_json', 'script_host_path', 'script_device_path',
        'target_dir'
    ]
    build_utils.CheckOptions(options, parser, required=required_options)

    CreateSymlinkScript(options)
    TriggerSymlinkScript(options)

    if options.stamp:
        build_utils.Touch(options.stamp)
示例#4
0
def main(argv):
    if not build_utils.IsDeviceReady():
        build_utils.PrintBigWarning(
            'Zero (or multiple) devices attached. Skipping APK install.')
        return

    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('--stamp', help='Path to touch on success.')
    options, _ = parser.parse_args()

    # TODO(cjhopman): Should this install to all devices/be configurable?
    install_cmd = [
        os.path.join(options.android_sdk_tools, 'adb'), 'install', '-r',
        options.apk_path
    ]

    serial_number = android_commands.AndroidCommands().Adb().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(apk_package, metadata_path)

    def Install():
        build_utils.CheckCallDie(install_cmd)
        RecordInstallMetadata(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],
                                   input_strings=install_cmd,
                                   force=force_install)

    if options.stamp:
        build_utils.Touch(options.stamp)
示例#5
0
def main(argv):
    option_parser = optparse.OptionParser()
    build_utils.AddDepfileOption(option_parser)
    options, args = option_parser.parse_args(argv[1:])

    try:
        stdout = build_utils.CheckOutput(['ant'] + args)
    except build_utils.CalledProcessError:
        # It is very difficult to diagnose ant failures without the '-verbose'
        # argument. So, when an ant command fails, re-run it with '-verbose' so that
        # the cause of the failure is easier to identify.
        verbose_args = ['-verbose'] + [a for a in args if a != '-quiet']
        try:
            stdout = build_utils.CheckOutput(['ant'] + verbose_args)
        except build_utils.CalledProcessError:
            traceback.print_exc()
            sys.exit(1)

        # If this did sys.exit(1), building again would succeed (which would be
        # awkward). Instead, just print a big warning.
        build_utils.PrintBigWarning('This is unexpected. `ant ' +
                                    ' '.join(args) + '` failed.' +
                                    'But, running `ant ' +
                                    ' '.join(verbose_args) + '` passed.')

    stdout = stdout.strip().split('\n')
    for line in stdout:
        if line.strip() == 'BUILD SUCCESSFUL':
            break
        print line

    if options.depfile:
        assert '-buildfile' in args
        ant_buildfile = args[args.index('-buildfile') + 1]

        build_utils.WriteDepfile(options.depfile, [ant_buildfile] +
                                 build_utils.GetPythonDependencies())