Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/nmigen
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 42805ad95974
Choose a base ref
...
head repository: m-labs/nmigen
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 9ea3ff7ae2fb
Choose a head ref
  • 2 commits
  • 4 files changed
  • 1 contributor

Commits on Sep 12, 2019

  1. Copy the full SHA
    c8f8c09 View commit details
  2. build.plat: bypass tool detection if NMIGEN_*_env is set.

    It's not practical to detect tools within the toolchain environment
    for various reasons, so just assume the tools are there if the user
    says they are.
    
    Before this commit, the tools would be searched outside the toolchain
    environment, which of course would always fail for Vivado, ISE, etc.
    whitequark committed Sep 12, 2019
    Copy the full SHA
    9ea3ff7 View commit details
Showing with 22 additions and 8 deletions.
  1. +11 −4 nmigen/build/plat.py
  2. +3 −3 nmigen/vendor/lattice_ecp5.py
  3. +7 −0 nmigen/vendor/xilinx_7series.py
  4. +1 −1 nmigen/vendor/xilinx_spartan_3_6.py
15 changes: 11 additions & 4 deletions nmigen/build/plat.py
Original file line number Diff line number Diff line change
@@ -60,12 +60,17 @@ def add_file(self, filename, content):
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:
@@ -78,6 +83,8 @@ def build(self, elaboratable, name="top",
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
@@ -238,13 +245,13 @@ class TemplatedPlatform(Platform):
"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")}}
""",
}
6 changes: 3 additions & 3 deletions nmigen/vendor/lattice_ecp5.py
Original file line number Diff line number Diff line change
@@ -163,9 +163,9 @@ class LatticeECP5Platform(TemplatedPlatform):
# {{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")}}
""",
7 changes: 7 additions & 0 deletions nmigen/vendor/xilinx_7series.py
Original file line number Diff line number Diff line change
@@ -54,6 +54,13 @@ class Xilinx7SeriesPlatform(TemplatedPlatform):

file_templates = {
**TemplatedPlatform.build_script_templates,
"build_{{name}}.sh": r"""
# {{autogenerated}}
set -e{{verbose("x")}}
if [ -z "$BASH" ] ; then exec /bin/bash "$0" "$@"; fi
[ -n "${{platform._toolchain_env_var}}" ] && . "${{platform._toolchain_env_var}}"
{{emit_commands("sh")}}
""",
"{{name}}.v": r"""
/* {{autogenerated}} */
{{emit_design("verilog")}}
2 changes: 1 addition & 1 deletion nmigen/vendor/xilinx_spartan_3_6.py
Original file line number Diff line number Diff line change
@@ -88,7 +88,7 @@ def family(self):
# {{autogenerated}}
set -e{{verbose("x")}}
if [ -z "$BASH" ] ; then exec /bin/bash "$0" "$@"; fi
[ -n "$NMIGEN_{{platform.toolchain}}_env" ] && . "$NMIGEN_{{platform.toolchain}}_env"
[ -n "${{platform._toolchain_env_var}}" ] && . "${{platform._toolchain_env_var}}"
{{emit_commands("sh")}}
""",
"{{name}}.v": r"""