Skip to content
This repository was archived by the owner on Jul 3, 2020. It is now read-only.

Commit 4eddc8b

Browse files
authored
Merge pull request #237 from philip-alldredge/cargo-apk-fixes
Fix broken build when using rust 1.37.0 support
2 parents bd0fa9f + 925c127 commit 4eddc8b

4 files changed

Lines changed: 25 additions & 5 deletions

File tree

cargo-apk/injected-glue/lib.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,3 +641,22 @@ pub fn load_asset(filename: &str) -> Result<Vec<u8>, AssetError> {
641641
};
642642
Ok(vec)
643643
}
644+
645+
// Exported function which is called be Android's NativeActivity
646+
#[no_mangle]
647+
pub unsafe extern "C" fn ANativeActivity_onCreate(
648+
activity: *mut c_void,
649+
saved_state: *mut c_void,
650+
saved_state_size: usize,
651+
) {
652+
native_app_glue_onCreate(activity, saved_state, saved_state_size);
653+
}
654+
655+
extern "C" {
656+
#[allow(non_snake_case)]
657+
fn native_app_glue_onCreate(
658+
activity: *mut c_void,
659+
saved_state: *mut c_void,
660+
saved_state_size: usize,
661+
);
662+
}

cargo-apk/native_app_glue/android_native_app_glue.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,8 +420,9 @@ static void onInputQueueDestroyed(ANativeActivity* activity, AInputQueue* queue)
420420
android_app_set_input((struct android_app*)activity->instance, NULL);
421421
}
422422

423-
JNIEXPORT
424-
void ANativeActivity_onCreate(ANativeActivity* activity, void* savedState,
423+
// Called by ANativeActivity_onCreate which will be exported and will call this function.
424+
// Needed because this symbol will not be globally exported.
425+
void native_app_glue_onCreate(ANativeActivity* activity, void* savedState,
425426
size_t savedStateSize) {
426427
LOGV("Creating: %p\n", activity);
427428
activity->callbacks->onDestroy = onDestroy;

cargo-apk/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ pub fn execute_install(options: &ArgMatches, cargo_config: &CargoConfig) -> carg
325325
&workspace,
326326
&options.value_of("package").map(|s| s.to_owned()),
327327
)?;
328-
android_config.release = options.is_present("release");
328+
android_config.release = !options.is_present("debug");
329329

330330
ops::install(&workspace, &android_config, &options)?;
331331
Ok(())

cargo-apk/src/ops/build/compile.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,14 @@ pub extern "C" fn android_main(app: *mut ()) {{
215215
fs::create_dir_all(&build_path).unwrap();
216216

217217
//
218-
// Change crate-type from bin to dylib
218+
// Change crate-type from bin to cdylib
219219
// Replace output directory with the directory we created
220220
//
221221
let mut iter = new_args.iter_mut().rev().peekable();
222222
while let Some(arg) = iter.next() {
223223
if let Some(prev_arg) = iter.peek() {
224224
if *prev_arg == "--crate-type" && arg == "bin" {
225-
*arg = "dylib".into();
225+
*arg = "cdylib".into();
226226
} else if *prev_arg == "--out-dir" {
227227
*arg = build_path.clone().into();
228228
}

0 commit comments

Comments
 (0)