From 6b323d7e2e78d6b5b14eb13f00bcf04d742ec321 Mon Sep 17 00:00:00 2001 From: Ani Date: Fri, 8 Dec 2017 21:47:49 +0000 Subject: [PATCH] Version adjustments --- .travis.yml | 4 ++++ Utilities/git-version-gen.cmd | 29 +++++++++++++---------------- appveyor.yml | 3 --- rpcs3/git-version.cmake | 26 ++++++++++++++------------ 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/.travis.yml b/.travis.yml index a16e35aff0..3125906214 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,6 +23,10 @@ matrix: git: 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: - if [ "$CC" = "clang" ]; then diff --git a/Utilities/git-version-gen.cmd b/Utilities/git-version-gen.cmd index 3595ca3ef4..15ce1f9f7a 100644 --- a/Utilities/git-version-gen.cmd +++ b/Utilities/git-version-gen.cmd @@ -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 // 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 ENABLEEXTENSIONS @@ -55,33 +55,30 @@ if errorlevel 1 ( goto done ) -rem // Get commit count from HEAD by default -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 - ) -) - +rem // If we're in AppVeyor, building a non-master, pull request artifact if defined APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH ( + 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 set "GIT_BRANCH=!user!/%APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH%" ) else ( + rem // Otherwise, GIT_BRANCH=branch set GIT_BRANCH=%APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH% ) + 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 --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 + 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 // 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 - rem // Echo obtained GIT_VERSION for debug purposes if needed echo %GIT_VERSION% diff --git a/appveyor.yml b/appveyor.yml index 294e41016e..a66316f069 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -15,9 +15,6 @@ image: Visual Studio 2015 # clone directory clone_folder: c:\projects\rpcs3 -# set clone depth -clone_depth: 3 # clone entire repository history if not defined - # environment variables environment: QTDIR: C:\Qt\5.9\msvc2015_64 diff --git a/rpcs3/git-version.cmake b/rpcs3/git-version.cmake index 3807f08a38..7cdea6a5f2 100644 --- a/rpcs3/git-version.cmake +++ b/rpcs3/git-version.cmake @@ -19,18 +19,20 @@ if(GIT_FOUND AND EXISTS "${SOURCE_DIR}/../.git/") if(NOT ${exit_code} EQUAL 0) message(WARNING "git rev-parse failed, unable to include version.") endif() - # 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 - WORKING_DIRECTORY ${SOURCE_DIR} - RESULT_VARIABLE exit_code - OUTPUT_VARIABLE GIT_BRANCH) - if(NOT ${exit_code} EQUAL 0) - message(WARNING "git rev-parse failed, unable to include git branch.") - endif() - else() - set(GIT_BRANCH $ENV{APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH}) - endif() + # (Unused code, we're currently building with MSVC on AppVeyor) + # 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 + # WORKING_DIRECTORY ${SOURCE_DIR} + # RESULT_VARIABLE exit_code + # OUTPUT_VARIABLE GIT_BRANCH) + # if(NOT ${exit_code} EQUAL 0) + # message(WARNING "git rev-parse failed, unable to include git branch.") + # endif() + # else() + # 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_} GIT_VERSION)