-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathbuild.rs
40 lines (35 loc) · 1.33 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use std::path::PathBuf;
use std::{env, fs};
fn main() {
build_pc();
}
fn build_pc() {
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
let target_path = out_path.join("../../..");
let target_triple = env::var("TARGET").unwrap();
// macOS or iOS
let libs_priv = if target_triple.contains("apple") || target_triple.contains("darwin") {
// TODO: verify all these are needed
// "-framework SystemConfiguration -framework Security -framework Foundation"
"-framework SystemConfiguration"
} else {
""
};
let pkg_config = format!(
include_str!("iroh.pc.in"),
name = "iroh",
description = env::var("CARGO_PKG_DESCRIPTION").unwrap(),
url = env::var("CARGO_PKG_HOMEPAGE").unwrap_or_else(|_| "".to_string()),
version = env::var("CARGO_PKG_VERSION").unwrap(),
libs_priv = libs_priv,
prefix = env::var("PREFIX").unwrap_or_else(|_| "/usr/local".to_string()),
libdir = env::var("LIBDIR").unwrap_or_else(|_| "/usr/local/lib".to_string()),
includedir = env::var("INCLUDEDIR").unwrap_or_else(|_| "/usr/local/include".to_string()),
);
fs::create_dir_all(target_path.join("pkgconfig")).unwrap();
fs::write(
target_path.join("pkgconfig").join("iroh.pc"),
pkg_config.as_bytes(),
)
.unwrap();
}