1 // Copyright 2022 The ChromiumOS Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 use std::env;
6
7 static PREBUILTS_VERSION_FILENAME: &str = "prebuilts_version";
8 static R8BRAIN_LIB: &str = "r8Brain.lib";
9 static R8BRAIN_DLL: &str = "r8Brain.dll";
10 static UCRTBASE_DLL: &str = "ucrtbased.dll";
11 static VCRUNTIME_DLL: &str = "vcruntime140d.dll";
12
main()13 fn main() {
14 if std::env::var("CARGO_CFG_WINDOWS").is_ok() {
15 let version = std::fs::read_to_string(PREBUILTS_VERSION_FILENAME)
16 .unwrap()
17 .trim()
18 .parse::<u32>()
19 .unwrap();
20
21 // TODO(b:253039132) build prebuilts locally on windows from build.rs.
22 let files = prebuilts::download_prebuilts(
23 "r8brain",
24 version,
25 &[R8BRAIN_DLL, R8BRAIN_LIB, UCRTBASE_DLL, VCRUNTIME_DLL],
26 )
27 .unwrap();
28 let lib_dir = files
29 .first()
30 .unwrap()
31 .parent()
32 .unwrap()
33 .as_os_str()
34 .to_str()
35 .unwrap();
36 println!("cargo:rustc-link-lib=r8Brain");
37 println!(r#"cargo:rustc-link-search={}"#, lib_dir);
38 println!(
39 r#"cargo:rustc-env=PATH={};{}"#,
40 lib_dir,
41 env::var("PATH").unwrap(),
42 );
43 }
44 }
45