Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions nym-vpn-core/crates/nym-wg-go/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,29 @@
use std::{env, fs, path::PathBuf};

fn main() {
let manifest_path = env::var_os("CARGO_MANIFEST_DIR").expect("manifest dir is not set");
let target = env::var("TARGET").expect("target is not set");
let target_os = env::var("CARGO_CFG_TARGET_OS").expect("target os is not set");

let build_dir = PathBuf::from(manifest_path).join("../../../build/lib");
// Support BUILD_TOP for sandbox builds where the source directory is read-only.
// Falls back to the traditional relative path from CARGO_MANIFEST_DIR.
let build_dir = if let Ok(build_top) = env::var("BUILD_TOP") {
PathBuf::from(build_top).join("build/lib")
} else {
let manifest_path = env::var_os("CARGO_MANIFEST_DIR").expect("manifest dir is not set");
let build_dir = PathBuf::from(manifest_path).join("../../../build/lib");

// canonicalize() will fail if the build directory does not exist
if !build_dir.exists() {
fs::create_dir_all(&build_dir).expect("failed to create build dir");
}
// canonicalize() will fail if the build directory does not exist
if !build_dir.exists() {
fs::create_dir_all(&build_dir).expect("failed to create build dir");
}

let mut build_dir = build_dir
.canonicalize()
.expect("failed to canonicalize build dir path");
build_dir
.canonicalize()
.expect("failed to canonicalize build dir path")
};

build_dir.push(target);
let mut build_dir = build_dir;
build_dir.push(&target);

// CI may only provide universal builds
if target_os == "macos" {
Expand Down
Loading