From b16dd800886337e7b63cc685aca3aac38f1ef487 Mon Sep 17 00:00:00 2001 From: Matt Guthaus Date: Fri, 12 May 2017 14:56:31 -0700 Subject: [PATCH] Add checks for valid OPENRAM_HOME and OPENRAM_TECH directories and subdirs --- compiler/debug.py | 6 ++++++ compiler/globals.py | 17 +++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/compiler/debug.py b/compiler/debug.py index 4bb7fab6..3fd40222 100644 --- a/compiler/debug.py +++ b/compiler/debug.py @@ -9,6 +9,12 @@ import sys # 2 = verbose # n = custom setting +def check(check,str): + (frame, filename, line_number, function_name, lines, + index) = inspect.getouterframes(inspect.currentframe())[1] + if not check: + print "ERROR: file ", os.path.basename(filename), ": line ", line_number, ": ", str + sys.exit(-1) def error(str,return_value=None): (frame, filename, line_number, function_name, lines, diff --git a/compiler/globals.py b/compiler/globals.py index f22fc112..ca81b12f 100644 --- a/compiler/globals.py +++ b/compiler/globals.py @@ -164,10 +164,17 @@ def setup_paths(): try: OPENRAM_HOME = os.path.abspath(os.environ.get("OPENRAM_HOME")) except: - debug.error("OPENRAM_HOME is not properly defined.",1) - sys.path.append("{0}".format(OPENRAM_HOME)) + debug.error("$OPENRAM_HOME is not properly defined.",1) + debug.check(os.path.isdir(OPENRAM_HOME),"$OPENRAM_HOME does not exist: {0}".format(OPENRAM_HOME)) + + debug.check(os.path.isdir(OPENRAM_HOME+"/gdsMill"), + "$OPENRAM_HOME/gdsMill does not exist: {0}".format(OPENRAM_HOME+"/gdsMill")) sys.path.append("{0}/gdsMill".format(OPENRAM_HOME)) + debug.check(os.path.isdir(OPENRAM_HOME+"/tests"), + "$OPENRAM_HOME/tests does not exist: {0}".format(OPENRAM_HOME+"/tests")) sys.path.append("{0}/tests".format(OPENRAM_HOME)) + debug.check(os.path.isdir(OPENRAM_HOME+"/characterizer"), + "$OPENRAM_HOME/characterizer does not exist: {0}".format(OPENRAM_HOME+"/characterizer")) sys.path.append("{0}/characterizer".format(OPENRAM_HOME)) if not OPTS.openram_temp.endswith('/'): @@ -258,8 +265,9 @@ def import_tech(): try: OPENRAM_TECH = os.path.abspath(os.environ.get("OPENRAM_TECH")) except: - debug.error("OPENRAM_TECH is not properly defined.",1) - + debug.error("$OPENRAM_TECH is not properly defined.",1) + debug.check(os.path.isdir(OPENRAM_TECH),"$OPENRAM_TECH does not exist: {0}".format(OPENRAM_TECH)) + OPTS.openram_tech = OPENRAM_TECH + "/" + OPTS.tech_name if not OPTS.openram_tech.endswith('/'): OPTS.openram_tech += "/" @@ -270,6 +278,7 @@ def import_tech(): # we assume that the setup scripts (and tech dirs) are located at the # same level as the compielr itself, probably not a good idea though. path = "{0}/setup_scripts".format(os.environ.get("OPENRAM_TECH")) + debug.check(os.path.isdir(path),"OPENRAM_TECH does not exist: {0}".format(path)) sys.path.append(os.path.abspath(path)) __import__(filename) except ImportError: