makefile, Visual Studio Projects: remove dependency on git hooks
the repository commit id will now be verified on each build directly.
This commit is contained in:
parent
65e931c1ff
commit
699d28fb83
6 changed files with 34 additions and 115 deletions
|
@ -21,15 +21,8 @@ rem files are available in the directory ..\..\windows-build\
|
||||||
rem
|
rem
|
||||||
rem In addition to the optional activities mentioned above, other activities
|
rem In addition to the optional activities mentioned above, other activities
|
||||||
rem are also performed. These include:
|
rem are also performed. These include:
|
||||||
rem - confirming that if the current source is a clone of the simh
|
rem - performing the activities which make confirm or generate the git
|
||||||
rem git repository, then assuring that git hooks which manage making
|
rem repository commit id available in an include file during compiles.
|
||||||
rem the git commit hash available during builds are properly installed
|
|
||||||
rem in the repository hooks directory. When the githooks are installed
|
|
||||||
rem the current commit id is generated if git.exe is available in the
|
|
||||||
rem current path. If it isn't, then report that fact and suggest how
|
|
||||||
rem to make sure that it is.
|
|
||||||
rem - performing the activities which make the git repository commit id
|
|
||||||
rem available in an include file during compiles.
|
|
||||||
rem
|
rem
|
||||||
rem
|
rem
|
||||||
|
|
||||||
|
@ -204,10 +197,10 @@ echo error: Review the Output Tab for more details.
|
||||||
exit 1
|
exit 1
|
||||||
:_done_build
|
:_done_build
|
||||||
|
|
||||||
:_GitHooks
|
:_CheckGit
|
||||||
if not exist ..\.git goto _done_hooks
|
if not exist ..\.git goto _done_id
|
||||||
call :FindGit _GIT_GIT
|
call :FindGit _GIT_GIT
|
||||||
if "%_GIT_GIT%" neq "" goto _check_hooks
|
if "%_GIT_GIT%" neq "" goto _SetId
|
||||||
echo ** ERROR ** ERROR ** ERROR ** ERROR ** ERROR ** ERROR **
|
echo ** ERROR ** ERROR ** ERROR ** ERROR ** ERROR ** ERROR **
|
||||||
echo ** ERROR ** ERROR ** ERROR ** ERROR ** ERROR ** ERROR **
|
echo ** ERROR ** ERROR ** ERROR ** ERROR ** ERROR ** ERROR **
|
||||||
echo ** **
|
echo ** **
|
||||||
|
@ -231,29 +224,7 @@ echo ** ERROR ** ERROR ** ERROR ** ERROR ** ERROR ** ERROR **
|
||||||
echo ** ERROR ** ERROR ** ERROR ** ERROR ** ERROR ** ERROR **
|
echo ** ERROR ** ERROR ** ERROR ** ERROR ** ERROR ** ERROR **
|
||||||
echo error: Review the Output Tab for more details.
|
echo error: Review the Output Tab for more details.
|
||||||
exit 1
|
exit 1
|
||||||
:_check_hooks
|
:_done_git
|
||||||
if not exist ..\.git\hooks\post-commit goto _initial_hooks
|
|
||||||
fc /b ..\.git\hooks\post-commit git-hooks\post-commit >nul
|
|
||||||
if %ERRORLEVEL% equ 0 goto _done_hooks
|
|
||||||
echo *****************************************************
|
|
||||||
echo *****************************************************
|
|
||||||
echo ** Installing updated git hooks in repository **
|
|
||||||
echo *****************************************************
|
|
||||||
echo *****************************************************
|
|
||||||
goto _install_hooks
|
|
||||||
:_initial_hooks
|
|
||||||
echo *****************************************************
|
|
||||||
echo *****************************************************
|
|
||||||
echo ** Installing git hooks in newly cloned repository **
|
|
||||||
echo *****************************************************
|
|
||||||
echo *****************************************************
|
|
||||||
:_install_hooks
|
|
||||||
copy /y git-hooks\post* ..\.git\hooks\
|
|
||||||
:_do_hooks
|
|
||||||
pushd ..
|
|
||||||
"%_GIT_GIT%" log -1 --pretty="SIM_GIT_COMMIT_ID %%H%%nSIM_GIT_COMMIT_TIME %%aI" >.git-commit-id
|
|
||||||
popd
|
|
||||||
:_done_hooks
|
|
||||||
|
|
||||||
:_SetId
|
:_SetId
|
||||||
rem
|
rem
|
||||||
|
@ -261,25 +232,23 @@ rem A race condition exists while creating the .git-commit-id.h file.
|
||||||
rem This race can happen at the beginning of a parallel build where
|
rem This race can happen at the beginning of a parallel build where
|
||||||
rem several projects can start execution at almost the same time.
|
rem several projects can start execution at almost the same time.
|
||||||
rem
|
rem
|
||||||
|
SET ACTUAL_GIT_COMMIT_ID=
|
||||||
|
SET ACTUAL_GIT_COMMIT_TIME=
|
||||||
SET GIT_COMMIT_ID=
|
SET GIT_COMMIT_ID=
|
||||||
SET GIT_COMMIT_TIME=
|
SET GIT_COMMIT_TIME=
|
||||||
if not exist ..\.git-commit-id goto _do_hooks
|
|
||||||
for /F "usebackq tokens=2" %%i in (`findstr /C:SIM_GIT_COMMIT_ID ..\.git-commit-id`) do SET GIT_COMMIT_ID=%%i
|
|
||||||
for /F "usebackq tokens=2" %%i in (`findstr /C:SIM_GIT_COMMIT_TIME ..\.git-commit-id`) do SET GIT_COMMIT_TIME=%%i
|
|
||||||
rem
|
|
||||||
rem Some 'git' environments don't honor the installed hooks (Visual
|
|
||||||
rem Studio 2015 for example), and in this case the initially generated
|
|
||||||
rem .git-commit-id file won't get updated. We can't be sure of this
|
|
||||||
rem detail, so perform a manual check now.
|
|
||||||
SET _GIT_COMMIT_ID_TEMP=.git-commit-id-temp-%RANDOM%
|
SET _GIT_COMMIT_ID_TEMP=.git-commit-id-temp-%RANDOM%
|
||||||
"%_GIT_GIT%" log -1 --pretty="SIM_GIT_COMMIT_ID %%H%%nSIM_GIT_COMMIT_TIME %%aI" >%_GIT_COMMIT_ID_TEMP%
|
"%_GIT_GIT%" log -1 --pretty="SIM_GIT_COMMIT_ID %%H%%nSIM_GIT_COMMIT_TIME %%aI" >%_GIT_COMMIT_ID_TEMP%
|
||||||
for /F "usebackq tokens=2" %%i in (`findstr /C:SIM_GIT_COMMIT_ID %_GIT_COMMIT_ID_TEMP%`) do SET CURRENT_GIT_COMMIT_ID=%%i
|
for /F "usebackq tokens=2" %%i in (`findstr /C:SIM_GIT_COMMIT_ID %_GIT_COMMIT_ID_TEMP%`) do SET ACTUAL_GIT_COMMIT_ID=%%i
|
||||||
for /F "usebackq tokens=2" %%i in (`findstr /C:SIM_GIT_COMMIT_TIME %_GIT_COMMIT_ID_TEMP%`) do SET CURRENT_GIT_COMMIT_TIME=%%i
|
for /F "usebackq tokens=2" %%i in (`findstr /C:SIM_GIT_COMMIT_TIME %_GIT_COMMIT_ID_TEMP%`) do SET ACTUAL_GIT_COMMIT_TIME=%%i
|
||||||
if "%CURRENT_GIT_COMMIT_ID%" neq "%GIT_COMMIT_ID%" move /Y %_GIT_COMMIT_ID_TEMP% ..\.git-commit-id
|
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 "%CURRENT_GIT_COMMIT_ID%" equ "%GIT_COMMIT_ID%" del %_GIT_COMMIT_ID_TEMP%
|
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%" move /Y %_GIT_COMMIT_ID_TEMP% ..\.git-commit-id
|
||||||
|
if "%ACTUAL_GIT_COMMIT_ID%" equ "%GIT_COMMIT_ID%" del %_GIT_COMMIT_ID_TEMP%
|
||||||
|
SET GIT_COMMIT_ID=%ACTUAL_GIT_COMMIT_ID%
|
||||||
|
SET SIM_GIT_COMMIT_TIME=%ACTUAL_SIM_GIT_COMMIT_TIME%
|
||||||
SET _GIT_COMMIT_ID_TEMP=
|
SET _GIT_COMMIT_ID_TEMP=
|
||||||
SET CURRENT_GIT_COMMIT_ID=
|
SET ACTUAL_GIT_COMMIT_ID=
|
||||||
SET CURRENT_GIT_COMMIT_TIME=
|
SET ACTUAL_GIT_COMMIT_TIME=
|
||||||
:_VerifyGitCommitId.h
|
:_VerifyGitCommitId.h
|
||||||
SET OLD_GIT_COMMIT_ID=
|
SET OLD_GIT_COMMIT_ID=
|
||||||
if not exist .git-commit-id.h echo.>.git-commit-id.h
|
if not exist .git-commit-id.h echo.>.git-commit-id.h
|
||||||
|
@ -292,8 +261,10 @@ if errorlevel 1 echo Retrying...
|
||||||
if errorlevel 1 goto _SetId
|
if errorlevel 1 goto _SetId
|
||||||
:_IdGood
|
:_IdGood
|
||||||
:_done_id
|
:_done_id
|
||||||
|
if not exist .git-commit-id.h echo. >.git-commit-id.h
|
||||||
goto :EOF
|
goto :EOF
|
||||||
|
|
||||||
|
|
||||||
:WhereInPath
|
:WhereInPath
|
||||||
if "%~$PATH:1" NEQ "" exit /B 0
|
if "%~$PATH:1" NEQ "" exit /B 0
|
||||||
exit /B 1
|
exit /B 1
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
This dirctory contains a set of git hook scripts which are useful when
|
|
||||||
working with this repository to make the git commit id available when
|
|
||||||
building simulators to uniquely identify the inputs to that build.
|
|
||||||
|
|
||||||
It is ONLY useful for folks who clone this as a repository and build
|
|
||||||
in the working directory of that repository.
|
|
||||||
|
|
||||||
Folks who download zip or tarball archives of the repository have the
|
|
||||||
git commit-id automatically inserted into the sim_rev.h file when the
|
|
||||||
archive is created due to a substitution performed via this repository's
|
|
||||||
.gitattributes.
|
|
||||||
|
|
||||||
To use these scripts automatically, copy these files to the .git/hooks
|
|
||||||
directory of the current repository. This can be done with the
|
|
||||||
following commands:
|
|
||||||
|
|
||||||
$ cd Visual\ Studio\ Projects/git-hooks
|
|
||||||
$ chmod +x post*
|
|
||||||
$ cp post* ../../.git/hooks/
|
|
||||||
|
|
||||||
Note: The makefile AND the Visual Studio Projects automatically
|
|
||||||
will install these git hooks in the ../../.git/hooks/ directory
|
|
||||||
if they're not already there and execute them as needed.
|
|
|
@ -1,7 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
#
|
|
||||||
# A hook script that is called after a successful
|
|
||||||
# checkout to record the commit-id in the working directory.
|
|
||||||
isodate=$(git log -1 --pretty="%ai"|sed -e 's/ /T/'|sed -e 's/ //')
|
|
||||||
git log -1 --pretty="SIM_GIT_COMMIT_ID %H%nSIM_GIT_COMMIT_TIME $isodate" >.git-commit-id
|
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
#
|
|
||||||
# A hook script that is called after a successful
|
|
||||||
# commit is made to record the commit-id in the working directory.
|
|
||||||
isodate=$(git log -1 --pretty="%ai"|sed -e 's/ /T/'|sed -e 's/ //')
|
|
||||||
git log -1 --pretty="SIM_GIT_COMMIT_ID %H%nSIM_GIT_COMMIT_TIME $isodate" >.git-commit-id
|
|
|
@ -1,7 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
#
|
|
||||||
# A hook script that is called after a successful merge
|
|
||||||
# to record the commit-id in the working directory.
|
|
||||||
isodate=$(git log -1 --pretty="%ai"|sed -e 's/ /T/'|sed -e 's/ //')
|
|
||||||
git log -1 --pretty="SIM_GIT_COMMIT_ID %H%nSIM_GIT_COMMIT_TIME $isodate" >.git-commit-id
|
|
||||||
|
|
37
makefile
37
makefile
|
@ -128,7 +128,7 @@ ifneq ($(findstring Windows,$(OS)),)
|
||||||
else # Msys or cygwin
|
else # Msys or cygwin
|
||||||
ifeq (MINGW,$(findstring MINGW,$(shell uname)))
|
ifeq (MINGW,$(findstring MINGW,$(shell uname)))
|
||||||
$(info *** This makefile can not be used with the Msys bash shell)
|
$(info *** This makefile can not be used with the Msys bash shell)
|
||||||
$(error *** Use build_mingw.bat $(MAKECMDGOALS) from a Windows command prompt)
|
$(error Use build_mingw.bat $(MAKECMDGOALS) from a Windows command prompt)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
@ -197,31 +197,22 @@ ifeq ($(WIN32),) #*nix Environments (&& cygwin)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
ifeq (git-repo,$(shell if $(TEST) -d ./.git; then echo git-repo; fi))
|
ifeq (git-repo,$(shell if $(TEST) -d ./.git; then echo git-repo; fi))
|
||||||
NEED_HOOKS = $(shell if $(TEST) ! -e ./.git/hooks/post-checkout; then echo need-hooks; fi)
|
GIT_PATH=$(strip $(shell which git))
|
||||||
ifeq (,$(NEED_HOOKS))
|
ifeq (,$(GIT_PATH))
|
||||||
NEED_HOOKS = $(shell if ! `diff ./.git/hooks/post-checkout ./Visual\ Studio\ Projects/git-hooks/post-checkout >/dev/null`; then echo need-hooks; fi)
|
$(error building using a git repository, but git is not available)
|
||||||
endif
|
endif
|
||||||
ifeq (need-hooks,$(NEED_HOOKS))
|
ifeq (commit-id-exists,$(shell if $(TEST) -e .git-commit-id; then echo commit-id-exists; fi))
|
||||||
$(info *** Installing git hooks in local repository ***)
|
CURRENT_GIT_COMMIT_ID=$(strip $(shell grep 'SIM_GIT_COMMIT_ID' .git-commit-id | awk '{ print $$2 }'))
|
||||||
GIT_HOOKS += $(shell cp './Visual Studio Projects/git-hooks/post-commit' ./.git/hooks/)
|
ACTUAL_GIT_COMMIT_ID=$(strip $(shell git log -1 --pretty="%H"))
|
||||||
GIT_HOOKS += $(shell cp './Visual Studio Projects/git-hooks/post-checkout' ./.git/hooks/)
|
ifneq ($(CURRENT_GIT_COMMIT_ID),$(ACTUAL_GIT_COMMIT_ID))
|
||||||
GIT_HOOKS += $(shell cp './Visual Studio Projects/git-hooks/post-merge' ./.git/hooks/)
|
NEED_COMMIT_ID = need-commit-id
|
||||||
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 rm .git-commit-id)
|
|
||||||
endif
|
|
||||||
endif
|
endif
|
||||||
|
else
|
||||||
|
NEED_COMMIT_ID = need-commit-id
|
||||||
endif
|
endif
|
||||||
ifneq (commit-id-exists,$(shell if $(TEST) -e .git-commit-id; then echo commit-id-exists; fi))
|
ifeq (need-commit-id,$(NEED_COMMIT_ID))
|
||||||
ifeq (,$(strip $(GIT_HOOKS)))
|
$isodate=$(shell git log -1 --pretty="%ai"|sed -e 's/ /T/'|sed -e 's/ //')
|
||||||
GIT_HOOKS = $(shell ./.git/hooks/post-checkout)
|
$(shell git log -1 --pretty="SIM_GIT_COMMIT_ID %H%nSIM_GIT_COMMIT_TIME $isodate" >.git-commit-id)
|
||||||
ifneq (,$(strip $(GIT_HOOKS)))
|
|
||||||
$(info *** Warning - Error executing git hooks *** $(GIT_HOOKS))
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
LTO_EXCLUDE_VERSIONS =
|
LTO_EXCLUDE_VERSIONS =
|
||||||
|
|
Loading…
Add table
Reference in a new issue