crosvm/sandbox/build.rs
Vikram Auradkar 44a07970cb sandbox: upstream sandbox
The crate depends on a prebuilt library.

BUG=b:213170185
TEST=presubmit

Change-Id: I810baa14afa53e88f6b2a739481a6d3656efc2e5
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3784338
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-10-12 21:05:39 +00:00

52 lines
1.6 KiB
Rust

// Copyright 2022 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
static PREBUILTS_VERSION_FILENAME: &str = "prebuilts_version";
static SANDBOX_LIB: &str = "libsandbox.lib";
static BINDINGS_FILE: &str = "bindings.rs";
pub fn setup_windows_prebuilts() {
println!("cargo:rustc-link-lib=dbghelp");
println!("cargo:rustc-link-lib=gdi32");
println!("cargo:rustc-link-lib=oleaut32");
println!("cargo:rustc-link-lib=setupapi");
println!("cargo:rustc-link-lib=shell32");
println!("cargo:rustc-link-lib=user32");
println!("cargo:rustc-link-lib=winmm");
if std::env::var("CARGO_CFG_DEBUG_ASSERTIONS").is_ok() {
println!("cargo:rustc-link-lib=ucrtd");
}
println!("cargo:rustc-link-lib=libsandbox");
println!("cargo:rerun-if-changed={}", BINDINGS_FILE);
}
fn main() {
if std::env::var("CARGO_CFG_WINDOWS").is_ok() {
let version = std::fs::read_to_string(PREBUILTS_VERSION_FILENAME)
.unwrap()
.trim()
.parse::<u32>()
.unwrap();
// TODO(b:253039132) build sandbox prebuilts locally on windows from build.rs.
let files = prebuilts::download_prebuilts("sandbox", version, &[SANDBOX_LIB]).unwrap();
println!(
r#"cargo:rustc-link-search={};{}"#,
std::env::var("PATH").unwrap(),
files
.get(0)
.unwrap()
.parent()
.unwrap()
.as_os_str()
.to_str()
.unwrap()
);
setup_windows_prebuilts();
}
}