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..cb29c5516d6148a98a55f207f6ec797dad2f996b |
| --- /dev/null |
| +++ b/build/android/gyp/find_sun_tools_jar.py |
| @@ -0,0 +1,47 @@ |
| +#!/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 optparse |
| +import os |
| +import re |
| +import shutil |
| +import sys |
| + |
| +from util import build_utils |
| + |
| +def main(argv): |
| + parser = optparse.OptionParser() |
| + build_utils.AddDepfileOption(parser) |
| + parser.add_option('--output', help='Path to copy the tools.jar to.') |
|
jbudorick
2015/05/07 18:49:26
There has got to be a better way to do this than c
cjhopman
2015/05/07 19:15:18
That would be nice. You need to use the tools.jar
raywilliams_chromium
2015/05/11 19:52:24
From cjhopman's answer, it sounds like this is the
|
| + options, _ = parser.parse_args(argv) |
| + |
| + # 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, print_stdout=False) |
| + rt_jar_finder = re.compile(r'\[Opened (.*)/jre/lib/rt.jar\]') |
| + sun_tools_jar_path = None |
| + for ln in stdout.split('\n'): |
| + match = re.match(rt_jar_finder, ln) |
| + if match: |
| + sun_tools_jar_path = os.path.join(match.group(1), 'lib', 'tools.jar') |
| + break |
| + |
| + if sun_tools_jar_path is None: |
| + raise Exception('Couldn\'t find tools.jar') |
| + |
| + shutil.copy(sun_tools_jar_path, options.output) |
| + |
| + if options.depfile: |
| + build_utils.WriteDepfile( |
| + options.depfile, |
| + [sun_tools_jar_path] + build_utils.GetPythonDependencies()) |
| + |
| + |
| +if __name__ == '__main__': |
| + sys.exit(main(sys.argv[1:])) |