|
1 | | -//! Sanity checking performed by bootstrap before actually executing anything. |
| 1 | +//! Sanity checking and tool selection performed by bootstrap. |
2 | 2 | //! |
3 | | -//! This module contains the implementation of ensuring that the build |
4 | | -//! environment looks reasonable before progressing. This will verify that |
5 | | -//! various programs like git and python exist, along with ensuring that all C |
6 | | -//! compilers for cross-compiling are found. |
| 3 | +//! This module ensures that the build environment is correctly set up before |
| 4 | +//! executing any build tasks. It verifies that required programs exist (like |
| 5 | +//! git and cmake when needed), selects appropriate tools based on the environment |
| 6 | +//! and platform requirements (like choosing the correct Python interpreter), |
| 7 | +//! and validates that C compilers for cross-compiling are available. |
7 | 8 | //! |
8 | 9 | //! In theory if we get past this phase it's a bug if a build fails, but in |
9 | 10 | //! practice that's likely not true! |
@@ -165,15 +166,34 @@ than building it. |
165 | 166 | crate::exit!(1); |
166 | 167 | } |
167 | 168 |
|
168 | | - build.config.python = build |
169 | | - .config |
170 | | - .python |
171 | | - .take() |
172 | | - .map(|p| cmd_finder.must_have(p)) |
173 | | - .or_else(|| env::var_os("BOOTSTRAP_PYTHON").map(PathBuf::from)) // set by bootstrap.py |
174 | | - .or_else(|| cmd_finder.maybe_have("python")) |
175 | | - .or_else(|| cmd_finder.maybe_have("python3")) |
176 | | - .or_else(|| cmd_finder.maybe_have("python2")); |
| 169 | + // Select the Python interpreter to use throughout the build. |
| 170 | + // |
| 171 | + // On macOS, LLDB tests require the Python version the LLDB plugin was built for. |
| 172 | + // The system Python/LLDB are compatible, and many users install Homebrew Python |
| 173 | + // but not Homebrew LLVM, so we default to the system Python (/usr/bin/python3). |
| 174 | + // This can be overridden via the `build.python` config option for custom LLVM installations. |
| 175 | + // |
| 176 | + // On other platforms, we prefer the Python interpreter that invoked bootstrap.py |
| 177 | + // (available via the BOOTSTRAP_PYTHON env var), then fall back to searching PATH |
| 178 | + // for python, python3, or python2. |
| 179 | + build.config.python = if build.host_target.ends_with("apple-darwin") { |
| 180 | + build |
| 181 | + .config |
| 182 | + .python |
| 183 | + .take() |
| 184 | + .map(|p| cmd_finder.must_have(p)) |
| 185 | + .or_else(|| Some(PathBuf::from("/usr/bin/python3"))) |
| 186 | + } else { |
| 187 | + build |
| 188 | + .config |
| 189 | + .python |
| 190 | + .take() |
| 191 | + .map(|p| cmd_finder.must_have(p)) |
| 192 | + .or_else(|| env::var_os("BOOTSTRAP_PYTHON").map(PathBuf::from)) // set by bootstrap.py |
| 193 | + .or_else(|| cmd_finder.maybe_have("python")) |
| 194 | + .or_else(|| cmd_finder.maybe_have("python3")) |
| 195 | + .or_else(|| cmd_finder.maybe_have("python2")) |
| 196 | + }; |
177 | 197 |
|
178 | 198 | build.config.nodejs = build |
179 | 199 | .config |
|
0 commit comments