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

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

Issue 328893003: Make javac and jar a single build action (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | build/android/gyp/javac.py » ('j') | build/java_apk.gypi » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2013 The Chromium Authors. All rights reserved. 3 # Copyright 2013 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 import fnmatch 7 import fnmatch
8 import optparse 8 import optparse
9 import os 9 import os
10 import sys 10 import sys
11 11
12 from util import build_utils 12 from util import build_utils
13 from util import md5_check 13 from util import md5_check
14 14
15 15 def Jar(class_files, classes_dir, jar_path):
16 def DoJar(options): 16 jar_path = os.path.abspath(jar_path)
17 class_files = build_utils.FindInDirectory(options.classes_dir, '*.class')
18 for exclude in build_utils.ParseGypList(options.excluded_classes):
19 class_files = filter(
20 lambda f: not fnmatch.fnmatch(f, exclude), class_files)
21
22 jar_path = os.path.abspath(options.jar_path)
23 17
24 # The paths of the files in the jar will be the same as they are passed in to 18 # The paths of the files in the jar will be the same as they are passed in to
25 # the command. Because of this, the command should be run in 19 # the command. Because of this, the command should be run in
26 # options.classes_dir so the .class file paths in the jar are correct. 20 # options.classes_dir so the .class file paths in the jar are correct.
27 jar_cwd = options.classes_dir 21 jar_cwd = classes_dir
28 class_files_rel = [os.path.relpath(f, jar_cwd) for f in class_files] 22 class_files_rel = [os.path.relpath(f, jar_cwd) for f in class_files]
29 jar_cmd = ['jar', 'cf0', jar_path] + class_files_rel 23 jar_cmd = ['jar', 'cf0', jar_path] + class_files_rel
30 24
31 record_path = '%s.md5.stamp' % options.jar_path 25 record_path = '%s.md5.stamp' % jar_path
32 md5_check.CallAndRecordIfStale( 26 md5_check.CallAndRecordIfStale(
33 lambda: build_utils.CheckOutput(jar_cmd, cwd=jar_cwd), 27 lambda: build_utils.CheckOutput(jar_cmd, cwd=jar_cwd),
34 record_path=record_path, 28 record_path=record_path,
35 input_paths=class_files, 29 input_paths=class_files,
36 input_strings=jar_cmd) 30 input_strings=jar_cmd,
31 force=not os.path.exists(jar_path),
32 )
37 33
38 build_utils.Touch(options.jar_path) 34 build_utils.Touch(jar_path, fail_if_missing=True)
39 35
40 36
37 def JarDirectory(classes_dir, excluded_classes, jar_path):
38 class_files = build_utils.FindInDirectory(classes_dir, '*.class')
39 for exclude in excluded_classes:
40 class_files = filter(
41 lambda f: not fnmatch.fnmatch(f, exclude), class_files)
42
43 Jar(class_files, classes_dir, jar_path)
44
41 def main(): 45 def main():
42 parser = optparse.OptionParser() 46 parser = optparse.OptionParser()
43 parser.add_option('--classes-dir', help='Directory containing .class files.') 47 parser.add_option('--classes-dir', help='Directory containing .class files.')
44 parser.add_option('--jar-path', help='Jar output path.') 48 parser.add_option('--jar-path', help='Jar output path.')
45 parser.add_option('--excluded-classes', 49 parser.add_option('--excluded-classes',
46 help='List of .class file patterns to exclude from the jar.') 50 help='List of .class file patterns to exclude from the jar.')
47 parser.add_option('--stamp', help='Path to touch on success.') 51 parser.add_option('--stamp', help='Path to touch on success.')
48 52
49 options, _ = parser.parse_args() 53 options, _ = parser.parse_args()
50 54
51 DoJar(options) 55 JarDirectory(options.classes_dir,
56 build_utils.ParseGypList(options.excluded_classes),
57 options.jar_path)
52 58
53 if options.stamp: 59 if options.stamp:
54 build_utils.Touch(options.stamp) 60 build_utils.Touch(options.stamp)
55 61
56 62
57 if __name__ == '__main__': 63 if __name__ == '__main__':
58 sys.exit(main()) 64 sys.exit(main())
59 65
OLDNEW
« no previous file with comments | « no previous file | build/android/gyp/javac.py » ('j') | build/java_apk.gypi » ('J')

Powered by Google App Engine
This is Rietveld 408576698