SConstruct (7739:f97a5f4d0879) SConstruct (7756:846fb3ffe0dc)
1# -*- mode:python -*-
2
3# Copyright (c) 2009 The Hewlett-Packard Development Company
4# Copyright (c) 2004-2005 The Regents of The University of Michigan
5# All rights reserved.
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions are

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

267 Exit(1)
268 variant_path = joinpath('/',*path_dirs[:build_top+2])
269 if variant_path not in variant_paths:
270 variant_paths.append(variant_path)
271
272# Make sure build_root exists (might not if this is the first build there)
273if not isdir(build_root):
274 mkdir(build_root)
1# -*- mode:python -*-
2
3# Copyright (c) 2009 The Hewlett-Packard Development Company
4# Copyright (c) 2004-2005 The Regents of The University of Michigan
5# All rights reserved.
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions are

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

267 Exit(1)
268 variant_path = joinpath('/',*path_dirs[:build_top+2])
269 if variant_path not in variant_paths:
270 variant_paths.append(variant_path)
271
272# Make sure build_root exists (might not if this is the first build there)
273if not isdir(build_root):
274 mkdir(build_root)
275main['BUILDROOT'] = build_root
275
276Export('main')
277
278main.SConsignFile(joinpath(build_root, "sconsign"))
279
280# Default duplicate option is to use hard links, but this messes up
281# when you use emacs to edit a file in the target dir, as emacs moves
282# file to file~ then copies to file, breaking the link. Symbolic

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

301 paths = val.split(':')
302 for path in paths:
303 if not isdir(path):
304 raise SCons.Errors.UserError("Path does not exist: '%s'" % path)
305
306global_sticky_vars_file = joinpath(build_root, 'variables.global')
307
308global_sticky_vars = Variables(global_sticky_vars_file, args=ARGUMENTS)
276
277Export('main')
278
279main.SConsignFile(joinpath(build_root, "sconsign"))
280
281# Default duplicate option is to use hard links, but this messes up
282# when you use emacs to edit a file in the target dir, as emacs moves
283# file to file~ then copies to file, breaking the link. Symbolic

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

302 paths = val.split(':')
303 for path in paths:
304 if not isdir(path):
305 raise SCons.Errors.UserError("Path does not exist: '%s'" % path)
306
307global_sticky_vars_file = joinpath(build_root, 'variables.global')
308
309global_sticky_vars = Variables(global_sticky_vars_file, args=ARGUMENTS)
310global_nonsticky_vars = Variables(args=ARGUMENTS)
309
310global_sticky_vars.AddVariables(
311 ('CC', 'C compiler', environ.get('CC', main['CC'])),
312 ('CXX', 'C++ compiler', environ.get('CXX', main['CXX'])),
313 ('BATCH', 'Use batch pool for build and tests', False),
314 ('BATCH_CMD', 'Batch pool submission command name', 'qdo'),
315 ('M5_BUILD_CACHE', 'Cache built objects in this directory', False),
316 ('EXTRAS', 'Add Extra directories to the compilation', '',
317 PathListAllExist, PathListMakeAbsolute),
318 )
319
311
312global_sticky_vars.AddVariables(
313 ('CC', 'C compiler', environ.get('CC', main['CC'])),
314 ('CXX', 'C++ compiler', environ.get('CXX', main['CXX'])),
315 ('BATCH', 'Use batch pool for build and tests', False),
316 ('BATCH_CMD', 'Batch pool submission command name', 'qdo'),
317 ('M5_BUILD_CACHE', 'Cache built objects in this directory', False),
318 ('EXTRAS', 'Add Extra directories to the compilation', '',
319 PathListAllExist, PathListMakeAbsolute),
320 )
321
322global_nonsticky_vars.AddVariables(
323 ('VERBOSE', 'Print full tool command lines', False),
324 ('update_ref', 'Update test reference outputs', False)
325 )
326
327
320# base help text
321help_text = '''
322Usage: scons [scons options] [build options] [target(s)]
323
324Global sticky options:
325'''
326
327# Update main environment with values from ARGUMENTS & global_sticky_vars_file
328global_sticky_vars.Update(main)
328# base help text
329help_text = '''
330Usage: scons [scons options] [build options] [target(s)]
331
332Global sticky options:
333'''
334
335# Update main environment with values from ARGUMENTS & global_sticky_vars_file
336global_sticky_vars.Update(main)
337global_nonsticky_vars.Update(main)
329
330help_text += global_sticky_vars.GenerateHelpText(main)
338
339help_text += global_sticky_vars.GenerateHelpText(main)
340help_text += global_nonsticky_vars.GenerateHelpText(main)
331
332# Save sticky variable settings back to current variables file
333global_sticky_vars.Save(global_sticky_vars_file, main)
334
335# Parse EXTRAS variable to build list of all directories where we're
336# look for sources etc. This list is exported as base_dir_list.
337base_dir = main.srcdir.abspath
338if main['EXTRAS']:
339 extras_dir_list = main['EXTRAS'].split(':')
340else:
341 extras_dir_list = []
342
343Export('base_dir')
344Export('extras_dir_list')
345
346# the ext directory should be on the #includes path
347main.Append(CPPPATH=[Dir('ext')])
348
341
342# Save sticky variable settings back to current variables file
343global_sticky_vars.Save(global_sticky_vars_file, main)
344
345# Parse EXTRAS variable to build list of all directories where we're
346# look for sources etc. This list is exported as base_dir_list.
347base_dir = main.srcdir.abspath
348if main['EXTRAS']:
349 extras_dir_list = main['EXTRAS'].split(':')
350else:
351 extras_dir_list = []
352
353Export('base_dir')
354Export('extras_dir_list')
355
356# the ext directory should be on the #includes path
357main.Append(CPPPATH=[Dir('ext')])
358
359def _STRIP(path, env):
360 path = str(path)
361 variant_base = env['BUILDROOT'] + os.path.sep
362 if path.startswith(variant_base):
363 path = path[len(variant_base):]
364 elif path.startswith('build/'):
365 path = path[6:]
366 return path
367
368def _STRIP_SOURCE(target, source, env, for_signature):
369 return _STRIP(source[0], env)
370main['STRIP_SOURCE'] = _STRIP_SOURCE
371
372def _STRIP_TARGET(target, source, env, for_signature):
373 return _STRIP(target[0], env)
374main['STRIP_TARGET'] = _STRIP_TARGET
375
376if main['VERBOSE']:
377 def MakeAction(action, string, *args, **kwargs):
378 return Action(action, *args, **kwargs)
379else:
380 MakeAction = Action
381 main['CCCOMSTR'] = ' [ CC] $STRIP_SOURCE'
382 main['CXXCOMSTR'] = ' [ CXX] $STRIP_SOURCE'
383 main['ASCOMSTR'] = ' [ AS] $STRIP_SOURCE'
384 main['SWIGCOMSTR'] = ' [ SWIG] $STRIP_SOURCE'
385 main['ARCOMSTR'] = ' [ AR] $STRIP_TARGET'
386 main['LINKCOMSTR'] = ' [ LINK] $STRIP_TARGET'
387 main['RANLIBCOMSTR'] = ' [ RANLIB] $STRIP_TARGET'
388 main['M4COMSTR'] = ' [ M4] $STRIP_TARGET'
389 main['SHCCCOMSTR'] = ' [ SHCC] $STRIP_TARGET'
390 main['SHCXXCOMSTR'] = ' [ SHCXX] $STRIP_TARGET'
391Export('MakeAction')
392
349CXX_version = readCommand([main['CXX'],'--version'], exception=False)
350CXX_V = readCommand([main['CXX'],'-V'], exception=False)
351
352main['GCC'] = CXX_version and CXX_version.find('g++') >= 0
353main['SUNCC'] = CXX_V and CXX_V.find('Sun C++') >= 0
354main['ICC'] = CXX_V and CXX_V.find('Intel') >= 0
355if main['GCC'] + main['SUNCC'] + main['ICC'] > 1:
356 print 'Error: How can we have two at the same time?'

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

661# value becomes sticky).
662sticky_vars = Variables(args=ARGUMENTS)
663Export('sticky_vars')
664
665# Sticky variables that should be exported
666export_vars = []
667Export('export_vars')
668
393CXX_version = readCommand([main['CXX'],'--version'], exception=False)
394CXX_V = readCommand([main['CXX'],'-V'], exception=False)
395
396main['GCC'] = CXX_version and CXX_version.find('g++') >= 0
397main['SUNCC'] = CXX_V and CXX_V.find('Sun C++') >= 0
398main['ICC'] = CXX_V and CXX_V.find('Intel') >= 0
399if main['GCC'] + main['SUNCC'] + main['ICC'] > 1:
400 print 'Error: How can we have two at the same time?'

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

705# value becomes sticky).
706sticky_vars = Variables(args=ARGUMENTS)
707Export('sticky_vars')
708
709# Sticky variables that should be exported
710export_vars = []
711Export('export_vars')
712
669# Non-sticky variables only apply to the current build.
670nonsticky_vars = Variables(args=ARGUMENTS)
671Export('nonsticky_vars')
672
673# Walk the tree and execute all SConsopts scripts that wil add to the
674# above variables
675for bdir in [ base_dir ] + extras_dir_list:
676 for root, dirs, files in os.walk(bdir):
677 if 'SConsopts' in files:
678 print "Reading", joinpath(root, 'SConsopts')
679 SConscript(joinpath(root, 'SConsopts'))
680

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

701 False),
702 BoolVariable('USE_MYSQL', 'Use MySQL for stats output', have_mysql),
703 BoolVariable('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv),
704 BoolVariable('USE_CHECKER', 'Use checker for detailed CPU models', False),
705 BoolVariable('CP_ANNOTATE', 'Enable critical path annotation capability', False),
706 BoolVariable('RUBY', 'Build with Ruby', False),
707 )
708
713# Walk the tree and execute all SConsopts scripts that wil add to the
714# above variables
715for bdir in [ base_dir ] + extras_dir_list:
716 for root, dirs, files in os.walk(bdir):
717 if 'SConsopts' in files:
718 print "Reading", joinpath(root, 'SConsopts')
719 SConscript(joinpath(root, 'SConsopts'))
720

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

741 False),
742 BoolVariable('USE_MYSQL', 'Use MySQL for stats output', have_mysql),
743 BoolVariable('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv),
744 BoolVariable('USE_CHECKER', 'Use checker for detailed CPU models', False),
745 BoolVariable('CP_ANNOTATE', 'Enable critical path annotation capability', False),
746 BoolVariable('RUBY', 'Build with Ruby', False),
747 )
748
709nonsticky_vars.AddVariables(
710 BoolVariable('update_ref', 'Update test reference outputs', False)
711 )
712
713# These variables get exported to #defines in config/*.hh (see src/SConscript).
714export_vars += ['FULL_SYSTEM', 'USE_FENV', 'USE_MYSQL',
715 'NO_FAST_ALLOC', 'FAST_ALLOC_DEBUG', 'FAST_ALLOC_STATS',
716 'SS_COMPATIBLE_FP', 'USE_CHECKER', 'TARGET_ISA', 'CP_ANNOTATE']
717
718###################################################
719#
720# Define a SCons builder for configuration flag headers.

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

782 # list of ISAs from env['ALL_ISA_LIST'].
783 def gen_switch_hdr(target, source, env):
784 fname = str(target[0])
785 f = open(fname, 'w')
786 isa = env['TARGET_ISA'].lower()
787 print >>f, '#include "%s/%s/%s"' % (dname, isa, basename(fname))
788 f.close()
789
749# These variables get exported to #defines in config/*.hh (see src/SConscript).
750export_vars += ['FULL_SYSTEM', 'USE_FENV', 'USE_MYSQL',
751 'NO_FAST_ALLOC', 'FAST_ALLOC_DEBUG', 'FAST_ALLOC_STATS',
752 'SS_COMPATIBLE_FP', 'USE_CHECKER', 'TARGET_ISA', 'CP_ANNOTATE']
753
754###################################################
755#
756# Define a SCons builder for configuration flag headers.

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

818 # list of ISAs from env['ALL_ISA_LIST'].
819 def gen_switch_hdr(target, source, env):
820 fname = str(target[0])
821 f = open(fname, 'w')
822 isa = env['TARGET_ISA'].lower()
823 print >>f, '#include "%s/%s/%s"' % (dname, isa, basename(fname))
824 f.close()
825
790 # String to print when generating header
791 def gen_switch_hdr_string(target, source, env):
792 return "Generating switch header " + str(target[0])
793
794 # Build SCons Action object. 'varlist' specifies env vars that this
795 # action depends on; when env['ALL_ISA_LIST'] changes these actions
796 # should get re-executed.
826 # Build SCons Action object. 'varlist' specifies env vars that this
827 # action depends on; when env['ALL_ISA_LIST'] changes these actions
828 # should get re-executed.
797 switch_hdr_action = Action(gen_switch_hdr, gen_switch_hdr_string,
798 varlist=['ALL_ISA_LIST'])
829 switch_hdr_action = MakeAction(gen_switch_hdr,
830 " [GENERATE] $STRIP_TARGET", varlist=['ALL_ISA_LIST'])
799
800 # Instantiate actions for each header
801 for hdr in switch_headers:
802 env.Command(hdr, [], switch_hdr_action)
803Export('make_switching_dir')
804
805###################################################
806#

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

847 % (current_vars_file, default_vars_file)
848 else:
849 print "Error: cannot find variables file %s or %s" \
850 % (current_vars_file, default_vars_file)
851 Exit(1)
852
853 # Apply current variable settings to env
854 sticky_vars.Update(env)
831
832 # Instantiate actions for each header
833 for hdr in switch_headers:
834 env.Command(hdr, [], switch_hdr_action)
835Export('make_switching_dir')
836
837###################################################
838#

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

879 % (current_vars_file, default_vars_file)
880 else:
881 print "Error: cannot find variables file %s or %s" \
882 % (current_vars_file, default_vars_file)
883 Exit(1)
884
885 # Apply current variable settings to env
886 sticky_vars.Update(env)
855 nonsticky_vars.Update(env)
856
857 help_text += "\nSticky variables for %s:\n" % variant_dir \
887
888 help_text += "\nSticky variables for %s:\n" % variant_dir \
858 + sticky_vars.GenerateHelpText(env) \
859 + "\nNon-sticky variables for %s:\n" % variant_dir \
860 + nonsticky_vars.GenerateHelpText(env)
889 + sticky_vars.GenerateHelpText(env)
861
862 # Process variable settings.
863
864 if not have_fenv and env['USE_FENV']:
865 print "Warning: <fenv.h> not available; " \
866 "forcing USE_FENV to False in", variant_dir + "."
867 env['USE_FENV'] = False
868

--- 36 unchanged lines hidden ---
890
891 # Process variable settings.
892
893 if not have_fenv and env['USE_FENV']:
894 print "Warning: <fenv.h> not available; " \
895 "forcing USE_FENV to False in", variant_dir + "."
896 env['USE_FENV'] = False
897

--- 36 unchanged lines hidden ---