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

Fix broken build when using rust 1.37.0 support #237

Merged
merged 2 commits into from
Sep 2, 2019
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
19 changes: 19 additions & 0 deletions cargo-apk/injected-glue/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,3 +641,22 @@ pub fn load_asset(filename: &str) -> Result<Vec<u8>, AssetError> {
};
Ok(vec)
}

// Exported function which is called be Android's NativeActivity
#[no_mangle]
pub unsafe extern "C" fn ANativeActivity_onCreate(
philip-alldredge marked this conversation as resolved.
Show resolved Hide resolved
activity: *mut c_void,
saved_state: *mut c_void,
saved_state_size: usize,
) {
native_app_glue_onCreate(activity, saved_state, saved_state_size);
}

extern "C" {
#[allow(non_snake_case)]
fn native_app_glue_onCreate(
activity: *mut c_void,
saved_state: *mut c_void,
saved_state_size: usize,
);
}
5 changes: 3 additions & 2 deletions cargo-apk/native_app_glue/android_native_app_glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,9 @@ static void onInputQueueDestroyed(ANativeActivity* activity, AInputQueue* queue)
android_app_set_input((struct android_app*)activity->instance, NULL);
}

JNIEXPORT
void ANativeActivity_onCreate(ANativeActivity* activity, void* savedState,
// Called by ANativeActivity_onCreate which will be exported and will call this function.
// Needed because this symbol will not be globally exported.
void native_app_glue_onCreate(ANativeActivity* activity, void* savedState,
size_t savedStateSize) {
LOGV("Creating: %p\n", activity);
activity->callbacks->onDestroy = onDestroy;
Expand Down
2 changes: 1 addition & 1 deletion cargo-apk/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ pub fn execute_install(options: &ArgMatches, cargo_config: &CargoConfig) -> carg
&workspace,
&options.value_of("package").map(|s| s.to_owned()),
)?;
android_config.release = options.is_present("release");
android_config.release = !options.is_present("debug");

ops::install(&workspace, &android_config, &options)?;
Ok(())
Expand Down
4 changes: 2 additions & 2 deletions cargo-apk/src/ops/build/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,14 @@ pub extern "C" fn android_main(app: *mut ()) {{
fs::create_dir_all(&build_path).unwrap();

//
// Change crate-type from bin to dylib
// Change crate-type from bin to cdylib
// Replace output directory with the directory we created
//
let mut iter = new_args.iter_mut().rev().peekable();
while let Some(arg) = iter.next() {
if let Some(prev_arg) = iter.peek() {
if *prev_arg == "--crate-type" && arg == "bin" {
*arg = "dylib".into();
*arg = "cdylib".into();
} else if *prev_arg == "--out-dir" {
*arg = build_path.clone().into();
}
Expand Down