MCPcopy Index your code
hub / github.com/RustPython/RustPython / main

Function main

crates/vm/build.rs:4–39  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2use std::{env, io::prelude::*, path::PathBuf, process::Command};
3
4fn main() {
5 let frozen_libs = if cfg!(feature = "freeze-stdlib") {
6 "Lib/*/*.py"
7 } else {
8 "Lib/python_builtins/*.py"
9 };
10 for entry in glob::glob(frozen_libs).expect("Lib/ exists?").flatten() {
11 let display = entry.display();
12 println!("cargo:rerun-if-changed={display}");
13 }
14 println!("cargo:rerun-if-changed=../../Lib/importlib/_bootstrap.py");
15
16 println!("cargo:rustc-env=RUSTPYTHON_GIT_HASH={}", git_hash());
17 println!(
18 "cargo:rustc-env=RUSTPYTHON_GIT_TIMESTAMP={}",
19 git_timestamp()
20 );
21 println!("cargo:rustc-env=RUSTPYTHON_GIT_TAG={}", git_tag());
22 println!("cargo:rustc-env=RUSTPYTHON_GIT_BRANCH={}", git_branch());
23 println!("cargo:rustc-env=RUSTC_VERSION={}", rustc_version());
24
25 println!(
26 "cargo:rustc-env=RUSTPYTHON_TARGET_TRIPLE={}",
27 env::var("TARGET").unwrap()
28 );
29
30 let mut env_path = PathBuf::from(env::var_os("OUT_DIR").unwrap());
31 env_path.push("env_vars.rs");
32 let mut f = std::fs::File::create(env_path).unwrap();
33 write!(
34 f,
35 "sysvars! {{ {} }}",
36 std::env::vars_os().format_with(", ", |(k, v), f| f(&format_args!("{k:?} => {v:?}")))
37 )
38 .unwrap();
39}
40
41fn git_hash() -> String {
42 git(&["rev-parse", "--short", "HEAD"])

Callers

nothing calls this directly

Calls 6

globFunction · 0.85
createFunction · 0.50
flattenMethod · 0.45
displayMethod · 0.45
unwrapMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected