From d6dc56670ffde07eb0b4c57248544fcd9bbcb2d7 Mon Sep 17 00:00:00 2001 From: Underground78 Date: Mon, 7 Oct 2013 23:21:45 +0200 Subject: [MPC-HC] Make sure the git build number identify the vanilla LAV Filters we are based on. 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. --- common/genversion.bat | 64 +++++++++++++++++------------------------------- common/version.sh | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 42 deletions(-) create mode 100644 common/version.sh 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 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 . + +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 -- cgit v1.2.3