3 # Copyright (c) 2009 The Hewlett-Packard Development Company
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.
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.
29 # Authors: Nathan Binkert
34 from os.path import basename, isdir, join as joinpath
40 if env['TARGET_ISA'] == 'no':
48 def do_embed_text(target, source, env):
49 """convert a text file into a file that can be embedded in C
50 using an #include statement, that defines a \"const char *\" pointing
53 This is useful to embed scripts and configuration files in object files.
56 escape = [ "\'", "\"", "\\", "\?" ]
58 # reads the text file in, line by line, converting it to a C string
59 fin = open(str(source[0]), 'r')
60 fout = open(str(target[0]), 'w' )
61 fout.write("static const char *%s =\n" % source[1].get_contents());
63 # add escape sequences for the characters in escape
73 fout.write("\\n\"\n");
81 generated_dir = Dir('../protocol')
83 def MakeIncludeAction(target, source, env):
84 f = file(str(target[0]), 'w')
86 print >>f, '#include "%s"' % str(s.abspath)
89 def MakeInclude(source):
90 target = generated_dir.File(basename(source))
91 env.Command(target, source, MakeIncludeAction)
93 MakeInclude('slicc_interface/AbstractEntry.hh')
94 MakeInclude('slicc_interface/AbstractCacheEntry.hh')
95 MakeInclude('slicc_interface/AbstractProtocol.hh')
96 MakeInclude('slicc_interface/Message.hh')
97 MakeInclude('slicc_interface/NetworkMessage.hh')
100 MakeInclude('buffers/MessageBuffer.hh')
101 MakeInclude('common/Address.hh')
102 MakeInclude('common/DataBlock.hh')
103 MakeInclude('common/NetDest.hh')
104 MakeInclude('common/Set.hh')
105 MakeInclude('filters/GenericBloomFilter.hh')
106 MakeInclude('system/CacheMemory.hh')
107 MakeInclude('system/DMASequencer.hh')
108 MakeInclude('system/DirectoryMemory.hh')
109 MakeInclude('system/MachineID.hh')
110 MakeInclude('system/MemoryControl.hh')
111 MakeInclude('system/NodeID.hh')
112 MakeInclude('system/PerfectCacheMemory.hh')
113 MakeInclude('system/PersistentTable.hh')
114 MakeInclude('system/Sequencer.hh')
115 MakeInclude('system/TBETable.hh')
116 MakeInclude('system/TimerTable.hh')