SConscript revision 11308
1955SN/A# -*- mode:python -*- 2955SN/A 31762SN/A# Copyright (c) 2004-2005 The Regents of The University of Michigan 4955SN/A# All rights reserved. 5955SN/A# 6955SN/A# Redistribution and use in source and binary forms, with or without 7955SN/A# modification, are permitted provided that the following conditions are 8955SN/A# met: redistributions of source code must retain the above copyright 9955SN/A# notice, this list of conditions and the following disclaimer; 10955SN/A# redistributions in binary form must reproduce the above copyright 11955SN/A# notice, this list of conditions and the following disclaimer in the 12955SN/A# documentation and/or other materials provided with the distribution; 13955SN/A# neither the name of the copyright holders nor the names of its 14955SN/A# contributors may be used to endorse or promote products derived from 15955SN/A# this software without specific prior written permission. 16955SN/A# 17955SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18955SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19955SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20955SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21955SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22955SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23955SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24955SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25955SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26955SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27955SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 282665Ssaidi@eecs.umich.edu# 294762Snate@binkert.org# Authors: Nathan Binkert 30955SN/A 315522Snate@binkert.orgimport array 326143Snate@binkert.orgimport bisect 334762Snate@binkert.orgimport imp 345522Snate@binkert.orgimport marshal 35955SN/Aimport os 365522Snate@binkert.orgimport re 37955SN/Aimport sys 385522Snate@binkert.orgimport zlib 394202Sbinkertn@umich.edu 405742Snate@binkert.orgfrom os.path import basename, dirname, exists, isdir, isfile, join as joinpath 41955SN/A 424381Sbinkertn@umich.eduimport SCons 434381Sbinkertn@umich.edu 44955SN/A# This file defines how to build a particular configuration of gem5 45955SN/A# based on variable settings in the 'env' build environment. 46955SN/A 474202Sbinkertn@umich.eduImport('*') 48955SN/A 494382Sbinkertn@umich.edu# Children need to see the environment 504382Sbinkertn@umich.eduExport('env') 514382Sbinkertn@umich.edu 526654Snate@binkert.orgbuild_env = [(opt, env[opt]) for opt in export_vars] 535517Snate@binkert.org 547674Snate@binkert.orgfrom m5.util import code_formatter, compareVersions 557674Snate@binkert.org 566143Snate@binkert.org######################################################################## 576143Snate@binkert.org# Code for adding source files of various types 586143Snate@binkert.org# 596143Snate@binkert.org# When specifying a source file of some type, a set of guards can be 606143Snate@binkert.org# specified for that file. When get() is used to find the files, if 616143Snate@binkert.org# get specifies a set of filters, only files that match those filters 626143Snate@binkert.org# will be accepted (unspecified filters on files are assumed to be 636143Snate@binkert.org# false). Current filters are: 646143Snate@binkert.org# main -- specifies the gem5 main() function 656143Snate@binkert.org# skip_lib -- do not put this file into the gem5 library 666143Snate@binkert.org# skip_no_python -- do not put this file into a no_python library 676143Snate@binkert.org# as it embeds compiled Python 686143Snate@binkert.org# <unittest> -- unit tests use filters based on the unit test name 696143Snate@binkert.org# 706143Snate@binkert.org# A parent can now be specified for a source file and default filter 714762Snate@binkert.org# values will be retrieved recursively from parents (children override 726143Snate@binkert.org# parents). 736143Snate@binkert.org# 746143Snate@binkert.orgclass SourceMeta(type): 756143Snate@binkert.org '''Meta class for source files that keeps track of all files of a 766143Snate@binkert.org particular type and has a get function for finding all functions 776143Snate@binkert.org of a certain type that match a set of guards''' 786143Snate@binkert.org def __init__(cls, name, bases, dict): 796143Snate@binkert.org super(SourceMeta, cls).__init__(name, bases, dict) 806143Snate@binkert.org cls.all = [] 816143Snate@binkert.org 826143Snate@binkert.org def get(cls, **guards): 836143Snate@binkert.org '''Find all files that match the specified guards. If a source 846143Snate@binkert.org file does not specify a flag, the default is False''' 856143Snate@binkert.org for src in cls.all: 866143Snate@binkert.org for flag,value in guards.iteritems(): 876143Snate@binkert.org # if the flag is found and has a different value, skip 886143Snate@binkert.org # this file 896143Snate@binkert.org if src.all_guards.get(flag, False) != value: 906143Snate@binkert.org break 916143Snate@binkert.org else: 926143Snate@binkert.org yield src 937065Snate@binkert.org 946143Snate@binkert.orgclass SourceFile(object): 956143Snate@binkert.org '''Base object that encapsulates the notion of a source file. 966143Snate@binkert.org This includes, the source node, target node, various manipulations 976143Snate@binkert.org of those. A source file also specifies a set of guards which 986143Snate@binkert.org describing which builds the source file applies to. A parent can 996143Snate@binkert.org also be specified to get default guards from''' 1006143Snate@binkert.org __metaclass__ = SourceMeta 1016143Snate@binkert.org def __init__(self, source, parent=None, **guards): 1026143Snate@binkert.org self.guards = guards 1036143Snate@binkert.org self.parent = parent 1046143Snate@binkert.org 1056143Snate@binkert.org tnode = source 1066143Snate@binkert.org if not isinstance(source, SCons.Node.FS.File): 1076143Snate@binkert.org tnode = File(source) 1086143Snate@binkert.org 1096143Snate@binkert.org self.tnode = tnode 1106143Snate@binkert.org self.snode = tnode.srcnode() 1116143Snate@binkert.org 1126143Snate@binkert.org for base in type(self).__mro__: 1136143Snate@binkert.org if issubclass(base, SourceFile): 1146143Snate@binkert.org base.all.append(self) 1155522Snate@binkert.org 1166143Snate@binkert.org @property 1176143Snate@binkert.org def filename(self): 1186143Snate@binkert.org return str(self.tnode) 1196143Snate@binkert.org 1206143Snate@binkert.org @property 1216143Snate@binkert.org def dirname(self): 1226143Snate@binkert.org return dirname(self.filename) 1236143Snate@binkert.org 1246143Snate@binkert.org @property 1256143Snate@binkert.org def basename(self): 1265522Snate@binkert.org return basename(self.filename) 1275522Snate@binkert.org 1285522Snate@binkert.org @property 1295522Snate@binkert.org def extname(self): 1305604Snate@binkert.org index = self.basename.rfind('.') 1315604Snate@binkert.org if index <= 0: 1326143Snate@binkert.org # dot files aren't extensions 1336143Snate@binkert.org return self.basename, None 1344762Snate@binkert.org 1354762Snate@binkert.org return self.basename[:index], self.basename[index+1:] 1366143Snate@binkert.org 1376727Ssteve.reinhardt@amd.com @property 1386727Ssteve.reinhardt@amd.com def all_guards(self): 1396727Ssteve.reinhardt@amd.com '''find all guards for this object getting default values 1404762Snate@binkert.org recursively from its parents''' 1416143Snate@binkert.org guards = {} 1426143Snate@binkert.org if self.parent: 1436143Snate@binkert.org guards.update(self.parent.guards) 1446143Snate@binkert.org guards.update(self.guards) 1456727Ssteve.reinhardt@amd.com return guards 1466143Snate@binkert.org 1477674Snate@binkert.org def __lt__(self, other): return self.filename < other.filename 1487674Snate@binkert.org def __le__(self, other): return self.filename <= other.filename 1495604Snate@binkert.org def __gt__(self, other): return self.filename > other.filename 1506143Snate@binkert.org def __ge__(self, other): return self.filename >= other.filename 1516143Snate@binkert.org def __eq__(self, other): return self.filename == other.filename 1526143Snate@binkert.org def __ne__(self, other): return self.filename != other.filename 1534762Snate@binkert.org 1546143Snate@binkert.org @staticmethod 1554762Snate@binkert.org def done(): 1564762Snate@binkert.org def disabled(cls, name, *ignored): 1574762Snate@binkert.org raise RuntimeError("Additional SourceFile '%s'" % name,\ 1586143Snate@binkert.org "declared, but targets deps are already fixed.") 1596143Snate@binkert.org SourceFile.__init__ = disabled 1604762Snate@binkert.org 1616143Snate@binkert.org 1626143Snate@binkert.orgclass Source(SourceFile): 1636143Snate@binkert.org '''Add a c/c++ source file to the build''' 1646143Snate@binkert.org def __init__(self, source, Werror=True, swig=False, **guards): 1654762Snate@binkert.org '''specify the source file, and any guards''' 1666143Snate@binkert.org super(Source, self).__init__(source, **guards) 1674762Snate@binkert.org 1686143Snate@binkert.org self.Werror = Werror 1694762Snate@binkert.org self.swig = swig 1706143Snate@binkert.org 1716143Snate@binkert.orgclass PySource(SourceFile): 1726143Snate@binkert.org '''Add a python source file to the named package''' 1736143Snate@binkert.org invalid_sym_char = re.compile('[^A-z0-9_]') 1746143Snate@binkert.org modules = {} 1756143Snate@binkert.org tnodes = {} 1766143Snate@binkert.org symnames = {} 1776143Snate@binkert.org 1786143Snate@binkert.org def __init__(self, package, source, **guards): 1796143Snate@binkert.org '''specify the python package, the source file, and any guards''' 1806143Snate@binkert.org super(PySource, self).__init__(source, **guards) 1816143Snate@binkert.org 1826143Snate@binkert.org modname,ext = self.extname 183955SN/A assert ext == 'py' 1845584Snate@binkert.org 1855584Snate@binkert.org if package: 1865584Snate@binkert.org path = package.split('.') 1875584Snate@binkert.org else: 1886143Snate@binkert.org path = [] 1896143Snate@binkert.org 1906143Snate@binkert.org modpath = path[:] 1915584Snate@binkert.org if modname != '__init__': 1924382Sbinkertn@umich.edu modpath += [ modname ] 1934202Sbinkertn@umich.edu modpath = '.'.join(modpath) 1944382Sbinkertn@umich.edu 1954382Sbinkertn@umich.edu arcpath = path + [ self.basename ] 1964382Sbinkertn@umich.edu abspath = self.snode.abspath 1975584Snate@binkert.org if not exists(abspath): 1984382Sbinkertn@umich.edu abspath = self.tnode.abspath 1994382Sbinkertn@umich.edu 2004382Sbinkertn@umich.edu self.package = package 2015192Ssaidi@eecs.umich.edu self.modname = modname 2025192Ssaidi@eecs.umich.edu self.modpath = modpath 2035799Snate@binkert.org self.arcname = joinpath(*arcpath) 2045799Snate@binkert.org self.abspath = abspath 2055799Snate@binkert.org self.compiled = File(self.filename + 'c') 2065192Ssaidi@eecs.umich.edu self.cpp = File(self.filename + '.cc') 2075799Snate@binkert.org self.symname = PySource.invalid_sym_char.sub('_', modpath) 2085192Ssaidi@eecs.umich.edu 2095799Snate@binkert.org PySource.modules[modpath] = self 2105799Snate@binkert.org PySource.tnodes[self.tnode] = self 2115192Ssaidi@eecs.umich.edu PySource.symnames[self.symname] = self 2125192Ssaidi@eecs.umich.edu 2135192Ssaidi@eecs.umich.educlass SimObject(PySource): 2145799Snate@binkert.org '''Add a SimObject python file as a python source object and add 2155192Ssaidi@eecs.umich.edu it to a list of sim object modules''' 2165192Ssaidi@eecs.umich.edu 2175192Ssaidi@eecs.umich.edu fixed = False 2185192Ssaidi@eecs.umich.edu modnames = [] 2195192Ssaidi@eecs.umich.edu 2205192Ssaidi@eecs.umich.edu def __init__(self, source, **guards): 2214382Sbinkertn@umich.edu '''Specify the source file and any guards (automatically in 2224382Sbinkertn@umich.edu the m5.objects package)''' 2234382Sbinkertn@umich.edu super(SimObject, self).__init__('m5.objects', source, **guards) 2242667Sstever@eecs.umich.edu if self.fixed: 2252667Sstever@eecs.umich.edu raise AttributeError, "Too late to call SimObject now." 2262667Sstever@eecs.umich.edu 2272667Sstever@eecs.umich.edu bisect.insort_right(SimObject.modnames, self.modname) 2282667Sstever@eecs.umich.edu 2292667Sstever@eecs.umich.educlass SwigSource(SourceFile): 2305742Snate@binkert.org '''Add a swig file to build''' 2315742Snate@binkert.org 2325742Snate@binkert.org def __init__(self, package, source, **guards): 2335793Snate@binkert.org '''Specify the python package, the source file, and any guards''' 2345793Snate@binkert.org super(SwigSource, self).__init__(source, skip_no_python=True, **guards) 2355793Snate@binkert.org 2365793Snate@binkert.org modname,ext = self.extname 2375793Snate@binkert.org assert ext == 'i' 2384382Sbinkertn@umich.edu 2394762Snate@binkert.org self.module = modname 2405344Sstever@gmail.com cc_file = joinpath(self.dirname, modname + '_wrap.cc') 2414382Sbinkertn@umich.edu py_file = joinpath(self.dirname, modname + '.py') 2425341Sstever@gmail.com 2435742Snate@binkert.org self.cc_source = Source(cc_file, swig=True, parent=self, **guards) 2445742Snate@binkert.org self.py_source = PySource(package, py_file, parent=self, **guards) 2455742Snate@binkert.org 2465742Snate@binkert.orgclass ProtoBuf(SourceFile): 2475742Snate@binkert.org '''Add a Protocol Buffer to build''' 2484762Snate@binkert.org 2495742Snate@binkert.org def __init__(self, source, **guards): 2505742Snate@binkert.org '''Specify the source file, and any guards''' 2517722Sgblack@eecs.umich.edu super(ProtoBuf, self).__init__(source, **guards) 2525742Snate@binkert.org 2535742Snate@binkert.org # Get the file name and the extension 2545742Snate@binkert.org modname,ext = self.extname 2555742Snate@binkert.org assert ext == 'proto' 2565341Sstever@gmail.com 2575742Snate@binkert.org # Currently, we stick to generating the C++ headers, so we 2587722Sgblack@eecs.umich.edu # only need to track the source and header. 2594773Snate@binkert.org self.cc_file = File(modname + '.pb.cc') 2606108Snate@binkert.org self.hh_file = File(modname + '.pb.h') 2611858SN/A 2621085SN/Aclass UnitTest(object): 2636658Snate@binkert.org '''Create a UnitTest''' 2646658Snate@binkert.org 2657673Snate@binkert.org all = [] 2666658Snate@binkert.org def __init__(self, target, *sources, **kwargs): 2676658Snate@binkert.org '''Specify the target name and any sources. Sources that are 2686658Snate@binkert.org not SourceFiles are evalued with Source(). All files are 2696658Snate@binkert.org guarded with a guard of the same name as the UnitTest 2706658Snate@binkert.org target.''' 2716658Snate@binkert.org 2726658Snate@binkert.org srcs = [] 2737673Snate@binkert.org for src in sources: 2747673Snate@binkert.org if not isinstance(src, SourceFile): 2757673Snate@binkert.org src = Source(src, skip_lib=True) 2767673Snate@binkert.org src.guards[target] = True 2777673Snate@binkert.org srcs.append(src) 2787673Snate@binkert.org 2797673Snate@binkert.org self.sources = srcs 2806658Snate@binkert.org self.target = target 2817673Snate@binkert.org self.main = kwargs.get('main', False) 2827673Snate@binkert.org UnitTest.all.append(self) 2837673Snate@binkert.org 2847673Snate@binkert.org# Children should have access 2857673Snate@binkert.orgExport('Source') 2867673Snate@binkert.orgExport('PySource') 2877673Snate@binkert.orgExport('SimObject') 2887673Snate@binkert.orgExport('SwigSource') 2897673Snate@binkert.orgExport('ProtoBuf') 2907673Snate@binkert.orgExport('UnitTest') 2916658Snate@binkert.org 2927756SAli.Saidi@ARM.com######################################################################## 2937756SAli.Saidi@ARM.com# 2946658Snate@binkert.org# Debug Flags 2954382Sbinkertn@umich.edu# 2964382Sbinkertn@umich.edudebug_flags = {} 2974762Snate@binkert.orgdef DebugFlag(name, desc=None): 2984762Snate@binkert.org if name in debug_flags: 2994762Snate@binkert.org raise AttributeError, "Flag %s already specified" % name 3006654Snate@binkert.org debug_flags[name] = (name, (), desc) 3016654Snate@binkert.org 3025517Snate@binkert.orgdef CompoundFlag(name, flags, desc=None): 3035517Snate@binkert.org if name in debug_flags: 3045517Snate@binkert.org raise AttributeError, "Flag %s already specified" % name 3055517Snate@binkert.org 3065517Snate@binkert.org compound = tuple(flags) 3075517Snate@binkert.org debug_flags[name] = (name, compound, desc) 3085517Snate@binkert.org 3095517Snate@binkert.orgExport('DebugFlag') 3105517Snate@binkert.orgExport('CompoundFlag') 3115517Snate@binkert.org 3125517Snate@binkert.org######################################################################## 3135517Snate@binkert.org# 3145517Snate@binkert.org# Set some compiler variables 3155517Snate@binkert.org# 3165517Snate@binkert.org 3175517Snate@binkert.org# Include file paths are rooted in this directory. SCons will 3185517Snate@binkert.org# automatically expand '.' to refer to both the source directory and 3196654Snate@binkert.org# the corresponding build directory to pick up generated include 3205517Snate@binkert.org# files. 3215517Snate@binkert.orgenv.Append(CPPPATH=Dir('.')) 3225517Snate@binkert.org 3235517Snate@binkert.orgfor extra_dir in extras_dir_list: 3245517Snate@binkert.org env.Append(CPPPATH=Dir(extra_dir)) 3255517Snate@binkert.org 3265517Snate@binkert.org# Workaround for bug in SCons version > 0.97d20071212 3275517Snate@binkert.org# Scons bug id: 2006 gem5 Bug id: 308 3286143Snate@binkert.orgfor root, dirs, files in os.walk(base_dir, topdown=True): 3296654Snate@binkert.org Dir(root[len(base_dir) + 1:]) 3305517Snate@binkert.org 3315517Snate@binkert.org######################################################################## 3325517Snate@binkert.org# 3335517Snate@binkert.org# Walk the tree and execute all SConscripts in subdirectories 3345517Snate@binkert.org# 3355517Snate@binkert.org 3365517Snate@binkert.orghere = Dir('.').srcnode().abspath 3375517Snate@binkert.orgfor root, dirs, files in os.walk(base_dir, topdown=True): 3385517Snate@binkert.org if root == here: 3395517Snate@binkert.org # we don't want to recurse back into this SConscript 3405517Snate@binkert.org continue 3415517Snate@binkert.org 3425517Snate@binkert.org if 'SConscript' in files: 3435517Snate@binkert.org build_dir = joinpath(env['BUILDDIR'], root[len(base_dir) + 1:]) 3446654Snate@binkert.org SConscript(joinpath(root, 'SConscript'), variant_dir=build_dir) 3456654Snate@binkert.org 3465517Snate@binkert.orgfor extra_dir in extras_dir_list: 3475517Snate@binkert.org prefix_len = len(dirname(extra_dir)) + 1 3486143Snate@binkert.org 3496143Snate@binkert.org # Also add the corresponding build directory to pick up generated 3506143Snate@binkert.org # include files. 3516727Ssteve.reinhardt@amd.com env.Append(CPPPATH=Dir(joinpath(env['BUILDDIR'], extra_dir[prefix_len:]))) 3525517Snate@binkert.org 3536727Ssteve.reinhardt@amd.com for root, dirs, files in os.walk(extra_dir, topdown=True): 3545517Snate@binkert.org # if build lives in the extras directory, don't walk down it 3555517Snate@binkert.org if 'build' in dirs: 3565517Snate@binkert.org dirs.remove('build') 3576654Snate@binkert.org 3586654Snate@binkert.org if 'SConscript' in files: 3597673Snate@binkert.org build_dir = joinpath(env['BUILDDIR'], root[prefix_len:]) 3606654Snate@binkert.org SConscript(joinpath(root, 'SConscript'), variant_dir=build_dir) 3616654Snate@binkert.org 3626654Snate@binkert.orgfor opt in export_vars: 3636654Snate@binkert.org env.ConfigFile(opt) 3645517Snate@binkert.org 3655517Snate@binkert.orgdef makeTheISA(source, target, env): 3665517Snate@binkert.org isas = [ src.get_contents() for src in source ] 3676143Snate@binkert.org target_isa = env['TARGET_ISA'] 3685517Snate@binkert.org def define(isa): 3694762Snate@binkert.org return isa.upper() + '_ISA' 3705517Snate@binkert.org 3715517Snate@binkert.org def namespace(isa): 3726143Snate@binkert.org return isa[0].upper() + isa[1:].lower() + 'ISA' 3736143Snate@binkert.org 3745517Snate@binkert.org 3755517Snate@binkert.org code = code_formatter() 3765517Snate@binkert.org code('''\ 3775517Snate@binkert.org#ifndef __CONFIG_THE_ISA_HH__ 3785517Snate@binkert.org#define __CONFIG_THE_ISA_HH__ 3795517Snate@binkert.org 3805517Snate@binkert.org''') 3815517Snate@binkert.org 3825517Snate@binkert.org # create defines for the preprocessing and compile-time determination 3835517Snate@binkert.org for i,isa in enumerate(isas): 3846143Snate@binkert.org code('#define $0 $1', define(isa), i + 1) 3855517Snate@binkert.org code() 3866654Snate@binkert.org 3876654Snate@binkert.org # create an enum for any run-time determination of the ISA, we 3886654Snate@binkert.org # reuse the same name as the namespaces 3896654Snate@binkert.org code('enum class Arch {') 3906654Snate@binkert.org for i,isa in enumerate(isas): 3916654Snate@binkert.org if i + 1 == len(isas): 3925517Snate@binkert.org code(' $0 = $1', namespace(isa), define(isa)) 3935517Snate@binkert.org else: 3945517Snate@binkert.org code(' $0 = $1,', namespace(isa), define(isa)) 3955517Snate@binkert.org code('};') 3965517Snate@binkert.org 3974762Snate@binkert.org code(''' 3984762Snate@binkert.org 3994762Snate@binkert.org#define THE_ISA ${{define(target_isa)}} 4004762Snate@binkert.org#define TheISA ${{namespace(target_isa)}} 4014762Snate@binkert.org#define THE_ISA_STR "${{target_isa}}" 4024762Snate@binkert.org 4037675Snate@binkert.org#endif // __CONFIG_THE_ISA_HH__''') 4044762Snate@binkert.org 4054762Snate@binkert.org code.write(str(target[0])) 4064762Snate@binkert.org 4074762Snate@binkert.orgenv.Command('config/the_isa.hh', map(Value, all_isa_list), 4084382Sbinkertn@umich.edu MakeAction(makeTheISA, Transform("CFG ISA", 0))) 4094382Sbinkertn@umich.edu 4105517Snate@binkert.orgdef makeTheGPUISA(source, target, env): 4116654Snate@binkert.org isas = [ src.get_contents() for src in source ] 4125517Snate@binkert.org target_gpu_isa = env['TARGET_GPU_ISA'] 4135798Snate@binkert.org def define(isa): 4146654Snate@binkert.org return isa.upper() + '_ISA' 4157673Snate@binkert.org 4166654Snate@binkert.org def namespace(isa): 4176654Snate@binkert.org return isa[0].upper() + isa[1:].lower() + 'ISA' 4186654Snate@binkert.org 4196654Snate@binkert.org 4206654Snate@binkert.org code = code_formatter() 4216654Snate@binkert.org code('''\ 4226654Snate@binkert.org#ifndef __CONFIG_THE_GPU_ISA_HH__ 4236654Snate@binkert.org#define __CONFIG_THE_GPU_ISA_HH__ 4246669Snate@binkert.org 4256669Snate@binkert.org''') 4266669Snate@binkert.org 4276669Snate@binkert.org # create defines for the preprocessing and compile-time determination 4286669Snate@binkert.org for i,isa in enumerate(isas): 4296669Snate@binkert.org code('#define $0 $1', define(isa), i + 1) 4306654Snate@binkert.org code() 4317673Snate@binkert.org 4325517Snate@binkert.org # create an enum for any run-time determination of the ISA, we 4335863Snate@binkert.org # reuse the same name as the namespaces 4345798Snate@binkert.org code('enum class GPUArch {') 4357756SAli.Saidi@ARM.com for i,isa in enumerate(isas): 4367756SAli.Saidi@ARM.com if i + 1 == len(isas): 4375798Snate@binkert.org code(' $0 = $1', namespace(isa), define(isa)) 4385798Snate@binkert.org else: 4395517Snate@binkert.org code(' $0 = $1,', namespace(isa), define(isa)) 4405517Snate@binkert.org code('};') 4417673Snate@binkert.org 4425517Snate@binkert.org code(''' 4435517Snate@binkert.org 4447673Snate@binkert.org#define THE_GPU_ISA ${{define(target_gpu_isa)}} 4457673Snate@binkert.org#define TheGpuISA ${{namespace(target_gpu_isa)}} 4465517Snate@binkert.org#define THE_GPU_ISA_STR "${{target_gpu_isa}}" 4475798Snate@binkert.org 4485798Snate@binkert.org#endif // __CONFIG_THE_GPU_ISA_HH__''') 4495798Snate@binkert.org 4507756SAli.Saidi@ARM.com code.write(str(target[0])) 4515798Snate@binkert.org 4525798Snate@binkert.orgenv.Command('config/the_gpu_isa.hh', map(Value, all_gpu_isa_list), 4534762Snate@binkert.org MakeAction(makeTheGPUISA, Transform("CFG ISA", 0))) 4544762Snate@binkert.org 4554762Snate@binkert.org######################################################################## 4564762Snate@binkert.org# 4574762Snate@binkert.org# Prevent any SimObjects from being added after this point, they 4585517Snate@binkert.org# should all have been added in the SConscripts above 4595517Snate@binkert.org# 4605517Snate@binkert.orgSimObject.fixed = True 4615517Snate@binkert.org 4625517Snate@binkert.orgclass DictImporter(object): 4635517Snate@binkert.org '''This importer takes a dictionary of arbitrary module names that 4647673Snate@binkert.org map to arbitrary filenames.''' 4657673Snate@binkert.org def __init__(self, modules): 4667673Snate@binkert.org self.modules = modules 4675517Snate@binkert.org self.installed = set() 4685517Snate@binkert.org 4695517Snate@binkert.org def __del__(self): 4705517Snate@binkert.org self.unload() 4715517Snate@binkert.org 4725517Snate@binkert.org def unload(self): 4735517Snate@binkert.org import sys 4747673Snate@binkert.org for module in self.installed: 4757677Snate@binkert.org del sys.modules[module] 4767673Snate@binkert.org self.installed = set() 4777673Snate@binkert.org 4785517Snate@binkert.org def find_module(self, fullname, path): 4795517Snate@binkert.org if fullname == 'm5.defines': 4805517Snate@binkert.org return self 4815517Snate@binkert.org 4825517Snate@binkert.org if fullname == 'm5.objects': 4835517Snate@binkert.org return self 4845517Snate@binkert.org 4857673Snate@binkert.org if fullname.startswith('m5.internal'): 4867673Snate@binkert.org return None 4877673Snate@binkert.org 4885517Snate@binkert.org source = self.modules.get(fullname, None) 4895517Snate@binkert.org if source is not None and fullname.startswith('m5.objects'): 4905517Snate@binkert.org return self 4915517Snate@binkert.org 4925517Snate@binkert.org return None 4935517Snate@binkert.org 4945517Snate@binkert.org def load_module(self, fullname): 4957673Snate@binkert.org mod = imp.new_module(fullname) 4967673Snate@binkert.org sys.modules[fullname] = mod 4977673Snate@binkert.org self.installed.add(fullname) 4985517Snate@binkert.org 4997675Snate@binkert.org mod.__loader__ = self 5007675Snate@binkert.org if fullname == 'm5.objects': 5017675Snate@binkert.org mod.__path__ = fullname.split('.') 5027675Snate@binkert.org return mod 5037675Snate@binkert.org 5047675Snate@binkert.org if fullname == 'm5.defines': 5057675Snate@binkert.org mod.__dict__['buildEnv'] = m5.util.SmartDict(build_env) 5067675Snate@binkert.org return mod 5077677Snate@binkert.org 5087675Snate@binkert.org source = self.modules[fullname] 5097675Snate@binkert.org if source.modname == '__init__': 5107675Snate@binkert.org mod.__path__ = source.modpath 5117675Snate@binkert.org mod.__file__ = source.abspath 5127675Snate@binkert.org 5137675Snate@binkert.org exec file(source.abspath, 'r') in mod.__dict__ 5147675Snate@binkert.org 5157675Snate@binkert.org return mod 5167675Snate@binkert.org 5174762Snate@binkert.orgimport m5.SimObject 5184762Snate@binkert.orgimport m5.params 5196143Snate@binkert.orgfrom m5.util import code_formatter 5206143Snate@binkert.org 5216143Snate@binkert.orgm5.SimObject.clear() 5224762Snate@binkert.orgm5.params.clear() 5234762Snate@binkert.org 5244762Snate@binkert.org# install the python importer so we can grab stuff from the source 5257756SAli.Saidi@ARM.com# tree itself. We can't have SimObjects added after this point or 5267756SAli.Saidi@ARM.com# else we won't know about them for the rest of the stuff. 5274762Snate@binkert.orgimporter = DictImporter(PySource.modules) 5284762Snate@binkert.orgsys.meta_path[0:0] = [ importer ] 5294762Snate@binkert.org 5305463Snate@binkert.org# import all sim objects so we can populate the all_objects list 5315517Snate@binkert.org# make sure that we're working with a list, then let's sort it 5327677Snate@binkert.orgfor modname in SimObject.modnames: 5335463Snate@binkert.org exec('from m5.objects import %s' % modname) 5347756SAli.Saidi@ARM.com 5357756SAli.Saidi@ARM.com# we need to unload all of the currently imported modules so that they 5364762Snate@binkert.org# will be re-imported the next time the sconscript is run 5377677Snate@binkert.orgimporter.unload() 5384762Snate@binkert.orgsys.meta_path.remove(importer) 5394762Snate@binkert.org 5406143Snate@binkert.orgsim_objects = m5.SimObject.allClasses 5416143Snate@binkert.orgall_enums = m5.params.allEnums 5426143Snate@binkert.org 5434762Snate@binkert.orgif m5.SimObject.noCxxHeader: 5444762Snate@binkert.org print >> sys.stderr, \ 5457756SAli.Saidi@ARM.com "warning: At least one SimObject lacks a header specification. " \ 5467756SAli.Saidi@ARM.com "This can cause unexpected results in the generated SWIG " \ 5474762Snate@binkert.org "wrappers." 5484762Snate@binkert.org 5494762Snate@binkert.org# Find param types that need to be explicitly wrapped with swig. 5504762Snate@binkert.org# These will be recognized because the ParamDesc will have a 5517756SAli.Saidi@ARM.com# swig_decl() method. Most param types are based on types that don't 5527756SAli.Saidi@ARM.com# need this, either because they're based on native types (like Int) 5534762Snate@binkert.org# or because they're SimObjects (which get swigged independently). 5544762Snate@binkert.org# For now the only things handled here are VectorParam types. 5557677Snate@binkert.orgparams_to_swig = {} 5567756SAli.Saidi@ARM.comfor name,obj in sorted(sim_objects.iteritems()): 5577756SAli.Saidi@ARM.com for param in obj._params.local.values(): 5587675Snate@binkert.org # load the ptype attribute now because it depends on the 5597677Snate@binkert.org # current version of SimObject.allClasses, but when scons 5605517Snate@binkert.org # actually uses the value, all versions of 5617675Snate@binkert.org # SimObject.allClasses will have been loaded 5627675Snate@binkert.org param.ptype 5637675Snate@binkert.org 5647675Snate@binkert.org if not hasattr(param, 'swig_decl'): 5657675Snate@binkert.org continue 5667675Snate@binkert.org pname = param.ptype_str 5677675Snate@binkert.org if pname not in params_to_swig: 5685517Snate@binkert.org params_to_swig[pname] = param 5697673Snate@binkert.org 5705517Snate@binkert.org######################################################################## 5717677Snate@binkert.org# 5727675Snate@binkert.org# calculate extra dependencies 5737673Snate@binkert.org# 5747675Snate@binkert.orgmodule_depends = ["m5", "m5.SimObject", "m5.params"] 5757675Snate@binkert.orgdepends = [ PySource.modules[dep].snode for dep in module_depends ] 5767675Snate@binkert.orgdepends.sort(key = lambda x: x.name) 5777673Snate@binkert.org 5787675Snate@binkert.org######################################################################## 5795517Snate@binkert.org# 5807675Snate@binkert.org# Commands for the basic automatically generated python files 5817675Snate@binkert.org# 5827673Snate@binkert.org 5837675Snate@binkert.org# Generate Python file containing a dict specifying the current 5847675Snate@binkert.org# buildEnv flags. 5857677Snate@binkert.orgdef makeDefinesPyFile(target, source, env): 5867675Snate@binkert.org build_env = source[0].get_contents() 5877675Snate@binkert.org 5887675Snate@binkert.org code = code_formatter() 5895517Snate@binkert.org code(""" 5907675Snate@binkert.orgimport m5.internal 5915517Snate@binkert.orgimport m5.util 5927673Snate@binkert.org 5935517Snate@binkert.orgbuildEnv = m5.util.SmartDict($build_env) 5947675Snate@binkert.org 5957677Snate@binkert.orgcompileDate = m5.internal.core.compileDate 5967756SAli.Saidi@ARM.com_globals = globals() 5977756SAli.Saidi@ARM.comfor key,val in m5.internal.core.__dict__.iteritems(): 5987675Snate@binkert.org if key.startswith('flag_'): 5997677Snate@binkert.org flag = key[5:] 6004762Snate@binkert.org _globals[flag] = val 6017674Snate@binkert.orgdel _globals 6027674Snate@binkert.org""") 6037674Snate@binkert.org code.write(target[0].abspath) 6047674Snate@binkert.org 6057674Snate@binkert.orgdefines_info = Value(build_env) 6067674Snate@binkert.org# Generate a file with all of the compile options in it 6077674Snate@binkert.orgenv.Command('python/m5/defines.py', defines_info, 6087674Snate@binkert.org MakeAction(makeDefinesPyFile, Transform("DEFINES", 0))) 6097674Snate@binkert.orgPySource('m5', 'python/m5/defines.py') 6107674Snate@binkert.org 6117674Snate@binkert.org# Generate python file containing info about the M5 source code 6127674Snate@binkert.orgdef makeInfoPyFile(target, source, env): 6137674Snate@binkert.org code = code_formatter() 6147674Snate@binkert.org for src in source: 6157674Snate@binkert.org data = ''.join(file(src.srcnode().abspath, 'r').xreadlines()) 6164762Snate@binkert.org code('$src = ${{repr(data)}}') 6176143Snate@binkert.org code.write(str(target[0])) 6186143Snate@binkert.org 6197756SAli.Saidi@ARM.com# Generate a file that wraps the basic top level files 6207756SAli.Saidi@ARM.comenv.Command('python/m5/info.py', 6217674Snate@binkert.org [ '#/COPYING', '#/LICENSE', '#/README', ], 6227756SAli.Saidi@ARM.com MakeAction(makeInfoPyFile, Transform("INFO"))) 6237756SAli.Saidi@ARM.comPySource('m5', 'python/m5/info.py') 6247674Snate@binkert.org 6256143Snate@binkert.org######################################################################## 6266143Snate@binkert.org# 6274382Sbinkertn@umich.edu# Create all of the SimObject param headers and enum headers 6286229Snate@binkert.org# 6296229Snate@binkert.org 6306229Snate@binkert.orgdef createSimObjectParamStruct(target, source, env): 6316229Snate@binkert.org assert len(target) == 1 and len(source) == 1 6326229Snate@binkert.org 6336229Snate@binkert.org name = str(source[0].get_contents()) 6346229Snate@binkert.org obj = sim_objects[name] 6356229Snate@binkert.org 6366229Snate@binkert.org code = code_formatter() 6376229Snate@binkert.org obj.cxx_param_decl(code) 6386229Snate@binkert.org code.write(target[0].abspath) 6396229Snate@binkert.org 6406229Snate@binkert.orgdef createSimObjectCxxConfig(is_header): 6416229Snate@binkert.org def body(target, source, env): 6426229Snate@binkert.org assert len(target) == 1 and len(source) == 1 6436229Snate@binkert.org 6446229Snate@binkert.org name = str(source[0].get_contents()) 6456229Snate@binkert.org obj = sim_objects[name] 6466229Snate@binkert.org 6476229Snate@binkert.org code = code_formatter() 6486229Snate@binkert.org obj.cxx_config_param_file(code, is_header) 6495192Ssaidi@eecs.umich.edu code.write(target[0].abspath) 6505517Snate@binkert.org return body 6515517Snate@binkert.org 6527673Snate@binkert.orgdef createParamSwigWrapper(target, source, env): 6535517Snate@binkert.org assert len(target) == 1 and len(source) == 1 6546229Snate@binkert.org 6555799Snate@binkert.org name = str(source[0].get_contents()) 6567673Snate@binkert.org param = params_to_swig[name] 6577673Snate@binkert.org 6585517Snate@binkert.org code = code_formatter() 6595517Snate@binkert.org param.swig_decl(code) 6607673Snate@binkert.org code.write(target[0].abspath) 6617673Snate@binkert.org 6627673Snate@binkert.orgdef createEnumStrings(target, source, env): 6637673Snate@binkert.org assert len(target) == 1 and len(source) == 1 6645517Snate@binkert.org 6657673Snate@binkert.org name = str(source[0].get_contents()) 6667673Snate@binkert.org obj = all_enums[name] 6677673Snate@binkert.org 6685517Snate@binkert.org code = code_formatter() 6695517Snate@binkert.org obj.cxx_def(code) 6707673Snate@binkert.org code.write(target[0].abspath) 6717673Snate@binkert.org 6727673Snate@binkert.orgdef createEnumDecls(target, source, env): 6737673Snate@binkert.org assert len(target) == 1 and len(source) == 1 6745517Snate@binkert.org 6757673Snate@binkert.org name = str(source[0].get_contents()) 6767673Snate@binkert.org obj = all_enums[name] 6775517Snate@binkert.org 6787673Snate@binkert.org code = code_formatter() 6797673Snate@binkert.org obj.cxx_decl(code) 6805517Snate@binkert.org code.write(target[0].abspath) 6817673Snate@binkert.org 6825517Snate@binkert.orgdef createEnumSwigWrapper(target, source, env): 6835517Snate@binkert.org assert len(target) == 1 and len(source) == 1 6847673Snate@binkert.org 6857673Snate@binkert.org name = str(source[0].get_contents()) 6867673Snate@binkert.org obj = all_enums[name] 6877673Snate@binkert.org 6885517Snate@binkert.org code = code_formatter() 6897673Snate@binkert.org obj.swig_decl(code) 6907673Snate@binkert.org code.write(target[0].abspath) 6917673Snate@binkert.org 6925517Snate@binkert.orgdef createSimObjectSwigWrapper(target, source, env): 6937673Snate@binkert.org name = source[0].get_contents() 6947673Snate@binkert.org obj = sim_objects[name] 6957673Snate@binkert.org 6965517Snate@binkert.org code = code_formatter() 6977673Snate@binkert.org obj.swig_decl(code) 6985517Snate@binkert.org code.write(target[0].abspath) 6995517Snate@binkert.org 7005517Snate@binkert.org# dummy target for generated code 7015517Snate@binkert.org# we start out with all the Source files so they get copied to build/*/ also. 7026229Snate@binkert.orgSWIG = env.Dummy('swig', [s.tnode for s in Source.get()]) 7037673Snate@binkert.org 7045517Snate@binkert.org# Generate all of the SimObject param C++ struct header files 7055517Snate@binkert.orgparams_hh_files = [] 7067673Snate@binkert.orgfor name,simobj in sorted(sim_objects.iteritems()): 7075517Snate@binkert.org py_source = PySource.modules[simobj.__module__] 7085517Snate@binkert.org extra_deps = [ py_source.tnode ] 7095517Snate@binkert.org 7105517Snate@binkert.org hh_file = File('params/%s.hh' % name) 7115517Snate@binkert.org params_hh_files.append(hh_file) 7125517Snate@binkert.org env.Command(hh_file, Value(name), 7135517Snate@binkert.org MakeAction(createSimObjectParamStruct, Transform("SO PARAM"))) 7145517Snate@binkert.org env.Depends(hh_file, depends + extra_deps) 7155517Snate@binkert.org env.Depends(SWIG, hh_file) 7167673Snate@binkert.org 7175517Snate@binkert.org# C++ parameter description files 7187673Snate@binkert.orgif GetOption('with_cxx_config'): 7195517Snate@binkert.org for name,simobj in sorted(sim_objects.iteritems()): 7205517Snate@binkert.org py_source = PySource.modules[simobj.__module__] 7215517Snate@binkert.org extra_deps = [ py_source.tnode ] 7225517Snate@binkert.org 7237673Snate@binkert.org cxx_config_hh_file = File('cxx_config/%s.hh' % name) 7245517Snate@binkert.org cxx_config_cc_file = File('cxx_config/%s.cc' % name) 7257673Snate@binkert.org env.Command(cxx_config_hh_file, Value(name), 7265517Snate@binkert.org MakeAction(createSimObjectCxxConfig(True), 7275517Snate@binkert.org Transform("CXXCPRHH"))) 7287673Snate@binkert.org env.Command(cxx_config_cc_file, Value(name), 7297673Snate@binkert.org MakeAction(createSimObjectCxxConfig(False), 7305517Snate@binkert.org Transform("CXXCPRCC"))) 7317673Snate@binkert.org env.Depends(cxx_config_hh_file, depends + extra_deps + 7327673Snate@binkert.org [File('params/%s.hh' % name), File('sim/cxx_config.hh')]) 7335517Snate@binkert.org env.Depends(cxx_config_cc_file, depends + extra_deps + 7347673Snate@binkert.org [cxx_config_hh_file]) 7357673Snate@binkert.org Source(cxx_config_cc_file) 7367673Snate@binkert.org 7377673Snate@binkert.org cxx_config_init_cc_file = File('cxx_config/init.cc') 7385517Snate@binkert.org 7395517Snate@binkert.org def createCxxConfigInitCC(target, source, env): 7405517Snate@binkert.org assert len(target) == 1 and len(source) == 1 7417673Snate@binkert.org 7427673Snate@binkert.org code = code_formatter() 7435517Snate@binkert.org 7445517Snate@binkert.org for name,simobj in sorted(sim_objects.iteritems()): 7457673Snate@binkert.org if not hasattr(simobj, 'abstract') or not simobj.abstract: 7467673Snate@binkert.org code('#include "cxx_config/${name}.hh"') 7477673Snate@binkert.org code() 7487673Snate@binkert.org code('void cxxConfigInit()') 7495517Snate@binkert.org code('{') 7505517Snate@binkert.org code.indent() 7515517Snate@binkert.org for name,simobj in sorted(sim_objects.iteritems()): 7525517Snate@binkert.org not_abstract = not hasattr(simobj, 'abstract') or \ 7537673Snate@binkert.org not simobj.abstract 7547673Snate@binkert.org if not_abstract and 'type' in simobj.__dict__: 7555517Snate@binkert.org code('cxx_config_directory["${name}"] = ' 7567673Snate@binkert.org '${name}CxxConfigParams::makeDirectoryEntry();') 7577673Snate@binkert.org code.dedent() 7587673Snate@binkert.org code('}') 7597673Snate@binkert.org code.write(target[0].abspath) 7607673Snate@binkert.org 7615517Snate@binkert.org py_source = PySource.modules[simobj.__module__] 7625517Snate@binkert.org extra_deps = [ py_source.tnode ] 7635517Snate@binkert.org env.Command(cxx_config_init_cc_file, Value(name), 7647673Snate@binkert.org MakeAction(createCxxConfigInitCC, Transform("CXXCINIT"))) 7657673Snate@binkert.org cxx_param_hh_files = ["cxx_config/%s.hh" % simobj 7667673Snate@binkert.org for name,simobj in sorted(sim_objects.iteritems()) 7675517Snate@binkert.org if not hasattr(simobj, 'abstract') or not simobj.abstract] 7685517Snate@binkert.org Depends(cxx_config_init_cc_file, cxx_param_hh_files + 7697673Snate@binkert.org [File('sim/cxx_config.hh')]) 7705517Snate@binkert.org Source(cxx_config_init_cc_file) 7717673Snate@binkert.org 7727673Snate@binkert.org# Generate any needed param SWIG wrapper files 7735517Snate@binkert.orgparams_i_files = [] 7747673Snate@binkert.orgfor name,param in sorted(params_to_swig.iteritems()): 7755517Snate@binkert.org i_file = File('python/m5/internal/%s.i' % (param.swig_module_name())) 7765517Snate@binkert.org params_i_files.append(i_file) 7775517Snate@binkert.org env.Command(i_file, Value(name), 7785517Snate@binkert.org MakeAction(createParamSwigWrapper, Transform("SW PARAM"))) 7796229Snate@binkert.org env.Depends(i_file, depends) 7807673Snate@binkert.org env.Depends(SWIG, i_file) 7815517Snate@binkert.org SwigSource('m5.internal', i_file) 7825517Snate@binkert.org 7837673Snate@binkert.org# Generate all enum header files 7845517Snate@binkert.orgfor name,enum in sorted(all_enums.iteritems()): 7855517Snate@binkert.org py_source = PySource.modules[enum.__module__] 7865517Snate@binkert.org extra_deps = [ py_source.tnode ] 7875517Snate@binkert.org 7885517Snate@binkert.org cc_file = File('enums/%s.cc' % name) 7895517Snate@binkert.org env.Command(cc_file, Value(name), 7905517Snate@binkert.org MakeAction(createEnumStrings, Transform("ENUM STR"))) 7915517Snate@binkert.org env.Depends(cc_file, depends + extra_deps) 7925517Snate@binkert.org env.Depends(SWIG, cc_file) 7935517Snate@binkert.org Source(cc_file) 7945517Snate@binkert.org 7957673Snate@binkert.org hh_file = File('enums/%s.hh' % name) 7965517Snate@binkert.org env.Command(hh_file, Value(name), 7975517Snate@binkert.org MakeAction(createEnumDecls, Transform("ENUMDECL"))) 7985517Snate@binkert.org env.Depends(hh_file, depends + extra_deps) 7997673Snate@binkert.org env.Depends(SWIG, hh_file) 8005517Snate@binkert.org 8015517Snate@binkert.org i_file = File('python/m5/internal/enum_%s.i' % name) 8027673Snate@binkert.org env.Command(i_file, Value(name), 8035517Snate@binkert.org MakeAction(createEnumSwigWrapper, Transform("ENUMSWIG"))) 8045517Snate@binkert.org env.Depends(i_file, depends + extra_deps) 8055517Snate@binkert.org env.Depends(SWIG, i_file) 8067673Snate@binkert.org SwigSource('m5.internal', i_file) 8077673Snate@binkert.org 8087673Snate@binkert.org# Generate SimObject SWIG wrapper files 8095517Snate@binkert.orgfor name,simobj in sorted(sim_objects.iteritems()): 8105517Snate@binkert.org py_source = PySource.modules[simobj.__module__] 8117673Snate@binkert.org extra_deps = [ py_source.tnode ] 8125517Snate@binkert.org i_file = File('python/m5/internal/param_%s.i' % name) 8135517Snate@binkert.org env.Command(i_file, Value(name), 8147673Snate@binkert.org MakeAction(createSimObjectSwigWrapper, Transform("SO SWIG"))) 8155517Snate@binkert.org env.Depends(i_file, depends + extra_deps) 8167673Snate@binkert.org SwigSource('m5.internal', i_file) 8177673Snate@binkert.org 8185517Snate@binkert.org# Generate the main swig init file 8195517Snate@binkert.orgdef makeEmbeddedSwigInit(target, source, env): 8205517Snate@binkert.org code = code_formatter() 8217673Snate@binkert.org module = source[0].get_contents() 8225517Snate@binkert.org code('''\ 8235517Snate@binkert.org#include "sim/init.hh" 8245517Snate@binkert.org 8257673Snate@binkert.orgextern "C" { 8267673Snate@binkert.org void init_${module}(); 8275517Snate@binkert.org} 8285517Snate@binkert.org 8297673Snate@binkert.orgEmbeddedSwig embed_swig_${module}(init_${module}); 8305517Snate@binkert.org''') 8315517Snate@binkert.org code.write(str(target[0])) 8325517Snate@binkert.org 8335517Snate@binkert.org# Build all swig modules 8345517Snate@binkert.orgfor swig in SwigSource.all: 8355517Snate@binkert.org env.Command([swig.cc_source.tnode, swig.py_source.tnode], swig.tnode, 8365517Snate@binkert.org MakeAction('$SWIG $SWIGFLAGS -outdir ${TARGETS[1].dir} ' 8375517Snate@binkert.org '-o ${TARGETS[0]} $SOURCES', Transform("SWIG"))) 8385517Snate@binkert.org cc_file = str(swig.tnode) 8395517Snate@binkert.org init_file = '%s/%s_init.cc' % (dirname(cc_file), basename(cc_file)) 8405517Snate@binkert.org env.Command(init_file, Value(swig.module), 8415517Snate@binkert.org MakeAction(makeEmbeddedSwigInit, Transform("EMBED SW"))) 8425517Snate@binkert.org env.Depends(SWIG, init_file) 8437673Snate@binkert.org Source(init_file, **swig.guards) 8445517Snate@binkert.org 8457673Snate@binkert.org# Build all protocol buffers if we have got protoc and protobuf available 8465517Snate@binkert.orgif env['HAVE_PROTOBUF']: 8476143Snate@binkert.org for proto in ProtoBuf.all: 8487756SAli.Saidi@ARM.com # Use both the source and header as the target, and the .proto 8497756SAli.Saidi@ARM.com # file as the source. When executing the protoc compiler, also 8505192Ssaidi@eecs.umich.edu # specify the proto_path to avoid having the generated files 8515192Ssaidi@eecs.umich.edu # include the path. 8527756SAli.Saidi@ARM.com env.Command([proto.cc_file, proto.hh_file], proto.tnode, 8537756SAli.Saidi@ARM.com MakeAction('$PROTOC --cpp_out ${TARGET.dir} ' 8547756SAli.Saidi@ARM.com '--proto_path ${SOURCE.dir} $SOURCE', 8557756SAli.Saidi@ARM.com Transform("PROTOC"))) 8565192Ssaidi@eecs.umich.edu 8575192Ssaidi@eecs.umich.edu env.Depends(SWIG, [proto.cc_file, proto.hh_file]) 8587674Snate@binkert.org # Add the C++ source file 8595522Snate@binkert.org Source(proto.cc_file, **proto.guards) 8605522Snate@binkert.orgelif ProtoBuf.all: 8617674Snate@binkert.org print 'Got protobuf to build, but lacks support!' 8627674Snate@binkert.org Exit(1) 8637674Snate@binkert.org 8647674Snate@binkert.org# 8657674Snate@binkert.org# Handle debug flags 8667674Snate@binkert.org# 8677674Snate@binkert.orgdef makeDebugFlagCC(target, source, env): 8687674Snate@binkert.org assert(len(target) == 1 and len(source) == 1) 8695522Snate@binkert.org 8705522Snate@binkert.org code = code_formatter() 8715522Snate@binkert.org 8725517Snate@binkert.org # delay definition of CompoundFlags until after all the definition 8735522Snate@binkert.org # of all constituent SimpleFlags 8745517Snate@binkert.org comp_code = code_formatter() 8756143Snate@binkert.org 8766727Ssteve.reinhardt@amd.com # file header 8775522Snate@binkert.org code(''' 8785522Snate@binkert.org/* 8795522Snate@binkert.org * DO NOT EDIT THIS FILE! Automatically generated by SCons. 8807674Snate@binkert.org */ 8815517Snate@binkert.org 8827673Snate@binkert.org#include "base/debug.hh" 8837673Snate@binkert.org 8847674Snate@binkert.orgnamespace Debug { 8857673Snate@binkert.org 8867674Snate@binkert.org''') 8877674Snate@binkert.org 8887674Snate@binkert.org for name, flag in sorted(source[0].read().iteritems()): 8897674Snate@binkert.org n, compound, desc = flag 8907674Snate@binkert.org assert n == name 8917674Snate@binkert.org 8925522Snate@binkert.org if not compound: 8935522Snate@binkert.org code('SimpleFlag $name("$name", "$desc");') 8947674Snate@binkert.org else: 8957674Snate@binkert.org comp_code('CompoundFlag $name("$name", "$desc",') 8967674Snate@binkert.org comp_code.indent() 8977674Snate@binkert.org last = len(compound) - 1 8987673Snate@binkert.org for i,flag in enumerate(compound): 8997674Snate@binkert.org if i != last: 9007674Snate@binkert.org comp_code('&$flag,') 9017674Snate@binkert.org else: 9027674Snate@binkert.org comp_code('&$flag);') 9037674Snate@binkert.org comp_code.dedent() 9047674Snate@binkert.org 9057674Snate@binkert.org code.append(comp_code) 9067674Snate@binkert.org code() 9077674Snate@binkert.org code('} // namespace Debug') 9087674Snate@binkert.org 9097673Snate@binkert.org code.write(str(target[0])) 9105522Snate@binkert.org 9116143Snate@binkert.orgdef makeDebugFlagHH(target, source, env): 9127756SAli.Saidi@ARM.com assert(len(target) == 1 and len(source) == 1) 9137756SAli.Saidi@ARM.com 9147674Snate@binkert.org val = eval(source[0].get_contents()) 9154382Sbinkertn@umich.edu name, compound, desc = val 9164382Sbinkertn@umich.edu 9174382Sbinkertn@umich.edu code = code_formatter() 9184382Sbinkertn@umich.edu 9194382Sbinkertn@umich.edu # file header boilerplate 9204382Sbinkertn@umich.edu code('''\ 9214382Sbinkertn@umich.edu/* 9224382Sbinkertn@umich.edu * DO NOT EDIT THIS FILE! Automatically generated by SCons. 9234382Sbinkertn@umich.edu */ 9244382Sbinkertn@umich.edu 9256143Snate@binkert.org#ifndef __DEBUG_${name}_HH__ 926955SN/A#define __DEBUG_${name}_HH__ 9272655Sstever@eecs.umich.edu 9282655Sstever@eecs.umich.edunamespace Debug { 9292655Sstever@eecs.umich.edu''') 9302655Sstever@eecs.umich.edu 9312655Sstever@eecs.umich.edu if compound: 9325601Snate@binkert.org code('class CompoundFlag;') 9335601Snate@binkert.org code('class SimpleFlag;') 9345601Snate@binkert.org 9355601Snate@binkert.org if compound: 9365522Snate@binkert.org code('extern CompoundFlag $name;') 9375863Snate@binkert.org for flag in compound: 9385601Snate@binkert.org code('extern SimpleFlag $flag;') 9395601Snate@binkert.org else: 9405601Snate@binkert.org code('extern SimpleFlag $name;') 9415863Snate@binkert.org 9426143Snate@binkert.org code(''' 9435559Snate@binkert.org} 9445559Snate@binkert.org 9455559Snate@binkert.org#endif // __DEBUG_${name}_HH__ 9465559Snate@binkert.org''') 9475601Snate@binkert.org 9486143Snate@binkert.org code.write(str(target[0])) 9496143Snate@binkert.org 9506143Snate@binkert.orgfor name,flag in sorted(debug_flags.iteritems()): 9516143Snate@binkert.org n, compound, desc = flag 9526143Snate@binkert.org assert n == name 9536143Snate@binkert.org 9546143Snate@binkert.org hh_file = 'debug/%s.hh' % name 9556143Snate@binkert.org env.Command(hh_file, Value(flag), 9566143Snate@binkert.org MakeAction(makeDebugFlagHH, Transform("TRACING", 0))) 9576143Snate@binkert.org env.Depends(SWIG, hh_file) 9586143Snate@binkert.org 9596143Snate@binkert.orgenv.Command('debug/flags.cc', Value(debug_flags), 9606143Snate@binkert.org MakeAction(makeDebugFlagCC, Transform("TRACING", 0))) 9616143Snate@binkert.orgenv.Depends(SWIG, 'debug/flags.cc') 9626143Snate@binkert.orgSource('debug/flags.cc') 9636143Snate@binkert.org 9646143Snate@binkert.org# version tags 9656143Snate@binkert.orgenv.Command('sim/tags.cc', None, 9666143Snate@binkert.org MakeAction('util/cpt_upgrader.py --get-cc-file > $TARGET', 9676143Snate@binkert.org Transform("VER TAGS"))) 9686143Snate@binkert.org 9696143Snate@binkert.org# Embed python files. All .py files that have been indicated by a 9706143Snate@binkert.org# PySource() call in a SConscript need to be embedded into the M5 9716143Snate@binkert.org# library. To do that, we compile the file to byte code, marshal the 9726143Snate@binkert.org# byte code, compress it, and then generate a c++ file that 9736143Snate@binkert.org# inserts the result into an array. 9746143Snate@binkert.orgdef embedPyFile(target, source, env): 9756143Snate@binkert.org def c_str(string): 9766143Snate@binkert.org if string is None: 9776143Snate@binkert.org return "0" 9786143Snate@binkert.org return '"%s"' % string 9796143Snate@binkert.org 9806240Snate@binkert.org '''Action function to compile a .py into a code object, marshal 9815554Snate@binkert.org it, compress it, and stick it into an asm file so the code appears 9825522Snate@binkert.org as just bytes with a label in the data section''' 9835522Snate@binkert.org 9845797Snate@binkert.org src = file(str(source[0]), 'r').read() 9855797Snate@binkert.org 9865522Snate@binkert.org pysource = PySource.tnodes[source[0]] 9875584Snate@binkert.org compiled = compile(src, pysource.abspath, 'exec') 9886143Snate@binkert.org marshalled = marshal.dumps(compiled) 9895862Snate@binkert.org compressed = zlib.compress(marshalled) 9905584Snate@binkert.org data = compressed 9915601Snate@binkert.org sym = pysource.symname 9926143Snate@binkert.org 9936143Snate@binkert.org code = code_formatter() 9942655Sstever@eecs.umich.edu code('''\ 9956143Snate@binkert.org#include "sim/init.hh" 9966143Snate@binkert.org 9976143Snate@binkert.orgnamespace { 9986143Snate@binkert.org 9996143Snate@binkert.orgconst uint8_t data_${sym}[] = { 10004007Ssaidi@eecs.umich.edu''') 10014596Sbinkertn@umich.edu code.indent() 10024007Ssaidi@eecs.umich.edu step = 16 10034596Sbinkertn@umich.edu for i in xrange(0, len(data), step): 10047756SAli.Saidi@ARM.com x = array.array('B', data[i:i+step]) 10057756SAli.Saidi@ARM.com code(''.join('%d,' % d for d in x)) 10065522Snate@binkert.org code.dedent() 10075601Snate@binkert.org 10085601Snate@binkert.org code('''}; 10092655Sstever@eecs.umich.edu 1010955SN/AEmbeddedPython embedded_${sym}( 10113918Ssaidi@eecs.umich.edu ${{c_str(pysource.arcname)}}, 10123918Ssaidi@eecs.umich.edu ${{c_str(pysource.abspath)}}, 10133918Ssaidi@eecs.umich.edu ${{c_str(pysource.modpath)}}, 10143918Ssaidi@eecs.umich.edu data_${sym}, 10153918Ssaidi@eecs.umich.edu ${{len(data)}}, 10163918Ssaidi@eecs.umich.edu ${{len(marshalled)}}); 10173918Ssaidi@eecs.umich.edu 10183918Ssaidi@eecs.umich.edu} // anonymous namespace 10193918Ssaidi@eecs.umich.edu''') 10203918Ssaidi@eecs.umich.edu code.write(str(target[0])) 10213918Ssaidi@eecs.umich.edu 10223918Ssaidi@eecs.umich.edufor source in PySource.all: 10233918Ssaidi@eecs.umich.edu env.Command(source.cpp, source.tnode, 10243918Ssaidi@eecs.umich.edu MakeAction(embedPyFile, Transform("EMBED PY"))) 10253940Ssaidi@eecs.umich.edu env.Depends(SWIG, source.cpp) 10263940Ssaidi@eecs.umich.edu Source(source.cpp, skip_no_python=True) 10273940Ssaidi@eecs.umich.edu 10283942Ssaidi@eecs.umich.edu######################################################################## 10293940Ssaidi@eecs.umich.edu# 10303515Ssaidi@eecs.umich.edu# Define binaries. Each different build type (debug, opt, etc.) gets 10313918Ssaidi@eecs.umich.edu# a slightly different build environment. 10324762Snate@binkert.org# 10333515Ssaidi@eecs.umich.edu 10342655Sstever@eecs.umich.edu# List of constructed environments to pass back to SConstruct 10353918Ssaidi@eecs.umich.edudate_source = Source('base/date.cc', skip_lib=True) 10363619Sbinkertn@umich.edu 1037955SN/A# Capture this directory for the closure makeEnv, otherwise when it is 1038955SN/A# called, it won't know what directory it should use. 10392655Sstever@eecs.umich.eduvariant_dir = Dir('.').path 10403918Ssaidi@eecs.umich.edudef variant(*path): 10413619Sbinkertn@umich.edu return os.path.join(variant_dir, *path) 1042955SN/Adef variantd(*path): 1043955SN/A return variant(*path)+'/' 10442655Sstever@eecs.umich.edu 10453918Ssaidi@eecs.umich.edu# Function to create a new build environment as clone of current 10463619Sbinkertn@umich.edu# environment 'env' with modified object suffix and optional stripped 1047955SN/A# binary. Additional keyword arguments are appended to corresponding 1048955SN/A# build environment vars. 10492655Sstever@eecs.umich.edudef makeEnv(env, label, objsfx, strip = False, **kwargs): 10503918Ssaidi@eecs.umich.edu # SCons doesn't know to append a library suffix when there is a '.' in the 10513683Sstever@eecs.umich.edu # name. Use '_' instead. 10522655Sstever@eecs.umich.edu libname = variant('gem5_' + label) 10531869SN/A exename = variant('gem5.' + label) 10541869SN/A secondary_exename = variant('m5.' + label) 1055 1056 new_env = env.Clone(OBJSUFFIX=objsfx, SHOBJSUFFIX=objsfx + 's') 1057 new_env.Label = label 1058 new_env.Append(**kwargs) 1059 1060 swig_env = new_env.Clone() 1061 1062 # Both gcc and clang have issues with unused labels and values in 1063 # the SWIG generated code 1064 swig_env.Append(CCFLAGS=['-Wno-unused-label', '-Wno-unused-value']) 1065 1066 if env['GCC']: 1067 # Depending on the SWIG version, we also need to supress 1068 # warnings about uninitialized variables and missing field 1069 # initializers. 1070 swig_env.Append(CCFLAGS=['-Wno-uninitialized', 1071 '-Wno-missing-field-initializers', 1072 '-Wno-unused-but-set-variable', 1073 '-Wno-maybe-uninitialized', 1074 '-Wno-type-limits']) 1075 1076 # Only gcc >= 4.9 supports UBSan, so check both the version 1077 # and the command-line option before adding the compiler and 1078 # linker flags. 1079 if GetOption('with_ubsan') and \ 1080 compareVersions(env['GCC_VERSION'], '4.9') >= 0: 1081 new_env.Append(CCFLAGS='-fsanitize=undefined') 1082 new_env.Append(LINKFLAGS='-fsanitize=undefined') 1083 1084 if env['CLANG']: 1085 swig_env.Append(CCFLAGS=['-Wno-sometimes-uninitialized', 1086 '-Wno-deprecated-register', 1087 '-Wno-tautological-compare']) 1088 1089 # All supported clang versions have support for UBSan, so if 1090 # asked to use it, append the compiler and linker flags. 1091 if GetOption('with_ubsan'): 1092 new_env.Append(CCFLAGS='-fsanitize=undefined') 1093 new_env.Append(LINKFLAGS='-fsanitize=undefined') 1094 1095 werror_env = new_env.Clone() 1096 # Treat warnings as errors but white list some warnings that we 1097 # want to allow (e.g., deprecation warnings). 1098 werror_env.Append(CCFLAGS=['-Werror', 1099 '-Wno-error=deprecated-declarations', 1100 '-Wno-error=deprecated', 1101 ]) 1102 1103 def make_obj(source, static, extra_deps = None): 1104 '''This function adds the specified source to the correct 1105 build environment, and returns the corresponding SCons Object 1106 nodes''' 1107 1108 if source.swig: 1109 env = swig_env 1110 elif source.Werror: 1111 env = werror_env 1112 else: 1113 env = new_env 1114 1115 if static: 1116 obj = env.StaticObject(source.tnode) 1117 else: 1118 obj = env.SharedObject(source.tnode) 1119 1120 if extra_deps: 1121 env.Depends(obj, extra_deps) 1122 1123 return obj 1124 1125 lib_guards = {'main': False, 'skip_lib': False} 1126 1127 # Without Python, leave out all SWIG and Python content from the 1128 # library builds. The option doesn't affect gem5 built as a program 1129 if GetOption('without_python'): 1130 lib_guards['skip_no_python'] = False 1131 1132 static_objs = [ make_obj(s, True) for s in Source.get(**lib_guards) ] 1133 shared_objs = [ make_obj(s, False) for s in Source.get(**lib_guards) ] 1134 1135 static_date = make_obj(date_source, static=True, extra_deps=static_objs) 1136 static_objs.append(static_date) 1137 1138 shared_date = make_obj(date_source, static=False, extra_deps=shared_objs) 1139 shared_objs.append(shared_date) 1140 1141 # First make a library of everything but main() so other programs can 1142 # link against m5. 1143 static_lib = new_env.StaticLibrary(libname, static_objs) 1144 shared_lib = new_env.SharedLibrary(libname, shared_objs) 1145 1146 # Now link a stub with main() and the static library. 1147 main_objs = [ make_obj(s, True) for s in Source.get(main=True) ] 1148 1149 for test in UnitTest.all: 1150 flags = { test.target : True } 1151 test_sources = Source.get(**flags) 1152 test_objs = [ make_obj(s, static=True) for s in test_sources ] 1153 if test.main: 1154 test_objs += main_objs 1155 path = variant('unittest/%s.%s' % (test.target, label)) 1156 new_env.Program(path, test_objs + static_objs) 1157 1158 progname = exename 1159 if strip: 1160 progname += '.unstripped' 1161 1162 targets = new_env.Program(progname, main_objs + static_objs) 1163 1164 if strip: 1165 if sys.platform == 'sunos5': 1166 cmd = 'cp $SOURCE $TARGET; strip $TARGET' 1167 else: 1168 cmd = 'strip $SOURCE -o $TARGET' 1169 targets = new_env.Command(exename, progname, 1170 MakeAction(cmd, Transform("STRIP"))) 1171 1172 new_env.Command(secondary_exename, exename, 1173 MakeAction('ln $SOURCE $TARGET', Transform("HARDLINK"))) 1174 1175 new_env.M5Binary = targets[0] 1176 return new_env 1177 1178# Start out with the compiler flags common to all compilers, 1179# i.e. they all use -g for opt and -g -pg for prof 1180ccflags = {'debug' : [], 'opt' : ['-g'], 'fast' : [], 'prof' : ['-g', '-pg'], 1181 'perf' : ['-g']} 1182 1183# Start out with the linker flags common to all linkers, i.e. -pg for 1184# prof, and -lprofiler for perf. The -lprofile flag is surrounded by 1185# no-as-needed and as-needed as the binutils linker is too clever and 1186# simply doesn't link to the library otherwise. 1187ldflags = {'debug' : [], 'opt' : [], 'fast' : [], 'prof' : ['-pg'], 1188 'perf' : ['-Wl,--no-as-needed', '-lprofiler', '-Wl,--as-needed']} 1189 1190# For Link Time Optimization, the optimisation flags used to compile 1191# individual files are decoupled from those used at link time 1192# (i.e. you can compile with -O3 and perform LTO with -O0), so we need 1193# to also update the linker flags based on the target. 1194if env['GCC']: 1195 if sys.platform == 'sunos5': 1196 ccflags['debug'] += ['-gstabs+'] 1197 else: 1198 ccflags['debug'] += ['-ggdb3'] 1199 ldflags['debug'] += ['-O0'] 1200 # opt, fast, prof and perf all share the same cc flags, also add 1201 # the optimization to the ldflags as LTO defers the optimization 1202 # to link time 1203 for target in ['opt', 'fast', 'prof', 'perf']: 1204 ccflags[target] += ['-O3'] 1205 ldflags[target] += ['-O3'] 1206 1207 ccflags['fast'] += env['LTO_CCFLAGS'] 1208 ldflags['fast'] += env['LTO_LDFLAGS'] 1209elif env['CLANG']: 1210 ccflags['debug'] += ['-g', '-O0'] 1211 # opt, fast, prof and perf all share the same cc flags 1212 for target in ['opt', 'fast', 'prof', 'perf']: 1213 ccflags[target] += ['-O3'] 1214else: 1215 print 'Unknown compiler, please fix compiler options' 1216 Exit(1) 1217 1218 1219# To speed things up, we only instantiate the build environments we 1220# need. We try to identify the needed environment for each target; if 1221# we can't, we fall back on instantiating all the environments just to 1222# be safe. 1223target_types = ['debug', 'opt', 'fast', 'prof', 'perf'] 1224obj2target = {'do': 'debug', 'o': 'opt', 'fo': 'fast', 'po': 'prof', 1225 'gpo' : 'perf'} 1226 1227def identifyTarget(t): 1228 ext = t.split('.')[-1] 1229 if ext in target_types: 1230 return ext 1231 if obj2target.has_key(ext): 1232 return obj2target[ext] 1233 match = re.search(r'/tests/([^/]+)/', t) 1234 if match and match.group(1) in target_types: 1235 return match.group(1) 1236 return 'all' 1237 1238needed_envs = [identifyTarget(target) for target in BUILD_TARGETS] 1239if 'all' in needed_envs: 1240 needed_envs += target_types 1241 1242gem5_root = Dir('.').up().up().abspath 1243def makeEnvirons(target, source, env): 1244 # cause any later Source() calls to be fatal, as a diagnostic. 1245 Source.done() 1246 1247 envList = [] 1248 1249 # Debug binary 1250 if 'debug' in needed_envs: 1251 envList.append( 1252 makeEnv(env, 'debug', '.do', 1253 CCFLAGS = Split(ccflags['debug']), 1254 CPPDEFINES = ['DEBUG', 'TRACING_ON=1'], 1255 LINKFLAGS = Split(ldflags['debug']))) 1256 1257 # Optimized binary 1258 if 'opt' in needed_envs: 1259 envList.append( 1260 makeEnv(env, 'opt', '.o', 1261 CCFLAGS = Split(ccflags['opt']), 1262 CPPDEFINES = ['TRACING_ON=1'], 1263 LINKFLAGS = Split(ldflags['opt']))) 1264 1265 # "Fast" binary 1266 if 'fast' in needed_envs: 1267 envList.append( 1268 makeEnv(env, 'fast', '.fo', strip = True, 1269 CCFLAGS = Split(ccflags['fast']), 1270 CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'], 1271 LINKFLAGS = Split(ldflags['fast']))) 1272 1273 # Profiled binary using gprof 1274 if 'prof' in needed_envs: 1275 envList.append( 1276 makeEnv(env, 'prof', '.po', 1277 CCFLAGS = Split(ccflags['prof']), 1278 CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'], 1279 LINKFLAGS = Split(ldflags['prof']))) 1280 1281 # Profiled binary using google-pprof 1282 if 'perf' in needed_envs: 1283 envList.append( 1284 makeEnv(env, 'perf', '.gpo', 1285 CCFLAGS = Split(ccflags['perf']), 1286 CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'], 1287 LINKFLAGS = Split(ldflags['perf']))) 1288 1289 # Set up the regression tests for each build. 1290 for e in envList: 1291 SConscript(os.path.join(gem5_root, 'tests', 'SConscript'), 1292 variant_dir = variantd('tests', e.Label), 1293 exports = { 'env' : e }, duplicate = False) 1294 1295# The MakeEnvirons Builder defers the full dependency collection until 1296# after processing the ISA definition (due to dynamically generated 1297# source files). Add this dependency to all targets so they will wait 1298# until the environments are completely set up. Otherwise, a second 1299# process (e.g. -j2 or higher) will try to compile the requested target, 1300# not know how, and fail. 1301env.Append(BUILDERS = {'MakeEnvirons' : 1302 Builder(action=MakeAction(makeEnvirons, 1303 Transform("ENVIRONS", 1)))}) 1304 1305isa_target = env['PHONY_BASE'] + '-deps' 1306environs = env['PHONY_BASE'] + '-environs' 1307env.Depends('#all-deps', isa_target) 1308env.Depends('#all-environs', environs) 1309env.ScanISA(isa_target, File('arch/%s/generated/inc.d' % env['TARGET_ISA'])) 1310envSetup = env.MakeEnvirons(environs, isa_target) 1311 1312# make sure no -deps targets occur before all ISAs are complete 1313env.Depends(isa_target, '#all-isas') 1314# likewise for -environs targets and all the -deps targets 1315env.Depends(environs, '#all-deps') 1316