fix(cli): android cmake build

This commit is contained in:
LongYinan 2023-01-03 21:02:13 +08:00
parent abc4566bbb
commit 895e4caf95
No known key found for this signature in database
GPG key ID: C3666B7FC82ADAD7
3 changed files with 3 additions and 14 deletions

View file

@ -435,8 +435,7 @@ export class BuildCommand extends Command {
CC: `${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/${targetArch}-linux-${targetPlatform}-clang`,
CXX: `${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/${targetArch}-linux-${targetPlatform}-clang++`,
AR: `${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar`,
CMAKE_TOOLCHAIN_FILE_armv7_linux_androideabi: `${ANDROID_NDK_LATEST_HOME}/build/cmake/android.toolchain.cmake`,
CMAKE_TOOLCHAIN_FILE_aarch64_linux_android: `${ANDROID_NDK_LATEST_HOME}/build/cmake/android.toolchain.cmake`,
ANDROID_NDK: ANDROID_NDK_LATEST_HOME,
PATH: `${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin:${process.env.PATH}`,
})
}

View file

@ -1,16 +1,9 @@
export const createCargoConfig = (
enableLinuxArm7: boolean,
enableLinuxArm8Musl: boolean,
) => {
export const createCargoConfig = (enableLinuxArm8Musl: boolean) => {
const result: string[] = []
if (enableLinuxArm8Musl) {
result.push(`[target.aarch64-unknown-linux-musl]
linker = "aarch64-linux-musl-gcc"
rustflags = ["-C", "target-feature=-crt-static"]`)
}
if (enableLinuxArm7) {
result.push(`[target.armv7-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"`)
}
return result.join('\n')
}

View file

@ -179,10 +179,7 @@ test('sum from native', (t) => {
const enableLinuxArm8Musl = this.targets!.includes(
'aarch64-unknown-linux-musl',
)
const enableLinuxArm7 = this.targets!.includes(
'armv7-unknown-linux-gnueabihf',
)
const cargoConfig = createCargoConfig(enableLinuxArm7, enableLinuxArm8Musl)
const cargoConfig = createCargoConfig(enableLinuxArm8Musl)
if (cargoConfig.length) {
const configDir = join(process.cwd(), this.dirname!, '.cargo')
if (!this.dryRun) {