Exemplo n.º 1
0
def main(args):
  args = build_utils.ExpandFileArgs(args)
  options = _ParseArgs(args)

  # Order of these must match order specified in GN so that the correct one
  # appears first in the depfile.
  possible_output_paths = [
    options.resource_zip_out,
    options.r_text_out,
    options.srcjar_out,
  ]
  output_paths = [x for x in possible_output_paths if x]

  # List python deps in input_strings rather than input_paths since the contents
  # of them does not change what gets written to the depsfile.
  input_strings = options.extra_res_packages + [
      options.custom_package,
      options.shared_resources,
      options.strip_drawables,
  ]

  possible_input_paths = [
    options.aapt_path,
    options.android_manifest,
  ]
  possible_input_paths += options.include_resources
  input_paths = [x for x in possible_input_paths if x]
  input_paths.extend(options.dependencies_res_zips)
  input_paths.extend(options.extra_r_text_files)

  # Resource files aren't explicitly listed in GN. Listing them in the depfile
  # ensures the target will be marked stale when resource files are removed.
  depfile_deps = []
  resource_names = []
  for resource_dir in options.resource_dirs:
    for resource_file in build_utils.FindInDirectory(resource_dir, '*'):
      # Don't list the empty .keep file in depfile. Since it doesn't end up
      # included in the .zip, it can lead to -w 'dupbuild=err' ninja errors
      # if ever moved.
      if not resource_file.endswith(os.path.join('empty', '.keep')):
        input_paths.append(resource_file)
        depfile_deps.append(resource_file)
      resource_names.append(os.path.relpath(resource_file, resource_dir))

  # Resource filenames matter to the output, so add them to strings as well.
  # This matters if a file is renamed but not changed (http://crbug.com/597126).
  input_strings.extend(sorted(resource_names))

  md5_check.CallAndWriteDepfileIfStale(
      lambda: _OnStaleMd5(options),
      options,
      input_paths=input_paths,
      input_strings=input_strings,
      output_paths=output_paths,
      depfile_deps=depfile_deps)
Exemplo n.º 2
0
def main(args):
    args = build_utils.ExpandFileArgs(args)
    options = _ParseArgs(args)

    # Order of these must match order specified in GN so that the correct one
    # appears first in the depfile.
    output_paths = [
        options.resource_zip_out,
        options.resource_zip_out + '.info',
        options.r_text_out,
    ]

    input_paths = [options.res_sources_path]
    if options.r_text_in:
        input_paths += [options.r_text_in]

    # Resource files aren't explicitly listed in GN. Listing them in the depfile
    # ensures the target will be marked stale when resource files are removed.
    depfile_deps = []
    resource_names = []
    for resource_dir in options.resource_dirs:
        for resource_file in build_utils.FindInDirectory(resource_dir, '*'):
            # Don't list the empty .keep file in depfile. Since it doesn't end up
            # included in the .zip, it can lead to -w 'dupbuild=err' ninja errors
            # if ever moved.
            if not resource_file.endswith(os.path.join('empty', '.keep')):
                input_paths.append(resource_file)
                depfile_deps.append(resource_file)
            resource_names.append(os.path.relpath(resource_file, resource_dir))

    # Resource filenames matter to the output, so add them to strings as well.
    # This matters if a file is renamed but not changed (http://crbug.com/597126).
    input_strings = sorted(resource_names) + [
        options.shared_resources,
        options.strip_drawables,
    ]

    # Since android_resources targets like *__all_dfm_resources depend on java
    # targets that they do not need (in reality it only needs the transitive
    # resource targets that those java targets depend on), md5_check is used to
    # prevent outputs from being re-written when real inputs have not changed.
    md5_check.CallAndWriteDepfileIfStale(lambda: _OnStaleMd5(options),
                                         options,
                                         input_paths=input_paths,
                                         input_strings=input_strings,
                                         output_paths=output_paths,
                                         depfile_deps=depfile_deps)
Exemplo n.º 3
0
def main(args):
    build_utils.InitLogging('DEX_DEBUG')
    options = _ParseArgs(args)

    options.class_inputs += options.class_inputs_filearg
    options.dex_inputs += options.dex_inputs_filearg

    input_paths = options.class_inputs + options.dex_inputs
    if options.multi_dex and options.main_dex_list_path:
        input_paths.append(options.main_dex_list_path)
    input_paths.append(options.r8_jar_path)

    output_paths = [options.output]

    if options.incremental_dir:
        final_dex_inputs = _IntermediateDexFilePathsFromInputJars(
            options.class_inputs, options.incremental_dir)
        output_paths += final_dex_inputs
        track_subpaths_allowlist = options.class_inputs
    else:
        final_dex_inputs = list(options.class_inputs)
        track_subpaths_allowlist = None
    final_dex_inputs += options.dex_inputs

    dex_cmd = [
        build_utils.JAVA_PATH, '-jar', options.r8_jar_path, 'd8',
        '--no-desugaring'
    ]
    if options.release:
        dex_cmd += ['--release']
    if options.min_api:
        dex_cmd += ['--min-api', options.min_api]

    if options.force_enable_assertions:
        dex_cmd += ['--force-enable-assertions']

    md5_check.CallAndWriteDepfileIfStale(
        lambda changes: _OnStaleMd5(changes, options, final_dex_inputs, dex_cmd
                                    ),
        options,
        depfile_deps=options.class_inputs_filearg + options.dex_inputs_filearg,
        output_paths=output_paths,
        input_paths=input_paths,
        input_strings=dex_cmd + [bool(options.incremental_dir)],
        pass_changes=True,
        track_subpaths_allowlist=track_subpaths_allowlist)
Exemplo n.º 4
0
def main(args):
    logging.basicConfig(
        level=logging.INFO if os.environ.get('DEX_DEBUG') else logging.WARNING,
        format='%(levelname).1s %(relativeCreated)6d %(message)s')
    options = _ParseArgs(args)

    options.class_inputs += options.class_inputs_filearg
    options.dex_inputs += options.dex_inputs_filearg

    input_paths = options.class_inputs + options.dex_inputs
    if options.multi_dex and options.main_dex_list_path:
        input_paths.append(options.main_dex_list_path)
    input_paths.append(options.r8_jar_path)

    output_paths = [options.output]

    if options.incremental_dir:
        final_dex_inputs = _IntermediateDexFilePathsFromInputJars(
            options.class_inputs, options.incremental_dir)
        output_paths += final_dex_inputs
        track_subpaths_whitelist = options.class_inputs
    else:
        final_dex_inputs = list(options.class_inputs)
        track_subpaths_whitelist = None
    final_dex_inputs += options.dex_inputs

    dex_cmd = [
        build_utils.JAVA_PATH, '-jar', options.r8_jar_path, 'd8',
        '--no-desugaring'
    ]
    if options.release:
        dex_cmd += ['--release']
    if options.min_api:
        dex_cmd += ['--min-api', options.min_api]

    md5_check.CallAndWriteDepfileIfStale(
        lambda changes: _OnStaleMd5(changes, options, final_dex_inputs, dex_cmd
                                    ),
        options,
        depfile_deps=options.class_inputs_filearg + options.dex_inputs_filearg,
        output_paths=output_paths,
        input_paths=input_paths,
        input_strings=dex_cmd + [bool(options.incremental_dir)],
        pass_changes=True,
        track_subpaths_whitelist=track_subpaths_whitelist)
Exemplo n.º 5
0
def main(args):
    build_utils.InitLogging('DEX_DEBUG')
    options = _ParseArgs(args)

    options.class_inputs += options.class_inputs_filearg
    options.dex_inputs += options.dex_inputs_filearg

    input_paths = options.class_inputs + options.dex_inputs
    if options.multi_dex and options.main_dex_list_path:
        input_paths.append(options.main_dex_list_path)
    input_paths.append(options.r8_jar_path)
    input_paths.append(options.custom_d8_jar_path)

    depfile_deps = options.class_inputs_filearg + options.dex_inputs_filearg

    output_paths = [options.output]

    track_subpaths_allowlist = []
    if options.incremental_dir:
        final_dex_inputs = _IntermediateDexFilePathsFromInputJars(
            options.class_inputs, options.incremental_dir)
        output_paths += final_dex_inputs
        track_subpaths_allowlist += options.class_inputs
    else:
        final_dex_inputs = list(options.class_inputs)
    final_dex_inputs += options.dex_inputs

    dex_cmd = build_utils.JavaCmd(options.warnings_as_errors) + [
        '-cp',
        '{}:{}'.format(options.r8_jar_path, options.custom_d8_jar_path),
        'org.chromium.build.CustomD8',
    ]
    if options.release:
        dex_cmd += ['--release']
    if options.min_api:
        dex_cmd += ['--min-api', options.min_api]

    if not options.desugar:
        dex_cmd += ['--no-desugaring']
    elif options.classpath:
        # The classpath is used by D8 to for interface desugaring.
        if options.desugar_dependencies:
            dex_cmd += ['--desugar-dependencies', options.desugar_dependencies]
            if track_subpaths_allowlist:
                track_subpaths_allowlist += options.classpath
        depfile_deps += options.classpath
        input_paths += options.classpath
        dex_cmd += ['--lib', build_utils.JAVA_HOME]
        for path in options.bootclasspath:
            dex_cmd += ['--lib', path]
        # Still pass the entire classpath in case a new dependency is needed by
        # desugar, so that desugar_dependencies will be updated for the next build.
        for path in options.classpath:
            dex_cmd += ['--classpath', path]
        depfile_deps += options.bootclasspath
        input_paths += options.bootclasspath

    if options.desugar_jdk_libs_json:
        dex_cmd += ['--desugared-lib', options.desugar_jdk_libs_json]
    if options.force_enable_assertions:
        dex_cmd += ['--force-enable-assertions']

    # The changes feature from md5_check allows us to only re-dex the class files
    # that have changed and the class files that need to be re-desugared by D8.
    md5_check.CallAndWriteDepfileIfStale(
        lambda changes: _OnStaleMd5(changes, options, final_dex_inputs, dex_cmd
                                    ),
        options,
        input_paths=input_paths,
        input_strings=dex_cmd + [bool(options.incremental_dir)],
        output_paths=output_paths,
        pass_changes=True,
        track_subpaths_allowlist=track_subpaths_allowlist,
        depfile_deps=depfile_deps)
Exemplo n.º 6
0
def main(argv):
  build_utils.InitLogging('JAVAC_DEBUG')
  colorama.init()

  argv = build_utils.ExpandFileArgs(argv)
  options, java_files = _ParseOptions(argv)

  javac_cmd = []
  if options.gomacc_path:
    javac_cmd.append(options.gomacc_path)
  javac_cmd.append(build_utils.JAVAC_PATH)

  javac_args = [
      '-g',
      # Chromium only allows UTF8 source files.  Being explicit avoids
      # javac pulling a default encoding from the user's environment.
      '-encoding',
      'UTF-8',
      # Prevent compiler from compiling .java files not listed as inputs.
      # See: http://blog.ltgt.net/most-build-tools-misuse-javac/
      '-sourcepath',
      ':',
  ]

  if options.enable_errorprone:
    # All errorprone args are passed space-separated in a single arg.
    errorprone_flags = ['-Xplugin:ErrorProne']
    for warning in ERRORPRONE_WARNINGS_TO_TURN_OFF:
      errorprone_flags.append('-Xep:{}:OFF'.format(warning))
    for warning in ERRORPRONE_WARNINGS_TO_ERROR:
      errorprone_flags.append('-Xep:{}:ERROR'.format(warning))
    if not options.warnings_as_errors:
      errorprone_flags.append('-XepAllErrorsAsWarnings')
    javac_args += ['-XDcompilePolicy=simple', ' '.join(errorprone_flags)]
    # This flag quits errorprone after checks and before code generation, since
    # we do not need errorprone outputs, this speeds up errorprone by 4 seconds
    # for chrome_java.
    javac_args += ['-XDshould-stop.ifNoError=FLOW']

  if options.java_version:
    javac_args.extend([
        '-source',
        options.java_version,
        '-target',
        options.java_version,
    ])
  if options.java_version == '1.8':
    # Android's boot jar doesn't contain all java 8 classes.
    options.bootclasspath.append(build_utils.RT_JAR_PATH)

  if options.warnings_as_errors:
    javac_args.extend(['-Werror'])
  else:
    # XDignore.symbol.file makes javac compile against rt.jar instead of
    # ct.sym. This means that using a java internal package/class will not
    # trigger a compile warning or error.
    javac_args.extend(['-XDignore.symbol.file'])

  if options.processors:
    javac_args.extend(['-processor', ','.join(options.processors)])
  else:
    # This effectively disables all annotation processors, even including
    # annotation processors in service provider configuration files named
    # META-INF/. See the following link for reference:
    #     https://docs.oracle.com/en/java/javase/11/tools/javac.html
    javac_args.extend(['-proc:none'])

  if options.bootclasspath:
    javac_args.extend(['-bootclasspath', ':'.join(options.bootclasspath)])

  if options.processorpath:
    javac_args.extend(['-processorpath', ':'.join(options.processorpath)])
  if options.processor_args:
    for arg in options.processor_args:
      javac_args.extend(['-A%s' % arg])

  javac_args.extend(options.javac_arg)

  classpath_inputs = (
      options.bootclasspath + options.classpath + options.processorpath)

  depfile_deps = classpath_inputs
  # Files that are already inputs in GN should go in input_paths.
  input_paths = depfile_deps + options.java_srcjars + java_files
  if options.header_jar:
    input_paths.append(options.header_jar)
  input_paths += [x[0] for x in options.additional_jar_files]

  output_paths = [
      options.jar_path,
      options.jar_path + '.info',
  ]

  input_strings = javac_cmd + javac_args + options.classpath + java_files
  if options.jar_info_exclude_globs:
    input_strings.append(options.jar_info_exclude_globs)

  md5_check.CallAndWriteDepfileIfStale(
      lambda: _OnStaleMd5(options, javac_cmd, javac_args, java_files),
      options,
      depfile_deps=depfile_deps,
      input_paths=input_paths,
      input_strings=input_strings,
      output_paths=output_paths)
Exemplo n.º 7
0
def main(args):
    build_utils.InitLogging('RESOURCE_DEBUG')
    args = build_utils.ExpandFileArgs(args)
    options = _ParseArgs(args)

    if options.expected_file:
        actual_data = _CreateNormalizedManifest(options)
        diff_utils.CheckExpectations(actual_data, options)
        if options.only_verify_expectations:
            return

    depfile_deps = (options.dependencies_res_zips +
                    options.dependencies_res_zip_overlays +
                    options.extra_main_r_text_files +
                    options.include_resources)

    possible_input_paths = depfile_deps + options.resources_config_paths + [
        options.aapt2_path,
        options.android_manifest,
        options.expected_file,
        options.expected_file_base,
        options.shared_resources_allowlist,
        options.use_resource_ids_path,
        options.webp_binary,
    ]
    input_paths = [p for p in possible_input_paths if p]
    input_strings = [
        options.app_as_shared_lib,
        options.arsc_package_name,
        options.debuggable,
        options.extra_res_packages,
        options.failure_file,
        options.include_resources,
        options.locale_allowlist,
        options.manifest_package,
        options.max_sdk_version,
        options.min_sdk_version,
        options.no_xml_namespaces,
        options.package_id,
        options.package_name,
        options.png_to_webp,
        options.rename_manifest_package,
        options.resource_exclusion_exceptions,
        options.resource_exclusion_regex,
        options.r_java_root_package_name,
        options.shared_resources,
        options.shared_resources_allowlist_locales,
        options.short_resource_paths,
        options.strip_resource_names,
        options.support_zh_hk,
        options.target_sdk_version,
        options.values_filter_rules,
        options.version_code,
        options.version_name,
        options.webp_cache_dir,
    ]
    output_paths = [options.srcjar_out]
    possible_output_paths = [
        options.actual_file,
        options.arsc_path,
        options.emit_ids_out,
        options.info_path,
        options.optimized_arsc_path,
        options.optimized_proto_path,
        options.proguard_file,
        options.proguard_file_main_dex,
        options.proto_path,
        options.resources_path_map_out_path,
        options.r_text_out,
    ]
    output_paths += [p for p in possible_output_paths if p]

    # Since we overspecify deps, this target depends on java deps that are not
    # going to change its output. This target is also slow (6-12 seconds) and
    # blocking the critical path. We want changes to java_library targets to not
    # trigger re-compilation of resources, thus we need to use md5_check.
    md5_check.CallAndWriteDepfileIfStale(lambda: _OnStaleMd5(options),
                                         options,
                                         input_paths=input_paths,
                                         input_strings=input_strings,
                                         output_paths=output_paths,
                                         depfile_deps=depfile_deps)
Exemplo n.º 8
0
def main(argv):
    build_utils.InitLogging('JAVAC_DEBUG')
    argv = build_utils.ExpandFileArgs(argv)
    options, java_files = _ParseOptions(argv)

    # Only use the build server for errorprone runs.
    if (options.enable_errorprone and not options.skip_build_server
            and server_utils.MaybeRunCommand(name=options.target_name,
                                             argv=sys.argv,
                                             stamp_file=options.jar_path)):
        return

    javac_cmd = []
    if options.gomacc_path:
        javac_cmd.append(options.gomacc_path)
    javac_cmd.append(build_utils.JAVAC_PATH)

    javac_args = [
        '-g',
        # Chromium only allows UTF8 source files.  Being explicit avoids
        # javac pulling a default encoding from the user's environment.
        '-encoding',
        'UTF-8',
        # Prevent compiler from compiling .java files not listed as inputs.
        # See: http://blog.ltgt.net/most-build-tools-misuse-javac/
        '-sourcepath',
        ':',
    ]

    if options.enable_errorprone:
        # All errorprone args are passed space-separated in a single arg.
        errorprone_flags = ['-Xplugin:ErrorProne']
        # Make everything a warning so that when treat_warnings_as_errors is false,
        # they do not fail the build.
        errorprone_flags += ['-XepAllErrorsAsWarnings']
        # Don't check generated files.
        errorprone_flags += ['-XepDisableWarningsInGeneratedCode']
        errorprone_flags.extend('-Xep:{}:OFF'.format(x)
                                for x in ERRORPRONE_WARNINGS_TO_DISABLE)
        errorprone_flags.extend('-Xep:{}:WARN'.format(x)
                                for x in ERRORPRONE_WARNINGS_TO_ENABLE)

        if ERRORPRONE_CHECKS_TO_APPLY:
            errorprone_flags += [
                '-XepPatchLocation:IN_PLACE',
                '-XepPatchChecks:,' + ','.join(ERRORPRONE_CHECKS_TO_APPLY)
            ]

        javac_args += ['-XDcompilePolicy=simple', ' '.join(errorprone_flags)]

        # This flag quits errorprone after checks and before code generation, since
        # we do not need errorprone outputs, this speeds up errorprone by 4 seconds
        # for chrome_java.
        if not ERRORPRONE_CHECKS_TO_APPLY:
            javac_args += ['-XDshould-stop.ifNoError=FLOW']

    if options.java_version:
        javac_args.extend([
            '-source',
            options.java_version,
            '-target',
            options.java_version,
        ])
    if options.java_version == '1.8':
        # Android's boot jar doesn't contain all java 8 classes.
        options.bootclasspath.append(build_utils.RT_JAR_PATH)

    # This effectively disables all annotation processors, even including
    # annotation processors in service provider configuration files named
    # META-INF/. See the following link for reference:
    #     https://docs.oracle.com/en/java/javase/11/tools/javac.html
    javac_args.extend(['-proc:none'])

    if options.bootclasspath:
        javac_args.extend(['-bootclasspath', ':'.join(options.bootclasspath)])

    if options.processorpath:
        javac_args.extend(['-processorpath', ':'.join(options.processorpath)])
    if options.processor_args:
        for arg in options.processor_args:
            javac_args.extend(['-A%s' % arg])

    javac_args.extend(options.javac_arg)

    classpath_inputs = (options.bootclasspath + options.classpath +
                        options.processorpath)

    depfile_deps = classpath_inputs
    # Files that are already inputs in GN should go in input_paths.
    input_paths = depfile_deps + options.java_srcjars + java_files
    if options.header_jar:
        input_paths.append(options.header_jar)
    input_paths += [x[0] for x in options.additional_jar_files]

    output_paths = [options.jar_path]
    if not options.enable_errorprone:
        output_paths += [options.jar_path + '.info']

    input_strings = javac_cmd + javac_args + options.classpath + java_files + [
        options.warnings_as_errors, options.jar_info_exclude_globs
    ]

    # Use md5_check for |pass_changes| feature.
    md5_check.CallAndWriteDepfileIfStale(lambda changes: _OnStaleMd5(
        changes, options, javac_cmd, javac_args, java_files),
                                         options,
                                         depfile_deps=depfile_deps,
                                         input_paths=input_paths,
                                         input_strings=input_strings,
                                         output_paths=output_paths,
                                         pass_changes=True)
Exemplo n.º 9
0
def main(argv):
    build_utils.InitLogging('JAVAC_DEBUG')
    colorama.init()

    argv = build_utils.ExpandFileArgs(argv)
    options, java_files = _ParseOptions(argv)
    javac_path = build_utils.JAVAC_PATH

    javac_cmd = [
        javac_path,
        '-g',
        # Chromium only allows UTF8 source files.  Being explicit avoids
        # javac pulling a default encoding from the user's environment.
        '-encoding',
        'UTF-8',
        # Prevent compiler from compiling .java files not listed as inputs.
        # See: http://blog.ltgt.net/most-build-tools-misuse-javac/
        '-sourcepath',
        ':',
    ]

    if options.enable_errorprone:
        # All errorprone args are passed space-separated in a single arg.
        errorprone_flags = ['-Xplugin:ErrorProne']
        for warning in ERRORPRONE_WARNINGS_TO_TURN_OFF:
            errorprone_flags.append('-Xep:{}:OFF'.format(warning))
        for warning in ERRORPRONE_WARNINGS_TO_ERROR:
            errorprone_flags.append('-Xep:{}:ERROR'.format(warning))
        if not options.warnings_as_errors:
            errorprone_flags.append('-XepAllErrorsAsWarnings')
        javac_cmd += ['-XDcompilePolicy=simple', ' '.join(errorprone_flags)]

    if options.java_version:
        javac_cmd.extend([
            '-source',
            options.java_version,
            '-target',
            options.java_version,
        ])
    if options.java_version == '1.8':
        # Android's boot jar doesn't contain all java 8 classes.
        options.bootclasspath.append(build_utils.RT_JAR_PATH)

    if options.warnings_as_errors:
        javac_cmd.extend(['-Werror'])
    else:
        # XDignore.symbol.file makes javac compile against rt.jar instead of
        # ct.sym. This means that using a java internal package/class will not
        # trigger a compile warning or error.
        javac_cmd.extend(['-XDignore.symbol.file'])

    if options.processors:
        javac_cmd.extend(['-processor', ','.join(options.processors)])

    if options.bootclasspath:
        javac_cmd.extend(['-bootclasspath', ':'.join(options.bootclasspath)])

    if options.processorpath:
        javac_cmd.extend(['-processorpath', ':'.join(options.processorpath)])
    if options.processor_args:
        for arg in options.processor_args:
            javac_cmd.extend(['-A%s' % arg])

    javac_cmd.extend(options.javac_arg)

    classpath_inputs = (options.bootclasspath + options.classpath +
                        options.processorpath)

    # GN already knows of java_files, so listing them just make things worse when
    # they change.
    depfile_deps = classpath_inputs + options.java_srcjars
    input_paths = depfile_deps + java_files
    input_paths += [x[0] for x in options.additional_jar_files]

    output_paths = [
        options.jar_path,
        options.jar_path + '.info',
    ]

    input_strings = javac_cmd + options.classpath + java_files
    if options.jar_info_exclude_globs:
        input_strings.append(options.jar_info_exclude_globs)
    md5_check.CallAndWriteDepfileIfStale(
        lambda: _OnStaleMd5(options, javac_cmd, java_files, options.classpath),
        options,
        depfile_deps=depfile_deps,
        input_paths=input_paths,
        input_strings=input_strings,
        output_paths=output_paths)
Exemplo n.º 10
0
def main(args):
    build_utils.InitLogging('DEX_DEBUG')
    options = _ParseArgs(args)

    options.class_inputs += options.class_inputs_filearg
    options.dex_inputs += options.dex_inputs_filearg

    input_paths = options.class_inputs + options.dex_inputs
    if options.multi_dex and options.main_dex_list_path:
        input_paths.append(options.main_dex_list_path)
    input_paths.append(options.r8_jar_path)

    depfile_deps = options.class_inputs_filearg + options.dex_inputs_filearg

    output_paths = [options.output]

    if options.incremental_dir:
        final_dex_inputs = _IntermediateDexFilePathsFromInputJars(
            options.class_inputs, options.incremental_dir)
        output_paths += final_dex_inputs
        track_subpaths_allowlist = options.class_inputs
    else:
        final_dex_inputs = list(options.class_inputs)
        track_subpaths_allowlist = None
    final_dex_inputs += options.dex_inputs

    dex_cmd = build_utils.JavaCmd(options.warnings_as_errors) + [
        '-cp',
        options.r8_jar_path,
        'com.android.tools.r8.D8',
    ]
    if options.release:
        dex_cmd += ['--release']
    if options.min_api:
        dex_cmd += ['--min-api', options.min_api]

    if not options.desugar:
        dex_cmd += ['--no-desugaring']
    elif options.classpath:
        # Don't pass classpath when Desugar.jar is doing interface desugaring.
        dex_cmd += ['--lib', build_utils.JAVA_HOME]
        for path in options.bootclasspath:
            dex_cmd += ['--lib', path]
        for path in options.classpath:
            dex_cmd += ['--classpath', path]
        depfile_deps += options.classpath
        depfile_deps += options.bootclasspath
        input_paths += options.classpath
        input_paths += options.bootclasspath

    if options.desugar_jdk_libs_json:
        dex_cmd += ['--desugared-lib', options.desugar_jdk_libs_json]
    if options.force_enable_assertions:
        dex_cmd += ['--force-enable-assertions']

    md5_check.CallAndWriteDepfileIfStale(
        lambda changes: _OnStaleMd5(changes, options, final_dex_inputs, dex_cmd
                                    ),
        options,
        input_paths=input_paths,
        input_strings=dex_cmd + [bool(options.incremental_dir)],
        output_paths=output_paths,
        pass_changes=True,
        track_subpaths_allowlist=track_subpaths_allowlist,
        depfile_deps=depfile_deps)
Exemplo n.º 11
0
def main():
  parser = argparse.ArgumentParser()
  build_utils.AddDepfileOption(parser)

  parser.add_argument('--lint-path', required=True,
                      help='Path to lint executable.')
  parser.add_argument('--product-dir', required=True,
                      help='Path to product dir.')
  parser.add_argument('--result-path', required=True,
                      help='Path to XML lint result file.')
  parser.add_argument('--cache-dir', required=True,
                      help='Path to the directory in which the android cache '
                           'directory tree should be stored.')
  parser.add_argument('--platform-xml-path', required=True,
                      help='Path to api-platforms.xml')
  parser.add_argument('--android-sdk-version',
                      help='Version (API level) of the Android SDK used for '
                           'building.')
  parser.add_argument('--can-fail-build', action='store_true',
                      help='If set, script will exit with nonzero exit status'
                           ' if lint errors are present')
  parser.add_argument('--include-unexpected-failures', action='store_true',
                      help='If set, script will exit with nonzero exit status'
                           ' if lint itself crashes with unexpected failures.')
  parser.add_argument('--config-path',
                      help='Path to lint suppressions file.')
  parser.add_argument('--disable',
                      help='List of checks to disable.')
  parser.add_argument('--jar-path',
                      help='Jar file containing class files.')
  parser.add_argument('--java-sources-file',
                      help='File containing a list of java files.')
  parser.add_argument('--manifest-path',
                      help='Path to AndroidManifest.xml')
  parser.add_argument('--classpath', default=[], action='append',
                      help='GYP-list of classpath .jar files')
  parser.add_argument('--processed-config-path',
                      help='Path to processed lint suppressions file.')
  parser.add_argument('--resource-dir',
                      help='Path to resource dir.')
  parser.add_argument('--resource-sources', default=[], action='append',
                      help='GYP-list of resource sources (directories with '
                      'resources or archives created by resource-generating '
                      'tasks.')
  parser.add_argument('--silent', action='store_true',
                      help='If set, script will not log anything.')
  parser.add_argument('--src-dirs',
                      help='Directories containing java files.')
  parser.add_argument('--srcjars',
                      help='GN list of included srcjars.')
  parser.add_argument(
      '--min-sdk-version',
      required=True,
      help='Minimal SDK version to lint against.')
  parser.add_argument(
      '--manifest-package', help='Package name of the AndroidManifest.xml.')

  args = parser.parse_args(build_utils.ExpandFileArgs(sys.argv[1:]))

  sources = []
  if args.src_dirs:
    src_dirs = build_utils.ParseGnList(args.src_dirs)
    sources = _FindInDirectories(src_dirs, '*.java')
  elif args.java_sources_file:
    sources.extend(build_utils.ReadSourcesList(args.java_sources_file))

  if args.config_path and not args.processed_config_path:
    parser.error('--config-path specified without --processed-config-path')
  elif args.processed_config_path and not args.config_path:
    parser.error('--processed-config-path specified without --config-path')

  input_paths = [
      args.lint_path,
      args.platform_xml_path,
  ]
  if args.config_path:
    input_paths.append(args.config_path)
  if args.jar_path:
    input_paths.append(args.jar_path)
  if args.manifest_path:
    input_paths.append(args.manifest_path)
  if sources:
    input_paths.extend(sources)
  classpath = []
  for gyp_list in args.classpath:
    classpath.extend(build_utils.ParseGnList(gyp_list))
  input_paths.extend(classpath)

  resource_sources = []
  if args.resource_dir:
    # Backward compatibility with GYP
    resource_sources += [ args.resource_dir ]

  for gyp_list in args.resource_sources:
    resource_sources += build_utils.ParseGnList(gyp_list)

  for resource_source in resource_sources:
    if os.path.isdir(resource_source):
      input_paths.extend(build_utils.FindInDirectory(resource_source, '*'))
    else:
      input_paths.append(resource_source)

  input_strings = [
    args.can_fail_build,
    args.include_unexpected_failures,
    args.silent,
  ]
  if args.android_sdk_version:
    input_strings.append(args.android_sdk_version)
  if args.processed_config_path:
    input_strings.append(args.processed_config_path)

  disable = []
  if args.disable:
    disable = build_utils.ParseGnList(args.disable)
    input_strings.extend(disable)

  output_paths = [args.result_path, args.processed_config_path]

  md5_check.CallAndWriteDepfileIfStale(
      lambda: _OnStaleMd5(args.lint_path,
                          args.config_path,
                          args.processed_config_path,
                          args.manifest_path, args.result_path,
                          args.product_dir, sources,
                          args.jar_path,
                          args.cache_dir,
                          args.android_sdk_version,
                          args.srcjars,
                          args.min_sdk_version,
                          args.manifest_package,
                          resource_sources,
                          disable=disable,
                          classpath=classpath,
                          can_fail_build=args.can_fail_build,
                          include_unexpected=args.include_unexpected_failures,
                          silent=args.silent),
      args,
      input_paths=input_paths,
      input_strings=input_strings,
      output_paths=output_paths,
      depfile_deps=classpath)
Exemplo n.º 12
0
def main(args):
    build_utils.InitLogging('DEX_DEBUG')
    options = _ParseArgs(args)

    options.class_inputs += options.class_inputs_filearg
    options.dex_inputs += options.dex_inputs_filearg

    input_paths = options.class_inputs + options.dex_inputs
    if options.multi_dex and options.main_dex_list_path:
        input_paths.append(options.main_dex_list_path)
    input_paths.append(options.r8_jar_path)
    input_paths.append(options.custom_d8_jar_path)

    depfile_deps = options.class_inputs_filearg + options.dex_inputs_filearg

    output_paths = [options.output]

    if options.incremental_dir:
        final_dex_inputs = _IntermediateDexFilePathsFromInputJars(
            options.class_inputs, options.incremental_dir)
        output_paths += final_dex_inputs
        track_subpaths_allowlist = options.class_inputs
    else:
        final_dex_inputs = list(options.class_inputs)
        track_subpaths_allowlist = None
    final_dex_inputs += options.dex_inputs

    dex_cmd = build_utils.JavaCmd(options.warnings_as_errors) + [
        '-cp',
        '{}:{}'.format(options.r8_jar_path, options.custom_d8_jar_path),
        'org.chromium.build.CustomD8',
    ]
    if options.release:
        dex_cmd += ['--release']
    if options.min_api:
        dex_cmd += ['--min-api', options.min_api]

    if not options.desugar:
        dex_cmd += ['--no-desugaring']
    elif options.classpath:
        # The classpath is used by D8 to for interface desugaring.
        classpath_paths = options.classpath
        if options.desugar_dependencies:
            dex_cmd += ['--desugar-dependencies', options.desugar_dependencies]
            if os.path.exists(options.desugar_dependencies):
                with open(options.desugar_dependencies, 'r') as f:
                    lines = [line.strip() for line in f.readlines()]
                    # Use a set to deduplicate entries.
                    desugar_dependencies = set(dep for dep in lines if dep)
                # Desugar dependencies are a subset of classpath.
                classpath_paths = list(desugar_dependencies)
        depfile_deps += classpath_paths
        input_paths += classpath_paths
        dex_cmd += ['--lib', build_utils.JAVA_HOME]
        for path in options.bootclasspath:
            dex_cmd += ['--lib', path]
        # Still pass the entire classpath in case a new dependency is needed by
        # desugar, so that desugar_dependencies will be updated for the next build.
        for path in options.classpath:
            dex_cmd += ['--classpath', path]
        depfile_deps += options.bootclasspath
        input_paths += options.bootclasspath

    if options.desugar_jdk_libs_json:
        dex_cmd += ['--desugared-lib', options.desugar_jdk_libs_json]
    if options.force_enable_assertions:
        dex_cmd += ['--force-enable-assertions']

    md5_check.CallAndWriteDepfileIfStale(
        lambda changes: _OnStaleMd5(changes, options, final_dex_inputs, dex_cmd
                                    ),
        options,
        input_paths=input_paths,
        input_strings=dex_cmd + [bool(options.incremental_dir)],
        output_paths=output_paths,
        pass_changes=True,
        track_subpaths_allowlist=track_subpaths_allowlist,
        depfile_deps=depfile_deps)
Exemplo n.º 13
0
def main(argv):
    build_utils.InitLogging('TURBINE_DEBUG')
    argv = build_utils.ExpandFileArgs(argv[1:])
    parser = argparse.ArgumentParser()
    build_utils.AddDepfileOption(parser)
    parser.add_argument('--turbine-jar-path',
                        required=True,
                        help='Path to the turbine jar file.')
    parser.add_argument('--java-srcjars',
                        action='append',
                        default=[],
                        help='List of srcjars to include in compilation.')
    parser.add_argument(
        '--bootclasspath',
        action='append',
        default=[],
        help='Boot classpath for javac. If this is specified multiple times, '
        'they will all be appended to construct the classpath.')
    parser.add_argument(
        '--java-version',
        help=
        'Java language version to use in -source and -target args to javac.')
    parser.add_argument('--classpath',
                        action='append',
                        help='Classpath to use.')
    parser.add_argument('--processors',
                        action='append',
                        help='GN list of annotation processor main classes.')
    parser.add_argument(
        '--processorpath',
        action='append',
        help='GN list of jars that comprise the classpath used for Annotation '
        'Processors.')
    parser.add_argument(
        '--processor-args',
        action='append',
        help='key=value arguments for the annotation processors.')
    parser.add_argument('--jar-path', help='Jar output path.', required=True)
    parser.add_argument('--generated-jar-path',
                        required=True,
                        help='Output path for generated source files.')
    options, unknown_args = parser.parse_known_args(argv)

    options.bootclasspath = build_utils.ParseGnList(options.bootclasspath)
    options.classpath = build_utils.ParseGnList(options.classpath)
    options.processorpath = build_utils.ParseGnList(options.processorpath)
    options.processors = build_utils.ParseGnList(options.processors)
    options.java_srcjars = build_utils.ParseGnList(options.java_srcjars)

    files = []
    for arg in unknown_args:
        # Interpret a path prefixed with @ as a file containing a list of sources.
        if arg.startswith('@'):
            files.extend(build_utils.ReadSourcesList(arg[1:]))

    cmd = [
        build_utils.JAVA_PATH, '-classpath', options.turbine_jar_path,
        'com.google.turbine.main.Main'
    ]
    javac_cmd = []

    # Turbine reads lists from command line args by consuming args until one
    # starts with double dash (--). Thus command line args should be grouped
    # together and passed in together.
    if options.processors:
        cmd += ['--processors']
        cmd += options.processors

    if options.java_version:
        javac_cmd.extend([
            '-source',
            options.java_version,
            '-target',
            options.java_version,
        ])
    if options.java_version == '1.8':
        # Android's boot jar doesn't contain all java 8 classes.
        options.bootclasspath.append(build_utils.RT_JAR_PATH)

    if options.bootclasspath:
        cmd += ['--bootclasspath']
        for bootclasspath in options.bootclasspath:
            cmd += bootclasspath.split(':')

    if options.processorpath:
        cmd += ['--processorpath']
        cmd += options.processorpath

    if options.processor_args:
        for arg in options.processor_args:
            javac_cmd.extend(['-A%s' % arg])

    classpath_inputs = (options.bootclasspath + options.classpath +
                        options.processorpath)

    # GN already knows of the java files, so avoid listing individual java files
    # in the depfile.
    depfile_deps = classpath_inputs + options.java_srcjars
    input_paths = depfile_deps + files

    output_paths = [
        options.jar_path,
        options.generated_jar_path,
    ]

    input_strings = cmd + options.classpath + files

    md5_check.CallAndWriteDepfileIfStale(
        lambda: _OnStaleMd5(options, cmd, javac_cmd, files, options.classpath),
        options,
        depfile_deps=depfile_deps,
        input_paths=input_paths,
        input_strings=input_strings,
        output_paths=output_paths)