diff options
| author | ruki <[email protected]> | 2025-12-16 23:25:49 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-12-16 23:25:49 +0800 |
| commit | c9ede56339f7faf96bb6ed105fd60dfcaf01655f (patch) | |
| tree | 5abc0e8171137527e9208293e9510622bd558061 | |
| parent | 8e63376d62415825aa2836df19ebb7c895aa7a2e (diff) | |
format code and fix keystore
| -rw-r--r-- | tests/projects/android/native_app/android/debug.jks | bin | 2487 -> 2148 bytes | |||
| -rw-r--r-- | tests/projects/android/native_app/src/main.cpp | 29 | ||||
| -rw-r--r-- | tests/projects/android/native_app/xmake.lua | 3 | ||||
| -rw-r--r-- | xmake/rules/ndk/install.lua | 6 | ||||
| -rw-r--r-- | xmake/rules/ndk/load.lua | 18 | ||||
| -rw-r--r-- | xmake/rules/ndk/package.lua | 9 | ||||
| -rw-r--r-- | xmake/rules/ndk/run.lua | 6 | ||||
| -rw-r--r-- | xmake/rules/ndk/xmake.lua | 20 |
8 files changed, 46 insertions, 45 deletions
diff --git a/tests/projects/android/native_app/android/debug.jks b/tests/projects/android/native_app/android/debug.jks Binary files differindex b4eb4f9f2..0a18aa012 100644 --- a/tests/projects/android/native_app/android/debug.jks +++ b/tests/projects/android/native_app/android/debug.jks diff --git a/tests/projects/android/native_app/src/main.cpp b/tests/projects/android/native_app/src/main.cpp index 4c8253ead..42f5b9a37 100644 --- a/tests/projects/android/native_app/src/main.cpp +++ b/tests/projects/android/native_app/src/main.cpp @@ -1,21 +1,16 @@ #include <raylib.h> -int main() { - InitWindow(0, 0, "Hello, xmake for raylib android!"); +int main(int argc, char** argv) { + InitWindow(0, 0, "Hello, xmake for raylib android!"); + SetTargetFPS(60); - SetTargetFPS(60); + while (!WindowShouldClose()) { + BeginDrawing(); + ClearBackground(BLACK); + DrawText("Hello, xmake for raylib android!", 250, 250, 25, BLUE); + EndDrawing(); + } - while (!WindowShouldClose()) { // Main game loop - BeginDrawing(); - - ClearBackground(BLACK); - - DrawText("Hello, xmake for raylib android!", 250, 250, 25, BLUE); - - EndDrawing(); - } - - CloseWindow(); - - return 0; -}
\ No newline at end of file + CloseWindow(); + return 0; +} diff --git a/tests/projects/android/native_app/xmake.lua b/tests/projects/android/native_app/xmake.lua index 81ac545e5..e959fdf32 100644 --- a/tests/projects/android/native_app/xmake.lua +++ b/tests/projects/android/native_app/xmake.lua @@ -5,9 +5,8 @@ add_requires("raylib 5.5.0") target("raydemo_android") set_kind("binary") set_languages("c++17") - add_files("src/main.cpp") + add_files("src/main.cpp") add_packages("raylib") - add_rules("android.native_app", { android_sdk_version = "35", android_manifest = "android/AndroidManifest.xml", diff --git a/xmake/rules/ndk/install.lua b/xmake/rules/ndk/install.lua index 8dae64ccd..6ab137c89 100644 --- a/xmake/rules/ndk/install.lua +++ b/xmake/rules/ndk/install.lua @@ -1,4 +1,4 @@ --- !A cross-platform build utility based on Lua +--!A cross-platform build utility based on Lua -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. @@ -18,17 +18,17 @@ -- @file install.lua -- +-- main entry function main(target) local android_sdkdir = target:toolchain("ndk"):config("android_sdk") local adb = path.join(android_sdkdir, "platform-tools", "adb") local final_apk = path.join(target:targetdir(), target:basename() .. ".apk") - assert(os.exists(final_apk)) + assert(os.exists(final_apk)) cprint("${color.success}[Android][Install] try to install apk ...") os.vrunv(adb, {"install", final_apk}) cprint("${color.success}[Android][Install] done.") - end diff --git a/xmake/rules/ndk/load.lua b/xmake/rules/ndk/load.lua index 8119c31a2..fbb7b72c8 100644 --- a/xmake/rules/ndk/load.lua +++ b/xmake/rules/ndk/load.lua @@ -1,4 +1,4 @@ --- !A cross-platform build utility based on Lua +--!A cross-platform build utility based on Lua -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. @@ -19,20 +19,26 @@ -- -- main entry -function main (target) +function main(target) - local toolchain_ndk = target:toolchain("ndk") + -- only for android target + if not target:is_plat("android") then + wprint("rule(android.native_app): only for android system!") + target:rule_enable("android.native_app", false) + return + end + local toolchain_ndk = target:toolchain("ndk") local ndk_root = toolchain_ndk:config("ndk") if not ndk_root then raise("NDK path not set! Please set NDK path properly.") end - -- Add glue file to target + -- add glue file to target local native_app_glue_file = path.join(ndk_root, "sources", "android", "native_app_glue", "android_native_app_glue.c") + local native_app_glue_dir = path.directory(native_app_glue_file) target:add("files", native_app_glue_file) - target:add("includedirs", native_app_glue_path) + target:add("includedirs", native_app_glue_dir) target:set("kind", "shared") - end diff --git a/xmake/rules/ndk/package.lua b/xmake/rules/ndk/package.lua index 795b87d0d..6583ee0a0 100644 --- a/xmake/rules/ndk/package.lua +++ b/xmake/rules/ndk/package.lua @@ -1,4 +1,4 @@ --- !A cross-platform build utility based on Lua +--!A cross-platform build utility based on Lua -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. @@ -17,9 +17,13 @@ -- @author keosu -- @file package.lua -- + +-- imports import("core.tool.toolchain") +-- main entry function main(target) + local conf = target:extraconf("rules", "android.native_app") local android_sdk_version = conf.android_sdk_version local android_manifest = conf.android_manifest @@ -51,7 +55,7 @@ function main(target) local zipalign = path.join(sdk_tool_path, "zipalign" .. (is_host("windows") and ".exe" or "")) local apksigner = path.join(sdk_tool_path, "apksigner" .. (is_host("windows") and ".bat" or "")) - -- pack resources + -- pack resources local resonly_apk = path.join(tmp_path, "res_only.apk") local androidjar = path.join(android_sdkdir, "platforms", string.format("android-%s", android_sdk_version), "android.jar") @@ -91,5 +95,4 @@ function main(target) os.vrunv(apksigner, apksigner_argv) cprint("${color.success}[Android][Package]${clear} Done!") - end diff --git a/xmake/rules/ndk/run.lua b/xmake/rules/ndk/run.lua index 1c08099bd..d4ab85be5 100644 --- a/xmake/rules/ndk/run.lua +++ b/xmake/rules/ndk/run.lua @@ -1,4 +1,4 @@ --- !A cross-platform build utility based on Lua +--!A cross-platform build utility based on Lua -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. @@ -18,9 +18,10 @@ -- @file run.lua -- +-- main entry function main(target) - local conf = target:extraconf("rules", "android.native_app") + local conf = target:extraconf("rules", "android.native_app") local package_name = conf.package_name local activity_name = conf.activity_name or "android.app.NativeActivity" @@ -31,5 +32,4 @@ function main(target) cprint("${color.success}[Android] Starting app ...") os.vrunv(adb, run_argv) - end diff --git a/xmake/rules/ndk/xmake.lua b/xmake/rules/ndk/xmake.lua index 313c57c05..4e97dc3fc 100644 --- a/xmake/rules/ndk/xmake.lua +++ b/xmake/rules/ndk/xmake.lua @@ -20,17 +20,15 @@ -- define rule: build android native app with NDK rule("android.native_app") - -- this rule only for android target - if is_plat("android") then - -- we must set_kind and add some glue files to target - on_load("load") - -- generate android apk package - on_package("package") + -- we must set_kind and add some glue files to target + on_load("load") - -- install android package with adb - on_install("install") + -- generate android apk package + on_package("package") - -- run android app through adb - after_install("run") - end
\ No newline at end of file + -- install android package with adb + on_install("install") + + -- run android app through adb + after_install("run") |
