Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions edalize/flows/edaflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,14 +270,11 @@ def add_scripts(self, depends, hook_name):
hooks = self.edam.get("hooks", {})
for script in hooks.get(hook_name, []):

# _env = self.env.copy()
# if 'env' in script:
# _env.update(script['env'])

targets = script["name"]
command = script["cmd"]
# FIXME : Add env vars
self.commands.add(command, [targets], [last_script])
self.commands.add(
command, [targets], [last_script], variables=script.get("env", {})
)

last_script = script["name"]
self.commands.add([], [hook_name], [last_script])
Expand Down
27 changes: 27 additions & 0 deletions tests/test_flow_hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from .edalize_common import FILES, param_gen
from .edalize_flow_common import get_flow


def test_hook_env(tmp_path):
edam = {
"name": "design",
"files": FILES,
"parameters": param_gen(["plusarg", "vlogdefine", "vlogparam"]),
"flow_options": {"tool": "icarus"},
"toplevel": "top_module",
"hooks": {
"pre_build": [
{
"name": "sample_pre_build",
"cmd": ["echo", "hello"],
"env": {"FOO": "bar"},
}
]
},
}

flow = get_flow("sim")(edam, tmp_path)
flow.configure()

makefile = (tmp_path / "Makefile").read_text()
assert "env FOO=bar echo hello" in makefile
Loading