Allow to build without vendored openssl, allow to build syntect with regex-onig (#1323)

* allow to build syntect with regex-onig

Syntect supports two regex engines:

* regex-fancy: a pure-rust regex engine based on the fancy-regex
* regex-onig: a regex engine based on the oniguruma C library

From the syntect's Readme:

> The advantage of fancy-regex is that it does not require the onig
> crate which requires building and linking the Oniguruma C library.
> Many users experience difficulty building the onig crate, especially
> on Windows and Webassembly.

> As far as our tests can tell this new engine is just as correct, but
> it hasn't been tested as extensively in production. It also currently
> seems to be about half the speed of the default Oniguruma engine

Oniguruma engine is faster than the fancy-regex engine and the syntect
project chose the latter as the default only to avoid difficulties with
linking Oniguruma (C library) on some platforms. This is not an issue
for linux distributions - linking against system-provided shared
library is preferred to bundled libraries.

Moreover, gitui built with Oniguruma instead of fancy-regex is by 25%
smaller.

This commit adds two cargo features, regex-fancy and regex-onig, to
enable respective syntect features. The former is enabled by default.

* allow to build without vendored openssl

Vendoring (bundling) openssl library is very bad for security and
Linux distributions forbid it. The aim of this change is to simplify
packaging gitui in linux distros.

Co-authored-by: extrawurst <776816+extrawurst@users.noreply.github.com>
This commit is contained in:
Jakub Jirutka 2022-09-18 15:02:01 +02:00 committed by GitHub
parent f2b2665c78
commit f69460cccf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 3 deletions

View file

@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* use filewatcher instead of polling updates ([#1](https://github.com/extrawurst/gitui/issues/1))
* word motions to text input [[@Rodrigodd](https://github.com/Rodrigodd)] ([#1256](https://github.com/extrawurst/gitui/issues/1256))
* file blame at right revision from commit-details [[@heiskane](https://github.com/heiskane)] ([#1122](https://github.com/extrawurst/gitui/issues/1122))
* add `regex-fancy` and `regex-onig` features to allow building Syntect with Onigumara regex engine instead of the default engine based on fancy-regex [[@jirutka](https://github.com/jirutka)]
* add `vendor-openssl` feature to allow building without vendored openssl [[@jirutka](https://github.com/jirutka)]
### Fixes
* remove insecure dependency `ansi_term` ([#1290](https://github.com/extrawurst/gitui/issues/1290))

23
Cargo.lock generated
View file

@ -1106,6 +1106,28 @@ version = "1.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f7254b99e31cad77da24b08ebf628882739a608578bb1bcdfc1f9c21260d7c0"
[[package]]
name = "onig"
version = "6.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c4b31c8722ad9171c6d77d3557db078cab2bd50afcc9d09c8b315c59df8ca4f"
dependencies = [
"bitflags",
"libc",
"once_cell",
"onig_sys",
]
[[package]]
name = "onig_sys"
version = "69.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b829e3d7e9cc74c7e315ee8edb185bf4190da5acde74afd7fc59c35b1f086e7"
dependencies = [
"cc",
"pkg-config",
]
[[package]]
name = "openssl-probe"
version = "0.1.5"
@ -1621,6 +1643,7 @@ dependencies = [
"fnv",
"lazy_static",
"once_cell",
"onig",
"regex-syntax",
"serde",
"serde_derive",

View file

@ -46,7 +46,7 @@ scopeguard = "1.1"
scopetime = { path = "./scopetime", version = "0.1" }
serde = "1.0"
simplelog = { version = "0.12", default-features = false }
syntect = { version = "5.0", default-features = false, features = ["parsing", "default-syntaxes", "default-themes", "html", "regex-fancy"] }
syntect = { version = "5.0", default-features = false, features = ["parsing", "default-syntaxes", "default-themes", "html"] }
textwrap = "0.15"
tui = { version = "0.19", default-features = false, features = ['crossterm', 'serde'] }
unicode-segmentation = "1.10"
@ -65,10 +65,14 @@ pretty_assertions = "1.3"
maintenance = { status = "actively-developed" }
[features]
default =["ghemoji", "trace-libgit"]
default =["ghemoji", "regex-fancy", "trace-libgit", "vendor-openssl"]
ghemoji =["gh-emoji"]
# regex-* features are mutually exclusive.
regex-fancy = ["syntect/regex-fancy"]
regex-onig = ["syntect/regex-onig"]
timing =["scopetime/enabled"]
trace-libgit =["asyncgit/trace-libgit"]
vendor-openssl = ["asyncgit/vendor-openssl"]
[workspace]
members =[

View file

@ -19,7 +19,7 @@ log = "0.4"
# git2 = { path = "../../extern/git2-rs", features = ["vendored-openssl"]}
# git2 = { git="https://github.com/extrawurst/git2-rs.git", rev="fc13dcc", features = ["vendored-openssl"]}
# pinning to vendored openssl, using the git2 feature this gets lost with new resolver
openssl-sys = { version = '0.9', features = ["vendored"] }
openssl-sys = { version = '0.9', features = ["vendored"], optional = true }
rayon-core = "1.9"
scopetime = { path = "../scopetime", version = "0.1" }
shellexpand = "2.1"
@ -37,3 +37,4 @@ tempfile = "3.2"
[features]
default = ["trace-libgit"]
trace-libgit = []
vendor-openssl = ["openssl-sys"]