diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 639a2329d..92473678e 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 @@ -585,8 +600,12 @@ OSX client build: stage: build only: - tags + - 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 @@ -607,6 +626,7 @@ Linux client test: stage: test except: - ryzomcore + - mac-ci-build tags: - Docker image: ubuntu:14.04 @@ -618,8 +638,9 @@ Linux client test: .OSX client test: stage: test - except: - - ryzomcore + only: + - tags + - mac-ci-build tags: - OSX script: 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() 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()