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 |
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) |
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 |
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) |
338 339help_text += global_sticky_vars.GenerateHelpText(main) |
340help_text += global_nonsticky_vars.GenerateHelpText(main) |
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 |
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 |
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 |
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 |
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. |
829 switch_hdr_action = MakeAction(gen_switch_hdr, 830 " [GENERATE] $STRIP_TARGET", varlist=['ALL_ISA_LIST']) |
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) |
887 888 help_text += "\nSticky variables for %s:\n" % variant_dir \ |
889 + sticky_vars.GenerateHelpText(env) |
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 --- |