SConscript revision 13245
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.orgfrom __future__ import print_function 326143Snate@binkert.org 334762Snate@binkert.orgimport array 345522Snate@binkert.orgimport bisect 35955SN/Aimport functools 365522Snate@binkert.orgimport imp 37955SN/Aimport marshal 385522Snate@binkert.orgimport os 394202Sbinkertn@umich.eduimport re 405742Snate@binkert.orgimport subprocess 41955SN/Aimport sys 424381Sbinkertn@umich.eduimport zlib 434381Sbinkertn@umich.edu 448334Snate@binkert.orgfrom os.path import basename, dirname, exists, isdir, isfile, join as joinpath 45955SN/A 46955SN/Aimport SCons 474202Sbinkertn@umich.edu 48955SN/Afrom gem5_scons import Transform 494382Sbinkertn@umich.edu 504382Sbinkertn@umich.edu# This file defines how to build a particular configuration of gem5 514382Sbinkertn@umich.edu# based on variable settings in the 'env' build environment. 526654Snate@binkert.org 535517Snate@binkert.orgImport('*') 548614Sgblack@eecs.umich.edu 557674Snate@binkert.org# Children need to see the environment 566143Snate@binkert.orgExport('env') 576143Snate@binkert.org 586143Snate@binkert.orgbuild_env = [(opt, env[opt]) for opt in export_vars] 598233Snate@binkert.org 608233Snate@binkert.orgfrom m5.util import code_formatter, compareVersions 618233Snate@binkert.org 628233Snate@binkert.org######################################################################## 638233Snate@binkert.org# Code for adding source files of various types 648334Snate@binkert.org# 658334Snate@binkert.org# When specifying a source file of some type, a set of tags can be 668233Snate@binkert.org# specified for that file. 678233Snate@binkert.org 688233Snate@binkert.orgclass SourceFilter(object): 698233Snate@binkert.org def __init__(self, predicate): 708233Snate@binkert.org self.predicate = predicate 718233Snate@binkert.org 726143Snate@binkert.org def __or__(self, other): 738233Snate@binkert.org return SourceFilter(lambda tags: self.predicate(tags) or 748233Snate@binkert.org other.predicate(tags)) 758233Snate@binkert.org 766143Snate@binkert.org def __and__(self, other): 776143Snate@binkert.org return SourceFilter(lambda tags: self.predicate(tags) and 786143Snate@binkert.org other.predicate(tags)) 796143Snate@binkert.org 808233Snate@binkert.orgdef with_tags_that(predicate): 818233Snate@binkert.org '''Return a list of sources with tags that satisfy a predicate.''' 828233Snate@binkert.org return SourceFilter(predicate) 836143Snate@binkert.org 848233Snate@binkert.orgdef with_any_tags(*tags): 858233Snate@binkert.org '''Return a list of sources with any of the supplied tags.''' 868233Snate@binkert.org return SourceFilter(lambda stags: len(set(tags) & stags) > 0) 878233Snate@binkert.org 886143Snate@binkert.orgdef with_all_tags(*tags): 896143Snate@binkert.org '''Return a list of sources with all of the supplied tags.''' 906143Snate@binkert.org return SourceFilter(lambda stags: set(tags) <= stags) 914762Snate@binkert.org 926143Snate@binkert.orgdef with_tag(tag): 938233Snate@binkert.org '''Return a list of sources with the supplied tag.''' 948233Snate@binkert.org return SourceFilter(lambda stags: tag in stags) 958233Snate@binkert.org 968233Snate@binkert.orgdef without_tags(*tags): 978233Snate@binkert.org '''Return a list of sources without any of the supplied tags.''' 986143Snate@binkert.org return SourceFilter(lambda stags: len(set(tags) & stags) == 0) 998233Snate@binkert.org 1008233Snate@binkert.orgdef without_tag(tag): 1018233Snate@binkert.org '''Return a list of sources with the supplied tag.''' 1028233Snate@binkert.org return SourceFilter(lambda stags: tag not in stags) 1036143Snate@binkert.org 1046143Snate@binkert.orgsource_filter_factories = { 1056143Snate@binkert.org 'with_tags_that': with_tags_that, 1066143Snate@binkert.org 'with_any_tags': with_any_tags, 1076143Snate@binkert.org 'with_all_tags': with_all_tags, 1086143Snate@binkert.org 'with_tag': with_tag, 1096143Snate@binkert.org 'without_tags': without_tags, 1106143Snate@binkert.org 'without_tag': without_tag, 1116143Snate@binkert.org} 1127065Snate@binkert.org 1136143Snate@binkert.orgExport(source_filter_factories) 1148233Snate@binkert.org 1158233Snate@binkert.orgclass SourceList(list): 1168233Snate@binkert.org def apply_filter(self, f): 1178233Snate@binkert.org def match(source): 1188233Snate@binkert.org return f.predicate(source.tags) 1198233Snate@binkert.org return SourceList(filter(match, self)) 1208233Snate@binkert.org 1218233Snate@binkert.org def __getattr__(self, name): 1228233Snate@binkert.org func = source_filter_factories.get(name, None) 1238233Snate@binkert.org if not func: 1248233Snate@binkert.org raise AttributeError 1258233Snate@binkert.org 1268233Snate@binkert.org @functools.wraps(func) 1278233Snate@binkert.org def wrapper(*args, **kwargs): 1288233Snate@binkert.org return self.apply_filter(func(*args, **kwargs)) 1298233Snate@binkert.org return wrapper 1308233Snate@binkert.org 1318233Snate@binkert.orgclass SourceMeta(type): 1328233Snate@binkert.org '''Meta class for source files that keeps track of all files of a 1338233Snate@binkert.org particular type.''' 1348233Snate@binkert.org def __init__(cls, name, bases, dict): 1358233Snate@binkert.org super(SourceMeta, cls).__init__(name, bases, dict) 1368233Snate@binkert.org cls.all = SourceList() 1378233Snate@binkert.org 1388233Snate@binkert.orgclass SourceFile(object): 1398233Snate@binkert.org '''Base object that encapsulates the notion of a source file. 1408233Snate@binkert.org This includes, the source node, target node, various manipulations 1418233Snate@binkert.org of those. A source file also specifies a set of tags which 1428233Snate@binkert.org describing arbitrary properties of the source file.''' 1438233Snate@binkert.org __metaclass__ = SourceMeta 1448233Snate@binkert.org 1456143Snate@binkert.org static_objs = {} 1466143Snate@binkert.org shared_objs = {} 1476143Snate@binkert.org 1486143Snate@binkert.org def __init__(self, source, tags=None, add_tags=None): 1496143Snate@binkert.org if tags is None: 1506143Snate@binkert.org tags='gem5 lib' 1516143Snate@binkert.org if isinstance(tags, basestring): 1526143Snate@binkert.org tags = set([tags]) 1536143Snate@binkert.org if not isinstance(tags, set): 1548945Ssteve.reinhardt@amd.com tags = set(tags) 1558233Snate@binkert.org self.tags = tags 1568233Snate@binkert.org 1576143Snate@binkert.org if add_tags: 1588945Ssteve.reinhardt@amd.com if isinstance(add_tags, basestring): 1596143Snate@binkert.org add_tags = set([add_tags]) 1606143Snate@binkert.org if not isinstance(add_tags, set): 1616143Snate@binkert.org add_tags = set(add_tags) 1626143Snate@binkert.org self.tags |= add_tags 1635522Snate@binkert.org 1646143Snate@binkert.org tnode = source 1656143Snate@binkert.org if not isinstance(source, SCons.Node.FS.File): 1666143Snate@binkert.org tnode = File(source) 1676143Snate@binkert.org 1688233Snate@binkert.org self.tnode = tnode 1698233Snate@binkert.org self.snode = tnode.srcnode() 1708233Snate@binkert.org 1716143Snate@binkert.org for base in type(self).__mro__: 1726143Snate@binkert.org if issubclass(base, SourceFile): 1736143Snate@binkert.org base.all.append(self) 1746143Snate@binkert.org 1755522Snate@binkert.org def static(self, env): 1765522Snate@binkert.org key = (self.tnode, env['OBJSUFFIX']) 1775522Snate@binkert.org if not key in self.static_objs: 1785522Snate@binkert.org self.static_objs[key] = env.StaticObject(self.tnode) 1795604Snate@binkert.org return self.static_objs[key] 1805604Snate@binkert.org 1816143Snate@binkert.org def shared(self, env): 1826143Snate@binkert.org key = (self.tnode, env['OBJSUFFIX']) 1834762Snate@binkert.org if not key in self.shared_objs: 1844762Snate@binkert.org self.shared_objs[key] = env.SharedObject(self.tnode) 1856143Snate@binkert.org return self.shared_objs[key] 1866727Ssteve.reinhardt@amd.com 1876727Ssteve.reinhardt@amd.com @property 1886727Ssteve.reinhardt@amd.com def filename(self): 1894762Snate@binkert.org return str(self.tnode) 1906143Snate@binkert.org 1916143Snate@binkert.org @property 1926143Snate@binkert.org def dirname(self): 1936143Snate@binkert.org return dirname(self.filename) 1946727Ssteve.reinhardt@amd.com 1956143Snate@binkert.org @property 1967674Snate@binkert.org def basename(self): 1977674Snate@binkert.org return basename(self.filename) 1985604Snate@binkert.org 1996143Snate@binkert.org @property 2006143Snate@binkert.org def extname(self): 2016143Snate@binkert.org index = self.basename.rfind('.') 2024762Snate@binkert.org if index <= 0: 2036143Snate@binkert.org # dot files aren't extensions 2044762Snate@binkert.org return self.basename, None 2054762Snate@binkert.org 2064762Snate@binkert.org return self.basename[:index], self.basename[index+1:] 2076143Snate@binkert.org 2086143Snate@binkert.org def __lt__(self, other): return self.filename < other.filename 2094762Snate@binkert.org def __le__(self, other): return self.filename <= other.filename 2108233Snate@binkert.org def __gt__(self, other): return self.filename > other.filename 2118233Snate@binkert.org def __ge__(self, other): return self.filename >= other.filename 2128233Snate@binkert.org def __eq__(self, other): return self.filename == other.filename 2138233Snate@binkert.org def __ne__(self, other): return self.filename != other.filename 2146143Snate@binkert.org 2156143Snate@binkert.orgclass Source(SourceFile): 2164762Snate@binkert.org ungrouped_tag = 'No link group' 2176143Snate@binkert.org source_groups = set() 2184762Snate@binkert.org 2196143Snate@binkert.org _current_group_tag = ungrouped_tag 2204762Snate@binkert.org 2216143Snate@binkert.org @staticmethod 2228233Snate@binkert.org def link_group_tag(group): 2238233Snate@binkert.org return 'link group: %s' % group 2248233Snate@binkert.org 2256143Snate@binkert.org @classmethod 2266143Snate@binkert.org def set_group(cls, group): 2276143Snate@binkert.org new_tag = Source.link_group_tag(group) 2286143Snate@binkert.org Source._current_group_tag = new_tag 2296143Snate@binkert.org Source.source_groups.add(group) 2306143Snate@binkert.org 2316143Snate@binkert.org def _add_link_group_tag(self): 2326143Snate@binkert.org self.tags.add(Source._current_group_tag) 2338233Snate@binkert.org 2348233Snate@binkert.org '''Add a c/c++ source file to the build''' 235955SN/A def __init__(self, source, tags=None, add_tags=None): 2368235Snate@binkert.org '''specify the source file, and any tags''' 2378235Snate@binkert.org super(Source, self).__init__(source, tags, add_tags) 2386143Snate@binkert.org self._add_link_group_tag() 2398235Snate@binkert.org 2409003SAli.Saidi@ARM.comclass PySource(SourceFile): 2418235Snate@binkert.org '''Add a python source file to the named package''' 2428235Snate@binkert.org invalid_sym_char = re.compile('[^A-z0-9_]') 2438235Snate@binkert.org modules = {} 2448235Snate@binkert.org tnodes = {} 2458235Snate@binkert.org symnames = {} 2468235Snate@binkert.org 2478235Snate@binkert.org def __init__(self, package, source, tags=None, add_tags=None): 2488235Snate@binkert.org '''specify the python package, the source file, and any tags''' 2498235Snate@binkert.org super(PySource, self).__init__(source, tags, add_tags) 2508235Snate@binkert.org 2518235Snate@binkert.org modname,ext = self.extname 2528235Snate@binkert.org assert ext == 'py' 2538235Snate@binkert.org 2548235Snate@binkert.org if package: 2559003SAli.Saidi@ARM.com path = package.split('.') 2568235Snate@binkert.org else: 2575584Snate@binkert.org path = [] 2584382Sbinkertn@umich.edu 2594202Sbinkertn@umich.edu modpath = path[:] 2604382Sbinkertn@umich.edu if modname != '__init__': 2614382Sbinkertn@umich.edu modpath += [ modname ] 2624382Sbinkertn@umich.edu modpath = '.'.join(modpath) 2635584Snate@binkert.org 2644382Sbinkertn@umich.edu arcpath = path + [ self.basename ] 2654382Sbinkertn@umich.edu abspath = self.snode.abspath 2664382Sbinkertn@umich.edu if not exists(abspath): 2678232Snate@binkert.org abspath = self.tnode.abspath 2685192Ssaidi@eecs.umich.edu 2698232Snate@binkert.org self.package = package 2708232Snate@binkert.org self.modname = modname 2718232Snate@binkert.org self.modpath = modpath 2725192Ssaidi@eecs.umich.edu self.arcname = joinpath(*arcpath) 2738232Snate@binkert.org self.abspath = abspath 2745192Ssaidi@eecs.umich.edu self.compiled = File(self.filename + 'c') 2755799Snate@binkert.org self.cpp = File(self.filename + '.cc') 2768232Snate@binkert.org self.symname = PySource.invalid_sym_char.sub('_', modpath) 2775192Ssaidi@eecs.umich.edu 2785192Ssaidi@eecs.umich.edu PySource.modules[modpath] = self 2795192Ssaidi@eecs.umich.edu PySource.tnodes[self.tnode] = self 2808232Snate@binkert.org PySource.symnames[self.symname] = self 2815192Ssaidi@eecs.umich.edu 2828232Snate@binkert.orgclass SimObject(PySource): 2835192Ssaidi@eecs.umich.edu '''Add a SimObject python file as a python source object and add 2845192Ssaidi@eecs.umich.edu it to a list of sim object modules''' 2855192Ssaidi@eecs.umich.edu 2865192Ssaidi@eecs.umich.edu fixed = False 2874382Sbinkertn@umich.edu modnames = [] 2884382Sbinkertn@umich.edu 2894382Sbinkertn@umich.edu def __init__(self, source, tags=None, add_tags=None): 2902667Sstever@eecs.umich.edu '''Specify the source file and any tags (automatically in 2912667Sstever@eecs.umich.edu the m5.objects package)''' 2922667Sstever@eecs.umich.edu super(SimObject, self).__init__('m5.objects', source, tags, add_tags) 2932667Sstever@eecs.umich.edu if self.fixed: 2942667Sstever@eecs.umich.edu raise AttributeError, "Too late to call SimObject now." 2952667Sstever@eecs.umich.edu 2965742Snate@binkert.org bisect.insort_right(SimObject.modnames, self.modname) 2975742Snate@binkert.org 2985742Snate@binkert.orgclass ProtoBuf(SourceFile): 2995793Snate@binkert.org '''Add a Protocol Buffer to build''' 3008334Snate@binkert.org 3015793Snate@binkert.org def __init__(self, source, tags=None, add_tags=None): 3025793Snate@binkert.org '''Specify the source file, and any tags''' 3035793Snate@binkert.org super(ProtoBuf, self).__init__(source, tags, add_tags) 3044382Sbinkertn@umich.edu 3054762Snate@binkert.org # Get the file name and the extension 3065344Sstever@gmail.com modname,ext = self.extname 3074382Sbinkertn@umich.edu assert ext == 'proto' 3085341Sstever@gmail.com 3095742Snate@binkert.org # Currently, we stick to generating the C++ headers, so we 3105742Snate@binkert.org # only need to track the source and header. 3115742Snate@binkert.org self.cc_file = File(modname + '.pb.cc') 3125742Snate@binkert.org self.hh_file = File(modname + '.pb.h') 3135742Snate@binkert.org 3144762Snate@binkert.org 3155742Snate@binkert.orgexectuable_classes = [] 3165742Snate@binkert.orgclass ExecutableMeta(type): 3177722Sgblack@eecs.umich.edu '''Meta class for Executables.''' 3185742Snate@binkert.org all = [] 3195742Snate@binkert.org 3205742Snate@binkert.org def __init__(cls, name, bases, d): 3215742Snate@binkert.org if not d.pop('abstract', False): 3228242Sbradley.danofsky@amd.com ExecutableMeta.all.append(cls) 3238242Sbradley.danofsky@amd.com super(ExecutableMeta, cls).__init__(name, bases, d) 3248242Sbradley.danofsky@amd.com 3258242Sbradley.danofsky@amd.com cls.all = [] 3265341Sstever@gmail.com 3275742Snate@binkert.orgclass Executable(object): 3287722Sgblack@eecs.umich.edu '''Base class for creating an executable from sources.''' 3294773Snate@binkert.org __metaclass__ = ExecutableMeta 3306108Snate@binkert.org 3311858SN/A abstract = True 3321085SN/A 3336658Snate@binkert.org def __init__(self, target, *srcs_and_filts): 3346658Snate@binkert.org '''Specify the target name and any sources. Sources that are 3357673Snate@binkert.org not SourceFiles are evalued with Source().''' 3366658Snate@binkert.org super(Executable, self).__init__() 3376658Snate@binkert.org self.all.append(self) 3386658Snate@binkert.org self.target = target 3396658Snate@binkert.org 3406658Snate@binkert.org isFilter = lambda arg: isinstance(arg, SourceFilter) 3416658Snate@binkert.org self.filters = filter(isFilter, srcs_and_filts) 3426658Snate@binkert.org sources = filter(lambda a: not isFilter(a), srcs_and_filts) 3437673Snate@binkert.org 3447673Snate@binkert.org srcs = SourceList() 3457673Snate@binkert.org for src in sources: 3467673Snate@binkert.org if not isinstance(src, SourceFile): 3477673Snate@binkert.org src = Source(src, tags=[]) 3487673Snate@binkert.org srcs.append(src) 3497673Snate@binkert.org 3506658Snate@binkert.org self.sources = srcs 3517673Snate@binkert.org self.dir = Dir('.') 3527673Snate@binkert.org 3537673Snate@binkert.org def path(self, env): 3547673Snate@binkert.org return self.dir.File(self.target + '.' + env['EXE_SUFFIX']) 3557673Snate@binkert.org 3567673Snate@binkert.org def srcs_to_objs(self, env, sources): 3579048SAli.Saidi@ARM.com return list([ s.static(env) for s in sources ]) 3587673Snate@binkert.org 3597673Snate@binkert.org @classmethod 3607673Snate@binkert.org def declare_all(cls, env): 3617673Snate@binkert.org return list([ instance.declare(env) for instance in cls.all ]) 3626658Snate@binkert.org 3637756SAli.Saidi@ARM.com def declare(self, env, objs=None): 3647816Ssteve.reinhardt@amd.com if objs is None: 3656658Snate@binkert.org objs = self.srcs_to_objs(env, self.sources) 3664382Sbinkertn@umich.edu 3674382Sbinkertn@umich.edu if env['STRIP_EXES']: 3684762Snate@binkert.org stripped = self.path(env) 3694762Snate@binkert.org unstripped = env.File(str(stripped) + '.unstripped') 3704762Snate@binkert.org if sys.platform == 'sunos5': 3716654Snate@binkert.org cmd = 'cp $SOURCE $TARGET; strip $TARGET' 3726654Snate@binkert.org else: 3735517Snate@binkert.org cmd = 'strip $SOURCE -o $TARGET' 3745517Snate@binkert.org env.Program(unstripped, objs) 3755517Snate@binkert.org return env.Command(stripped, unstripped, 3765517Snate@binkert.org MakeAction(cmd, Transform("STRIP"))) 3775517Snate@binkert.org else: 3785517Snate@binkert.org return env.Program(self.path(env), objs) 3795517Snate@binkert.org 3805517Snate@binkert.orgclass UnitTest(Executable): 3815517Snate@binkert.org '''Create a UnitTest''' 3825517Snate@binkert.org def __init__(self, target, *srcs_and_filts, **kwargs): 3835517Snate@binkert.org super(UnitTest, self).__init__(target, *srcs_and_filts) 3845517Snate@binkert.org 3855517Snate@binkert.org self.main = kwargs.get('main', False) 3865517Snate@binkert.org 3875517Snate@binkert.org def declare(self, env): 3885517Snate@binkert.org sources = list(self.sources) 3895517Snate@binkert.org for f in self.filters: 3906654Snate@binkert.org sources = Source.all.apply_filter(f) 3915517Snate@binkert.org objs = self.srcs_to_objs(env, sources) + env['STATIC_OBJS'] 3925517Snate@binkert.org if self.main: 3935517Snate@binkert.org objs += env['MAIN_OBJS'] 3945517Snate@binkert.org return super(UnitTest, self).declare(env, objs) 3955517Snate@binkert.org 3965517Snate@binkert.orgclass GTest(Executable): 3975517Snate@binkert.org '''Create a unit test based on the google test framework.''' 3985517Snate@binkert.org all = [] 3996143Snate@binkert.org def __init__(self, *srcs_and_filts, **kwargs): 4006654Snate@binkert.org super(GTest, self).__init__(*srcs_and_filts) 4015517Snate@binkert.org 4025517Snate@binkert.org self.skip_lib = kwargs.pop('skip_lib', False) 4035517Snate@binkert.org 4045517Snate@binkert.org @classmethod 4055517Snate@binkert.org def declare_all(cls, env): 4065517Snate@binkert.org env = env.Clone() 4075517Snate@binkert.org env.Append(LIBS=env['GTEST_LIBS']) 4085517Snate@binkert.org env.Append(CPPFLAGS=env['GTEST_CPPFLAGS']) 4095517Snate@binkert.org env['GTEST_LIB_SOURCES'] = Source.all.with_tag('gtest lib') 4105517Snate@binkert.org env['GTEST_OUT_DIR'] = \ 4115517Snate@binkert.org Dir(env['BUILDDIR']).Dir('unittests.' + env['EXE_SUFFIX']) 4125517Snate@binkert.org return super(GTest, cls).declare_all(env) 4135517Snate@binkert.org 4145517Snate@binkert.org def declare(self, env): 4156654Snate@binkert.org sources = list(self.sources) 4166654Snate@binkert.org if not self.skip_lib: 4175517Snate@binkert.org sources += env['GTEST_LIB_SOURCES'] 4185517Snate@binkert.org for f in self.filters: 4196143Snate@binkert.org sources += Source.all.apply_filter(f) 4206143Snate@binkert.org objs = self.srcs_to_objs(env, sources) 4216143Snate@binkert.org 4226727Ssteve.reinhardt@amd.com binary = super(GTest, self).declare(env, objs) 4235517Snate@binkert.org 4246727Ssteve.reinhardt@amd.com out_dir = env['GTEST_OUT_DIR'] 4255517Snate@binkert.org xml_file = out_dir.Dir(str(self.dir)).File(self.target + '.xml') 4265517Snate@binkert.org AlwaysBuild(env.Command(xml_file, binary, 4275517Snate@binkert.org "${SOURCES[0]} --gtest_output=xml:${TARGETS[0]}")) 4286654Snate@binkert.org 4296654Snate@binkert.org return binary 4307673Snate@binkert.org 4316654Snate@binkert.orgclass Gem5(Executable): 4326654Snate@binkert.org '''Create a gem5 executable.''' 4336654Snate@binkert.org 4346654Snate@binkert.org def __init__(self, target): 4355517Snate@binkert.org super(Gem5, self).__init__(target) 4365517Snate@binkert.org 4375517Snate@binkert.org def declare(self, env): 4386143Snate@binkert.org objs = env['MAIN_OBJS'] + env['STATIC_OBJS'] 4395517Snate@binkert.org return super(Gem5, self).declare(env, objs) 4404762Snate@binkert.org 4415517Snate@binkert.org 4425517Snate@binkert.org# Children should have access 4436143Snate@binkert.orgExport('Source') 4446143Snate@binkert.orgExport('PySource') 4455517Snate@binkert.orgExport('SimObject') 4465517Snate@binkert.orgExport('ProtoBuf') 4475517Snate@binkert.orgExport('Executable') 4485517Snate@binkert.orgExport('UnitTest') 4495517Snate@binkert.orgExport('GTest') 4505517Snate@binkert.org 4515517Snate@binkert.org######################################################################## 4525517Snate@binkert.org# 4535517Snate@binkert.org# Debug Flags 4549338SAndreas.Sandberg@arm.com# 4559338SAndreas.Sandberg@arm.comdebug_flags = {} 4569338SAndreas.Sandberg@arm.comdef DebugFlag(name, desc=None): 4579338SAndreas.Sandberg@arm.com if name in debug_flags: 4589338SAndreas.Sandberg@arm.com raise AttributeError, "Flag %s already specified" % name 4599338SAndreas.Sandberg@arm.com debug_flags[name] = (name, (), desc) 4608596Ssteve.reinhardt@amd.com 4618596Ssteve.reinhardt@amd.comdef CompoundFlag(name, flags, desc=None): 4628596Ssteve.reinhardt@amd.com if name in debug_flags: 4638596Ssteve.reinhardt@amd.com raise AttributeError, "Flag %s already specified" % name 4648596Ssteve.reinhardt@amd.com 4658596Ssteve.reinhardt@amd.com compound = tuple(flags) 4668596Ssteve.reinhardt@amd.com debug_flags[name] = (name, compound, desc) 4676143Snate@binkert.org 4685517Snate@binkert.orgExport('DebugFlag') 4696654Snate@binkert.orgExport('CompoundFlag') 4706654Snate@binkert.org 4716654Snate@binkert.org######################################################################## 4726654Snate@binkert.org# 4736654Snate@binkert.org# Set some compiler variables 4746654Snate@binkert.org# 4755517Snate@binkert.org 4765517Snate@binkert.org# Include file paths are rooted in this directory. SCons will 4775517Snate@binkert.org# automatically expand '.' to refer to both the source directory and 4788596Ssteve.reinhardt@amd.com# the corresponding build directory to pick up generated include 4798596Ssteve.reinhardt@amd.com# files. 4804762Snate@binkert.orgenv.Append(CPPPATH=Dir('.')) 4814762Snate@binkert.org 4824762Snate@binkert.orgfor extra_dir in extras_dir_list: 4834762Snate@binkert.org env.Append(CPPPATH=Dir(extra_dir)) 4844762Snate@binkert.org 4854762Snate@binkert.org# Workaround for bug in SCons version > 0.97d20071212 4867675Snate@binkert.org# Scons bug id: 2006 gem5 Bug id: 308 4874762Snate@binkert.orgfor root, dirs, files in os.walk(base_dir, topdown=True): 4884762Snate@binkert.org Dir(root[len(base_dir) + 1:]) 4894762Snate@binkert.org 4904762Snate@binkert.org######################################################################## 4914382Sbinkertn@umich.edu# 4924382Sbinkertn@umich.edu# Walk the tree and execute all SConscripts in subdirectories 4935517Snate@binkert.org# 4946654Snate@binkert.org 4955517Snate@binkert.orghere = Dir('.').srcnode().abspath 4968126Sgblack@eecs.umich.edufor root, dirs, files in os.walk(base_dir, topdown=True): 4976654Snate@binkert.org if root == here: 4987673Snate@binkert.org # we don't want to recurse back into this SConscript 4996654Snate@binkert.org continue 5006654Snate@binkert.org 5016654Snate@binkert.org if 'SConscript' in files: 5026654Snate@binkert.org build_dir = joinpath(env['BUILDDIR'], root[len(base_dir) + 1:]) 5036654Snate@binkert.org Source.set_group(build_dir) 5046654Snate@binkert.org SConscript(joinpath(root, 'SConscript'), variant_dir=build_dir) 5056654Snate@binkert.org 5066669Snate@binkert.orgfor extra_dir in extras_dir_list: 5076669Snate@binkert.org prefix_len = len(dirname(extra_dir)) + 1 5086669Snate@binkert.org 5096669Snate@binkert.org # Also add the corresponding build directory to pick up generated 5106669Snate@binkert.org # include files. 5116669Snate@binkert.org env.Append(CPPPATH=Dir(joinpath(env['BUILDDIR'], extra_dir[prefix_len:]))) 5126654Snate@binkert.org 5137673Snate@binkert.org for root, dirs, files in os.walk(extra_dir, topdown=True): 5145517Snate@binkert.org # if build lives in the extras directory, don't walk down it 5158126Sgblack@eecs.umich.edu if 'build' in dirs: 5165798Snate@binkert.org dirs.remove('build') 5177756SAli.Saidi@ARM.com 5187816Ssteve.reinhardt@amd.com if 'SConscript' in files: 5195798Snate@binkert.org build_dir = joinpath(env['BUILDDIR'], root[prefix_len:]) 5205798Snate@binkert.org SConscript(joinpath(root, 'SConscript'), variant_dir=build_dir) 5215517Snate@binkert.org 5225517Snate@binkert.orgfor opt in export_vars: 5237673Snate@binkert.org env.ConfigFile(opt) 5245517Snate@binkert.org 5255517Snate@binkert.orgdef makeTheISA(source, target, env): 5267673Snate@binkert.org isas = [ src.get_contents() for src in source ] 5277673Snate@binkert.org target_isa = env['TARGET_ISA'] 5285517Snate@binkert.org def define(isa): 5295798Snate@binkert.org return isa.upper() + '_ISA' 5305798Snate@binkert.org 5318333Snate@binkert.org def namespace(isa): 5327816Ssteve.reinhardt@amd.com return isa[0].upper() + isa[1:].lower() + 'ISA' 5335798Snate@binkert.org 5345798Snate@binkert.org 5354762Snate@binkert.org code = code_formatter() 5364762Snate@binkert.org code('''\ 5374762Snate@binkert.org#ifndef __CONFIG_THE_ISA_HH__ 5384762Snate@binkert.org#define __CONFIG_THE_ISA_HH__ 5394762Snate@binkert.org 5408596Ssteve.reinhardt@amd.com''') 5415517Snate@binkert.org 5425517Snate@binkert.org # create defines for the preprocessing and compile-time determination 5435517Snate@binkert.org for i,isa in enumerate(isas): 5445517Snate@binkert.org code('#define $0 $1', define(isa), i + 1) 5455517Snate@binkert.org code() 5467673Snate@binkert.org 5478596Ssteve.reinhardt@amd.com # create an enum for any run-time determination of the ISA, we 5487673Snate@binkert.org # reuse the same name as the namespaces 5495517Snate@binkert.org code('enum class Arch {') 5508596Ssteve.reinhardt@amd.com for i,isa in enumerate(isas): 5515517Snate@binkert.org if i + 1 == len(isas): 5525517Snate@binkert.org code(' $0 = $1', namespace(isa), define(isa)) 5535517Snate@binkert.org else: 5548596Ssteve.reinhardt@amd.com code(' $0 = $1,', namespace(isa), define(isa)) 5555517Snate@binkert.org code('};') 5567673Snate@binkert.org 5577673Snate@binkert.org code(''' 5587673Snate@binkert.org 5595517Snate@binkert.org#define THE_ISA ${{define(target_isa)}} 5605517Snate@binkert.org#define TheISA ${{namespace(target_isa)}} 5615517Snate@binkert.org#define THE_ISA_STR "${{target_isa}}" 5625517Snate@binkert.org 5635517Snate@binkert.org#endif // __CONFIG_THE_ISA_HH__''') 5645517Snate@binkert.org 5655517Snate@binkert.org code.write(str(target[0])) 5667673Snate@binkert.org 5677673Snate@binkert.orgenv.Command('config/the_isa.hh', map(Value, all_isa_list), 5687673Snate@binkert.org MakeAction(makeTheISA, Transform("CFG ISA", 0))) 5695517Snate@binkert.org 5708596Ssteve.reinhardt@amd.comdef makeTheGPUISA(source, target, env): 5715517Snate@binkert.org isas = [ src.get_contents() for src in source ] 5725517Snate@binkert.org target_gpu_isa = env['TARGET_GPU_ISA'] 5735517Snate@binkert.org def define(isa): 5745517Snate@binkert.org return isa.upper() + '_ISA' 5755517Snate@binkert.org 5767673Snate@binkert.org def namespace(isa): 5777673Snate@binkert.org return isa[0].upper() + isa[1:].lower() + 'ISA' 5787673Snate@binkert.org 5795517Snate@binkert.org 5808596Ssteve.reinhardt@amd.com code = code_formatter() 5817675Snate@binkert.org code('''\ 5827675Snate@binkert.org#ifndef __CONFIG_THE_GPU_ISA_HH__ 5837675Snate@binkert.org#define __CONFIG_THE_GPU_ISA_HH__ 5847675Snate@binkert.org 5857675Snate@binkert.org''') 5867675Snate@binkert.org 5878596Ssteve.reinhardt@amd.com # create defines for the preprocessing and compile-time determination 5887675Snate@binkert.org for i,isa in enumerate(isas): 5897675Snate@binkert.org code('#define $0 $1', define(isa), i + 1) 5908596Ssteve.reinhardt@amd.com code() 5918596Ssteve.reinhardt@amd.com 5928596Ssteve.reinhardt@amd.com # create an enum for any run-time determination of the ISA, we 5938596Ssteve.reinhardt@amd.com # reuse the same name as the namespaces 5948596Ssteve.reinhardt@amd.com code('enum class GPUArch {') 5958596Ssteve.reinhardt@amd.com for i,isa in enumerate(isas): 5968596Ssteve.reinhardt@amd.com if i + 1 == len(isas): 5978596Ssteve.reinhardt@amd.com code(' $0 = $1', namespace(isa), define(isa)) 5988596Ssteve.reinhardt@amd.com else: 5994762Snate@binkert.org code(' $0 = $1,', namespace(isa), define(isa)) 6006143Snate@binkert.org code('};') 6016143Snate@binkert.org 6026143Snate@binkert.org code(''' 6034762Snate@binkert.org 6044762Snate@binkert.org#define THE_GPU_ISA ${{define(target_gpu_isa)}} 6054762Snate@binkert.org#define TheGpuISA ${{namespace(target_gpu_isa)}} 6067756SAli.Saidi@ARM.com#define THE_GPU_ISA_STR "${{target_gpu_isa}}" 6078596Ssteve.reinhardt@amd.com 6084762Snate@binkert.org#endif // __CONFIG_THE_GPU_ISA_HH__''') 6094762Snate@binkert.org 6108596Ssteve.reinhardt@amd.com code.write(str(target[0])) 6115463Snate@binkert.org 6128596Ssteve.reinhardt@amd.comenv.Command('config/the_gpu_isa.hh', map(Value, all_gpu_isa_list), 6138596Ssteve.reinhardt@amd.com MakeAction(makeTheGPUISA, Transform("CFG ISA", 0))) 6145463Snate@binkert.org 6157756SAli.Saidi@ARM.com######################################################################## 6168596Ssteve.reinhardt@amd.com# 6174762Snate@binkert.org# Prevent any SimObjects from being added after this point, they 6187677Snate@binkert.org# should all have been added in the SConscripts above 6194762Snate@binkert.org# 6204762Snate@binkert.orgSimObject.fixed = True 6216143Snate@binkert.org 6226143Snate@binkert.orgclass DictImporter(object): 6236143Snate@binkert.org '''This importer takes a dictionary of arbitrary module names that 6244762Snate@binkert.org map to arbitrary filenames.''' 6254762Snate@binkert.org def __init__(self, modules): 6267756SAli.Saidi@ARM.com self.modules = modules 6277816Ssteve.reinhardt@amd.com self.installed = set() 6284762Snate@binkert.org 6294762Snate@binkert.org def __del__(self): 6304762Snate@binkert.org self.unload() 6314762Snate@binkert.org 6327756SAli.Saidi@ARM.com def unload(self): 6338596Ssteve.reinhardt@amd.com import sys 6344762Snate@binkert.org for module in self.installed: 6354762Snate@binkert.org del sys.modules[module] 6367677Snate@binkert.org self.installed = set() 6377756SAli.Saidi@ARM.com 6388596Ssteve.reinhardt@amd.com def find_module(self, fullname, path): 6397675Snate@binkert.org if fullname == 'm5.defines': 6407677Snate@binkert.org return self 6415517Snate@binkert.org 6428596Ssteve.reinhardt@amd.com if fullname == 'm5.objects': 6439248SAndreas.Sandberg@arm.com return self 6449248SAndreas.Sandberg@arm.com 6459248SAndreas.Sandberg@arm.com if fullname.startswith('_m5'): 6469248SAndreas.Sandberg@arm.com return None 6478596Ssteve.reinhardt@amd.com 6488596Ssteve.reinhardt@amd.com source = self.modules.get(fullname, None) 6498596Ssteve.reinhardt@amd.com if source is not None and fullname.startswith('m5.objects'): 6509248SAndreas.Sandberg@arm.com return self 6518596Ssteve.reinhardt@amd.com 6524762Snate@binkert.org return None 6537674Snate@binkert.org 6547674Snate@binkert.org def load_module(self, fullname): 6557674Snate@binkert.org mod = imp.new_module(fullname) 6567674Snate@binkert.org sys.modules[fullname] = mod 6577674Snate@binkert.org self.installed.add(fullname) 6587674Snate@binkert.org 6597674Snate@binkert.org mod.__loader__ = self 6607674Snate@binkert.org if fullname == 'm5.objects': 6617674Snate@binkert.org mod.__path__ = fullname.split('.') 6627674Snate@binkert.org return mod 6637674Snate@binkert.org 6647674Snate@binkert.org if fullname == 'm5.defines': 6657674Snate@binkert.org mod.__dict__['buildEnv'] = m5.util.SmartDict(build_env) 6667674Snate@binkert.org return mod 6677674Snate@binkert.org 6684762Snate@binkert.org source = self.modules[fullname] 6696143Snate@binkert.org if source.modname == '__init__': 6706143Snate@binkert.org mod.__path__ = source.modpath 6717756SAli.Saidi@ARM.com mod.__file__ = source.abspath 6727816Ssteve.reinhardt@amd.com 6738235Snate@binkert.org exec file(source.abspath, 'r') in mod.__dict__ 6748596Ssteve.reinhardt@amd.com 6757756SAli.Saidi@ARM.com return mod 6767816Ssteve.reinhardt@amd.com 6778235Snate@binkert.orgimport m5.SimObject 6784382Sbinkertn@umich.eduimport m5.params 6798232Snate@binkert.orgfrom m5.util import code_formatter 6808232Snate@binkert.org 6818232Snate@binkert.orgm5.SimObject.clear() 6828232Snate@binkert.orgm5.params.clear() 6838232Snate@binkert.org 6846229Snate@binkert.org# install the python importer so we can grab stuff from the source 6858232Snate@binkert.org# tree itself. We can't have SimObjects added after this point or 6868232Snate@binkert.org# else we won't know about them for the rest of the stuff. 6878232Snate@binkert.orgimporter = DictImporter(PySource.modules) 6886229Snate@binkert.orgsys.meta_path[0:0] = [ importer ] 6897673Snate@binkert.org 6905517Snate@binkert.org# import all sim objects so we can populate the all_objects list 6915517Snate@binkert.org# make sure that we're working with a list, then let's sort it 6927673Snate@binkert.orgfor modname in SimObject.modnames: 6935517Snate@binkert.org exec('from m5.objects import %s' % modname) 6945517Snate@binkert.org 6955517Snate@binkert.org# we need to unload all of the currently imported modules so that they 6965517Snate@binkert.org# will be re-imported the next time the sconscript is run 6978232Snate@binkert.orgimporter.unload() 6987673Snate@binkert.orgsys.meta_path.remove(importer) 6997673Snate@binkert.org 7008232Snate@binkert.orgsim_objects = m5.SimObject.allClasses 7018232Snate@binkert.orgall_enums = m5.params.allEnums 7028232Snate@binkert.org 7038232Snate@binkert.orgfor name,obj in sorted(sim_objects.iteritems()): 7047673Snate@binkert.org for param in obj._params.local.values(): 7055517Snate@binkert.org # load the ptype attribute now because it depends on the 7068232Snate@binkert.org # current version of SimObject.allClasses, but when scons 7078232Snate@binkert.org # actually uses the value, all versions of 7088232Snate@binkert.org # SimObject.allClasses will have been loaded 7098232Snate@binkert.org param.ptype 7107673Snate@binkert.org 7118232Snate@binkert.org######################################################################## 7128232Snate@binkert.org# 7138232Snate@binkert.org# calculate extra dependencies 7148232Snate@binkert.org# 7158232Snate@binkert.orgmodule_depends = ["m5", "m5.SimObject", "m5.params"] 7168232Snate@binkert.orgdepends = [ PySource.modules[dep].snode for dep in module_depends ] 7177673Snate@binkert.orgdepends.sort(key = lambda x: x.name) 7185517Snate@binkert.org 7198232Snate@binkert.org######################################################################## 7208232Snate@binkert.org# 7215517Snate@binkert.org# Commands for the basic automatically generated python files 7227673Snate@binkert.org# 7235517Snate@binkert.org 7248232Snate@binkert.org# Generate Python file containing a dict specifying the current 7258232Snate@binkert.org# buildEnv flags. 7265517Snate@binkert.orgdef makeDefinesPyFile(target, source, env): 7278232Snate@binkert.org build_env = source[0].get_contents() 7288232Snate@binkert.org 7298232Snate@binkert.org code = code_formatter() 7307673Snate@binkert.org code(""" 7315517Snate@binkert.orgimport _m5.core 7325517Snate@binkert.orgimport m5.util 7337673Snate@binkert.org 7345517Snate@binkert.orgbuildEnv = m5.util.SmartDict($build_env) 7355517Snate@binkert.org 7365517Snate@binkert.orgcompileDate = _m5.core.compileDate 7378232Snate@binkert.org_globals = globals() 7385517Snate@binkert.orgfor key,val in _m5.core.__dict__.iteritems(): 7395517Snate@binkert.org if key.startswith('flag_'): 7408232Snate@binkert.org flag = key[5:] 7418232Snate@binkert.org _globals[flag] = val 7425517Snate@binkert.orgdel _globals 7438232Snate@binkert.org""") 7448232Snate@binkert.org code.write(target[0].abspath) 7455517Snate@binkert.org 7468232Snate@binkert.orgdefines_info = Value(build_env) 7478232Snate@binkert.org# Generate a file with all of the compile options in it 7488232Snate@binkert.orgenv.Command('python/m5/defines.py', defines_info, 7495517Snate@binkert.org MakeAction(makeDefinesPyFile, Transform("DEFINES", 0))) 7508232Snate@binkert.orgPySource('m5', 'python/m5/defines.py') 7518232Snate@binkert.org 7528232Snate@binkert.org# Generate python file containing info about the M5 source code 7538232Snate@binkert.orgdef makeInfoPyFile(target, source, env): 7548232Snate@binkert.org code = code_formatter() 7558232Snate@binkert.org for src in source: 7565517Snate@binkert.org data = ''.join(file(src.srcnode().abspath, 'r').xreadlines()) 7578232Snate@binkert.org code('$src = ${{repr(data)}}') 7588232Snate@binkert.org code.write(str(target[0])) 7595517Snate@binkert.org 7608232Snate@binkert.org# Generate a file that wraps the basic top level files 7617673Snate@binkert.orgenv.Command('python/m5/info.py', 7625517Snate@binkert.org [ '#/COPYING', '#/LICENSE', '#/README', ], 7637673Snate@binkert.org MakeAction(makeInfoPyFile, Transform("INFO"))) 7645517Snate@binkert.orgPySource('m5', 'python/m5/info.py') 7658232Snate@binkert.org 7668232Snate@binkert.org######################################################################## 7678232Snate@binkert.org# 7685192Ssaidi@eecs.umich.edu# Create all of the SimObject param headers and enum headers 7698232Snate@binkert.org# 7708232Snate@binkert.org 7718232Snate@binkert.orgdef createSimObjectParamStruct(target, source, env): 7728232Snate@binkert.org assert len(target) == 1 and len(source) == 1 7738232Snate@binkert.org 7745192Ssaidi@eecs.umich.edu name = source[0].get_text_contents() 7757674Snate@binkert.org obj = sim_objects[name] 7765522Snate@binkert.org 7775522Snate@binkert.org code = code_formatter() 7787674Snate@binkert.org obj.cxx_param_decl(code) 7797674Snate@binkert.org code.write(target[0].abspath) 7807674Snate@binkert.org 7817674Snate@binkert.orgdef createSimObjectCxxConfig(is_header): 7827674Snate@binkert.org def body(target, source, env): 7837674Snate@binkert.org assert len(target) == 1 and len(source) == 1 7847674Snate@binkert.org 7857674Snate@binkert.org name = str(source[0].get_contents()) 7865522Snate@binkert.org obj = sim_objects[name] 7875522Snate@binkert.org 7885522Snate@binkert.org code = code_formatter() 7895517Snate@binkert.org obj.cxx_config_param_file(code, is_header) 7905522Snate@binkert.org code.write(target[0].abspath) 7915517Snate@binkert.org return body 7926143Snate@binkert.org 7936727Ssteve.reinhardt@amd.comdef createEnumStrings(target, source, env): 7945522Snate@binkert.org assert len(target) == 1 and len(source) == 2 7955522Snate@binkert.org 7965522Snate@binkert.org name = source[0].get_text_contents() 7977674Snate@binkert.org use_python = source[1].read() 7985517Snate@binkert.org obj = all_enums[name] 7997673Snate@binkert.org 8007673Snate@binkert.org code = code_formatter() 8017674Snate@binkert.org obj.cxx_def(code) 8027673Snate@binkert.org if use_python: 8037674Snate@binkert.org obj.pybind_def(code) 8047674Snate@binkert.org code.write(target[0].abspath) 8058946Sandreas.hansson@arm.com 8067674Snate@binkert.orgdef createEnumDecls(target, source, env): 8077674Snate@binkert.org assert len(target) == 1 and len(source) == 1 8087674Snate@binkert.org 8095522Snate@binkert.org name = source[0].get_text_contents() 8105522Snate@binkert.org obj = all_enums[name] 8117674Snate@binkert.org 8127674Snate@binkert.org code = code_formatter() 8137674Snate@binkert.org obj.cxx_decl(code) 8147674Snate@binkert.org code.write(target[0].abspath) 8157673Snate@binkert.org 8167674Snate@binkert.orgdef createSimObjectPyBindWrapper(target, source, env): 8177674Snate@binkert.org name = source[0].get_text_contents() 8187674Snate@binkert.org obj = sim_objects[name] 8197674Snate@binkert.org 8207674Snate@binkert.org code = code_formatter() 8217674Snate@binkert.org obj.pybind_decl(code) 8227674Snate@binkert.org code.write(target[0].abspath) 8237674Snate@binkert.org 8247811Ssteve.reinhardt@amd.com# Generate all of the SimObject param C++ struct header files 8257674Snate@binkert.orgparams_hh_files = [] 8267673Snate@binkert.orgfor name,simobj in sorted(sim_objects.iteritems()): 8275522Snate@binkert.org py_source = PySource.modules[simobj.__module__] 8286143Snate@binkert.org extra_deps = [ py_source.tnode ] 8297756SAli.Saidi@ARM.com 8307816Ssteve.reinhardt@amd.com hh_file = File('params/%s.hh' % name) 8317674Snate@binkert.org params_hh_files.append(hh_file) 8324382Sbinkertn@umich.edu env.Command(hh_file, Value(name), 8334382Sbinkertn@umich.edu MakeAction(createSimObjectParamStruct, Transform("SO PARAM"))) 8344382Sbinkertn@umich.edu env.Depends(hh_file, depends + extra_deps) 8354382Sbinkertn@umich.edu 8364382Sbinkertn@umich.edu# C++ parameter description files 8374382Sbinkertn@umich.eduif GetOption('with_cxx_config'): 8384382Sbinkertn@umich.edu for name,simobj in sorted(sim_objects.iteritems()): 8394382Sbinkertn@umich.edu py_source = PySource.modules[simobj.__module__] 8404382Sbinkertn@umich.edu extra_deps = [ py_source.tnode ] 8414382Sbinkertn@umich.edu 8426143Snate@binkert.org cxx_config_hh_file = File('cxx_config/%s.hh' % name) 843955SN/A cxx_config_cc_file = File('cxx_config/%s.cc' % name) 8442655Sstever@eecs.umich.edu env.Command(cxx_config_hh_file, Value(name), 8452655Sstever@eecs.umich.edu MakeAction(createSimObjectCxxConfig(True), 8462655Sstever@eecs.umich.edu Transform("CXXCPRHH"))) 8472655Sstever@eecs.umich.edu env.Command(cxx_config_cc_file, Value(name), 8482655Sstever@eecs.umich.edu MakeAction(createSimObjectCxxConfig(False), 8495601Snate@binkert.org Transform("CXXCPRCC"))) 8505601Snate@binkert.org env.Depends(cxx_config_hh_file, depends + extra_deps + 8518334Snate@binkert.org [File('params/%s.hh' % name), File('sim/cxx_config.hh')]) 8528334Snate@binkert.org env.Depends(cxx_config_cc_file, depends + extra_deps + 8538334Snate@binkert.org [cxx_config_hh_file]) 8545522Snate@binkert.org Source(cxx_config_cc_file) 8555863Snate@binkert.org 8565601Snate@binkert.org cxx_config_init_cc_file = File('cxx_config/init.cc') 8575601Snate@binkert.org 8585601Snate@binkert.org def createCxxConfigInitCC(target, source, env): 8595863Snate@binkert.org assert len(target) == 1 and len(source) == 1 8608945Ssteve.reinhardt@amd.com 8615559Snate@binkert.org code = code_formatter() 8629175Sandreas.hansson@arm.com 8639175Sandreas.hansson@arm.com for name,simobj in sorted(sim_objects.iteritems()): 8649175Sandreas.hansson@arm.com if not hasattr(simobj, 'abstract') or not simobj.abstract: 8658946Sandreas.hansson@arm.com code('#include "cxx_config/${name}.hh"') 8668614Sgblack@eecs.umich.edu code() 8678737Skoansin.tan@gmail.com code('void cxxConfigInit()') 8689175Sandreas.hansson@arm.com code('{') 8698945Ssteve.reinhardt@amd.com code.indent() 8708945Ssteve.reinhardt@amd.com for name,simobj in sorted(sim_objects.iteritems()): 8718945Ssteve.reinhardt@amd.com not_abstract = not hasattr(simobj, 'abstract') or \ 8728945Ssteve.reinhardt@amd.com not simobj.abstract 8736143Snate@binkert.org if not_abstract and 'type' in simobj.__dict__: 8746143Snate@binkert.org code('cxx_config_directory["${name}"] = ' 8756143Snate@binkert.org '${name}CxxConfigParams::makeDirectoryEntry();') 8766143Snate@binkert.org code.dedent() 8776143Snate@binkert.org code('}') 8786143Snate@binkert.org code.write(target[0].abspath) 8796143Snate@binkert.org 8808945Ssteve.reinhardt@amd.com py_source = PySource.modules[simobj.__module__] 8818945Ssteve.reinhardt@amd.com extra_deps = [ py_source.tnode ] 8826143Snate@binkert.org env.Command(cxx_config_init_cc_file, Value(name), 8836143Snate@binkert.org MakeAction(createCxxConfigInitCC, Transform("CXXCINIT"))) 8846143Snate@binkert.org cxx_param_hh_files = ["cxx_config/%s.hh" % simobj 8856143Snate@binkert.org for name,simobj in sorted(sim_objects.iteritems()) 8866143Snate@binkert.org if not hasattr(simobj, 'abstract') or not simobj.abstract] 8876143Snate@binkert.org Depends(cxx_config_init_cc_file, cxx_param_hh_files + 8886143Snate@binkert.org [File('sim/cxx_config.hh')]) 8896143Snate@binkert.org Source(cxx_config_init_cc_file) 8906143Snate@binkert.org 8916143Snate@binkert.org# Generate all enum header files 8926143Snate@binkert.orgfor name,enum in sorted(all_enums.iteritems()): 8936143Snate@binkert.org py_source = PySource.modules[enum.__module__] 8946143Snate@binkert.org extra_deps = [ py_source.tnode ] 8958594Snate@binkert.org 8968594Snate@binkert.org cc_file = File('enums/%s.cc' % name) 8978594Snate@binkert.org env.Command(cc_file, [Value(name), Value(env['USE_PYTHON'])], 8988594Snate@binkert.org MakeAction(createEnumStrings, Transform("ENUM STR"))) 8996143Snate@binkert.org env.Depends(cc_file, depends + extra_deps) 9006143Snate@binkert.org Source(cc_file) 9016143Snate@binkert.org 9026143Snate@binkert.org hh_file = File('enums/%s.hh' % name) 9036143Snate@binkert.org env.Command(hh_file, Value(name), 9046240Snate@binkert.org MakeAction(createEnumDecls, Transform("ENUMDECL"))) 9055554Snate@binkert.org env.Depends(hh_file, depends + extra_deps) 9065522Snate@binkert.org 9075522Snate@binkert.org# Generate SimObject Python bindings wrapper files 9085797Snate@binkert.orgif env['USE_PYTHON']: 9095797Snate@binkert.org for name,simobj in sorted(sim_objects.iteritems()): 9105522Snate@binkert.org py_source = PySource.modules[simobj.__module__] 9115601Snate@binkert.org extra_deps = [ py_source.tnode ] 9128233Snate@binkert.org cc_file = File('python/_m5/param_%s.cc' % name) 9138233Snate@binkert.org env.Command(cc_file, Value(name), 9148235Snate@binkert.org MakeAction(createSimObjectPyBindWrapper, 9158235Snate@binkert.org Transform("SO PyBind"))) 9168235Snate@binkert.org env.Depends(cc_file, depends + extra_deps) 9178235Snate@binkert.org Source(cc_file) 9189003SAli.Saidi@ARM.com 9199003SAli.Saidi@ARM.com# Build all protocol buffers if we have got protoc and protobuf available 9208235Snate@binkert.orgif env['HAVE_PROTOBUF']: 9218942Sgblack@eecs.umich.edu for proto in ProtoBuf.all: 9228235Snate@binkert.org # Use both the source and header as the target, and the .proto 9236143Snate@binkert.org # file as the source. When executing the protoc compiler, also 9242655Sstever@eecs.umich.edu # specify the proto_path to avoid having the generated files 9256143Snate@binkert.org # include the path. 9266143Snate@binkert.org env.Command([proto.cc_file, proto.hh_file], proto.tnode, 9278233Snate@binkert.org MakeAction('$PROTOC --cpp_out ${TARGET.dir} ' 9286143Snate@binkert.org '--proto_path ${SOURCE.dir} $SOURCE', 9296143Snate@binkert.org Transform("PROTOC"))) 9304007Ssaidi@eecs.umich.edu 9314596Sbinkertn@umich.edu # Add the C++ source file 9324007Ssaidi@eecs.umich.edu Source(proto.cc_file, tags=proto.tags) 9334596Sbinkertn@umich.eduelif ProtoBuf.all: 9347756SAli.Saidi@ARM.com print('Got protobuf to build, but lacks support!') 9357816Ssteve.reinhardt@amd.com Exit(1) 9368334Snate@binkert.org 9378334Snate@binkert.org# 9388334Snate@binkert.org# Handle debug flags 9398334Snate@binkert.org# 9405601Snate@binkert.orgdef makeDebugFlagCC(target, source, env): 9415601Snate@binkert.org assert(len(target) == 1 and len(source) == 1) 9422655Sstever@eecs.umich.edu 9439225Sandreas.hansson@arm.com code = code_formatter() 9449225Sandreas.hansson@arm.com 9459226Sandreas.hansson@arm.com # delay definition of CompoundFlags until after all the definition 9469226Sandreas.hansson@arm.com # of all constituent SimpleFlags 9479225Sandreas.hansson@arm.com comp_code = code_formatter() 9489226Sandreas.hansson@arm.com 9499226Sandreas.hansson@arm.com # file header 9509226Sandreas.hansson@arm.com code(''' 9519226Sandreas.hansson@arm.com/* 9529226Sandreas.hansson@arm.com * DO NOT EDIT THIS FILE! Automatically generated by SCons. 9539226Sandreas.hansson@arm.com */ 9549225Sandreas.hansson@arm.com 9559227Sandreas.hansson@arm.com#include "base/debug.hh" 9569227Sandreas.hansson@arm.com 9579227Sandreas.hansson@arm.comnamespace Debug { 9589227Sandreas.hansson@arm.com 9598946Sandreas.hansson@arm.com''') 9603918Ssaidi@eecs.umich.edu 9619225Sandreas.hansson@arm.com for name, flag in sorted(source[0].read().iteritems()): 9623918Ssaidi@eecs.umich.edu n, compound, desc = flag 9639225Sandreas.hansson@arm.com assert n == name 9649225Sandreas.hansson@arm.com 9659227Sandreas.hansson@arm.com if not compound: 9669227Sandreas.hansson@arm.com code('SimpleFlag $name("$name", "$desc");') 9679227Sandreas.hansson@arm.com else: 9689226Sandreas.hansson@arm.com comp_code('CompoundFlag $name("$name", "$desc",') 9699225Sandreas.hansson@arm.com comp_code.indent() 9709227Sandreas.hansson@arm.com last = len(compound) - 1 9719227Sandreas.hansson@arm.com for i,flag in enumerate(compound): 9729227Sandreas.hansson@arm.com if i != last: 9739227Sandreas.hansson@arm.com comp_code('&$flag,') 9749227Sandreas.hansson@arm.com else: 9753918Ssaidi@eecs.umich.edu comp_code('&$flag);') 9769225Sandreas.hansson@arm.com comp_code.dedent() 9779225Sandreas.hansson@arm.com 9789226Sandreas.hansson@arm.com code.append(comp_code) 9799226Sandreas.hansson@arm.com code() 9803940Ssaidi@eecs.umich.edu code('} // namespace Debug') 9819225Sandreas.hansson@arm.com 9829225Sandreas.hansson@arm.com code.write(str(target[0])) 9839226Sandreas.hansson@arm.com 9849226Sandreas.hansson@arm.comdef makeDebugFlagHH(target, source, env): 9858946Sandreas.hansson@arm.com assert(len(target) == 1 and len(source) == 1) 9869225Sandreas.hansson@arm.com 9879226Sandreas.hansson@arm.com val = eval(source[0].get_contents()) 9889226Sandreas.hansson@arm.com name, compound, desc = val 9899226Sandreas.hansson@arm.com 9903515Ssaidi@eecs.umich.edu code = code_formatter() 9913918Ssaidi@eecs.umich.edu 9924762Snate@binkert.org # file header boilerplate 9933515Ssaidi@eecs.umich.edu code('''\ 9948881Smarc.orr@gmail.com/* 9958881Smarc.orr@gmail.com * DO NOT EDIT THIS FILE! Automatically generated by SCons. 9968881Smarc.orr@gmail.com */ 9978881Smarc.orr@gmail.com 9988881Smarc.orr@gmail.com#ifndef __DEBUG_${name}_HH__ 9999226Sandreas.hansson@arm.com#define __DEBUG_${name}_HH__ 10009226Sandreas.hansson@arm.com 10019226Sandreas.hansson@arm.comnamespace Debug { 10028881Smarc.orr@gmail.com''') 10038881Smarc.orr@gmail.com 10048881Smarc.orr@gmail.com if compound: 10058881Smarc.orr@gmail.com code('class CompoundFlag;') 10068881Smarc.orr@gmail.com code('class SimpleFlag;') 10078881Smarc.orr@gmail.com 10088881Smarc.orr@gmail.com if compound: 10098881Smarc.orr@gmail.com code('extern CompoundFlag $name;') 10108881Smarc.orr@gmail.com for flag in compound: 10118881Smarc.orr@gmail.com code('extern SimpleFlag $flag;') 10128881Smarc.orr@gmail.com else: 10138881Smarc.orr@gmail.com code('extern SimpleFlag $name;') 10148881Smarc.orr@gmail.com 10158881Smarc.orr@gmail.com code(''' 10168881Smarc.orr@gmail.com} 10178881Smarc.orr@gmail.com 10188881Smarc.orr@gmail.com#endif // __DEBUG_${name}_HH__ 10198881Smarc.orr@gmail.com''') 10208881Smarc.orr@gmail.com 10218881Smarc.orr@gmail.com code.write(str(target[0])) 10229225Sandreas.hansson@arm.com 10239225Sandreas.hansson@arm.comfor name,flag in sorted(debug_flags.iteritems()): 1024955SN/A n, compound, desc = flag 1025955SN/A assert n == name 10268881Smarc.orr@gmail.com 10278881Smarc.orr@gmail.com hh_file = 'debug/%s.hh' % name 10288881Smarc.orr@gmail.com env.Command(hh_file, Value(flag), 10299225Sandreas.hansson@arm.com MakeAction(makeDebugFlagHH, Transform("TRACING", 0))) 10309225Sandreas.hansson@arm.com 1031955SN/Aenv.Command('debug/flags.cc', Value(debug_flags), 1032955SN/A MakeAction(makeDebugFlagCC, Transform("TRACING", 0))) 10338881Smarc.orr@gmail.comSource('debug/flags.cc') 10348881Smarc.orr@gmail.com 10358881Smarc.orr@gmail.com# version tags 10369225Sandreas.hansson@arm.comtags = \ 10379225Sandreas.hansson@arm.comenv.Command('sim/tags.cc', None, 1038955SN/A MakeAction('util/cpt_upgrader.py --get-cc-file > $TARGET', 10399226Sandreas.hansson@arm.com Transform("VER TAGS"))) 10408881Smarc.orr@gmail.comenv.AlwaysBuild(tags) 10418881Smarc.orr@gmail.com 10428881Smarc.orr@gmail.com# Embed python files. All .py files that have been indicated by a 10438881Smarc.orr@gmail.com# PySource() call in a SConscript need to be embedded into the M5 10449225Sandreas.hansson@arm.com# library. To do that, we compile the file to byte code, marshal the 10451869SN/A# byte code, compress it, and then generate a c++ file that 10469226Sandreas.hansson@arm.com# inserts the result into an array. 10479226Sandreas.hansson@arm.comdef embedPyFile(target, source, env): 10489226Sandreas.hansson@arm.com def c_str(string): 10499226Sandreas.hansson@arm.com if string is None: 10509226Sandreas.hansson@arm.com return "0" 10519226Sandreas.hansson@arm.com return '"%s"' % string 10529226Sandreas.hansson@arm.com 10531869SN/A '''Action function to compile a .py into a code object, marshal 1054 it, compress it, and stick it into an asm file so the code appears 1055 as just bytes with a label in the data section''' 1056 1057 src = file(str(source[0]), 'r').read() 1058 1059 pysource = PySource.tnodes[source[0]] 1060 compiled = compile(src, pysource.abspath, 'exec') 1061 marshalled = marshal.dumps(compiled) 1062 compressed = zlib.compress(marshalled) 1063 data = compressed 1064 sym = pysource.symname 1065 1066 code = code_formatter() 1067 code('''\ 1068#include "sim/init.hh" 1069 1070namespace { 1071 1072const uint8_t data_${sym}[] = { 1073''') 1074 code.indent() 1075 step = 16 1076 for i in xrange(0, len(data), step): 1077 x = array.array('B', data[i:i+step]) 1078 code(''.join('%d,' % d for d in x)) 1079 code.dedent() 1080 1081 code('''}; 1082 1083EmbeddedPython embedded_${sym}( 1084 ${{c_str(pysource.arcname)}}, 1085 ${{c_str(pysource.abspath)}}, 1086 ${{c_str(pysource.modpath)}}, 1087 data_${sym}, 1088 ${{len(data)}}, 1089 ${{len(marshalled)}}); 1090 1091} // anonymous namespace 1092''') 1093 code.write(str(target[0])) 1094 1095for source in PySource.all: 1096 env.Command(source.cpp, source.tnode, 1097 MakeAction(embedPyFile, Transform("EMBED PY"))) 1098 Source(source.cpp, tags=source.tags, add_tags='python') 1099 1100######################################################################## 1101# 1102# Define binaries. Each different build type (debug, opt, etc.) gets 1103# a slightly different build environment. 1104# 1105 1106# List of constructed environments to pass back to SConstruct 1107date_source = Source('base/date.cc', tags=[]) 1108 1109gem5_binary = Gem5('gem5') 1110 1111# Function to create a new build environment as clone of current 1112# environment 'env' with modified object suffix and optional stripped 1113# binary. Additional keyword arguments are appended to corresponding 1114# build environment vars. 1115def makeEnv(env, label, objsfx, strip=False, disable_partial=False, **kwargs): 1116 # SCons doesn't know to append a library suffix when there is a '.' in the 1117 # name. Use '_' instead. 1118 libname = 'gem5_' + label 1119 secondary_exename = 'm5.' + label 1120 1121 new_env = env.Clone(OBJSUFFIX=objsfx, SHOBJSUFFIX=objsfx + 's') 1122 new_env.Label = label 1123 new_env.Append(**kwargs) 1124 1125 lib_sources = Source.all.with_tag('gem5 lib') 1126 1127 # Without Python, leave out all Python content from the library 1128 # builds. The option doesn't affect gem5 built as a program 1129 if GetOption('without_python'): 1130 lib_sources = lib_sources.without_tag('python') 1131 1132 static_objs = [] 1133 shared_objs = [] 1134 1135 for s in lib_sources.with_tag(Source.ungrouped_tag): 1136 static_objs.append(s.static(new_env)) 1137 shared_objs.append(s.shared(new_env)) 1138 1139 for group in Source.source_groups: 1140 srcs = lib_sources.with_tag(Source.link_group_tag(group)) 1141 if not srcs: 1142 continue 1143 1144 group_static = [ s.static(new_env) for s in srcs ] 1145 group_shared = [ s.shared(new_env) for s in srcs ] 1146 1147 # If partial linking is disabled, add these sources to the build 1148 # directly, and short circuit this loop. 1149 if disable_partial: 1150 static_objs.extend(group_static) 1151 shared_objs.extend(group_shared) 1152 continue 1153 1154 # Set up the static partially linked objects. 1155 file_name = new_env.subst("${OBJPREFIX}lib${OBJSUFFIX}.partial") 1156 target = File(joinpath(group, file_name)) 1157 partial = env.PartialStatic(target=target, source=group_static) 1158 static_objs.extend(partial) 1159 1160 # Set up the shared partially linked objects. 1161 file_name = new_env.subst("${SHOBJPREFIX}lib${SHOBJSUFFIX}.partial") 1162 target = File(joinpath(group, file_name)) 1163 partial = env.PartialShared(target=target, source=group_shared) 1164 shared_objs.extend(partial) 1165 1166 static_date = date_source.static(new_env) 1167 new_env.Depends(static_date, static_objs) 1168 static_objs.extend(static_date) 1169 1170 shared_date = date_source.shared(new_env) 1171 new_env.Depends(shared_date, shared_objs) 1172 shared_objs.extend(shared_date) 1173 1174 main_objs = [ s.static(new_env) for s in Source.all.with_tag('main') ] 1175 1176 # First make a library of everything but main() so other programs can 1177 # link against m5. 1178 static_lib = new_env.StaticLibrary(libname, static_objs) 1179 shared_lib = new_env.SharedLibrary(libname, shared_objs) 1180 1181 # Keep track of the object files generated so far so Executables can 1182 # include them. 1183 new_env['STATIC_OBJS'] = static_objs 1184 new_env['SHARED_OBJS'] = shared_objs 1185 new_env['MAIN_OBJS'] = main_objs 1186 1187 new_env['STATIC_LIB'] = static_lib 1188 new_env['SHARED_LIB'] = shared_lib 1189 1190 # Record some settings for building Executables. 1191 new_env['EXE_SUFFIX'] = label 1192 new_env['STRIP_EXES'] = strip 1193 1194 for cls in ExecutableMeta.all: 1195 cls.declare_all(new_env) 1196 1197 new_env.M5Binary = File(gem5_binary.path(new_env)) 1198 1199 new_env.Command(secondary_exename, new_env.M5Binary, 1200 MakeAction('ln $SOURCE $TARGET', Transform("HARDLINK"))) 1201 1202 # Set up regression tests. 1203 SConscript(os.path.join(env.root.abspath, 'tests', 'SConscript'), 1204 variant_dir=Dir('tests').Dir(new_env.Label), 1205 exports={ 'env' : new_env }, duplicate=False) 1206 1207# Start out with the compiler flags common to all compilers, 1208# i.e. they all use -g for opt and -g -pg for prof 1209ccflags = {'debug' : [], 'opt' : ['-g'], 'fast' : [], 'prof' : ['-g', '-pg'], 1210 'perf' : ['-g']} 1211 1212# Start out with the linker flags common to all linkers, i.e. -pg for 1213# prof, and -lprofiler for perf. The -lprofile flag is surrounded by 1214# no-as-needed and as-needed as the binutils linker is too clever and 1215# simply doesn't link to the library otherwise. 1216ldflags = {'debug' : [], 'opt' : [], 'fast' : [], 'prof' : ['-pg'], 1217 'perf' : ['-Wl,--no-as-needed', '-lprofiler', '-Wl,--as-needed']} 1218 1219# For Link Time Optimization, the optimisation flags used to compile 1220# individual files are decoupled from those used at link time 1221# (i.e. you can compile with -O3 and perform LTO with -O0), so we need 1222# to also update the linker flags based on the target. 1223if env['GCC']: 1224 if sys.platform == 'sunos5': 1225 ccflags['debug'] += ['-gstabs+'] 1226 else: 1227 ccflags['debug'] += ['-ggdb3'] 1228 ldflags['debug'] += ['-O0'] 1229 # opt, fast, prof and perf all share the same cc flags, also add 1230 # the optimization to the ldflags as LTO defers the optimization 1231 # to link time 1232 for target in ['opt', 'fast', 'prof', 'perf']: 1233 ccflags[target] += ['-O3'] 1234 ldflags[target] += ['-O3'] 1235 1236 ccflags['fast'] += env['LTO_CCFLAGS'] 1237 ldflags['fast'] += env['LTO_LDFLAGS'] 1238elif env['CLANG']: 1239 ccflags['debug'] += ['-g', '-O0'] 1240 # opt, fast, prof and perf all share the same cc flags 1241 for target in ['opt', 'fast', 'prof', 'perf']: 1242 ccflags[target] += ['-O3'] 1243else: 1244 print('Unknown compiler, please fix compiler options') 1245 Exit(1) 1246 1247 1248# To speed things up, we only instantiate the build environments we 1249# need. We try to identify the needed environment for each target; if 1250# we can't, we fall back on instantiating all the environments just to 1251# be safe. 1252target_types = ['debug', 'opt', 'fast', 'prof', 'perf'] 1253obj2target = {'do': 'debug', 'o': 'opt', 'fo': 'fast', 'po': 'prof', 1254 'gpo' : 'perf'} 1255 1256def identifyTarget(t): 1257 ext = t.split('.')[-1] 1258 if ext in target_types: 1259 return ext 1260 if obj2target.has_key(ext): 1261 return obj2target[ext] 1262 match = re.search(r'/tests/([^/]+)/', t) 1263 if match and match.group(1) in target_types: 1264 return match.group(1) 1265 return 'all' 1266 1267needed_envs = [identifyTarget(target) for target in BUILD_TARGETS] 1268if 'all' in needed_envs: 1269 needed_envs += target_types 1270 1271# Debug binary 1272if 'debug' in needed_envs: 1273 makeEnv(env, 'debug', '.do', 1274 CCFLAGS = Split(ccflags['debug']), 1275 CPPDEFINES = ['DEBUG', 'TRACING_ON=1'], 1276 LINKFLAGS = Split(ldflags['debug'])) 1277 1278# Optimized binary 1279if 'opt' in needed_envs: 1280 makeEnv(env, 'opt', '.o', 1281 CCFLAGS = Split(ccflags['opt']), 1282 CPPDEFINES = ['TRACING_ON=1'], 1283 LINKFLAGS = Split(ldflags['opt'])) 1284 1285# "Fast" binary 1286if 'fast' in needed_envs: 1287 disable_partial = \ 1288 env.get('BROKEN_INCREMENTAL_LTO', False) and \ 1289 GetOption('force_lto') 1290 makeEnv(env, 'fast', '.fo', strip = True, 1291 CCFLAGS = Split(ccflags['fast']), 1292 CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'], 1293 LINKFLAGS = Split(ldflags['fast']), 1294 disable_partial=disable_partial) 1295 1296# Profiled binary using gprof 1297if 'prof' in needed_envs: 1298 makeEnv(env, 'prof', '.po', 1299 CCFLAGS = Split(ccflags['prof']), 1300 CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'], 1301 LINKFLAGS = Split(ldflags['prof'])) 1302 1303# Profiled binary using google-pprof 1304if 'perf' in needed_envs: 1305 makeEnv(env, 'perf', '.gpo', 1306 CCFLAGS = Split(ccflags['perf']), 1307 CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'], 1308 LINKFLAGS = Split(ldflags['perf'])) 1309