raise TypeError("File contents must be str, bytes, or a file-like object")
self.extra_files[filename] = content
+ @property
+ def _toolchain_env_var(self):
+ return f"NMIGEN_{self.toolchain}_env"
+
def build(self, elaboratable, name="top",
build_dir="build", do_build=True,
program_opts=None, do_program=False,
**kwargs):
- for tool in self.required_tools:
- require_tool(tool)
+ if self._toolchain_env_var not in os.environ:
+ for tool in self.required_tools:
+ require_tool(tool)
plan = self.prepare(elaboratable, name, **kwargs)
if not do_build:
self.toolchain_program(products, name, **(program_opts or {}))
def has_required_tools(self):
+ if self._toolchain_env_var in os.environ:
+ return True
return all(has_tool(name) for name in self.required_tools)
@abstractmethod
"build_{{name}}.sh": """
# {{autogenerated}}
set -e{{verbose("x")}}
- [ -n "$NMIGEN_{{platform.toolchain}}_env" ] && . "$NMIGEN_{{platform.toolchain}}_env"
+ [ -n "${{platform._toolchain_env_var}}" ] && . "${{platform._toolchain_env_var}}"
{{emit_commands("sh")}}
""",
"build_{{name}}.bat": """
@rem {{autogenerated}}
{{quiet("@echo off")}}
- if defined NMIGEN_{{platform.toolchain}}_env call %NMIGEN_{{platform.toolchain}}_env%
+ if defined {{platform._toolchain_env_var}} call %{{platform._toolchain_env_var}}%
{{emit_commands("bat")}}
""",
}
# {{autogenerated}}
set -e{{verbose("x")}}
if [ -z "$BASH" ] ; then exec /bin/bash "$0" "$@"; fi
- if [ -n "$NMIGEN_{{platform.toolchain}}_env" ]; then
- bindir=$(dirname "$NMIGEN_{{platform.toolchain}}_env")
- . "$NMIGEN_{{platform.toolchain}}_env"
+ if [ -n "${{platform._toolchain_env_var}}" ]; then
+ bindir=$(dirname "${{platform._toolchain_env_var}}")
+ . "${{platform._toolchain_env_var}}"
fi
{{emit_commands("sh")}}
""",