SConscript revision 12892
110779SCurtis.Dunham@arm.com# -*- mode:python -*-
210779SCurtis.Dunham@arm.com
310779SCurtis.Dunham@arm.com# Copyright (c) 2009 The Hewlett-Packard Development Company
410779SCurtis.Dunham@arm.com# All rights reserved.
510779SCurtis.Dunham@arm.com#
610779SCurtis.Dunham@arm.com# Redistribution and use in source and binary forms, with or without
710779SCurtis.Dunham@arm.com# modification, are permitted provided that the following conditions are
810779SCurtis.Dunham@arm.com# met: redistributions of source code must retain the above copyright
910779SCurtis.Dunham@arm.com# notice, this list of conditions and the following disclaimer;
1010779SCurtis.Dunham@arm.com# redistributions in binary form must reproduce the above copyright
1110779SCurtis.Dunham@arm.com# notice, this list of conditions and the following disclaimer in the
1210779SCurtis.Dunham@arm.com# documentation and/or other materials provided with the distribution;
1310779SCurtis.Dunham@arm.com# neither the name of the copyright holders nor the names of its
1410779SCurtis.Dunham@arm.com# contributors may be used to endorse or promote products derived from
1510779SCurtis.Dunham@arm.com# this software without specific prior written permission.
1610779SCurtis.Dunham@arm.com#
1710779SCurtis.Dunham@arm.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1810779SCurtis.Dunham@arm.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1910779SCurtis.Dunham@arm.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2010779SCurtis.Dunham@arm.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2110779SCurtis.Dunham@arm.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2210779SCurtis.Dunham@arm.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2310779SCurtis.Dunham@arm.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2410779SCurtis.Dunham@arm.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2510779SCurtis.Dunham@arm.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2610779SCurtis.Dunham@arm.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2710779SCurtis.Dunham@arm.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2810779SCurtis.Dunham@arm.com#
2910779SCurtis.Dunham@arm.com# Authors: Nathan Binkert
3010779SCurtis.Dunham@arm.com
3110779SCurtis.Dunham@arm.comfrom __future__ import print_function
3210779SCurtis.Dunham@arm.com
3310779SCurtis.Dunham@arm.comimport os
3410779SCurtis.Dunham@arm.comimport sys
3510779SCurtis.Dunham@arm.com
3610779SCurtis.Dunham@arm.comfrom os.path import basename, isdir, join as joinpath
3710779SCurtis.Dunham@arm.com
3810779SCurtis.Dunham@arm.comimport SCons
3910779SCurtis.Dunham@arm.com
4010779SCurtis.Dunham@arm.comfrom gem5_scons import Transform
4110779SCurtis.Dunham@arm.com
4210779SCurtis.Dunham@arm.comImport('*')
4310779SCurtis.Dunham@arm.com
4410779SCurtis.Dunham@arm.comif env['PROTOCOL'] == 'None':
4511617SCurtis.Dunham@arm.com    Return()
4610779SCurtis.Dunham@arm.com
4710779SCurtis.Dunham@arm.comDebugFlag('ProtocolTrace')
4810779SCurtis.Dunham@arm.comDebugFlag('RubyCache')
4910779SCurtis.Dunham@arm.comDebugFlag('RubyCacheTrace')
5010779SCurtis.Dunham@arm.comDebugFlag('RubyDma')
5110779SCurtis.Dunham@arm.comDebugFlag('RubyGenerated')
5210779SCurtis.Dunham@arm.comDebugFlag('RubyNetwork')
5310779SCurtis.Dunham@arm.comDebugFlag('RubyPort')
5410779SCurtis.Dunham@arm.comDebugFlag('RubyPrefetcher')
5510779SCurtis.Dunham@arm.comDebugFlag('RubyQueue')
5610779SCurtis.Dunham@arm.comDebugFlag('RubySequencer')
5710779SCurtis.Dunham@arm.comDebugFlag('RubySlicc')
5810779SCurtis.Dunham@arm.comDebugFlag('RubySystem')
5910779SCurtis.Dunham@arm.comDebugFlag('RubyTester')
6010779SCurtis.Dunham@arm.comDebugFlag('RubyStats')
6110779SCurtis.Dunham@arm.comDebugFlag('RubyResourceStalls')
6210779SCurtis.Dunham@arm.com
6310779SCurtis.Dunham@arm.comCompoundFlag('Ruby', [ 'RubyQueue', 'RubyNetwork', 'RubyTester',
6410779SCurtis.Dunham@arm.com    'RubyGenerated', 'RubySlicc', 'RubySystem', 'RubyCache',
6510779SCurtis.Dunham@arm.com    'RubyDma', 'RubyPort', 'RubySequencer', 'RubyCacheTrace',
6610779SCurtis.Dunham@arm.com    'RubyPrefetcher'])
6710779SCurtis.Dunham@arm.com
6810779SCurtis.Dunham@arm.comdef do_embed_text(target, source, env):
6910779SCurtis.Dunham@arm.com    """convert a text file into a file that can be embedded in C
7010779SCurtis.Dunham@arm.com    using an #include statement, that defines a \"const char *\" pointing
7110779SCurtis.Dunham@arm.com    to the same text.
7210779SCurtis.Dunham@arm.com
7310779SCurtis.Dunham@arm.com    This is useful to embed scripts and configuration files in object files.
7410779SCurtis.Dunham@arm.com    """
7510779SCurtis.Dunham@arm.com
7610779SCurtis.Dunham@arm.com    escape = [ "\'", "\"", "\\", "\?" ]
7710779SCurtis.Dunham@arm.com
7810779SCurtis.Dunham@arm.com    # reads the text file in, line by line, converting it to a C string
7910779SCurtis.Dunham@arm.com    fin = open(str(source[0]), 'r')
8010779SCurtis.Dunham@arm.com    fout = open(str(target[0]), 'w' )
81    fout.write("static const char *%s =\n" % source[1].get_contents());
82    for l in fin:
83        # add escape sequences for the characters in escape
84        fout.write("\"")
85        for char in l:
86            if char == "\n":
87                break
88            if char in escape:
89                fout.write("\\")
90                fout.write(char)
91            else:
92                fout.write(char)
93        fout.write("\\n\"\n");
94    fout.write(";\n");
95    fin.close()
96    fout.close()
97
98#
99# Link includes
100#
101generated_dir = Dir('../protocol')
102
103def MakeIncludeAction(target, source, env):
104    f = file(str(target[0]), 'w')
105    for s in source:
106        print('#include "%s"' % str(s.abspath), file=f)
107    f.close()
108
109def MakeInclude(source):
110    target = generated_dir.File(basename(source))
111    include_action = MakeAction(MakeIncludeAction, Transform("MAKE INC", 1))
112    env.Command(target, source, include_action)
113
114MakeInclude('slicc_interface/AbstractEntry.hh')
115MakeInclude('slicc_interface/AbstractCacheEntry.hh')
116MakeInclude('slicc_interface/Message.hh')
117MakeInclude('slicc_interface/RubyRequest.hh')
118
119# External types
120MakeInclude('common/Address.hh')
121MakeInclude('common/BoolVec.hh')
122MakeInclude('common/DataBlock.hh')
123MakeInclude('common/IntVec.hh')
124MakeInclude('common/MachineID.hh')
125MakeInclude('common/NetDest.hh')
126MakeInclude('common/Set.hh')
127MakeInclude('common/WriteMask.hh')
128MakeInclude('filters/AbstractBloomFilter.hh')
129MakeInclude('network/MessageBuffer.hh')
130MakeInclude('structures/CacheMemory.hh')
131MakeInclude('structures/DirectoryMemory.hh')
132MakeInclude('structures/PerfectCacheMemory.hh')
133MakeInclude('structures/PersistentTable.hh')
134MakeInclude('structures/Prefetcher.hh')
135MakeInclude('structures/TBETable.hh')
136MakeInclude('structures/TimerTable.hh')
137MakeInclude('structures/WireBuffer.hh')
138MakeInclude('system/DMASequencer.hh')
139MakeInclude('system/Sequencer.hh')
140
141# External types : Group "mem/protocol" : include "header.hh" to the bottom
142# of this MakeIncludes if it is referenced as
143# <# include "mem/protocol/header.hh"> in any file
144# generated_dir = Dir('../protocol')
145MakeInclude('system/GPUCoalescer.hh')
146MakeInclude('system/VIPERCoalescer.hh')
147