makefile, Visual Studio build: Report uncommitted changes in commit-id
This commit is contained in:
parent
f91d56c60f
commit
3e5bd84523
3 changed files with 36 additions and 19 deletions
|
@ -340,13 +340,15 @@ rem several projects can start execution at almost the same time.
|
||||||
rem
|
rem
|
||||||
SET ACTUAL_GIT_COMMIT_ID=
|
SET ACTUAL_GIT_COMMIT_ID=
|
||||||
SET ACTUAL_GIT_COMMIT_TIME=
|
SET ACTUAL_GIT_COMMIT_TIME=
|
||||||
|
SET ACTUAL_GIT_COMMIT_EXTRAS=
|
||||||
SET GIT_COMMIT_ID=
|
SET GIT_COMMIT_ID=
|
||||||
SET GIT_COMMIT_TIME=
|
SET GIT_COMMIT_TIME=
|
||||||
for /F "usebackq tokens=1" %%i in (`git log -1 "--pretty=%%H"`) do SET ACTUAL_GIT_COMMIT_ID=%%i
|
for /F "usebackq tokens=1" %%i in (`git update-index --refresh --`) do SET ACTUAL_GIT_COMMIT_EXTRAS=+uncommitted-changes
|
||||||
|
for /F "usebackq tokens=1" %%i in (`git log -1 "--pretty=%%H"`) do SET ACTUAL_GIT_COMMIT_ID=%%i%ACTUAL_GIT_COMMIT_EXTRAS%
|
||||||
for /F "usebackq tokens=1" %%i in (`git log -1 "--pretty=%%aI"`) do SET ACTUAL_GIT_COMMIT_TIME=%%i
|
for /F "usebackq tokens=1" %%i in (`git log -1 "--pretty=%%aI"`) do SET ACTUAL_GIT_COMMIT_TIME=%%i
|
||||||
if exist ..\.git-commit-id for /F "usebackq tokens=2" %%i in (`findstr /C:SIM_GIT_COMMIT_ID ..\.git-commit-id`) do SET GIT_COMMIT_ID=%%i
|
if exist ..\.git-commit-id for /F "usebackq tokens=2" %%i in (`findstr /C:SIM_GIT_COMMIT_ID ..\.git-commit-id`) do SET GIT_COMMIT_ID=%%i
|
||||||
if exist ..\.git-commit-id for /F "usebackq tokens=2" %%i in (`findstr /C:SIM_GIT_COMMIT_TIME ..\.git-commit-id`) do SET GIT_COMMIT_TIME=%%i
|
if exist ..\.git-commit-id for /F "usebackq tokens=2" %%i in (`findstr /C:SIM_GIT_COMMIT_TIME ..\.git-commit-id`) do SET GIT_COMMIT_TIME=%%i
|
||||||
if "%ACTUAL_GIT_COMMIT_ID%" neq "%GIT_COMMIT_ID%" "%_GIT_GIT%" log -1 --pretty="SIM_GIT_COMMIT_ID %%H%%nSIM_GIT_COMMIT_TIME %%aI" >..\.git-commit-id
|
if "%ACTUAL_GIT_COMMIT_ID%" neq "%GIT_COMMIT_ID%" "%_GIT_GIT%" log -1 --pretty="SIM_GIT_COMMIT_ID %%H%%ACTUAL_GIT_COMMIT_EXTRAS%%%%nSIM_GIT_COMMIT_TIME %%aI" >..\.git-commit-id
|
||||||
SET GIT_COMMIT_ID=%ACTUAL_GIT_COMMIT_ID%
|
SET GIT_COMMIT_ID=%ACTUAL_GIT_COMMIT_ID%
|
||||||
SET GIT_COMMIT_TIME=%ACTUAL_GIT_COMMIT_TIME%
|
SET GIT_COMMIT_TIME=%ACTUAL_GIT_COMMIT_TIME%
|
||||||
SET ACTUAL_GIT_COMMIT_ID=
|
SET ACTUAL_GIT_COMMIT_ID=
|
||||||
|
|
41
makefile
41
makefile
|
@ -153,6 +153,19 @@ endif
|
||||||
ifneq ($(NOVIDEO),)
|
ifneq ($(NOVIDEO),)
|
||||||
VIDEO_USEFUL =
|
VIDEO_USEFUL =
|
||||||
endif
|
endif
|
||||||
|
ifneq ($(findstring Windows,${OS}),)
|
||||||
|
ifeq ($(findstring .exe,${SHELL}),.exe)
|
||||||
|
# MinGW
|
||||||
|
WIN32 := 1
|
||||||
|
# Tests don't run under MinGW
|
||||||
|
TESTS := 0
|
||||||
|
else # Msys or cygwin
|
||||||
|
ifeq (MINGW,$(findstring MINGW,$(shell uname)))
|
||||||
|
$(info *** This makefile can not be used with the Msys bash shell)
|
||||||
|
$(error Use build_mingw.bat ${MAKECMDGOALS} from a Windows command prompt)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
find_exe = $(abspath $(strip $(firstword $(foreach dir,$(strip $(subst :, ,${PATH})),$(wildcard $(dir)/$(1))))))
|
find_exe = $(abspath $(strip $(firstword $(foreach dir,$(strip $(subst :, ,${PATH})),$(wildcard $(dir)/$(1))))))
|
||||||
find_lib = $(abspath $(strip $(firstword $(foreach dir,$(strip ${LIBPATH}),$(wildcard $(dir)/lib$(1).${LIBEXT})))))
|
find_lib = $(abspath $(strip $(firstword $(foreach dir,$(strip ${LIBPATH}),$(wildcard $(dir)/lib$(1).${LIBEXT})))))
|
||||||
find_include = $(abspath $(strip $(firstword $(foreach dir,$(strip ${INCPATH}),$(wildcard $(dir)/$(1).h)))))
|
find_include = $(abspath $(strip $(firstword $(foreach dir,$(strip ${INCPATH}),$(wildcard $(dir)/$(1).h)))))
|
||||||
|
@ -162,17 +175,6 @@ ifneq (0,$(TESTS))
|
||||||
else
|
else
|
||||||
TESTING_FEATURES = - Per simulator tests will be skipped
|
TESTING_FEATURES = - Per simulator tests will be skipped
|
||||||
endif
|
endif
|
||||||
ifneq ($(findstring Windows,${OS}),)
|
|
||||||
ifeq ($(findstring .exe,${SHELL}),.exe)
|
|
||||||
# MinGW
|
|
||||||
WIN32 := 1
|
|
||||||
else # Msys or cygwin
|
|
||||||
ifeq (MINGW,$(findstring MINGW,$(shell uname)))
|
|
||||||
$(info *** This makefile can not be used with the Msys bash shell)
|
|
||||||
$(error Use build_mingw.bat ${MAKECMDGOALS} from a Windows command prompt)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
ifeq (${WIN32},) #*nix Environments (&& cygwin)
|
ifeq (${WIN32},) #*nix Environments (&& cygwin)
|
||||||
ifeq (${GCC},)
|
ifeq (${GCC},)
|
||||||
ifeq (,$(shell which gcc 2>/dev/null))
|
ifeq (,$(shell which gcc 2>/dev/null))
|
||||||
|
@ -256,8 +258,11 @@ ifeq (${WIN32},) #*nix Environments (&& cygwin)
|
||||||
NEED_COMMIT_ID = need-commit-id
|
NEED_COMMIT_ID = need-commit-id
|
||||||
endif
|
endif
|
||||||
ifeq (need-commit-id,$(NEED_COMMIT_ID))
|
ifeq (need-commit-id,$(NEED_COMMIT_ID))
|
||||||
|
ifneq (,$(shell git update-index --refresh --))
|
||||||
|
GIT_EXTRA_FILES=+uncommitted-changes
|
||||||
|
endif
|
||||||
isodate=$(shell git log -1 --pretty="%ai"|sed -e 's/ /T/'|sed -e 's/ //')
|
isodate=$(shell git log -1 --pretty="%ai"|sed -e 's/ /T/'|sed -e 's/ //')
|
||||||
$(shell git log -1 --pretty="SIM_GIT_COMMIT_ID %H%nSIM_GIT_COMMIT_TIME $(isodate)" >.git-commit-id)
|
$(shell git log -1 --pretty="SIM_GIT_COMMIT_ID %H$(GIT_EXTRA_FILES)%nSIM_GIT_COMMIT_TIME $(isodate)" >.git-commit-id)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
LTO_EXCLUDE_VERSIONS =
|
LTO_EXCLUDE_VERSIONS =
|
||||||
|
@ -992,7 +997,10 @@ else
|
||||||
endif
|
endif
|
||||||
ifeq (commit-id-exists,$(shell if exist .git-commit-id echo commit-id-exists))
|
ifeq (commit-id-exists,$(shell if exist .git-commit-id echo commit-id-exists))
|
||||||
CURRENT_GIT_COMMIT_ID=$(shell for /F "tokens=2" %%i in ("$(shell findstr /C:"SIM_GIT_COMMIT_ID" .git-commit-id)") do echo %%i)
|
CURRENT_GIT_COMMIT_ID=$(shell for /F "tokens=2" %%i in ("$(shell findstr /C:"SIM_GIT_COMMIT_ID" .git-commit-id)") do echo %%i)
|
||||||
ACTUAL_GIT_COMMIT_ID=$(strip $(shell git log -1 --pretty=%H))
|
ifneq (, $(shell git update-index --refresh --))
|
||||||
|
ACTUAL_GIT_COMMIT_EXTRAS=+uncommitted-changes
|
||||||
|
endif
|
||||||
|
ACTUAL_GIT_COMMIT_ID=$(strip $(shell git log -1 --pretty=%H))$(ACTUAL_GIT_COMMIT_EXTRAS)
|
||||||
ifneq ($(CURRENT_GIT_COMMIT_ID),$(ACTUAL_GIT_COMMIT_ID))
|
ifneq ($(CURRENT_GIT_COMMIT_ID),$(ACTUAL_GIT_COMMIT_ID))
|
||||||
NEED_COMMIT_ID = need-commit-id
|
NEED_COMMIT_ID = need-commit-id
|
||||||
# make sure that the invalidly formatted .git-commit-id file wasn't generated
|
# make sure that the invalidly formatted .git-commit-id file wasn't generated
|
||||||
|
@ -1005,10 +1013,13 @@ else
|
||||||
NEED_COMMIT_ID = need-commit-id
|
NEED_COMMIT_ID = need-commit-id
|
||||||
endif
|
endif
|
||||||
ifeq (need-commit-id,$(NEED_COMMIT_ID))
|
ifeq (need-commit-id,$(NEED_COMMIT_ID))
|
||||||
commit_id=$(shell git log -1 --pretty=%H)
|
ifneq (, $(shell git update-index --refresh --))
|
||||||
|
ACTUAL_GIT_COMMIT_EXTRAS=+uncommitted-changes
|
||||||
|
endif
|
||||||
|
ACTUAL_GIT_COMMIT_ID=$(strip $(shell git log -1 --pretty=%H))$(ACTUAL_GIT_COMMIT_EXTRAS)
|
||||||
isodate=$(shell git log -1 --pretty=%ai)
|
isodate=$(shell git log -1 --pretty=%ai)
|
||||||
commit_time=$(word 1,$(isodate))T$(word 2,$(isodate))$(word 3,$(isodate))
|
commit_time=$(word 1,$(isodate))T$(word 2,$(isodate))$(word 3,$(isodate))
|
||||||
$(shell echo SIM_GIT_COMMIT_ID $(commit_id)>.git-commit-id)
|
$(shell echo SIM_GIT_COMMIT_ID $(ACTUAL_GIT_COMMIT_ID)>.git-commit-id)
|
||||||
$(shell echo SIM_GIT_COMMIT_TIME $(commit_time)>>.git-commit-id)
|
$(shell echo SIM_GIT_COMMIT_TIME $(commit_time)>>.git-commit-id)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
8
scp.c
8
scp.c
|
@ -6221,8 +6221,12 @@ if (flag) {
|
||||||
#if defined(SIM_GIT_COMMIT_ID)
|
#if defined(SIM_GIT_COMMIT_ID)
|
||||||
#define S_xstr(a) S_str(a)
|
#define S_xstr(a) S_str(a)
|
||||||
#define S_str(a) #a
|
#define S_str(a) #a
|
||||||
fprintf (st, "%sgit commit id: %8.8s", flag ? "\n " : " ", S_xstr(SIM_GIT_COMMIT_ID));
|
if (1) {
|
||||||
setenv ("SIM_GIT_COMMIT_ID", S_xstr(SIM_GIT_COMMIT_ID), 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)
|
#if defined(SIM_GIT_COMMIT_TIME)
|
||||||
setenv ("SIM_GIT_COMMIT_TIME", S_xstr(SIM_GIT_COMMIT_TIME), 1);
|
setenv ("SIM_GIT_COMMIT_TIME", S_xstr(SIM_GIT_COMMIT_TIME), 1);
|
||||||
if (flag)
|
if (flag)
|
||||||
|
|
Loading…
Add table
Reference in a new issue