From c1f6c7d19ecb7d3bb8447b59542c9da5b8a5be45 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Wed, 7 Oct 2020 05:41:16 +0000 Subject: [PATCH] doc: extract_content.py: support multiple build directories Exclude (other) build directories with a CMakeCache.txt file as they typically contain previous output from ourselves. One key feature of 'out of source" builds offered by CMake is allowing multiple build directories. For instance to build different configurations without starting from scratch. Unfortunately, the extract_content.py code had a severe issue with multiple build directories with an interesting effect on build times, see simple reproduction below: cd doc/ cmake -B _build/ cmake -B _b2 # Repeat these a couple times make -C _build content make -C _b2 content find -name rst ./_b2/rst ./_b2/rst/doc/_build/rst ./_b2/rst/doc/_build/rst/doc/_b2/rst ./_b2/rst/doc/_build/rst/doc/_b2/rst/doc/_build/rst Signed-off-by: Marc Herbert --- doc/scripts/extract_content.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/scripts/extract_content.py b/doc/scripts/extract_content.py index fdf3b5c327e..d638e8a987f 100755 --- a/doc/scripts/extract_content.py +++ b/doc/scripts/extract_content.py @@ -125,6 +125,11 @@ def find_content(zephyr_base, src, dest, fnfilter, ignore, src_root): dirnames[:] = [d for d in dirnames if not path.normpath(path.join(dirpath, d)).startswith(ignore)] + # Exclude (other) build directories. They may contain previous + # output from ourselves! + dirnames[:] = [d for d in dirnames if not + path.exists(path.join(dirpath, d, 'CMakeCache.txt'))] + # If the current directory contains no matching files, keep going. sources = fnmatch.filter(filenames, fnfilter) if not sources: