SConscript revision 12892
1955SN/A# -*- mode:python -*-
2955SN/A
31762SN/A# Copyright (c) 2009 The Hewlett-Packard Development Company
4955SN/A# All rights reserved.
5955SN/A#
6955SN/A# Redistribution and use in source and binary forms, with or without
7955SN/A# modification, are permitted provided that the following conditions are
8955SN/A# met: redistributions of source code must retain the above copyright
9955SN/A# notice, this list of conditions and the following disclaimer;
10955SN/A# redistributions in binary form must reproduce the above copyright
11955SN/A# notice, this list of conditions and the following disclaimer in the
12955SN/A# documentation and/or other materials provided with the distribution;
13955SN/A# neither the name of the copyright holders nor the names of its
14955SN/A# contributors may be used to endorse or promote products derived from
15955SN/A# this software without specific prior written permission.
16955SN/A#
17955SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18955SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19955SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20955SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21955SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22955SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23955SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24955SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25955SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26955SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27955SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
282665Ssaidi@eecs.umich.edu#
294762Snate@binkert.org# Authors: Nathan Binkert
30955SN/A
315522Snate@binkert.orgfrom __future__ import print_function
324762Snate@binkert.org
335522Snate@binkert.orgimport os
34955SN/Aimport sys
355522Snate@binkert.org
36955SN/Afrom os.path import basename, isdir, join as joinpath
375522Snate@binkert.org
384202Sbinkertn@umich.eduimport SCons
395342Sstever@gmail.com
40955SN/Afrom gem5_scons import Transform
414381Sbinkertn@umich.edu
424381Sbinkertn@umich.eduImport('*')
43955SN/A
44955SN/Aif env['PROTOCOL'] == 'None':
45955SN/A    Return()
464202Sbinkertn@umich.edu
47955SN/ADebugFlag('ProtocolTrace')
484382Sbinkertn@umich.eduDebugFlag('RubyCache')
494382Sbinkertn@umich.eduDebugFlag('RubyCacheTrace')
504382Sbinkertn@umich.eduDebugFlag('RubyDma')
515517Snate@binkert.orgDebugFlag('RubyGenerated')
525517Snate@binkert.orgDebugFlag('RubyNetwork')
534762Snate@binkert.orgDebugFlag('RubyPort')
544762Snate@binkert.orgDebugFlag('RubyPrefetcher')
554762Snate@binkert.orgDebugFlag('RubyQueue')
564762Snate@binkert.orgDebugFlag('RubySequencer')
574762Snate@binkert.orgDebugFlag('RubySlicc')
584762Snate@binkert.orgDebugFlag('RubySystem')
594762Snate@binkert.orgDebugFlag('RubyTester')
604762Snate@binkert.orgDebugFlag('RubyStats')
614762Snate@binkert.orgDebugFlag('RubyResourceStalls')
624762Snate@binkert.org
635522Snate@binkert.orgCompoundFlag('Ruby', [ 'RubyQueue', 'RubyNetwork', 'RubyTester',
645604Snate@binkert.org    'RubyGenerated', 'RubySlicc', 'RubySystem', 'RubyCache',
655604Snate@binkert.org    'RubyDma', 'RubyPort', 'RubySequencer', 'RubyCacheTrace',
665604Snate@binkert.org    'RubyPrefetcher'])
674762Snate@binkert.org
684762Snate@binkert.orgdef do_embed_text(target, source, env):
694762Snate@binkert.org    """convert a text file into a file that can be embedded in C
705522Snate@binkert.org    using an #include statement, that defines a \"const char *\" pointing
715522Snate@binkert.org    to the same text.
725522Snate@binkert.org
735522Snate@binkert.org    This is useful to embed scripts and configuration files in object files.
745604Snate@binkert.org    """
755604Snate@binkert.org
764762Snate@binkert.org    escape = [ "\'", "\"", "\\", "\?" ]
774762Snate@binkert.org
784762Snate@binkert.org    # reads the text file in, line by line, converting it to a C string
794762Snate@binkert.org    fin = open(str(source[0]), 'r')
805522Snate@binkert.org    fout = open(str(target[0]), 'w' )
814762Snate@binkert.org    fout.write("static const char *%s =\n" % source[1].get_contents());
824762Snate@binkert.org    for l in fin:
835604Snate@binkert.org        # add escape sequences for the characters in escape
845604Snate@binkert.org        fout.write("\"")
855604Snate@binkert.org        for char in l:
865604Snate@binkert.org            if char == "\n":
875604Snate@binkert.org                break
885604Snate@binkert.org            if char in escape:
894762Snate@binkert.org                fout.write("\\")
904762Snate@binkert.org                fout.write(char)
914762Snate@binkert.org            else:
924762Snate@binkert.org                fout.write(char)
935604Snate@binkert.org        fout.write("\\n\"\n");
944762Snate@binkert.org    fout.write(";\n");
955522Snate@binkert.org    fin.close()
965522Snate@binkert.org    fout.close()
975522Snate@binkert.org
984762Snate@binkert.org#
994382Sbinkertn@umich.edu# Link includes
1004762Snate@binkert.org#
1014382Sbinkertn@umich.edugenerated_dir = Dir('../protocol')
1025522Snate@binkert.org
1034381Sbinkertn@umich.edudef MakeIncludeAction(target, source, env):
1045522Snate@binkert.org    f = file(str(target[0]), 'w')
1054762Snate@binkert.org    for s in source:
1064762Snate@binkert.org        print('#include "%s"' % str(s.abspath), file=f)
1074762Snate@binkert.org    f.close()
1085522Snate@binkert.org
1095522Snate@binkert.orgdef MakeInclude(source):
1105522Snate@binkert.org    target = generated_dir.File(basename(source))
1115522Snate@binkert.org    include_action = MakeAction(MakeIncludeAction, Transform("MAKE INC", 1))
1125522Snate@binkert.org    env.Command(target, source, include_action)
1135522Snate@binkert.org
1145522Snate@binkert.orgMakeInclude('slicc_interface/AbstractEntry.hh')
1155522Snate@binkert.orgMakeInclude('slicc_interface/AbstractCacheEntry.hh')
1165522Snate@binkert.orgMakeInclude('slicc_interface/Message.hh')
1174762Snate@binkert.orgMakeInclude('slicc_interface/RubyRequest.hh')
1184762Snate@binkert.org
1194762Snate@binkert.org# External types
1204762Snate@binkert.orgMakeInclude('common/Address.hh')
1214762Snate@binkert.orgMakeInclude('common/BoolVec.hh')
1224762Snate@binkert.orgMakeInclude('common/DataBlock.hh')
1234762Snate@binkert.orgMakeInclude('common/IntVec.hh')
1244762Snate@binkert.orgMakeInclude('common/MachineID.hh')
1254762Snate@binkert.orgMakeInclude('common/NetDest.hh')
1264762Snate@binkert.orgMakeInclude('common/Set.hh')
1274762Snate@binkert.orgMakeInclude('common/WriteMask.hh')
1284762Snate@binkert.orgMakeInclude('filters/AbstractBloomFilter.hh')
1294762Snate@binkert.orgMakeInclude('network/MessageBuffer.hh')
1304762Snate@binkert.orgMakeInclude('structures/CacheMemory.hh')
1314762Snate@binkert.orgMakeInclude('structures/DirectoryMemory.hh')
1324762Snate@binkert.orgMakeInclude('structures/PerfectCacheMemory.hh')
1334762Snate@binkert.orgMakeInclude('structures/PersistentTable.hh')
1344762Snate@binkert.orgMakeInclude('structures/Prefetcher.hh')
1354762Snate@binkert.orgMakeInclude('structures/TBETable.hh')
1364762Snate@binkert.orgMakeInclude('structures/TimerTable.hh')
1374762Snate@binkert.orgMakeInclude('structures/WireBuffer.hh')
1384762Snate@binkert.orgMakeInclude('system/DMASequencer.hh')
1394762Snate@binkert.orgMakeInclude('system/Sequencer.hh')
1404762Snate@binkert.org
1414762Snate@binkert.org# External types : Group "mem/protocol" : include "header.hh" to the bottom
1424762Snate@binkert.org# of this MakeIncludes if it is referenced as
1434762Snate@binkert.org# <# include "mem/protocol/header.hh"> in any file
1444762Snate@binkert.org# generated_dir = Dir('../protocol')
1454762Snate@binkert.orgMakeInclude('system/GPUCoalescer.hh')
1464762Snate@binkert.orgMakeInclude('system/VIPERCoalescer.hh')
1474762Snate@binkert.org