[iOS][GN] Port ios_web_unittests to build with gn

Add template to run a java command as an "script", i.e. templates
java_action/java_action_foreach similar to action/action_foreach.

Add template to compile a bunch of JavaScript to a bundle and to
compile JavaScript files with closure compile (only enable checks
that are known to work).

Fix gcdwebserver public configuration to add the dependency on libz
to libs instead of using ldflags.

Add files missing from //ui/base:test_support when building for iOS
with gn (they are present in the gyp build).

BUG=459705

Review URL: https://codereview.chromium.org/1393303003

Cr-Original-Commit-Position: refs/heads/master@{#355460}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: aa7c1cf96274a0a531629f934bd9091a55439270
This commit is contained in:
sdefresne 2015-10-21 17:41:11 -07:00 коммит произвёл Commit bot
Родитель beb6ce497b
Коммит f345848333
2 изменённых файлов: 183 добавлений и 0 удалений

101
util/java_action.gni Normal file
Просмотреть файл

@ -0,0 +1,101 @@
# 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.
jarrunner = "//build/util/java_action.py"
# Declare a target that runs a java command a single time.
#
# This target type allows you to run a java command a single time to produce
# one or more output files. If you want to run a java command for each of a
# set of input files, see "java_action_foreach".
#
# See "gn help action" for more information on how to use this target. This
# template is based on the "action" and supports the same variables.
template("java_action") {
assert(defined(invoker.script),
"Need script in $target_name listing the .jar file to run.")
assert(defined(invoker.outputs),
"Need outputs in $target_name listing the generated outputs.")
jarscript = invoker.script
action(target_name) {
script = jarrunner
inputs = [
jarscript,
]
if (defined(invoker.inputs)) {
inputs += invoker.inputs
}
args = [
"-jar",
rebase_path(jarscript, root_build_dir),
]
if (defined(invoker.args)) {
args += invoker.args
}
forward_variables_from(invoker,
[
"console",
"data",
"data_deps",
"depfile",
"deps",
"outputs",
"sources",
"visibility",
])
}
}
# Declare a target that runs a java command over a set of files.
#
# This target type allows you to run a java command once-per-file over a set of
# sources. If you want to run a java command once that takes many files as
# input, see "java_action".
#
# See "gn help action_foreach" for more information on how to use this target.
# This template is based on the "action_foreach" supports the same variables.
template("java_action_foreach") {
assert(defined(invoker.script),
"Need script in $target_name listing the .jar file to run.")
assert(defined(invoker.outputs),
"Need outputs in $target_name listing the generated outputs.")
assert(defined(invoker.sources),
"Need sources in $target_name listing the target inputs.")
jarscript = invoker.script
action_foreach(target_name) {
script = jarrunner
inputs = [
jarscript,
]
if (defined(invoker.inputs)) {
inputs += invoker.inputs
}
args = [
"-jar",
rebase_path(jarscript, root_build_dir),
]
if (defined(invoker.args)) {
args += invoker.args
}
forward_variables_from(invoker,
[
"console",
"data",
"data_deps",
"depfile",
"deps",
"outputs",
"sources",
"visibility",
])
}
}

82
util/java_action.py Executable file
Просмотреть файл

@ -0,0 +1,82 @@
#!/usr/bin/python
# 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.
"""Wrapper script to run java command as action with gn."""
import os
import subprocess
import sys
EXIT_SUCCESS = 0
EXIT_FAILURE = 1
def IsExecutable(path):
"""Returns whether file at |path| exists and is executable.
Args:
path: absolute or relative path to test.
Returns:
True if the file at |path| exists, False otherwise.
"""
return os.path.isfile(path) and os.access(path, os.X_OK)
def FindCommand(command):
"""Looks up for |command| in PATH.
Args:
command: name of the command to lookup, if command is a relative or
absolute path (i.e. contains some path separator) then only that
path will be tested.
Returns:
Full path to command or None if the command was not found.
On Windows, this respects the PATHEXT environment variable when the
command name does not have an extension.
"""
fpath, _ = os.path.split(command)
if fpath:
if IsExecutable(command):
return command
if sys.platform == 'win32':
# On Windows, if the command does not have an extension, cmd.exe will
# try all extensions from PATHEXT when resolving the full path.
command, ext = os.path.splitext(command)
if not ext:
exts = os.environ['PATHEXT'].split(os.path.pathsep)
else:
exts = [ext]
else:
exts = ['']
for path in os.environ['PATH'].split(os.path.pathsep):
for ext in exts:
path = os.path.join(path, command) + ext
if IsExecutable(path):
return path
return None
def main():
java_path = FindCommand('java')
if not java_path:
sys.stderr.write('java: command not found\n')
sys.exit(EXIT_FAILURE)
args = sys.argv[1:]
if len(args) < 2 or args[0] != '-jar':
sys.stderr.write('usage: %s -jar JARPATH [java_args]...\n' % sys.argv[0])
sys.exit(EXIT_FAILURE)
return subprocess.check_call([java_path] + args)
if __name__ == '__main__':
sys.exit(main())