Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AndroidAppBuilder] add missing includes to template #89197

Merged
merged 2 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/tasks/AndroidAppBuilder/Templates/CMakeLists-android.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ if(ANDROID_NDK_MAJOR VERSION_LESS "23")
message(FATAL_ERROR "Error: need at least Android NDK 23, got ${ANDROID_NDK_REVISION}!")
endif()

add_compile_options(-Werror=missing-prototypes -Werror=missing-declarations -Wall -std=c99)

add_library(
monodroid
SHARED
Expand Down
18 changes: 15 additions & 3 deletions src/tasks/AndroidAppBuilder/Templates/monodroid-librarymode.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@
#include <assert.h>
#include <unistd.h>

/********* exported symbols *********/

void
Java_net_dot_MonoRunner_setEnv (JNIEnv* env, jobject thiz, jstring j_key, jstring j_value);

int
Java_net_dot_MonoRunner_initRuntime (JNIEnv* env, jobject thiz, jstring j_files_dir, jstring j_cache_dir, jstring j_testresults_dir, jstring j_entryPointLibName, jobjectArray j_args, long current_local_time);

/********* imported symbols *********/
void SayHello ();

/********* implementation *********/

static void
strncpy_str (JNIEnv *env, char *buff, jstring str, int nbuff)
{
Expand All @@ -19,9 +32,8 @@ strncpy_str (JNIEnv *env, char *buff, jstring str, int nbuff)
(*env)->ReleaseStringUTFChars (env, str, copy_buff);
}

void SayHello ();

int invoke_netlibrary_entrypoints (void)
static int
invoke_netlibrary_entrypoints (void)
{
SayHello ();

Expand Down
29 changes: 24 additions & 5 deletions src/tasks/AndroidAppBuilder/Templates/monodroid.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@

#include <mono/utils/mono-publib.h>
#include <mono/utils/mono-logger.h>
#include <mono/metadata/appdomain.h>
#include <mono/metadata/assembly.h>
#include <mono/metadata/class.h>
#include <mono/metadata/mono-debug.h>
#include <mono/metadata/mono-gc.h>
#include <mono/metadata/exception.h>
#include <mono/metadata/object.h>
#include <mono/jit/jit.h>
#include <mono/jit/mono-private-unstable.h>

Expand All @@ -23,6 +26,22 @@
#include <assert.h>
#include <unistd.h>

/********* exported symbols *********/

/* JNI exports */

void
Java_net_dot_MonoRunner_setEnv (JNIEnv* env, jobject thiz, jstring j_key, jstring j_value);

int
Java_net_dot_MonoRunner_initRuntime (JNIEnv* env, jobject thiz, jstring j_files_dir, jstring j_cache_dir, jstring j_testresults_dir, jstring j_entryPointLibName, jobjectArray j_args, long current_local_time);

// called from C#
void
invoke_external_native_api (void (*callback)(void));

/********* implementation *********/

static char *bundle_path;
static char *executable;

Expand Down Expand Up @@ -124,7 +143,7 @@ free_aot_data (MonoAssembly *assembly, int size, void *user_data, void *handle)
munmap (handle, size);
}

char *
static char *
strdup_printf (const char *msg, ...)
{
va_list args;
Expand Down Expand Up @@ -165,7 +184,7 @@ mono_droid_fetch_exception_property_string (MonoObject *obj, const char *name, b
return str ? mono_string_to_utf8 (str) : NULL;
}

void
static void
unhandled_exception_handler (MonoObject *exc, void *user_data)
{
MonoClass *type = mono_object_get_class (exc);
Expand All @@ -181,7 +200,7 @@ unhandled_exception_handler (MonoObject *exc, void *user_data)
exit (1);
}

void
static void
log_callback (const char *log_domain, const char *log_level, const char *message, mono_bool fatal, void *user_data)
{
LOG_INFO ("(%s %s) %s", log_domain, log_level, message);
Expand All @@ -195,14 +214,14 @@ log_callback (const char *log_domain, const char *log_level, const char *message
void register_aot_modules (void);
#endif

void
static void
cleanup_runtime_config (MonovmRuntimeConfigArguments *args, void *user_data)
{
free (args);
free (user_data);
}

int
static int
mono_droid_runtime_init (const char* executable, int managed_argc, char* managed_argv[], int local_date_time_offset)
{
// NOTE: these options can be set via command line args for adb or xharness, see AndroidSampleApp.csproj
Expand Down