GN: Use interface jars in the classpath to speed up compiling (a little)

Rebuilding chrome_java before change:
real    1m0.108s
user    7m44.609s
sys     0m27.630s

Rebuilding chrome_java after change:
real    0m57.893s
user    7m22.493s
sys     0m21.224s

BUG=527632

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

Cr-Original-Commit-Position: refs/heads/master@{#347405}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 6d6c9ac82e8f06abb047501d37b95cae145a727c
This commit is contained in:
agrieve 2015-09-04 07:57:35 -07:00 коммит произвёл Commit bot
Родитель 48b76da6ce
Коммит 4f937822f1
3 изменённых файлов: 38 добавлений и 15 удалений

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

@ -3,6 +3,7 @@
# found in the LICENSE file.
import("//build/config/android/rules.gni")
import("//third_party/ijar/ijar.gni")
sun_tools_jar_path = "$root_gen_dir/sun_tools_jar/tools.jar"
@ -26,6 +27,11 @@ java_prebuilt("sun_tools_java") {
jar_dep = ":find_sun_tools_jar"
}
generate_interface_jar("android_ijar") {
input_jar = android_sdk_jar
output_jar = "$root_out_dir/lib.java/android.interface.jar"
}
action("cpplib_stripped") {
_strip_bin = "${android_tool_prefix}strip"
_soname = "libc++_shared.so"

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

@ -132,6 +132,10 @@ def _ParseOptions(argv):
action='append',
help='Classpath for javac. If this is specified multiple times, they '
'will all be appended to construct the classpath.')
parser.add_option(
'--use-ijars',
action='store_true',
help='Whether to use interface jars (.interface.jar) when compiling')
parser.add_option(
'--javac-includes',
default='',
@ -201,12 +205,19 @@ def main(argv):
java_files = _FilterJavaFiles(java_files, options.javac_includes)
runtime_classpath = options.classpath
compile_classpath = runtime_classpath
if options.use_ijars:
ijar_re = re.compile(r'\.jar$')
compile_classpath = (
[ijar_re.sub('.interface.jar', p) for p in runtime_classpath])
javac_args = [
'-g',
# Chromium only allows UTF8 source files. Being explicit avoids
# javac pulling a default encoding from the user's environment.
'-encoding', 'UTF-8',
'-classpath', ':'.join(options.classpath),
'-classpath', ':'.join(compile_classpath),
]
if options.bootclasspath:
@ -231,11 +242,13 @@ def main(argv):
# Compute the list of paths that when changed, we need to rebuild.
input_paths = options.bootclasspath + options.java_srcjars + java_files
for path in options.classpath:
if os.path.exists(path + '.TOC'):
input_paths.append(path + '.TOC')
else:
input_paths.append(path)
# TODO(agrieve): Remove this .TOC heuristic once GYP is no more.
if not options.use_ijars:
for path in compile_classpath:
if os.path.exists(path + '.TOC'):
input_paths.append(path + '.TOC')
else:
input_paths.append(path)
python_deps = build_utils.GetPythonDependencies()
def OnStaleMd5():
@ -266,7 +279,7 @@ def main(argv):
if options.manifest_entry:
entries = [e.split(':') for e in options.manifest_entry]
manifest_file = os.path.join(temp_dir, 'manifest')
_CreateManifest(manifest_file, options.classpath, options.main_class,
_CreateManifest(manifest_file, runtime_classpath, options.main_class,
entries)
else:
manifest_file = None

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

@ -413,7 +413,8 @@ template("process_java_prebuilt") {
_input_jar_path = invoker.input_jar_path
_output_jar_path = invoker.output_jar_path
_jar_toc_path = _output_jar_path + ".TOC"
_output_ijar_path = get_path_info(_output_jar_path, "dir") + "/" +
get_path_info(_output_jar_path, "name") + ".interface.jar"
assert(invoker.build_config != "")
@ -477,10 +478,9 @@ template("process_java_prebuilt") {
}
}
# TODO(agrieve): Change file extension to .ijar and use them in classpaths.
generate_interface_jar("${target_name}__jar_toc") {
generate_interface_jar("${target_name}__ijar") {
input_jar = _output_jar_path
output_jar = _jar_toc_path
output_jar = _output_ijar_path
deps = [
":$_output_jar_target",
]
@ -489,7 +489,7 @@ template("process_java_prebuilt") {
group(target_name) {
forward_variables_from(invoker, [ "visibility" ])
public_deps = [
":${target_name}__jar_toc",
":${target_name}__ijar",
":$_output_jar_target",
]
}
@ -984,7 +984,7 @@ template("java_prebuilt_impl") {
#
# Outputs:
# $jar_path.jar
# $jar_path.jar.TOC
# $jar_path.interface.jar
#
# Variables
# java_files: List of .java files to compile.
@ -1083,6 +1083,7 @@ template("compile_java") {
_rebased_depfile = rebase_path(depfile, root_build_dir)
args = [
"--depfile=$_rebased_depfile",
"--use-ijars",
"--classpath=@FileArg($_rebased_build_config:javac:classpath)",
"--jar-path=$_rebased_jar_path",
"--java-srcjars=$_rebased_java_srcjars",
@ -1090,8 +1091,11 @@ template("compile_java") {
"--jar-excluded-classes=$_jar_excluded_patterns",
]
if (_supports_android) {
_rebased_android_sdk_jar = rebase_path(android_sdk_jar, root_build_dir)
args += [ "--bootclasspath=$_rebased_android_sdk_jar" ]
deps += [ "//build/android:android_ijar" ]
_android_sdk_ijar = "$root_out_dir/lib.java/android.interface.jar"
inputs += [ _android_sdk_ijar ]
_rebased_android_sdk_ijar = rebase_path(_android_sdk_ijar, root_build_dir)
args += [ "--bootclasspath=$_rebased_android_sdk_ijar" ]
}
foreach(e, _manifest_entries) {
args += [ "--manifest-entry=" + e ]