-
Notifications
You must be signed in to change notification settings - Fork 68
Installing NDK automatically #976
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think the best solution would be to introduce a package
And then the package has some code in
Other packages can then depend on that package, which will cause the This leads to some open questions:
We'd need to check if that error message comes from Flutter or from the All of the same applies to a package |
Okay, the error is coming from the flutter_tools, and flutter_tools policy is to not auto-install native tooling. flutter/flutter#144530 |
@dcharkes, thanks for following that up. Flutter doctor currently doesn't seem to complain if NDK is not installed, possibly something to add. I generally agree with the sentiment of not installing things silently during build. Maybe something like this would make sense down the line, which could be suggested by the error message:
Or perhaps a hook on I did some work on a proof of concept implementation of native_toolchain_rust. It's only a rough prototype right now and needs quite a bit of love, but it can build macOS, iOS and android dylibs (I only tested it on macOS for now, but I wouldn't be too surprised if it worked on other platforms as well). final rustup = Rustup.systemRustup()!;
final toolchain = rustup.installedToolchains().first;
final builder = RustBuilder(
assetId: 'package:$packageName/${packageName}_hello_rust_ffi',
toolchain: toolchain,
manifestPath: 'rust/Cargo.toml',
buildConfig: buildConfig,
);
builder.run(output: buildOutput); I noticed couple of things:
If these are not known issues I can file them separately. Overall this seems like a well thought approach and so far I like it a lot. cargokit holds together with a lot of ducktape and this removes pretty much all of it. I'll work on this some more and if the feedback is good I'd be interested in maintaining the package. |
Thanks for giving it a spin! 🎸
❤️ !
Good catch! The error is here: Should be a simple fix, would you mind making a PR?
This is a feature, not a bug. https://github.com/flutter/flutter/blob/d3c274b25540de40e17693ce6800454b5f32ecb8/packages/flutter_tools/lib/src/isolated/native_assets/macos/native_assets_host.dart#L152-L208
That sounds like a bug. Please file a bug with a minimal repro on the flutter repo and cc me.
Thanks! 😄
Awesome! 🚀 |
Sure, I'll take a look.
I don't think this is enforced in any way. Many first party flutter plugins have frameworks with names longer than 15 characters, i.e.
These are just random picks from app successfully deployed to AppStore. EDIT: Also looking at Apple frameworks they routinely have names longer than 15 characters. |
cc @jmagman should we consider removing the 15 char limit? |
Some additional information: As far as I can tell the 15 character limit of |
@knopp If you would like to make a PR, the corresponding tests are in |
Right now when appropriate NDK is not installed the build will fail with
IIRC gradle will install ndk automatically for
externalNativeBuild
projects. We do the same thing in cargokit (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 hypotheticalnative_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 duringpub 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.The text was updated successfully, but these errors were encountered: