[librsvg/fix-build-rs-windows: 2/2] rsvg_internals/build.rs: Fix native, non-cross Windows builds



commit 17e53d6a5ee4401bd8a018ce1f3530622c50ff5e
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Mon Jul 1 16:43:18 2019 +0800

    rsvg_internals/build.rs: Fix native, non-cross Windows builds
    
    Commit e310e36b broke builds on native Windows as it assumed the build
    is running on *NIX and is cross-compiling for Windows.  Fix this by:
    
    -Including the *nix-only items conditionally, and include the Windows
     symlink items only on non-MSVC builds.  The MSVC build files handle
     how the rust-built rsvg-internals.lib is being linked, so we don't need
     to build nor use generate_convenience_lib() on MSVC builds.
    
    -Only include the items related to generate_convenience_lib() when it
     is indeed being built.
    
    At this point we do not support cross-compiling on *nix for MSVC builds,
    and it is unlikely it would be supported, at least in the near future.

 rsvg_internals/build.rs | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/rsvg_internals/build.rs b/rsvg_internals/build.rs
index 29249991..eaa17b05 100644
--- a/rsvg_internals/build.rs
+++ b/rsvg_internals/build.rs
@@ -1,13 +1,23 @@
 use std::env;
-use std::fs;
 use std::fs::File;
 use std::io::{BufWriter, Write};
-use std::os::unix::fs::symlink;
 use std::path::Path;
+
+#[cfg(unix)]
+use std::os::unix::fs::symlink;
+
+#[cfg(all(windows, not(target_env = "msvc")))]
+use std::os::windows::fs::symlink_file;
+
+#[cfg(not(target_env = "msvc"))]
+use std::fs;
+#[cfg(not(target_env = "msvc"))]
 use std::path::PathBuf;
 
 fn main() {
     generate_srgb_tables();
+
+    #[cfg(not (target_env = "msvc"))]
     generate_convenience_lib().unwrap();
 }
 
@@ -70,6 +80,7 @@ fn generate_srgb_tables() {
 
 /// Generate libtool archive file librsvg_internals.la
 /// From: https://docs.rs/libtool/0.1.1/libtool/
+#[cfg(not (target_env = "msvc"))]
 pub fn generate_convenience_lib() -> std::io::Result<()> {
     let target = env::var("TARGET").expect("TARGET was not set");
     let build_dir = env::var("LIBRSVG_BUILD_DIR").expect("LIBRSVG_BUILD_DIR was not set");


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]