SConscript revision 4120
12139SN/A# -*- mode:python -*- 22139SN/A 32139SN/A# Copyright (c) 2006 The Regents of The University of Michigan 42139SN/A# All rights reserved. 52139SN/A# 62139SN/A# Redistribution and use in source and binary forms, with or without 72139SN/A# modification, are permitted provided that the following conditions are 82139SN/A# met: redistributions of source code must retain the above copyright 92139SN/A# notice, this list of conditions and the following disclaimer; 102139SN/A# redistributions in binary form must reproduce the above copyright 112139SN/A# notice, this list of conditions and the following disclaimer in the 122139SN/A# documentation and/or other materials provided with the distribution; 132139SN/A# neither the name of the copyright holders nor the names of its 142139SN/A# contributors may be used to endorse or promote products derived from 152139SN/A# this software without specific prior written permission. 162139SN/A# 172139SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 182139SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 192139SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 202139SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 212139SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 222139SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 232139SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 242139SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 252139SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 262139SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 272139SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 282665Ssaidi@eecs.umich.edu# 292665Ssaidi@eecs.umich.edu# Authors: Steve Reinhardt 302139SN/A 314202Sbinkertn@umich.eduimport os.path, sys 322139SN/A 334202Sbinkertn@umich.edu# Import build environment variable from SConstruct. 342152SN/AImport('env') 352152SN/A 362139SN/A# Right now there are no source files immediately in this directory 372139SN/Asources = [] 382139SN/A 392139SN/A################################################################# 402139SN/A# 412152SN/A# ISA "switch header" generation. 422152SN/A# 432139SN/A# Auto-generate arch headers that include the right ISA-specific 442139SN/A# header based on the setting of THE_ISA preprocessor variable. 452139SN/A# 464781Snate@binkert.org################################################################# 474781Snate@binkert.org 484781Snate@binkert.org# List of headers to generate 496313Sgblack@eecs.umich.eduisa_switch_hdrs = Split(''' 504781Snate@binkert.org arguments.hh 514781Snate@binkert.org faults.hh 523170Sstever@eecs.umich.edu interrupts.hh 535664Sgblack@eecs.umich.edu isa_traits.hh 543806Ssaidi@eecs.umich.edu kernel_stats.hh 556179Sksewell@umich.edu locked_mem.hh 564781Snate@binkert.org mmaped_ipr.hh 574781Snate@binkert.org process.hh 584781Snate@binkert.org regfile.hh 594781Snate@binkert.org remote_gdb.hh 604781Snate@binkert.org stacktrace.hh 614781Snate@binkert.org syscallreturn.hh 624781Snate@binkert.org tlb.hh 634781Snate@binkert.org types.hh 644781Snate@binkert.org utility.hh 652139SN/A vtophys.hh 662139SN/A ''') 673546Sgblack@eecs.umich.edu 684202Sbinkertn@umich.edu# Set up this directory to support switching headers 692152SN/Aenv.make_switching_dir('arch', isa_switch_hdrs, env) 702152SN/A 712152SN/A################################################################# 722152SN/A# 732152SN/A# Include architecture-specific files. 742152SN/A# 752152SN/A################################################################# 762152SN/A 772152SN/A# 782152SN/A# Build a SCons scanner for ISA files 792152SN/A# 802152SN/Aimport SCons.Scanner 812504SN/A 822504SN/Aisa_scanner = SCons.Scanner.Classic("ISAScan", 832504SN/A [".isa", ".ISA"], 842504SN/A "SRCDIR", 852152SN/A r'^\s*##include\s+"([\w/.-]*)"') 862504SN/A 872152SN/Aenv.Append(SCANNERS = isa_scanner) 882152SN/A 892152SN/A# 902152SN/A# Now create a Builder object that uses isa_parser.py to generate C++ 912152SN/A# output from the ISA description (*.isa) files. 922152SN/A# 932152SN/A 942152SN/A# Convert to File node to fix path 952632Sstever@eecs.umich.eduisa_parser = File('isa_parser.py') 962155SN/Acpu_models_file = File('../cpu/cpu_models.py') 972155SN/A 982155SN/A# This sucks in the defintions of the CpuModel objects. 992155SN/Aexecfile(cpu_models_file.srcnode().abspath) 1002155SN/A 1012155SN/A# Several files are generated from the ISA description. 1025228Sgblack@eecs.umich.edu# We always get the basic decoder and header file. 1032155SN/Aisa_desc_gen_files = Split('decoder.cc decoder.hh') 1042155SN/A# We also get an execute file for each selected CPU model. 1052155SN/Aisa_desc_gen_files += [CpuModel.dict[cpu].filename 1062152SN/A for cpu in env['CPU_MODELS']] 1072766Sktlim@umich.edu 1082766Sktlim@umich.edu# Also include the CheckerCPU as one of the models if it is being 1092766Sktlim@umich.edu# enabled via command line. 1102766Sktlim@umich.eduif env['USE_CHECKER']: 1112766Sktlim@umich.edu isa_desc_gen_files += [CpuModel.dict['CheckerCPU'].filename] 1122152SN/A 1132152SN/A# The emitter patches up the sources & targets to include the 1142152SN/A# autogenerated files as targets and isa parser itself as a source. 1152155SN/Adef isa_desc_emitter(target, source, env): 1162152SN/A return (isa_desc_gen_files, [isa_parser, cpu_models_file] + source) 1172152SN/A 1182718Sstever@eecs.umich.edu# Pieces are in place, so create the builder. 1192921Sktlim@umich.edupython = sys.executable # use same Python binary used to run scons 1202921Sktlim@umich.edu 1212921Sktlim@umich.edu# Also include the CheckerCPU as one of the models if it is being 1222921Sktlim@umich.edu# enabled via command line. 1232921Sktlim@umich.eduif env['USE_CHECKER']: 1242921Sktlim@umich.edu isa_desc_builder = Builder(action=python + ' $SOURCES $TARGET.dir $CPU_MODELS CheckerCPU', 1252921Sktlim@umich.edu emitter = isa_desc_emitter) 1262921Sktlim@umich.eduelse: 1272921Sktlim@umich.edu isa_desc_builder = Builder(action=python + ' $SOURCES $TARGET.dir $CPU_MODELS', 1282152SN/A emitter = isa_desc_emitter) 1292152SN/A 1305944Sgblack@eecs.umich.eduenv.Append(BUILDERS = { 'ISADesc' : isa_desc_builder }) 1315944Sgblack@eecs.umich.edu 1325944Sgblack@eecs.umich.edu# 1335944Sgblack@eecs.umich.edu# Now include other ISA-specific sources from the ISA subdirectories. 1345944Sgblack@eecs.umich.edu# 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