SConscript revision 12363
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 3312371Sgabeblack@google.comimport imp 344762Snate@binkert.orgimport marshal 355522Snate@binkert.orgimport os 36955SN/Aimport re 375522Snate@binkert.orgimport subprocess 3811974Sgabeblack@google.comimport sys 39955SN/Aimport zlib 405522Snate@binkert.org 414202Sbinkertn@umich.edufrom os.path import basename, dirname, exists, isdir, isfile, join as joinpath 425742Snate@binkert.org 43955SN/Aimport SCons 444381Sbinkertn@umich.edu 454381Sbinkertn@umich.edufrom gem5_scons import Transform 4612246Sgabeblack@google.com 4712246Sgabeblack@google.com# This file defines how to build a particular configuration of gem5 488334Snate@binkert.org# based on variable settings in the 'env' build environment. 49955SN/A 50955SN/AImport('*') 514202Sbinkertn@umich.edu 52955SN/A# Children need to see the environment 534382Sbinkertn@umich.eduExport('env') 544382Sbinkertn@umich.edu 554382Sbinkertn@umich.edubuild_env = [(opt, env[opt]) for opt in export_vars] 566654Snate@binkert.org 575517Snate@binkert.orgfrom m5.util import code_formatter, compareVersions 588614Sgblack@eecs.umich.edu 597674Snate@binkert.org######################################################################## 606143Snate@binkert.org# Code for adding source files of various types 616143Snate@binkert.org# 626143Snate@binkert.org# When specifying a source file of some type, a set of tags can be 6312302Sgabeblack@google.com# specified for that file. 6412302Sgabeblack@google.com 6512302Sgabeblack@google.comclass SourceList(list): 6612371Sgabeblack@google.com def with_tags_that(self, predicate): 6712371Sgabeblack@google.com '''Return a list of sources with tags that satisfy a predicate.''' 6812371Sgabeblack@google.com def match(source): 6912371Sgabeblack@google.com return predicate(source.tags) 7012371Sgabeblack@google.com return SourceList(filter(match, self)) 7112371Sgabeblack@google.com 7212371Sgabeblack@google.com def with_any_tags(self, *tags): 7312371Sgabeblack@google.com '''Return a list of sources with any of the supplied tags.''' 7412371Sgabeblack@google.com return self.with_tags_that(lambda stags: len(set(tags) & stags) > 0) 7512371Sgabeblack@google.com 7612371Sgabeblack@google.com def with_all_tags(self, *tags): 7712371Sgabeblack@google.com '''Return a list of sources with all of the supplied tags.''' 7812371Sgabeblack@google.com return self.with_tags_that(lambda stags: set(tags) <= stags) 7912371Sgabeblack@google.com 8012371Sgabeblack@google.com def with_tag(self, tag): 8112371Sgabeblack@google.com '''Return a list of sources with the supplied tag.''' 8212371Sgabeblack@google.com return self.with_tags_that(lambda stags: tag in stags) 8312371Sgabeblack@google.com 8412371Sgabeblack@google.com def without_tags(self, *tags): 8512371Sgabeblack@google.com '''Return a list of sources without any of the supplied tags.''' 8612371Sgabeblack@google.com return self.with_tags_that(lambda stags: len(set(tags) & stags) == 0) 8712371Sgabeblack@google.com 8812371Sgabeblack@google.com def without_tag(self, tag): 8912371Sgabeblack@google.com '''Return a list of sources with the supplied tag.''' 9012371Sgabeblack@google.com return self.with_tags_that(lambda stags: tag not in stags) 9112371Sgabeblack@google.com 9212371Sgabeblack@google.comclass SourceMeta(type): 9312371Sgabeblack@google.com '''Meta class for source files that keeps track of all files of a 9412371Sgabeblack@google.com particular type.''' 9512371Sgabeblack@google.com def __init__(cls, name, bases, dict): 9612371Sgabeblack@google.com super(SourceMeta, cls).__init__(name, bases, dict) 9712371Sgabeblack@google.com cls.all = SourceList() 9812371Sgabeblack@google.com 9912371Sgabeblack@google.comclass SourceFile(object): 10012371Sgabeblack@google.com '''Base object that encapsulates the notion of a source file. 10112371Sgabeblack@google.com This includes, the source node, target node, various manipulations 10212371Sgabeblack@google.com of those. A source file also specifies a set of tags which 10312371Sgabeblack@google.com describing arbitrary properties of the source file.''' 10412371Sgabeblack@google.com __metaclass__ = SourceMeta 10512371Sgabeblack@google.com 10612371Sgabeblack@google.com static_objs = {} 10712371Sgabeblack@google.com shared_objs = {} 10812371Sgabeblack@google.com 10912371Sgabeblack@google.com def __init__(self, source, tags=None, add_tags=None): 11012371Sgabeblack@google.com if tags is None: 11112371Sgabeblack@google.com tags='gem5 lib' 11212371Sgabeblack@google.com if isinstance(tags, basestring): 11312302Sgabeblack@google.com tags = set([tags]) 11412371Sgabeblack@google.com if not isinstance(tags, set): 11512302Sgabeblack@google.com tags = set(tags) 11612371Sgabeblack@google.com self.tags = tags 11712302Sgabeblack@google.com 11812302Sgabeblack@google.com if add_tags: 11912371Sgabeblack@google.com if isinstance(add_tags, basestring): 12012371Sgabeblack@google.com add_tags = set([add_tags]) 12112371Sgabeblack@google.com if not isinstance(add_tags, set): 12212371Sgabeblack@google.com add_tags = set(add_tags) 12312302Sgabeblack@google.com self.tags |= add_tags 12412371Sgabeblack@google.com 12512371Sgabeblack@google.com tnode = source 12612371Sgabeblack@google.com if not isinstance(source, SCons.Node.FS.File): 12712371Sgabeblack@google.com tnode = File(source) 12811983Sgabeblack@google.com 1296143Snate@binkert.org self.tnode = tnode 1308233Snate@binkert.org self.snode = tnode.srcnode() 13112302Sgabeblack@google.com 1326143Snate@binkert.org for base in type(self).__mro__: 1336143Snate@binkert.org if issubclass(base, SourceFile): 13412302Sgabeblack@google.com base.all.append(self) 1354762Snate@binkert.org 1366143Snate@binkert.org def static(self, env): 1378233Snate@binkert.org key = (self.tnode, env['OBJSUFFIX']) 1388233Snate@binkert.org if not key in self.static_objs: 13912302Sgabeblack@google.com self.static_objs[key] = env.StaticObject(self.tnode) 14012302Sgabeblack@google.com return self.static_objs[key] 1416143Snate@binkert.org 14212362Sgabeblack@google.com def shared(self, env): 14312362Sgabeblack@google.com key = (self.tnode, env['OBJSUFFIX']) 14412362Sgabeblack@google.com if not key in self.shared_objs: 14512362Sgabeblack@google.com self.shared_objs[key] = env.SharedObject(self.tnode) 14612302Sgabeblack@google.com return self.shared_objs[key] 14712302Sgabeblack@google.com 14812302Sgabeblack@google.com @property 14912302Sgabeblack@google.com def filename(self): 15012302Sgabeblack@google.com return str(self.tnode) 15112363Sgabeblack@google.com 15212363Sgabeblack@google.com @property 15312363Sgabeblack@google.com def dirname(self): 15412363Sgabeblack@google.com return dirname(self.filename) 15512302Sgabeblack@google.com 15612363Sgabeblack@google.com @property 15712363Sgabeblack@google.com def basename(self): 15812363Sgabeblack@google.com return basename(self.filename) 15912363Sgabeblack@google.com 16012363Sgabeblack@google.com @property 1618233Snate@binkert.org def extname(self): 1626143Snate@binkert.org index = self.basename.rfind('.') 1636143Snate@binkert.org if index <= 0: 1646143Snate@binkert.org # dot files aren't extensions 1656143Snate@binkert.org return self.basename, None 1666143Snate@binkert.org 1676143Snate@binkert.org return self.basename[:index], self.basename[index+1:] 1686143Snate@binkert.org 1696143Snate@binkert.org def __lt__(self, other): return self.filename < other.filename 1706143Snate@binkert.org def __le__(self, other): return self.filename <= other.filename 1717065Snate@binkert.org def __gt__(self, other): return self.filename > other.filename 1726143Snate@binkert.org def __ge__(self, other): return self.filename >= other.filename 17312362Sgabeblack@google.com def __eq__(self, other): return self.filename == other.filename 17412362Sgabeblack@google.com def __ne__(self, other): return self.filename != other.filename 17512362Sgabeblack@google.com 17612362Sgabeblack@google.comclass Source(SourceFile): 17712362Sgabeblack@google.com ungrouped_tag = 'No link group' 17812362Sgabeblack@google.com source_groups = set() 17912362Sgabeblack@google.com 18012362Sgabeblack@google.com _current_group_tag = ungrouped_tag 18112362Sgabeblack@google.com 18212362Sgabeblack@google.com @staticmethod 18312362Sgabeblack@google.com def link_group_tag(group): 18412362Sgabeblack@google.com return 'link group: %s' % group 1858233Snate@binkert.org 1868233Snate@binkert.org @classmethod 1878233Snate@binkert.org def set_group(cls, group): 1888233Snate@binkert.org new_tag = Source.link_group_tag(group) 1898233Snate@binkert.org Source._current_group_tag = new_tag 1908233Snate@binkert.org Source.source_groups.add(group) 1918233Snate@binkert.org 1928233Snate@binkert.org def _add_link_group_tag(self): 1938233Snate@binkert.org self.tags.add(Source._current_group_tag) 1948233Snate@binkert.org 1958233Snate@binkert.org '''Add a c/c++ source file to the build''' 1968233Snate@binkert.org def __init__(self, source, tags=None, add_tags=None): 1978233Snate@binkert.org '''specify the source file, and any tags''' 1988233Snate@binkert.org super(Source, self).__init__(source, tags, add_tags) 1998233Snate@binkert.org self._add_link_group_tag() 2008233Snate@binkert.org 2018233Snate@binkert.orgclass PySource(SourceFile): 2028233Snate@binkert.org '''Add a python source file to the named package''' 2038233Snate@binkert.org invalid_sym_char = re.compile('[^A-z0-9_]') 2048233Snate@binkert.org modules = {} 2058233Snate@binkert.org tnodes = {} 2066143Snate@binkert.org symnames = {} 2076143Snate@binkert.org 2086143Snate@binkert.org def __init__(self, package, source, tags=None, add_tags=None): 2096143Snate@binkert.org '''specify the python package, the source file, and any tags''' 2106143Snate@binkert.org super(PySource, self).__init__(source, tags, add_tags) 2116143Snate@binkert.org 2129982Satgutier@umich.edu modname,ext = self.extname 2136143Snate@binkert.org assert ext == 'py' 21412302Sgabeblack@google.com 21512302Sgabeblack@google.com if package: 21612302Sgabeblack@google.com path = package.split('.') 21712302Sgabeblack@google.com else: 21812302Sgabeblack@google.com path = [] 21912302Sgabeblack@google.com 22012302Sgabeblack@google.com modpath = path[:] 22112302Sgabeblack@google.com if modname != '__init__': 22211983Sgabeblack@google.com modpath += [ modname ] 22311983Sgabeblack@google.com modpath = '.'.join(modpath) 22411983Sgabeblack@google.com 22512302Sgabeblack@google.com arcpath = path + [ self.basename ] 22612302Sgabeblack@google.com abspath = self.snode.abspath 22712302Sgabeblack@google.com if not exists(abspath): 22812302Sgabeblack@google.com abspath = self.tnode.abspath 22912302Sgabeblack@google.com 23012302Sgabeblack@google.com self.package = package 23111983Sgabeblack@google.com self.modname = modname 2326143Snate@binkert.org self.modpath = modpath 23312305Sgabeblack@google.com self.arcname = joinpath(*arcpath) 23412302Sgabeblack@google.com self.abspath = abspath 23512302Sgabeblack@google.com self.compiled = File(self.filename + 'c') 23612302Sgabeblack@google.com self.cpp = File(self.filename + '.cc') 2376143Snate@binkert.org self.symname = PySource.invalid_sym_char.sub('_', modpath) 2386143Snate@binkert.org 2396143Snate@binkert.org PySource.modules[modpath] = self 2405522Snate@binkert.org PySource.tnodes[self.tnode] = self 2416143Snate@binkert.org PySource.symnames[self.symname] = self 2426143Snate@binkert.org 2436143Snate@binkert.orgclass SimObject(PySource): 2449982Satgutier@umich.edu '''Add a SimObject python file as a python source object and add 24512302Sgabeblack@google.com it to a list of sim object modules''' 24612302Sgabeblack@google.com 24712302Sgabeblack@google.com fixed = False 2486143Snate@binkert.org modnames = [] 2496143Snate@binkert.org 2506143Snate@binkert.org def __init__(self, source, tags=None, add_tags=None): 2516143Snate@binkert.org '''Specify the source file and any tags (automatically in 2525522Snate@binkert.org the m5.objects package)''' 2535522Snate@binkert.org super(SimObject, self).__init__('m5.objects', source, tags, add_tags) 2545522Snate@binkert.org if self.fixed: 2555522Snate@binkert.org raise AttributeError, "Too late to call SimObject now." 2565604Snate@binkert.org 2575604Snate@binkert.org bisect.insort_right(SimObject.modnames, self.modname) 2586143Snate@binkert.org 2596143Snate@binkert.orgclass ProtoBuf(SourceFile): 2604762Snate@binkert.org '''Add a Protocol Buffer to build''' 2614762Snate@binkert.org 2626143Snate@binkert.org def __init__(self, source, tags=None, add_tags=None): 2636727Ssteve.reinhardt@amd.com '''Specify the source file, and any tags''' 2646727Ssteve.reinhardt@amd.com super(ProtoBuf, self).__init__(source, tags, add_tags) 2656727Ssteve.reinhardt@amd.com 2664762Snate@binkert.org # Get the file name and the extension 2676143Snate@binkert.org modname,ext = self.extname 2686143Snate@binkert.org assert ext == 'proto' 2696143Snate@binkert.org 2706143Snate@binkert.org # Currently, we stick to generating the C++ headers, so we 2716727Ssteve.reinhardt@amd.com # only need to track the source and header. 2726143Snate@binkert.org self.cc_file = File(modname + '.pb.cc') 2737674Snate@binkert.org self.hh_file = File(modname + '.pb.h') 2747674Snate@binkert.org 2755604Snate@binkert.orgclass UnitTest(object): 2766143Snate@binkert.org '''Create a UnitTest''' 2776143Snate@binkert.org 2786143Snate@binkert.org all = [] 2794762Snate@binkert.org def __init__(self, target, *sources, **kwargs): 2806143Snate@binkert.org '''Specify the target name and any sources. Sources that are 2814762Snate@binkert.org not SourceFiles are evalued with Source(). All files are 2824762Snate@binkert.org tagged with the name of the UnitTest target.''' 2834762Snate@binkert.org 2846143Snate@binkert.org srcs = SourceList() 2856143Snate@binkert.org for src in sources: 2864762Snate@binkert.org if not isinstance(src, SourceFile): 28712302Sgabeblack@google.com src = Source(src, tags=str(target)) 28812302Sgabeblack@google.com srcs.append(src) 2898233Snate@binkert.org 29012302Sgabeblack@google.com self.sources = srcs 2916143Snate@binkert.org self.target = target 2926143Snate@binkert.org self.main = kwargs.get('main', False) 2934762Snate@binkert.org self.all.append(self) 2946143Snate@binkert.org 2954762Snate@binkert.orgclass GTest(UnitTest): 2969396Sandreas.hansson@arm.com '''Create a unit test based on the google test framework.''' 2979396Sandreas.hansson@arm.com 2989396Sandreas.hansson@arm.com all = [] 29912302Sgabeblack@google.com def __init__(self, *args, **kwargs): 30012302Sgabeblack@google.com super(GTest, self).__init__(*args, **kwargs) 30112302Sgabeblack@google.com self.dir = Dir('.') 3029396Sandreas.hansson@arm.com 3039396Sandreas.hansson@arm.com# Children should have access 3049396Sandreas.hansson@arm.comExport('Source') 3059396Sandreas.hansson@arm.comExport('PySource') 3069396Sandreas.hansson@arm.comExport('SimObject') 3079396Sandreas.hansson@arm.comExport('ProtoBuf') 3089396Sandreas.hansson@arm.comExport('UnitTest') 3099930Sandreas.hansson@arm.comExport('GTest') 3109930Sandreas.hansson@arm.com 3119396Sandreas.hansson@arm.com######################################################################## 3128235Snate@binkert.org# 3138235Snate@binkert.org# Debug Flags 3146143Snate@binkert.org# 3158235Snate@binkert.orgdebug_flags = {} 3169003SAli.Saidi@ARM.comdef DebugFlag(name, desc=None): 3178235Snate@binkert.org if name in debug_flags: 3188235Snate@binkert.org raise AttributeError, "Flag %s already specified" % name 31912302Sgabeblack@google.com debug_flags[name] = (name, (), desc) 3208235Snate@binkert.org 32112302Sgabeblack@google.comdef CompoundFlag(name, flags, desc=None): 3228235Snate@binkert.org if name in debug_flags: 3238235Snate@binkert.org raise AttributeError, "Flag %s already specified" % name 32412302Sgabeblack@google.com 3258235Snate@binkert.org compound = tuple(flags) 3268235Snate@binkert.org debug_flags[name] = (name, compound, desc) 3278235Snate@binkert.org 3288235Snate@binkert.orgExport('DebugFlag') 3299003SAli.Saidi@ARM.comExport('CompoundFlag') 33012313Sgabeblack@google.com 33112313Sgabeblack@google.com######################################################################## 33212313Sgabeblack@google.com# 33312313Sgabeblack@google.com# Set some compiler variables 33412313Sgabeblack@google.com# 33512315Sgabeblack@google.com 33612371Sgabeblack@google.com# Include file paths are rooted in this directory. SCons will 33712371Sgabeblack@google.com# automatically expand '.' to refer to both the source directory and 33812371Sgabeblack@google.com# the corresponding build directory to pick up generated include 33912315Sgabeblack@google.com# files. 34012315Sgabeblack@google.comenv.Append(CPPPATH=Dir('.')) 34112371Sgabeblack@google.com 3425584Snate@binkert.orgfor extra_dir in extras_dir_list: 3434382Sbinkertn@umich.edu env.Append(CPPPATH=Dir(extra_dir)) 3444202Sbinkertn@umich.edu 3454382Sbinkertn@umich.edu# Workaround for bug in SCons version > 0.97d20071212 3464382Sbinkertn@umich.edu# Scons bug id: 2006 gem5 Bug id: 308 3479396Sandreas.hansson@arm.comfor root, dirs, files in os.walk(base_dir, topdown=True): 3485584Snate@binkert.org Dir(root[len(base_dir) + 1:]) 34912313Sgabeblack@google.com 3504382Sbinkertn@umich.edu######################################################################## 3514382Sbinkertn@umich.edu# 3524382Sbinkertn@umich.edu# Walk the tree and execute all SConscripts in subdirectories 3538232Snate@binkert.org# 3545192Ssaidi@eecs.umich.edu 3558232Snate@binkert.orghere = Dir('.').srcnode().abspath 3568232Snate@binkert.orgfor root, dirs, files in os.walk(base_dir, topdown=True): 3578232Snate@binkert.org if root == here: 3585192Ssaidi@eecs.umich.edu # we don't want to recurse back into this SConscript 3598232Snate@binkert.org continue 3605192Ssaidi@eecs.umich.edu 3615799Snate@binkert.org if 'SConscript' in files: 3628232Snate@binkert.org build_dir = joinpath(env['BUILDDIR'], root[len(base_dir) + 1:]) 3635192Ssaidi@eecs.umich.edu Source.set_group(build_dir) 3645192Ssaidi@eecs.umich.edu SConscript(joinpath(root, 'SConscript'), variant_dir=build_dir) 3655192Ssaidi@eecs.umich.edu 3668232Snate@binkert.orgfor extra_dir in extras_dir_list: 3675192Ssaidi@eecs.umich.edu prefix_len = len(dirname(extra_dir)) + 1 3688232Snate@binkert.org 3695192Ssaidi@eecs.umich.edu # Also add the corresponding build directory to pick up generated 3705192Ssaidi@eecs.umich.edu # include files. 3715192Ssaidi@eecs.umich.edu env.Append(CPPPATH=Dir(joinpath(env['BUILDDIR'], extra_dir[prefix_len:]))) 3725192Ssaidi@eecs.umich.edu 3734382Sbinkertn@umich.edu for root, dirs, files in os.walk(extra_dir, topdown=True): 3744382Sbinkertn@umich.edu # if build lives in the extras directory, don't walk down it 3754382Sbinkertn@umich.edu if 'build' in dirs: 3762667Sstever@eecs.umich.edu dirs.remove('build') 3772667Sstever@eecs.umich.edu 3782667Sstever@eecs.umich.edu if 'SConscript' in files: 3792667Sstever@eecs.umich.edu build_dir = joinpath(env['BUILDDIR'], root[prefix_len:]) 3802667Sstever@eecs.umich.edu SConscript(joinpath(root, 'SConscript'), variant_dir=build_dir) 3812667Sstever@eecs.umich.edu 3825742Snate@binkert.orgfor opt in export_vars: 3835742Snate@binkert.org env.ConfigFile(opt) 3845742Snate@binkert.org 3855793Snate@binkert.orgdef makeTheISA(source, target, env): 3868334Snate@binkert.org isas = [ src.get_contents() for src in source ] 3875793Snate@binkert.org target_isa = env['TARGET_ISA'] 3885793Snate@binkert.org def define(isa): 3895793Snate@binkert.org return isa.upper() + '_ISA' 3904382Sbinkertn@umich.edu 3914762Snate@binkert.org def namespace(isa): 3925344Sstever@gmail.com return isa[0].upper() + isa[1:].lower() + 'ISA' 3934382Sbinkertn@umich.edu 3945341Sstever@gmail.com 3955742Snate@binkert.org code = code_formatter() 3965742Snate@binkert.org code('''\ 3975742Snate@binkert.org#ifndef __CONFIG_THE_ISA_HH__ 3985742Snate@binkert.org#define __CONFIG_THE_ISA_HH__ 3995742Snate@binkert.org 4004762Snate@binkert.org''') 4015742Snate@binkert.org 4025742Snate@binkert.org # create defines for the preprocessing and compile-time determination 40311984Sgabeblack@google.com for i,isa in enumerate(isas): 4047722Sgblack@eecs.umich.edu code('#define $0 $1', define(isa), i + 1) 4055742Snate@binkert.org code() 4065742Snate@binkert.org 4075742Snate@binkert.org # create an enum for any run-time determination of the ISA, we 4089930Sandreas.hansson@arm.com # reuse the same name as the namespaces 4099930Sandreas.hansson@arm.com code('enum class Arch {') 4109930Sandreas.hansson@arm.com for i,isa in enumerate(isas): 4119930Sandreas.hansson@arm.com if i + 1 == len(isas): 4129930Sandreas.hansson@arm.com code(' $0 = $1', namespace(isa), define(isa)) 4135742Snate@binkert.org else: 4148242Sbradley.danofsky@amd.com code(' $0 = $1,', namespace(isa), define(isa)) 4158242Sbradley.danofsky@amd.com code('};') 4168242Sbradley.danofsky@amd.com 4178242Sbradley.danofsky@amd.com code(''' 4185341Sstever@gmail.com 4195742Snate@binkert.org#define THE_ISA ${{define(target_isa)}} 4207722Sgblack@eecs.umich.edu#define TheISA ${{namespace(target_isa)}} 4214773Snate@binkert.org#define THE_ISA_STR "${{target_isa}}" 4226108Snate@binkert.org 4231858SN/A#endif // __CONFIG_THE_ISA_HH__''') 4241085SN/A 4256658Snate@binkert.org code.write(str(target[0])) 4266658Snate@binkert.org 4277673Snate@binkert.orgenv.Command('config/the_isa.hh', map(Value, all_isa_list), 4286658Snate@binkert.org MakeAction(makeTheISA, Transform("CFG ISA", 0))) 4296658Snate@binkert.org 43011308Santhony.gutierrez@amd.comdef makeTheGPUISA(source, target, env): 4316658Snate@binkert.org isas = [ src.get_contents() for src in source ] 43211308Santhony.gutierrez@amd.com target_gpu_isa = env['TARGET_GPU_ISA'] 4336658Snate@binkert.org def define(isa): 4346658Snate@binkert.org return isa.upper() + '_ISA' 4357673Snate@binkert.org 4367673Snate@binkert.org def namespace(isa): 4377673Snate@binkert.org return isa[0].upper() + isa[1:].lower() + 'ISA' 4387673Snate@binkert.org 4397673Snate@binkert.org 4407673Snate@binkert.org code = code_formatter() 4417673Snate@binkert.org code('''\ 44210467Sandreas.hansson@arm.com#ifndef __CONFIG_THE_GPU_ISA_HH__ 4436658Snate@binkert.org#define __CONFIG_THE_GPU_ISA_HH__ 4447673Snate@binkert.org 44510467Sandreas.hansson@arm.com''') 44610467Sandreas.hansson@arm.com 44710467Sandreas.hansson@arm.com # create defines for the preprocessing and compile-time determination 44810467Sandreas.hansson@arm.com for i,isa in enumerate(isas): 44910467Sandreas.hansson@arm.com code('#define $0 $1', define(isa), i + 1) 45010467Sandreas.hansson@arm.com code() 45110467Sandreas.hansson@arm.com 45210467Sandreas.hansson@arm.com # create an enum for any run-time determination of the ISA, we 45310467Sandreas.hansson@arm.com # reuse the same name as the namespaces 45410467Sandreas.hansson@arm.com code('enum class GPUArch {') 45510467Sandreas.hansson@arm.com for i,isa in enumerate(isas): 4567673Snate@binkert.org if i + 1 == len(isas): 4577673Snate@binkert.org code(' $0 = $1', namespace(isa), define(isa)) 4587673Snate@binkert.org else: 4597673Snate@binkert.org code(' $0 = $1,', namespace(isa), define(isa)) 4607673Snate@binkert.org code('};') 4619048SAli.Saidi@ARM.com 4627673Snate@binkert.org code(''' 4637673Snate@binkert.org 4647673Snate@binkert.org#define THE_GPU_ISA ${{define(target_gpu_isa)}} 4657673Snate@binkert.org#define TheGpuISA ${{namespace(target_gpu_isa)}} 4666658Snate@binkert.org#define THE_GPU_ISA_STR "${{target_gpu_isa}}" 4677756SAli.Saidi@ARM.com 4687816Ssteve.reinhardt@amd.com#endif // __CONFIG_THE_GPU_ISA_HH__''') 4696658Snate@binkert.org 47011308Santhony.gutierrez@amd.com code.write(str(target[0])) 47111308Santhony.gutierrez@amd.com 47211308Santhony.gutierrez@amd.comenv.Command('config/the_gpu_isa.hh', map(Value, all_gpu_isa_list), 47311308Santhony.gutierrez@amd.com MakeAction(makeTheGPUISA, Transform("CFG ISA", 0))) 47411308Santhony.gutierrez@amd.com 47511308Santhony.gutierrez@amd.com######################################################################## 47611308Santhony.gutierrez@amd.com# 47711308Santhony.gutierrez@amd.com# Prevent any SimObjects from being added after this point, they 47811308Santhony.gutierrez@amd.com# should all have been added in the SConscripts above 47911308Santhony.gutierrez@amd.com# 48011308Santhony.gutierrez@amd.comSimObject.fixed = True 48111308Santhony.gutierrez@amd.com 48211308Santhony.gutierrez@amd.comclass DictImporter(object): 48311308Santhony.gutierrez@amd.com '''This importer takes a dictionary of arbitrary module names that 48411308Santhony.gutierrez@amd.com map to arbitrary filenames.''' 48511308Santhony.gutierrez@amd.com def __init__(self, modules): 48611308Santhony.gutierrez@amd.com self.modules = modules 48711308Santhony.gutierrez@amd.com self.installed = set() 48811308Santhony.gutierrez@amd.com 48911308Santhony.gutierrez@amd.com def __del__(self): 49011308Santhony.gutierrez@amd.com self.unload() 49111308Santhony.gutierrez@amd.com 49211308Santhony.gutierrez@amd.com def unload(self): 49311308Santhony.gutierrez@amd.com import sys 49411308Santhony.gutierrez@amd.com for module in self.installed: 49511308Santhony.gutierrez@amd.com del sys.modules[module] 49611308Santhony.gutierrez@amd.com self.installed = set() 49711308Santhony.gutierrez@amd.com 49811308Santhony.gutierrez@amd.com def find_module(self, fullname, path): 49911308Santhony.gutierrez@amd.com if fullname == 'm5.defines': 50011308Santhony.gutierrez@amd.com return self 50111308Santhony.gutierrez@amd.com 50211308Santhony.gutierrez@amd.com if fullname == 'm5.objects': 50311308Santhony.gutierrez@amd.com return self 50411308Santhony.gutierrez@amd.com 50511308Santhony.gutierrez@amd.com if fullname.startswith('_m5'): 50611308Santhony.gutierrez@amd.com return None 50711308Santhony.gutierrez@amd.com 50811308Santhony.gutierrez@amd.com source = self.modules.get(fullname, None) 50911308Santhony.gutierrez@amd.com if source is not None and fullname.startswith('m5.objects'): 51011308Santhony.gutierrez@amd.com return self 51111308Santhony.gutierrez@amd.com 51211308Santhony.gutierrez@amd.com return None 51311308Santhony.gutierrez@amd.com 51411308Santhony.gutierrez@amd.com def load_module(self, fullname): 5154382Sbinkertn@umich.edu mod = imp.new_module(fullname) 5164382Sbinkertn@umich.edu sys.modules[fullname] = mod 5174762Snate@binkert.org self.installed.add(fullname) 5184762Snate@binkert.org 5194762Snate@binkert.org mod.__loader__ = self 5206654Snate@binkert.org if fullname == 'm5.objects': 5216654Snate@binkert.org mod.__path__ = fullname.split('.') 5225517Snate@binkert.org return mod 5235517Snate@binkert.org 5245517Snate@binkert.org if fullname == 'm5.defines': 5255517Snate@binkert.org mod.__dict__['buildEnv'] = m5.util.SmartDict(build_env) 5265517Snate@binkert.org return mod 5275517Snate@binkert.org 5285517Snate@binkert.org source = self.modules[fullname] 5295517Snate@binkert.org if source.modname == '__init__': 5305517Snate@binkert.org mod.__path__ = source.modpath 5315517Snate@binkert.org mod.__file__ = source.abspath 5325517Snate@binkert.org 5335517Snate@binkert.org exec file(source.abspath, 'r') in mod.__dict__ 5345517Snate@binkert.org 5355517Snate@binkert.org return mod 5365517Snate@binkert.org 5375517Snate@binkert.orgimport m5.SimObject 5385517Snate@binkert.orgimport m5.params 5396654Snate@binkert.orgfrom m5.util import code_formatter 5405517Snate@binkert.org 5415517Snate@binkert.orgm5.SimObject.clear() 5425517Snate@binkert.orgm5.params.clear() 5435517Snate@binkert.org 5445517Snate@binkert.org# install the python importer so we can grab stuff from the source 54511802Sandreas.sandberg@arm.com# tree itself. We can't have SimObjects added after this point or 5465517Snate@binkert.org# else we won't know about them for the rest of the stuff. 5475517Snate@binkert.orgimporter = DictImporter(PySource.modules) 5486143Snate@binkert.orgsys.meta_path[0:0] = [ importer ] 5496654Snate@binkert.org 5505517Snate@binkert.org# import all sim objects so we can populate the all_objects list 5515517Snate@binkert.org# make sure that we're working with a list, then let's sort it 5525517Snate@binkert.orgfor modname in SimObject.modnames: 5535517Snate@binkert.org exec('from m5.objects import %s' % modname) 5545517Snate@binkert.org 5555517Snate@binkert.org# we need to unload all of the currently imported modules so that they 5565517Snate@binkert.org# will be re-imported the next time the sconscript is run 5575517Snate@binkert.orgimporter.unload() 5585517Snate@binkert.orgsys.meta_path.remove(importer) 5595517Snate@binkert.org 5605517Snate@binkert.orgsim_objects = m5.SimObject.allClasses 5615517Snate@binkert.orgall_enums = m5.params.allEnums 5625517Snate@binkert.org 5635517Snate@binkert.orgfor name,obj in sorted(sim_objects.iteritems()): 5646654Snate@binkert.org for param in obj._params.local.values(): 5656654Snate@binkert.org # load the ptype attribute now because it depends on the 5665517Snate@binkert.org # current version of SimObject.allClasses, but when scons 5675517Snate@binkert.org # actually uses the value, all versions of 5686143Snate@binkert.org # SimObject.allClasses will have been loaded 5696143Snate@binkert.org param.ptype 5706143Snate@binkert.org 5716727Ssteve.reinhardt@amd.com######################################################################## 5725517Snate@binkert.org# 5736727Ssteve.reinhardt@amd.com# calculate extra dependencies 5745517Snate@binkert.org# 5755517Snate@binkert.orgmodule_depends = ["m5", "m5.SimObject", "m5.params"] 5765517Snate@binkert.orgdepends = [ PySource.modules[dep].snode for dep in module_depends ] 5776654Snate@binkert.orgdepends.sort(key = lambda x: x.name) 5786654Snate@binkert.org 5797673Snate@binkert.org######################################################################## 5806654Snate@binkert.org# 5816654Snate@binkert.org# Commands for the basic automatically generated python files 5826654Snate@binkert.org# 5836654Snate@binkert.org 5845517Snate@binkert.org# Generate Python file containing a dict specifying the current 5855517Snate@binkert.org# buildEnv flags. 5865517Snate@binkert.orgdef makeDefinesPyFile(target, source, env): 5876143Snate@binkert.org build_env = source[0].get_contents() 5885517Snate@binkert.org 5894762Snate@binkert.org code = code_formatter() 5905517Snate@binkert.org code(""" 5915517Snate@binkert.orgimport _m5.core 5926143Snate@binkert.orgimport m5.util 5936143Snate@binkert.org 5945517Snate@binkert.orgbuildEnv = m5.util.SmartDict($build_env) 5955517Snate@binkert.org 5965517Snate@binkert.orgcompileDate = _m5.core.compileDate 5975517Snate@binkert.org_globals = globals() 5985517Snate@binkert.orgfor key,val in _m5.core.__dict__.iteritems(): 5995517Snate@binkert.org if key.startswith('flag_'): 6005517Snate@binkert.org flag = key[5:] 6015517Snate@binkert.org _globals[flag] = val 6025517Snate@binkert.orgdel _globals 6036143Snate@binkert.org""") 6045517Snate@binkert.org code.write(target[0].abspath) 6056654Snate@binkert.org 6066654Snate@binkert.orgdefines_info = Value(build_env) 6076654Snate@binkert.org# Generate a file with all of the compile options in it 6086654Snate@binkert.orgenv.Command('python/m5/defines.py', defines_info, 6096654Snate@binkert.org MakeAction(makeDefinesPyFile, Transform("DEFINES", 0))) 6106654Snate@binkert.orgPySource('m5', 'python/m5/defines.py') 6114762Snate@binkert.org 6124762Snate@binkert.org# Generate python file containing info about the M5 source code 6134762Snate@binkert.orgdef makeInfoPyFile(target, source, env): 6144762Snate@binkert.org code = code_formatter() 6154762Snate@binkert.org for src in source: 6167675Snate@binkert.org data = ''.join(file(src.srcnode().abspath, 'r').xreadlines()) 61710584Sandreas.hansson@arm.com code('$src = ${{repr(data)}}') 6184762Snate@binkert.org code.write(str(target[0])) 6194762Snate@binkert.org 6204762Snate@binkert.org# Generate a file that wraps the basic top level files 6214762Snate@binkert.orgenv.Command('python/m5/info.py', 6224382Sbinkertn@umich.edu [ '#/COPYING', '#/LICENSE', '#/README', ], 6234382Sbinkertn@umich.edu MakeAction(makeInfoPyFile, Transform("INFO"))) 6245517Snate@binkert.orgPySource('m5', 'python/m5/info.py') 6256654Snate@binkert.org 6265517Snate@binkert.org######################################################################## 6278126Sgblack@eecs.umich.edu# 6286654Snate@binkert.org# Create all of the SimObject param headers and enum headers 6297673Snate@binkert.org# 6306654Snate@binkert.org 63111802Sandreas.sandberg@arm.comdef createSimObjectParamStruct(target, source, env): 6326654Snate@binkert.org assert len(target) == 1 and len(source) == 1 6336654Snate@binkert.org 6346654Snate@binkert.org name = source[0].get_text_contents() 6356654Snate@binkert.org obj = sim_objects[name] 63611802Sandreas.sandberg@arm.com 6376669Snate@binkert.org code = code_formatter() 63811802Sandreas.sandberg@arm.com obj.cxx_param_decl(code) 6396669Snate@binkert.org code.write(target[0].abspath) 6406669Snate@binkert.org 6416669Snate@binkert.orgdef createSimObjectCxxConfig(is_header): 6426669Snate@binkert.org def body(target, source, env): 6436654Snate@binkert.org assert len(target) == 1 and len(source) == 1 6447673Snate@binkert.org 6455517Snate@binkert.org name = str(source[0].get_contents()) 6468126Sgblack@eecs.umich.edu obj = sim_objects[name] 6475798Snate@binkert.org 6487756SAli.Saidi@ARM.com code = code_formatter() 6497816Ssteve.reinhardt@amd.com obj.cxx_config_param_file(code, is_header) 6505798Snate@binkert.org code.write(target[0].abspath) 6515798Snate@binkert.org return body 6525517Snate@binkert.org 6535517Snate@binkert.orgdef createEnumStrings(target, source, env): 6547673Snate@binkert.org assert len(target) == 1 and len(source) == 2 6555517Snate@binkert.org 6565517Snate@binkert.org name = source[0].get_text_contents() 6577673Snate@binkert.org use_python = source[1].read() 6587673Snate@binkert.org obj = all_enums[name] 6595517Snate@binkert.org 6605798Snate@binkert.org code = code_formatter() 6615798Snate@binkert.org obj.cxx_def(code) 6628333Snate@binkert.org if use_python: 6637816Ssteve.reinhardt@amd.com obj.pybind_def(code) 6645798Snate@binkert.org code.write(target[0].abspath) 6655798Snate@binkert.org 6664762Snate@binkert.orgdef createEnumDecls(target, source, env): 6674762Snate@binkert.org assert len(target) == 1 and len(source) == 1 6684762Snate@binkert.org 6694762Snate@binkert.org name = source[0].get_text_contents() 6704762Snate@binkert.org obj = all_enums[name] 6718596Ssteve.reinhardt@amd.com 6725517Snate@binkert.org code = code_formatter() 6735517Snate@binkert.org obj.cxx_decl(code) 67411997Sgabeblack@google.com code.write(target[0].abspath) 6755517Snate@binkert.org 6765517Snate@binkert.orgdef createSimObjectPyBindWrapper(target, source, env): 6777673Snate@binkert.org name = source[0].get_text_contents() 6788596Ssteve.reinhardt@amd.com obj = sim_objects[name] 6797673Snate@binkert.org 6805517Snate@binkert.org code = code_formatter() 68110458Sandreas.hansson@arm.com obj.pybind_decl(code) 68210458Sandreas.hansson@arm.com code.write(target[0].abspath) 68310458Sandreas.hansson@arm.com 68410458Sandreas.hansson@arm.com# Generate all of the SimObject param C++ struct header files 68510458Sandreas.hansson@arm.comparams_hh_files = [] 68610458Sandreas.hansson@arm.comfor name,simobj in sorted(sim_objects.iteritems()): 68710458Sandreas.hansson@arm.com py_source = PySource.modules[simobj.__module__] 68810458Sandreas.hansson@arm.com extra_deps = [ py_source.tnode ] 68910458Sandreas.hansson@arm.com 69010458Sandreas.hansson@arm.com hh_file = File('params/%s.hh' % name) 69110458Sandreas.hansson@arm.com params_hh_files.append(hh_file) 69210458Sandreas.hansson@arm.com env.Command(hh_file, Value(name), 6935517Snate@binkert.org MakeAction(createSimObjectParamStruct, Transform("SO PARAM"))) 69411996Sgabeblack@google.com env.Depends(hh_file, depends + extra_deps) 6955517Snate@binkert.org 69611997Sgabeblack@google.com# C++ parameter description files 69711996Sgabeblack@google.comif GetOption('with_cxx_config'): 6985517Snate@binkert.org for name,simobj in sorted(sim_objects.iteritems()): 6995517Snate@binkert.org py_source = PySource.modules[simobj.__module__] 7007673Snate@binkert.org extra_deps = [ py_source.tnode ] 7017673Snate@binkert.org 70211996Sgabeblack@google.com cxx_config_hh_file = File('cxx_config/%s.hh' % name) 70311988Sandreas.sandberg@arm.com cxx_config_cc_file = File('cxx_config/%s.cc' % name) 7047673Snate@binkert.org env.Command(cxx_config_hh_file, Value(name), 7055517Snate@binkert.org MakeAction(createSimObjectCxxConfig(True), 7068596Ssteve.reinhardt@amd.com Transform("CXXCPRHH"))) 7075517Snate@binkert.org env.Command(cxx_config_cc_file, Value(name), 7085517Snate@binkert.org MakeAction(createSimObjectCxxConfig(False), 70911997Sgabeblack@google.com Transform("CXXCPRCC"))) 7105517Snate@binkert.org env.Depends(cxx_config_hh_file, depends + extra_deps + 7115517Snate@binkert.org [File('params/%s.hh' % name), File('sim/cxx_config.hh')]) 7127673Snate@binkert.org env.Depends(cxx_config_cc_file, depends + extra_deps + 7137673Snate@binkert.org [cxx_config_hh_file]) 7147673Snate@binkert.org Source(cxx_config_cc_file) 7155517Snate@binkert.org 71611988Sandreas.sandberg@arm.com cxx_config_init_cc_file = File('cxx_config/init.cc') 71711997Sgabeblack@google.com 7188596Ssteve.reinhardt@amd.com def createCxxConfigInitCC(target, source, env): 7198596Ssteve.reinhardt@amd.com assert len(target) == 1 and len(source) == 1 7208596Ssteve.reinhardt@amd.com 72111988Sandreas.sandberg@arm.com code = code_formatter() 7228596Ssteve.reinhardt@amd.com 7238596Ssteve.reinhardt@amd.com for name,simobj in sorted(sim_objects.iteritems()): 7248596Ssteve.reinhardt@amd.com if not hasattr(simobj, 'abstract') or not simobj.abstract: 7254762Snate@binkert.org code('#include "cxx_config/${name}.hh"') 7266143Snate@binkert.org code() 7276143Snate@binkert.org code('void cxxConfigInit()') 7286143Snate@binkert.org code('{') 7294762Snate@binkert.org code.indent() 7304762Snate@binkert.org for name,simobj in sorted(sim_objects.iteritems()): 7314762Snate@binkert.org not_abstract = not hasattr(simobj, 'abstract') or \ 7327756SAli.Saidi@ARM.com not simobj.abstract 7338596Ssteve.reinhardt@amd.com if not_abstract and 'type' in simobj.__dict__: 7344762Snate@binkert.org code('cxx_config_directory["${name}"] = ' 7354762Snate@binkert.org '${name}CxxConfigParams::makeDirectoryEntry();') 73610458Sandreas.hansson@arm.com code.dedent() 73710458Sandreas.hansson@arm.com code('}') 73810458Sandreas.hansson@arm.com code.write(target[0].abspath) 73910458Sandreas.hansson@arm.com 74010458Sandreas.hansson@arm.com py_source = PySource.modules[simobj.__module__] 74110458Sandreas.hansson@arm.com extra_deps = [ py_source.tnode ] 74210458Sandreas.hansson@arm.com env.Command(cxx_config_init_cc_file, Value(name), 74310458Sandreas.hansson@arm.com MakeAction(createCxxConfigInitCC, Transform("CXXCINIT"))) 74410458Sandreas.hansson@arm.com cxx_param_hh_files = ["cxx_config/%s.hh" % simobj 74510458Sandreas.hansson@arm.com for name,simobj in sorted(sim_objects.iteritems()) 74610458Sandreas.hansson@arm.com if not hasattr(simobj, 'abstract') or not simobj.abstract] 74710458Sandreas.hansson@arm.com Depends(cxx_config_init_cc_file, cxx_param_hh_files + 74810458Sandreas.hansson@arm.com [File('sim/cxx_config.hh')]) 74910458Sandreas.hansson@arm.com Source(cxx_config_init_cc_file) 75010458Sandreas.hansson@arm.com 75110458Sandreas.hansson@arm.com# Generate all enum header files 75210458Sandreas.hansson@arm.comfor name,enum in sorted(all_enums.iteritems()): 75310458Sandreas.hansson@arm.com py_source = PySource.modules[enum.__module__] 75410458Sandreas.hansson@arm.com extra_deps = [ py_source.tnode ] 75510458Sandreas.hansson@arm.com 75610458Sandreas.hansson@arm.com cc_file = File('enums/%s.cc' % name) 75710458Sandreas.hansson@arm.com env.Command(cc_file, [Value(name), Value(env['USE_PYTHON'])], 75810458Sandreas.hansson@arm.com MakeAction(createEnumStrings, Transform("ENUM STR"))) 75910458Sandreas.hansson@arm.com env.Depends(cc_file, depends + extra_deps) 76010458Sandreas.hansson@arm.com Source(cc_file) 76110458Sandreas.hansson@arm.com 76210458Sandreas.hansson@arm.com hh_file = File('enums/%s.hh' % name) 76310458Sandreas.hansson@arm.com env.Command(hh_file, Value(name), 76410458Sandreas.hansson@arm.com MakeAction(createEnumDecls, Transform("ENUMDECL"))) 76510458Sandreas.hansson@arm.com env.Depends(hh_file, depends + extra_deps) 76610458Sandreas.hansson@arm.com 76710458Sandreas.hansson@arm.com# Generate SimObject Python bindings wrapper files 76810458Sandreas.hansson@arm.comif env['USE_PYTHON']: 76910458Sandreas.hansson@arm.com for name,simobj in sorted(sim_objects.iteritems()): 77010458Sandreas.hansson@arm.com py_source = PySource.modules[simobj.__module__] 77110458Sandreas.hansson@arm.com extra_deps = [ py_source.tnode ] 77210458Sandreas.hansson@arm.com cc_file = File('python/_m5/param_%s.cc' % name) 77310458Sandreas.hansson@arm.com env.Command(cc_file, Value(name), 77410458Sandreas.hansson@arm.com MakeAction(createSimObjectPyBindWrapper, 77510458Sandreas.hansson@arm.com Transform("SO PyBind"))) 77610458Sandreas.hansson@arm.com env.Depends(cc_file, depends + extra_deps) 77710458Sandreas.hansson@arm.com Source(cc_file) 77810458Sandreas.hansson@arm.com 77910458Sandreas.hansson@arm.com# Build all protocol buffers if we have got protoc and protobuf available 78010458Sandreas.hansson@arm.comif env['HAVE_PROTOBUF']: 78110458Sandreas.hansson@arm.com for proto in ProtoBuf.all: 78210458Sandreas.hansson@arm.com # Use both the source and header as the target, and the .proto 78310458Sandreas.hansson@arm.com # file as the source. When executing the protoc compiler, also 78410458Sandreas.hansson@arm.com # specify the proto_path to avoid having the generated files 78510584Sandreas.hansson@arm.com # include the path. 78610458Sandreas.hansson@arm.com env.Command([proto.cc_file, proto.hh_file], proto.tnode, 78710458Sandreas.hansson@arm.com MakeAction('$PROTOC --cpp_out ${TARGET.dir} ' 78810458Sandreas.hansson@arm.com '--proto_path ${SOURCE.dir} $SOURCE', 78910458Sandreas.hansson@arm.com Transform("PROTOC"))) 79010458Sandreas.hansson@arm.com 7914762Snate@binkert.org # Add the C++ source file 7926143Snate@binkert.org Source(proto.cc_file, tags=proto.tags) 7936143Snate@binkert.orgelif ProtoBuf.all: 7946143Snate@binkert.org print 'Got protobuf to build, but lacks support!' 7954762Snate@binkert.org Exit(1) 7964762Snate@binkert.org 79711996Sgabeblack@google.com# 7987816Ssteve.reinhardt@amd.com# Handle debug flags 7994762Snate@binkert.org# 8004762Snate@binkert.orgdef makeDebugFlagCC(target, source, env): 8014762Snate@binkert.org assert(len(target) == 1 and len(source) == 1) 8024762Snate@binkert.org 8037756SAli.Saidi@ARM.com code = code_formatter() 8048596Ssteve.reinhardt@amd.com 8054762Snate@binkert.org # delay definition of CompoundFlags until after all the definition 8064762Snate@binkert.org # of all constituent SimpleFlags 80711988Sandreas.sandberg@arm.com comp_code = code_formatter() 80811988Sandreas.sandberg@arm.com 80911988Sandreas.sandberg@arm.com # file header 81011988Sandreas.sandberg@arm.com code(''' 81111988Sandreas.sandberg@arm.com/* 81211988Sandreas.sandberg@arm.com * DO NOT EDIT THIS FILE! Automatically generated by SCons. 81311988Sandreas.sandberg@arm.com */ 81411988Sandreas.sandberg@arm.com 81511988Sandreas.sandberg@arm.com#include "base/debug.hh" 81611988Sandreas.sandberg@arm.com 81711988Sandreas.sandberg@arm.comnamespace Debug { 8184382Sbinkertn@umich.edu 8199396Sandreas.hansson@arm.com''') 8209396Sandreas.hansson@arm.com 8219396Sandreas.hansson@arm.com for name, flag in sorted(source[0].read().iteritems()): 8229396Sandreas.hansson@arm.com n, compound, desc = flag 8239396Sandreas.hansson@arm.com assert n == name 8249396Sandreas.hansson@arm.com 8259396Sandreas.hansson@arm.com if not compound: 8269396Sandreas.hansson@arm.com code('SimpleFlag $name("$name", "$desc");') 8279396Sandreas.hansson@arm.com else: 8289396Sandreas.hansson@arm.com comp_code('CompoundFlag $name("$name", "$desc",') 8299396Sandreas.hansson@arm.com comp_code.indent() 8309396Sandreas.hansson@arm.com last = len(compound) - 1 8319396Sandreas.hansson@arm.com for i,flag in enumerate(compound): 83212302Sgabeblack@google.com if i != last: 8339396Sandreas.hansson@arm.com comp_code('&$flag,') 8349396Sandreas.hansson@arm.com else: 8359396Sandreas.hansson@arm.com comp_code('&$flag);') 8369396Sandreas.hansson@arm.com comp_code.dedent() 8378232Snate@binkert.org 8388232Snate@binkert.org code.append(comp_code) 8398232Snate@binkert.org code() 8408232Snate@binkert.org code('} // namespace Debug') 8418232Snate@binkert.org 8426229Snate@binkert.org code.write(str(target[0])) 84310455SCurtis.Dunham@arm.com 8446229Snate@binkert.orgdef makeDebugFlagHH(target, source, env): 84510455SCurtis.Dunham@arm.com assert(len(target) == 1 and len(source) == 1) 84610455SCurtis.Dunham@arm.com 84710455SCurtis.Dunham@arm.com val = eval(source[0].get_contents()) 8485517Snate@binkert.org name, compound, desc = val 8495517Snate@binkert.org 8507673Snate@binkert.org code = code_formatter() 8515517Snate@binkert.org 85210455SCurtis.Dunham@arm.com # file header boilerplate 8535517Snate@binkert.org code('''\ 8545517Snate@binkert.org/* 8558232Snate@binkert.org * DO NOT EDIT THIS FILE! Automatically generated by SCons. 85610455SCurtis.Dunham@arm.com */ 85710455SCurtis.Dunham@arm.com 85810455SCurtis.Dunham@arm.com#ifndef __DEBUG_${name}_HH__ 8597673Snate@binkert.org#define __DEBUG_${name}_HH__ 8607673Snate@binkert.org 86110455SCurtis.Dunham@arm.comnamespace Debug { 86210455SCurtis.Dunham@arm.com''') 86310455SCurtis.Dunham@arm.com 8645517Snate@binkert.org if compound: 86510455SCurtis.Dunham@arm.com code('class CompoundFlag;') 86610455SCurtis.Dunham@arm.com code('class SimpleFlag;') 86710455SCurtis.Dunham@arm.com 86810455SCurtis.Dunham@arm.com if compound: 86910455SCurtis.Dunham@arm.com code('extern CompoundFlag $name;') 87010455SCurtis.Dunham@arm.com for flag in compound: 87110455SCurtis.Dunham@arm.com code('extern SimpleFlag $flag;') 87210455SCurtis.Dunham@arm.com else: 87310685Sandreas.hansson@arm.com code('extern SimpleFlag $name;') 87410455SCurtis.Dunham@arm.com 87510685Sandreas.hansson@arm.com code(''' 87610455SCurtis.Dunham@arm.com} 8775517Snate@binkert.org 87810455SCurtis.Dunham@arm.com#endif // __DEBUG_${name}_HH__ 8798232Snate@binkert.org''') 8808232Snate@binkert.org 8815517Snate@binkert.org code.write(str(target[0])) 8827673Snate@binkert.org 8835517Snate@binkert.orgfor name,flag in sorted(debug_flags.iteritems()): 8848232Snate@binkert.org n, compound, desc = flag 8858232Snate@binkert.org assert n == name 8865517Snate@binkert.org 8878232Snate@binkert.org hh_file = 'debug/%s.hh' % name 8888232Snate@binkert.org env.Command(hh_file, Value(flag), 8898232Snate@binkert.org MakeAction(makeDebugFlagHH, Transform("TRACING", 0))) 8907673Snate@binkert.org 8915517Snate@binkert.orgenv.Command('debug/flags.cc', Value(debug_flags), 8925517Snate@binkert.org MakeAction(makeDebugFlagCC, Transform("TRACING", 0))) 8937673Snate@binkert.orgSource('debug/flags.cc') 8945517Snate@binkert.org 89510455SCurtis.Dunham@arm.com# version tags 8965517Snate@binkert.orgtags = \ 8975517Snate@binkert.orgenv.Command('sim/tags.cc', None, 8988232Snate@binkert.org MakeAction('util/cpt_upgrader.py --get-cc-file > $TARGET', 8998232Snate@binkert.org Transform("VER TAGS"))) 9005517Snate@binkert.orgenv.AlwaysBuild(tags) 9018232Snate@binkert.org 9028232Snate@binkert.org# Embed python files. All .py files that have been indicated by a 9035517Snate@binkert.org# PySource() call in a SConscript need to be embedded into the M5 9048232Snate@binkert.org# library. To do that, we compile the file to byte code, marshal the 9058232Snate@binkert.org# byte code, compress it, and then generate a c++ file that 9068232Snate@binkert.org# inserts the result into an array. 9075517Snate@binkert.orgdef embedPyFile(target, source, env): 9088232Snate@binkert.org def c_str(string): 9098232Snate@binkert.org if string is None: 9108232Snate@binkert.org return "0" 9118232Snate@binkert.org return '"%s"' % string 9128232Snate@binkert.org 9138232Snate@binkert.org '''Action function to compile a .py into a code object, marshal 9145517Snate@binkert.org it, compress it, and stick it into an asm file so the code appears 9158232Snate@binkert.org as just bytes with a label in the data section''' 9168232Snate@binkert.org 9175517Snate@binkert.org src = file(str(source[0]), 'r').read() 9188232Snate@binkert.org 9197673Snate@binkert.org pysource = PySource.tnodes[source[0]] 9205517Snate@binkert.org compiled = compile(src, pysource.abspath, 'exec') 9217673Snate@binkert.org marshalled = marshal.dumps(compiled) 9225517Snate@binkert.org compressed = zlib.compress(marshalled) 9238232Snate@binkert.org data = compressed 9248232Snate@binkert.org sym = pysource.symname 9258232Snate@binkert.org 9265192Ssaidi@eecs.umich.edu code = code_formatter() 92710454SCurtis.Dunham@arm.com code('''\ 92810454SCurtis.Dunham@arm.com#include "sim/init.hh" 9298232Snate@binkert.org 93010455SCurtis.Dunham@arm.comnamespace { 93110455SCurtis.Dunham@arm.com 93210455SCurtis.Dunham@arm.comconst uint8_t data_${sym}[] = { 93310455SCurtis.Dunham@arm.com''') 9345192Ssaidi@eecs.umich.edu code.indent() 93511077SCurtis.Dunham@arm.com step = 16 93611330SCurtis.Dunham@arm.com for i in xrange(0, len(data), step): 93711077SCurtis.Dunham@arm.com x = array.array('B', data[i:i+step]) 93811077SCurtis.Dunham@arm.com code(''.join('%d,' % d for d in x)) 93911077SCurtis.Dunham@arm.com code.dedent() 94011330SCurtis.Dunham@arm.com 94111077SCurtis.Dunham@arm.com code('''}; 9427674Snate@binkert.org 9435522Snate@binkert.orgEmbeddedPython embedded_${sym}( 9445522Snate@binkert.org ${{c_str(pysource.arcname)}}, 9457674Snate@binkert.org ${{c_str(pysource.abspath)}}, 9467674Snate@binkert.org ${{c_str(pysource.modpath)}}, 9477674Snate@binkert.org data_${sym}, 9487674Snate@binkert.org ${{len(data)}}, 9497674Snate@binkert.org ${{len(marshalled)}}); 9507674Snate@binkert.org 9517674Snate@binkert.org} // anonymous namespace 9527674Snate@binkert.org''') 9535522Snate@binkert.org code.write(str(target[0])) 9545522Snate@binkert.org 9555522Snate@binkert.orgfor source in PySource.all: 9565517Snate@binkert.org env.Command(source.cpp, source.tnode, 9575522Snate@binkert.org MakeAction(embedPyFile, Transform("EMBED PY"))) 9585517Snate@binkert.org Source(source.cpp, tags=source.tags, add_tags='python') 9596143Snate@binkert.org 9606727Ssteve.reinhardt@amd.com######################################################################## 9615522Snate@binkert.org# 9625522Snate@binkert.org# Define binaries. Each different build type (debug, opt, etc.) gets 9635522Snate@binkert.org# a slightly different build environment. 9647674Snate@binkert.org# 9655517Snate@binkert.org 9667673Snate@binkert.org# List of constructed environments to pass back to SConstruct 9677673Snate@binkert.orgdate_source = Source('base/date.cc', tags=[]) 9687674Snate@binkert.org 9697673Snate@binkert.org# Function to create a new build environment as clone of current 9707674Snate@binkert.org# environment 'env' with modified object suffix and optional stripped 9717674Snate@binkert.org# binary. Additional keyword arguments are appended to corresponding 9728946Sandreas.hansson@arm.com# build environment vars. 9737674Snate@binkert.orgdef makeEnv(env, label, objsfx, strip=False, disable_partial=False, **kwargs): 9747674Snate@binkert.org # SCons doesn't know to append a library suffix when there is a '.' in the 9757674Snate@binkert.org # name. Use '_' instead. 9765522Snate@binkert.org libname = 'gem5_' + label 9775522Snate@binkert.org exename = 'gem5.' + label 9787674Snate@binkert.org secondary_exename = 'm5.' + label 9797674Snate@binkert.org 98011308Santhony.gutierrez@amd.com new_env = env.Clone(OBJSUFFIX=objsfx, SHOBJSUFFIX=objsfx + 's') 9817674Snate@binkert.org new_env.Label = label 9827673Snate@binkert.org new_env.Append(**kwargs) 9837674Snate@binkert.org 9847674Snate@binkert.org lib_sources = Source.all.with_tag('gem5 lib') 9857674Snate@binkert.org 9867674Snate@binkert.org # Without Python, leave out all Python content from the library 9877674Snate@binkert.org # builds. The option doesn't affect gem5 built as a program 9887674Snate@binkert.org if GetOption('without_python'): 9897674Snate@binkert.org lib_sources = lib_sources.without_tag('python') 9907674Snate@binkert.org 9917811Ssteve.reinhardt@amd.com static_objs = [] 9927674Snate@binkert.org shared_objs = [] 9937673Snate@binkert.org 9945522Snate@binkert.org for s in lib_sources.with_tag(Source.ungrouped_tag): 9956143Snate@binkert.org static_objs.append(s.static(new_env)) 99610453SAndrew.Bardsley@arm.com shared_objs.append(s.shared(new_env)) 9977816Ssteve.reinhardt@amd.com 99812302Sgabeblack@google.com for group in Source.source_groups: 9994382Sbinkertn@umich.edu srcs = lib_sources.with_tag(Source.link_group_tag(group)) 10004382Sbinkertn@umich.edu if not srcs: 10014382Sbinkertn@umich.edu continue 10024382Sbinkertn@umich.edu 10034382Sbinkertn@umich.edu group_static = [ s.static(new_env) for s in srcs ] 10044382Sbinkertn@umich.edu group_shared = [ s.shared(new_env) for s in srcs ] 10054382Sbinkertn@umich.edu 10064382Sbinkertn@umich.edu # If partial linking is disabled, add these sources to the build 100712302Sgabeblack@google.com # directly, and short circuit this loop. 10084382Sbinkertn@umich.edu if disable_partial: 10092655Sstever@eecs.umich.edu static_objs.extend(group_static) 10102655Sstever@eecs.umich.edu shared_objs.extend(group_shared) 10112655Sstever@eecs.umich.edu continue 10122655Sstever@eecs.umich.edu 101312063Sgabeblack@google.com # Set up the static partially linked objects. 10145601Snate@binkert.org file_name = new_env.subst("${OBJPREFIX}lib${OBJSUFFIX}.partial") 10155601Snate@binkert.org target = File(joinpath(group, file_name)) 101612222Sgabeblack@google.com partial = env.PartialStatic(target=target, source=group_static) 101712222Sgabeblack@google.com static_objs.extend(partial) 101812222Sgabeblack@google.com 10195522Snate@binkert.org # Set up the shared partially linked objects. 10205863Snate@binkert.org file_name = new_env.subst("${SHOBJPREFIX}lib${SHOBJSUFFIX}.partial") 10215601Snate@binkert.org target = File(joinpath(group, file_name)) 10225601Snate@binkert.org partial = env.PartialShared(target=target, source=group_shared) 10235601Snate@binkert.org shared_objs.extend(partial) 102412302Sgabeblack@google.com 102510453SAndrew.Bardsley@arm.com static_date = date_source.static(new_env) 102611988Sandreas.sandberg@arm.com new_env.Depends(static_date, static_objs) 102711988Sandreas.sandberg@arm.com static_objs.extend(static_date) 102810453SAndrew.Bardsley@arm.com 102912302Sgabeblack@google.com shared_date = date_source.shared(new_env) 103010453SAndrew.Bardsley@arm.com new_env.Depends(shared_date, shared_objs) 103111983Sgabeblack@google.com shared_objs.extend(shared_date) 103211983Sgabeblack@google.com 103312302Sgabeblack@google.com # First make a library of everything but main() so other programs can 103412302Sgabeblack@google.com # link against m5. 103512362Sgabeblack@google.com static_lib = new_env.StaticLibrary(libname, static_objs) 103612362Sgabeblack@google.com shared_lib = new_env.SharedLibrary(libname, shared_objs) 103711983Sgabeblack@google.com 103812302Sgabeblack@google.com # Now link a stub with main() and the static library. 103912302Sgabeblack@google.com main_objs = [ s.static(new_env) for s in Source.all.with_tag('main') ] 104011983Sgabeblack@google.com 104111983Sgabeblack@google.com for test in UnitTest.all: 104211983Sgabeblack@google.com test_sources = Source.all.with_tag(str(test.target)) 104312362Sgabeblack@google.com test_objs = [ s.static(new_env) for s in test_sources ] 104412362Sgabeblack@google.com if test.main: 104512310Sgabeblack@google.com test_objs += main_objs 104612063Sgabeblack@google.com path = 'unittest/%s.%s' % (test.target, label) 104712063Sgabeblack@google.com new_env.Program(path, test_objs + static_objs) 104812063Sgabeblack@google.com 104912310Sgabeblack@google.com gtest_env = new_env.Clone() 105012310Sgabeblack@google.com gtest_env.Append(LIBS=gtest_env['GTEST_LIBS']) 105112063Sgabeblack@google.com gtest_env.Append(CPPFLAGS=gtest_env['GTEST_CPPFLAGS']) 105212063Sgabeblack@google.com for test in GTest.all: 105311983Sgabeblack@google.com test_sources = Source.all.with_tag(str(test.target)) 105411983Sgabeblack@google.com test_objs = [ s.static(gtest_env) for s in test_sources ] 105511983Sgabeblack@google.com gtest_env.Program(test.dir.File('%s.%s' % (test.target, label)), 105612310Sgabeblack@google.com test_objs) 105712310Sgabeblack@google.com 105811983Sgabeblack@google.com progname = exename 105911983Sgabeblack@google.com if strip: 106011983Sgabeblack@google.com progname += '.unstripped' 106111983Sgabeblack@google.com 106212310Sgabeblack@google.com targets = new_env.Program(progname, main_objs + static_objs) 106312310Sgabeblack@google.com 10646143Snate@binkert.org if strip: 106512362Sgabeblack@google.com if sys.platform == 'sunos5': 106612306Sgabeblack@google.com cmd = 'cp $SOURCE $TARGET; strip $TARGET' 106712310Sgabeblack@google.com else: 106810453SAndrew.Bardsley@arm.com cmd = 'strip $SOURCE -o $TARGET' 106912362Sgabeblack@google.com targets = new_env.Command(exename, progname, 107012306Sgabeblack@google.com MakeAction(cmd, Transform("STRIP"))) 107112310Sgabeblack@google.com 10725554Snate@binkert.org new_env.Command(secondary_exename, exename, 10735522Snate@binkert.org MakeAction('ln $SOURCE $TARGET', Transform("HARDLINK"))) 10745522Snate@binkert.org 10755797Snate@binkert.org new_env.M5Binary = targets[0] 10765797Snate@binkert.org 10775522Snate@binkert.org # Set up regression tests. 10785601Snate@binkert.org SConscript(os.path.join(env.root.abspath, 'tests', 'SConscript'), 107912362Sgabeblack@google.com variant_dir=Dir('tests').Dir(new_env.Label), 10808233Snate@binkert.org exports={ 'env' : new_env }, duplicate=False) 10818235Snate@binkert.org 108212302Sgabeblack@google.com# Start out with the compiler flags common to all compilers, 108312362Sgabeblack@google.com# i.e. they all use -g for opt and -g -pg for prof 10849003SAli.Saidi@ARM.comccflags = {'debug' : [], 'opt' : ['-g'], 'fast' : [], 'prof' : ['-g', '-pg'], 10859003SAli.Saidi@ARM.com 'perf' : ['-g']} 108612222Sgabeblack@google.com 108710196SCurtis.Dunham@arm.com# Start out with the linker flags common to all linkers, i.e. -pg for 10888235Snate@binkert.org# prof, and -lprofiler for perf. The -lprofile flag is surrounded by 108912313Sgabeblack@google.com# no-as-needed and as-needed as the binutils linker is too clever and 109012313Sgabeblack@google.com# simply doesn't link to the library otherwise. 109112313Sgabeblack@google.comldflags = {'debug' : [], 'opt' : [], 'fast' : [], 'prof' : ['-pg'], 109212371Sgabeblack@google.com 'perf' : ['-Wl,--no-as-needed', '-lprofiler', '-Wl,--as-needed']} 109312370Sgabeblack@google.com 109412313Sgabeblack@google.com# For Link Time Optimization, the optimisation flags used to compile 109512371Sgabeblack@google.com# individual files are decoupled from those used at link time 109612371Sgabeblack@google.com# (i.e. you can compile with -O3 and perform LTO with -O0), so we need 109712371Sgabeblack@google.com# to also update the linker flags based on the target. 109812371Sgabeblack@google.comif env['GCC']: 109912371Sgabeblack@google.com if sys.platform == 'sunos5': 110012362Sgabeblack@google.com ccflags['debug'] += ['-gstabs+'] 110112370Sgabeblack@google.com else: 110212370Sgabeblack@google.com ccflags['debug'] += ['-ggdb3'] 110312370Sgabeblack@google.com ldflags['debug'] += ['-O0'] 110412370Sgabeblack@google.com # opt, fast, prof and perf all share the same cc flags, also add 110512370Sgabeblack@google.com # the optimization to the ldflags as LTO defers the optimization 110612313Sgabeblack@google.com # to link time 11076143Snate@binkert.org for target in ['opt', 'fast', 'prof', 'perf']: 11082655Sstever@eecs.umich.edu ccflags[target] += ['-O3'] 11096143Snate@binkert.org ldflags[target] += ['-O3'] 11106143Snate@binkert.org 111111985Sgabeblack@google.com ccflags['fast'] += env['LTO_CCFLAGS'] 11126143Snate@binkert.org ldflags['fast'] += env['LTO_LDFLAGS'] 11136143Snate@binkert.orgelif env['CLANG']: 11144007Ssaidi@eecs.umich.edu ccflags['debug'] += ['-g', '-O0'] 11154596Sbinkertn@umich.edu # opt, fast, prof and perf all share the same cc flags 11164007Ssaidi@eecs.umich.edu for target in ['opt', 'fast', 'prof', 'perf']: 11174596Sbinkertn@umich.edu ccflags[target] += ['-O3'] 11187756SAli.Saidi@ARM.comelse: 11197816Ssteve.reinhardt@amd.com print 'Unknown compiler, please fix compiler options' 11208334Snate@binkert.org Exit(1) 11218334Snate@binkert.org 11228334Snate@binkert.org 11238334Snate@binkert.org# To speed things up, we only instantiate the build environments we 11245601Snate@binkert.org# need. We try to identify the needed environment for each target; if 112511993Sgabeblack@google.com# we can't, we fall back on instantiating all the environments just to 112611993Sgabeblack@google.com# be safe. 112711993Sgabeblack@google.comtarget_types = ['debug', 'opt', 'fast', 'prof', 'perf'] 112812223Sgabeblack@google.comobj2target = {'do': 'debug', 'o': 'opt', 'fo': 'fast', 'po': 'prof', 112911993Sgabeblack@google.com 'gpo' : 'perf'} 11302655Sstever@eecs.umich.edu 11319225Sandreas.hansson@arm.comdef identifyTarget(t): 11329225Sandreas.hansson@arm.com ext = t.split('.')[-1] 11339226Sandreas.hansson@arm.com if ext in target_types: 11349226Sandreas.hansson@arm.com return ext 11359225Sandreas.hansson@arm.com if obj2target.has_key(ext): 11369226Sandreas.hansson@arm.com return obj2target[ext] 11379226Sandreas.hansson@arm.com match = re.search(r'/tests/([^/]+)/', t) 11389226Sandreas.hansson@arm.com if match and match.group(1) in target_types: 11399226Sandreas.hansson@arm.com return match.group(1) 11409226Sandreas.hansson@arm.com return 'all' 11419226Sandreas.hansson@arm.com 11429225Sandreas.hansson@arm.comneeded_envs = [identifyTarget(target) for target in BUILD_TARGETS] 11439227Sandreas.hansson@arm.comif 'all' in needed_envs: 11449227Sandreas.hansson@arm.com needed_envs += target_types 11459227Sandreas.hansson@arm.com 11469227Sandreas.hansson@arm.com# Debug binary 11478946Sandreas.hansson@arm.comif 'debug' in needed_envs: 11483918Ssaidi@eecs.umich.edu makeEnv(env, 'debug', '.do', 11499225Sandreas.hansson@arm.com CCFLAGS = Split(ccflags['debug']), 11503918Ssaidi@eecs.umich.edu CPPDEFINES = ['DEBUG', 'TRACING_ON=1'], 11519225Sandreas.hansson@arm.com LINKFLAGS = Split(ldflags['debug'])) 11529225Sandreas.hansson@arm.com 11539227Sandreas.hansson@arm.com# Optimized binary 11549227Sandreas.hansson@arm.comif 'opt' in needed_envs: 11559227Sandreas.hansson@arm.com makeEnv(env, 'opt', '.o', 11569226Sandreas.hansson@arm.com CCFLAGS = Split(ccflags['opt']), 11579225Sandreas.hansson@arm.com CPPDEFINES = ['TRACING_ON=1'], 11589227Sandreas.hansson@arm.com LINKFLAGS = Split(ldflags['opt'])) 11599227Sandreas.hansson@arm.com 11609227Sandreas.hansson@arm.com# "Fast" binary 11619227Sandreas.hansson@arm.comif 'fast' in needed_envs: 11628946Sandreas.hansson@arm.com disable_partial = \ 11639225Sandreas.hansson@arm.com env.get('BROKEN_INCREMENTAL_LTO', False) and \ 11649226Sandreas.hansson@arm.com GetOption('force_lto') 11659226Sandreas.hansson@arm.com makeEnv(env, 'fast', '.fo', strip = True, 11669226Sandreas.hansson@arm.com CCFLAGS = Split(ccflags['fast']), 11673515Ssaidi@eecs.umich.edu CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'], 11683918Ssaidi@eecs.umich.edu LINKFLAGS = Split(ldflags['fast']), 11694762Snate@binkert.org disable_partial=disable_partial) 11703515Ssaidi@eecs.umich.edu 11718881Smarc.orr@gmail.com# Profiled binary using gprof 11728881Smarc.orr@gmail.comif 'prof' in needed_envs: 11738881Smarc.orr@gmail.com makeEnv(env, 'prof', '.po', 11748881Smarc.orr@gmail.com CCFLAGS = Split(ccflags['prof']), 11758881Smarc.orr@gmail.com CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'], 11769226Sandreas.hansson@arm.com LINKFLAGS = Split(ldflags['prof'])) 11779226Sandreas.hansson@arm.com 11789226Sandreas.hansson@arm.com# Profiled binary using google-pprof 11798881Smarc.orr@gmail.comif 'perf' in needed_envs: 11808881Smarc.orr@gmail.com makeEnv(env, 'perf', '.gpo', 11818881Smarc.orr@gmail.com CCFLAGS = Split(ccflags['perf']), 11828881Smarc.orr@gmail.com CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'], 11838881Smarc.orr@gmail.com LINKFLAGS = Split(ldflags['perf'])) 11848881Smarc.orr@gmail.com