Skip to content

Commit

Permalink
Add pre_build as prerequisite to all build targets
Browse files Browse the repository at this point in the history
  • Loading branch information
olofk committed Jan 23, 2025
1 parent 8a3f4f2 commit 77e39e0
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 32 deletions.
12 changes: 7 additions & 5 deletions edalize/flows/edaflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,13 @@ def merge_edam(a, b):

# This is an input node. Inject dependency on pre_build scripts
if not node.deps:
# Inject pre-build scripts before the first command
# that the node executes. Note that this isn't
# technically correct since the first command in
# the list might not be the first command executed
node.inst.commands.commands[0].order_only_deps = ["pre_build"]
# Inject pre-build scripts as an order-only dependency
# before every command that the node executes during build. This is
# probably safe, but might cause pre-build scripts to
# be executed several times
for c in node.inst.commands.commands:
if not "run" in c.targets:
c.order_only_deps.insert(0, "pre_build")
self.commands.commands += node.inst.commands.commands

def add_scripts(self, depends, hook_name):
Expand Down
2 changes: 1 addition & 1 deletion edalize/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def __init__(
self.commands = commands
self.targets = targets
self.depends = depends
self.order_only_deps = order_only_deps
self.order_only_deps = order_only_deps[:]
self.variables = variables

def __init__(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/flows/sim/with_cocotb/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pre_build:
Vtop.mk: design.vc sv_file.sv vlog_file.v vlog_with_define.v vlog05_file.v vlog_incfile another_sv_file.sv | pre_build
$(EDALIZE_LAUNCHER) verilator -f design.vc `cocotb-config --share`/lib/verilator/verilator.cpp

Vtop: Vtop.mk c_file.c cpp_file.cpp
Vtop: Vtop.mk c_file.c cpp_file.cpp | pre_build
$(EDALIZE_LAUNCHER) make -f Vtop.mk

post_build: Vtop
Expand Down
10 changes: 5 additions & 5 deletions tests/test_vivado/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ pre_build:
test_vivado_0.xpr: test_vivado_0.tcl sdc_file sv_file.sv tcl_file.tcl vlog_file.v vlog_with_define.v vlog05_file.v vlog_incfile vhdl_file.vhd vhdl_lfile vhdl2008_file xci_file.xci xdc_file.xdc bootrom.mem another_sv_file.sv | pre_build
$(EDALIZE_LAUNCHER) vivado -notrace -mode batch -source test_vivado_0.tcl

test_vivado_0.v test_vivado_0.edn: test_vivado_0_synth.tcl test_vivado_0_netlist.tcl | test_vivado_0.xpr
test_vivado_0.v test_vivado_0.edn: test_vivado_0_synth.tcl test_vivado_0_netlist.tcl | pre_build test_vivado_0.xpr
$(EDALIZE_LAUNCHER) vivado -notrace -mode batch -source test_vivado_0_synth.tcl test_vivado_0_netlist.tcl test_vivado_0.xpr

synth: test_vivado_0.v test_vivado_0.edn
synth: test_vivado_0.v test_vivado_0.edn | pre_build

test_vivado_0.bit: test_vivado_0_synth.tcl test_vivado_0_run.tcl | test_vivado_0.xpr
test_vivado_0.bit: test_vivado_0_synth.tcl test_vivado_0_run.tcl | pre_build test_vivado_0.xpr
$(EDALIZE_LAUNCHER) vivado -notrace -mode batch -source test_vivado_0_synth.tcl test_vivado_0_run.tcl test_vivado_0.xpr

build-gui: test_vivado_0.xpr
build-gui: test_vivado_0.xpr | pre_build
$(EDALIZE_LAUNCHER) vivado test_vivado_0.xpr

pgm: test_vivado_0_pgm.tcl test_vivado_0.bit
pgm: test_vivado_0_pgm.tcl test_vivado_0.bit | pre_build
$(EDALIZE_LAUNCHER) vivado -quiet -nolog -notrace -mode batch -source test_vivado_0_pgm.tcl -tclargs xc7a35tcsg324-1 test_vivado_0.bit

post_build: test_vivado_0.bit
Expand Down
10 changes: 5 additions & 5 deletions tests/test_vivado/board_file/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ pre_build:
test_vivado_0.xpr: test_vivado_0.tcl sdc_file sv_file.sv tcl_file.tcl vlog_file.v vlog_with_define.v vlog05_file.v vlog_incfile vhdl_file.vhd vhdl_lfile vhdl2008_file xci_file.xci xdc_file.xdc bootrom.mem another_sv_file.sv | pre_build
$(EDALIZE_LAUNCHER) vivado -notrace -mode batch -source test_vivado_0.tcl

test_vivado_0.v test_vivado_0.edn: test_vivado_0_synth.tcl test_vivado_0_netlist.tcl | test_vivado_0.xpr
test_vivado_0.v test_vivado_0.edn: test_vivado_0_synth.tcl test_vivado_0_netlist.tcl | pre_build test_vivado_0.xpr
$(EDALIZE_LAUNCHER) vivado -notrace -mode batch -source test_vivado_0_synth.tcl test_vivado_0_netlist.tcl test_vivado_0.xpr

synth: test_vivado_0.v test_vivado_0.edn
synth: test_vivado_0.v test_vivado_0.edn | pre_build

test_vivado_0.bit: test_vivado_0_synth.tcl test_vivado_0_run.tcl | test_vivado_0.xpr
test_vivado_0.bit: test_vivado_0_synth.tcl test_vivado_0_run.tcl | pre_build test_vivado_0.xpr
$(EDALIZE_LAUNCHER) vivado -notrace -mode batch -source test_vivado_0_synth.tcl test_vivado_0_run.tcl test_vivado_0.xpr

build-gui: test_vivado_0.xpr
build-gui: test_vivado_0.xpr | pre_build
$(EDALIZE_LAUNCHER) vivado test_vivado_0.xpr

pgm: test_vivado_0_pgm.tcl test_vivado_0.bit
pgm: test_vivado_0_pgm.tcl test_vivado_0.bit | pre_build
$(EDALIZE_LAUNCHER) vivado -quiet -nolog -notrace -mode batch -source test_vivado_0_pgm.tcl -tclargs xc7a35tcsg324-1 test_vivado_0.bit

post_build: test_vivado_0.bit
Expand Down
10 changes: 5 additions & 5 deletions tests/test_vivado/edif_netlist/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ pre_build:
test_vivado_0.xpr: test_vivado_0.tcl netlist.edif netlist.edif | pre_build
$(EDALIZE_LAUNCHER) vivado -notrace -mode batch -source test_vivado_0.tcl

test_vivado_0.v test_vivado_0.edn: test_vivado_0_synth.tcl test_vivado_0_netlist.tcl | test_vivado_0.xpr
test_vivado_0.v test_vivado_0.edn: test_vivado_0_synth.tcl test_vivado_0_netlist.tcl | pre_build test_vivado_0.xpr
$(EDALIZE_LAUNCHER) vivado -notrace -mode batch -source test_vivado_0_synth.tcl test_vivado_0_netlist.tcl test_vivado_0.xpr

synth: test_vivado_0.v test_vivado_0.edn
synth: test_vivado_0.v test_vivado_0.edn | pre_build

test_vivado_0.bit: test_vivado_0_synth.tcl test_vivado_0_run.tcl | test_vivado_0.xpr
test_vivado_0.bit: test_vivado_0_synth.tcl test_vivado_0_run.tcl | pre_build test_vivado_0.xpr
$(EDALIZE_LAUNCHER) vivado -notrace -mode batch -source test_vivado_0_synth.tcl test_vivado_0_run.tcl test_vivado_0.xpr

build-gui: test_vivado_0.xpr
build-gui: test_vivado_0.xpr | pre_build
$(EDALIZE_LAUNCHER) vivado test_vivado_0.xpr

pgm: test_vivado_0_pgm.tcl test_vivado_0.bit
pgm: test_vivado_0_pgm.tcl test_vivado_0.bit | pre_build
$(EDALIZE_LAUNCHER) vivado -quiet -nolog -notrace -mode batch -source test_vivado_0_pgm.tcl -tclargs xc7a35tcsg324-1 test_vivado_0.bit

post_build: test_vivado_0.bit
Expand Down
10 changes: 5 additions & 5 deletions tests/test_vivado/edif_netlist_no_link_design/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ pre_build:
test_vivado_0.xpr: test_vivado_0.tcl netlist.edif netlist.edif | pre_build
$(EDALIZE_LAUNCHER) vivado -notrace -mode batch -source test_vivado_0.tcl

test_vivado_0.v test_vivado_0.edn: test_vivado_0_synth.tcl test_vivado_0_netlist.tcl | test_vivado_0.xpr
test_vivado_0.v test_vivado_0.edn: test_vivado_0_synth.tcl test_vivado_0_netlist.tcl | pre_build test_vivado_0.xpr
$(EDALIZE_LAUNCHER) vivado -notrace -mode batch -source test_vivado_0_synth.tcl test_vivado_0_netlist.tcl test_vivado_0.xpr

synth: test_vivado_0.v test_vivado_0.edn
synth: test_vivado_0.v test_vivado_0.edn | pre_build

test_vivado_0.bit: test_vivado_0_synth.tcl test_vivado_0_run.tcl | test_vivado_0.xpr
test_vivado_0.bit: test_vivado_0_synth.tcl test_vivado_0_run.tcl | pre_build test_vivado_0.xpr
$(EDALIZE_LAUNCHER) vivado -notrace -mode batch -source test_vivado_0_synth.tcl test_vivado_0_run.tcl test_vivado_0.xpr

build-gui: test_vivado_0.xpr
build-gui: test_vivado_0.xpr | pre_build
$(EDALIZE_LAUNCHER) vivado test_vivado_0.xpr

pgm: test_vivado_0_pgm.tcl test_vivado_0.bit
pgm: test_vivado_0_pgm.tcl test_vivado_0.bit | pre_build
$(EDALIZE_LAUNCHER) vivado -quiet -nolog -notrace -mode batch -source test_vivado_0_pgm.tcl -tclargs xc7a35tcsg324-1 test_vivado_0.bit

post_build: test_vivado_0.bit
Expand Down
10 changes: 5 additions & 5 deletions tests/test_vivado/minimal/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ pre_build:
test_vivado_minimal_0.xpr: test_vivado_minimal_0.tcl | pre_build
$(EDALIZE_LAUNCHER) vivado -notrace -mode batch -source test_vivado_minimal_0.tcl

test_vivado_minimal_0.v test_vivado_minimal_0.edn: test_vivado_minimal_0_synth.tcl test_vivado_minimal_0_netlist.tcl | test_vivado_minimal_0.xpr
test_vivado_minimal_0.v test_vivado_minimal_0.edn: test_vivado_minimal_0_synth.tcl test_vivado_minimal_0_netlist.tcl | pre_build test_vivado_minimal_0.xpr
$(EDALIZE_LAUNCHER) vivado -notrace -mode batch -source test_vivado_minimal_0_synth.tcl test_vivado_minimal_0_netlist.tcl test_vivado_minimal_0.xpr

synth: test_vivado_minimal_0.v test_vivado_minimal_0.edn
synth: test_vivado_minimal_0.v test_vivado_minimal_0.edn | pre_build

test_vivado_minimal_0.bit: test_vivado_minimal_0_synth.tcl test_vivado_minimal_0_run.tcl | test_vivado_minimal_0.xpr
test_vivado_minimal_0.bit: test_vivado_minimal_0_synth.tcl test_vivado_minimal_0_run.tcl | pre_build test_vivado_minimal_0.xpr
$(EDALIZE_LAUNCHER) vivado -notrace -mode batch -source test_vivado_minimal_0_synth.tcl test_vivado_minimal_0_run.tcl test_vivado_minimal_0.xpr

build-gui: test_vivado_minimal_0.xpr
build-gui: test_vivado_minimal_0.xpr | pre_build
$(EDALIZE_LAUNCHER) vivado test_vivado_minimal_0.xpr

pgm: test_vivado_minimal_0_pgm.tcl test_vivado_minimal_0.bit
pgm: test_vivado_minimal_0_pgm.tcl test_vivado_minimal_0.bit | pre_build
$(EDALIZE_LAUNCHER) vivado -quiet -nolog -notrace -mode batch -source test_vivado_minimal_0_pgm.tcl -tclargs xc7a35tcsg324-1 test_vivado_minimal_0.bit

post_build: test_vivado_minimal_0.bit
Expand Down

0 comments on commit 77e39e0

Please sign in to comment.