main
Add repeatable --preserve options for binary clearing so install prefixes survive removal of shorter source and build paths. Match text replacements against the original input and retain paths already under the replacement root. This prevents expanded path forms and repeated cleanup passes from rewriting an installed path again. Add regression coverage for binary prefix preservation, overlapping path forms, and repeated replacement. Document the supported behavior. Validation: all 21 CTest tests pass, including both new regressions.
strclear
strclear removes or replaces embedded strings in files. BRL-CAD uses it
when staging third party dependencies, primarily to remove build-time paths
from binaries and to rewrite paths in text metadata such as CMake package files
and pkg-config files.
Supported modes:
strclear -B <file>classifies one file. It returns0for binary input and1for text input, matching the historical BRL-CAD CMake contract.strclear --classify [--files <list> | <file> ...]emits one JSON Lines record per input path:{"type":"TEXT","path":"..."}or{"type":"BINARY","path":"..."}.strclear [-v] <file> <target> [replacement]rewrites one file. Binary files clear matching bytes to NUL by default; text files replacetargetwithreplacement, or removetargetif no replacement is supplied.strclear [-v] --files <list> <target> [replacement]applies the same operation to each path listed in the file.--text-onlyskips binary inputs, and--binary-onlyskips text inputs.-pexpands a filesystem path target into common path forms before matching. Text replacement matches the original input once, using the longest matching form. It preserves paths already under the replacement root, so replacing a parent directory with a nested install root is safe to repeat. The replacement keeps the spelling supplied on the command line, including symlink aliases.--preserve <string>protects matching byte ranges during binary clearing. It requires-bor--binary-only, may be repeated, and expands preserved paths when used with-p. This keeps install prefixes intact when clearing shorter build or source paths from the same binary.-b -cand-rare accepted for compatibility with existing BRL-CAD CMake logic.-b -cforces binary clearing, and-rforces text replacement.
The --classify output is intentionally JSONL so build systems can parse it
without ambiguous path escaping rules.
Description
Utility for clearing/replacing strings in binary and text files
https://brlcad.org/
109 KiB
0 Stars
3 Watchers
0 Forks
Languages
C++
79.1%
CMake
20.9%