Skip to content

Commit 7591868

Browse files
committed
stop defining geode platform macros in 4 different places
1 parent e7f8238 commit 7591868

File tree

8 files changed

+23
-215
lines changed

8 files changed

+23
-215
lines changed

loader/include/Geode/meta/meta.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "callconv.hpp"
55
#include "common.hpp"
66
#include "function.hpp"
7-
#include "preproc.hpp"
7+
#include "../platform/platform.hpp"
88
#include "defaultconv.hpp"
99

1010
namespace geode::core::meta {}

loader/include/Geode/meta/preproc.hpp

Lines changed: 0 additions & 73 deletions
This file was deleted.
Lines changed: 16 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
#pragma once
22

33
#include <functional>
4-
5-
#if defined(GEODE_CALL)
6-
#undef GEODE_CALL
7-
#endif
4+
#include "cplatform.h"
85

96
namespace geode {
107
class PlatformID {
@@ -70,20 +67,13 @@ namespace std {
7067
#endif
7168

7269
// Windows
73-
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
70+
#ifdef GEODE_IS_WINDOWS
7471

75-
#define GEODE_WINDOWS(...) __VA_ARGS__
76-
#define GEODE_IS_WINDOWS
77-
#define GEODE_IS_DESKTOP
78-
#define GEODE_PLATFORM_NAME "Windows"
7972
#define GEODE_PLATFORM_TARGET PlatformID::Windows
80-
#define GEODE_CALL __stdcall
8173
#define GEODE_HIDDEN
8274
#define GEODE_DUPABLE __forceinline
8375
#define GEODE_VIRTUAL_CONSTEXPR
8476
#define GEODE_NOINLINE __declspec(noinline)
85-
#define GEODE_PLATFORM_EXTENSION ".dll"
86-
#define GEODE_PLATFORM_SHORT_IDENTIFIER "win"
8777

8878
#ifdef GEODE_EXPORTING
8979
#define GEODE_DLL __declspec(dllexport)
@@ -96,89 +86,51 @@ namespace std {
9686

9787
#include "windows.hpp"
9888

99-
#else
100-
#define GEODE_WINDOWS(...)
101-
#endif
89+
#elif defined(GEODE_IS_MACOS)
10290

103-
// MacOS / iOS
104-
#if defined(__APPLE__)
105-
#include <TargetConditionals.h>
106-
107-
#if TARGET_OS_IPHONE
108-
#define GEODE_MACOS(...)
109-
110-
#define GEODE_IOS(...) __VA_ARGS__
111-
#define GEODE_IS_IOS
112-
#define GEODE_IS_MOBILE
113-
#define GEODE_PLATFORM_NAME "iOS"
114-
#define GEODE_PLATFORM_TARGET PlatformID::iOS
115-
#define GEODE_CALL
91+
#define GEODE_PLATFORM_TARGET PlatformID::MacOS
11692
#define GEODE_HIDDEN __attribute__((visibility("hidden")))
11793
#define GEODE_DUPABLE __attribute__((always_inline))
11894
#define GEODE_VIRTUAL_CONSTEXPR constexpr
11995
#define GEODE_NOINLINE __attribute__((noinline))
120-
#define GEODE_PLATFORM_EXTENSION ".ios.dylib"
121-
#define GEODE_PLATFORM_SHORT_IDENTIFIER "ios"
12296

12397
#ifdef GEODE_EXPORTING
12498
#define GEODE_DLL __attribute__((visibility("default")))
12599
#else
126-
#define GEODE_DLL
100+
#define GEODE_DLL
127101
#endif
128102

129103
#define GEODE_API extern "C" __attribute__((visibility("default")))
130104
#define GEODE_EXPORT __attribute__((visibility("default")))
131105

132-
#include "ios.hpp"
106+
#include "macos.hpp"
133107

134-
#else
135-
#define GEODE_IOS(...)
108+
#elif defined(GEODE_IS_IOS)
136109

137-
#define GEODE_MACOS(...) __VA_ARGS__
138-
#define GEODE_IS_MACOS
139-
#define GEODE_IS_DESKTOP
140-
#define GEODE_PLATFORM_NAME "MacOS"
141-
#define GEODE_PLATFORM_TARGET PlatformID::MacOS
142-
#define GEODE_CALL
110+
#define GEODE_PLATFORM_TARGET PlatformID::iOS
143111
#define GEODE_HIDDEN __attribute__((visibility("hidden")))
144112
#define GEODE_DUPABLE __attribute__((always_inline))
145113
#define GEODE_VIRTUAL_CONSTEXPR constexpr
146114
#define GEODE_NOINLINE __attribute__((noinline))
147-
#define GEODE_PLATFORM_EXTENSION ".dylib"
148-
#define GEODE_PLATFORM_SHORT_IDENTIFIER "mac"
149115

150116
#ifdef GEODE_EXPORTING
151-
#define GEODE_DLL __attribute__((visibility("default")))
117+
#define GEODE_DLL __attribute__((visibility("default")))
152118
#else
153-
#define GEODE_DLL
119+
#define GEODE_DLL
154120
#endif
155121

156122
#define GEODE_API extern "C" __attribute__((visibility("default")))
157123
#define GEODE_EXPORT __attribute__((visibility("default")))
158124

159-
#include "macos.hpp"
160-
#endif
161-
162-
#else
163-
#define GEODE_IOS(...)
164-
#define GEODE_MACOS(...)
165-
166-
#endif
125+
#include "ios.hpp"
126+
127+
#elif defined(GEODE_IS_ANDROID)
167128

168-
// Android
169-
#if defined(__ANDROID__)
170-
#define GEODE_ANDROID(...) __VA_ARGS__
171-
#define GEODE_IS_ANDROID
172-
#define GEODE_IS_MOBILE
173-
#define GEODE_PLATFORM_NAME "Android"
174129
#define GEODE_PLATFORM_TARGET PlatformID::Android
175-
#define GEODE_CALL
176130
#define GEODE_HIDDEN __attribute__((visibility("hidden")))
177131
#define GEODE_DUPABLE __attribute__((always_inline))
178132
#define GEODE_VIRTUAL_CONSTEXPR constexpr
179133
#define GEODE_NOINLINE __attribute__((noinline))
180-
#define GEODE_PLATFORM_EXTENSION ".so"
181-
#define GEODE_PLATFORM_SHORT_IDENTIFIER "android"
182134

183135
#ifdef GEODE_EXPORTING
184136
#define GEODE_DLL __attribute__((visibility("default")))
@@ -189,12 +141,10 @@ namespace std {
189141
#define GEODE_API extern "C" __attribute__((visibility("default")))
190142
#define GEODE_EXPORT __attribute__((visibility("default")))
191143

192-
#include "windows.hpp"
144+
#include "android.hpp"
193145

194146
#else
195-
#define GEODE_ANDROID(...)
196-
#endif
197147

198-
#ifndef GEODE_PLATFORM_NAME
199-
#error "Unsupported PlatformID!"
148+
#error "Unsupported Platform!"
149+
200150
#endif

loader/lilac/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
1111
add_subdirectory("test")
1212
endif()
1313

14+
message(STATUS ${GEODE_LOADER_PATH}/include)
15+
1416
target_include_directories(
1517
lilac_hook INTERFACE
1618
${lilac_SOURCE_DIR}/include/geode
1719
${lilac_SOURCE_DIR}/include/geode/core
1820
${lilac_SOURCE_DIR}/include/geode/core/hook
21+
${GEODE_LOADER_PATH}/include
1922
)

loader/lilac/include/geode/core/hook/hook.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef GEODE_CORE_HOOK_HPP
22
#define GEODE_CORE_HOOK_HPP
33

4-
#include "../meta/preproc.hpp"
4+
#include <Geode/platform/platform.hpp>
55

66
#include <cstddef>
77

loader/lilac/include/geode/core/meta/meta.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "common.hpp"
66
#include "function.hpp"
77
#include "hook.hpp"
8-
#include "preproc.hpp"
8+
#include <Geode/platform/platform.hpp>
99

1010
#if defined(LILAC_IS_WINDOWS)
1111
#include "cdecl.hpp"

loader/lilac/include/geode/core/meta/preproc.hpp

Lines changed: 0 additions & 73 deletions
This file was deleted.

loader/lilac/src/hook/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ target_compile_features(lilac_hook PUBLIC cxx_std_17)
3030
target_include_directories(lilac_hook
3131
PRIVATE
3232
${lilac_SOURCE_DIR}/include/geode/core/hook
33+
${GEODE_LOADER_PATH}/include
3334
INTERFACE
3435
$<BUILD_INTERFACE:${lilac_SOURCE_DIR}/include>
3536
$<BUILD_INTERFACE:${lilac_SOURCE_DIR}/include/geode>

0 commit comments

Comments
 (0)