windres in mingw32 is broken. Add script that tests for the bug and

call from Makefile to abort if building on unpatched machine.  (Bug
report's been submitted.)
This commit is contained in:
ehouse 2009-10-01 04:11:36 +00:00
parent 1fba7d7ef6
commit b1faf6ac8a
2 changed files with 42 additions and 4 deletions

View file

@ -238,17 +238,15 @@ $(OBJDIR)/%.o : ../common/%.c $(INCLUDES)
$(CC) -c $(CFLAGS) -o $@ $<
$(BASE_LANG_OBJ) : $(BASE_LANG_SRC) $(INCLUDES) xwords4.ico common_rsrc.rc $(BMPS)
scripts/test_windres.sh ${WINDRES}
$(WINDRES) -v $(MINGW_INC_PATH) $(RESFLAGS) -DAM_BASE_LANGUAGE -o $@ $<
$(OBJDIR)/l10n/%.rc.o : l10n/%.rc $(WINCE_INCLUDES)
scripts/test_windres.sh ${WINDRES}
mkdir -p $(dir $@)
ifeq ($(TARGET_OS),wince)
UTF8=x$(shell file -b -n -i $< | grep 'utf-8'); \
if [ x != $$UTF8 ]; then ENC="-c 65001"; fi; \
$(WINDRES) $$ENC -v $(MINGW_INC_PATH) $(RESFLAGS) $< -o $@
else
$(WINDRES) -v $(MINGW_INC_PATH) $(RESFLAGS) $< -o $@
endif
$(BUILTDIR)/%.dll: $(OBJDIR)/l10n/%.rc.o
mkdir -p $(dir $@)

View file

@ -0,0 +1,40 @@
#!/bin/sh
# Make sure the windres we have is correctly converting utf-8 to
# utf-16. We'll cons up a fake .rc file, compile it, hexdump it and
# look for a pattern. Use Polish for grins.
usage() {
echo "usage: $0 path/to/windres"
}
STR="Wartości i ilości klocków"
RC_FILE=/tmp/test_$$.rc
DOT_O_FILE=/tmp/test_$$.o
WINDRES=$1
which $WINDRES || usage
# Create the .rc file
cat > $RC_FILE <<EOF
STRINGTABLE DISCARDABLE
BEGIN
1000 "$STR"
END
EOF
# compile it
${WINDRES} -c 65001 $RC_FILE -o $DOT_O_FILE
NEEDLE=$(echo -n "$STR" | iconv -t UTF-16LE | hexdump -v -e '1/1 "%02X"')
HAYSTACK=$(hexdump -v -e '1/1 "%02X"' < $DOT_O_FILE)
rm -f $RC_FILE $DOT_O_FILE
if echo $HAYSTACK | grep -q $NEEDLE; then
exit 0
else
echo "failed!!!"
echo $NEEDLE
echo $HAYSTACK
exit 1
fi