Deleted Added
sdiff udiff text old ( 10181:6270235e0585 ) new ( 10196:be0e1724eb39 )
full compact
1# -*- mode:python -*-
2
3# Copyright (c) 2013 ARM Limited
4# All rights reserved.
5#
6# The license below extends only to copyright in the software and shall
7# not be construed as granting a license to any other intellectual
8# property including but not limited to intellectual property relating

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

104'python-config' first.
105
106For more details, see:
107 http://gem5.org/wiki/index.php/Using_a_non-default_Python_installation
108"""
109 raise
110
111# Global Python includes
112import itertools
113import os
114import re
115import subprocess
116import sys
117
118from os import mkdir, environ
119from os.path import abspath, basename, dirname, expanduser, normpath
120from os.path import exists, isdir, isfile

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

1156
1157###################################################
1158#
1159# This function is used to set up a directory with switching headers
1160#
1161###################################################
1162
1163main['ALL_ISA_LIST'] = all_isa_list
1164all_isa_deps = {}
1165def make_switching_dir(dname, switch_headers, env):
1166 # Generate the header. target[0] is the full path of the output
1167 # header to generate. 'source' is a dummy variable, since we get the
1168 # list of ISAs from env['ALL_ISA_LIST'].
1169 def gen_switch_hdr(target, source, env):
1170 fname = str(target[0])
1171 isa = env['TARGET_ISA'].lower()
1172 try:
1173 f = open(fname, 'w')
1174 print >>f, '#include "%s/%s/%s"' % (dname, isa, basename(fname))
1175 f.close()
1176 except IOError:
1177 print "Failed to create %s" % fname
1178 raise
1179
1180 # Build SCons Action object. 'varlist' specifies env vars that this
1181 # action depends on; when env['ALL_ISA_LIST'] changes these actions
1182 # should get re-executed.
1183 switch_hdr_action = MakeAction(gen_switch_hdr,
1184 Transform("GENERATE"), varlist=['ALL_ISA_LIST'])
1185
1186 # Instantiate actions for each header
1187 for hdr in switch_headers:
1188 env.Command(hdr, [], switch_hdr_action)
1189
1190 isa_target = Dir('.').up().name.lower().replace('_', '-')
1191 env['PHONY_BASE'] = '#'+isa_target
1192 all_isa_deps[isa_target] = None
1193
1194Export('make_switching_dir')
1195
1196# all-isas -> all-deps -> all-environs -> all_targets
1197main.Alias('#all-isas', [])
1198main.Alias('#all-deps', '#all-isas')
1199
1200# Dummy target to ensure all environments are created before telling
1201# SCons what to actually make (the command line arguments). We attach
1202# them to the dependence graph after the environments are complete.
1203ORIG_BUILD_TARGETS = list(BUILD_TARGETS) # force a copy; gets closure to work.
1204def environsComplete(target, source, env):
1205 for t in ORIG_BUILD_TARGETS:
1206 main.Depends('#all-targets', t)
1207
1208# Each build/* switching_dir attaches its *-environs target to #all-environs.
1209main.Append(BUILDERS = {'CompleteEnvirons' :
1210 Builder(action=MakeAction(environsComplete, None))})
1211main.CompleteEnvirons('#all-environs', [])
1212
1213def doNothing(**ignored): pass
1214main.Append(BUILDERS = {'Dummy': Builder(action=MakeAction(doNothing, None))})
1215
1216# The final target to which all the original targets ultimately get attached.
1217main.Dummy('#all-targets', '#all-environs')
1218BUILD_TARGETS[:] = ['#all-targets']
1219
1220###################################################
1221#
1222# Define build environments for selected configurations.
1223#
1224###################################################
1225
1226for variant_path in variant_paths:
1227 if not GetOption('silent'):

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

1320 sticky_vars.Save(current_vars_file, env)
1321
1322 if env['USE_SSE2']:
1323 env.Append(CCFLAGS=['-msse2'])
1324
1325 # The src/SConscript file sets up the build rules in 'env' according
1326 # to the configured variables. It returns a list of environments,
1327 # one for each variant build (debug, opt, etc.)
1328 SConscript('src/SConscript', variant_dir = variant_path, exports = 'env')
1329
1330def pairwise(iterable):
1331 "s -> (s0,s1), (s1,s2), (s2, s3), ..."
1332 a, b = itertools.tee(iterable)
1333 b.next()
1334 return itertools.izip(a, b)
1335
1336# Create false dependencies so SCons will parse ISAs, establish
1337# dependencies, and setup the build Environments serially. Either
1338# SCons (likely) and/or our SConscripts (possibly) cannot cope with -j
1339# greater than 1. It appears to be standard race condition stuff; it
1340# doesn't always fail, but usually, and the behaviors are different.
1341# Every time I tried to remove this, builds would fail in some
1342# creative new way. So, don't do that. You'll want to, though, because
1343# tests/SConscript takes a long time to make its Environments.
1344for t1, t2 in pairwise(sorted(all_isa_deps.iterkeys())):
1345 main.Depends('#%s-deps' % t2, '#%s-deps' % t1)
1346 main.Depends('#%s-environs' % t2, '#%s-environs' % t1)
1347
1348# base help text
1349Help('''
1350Usage: scons [scons options] [build variables] [target(s)]
1351
1352Extra scons options:
1353%(options)s
1354
1355Global build variables:
1356%(global_vars)s
1357
1358%(local_vars)s
1359''' % help_texts)