From 6adb4e7b8b83ee6889ed25513c9d8d49b1bec140 Mon Sep 17 00:00:00 2001 From: Tau Date: Fri, 23 Nov 2018 18:24:41 -0500 Subject: [PATCH] Make project buildable by MSVC --- meson.build | 26 +++++++++++++++++--------- nu/ds.c | 11 +++++++++++ nu/eeprom.c | 8 ++++++++ nu/jvs.c | 4 ++++ nu/sram.c | 8 ++++++++ precompiled.h | 16 +++++++++++++++- 6 files changed, 63 insertions(+), 10 deletions(-) diff --git a/meson.build b/meson.build index 8862c58..3852044 100644 --- a/meson.build +++ b/meson.build @@ -1,19 +1,27 @@ project('segatools', 'c', version: '0.1.0') add_project_arguments( - '-Wall', '-DCOBJMACROS', - '-ffunction-sections', - '-fdata-sections', + '-DWIN32_LEAN_AND_MEAN', language: 'c', ) -add_project_link_arguments( - '-Wl,--exclude-all-symbols', - '-Wl,--gc-sections', - '-static-libgcc', - language: 'c', -) +# Use get_argument_syntax() instead once Meson 0.49.0 releases +if meson.get_compiler('c').get_id() != 'msvc' + add_project_arguments( + '-Wall', + '-ffunction-sections', + '-fdata-sections', + language: 'c', + ) + + add_project_link_arguments( + '-Wl,--exclude-all-symbols', + '-Wl,--gc-sections', + '-static-libgcc', + language: 'c', + ) +endif inc = include_directories('.') capnhook = subproject('capnhook') diff --git a/nu/ds.c b/nu/ds.c index e81ddff..d62dc6b 100644 --- a/nu/ds.c +++ b/nu/ds.c @@ -1,4 +1,15 @@ +#define WIN32_NO_STATUS #include +#undef WIN32_NO_STATUS +#include + +#ifdef __GNUC__ +#include +#else +#include +#endif +#include +#include #include #include diff --git a/nu/eeprom.c b/nu/eeprom.c index 7e2482a..80971b1 100644 --- a/nu/eeprom.c +++ b/nu/eeprom.c @@ -1,5 +1,13 @@ #include +#ifdef __GNUC__ +#include +#else +#include +#endif +#include +#include + #include #include "hook/iohook.h" diff --git a/nu/jvs.c b/nu/jvs.c index e86130e..31a4b59 100644 --- a/nu/jvs.c +++ b/nu/jvs.c @@ -1,4 +1,8 @@ +#define WIN32_NO_STATUS #include +#undef WIN32_NO_STATUS +#include + #include #include diff --git a/nu/sram.c b/nu/sram.c index 16f7bf2..9da5152 100644 --- a/nu/sram.c +++ b/nu/sram.c @@ -1,5 +1,13 @@ #include +#ifdef __GNUC__ +#include +#else +#include +#endif +#include +#include + #include #include "hook/iohook.h" diff --git a/precompiled.h b/precompiled.h index a70c430..be2fcf5 100644 --- a/precompiled.h +++ b/precompiled.h @@ -1,15 +1,29 @@ +/* + Making NTSTATUS available is slightly awkward. See: + https://kirkshoop.github.io/2011/09/20/ntstatus.html +*/ + /* Win32 user-mode API */ +#define WIN32_NO_STATUS #include +#undef WIN32_NO_STATUS #include #include #include #include /* Win32 kernel-mode definitions */ +#ifdef __GNUC__ +/* MinGW needs to include this for PHYSICAL_ADDRESS to be defined. + The MS SDK throws a bunch of duplicate symbol errors instead. */ #include -#include +#else +#include +#endif #include +#include #include +#include #include #include