build.plat: source a script with toolchain environment.

Fixes #131.
This commit is contained in:
whitequark 2019-07-07 00:41:03 +00:00
parent 744154ebb5
commit 146f3cb684
5 changed files with 23 additions and 0 deletions

View file

@ -184,6 +184,7 @@ class Platform(ResourceManager, metaclass=ABCMeta):
class TemplatedPlatform(Platform): class TemplatedPlatform(Platform):
toolchain = abstractproperty()
file_templates = abstractproperty() file_templates = abstractproperty()
command_templates = abstractproperty() command_templates = abstractproperty()
@ -191,11 +192,13 @@ class TemplatedPlatform(Platform):
"build_{{name}}.sh": """ "build_{{name}}.sh": """
# {{autogenerated}} # {{autogenerated}}
set -e{{verbose("x")}} set -e{{verbose("x")}}
[ -n "$NMIGEN_{{platform.toolchain}}_env" ] && . "$NMIGEN_{{platform.toolchain}}_env"
{{emit_commands("sh")}} {{emit_commands("sh")}}
""", """,
"build_{{name}}.bat": """ "build_{{name}}.bat": """
@rem {{autogenerated}} @rem {{autogenerated}}
{{quiet("@echo off")}} {{quiet("@echo off")}}
if defined NMIGEN_{{platform.toolchain}}_env call %NMIGEN_{{platform.toolchain}}_env%
{{emit_commands("bat")}} {{emit_commands("bat")}}
""", """,
} }

View file

@ -14,6 +14,9 @@ class LatticeECP5Platform(TemplatedPlatform):
* ``nextpnr-ecp5`` * ``nextpnr-ecp5``
* ``ecppack`` * ``ecppack``
The environment is populated by running the script specified in the environment variable
``NMIGEN_Trellis_env``, if present.
Available overrides: Available overrides:
* ``verbose``: enables logging of informational messages to standard error. * ``verbose``: enables logging of informational messages to standard error.
* ``read_verilog_opts``: adds options for ``read_verilog`` Yosys command. * ``read_verilog_opts``: adds options for ``read_verilog`` Yosys command.
@ -33,6 +36,8 @@ class LatticeECP5Platform(TemplatedPlatform):
* ``{{name}}.svf``: JTAG programming vector. * ``{{name}}.svf``: JTAG programming vector.
""" """
toolchain = "Trellis"
device = abstractproperty() device = abstractproperty()
package = abstractproperty() package = abstractproperty()
speed = abstractproperty() speed = abstractproperty()

View file

@ -14,6 +14,9 @@ class LatticeICE40Platform(TemplatedPlatform):
* ``nextpnr-ice40`` * ``nextpnr-ice40``
* ``icepack`` * ``icepack``
The environment is populated by running the script specified in the environment variable
``NMIGEN_IceStorm_env``, if present.
Available overrides: Available overrides:
* ``verbose``: enables logging of informational messages to standard error. * ``verbose``: enables logging of informational messages to standard error.
* ``read_verilog_opts``: adds options for ``read_verilog`` Yosys command. * ``read_verilog_opts``: adds options for ``read_verilog`` Yosys command.
@ -32,6 +35,8 @@ class LatticeICE40Platform(TemplatedPlatform):
* ``{{name}}.bin``: binary bitstream. * ``{{name}}.bin``: binary bitstream.
""" """
toolchain = "IceStorm"
device = abstractproperty() device = abstractproperty()
package = abstractproperty() package = abstractproperty()

View file

@ -14,6 +14,9 @@ class Xilinx7SeriesPlatform(TemplatedPlatform):
Required tools: Required tools:
* ``vivado`` * ``vivado``
The environment is populated by running the script specified in the environment variable
``NMIGEN_Vivado_env``, if present.
Available overrides: Available overrides:
* ``script_after_read``: inserts commands after ``read_xdc`` in Tcl script. * ``script_after_read``: inserts commands after ``read_xdc`` in Tcl script.
* ``script_after_synth``: inserts commands after ``synth_design`` 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. * ``{{name}}.bit``: binary bitstream.
""" """
toolchain = "Vivado"
device = abstractproperty() device = abstractproperty()
package = abstractproperty() package = abstractproperty()
speed = abstractproperty() speed = abstractproperty()

View file

@ -19,6 +19,9 @@ class XilinxSpartan6Platform(TemplatedPlatform):
* ``par`` * ``par``
* ``bitgen`` * ``bitgen``
The environment is populated by running the script specified in the environment variable
``NMIGEN_ISE_env``, if present.
Available overrides: Available overrides:
* ``script_after_run``: inserts commands after ``run`` in XST script. * ``script_after_run``: inserts commands after ``run`` in XST script.
* ``add_constraints``: inserts commands in UCF file. * ``add_constraints``: inserts commands in UCF file.
@ -45,6 +48,8 @@ class XilinxSpartan6Platform(TemplatedPlatform):
* ``{{name}}.bit``: binary bitstream. * ``{{name}}.bit``: binary bitstream.
""" """
toolchain = "ISE"
device = abstractproperty() device = abstractproperty()
package = abstractproperty() package = abstractproperty()
speed = abstractproperty() speed = abstractproperty()