Skip to content

Commit

Permalink
Transform bin to cdylib with exported symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
MarijnS95 committed Aug 21, 2024
1 parent caa8062 commit c2e808c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion cargo-apk/src/apk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,9 @@ impl<'a> ApkBuilder<'a> {
for target in &self.build_targets {
let triple = target.rust_triple();
let build_dir = self.cmd.build_dir(Some(triple));
let artifact = self.cmd.artifact(artifact, Some(triple), CrateType::Cdylib);
// TODO: Read crate type from Cargo.toml/metadata?
let artifact = self.cmd.artifact(artifact, Some(triple), CrateType::Bin);
// let artifact = self.cmd.artifact(artifact, Some(triple), CrateType::Cdylib);

let mut cargo = cargo_ndk(
&self.ndk,
Expand Down
6 changes: 5 additions & 1 deletion ndk-build/src/apk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ impl<'a> UnalignedApk<'a> {
return Err(NdkError::PathNotFound(path.into()));
}
let abi = target.android_abi();
let lib_path = Path::new("lib").join(abi).join(path.file_name().unwrap());
let mut filename = PathBuf::from(path.file_name().unwrap());
if filename.extension().is_none() {
filename = PathBuf::from(format!("lib{}.so", filename.display()));
}
let lib_path = Path::new("lib").join(abi).join(filename);
let out = self.config.build_dir.join(&lib_path);
std::fs::create_dir_all(out.parent().unwrap())?;

Expand Down
3 changes: 3 additions & 0 deletions ndk-build/src/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ pub fn cargo_ndk(
}
rustflags.push_str("-Clink-arg=");
rustflags.push_str(&clang_target);
rustflags.push_str(SEP);
rustflags.push_str("-Clink-arg=-rdynamic");
// rustflags.push_str("-Clink-arg=-Wl,-export-dynamic");

let ar = ndk.toolchain_bin("ar", target)?;
cargo.env(format!("AR_{}", triple), &ar);
Expand Down

0 comments on commit c2e808c

Please sign in to comment.