SConscript revision 12246
12221SN/A# -*- mode:python -*-
22221SN/A
32221SN/A# Copyright (c) 2009 The Hewlett-Packard Development Company
42221SN/A# All rights reserved.
52221SN/A#
62221SN/A# Redistribution and use in source and binary forms, with or without
72221SN/A# modification, are permitted provided that the following conditions are
82221SN/A# met: redistributions of source code must retain the above copyright
92221SN/A# notice, this list of conditions and the following disclaimer;
102221SN/A# redistributions in binary form must reproduce the above copyright
112221SN/A# notice, this list of conditions and the following disclaimer in the
122221SN/A# documentation and/or other materials provided with the distribution;
132221SN/A# neither the name of the copyright holders nor the names of its
142221SN/A# contributors may be used to endorse or promote products derived from
152221SN/A# this software without specific prior written permission.
162221SN/A#
172221SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
182221SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
192221SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
202221SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
212221SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
222221SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
232221SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
242221SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
252221SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
262221SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
272665Ssaidi@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
282665Ssaidi@eecs.umich.edu#
292665Ssaidi@eecs.umich.edu# Authors: Nathan Binkert
302221SN/A
312221SN/Aimport os
322223SN/Aimport sys
332221SN/A
342221SN/Afrom os.path import basename, isdir, join as joinpath
352221SN/A
362221SN/Aimport SCons
372223SN/A
382221SN/Afrom gem5_scons import Transform
392221SN/A
402223SN/AImport('*')
412223SN/A
422223SN/ADebugFlag('ProtocolTrace')
432223SN/ADebugFlag('RubyCache')
442221SN/ADebugFlag('RubyCacheTrace')
452223SN/ADebugFlag('RubyDma')
462223SN/ADebugFlag('RubyGenerated')
472223SN/ADebugFlag('RubyNetwork')
482223SN/ADebugFlag('RubyPort')
492221SN/ADebugFlag('RubyPrefetcher')
502223SN/ADebugFlag('RubyQueue')
512223SN/ADebugFlag('RubySequencer')
522223SN/ADebugFlag('RubySlicc')
532223SN/ADebugFlag('RubySystem')
542221SN/ADebugFlag('RubyTester')
552223SN/ADebugFlag('RubyStats')
562223SN/ADebugFlag('RubyResourceStalls')
572223SN/A
582223SN/ACompoundFlag('Ruby', [ 'RubyQueue', 'RubyNetwork', 'RubyTester',
592221SN/A    'RubyGenerated', 'RubySlicc', 'RubySystem', 'RubyCache',
602223SN/A    'RubyDma', 'RubyPort', 'RubySequencer', 'RubyCacheTrace',
612223SN/A    'RubyPrefetcher'])
622223SN/A
632223SN/Aif env['PROTOCOL'] == 'None':
642221SN/A    Return()
652223SN/A
662223SN/Adef do_embed_text(target, source, env):
672223SN/A    """convert a text file into a file that can be embedded in C
682223SN/A    using an #include statement, that defines a \"const char *\" pointing
692221SN/A    to the same text.
702223SN/A
712223SN/A    This is useful to embed scripts and configuration files in object files.
722223SN/A    """
732223SN/A
742221SN/A    escape = [ "\'", "\"", "\\", "\?" ]
752223SN/A
762223SN/A    # reads the text file in, line by line, converting it to a C string
772223SN/A    fin = open(str(source[0]), 'r')
782223SN/A    fout = open(str(target[0]), 'w' )
792221SN/A    fout.write("static const char *%s =\n" % source[1].get_contents());
802223SN/A    for l in fin:
812223SN/A        # add escape sequences for the characters in escape
822223SN/A        fout.write("\"")
832223SN/A        for char in l:
842221SN/A            if char == "\n":
852223SN/A                break
862223SN/A            if char in escape:
872223SN/A                fout.write("\\")
882223SN/A                fout.write(char)
892221SN/A            else:
902223SN/A                fout.write(char)
912223SN/A        fout.write("\\n\"\n");
922223SN/A    fout.write(";\n");
932223SN/A    fin.close()
942221SN/A    fout.close()
952469SN/A
962469SN/A#
972469SN/A# Link includes
982469SN/A#
992221SN/Agenerated_dir = Dir('../protocol')
1002223SN/A
1012223SN/Adef MakeIncludeAction(target, source, env):
1022223SN/A    f = file(str(target[0]), 'w')
1032223SN/A    for s in source:
1042221SN/A        print >>f, '#include "%s"' % str(s.abspath)
1052223SN/A    f.close()
1062223SN/A
1072223SN/Adef MakeInclude(source):
1082223SN/A    target = generated_dir.File(basename(source))
1092221SN/A    include_action = MakeAction(MakeIncludeAction, Transform("MAKE INC", 1))
1102223SN/A    env.Command(target, source, include_action)
1112223SN/A
1122223SN/AMakeInclude('slicc_interface/AbstractEntry.hh')
1132223SN/AMakeInclude('slicc_interface/AbstractCacheEntry.hh')
1142221SN/AMakeInclude('slicc_interface/Message.hh')
1152223SN/AMakeInclude('slicc_interface/RubyRequest.hh')
1162223SN/A
1172223SN/A# External types
1182223SN/AMakeInclude('common/Address.hh')
1192223SN/AMakeInclude('common/BoolVec.hh')
1202223SN/AMakeInclude('common/DataBlock.hh')
1212223SN/AMakeInclude('common/IntVec.hh')
1222223SN/AMakeInclude('common/MachineID.hh')
1232223SN/AMakeInclude('common/NetDest.hh')
1242223SN/AMakeInclude('common/Set.hh')
1252223SN/AMakeInclude('common/WriteMask.hh')
1262223SN/AMakeInclude('filters/AbstractBloomFilter.hh')
1272223SN/AMakeInclude('network/MessageBuffer.hh')
1282223SN/AMakeInclude('structures/CacheMemory.hh')
1292223SN/AMakeInclude('structures/DirectoryMemory.hh')
1302223SN/AMakeInclude('structures/PerfectCacheMemory.hh')
1312223SN/AMakeInclude('structures/PersistentTable.hh')
1322223SN/AMakeInclude('structures/Prefetcher.hh')
1332223SN/AMakeInclude('structures/TBETable.hh')
1342223SN/AMakeInclude('structures/TimerTable.hh')
1352223SN/AMakeInclude('structures/WireBuffer.hh')
1362223SN/AMakeInclude('system/DMASequencer.hh')
1372223SN/AMakeInclude('system/Sequencer.hh')
1382223SN/A
1392223SN/A# External types : Group "mem/protocol" : include "header.hh" to the bottom
1402223SN/A# of this MakeIncludes if it is referenced as
1412223SN/A# <# include "mem/protocol/header.hh"> in any file
1422223SN/A# generated_dir = Dir('../protocol')
1432223SN/AMakeInclude('system/GPUCoalescer.hh')
1442223SN/AMakeInclude('system/VIPERCoalescer.hh')
1452223SN/A