Skip to content

Commit

Permalink
[native_toolchain_c] Setup Android RISCV64 toolchain.
Browse files Browse the repository at this point in the history
  • Loading branch information
rmacnak-google committed Nov 3, 2023
1 parent c72ed16 commit 3e0a9c3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion pkgs/native_toolchain_c/lib/src/cbuilder/run_cbuilder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion pkgs/native_toolchain_c/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,24 @@ void main() {
Target.androidArm64,
Target.androidIA32,
Target.androidX64,
// TODO(rmacnak): Enable when stable NDK 27 is available.
// Target.androidRiscv64,
];

const readElfMachine = {
Target.androidArm: 'ARM',
Target.androidArm64: 'AArch64',
Target.androidIA32: 'Intel 80386',
Target.androidX64: 'Advanced Micro Devices X86-64',
Target.androidRiscv64: 'RISC-V',
};

const objdumpFileFormat = {
Target.androidArm: 'elf32-littlearm',
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.
Expand Down

0 comments on commit 3e0a9c3

Please sign in to comment.