-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Summary
We currently have the following code:
Lines 16 to 38 in 9f250a0
| println!("cargo:rustc-env=RUSTPYTHON_GIT_HASH={}", git_hash()); | |
| println!( | |
| "cargo:rustc-env=RUSTPYTHON_GIT_TIMESTAMP={}", | |
| git_timestamp() | |
| ); | |
| println!("cargo:rustc-env=RUSTPYTHON_GIT_TAG={}", git_tag()); | |
| println!("cargo:rustc-env=RUSTPYTHON_GIT_BRANCH={}", git_branch()); | |
| println!("cargo:rustc-env=RUSTC_VERSION={}", rustc_version()); | |
| println!( | |
| "cargo:rustc-env=RUSTPYTHON_TARGET_TRIPLE={}", | |
| env::var("TARGET").unwrap() | |
| ); | |
| let mut env_path = PathBuf::from(env::var_os("OUT_DIR").unwrap()); | |
| env_path.push("env_vars.rs"); | |
| let mut f = std::fs::File::create(env_path).unwrap(); | |
| write!( | |
| f, | |
| "sysvars! {{ {} }}", | |
| std::env::vars_os().format_with(", ", |(k, v), f| f(&format_args!("{k:?} => {v:?}"))) | |
| ) | |
| .unwrap(); |
This changes the sysvars for every branch switch or git commit, even if you haven't changed anything in the source code.
this works fine, but the DX is bad because this forces a recompilation of the following crates:
vmstdlibrustpython
And I believe this is what is also affecting our CI cache.
Proposed solution
(depends on rust-lang/cargo#10271 being merged 🫤)
I suggest adding a new build profile called "dist" that can inherit from "release" and set a custom rustflag cfg like "dist_build", and adjusting the build.rs to use the dynamic values when #[cfg(dist_build)] and populate the fields with dummy static values when #[cfg(not(dist_build))]
That way we can still retain the existing behavior for the binaries provided by our release process, while improving the DX for the majority of time