3
0
Fork 0
mirror of https://github.com/YosysHQ/sby.git synced 2025-08-19 11:20:25 +00:00

Add linkmode --link

Symlinks files instead of copying them.
This commit is contained in:
Krystine Sherwin 2025-06-23 16:17:18 +12:00
parent b47d2829f9
commit 829b4cc32f
No known key found for this signature in database
3 changed files with 20 additions and 6 deletions

View file

@ -54,6 +54,7 @@ dump_taskinfo = args.dump_taskinfo
dump_files = args.dump_files
reusedir = False
setupmode = args.setupmode
linkmode = args.linkmode
autotune = args.autotune
autotune_config = args.autotune_config
sequential = args.sequential
@ -62,6 +63,10 @@ init_config_file = args.init_config_file
status_show = args.status
status_reset = args.status_reset
if autotune and linkmode:
print("ERROR: --link flag currently not available with --autotune")
sys.exit(1)
if status_show or status_reset:
target = workdir_prefix or workdir or sbyfile
if target is None:
@ -495,7 +500,7 @@ def start_task(taskloop, taskname):
task.exit_callback = exit_callback
if not autotune:
task.setup_procs(setupmode)
task.setup_procs(setupmode, linkmode)
task.task_local_abort = not throw_err
return task

View file

@ -70,6 +70,8 @@ def parser_func(release_version='unknown SBY version'):
help="print the list of source files")
parser.add_argument("--setup", action="store_true", dest="setupmode",
help="set up the working directory and exit")
parser.add_argument("--link", action="store_true", dest="linkmode",
help="make symbolic links to source files instead of copying them")
parser.add_argument("--status", action="store_true", dest="status",
help="summarize the contents of the status database")

View file

@ -947,7 +947,7 @@ class SbyTask(SbyConfig):
if not os.path.isdir(path):
os.makedirs(path)
def copy_src(self):
def copy_src(self, linkmode=False):
self.makedirs(self.workdir + "/src")
for dstfile, lines in self.verbatim_files.items():
@ -969,8 +969,15 @@ class SbyTask(SbyConfig):
if basedir != "" and not os.path.exists(basedir):
os.makedirs(basedir)
self.log(f"Copy '{os.path.abspath(srcfile)}' to '{os.path.abspath(dstfile)}'.")
if os.path.isdir(srcfile):
if linkmode:
verb = "Link"
else:
verb = "Copy"
self.log(f"{verb} '{os.path.abspath(srcfile)}' to '{os.path.abspath(dstfile)}'.")
if linkmode:
os.symlink(os.path.relpath(srcfile, basedir), dstfile)
elif os.path.isdir(srcfile):
copytree(srcfile, dstfile, dirs_exist_ok=True)
else:
copyfile(srcfile, dstfile)
@ -1308,7 +1315,7 @@ class SbyTask(SbyConfig):
self.status_db = SbyStatusDb(status_path, self)
def setup_procs(self, setupmode):
def setup_procs(self, setupmode, linkmode=False):
self.handle_non_engine_options()
if self.opt_smtc is not None:
for engine_idx, engine in self.engine_list():
@ -1329,7 +1336,7 @@ class SbyTask(SbyConfig):
if self.reusedir:
rmtree(f"{self.workdir}/model", ignore_errors=True)
else:
self.copy_src()
self.copy_src(linkmode)
if setupmode:
self.retcode = 0