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

search android ndk also in ANDROID_NDK env var and pass ANDROID_NDK var to build if not set (cmake compat) #192

Merged
merged 1 commit into from
Sep 29, 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
5 changes: 4 additions & 1 deletion dinghy-lib/src/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl PlatformManager for AndroidManager {
binutils_prefix: format!("{}-linux-{}", binutils_cpu, abi_kind),
cc_prefix: format!("{}-linux-{}{}", cc_cpu, abi_kind, api),
};
AndroidPlatform::new(PlatformConfiguration::default(), id, tc, major, libclang_path.clone())
AndroidPlatform::new(PlatformConfiguration::default(), id, tc, major, ndk.clone(),libclang_path.clone())
};
for api in api_levels.iter() {
platforms.push(create_platform(&api, &format!("-api{}", api))?);
Expand Down Expand Up @@ -190,6 +190,9 @@ fn ndk() -> Result<Option<path::PathBuf>> {
if let Ok(path) = env::var("ANDROID_NDK_HOME") {
return Ok(Some(path.into()));
}
if let Ok(path) = env::var("ANDROID_NDK") {
return Ok(Some(path.into()));
}
for sdk in probable_sdk_locs()? {
if sdk.join("ndk-bundle/source.properties").is_file() {
return Ok(Some(sdk.join("ndk-bundle")));
Expand Down
11 changes: 11 additions & 0 deletions dinghy-lib/src/android/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub struct AndroidPlatform {
regular_platform: Box<dyn Platform>,
toolchain_config: ToolchainConfig,
ndk_major_version: usize,
ndk_path: PathBuf,
libclang_path: PathBuf,
}

Expand All @@ -21,6 +22,7 @@ impl AndroidPlatform {
id: String,
toolchain_config: ToolchainConfig,
ndk_major_version: usize,
ndk_path: PathBuf,
libclang_path: PathBuf,
) -> Result<Box<dyn Platform>> {
Ok(Box::new(Self {
Expand All @@ -31,6 +33,7 @@ impl AndroidPlatform {
)?,
toolchain_config,
ndk_major_version,
ndk_path,
libclang_path
}))
}
Expand Down Expand Up @@ -76,6 +79,14 @@ impl Platform for AndroidPlatform {
set_env("DINGHY_BUILD_LIBCLANG_PATH", &self.libclang_path )
}

if std::env::var("ANDROID_NDK").is_err() {
set_env("ANDROID_NDK", self.ndk_path.canonicalize()?)
}

if std::env::var("ANDROID_NDK_HOME").is_err() {
set_env("ANDROID_NDK_HOME", self.ndk_path.canonicalize()?)
}


Ok(())
}
Expand Down