android: build: Use .pydeps file to store Python dependencies.

NOTE: This is a reland of the following CL which was reverted:

  https://chromium-review.googlesource.com/c/chromium/src/+/1131190

The revert was due to a problem with an internal clank/DEPS runhooks
step that calls jinja_template.py (see BUG entry below for details).
The new CL was checking inputs by defaults, which would raise an
error during gclient sync.

To ease review, the first CL on gerrit is the original one,
unmodified, and the second fixes the issue.

---- end of NOTE ------

ProTip: start by looking at the action_with_pydefps() definition
in internal_rules.gni to review changes in this CL.

This CL tries to make "gn analyze" smarter by ensuring that
it knows about Python module dependencies, for any python
script under //build.

At the moment, these dependencies are computed by
build_utils.WriteDepFile() automatically (unless the
add_pydeps=False argument is passed). This adds all imported
module paths to the generated .d file written by the script.

Unfortunately, because this .d file is generated by the
actions, the corresponding Python sources are not part of
the target's inputs, known by GN at parse time, and thus do
not appear in "gn analyze" properly.

This CL tries to solve the problem by adding a new template
named "action_with_pydeps", which acts as "action", but also
expects a foo.pydeps file for every foo.py invoked through
the 'script' scope variable.

This '.pydeps' file is read directly at GN parse time and
added to the action's target inputs.

These .pydeps contain the path of each imported module, one
per line, and are generated with build/print_python_deps.py

Benchmarking shows no significant difference in the time
taken to perform a "gn gen out/Release" on a full Chrome
for Android checkout.

This also needs a PRESUBMIT.py step that ensures that all .pydeps
files are up-to-date with regards to their corresponding .py source
files (this can be done with 'gen_pydeps.py --check .../foo.py')

+ Remove some --depfile options on a few Python scripts that
  don't need it anymore (e.g. when their inputs and outputs
  are now fully known by GN at parse time).

+ Remove uses of compute_inputs_for_analyze in rules.gni and
  internal_rules.gni (as well as exec_script() calls to
  print_python_deps.py). Note that the variable itself is still
  needed for grit inputs, see tools/grit/grit_rule.gni for
  details).

BUG=870845,843562
R=agrieve@chromium.org, estevenson@chromium.org

Change-Id: Id1f606a0c9df9e4e8971fd885ac0394103ca7b03
Reviewed-on: https://chromium-review.googlesource.com/1163512
Reviewed-by: agrieve <agrieve@chromium.org>
Reviewed-by: Eric Stevenson <estevenson@chromium.org>
Commit-Queue: David Turner <digit@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#581158}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 0006f4737647ad0790431737586fd700085f8b0e
This commit is contained in:
David 'Digit' Turner 2018-08-07 07:12:36 +00:00 коммит произвёл Commit Bot
Родитель 60ce94a24b
Коммит f24ca38e53
53 изменённых файлов: 615 добавлений и 240 удалений

7
android/gyp/aar.pydeps Normal file
Просмотреть файл

@ -0,0 +1,7 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/aar.pydeps build/android/gyp/aar.py
../../gn_helpers.py
aar.py
util/__init__.py
util/build_utils.py
util/md5_check.py

Просмотреть файл

@ -18,7 +18,6 @@ from util import build_utils
def main(argv):
option_parser = optparse.OptionParser()
build_utils.AddDepfileOption(option_parser)
option_parser.add_option('--aidl-path', help='Path to the aidl binary.')
option_parser.add_option('--imports', help='Files to import.')
option_parser.add_option('--includes',
@ -54,9 +53,6 @@ def main(argv):
pkg_name.replace('.', '/'), os.path.basename(path))
build_utils.AddToZipHermetic(srcjar, arcname, data=data)
if options.depfile:
build_utils.WriteDepfile(options.depfile, options.srcjar)
if __name__ == '__main__':
sys.exit(main(sys.argv))

7
android/gyp/aidl.pydeps Normal file
Просмотреть файл

@ -0,0 +1,7 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/aidl.pydeps build/android/gyp/aidl.py
../../gn_helpers.py
aidl.py
util/__init__.py
util/build_utils.py
util/md5_check.py

Просмотреть файл

@ -0,0 +1,8 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/apkbuilder.pydeps build/android/gyp/apkbuilder.py
../../gn_helpers.py
apkbuilder.py
finalize_apk.py
util/__init__.py
util/build_utils.py
util/md5_check.py

Просмотреть файл

@ -0,0 +1,8 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/app_bundle_to_apks.pydeps build/android/gyp/app_bundle_to_apks.py
../../gn_helpers.py
app_bundle_to_apks.py
bundletool.py
util/__init__.py
util/build_utils.py
util/md5_check.py

Просмотреть файл

@ -0,0 +1,7 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/bytecode_processor.pydeps build/android/gyp/bytecode_processor.py
../../gn_helpers.py
bytecode_processor.py
util/__init__.py
util/build_utils.py
util/md5_check.py

Просмотреть файл

@ -671,7 +671,8 @@ def main(args):
input_paths=input_paths,
input_strings=input_strings,
output_paths=output_paths,
depfile_deps=options.dependencies_res_zips + options.extra_r_text_files)
depfile_deps=options.dependencies_res_zips + options.extra_r_text_files,
add_pydeps=False)
if __name__ == '__main__':

Просмотреть файл

@ -0,0 +1,29 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/compile_resources.pydeps build/android/gyp/compile_resources.py
../../../third_party/jinja2/__init__.py
../../../third_party/jinja2/_compat.py
../../../third_party/jinja2/bccache.py
../../../third_party/jinja2/compiler.py
../../../third_party/jinja2/defaults.py
../../../third_party/jinja2/environment.py
../../../third_party/jinja2/exceptions.py
../../../third_party/jinja2/filters.py
../../../third_party/jinja2/idtracking.py
../../../third_party/jinja2/lexer.py
../../../third_party/jinja2/loaders.py
../../../third_party/jinja2/nodes.py
../../../third_party/jinja2/optimizer.py
../../../third_party/jinja2/parser.py
../../../third_party/jinja2/runtime.py
../../../third_party/jinja2/tests.py
../../../third_party/jinja2/utils.py
../../../third_party/jinja2/visitor.py
../../../third_party/markupsafe/__init__.py
../../../third_party/markupsafe/_compat.py
../../../third_party/markupsafe/_native.py
../../gn_helpers.py
compile_resources.py
util/__init__.py
util/build_utils.py
util/md5_check.py
util/resource_utils.py

Просмотреть файл

@ -0,0 +1,7 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/copy_ex.pydeps build/android/gyp/copy_ex.py
../../gn_helpers.py
copy_ex.py
util/__init__.py
util/build_utils.py
util/md5_check.py

Просмотреть файл

@ -0,0 +1,3 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/create_apk_operations_script.pydeps build/android/gyp/create_apk_operations_script.py
create_apk_operations_script.py

Просмотреть файл

@ -0,0 +1,30 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/create_app_bundle.pydeps build/android/gyp/create_app_bundle.py
../../../third_party/jinja2/__init__.py
../../../third_party/jinja2/_compat.py
../../../third_party/jinja2/bccache.py
../../../third_party/jinja2/compiler.py
../../../third_party/jinja2/defaults.py
../../../third_party/jinja2/environment.py
../../../third_party/jinja2/exceptions.py
../../../third_party/jinja2/filters.py
../../../third_party/jinja2/idtracking.py
../../../third_party/jinja2/lexer.py
../../../third_party/jinja2/loaders.py
../../../third_party/jinja2/nodes.py
../../../third_party/jinja2/optimizer.py
../../../third_party/jinja2/parser.py
../../../third_party/jinja2/runtime.py
../../../third_party/jinja2/tests.py
../../../third_party/jinja2/utils.py
../../../third_party/jinja2/visitor.py
../../../third_party/markupsafe/__init__.py
../../../third_party/markupsafe/_compat.py
../../../third_party/markupsafe/_native.py
../../gn_helpers.py
bundletool.py
create_app_bundle.py
util/__init__.py
util/build_utils.py
util/md5_check.py
util/resource_utils.py

Просмотреть файл

@ -0,0 +1,7 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/create_bundle_wrapper_script.pydeps build/android/gyp/create_bundle_wrapper_script.py
../../gn_helpers.py
create_bundle_wrapper_script.py
util/__init__.py
util/build_utils.py
util/md5_check.py

Просмотреть файл

@ -24,7 +24,8 @@ def main(args):
build_utils.MergeZips(options.output, input_jars)
if options.depfile:
build_utils.WriteDepfile(options.depfile, options.output, input_jars)
build_utils.WriteDepfile(options.depfile, options.output, input_jars,
add_pydeps=False)
if __name__ == '__main__':

Просмотреть файл

@ -0,0 +1,7 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/create_dist_jar.pydeps build/android/gyp/create_dist_jar.py
../../gn_helpers.py
create_dist_jar.py
util/__init__.py
util/build_utils.py
util/md5_check.py

Просмотреть файл

@ -0,0 +1,7 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/create_java_binary_script.pydeps build/android/gyp/create_java_binary_script.py
../../gn_helpers.py
create_java_binary_script.py
util/__init__.py
util/build_utils.py
util/md5_check.py

Просмотреть файл

@ -0,0 +1,7 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/create_stack_script.pydeps build/android/gyp/create_stack_script.py
../../gn_helpers.py
create_stack_script.py
util/__init__.py
util/build_utils.py
util/md5_check.py

Просмотреть файл

@ -0,0 +1,7 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/create_test_runner_script.pydeps build/android/gyp/create_test_runner_script.py
../../gn_helpers.py
create_test_runner_script.py
util/__init__.py
util/build_utils.py
util/md5_check.py

Просмотреть файл

@ -0,0 +1,3 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/create_tool_wrapper.pydeps build/android/gyp/create_tool_wrapper.py
create_tool_wrapper.py

Просмотреть файл

@ -0,0 +1,7 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/desugar.pydeps build/android/gyp/desugar.py
../../gn_helpers.py
desugar.py
util/__init__.py
util/build_utils.py
util/md5_check.py

7
android/gyp/dex.pydeps Normal file
Просмотреть файл

@ -0,0 +1,7 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/dex.pydeps build/android/gyp/dex.py
../../gn_helpers.py
dex.py
util/__init__.py
util/build_utils.py
util/md5_check.py

Просмотреть файл

@ -124,7 +124,8 @@ def main(args):
if options.depfile:
all_inputs = (options.jars + options.dependencies_res_zips +
options.r_text_files + options.proguard_configs)
build_utils.WriteDepfile(options.depfile, options.output, all_inputs)
build_utils.WriteDepfile(options.depfile, options.output, all_inputs,
add_pydeps=False)
if __name__ == '__main__':

Просмотреть файл

@ -0,0 +1,7 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/dist_aar.pydeps build/android/gyp/dist_aar.py
../../gn_helpers.py
dist_aar.py
util/__init__.py
util/build_utils.py
util/md5_check.py

Просмотреть файл

@ -0,0 +1,7 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/emma_instr.pydeps build/android/gyp/emma_instr.py
../../gn_helpers.py
emma_instr.py
util/__init__.py
util/build_utils.py
util/md5_check.py

Просмотреть файл

@ -0,0 +1,7 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/filter_zip.pydeps build/android/gyp/filter_zip.py
../../gn_helpers.py
filter_zip.py
util/__init__.py
util/build_utils.py
util/md5_check.py

Просмотреть файл

@ -47,7 +47,7 @@ def main(args):
DoGcc(options)
if options.depfile:
build_utils.WriteDepfile(options.depfile, options.output)
build_utils.WriteDepfile(options.depfile, options.output, add_pydeps=False)
if __name__ == '__main__':

Просмотреть файл

@ -0,0 +1,7 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/gcc_preprocess.pydeps build/android/gyp/gcc_preprocess.py
../../gn_helpers.py
gcc_preprocess.py
util/__init__.py
util/build_utils.py
util/md5_check.py

Просмотреть файл

@ -0,0 +1,7 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/generate_proguarded_module_jar.pydeps build/android/gyp/generate_proguarded_module_jar.py
../../gn_helpers.py
generate_proguarded_module_jar.py
util/__init__.py
util/build_utils.py
util/md5_check.py

7
android/gyp/ijar.pydeps Normal file
Просмотреть файл

@ -0,0 +1,7 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/ijar.pydeps build/android/gyp/ijar.py
../../gn_helpers.py
ijar.py
util/__init__.py
util/build_utils.py
util/md5_check.py

Просмотреть файл

@ -447,7 +447,7 @@ def DoMain(argv):
build_utils.AddToZipHermetic(srcjar, output_path, data=data)
if options.depfile:
build_utils.WriteDepfile(options.depfile, options.srcjar)
build_utils.WriteDepfile(options.depfile, options.srcjar, add_pydeps=False)
if __name__ == '__main__':

Просмотреть файл

@ -0,0 +1,7 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/java_cpp_enum.pydeps build/android/gyp/java_cpp_enum.py
../../gn_helpers.py
java_cpp_enum.py
util/__init__.py
util/build_utils.py
util/md5_check.py

Просмотреть файл

@ -597,7 +597,8 @@ def main(argv):
input_strings=javac_cmd + classpath,
output_paths=output_paths,
force=force,
pass_changes=True)
pass_changes=True,
add_pydeps=False)
if __name__ == '__main__':

15
android/gyp/javac.pydeps Normal file
Просмотреть файл

@ -0,0 +1,15 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/javac.pydeps build/android/gyp/javac.py
../../../third_party/colorama/src/colorama/__init__.py
../../../third_party/colorama/src/colorama/ansi.py
../../../third_party/colorama/src/colorama/ansitowin32.py
../../../third_party/colorama/src/colorama/initialise.py
../../../third_party/colorama/src/colorama/win32.py
../../../third_party/colorama/src/colorama/winterm.py
../../gn_helpers.py
jar.py
javac.py
util/__init__.py
util/build_utils.py
util/jar_info_utils.py
util/md5_check.py

Просмотреть файл

@ -124,7 +124,8 @@ def main():
parser.add_argument('--variables', help='Variables to be made available in '
'the template processing environment, as a GYP list '
'(e.g. --variables "channel=beta mstone=39")', default='')
build_utils.AddDepfileOption(parser)
parser.add_argument('--check-includes', action='store_true',
help='Enable inputs and includes checks.')
options = parser.parse_args()
inputs = build_utils.ParseGnList(options.inputs)
@ -146,15 +147,13 @@ def main():
_ProcessFiles(processor, inputs, options.inputs_base_dir,
options.outputs_zip)
if options.depfile:
output = options.output or options.outputs_zip
if options.check_includes:
all_inputs = set(processor.GetLoadedTemplates())
all_inputs.difference_update(inputs)
all_inputs.difference_update(includes)
if all_inputs:
raise Exception('Found files not listed via --includes:\n' +
'\n'.join(sorted(all_inputs)))
build_utils.WriteDepfile(options.depfile, output)
if __name__ == '__main__':

Просмотреть файл

@ -0,0 +1,41 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/jinja_template.pydeps build/android/gyp/jinja_template.py
../../../third_party/catapult/devil/devil/__init__.py
../../../third_party/catapult/devil/devil/android/__init__.py
../../../third_party/catapult/devil/devil/android/constants/__init__.py
../../../third_party/catapult/devil/devil/android/constants/chrome.py
../../../third_party/catapult/devil/devil/android/sdk/__init__.py
../../../third_party/catapult/devil/devil/android/sdk/keyevent.py
../../../third_party/catapult/devil/devil/android/sdk/version_codes.py
../../../third_party/catapult/devil/devil/constants/__init__.py
../../../third_party/catapult/devil/devil/constants/exit_codes.py
../../../third_party/jinja2/__init__.py
../../../third_party/jinja2/_compat.py
../../../third_party/jinja2/bccache.py
../../../third_party/jinja2/compiler.py
../../../third_party/jinja2/defaults.py
../../../third_party/jinja2/environment.py
../../../third_party/jinja2/exceptions.py
../../../third_party/jinja2/filters.py
../../../third_party/jinja2/idtracking.py
../../../third_party/jinja2/lexer.py
../../../third_party/jinja2/loaders.py
../../../third_party/jinja2/nodes.py
../../../third_party/jinja2/optimizer.py
../../../third_party/jinja2/parser.py
../../../third_party/jinja2/runtime.py
../../../third_party/jinja2/tests.py
../../../third_party/jinja2/utils.py
../../../third_party/jinja2/visitor.py
../../../third_party/markupsafe/__init__.py
../../../third_party/markupsafe/_compat.py
../../../third_party/markupsafe/_native.py
../../gn_helpers.py
../pylib/__init__.py
../pylib/constants/__init__.py
../pylib/constants/host_paths.py
jinja_template.py
util/__init__.py
util/build_utils.py
util/md5_check.py
util/resource_utils.py

7
android/gyp/lint.pydeps Normal file
Просмотреть файл

@ -0,0 +1,7 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/lint.pydeps build/android/gyp/lint.py
../../gn_helpers.py
lint.py
util/__init__.py
util/build_utils.py
util/md5_check.py

Просмотреть файл

@ -0,0 +1,8 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/main_dex_list.pydeps build/android/gyp/main_dex_list.py
../../gn_helpers.py
main_dex_list.py
util/__init__.py
util/build_utils.py
util/md5_check.py
util/proguard_util.py

Просмотреть файл

@ -0,0 +1,8 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/merge_jar_info_files.pydeps build/android/gyp/merge_jar_info_files.py
../../gn_helpers.py
merge_jar_info_files.py
util/__init__.py
util/build_utils.py
util/jar_info_utils.py
util/md5_check.py

Просмотреть файл

@ -0,0 +1,7 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/merge_manifest.pydeps build/android/gyp/merge_manifest.py
../../gn_helpers.py
merge_manifest.py
util/__init__.py
util/build_utils.py
util/md5_check.py

Просмотреть файл

@ -297,7 +297,8 @@ def main(args):
input_paths=input_paths,
input_strings=input_strings,
output_paths=output_paths,
depfile_deps=depfile_deps)
depfile_deps=depfile_deps,
add_pydeps=False)
if __name__ == '__main__':

Просмотреть файл

@ -0,0 +1,30 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/prepare_resources.pydeps build/android/gyp/prepare_resources.py
../../../third_party/jinja2/__init__.py
../../../third_party/jinja2/_compat.py
../../../third_party/jinja2/bccache.py
../../../third_party/jinja2/compiler.py
../../../third_party/jinja2/defaults.py
../../../third_party/jinja2/environment.py
../../../third_party/jinja2/exceptions.py
../../../third_party/jinja2/filters.py
../../../third_party/jinja2/idtracking.py
../../../third_party/jinja2/lexer.py
../../../third_party/jinja2/loaders.py
../../../third_party/jinja2/nodes.py
../../../third_party/jinja2/optimizer.py
../../../third_party/jinja2/parser.py
../../../third_party/jinja2/runtime.py
../../../third_party/jinja2/tests.py
../../../third_party/jinja2/utils.py
../../../third_party/jinja2/visitor.py
../../../third_party/markupsafe/__init__.py
../../../third_party/markupsafe/_compat.py
../../../third_party/markupsafe/_native.py
../../gn_helpers.py
generate_v14_compatible_resources.py
prepare_resources.py
util/__init__.py
util/build_utils.py
util/md5_check.py
util/resource_utils.py

Просмотреть файл

@ -0,0 +1,8 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/proguard.pydeps build/android/gyp/proguard.py
../../gn_helpers.py
proguard.py
util/__init__.py
util/build_utils.py
util/md5_check.py
util/proguard_util.py

Просмотреть файл

@ -0,0 +1,7 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/write_build_config.pydeps build/android/gyp/write_build_config.py
../../gn_helpers.py
util/__init__.py
util/build_utils.py
util/md5_check.py
write_build_config.py

Просмотреть файл

@ -109,7 +109,8 @@ def main():
only_if_changed=True)
if options.depfile:
build_utils.WriteDepfile(options.depfile, options.output, libraries)
build_utils.WriteDepfile(options.depfile, options.output, libraries,
add_pydeps=False)
if __name__ == '__main__':

Просмотреть файл

@ -0,0 +1,7 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/write_ordered_libraries.pydeps build/android/gyp/write_ordered_libraries.py
../../gn_helpers.py
util/__init__.py
util/build_utils.py
util/md5_check.py
write_ordered_libraries.py

Просмотреть файл

@ -0,0 +1,7 @@
# Generated by running:
# build/print_python_deps.py --root build/android/incremental_install --output build/android/incremental_install/generate_android_manifest.pydeps build/android/incremental_install/generate_android_manifest.py
../../gn_helpers.py
../gyp/util/__init__.py
../gyp/util/build_utils.py
../gyp/util/md5_check.py
generate_android_manifest.py

Просмотреть файл

@ -19,7 +19,6 @@ from util import build_utils
def _ParseArgs(args):
args = build_utils.ExpandFileArgs(args)
parser = argparse.ArgumentParser()
build_utils.AddDepfileOption(parser)
parser.add_argument('--output-path',
help='Output path for .json file.',
required=True)
@ -76,9 +75,6 @@ def main(args):
with build_utils.AtomicOutput(options.output_path) as f:
json.dump(data, f, indent=2, sort_keys=True)
if options.depfile:
build_utils.WriteDepfile(options.depfile, options.output_path)
if __name__ == '__main__':
main(sys.argv[1:])

Просмотреть файл

@ -0,0 +1,7 @@
# Generated by running:
# build/print_python_deps.py --root build/android/incremental_install --output build/android/incremental_install/write_installer_json.pydeps build/android/incremental_install/write_installer_json.py
../../gn_helpers.py
../gyp/util/__init__.py
../gyp/util/build_utils.py
../gyp/util/md5_check.py
write_installer_json.py

Просмотреть файл

@ -6,8 +6,8 @@
# Some projects (e.g. V8) do not have non-build directories DEPS'ed in.
import("//build_overrides/build.gni")
import("//build/config/android/config.gni")
import("//build/config/compute_inputs_for_analyze.gni")
import("//build/config/dcheck_always_on.gni")
import("//build/config/python.gni")
import("//build/config/sanitizers/sanitizers.gni")
assert(is_android)
@ -45,14 +45,6 @@ _java_target_blacklist = [
_default_proguard_jar_path = "//third_party/proguard/lib/proguard.jar"
# List of .py files required when scripts import build_utils.py.
# Use this for "inputs" for actions that rely on build_utils.py.
build_utils_py = [
"//build/android/gyp/util/build_utils.py",
"//build/android/gyp/util/md5_check.py",
"//build/gn_helpers.py",
]
# Write the target's .build_config file. This is a json file that contains a
# dictionary of information about how to build this target (things that
# require knowledge about this target's dependencies and cannot be calculated
@ -91,7 +83,7 @@ template("write_build_config") {
sources = []
}
action(target_name) {
action_with_pydeps(target_name) {
forward_variables_from(invoker,
[
"deps",
@ -106,7 +98,7 @@ template("write_build_config") {
script = "//build/android/gyp/write_build_config.py"
depfile = "$target_gen_dir/$target_name.d"
inputs = build_utils_py
inputs = []
outputs = [
invoker.build_config,
]
@ -438,7 +430,7 @@ template("write_build_config") {
#
template("copy_ex") {
set_sources_assignment_filter([])
action(target_name) {
action_with_pydeps(target_name) {
forward_variables_from(invoker,
[
"data",
@ -451,9 +443,8 @@ template("copy_ex") {
if (defined(invoker.sources)) {
sources += invoker.sources
}
inputs = build_utils_py
if (defined(invoker.inputs)) {
inputs += invoker.inputs
inputs = invoker.inputs
}
script = "//build/android/gyp/copy_ex.py"
@ -519,7 +510,7 @@ template("test_runner_script") {
}
}
action(target_name) {
action_with_pydeps(target_name) {
forward_variables_from(invoker,
[
"data_deps",
@ -533,7 +524,6 @@ template("test_runner_script") {
}
script = "//build/android/gyp/create_test_runner_script.py"
inputs = build_utils_py
data_deps += [
"//build/android:test_runner_py",
@ -725,15 +715,12 @@ template("test_runner_script") {
}
template("stack_script") {
forward_variables_from(invoker, [ "testonly" ])
_stack_target_name = invoker.stack_target_name
action(target_name) {
action_with_pydeps(target_name) {
forward_variables_from(invoker,
[
"data_deps",
"deps",
"testonly",
])
if (!defined(deps)) {
deps = []
@ -746,8 +733,8 @@ template("stack_script") {
[ "//third_party/android_platform/development/scripts:stack_py" ]
script = "//build/android/gyp/create_stack_script.py"
inputs = build_utils_py
_stack_target_name = invoker.stack_target_name
_stack_script = "//third_party/android_platform/development/scripts/stack"
_generated_script = "$root_build_dir/bin/stack_${_stack_target_name}"
@ -783,7 +770,7 @@ if (enable_java_templates) {
android_default_aapt2_path = "$android_sdk_build_tools/aapt2"
template("android_lint") {
action(target_name) {
action_with_pydeps(target_name) {
forward_variables_from(invoker,
[
"deps",
@ -811,10 +798,10 @@ if (enable_java_templates) {
script = "//build/android/gyp/lint.py"
depfile = "$target_gen_dir/$target_name.d"
inputs = build_utils_py + [
_platform_xml_path,
_suppressions_file,
]
inputs = [
_platform_xml_path,
_suppressions_file,
]
outputs = [
_result_path,
@ -891,7 +878,7 @@ if (enable_java_templates) {
}
template("proguard") {
action(target_name) {
action_with_pydeps(target_name) {
set_sources_assignment_filter([])
forward_variables_from(invoker,
[
@ -912,11 +899,10 @@ if (enable_java_templates) {
_proguard_jar_path = invoker.proguard_jar_path
}
inputs = build_utils_py + [
"//build/android/gyp/util/proguard_util.py",
_proguard_jar_path,
invoker.build_config,
]
inputs = [
_proguard_jar_path,
invoker.build_config,
]
if (defined(invoker.inputs)) {
inputs += invoker.inputs
}
@ -966,7 +952,7 @@ if (enable_java_templates) {
# class path when the script will invoke javac.
#
template("java_binary_script") {
action(target_name) {
action_with_pydeps(target_name) {
forward_variables_from(invoker,
[
"deps",
@ -978,7 +964,9 @@ if (enable_java_templates) {
_script_name = invoker.script_name
script = "//build/android/gyp/create_java_binary_script.py"
inputs = build_utils_py + [ _build_config ]
inputs = [
_build_config,
]
_java_script = "$root_build_dir/bin/$_script_name"
outputs = [
_java_script,
@ -1023,7 +1011,7 @@ if (enable_java_templates) {
if (_enable_multidex) {
_main_dex_list_path = invoker.output + ".main_dex_list"
_main_dex_list_target_name = "${target_name}__main_dex_list"
action(_main_dex_list_target_name) {
action_with_pydeps(_main_dex_list_target_name) {
forward_variables_from(invoker,
[
"deps",
@ -1046,13 +1034,12 @@ if (enable_java_templates) {
_shrinked_android = "$android_sdk_build_tools/lib/shrinkedAndroid.jar"
_dx = "$android_sdk_build_tools/lib/dx.jar"
inputs = build_utils_py + [
"//build/android/gyp/util/proguard_util.py",
main_dex_rules,
_dx,
_proguard_jar_path,
_shrinked_android,
]
inputs = [
main_dex_rules,
_dx,
_proguard_jar_path,
_shrinked_android,
]
outputs = [
_main_dex_list_path,
@ -1099,7 +1086,7 @@ if (enable_java_templates) {
}
assert(defined(invoker.output))
action(target_name) {
action_with_pydeps(target_name) {
forward_variables_from(invoker,
[
"deps",
@ -1107,7 +1094,7 @@ if (enable_java_templates) {
])
script = "//build/android/gyp/dex.py"
depfile = "$target_gen_dir/$target_name.d"
inputs = build_utils_py
inputs = []
outputs = [
invoker.output,
]
@ -1155,7 +1142,7 @@ if (enable_java_templates) {
}
template("emma_instr") {
action(target_name) {
action_with_pydeps(target_name) {
forward_variables_from(invoker,
[
"deps",
@ -1168,7 +1155,7 @@ if (enable_java_templates) {
_emma_jar = "${android_sdk_root}/tools/lib/emma.jar"
script = "//build/android/gyp/emma_instr.py"
inputs = build_utils_py + invoker.java_files + [
inputs = invoker.java_files + [
_emma_jar,
invoker.input_jar_path,
]
@ -1276,7 +1263,7 @@ if (enable_java_templates) {
_java_bytecode_rewriter_output_jar =
"$target_out_dir/$target_name-bytecode-rewritten.jar"
action(_java_bytecode_rewriter_target) {
action_with_pydeps(_java_bytecode_rewriter_target) {
script = "//build/android/gyp/bytecode_processor.py"
_bytecode_rewriter_script =
"$root_build_dir/bin/helper/java_bytecode_rewriter"
@ -1327,7 +1314,7 @@ if (enable_java_templates) {
_desugar_input_jar = _previous_output_jar
_desugar_output_jar = "$target_out_dir/$target_name-desugar.jar"
action(_desugar_target) {
action_with_pydeps(_desugar_target) {
script = "//build/android/gyp/desugar.py"
deps = _deps
if (defined(invoker.deps)) {
@ -1335,11 +1322,11 @@ if (enable_java_templates) {
}
_desugar_jar = "//third_party/bazel/desugar/Desugar.jar"
inputs = build_utils_py + [
_build_config,
_desugar_input_jar,
_desugar_jar,
]
inputs = [
_build_config,
_desugar_input_jar,
_desugar_jar,
]
outputs = [
_desugar_output_jar,
]
@ -1365,16 +1352,16 @@ if (enable_java_templates) {
_filter_input_jar = _previous_output_jar
_filter_output_jar = "$target_out_dir/$target_name-filtered.jar"
action(_filter_target) {
action_with_pydeps(_filter_target) {
script = "//build/android/gyp/filter_zip.py"
deps = _deps
if (defined(invoker.deps)) {
deps += invoker.deps
}
inputs = build_utils_py + [
_build_config,
_filter_input_jar,
]
inputs = [
_build_config,
_filter_input_jar,
]
outputs = [
_filter_output_jar,
]
@ -1456,7 +1443,7 @@ if (enable_java_templates) {
}
template("merge_manifests") {
action(target_name) {
action_with_pydeps(target_name) {
forward_variables_from(invoker,
[
"deps",
@ -1465,10 +1452,10 @@ if (enable_java_templates) {
script = "//build/android/gyp/merge_manifest.py"
depfile = "$target_gen_dir/$target_name.d"
inputs = build_utils_py + [
invoker.build_config,
invoker.input_manifest,
]
inputs = [
invoker.build_config,
invoker.input_manifest,
]
outputs = [
invoker.output_manifest,
@ -1490,19 +1477,6 @@ if (enable_java_templates) {
}
}
if (compute_inputs_for_analyze) {
_prepare_resources_py =
exec_script("//build/print_python_deps.py",
[
rebase_path("//build/android/gyp/prepare_resources.py"),
"--no-header",
"--gn-paths",
"--root",
rebase_path("//", root_build_dir),
],
"list lines")
}
# This template is used to parse a set of resource directories and
# create the R.txt, .srcjar and .resources.zip for it.
#
@ -1558,7 +1532,7 @@ if (enable_java_templates) {
if (defined(invoker.srcjar_path)) {
_srcjar_path = invoker.srcjar_path
}
action(target_name) {
action_with_pydeps(target_name) {
set_sources_assignment_filter([])
forward_variables_from(invoker,
[
@ -1599,9 +1573,6 @@ if (enable_java_templates) {
invoker.build_config,
_android_aapt_path,
]
if (compute_inputs_for_analyze) {
inputs += _prepare_resources_py
}
_rebased_all_resource_dirs =
rebase_path(_all_resource_dirs, root_build_dir)
@ -1686,19 +1657,6 @@ if (enable_java_templates) {
}
}
if (compute_inputs_for_analyze) {
_compile_resources_py =
exec_script("//build/print_python_deps.py",
[
rebase_path("//build/android/gyp/compile_resources.py"),
"--no-header",
"--gn-paths",
"--root",
rebase_path("//", root_build_dir),
],
"list lines")
}
# A template that is used to compile all resources needed by a binary
# (e.g. an android_apk or a junit_binary) into an intermediate .ar_
# archive. It can also generate an associated .srcjar that contains the
@ -1801,7 +1759,7 @@ if (enable_java_templates) {
# _2.d for the optional processed compiled resources.
# _3.d for the proto-compiled resources.
action(_compile_resources_target_name) {
action_with_pydeps(_compile_resources_target_name) {
set_sources_assignment_filter([])
forward_variables_from(invoker,
[
@ -1824,9 +1782,6 @@ if (enable_java_templates) {
invoker.build_config,
_android_aapt_path,
]
if (compute_inputs_for_analyze) {
inputs += _compile_resources_py
}
_rebased_build_config = rebase_path(invoker.build_config, root_build_dir)
@ -2048,17 +2003,16 @@ if (enable_java_templates) {
_output = invoker.output
_build_config = invoker.apk_build_config
_rebased_build_config = rebase_path(_build_config, root_build_dir)
action(target_name) {
action_with_pydeps(target_name) {
forward_variables_from(invoker,
[
"testonly",
"deps",
])
script = "//build/android/gyp/merge_jar_info_files.py"
inputs = build_utils_py + [
_build_config,
"//build/android/gyp/util/jar_info_utils.py",
]
inputs = [
_build_config,
]
outputs = [
_output,
]
@ -2104,7 +2058,7 @@ if (enable_java_templates) {
# uncompress_shared_libraries: (optional, default false) Whether to store
# native libraries inside the APK uncompressed and page-aligned.
template("package_apk") {
action(target_name) {
action_with_pydeps(target_name) {
forward_variables_from(invoker,
[
"deps",
@ -2129,8 +2083,7 @@ if (enable_java_templates) {
"//tools/android/md5sum",
] # Used when deploying APKs
inputs = build_utils_py + invoker.native_libs + [
"//build/android/gyp/finalize_apk.py",
inputs = invoker.native_libs + [
invoker.keystore_path,
invoker.packaged_resources_path,
_apksigner,
@ -2332,16 +2285,14 @@ if (enable_java_templates) {
_rebased_build_config =
rebase_path(invoker.assets_build_config, root_build_dir)
action(_incremental_compile_resources_target_name) {
action_with_pydeps(_incremental_compile_resources_target_name) {
deps = _incremental_deps
script =
"//build/android/incremental_install/generate_android_manifest.py"
inputs = build_utils_py + [
# Save on a depfile by listing only .py dep here.
"//build/android/gyp/util/build_utils.py",
_android_manifest,
invoker.packaged_resources_path,
]
inputs = [
_android_manifest,
invoker.packaged_resources_path,
]
outputs = [
# Output the non-compiled manifest for easy debugging (as opposed to
# generating to a temp file).
@ -2406,18 +2357,6 @@ if (enable_java_templates) {
}
}
if (compute_inputs_for_analyze) {
_javac_py = exec_script("//build/print_python_deps.py",
[
rebase_path("//build/android/gyp/javac.py"),
"--no-header",
"--gn-paths",
"--root",
rebase_path("//", root_build_dir),
],
"list lines")
}
# Compile Java source files into a .jar file, potentially using an
# annotation processor, and/or the errorprone compiler.
#
@ -2526,7 +2465,7 @@ if (enable_java_templates) {
_javac_args = invoker.javac_args
}
action(target_name) {
action_with_pydeps(target_name) {
script = "//build/android/gyp/javac.py"
depfile = "$target_gen_dir/$target_name.d"
deps = _srcjar_deps
@ -2543,9 +2482,6 @@ if (enable_java_templates) {
if (invoker.java_files != []) {
inputs += [ invoker.java_sources_file ]
}
if (compute_inputs_for_analyze) {
inputs += _javac_py
}
_rebased_build_config = rebase_path(_build_config, root_build_dir)
_rebased_javac_jar_path =
@ -2618,7 +2554,7 @@ if (enable_java_templates) {
# output_jar: Path to output .ijar.
#
template("generate_interface_jar") {
action(target_name) {
action_with_pydeps(target_name) {
_ijar_target = "//third_party/ijar:ijar($host_toolchain)"
_ijar_executable = get_label_info(_ijar_target, "root_out_dir") + "/ijar"
forward_variables_from(invoker,
@ -2636,10 +2572,10 @@ if (enable_java_templates) {
if (defined(invoker.deps)) {
deps += invoker.deps
}
inputs = build_utils_py + [
invoker.input_jar,
_ijar_executable,
]
inputs = [
invoker.input_jar,
_ijar_executable,
]
if (defined(invoker.inputs)) {
inputs += invoker.inputs
}
@ -3274,7 +3210,7 @@ template("create_android_app_bundle_module") {
_build_config = invoker.build_config
_rebased_build_config = rebase_path(_build_config, root_build_dir)
action(target_name) {
action_with_pydeps(target_name) {
forward_variables_from(invoker,
[
"testonly",
@ -3291,7 +3227,9 @@ template("create_android_app_bundle_module") {
# dependencies like extra native libraries are all pulled from the
# .build_config through @FileArg() references (see below) and
# will be listed in the generated depfile instead.
inputs = build_utils_py + [ _build_config ]
inputs = [
_build_config,
]
outputs = [
invoker.module_zip_path,
]
@ -3337,10 +3275,9 @@ template("create_android_app_bundle_module") {
template("generate_proguarded_module_jar") {
_rebased_build_config = rebase_path(invoker.build_config, root_build_dir)
action(target_name) {
action_with_pydeps(target_name) {
forward_variables_from(invoker, [ "deps" ])
script = "//build/android/gyp/generate_proguarded_module_jar.py"
inputs = build_utils_py
outputs = [
invoker.output_jar,
]

Просмотреть файл

@ -8,8 +8,8 @@ import("//build/config/android/config.gni")
import("//build/config/android/internal_rules.gni")
import("//build/config/clang/clang.gni")
import("//build/config/compiler/compiler.gni")
import("//build/config/compute_inputs_for_analyze.gni")
import("//build/config/dcheck_always_on.gni")
import("//build/config/python.gni")
import("//build/config/zip.gni")
import("//build/toolchain/toolchain.gni")
@ -76,7 +76,7 @@ template("create_native_executable_dist") {
_find_deps_target_name = "${target_name}__find_library_dependencies"
# TODO(agrieve): Extract dependent libs from GN rather than readelf.
action(_find_deps_target_name) {
action_with_pydeps(_find_deps_target_name) {
deps = invoker.deps + [ ":$_runtime_deps_target_name" ]
script = "//build/android/gyp/write_ordered_libraries.py"
depfile = "$target_gen_dir/$target_name.d"
@ -157,7 +157,7 @@ template("create_native_executable_dist") {
# target = "//pkg/foo.py"
# }
template("wrapper_script") {
action(target_name) {
action_with_pydeps(target_name) {
_name = get_path_info(invoker.target, "name")
_output = "$root_out_dir/bin/$_name"
@ -233,17 +233,14 @@ if (enable_java_templates) {
}
_foreach_target_name = "${target_name}__jni_gen"
action_foreach(_foreach_target_name) {
action_foreach_with_pydeps(_foreach_target_name) {
script = "//base/android/jni_generator/jni_generator.py"
depfile = "$target_gen_dir/$target_name.{{source_name_part}}.d"
sources = invoker.sources
outputs = [
"${_jni_output_dir}/{{source_name_part}}_jni.h",
]
args = [
"--depfile",
rebase_path(depfile, root_build_dir),
"--input_file={{source}}",
"--ptr_type=long",
"--output_dir",
@ -338,10 +335,9 @@ if (enable_java_templates) {
_classname = get_path_info(_class, "name")
_jni_target_name = "${target_name}__jni_${_classname}"
_jni_actions += [ ":$_jni_target_name" ]
action(_jni_target_name) {
action_with_pydeps(_jni_target_name) {
# The sources aren't compiled so don't check their dependencies.
check_includes = false
depfile = "$target_gen_dir/$target_name.d"
script = "//base/android/jni_generator/jni_generator.py"
inputs = [
_jar_file,
@ -351,8 +347,6 @@ if (enable_java_templates) {
]
args = [
"--depfile",
rebase_path(depfile, root_build_dir),
"--jar_file",
rebase_path(_jar_file, root_build_dir),
"--input_file",
@ -413,7 +407,7 @@ if (enable_java_templates) {
# ]
# }
template("generate_jni_registration") {
action(target_name) {
action_with_pydeps(target_name) {
forward_variables_from(invoker, [ "testonly" ])
_build_config = get_label_info(invoker.target, "target_gen_dir") + "/" +
get_label_info(invoker.target, "name") + ".build_config"
@ -494,7 +488,7 @@ if (enable_java_templates) {
_base_gen_dir = "${target_gen_dir}/${target_name}/java_cpp_template"
_package_path = invoker.package_path
action_foreach(_apply_gcc_target_name) {
action_foreach_with_pydeps(_apply_gcc_target_name) {
forward_variables_from(invoker,
[
"deps",
@ -568,7 +562,7 @@ if (enable_java_templates) {
# }
template("java_cpp_enum") {
set_sources_assignment_filter([])
action(target_name) {
action_with_pydeps(target_name) {
forward_variables_from(invoker,
[
"sources",
@ -596,19 +590,6 @@ if (enable_java_templates) {
}
}
if (compute_inputs_for_analyze) {
_jinja_template_pydeps =
exec_script("//build/print_python_deps.py",
[
rebase_path("//build/android/gyp/jinja_template.py"),
"--no-header",
"--gn-paths",
"--root",
rebase_path("//", root_build_dir),
],
"list lines")
}
# Declare a target for processing a Jinja template.
#
# Variables
@ -624,26 +605,20 @@ if (enable_java_templates) {
# output = "$target_gen_dir/AndroidManifest.xml"
# }
template("jinja_template") {
forward_variables_from(invoker, [ "testonly" ])
action(target_name) {
action_with_pydeps(target_name) {
forward_variables_from(invoker,
[
"visibility",
"deps",
"testonly",
])
inputs = [
invoker.input,
]
if (defined(invoker.includes)) {
inputs += invoker.includes
}
if (compute_inputs_for_analyze) {
inputs += _jinja_template_pydeps
}
script = "//build/android/gyp/jinja_template.py"
depfile = "$target_gen_dir/$target_name.d"
outputs = [
invoker.output,
@ -656,8 +631,7 @@ if (enable_java_templates) {
rebase_path(invoker.input, root_build_dir),
"--output",
rebase_path(invoker.output, root_build_dir),
"--depfile",
rebase_path(depfile, root_build_dir),
"--check-includes",
]
if (defined(invoker.includes)) {
_rebased_includes = rebase_path(invoker.includes, root_build_dir)
@ -753,8 +727,6 @@ if (enable_java_templates) {
# variables = ["color=red"]
# }
template("jinja_template_resources") {
forward_variables_from(invoker, [ "testonly" ])
# JUnit tests use resource zip files. These must not be put in gen/
# directory or they will not be available to tester bots.
_resources_zip_rebased_path = rebase_path(target_gen_dir, root_gen_dir)
@ -762,11 +734,14 @@ if (enable_java_templates) {
_generating_target_name = "${target_name}__template"
action(_generating_target_name) {
forward_variables_from(invoker, [ "deps" ])
action_with_pydeps(_generating_target_name) {
forward_variables_from(invoker,
[
"deps",
"testonly",
])
inputs = invoker.resources
script = "//build/android/gyp/jinja_template.py"
depfile = "$target_gen_dir/$target_name.d"
outputs = [
_resources_zip,
@ -779,8 +754,7 @@ if (enable_java_templates) {
rebase_path(invoker.res_dir, root_build_dir),
"--outputs-zip",
rebase_path(_resources_zip, root_build_dir),
"--depfile",
rebase_path(depfile, root_build_dir),
"--check-includes",
]
if (defined(invoker.variables)) {
variables = invoker.variables
@ -789,7 +763,11 @@ if (enable_java_templates) {
}
android_generated_resources(target_name) {
forward_variables_from(invoker, [ "deps" ])
forward_variables_from(invoker,
[
"deps",
"testonly",
])
generating_target_name = ":$_generating_target_name"
generated_resources_zip = _resources_zip
}
@ -1545,7 +1523,7 @@ if (enable_java_templates) {
}
}
} else {
action(_jar_target_name) {
action_with_pydeps(_jar_target_name) {
forward_variables_from(invoker, [ "data" ])
script = "//build/android/gyp/create_dist_jar.py"
depfile = "$target_gen_dir/$target_name.d"
@ -1653,7 +1631,7 @@ if (enable_java_templates) {
_rebased_build_config = rebase_path(_build_config, root_build_dir)
action(target_name) {
action_with_pydeps(target_name) {
forward_variables_from(invoker, [ "data" ])
depfile = "$target_gen_dir/$target_name.d"
deps = _deps
@ -2156,13 +2134,6 @@ if (enable_java_templates) {
version_code = _version_code
version_name = _version_name
# Subtle: required to avoid GN build errors. "testonly" cannot be added
# to the forward_variables_from() above because it was already forwarded
# at the start of android_apk(). And if the assignment below is not
# performed, GN will complain that some test-only targets depend
# on non-test-only ones.
testonly = defined(testonly) && testonly
if (defined(invoker.post_process_package_resources_script)) {
post_process_script = invoker.post_process_package_resources_script
}
@ -2211,7 +2182,7 @@ if (enable_java_templates) {
# TODO(agrieve): Make GN write runtime deps in dependency order so as to
# not need this manual sorting step.
action(_ordered_libraries_target) {
action_with_pydeps(_ordered_libraries_target) {
script = "//build/android/gyp/write_ordered_libraries.py"
deps = [
":$_build_config_target",
@ -2628,9 +2599,8 @@ if (enable_java_templates) {
}
_write_installer_json_rule_name = "${_template_name}__incremental_json"
action(_write_installer_json_rule_name) {
action_with_pydeps(_write_installer_json_rule_name) {
script = "//build/android/incremental_install/write_installer_json.py"
depfile = "$target_gen_dir/$target_name.d"
deps = [
_native_libs_file_arg_dep,
]
@ -2643,14 +2613,12 @@ if (enable_java_templates) {
rebase_path(_final_apk_path_no_ext, root_build_dir)
_rebased_incremental_install_json_path =
rebase_path(_incremental_install_json_path, root_build_dir)
_rebased_depfile = rebase_path(depfile, root_build_dir)
_dex_arg_key = "${_rebased_build_config}:final_dex:dependency_dex_files"
args = [
"--apk-path=${_rebased_apk_path_no_ext}_incremental.apk",
"--output-path=$_rebased_incremental_install_json_path",
"--dex-file=$_rebased_lib_dex_path",
"--dex-file-list=@FileArg($_dex_arg_key)",
"--depfile=$_rebased_depfile",
]
if (_proguard_enabled) {
args += [ "--show-proguard-warning" ]
@ -2676,7 +2644,7 @@ if (enable_java_templates) {
# Generate apk operation related script.
if (!defined(invoker.create_apk_script) || invoker.create_apk_script) {
_apk_operations_target_name = "${target_name}__apk_operations"
action(_apk_operations_target_name) {
action_with_pydeps(_apk_operations_target_name) {
_generated_script = "$root_build_dir/bin/${invoker.target_name}"
script = "//build/android/gyp/create_apk_operations_script.py"
outputs = [
@ -3251,7 +3219,7 @@ if (enable_java_templates) {
# ]
# }
template("android_aidl") {
action(target_name) {
action_with_pydeps(target_name) {
set_sources_assignment_filter([])
forward_variables_from(invoker, [ "testonly" ])
@ -3269,14 +3237,11 @@ if (enable_java_templates) {
inputs = [ _aidl_path ] + _imports
depfile = "${target_gen_dir}/${target_name}.d"
outputs = [
_srcjar_path,
]
_rebased_imports = rebase_path(_imports, root_build_dir)
args = [
"--depfile",
rebase_path(depfile, root_build_dir),
"--aidl-path",
rebase_path(_aidl_path, root_build_dir),
"--imports=$_rebased_imports",
@ -3349,7 +3314,7 @@ if (enable_java_templates) {
_proto_path = invoker.proto_path
_template_name = target_name
action("${_template_name}__protoc_java") {
action_with_pydeps("${_template_name}__protoc_java") {
_srcjar_path = "$target_gen_dir/$target_name.srcjar"
script = "//build/protoc_java.py"
@ -3462,7 +3427,7 @@ if (enable_java_templates) {
" Use ignore_native_libraries = true to silence this error.")
assert(_scanned_files.has_classes_jar || _scanned_files.subjars == [])
action(_unpack_target_name) {
action_with_pydeps(_unpack_target_name) {
script = "//build/android/gyp/aar.py" # Unzips the AAR
args = [
"extract",
@ -3863,18 +3828,10 @@ if (enable_java_templates) {
_bundle_keystore_name = _keystore_name
}
# NOTE: Keep this consistent with the imports of create_app_bundle.py
_create_app_bundle_py_imports =
build_utils_py + [
"//build/android/gyp/util/resource_utils.py",
"//build/android/gyp/bundletool.py",
]
_bundle_target_name = "${target_name}__bundle"
action(_bundle_target_name) {
action_with_pydeps(_bundle_target_name) {
script = "//build/android/gyp/create_app_bundle.py"
inputs = _all_module_zip_paths + _all_module_build_configs +
_create_app_bundle_py_imports
inputs = _all_module_zip_paths + _all_module_build_configs
outputs = [
_bundle_path,
]
@ -3920,12 +3877,12 @@ if (enable_java_templates) {
_rebased_base_module_build_config =
rebase_path(_base_module_build_config, root_build_dir)
action("${target_name}__wrapper_script") {
action_with_pydeps("${target_name}__wrapper_script") {
script = "//build/android/gyp/create_bundle_wrapper_script.py"
inputs = build_utils_py + [
"//build/android/gyp/bundletool.py",
_base_module_build_config,
]
inputs = [
"//build/android/gyp/bundletool.py",
_base_module_build_config,
]
outputs = [
_bundle_wrapper_script_path,
]

Просмотреть файл

@ -59,3 +59,108 @@ template("python_library") {
}
}
}
# A template used for actions that execute a Python script, which has an
# associated .pydeps file. In other words:
#
# - This is very similar to just an action(), except that |script| must point
# to a Python script (e.g. "//build/.../foo.py") that has a corresponding
# .pydeps file in the source tree (e.g. "//build/.../foo.pydeps").
#
# - The .pydeps file contains a list of python dependencies (imports really)
# and is generated _manually_ by using a command like:
#
# build/print_python_deps.py --inplace build/android/gyp/foo.py
#
template("action_with_pydeps") {
# Read the .pydeps file now. Note that this is done everytime this
# template is called, but benchmarking doesn't show any impact on overall
# 'gn gen' speed anyway.
_pydeps_file = invoker.script + "deps"
_pydeps_raw = read_file(_pydeps_file, "list lines")
# Filter out comments.
# This is a bit convoluted to preserve the value of sources if defined.
_old_sources = []
if (defined(sources)) {
_old_sources = sources
}
set_sources_assignment_filter([ "#*" ])
sources = _pydeps_raw
_pydeps = sources
set_sources_assignment_filter([])
sources = _old_sources
action(target_name) {
# Forward all variables. Ensure that testonly and visibility are forwarded
# explicitly, since this performs recursive scope lookups, which is
# required to ensure their definition from scopes above the caller are
# properly handled. All other variables are forwarded with "*", which
# doesn't perform recursive lookups at all. See https://crbug.com/862232
forward_variables_from(invoker,
[
"testonly",
"visibility",
])
forward_variables_from(invoker,
"*",
[
"testonly",
"visibility",
])
if (!defined(inputs)) {
inputs = []
}
# Dependencies are listed relative to the script directory, but inputs
# expects paths that are relative to the current BUILD.gn
_script_dir = get_path_info(script, "dir")
inputs += rebase_path(_pydeps, ".", _script_dir)
}
}
template("action_foreach_with_pydeps") {
_pydeps_file = invoker.script + "deps"
_pydeps_raw = read_file(_pydeps_file, "list lines")
# Filter out comments.
# This is a bit convoluted to preserve the value of sources if defined.
_old_sources = []
if (defined(sources)) {
_old_sources = sources
}
set_sources_assignment_filter([ "#*" ])
sources = _pydeps_raw
_pydeps = sources
set_sources_assignment_filter([])
sources = _old_sources
action_foreach(target_name) {
# Forward all variables. Ensure that testonly and visibility are forwarded
# explicitly, since this performs recursive scope lookups, which is
# required to ensure their definition from scopes above the caller are
# properly handled. All other variables are forwarded with "*", which
# doesn't perform recursive lookups at all. See https://crbug.com/862232
forward_variables_from(invoker,
[
"testonly",
"visibility",
])
forward_variables_from(invoker,
"*",
[
"testonly",
"visibility",
])
if (!defined(inputs)) {
inputs = []
}
# Dependencies are listed relative to the script directory, but inputs
# expects paths that are relative to the current BUILD.gn
_script_dir = get_path_info(script, "dir")
inputs += rebase_path(_pydeps, ".", _script_dir)
}
}

Просмотреть файл

@ -78,6 +78,10 @@ def main():
help='Directory to make paths relative to.')
parser.add_argument('--output',
help='Write output to a file rather than stdout.')
parser.add_argument('--inplace', action='store_true',
help='Write output to a file with the same path as the '
'module, but with a .pydeps extension. Also sets the '
'root to the module\'s directory.')
parser.add_argument('--no-header', action='store_true',
help='Do not write the "# Generated by" header.')
parser.add_argument('--gn-paths', action='store_true',
@ -92,6 +96,14 @@ def main():
sys.path[0] = os.path.dirname(options.module)
imp.load_source('NAME', options.module)
if options.inplace:
if options.output:
parser.error('Cannot use --inplace and --output at the same time!')
if not options.module.endswith('.py'):
parser.error('Input module path should end with .py suffix!')
options.output = options.module + 'deps'
options.root = os.path.dirname(options.module)
paths_set = _ComputePythonDependencies()
for path in options.whitelists:
paths_set.update(os.path.abspath(p) for p in _FindPythonInDirectory(path))

Просмотреть файл

@ -76,7 +76,8 @@ def main(argv):
if options.depfile:
assert options.srcjar
deps = args + [options.protoc]
build_utils.WriteDepfile(options.depfile, options.srcjar, deps)
build_utils.WriteDepfile(options.depfile, options.srcjar, deps,
add_pydeps=False)
if options.stamp:
build_utils.Touch(options.stamp)

7
protoc_java.pydeps Normal file
Просмотреть файл

@ -0,0 +1,7 @@
# Generated by running:
# build/print_python_deps.py --root build --output build/protoc_java.pydeps build/protoc_java.py
android/gyp/util/__init__.py
android/gyp/util/build_utils.py
android/gyp/util/md5_check.py
gn_helpers.py
protoc_java.py