SConscript revision 10301
14486Sbinkertn@umich.edu# -*- mode:python -*-
24486Sbinkertn@umich.edu
34486Sbinkertn@umich.edu# Copyright (c) 2009 The Hewlett-Packard Development Company
44486Sbinkertn@umich.edu# All rights reserved.
54486Sbinkertn@umich.edu#
64486Sbinkertn@umich.edu# Redistribution and use in source and binary forms, with or without
74486Sbinkertn@umich.edu# modification, are permitted provided that the following conditions are
84486Sbinkertn@umich.edu# met: redistributions of source code must retain the above copyright
94486Sbinkertn@umich.edu# notice, this list of conditions and the following disclaimer;
104486Sbinkertn@umich.edu# redistributions in binary form must reproduce the above copyright
114486Sbinkertn@umich.edu# notice, this list of conditions and the following disclaimer in the
124486Sbinkertn@umich.edu# documentation and/or other materials provided with the distribution;
134486Sbinkertn@umich.edu# neither the name of the copyright holders nor the names of its
144486Sbinkertn@umich.edu# contributors may be used to endorse or promote products derived from
154486Sbinkertn@umich.edu# this software without specific prior written permission.
164486Sbinkertn@umich.edu#
174486Sbinkertn@umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
184486Sbinkertn@umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
194486Sbinkertn@umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
204486Sbinkertn@umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
214486Sbinkertn@umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
224486Sbinkertn@umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
234486Sbinkertn@umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
244486Sbinkertn@umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
254486Sbinkertn@umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
264486Sbinkertn@umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
274486Sbinkertn@umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
284486Sbinkertn@umich.edu#
293630SN/A# Authors: Nathan Binkert
303630SN/A
314104SN/Aimport os
325478Snate@binkert.orgimport sys
335478Snate@binkert.org
343743SN/Afrom os.path import basename, isdir, join as joinpath
353630SN/A
363898SN/Aimport SCons
373898SN/A
383898SN/AImport('*')
393898SN/A
403898SN/ADebugFlag('ProtocolTrace')
413898SN/ADebugFlag('RubyCache')
423914SN/ADebugFlag('RubyCacheTrace')
433914SN/ADebugFlag('RubyDma')
443914SN/ADebugFlag('RubyGenerated')
453914SN/ADebugFlag('RubyMemory')
463914SN/ADebugFlag('RubyNetwork')
474104SN/ADebugFlag('RubyPort')
484104SN/ADebugFlag('RubyPrefetcher')
498742Sgblack@eecs.umich.eduDebugFlag('RubyQueue')
504104SN/ADebugFlag('RubySequencer')
514104SN/ADebugFlag('RubySlicc')
523914SN/ADebugFlag('RubySystem')
533630SN/ADebugFlag('RubyTester')
543630SN/ADebugFlag('RubyStats')
553630SN/ADebugFlag('RubyResourceStalls')
563630SN/A
574007SN/ACompoundFlag('Ruby', [ 'RubyQueue', 'RubyNetwork', 'RubyTester',
584007SN/A    'RubyGenerated', 'RubySlicc', 'RubySystem', 'RubyCache',
593630SN/A    'RubyMemory', 'RubyDma', 'RubyPort', 'RubySequencer', 'RubyCacheTrace',
603814SN/A    'RubyPrefetcher'])
614007SN/A
624007SN/Aif env['TARGET_ISA'] == 'null':
633814SN/A    Return()
644007SN/A
654007SN/Aif env['PROTOCOL'] == 'None':
663814SN/A    Return()
673814SN/A
684007SN/Adef do_embed_text(target, source, env):
694007SN/A    """convert a text file into a file that can be embedded in C
703814SN/A    using an #include statement, that defines a \"const char *\" pointing
713814SN/A    to the same text.
724007SN/A
734007SN/A    This is useful to embed scripts and configuration files in object files.
743814SN/A    """
753814SN/A
764007SN/A    escape = [ "\'", "\"", "\\", "\?" ]
774007SN/A
783814SN/A    # reads the text file in, line by line, converting it to a C string
793814SN/A    fin = open(str(source[0]), 'r')
804007SN/A    fout = open(str(target[0]), 'w' )
814007SN/A    fout.write("static const char *%s =\n" % source[1].get_contents());
823814SN/A    for l in fin:
833825SN/A        # add escape sequences for the characters in escape
844007SN/A        fout.write("\"")
854007SN/A        for char in l:
863825SN/A            if char == "\n":
873825SN/A                break
884007SN/A            if char in escape:
894007SN/A                fout.write("\\")
903825SN/A                fout.write(char)
913825SN/A            else:
924007SN/A                fout.write(char)
934007SN/A        fout.write("\\n\"\n");
943825SN/A    fout.write(";\n");
953825SN/A    fin.close()
964007SN/A    fout.close()
974007SN/A
983825SN/A#
994007SN/A# Link includes
1004007SN/A#
1013814SN/Agenerated_dir = Dir('../protocol')
1025478Snate@binkert.org
1033814SN/Adef MakeIncludeAction(target, source, env):
1043914SN/A    f = file(str(target[0]), 'w')
1053914SN/A    for s in source:
1065478Snate@binkert.org        print >>f, '#include "%s"' % str(s.abspath)
1073814SN/A    f.close()
1083630SN/A
1094104SN/Adef MakeInclude(source):
1104104SN/A    target = generated_dir.File(basename(source))
1114104SN/A    include_action = MakeAction(MakeIncludeAction, Transform("MAKE INC", 1))
1128847Sandreas.hansson@arm.com    env.Command(target, source, include_action)
1138847Sandreas.hansson@arm.com
1144104SN/AMakeInclude('slicc_interface/AbstractEntry.hh')
1154104SN/AMakeInclude('slicc_interface/AbstractCacheEntry.hh')
1163630SN/AMakeInclude('slicc_interface/Message.hh')
1173630SN/AMakeInclude('slicc_interface/NetworkMessage.hh')
1183630SN/AMakeInclude('slicc_interface/RubyRequest.hh')
1193630SN/A
1205478Snate@binkert.org# External types
1215478Snate@binkert.orgMakeInclude('common/Address.hh')
1228847Sandreas.hansson@arm.comMakeInclude('common/DataBlock.hh')
1238847Sandreas.hansson@arm.comMakeInclude('common/MachineID.hh')
1248847Sandreas.hansson@arm.comMakeInclude('common/NetDest.hh')
1258847Sandreas.hansson@arm.comMakeInclude('common/Set.hh')
1268847Sandreas.hansson@arm.comMakeInclude('filters/GenericBloomFilter.hh')
1278847Sandreas.hansson@arm.comMakeInclude('network/MessageBuffer.hh')
1288847Sandreas.hansson@arm.comMakeInclude('structures/Prefetcher.hh')
1298847Sandreas.hansson@arm.comMakeInclude('structures/CacheMemory.hh')
1308847Sandreas.hansson@arm.comMakeInclude('system/DMASequencer.hh')
1318847Sandreas.hansson@arm.comMakeInclude('structures/DirectoryMemory.hh')
1328847Sandreas.hansson@arm.comMakeInclude('structures/MemoryControl.hh')
1338847Sandreas.hansson@arm.comMakeInclude('structures/WireBuffer.hh')
1348847Sandreas.hansson@arm.comMakeInclude('structures/PerfectCacheMemory.hh')
1358847Sandreas.hansson@arm.comMakeInclude('structures/PersistentTable.hh')
136MakeInclude('system/Sequencer.hh')
137MakeInclude('structures/TBETable.hh')
138MakeInclude('structures/TimerTable.hh')
139