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 --- 91 unchanged lines hidden (view full) --- 100 raise ValueError, "element not found" 101 102# Each target must have 'build' in the interior of the path; the 103# directory below this will determine the build parameters. For 104# example, for target 'foo/bar/build/ALPHA_SE/arch/alpha/blah.do' we 105# recognize that ALPHA_SE specifies the configuration because it 106# follow 'build' in the bulid path. 107 |
108# Generate a list of the unique build roots and configs that the 109# collected targets reference. |
110build_paths = [] |
111build_roots = [] |
112for t in abs_targets: 113 path_dirs = t.split('/') 114 try: 115 build_top = rfind(path_dirs, 'build', -2) 116 except: 117 print "Error: no non-leaf 'build' dir found on target path", t 118 Exit(1) |
119 build_root = os.path.join('/',*path_dirs[:build_top+1]) 120 if build_root not in build_roots: 121 build_roots.append(build_root) 122 build_path = os.path.join('/',*path_dirs[:build_top+2]) 123 if build_path not in build_paths: 124 build_paths.append(build_path) |
125 126################################################### 127# 128# Set up the default build environment. This environment is copied 129# and modified according to each selected configuration. 130# 131################################################### 132 --- 112 unchanged lines hidden (view full) --- 245 'STATS_BINNING'] 246 247# Define a handy 'no-op' action 248def no_action(target, source, env): 249 return 0 250 251env.NoAction = Action(no_action, None) 252 |
253################################################### 254# 255# Define a SCons builder for configuration flag headers. 256# 257################################################### 258 259# This function generates a config header file that #defines the 260# option symbol to the current option setting (0 or 1). The source --- 25 unchanged lines hidden (view full) --- 286 val = int(eval(str(env[option]))) 287 # Sources are option name & value (packaged in SCons Value nodes) 288 return ([target], [Value(option), Value(val)]) 289 290config_builder = Builder(emitter = config_emitter, action = config_action) 291 292env.Append(BUILDERS = { 'ConfigFile' : config_builder }) 293 |
294# base help text 295help_text = ''' 296Usage: scons [scons options] [build options] [target(s)] 297 298''' 299 |
300################################################### 301# 302# Define build environments for selected configurations. 303# 304################################################### 305 306# rename base env 307base_env = env 308 |
309# Spme things (just libelf currently) are shared across all configs in 310# a "build root". Need to define how to build these just once for 311# each referenced root. 312build_root_env = {} 313for build_root in build_roots: 314 env = base_env.Copy() 315 env.SConscript('ext/libelf/SConscript', 316 build_dir = os.path.join(build_root, 'libelf'), 317 exports = 'env') 318 build_root_env[build_root] = env |
319 |
320for build_path in build_paths: 321 print "Building in", build_path 322 # build_dir is the tail component of build path, and is used to 323 # determine the build parameters (e.g., 'ALPHA_SE') 324 (build_root, build_dir) = os.path.split(build_path) |
325 # Make a copy of the build-root environment to use for this config. 326 env = build_root_env[build_root].Copy() |
327 328 # Set env options according to the build directory config. 329 sticky_opts.files = [] 330 # Options for $BUILD_ROOT/$BUILD_DIR are stored in 331 # $BUILD_ROOT/options/$BUILD_DIR so you can nuke 332 # $BUILD_ROOT/$BUILD_DIR without losing your options settings. 333 current_opts_file = os.path.join(build_root, 'options', build_dir) 334 if os.path.isfile(current_opts_file): --- 90 unchanged lines hidden --- |