From 37f89080ba5ce1ddd7848d2029794a5f5aabb7be Mon Sep 17 00:00:00 2001 From: Rye Date: Thu, 23 Oct 2025 09:15:38 -0400 Subject: Introduce global precompiled header to accelerate build Signed-off-by: Rye --- indra/cmake/LLAddBuildTest.cmake | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'indra/cmake/LLAddBuildTest.cmake') diff --git a/indra/cmake/LLAddBuildTest.cmake b/indra/cmake/LLAddBuildTest.cmake index 83725ffd1b..4959051617 100644 --- a/indra/cmake/LLAddBuildTest.cmake +++ b/indra/cmake/LLAddBuildTest.cmake @@ -100,6 +100,10 @@ MACRO(LL_ADD_PROJECT_UNIT_TESTS project sources) ) endif(DARWIN) + if (USE_PRECOMPILED_HEADERS) + target_precompile_headers(PROJECT_${project}_TEST_${name} REUSE_FROM llprecompiled) + endif () + # # Per-codefile additional / external project dep and lib dep property extraction # @@ -122,7 +126,9 @@ MACRO(LL_ADD_PROJECT_UNIT_TESTS project sources) set_target_properties(PROJECT_${project}_TEST_${name} PROPERTIES COMPILE_FLAGS "${${name}_test_additional_CFLAGS}" - COMPILE_DEFINITIONS "LL_TEST=${name};LL_TEST_${name}") + COMPILE_DEFINITIONS "LL_TEST=${name};LL_TEST_${name}" + FOLDER "Tests" + ) if(LL_TEST_VERBOSE) message("LL_ADD_PROJECT_UNIT_TESTS ${name}_test_additional_CFLAGS ${${name}_test_additional_CFLAGS}") endif() @@ -217,6 +223,7 @@ FUNCTION(LL_ADD_INTEGRATION_TEST PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${EXE_STAGING_DIR}" COMPILE_DEFINITIONS "LL_TEST=${testname};LL_TEST_${testname}" + FOLDER "Tests" ) # The following was copied to llcorehttp/CMakeLists.txt's texture_load target. @@ -246,6 +253,11 @@ FUNCTION(LL_ADD_INTEGRATION_TEST target_link_libraries(INTEGRATION_TEST_${testname} ${libraries}) target_include_directories (INTEGRATION_TEST_${testname} PRIVATE ${LIBS_OPEN_DIR}/test ) + if (USE_PRECOMPILED_HEADERS) + target_include_directories (INTEGRATION_TEST_${testname} PRIVATE ${LIBS_OPEN_DIR}/llmath ) + target_precompile_headers(INTEGRATION_TEST_${testname} REUSE_FROM llprecompiled) + endif () + # Create the test running command set(test_command ${ARGN}) set(TEST_EXE $) -- cgit v1.3 From b66d6679b268069b155e7a0f5b843095a200a29f Mon Sep 17 00:00:00 2001 From: Rye Date: Thu, 23 Oct 2025 20:19:06 -0400 Subject: Run tests using ctest after all targets are built to reduce build contention Reuse test runner compilation unit to reduce extra source files compiled by 189 Only build macOS tests for build host architecture that will be running them to reduce wasted CI time Signed-off-by: Rye --- autobuild.xml | 40 +++++------- build.sh | 4 ++ indra/CMakeLists.txt | 26 ++++++++ indra/cmake/LLAddBuildTest.cmake | 41 +++++------- indra/cmake/Variables.cmake | 5 ++ indra/cmake/run_build_test.py | 2 +- .../llimage_libtest/CMakeLists.txt | 13 +++- .../integration_tests/llui_libtest/CMakeLists.txt | 14 +++- indra/llcorehttp/CMakeLists.txt | 7 ++ indra/test/CMakeLists.txt | 75 ++++++++++++++-------- 10 files changed, 151 insertions(+), 76 deletions(-) (limited to 'indra/cmake/LLAddBuildTest.cmake') diff --git a/autobuild.xml b/autobuild.xml index 85b3ea4e63..4dcb2e7d3a 100644 --- a/autobuild.xml +++ b/autobuild.xml @@ -3018,7 +3018,7 @@ Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors options -G - Unix Makefiles + Ninja build @@ -3076,7 +3076,7 @@ Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors options -G - Unix Makefiles + Ninja build @@ -3163,19 +3163,15 @@ Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors build command - msbuild.exe + cmake options - /p:Configuration=RelWithDebInfo - /p:Platform=${AUTOBUILD_WIN_VSPLATFORM|NOTWIN} - /t:Build - /p:useenv=true - /verbosity:minimal - /p:VCBuildAdditionalOptions= /incremental - - arguments - - SecondLife.sln + --build + . + --config + RelWithDebInfo + --parallel + $AUTOBUILD_CPU_COUNT name @@ -3237,19 +3233,15 @@ Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors build command - msbuild.exe + cmake options - /p:Configuration=Release - /p:Platform=${AUTOBUILD_WIN_VSPLATFORM|NOTWIN} - /t:Build - /p:useenv=true - /verbosity:minimal - /p:VCBuildAdditionalOptions= /incremental - - arguments - - SecondLife.sln + --build + . + --config + Release + --parallel + $AUTOBUILD_CPU_COUNT name diff --git a/build.sh b/build.sh index c9f366d64c..31604663f1 100755 --- a/build.sh +++ b/build.sh @@ -254,6 +254,10 @@ build() "$autobuild" build --no-configure -c $variant \ $eval_autobuild_build_parameters \ || fatal "failed building $variant" + + ctest -C Release --test-dir "${build_dir}" --output-on-failure -j $(nproc --all) \ + || fatal "failed testing $variant" + echo true >"$build_dir"/build_ok end_section "autobuild $variant" diff --git a/indra/CMakeLists.txt b/indra/CMakeLists.txt index a7f0ab0486..fb5cceb9ce 100644 --- a/indra/CMakeLists.txt +++ b/indra/CMakeLists.txt @@ -56,6 +56,32 @@ if (NOT CMAKE_BUILD_TYPE) "Build type. One of: Debug Release RelWithDebInfo" FORCE) endif (NOT CMAKE_BUILD_TYPE) +if (LL_TESTS) + set(CMAKE_SKIP_TEST_ALL_DEPENDENCY FALSE) + include(ProcessorCount) + ProcessorCount(NUM_CORES) + + # Set parallel level to decrease test runtime + set(CMAKE_CTEST_ARGUMENTS -j${NUM_CORES} --output-on-failure) + + # Set up our test targets + set(CTEST_TEST_TARGET_ALIAS BUILD_AND_RUN_TESTS) + include(CTest) + + set_target_properties(BUILD_AND_RUN_TESTS + PROPERTIES + FOLDER "CMakePredefinedTargets" + ) + + add_custom_target(BUILD_TESTS) + add_dependencies(BUILD_AND_RUN_TESTS BUILD_TESTS) + + set_target_properties(BUILD_TESTS + PROPERTIES + FOLDER "CMakePredefinedTargets" + ) +endif () + add_subdirectory(cmake) if (USE_PRECOMPILED_HEADERS) diff --git a/indra/cmake/LLAddBuildTest.cmake b/indra/cmake/LLAddBuildTest.cmake index 4959051617..bd2f894c97 100644 --- a/indra/cmake/LLAddBuildTest.cmake +++ b/indra/cmake/LLAddBuildTest.cmake @@ -1,4 +1,11 @@ # -*- cmake -*- + +include_guard() + +if( NOT LL_TESTS ) + return() +endif() + include(00-Common) include(LLTestCommand) include(bugsplat) @@ -26,8 +33,6 @@ MACRO(LL_ADD_PROJECT_UNIT_TESTS project sources) #project(UNITTEST_PROJECT_${project}) # Setup includes, paths, etc set(alltest_SOURCE_FILES - ${CMAKE_SOURCE_DIR}/test/test.cpp - ${CMAKE_SOURCE_DIR}/test/lltut.cpp ) set(alltest_DEP_TARGETS # needed by the test harness itself @@ -35,6 +40,7 @@ MACRO(LL_ADD_PROJECT_UNIT_TESTS project sources) ) set(alltest_LIBRARIES + lltut_runner_lib llcommon ) if(NOT "${project}" STREQUAL "llmath") @@ -137,6 +143,7 @@ MACRO(LL_ADD_PROJECT_UNIT_TESTS project sources) # test binaries always need to be signed for local development set_target_properties(PROJECT_${project}_TEST_${name} PROPERTIES + OSX_ARCHITECTURES ${LL_MACOS_TEST_ARCHITECTURE} XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "-") endif () @@ -159,24 +166,15 @@ MACRO(LL_ADD_PROJECT_UNIT_TESTS project sources) endif() # Add test - add_custom_command( - OUTPUT ${TEST_OUTPUT} + add_test( + NAME PROJECT_${project}_TEST_${name} COMMAND ${TEST_SCRIPT_CMD} - DEPENDS PROJECT_${project}_TEST_${name} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) - # Why not add custom target and add POST_BUILD command? - # Slightly less uncertain behavior - # (OUTPUT commands run non-deterministically AFAIK) + poppy 2009-04-19 - # > I did not use a post build step as I could not make it notify of a - # > failure after the first time you build and fail a test. - daveh 2009-04-20 + + add_dependencies(BUILD_TESTS PROJECT_${project}_TEST_${name}) list(APPEND ${project}_TEST_OUTPUT ${TEST_OUTPUT}) endforeach (source) - - # Add the test runner target per-project - # (replaces old _test_ok targets all over the place) - add_custom_target(${project}_tests ALL DEPENDS ${${project}_TEST_OUTPUT}) - add_dependencies(${project} ${project}_tests) ENDMACRO(LL_ADD_PROJECT_UNIT_TESTS) #***************************************************************************** @@ -204,12 +202,11 @@ FUNCTION(LL_ADD_INTEGRATION_TEST set(source_files tests/${testname}_test.cpp - ${CMAKE_SOURCE_DIR}/test/test.cpp - ${CMAKE_SOURCE_DIR}/test/lltut.cpp ${additional_source_files} ) set(libraries + lltut_runner_lib ${library_dependencies} ) @@ -239,6 +236,7 @@ FUNCTION(LL_ADD_INTEGRATION_TEST # test binaries always need to be signed for local development set_target_properties(INTEGRATION_TEST_${testname} PROPERTIES + OSX_ARCHITECTURES ${LL_MACOS_TEST_ARCHITECTURE} XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "-" BUILD_WITH_INSTALL_RPATH 1 INSTALL_RPATH "@executable_path/Resources" @@ -286,14 +284,9 @@ FUNCTION(LL_ADD_INTEGRATION_TEST message(STATUS "TEST_SCRIPT_CMD: ${TEST_SCRIPT_CMD}") endif() - add_custom_command( - TARGET INTEGRATION_TEST_${testname} - POST_BUILD - COMMAND ${TEST_SCRIPT_CMD} - ) + add_test(NAME INTEGRATION_TEST_RUNNER_${testname} COMMAND ${TEST_SCRIPT_CMD}) - # Use CTEST? Not sure how to yet... - # ADD_TEST(INTEGRATION_TEST_RUNNER_${testname} ${TEST_SCRIPT_CMD}) + add_dependencies(BUILD_TESTS INTEGRATION_TEST_${testname}) ENDFUNCTION(LL_ADD_INTEGRATION_TEST) diff --git a/indra/cmake/Variables.cmake b/indra/cmake/Variables.cmake index 2341d15a85..81a8f87cd3 100644 --- a/indra/cmake/Variables.cmake +++ b/indra/cmake/Variables.cmake @@ -198,6 +198,11 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set(CMAKE_XCODE_ATTRIBUTE_DISABLE_MANUAL_TARGET_ORDER_BUILD_WARNING YES) set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_64_TO_32_BIT_CONVERSION NO) set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "macOS Build Arch" FORCE) + if(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64") + set(LL_MACOS_TEST_ARCHITECTURE "arm64") + else() + set(LL_MACOS_TEST_ARCHITECTURE "x86_64") + endif() endif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") # Default deploy grid diff --git a/indra/cmake/run_build_test.py b/indra/cmake/run_build_test.py index 940a130a50..85689b361a 100755 --- a/indra/cmake/run_build_test.py +++ b/indra/cmake/run_build_test.py @@ -133,7 +133,7 @@ def main(command, arguments=[], libpath=[], vars={}): raise # In practice, the pathnames into CMake's build tree are so long as to # obscure the name of the test program. Just log its basename. - log.warn("No such program %s; check for preceding build errors" % \ + log.warning("No such program %s; check for preceding build errors" % \ os.path.basename(command[0])) # What rc should we simulate for missing executable? Windows produces # 9009. diff --git a/indra/integration_tests/llimage_libtest/CMakeLists.txt b/indra/integration_tests/llimage_libtest/CMakeLists.txt index e6ff142626..40837c8abb 100644 --- a/indra/integration_tests/llimage_libtest/CMakeLists.txt +++ b/indra/integration_tests/llimage_libtest/CMakeLists.txt @@ -9,7 +9,6 @@ include(00-Common) include(LLCommon) include(LLImage) include(LLMath) -include(LLKDU) set(llimage_libtest_SOURCE_FILES llimage_libtest.cpp @@ -26,6 +25,18 @@ add_executable(llimage_libtest ${llimage_libtest_SOURCE_FILES} ) +set_target_properties(llimage_libtest + PROPERTIES + FOLDER "Tests" + ) + +if(DARWIN) + set_target_properties(llimage_libtest + PROPERTIES + OSX_ARCHITECTURES ${LL_MACOS_TEST_ARCHITECTURE} + ) +endif() + # Libraries on which this application depends on # Sort by high-level to low-level target_link_libraries(llimage_libtest diff --git a/indra/integration_tests/llui_libtest/CMakeLists.txt b/indra/integration_tests/llui_libtest/CMakeLists.txt index a6ce657f4f..19ae1ae215 100644 --- a/indra/integration_tests/llui_libtest/CMakeLists.txt +++ b/indra/integration_tests/llui_libtest/CMakeLists.txt @@ -49,9 +49,14 @@ target_link_libraries(llui_libtest llimagej2coj ) +set_target_properties(llui_libtest + PROPERTIES + FOLDER "Tests" + ) + if (WINDOWS) set_target_properties(llui_libtest - PROPERTIES + PROPERTIES LINK_FLAGS "/NODEFAULTLIB:LIBCMT" ) @@ -66,6 +71,13 @@ if (WINDOWS) ) endif (WINDOWS) +if(DARWIN) + set_target_properties(llui_libtest + PROPERTIES + OSX_ARCHITECTURES ${LL_MACOS_TEST_ARCHITECTURE} + ) +endif() + # Ensure people working on the viewer don't break this library # *NOTE: This could be removed, or only built by Parabuild, if the build # and link times become too long. JC diff --git a/indra/llcorehttp/CMakeLists.txt b/indra/llcorehttp/CMakeLists.txt index 46503a8a4b..58bbdb2d9a 100644 --- a/indra/llcorehttp/CMakeLists.txt +++ b/indra/llcorehttp/CMakeLists.txt @@ -169,6 +169,13 @@ if (LL_TESTS AND LLCOREHTTP_TESTS) ) endif (WINDOWS) + if(DARWIN) + set_target_properties(http_texture_load + PROPERTIES + OSX_ARCHITECTURES ${LL_MACOS_TEST_ARCHITECTURE} + ) + endif() + target_link_libraries(http_texture_load ${example_libs}) endif (LL_TESTS AND LLCOREHTTP_TESTS) diff --git a/indra/test/CMakeLists.txt b/indra/test/CMakeLists.txt index f80286a630..a3cf762f90 100644 --- a/indra/test/CMakeLists.txt +++ b/indra/test/CMakeLists.txt @@ -10,6 +10,27 @@ include(Tut) include(LLAddBuildTest) include(bugsplat) +set(test_lib_SOURCE_FILES + lltut.cpp + test.cpp + ) + +set(test_lib_HEADER_FILES + CMakeLists.txt + lltut.h + ) + +list(APPEND test_lib_SOURCE_FILES ${test_lib_HEADER_FILES}) + +add_library(lltut_runner_lib ${test_lib_SOURCE_FILES}) + +target_link_libraries(lltut_runner_lib PRIVATE llcommon) + +set_target_properties(lltut_runner_lib + PROPERTIES + FOLDER "Tests" + ) + set(test_SOURCE_FILES io.cpp llapp_tut.cpp @@ -31,9 +52,7 @@ set(test_SOURCE_FILES llservicebuilder_tut.cpp llstreamtools_tut.cpp lltemplatemessagebuilder_tut.cpp - lltut.cpp message_tut.cpp - test.cpp ) set(test_HEADER_FILES @@ -57,6 +76,7 @@ list(APPEND test_SOURCE_FILES ${test_HEADER_FILES}) add_executable(lltest ${test_SOURCE_FILES}) target_link_libraries(lltest + lltut_runner_lib llinventory llmessage llmath @@ -66,14 +86,27 @@ target_link_libraries(lltest llcorehttp ) +set_target_properties(lltest + PROPERTIES + FOLDER "Tests" + ) + if (WINDOWS) set_target_properties(lltest - PROPERTIES + PROPERTIES LINK_FLAGS "/NODEFAULTLIB:LIBCMT" LINK_FLAGS_DEBUG "/NODEFAULTLIB:\"LIBCMT;LIBCMTD;MSVCRT\"" RUNTIME_OUTPUT_DIRECTORY "${EXE_STAGING_DIR}" ) elseif (DARWIN) + set_target_properties(lltut_runner_lib + PROPERTIES + OSX_ARCHITECTURES ${LL_MACOS_TEST_ARCHITECTURE} + ) + set_target_properties(lltest + PROPERTIES + OSX_ARCHITECTURES ${LL_MACOS_TEST_ARCHITECTURE} + ) # Support our "@executable_path/../Resources" load path for our test # executable. This SHOULD properly be "$/Resources", # but the CMake $ generator expression isn't evaluated by @@ -82,32 +115,24 @@ elseif (DARWIN) SYMBOLIC) endif (WINDOWS) -set(TEST_EXE $) - -SET_TEST_PATH(LD_LIBRARY_PATH) +# This should cause the test executable to be built, but not +# run if LL_TESTS is disabled. This will hopefully keep the +# tests up to date with any code changes changes even if +# developers choose to disable LL_TESTS. +if (LL_TESTS) + set(TEST_EXE $) -LL_TEST_COMMAND(command - "${LD_LIBRARY_PATH}" - "${TEST_EXE}" - "--output=${CMAKE_CURRENT_BINARY_DIR}/cpp_test_results.txt" - "--touch=${CMAKE_CURRENT_BINARY_DIR}/cpp_tests_ok.txt") + SET_TEST_PATH(LD_LIBRARY_PATH) -ADD_CUSTOM_COMMAND( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cpp_tests_ok.txt - COMMAND ${command} - DEPENDS lltest - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMENT "C++ unit tests" - ) + LL_TEST_COMMAND(command + "${LD_LIBRARY_PATH}" + "${TEST_EXE}" + "--output=${CMAKE_CURRENT_BINARY_DIR}/cpp_test_results.txt" + "--touch=${CMAKE_CURRENT_BINARY_DIR}/cpp_tests_ok.txt") -set(test_results ${CMAKE_CURRENT_BINARY_DIR}/cpp_tests_ok.txt) + add_test(NAME "C++ unit tests" COMMAND ${command} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) -# This should cause the test executable to be built, but not -# run if LL_TESTS is disabled. This will hopefully keep the -# tests up to date with any code changes changes even if -# developers choose to disable LL_TESTS. -if (LL_TESTS) - add_custom_target(tests_ok ALL DEPENDS ${test_results}) + add_dependencies(BUILD_TESTS lltest) if(DARWIN) # Support our "@executable_path/../Resources" load path for our test # executable. This SHOULD properly be "$/Resources", -- cgit v1.3