SysPaths.py revision 3510:c529f0b16334
16145SN/A# Copyright (c) 2006 The Regents of The University of Michigan
26145SN/A# All rights reserved.
36145SN/A#
46145SN/A# Redistribution and use in source and binary forms, with or without
56145SN/A# modification, are permitted provided that the following conditions are
66145SN/A# met: redistributions of source code must retain the above copyright
76145SN/A# notice, this list of conditions and the following disclaimer;
86145SN/A# redistributions in binary form must reproduce the above copyright
96145SN/A# notice, this list of conditions and the following disclaimer in the
106145SN/A# documentation and/or other materials provided with the distribution;
116145SN/A# neither the name of the copyright holders nor the names of its
126145SN/A# contributors may be used to endorse or promote products derived from
136145SN/A# this software without specific prior written permission.
146145SN/A#
156145SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
166145SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
176145SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
186145SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
196145SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
206145SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
216145SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
226145SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
236145SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
246145SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
256145SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
266145SN/A#
276145SN/A# Authors: Ali Saidi
286145SN/A
296145SN/Aimport os, sys
307054SN/Afrom os.path import isdir, join as joinpath
317054SN/Afrom os import environ as env
327054SN/A
337054SN/Aconfig_path = os.path.dirname(os.path.abspath(__file__))
347054SN/Aconfig_root = os.path.dirname(config_path)
357054SN/A
367054SN/Adef disk(file):
377054SN/A    system()
387054SN/A    return joinpath(disk.dir, file)
396145SN/A
407054SN/Adef binary(file):
417054SN/A    system()
426145SN/A    return joinpath(binary.dir, file)
437002SN/A
447002SN/Adef script(file):
457454SN/A    system()
467002SN/A    return joinpath(script.dir, file)
478257SBrad.Beckmann@amd.com
488608Snilay@cs.wisc.edudef system():
497054SN/A    if not system.dir:
507054SN/A        try:
516145SN/A                path = env['M5_PATH'].split(':')
528257SBrad.Beckmann@amd.com        except KeyError:
536145SN/A                path = [ '/dist/m5/system', '/n/poolfs/z/dist/m5/system' ]
546145SN/A
557454SN/A        for system.dir in path:
566145SN/A            if os.path.isdir(system.dir):
578257SBrad.Beckmann@amd.com                break
587054SN/A        else:
598257SBrad.Beckmann@amd.com            raise ImportError, "Can't find a path to system files."
608257SBrad.Beckmann@amd.com
616879SN/A    if not binary.dir:
626879SN/A        binary.dir = joinpath(system.dir, 'binaries')
638257SBrad.Beckmann@amd.com    if not disk.dir:
646879SN/A        disk.dir = joinpath(system.dir, 'disks')
657054SN/A    if not script.dir:
667054SN/A        script.dir = joinpath(config_root, 'boot')
677054SN/A
686876SN/Asystem.dir = None
696876SN/Abinary.dir = None
707054SN/Adisk.dir = None
716879SN/Ascript.dir = None
726145SN/A