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`, 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++`, 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`, 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`, ANDROID_NDK: ANDROID_NDK_LATEST_HOME,
CMAKE_TOOLCHAIN_FILE_aarch64_linux_android: `${ANDROID_NDK_LATEST_HOME}/build/cmake/android.toolchain.cmake`,
PATH: `${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin:${process.env.PATH}`, PATH: `${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin:${process.env.PATH}`,
}) })
} }

View file

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

View file

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