From 3e0a9c39344d765df4263a2be9dcb17446789c18 Mon Sep 17 00:00:00 2001 From: Ryan Macnak Date: Wed, 25 Oct 2023 11:02:45 -0700 Subject: [PATCH] [native_toolchain_c] Setup Android RISCV64 toolchain. --- pkgs/native_toolchain_c/lib/src/cbuilder/run_cbuilder.dart | 4 +++- pkgs/native_toolchain_c/pubspec.yaml | 2 +- .../test/cbuilder/cbuilder_cross_android_test.dart | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pkgs/native_toolchain_c/lib/src/cbuilder/run_cbuilder.dart b/pkgs/native_toolchain_c/lib/src/cbuilder/run_cbuilder.dart index 0db3ddab3..ecb91823c 100644 --- a/pkgs/native_toolchain_c/lib/src/cbuilder/run_cbuilder.dart +++ b/pkgs/native_toolchain_c/lib/src/cbuilder/run_cbuilder.dart @@ -133,7 +133,8 @@ class RunCBuilder { // See https://github.com/dart-lang/native/issues/171. late final int targetAndroidNdkApi; if (target.os == OS.android) { - targetAndroidNdkApi = max(buildConfig.targetAndroidNdkApi!, 21); + final minimumApi = target == Target.androidRiscv64 ? 35 : 21; + targetAndroidNdkApi = max(buildConfig.targetAndroidNdkApi!, minimumApi); } await runProcess( @@ -294,6 +295,7 @@ class RunCBuilder { Target.androidArm64: 'aarch64-linux-android', Target.androidIA32: 'i686-linux-android', Target.androidX64: 'x86_64-linux-android', + Target.androidRiscv64: 'riscv64-linux-android', }; static const appleClangMacosTargetFlags = { diff --git a/pkgs/native_toolchain_c/pubspec.yaml b/pkgs/native_toolchain_c/pubspec.yaml index 886e74500..5f4d321ca 100644 --- a/pkgs/native_toolchain_c/pubspec.yaml +++ b/pkgs/native_toolchain_c/pubspec.yaml @@ -19,7 +19,7 @@ dependencies: glob: ^2.1.1 logging: ^1.1.1 meta: ^1.9.1 - native_assets_cli: ^0.3.0 + native_assets_cli: ^0.3.2 pub_semver: ^2.1.3 dev_dependencies: diff --git a/pkgs/native_toolchain_c/test/cbuilder/cbuilder_cross_android_test.dart b/pkgs/native_toolchain_c/test/cbuilder/cbuilder_cross_android_test.dart index 0f5081aec..6e1800e0b 100644 --- a/pkgs/native_toolchain_c/test/cbuilder/cbuilder_cross_android_test.dart +++ b/pkgs/native_toolchain_c/test/cbuilder/cbuilder_cross_android_test.dart @@ -17,6 +17,8 @@ void main() { Target.androidArm64, Target.androidIA32, Target.androidX64, + // TODO(rmacnak): Enable when stable NDK 27 is available. + // Target.androidRiscv64, ]; const readElfMachine = { @@ -24,6 +26,7 @@ void main() { Target.androidArm64: 'AArch64', Target.androidIA32: 'Intel 80386', Target.androidX64: 'Advanced Micro Devices X86-64', + Target.androidRiscv64: 'RISC-V', }; const objdumpFileFormat = { @@ -31,6 +34,7 @@ void main() { Target.androidArm64: 'elf64-littleaarch64', Target.androidIA32: 'elf32-i386', Target.androidX64: 'elf64-x86-64', + Target.androidRiscv64: 'elf64-littleriscv', }; /// From https://docs.flutter.dev/reference/supported-platforms.