Commit 0006f473 authored by David 'Digit' Turner's avatar David 'Digit' Turner Committed by Commit Bot

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/1163512Reviewed-by: default avataragrieve <agrieve@chromium.org>
Reviewed-by: default avatarEric Stevenson <estevenson@chromium.org>
Commit-Queue: David Turner <digit@chromium.org>
Cr-Commit-Position: refs/heads/master@{#581158}
parent 66101cc5
......@@ -638,9 +638,48 @@ _VALID_OS_MACROS = (
_ANDROID_SPECIFIC_PYDEPS_FILES = [
'base/android/jni_generator/jni_generator.pydeps',
'base/android/jni_generator/jni_registration_generator.pydeps',
'build/android/gyp/aar.pydeps',
'build/android/gyp/aidl.pydeps',
'build/android/gyp/apkbuilder.pydeps',
'build/android/gyp/app_bundle_to_apks.pydeps',
'build/android/gyp/bytecode_processor.pydeps',
'build/android/gyp/compile_resources.pydeps',
'build/android/gyp/create_bundle_wrapper_script.pydeps',
'build/android/gyp/copy_ex.pydeps',
'build/android/gyp/create_app_bundle.pydeps',
'build/android/gyp/create_apk_operations_script.pydeps',
'build/android/gyp/create_dist_jar.pydeps',
'build/android/gyp/create_java_binary_script.pydeps',
'build/android/gyp/create_stack_script.pydeps',
'build/android/gyp/create_test_runner_script.pydeps',
'build/android/gyp/create_tool_wrapper.pydeps',
'build/android/gyp/desugar.pydeps',
'build/android/gyp/dex.pydeps',
'build/android/gyp/dist_aar.pydeps',
'build/android/gyp/emma_instr.pydeps',
'build/android/gyp/filter_zip.pydeps',
'build/android/gyp/gcc_preprocess.pydeps',
'build/android/gyp/generate_proguarded_module_jar.pydeps',
'build/android/gyp/ijar.pydeps',
'build/android/gyp/java_cpp_enum.pydeps',
'build/android/gyp/javac.pydeps',
'build/android/gyp/jinja_template.pydeps',
'build/android/gyp/lint.pydeps',
'build/android/gyp/main_dex_list.pydeps',
'build/android/gyp/merge_jar_info_files.pydeps',
'build/android/gyp/merge_manifest.pydeps',
'build/android/gyp/prepare_resources.pydeps',
'build/android/gyp/proguard.pydeps',
'build/android/gyp/write_build_config.pydeps',
'build/android/gyp/write_ordered_libraries.pydeps',
'build/android/incremental_install/generate_android_manifest.pydeps',
'build/android/incremental_install/write_installer_json.pydeps',
'build/android/resource_sizes.pydeps',
'build/android/test_runner.pydeps',
'build/android/test_wrapper/logdog_wrapper.pydeps',
'build/protoc_java.pydeps',
'build/secondary/third_party/android_platform/'
'development/scripts/stack.pydeps',
'net/tools/testserver/testserver.pydeps',
......
......@@ -1347,7 +1347,6 @@ declarations and print the header file to stdout (or a file).
See SampleForTests.java for more details.
"""
option_parser = optparse.OptionParser(usage=usage)
build_utils.AddDepfileOption(option_parser)
option_parser.add_option('-j', '--jar_file', dest='jar_file',
help='Extract the list of input files from'
......@@ -1401,9 +1400,6 @@ See SampleForTests.java for more details.
output_file = os.path.join(options.output_dir, root_name) + '_jni.h'
GenerateJNIHeader(input_file, output_file, options)
if options.depfile:
build_utils.WriteDepfile(options.depfile, output_file)
if __name__ == '__main__':
sys.exit(main(sys.argv))
# Generated by running:
# build/print_python_deps.py --root base/android/jni_generator --output base/android/jni_generator/jni_generator.pydeps base/android/jni_generator/jni_generator.py
../../../build/android/gyp/util/__init__.py
../../../build/android/gyp/util/build_utils.py
../../../build/android/gyp/util/md5_check.py
../../../build/gn_helpers.py
jni_generator.py
......@@ -333,7 +333,8 @@ def main(argv):
if args.depfile:
build_utils.WriteDepfile(args.depfile, output_file,
args.sources_files + java_file_paths)
args.sources_files + java_file_paths,
add_pydeps=False)
if __name__ == '__main__':
......
# Generated by running:
# build/print_python_deps.py --root base/android/jni_generator --output base/android/jni_generator/jni_registration_generator.pydeps base/android/jni_generator/jni_registration_generator.py
../../../build/android/gyp/util/__init__.py
../../../build/android/gyp/util/build_utils.py
../../../build/android/gyp/util/md5_check.py
../../../build/gn_helpers.py
jni_generator.py
jni_registration_generator.py
# 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))
# 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
# 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
# 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
# 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__':
......
# 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
# 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
# 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
# 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
# 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__':
......
# 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
# 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
# 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
# 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
# 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
# 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
# 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__':
......
# 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
# 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
# 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__':
......
# 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
# 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
# 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__':
......
# 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__':
......
# 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__':
......
# 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
# 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
# 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
# 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
# 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__':
......
# 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
# 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
# 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__':
......
# 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
# 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:])
# 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
This diff is collapsed.
This diff is collapsed.
......@@ -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)
......
# 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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment