mirror of
https://github.com/YosysHQ/sby.git
synced 2025-09-29 22:49:03 +00:00
Add linkmode --link
Symlinks files instead of copying them.
This commit is contained in:
parent
b47d2829f9
commit
829b4cc32f
3 changed files with 20 additions and 6 deletions
|
@ -54,6 +54,7 @@ dump_taskinfo = args.dump_taskinfo
|
||||||
dump_files = args.dump_files
|
dump_files = args.dump_files
|
||||||
reusedir = False
|
reusedir = False
|
||||||
setupmode = args.setupmode
|
setupmode = args.setupmode
|
||||||
|
linkmode = args.linkmode
|
||||||
autotune = args.autotune
|
autotune = args.autotune
|
||||||
autotune_config = args.autotune_config
|
autotune_config = args.autotune_config
|
||||||
sequential = args.sequential
|
sequential = args.sequential
|
||||||
|
@ -62,6 +63,10 @@ init_config_file = args.init_config_file
|
||||||
status_show = args.status
|
status_show = args.status
|
||||||
status_reset = args.status_reset
|
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:
|
if status_show or status_reset:
|
||||||
target = workdir_prefix or workdir or sbyfile
|
target = workdir_prefix or workdir or sbyfile
|
||||||
if target is None:
|
if target is None:
|
||||||
|
@ -495,7 +500,7 @@ def start_task(taskloop, taskname):
|
||||||
task.exit_callback = exit_callback
|
task.exit_callback = exit_callback
|
||||||
|
|
||||||
if not autotune:
|
if not autotune:
|
||||||
task.setup_procs(setupmode)
|
task.setup_procs(setupmode, linkmode)
|
||||||
task.task_local_abort = not throw_err
|
task.task_local_abort = not throw_err
|
||||||
|
|
||||||
return task
|
return task
|
||||||
|
|
|
@ -70,6 +70,8 @@ def parser_func(release_version='unknown SBY version'):
|
||||||
help="print the list of source files")
|
help="print the list of source files")
|
||||||
parser.add_argument("--setup", action="store_true", dest="setupmode",
|
parser.add_argument("--setup", action="store_true", dest="setupmode",
|
||||||
help="set up the working directory and exit")
|
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",
|
parser.add_argument("--status", action="store_true", dest="status",
|
||||||
help="summarize the contents of the status database")
|
help="summarize the contents of the status database")
|
||||||
|
|
|
@ -947,7 +947,7 @@ class SbyTask(SbyConfig):
|
||||||
if not os.path.isdir(path):
|
if not os.path.isdir(path):
|
||||||
os.makedirs(path)
|
os.makedirs(path)
|
||||||
|
|
||||||
def copy_src(self):
|
def copy_src(self, linkmode=False):
|
||||||
self.makedirs(self.workdir + "/src")
|
self.makedirs(self.workdir + "/src")
|
||||||
|
|
||||||
for dstfile, lines in self.verbatim_files.items():
|
for dstfile, lines in self.verbatim_files.items():
|
||||||
|
@ -969,8 +969,15 @@ class SbyTask(SbyConfig):
|
||||||
if basedir != "" and not os.path.exists(basedir):
|
if basedir != "" and not os.path.exists(basedir):
|
||||||
os.makedirs(basedir)
|
os.makedirs(basedir)
|
||||||
|
|
||||||
self.log(f"Copy '{os.path.abspath(srcfile)}' to '{os.path.abspath(dstfile)}'.")
|
if linkmode:
|
||||||
if os.path.isdir(srcfile):
|
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)
|
copytree(srcfile, dstfile, dirs_exist_ok=True)
|
||||||
else:
|
else:
|
||||||
copyfile(srcfile, dstfile)
|
copyfile(srcfile, dstfile)
|
||||||
|
@ -1308,7 +1315,7 @@ class SbyTask(SbyConfig):
|
||||||
|
|
||||||
self.status_db = SbyStatusDb(status_path, self)
|
self.status_db = SbyStatusDb(status_path, self)
|
||||||
|
|
||||||
def setup_procs(self, setupmode):
|
def setup_procs(self, setupmode, linkmode=False):
|
||||||
self.handle_non_engine_options()
|
self.handle_non_engine_options()
|
||||||
if self.opt_smtc is not None:
|
if self.opt_smtc is not None:
|
||||||
for engine_idx, engine in self.engine_list():
|
for engine_idx, engine in self.engine_list():
|
||||||
|
@ -1329,7 +1336,7 @@ class SbyTask(SbyConfig):
|
||||||
if self.reusedir:
|
if self.reusedir:
|
||||||
rmtree(f"{self.workdir}/model", ignore_errors=True)
|
rmtree(f"{self.workdir}/model", ignore_errors=True)
|
||||||
else:
|
else:
|
||||||
self.copy_src()
|
self.copy_src(linkmode)
|
||||||
|
|
||||||
if setupmode:
|
if setupmode:
|
||||||
self.retcode = 0
|
self.retcode = 0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue