diff -r b1cbbe4ec8d7 -r 85fcc9b7b653 configs/common/SysPaths.py --- a/configs/common/SysPaths.py Wed Feb 23 02:13:50 2011 -0800 +++ b/configs/common/SysPaths.py Wed Feb 23 02:17:21 2011 -0800 @@ -1,4 +1,4 @@ -# Copyright (c) 2006 The Regents of The University of Michigan +# Copyright (c) 2006-2011 The Regents of The University of Michigan # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -26,46 +26,40 @@ # # Authors: Ali Saidi -import os, sys -from os.path import isdir, join as joinpath -from os import environ as env +from os import environ +from os.path import absdir, dirname, isdir, join as joinpath -config_path = os.path.dirname(os.path.abspath(__file__)) -config_root = os.path.dirname(config_path) +# Name of the M5 path environment variable. +m5_path_env = 'M5_PATH' +# Default M5 path. +default_path = '/opt/m5/' +# Directories holding different types of files. +binary_dir = 'binaries' +disk_dir = 'disks' +script_dir = 'boot' +# Find a directory in the path that actually exists. +if m5_path_env in environ: + raw_path = environ[m5_path_env] +else: + raw_path = default_path +paths = raw_path.split(':') +for system_dir in paths: + if isdir(system_dir): + break +else: + raise ImportError, "Can't find a path to system files." + +# Use the path of this file as the config script path. +config_path = dirname(abspath(__file__)) +config_root = dirname(config_path) + +# Functions to generate particular types of paths. def disk(file): - system() - return joinpath(disk.dir, file) + return joinpath(system_dir, disk_dir, file) +def binary(file): + return joinpath(system_dir, binary_dir, file) +def script(file): + return joinpath(config_root, script_dir, file) -def binary(file): - system() - return joinpath(binary.dir, file) - -def script(file): - system() - return joinpath(script.dir, file) - -def system(): - if not system.dir: - try: - path = env['M5_PATH'].split(':') - except KeyError: - path = [ '/dist/m5/system', '/n/poolfs/z/dist/m5/system' ] - - for system.dir in path: - if os.path.isdir(system.dir): - break - else: - raise ImportError, "Can't find a path to system files." - - if not binary.dir: - binary.dir = joinpath(system.dir, 'binaries') - if not disk.dir: - disk.dir = joinpath(system.dir, 'disks') - if not script.dir: - script.dir = joinpath(config_root, 'boot') - -system.dir = None -binary.dir = None -disk.dir = None -script.dir = None +__all__ = ['disk', 'binary', 'script']