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