|
33 | 33 | void |
34 | 34 | Java_net_dot_MonoRunner_setEnv (JNIEnv* env, jobject thiz, jstring j_key, jstring j_value); |
35 | 35 |
|
| 36 | +void |
| 37 | +Java_net_dot_MonoRunner_initRuntime (JNIEnv* env, jobject thiz, jstring j_files_dir, jstring j_cache_dir, jstring j_testresults_dir, long current_local_time); |
| 38 | + |
36 | 39 | int |
37 | | -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); |
| 40 | +Java_net_dot_MonoRunner_execEntryPoint (JNIEnv* env, jobject thiz, jstring j_entryPointLibName, jobjectArray j_args); |
38 | 41 |
|
39 | 42 | // called from C# |
40 | 43 | void |
@@ -221,8 +224,8 @@ cleanup_runtime_config (MonovmRuntimeConfigArguments *args, void *user_data) |
221 | 224 | free (user_data); |
222 | 225 | } |
223 | 226 |
|
224 | | -static int |
225 | | -mono_droid_runtime_init (const char* executable, int managed_argc, char* managed_argv[], int local_date_time_offset) |
| 227 | +static void |
| 228 | +mono_droid_runtime_init (int local_date_time_offset) |
226 | 229 | { |
227 | 230 | // NOTE: these options can be set via command line args for adb or xharness, see AndroidSampleApp.csproj |
228 | 231 |
|
@@ -304,7 +307,11 @@ mono_droid_runtime_init (const char* executable, int managed_argc, char* managed |
304 | 307 | mono_jit_set_aot_mode(MONO_AOT_MODE_NORMAL); |
305 | 308 | #endif // FULL_AOT |
306 | 309 | #endif // FORCE_INTERPRETER |
| 310 | +} |
307 | 311 |
|
| 312 | +static int |
| 313 | +mono_droid_execute_assembly (const char *executable, int managed_argc, char* managed_argv[]) |
| 314 | +{ |
308 | 315 | MonoDomain *domain = mono_jit_init_version ("dotnet.android", "mobile"); |
309 | 316 | assert (domain); |
310 | 317 |
|
@@ -340,37 +347,48 @@ Java_net_dot_MonoRunner_setEnv (JNIEnv* env, jobject thiz, jstring j_key, jstrin |
340 | 347 | (*env)->ReleaseStringUTFChars(env, j_value, val); |
341 | 348 | } |
342 | 349 |
|
343 | | -int |
344 | | -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) |
| 350 | +void |
| 351 | +Java_net_dot_MonoRunner_initRuntime (JNIEnv* env, jobject thiz, jstring j_files_dir, jstring j_cache_dir, jstring j_testresults_dir, long current_local_time) |
345 | 352 | { |
346 | 353 | char file_dir[2048]; |
347 | 354 | char cache_dir[2048]; |
348 | 355 | char testresults_dir[2048]; |
349 | | - char entryPointLibName[2048]; |
350 | 356 | strncpy_str (env, file_dir, j_files_dir, sizeof(file_dir)); |
351 | 357 | strncpy_str (env, cache_dir, j_cache_dir, sizeof(cache_dir)); |
352 | 358 | strncpy_str (env, testresults_dir, j_testresults_dir, sizeof(testresults_dir)); |
353 | | - strncpy_str (env, entryPointLibName, j_entryPointLibName, sizeof(entryPointLibName)); |
354 | 359 |
|
355 | 360 | bundle_path = file_dir; |
356 | | - executable = entryPointLibName; |
357 | 361 |
|
358 | 362 | setenv ("HOME", bundle_path, true); |
359 | 363 | setenv ("TMPDIR", cache_dir, true); |
360 | 364 | setenv ("TEST_RESULTS_DIR", testresults_dir, true); |
361 | 365 |
|
| 366 | + mono_droid_runtime_init (current_local_time); |
| 367 | +} |
| 368 | + |
| 369 | +int |
| 370 | +Java_net_dot_MonoRunner_execEntryPoint (JNIEnv* env, jobject thiz, jstring j_entryPointLibName, jobjectArray j_args) |
| 371 | +{ |
| 372 | + char entryPointLibName[2048]; |
| 373 | + strncpy_str (env, entryPointLibName, j_entryPointLibName, sizeof(entryPointLibName)); |
| 374 | + |
| 375 | + executable = entryPointLibName; |
| 376 | + assert (executable); |
| 377 | + |
362 | 378 | int args_len = (*env)->GetArrayLength(env, j_args); |
363 | 379 | int managed_argc = args_len + 1; |
364 | 380 | char** managed_argv = (char**)malloc(managed_argc * sizeof(char*)); |
365 | 381 |
|
| 382 | + bundle_path = getenv ("HOME"); |
| 383 | + assert (bundle_path); // "HOME" env variable must be set by Java_net_dot_MonoRunner_initRuntime |
366 | 384 | managed_argv[0] = bundle_path; |
367 | 385 | for (int i = 0; i < args_len; ++i) |
368 | 386 | { |
369 | 387 | jstring j_arg = (*env)->GetObjectArrayElement(env, j_args, i); |
370 | 388 | managed_argv[i + 1] = (char*)((*env)->GetStringUTFChars(env, j_arg, NULL)); |
371 | 389 | } |
372 | 390 |
|
373 | | - int res = mono_droid_runtime_init (executable, managed_argc, managed_argv, current_local_time); |
| 391 | + int res = mono_droid_execute_assembly (executable, managed_argc, managed_argv); |
374 | 392 |
|
375 | 393 | for (int i = 0; i < args_len; ++i) |
376 | 394 | { |
|
0 commit comments