summaryrefslogtreecommitdiffstats
path: root/vendor/libnghttp2-sys/build.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 12:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 12:47:55 +0000
commit2aadc03ef15cb5ca5cc2af8a7c08e070742f0ac4 (patch)
tree033cc839730fda84ff08db877037977be94e5e3a /vendor/libnghttp2-sys/build.rs
parentInitial commit. (diff)
downloadcargo-upstream.tar.xz
cargo-upstream.zip
Adding upstream version 0.70.1+ds1.upstream/0.70.1+ds1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--vendor/libnghttp2-sys/build.rs7
-rw-r--r--vendor/libnghttp2-sys/build.rs.orig116
2 files changed, 123 insertions, 0 deletions
diff --git a/vendor/libnghttp2-sys/build.rs b/vendor/libnghttp2-sys/build.rs
new file mode 100644
index 0000000..e0f5612
--- /dev/null
+++ b/vendor/libnghttp2-sys/build.rs
@@ -0,0 +1,7 @@
+extern crate pkg_config;
+
+pub fn main() {
+ if pkg_config::probe_library("libnghttp2").is_ok() {
+ return;
+ }
+}
diff --git a/vendor/libnghttp2-sys/build.rs.orig b/vendor/libnghttp2-sys/build.rs.orig
new file mode 100644
index 0000000..5d509bb
--- /dev/null
+++ b/vendor/libnghttp2-sys/build.rs.orig
@@ -0,0 +1,116 @@
+extern crate cc;
+
+use std::env;
+use std::fs;
+use std::path::PathBuf;
+
+fn main() {
+ let target = env::var("TARGET").unwrap();
+ let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
+ let lib_version = env::var("CARGO_PKG_VERSION")
+ .unwrap()
+ .split('+')
+ .nth(1)
+ .unwrap()
+ .to_string();
+ let major = lib_version
+ .split('.')
+ .nth(0)
+ .unwrap()
+ .parse::<u32>()
+ .unwrap();
+ let minor = lib_version
+ .split('.')
+ .nth(1)
+ .unwrap()
+ .parse::<u32>()
+ .unwrap();
+ let patch = lib_version
+ .split('.')
+ .nth(2)
+ .unwrap()
+ .parse::<u32>()
+ .unwrap();
+ let ver = fs::read_to_string("nghttp2/lib/includes/nghttp2/nghttp2ver.h.in")
+ .unwrap()
+ .replace("@PACKAGE_VERSION@", &lib_version)
+ .replace(
+ "@PACKAGE_VERSION_NUM@",
+ &format!("0x{:02x}{:02x}{:02x}", major, minor, patch),
+ );
+
+ let install = out_dir.join("i");
+
+ let include = install.join("include");
+ let lib = install.join("lib");
+ let pkgconfig = lib.join("pkgconfig");
+ fs::create_dir_all(include.join("nghttp2")).unwrap();
+ fs::create_dir_all(&pkgconfig).unwrap();
+ fs::write(include.join("nghttp2/nghttp2ver.h"), ver).unwrap();
+
+ let mut cfg = cc::Build::new();
+ cfg.include("nghttp2/lib/includes")
+ .include(&include)
+ .file("nghttp2/lib/sfparse.c")
+ .file("nghttp2/lib/nghttp2_buf.c")
+ .file("nghttp2/lib/nghttp2_callbacks.c")
+ .file("nghttp2/lib/nghttp2_debug.c")
+ .file("nghttp2/lib/nghttp2_extpri.c")
+ .file("nghttp2/lib/nghttp2_frame.c")
+ .file("nghttp2/lib/nghttp2_hd.c")
+ .file("nghttp2/lib/nghttp2_hd_huffman.c")
+ .file("nghttp2/lib/nghttp2_hd_huffman_data.c")
+ .file("nghttp2/lib/nghttp2_helper.c")
+ .file("nghttp2/lib/nghttp2_http.c")
+ .file("nghttp2/lib/nghttp2_map.c")
+ .file("nghttp2/lib/nghttp2_mem.c")
+ .file("nghttp2/lib/nghttp2_npn.c")
+ .file("nghttp2/lib/nghttp2_option.c")
+ .file("nghttp2/lib/nghttp2_outbound_item.c")
+ .file("nghttp2/lib/nghttp2_pq.c")
+ .file("nghttp2/lib/nghttp2_priority_spec.c")
+ .file("nghttp2/lib/nghttp2_queue.c")
+ .file("nghttp2/lib/nghttp2_rcbuf.c")
+ .file("nghttp2/lib/nghttp2_session.c")
+ .file("nghttp2/lib/nghttp2_stream.c")
+ .file("nghttp2/lib/nghttp2_submit.c")
+ .file("nghttp2/lib/nghttp2_version.c")
+ .warnings(false)
+ .define("NGHTTP2_STATICLIB", None)
+ .define("HAVE_NETINET_IN", None)
+ .out_dir(&lib);
+
+ if target.contains("windows") {
+ // Apparently MSVC doesn't have `ssize_t` defined as a type
+ if target.contains("msvc") {
+ match &env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap()[..] {
+ "64" => {
+ cfg.define("ssize_t", "int64_t");
+ }
+ "32" => {
+ cfg.define("ssize_t", "int32_t");
+ }
+ s => panic!("unknown pointer size: {}", s),
+ }
+ }
+ } else {
+ cfg.define("HAVE_ARPA_INET_H", None);
+ }
+ cfg.compile("nghttp2");
+
+ println!("cargo:root={}", install.display());
+
+ let pc = fs::read_to_string("nghttp2/lib/libnghttp2.pc.in")
+ .unwrap()
+ .replace("@prefix@", install.to_str().unwrap())
+ .replace("@exec_prefix@", "")
+ .replace("@libdir@", lib.to_str().unwrap())
+ .replace("@includedir@", include.to_str().unwrap())
+ .replace("@VERSION@", &lib_version);
+ fs::write(pkgconfig.join("libnghttp2.pc"), pc).unwrap();
+ fs::copy(
+ "nghttp2/lib/includes/nghttp2/nghttp2.h",
+ include.join("nghttp2/nghttp2.h"),
+ )
+ .unwrap();
+}