Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python | |
|
cjhopman
2014/06/25 01:20:03
This now uses the gyp/javac.py (going forward, we
| |
| 2 # | |
| 3 # Copyright 2014 The Chromium Authors. All rights reserved. | |
| 4 # Use of this source code is governed by a BSD-style license that can be | |
| 5 # found in the LICENSE file. | |
| 6 | |
| 7 import fnmatch | |
| 8 import optparse | |
| 9 import os | |
| 10 import sys | |
| 11 import zipfile | |
| 12 | |
| 13 BUILD_ANDROID_DIR = os.path.join(os.path.dirname(__file__), '..') | |
| 14 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
| |
| 15 | |
| 16 from gyp import javac as gyp_javac | |
| 17 from gyp import jar as gyp_jar | |
| 18 from gyp.util import build_utils | |
| 19 | |
| 20 | |
| 21 def main(argv): | |
| 22 parser = optparse.OptionParser() | |
| 23 parser.add_option( | |
| 24 '--depfile', | |
| 25 help='Path to depfile output (relative to the root build directory).') | |
| 26 parser.add_option('--java-files', help='List of java files to compile.') | |
| 27 parser.add_option( | |
| 28 '--java-srcjars', | |
| 29 help='List of srcjars to include in compilation.') | |
| 30 parser.add_option('--classpath-jars', help='Paths to jar dependencies.') | |
| 31 parser.add_option('--jar-path', help='Output jar path.') | |
| 32 parser.add_option('--chromium-code', help='If 1, enable extra warnings.') | |
| 33 options, _ = parser.parse_args(argv) | |
| 34 | |
| 35 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
| |
| 36 build_utils.GetPythonDependencies()) | |
| 37 | |
| 38 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.
| |
| 39 java_srcjars = build_utils.ParseGnList(options.java_srcjars) | |
| 40 classpath_jars = build_utils.ParseGnList(options.classpath_jars) | |
| 41 jar_path = options.jar_path | |
| 42 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
| |
| 43 | |
| 44 with build_utils.TempDir() as temp_dir: | |
| 45 classes_dir = os.path.join(temp_dir, 'classes') | |
|
Nico
2014/05/05 22:26:14
Consider giving TempDir() an argument that's appen
| |
| 46 os.makedirs(classes_dir) | |
| 47 if java_srcjars: | |
| 48 java_dir = os.path.join(temp_dir, 'java') | |
| 49 os.makedirs(java_dir) | |
| 50 for srcjar in java_srcjars: | |
| 51 with zipfile.ZipFile(srcjar, 'r') as srczip: | |
| 52 for name in srczip.namelist(): | |
| 53 if os.path.normpath(name) != name: | |
| 54 raise Exception('bad name in srcjar') | |
| 55 srczip.extract(name, java_dir) | |
| 56 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
| |
| 57 | |
| 58 | |
| 59 gyp_javac.Javac(java_files, classpath_jars, classes_dir, chromium_code) | |
| 60 class_files = build_utils.FindInDirectory(classes_dir, '*.class') | |
| 61 gyp_jar.Jar(class_files, classes_dir, jar_path) | |
| 62 | |
| 63 | |
| 64 | |
| 65 if __name__ == '__main__': | |
| 66 sys.exit(main(sys.argv)) | |
| 67 | |
|
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.
| |
| 68 | |
| 69 | |
| 70 | |
| OLD | NEW |