Chromium Code Reviews| 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 parser.add_argument('--depfile', | |
| 23 help='Path to depfile. This must be specified as the ' | |
| 24 'action\'s first output.') | |
| 25 parser.add_argument('--output', required=True) | |
| 26 args = parser.parse_args() | |
| 27 | |
| 28 sun_tools_jar_path = FindSunToolsJarPath() | |
| 29 | |
| 30 if sun_tools_jar_path is None: | |
| 31 raise Exception("Couldn\'t find tools.jar") | |
| 32 | |
| 33 shutil.copy(sun_tools_jar_path, args.output) | |
| 34 | |
| 35 if args.depfile: | |
| 36 build_utils.WriteDepfile( | |
| 37 args.depfile, | |
| 38 [sun_tools_jar_path] + build_utils.GetPythonDependencies()) | |
| 39 | |
| 40 | |
| 41 def FindSunToolsJarPath(): | |
| 42 # This works with at least openjdk 1.6, 1.7 and sun java 1.6, 1.7 | |
| 43 stdout = build_utils.CheckOutput( | |
| 44 ["java", "-verbose", "-version"], print_stderr=False) | |
| 45 for ln in stdout.splitlines(): | |
| 46 match = re.match(RT_JAR_FINDER, ln) | |
|
jbudorick
2015/06/01 22:28:42
nit: match = RT_JAR_FINDER.match(ln)
raywilliams_chromium
2015/06/03 21:53:18
Done.
| |
| 47 if match: | |
| 48 return os.path.join(match.group(1), 'lib', 'tools.jar') | |
| 49 | |
| 50 return None | |
| 51 | |
| 52 | |
| 53 if __name__ == '__main__': | |
| 54 sys.exit(main()) | |
| OLD | NEW |