mirror of
https://github.com/simh/simh.git
synced 2026-02-27 09:09:46 +00:00
makefile: Properly report archive git commit info when building from an archive
This commit is contained in:
12
makefile
12
makefile
@@ -413,6 +413,7 @@ ifeq (${WIN32},) #*nix Environments (&& cygwin)
|
||||
endif
|
||||
endif
|
||||
ifeq (git-repo,$(shell if ${TEST} -e ./.git; then echo git-repo; fi))
|
||||
GIT_REPO=1
|
||||
GIT_PATH=$(strip $(shell which git))
|
||||
ifeq (,$(GIT_PATH))
|
||||
$(error building using a git repository, but git is not available)
|
||||
@@ -427,8 +428,9 @@ ifeq (${WIN32},) #*nix Environments (&& cygwin)
|
||||
$(error building using a got repository, but git repository is not available)
|
||||
endif
|
||||
REPO_PATH=-C $(file <.got/repository)
|
||||
GIT_REPO=1
|
||||
endif
|
||||
ifneq (,GIT_PATH)
|
||||
ifneq (,$(and $(GIT_REPO),$(GIT_PATH)))
|
||||
ifeq (commit-id-exists,$(shell if ${TEST} -e .git-commit-id; then echo commit-id-exists; fi))
|
||||
CURRENT_FULL_GIT_COMMIT_ID=$(strip $(shell grep 'SIM_GIT_COMMIT_ID' .git-commit-id | awk '{ print $$2 }'))
|
||||
CURRENT_GIT_COMMIT_ID=$(word 1,$(subst +, , $(CURRENT_FULL_GIT_COMMIT_ID)))
|
||||
@@ -1070,10 +1072,10 @@ ifeq (${WIN32},) #*nix Environments (&& cygwin)
|
||||
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 (,$(shell grep 'define SIM_ARCHIVE_GIT_COMMIT_ID' sim_rev.h | grep 'Format:'))
|
||||
GIT_COMMIT_ID=$(shell grep 'define SIM_ARCHIVE_GIT_COMMIT_ID' sim_rev.h | awk '{ print $$3 }')
|
||||
GIT_COMMIT_TIME=$(shell grep 'define SIM_ARCHIVE_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 }')
|
||||
GIT_COMMIT_TIME=$(shell git $(REPO_PATH) --git-dir=$(realpath .)/.git log $(GIT_COMMIT_ID) -1 --pretty="%aI")
|
||||
|
||||
25
scp.c
25
scp.c
@@ -7108,6 +7108,19 @@ if (flag) {
|
||||
strlcpy (os_type, getenv ("OSTYPE"), sizeof (os_type));
|
||||
setenv ("SIM_OSTYPE", os_type, 1);
|
||||
}
|
||||
#if defined(SIM_GIT_COMMIT_ID)
|
||||
if (1) {
|
||||
const char *extras = strchr (S_xstr(SIM_GIT_COMMIT_ID), '+');
|
||||
|
||||
fprintf (st, "%sgit commit id: %8.8s%s", flag ? "\n " : " ", S_xstr(SIM_GIT_COMMIT_ID), extras ? extras : "");
|
||||
setenv ("SIM_GIT_COMMIT_ID", S_xstr(SIM_GIT_COMMIT_ID), 1);
|
||||
}
|
||||
#if defined(SIM_GIT_COMMIT_TIME)
|
||||
setenv ("SIM_GIT_COMMIT_TIME", S_xstr(SIM_GIT_COMMIT_TIME), 1);
|
||||
if (flag)
|
||||
fprintf (st, "%sgit commit time: %s", "\n ", S_xstr(SIM_GIT_COMMIT_TIME));
|
||||
#endif
|
||||
#else
|
||||
#if defined(SIM_ARCHIVE_GIT_COMMIT_ID)
|
||||
if (NULL == strchr (S_xstr(SIM_ARCHIVE_GIT_COMMIT_ID), '$')) {
|
||||
const char *extras = strchr (S_xstr(SIM_ARCHIVE_GIT_COMMIT_ID), '+');
|
||||
@@ -7123,18 +7136,6 @@ if (NULL == strchr (S_xstr(SIM_ARCHIVE_GIT_COMMIT_TIME), '$')) {
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#if defined(SIM_GIT_COMMIT_ID)
|
||||
if (1) {
|
||||
const char *extras = strchr (S_xstr(SIM_GIT_COMMIT_ID), '+');
|
||||
|
||||
fprintf (st, "%sgit commit id: %8.8s%s", flag ? "\n " : " ", S_xstr(SIM_GIT_COMMIT_ID), extras ? extras : "");
|
||||
setenv ("SIM_GIT_COMMIT_ID", S_xstr(SIM_GIT_COMMIT_ID), 1);
|
||||
}
|
||||
#if defined(SIM_GIT_COMMIT_TIME)
|
||||
setenv ("SIM_GIT_COMMIT_TIME", S_xstr(SIM_GIT_COMMIT_TIME), 1);
|
||||
if (flag)
|
||||
fprintf (st, "%sgit commit time: %s", "\n ", S_xstr(SIM_GIT_COMMIT_TIME));
|
||||
#endif
|
||||
#endif
|
||||
#if defined(SIM_BUILD)
|
||||
fprintf (st, "%sBuild: %s", flag ? "\n " : " ", S_xstr(SIM_BUILD));
|
||||
|
||||
Reference in New Issue
Block a user