From 57ca8c8dc0ef174cca7741f39815f4e06e628c93 Mon Sep 17 00:00:00 2001 From: "Totto16 (Windows VM)" Date: Tue, 15 Oct 2024 00:58:49 +0200 Subject: [PATCH 1/3] ci: also add static build for windows --- .github/workflows/build.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4b4b12ad..951b1cf0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 @@ -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 From 0a1bb668e39e77796ce60d033d1ef3e9c4f4e837 Mon Sep 17 00:00:00 2001 From: "Totto16 (Windows VM)" Date: Tue, 15 Oct 2024 00:59:25 +0200 Subject: [PATCH 2/3] windows: fix static builds, by some define magic --- src/helper/windows.hpp | 4 ++++ src/libs/core/hash-library/sha256.h | 4 ++++ src/libs/core/helper/windows.hpp | 4 ++++ src/libs/core/meson.build | 2 +- src/libs/recordings/meson.build | 2 +- src/libs/recordings/utility/windows.hpp | 4 ++++ src/meson.build | 2 +- wrapper/javascript | 2 +- 8 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/helper/windows.hpp b/src/helper/windows.hpp index 9b4270be..dc11d6f2 100644 --- a/src/helper/windows.hpp +++ b/src/helper/windows.hpp @@ -1,6 +1,7 @@ #pragma once #if defined(_MSC_VER) +#if defined(OOPETRIS_LIBRARY_GRAPHICS_COMPILATION) #if defined(OOPETRIS_LIBRARY_GRAPHICS_EXPORT) #define OOPETRIS_GRAPHICS_EXPORTED __declspec(dllexport) #else @@ -9,3 +10,6 @@ #else #define OOPETRIS_GRAPHICS_EXPORTED #endif +#else +#define OOPETRIS_GRAPHICS_EXPORTED +#endif diff --git a/src/libs/core/hash-library/sha256.h b/src/libs/core/hash-library/sha256.h index 408361d5..585ffe66 100644 --- a/src/libs/core/hash-library/sha256.h +++ b/src/libs/core/hash-library/sha256.h @@ -18,11 +18,15 @@ typedef unsigned __int8 uint8_t; typedef unsigned __int32 uint32_t; typedef unsigned __int64 uint64_t; +#if defined(HASH_LIBRARY_COMPILATION) #if defined(HASH_LIBRARY_EXPORT) #define HASH_LIBRARY_EXPORTED __declspec(dllexport) #else #define HASH_LIBRARY_EXPORTED __declspec(dllimport) #endif +#else +#define HASH_LIBRARY_EXPORTED +#endif #else // GCC diff --git a/src/libs/core/helper/windows.hpp b/src/libs/core/helper/windows.hpp index dc59ff01..959b3c46 100644 --- a/src/libs/core/helper/windows.hpp +++ b/src/libs/core/helper/windows.hpp @@ -1,6 +1,7 @@ #pragma once #if defined(_MSC_VER) +#if defined(OOPETRIS_LIBRARY_CORE_COMPILATION) #if defined(OOPETRIS_LIBRARY_CORE_EXPORT) #define OOPETRIS_CORE_EXPORTED __declspec(dllexport) #else @@ -9,3 +10,6 @@ #else #define OOPETRIS_CORE_EXPORTED #endif +#else +#define OOPETRIS_CORE_EXPORTED +#endif diff --git a/src/libs/core/meson.build b/src/libs/core/meson.build index 2da91d76..bf8201e2 100644 --- a/src/libs/core/meson.build +++ b/src/libs/core/meson.build @@ -13,7 +13,7 @@ liboopetris_core = library( core_header_files, include_directories: core_lib.get('inc_dirs'), dependencies: core_lib.get('deps'), - cpp_args: core_lib.get('compile_args'), + cpp_args: [core_lib.get('compile_args'),'-DOOPETRIS_LIBRARY_CORE_COMPILATION','-DHASH_LIBRARY_COMPILATION'], cpp_shared_args: ['-DOOPETRIS_LIBRARY_CORE_EXPORT', '-DHASH_LIBRARY_EXPORT'], override_options: { 'warning_level': '3', diff --git a/src/libs/recordings/meson.build b/src/libs/recordings/meson.build index 46f1a44a..362ba181 100644 --- a/src/libs/recordings/meson.build +++ b/src/libs/recordings/meson.build @@ -16,7 +16,7 @@ liboopetris_recordings = library( recordings_header_files, include_directories: recordings_lib.get('inc_dirs'), dependencies: recordings_lib.get('deps'), - cpp_args: recordings_lib.get('compile_args'), + cpp_args: [recordings_lib.get('compile_args'),'-DOOPETRIS_LIBRARY_RECORDINGS_COMPILATION'], cpp_shared_args: ['-DOOPETRIS_LIBRARY_RECORDINGS_EXPORT'], override_options: { 'warning_level': '3', diff --git a/src/libs/recordings/utility/windows.hpp b/src/libs/recordings/utility/windows.hpp index 1ac7bb57..b2e6e941 100644 --- a/src/libs/recordings/utility/windows.hpp +++ b/src/libs/recordings/utility/windows.hpp @@ -1,6 +1,7 @@ #pragma once #if defined(_MSC_VER) +#if defined(OOPETRIS_LIBRARY_RECORDINGS_COMPILATION) #if defined(OOPETRIS_LIBRARY_RECORDINGS_EXPORT) #define OOPETRIS_RECORDINGS_EXPORTED __declspec(dllexport) #else @@ -9,3 +10,6 @@ #else #define OOPETRIS_RECORDINGS_EXPORTED #endif +#else +#define OOPETRIS_RECORDINGS_EXPORTED +#endif diff --git a/src/meson.build b/src/meson.build index 97c03e67..b474e88e 100644 --- a/src/meson.build +++ b/src/meson.build @@ -30,7 +30,7 @@ if build_application graphics_src_files, include_directories: graphics_lib.get('inc_dirs'), dependencies: graphics_lib.get('deps'), - cpp_args: graphics_lib.get('compile_args'), + cpp_args: [graphics_lib.get('compile_args'),'-DOOPETRIS_LIBRARY_GRAPHICS_COMPILATION'], cpp_shared_args: ['-DOOPETRIS_LIBRARY_GRAPHICS_EXPORT'], override_options: { 'warning_level': '3', diff --git a/wrapper/javascript b/wrapper/javascript index 0c0baa4b..c63c4762 160000 --- a/wrapper/javascript +++ b/wrapper/javascript @@ -1 +1 @@ -Subproject commit 0c0baa4b8da4644cdac1b1a975a7276a4392d5ec +Subproject commit c63c4762c9de8106c9c12bd380e968bcead262b2 From 04d1cb635e671aee93400a61c140082a9054533c Mon Sep 17 00:00:00 2001 From: "Totto16 (Windows VM)" Date: Tue, 15 Oct 2024 01:21:17 +0200 Subject: [PATCH 3/3] windows: fix define magic for static builds --- src/helper/graphic_utils.hpp | 17 ++++++++++++++++- src/helper/windows.hpp | 2 +- src/libs/core/hash-library/sha256.h | 4 ++-- src/libs/core/helper/windows.hpp | 2 +- src/libs/core/meson.build | 10 ++++++++-- src/libs/recordings/meson.build | 10 ++++++++-- src/libs/recordings/utility/windows.hpp | 2 +- src/meson.build | 5 ++++- 8 files changed, 41 insertions(+), 11 deletions(-) diff --git a/src/helper/graphic_utils.hpp b/src/helper/graphic_utils.hpp index e4a20f8f..0a32b835 100644 --- a/src/helper/graphic_utils.hpp +++ b/src/helper/graphic_utils.hpp @@ -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 diff --git a/src/helper/windows.hpp b/src/helper/windows.hpp index dc11d6f2..ac04f70e 100644 --- a/src/helper/windows.hpp +++ b/src/helper/windows.hpp @@ -1,7 +1,7 @@ #pragma once #if defined(_MSC_VER) -#if defined(OOPETRIS_LIBRARY_GRAPHICS_COMPILATION) +#if defined(OOPETRIS_LIBRARY_GRAPHICS_TYPE) && OOPETRIS_LIBRARY_GRAPHICS_TYPE == 0 #if defined(OOPETRIS_LIBRARY_GRAPHICS_EXPORT) #define OOPETRIS_GRAPHICS_EXPORTED __declspec(dllexport) #else diff --git a/src/libs/core/hash-library/sha256.h b/src/libs/core/hash-library/sha256.h index 585ffe66..23e1c660 100644 --- a/src/libs/core/hash-library/sha256.h +++ b/src/libs/core/hash-library/sha256.h @@ -18,8 +18,8 @@ typedef unsigned __int8 uint8_t; typedef unsigned __int32 uint32_t; typedef unsigned __int64 uint64_t; -#if defined(HASH_LIBRARY_COMPILATION) -#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) diff --git a/src/libs/core/helper/windows.hpp b/src/libs/core/helper/windows.hpp index 959b3c46..6929e7a6 100644 --- a/src/libs/core/helper/windows.hpp +++ b/src/libs/core/helper/windows.hpp @@ -1,7 +1,7 @@ #pragma once #if defined(_MSC_VER) -#if defined(OOPETRIS_LIBRARY_CORE_COMPILATION) +#if defined(OOPETRIS_LIBRARY_CORE_TYPE) && OOPETRIS_LIBRARY_CORE_TYPE == 0 #if defined(OOPETRIS_LIBRARY_CORE_EXPORT) #define OOPETRIS_CORE_EXPORTED __declspec(dllexport) #else diff --git a/src/libs/core/meson.build b/src/libs/core/meson.build index bf8201e2..9dd183fb 100644 --- a/src/libs/core/meson.build +++ b/src/libs/core/meson.build @@ -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'),'-DOOPETRIS_LIBRARY_CORE_COMPILATION','-DHASH_LIBRARY_COMPILATION'], - cpp_shared_args: ['-DOOPETRIS_LIBRARY_CORE_EXPORT', '-DHASH_LIBRARY_EXPORT'], + cpp_args: core_lib.get('compile_args'), + cpp_shared_args: ['-DOOPETRIS_LIBRARY_CORE_EXPORT'], override_options: { 'warning_level': '3', 'werror': true, diff --git a/src/libs/recordings/meson.build b/src/libs/recordings/meson.build index 362ba181..e091b1b4 100644 --- a/src/libs/recordings/meson.build +++ b/src/libs/recordings/meson.build @@ -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( @@ -16,7 +22,7 @@ liboopetris_recordings = library( recordings_header_files, include_directories: recordings_lib.get('inc_dirs'), dependencies: recordings_lib.get('deps'), - cpp_args: [recordings_lib.get('compile_args'),'-DOOPETRIS_LIBRARY_RECORDINGS_COMPILATION'], + cpp_args: recordings_lib.get('compile_args'), cpp_shared_args: ['-DOOPETRIS_LIBRARY_RECORDINGS_EXPORT'], override_options: { 'warning_level': '3', diff --git a/src/libs/recordings/utility/windows.hpp b/src/libs/recordings/utility/windows.hpp index b2e6e941..4d0d4a08 100644 --- a/src/libs/recordings/utility/windows.hpp +++ b/src/libs/recordings/utility/windows.hpp @@ -1,7 +1,7 @@ #pragma once #if defined(_MSC_VER) -#if defined(OOPETRIS_LIBRARY_RECORDINGS_COMPILATION) +#if defined(OOPETRIS_LIBRARY_RECORDINGS_TYPE) && OOPETRIS_LIBRARY_RECORDINGS_TYPE == 0 #if defined(OOPETRIS_LIBRARY_RECORDINGS_EXPORT) #define OOPETRIS_RECORDINGS_EXPORTED __declspec(dllexport) #else diff --git a/src/meson.build b/src/meson.build index b474e88e..d4598074 100644 --- a/src/meson.build +++ b/src/meson.build @@ -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( @@ -30,7 +33,7 @@ if build_application graphics_src_files, include_directories: graphics_lib.get('inc_dirs'), dependencies: graphics_lib.get('deps'), - cpp_args: [graphics_lib.get('compile_args'),'-DOOPETRIS_LIBRARY_GRAPHICS_COMPILATION'], + cpp_args: graphics_lib.get('compile_args'), cpp_shared_args: ['-DOOPETRIS_LIBRARY_GRAPHICS_EXPORT'], override_options: { 'warning_level': '3',