SConstruct (5274:7888bf966443) SConstruct (5341:4efeab4cc2a5)
1# -*- mode:python -*-
2
3# Copyright (c) 2004-2005 The Regents of The University of Michigan
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions are
8# met: redistributions of source code must retain the above copyright

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

200 if this_build_root != build_root:
201 print "Error: build targets not under same build root\n"\
202 " %s\n %s" % (build_root, this_build_root)
203 Exit(1)
204 build_path = joinpath('/',*path_dirs[:build_top+2])
205 if build_path not in build_paths:
206 build_paths.append(build_path)
207
1# -*- mode:python -*-
2
3# Copyright (c) 2004-2005 The Regents of The University of Michigan
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions are
8# met: redistributions of source code must retain the above copyright

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

200 if this_build_root != build_root:
201 print "Error: build targets not under same build root\n"\
202 " %s\n %s" % (build_root, this_build_root)
203 Exit(1)
204 build_path = joinpath('/',*path_dirs[:build_top+2])
205 if build_path not in build_paths:
206 build_paths.append(build_path)
207
208# Make sure build_root exists (might not if this is the first build there)
209if not isdir(build_root):
210 os.mkdir(build_root)
211
208###################################################
209#
210# Set up the default build environment. This environment is copied
211# and modified according to each selected configuration.
212#
213###################################################
214
215env = Environment(ENV = os.environ, # inherit user's environment vars
216 ROOT = ROOT,
217 SRCDIR = SRCDIR)
218
212###################################################
213#
214# Set up the default build environment. This environment is copied
215# and modified according to each selected configuration.
216#
217###################################################
218
219env = Environment(ENV = os.environ, # inherit user's environment vars
220 ROOT = ROOT,
221 SRCDIR = SRCDIR)
222
219#Parse CC/CXX early so that we use the correct compiler for
220# to test for dependencies/versions/libraries/includes
221if ARGUMENTS.get('CC', None):
222 env['CC'] = ARGUMENTS.get('CC')
223
224if ARGUMENTS.get('CXX', None):
225 env['CXX'] = ARGUMENTS.get('CXX')
226
227Export('env')
228
229env.SConsignFile(joinpath(build_root,"sconsign"))
230
231# Default duplicate option is to use hard links, but this messes up
232# when you use emacs to edit a file in the target dir, as emacs moves
233# file to file~ then copies to file, breaking the link. Symbolic
234# (soft) links work better.
235env.SetOption('duplicate', 'soft-copy')
236
237# I waffle on this setting... it does avoid a few painful but
238# unnecessary builds, but it also seems to make trivial builds take
239# noticeably longer.
240if False:
241 env.TargetSignatures('content')
242
223Export('env')
224
225env.SConsignFile(joinpath(build_root,"sconsign"))
226
227# Default duplicate option is to use hard links, but this messes up
228# when you use emacs to edit a file in the target dir, as emacs moves
229# file to file~ then copies to file, breaking the link. Symbolic
230# (soft) links work better.
231env.SetOption('duplicate', 'soft-copy')
232
233# I waffle on this setting... it does avoid a few painful but
234# unnecessary builds, but it also seems to make trivial builds take
235# noticeably longer.
236if False:
237 env.TargetSignatures('content')
238
239#
240# Set up global sticky options... these are common to an entire build
241# tree (not specific to a particular build like ALPHA_SE)
242#
243
244# Option validators & converters for global sticky options
245def PathListMakeAbsolute(val):
246 if not val:
247 return val
248 f = lambda p: os.path.abspath(os.path.expanduser(p))
249 return ':'.join(map(f, val.split(':')))
250
251def PathListAllExist(key, val, env):
252 if not val:
253 return
254 paths = val.split(':')
255 for path in paths:
256 if not isdir(path):
257 raise SCons.Errors.UserError("Path does not exist: '%s'" % path)
258
259global_sticky_opts_file = joinpath(build_root, 'options.global')
260
261global_sticky_opts = Options(global_sticky_opts_file, args=ARGUMENTS)
262
263global_sticky_opts.AddOptions(
264 ('CC', 'C compiler', os.environ.get('CC', env['CC'])),
265 ('CXX', 'C++ compiler', os.environ.get('CXX', env['CXX'])),
266 ('EXTRAS', 'Add Extra directories to the compilation', '',
267 PathListAllExist, PathListMakeAbsolute)
268 )
269
270
271# base help text
272help_text = '''
273Usage: scons [scons options] [build options] [target(s)]
274
275'''
276
277help_text += "Global sticky options:\n" \
278 + global_sticky_opts.GenerateHelpText(env)
279
280# Update env with values from ARGUMENTS & file global_sticky_opts_file
281global_sticky_opts.Update(env)
282
283# Save sticky option settings back to current options file
284global_sticky_opts.Save(global_sticky_opts_file, env)
285
286# Parse EXTRAS option to build list of all directories where we're
287# look for sources etc. This list is exported as base_dir_list.
288base_dir_list = [ROOT]
289if env['EXTRAS']:
290 base_dir_list += env['EXTRAS'].split(':')
291
292Export('base_dir_list')
293
243# M5_PLY is used by isa_parser.py to find the PLY package.
244env.Append(ENV = { 'M5_PLY' : str(Dir('ext/ply')) })
245env['GCC'] = False
246env['SUNCC'] = False
247env['ICC'] = False
248env['GCC'] = subprocess.Popen(env['CXX'] + ' --version', shell=True,
249 stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
250 close_fds=True).communicate()[0].find('GCC') >= 0

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

462Export('sticky_opts')
463
464# Non-sticky options only apply to the current build.
465nonsticky_opts = Options(args=ARGUMENTS)
466Export('nonsticky_opts')
467
468# Walk the tree and execute all SConsopts scripts that wil add to the
469# above options
294# M5_PLY is used by isa_parser.py to find the PLY package.
295env.Append(ENV = { 'M5_PLY' : str(Dir('ext/ply')) })
296env['GCC'] = False
297env['SUNCC'] = False
298env['ICC'] = False
299env['GCC'] = subprocess.Popen(env['CXX'] + ' --version', shell=True,
300 stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
301 close_fds=True).communicate()[0].find('GCC') >= 0

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

513Export('sticky_opts')
514
515# Non-sticky options only apply to the current build.
516nonsticky_opts = Options(args=ARGUMENTS)
517Export('nonsticky_opts')
518
519# Walk the tree and execute all SConsopts scripts that wil add to the
520# above options
470for root, dirs, files in os.walk('.'):
471 if 'SConsopts' in files:
472 SConscript(os.path.join(root, 'SConsopts'))
521for base_dir in base_dir_list:
522 for root, dirs, files in os.walk(base_dir):
523 if 'SConsopts' in files:
524 print "Reading", os.path.join(root, 'SConsopts')
525 SConscript(os.path.join(root, 'SConsopts'))
473
474all_isa_list.sort()
475all_cpu_list.sort()
476default_cpus.sort()
477
526
527all_isa_list.sort()
528all_cpu_list.sort()
529default_cpus.sort()
530
478def PathListMakeAbsolute(val):
479 if not val:
480 return val
481 f = lambda p: os.path.abspath(os.path.expanduser(p))
482 return ':'.join(map(f, val.split(':')))
483
484def PathListAllExist(key, val, env):
485 if not val:
486 return
487 paths = val.split(':')
488 for path in paths:
489 if not isdir(path):
490 raise SCons.Errors.UserError("Path does not exist: '%s'" % path)
491
492sticky_opts.AddOptions(
493 EnumOption('TARGET_ISA', 'Target ISA', 'alpha', all_isa_list),
494 BoolOption('FULL_SYSTEM', 'Full-system support', False),
495 # There's a bug in scons 0.96.1 that causes ListOptions with list
496 # values (more than one value) not to be able to be restored from
497 # a saved option file. If this causes trouble then upgrade to
498 # scons 0.96.90 or later.
499 ListOption('CPU_MODELS', 'CPU models', default_cpus, all_cpu_list),

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

504 'Make floating-point results compatible with SimpleScalar',
505 False),
506 BoolOption('USE_SSE2',
507 'Compile for SSE2 (-msse2) to get IEEE FP on x86 hosts',
508 False),
509 BoolOption('USE_MYSQL', 'Use MySQL for stats output', have_mysql),
510 BoolOption('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv),
511 BoolOption('USE_CHECKER', 'Use checker for detailed CPU models', False),
531sticky_opts.AddOptions(
532 EnumOption('TARGET_ISA', 'Target ISA', 'alpha', all_isa_list),
533 BoolOption('FULL_SYSTEM', 'Full-system support', False),
534 # There's a bug in scons 0.96.1 that causes ListOptions with list
535 # values (more than one value) not to be able to be restored from
536 # a saved option file. If this causes trouble then upgrade to
537 # scons 0.96.90 or later.
538 ListOption('CPU_MODELS', 'CPU models', default_cpus, all_cpu_list),

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

543 'Make floating-point results compatible with SimpleScalar',
544 False),
545 BoolOption('USE_SSE2',
546 'Compile for SSE2 (-msse2) to get IEEE FP on x86 hosts',
547 False),
548 BoolOption('USE_MYSQL', 'Use MySQL for stats output', have_mysql),
549 BoolOption('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv),
550 BoolOption('USE_CHECKER', 'Use checker for detailed CPU models', False),
512 ('CC', 'C compiler', os.environ.get('CC', env['CC'])),
513 ('CXX', 'C++ compiler', os.environ.get('CXX', env['CXX'])),
514 BoolOption('BATCH', 'Use batch pool for build and tests', False),
515 ('BATCH_CMD', 'Batch pool submission command name', 'qdo'),
516 ('PYTHONHOME',
517 'Override the default PYTHONHOME for this system (use with caution)',
518 '%s:%s' % (sys.prefix, sys.exec_prefix)),
551 BoolOption('BATCH', 'Use batch pool for build and tests', False),
552 ('BATCH_CMD', 'Batch pool submission command name', 'qdo'),
553 ('PYTHONHOME',
554 'Override the default PYTHONHOME for this system (use with caution)',
555 '%s:%s' % (sys.prefix, sys.exec_prefix)),
519 ('EXTRAS', 'Add Extra directories to the compilation', '',
520 PathListAllExist, PathListMakeAbsolute)
521 )
522
523nonsticky_opts.AddOptions(
524 BoolOption('update_ref', 'Update test reference outputs', False)
525 )
526
527# These options get exported to #defines in config/*.hh (see src/SConscript).
528env.ExportOptions = ['FULL_SYSTEM', 'ALPHA_TLASER', 'USE_FENV', \

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

602###################################################
603
604concat_builder = Builder(action = Action(['cat $SOURCES > $TARGET',
605 'chmod +x $TARGET']))
606
607env.Append(BUILDERS = { 'Concat' : concat_builder })
608
609
556 )
557
558nonsticky_opts.AddOptions(
559 BoolOption('update_ref', 'Update test reference outputs', False)
560 )
561
562# These options get exported to #defines in config/*.hh (see src/SConscript).
563env.ExportOptions = ['FULL_SYSTEM', 'ALPHA_TLASER', 'USE_FENV', \

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

637###################################################
638
639concat_builder = Builder(action = Action(['cat $SOURCES > $TARGET',
640 'chmod +x $TARGET']))
641
642env.Append(BUILDERS = { 'Concat' : concat_builder })
643
644
610# base help text
611help_text = '''
612Usage: scons [scons options] [build options] [target(s)]
613
614'''
615
616# libelf build is shared across all configs in the build root.
617env.SConscript('ext/libelf/SConscript',
618 build_dir = joinpath(build_root, 'libelf'),
619 exports = 'env')
620
621###################################################
622#
623# This function is used to set up a directory with switching headers

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

707 print "Error: cannot find options file %s or %s" \
708 % (current_opts_file, default_opts_file)
709 Exit(1)
710
711 # Apply current option settings to env
712 sticky_opts.Update(env)
713 nonsticky_opts.Update(env)
714
645# libelf build is shared across all configs in the build root.
646env.SConscript('ext/libelf/SConscript',
647 build_dir = joinpath(build_root, 'libelf'),
648 exports = 'env')
649
650###################################################
651#
652# This function is used to set up a directory with switching headers

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

736 print "Error: cannot find options file %s or %s" \
737 % (current_opts_file, default_opts_file)
738 Exit(1)
739
740 # Apply current option settings to env
741 sticky_opts.Update(env)
742 nonsticky_opts.Update(env)
743
715 help_text += "Sticky options for %s:\n" % build_dir \
744 help_text += "\nSticky options for %s:\n" % build_dir \
716 + sticky_opts.GenerateHelpText(env) \
717 + "\nNon-sticky options for %s:\n" % build_dir \
718 + nonsticky_opts.GenerateHelpText(env)
719
720 # Process option settings.
721
722 if not have_fenv and env['USE_FENV']:
723 print "Warning: <fenv.h> not available; " \

--- 54 unchanged lines hidden ---
745 + sticky_opts.GenerateHelpText(env) \
746 + "\nNon-sticky options for %s:\n" % build_dir \
747 + nonsticky_opts.GenerateHelpText(env)
748
749 # Process option settings.
750
751 if not have_fenv and env['USE_FENV']:
752 print "Warning: <fenv.h> not available; " \

--- 54 unchanged lines hidden ---