roc/roc_std/build.rs
Richard Feldman 60be120fc1 Rename COPYRIGHT_DETAILS to LEGAL_DETAILS
Turns out GitHub's `Licensee` gem treats any file with the word
"copyright" in it as a potential license, and therefore doesn't
recognize and list Roc's license as UPL-1.0 because it thinks
there might be two licenses or something.

d274e47c71/lib/licensee/project_files/license_file.rb (L26)
2021-04-22 21:52:07 -04:00

51 lines
1.4 KiB
Rust

// Adapted from https://github.com/TheDan64/scoped_alloca
// by Daniel Kolsoi - license information can be found in
// the LEGAL_DETAILS file in the root directory of this distribution.
//
// Thank you, Dan!
use std::env;
use std::fs::create_dir;
use std::path::Path;
use std::process::Command;
fn main() {
let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
let cargo_dir = Path::new(manifest_dir.as_str());
let lib_dir = cargo_dir.join("lib");
let alloca_c = cargo_dir.join("src/alloca.c");
let alloca_o = lib_dir.join("alloca.o");
let liballoca_a = lib_dir.join("liballoca.a");
println!("cargo:rustc-link-search=native={}", lib_dir.display());
// No need to recompile alloca static lib every time. We could
// add a feature flag to do so if needed, though
if liballoca_a.is_file() {
return;
}
if !lib_dir.is_dir() {
create_dir(&lib_dir).unwrap();
}
let clang_output = Command::new("clang")
.arg("-c")
.arg(alloca_c)
.arg("-o")
.arg(&alloca_o)
.output()
.expect("Could not execute clang");
assert!(clang_output.status.success(), "{:?}", clang_output);
let ar_output = Command::new("ar")
.arg("-q")
.arg(liballoca_a)
.arg(alloca_o)
.output()
.expect("Could not execute ar");
assert!(ar_output.status.success(), "{:?}", ar_output);
}