Skip to content

Commit ecd2a17

Browse files
committed
make: check if binaries are valid before continuing
The current logic in variables.mk results in OPENROAD_EXE and YOSYS_EXE to always be set to something, either the absolute path to tools/install or the value from the parent env. With this behavior, when calling make versions.txt the if statements are always true and the "not available" is never printed to the versions.txt file. If the bins are not valid it just prints an empty string. Before this change, calling make versions.txt would fail silently ($? == 0) and other make commands would fail when trying to run openroad or yosys. After this change, calling any make command without having a valid openroad or yosys binary will fail with an error message, which is the same behaviour already implemented for klayout. Signed-off-by: Vitor Bandeira <[email protected]>
1 parent 82a5c44 commit ecd2a17

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

flow/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,9 @@ $(foreach block,$(BLOCKS),$(eval $(WORK_HOME)/results/$(PLATFORM)/$(DESIGN_NICKN
184184
.PHONY: versions.txt
185185
versions.txt:
186186
mkdir -p $(OBJECTS_DIR)
187-
@echo "yosys $(if $(YOSYS_EXE),$(shell $(YOSYS_EXE) -V 2>&1),not available)" > $(OBJECTS_DIR)/$@
188-
@echo "openroad $(if $(OPENROAD_EXE),$(shell $(OPENROAD_EXE) -version 2>&1),not available)" >> $(OBJECTS_DIR)/$@
189-
@echo "klayout $(if $(KLAYOUT_CMD),$(shell $(KLAYOUT_CMD) -zz -v 2>&1),not available)" >> $(OBJECTS_DIR)/$@
187+
@echo "yosys $(shell $(YOSYS_EXE) -V 2>&1)" > $(OBJECTS_DIR)/$@
188+
@echo "openroad $(shell $(OPENROAD_EXE) -version 2>&1)" >> $(OBJECTS_DIR)/$@
189+
@echo "klayout $(shell $(KLAYOUT_CMD) -zz -v 2>&1)" >> $(OBJECTS_DIR)/$@
190190

191191
# Pre-process libraries
192192
# ==============================================================================

flow/scripts/variables.mk

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ else
9797
export OPENSTA_EXE ?= $(abspath $(FLOW_HOME)/../tools/install/OpenROAD/bin/sta)
9898
endif
9999

100+
OPENROAD_IS_VALID := $(if $(OPENROAD_EXE),$(shell test -x $(OPENROAD_EXE) && echo "true"),)
101+
ifneq ($(strip $(OPENROAD_IS_VALID)),true)
102+
$(error OPENROAD_EXE is set to '$(OPENROAD_EXE)', but it is either not found or not executable.)
103+
endif
104+
100105
export OPENROAD_ARGS = -no_init -threads $(NUM_CORES) $(OR_ARGS)
101106
export OPENROAD_CMD = $(OPENROAD_EXE) -exit $(OPENROAD_ARGS)
102107
export OPENROAD_NO_EXIT_CMD = $(OPENROAD_EXE) $(OPENROAD_ARGS)
@@ -109,6 +114,11 @@ else
109114
endif
110115
export YOSYS_EXE
111116

117+
YOSYS_IS_VALID := $(if $(YOSYS_EXE),$(shell test -x $(YOSYS_EXE) && echo "true"),)
118+
ifneq ($(strip $(YOSYS_IS_VALID)),true)
119+
$(error YOSYS_EXE is set to '$(YOSYS_EXE)', but it is either not found or not executable.)
120+
endif
121+
112122
# Use locally installed and built klayout if it exists, otherwise use klayout in path
113123
KLAYOUT_DIR = $(abspath $(FLOW_HOME)/../tools/install/klayout/)
114124
KLAYOUT_BIN_FROM_DIR = $(KLAYOUT_DIR)/klayout

0 commit comments

Comments
 (0)