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-Original-Commit-Position: refs/heads/master@{#559916}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: a7f1ee90249c022de2b5d441bb1e1a3f8c0ecdd7
This commit is contained in:
Andrew Grieve 2018-05-18 16:17:22 +00:00 коммит произвёл Commit Bot
Родитель fc8308f6b6
Коммит 1a81962a1a
4 изменённых файлов: 146 добавлений и 38 удалений

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

@ -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
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",
]
}