SConscript revision 8492:1ad244a20877
15390SN/A# -*- mode:python -*-
25390SN/A
35390SN/A# Copyright (c) 2009 The Hewlett-Packard Development Company
45390SN/A# All rights reserved.
55390SN/A#
65390SN/A# Redistribution and use in source and binary forms, with or without
75390SN/A# modification, are permitted provided that the following conditions are
85390SN/A# met: redistributions of source code must retain the above copyright
95390SN/A# notice, this list of conditions and the following disclaimer;
105390SN/A# redistributions in binary form must reproduce the above copyright
115390SN/A# notice, this list of conditions and the following disclaimer in the
125390SN/A# documentation and/or other materials provided with the distribution;
135390SN/A# neither the name of the copyright holders nor the names of its
145390SN/A# contributors may be used to endorse or promote products derived from
155390SN/A# this software without specific prior written permission.
165390SN/A#
175390SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
185390SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
195390SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
205390SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
215390SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
225390SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
235390SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
245390SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
255390SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
265390SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
275390SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
285390SN/A#
295390SN/A# Authors: Nathan Binkert
305390SN/A
315631Sgblack@eecs.umich.eduimport os
325630Sgblack@eecs.umich.eduimport sys
335390SN/A
345390SN/Afrom os.path import basename, isdir, join as joinpath
355390SN/A
365390SN/Aimport SCons
375631Sgblack@eecs.umich.edu
385631Sgblack@eecs.umich.eduImport('*')
395631Sgblack@eecs.umich.edu
405631Sgblack@eecs.umich.eduif env['TARGET_ISA'] == 'no':
415631Sgblack@eecs.umich.edu    Return()
425631Sgblack@eecs.umich.edu
435631Sgblack@eecs.umich.eduif env['PROTOCOL'] == 'None':
445631Sgblack@eecs.umich.edu    Return()
455631Sgblack@eecs.umich.edu
465631Sgblack@eecs.umich.edudef do_embed_text(target, source, env):
475631Sgblack@eecs.umich.edu    """convert a text file into a file that can be embedded in C
485631Sgblack@eecs.umich.edu    using an #include statement, that defines a \"const char *\" pointing
495631Sgblack@eecs.umich.edu    to the same text.
505631Sgblack@eecs.umich.edu
515631Sgblack@eecs.umich.edu    This is useful to embed scripts and configuration files in object files.
525631Sgblack@eecs.umich.edu    """
535631Sgblack@eecs.umich.edu
545630Sgblack@eecs.umich.edu    escape = [ "\'", "\"", "\\", "\?" ]
555390SN/A
565390SN/A    # reads the text file in, line by line, converting it to a C string
575390SN/A    fin = open(str(source[0]), 'r')
585390SN/A    fout = open(str(target[0]), 'w' )
595390SN/A    fout.write("static const char *%s =\n" % source[1].get_contents());
605631Sgblack@eecs.umich.edu    for l in fin:
615631Sgblack@eecs.umich.edu        # add escape sequences for the characters in escape
625631Sgblack@eecs.umich.edu        fout.write("\"")
635631Sgblack@eecs.umich.edu        for char in l:
645631Sgblack@eecs.umich.edu            if char == "\n":
655631Sgblack@eecs.umich.edu                break
665631Sgblack@eecs.umich.edu            if char in escape:
675631Sgblack@eecs.umich.edu                fout.write("\\")
685631Sgblack@eecs.umich.edu                fout.write(char)
695631Sgblack@eecs.umich.edu            else:
705631Sgblack@eecs.umich.edu                fout.write(char)
715631Sgblack@eecs.umich.edu        fout.write("\\n\"\n");
725631Sgblack@eecs.umich.edu    fout.write(";\n");
735631Sgblack@eecs.umich.edu    fin.close()
745631Sgblack@eecs.umich.edu    fout.close()
755631Sgblack@eecs.umich.edu
765631Sgblack@eecs.umich.edu#
775631Sgblack@eecs.umich.edu# Link includes
785631Sgblack@eecs.umich.edu#
795631Sgblack@eecs.umich.edugenerated_dir = Dir('../protocol')
805631Sgblack@eecs.umich.edu
815631Sgblack@eecs.umich.edudef MakeIncludeAction(target, source, env):
825631Sgblack@eecs.umich.edu    f = file(str(target[0]), 'w')
835631Sgblack@eecs.umich.edu    for s in source:
845631Sgblack@eecs.umich.edu        print >>f, '#include "%s"' % str(s.abspath)
855631Sgblack@eecs.umich.edu    f.close()
865631Sgblack@eecs.umich.edu
875631Sgblack@eecs.umich.edudef MakeInclude(source):
885631Sgblack@eecs.umich.edu    target = generated_dir.File(basename(source))
895631Sgblack@eecs.umich.edu    include_action = MakeAction(MakeIncludeAction, Transform("MAKE INC", 1))
905631Sgblack@eecs.umich.edu    env.Command(target, source, include_action)
915631Sgblack@eecs.umich.edu
925631Sgblack@eecs.umich.eduMakeInclude('slicc_interface/AbstractEntry.hh')
935631Sgblack@eecs.umich.eduMakeInclude('slicc_interface/AbstractCacheEntry.hh')
945631Sgblack@eecs.umich.eduMakeInclude('slicc_interface/AbstractProtocol.hh')
955631Sgblack@eecs.umich.eduMakeInclude('slicc_interface/Message.hh')
965631Sgblack@eecs.umich.eduMakeInclude('slicc_interface/NetworkMessage.hh')
975631Sgblack@eecs.umich.eduMakeInclude('slicc_interface/RubyRequest.hh')
985631Sgblack@eecs.umich.edu
995631Sgblack@eecs.umich.edu# External types
1005631Sgblack@eecs.umich.eduMakeInclude('buffers/MessageBuffer.hh')
1015631Sgblack@eecs.umich.eduMakeInclude('common/Address.hh')
1025631Sgblack@eecs.umich.eduMakeInclude('common/DataBlock.hh')
1035631Sgblack@eecs.umich.eduMakeInclude('common/NetDest.hh')
1045631Sgblack@eecs.umich.eduMakeInclude('common/Set.hh')
1055631Sgblack@eecs.umich.eduMakeInclude('filters/GenericBloomFilter.hh')
1065631Sgblack@eecs.umich.eduMakeInclude('system/CacheMemory.hh')
1075631Sgblack@eecs.umich.eduMakeInclude('system/DMASequencer.hh')
1085631Sgblack@eecs.umich.eduMakeInclude('system/DirectoryMemory.hh')
1095631Sgblack@eecs.umich.eduMakeInclude('system/MachineID.hh')
1105631Sgblack@eecs.umich.eduMakeInclude('system/MemoryControl.hh')
1115631Sgblack@eecs.umich.eduMakeInclude('system/WireBuffer.hh')
1125631Sgblack@eecs.umich.eduMakeInclude('system/NodeID.hh')
1135631Sgblack@eecs.umich.eduMakeInclude('system/PerfectCacheMemory.hh')
1145631Sgblack@eecs.umich.eduMakeInclude('system/PersistentTable.hh')
1155631Sgblack@eecs.umich.eduMakeInclude('system/Sequencer.hh')
1165631Sgblack@eecs.umich.eduMakeInclude('system/TBETable.hh')
1175631Sgblack@eecs.umich.eduMakeInclude('system/TimerTable.hh')
1185631Sgblack@eecs.umich.edu