SConstruct (2632:1bb2f91485ea) SConstruct (2634:db0b1133abd5)
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
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 configs that the collected targets
109# reference.
108# Generate a list of the unique build roots and configs that the
109# collected targets reference.
110build_paths = []
110build_paths = []
111build_roots = []
111for t in abs_targets:
112 path_dirs = t.split('/')
113 try:
114 build_top = rfind(path_dirs, 'build', -2)
115 except:
116 print "Error: no non-leaf 'build' dir found on target path", t
117 Exit(1)
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)
118 config_dir = os.path.join('/',*path_dirs[:build_top+2])
119 if config_dir not in build_paths:
120 build_paths.append(config_dir)
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)
121
122###################################################
123#
124# Set up the default build environment. This environment is copied
125# and modified according to each selected configuration.
126#
127###################################################
128

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

241 'STATS_BINNING']
242
243# Define a handy 'no-op' action
244def no_action(target, source, env):
245 return 0
246
247env.NoAction = Action(no_action, None)
248
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
249# libelf build is described in its own SConscript file.
250# SConscript-global is the build in build/libelf shared among all
251# configs.
252env.SConscript('src/libelf/SConscript-global', exports = 'env')
253
254###################################################
255#
256# Define a SCons builder for configuration flag headers.
257#
258###################################################
259
260# This function generates a config header file that #defines the
261# option symbol to the current option setting (0 or 1). The source

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

287 val = int(eval(str(env[option])))
288 # Sources are option name & value (packaged in SCons Value nodes)
289 return ([target], [Value(option), Value(val)])
290
291config_builder = Builder(emitter = config_emitter, action = config_action)
292
293env.Append(BUILDERS = { 'ConfigFile' : config_builder })
294
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
295###################################################
296#
297# Define build environments for selected configurations.
298#
299###################################################
300
301# rename base env
302base_env = env
303
300###################################################
301#
302# Define build environments for selected configurations.
303#
304###################################################
305
306# rename base env
307base_env = env
308
304help_text = '''
305Usage: scons [scons options] [build options] [target(s)]
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
306
319
307'''
308
309for build_path in build_paths:
310 print "Building in", build_path
311 # build_dir is the tail component of build path, and is used to
312 # determine the build parameters (e.g., 'ALPHA_SE')
313 (build_root, build_dir) = os.path.split(build_path)
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)
314 # Make a copy of the default environment to use for this config.
315 env = base_env.Copy()
325 # Make a copy of the build-root environment to use for this config.
326 env = build_root_env[build_root].Copy()
316
317 # Set env options according to the build directory config.
318 sticky_opts.files = []
319 # Options for $BUILD_ROOT/$BUILD_DIR are stored in
320 # $BUILD_ROOT/options/$BUILD_DIR so you can nuke
321 # $BUILD_ROOT/$BUILD_DIR without losing your options settings.
322 current_opts_file = os.path.join(build_root, 'options', build_dir)
323 if os.path.isfile(current_opts_file):

--- 90 unchanged lines hidden ---
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 ---