diff --git a/CMakeLists.txt b/CMakeLists.txt index 73f4b4233f0ad..ef4a246e5cee3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}") diff --git a/README/ReleaseNotes/v630/index.md b/README/ReleaseNotes/v630/index.md index cb54ed9f43cfe..63f09840c0906 100644 --- a/README/ReleaseNotes/v630/index.md +++ b/README/ReleaseNotes/v630/index.md @@ -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 diff --git a/build/unix/makedistsrc.sh b/build/unix/makedistsrc.sh index ad443dc5bb594..b966f8c9a9622 100755 --- a/build/unix/makedistsrc.sh +++ b/build/unix/makedistsrc.sh @@ -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 diff --git a/cmake/modules/SetROOTVersion.cmake b/cmake/modules/SetROOTVersion.cmake new file mode 100644 index 0000000000000..2216a4bd48ce7 --- /dev/null +++ b/cmake/modules/SetROOTVersion.cmake @@ -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() diff --git a/cmake/modules/UpdateGitInfo.cmake b/cmake/modules/UpdateGitInfo.cmake new file mode 100644 index 0000000000000..3a71413135248 --- /dev/null +++ b/cmake/modules/UpdateGitInfo.cmake @@ -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() diff --git a/config/root-config.bat.in b/config/root-config.bat.in index 3a9cbefc0cc24..002fb5e6a4a96 100644 --- a/config/root-config.bat.in +++ b/config/root-config.bat.in @@ -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@ diff --git a/config/root-config.in b/config/root-config.in index a46ae9802ae5e..e878cc7ac7946 100755 --- a/config/root-config.in +++ b/config/root-config.in @@ -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 ;; diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 627b09346fbd5..b00f377a0854b 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -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 @@ -33,38 +33,6 @@ 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 @@ -72,7 +40,7 @@ generateHeader(Core ${CMAKE_BINARY_DIR}/ginclude/TApplicationCommandLineOptionsHelp.h ) -add_dependencies(Core CLING gitcommit rconfigure) +add_dependencies(Core CLING rconfigure) target_link_libraries(Core PRIVATE diff --git a/core/base/src/TROOT.cxx b/core/base/src/TROOT.cxx index cfe7927015a40..2c3f68756500b 100644 --- a/core/base/src/TROOT.cxx +++ b/core/base/src/TROOT.cxx @@ -68,10 +68,9 @@ of a main program creating an interactive version is shown below: #include #include +#include #include "RConfigure.h" #include "RConfigOptions.h" -#include "RVersion.h" -#include "RGitCommit.h" #include #include #include @@ -2390,15 +2389,8 @@ Longptr_t TROOT::ProcessLineFast(const char *line, Int_t *error) void TROOT::ReadGitInfo() { -#ifdef ROOT_GIT_COMMIT - fGitCommit = ROOT_GIT_COMMIT; -#endif -#ifdef ROOT_GIT_BRANCH - fGitBranch = ROOT_GIT_BRANCH; -#endif - - TString gitinfo = "gitinfo.txt"; - char *filename = gSystem->ConcatFileName(TROOT::GetEtcDir(), gitinfo); + TString filename = "gitinfo.txt"; + gSystem->PrependPathName(TROOT::GetEtcDir(), filename); FILE *fp = fopen(filename, "r"); if (fp) { @@ -2406,15 +2398,16 @@ void TROOT::ReadGitInfo() // read branch name s.Gets(fp); fGitBranch = s; - // read commit SHA1 + // read commit hash s.Gets(fp); fGitCommit = s; // read date/time make was run s.Gets(fp); fGitDate = s; fclose(fp); + } else { + Error("ReadGitInfo()", "Cannot determine git info: etc/gitinfo.txt not found!"); } - delete [] filename; } Bool_t &GetReadingObject() { diff --git a/core/foundation/inc/RGitCommit.h b/core/foundation/inc/RGitCommit.h new file mode 100644 index 0000000000000..70d99d4885f5d --- /dev/null +++ b/core/foundation/inc/RGitCommit.h @@ -0,0 +1,12 @@ +#ifndef ROOT_RGITCOMMIT_H +#define ROOT_RGITCOMMIT_H +#include "ROOT/RConfig.hxx" +namespace ROOT { +namespace Internal { + static constexpr const char R__DEPRECATED(6,32, "Not updated anymore; please use etc/gitinfo.txt") gGitBranch[] = ""; + static constexpr const char R__DEPRECATED(6,32, "Not updated anymore; please use etc/gitinfo.txt") gGitCommit[] = ""; +} +} +#define ROOT_GIT_BRANCH (ROOT::Internal::gGitBranch) +#define ROOT_GIT_COMMIT (ROOT::Internal::gGitCommit) +#endif diff --git a/proof/proofd/inc/XrdROOT.h b/proof/proofd/inc/XrdROOT.h index 8a96ff700655b..17213996d2715 100644 --- a/proof/proofd/inc/XrdROOT.h +++ b/proof/proofd/inc/XrdROOT.h @@ -39,6 +39,7 @@ friend class XrdROOTMgr; XrdOucString fDir; XrdOucString fBinDir; XrdOucString fDataDir; + XrdOucString fEtcDir; XrdOucString fIncDir; XrdOucString fLibDir; XrdOucString fTag; @@ -59,12 +60,14 @@ friend class XrdROOTMgr; public: XrdROOT(const char *dir, const char *tag, const char *bindir = 0, - const char *incdir = 0, const char *libdir = 0, const char *datadir = 0); + const char *incdir = 0, const char *libdir = 0, const char *datadir = 0, + const char *etcdir = 0); ~XrdROOT() { } const char *Dir() const { return fDir.c_str(); } const char *BinDir() const { return fBinDir.c_str(); } const char *DataDir() const { return fDataDir.c_str(); } + const char *EtcDir() const { return fEtcDir.c_str(); } const char *IncDir() const { return fIncDir.c_str(); } const char *LibDir() const { return fLibDir.c_str(); } const char *Export() const { return fExport.c_str(); } diff --git a/proof/proofd/src/XrdROOT.cxx b/proof/proofd/src/XrdROOT.cxx index 0233dfd7ac853..6d3bb1cdfc856 100644 --- a/proof/proofd/src/XrdROOT.cxx +++ b/proof/proofd/src/XrdROOT.cxx @@ -20,7 +20,6 @@ ////////////////////////////////////////////////////////////////////////// #include "RConfigure.h" #include "ROOT/RVersion.hxx" -#include "RGitCommit.h" #include "XrdProofdPlatform.h" @@ -36,27 +35,29 @@ // Tracing #include "XrdProofdTrace.h" +#include + //////////////////////////////////////////////////////////////////////////////// /// Constructor: validates 'dir', gets the version and defines the tag. XrdROOT::XrdROOT(const char *dir, const char *tag, const char *bindir, - const char *incdir, const char *libdir, const char *datadir) + const char *incdir, const char *libdir, const char *datadir, + const char *etcdir) { XPDLOC(SMGR, "XrdROOT") fStatus = -1; fSrvProtVers = -1; fRelease = ROOT_RELEASE; - fGitCommit = ROOT_GIT_COMMIT; fVersionCode = ROOT_VERSION_CODE; fVrsMajor = ROOT_VERSION_MAJOR; fVrsMinor = ROOT_VERSION_MINOR; fVrsPatch = ROOT_VERSION_PATCH; // 'dir' must make sense - if (!dir || strlen(dir) <= 0) + if (!dir || !dir[0]) return; - if (tag && strlen(tag) > 0) { + if (tag && tag[0]) { fExport = tag; fExport += " "; fExport += dir; } else @@ -65,13 +66,24 @@ XrdROOT::XrdROOT(const char *dir, const char *tag, const char *bindir, if (CheckDir(dir) != 0) return; fDir = dir; - // Include dir - fIncDir = incdir; - if (!incdir || strlen(incdir) <= 0) { - fIncDir = fDir; - fIncDir += "/include"; - } - if (CheckDir(fIncDir.c_str()) != 0) return; + auto setDir = [&](XrdOucString &target, const char *src, const char *subdir) -> bool { + target = src; + if (!src || !src[0]) { + target = fDir + subdir; + } + return CheckDir(target.c_str()) == 0; + }; + + if (!setDir(fIncDir, incdir, "/include")) + return; + if (!setDir(fLibDir, libdir, "/lib")) + return; + if (!setDir(fBinDir, bindir, "/bin")) + return; + if (!setDir(fDataDir, datadir, "")) + return; + if (!setDir(fEtcDir, etcdir, "/etc")) + return; // Parse version info if (ParseROOTVersionInfo() == -1) { @@ -82,29 +94,6 @@ XrdROOT::XrdROOT(const char *dir, const char *tag, const char *bindir, // Default tag is the version fTag = (!tag || strlen(tag) <= 0) ? fRelease : tag; - // Lib dir - fLibDir = libdir; - if (!libdir || strlen(libdir) <= 0) { - fLibDir = fDir; - fLibDir += "/lib"; - } - if (CheckDir(fLibDir.c_str()) != 0) return; - - // Bin dir - fBinDir = bindir; - if (!bindir || strlen(bindir) <= 0) { - fBinDir = fDir; - fBinDir += "/bin"; - } - if (CheckDir(fBinDir.c_str()) != 0) return; - - // Data dir - fDataDir = datadir; - if (!datadir || strlen(datadir) <= 0) { - fDataDir = fDir; - } - if (CheckDir(fDataDir.c_str()) != 0) return; - // The application to be run fPrgmSrv = fBinDir; fPrgmSrv += "/proofserv"; @@ -176,15 +165,33 @@ int XrdROOT::ParseROOTVersionInfo() // Version code must be there if (fVersionCode < 0) { - TRACE(XERR, "incomplete info found in "< 0) { XrdROOT *rootc = new XrdROOT(dir.c_str(), "", - bd.c_str(), id.c_str(), ld.c_str(), dd.c_str()); + bd.c_str(), id.c_str(), ld.c_str(), dd.c_str(), ed.c_str()); if (Validate(rootc, fMgr->Sched()) == 0) { XPDFORM(msg, "ROOT dist: '%s' validated", rootc->Export()); fROOT.push_back(rootc);