Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Makefile & compat/pcre2: add ability to build an embedded PCRE
Add a USE_LIBPCRE2_BUNDLED=YesIHaveNoPackagedVersion flag to the Makefile. If enabled we'll use the PCRE v2 shipped in compat/pcre2, instead of trying to find it via -lpcre2-8 on the installed system. As covered in a previous commits ("grep: add support for PCRE v2", 2017-04-08) there are major benefits to using a bleeding edge PCRE v2, but more importantly I'd like to experiment with making PCRE a mandatory dependency to power various internal features of grep/log without the user being aware that they're using the library under the hood, similar to how we use kwset now for fixed-string searches. Imposing that hard dependency on everyone using git would bother a lot of people, whereas if git itself ships PCRE it's no more bothersome than the code using kwset, i.e. it can be invisible to the builder & user, and even allow git to target newer PCRE APIs (or parts of the API, e.g. pattern conversion) without worrying about versioning. See [1] for a mostly one-sided pcre-dev mailing list thread discussing how embed the library. Implementation details: * I configured PCRE v2 with ./configure --enable-jit --enable-utf * It sets a lot of -DHAVE_* but these are used by the subset of the files I copied, many are either unused or only used by pcre2test.c which isn't brought in by the script. * These -DHAVE_* flags are something we have already by default & assume in other git.git code, so it should be fine to define it. * -DPCRE2_CODE_UNIT_WIDTH=8 only compiles the functions linking to -lpcre2-8 would have gotten us. * All the limits / sizes are the PCRE defaults, the MATCH_LIMIT_RECURSION define is a synonym for MATCH_LIMIT_DEPTH in older versions, it allows building against older (currently release) versions of the library. * -DNEWLINE_DEFAULT=2 means only \n is recognized as a newline. This corresponds to the --enable-newline-is-lf option. It's also possible to set this to CR, CRLF, any of CR, LF, or CRLF, or any Unicode newline character being recognized as \n. This *might* have to be customized on Windows, but I think the grep machinery always splits on newlines for us already, so this probably works on Windows as-is, but needs testing. 1. https://lists.exim.org/lurker/thread/20170507.223619.fbee8f00.en.html Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Loading branch information