SConscript revision 11210:64c0ebeae224
17119Sgblack@eecs.umich.edu# -*- mode:python -*- 27119Sgblack@eecs.umich.edu 37120Sgblack@eecs.umich.edu# Copyright (c) 2009 The Hewlett-Packard Development Company 47120Sgblack@eecs.umich.edu# All rights reserved. 57120Sgblack@eecs.umich.edu# 67120Sgblack@eecs.umich.edu# Redistribution and use in source and binary forms, with or without 77120Sgblack@eecs.umich.edu# modification, are permitted provided that the following conditions are 87120Sgblack@eecs.umich.edu# met: redistributions of source code must retain the above copyright 97120Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer; 107120Sgblack@eecs.umich.edu# redistributions in binary form must reproduce the above copyright 117120Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer in the 127120Sgblack@eecs.umich.edu# documentation and/or other materials provided with the distribution; 137120Sgblack@eecs.umich.edu# neither the name of the copyright holders nor the names of its 147120Sgblack@eecs.umich.edu# contributors may be used to endorse or promote products derived from 157119Sgblack@eecs.umich.edu# this software without specific prior written permission. 167119Sgblack@eecs.umich.edu# 177119Sgblack@eecs.umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 187119Sgblack@eecs.umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 197119Sgblack@eecs.umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 207119Sgblack@eecs.umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 217119Sgblack@eecs.umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 227119Sgblack@eecs.umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 237119Sgblack@eecs.umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 247119Sgblack@eecs.umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 257119Sgblack@eecs.umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 267119Sgblack@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 277119Sgblack@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 287119Sgblack@eecs.umich.edu# 297119Sgblack@eecs.umich.edu# Authors: Nathan Binkert 307119Sgblack@eecs.umich.edu 317119Sgblack@eecs.umich.eduimport os 327119Sgblack@eecs.umich.eduimport sys 337119Sgblack@eecs.umich.edu 347119Sgblack@eecs.umich.edufrom os.path import basename, isdir, join as joinpath 357119Sgblack@eecs.umich.edu 367119Sgblack@eecs.umich.eduimport SCons 377119Sgblack@eecs.umich.edu 387119Sgblack@eecs.umich.eduImport('*') 397119Sgblack@eecs.umich.edu 407119Sgblack@eecs.umich.eduDebugFlag('ProtocolTrace') 417119Sgblack@eecs.umich.eduDebugFlag('RubyCache') 427119Sgblack@eecs.umich.eduDebugFlag('RubyCacheTrace') 437119Sgblack@eecs.umich.eduDebugFlag('RubyDma') 447205Sgblack@eecs.umich.eduDebugFlag('RubyGenerated') 457205Sgblack@eecs.umich.eduDebugFlag('RubyMemory') 467205Sgblack@eecs.umich.eduDebugFlag('RubyNetwork') 477205Sgblack@eecs.umich.eduDebugFlag('RubyPort') 487205Sgblack@eecs.umich.eduDebugFlag('RubyPrefetcher') 497205Sgblack@eecs.umich.eduDebugFlag('RubyQueue') 507205Sgblack@eecs.umich.eduDebugFlag('RubySequencer') 517205Sgblack@eecs.umich.eduDebugFlag('RubySlicc') 527205Sgblack@eecs.umich.eduDebugFlag('RubySystem') 537205Sgblack@eecs.umich.eduDebugFlag('RubyTester') 547205Sgblack@eecs.umich.eduDebugFlag('RubyStats') 557205Sgblack@eecs.umich.eduDebugFlag('RubyResourceStalls') 567205Sgblack@eecs.umich.edu 577205Sgblack@eecs.umich.eduCompoundFlag('Ruby', [ 'RubyQueue', 'RubyNetwork', 'RubyTester', 587205Sgblack@eecs.umich.edu 'RubyGenerated', 'RubySlicc', 'RubySystem', 'RubyCache', 597205Sgblack@eecs.umich.edu 'RubyMemory', 'RubyDma', 'RubyPort', 'RubySequencer', 'RubyCacheTrace', 607205Sgblack@eecs.umich.edu 'RubyPrefetcher']) 617205Sgblack@eecs.umich.edu 627205Sgblack@eecs.umich.eduif env['PROTOCOL'] == 'None': 637205Sgblack@eecs.umich.edu Return() 647205Sgblack@eecs.umich.edu 657205Sgblack@eecs.umich.edudef do_embed_text(target, source, env): 667205Sgblack@eecs.umich.edu """convert a text file into a file that can be embedded in C 677205Sgblack@eecs.umich.edu using an #include statement, that defines a \"const char *\" pointing 687205Sgblack@eecs.umich.edu to the same text. 697205Sgblack@eecs.umich.edu 707205Sgblack@eecs.umich.edu This is useful to embed scripts and configuration files in object files. 717205Sgblack@eecs.umich.edu """ 727205Sgblack@eecs.umich.edu 737205Sgblack@eecs.umich.edu escape = [ "\'", "\"", "\\", "\?" ] 747205Sgblack@eecs.umich.edu 757205Sgblack@eecs.umich.edu # reads the text file in, line by line, converting it to a C string 767205Sgblack@eecs.umich.edu fin = open(str(source[0]), 'r') 777205Sgblack@eecs.umich.edu fout = open(str(target[0]), 'w' ) 787205Sgblack@eecs.umich.edu fout.write("static const char *%s =\n" % source[1].get_contents()); 797205Sgblack@eecs.umich.edu for l in fin: 807205Sgblack@eecs.umich.edu # add escape sequences for the characters in escape 817205Sgblack@eecs.umich.edu fout.write("\"") 827205Sgblack@eecs.umich.edu for char in l: 837205Sgblack@eecs.umich.edu if char == "\n": 847205Sgblack@eecs.umich.edu break 857205Sgblack@eecs.umich.edu if char in escape: 867205Sgblack@eecs.umich.edu fout.write("\\") 877205Sgblack@eecs.umich.edu fout.write(char) 887205Sgblack@eecs.umich.edu else: 897205Sgblack@eecs.umich.edu fout.write(char) 907205Sgblack@eecs.umich.edu fout.write("\\n\"\n"); 917205Sgblack@eecs.umich.edu fout.write(";\n"); 927205Sgblack@eecs.umich.edu fin.close() 937205Sgblack@eecs.umich.edu fout.close() 947205Sgblack@eecs.umich.edu 957205Sgblack@eecs.umich.edu# 967205Sgblack@eecs.umich.edu# Link includes 977205Sgblack@eecs.umich.edu# 987205Sgblack@eecs.umich.edugenerated_dir = Dir('../protocol') 997205Sgblack@eecs.umich.edu 1007205Sgblack@eecs.umich.edudef MakeIncludeAction(target, source, env): 1017205Sgblack@eecs.umich.edu f = file(str(target[0]), 'w') 1027205Sgblack@eecs.umich.edu for s in source: 1037205Sgblack@eecs.umich.edu print >>f, '#include "%s"' % str(s.abspath) 1047205Sgblack@eecs.umich.edu f.close() 1057205Sgblack@eecs.umich.edu 1067205Sgblack@eecs.umich.edudef MakeInclude(source): 1077205Sgblack@eecs.umich.edu target = generated_dir.File(basename(source)) 1087205Sgblack@eecs.umich.edu include_action = MakeAction(MakeIncludeAction, Transform("MAKE INC", 1)) 1097205Sgblack@eecs.umich.edu env.Command(target, source, include_action) 1107205Sgblack@eecs.umich.edu 1117205Sgblack@eecs.umich.eduMakeInclude('slicc_interface/AbstractEntry.hh') 1127205Sgblack@eecs.umich.eduMakeInclude('slicc_interface/AbstractCacheEntry.hh') 1137205Sgblack@eecs.umich.eduMakeInclude('slicc_interface/Message.hh') 1147205Sgblack@eecs.umich.eduMakeInclude('slicc_interface/RubyRequest.hh') 1157205Sgblack@eecs.umich.edu 1167205Sgblack@eecs.umich.edu# External types 1177205Sgblack@eecs.umich.eduMakeInclude('common/Address.hh') 1187205Sgblack@eecs.umich.eduMakeInclude('common/BoolVec.hh') 1197205Sgblack@eecs.umich.eduMakeInclude('common/DataBlock.hh') 1207205Sgblack@eecs.umich.eduMakeInclude('common/IntVec.hh') 1217205Sgblack@eecs.umich.eduMakeInclude('common/MachineID.hh') 1227205Sgblack@eecs.umich.eduMakeInclude('common/NetDest.hh') 1237205Sgblack@eecs.umich.eduMakeInclude('common/Set.hh') 1247205Sgblack@eecs.umich.eduMakeInclude('filters/AbstractBloomFilter.hh') 1257205Sgblack@eecs.umich.eduMakeInclude('network/MessageBuffer.hh') 1267205Sgblack@eecs.umich.eduMakeInclude('structures/Prefetcher.hh') 1277205Sgblack@eecs.umich.eduMakeInclude('structures/CacheMemory.hh') 1287205Sgblack@eecs.umich.eduMakeInclude('system/DMASequencer.hh') 1297205Sgblack@eecs.umich.eduMakeInclude('structures/DirectoryMemory.hh') 1307205Sgblack@eecs.umich.eduMakeInclude('structures/WireBuffer.hh') 1317205Sgblack@eecs.umich.eduMakeInclude('structures/PerfectCacheMemory.hh') 1327205Sgblack@eecs.umich.eduMakeInclude('structures/PersistentTable.hh') 1337205Sgblack@eecs.umich.eduMakeInclude('system/Sequencer.hh') 1347119Sgblack@eecs.umich.eduMakeInclude('structures/TBETable.hh') 1357119Sgblack@eecs.umich.eduMakeInclude('structures/TimerTable.hh') 1367119Sgblack@eecs.umich.edu