SConscript revision 6655:380a32b43336
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.orgimport os 326143Snate@binkert.orgimport re 334762Snate@binkert.orgimport string 345522Snate@binkert.orgimport sys 35955SN/A 365522Snate@binkert.orgfrom os.path import basename, dirname, exists, expanduser, isdir, isfile 37955SN/Afrom os.path import join as joinpath 385522Snate@binkert.org 394202Sbinkertn@umich.eduimport SCons 405742Snate@binkert.org 41955SN/AImport('*') 424381Sbinkertn@umich.edu 434381Sbinkertn@umich.eduif not env['RUBY']: 448334Snate@binkert.org Return() 45955SN/A 46955SN/Aslicc_dir = Dir('../slicc') 474202Sbinkertn@umich.eduprotocol_dir = Dir('.') 48955SN/Ahtml_dir = Dir('html') 494382Sbinkertn@umich.edu 504382Sbinkertn@umich.edu# 514382Sbinkertn@umich.edu# Use SLICC 526654Snate@binkert.org# 535517Snate@binkert.orgdef slicc_generator(target, source, env, for_signature): 548614Sgblack@eecs.umich.edu slicc_bin = str(source[0]) 557674Snate@binkert.org protocol = source[1].get_contents() 566143Snate@binkert.org pdir = str(protocol_dir) 576143Snate@binkert.org hdir = str(html_dir) 586143Snate@binkert.org 598233Snate@binkert.org if not isdir(pdir): 608233Snate@binkert.org os.mkdir(pdir) 618233Snate@binkert.org if not isdir(hdir): 628233Snate@binkert.org os.mkdir(hdir) 638233Snate@binkert.org 648334Snate@binkert.org do_html = "html" 658334Snate@binkert.org cmdline = [ slicc_bin, pdir, hdir, protocol, do_html ] 668233Snate@binkert.org cmdline += [ str(s) for s in source[2:] ] 678233Snate@binkert.org cmdline = ' '.join(cmdline) 688233Snate@binkert.org return cmdline 698233Snate@binkert.org 708233Snate@binkert.orgslicc_builder = Builder(generator=slicc_generator) 718233Snate@binkert.org 726143Snate@binkert.orgprotocol = env['PROTOCOL'] 738233Snate@binkert.orgsources = [ protocol_dir.File("RubySlicc_interfaces.slicc"), 748233Snate@binkert.org protocol_dir.File("%s.slicc" % protocol) ] 758233Snate@binkert.org 766143Snate@binkert.orgexecfile(slicc_dir.File('parser/parser.py').srcnode().abspath) 776143Snate@binkert.org 786143Snate@binkert.orgsm_files = read_slicc([s.srcnode().abspath for s in sources]) 796143Snate@binkert.orgsm_files = [ protocol_dir.File(f) for f in sm_files ] 808233Snate@binkert.org 818233Snate@binkert.orghh, cc = scan([s.srcnode().abspath for s in sm_files]) 828233Snate@binkert.orghh = [ protocol_dir.File(f) for f in hh ] 836143Snate@binkert.orgcc = [ protocol_dir.File(f) for f in cc ] 848233Snate@binkert.org 858233Snate@binkert.orgslicc_bin = slicc_dir.File("slicc") 868233Snate@binkert.org 878233Snate@binkert.orgenv.Append(BUILDERS={'SLICC' : slicc_builder}) 886143Snate@binkert.orgenv.SLICC(hh + cc, [ slicc_bin, Value(protocol) ] + sm_files) 896143Snate@binkert.org 906143Snate@binkert.orgfor f in cc: 914762Snate@binkert.org Source(f) 926143Snate@binkert.org