diff options
Diffstat (limited to 'mk')
| -rw-r--r-- | mk/cocotb.mk | 44 | ||||
| -rw-r--r-- | mk/tools.mk | 1 |
2 files changed, 35 insertions, 10 deletions
diff --git a/mk/cocotb.mk b/mk/cocotb.mk index 7187773..240d808 100644 --- a/mk/cocotb.mk +++ b/mk/cocotb.mk @@ -1,17 +1,38 @@ -targets += test +targets += pydoc test target/test/prepare = $(prepare_verilator_target) cocotb_modules = $(call per_target,cocotb_modules) +pydoc_modules = $(call per_target,pydoc_modules) -define target/test/setup - $(setup_verilator_target) +cocotb_pythonpath_decl = PYTHONPATH="$(subst $(space),:,$(strip $(cocotb_pythonpath)) $$PYTHONPATH)" + +cocotb_pythonpath = \ + $(addprefix $(src)/, \ + $(foreach dep,$(dep_tree/$(rule_top)), \ + $(call core_paths,$(dep),cocotb_paths))) +define cocotb_setup_common $$(call target_var,cocotb_modules) := $$(strip $$(core_info/$$(rule_top)/cocotb_modules)) ifeq (,$$(cocotb_modules)) $$(error core '$$(rule_top)' has no cocotb test modules) endif +endef + +define target/pydoc/setup + $(cocotb_setup_common) + + $$(call target_var,pydoc_modules) := $$(strip $$(core_info/$$(rule_top)/pydoc_modules)) + + ifeq (,$$(pydoc_modules)) + $$(error core '$$(rule_top)' has no modules for pydoc to cover) + endif +endef + +define target/test/setup + $(setup_verilator_target) + $(cocotb_setup_common) $$(call target_var,vl_main) = $$(cocotb_share)/lib/verilator/verilator.cpp $$(call target_var,vl_flags) += --vpi --public-flat-rw @@ -20,6 +41,15 @@ define target/test/setup -lcocotbvpi_verilator -lgpi -lcocotb -lgpilog -lcocotbutils $$(cocotb_libpython) endef +define target/pydoc/rules + .PHONY: $$(rule_top_path)/pydoc + + $$(rule_top_path)/pydoc: | $$(obj) + $$(call run,PYDOC) cd $$(obj) && $$(cocotb_pythonpath_decl) $$(PYDOC3) -w $$(pydoc_modules) + + $(call target_entrypoint,$$(rule_top_path)/pydoc) +endef + define target/test/rules $(verilator_target_rules) @@ -28,14 +58,8 @@ define target/test/rules $$(rule_top_path)/test &: $$(vtop_exe) $$(call core_objs,$$(rule_top),obj_deps) | $$(obj) $$(call run_no_err,COCOTB) cd $$(obj) && rm -f log.txt results.xml && \ LIBPYTHON_LOC=$$(cocotb_libpython) COCOTB_RESULTS_FILE=results.xml \ - PYTHONPATH="$$(subst $$(space),:,$$(strip $$(cocotb_pythonpath) $$$$PYTHONPATH))" \ - MODULE=$$(subst $$(space),$$(comma),$$(cocotb_modules)) \ + $$(cocotb_pythonpath_decl) MODULE=$$(subst $$(space),$$(comma),$$(cocotb_modules)) \ $$(src)/$$< | tee log.txt $(call target_entrypoint,$$(rule_top_path)/test) endef - -cocotb_pythonpath = \ - $(addprefix $(src)/, \ - $(foreach dep,$(dep_tree/$(rule_top)), \ - $(call core_paths,$(dep),cocotb_paths))) diff --git a/mk/tools.mk b/mk/tools.mk index c01c2de..177b956 100644 --- a/mk/tools.mk +++ b/mk/tools.mk @@ -5,6 +5,7 @@ define find_tools_lazy $(call find_command_lazy,ninja,NINJA) $(call find_command_lazy,peakrdl,PEAKRDL) $(call find_command_lazy,pkg-config,PKG_CONFIG) + $(call find_command_lazy,pydoc3,PYDOC3) $(call find_command_lazy,python3,PYTHON3) $(call find_command_lazy,qsys-generate,QSYS_GENERATE) $(call find_command_lazy,quartus,QUARTUS) |
