Chromium Code Reviews| Index: build/android/gyp/find_sun_tools_jar.py |
| diff --git a/build/android/gyp/find_sun_tools_jar.py b/build/android/gyp/find_sun_tools_jar.py |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..66e911341d6137b8db4c03f31fa76ec4382ddedf |
| --- /dev/null |
| +++ b/build/android/gyp/find_sun_tools_jar.py |
| @@ -0,0 +1,56 @@ |
| +#!/usr/bin/env python |
| +# |
| +# 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. |
| + |
| +"""This finds the java distribution's tools.jar and copies it somewhere. |
| +""" |
| + |
| +import argparse |
| +import os |
| +import re |
| +import shutil |
| +import sys |
| + |
| +from util import build_utils |
| + |
| +RT_JAR_FINDER = re.compile(r'\[Opened (.*)/jre/lib/rt.jar\]') |
| + |
| +def main(): |
| + parser = argparse.ArgumentParser(description='Find Sun Tools Jar') |
| + parser.add_argument('--depfile', |
| + help='Path to depfile. This must be specified as the ' |
| + 'action\'s first output.') |
|
jbudorick
2015/05/28 15:38:00
nit: indent this line to where the help string sta
raywilliams_chromium
2015/05/28 17:59:11
Done.
|
| + parser.add_argument('--output', required=True) |
| + args = parser.parse_args() |
| + |
| + sun_tools_jar_path = FindSunToolsJarPath() |
| + |
| + if sun_tools_jar_path is None: |
| + raise Exception("Couldn\'t find tools.jar") |
| + |
| + shutil.copy(sun_tools_jar_path, args.output) |
| + |
| + if args.depfile: |
| + build_utils.WriteDepfile( |
| + args.depfile, |
| + [sun_tools_jar_path] + build_utils.GetPythonDependencies()) |
| + |
| + |
| +def FindSunToolsJarPath(): |
| + # This works with at least openjdk 1.6, 1.7 and sun java 1.6, 1.7 |
| + stdout = build_utils.CheckOutput( |
| + ["java", "-verbose", "-version"], print_stderr=False) |
| + sun_tools_jar_path = None |
| + for ln in stdout.splitlines(): |
| + match = re.match(RT_JAR_FINDER, ln) |
| + if match: |
| + sun_tools_jar_path = os.path.join(match.group(1), 'lib', 'tools.jar') |
|
jbudorick
2015/05/28 15:38:00
nit: just return os.path.join(...) here and return
raywilliams_chromium
2015/05/28 17:59:11
I like that idea
raywilliams_chromium
2015/05/28 17:59:11
Done.
|
| + break |
| + |
| + return sun_tools_jar_path |
| + |
| + |
| +if __name__ == '__main__': |
| + sys.exit(main()) |