MCPcopy Create free account
hub / github.com/Nariod/RustPacker / compile_locally

Function compile_locally

src/compiler.rs:113–142  ·  view source on GitHub ↗
(path_to_cargo_folder: &Path)

Source from the content-addressed store, hash-verified

111}
112
113fn compile_locally(path_to_cargo_folder: &Path) -> Result<(), Box<dyn std::error::Error>> {
114 let target = local_build_target();
115 let manifest = path_to_cargo_folder.join("Cargo.toml");
116 let mut cmd = Command::new("cargo");
117
118 if cfg!(not(target_os = "windows")) {
119 cmd.env("CFLAGS", "-lrt");
120 cmd.env("LDFLAGS", "-lrt");
121 }
122
123 let output = cmd
124 .env("RUSTFLAGS", "-C target-feature=+crt-static")
125 .args(["build", "--release", "--manifest-path"])
126 .arg(&manifest)
127 .args(["--target", target])
128 .output()?;
129
130 if !output.status.success() {
131 let err = String::from_utf8_lossy(&output.stderr);
132 eprintln!("{}", err);
133 return Err(format!("Compilation failed: {}", output.status).into());
134 }
135
136 if !output.stderr.is_empty() {
137 let warnings = String::from_utf8_lossy(&output.stderr);
138 println!("{}", warnings);
139 }
140
141 Ok(())
142}
143
144fn run_compiler(path_to_cargo_folder: &Path) -> Result<(), Box<dyn std::error::Error>> {
145 if is_running_in_container() {

Callers 1

run_compilerFunction · 0.85

Calls 1

local_build_targetFunction · 0.85

Tested by

no test coverage detected