From ee3e587ddcceaa639a407bbe0aa4e0b56b7b476b Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sat, 4 May 2019 21:47:04 -0400 Subject: [PATCH] Fixed build errors on Windows. --- test/initmain.c | 2 -- test/lib/meson.build | 10 +--------- test/lib/testing.c | 16 ++++++++++++++-- test/meson.build | 12 ++++++++++++ 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/test/initmain.c b/test/initmain.c index 1d6878fa..4a44b0e7 100644 --- a/test/initmain.c +++ b/test/initmain.c @@ -4,8 +4,6 @@ #include "lib/thread.h" #include "test.h" -// TODO fix up the formatting of testing.c so we can use newlines on the got/want stuff - #define errInvalidOptions "options parameter to uiInit() must be NULL" #define errAlreadyInitialized "libui already initialized" diff --git a/test/lib/meson.build b/test/lib/meson.build index afa6926c..403922db 100644 --- a/test/lib/meson.build +++ b/test/lib/meson.build @@ -22,15 +22,7 @@ libui_test_deps += [ required: true), ] if libui_OS == 'windows' - libui_test_manifest = 'test.manifest' - if libui_mode == 'static' - libui_test_manifest = 'test.static.manifest' - endif - libui_test_sources += [ - windows.compile_resources('resources.rc', - args: libui_manifest_args, - depend_files: [libui_test_manifest]), - ] + # static mode already gives us these dependencies if libui_mode != 'static' libui_test_deps += [ meson.get_compiler('c').find_library('kernel32', diff --git a/test/lib/testing.c b/test/lib/testing.c index acd7a7dc..ef3e3c31 100644 --- a/test/lib/testing.c +++ b/test/lib/testing.c @@ -1,4 +1,8 @@ // 27 february 2018 +// TODO get rid of the need for this (it temporarily silences noise so I can find actual build issues) +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif #include #include #include @@ -6,6 +10,14 @@ #include "timer.h" #include "testing.h" +// goddamnit VS2013 +#ifdef _MSC_VER +#define testingprivSnprintf _snprintf +#else +#define testingprivSnprint snprintf +#endif +// and yes, vsnprintf() IS properly provided, so wtf + void testingprivInternalError(const char *fmt, ...) { va_list ap; @@ -297,14 +309,14 @@ void testingprivTLogvfFull(testingT *t, const char *file, long line, const char int n, n2; // TODO extract filename from file - n = snprintf(NULL, 0, "%s:%ld: ", file, line); + n = testingprivSnprintf(NULL, 0, "%s:%ld: ", file, line); // TODO handle n < 0 case va_copy(ap2, ap); n2 = vsnprintf(NULL, 0, format, ap2); // TODO handle n2 < 0 case va_end(ap2); buf = testingprivNewArray(char, n + n2 + 1); - snprintf(buf, n + 1, "%s:%ld: ", file, line); + testingprivSnprintf(buf, n + 1, "%s:%ld: ", file, line); vsnprintf(buf + n, n2 + 1, format, ap); printfIndented(t->indent, "%s", buf); testingprivFree(buf); diff --git a/test/meson.build b/test/meson.build index 6fc094cf..28cb8033 100644 --- a/test/meson.build +++ b/test/meson.build @@ -5,6 +5,18 @@ libui_test_sources = [ 'main.c', ] +if libui_OS == 'windows' + libui_test_manifest = 'test.manifest' + if libui_mode == 'static' + libui_test_manifest = 'test.static.manifest' + endif + libui_test_sources += [ + windows.compile_resources('resources.rc', + args: libui_manifest_args, + depend_files: [libui_test_manifest]), + ] +endif + libui_test_deps = [] subdir('lib')