From 92d5840e1440fe45a150079fab5a39877589c20f Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Sun, 25 May 2025 18:33:17 -0400 Subject: build: Improve Windows support Signed-off-by: Andrew Opalach --- include/al/lib.h | 2 +- include/al/log.h | 2 +- include/al/types.h | 11 ++++++----- meson.build | 5 +++-- meson_options.txt | 2 +- src/log.c | 1 + 6 files changed, 13 insertions(+), 10 deletions(-) diff --git a/include/al/lib.h b/include/al/lib.h index 60960cc..154474e 100644 --- a/include/al/lib.h +++ b/include/al/lib.h @@ -87,7 +87,7 @@ void al_malloc_stats(size_t *current, size_t *peak, size_t *total); #define al_snprintf snprintf #define al_vsnprintf vsnprintf #define al_fflush fflush -#ifdef _DEBUG_ +#ifdef AL_DEBUG #define al_assert assert #else #define al_assert(expr) do { (void)sizeof(expr); } while (0) // NOLINT(bugprone-sizeof-expression) diff --git a/include/al/log.h b/include/al/log.h index 91f87bb..f3c61b1 100644 --- a/include/al/log.h +++ b/include/al/log.h @@ -37,7 +37,7 @@ s32 _al_logv(u8 level, const char *section, const char *name, const s32 line, co #define log_info(fmt, ...) al_log(AL_LOG_INFO, AL_LOG_SECTION_NAME, fmt, ##__VA_ARGS__) #define log_warn(fmt, ...) al_log(AL_LOG_WARN, AL_LOG_SECTION_NAME, fmt, ##__VA_ARGS__) #define log_error(fmt, ...) al_log(AL_LOG_ERROR, AL_LOG_SECTION_NAME, fmt, ##__VA_ARGS__) -#ifdef _DEBUG_ +#ifdef AL_DEBUG #define log_debug(fmt, ...) al_log(AL_LOG_DEBUG, AL_LOG_SECTION_NAME, fmt, ##__VA_ARGS__) #else #define log_debug(fmt, ...) al_log_nop(AL_LOG_SECTION_NAME, fmt, ##__VA_ARGS__) diff --git a/include/al/types.h b/include/al/types.h index fc88077..2e2ebfe 100644 --- a/include/al/types.h +++ b/include/al/types.h @@ -19,6 +19,12 @@ #define _XOPEN_SOURCE 500 #endif +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#include +typedef SSIZE_T ssize_t; +#endif + #include #include #include @@ -43,9 +49,4 @@ typedef double f64; typedef unsigned long ulong; typedef unsigned char uchar; -#ifdef _MSC_VER -#include -typedef SSIZE_T ssize_t; -#endif - #endif // _AL_TYPES_H diff --git a/meson.build b/meson.build index 30b3532..3e8c70b 100644 --- a/meson.build +++ b/meson.build @@ -6,6 +6,7 @@ project('libalabaster', 'c', version: '0.01', compiler = meson.get_compiler('c') is_debug = get_option('debug') +is_msvc = compiler.get_id() == 'msvc' or compiler.get_id() == 'clang-cl' is_msvc_specifically = compiler.cmd_array()[0] == 'cl' supports_needed_gnu_extensions = not is_msvc_specifically @@ -24,7 +25,7 @@ have_wide_string_width = compiler.has_function('wcswidth') alabaster_args = ['-fstrict-aliasing', '-Wstrict-aliasing'] if is_debug - alabaster_args += ['-D_DEBUG_'] + alabaster_args += ['-DAL_DEBUG'] endif if is_msvc_specifically @@ -67,7 +68,7 @@ alabaster = declare_dependency(include_directories: alabaster_inc, dependencies: alabaster_deps, sources: alabaster_src, compile_args: alabaster_args) -if get_option('tests') and not meson.is_subproject() +if get_option('tests').auto() and not meson.is_subproject() tests_src = [ 'tests/main.c', 'tests/lib.c', diff --git a/meson_options.txt b/meson_options.txt index 39efa83..14a2c36 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1 +1 @@ -option('tests', type: 'boolean', value: false) +option('tests', type: 'feature', value: 'auto', yield: true) diff --git a/src/log.c b/src/log.c index 3c0466a..9d5781f 100644 --- a/src/log.c +++ b/src/log.c @@ -57,6 +57,7 @@ s32 _al_logv(u8 level, const char *section, const char *name, const s32 line, co } return ret; #else + al_assert(_al_print && "Global print method not set."); return _al_print(_al_log_userdata, level, get_message_buffer(level, section, name, line, func, fmt, args)); #endif } -- cgit v1.2.3-101-g0448