Skip to content

Commit f68bfac

Browse files
committed
Validate the prerequisites before building
To prevent users from building shecc without certain required packages, these changes modify the build system to check for prerequisites before building. The changes introduce a new .mk file called "check.mk". The build system includes this file so that it lists all necessary tools, verify the existence of their executables, and aborts the build if any required tool is missing. Additionally, these changes modify main.yml to install all necessary tools for the host-arm build, so the build won't fail due to missing packages. Close #44
1 parent 032516b commit f68bfac

File tree

5 files changed

+16
-13
lines changed

5 files changed

+16
-13
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
githubToken: ${{ github.token }}
4040
install: |
4141
apt-get update -qq -y
42-
apt-get install -yqq build-essential
42+
apt-get install -yqq build-essential graphviz jq
4343
run: |
4444
make config ARCH=arm
4545
make check || exit 1

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ ifeq (,$(filter $(ARCH),$(ARCHS)))
4242
$(error Support ARM and RISC-V only. Select the target with "ARCH=arm" or "ARCH=riscv")
4343
endif
4444
include mk/$(ARCH).mk
45+
include mk/check.mk
4546

4647
config:
4748
$(Q)ln -s $(PWD)/$(SRCDIR)/$(ARCH)-codegen.c $(SRCDIR)/codegen.c

mk/arm.mk

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
ifeq ($(HOST_ARCH),armv7l) # detect ARMv7-A only and assume Linux-compatible
22
TARGET_EXEC :=
33
else
4-
TARGET_EXEC = qemu-arm
5-
TARGET_EXEC := $(shell which $(TARGET_EXEC))
6-
ifndef TARGET_EXEC
7-
$(warning "no qemu-arm found. Please check package installation")
8-
ARM_EXEC = echo WARN: unable to run
9-
endif
4+
ARCH_EXEC = qemu-arm
5+
TARGET_EXEC := $(shell which $(ARCH_EXEC))
106
endif
117

128
export TARGET_EXEC

mk/check.mk

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Check the prerequisites
2+
PREREQ_LIST := dot jq $(ARCH_EXEC)
3+
PREREQ_EXEC := $(shell which $(PREREQ_LIST))
4+
PREREQ_MISSING := $(filter-out $(notdir $(PREREQ_EXEC)),$(PREREQ_LIST))
5+
6+
ifdef PREREQ_MISSING
7+
$(warning "Necessary packages: $(PREREQ_LIST)")
8+
$(warning "Missing packages: $(PREREQ_MISSING)")
9+
$(error "Please check package installation")
10+
endif

mk/riscv.mk

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
TARGET_EXEC = qemu-riscv32
2-
TARGET_EXEC := $(shell which $(TARGET_EXEC))
3-
ifndef TARGET_EXEC
4-
$(warning "no qemu-riscv32 found. Please check package installation")
5-
TARGET_EXEC = echo WARN: unable to run
6-
endif
1+
ARCH_EXEC = qemu-riscv32
2+
TARGET_EXEC := $(shell which $(ARCH_EXEC))
73

84
export TARGET_EXEC
95

0 commit comments

Comments
 (0)