Fix pmgen for out-of-tree build
authorClifford Wolf <clifford@clifford.at>
Thu, 28 Feb 2019 22:00:58 +0000 (14:00 -0800)
committerClifford Wolf <clifford@clifford.at>
Thu, 28 Feb 2019 22:00:58 +0000 (14:00 -0800)
Signed-off-by: Clifford Wolf <clifford@clifford.at>
passes/pmgen/Makefile.inc
passes/pmgen/pmgen.py

index 33baaca30f8c9acf02250377db47f48103aa32d2..b9682612b630b80ac4161e02b7c389b0d7e7184b 100644 (file)
@@ -4,5 +4,5 @@ passes/pmgen/ice40_dsp.o: passes/pmgen/ice40_dsp_pm.h
 EXTRA_OBJS += passes/pmgen/ice40_dsp_pm.h
 .SECONDARY: passes/pmgen/ice40_dsp_pm.h
 
-passes/pmgen/ice40_dsp_pm.h: passes/pmgen/ice40_dsp.pmg passes/pmgen/pmgen.py
-       $(P) cd passes/pmgen && python3 pmgen.py ice40_dsp
+passes/pmgen/ice40_dsp_pm.h: passes/pmgen/pmgen.py passes/pmgen/ice40_dsp.pmg
+       $(P) mkdir -p passes/pmgen && cd passes/pmgen && python3 $^
index e688a4567f52923915804be2acf8ef135a024d7d..166d3963a0f8ae050042ffc840f7a1796b3d9a44 100644 (file)
@@ -6,7 +6,9 @@ import pprint
 
 pp = pprint.PrettyPrinter(indent=4)
 
-prefix = sys.argv[1]
+pmgfile = sys.argv[1]
+prefix = pmgfile.split("/")[-1]
+prefix = prefix.split(".")[0]
 
 state_types = dict()
 udata_types = dict()
@@ -73,7 +75,7 @@ def rewrite_cpp(s):
 
     return "".join(t)
 
-with open("%s.pmg" % prefix, "r") as f:
+with open(pmgfile, "r") as f:
     while True:
         line = f.readline()
         if line == "": break