build opts: add MI_example to NULL ISA
[gem5.git] / src / mem / ruby / SConscript
1 # -*- mode:python -*-
2
3 # Copyright (c) 2009 The Hewlett-Packard Development Company
4 # All rights reserved.
5 #
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions are
8 # met: redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer;
10 # redistributions in binary form must reproduce the above copyright
11 # notice, this list of conditions and the following disclaimer in the
12 # documentation and/or other materials provided with the distribution;
13 # neither the name of the copyright holders nor the names of its
14 # contributors may be used to endorse or promote products derived from
15 # this software without specific prior written permission.
16 #
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #
29 # Authors: Nathan Binkert
30
31 import os
32 import sys
33
34 from os.path import basename, isdir, join as joinpath
35
36 import SCons
37
38 Import('*')
39
40 DebugFlag('ProtocolTrace')
41 DebugFlag('RubyCache')
42 DebugFlag('RubyCacheTrace')
43 DebugFlag('RubyDma')
44 DebugFlag('RubyGenerated')
45 DebugFlag('RubyMemory')
46 DebugFlag('RubyNetwork')
47 DebugFlag('RubyPort')
48 DebugFlag('RubyPrefetcher')
49 DebugFlag('RubyQueue')
50 DebugFlag('RubySequencer')
51 DebugFlag('RubySlicc')
52 DebugFlag('RubySystem')
53 DebugFlag('RubyTester')
54 DebugFlag('RubyStats')
55 DebugFlag('RubyResourceStalls')
56
57 CompoundFlag('Ruby', [ 'RubyQueue', 'RubyNetwork', 'RubyTester',
58 'RubyGenerated', 'RubySlicc', 'RubySystem', 'RubyCache',
59 'RubyMemory', 'RubyDma', 'RubyPort', 'RubySequencer', 'RubyCacheTrace',
60 'RubyPrefetcher'])
61
62 if env['PROTOCOL'] == 'None':
63 Return()
64
65 def do_embed_text(target, source, env):
66 """convert a text file into a file that can be embedded in C
67 using an #include statement, that defines a \"const char *\" pointing
68 to the same text.
69
70 This is useful to embed scripts and configuration files in object files.
71 """
72
73 escape = [ "\'", "\"", "\\", "\?" ]
74
75 # reads the text file in, line by line, converting it to a C string
76 fin = open(str(source[0]), 'r')
77 fout = open(str(target[0]), 'w' )
78 fout.write("static const char *%s =\n" % source[1].get_contents());
79 for l in fin:
80 # add escape sequences for the characters in escape
81 fout.write("\"")
82 for char in l:
83 if char == "\n":
84 break
85 if char in escape:
86 fout.write("\\")
87 fout.write(char)
88 else:
89 fout.write(char)
90 fout.write("\\n\"\n");
91 fout.write(";\n");
92 fin.close()
93 fout.close()
94
95 #
96 # Link includes
97 #
98 generated_dir = Dir('../protocol')
99
100 def MakeIncludeAction(target, source, env):
101 f = file(str(target[0]), 'w')
102 for s in source:
103 print >>f, '#include "%s"' % str(s.abspath)
104 f.close()
105
106 def MakeInclude(source):
107 target = generated_dir.File(basename(source))
108 include_action = MakeAction(MakeIncludeAction, Transform("MAKE INC", 1))
109 env.Command(target, source, include_action)
110
111 MakeInclude('slicc_interface/AbstractEntry.hh')
112 MakeInclude('slicc_interface/AbstractCacheEntry.hh')
113 MakeInclude('slicc_interface/Message.hh')
114 MakeInclude('slicc_interface/NetworkMessage.hh')
115 MakeInclude('slicc_interface/RubyRequest.hh')
116
117 # External types
118 MakeInclude('common/Address.hh')
119 MakeInclude('common/DataBlock.hh')
120 MakeInclude('common/MachineID.hh')
121 MakeInclude('common/NetDest.hh')
122 MakeInclude('common/Set.hh')
123 MakeInclude('filters/GenericBloomFilter.hh')
124 MakeInclude('network/MessageBuffer.hh')
125 MakeInclude('structures/Prefetcher.hh')
126 MakeInclude('structures/CacheMemory.hh')
127 MakeInclude('system/DMASequencer.hh')
128 MakeInclude('structures/DirectoryMemory.hh')
129 MakeInclude('structures/MemoryControl.hh')
130 MakeInclude('structures/WireBuffer.hh')
131 MakeInclude('structures/PerfectCacheMemory.hh')
132 MakeInclude('structures/PersistentTable.hh')
133 MakeInclude('system/Sequencer.hh')
134 MakeInclude('structures/TBETable.hh')
135 MakeInclude('structures/TimerTable.hh')