Skip to content

Commit f270d6e

Browse files
committed
testsuite: Make sure we prefix the ghcconfig with a hash
Ideally, ghc should just be able to produce this data outright, without having to resort to a separate tool. This seems highly questionable. It would be much better if ghc should emitted this information in a structured way.
1 parent aed1df3 commit f270d6e

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

testsuite/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ tmp.d
6060
*.so
6161
*bindisttest_install___dir_bin_ghc.mk
6262
*bindisttest_install___dir_bin_ghc.exe.mk
63+
mk/*_ghcconfig*_bin_ghc*.mk
64+
mk/*_ghcconfig*_bin_ghc*.exe.mk
65+
mk/*_ghcconfig*_test___spaces_ghc*.mk
66+
mk/*_ghcconfig*_test___spaces_ghc*.exe.mk
6367
mk/ghcconfig*_bin_ghc*.mk
6468
mk/ghcconfig*_bin_ghc*.exe.mk
6569
mk/ghcconfig*_test___spaces_ghc*.mk

testsuite/mk/boilerplate.mk

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,18 @@ $(TOP)/ghc-config/ghc-config : $(TOP)/ghc-config/ghc-config.hs
260260
empty=
261261
space=$(empty) $(empty)
262262
ifeq "$(ghc_config_mk)" ""
263-
ghc_config_mk = $(TOP)/mk/ghcconfig$(subst $(space),_,$(subst :,_,$(subst /,_,$(subst \,_,$(TEST_HC))))).mk
263+
sanitized_hc := $(subst $(space),_,$(subst :,_,$(subst /,_,$(subst \,_,$(TEST_HC)))))
264+
test_hc_hash := $(shell \
265+
if command -v openssl >/dev/null 2>&1; then \
266+
openssl dgst -sha256 $(TEST_HC) | awk '{print substr($$2, 1, 8)}'; \
267+
elif command -v sha256sum >/dev/null 2>&1; then \
268+
sha256sum $(TEST_HC) | awk '{print substr($$1, 1, 8)}'; \
269+
elif command -v shasum >/dev/null 2>&1; then \
270+
shasum -a 256 $(TEST_HC) | awk '{print substr($$1, 1, 8)}'; \
271+
else \
272+
echo "no_hash"; \
273+
fi)
274+
ghc_config_mk = $(TOP)/mk/$(test_hc_hash)_ghcconfig$(sanitized_hc).mk
264275

265276
$(ghc_config_mk) : $(TOP)/ghc-config/ghc-config
266277
$(TOP)/ghc-config/ghc-config "$(TEST_HC)" >"$@"; if [ "$$?" != "0" ]; then $(RM) "$@"; exit 1; fi

0 commit comments

Comments
 (0)