Repository navigation
fix(build): escape regex metacharacters in unity build commands-dir match - #1281
Merged
Merged
Conversation
…atch
The unity build picked command sources with
ABS_SOURCE_FILE MATCHES "${COMMANDS_DIR}.*", building the pattern from
the literal source path. On checkouts under paths containing regex
metacharacters (e.g. D:\code\C++Files\...), the pattern cannot compile
(Nested *?+) and configure aborts with
"Regular expression ... cannot compile" at the unity-build if().
Escape the directory with string(REGEX REPLACE) before matching, so
paths with + . * ? ( ) [ ] ^ $ | and backslash match literally.
Verified on D:/code/C++Files/WinuxCmd: configure previously failed at
CMakeLists.txt:261; now the winuxcmd-commands target merges 176 command
files, the full build and unit suite run (3095/3097, the 2 failures
reproduce identically on the existing non-unity build).
1 of 3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
With
ENABLE_UNITY_BUILD=ON(default for RELEASE), the unity build selects command sources withABS_SOURCE_FILE MATCHES "${COMMANDS_DIR}.*", building the regex from the literal source path. When the checkout path contains regex metacharacters — e.g.D:\code\C++Files\WinuxCmd— the pattern cannot compile and configure aborts atCMakeLists.txt:261:This PR escapes
+ . * ? ( ) [ ] ^ $ |and backslash inCOMMANDS_DIRwithstring(REGEX REPLACE)before matching, so the directory matches literally (also covers paths likeProgram Files (x86)).Test plan
On
D:/code/C++Files/WinuxCmd(MSVC 14.44, CMake 4.3.3, Ninja):CMakeLists.txt:261with unity build onwinuxcmd-commandsmerges 176 command files; full build succeeds; unit suite 3097 tests pass (2 chown/mktemp cases fail only whenTMPis on a D: drive that rejects chown, identical on the non-unity build — environment, not this change)