Chromium Code Reviews| Index: build/android/gn/javac.py |
| diff --git a/build/android/gn/javac.py b/build/android/gn/javac.py |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..de85c27576a57c048d3ff5839cbb7f90a4112195 |
| --- /dev/null |
| +++ b/build/android/gn/javac.py |
| @@ -0,0 +1,70 @@ |
| +#!/usr/bin/env python |
|
cjhopman
2014/06/25 01:20:03
This now uses the gyp/javac.py (going forward, we
|
| +# |
| +# Copyright 2014 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. |
| + |
| +import fnmatch |
| +import optparse |
| +import os |
| +import sys |
| +import zipfile |
| + |
| +BUILD_ANDROID_DIR = os.path.join(os.path.dirname(__file__), '..') |
| +sys.path.append(BUILD_ANDROID_DIR) |
|
Nico
2014/05/05 22:26:14
This is defined in build/android/pylib/constants.p
cjhopman
2014/06/25 01:20:03
Can't access constants.py without first calculatin
|
| + |
| +from gyp import javac as gyp_javac |
| +from gyp import jar as gyp_jar |
| +from gyp.util import build_utils |
| + |
| + |
| +def main(argv): |
| + parser = optparse.OptionParser() |
| + parser.add_option( |
| + '--depfile', |
| + help='Path to depfile output (relative to the root build directory).') |
| + parser.add_option('--java-files', help='List of java files to compile.') |
| + parser.add_option( |
| + '--java-srcjars', |
| + help='List of srcjars to include in compilation.') |
| + parser.add_option('--classpath-jars', help='Paths to jar dependencies.') |
| + parser.add_option('--jar-path', help='Output jar path.') |
| + parser.add_option('--chromium-code', help='If 1, enable extra warnings.') |
| + options, _ = parser.parse_args(argv) |
| + |
| + build_utils.WriteDepfile(options.depfile, |
|
Nico
2014/05/05 21:56:45
I don't see this checked in yet. Does this have th
cjhopman
2014/05/05 22:05:19
This is in build/android/gyp/util/build_utils.py
I
|
| + build_utils.GetPythonDependencies()) |
| + |
| + java_files = build_utils.ParseGnList(options.java_files) |
|
Nico
2014/05/05 22:26:14
nit: I'd parse java_files through args, not throug
cjhopman
2014/06/25 01:20:03
Done.
|
| + java_srcjars = build_utils.ParseGnList(options.java_srcjars) |
| + classpath_jars = build_utils.ParseGnList(options.classpath_jars) |
| + jar_path = options.jar_path |
| + chromium_code = options.chromium_code == 'false' |
|
Nico
2014/05/05 22:26:14
Make the option's action store_bool instead?
cjhopman
2014/06/25 01:20:02
Done. It is complicated to have gyp use options th
|
| + |
| + with build_utils.TempDir() as temp_dir: |
| + classes_dir = os.path.join(temp_dir, 'classes') |
|
Nico
2014/05/05 22:26:14
Consider giving TempDir() an argument that's appen
|
| + os.makedirs(classes_dir) |
| + if java_srcjars: |
| + java_dir = os.path.join(temp_dir, 'java') |
| + os.makedirs(java_dir) |
| + for srcjar in java_srcjars: |
| + with zipfile.ZipFile(srcjar, 'r') as srczip: |
| + for name in srczip.namelist(): |
| + if os.path.normpath(name) != name: |
| + raise Exception('bad name in srcjar') |
| + srczip.extract(name, java_dir) |
| + java_files.append(os.path.join(java_dir, name)) |
|
Nico
2014/05/05 22:26:14
This is a somewhat "interesting" change. I'd decou
cjhopman
2014/06/25 01:20:03
In general, I think this is a much better approach
|
| + |
| + |
| + gyp_javac.Javac(java_files, classpath_jars, classes_dir, chromium_code) |
| + class_files = build_utils.FindInDirectory(classes_dir, '*.class') |
| + gyp_jar.Jar(class_files, classes_dir, jar_path) |
| + |
| + |
| + |
| +if __name__ == '__main__': |
| + sys.exit(main(sys.argv)) |
| + |
|
Nico
2014/05/05 21:56:45
nit: Maybe have fewer than 4 empty newlines at the
cjhopman
2014/05/05 22:05:19
Ha.
|
| + |
| + |
| + |