Skip to content

Commit 1e83926

Browse files
erikwaolofk
authored andcommitted
Add --work-root command line option for overriding build-root
1 parent 7f71d14 commit 1e83926

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

fusesoc/config.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,14 @@ def build_root(self):
159159
def build_root(self, val):
160160
self._set_default_section("build_root", val)
161161

162+
@property
163+
def work_root(self):
164+
return self._arg_or_val("args_work_root", self._path_from_cfg("work_root"))
165+
166+
@work_root.setter
167+
def work_root(self, val):
168+
self._set_default_section("work_root", val)
169+
162170
@property
163171
def cache_root(self):
164172
return self._get_cache_root()

fusesoc/fusesoc.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def get_work_root(self, core, flags):
9292

9393
if flow:
9494
logger.debug(f"Using flow API (flow={flow})")
95-
work_root = os.path.join(build_root, target)
95+
work_root = self.config.work_root or os.path.join(build_root, target)
9696
else:
9797
logger.debug("flow not set. Falling back to tool API")
9898
if "tool" in flags:
@@ -101,7 +101,9 @@ def get_work_root(self, core, flags):
101101
tool_error = "No flow or tool was supplied on command line or found in '{}' core description"
102102
raise RuntimeError(tool_error.format(core.name.sanitized_name))
103103

104-
work_root = os.path.join(build_root, f"{target}-{tool}")
104+
work_root = self.config.work_root or os.path.join(
105+
build_root, f"{target}-{tool}"
106+
)
105107

106108
return work_root
107109

fusesoc/main.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,12 @@ def get_parser():
538538
help="Reference source files from their current location instead of exporting to a build tree",
539539
)
540540
parser_run.add_argument(
541-
"--build-root", help="Output directory for build. Defaults to build/$VLNV"
541+
"--build-root",
542+
help="Output directory for build. VLNV will be appended (defaults to build/)",
543+
)
544+
parser_run.add_argument(
545+
"--work-root",
546+
help="Output directory for build. VLNV will not be appended (overrides build-root)",
542547
)
543548
parser_run.add_argument("--setup", action="store_true", help="Execute setup stage")
544549
parser_run.add_argument("--build", action="store_true", help="Execute build stage")
@@ -617,6 +622,9 @@ def args_to_config(args, config):
617622
if hasattr(args, "build_root") and args.build_root and len(args.build_root) > 0:
618623
setattr(config, "args_build_root", args.build_root)
619624

625+
if hasattr(args, "work_root") and args.work_root and len(args.work_root) > 0:
626+
setattr(config, "args_work_root", args.work_root)
627+
620628
if hasattr(args, "cores_root") and args.cores_root and len(args.cores_root) > 0:
621629
setattr(config, "args_cores_root", args.cores_root)
622630

0 commit comments

Comments
 (0)