genini.py revision 1641
14486Sbinkertn@umich.edu#!/usr/bin/env python
27897Shestness@cs.utexas.edu# Copyright (c) 2005 The Regents of The University of Michigan
34486Sbinkertn@umich.edu# All rights reserved.
44486Sbinkertn@umich.edu#
54486Sbinkertn@umich.edu# Redistribution and use in source and binary forms, with or without
64486Sbinkertn@umich.edu# modification, are permitted provided that the following conditions are
74486Sbinkertn@umich.edu# met: redistributions of source code must retain the above copyright
84486Sbinkertn@umich.edu# notice, this list of conditions and the following disclaimer;
94486Sbinkertn@umich.edu# redistributions in binary form must reproduce the above copyright
104486Sbinkertn@umich.edu# notice, this list of conditions and the following disclaimer in the
114486Sbinkertn@umich.edu# documentation and/or other materials provided with the distribution;
124486Sbinkertn@umich.edu# neither the name of the copyright holders nor the names of its
134486Sbinkertn@umich.edu# contributors may be used to endorse or promote products derived from
144486Sbinkertn@umich.edu# this software without specific prior written permission.
154486Sbinkertn@umich.edu#
164486Sbinkertn@umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
174486Sbinkertn@umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
184486Sbinkertn@umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
194486Sbinkertn@umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
204486Sbinkertn@umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
214486Sbinkertn@umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
224486Sbinkertn@umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
234486Sbinkertn@umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
244486Sbinkertn@umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
254486Sbinkertn@umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
264486Sbinkertn@umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
274486Sbinkertn@umich.edu
284486Sbinkertn@umich.eduimport getopt, os, os.path, sys
297897Shestness@cs.utexas.edufrom os.path import join as joinpath, realpath
304486Sbinkertn@umich.edu
313102SN/Amypath = sys.path[0]
326654Snate@binkert.orgsys.path.append(joinpath(mypath, '..'))
333102SN/Asys.path.append(joinpath(mypath, '../python'))
343102SN/Asys.path.append(joinpath(mypath, '../util/pbs'))
356654Snate@binkert.org
3610249Sstephan.diestelhorst@arm.compathlist = [ '.' ]
378931Sandreas.hansson@arm.com
382212SN/Am5_build_env = {}
399524SAndreas.Sandberg@ARM.com
409524SAndreas.Sandberg@ARM.comtry:
412902SN/A    opts, args = getopt.getopt(sys.argv[1:], '-E:I:')
428703Sandreas.hansson@arm.com    for opt,arg in opts:
431783SN/A        if opt == '-E':
449338SAndreas.Sandberg@arm.com            offset = arg.find('=')
458839Sandreas.hansson@arm.com            if offset == -1:
467673Snate@binkert.org                name = arg
477673Snate@binkert.org                value = 'True'
488597Ssteve.reinhardt@amd.com            else:
498597Ssteve.reinhardt@amd.com                name = arg[:offset]
508597Ssteve.reinhardt@amd.com                value = arg[offset+1:]
518597Ssteve.reinhardt@amd.com            os.environ[name] = value
528597Ssteve.reinhardt@amd.com            m5_build_env[name] = value
538597Ssteve.reinhardt@amd.com        if opt == '-I':
549524SAndreas.Sandberg@ARM.com            pathlist.append(arg)
558597Ssteve.reinhardt@amd.comexcept getopt.GetoptError:
568597Ssteve.reinhardt@amd.com    sys.exit('Improper Usage')
574859Snate@binkert.org
588931Sandreas.hansson@arm.comfrom m5 import *
598931Sandreas.hansson@arm.com
602902SN/Afor path in pathlist:
619408Sandreas.hansson@arm.com    AddToPath(path)
6211420Sdavid.guillen@arm.com
6311420Sdavid.guillen@arm.comfor arg in args:
6411420Sdavid.guillen@arm.com    LoadMpyFile(arg)
6511420Sdavid.guillen@arm.com
6610700Sandreas.hansson@arm.comif globals().has_key('root') and isinstance(root, type) \
6710700Sandreas.hansson@arm.com       and issubclass(root, Root):
6810700Sandreas.hansson@arm.com    instantiate(root)
6910700Sandreas.hansson@arm.com