Files
RustPython/crates/stdlib/build.rs
Copilot d5921d16af Create rustpython-host-env (#7582)
* Create rustpython-host-env crate; move host abstractions out of common

Move os, crt_fd, fileutils, windows, macros modules from
rustpython-common into the new rustpython-host-env crate.
This isolates host OS API wrappers behind a crate boundary
with zero Python runtime dependency.

- Add crates/host_env to workspace
- Drop nix, windows-sys, widestring deps from common
- Wire vm and stdlib to depend on rustpython-host-env
- Migrate all imports from common::{os,crt_fd,fileutils,windows}
  to rustpython_host_env::

* refactor: extract host helpers

Agent-Logs-Url: https://github.com/RustPython/RustPython/sessions/48d1e64d-37ce-409f-b511-8e61a349665c

Co-authored-by: youknowone <69878+youknowone@users.noreply.github.com>

* lint: enforce direct host API boundaries

Agent-Logs-Url: https://github.com/RustPython/RustPython/sessions/97225fb7-7b3d-4197-a77c-eb44aead5b13

Co-authored-by: youknowone <69878+youknowone@users.noreply.github.com>

* refactor: extract remaining host env helpers

Agent-Logs-Url: https://github.com/RustPython/RustPython/sessions/d96f57e1-b196-4460-9983-97d5ff118835

Co-authored-by: youknowone <69878+youknowone@users.noreply.github.com>

* fix: clean extracted host env follow-up

Agent-Logs-Url: https://github.com/RustPython/RustPython/sessions/d96f57e1-b196-4460-9983-97d5ff118835

Co-authored-by: youknowone <69878+youknowone@users.noreply.github.com>

* fix: document env mutation safety

Agent-Logs-Url: https://github.com/RustPython/RustPython/sessions/d96f57e1-b196-4460-9983-97d5ff118835

Co-authored-by: youknowone <69878+youknowone@users.noreply.github.com>

* refactor: split host fs helpers from fileutils

Agent-Logs-Url: https://github.com/RustPython/RustPython/sessions/c57424c5-0e1d-490a-82b3-2d2f6c8cf2cd

Co-authored-by: youknowone <69878+youknowone@users.noreply.github.com>

* fix: resolve latest host env ci regressions

Agent-Logs-Url: https://github.com/RustPython/RustPython/sessions/899eb717-ebc6-4a4a-870c-2a15c5f33e02

Co-authored-by: youknowone <69878+youknowone@users.noreply.github.com>

* fix: resolve remaining windows clippy host fs calls

Agent-Logs-Url: https://github.com/RustPython/RustPython/sessions/12f32740-8173-4b10-a1d6-00b29e90a8ec

Co-authored-by: youknowone <69878+youknowone@users.noreply.github.com>

* host_env

---------

Co-authored-by: Jeong, YunWon <jeong@youknowone.org>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: youknowone <69878+youknowone@users.noreply.github.com>
2026-04-21 00:13:25 +09:00

62 lines
2.1 KiB
Rust

#![allow(
clippy::disallowed_methods,
reason = "build scripts cannot use rustpython-host_env"
)]
// spell-checker:ignore ossl osslconf
fn main() {
println!(r#"cargo::rustc-check-cfg=cfg(osslconf, values("OPENSSL_NO_COMP"))"#);
println!(r#"cargo::rustc-check-cfg=cfg(openssl_vendored)"#);
#[allow(
clippy::unusual_byte_groupings,
reason = "hex groups follow OpenSSL version field boundaries"
)]
let ossl_vers = [
(0x1_00_01_00_0, "ossl101"),
(0x1_00_02_00_0, "ossl102"),
(0x1_01_00_00_0, "ossl110"),
(0x1_01_00_07_0, "ossl110g"),
(0x1_01_00_08_0, "ossl110h"),
(0x1_01_01_00_0, "ossl111"),
(0x1_01_01_04_0, "ossl111d"),
(0x3_00_00_00_0, "ossl300"),
(0x3_01_00_00_0, "ossl310"),
(0x3_02_00_00_0, "ossl320"),
(0x3_03_00_00_0, "ossl330"),
];
for (_, cfg) in ossl_vers {
println!("cargo::rustc-check-cfg=cfg({cfg})");
}
#[cfg(feature = "ssl-openssl")]
{
#[allow(
clippy::unusual_byte_groupings,
reason = "OpenSSL version number is parsed with grouped hex fields"
)]
if let Ok(v) = std::env::var("DEP_OPENSSL_VERSION_NUMBER") {
println!("cargo:rustc-env=OPENSSL_API_VERSION={v}");
// cfg setup from openssl crate's build script
let version = u64::from_str_radix(&v, 16).unwrap();
for (ver, cfg) in ossl_vers {
if version >= ver {
println!("cargo:rustc-cfg={cfg}");
}
}
}
if let Ok(v) = std::env::var("DEP_OPENSSL_CONF") {
for conf in v.split(',') {
println!("cargo:rustc-cfg=osslconf=\"{conf}\"");
}
}
// it's possible for openssl-sys to link against the system openssl under certain conditions,
// so let the ssl module know to only perform a probe if we're actually vendored
if std::env::var("DEP_OPENSSL_VENDORED").is_ok_and(|s| s == "1") {
println!("cargo::rustc-cfg=openssl_vendored")
}
}
}