GN: Make the wrapper script generated for junit work without extra args
Still works with GYP, but for gyp you need the extra arg. BUG= Review URL: https://codereview.chromium.org/1317853006 Cr-Original-Commit-Position: refs/heads/master@{#347413} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 60d3387b05d03cccc8b2339a0541ef6972d2a307
This commit is contained in:
Родитель
4f937822f1
Коммит
50ac99d89e
|
@ -30,6 +30,7 @@ import sys
|
||||||
|
|
||||||
self_dir = os.path.dirname(__file__)
|
self_dir = os.path.dirname(__file__)
|
||||||
classpath = [{classpath}]
|
classpath = [{classpath}]
|
||||||
|
extra_args = {extra_args}
|
||||||
if os.getcwd() != self_dir:
|
if os.getcwd() != self_dir:
|
||||||
offset = os.path.relpath(self_dir, os.getcwd())
|
offset = os.path.relpath(self_dir, os.getcwd())
|
||||||
classpath = [os.path.join(offset, p) for p in classpath]
|
classpath = [os.path.join(offset, p) for p in classpath]
|
||||||
|
@ -37,7 +38,7 @@ java_args = [
|
||||||
"java",
|
"java",
|
||||||
"-classpath", ":".join(classpath),
|
"-classpath", ":".join(classpath),
|
||||||
"-enableassertions",
|
"-enableassertions",
|
||||||
\"{main_class}\"] + sys.argv[1:]
|
\"{main_class}\"] + extra_args + sys.argv[1:]
|
||||||
os.execvp("java", java_args)
|
os.execvp("java", java_args)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -51,7 +52,7 @@ def main(argv):
|
||||||
help='Name of the java class with the "main" entry point.')
|
help='Name of the java class with the "main" entry point.')
|
||||||
parser.add_option('--classpath', action='append',
|
parser.add_option('--classpath', action='append',
|
||||||
help='Classpath for running the jar.')
|
help='Classpath for running the jar.')
|
||||||
options, _ = parser.parse_args(argv)
|
options, extra_args = parser.parse_args(argv)
|
||||||
|
|
||||||
classpath = [options.jar_path]
|
classpath = [options.jar_path]
|
||||||
for cp_arg in options.classpath:
|
for cp_arg in options.classpath:
|
||||||
|
@ -63,7 +64,8 @@ def main(argv):
|
||||||
with open(options.output, 'w') as script:
|
with open(options.output, 'w') as script:
|
||||||
script.write(script_template.format(
|
script.write(script_template.format(
|
||||||
classpath=('"%s"' % '", "'.join(classpath)),
|
classpath=('"%s"' % '", "'.join(classpath)),
|
||||||
main_class=options.main_class))
|
main_class=options.main_class,
|
||||||
|
extra_args=repr(extra_args)))
|
||||||
|
|
||||||
os.chmod(options.output, 0750)
|
os.chmod(options.output, 0750)
|
||||||
|
|
||||||
|
|
|
@ -121,6 +121,14 @@ template("findbugs") {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Generates a script in the output bin.java directory to run a java binary.
|
# Generates a script in the output bin.java directory to run a java binary.
|
||||||
|
#
|
||||||
|
# Variables
|
||||||
|
# main_class: The class containing the progam entry point.
|
||||||
|
# jar_path: The path to the jar to run.
|
||||||
|
# script_name: Name of the script to generate.
|
||||||
|
# build_config: Path to .build_config for the jar (contains classpath).
|
||||||
|
# wrapper_script_args: List of extra arguments to pass to the executable.
|
||||||
|
#
|
||||||
template("java_binary_script") {
|
template("java_binary_script") {
|
||||||
set_sources_assignment_filter([])
|
set_sources_assignment_filter([])
|
||||||
forward_variables_from(invoker, [ "testonly" ])
|
forward_variables_from(invoker, [ "testonly" ])
|
||||||
|
@ -154,6 +162,9 @@ template("java_binary_script") {
|
||||||
"--main-class",
|
"--main-class",
|
||||||
_main_class,
|
_main_class,
|
||||||
]
|
]
|
||||||
|
if (defined(invoker.wrapper_script_args)) {
|
||||||
|
args += [ "--" ] + invoker.wrapper_script_args
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1272,9 +1283,13 @@ template("java_library_impl") {
|
||||||
if (defined(invoker.main_class)) {
|
if (defined(invoker.main_class)) {
|
||||||
_final_datadeps += [ ":${_template_name}__java_binary_script" ]
|
_final_datadeps += [ ":${_template_name}__java_binary_script" ]
|
||||||
java_binary_script("${_template_name}__java_binary_script") {
|
java_binary_script("${_template_name}__java_binary_script") {
|
||||||
|
forward_variables_from(invoker,
|
||||||
|
[
|
||||||
|
"main_class",
|
||||||
|
"wrapper_script_args",
|
||||||
|
])
|
||||||
build_config = _build_config
|
build_config = _build_config
|
||||||
jar_path = _jar_path
|
jar_path = _jar_path
|
||||||
main_class = invoker.main_class
|
|
||||||
script_name = _template_name
|
script_name = _template_name
|
||||||
deps = build_config_deps
|
deps = build_config_deps
|
||||||
}
|
}
|
||||||
|
|
|
@ -796,19 +796,20 @@ template("java_strings_grd_prebuilt") {
|
||||||
# Variables
|
# Variables
|
||||||
# deps: Specifies the dependencies of this target. Java targets in this list
|
# deps: Specifies the dependencies of this target. Java targets in this list
|
||||||
# will be included in the executable (and the javac classpath).
|
# will be included in the executable (and the javac classpath).
|
||||||
#
|
|
||||||
# java_files: List of .java files included in this library.
|
# java_files: List of .java files included in this library.
|
||||||
# srcjar_deps: List of srcjar dependencies. The .java files in the srcjars
|
# srcjar_deps: List of srcjar dependencies. The .java files in the srcjars
|
||||||
# will be added to java_files and be included in this library.
|
# will be added to java_files and be included in this library.
|
||||||
# srcjars: List of srcjars to be included in this library, together with the
|
# srcjars: List of srcjars to be included in this library, together with the
|
||||||
# ones obtained from srcjar_deps.
|
# ones obtained from srcjar_deps.
|
||||||
#
|
|
||||||
# bypass_platform_checks: Disables checks about cross-platform (Java/Android)
|
# bypass_platform_checks: Disables checks about cross-platform (Java/Android)
|
||||||
# dependencies for this target. This will allow depending on an
|
# dependencies for this target. This will allow depending on an
|
||||||
# android_library target, for example.
|
# android_library target, for example.
|
||||||
#
|
|
||||||
# chromium_code: If true, extra analysis warning/errors will be enabled.
|
# chromium_code: If true, extra analysis warning/errors will be enabled.
|
||||||
# enable_errorprone: If true, enables the errorprone compiler.
|
# enable_errorprone: If true, enables the errorprone compiler.
|
||||||
|
# main_class: When specified, a wrapper script is created within
|
||||||
|
# $target_out_dir/bin to launch the binary with the given class as the
|
||||||
|
# entrypoint.
|
||||||
|
# wrapper_script_args: List of additional arguments for the wrapper script.
|
||||||
#
|
#
|
||||||
# data_deps, testonly
|
# data_deps, testonly
|
||||||
#
|
#
|
||||||
|
@ -860,6 +861,10 @@ template("junit_binary") {
|
||||||
forward_variables_from(invoker, "*")
|
forward_variables_from(invoker, "*")
|
||||||
bypass_platform_checks = true
|
bypass_platform_checks = true
|
||||||
main_class = "org.chromium.testing.local.JunitTestMain"
|
main_class = "org.chromium.testing.local.JunitTestMain"
|
||||||
|
wrapper_script_args = [
|
||||||
|
"-test-jars",
|
||||||
|
"$target_name.jar",
|
||||||
|
]
|
||||||
testonly = true
|
testonly = true
|
||||||
|
|
||||||
deps += [
|
deps += [
|
||||||
|
|
Загрузка…
Ссылка в новой задаче