1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//! Discovery of the `trusty-embedderd` binary.
//!
//! Why: split out of `supervisor.rs` (#9828) to keep that file under the
//! 500-SLOC production cap once the recycle triggers landed there.
//! What: [`locate_embedderd_binary`] and its PATH helper, unchanged.
//! Test: `locate_binary_respects_explicit_override` in `supervisor_tests.rs`.
use PathBuf;
use Result;
/// Locate the `trusty-embedderd` binary for the current build profile.
///
/// Why: the default auto-spawn path needs to find the binary without requiring
/// the operator to set `TRUSTY_EMBEDDERD_BIN`. The search order is:
/// 1. `TRUSTY_EMBEDDERD_BIN` env var (explicit override)
/// 2. Sibling of `current_exe()` (release build: both binaries are in
/// `target/release/`)
/// 3. `trusty-embedderd` on `PATH`
///
/// What: returns the first path at which the file exists and is executable.
/// Returns `Err` if none is found.
///
/// Test: `locate_binary_respects_explicit_override` (the explicit override
/// path; the sibling and PATH tiers have no unit test).
/// Minimal `which`-style PATH search for `trusty-embedderd`.
///
/// Why: avoids adding a `which` crate dependency just for this one lookup.
/// What: splits `PATH` by OS separator, appends `trusty-embedderd` (+ `.exe`
/// on Windows), returns the first path that is_file().
/// Test: tested implicitly when the sibling-path lookup fails.