SConscript revision 10301
14762Snate@binkert.org# -*- mode:python -*- 24762Snate@binkert.org 34762Snate@binkert.org# Copyright (c) 2009 The Hewlett-Packard Development Company 44762Snate@binkert.org# All rights reserved. 54762Snate@binkert.org# 64762Snate@binkert.org# Redistribution and use in source and binary forms, with or without 74762Snate@binkert.org# modification, are permitted provided that the following conditions are 84762Snate@binkert.org# met: redistributions of source code must retain the above copyright 94762Snate@binkert.org# notice, this list of conditions and the following disclaimer; 104762Snate@binkert.org# redistributions in binary form must reproduce the above copyright 114762Snate@binkert.org# notice, this list of conditions and the following disclaimer in the 124762Snate@binkert.org# documentation and/or other materials provided with the distribution; 134762Snate@binkert.org# neither the name of the copyright holders nor the names of its 144762Snate@binkert.org# contributors may be used to endorse or promote products derived from 154762Snate@binkert.org# this software without specific prior written permission. 164762Snate@binkert.org# 174762Snate@binkert.org# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 184762Snate@binkert.org# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 194762Snate@binkert.org# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 204762Snate@binkert.org# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 214762Snate@binkert.org# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 224762Snate@binkert.org# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 234762Snate@binkert.org# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 244762Snate@binkert.org# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 254762Snate@binkert.org# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 264762Snate@binkert.org# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 274762Snate@binkert.org# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 284762Snate@binkert.org# 294762Snate@binkert.org# Authors: Nathan Binkert 304762Snate@binkert.org 314762Snate@binkert.orgimport os 324762Snate@binkert.orgimport sys 334762Snate@binkert.org 344762Snate@binkert.orgfrom os.path import basename, isdir, join as joinpath 35 36import SCons 37 38Import('*') 39 40DebugFlag('ProtocolTrace') 41DebugFlag('RubyCache') 42DebugFlag('RubyCacheTrace') 43DebugFlag('RubyDma') 44DebugFlag('RubyGenerated') 45DebugFlag('RubyMemory') 46DebugFlag('RubyNetwork') 47DebugFlag('RubyPort') 48DebugFlag('RubyPrefetcher') 49DebugFlag('RubyQueue') 50DebugFlag('RubySequencer') 51DebugFlag('RubySlicc') 52DebugFlag('RubySystem') 53DebugFlag('RubyTester') 54DebugFlag('RubyStats') 55DebugFlag('RubyResourceStalls') 56 57CompoundFlag('Ruby', [ 'RubyQueue', 'RubyNetwork', 'RubyTester', 58 'RubyGenerated', 'RubySlicc', 'RubySystem', 'RubyCache', 59 'RubyMemory', 'RubyDma', 'RubyPort', 'RubySequencer', 'RubyCacheTrace', 60 'RubyPrefetcher']) 61 62if env['TARGET_ISA'] == 'null': 63 Return() 64 65if env['PROTOCOL'] == 'None': 66 Return() 67 68def do_embed_text(target, source, env): 69 """convert a text file into a file that can be embedded in C 70 using an #include statement, that defines a \"const char *\" pointing 71 to the same text. 72 73 This is useful to embed scripts and configuration files in object files. 74 """ 75 76 escape = [ "\'", "\"", "\\", "\?" ] 77 78 # reads the text file in, line by line, converting it to a C string 79 fin = open(str(source[0]), 'r') 80 fout = open(str(target[0]), 'w' ) 81 fout.write("static const char *%s =\n" % source[1].get_contents()); 82 for l in fin: 83 # add escape sequences for the characters in escape 84 fout.write("\"") 85 for char in l: 86 if char == "\n": 87 break 88 if char in escape: 89 fout.write("\\") 90 fout.write(char) 91 else: 92 fout.write(char) 93 fout.write("\\n\"\n"); 94 fout.write(";\n"); 95 fin.close() 96 fout.close() 97 98# 99# Link includes 100# 101generated_dir = Dir('../protocol') 102 103def MakeIncludeAction(target, source, env): 104 f = file(str(target[0]), 'w') 105 for s in source: 106 print >>f, '#include "%s"' % str(s.abspath) 107 f.close() 108 109def MakeInclude(source): 110 target = generated_dir.File(basename(source)) 111 include_action = MakeAction(MakeIncludeAction, Transform("MAKE INC", 1)) 112 env.Command(target, source, include_action) 113 114MakeInclude('slicc_interface/AbstractEntry.hh') 115MakeInclude('slicc_interface/AbstractCacheEntry.hh') 116MakeInclude('slicc_interface/Message.hh') 117MakeInclude('slicc_interface/NetworkMessage.hh') 118MakeInclude('slicc_interface/RubyRequest.hh') 119 120# External types 121MakeInclude('common/Address.hh') 122MakeInclude('common/DataBlock.hh') 123MakeInclude('common/MachineID.hh') 124MakeInclude('common/NetDest.hh') 125MakeInclude('common/Set.hh') 126MakeInclude('filters/GenericBloomFilter.hh') 127MakeInclude('network/MessageBuffer.hh') 128MakeInclude('structures/Prefetcher.hh') 129MakeInclude('structures/CacheMemory.hh') 130MakeInclude('system/DMASequencer.hh') 131MakeInclude('structures/DirectoryMemory.hh') 132MakeInclude('structures/MemoryControl.hh') 133MakeInclude('structures/WireBuffer.hh') 134MakeInclude('structures/PerfectCacheMemory.hh') 135MakeInclude('structures/PersistentTable.hh') 136MakeInclude('system/Sequencer.hh') 137MakeInclude('structures/TBETable.hh') 138MakeInclude('structures/TimerTable.hh') 139