SConscript revision 11210:64c0ebeae224
12931Sktlim@umich.edu# -*- mode:python -*- 22931Sktlim@umich.edu 32931Sktlim@umich.edu# Copyright (c) 2009 The Hewlett-Packard Development Company 42931Sktlim@umich.edu# All rights reserved. 52931Sktlim@umich.edu# 62931Sktlim@umich.edu# Redistribution and use in source and binary forms, with or without 72931Sktlim@umich.edu# modification, are permitted provided that the following conditions are 82931Sktlim@umich.edu# met: redistributions of source code must retain the above copyright 92931Sktlim@umich.edu# notice, this list of conditions and the following disclaimer; 102931Sktlim@umich.edu# redistributions in binary form must reproduce the above copyright 112931Sktlim@umich.edu# notice, this list of conditions and the following disclaimer in the 122931Sktlim@umich.edu# documentation and/or other materials provided with the distribution; 132931Sktlim@umich.edu# neither the name of the copyright holders nor the names of its 142931Sktlim@umich.edu# contributors may be used to endorse or promote products derived from 152931Sktlim@umich.edu# this software without specific prior written permission. 162931Sktlim@umich.edu# 172931Sktlim@umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 182931Sktlim@umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 192931Sktlim@umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 202931Sktlim@umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 212931Sktlim@umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 222931Sktlim@umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 232931Sktlim@umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 242931Sktlim@umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 252931Sktlim@umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 262931Sktlim@umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 272931Sktlim@umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 282931Sktlim@umich.edu# 292774SN/A# Authors: Nathan Binkert 302774SN/A 312774SN/Aimport os 322566SN/Aimport sys 333510Shsul@eecs.umich.edu 343510Shsul@eecs.umich.edufrom os.path import basename, isdir, join as joinpath 353510Shsul@eecs.umich.edu 3610681Ssteve.reinhardt@amd.comimport SCons 3710681Ssteve.reinhardt@amd.com 3810681Ssteve.reinhardt@amd.comImport('*') 3910681Ssteve.reinhardt@amd.com 4010681Ssteve.reinhardt@amd.comDebugFlag('ProtocolTrace') 4110681Ssteve.reinhardt@amd.comDebugFlag('RubyCache') 4210681Ssteve.reinhardt@amd.comDebugFlag('RubyCacheTrace') 432902SN/ADebugFlag('RubyDma') 442902SN/ADebugFlag('RubyGenerated') 4510681Ssteve.reinhardt@amd.comDebugFlag('RubyMemory') 462566SN/ADebugFlag('RubyNetwork') 472902SN/ADebugFlag('RubyPort') 482902SN/ADebugFlag('RubyPrefetcher') 4910681Ssteve.reinhardt@amd.comDebugFlag('RubyQueue') 502902SN/ADebugFlag('RubySequencer') 512902SN/ADebugFlag('RubySlicc') 522902SN/ADebugFlag('RubySystem') 5310681Ssteve.reinhardt@amd.comDebugFlag('RubyTester') 542902SN/ADebugFlag('RubyStats') 552902SN/ADebugFlag('RubyResourceStalls') 5610681Ssteve.reinhardt@amd.com 572774SN/ACompoundFlag('Ruby', [ 'RubyQueue', 'RubyNetwork', 'RubyTester', 5810681Ssteve.reinhardt@amd.com 'RubyGenerated', 'RubySlicc', 'RubySystem', 'RubyCache', 592774SN/A 'RubyMemory', 'RubyDma', 'RubyPort', 'RubySequencer', 'RubyCacheTrace', 6010681Ssteve.reinhardt@amd.com 'RubyPrefetcher']) 612566SN/A 6210681Ssteve.reinhardt@amd.comif env['PROTOCOL'] == 'None': 6310681Ssteve.reinhardt@amd.com Return() 642566SN/A 6510681Ssteve.reinhardt@amd.comdef do_embed_text(target, source, env): 6610681Ssteve.reinhardt@amd.com """convert a text file into a file that can be embedded in C 672566SN/A using an #include statement, that defines a \"const char *\" pointing 6810681Ssteve.reinhardt@amd.com to the same text. 6910681Ssteve.reinhardt@amd.com 7010681Ssteve.reinhardt@amd.com This is useful to embed scripts and configuration files in object files. 7110681Ssteve.reinhardt@amd.com """ 7210681Ssteve.reinhardt@amd.com 7310681Ssteve.reinhardt@amd.com escape = [ "\'", "\"", "\\", "\?" ] 7410681Ssteve.reinhardt@amd.com 7510681Ssteve.reinhardt@amd.com # reads the text file in, line by line, converting it to a C string 7610681Ssteve.reinhardt@amd.com fin = open(str(source[0]), 'r') 7710681Ssteve.reinhardt@amd.com fout = open(str(target[0]), 'w' ) 7810681Ssteve.reinhardt@amd.com fout.write("static const char *%s =\n" % source[1].get_contents()); 79 for l in fin: 80 # add escape sequences for the characters in escape 81 fout.write("\"") 82 for char in l: 83 if char == "\n": 84 break 85 if char in escape: 86 fout.write("\\") 87 fout.write(char) 88 else: 89 fout.write(char) 90 fout.write("\\n\"\n"); 91 fout.write(";\n"); 92 fin.close() 93 fout.close() 94 95# 96# Link includes 97# 98generated_dir = Dir('../protocol') 99 100def MakeIncludeAction(target, source, env): 101 f = file(str(target[0]), 'w') 102 for s in source: 103 print >>f, '#include "%s"' % str(s.abspath) 104 f.close() 105 106def MakeInclude(source): 107 target = generated_dir.File(basename(source)) 108 include_action = MakeAction(MakeIncludeAction, Transform("MAKE INC", 1)) 109 env.Command(target, source, include_action) 110 111MakeInclude('slicc_interface/AbstractEntry.hh') 112MakeInclude('slicc_interface/AbstractCacheEntry.hh') 113MakeInclude('slicc_interface/Message.hh') 114MakeInclude('slicc_interface/RubyRequest.hh') 115 116# External types 117MakeInclude('common/Address.hh') 118MakeInclude('common/BoolVec.hh') 119MakeInclude('common/DataBlock.hh') 120MakeInclude('common/IntVec.hh') 121MakeInclude('common/MachineID.hh') 122MakeInclude('common/NetDest.hh') 123MakeInclude('common/Set.hh') 124MakeInclude('filters/AbstractBloomFilter.hh') 125MakeInclude('network/MessageBuffer.hh') 126MakeInclude('structures/Prefetcher.hh') 127MakeInclude('structures/CacheMemory.hh') 128MakeInclude('system/DMASequencer.hh') 129MakeInclude('structures/DirectoryMemory.hh') 130MakeInclude('structures/WireBuffer.hh') 131MakeInclude('structures/PerfectCacheMemory.hh') 132MakeInclude('structures/PersistentTable.hh') 133MakeInclude('system/Sequencer.hh') 134MakeInclude('structures/TBETable.hh') 135MakeInclude('structures/TimerTable.hh') 136