aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerome Gaillard <jgaillard@google.com>2024-05-17 17:56:35 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2024-05-17 17:56:35 +0000
commite5ddaeeccb966b40f388f0e578e5959908be8a9f (patch)
tree4503ad2c3540eec13111a442aab50bed39aa65f9
parent3dcba36aa77d40d15134dbf714beffb21f744808 (diff)
parent88c826d2c0b20f8c29e5549333c49fb824055e6a (diff)
downloadlibnativehelper-master.tar.gz
Merge "Make a host JVM compatible version of libnativehelper" into mainHEADmastermain
-rw-r--r--Android.bp37
-rw-r--r--include/nativehelper/JNIHelp.h5
2 files changed, 36 insertions, 6 deletions
diff --git a/Android.bp b/Android.bp
index 8bd49c5..7550873 100644
--- a/Android.bp
+++ b/Android.bp
@@ -102,19 +102,18 @@ cc_library_headers {
min_sdk_version: "S", // 31
}
-cc_library_shared {
- name: "libnativehelper",
+// This library contains code that is compatible with
+// both ART and JVM. All code specific to ART should go
+// inside libnativehelper directly.
+cc_library_static {
+ name: "libnativehelper_any_vm",
defaults: ["libnativehelper_defaults"],
- bootstrap: false,
host_supported: true,
srcs: [
"DlHelp.c",
"ExpandableString.c",
"JNIHelp.c",
- "JNIPlatformHelp.c",
- "JniConstants.c",
"JniInvocation.c",
- "file_descriptor_jni.c",
],
export_include_dirs: [
"header_only_include",
@@ -123,6 +122,32 @@ cc_library_shared {
"include_platform",
"include_platform_header_only",
],
+ visibility: ["//frameworks/base/libs/nativehelper_jvm"],
+ stl: "none",
+ apex_available: [
+ "com.android.art",
+ "com.android.art.debug",
+ ],
+ min_sdk_version: "S", // 31
+ target: {
+ windows: {
+ enabled: true,
+ },
+ },
+}
+
+cc_library_shared {
+ name: "libnativehelper",
+ defaults: ["libnativehelper_defaults"],
+ bootstrap: false,
+ host_supported: true,
+ srcs: [
+ "JNIPlatformHelp.c",
+ "JniConstants.c",
+ "file_descriptor_jni.c",
+ ],
+ whole_static_libs: ["libnativehelper_any_vm"],
+ export_static_lib_headers: ["libnativehelper_any_vm"],
stl: "none",
stubs: {
symbol_file: "libnativehelper.map.txt",
diff --git a/include/nativehelper/JNIHelp.h b/include/nativehelper/JNIHelp.h
index 6538ddf..f34a110 100644
--- a/include/nativehelper/JNIHelp.h
+++ b/include/nativehelper/JNIHelp.h
@@ -96,7 +96,12 @@ struct [[maybe_unused]] ExpandableString {
}
[[maybe_unused]] static const char* platformStrError(int errnum, char* buf, size_t buflen) {
+#ifdef _WIN32
+ strerror_s(buf, buflen, errnum);
+ return buf;
+#else
return safe_strerror(strerror_r, errnum, buf, buflen);
+#endif
}
[[maybe_unused]] static jmethodID FindMethod(JNIEnv* env, const char* className,