fix(build): emit Android alignment flags from build.rs - #134
Conversation
|
@Johnosezele (and anyone else that wants to give feedback) does moving the Cargo config to a non hidden path and verifying it in the pub.dev package manifest seem like the right fix, or is there a better Dart packaging convention we should use? |
|
I think moving the file is the right approach. Dart excludes hidden folders like We could keep Only small suggestion: make the CI check verify the exact archived file if possible, rather than matching any file named |
Johnosezele
left a comment
There was a problem hiding this comment.
Only tradeoff I see is that direct Cargo builds from native/ will no longer discover the config automatically, so those builds must also pass --config.
Replace the shipped Cargo config with a build script that adds the 16 KiB max-page-size/common-page-size linker flags via cargo:rustc-link-arg-cdylib whenever CARGO_CFG_TARGET_OS is android. This makes the alignment intrinsic to the crate, so the Native Assets hook, CI and manual Android cargo builds all get it without shipping a config file, passing --config, or guarding the pub archive contents. The linker args are additive and survive a consumer setting RUSTFLAGS, unlike target.<cfg>.rustflags in a Cargo config. Also drop the never-compiled [build-dependencies] block: with no build script it was inert, but adding one would have pulled uniffi's build feature into every consumer build. Cargo.lock loses the corresponding uniffi_build edge only.
|
Thanks your note about direct Cargo builds led me to prototype a different approach. I’ve replaced the shipped Cargo config with an Android-gated build.rs, so Native Assets and manual Cargo builds receive the alignment flags without --config. This definitely changes the implementation you reviewed. I also included a two line fix for the alignment jobs, which currently fail in setup-android before reaching the build. I may actually spin that CI only change into a separate PR to keep this one focused. |
Pub.dev excludes the hidden
native/.cargodirectory, while the Native Assets hook previously passed that missing config file to Cargo. This caused builds from the published package to fail.Replace the shipped Cargo config with an Android-gated
native/build.rsthat emits the 16 KiB page-alignment linker arguments for the cdylib. This makes the alignment flags apply consistently to Native Assets, CI, and manual Cargo builds without requiring--config.Also:
Cargo.tomlso a missing packaged file fails clearly.setup-android’s obsolete defaulttoolspackage.