Skip to content

Commit

Permalink
More NDK libs: add native_app_glue cc_library and example for android…
Browse files Browse the repository at this point in the history
…/log.h (#73)

Should help with #55.
  • Loading branch information
ted-xie authored Jul 18, 2024
1 parent d4bccda commit b91e64f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
20 changes: 20 additions & 0 deletions BUILD.ndk_root.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,23 @@ cc_library(
]),
linkopts = ["-ldl"],
)

# NOTE: New projects should use GameActivity instead.
# https://developer.android.com/games/agdk/game-activity
cc_library(
name = "native_app_glue",
srcs = glob([
"sources/android/native_app_glue/*.c",
# TODO(#32): Remove this hack
"ndk/sources/android/native_app_glue/*.c",
]),
hdrs = glob([
"sources/android/native_app_glue/*.h",
# TODO(#32): Remove this hack
"ndk/sources/android/native_app_glue/*.h",
]),
)

exports_files ([
"sources/android/native_app_glue/android_native_app_glue.h",
])
1 change: 1 addition & 0 deletions examples/basic/java/com/app/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ cc_library(
name = "jni_dep",
srcs = ["jni_dep.cc"],
hdrs = ["jni_dep.h"],
linkopts = ["-llog"],
)
1 change: 1 addition & 0 deletions examples/basic/java/com/app/jni_dep.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
#include "java/com/app/jni_dep.h"

int calculate(int a, int b) {
__android_log_write(3, "MyTag", "foobar");
return a + b * 20;
}
1 change: 1 addition & 0 deletions examples/basic/java/com/app/jni_dep.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
// limitations under the License.

#pragma once
#include <android/log.h>

int calculate(int a, int b);

0 comments on commit b91e64f

Please sign in to comment.