Skip to content

Commit

Permalink
Store the version number in one place
Browse files Browse the repository at this point in the history
The VERSION macro in Makefile is now the single source of the version of
FlexDLL. This is used when compiling version.rc.

version.rc is corrected to adopt Windows version format, so the current
release is rendered as 0.43.0.0 instead of 0.0.0.43.

flexdll.opam is now the primary source for the version number for the
package, and both version.ml and version.rc are compiled using the
number taken from there.
  • Loading branch information
dra27 committed Mar 15, 2024
1 parent 62f20c3 commit c5d59b5
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 13 deletions.
41 changes: 33 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@
##


VERSION = 0.43
# Fetch the version number from its source, in flexdll.opam
VERSION = \
$(eval VERSION := $$(shell sed -ne 's/^version: *"\(.*\)"/\1/p' flexdll.opam))$(VERSION)

all: flexlink.exe support

OCAML_CONFIG_FILE=$(shell cygpath -ad "$(shell ocamlopt -where 2>/dev/null)/Makefile.config" 2>/dev/null)
include $(OCAML_CONFIG_FILE)
OCAMLOPT=ocamlopt
EMPTY=
SPACE=$(EMPTY) $(EMPTY)
COMMA=,
OCAML_VERSION:=$(firstword $(subst ~, ,$(subst +, ,$(shell $(OCAMLOPT) -version 2>/dev/null))))
ifeq ($(OCAML_VERSION),)
OCAML_VERSION:=0
Expand All @@ -31,7 +35,7 @@ MIN64CC = $(MINGW64_PREFIX)gcc
CYGWIN64_PREFIX = x86_64-pc-cygwin-
CYG64CC = $(CYGWIN64_PREFIX)gcc

version.ml: Makefile
version.ml: Makefile flexdll.opam
echo "let version = \"$(VERSION)\"" > version.ml
echo "let mingw_prefix = \"$(MINGW_PREFIX)\"" >> version.ml
echo "let mingw64_prefix = \"$(MINGW64_PREFIX)\"" >> version.ml
Expand Down Expand Up @@ -160,11 +164,32 @@ flexlink.exe: $(OBJS) $(RES)
rm -f $@
$(RES_PREFIX) $(OCAMLOPT) -o $@ $(LINKFLAGS) $(OBJS)

version.res: version.rc
$(RES_PREFIX) rc $<

version_res.o: version.rc
$(TOOLPREF)windres -i $< -o $@
# VERSION at present is x.y, but there would be no reason not to have x.y.z in
# future. Windows versions have four components. $(FLEXDLL_FULL_VERSION) adds
# additional .0s to the right of $(VERSION) such that $(FLEXDLL_FULL_VERSION)
# has four version components.
# Thus if VERSION=0.43, then FLEXDLL_FULL_VERSION=0.43.0.0
# $(FLEXDLL_VS_VERSION_INFO) is the same value, but using a ',' to separate the
# items rather than a '.', as this is the format used in a VS_VERSION_INFO block
# in Resource Compiler format.
FLEXDLL_FULL_VERSION = \
$(subst $(SPACE),.,$(wordlist 1, 4, $(subst .,$(SPACE),$(VERSION)) 0 0 0))
FLEXDLL_VS_VERSION_INFO = $(subst .,$(COMMA),$(FLEXDLL_FULL_VERSION))

RC_FLAGS = \
/d FLEXDLL_VS_VERSION_INFO=$(FLEXDLL_VS_VERSION_INFO) \
/d FLEXDLL_FULL_VERSION="$(FLEXDLL_FULL_VERSION)"

# cf. https://sourceware.org/bugzilla/show_bug.cgi?id=27843
WINDRES_FLAGS = \
-D FLEXDLL_VS_VERSION_INFO=$(FLEXDLL_VS_VERSION_INFO) \
-D FLEXDLL_FULL_VERSION=\\\"$(FLEXDLL_FULL_VERSION)\\\"

version.res: version.rc flexdll.opam
$(RES_PREFIX) rc /nologo $(RC_FLAGS) $<

version_res.o: version.rc flexdll.opam
$(TOOLPREF)windres $(WINDRES_FLAGS) -i $< -o $@

flexdll_msvc.obj: flexdll.c flexdll.h
$(MSVC_PREFIX) $(MSVCC) /DMSVC -c /Fo"$@" $<
Expand Down Expand Up @@ -239,7 +264,7 @@ package_src:
rm -Rf flexdll-$(VERSION)
mkdir flexdll-$(VERSION)
mkdir flexdll-$(VERSION)/test
cp -a $(filter-out version.ml,$(OBJS:Compat.ml=Compat.ml.in)) Makefile msvs-detect $(COMMON_FILES) version.rc flexdll.install flexdll-$(VERSION)/
cp -a $(filter-out version.ml,$(OBJS:Compat.ml=Compat.ml.in)) Makefile msvs-detect $(COMMON_FILES) version.rc flexdll.install flexdll.opam flexdll-$(VERSION)/
cp -aR test/Makefile test/*.c flexdll-$(VERSION)/test/
tar czf $(PACKAGE) flexdll-$(VERSION)
rm -Rf flexdll-$(VERSION)
Expand Down
2 changes: 1 addition & 1 deletion appveyor_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ if [ "$ARTEFACTS" = 'yes' ] ; then

make package_bin installer
SUFFIX="$(git describe)"
VERSION="$(sed -ne 's/^VERSION *= *//p' Makefile)"
VERSION="$(sed -ne 's/^version: *"\(.*\)"/\1/p' flexdll.opam)"
if [ "$SUFFIX" != "$VERSION" ] ; then
mv "flexdll-bin-$VERSION.zip" "flexdll-bin-$SUFFIX.zip"
mv "flexdll-$VERSION-setup.exe" "flexdll-$SUFFIX-setup.exe"
Expand Down
1 change: 1 addition & 0 deletions flexdll.install
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ share: [
"default_amd64.manifest"
"flexdll.c"
"flexdll.h"
"flexdll.opam"
"flexdll_initer.c"
"reloc.ml"
"version.rc"
Expand Down
8 changes: 4 additions & 4 deletions version.rc
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,0,0,43
PRODUCTVERSION 0,0,0,43
FILEVERSION FLEXDLL_VS_VERSION_INFO
PRODUCTVERSION FLEXDLL_VS_VERSION_INFO
FILEFLAGSMASK 0x3fL
FILEFLAGS 0x0L
FILEOS 0x40004L
Expand All @@ -21,8 +21,8 @@ BEGIN
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "FileVersion", "0.0.0.43"
VALUE "ProductVersion", "0.0.0.43"
VALUE "FileVersion", FLEXDLL_FULL_VERSION
VALUE "ProductVersion", FLEXDLL_FULL_VERSION
VALUE "ProductName", "FlexDLL"
VALUE "FileDescription", "FlexDLL Linker"
VALUE "LegalCopyright", "Institut National de Recherche en Informatique et en Automatique"
Expand Down

0 comments on commit c5d59b5

Please sign in to comment.