SConstruct (8100:cf1afc88070f) SConstruct (8120:e4257cde2d79)
1# -*- mode:python -*-
2
3# Copyright (c) 2011 Advanced Micro Devices, Inc.
4# Copyright (c) 2009 The Hewlett-Packard Development Company
5# Copyright (c) 2004-2005 The Regents of The University of Michigan
6# All rights reserved.
7#
8# Redistribution and use in source and binary forms, with or without

--- 107 unchanged lines hidden (view full) ---

116 Dir('src/python').srcnode().abspath, # M5 includes
117 Dir('ext/ply').srcnode().abspath, # ply is used by several files
118 ]
119
120sys.path[1:1] = extra_python_paths
121
122from m5.util import compareVersions, readCommand
123
1# -*- mode:python -*-
2
3# Copyright (c) 2011 Advanced Micro Devices, Inc.
4# Copyright (c) 2009 The Hewlett-Packard Development Company
5# Copyright (c) 2004-2005 The Regents of The University of Michigan
6# All rights reserved.
7#
8# Redistribution and use in source and binary forms, with or without

--- 107 unchanged lines hidden (view full) ---

116 Dir('src/python').srcnode().abspath, # M5 includes
117 Dir('ext/ply').srcnode().abspath, # ply is used by several files
118 ]
119
120sys.path[1:1] = extra_python_paths
121
122from m5.util import compareVersions, readCommand
123
124AddOption('--colors', dest='use_colors', action='store_true')
125AddOption('--no-colors', dest='use_colors', action='store_false')
126use_colors = GetOption('use_colors')
124help_texts = {
125 "options" : "",
126 "global_vars" : "",
127 "local_vars" : ""
128}
127
129
130Export("help_texts")
131
132def AddM5Option(*args, **kwargs):
133 col_width = 30
134
135 help = " " + ", ".join(args)
136 if "help" in kwargs:
137 length = len(help)
138 if length >= col_width:
139 help += "\n" + " " * col_width
140 else:
141 help += " " * (col_width - length)
142 help += kwargs["help"]
143 help_texts["options"] += help + "\n"
144
145 AddOption(*args, **kwargs)
146
147AddM5Option('--colors', dest='use_colors', action='store_true',
148 help="Add color to abbreviated scons output")
149AddM5Option('--no-colors', dest='use_colors', action='store_false',
150 help="Don't add color to abbreviated scons output")
151AddM5Option('--default', dest='default', type='string', action='store',
152 help='Override which build_opts file to use for defaults')
153AddM5Option('--ignore-style', dest='ignore_style', action='store_true',
154 help='Disable style checking hooks')
155AddM5Option('--update-ref', dest='update_ref', action='store_true',
156 help='Update test reference outputs')
157AddM5Option('--verbose', dest='verbose', action='store_true',
158 help='Print full tool command lines')
159
160use_colors = GetOption('use_colors')
128if use_colors:
129 from m5.util.terminal import termcap
130elif use_colors is None:
131 # option unspecified; default behavior is to use colors iff isatty
132 from m5.util.terminal import tty_termcap as termcap
133else:
134 from m5.util.terminal import no_termcap as termcap
135

--- 65 unchanged lines hidden (view full) ---

201 try:
202 hg_info = readCommand(cmd, cwd=main.root.abspath).strip()
203 except OSError:
204 print mercurial_bin_not_found
205
206 # 2) Ensure that the style hook is in place.
207 try:
208 ui = None
161if use_colors:
162 from m5.util.terminal import termcap
163elif use_colors is None:
164 # option unspecified; default behavior is to use colors iff isatty
165 from m5.util.terminal import tty_termcap as termcap
166else:
167 from m5.util.terminal import no_termcap as termcap
168

--- 65 unchanged lines hidden (view full) ---

234 try:
235 hg_info = readCommand(cmd, cwd=main.root.abspath).strip()
236 except OSError:
237 print mercurial_bin_not_found
238
239 # 2) Ensure that the style hook is in place.
240 try:
241 ui = None
209 if ARGUMENTS.get('IGNORE_STYLE') != 'True':
242 if GetOption('ignore_style'):
210 from mercurial import ui
211 ui = ui.ui()
212 except ImportError:
213 print mercurial_lib_not_found
214
215 if ui is not None:
216 ui.readconfig(hgdir.File('hgrc').abspath)
217 style_hook = ui.config('hooks', 'pretxncommit.style', None)

--- 95 unchanged lines hidden (view full) ---

313def PathListAllExist(key, val, env):
314 if not val:
315 return
316 paths = val.split(':')
317 for path in paths:
318 if not isdir(path):
319 raise SCons.Errors.UserError("Path does not exist: '%s'" % path)
320
243 from mercurial import ui
244 ui = ui.ui()
245 except ImportError:
246 print mercurial_lib_not_found
247
248 if ui is not None:
249 ui.readconfig(hgdir.File('hgrc').abspath)
250 style_hook = ui.config('hooks', 'pretxncommit.style', None)

--- 95 unchanged lines hidden (view full) ---

346def PathListAllExist(key, val, env):
347 if not val:
348 return
349 paths = val.split(':')
350 for path in paths:
351 if not isdir(path):
352 raise SCons.Errors.UserError("Path does not exist: '%s'" % path)
353
321global_sticky_vars_file = joinpath(build_root, 'variables.global')
354global_vars_file = joinpath(build_root, 'variables.global')
322
355
323global_sticky_vars = Variables(global_sticky_vars_file, args=ARGUMENTS)
324global_nonsticky_vars = Variables(args=ARGUMENTS)
356global_vars = Variables(global_vars_file, args=ARGUMENTS)
325
357
326global_sticky_vars.AddVariables(
358global_vars.AddVariables(
327 ('CC', 'C compiler', environ.get('CC', main['CC'])),
328 ('CXX', 'C++ compiler', environ.get('CXX', main['CXX'])),
329 ('BATCH', 'Use batch pool for build and tests', False),
330 ('BATCH_CMD', 'Batch pool submission command name', 'qdo'),
331 ('M5_BUILD_CACHE', 'Cache built objects in this directory', False),
332 ('EXTRAS', 'Add Extra directories to the compilation', '',
333 PathListAllExist, PathListMakeAbsolute),
334 )
335
359 ('CC', 'C compiler', environ.get('CC', main['CC'])),
360 ('CXX', 'C++ compiler', environ.get('CXX', main['CXX'])),
361 ('BATCH', 'Use batch pool for build and tests', False),
362 ('BATCH_CMD', 'Batch pool submission command name', 'qdo'),
363 ('M5_BUILD_CACHE', 'Cache built objects in this directory', False),
364 ('EXTRAS', 'Add Extra directories to the compilation', '',
365 PathListAllExist, PathListMakeAbsolute),
366 )
367
336global_nonsticky_vars.AddVariables(
337 ('VERBOSE', 'Print full tool command lines', False),
338 ('update_ref', 'Update test reference outputs', False)
339 )
368# Update main environment with values from ARGUMENTS & global_vars_file
369global_vars.Update(main)
370help_texts["global_vars"] += global_vars.GenerateHelpText(main)
340
371
341# Update main environment with values from ARGUMENTS & global_sticky_vars_file
342global_sticky_vars.Update(main)
343global_nonsticky_vars.Update(main)
344global_help_texts = {
345 "global_sticky" : global_sticky_vars.GenerateHelpText(main),
346 "global_nonsticky" : global_nonsticky_vars.GenerateHelpText(main)
347}
348
349# base help text
350help_text = '''
351Usage: scons [scons options] [build options] [target(s)]
352
353Global sticky options:
354%(global_sticky)s
355Global nonsticky options:
356%(global_nonsticky)s
357''' % global_help_texts
358
359# Save sticky variable settings back to current variables file
372# Save sticky variable settings back to current variables file
360global_sticky_vars.Save(global_sticky_vars_file, main)
373global_vars.Save(global_vars_file, main)
361
362# Parse EXTRAS variable to build list of all directories where we're
363# look for sources etc. This list is exported as base_dir_list.
364base_dir = main.srcdir.abspath
365if main['EXTRAS']:
366 extras_dir_list = main['EXTRAS'].split(':')
367else:
368 extras_dir_list = []

--- 81 unchanged lines hidden (view full) ---

450 def fmt(files):
451 f = map(lambda s: s[com_pfx_len:], files)
452 return ', '.join(f)
453 return self.format % (com_pfx, fmt(srcs), fmt(tgts))
454
455Export('Transform')
456
457
374
375# Parse EXTRAS variable to build list of all directories where we're
376# look for sources etc. This list is exported as base_dir_list.
377base_dir = main.srcdir.abspath
378if main['EXTRAS']:
379 extras_dir_list = main['EXTRAS'].split(':')
380else:
381 extras_dir_list = []

--- 81 unchanged lines hidden (view full) ---

463 def fmt(files):
464 f = map(lambda s: s[com_pfx_len:], files)
465 return ', '.join(f)
466 return self.format % (com_pfx, fmt(srcs), fmt(tgts))
467
468Export('Transform')
469
470
458if main['VERBOSE']:
471if GetOption('verbose'):
459 def MakeAction(action, string, *args, **kwargs):
460 return Action(action, *args, **kwargs)
461else:
462 MakeAction = Action
463 main['CCCOMSTR'] = Transform("CC")
464 main['CXXCOMSTR'] = Transform("CXX")
465 main['ASCOMSTR'] = Transform("AS")
466 main['SWIGCOMSTR'] = Transform("SWIG")

--- 493 unchanged lines hidden (view full) ---

960 # Make sure the directory is there so we can create it later
961 opt_dir = dirname(current_vars_file)
962 if not isdir(opt_dir):
963 mkdir(opt_dir)
964
965 # Get default build variables from source tree. Variables are
966 # normally determined by name of $VARIANT_DIR, but can be
967 # overriden by 'default=' arg on command line.
472 def MakeAction(action, string, *args, **kwargs):
473 return Action(action, *args, **kwargs)
474else:
475 MakeAction = Action
476 main['CCCOMSTR'] = Transform("CC")
477 main['CXXCOMSTR'] = Transform("CXX")
478 main['ASCOMSTR'] = Transform("AS")
479 main['SWIGCOMSTR'] = Transform("SWIG")

--- 493 unchanged lines hidden (view full) ---

973 # Make sure the directory is there so we can create it later
974 opt_dir = dirname(current_vars_file)
975 if not isdir(opt_dir):
976 mkdir(opt_dir)
977
978 # Get default build variables from source tree. Variables are
979 # normally determined by name of $VARIANT_DIR, but can be
980 # overriden by 'default=' arg on command line.
968 default_vars_file = joinpath('build_opts',
969 ARGUMENTS.get('default', variant_dir))
981 default = GetOption('default')
982 if not default:
983 default = variant_dir
984 default_vars_file = joinpath('build_opts', default)
970 if isfile(default_vars_file):
971 sticky_vars.files.append(default_vars_file)
972 print "Variables file %s not found,\n using defaults in %s" \
973 % (current_vars_file, default_vars_file)
974 else:
975 print "Error: cannot find variables file %s or %s" \
976 % (current_vars_file, default_vars_file)
977 Exit(1)
978
979 # Apply current variable settings to env
980 sticky_vars.Update(env)
981
985 if isfile(default_vars_file):
986 sticky_vars.files.append(default_vars_file)
987 print "Variables file %s not found,\n using defaults in %s" \
988 % (current_vars_file, default_vars_file)
989 else:
990 print "Error: cannot find variables file %s or %s" \
991 % (current_vars_file, default_vars_file)
992 Exit(1)
993
994 # Apply current variable settings to env
995 sticky_vars.Update(env)
996
982 help_text += "\nSticky variables for %s:\n" % variant_dir \
997 help_texts["local_vars"] += \
998 "Build variables for %s:\n" % variant_dir \
983 + sticky_vars.GenerateHelpText(env)
984
985 # Process variable settings.
986
987 if not have_fenv and env['USE_FENV']:
988 print "Warning: <fenv.h> not available; " \
989 "forcing USE_FENV to False in", variant_dir + "."
990 env['USE_FENV'] = False

--- 28 unchanged lines hidden (view full) ---

1019 exports = 'env')
1020
1021 # Set up the regression tests for each build.
1022 for e in envList:
1023 SConscript('tests/SConscript',
1024 variant_dir = joinpath(variant_path, 'tests', e.Label),
1025 exports = { 'env' : e }, duplicate = False)
1026
999 + sticky_vars.GenerateHelpText(env)
1000
1001 # Process variable settings.
1002
1003 if not have_fenv and env['USE_FENV']:
1004 print "Warning: <fenv.h> not available; " \
1005 "forcing USE_FENV to False in", variant_dir + "."
1006 env['USE_FENV'] = False

--- 28 unchanged lines hidden (view full) ---

1035 exports = 'env')
1036
1037 # Set up the regression tests for each build.
1038 for e in envList:
1039 SConscript('tests/SConscript',
1040 variant_dir = joinpath(variant_path, 'tests', e.Label),
1041 exports = { 'env' : e }, duplicate = False)
1042
1027Help(help_text)
1043# base help text
1044Help('''
1045Usage: scons [scons options] [build variables] [target(s)]
1046
1047Extra scons options:
1048%(options)s
1049
1050Global build variables:
1051%(global_vars)s
1052
1053%(local_vars)s
1054''' % help_texts)