@@ -90,6 +90,17 @@ mixin template GodotNativeLibrary(string symbolPrefix, Args...)
90
90
91
91
// / HACK: empty main to force the compiler to add emulated TLS.
92
92
version (Android ) void main() { }
93
+
94
+ // Windows DLL entry points handle TLS+DRuntime initialization and thread attachment
95
+ version (Windows )
96
+ {
97
+ version (D_BetterC ) {}
98
+ else
99
+ {
100
+ import core.sys.windows.dll : SimpleDllMain;
101
+ mixin SimpleDllMain;
102
+ }
103
+ }
93
104
94
105
pragma (mangle, symbolPrefix~ " gdnative_init" )
95
106
export extern (C) static void godot_gdnative_init(godot.c.godot_gdnative_init_options* options)
@@ -100,9 +111,13 @@ mixin template GodotNativeLibrary(string symbolPrefix, Args...)
100
111
import core.runtime : Runtime ;
101
112
import godot.d.output;
102
113
import godot.d.traits;
103
- version (D_BetterC ) enum bool loadDRuntime = staticIndexOf! (LoadDRuntime.yes, Args) != - 1 ;
104
- else enum bool loadDRuntime = staticIndexOf! (LoadDRuntime.no, Args) == - 1 ;
105
- static if (loadDRuntime) Runtime .initialize();
114
+ version (Windows ) {}
115
+ else
116
+ {
117
+ version (D_BetterC ) enum bool loadDRuntime = staticIndexOf! (LoadDRuntime.yes, Args) != - 1 ;
118
+ else enum bool loadDRuntime = staticIndexOf! (LoadDRuntime.no, Args) == - 1 ;
119
+ static if (loadDRuntime) Runtime .initialize();
120
+ }
106
121
107
122
godot_gdnative_api_struct_init(options.api_struct);
108
123
@@ -208,10 +223,14 @@ mixin template GodotNativeLibrary(string symbolPrefix, Args...)
208
223
209
224
_GODOT_library.unref();
210
225
211
- import core.runtime : Runtime ;
212
- version (D_BetterC ) enum bool loadDRuntime = staticIndexOf! (LoadDRuntime.yes, Args) != - 1 ;
213
- else enum bool loadDRuntime = staticIndexOf! (LoadDRuntime.no, Args) == - 1 ;
214
- static if (loadDRuntime) Runtime .terminate();
226
+ version (Windows ) {}
227
+ else
228
+ {
229
+ import core.runtime : Runtime ;
230
+ version (D_BetterC ) enum bool loadDRuntime = staticIndexOf! (LoadDRuntime.yes, Args) != - 1 ;
231
+ else enum bool loadDRuntime = staticIndexOf! (LoadDRuntime.no, Args) == - 1 ;
232
+ static if (loadDRuntime) Runtime .terminate();
233
+ }
215
234
}
216
235
}
217
236
0 commit comments