SConscript revision 12246:9ffa51416f39
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
38from gem5_scons import Transform
39
40Import('*')
41
42DebugFlag('ProtocolTrace')
43DebugFlag('RubyCache')
44DebugFlag('RubyCacheTrace')
45DebugFlag('RubyDma')
46DebugFlag('RubyGenerated')
47DebugFlag('RubyNetwork')
48DebugFlag('RubyPort')
49DebugFlag('RubyPrefetcher')
50DebugFlag('RubyQueue')
51DebugFlag('RubySequencer')
52DebugFlag('RubySlicc')
53DebugFlag('RubySystem')
54DebugFlag('RubyTester')
55DebugFlag('RubyStats')
56DebugFlag('RubyResourceStalls')
57
58CompoundFlag('Ruby', [ 'RubyQueue', 'RubyNetwork', 'RubyTester',
59    'RubyGenerated', 'RubySlicc', 'RubySystem', 'RubyCache',
60    'RubyDma', 'RubyPort', 'RubySequencer', 'RubyCacheTrace',
61    'RubyPrefetcher'])
62
63if env['PROTOCOL'] == 'None':
64    Return()
65
66def 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#
99generated_dir = Dir('../protocol')
100
101def MakeIncludeAction(target, source, env):
102    f = file(str(target[0]), 'w')
103    for s in source:
104        print >>f, '#include "%s"' % str(s.abspath)
105    f.close()
106
107def 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
112MakeInclude('slicc_interface/AbstractEntry.hh')
113MakeInclude('slicc_interface/AbstractCacheEntry.hh')
114MakeInclude('slicc_interface/Message.hh')
115MakeInclude('slicc_interface/RubyRequest.hh')
116
117# External types
118MakeInclude('common/Address.hh')
119MakeInclude('common/BoolVec.hh')
120MakeInclude('common/DataBlock.hh')
121MakeInclude('common/IntVec.hh')
122MakeInclude('common/MachineID.hh')
123MakeInclude('common/NetDest.hh')
124MakeInclude('common/Set.hh')
125MakeInclude('common/WriteMask.hh')
126MakeInclude('filters/AbstractBloomFilter.hh')
127MakeInclude('network/MessageBuffer.hh')
128MakeInclude('structures/CacheMemory.hh')
129MakeInclude('structures/DirectoryMemory.hh')
130MakeInclude('structures/PerfectCacheMemory.hh')
131MakeInclude('structures/PersistentTable.hh')
132MakeInclude('structures/Prefetcher.hh')
133MakeInclude('structures/TBETable.hh')
134MakeInclude('structures/TimerTable.hh')
135MakeInclude('structures/WireBuffer.hh')
136MakeInclude('system/DMASequencer.hh')
137MakeInclude('system/Sequencer.hh')
138
139# External types : Group "mem/protocol" : include "header.hh" to the bottom
140# of this MakeIncludes if it is referenced as
141# <# include "mem/protocol/header.hh"> in any file
142# generated_dir = Dir('../protocol')
143MakeInclude('system/GPUCoalescer.hh')
144MakeInclude('system/VIPERCoalescer.hh')
145