SConscript revision 11755
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
323415Sgblack@eecs.umich.eduimport sys
333415Sgblack@eecs.umich.edu
342223SN/Afrom os.path import basename, isdir, join as joinpath
353415Sgblack@eecs.umich.edu
363578Sgblack@eecs.umich.eduimport SCons
373415Sgblack@eecs.umich.edu
383415Sgblack@eecs.umich.eduImport('*')
393523Sgblack@eecs.umich.edu
403415Sgblack@eecs.umich.eduDebugFlag('ProtocolTrace')
412680Sktlim@umich.eduDebugFlag('RubyCache')
422800Ssaidi@eecs.umich.eduDebugFlag('RubyCacheTrace')
433523Sgblack@eecs.umich.eduDebugFlag('RubyDma')
443415Sgblack@eecs.umich.eduDebugFlag('RubyGenerated')
452800Ssaidi@eecs.umich.eduDebugFlag('RubyNetwork')
462800Ssaidi@eecs.umich.eduDebugFlag('RubyPort')
472221SN/ADebugFlag('RubyPrefetcher')
483415Sgblack@eecs.umich.eduDebugFlag('RubyQueue')
493415Sgblack@eecs.umich.eduDebugFlag('RubySequencer')
502223SN/ADebugFlag('RubySlicc')
512221SN/ADebugFlag('RubySystem')
522221SN/ADebugFlag('RubyTester')
533573Sgblack@eecs.umich.eduDebugFlag('RubyStats')
543576Sgblack@eecs.umich.eduDebugFlag('RubyResourceStalls')
553576Sgblack@eecs.umich.edu
562221SN/ACompoundFlag('Ruby', [ 'RubyQueue', 'RubyNetwork', 'RubyTester',
573573Sgblack@eecs.umich.edu    'RubyGenerated', 'RubySlicc', 'RubySystem', 'RubyCache',
583576Sgblack@eecs.umich.edu    'RubyDma', 'RubyPort', 'RubySequencer', 'RubyCacheTrace',
593576Sgblack@eecs.umich.edu    'RubyPrefetcher'])
602221SN/A
613573Sgblack@eecs.umich.eduif env['PROTOCOL'] == 'None':
623576Sgblack@eecs.umich.edu    Return()
633576Sgblack@eecs.umich.edu
642221SN/Adef do_embed_text(target, source, env):
653573Sgblack@eecs.umich.edu    """convert a text file into a file that can be embedded in C
663576Sgblack@eecs.umich.edu    using an #include statement, that defines a \"const char *\" pointing
673576Sgblack@eecs.umich.edu    to the same text.
682221SN/A
693573Sgblack@eecs.umich.edu    This is useful to embed scripts and configuration files in object files.
703576Sgblack@eecs.umich.edu    """
713576Sgblack@eecs.umich.edu
722221SN/A    escape = [ "\'", "\"", "\\", "\?" ]
733573Sgblack@eecs.umich.edu
743576Sgblack@eecs.umich.edu    # reads the text file in, line by line, converting it to a C string
753576Sgblack@eecs.umich.edu    fin = open(str(source[0]), 'r')
762221SN/A    fout = open(str(target[0]), 'w' )
773573Sgblack@eecs.umich.edu    fout.write("static const char *%s =\n" % source[1].get_contents());
783576Sgblack@eecs.umich.edu    for l in fin:
793576Sgblack@eecs.umich.edu        # add escape sequences for the characters in escape
803576Sgblack@eecs.umich.edu        fout.write("\"")
813576Sgblack@eecs.umich.edu        for char in l:
823576Sgblack@eecs.umich.edu            if char == "\n":
833576Sgblack@eecs.umich.edu                break
843576Sgblack@eecs.umich.edu            if char in escape:
852221SN/A                fout.write("\\")
863573Sgblack@eecs.umich.edu                fout.write(char)
873576Sgblack@eecs.umich.edu            else:
883576Sgblack@eecs.umich.edu                fout.write(char)
892221SN/A        fout.write("\\n\"\n");
903573Sgblack@eecs.umich.edu    fout.write(";\n");
913576Sgblack@eecs.umich.edu    fin.close()
923576Sgblack@eecs.umich.edu    fout.close()
932221SN/A
943573Sgblack@eecs.umich.edu#
953576Sgblack@eecs.umich.edu# Link includes
963576Sgblack@eecs.umich.edu#
973576Sgblack@eecs.umich.edugenerated_dir = Dir('../protocol')
983576Sgblack@eecs.umich.edu
993576Sgblack@eecs.umich.edudef MakeIncludeAction(target, source, env):
1003576Sgblack@eecs.umich.edu    f = file(str(target[0]), 'w')
1013576Sgblack@eecs.umich.edu    for s in source:
1023576Sgblack@eecs.umich.edu        print >>f, '#include "%s"' % str(s.abspath)
1033576Sgblack@eecs.umich.edu    f.close()
1043576Sgblack@eecs.umich.edu
1053576Sgblack@eecs.umich.edudef MakeInclude(source):
1063576Sgblack@eecs.umich.edu    target = generated_dir.File(basename(source))
1072221SN/A    include_action = MakeAction(MakeIncludeAction, Transform("MAKE INC", 1))
1083573Sgblack@eecs.umich.edu    env.Command(target, source, include_action)
1093576Sgblack@eecs.umich.edu
1103576Sgblack@eecs.umich.eduMakeInclude('slicc_interface/AbstractEntry.hh')
1112221SN/AMakeInclude('slicc_interface/AbstractCacheEntry.hh')
1123573Sgblack@eecs.umich.eduMakeInclude('slicc_interface/Message.hh')
1133576Sgblack@eecs.umich.eduMakeInclude('slicc_interface/RubyRequest.hh')
1143576Sgblack@eecs.umich.edu
1152221SN/A# External types
1163573Sgblack@eecs.umich.eduMakeInclude('common/Address.hh')
1173576Sgblack@eecs.umich.eduMakeInclude('common/BoolVec.hh')
1183576Sgblack@eecs.umich.eduMakeInclude('common/DataBlock.hh')
1192221SN/AMakeInclude('common/IntVec.hh')
1203573Sgblack@eecs.umich.eduMakeInclude('common/MachineID.hh')
1213576Sgblack@eecs.umich.eduMakeInclude('common/NetDest.hh')
1223576Sgblack@eecs.umich.eduMakeInclude('common/Set.hh')
1232221SN/AMakeInclude('common/WriteMask.hh')
1243573Sgblack@eecs.umich.eduMakeInclude('filters/AbstractBloomFilter.hh')
1253576Sgblack@eecs.umich.eduMakeInclude('network/MessageBuffer.hh')
1263576Sgblack@eecs.umich.eduMakeInclude('structures/CacheMemory.hh')
1272221SN/AMakeInclude('structures/DirectoryMemory.hh')
1283573Sgblack@eecs.umich.eduMakeInclude('structures/PerfectCacheMemory.hh')
1293576Sgblack@eecs.umich.eduMakeInclude('structures/PersistentTable.hh')
1303576Sgblack@eecs.umich.eduMakeInclude('structures/Prefetcher.hh')
1312223SN/AMakeInclude('structures/TBETable.hh')
1323573Sgblack@eecs.umich.eduMakeInclude('structures/TimerTable.hh')
1333576Sgblack@eecs.umich.eduMakeInclude('structures/WireBuffer.hh')
1343576Sgblack@eecs.umich.eduMakeInclude('system/DMASequencer.hh')
1352223SN/AMakeInclude('system/Sequencer.hh')
1363573Sgblack@eecs.umich.edu
1373576Sgblack@eecs.umich.edu# External types : Group "mem/protocol" : include "header.hh" to the bottom
1383576Sgblack@eecs.umich.edu# of this MakeIncludes if it is referenced as
1392223SN/A# <# include "mem/protocol/header.hh"> in any file
1403573Sgblack@eecs.umich.edu# generated_dir = Dir('../protocol')
1413576Sgblack@eecs.umich.eduMakeInclude('system/GPUCoalescer.hh')
1423576Sgblack@eecs.umich.eduMakeInclude('system/VIPERCoalescer.hh')
1432223SN/A