OLD | NEW |
1 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """ | 5 """ |
6 Tool module for adding, to a construction environment, Chromium-specific | 6 Tool module for adding, to a construction environment, Chromium-specific |
7 wrappers around SCons builders. This gives us a central place for any | 7 wrappers around SCons builders. This gives us a central place for any |
8 customization we need to make to the different things we build. | 8 customization we need to make to the different things we build. |
9 """ | 9 """ |
10 | 10 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 def compilable_files(env, sources): | 181 def compilable_files(env, sources): |
182 if not hasattr(sources, 'entries'): | 182 if not hasattr(sources, 'entries'): |
183 return [x for x in sources if compilable(env, x)] | 183 return [x for x in sources if compilable(env, x)] |
184 result = [] | 184 result = [] |
185 for top, folders, nonfolders in FileListWalk(sources): | 185 for top, folders, nonfolders in FileListWalk(sources): |
186 result.extend([x for x in nonfolders if compilable(env, x)]) | 186 result.extend([x for x in nonfolders if compilable(env, x)]) |
187 return result | 187 return result |
188 | 188 |
189 def ChromeProgram(env, target, source, *args, **kw): | 189 def ChromeProgram(env, target, source, *args, **kw): |
190 source = compilable_files(env, source) | 190 source = compilable_files(env, source) |
191 if env.get('_GYP'): | 191 result = env.Program('$TOP_BUILDDIR/' + str(target), source, *args, **kw) |
192 prog = env.Program(target, source, *args, **kw) | |
193 result = env.ChromeInstall('$TOP_BUILDDIR', prog) | |
194 else: | |
195 result = env.ComponentProgram(target, source, *args, **kw) | |
196 if env.get('INCREMENTAL'): | 192 if env.get('INCREMENTAL'): |
197 env.Precious(result) | 193 env.Precious(result) |
198 return result | 194 return result |
199 | 195 |
200 def ChromeTestProgram(env, target, source, *args, **kw): | 196 def ChromeTestProgram(env, target, source, *args, **kw): |
201 source = compilable_files(env, source) | 197 source = compilable_files(env, source) |
202 if env.get('_GYP'): | 198 result = env.Program('$TOP_BUILDDIR/' + str(target), source, *args, **kw) |
203 prog = env.Program(target, source, *args, **kw) | |
204 result = env.ChromeInstall('$TOP_BUILDDIR', prog) | |
205 else: | |
206 result = env.ComponentTestProgram(target, source, *args, **kw) | |
207 if env.get('INCREMENTAL'): | 199 if env.get('INCREMENTAL'): |
208 env.Precious(*result) | 200 env.Precious(*result) |
209 return result | 201 return result |
210 | 202 |
211 def ChromeLibrary(env, target, source, *args, **kw): | 203 def ChromeLibrary(env, target, source, *args, **kw): |
212 source = compilable_files(env, source) | 204 source = compilable_files(env, source) |
213 if env.get('_GYP'): | 205 result = env.Library('$LIB_DIR/' + str(target), source, *args, **kw) |
214 lib = env.Library(target, source, *args, **kw) | |
215 result = env.ChromeInstall('$LIB_DIR', lib) | |
216 else: | |
217 result = env.ComponentLibrary(target, source, *args, **kw) | |
218 return result | 206 return result |
219 | 207 |
220 def ChromeLoadableModule(env, target, source, *args, **kw): | 208 def ChromeLoadableModule(env, target, source, *args, **kw): |
221 source = compilable_files(env, source) | 209 source = compilable_files(env, source) |
222 if env.get('_GYP'): | 210 if env.get('_GYP'): |
223 result = env.LoadableModule(target, source, *args, **kw) | 211 result = env.LoadableModule(target, source, *args, **kw) |
224 else: | 212 else: |
225 kw['COMPONENT_STATIC'] = True | 213 kw['COMPONENT_STATIC'] = True |
226 result = env.LoadableModule(target, source, *args, **kw) | 214 result = env.LoadableModule(target, source, *args, **kw) |
227 return result | 215 return result |
228 | 216 |
229 def ChromeStaticLibrary(env, target, source, *args, **kw): | 217 def ChromeStaticLibrary(env, target, source, *args, **kw): |
230 source = compilable_files(env, source) | 218 source = compilable_files(env, source) |
231 if env.get('_GYP'): | 219 if env.get('_GYP'): |
232 lib = env.StaticLibrary(target, source, *args, **kw) | 220 result = env.StaticLibrary('$LIB_DIR/' + str(target), source, *args, **kw) |
233 result = env.ChromeInstall('$LIB_DIR', lib) | |
234 else: | 221 else: |
235 kw['COMPONENT_STATIC'] = True | 222 kw['COMPONENT_STATIC'] = True |
236 result = env.ComponentLibrary(target, source, *args, **kw) | 223 result = env.ComponentLibrary(target, source, *args, **kw) |
237 return result | 224 return result |
238 | 225 |
239 def ChromeSharedLibrary(env, target, source, *args, **kw): | 226 def ChromeSharedLibrary(env, target, source, *args, **kw): |
240 source = compilable_files(env, source) | 227 source = compilable_files(env, source) |
241 if env.get('_GYP'): | 228 if env.get('_GYP'): |
242 lib = env.SharedLibrary(target, source, *args, **kw) | 229 result = env.SharedLibrary('$LIB_DIR/' + str(target), source, *args, **kw) |
243 result = env.ChromeInstall('$LIB_DIR', lib) | |
244 else: | 230 else: |
245 kw['COMPONENT_STATIC'] = False | 231 kw['COMPONENT_STATIC'] = False |
246 result = [env.ComponentLibrary(target, source, *args, **kw)[0]] | 232 result = [env.ComponentLibrary(target, source, *args, **kw)[0]] |
247 if env.get('INCREMENTAL'): | 233 if env.get('INCREMENTAL'): |
248 env.Precious(result) | 234 env.Precious(result) |
249 return result | 235 return result |
250 | 236 |
251 def ChromeObject(env, *args, **kw): | 237 def ChromeObject(env, *args, **kw): |
252 if env.get('_GYP'): | 238 if env.get('_GYP'): |
253 result = env.Object(target, source, *args, **kw) | 239 result = env.Object(target, source, *args, **kw) |
254 else: | 240 else: |
255 result = env.ComponentObject(*args, **kw) | 241 result = env.ComponentObject(*args, **kw) |
256 return result | 242 return result |
257 | 243 |
258 def ChromeInstall(env, target, source): | |
259 """ | |
260 Replacement for the stock SCons Install() builder to use the | |
261 external cp utility instead of Python internals. | |
262 """ | |
263 result = [] | |
264 copy_action = Action('cp $SOURCE $TARGET', 'Copying $TARGET') | |
265 for s in source: | |
266 dest = str(target) + '/' + os.path.split(str(s))[1] | |
267 result.extend(env.Command(dest, s, copy_action)) | |
268 return result | |
269 | |
270 def generate(env): | 244 def generate(env): |
271 env.AddMethod(ChromeProgram) | 245 env.AddMethod(ChromeProgram) |
272 env.AddMethod(ChromeTestProgram) | 246 env.AddMethod(ChromeTestProgram) |
273 env.AddMethod(ChromeLibrary) | 247 env.AddMethod(ChromeLibrary) |
274 env.AddMethod(ChromeLoadableModule) | 248 env.AddMethod(ChromeLoadableModule) |
275 env.AddMethod(ChromeStaticLibrary) | 249 env.AddMethod(ChromeStaticLibrary) |
276 env.AddMethod(ChromeSharedLibrary) | 250 env.AddMethod(ChromeSharedLibrary) |
277 env.AddMethod(ChromeObject) | 251 env.AddMethod(ChromeObject) |
278 env.AddMethod(ChromeInstall) | |
279 | 252 |
280 env.AddMethod(FilterOut) | 253 env.AddMethod(FilterOut) |
281 | 254 |
282 # Add the grit tool to the base environment because we use this a lot. | 255 # Add the grit tool to the base environment because we use this a lot. |
283 sys.path.append(env.Dir('$SRC_DIR/tools/grit').abspath) | 256 sys.path.append(env.Dir('$SRC_DIR/tools/grit').abspath) |
284 env.Tool('scons', toolpath=[env.Dir('$SRC_DIR/tools/grit/grit')]) | 257 env.Tool('scons', toolpath=[env.Dir('$SRC_DIR/tools/grit/grit')]) |
285 | 258 |
286 # Add the repack python script tool that we use in multiple places. | 259 # Add the repack python script tool that we use in multiple places. |
287 sys.path.append(env.Dir('$SRC_DIR/tools/data_pack').abspath) | 260 sys.path.append(env.Dir('$SRC_DIR/tools/data_pack').abspath) |
288 env.Tool('scons', toolpath=[env.Dir('$SRC_DIR/tools/data_pack/')]) | 261 env.Tool('scons', toolpath=[env.Dir('$SRC_DIR/tools/data_pack/')]) |
289 | 262 |
290 def exists(env): | 263 def exists(env): |
291 return True | 264 return True |
OLD | NEW |