From f37b991c14b48f1f1ce34f169511ce8c2581b7e9 Mon Sep 17 00:00:00 2001 From: Sit Melai Date: Sat, 7 Apr 2018 17:19:01 +0200 Subject: [PATCH 1/5] CMakeModule to find Git (previously only Mercurial) --- code/CMakeModules/FindGit.cmake | 106 ++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 code/CMakeModules/FindGit.cmake diff --git a/code/CMakeModules/FindGit.cmake b/code/CMakeModules/FindGit.cmake new file mode 100644 index 000000000..883357d79 --- /dev/null +++ b/code/CMakeModules/FindGit.cmake @@ -0,0 +1,106 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#.rst: +# FindGit +# ------- +# +# The module defines the following variables: +# +# ``GIT_EXECUTABLE`` +# Path to Git command-line client. +# ``Git_FOUND``, ``GIT_FOUND`` +# True if the Git command-line client was found. +# ``GIT_VERSION_STRING`` +# The version of Git found. +# +# Example usage: +# +# .. code-block:: cmake +# +# find_package(Git) +# if(Git_FOUND) +# message("Git found: ${GIT_EXECUTABLE}") +# endif() + +# Look for 'git' or 'eg' (easy git) +# +set(git_names git eg) + +# Prefer .cmd variants on Windows unless running in a Makefile +# in the MSYS shell. +# +if(CMAKE_HOST_WIN32) + if(NOT CMAKE_GENERATOR MATCHES "MSYS") + set(git_names git.cmd git eg.cmd eg) + # GitHub search path for Windows + file(GLOB github_path + "$ENV{LOCALAPPDATA}/Github/PortableGit*/cmd" + "$ENV{LOCALAPPDATA}/Github/PortableGit*/bin" + ) + # SourceTree search path for Windows + set(_git_sourcetree_path "$ENV{LOCALAPPDATA}/Atlassian/SourceTree/git_local/bin") + endif() +endif() + +# First search the PATH and specific locations. +find_program(GIT_EXECUTABLE + NAMES ${git_names} + PATHS ${github_path} ${_git_sourcetree_path} + DOC "Git command line client" + ) + +if(CMAKE_HOST_WIN32) + # Now look for installations in Git/ directories under typical installation + # prefixes on Windows. Exclude PATH from this search because VS 2017's + # command prompt happens to have a PATH entry with a Git/ subdirectory + # containing a minimal git not meant for general use. + find_program(GIT_EXECUTABLE + NAMES ${git_names} + PATH_SUFFIXES Git/cmd Git/bin + NO_SYSTEM_ENVIRONMENT_PATH + DOC "Git command line client" + ) +endif() + +mark_as_advanced(GIT_EXECUTABLE) + +MACRO(Git_WC_INFO dir prefix) + EXECUTE_PROCESS(COMMAND ${Git_EXECUTABLE} log -r --pretty=format:"%d;%H;%an" . + WORKING_DIRECTORY ${dir} + OUTPUT_VARIABLE ${prefix}_WC_INFO + ERROR_VARIABLE Git_info_error + RESULT_VARIABLE Git_info_result + OUTPUT_STRIP_TRAILING_WHITESPACE) + + IF(NOT ${Git_info_result} EQUAL 0) + MESSAGE(SEND_ERROR "Command \"${GIT_EXECUTABLE} log\" failed with output:\n${Git_info_error}") + ELSE() + LIST(LENGTH ${prefix}_WC_INFO _COUNT) + IF(_COUNT EQUAL 4) + LIST(GET ${prefix}_WC_INFO 0 ${prefix}_WC_REVISION) + LIST(GET ${prefix}_WC_INFO 1 ${prefix}_WC_CHANGESET) + LIST(GET ${prefix}_WC_INFO 3 ${prefix}_WC_LAST_CHANGED_AUTHOR) + ELSE() + MESSAGE(STATUS "Bad output from HG") + SET(${prefix}_WC_REVISION "unknown") + SET(${prefix}_WC_CHANGESET "unknown") + SET(${prefix}_WC_BRANCH "unknown") + ENDIF() + ENDIF() + + ENDMACRO() + +unset(git_names) +unset(_git_sourcetree_path) + +if(GIT_EXECUTABLE) + execute_process(COMMAND ${GIT_EXECUTABLE} --version + OUTPUT_VARIABLE git_version + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if (git_version MATCHES "^git version [0-9]") + string(REPLACE "git version " "" GIT_VERSION_STRING "${git_version}") + endif() + unset(git_version) +endif() From 69c8be03d9e327eaecf34685faf4eca81525394c Mon Sep 17 00:00:00 2001 From: Sit Melai Date: Sat, 7 Apr 2018 17:20:10 +0200 Subject: [PATCH 2/5] Prevent crash on Windows due to no revision from Git or Mercurial found. --- code/CMakeModules/GetRevision.cmake | 187 +++++++++++++++------------- 1 file changed, 101 insertions(+), 86 deletions(-) diff --git a/code/CMakeModules/GetRevision.cmake b/code/CMakeModules/GetRevision.cmake index b29a8763e..b9bd6eb84 100644 --- a/code/CMakeModules/GetRevision.cmake +++ b/code/CMakeModules/GetRevision.cmake @@ -1,86 +1,101 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6.3) - -# ROOT_DIR should be set to root of the repository (where to find the .svn or .hg directory) -# SOURCE_DIR should be set to root of your code (where to find CMakeLists.txt) -# BINARY_DIR should be set to root of your build directory - -IF(SOURCE_DIR) - # Replace spaces by semi-columns - IF(CMAKE_MODULE_PATH) - STRING(REPLACE " " ";" CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}) - ENDIF() - - SET(CMAKE_MODULE_PATH ${SOURCE_DIR}/CMakeModules ${CMAKE_MODULE_PATH}) - - IF(NOT ROOT_DIR AND SOURCE_DIR) - SET(ROOT_DIR ${SOURCE_DIR}) - ENDIF() - - IF(NOT SOURCE_DIR AND ROOT_DIR) - SET(SOURCE_DIR ${ROOT_DIR}) - ENDIF() -ELSE() - SET(SOURCE_DIR ${CMAKE_SOURCE_DIR}) - SET(ROOT_DIR ${CMAKE_SOURCE_DIR}/..) - - # convert ROOT_DIR to absolute path - GET_FILENAME_COMPONENT(ROOT_DIR ${ROOT_DIR} ABSOLUTE) -ENDIF() - -MACRO(NOW RESULT) - IF(CMAKE_VERSION VERSION_GREATER "2.8.10") - STRING(TIMESTAMP ${RESULT} "%Y-%m-%d %H:%M:%S") - ELSE() - IF(WIN32) - EXECUTE_PROCESS(COMMAND "wmic" "os" "get" "localdatetime" OUTPUT_VARIABLE DATETIME) - IF(NOT DATETIME MATCHES "ERROR") - STRING(REGEX REPLACE ".*\n([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9]).*" "\\1-\\2-\\3 \\4:\\5:\\6" ${RESULT} "${DATETIME}") - ENDIF() - ELSEIF(UNIX) - EXECUTE_PROCESS(COMMAND "date" "+%Y-%m-%d %H:%M:%S" OUTPUT_VARIABLE DATETIME) - STRING(REGEX REPLACE "([0-9: -]+).*" "\\1" ${RESULT} "${DATETIME}") - ELSE() - MESSAGE(SEND_ERROR "date not implemented") - SET(${RESULT} "0000-00-00 00:00:00") - ENDIF() - ENDIF() -ENDMACRO() - -IF(EXISTS "${ROOT_DIR}/.svn/") - FIND_PACKAGE(Subversion QUIET) - - IF(SUBVERSION_FOUND) - Subversion_WC_INFO(${ROOT_DIR} ER) - SET(REVISION ${ER_WC_REVISION}) - ENDIF() - - FIND_PACKAGE(TortoiseSVN QUIET) - - IF(TORTOISESVN_FOUND) - TORTOISESVN_GET_REVISION(${ROOT_DIR} REVISION) - ENDIF() -ENDIF() - -IF(EXISTS "${ROOT_DIR}/.hg/") - FIND_PACKAGE(Mercurial) - - IF(MERCURIAL_FOUND) - Mercurial_WC_INFO(${ROOT_DIR} ER) - SET(REVISION ${ER_WC_REVISION}) - SET(CHANGESET ${ER_WC_CHANGESET}) - SET(BRANCH ${ER_WC_BRANCH}) - ENDIF() -ENDIF() - -# if processing exported sources, use "revision" file if exists -IF(SOURCE_DIR AND NOT DEFINED REVISION) - SET(REVISION_FILE ${SOURCE_DIR}/revision) - IF(EXISTS ${REVISION_FILE}) - FILE(STRINGS ${REVISION_FILE} REVISION LIMIT_COUNT 1) - MESSAGE(STATUS "Read revision ${REVISION} from file") - ENDIF() -ENDIF() - -IF(DEFINED REVISION) - MESSAGE(STATUS "Found revision ${REVISION}") -ENDIF() +CMAKE_MINIMUM_REQUIRED(VERSION 2.6.3) + +# ROOT_DIR should be set to root of the repository (where to find the .svn or .hg directory) +# SOURCE_DIR should be set to root of your code (where to find CMakeLists.txt) +# BINARY_DIR should be set to root of your build directory + +IF(SOURCE_DIR) + # Replace spaces by semi-columns + IF(CMAKE_MODULE_PATH) + STRING(REPLACE " " ";" CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}) + ENDIF() + + SET(CMAKE_MODULE_PATH ${SOURCE_DIR}/CMakeModules ${CMAKE_MODULE_PATH}) + + IF(NOT ROOT_DIR AND SOURCE_DIR) + SET(ROOT_DIR ${SOURCE_DIR}) + ENDIF() + + IF(NOT SOURCE_DIR AND ROOT_DIR) + SET(SOURCE_DIR ${ROOT_DIR}) + ENDIF() +ELSE() + SET(SOURCE_DIR ${CMAKE_SOURCE_DIR}) + SET(ROOT_DIR ${CMAKE_SOURCE_DIR}/..) + + # convert ROOT_DIR to absolute path + GET_FILENAME_COMPONENT(ROOT_DIR ${ROOT_DIR} ABSOLUTE) +ENDIF() + +MACRO(NOW RESULT) + IF(CMAKE_VERSION VERSION_GREATER "2.8.10") + STRING(TIMESTAMP ${RESULT} "%Y-%m-%d %H:%M:%S") + ELSE() + IF(WIN32) + EXECUTE_PROCESS(COMMAND "wmic" "os" "get" "localdatetime" OUTPUT_VARIABLE DATETIME) + IF(NOT DATETIME MATCHES "ERROR") + STRING(REGEX REPLACE ".*\n([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9]).*" "\\1-\\2-\\3 \\4:\\5:\\6" ${RESULT} "${DATETIME}") + ENDIF() + ELSEIF(UNIX) + EXECUTE_PROCESS(COMMAND "date" "+%Y-%m-%d %H:%M:%S" OUTPUT_VARIABLE DATETIME) + STRING(REGEX REPLACE "([0-9: -]+).*" "\\1" ${RESULT} "${DATETIME}") + ELSE() + MESSAGE(SEND_ERROR "date not implemented") + SET(${RESULT} "0000-00-00 00:00:00") + ENDIF() + ENDIF() +ENDMACRO() + +IF(EXISTS "${ROOT_DIR}/.svn/") + FIND_PACKAGE(Subversion QUIET) + + IF(SUBVERSION_FOUND) + Subversion_WC_INFO(${ROOT_DIR} ER) + SET(REVISION ${ER_WC_REVISION}) + ENDIF() + + FIND_PACKAGE(TortoiseSVN QUIET) + + IF(TORTOISESVN_FOUND) + TORTOISESVN_GET_REVISION(${ROOT_DIR} REVISION) + ENDIF() +ENDIF() + +IF(EXISTS "${ROOT_DIR}/.hg/") + FIND_PACKAGE(Mercurial) + + IF(MERCURIAL_FOUND) + Mercurial_WC_INFO(${ROOT_DIR} ER) + SET(REVISION ${ER_WC_REVISION}) + SET(CHANGESET ${ER_WC_CHANGESET}) + SET(BRANCH ${ER_WC_BRANCH}) + ENDIF() +ENDIF() + +IF(EXISTS "${ROOT_DIR}/.git/") + FIND_PACKAGE(Git) + + IF(GIT_FOUND) + Git_WC_INFO(${ROOT_DIR} ER) + SET(REVISION ${ER_WC_REVISION}) + SET(CHANGESET ${ER_WC_CHANGESET}) + ENDIF() +ENDIF() + +# if processing exported sources, use "revision" file if exists +IF(SOURCE_DIR AND NOT DEFINED REVISION) + SET(REVISION_FILE ${SOURCE_DIR}/revision) + IF(EXISTS ${REVISION_FILE}) + FILE(STRINGS ${REVISION_FILE} REVISION LIMIT_COUNT 1) + MESSAGE(STATUS "Read revision ${REVISION} from file") + ENDIF() +ENDIF() + +# Prevent crash if no revision from git or mercurial found +IF(NOT DEFINED REVISION) + SET(REVISION 0) +ENDIF() + +IF(DEFINED REVISION) + MESSAGE(STATUS "Found revision ${REVISION}") +ENDIF() From 6a6252b4fbcb275b948716a6ddb1f476211da237 Mon Sep 17 00:00:00 2001 From: Sit Melai Date: Wed, 11 Apr 2018 18:31:18 +0200 Subject: [PATCH 3/5] Ajout de la branche mac-ci-build pour compiler le client sur Mac OS X --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6bfe941b6..d36e51e93 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -585,6 +585,7 @@ OSX client build: stage: build only: - tags + - mac-ci-build tags: - OSX script: From 8a37223e35248a7a6998d7d44f3eb166f09084f3 Mon Sep 17 00:00:00 2001 From: Sit Melai Date: Wed, 11 Apr 2018 18:36:38 +0200 Subject: [PATCH 4/5] Compiler seulement le client Mac OSX sur la branche mac-ci-build --- .gitlab-ci.yml | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d36e51e93..10ba3b076 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -39,6 +39,7 @@ Linux client build: stage: build except: - ryzomcore + - mac-ci-build tags: - Docker image: debian:jessie @@ -88,6 +89,8 @@ Linux client build: Linux server debian_amd64_strech build: stage: build + except: + - mac-ci-build tags: - Docker image: amd64/debian:9 @@ -169,6 +172,8 @@ Linux server debian_amd64_strech build: Linux client debian_amd64_strech build: stage: build + except: + - mac-ci-build tags: - Docker image: amd64/debian:9 @@ -229,6 +234,8 @@ Linux client debian_amd64_strech build: Linux client_static debian_amd64_strech build: stage: build + except: + - mac-ci-build tags: - Docker image: amd64/debian:9 @@ -335,6 +342,8 @@ Linux client_static debian_amd64_strech build: # Fedora Client Linux client fedora_amd64_27 build: stage: build + except: + - mac-ci-build tags: - Docker image: amd64/fedora:27 @@ -395,6 +404,8 @@ Linux client fedora_amd64_27 build: # Ubuntu Client Linux client ubuntu_amd64_17_10 build: stage: build + except: + - mac-ci-build tags: - Docker image: amd64/ubuntu:17.10 @@ -450,6 +461,8 @@ Linux client ubuntu_amd64_17_10 build: # Archlinux Client Linux client archlinux build: stage: build + except: + - mac-ci-build tags: - Docker image: base/archlinux @@ -544,6 +557,8 @@ Linux client archlinux build: Windows client build: stage: build + except: + - mac-ci-build tags: - Docker image: amd64/debian:9 @@ -608,6 +623,7 @@ Linux client test: stage: test except: - ryzomcore + - mac-ci-build tags: - Docker image: ubuntu:14.04 @@ -619,8 +635,9 @@ Linux client test: .OSX client test: stage: test - except: - - ryzomcore + only: + - tags + - mac-ci-build tags: - OSX script: From e669336aeed4c31010a3a886ec6879b63d59c354 Mon Sep 17 00:00:00 2001 From: Sit Melai Date: Wed, 11 Apr 2018 19:28:06 +0200 Subject: [PATCH 5/5] =?UTF-8?q?Changement=20du=20job=20Mac=20OSX:=20Ne=20p?= =?UTF-8?q?as=20recloner=20le=20d=C3=A9pot=20entier=20=C3=A0=20chaque=20ex?= =?UTF-8?q?ecution.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 10ba3b076..9cabbb6f0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -603,6 +603,9 @@ OSX client build: - mac-ci-build tags: - OSX + variables: + # Éviter de cloner tout le dépot à chaque fois, à la place juste récuperer les changements + GIT_STRATEGY: fetch script: # Création de l'environnement de compilation - mkdir -p BUILD/x86_64