From 68b0483c81c5cbddc7b0294ae36772701549cbe2 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Thu, 2 Dec 2021 13:10:53 +0800 Subject: [PATCH] feat(cli): support android armv7 target --- cli/src/new/ci-template.ts | 12 ++++++++++++ cli/src/new/index.ts | 1 + cli/src/parse-triple.ts | 7 +++++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/cli/src/new/ci-template.ts b/cli/src/new/ci-template.ts index 1a0c4de1..32ca8201 100644 --- a/cli/src/new/ci-template.ts +++ b/cli/src/new/ci-template.ts @@ -87,9 +87,21 @@ jobs: target: 'aarch64-linux-android' build: | export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="\${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android24-clang" + export CC="\${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android24-clang" + export CXX="\${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android24-clang++" export PATH="\${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin:\${PATH}" yarn build --target aarch64-linux-android \${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-strip *.node + - host: ubuntu-latest + architecture: 'x64' + target: 'armv7-linux-androideabi' + build: | + export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="\${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi24-clang" + export CC="\${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi24-clang" + export CXX="\${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi24-clang++" + export PATH="\${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin:\${PATH}" + yarn build --target armv7-linux-androideabi + \${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/arm-linux-androideabi-strip *.node - host: ubuntu-latest architecture: 'x64' target: 'aarch64-unknown-linux-musl' diff --git a/cli/src/new/index.ts b/cli/src/new/index.ts index c8de840b..71707ef5 100644 --- a/cli/src/new/index.ts +++ b/cli/src/new/index.ts @@ -42,6 +42,7 @@ const SupportedPlatforms: string[] = [ 'x86_64-unknown-linux-musl', 'x86_64-unknown-freebsd', 'i686-pc-windows-msvc', + 'armv7-linux-androideabi', ] export class NewProjectCommand extends Command { diff --git a/cli/src/parse-triple.ts b/cli/src/parse-triple.ts index 2e4efd89..c09e40bd 100644 --- a/cli/src/parse-triple.ts +++ b/cli/src/parse-triple.ts @@ -70,7 +70,10 @@ export const DefaultPlatforms: PlatformDetail[] = [ * - `sys` = The system name, for example `linux`, `windows`, `darwin`, etc. none is typically used for bare-metal without an OS. * - `abi` = The ABI, for example `gnu`, `android`, `eabi`, etc. */ -export function parseTriple(triple: string): PlatformDetail { +export function parseTriple(rawTriple: string): PlatformDetail { + const triple = rawTriple.endsWith('eabi') + ? `${rawTriple.slice(0, -4)}-eabi` + : rawTriple const triples = triple.split('-') let cpu: string let sys: string @@ -91,7 +94,7 @@ export function parseTriple(triple: string): PlatformDetail { platformArchABI: abi ? `${platformName}-${arch}-${abi}` : `${platformName}-${arch}`, - raw: triple, + raw: rawTriple, } }