2022-09-13 17:55:17 +00:00
|
|
|
// Copyright 2022 The ChromiumOS Authors
|
2022-06-07 20:55:59 +00:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2022-10-17 21:24:42 +00:00
|
|
|
use std::env;
|
|
|
|
|
|
|
|
static PREBUILTS_VERSION_FILENAME: &str = "prebuilts_version";
|
|
|
|
static R8BRAIN_LIB: &str = "r8Brain.lib";
|
|
|
|
static R8BRAIN_DLL: &str = "r8Brain.dll";
|
|
|
|
#[cfg(windows)]
|
|
|
|
static UCRTBASE_DLL: &str = "ucrtbased.dll";
|
|
|
|
#[cfg(windows)]
|
|
|
|
static VCRUNTIME_DLL: &str = "vcruntime140d.dll";
|
|
|
|
|
2022-06-07 20:55:59 +00:00
|
|
|
fn main() {
|
2022-10-17 21:24:42 +00:00
|
|
|
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,
|
|
|
|
#[cfg(windows)]
|
|
|
|
UCRTBASE_DLL,
|
|
|
|
#[cfg(windows)]
|
|
|
|
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(),
|
|
|
|
);
|
2022-06-07 20:55:59 +00:00
|
|
|
}
|
|
|
|
}
|