Skip to content

Commit 3ff3459

Browse files
committed
feat(ui): add -tar option
1 parent b855b54 commit 3ff3459

File tree

1 file changed

+38
-11
lines changed

1 file changed

+38
-11
lines changed

run_noc_pass.py

+38-11
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,12 @@ class SelectorEnum(Enum):
8484
@click.option(
8585
"--build-dir",
8686
default=None,
87-
help="<Optional> Absolute path of build directory." "Required for --mmap-ilp.",
87+
help="<Optional> Absolute path of build directory.",
88+
)
89+
@click.option(
90+
"--tar",
91+
default=None,
92+
help="<Optional> File name for the build directory tar." "Exclude '.tar.gz'.",
8893
)
8994
@click.option(
9095
"--top-mod-name",
@@ -98,6 +103,15 @@ def parse_arguments(**kwargs: dict[str, Any]) -> dict[str, Any]:
98103
Returns a dictionary containing the parsed command-line arguments.
99104
"""
100105

106+
# Print all options that were used
107+
print("Used options:")
108+
for option, value in kwargs.items():
109+
if value is not None:
110+
print(f"{option}: {value}")
111+
112+
if kwargs["build_dir"] and kwargs["tar"]:
113+
raise click.BadParameter("Choose either --build-dir or --tar.")
114+
101115
if not kwargs["rapidstream_json"] and not kwargs["tapa_xo"]:
102116
raise click.BadParameter(
103117
"Either --rapidstream-json or --tapa-xo inputs is required."
@@ -126,6 +140,7 @@ def parse_arguments(**kwargs: dict[str, Any]) -> dict[str, Any]:
126140
mmap_port_json = args["mmap_port_json"]
127141
selector = args["selector"]
128142
build_dir = args["build_dir"]
143+
tar = args["tar"]
129144
top_mod_name = args["top_mod_name"]
130145
mmap_ilp = args["mmap_ilp"]
131146

@@ -211,23 +226,27 @@ def parse_arguments(**kwargs: dict[str, Any]) -> dict[str, Any]:
211226
else:
212227
raise NotImplementedError
213228

229+
if tar:
230+
build_dir = tar
231+
# build_dir = f"{os.getcwd()}/{tar}"
232+
214233
if build_dir:
215234
if os.path.exists(build_dir):
216235
print(f"The folder '{build_dir}' already exists. Aborting.")
217236
sys.exit(1)
218-
else:
219-
zsh_cmds = f"""
237+
238+
zsh_cmds = f"""
220239
mkdir {build_dir}
221240
cp {mmap_port_json} {build_dir}/{I_MMAP_PORT_JSON}
222241
"""
223-
if rapidstream_json:
224-
zsh_cmds += f"cp {rapidstream_json} {build_dir}/"
225-
elif tapa_xo:
226-
zsh_cmds += f"cp {tapa_xo} {build_dir}/"
227-
else:
228-
raise NotImplementedError
229-
print(zsh_cmds)
230-
subprocess.run(["zsh", "-c", zsh_cmds], check=True)
242+
if rapidstream_json:
243+
zsh_cmds += f"cp {rapidstream_json} {build_dir}/"
244+
elif tapa_xo:
245+
zsh_cmds += f"cp {tapa_xo} {build_dir}/"
246+
else:
247+
raise NotImplementedError
248+
print(zsh_cmds)
249+
subprocess.run(["zsh", "-c", zsh_cmds], check=True)
231250

232251
# Select MMAP ports to put over NoC
233252

@@ -444,6 +463,14 @@ def parse_arguments(**kwargs: dict[str, Any]) -> dict[str, Any]:
444463
with open(f"{build_dir}/{DUMP_NEG_PATHS_TCL}", "w", encoding="utf-8") as file:
445464
file.write("\n".join(tcl))
446465

466+
if tar:
467+
zsh_cmds = f"tar -czf {build_dir}.tar.gz {build_dir}\n"
468+
# delete the temporary tar directory
469+
zsh_cmds += f"rm -rf {build_dir}\n"
470+
print(zsh_cmds)
471+
subprocess.run(["zsh", "-c", zsh_cmds], check=True)
472+
sys.exit(1)
473+
447474
# launch vivado
448475
zsh_cmds = f"""
449476
source ~/.zshrc && amd

0 commit comments

Comments
 (0)