@@ -36,15 +36,30 @@ SCIMARK2_SHA1 := de278c5b8cef84ab6dda41855052c7bfef919e36
3636
3737SHELL_HACK := $(shell mkdir -p $(BIN_DIR ) /linux-x86-softfp $(BIN_DIR ) /riscv32 $(BIN_DIR ) /linux-image)
3838
39+ # $(1): tag of GitHub releases
40+ # $(2): name of GitHub releases
41+ # $(3): name showing in terminal
42+ define fetch-sha1
43+ $(if $(wildcard $(BIN_DIR ) /$(2 ) ) , \
44+ $(eval $(info $(3 ) is found. Skipping downloading.) ) , \
45+ $(eval LATEST_RELEASE := $(shell wget -q https://api.github.com/repos/sysprog21/rv32emu-prebuilt/releases -O- \
46+ | grep '"tag_name"' \
47+ | grep "$(1 ) " \
48+ | head -n 1 \
49+ | sed -E 's/.* "tag_name": "([^"]+) ".* /\1/') ) \
50+ )
51+ endef
52+
3953ifeq ($(call has, PREBUILT) , 1)
40- ifeq ($(call has, SYSTEM) , 1)
41- LATEST_RELEASE := $(shell wget -q https://api.github.com/repos/sysprog21/rv32emu-prebuilt/releases -O- | grep '"tag_name"' | grep "Linux-Image" | head -n 1 | sed -E 's/.* "tag_name": "([^"]+) ".*/\1/')
42- else ifeq ($(call has, ARCH_TEST), 1)
43- LATEST_RELEASE := $(shell wget -q https://api.github.com/repos/sysprog21/rv32emu-prebuilt/releases -O- | grep '"tag_name"' | grep "sail" | head -n 1 | sed -E 's/.* "tag_name": "([^"]+) ".*/\1/')
44- else
45- LATEST_RELEASE := $(shell wget -q https://api.github.com/repos/sysprog21/rv32emu-prebuilt/releases -O- | grep '"tag_name"' | grep "ELF" | head -n 1 | sed -E 's/.* "tag_name": "([^"]+) ".*/\1/')
46- endif
47- PREBUILT_BLOB_URL = https://github.com/sysprog21/rv32emu-prebuilt/releases/download/$(LATEST_RELEASE )
54+ ifeq ($(call has, SYSTEM), 1)
55+ $(call fetch-releases-tag,Linux-Image,rv32emu-linux-image-prebuilt.tar.gz,Linux image)
56+ else ifeq ($(call has, ARCH_TEST), 1)
57+ $(call fetch-releases-tag,sail,rv32emu-prebuilt-sail-$(HOST_PLATFORM),Sail model)
58+ else
59+ $(call fetch-releases-tag,ELF,rv32emu-prebuilt.tar.gz,Prebuilt benchmark)
60+ endif
61+
62+ PREBUILT_BLOB_URL = https://github.com/sysprog21/rv32emu-prebuilt/releases/download/$(LATEST_RELEASE )
4863else
4964 # Since rv32emu only supports the dynamic binary translation of integer instruction in tiered compilation currently,
5065 # we disable the hardware floating-point and the related SIMD operation of x86.
@@ -95,14 +110,15 @@ endif
95110ifeq ($(call has, ARCH_TEST) , 1)
96111 $(Q)if [ "$(RES)" = "1" ]; then \
97112 $(PRINTF) "\n$(YELLOW)SHA-1 verification failed! Re-fetching prebuilt binaries from \"rv32emu-prebuilt\" ...\n$(NO_COLOR)"; \
98- wget -q --show-progress $(PREBUILT_BLOB_URL)/$(RV32EMU_PREBUILT_TARBALL) -O build/$(RV32EMU_PREBUILT_TARBALL);\
113+ wget -q --show-progress $(PREBUILT_BLOB_URL)/$(RV32EMU_PREBUILT_TARBALL) -O build/$(RV32EMU_PREBUILT_TARBALL); \
99114 else \
100115 $(call notice, [OK]); \
101116 fi
102117else
103118 $(Q)if [ "$(RES)" = "1" ]; then \
104119 $(PRINTF) "\n$(YELLOW)SHA-1 verification failed! Re-fetching prebuilt binaries from \"rv32emu-prebuilt\" ...\n$(NO_COLOR)"; \
105- wget -q --show-progress $(PREBUILT_BLOB_URL)/$(RV32EMU_PREBUILT_TARBALL) -O- | tar -C build --strip-components=1 -xz; \
120+ wget -q --show-progress $(PREBUILT_BLOB_URL)/$(RV32EMU_PREBUILT_TARBALL) -O build/$(RV32EMU_PREBUILT_TARBALL); \
121+ tar --strip-components=1 -zxf build/$(RV32EMU_PREBUILT_TARBALL) -C build; \
106122 else \
107123 $(call notice, [OK]); \
108124 fi
@@ -147,16 +163,28 @@ endif
147163
148164fetch-checksum :
149165ifeq ($(call has, PREBUILT) , 1)
150- $(Q)$(PRINTF) "Fetching SHA-1 of prebuilt binaries ...\n "
166+ $(Q)$(PRINTF) "Fetching SHA-1 of prebuilt binaries ... "
151167ifeq ($(call has, SYSTEM) , 1)
152- $(Q)wget -q -O $(BIN_DIR)/sha1sum-linux-image $(PREBUILT_BLOB_URL)/sha1sum-linux-image
153- $(Q)$(call notice, [OK])
168+ ifeq ($(wildcard $(BIN_DIR)/rv32emu-linux-image-prebuilt.tar.gz),)
169+ $(Q)wget -q -O $(BIN_DIR)/sha1sum-linux-image $(PREBUILT_BLOB_URL)/sha1sum-linux-image
170+ $(Q)$(call notice, [OK])
171+ else
172+ $(Q)$(PRINTF) "Skipped\n"
173+ endif
154174else ifeq ($(call has, ARCH_TEST), 1)
155- $(Q)wget -q -O $(BIN_DIR)/rv32emu-prebuilt-sail-$(HOST_PLATFORM).sha $(PREBUILT_BLOB_URL)/rv32emu-prebuilt-sail-$(HOST_PLATFORM).sha
175+ ifeq ($(wildcard $(BIN_DIR)/rv32emu-prebuilt-sail-$(HOST_PLATFORM)),)
176+ wget -q -O $(BIN_DIR)/rv32emu-prebuilt-sail-$(HOST_PLATFORM).sha $(PREBUILT_BLOB_URL)/rv32emu-prebuilt-sail-$(HOST_PLATFORM).sha
177+ else
178+ $(Q)$(PRINTF) "Skipped\n"
179+ endif
156180else
157- $(Q)wget -q -O $(BIN_DIR)/sha1sum-linux-x86-softfp $(PREBUILT_BLOB_URL)/sha1sum-linux-x86-softfp
158- $(Q)wget -q -O $(BIN_DIR)/sha1sum-riscv32 $(PREBUILT_BLOB_URL)/sha1sum-riscv32
159- $(Q)$(call notice, [OK])
181+ ifeq ($(wildcard $(BIN_DIR)/rv32emu-prebuilt.tar.gz),)
182+ $(Q)wget -q -O $(BIN_DIR)/sha1sum-linux-x86-softfp $(PREBUILT_BLOB_URL)/sha1sum-linux-x86-softfp
183+ $(Q)wget -q -O $(BIN_DIR)/sha1sum-riscv32 $(PREBUILT_BLOB_URL)/sha1sum-riscv32
184+ $(Q)$(call notice, [OK])
185+ else
186+ $(Q)$(PRINTF) "Skipped\n"
187+ endif
160188endif
161189endif
162190
0 commit comments