mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-02 00:42:33 +01:00
97 lines
3.7 KiB
Plaintext
97 lines
3.7 KiB
Plaintext
function(openrw_src_dir RESULT)
|
|
# Returns the OpenRW source directory
|
|
get_filename_component(SRC "${CTEST_SCRIPT_DIRECTORY}/../.." ABSOLUTE)
|
|
set("${RESULT}" "${SRC}" PARENT_SCOPE)
|
|
endfunction()
|
|
|
|
function(openrw_bin_dir_default RESULT)
|
|
# Returns the default OpenRW binary output directory
|
|
get_filename_component(BIN "${CTEST_SCRIPT_DIRECTORY}/../../build" ABSOLUTE)
|
|
set("${RESULT}" "${BIN}" PARENT_SCOPE)
|
|
endfunction()
|
|
|
|
function(openrw_bin_dir RESULT SUBDIR)
|
|
# Returns a subdirectory in the default OpenRW binary output directory
|
|
get_filename_component(BIN "${CTEST_SCRIPT_DIRECTORY}/../../build" ABSOLUTE)
|
|
set("${RESULT}" "${BIN}/${SUBDIR}" PARENT_SCOPE)
|
|
endfunction()
|
|
|
|
function(openrw_git_sha1 RESULT BINDIR)
|
|
# Get the full SHA1 of the current checked out OpenRW
|
|
include("${CTEST_SCRIPT_DIRECTORY}/../modules/GetGitRevisionDescription.cmake")
|
|
# get_git_head_revision expects CMAKE_CURRENT_BINARY_DIR to exist.
|
|
set(CMAKE_BINARY_DIR "${BINDIR}")
|
|
set(CMAKE_CURRENT_BINARY_DIR "${BINDIR}")
|
|
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
|
|
set("${RESULT}" "${GIT_SHA1}" PARENT_SCOPE)
|
|
endfunction()
|
|
|
|
function(openrw_git_sha1_short RESULT BINDIR)
|
|
# Get a short SHA1 of the current checked out OpenRW
|
|
openrw_git_sha1(GIT_SHA1 "${BINDIR}")
|
|
string(SUBSTRING "${GIT_SHA1}" 0 8 SHORT_HASH)
|
|
set("${RESULT}" "${SHORT_HASH}" PARENT_SCOPE)
|
|
endfunction()
|
|
|
|
function(openrw_build_name BUILDER_NAME_RES BUILD_NAME_RES)
|
|
# Construct a name for the current builder and build.
|
|
if(CTEST_BINARY_DIRECTORY STREQUAL "")
|
|
message(FATAL_ERROR "calculate_names needs CTEST_BINARY_DIRECTORY set.")
|
|
endif()
|
|
if(MODEL_NAME STREQUAL "")
|
|
message(FATAL_ERROR "calculate_names needs MODEL_NAME set.")
|
|
endif()
|
|
|
|
if(MODEL_NAME STREQUAL "continuous")
|
|
if("$ENV{TRAVIS}")
|
|
message(STATUS "Travis detected")
|
|
set(BUILDER_NAME "Travis")
|
|
set(REPO_NAME "$ENV{TRAVIS_REPO_SLUG}")
|
|
set(REPO_BRANCH "$ENV{TRAVIS_BRANCH}")
|
|
set(GIT_HASH "$ENV{TRAVIS_COMMIT}")
|
|
set(_EVENT_TYPE "$ENV{TRAVIS_EVENT_TYPE}")
|
|
set(SUBMIT TRUE)
|
|
elseif("$ENV{APPVEYOR}")
|
|
message(STATUS "AppVeyor detected")
|
|
set(BUILDER_NAME "AppVeyor")
|
|
set(REPO_NAME "$ENV{APPVEYOR_REPO_NAME}")
|
|
set(REPO_BRANCH "$ENV{APPVEYOR_REPO_BRANCH}")
|
|
set(GIT_HASH "$ENV{APPVEYOR_REPO_COMMIT}")
|
|
if(NOT "$ENV{APPVEYOR_PULL_REQUEST_NUMBER}" STREQUAL "")
|
|
set(_EVENT_TYPE "pull_request")
|
|
else()
|
|
set(_EVENT_TYPE "push")
|
|
endif()
|
|
set(SUBMIT TRUE)
|
|
else()
|
|
message("Unknown CI")
|
|
set(BUILDER_NAME "unknown")
|
|
set(REPO_NAME "repo_name")
|
|
set(REPO_BRANCH "branch")
|
|
set(GIT_HASH "git_hash")
|
|
set(_EVENT_TYPE "nop")
|
|
set(SUBMIT FALSE)
|
|
endif()
|
|
string(SUBSTRING "${GIT_HASH}" 0 8 GIT_HASH_SHORT)
|
|
set(BUILD_NAME "${REPO_NAME}/${REPO_BRANCH}/${_EVENT_TYPE}/${GIT_HASH_SHORT}")
|
|
elseif(MODEL_NAME STREQUAL "experimental")
|
|
cmake_host_system_information(RESULT BUILDER_NAME QUERY HOSTNAME)
|
|
set(BUILD_NAME "experimental-${GIT_HASH}")
|
|
else()
|
|
message(FATAL_ERROR "Unknown MODEL_NAME (was '${MODEL_NAME}')")
|
|
endif()
|
|
set("${BUILDER_NAME_RES}" "${BUILDER_NAME}" PARENT_SCOPE)
|
|
set("${BUILD_NAME_RES}" "${BUILD_NAME}" PARENT_SCOPE)
|
|
endfunction()
|
|
|
|
function(openrw_should_submit_ci SHOULD_SUBMIT)
|
|
if("$ENV{TRAVIS}")
|
|
set(RES TRUE)
|
|
elseif("$ENV{APPVEYOR}")
|
|
set(RES TRUE)
|
|
else()
|
|
set(RES FALSE)
|
|
endif()
|
|
set("${SHOULD_SUBMIT}" "${RES}" PARENT_SCOPE)
|
|
endfunction()
|