SConscript revision 4997
112027Sjungma@eit.uni-kl.de# -*- mode:python -*-
212027Sjungma@eit.uni-kl.de
312027Sjungma@eit.uni-kl.de# Copyright (c) 2006 The Regents of The University of Michigan
412027Sjungma@eit.uni-kl.de# All rights reserved.
512027Sjungma@eit.uni-kl.de#
612027Sjungma@eit.uni-kl.de# Redistribution and use in source and binary forms, with or without
712027Sjungma@eit.uni-kl.de# modification, are permitted provided that the following conditions are
812027Sjungma@eit.uni-kl.de# met: redistributions of source code must retain the above copyright
912027Sjungma@eit.uni-kl.de# notice, this list of conditions and the following disclaimer;
1012027Sjungma@eit.uni-kl.de# redistributions in binary form must reproduce the above copyright
1112027Sjungma@eit.uni-kl.de# notice, this list of conditions and the following disclaimer in the
1212027Sjungma@eit.uni-kl.de# documentation and/or other materials provided with the distribution;
1312027Sjungma@eit.uni-kl.de# neither the name of the copyright holders nor the names of its
1412027Sjungma@eit.uni-kl.de# contributors may be used to endorse or promote products derived from
1512027Sjungma@eit.uni-kl.de# this software without specific prior written permission.
1612027Sjungma@eit.uni-kl.de#
1712027Sjungma@eit.uni-kl.de# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1812027Sjungma@eit.uni-kl.de# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1912027Sjungma@eit.uni-kl.de# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2012027Sjungma@eit.uni-kl.de# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2112027Sjungma@eit.uni-kl.de# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2212027Sjungma@eit.uni-kl.de# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2312027Sjungma@eit.uni-kl.de# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2412027Sjungma@eit.uni-kl.de# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2512027Sjungma@eit.uni-kl.de# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2612027Sjungma@eit.uni-kl.de# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2712046Sgabeblack@google.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2812027Sjungma@eit.uni-kl.de#
2912027Sjungma@eit.uni-kl.de# Authors: Steve Reinhardt
3012046Sgabeblack@google.com
3112027Sjungma@eit.uni-kl.deimport sys
3212046Sgabeblack@google.com
3312046Sgabeblack@google.comImport('*')
3412027Sjungma@eit.uni-kl.de
3512046Sgabeblack@google.com#################################################################
3612046Sgabeblack@google.com#
3712027Sjungma@eit.uni-kl.de# ISA "switch header" generation.
3812046Sgabeblack@google.com#
3912046Sgabeblack@google.com# Auto-generate arch headers that include the right ISA-specific
4012027Sjungma@eit.uni-kl.de# header based on the setting of THE_ISA preprocessor variable.
4112046Sgabeblack@google.com#
4212046Sgabeblack@google.com#################################################################
4312046Sgabeblack@google.com
4412027Sjungma@eit.uni-kl.de# List of headers to generate
4512046Sgabeblack@google.comisa_switch_hdrs = Split('''
4612046Sgabeblack@google.com        arguments.hh
4712046Sgabeblack@google.com        faults.hh
4812046Sgabeblack@google.com        interrupts.hh
4912046Sgabeblack@google.com        isa_traits.hh
5012046Sgabeblack@google.com        kernel_stats.hh
5112046Sgabeblack@google.com        locked_mem.hh
5212046Sgabeblack@google.com        mmaped_ipr.hh
5312046Sgabeblack@google.com        process.hh
5412046Sgabeblack@google.com        predecoder.hh
5512046Sgabeblack@google.com        regfile.hh
5612046Sgabeblack@google.com        remote_gdb.hh
5712046Sgabeblack@google.com        stacktrace.hh
5812046Sgabeblack@google.com        syscallreturn.hh
5912046Sgabeblack@google.com        tlb.hh
6012046Sgabeblack@google.com        types.hh
6112046Sgabeblack@google.com        utility.hh
6212046Sgabeblack@google.com        vtophys.hh
6312027Sjungma@eit.uni-kl.de        ''')
6412027Sjungma@eit.uni-kl.de
6512046Sgabeblack@google.com# Set up this directory to support switching headers
6612046Sgabeblack@google.commake_switching_dir('arch', isa_switch_hdrs, env)
6712027Sjungma@eit.uni-kl.de
6812046Sgabeblack@google.com#################################################################
6912046Sgabeblack@google.com#
7012046Sgabeblack@google.com# Include architecture-specific files.
7112046Sgabeblack@google.com#
7212027Sjungma@eit.uni-kl.de#################################################################
7312046Sgabeblack@google.com
7412046Sgabeblack@google.com#
7512046Sgabeblack@google.com# Build a SCons scanner for ISA files
7612046Sgabeblack@google.com#
7712046Sgabeblack@google.comimport SCons.Scanner
7812046Sgabeblack@google.com
7912046Sgabeblack@google.comisa_scanner = SCons.Scanner.Classic("ISAScan",
8012027Sjungma@eit.uni-kl.de                                    [".isa", ".ISA"],
8112046Sgabeblack@google.com                                    "SRCDIR",
8212046Sgabeblack@google.com                                    r'^\s*##include\s+"([\w/.-]*)"')
8312046Sgabeblack@google.com
84env.Append(SCANNERS = isa_scanner)
85
86#
87# Now create a Builder object that uses isa_parser.py to generate C++
88# output from the ISA description (*.isa) files.
89#
90
91# Convert to File node to fix path
92isa_parser = File('isa_parser.py')
93cpu_models_file = File('../cpu/cpu_models.py')
94
95# This sucks in the defintions of the CpuModel objects.
96execfile(cpu_models_file.srcnode().abspath)
97
98# Several files are generated from the ISA description.
99# We always get the basic decoder and header file.
100isa_desc_gen_files = [ 'decoder.cc', 'decoder.hh' ]
101# We also get an execute file for each selected CPU model.
102isa_desc_gen_files += [CpuModel.dict[cpu].filename
103                       for cpu in env['CPU_MODELS']]
104
105# Also include the CheckerCPU as one of the models if it is being
106# enabled via command line.
107if env['USE_CHECKER']:
108    isa_desc_gen_files += [CpuModel.dict['CheckerCPU'].filename]
109
110# The emitter patches up the sources & targets to include the
111# autogenerated files as targets and isa parser itself as a source.
112def isa_desc_emitter(target, source, env):
113    return (isa_desc_gen_files, [isa_parser, cpu_models_file] + source)
114
115# Pieces are in place, so create the builder.
116python = sys.executable  # use same Python binary used to run scons
117
118# Also include the CheckerCPU as one of the models if it is being
119# enabled via command line.
120if env['USE_CHECKER']:
121    isa_desc_builder = Builder(action=python + ' $SOURCES $TARGET.dir $CPU_MODELS CheckerCPU',
122                               emitter = isa_desc_emitter)
123else:
124    isa_desc_builder = Builder(action=python + ' $SOURCES $TARGET.dir $CPU_MODELS',
125                               emitter = isa_desc_emitter)
126
127env.Append(BUILDERS = { 'ISADesc' : isa_desc_builder })
128