SConscript revision 11210
16157Snate@binkert.org# -*- mode:python -*- 26157Snate@binkert.org 36157Snate@binkert.org# Copyright (c) 2009 The Hewlett-Packard Development Company 46157Snate@binkert.org# All rights reserved. 56157Snate@binkert.org# 66157Snate@binkert.org# Redistribution and use in source and binary forms, with or without 76157Snate@binkert.org# modification, are permitted provided that the following conditions are 86157Snate@binkert.org# met: redistributions of source code must retain the above copyright 96157Snate@binkert.org# notice, this list of conditions and the following disclaimer; 106157Snate@binkert.org# redistributions in binary form must reproduce the above copyright 116157Snate@binkert.org# notice, this list of conditions and the following disclaimer in the 126157Snate@binkert.org# documentation and/or other materials provided with the distribution; 136157Snate@binkert.org# neither the name of the copyright holders nor the names of its 146157Snate@binkert.org# contributors may be used to endorse or promote products derived from 156157Snate@binkert.org# this software without specific prior written permission. 166157Snate@binkert.org# 176157Snate@binkert.org# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 186157Snate@binkert.org# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 196157Snate@binkert.org# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 206157Snate@binkert.org# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 216157Snate@binkert.org# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 226157Snate@binkert.org# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 236157Snate@binkert.org# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 246157Snate@binkert.org# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 256157Snate@binkert.org# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 266157Snate@binkert.org# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 276157Snate@binkert.org# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 286157Snate@binkert.org# 296157Snate@binkert.org# Authors: Nathan Binkert 306157Snate@binkert.org 316157Snate@binkert.orgimport os 326157Snate@binkert.orgimport sys 336157Snate@binkert.org 346157Snate@binkert.orgfrom os.path import basename, isdir, join as joinpath 356157Snate@binkert.org 366157Snate@binkert.orgimport SCons 376157Snate@binkert.org 386157Snate@binkert.orgImport('*') 396157Snate@binkert.org 406168Snate@binkert.orgDebugFlag('ProtocolTrace') 416168Snate@binkert.orgDebugFlag('RubyCache') 426168Snate@binkert.orgDebugFlag('RubyCacheTrace') 436286Snate@binkert.orgDebugFlag('RubyDma') 446157Snate@binkert.orgDebugFlag('RubyGenerated') 456157Snate@binkert.orgDebugFlag('RubyMemory') 466157Snate@binkert.orgDebugFlag('RubyNetwork') 476157Snate@binkert.orgDebugFlag('RubyPort') 486157Snate@binkert.orgDebugFlag('RubyPrefetcher') 496157Snate@binkert.orgDebugFlag('RubyQueue') 506157Snate@binkert.orgDebugFlag('RubySequencer') 516157Snate@binkert.orgDebugFlag('RubySlicc') 526157Snate@binkert.orgDebugFlag('RubySystem') 536157Snate@binkert.orgDebugFlag('RubyTester') 546157Snate@binkert.orgDebugFlag('RubyStats') 556157Snate@binkert.orgDebugFlag('RubyResourceStalls') 566157Snate@binkert.org 576157Snate@binkert.orgCompoundFlag('Ruby', [ 'RubyQueue', 'RubyNetwork', 'RubyTester', 586157Snate@binkert.org 'RubyGenerated', 'RubySlicc', 'RubySystem', 'RubyCache', 596157Snate@binkert.org 'RubyMemory', 'RubyDma', 'RubyPort', 'RubySequencer', 'RubyCacheTrace', 606157Snate@binkert.org 'RubyPrefetcher']) 616157Snate@binkert.org 626157Snate@binkert.orgif env['PROTOCOL'] == 'None': 636157Snate@binkert.org Return() 646157Snate@binkert.org 656157Snate@binkert.orgdef do_embed_text(target, source, env): 666157Snate@binkert.org """convert a text file into a file that can be embedded in C 676157Snate@binkert.org using an #include statement, that defines a \"const char *\" pointing 686157Snate@binkert.org to the same text. 696157Snate@binkert.org 706157Snate@binkert.org This is useful to embed scripts and configuration files in object files. 716157Snate@binkert.org """ 726157Snate@binkert.org 736157Snate@binkert.org escape = [ "\'", "\"", "\\", "\?" ] 746157Snate@binkert.org 756157Snate@binkert.org # reads the text file in, line by line, converting it to a C string 766157Snate@binkert.org fin = open(str(source[0]), 'r') 776157Snate@binkert.org fout = open(str(target[0]), 'w' ) 786157Snate@binkert.org fout.write("static const char *%s =\n" % source[1].get_contents()); 796157Snate@binkert.org for l in fin: 806157Snate@binkert.org # add escape sequences for the characters in escape 816157Snate@binkert.org fout.write("\"") 826157Snate@binkert.org for char in l: 836157Snate@binkert.org if char == "\n": 846157Snate@binkert.org break 856157Snate@binkert.org if char in escape: 866157Snate@binkert.org fout.write("\\") 876157Snate@binkert.org fout.write(char) 886157Snate@binkert.org else: 896157Snate@binkert.org fout.write(char) 906157Snate@binkert.org fout.write("\\n\"\n"); 916157Snate@binkert.org fout.write(";\n"); 926157Snate@binkert.org fin.close() 936157Snate@binkert.org fout.close() 946157Snate@binkert.org 956157Snate@binkert.org# 966157Snate@binkert.org# Link includes 976157Snate@binkert.org# 986286Snate@binkert.orggenerated_dir = Dir('../protocol') 996286Snate@binkert.org 1006286Snate@binkert.orgdef MakeIncludeAction(target, source, env): 1016286Snate@binkert.org f = file(str(target[0]), 'w') 1026286Snate@binkert.org for s in source: 1036286Snate@binkert.org print >>f, '#include "%s"' % str(s.abspath) 1046157Snate@binkert.org f.close() 1056157Snate@binkert.org 1066157Snate@binkert.orgdef MakeInclude(source): 1076157Snate@binkert.org target = generated_dir.File(basename(source)) 1086157Snate@binkert.org include_action = MakeAction(MakeIncludeAction, Transform("MAKE INC", 1)) 1096286Snate@binkert.org env.Command(target, source, include_action) 1106157Snate@binkert.org 1116286Snate@binkert.orgMakeInclude('slicc_interface/AbstractEntry.hh') 1126157Snate@binkert.orgMakeInclude('slicc_interface/AbstractCacheEntry.hh') 1136157Snate@binkert.orgMakeInclude('slicc_interface/Message.hh') 1146157Snate@binkert.orgMakeInclude('slicc_interface/RubyRequest.hh') 1156157Snate@binkert.org 1166157Snate@binkert.org# External types 1176157Snate@binkert.orgMakeInclude('common/Address.hh') 1186157Snate@binkert.orgMakeInclude('common/BoolVec.hh') 1196157Snate@binkert.orgMakeInclude('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