SConscript revision 6286
18112Sgblack@eecs.umich.edu# -*- mode:python -*- 28112Sgblack@eecs.umich.edu 38112Sgblack@eecs.umich.edu# Copyright (c) 2009 The Hewlett-Packard Development Company 48112Sgblack@eecs.umich.edu# All rights reserved. 58112Sgblack@eecs.umich.edu# 68112Sgblack@eecs.umich.edu# Redistribution and use in source and binary forms, with or without 78112Sgblack@eecs.umich.edu# modification, are permitted provided that the following conditions are 88112Sgblack@eecs.umich.edu# met: redistributions of source code must retain the above copyright 98112Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer; 108112Sgblack@eecs.umich.edu# redistributions in binary form must reproduce the above copyright 118112Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer in the 128112Sgblack@eecs.umich.edu# documentation and/or other materials provided with the distribution; 138112Sgblack@eecs.umich.edu# neither the name of the copyright holders nor the names of its 148112Sgblack@eecs.umich.edu# contributors may be used to endorse or promote products derived from 158112Sgblack@eecs.umich.edu# this software without specific prior written permission. 168112Sgblack@eecs.umich.edu# 178112Sgblack@eecs.umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 188112Sgblack@eecs.umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 198112Sgblack@eecs.umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 208112Sgblack@eecs.umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 218112Sgblack@eecs.umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 228112Sgblack@eecs.umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 238112Sgblack@eecs.umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 248112Sgblack@eecs.umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 258112Sgblack@eecs.umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 268112Sgblack@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 278112Sgblack@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 288112Sgblack@eecs.umich.edu# 298112Sgblack@eecs.umich.edu# Authors: Nathan Binkert 308112Sgblack@eecs.umich.edu 318112Sgblack@eecs.umich.eduimport os 328112Sgblack@eecs.umich.eduimport sys 33 34from os.path import basename, isdir, join as joinpath 35 36import SCons 37 38Import('*') 39 40if not env['RUBY']: 41 Return() 42 43Source('libruby.cc') 44 45def do_embed_text(target, source, env): 46 """convert a text file into a file that can be embedded in C 47 using an #include statement, that defines a \"const char *\" pointing 48 to the same text. 49 50 This is useful to embed scripts and configuration files in object files. 51 """ 52 53 escape = [ "\'", "\"", "\\", "\?" ] 54 55 # reads the text file in, line by line, converting it to a C string 56 fin = open(str(source[0]), 'r') 57 fout = open(str(target[0]), 'w' ) 58 fout.write("static const char *%s =\n" % source[1].get_contents()); 59 for l in fin: 60 # add escape sequences for the characters in escape 61 fout.write("\"") 62 for char in l: 63 if char == "\n": 64 break 65 if char in escape: 66 fout.write("\\") 67 fout.write(char) 68 else: 69 fout.write(char) 70 fout.write("\\n\"\n"); 71 fout.write(";\n"); 72 fin.close() 73 fout.close() 74 75def EmbedText(target, source, param): 76 env.Command(target, [source, Value(param)], do_embed_text) 77 78EmbedText('default_param.hh', 'config/rubyconfig.defaults', 79 'global_default_param') 80EmbedText('tester_param.hh', 'config/tester.defaults', 81 'global_default_tester_param') 82 83# 84# Link includes 85# 86generated_dir = Dir('../protocol') 87 88def MakeIncludeAction(target, source, env): 89 f = file(str(target[0]), 'w') 90 for s in source: 91 print >>f, '#include "%s"' % str(s.abspath) 92 f.close() 93 94def MakeInclude(source): 95 target = generated_dir.File(basename(source)) 96 env.Command(target, source, MakeIncludeAction) 97 98MakeInclude('slicc_interface/AbstractCacheEntry.hh') 99MakeInclude('slicc_interface/AbstractProtocol.hh') 100MakeInclude('slicc_interface/Message.hh') 101MakeInclude('slicc_interface/NetworkMessage.hh') 102 103# External types 104MakeInclude('buffers/MessageBuffer.hh') 105MakeInclude('common/Address.hh') 106MakeInclude('common/DataBlock.hh') 107MakeInclude('common/NetDest.hh') 108MakeInclude('common/Set.hh') 109MakeInclude('filters/GenericBloomFilter.hh') 110MakeInclude('system/CacheMemory.hh') 111MakeInclude('system/DMASequencer.hh') 112MakeInclude('system/DirectoryMemory.hh') 113MakeInclude('system/MachineID.hh') 114MakeInclude('system/MemoryControl.hh') 115MakeInclude('system/NodeID.hh') 116MakeInclude('system/PerfectCacheMemory.hh') 117MakeInclude('system/Sequencer.hh') 118MakeInclude('system/TBETable.hh') 119MakeInclude('system/TimerTable.hh') 120