]> granicus.if.org Git - nethack/commitdiff
try to work around a mingw shortcoming within CI
authornhmall <nhmall@nethack.org>
Sat, 29 Jan 2022 14:20:29 +0000 (09:20 -0500)
committernhmall <nhmall@nethack.org>
Sat, 29 Jan 2022 14:20:29 +0000 (09:20 -0500)
The mingw-w64 version on the CI platform is older and
is missing a sought copy of winres.h.

This attempts to work around that by having the Makefile
create a temporary copy of winres.h in the win/win32 directory
which that windres.exe is already search in. The file is
then immediately removed after windres uses it.

The contents of the temporary winres.h match the contents
of that file that is distributed with the more up-to-date msys2
distribution of mingw-w64.

It won't be known if this workaround solves all the CI issues
with the mingw build until after it is committed and observed.

sys/windows/Makefile.mingw32

index 6533e90d7c8803fd845b3fdbda1e46e3870c2533..9ae38be95ee6ff9f85487e2ea33890889da805b1 100644 (file)
@@ -203,6 +203,11 @@ ifdef CI_COMPILER
 cc = i686-w64-mingw32-gcc.exe
 ld = i686-w64-mingw32-gcc.exe
 rc = windres --target=pe-i386
+# the mingw version on our CI is missing
+# windef.h. This will cause the Makefile.mingw32
+# to put a temporary copy into one of our folders
+# that windres is already looking in.
+MISSING_HEADER = Y
 else
 cc = gcc -c
 ld = gcc
@@ -211,6 +216,7 @@ rc = windres --target=pe-i386
 else # MINGW64
 rc = windres --target=pe-x86-64
 endif
+MISSING_HEADER = N
 endif
 
 #
@@ -730,7 +736,22 @@ $(ONH)/%.o: $(WCURSES)/%.c $(NHLUAH) | $(ONH)
        $(cc) $(CFLAGSNH) $(PDCINCL) $< -o$@
 
 $(NHRES): $(MSWIN)/NetHack.rc $(MSWIN)/NetHack.ico | $(ONH)
+ifeq "$(MISSING_HEADER)" "Y"
+       echo '/**' > $(MSWIN)/winres.h
+       echo ' * This file has no copyright assigned and is placed in the Public Domain.' >> $(MSWIN)/winres.h
+       echo ' * This file is part of the mingw-w64 runtime package.' >> $(MSWIN)/winres.h
+       echo ' * No warranty is given; refer to the file DISCLAIMER.PD within this package.' >> $(MSWIN)/winres.h
+       echo ' */' >> $(MSWIN)/winres.h
+       echo '#include <winresrc.h>' >> $(MSWIN)/winres.h
+       echo '#ifdef IDC_STATIC' >> $(MSWIN)/winres.h
+       echo '#undef IDC_STATIC' >> $(MSWIN)/winres.h
+       echo '#endif' >> $(MSWIN)/winres.h
+       echo '#define IDC_STATIC (-1)' >> $(MSWIN)/winres.h
+endif
        $(rc) --include-dir=$(MSWIN) --input=$< -o$@
+ifeq "$(MISSING_HEADER)" "Y"
+       @-rm -f $(MSWIN)/winres.h
+endif
 
 $(ONH):
        @mkdir -p $@