Add eyra support as a feature (#728)

This commit is contained in:
Félix Saparelli 2023-12-13 14:08:03 +13:00 committed by GitHub
parent a72ff0e142
commit b4a64a096a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 261 additions and 18 deletions

246
Cargo.lock generated
View File

@ -193,7 +193,7 @@ dependencies = [
"futures-lite 2.0.1",
"parking",
"polling 3.3.1",
"rustix 0.38.25",
"rustix 0.38.28",
"slab",
"tracing",
"windows-sys 0.52.0",
@ -241,7 +241,7 @@ dependencies = [
"cfg-if",
"event-listener 3.1.0",
"futures-lite 1.13.0",
"rustix 0.38.25",
"rustix 0.38.28",
"windows-sys 0.48.0",
]
@ -268,7 +268,7 @@ dependencies = [
"cfg-if",
"futures-core",
"futures-io",
"rustix 0.38.25",
"rustix 0.38.28",
"signal-hook-registry",
"slab",
"windows-sys 0.48.0",
@ -501,6 +501,45 @@ version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223"
[[package]]
name = "c-gull"
version = "0.15.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6fcbafc70737ce8abca003fade0d703adaa6b4d6702151667db931f4d4b87fe"
dependencies = [
"c-scape",
"errno",
"libc",
"rustix 0.38.28",
"tz-rs",
]
[[package]]
name = "c-scape"
version = "0.15.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6253d853d2e58a600ca7c16b6a0d3d0c531d776360ac5ffd3bccffe93b82baa"
dependencies = [
"bitflags 2.4.1",
"errno",
"libc",
"libm",
"memoffset 0.9.0",
"num-complex",
"origin",
"posix-regex",
"printf-compat",
"rand",
"rand_core",
"rand_pcg",
"realpath-ext",
"rustix 0.38.28",
"rustix-dlmalloc",
"rustix-futex-sync",
"rustix-openpty",
"unwinding",
]
[[package]]
name = "cc"
version = "1.0.83"
@ -736,6 +775,22 @@ dependencies = [
"typenum",
]
[[package]]
name = "cstr_core"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd98742e4fdca832d40cab219dc2e3048de17d873248f83f17df47c1bea70956"
dependencies = [
"cty",
"memchr",
]
[[package]]
name = "cty"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35"
[[package]]
name = "deranged"
version = "0.3.9"
@ -880,6 +935,15 @@ dependencies = [
"syn 2.0.39",
]
[[package]]
name = "env_logger"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95b3f3e67048839cb0d0781f445682a35113da7121f7c949db0e2be96a4fbece"
dependencies = [
"log",
]
[[package]]
name = "equivalent"
version = "1.0.1"
@ -888,12 +952,12 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]]
name = "errno"
version = "0.3.7"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f258a7194e7f7c2a7837a8913aeab7fd8c383457034fa20ce4dd3dcb813e8eb8"
checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245"
dependencies = [
"libc",
"windows-sys 0.48.0",
"windows-sys 0.52.0",
]
[[package]]
@ -934,6 +998,15 @@ dependencies = [
"pin-project-lite",
]
[[package]]
name = "eyra"
version = "0.16.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a1a709c15a719374d2bfce0bd13487e045fdcc97c10d874503d48f1ac9ba8f7"
dependencies = [
"c-gull",
]
[[package]]
name = "faster-hex"
version = "0.8.1"
@ -1911,7 +1984,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b"
dependencies = [
"hermit-abi",
"rustix 0.38.25",
"rustix 0.38.28",
"windows-sys 0.48.0",
]
@ -1921,6 +1994,15 @@ version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "616cde7c720bb2bb5824a224687d8f77bfd38922027f01d825cd7453be5099fb"
[[package]]
name = "itertools"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b"
dependencies = [
"either",
]
[[package]]
name = "itertools"
version = "0.11.0"
@ -1977,6 +2059,12 @@ version = "0.2.150"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c"
[[package]]
name = "libm"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058"
[[package]]
name = "libmimalloc-sys"
version = "0.1.35"
@ -2087,6 +2175,15 @@ dependencies = [
"autocfg",
]
[[package]]
name = "memoffset"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c"
dependencies = [
"autocfg",
]
[[package]]
name = "miette"
version = "5.10.0"
@ -2179,7 +2276,7 @@ dependencies = [
"bitflags 1.3.2",
"cfg-if",
"libc",
"memoffset",
"memoffset 0.7.1",
]
[[package]]
@ -2258,6 +2355,15 @@ dependencies = [
"winapi",
]
[[package]]
name = "num-complex"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ba157ca0885411de85d6ca030ba7e2a83a28636056c7c699b07c8b6f7383214"
dependencies = [
"num-traits",
]
[[package]]
name = "num-traits"
version = "0.2.17"
@ -2265,6 +2371,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c"
dependencies = [
"autocfg",
"libm",
]
[[package]]
@ -2346,6 +2453,23 @@ dependencies = [
"pin-project-lite",
]
[[package]]
name = "origin"
version = "0.16.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7d9b3f29defd1880770d2ab032f0ed0f216e51bc4e509d164c1a63d3bd09dfd"
dependencies = [
"bitflags 2.4.1",
"env_logger",
"linux-raw-sys 0.4.11",
"log",
"memoffset 0.9.0",
"rustix 0.38.28",
"rustix-futex-sync",
"smallvec",
"unwinding",
]
[[package]]
name = "os_str_bytes"
version = "6.6.1"
@ -2519,11 +2643,17 @@ dependencies = [
"cfg-if",
"concurrent-queue",
"pin-project-lite",
"rustix 0.38.25",
"rustix 0.38.28",
"tracing",
"windows-sys 0.52.0",
]
[[package]]
name = "posix-regex"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0df8665cbe91ba9b18af9b0e7a36f02d00ce1123cf8d4b8a3a1104e932cdd341"
[[package]]
name = "powerfmt"
version = "0.2.0"
@ -2536,6 +2666,18 @@ version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
[[package]]
name = "printf-compat"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b002af28ffe3d3d67202ae717810a28125a494d5396debc43de01ee136ac404"
dependencies = [
"bitflags 1.3.2",
"cstr_core",
"cty",
"itertools 0.9.0",
]
[[package]]
name = "proc-macro-crate"
version = "1.3.1"
@ -2589,7 +2731,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efb6c9a1dd1def8e2124d17e83a20af56f1570d6c2d2bd9e266ccb768df3840e"
dependencies = [
"anyhow",
"itertools",
"itertools 0.11.0",
"proc-macro2",
"quote",
"syn 2.0.39",
@ -2662,6 +2804,26 @@ dependencies = [
"getrandom",
]
[[package]]
name = "rand_pcg"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59cad018caf63deb318e5a4586d99a24424a364f40f1e5778c29aca23f4fc73e"
dependencies = [
"rand_core",
]
[[package]]
name = "realpath-ext"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "692f72862a0d532b44a0f4965fb10f17e7659eaedf24d2ce3c989ca778bd092f"
dependencies = [
"bitflags 1.3.2",
"errno",
"libc",
]
[[package]]
name = "redox_syscall"
version = "0.3.5"
@ -2772,15 +2934,48 @@ dependencies = [
[[package]]
name = "rustix"
version = "0.38.25"
version = "0.38.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc99bc2d4f1fed22595588a013687477aedf3cdcfb26558c559edb67b4d9b22e"
checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316"
dependencies = [
"bitflags 2.4.1",
"errno",
"itoa",
"libc",
"linux-raw-sys 0.4.11",
"windows-sys 0.48.0",
"once_cell",
"windows-sys 0.52.0",
]
[[package]]
name = "rustix-dlmalloc"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0af789be2f2a6a302aedb487019503fd5b51af4cac7b30ed2590d16d05a0a2ea"
dependencies = [
"rustix 0.38.28",
"rustix-futex-sync",
]
[[package]]
name = "rustix-futex-sync"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fbf5fb8d04cb2409733689b671078896d4a79ebb34cee0b9067fa4e82e072484"
dependencies = [
"lock_api",
"rustix 0.38.28",
]
[[package]]
name = "rustix-openpty"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a25c3aad9fc1424eb82c88087789a7d938e1829724f3e4043163baf0d13cfc12"
dependencies = [
"errno",
"libc",
"rustix 0.38.28",
]
[[package]]
@ -3074,7 +3269,7 @@ dependencies = [
"cfg-if",
"fastrand 2.0.1",
"redox_syscall 0.4.1",
"rustix 0.38.25",
"rustix 0.38.28",
"windows-sys 0.48.0",
]
@ -3103,7 +3298,7 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7"
dependencies = [
"rustix 0.38.25",
"rustix 0.38.28",
"windows-sys 0.48.0",
]
@ -3463,6 +3658,12 @@ version = "1.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
[[package]]
name = "tz-rs"
version = "0.6.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33851b15c848fad2cf4b105c6bb66eb9512b6f6c44a4b13f57c53c73c707e2b4"
[[package]]
name = "uds_windows"
version = "1.0.2"
@ -3521,6 +3722,16 @@ version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"
[[package]]
name = "unwinding"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37a19a21a537f635c16c7576f22d0f2f7d63353c1337ad4ce0d8001c7952a25b"
dependencies = [
"gimli",
"libc",
]
[[package]]
name = "url"
version = "2.5.0"
@ -3695,6 +3906,7 @@ dependencies = [
"console-subscriber",
"dirs 5.0.1",
"embed-resource",
"eyra",
"futures",
"humantime",
"ignore-files",
@ -3817,7 +4029,7 @@ dependencies = [
"either",
"home",
"once_cell",
"rustix 0.38.25",
"rustix 0.38.28",
]
[[package]]
@ -3829,7 +4041,7 @@ dependencies = [
"either",
"home",
"once_cell",
"rustix 0.38.25",
"rustix 0.38.28",
"windows-sys 0.48.0",
]

View File

@ -45,6 +45,11 @@ optional = true
version = "4.4.7"
features = ["cargo", "derive", "env", "wrap_help"]
[dependencies.eyra]
version = "0.16.8"
features = ["log", "env_logger"]
optional = true
[dependencies.ignore-files]
version = "1.3.2"
path = "../ignore-files"
@ -112,6 +117,9 @@ path = "../bosion"
[features]
default = ["pid1"]
## Build using Eyra's pure-Rust libc
eyra = ["dep:eyra"]
## Enables PID1 handling.
pid1 = ["dep:pid1"]
@ -119,7 +127,7 @@ pid1 = ["dep:pid1"]
pid1-withlog = ["pid1"]
## For debugging only: enables the Tokio Console.
dev-console = ["console-subscriber"]
dev-console = ["dep:console-subscriber"]
[package.metadata.binstall]
pkg-url = "{ repo }/releases/download/v{ version }/watchexec-{ version }-{ target }.{ archive-format }"

View File

@ -179,3 +179,19 @@ If not bundled, you can generate a manual page with `watchexec --manual > /path/
You can also [read a text version](../../doc/watchexec.1.md).
Note that it is automatically generated from the help text, so it is not as pretty as a carefully hand-written one.
## Advanced builds
These are additional options available with custom builds by setting features:
### PID1
If you're using Watchexec as PID1 (most frequently in containers or namespaces), and it's not doing what you expect, you can create a build with PID1 early logging: `--features pid1-withlog`.
If you don't need PID1 support, or if you're doing something that conflicts with this program's PID1 support, you can disable it with `--no-default-features`.
### Eyra
[Eyra](https://github.com/sunfishcode/eyra) is a system to build Linux programs with no dependency on C code (in the libc path). To build Watchexec like this, use `--features eyra` and a Nightly compiler.
This feature also lets you get early logging into program startup, with `RUST_LOG=trace`.

View File

@ -1,4 +1,8 @@
fn main() {
embed_resource::compile("watchexec-manifest.rc", embed_resource::NONE);
bosion::gather();
if std::env::var("CARGO_FEATURE_EYRA").is_ok() {
println!("cargo:rustc-link-arg=-nostartfiles");
}
}

View File

@ -1,3 +1,6 @@
#[cfg(feature = "eyra")]
extern crate eyra;
use miette::IntoDiagnostic;
#[cfg(target_env = "musl")]