From b3a90eaec83f16ab067bc1aeae9200e2667aa6c2 Mon Sep 17 00:00:00 2001 From: "Trevor R.H. Clarke" Date: Wed, 1 May 2024 14:05:44 -0400 Subject: [PATCH] Add support for pgm and epgm --- Cargo.toml | 1 + zmq-sys/Cargo.toml | 1 + zmq-sys/build/main.rs | 14 ++++++++++++++ 3 files changed, 16 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 02e6c23c..0b7a2018 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,6 +24,7 @@ default = ["zmq_has"] # this feature is a no-op and only present for backward-compatibility; # it will be removed in the next API-breaking release. zmq_has = [] +libpgm = ["zmq-sys/libpgm"] [dependencies] bitflags = "1.0" diff --git a/zmq-sys/Cargo.toml b/zmq-sys/Cargo.toml index 14507b86..0f54331e 100644 --- a/zmq-sys/Cargo.toml +++ b/zmq-sys/Cargo.toml @@ -14,6 +14,7 @@ build = "build/main.rs" links = "zmq" [features] +libpgm = [] [dependencies] libc = "0.2.15" diff --git a/zmq-sys/build/main.rs b/zmq-sys/build/main.rs index d6c229bc..756bbbb4 100644 --- a/zmq-sys/build/main.rs +++ b/zmq-sys/build/main.rs @@ -1,13 +1,27 @@ +use std::env; + pub fn configure() { println!("cargo:rerun-if-changed=build/main.rs"); println!("cargo:rerun-if-env-changed=PROFILE"); + let maybe_libpgm = if cfg!(feature = "libpgm") { + let lib_dir = env::var("DEP_PGM_LIB") + .expect("build metadata `DEP_PGM_LIB` required"); + let include_dir = env::var("DEP_PGM_INCLUDE") + .expect("build metadata `DEP_PGM_INCLUDE` required"); + + Some(zeromq_src::LibLocation::new(lib_dir, include_dir)) + } else { + None + }; + // Note that by default `libzmq` builds without `libsodium` by instead // relying on `tweetnacl`. However since this `tweetnacl` [has never been // audited nor is ready for production](https://github.com/zeromq/libzmq/issues/3006), // we link against `libsodium` to enable `ZMQ_CURVE`. zeromq_src::Build::new() .with_libsodium(None) + .with_libpgm(maybe_libpgm) .build(); }