Git fork

Makefile: generate "git.rc" via GIT-VERSION-GEN

The "git.rc" is used on Windows to embed information like the project
name and version into the resulting executables. As such we need to
inject the version information, which we do by using preprocessor
defines. The logic to do so is non-trivial and needs to be kept in sync
with the different build systems.

Refactor the logic so that we generate "git.rc" via `GIT-VERSION-GEN`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Patrick Steinhardt and committed by
Junio C Hamano
9bb10d27 0c8d3395

+30 -17
+1
.gitignore
··· 199 199 *.tar.gz 200 200 *.dsc 201 201 *.deb 202 + /git.rc 202 203 /git.spec 203 204 *.exe 204 205 *.[aos]
+6 -2
GIT-VERSION-GEN
··· 58 58 GIT_USER_AGENT="git/$GIT_VERSION" 59 59 fi 60 60 61 - read GIT_MAJOR_VERSION GIT_MINOR_VERSION GIT_MICRO_VERSION trailing <<EOF 62 - $(echo "$GIT_VERSION" 0 0 0 | tr '.a-zA-Z-' ' ') 61 + # While released Git versions only have three numbers, development builds also 62 + # have a fourth number that corresponds to the number of patches since the last 63 + # release. 64 + read GIT_MAJOR_VERSION GIT_MINOR_VERSION GIT_MICRO_VERSION GIT_PATCH_LEVEL trailing <<EOF 65 + $(echo "$GIT_VERSION" 0 0 0 0 | tr '.a-zA-Z-' ' ') 63 66 EOF 64 67 65 68 sed -e "s|@GIT_VERSION@|$GIT_VERSION|" \ 66 69 -e "s|@GIT_MAJOR_VERSION@|$GIT_MAJOR_VERSION|" \ 67 70 -e "s|@GIT_MINOR_VERSION@|$GIT_MINOR_VERSION|" \ 68 71 -e "s|@GIT_MICRO_VERSION@|$GIT_MICRO_VERSION|" \ 72 + -e "s|@GIT_PATCH_LEVEL@|$GIT_PATCH_LEVEL|" \ 69 73 -e "s|@GIT_BUILT_FROM_COMMIT@|$GIT_BUILT_FROM_COMMIT|" \ 70 74 -e "s|@GIT_USER_AGENT@|$GIT_USER_AGENT|" \ 71 75 "$INPUT" >"$OUTPUT"+
+7 -6
Makefile
··· 2568 2568 $(QUIET_GEN)$(cmd_munge_script) && \ 2569 2569 mv $@+ $@ 2570 2570 2571 - git.res: git.rc GIT-VERSION-FILE GIT-PREFIX 2572 - $(QUIET_RC)$(RC) \ 2573 - $(join -DMAJOR= -DMINOR= -DMICRO= -DPATCHLEVEL=, $(wordlist 1, 4, \ 2574 - $(shell echo $(GIT_VERSION) 0 0 0 0 | tr '.a-zA-Z-' ' '))) \ 2575 - -DGIT_VERSION="\\\"$(GIT_VERSION)\\\"" -i $< -o $@ 2571 + git.rc: git.rc.in GIT-VERSION-GEN GIT-VERSION-FILE 2572 + $(QUIET_GEN)$(SHELL_PATH) ./GIT-VERSION-GEN "$(shell pwd)" $< $@+ 2573 + @if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else mv $@+ $@; fi 2574 + 2575 + git.res: git.rc GIT-PREFIX 2576 + $(QUIET_RC)$(RC) -i $< -o $@ 2576 2577 2577 2578 # This makes sure we depend on the NO_PERL setting itself. 2578 2579 $(SCRIPT_PERL_GEN): GIT-BUILD-OPTIONS ··· 3717 3718 $(RM) -r .build $(UNIT_TEST_BIN) 3718 3719 $(RM) GIT-TEST-SUITES 3719 3720 $(RM) po/git.pot po/git-core.pot 3720 - $(RM) git.res 3721 + $(RM) git.rc git.res 3721 3722 $(RM) $(OBJECTS) 3722 3723 $(RM) headless-git.o 3723 3724 $(RM) $(LIB_FILE) $(XDIFF_LIB) $(REFTABLE_LIB)
+13 -6
contrib/buildsystems/CMakeLists.txt
··· 691 691 add_library(reftable STATIC ${reftable_SOURCES}) 692 692 693 693 if(WIN32) 694 + add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.rc 695 + COMMAND "${SH_EXE}" "${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN" 696 + "${CMAKE_SOURCE_DIR}" 697 + "${CMAKE_SOURCE_DIR}/git.rc.in" 698 + "${CMAKE_BINARY_DIR}/git.rc" 699 + DEPENDS "${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN" 700 + "${CMAKE_SOURCE_DIR}/git.rc.in" 701 + VERBATIM) 702 + 694 703 if(NOT MSVC)#use windres when compiling with gcc and clang 695 704 add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res 696 - COMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR} 697 - -DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION="\\\"${PROJECT_VERSION}.GIT\\\"" 698 - -i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res 705 + COMMAND ${WINDRES_EXE} -O coff -i ${CMAKE_BINARY_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res 706 + DEPENDS "${CMAKE_BINARY_DIR}/git.rc" 699 707 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} 700 708 VERBATIM) 701 709 else()#MSVC use rc 702 710 add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res 703 - COMMAND ${CMAKE_RC_COMPILER} /d MAJOR=${PROJECT_VERSION_MAJOR} /d MINOR=${PROJECT_VERSION_MINOR} 704 - /d MICRO=${PROJECT_VERSION_PATCH} /d PATCHLEVEL=0 /d GIT_VERSION="${PROJECT_VERSION}.GIT" 705 - /fo ${CMAKE_BINARY_DIR}/git.res ${CMAKE_SOURCE_DIR}/git.rc 711 + COMMAND ${CMAKE_RC_COMPILER} /fo ${CMAKE_BINARY_DIR}/git.res ${CMAKE_BINARY_DIR}/git.rc 712 + DEPENDS "${CMAKE_BINARY_DIR}/git.rc" 706 713 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} 707 714 VERBATIM) 708 715 endif()
+3 -3
git.rc git.rc.in
··· 1 1 1 VERSIONINFO 2 - FILEVERSION MAJOR,MINOR,MICRO,PATCHLEVEL 3 - PRODUCTVERSION MAJOR,MINOR,MICRO,PATCHLEVEL 2 + FILEVERSION @GIT_MAJOR_VERSION@,@GIT_MINOR_VERSION@,@GIT_MICRO_VERSION@,@GIT_PATCH_LEVEL@ 3 + PRODUCTVERSION @GIT_MAJOR_VERSION@,@GIT_MINOR_VERSION@,@GIT_MICRO_VERSION@,@GIT_PATCH_LEVEL@ 4 4 BEGIN 5 5 BLOCK "StringFileInfo" 6 6 BEGIN ··· 11 11 VALUE "InternalName", "git\0" 12 12 VALUE "OriginalFilename", "git.exe\0" 13 13 VALUE "ProductName", "Git\0" 14 - VALUE "ProductVersion", GIT_VERSION "\0" 14 + VALUE "ProductVersion", "@GIT_VERSION@\0" 15 15 END 16 16 END 17 17