• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #[cfg(windows)]
11 static UCRTBASE_DLL: &str = "ucrtbased.dll";
12 #[cfg(windows)]
13 static VCRUNTIME_DLL: &str = "vcruntime140d.dll";
14 
main()15 fn main() {
16     if std::env::var("CARGO_CFG_WINDOWS").is_ok() {
17         let version = std::fs::read_to_string(PREBUILTS_VERSION_FILENAME)
18             .unwrap()
19             .trim()
20             .parse::<u32>()
21             .unwrap();
22 
23         // TODO(b:253039132) build prebuilts locally on windows from build.rs.
24         let files = prebuilts::download_prebuilts(
25             "r8brain",
26             version,
27             &[
28                 R8BRAIN_DLL,
29                 R8BRAIN_LIB,
30                 #[cfg(windows)]
31                 UCRTBASE_DLL,
32                 #[cfg(windows)]
33                 VCRUNTIME_DLL,
34             ],
35         )
36         .unwrap();
37         let lib_dir = files
38             .get(0)
39             .unwrap()
40             .parent()
41             .unwrap()
42             .as_os_str()
43             .to_str()
44             .unwrap();
45         println!("cargo:rustc-link-lib=r8Brain");
46         println!(r#"cargo:rustc-link-search={}"#, lib_dir);
47         println!(
48             r#"cargo:rustc-env=PATH={};{}"#,
49             lib_dir,
50             env::var("PATH").unwrap(),
51         );
52     }
53 }
54