1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-22 10:22:52 +01:00

cmake+ci: rewrite ctest + add appveyor

This commit is contained in:
Anonymous Maarten 2018-02-10 02:07:35 +01:00 committed by Daniel Evans
parent 4ebc66b544
commit af7b84637d
15 changed files with 543 additions and 141 deletions

40
.appveyor.yml Normal file
View File

@ -0,0 +1,40 @@
image:
- Visual Studio 2017
clone_depth: 1
shallow_clone: false
# All paths in the environment section should be
# cmake-style paths: using forward-slashes (/).
environment:
PYTHON: "C:\\Python36-x64"
CMAKE_GENERATOR: "Visual Studio 15 2017"
BOOST_ROOT: "C:\\Libraries"
BOOST_VERSION: "1.65.1"
DEP_DIR: "C:\\dependencies"
WIN_DEP_NAME: "openrw-windows-dependencies"
WIN_DEP_URL: "https://github.com/rwengine/openrw-windows-dependencies"
NAME_SUFFIX: "windows"
platform:
- Win32
# - x64
configuration:
# - Debug
- Release
matrix:
fast_finish: false
cache:
- C:\dependencies -> .appveyor.yml, cmake/ctest/script_ci.ctest, cmake/ctest/utils.ctest, , cmake/ctest/configure_windows.ctest
init:
- set PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%
- python --version
- cmake --version
- msbuild /version
build_script:
- ctest -VV -S cmake/ctest/script_ci.ctest

View File

@ -6,22 +6,22 @@ git:
matrix: matrix:
include: include:
- os: linux - os: linux
env: NAME="Ubuntu Linux (Latest)" env: NAME="Ubuntu Linux (Latest)" NAME_SUFFIX="ubuntu"
services: docker services: docker
script: script:
- scripts/docker/docker_travis.sh "ubuntu_latest.docker" - scripts/docker/docker_travis.sh "ubuntu_latest.docker"
- os: linux - os: linux
env: NAME="Fedora Linux (Latest)" env: NAME="Fedora Linux (Latest)" NAME_SUFFIX="fedora"
services: docker services: docker
script: script:
- scripts/docker/docker_travis.sh "fedora_latest.docker" - scripts/docker/docker_travis.sh "fedora_latest.docker"
- os: linux - os: linux
env: NAME="Arch Linux (Latest)" env: NAME="Arch Linux (Latest)" NAME_SUFFIX="arch"
services: docker services: docker
script: script:
- scripts/docker/docker_travis.sh "arch_latest.docker" - scripts/docker/docker_travis.sh "arch_latest.docker"
- os: osx - os: osx
env: NAME="Apple macOS" env: NAME="Apple macOS" NAME_SUFFIX="mac"
osx_image: xcode9.2 osx_image: xcode9.2
install: install:
- brew update - brew update
@ -30,7 +30,7 @@ matrix:
- export PATH="/usr/local/opt/qt/bin:$PATH" - export PATH="/usr/local/opt/qt/bin:$PATH"
script: script:
- mkdir -p "$TRAVIS_BUILD_DIR/build" - mkdir -p "$TRAVIS_BUILD_DIR/build"
- ctest -S "$TRAVIS_BUILD_DIR/cmake/ctest/travis_script.ctest" -VV -DSRC_DIR="$TRAVIS_BUILD_DIR" -DBIN_DIR="$TRAVIS_BUILD_DIR/build" - ctest -VV -S "$TRAVIS_BUILD_DIR/cmake/ctest/script_ci.ctest"
notifications: notifications:
email: false email: false

160
cmake/ctest/build.ctest Normal file
View File

@ -0,0 +1,160 @@
# This file does:
# - check whether all arguments are defined,
# - clean the build directory,
# - configure, build and test,
# - coverage and memcheck,
# - submit
set(_ARGS_BOOL
EMPTY_BINARY_DIR
DEBUG
CHECK_INCLUDES
BUILD_VIEWER
RUN_TESTS
TESTS_NODATA
SEPARATE_TEST_SUITES
RUN_MEMCHECK
APPEND_RESULTS
RUN_COVERAGE
SUBMIT
)
set(_ARGS_ONEVAL
CTEST_SOURCE_DIRECTORY
CTEST_BINARY_DIRECTORY
MODEL_NAME
BUILDER_NAME
BUILD_NAME
CMAKE_GENERATOR
COVERAGE_COMMAND
)
set(_ARGS_MULVAL
CONFIGURE_EXTRA_OPTIONS
)
foreach(_ARG ${_ARGS_BOOL} ${_ARGS_ONEVAL} ${_ARGS_MULVAL})
set(_VAL "${${_ARG}}")
message(STATUS "build parameter: ${_ARG}='${_VAL}'")
if(_VAL STREQUAL "")
message(FATAL_ERROR "Need value for build parameter '${_ARG}'")
endif()
endforeach()
# CTEST_CMAKE_GENERATOR and CTEST_COVERAGE_COMMAND needed by CTest
set(CTEST_CMAKE_GENERATOR "${CMAKE_GENERATOR}")
set(CTEST_COVERAGE_COMMAND "${COVERAGE_COMMAND}")
set(CTEST_SITE "${BUILDER_NAME}")
set(CTEST_BUILD_NAME "${BUILD_NAME}")
set(NUMBER_ERRORS "0")
set(NUMBER_WARNINGS "0")
if(EMPTY_BINARY_DIR)
message(STATUS "Removing binary directory '${CTEST_BINARY_DIRECTORY}'...")
if(EXISTS "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt")
message(STATUS "CMakeCache.txt file exists ==> removing")
ctest_empty_binary_directory("${CTEST_BINARY_DIRECTORY}")
endif()
endif()
set(_CTEST_START_EXTRA_ARGS)
set(_CTEST_CONFIGURE_EXTRA_ARGS)
if(APPEND_RESULTS)
list(APPEND _CTEST_START_EXTRA_ARGS "APPEND")
list(APPEND _CTEST_CONFIGURE_EXTRA_ARGS "APPEND")
endif()
message(STATUS "Starting test...")
ctest_start("${MODEL_NAME}" ${_CTEST_START_EXTRA_ARGS})
# CTEST_CONFIGURATION_TYPE is needed on Windows (no leading underscore)
if(DEBUG)
set(_CMAKE_BUILD_TYPE "Debug")
set(_CTEST_BUILD_CONFIGURATION "Debug")
set(CTEST_CONFIGURATION_TYPE "Debug")
else()
set(_CMAKE_BUILD_TYPE "Release")
set(_CTEST_BUILD_CONFIGURATION "Release")
set(CTEST_CONFIGURATION_TYPE "Release")
endif()
set(_CONFIGURE_OPTIONS
"-DBUILD_VIEWER=${BUILD_VIEWER}"
"-DBUILD_TESTS=TRUE"
"-DTESTS_NODATA=${TESTS_NODATA}"
"-DTEST_COVERAGE=${RUN_COVERAGE}"
"-DSEPARATE_TEST_SUITES=${SEPARATE_TEST_SUITES}"
"-DCHECK_INCLUDES=${CHECK_INCLUDES}"
"-DCMAKE_BUILD_TYPE=${_CMAKE_BUILD_TYPE}"
)
message(STATUS "Configuring...")
message(STATUS "options='${_CONFIGURE_OPTIONS}'")
message(STATUS "extra options='${CONFIGURE_EXTRA_OPTIONS}'")
ctest_configure(
OPTIONS
"${_CONFIGURE_OPTIONS};${CONFIGURE_EXTRA_OPTIONS}"
RETURN_VALUE
_CONFIGURE_RESULT
${_CTEST_CONFIGURE_EXTRA_ARGS}
)
message(STATUS "Building...")
ctest_build(
CONFIGURATION "${_CTEST_BUILD_CONFIGURATION}"
NUMBER_ERRORS _NB_BUILD_ERRORS
NUMBER_WARNINGS _NB_BUILD_WARNINGS
)
if(RUN_TESTS)
message(STATUS "Running tests...")
ctest_test(
RETURN_VALUE _TEST_RESULT
)
else()
message(STATUS "Skipping tests...")
endif()
if(RUN_COVERAGE)
message(STATUS "Collecting coverage...")
ctest_coverage(
RETURN_VALUE _COVERAGE_RESULT
)
else()
message(STATUS "Coverage skipped.")
endif()
if(RUN_MEMCHECK)
message(STATUS "Running memcheck...")
message(AUTHOR_WARNING "Memcheck not implemented (yet).")
else()
message(STATUS "Memcheck skipped.")
endif()
if(SUBMIT)
message(STATUS "Submitting...")
ctest_submit(
RETURN_VALUE _SUBMIT_RESULT
)
else()
message(STATUS "Submit skipped.")
endif()
if(_CONFIGURE_RESULT)
list(APPEND ERROR_MESSAGES "Configure error detected!")
endif()
if(_NB_BUILD_ERRORS)
list(APPEND ERROR_MESSAGES "Build failure detected!")
endif()
if(_TEST_RESULT)
list(APPEND ERROR_MESSAGES "Test failure detected!")
endif()

View File

@ -0,0 +1,12 @@
set(CMAKE_GENERATOR "Xcode")
set(DEBUG FALSE)
set(CONFIGURE_EXTRA_OPTIONS ";")
set(BUILD_VIEWER TRUE)
set(COVERAGE_COMMAND gcov)
set(CHECK_INCLUDES FALSE)
if(MODEL_NAME STREQUAL "EXPERIMENTAL")
set(CHECK_INCLUDES FALSE)
else()
set(CHECK_INCLUDES FALSE)
endif()

View File

@ -0,0 +1,12 @@
set(CMAKE_GENERATOR "Unix Makefiles")
set(DEBUG FALSE)
set(CONFIGURE_EXTRA_OPTIONS ";")
set(BUILD_VIEWER TRUE)
set(COVERAGE_COMMAND gcov)
set(CHECK_INCLUDES FALSE)
if(MODEL_NAME STREQUAL "EXPERIMENTAL")
set(CHECK_INCLUDES FALSE)
else()
set(CHECK_INCLUDES FALSE)
endif()

View File

@ -0,0 +1,104 @@
set(_WIN_NEEDED_VARS
BOOST_ROOT
BOOST_VERSION
CMAKE_GENERATOR
CONFIGURATION
DEP_DIR
PLATFORM
WIN_DEP_NAME
WIN_DEP_URL
)
foreach(_WIN_NEEDED_VAR ${_WIN_NEEDED_VARS})
set("${_WIN_NEEDED_VAR}" "$ENV{${_WIN_NEEDED_VAR}}")
message(STATUS "configure_windows: script argument: ${_WIN_NEEDED_VAR} = '${${_WIN_NEEDED_VAR}}'")
if("${${_WIN_NEEDED_VAR}}" STREQUAL "")
message(FATAL_ERROR "${_WIN_NEEDED_VAR} is empty")
endif()
endforeach()
string(REPLACE "." "_" _BOOST_VERSION_UNDERSCORED "${BOOST_VERSION}")
set(BOOST_ROOT "${BOOST_ROOT}\\boost_${_BOOST_VERSION_UNDERSCORED}")
string(TOLOWER "${PLATFORM}" PLATFORM)
if(PLATFORM STREQUAL "win32")
set(CMAKE_GENERATOR "${CMAKE_GENERATOR}")
set(TRIPLET "x86-windows-static")
elseif(PLATFORM STREQUAL "x64")
set(CMAKE_GENERATOR "${CMAKE_GENERATOR} Win64")
set(TRIPLET "x64-windows-static")
else()
message(FATAL_ERROR "Unknown platform (${PLATFORM})")
endif()
string(TOLOWER "${CONFIGURATION}" CONFIGURATION)
if(CONFIGURATION STREQUAL "debug")
set(DEBUG TRUE)
set(_LIBRARY_DIR_INFIX "debug")
elseif(CONFIGURATION STREQUAL "release")
set(DEBUG FALSE)
set(_LIBRARY_DIR_INFIX "")
else()
message(FATAL_ERROR "Unknown configuration '${CONFIGURATION}'")
endif()
file(MAKE_DIRECTORY "${DEP_DIR}")
set(_WIN_DEP_DIR "${DEP_DIR}\\${WIN_DEP_NAME}")
set(TRIPLET_DIR "${_WIN_DEP_DIR}\\${TRIPLET}")
message(STATUS "Checking windows dependency dir '${_WIN_DEP_DIR}'...")
if(NOT IS_DIRECTORY "${_WIN_DEP_DIR}")
message(STATUS "... does not exist.")
message(STATUS "Executing git clone...")
execute_process(
COMMAND git clone --depth 1 -- "${WIN_DEP_URL}"
WORKING_DIRECTORY "${DEP_DIR}"
RESULT_VARIABLE GIT_RESULT
)
if(GIT_RESULT)
message(FATAL_ERROR "Failed to clone '${WIN_DEP_URL}'")
endif()
else()
message(STATUS "... exists.")
message(STATUS "Skipping git clone")
endif()
set(_INCLUDE_PATH
"${TRIPLET_DIR}\\include"
)
set(ENV{OPENALDIR} "${TRIPLET_DIR}\\include\\AL")
set(ENV{SDL2DIR} "${TRIPLET_DIR}\\include\\SDL2")
set(_LIBRARY_PATH
"${TRIPLET_DIR}\\${_LIBRARY_DIR_INFIX}\\lib"
)
set(_C_FLAGS "/DWIN32 /D_WINDOWS /W3 /utf-8 /MP")
set(_CXX_FLAGS "/DWIN32 /D_WINDOWS /W3 /utf-8 /GR /EHsc /MP")
set(_C_FLAGS_DEBUG "/D_DEBUG /MTd /Z7 /Ob0 /Od /RTC1")
set(_C_FLAGS_RELEASE "/MT /O2 /Ob2 /DNDEBUG")
set(_C_FLAGS_MINSIZEREL "/MT /O1 /Ob1 /DNDEBUG")
set(_C_FLAGS_RELWITHDEBINFO "/MT /Zi /O2 /Ob1 /DNDEBUG")
set(CMAKE_GENERATOR "${CMAKE_GENERATOR}")
set(DEBUG "${DEBUG}")
set(CONFIGURE_EXTRA_OPTIONS
"-DCMAKE_INCLUDE_PATH=${_INCLUDE_PATH}"
"-DCMAKE_LIBRARY_PATH=${_LIBRARY_PATH}"
"-DCMAKE_C_FLAGS=${_C_FLAGS}"
"-DCMAKE_C_FLAGS_DEBUG=${_C_FLAGS_DEBUG}"
"-DCMAKE_C_FLAGS_MINSIZEREL=${_C_FLAGS_MINSIZEREL}"
"-DCMAKE_C_FLAGS_RELEASE=${_C_FLAGS_RELEASE}"
"-DCMAKE_C_FLAGS_RELWITHDEBINFO=${_C_FLAGS_RELWITHDEBINFO}"
"-DCMAKE_CXX_FLAGS=${_CXX_FLAGS}"
"-DCMAKE_CXX_FLAGS_DEBUG=${_C_FLAGS_DEBUG}"
"-DCMAKE_CXX_FLAGS_MINSIZEREL=${_C_FLAGS_MINSIZEREL}"
"-DCMAKE_CXX_FLAGS_RELEASE=${_C_FLAGS_RELEASE}"
"-DCMAKE_CXX_FLAGS_RELWITHDEBINFO=${_C_FLAGS_RELWITHDEBINFO}"
"-DBOOST_ROOT=${BOOST_ROOT}"
"-DBoost_USE_STATIC_LIBS=TRUE"
"-DBoost_USE_STATIC_RUNTIME=TRUE"
)
set(BUILD_VIEWER FALSE) #FIXME: ENABLE
set(COVERAGE_COMMAND "echo") #FIXME: ENABLE
set(CHECK_INCLUDES FALSE) #FIXME: ENABLE

View File

@ -1,42 +0,0 @@
cmake_minimum_required(VERSION 3.2.2)
get_filename_component(CTEST_SOURCE_DIRECTORY "${CTEST_SCRIPT_DIRECTORY}/../.." ABSOLUTE)
get_filename_component(CTEST_BINARY_DIRECTORY "${CTEST_SOURCE_DIRECTORY}/build/experimental" ABSOLUTE)
set(CTEST_CMAKE_GENERATOR "Unix Makefiles")
set(CTEST_COVERAGE_COMMAND "gcov")
if(EXISTS "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt")
ctest_empty_binary_directory("${CTEST_BINARY_DIRECTORY}")
endif()
include("${CTEST_SCRIPT_DIRECTORY}/../modules/GetGitRevisionDescription.cmake")
# get_git_head_revision expects CMAKE_CURRENT_BINARY_DIR to exist.
set(CMAKE_BINARY_DIR "${CTEST_BINARY_DIRECTORY}")
set(CMAKE_CURRENT_BINARY_DIR "${CTEST_BINARY_DIRECTORY}")
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
string(SUBSTRING "${GIT_SHA1}" 0 8 SHORT_COMMIT)
set(CTEST_SITE "${CMAKE_SYSTEM_NAME}")
set(CTEST_BUILD_NAME "experimental_script-${SHORT_COMMIT}")
ctest_start("Experimental")
ctest_configure(
OPTIONS
"-DBUILD_VIEWER=1;-DBUILD_TESTS=1;-DTEST_COVERAGE=1;-DRW_VERBOSE_DEBUG_MESSAGES=1;-DSEPARATE_TEST_SUITES=1;-DCHECK_INCLUDES=1"
)
ctest_build()
ctest_test()
ctest_coverage()
ctest_submit(
RETURN_VALUE SUBMIT_RESULT
)
message("Site: ${CTEST_SITE}")
message("Build Name: ${CTEST_BUILD_NAME}")
if(NOT SUBMIT_RESULT EQUAL "0")
message("Uploading results failed.")
message("Execute the next command to submit later.")
message("make -C \"${CTEST_BINARY_DIRECTORY}\" ExperimentalSubmit")
endif()

View File

@ -0,0 +1,64 @@
cmake_minimum_required(VERSION 3.2.2)
set(MODEL_NAME "continuous")
include("${CTEST_SCRIPT_DIRECTORY}/utils.ctest")
openrw_src_dir(CTEST_SOURCE_DIRECTORY)
if($ENV{DOCKER})
set(CTEST_BINARY_DIRECTORY "/build")
else()
openrw_bin_dir_default(CTEST_BINARY_DIRECTORY)
endif()
set(CTEST_COMMAND "${CMAKE_CTEST_COMMAND}")
openrw_build_name(BUILDER_NAME_BASE BUILD_NAME)
set(BUILDER_NAME_BASE "${BUILDER_NAME_BASE}-$ENV{NAME_SUFFIX}")
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
message(STATUS "Linux detected")
include("${CTEST_SCRIPT_DIRECTORY}/configure_linux.ctest")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
message(STATUS "Windows detected")
include("${CTEST_SCRIPT_DIRECTORY}/configure_windows.ctest")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
message(STATUS "MacOS X detected")
include("${CTEST_SCRIPT_DIRECTORY}/configure_darwin.ctest")
else()
message(FATAL_ERROR "Unknown CMAKE_SYSTEM_NAME detected '${CMAKE_SYSTEM_NAME}'")
endif()
set(ERROR_MESSAGES)
set(SEPARATE_TEST_SUITES FALSE)
set(RUN_COVERAGE FALSE)
set(RUN_MEMCHECK FALSE)
set(SUBMIT TRUE)
# Build with no data and test
set(BUILDER_NAME "${BUILDER_NAME_BASE}-nodata")
set(APPEND_RESULTS FALSE)
set(EMPTY_BINARY_DIR TRUE)
set(TESTS_NODATA TRUE)
set(RUN_TESTS TRUE)
include("${CTEST_SCRIPT_DIRECTORY}/build.ctest")
# Build with data and do not test
set(BUILDER_NAME "${BUILDER_NAME_BASE}-data")
set(APPEND_RESULTS FALSE)
set(EMPTY_BINARY_DIR FALSE)
set(TESTS_NODATA FALSE)
set(RUN_TESTS FALSE)
include("${CTEST_SCRIPT_DIRECTORY}/build.ctest")
if(ERROR_MESSAGES)
foreach(ERROR_MESSAGE ${ERROR_MESSAGES})
message(SEND_ERROR "${ERROR_MESSAGE}")
endforeach()
message(FATAL_ERROR "Error(s) detected")
endif()

View File

@ -0,0 +1,62 @@
cmake_minimum_required(VERSION 3.2.2)
set(MODEL_NAME "experimental")
include("${CTEST_SCRIPT_DIRECTORY}/utils.ctest")
openrw_src_dir(CTEST_SOURCE_DIRECTORY)
if($ENV{DOCKER})
set(CTEST_BINARY_DIRECTORY "/build")
else()
openrw_bin_dir(CTEST_BINARY_DIRECTORY "experimental")
endif()
set(CTEST_COMMAND "${CMAKE_CTEST_COMMAND}")
openrw_build_name(BUILDER_NAME BUILD_NAME)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
message(STATUS "Linux detected")
include("${CTEST_SCRIPT_DIRECTORY}/configure_linux.ctest")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
message(STATUS "Windows detected")
include("${CTEST_SCRIPT_DIRECTORY}/configure_windows.ctest")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
message(STATUS "MacOS X detected")
include("${CTEST_SCRIPT_DIRECTORY}/configure_darwin.ctest")
else()
message(FATAL_ERROR "Unknown CMAKE_SYSTEM_NAME detected '${CMAKE_SYSTEM_NAME}'")
endif()
set(ERROR_MESSAGES)
set(SEPARATE_TEST_SUITES TRUE)
if($ENV{RUN_COVERAGE})
set(RUN_COVERAGE TRUE)
else()
set(RUN_COVERAGE FALSE)
endif()
set(RUN_MEMCHECK FALSE) #TODO
set(APPEND_RESULTS FALSE)
if($ENV{SUBMIT})
set(SUBMIT TRUE)
else()
set(SUBMIT FALSE)
endif()
set(EMPTY_BINARY_DIR TRUE)
set(TESTS_NODATA FALSE)
set(RUN_TESTS TRUE)
include("${CTEST_SCRIPT_DIRECTORY}/build.ctest")
if(ERROR_MESSAGES)
foreach(ERROR_MESSAGE ${ERROR_MESSAGES})
message(SEND_ERROR "${ERROR_MESSAGE}")
endforeach()
message(FATAL_ERROR "Error(s) detected")
endif()

View File

@ -1,88 +0,0 @@
cmake_minimum_required(VERSION 3.2.2)
set(TRAVIS "$ENV{TRAVIS}")
if(TRAVIS)
message("travis_script: Travis detected")
set(CTEST_SITE_BASE "Travis")
string(SUBSTRING "$ENV{TRAVIS_COMMIT}" 0 8 SHORT_COMMIT)
set(CTEST_BUILD_NAME "$ENV{TRAVIS_EVENT_TYPE}-$ENV{TRAVIS_REPO_SLUG}-$ENV{TRAVIS_BRANCH}-${SHORT_COMMIT}")
else()
message("travis_script: Travis NOT detected")
endif()
get_filename_component(SRC_DIR "${SRC_DIR}" ABSOLUTE)
get_filename_component(BIN_DIR "${BIN_DIR}" ABSOLUTE)
set(CTEST_SOURCE_DIRECTORY "${SRC_DIR}")
set(CTEST_BINARY_DIRECTORY "${BIN_DIR}")
set(CTEST_CMAKE_GENERATOR "Unix Makefiles")
message(STATUS "Removing binary directory '${CTEST_BINARY_DIRECTORY}'...")
if(EXISTS "${BIN_DIR}/CMakeCache.txt")
message(STATUS "CMakeCache.txt file exists ==> removing")
ctest_empty_binary_directory("${BIN_DIR}")
endif()
set(CTEST_SITE "${CTEST_SITE_BASE}-NODATA")
ctest_start("Continuous")
ctest_configure(
OPTIONS
"-DBUILD_VIEWER=1;-DBUILD_TESTS=1;-DTESTS_NODATA=1"
RETURN_VALUE
CONFIGURE_RESULT_NODATA
)
ctest_build(
NUMBER_ERRORS BUILD_NB_ERRORS_NODATA
NUMBER_WARNINGS BUILD_NB_WARNINGS_NODATA
)
ctest_test(
RETURN_VALUE TEST_RESULT
)
if(TRAVIS)
ctest_submit(
RETURN_VALUE SUBMIT_RESULT
)
if(NOT SUBMIT_RESULT EQUAL "0")
message(WARNING "Submit failure detected!")
endif()
endif()
set(CTEST_SITE "${CTEST_SITE_BASE}-DATA")
ctest_start("Continuous")
ctest_configure(
OPTIONS
"-DBUILD_VIEWER=1;-DBUILD_TESTS=1;-DTESTS_NODATA=0"
RETURN_VALUE
CONFIGURE_RESULT_DATA
)
ctest_build(
NUMBER_ERRORS BUILD_NB_ERRORS_DATA
NUMBER_WARNINGS BUILD_NB_WARNINGS_DATA
)
if(TRAVIS)
ctest_submit(
RETURN_VALUE SUBMIT_RESULT
)
if(SUBMIT_RESULT)
message(FATAL_ERROR "Submit failure detected!")
endif()
endif()
if(CONFIGURE_RESULT_DATA OR CONFIGURE_RESULT_NODATA)
message(FATAL_ERROR "Configure error detected!")
endif()
if(BUILD_NB_ERRORS_DATA OR BUILD_NB_ERRORS_NODATA)
message(FATAL_ERROR "Build failure detected!")
endif()
if(TEST_RESULT)
message(FATAL_ERROR "Test failure detected!")
endif()

77
cmake/ctest/utils.ctest Normal file
View File

@ -0,0 +1,77 @@
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}")
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()
else()
message(FATAL_ERROR "Unknown CI")
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()

View File

@ -5,7 +5,7 @@ add_library(openrw::interface ALIAS rw_interface)
set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
target_compile_options(rw_interface target_compile_options(rw_interface
INTERFACE INTERFACE
"-Wall" "-Wall"
@ -24,7 +24,7 @@ else()
message(FATAL_ERROR "Unknown compiler ID: '${CMAKE_CXX_COMPILER_ID}'") message(FATAL_ERROR "Unknown compiler ID: '${CMAKE_CXX_COMPILER_ID}'")
endif() endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL Clang) if(CMAKE_CXX_COMPILER_ID STREQUAL Clang OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
target_compile_options(rw_interface target_compile_options(rw_interface
INTERFACE INTERFACE
"-Wno-gnu-array-member-paren-init" "-Wno-gnu-array-member-paren-init"

View File

@ -8,7 +8,7 @@ docker=$1
"$curdir/docker_tool.py" build -d "$docker" -t openrw_build_image "$curdir/docker_tool.py" build -d "$docker" -t openrw_build_image
# Start docker container + add travis user # Start docker container + add travis user
"$curdir/docker_tool.py" create -t openrw_build_image -n openrw_builder -U travis -e XDG_RUNTIME_DIR=/tmp CI=$CI TRAVIS=$TRAVIS TRAVIS_COMMIT=$TRAVIS_COMMIT TRAVIS_EVENT_TYPE=$TRAVIS_EVENT_TYPE TRAVIS_REPO_SLUG=$TRAVIS_REPO_SLUG TRAVIS_BRANCH=$TRAVIS_BRANCH "$curdir/docker_tool.py" create -t openrw_build_image -n openrw_builder -U travis
# Build only # Build only
"$curdir/docker_tool.py" exec -n openrw_builder -U travis -- /bin/bash -c "cd /build && cmake -VV /src && make" "$curdir/docker_tool.py" exec -n openrw_builder -U travis -- /bin/bash -c "cd /build && cmake -VV /src && make"

View File

@ -30,6 +30,7 @@ def create(ns: argparse.Namespace):
if not build_dir.exists(): if not build_dir.exists():
build_dir.mkdir() build_dir.mkdir()
env_args = [a for e in ns.env for a in ('-e', e)] env_args = [a for e in ns.env for a in ('-e', e)]
env_args += ['-e', 'DOCKER=TRUE', ]
run_args = ['docker', 'run', run_args = ['docker', 'run',
'-v', '{}:/src:ro,z'.format(str(openrw_dir)), '-v', '{}:/src:ro,z'.format(str(openrw_dir)),
'-v', '{}:/build:rw,z'.format(str(build_dir)) ] + \ '-v', '{}:/build:rw,z'.format(str(build_dir)) ] + \
@ -42,7 +43,7 @@ def create(ns: argparse.Namespace):
sub_run(['docker', 'exec', ns.name, 'useradd', '--create-home', sub_run(['docker', 'exec', ns.name, 'useradd', '--create-home',
'--uid', str(ns.uid), '-g', ns.username, ns.username]) '--uid', str(ns.uid), '-g', ns.username, ns.username])
sub_run(['docker', 'exec', ns.name, 'chown', '{0}:{0}'.format(ns.username), sub_run(['docker', 'exec', ns.name, 'chown', '{0}:{0}'.format(ns.username),
'/build', '/src']) '/build'])
def exec(ns: argparse.Namespace): def exec(ns: argparse.Namespace):

View File

@ -8,7 +8,7 @@ docker=$1
"$curdir/docker_tool.py" build -d "$docker" -t openrw_build_image "$curdir/docker_tool.py" build -d "$docker" -t openrw_build_image
# Start docker container + add travis user # Start docker container + add travis user
"$curdir/docker_tool.py" create -t openrw_build_image -n openrw_builder -U travis -e XDG_RUNTIME_DIR=/tmp CI=$CI TRAVIS=$TRAVIS TRAVIS_COMMIT=$TRAVIS_COMMIT TRAVIS_EVENT_TYPE=$TRAVIS_EVENT_TYPE TRAVIS_REPO_SLUG=$TRAVIS_REPO_SLUG TRAVIS_BRANCH=$TRAVIS_BRANCH "$curdir/docker_tool.py" create -t openrw_build_image -n openrw_builder -U travis -e NAME_SUFFIX=$NAME_SUFFIX XDG_RUNTIME_DIR=/tmp TRAVIS=$TRAVIS TRAVIS_COMMIT=$TRAVIS_COMMIT TRAVIS_EVENT_TYPE=$TRAVIS_EVENT_TYPE TRAVIS_REPO_SLUG=$TRAVIS_REPO_SLUG TRAVIS_BRANCH=$TRAVIS_BRANCH
# execute test # execute test
"$curdir/docker_tool.py" exec -n openrw_builder -U travis -- /bin/bash -c "ctest -S /src/cmake/ctest/travis_script.ctest -VV -DSRC_DIR=/src -DBIN_DIR=/build" "$curdir/docker_tool.py" exec -n openrw_builder -U travis -- /bin/bash -c "ctest -VV -S /src/cmake/ctest/script_ci.ctest -VV"