genini.py revision 1943
18840Sandreas.hansson@arm.com#!/usr/bin/env python
28840Sandreas.hansson@arm.com# Copyright (c) 2005 The Regents of The University of Michigan
38840Sandreas.hansson@arm.com# All rights reserved.
48840Sandreas.hansson@arm.com#
58840Sandreas.hansson@arm.com# Redistribution and use in source and binary forms, with or without
68840Sandreas.hansson@arm.com# modification, are permitted provided that the following conditions are
78840Sandreas.hansson@arm.com# met: redistributions of source code must retain the above copyright
88840Sandreas.hansson@arm.com# notice, this list of conditions and the following disclaimer;
98840Sandreas.hansson@arm.com# redistributions in binary form must reproduce the above copyright
108840Sandreas.hansson@arm.com# notice, this list of conditions and the following disclaimer in the
118840Sandreas.hansson@arm.com# documentation and/or other materials provided with the distribution;
128840Sandreas.hansson@arm.com# neither the name of the copyright holders nor the names of its
132740SN/A# contributors may be used to endorse or promote products derived from
147534Ssteve.reinhardt@amd.com# this software without specific prior written permission.
151046SN/A#
161046SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
171046SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
181046SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
191046SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
201046SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
211046SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
221046SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
231046SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
241046SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
251046SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
261046SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
271046SN/A
281046SN/Aimport getopt, os, os.path, sys
291046SN/Afrom os.path import join as joinpath, realpath
301046SN/A
311046SN/Amypath = sys.path[0]
321046SN/Asys.path.append(joinpath(mypath, '..'))
331046SN/Asys.path.append(joinpath(mypath, '../python'))
341046SN/Asys.path.append(joinpath(mypath, '../util/pbs'))
351046SN/A
361046SN/Apathlist = [ '.' ]
371046SN/A
381046SN/Am5_build_env = {}
392665SN/A
402665SN/Atry:
412665SN/A    opts, args = getopt.getopt(sys.argv[1:], '-E:I:')
428840Sandreas.hansson@arm.com    for opt,arg in opts:
431046SN/A        if opt == '-E':
445766Snate@binkert.org            offset = arg.find('=')
458331Ssteve.reinhardt@amd.com            if offset == -1:
461438SN/A                name = arg
474762Snate@binkert.org                value = 'True'
486654Snate@binkert.org            else:
493102Sstever@eecs.umich.edu                name = arg[:offset]
503102Sstever@eecs.umich.edu                value = arg[offset+1:]
513102Sstever@eecs.umich.edu            os.environ[name] = value
523102Sstever@eecs.umich.edu            m5_build_env[name] = value
536654Snate@binkert.org        if opt == '-I':
543102Sstever@eecs.umich.edu            pathlist.append(arg)
553102Sstever@eecs.umich.eduexcept getopt.GetoptError:
567528Ssteve.reinhardt@amd.com    sys.exit('Improper Usage')
578839Sandreas.hansson@arm.com
583102Sstever@eecs.umich.eduimport __main__
596654Snate@binkert.org__main__.m5_build_env = m5_build_env
606654Snate@binkert.org
61679SN/Afrom m5 import *
62679SN/A
63679SN/Afor path in pathlist:
64679SN/A    AddToPath(path)
65679SN/A
66679SN/Afor arg in args:
671692SN/A    m5execfile(arg, globals())
68679SN/A
69679SN/Aif globals().has_key('root') and isinstance(root, Root):
70679SN/A    instantiate(root)
71679SN/Aelse:
72679SN/A    print "Instantiation skipped: no root object found."
73679SN/A