Skip to content

Commit e244507

Browse files
committed
Fixing issue with running outside of examples dir
1 parent 64b7d53 commit e244507

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

examples/baremetal/make.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,21 @@
2828

2929
parser.add_argument("-group","-g",
3030
nargs='+',
31-
choices=['basic', 'memory', 'arithmetic', 'epfl', 'block'],
31+
choices=['basic',
32+
'memory',
33+
'arithmetic',
34+
'epfl',
35+
'block'],
3236
required=True,
3337
help="Benchmark group")
3438
parser.add_argument("-name","-n",
3539
nargs='+',
3640
help="Benchmark name")
3741
parser.add_argument("-tool",
3842
choices=['yosys', 'vivado'],
39-
required=True,
43+
default="yosys",
4044
help="Tool name")
4145
parser.add_argument("-target",
42-
required=True,
4346
help="Compilation target")
4447
parser.add_argument('-clean','-c',
4548
action='store_true',
@@ -51,11 +54,12 @@
5154
args = parser.parse_args()
5255

5356
# resolving relative path
57+
cwd = os.getcwd()
5458
scriptdir = Path(__file__).resolve().parent
5559
rootdir = Path(__file__).resolve().parent.parent.parent
5660

5761
# generated local script
58-
env = Environment(loader=FileSystemLoader('.'))
62+
env = Environment(loader=FileSystemLoader(scriptdir))
5963
template = env.get_template(f'{args.tool}_template.j2')
6064

6165
# global analysis
@@ -79,11 +83,12 @@
7983
script = f"{name}.tcl"
8084
cmd = ['vivado', '-mode batch', '-source', script]
8185

82-
# clean up old run
83-
if args.clean: # create run dir.clean:
84-
shutil.rmtree(f"build/{group}/{name}")
86+
# clean up old results
87+
if os.path.isdir(f"build/{group}/{name}"):
88+
if args.clean: # create run dir.clean:
89+
shutil.rmtree(f"build/{group}/{name}")
8590

86-
# create run dir
91+
# change dir
8792
os.makedirs(f"build/{group}/{name}", exist_ok=True)
8893
os.chdir(f"build/{group}/{name}")
8994

@@ -131,8 +136,8 @@
131136
data = json.load(f)
132137
results["cells"][name] = data["design"]["num_cells"]
133138

134-
# go back home
135-
os.chdir(scriptdir)
139+
# go back to cwd
140+
os.chdir(cwd)
136141

137142

138143
# writing results to file

0 commit comments

Comments
 (0)