From e1931596ae8b3fe95897316c91eb2aae3e5ca96a Mon Sep 17 00:00:00 2001 From: Krystine Sherwin <93062060+KrystalDelusion@users.noreply.github.com> Date: Wed, 3 Jun 2026 16:53:25 +1200 Subject: [PATCH] CMake: Add wrapper for test-docs Also skip calling `tail` on stubnets log outputs. Fix auxprog prefixes i.e. if we've set `YOSYS_PROGRAM_PREFIX=why`, we shouldn't be trying to call `build/yosys` when building docs (because if we've done a clean build it doesn't exist). I suspect this also affects tests, but I was working on docs when I noticed it. --- CMakeLists.txt | 11 ++++++++--- docs/Makefile | 8 ++++---- docs/source/code_examples/stubnets/Makefile | 1 - 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 287631547..3deacd232 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -500,10 +500,10 @@ set(makefile_vars PROGRAM_PREFIX=${YOSYS_PROGRAM_PREFIX} ABC=$,$,${YOSYS_ABC_EXECUTABLE}> YOSYS=$ - YOSYS_CONFIG=${CMAKE_BINARY_DIR}/yosys-config + YOSYS_CONFIG=${CMAKE_BINARY_DIR}/${YOSYS_PROGRAM_PREFIX}yosys-config YOSYS_FILTERLIB=$<$:$> - YOSYS_SMTBMC=${CMAKE_BINARY_DIR}/yosys-smtbmc - YOSYS_WITNESS=${CMAKE_BINARY_DIR}/yosys-witness + YOSYS_SMTBMC=${CMAKE_BINARY_DIR}/${YOSYS_PROGRAM_PREFIX}yosys-smtbmc + YOSYS_WITNESS=${CMAKE_BINARY_DIR}/${YOSYS_PROGRAM_PREFIX}yosys-witness ) set(makefile_depends # abc is implied via $ @@ -545,6 +545,11 @@ if (NOT YOSYS_BUILD_PYTHON_ONLY) DEPENDS docs-prepare ) endforeach() + add_custom_target(test-docs + COMMAND make test ${makefile_vars} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/docs + DEPENDS ${makefile_depends} + ) endif() # Utilities. diff --git a/docs/Makefile b/docs/Makefile index 948404a79..ce32dd723 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -268,12 +268,12 @@ extract: @cd .. && diff -U 20 backends/functional/smtlib.cc backends/functional/smtlib_rosette.cc \ > docs/source/generated/functional/rosette.diff || true - $(YOSYS) --help | sed "s%$(BUILD_DIR)/yosys%yosys%g" - >source/generated/yosys + @$(YOSYS) --help | sed "s%$(YOSYS)%$(PROGRAM_PREFIX)yosys%g" - >source/generated/yosys @$(YOSYS_SMTBMC) --help >source/generated/yosys-smtbmc @$(YOSYS_WITNESS) --help >source/generated/yosys-witness - @$(YOSYS_CONFIG) --help | sed "s%$(BUILD_DIR)/yosys-config%yosys-config%g" - >source/generated/yosys-config - @$(YOSYS_FILTERLIB) --help 2>source/generated/yosys-filterlib || true - @$(ABC) --help 2>&1 >/dev/null | sed "s%$(BUILD_DIR)/yosys-abc%yosys-abc%g" - >source/generated/yosys-abc + @$(YOSYS_CONFIG) --help | sed "s%$(YOSYS_CONFIG)%$(PROGRAM_PREFIX)yosys-config%g" - >source/generated/yosys-config + @$(YOSYS_FILTERLIB) --help 2>&1 >/dev/null | sed "s%filterlib%$(PROGRAM_PREFIX)yosys-filterlib%g" - >source/generated/yosys-filterlib + @$(ABC) --help 2>&1 >/dev/null | sed "s%$(ABC)%$(PROGRAM_PREFIX)yosys-abc%g" - >source/generated/yosys-abc .PHONY: gen gen: diff --git a/docs/source/code_examples/stubnets/Makefile b/docs/source/code_examples/stubnets/Makefile index 334daead0..cefaf36ce 100644 --- a/docs/source/code_examples/stubnets/Makefile +++ b/docs/source/code_examples/stubnets/Makefile @@ -10,7 +10,6 @@ test: stubnets.so @$(YOSYS) -ql test1.log -m ./stubnets.so test.v -p "stubnets" >/dev/null 2>&1 @$(YOSYS) -ql test2.log -m ./stubnets.so test.v -p "opt; stubnets" >/dev/null 2>&1 @$(YOSYS) -ql test3.log -m ./stubnets.so test.v -p "techmap; opt; stubnets -report_bits" >/dev/null 2>&1 - @tail test1.log test2.log test3.log stubnets.so: stubnets.cc @$(YOSYS_CONFIG) --exec --cxx --cxxflags --ldflags -o $@ -shared $^ --ldlibs >/dev/null 2>&1