diff options
author | Underground78 <underground78@users.sourceforge.net> | 2013-10-08 01:21:45 +0400 |
---|---|---|
committer | Underground78 <underground78@users.sourceforge.net> | 2015-12-22 21:02:22 +0300 |
commit | 2160382ebaa10475cbd48e91787b22c20e77ca4c (patch) | |
tree | 01641840c6538de8fcdf0c8372199eea0bbd9aae | |
parent | 757dbfc16dc16590f1a675b68e0c2b78ee7065e8 (diff) |
[MPC-HC] Make sure the git build number identify the vanilla LAV Filters we are based on.mpc-hc-1.7.9-7
This way if we distribute LAV Filters version X.Y.Z.N, it means that our custom build is based on:
- the stable version X.Y.Z,
- with N official patches (which will be part of next official LAV Filters build),
- and some custom non-official patches which are here to improve the integration in MPC-HC.
-rw-r--r-- | common/genversion.bat | 64 | ||||
-rw-r--r-- | common/version.sh | 67 |
2 files changed, 89 insertions, 42 deletions
diff --git a/common/genversion.bat b/common/genversion.bat index f46b30a0..59e95ab4 100644 --- a/common/genversion.bat +++ b/common/genversion.bat @@ -3,49 +3,29 @@ SETLOCAL PUSHD "%~dp0" -SET nbMAJOR_PART=0 -SET nbCOMMIT_PART=0 -SET nbHASH_PART=00000 -SET OLDVER= - -:: check for git presence -CALL git describe >NUL 2>&1 -IF ERRORLEVEL 1 ( - GOTO NOGIT -) - -:: Get git-describe output -FOR /F "tokens=*" %%A IN ('"git describe --long --abbrev=5 HEAD"') DO ( - SET strFILE_VERSION=%%A -) - -:: Split into tag, nb commits, hash -FOR /F "tokens=1,2,3 delims=-" %%A IN ("%strFILE_VERSION%") DO ( - SET nbMAJOR_PART=%%A - SET nbCOMMIT_PART=%%B - SET nbHASH_PART=%%C -) - -:: strip the "g" off the hash -SET nbHASH_PART=%nbHASH_PART:~1% - -:WRITE_VER - -:: check if info changed, and write if needed -IF EXIST includes\version_rev.h ( - SET /P OLDVER=<includes\version_rev.h -) -SET NEWVER=#define LAV_VERSION_BUILD %nbCOMMIT_PART% -IF NOT "%NEWVER%" == "%OLDVER%" ( - :: swapped order to avoid trailing newlines - > includes\version_rev.h ECHO %NEWVER% -) -GOTO :END - -:NOGIT -echo Git not found -goto WRITE_VER +IF EXIST "..\..\..\..\..\build.user.bat" CALL "..\..\..\..\..\build.user.bat" + +IF NOT DEFINED MPCHC_GIT IF DEFINED GIT (SET MPCHC_GIT=%GIT%) +IF NOT DEFINED MPCHC_MSYS IF DEFINED MSYS (SET MPCHC_MSYS=%MSYS%) ELSE (GOTO MissingVar) + +IF NOT EXIST "%MPCHC_MSYS%" GOTO MissingVar + +SET PATH=%MPCHC_MSYS%\bin;%MPCHC_GIT%\cmd;%PATH% +FOR %%G IN (bash.exe) DO (SET FOUND=%%~$PATH:G) +IF NOT DEFINED FOUND GOTO MissingVar + +bash.exe ./version.sh + :END POPD ENDLOCAL +EXIT /B + + +:MissingVar +ECHO Not all build dependencies were found. +ECHO. +ECHO See "..\..\..\..\..\docs\Compilation.txt" for more information. +ENDLOCAL +EXIT /B 1 diff --git a/common/version.sh b/common/version.sh new file mode 100644 index 00000000..3652a522 --- /dev/null +++ b/common/version.sh @@ -0,0 +1,67 @@ +#!/bin/bash +# (C) 2013 see Authors.txt +# +# This file is part of MPC-HC. +# +# MPC-HC is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# MPC-HC is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +versionfile_fixed="./includes/version.h" +versionfile="./includes/version_rev.h" + +# Read major, minor and patch version numbers from static version.h file +while read -r _ var value; do + if [[ $var == LAV_VERSION_MAJOR ]]; then + ver_fixed_major=$value + elif [[ $var == LAV_VERSION_MINOR ]]; then + ver_fixed_minor=$value + elif [[ $var == LAV_VERSION_REVISION ]]; then + ver_fixed_patch=$value + fi +done < "$versionfile_fixed" +ver_fixed="${ver_fixed_major}.${ver_fixed_minor}.${ver_fixed_patch}" +echo "Version: $ver_fixed" + +# If we are not inside a git repo use hardcoded values +if ! git rev-parse --git-dir > /dev/null 2>&1; then + hash=0000000 + ver=0 + ver_additional= + echo "Warning: Git not available or not a git repo. Using dummy values for hash and version number." +else + # Get information about the current version + describe=$(git describe --long `git log --grep="\[MPC-HC\] Use our own ffmpeg clone repository\." --pretty=%H`~1) + echo "Describe: $describe" + + # Get the abbreviated hash of the current changeset + hash=${describe##*-g} + + # Get the number changesets since the last tag + ver=${describe#*-} + ver=${ver%-*} + + echo "Hash: $hash" + if ! git diff-index --quiet HEAD; then + echo "Revision: $ver (Local modifications found)" + else + echo "Revision: $ver" + fi +fi + +version_info="#define LAV_VERSION_BUILD $ver" + +# Update version_rev.h if it does not exist, or if version information was changed. +if [[ ! -f "$versionfile" ]] || [[ "$version_info" != "$(<"$versionfile")" ]]; then + # Write the version information to version_rev.h + echo "$version_info" > "$versionfile" +fi |