build: Limit recursion to speed up configuration in slow filesystems with many files

This commit is contained in:
Gabriel Ferreira
2024-06-11 17:52:17 +02:00
parent 0d051e6705
commit 55abe1f10a
3 changed files with 27 additions and 8 deletions

View File

@@ -168,8 +168,20 @@ function(scan_python_examples path)
return()
endif()
# Search for python examples
file(GLOB_RECURSE python_examples ${path}/*.py)
# Search for example scripts in the directory and its immediate children
# directories
set(python_examples)
file(GLOB examples_subdirs LIST_DIRECTORIES TRUE ${path}/*)
foreach(subdir ${path} ${examples_subdirs})
if(NOT (IS_DIRECTORY ${subdir}))
continue()
endif()
file(GLOB python_examples_subdir ${subdir}/*.py)
list(APPEND python_examples ${python_examples_subdir})
endforeach()
# Add example scripts to the list
list(REMOVE_DUPLICATES python_examples)
foreach(python_example ${python_examples})
if(NOT (${python_example} MATCHES "examples-to-run"))
set(ns3-execs-py "${python_example};${ns3-execs-py}"

View File

@@ -320,10 +320,17 @@ macro(process_options)
if("${CMAKE_FORMAT_PROGRAM}" STREQUAL "CMAKE_FORMAT_PROGRAM-NOTFOUND")
message(${HIGHLIGHTED_STATUS} "Proceeding without cmake-format")
else()
file(GLOB_RECURSE MODULES_CMAKE_FILES src/**/CMakeLists.txt
contrib/**/CMakeLists.txt examples/**/CMakeLists.txt
scratch/**/CMakeLists.txt
file(
GLOB
MODULES_CMAKE_FILES
src/**/CMakeLists.txt
contrib/**/CMakeLists.txt
src/**/examples/CMakeLists.txt
contrib/**/examples/CMakeLists.txt
examples/**/CMakeLists.txt
scratch/**/CMakeLists.txt
)
file(GLOB_RECURSE SCRATCH_CMAKE_FILES scratch/**/CMakeLists.txt)
file(
GLOB
INTERNAL_CMAKE_FILES
@@ -342,7 +349,7 @@ macro(process_options)
COMMAND
${CMAKE_FORMAT_PROGRAM} -c
${PROJECT_SOURCE_DIR}/build-support/cmake-format-modules.yaml -i
${MODULES_CMAKE_FILES}
${MODULES_CMAKE_FILES} ${SCRATCH_CMAKE_FILES}
)
add_custom_target(
cmake-format-check

4
ns3
View File

@@ -657,7 +657,7 @@ def remove_file(file_to_remove, dry_run):
def clean_cmake_artifacts(dry_run=False):
remove_dir(out_dir, dry_run, "output")
cmake_cache_files = glob.glob("%s/**/CMakeCache.txt" % ns3_path, recursive=True)
cmake_cache_files = glob.glob("%s/**/CMakeCache.txt" % ns3_path)
for cmake_cache_file in cmake_cache_files:
dirname = os.path.dirname(cmake_cache_file)
remove_dir(dirname, dry_run, "CMake cache")
@@ -707,7 +707,7 @@ def clean_vcpkg_artifacts(dry_run=False):
def search_cmake_cache(build_profile):
# Search for the CMake cache
cmake_cache_files = glob.glob("%s/**/CMakeCache.txt" % ns3_path, recursive=True)
cmake_cache_files = glob.glob("%s/**/CMakeCache.txt" % ns3_path)
current_cmake_cache_folder = None
current_cmake_generator = None