Skip to content

Commit

Permalink
Merge pull request #190 from OpenBrickProtocolFoundation/fix_windows_…
Browse files Browse the repository at this point in the history
…static_build

Fix windows static build
  • Loading branch information
Totto16 authored Oct 15, 2024
2 parents 5028e8f + 04d1cb6 commit 4da0b09
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 7 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,19 @@ jobs:
fail-fast: false
matrix:
config:
- name: Windows MSVC
- name: Windows MSVC (dynamic)
os: windows
os-version: 2022
environment: msvc
shell: pwsh
static: false

- name: Windows MSVC (static)
os: windows
os-version: 2022
environment: msvc
shell: pwsh
static: true

- name: Windows MingGW
os: windows
Expand Down Expand Up @@ -187,7 +195,7 @@ jobs:
brew install sdl2 sdl2_ttf sdl2_mixer sdl2_image
- name: Configure
run: meson setup build -Dbuildtype=release -Ddefault_library=shared -Dclang_libcpp=${{ ( ( matrix.config.os == 'ubuntu' && matrix.config.use-clang == true && matrix.config.use-clang_stdlib ) || matrix.config.os == 'macos' ) && 'enabled' || 'disabled' }}
run: meson setup build -Dbuildtype=release -Ddefault_library=${{( matrix.config.os == 'windows' && matrix.config.environment == 'msvc' && matrix.config.static ) && 'static' ||'shared' }} -Dclang_libcpp=${{ ( ( matrix.config.os == 'ubuntu' && matrix.config.use-clang == true && matrix.config.use-clang_stdlib ) || matrix.config.os == 'macos' ) && 'enabled' || 'disabled' }}

- name: Build
run: meson compile -C build
Expand Down
17 changes: 16 additions & 1 deletion src/helper/graphic_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,28 @@ namespace utils {

// this needs some special handling, so the macro is defined here
#if defined(_MSC_VER)
#if defined(OOPETRIS_LIBRARY_GRAPHICS_TYPE) && OOPETRIS_LIBRARY_GRAPHICS_TYPE == 0

#else

#endif
#else

#endif


#if defined(_MSC_VER)
#if defined(OOPETRIS_LIBRARY_GRAPHICS_TYPE) && OOPETRIS_LIBRARY_GRAPHICS_TYPE == 0
#if defined(OOPETRIS_LIBRARY_GRAPHICS_EXPORT)
#define OOPETRIS_GRAPHICS_EXPORTED_NORETURN __declspec(dllexport, noreturn)
#else
#define OOPETRIS_GRAPHICS_EXPORTED_NORETURN __declspec(dllimport, noreturn)
#endif
#else
#define OOPETRIS_GRAPHICS_EXPORTED_NORETURN
#define OOPETRIS_GRAPHICS_EXPORTED_NORETURN __declspec(noreturn)
#endif
#else
#define OOPETRIS_GRAPHICS_EXPORTED_NORETURN [[noreturn]]
#endif


Expand Down
4 changes: 4 additions & 0 deletions src/helper/windows.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#if defined(_MSC_VER)
#if defined(OOPETRIS_LIBRARY_GRAPHICS_TYPE) && OOPETRIS_LIBRARY_GRAPHICS_TYPE == 0
#if defined(OOPETRIS_LIBRARY_GRAPHICS_EXPORT)
#define OOPETRIS_GRAPHICS_EXPORTED __declspec(dllexport)
#else
Expand All @@ -9,3 +10,6 @@
#else
#define OOPETRIS_GRAPHICS_EXPORTED
#endif
#else
#define OOPETRIS_GRAPHICS_EXPORTED
#endif
6 changes: 5 additions & 1 deletion src/libs/core/hash-library/sha256.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@ typedef unsigned __int8 uint8_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int64 uint64_t;

#if defined(HASH_LIBRARY_EXPORT)
#if defined(OOPETRIS_LIBRARY_CORE_TYPE) && OOPETRIS_LIBRARY_CORE_TYPE == 0
#if defined(OOPETRIS_LIBRARY_CORE_EXPORT)
#define HASH_LIBRARY_EXPORTED __declspec(dllexport)
#else
#define HASH_LIBRARY_EXPORTED __declspec(dllimport)
#endif
#else
#define HASH_LIBRARY_EXPORTED
#endif

#else
// GCC
Expand Down
4 changes: 4 additions & 0 deletions src/libs/core/helper/windows.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#if defined(_MSC_VER)
#if defined(OOPETRIS_LIBRARY_CORE_TYPE) && OOPETRIS_LIBRARY_CORE_TYPE == 0
#if defined(OOPETRIS_LIBRARY_CORE_EXPORT)
#define OOPETRIS_CORE_EXPORTED __declspec(dllexport)
#else
Expand All @@ -9,3 +10,6 @@
#else
#define OOPETRIS_CORE_EXPORTED
#endif
#else
#define OOPETRIS_CORE_EXPORTED
#endif
8 changes: 7 additions & 1 deletion src/libs/core/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,20 @@ subdir('game')
subdir('hash-library')
subdir('helper')

temp = core_lib.get('compile_args')
temp += '-DOOPETRIS_LIBRARY_CORE_TYPE='+ (get_option('default_library') == 'static' ? '1' : '0')
core_lib += {'compile_args': temp}
temp = 0


liboopetris_core = library(
'oopetris_core',
core_src_files,
core_header_files,
include_directories: core_lib.get('inc_dirs'),
dependencies: core_lib.get('deps'),
cpp_args: core_lib.get('compile_args'),
cpp_shared_args: ['-DOOPETRIS_LIBRARY_CORE_EXPORT', '-DHASH_LIBRARY_EXPORT'],
cpp_shared_args: ['-DOOPETRIS_LIBRARY_CORE_EXPORT'],
override_options: {
'warning_level': '3',
'werror': true,
Expand Down
8 changes: 7 additions & 1 deletion src/libs/recordings/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@ recordings_include_dir = include_dir / 'oopetris' / 'recordings'

subdir('utility')

temp = recordings_lib.get('compile_args')
temp += '-DOOPETRIS_LIBRARY_RECORDINGS_TYPE='+ (get_option('default_library') == 'static' ? '1' : '0')
recordings_lib += {'compile_args': temp}
temp = 0


recordings_lib += {
'deps': [recordings_lib.get('deps'), liboopetris_core_dep],
'inc_dirs': [recordings_lib.get('inc_dirs'), include_directories('.')],
'inc_dirs': [recordings_lib.get('inc_dirs'), include_directories('.')]
}

liboopetris_recordings = library(
Expand Down
4 changes: 4 additions & 0 deletions src/libs/recordings/utility/windows.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#if defined(_MSC_VER)
#if defined(OOPETRIS_LIBRARY_RECORDINGS_TYPE) && OOPETRIS_LIBRARY_RECORDINGS_TYPE == 0
#if defined(OOPETRIS_LIBRARY_RECORDINGS_EXPORT)
#define OOPETRIS_RECORDINGS_EXPORTED __declspec(dllexport)
#else
Expand All @@ -9,3 +10,6 @@
#else
#define OOPETRIS_RECORDINGS_EXPORTED
#endif
#else
#define OOPETRIS_RECORDINGS_EXPORTED
#endif
3 changes: 3 additions & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ if build_application
graphics_lib += {
'deps': [graphics_lib.get('deps'), liboopetris_recordings_dep],
'inc_dirs': [graphics_lib.get('inc_dirs'), include_directories('.')],
'compile_args' : [graphics_lib.get('compile_args'),
'-DOOPETRIS_LIBRARY_GRAPHICS_TYPE='+
(get_option('default_library') == 'static' ? '1' : '0')]
}

liboopetris_graphics = library(
Expand Down

0 comments on commit 4da0b09

Please sign in to comment.