git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH/RFC] Makefile: Fix compilation of windows resource file

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 21, 2014, 21:36 UTC
Message-ID
<xmqqppnlt3u3.fsf@gitster.dls.corp.google.com>
In-Reply-To
<xmqqy529t5bb.fsf@gitster.dls.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 38 quoted lines
> Ramsay Jones <ramsay@ramsay1.demon.co.uk> writes:
>
>> If the git version number consists of less than three period
>> separated numbers, then the windows resource file compilation
>> issues a syntax error:
>>
>>   $ touch git.rc
>>   $ make V=1 git.res
>>   GIT_VERSION = 1.9.rc0
>>   windres -O coff \
>>             -DMAJOR=1 -DMINOR=9 -DPATCH=rc0 \
>>             -DGIT_VERSION="\\\"1.9.rc0\\\"" git.rc -o git.res
>>   C:\msysgit\msysgit\mingw\bin\windres.exe: git.rc:2: syntax error
>>   make: *** [git.res] Error 1
>>   $
>>
>> [Note that -DPATCH=rc0]
>
> Thanks for a report.  I've been wondering how many distros and
> packagers would have an issue like this when we go to 2-digit
> release naming.  Of course we knew everybody can grok 3-or-4 ;-)
>
>> In order to fix the syntax error, we replace any rcX with zero and
>> include some additional 'zero' padding to the version number list.
>>
>> Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
>> ---
>>
>> Hi Junio,
>>
>> This patch is marked RFC because, as I was just about to send this
>> email, I realized it wouldn't always work:
>
> Yeah, and I suspect that with the use of $(wordlist 1,3,...) it is
> not even working for maintenance releases.  Does it differenciate
> between 1.8.5.1 and 1.8.5.2, for example?.  Or does "windres" always
> assume that a package version is always 3-dewey-decimal (not 2, not
> 4)?

Perhaps like this? Just grab digit-only segments that are separated with either dot or dash (and stop when we see a non-digit like 'dirty' or 'rcX'), and make them separated with comma.

Note that I am merely guessing that "short-digit" version numbers are acceptable by now after seeing

    https://sourceware.org/ml/binutils/2012-07/msg00199.html

without knowing the current state of affairs. If that is not the case you may have to count the iteration of the loop and append or chop the resulting string as necessary.

 Makefile              |  2 +-
 gen-version-string.sh | 13 +++++++++++++
 git.rc                |  4 ++--
 3 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index b4af1e2..329f942 100644
--- a/Makefile
+++ b/Makefile
@@ -1773,7 +1773,7 @@ $(SCRIPT_LIB) : % : %.sh GIT-SCRIPT-DEFINES
 
 git.res: git.rc GIT-VERSION-FILE
 	$(QUIET_RC)$(RC) \
-	  $(join -DMAJOR= -DMINOR= -DPATCH=, $(wordlist 1,3,$(subst -, ,$(subst ., ,$(GIT_VERSION))))) \
+		-DVERSIONSTRING=$$(./gen-version-string.sh $(GIT_VERSION)) \
 	  -DGIT_VERSION="\\\"$(GIT_VERSION)\\\"" $< -o $@
 
 ifndef NO_PERL
diff --git a/gen-version-string.sh b/gen-version-string.sh
new file mode 100755
index 0000000..00af718
--- /dev/null
+++ b/gen-version-string.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+IFS=.- result=
+for v in $1
+do
+	if expr "$v" : '[0-9][0-9]*$' >/dev/null
+	then
+		result=$result${result:+,}$v
+	else
+		break
+	fi
+done
+echo "$result"
diff --git a/git.rc b/git.rc
index bce6db9..6f2a8d2 100644
--- a/git.rc
+++ b/git.rc
@@ -1,6 +1,6 @@
 1 VERSIONINFO
-FILEVERSION     MAJOR,MINOR,PATCH,0
-PRODUCTVERSION  MAJOR,MINOR,PATCH,0
+FILEVERSION     VERSIONSTRING,0
+PRODUCTVERSION  VERSIONSTRING,0
 BEGIN
   BLOCK "StringFileInfo"
   BEGIN
Previous: Junio C HamanoNext: Ramsay Jones
Message 3 of 15 in “Makefile: Fix compilation of windows resource file”
  1. Makefile: Fix compilation of windows resource fileRamsay Jones, Jan 20, 2014
  2. Junio C HamanoJan 21, 2014
  3. Junio C HamanoJan 21, 2014
  4. Ramsay JonesJan 21, 2014
  5. Junio C HamanoJan 21, 2014
  6. Johannes SixtJan 22, 2014
  7. Junio C HamanoJan 22, 2014
  8. Johannes SixtJan 22, 2014
  9. Junio C HamanoJan 22, 2014
  10. Junio C HamanoJan 22, 2014
  11. Makefile: Fix compilation of Windows resource fileJohannes Sixt, Jan 23, 2014
  12. Pat ThoytsJan 23, 2014
  13. Johannes SixtJan 23, 2014
  14. Pat ThoytsJan 23, 2014
  15. Junio C HamanoJan 23, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.