Version adjustments

This commit is contained in:
Ani 2017-12-08 21:47:49 +00:00 committed by Ani
parent d7881c6714
commit 6b323d7e2e
4 changed files with 31 additions and 31 deletions

View file

@ -23,6 +23,10 @@ matrix:
git: git:
submodules: false submodules: false
# Unshallow clone to obtain proper GIT_VERSION
# There's no variable to disable depth, so we just have to set it to a huge number
# https://docs.travis-ci.com/user/customizing-the-build/#Git-Clone-Depth
depth: 100000
before_install: before_install:
- if [ "$CC" = "clang" ]; then - if [ "$CC" = "clang" ]; then

View file

@ -13,7 +13,7 @@ rem // A copy of the GPL 2.0 should have been included with the program.
rem // If not, see http://www.gnu.org/licenses/ rem // If not, see http://www.gnu.org/licenses/
rem // Official git repository and contact information can be found at rem // Official git repository and contact information can be found at
rem // https://github.com/RPCS3/rpcs3 and http://rpcs3.net/. rem // https://github.com/RPCS3/rpcs3 and https://rpcs3.net/.
setlocal ENABLEDELAYEDEXPANSION setlocal ENABLEDELAYEDEXPANSION
setlocal ENABLEEXTENSIONS setlocal ENABLEEXTENSIONS
@ -55,33 +55,30 @@ if errorlevel 1 (
goto done goto done
) )
rem // Get commit count from HEAD by default rem // If we're in AppVeyor, building a non-master, pull request artifact
for /F %%I IN ('call %GIT% rev-list HEAD --count') do set GIT_VERSION=%%I
rem // If we're in AppVeyor and we're building for master: Get commit count from unshallowed upstream
if defined APPVEYOR (
if not defined APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH (
call %GIT% remote add upstream https://github.com/RPCS3/RPCS3.git
call %GIT% fetch --unshallow upstream
for /F %%I IN ('call %GIT% rev-list --count upstream/master') do set GIT_VERSION=%%I
)
)
if defined APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH ( if defined APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH (
if "%APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH%"=="master" ( if "%APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH%"=="master" (
rem // If pull request comes from a master branch, GIT_BRANCH = username/branch in order to distinguish from upstream/master
for /f "tokens=1* delims=/" %%a in ("%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%") do set user=%%a for /f "tokens=1* delims=/" %%a in ("%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%") do set user=%%a
set "GIT_BRANCH=!user!/%APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH%" set "GIT_BRANCH=!user!/%APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH%"
) else ( ) else (
rem // Otherwise, GIT_BRANCH=branch
set GIT_BRANCH=%APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH% set GIT_BRANCH=%APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH%
) )
) else ( rem // Make GIT_VERSION the last commit (shortened); Don't include commit count on non-master builds
for /F %%I IN ('call %GIT% rev-parse --abbrev-ref HEAD') do set GIT_BRANCH=%%I for /F %%I IN ('call %GIT% rev-parse --short HEAD') do set GIT_VERSION=%%I
)
) else (
rem // Get commit count from (unshallowed) HEAD
for /F %%I IN ('call %GIT% rev-list HEAD --count') do set GIT_VERSION=%%I
rem // Get last commit (shortened) and concat after commit count in GIT_VERSION rem // Get last commit (shortened) and concat after commit count in GIT_VERSION
for /F %%I IN ('call %GIT% rev-parse --short HEAD') do set GIT_VERSION=%GIT_VERSION%-%%I for /F %%I IN ('call %GIT% rev-parse --short HEAD') do set GIT_VERSION=%GIT_VERSION%-%%I
for /F %%I IN ('call %GIT% rev-parse --abbrev-ref HEAD') do set GIT_BRANCH=%%I
)
rem // Echo obtained GIT_VERSION for debug purposes if needed rem // Echo obtained GIT_VERSION for debug purposes if needed
echo %GIT_VERSION% echo %GIT_VERSION%

View file

@ -15,9 +15,6 @@ image: Visual Studio 2015
# clone directory # clone directory
clone_folder: c:\projects\rpcs3 clone_folder: c:\projects\rpcs3
# set clone depth
clone_depth: 3 # clone entire repository history if not defined
# environment variables # environment variables
environment: environment:
QTDIR: C:\Qt\5.9\msvc2015_64 QTDIR: C:\Qt\5.9\msvc2015_64

View file

@ -19,18 +19,20 @@ if(GIT_FOUND AND EXISTS "${SOURCE_DIR}/../.git/")
if(NOT ${exit_code} EQUAL 0) if(NOT ${exit_code} EQUAL 0)
message(WARNING "git rev-parse failed, unable to include version.") message(WARNING "git rev-parse failed, unable to include version.")
endif() endif()
# (Unused code, we're currently building with MSVC on AppVeyor)
# Hack fix for AppVeyor (Pull Requests don't generate a branch name) # Hack fix for AppVeyor (Pull Requests don't generate a branch name)
if(NOT DEFINED ENV{APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH}) #
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD # if(NOT DEFINED ENV{APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH})
WORKING_DIRECTORY ${SOURCE_DIR} # execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
RESULT_VARIABLE exit_code # WORKING_DIRECTORY ${SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH) # RESULT_VARIABLE exit_code
if(NOT ${exit_code} EQUAL 0) # OUTPUT_VARIABLE GIT_BRANCH)
message(WARNING "git rev-parse failed, unable to include git branch.") # if(NOT ${exit_code} EQUAL 0)
endif() # message(WARNING "git rev-parse failed, unable to include git branch.")
else() # endif()
set(GIT_BRANCH $ENV{APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH}) # else()
endif() # set(GIT_BRANCH $ENV{APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH})
# endif()
string(STRIP ${GIT_VERSION} GIT_VERSION) string(STRIP ${GIT_VERSION} GIT_VERSION)
string(STRIP ${GIT_VERSION_} GIT_VERSION_) string(STRIP ${GIT_VERSION_} GIT_VERSION_)
string(STRIP ${GIT_VERSION}-${GIT_VERSION_} GIT_VERSION) string(STRIP ${GIT_VERSION}-${GIT_VERSION_} GIT_VERSION)