Skip to content

Commit 4da0b09

Browse files
authored
Merge pull request #190 from OpenBrickProtocolFoundation/fix_windows_static_build
Fix windows static build
2 parents 5028e8f + 04d1cb6 commit 4da0b09

File tree

10 files changed

+61
-7
lines changed

10 files changed

+61
-7
lines changed

.github/workflows/build.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,19 @@ jobs:
1515
fail-fast: false
1616
matrix:
1717
config:
18-
- name: Windows MSVC
18+
- name: Windows MSVC (dynamic)
1919
os: windows
2020
os-version: 2022
2121
environment: msvc
2222
shell: pwsh
23+
static: false
24+
25+
- name: Windows MSVC (static)
26+
os: windows
27+
os-version: 2022
28+
environment: msvc
29+
shell: pwsh
30+
static: true
2331

2432
- name: Windows MingGW
2533
os: windows
@@ -187,7 +195,7 @@ jobs:
187195
brew install sdl2 sdl2_ttf sdl2_mixer sdl2_image
188196
189197
- name: Configure
190-
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' }}
198+
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' }}
191199

192200
- name: Build
193201
run: meson compile -C build

src/helper/graphic_utils.hpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,28 @@ namespace utils {
3636

3737
// this needs some special handling, so the macro is defined here
3838
#if defined(_MSC_VER)
39+
#if defined(OOPETRIS_LIBRARY_GRAPHICS_TYPE) && OOPETRIS_LIBRARY_GRAPHICS_TYPE == 0
40+
41+
#else
42+
43+
#endif
44+
#else
45+
46+
#endif
47+
48+
49+
#if defined(_MSC_VER)
50+
#if defined(OOPETRIS_LIBRARY_GRAPHICS_TYPE) && OOPETRIS_LIBRARY_GRAPHICS_TYPE == 0
3951
#if defined(OOPETRIS_LIBRARY_GRAPHICS_EXPORT)
4052
#define OOPETRIS_GRAPHICS_EXPORTED_NORETURN __declspec(dllexport, noreturn)
4153
#else
4254
#define OOPETRIS_GRAPHICS_EXPORTED_NORETURN __declspec(dllimport, noreturn)
4355
#endif
4456
#else
45-
#define OOPETRIS_GRAPHICS_EXPORTED_NORETURN
57+
#define OOPETRIS_GRAPHICS_EXPORTED_NORETURN __declspec(noreturn)
58+
#endif
59+
#else
60+
#define OOPETRIS_GRAPHICS_EXPORTED_NORETURN [[noreturn]]
4661
#endif
4762

4863

src/helper/windows.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22

33
#if defined(_MSC_VER)
4+
#if defined(OOPETRIS_LIBRARY_GRAPHICS_TYPE) && OOPETRIS_LIBRARY_GRAPHICS_TYPE == 0
45
#if defined(OOPETRIS_LIBRARY_GRAPHICS_EXPORT)
56
#define OOPETRIS_GRAPHICS_EXPORTED __declspec(dllexport)
67
#else
@@ -9,3 +10,6 @@
910
#else
1011
#define OOPETRIS_GRAPHICS_EXPORTED
1112
#endif
13+
#else
14+
#define OOPETRIS_GRAPHICS_EXPORTED
15+
#endif

src/libs/core/hash-library/sha256.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@ typedef unsigned __int8 uint8_t;
1818
typedef unsigned __int32 uint32_t;
1919
typedef unsigned __int64 uint64_t;
2020

21-
#if defined(HASH_LIBRARY_EXPORT)
21+
#if defined(OOPETRIS_LIBRARY_CORE_TYPE) && OOPETRIS_LIBRARY_CORE_TYPE == 0
22+
#if defined(OOPETRIS_LIBRARY_CORE_EXPORT)
2223
#define HASH_LIBRARY_EXPORTED __declspec(dllexport)
2324
#else
2425
#define HASH_LIBRARY_EXPORTED __declspec(dllimport)
2526
#endif
27+
#else
28+
#define HASH_LIBRARY_EXPORTED
29+
#endif
2630

2731
#else
2832
// GCC

src/libs/core/helper/windows.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22

33
#if defined(_MSC_VER)
4+
#if defined(OOPETRIS_LIBRARY_CORE_TYPE) && OOPETRIS_LIBRARY_CORE_TYPE == 0
45
#if defined(OOPETRIS_LIBRARY_CORE_EXPORT)
56
#define OOPETRIS_CORE_EXPORTED __declspec(dllexport)
67
#else
@@ -9,3 +10,6 @@
910
#else
1011
#define OOPETRIS_CORE_EXPORTED
1112
#endif
13+
#else
14+
#define OOPETRIS_CORE_EXPORTED
15+
#endif

src/libs/core/meson.build

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,20 @@ subdir('game')
77
subdir('hash-library')
88
subdir('helper')
99

10+
temp = core_lib.get('compile_args')
11+
temp += '-DOOPETRIS_LIBRARY_CORE_TYPE='+ (get_option('default_library') == 'static' ? '1' : '0')
12+
core_lib += {'compile_args': temp}
13+
temp = 0
14+
15+
1016
liboopetris_core = library(
1117
'oopetris_core',
1218
core_src_files,
1319
core_header_files,
1420
include_directories: core_lib.get('inc_dirs'),
1521
dependencies: core_lib.get('deps'),
1622
cpp_args: core_lib.get('compile_args'),
17-
cpp_shared_args: ['-DOOPETRIS_LIBRARY_CORE_EXPORT', '-DHASH_LIBRARY_EXPORT'],
23+
cpp_shared_args: ['-DOOPETRIS_LIBRARY_CORE_EXPORT'],
1824
override_options: {
1925
'warning_level': '3',
2026
'werror': true,

src/libs/recordings/meson.build

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,15 @@ recordings_include_dir = include_dir / 'oopetris' / 'recordings'
55

66
subdir('utility')
77

8+
temp = recordings_lib.get('compile_args')
9+
temp += '-DOOPETRIS_LIBRARY_RECORDINGS_TYPE='+ (get_option('default_library') == 'static' ? '1' : '0')
10+
recordings_lib += {'compile_args': temp}
11+
temp = 0
12+
13+
814
recordings_lib += {
915
'deps': [recordings_lib.get('deps'), liboopetris_core_dep],
10-
'inc_dirs': [recordings_lib.get('inc_dirs'), include_directories('.')],
16+
'inc_dirs': [recordings_lib.get('inc_dirs'), include_directories('.')]
1117
}
1218

1319
liboopetris_recordings = library(

src/libs/recordings/utility/windows.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22

33
#if defined(_MSC_VER)
4+
#if defined(OOPETRIS_LIBRARY_RECORDINGS_TYPE) && OOPETRIS_LIBRARY_RECORDINGS_TYPE == 0
45
#if defined(OOPETRIS_LIBRARY_RECORDINGS_EXPORT)
56
#define OOPETRIS_RECORDINGS_EXPORTED __declspec(dllexport)
67
#else
@@ -9,3 +10,6 @@
910
#else
1011
#define OOPETRIS_RECORDINGS_EXPORTED
1112
#endif
13+
#else
14+
#define OOPETRIS_RECORDINGS_EXPORTED
15+
#endif

src/meson.build

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ if build_application
2323
graphics_lib += {
2424
'deps': [graphics_lib.get('deps'), liboopetris_recordings_dep],
2525
'inc_dirs': [graphics_lib.get('inc_dirs'), include_directories('.')],
26+
'compile_args' : [graphics_lib.get('compile_args'),
27+
'-DOOPETRIS_LIBRARY_GRAPHICS_TYPE='+
28+
(get_option('default_library') == 'static' ? '1' : '0')]
2629
}
2730

2831
liboopetris_graphics = library(

0 commit comments

Comments
 (0)