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

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: 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
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',
122 help='List of srcjars to include in compilation.') 123 help='List of srcjars to include in compilation.')
123 parser.add_option( 124 parser.add_option(
124 '--classpath', 125 '--classpath',
125 action='append', 126 action='append',
126 help='Classpath for javac. If this is specified multiple times, they ' 127 help='Classpath for javac. If this is specified multiple times, they '
127 'will all be appended to construct the classpath.') 128 'will all be appended to construct the classpath.')
128 parser.add_option( 129 parser.add_option(
129 '--javac-includes', 130 '--javac-includes',
130 help='A list of file patterns. If provided, only java files that match' 131 help='A list of file patterns. If provided, only java files that match'
131 'one of the patterns will be compiled.') 132 'one of the patterns will be compiled.')
(...skipping 14 matching lines...) Expand all
146 parser.add_option('--jar-path', help='Jar output path.') 147 parser.add_option('--jar-path', help='Jar output path.')
147 148
148 parser.add_option('--stamp', help='Path to touch on success.') 149 parser.add_option('--stamp', help='Path to touch on success.')
149 150
150 options, args = parser.parse_args(argv) 151 options, args = parser.parse_args(argv)
151 152
152 classpath = [] 153 classpath = []
153 for arg in options.classpath: 154 for arg in options.classpath:
154 classpath += build_utils.ParseGypList(arg) 155 classpath += build_utils.ParseGypList(arg)
155 156
157 java_srcjars = []
158 for arg in options.java_srcjars:
159 java_srcjars += build_utils.ParseGypList(arg)
160
156 java_files = args 161 java_files = args
157 if options.src_gendirs: 162 if options.src_gendirs:
158 src_gendirs = build_utils.ParseGypList(options.src_gendirs) 163 src_gendirs = build_utils.ParseGypList(options.src_gendirs)
159 java_files += build_utils.FindInDirectories(src_gendirs, '*.java') 164 java_files += build_utils.FindInDirectories(src_gendirs, '*.java')
160 165
166 input_files = classpath + java_srcjars + java_files
161 with build_utils.TempDir() as temp_dir: 167 with build_utils.TempDir() as temp_dir:
162 classes_dir = os.path.join(temp_dir, 'classes') 168 classes_dir = os.path.join(temp_dir, 'classes')
163 os.makedirs(classes_dir) 169 os.makedirs(classes_dir)
164 if options.java_srcjars: 170 if java_srcjars:
165 java_dir = os.path.join(temp_dir, 'java') 171 java_dir = os.path.join(temp_dir, 'java')
166 os.makedirs(java_dir) 172 os.makedirs(java_dir)
167 for srcjar in build_utils.ParseGypList(options.java_srcjars): 173 for srcjar in java_srcjars:
168 build_utils.ExtractAll(srcjar, path=java_dir) 174 build_utils.ExtractAll(srcjar, path=java_dir)
169 java_files += build_utils.FindInDirectory(java_dir, '*.java') 175 java_files += build_utils.FindInDirectory(java_dir, '*.java')
170 176
171 if options.javac_includes: 177 if options.javac_includes:
172 javac_includes = build_utils.ParseGypList(options.javac_includes) 178 javac_includes = build_utils.ParseGypList(options.javac_includes)
173 filtered_java_files = [] 179 filtered_java_files = []
174 for f in java_files: 180 for f in java_files:
175 for include in javac_includes: 181 for include in javac_includes:
176 if fnmatch.fnmatch(f, include): 182 if fnmatch.fnmatch(f, include):
177 filtered_java_files.append(f) 183 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 200 # 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 201 # .java file is deleted or an inner class is removed, the classes
196 # directory should not contain the corresponding old .class file after 202 # directory should not contain the corresponding old .class file after
197 # running this action. 203 # running this action.
198 build_utils.DeleteDirectory(options.classes_dir) 204 build_utils.DeleteDirectory(options.classes_dir)
199 shutil.copytree(classes_dir, options.classes_dir) 205 shutil.copytree(classes_dir, options.classes_dir)
200 206
201 if options.depfile: 207 if options.depfile:
202 build_utils.WriteDepfile( 208 build_utils.WriteDepfile(
203 options.depfile, 209 options.depfile,
204 classpath + build_utils.GetPythonDependencies()) 210 input_files + build_utils.GetPythonDependencies())
205 211
206 if options.stamp: 212 if options.stamp:
207 build_utils.Touch(options.stamp) 213 build_utils.Touch(options.stamp)
208 214
209 215
210 if __name__ == '__main__': 216 if __name__ == '__main__':
211 sys.exit(main(sys.argv[1:])) 217 sys.exit(main(sys.argv[1:]))
212 218
213 219
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698