Skip to content

Commit

Permalink
Merge pull request #601 from bartlettroscoe/597-config-git-version-in…
Browse files Browse the repository at this point in the history
…fo-rab

Should be final commits for Git version parent info PR #598 (#597)
  • Loading branch information
bartlettroscoe authored Jan 25, 2024
2 parents ba7e8da + 548a0b9 commit da80610
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 55 deletions.
2 changes: 2 additions & 0 deletions test/core/ExamplesUnitTests/TribitsHelloWorld_Tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ tribits_add_advanced_test( TribitsHelloWorld_config_git_version_single_repo_one_
-DTribitsHelloWorld_TRIBITS_DIR=${${PROJECT_NAME}_TRIBITS_DIR}
-DTribitsHelloWorld_ENABLE_TESTS=ON
-DTribitsHelloWorld_GENERATE_REPO_VERSION_FILE=ON
-DTribitsHelloWorld_TRACE_DEPENDENCY_HANDLING_ONLY=ON
-DGIT_EXECUTABLE=${${PROJECT_NAME}_TRIBITS_DIR}/python_utils/mockprogram.py
../TribitsHelloWorld
PASS_REGULAR_EXPRESSION_ALL
Expand Down Expand Up @@ -122,6 +123,7 @@ tribits_add_advanced_test( TribitsHelloWorld_config_git_version_single_repo_two_
-DTribitsHelloWorld_TRIBITS_DIR=${${PROJECT_NAME}_TRIBITS_DIR}
-DTribitsHelloWorld_ENABLE_TESTS=ON
-DTribitsHelloWorld_GENERATE_REPO_VERSION_FILE=ON
-DTribitsHelloWorld_TRACE_DEPENDENCY_HANDLING_ONLY=ON
-DTribitsHelloWorld_SHOW_GIT_COMMIT_PARENTS=ON
-DGIT_EXECUTABLE=${${PROJECT_NAME}_TRIBITS_DIR}/python_utils/mockprogram.py
../TribitsHelloWorld
Expand Down
5 changes: 3 additions & 2 deletions test/ctest_driver/TribitsExampleMetaProject/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ tribits_add_advanced_test( CTestDriver_TribitsExMetaProj_clone_default_branch_re
${COMMON_ENV_ARGS}
TribitsExMetaProj_ENABLE_SECONDARY_TESTED_CODE=TRUE
CTEST_BUILD_NAME=CTestDriver_TribitsExMetaProj_clone_default_branch_remote
TribitsExMetaProj_EXTRA_CONFIGURE_OPTIONS=-DTribitsExMetaProj_SHOW_GIT_COMMIT_PARENTS=ON
CTEST_SITE=CustomSite
${CTEST_S_SCRIPT_ARGS}
PASS_REGULAR_EXPRESSION_ALL
Expand Down Expand Up @@ -262,7 +263,7 @@ tribits_add_advanced_test( CTestDriver_TribitsExMetaProj_clone_default_branch_re
TEST_8
MESSAGE "Make sure that the file TribitsExMetaProjRepoVersion.txt is correct"
CMND diff ARGS
"${CMAKE_CURRENT_LIST_DIR}/data/TribitsExMetaProjRepoVersion.for-testing.txt"
"${CMAKE_CURRENT_LIST_DIR}/data/TribitsExMetaProjRepoVersion.for-testing.with-parents.txt"
BUILD/TribitsExMetaProjRepoVersion.txt
ALWAYS_FAIL_ON_NONZERO_RETURN

Expand Down Expand Up @@ -320,7 +321,7 @@ tribits_add_advanced_test( CTestDriver_TribitsExMetaProj_clone_default_branch_re
TEST_12
MESSAGE "Make sure that the file TribitsExMetaProjRepoVersion.txt is correct"
CMND diff ARGS
"${CMAKE_CURRENT_LIST_DIR}/data/TribitsExMetaProjRepoVersion.for-testing.txt"
"${CMAKE_CURRENT_LIST_DIR}/data/TribitsExMetaProjRepoVersion.for-testing.with-parents.txt"
BUILD/TribitsExMetaProjRepoVersion.txt
ALWAYS_FAIL_ON_NONZERO_RETURN

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
*** Base Git Repo: TribitsExMetaProj
863461e [Tue Sep 14 15:05:31 2021 -0600] <[email protected]>
Merge branch 'tribits-github-snapshot' (TriBITSPub/TriBITS#299)
*** Parent 1:
e12aad9 [Fri Dec 11 16:17:18 2020 -0700] <[email protected]>
Merge branch 'tribits-github-snapshot' (TriBITSPub/TriBITS#309)
*** Parent 2:
ed38a1f [Tue Sep 14 15:04:06 2021 -0600] <[email protected]>
Automatic snapshot commit from TribitsExampleMetaProject at d1e4913
*** Git Repo: TribitsExampleProject
94c2b12 [Tue Sep 14 15:18:55 2021 -0600] <[email protected]>
Merge branch 'tribits-github-snapshot' (TriBITSPub/TriBITS#299)
*** Parent 1:
59c7057 [Fri Dec 11 16:23:46 2020 -0700] <[email protected]>
Merge branch 'tribits-github-snapshot'
*** Parent 2:
da4197f [Tue Sep 14 15:11:39 2021 -0600] <[email protected]>
Automatic snapshot commit from TribitsExampleProject at d95ddbd
*** Git Repo: TribitsExampleProjectAddons
d846ae1 [Tue Sep 14 15:23:39 2021 -0600] <[email protected]>
Merge branch 'tribits-github-snapshot' (TriBITSPub/TriBITS#299)
*** Parent 1:
226a17e [Tue Feb 19 06:33:23 2019 -0700] <[email protected]>
Update README file (tribitspub/tribits#278)
*** Parent 2:
08f06bb [Tue Sep 14 15:20:24 2021 -0600] <[email protected]>
Automatic snapshot commit from TribitsExampleProjectAddons at abb6694
68 changes: 26 additions & 42 deletions tribits/core/package_arch/TribitsGlobalMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@

# Standard TriBITS system includes

include("${CMAKE_CURRENT_LIST_DIR}/../utils/TribitsGitRepoVersionInfo.cmake")

include("${CMAKE_CURRENT_LIST_DIR}/../common/TribitsConstants.cmake")

include("${CMAKE_CURRENT_LIST_DIR}/../test_support/TribitsTestCategories.cmake")
Expand All @@ -53,7 +55,6 @@ include(TribitsGetVersionDate)
include(TribitsReportInvalidTribitsUsage)
include(TribitsReadAllProjectDepsFilesCreateDepsGraph)
include(TribitsAdjustPackageEnables)
include(TribitsGitRepoVersionInfo)
include(TribitsSetUpEnabledOnlyDependencies)
include(TribitsConfigureTiming)

Expand Down Expand Up @@ -685,13 +686,8 @@ macro(tribits_define_global_options_and_define_extra_repos)
CACHE BOOL
"Generate the ${PROJECT_NAME}RepoVersion.txt file.")

if ("${${PROJECT_NAME}_SHOW_GIT_COMMIT_PARENTS_DEFAULT}" STREQUAL "")
set(${PROJECT_NAME}_SHOW_GIT_COMMIT_PARENTS_DEFAULT OFF)
endif()
advanced_set(${PROJECT_NAME}_SHOW_GIT_COMMIT_PARENTS
${${PROJECT_NAME}_SHOW_GIT_COMMIT_PARENTS_DEFAULT}
CACHE BOOL
"Show parents' commit info in the repo version output.")
tribits_advanced_set_cache_var_and_default(${PROJECT_NAME}_SHOW_GIT_COMMIT_PARENTS
BOOL OFF "Show parents' commit info in the repo version output.")

if ("${${PROJECT_NAME}_GENERATE_VERSION_DATE_FILES_DEFAULT}" STREQUAL "")
set(${PROJECT_NAME}_GENERATE_VERSION_DATE_FILES_DEFAULT OFF)
Expand Down Expand Up @@ -1215,53 +1211,41 @@ endmacro()

# Get the versions of all the git repos
#
function(tribits_generate_repo_version_file_string PROJECT_REPO_VERSION_FILE_STRING_OUT)
function(tribits_generate_repo_version_file_string projectRepoVersionFileStrOut)

set(REPO_VERSION_FILE_STR "")
set(projectRepoVersionFileStr "")

if (${${PROJECT_NAME}_SHOW_GIT_COMMIT_PARENTS})
tribits_generate_single_repo_version_string(
${CMAKE_CURRENT_SOURCE_DIR}
SINGLE_REPO_VERSION INCLUDE_COMMIT_PARENTS)
else()
tribits_generate_single_repo_version_string(
${CMAKE_CURRENT_SOURCE_DIR} SINGLE_REPO_VERSION)
endif()
string(APPEND REPO_VERSION_FILE_STR
tribits_generate_single_repo_version_string(
${CMAKE_CURRENT_SOURCE_DIR} singleRepoVersionStr
INCLUDE_COMMIT_PARENTS ${${PROJECT_NAME}_SHOW_GIT_COMMIT_PARENTS})
string(APPEND projectRepoVersionFileStr
"*** Base Git Repo: ${PROJECT_NAME}\n"
"${SINGLE_REPO_VERSION}\n" )
"${singleRepoVersionStr}\n" )

set(EXTRAREPO_IDX 0)
foreach(EXTRA_REPO ${${PROJECT_NAME}_ALL_EXTRA_REPOSITORIES})

#print_var(EXTRA_REPO)
#print_var(EXTRAREPO_IDX)
#print_var(${PROJECT_NAME}_ALL_EXTRA_REPOSITORIES_DIRS)
set(extraRepoIdx 0)
foreach(extraRepo ${${PROJECT_NAME}_ALL_EXTRA_REPOSITORIES})

if (${PROJECT_NAME}_ALL_EXTRA_REPOSITORIES_DIRS)
# Read from an extra repo file with potentially different dir.
list(GET ${PROJECT_NAME}_ALL_EXTRA_REPOSITORIES_DIRS ${EXTRAREPO_IDX}
EXTRAREPO_DIR )
list(GET ${PROJECT_NAME}_ALL_EXTRA_REPOSITORIES_DIRS ${extraRepoIdx}
extraRepoDir )
else()
# Not read from extra repo file so dir is same as name
set(EXTRAREPO_DIR ${EXTRA_REPO})
set(extraRepoDir ${extraRepo})
endif()
#print_var(EXTRAREPO_DIR)

tribits_generate_single_repo_version_string(
"${CMAKE_CURRENT_SOURCE_DIR}/${EXTRAREPO_DIR}"
SINGLE_REPO_VERSION)
string(APPEND REPO_VERSION_FILE_STR
"*** Git Repo: ${EXTRAREPO_DIR}\n"
"${SINGLE_REPO_VERSION}\n" )

#print_var(REPO_VERSION_FILE_STR)
"${CMAKE_CURRENT_SOURCE_DIR}/${extraRepoDir}" singleRepoVersionStr
INCLUDE_COMMIT_PARENTS ${${PROJECT_NAME}_SHOW_GIT_COMMIT_PARENTS})
string(APPEND projectRepoVersionFileStr
"*** Git Repo: ${extraRepoDir}\n"
"${singleRepoVersionStr}\n" )

math(EXPR EXTRAREPO_IDX "${EXTRAREPO_IDX}+1")
math(EXPR extraRepoIdx "${extraRepoIdx}+1")

endforeach()

set(${PROJECT_REPO_VERSION_FILE_STRING_OUT} ${REPO_VERSION_FILE_STR} PARENT_SCOPE)
set(${projectRepoVersionFileStrOut} ${projectRepoVersionFileStr} PARENT_SCOPE)

endfunction()

Expand All @@ -1273,17 +1257,17 @@ endfunction()
#
function(tribits_generate_repo_version_output_and_file)
# Get the repos versions
tribits_generate_repo_version_file_string(PROJECT_REPO_VERSION_FILE_STRING)
tribits_generate_repo_version_file_string(projectRepoVersionFileStr)
# Print the versions
message("\n${PROJECT_NAME} repos versions:\n"
"--------------------------------------------------------------------------------\n"
"${PROJECT_REPO_VERSION_FILE_STRING}"
"${projectRepoVersionFileStr}"
" --------------------------------------------------------------------------------\n"
)
#) Write out the version file
file(WRITE
"${CMAKE_CURRENT_BINARY_DIR}/${${PROJECT_NAME}_REPO_VERSION_FILE_NAME}"
"${PROJECT_REPO_VERSION_FILE_STRING}")
"${projectRepoVersionFileStr}")
endfunction()


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,16 @@ function(tribits_git_repo_sha1 gitRepoDir gitRepoSha1Out)
endfunction()


# @FUNCTION: tribits_generate_single_repo_version_string
# @FUNCTION: tribits_generate_single_repo_version_string()
#
# Get the formatted string containing the current git repo version.
#
# Usage:
#
# tribits_generate_single_repo_version_string(<gitRepoDir>
# <repoVersionStringOut> INCLUDE_PARENT_COMMITS [ON|OFF])
# <repoVersionStringOut> [INCLUDE_PARENT_COMMITS ON|OFF])
#
# If the optional argument ``INCLUDE_PARENT_COMMITS`` is passed,
# If the optional argument ``INCLUDE_PARENT_COMMITS <val>`` is passed,
# then the head commit's parent(s) info will be be included in
# the repo version output string formatted.
#
Expand All @@ -124,8 +124,8 @@ function(tribits_generate_single_repo_version_string gitRepoDir
)

cmake_parse_arguments( PARSE_ARGV 2
PARSE "INCLUDE_COMMIT_PARENTS" # prefix, optional
"" "" # one_value_keywords, multi_value_keyword
PARSE "" # prefix, optional
"INCLUDE_COMMIT_PARENTS" "" # one_value_keywords, multi_value_keyword
)
tribits_check_for_unparsed_arguments()
tribits_assert_parse_arg_zero_or_one_value(PARSE INCLUDE_COMMIT_PARENTS)
Expand Down
2 changes: 1 addition & 1 deletion tribits/ctest_driver/TribitsAddDashboardTarget.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#
################################################################################

include(TribitsGitRepoVersionInfo)
include("${CMAKE_CURRENT_LIST_DIR}/../core/utils/TribitsGitRepoVersionInfo.cmake")

#
# Macro that drives a experimental 'dashboard' target
Expand Down
10 changes: 5 additions & 5 deletions tribits/ctest_driver/TribitsCTestDriverCore.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -669,11 +669,11 @@ include(TribitsCTestDriverCoreHelpers)
# **Setting variables in the inner CMake configure:**
#
# It is important to understand that none of the CMake vars that get set in
# the other CTest -S program that calls ``tribits_ctest_driver()``
# the outer CTest -S program that calls ``tribits_ctest_driver()``
# automatically get passed into the inner configure of the TriBITS CMake
# project using the ``ctest_configure()`` command by CMake. From the
# perspective of raw CTest and CMake, these are completely separate programs.
# However, the ``tribits_ctest_driver()`` function will forward subset of
# However, the ``tribits_ctest_driver()`` function will forward subset a of
# variables documented below into the inner CMake configure. The following
# variables that are set in the outer CTest -S program will be passed into the
# inner CMake configure by default (but their values they can be overridden by
Expand All @@ -684,7 +684,7 @@ include(TribitsCTestDriverCoreHelpers)
#
# Missing extra repos are always ignored in the inner CMake configure.
# This is because any problems reading an extra repo will be caught in the
# outer CTest -S drivers script.
# outer CTest -S driver script.
#
# ``-D${PROJECT_NAME}_ENABLE_ALL_OPTIONAL_PACKAGES:BOOL=ON``
#
Expand All @@ -699,7 +699,7 @@ include(TribitsCTestDriverCoreHelpers)
# may be disabled. (This set may be removed in the future for the
# all-at-once mode.)
#
# The following variables set in the CTest -S driver script will be passed
# The following variables set in the outer CTest -S driver script will be passed
# down into the inner CMake configure through the ``OPTIONS`` variable to the
# ``ctest_configure()`` command:
#
Expand Down Expand Up @@ -758,7 +758,7 @@ include(TribitsCTestDriverCoreHelpers)
# These configure options are passed into the ``ctest_configure()`` command in
# the order::
#
# <initial options> ${EXTRA_SYSTEM_CONFIGURE_OPTIONS}} \
# <initial options> ${EXTRA_SYSTEM_CONFIGURE_OPTIONS}} \
# ${EXTRA_CONFIGURE_OPTIONS} ${${PROJECT_NAME}_EXTRA_CONFIGURE_OPTIONS}
#
# **WARNING:** The options listed in ``EXTRA_SYSTEM_CONFIGURE_OPTIONS``,
Expand Down
17 changes: 17 additions & 0 deletions tribits/doc/build_ref/TribitsBuildReferenceBody.rst
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ See the following use cases:
* `Enable all packages (and optionally all tests)`_
* `Disable a package and all its dependencies`_
* `Remove all package enables in the cache`_
* `Speed up debugging dependency handling`_


Determine the list of packages that can be enabled
Expand Down Expand Up @@ -656,6 +657,22 @@ For example, one would want to do this to avoid more expensive compiler and
TPL checks.


Speed up debugging dependency handling
+++++++++++++++++++++++++++++++++++++++

To speed up debugging the package enable/disable dependency handling, set the
cache variable::

-D <Project>_TRACE_DEPENDENCY_HANDLING_ONLY=ON

This will result in only performing the package enable/disable dependency
handling logic and tracing what would be done to configure the compilers and
configure the various enabled packages but not actually do that work. This
can greatly speed up the time to complete the ``cmake`` configure command when
debugging the dependency handling (or when creating tests that check that
behavior).


Selecting compiler and linker options
-------------------------------------

Expand Down
16 changes: 16 additions & 0 deletions tribits/doc/guides/TribitsCoreDetailedReference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ a given TriBITS project are:
* `${PROJECT_NAME}_MUST_FIND_ALL_TPL_LIBS`_
* `${PROJECT_NAME}_REQUIRES_PYTHON`_
* `${PROJECT_NAME}_SET_INSTALL_RPATH`_
* `${PROJECT_NAME}_SHOW_GIT_COMMIT_PARENTS`_
* `${PROJECT_NAME}_SHOW_TEST_START_END_DATE_TIME`_
* `${PROJECT_NAME}_SKIP_INSTALL_PROJECT_CMAKE_CONFIG_FILES`_
* `${PROJECT_NAME}_TEST_CATEGORIES`_
Expand Down Expand Up @@ -651,6 +652,21 @@ These options are described below.
Handling`_).


.. _${PROJECT_NAME}_SHOW_GIT_COMMIT_PARENTS:

**${PROJECT_NAME}_SHOW_GIT_COMMIT_PARENTS**

The cache variable ``${PROJECT_NAME}_SHOW_GIT_COMMIT_PARENTS`` results in
the repo version file showing the parent commits for each repo commit. By
default, this variable is set to ``OFF`` but projects can set to to ``ON``
by default by setting::

set(${PROJECT_NAME}_SHOW_GIT_COMMIT_PARENTS_DEFAULT ON)

in the project's ``ProjectName.cmake`` file. (That way, it will also impact
``cmake -P`` scripts don't configure the project itself to be built.)


.. _${PROJECT_NAME}_SHOW_TEST_START_END_DATE_TIME:

**${PROJECT_NAME}_SHOW_TEST_START_END_DATE_TIME**
Expand Down

0 comments on commit da80610

Please sign in to comment.