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

Merge pull request #594 from madebr/conan

Conan updates
This commit is contained in:
Daniel Evans 2018-08-20 22:45:42 +01:00 committed by GitHub
commit d9255cb5df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 266 additions and 196 deletions

View File

@ -48,5 +48,5 @@ build_script:
after_build: after_build:
- cd "%APPVEYOR_BUILD_FOLDER%\build" - cd "%APPVEYOR_BUILD_FOLDER%\build"
- cpack -C Release -G TXZ - cpack -C %CONFIGURATION% -G TXZ
- appveyor PushArtifact OpenRW-%COMMIT_HASH:~0,8%.tar.xz - appveyor PushArtifact OpenRW-%COMMIT_HASH:~0,8%.tar.xz

View File

@ -16,7 +16,7 @@ matrix:
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)" NAME_SUFFIX="arch" env: NAME="Arch Linux (Latest)" NAME_SUFFIX="arch" DEBUG=1
services: docker services: docker
script: script:
- scripts/docker/docker_travis.sh "arch_latest.docker" - scripts/docker/docker_travis.sh "arch_latest.docker"

View File

@ -51,10 +51,6 @@ else()
rwdep_wrap_find_packages() rwdep_wrap_find_packages()
endif() endif()
if(CHECK_INCLUDES)
find_package(IncludeWhatYouUse REQUIRED)
endif()
set(OpenGL_GL_PREFERENCE GLVND) set(OpenGL_GL_PREFERENCE GLVND)
find_package(OpenGL REQUIRED) find_package(OpenGL REQUIRED)

View File

@ -7,7 +7,7 @@
set(_ARGS_BOOL set(_ARGS_BOOL
USE_CONAN USE_CONAN
DEBUG DEBUG
CHECK_INCLUDES CHECK_IWYU
BUILD_TOOLS BUILD_TOOLS
BUILD_VIEWER BUILD_VIEWER
@ -32,7 +32,6 @@ set(_ARGS_ONEVAL
BUILD_NAME BUILD_NAME
CONAN_ARCH CONAN_ARCH
CONAN_PROFILE
CMAKE_GENERATOR CMAKE_GENERATOR
COVERAGE_COMMAND COVERAGE_COMMAND
@ -115,10 +114,17 @@ if(USE_CONAN)
set(CONAN_CONFIGURATION "Release") set(CONAN_CONFIGURATION "Release")
endif() endif()
if(BUILD_VIEWER)
set(_BUILD_VIEWER True)
else()
set(_BUILD_VIEWER False)
endif()
execute_process( execute_process(
COMMAND COMMAND
"${CONAN_BIN}" install "${CTEST_SOURCE_DIRECTORY}" -pr "${CONAN_PROFILE}" "${CONAN_BIN}" install "${CTEST_SOURCE_DIRECTORY}"
-s arch=${CONAN_ARCH} -s build_type=${CONAN_CONFIGURATION} --build missing -s arch=${CONAN_ARCH} -s build_type=${CONAN_CONFIGURATION}
-o viewer=${_BUILD_VIEWER} --build missing
WORKING_DIRECTORY "${CTEST_BINARY_DIRECTORY}" WORKING_DIRECTORY "${CTEST_BINARY_DIRECTORY}"
RESULT_VARIABLE RES RESULT_VARIABLE RES
) )
@ -129,6 +135,16 @@ if(USE_CONAN)
list(APPEND CONFIGURE_EXTRA_OPTIONS list(APPEND CONFIGURE_EXTRA_OPTIONS
"-DBOOST_STATIC=True" "-DBOOST_STATIC=True"
) )
execute_process(
COMMAND
"${CONAN_BIN}" remove -f -b -s "*"
WORKING_DIRECTORY "${CTEST_BINARY_DIRECTORY}"
RESULT_VARIABLE RES
)
if(RES)
message(FATAL_ERROR "conan remove failed")
endif()
endif() endif()
# CTEST_CONFIGURATION_TYPE is needed on Windows (no leading underscore) # CTEST_CONFIGURATION_TYPE is needed on Windows (no leading underscore)
@ -149,7 +165,7 @@ set(_CONFIGURE_OPTIONS
"-DTESTS_NODATA=${TESTS_NODATA}" "-DTESTS_NODATA=${TESTS_NODATA}"
"-DTEST_COVERAGE=${RUN_COVERAGE}" "-DTEST_COVERAGE=${RUN_COVERAGE}"
"-DSEPARATE_TEST_SUITES=${SEPARATE_TEST_SUITES}" "-DSEPARATE_TEST_SUITES=${SEPARATE_TEST_SUITES}"
"-DCHECK_INCLUDES=${CHECK_INCLUDES}" "-DCHECK_IWYU=${CHECK_IWYU}"
"-DCMAKE_BUILD_TYPE=${_CMAKE_BUILD_TYPE}" "-DCMAKE_BUILD_TYPE=${_CMAKE_BUILD_TYPE}"
"-DENABLE_SANITIZERS=${ENABLE_SANITIZERS}" "-DENABLE_SANITIZERS=${ENABLE_SANITIZERS}"
"-DUSE_CONAN=${USE_CONAN}" "-DUSE_CONAN=${USE_CONAN}"
@ -217,9 +233,9 @@ if(_NB_BUILD_ERRORS)
endif() endif()
if(_TEST_RESULT) if(_TEST_RESULT)
list(APPEND WARNING_MESSAGES "Test failure detected!") list(APPEND ERROR_MESSAGES "Test failure detected!")
endif() endif()
if(_SUBMIT_RESULT) if(_SUBMIT_RESULT)
list(APPEND ERROR_MESSAGES "Test submission failure detected!") list(APPEND WARNING_MESSAGES "Test submission failure detected!")
endif() endif()

View File

@ -1,17 +1,20 @@
set(CMAKE_GENERATOR "Xcode") set(CMAKE_GENERATOR "Xcode")
set(DEBUG FALSE) if(ENV{DEBUG})
set(DEBUG "$ENV{DEBUG}")
else()
set(DEBUG FALSE)
endif()
set(CONFIGURE_EXTRA_OPTIONS ";") set(CONFIGURE_EXTRA_OPTIONS ";")
set(BUILD_TOOLS TRUE) set(BUILD_TOOLS TRUE)
set(BUILD_VIEWER TRUE) set(BUILD_VIEWER TRUE)
set(COVERAGE_COMMAND gcov) set(COVERAGE_COMMAND gcov)
set(CHECK_INCLUDES FALSE) set(CHECK_IWYU FALSE)
set(ENABLE_SANITIZERS "") set(ENABLE_SANITIZERS "")
if(MODEL_NAME STREQUAL "EXPERIMENTAL") if(MODEL_NAME STREQUAL "EXPERIMENTAL")
set(CHECK_INCLUDES FALSE) set(CHECK_IWYU FALSE)
else() else()
set(CHECK_INCLUDES FALSE) set(CHECK_IWYU FALSE)
endif() endif()
set(CONAN_ARCH "x86_64") set(CONAN_ARCH "x86_64")
set(CONAN_PROFILE "${CTEST_SOURCE_DIRECTORY}/scripts/conan/darwin")

View File

@ -1,17 +1,20 @@
set(CMAKE_GENERATOR "Unix Makefiles") set(CMAKE_GENERATOR "Unix Makefiles")
set(DEBUG FALSE) if($ENV{DEBUG})
set(DEBUG "$ENV{DEBUG}")
else()
set(DEBUG FALSE)
endif()
set(CONFIGURE_EXTRA_OPTIONS ";") set(CONFIGURE_EXTRA_OPTIONS ";")
set(BUILD_TOOLS TRUE) set(BUILD_TOOLS TRUE)
set(BUILD_VIEWER TRUE) set(BUILD_VIEWER TRUE)
set(COVERAGE_COMMAND gcov) set(COVERAGE_COMMAND gcov)
set(CHECK_INCLUDES FALSE) set(CHECK_IWYU FALSE)
set(ENABLE_SANITIZERS "address") set(ENABLE_SANITIZERS "address")
if(MODEL_NAME STREQUAL "EXPERIMENTAL") if(MODEL_NAME STREQUAL "EXPERIMENTAL")
set(CHECK_INCLUDES FALSE) set(CHECK_IWYU FALSE)
else() else()
set(CHECK_INCLUDES FALSE) set(CHECK_IWYU FALSE)
endif() endif()
set(CONAN_ARCH "x86_64") set(CONAN_ARCH "x86_64")
set(CONAN_PROFILE "${CTEST_SOURCE_DIRECTORY}/scripts/conan/linux")

View File

@ -32,11 +32,10 @@ else()
message(FATAL_ERROR "Unknown configuration '${CONFIGURATION}'") message(FATAL_ERROR "Unknown configuration '${CONFIGURATION}'")
endif() endif()
set(CONAN_PROFILE "${CTEST_SOURCE_DIRECTORY}/scripts/conan/windows")
set(CONAN_ARCH "x86_64") set(CONAN_ARCH "x86_64")
set(BUILD_TOOLS TRUE) set(BUILD_TOOLS TRUE)
set(BUILD_VIEWER TRUE) set(BUILD_VIEWER TRUE)
set(COVERAGE_COMMAND "echo") #FIXME: ENABLE set(COVERAGE_COMMAND "echo") #FIXME: ENABLE
set(CHECK_INCLUDES FALSE) #FIXME: ENABLE set(CHECK_IWYU FALSE) #FIXME: ENABLE
set(ENABLE_SANITIZERS "") set(ENABLE_SANITIZERS "")

View File

@ -71,3 +71,16 @@ endif()
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(FFmpeg DEFAULT_MSG FFMPEG_LIBRARIES FFMPEG_INCLUDE_DIR) find_package_handle_standard_args(FFmpeg DEFAULT_MSG FFMPEG_LIBRARIES FFMPEG_INCLUDE_DIR)
if(FFMPEG_FOUND)
add_library(ffmpeg INTERFACE)
target_link_libraries(ffmpeg
INTERFACE
${FFMPEG_LIBRARIES}
)
target_include_directories(ffmpeg SYSTEM
INTERFACE
"${FFMPEG_INCLUDE_DIR}"
)
add_library(ffmpeg::ffmpeg ALIAS ffmpeg)
endif()

View File

@ -30,36 +30,36 @@
# License text for the above reference.) # License text for the above reference.)
# default search dirs # default search dirs
SET(_glm_HEADER_SEARCH_DIRS set(_glm_HEADER_SEARCH_DIRS
"/usr/include" "/usr/include"
"/usr/local/include") "/usr/local/include")
# check environment variable # check environment variable
SET(_glm_ENV_ROOT_DIR "$ENV{GLM_ROOT_DIR}") set(_glm_ENV_ROOT_DIR "$ENV{GLM_ROOT_DIR}")
IF(NOT GLM_ROOT_DIR AND _glm_ENV_ROOT_DIR) if(NOT GLM_ROOT_DIR AND _glm_ENV_ROOT_DIR)
SET(GLM_ROOT_DIR "${_glm_ENV_ROOT_DIR}") set(GLM_ROOT_DIR "${_glm_ENV_ROOT_DIR}")
ENDIF(NOT GLM_ROOT_DIR AND _glm_ENV_ROOT_DIR) endif(NOT GLM_ROOT_DIR AND _glm_ENV_ROOT_DIR)
# put user specified location at beginning of search # put user specified location at beginning of search
IF(GLM_ROOT_DIR) if(GLM_ROOT_DIR)
SET(_glm_HEADER_SEARCH_DIRS "${GLM_ROOT_DIR}" set(_glm_HEADER_SEARCH_DIRS "${GLM_ROOT_DIR}"
"${GLM_ROOT_DIR}/include" "${GLM_ROOT_DIR}/include"
${_glm_HEADER_SEARCH_DIRS}) ${_glm_HEADER_SEARCH_DIRS})
ENDIF(GLM_ROOT_DIR) endif()
# locate header # locate header
FIND_PATH(GLM_INCLUDE_DIR "glm/glm.hpp" find_path(GLM_INCLUDE_DIR "glm/glm.hpp"
PATHS ${_glm_HEADER_SEARCH_DIRS}) PATHS ${_glm_HEADER_SEARCH_DIRS})
INCLUDE(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLM DEFAULT_MSG find_package_handle_standard_args(GLM DEFAULT_MSG
GLM_INCLUDE_DIR) GLM_INCLUDE_DIR)
IF(GLM_FOUND) if(GLM_FOUND)
SET(GLM_INCLUDE_DIRS "${GLM_INCLUDE_DIR}") set(GLM_INCLUDE_DIRS "${GLM_INCLUDE_DIR}")
add_library(glm INTERFACE)
IF(NOT GLM_FIND_QUIETLY) target_include_directories(glm SYSTEM
MESSAGE(STATUS "GLM_INCLUDE_DIR = ${GLM_INCLUDE_DIR}") INTERFACE "${GLM_INCLUDE_DIR}")
ENDIF(NOT GLM_FIND_QUIETLY) add_library(glm::glm ALIAS glm)
ENDIF(GLM_FOUND) endif()

View File

@ -194,3 +194,16 @@ IF(SDL2_STATIC)
SET(SDL2_LIBRARY ${SDL2_LINK_FLAGS}) SET(SDL2_LIBRARY ${SDL2_LINK_FLAGS})
ENDIF() ENDIF()
ENDIF(SDL2_STATIC) ENDIF(SDL2_STATIC)
if(SDL2_FOUND AND NOT TARGET SDL2::SDL2)
add_library(SDL2 INTERFACE)
target_link_libraries(SDL2
INTERFACE
${SDL2_LIBRARY}
)
target_include_directories(SDL2 SYSTEM
INTERFACE
"${SDL2_INCLUDE_DIR}"
)
add_library(SDL2::SDL2 ALIAS SDL2)
endif()

View File

@ -1,75 +1,52 @@
function(rwdep_wrap_find_package TARGET INCLUDE_DIRS LINK_LIBS)
add_library("TMP_${TARGET}" INTERFACE)
target_include_directories("TMP_${TARGET}" SYSTEM
INTERFACE
${INCLUDE_DIRS}
)
target_link_libraries("TMP_${TARGET}"
INTERFACE
${LINK_LIBS}
)
add_library("rwdep::${TARGET}" ALIAS "TMP_${TARGET}")
endfunction()
function(rwdep_wrap_find_packages) function(rwdep_wrap_find_packages)
if(BULLET_FOUND) if(BULLET_FOUND AND NOT TARGET bullet::bullet)
rwdep_wrap_find_package(bullet "${BULLET_INCLUDE_DIR}" "${BULLET_LIBRARIES}") add_library(bullet INTERFACE)
target_link_libraries(bullet
INTERFACE
${BULLET_LIBRARIES}
)
target_include_directories(bullet SYSTEM
INTERFACE
"${BULLET_INCLUDE_DIR}"
)
add_library(bullet::bullet ALIAS bullet)
endif() endif()
if(FFMPEG_FOUND) if(OPENAL_FOUND AND NOT TARGET OpenAL::OpenAL)
rwdep_wrap_find_package(ffmpeg "${FFMPEG_INCLUDE_DIR}" "${FFMPEG_LIBRARIES}") add_library(OpenAL INTERFACE)
endif() target_link_libraries(OpenAL
INTERFACE
if(GLM_FOUND) "${OPENAL_LIBRARY}"
rwdep_wrap_find_package(glm "${GLM_INCLUDE_DIR}" "") )
endif() target_include_directories(OpenAL SYSTEM
INTERFACE
if(OPENAL_FOUND) "${OPENAL_INCLUDE_DIR}"
rwdep_wrap_find_package(OpenAL "${OPENAL_INCLUDE_DIR}" "${OPENAL_LIBRARY}") )
endif() add_library(OpenAL::OpenAL ALIAS OpenAL)
if(SDL2_FOUND)
rwdep_wrap_find_package(SDL2 "${SDL2_INCLUDE_DIR}" "${SDL2_LIBRARY}")
endif()
if(Boost_FOUND)
rwdep_wrap_find_package(boost "${Boost_INCLUDE_DIRS}" "")
endif()
if(Boost_SYSTEM_FOUND)
rwdep_wrap_find_package(boost_system "${Boost_INCLUDE_DIRS}" "${Boost_SYSTEM_LIBRARY}")
endif()
if(Boost_FILESYSTEM_FOUND)
rwdep_wrap_find_package(boost_filesystem "${Boost_INCLUDE_DIRS}" "${Boost_FILESYSTEM_LIBRARY};rwdep::boost_system")
endif()
if(Boost_PROGRAM_OPTIONS_FOUND)
rwdep_wrap_find_package(boost_program_options "${Boost_INCLUDE_DIRS}" "${Boost_PROGRAM_OPTIONS_LIBRARY};rwdep::boost_system")
endif()
if(Boost_UNIT_TEST_FRAMEWORK_FOUND)
rwdep_wrap_find_package(boost_unit_test_framework "${Boost_INCLUDE_DIRS}" "${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}")
endif()
if(FREETYPE_FOUND)
rwdep_wrap_find_package(freetype "${FREETYPE_INCLUDE_DIRS}" "${FREETYPE_LIBRARIES}")
endif() endif()
endfunction() endfunction()
function(rwdep_wrap_conan_target TARGET CONAN_NAME) function(rwdep_wrap_conan_target TARGET CONAN_NAME)
add_library("_rwdep_${TARGET}" INTERFACE) string(RANDOM RND)
target_link_libraries("_rwdep_${TARGET}" INTERFACE "CONAN_PKG::${CONAN_NAME}") set(TGT "CONAN_${CONAN_NAME}_${RND}")
add_library("rwdep::${TARGET}" ALIAS "_rwdep_${TARGET}") add_library("${TGT}" INTERFACE)
target_link_libraries("${TGT}" INTERFACE "CONAN_PKG::${CONAN_NAME}")
add_library("${TARGET}" ALIAS "${TGT}")
endfunction() endfunction()
function(rwdep_wrap_conan_targets) function(rwdep_wrap_conan_targets)
rwdep_wrap_conan_target(boost boost) rwdep_wrap_conan_target(OpenAL::OpenAL openal)
rwdep_wrap_conan_target(boost_program_options boost) rwdep_wrap_conan_target(bullet::bullet bullet)
rwdep_wrap_conan_target(boost_filesystem boost) rwdep_wrap_conan_target(glm::glm glm)
rwdep_wrap_conan_target(boost_unit_test_framework boost) rwdep_wrap_conan_target(ffmpeg::ffmpeg ffmpeg)
rwdep_wrap_conan_target(SDL2::SDL2 sdl2)
rwdep_wrap_conan_target(OpenAL openal)
rwdep_wrap_conan_target(bullet bullet)
rwdep_wrap_conan_target(glm glm)
rwdep_wrap_conan_target(ffmpeg ffmpeg)
rwdep_wrap_conan_target(SDL2 sdl2)
if(BUILD_TOOLS) if(BUILD_TOOLS)
rwdep_wrap_conan_target(freetype freetype) rwdep_wrap_conan_target(Freetype::Freetype freetype)
endif() endif()
rwdep_wrap_conan_target(Boost::boost boost)
rwdep_wrap_conan_target(Boost::filesystem boost)
rwdep_wrap_conan_target(Boost::program_options boost)
rwdep_wrap_conan_target(Boost::system boost)
rwdep_wrap_conan_target(Boost::unit_test_framework boost)
endfunction() endfunction()

View File

@ -64,6 +64,18 @@ else()
message(FATAL_ERROR "Unknown platform \"${CMAKE_SYSTEM_NAME}\". please update CMakeLists.txt.") message(FATAL_ERROR "Unknown platform \"${CMAKE_SYSTEM_NAME}\". please update CMakeLists.txt.")
endif() endif()
target_compile_definitions(rw_interface
INTERFACE
BOOST_ALL_NO_LIB
)
if(NOT BOOST_STATIC)
target_compile_definitions(rw_interface
INTERFACE
BOOST_ALL_DYN_LINK
)
endif()
if(USE_CONAN) if(USE_CONAN)
if(CONAN_SETTINGS_COMPILER_LIBCXX STREQUAL "libstdc++11") if(CONAN_SETTINGS_COMPILER_LIBCXX STREQUAL "libstdc++11")
target_compile_definitions(rw_interface INTERFACE _GLIBCXX_USE_CXX11_ABI=1) target_compile_definitions(rw_interface INTERFACE _GLIBCXX_USE_CXX11_ABI=1)
@ -86,20 +98,12 @@ elseif(FILESYSTEM_LIBRARY STREQUAL "CXXTS")
elseif(FILESYSTEM_LIBRARY STREQUAL "BOOST") elseif(FILESYSTEM_LIBRARY STREQUAL "BOOST")
target_compile_definitions(rw_interface INTERFACE "RW_FS_LIBRARY=2") target_compile_definitions(rw_interface INTERFACE "RW_FS_LIBRARY=2")
target_link_libraries(rw_interface INTERFACE target_link_libraries(rw_interface INTERFACE
rwdep::boost_filesystem Boost::filesystem
) )
else() else()
message(FATAL_ERROR "Illegal FILESYSTEM_LIBRARY option. (was '${FILESYSTEM_LIBRARY}')") message(FATAL_ERROR "Illegal FILESYSTEM_LIBRARY option. (was '${FILESYSTEM_LIBRARY}')")
endif() endif()
if(NOT BOOST_STATIC)
target_compile_definitions(rw_interface
INTERFACE
BOOST_ALL_DYN_LINK
)
endif()
if(ENABLE_SCRIPT_DEBUG) if(ENABLE_SCRIPT_DEBUG)
target_compile_definitions(rw_interface target_compile_definitions(rw_interface
INTERFACE INTERFACE

View File

@ -1,9 +1,6 @@
from conans import ConanFile, CMake from conans import ConanFile, CMake
from conans.errors import ConanException from conans.errors import ConanException
# FIXME:
# - no sound in cutscenes. Also no subtitles.
class OpenrwConan(ConanFile): class OpenrwConan(ConanFile):
name = 'openrw' name = 'openrw'
@ -20,11 +17,9 @@ class OpenrwConan(ConanFile):
default_options = ( default_options = (
'test_data=False', 'test_data=False',
'viewer=False', 'viewer=True',
'tools=False', 'tools=True',
'bullet:shared=False', 'bullet:shared=False',
'ffmpeg:iconv=False',
'libalsa:disable_python=True', # https://github.com/conan-community/community/issues/3
'sdl2:sdl2main=False', 'sdl2:sdl2main=False',
) )
@ -42,13 +37,17 @@ class OpenrwConan(ConanFile):
'boost/1.67.0@conan/stable', 'boost/1.67.0@conan/stable',
), ),
'viewer': ( 'viewer': (
'Qt/5.11@bincrafters/stable', 'Qt/5.11.1@bincrafters/stable',
), ),
'tools': ( 'tools': (
'freetype/2.9.0@bincrafters/stable', 'freetype/2.9.0@bincrafters/stable',
), ),
} }
def configure(self):
if self.options.viewer:
self.options['Qt'].opengl = 'desktop'
def requirements(self): def requirements(self):
for dep in self._rw_dependencies['game']: for dep in self._rw_dependencies['game']:
self.requires(dep) self.requires(dep)

View File

@ -44,6 +44,14 @@ add_library(rwcore
loaders/LoaderTXD.cpp loaders/LoaderTXD.cpp
) )
if(WIN32)
target_sources(rwcore
PRIVATE
platform/RWWindows.hpp
platform/RWWindows.cpp
)
endif()
target_include_directories(rwcore target_include_directories(rwcore
PUBLIC PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}"
@ -51,8 +59,8 @@ target_include_directories(rwcore
target_link_libraries(rwcore target_link_libraries(rwcore
PUBLIC PUBLIC
rwdep::boost Boost::boost
rwdep::glm glm::glm
openrw::interface openrw::interface
PRIVATE PRIVATE
OpenGL::GL OpenGL::GL

View File

@ -0,0 +1,30 @@
#include "RWWindows.hpp"
#include "rw/Debug.hpp"
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
std::string wideStringToACP(const wchar_t* wString) {
std::string returnValue;
bool result = true;
int nbChars = WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, wString, -1,
nullptr, 0, nullptr, nullptr);
if (nbChars == 0) {
if (GetLastError() != ERROR_SUCCESS) {
RW_ERROR("Unable to calculate length of wide string");
return returnValue;
}
}
returnValue.resize(nbChars);
nbChars =
WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, wString, -1,
&returnValue.front(), nbChars, nullptr, nullptr);
if (nbChars == 0) {
returnValue.resize(0);
return returnValue;
}
returnValue.resize(nbChars - 1);
return returnValue;
}

View File

@ -0,0 +1,14 @@
#ifndef _RWCORE_PLATFORM_RWWINDOWS_HPP_
#define _RWCORE_PLATFORM_RWWINDOWS_HPP_
#include <string>
/**
* @brief Convert a wide string to a ACP string (=active code page)
* This function converts to the active code page instead of utf8
* because Windows functions need to understand the encoding.
* @param str The wide string to convert
*/
std::string wideStringToACP(const wchar_t* str);
#endif

View File

@ -2,6 +2,7 @@
#define _LIBRW_CASTS_HPP_ #define _LIBRW_CASTS_HPP_
#include <cstring> // memcpy #include <cstring> // memcpy
#include <string>
#include "rw/debug.hpp" #include "rw/debug.hpp"

View File

@ -1,7 +1,3 @@
###########################################################
## RWENGINE
###########################################################
set(RWENGINE_SOURCES set(RWENGINE_SOURCES
src/ai/AIGraph.cpp src/ai/AIGraph.cpp
src/ai/AIGraph.hpp src/ai/AIGraph.hpp
@ -149,10 +145,10 @@ add_library(rwengine
target_link_libraries(rwengine target_link_libraries(rwengine
PUBLIC PUBLIC
rwcore rwcore
rwdep::bullet bullet::bullet
rwdep::ffmpeg ffmpeg::ffmpeg
rwdep::glm glm::glm
rwdep::OpenAL OpenAL::OpenAL
) )
target_include_directories(rwengine target_include_directories(rwengine

View File

@ -45,14 +45,14 @@ add_executable(rwgame
target_include_directories(rwgame target_include_directories(rwgame
PUBLIC PUBLIC
"${CMAKE_SOURCE_DIR}/rwgame" "${CMAKE_CURRENT_SOURCE_DIR}"
) )
target_link_libraries(rwgame target_link_libraries(rwgame
PRIVATE PRIVATE
rwengine rwengine
rwdep::boost_program_options Boost::program_options
rwdep::SDL2 SDL2::SDL2
) )
openrw_target_apply_options(TARGET rwgame) openrw_target_apply_options(TARGET rwgame)

View File

@ -1,13 +1,20 @@
#include "GameConfig.hpp" #include "GameConfig.hpp"
#include <algorithm>
#include <rw/debug.hpp> #include <rw/debug.hpp>
#include <rw/filesystem.hpp> #include <rw/filesystem.hpp>
#include <algorithm>
#include <boost/property_tree/ini_parser.hpp> #include <boost/property_tree/ini_parser.hpp>
#include <boost/property_tree/ptree.hpp> #include <boost/property_tree/ptree.hpp>
namespace pt = boost::property_tree; namespace pt = boost::property_tree;
#ifdef RW_WINDOWS
#include <Shlobj.h>
#include <winerror.h>
#include <platform/RWWindows.hpp>
#endif
const std::string kConfigDirectoryName("OpenRW"); const std::string kConfigDirectoryName("OpenRW");
void GameConfig::loadFile(const rwfs::path &path) { void GameConfig::loadFile(const rwfs::path &path) {
@ -44,9 +51,16 @@ rwfs::path GameConfig::getDefaultConfigPath() {
#elif defined(RW_OSX) #elif defined(RW_OSX)
char *home = getenv("HOME"); char *home = getenv("HOME");
if (home) if (home)
return rwfs::path(home) / "Library/Preferences/" / return rwfs::path(home) / "Library/Preferences/" / kConfigDirectoryName;
kConfigDirectoryName;
#elif defined(RW_WINDOWS)
wchar_t *widePath;
auto res = SHGetKnownFolderPath(FOLDERID_RoamingAppData, KF_FLAG_DEFAULT,
nullptr, &widePath);
if (SUCCEEDED(res)) {
auto utf8Path = wideStringToACP(widePath);
return rwfs::path(utf8Path) / kConfigDirectoryName;
}
#else #else
return rwfs::path(); return rwfs::path();
#endif #endif
@ -343,7 +357,7 @@ void GameConfig::ParseResult::failInputFile(size_t line,
} }
void GameConfig::ParseResult::markGood() { void GameConfig::ParseResult::markGood() {
this-> m_result = ParseResult::ErrorType::GOOD; this->m_result = ParseResult::ErrorType::GOOD;
} }
void GameConfig::ParseResult::failArgument() { void GameConfig::ParseResult::failArgument() {

View File

@ -867,7 +867,7 @@ void RWGame::renderProfile() {
float xscale = renderer.getRenderer()->getViewport().x / upperlimit; float xscale = renderer.getRenderer()->getViewport().x / upperlimit;
TextRenderer::TextInfo ti; TextRenderer::TextInfo ti;
ti.align = TextRenderer::TextInfo::Left; ti.align = TextRenderer::TextInfo::TextAlignment::Left;
ti.font = FONT_ARIAL; ti.font = FONT_ARIAL;
ti.size = lineHeight - 2.f; ti.size = lineHeight - 2.f;
ti.baseColour = glm::u8vec3(255); ti.baseColour = glm::u8vec3(255);

View File

@ -1,4 +1,3 @@
# fixme: conan support
find_package(Qt5 REQUIRED COMPONENTS Gui) find_package(Qt5 REQUIRED COMPONENTS Gui)
add_executable(rwfontmap add_executable(rwfontmap
rwfontmap.cpp rwfontmap.cpp
@ -7,12 +6,11 @@ add_executable(rwfontmap
target_link_libraries(rwfontmap target_link_libraries(rwfontmap
PUBLIC PUBLIC
rwcore rwcore
rwdep::freetype Freetype::Freetype
rwdep::boost_program_options Boost::program_options
Qt5::Gui Qt5::Gui
) )
install(TARGETS rwfontmap install(TARGETS rwfontmap
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
) )

View File

@ -4,7 +4,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
find_package(Qt5OpenGL REQUIRED) find_package(Qt5OpenGL REQUIRED)
find_package(Qt5Widgets REQUIRED) find_package(Qt5Widgets REQUIRED)
add_executable(rwviewer WIN32 add_executable(rwviewer
main.cpp main.cpp
ViewerWindow.hpp ViewerWindow.hpp

View File

@ -10,31 +10,37 @@ from conans.client import conan_api
openrw_path = Path(__file__).resolve().parents[2] openrw_path = Path(__file__).resolve().parents[2]
windows_profile = openrw_path / 'scripts' / 'conan' / 'windows'
cmake_generator_lookup = { cmake_generator_lookup = {
2015: 'Visual Studio 14 2015', 2015: 'Visual Studio 14 2015',
2017: 'Visual Studio 15 2017', 2017: 'Visual Studio 15 2017',
} }
architectures = ['x64', 'x86'] architectures = ['x64', 'x86']
conan_arch_map = {
'x86': 'x86',
'x64': 'x86_64',
}
def to_cmake_generator(vs_version, arch): def to_cmake_generator(vs_version, arch):
cmake_generator = cmake_generator_lookup[vs_version] cmake_generator = cmake_generator_lookup[vs_version]
if arch == 'x64': if arch == 'x64':
cmake_generator = '{} Win64'.format(cmake_generator) cmake_generator = '{} Win64'.format(cmake_generator)
return cmake_generator return cmake_generator
def create_solution(path, vs_version, arch): def create_solution(path, vs_version, arch):
conan, _, _ = conan_api.ConanAPIV1.factory() conan, _, _ = conan_api.ConanAPIV1.factory()
conan.remote_add(remote='bincrafters', url='https://api.bintray.com/conan/bincrafters/public-conan', force=True) conan.remote_add(remote='bincrafters', url='https://api.bintray.com/conan/bincrafters/public-conan', force=True)
conan.install(path=openrw_path, profile_name=windows_profile, generators=('cmake_multi',), conan_arch = conan_arch_map[arch]
options=('openrw:viewer=False', ), settings=('build_type=Debug', ), install_folder=path) conan.install(path=openrw_path, generators=('cmake_multi',), build=['missing', ],
conan.install(path=openrw_path, profile_name=windows_profile, generators=('cmake_multi',), settings=('build_type=Debug', 'arch={}'.format(conan_arch), ), install_folder=path)
options=('openrw:viewer=False', ), settings=('build_type=Release', ), install_folder=path) conan.install(path=openrw_path, generators=('cmake_multi',), build=['missing', ],
settings=('build_type=Release', 'arch={}'.format(conan_arch), ), install_folder=path)
cmake_generator = to_cmake_generator(vs_version=vs_version, arch=arch) cmake_generator = to_cmake_generator(vs_version=vs_version, arch=arch)
subprocess.run([ subprocess.run([
'cmake', '-DUSE_CONAN=1', '-DBOOST_STATIC=TRUE', '-DBUILD_TESTS=1', 'cmake', '-DUSE_CONAN=TRUE', '-DBOOST_STATIC=TRUE',
'-DBUILD_TESTS=TRUE', '-DBUILD_VIEWER=TRUE', '-DBUILD_TOOLS=TRUE',
'-G{}'.format(cmake_generator), str(openrw_path), '-G{}'.format(cmake_generator), str(openrw_path),
], cwd=path, check=True) ], cwd=path, check=True)

View File

@ -1,9 +0,0 @@
include(default)
[options]
openrw:tools=True
openrw:viewer=True
# https://github.com/bincrafters/community/issues/120
ffmpeg:vdpau=False
ffmpeg:vaapi=False
ffmpeg:xcb=False

View File

@ -1,12 +0,0 @@
include(default)
[options]
openrw:tools=True
openrw:viewer=True
sdl2:esd=False
sdl2:wayland=True
sdl2:x11=True
# https://github.com/bincrafters/community/issues/120
ffmpeg:vdpau=False
ffmpeg:vaapi=False
ffmpeg:xcb=False

View File

@ -1,6 +0,0 @@
include(default)
[options]
openrw:tools=True
openrw:viewer=True
ffmpeg:qsv=False

View File

@ -11,6 +11,7 @@ RUN apt-get update \
python3-distutils \ python3-distutils \
python3-setuptools \ python3-setuptools \
python3-wheel \ python3-wheel \
wget \
# packet build requirements \ # packet build requirements \
git \ git \
autoconf \ autoconf \

View File

@ -8,7 +8,17 @@ 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 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 USE_CONAN=$USE_CONAN "$curdir/docker_tool.py" create -t openrw_build_image -n openrw_builder -U travis \
-e \
NAME_SUFFIX=$NAME_SUFFIX \
TRAVIS=$TRAVIS \
TRAVIS_COMMIT=$TRAVIS_COMMIT \
TRAVIS_EVENT_TYPE=$TRAVIS_EVENT_TYPE \
TRAVIS_REPO_SLUG=$TRAVIS_REPO_SLUG \
TRAVIS_BRANCH=$TRAVIS_BRANCH \
USE_CONAN=$USE_CONAN \
DEBUG=$DEBUG \
XDG_RUNTIME_DIR=/tmp
# execute test # execute test
"$curdir/docker_tool.py" exec -n openrw_builder -U travis -- /bin/bash -c "ctest -VV -S /src/cmake/ctest/script_ci.ctest -VV" "$curdir/docker_tool.py" exec -n openrw_builder -U travis -- /bin/bash -c "ctest -VV -S /src/cmake/ctest/script_ci.ctest -VV"

View File

@ -1,4 +1,4 @@
FROM fedora:branched FROM fedora:latest
# ffmpeg-devel needs rpmfusion # ffmpeg-devel needs rpmfusion
RUN dnf install -y https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm \ RUN dnf install -y https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm \

View File

@ -1,7 +1,3 @@
##############################################################################
# Unit Tests
##############################################################################
set(TESTS set(TESTS
Animation Animation
Archive Archive
@ -47,9 +43,9 @@ set(TEST_SOURCES
test_Globals.hpp test_Globals.hpp
# Hack in rwgame sources until there's a per-target test suite # Hack in rwgame sources until there's a per-target test suite
"${CMAKE_SOURCE_DIR}/rwgame/GameConfig.cpp" "${PROJECT_SOURCE_DIR}/rwgame/GameConfig.cpp"
"${CMAKE_SOURCE_DIR}/rwgame/GameWindow.cpp" "${PROJECT_SOURCE_DIR}/rwgame/GameWindow.cpp"
"${CMAKE_SOURCE_DIR}/rwgame/GameInput.cpp" "${PROJECT_SOURCE_DIR}/rwgame/GameInput.cpp"
) )
foreach(TEST ${TESTS}) foreach(TEST ${TESTS})
@ -67,16 +63,16 @@ target_compile_definitions(rwtests
target_include_directories(rwtests target_include_directories(rwtests
PRIVATE PRIVATE
"${CMAKE_SOURCE_DIR}/tests" "${PROJECT_SOURCE_DIR}/tests"
"${CMAKE_SOURCE_DIR}/rwgame" "${PROJECT_SOURCE_DIR}/rwgame"
) )
target_link_libraries(rwtests target_link_libraries(rwtests
PRIVATE PRIVATE
Boost::unit_test_framework
rwengine rwengine
rwdep::SDL2 SDL2::SDL2
rwdep::boost_filesystem Boost::filesystem
rwdep::boost_unit_test_framework
) )
openrw_target_apply_options(TARGET rwtests) openrw_target_apply_options(TARGET rwtests)

View File

@ -33,7 +33,7 @@ BOOST_AUTO_TEST_CASE(test_indexTree) {
BOOST_CHECK(upperpath != truepath); BOOST_CHECK(upperpath != truepath);
rwfs::path expected{Global::getGamePath()}; rwfs::path expected{Global::getGamePath()};
expected /= "data/CULLZONE.DAT"; expected /= "data/CULLZONE.DAT";
BOOST_CHECK_EQUAL(truepath.string(), expected.string()); BOOST_CHECK(expected.compare(expected) == 0);
} }
{ {
std::string upperpath{"DATA/MAPS/COMNBTM/COMNBTM.IPL"}; std::string upperpath{"DATA/MAPS/COMNBTM/COMNBTM.IPL"};
@ -42,7 +42,7 @@ BOOST_AUTO_TEST_CASE(test_indexTree) {
BOOST_CHECK(upperpath != truepath); BOOST_CHECK(upperpath != truepath);
rwfs::path expected{Global::getGamePath()}; rwfs::path expected{Global::getGamePath()};
expected /= "data/maps/comnbtm/comNbtm.ipl"; expected /= "data/maps/comnbtm/comNbtm.ipl";
BOOST_CHECK_EQUAL(truepath.string(), expected.string()); BOOST_CHECK(expected.compare(truepath) == 0);
} }
} }