2004-07-03 06:16:38 +02:00
|
|
|
# -*- mode:python -*-
|
|
|
|
|
2005-06-05 11:16:00 +02:00
|
|
|
# Copyright (c) 2004-2005 The Regents of The University of Michigan
|
2004-07-03 06:16:38 +02:00
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions are
|
|
|
|
# met: redistributions of source code must retain the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer;
|
|
|
|
# redistributions in binary form must reproduce the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer in the
|
|
|
|
# documentation and/or other materials provided with the distribution;
|
|
|
|
# neither the name of the copyright holders nor the names of its
|
|
|
|
# contributors may be used to endorse or promote products derived from
|
|
|
|
# this software without specific prior written permission.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2006-06-01 01:26:56 +02:00
|
|
|
#
|
2007-07-24 06:51:38 +02:00
|
|
|
# Authors: Nathan Binkert
|
2004-07-03 06:16:38 +02:00
|
|
|
|
2007-07-24 06:51:38 +02:00
|
|
|
import imp
|
2004-07-03 06:16:38 +02:00
|
|
|
import os
|
|
|
|
import sys
|
2007-03-11 08:00:54 +01:00
|
|
|
|
2008-02-06 02:43:45 +01:00
|
|
|
from os.path import basename, exists, isdir, isfile, join as joinpath
|
2004-07-03 06:16:38 +02:00
|
|
|
|
2007-04-12 18:07:59 +02:00
|
|
|
import SCons
|
|
|
|
|
2004-07-03 06:16:38 +02:00
|
|
|
# This file defines how to build a particular configuration of M5
|
|
|
|
# based on variable settings in the 'env' build environment.
|
|
|
|
|
2007-03-11 08:00:54 +01:00
|
|
|
Import('*')
|
2004-07-03 06:16:38 +02:00
|
|
|
|
2007-04-13 06:20:04 +02:00
|
|
|
# Children need to see the environment
|
|
|
|
Export('env')
|
|
|
|
|
2007-07-24 06:51:38 +02:00
|
|
|
def sort_list(_list):
|
|
|
|
"""return a sorted copy of '_list'"""
|
|
|
|
if isinstance(_list, list):
|
|
|
|
_list = _list[:]
|
|
|
|
else:
|
|
|
|
_list = list(_list)
|
|
|
|
_list.sort()
|
|
|
|
return _list
|
|
|
|
|
|
|
|
class PySourceFile(object):
|
|
|
|
def __init__(self, package, source):
|
|
|
|
filename = str(source)
|
|
|
|
pyname = basename(filename)
|
|
|
|
assert pyname.endswith('.py')
|
|
|
|
name = pyname[:-3]
|
|
|
|
path = package.split('.')
|
|
|
|
modpath = path
|
|
|
|
if name != '__init__':
|
|
|
|
modpath += [name]
|
|
|
|
modpath = '.'.join(modpath)
|
|
|
|
|
|
|
|
arcpath = package.split('.') + [ pyname + 'c' ]
|
|
|
|
arcname = joinpath(*arcpath)
|
|
|
|
|
|
|
|
self.source = source
|
|
|
|
self.pyname = pyname
|
|
|
|
self.srcpath = source.srcnode().abspath
|
|
|
|
self.package = package
|
|
|
|
self.modpath = modpath
|
|
|
|
self.arcname = arcname
|
|
|
|
self.filename = filename
|
|
|
|
self.compiled = File(filename + 'c')
|
|
|
|
|
2007-04-13 06:20:04 +02:00
|
|
|
########################################################################
|
2007-07-24 06:51:38 +02:00
|
|
|
# Code for adding source files of various types
|
2007-04-13 06:20:04 +02:00
|
|
|
#
|
2007-07-24 06:51:38 +02:00
|
|
|
cc_sources = []
|
2007-04-12 18:07:59 +02:00
|
|
|
def Source(source):
|
2007-07-24 06:51:38 +02:00
|
|
|
'''Add a C/C++ source file to the build'''
|
|
|
|
if not isinstance(source, SCons.Node.FS.File):
|
|
|
|
source = File(source)
|
2004-07-03 06:16:38 +02:00
|
|
|
|
2007-07-24 06:51:38 +02:00
|
|
|
cc_sources.append(source)
|
2006-02-21 05:26:39 +01:00
|
|
|
|
2007-04-13 06:20:04 +02:00
|
|
|
py_sources = []
|
|
|
|
def PySource(package, source):
|
2007-07-24 06:51:38 +02:00
|
|
|
'''Add a python source file to the named package'''
|
2007-04-13 06:20:04 +02:00
|
|
|
if not isinstance(source, SCons.Node.FS.File):
|
|
|
|
source = File(source)
|
2007-07-24 06:51:38 +02:00
|
|
|
|
|
|
|
source = PySourceFile(package, source)
|
2007-04-13 06:20:04 +02:00
|
|
|
py_sources.append(source)
|
|
|
|
|
2007-07-24 06:51:38 +02:00
|
|
|
sim_objects_fixed = False
|
|
|
|
sim_object_modfiles = set()
|
2007-04-13 06:20:04 +02:00
|
|
|
def SimObject(source):
|
2007-07-24 06:51:38 +02:00
|
|
|
'''Add a SimObject python file as a python source object and add
|
|
|
|
it to a list of sim object modules'''
|
|
|
|
|
|
|
|
if sim_objects_fixed:
|
|
|
|
raise AttributeError, "Too late to call SimObject now."
|
|
|
|
|
2007-04-13 06:20:04 +02:00
|
|
|
if not isinstance(source, SCons.Node.FS.File):
|
|
|
|
source = File(source)
|
2007-07-24 06:51:38 +02:00
|
|
|
|
2007-04-13 06:20:04 +02:00
|
|
|
PySource('m5.objects', source)
|
2007-07-24 06:51:38 +02:00
|
|
|
modfile = basename(str(source))
|
|
|
|
assert modfile.endswith('.py')
|
|
|
|
modname = modfile[:-3]
|
|
|
|
sim_object_modfiles.add(modname)
|
2007-04-13 06:20:04 +02:00
|
|
|
|
|
|
|
swig_sources = []
|
|
|
|
def SwigSource(package, source):
|
2007-07-24 06:51:38 +02:00
|
|
|
'''Add a swig file to build'''
|
2007-04-13 06:20:04 +02:00
|
|
|
if not isinstance(source, SCons.Node.FS.File):
|
|
|
|
source = File(source)
|
2007-07-24 06:51:38 +02:00
|
|
|
val = source,package
|
|
|
|
swig_sources.append(val)
|
2007-04-13 06:20:04 +02:00
|
|
|
|
|
|
|
# Children should have access
|
2007-07-24 06:51:38 +02:00
|
|
|
Export('Source')
|
2007-04-13 06:20:04 +02:00
|
|
|
Export('PySource')
|
|
|
|
Export('SimObject')
|
|
|
|
Export('SwigSource')
|
|
|
|
|
2007-10-31 06:21:54 +01:00
|
|
|
########################################################################
|
|
|
|
#
|
|
|
|
# Trace Flags
|
|
|
|
#
|
|
|
|
all_flags = {}
|
|
|
|
trace_flags = []
|
|
|
|
def TraceFlag(name, desc=''):
|
|
|
|
if name in all_flags:
|
|
|
|
raise AttributeError, "Flag %s already specified" % name
|
|
|
|
flag = (name, (), desc)
|
|
|
|
trace_flags.append(flag)
|
|
|
|
all_flags[name] = ()
|
|
|
|
|
|
|
|
def CompoundFlag(name, flags, desc=''):
|
|
|
|
if name in all_flags:
|
|
|
|
raise AttributeError, "Flag %s already specified" % name
|
|
|
|
|
|
|
|
compound = tuple(flags)
|
|
|
|
for flag in compound:
|
|
|
|
if flag not in all_flags:
|
|
|
|
raise AttributeError, "Trace flag %s not found" % flag
|
|
|
|
if all_flags[flag]:
|
|
|
|
raise AttributeError, \
|
|
|
|
"Compound flag can't point to another compound flag"
|
|
|
|
|
|
|
|
flag = (name, compound, desc)
|
|
|
|
trace_flags.append(flag)
|
|
|
|
all_flags[name] = compound
|
|
|
|
|
|
|
|
Export('TraceFlag')
|
|
|
|
Export('CompoundFlag')
|
|
|
|
|
2007-04-13 06:20:04 +02:00
|
|
|
########################################################################
|
|
|
|
#
|
|
|
|
# Set some compiler variables
|
|
|
|
#
|
|
|
|
|
2006-06-10 05:01:31 +02:00
|
|
|
# Include file paths are rooted in this directory. SCons will
|
|
|
|
# automatically expand '.' to refer to both the source directory and
|
|
|
|
# the corresponding build directory to pick up generated include
|
|
|
|
# files.
|
|
|
|
env.Append(CPPPATH=Dir('.'))
|
|
|
|
|
2006-02-08 07:03:55 +01:00
|
|
|
# Add a flag defining what THE_ISA should be for all compilation
|
|
|
|
env.Append(CPPDEFINES=[('THE_ISA','%s_ISA' % env['TARGET_ISA'].upper())])
|
2004-10-23 04:49:12 +02:00
|
|
|
|
2007-04-13 06:20:04 +02:00
|
|
|
########################################################################
|
2007-07-24 06:51:38 +02:00
|
|
|
#
|
2008-02-11 17:04:01 +01:00
|
|
|
# Walk the tree and execute all SConscripts in subdirectories
|
2007-04-13 06:20:04 +02:00
|
|
|
#
|
2007-07-24 06:51:38 +02:00
|
|
|
|
2008-02-06 02:40:08 +01:00
|
|
|
for base_dir in base_dir_list:
|
|
|
|
here = Dir('.').srcnode().abspath
|
2008-02-11 17:04:01 +01:00
|
|
|
for root, dirs, files in os.walk(base_dir, topdown=True):
|
2008-02-06 02:40:08 +01:00
|
|
|
if root == here:
|
|
|
|
# we don't want to recurse back into this SConscript
|
|
|
|
continue
|
|
|
|
|
|
|
|
if 'SConscript' in files:
|
2008-02-11 17:04:01 +01:00
|
|
|
build_dir = joinpath(env['BUILDDIR'], root[len(base_dir) + 1:])
|
2008-02-06 02:40:08 +01:00
|
|
|
SConscript(joinpath(root, 'SConscript'), build_dir=build_dir)
|
2007-07-26 03:21:11 +02:00
|
|
|
|
2005-08-30 19:18:54 +02:00
|
|
|
for opt in env.ExportOptions:
|
|
|
|
env.ConfigFile(opt)
|
2004-09-16 21:11:38 +02:00
|
|
|
|
2007-04-13 06:20:04 +02:00
|
|
|
########################################################################
|
|
|
|
#
|
2007-07-24 06:51:38 +02:00
|
|
|
# Prevent any SimObjects from being added after this point, they
|
|
|
|
# should all have been added in the SConscripts above
|
2007-04-13 06:20:04 +02:00
|
|
|
#
|
2007-07-24 06:51:38 +02:00
|
|
|
sim_objects_fixed = True
|
2007-04-13 06:20:04 +02:00
|
|
|
|
2007-07-24 06:51:38 +02:00
|
|
|
########################################################################
|
|
|
|
#
|
|
|
|
# Manually turn python/generate.py into a python module and import it
|
|
|
|
#
|
|
|
|
generate_file = File('python/generate.py')
|
|
|
|
generate_module = imp.new_module('generate')
|
|
|
|
sys.modules['generate'] = generate_module
|
|
|
|
exec file(generate_file.srcnode().abspath, 'r') in generate_module.__dict__
|
2007-04-13 06:20:04 +02:00
|
|
|
|
2007-07-24 06:51:38 +02:00
|
|
|
########################################################################
|
|
|
|
#
|
|
|
|
# build a generate
|
|
|
|
#
|
|
|
|
from generate import Generate
|
2007-04-13 06:20:04 +02:00
|
|
|
optionDict = dict([(opt, env[opt]) for opt in env.ExportOptions])
|
2007-07-24 06:51:38 +02:00
|
|
|
generate = Generate(py_sources, sim_object_modfiles, optionDict)
|
|
|
|
m5 = generate.m5
|
|
|
|
|
|
|
|
########################################################################
|
|
|
|
#
|
|
|
|
# calculate extra dependencies
|
|
|
|
#
|
|
|
|
module_depends = ["m5", "m5.SimObject", "m5.params"]
|
|
|
|
module_depends = [ File(generate.py_modules[dep]) for dep in module_depends ]
|
|
|
|
file_depends = [ generate_file ]
|
|
|
|
depends = module_depends + file_depends
|
2007-04-13 06:20:04 +02:00
|
|
|
|
2007-07-24 06:51:38 +02:00
|
|
|
########################################################################
|
|
|
|
#
|
|
|
|
# Commands for the basic automatically generated python files
|
|
|
|
#
|
|
|
|
|
|
|
|
# Generate a file with all of the compile options in it
|
|
|
|
env.Command('python/m5/defines.py', Value(optionDict),
|
|
|
|
generate.makeDefinesPyFile)
|
|
|
|
PySource('m5', 'python/m5/defines.py')
|
2007-04-13 06:20:04 +02:00
|
|
|
|
2007-07-24 06:51:38 +02:00
|
|
|
# Generate a file that wraps the basic top level files
|
2007-04-13 06:20:04 +02:00
|
|
|
env.Command('python/m5/info.py',
|
|
|
|
[ '#/AUTHORS', '#/LICENSE', '#/README', '#/RELEASE_NOTES' ],
|
2007-07-24 06:51:38 +02:00
|
|
|
generate.makeInfoPyFile)
|
2007-04-13 06:20:04 +02:00
|
|
|
PySource('m5', 'python/m5/info.py')
|
|
|
|
|
2007-07-24 06:51:38 +02:00
|
|
|
# Generate an __init__.py file for the objects package
|
2007-04-13 06:20:04 +02:00
|
|
|
env.Command('python/m5/objects/__init__.py',
|
2007-07-24 06:51:38 +02:00
|
|
|
[ Value(o) for o in sort_list(sim_object_modfiles) ],
|
|
|
|
generate.makeObjectsInitFile)
|
2007-04-13 06:20:04 +02:00
|
|
|
PySource('m5.objects', 'python/m5/objects/__init__.py')
|
|
|
|
|
2007-07-24 06:51:38 +02:00
|
|
|
########################################################################
|
|
|
|
#
|
|
|
|
# Create all of the SimObject param headers and enum headers
|
|
|
|
#
|
|
|
|
|
|
|
|
# Generate all of the SimObject param struct header files
|
|
|
|
params_hh_files = []
|
|
|
|
for name,simobj in generate.sim_objects.iteritems():
|
|
|
|
extra_deps = [ File(generate.py_modules[simobj.__module__]) ]
|
|
|
|
|
|
|
|
hh_file = File('params/%s.hh' % name)
|
|
|
|
params_hh_files.append(hh_file)
|
|
|
|
env.Command(hh_file, Value(name), generate.createSimObjectParam)
|
|
|
|
env.Depends(hh_file, depends + extra_deps)
|
|
|
|
|
|
|
|
# Generate any parameter header files needed
|
2008-06-14 21:10:50 +02:00
|
|
|
params_i_files = []
|
2007-07-24 06:51:38 +02:00
|
|
|
for name,param in generate.params.iteritems():
|
|
|
|
if isinstance(param, m5.params.VectorParamDesc):
|
|
|
|
ext = 'vptype'
|
|
|
|
else:
|
|
|
|
ext = 'ptype'
|
|
|
|
|
|
|
|
i_file = File('params/%s_%s.i' % (name, ext))
|
2008-06-14 21:10:50 +02:00
|
|
|
params_i_files.append(i_file)
|
2007-07-24 06:51:38 +02:00
|
|
|
env.Command(i_file, Value(name), generate.createSwigParam)
|
|
|
|
env.Depends(i_file, depends)
|
|
|
|
|
|
|
|
# Generate all enum header files
|
|
|
|
for name,enum in generate.enums.iteritems():
|
|
|
|
extra_deps = [ File(generate.py_modules[enum.__module__]) ]
|
|
|
|
|
|
|
|
cc_file = File('enums/%s.cc' % name)
|
|
|
|
env.Command(cc_file, Value(name), generate.createEnumStrings)
|
|
|
|
env.Depends(cc_file, depends + extra_deps)
|
|
|
|
Source(cc_file)
|
|
|
|
|
|
|
|
hh_file = File('enums/%s.hh' % name)
|
|
|
|
env.Command(hh_file, Value(name), generate.createEnumParam)
|
|
|
|
env.Depends(hh_file, depends + extra_deps)
|
|
|
|
|
|
|
|
# Build the big monolithic swigged params module (wraps all SimObject
|
|
|
|
# param structs and enum structs)
|
|
|
|
params_file = File('params/params.i')
|
|
|
|
names = sort_list(generate.sim_objects.keys())
|
|
|
|
env.Command(params_file, [ Value(v) for v in names ],
|
|
|
|
generate.buildParams)
|
2008-06-14 21:10:50 +02:00
|
|
|
env.Depends(params_file, params_hh_files + params_i_files + depends)
|
2007-07-24 06:51:38 +02:00
|
|
|
SwigSource('m5.objects', params_file)
|
|
|
|
|
|
|
|
# Build all swig modules
|
2007-04-13 06:20:04 +02:00
|
|
|
swig_modules = []
|
2007-07-24 06:51:38 +02:00
|
|
|
for source,package in swig_sources:
|
2007-04-13 06:20:04 +02:00
|
|
|
filename = str(source)
|
2007-07-24 06:51:38 +02:00
|
|
|
assert filename.endswith('.i')
|
2007-04-13 06:20:04 +02:00
|
|
|
|
2007-07-24 06:51:38 +02:00
|
|
|
base = '.'.join(filename.split('.')[:-1])
|
|
|
|
module = basename(base)
|
|
|
|
cc_file = base + '_wrap.cc'
|
|
|
|
py_file = base + '.py'
|
2007-04-13 06:20:04 +02:00
|
|
|
|
|
|
|
env.Command([cc_file, py_file], source,
|
|
|
|
'$SWIG $SWIGFLAGS -outdir ${TARGETS[1].dir} '
|
|
|
|
'-o ${TARGETS[0]} $SOURCES')
|
|
|
|
env.Depends(py_file, source)
|
|
|
|
env.Depends(cc_file, source)
|
2007-07-24 06:51:38 +02:00
|
|
|
|
2007-04-13 06:20:04 +02:00
|
|
|
swig_modules.append(Value(module))
|
|
|
|
Source(cc_file)
|
|
|
|
PySource(package, py_file)
|
|
|
|
|
2007-07-24 06:51:38 +02:00
|
|
|
# Generate the main swig init file
|
|
|
|
env.Command('swig/init.cc', swig_modules, generate.makeSwigInit)
|
|
|
|
Source('swig/init.cc')
|
2007-04-13 06:20:04 +02:00
|
|
|
|
2007-10-31 06:21:54 +01:00
|
|
|
# Generate traceflags.py
|
|
|
|
flags = [ Value(f) for f in trace_flags ]
|
|
|
|
env.Command('base/traceflags.py', flags, generate.traceFlagsPy)
|
|
|
|
PySource('m5', 'base/traceflags.py')
|
|
|
|
|
|
|
|
env.Command('base/traceflags.hh', flags, generate.traceFlagsHH)
|
|
|
|
env.Command('base/traceflags.cc', flags, generate.traceFlagsCC)
|
|
|
|
Source('base/traceflags.cc')
|
|
|
|
|
2008-06-13 07:09:04 +02:00
|
|
|
# Generate program_info.cc
|
|
|
|
env.Command('base/program_info.cc',
|
2008-06-14 02:34:22 +02:00
|
|
|
Value(str(SCons.Node.FS.default_fs.SConstruct_dir)),
|
|
|
|
generate.programInfo)
|
2008-06-13 07:09:04 +02:00
|
|
|
|
2007-07-24 06:51:38 +02:00
|
|
|
# Build the zip file
|
2007-04-13 06:20:04 +02:00
|
|
|
py_compiled = []
|
|
|
|
py_zip_depends = []
|
|
|
|
for source in py_sources:
|
2007-07-24 06:51:38 +02:00
|
|
|
env.Command(source.compiled, source.source, generate.compilePyFile)
|
|
|
|
py_compiled.append(source.compiled)
|
2007-04-13 06:20:04 +02:00
|
|
|
|
|
|
|
# make the zipfile depend on the archive name so that the archive
|
|
|
|
# is rebuilt if the name changes
|
2007-07-24 06:51:38 +02:00
|
|
|
py_zip_depends.append(Value(source.arcname))
|
2007-04-13 06:20:04 +02:00
|
|
|
|
|
|
|
# Add the zip file target to the environment.
|
2007-07-24 06:51:38 +02:00
|
|
|
m5zip = File('m5py.zip')
|
|
|
|
env.Command(m5zip, py_compiled, generate.buildPyZip)
|
|
|
|
env.Depends(m5zip, py_zip_depends)
|
2007-04-13 06:20:04 +02:00
|
|
|
|
|
|
|
########################################################################
|
|
|
|
#
|
|
|
|
# Define binaries. Each different build type (debug, opt, etc.) gets
|
|
|
|
# a slightly different build environment.
|
|
|
|
#
|
|
|
|
|
|
|
|
# List of constructed environments to pass back to SConstruct
|
|
|
|
envList = []
|
|
|
|
|
2004-07-03 06:16:38 +02:00
|
|
|
# This function adds the specified sources to the given build
|
|
|
|
# environment, and returns a list of all the corresponding SCons
|
|
|
|
# Object nodes (including an extra one for date.cc). We explicitly
|
|
|
|
# add the Object nodes so we can set up special dependencies for
|
2004-10-23 04:49:12 +02:00
|
|
|
# date.cc.
|
2004-07-03 06:16:38 +02:00
|
|
|
def make_objs(sources, env):
|
|
|
|
objs = [env.Object(s) for s in sources]
|
2008-06-13 07:09:04 +02:00
|
|
|
|
2004-07-03 06:16:38 +02:00
|
|
|
# make date.cc depend on all other objects so it always gets
|
|
|
|
# recompiled whenever anything else does
|
|
|
|
date_obj = env.Object('base/date.cc')
|
2008-06-13 07:09:04 +02:00
|
|
|
|
|
|
|
# Make the generation of program_info.cc dependend on all
|
|
|
|
# the other cc files and the compiling of program_info.cc
|
|
|
|
# dependent on all the objects but program_info.o
|
|
|
|
pinfo_obj = env.Object('base/program_info.cc')
|
|
|
|
env.Depends('base/program_info.cc', sources)
|
2004-07-03 06:16:38 +02:00
|
|
|
env.Depends(date_obj, objs)
|
2008-06-13 07:09:04 +02:00
|
|
|
env.Depends(pinfo_obj, objs)
|
|
|
|
objs.extend([date_obj,pinfo_obj])
|
2004-07-03 06:16:38 +02:00
|
|
|
return objs
|
|
|
|
|
2006-05-30 19:11:34 +02:00
|
|
|
# Function to create a new build environment as clone of current
|
|
|
|
# environment 'env' with modified object suffix and optional stripped
|
|
|
|
# binary. Additional keyword arguments are appended to corresponding
|
|
|
|
# build environment vars.
|
|
|
|
def makeEnv(label, objsfx, strip = False, **kwargs):
|
|
|
|
newEnv = env.Copy(OBJSUFFIX=objsfx)
|
|
|
|
newEnv.Label = label
|
|
|
|
newEnv.Append(**kwargs)
|
|
|
|
exe = 'm5.' + label # final executable
|
|
|
|
bin = exe + '.bin' # executable w/o appended Python zip archive
|
2007-07-24 06:51:38 +02:00
|
|
|
newEnv.Program(bin, make_objs(cc_sources, newEnv))
|
2006-05-30 19:11:34 +02:00
|
|
|
if strip:
|
|
|
|
stripped_bin = bin + '.stripped'
|
2007-02-01 00:32:27 +01:00
|
|
|
if sys.platform == 'sunos5':
|
2007-06-20 17:12:10 +02:00
|
|
|
cmd = 'cp $SOURCE $TARGET; strip $TARGET'
|
2007-02-01 00:32:27 +01:00
|
|
|
else:
|
2007-06-20 17:12:10 +02:00
|
|
|
cmd = 'strip $SOURCE -o $TARGET'
|
|
|
|
newEnv.Command(stripped_bin, bin, cmd)
|
2006-05-30 19:11:34 +02:00
|
|
|
bin = stripped_bin
|
2007-04-13 06:20:04 +02:00
|
|
|
targets = newEnv.Concat(exe, [bin, 'm5py.zip'])
|
2006-05-30 19:11:34 +02:00
|
|
|
newEnv.M5Binary = targets[0]
|
|
|
|
envList.append(newEnv)
|
|
|
|
|
2004-07-03 06:16:38 +02:00
|
|
|
# Debug binary
|
2007-01-27 00:48:51 +01:00
|
|
|
ccflags = {}
|
|
|
|
if env['GCC']:
|
|
|
|
if sys.platform == 'sunos5':
|
|
|
|
ccflags['debug'] = '-gstabs+'
|
|
|
|
else:
|
|
|
|
ccflags['debug'] = '-ggdb3'
|
|
|
|
ccflags['opt'] = '-g -O3'
|
|
|
|
ccflags['fast'] = '-O3'
|
|
|
|
ccflags['prof'] = '-O3 -g -pg'
|
|
|
|
elif env['SUNCC']:
|
|
|
|
ccflags['debug'] = '-g0'
|
|
|
|
ccflags['opt'] = '-g -O'
|
|
|
|
ccflags['fast'] = '-fast'
|
|
|
|
ccflags['prof'] = '-fast -g -pg'
|
2007-01-27 21:38:04 +01:00
|
|
|
elif env['ICC']:
|
|
|
|
ccflags['debug'] = '-g -O0'
|
|
|
|
ccflags['opt'] = '-g -O'
|
2007-01-27 21:47:18 +01:00
|
|
|
ccflags['fast'] = '-fast'
|
2007-01-27 21:38:04 +01:00
|
|
|
ccflags['prof'] = '-fast -g -pg'
|
2006-11-08 21:05:54 +01:00
|
|
|
else:
|
2007-01-27 00:48:51 +01:00
|
|
|
print 'Unknown compiler, please fix compiler options'
|
2007-07-24 06:51:38 +02:00
|
|
|
Exit(1)
|
2006-11-08 21:05:54 +01:00
|
|
|
|
2006-05-30 19:11:34 +02:00
|
|
|
makeEnv('debug', '.do',
|
2007-01-27 00:48:51 +01:00
|
|
|
CCFLAGS = Split(ccflags['debug']),
|
2006-11-12 05:46:56 +01:00
|
|
|
CPPDEFINES = ['DEBUG', 'TRACING_ON=1'])
|
2004-07-03 06:16:38 +02:00
|
|
|
|
|
|
|
# Optimized binary
|
2006-05-30 19:11:34 +02:00
|
|
|
makeEnv('opt', '.o',
|
2007-01-27 00:48:51 +01:00
|
|
|
CCFLAGS = Split(ccflags['opt']),
|
2006-11-12 05:46:56 +01:00
|
|
|
CPPDEFINES = ['TRACING_ON=1'])
|
2004-07-03 06:16:38 +02:00
|
|
|
|
|
|
|
# "Fast" binary
|
2006-05-30 19:11:34 +02:00
|
|
|
makeEnv('fast', '.fo', strip = True,
|
2007-01-27 00:48:51 +01:00
|
|
|
CCFLAGS = Split(ccflags['fast']),
|
2006-11-12 05:46:56 +01:00
|
|
|
CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'])
|
2004-07-03 06:16:38 +02:00
|
|
|
|
|
|
|
# Profiled binary
|
2006-05-30 19:11:34 +02:00
|
|
|
makeEnv('prof', '.po',
|
2007-01-27 00:48:51 +01:00
|
|
|
CCFLAGS = Split(ccflags['prof']),
|
2006-11-27 08:16:24 +01:00
|
|
|
CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'],
|
2006-05-30 19:11:34 +02:00
|
|
|
LINKFLAGS = '-pg')
|
2005-09-05 22:31:27 +02:00
|
|
|
|
|
|
|
Return('envList')
|