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

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

Issue 361633002: [Android][gn] Add android resources templates (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gn-java
Patch Set: Fix bad rebase Created 6 years, 5 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
« no previous file with comments | « build/android/gyp/find.py ('k') | build/android/gyp/process_resources.py » ('j') | no next file with comments »
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 shutil 10 import shutil
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 argv = build_utils.ExpandFileArgs(argv) 112 argv = build_utils.ExpandFileArgs(argv)
113 113
114 parser = optparse.OptionParser() 114 parser = optparse.OptionParser()
115 build_utils.AddDepfileOption(parser) 115 build_utils.AddDepfileOption(parser)
116 116
117 parser.add_option( 117 parser.add_option(
118 '--src-gendirs', 118 '--src-gendirs',
119 help='Directories containing generated java files.') 119 help='Directories containing generated java files.')
120 parser.add_option( 120 parser.add_option(
121 '--java-srcjars', 121 '--java-srcjars',
122 action='append',
123 default=[],
122 help='List of srcjars to include in compilation.') 124 help='List of srcjars to include in compilation.')
123 parser.add_option( 125 parser.add_option(
124 '--classpath', 126 '--classpath',
125 action='append', 127 action='append',
126 help='Classpath for javac. If this is specified multiple times, they ' 128 help='Classpath for javac. If this is specified multiple times, they '
127 'will all be appended to construct the classpath.') 129 'will all be appended to construct the classpath.')
128 parser.add_option( 130 parser.add_option(
129 '--javac-includes', 131 '--javac-includes',
130 help='A list of file patterns. If provided, only java files that match' 132 help='A list of file patterns. If provided, only java files that match'
131 'one of the patterns will be compiled.') 133 'one of the patterns will be compiled.')
(...skipping 14 matching lines...) Expand all
146 parser.add_option('--jar-path', help='Jar output path.') 148 parser.add_option('--jar-path', help='Jar output path.')
147 149
148 parser.add_option('--stamp', help='Path to touch on success.') 150 parser.add_option('--stamp', help='Path to touch on success.')
149 151
150 options, args = parser.parse_args(argv) 152 options, args = parser.parse_args(argv)
151 153
152 classpath = [] 154 classpath = []
153 for arg in options.classpath: 155 for arg in options.classpath:
154 classpath += build_utils.ParseGypList(arg) 156 classpath += build_utils.ParseGypList(arg)
155 157
158 java_srcjars = []
159 for arg in options.java_srcjars:
160 java_srcjars += build_utils.ParseGypList(arg)
161
156 java_files = args 162 java_files = args
157 if options.src_gendirs: 163 if options.src_gendirs:
158 src_gendirs = build_utils.ParseGypList(options.src_gendirs) 164 src_gendirs = build_utils.ParseGypList(options.src_gendirs)
159 java_files += build_utils.FindInDirectories(src_gendirs, '*.java') 165 java_files += build_utils.FindInDirectories(src_gendirs, '*.java')
160 166
167 input_files = classpath + java_srcjars + java_files
161 with build_utils.TempDir() as temp_dir: 168 with build_utils.TempDir() as temp_dir:
162 classes_dir = os.path.join(temp_dir, 'classes') 169 classes_dir = os.path.join(temp_dir, 'classes')
163 os.makedirs(classes_dir) 170 os.makedirs(classes_dir)
164 if options.java_srcjars: 171 if java_srcjars:
165 java_dir = os.path.join(temp_dir, 'java') 172 java_dir = os.path.join(temp_dir, 'java')
166 os.makedirs(java_dir) 173 os.makedirs(java_dir)
167 for srcjar in build_utils.ParseGypList(options.java_srcjars): 174 for srcjar in java_srcjars:
168 build_utils.ExtractAll(srcjar, path=java_dir) 175 build_utils.ExtractAll(srcjar, path=java_dir)
169 java_files += build_utils.FindInDirectory(java_dir, '*.java') 176 java_files += build_utils.FindInDirectory(java_dir, '*.java')
170 177
171 if options.javac_includes: 178 if options.javac_includes:
172 javac_includes = build_utils.ParseGypList(options.javac_includes) 179 javac_includes = build_utils.ParseGypList(options.javac_includes)
173 filtered_java_files = [] 180 filtered_java_files = []
174 for f in java_files: 181 for f in java_files:
175 for include in javac_includes: 182 for include in javac_includes:
176 if fnmatch.fnmatch(f, include): 183 if fnmatch.fnmatch(f, include):
177 filtered_java_files.append(f) 184 filtered_java_files.append(f)
(...skipping 16 matching lines...) Expand all
194 # the output are actually from the input .java files. For example, if a 201 # the output are actually from the input .java files. For example, if a
195 # .java file is deleted or an inner class is removed, the classes 202 # .java file is deleted or an inner class is removed, the classes
196 # directory should not contain the corresponding old .class file after 203 # directory should not contain the corresponding old .class file after
197 # running this action. 204 # running this action.
198 build_utils.DeleteDirectory(options.classes_dir) 205 build_utils.DeleteDirectory(options.classes_dir)
199 shutil.copytree(classes_dir, options.classes_dir) 206 shutil.copytree(classes_dir, options.classes_dir)
200 207
201 if options.depfile: 208 if options.depfile:
202 build_utils.WriteDepfile( 209 build_utils.WriteDepfile(
203 options.depfile, 210 options.depfile,
204 classpath + build_utils.GetPythonDependencies()) 211 input_files + build_utils.GetPythonDependencies())
205 212
206 if options.stamp: 213 if options.stamp:
207 build_utils.Touch(options.stamp) 214 build_utils.Touch(options.stamp)
208 215
209 216
210 if __name__ == '__main__': 217 if __name__ == '__main__':
211 sys.exit(main(sys.argv[1:])) 218 sys.exit(main(sys.argv[1:]))
212 219
213 220
OLDNEW
« no previous file with comments | « build/android/gyp/find.py ('k') | build/android/gyp/process_resources.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698