set app version to 2.0.0 and include v2 features in that case - #48402
Merged
Conversation
jkarneges
force-pushed
the
jkarneges/v2-conditionals
branch
from
August 19, 2026 01:56
f792689 to
6112015
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This excludes v2 features when the app's version in
Cargo.tomlis < 2.0.0. It also sets the version to 2.0.0 so inclusion of v2 features remains the default when building onmain. With this behavior in place, we can conditionally produce releases of either v1 or v2 frommainand we shouldn't need a separatev1branch.There is also a
legacy-runnerfeature flag that controls whether to build apushpin-legacybinary, which is default enabled as well. This is a separate flag since it's not possible to conditionally build binaries based on the app version. Note that the app version determines the implementation of the main runner; if you set the app version to 1.x but leave thelegacy-runnerfeature enabled, you get two runners that are both the legacy implementation.To build v1 and avoid producing a redundant
pushpin-legacybinary (as a standard v1 release would do), change the version number inCargo.tomlto 1.x and set cargo features explicitly:The way it works under the hood is if the app version is >= 2.0.0,
build.rssets aversion_ge_2Rust cfg attribute as well as aVERSION_GE_2C++ define, to mean "version greater than or equal to 2". Features are then guarded like:Flags are provided instead of actual version numbers since, unlike C++, Rust doesn't have a way to do conditional compilation based on version math, and this keeps things consistent in both languages. However, it should be possible to stack such version flags to do version range checks, which is why they indicate "greater than or equal" rather than exact versions. For example, a hypothetical major version 3 could set a
version_ge_3flag along with aversion_ge_2as well.