diff options
| author | ruki <[email protected]> | 2025-12-16 23:33:30 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-12-16 23:33:30 +0800 |
| commit | 51ef6420b6bba35a34f3ac9dafd5b5d36eb24e2d (patch) | |
| tree | b50d91101f268985fdd719056061c3a91b01ba7e | |
| parent | b0f05a5196bb5c4b0590895e69c64fd1a2be3f9c (diff) | |
improve run logs
| -rw-r--r-- | tests/projects/android/native_app/src/main.cpp | 5 | ||||
| -rw-r--r-- | tests/projects/android/native_app/xmake.lua | 4 | ||||
| -rw-r--r-- | xmake/rules/ndk/install.lua | 1 | ||||
| -rw-r--r-- | xmake/rules/ndk/package.lua | 1 | ||||
| -rw-r--r-- | xmake/rules/ndk/run.lua | 18 | ||||
| -rw-r--r-- | xmake/rules/ndk/xmake.lua | 3 |
6 files changed, 28 insertions, 4 deletions
diff --git a/tests/projects/android/native_app/src/main.cpp b/tests/projects/android/native_app/src/main.cpp index 42f5b9a37..b7dda5d34 100644 --- a/tests/projects/android/native_app/src/main.cpp +++ b/tests/projects/android/native_app/src/main.cpp @@ -1,8 +1,13 @@ #include <raylib.h> +#include <android/log.h> + +#define LOG_TAG "raydemo_android" +#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__) int main(int argc, char** argv) { InitWindow(0, 0, "Hello, xmake for raylib android!"); SetTargetFPS(60); + LOGI("raylib application is running!"); while (!WindowShouldClose()) { BeginDrawing(); diff --git a/tests/projects/android/native_app/xmake.lua b/tests/projects/android/native_app/xmake.lua index e959fdf32..587994928 100644 --- a/tests/projects/android/native_app/xmake.lua +++ b/tests/projects/android/native_app/xmake.lua @@ -6,6 +6,7 @@ target("raydemo_android") set_kind("binary") set_languages("c++17") add_files("src/main.cpp") + add_syslinks("log") add_packages("raylib") add_rules("android.native_app", { android_sdk_version = "35", @@ -13,5 +14,6 @@ target("raydemo_android") android_res = "android/res", keystore = "android/debug.jks", keystore_pass = "123456", - package_name = "com.raylib.demo" + package_name = "com.raylib.demo", + logcat_filters = {"raydemo_android", "raylib"} }) diff --git a/xmake/rules/ndk/install.lua b/xmake/rules/ndk/install.lua index 20f213f05..672a623ce 100644 --- a/xmake/rules/ndk/install.lua +++ b/xmake/rules/ndk/install.lua @@ -19,7 +19,6 @@ -- -- imports -import("core.tool.toolchain") import("run", {alias = "run_app"}) -- main entry diff --git a/xmake/rules/ndk/package.lua b/xmake/rules/ndk/package.lua index 5b4921ddb..797efa22e 100644 --- a/xmake/rules/ndk/package.lua +++ b/xmake/rules/ndk/package.lua @@ -19,7 +19,6 @@ -- -- imports -import("core.tool.toolchain") import("utils.progress") -- main entry diff --git a/xmake/rules/ndk/run.lua b/xmake/rules/ndk/run.lua index d85af1de9..612d18c7e 100644 --- a/xmake/rules/ndk/run.lua +++ b/xmake/rules/ndk/run.lua @@ -18,6 +18,9 @@ -- @file run.lua -- +-- imports +import("core.base.tty") + -- main entry function main(target) @@ -32,4 +35,19 @@ function main(target) cprint("running %s ...", package_name) os.vrunv(adb, run_argv) + + -- show logcat + local logcat_argv = {"logcat"} + if io.isatty() and (tty.has_color8() or tty.has_color256()) then + table.insert(logcat_argv, "-v") + table.insert(logcat_argv, "color") + end + local logcat_filters = conf.logcat_filters + if logcat_filters then + table.insert(logcat_argv, "-s") + for _, filter in ipairs(logcat_filters) do + table.insert(logcat_argv, filter) + end + end + os.execv(adb, logcat_argv) end diff --git a/xmake/rules/ndk/xmake.lua b/xmake/rules/ndk/xmake.lua index 783abac65..0c58d7d09 100644 --- a/xmake/rules/ndk/xmake.lua +++ b/xmake/rules/ndk/xmake.lua @@ -30,7 +30,8 @@ -- android_assets = "android/assets", -- keystore = "android/debug.jks", -- keystore_pass = "123456", --- package_name = "com.raylib.demo" +-- package_name = "com.raylib.demo", +-- logcat_filters = {"raydemo_android", "raylib"} -- }) -- @endcode -- |
