genini.py revision 1641
12600SN/A#!/usr/bin/env python
22600SN/A# Copyright (c) 2005 The Regents of The University of Michigan
32600SN/A# All rights reserved.
42600SN/A#
52600SN/A# Redistribution and use in source and binary forms, with or without
62600SN/A# modification, are permitted provided that the following conditions are
72600SN/A# met: redistributions of source code must retain the above copyright
82600SN/A# notice, this list of conditions and the following disclaimer;
92600SN/A# redistributions in binary form must reproduce the above copyright
102600SN/A# notice, this list of conditions and the following disclaimer in the
112600SN/A# documentation and/or other materials provided with the distribution;
122600SN/A# neither the name of the copyright holders nor the names of its
132600SN/A# contributors may be used to endorse or promote products derived from
142600SN/A# this software without specific prior written permission.
152600SN/A#
162600SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172600SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182600SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192600SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202600SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212600SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222600SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232600SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242600SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252600SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262600SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272665Ssaidi@eecs.umich.edu
282665Ssaidi@eecs.umich.eduimport getopt, os, os.path, sys
292600SN/Afrom os.path import join as joinpath, realpath
302600SN/A
318229Snate@binkert.orgmypath = sys.path[0]
3211793Sbrandon.potter@amd.comsys.path.append(joinpath(mypath, '..'))
332600SN/Asys.path.append(joinpath(mypath, '../python'))
346329Sgblack@eecs.umich.edusys.path.append(joinpath(mypath, '../util/pbs'))
3513988Sgabeblack@google.com
362600SN/Apathlist = [ '.' ]
372680Sktlim@umich.edu
382600SN/Am5_build_env = {}
392600SN/A
4011794Sbrandon.potter@amd.comtry:
412600SN/A    opts, args = getopt.getopt(sys.argv[1:], '-E:I:')
422600SN/A    for opt,arg in opts:
432600SN/A        if opt == '-E':
442600SN/A            offset = arg.find('=')
452600SN/A            if offset == -1:
4613988Sgabeblack@google.com                name = arg
4713988Sgabeblack@google.com                value = 'True'
4813988Sgabeblack@google.com            else:
4913988Sgabeblack@google.com                name = arg[:offset]
5013988Sgabeblack@google.com                value = arg[offset+1:]
5113988Sgabeblack@google.com            os.environ[name] = value
5213988Sgabeblack@google.com            m5_build_env[name] = value
5313988Sgabeblack@google.com        if opt == '-I':
5413988Sgabeblack@google.com            pathlist.append(arg)
5513988Sgabeblack@google.comexcept getopt.GetoptError:
5613988Sgabeblack@google.com    sys.exit('Improper Usage')
5713988Sgabeblack@google.com
5813988Sgabeblack@google.comfrom m5 import *
5913988Sgabeblack@google.com
6013988Sgabeblack@google.comfor path in pathlist:
6113988Sgabeblack@google.com    AddToPath(path)
6213988Sgabeblack@google.com
6313988Sgabeblack@google.comfor arg in args:
6413988Sgabeblack@google.com    LoadMpyFile(arg)
6513988Sgabeblack@google.com
6613988Sgabeblack@google.comif globals().has_key('root') and isinstance(root, type) \
6713988Sgabeblack@google.com       and issubclass(root, Root):
6813988Sgabeblack@google.com    instantiate(root)
6913988Sgabeblack@google.com