Skip to content
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

Fix mechanism for getting package version, when git is not present #349

Merged
merged 2 commits into from
Aug 6, 2024

Conversation

nirosys
Copy link
Contributor

@nirosys nirosys commented Aug 6, 2024

Issue #, if available: n/a

Description of changes:
Not too long ago an API was added in order to provide access to ion-c version information programmatically. During the build, a cmake script would query git for detailed information (revision sha, commits since tag, etc) to include in the API's data.

In the event that git is not available, or not enough git commits have been pulled down (clone --depth 1 for instance) this information is not present. The intention, was to lean on the cmake project's version in this case, but 2 issues prevented that from happening, which this PR fixes.

  • Use of CMAKE_PROJECT_VERSION in a script that is not really executed as part of the project. This leads to an undefined version when git did not provide a version.
  • Mismatch between the initialization of the project version, and how git would provide a long description. When git did/could not provide a version the default project version would not match the regex that parsed the version, resulting in build failure.

This PR passes the project version to the cmake script as a define, so that it is always present. It also fixes the default version to include filler that would normally be present in a git describe, so that the regex correctly matches and version header is generated.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@nirosys nirosys marked this pull request as ready for review August 6, 2024 21:09
jobarr-amzn
jobarr-amzn previously approved these changes Aug 6, 2024
tgregg
tgregg previously approved these changes Aug 6, 2024
CMakeLists.txt Outdated
@@ -53,13 +53,14 @@ elseif (CMAKE_BUILD_TYPE STREQUAL "Profiling")
endif()

## ion-c Build Version
set(IONC_FULL_VERSION ${CMAKE_PROJECT_VERSION})
set(IONC_FULL_VERSION "v${CMAKE_PROJECT_VERSION}-0-g000000")
Copy link
Contributor

Choose a reason for hiding this comment

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

I recommend leaving a comment about why this is formatted this way.

@nirosys nirosys dismissed stale reviews from tgregg and jobarr-amzn via 4aa87b5 August 6, 2024 22:00
@nirosys nirosys merged commit 3969362 into amazon-ion:master Aug 6, 2024
13 checks passed
@nirosys nirosys deleted the rgiliam/fix_version branch January 10, 2025 22:29
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.

3 participants