mirror of
https://github.com/open-simh/simh.git
synced 2026-01-25 11:55:43 +00:00
SCP: Add git commit time to commit id version information
This commit is contained in:
32
makefile
32
makefile
@@ -195,7 +195,11 @@ ifeq ($(WIN32),) #*nix Environments (&& cygwin)
|
||||
endif
|
||||
endif
|
||||
ifeq (git-repo,$(shell if $(TEST) -d ./.git; then echo git-repo; fi))
|
||||
ifeq (need-hooks,$(shell if $(TEST) ! -e ./.git/hooks/post-checkout; then echo need-hooks; fi))
|
||||
NEED_HOOKS = $(shell if $(TEST) ! -e ./.git/hooks/post-checkout; then echo need-hooks; fi)
|
||||
ifeq (,$(NEED_HOOKS))
|
||||
NEED_HOOKS = $(shell if ! `diff ./.git/hooks/post-checkout ./Visual\ Studio\ Projects/git-hooks/post-checkout >/dev/null`; then echo need-hooks; fi)
|
||||
endif
|
||||
ifeq (need-hooks,$(NEED_HOOKS))
|
||||
$(info *** Installing git hooks in local repository ***)
|
||||
GIT_HOOKS += $(shell /bin/cp './Visual Studio Projects/git-hooks/post-commit' ./.git/hooks/)
|
||||
GIT_HOOKS += $(shell /bin/cp './Visual Studio Projects/git-hooks/post-checkout' ./.git/hooks/)
|
||||
@@ -203,9 +207,14 @@ ifeq ($(WIN32),) #*nix Environments (&& cygwin)
|
||||
GIT_HOOKS += $(shell ./.git/hooks/post-checkout)
|
||||
ifneq (,$(strip $(GIT_HOOKS)))
|
||||
$(info *** Warning - Error installing git hooks *** $(GIT_HOOKS))
|
||||
else
|
||||
ifneq (commit-id-exists,$(shell if $(TEST) -e .git-commit-id; then echo commit-id-exists; fi))
|
||||
$(shell /bin/rm .git-commit-id)
|
||||
endif
|
||||
endif
|
||||
else
|
||||
ifneq (commit-id-exists,$(shell if $(TEST) -e .git-commit-id; then echo commit-id-exists; fi))
|
||||
endif
|
||||
ifneq (commit-id-exists,$(shell if $(TEST) -e .git-commit-id; then echo commit-id-exists; fi))
|
||||
ifeq (,$(strip $(GIT_HOOKS)))
|
||||
GIT_HOOKS = $(shell ./.git/hooks/post-checkout)
|
||||
ifneq (,$(strip $(GIT_HOOKS)))
|
||||
$(info *** Warning - Error executing git hooks *** $(GIT_HOOKS))
|
||||
@@ -828,15 +837,18 @@ ifeq ($(WIN32),) #*nix Environments (&& cygwin)
|
||||
MKDIRBIN = mkdir -p BIN
|
||||
endif
|
||||
ifeq (commit-id-exists,$(shell if $(TEST) -e .git-commit-id; then echo commit-id-exists; fi))
|
||||
GIT_COMMIT_ID=$(shell cat .git-commit-id)
|
||||
GIT_COMMIT_ID=$(shell grep 'SIM_GIT_COMMIT_ID' .git-commit-id | awk '{ print $$2 }')
|
||||
GIT_COMMIT_TIME=$(shell grep 'SIM_GIT_COMMIT_TIME' .git-commit-id | awk '{ print $$2 }')
|
||||
else
|
||||
ifeq (,$(shell grep 'define SIM_GIT_COMMIT_ID' sim_rev.h | grep 'Format:'))
|
||||
GIT_COMMIT_ID=$(shell grep 'define SIM_GIT_COMMIT_ID' sim_rev.h | awk '{ print $$3 }')
|
||||
GIT_COMMIT_TIME=$(shell grep 'define SIM_GIT_COMMIT_TIME' sim_rev.h | awk '{ print $$3 }')
|
||||
else
|
||||
ifeq (git-submodule,$(if $(shell cd .. ; git rev-parse --git-dir 2>/dev/null),git-submodule))
|
||||
GIT_COMMIT_ID=$(shell cd .. ; git submodule status | grep "$(notdir $(realpath .))" | awk '{ print $$1 }')
|
||||
else
|
||||
GIT_COMMIT_ID=undetermined-git-id
|
||||
GIT_COMMIT_TIME=undetermined-commit-time
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
@@ -921,11 +933,13 @@ else
|
||||
ifneq ($(USE_NETWORK),)
|
||||
NETWORK_OPT += -DUSE_SHARED
|
||||
endif
|
||||
ifneq (,$(shell if exist .git-commit-id type .git-commit-id))
|
||||
GIT_COMMIT_ID=$(shell if exist .git-commit-id type .git-commit-id)
|
||||
ifneq (,$(shell if exist .git-commit-id echo git-commit-id))
|
||||
GIT_COMMIT_ID=$(shell for /F "tokens=2" %%i in ("$(shell findstr /C:"SIM_GIT_COMMIT_ID" .git-commit-id)") do echo %%i)
|
||||
GIT_COMMIT_TIME=$(shell for /F "tokens=2" %%i in ("$(shell findstr /C:"SIM_GIT_COMMIT_TIME" .git-commit-id)") do echo %%i)
|
||||
else
|
||||
ifeq (,$(shell findstr /C:"define SIM_GIT_COMMIT_ID" sim_rev.h | findstr Format))
|
||||
GIT_COMMIT_ID=$(shell for /F "tokens=3" %%i in ("$(shell findstr /C:"define SIM_GIT_COMMIT_ID" sim_rev.h)") do echo %%i)
|
||||
GIT_COMMIT_TIME=$(shell for /F "tokens=3" %%i in ("$(shell findstr /C:"define SIM_GIT_COMMIT_TIME" sim_rev.h)") do echo %%i)
|
||||
endif
|
||||
endif
|
||||
ifneq (windows-build,$(shell if exist ..\windows-build\README.md echo windows-build))
|
||||
@@ -978,7 +992,10 @@ else
|
||||
endif
|
||||
endif # Win32 (via MinGW)
|
||||
ifneq (,$(GIT_COMMIT_ID))
|
||||
CFLAGS_GIT = -DSIM_GIT_COMMIT_ID=$(GIT_COMMIT_ID)
|
||||
CFLAGS_GIT = -DSIM_GIT_COMMIT_ID=$(GIT_COMMIT_ID) -DSIM_GIT_COMMIT_TIME=$(GIT_COMMIT_TIME)
|
||||
endif
|
||||
ifneq (,$(GIT_COMMIT_TIME))
|
||||
CFLAGS_GIT += -DSIM_GIT_COMMIT_TIME=$(GIT_COMMIT_TIME)
|
||||
endif
|
||||
ifneq (,$(UNSUPPORTED_BUILD))
|
||||
CFLAGS_GIT += -DSIM_BUILD=Unsupported=$(UNSUPPORTED_BUILD)
|
||||
@@ -1063,6 +1080,7 @@ ifneq (clean,$(MAKECMDGOALS))
|
||||
ifneq (,$(GIT_COMMIT_ID))
|
||||
$(info ***)
|
||||
$(info *** git commit id is $(GIT_COMMIT_ID).)
|
||||
$(info *** git commit time is $(GIT_COMMIT_TIME).)
|
||||
endif
|
||||
$(info ***)
|
||||
endif
|
||||
|
||||
Reference in New Issue
Block a user