Skip to content

Commit 92c584b

Browse files
committed
fix various issues
1 parent 83c80cf commit 92c584b

19 files changed

+25793
-26
lines changed

examples/minimal/src/minimal.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ else
1616
pub const panic = if (builtin.abi.isAndroid())
1717
android.panic
1818
else
19-
std.builtin.default_panic;
19+
std.debug.FullPanic(std.debug.defaultPanic);
2020

2121
fn nativeActivityOnCreate(activity: *androidbind.ANativeActivity, savedState: []const u8) !void {
2222
const sdk_version: c_int = blk: {

examples/sdl2/build.zig

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ pub fn build(b: *std.Build) void {
77
const optimize = b.standardOptimizeOption(.{});
88
const android_targets = android.standardTargets(b, root_target);
99

10+
const library_optimize = if (android_targets.len == 0)
11+
optimize
12+
else
13+
// For Android builds, make sure we build libraries with ReleaseSafe
14+
// otherwise we get errors relating to libubsan_rt.a getting RELOCATION errors
15+
// https://github.com/silbinarywolf/zig-android-sdk/issues/18
16+
if (optimize == .Debug) .ReleaseSafe else optimize;
17+
1018
var root_target_single = [_]std.Build.ResolvedTarget{root_target};
1119
const targets: []std.Build.ResolvedTarget = if (android_targets.len == 0)
1220
root_target_single[0..]
@@ -44,7 +52,7 @@ pub fn build(b: *std.Build) void {
4452

4553
// Add SDL2's Java files like SDL.java, SDLActivity.java, HIDDevice.java, etc
4654
const sdl_dep = b.dependency("sdl2", .{
47-
.optimize = .ReleaseFast,
55+
.optimize = library_optimize,
4856
.target = android_targets[0],
4957
});
5058
const sdl_java_files = sdl_dep.namedWriteFiles("sdljava");
@@ -71,7 +79,7 @@ pub fn build(b: *std.Build) void {
7179
// add SDL2
7280
{
7381
const sdl_dep = b.dependency("sdl2", .{
74-
.optimize = .ReleaseFast,
82+
.optimize = library_optimize,
7583
.target = target,
7684
});
7785
if (target.result.os.tag == .linux and !target.result.abi.isAndroid()) {

examples/sdl2/src/sdl-zig-demo.zig

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,20 @@ else
1818
pub const panic = if (builtin.abi.isAndroid())
1919
android.panic
2020
else
21-
std.builtin.default_panic;
21+
std.debug.FullPanic(std.debug.defaultPanic);
2222

23-
/// This needs to be exported for Android builds
24-
export fn SDL_main() callconv(.C) void {
23+
comptime {
2524
if (builtin.abi.isAndroid()) {
25+
@export(&SDL_main, .{ .name = "SDL_main", .linkage = .strong });
26+
}
27+
}
28+
29+
/// This needs to be exported for Android builds
30+
fn SDL_main() callconv(.C) void {
31+
if (comptime builtin.abi.isAndroid()) {
2632
_ = std.start.callMain();
2733
} else {
28-
@panic("SDL_main should not be called outside of Android builds");
34+
@compileError("SDL_main should not be called outside of Android builds");
2935
}
3036
}
3137

examples/sdl2/third-party/sdl2/build.zig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ pub fn build(b: *std.Build) !void {
3131
var sdl_config_header: ?*std.Build.Step.ConfigHeader = null;
3232
switch (target.result.os.tag) {
3333
.windows => {
34+
// Between Zig 0.13.0 and Zig 0.14.0, "windows.gaming.input.h" was removed from "lib/libc/include/any-windows-any"
35+
// This folder brings all headers needed by that one file so that SDL can be compiled for Windows.
36+
lib.addIncludePath(b.path("upstream/any-windows-any"));
37+
3438
lib.addCSourceFiles(.{
3539
.root = sdl_path,
3640
.files = &windows_src_files,
@@ -114,7 +118,7 @@ pub fn build(b: *std.Build) !void {
114118
// _ = std.start.callMain();
115119
// }
116120
// comptime {
117-
// if (builtin.abi == .android) @export(android_sdl_main, .{ .name = "SDL_main", .linkage = .strong });
121+
// if (builtin.abi.isAndroid()) @export(&android_sdl_main, .{ .name = "SDL_main", .linkage = .strong });
118122
// }
119123

120124
const hidapi_lib = b.addStaticLibrary(.{
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Between Zig 0.13.0 and Zig 0.14.0, "windows.gaming.input.h" was removed from "lib/libc/include/any-windows-any"
2+
// This folder brings all headers needed by that one file so that SDL can be compiled for Windows.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*** Autogenerated by WIDL 8.21 from include/eventtoken.idl - Do not edit ***/
2+
3+
#ifdef _WIN32
4+
#ifndef __REQUIRED_RPCNDR_H_VERSION__
5+
#define __REQUIRED_RPCNDR_H_VERSION__ 475
6+
#endif
7+
#include <rpc.h>
8+
#include <rpcndr.h>
9+
#endif
10+
11+
#ifndef COM_NO_WINDOWS_H
12+
#include <windows.h>
13+
#include <ole2.h>
14+
#endif
15+
16+
#ifndef __eventtoken_h__
17+
#define __eventtoken_h__
18+
19+
#ifndef __WIDL_INLINE
20+
#if defined(__cplusplus) || defined(_MSC_VER)
21+
#define __WIDL_INLINE inline
22+
#elif defined(__GNUC__)
23+
#define __WIDL_INLINE __inline__
24+
#endif
25+
#endif
26+
27+
/* Forward declarations */
28+
29+
/* Headers for imported files */
30+
31+
32+
#ifdef __cplusplus
33+
extern "C" {
34+
#endif
35+
36+
struct EventRegistrationToken {
37+
INT64 value;
38+
};
39+
typedef struct EventRegistrationToken EventRegistrationToken;
40+
/* Begin additional prototypes for all interfaces */
41+
42+
43+
/* End additional prototypes */
44+
45+
#ifdef __cplusplus
46+
}
47+
#endif
48+
49+
#endif /* __eventtoken_h__ */
Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
/*** Autogenerated by WIDL 8.21 from include/ivectorchangedeventargs.idl - Do not edit ***/
2+
3+
#ifdef _WIN32
4+
#ifndef __REQUIRED_RPCNDR_H_VERSION__
5+
#define __REQUIRED_RPCNDR_H_VERSION__ 475
6+
#endif
7+
#include <rpc.h>
8+
#include <rpcndr.h>
9+
#endif
10+
11+
#ifndef COM_NO_WINDOWS_H
12+
#include <windows.h>
13+
#include <ole2.h>
14+
#endif
15+
16+
#ifndef __ivectorchangedeventargs_h__
17+
#define __ivectorchangedeventargs_h__
18+
19+
#ifndef __WIDL_INLINE
20+
#if defined(__cplusplus) || defined(_MSC_VER)
21+
#define __WIDL_INLINE inline
22+
#elif defined(__GNUC__)
23+
#define __WIDL_INLINE __inline__
24+
#endif
25+
#endif
26+
27+
/* Forward declarations */
28+
29+
#ifndef ____x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs_FWD_DEFINED__
30+
#define ____x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs_FWD_DEFINED__
31+
typedef interface __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs;
32+
#ifdef __cplusplus
33+
#define __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs ABI::Windows::Foundation::Collections::IVectorChangedEventArgs
34+
namespace ABI {
35+
namespace Windows {
36+
namespace Foundation {
37+
namespace Collections {
38+
interface IVectorChangedEventArgs;
39+
}
40+
}
41+
}
42+
}
43+
#endif /* __cplusplus */
44+
#endif
45+
46+
/* Headers for imported files */
47+
48+
#include <inspectable.h>
49+
#include <windowscontracts.h>
50+
51+
#ifdef __cplusplus
52+
extern "C" {
53+
#endif
54+
55+
#if WINDOWS_FOUNDATION_FOUNDATIONCONTRACT_VERSION >= 0x10000
56+
#ifdef __cplusplus
57+
} /* extern "C" */
58+
namespace ABI {
59+
namespace Windows {
60+
namespace Foundation {
61+
namespace Collections {
62+
enum CollectionChange {
63+
CollectionChange_Reset = 0,
64+
CollectionChange_ItemInserted = 1,
65+
CollectionChange_ItemRemoved = 2,
66+
CollectionChange_ItemChanged = 3
67+
};
68+
}
69+
}
70+
}
71+
}
72+
extern "C" {
73+
#else
74+
enum __x_ABI_CWindows_CFoundation_CCollections_CCollectionChange {
75+
CollectionChange_Reset = 0,
76+
CollectionChange_ItemInserted = 1,
77+
CollectionChange_ItemRemoved = 2,
78+
CollectionChange_ItemChanged = 3
79+
};
80+
#ifdef WIDL_using_Windows_Foundation_Collections
81+
#define CollectionChange __x_ABI_CWindows_CFoundation_CCollections_CCollectionChange
82+
#endif /* WIDL_using_Windows_Foundation_Collections */
83+
#endif
84+
85+
#endif /* WINDOWS_FOUNDATION_FOUNDATIONCONTRACT_VERSION >= 0x10000 */
86+
#ifndef __cplusplus
87+
typedef enum __x_ABI_CWindows_CFoundation_CCollections_CCollectionChange __x_ABI_CWindows_CFoundation_CCollections_CCollectionChange;
88+
#endif /* __cplusplus */
89+
90+
/*****************************************************************************
91+
* IVectorChangedEventArgs interface
92+
*/
93+
#if WINDOWS_FOUNDATION_FOUNDATIONCONTRACT_VERSION >= 0x10000
94+
#ifndef ____x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs_INTERFACE_DEFINED__
95+
#define ____x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs_INTERFACE_DEFINED__
96+
97+
DEFINE_GUID(IID___x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs, 0x575933df, 0x34fe, 0x4480, 0xaf,0x15, 0x07,0x69,0x1f,0x3d,0x5d,0x9b);
98+
#if defined(__cplusplus) && !defined(CINTERFACE)
99+
} /* extern "C" */
100+
namespace ABI {
101+
namespace Windows {
102+
namespace Foundation {
103+
namespace Collections {
104+
MIDL_INTERFACE("575933df-34fe-4480-af15-07691f3d5d9b")
105+
IVectorChangedEventArgs : public IInspectable
106+
{
107+
virtual HRESULT STDMETHODCALLTYPE get_CollectionChange(
108+
enum CollectionChange *value) = 0;
109+
110+
virtual HRESULT STDMETHODCALLTYPE get_Index(
111+
unsigned int *value) = 0;
112+
113+
};
114+
}
115+
}
116+
}
117+
}
118+
extern "C" {
119+
#ifdef __CRT_UUID_DECL
120+
__CRT_UUID_DECL(__x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs, 0x575933df, 0x34fe, 0x4480, 0xaf,0x15, 0x07,0x69,0x1f,0x3d,0x5d,0x9b)
121+
#endif
122+
#else
123+
typedef struct __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgsVtbl {
124+
BEGIN_INTERFACE
125+
126+
/*** IUnknown methods ***/
127+
HRESULT (STDMETHODCALLTYPE *QueryInterface)(
128+
__x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs *This,
129+
REFIID riid,
130+
void **ppvObject);
131+
132+
ULONG (STDMETHODCALLTYPE *AddRef)(
133+
__x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs *This);
134+
135+
ULONG (STDMETHODCALLTYPE *Release)(
136+
__x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs *This);
137+
138+
/*** IInspectable methods ***/
139+
HRESULT (STDMETHODCALLTYPE *GetIids)(
140+
__x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs *This,
141+
ULONG *iidCount,
142+
IID **iids);
143+
144+
HRESULT (STDMETHODCALLTYPE *GetRuntimeClassName)(
145+
__x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs *This,
146+
HSTRING *className);
147+
148+
HRESULT (STDMETHODCALLTYPE *GetTrustLevel)(
149+
__x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs *This,
150+
TrustLevel *trustLevel);
151+
152+
/*** IVectorChangedEventArgs methods ***/
153+
HRESULT (STDMETHODCALLTYPE *get_CollectionChange)(
154+
__x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs *This,
155+
enum __x_ABI_CWindows_CFoundation_CCollections_CCollectionChange *value);
156+
157+
HRESULT (STDMETHODCALLTYPE *get_Index)(
158+
__x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs *This,
159+
unsigned int *value);
160+
161+
END_INTERFACE
162+
} __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgsVtbl;
163+
164+
interface __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs {
165+
CONST_VTBL __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgsVtbl* lpVtbl;
166+
};
167+
168+
#ifdef COBJMACROS
169+
#ifndef WIDL_C_INLINE_WRAPPERS
170+
/*** IUnknown methods ***/
171+
#define __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs_QueryInterface(This,riid,ppvObject) (This)->lpVtbl->QueryInterface(This,riid,ppvObject)
172+
#define __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs_AddRef(This) (This)->lpVtbl->AddRef(This)
173+
#define __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs_Release(This) (This)->lpVtbl->Release(This)
174+
/*** IInspectable methods ***/
175+
#define __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs_GetIids(This,iidCount,iids) (This)->lpVtbl->GetIids(This,iidCount,iids)
176+
#define __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs_GetRuntimeClassName(This,className) (This)->lpVtbl->GetRuntimeClassName(This,className)
177+
#define __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs_GetTrustLevel(This,trustLevel) (This)->lpVtbl->GetTrustLevel(This,trustLevel)
178+
/*** IVectorChangedEventArgs methods ***/
179+
#define __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs_get_CollectionChange(This,value) (This)->lpVtbl->get_CollectionChange(This,value)
180+
#define __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs_get_Index(This,value) (This)->lpVtbl->get_Index(This,value)
181+
#else
182+
/*** IUnknown methods ***/
183+
static __WIDL_INLINE HRESULT __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs_QueryInterface(__x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs* This,REFIID riid,void **ppvObject) {
184+
return This->lpVtbl->QueryInterface(This,riid,ppvObject);
185+
}
186+
static __WIDL_INLINE ULONG __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs_AddRef(__x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs* This) {
187+
return This->lpVtbl->AddRef(This);
188+
}
189+
static __WIDL_INLINE ULONG __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs_Release(__x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs* This) {
190+
return This->lpVtbl->Release(This);
191+
}
192+
/*** IInspectable methods ***/
193+
static __WIDL_INLINE HRESULT __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs_GetIids(__x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs* This,ULONG *iidCount,IID **iids) {
194+
return This->lpVtbl->GetIids(This,iidCount,iids);
195+
}
196+
static __WIDL_INLINE HRESULT __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs_GetRuntimeClassName(__x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs* This,HSTRING *className) {
197+
return This->lpVtbl->GetRuntimeClassName(This,className);
198+
}
199+
static __WIDL_INLINE HRESULT __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs_GetTrustLevel(__x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs* This,TrustLevel *trustLevel) {
200+
return This->lpVtbl->GetTrustLevel(This,trustLevel);
201+
}
202+
/*** IVectorChangedEventArgs methods ***/
203+
static __WIDL_INLINE HRESULT __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs_get_CollectionChange(__x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs* This,enum __x_ABI_CWindows_CFoundation_CCollections_CCollectionChange *value) {
204+
return This->lpVtbl->get_CollectionChange(This,value);
205+
}
206+
static __WIDL_INLINE HRESULT __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs_get_Index(__x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs* This,unsigned int *value) {
207+
return This->lpVtbl->get_Index(This,value);
208+
}
209+
#endif
210+
#ifdef WIDL_using_Windows_Foundation_Collections
211+
#define IID_IVectorChangedEventArgs IID___x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs
212+
#define IVectorChangedEventArgsVtbl __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgsVtbl
213+
#define IVectorChangedEventArgs __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs
214+
#define IVectorChangedEventArgs_QueryInterface __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs_QueryInterface
215+
#define IVectorChangedEventArgs_AddRef __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs_AddRef
216+
#define IVectorChangedEventArgs_Release __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs_Release
217+
#define IVectorChangedEventArgs_GetIids __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs_GetIids
218+
#define IVectorChangedEventArgs_GetRuntimeClassName __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs_GetRuntimeClassName
219+
#define IVectorChangedEventArgs_GetTrustLevel __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs_GetTrustLevel
220+
#define IVectorChangedEventArgs_get_CollectionChange __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs_get_CollectionChange
221+
#define IVectorChangedEventArgs_get_Index __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs_get_Index
222+
#endif /* WIDL_using_Windows_Foundation_Collections */
223+
#endif
224+
225+
#endif
226+
227+
#endif /* ____x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs_INTERFACE_DEFINED__ */
228+
#endif /* WINDOWS_FOUNDATION_FOUNDATIONCONTRACT_VERSION >= 0x10000 */
229+
230+
/* Begin additional prototypes for all interfaces */
231+
232+
233+
/* End additional prototypes */
234+
235+
#ifdef __cplusplus
236+
}
237+
#endif
238+
239+
#endif /* __ivectorchangedeventargs_h__ */

0 commit comments

Comments
 (0)