Skip to content

Commit cb07811

Browse files
committed
Avoid build failures of unsupported examples on freebsd
I'm not really happy with the readability, there ought to be a real way to mark an example as "non applicable in cfg so and so". Signed-off-by: Yann Dirson <yann.dirson@vates.fr>
1 parent d887563 commit cb07811

File tree

8 files changed

+43
-1
lines changed

8 files changed

+43
-1
lines changed

examples/add_netns.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
// SPDX-License-Identifier: MIT
22

3+
#[cfg(not(target_os = "freebsd"))]
34
use rtnetlink::NetworkNamespace;
45
use std::env;
56

7+
#[cfg(target_os = "freebsd")]
8+
fn main() -> () {}
9+
10+
#[cfg(not(target_os = "freebsd"))]
611
#[tokio::main]
712
async fn main() -> Result<(), String> {
813
env_logger::init();

examples/add_netns_async.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
// SPDX-License-Identifier: MIT
22

3+
#[cfg(not(target_os = "freebsd"))]
34
use rtnetlink::NetworkNamespace;
45
use std::env;
56

7+
#[cfg(target_os = "freebsd")]
8+
fn main() -> () {}
9+
10+
#[cfg(not(target_os = "freebsd"))]
611
#[async_std::main]
712
async fn main() -> Result<(), String> {
813
env_logger::init();

examples/add_tc_qdisc_ingress.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ use std::env;
44

55
use rtnetlink::new_connection;
66

7+
#[cfg(target_os = "freebsd")]
8+
fn main() -> () {}
9+
10+
#[cfg(not(target_os = "freebsd"))]
711
#[tokio::main]
812
async fn main() -> Result<(), ()> {
913
env_logger::init();

examples/del_netns.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
// SPDX-License-Identifier: MIT
22

3+
#[cfg(not(target_os = "freebsd"))]
34
use rtnetlink::NetworkNamespace;
45
use std::env;
56

7+
#[cfg(target_os = "freebsd")]
8+
fn main() -> () {}
9+
10+
#[cfg(not(target_os = "freebsd"))]
611
#[tokio::main]
712
async fn main() -> Result<(), String> {
813
let args: Vec<String> = env::args().collect();

examples/del_netns_async.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
// SPDX-License-Identifier: MIT
22

3+
#[cfg(not(target_os = "freebsd"))]
34
use rtnetlink::NetworkNamespace;
45
use std::env;
56

7+
#[cfg(target_os = "freebsd")]
8+
fn main() -> () {}
9+
10+
#[cfg(not(target_os = "freebsd"))]
611
#[async_std::main]
712
async fn main() -> Result<(), String> {
813
let args: Vec<String> = env::args().collect();

examples/get_links.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ use netlink_packet_route::{
77
};
88
use rtnetlink::{new_connection, Error, Handle};
99

10+
#[cfg(target_os = "freebsd")]
11+
fn main() -> () {}
12+
13+
#[cfg(not(target_os = "freebsd"))]
1014
#[tokio::main]
1115
async fn main() -> Result<(), ()> {
1216
env_logger::init();
@@ -90,6 +94,7 @@ async fn dump_links(handle: Handle) -> Result<(), Error> {
9094
Ok(())
9195
}
9296

97+
#[cfg(not(target_os = "freebsd"))]
9398
async fn dump_bridge_filter_info(handle: Handle) -> Result<(), Error> {
9499
let mut links = handle
95100
.link()

examples/get_links_async.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ use netlink_packet_route::{
77
};
88
use rtnetlink::{new_connection, Error, Handle};
99

10+
#[cfg(target_os = "freebsd")]
11+
fn main() -> () {}
12+
13+
#[cfg(not(target_os = "freebsd"))]
1014
#[async_std::main]
1115
async fn main() -> Result<(), ()> {
1216
env_logger::init();
@@ -90,6 +94,7 @@ async fn dump_links(handle: Handle) -> Result<(), Error> {
9094
Ok(())
9195
}
9296

97+
#[cfg(not(target_os = "freebsd"))]
9398
async fn dump_bridge_filter_info(handle: Handle) -> Result<(), Error> {
9499
let mut links = handle
95100
.link()

examples/get_links_thread_builder.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ use netlink_packet_route::{
55
link::{LinkAttribute, LinkExtentMask},
66
AddressFamily,
77
};
8-
use rtnetlink::{new_connection, Error, Handle};
8+
#[cfg(not(target_os = "freebsd"))]
9+
use rtnetlink::new_connection;
10+
use rtnetlink::{Error, Handle};
911

12+
#[cfg(not(target_os = "freebsd"))]
1013
async fn do_it(rt: &tokio::runtime::Runtime) -> Result<(), ()> {
1114
env_logger::init();
1215
let (connection, handle, _) = new_connection().unwrap();
@@ -89,6 +92,7 @@ async fn dump_links(handle: Handle) -> Result<(), Error> {
8992
Ok(())
9093
}
9194

95+
#[cfg(not(target_os = "freebsd"))]
9296
async fn dump_bridge_filter_info(handle: Handle) -> Result<(), Error> {
9397
let mut links = handle
9498
.link()
@@ -109,6 +113,10 @@ async fn dump_bridge_filter_info(handle: Handle) -> Result<(), Error> {
109113
Ok(())
110114
}
111115

116+
#[cfg(target_os = "freebsd")]
117+
fn main() -> () {}
118+
119+
#[cfg(not(target_os = "freebsd"))]
112120
fn main() -> Result<(), String> {
113121
let rt = tokio::runtime::Builder::new_multi_thread()
114122
.enable_io()

0 commit comments

Comments
 (0)