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 5 static PREBUILTS_VERSION_FILENAME: &str = "prebuilts_version"; 6 static SLIRP_LIB: &str = "libslirp.lib"; 7 static SLIRP_DLL: &str = "libslirp-0.dll"; 8 #[cfg(unix)] 9 static GLIB_FILENAME: &str = "libglib-2.0.dll.a"; 10 main()11fn main() { 12 // We (the Windows crosvm maintainers) submitted upstream patches to libslirp-sys so it doesn't 13 // try to link directly on Windows. This is because linking on Windows tends to be specific 14 // to the build system that invokes Cargo (e.g. the crosvm jCI scripts that also produce the 15 // required libslirp DLL & lib). The integration here (win_slirp::main) is specific to crosvm's 16 // build process. 17 if std::env::var("CARGO_CFG_WINDOWS").is_ok() { 18 let version = std::fs::read_to_string(PREBUILTS_VERSION_FILENAME) 19 .unwrap() 20 .trim() 21 .parse::<u32>() 22 .unwrap(); 23 // TODO(b:242204245) build libslirp locally on windows from build.rs. 24 prebuilts::download_prebuilts( 25 "libslirp", 26 version, 27 &[ 28 SLIRP_DLL, 29 SLIRP_LIB, 30 #[cfg(unix)] 31 // When compiling with mingw64 to run under wine64, we need glib as slirp links 32 // against it. 33 GLIB_FILENAME, 34 ], 35 ) 36 .unwrap(); 37 } 38 39 // For unix, libslirp-sys's build script will make the appropriate linking calls to pkg_config. 40 } 41