From: whitequark Date: Sun, 7 Jul 2019 00:41:03 +0000 (+0000) Subject: build.plat: source a script with toolchain environment. X-Git-Tag: locally_working~107 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=146f3cb6849916d4e69252c019e2a22975243889;p=nmigen.git build.plat: source a script with toolchain environment. Fixes #131. --- diff --git a/nmigen/build/plat.py b/nmigen/build/plat.py index d7e98dc..9a21bad 100644 --- a/nmigen/build/plat.py +++ b/nmigen/build/plat.py @@ -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")}} """, } diff --git a/nmigen/vendor/lattice_ecp5.py b/nmigen/vendor/lattice_ecp5.py index 2993dd1..b65a628 100644 --- a/nmigen/vendor/lattice_ecp5.py +++ b/nmigen/vendor/lattice_ecp5.py @@ -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() diff --git a/nmigen/vendor/lattice_ice40.py b/nmigen/vendor/lattice_ice40.py index e296ce6..57d90e4 100644 --- a/nmigen/vendor/lattice_ice40.py +++ b/nmigen/vendor/lattice_ice40.py @@ -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() diff --git a/nmigen/vendor/xilinx_7series.py b/nmigen/vendor/xilinx_7series.py index 4749ed6..3027070 100644 --- a/nmigen/vendor/xilinx_7series.py +++ b/nmigen/vendor/xilinx_7series.py @@ -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() diff --git a/nmigen/vendor/xilinx_spartan6.py b/nmigen/vendor/xilinx_spartan6.py index fe4c775..8ba4981 100644 --- a/nmigen/vendor/xilinx_spartan6.py +++ b/nmigen/vendor/xilinx_spartan6.py @@ -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()