-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.rs
37 lines (34 loc) · 1.05 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
use std::env;
use std::process::Command;
fn main() {
let use_dll = cfg!(target_env = "msvc");
let out_dir = env::var("OUT_DIR").unwrap();
let out_name = if use_dll {
"esbuild.dll"
} else {
// This is the name on Windows as well because we use the gnu toolchain.
"libesbuild.a"
};
Command::new("go")
.current_dir("lib")
.arg("build")
.arg("-mod=vendor")
.arg(if use_dll {
"-buildmode=c-shared"
} else {
"-buildmode=c-archive"
})
.arg("-o")
.arg(format!("{}/{}", out_dir, out_name))
.arg("vendor/github.com/evanw/esbuild/pkg/ffiapi/ffiapi.go")
.status()
.expect("compile Go library");
if !use_dll {
println!("cargo:rustc-link-search=native={}", out_dir);
println!("cargo:rustc-link-lib=static=esbuild");
if cfg!(target_os = "macos") {
println!("cargo:rustc-link-lib=framework=CoreFoundation");
println!("cargo:rustc-link-lib=framework=Security");
};
};
}