SConscript revision 5742
110066Sandreas.hansson@arm.com# -*- mode:python -*- 210066Sandreas.hansson@arm.com 310066Sandreas.hansson@arm.com# Copyright (c) 2006 The Regents of The University of Michigan 410066Sandreas.hansson@arm.com# All rights reserved. 510066Sandreas.hansson@arm.com# 610066Sandreas.hansson@arm.com# Redistribution and use in source and binary forms, with or without 710066Sandreas.hansson@arm.com# modification, are permitted provided that the following conditions are 810066Sandreas.hansson@arm.com# met: redistributions of source code must retain the above copyright 910066Sandreas.hansson@arm.com# notice, this list of conditions and the following disclaimer; 1010066Sandreas.hansson@arm.com# redistributions in binary form must reproduce the above copyright 1110066Sandreas.hansson@arm.com# notice, this list of conditions and the following disclaimer in the 1210066Sandreas.hansson@arm.com# documentation and/or other materials provided with the distribution; 1310066Sandreas.hansson@arm.com# neither the name of the copyright holders nor the names of its 1410066Sandreas.hansson@arm.com# contributors may be used to endorse or promote products derived from 1510066Sandreas.hansson@arm.com# this software without specific prior written permission. 1610066Sandreas.hansson@arm.com# 1710066Sandreas.hansson@arm.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1810066Sandreas.hansson@arm.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1910066Sandreas.hansson@arm.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 2010066Sandreas.hansson@arm.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2110066Sandreas.hansson@arm.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2210066Sandreas.hansson@arm.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2310066Sandreas.hansson@arm.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2410066Sandreas.hansson@arm.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2510066Sandreas.hansson@arm.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2610066Sandreas.hansson@arm.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2710066Sandreas.hansson@arm.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2810066Sandreas.hansson@arm.com# 2910066Sandreas.hansson@arm.com# Authors: Steve Reinhardt 3010066Sandreas.hansson@arm.com 3110066Sandreas.hansson@arm.comimport sys 3210066Sandreas.hansson@arm.com 3310066Sandreas.hansson@arm.comImport('*') 3410066Sandreas.hansson@arm.com 3510066Sandreas.hansson@arm.com################################################################# 3610066Sandreas.hansson@arm.com# 3710066Sandreas.hansson@arm.com# ISA "switch header" generation. 3810066Sandreas.hansson@arm.com# 3910066Sandreas.hansson@arm.com# Auto-generate arch headers that include the right ISA-specific 4010066Sandreas.hansson@arm.com# header based on the setting of THE_ISA preprocessor variable. 4110066Sandreas.hansson@arm.com# 4210066Sandreas.hansson@arm.com################################################################# 4310066Sandreas.hansson@arm.com 4410066Sandreas.hansson@arm.com# List of headers to generate 4510066Sandreas.hansson@arm.comisa_switch_hdrs = Split(''' 4610066Sandreas.hansson@arm.com arguments.hh 4710066Sandreas.hansson@arm.com faults.hh 4810066Sandreas.hansson@arm.com interrupts.hh 4910066Sandreas.hansson@arm.com isa_traits.hh 5010066Sandreas.hansson@arm.com kernel_stats.hh 5110066Sandreas.hansson@arm.com locked_mem.hh 5210066Sandreas.hansson@arm.com microcode_rom.hh 5310066Sandreas.hansson@arm.com mmaped_ipr.hh 5410066Sandreas.hansson@arm.com process.hh 5510066Sandreas.hansson@arm.com predecoder.hh 5610066Sandreas.hansson@arm.com regfile.hh 5710066Sandreas.hansson@arm.com remote_gdb.hh 5810066Sandreas.hansson@arm.com stacktrace.hh 5910066Sandreas.hansson@arm.com syscallreturn.hh 6010066Sandreas.hansson@arm.com tlb.hh 6110066Sandreas.hansson@arm.com types.hh 6210066Sandreas.hansson@arm.com utility.hh 6310066Sandreas.hansson@arm.com vtophys.hh 6410066Sandreas.hansson@arm.com ''') 6510066Sandreas.hansson@arm.com 6610066Sandreas.hansson@arm.com# Set up this directory to support switching headers 6710066Sandreas.hansson@arm.commake_switching_dir('arch', isa_switch_hdrs, env) 6810066Sandreas.hansson@arm.com 6910066Sandreas.hansson@arm.com################################################################# 7010066Sandreas.hansson@arm.com# 7110066Sandreas.hansson@arm.com# Include architecture-specific files. 7210066Sandreas.hansson@arm.com# 7310066Sandreas.hansson@arm.com################################################################# 7410066Sandreas.hansson@arm.com 7510066Sandreas.hansson@arm.com# 7610066Sandreas.hansson@arm.com# Build a SCons scanner for ISA files 7710066Sandreas.hansson@arm.com# 7810130Sandreas.hansson@arm.comimport SCons.Scanner 7910130Sandreas.hansson@arm.com 8010130Sandreas.hansson@arm.comisa_scanner = SCons.Scanner.Classic("ISAScan", 8110130Sandreas.hansson@arm.com [".isa", ".ISA"], 8210066Sandreas.hansson@arm.com "SRCDIR", 8310066Sandreas.hansson@arm.com r'^\s*##include\s+"([\w/.-]*)"') 8410066Sandreas.hansson@arm.com 8510066Sandreas.hansson@arm.comenv.Append(SCANNERS = isa_scanner) 8610130Sandreas.hansson@arm.com 8710066Sandreas.hansson@arm.com# 8810066Sandreas.hansson@arm.com# Now create a Builder object that uses isa_parser.py to generate C++ 8910066Sandreas.hansson@arm.com# output from the ISA description (*.isa) files. 9010066Sandreas.hansson@arm.com# 91 92# Convert to File node to fix path 93isa_parser = File('isa_parser.py') 94cpu_models_file = File('../cpu/cpu_models.py') 95 96# This sucks in the defintions of the CpuModel objects. 97execfile(cpu_models_file.srcnode().abspath) 98 99# Several files are generated from the ISA description. 100# We always get the basic decoder and header file. 101isa_desc_gen_files = [ 'decoder.cc', 'decoder.hh', 'max_inst_regs.hh' ] 102# We also get an execute file for each selected CPU model. 103isa_desc_gen_files += [CpuModel.dict[cpu].filename 104 for cpu in env['CPU_MODELS']] 105 106# Also include the CheckerCPU as one of the models if it is being 107# enabled via command line. 108if env['USE_CHECKER']: 109 isa_desc_gen_files += [CpuModel.dict['CheckerCPU'].filename] 110 111# The emitter patches up the sources & targets to include the 112# autogenerated files as targets and isa parser itself as a source. 113def isa_desc_emitter(target, source, env): 114 return (isa_desc_gen_files, [isa_parser, cpu_models_file] + source) 115 116# Pieces are in place, so create the builder. 117python = sys.executable # use same Python binary used to run scons 118 119# Also include the CheckerCPU as one of the models if it is being 120# enabled via command line. 121if env['USE_CHECKER']: 122 isa_desc_builder = Builder(action=python + ' $SOURCES $TARGET.dir $CPU_MODELS CheckerCPU', 123 emitter = isa_desc_emitter) 124else: 125 isa_desc_builder = Builder(action=python + ' $SOURCES $TARGET.dir $CPU_MODELS', 126 emitter = isa_desc_emitter) 127 128env.Append(BUILDERS = { 'ISADesc' : isa_desc_builder }) 129