From 04d1cb635e671aee93400a61c140082a9054533c Mon Sep 17 00:00:00 2001 From: "Totto16 (Windows VM)" Date: Tue, 15 Oct 2024 01:21:17 +0200 Subject: [PATCH] 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',