Skip to content

na-mainloop: Drop unneeded and broken cargo-apk setup#9

Open
MarijnS95 wants to merge 1 commit intomainfrom
cargo-apk-cleanup-and-xbuild
Open

na-mainloop: Drop unneeded and broken cargo-apk setup#9
MarijnS95 wants to merge 1 commit intomainfrom
cargo-apk-cleanup-and-xbuild

Conversation

@MarijnS95
Copy link
Copy Markdown
Member

@MarijnS95 MarijnS95 commented Jun 26, 2023

There were many things wrong with the cargo-apk metadata configuration:

  • Lots of unused defaults and unnecessary documentation;
  • With [package.metadata.android.application] commented out label = "NativeActivity Mainloop" was applied to [[package.metadata.android.uses_feature]];
  • That feature requirement for android.hardware.vulkan.level == 1 is completely irrelevant for na-mainloop.

Without configuration cargo-apk uses the default rust.<package> namespace instead of the hardcoded com.foo.bar but that seems to have recently been rewritten to com.github.rust_mobile.namainloop.

@MarijnS95 MarijnS95 force-pushed the cargo-apk-cleanup-and-xbuild branch 3 times, most recently from ac61f12 to 5e30ef6 Compare June 26, 2023 20:29
@rib
Copy link
Copy Markdown
Member

rib commented Jun 27, 2023

Yeah this sounds probably ok if they can Just Work(tm) - maybe the gradle builds could be configured with the same application Id that cargo apk / xbuild will come up with by default. Does xbuild have the same default as cargo apk here?

Btw, it would be kinda interesting to know if it would be possible to have xbuild also work with the agdk examples at some point, and those would need some kind of config for knowing to fetch the game-activity dependency.

@MarijnS95
Copy link
Copy Markdown
Member Author

Does xbuild have the same default as cargo apk here?

Afaik they're different.

@MarijnS95
Copy link
Copy Markdown
Member Author

Btw, it would be kinda interesting to know if it would be possible to have xbuild also work with the agdk examples at some point, and those would need some kind of config for knowing to fetch the game-activity dependency.

xbuild has gradle support, but I've never toyed with it. Would be lovely if you could!

@MarijnS95
Copy link
Copy Markdown
Member Author

@rib
Copy link
Copy Markdown
Member

rib commented Jun 27, 2023

xbuild has gradle support, but I've never toyed with it. Would be lovely if you could!

I don't really know where to start with configuring xbuild without looking at the implementation atm, the README doesn't show any examples and I haven't seen it reference any example projects. Can you maybe link to some open source example with an xbuild config to get a starting point for knowing what's configurable?

@MarijnS95
Copy link
Copy Markdown
Member Author

Maybe @dvc94ch has a link. Afaik it's "as simple as" setting gradle: true under android: in manifest.yaml, at least that's what's being done for the template.

Supposedly it creates a bunch of files in the source dir for you, at least if mod.rs is believed:

https://github.com/rust-mobile/xbuild/tree/master/xbuild/src/gradle

@MarijnS95 MarijnS95 force-pushed the cargo-apk-cleanup-and-xbuild branch 3 times, most recently from 8d7cb4a to e95e9c4 Compare July 18, 2023 20:08
@MarijnS95
Copy link
Copy Markdown
Member Author

Well this is awkward. The Ubuntu VM probably has a weird/old clang/LLVM setup as I cannot repro this issue locally, though xbuild itself uses a very similar CI setup to do build-testing.

@MarijnS95
Copy link
Copy Markdown
Member Author

MarijnS95 commented Jul 24, 2023

I just ran into this myself while trying to teach xbuild to support env vars with spaces.

xbuild sets CARGO_TARGET_<triple>_RUSTFLAGS, and that probably gets skipped/ignored because the CI script already sets RUSTFLAGS, hence it's using the wrong compiler flags.

Its precedence is not documented at https://doc.rust-lang.org/cargo/reference/config.html#buildrustflags, but it probably falls at position 3. (after RUSTFLAGS which is at 2.) as it is supposed to provide a value for target.<triple>.rustflags.

@MarijnS95 MarijnS95 changed the title na-mainloop: Drop unneeded cargo-apk setup and add xbuild docs na-mainloop: Drop unneeded cargo-apk setup Apr 2, 2026
@MarijnS95 MarijnS95 marked this pull request as ready for review April 2, 2026 17:54
@MarijnS95 MarijnS95 force-pushed the cargo-apk-cleanup-and-xbuild branch from e95e9c4 to 5221b0b Compare April 2, 2026 17:56
Comment on lines 34 to 36
[package.metadata.android.sdk]
min_sdk_version = 31
target_sdk_version = 35
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be dropped in favour of defaults.

@MarijnS95 MarijnS95 force-pushed the cargo-apk-cleanup-and-xbuild branch from 5221b0b to e873070 Compare April 2, 2026 18:00
@MarijnS95 MarijnS95 changed the title na-mainloop: Drop unneeded cargo-apk setup na-mainloop: Drop unneeded and broken cargo-apk setup Apr 2, 2026
@MarijnS95 MarijnS95 force-pushed the cargo-apk-cleanup-and-xbuild branch from e873070 to 98dd8eb Compare April 2, 2026 18:05
@rib
Copy link
Copy Markdown
Member

rib commented Apr 2, 2026

I think I recently dropped the cargo apk docs when updating na-winit-wgpu since I had briefly gone to try running cargo apk run and it hadn't worked. If we're updating these docs though maybe we should re-instate the README section for na-winit-wgpu at the same time (maybe I need to update cargo apk or we can figure why it maybe didn't work)

@MarijnS95
Copy link
Copy Markdown
Member Author

Cargo-apk might have broken, as we were on a severe time-wasting distraction with xbuild unfortunately :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants