Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(679)

Side by Side Diff: build/android/gyp/retrolambda.py

Issue 2543463002: Add retrolambda.py and integrate it to build process. (Closed)
Patch Set: Addressing comments Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/android/gyp/javac.py ('k') | build/config/android/config.gni » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 #
3 # Copyright 2016 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 argparse
8 import os
9 import shutil
10 import sys
11 import tempfile
12
13 from util import build_utils
14
15
16 _SRC_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__),
17 '..', '..', '..'))
18 _RETROLAMBDA_JAR_PATH = os.path.normpath(os.path.join(
19 _SRC_ROOT, 'third_party', 'retrolambda', 'retrolambda-2.3.0.jar'))
20
21
22 def _OnStaleMd5(input_jar, output_jar, classpath, android_sdk_jar):
23 with build_utils.TempDir() as temp_dir:
24 build_utils.ExtractAll(input_jar, path=temp_dir)
25 cmd = [
26 'java',
27 '-Dretrolambda.inputDir=' + temp_dir,
28 '-Dretrolambda.classpath=' +
29 ':'.join([temp_dir] + classpath + [android_sdk_jar]),
30 '-javaagent:' + _RETROLAMBDA_JAR_PATH,
31 '-jar',
32 _RETROLAMBDA_JAR_PATH,
33 ]
34
35 build_utils.CheckOutput(cmd, print_stdout=False)
36 build_utils.ZipDir(output_jar + '.tmp', temp_dir)
37 shutil.move(output_jar + '.tmp', output_jar)
38
39
40 def main():
41 args = build_utils.ExpandFileArgs(sys.argv[1:])
42 parser = argparse.ArgumentParser()
43 build_utils.AddDepfileOption(parser)
44 parser.add_argument('--input-jar', required=True,
45 help='Jar input path to include .class files from.')
46 parser.add_argument('--output-jar', required=True,
47 help='Jar output path.')
48 parser.add_argument('--classpath', required=True,
49 help='Classpath.')
50 parser.add_argument('--android-sdk-jar', required=True,
51 help='Android sdk jar path.')
52 options = parser.parse_args(args)
53
54 options.classpath = build_utils.ParseGnList(options.classpath)
55 input_paths = options.classpath + [options.input_jar]
56 output_paths = [options.output_jar]
57
58 build_utils.CallAndWriteDepfileIfStale(
59 lambda: _OnStaleMd5(options.input_jar, options.output_jar,
60 options.classpath, options.android_sdk_jar),
61 options,
62 input_paths=input_paths,
63 input_strings=[],
64 output_paths=output_paths)
65
66
67 if __name__ == '__main__':
68 sys.exit(main())
OLDNEW
« no previous file with comments | « build/android/gyp/javac.py ('k') | build/config/android/config.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698