Skip to content

Commit f2c05d5

Browse files
authored
added iot edge support (#7)
* added iot edge support
1 parent 3fa2404 commit f2c05d5

File tree

5 files changed

+32
-2
lines changed

5 files changed

+32
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/target
22
Cargo.lock
3+
.vscode/launch.json

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.3.0] Q2 2022
9+
- added iot edge support
10+
811
## [0.2.3] Q1 2022
912
- removed conanfile.txt and instead provide pre-built-libs in release
1013
- improve documentation for building the crate

Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "azure-iot-sdk-sys"
3-
version = "0.2.3"
3+
version = "0.3.0"
44
edition = "2021"
55
authors = ["Joerg Zeidler <[email protected]>", "Jan Zachmann <[email protected]>"]
66
build = "build.rs"
@@ -10,6 +10,11 @@ repository = "https://github.com/ICS-DeviceManagement/azure-iot-sdk-sys"
1010

1111
[dependencies]
1212

13+
[features]
14+
# select "default = ["edge_modules"]" for building crate with iotedge module support
15+
default = []
16+
edge_modules = []
17+
1318
[build-dependencies]
1419
bindgen = "0.59.1"
1520
glob = "0.3.0"

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ You're free to build your own versions of libraries for the target platform of y
2020

2121
For your convenience we provide for x86_64 a bundle of libraries, created on Ubuntu 20.04lts, as part of our github release. Please find the library archive [here](https://github.com/ICS-DeviceManagement/azure-iot-sdk-sys/releases/latest)
2222

23+
## Enable iot edge support
24+
25+
In order to build `azure-iot-sdk-sys` with iot edge module API's enabled you have to set `edge_modules` cargo feature. This builds bindings with `"-DUSE_EDGE_MODULES"` option.<br>
26+
**Note: `azure-iot-sdk-c` also must have been built with `"-DUSE_EDGE_MODULES"` option!**
27+
2328
# License
2429

2530
Licensed under either of

build.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fn path_handling(env: &str) -> String {
2222
index += 1;
2323
}
2424

25-
if path_lib.len() == 0{
25+
if path_lib.len() == 0 {
2626
panic!("No paths found for {:?}", env);
2727
}
2828

@@ -34,6 +34,7 @@ fn path_handling(env: &str) -> String {
3434
}
3535

3636
fn main() {
37+
let mut iotedge = "";
3738
let path_lib_azuresdk = path_handling("LIB_PATH_AZURESDK");
3839
let path_lib_uuid = path_handling("LIB_PATH_UUID");
3940
let path_lib_openssl = path_handling("LIB_PATH_OPENSSL");
@@ -58,10 +59,18 @@ fn main() {
5859
);
5960

6061
// Tell cargo to tell rustc to link the azure iot-sdk libraries.
62+
// Order of libraries matters!
6163
println!("cargo:rustc-link-lib=iothub_client_mqtt_transport");
6264
println!("cargo:rustc-link-lib=iothub_client");
6365
println!("cargo:rustc-link-lib=parson");
6466
println!("cargo:rustc-link-lib=umqtt");
67+
68+
if env::var("CARGO_FEATURE_EDGE_MODULES").is_ok() {
69+
iotedge = "-DUSE_EDGE_MODULES";
70+
println!("cargo:rustc-link-lib=prov_auth_client");
71+
println!("cargo:rustc-link-lib=hsm_security_client");
72+
}
73+
6574
println!("cargo:rustc-link-lib=uhttp");
6675
println!("cargo:rustc-link-lib=aziotsharedutil");
6776
println!("cargo:rustc-link-lib=curl");
@@ -71,6 +80,12 @@ fn main() {
7180

7281
// Tell cargo to invalidate the built crate whenever the wrapper changes
7382
println!("cargo:rerun-if-changed=wrapper.h");
83+
println!("cargo:rerun-if-changed=build.rs");
84+
println!("cargo:rerun-if-env-changed=CARGO_FEATURE_EDGE_MODULES");
85+
println!("cargo:rerun-if-env-changed=LIB_PATH_AZURESDK");
86+
println!("cargo:rerun-if-env-changed=LIB_PATH_UUID");
87+
println!("cargo:rerun-if-env-changed=LIB_PATH_CURL");
88+
println!("cargo:rerun-if-env-changed=LIB_PATH_OPENSSL");
7489

7590
// The bindgen::Builder is the main entry point
7691
// to bindgen, and lets you build up options for
@@ -80,6 +95,7 @@ fn main() {
8095
// bindings for.
8196
.header("wrapper.h")
8297
// additional clang arguments.
98+
.clang_arg(iotedge)
8399
.clang_arg(format!("-I{}/include", path_lib_azuresdk.to_string()))
84100
.clang_arg(format!(
85101
"-I{}/include/azureiot",

0 commit comments

Comments
 (0)