mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-24 20:48:55 +00:00
01da29a398
The build.rs file will be compiled for the host platform and cfg() flags will reflect those of the host platform and not of the build target. Use CARGO_CFG_ environment variables instead. BUG=b:240593511 TEST=CQ Change-Id: Ib8b6c8e8bfb44ad83212bb2aa40a17a4e16a4adf Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4518569 Commit-Queue: Dennis Kempin <denniskempin@google.com> Reviewed-by: Vikram Auradkar <auradkar@google.com>
44 lines
1.3 KiB
Rust
44 lines
1.3 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.
|
|
|
|
use std::env;
|
|
|
|
static PREBUILTS_VERSION_FILENAME: &str = "prebuilts_version";
|
|
static R8BRAIN_LIB: &str = "r8Brain.lib";
|
|
static R8BRAIN_DLL: &str = "r8Brain.dll";
|
|
static UCRTBASE_DLL: &str = "ucrtbased.dll";
|
|
static VCRUNTIME_DLL: &str = "vcruntime140d.dll";
|
|
|
|
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 prebuilts locally on windows from build.rs.
|
|
let files = prebuilts::download_prebuilts(
|
|
"r8brain",
|
|
version,
|
|
&[R8BRAIN_DLL, R8BRAIN_LIB, UCRTBASE_DLL, VCRUNTIME_DLL],
|
|
)
|
|
.unwrap();
|
|
let lib_dir = files
|
|
.get(0)
|
|
.unwrap()
|
|
.parent()
|
|
.unwrap()
|
|
.as_os_str()
|
|
.to_str()
|
|
.unwrap();
|
|
println!("cargo:rustc-link-lib=r8Brain");
|
|
println!(r#"cargo:rustc-link-search={}"#, lib_dir);
|
|
println!(
|
|
r#"cargo:rustc-env=PATH={};{}"#,
|
|
lib_dir,
|
|
env::var("PATH").unwrap(),
|
|
);
|
|
}
|
|
}
|