feat(cli): support android armv7 target

This commit is contained in:
LongYinan 2021-12-02 13:10:53 +08:00
parent 5f222038d3
commit 68b0483c81
No known key found for this signature in database
GPG key ID: C3666B7FC82ADAD7
3 changed files with 18 additions and 2 deletions

View file

@ -87,9 +87,21 @@ jobs:
target: 'aarch64-linux-android' target: 'aarch64-linux-android'
build: | build: |
export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="\${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android24-clang" 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}" export PATH="\${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin:\${PATH}"
yarn build --target aarch64-linux-android yarn build --target aarch64-linux-android
\${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-strip *.node \${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 - host: ubuntu-latest
architecture: 'x64' architecture: 'x64'
target: 'aarch64-unknown-linux-musl' target: 'aarch64-unknown-linux-musl'

View file

@ -42,6 +42,7 @@ const SupportedPlatforms: string[] = [
'x86_64-unknown-linux-musl', 'x86_64-unknown-linux-musl',
'x86_64-unknown-freebsd', 'x86_64-unknown-freebsd',
'i686-pc-windows-msvc', 'i686-pc-windows-msvc',
'armv7-linux-androideabi',
] ]
export class NewProjectCommand extends Command { export class NewProjectCommand extends Command {

View file

@ -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. * - `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. * - `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('-') const triples = triple.split('-')
let cpu: string let cpu: string
let sys: string let sys: string
@ -91,7 +94,7 @@ export function parseTriple(triple: string): PlatformDetail {
platformArchABI: abi platformArchABI: abi
? `${platformName}-${arch}-${abi}` ? `${platformName}-${arch}-${abi}`
: `${platformName}-${arch}`, : `${platformName}-${arch}`,
raw: triple, raw: rawTriple,
} }
} }