Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
[linux] add CI for Linux, dxvk_native, safeclib and 1st version for s…
Browse files Browse the repository at this point in the history
…torm_platform.h
  • Loading branch information
q4a committed Jun 6, 2022
1 parent 306e975 commit 53b415c
Show file tree
Hide file tree
Showing 12 changed files with 181 additions and 10 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/ci_linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: CI Linux

on:
push:
paths-ignore:
- 'docs/**'
- 'tools/**'
- '*.md'
pull_request:
paths-ignore:
- 'docs/**'
- 'tools/**'
- '*.md'

jobs:
build-linux:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
configuration: [Debug]
name: 'build-linux [${{ matrix.configuration}}]'
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Install libs
run: sudo apt update && sudo apt install meson libstdc++-10-dev libvulkan-dev glslang-tools libsdl2-dev libgl-dev libegl-dev
- name: Install Conan
run: pip install conan
- name: Configure with cmake
run: |
export CC=clang-11
export CXX=clang++-11
${CXX} --version
mkdir build && cd build
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=${{matrix.configuration}}
- name: Build dependencies
run: ninja dependencies
working-directory: build
- name: Build project
run: ninja
working-directory: build
File renamed without changes.
26 changes: 25 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,30 @@ conan_cmake_run(CONANFILE conanfile.py
steam=${STORM_ENABLE_STEAM}
)

if (NOT WIN32)
message("Using DXVK-native for D3D9 API")

include(ExternalProject)
ExternalProject_Add(dxvk-native
GIT_REPOSITORY https://github.com/Joshua-Ashton/dxvk-native
GIT_TAG a2dc99c407340432d4ba5bfa29efa685c27942ea
GIT_SHALLOW ON
BUILD_ALWAYS OFF
CONFIGURE_HANDLED_BY_BUILD ON
CONFIGURE_COMMAND meson ../dxvk-native
BUILD_COMMAND ninja
INSTALL_COMMAND ""
)
ExternalProject_Get_property(dxvk-native SOURCE_DIR BINARY_DIR)
set(DXVK_NATIVE_INCLUDE_DIRS
"${SOURCE_DIR}/include/native/directx"
"${SOURCE_DIR}/include/native/windows"
)
set(DXVK_NATIVE_D3D9_LIB ${BINARY_DIR}/src/d3d9/libdxvk_d3d9.so)
include_directories("${DXVK_NATIVE_INCLUDE_DIRS}")
ADD_CUSTOM_TARGET(dependencies ALL DEPENDS dxvk-native)
endif()

### Define library ALIASes for use without CONAN_PKG:: prefix
foreach (conan_target ${CONAN_TARGETS})
string(REPLACE "CONAN_PKG::" "" unprefixed_target ${conan_target})
Expand All @@ -54,4 +78,4 @@ set(HEADER_FILE_EXTENSIONS "*.h" "*.hpp" CACHE STRING "File extensions for heade
###

add_subdirectory(src)
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT engine)
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT engine)
12 changes: 11 additions & 1 deletion cmake/StormSetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,24 @@ macro(STORM_SETUP)

# link storm modules to executable forcing unused symbols to be preserved
if(${_SETUP_TYPE} STREQUAL "executable")
if(NOT WIN32)
list(APPEND target_link_flags "-Wl,--whole-archive")
endif()
list(REMOVE_DUPLICATES global_modules_list)
list(APPEND _SETUP_DEPENDENCIES "${global_modules_list}")
foreach(module ${global_modules_list})
if(TARGET ${module})
# TODO: make it portable? (at least for gcc it is --whole-archive)
list(APPEND target_link_flags "/WHOLEARCHIVE:${module}")
if (WIN32)
list(APPEND target_link_flags "/WHOLEARCHIVE:${module}")
else()
list(APPEND target_link_flags "${CMAKE_BINARY_DIR}/lib/lib${dep}.a")
endif()
endif()
endforeach()
if(NOT WIN32)
list(APPEND target_link_flags "-Wl,--no-whole-archive")
endif()
endif()

if(_SETUP_DEPENDENCIES)
Expand Down
14 changes: 12 additions & 2 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,37 @@ class StormEngine(ConanFile):

# dependencies used in deploy binaries
# conan-center
requires = ["zlib/1.2.11", "spdlog/1.9.2", "7zip/19.00", "fast_float/3.4.0", "sdl/2.0.18", "mimalloc/2.0.3",
requires = ["zlib/1.2.11", "spdlog/1.9.2", "fast_float/3.4.0", "sdl/2.0.18", "mimalloc/2.0.3",
# storm.jfrog.io
"sentry-native/0.4.13@storm/patched", "directx/9.0@storm/prebuilt", "fmod/2.02.05@storm/prebuilt"]
# aux dependencies (e.g. for tests)
build_requires = "catch2/2.13.7"

# optional dependencies
def requirements(self):
if self.settings.os == "Windows":
# conan-center
self.requires("7zip/19.00")
else:
# conan-center
self.requires("libsafec/3.6.0")
if self.options.steam:
self.requires("steamworks/1.5.1@storm/prebuilt")

generators = "cmake_multi"

default_options = {
"sdl2:sdl2main": False,
"sdl2:pulse": False,
"sentry-native:backend": "crashpad",
"sentry-native:transport": "winhttp",
"mimalloc:shared": True,
"mimalloc:override": True
}

def configure(self):
if self.settings.os == "Windows":
self.default_options["sentry-native:transport"] = "winhttp"

def imports(self):
self.__dest = str(self.options.output_directory) + "/" + getenv("CONAN_IMPORT_PATH", "bin")
self.__install_folder("/src/techniques", "/resource/techniques")
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ if (MSVC)
add_link_options("$<$<CONFIG:Release>:/OPT:ICF>") # Perform identical COMDAT folding, needs to be explicitly specified with /DEBUG
add_link_options("$<$<CONFIG:Release>:/LTCG>") # Enable link-time code generation
else()
add_definitions(-D_GLIBCXX_USE_TBB_PAR_BACKEND=0) # Don't use tbb
add_compile_options(-std=c++20)

# Verbose output
Expand Down
12 changes: 9 additions & 3 deletions src/apps/engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ else()
set(MIMALLOC_DEP "$<IF:$<CONFIG:Release>,${CONAN_LIB_DIRS_MIMALLOC_RELEASE}/libmimalloc.so,${CONAN_LIB_DIRS_MIMALLOC_DEBUG}/libmimalloc-debug.so>")
endif()

if (WIN32)
set(SYSTEM_DEPS
"comctl32"
"dbghelp"
"winhttp"
)
endif()

STORM_SETUP(
TARGET_NAME engine
TYPE executable
Expand All @@ -27,7 +35,5 @@ STORM_SETUP(
zlib

# system
comctl32
dbghelp
winhttp
${SYSTEM_DEPS}
)
6 changes: 5 additions & 1 deletion src/libs/common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
if (NOT WIN32)
set(SYSTEM_DEPS "libsafec")
endif()

STORM_SETUP(
TARGET_NAME common
TYPE library
DEPENDENCIES shared_headers util spdlog directx
DEPENDENCIES shared_headers util spdlog directx ${SYSTEM_DEPS}
)
1 change: 1 addition & 0 deletions src/libs/common/include/attributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include "storm_assert.h"
#include "storm/string_compare.hpp"
#include "storm_platform.h"

class VSTRING_CODEC
{
Expand Down
61 changes: 61 additions & 0 deletions src/libs/common/include/storm_platform.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#ifndef _WIN32

#include "safe_str_lib.h"

// use custom strcpy_s instead of safeclib: #define strcpy_s(dest, dmax, src)
#undef strcpy_s

inline int strcpy_s(char *dest, size_t size, const char *src)
{
if (!dest)
return EINVAL;

if (0 == size)
{
dest[0] = '\0';
return ERANGE;
}

if (!src)
{
dest[0] = '\0';
return EINVAL;
}

size_t i;
for (i = 0; i < size; i++)
{
if ((dest[i] = src[i]) == '\0')
return 0;
}
dest[0] = '\0';
return ERANGE;
}

template <std::size_t size> inline int strcpy_s(char (&dest)[size], const char *src)
{
return strcpy_s(dest, size, src);
}

// use custom sprintf_s instead of safeclib: #define sprintf_s(dest, dmax, ...)
#undef sprintf_s

template <size_t size> inline int sprintf_s(char (&buffer)[size], const char *format, ...)
{
va_list args;
va_start(args, format);
int result = vsnprintf(buffer, size, format, args);
va_end(args);
return result;
}

inline int sprintf_s(char *buffer, size_t size, const char *format, ...)
{
va_list ap;
va_start(ap, format);
int result = vsnprintf(buffer, size, format, ap);
va_end(ap);
return result;
}

#endif
6 changes: 5 additions & 1 deletion src/libs/renderer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
if (WIN32)
set(SYSTEM_DEPS "legacy_stdio_definitions")
endif()

STORM_SETUP(
TARGET_NAME renderer
TYPE storm_module
DEPENDENCIES common core util legacy_stdio_definitions
DEPENDENCIES common core util ${SYSTEM_DEPS}
)
9 changes: 8 additions & 1 deletion src/libs/xinterface/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
if (WIN32)
set(SYSTEM_DEPS
"ddraw"
"amstrmid"
)
endif()

STORM_SETUP(
TARGET_NAME xinterface
TYPE storm_module
DEPENDENCIES common core ddraw amstrmid util
DEPENDENCIES common core util ${SYSTEM_DEPS}
TEST_DEPENDENCIES catch2
)

0 comments on commit 53b415c

Please sign in to comment.