SConscript revision 4120
112855Sgabeblack@google.com# -*- mode:python -*- 212855Sgabeblack@google.com 312855Sgabeblack@google.com# Copyright (c) 2006 The Regents of The University of Michigan 412855Sgabeblack@google.com# All rights reserved. 512855Sgabeblack@google.com# 612855Sgabeblack@google.com# Redistribution and use in source and binary forms, with or without 712855Sgabeblack@google.com# modification, are permitted provided that the following conditions are 812855Sgabeblack@google.com# met: redistributions of source code must retain the above copyright 912855Sgabeblack@google.com# notice, this list of conditions and the following disclaimer; 1012855Sgabeblack@google.com# redistributions in binary form must reproduce the above copyright 1112855Sgabeblack@google.com# notice, this list of conditions and the following disclaimer in the 1212855Sgabeblack@google.com# documentation and/or other materials provided with the distribution; 1312855Sgabeblack@google.com# neither the name of the copyright holders nor the names of its 1412855Sgabeblack@google.com# contributors may be used to endorse or promote products derived from 1512855Sgabeblack@google.com# this software without specific prior written permission. 1612855Sgabeblack@google.com# 1712855Sgabeblack@google.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1812855Sgabeblack@google.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1912855Sgabeblack@google.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 2012855Sgabeblack@google.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2112855Sgabeblack@google.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2212855Sgabeblack@google.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2312855Sgabeblack@google.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2412855Sgabeblack@google.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2512855Sgabeblack@google.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2612855Sgabeblack@google.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2712855Sgabeblack@google.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2812855Sgabeblack@google.com# 2912855Sgabeblack@google.com# Authors: Steve Reinhardt 3012855Sgabeblack@google.com 3112855Sgabeblack@google.comimport os.path, sys 3212855Sgabeblack@google.com 3312855Sgabeblack@google.com# Import build environment variable from SConstruct. 3412855Sgabeblack@google.comImport('env') 3512855Sgabeblack@google.com 3612855Sgabeblack@google.com# Right now there are no source files immediately in this directory 3712855Sgabeblack@google.comsources = [] 3812855Sgabeblack@google.com 3912855Sgabeblack@google.com################################################################# 4012855Sgabeblack@google.com# 4112855Sgabeblack@google.com# ISA "switch header" generation. 4212855Sgabeblack@google.com# 4312855Sgabeblack@google.com# Auto-generate arch headers that include the right ISA-specific 4412855Sgabeblack@google.com# header based on the setting of THE_ISA preprocessor variable. 4512855Sgabeblack@google.com# 4612855Sgabeblack@google.com################################################################# 4712855Sgabeblack@google.com 4812855Sgabeblack@google.com# List of headers to generate 4912855Sgabeblack@google.comisa_switch_hdrs = Split(''' 5012855Sgabeblack@google.com arguments.hh 5112855Sgabeblack@google.com faults.hh 5212855Sgabeblack@google.com interrupts.hh 5312855Sgabeblack@google.com isa_traits.hh 5412855Sgabeblack@google.com kernel_stats.hh 5512855Sgabeblack@google.com locked_mem.hh 5612855Sgabeblack@google.com mmaped_ipr.hh 5712855Sgabeblack@google.com process.hh 5812855Sgabeblack@google.com regfile.hh 5912855Sgabeblack@google.com remote_gdb.hh 6012855Sgabeblack@google.com stacktrace.hh 6112855Sgabeblack@google.com syscallreturn.hh 6212855Sgabeblack@google.com tlb.hh 6312855Sgabeblack@google.com types.hh 6412855Sgabeblack@google.com utility.hh 6512855Sgabeblack@google.com vtophys.hh 6612855Sgabeblack@google.com ''') 6712855Sgabeblack@google.com 6812855Sgabeblack@google.com# Set up this directory to support switching headers 6912855Sgabeblack@google.comenv.make_switching_dir('arch', isa_switch_hdrs, env) 7012855Sgabeblack@google.com 7112855Sgabeblack@google.com################################################################# 7212855Sgabeblack@google.com# 7312855Sgabeblack@google.com# Include architecture-specific files. 7412855Sgabeblack@google.com# 7512855Sgabeblack@google.com################################################################# 7612855Sgabeblack@google.com 7712855Sgabeblack@google.com# 7812855Sgabeblack@google.com# Build a SCons scanner for ISA files 7912855Sgabeblack@google.com# 8012855Sgabeblack@google.comimport SCons.Scanner 8112855Sgabeblack@google.com 8212855Sgabeblack@google.comisa_scanner = SCons.Scanner.Classic("ISAScan", 8312855Sgabeblack@google.com [".isa", ".ISA"], 8412855Sgabeblack@google.com "SRCDIR", 8512855Sgabeblack@google.com r'^\s*##include\s+"([\w/.-]*)"') 8612855Sgabeblack@google.com 8712855Sgabeblack@google.comenv.Append(SCANNERS = isa_scanner) 8812855Sgabeblack@google.com 8912855Sgabeblack@google.com# 9012855Sgabeblack@google.com# Now create a Builder object that uses isa_parser.py to generate C++ 9112855Sgabeblack@google.com# output from the ISA description (*.isa) files. 9212855Sgabeblack@google.com# 9312855Sgabeblack@google.com 9412855Sgabeblack@google.com# Convert to File node to fix path 9512855Sgabeblack@google.comisa_parser = File('isa_parser.py') 9612855Sgabeblack@google.comcpu_models_file = File('../cpu/cpu_models.py') 9712855Sgabeblack@google.com 9812855Sgabeblack@google.com# This sucks in the defintions of the CpuModel objects. 9912855Sgabeblack@google.comexecfile(cpu_models_file.srcnode().abspath) 10012855Sgabeblack@google.com 10112855Sgabeblack@google.com# Several files are generated from the ISA description. 10212855Sgabeblack@google.com# We always get the basic decoder and header file. 10312855Sgabeblack@google.comisa_desc_gen_files = Split('decoder.cc decoder.hh') 10412855Sgabeblack@google.com# We also get an execute file for each selected CPU model. 10512855Sgabeblack@google.comisa_desc_gen_files += [CpuModel.dict[cpu].filename 10612855Sgabeblack@google.com for cpu in env['CPU_MODELS']] 10712855Sgabeblack@google.com 10812855Sgabeblack@google.com# Also include the CheckerCPU as one of the models if it is being 10912855Sgabeblack@google.com# enabled via command line. 11012855Sgabeblack@google.comif env['USE_CHECKER']: 11112855Sgabeblack@google.com isa_desc_gen_files += [CpuModel.dict['CheckerCPU'].filename] 11212855Sgabeblack@google.com 11312855Sgabeblack@google.com# The emitter patches up the sources & targets to include the 11412855Sgabeblack@google.com# autogenerated files as targets and isa parser itself as a source. 11512855Sgabeblack@google.comdef isa_desc_emitter(target, source, env): 11612855Sgabeblack@google.com return (isa_desc_gen_files, [isa_parser, cpu_models_file] + source) 11712855Sgabeblack@google.com 11812855Sgabeblack@google.com# Pieces are in place, so create the builder. 11912855Sgabeblack@google.compython = sys.executable # use same Python binary used to run scons 12012855Sgabeblack@google.com 12112855Sgabeblack@google.com# Also include the CheckerCPU as one of the models if it is being 12212855Sgabeblack@google.com# enabled via command line. 12312855Sgabeblack@google.comif env['USE_CHECKER']: 12412855Sgabeblack@google.com isa_desc_builder = Builder(action=python + ' $SOURCES $TARGET.dir $CPU_MODELS CheckerCPU', 12512855Sgabeblack@google.com emitter = isa_desc_emitter) 12612855Sgabeblack@google.comelse: 12712855Sgabeblack@google.com isa_desc_builder = Builder(action=python + ' $SOURCES $TARGET.dir $CPU_MODELS', 12812855Sgabeblack@google.com emitter = isa_desc_emitter) 12912855Sgabeblack@google.com 13012855Sgabeblack@google.comenv.Append(BUILDERS = { 'ISADesc' : isa_desc_builder }) 131 132# 133# Now include other ISA-specific sources from the ISA subdirectories. 134# 135 136isa = env['TARGET_ISA'] # someday this may be a list of ISAs 137 138# Let the target architecture define what additional sources it needs 139sources += SConscript(os.path.join(isa, 'SConscript'), exports = 'env') 140 141Return('sources') 142