[librsvg/meson-2022-oct] build.rs: generate rsvg-version.h



commit 813f82d4446f9f5fe0fd9bd20fc8cacd05eea503
Author: Federico Mena Quintero <federico gnome org>
Date:   Thu Jan 20 16:16:22 2022 -0600

    build.rs: generate rsvg-version.h
    
    This file was/is generated from configure.ac, but now we'll do it from
    the Rust build script.  This is so that "cargo cinstall" can use it.

 build.rs | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
---
diff --git a/build.rs b/build.rs
index bc44ffe8a..40b8eb72c 100644
--- a/build.rs
+++ b/build.rs
@@ -16,6 +16,7 @@ fn main() {
 
     let version = read_version_from_file("configure.ac").expect("Could not find version in configure.ac");
     write_version_rs(&version);
+    write_rsvg_version_h(&version);
 }
 
 /// Converts an sRGB color value to a linear sRGB color value (undoes the gamma correction).
@@ -140,3 +141,30 @@ pub static rsvg_micro_version: c_uint = {};
     )
     .expect("write version.rs");
 }
+
+fn write_rsvg_version_h(version: &Version) {
+    let output = Path::new(&env::var("OUT_DIR").unwrap()).join("rsvg-version.h");
+    let mut file = File::create(output).expect("open rsvg-version.h for writing");
+    file.write_all(
+        format!(
+r##"#if !defined (__RSVG_RSVG_H_INSIDE__) && !defined (RSVG_COMPILATION)
+#warning "Including <librsvg/rsvg-version.h> directly is deprecated."
+#endif
+
+#ifndef RSVG_VERSION_H
+#define RSVG_VERSION_H
+
+#define LIBRSVG_MAJOR_VERSION ({major})
+#define LIBRSVG_MINOR_VERSION ({minor})
+#define LIBRSVG_MICRO_VERSION ({micro})
+#define LIBRSVG_VERSION "{major}.{minor}.{micro}"
+
+#endif
+"##,
+            major = version.major,
+            minor = version.minor,
+            micro = version.micro,
+        ).as_bytes()
+    )
+    .expect("write rsvg-version.h");
+}


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