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 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 9b4270be..ac04f70e 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_TYPE) && OOPETRIS_LIBRARY_GRAPHICS_TYPE == 0 #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..23e1c660 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_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 diff --git a/src/libs/core/helper/windows.hpp b/src/libs/core/helper/windows.hpp index dc59ff01..6929e7a6 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_TYPE) && OOPETRIS_LIBRARY_CORE_TYPE == 0 #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..9dd183fb 100644 --- a/src/libs/core/meson.build +++ b/src/libs/core/meson.build @@ -7,6 +7,12 @@ 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, @@ -14,7 +20,7 @@ liboopetris_core = library( 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, diff --git a/src/libs/recordings/meson.build b/src/libs/recordings/meson.build index 46f1a44a..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( diff --git a/src/libs/recordings/utility/windows.hpp b/src/libs/recordings/utility/windows.hpp index 1ac7bb57..4d0d4a08 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_TYPE) && OOPETRIS_LIBRARY_RECORDINGS_TYPE == 0 #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..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( 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