1
0

build.rs 1.4 KB

12345678910111213141516171819202122232425262728293031
  1. // Copyright 2020 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. static PREBUILTS_VERSION_FILENAME: &str = "prebuilts_version";
  5. static SLIRP_LIB: &str = "libslirp.lib";
  6. static SLIRP_DLL: &str = "libslirp-0.dll";
  7. static GLIB_FILENAME: &str = "libglib-2.0.dll.a";
  8. fn main() {
  9. // We (the Windows crosvm maintainers) submitted upstream patches to libslirp-sys so it doesn't
  10. // try to link directly on Windows. This is because linking on Windows tends to be specific
  11. // to the build system that invokes Cargo (e.g. the crosvm jCI scripts that also produce the
  12. // required libslirp DLL & lib). The integration here (win_slirp::main) is specific to crosvm's
  13. // build process.
  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. // TODO(b:242204245) build libslirp locally on windows from build.rs.
  21. let mut libs = vec![SLIRP_DLL, SLIRP_LIB];
  22. if std::env::var("CARGO_CFG_TARGET_ENV") == Ok("gnu".to_string()) {
  23. libs.push(GLIB_FILENAME);
  24. }
  25. prebuilts::download_prebuilts("libslirp", version, &libs).unwrap();
  26. }
  27. // For unix, libslirp-sys's build script will make the appropriate linking calls to pkg_config.
  28. }