Commit 148d5c92 authored by Andrew Grieve's avatar Andrew Grieve Committed by Commit Bot

Delete "wrapper_script" GN template.

Converts run_benchmark to use the newer generate_wrapper() template.
Deletes other uses, which I don't think were used at all.

This also adds a call to "normpath" to generate_wrapper.py so that
@WrappedPath()s don't look odd (e.g.: one was: "bin/../.")

Bug: 816629
Change-Id: I5aa5dc7c2033e3386712f7162fe7371dc47661fb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1866556
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Commit-Queue: John Budorick <jbudorick@chromium.org>
Auto-Submit: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: default avatarJohn Budorick <jbudorick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#707092}
parent abd4fcfa
......@@ -1323,7 +1323,6 @@ _ANDROID_SPECIFIC_PYDEPS_FILES = [
'build/android/gyp/create_apk_operations_script.pydeps',
'build/android/gyp/create_java_binary_script.pydeps',
'build/android/gyp/create_size_info_files.pydeps',
'build/android/gyp/create_tool_wrapper.pydeps',
'build/android/gyp/desugar.pydeps',
'build/android/gyp/dexsplitter.pydeps',
'build/android/gyp/dex.pydeps',
......
......@@ -131,23 +131,3 @@ python_library("bundle_wrapper_script_py") {
"//third_party/android_build_tools/bundletool/bundletool-all-0.10.3.jar",
]
}
# Create wrapper scripts in out/bin that takes care of setting the
# --output-directory.
_scripts_to_wrap = [
"asan_symbolize.py",
"tombstones.py",
]
_wrapper_targets = []
foreach(script, _scripts_to_wrap) {
_target_name = get_path_info(script, "name") + "_wrapper"
_wrapper_targets += [ ":$_target_name" ]
wrapper_script(_target_name) {
target = script
}
}
group("wrapper_scripts") {
deps = _wrapper_targets
}
#!/usr/bin/env python
#
# Copyright 2016 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 simple wrapper script that passes the correct --output-directory.
"""
import argparse
import os
_TEMPLATE = """\
#!/usr/bin/env python
#
# This file was generated by //build/android/gyp/create_tool_script.py
import os
import sys
cmd = '{cmd}'
args = [os.path.basename(cmd), '{flag_name}={output_directory}'] + sys.argv[1:]
os.execv(cmd, args)
"""
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--output', help='Output path for executable script.')
parser.add_argument('--target', help='Path to script being wrapped.')
parser.add_argument('--output-directory', help='Value for --output-directory')
parser.add_argument('--flag-name',
help='Flag name to use instead of --output-directory',
default='--output-directory')
args = parser.parse_args()
with open(args.output, 'w') as script:
script.write(_TEMPLATE.format(
cmd=os.path.abspath(args.target),
flag_name=args.flag_name,
output_directory=os.path.abspath(args.output_directory)))
os.chmod(args.output, 0750)
if __name__ == '__main__':
main()
# 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
......@@ -128,53 +128,6 @@ template("create_native_executable_dist") {
}
}
# Writes a script to root_out_dir/bin that passes --output-directory to the
# wrapped script, in addition to forwarding arguments. Most / all of these
# wrappers should be made deps of //tools/android:android_tools.
#
# Variables
# target: Script to wrap.
# flag_name: Default is "--output-directory"
#
# Example
# wrapper_script("foo_wrapper") {
# target = "//pkg/foo.py"
# }
template("wrapper_script") {
action_with_pydeps(target_name) {
forward_variables_from(invoker,
[
"data",
"data_deps",
"deps",
])
_name = get_path_info(invoker.target, "name")
_output = "$root_out_dir/bin/$_name"
script = "//build/android/gyp/create_tool_wrapper.py"
outputs = [
_output,
]
# The target isn't actually used by the script, but it's nice to have GN
# check that it exists.
inputs = [
invoker.target,
]
args = [
"--output",
rebase_path(_output, root_build_dir),
"--target",
rebase_path(invoker.target, root_build_dir),
"--output-directory",
rebase_path(root_out_dir, root_build_dir),
]
if (defined(invoker.flag_name)) {
args += [ "--flag-name=${invoker.flag_name}" ]
}
}
}
if (enable_java_templates) {
import("//build/config/sanitizers/sanitizers.gni")
import("//tools/grit/grit_rule.gni")
......
......@@ -57,8 +57,9 @@ PY_TEMPLATE = textwrap.dedent(
def ExpandWrappedPath(arg):
m = _WRAPPED_PATH_RE.match(arg)
if m:
return os.path.join(
relpath = os.path.join(
os.path.relpath(_SCRIPT_DIR), _PATH_TO_OUTPUT_DIR, m.group(1))
return os.path.normpath(relpath)
return arg
......
# Copyright 2015 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.
if (is_android) {
import("//build/config/android/rules.gni")
wrapper_script("stack_wrapper") {
target = "//third_party/android_platform/development/scripts/stack"
data_deps = [
"//third_party/android_platform/development/scripts:stack_py",
]
}
}
......@@ -9,9 +9,7 @@ import("//build/config/sanitizers/sanitizers.gni")
group("android_tools") {
testonly = true
deps = [
"//build/android:wrapper_scripts",
"//build/android/pylib/device/commands",
"//third_party/android_platform:stack_wrapper",
"//third_party/catapult/telemetry:bitmaptools($host_toolchain)",
"//tools/android/adb_reboot",
"//tools/android/forwarder2",
......
......@@ -43,11 +43,15 @@ group("perf") {
}
if (is_android) {
import("//build/config/android/rules.gni")
wrapper_script("run_benchmark_wrapper") {
target = "run_benchmark"
flag_name = "--chromium-output-directory"
import("//build/util/generate_wrapper.gni")
generate_wrapper("run_benchmark_wrapper") {
executable = "run_benchmark"
wrapper_script = "$root_build_dir/bin/run_benchmark"
executable_args = [
"--chromium-output-directory",
"@WrappedPath(.)",
]
}
}
......
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