Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
63 changes: 1 addition & 62 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,68 +74,7 @@ set(ROOTSYS ${CMAKE_BINARY_DIR})
set(HEADER_OUTPUT_PATH ${CMAKE_BINARY_DIR}/include)

#---Set the ROOT version--------------------------------------------------------------------
find_package(Git)
if(Git_FOUND AND EXISTS ${CMAKE_SOURCE_DIR}/.git)
execute_process(COMMAND ${GIT_EXECUTABLE} --git-dir=${CMAKE_SOURCE_DIR}/.git describe --all
OUTPUT_VARIABLE GIT_DESCRIBE_ALL
RESULT_VARIABLE GIT_DESCRIBE_ERRCODE
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
else()
set(GIT_DESCRIBE_ERRCODE "NoGit")
endif()

function(SET_VERSION_FROM_FILE)
# See https://stackoverflow.com/questions/47066115/cmake-get-version-from-multiline-text-file
file(READ "${CMAKE_SOURCE_DIR}/core/foundation/inc/ROOT/RVersion.hxx" versionstr)
string(REGEX MATCH "#define ROOT_VERSION_MAJOR ([0-9]*)" _ ${versionstr})
set(ROOT_MAJOR_VERSION ${CMAKE_MATCH_1})
string(REGEX MATCH "#define ROOT_VERSION_MINOR ([0-9]*)" _ ${versionstr})
set(ROOT_MINOR_VERSION ${CMAKE_MATCH_1})
string(REGEX MATCH "#define ROOT_VERSION_PATCH ([0-9]*)" _ ${versionstr})
set(ROOT_PATCH_VERSION ${CMAKE_MATCH_1})

set(ROOT_MAJOR_VERSION "${ROOT_MAJOR_VERSION}" PARENT_SCOPE)
set(ROOT_MINOR_VERSION "${ROOT_MINOR_VERSION}" PARENT_SCOPE)
set(ROOT_PATCH_VERSION "${ROOT_PATCH_VERSION}" PARENT_SCOPE)
endfunction()

SET_VERSION_FROM_FILE()

set(ROOT_VERSION "${ROOT_MAJOR_VERSION}.${ROOT_MINOR_VERSION}.${ROOT_PATCH_VERSION}")
set(ROOT_FULL_VERSION "${ROOT_VERSION}")

math(EXPR ROOT_PATCH_VERSION_ODD ${ROOT_PATCH_VERSION}%2)
# For release versions (even patch version number) we use the number from
# core/foundation/inc/ROOT/RVersion.hxx, not that of git: it's more stable / reliable.
if(NOT GIT_DESCRIBE_ERRCODE AND ${ROOT_PATCH_VERSION_ODD} EQUAL 1)
execute_process(COMMAND ${GIT_EXECUTABLE} --git-dir=${CMAKE_SOURCE_DIR}/.git describe --always
OUTPUT_VARIABLE GIT_DESCRIBE_ALWAYS
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
string(TIMESTAMP GIT_TIMESTAMP "%b %d %Y, %H:%M:%S" UTC)

if("${GIT_DESCRIBE_ALL}" MATCHES "^tags/v[0-9]+-[0-9]+-[0-9]+.*")
# GIT_DESCRIBE_ALWAYS: v6-16-00-rc1
# GIT_DESCRIBE_ALL: tags/v6-16-00-rc1
# tag might end on "-rc1" or similar; parse version number in front.
string(REGEX REPLACE "^tags/v([0-9]+)-.*" "\\1" ROOT_MAJOR_VERSION ${GIT_DESCRIBE_ALL})
string(REGEX REPLACE "^tags/v[0-9]+-([0-9]+).*" "\\1" ROOT_MINOR_VERSION ${GIT_DESCRIBE_ALL})
string(REGEX REPLACE "^tags/v[0-9]+-[0-9]+-([0-9]+).*" "\\1" ROOT_PATCH_VERSION ${GIT_DESCRIBE_ALL})
string(REGEX REPLACE "^v([0-9]+)-([0-9]+)-(.*)" "\\1.\\2.\\3" ROOT_FULL_VERSION ${GIT_DESCRIBE_ALWAYS})
elseif("${GIT_DESCRIBE_ALL}" MATCHES "/v[0-9]+-[0-9]+.*-patches$")
# GIT_DESCRIBE_ALWAYS: v6-16-00-rc1-47-g9ba56ef4a3
# GIT_DESCRIBE_ALL: heads/v6-16-00-patches
string(REGEX REPLACE "^.*/v([0-9]+)-.*" "\\1" ROOT_MAJOR_VERSION ${GIT_DESCRIBE_ALL})
string(REGEX REPLACE "^.*/v[0-9]+-([0-9]+).*" "\\1" ROOT_MINOR_VERSION ${GIT_DESCRIBE_ALL})
set(ROOT_PATCH_VERSION "99") # aka head of ...-patches
else()
# GIT_DESCRIBE_ALWAYS: v6-13-04-2163-g7e8d27ea66
# GIT_DESCRIBE_ALL: heads/master or remotes/origin/master

# Use what was set above in SET_VERSION_FROM_FILE().
endif()
endif()
include(cmake/modules/SetROOTVersion.cmake)

message(STATUS "Building ROOT version ${ROOT_FULL_VERSION}")

Expand Down
1 change: 1 addition & 0 deletions README/ReleaseNotes/v630/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ The following people have contributed to this new version:
- The `RooSpan` class was removed and its place in the implementation details of RooFit is now taken by `std::span`.
- The `RooAbsArg::isCloneOf()` and `RooAbsArg::getCloningAncestors()` member functions were removed because they didn't work (always returned `false` and an empty list respectively)
- `ROOT::Math::KelvinFunctions` had an incompatible license and needed to be removed without deprecation.
- The use of `ROOT_GIT_BRANCH` and `ROOT_GIT_COMMIT` have been deprecated in favor of parsing `etc/gitinfo.txt`. This later file is now generated as part of the build of ROOT; `RGitCommit.h` (defining `ROOT_GIT_BRANCH` and `ROOT_GIT_COMMIT`) is not updated anymore. This simplifies ROOT's build and release procedure.

## Core Libraries

Expand Down
15 changes: 3 additions & 12 deletions build/unix/makedistsrc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,6 @@ ROOTSRCDIR=$3

TARFILE=root_v$FILEVERS.source.tar

( cd $ROOTSRCDIR; git archive -v -o ../$TARFILE --prefix=root-$FILEVERS/ $GITTAG )

mkdir -p etc/root-$FILEVERS/etc
cp etc/gitinfo.txt etc/root-$FILEVERS/etc/
cd etc
tar -r -vf ../../$TARFILE root-$FILEVERS/etc/gitinfo.txt
cd ..
rm -rf etc/root-$FILEVERS
cd ..
gzip $TARFILE

exit 0
cd $ROOTSRCDIR \
&& git archive -v -o ../$TARFILE --prefix=root-$FILEVERS/ $GITTAG \
&& gzip $TARFILE
91 changes: 91 additions & 0 deletions cmake/modules/SetROOTVersion.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Copyright (C) 1995-2023, Rene Brun and Fons Rademakers.
# All rights reserved.
#
# For the licensing terms see $ROOTSYS/LICENSE.
# For the list of contributors see $ROOTSYS/README/CREDITS.

# Sets the following variables:
# - ROOT_MAJOR_VERSION, ROOT_MINOR_VERSION, ROOT_PATCH_VERSION, e.g. "6", "30", "00", respectively.
# - ROOT_VERSION: "6.30.00"
# - ROOT_FULL_VERSION: 6.29.02-pre1
# - GIT_DESCRIBE_ALWAYS: output of `git describe --always` if source directory is git repo
# - GIT_DESCRIBE_ALL: output of `git describe --all` if source directory is git repo


cmake_minimum_required(VERSION 3.16 FATAL_ERROR)

find_package(Git)

function(SET_VERSION_FROM_FILE)
# See https://stackoverflow.com/questions/47066115/cmake-get-version-from-multiline-text-file
file(READ "${CMAKE_SOURCE_DIR}/core/foundation/inc/ROOT/RVersion.hxx" versionstr)
string(REGEX MATCH "#define ROOT_VERSION_MAJOR ([0-9]*)" _ ${versionstr})
set(ROOT_MAJOR_VERSION ${CMAKE_MATCH_1})
string(REGEX MATCH "#define ROOT_VERSION_MINOR ([0-9]*)" _ ${versionstr})
set(ROOT_MINOR_VERSION ${CMAKE_MATCH_1})
string(REGEX MATCH "#define ROOT_VERSION_PATCH ([0-9]*)" _ ${versionstr})
set(ROOT_PATCH_VERSION ${CMAKE_MATCH_1})

set(ROOT_MAJOR_VERSION "${ROOT_MAJOR_VERSION}" PARENT_SCOPE)
set(ROOT_MINOR_VERSION "${ROOT_MINOR_VERSION}" PARENT_SCOPE)
set(ROOT_PATCH_VERSION "${ROOT_PATCH_VERSION}" PARENT_SCOPE)
endfunction()

function(SET_ROOT_VERSION)
if(Git_FOUND AND EXISTS ${CMAKE_SOURCE_DIR}/.git)
execute_process(COMMAND ${GIT_EXECUTABLE} --git-dir=${CMAKE_SOURCE_DIR}/.git describe --all
OUTPUT_VARIABLE GIT_DESCRIBE_ALL
RESULT_VARIABLE GIT_DESCRIBE_ERRCODE
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
else()
set(GIT_DESCRIBE_ERRCODE "NoGit")
endif()

SET_VERSION_FROM_FILE()

set(ROOT_VERSION "${ROOT_MAJOR_VERSION}.${ROOT_MINOR_VERSION}.${ROOT_PATCH_VERSION}")
set(ROOT_FULL_VERSION "${ROOT_VERSION}")

math(EXPR ROOT_PATCH_VERSION_ODD ${ROOT_PATCH_VERSION}%2)
# For release versions (even patch version number) we use the number from
# core/foundation/inc/ROOT/RVersion.hxx, not that of git: it's more stable / reliable.
if(NOT GIT_DESCRIBE_ERRCODE AND ${ROOT_PATCH_VERSION_ODD} EQUAL 1)
execute_process(COMMAND ${GIT_EXECUTABLE} --git-dir=${CMAKE_SOURCE_DIR}/.git describe --always
OUTPUT_VARIABLE GIT_DESCRIBE_ALWAYS
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)

if("${GIT_DESCRIBE_ALL}" MATCHES "^tags/v[0-9]+-[0-9]+-[0-9]+.*")
# GIT_DESCRIBE_ALWAYS: v6-16-00-rc1
# GIT_DESCRIBE_ALL: tags/v6-16-00-rc1
# tag might end on "-rc1" or similar; parse version number in front.
string(REGEX REPLACE "^tags/v([0-9]+)-.*" "\\1" ROOT_MAJOR_VERSION ${GIT_DESCRIBE_ALL})
string(REGEX REPLACE "^tags/v[0-9]+-([0-9]+).*" "\\1" ROOT_MINOR_VERSION ${GIT_DESCRIBE_ALL})
string(REGEX REPLACE "^tags/v[0-9]+-[0-9]+-([0-9]+).*" "\\1" ROOT_PATCH_VERSION ${GIT_DESCRIBE_ALL})
string(REGEX REPLACE "^v([0-9]+)-([0-9]+)-(.*)" "\\1.\\2.\\3" ROOT_FULL_VERSION ${GIT_DESCRIBE_ALWAYS})
elseif("${GIT_DESCRIBE_ALL}" MATCHES "/v[0-9]+-[0-9]+.*-patches$")
# GIT_DESCRIBE_ALWAYS: v6-16-00-rc1-47-g9ba56ef4a3
# GIT_DESCRIBE_ALL: heads/v6-16-00-patches
string(REGEX REPLACE "^.*/v([0-9]+)-.*" "\\1" ROOT_MAJOR_VERSION ${GIT_DESCRIBE_ALL})
string(REGEX REPLACE "^.*/v[0-9]+-([0-9]+).*" "\\1" ROOT_MINOR_VERSION ${GIT_DESCRIBE_ALL})
set(ROOT_PATCH_VERSION "99") # aka head of ...-patches
else()
# GIT_DESCRIBE_ALWAYS: v6-13-04-2163-g7e8d27ea66
# GIT_DESCRIBE_ALL: heads/master or remotes/origin/master

# Use what was set above in SET_VERSION_FROM_FILE().
endif()
endif()

set(ROOT_MAJOR_VERSION "${ROOT_MAJOR_VERSION}" PARENT_SCOPE)
set(ROOT_MINOR_VERSION "${ROOT_MINOR_VERSION}" PARENT_SCOPE)
set(ROOT_PATCH_VERSION "${ROOT_PATCH_VERSION}" PARENT_SCOPE)
set(ROOT_VERSION "${ROOT_VERSION}" PARENT_SCOPE)
set(ROOT_FULL_VERSION "${ROOT_FULL_VERSION}" PARENT_SCOPE)
set(GIT_DESCRIBE_ALWAYS "${GIT_DESCRIBE_ALWAYS}" PARENT_SCOPE)
set(GIT_DESCRIBE_ALL "${GIT_DESCRIBE_ALL}" PARENT_SCOPE)
endfunction()


SET_ROOT_VERSION()
50 changes: 50 additions & 0 deletions cmake/modules/UpdateGitInfo.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Copyright (C) 1995-2023, Rene Brun and Fons Rademakers.
# All rights reserved.
#
# For the licensing terms see $ROOTSYS/LICENSE.
# For the list of contributors see $ROOTSYS/README/CREDITS.

# Writes etc/gitinfo.txt based on the source directory's git commit - if available -
# or the version info.

# INPUT variables: none
# OUTPUT variables: none

# In script mode, CMake doesn't get CMAKE_SOURCE_DIR / CMAKE_BINARY_DIR right.
if(SRCDIR)
set(CMAKE_SOURCE_DIR ${SRCDIR})
endif()
if(BINDIR)
set(CMAKE_BINARY_DIR ${BINDIR})
endif()

include(${CMAKE_SOURCE_DIR}/cmake/modules/SetROOTVersion.cmake)

function(UPDATE_GIT_VERSION)
string(TIMESTAMP PSEUDO_GIT_TIMESTAMP "%b %d %Y, %H:%M:%S" UTC)
if(GIT_DESCRIBE_ALL)
file(WRITE ${CMAKE_BINARY_DIR}/etc/gitinfo.txt
"${GIT_DESCRIBE_ALL}\n${GIT_DESCRIBE_ALWAYS}\n${PSEUDO_GIT_TIMESTAMP}\n")
else()
math(EXPR ROOT_PATCH_VERSION_ODD ${ROOT_PATCH_VERSION}%2)
if(${ROOT_PATCH_VERSION} EQUAL 0)
# A release.
math(EXPR ROOT_MINOR_VERSION_ODD ${ROOT_MINOR_VERSION}%2)
if(${ROOT_MINOR_VERSION_ODD} EQUAL 1)
# Dev release.
file(WRITE ${CMAKE_BINARY_DIR}/etc/gitinfo.txt
"heads/master\ntags/v${ROOT_MAJOR_VERSION}-${ROOT_MINOR_VERSION}-${ROOT_PATCH_VERSION}\n${PSEUDO_GIT_TIMESTAMP}\n")
else()
# Production release / patch release.
file(WRITE ${CMAKE_BINARY_DIR}/etc/gitinfo.txt
"heads/v${ROOT_MAJOR_VERSION}-${ROOT_MINOR_VERSION}-patches\ntags/v${ROOT_MAJOR_VERSION}-${ROOT_MINOR_VERSION}-${ROOT_PATCH_VERSION}\n${PSEUDO_GIT_TIMESTAMP}\n")
endif()
else()
file(WRITE ${CMAKE_BINARY_DIR}/etc/gitinfo.txt
"heads/master\ntags/v${ROOT_MAJOR_VERSION}-${ROOT_MINOR_VERSION}-${ROOT_PATCH_VERSION}\n${PSEUDO_GIT_TIMESTAMP}\n")
message(WARNING "Cannot determine git revision info: source is not a release and not a git repo. Noting v${ROOT_MAJOR_VERSION}-${ROOT_MINOR_VERSION}-${ROOT_PATCH_VERSION} as commit.")
endif()
endif()
endfunction()

UPDATE_GIT_VERSION()
28 changes: 8 additions & 20 deletions config/root-config.bat.in
Original file line number Diff line number Diff line change
Expand Up @@ -109,32 +109,20 @@ for %%w in (%*) do (
set out=!out! !prefix!
)
if "!arg!"=="--version" (
rem Output the version number. If RVersion.h can not be found, give up.
if exist !incdir!\RVersion.h (
for /f "tokens=2,3" %%a in (!incdir!\RVersion.h) do (
if "%%a"=="ROOT_RELEASE" (
set ROOT_RELEASE=%%~b
)
)
set out=!out! !ROOT_RELEASE!
) else (
echo "cannot read ${incdir}/RVersion.h"
exit /b 1
)
set out=!out! @ROOT_VERSION@
)
if "!arg!"=="--git-revision" (
rem Output the git revision number. If RGitCommit.h can not be found, give up.
if exist !incdir!\RGitCommit.h (
for /f "tokens=2,3" %%a in (!incdir!\RGitCommit.h) do (
if "%%a"=="ROOT_GIT_COMMIT" (
set ROOT_GIT_COMMIT=%%~b
)
if exist !etcdir!\gitinfo.txt (
for /f "skip=1" %%l in (!etcdir!\gitinfo.txt) do (
set ROOT_GIT_COMMIT=%%~l
goto COMMITSET
)
set out=!out! !ROOT_GIT_COMMIT!
) else (
echo "cannot read !incdir!\RGitCommit.h"
echo "cannot read !etcdir!\gitinfo.txt"
exit /b 1
)
:COMMITSET
set out=!out! !ROOT_GIT_COMMIT!
)
if "!arg!"=="--python-version" (
set out=!out! @pythonvers@
Expand Down
8 changes: 4 additions & 4 deletions config/root-config.in
Original file line number Diff line number Diff line change
Expand Up @@ -556,11 +556,11 @@ while test $# -gt 0; do
out="$out @ROOT_VERSION@"
;;
--git-revision)
### Output the git revision number. If RGitCommit.h can not be found, give up.
if test -r "${incdir}/RGitCommit.h"; then
out="$out `sed -n 's,.*ROOT_GIT_COMMIT *\"\(.*\)\".*,\1,p' < \"${incdir}/RGitCommit.h\"`"
### Output the git revision. Give up if gitinfo.txt can not be found.
if test -r "${etcdir}/gitinfo.txt"; then
out="$out `head -m2 \"${etcdir}/gitinfo.txt\" | tail -n`"
else
echo "cannot read ${incdir}/RGitCommit.h"
echo "cannot read ${etcdir}/gitinfo.txt"
exit 1
fi
;;
Expand Down
52 changes: 10 additions & 42 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
# CMakeLists.txt file for building ROOT (global) core package
############################################################################

file(WRITE ${CMAKE_BINARY_DIR}/etc/gitinfo.txt
"${GIT_DESCRIBE_ALL}\n${GIT_DESCRIBE_ALWAYS}\n${GIT_TIMESTAMP}\n")

file(WRITE ${CMAKE_BINARY_DIR}/RGitCommit.h.tmp
"#ifndef ROOT_RGITCOMMIT_H
#define ROOT_RGITCOMMIT_H
#define ROOT_GIT_BRANCH \"${GIT_DESCRIBE_ALL}\"
#define ROOT_GIT_COMMIT \"${GIT_DESCRIBE_ALWAYS}\"
#endif"
include(SetROOTVersion)

# Update etc/gitinfo.txt for every build.
add_custom_target(gitinfotxt
ALL
COMMAND ${CMAKE_COMMAND} -DSRCDIR=${CMAKE_SOURCE_DIR} -DBINDIR=${CMAKE_BINARY_DIR} -P ${CMAKE_SOURCE_DIR}/cmake/modules/UpdateGitInfo.cmake
WORKING_DIRECTORY
COMMENT "Updating etc/gitinfo.txt."
BYPRODUCTS ${CMAKE_BINARY_DIR}/etc/gitinfo.txt
)

set_source_files_properties(${CMAKE_BINARY_DIR}/ginclude/RConfigure.h
Expand All @@ -33,46 +33,14 @@ add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/include/RConfigure.h

add_custom_target(rconfigure ALL DEPENDS ${CMAKE_BINARY_DIR}/include/RConfigure.h)

add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/ginclude/RGitCommit.h
COMMAND
${CMAKE_COMMAND} -E copy_if_different
${CMAKE_BINARY_DIR}/RGitCommit.h.tmp
${CMAKE_BINARY_DIR}/ginclude/RGitCommit.h
DEPENDS
${CMAKE_BINARY_DIR}/RGitCommit.h.tmp
)

add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/include/RGitCommit.h
COMMAND
${CMAKE_COMMAND} -E copy_if_different
${CMAKE_BINARY_DIR}/RGitCommit.h.tmp
${CMAKE_BINARY_DIR}/include/RGitCommit.h
DEPENDS
${CMAKE_BINARY_DIR}/RGitCommit.h.tmp
)

add_custom_target(gitcommit ALL DEPENDS
${CMAKE_BINARY_DIR}/include/RGitCommit.h
${CMAKE_BINARY_DIR}/ginclude/RGitCommit.h
)

set_source_files_properties(${CMAKE_BINARY_DIR}/ginclude/RGitCommit.h
PROPERTIES GENERATED TRUE HEADER_FILE_ONLY TRUE)

set_source_files_properties(${CMAKE_BINARY_DIR}/include/RGitCommit.h
PROPERTIES GENERATED TRUE HEADER_FILE_ONLY TRUE)

install(FILES ${CMAKE_BINARY_DIR}/ginclude/RGitCommit.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

ROOT_LINKER_LIBRARY(Core BUILTINS LZMA)

generateHeader(Core
${CMAKE_SOURCE_DIR}/core/base/src/root-argparse.py
${CMAKE_BINARY_DIR}/ginclude/TApplicationCommandLineOptionsHelp.h
)

add_dependencies(Core CLING gitcommit rconfigure)
add_dependencies(Core CLING rconfigure)

target_link_libraries(Core
PRIVATE
Expand Down
Loading