genini.py revision 2665
11311SN/A#!/usr/bin/env python 21310SN/A# Copyright (c) 2005 The Regents of The University of Michigan 31310SN/A# All rights reserved. 41310SN/A# 51310SN/A# Redistribution and use in source and binary forms, with or without 61310SN/A# modification, are permitted provided that the following conditions are 71310SN/A# met: redistributions of source code must retain the above copyright 81310SN/A# notice, this list of conditions and the following disclaimer; 91310SN/A# redistributions in binary form must reproduce the above copyright 101310SN/A# notice, this list of conditions and the following disclaimer in the 111310SN/A# documentation and/or other materials provided with the distribution; 121310SN/A# neither the name of the copyright holders nor the names of its 131310SN/A# contributors may be used to endorse or promote products derived from 141310SN/A# this software without specific prior written permission. 151310SN/A# 161310SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 171310SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 181310SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 191310SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 201310SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 211310SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 221310SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 231310SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 241310SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 251310SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 261310SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665Ssaidi@eecs.umich.edu# 282665Ssaidi@eecs.umich.edu# Authors: Nathan Binkert 291310SN/A 301320SN/Aimport getopt, os, os.path, sys 311377SN/Afrom os.path import join as joinpath, realpath 321310SN/A 331377SN/Amypath = sys.path[0] 341377SN/Asys.path.append(joinpath(mypath, '..')) 351511SN/Asys.path.append(joinpath(mypath, '../python')) 361385SN/Asys.path.append(joinpath(mypath, '../util/pbs')) 371310SN/A 381511SN/Apathlist = [ '.' ] 391403SN/A 401530SN/Am5_build_env = {} 411530SN/A 421310SN/Atry: 431385SN/A opts, args = getopt.getopt(sys.argv[1:], '-E:I:') 441385SN/A for opt,arg in opts: 451385SN/A if opt == '-E': 461385SN/A offset = arg.find('=') 471310SN/A if offset == -1: 481385SN/A name = arg 491641SN/A value = 'True' 501310SN/A else: 511385SN/A name = arg[:offset] 521385SN/A value = arg[offset+1:] 531455SN/A os.environ[name] = value 541530SN/A m5_build_env[name] = value 551385SN/A if opt == '-I': 561511SN/A pathlist.append(arg) 571310SN/Aexcept getopt.GetoptError: 581310SN/A sys.exit('Improper Usage') 591310SN/A 601692SN/Aimport __main__ 611692SN/A__main__.m5_build_env = m5_build_env 621692SN/A 631511SN/Afrom m5 import * 641511SN/A 651511SN/Afor path in pathlist: 661511SN/A AddToPath(path) 671455SN/A 681310SN/Afor arg in args: 691943SN/A m5execfile(arg, globals()) 701310SN/A 711692SN/Aif globals().has_key('root') and isinstance(root, Root): 721310SN/A instantiate(root) 731692SN/Aelse: 741692SN/A print "Instantiation skipped: no root object found." 75