[librsvg] (#491): rsvg_internals: Don't require environment variables when building as rust crate



commit 4167c9607848e349d3eba4210b5c4a1a678ad05e
Author: Federico Mena Quintero <federico gnome org>
Date:   Thu Aug 1 10:49:21 2019 -0500

    (#491): rsvg_internals: Don't require environment variables when building as rust crate
    
    For the libtool case, when we are building rsvg_internals as part of
    the C library, we *do* need the libtool stuff in
    generate_convenience_lib().  In this case, that function needs to know
    LIBRSVG_BUILD_DIR and LIBRSVG_TARGET_DIR.
    
    However, when building rsvg_internals as part of the standalone
    librsvg_crate, those variables are not needed, since that compilation
    scheme doesn't use libtool.
    
    Fixes https://gitlab.gnome.org/GNOME/librsvg/issues/491

 rsvg_internals/build.rs | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/rsvg_internals/build.rs b/rsvg_internals/build.rs
index eafaa2b4..e29e45de 100644
--- a/rsvg_internals/build.rs
+++ b/rsvg_internals/build.rs
@@ -3,21 +3,20 @@ use std::fs::File;
 use std::io::{BufWriter, Write};
 use std::path::Path;
 
-#[cfg(unix)]
+#[cfg(all(unix, feature = "c-library"))]
 use std::os::unix::fs::symlink;
 
-#[cfg(all(windows, not(target_env = "msvc")))]
+#[cfg(all(windows, not(target_env = "msvc"), feature="c-library"))]
 use std::os::windows::fs::symlink_file as symlink;
 
-#[cfg(not(target_env = "msvc"))]
+#[cfg(all(not(target_env = "msvc"), feature="c-library"))]
 use std::fs;
-#[cfg(not(target_env = "msvc"))]
+#[cfg(all(not(target_env = "msvc"), feature="c-library"))]
 use std::path::PathBuf;
 
 fn main() {
     generate_srgb_tables();
 
-    #[cfg(not (target_env = "msvc"))]
     generate_convenience_lib().unwrap();
 }
 
@@ -80,7 +79,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"))]
+#[cfg(all(feature = "c-library", 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");
@@ -124,3 +123,8 @@ pub fn generate_convenience_lib() -> std::io::Result<()> {
     symlink(&old_lib_path, &new_lib_path)?;
     Ok(())
 }
+
+#[cfg(not(all(feature = "c-library", not(target_env = "msvc"))))]
+pub fn generate_convenience_lib() -> std::io::Result<()> {
+    Ok(())
+}


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