build.plat: source a script with toolchain environment.
authorwhitequark <whitequark@whitequark.org>
Sun, 7 Jul 2019 00:41:03 +0000 (00:41 +0000)
committerwhitequark <whitequark@whitequark.org>
Sun, 7 Jul 2019 00:44:28 +0000 (00:44 +0000)
Fixes #131.

nmigen/build/plat.py
nmigen/vendor/lattice_ecp5.py
nmigen/vendor/lattice_ice40.py
nmigen/vendor/xilinx_7series.py
nmigen/vendor/xilinx_spartan6.py

index d7e98dc42780f36043c784b518e6447d9ae7cd9c..9a21bad6a099bcd107012036e2a8620b3b80578d 100644 (file)
@@ -184,6 +184,7 @@ class Platform(ResourceManager, metaclass=ABCMeta):
 
 
 class TemplatedPlatform(Platform):
+    toolchain         = abstractproperty()
     file_templates    = abstractproperty()
     command_templates = abstractproperty()
 
@@ -191,11 +192,13 @@ class TemplatedPlatform(Platform):
         "build_{{name}}.sh": """
             # {{autogenerated}}
             set -e{{verbose("x")}}
+            [ -n "$NMIGEN_{{platform.toolchain}}_env" ] && . "$NMIGEN_{{platform.toolchain}}_env"
             {{emit_commands("sh")}}
         """,
         "build_{{name}}.bat": """
             @rem {{autogenerated}}
             {{quiet("@echo off")}}
+            if defined NMIGEN_{{platform.toolchain}}_env call %NMIGEN_{{platform.toolchain}}_env%
             {{emit_commands("bat")}}
         """,
     }
index 2993dd1b936f75793f269991403e71df46e512fd..b65a62831b7c99dda158a8e7894074923c24e7fa 100644 (file)
@@ -14,6 +14,9 @@ class LatticeECP5Platform(TemplatedPlatform):
         * ``nextpnr-ecp5``
         * ``ecppack``
 
+    The environment is populated by running the script specified in the environment variable
+    ``NMIGEN_Trellis_env``, if present.
+
     Available overrides:
         * ``verbose``: enables logging of informational messages to standard error.
         * ``read_verilog_opts``: adds options for ``read_verilog`` Yosys command.
@@ -33,6 +36,8 @@ class LatticeECP5Platform(TemplatedPlatform):
         * ``{{name}}.svf``: JTAG programming vector.
     """
 
+    toolchain = "Trellis"
+
     device  = abstractproperty()
     package = abstractproperty()
     speed   = abstractproperty()
index e296ce696b61b0ac4a61a924f3033b0da1823872..57d90e4735cec4020bb0f0f21e4e6599b200d9a1 100644 (file)
@@ -14,6 +14,9 @@ class LatticeICE40Platform(TemplatedPlatform):
         * ``nextpnr-ice40``
         * ``icepack``
 
+    The environment is populated by running the script specified in the environment variable
+    ``NMIGEN_IceStorm_env``, if present.
+
     Available overrides:
         * ``verbose``: enables logging of informational messages to standard error.
         * ``read_verilog_opts``: adds options for ``read_verilog`` Yosys command.
@@ -32,6 +35,8 @@ class LatticeICE40Platform(TemplatedPlatform):
         * ``{{name}}.bin``: binary bitstream.
     """
 
+    toolchain = "IceStorm"
+
     device  = abstractproperty()
     package = abstractproperty()
 
index 4749ed67f6123e10450df3ac0e108fc70b878237..30270704a929e8af23704a3b8e6deb52f6908022 100644 (file)
@@ -14,6 +14,9 @@ class Xilinx7SeriesPlatform(TemplatedPlatform):
     Required tools:
         * ``vivado``
 
+    The environment is populated by running the script specified in the environment variable
+    ``NMIGEN_Vivado_env``, if present.
+
     Available overrides:
         * ``script_after_read``: inserts commands after ``read_xdc`` in Tcl script.
         * ``script_after_synth``: inserts commands after ``synth_design`` in Tcl script.
@@ -42,6 +45,8 @@ class Xilinx7SeriesPlatform(TemplatedPlatform):
         * ``{{name}}.bit``: binary bitstream.
     """
 
+    toolchain = "Vivado"
+
     device  = abstractproperty()
     package = abstractproperty()
     speed   = abstractproperty()
index fe4c77548a825638515bc405d1911eea681d9298..8ba4981afe18601cf176b13204c8406c9a6303b7 100644 (file)
@@ -19,6 +19,9 @@ class XilinxSpartan6Platform(TemplatedPlatform):
             * ``par``
             * ``bitgen``
 
+    The environment is populated by running the script specified in the environment variable
+    ``NMIGEN_ISE_env``, if present.
+
     Available overrides:
         * ``script_after_run``: inserts commands after ``run`` in XST script.
         * ``add_constraints``: inserts commands in UCF file.
@@ -45,6 +48,8 @@ class XilinxSpartan6Platform(TemplatedPlatform):
         * ``{{name}}.bit``: binary bitstream.
     """
 
+    toolchain = "ISE"
+
     device  = abstractproperty()
     package = abstractproperty()
     speed   = abstractproperty()