OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 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 """This finds the java distribution's tools.jar and copies it somewhere. |
| 8 """ |
| 9 |
| 10 import argparse |
| 11 import os |
| 12 import re |
| 13 import shutil |
| 14 import sys |
| 15 |
| 16 from util import build_utils |
| 17 |
| 18 RT_JAR_FINDER = re.compile(r'\[Opened (.*)/jre/lib/rt.jar\]') |
| 19 |
| 20 def main(): |
| 21 parser = argparse.ArgumentParser(description='Find Sun Tools Jar') |
| 22 build_utils.AddDepfileOption(parser) |
| 23 parser.add_option('--output', required=True) |
| 24 args = parser.parse_args() |
| 25 |
| 26 sun_tools_jar_path = FindSunToolsJarPath() |
| 27 |
| 28 if sun_tools_jar_path is None: |
| 29 raise Exception("Couldn\'t find tools.jar") |
| 30 |
| 31 shutil.copy(sun_tools_jar_path, args.output) |
| 32 |
| 33 if args.depfile: |
| 34 build_utils.WriteDepfile( |
| 35 args.depfile, |
| 36 [sun_tools_jar_path] + build_utils.GetPythonDependencies()) |
| 37 |
| 38 |
| 39 def FindSunToolsJarPath(): |
| 40 # This works with at least openjdk 1.6, 1.7 and sun java 1.6, 1.7 |
| 41 stdout = build_utils.CheckOutput( |
| 42 ["java", "-verbose", "-version"], print_stderr=False) |
| 43 sun_tools_jar_path = None |
| 44 for ln in stdout.splitlines(): |
| 45 match = re.match(RT_JAR_FINDER, ln) |
| 46 if match: |
| 47 sun_tools_jar_path = os.path.join(match.group(1), 'lib', 'tools.jar') |
| 48 break |
| 49 |
| 50 return sun_tools_jar_path |
| 51 |
| 52 |
| 53 if __name__ == '__main__': |
| 54 sys.exit(main(sys.argv[1:])) |
OLD | NEW |