├── .gitattributes ├── .github └── workflows │ └── ci.yml ├── .gitignore ├── LICENSE ├── README.md ├── build.zig ├── build.zig.zon ├── examples ├── minimal │ ├── README.md │ ├── android │ │ ├── AndroidManifest.xml │ │ └── res │ │ │ ├── mipmap │ │ │ └── ic_launcher.png │ │ │ └── values │ │ │ └── strings.xml │ ├── build.zig │ ├── build.zig.zon │ └── src │ │ ├── android-bind.zig │ │ └── minimal.zig ├── raylib │ ├── README.md │ ├── android │ │ ├── AndroidManifest.xml │ │ └── res │ │ │ ├── mipmap │ │ │ └── ic_launcher.png │ │ │ └── values │ │ │ └── strings.xml │ ├── build.zig │ ├── build.zig.zon │ └── src │ │ └── main.zig └── sdl2 │ ├── README.md │ ├── android │ ├── AndroidManifest.xml │ ├── androidCrashTest │ │ └── ZigSDLActivity.java │ ├── res │ │ ├── mipmap │ │ │ └── ic_launcher.png │ │ └── values │ │ │ └── strings.xml │ └── src │ │ └── ZigSDLActivity.java │ ├── build.zig │ ├── build.zig.zon │ ├── src │ ├── sdl-zig-demo.zig │ └── zig.bmp │ └── third-party │ └── sdl2 │ ├── build.zig │ ├── build.zig.zon │ ├── src │ └── sdl.h │ └── upstream │ └── any-windows-any │ ├── README.txt │ ├── eventtoken.h │ ├── ivectorchangedeventargs.h │ ├── windows.devices.haptics.h │ ├── windows.devices.power.h │ ├── windows.foundation.collections.h │ ├── windows.foundation.h │ ├── windows.foundation.numerics.h │ ├── windows.gaming.input.forcefeedback.h │ ├── windows.gaming.input.h │ ├── windows.system.h │ ├── windows.system.power.h │ └── windowscontracts.h └── src ├── android └── android.zig └── androidbuild ├── WindowsSdk.zig ├── androidbuild.zig ├── apk.zig ├── builtin_options_update.zig ├── d8glob.zig └── tools.zig /.gitattributes: -------------------------------------------------------------------------------- 1 | # Use Unix line endings in all text files. 2 | * text=auto eol=lf 3 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | pull_request: 5 | push: 6 | branches: 7 | - main 8 | 9 | concurrency: 10 | # Cancels pending runs when a PR gets updated. 11 | group: ${{ github.head_ref || github.run_id }}-${{ github.actor }} 12 | cancel-in-progress: true 13 | 14 | jobs: 15 | build: 16 | name: Build 17 | strategy: 18 | matrix: 19 | include: 20 | - os: "ubuntu-22.04" 21 | - os: "windows-latest" 22 | - os: "macos-14" # arm64 as per table: https://github.com/actions/runner-images/blob/8a1eeaf6ac70c66f675a04078d1a7222edd42008/README.md#available-images 23 | 24 | runs-on: ${{matrix.os}} 25 | 26 | steps: 27 | - uses: actions/checkout@v4 28 | 29 | - name: Set up JDK 17 30 | uses: actions/setup-java@v3 31 | with: 32 | java-version: '17' 33 | distribution: 'temurin' 34 | 35 | - name: Setup Android SDK 36 | uses: android-actions/setup-android@v3 37 | with: 38 | packages: 'tools platform-tools platforms;android-35 build-tools;35.0.0 ndk;29.0.13113456' 39 | 40 | # 41 | # Stable Zig Builds 42 | # 43 | 44 | - name: Setup Zig Stable (0.14.0) 45 | # note(jae): 2024-09-15 46 | # Uses download mirror first as preferred by Zig Foundation 47 | # see: https://ziglang.org/news/migrate-to-self-hosting/ 48 | uses: mlugg/setup-zig@v1 49 | with: 50 | version: "0.14.0" 51 | 52 | - name: Build Minimal Example (Zig Stable) 53 | run: zig build -Dandroid=true --verbose 54 | working-directory: examples/minimal 55 | 56 | - name: Build SDL2 Example (Zig Stable) 57 | run: | 58 | zig build -Dandroid=true --verbose 59 | zig build -Dandroid=true -Dcrash-on-exception --verbose 60 | working-directory: examples/sdl2 61 | 62 | # TODO(jae): 2025-03-30 63 | # Need to figure out how to get 'adb shell monkey' to return an error code or be able to return an error code 64 | # if the stdout of the command has 'Monkey aborted due to error.' 65 | 66 | # - name: Enable KVM (For Android emulation) 67 | # if: startsWith(matrix.os, 'ubuntu-') 68 | # run: | 69 | # echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules 70 | # sudo udevadm control --reload-rules 71 | # sudo udevadm trigger --name-match=kvm 72 | 73 | # - name: Run Minimal Example (Android Emulator) 74 | # if: startsWith(matrix.os, 'ubuntu-') 75 | # uses: reactivecircus/android-emulator-runner@v2 76 | # with: 77 | # api-level: 34 78 | # arch: x86_64 79 | # profile: Nexus 6 80 | # script: | 81 | # adb install ./zig-out/bin/minimal.apk 82 | # adb shell am start -S -W -n com.zig.minimal/android.app.NativeActivity 83 | # working-directory: examples/minimal 84 | 85 | # - name: Run SDL2 Example (Android Emulator) 86 | # if: startsWith(matrix.os, 'ubuntu-') 87 | # uses: reactivecircus/android-emulator-runner@v2 88 | # with: 89 | # api-level: 34 90 | # arch: x86_64 91 | # profile: Nexus 6 92 | # script: | 93 | # adb install ./zig-out/bin/sdl-zig-demo.apk 94 | # adb shell monkey --kill-process-after-error --monitor-native-crashes --pct-touch 100 -p com.zig.sdl2 --throttle 1000 -v 2 95 | # working-directory: examples/sdl2 96 | 97 | # 98 | # Nightly Zig Builds 99 | # 100 | 101 | - name: Setup Zig Nightly 102 | uses: mlugg/setup-zig@v1 103 | with: 104 | version: "master" 105 | 106 | - name: Build Minimal Example (Zig Nightly) 107 | run: zig build -Dandroid=true --verbose 108 | working-directory: examples/minimal 109 | 110 | - name: Build SDL2 Example (Zig Nightly) 111 | run: zig build -Dandroid=true --verbose 112 | working-directory: examples/sdl2 113 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .zig-cache 2 | zig-out 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) SilbinaryWolf and Zig Android SDK contributors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Zig Android SDK 2 | 3 | ![Continuous integration](https://github.com/silbinarywolf/zig-android-sdk/actions/workflows/ci.yml/badge.svg) 4 | 5 | This library allows you to setup and build an APK for your Android devices. This project was mostly based off the work of [ikskuh](https://github.com/ikskuh) and wouldn't exist without the work they did on the [ZigAndroidTemplate](https://github.com/ikskuh/ZigAndroidTemplate) project. 6 | 7 | ```sh 8 | # Target one Android architecture 9 | zig build -Dtarget=x86_64-linux-android 10 | 11 | # Target all Android architectures 12 | zig build -Dandroid=true 13 | ``` 14 | 15 | ```zig 16 | // This is an overly simplified example to give you the gist 17 | // of how this library works, see: examples/minimal/build.zig 18 | const android = @import("android"); 19 | 20 | pub fn build(b: *std.Build) !void { 21 | const android_tools = android.Tools.create(b, ...); 22 | const apk = android.APK.create(b, android_tools); 23 | apk.setAndroidManifest(b.path("android/AndroidManifest.xml")); 24 | apk.addResourceDirectory(b.path("android/res")); 25 | apk.addJavaSourceFile(.{ .file = b.path("android/src/NativeInvocationHandler.java") }); 26 | for (android.standardTargets(b, b.standardTargetOptions(.{}))) |target| { 27 | apk.addArtifact(b.addSharedLibrary(.{ 28 | .name = exe_name, 29 | .root_source_file = b.path("src/main.zig"), 30 | .target = target, 31 | .optimize = optimize, 32 | })) 33 | } 34 | } 35 | ``` 36 | 37 | ## Requirements 38 | 39 | * [Zig](https://ziglang.org/download) 40 | * Android Tools 41 | * Option A: [Android Studio](https://developer.android.com/studio) 42 | * Option B: [Android Command Line Tools](https://developer.android.com/studio#command-line-tools-only) 43 | * [Java Development Kit](https://www.oracle.com/au/java/technologies/downloads/) 44 | 45 | ## Installation 46 | 47 | Add the following to your build.zig.zon file and run `zig build`. 48 | 49 | ```zig 50 | .{ 51 | .dependencies = .{ 52 | .android = .{ 53 | .path = "https://github.com/silbinarywolf/zig-android-sdk/archive/REPLACE_WITH_WANTED_COMMIT.tar.gz", 54 | // .hash = REPLACE_WITH_HASH_FROM_BUILD_ERROR 55 | }, 56 | }, 57 | } 58 | ``` 59 | 60 | ## Examples 61 | 62 | * [minimal](examples/minimal): This is based off ZigAndroidTemplate's minimal example. 63 | * [SDL2](examples/sdl2): This is based off Andrew Kelly's SDL Zig Demo but modified to run on Android, Windows, Mac and Linux. 64 | 65 | ## Workarounds 66 | 67 | - Patch any artifacts that called `linkLibCpp()` to disable linking C++ and instead manually link `c++abi` and `unwind`. This at least allows the SDL2 example to work for now. 68 | 69 | ## Credits 70 | 71 | - [ikskuh](https://github.com/ikskuh) This would not exist without their [ZigAndroidTemplate](https://github.com/ikskuh/ZigAndroidTemplate) repository to use as a baseline for figuring this all out and also being able to use their logic for the custom panic / logging functions. 72 | - ikskuh gave a huge thanks to [@cnlohr](https://github.com/cnlohr) for [rawdrawandroid](https://github.com/cnlohr/rawdrawandroid) 73 | -------------------------------------------------------------------------------- /build.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | const androidbuild = @import("src/androidbuild/androidbuild.zig"); 3 | const Apk = @import("src/androidbuild/apk.zig"); 4 | 5 | // Expose Android build functionality for use in your build.zig 6 | 7 | pub const Tools = @import("src/androidbuild/tools.zig"); 8 | pub const APK = Apk; // TODO(jae): 2025-03-13: Consider deprecating and using 'Apk' to be conventional to Zig 9 | pub const APILevel = androidbuild.APILevel; // TODO(jae): 2025-03-13: Consider deprecating and using 'ApiLevel' to be conventional to Zig 10 | pub const standardTargets = androidbuild.standardTargets; 11 | 12 | // Deprecated exposes fields 13 | 14 | /// Deprecated: Use Tools.Options instead. 15 | pub const ToolsOptions = Tools.Options; 16 | /// Deprecated: Use Tools.CreateKey instead. 17 | pub const CreateKey = Tools.CreateKey; 18 | 19 | /// NOTE: As well as providing the "android" module this declaration is required so this can be imported by other build.zig files 20 | pub fn build(b: *std.Build) void { 21 | const target = b.standardTargetOptions(.{}); 22 | const optimize = b.standardOptimizeOption(.{}); 23 | 24 | const module = b.addModule("android", .{ 25 | .root_source_file = b.path("src/android/android.zig"), 26 | .target = target, 27 | .optimize = optimize, 28 | }); 29 | 30 | // Create stub of builtin options. 31 | // This is discovered and then replaced by "Apk" in the build process 32 | const android_builtin_options = std.Build.addOptions(b); 33 | android_builtin_options.addOption([:0]const u8, "package_name", ""); 34 | module.addImport("android_builtin", android_builtin_options.createModule()); 35 | 36 | module.linkSystemLibrary("log", .{}); 37 | } 38 | -------------------------------------------------------------------------------- /build.zig.zon: -------------------------------------------------------------------------------- 1 | .{ 2 | .name = .android, 3 | .version = "0.1.0", 4 | .dependencies = .{}, 5 | .paths = .{ 6 | "build.zig", 7 | "build.zig.zon", 8 | "src", 9 | }, 10 | .minimum_zig_version = "0.14.0", 11 | .fingerprint = 0x92bcb62d42fb2cee, 12 | } 13 | -------------------------------------------------------------------------------- /examples/minimal/README.md: -------------------------------------------------------------------------------- 1 | # Minimal Example 2 | 3 | As of 2024-09-19, this is a thrown together, very quick copy-paste of the minimal example from the original [ZigAndroidTemplate](https://github.com/ikskuh/ZigAndroidTemplate/blob/master/examples/minimal/main.zig) repository. 4 | 5 | ### Build, install to test one target against a local emulator and run 6 | 7 | ```sh 8 | zig build -Dtarget=x86_64-linux-android 9 | adb install ./zig-out/bin/minimal.apk 10 | adb shell am start -S -W -n com.zig.minimal/android.app.NativeActivity 11 | ``` 12 | 13 | ### Build and install for all supported Android targets 14 | 15 | ```sh 16 | zig build -Dandroid=true 17 | adb install ./zig-out/bin/minimal.apk 18 | ``` 19 | 20 | ### Uninstall your application 21 | 22 | If installing your application fails with something like: 23 | ``` 24 | adb: failed to install ./zig-out/bin/minimal.apk: Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE: Existing package com.zig.minimal signatures do not match newer version; ignoring!] 25 | ``` 26 | 27 | ```sh 28 | adb uninstall "com.zig.minimal" 29 | ``` 30 | 31 | ### View logs of application 32 | 33 | Powershell (app doesn't need to be running) 34 | ```sh 35 | adb logcat | Select-String com.zig.minimal: 36 | ``` 37 | 38 | Bash (app doesn't need running to be running) 39 | ```sh 40 | adb logcat com.zig.minimal:D *:S 41 | ``` 42 | 43 | Bash (app must be running, logs everything by the process including modules) 44 | ```sh 45 | adb logcat --pid=`adb shell pidof -s com.zig.minimal` 46 | ``` 47 | -------------------------------------------------------------------------------- /examples/minimal/android/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 12 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /examples/minimal/android/res/mipmap/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/silbinarywolf/zig-android-sdk/1ed383662bcd56d00a11079641f598b712a0599d/examples/minimal/android/res/mipmap/ic_launcher.png -------------------------------------------------------------------------------- /examples/minimal/android/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Zig Minimal 5 | 9 | com.zig.minimal 10 | 11 | -------------------------------------------------------------------------------- /examples/minimal/build.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | const builtin = @import("builtin"); 3 | const android = @import("android"); 4 | 5 | pub fn build(b: *std.Build) void { 6 | const exe_name: []const u8 = "minimal"; 7 | const root_target = b.standardTargetOptions(.{}); 8 | const optimize = b.standardOptimizeOption(.{}); 9 | const android_targets = android.standardTargets(b, root_target); 10 | 11 | var root_target_single = [_]std.Build.ResolvedTarget{root_target}; 12 | const targets: []std.Build.ResolvedTarget = if (android_targets.len == 0) 13 | root_target_single[0..] 14 | else 15 | android_targets; 16 | 17 | // If building with Android, initialize the tools / build 18 | const android_apk: ?*android.APK = blk: { 19 | if (android_targets.len == 0) { 20 | break :blk null; 21 | } 22 | const android_tools = android.Tools.create(b, .{ 23 | .api_level = .android15, 24 | .build_tools_version = "35.0.1", 25 | .ndk_version = "29.0.13113456", 26 | }); 27 | const apk = android.APK.create(b, android_tools); 28 | 29 | const key_store_file = android_tools.createKeyStore(android.CreateKey.example()); 30 | apk.setKeyStore(key_store_file); 31 | apk.setAndroidManifest(b.path("android/AndroidManifest.xml")); 32 | apk.addResourceDirectory(b.path("android/res")); 33 | 34 | // Add Java files 35 | // - If you have 'android:hasCode="false"' in your AndroidManifest.xml then no Java files are required 36 | // see: https://developer.android.com/ndk/samples/sample_na 37 | // 38 | // WARNING: If you do not provide Java files AND android:hasCode="false" isn't explicitly set, then you may get the following error on "adb install" 39 | // Scanning Failed.: Package /data/app/base.apk code is missing] 40 | // 41 | // apk.addJavaSourceFile(.{ .file = b.path("android/src/X.java") }); 42 | break :blk apk; 43 | }; 44 | 45 | for (targets) |target| { 46 | const app_module = b.createModule(.{ 47 | .target = target, 48 | .optimize = optimize, 49 | .root_source_file = b.path("src/minimal.zig"), 50 | }); 51 | 52 | var exe: *std.Build.Step.Compile = if (target.result.abi.isAndroid()) b.addLibrary(.{ 53 | .name = exe_name, 54 | .root_module = app_module, 55 | .linkage = .dynamic, 56 | }) else b.addExecutable(.{ 57 | .name = exe_name, 58 | .root_module = app_module, 59 | }); 60 | 61 | // if building as library for Android, add this target 62 | // NOTE: Android has different CPU targets so you need to build a version of your 63 | // code for x86, x86_64, arm, arm64 and more 64 | if (target.result.abi.isAndroid()) { 65 | const apk: *android.APK = android_apk orelse @panic("Android APK should be initialized"); 66 | const android_dep = b.dependency("android", .{ 67 | .optimize = optimize, 68 | .target = target, 69 | }); 70 | exe.root_module.addImport("android", android_dep.module("android")); 71 | 72 | apk.addArtifact(exe); 73 | } else { 74 | b.installArtifact(exe); 75 | 76 | // If only 1 target, add "run" step 77 | if (targets.len == 1) { 78 | const run_step = b.step("run", "Run the application"); 79 | const run_cmd = b.addRunArtifact(exe); 80 | run_step.dependOn(&run_cmd.step); 81 | } 82 | } 83 | } 84 | if (android_apk) |apk| { 85 | apk.installApk(); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /examples/minimal/build.zig.zon: -------------------------------------------------------------------------------- 1 | .{ 2 | .name = .minimal, 3 | .version = "0.0.0", 4 | .dependencies = .{ 5 | .android = .{ 6 | .path = "../..", 7 | }, 8 | }, 9 | .paths = .{ 10 | "build.zig", 11 | "build.zig.zon", 12 | "src", 13 | }, 14 | .fingerprint = 0x4037f28ad1eb4832, 15 | } 16 | -------------------------------------------------------------------------------- /examples/minimal/src/minimal.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | const builtin = @import("builtin"); 3 | const android = @import("android"); 4 | const androidbind = @import("android-bind.zig"); 5 | const log = std.log; 6 | 7 | /// custom standard options for Android 8 | pub const std_options: std.Options = if (builtin.abi.isAndroid()) 9 | .{ 10 | .logFn = android.logFn, 11 | } 12 | else 13 | .{}; 14 | 15 | /// custom panic handler for Android 16 | pub const panic = if (builtin.abi.isAndroid()) 17 | android.panic 18 | else 19 | std.debug.FullPanic(std.debug.defaultPanic); 20 | 21 | fn nativeActivityOnCreate(activity: *androidbind.ANativeActivity, savedState: []const u8) !void { 22 | const sdk_version: c_int = blk: { 23 | var sdk_ver_str: [92]u8 = undefined; 24 | const len = androidbind.__system_property_get("ro.build.version.sdk", &sdk_ver_str); 25 | if (len <= 0) { 26 | break :blk 0; 27 | } else { 28 | const str = sdk_ver_str[0..@intCast(len)]; 29 | break :blk std.fmt.parseInt(c_int, str, 10) catch 0; 30 | } 31 | }; 32 | 33 | log.debug( 34 | \\Zig Android SDK: 35 | \\ App: {s} 36 | \\ API level: actual={d} 37 | \\ App pid: {} 38 | \\ Build mode: {s} 39 | \\ ABI: {s}-{s}-{s} 40 | \\ Compiler version: {} 41 | \\ Compiler backend: {s} 42 | , .{ 43 | "Minimal App", // build_options.app_name, 44 | // build_options.android_sdk_version, 45 | sdk_version, 46 | std.os.linux.getpid(), 47 | @tagName(builtin.mode), 48 | @tagName(builtin.cpu.arch), 49 | @tagName(builtin.os.tag), 50 | @tagName(builtin.abi), 51 | builtin.zig_version, 52 | @tagName(builtin.zig_backend), 53 | }); 54 | 55 | const allocator = std.heap.c_allocator; 56 | 57 | const app = try allocator.create(AndroidApp); 58 | errdefer allocator.destroy(app); 59 | 60 | activity.callbacks.* = makeNativeActivityGlue(AndroidApp); 61 | app.* = try AndroidApp.init( 62 | allocator, 63 | activity, 64 | savedState, 65 | ); 66 | errdefer app.deinit(); 67 | 68 | try app.start(); 69 | 70 | activity.instance = app; 71 | 72 | log.debug("Successfully started the app.", .{}); 73 | } 74 | 75 | comptime { 76 | if (builtin.abi.isAndroid()) { 77 | @export(&NativeActivity_onCreate, .{ .name = "ANativeActivity_onCreate" }); 78 | } else { 79 | @compileError("This example cannot run on targets other Android"); 80 | } 81 | } 82 | 83 | /// Android entry point 84 | fn NativeActivity_onCreate(activity: *androidbind.ANativeActivity, rawSavedState: ?[*]u8, rawSavedStateSize: usize) callconv(.C) void { 85 | const savedState: []const u8 = if (rawSavedState) |s| 86 | s[0..rawSavedStateSize] 87 | else 88 | &[0]u8{}; 89 | 90 | nativeActivityOnCreate(activity, savedState) catch |err| { 91 | log.err("ANativeActivity_onCreate: error within nativeActivityOnCreate: {s}", .{@errorName(err)}); 92 | return; 93 | }; 94 | } 95 | 96 | /// Entry point for our application. 97 | /// This struct provides the interface to the android support package. 98 | pub const AndroidApp = struct { 99 | const Self = @This(); 100 | 101 | allocator: std.mem.Allocator, 102 | activity: *androidbind.ANativeActivity, 103 | 104 | /// This is the entry point which initializes a application 105 | /// that has stored its previous state. 106 | /// `stored_state` is that state, the memory is only valid for this function. 107 | pub fn init(allocator: std.mem.Allocator, activity: *androidbind.ANativeActivity, savedState: []const u8) !Self { 108 | _ = savedState; // autofix 109 | 110 | return Self{ 111 | .allocator = allocator, 112 | .activity = activity, 113 | }; 114 | } 115 | 116 | /// This function is called when the application is successfully initialized. 117 | /// It should create a background thread that processes the events and runs until 118 | /// the application gets destroyed. 119 | pub fn start(self: *Self) !void { 120 | _ = self; 121 | } 122 | 123 | /// Uninitialize the application. 124 | /// Don't forget to stop your background thread here! 125 | pub fn deinit(self: *Self) void { 126 | self.* = undefined; 127 | } 128 | }; 129 | 130 | /// Returns a wrapper implementation for the given App type which implements all 131 | /// ANativeActivity callbacks. 132 | fn makeNativeActivityGlue(comptime App: type) androidbind.ANativeActivityCallbacks { 133 | const T = struct { 134 | fn invoke(activity: *androidbind.ANativeActivity, comptime func: []const u8, args: anytype) void { 135 | if (!@hasDecl(App, func)) { 136 | log.debug("ANativeActivity callback {s} not available on {s}", .{ func, @typeName(App) }); 137 | return; 138 | } 139 | const instance = activity.instance orelse return; 140 | const result = @call(.auto, @field(App, func), .{@as(*App, @ptrCast(instance))} ++ args); 141 | switch (@typeInfo(@TypeOf(result))) { 142 | .ErrorUnion => result catch |err| log.err("{s} returned error {s}", .{ func, @errorName(err) }), 143 | .Void => {}, 144 | .ErrorSet => log.err("{s} returned error {s}", .{ func, @errorName(result) }), 145 | else => @compileError("callback must return void!"), 146 | } 147 | } 148 | 149 | // return value must be created with malloc(), so we pass the c_allocator to App.onSaveInstanceState 150 | fn onSaveInstanceState(activity: *androidbind.ANativeActivity, outSize: *usize) callconv(.C) ?[*]u8 { 151 | outSize.* = 0; 152 | if (!@hasDecl(App, "onSaveInstanceState")) { 153 | log.debug("ANativeActivity callback onSaveInstanceState not available on {s}", .{@typeName(App)}); 154 | return null; 155 | } 156 | const instance = activity.instance orelse return null; 157 | const optional_slice = @as(*App, @ptrCast(instance)).onSaveInstanceState(std.heap.c_allocator); 158 | if (optional_slice) |slice| { 159 | outSize.* = slice.len; 160 | return slice.ptr; 161 | } 162 | return null; 163 | } 164 | 165 | fn onDestroy(activity: *androidbind.ANativeActivity) callconv(.C) void { 166 | const instance = activity.instance orelse return; 167 | const app: *App = @ptrCast(@alignCast(instance)); 168 | app.deinit(); 169 | std.heap.c_allocator.destroy(app); 170 | } 171 | fn onStart(activity: *androidbind.ANativeActivity) callconv(.C) void { 172 | invoke(activity, "onStart", .{}); 173 | } 174 | fn onResume(activity: *androidbind.ANativeActivity) callconv(.C) void { 175 | invoke(activity, "onResume", .{}); 176 | } 177 | fn onPause(activity: *androidbind.ANativeActivity) callconv(.C) void { 178 | invoke(activity, "onPause", .{}); 179 | } 180 | fn onStop(activity: *androidbind.ANativeActivity) callconv(.C) void { 181 | invoke(activity, "onStop", .{}); 182 | } 183 | fn onConfigurationChanged(activity: *androidbind.ANativeActivity) callconv(.C) void { 184 | invoke(activity, "onConfigurationChanged", .{}); 185 | } 186 | fn onLowMemory(activity: *androidbind.ANativeActivity) callconv(.C) void { 187 | invoke(activity, "onLowMemory", .{}); 188 | } 189 | fn onWindowFocusChanged(activity: *androidbind.ANativeActivity, hasFocus: c_int) callconv(.C) void { 190 | invoke(activity, "onWindowFocusChanged", .{(hasFocus != 0)}); 191 | } 192 | fn onNativeWindowCreated(activity: *androidbind.ANativeActivity, window: *androidbind.ANativeWindow) callconv(.C) void { 193 | invoke(activity, "onNativeWindowCreated", .{window}); 194 | } 195 | fn onNativeWindowResized(activity: *androidbind.ANativeActivity, window: *androidbind.ANativeWindow) callconv(.C) void { 196 | invoke(activity, "onNativeWindowResized", .{window}); 197 | } 198 | fn onNativeWindowRedrawNeeded(activity: *androidbind.ANativeActivity, window: *androidbind.ANativeWindow) callconv(.C) void { 199 | invoke(activity, "onNativeWindowRedrawNeeded", .{window}); 200 | } 201 | fn onNativeWindowDestroyed(activity: *androidbind.ANativeActivity, window: *androidbind.ANativeWindow) callconv(.C) void { 202 | invoke(activity, "onNativeWindowDestroyed", .{window}); 203 | } 204 | fn onInputQueueCreated(activity: *androidbind.ANativeActivity, input_queue: *androidbind.AInputQueue) callconv(.C) void { 205 | invoke(activity, "onInputQueueCreated", .{input_queue}); 206 | } 207 | fn onInputQueueDestroyed(activity: *androidbind.ANativeActivity, input_queue: *androidbind.AInputQueue) callconv(.C) void { 208 | invoke(activity, "onInputQueueDestroyed", .{input_queue}); 209 | } 210 | fn onContentRectChanged(activity: *androidbind.ANativeActivity, rect: *const androidbind.ARect) callconv(.C) void { 211 | invoke(activity, "onContentRectChanged", .{rect}); 212 | } 213 | }; 214 | return androidbind.ANativeActivityCallbacks{ 215 | .onStart = T.onStart, 216 | .onResume = T.onResume, 217 | .onSaveInstanceState = T.onSaveInstanceState, 218 | .onPause = T.onPause, 219 | .onStop = T.onStop, 220 | .onDestroy = T.onDestroy, 221 | .onWindowFocusChanged = T.onWindowFocusChanged, 222 | .onNativeWindowCreated = T.onNativeWindowCreated, 223 | .onNativeWindowResized = T.onNativeWindowResized, 224 | .onNativeWindowRedrawNeeded = T.onNativeWindowRedrawNeeded, 225 | .onNativeWindowDestroyed = T.onNativeWindowDestroyed, 226 | .onInputQueueCreated = T.onInputQueueCreated, 227 | .onInputQueueDestroyed = T.onInputQueueDestroyed, 228 | .onContentRectChanged = T.onContentRectChanged, 229 | .onConfigurationChanged = T.onConfigurationChanged, 230 | .onLowMemory = T.onLowMemory, 231 | }; 232 | } 233 | -------------------------------------------------------------------------------- /examples/raylib/README.md: -------------------------------------------------------------------------------- 1 | # Raylib Example 2 | **Note**: 3 | Due to [an upstream bug](https://github.com/ziglang/zig/issues/20476), you will probably receive a warning (or multiple warnings if building for multiple targets) like this: 4 | ``` 5 | error: warning(link): unexpected LLD stderr: 6 | ld.lld: warning: /.zig-cache/o/4227869d730f094811a7cdaaab535797/libraylib.a: archive member '/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/x86_64-linux-android/35/libGLESv2.so' is neither ET_REL nor LLVM bitcode 7 | ``` 8 | You can ignore this error for now. 9 | 10 | ### Build, install to test one target against a local emulator and run 11 | 12 | ```sh 13 | zig build -Dtarget=x86_64-linux-android 14 | adb install ./zig-out/bin/raylib.apk 15 | adb shell am start -S -W -n com.zig.raylib/android.app.NativeActivity 16 | ``` 17 | 18 | ### Build and install for all supported Android targets 19 | 20 | ```sh 21 | zig build -Dandroid=true 22 | adb install ./zig-out/bin/raylib.apk 23 | ``` 24 | 25 | ### Build and run natively on your operating system 26 | 27 | ```sh 28 | zig build run 29 | ``` 30 | 31 | ### Uninstall your application 32 | 33 | If installing your application fails with something like: 34 | ``` 35 | adb: failed to install ./zig-out/bin/raylib.apk: Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE: Existing package com.zig.raylib signatures do not match newer version; ignoring!] 36 | ``` 37 | 38 | ```sh 39 | adb uninstall "com.zig.raylib" 40 | ``` 41 | 42 | ### View logs of application 43 | 44 | Powershell (app doesn't need to be running) 45 | ```sh 46 | adb logcat | Select-String com.zig.raylib: 47 | ``` 48 | 49 | Bash (app doesn't need running to be running) 50 | ```sh 51 | adb logcat com.zig.raylib:D *:S 52 | ``` 53 | 54 | Bash (app must be running, logs everything by the process including modules) 55 | ```sh 56 | adb logcat --pid=`adb shell pidof -s com.zig.raylib` 57 | ``` 58 | 59 | 60 | -------------------------------------------------------------------------------- /examples/raylib/android/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 18 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /examples/raylib/android/res/mipmap/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/silbinarywolf/zig-android-sdk/1ed383662bcd56d00a11079641f598b712a0599d/examples/raylib/android/res/mipmap/ic_launcher.png -------------------------------------------------------------------------------- /examples/raylib/android/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Zig Raylib 5 | 9 | com.zig.raylib 10 | 11 | -------------------------------------------------------------------------------- /examples/raylib/build.zig: -------------------------------------------------------------------------------- 1 | const android = @import("android"); 2 | const std = @import("std"); 3 | 4 | //This is targeting android version 10 / API level 29. 5 | //Change the value here and in android/AndroidManifest.xml to target your desired API level 6 | const android_version: android.APILevel = .android10; 7 | const android_api = std.fmt.comptimePrint("{}", .{@intFromEnum(android_version)}); 8 | const exe_name = "raylib"; 9 | 10 | pub fn build(b: *std.Build) void { 11 | const root_target = b.standardTargetOptions(.{}); 12 | const optimize = b.standardOptimizeOption(.{}); 13 | const android_targets = android.standardTargets(b, root_target); 14 | 15 | var root_target_single = [_]std.Build.ResolvedTarget{root_target}; 16 | const targets: []std.Build.ResolvedTarget = if (android_targets.len == 0) 17 | root_target_single[0..] 18 | else 19 | android_targets; 20 | 21 | const android_apk: ?*android.APK = blk: { 22 | if (android_targets.len == 0) { 23 | break :blk null; 24 | } 25 | const android_tools = android.Tools.create(b, .{ 26 | .api_level = android_version, 27 | .build_tools_version = "35.0.1", 28 | .ndk_version = "29.0.13113456", 29 | }); 30 | const apk = android.APK.create(b, android_tools); 31 | 32 | const key_store_file = android_tools.createKeyStore(android.CreateKey.example()); 33 | apk.setKeyStore(key_store_file); 34 | apk.setAndroidManifest(b.path("android/AndroidManifest.xml")); 35 | apk.addResourceDirectory(b.path("android/res")); 36 | 37 | break :blk apk; 38 | }; 39 | 40 | for (targets) |target| { 41 | const lib_mod = b.createModule(.{ 42 | .root_source_file = b.path("src/main.zig"), 43 | .target = target, 44 | .optimize = optimize, 45 | }); 46 | const lib = b.addLibrary(.{ 47 | .linkage = .dynamic, 48 | .name = exe_name, 49 | .root_module = lib_mod, 50 | }); 51 | lib.linkLibC(); 52 | b.installArtifact(lib); 53 | 54 | const android_ndk_path = if(android_apk) |apk| (b.fmt("{s}/ndk/{s}", .{ apk.tools.android_sdk_path, apk.tools.ndk_version })) else ""; 55 | const raylib_dep = if (target.result.abi.isAndroid()) ( 56 | b.dependency("raylib_zig", .{ 57 | .target = target, 58 | .optimize = optimize, 59 | .android_api_version = @as([]const u8, android_api), 60 | .android_ndk = @as([]const u8, android_ndk_path), 61 | })) else ( 62 | b.dependency("raylib_zig", .{ 63 | .target = target, 64 | .optimize = optimize, 65 | .shared = true 66 | })); 67 | const raylib_artifact = raylib_dep.artifact("raylib"); 68 | lib.linkLibrary(raylib_artifact); 69 | const raylib_mod = raylib_dep.module("raylib"); 70 | lib.root_module.addImport("raylib", raylib_mod); 71 | 72 | if (target.result.abi.isAndroid()) { 73 | const apk: *android.APK = android_apk orelse @panic("Android APK should be initialized"); 74 | const android_dep = b.dependency("android", .{ 75 | .optimize = optimize, 76 | .target = target, 77 | }); 78 | lib.root_module.linkSystemLibrary("android", .{ .preferred_link_mode = .dynamic }); 79 | lib.root_module.addImport("android", android_dep.module("android")); 80 | 81 | const native_app_glue_dir: std.Build.LazyPath = .{ .cwd_relative = b.fmt("{s}/sources/android/native_app_glue", .{android_ndk_path}) }; 82 | lib.root_module.addCSourceFile(.{ .file = native_app_glue_dir.path(b, "android_native_app_glue.c") }); 83 | lib.root_module.addIncludePath(native_app_glue_dir); 84 | 85 | lib.root_module.linkSystemLibrary("log", .{ .preferred_link_mode = .dynamic }); 86 | apk.addArtifact(lib); 87 | } else { 88 | const exe = b.addExecutable(.{ .name = exe_name, .optimize = optimize, .root_module = lib_mod }); 89 | b.installArtifact(exe); 90 | 91 | const run_exe = b.addRunArtifact(exe); 92 | const run_step = b.step("run", "Run the application"); 93 | run_step.dependOn(&run_exe.step); 94 | } 95 | } 96 | if (android_apk) |apk| { 97 | apk.installApk(); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /examples/raylib/build.zig.zon: -------------------------------------------------------------------------------- 1 | .{ 2 | .name = .raylib, 3 | .version = "0.0.0", 4 | .minimum_zig_version = "0.14.0", 5 | .fingerprint = 0x13035e5cf42e313f, 6 | .dependencies = .{ 7 | .raylib_zig = .{ 8 | .url = "git+https://github.com/lumenkeyes/raylib-zig#b00d4c2b973665e3a88c2565b6cd63c56d0173c2", 9 | .hash = "raylib_zig-5.6.0-dev-KE8REPwqBQC35iWa2sFblBUNWkTlEi1gjit9dtyOLu_b" 10 | }, 11 | .android = .{ .path = "../.." }, 12 | }, 13 | .paths = .{ 14 | "build.zig", 15 | "build.zig.zon", 16 | "src", 17 | }, 18 | } 19 | -------------------------------------------------------------------------------- /examples/raylib/src/main.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | const builtin = @import("builtin"); 3 | const android = @import("android"); 4 | const rl = @import("raylib"); 5 | 6 | pub fn main() void { 7 | const screenWidth = 800; 8 | const screenHeight = 450; 9 | rl.initWindow(screenWidth, screenHeight, "raylib-zig [core] example - basic window"); 10 | defer rl.closeWindow(); 11 | rl.setTargetFPS(60); 12 | while (!rl.windowShouldClose()) { 13 | rl.beginDrawing(); 14 | defer rl.endDrawing(); 15 | 16 | rl.clearBackground(.white); 17 | 18 | rl.drawText("Congrats! You created your first window!", 190, 200, 20, .light_gray); 19 | } 20 | } 21 | 22 | /// custom panic handler for Android 23 | pub const panic = if (builtin.abi.isAndroid()) 24 | android.panic 25 | else 26 | std.debug.FullPanic(std.debug.defaultPanic); 27 | 28 | /// custom standard options for Android 29 | pub const std_options: std.Options = if (builtin.abi.isAndroid()) 30 | .{ 31 | .logFn = android.logFn, 32 | } 33 | else 34 | .{}; 35 | 36 | comptime { 37 | if (builtin.abi.isAndroid()) { 38 | // Setup exported C-function as defined in AndroidManifest.xml 39 | // ie. 40 | @export(&androidMain, .{ .name = "main" }); 41 | } 42 | } 43 | 44 | fn androidMain() callconv(.c) c_int { 45 | return std.start.callMain(); 46 | } 47 | -------------------------------------------------------------------------------- /examples/sdl2/README.md: -------------------------------------------------------------------------------- 1 | # SDL2 Example 2 | 3 | This is a copy-paste of [Andrew Kelly's SDL Zig Demo](https://github.com/andrewrk/sdl-zig-demo) but running on Android. The build is setup so you can also target your native operating system as well. 4 | 5 | ### Build, install to test one target against a local emulator and run 6 | 7 | ```sh 8 | zig build -Dtarget=x86_64-linux-android 9 | adb install ./zig-out/bin/sdl-zig-demo.apk 10 | adb shell am start -S -W -n com.zig.sdl2/com.zig.sdl2.ZigSDLActivity 11 | ``` 12 | 13 | ### Build and install for all supported Android targets 14 | 15 | ```sh 16 | zig build -Dandroid=true 17 | adb install ./zig-out/bin/sdl-zig-demo.apk 18 | ``` 19 | 20 | ### Build and run natively on your operating system 21 | 22 | ```sh 23 | zig build run 24 | ``` 25 | 26 | ### Uninstall your application 27 | 28 | If installing your application fails with something like: 29 | ``` 30 | adb: failed to install ./zig-out/bin/sdl2.apk: Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE: Existing package com.zig.sdl2 signatures do not match newer version; ignoring!] 31 | ``` 32 | 33 | ```sh 34 | adb uninstall "com.zig.sdl2" 35 | ``` 36 | 37 | ### View logs of application 38 | 39 | Powershell (app doesn't need to be running) 40 | ```sh 41 | adb logcat | Select-String com.zig.sdl2: 42 | ``` 43 | 44 | Bash (app doesn't need running to be running) 45 | ```sh 46 | adb logcat com.zig.sdl2:D *:S 47 | ``` 48 | 49 | Bash (app must be running, logs everything by the process including modules) 50 | ```sh 51 | adb logcat --pid=`adb shell pidof -s com.zig.sdl2` 52 | ``` 53 | -------------------------------------------------------------------------------- /examples/sdl2/android/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 21 | 22 | 23 | 26 | 29 | 32 | 33 | 34 | 37 | 38 | 39 | 40 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 66 | 71 | 72 | 75 | 76 | 84 | 85 | 86 | 87 | 88 | 89 | 92 | 93 | 100 | 101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /examples/sdl2/android/androidCrashTest/ZigSDLActivity.java: -------------------------------------------------------------------------------- 1 | package com.zig.sdl2; // <- Your game package name 2 | 3 | import org.libsdl.app.SDLActivity; 4 | import android.os.Bundle; 5 | import android.util.AndroidRuntimeException; 6 | 7 | /** 8 | * Used by ci.yml to make the application crash if an error occurs initializing your application. 9 | * 10 | * This allows the following commands to catch crash errors on startup: 11 | * - adb install ./zig-out/bin/sdl-zig-demo.apk 12 | * - adb shell monkey --kill-process-after-error --monitor-native-crashes --pct-touch 100 -p com.zig.sdl2 -v 50 13 | */ 14 | public class ZigSDLActivity extends SDLActivity { 15 | @Override 16 | protected void onCreate(Bundle savedInstanceState) { 17 | super.onCreate(savedInstanceState); 18 | 19 | if (mBrokenLibraries) { 20 | throw new AndroidRuntimeException("SDL Error, has broken libraries"); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /examples/sdl2/android/res/mipmap/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/silbinarywolf/zig-android-sdk/1ed383662bcd56d00a11079641f598b712a0599d/examples/sdl2/android/res/mipmap/ic_launcher.png -------------------------------------------------------------------------------- /examples/sdl2/android/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Zig SDL2 5 | 9 | com.zig.sdl2 10 | 11 | -------------------------------------------------------------------------------- /examples/sdl2/android/src/ZigSDLActivity.java: -------------------------------------------------------------------------------- 1 | package com.zig.sdl2; // <- Your game package name 2 | 3 | import org.libsdl.app.SDLActivity; 4 | 5 | /** 6 | * A sample wrapper class that just calls SDLActivity 7 | */ 8 | public class ZigSDLActivity extends SDLActivity { 9 | } 10 | -------------------------------------------------------------------------------- /examples/sdl2/build.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | const builtin = @import("builtin"); 3 | const android = @import("android"); 4 | 5 | pub fn build(b: *std.Build) void { 6 | const root_target = b.standardTargetOptions(.{}); 7 | const optimize = b.standardOptimizeOption(.{}); 8 | const android_targets = android.standardTargets(b, root_target); 9 | 10 | const crash_on_exception = b.option(bool, "crash-on-exception", "if true then we'll use the activity from androidCrashTest folder") orelse false; 11 | 12 | var root_target_single = [_]std.Build.ResolvedTarget{root_target}; 13 | const targets: []std.Build.ResolvedTarget = if (android_targets.len == 0) 14 | root_target_single[0..] 15 | else 16 | android_targets; 17 | 18 | // If building with Android, initialize the tools / build 19 | const android_apk: ?*android.APK = blk: { 20 | if (android_targets.len == 0) { 21 | break :blk null; 22 | } 23 | const android_tools = android.Tools.create(b, .{ 24 | .api_level = .android15, 25 | .build_tools_version = "35.0.1", 26 | .ndk_version = "29.0.13113456", 27 | // NOTE(jae): 2025-03-09 28 | // Previously this example used 'ndk' "27.0.12077973". 29 | // 30 | // However that has issues with the latest SDL2 version when including 'hardware_buffer.h' 31 | // for 32-bit builds. 32 | // 33 | // - AHARDWAREBUFFER_USAGE_FRONT_BUFFER = 1UL << 32 34 | // - ndk/27.0.12077973/toolchains/llvm/prebuilt/{OS}-x86_64/sysroot/usr/include/android/hardware_buffer.h:322:42: 35 | // - error: expression is not an integral constant expression 36 | }); 37 | const apk = android.APK.create(b, android_tools); 38 | 39 | const key_store_file = android_tools.createKeyStore(android.CreateKey.example()); 40 | apk.setKeyStore(key_store_file); 41 | apk.setAndroidManifest(b.path("android/AndroidManifest.xml")); 42 | apk.addResourceDirectory(b.path("android/res")); 43 | 44 | // Add Java files 45 | if (!crash_on_exception) { 46 | apk.addJavaSourceFile(.{ .file = b.path("android/src/ZigSDLActivity.java") }); 47 | } else { 48 | // This is used for testing in Github Actions, so that we can call "adb shell monkey" and trigger 49 | // an error. 50 | // - adb shell monkey --kill-process-after-error --monitor-native-crashes --pct-touch 100 -p com.zig.sdl2 -v 50 51 | // 52 | // This alternate SDLActivity skips the nice dialog box you get when doing manual human testing. 53 | apk.addJavaSourceFile(.{ .file = b.path("android/androidCrashTest/ZigSDLActivity.java") }); 54 | } 55 | 56 | // Add SDL2's Java files like SDL.java, SDLActivity.java, HIDDevice.java, etc 57 | const sdl_dep = b.dependency("sdl2", .{ 58 | .optimize = optimize, 59 | .target = android_targets[0], 60 | }); 61 | const sdl_java_files = sdl_dep.namedWriteFiles("sdljava"); 62 | for (sdl_java_files.files.items) |file| { 63 | apk.addJavaSourceFile(.{ .file = file.contents.copy }); 64 | } 65 | break :blk apk; 66 | }; 67 | 68 | for (targets) |target| { 69 | const exe_name: []const u8 = "sdl-zig-demo"; 70 | const app_module = b.createModule(.{ 71 | .target = target, 72 | .optimize = optimize, 73 | .root_source_file = b.path("src/sdl-zig-demo.zig"), 74 | }); 75 | var exe: *std.Build.Step.Compile = if (target.result.abi.isAndroid()) b.addLibrary(.{ 76 | .name = exe_name, 77 | .root_module = app_module, 78 | .linkage = .dynamic, 79 | }) else b.addExecutable(.{ 80 | .name = exe_name, 81 | .root_module = app_module, 82 | }); 83 | 84 | const library_optimize = if (!target.result.abi.isAndroid()) 85 | optimize 86 | else 87 | // In Zig 0.14.0, for Android builds, make sure we build libraries with ReleaseSafe 88 | // otherwise we get errors relating to libubsan_rt.a getting RELOCATION errors 89 | // https://github.com/silbinarywolf/zig-android-sdk/issues/18 90 | if (optimize == .Debug) .ReleaseSafe else optimize; 91 | 92 | // add SDL2 93 | { 94 | const sdl_dep = b.dependency("sdl2", .{ 95 | .optimize = library_optimize, 96 | .target = target, 97 | }); 98 | if (target.result.os.tag == .linux and !target.result.abi.isAndroid()) { 99 | // The SDL package doesn't work for Linux yet, so we rely on system 100 | // packages for now. 101 | exe.linkSystemLibrary("SDL2"); 102 | exe.linkLibC(); 103 | } else { 104 | const sdl_lib = sdl_dep.artifact("SDL2"); 105 | exe.linkLibrary(sdl_lib); 106 | } 107 | 108 | const sdl_module = sdl_dep.module("sdl"); 109 | exe.root_module.addImport("sdl", sdl_module); 110 | } 111 | 112 | // if building as library for Android, add this target 113 | // NOTE: Android has different CPU targets so you need to build a version of your 114 | // code for x86, x86_64, arm, arm64 and more 115 | if (target.result.abi.isAndroid()) { 116 | const apk: *android.APK = android_apk orelse @panic("Android APK should be initialized"); 117 | const android_dep = b.dependency("android", .{ 118 | .optimize = optimize, 119 | .target = target, 120 | }); 121 | exe.root_module.addImport("android", android_dep.module("android")); 122 | 123 | apk.addArtifact(exe); 124 | } else { 125 | b.installArtifact(exe); 126 | 127 | // If only 1 target, add "run" step 128 | if (targets.len == 1) { 129 | const run_step = b.step("run", "Run the application"); 130 | const run_cmd = b.addRunArtifact(exe); 131 | run_step.dependOn(&run_cmd.step); 132 | } 133 | } 134 | } 135 | if (android_apk) |apk| { 136 | apk.installApk(); 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /examples/sdl2/build.zig.zon: -------------------------------------------------------------------------------- 1 | .{ 2 | .name = .sdl2, 3 | .version = "0.0.0", 4 | .dependencies = .{ 5 | .android = .{ 6 | .path = "../..", 7 | }, 8 | .sdl2 = .{ 9 | .path = "third-party/sdl2", 10 | }, 11 | }, 12 | .paths = .{ 13 | "build.zig", 14 | "build.zig.zon", 15 | "src", 16 | }, 17 | .fingerprint = 0x168fc6b9a7d0df48, 18 | } 19 | -------------------------------------------------------------------------------- /examples/sdl2/src/sdl-zig-demo.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | const builtin = @import("builtin"); 3 | const android = @import("android"); 4 | const sdl = @import("sdl"); 5 | 6 | const log = std.log; 7 | const assert = std.debug.assert; 8 | 9 | /// custom standard options for Android 10 | pub const std_options: std.Options = if (builtin.abi.isAndroid()) 11 | .{ 12 | .logFn = android.logFn, 13 | } 14 | else 15 | .{}; 16 | 17 | /// custom panic handler for Android 18 | pub const panic = if (builtin.abi.isAndroid()) 19 | android.panic 20 | else 21 | std.debug.FullPanic(std.debug.defaultPanic); 22 | 23 | comptime { 24 | 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()) { 32 | _ = std.start.callMain(); 33 | } else { 34 | @compileError("SDL_main should not be called outside of Android builds"); 35 | } 36 | } 37 | 38 | pub fn main() !void { 39 | log.debug("started sdl-zig-demo", .{}); 40 | 41 | if (sdl.SDL_Init(sdl.SDL_INIT_VIDEO) < 0) { 42 | log.info("Unable to initialize SDL: {s}", .{sdl.SDL_GetError()}); 43 | return error.SDLInitializationFailed; 44 | } 45 | defer sdl.SDL_Quit(); 46 | 47 | const screen = sdl.SDL_CreateWindow("My Game Window", sdl.SDL_WINDOWPOS_UNDEFINED, sdl.SDL_WINDOWPOS_UNDEFINED, 400, 140, sdl.SDL_WINDOW_OPENGL) orelse { 48 | log.info("Unable to create window: {s}", .{sdl.SDL_GetError()}); 49 | return error.SDLInitializationFailed; 50 | }; 51 | defer sdl.SDL_DestroyWindow(screen); 52 | 53 | const renderer = sdl.SDL_CreateRenderer(screen, -1, 0) orelse { 54 | log.info("Unable to create renderer: {s}", .{sdl.SDL_GetError()}); 55 | return error.SDLInitializationFailed; 56 | }; 57 | defer sdl.SDL_DestroyRenderer(renderer); 58 | 59 | const zig_bmp = @embedFile("zig.bmp"); 60 | const rw = sdl.SDL_RWFromConstMem(zig_bmp, zig_bmp.len) orelse { 61 | log.info("Unable to get RWFromConstMem: {s}", .{sdl.SDL_GetError()}); 62 | return error.SDLInitializationFailed; 63 | }; 64 | defer assert(sdl.SDL_RWclose(rw) == 0); 65 | 66 | const zig_surface = sdl.SDL_LoadBMP_RW(rw, 0) orelse { 67 | log.info("Unable to load bmp: {s}", .{sdl.SDL_GetError()}); 68 | return error.SDLInitializationFailed; 69 | }; 70 | defer sdl.SDL_FreeSurface(zig_surface); 71 | 72 | const zig_texture = sdl.SDL_CreateTextureFromSurface(renderer, zig_surface) orelse { 73 | log.info("Unable to create texture from surface: {s}", .{sdl.SDL_GetError()}); 74 | return error.SDLInitializationFailed; 75 | }; 76 | defer sdl.SDL_DestroyTexture(zig_texture); 77 | 78 | var quit = false; 79 | var has_run_frame: FrameLog = .none; 80 | while (!quit) { 81 | if (has_run_frame == .one_frame_passed) { 82 | // NOTE(jae): 2024-10-03 83 | // Allow inspection of logs to see if a frame executed at least once 84 | log.debug("has executed one frame", .{}); 85 | has_run_frame = .logged_one_frame; 86 | } 87 | var event: sdl.SDL_Event = undefined; 88 | while (sdl.SDL_PollEvent(&event) != 0) { 89 | switch (event.type) { 90 | sdl.SDL_QUIT => { 91 | quit = true; 92 | }, 93 | else => {}, 94 | } 95 | } 96 | 97 | _ = sdl.SDL_RenderClear(renderer); 98 | _ = sdl.SDL_RenderCopy(renderer, zig_texture, null, null); 99 | sdl.SDL_RenderPresent(renderer); 100 | sdl.SDL_Delay(17); 101 | if (has_run_frame == .none) { 102 | has_run_frame = .one_frame_passed; 103 | } 104 | } 105 | } 106 | 107 | const FrameLog = enum { 108 | none, 109 | one_frame_passed, 110 | logged_one_frame, 111 | }; 112 | -------------------------------------------------------------------------------- /examples/sdl2/src/zig.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/silbinarywolf/zig-android-sdk/1ed383662bcd56d00a11079641f598b712a0599d/examples/sdl2/src/zig.bmp -------------------------------------------------------------------------------- /examples/sdl2/third-party/sdl2/build.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | const builtin = @import("builtin"); 3 | 4 | pub fn build(b: *std.Build) !void { 5 | const target = b.standardTargetOptions(.{}); 6 | const optimize = b.standardOptimizeOption(.{}); 7 | 8 | const sdl_dep = b.dependency("sdl2", .{}); 9 | const sdl_path = sdl_dep.path(""); 10 | const sdl_include_path = sdl_path.path(b, "include"); 11 | 12 | const is_shared_library = target.result.abi.isAndroid(); // NOTE(jae): 2024-09-22: Android uses shared library as SDL2 loads it as part of SDLActivity.java 13 | const lib = if (!is_shared_library) b.addStaticLibrary(.{ 14 | .name = "SDL2", 15 | .target = target, 16 | .optimize = optimize, 17 | .link_libc = true, 18 | }) else b.addSharedLibrary(.{ 19 | .name = "SDL2", 20 | .target = target, 21 | .optimize = optimize, 22 | .link_libc = true, 23 | }); 24 | 25 | lib.addCSourceFiles(.{ 26 | .root = sdl_path, 27 | .files = &generic_src_files, 28 | }); 29 | lib.root_module.addCMacro("SDL_USE_BUILTIN_OPENGL_DEFINITIONS", "1"); 30 | 31 | var sdl_config_header: ?*std.Build.Step.ConfigHeader = null; 32 | switch (target.result.os.tag) { 33 | .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 | 38 | lib.addCSourceFiles(.{ 39 | .root = sdl_path, 40 | .files = &windows_src_files, 41 | }); 42 | lib.linkSystemLibrary("setupapi"); 43 | lib.linkSystemLibrary("winmm"); 44 | lib.linkSystemLibrary("gdi32"); 45 | lib.linkSystemLibrary("imm32"); 46 | lib.linkSystemLibrary("version"); 47 | lib.linkSystemLibrary("oleaut32"); 48 | lib.linkSystemLibrary("ole32"); 49 | }, 50 | .macos => { 51 | // NOTE(jae): 2024-07-07 52 | // Cross-compilation from Linux to Mac requires more effort currently (Zig 0.13.0) 53 | // See: https://github.com/ziglang/zig/issues/1349 54 | 55 | lib.addCSourceFiles(.{ 56 | .root = sdl_path, 57 | .files = &darwin_src_files, 58 | }); 59 | lib.addCSourceFiles(.{ 60 | .root = sdl_path, 61 | .files = &objective_c_src_files, 62 | .flags = &.{"-fobjc-arc"}, 63 | }); 64 | lib.linkFramework("OpenGL"); 65 | lib.linkFramework("Metal"); 66 | lib.linkFramework("CoreVideo"); 67 | lib.linkFramework("Cocoa"); 68 | lib.linkFramework("IOKit"); 69 | lib.linkFramework("ForceFeedback"); 70 | lib.linkFramework("Carbon"); 71 | lib.linkFramework("CoreAudio"); 72 | lib.linkFramework("AudioToolbox"); 73 | lib.linkFramework("AVFoundation"); 74 | lib.linkFramework("Foundation"); 75 | lib.linkFramework("GameController"); 76 | lib.linkFramework("CoreHaptics"); 77 | }, 78 | else => { 79 | if (target.result.abi.isAndroid()) { 80 | lib.root_module.addCSourceFiles(.{ 81 | .root = sdl_path, 82 | .files = &android_src_files, 83 | }); 84 | // NOTE(jae): 2024-09-22 85 | // Build settings taken from: SDL2-2.32.2/src/hidapi/android/jni/Android.mk 86 | // SDLActivity.java by default expects to be able to load this library 87 | lib.root_module.addCSourceFiles(.{ 88 | .root = sdl_path, 89 | .files = &[_][]const u8{ 90 | "src/hidapi/android/hid.cpp", 91 | }, 92 | .flags = &.{"-std=c++11"}, 93 | }); 94 | lib.linkLibCpp(); 95 | 96 | // This is needed for "src/render/opengles/SDL_render_gles.c" to compile 97 | lib.root_module.addCMacro("GL_GLEXT_PROTOTYPES", "1"); 98 | 99 | // Add Java files to dependency 100 | const java_dir = sdl_dep.path("android-project/app/src/main/java/org/libsdl/app"); 101 | const java_files: []const []const u8 = &.{ 102 | "SDL.java", 103 | "SDLSurface.java", 104 | "SDLActivity.java", 105 | "SDLAudioManager.java", 106 | "SDLControllerManager.java", 107 | "HIDDevice.java", 108 | "HIDDeviceUSB.java", 109 | "HIDDeviceManager.java", 110 | "HIDDeviceBLESteamController.java", 111 | }; 112 | const java_write_files = b.addNamedWriteFiles("sdljava"); 113 | for (java_files) |java_file_basename| { 114 | _ = java_write_files.addCopyFile(java_dir.path(b, java_file_basename), java_file_basename); 115 | } 116 | 117 | // https://github.com/libsdl-org/SDL/blob/release-2.30.6/Android.mk#L82C62-L82C69 118 | lib.linkSystemLibrary("dl"); 119 | lib.linkSystemLibrary("GLESv1_CM"); 120 | lib.linkSystemLibrary("GLESv2"); 121 | lib.linkSystemLibrary("OpenSLES"); 122 | lib.linkSystemLibrary("log"); 123 | lib.linkSystemLibrary("android"); 124 | 125 | // SDLActivity.java's getMainFunction defines the entrypoint as "SDL_main" 126 | // So your main / root file will need something like this for Android 127 | // 128 | // fn android_sdl_main() callconv(.C) void { 129 | // _ = std.start.callMain(); 130 | // } 131 | // comptime { 132 | // if (builtin.abi.isAndroid()) @export(&android_sdl_main, .{ .name = "SDL_main", .linkage = .strong }); 133 | // } 134 | } else { 135 | const config_header = b.addConfigHeader(.{ 136 | .style = .{ .cmake = sdl_include_path.path(b, "SDL_config.h.cmake") }, 137 | .include_path = "SDL/SDL_config.h", 138 | }, .{}); 139 | sdl_config_header = config_header; 140 | 141 | lib.addConfigHeader(config_header); 142 | lib.installConfigHeader(config_header); 143 | } 144 | }, 145 | } 146 | // NOTE(jae): 2024-07-07 147 | // This must come *after* addConfigHeader logic above for per-OS so that the include for SDL_config.h takes precedence 148 | lib.addIncludePath(sdl_include_path); 149 | // NOTE(jae): 2024-04-07 150 | // Not installing header as we include/export it from the module 151 | // lib.installHeadersDirectory("include", "SDL"); 152 | b.installArtifact(lib); 153 | 154 | var sdl_c_module = b.addTranslateC(.{ 155 | .target = target, 156 | .optimize = .ReleaseFast, 157 | .root_source_file = b.path("src/sdl.h"), 158 | }); 159 | if (sdl_config_header) |config_header| { 160 | sdl_c_module.addConfigHeader(config_header); 161 | } 162 | sdl_c_module.addIncludePath(sdl_include_path); 163 | 164 | _ = b.addModule("sdl", .{ 165 | .target = target, 166 | .optimize = optimize, 167 | .root_source_file = sdl_c_module.getOutput(), 168 | }); 169 | } 170 | 171 | const generic_src_files = [_][]const u8{ 172 | "src/SDL.c", 173 | "src/SDL_assert.c", 174 | "src/SDL_dataqueue.c", 175 | "src/SDL_error.c", 176 | "src/SDL_guid.c", 177 | "src/SDL_hints.c", 178 | "src/SDL_list.c", 179 | "src/SDL_log.c", 180 | "src/SDL_utils.c", 181 | "src/atomic/SDL_atomic.c", 182 | "src/atomic/SDL_spinlock.c", 183 | "src/audio/SDL_audio.c", 184 | "src/audio/SDL_audiocvt.c", 185 | "src/audio/SDL_audiodev.c", 186 | "src/audio/SDL_audiotypecvt.c", 187 | "src/audio/SDL_mixer.c", 188 | "src/audio/SDL_wave.c", 189 | "src/cpuinfo/SDL_cpuinfo.c", 190 | "src/dynapi/SDL_dynapi.c", 191 | "src/events/SDL_clipboardevents.c", 192 | "src/events/SDL_displayevents.c", 193 | "src/events/SDL_dropevents.c", 194 | "src/events/SDL_events.c", 195 | "src/events/SDL_gesture.c", 196 | "src/events/SDL_keyboard.c", 197 | "src/events/SDL_keysym_to_scancode.c", 198 | "src/events/SDL_mouse.c", 199 | "src/events/SDL_quit.c", 200 | "src/events/SDL_scancode_tables.c", 201 | "src/events/SDL_touch.c", 202 | "src/events/SDL_windowevents.c", 203 | "src/events/imKStoUCS.c", 204 | "src/file/SDL_rwops.c", 205 | "src/haptic/SDL_haptic.c", 206 | "src/hidapi/SDL_hidapi.c", 207 | 208 | "src/joystick/SDL_gamecontroller.c", 209 | "src/joystick/SDL_joystick.c", 210 | "src/joystick/controller_type.c", 211 | "src/joystick/virtual/SDL_virtualjoystick.c", 212 | "src/joystick/SDL_steam_virtual_gamepad.c", 213 | 214 | "src/libm/e_atan2.c", 215 | "src/libm/e_exp.c", 216 | "src/libm/e_fmod.c", 217 | "src/libm/e_log.c", 218 | "src/libm/e_log10.c", 219 | "src/libm/e_pow.c", 220 | "src/libm/e_rem_pio2.c", 221 | "src/libm/e_sqrt.c", 222 | "src/libm/k_cos.c", 223 | "src/libm/k_rem_pio2.c", 224 | "src/libm/k_sin.c", 225 | "src/libm/k_tan.c", 226 | "src/libm/s_atan.c", 227 | "src/libm/s_copysign.c", 228 | "src/libm/s_cos.c", 229 | "src/libm/s_fabs.c", 230 | "src/libm/s_floor.c", 231 | "src/libm/s_scalbn.c", 232 | "src/libm/s_sin.c", 233 | "src/libm/s_tan.c", 234 | "src/locale/SDL_locale.c", 235 | "src/misc/SDL_url.c", 236 | "src/power/SDL_power.c", 237 | "src/render/SDL_d3dmath.c", 238 | "src/render/SDL_render.c", 239 | "src/render/SDL_yuv_sw.c", 240 | "src/sensor/SDL_sensor.c", 241 | "src/stdlib/SDL_crc16.c", 242 | "src/stdlib/SDL_crc32.c", 243 | "src/stdlib/SDL_getenv.c", 244 | "src/stdlib/SDL_iconv.c", 245 | "src/stdlib/SDL_malloc.c", 246 | "src/stdlib/SDL_mslibc.c", 247 | "src/stdlib/SDL_qsort.c", 248 | "src/stdlib/SDL_stdlib.c", 249 | "src/stdlib/SDL_string.c", 250 | "src/stdlib/SDL_strtokr.c", 251 | "src/thread/SDL_thread.c", 252 | "src/timer/SDL_timer.c", 253 | "src/video/SDL_RLEaccel.c", 254 | "src/video/SDL_blit.c", 255 | "src/video/SDL_blit_0.c", 256 | "src/video/SDL_blit_1.c", 257 | "src/video/SDL_blit_A.c", 258 | "src/video/SDL_blit_N.c", 259 | "src/video/SDL_blit_auto.c", 260 | "src/video/SDL_blit_copy.c", 261 | "src/video/SDL_blit_slow.c", 262 | "src/video/SDL_bmp.c", 263 | "src/video/SDL_clipboard.c", 264 | "src/video/SDL_egl.c", 265 | "src/video/SDL_fillrect.c", 266 | "src/video/SDL_pixels.c", 267 | "src/video/SDL_rect.c", 268 | "src/video/SDL_shape.c", 269 | "src/video/SDL_stretch.c", 270 | "src/video/SDL_surface.c", 271 | "src/video/SDL_video.c", 272 | "src/video/SDL_vulkan_utils.c", 273 | "src/video/SDL_yuv.c", 274 | 275 | "src/video/yuv2rgb/yuv_rgb_std.c", 276 | "src/video/yuv2rgb/yuv_rgb_sse.c", 277 | 278 | "src/video/dummy/SDL_nullevents.c", 279 | "src/video/dummy/SDL_nullframebuffer.c", 280 | "src/video/dummy/SDL_nullvideo.c", 281 | 282 | "src/render/software/SDL_blendfillrect.c", 283 | "src/render/software/SDL_blendline.c", 284 | "src/render/software/SDL_blendpoint.c", 285 | "src/render/software/SDL_drawline.c", 286 | "src/render/software/SDL_drawpoint.c", 287 | "src/render/software/SDL_render_sw.c", 288 | "src/render/software/SDL_rotate.c", 289 | "src/render/software/SDL_triangle.c", 290 | 291 | "src/audio/dummy/SDL_dummyaudio.c", 292 | 293 | "src/joystick/hidapi/SDL_hidapi_combined.c", 294 | "src/joystick/hidapi/SDL_hidapi_gamecube.c", 295 | "src/joystick/hidapi/SDL_hidapi_luna.c", 296 | "src/joystick/hidapi/SDL_hidapi_ps3.c", 297 | "src/joystick/hidapi/SDL_hidapi_ps4.c", 298 | "src/joystick/hidapi/SDL_hidapi_ps5.c", 299 | "src/joystick/hidapi/SDL_hidapi_rumble.c", 300 | "src/joystick/hidapi/SDL_hidapi_shield.c", 301 | "src/joystick/hidapi/SDL_hidapi_stadia.c", 302 | "src/joystick/hidapi/SDL_hidapi_steam.c", 303 | "src/joystick/hidapi/SDL_hidapi_switch.c", 304 | "src/joystick/hidapi/SDL_hidapi_wii.c", 305 | "src/joystick/hidapi/SDL_hidapi_xbox360.c", 306 | "src/joystick/hidapi/SDL_hidapi_xbox360w.c", 307 | "src/joystick/hidapi/SDL_hidapi_xboxone.c", 308 | "src/joystick/hidapi/SDL_hidapijoystick.c", 309 | "src/joystick/hidapi/SDL_hidapi_steamdeck.c", 310 | }; 311 | 312 | // https://github.com/libsdl-org/SDL/blob/release-2.30.6/Android.mk#L17 313 | const android_src_files = [_][]const u8{ 314 | "src/core/android/SDL_android.c", 315 | 316 | "src/audio/android/SDL_androidaudio.c", 317 | "src/audio/openslES/SDL_openslES.c", 318 | "src/audio/aaudio/SDL_aaudio.c", 319 | 320 | "src/haptic/android/SDL_syshaptic.c", 321 | "src/joystick/android/SDL_sysjoystick.c", 322 | "src/locale/android/SDL_syslocale.c", 323 | "src/misc/android/SDL_sysurl.c", 324 | "src/power/android/SDL_syspower.c", 325 | "src/filesystem/android/SDL_sysfilesystem.c", 326 | "src/sensor/android/SDL_androidsensor.c", 327 | 328 | "src/timer/unix/SDL_systimer.c", 329 | "src/loadso/dlopen/SDL_sysloadso.c", 330 | 331 | "src/thread/pthread/SDL_syscond.c", 332 | "src/thread/pthread/SDL_sysmutex.c", 333 | "src/thread/pthread/SDL_syssem.c", 334 | "src/thread/pthread/SDL_systhread.c", 335 | "src/thread/pthread/SDL_systls.c", 336 | "src/render/opengles/SDL_render_gles.c", // use of undeclared identifier: glCheckFramebufferStatusOES 337 | "src/render/opengles2/SDL_render_gles2.c", 338 | "src/render/opengles2/SDL_shaders_gles2.c", 339 | 340 | "src/video/android/SDL_androidclipboard.c", 341 | "src/video/android/SDL_androidevents.c", 342 | "src/video/android/SDL_androidgl.c", 343 | "src/video/android/SDL_androidkeyboard.c", 344 | "src/video/android/SDL_androidmessagebox.c", 345 | "src/video/android/SDL_androidmouse.c", 346 | "src/video/android/SDL_androidtouch.c", 347 | "src/video/android/SDL_androidvideo.c", 348 | "src/video/android/SDL_androidvulkan.c", 349 | "src/video/android/SDL_androidwindow.c", 350 | }; 351 | 352 | const windows_src_files = [_][]const u8{ 353 | "src/core/windows/SDL_hid.c", 354 | "src/core/windows/SDL_immdevice.c", 355 | "src/core/windows/SDL_windows.c", 356 | "src/core/windows/SDL_xinput.c", 357 | "src/filesystem/windows/SDL_sysfilesystem.c", 358 | "src/haptic/windows/SDL_dinputhaptic.c", 359 | "src/haptic/windows/SDL_windowshaptic.c", 360 | "src/haptic/windows/SDL_xinputhaptic.c", 361 | "src/hidapi/windows/hid.c", 362 | "src/joystick/windows/SDL_dinputjoystick.c", 363 | "src/joystick/windows/SDL_rawinputjoystick.c", 364 | // This can be enabled when Zig updates to the next mingw-w64 release, 365 | // which will make the headers gain `windows.gaming.input.h`. 366 | // Also revert the patch 2c79fd8fd04f1e5045cbe5978943b0aea7593110. 367 | "src/joystick/windows/SDL_windows_gaming_input.c", // note: previously didnt work 368 | "src/joystick/windows/SDL_windowsjoystick.c", 369 | "src/joystick/windows/SDL_xinputjoystick.c", 370 | 371 | "src/loadso/windows/SDL_sysloadso.c", 372 | "src/locale/windows/SDL_syslocale.c", 373 | "src/main/windows/SDL_windows_main.c", 374 | "src/misc/windows/SDL_sysurl.c", 375 | "src/power/windows/SDL_syspower.c", 376 | "src/sensor/windows/SDL_windowssensor.c", 377 | "src/timer/windows/SDL_systimer.c", 378 | "src/video/windows/SDL_windowsclipboard.c", 379 | "src/video/windows/SDL_windowsevents.c", 380 | "src/video/windows/SDL_windowsframebuffer.c", 381 | "src/video/windows/SDL_windowskeyboard.c", 382 | "src/video/windows/SDL_windowsmessagebox.c", 383 | "src/video/windows/SDL_windowsmodes.c", 384 | "src/video/windows/SDL_windowsmouse.c", 385 | "src/video/windows/SDL_windowsopengl.c", 386 | "src/video/windows/SDL_windowsopengles.c", 387 | "src/video/windows/SDL_windowsshape.c", 388 | "src/video/windows/SDL_windowsvideo.c", 389 | "src/video/windows/SDL_windowsvulkan.c", 390 | "src/video/windows/SDL_windowswindow.c", 391 | 392 | "src/thread/windows/SDL_syscond_cv.c", 393 | "src/thread/windows/SDL_sysmutex.c", 394 | "src/thread/windows/SDL_syssem.c", 395 | "src/thread/windows/SDL_systhread.c", 396 | "src/thread/windows/SDL_systls.c", 397 | "src/thread/generic/SDL_syscond.c", 398 | 399 | "src/render/direct3d/SDL_render_d3d.c", 400 | "src/render/direct3d/SDL_shaders_d3d.c", 401 | "src/render/direct3d11/SDL_render_d3d11.c", 402 | "src/render/direct3d11/SDL_shaders_d3d11.c", 403 | "src/render/direct3d12/SDL_render_d3d12.c", 404 | "src/render/direct3d12/SDL_shaders_d3d12.c", 405 | 406 | "src/audio/directsound/SDL_directsound.c", 407 | "src/audio/wasapi/SDL_wasapi.c", 408 | "src/audio/wasapi/SDL_wasapi_win32.c", 409 | "src/audio/winmm/SDL_winmm.c", 410 | "src/audio/disk/SDL_diskaudio.c", 411 | 412 | "src/render/opengl/SDL_render_gl.c", 413 | "src/render/opengl/SDL_shaders_gl.c", 414 | "src/render/opengles/SDL_render_gles.c", 415 | "src/render/opengles2/SDL_render_gles2.c", 416 | "src/render/opengles2/SDL_shaders_gles2.c", 417 | }; 418 | 419 | const linux_src_files = [_][]const u8{ 420 | "src/core/linux/SDL_dbus.c", 421 | "src/core/linux/SDL_evdev.c", 422 | "src/core/linux/SDL_evdev_capabilities.c", 423 | "src/core/linux/SDL_evdev_kbd.c", 424 | "src/core/linux/SDL_fcitx.c", 425 | "src/core/linux/SDL_ibus.c", 426 | "src/core/linux/SDL_ime.c", 427 | "src/core/linux/SDL_sandbox.c", 428 | "src/core/linux/SDL_threadprio.c", 429 | "src/core/linux/SDL_udev.c", 430 | 431 | // "src/haptic/linux/SDL_syshaptic.c", 432 | "src/haptic/dummy/SDL_syshaptic.c", 433 | 434 | "src/hidapi/linux/hid.c", 435 | 436 | "src/locale/unix/SDL_syslocale.c", 437 | 438 | // "src/filesystem/unix/SDL_sysfilesystem.c", 439 | "src/filesystem/dummy/SDL_sysfilesystem.c", 440 | 441 | "src/misc/dummy/SDL_sysurl.c", 442 | 443 | "src/joystick/linux/SDL_sysjoystick.c", 444 | "src/joystick/dummy/SDL_sysjoystick.c", // required with default SDL_config.h 445 | 446 | "src/power/linux/SDL_syspower.c", 447 | 448 | "src/timer/unix/SDL_systimer.c", 449 | "src/core/unix/SDL_poll.c", 450 | 451 | "src/sensor/dummy/SDL_dummysensor.c", 452 | 453 | "src/loadso/dlopen/SDL_sysloadso.c", 454 | 455 | "src/thread/pthread/SDL_syscond.c", 456 | "src/thread/pthread/SDL_sysmutex.c", 457 | "src/thread/pthread/SDL_syssem.c", 458 | "src/thread/pthread/SDL_systhread.c", 459 | "src/thread/pthread/SDL_systls.c", 460 | 461 | "src/video/wayland/SDL_waylandclipboard.c", 462 | "src/video/wayland/SDL_waylanddatamanager.c", 463 | "src/video/wayland/SDL_waylanddyn.c", 464 | "src/video/wayland/SDL_waylandevents.c", 465 | "src/video/wayland/SDL_waylandkeyboard.c", 466 | "src/video/wayland/SDL_waylandmessagebox.c", 467 | "src/video/wayland/SDL_waylandmouse.c", 468 | "src/video/wayland/SDL_waylandopengles.c", 469 | "src/video/wayland/SDL_waylandtouch.c", 470 | "src/video/wayland/SDL_waylandvideo.c", 471 | "src/video/wayland/SDL_waylandvulkan.c", 472 | "src/video/wayland/SDL_waylandwindow.c", 473 | 474 | "src/video/x11/SDL_x11clipboard.c", 475 | "src/video/x11/SDL_x11dyn.c", 476 | "src/video/x11/SDL_x11events.c", 477 | "src/video/x11/SDL_x11framebuffer.c", 478 | "src/video/x11/SDL_x11keyboard.c", 479 | "src/video/x11/SDL_x11messagebox.c", 480 | "src/video/x11/SDL_x11modes.c", 481 | "src/video/x11/SDL_x11mouse.c", 482 | "src/video/x11/SDL_x11opengl.c", 483 | "src/video/x11/SDL_x11opengles.c", 484 | "src/video/x11/SDL_x11shape.c", 485 | "src/video/x11/SDL_x11touch.c", 486 | "src/video/x11/SDL_x11video.c", 487 | "src/video/x11/SDL_x11vulkan.c", 488 | "src/video/x11/SDL_x11window.c", 489 | "src/video/x11/SDL_x11xfixes.c", 490 | "src/video/x11/SDL_x11xinput2.c", 491 | "src/video/x11/edid-parse.c", 492 | 493 | "src/audio/alsa/SDL_alsa_audio.c", 494 | "src/audio/jack/SDL_jackaudio.c", 495 | "src/audio/pulseaudio/SDL_pulseaudio.c", 496 | }; 497 | 498 | const darwin_src_files = [_][]const u8{ 499 | "src/haptic/darwin/SDL_syshaptic.c", 500 | "src/joystick/darwin/SDL_iokitjoystick.c", 501 | "src/power/macosx/SDL_syspower.c", 502 | "src/timer/unix/SDL_systimer.c", 503 | "src/loadso/dlopen/SDL_sysloadso.c", 504 | "src/audio/disk/SDL_diskaudio.c", 505 | "src/render/opengl/SDL_render_gl.c", 506 | "src/render/opengl/SDL_shaders_gl.c", 507 | "src/render/opengles/SDL_render_gles.c", 508 | "src/render/opengles2/SDL_render_gles2.c", 509 | "src/render/opengles2/SDL_shaders_gles2.c", 510 | "src/sensor/dummy/SDL_dummysensor.c", 511 | 512 | "src/thread/pthread/SDL_syscond.c", 513 | "src/thread/pthread/SDL_sysmutex.c", 514 | "src/thread/pthread/SDL_syssem.c", 515 | "src/thread/pthread/SDL_systhread.c", 516 | "src/thread/pthread/SDL_systls.c", 517 | }; 518 | 519 | const objective_c_src_files = [_][]const u8{ 520 | "src/audio/coreaudio/SDL_coreaudio.m", 521 | "src/file/cocoa/SDL_rwopsbundlesupport.m", 522 | "src/filesystem/cocoa/SDL_sysfilesystem.m", 523 | "src/joystick/iphoneos/SDL_mfijoystick.m", 524 | //"src/hidapi/testgui/mac_support_cocoa.m", 525 | // This appears to be for SDL3 only. 526 | //"src/joystick/apple/SDL_mfijoystick.m", 527 | "src/locale/macosx/SDL_syslocale.m", 528 | "src/misc/macosx/SDL_sysurl.m", 529 | "src/power/uikit/SDL_syspower.m", 530 | "src/render/metal/SDL_render_metal.m", 531 | "src/sensor/coremotion/SDL_coremotionsensor.m", 532 | "src/video/cocoa/SDL_cocoaclipboard.m", 533 | "src/video/cocoa/SDL_cocoaevents.m", 534 | "src/video/cocoa/SDL_cocoakeyboard.m", 535 | "src/video/cocoa/SDL_cocoamessagebox.m", 536 | "src/video/cocoa/SDL_cocoametalview.m", 537 | "src/video/cocoa/SDL_cocoamodes.m", 538 | "src/video/cocoa/SDL_cocoamouse.m", 539 | "src/video/cocoa/SDL_cocoaopengl.m", 540 | "src/video/cocoa/SDL_cocoaopengles.m", 541 | "src/video/cocoa/SDL_cocoashape.m", 542 | "src/video/cocoa/SDL_cocoavideo.m", 543 | "src/video/cocoa/SDL_cocoavulkan.m", 544 | "src/video/cocoa/SDL_cocoawindow.m", 545 | "src/video/uikit/SDL_uikitappdelegate.m", 546 | "src/video/uikit/SDL_uikitclipboard.m", 547 | "src/video/uikit/SDL_uikitevents.m", 548 | "src/video/uikit/SDL_uikitmessagebox.m", 549 | "src/video/uikit/SDL_uikitmetalview.m", 550 | "src/video/uikit/SDL_uikitmodes.m", 551 | "src/video/uikit/SDL_uikitopengles.m", 552 | "src/video/uikit/SDL_uikitopenglview.m", 553 | "src/video/uikit/SDL_uikitvideo.m", 554 | "src/video/uikit/SDL_uikitview.m", 555 | "src/video/uikit/SDL_uikitviewcontroller.m", 556 | "src/video/uikit/SDL_uikitvulkan.m", 557 | "src/video/uikit/SDL_uikitwindow.m", 558 | }; 559 | 560 | const ios_src_files = [_][]const u8{ 561 | "src/hidapi/ios/hid.m", 562 | "src/misc/ios/SDL_sysurl.m", 563 | "src/joystick/iphoneos/SDL_mfijoystick.m", 564 | }; 565 | 566 | const emscripten_src_files = [_][]const u8{ 567 | "src/audio/emscripten/SDL_emscriptenaudio.c", 568 | "src/filesystem/emscripten/SDL_sysfilesystem.c", 569 | "src/joystick/emscripten/SDL_sysjoystick.c", 570 | "src/locale/emscripten/SDL_syslocale.c", 571 | "src/misc/emscripten/SDL_sysurl.c", 572 | "src/power/emscripten/SDL_syspower.c", 573 | "src/video/emscripten/SDL_emscriptenevents.c", 574 | "src/video/emscripten/SDL_emscriptenframebuffer.c", 575 | "src/video/emscripten/SDL_emscriptenmouse.c", 576 | "src/video/emscripten/SDL_emscriptenopengles.c", 577 | "src/video/emscripten/SDL_emscriptenvideo.c", 578 | 579 | "src/timer/unix/SDL_systimer.c", 580 | "src/loadso/dlopen/SDL_sysloadso.c", 581 | "src/audio/disk/SDL_diskaudio.c", 582 | "src/render/opengles2/SDL_render_gles2.c", 583 | "src/render/opengles2/SDL_shaders_gles2.c", 584 | "src/sensor/dummy/SDL_dummysensor.c", 585 | 586 | "src/thread/pthread/SDL_syscond.c", 587 | "src/thread/pthread/SDL_sysmutex.c", 588 | "src/thread/pthread/SDL_syssem.c", 589 | "src/thread/pthread/SDL_systhread.c", 590 | "src/thread/pthread/SDL_systls.c", 591 | }; 592 | 593 | const unknown_src_files = [_][]const u8{ 594 | "src/thread/generic/SDL_syscond.c", 595 | "src/thread/generic/SDL_sysmutex.c", 596 | "src/thread/generic/SDL_syssem.c", 597 | "src/thread/generic/SDL_systhread.c", 598 | "src/thread/generic/SDL_systls.c", 599 | 600 | "src/audio/arts/SDL_artsaudio.c", 601 | "src/audio/dsp/SDL_dspaudio.c", 602 | // "src/audio/emscripten/SDL_emscriptenaudio.c", 603 | "src/audio/esd/SDL_esdaudio.c", 604 | "src/audio/fusionsound/SDL_fsaudio.c", 605 | "src/audio/n3ds/SDL_n3dsaudio.c", 606 | "src/audio/nacl/SDL_naclaudio.c", 607 | "src/audio/nas/SDL_nasaudio.c", 608 | "src/audio/netbsd/SDL_netbsdaudio.c", 609 | "src/audio/openslES/SDL_openslES.c", 610 | "src/audio/os2/SDL_os2audio.c", 611 | "src/audio/paudio/SDL_paudio.c", 612 | "src/audio/pipewire/SDL_pipewire.c", 613 | "src/audio/ps2/SDL_ps2audio.c", 614 | "src/audio/psp/SDL_pspaudio.c", 615 | "src/audio/qsa/SDL_qsa_audio.c", 616 | "src/audio/sndio/SDL_sndioaudio.c", 617 | "src/audio/sun/SDL_sunaudio.c", 618 | "src/audio/vita/SDL_vitaaudio.c", 619 | 620 | "src/core/android/SDL_android.c", 621 | "src/core/freebsd/SDL_evdev_kbd_freebsd.c", 622 | "src/core/openbsd/SDL_wscons_kbd.c", 623 | "src/core/openbsd/SDL_wscons_mouse.c", 624 | "src/core/os2/SDL_os2.c", 625 | "src/core/os2/geniconv/geniconv.c", 626 | "src/core/os2/geniconv/os2cp.c", 627 | "src/core/os2/geniconv/os2iconv.c", 628 | "src/core/os2/geniconv/sys2utf8.c", 629 | "src/core/os2/geniconv/test.c", 630 | "src/core/unix/SDL_poll.c", 631 | 632 | "src/file/n3ds/SDL_rwopsromfs.c", 633 | 634 | "src/filesystem/android/SDL_sysfilesystem.c", 635 | // "src/filesystem/emscripten/SDL_sysfilesystem.c", 636 | "src/filesystem/n3ds/SDL_sysfilesystem.c", 637 | "src/filesystem/nacl/SDL_sysfilesystem.c", 638 | "src/filesystem/os2/SDL_sysfilesystem.c", 639 | "src/filesystem/ps2/SDL_sysfilesystem.c", 640 | "src/filesystem/psp/SDL_sysfilesystem.c", 641 | "src/filesystem/riscos/SDL_sysfilesystem.c", 642 | "src/filesystem/unix/SDL_sysfilesystem.c", 643 | "src/filesystem/vita/SDL_sysfilesystem.c", 644 | 645 | "src/haptic/android/SDL_syshaptic.c", 646 | "src/haptic/dummy/SDL_syshaptic.c", 647 | 648 | "src/hidapi/libusb/hid.c", 649 | "src/hidapi/mac/hid.c", 650 | 651 | "src/joystick/android/SDL_sysjoystick.c", 652 | "src/joystick/bsd/SDL_bsdjoystick.c", 653 | "src/joystick/dummy/SDL_sysjoystick.c", 654 | // "src/joystick/emscripten/SDL_sysjoystick.c", 655 | "src/joystick/n3ds/SDL_sysjoystick.c", 656 | "src/joystick/os2/SDL_os2joystick.c", 657 | "src/joystick/ps2/SDL_sysjoystick.c", 658 | "src/joystick/psp/SDL_sysjoystick.c", 659 | "src/joystick/steam/SDL_steamcontroller.c", 660 | "src/joystick/vita/SDL_sysjoystick.c", 661 | 662 | "src/loadso/dummy/SDL_sysloadso.c", 663 | "src/loadso/os2/SDL_sysloadso.c", 664 | 665 | "src/locale/android/SDL_syslocale.c", 666 | "src/locale/dummy/SDL_syslocale.c", 667 | // "src/locale/emscripten/SDL_syslocale.c", 668 | "src/locale/n3ds/SDL_syslocale.c", 669 | "src/locale/unix/SDL_syslocale.c", 670 | "src/locale/vita/SDL_syslocale.c", 671 | "src/locale/winrt/SDL_syslocale.c", 672 | 673 | "src/main/android/SDL_android_main.c", 674 | "src/main/dummy/SDL_dummy_main.c", 675 | "src/main/gdk/SDL_gdk_main.c", 676 | "src/main/n3ds/SDL_n3ds_main.c", 677 | "src/main/nacl/SDL_nacl_main.c", 678 | "src/main/ps2/SDL_ps2_main.c", 679 | "src/main/psp/SDL_psp_main.c", 680 | "src/main/uikit/SDL_uikit_main.c", 681 | 682 | "src/misc/android/SDL_sysurl.c", 683 | "src/misc/dummy/SDL_sysurl.c", 684 | // "src/misc/emscripten/SDL_sysurl.c", 685 | "src/misc/riscos/SDL_sysurl.c", 686 | "src/misc/unix/SDL_sysurl.c", 687 | "src/misc/vita/SDL_sysurl.c", 688 | 689 | "src/power/android/SDL_syspower.c", 690 | // "src/power/emscripten/SDL_syspower.c", 691 | "src/power/haiku/SDL_syspower.c", 692 | "src/power/n3ds/SDL_syspower.c", 693 | "src/power/psp/SDL_syspower.c", 694 | "src/power/vita/SDL_syspower.c", 695 | 696 | "src/sensor/android/SDL_androidsensor.c", 697 | "src/sensor/n3ds/SDL_n3dssensor.c", 698 | "src/sensor/vita/SDL_vitasensor.c", 699 | 700 | "src/test/SDL_test_assert.c", 701 | "src/test/SDL_test_common.c", 702 | "src/test/SDL_test_compare.c", 703 | "src/test/SDL_test_crc32.c", 704 | "src/test/SDL_test_font.c", 705 | "src/test/SDL_test_fuzzer.c", 706 | "src/test/SDL_test_harness.c", 707 | "src/test/SDL_test_imageBlit.c", 708 | "src/test/SDL_test_imageBlitBlend.c", 709 | "src/test/SDL_test_imageFace.c", 710 | "src/test/SDL_test_imagePrimitives.c", 711 | "src/test/SDL_test_imagePrimitivesBlend.c", 712 | "src/test/SDL_test_log.c", 713 | "src/test/SDL_test_md5.c", 714 | "src/test/SDL_test_memory.c", 715 | "src/test/SDL_test_random.c", 716 | 717 | "src/thread/n3ds/SDL_syscond.c", 718 | "src/thread/n3ds/SDL_sysmutex.c", 719 | "src/thread/n3ds/SDL_syssem.c", 720 | "src/thread/n3ds/SDL_systhread.c", 721 | "src/thread/os2/SDL_sysmutex.c", 722 | "src/thread/os2/SDL_syssem.c", 723 | "src/thread/os2/SDL_systhread.c", 724 | "src/thread/os2/SDL_systls.c", 725 | "src/thread/ps2/SDL_syssem.c", 726 | "src/thread/ps2/SDL_systhread.c", 727 | "src/thread/psp/SDL_syscond.c", 728 | "src/thread/psp/SDL_sysmutex.c", 729 | "src/thread/psp/SDL_syssem.c", 730 | "src/thread/psp/SDL_systhread.c", 731 | "src/thread/vita/SDL_syscond.c", 732 | "src/thread/vita/SDL_sysmutex.c", 733 | "src/thread/vita/SDL_syssem.c", 734 | "src/thread/vita/SDL_systhread.c", 735 | 736 | "src/timer/dummy/SDL_systimer.c", 737 | "src/timer/haiku/SDL_systimer.c", 738 | "src/timer/n3ds/SDL_systimer.c", 739 | "src/timer/os2/SDL_systimer.c", 740 | "src/timer/ps2/SDL_systimer.c", 741 | "src/timer/psp/SDL_systimer.c", 742 | "src/timer/vita/SDL_systimer.c", 743 | 744 | "src/video/android/SDL_androidclipboard.c", 745 | "src/video/android/SDL_androidevents.c", 746 | "src/video/android/SDL_androidgl.c", 747 | "src/video/android/SDL_androidkeyboard.c", 748 | "src/video/android/SDL_androidmessagebox.c", 749 | "src/video/android/SDL_androidmouse.c", 750 | "src/video/android/SDL_androidtouch.c", 751 | "src/video/android/SDL_androidvideo.c", 752 | "src/video/android/SDL_androidvulkan.c", 753 | "src/video/android/SDL_androidwindow.c", 754 | "src/video/directfb/SDL_DirectFB_WM.c", 755 | "src/video/directfb/SDL_DirectFB_dyn.c", 756 | "src/video/directfb/SDL_DirectFB_events.c", 757 | "src/video/directfb/SDL_DirectFB_modes.c", 758 | "src/video/directfb/SDL_DirectFB_mouse.c", 759 | "src/video/directfb/SDL_DirectFB_opengl.c", 760 | "src/video/directfb/SDL_DirectFB_render.c", 761 | "src/video/directfb/SDL_DirectFB_shape.c", 762 | "src/video/directfb/SDL_DirectFB_video.c", 763 | "src/video/directfb/SDL_DirectFB_vulkan.c", 764 | "src/video/directfb/SDL_DirectFB_window.c", 765 | // "src/video/emscripten/SDL_emscriptenevents.c", 766 | // "src/video/emscripten/SDL_emscriptenframebuffer.c", 767 | // "src/video/emscripten/SDL_emscriptenmouse.c", 768 | // "src/video/emscripten/SDL_emscriptenopengles.c", 769 | // "src/video/emscripten/SDL_emscriptenvideo.c", 770 | "src/video/kmsdrm/SDL_kmsdrmdyn.c", 771 | "src/video/kmsdrm/SDL_kmsdrmevents.c", 772 | "src/video/kmsdrm/SDL_kmsdrmmouse.c", 773 | "src/video/kmsdrm/SDL_kmsdrmopengles.c", 774 | "src/video/kmsdrm/SDL_kmsdrmvideo.c", 775 | "src/video/kmsdrm/SDL_kmsdrmvulkan.c", 776 | "src/video/n3ds/SDL_n3dsevents.c", 777 | "src/video/n3ds/SDL_n3dsframebuffer.c", 778 | "src/video/n3ds/SDL_n3dsswkb.c", 779 | "src/video/n3ds/SDL_n3dstouch.c", 780 | "src/video/n3ds/SDL_n3dsvideo.c", 781 | "src/video/nacl/SDL_naclevents.c", 782 | "src/video/nacl/SDL_naclglue.c", 783 | "src/video/nacl/SDL_naclopengles.c", 784 | "src/video/nacl/SDL_naclvideo.c", 785 | "src/video/nacl/SDL_naclwindow.c", 786 | "src/video/offscreen/SDL_offscreenevents.c", 787 | "src/video/offscreen/SDL_offscreenframebuffer.c", 788 | "src/video/offscreen/SDL_offscreenopengles.c", 789 | "src/video/offscreen/SDL_offscreenvideo.c", 790 | "src/video/offscreen/SDL_offscreenwindow.c", 791 | "src/video/os2/SDL_os2dive.c", 792 | "src/video/os2/SDL_os2messagebox.c", 793 | "src/video/os2/SDL_os2mouse.c", 794 | "src/video/os2/SDL_os2util.c", 795 | "src/video/os2/SDL_os2video.c", 796 | "src/video/os2/SDL_os2vman.c", 797 | "src/video/pandora/SDL_pandora.c", 798 | "src/video/pandora/SDL_pandora_events.c", 799 | "src/video/ps2/SDL_ps2video.c", 800 | "src/video/psp/SDL_pspevents.c", 801 | "src/video/psp/SDL_pspgl.c", 802 | "src/video/psp/SDL_pspmouse.c", 803 | "src/video/psp/SDL_pspvideo.c", 804 | "src/video/qnx/gl.c", 805 | "src/video/qnx/keyboard.c", 806 | "src/video/qnx/video.c", 807 | "src/video/raspberry/SDL_rpievents.c", 808 | "src/video/raspberry/SDL_rpimouse.c", 809 | "src/video/raspberry/SDL_rpiopengles.c", 810 | "src/video/raspberry/SDL_rpivideo.c", 811 | "src/video/riscos/SDL_riscosevents.c", 812 | "src/video/riscos/SDL_riscosframebuffer.c", 813 | "src/video/riscos/SDL_riscosmessagebox.c", 814 | "src/video/riscos/SDL_riscosmodes.c", 815 | "src/video/riscos/SDL_riscosmouse.c", 816 | "src/video/riscos/SDL_riscosvideo.c", 817 | "src/video/riscos/SDL_riscoswindow.c", 818 | "src/video/vita/SDL_vitaframebuffer.c", 819 | "src/video/vita/SDL_vitagl_pvr.c", 820 | "src/video/vita/SDL_vitagles.c", 821 | "src/video/vita/SDL_vitagles_pvr.c", 822 | "src/video/vita/SDL_vitakeyboard.c", 823 | "src/video/vita/SDL_vitamessagebox.c", 824 | "src/video/vita/SDL_vitamouse.c", 825 | "src/video/vita/SDL_vitatouch.c", 826 | "src/video/vita/SDL_vitavideo.c", 827 | "src/video/vivante/SDL_vivanteopengles.c", 828 | "src/video/vivante/SDL_vivanteplatform.c", 829 | "src/video/vivante/SDL_vivantevideo.c", 830 | "src/video/vivante/SDL_vivantevulkan.c", 831 | 832 | "src/render/opengl/SDL_render_gl.c", 833 | "src/render/opengl/SDL_shaders_gl.c", 834 | "src/render/opengles/SDL_render_gles.c", 835 | "src/render/opengles2/SDL_render_gles2.c", 836 | "src/render/opengles2/SDL_shaders_gles2.c", 837 | "src/render/ps2/SDL_render_ps2.c", 838 | "src/render/psp/SDL_render_psp.c", 839 | "src/render/vitagxm/SDL_render_vita_gxm.c", 840 | "src/render/vitagxm/SDL_render_vita_gxm_memory.c", 841 | "src/render/vitagxm/SDL_render_vita_gxm_tools.c", 842 | }; 843 | -------------------------------------------------------------------------------- /examples/sdl2/third-party/sdl2/build.zig.zon: -------------------------------------------------------------------------------- 1 | .{ 2 | .name = "sdl", 3 | .version = "0.0.0", 4 | .dependencies = .{ 5 | .sdl2 = .{ 6 | // NOTE(jae): 2024-06-30 7 | // Using ".zip" as "tar.gz" fails on Windows for Zig 0.13.0 due to symlink issue with something in the android folders 8 | .url = "https://github.com/libsdl-org/SDL/archive/refs/tags/release-2.32.2.zip", 9 | .hash = "12204a4a9e9f41fc906decd762be78b9e80de65a7bdec428aa0dfdf03f46e7614d9e", 10 | }, 11 | }, 12 | .paths = .{ 13 | "build.zig", 14 | "build.zig.zon", 15 | "src", 16 | }, 17 | } 18 | -------------------------------------------------------------------------------- /examples/sdl2/third-party/sdl2/src/sdl.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /examples/sdl2/third-party/sdl2/upstream/any-windows-any/README.txt: -------------------------------------------------------------------------------- 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. 3 | -------------------------------------------------------------------------------- /examples/sdl2/third-party/sdl2/upstream/any-windows-any/eventtoken.h: -------------------------------------------------------------------------------- 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 8 | #include 9 | #endif 10 | 11 | #ifndef COM_NO_WINDOWS_H 12 | #include 13 | #include 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__ */ 50 | -------------------------------------------------------------------------------- /examples/sdl2/third-party/sdl2/upstream/any-windows-any/ivectorchangedeventargs.h: -------------------------------------------------------------------------------- 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 8 | #include 9 | #endif 10 | 11 | #ifndef COM_NO_WINDOWS_H 12 | #include 13 | #include 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 49 | #include 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__ */ 240 | -------------------------------------------------------------------------------- /examples/sdl2/third-party/sdl2/upstream/any-windows-any/windows.devices.power.h: -------------------------------------------------------------------------------- 1 | /*** Autogenerated by WIDL 8.21 from include/windows.devices.power.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 8 | #include 9 | #endif 10 | 11 | #ifndef COM_NO_WINDOWS_H 12 | #include 13 | #include 14 | #endif 15 | 16 | #ifndef __windows_devices_power_h__ 17 | #define __windows_devices_power_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_CDevices_CPower_CIBatteryReport_FWD_DEFINED__ 30 | #define ____x_ABI_CWindows_CDevices_CPower_CIBatteryReport_FWD_DEFINED__ 31 | typedef interface __x_ABI_CWindows_CDevices_CPower_CIBatteryReport __x_ABI_CWindows_CDevices_CPower_CIBatteryReport; 32 | #ifdef __cplusplus 33 | #define __x_ABI_CWindows_CDevices_CPower_CIBatteryReport ABI::Windows::Devices::Power::IBatteryReport 34 | namespace ABI { 35 | namespace Windows { 36 | namespace Devices { 37 | namespace Power { 38 | interface IBatteryReport; 39 | } 40 | } 41 | } 42 | } 43 | #endif /* __cplusplus */ 44 | #endif 45 | 46 | #ifndef ____x_ABI_CWindows_CDevices_CPower_CBatteryReport_FWD_DEFINED__ 47 | #define ____x_ABI_CWindows_CDevices_CPower_CBatteryReport_FWD_DEFINED__ 48 | #ifdef __cplusplus 49 | namespace ABI { 50 | namespace Windows { 51 | namespace Devices { 52 | namespace Power { 53 | class BatteryReport; 54 | } 55 | } 56 | } 57 | } 58 | #else 59 | typedef struct __x_ABI_CWindows_CDevices_CPower_CBatteryReport __x_ABI_CWindows_CDevices_CPower_CBatteryReport; 60 | #endif /* defined __cplusplus */ 61 | #endif /* defined ____x_ABI_CWindows_CDevices_CPower_CBatteryReport_FWD_DEFINED__ */ 62 | 63 | /* Headers for imported files */ 64 | 65 | #include 66 | #include 67 | #include 68 | 69 | #ifdef __cplusplus 70 | extern "C" { 71 | #endif 72 | 73 | #ifndef ____x_ABI_CWindows_CDevices_CPower_CIBatteryReport_FWD_DEFINED__ 74 | #define ____x_ABI_CWindows_CDevices_CPower_CIBatteryReport_FWD_DEFINED__ 75 | typedef interface __x_ABI_CWindows_CDevices_CPower_CIBatteryReport __x_ABI_CWindows_CDevices_CPower_CIBatteryReport; 76 | #ifdef __cplusplus 77 | #define __x_ABI_CWindows_CDevices_CPower_CIBatteryReport ABI::Windows::Devices::Power::IBatteryReport 78 | namespace ABI { 79 | namespace Windows { 80 | namespace Devices { 81 | namespace Power { 82 | interface IBatteryReport; 83 | } 84 | } 85 | } 86 | } 87 | #endif /* __cplusplus */ 88 | #endif 89 | 90 | /***************************************************************************** 91 | * IBatteryReport interface 92 | */ 93 | #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 94 | #ifndef ____x_ABI_CWindows_CDevices_CPower_CIBatteryReport_INTERFACE_DEFINED__ 95 | #define ____x_ABI_CWindows_CDevices_CPower_CIBatteryReport_INTERFACE_DEFINED__ 96 | 97 | DEFINE_GUID(IID___x_ABI_CWindows_CDevices_CPower_CIBatteryReport, 0xc9858c3a, 0x4e13, 0x420a, 0xa8,0xd0, 0x24,0xf1,0x8f,0x39,0x54,0x01); 98 | #if defined(__cplusplus) && !defined(CINTERFACE) 99 | } /* extern "C" */ 100 | namespace ABI { 101 | namespace Windows { 102 | namespace Devices { 103 | namespace Power { 104 | MIDL_INTERFACE("c9858c3a-4e13-420a-a8d0-24f18f395401") 105 | IBatteryReport : public IInspectable 106 | { 107 | virtual HRESULT STDMETHODCALLTYPE get_ChargeRateInMilliwatts( 108 | ABI::Windows::Foundation::IReference **value) = 0; 109 | 110 | virtual HRESULT STDMETHODCALLTYPE get_DesignCapacityInMilliwattHours( 111 | ABI::Windows::Foundation::IReference **value) = 0; 112 | 113 | virtual HRESULT STDMETHODCALLTYPE get_FullChargeCapacityInMilliwattHours( 114 | ABI::Windows::Foundation::IReference **value) = 0; 115 | 116 | virtual HRESULT STDMETHODCALLTYPE get_RemainingCapacityInMilliwattHours( 117 | ABI::Windows::Foundation::IReference **value) = 0; 118 | 119 | virtual HRESULT STDMETHODCALLTYPE get_Status( 120 | enum BatteryStatus *value) = 0; 121 | 122 | }; 123 | } 124 | } 125 | } 126 | } 127 | extern "C" { 128 | #ifdef __CRT_UUID_DECL 129 | __CRT_UUID_DECL(__x_ABI_CWindows_CDevices_CPower_CIBatteryReport, 0xc9858c3a, 0x4e13, 0x420a, 0xa8,0xd0, 0x24,0xf1,0x8f,0x39,0x54,0x01) 130 | #endif 131 | #else 132 | typedef struct __x_ABI_CWindows_CDevices_CPower_CIBatteryReportVtbl { 133 | BEGIN_INTERFACE 134 | 135 | /*** IUnknown methods ***/ 136 | HRESULT (STDMETHODCALLTYPE *QueryInterface)( 137 | __x_ABI_CWindows_CDevices_CPower_CIBatteryReport *This, 138 | REFIID riid, 139 | void **ppvObject); 140 | 141 | ULONG (STDMETHODCALLTYPE *AddRef)( 142 | __x_ABI_CWindows_CDevices_CPower_CIBatteryReport *This); 143 | 144 | ULONG (STDMETHODCALLTYPE *Release)( 145 | __x_ABI_CWindows_CDevices_CPower_CIBatteryReport *This); 146 | 147 | /*** IInspectable methods ***/ 148 | HRESULT (STDMETHODCALLTYPE *GetIids)( 149 | __x_ABI_CWindows_CDevices_CPower_CIBatteryReport *This, 150 | ULONG *iidCount, 151 | IID **iids); 152 | 153 | HRESULT (STDMETHODCALLTYPE *GetRuntimeClassName)( 154 | __x_ABI_CWindows_CDevices_CPower_CIBatteryReport *This, 155 | HSTRING *className); 156 | 157 | HRESULT (STDMETHODCALLTYPE *GetTrustLevel)( 158 | __x_ABI_CWindows_CDevices_CPower_CIBatteryReport *This, 159 | TrustLevel *trustLevel); 160 | 161 | /*** IBatteryReport methods ***/ 162 | HRESULT (STDMETHODCALLTYPE *get_ChargeRateInMilliwatts)( 163 | __x_ABI_CWindows_CDevices_CPower_CIBatteryReport *This, 164 | __FIReference_1_INT32 **value); 165 | 166 | HRESULT (STDMETHODCALLTYPE *get_DesignCapacityInMilliwattHours)( 167 | __x_ABI_CWindows_CDevices_CPower_CIBatteryReport *This, 168 | __FIReference_1_INT32 **value); 169 | 170 | HRESULT (STDMETHODCALLTYPE *get_FullChargeCapacityInMilliwattHours)( 171 | __x_ABI_CWindows_CDevices_CPower_CIBatteryReport *This, 172 | __FIReference_1_INT32 **value); 173 | 174 | HRESULT (STDMETHODCALLTYPE *get_RemainingCapacityInMilliwattHours)( 175 | __x_ABI_CWindows_CDevices_CPower_CIBatteryReport *This, 176 | __FIReference_1_INT32 **value); 177 | 178 | HRESULT (STDMETHODCALLTYPE *get_Status)( 179 | __x_ABI_CWindows_CDevices_CPower_CIBatteryReport *This, 180 | enum __x_ABI_CWindows_CSystem_CPower_CBatteryStatus *value); 181 | 182 | END_INTERFACE 183 | } __x_ABI_CWindows_CDevices_CPower_CIBatteryReportVtbl; 184 | 185 | interface __x_ABI_CWindows_CDevices_CPower_CIBatteryReport { 186 | CONST_VTBL __x_ABI_CWindows_CDevices_CPower_CIBatteryReportVtbl* lpVtbl; 187 | }; 188 | 189 | #ifdef COBJMACROS 190 | #ifndef WIDL_C_INLINE_WRAPPERS 191 | /*** IUnknown methods ***/ 192 | #define __x_ABI_CWindows_CDevices_CPower_CIBatteryReport_QueryInterface(This,riid,ppvObject) (This)->lpVtbl->QueryInterface(This,riid,ppvObject) 193 | #define __x_ABI_CWindows_CDevices_CPower_CIBatteryReport_AddRef(This) (This)->lpVtbl->AddRef(This) 194 | #define __x_ABI_CWindows_CDevices_CPower_CIBatteryReport_Release(This) (This)->lpVtbl->Release(This) 195 | /*** IInspectable methods ***/ 196 | #define __x_ABI_CWindows_CDevices_CPower_CIBatteryReport_GetIids(This,iidCount,iids) (This)->lpVtbl->GetIids(This,iidCount,iids) 197 | #define __x_ABI_CWindows_CDevices_CPower_CIBatteryReport_GetRuntimeClassName(This,className) (This)->lpVtbl->GetRuntimeClassName(This,className) 198 | #define __x_ABI_CWindows_CDevices_CPower_CIBatteryReport_GetTrustLevel(This,trustLevel) (This)->lpVtbl->GetTrustLevel(This,trustLevel) 199 | /*** IBatteryReport methods ***/ 200 | #define __x_ABI_CWindows_CDevices_CPower_CIBatteryReport_get_ChargeRateInMilliwatts(This,value) (This)->lpVtbl->get_ChargeRateInMilliwatts(This,value) 201 | #define __x_ABI_CWindows_CDevices_CPower_CIBatteryReport_get_DesignCapacityInMilliwattHours(This,value) (This)->lpVtbl->get_DesignCapacityInMilliwattHours(This,value) 202 | #define __x_ABI_CWindows_CDevices_CPower_CIBatteryReport_get_FullChargeCapacityInMilliwattHours(This,value) (This)->lpVtbl->get_FullChargeCapacityInMilliwattHours(This,value) 203 | #define __x_ABI_CWindows_CDevices_CPower_CIBatteryReport_get_RemainingCapacityInMilliwattHours(This,value) (This)->lpVtbl->get_RemainingCapacityInMilliwattHours(This,value) 204 | #define __x_ABI_CWindows_CDevices_CPower_CIBatteryReport_get_Status(This,value) (This)->lpVtbl->get_Status(This,value) 205 | #else 206 | /*** IUnknown methods ***/ 207 | static __WIDL_INLINE HRESULT __x_ABI_CWindows_CDevices_CPower_CIBatteryReport_QueryInterface(__x_ABI_CWindows_CDevices_CPower_CIBatteryReport* This,REFIID riid,void **ppvObject) { 208 | return This->lpVtbl->QueryInterface(This,riid,ppvObject); 209 | } 210 | static __WIDL_INLINE ULONG __x_ABI_CWindows_CDevices_CPower_CIBatteryReport_AddRef(__x_ABI_CWindows_CDevices_CPower_CIBatteryReport* This) { 211 | return This->lpVtbl->AddRef(This); 212 | } 213 | static __WIDL_INLINE ULONG __x_ABI_CWindows_CDevices_CPower_CIBatteryReport_Release(__x_ABI_CWindows_CDevices_CPower_CIBatteryReport* This) { 214 | return This->lpVtbl->Release(This); 215 | } 216 | /*** IInspectable methods ***/ 217 | static __WIDL_INLINE HRESULT __x_ABI_CWindows_CDevices_CPower_CIBatteryReport_GetIids(__x_ABI_CWindows_CDevices_CPower_CIBatteryReport* This,ULONG *iidCount,IID **iids) { 218 | return This->lpVtbl->GetIids(This,iidCount,iids); 219 | } 220 | static __WIDL_INLINE HRESULT __x_ABI_CWindows_CDevices_CPower_CIBatteryReport_GetRuntimeClassName(__x_ABI_CWindows_CDevices_CPower_CIBatteryReport* This,HSTRING *className) { 221 | return This->lpVtbl->GetRuntimeClassName(This,className); 222 | } 223 | static __WIDL_INLINE HRESULT __x_ABI_CWindows_CDevices_CPower_CIBatteryReport_GetTrustLevel(__x_ABI_CWindows_CDevices_CPower_CIBatteryReport* This,TrustLevel *trustLevel) { 224 | return This->lpVtbl->GetTrustLevel(This,trustLevel); 225 | } 226 | /*** IBatteryReport methods ***/ 227 | static __WIDL_INLINE HRESULT __x_ABI_CWindows_CDevices_CPower_CIBatteryReport_get_ChargeRateInMilliwatts(__x_ABI_CWindows_CDevices_CPower_CIBatteryReport* This,__FIReference_1_INT32 **value) { 228 | return This->lpVtbl->get_ChargeRateInMilliwatts(This,value); 229 | } 230 | static __WIDL_INLINE HRESULT __x_ABI_CWindows_CDevices_CPower_CIBatteryReport_get_DesignCapacityInMilliwattHours(__x_ABI_CWindows_CDevices_CPower_CIBatteryReport* This,__FIReference_1_INT32 **value) { 231 | return This->lpVtbl->get_DesignCapacityInMilliwattHours(This,value); 232 | } 233 | static __WIDL_INLINE HRESULT __x_ABI_CWindows_CDevices_CPower_CIBatteryReport_get_FullChargeCapacityInMilliwattHours(__x_ABI_CWindows_CDevices_CPower_CIBatteryReport* This,__FIReference_1_INT32 **value) { 234 | return This->lpVtbl->get_FullChargeCapacityInMilliwattHours(This,value); 235 | } 236 | static __WIDL_INLINE HRESULT __x_ABI_CWindows_CDevices_CPower_CIBatteryReport_get_RemainingCapacityInMilliwattHours(__x_ABI_CWindows_CDevices_CPower_CIBatteryReport* This,__FIReference_1_INT32 **value) { 237 | return This->lpVtbl->get_RemainingCapacityInMilliwattHours(This,value); 238 | } 239 | static __WIDL_INLINE HRESULT __x_ABI_CWindows_CDevices_CPower_CIBatteryReport_get_Status(__x_ABI_CWindows_CDevices_CPower_CIBatteryReport* This,enum __x_ABI_CWindows_CSystem_CPower_CBatteryStatus *value) { 240 | return This->lpVtbl->get_Status(This,value); 241 | } 242 | #endif 243 | #ifdef WIDL_using_Windows_Devices_Power 244 | #define IID_IBatteryReport IID___x_ABI_CWindows_CDevices_CPower_CIBatteryReport 245 | #define IBatteryReportVtbl __x_ABI_CWindows_CDevices_CPower_CIBatteryReportVtbl 246 | #define IBatteryReport __x_ABI_CWindows_CDevices_CPower_CIBatteryReport 247 | #define IBatteryReport_QueryInterface __x_ABI_CWindows_CDevices_CPower_CIBatteryReport_QueryInterface 248 | #define IBatteryReport_AddRef __x_ABI_CWindows_CDevices_CPower_CIBatteryReport_AddRef 249 | #define IBatteryReport_Release __x_ABI_CWindows_CDevices_CPower_CIBatteryReport_Release 250 | #define IBatteryReport_GetIids __x_ABI_CWindows_CDevices_CPower_CIBatteryReport_GetIids 251 | #define IBatteryReport_GetRuntimeClassName __x_ABI_CWindows_CDevices_CPower_CIBatteryReport_GetRuntimeClassName 252 | #define IBatteryReport_GetTrustLevel __x_ABI_CWindows_CDevices_CPower_CIBatteryReport_GetTrustLevel 253 | #define IBatteryReport_get_ChargeRateInMilliwatts __x_ABI_CWindows_CDevices_CPower_CIBatteryReport_get_ChargeRateInMilliwatts 254 | #define IBatteryReport_get_DesignCapacityInMilliwattHours __x_ABI_CWindows_CDevices_CPower_CIBatteryReport_get_DesignCapacityInMilliwattHours 255 | #define IBatteryReport_get_FullChargeCapacityInMilliwattHours __x_ABI_CWindows_CDevices_CPower_CIBatteryReport_get_FullChargeCapacityInMilliwattHours 256 | #define IBatteryReport_get_RemainingCapacityInMilliwattHours __x_ABI_CWindows_CDevices_CPower_CIBatteryReport_get_RemainingCapacityInMilliwattHours 257 | #define IBatteryReport_get_Status __x_ABI_CWindows_CDevices_CPower_CIBatteryReport_get_Status 258 | #endif /* WIDL_using_Windows_Devices_Power */ 259 | #endif 260 | 261 | #endif 262 | 263 | #endif /* ____x_ABI_CWindows_CDevices_CPower_CIBatteryReport_INTERFACE_DEFINED__ */ 264 | #endif /* WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 */ 265 | 266 | /* 267 | * Class Windows.Devices.Power.BatteryReport 268 | */ 269 | #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 270 | #ifndef RUNTIMECLASS_Windows_Devices_Power_BatteryReport_DEFINED 271 | #define RUNTIMECLASS_Windows_Devices_Power_BatteryReport_DEFINED 272 | #if !defined(_MSC_VER) && !defined(__MINGW32__) 273 | static const WCHAR RuntimeClass_Windows_Devices_Power_BatteryReport[] = {'W','i','n','d','o','w','s','.','D','e','v','i','c','e','s','.','P','o','w','e','r','.','B','a','t','t','e','r','y','R','e','p','o','r','t',0}; 274 | #elif defined(__GNUC__) && !defined(__cplusplus) 275 | const DECLSPEC_SELECTANY WCHAR RuntimeClass_Windows_Devices_Power_BatteryReport[] = L"Windows.Devices.Power.BatteryReport"; 276 | #else 277 | extern const DECLSPEC_SELECTANY WCHAR RuntimeClass_Windows_Devices_Power_BatteryReport[] = {'W','i','n','d','o','w','s','.','D','e','v','i','c','e','s','.','P','o','w','e','r','.','B','a','t','t','e','r','y','R','e','p','o','r','t',0}; 278 | #endif 279 | #endif /* RUNTIMECLASS_Windows_Devices_Power_BatteryReport_DEFINED */ 280 | #endif /* WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 */ 281 | 282 | /* Begin additional prototypes for all interfaces */ 283 | 284 | 285 | /* End additional prototypes */ 286 | 287 | #ifdef __cplusplus 288 | } 289 | #endif 290 | 291 | #endif /* __windows_devices_power_h__ */ 292 | -------------------------------------------------------------------------------- /examples/sdl2/third-party/sdl2/upstream/any-windows-any/windows.foundation.numerics.h: -------------------------------------------------------------------------------- 1 | /*** Autogenerated by WIDL 8.21 from include/windows.foundation.numerics.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 8 | #include 9 | #endif 10 | 11 | #ifndef COM_NO_WINDOWS_H 12 | #include 13 | #include 14 | #endif 15 | 16 | #ifndef __windows_foundation_numerics_h__ 17 | #define __windows_foundation_numerics_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 ____FIReference_1_Matrix4x4_FWD_DEFINED__ 30 | #define ____FIReference_1_Matrix4x4_FWD_DEFINED__ 31 | typedef interface __FIReference_1_Matrix4x4 __FIReference_1_Matrix4x4; 32 | #ifdef __cplusplus 33 | #define __FIReference_1_Matrix4x4 ABI::Windows::Foundation::IReference 34 | #endif /* __cplusplus */ 35 | #endif 36 | 37 | #ifndef ____FIReference_1_Vector2_FWD_DEFINED__ 38 | #define ____FIReference_1_Vector2_FWD_DEFINED__ 39 | typedef interface __FIReference_1_Vector2 __FIReference_1_Vector2; 40 | #ifdef __cplusplus 41 | #define __FIReference_1_Vector2 ABI::Windows::Foundation::IReference 42 | #endif /* __cplusplus */ 43 | #endif 44 | 45 | #ifndef ____FIReference_1_Vector3_FWD_DEFINED__ 46 | #define ____FIReference_1_Vector3_FWD_DEFINED__ 47 | typedef interface __FIReference_1_Vector3 __FIReference_1_Vector3; 48 | #ifdef __cplusplus 49 | #define __FIReference_1_Vector3 ABI::Windows::Foundation::IReference 50 | #endif /* __cplusplus */ 51 | #endif 52 | 53 | /* Headers for imported files */ 54 | 55 | #include 56 | #include 57 | #include 58 | #include 59 | #include 60 | 61 | #ifdef __cplusplus 62 | extern "C" { 63 | #endif 64 | 65 | #ifndef __cplusplus 66 | typedef struct __x_ABI_CWindows_CFoundation_CNumerics_CMatrix3x2 __x_ABI_CWindows_CFoundation_CNumerics_CMatrix3x2; 67 | #else /* __cplusplus */ 68 | namespace ABI { 69 | namespace Windows { 70 | namespace Foundation { 71 | namespace Numerics { 72 | typedef struct Matrix3x2 Matrix3x2; 73 | } 74 | } 75 | } 76 | } 77 | #endif /* __cplusplus */ 78 | 79 | #ifndef __cplusplus 80 | typedef struct __x_ABI_CWindows_CFoundation_CNumerics_CMatrix4x4 __x_ABI_CWindows_CFoundation_CNumerics_CMatrix4x4; 81 | #else /* __cplusplus */ 82 | namespace ABI { 83 | namespace Windows { 84 | namespace Foundation { 85 | namespace Numerics { 86 | typedef struct Matrix4x4 Matrix4x4; 87 | } 88 | } 89 | } 90 | } 91 | #endif /* __cplusplus */ 92 | 93 | #ifndef __cplusplus 94 | typedef struct __x_ABI_CWindows_CFoundation_CNumerics_CPlane __x_ABI_CWindows_CFoundation_CNumerics_CPlane; 95 | #else /* __cplusplus */ 96 | namespace ABI { 97 | namespace Windows { 98 | namespace Foundation { 99 | namespace Numerics { 100 | typedef struct Plane Plane; 101 | } 102 | } 103 | } 104 | } 105 | #endif /* __cplusplus */ 106 | 107 | #ifndef __cplusplus 108 | typedef struct __x_ABI_CWindows_CFoundation_CNumerics_CQuaternion __x_ABI_CWindows_CFoundation_CNumerics_CQuaternion; 109 | #else /* __cplusplus */ 110 | namespace ABI { 111 | namespace Windows { 112 | namespace Foundation { 113 | namespace Numerics { 114 | typedef struct Quaternion Quaternion; 115 | } 116 | } 117 | } 118 | } 119 | #endif /* __cplusplus */ 120 | 121 | #ifndef __cplusplus 122 | typedef struct __x_ABI_CWindows_CFoundation_CNumerics_CVector2 __x_ABI_CWindows_CFoundation_CNumerics_CVector2; 123 | #else /* __cplusplus */ 124 | namespace ABI { 125 | namespace Windows { 126 | namespace Foundation { 127 | namespace Numerics { 128 | typedef struct Vector2 Vector2; 129 | } 130 | } 131 | } 132 | } 133 | #endif /* __cplusplus */ 134 | 135 | #ifndef __cplusplus 136 | typedef struct __x_ABI_CWindows_CFoundation_CNumerics_CVector3 __x_ABI_CWindows_CFoundation_CNumerics_CVector3; 137 | #else /* __cplusplus */ 138 | namespace ABI { 139 | namespace Windows { 140 | namespace Foundation { 141 | namespace Numerics { 142 | typedef struct Vector3 Vector3; 143 | } 144 | } 145 | } 146 | } 147 | #endif /* __cplusplus */ 148 | 149 | #ifndef __cplusplus 150 | typedef struct __x_ABI_CWindows_CFoundation_CNumerics_CVector4 __x_ABI_CWindows_CFoundation_CNumerics_CVector4; 151 | #else /* __cplusplus */ 152 | namespace ABI { 153 | namespace Windows { 154 | namespace Foundation { 155 | namespace Numerics { 156 | typedef struct Vector4 Vector4; 157 | } 158 | } 159 | } 160 | } 161 | #endif /* __cplusplus */ 162 | 163 | #ifndef ____FIReference_1_Matrix4x4_FWD_DEFINED__ 164 | #define ____FIReference_1_Matrix4x4_FWD_DEFINED__ 165 | typedef interface __FIReference_1_Matrix4x4 __FIReference_1_Matrix4x4; 166 | #ifdef __cplusplus 167 | #define __FIReference_1_Matrix4x4 ABI::Windows::Foundation::IReference 168 | #endif /* __cplusplus */ 169 | #endif 170 | 171 | #ifndef ____FIReference_1_Vector2_FWD_DEFINED__ 172 | #define ____FIReference_1_Vector2_FWD_DEFINED__ 173 | typedef interface __FIReference_1_Vector2 __FIReference_1_Vector2; 174 | #ifdef __cplusplus 175 | #define __FIReference_1_Vector2 ABI::Windows::Foundation::IReference 176 | #endif /* __cplusplus */ 177 | #endif 178 | 179 | #ifndef ____FIReference_1_Vector3_FWD_DEFINED__ 180 | #define ____FIReference_1_Vector3_FWD_DEFINED__ 181 | typedef interface __FIReference_1_Vector3 __FIReference_1_Vector3; 182 | #ifdef __cplusplus 183 | #define __FIReference_1_Vector3 ABI::Windows::Foundation::IReference 184 | #endif /* __cplusplus */ 185 | #endif 186 | 187 | #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 188 | #ifdef __cplusplus 189 | } /* extern "C" */ 190 | namespace ABI { 191 | namespace Windows { 192 | namespace Foundation { 193 | namespace Numerics { 194 | struct Matrix3x2 { 195 | FLOAT M11; 196 | FLOAT M12; 197 | FLOAT M21; 198 | FLOAT M22; 199 | FLOAT M31; 200 | FLOAT M32; 201 | }; 202 | } 203 | } 204 | } 205 | } 206 | extern "C" { 207 | #else 208 | struct __x_ABI_CWindows_CFoundation_CNumerics_CMatrix3x2 { 209 | FLOAT M11; 210 | FLOAT M12; 211 | FLOAT M21; 212 | FLOAT M22; 213 | FLOAT M31; 214 | FLOAT M32; 215 | }; 216 | #ifdef WIDL_using_Windows_Foundation_Numerics 217 | #define Matrix3x2 __x_ABI_CWindows_CFoundation_CNumerics_CMatrix3x2 218 | #endif /* WIDL_using_Windows_Foundation_Numerics */ 219 | #endif 220 | 221 | #endif /* WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 */ 222 | #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 223 | #ifdef __cplusplus 224 | } /* extern "C" */ 225 | namespace ABI { 226 | namespace Windows { 227 | namespace Foundation { 228 | namespace Numerics { 229 | struct Matrix4x4 { 230 | FLOAT M11; 231 | FLOAT M12; 232 | FLOAT M13; 233 | FLOAT M14; 234 | FLOAT M21; 235 | FLOAT M22; 236 | FLOAT M23; 237 | FLOAT M24; 238 | FLOAT M31; 239 | FLOAT M32; 240 | FLOAT M33; 241 | FLOAT M34; 242 | FLOAT M41; 243 | FLOAT M42; 244 | FLOAT M43; 245 | FLOAT M44; 246 | }; 247 | } 248 | } 249 | } 250 | } 251 | extern "C" { 252 | #else 253 | struct __x_ABI_CWindows_CFoundation_CNumerics_CMatrix4x4 { 254 | FLOAT M11; 255 | FLOAT M12; 256 | FLOAT M13; 257 | FLOAT M14; 258 | FLOAT M21; 259 | FLOAT M22; 260 | FLOAT M23; 261 | FLOAT M24; 262 | FLOAT M31; 263 | FLOAT M32; 264 | FLOAT M33; 265 | FLOAT M34; 266 | FLOAT M41; 267 | FLOAT M42; 268 | FLOAT M43; 269 | FLOAT M44; 270 | }; 271 | #ifdef WIDL_using_Windows_Foundation_Numerics 272 | #define Matrix4x4 __x_ABI_CWindows_CFoundation_CNumerics_CMatrix4x4 273 | #endif /* WIDL_using_Windows_Foundation_Numerics */ 274 | #endif 275 | 276 | #endif /* WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 */ 277 | #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 278 | #ifdef __cplusplus 279 | } /* extern "C" */ 280 | namespace ABI { 281 | namespace Windows { 282 | namespace Foundation { 283 | namespace Numerics { 284 | struct Vector3 { 285 | FLOAT X; 286 | FLOAT Y; 287 | FLOAT Z; 288 | }; 289 | } 290 | } 291 | } 292 | } 293 | extern "C" { 294 | #else 295 | struct __x_ABI_CWindows_CFoundation_CNumerics_CVector3 { 296 | FLOAT X; 297 | FLOAT Y; 298 | FLOAT Z; 299 | }; 300 | #ifdef WIDL_using_Windows_Foundation_Numerics 301 | #define Vector3 __x_ABI_CWindows_CFoundation_CNumerics_CVector3 302 | #endif /* WIDL_using_Windows_Foundation_Numerics */ 303 | #endif 304 | 305 | #endif /* WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 */ 306 | #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 307 | #ifdef __cplusplus 308 | } /* extern "C" */ 309 | namespace ABI { 310 | namespace Windows { 311 | namespace Foundation { 312 | namespace Numerics { 313 | struct Plane { 314 | struct Vector3 Normal; 315 | FLOAT D; 316 | }; 317 | } 318 | } 319 | } 320 | } 321 | extern "C" { 322 | #else 323 | struct __x_ABI_CWindows_CFoundation_CNumerics_CPlane { 324 | struct __x_ABI_CWindows_CFoundation_CNumerics_CVector3 Normal; 325 | FLOAT D; 326 | }; 327 | #ifdef WIDL_using_Windows_Foundation_Numerics 328 | #define Plane __x_ABI_CWindows_CFoundation_CNumerics_CPlane 329 | #endif /* WIDL_using_Windows_Foundation_Numerics */ 330 | #endif 331 | 332 | #endif /* WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 */ 333 | #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 334 | #ifdef __cplusplus 335 | } /* extern "C" */ 336 | namespace ABI { 337 | namespace Windows { 338 | namespace Foundation { 339 | namespace Numerics { 340 | struct Quaternion { 341 | FLOAT X; 342 | FLOAT Y; 343 | FLOAT Z; 344 | FLOAT W; 345 | }; 346 | } 347 | } 348 | } 349 | } 350 | extern "C" { 351 | #else 352 | struct __x_ABI_CWindows_CFoundation_CNumerics_CQuaternion { 353 | FLOAT X; 354 | FLOAT Y; 355 | FLOAT Z; 356 | FLOAT W; 357 | }; 358 | #ifdef WIDL_using_Windows_Foundation_Numerics 359 | #define Quaternion __x_ABI_CWindows_CFoundation_CNumerics_CQuaternion 360 | #endif /* WIDL_using_Windows_Foundation_Numerics */ 361 | #endif 362 | 363 | #endif /* WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 */ 364 | #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 365 | #ifdef __cplusplus 366 | } /* extern "C" */ 367 | namespace ABI { 368 | namespace Windows { 369 | namespace Foundation { 370 | namespace Numerics { 371 | struct Vector2 { 372 | FLOAT X; 373 | FLOAT Y; 374 | }; 375 | } 376 | } 377 | } 378 | } 379 | extern "C" { 380 | #else 381 | struct __x_ABI_CWindows_CFoundation_CNumerics_CVector2 { 382 | FLOAT X; 383 | FLOAT Y; 384 | }; 385 | #ifdef WIDL_using_Windows_Foundation_Numerics 386 | #define Vector2 __x_ABI_CWindows_CFoundation_CNumerics_CVector2 387 | #endif /* WIDL_using_Windows_Foundation_Numerics */ 388 | #endif 389 | 390 | #endif /* WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 */ 391 | #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 392 | #ifdef __cplusplus 393 | } /* extern "C" */ 394 | namespace ABI { 395 | namespace Windows { 396 | namespace Foundation { 397 | namespace Numerics { 398 | struct Vector4 { 399 | FLOAT X; 400 | FLOAT Y; 401 | FLOAT Z; 402 | FLOAT W; 403 | }; 404 | } 405 | } 406 | } 407 | } 408 | extern "C" { 409 | #else 410 | struct __x_ABI_CWindows_CFoundation_CNumerics_CVector4 { 411 | FLOAT X; 412 | FLOAT Y; 413 | FLOAT Z; 414 | FLOAT W; 415 | }; 416 | #ifdef WIDL_using_Windows_Foundation_Numerics 417 | #define Vector4 __x_ABI_CWindows_CFoundation_CNumerics_CVector4 418 | #endif /* WIDL_using_Windows_Foundation_Numerics */ 419 | #endif 420 | 421 | #endif /* WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 */ 422 | /***************************************************************************** 423 | * IReference interface 424 | */ 425 | #ifndef ____FIReference_1_Matrix4x4_INTERFACE_DEFINED__ 426 | #define ____FIReference_1_Matrix4x4_INTERFACE_DEFINED__ 427 | 428 | DEFINE_GUID(IID___FIReference_1_Matrix4x4, 0xdacbffdc, 0x68ef, 0x5fd0, 0xb6,0x57, 0x78,0x2d,0x0a,0xc9,0x80,0x7e); 429 | #if defined(__cplusplus) && !defined(CINTERFACE) 430 | } /* extern "C" */ 431 | namespace ABI { 432 | namespace Windows { 433 | namespace Foundation { 434 | template<> 435 | MIDL_INTERFACE("dacbffdc-68ef-5fd0-b657-782d0ac9807e") 436 | IReference : IReference_impl 437 | { 438 | }; 439 | } 440 | } 441 | } 442 | extern "C" { 443 | #ifdef __CRT_UUID_DECL 444 | __CRT_UUID_DECL(__FIReference_1_Matrix4x4, 0xdacbffdc, 0x68ef, 0x5fd0, 0xb6,0x57, 0x78,0x2d,0x0a,0xc9,0x80,0x7e) 445 | #endif 446 | #else 447 | typedef struct __FIReference_1_Matrix4x4Vtbl { 448 | BEGIN_INTERFACE 449 | 450 | /*** IUnknown methods ***/ 451 | HRESULT (STDMETHODCALLTYPE *QueryInterface)( 452 | __FIReference_1_Matrix4x4 *This, 453 | REFIID riid, 454 | void **ppvObject); 455 | 456 | ULONG (STDMETHODCALLTYPE *AddRef)( 457 | __FIReference_1_Matrix4x4 *This); 458 | 459 | ULONG (STDMETHODCALLTYPE *Release)( 460 | __FIReference_1_Matrix4x4 *This); 461 | 462 | /*** IInspectable methods ***/ 463 | HRESULT (STDMETHODCALLTYPE *GetIids)( 464 | __FIReference_1_Matrix4x4 *This, 465 | ULONG *iidCount, 466 | IID **iids); 467 | 468 | HRESULT (STDMETHODCALLTYPE *GetRuntimeClassName)( 469 | __FIReference_1_Matrix4x4 *This, 470 | HSTRING *className); 471 | 472 | HRESULT (STDMETHODCALLTYPE *GetTrustLevel)( 473 | __FIReference_1_Matrix4x4 *This, 474 | TrustLevel *trustLevel); 475 | 476 | /*** IReference methods ***/ 477 | HRESULT (STDMETHODCALLTYPE *get_Value)( 478 | __FIReference_1_Matrix4x4 *This, 479 | struct __x_ABI_CWindows_CFoundation_CNumerics_CMatrix4x4 *value); 480 | 481 | END_INTERFACE 482 | } __FIReference_1_Matrix4x4Vtbl; 483 | 484 | interface __FIReference_1_Matrix4x4 { 485 | CONST_VTBL __FIReference_1_Matrix4x4Vtbl* lpVtbl; 486 | }; 487 | 488 | #ifdef COBJMACROS 489 | #ifndef WIDL_C_INLINE_WRAPPERS 490 | /*** IUnknown methods ***/ 491 | #define __FIReference_1_Matrix4x4_QueryInterface(This,riid,ppvObject) (This)->lpVtbl->QueryInterface(This,riid,ppvObject) 492 | #define __FIReference_1_Matrix4x4_AddRef(This) (This)->lpVtbl->AddRef(This) 493 | #define __FIReference_1_Matrix4x4_Release(This) (This)->lpVtbl->Release(This) 494 | /*** IInspectable methods ***/ 495 | #define __FIReference_1_Matrix4x4_GetIids(This,iidCount,iids) (This)->lpVtbl->GetIids(This,iidCount,iids) 496 | #define __FIReference_1_Matrix4x4_GetRuntimeClassName(This,className) (This)->lpVtbl->GetRuntimeClassName(This,className) 497 | #define __FIReference_1_Matrix4x4_GetTrustLevel(This,trustLevel) (This)->lpVtbl->GetTrustLevel(This,trustLevel) 498 | /*** IReference methods ***/ 499 | #define __FIReference_1_Matrix4x4_get_Value(This,value) (This)->lpVtbl->get_Value(This,value) 500 | #else 501 | /*** IUnknown methods ***/ 502 | static __WIDL_INLINE HRESULT __FIReference_1_Matrix4x4_QueryInterface(__FIReference_1_Matrix4x4* This,REFIID riid,void **ppvObject) { 503 | return This->lpVtbl->QueryInterface(This,riid,ppvObject); 504 | } 505 | static __WIDL_INLINE ULONG __FIReference_1_Matrix4x4_AddRef(__FIReference_1_Matrix4x4* This) { 506 | return This->lpVtbl->AddRef(This); 507 | } 508 | static __WIDL_INLINE ULONG __FIReference_1_Matrix4x4_Release(__FIReference_1_Matrix4x4* This) { 509 | return This->lpVtbl->Release(This); 510 | } 511 | /*** IInspectable methods ***/ 512 | static __WIDL_INLINE HRESULT __FIReference_1_Matrix4x4_GetIids(__FIReference_1_Matrix4x4* This,ULONG *iidCount,IID **iids) { 513 | return This->lpVtbl->GetIids(This,iidCount,iids); 514 | } 515 | static __WIDL_INLINE HRESULT __FIReference_1_Matrix4x4_GetRuntimeClassName(__FIReference_1_Matrix4x4* This,HSTRING *className) { 516 | return This->lpVtbl->GetRuntimeClassName(This,className); 517 | } 518 | static __WIDL_INLINE HRESULT __FIReference_1_Matrix4x4_GetTrustLevel(__FIReference_1_Matrix4x4* This,TrustLevel *trustLevel) { 519 | return This->lpVtbl->GetTrustLevel(This,trustLevel); 520 | } 521 | /*** IReference methods ***/ 522 | static __WIDL_INLINE HRESULT __FIReference_1_Matrix4x4_get_Value(__FIReference_1_Matrix4x4* This,struct __x_ABI_CWindows_CFoundation_CNumerics_CMatrix4x4 *value) { 523 | return This->lpVtbl->get_Value(This,value); 524 | } 525 | #endif 526 | #ifdef WIDL_using_Windows_Foundation 527 | #define IID_IReference_Matrix4x4 IID___FIReference_1_Matrix4x4 528 | #define IReference_Matrix4x4Vtbl __FIReference_1_Matrix4x4Vtbl 529 | #define IReference_Matrix4x4 __FIReference_1_Matrix4x4 530 | #define IReference_Matrix4x4_QueryInterface __FIReference_1_Matrix4x4_QueryInterface 531 | #define IReference_Matrix4x4_AddRef __FIReference_1_Matrix4x4_AddRef 532 | #define IReference_Matrix4x4_Release __FIReference_1_Matrix4x4_Release 533 | #define IReference_Matrix4x4_GetIids __FIReference_1_Matrix4x4_GetIids 534 | #define IReference_Matrix4x4_GetRuntimeClassName __FIReference_1_Matrix4x4_GetRuntimeClassName 535 | #define IReference_Matrix4x4_GetTrustLevel __FIReference_1_Matrix4x4_GetTrustLevel 536 | #define IReference_Matrix4x4_get_Value __FIReference_1_Matrix4x4_get_Value 537 | #endif /* WIDL_using_Windows_Foundation */ 538 | #endif 539 | 540 | #endif 541 | 542 | #endif /* ____FIReference_1_Matrix4x4_INTERFACE_DEFINED__ */ 543 | 544 | /***************************************************************************** 545 | * IReference interface 546 | */ 547 | #ifndef ____FIReference_1_Vector2_INTERFACE_DEFINED__ 548 | #define ____FIReference_1_Vector2_INTERFACE_DEFINED__ 549 | 550 | DEFINE_GUID(IID___FIReference_1_Vector2, 0x48f6a69e, 0x8465, 0x57ae, 0x94,0x00, 0x97,0x64,0x08,0x7f,0x65,0xad); 551 | #if defined(__cplusplus) && !defined(CINTERFACE) 552 | } /* extern "C" */ 553 | namespace ABI { 554 | namespace Windows { 555 | namespace Foundation { 556 | template<> 557 | MIDL_INTERFACE("48f6a69e-8465-57ae-9400-9764087f65ad") 558 | IReference : IReference_impl 559 | { 560 | }; 561 | } 562 | } 563 | } 564 | extern "C" { 565 | #ifdef __CRT_UUID_DECL 566 | __CRT_UUID_DECL(__FIReference_1_Vector2, 0x48f6a69e, 0x8465, 0x57ae, 0x94,0x00, 0x97,0x64,0x08,0x7f,0x65,0xad) 567 | #endif 568 | #else 569 | typedef struct __FIReference_1_Vector2Vtbl { 570 | BEGIN_INTERFACE 571 | 572 | /*** IUnknown methods ***/ 573 | HRESULT (STDMETHODCALLTYPE *QueryInterface)( 574 | __FIReference_1_Vector2 *This, 575 | REFIID riid, 576 | void **ppvObject); 577 | 578 | ULONG (STDMETHODCALLTYPE *AddRef)( 579 | __FIReference_1_Vector2 *This); 580 | 581 | ULONG (STDMETHODCALLTYPE *Release)( 582 | __FIReference_1_Vector2 *This); 583 | 584 | /*** IInspectable methods ***/ 585 | HRESULT (STDMETHODCALLTYPE *GetIids)( 586 | __FIReference_1_Vector2 *This, 587 | ULONG *iidCount, 588 | IID **iids); 589 | 590 | HRESULT (STDMETHODCALLTYPE *GetRuntimeClassName)( 591 | __FIReference_1_Vector2 *This, 592 | HSTRING *className); 593 | 594 | HRESULT (STDMETHODCALLTYPE *GetTrustLevel)( 595 | __FIReference_1_Vector2 *This, 596 | TrustLevel *trustLevel); 597 | 598 | /*** IReference methods ***/ 599 | HRESULT (STDMETHODCALLTYPE *get_Value)( 600 | __FIReference_1_Vector2 *This, 601 | struct __x_ABI_CWindows_CFoundation_CNumerics_CVector2 *value); 602 | 603 | END_INTERFACE 604 | } __FIReference_1_Vector2Vtbl; 605 | 606 | interface __FIReference_1_Vector2 { 607 | CONST_VTBL __FIReference_1_Vector2Vtbl* lpVtbl; 608 | }; 609 | 610 | #ifdef COBJMACROS 611 | #ifndef WIDL_C_INLINE_WRAPPERS 612 | /*** IUnknown methods ***/ 613 | #define __FIReference_1_Vector2_QueryInterface(This,riid,ppvObject) (This)->lpVtbl->QueryInterface(This,riid,ppvObject) 614 | #define __FIReference_1_Vector2_AddRef(This) (This)->lpVtbl->AddRef(This) 615 | #define __FIReference_1_Vector2_Release(This) (This)->lpVtbl->Release(This) 616 | /*** IInspectable methods ***/ 617 | #define __FIReference_1_Vector2_GetIids(This,iidCount,iids) (This)->lpVtbl->GetIids(This,iidCount,iids) 618 | #define __FIReference_1_Vector2_GetRuntimeClassName(This,className) (This)->lpVtbl->GetRuntimeClassName(This,className) 619 | #define __FIReference_1_Vector2_GetTrustLevel(This,trustLevel) (This)->lpVtbl->GetTrustLevel(This,trustLevel) 620 | /*** IReference methods ***/ 621 | #define __FIReference_1_Vector2_get_Value(This,value) (This)->lpVtbl->get_Value(This,value) 622 | #else 623 | /*** IUnknown methods ***/ 624 | static __WIDL_INLINE HRESULT __FIReference_1_Vector2_QueryInterface(__FIReference_1_Vector2* This,REFIID riid,void **ppvObject) { 625 | return This->lpVtbl->QueryInterface(This,riid,ppvObject); 626 | } 627 | static __WIDL_INLINE ULONG __FIReference_1_Vector2_AddRef(__FIReference_1_Vector2* This) { 628 | return This->lpVtbl->AddRef(This); 629 | } 630 | static __WIDL_INLINE ULONG __FIReference_1_Vector2_Release(__FIReference_1_Vector2* This) { 631 | return This->lpVtbl->Release(This); 632 | } 633 | /*** IInspectable methods ***/ 634 | static __WIDL_INLINE HRESULT __FIReference_1_Vector2_GetIids(__FIReference_1_Vector2* This,ULONG *iidCount,IID **iids) { 635 | return This->lpVtbl->GetIids(This,iidCount,iids); 636 | } 637 | static __WIDL_INLINE HRESULT __FIReference_1_Vector2_GetRuntimeClassName(__FIReference_1_Vector2* This,HSTRING *className) { 638 | return This->lpVtbl->GetRuntimeClassName(This,className); 639 | } 640 | static __WIDL_INLINE HRESULT __FIReference_1_Vector2_GetTrustLevel(__FIReference_1_Vector2* This,TrustLevel *trustLevel) { 641 | return This->lpVtbl->GetTrustLevel(This,trustLevel); 642 | } 643 | /*** IReference methods ***/ 644 | static __WIDL_INLINE HRESULT __FIReference_1_Vector2_get_Value(__FIReference_1_Vector2* This,struct __x_ABI_CWindows_CFoundation_CNumerics_CVector2 *value) { 645 | return This->lpVtbl->get_Value(This,value); 646 | } 647 | #endif 648 | #ifdef WIDL_using_Windows_Foundation 649 | #define IID_IReference_Vector2 IID___FIReference_1_Vector2 650 | #define IReference_Vector2Vtbl __FIReference_1_Vector2Vtbl 651 | #define IReference_Vector2 __FIReference_1_Vector2 652 | #define IReference_Vector2_QueryInterface __FIReference_1_Vector2_QueryInterface 653 | #define IReference_Vector2_AddRef __FIReference_1_Vector2_AddRef 654 | #define IReference_Vector2_Release __FIReference_1_Vector2_Release 655 | #define IReference_Vector2_GetIids __FIReference_1_Vector2_GetIids 656 | #define IReference_Vector2_GetRuntimeClassName __FIReference_1_Vector2_GetRuntimeClassName 657 | #define IReference_Vector2_GetTrustLevel __FIReference_1_Vector2_GetTrustLevel 658 | #define IReference_Vector2_get_Value __FIReference_1_Vector2_get_Value 659 | #endif /* WIDL_using_Windows_Foundation */ 660 | #endif 661 | 662 | #endif 663 | 664 | #endif /* ____FIReference_1_Vector2_INTERFACE_DEFINED__ */ 665 | 666 | /***************************************************************************** 667 | * IReference interface 668 | */ 669 | #ifndef ____FIReference_1_Vector3_INTERFACE_DEFINED__ 670 | #define ____FIReference_1_Vector3_INTERFACE_DEFINED__ 671 | 672 | DEFINE_GUID(IID___FIReference_1_Vector3, 0x1ee770ff, 0xc954, 0x59ca, 0xa7,0x54, 0x61,0x99,0xa9,0xbe,0x28,0x2c); 673 | #if defined(__cplusplus) && !defined(CINTERFACE) 674 | } /* extern "C" */ 675 | namespace ABI { 676 | namespace Windows { 677 | namespace Foundation { 678 | template<> 679 | MIDL_INTERFACE("1ee770ff-c954-59ca-a754-6199a9be282c") 680 | IReference : IReference_impl 681 | { 682 | }; 683 | } 684 | } 685 | } 686 | extern "C" { 687 | #ifdef __CRT_UUID_DECL 688 | __CRT_UUID_DECL(__FIReference_1_Vector3, 0x1ee770ff, 0xc954, 0x59ca, 0xa7,0x54, 0x61,0x99,0xa9,0xbe,0x28,0x2c) 689 | #endif 690 | #else 691 | typedef struct __FIReference_1_Vector3Vtbl { 692 | BEGIN_INTERFACE 693 | 694 | /*** IUnknown methods ***/ 695 | HRESULT (STDMETHODCALLTYPE *QueryInterface)( 696 | __FIReference_1_Vector3 *This, 697 | REFIID riid, 698 | void **ppvObject); 699 | 700 | ULONG (STDMETHODCALLTYPE *AddRef)( 701 | __FIReference_1_Vector3 *This); 702 | 703 | ULONG (STDMETHODCALLTYPE *Release)( 704 | __FIReference_1_Vector3 *This); 705 | 706 | /*** IInspectable methods ***/ 707 | HRESULT (STDMETHODCALLTYPE *GetIids)( 708 | __FIReference_1_Vector3 *This, 709 | ULONG *iidCount, 710 | IID **iids); 711 | 712 | HRESULT (STDMETHODCALLTYPE *GetRuntimeClassName)( 713 | __FIReference_1_Vector3 *This, 714 | HSTRING *className); 715 | 716 | HRESULT (STDMETHODCALLTYPE *GetTrustLevel)( 717 | __FIReference_1_Vector3 *This, 718 | TrustLevel *trustLevel); 719 | 720 | /*** IReference methods ***/ 721 | HRESULT (STDMETHODCALLTYPE *get_Value)( 722 | __FIReference_1_Vector3 *This, 723 | struct __x_ABI_CWindows_CFoundation_CNumerics_CVector3 *value); 724 | 725 | END_INTERFACE 726 | } __FIReference_1_Vector3Vtbl; 727 | 728 | interface __FIReference_1_Vector3 { 729 | CONST_VTBL __FIReference_1_Vector3Vtbl* lpVtbl; 730 | }; 731 | 732 | #ifdef COBJMACROS 733 | #ifndef WIDL_C_INLINE_WRAPPERS 734 | /*** IUnknown methods ***/ 735 | #define __FIReference_1_Vector3_QueryInterface(This,riid,ppvObject) (This)->lpVtbl->QueryInterface(This,riid,ppvObject) 736 | #define __FIReference_1_Vector3_AddRef(This) (This)->lpVtbl->AddRef(This) 737 | #define __FIReference_1_Vector3_Release(This) (This)->lpVtbl->Release(This) 738 | /*** IInspectable methods ***/ 739 | #define __FIReference_1_Vector3_GetIids(This,iidCount,iids) (This)->lpVtbl->GetIids(This,iidCount,iids) 740 | #define __FIReference_1_Vector3_GetRuntimeClassName(This,className) (This)->lpVtbl->GetRuntimeClassName(This,className) 741 | #define __FIReference_1_Vector3_GetTrustLevel(This,trustLevel) (This)->lpVtbl->GetTrustLevel(This,trustLevel) 742 | /*** IReference methods ***/ 743 | #define __FIReference_1_Vector3_get_Value(This,value) (This)->lpVtbl->get_Value(This,value) 744 | #else 745 | /*** IUnknown methods ***/ 746 | static __WIDL_INLINE HRESULT __FIReference_1_Vector3_QueryInterface(__FIReference_1_Vector3* This,REFIID riid,void **ppvObject) { 747 | return This->lpVtbl->QueryInterface(This,riid,ppvObject); 748 | } 749 | static __WIDL_INLINE ULONG __FIReference_1_Vector3_AddRef(__FIReference_1_Vector3* This) { 750 | return This->lpVtbl->AddRef(This); 751 | } 752 | static __WIDL_INLINE ULONG __FIReference_1_Vector3_Release(__FIReference_1_Vector3* This) { 753 | return This->lpVtbl->Release(This); 754 | } 755 | /*** IInspectable methods ***/ 756 | static __WIDL_INLINE HRESULT __FIReference_1_Vector3_GetIids(__FIReference_1_Vector3* This,ULONG *iidCount,IID **iids) { 757 | return This->lpVtbl->GetIids(This,iidCount,iids); 758 | } 759 | static __WIDL_INLINE HRESULT __FIReference_1_Vector3_GetRuntimeClassName(__FIReference_1_Vector3* This,HSTRING *className) { 760 | return This->lpVtbl->GetRuntimeClassName(This,className); 761 | } 762 | static __WIDL_INLINE HRESULT __FIReference_1_Vector3_GetTrustLevel(__FIReference_1_Vector3* This,TrustLevel *trustLevel) { 763 | return This->lpVtbl->GetTrustLevel(This,trustLevel); 764 | } 765 | /*** IReference methods ***/ 766 | static __WIDL_INLINE HRESULT __FIReference_1_Vector3_get_Value(__FIReference_1_Vector3* This,struct __x_ABI_CWindows_CFoundation_CNumerics_CVector3 *value) { 767 | return This->lpVtbl->get_Value(This,value); 768 | } 769 | #endif 770 | #ifdef WIDL_using_Windows_Foundation 771 | #define IID_IReference_Vector3 IID___FIReference_1_Vector3 772 | #define IReference_Vector3Vtbl __FIReference_1_Vector3Vtbl 773 | #define IReference_Vector3 __FIReference_1_Vector3 774 | #define IReference_Vector3_QueryInterface __FIReference_1_Vector3_QueryInterface 775 | #define IReference_Vector3_AddRef __FIReference_1_Vector3_AddRef 776 | #define IReference_Vector3_Release __FIReference_1_Vector3_Release 777 | #define IReference_Vector3_GetIids __FIReference_1_Vector3_GetIids 778 | #define IReference_Vector3_GetRuntimeClassName __FIReference_1_Vector3_GetRuntimeClassName 779 | #define IReference_Vector3_GetTrustLevel __FIReference_1_Vector3_GetTrustLevel 780 | #define IReference_Vector3_get_Value __FIReference_1_Vector3_get_Value 781 | #endif /* WIDL_using_Windows_Foundation */ 782 | #endif 783 | 784 | #endif 785 | 786 | #endif /* ____FIReference_1_Vector3_INTERFACE_DEFINED__ */ 787 | 788 | /* Begin additional prototypes for all interfaces */ 789 | 790 | 791 | /* End additional prototypes */ 792 | 793 | #ifdef __cplusplus 794 | } 795 | #endif 796 | 797 | #endif /* __windows_foundation_numerics_h__ */ 798 | -------------------------------------------------------------------------------- /examples/sdl2/third-party/sdl2/upstream/any-windows-any/windows.system.power.h: -------------------------------------------------------------------------------- 1 | /*** Autogenerated by WIDL 8.21 from include/windows.system.power.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 8 | #include 9 | #endif 10 | 11 | #ifndef COM_NO_WINDOWS_H 12 | #include 13 | #include 14 | #endif 15 | 16 | #ifndef __windows_system_power_h__ 17 | #define __windows_system_power_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 | #include 32 | #include 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | #ifndef __cplusplus 39 | typedef enum __x_ABI_CWindows_CSystem_CPower_CBatteryStatus __x_ABI_CWindows_CSystem_CPower_CBatteryStatus; 40 | #endif /* __cplusplus */ 41 | 42 | #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 43 | #ifdef __cplusplus 44 | } /* extern "C" */ 45 | namespace ABI { 46 | namespace Windows { 47 | namespace System { 48 | namespace Power { 49 | enum BatteryStatus { 50 | BatteryStatus_NotPresent = 0, 51 | BatteryStatus_Discharging = 1, 52 | BatteryStatus_Idle = 2, 53 | BatteryStatus_Charging = 3 54 | }; 55 | } 56 | } 57 | } 58 | } 59 | extern "C" { 60 | #else 61 | enum __x_ABI_CWindows_CSystem_CPower_CBatteryStatus { 62 | BatteryStatus_NotPresent = 0, 63 | BatteryStatus_Discharging = 1, 64 | BatteryStatus_Idle = 2, 65 | BatteryStatus_Charging = 3 66 | }; 67 | #ifdef WIDL_using_Windows_System_Power 68 | #define BatteryStatus __x_ABI_CWindows_CSystem_CPower_CBatteryStatus 69 | #endif /* WIDL_using_Windows_System_Power */ 70 | #endif 71 | 72 | #endif /* WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 */ 73 | /* Begin additional prototypes for all interfaces */ 74 | 75 | 76 | /* End additional prototypes */ 77 | 78 | #ifdef __cplusplus 79 | } 80 | #endif 81 | 82 | #endif /* __windows_system_power_h__ */ 83 | -------------------------------------------------------------------------------- /examples/sdl2/third-party/sdl2/upstream/any-windows-any/windowscontracts.h: -------------------------------------------------------------------------------- 1 | /*** Autogenerated by WIDL 8.21 from include/windowscontracts.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 8 | #include 9 | #endif 10 | 11 | #ifndef COM_NO_WINDOWS_H 12 | #include 13 | #include 14 | #endif 15 | 16 | #ifndef __windowscontracts_h__ 17 | #define __windowscontracts_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 | #if !defined(WINDOWS_FOUNDATION_FOUNDATIONCONTRACT_VERSION) 37 | #define WINDOWS_FOUNDATION_FOUNDATIONCONTRACT_VERSION 0x40000 38 | #endif // defined(WINDOWS_FOUNDATION_FOUNDATIONCONTRACT_VERSION) 39 | 40 | #if !defined(WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION) 41 | #define WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION 0xe0000 42 | #endif // defined(WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION) 43 | 44 | #if !defined(WINDOWS_PHONE_PHONECONTRACT_VERSION) 45 | #define WINDOWS_PHONE_PHONECONTRACT_VERSION 0x10000 46 | #endif // defined(WINDOWS_PHONE_PHONECONTRACT_VERSION) 47 | 48 | /* Begin additional prototypes for all interfaces */ 49 | 50 | 51 | /* End additional prototypes */ 52 | 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | 57 | #endif /* __windowscontracts_h__ */ 58 | -------------------------------------------------------------------------------- /src/android/android.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | const builtin = @import("builtin"); 3 | 4 | // TODO(jae): 2024-10-03 5 | // Consider exposing this in the future 6 | // pub const builtin = android_builtin; 7 | 8 | const android_builtin = struct { 9 | const ab = @import("android_builtin"); 10 | 11 | /// package name extracted from your AndroidManifest.xml file 12 | /// ie. "com.zig.sdl2" 13 | pub const package_name: [:0]const u8 = ab.package_name; 14 | }; 15 | 16 | /// Writes the constant string text to the log, with priority prio and tag tag. 17 | /// Returns: 1 if the message was written to the log, or -EPERM if it was not; see __android_log_is_loggable(). 18 | /// Source: https://developer.android.com/ndk/reference/group/logging 19 | extern "log" fn __android_log_write(prio: c_int, tag: [*c]const u8, text: [*c]const u8) c_int; 20 | 21 | /// Alternate panic implementation that calls __android_log_write so that you can see the logging via "adb logcat" 22 | pub const panic = std.debug.FullPanic(Panic.panic); 23 | 24 | /// Levels for Android 25 | pub const Level = enum(u8) { 26 | // silent = 8, // Android docs: For internal use only. 27 | // Fatal: Android only, for use when aborting 28 | fatal = 7, // ANDROID_LOG_FATAL 29 | /// Error: something has gone wrong. This might be recoverable or might 30 | /// be followed by the program exiting. 31 | err = 6, // ANDROID_LOG_ERROR 32 | /// Warning: it is uncertain if something has gone wrong or not, but the 33 | /// circumstances would be worth investigating. 34 | warn = 5, // ANDROID_LOG_WARN 35 | /// Info: general messages about the state of the program. 36 | info = 4, // ANDROID_LOG_INFO 37 | /// Debug: messages only useful for debugging. 38 | debug = 3, // ANDROID_LOG_DEBUG 39 | // verbose = 2, // ANDROID_LOG_VERBOSE 40 | // default = 1, // ANDROID_LOG_DEFAULT 41 | 42 | // Returns a string literal of the given level in full text form. 43 | // pub fn asText(comptime self: Level) []const u8 { 44 | // return switch (self) { 45 | // .err => "error", 46 | // .warn => "warning", 47 | // .info => "info", 48 | // .debug => "debug", 49 | // }; 50 | // } 51 | }; 52 | 53 | /// Alternate log function implementation that calls __android_log_write so that you can see the logging via "adb logcat" 54 | pub fn logFn( 55 | comptime message_level: std.log.Level, 56 | comptime scope: if (builtin.zig_version.major == 0 and builtin.zig_version.minor == 13) 57 | // Support Zig 0.13.0 58 | @Type(.EnumLiteral) 59 | else 60 | // Support Zig 0.14.0-dev 61 | @Type(.enum_literal), 62 | comptime format: []const u8, 63 | args: anytype, 64 | ) void { 65 | // NOTE(jae): 2024-09-11 66 | // Zig has a colon ": " or "): " for scoped but Android logs just do that after being flushed 67 | // So we don't do that here. 68 | const prefix2 = if (scope == .default) "" else "(" ++ @tagName(scope) ++ ")"; // "): "; 69 | var androidLogWriter = comptime LogWriter{ 70 | .level = switch (message_level) { 71 | // => .ANDROID_LOG_VERBOSE, // No mapping 72 | .debug => .debug, // android.ANDROID_LOG_DEBUG = 3, 73 | .info => .info, // android.ANDROID_LOG_INFO = 4, 74 | .warn => .warn, // android.ANDROID_LOG_WARN = 5, 75 | .err => .err, // android.ANDROID_LOG_WARN = 6, 76 | }, 77 | }; 78 | const writer = androidLogWriter.writer(); 79 | 80 | nosuspend { 81 | writer.print(prefix2 ++ format ++ "\n", args) catch return; 82 | androidLogWriter.flush(); 83 | } 84 | } 85 | 86 | /// LogWriter was was taken basically as is from: https://github.com/ikskuh/ZigAndroidTemplate 87 | const LogWriter = struct { 88 | /// Default to the "package" attribute defined in AndroidManifest.xml 89 | /// 90 | /// If tag isn't set when calling "__android_log_write" then it *usually* defaults to the current 91 | /// package name, ie. "com.zig.minimal" 92 | /// 93 | /// However if running via a seperate thread, then it seems to use that threads 94 | /// tag, which means if you log after running code through sdl_main, it won't print 95 | /// logs with the package name. 96 | /// 97 | /// To workaround this, we bake the package name into the Zig binaries. 98 | const tag: [:0]const u8 = android_builtin.package_name; 99 | 100 | level: Level, 101 | 102 | line_buffer: [8192]u8 = undefined, 103 | line_len: usize = 0, 104 | 105 | const Error = error{}; 106 | const Writer = std.io.Writer(*@This(), Error, write); 107 | 108 | fn write(self: *@This(), buffer: []const u8) Error!usize { 109 | for (buffer) |char| { 110 | switch (char) { 111 | '\n' => { 112 | self.flush(); 113 | }, 114 | else => { 115 | if (self.line_len >= self.line_buffer.len - 1) { 116 | self.flush(); 117 | } 118 | self.line_buffer[self.line_len] = char; 119 | self.line_len += 1; 120 | }, 121 | } 122 | } 123 | return buffer.len; 124 | } 125 | 126 | fn flush(self: *@This()) void { 127 | if (self.line_len > 0) { 128 | std.debug.assert(self.line_len < self.line_buffer.len - 1); 129 | self.line_buffer[self.line_len] = 0; 130 | if (tag.len == 0) { 131 | _ = __android_log_write( 132 | @intFromEnum(self.level), 133 | null, 134 | &self.line_buffer, 135 | ); 136 | } else { 137 | _ = __android_log_write( 138 | @intFromEnum(self.level), 139 | tag.ptr, 140 | &self.line_buffer, 141 | ); 142 | } 143 | } 144 | self.line_len = 0; 145 | } 146 | 147 | fn writer(self: *@This()) Writer { 148 | return Writer{ .context = self }; 149 | } 150 | }; 151 | 152 | /// Panic is a copy-paste of the panic logic from Zig but replaces usages of getStdErr with our own writer 153 | /// 154 | /// Example output (Zig 0.13.0): 155 | /// 09-22 13:08:49.578 3390 3390 F com.zig.minimal: thread 3390 panic: your panic message here 156 | /// 09-22 13:08:49.637 3390 3390 F com.zig.minimal: zig-android-sdk/examples\minimal/src/minimal.zig:33:15: 0x7ccb77b282dc in nativeActivityOnCreate (minimal) 157 | /// 09-22 13:08:49.637 3390 3390 F com.zig.minimal: zig-android-sdk/examples/minimal/src/minimal.zig:84:27: 0x7ccb77b28650 in ANativeActivity_onCreate (minimal) 158 | /// 09-22 13:08:49.637 3390 3390 F com.zig.minimal: ???:?:?: 0x7ccea4021d9c in ??? (libandroid_runtime.so) 159 | const Panic = struct { 160 | /// Non-zero whenever the program triggered a panic. 161 | /// The counter is incremented/decremented atomically. 162 | var panicking = std.atomic.Value(u8).init(0); 163 | 164 | // Locked to avoid interleaving panic messages from multiple threads. 165 | var panic_mutex = std.Thread.Mutex{}; 166 | 167 | /// Counts how many times the panic handler is invoked by this thread. 168 | /// This is used to catch and handle panics triggered by the panic handler. 169 | threadlocal var panic_stage: usize = 0; 170 | 171 | fn panic(message: []const u8, ret_addr: ?usize) noreturn { 172 | @branchHint(.cold); 173 | if (comptime !builtin.abi.isAndroid()) @compileError("do not use Android panic for non-Android builds"); 174 | const first_trace_addr = ret_addr orelse @returnAddress(); 175 | panicImpl(first_trace_addr, message); 176 | } 177 | 178 | /// Must be called only after adding 1 to `panicking`. There are three callsites. 179 | fn waitForOtherThreadToFinishPanicking() void { 180 | if (panicking.fetchSub(1, .seq_cst) != 1) { 181 | // Another thread is panicking, wait for the last one to finish 182 | // and call abort() 183 | if (builtin.single_threaded) unreachable; 184 | 185 | // Sleep forever without hammering the CPU 186 | var futex = std.atomic.Value(u32).init(0); 187 | while (true) std.Thread.Futex.wait(&futex, 0); 188 | unreachable; 189 | } 190 | } 191 | 192 | const native_os = builtin.os.tag; 193 | const updateSegfaultHandler = std.debug.updateSegfaultHandler; 194 | 195 | fn resetSegfaultHandler() void { 196 | // NOTE(jae): 2024-09-22 197 | // Not applicable for Android as it runs on the OS tag Linux 198 | // if (native_os == .windows) { 199 | // if (windows_segfault_handle) |handle| { 200 | // assert(windows.kernel32.RemoveVectoredExceptionHandler(handle) != 0); 201 | // windows_segfault_handle = null; 202 | // } 203 | // return; 204 | // } 205 | var act = posix.Sigaction{ 206 | .handler = .{ .handler = posix.SIG.DFL }, 207 | .mask = if (builtin.zig_version.major == 0 and builtin.zig_version.minor == 14) 208 | // Legacy 0.14.0 209 | posix.empty_sigset 210 | else 211 | // 0.15.0-dev+ 212 | posix.sigemptyset(), 213 | .flags = 0, 214 | }; 215 | // To avoid a double-panic, do nothing if an error happens here. 216 | if (builtin.zig_version.major == 0 and builtin.zig_version.minor == 13) { 217 | // Legacy 0.13.0 218 | updateSegfaultHandler(&act) catch {}; 219 | } else { 220 | // 0.14.0-dev+ 221 | updateSegfaultHandler(&act); 222 | } 223 | } 224 | 225 | const io = struct { 226 | const tty = struct { 227 | inline fn detectConfig(_: *LogWriter) std.io.tty.Config { 228 | return .no_color; 229 | } 230 | }; 231 | 232 | var writer = LogWriter{ 233 | .level = .fatal, 234 | }; 235 | 236 | inline fn getStdErr() *LogWriter { 237 | return &writer; 238 | } 239 | }; 240 | 241 | const posix = std.posix; 242 | const enable_segfault_handler = std.options.enable_segfault_handler; 243 | 244 | /// Panic is a copy-paste of the panic logic from Zig but replaces usages of getStdErr with our own writer 245 | /// 246 | /// - Provide custom "io" namespace so we can easily customize getStdErr() to be our own writer 247 | /// - Provide other functions from std.debug.* 248 | fn panicImpl(first_trace_addr: ?usize, msg: []const u8) noreturn { 249 | @branchHint(.cold); 250 | 251 | if (enable_segfault_handler) { 252 | // If a segfault happens while panicking, we want it to actually segfault, not trigger 253 | // the handler. 254 | resetSegfaultHandler(); 255 | } 256 | 257 | // Note there is similar logic in handleSegfaultPosix and handleSegfaultWindowsExtra. 258 | nosuspend switch (panic_stage) { 259 | 0 => { 260 | panic_stage = 1; 261 | 262 | _ = panicking.fetchAdd(1, .seq_cst); 263 | 264 | // Make sure to release the mutex when done 265 | { 266 | panic_mutex.lock(); 267 | defer panic_mutex.unlock(); 268 | 269 | const stderr = io.getStdErr().writer(); 270 | if (builtin.single_threaded) { 271 | stderr.print("panic: ", .{}) catch posix.abort(); 272 | } else { 273 | const current_thread_id = std.Thread.getCurrentId(); 274 | stderr.print("thread {} panic: ", .{current_thread_id}) catch posix.abort(); 275 | } 276 | stderr.print("{s}\n", .{msg}) catch posix.abort(); 277 | if (@errorReturnTrace()) |t| dumpStackTrace(t.*); 278 | dumpCurrentStackTrace(first_trace_addr); 279 | } 280 | 281 | waitForOtherThreadToFinishPanicking(); 282 | }, 283 | 1 => { 284 | panic_stage = 2; 285 | 286 | // A panic happened while trying to print a previous panic message, 287 | // we're still holding the mutex but that's fine as we're going to 288 | // call abort() 289 | const stderr = io.getStdErr().writer(); 290 | stderr.print("Panicked during a panic. Aborting.\n", .{}) catch posix.abort(); 291 | }, 292 | else => { 293 | // Panicked while printing "Panicked during a panic." 294 | }, 295 | }; 296 | 297 | posix.abort(); 298 | } 299 | 300 | const getSelfDebugInfo = std.debug.getSelfDebugInfo; 301 | const writeStackTrace = std.debug.writeStackTrace; 302 | 303 | // Used for 0.13.0 compatibility, technically this allocator is completely unused by "writeStackTrace" 304 | fn getDebugInfoAllocator() std.mem.Allocator { 305 | return std.heap.page_allocator; 306 | } 307 | 308 | fn dumpStackTrace(stack_trace: std.builtin.StackTrace) void { 309 | nosuspend { 310 | if (comptime builtin.target.cpu.arch.isWasm()) { 311 | if (native_os == .wasi) { 312 | const stderr = io.getStdErr().writer(); 313 | stderr.print("Unable to dump stack trace: not implemented for Wasm\n", .{}) catch return; 314 | } 315 | return; 316 | } 317 | const stderr = io.getStdErr().writer(); 318 | if (builtin.strip_debug_info) { 319 | stderr.print("Unable to dump stack trace: debug info stripped\n", .{}) catch return; 320 | return; 321 | } 322 | const debug_info = getSelfDebugInfo() catch |err| { 323 | stderr.print("Unable to dump stack trace: Unable to open debug info: {s}\n", .{@errorName(err)}) catch return; 324 | return; 325 | }; 326 | if (builtin.zig_version.major == 0 and builtin.zig_version.minor == 13) { 327 | // Legacy 0.13.0 328 | writeStackTrace(stack_trace, stderr, getDebugInfoAllocator(), debug_info, io.tty.detectConfig(io.getStdErr())) catch |err| { 329 | stderr.print("Unable to dump stack trace: {s}\n", .{@errorName(err)}) catch return; 330 | return; 331 | }; 332 | } else { 333 | // 0.14.0-dev+ 334 | writeStackTrace(stack_trace, stderr, debug_info, io.tty.detectConfig(io.getStdErr())) catch |err| { 335 | stderr.print("Unable to dump stack trace: {s}\n", .{@errorName(err)}) catch return; 336 | return; 337 | }; 338 | } 339 | } 340 | } 341 | 342 | const writeCurrentStackTrace = std.debug.writeCurrentStackTrace; 343 | fn dumpCurrentStackTrace(start_addr: ?usize) void { 344 | nosuspend { 345 | if (comptime builtin.target.cpu.arch.isWasm()) { 346 | if (native_os == .wasi) { 347 | const stderr = io.getStdErr().writer(); 348 | stderr.print("Unable to dump stack trace: not implemented for Wasm\n", .{}) catch return; 349 | } 350 | return; 351 | } 352 | const stderr = io.getStdErr().writer(); 353 | if (builtin.strip_debug_info) { 354 | stderr.print("Unable to dump stack trace: debug info stripped\n", .{}) catch return; 355 | return; 356 | } 357 | const debug_info = getSelfDebugInfo() catch |err| { 358 | stderr.print("Unable to dump stack trace: Unable to open debug info: {s}\n", .{@errorName(err)}) catch return; 359 | return; 360 | }; 361 | writeCurrentStackTrace(stderr, debug_info, io.tty.detectConfig(io.getStdErr()), start_addr) catch |err| { 362 | stderr.print("Unable to dump stack trace: {s}\n", .{@errorName(err)}) catch return; 363 | return; 364 | }; 365 | } 366 | } 367 | }; 368 | -------------------------------------------------------------------------------- /src/androidbuild/WindowsSdk.zig: -------------------------------------------------------------------------------- 1 | //! NOTE(jae): 2024-09-15 2 | //! Copy paste of lib/std/zig/WindowsSdk.zig but cutdown to only use Registry functions 3 | const WindowsSdk = @This(); 4 | const std = @import("std"); 5 | const builtin = @import("builtin"); 6 | 7 | const windows = std.os.windows; 8 | const RRF = windows.advapi32.RRF; 9 | 10 | const OpenOptions = struct { 11 | /// Sets the KEY_WOW64_32KEY access flag. 12 | /// https://learn.microsoft.com/en-us/windows/win32/winprog64/accessing-an-alternate-registry-view 13 | wow64_32: bool = false, 14 | }; 15 | 16 | pub const RegistryWtf8 = struct { 17 | key: windows.HKEY, 18 | 19 | /// Assert that `key` is valid WTF-8 string 20 | pub fn openKey(hkey: windows.HKEY, key: []const u8, options: OpenOptions) error{KeyNotFound}!RegistryWtf8 { 21 | const key_wtf16le: [:0]const u16 = key_wtf16le: { 22 | var key_wtf16le_buf: [RegistryWtf16Le.key_name_max_len]u16 = undefined; 23 | const key_wtf16le_len: usize = std.unicode.wtf8ToWtf16Le(key_wtf16le_buf[0..], key) catch |err| switch (err) { 24 | error.InvalidWtf8 => unreachable, 25 | }; 26 | key_wtf16le_buf[key_wtf16le_len] = 0; 27 | break :key_wtf16le key_wtf16le_buf[0..key_wtf16le_len :0]; 28 | }; 29 | 30 | const registry_wtf16le = try RegistryWtf16Le.openKey(hkey, key_wtf16le, options); 31 | return .{ .key = registry_wtf16le.key }; 32 | } 33 | 34 | /// Closes key, after that usage is invalid 35 | pub fn closeKey(reg: RegistryWtf8) void { 36 | const return_code_int: windows.HRESULT = windows.advapi32.RegCloseKey(reg.key); 37 | const return_code: windows.Win32Error = @enumFromInt(return_code_int); 38 | switch (return_code) { 39 | .SUCCESS => {}, 40 | else => {}, 41 | } 42 | } 43 | 44 | /// Get string from registry. 45 | /// Caller owns result. 46 | pub fn getString(reg: RegistryWtf8, allocator: std.mem.Allocator, subkey: []const u8, value_name: []const u8) error{ OutOfMemory, ValueNameNotFound, NotAString, StringNotFound }![]u8 { 47 | const subkey_wtf16le: [:0]const u16 = subkey_wtf16le: { 48 | var subkey_wtf16le_buf: [RegistryWtf16Le.key_name_max_len]u16 = undefined; 49 | const subkey_wtf16le_len: usize = std.unicode.wtf8ToWtf16Le(subkey_wtf16le_buf[0..], subkey) catch unreachable; 50 | subkey_wtf16le_buf[subkey_wtf16le_len] = 0; 51 | break :subkey_wtf16le subkey_wtf16le_buf[0..subkey_wtf16le_len :0]; 52 | }; 53 | 54 | const value_name_wtf16le: [:0]const u16 = value_name_wtf16le: { 55 | var value_name_wtf16le_buf: [RegistryWtf16Le.value_name_max_len]u16 = undefined; 56 | const value_name_wtf16le_len: usize = std.unicode.wtf8ToWtf16Le(value_name_wtf16le_buf[0..], value_name) catch unreachable; 57 | value_name_wtf16le_buf[value_name_wtf16le_len] = 0; 58 | break :value_name_wtf16le value_name_wtf16le_buf[0..value_name_wtf16le_len :0]; 59 | }; 60 | 61 | const registry_wtf16le: RegistryWtf16Le = .{ .key = reg.key }; 62 | const value_wtf16le = try registry_wtf16le.getString(allocator, subkey_wtf16le, value_name_wtf16le); 63 | defer allocator.free(value_wtf16le); 64 | 65 | const value_wtf8: []u8 = try std.unicode.wtf16LeToWtf8Alloc(allocator, value_wtf16le); 66 | errdefer allocator.free(value_wtf8); 67 | 68 | return value_wtf8; 69 | } 70 | 71 | /// Get DWORD (u32) from registry. 72 | pub fn getDword(reg: RegistryWtf8, subkey: []const u8, value_name: []const u8) error{ ValueNameNotFound, NotADword, DwordTooLong, DwordNotFound }!u32 { 73 | const subkey_wtf16le: [:0]const u16 = subkey_wtf16le: { 74 | var subkey_wtf16le_buf: [RegistryWtf16Le.key_name_max_len]u16 = undefined; 75 | const subkey_wtf16le_len: usize = std.unicode.wtf8ToWtf16Le(subkey_wtf16le_buf[0..], subkey) catch unreachable; 76 | subkey_wtf16le_buf[subkey_wtf16le_len] = 0; 77 | break :subkey_wtf16le subkey_wtf16le_buf[0..subkey_wtf16le_len :0]; 78 | }; 79 | 80 | const value_name_wtf16le: [:0]const u16 = value_name_wtf16le: { 81 | var value_name_wtf16le_buf: [RegistryWtf16Le.value_name_max_len]u16 = undefined; 82 | const value_name_wtf16le_len: usize = std.unicode.wtf8ToWtf16Le(value_name_wtf16le_buf[0..], value_name) catch unreachable; 83 | value_name_wtf16le_buf[value_name_wtf16le_len] = 0; 84 | break :value_name_wtf16le value_name_wtf16le_buf[0..value_name_wtf16le_len :0]; 85 | }; 86 | 87 | const registry_wtf16le: RegistryWtf16Le = .{ .key = reg.key }; 88 | return registry_wtf16le.getDword(subkey_wtf16le, value_name_wtf16le); 89 | } 90 | 91 | /// Under private space with flags: 92 | /// KEY_QUERY_VALUE and KEY_ENUMERATE_SUB_KEYS. 93 | /// After finishing work, call `closeKey`. 94 | pub fn loadFromPath(absolute_path: []const u8) error{KeyNotFound}!RegistryWtf8 { 95 | const absolute_path_wtf16le: [:0]const u16 = absolute_path_wtf16le: { 96 | var absolute_path_wtf16le_buf: [RegistryWtf16Le.value_name_max_len]u16 = undefined; 97 | const absolute_path_wtf16le_len: usize = std.unicode.wtf8ToWtf16Le(absolute_path_wtf16le_buf[0..], absolute_path) catch unreachable; 98 | absolute_path_wtf16le_buf[absolute_path_wtf16le_len] = 0; 99 | break :absolute_path_wtf16le absolute_path_wtf16le_buf[0..absolute_path_wtf16le_len :0]; 100 | }; 101 | 102 | const registry_wtf16le = try RegistryWtf16Le.loadFromPath(absolute_path_wtf16le); 103 | return .{ .key = registry_wtf16le.key }; 104 | } 105 | }; 106 | 107 | const RegistryWtf16Le = struct { 108 | key: windows.HKEY, 109 | 110 | /// Includes root key (f.e. HKEY_LOCAL_MACHINE). 111 | /// https://learn.microsoft.com/en-us/windows/win32/sysinfo/registry-element-size-limits 112 | pub const key_name_max_len = 255; 113 | /// In Unicode characters. 114 | /// https://learn.microsoft.com/en-us/windows/win32/sysinfo/registry-element-size-limits 115 | pub const value_name_max_len = 16_383; 116 | 117 | /// Under HKEY_LOCAL_MACHINE with flags: 118 | /// KEY_QUERY_VALUE, KEY_ENUMERATE_SUB_KEYS, optionally KEY_WOW64_32KEY. 119 | /// After finishing work, call `closeKey`. 120 | fn openKey(hkey: windows.HKEY, key_wtf16le: [:0]const u16, options: OpenOptions) error{KeyNotFound}!RegistryWtf16Le { 121 | var key: windows.HKEY = undefined; 122 | var access: windows.REGSAM = windows.KEY_QUERY_VALUE | windows.KEY_ENUMERATE_SUB_KEYS; 123 | if (options.wow64_32) access |= windows.KEY_WOW64_32KEY; 124 | const return_code_int: windows.HRESULT = windows.advapi32.RegOpenKeyExW( 125 | hkey, 126 | key_wtf16le, 127 | 0, 128 | access, 129 | &key, 130 | ); 131 | const return_code: windows.Win32Error = @enumFromInt(return_code_int); 132 | switch (return_code) { 133 | .SUCCESS => {}, 134 | .FILE_NOT_FOUND => return error.KeyNotFound, 135 | 136 | else => return error.KeyNotFound, 137 | } 138 | return .{ .key = key }; 139 | } 140 | 141 | /// Closes key, after that usage is invalid 142 | fn closeKey(reg: RegistryWtf16Le) void { 143 | const return_code_int: windows.HRESULT = windows.advapi32.RegCloseKey(reg.key); 144 | const return_code: windows.Win32Error = @enumFromInt(return_code_int); 145 | switch (return_code) { 146 | .SUCCESS => {}, 147 | else => {}, 148 | } 149 | } 150 | 151 | /// Get string ([:0]const u16) from registry. 152 | fn getString(reg: RegistryWtf16Le, allocator: std.mem.Allocator, subkey_wtf16le: [:0]const u16, value_name_wtf16le: [:0]const u16) error{ OutOfMemory, ValueNameNotFound, NotAString, StringNotFound }![]const u16 { 153 | var actual_type: windows.ULONG = undefined; 154 | 155 | // Calculating length to allocate 156 | var value_wtf16le_buf_size: u32 = 0; // in bytes, including any terminating NUL character or characters. 157 | var return_code_int: windows.HRESULT = windows.advapi32.RegGetValueW( 158 | reg.key, 159 | subkey_wtf16le, 160 | value_name_wtf16le, 161 | RRF.RT_REG_SZ, 162 | &actual_type, 163 | null, 164 | &value_wtf16le_buf_size, 165 | ); 166 | 167 | // Check returned code and type 168 | var return_code: windows.Win32Error = @enumFromInt(return_code_int); 169 | switch (return_code) { 170 | .SUCCESS => std.debug.assert(value_wtf16le_buf_size != 0), 171 | .MORE_DATA => unreachable, // We are only reading length 172 | .FILE_NOT_FOUND => return error.ValueNameNotFound, 173 | .INVALID_PARAMETER => unreachable, // We didn't combine RRF.SUBKEY_WOW6464KEY and RRF.SUBKEY_WOW6432KEY 174 | else => return error.StringNotFound, 175 | } 176 | switch (actual_type) { 177 | windows.REG.SZ => {}, 178 | else => return error.NotAString, 179 | } 180 | 181 | const value_wtf16le_buf: []u16 = try allocator.alloc(u16, std.math.divCeil(u32, value_wtf16le_buf_size, 2) catch unreachable); 182 | errdefer allocator.free(value_wtf16le_buf); 183 | 184 | return_code_int = windows.advapi32.RegGetValueW( 185 | reg.key, 186 | subkey_wtf16le, 187 | value_name_wtf16le, 188 | RRF.RT_REG_SZ, 189 | &actual_type, 190 | value_wtf16le_buf.ptr, 191 | &value_wtf16le_buf_size, 192 | ); 193 | 194 | // Check returned code and (just in case) type again. 195 | return_code = @enumFromInt(return_code_int); 196 | switch (return_code) { 197 | .SUCCESS => {}, 198 | .MORE_DATA => unreachable, // Calculated first time length should be enough, even overestimated 199 | .FILE_NOT_FOUND => return error.ValueNameNotFound, 200 | .INVALID_PARAMETER => unreachable, // We didn't combine RRF.SUBKEY_WOW6464KEY and RRF.SUBKEY_WOW6432KEY 201 | else => return error.StringNotFound, 202 | } 203 | switch (actual_type) { 204 | windows.REG.SZ => {}, 205 | else => return error.NotAString, 206 | } 207 | 208 | const value_wtf16le: []const u16 = value_wtf16le: { 209 | // note(bratishkaerik): somehow returned value in `buf_len` is overestimated by Windows and contains extra space 210 | // we will just search for zero termination and forget length 211 | // Windows sure is strange 212 | const value_wtf16le_overestimated: [*:0]const u16 = @ptrCast(value_wtf16le_buf.ptr); 213 | break :value_wtf16le std.mem.span(value_wtf16le_overestimated); 214 | }; 215 | 216 | _ = allocator.resize(value_wtf16le_buf, value_wtf16le.len); 217 | return value_wtf16le; 218 | } 219 | 220 | /// Get DWORD (u32) from registry. 221 | fn getDword(reg: RegistryWtf16Le, subkey_wtf16le: [:0]const u16, value_name_wtf16le: [:0]const u16) error{ ValueNameNotFound, NotADword, DwordTooLong, DwordNotFound }!u32 { 222 | var actual_type: windows.ULONG = undefined; 223 | var reg_size: u32 = @sizeOf(u32); 224 | var reg_value: u32 = 0; 225 | 226 | const return_code_int: windows.HRESULT = windows.advapi32.RegGetValueW( 227 | reg.key, 228 | subkey_wtf16le, 229 | value_name_wtf16le, 230 | RRF.RT_REG_DWORD, 231 | &actual_type, 232 | ®_value, 233 | ®_size, 234 | ); 235 | const return_code: windows.Win32Error = @enumFromInt(return_code_int); 236 | switch (return_code) { 237 | .SUCCESS => {}, 238 | .MORE_DATA => return error.DwordTooLong, 239 | .FILE_NOT_FOUND => return error.ValueNameNotFound, 240 | .INVALID_PARAMETER => unreachable, // We didn't combine RRF.SUBKEY_WOW6464KEY and RRF.SUBKEY_WOW6432KEY 241 | else => return error.DwordNotFound, 242 | } 243 | 244 | switch (actual_type) { 245 | windows.REG.DWORD => {}, 246 | else => return error.NotADword, 247 | } 248 | 249 | return reg_value; 250 | } 251 | 252 | /// Under private space with flags: 253 | /// KEY_QUERY_VALUE and KEY_ENUMERATE_SUB_KEYS. 254 | /// After finishing work, call `closeKey`. 255 | fn loadFromPath(absolute_path_as_wtf16le: [:0]const u16) error{KeyNotFound}!RegistryWtf16Le { 256 | var key: windows.HKEY = undefined; 257 | 258 | const return_code_int: windows.HRESULT = std.os.windows.advapi32.RegLoadAppKeyW( 259 | absolute_path_as_wtf16le, 260 | &key, 261 | windows.KEY_QUERY_VALUE | windows.KEY_ENUMERATE_SUB_KEYS, 262 | 0, 263 | 0, 264 | ); 265 | const return_code: windows.Win32Error = @enumFromInt(return_code_int); 266 | switch (return_code) { 267 | .SUCCESS => {}, 268 | else => return error.KeyNotFound, 269 | } 270 | 271 | return .{ .key = key }; 272 | } 273 | }; 274 | -------------------------------------------------------------------------------- /src/androidbuild/androidbuild.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | const builtin = @import("builtin"); 3 | 4 | const Target = std.Target; 5 | const ResolvedTarget = std.Build.ResolvedTarget; 6 | const LazyPath = std.Build.LazyPath; 7 | 8 | const log = std.log.scoped(.@"zig-android-sdk"); 9 | 10 | /// API Level is an enum the maps the Android OS version to the API level 11 | /// 12 | /// https://en.wikipedia.org/wiki/Android_version_history 13 | /// https://apilevels.com/ 14 | pub const APILevel = enum(u32) { 15 | /// KitKat (2013) 16 | /// Android 4.4 = 19 17 | android4_4 = 19, 18 | /// Lollipop (2014) 19 | android5 = 21, 20 | /// Marshmallow (2015) 21 | android6 = 23, 22 | /// Nougat (2016) 23 | android7 = 24, 24 | /// Oreo (2017) 25 | android8 = 26, 26 | /// Quince Tart (2018) 27 | android9 = 28, 28 | /// Quince Tart (2019) 29 | android10 = 29, 30 | /// Red Velvet Cake (2020) 31 | android11 = 30, 32 | /// Snow Cone (2021) 33 | android12 = 31, 34 | /// Tiramisu (2022) 35 | android13 = 33, 36 | /// Upside Down Cake (2023) 37 | android14 = 34, 38 | /// Vanilla Ice Cream 39 | android15 = 35, 40 | /// Baklava 41 | android16 = 36, 42 | // allow custom overrides (incase this library is not up to date with the latest android version) 43 | _, 44 | }; 45 | 46 | pub const KeyStore = struct { 47 | file: LazyPath, 48 | password: []const u8, 49 | }; 50 | 51 | pub fn getAndroidTriple(target: ResolvedTarget) error{InvalidAndroidTarget}![]const u8 { 52 | if (!target.result.abi.isAndroid()) return error.InvalidAndroidTarget; 53 | return switch (target.result.cpu.arch) { 54 | .x86 => "i686-linux-android", 55 | .x86_64 => "x86_64-linux-android", 56 | .arm => "arm-linux-androideabi", 57 | .aarch64 => "aarch64-linux-android", 58 | .riscv64 => "riscv64-linux-android", 59 | else => error.InvalidAndroidTarget, 60 | }; 61 | } 62 | 63 | /// Will return a slice of Android targets 64 | /// - If -Dandroid=true, return all Android targets (x86, x86_64, aarch64, etc) 65 | /// - If -Dtarget=aarch64-linux-android, return a slice with the one specified Android target 66 | /// 67 | /// If none of the above, then return a zero length slice. 68 | pub fn standardTargets(b: *std.Build, target: ResolvedTarget) []ResolvedTarget { 69 | const all_targets = b.option(bool, "android", "if true, build for all Android targets (x86, x86_64, aarch64, etc)") orelse false; 70 | if (all_targets) { 71 | return getAllAndroidTargets(b); 72 | } 73 | if (!target.result.abi.isAndroid()) { 74 | return &[0]ResolvedTarget{}; 75 | } 76 | if (target.result.os.tag != .linux) { 77 | const linuxTriple = target.result.linuxTriple(b.allocator) catch @panic("OOM"); 78 | @panic(b.fmt("unsupported Android target given: {s}, expected linux to be target OS", .{linuxTriple})); 79 | } 80 | for (supported_android_targets) |android_target| { 81 | if (target.result.cpu.arch == android_target.cpu_arch) { 82 | const resolved_targets = b.allocator.alloc(ResolvedTarget, 1) catch @panic("OOM"); 83 | resolved_targets[0] = b.resolveTargetQuery(android_target.queryTarget()); 84 | return resolved_targets; 85 | } 86 | } 87 | const linuxTriple = target.result.linuxTriple(b.allocator) catch @panic("OOM"); 88 | @panic(b.fmt("unsupported Android target given: {s}", .{linuxTriple})); 89 | } 90 | 91 | fn getAllAndroidTargets(b: *std.Build) []ResolvedTarget { 92 | const resolved_targets = b.allocator.alloc(ResolvedTarget, supported_android_targets.len) catch @panic("OOM"); 93 | for (supported_android_targets, 0..) |android_target, i| { 94 | const resolved_target = b.resolveTargetQuery(android_target.queryTarget()); 95 | resolved_targets[i] = resolved_target; 96 | } 97 | return resolved_targets; 98 | } 99 | 100 | pub fn runNameContext(comptime name: []const u8) []const u8 { 101 | return "zig-android-sdk " ++ name; 102 | } 103 | 104 | pub fn printErrorsAndExit(message: []const u8, errors: []const []const u8) noreturn { 105 | nosuspend { 106 | log.err("{s}", .{message}); 107 | const stderr = std.io.getStdErr().writer(); 108 | std.debug.lockStdErr(); 109 | defer std.debug.unlockStdErr(); 110 | for (errors) |err| { 111 | var it = std.mem.splitScalar(u8, err, '\n'); 112 | const headline = it.next() orelse continue; 113 | stderr.writeAll("- ") catch {}; 114 | stderr.writeAll(headline) catch {}; 115 | stderr.writeByte('\n') catch {}; 116 | while (it.next()) |line| { 117 | stderr.writeAll(" ") catch {}; 118 | stderr.writeAll(line) catch {}; 119 | stderr.writeByte('\n') catch {}; 120 | } 121 | } 122 | stderr.writeByte('\n') catch {}; 123 | } 124 | std.process.exit(1); 125 | } 126 | 127 | const AndroidTargetQuery = struct { 128 | cpu_arch: Target.Cpu.Arch, 129 | cpu_features_add: Target.Cpu.Feature.Set = Target.Cpu.Feature.Set.empty, 130 | 131 | fn queryTarget(android_target: AndroidTargetQuery) Target.Query { 132 | return .{ 133 | .os_tag = .linux, 134 | .cpu_model = .baseline, 135 | .abi = if (android_target.cpu_arch != .arm) .android else .androideabi, 136 | .cpu_arch = android_target.cpu_arch, 137 | .cpu_features_add = android_target.cpu_features_add, 138 | // TODO(jae): 2025-05-11 139 | // Setup Android API Level for Zig 0.14.0+ 140 | // .android_api_level = null, 141 | }; 142 | } 143 | }; 144 | 145 | const supported_android_targets = [_]AndroidTargetQuery{ 146 | .{ 147 | // i686-linux-android 148 | .cpu_arch = .x86, 149 | }, 150 | .{ 151 | // x86_64-linux-android 152 | .cpu_arch = .x86_64, 153 | }, 154 | .{ 155 | // aarch64-linux-android 156 | .cpu_arch = .aarch64, 157 | .cpu_features_add = Target.aarch64.featureSet(&.{.v8a}), 158 | }, 159 | // NOTE(jae): 2024-09-08 160 | // 'arm-linux-androideabi' previously didn't work with Zig 0.13.0 for compiling C code like SDL2 or OpenXR due to "__ARM_ARCH" not being "7" 161 | .{ 162 | // arm-linux-androideabi 163 | .cpu_arch = .arm, 164 | .cpu_features_add = Target.arm.featureSet(&.{.v7a}), 165 | }, 166 | }; 167 | -------------------------------------------------------------------------------- /src/androidbuild/builtin_options_update.zig: -------------------------------------------------------------------------------- 1 | //! BuiltinOptionsUpdate will update the *Options 2 | 3 | const std = @import("std"); 4 | const androidbuild = @import("androidbuild.zig"); 5 | const builtin = @import("builtin"); 6 | const Build = std.Build; 7 | const Step = Build.Step; 8 | const Options = Build.Step.Options; 9 | const LazyPath = Build.LazyPath; 10 | const fs = std.fs; 11 | const mem = std.mem; 12 | const assert = std.debug.assert; 13 | 14 | pub const base_id: Step.Id = .custom; 15 | 16 | step: Step, 17 | 18 | options: *Options, 19 | package_name_stdout: LazyPath, 20 | 21 | pub fn create(owner: *std.Build, options: *Options, package_name_stdout: LazyPath) void { 22 | const builtin_options_update = owner.allocator.create(@This()) catch @panic("OOM"); 23 | builtin_options_update.* = .{ 24 | .step = Step.init(.{ 25 | .id = base_id, 26 | .name = androidbuild.runNameContext("builtin_options_update"), 27 | .owner = owner, 28 | .makeFn = comptime if (std.mem.eql(u8, builtin.zig_version_string, "0.13.0")) 29 | make013 30 | else 31 | makeLatest, 32 | }), 33 | .options = options, 34 | .package_name_stdout = package_name_stdout, 35 | }; 36 | // Run step relies on this finishing 37 | options.step.dependOn(&builtin_options_update.step); 38 | // Depend on package name stdout before running this step 39 | package_name_stdout.addStepDependencies(&builtin_options_update.step); 40 | } 41 | 42 | /// make for zig 0.13.0 43 | fn make013(step: *Step, prog_node: std.Progress.Node) !void { 44 | _ = prog_node; // autofix 45 | try make(step); 46 | } 47 | 48 | /// make for zig 0.14.0+ 49 | fn makeLatest(step: *Step, options: Build.Step.MakeOptions) !void { 50 | _ = options; // autofix 51 | try make(step); 52 | } 53 | 54 | fn make(step: *Step) !void { 55 | const b = step.owner; 56 | const builtin_options_update: *@This() = @fieldParentPtr("step", step); 57 | const options = builtin_options_update.options; 58 | 59 | const package_name_path = builtin_options_update.package_name_stdout.getPath2(b, step); 60 | 61 | const file = try fs.openFileAbsolute(package_name_path, .{}); 62 | 63 | // Read package name from stdout and strip line feed / carriage return 64 | // ie. "com.zig.sdl2\n\r" 65 | const package_name_filedata = try file.readToEndAlloc(b.allocator, 8192); 66 | const package_name_stripped = std.mem.trimRight(u8, package_name_filedata, " \r\n"); 67 | const package_name: [:0]const u8 = try b.allocator.dupeZ(u8, package_name_stripped); 68 | 69 | options.addOption([:0]const u8, "package_name", package_name); 70 | } 71 | 72 | const BuiltinOptionsUpdate = @This(); 73 | -------------------------------------------------------------------------------- /src/androidbuild/d8glob.zig: -------------------------------------------------------------------------------- 1 | //! D8Glob is specific for D8 and is used to collect all *.class output files after a javac process generates them 2 | 3 | const std = @import("std"); 4 | const androidbuild = @import("androidbuild.zig"); 5 | const builtin = @import("builtin"); 6 | const Build = std.Build; 7 | const Step = Build.Step; 8 | const Run = Build.Step.Run; 9 | const LazyPath = Build.LazyPath; 10 | const fs = std.fs; 11 | const mem = std.mem; 12 | const assert = std.debug.assert; 13 | 14 | pub const base_id: Step.Id = .custom; 15 | 16 | step: Step, 17 | 18 | /// Runner to update 19 | run: *Build.Step.Run, 20 | 21 | /// The directory that will contain the files to glob 22 | dir: LazyPath, 23 | 24 | const file_ext = ".class"; 25 | 26 | /// Creates a D8Glob step which is used to collect all *.class output files after a javac process generates them 27 | pub fn create(owner: *std.Build, run: *Run, dir: LazyPath) void { 28 | const glob = owner.allocator.create(@This()) catch @panic("OOM"); 29 | glob.* = .{ 30 | .step = Step.init(.{ 31 | .id = base_id, 32 | .name = androidbuild.runNameContext("d8glob"), 33 | .owner = owner, 34 | .makeFn = comptime if (std.mem.eql(u8, builtin.zig_version_string, "0.13.0")) 35 | make013 36 | else 37 | makeLatest, 38 | }), 39 | .run = run, 40 | .dir = dir, 41 | }; 42 | // Run step relies on this finishing 43 | run.step.dependOn(&glob.step); 44 | // If dir is generated then this will wait for that dir to generate 45 | dir.addStepDependencies(&glob.step); 46 | } 47 | 48 | /// make for zig 0.13.0 49 | fn make013(step: *Step, prog_node: std.Progress.Node) !void { 50 | _ = prog_node; // autofix 51 | try make(step); 52 | } 53 | 54 | /// make for zig 0.14.0+ 55 | fn makeLatest(step: *Step, options: Build.Step.MakeOptions) !void { 56 | _ = options; // autofix 57 | try make(step); 58 | } 59 | 60 | fn make(step: *Step) !void { 61 | const b = step.owner; 62 | const arena = b.allocator; 63 | const glob: *@This() = @fieldParentPtr("step", step); 64 | const d8 = glob.run; 65 | 66 | const search_dir = glob.dir.getPath2(b, step); 67 | 68 | // NOTE(jae): 2024-09-22 69 | // Change current working directory to where the Java classes are 70 | // This is to avoid the Java error "command line too long" that can occur with d8 71 | // 72 | // I was hitting this due to a path this long on Windows 73 | // J:\ZigProjects\openxr-game\third-party\zig-android-sdk\examples\sdl2\.zig-cache\o\9012552ac182acf9dfb49627cf81376e\android_dex 74 | // 75 | // A deeper fix to this problem could be: 76 | // - Zip up all the *.class files and just provide that as ONE argument or alternatively 77 | // - If "d8" has the ability to pass a file of command line parameters, that would work too but I haven't seen any in the docs 78 | d8.setCwd(glob.dir); 79 | 80 | var dir = try fs.openDirAbsolute(search_dir, .{ .iterate = true }); 81 | defer dir.close(); 82 | var walker = try dir.walk(arena); 83 | defer walker.deinit(); 84 | while (try walker.next()) |entry| { 85 | if (entry.kind != .file) { 86 | continue; 87 | } 88 | // NOTE(jae): 2024-10-01 89 | // Initially ignored classes with alternate API postfixes / etc but 90 | // that did not work with SDL2 so no longer do that. 91 | // - !std.mem.containsAtLeast(u8, entry.basename, 1, "$") and 92 | // - !std.mem.containsAtLeast(u8, entry.basename, 1, "_API") 93 | if (std.mem.endsWith(u8, entry.path, file_ext)) { 94 | // NOTE(jae): 2024-09-22 95 | // We set the current working directory to "glob.Dir" and then make arguments be 96 | // relative to that directory. 97 | // 98 | // This is to avoid the Java error "command line too long" that can occur with d8 99 | d8.addArg(entry.path); 100 | d8.addFileInput(LazyPath{ 101 | .cwd_relative = try fs.path.resolve(arena, &.{ search_dir, entry.path }), 102 | }); 103 | } 104 | } 105 | } 106 | 107 | const D8Glob = @This(); 108 | --------------------------------------------------------------------------------