dart-lang / dart-lang/native

Installing NDK automatically

Open
#976 9 comments 0 reactions 0 assignees View on GitHub
P3 package:native_toolchain_c
Dominant language
Dart
Stars
275
Forks
144
Avg merge
2d 10h
Merged PRs (30d)
47

Description

Right now when appropriate NDK is not installed the build will fail with
```
Target native_assets failed: Error: Android NDK Clang could not be found.
```

IIRC gradle will install ndk automatically for `externalNativeBuild` projects. We do the same thing in [cargokit](https://github.com/irondash/cargokit/blob/97668e95b40a09aecd06bef8c627d38b5f699fd8/build_tool/lib/src/android_environment.dart#L60) (glue used to build rust code for Flutter plugins). That results in a smoother experience compared to failing the build. I'm currently looking into reimplementing cargokit in terms of native assets and this would be a bit of a downgrade.

This does raise question whether running build should be allowed to install NDK (or other toolchains for that matter). At least for gradle/NDK nobody seems to object.

Longer term it would be nice to have an option to install toolchains as part of build. When user has `rustup` installed, cargokit will currently install missing toolchains and targets. But this means that build is modifying files outside of build folder (or pub cache). Which does feels a little bit iffy. It would be great if a hypothetical `native_toolchain_rust` could install and manage rust toolchain, possibly stored in `.pub_cache` so that it can get reused between project. Or maybe this could be done during `pub get` through a hook, but at that point we don't know the target architecture so for rust for example we'd need to install all targets, which might be an overkill.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.