a9c339403314f9aba05f2f6454b9f2dcd151671d
[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 from __future__ import print_function
30
31 import os
32 import sys
33
34 from os.path import basename, isdir, join as joinpath
35
36 import SCons
37
38 from gem5_scons import Transform
39
40 Import('*')
41
42 if env['PROTOCOL'] == 'None':
43 Return()
44
45 DebugFlag('ProtocolTrace')
46 DebugFlag('RubyCache')
47 DebugFlag('RubyCacheTrace')
48 DebugFlag('RubyDma')
49 DebugFlag('RubyGenerated')
50 DebugFlag('RubyNetwork')
51 DebugFlag('RubyPort')
52 DebugFlag('RubyPrefetcher')
53 DebugFlag('RubyQueue')
54 DebugFlag('RubySequencer')
55 DebugFlag('RubySlicc')
56 DebugFlag('RubySystem')
57 DebugFlag('RubyTester')
58 DebugFlag('RubyStats')
59 DebugFlag('RubyResourceStalls')
60
61 CompoundFlag('Ruby', [ 'RubyQueue', 'RubyNetwork', 'RubyTester',
62 'RubyGenerated', 'RubySlicc', 'RubySystem', 'RubyCache',
63 'RubyDma', 'RubyPort', 'RubySequencer', 'RubyCacheTrace',
64 'RubyPrefetcher'])
65
66 def do_embed_text(target, source, env):
67 """convert a text file into a file that can be embedded in C
68 using an #include statement, that defines a \"const char *\" pointing
69 to the same text.
70
71 This is useful to embed scripts and configuration files in object files.
72 """
73
74 escape = [ "\'", "\"", "\\", "\?" ]
75
76 # reads the text file in, line by line, converting it to a C string
77 fin = open(str(source[0]), 'r')
78 fout = open(str(target[0]), 'w' )
79 fout.write("static const char *%s =\n" % source[1].get_contents());
80 for l in fin:
81 # add escape sequences for the characters in escape
82 fout.write("\"")
83 for char in l:
84 if char == "\n":
85 break
86 if char in escape:
87 fout.write("\\")
88 fout.write(char)
89 else:
90 fout.write(char)
91 fout.write("\\n\"\n");
92 fout.write(";\n");
93 fin.close()
94 fout.close()
95
96 #
97 # Link includes
98 #
99 generated_dir = Dir('protocol')
100
101 def MakeIncludeAction(target, source, env):
102 f = file(str(target[0]), 'w')
103 for s in source:
104 print('#include "%s"' % str(s.abspath), file=f)
105 f.close()
106
107 def MakeInclude(source):
108 target = generated_dir.File(basename(source))
109 include_action = MakeAction(MakeIncludeAction, Transform("MAKE INC", 1))
110 env.Command(target, source, include_action)
111
112 MakeInclude('slicc_interface/AbstractCacheEntry.hh')
113 MakeInclude('slicc_interface/Message.hh')
114 MakeInclude('slicc_interface/RubyRequest.hh')
115
116 # External types
117 MakeInclude('common/Address.hh')
118 MakeInclude('common/BoolVec.hh')
119 MakeInclude('common/DataBlock.hh')
120 MakeInclude('common/IntVec.hh')
121 MakeInclude('common/MachineID.hh')
122 MakeInclude('common/NetDest.hh')
123 MakeInclude('common/Set.hh')
124 MakeInclude('common/WriteMask.hh')
125 MakeInclude('network/MessageBuffer.hh')
126 MakeInclude('structures/CacheMemory.hh')
127 MakeInclude('structures/DirectoryMemory.hh')
128 MakeInclude('structures/PerfectCacheMemory.hh')
129 MakeInclude('structures/PersistentTable.hh')
130 MakeInclude('structures/Prefetcher.hh')
131 MakeInclude('structures/TBETable.hh')
132 MakeInclude('structures/TimerTable.hh')
133 MakeInclude('structures/WireBuffer.hh')
134 MakeInclude('system/DMASequencer.hh')
135 MakeInclude('system/Sequencer.hh')
136
137 # External types : Group "mem/ruby/protocol" : include "header.hh" to the
138 # bottom of this MakeIncludes if it is referenced as
139 # <# include "mem/ruby/protocol/header.hh"> in any file
140 # generated_dir = Dir('protocol')
141 MakeInclude('system/GPUCoalescer.hh')
142 MakeInclude('system/VIPERCoalescer.hh')