-
Notifications
You must be signed in to change notification settings - Fork 112
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
Release planning #413
Comments
We discussed this last week in rust-windowing/winit#2905 (comment), do we need a second issue to track this? |
Note that we can then also use https://github.com/MarijnS95/android-activity/compare/ndk-breaking-prep to apply the new breaking release to |
I figured it's helpful having a specific issue to ask about this in the context of this repo. I also don't always remember which miscellaneous thread we have side discussions on. In the case of supporting I'm not sure exactly what you're planning to land before making an |
All the PRs open right now are supposed to be additive, and could eventually land shortly after a breaking release as patch releases. However, one PR (#397) adds more API to the If there appears to be time pressure I can and will extract/cherry-pick just the Tangent: improving the situationI'd appreciate if Alternatively I could move the new headers to the end so that they don't affect existing enumerations, but that falls apart when a newer (additive/backwards-compatible!) NDK releases with more anonymous enums spread across the files. |
It would probably be OK to document that those types aren't covered by the crates semver - similar to how crates will explicitly document that they consider certain unstable APIs to fall outside of their semver. Those types getting renamed shouldn't break the API for anyone. Although they are technically public, they are conceptually intended to be private, and their only purpose is to be unique across the enum. I suppose it would be neat if bindgen could somehow implement some kind of heuristic for naming those based on any common prefix it finds for all members of the enum and fallback to numbering when that fails. Having a bit of a look at bindgen - have you already poked at rustified_enum? I wonder if that could help here - though that may lead to needing a large boilerplate change to the ndk crate to use generated rust-style enums for these types. |
At least the Seems like it should be possible to give bindgen a name for anonymous enums that could be based on a regex match for any of the members (first match wins) - or else some default behaviour that would let it clip a common prefix from all members and use that as a name. |
I probably shouldn't have got distracted looking at this last night but out of curiosity I ended up cooking up an experimental API for being able to deanonymize enums in bindgen via That has an initial proof of concept for being able to name an enum based on the names of all its variants, and shows how we could e.g. match and rename specific prefixes or else automatically infer a name by looking for a common prefix across all variants. One additional thing that could be nice to have here is some way of telling bindgen to strip a prefix from the name of variants if an enum is automatically named based on finding a common prefix. The order of things would be a bit more fiddly for supporting that. I'm probably not going to continue with this right now, but maybe it's be possible to upstream something like this that we could use here. I guess it would involve creating a separate |
Yeah I would want to document those types to be exempt but it seems rather annoying if one has to use them (at least we're not using them publicly in any of the safe API, and they can't/won't be used as
Oh I didn't even expect this to look at constant names, only at typed enums... Cool I guess? Seems we can do the same with
I wish I had as much time as you... Cool idea but would like to run this from a script instead of implementing custom parser callbacks. As for the rest, agreed with all these problems and I'd rather have the simplest solution: a CLI option that allows me to hardcode the expected prefix, as we already do for all other known enums (and they're very easy to find by searching for Understanding the prefix from a regex greatly complicates the problem though. Let's at the very least ask this over at For the rest of this planning, I opened some more (breaking) PRs to clean up other API bits. Think that's all for now, but the |
Yeah I'd think it's probably fine / reasonable to document that they are exempt - the name is clearly intended to be private and nothing should be expecting the name to be stable.
Er, it does only relate to C/C++ enums, it's just that bindgen has a few different options for how to handle codegen for enums (including anonymous enums). I had half wondered enabling generation of rust enums would have avoided these awkward private types.
nah, I don't have as much time as me either :) - I was just stupid and stayed up until 2am experimenting instead of sleeping.
Sure, but it's not a practical problem if we end up needing to write a tiny bindgen runner that uses the library API if it turns out to not be practical to expose the feature via bindgen-cli. There are other features that aren't accessible via the bindgen-cli and in this kind of situation where we want to do something a bit more sophisticated then it's probably reasonable if it doesn't end up being possible via the command line tool.
Not quite sure what you're thinking here - but maybe imagining how it could be exposed via I'm not sure it would be worth trying to expose this via the CLI - or at least I think it would be more practical to figure out what works for the problem by solving it with the bindgen library API first and then potentially afterwards it might be possible to think of how that could be made to also work with
At some point I can probably iterate this and create a [draft] PR to look at upstreaming but I think the main thing first though would be to figure out exactly what would be wanted / needed for the
Yeah I can see how that could happen - I think that's partly also why I was half hoping it might be possible to decouple |
Probably the only thing that annoys me more is that we recreate these enumerations in various ways for the "safe wrappers" in the Even worse, we have a totally mixed approach to each of these implementations. Some are
Yes. See for example
Sure; not sure what the best way is to describe those needs though. I guess we:
I just really don't want to desync them when it comes to breaking changes. Furthermore we should land the example improvements and port them to |
I'm not really sure this would be an improvement. Just because Private formats can be used as inputs as well. For example, I can create a |
I'd guess that many / most? NDK enums should have an It would be nice if bindgen made it easy to generate these though. Generally these enums are just mapped from int constants from the Java SDK which may get extended for new SDK API levels. It's possible (likely even) that a binary built against one ndk version could later end up running on a device with a higher SDK API level that has introduced new variants and in most situations the added variants aren't going to represent errors - just new types of things that should be gracefully ignored at runtime by older code. |
@spencercw fair enough, I used In other words, turning: enum SomeConstant {
X,
Y,
#[cfg(feature = "api-level-28")]
Z,
Unknown(u32),
}
// many many hand-written match statements with `cfg`s back into: #[derive(TryFrom/IntoPrimitive)]
#[repr(u32)]
#[nonehaustive?]
enum SomeConstant {
X = 1,
Y = 2,
#[cfg(feature = "api-level-28")]
Z = 20,
}
enum PossiblyUnknownSomeConstant {
SomeConstant(SomeConstant),
Unknown(u32),
} (@rib regarding your last point, this is indeed odd if the user gets a value of
It can't because of Rust limitations afaik. I was really unhappy when reading the enum discriminant RFC that this wasn't thought of: having a catch-all for unknown discriminants. Hence my suggestion to pull it out some way instead of having to write many What are your thoughts on this? Again, I mostly care about removing |
The original version of this was simpler by taking advantage of |
I also tend to think it should be reasonable to bump the MSRV and use Awkwardly though we're currently constrained from bumping the rust-version in android-activity and the ndk crates for the sake of being compatible with the rust-version of the Winit crate which is aims to support Debian on Linux with a really old version of Rust. Imho I find it frustrating / unreasonable that Android-specific crates like this would be constrained by Linux / Debian specific needs but hopefully Winit will stop testing Android builds against their MSRV soon: rust-windowing/winit#3046 Also ref: rust-mobile/android-activity#103 |
As expressed before It seems I'd love to be proven wrong here. @rib this isn't the place to take a jibe at |
In so far as providing context for why we're currently unable to bump the msrv >= 1.66 it was relevant |
I'm not sure I follow what the concern is here. It sounds OK that |
In the short term it seems ok to stick with the hand written match and anticipate using num_enum to simplify later. Generally having enums like: enum SomeConstant {
X,
Y,
#[cfg(feature = "api-level-28")]
Z,
Unknown(u32),
} sounds like the right way to go. Code needs to generally be able to gracefully / safely handle the possibility that it is running on a newer version of Android than was targeted at compile time and since extended values likely don't represent error conditions then a catch all |
It does translate to Unfortunately that RFC was only cooked up with FFI in mind. We're not passing these enums over an FFI boundary, For example, when Turns out
There was no debate whether or not unknown-to-the- However, I've just brought up the same discussion over at The problem with |
Not to take away from the discussion on how to best represent enums, but |
For reference Winit is now testing the Android backend with 1.69 since merging rust-windowing/winit#3046 so I think we can revisit bumping the rust-version for android-activity and the ndk[-sys] crates. I think bumping to at least 1.68 makes a good deal of sense for all Android crates. |
@rib I don't just blindly want to bump the MSRV "because Winit now allows it", for lack of a written-down policy of our own. On the other hand I also don't want to delay Rust updates too harshly, when it quickly becomes obvious that there are useful features in newer releases. For the time being 1.66 perfectly suits our needs: Regarding the enums above, I'm still unhappy that As discussed over at For most cases (such as |
I have now bumped the MSRV for the One other thought/offer: since |
I have mostly all the stuff resolved for the winit, so it'd be nice for android stuff to get released/updated for the next release, since it won't be a beta. |
@kchibisov I figured this would get asked right as I'm 2 days into a trip and not near a computer for some time. |
@MarijnS95 unfortunate, but no rush. Wanted to say that there's a desire in winit to do it in the upcoming weeks. |
@kchibisov perfect, if you have a bit less than 2 weeks I'll get everything in order as soon as I return. |
Yeah, don't worry. |
I have just opened PRs for all the planned breaking changes that were still on my mind, and will merge them in (assuming there's very likely no objections) before pushing out the actual release. Apologies for the slowdown/inconvenience. However, as mentioned in rust-windowing/winit#2686 (comment) the |
Hey @MarijnS95, it would be good to know if there's a release being planned for the
ndk
andndk-sys
crates?In particular an
ndk-sys
release would be really appreciated, since I'd like to be able to useAMotionEvent_getActionButton
.The text was updated successfully, but these errors were encountered: