0

GN: Add "python_library" template for group()s that use ".pydeps"

Also adds two new usages of it:
  //build/android:resource_sizes_py
  //tools/binary_size:binary_size_trybot_py

Bug: 702625
Change-Id: Idc8113ca5e95ec9b5f5ff0cf22c14eeab95b78f8
Reviewed-on: https://chromium-review.googlesource.com/1058836
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Reviewed-by: John Budorick <jbudorick@chromium.org>
Reviewed-by: Helen Li <xunjieli@chromium.org>
Reviewed-by: Peter Wen <wnwen@chromium.org>
Commit-Queue: agrieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#559916}
This commit is contained in:
Andrew Grieve
2018-05-18 16:17:22 +00:00
committed by Commit Bot
parent c94b10c2de
commit a7f1ee9024
11 changed files with 234 additions and 55 deletions
BUILD.gnOWNERSPRESUBMIT.py
build
android
config
secondary
third_party
android_platform
development
scripts
chrome/test/chromedriver
net/tools/testserver
tools/binary_size

@ -68,6 +68,7 @@ group("gn_all") {
"//net:net_unittests",
"//skia:skia_unittests",
"//sql:sql_unittests",
"//tools/binary_size:binary_size_trybot_py",
"//tools/ipc_fuzzer:ipc_fuzzer_all",
"//ui/base:ui_base_unittests",
"//url:url_unittests",

1
OWNERS

@ -18,6 +18,7 @@ per-file AUTHORS=*
per-file BUILD.gn=file://build/OWNERS
per-file codereview.settings=agable@chromium.org
per-file DEPS=*
per-file PRESUBMIT*.py=agrieve@chromium.org # For .pydeps changes
per-file PRESUBMIT*.py=dcheng@chromium.org
per-file PRESUBMIT*.py=dpranke@chromium.org
per-file PRESUBMIT*.py=jochen@chromium.org

@ -628,6 +628,7 @@ _VALID_OS_MACROS = (
_ANDROID_SPECIFIC_PYDEPS_FILES = [
'build/android/resource_sizes.pydeps',
'build/android/test_runner.pydeps',
'build/android/test_wrapper/logdog_wrapper.pydeps',
'build/secondary/third_party/android_platform/'
@ -638,6 +639,7 @@ _ANDROID_SPECIFIC_PYDEPS_FILES = [
_GENERIC_PYDEPS_FILES = [
'chrome/test/chromedriver/test/run_py_tests.pydeps',
'tools/binary_size/supersize.pydeps',
]

@ -4,6 +4,7 @@
import("//build/config/android/config.gni")
import("//build/config/android/rules.gni")
import("//build/config/python.gni")
if (enable_java_templates) {
import("//third_party/ijar/ijar.gni")
@ -109,36 +110,30 @@ action("cpplib_stripped") {
]
}
group("test_runner_py") {
_py_files = read_file("test_runner.pydeps", "list lines")
# Filter out comments.
set_sources_assignment_filter([ "#*" ])
sources = _py_files
data = sources + [
"test_runner.pydeps",
"devil_chromium.json",
"pylib/gtest/filter/",
"pylib/instrumentation/render_test.html.jinja",
"test_wrapper/logdog_wrapper.py",
"${android_sdk_build_tools}/aapt",
"${android_sdk_build_tools}/dexdump",
"${android_sdk_build_tools}/lib64/libc++.so",
"${android_sdk_build_tools}/split-select",
"${android_sdk_root}/platform-tools/adb",
"//third_party/catapult/third_party/gsutil/",
"//third_party/catapult/devil/devil/devil_dependencies.json",
"//third_party/proguard/lib/proguard.jar",
]
python_library("test_runner_py") {
pydeps_file = "test_runner.pydeps"
data = [
"devil_chromium.json",
"pylib/gtest/filter/",
"pylib/instrumentation/render_test.html.jinja",
"test_wrapper/logdog_wrapper.py",
"${android_sdk_build_tools}/aapt",
"${android_sdk_build_tools}/dexdump",
"${android_sdk_build_tools}/lib64/libc++.so",
"${android_sdk_build_tools}/split-select",
"${android_sdk_root}/platform-tools/adb",
"//third_party/catapult/third_party/gsutil/",
"//third_party/catapult/devil/devil/devil_dependencies.json",
"//third_party/proguard/lib/proguard.jar",
]
}
group("logdog_wrapper_py") {
_py_files = read_file("test_wrapper/logdog_wrapper.pydeps", "list lines")
python_library("logdog_wrapper_py") {
pydeps_file = "test_wrapper/logdog_wrapper.pydeps"
}
# Filter out comments.
set_sources_assignment_filter([ "#*" ])
sources = _py_files
data = sources + [ "test_wrapper/logdog_wrapper.pydeps" ]
python_library("resource_sizes_py") {
pydeps_file = "resource_sizes.pydeps"
}
# Create wrapper scripts in out/bin that takes care of setting the

@ -0,0 +1,56 @@
# Generated by running:
# build/print_python_deps.py --root build/android --output build/android/resource_sizes.pydeps build/android/resource_sizes.py
../../third_party/apk-patch-size-estimator/apk_patch_size_estimator.py
../../third_party/catapult/common/py_utils/py_utils/__init__.py
../../third_party/catapult/common/py_utils/py_utils/cloud_storage.py
../../third_party/catapult/common/py_utils/py_utils/cloud_storage_global_lock.py
../../third_party/catapult/common/py_utils/py_utils/lock.py
../../third_party/catapult/dependency_manager/dependency_manager/__init__.py
../../third_party/catapult/dependency_manager/dependency_manager/archive_info.py
../../third_party/catapult/dependency_manager/dependency_manager/base_config.py
../../third_party/catapult/dependency_manager/dependency_manager/cloud_storage_info.py
../../third_party/catapult/dependency_manager/dependency_manager/dependency_info.py
../../third_party/catapult/dependency_manager/dependency_manager/dependency_manager_util.py
../../third_party/catapult/dependency_manager/dependency_manager/exceptions.py
../../third_party/catapult/dependency_manager/dependency_manager/local_path_info.py
../../third_party/catapult/dependency_manager/dependency_manager/manager.py
../../third_party/catapult/dependency_manager/dependency_manager/uploader.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/build_tools.py
../../third_party/catapult/devil/devil/android/sdk/dexdump.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/catapult/devil/devil/devil_env.py
../../third_party/catapult/devil/devil/utils/__init__.py
../../third_party/catapult/devil/devil/utils/cmd_helper.py
../../third_party/catapult/devil/devil/utils/lazy/__init__.py
../../third_party/catapult/devil/devil/utils/lazy/weak_constant.py
../../third_party/catapult/devil/devil/utils/reraiser_thread.py
../../third_party/catapult/devil/devil/utils/timeout_retry.py
../../third_party/catapult/devil/devil/utils/watchdog_timer.py
../../third_party/catapult/third_party/zipfile/zipfile_2_7_13.py
../../third_party/depot_tools/breakpad.py
../../third_party/depot_tools/download_from_google_storage.py
../../third_party/depot_tools/subprocess2.py
../../third_party/depot_tools/upload_to_google_storage.py
../find_depot_tools.py
../gn_helpers.py
../util/lib/common/perf_result_data_type.py
../util/lib/common/perf_tests_results_helper.py
binary_size/__init__.py
binary_size/apk_downloader.py
devil_chromium.py
gyp/util/__init__.py
gyp/util/build_utils.py
gyp/util/md5_check.py
method_count.py
pylib/__init__.py
pylib/constants/__init__.py
pylib/constants/host_paths.py
resource_sizes.py

61
build/config/python.gni Normal file

@ -0,0 +1,61 @@
# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Creates a group() that lists Python sources as |data|.
# Having such targets serves two purposes:
# 1) Causes files to be included in runtime_deps, so that they are uploaded to
# swarming when running tests remotely.
# 2) Causes "gn analyze" to know about all Python inputs so that tests will be
# re-run when relevant Python files change.
#
# All non-trivial Python scripts should use a "pydeps" file to track their
# sources. To create a .pydep file for a target in //example:
#
# build/print_python_deps.py \
# --root example \
# --output example/$target_name.pydeps \
# path/to/your/script.py
#
# Keep the .pydep file up-to-date by adding to //PRESUBMIT.py under one of:
# _ANDROID_SPECIFIC_PYDEPS_FILES, _GENERIC_PYDEPS_FILES
#
# Variables
# pydeps_file: Path to .pydeps file to read sources from (optional).
# data: Additional files to include in data. E.g. non-.py files needed by the
# library, or .py files that are conditionally / lazily imported.
#
# Example
# python_library("my_library_py") {
# pydeps_file = "my_library.pydeps"
# data = [ "foo.dat" ]
# }
template("python_library") {
group(target_name) {
forward_variables_from(invoker,
[
"data_deps",
"deps",
"testonly",
"visibility",
])
if (defined(invoker.pydeps_file)) {
_py_files = read_file(invoker.pydeps_file, "list lines")
# Filter out comments.
set_sources_assignment_filter([ "#*" ])
sources = _py_files
# Even though the .pydep file is not used at runtime, it must be added
# so that "gn analyze" will mark the target as changed when .py files
# are removed but none are added or modified.
data = sources + [ invoker.pydeps_file ]
} else {
data = []
}
if (defined(invoker.data)) {
data += invoker.data
}
}
}

@ -3,16 +3,12 @@
# found in the LICENSE file.
import("//build/config/android/config.gni")
import("//build/config/python.gni")
group("stack_py") {
_pydeps_file = "//build/secondary/third_party/android_platform/development/scripts/stack.pydeps"
_py_files = read_file(_pydeps_file, "list lines")
set_sources_assignment_filter([ "#*" ])
sources = _py_files
data = sources + [
_pydeps_file,
"//third_party/android_platform/development/scripts/stack",
"//third_party/llvm-build/Release+Asserts/bin/llvm-symbolizer",
]
python_library("stack_py") {
pydeps_file = "//build/secondary/third_party/android_platform/development/scripts/stack.pydeps"
data = [
"//third_party/android_platform/development/scripts/stack",
"//third_party/llvm-build/Release+Asserts/bin/llvm-symbolizer",
]
}

@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/python.gni")
import("//build/config/ui.gni")
import("//testing/test.gni")
@ -324,23 +325,18 @@ executable("chromedriver") {
]
}
group("chromedriver_py_tests") {
python_library("chromedriver_py_tests") {
testonly = true
deps = [
":chromedriver",
"//chrome:chrome",
]
_py_files = read_file("test/run_py_tests.pydeps", "list lines")
# Filter out comments.
set_sources_assignment_filter([ "#*" ])
sources = _py_files
data = sources + [
"test/run_py_tests.pydeps",
"//chrome/test/data/chromedriver/",
"//testing/xvfb.py",
]
pydeps_file = "test/run_py_tests.pydeps"
data = [
"//chrome/test/data/chromedriver/",
"//testing/xvfb.py",
]
data_deps = [
"//chrome/test/chromedriver",

@ -2,11 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
group("testserver_py") {
_py_files = read_file("testserver.pydeps", "list lines")
import("//build/config/python.gni")
# Filter out comments.
set_sources_assignment_filter([ "#*" ])
sources = _py_files
data = sources + [ "testserver.pydeps" ]
python_library("testserver_py") {
pydeps_file = "testserver.pydeps"
}

@ -0,0 +1,14 @@
# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/python.gni")
# Used by Android's binary size trybot's "gn analyze" step in order to trigger
# builds when changes are made to these scripts.
python_library("binary_size_trybot_py") {
pydeps_file = "supersize.pydeps"
data = [
"diagnose_bloat.py",
]
}

@ -0,0 +1,60 @@
# Generated by running:
# build/print_python_deps.py --root tools/binary_size --output tools/binary_size/supersize.pydeps tools/binary_size/libsupersize/main.py
../grit/grit/__init__.py
../grit/grit/clique.py
../grit/grit/constants.py
../grit/grit/exception.py
../grit/grit/extern/FP.py
../grit/grit/extern/__init__.py
../grit/grit/extern/tclib.py
../grit/grit/format/__init__.py
../grit/grit/format/data_pack.py
../grit/grit/format/gzip_string.py
../grit/grit/format/html_inline.py
../grit/grit/format/minifier.py
../grit/grit/format/rc.py
../grit/grit/format/rc_header.py
../grit/grit/gather/__init__.py
../grit/grit/gather/admin_template.py
../grit/grit/gather/chrome_html.py
../grit/grit/gather/chrome_scaled_image.py
../grit/grit/gather/interface.py
../grit/grit/gather/policy_json.py
../grit/grit/gather/rc.py
../grit/grit/gather/regexp.py
../grit/grit/gather/skeleton_gatherer.py
../grit/grit/gather/tr_html.py
../grit/grit/gather/txt.py
../grit/grit/lazy_re.py
../grit/grit/node/__init__.py
../grit/grit/node/base.py
../grit/grit/node/include.py
../grit/grit/node/io.py
../grit/grit/node/message.py
../grit/grit/node/misc.py
../grit/grit/node/structure.py
../grit/grit/node/variant.py
../grit/grit/pseudo.py
../grit/grit/pseudo_rtl.py
../grit/grit/tclib.py
../grit/grit/util.py
../grit/grit/xtb_reader.py
libsupersize/apkanalyzer.py
libsupersize/ar.py
libsupersize/archive.py
libsupersize/canned_queries.py
libsupersize/concurrent.py
libsupersize/console.py
libsupersize/demangle.py
libsupersize/describe.py
libsupersize/diff.py
libsupersize/file_format.py
libsupersize/function_signature.py
libsupersize/html_report.py
libsupersize/linker_map_parser.py
libsupersize/main.py
libsupersize/match_util.py
libsupersize/models.py
libsupersize/ninja_parser.py
libsupersize/nm.py
libsupersize/path_util.py