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

Side by Side Diff: pylib/gyp/__init__.py

Issue 2122004: Add a flag to generate the Makefile in a different directory than... (Closed) Base URL: http://gyp.googlecode.com/svn/trunk/
Patch Set: '' Created 10 years, 7 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 | pylib/gyp/generator/make.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/python 1 #!/usr/bin/python
2 2
3 # Copyright (c) 2009 Google Inc. All rights reserved. 3 # Copyright (c) 2009 Google Inc. 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 copy 7 import copy
8 import gyp.input 8 import gyp.input
9 import optparse 9 import optparse
10 import os.path 10 import os.path
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 help='sets generator flag FLAG to VAL') 258 help='sets generator flag FLAG to VAL')
259 parser.add_option('--generator-output', dest='generator_output', 259 parser.add_option('--generator-output', dest='generator_output',
260 action='store', default=None, metavar='DIR', type='path', 260 action='store', default=None, metavar='DIR', type='path',
261 env_name='GYP_GENERATOR_OUTPUT', 261 env_name='GYP_GENERATOR_OUTPUT',
262 help='puts generated build files under DIR') 262 help='puts generated build files under DIR')
263 parser.add_option('--ignore-environment', dest='use_environment', 263 parser.add_option('--ignore-environment', dest='use_environment',
264 action='store_false', default=True, regenerate=False, 264 action='store_false', default=True, regenerate=False,
265 help='do not read options from environment variables') 265 help='do not read options from environment variables')
266 parser.add_option('--check', dest='check', action='store_true', 266 parser.add_option('--check', dest='check', action='store_true',
267 help='check format of gyp files') 267 help='check format of gyp files')
268 parser.add_option('--toplevel-dir', dest='toplevel_dir', action='store',
269 default=None, metavar='DIR', type='path',
270 help='directory to use as the root of the source tree')
268 # --no-circular-check disables the check for circular relationships between 271 # --no-circular-check disables the check for circular relationships between
269 # .gyp files. These relationships should not exist, but they've only been 272 # .gyp files. These relationships should not exist, but they've only been
270 # observed to be harmful with the Xcode generator. Chromium's .gyp files 273 # observed to be harmful with the Xcode generator. Chromium's .gyp files
271 # currently have some circular relationships on non-Mac platforms, so this 274 # currently have some circular relationships on non-Mac platforms, so this
272 # option allows the strict behavior to be used on Macs and the lenient 275 # option allows the strict behavior to be used on Macs and the lenient
273 # behavior to be used elsewhere. 276 # behavior to be used elsewhere.
274 # TODO(mark): Remove this option when http://crbug.com/35878 is fixed. 277 # TODO(mark): Remove this option when http://crbug.com/35878 is fixed.
275 parser.add_option('--no-circular-check', dest='circular_check', 278 parser.add_option('--no-circular-check', dest='circular_check',
276 action='store_false', default=True, regenerate=False, 279 action='store_false', default=True, regenerate=False,
277 help="don't check for circular relationships between files") 280 help="don't check for circular relationships between files")
278 281
279 # We read a few things from ~/.gyp, so set up a var for that. 282 # We read a few things from ~/.gyp, so set up a var for that.
280 home_vars = ['HOME'] 283 home_vars = ['HOME']
281 if sys.platform in ('cygwin', 'win32'): 284 if sys.platform in ('cygwin', 'win32'):
282 home_vars.append('USERPROFILE') 285 home_vars.append('USERPROFILE')
283 home = None 286 home = None
284 for home_var in home_vars: 287 for home_var in home_vars:
285 home = os.getenv(home_var) 288 home = os.getenv(home_var)
286 if home != None: 289 if home != None:
287 break 290 break
288 home_dot_gyp = None 291 home_dot_gyp = None
289 if home != None: 292 if home != None:
290 home_dot_gyp = os.path.join(home, '.gyp') 293 home_dot_gyp = os.path.join(home, '.gyp')
291 if not os.path.exists(home_dot_gyp): 294 if not os.path.exists(home_dot_gyp):
292 home_dot_gyp = None 295 home_dot_gyp = None
293 296
294 # TODO(thomasvl): add support for ~/.gyp/defaults 297 # TODO(thomasvl): add support for ~/.gyp/defaults
295 298
296 (options, build_files_arg) = parser.parse_args(args) 299 options, build_files_arg = parser.parse_args(args)
297 build_files = build_files_arg 300 build_files = build_files_arg
298 301
299 if not options.formats: 302 if not options.formats:
300 # If no format was given on the command line, then check the env variable. 303 # If no format was given on the command line, then check the env variable.
301 generate_formats = [] 304 generate_formats = []
302 if options.use_environment: 305 if options.use_environment:
303 generate_formats = os.environ.get('GYP_GENERATORS', []) 306 generate_formats = os.environ.get('GYP_GENERATORS', [])
304 if generate_formats: 307 if generate_formats:
305 generate_formats = re.split('[\s,]', generate_formats) 308 generate_formats = re.split('[\s,]', generate_formats)
306 if generate_formats: 309 if generate_formats:
(...skipping 13 matching lines...) Expand all
320 g_o = os.environ.get('GYP_GENERATOR_OUTPUT') 323 g_o = os.environ.get('GYP_GENERATOR_OUTPUT')
321 if g_o: 324 if g_o:
322 options.generator_output = g_o 325 options.generator_output = g_o
323 326
324 for mode in options.debug: 327 for mode in options.debug:
325 gyp.debug[mode] = 1 328 gyp.debug[mode] = 1
326 329
327 # Do an extra check to avoid work when we're not debugging. 330 # Do an extra check to avoid work when we're not debugging.
328 if DEBUG_GENERAL in gyp.debug.keys(): 331 if DEBUG_GENERAL in gyp.debug.keys():
329 DebugOutput(DEBUG_GENERAL, 'running with these options:') 332 DebugOutput(DEBUG_GENERAL, 'running with these options:')
330 for (option, value) in options.__dict__.items(): 333 for option, value in sorted(options.__dict__.items()):
331 if option[0] == '_': 334 if option[0] == '_':
332 continue 335 continue
333 if isinstance(value, basestring): 336 if isinstance(value, basestring):
334 DebugOutput(DEBUG_GENERAL, " %s: '%s'" % (option, value)) 337 DebugOutput(DEBUG_GENERAL, " %s: '%s'" % (option, value))
335 else: 338 else:
336 DebugOutput(DEBUG_GENERAL, " %s: %s" % (option, str(value))) 339 DebugOutput(DEBUG_GENERAL, " %s: %s" % (option, str(value)))
337 340
338 if not build_files: 341 if not build_files:
339 build_files = FindBuildFiles() 342 build_files = FindBuildFiles()
340 if not build_files: 343 if not build_files:
(...skipping 22 matching lines...) Expand all
363 # build file. 366 # build file.
364 if options.depth: 367 if options.depth:
365 break 368 break
366 369
367 if not options.depth: 370 if not options.depth:
368 raise Exception, \ 371 raise Exception, \
369 'Could not automatically locate src directory. This is a ' + \ 372 'Could not automatically locate src directory. This is a ' + \
370 'temporary Chromium feature that will be removed. Use ' + \ 373 'temporary Chromium feature that will be removed. Use ' + \
371 '--depth as a workaround.' 374 '--depth as a workaround.'
372 375
376 # If toplevel-dir is not set, we assume that depth is the root of our source
377 # tree.
378 if not options.toplevel_dir:
379 options.toplevel_dir = options.depth
380
373 # -D on the command line sets variable defaults - D isn't just for define, 381 # -D on the command line sets variable defaults - D isn't just for define,
374 # it's for default. Perhaps there should be a way to force (-F?) a 382 # it's for default. Perhaps there should be a way to force (-F?) a
375 # variable's value so that it can't be overridden by anything else. 383 # variable's value so that it can't be overridden by anything else.
376 cmdline_default_variables = {} 384 cmdline_default_variables = {}
377 defines = [] 385 defines = []
378 if options.use_environment: 386 if options.use_environment:
379 defines += ShlexEnv('GYP_DEFINES') 387 defines += ShlexEnv('GYP_DEFINES')
380 if options.defines: 388 if options.defines:
381 defines += options.defines 389 defines += options.defines
382 cmdline_default_variables = NameValueListToDict(defines) 390 cmdline_default_variables = NameValueListToDict(defines)
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 # need to have dependencies defined before dependents reference them should 452 # need to have dependencies defined before dependents reference them should
445 # generate targets in the order specified in flat_list. 453 # generate targets in the order specified in flat_list.
446 generator.GenerateOutput(flat_list, targets, data, params) 454 generator.GenerateOutput(flat_list, targets, data, params)
447 455
448 # Done 456 # Done
449 return 0 457 return 0
450 458
451 459
452 if __name__ == '__main__': 460 if __name__ == '__main__':
453 sys.exit(main(sys.argv[1:])) 461 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | pylib/gyp/generator/make.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698