SConscript revision 6287:d60118c43d60
12155SN/A# -*- mode:python -*- 22155SN/A 32155SN/A# Copyright (c) 2009 The Hewlett-Packard Development Company 42155SN/A# All rights reserved. 52155SN/A# 62155SN/A# Redistribution and use in source and binary forms, with or without 72155SN/A# modification, are permitted provided that the following conditions are 82155SN/A# met: redistributions of source code must retain the above copyright 92155SN/A# notice, this list of conditions and the following disclaimer; 102155SN/A# redistributions in binary form must reproduce the above copyright 112155SN/A# notice, this list of conditions and the following disclaimer in the 122155SN/A# documentation and/or other materials provided with the distribution; 132155SN/A# neither the name of the copyright holders nor the names of its 142155SN/A# contributors may be used to endorse or promote products derived from 152155SN/A# this software without specific prior written permission. 162155SN/A# 172155SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 182155SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 192155SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 202155SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 212155SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 222155SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 232155SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 242155SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 252155SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 262155SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 272155SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 282665Ssaidi@eecs.umich.edu# 292665Ssaidi@eecs.umich.edu# Authors: Nathan Binkert 302155SN/A 312155SN/Aimport os 322155SN/Aimport re 332155SN/Aimport string 342155SN/Aimport sys 352155SN/A 362155SN/Afrom os.path import basename, dirname, exists, expanduser, isdir, isfile 372178SN/Afrom os.path import join as joinpath 382178SN/A 392178SN/Aimport SCons 402178SN/A 412178SN/AImport('*') 422178SN/A 432178SN/Aif not env['RUBY']: 442178SN/A Return() 452178SN/A 462178SN/Aslicc_dir = Dir('../slicc') 472178SN/Aprotocol_dir = Dir('.') 482178SN/Ahtml_dir = Dir('html') 492155SN/A 502178SN/A# 512155SN/A# Use SLICC 522155SN/A# 532178SN/Adef slicc_generator(target, source, env, for_signature): 542155SN/A slicc_bin = str(source[0]) 552155SN/A protocol = source[1].get_contents() 562623SN/A pdir = str(protocol_dir) 572623SN/A hdir = str(html_dir) 582623SN/A 592623SN/A if not isdir(pdir): 602623SN/A os.mkdir(pdir) 612155SN/A if not isdir(hdir): 622155SN/A os.mkdir(hdir) 632292SN/A 642292SN/A do_html = "no_html" 652292SN/A cmdline = [ slicc_bin, pdir, hdir, protocol, do_html ] 662292SN/A cmdline += [ str(s) for s in source[2:] ] 672292SN/A cmdline = ' '.join(cmdline) 682292SN/A return cmdline 692292SN/A 702292SN/Aslicc_builder = Builder(generator=slicc_generator) 712766Sktlim@umich.edu 722766Sktlim@umich.eduprotocol = env['PROTOCOL'] 732766Sktlim@umich.edusources = [ protocol_dir.File("RubySlicc_interfaces.slicc"), 742766Sktlim@umich.edu protocol_dir.File("%s.slicc" % protocol) ] 752766Sktlim@umich.edu 762766Sktlim@umich.edusys.path[0:0] = [env['ENV']['M5_PLY']] 772766Sktlim@umich.eduexecfile(slicc_dir.File('parser/parser.py').srcnode().abspath) 782178SN/A 792155SN/Asm_files = read_slicc([s.srcnode().abspath for s in sources]) 802155SN/Asm_files = [ protocol_dir.File(f) for f in sm_files ] 812155SN/A 822155SN/Ahh, cc = scan([s.srcnode().abspath for s in sm_files]) 832155SN/Ahh = [ protocol_dir.File(f) for f in hh ] 842155SN/Acc = [ protocol_dir.File(f) for f in cc ] 852766Sktlim@umich.edu 862155SN/Aslicc_bin = slicc_dir.File("slicc") 872623SN/A 882155SN/Aenv.Append(BUILDERS={'SLICC' : slicc_builder}) 892155SN/Aenv.SLICC(hh + cc, [ slicc_bin, Value(protocol) ] + sm_files) 902155SN/A 912155SN/Afor f in cc: 922178SN/A Source(f) 932178SN/A