SConscript revision 6654
14202Sbinkertn@umich.edu# -*- mode:python -*- 24202Sbinkertn@umich.edu 34202Sbinkertn@umich.edu# Copyright (c) 2009 The Hewlett-Packard Development Company 44202Sbinkertn@umich.edu# All rights reserved. 54202Sbinkertn@umich.edu# 64202Sbinkertn@umich.edu# Redistribution and use in source and binary forms, with or without 74202Sbinkertn@umich.edu# modification, are permitted provided that the following conditions are 84202Sbinkertn@umich.edu# met: redistributions of source code must retain the above copyright 94202Sbinkertn@umich.edu# notice, this list of conditions and the following disclaimer; 104202Sbinkertn@umich.edu# redistributions in binary form must reproduce the above copyright 114202Sbinkertn@umich.edu# notice, this list of conditions and the following disclaimer in the 124202Sbinkertn@umich.edu# documentation and/or other materials provided with the distribution; 134202Sbinkertn@umich.edu# neither the name of the copyright holders nor the names of its 144202Sbinkertn@umich.edu# contributors may be used to endorse or promote products derived from 154202Sbinkertn@umich.edu# this software without specific prior written permission. 164202Sbinkertn@umich.edu# 174202Sbinkertn@umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 184202Sbinkertn@umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 194202Sbinkertn@umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 204202Sbinkertn@umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 214202Sbinkertn@umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 224202Sbinkertn@umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 234202Sbinkertn@umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 244202Sbinkertn@umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 254202Sbinkertn@umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 264202Sbinkertn@umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 274202Sbinkertn@umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 284202Sbinkertn@umich.edu# 294202Sbinkertn@umich.edu# Authors: Nathan Binkert 304202Sbinkertn@umich.edu 314202Sbinkertn@umich.eduimport os 324202Sbinkertn@umich.eduimport re 335628Sgblack@eecs.umich.eduimport string 344486Sbinkertn@umich.eduimport sys 354776Sgblack@eecs.umich.edu 364486Sbinkertn@umich.edufrom os.path import basename, dirname, exists, expanduser, isdir, isfile 374202Sbinkertn@umich.edufrom os.path import join as joinpath 384202Sbinkertn@umich.edu 394202Sbinkertn@umich.eduimport SCons 404202Sbinkertn@umich.edu 415522Snate@binkert.orgImport('*') 428233Snate@binkert.org 434202Sbinkertn@umich.eduif not env['RUBY']: 444202Sbinkertn@umich.edu Return() 454202Sbinkertn@umich.edu 464202Sbinkertn@umich.eduslicc_dir = Dir('../slicc') 474202Sbinkertn@umich.eduprotocol_dir = Dir('.') 484202Sbinkertn@umich.eduhtml_dir = Dir('html') 497768SAli.Saidi@ARM.com 507768SAli.Saidi@ARM.com# 518766Sgblack@eecs.umich.edu# Use SLICC 527768SAli.Saidi@ARM.com# 537768SAli.Saidi@ARM.comdef slicc_generator(target, source, env, for_signature): 548766Sgblack@eecs.umich.edu slicc_bin = str(source[0]) 557768SAli.Saidi@ARM.com protocol = source[1].get_contents() 567768SAli.Saidi@ARM.com pdir = str(protocol_dir) 574202Sbinkertn@umich.edu hdir = str(html_dir) 584202Sbinkertn@umich.edu 594826Ssaidi@eecs.umich.edu if not isdir(pdir): 607768SAli.Saidi@ARM.com os.mkdir(pdir) 615016Sgblack@eecs.umich.edu if not isdir(hdir): 624486Sbinkertn@umich.edu os.mkdir(hdir) 634202Sbinkertn@umich.edu 645192Ssaidi@eecs.umich.edu do_html = "html" 658335Snate@binkert.org cmdline = [ slicc_bin, pdir, hdir, protocol, do_html ] 668335Snate@binkert.org cmdline += [ str(s) for s in source[2:] ] 678335Snate@binkert.org cmdline = ' '.join(cmdline) 688335Snate@binkert.org return cmdline 698335Snate@binkert.org 708335Snate@binkert.orgslicc_builder = Builder(generator=slicc_generator) 718335Snate@binkert.org 728335Snate@binkert.orgprotocol = env['PROTOCOL'] 738335Snate@binkert.orgsources = [ protocol_dir.File("RubySlicc_interfaces.slicc"), 748335Snate@binkert.org protocol_dir.File("%s.slicc" % protocol) ] 758335Snate@binkert.org 768335Snate@binkert.orgsys.path[0:0] = [env['ENV']['M5_PLY']] 778335Snate@binkert.orgexecfile(slicc_dir.File('parser/parser.py').srcnode().abspath) 788335Snate@binkert.org 798335Snate@binkert.orgsm_files = read_slicc([s.srcnode().abspath for s in sources]) 808335Snate@binkert.orgsm_files = [ protocol_dir.File(f) for f in sm_files ] 818335Snate@binkert.org 82hh, cc = scan([s.srcnode().abspath for s in sm_files]) 83hh = [ protocol_dir.File(f) for f in hh ] 84cc = [ protocol_dir.File(f) for f in cc ] 85 86slicc_bin = slicc_dir.File("slicc") 87 88env.Append(BUILDERS={'SLICC' : slicc_builder}) 89env.SLICC(hh + cc, [ slicc_bin, Value(protocol) ] + sm_files) 90 91for f in cc: 92 Source(f) 93