1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

android: enable custom (e)println output via android log system (#8135)

This commit is contained in:
Larpon 2021-01-17 05:32:59 +01:00 committed by GitHub
parent 9376c57a51
commit 512f62b7a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 7 deletions

View File

@ -936,13 +936,6 @@ fn (mut app App) showfps() {
} }
} }
// TODO: Move this somewhere else (vlib?) once Android support is merged
$if android {
#include <android/log.h>
#define LOG_TAG "v_logcat_test"
#define printf(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
#define fprintf(a, ...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
}
fn main() { fn main() {
mut app := &App{} mut app := &App{}
app.new_game() app.new_game()

20
thirdparty/sokol/sokol_v.h vendored Normal file
View File

@ -0,0 +1,20 @@
#if defined(__ANDROID__)
// Adapted from https://stackoverflow.com/a/196018/1904615
#define V_ANDROID_LOG_STR_VALUE(arg) #arg
#define V_ANDROID_LOG_NAME(tag_name) V_ANDROID_LOG_STR_VALUE(tag_name)
#ifndef V_ANDROID_LOG_TAG
#if defined(APPNAME)
#define V_ANDROID_LOG_TAG APPNAME
#else
#define V_ANDROID_LOG_TAG "V_ANDROID"
#endif
#endif
#define V_ANDROID_LOG_TAG_NAME V_ANDROID_LOG_NAME(V_ANDROID_LOG_TAG)
#include <android/log.h>
#define printf(...) __android_log_print(ANDROID_LOG_INFO, V_ANDROID_LOG_TAG_NAME, __VA_ARGS__)
#define fprintf(a, ...) __android_log_print(ANDROID_LOG_ERROR, V_ANDROID_LOG_TAG_NAME, __VA_ARGS__)
#endif

View File

@ -41,6 +41,8 @@ pub const (
#flag solaris -DSOKOL_NO_ENTRY #flag solaris -DSOKOL_NO_ENTRY
// TODO end // TODO end
#include "sokol_v.h"
#include "sokol_app.h" #include "sokol_app.h"
#define SOKOL_IMPL #define SOKOL_IMPL