SConscript revision 8092
112628Sodanrc@yahoo.com.br# -*- mode:python -*-
212628Sodanrc@yahoo.com.br
312628Sodanrc@yahoo.com.br# Copyright (c) 2009 The Hewlett-Packard Development Company
412628Sodanrc@yahoo.com.br# All rights reserved.
512628Sodanrc@yahoo.com.br#
612628Sodanrc@yahoo.com.br# Redistribution and use in source and binary forms, with or without
712628Sodanrc@yahoo.com.br# modification, are permitted provided that the following conditions are
812628Sodanrc@yahoo.com.br# met: redistributions of source code must retain the above copyright
912628Sodanrc@yahoo.com.br# notice, this list of conditions and the following disclaimer;
1012628Sodanrc@yahoo.com.br# redistributions in binary form must reproduce the above copyright
1112628Sodanrc@yahoo.com.br# notice, this list of conditions and the following disclaimer in the
1212628Sodanrc@yahoo.com.br# documentation and/or other materials provided with the distribution;
1312628Sodanrc@yahoo.com.br# neither the name of the copyright holders nor the names of its
1412628Sodanrc@yahoo.com.br# contributors may be used to endorse or promote products derived from
1512628Sodanrc@yahoo.com.br# this software without specific prior written permission.
1612628Sodanrc@yahoo.com.br#
1712628Sodanrc@yahoo.com.br# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1812628Sodanrc@yahoo.com.br# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1912628Sodanrc@yahoo.com.br# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2012628Sodanrc@yahoo.com.br# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2112628Sodanrc@yahoo.com.br# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2212628Sodanrc@yahoo.com.br# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2312628Sodanrc@yahoo.com.br# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2412628Sodanrc@yahoo.com.br# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2512628Sodanrc@yahoo.com.br# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2612628Sodanrc@yahoo.com.br# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2712628Sodanrc@yahoo.com.br# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2812628Sodanrc@yahoo.com.br#
2912628Sodanrc@yahoo.com.br# Authors: Nathan Binkert
3012628Sodanrc@yahoo.com.br
3112628Sodanrc@yahoo.com.brimport os
3212628Sodanrc@yahoo.com.brimport sys
3312628Sodanrc@yahoo.com.br
3412628Sodanrc@yahoo.com.brfrom os.path import basename, isdir, join as joinpath
3512628Sodanrc@yahoo.com.br
3612628Sodanrc@yahoo.com.brimport SCons
3712628Sodanrc@yahoo.com.br
3812628Sodanrc@yahoo.com.brImport('*')
3912628Sodanrc@yahoo.com.br
4012628Sodanrc@yahoo.com.brif env['TARGET_ISA'] == 'no':
4112628Sodanrc@yahoo.com.br    Return()
4212628Sodanrc@yahoo.com.br
4312628Sodanrc@yahoo.com.brif not env['RUBY']:
4412628Sodanrc@yahoo.com.br    Return()
4512628Sodanrc@yahoo.com.br
4612628Sodanrc@yahoo.com.brdef do_embed_text(target, source, env):
4712628Sodanrc@yahoo.com.br    """convert a text file into a file that can be embedded in C
4812628Sodanrc@yahoo.com.br    using an #include statement, that defines a \"const char *\" pointing
4912628Sodanrc@yahoo.com.br    to the same text.
5012628Sodanrc@yahoo.com.br
5112628Sodanrc@yahoo.com.br    This is useful to embed scripts and configuration files in object files.
5212628Sodanrc@yahoo.com.br    """
5312628Sodanrc@yahoo.com.br
5412628Sodanrc@yahoo.com.br    escape = [ "\'", "\"", "\\", "\?" ]
5512628Sodanrc@yahoo.com.br
5612628Sodanrc@yahoo.com.br    # reads the text file in, line by line, converting it to a C string
5712628Sodanrc@yahoo.com.br    fin = open(str(source[0]), 'r')
5812628Sodanrc@yahoo.com.br    fout = open(str(target[0]), 'w' )
5912628Sodanrc@yahoo.com.br    fout.write("static const char *%s =\n" % source[1].get_contents());
6012628Sodanrc@yahoo.com.br    for l in fin:
6112628Sodanrc@yahoo.com.br        # add escape sequences for the characters in escape
6212628Sodanrc@yahoo.com.br        fout.write("\"")
6312628Sodanrc@yahoo.com.br        for char in l:
6412628Sodanrc@yahoo.com.br            if char == "\n":
6512628Sodanrc@yahoo.com.br                break
6612628Sodanrc@yahoo.com.br            if char in escape:
6712628Sodanrc@yahoo.com.br                fout.write("\\")
6812628Sodanrc@yahoo.com.br                fout.write(char)
6912628Sodanrc@yahoo.com.br            else:
70                fout.write(char)
71        fout.write("\\n\"\n");
72    fout.write(";\n");
73    fin.close()
74    fout.close()
75
76#
77# Link includes
78#
79generated_dir = Dir('../protocol')
80
81def MakeIncludeAction(target, source, env):
82    f = file(str(target[0]), 'w')
83    for s in source:
84        print >>f, '#include "%s"' % str(s.abspath)
85    f.close()
86
87def MakeInclude(source):
88    target = generated_dir.File(basename(source))
89    env.Command(target, source, MakeIncludeAction)
90
91MakeInclude('slicc_interface/AbstractEntry.hh')
92MakeInclude('slicc_interface/AbstractCacheEntry.hh')
93MakeInclude('slicc_interface/AbstractProtocol.hh')
94MakeInclude('slicc_interface/Message.hh')
95MakeInclude('slicc_interface/NetworkMessage.hh')
96MakeInclude('slicc_interface/RubyRequest.hh')
97
98# External types
99MakeInclude('buffers/MessageBuffer.hh')
100MakeInclude('common/Address.hh')
101MakeInclude('common/DataBlock.hh')
102MakeInclude('common/NetDest.hh')
103MakeInclude('common/Set.hh')
104MakeInclude('filters/GenericBloomFilter.hh')
105MakeInclude('system/CacheMemory.hh')
106MakeInclude('system/DMASequencer.hh')
107MakeInclude('system/DirectoryMemory.hh')
108MakeInclude('system/MachineID.hh')
109MakeInclude('system/MemoryControl.hh')
110MakeInclude('system/NodeID.hh')
111MakeInclude('system/PerfectCacheMemory.hh')
112MakeInclude('system/PersistentTable.hh')
113MakeInclude('system/Sequencer.hh')
114MakeInclude('system/TBETable.hh')
115MakeInclude('system/TimerTable.hh')
116