Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion scripts/extract_configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ def parse_configure_trace(
e = json.loads(line)
except json.JSONDecodeError:
continue
if e.get("cmd") != "configure_file":
# CMake command names are case-insensitive, and the trace reports
# the spelling used in the CMakeLists (large projects commonly
# write CONFIGURE_FILE); match either.
if (e.get("cmd") or "").lower() != "configure_file":
continue
args = [a for a in e.get("args", []) if a]
if len(args) < 2:
Expand Down
21 changes: 21 additions & 0 deletions tests/test_configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,27 @@ def test_options_captured():
assert cfs[0].options == ("@ONLY",)


def test_uppercase_command_spelling_is_matched():
# CMake commands are case-insensitive and the trace keeps the spelling the
# CMakeLists used; CONFIGURE_FILE and Configure_File are the same command.
upper = dict(_cf(f"{SRC}/my_config.h.cmake", f"{BUILD}/my_config.h"),
cmd="CONFIGURE_FILE")
mixed = dict(_cf(f"{SRC}/version.h.in", f"{BUILD}/version.h"),
cmd="Configure_File")
t = _trace(upper, mixed, _cf(f"{SRC}/zconf.h.cmakein", f"{BUILD}/zconf.h"))
cfs = parse_configure_trace(t, SRC, BUILD, include_dirs=[BUILD])
os.unlink(t)
assert sorted(c.name for c in cfs) == ["my_config.h", "version.h", "zconf.h"]


def test_other_commands_are_ignored():
t = _trace({"cmd": "file", "args": ["WRITE", f"{BUILD}/x.h", "y"]},
{"cmd": "CONFIGURE_FILE_EXTRA", "args": [f"{SRC}/a.in", f"{BUILD}/a.h"]})
cfs = parse_configure_trace(t, SRC, BUILD, include_dirs=[BUILD])
os.unlink(t)
assert cfs == []


def test_no_include_dirs_means_not_compile_input():
# without include dirs we cannot assert compile-input status -> False (we do
# not guess); the file is still recorded.
Expand Down
Loading