Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
5779779
single source of truth for version identifier
ahnaf-tahmid-chowdhury Sep 24, 2024
104dfb0
Follow PyPA compliant
ahnaf-tahmid-chowdhury Sep 27, 2024
cb849ee
move version file to root-level
ahnaf-tahmid-chowdhury Sep 27, 2024
0ce318c
add get_version_info function
ahnaf-tahmid-chowdhury Sep 27, 2024
0eff6a4
Merge remote-tracking branch 'upstream/develop' into version
ahnaf-tahmid-chowdhury Oct 3, 2024
dd6e579
Merge remote-tracking branch 'upstream/develop' into version
ahnaf-tahmid-chowdhury Oct 16, 2024
23b93e3
add export config
ahnaf-tahmid-chowdhury Oct 16, 2024
31e3692
remove version file
ahnaf-tahmid-chowdhury Oct 16, 2024
d6be0ff
Ensure the version string matches a standard format
ahnaf-tahmid-chowdhury Oct 16, 2024
8bc99cd
set fetch depth to zero
ahnaf-tahmid-chowdhury Oct 16, 2024
2eb6c93
Merge branch 'develop' into version
shimwell Jan 11, 2025
5219406
add hash
ahnaf-tahmid-chowdhury Jan 12, 2025
d4b37cf
Add more log
ahnaf-tahmid-chowdhury Jan 12, 2025
160bf43
clang format
ahnaf-tahmid-chowdhury Jan 12, 2025
2b47355
Find git at the beginning
ahnaf-tahmid-chowdhury Jan 12, 2025
923f84a
add VERSION_COMMIT_COUNT
ahnaf-tahmid-chowdhury Jan 19, 2025
07c65a3
Increment release number for dev versions
ahnaf-tahmid-chowdhury Jan 23, 2025
940c571
Merge remote-tracking branch 'upstream/develop' into version
ahnaf-tahmid-chowdhury Jan 23, 2025
21594d6
Move versioning to a separate file, as suggested by @gonuke
ahnaf-tahmid-chowdhury Jan 26, 2025
14e678f
add more info
ahnaf-tahmid-chowdhury Jan 26, 2025
075f92b
Merge remote-tracking branch 'upstream/develop' into version
ahnaf-tahmid-chowdhury Jan 26, 2025
dc28e2a
Update cmake/Modules/GetVersionFromGit.cmake
ahnaf-tahmid-chowdhury Jan 27, 2025
e2a64d7
Update cmake/Modules/GetVersionFromGit.cmake
ahnaf-tahmid-chowdhury Jan 27, 2025
1603dc5
add more variables
ahnaf-tahmid-chowdhury Jan 27, 2025
9dc344e
Update cmake/Modules/GetVersionFromGit.cmake
ahnaf-tahmid-chowdhury Jan 29, 2025
efc43ba
Merge branch 'develop' into version
ahnaf-tahmid-chowdhury Feb 17, 2025
a2942f6
Don't use PROJECT_ variable names
paulromano Feb 20, 2025
727a0ae
Get rid of unused variables
paulromano Feb 20, 2025
8440b2c
Fix fetch-depth
paulromano Feb 20, 2025
8ddcb06
Set fetch-depth to 0 as before
paulromano Feb 20, 2025
ece247a
Update cmake/Modules/GetVersionFromGit.cmake
paulromano Feb 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add hash
  • Loading branch information
ahnaf-tahmid-chowdhury committed Jan 12, 2025
commit 521940629917d1cab68a364b4c897b90571094ef
1 change: 1 addition & 0 deletions .git_archival.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node: $Format:%H$
short-node: $Format:%h$
node-date: $Format:%cI$
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
26 changes: 26 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,21 @@ project(openmc C CXX)

# Try to get the version from git describe
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
# Extract the tag
execute_process(
COMMAND git describe --tags --match "*[0-9]*" --dirty
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE VERSION_STRING
OUTPUT_STRIP_TRAILING_WHITESPACE
)

# Extract the abbreviated hash
execute_process(
COMMAND git rev-parse --short HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE ABBREVIATED_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
else()
set(GIT_ARCHIVAL_FILE "${CMAKE_SOURCE_DIR}/.git_archival.txt")
if(EXISTS "${GIT_ARCHIVAL_FILE}")
Expand All @@ -23,6 +32,16 @@ else()
else()
message(FATAL_ERROR "Could not extract version from .git_archival.txt")
endif()

# Extract the abbreviated hash
string(REGEX MATCH "short-node: ([a-f0-9]+)" ABBREVIATED_HASH "${GIT_ARCHIVAL_CONTENT}")

# If a abbreviated hash is found, use it
if(ABBREVIATED_HASH MATCHES "short-node: ([a-f0-9]+)")
set(ABBREVIATED_HASH "${CMAKE_MATCH_1}")
else()
message(FATAL_ERROR "Could not extract abbreviated hash from .git_archival.txt")
endif()
else()
message(FATAL_ERROR "Neither git describe nor .git_archival.txt is available for versioning.")
endif()
Expand All @@ -31,6 +50,11 @@ endif()
# Ensure the version string matches a standard format
if(VERSION_STRING MATCHES "^v?([0-9]+\\.[0-9]+\\.[0-9]+)([-].*)?")
set(VERSION_NO_SUFFIX "${CMAKE_MATCH_1}")
if(VERSION_STRING MATCHES "-.*")
set(VERSION_DEV_SUFFIX "true")
else()
set(VERSION_DEV_SUFFIX "false")
endif()
else()
message(FATAL_ERROR "Invalid version format: ${VERSION_STRING}")
endif()
Expand All @@ -42,6 +66,8 @@ list(GET VERSION_LIST 1 OPENMC_VERSION_MINOR)
list(GET VERSION_LIST 2 OPENMC_VERSION_RELEASE)
set(OPENMC_VERSION ${OPENMC_VERSION_MAJOR}.${OPENMC_VERSION_MINOR}.${OPENMC_VERSION_RELEASE})
message(STATUS "OpenMC version: ${OPENMC_VERSION}")
message(STATUS "OpenMC development version: ${VERSION_DEV_SUFFIX}")
message(STATUS "OpenMC version hash: ${ABBREVIATED_HASH}")

# Generate version.h
configure_file(include/openmc/version.h.in "${CMAKE_BINARY_DIR}/include/openmc/version.h" @ONLY)
Expand Down
3 changes: 2 additions & 1 deletion include/openmc/version.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ namespace openmc {
constexpr int VERSION_MAJOR {@OPENMC_VERSION_MAJOR@};
constexpr int VERSION_MINOR {@OPENMC_VERSION_MINOR@};
constexpr int VERSION_RELEASE {@OPENMC_VERSION_RELEASE@};
constexpr bool VERSION_DEV {true};
constexpr bool VERSION_DEV {@VERSION_DEV_SUFFIX@};
constexpr const char* VERSION_HASH = "@ABBREVIATED_HASH@";
constexpr std::array<int, 3> VERSION {VERSION_MAJOR, VERSION_MINOR, VERSION_RELEASE};
// clang-format on

Expand Down
6 changes: 3 additions & 3 deletions src/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ void title()
// Write version information
fmt::print(
" | The OpenMC Monte Carlo Code\n"
" Copyright | 2011-2024 MIT, UChicago Argonne LLC, and contributors\n"
" Copyright | 2011-2025 MIT, UChicago Argonne LLC, and contributors\n"
" License | https://docs.openmc.org/en/latest/license.html\n"
" Version | {}.{}.{}{}\n",
VERSION_MAJOR, VERSION_MINOR, VERSION_RELEASE, VERSION_DEV ? "-dev" : "");
" Version | {}.{}.{}{} ({})\n",
VERSION_MAJOR, VERSION_MINOR, VERSION_RELEASE, VERSION_DEV ? "-dev" : "", VERSION_HASH);
#ifdef GIT_SHA1
fmt::print(" Git SHA1 | {}\n", GIT_SHA1);
#endif
Expand Down