Skip to content

Commit f6787bf

Browse files
authored
Merge pull request #1328 from ekxide/iox2-1327-use-target-switch-instead-of-posix-feature
[#1327] Use target switches for POSIX usage instead of feature
2 parents 37ba14f + 8dc88e2 commit f6787bf

File tree

9 files changed

+113
-82
lines changed

9 files changed

+113
-82
lines changed

Cargo.Bazel.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"checksum": "1277e9a9ee7d849cba0a66cb83f4d3ea45a52da8efe6fe33a03d7f74fac9d1ab",
2+
"checksum": "2294447d63760449f293a07ca48ba89d64093498189e12811ecfe2b1734f686a",
33
"crates": {
44
"addr2line 0.24.2": {
55
"name": "addr2line",

MODULE.bazel.lock

Lines changed: 70 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

doc/release-notes/iceoryx2-unreleased.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
NOTE: Add new entries sorted by issue number to minimize the possibility of
4343
conflicts when merging.
4444
-->
45+
* Remove support for Bazel Workspaces
46+
[#1263](https://github.com/eclipse-iceoryx/iceoryx2/issues/1263)
4547
* Adjust test names to naming convention
4648
[#1273](https://github.com/eclipse-iceoryx/iceoryx2/issues/1273)
4749
* Move character output abstraction into their own crate
@@ -51,8 +53,8 @@
5153
* Replace `lazy_static` dependency with `LazyLock` from `std` in `std` builds or
5254
a custom minimal spin-based implementation for `no_std` builds
5355
[#1321](https://github.com/eclipse-iceoryx/iceoryx2/issues/1321)
54-
* Remove support for Bazel Workspaces
55-
[#1263](https://github.com/eclipse-iceoryx/iceoryx2/issues/1263)
56+
* Remove `posix` feature and use `cfg` switch based on target instead
57+
[#1327](https://github.com/eclipse-iceoryx/iceoryx2/issues/1327)
5658

5759
### Workflow
5860

examples/nostd/posix/rust/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ posix-nostd-publish-subscribe = { path = "publish-subscribe/" }
1717
posix-nostd-event = { path = "event/" }
1818

1919
iceoryx2 = { path = "../../../../iceoryx2/", default-features = false }
20-
iceoryx2-bb-loggers = { path = "../../../../iceoryx2-bb/loggers", default-features = false, features = ["posix", "console"]}
20+
iceoryx2-bb-loggers = { path = "../../../../iceoryx2-bb/loggers", default-features = false, features = ["console"]}
2121
iceoryx2-bb-elementary-traits = { path = "../../../../iceoryx2-bb/elementary-traits" }
2222
iceoryx2-bb-memory = { path = "../../../../iceoryx2-bb/memory" }
2323
iceoryx2-bb-posix = { path = "../../../../iceoryx2-bb/posix" }

iceoryx2-bb/loggers/Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,10 @@ workspace = true
1616
[features]
1717
default = []
1818

19-
# Use the std module
2019
std = [
2120
"iceoryx2-bb-print/std",
2221
"iceoryx2-pal-concurrency-sync/std"
2322
]
24-
# Use POSIX APIs
25-
posix = [
26-
"iceoryx2-bb-print/posix",
27-
"iceoryx2-pal-posix"
28-
]
2923

3024
# Enables logging to buffer
3125
buffer = []
@@ -46,3 +40,9 @@ iceoryx2-pal-concurrency-sync = { workspace = true }
4640

4741
log = { workspace = true, optional = true }
4842
tracing = { workspace = true, optional = true }
43+
44+
[target.'cfg(target_os = "linux")'.dependencies]
45+
iceoryx2-pal-posix = { workspace = true }
46+
47+
[target.'cfg(target_os = "nto")'.dependencies]
48+
iceoryx2-pal-posix = { workspace = true }

iceoryx2-bb/loggers/src/console.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fn duration_since_epoch() -> core::time::Duration {
4747
.duration_since(std::time::UNIX_EPOCH)
4848
.unwrap()
4949
}
50-
#[cfg(feature = "posix")]
50+
#[cfg(all(not(feature = "std"), any(target_os = "linux", target_os = "nto",)))]
5151
{
5252
use core::time::Duration;
5353
use iceoryx2_pal_posix::*;
@@ -65,7 +65,10 @@ fn duration_since_epoch() -> core::time::Duration {
6565
}
6666
Duration::from_secs(0)
6767
}
68-
#[cfg(not(any(feature = "std", feature = "posix")))]
68+
#[cfg(all(
69+
not(feature = "std"),
70+
not(any(target_os = "linux", target_os = "nto",))
71+
))]
6972
{
7073
Duration::from_secs(0)
7174
}

iceoryx2-bb/print/Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,8 @@ version = { workspace = true }
1313
[features]
1414
default = []
1515

16-
# Use the std module
1716
std = ["iceoryx2-pal-print/std"]
1817

19-
# Use POSIX APIs
20-
posix = ["iceoryx2-pal-print/posix"]
21-
2218
[dependencies]
2319
iceoryx2-pal-print = { workspace = true }
2420

iceoryx2-pal/print/Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ version = { workspace = true }
1212

1313
[features]
1414
default = []
15-
16-
# Use the std module
1715
std = []
1816

19-
# Use POSIX APIs
20-
posix = ["iceoryx2-pal-posix"]
21-
2217
[dependencies]
23-
iceoryx2-pal-posix = { workspace = true, optional = true }
18+
19+
[target.'cfg(target_os = "linux")'.dependencies]
20+
iceoryx2-pal-posix = { workspace = true }
21+
22+
[target.'cfg(target_os = "nto")'.dependencies]
23+
iceoryx2-pal-posix = { workspace = true }
2424

2525
[lints]
2626
workspace = true

iceoryx2-pal/print/src/writer.rs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl IsTerminal for Stderr {
7171
}
7272
}
7373

74-
#[cfg(feature = "posix")]
74+
#[cfg(all(not(feature = "std"), any(target_os = "linux", target_os = "nto",)))]
7575
impl Write for Stdout {
7676
fn write_str(&mut self, s: &str) -> fmt::Result {
7777
use iceoryx2_pal_posix::*;
@@ -92,14 +92,14 @@ impl Write for Stdout {
9292
}
9393
}
9494

95-
#[cfg(feature = "posix")]
95+
#[cfg(all(not(feature = "std"), any(target_os = "linux", target_os = "nto",)))]
9696
impl IsTerminal for Stdout {
9797
fn is_terminal(&self) -> bool {
9898
true
9999
}
100100
}
101101

102-
#[cfg(feature = "posix")]
102+
#[cfg(all(not(feature = "std"), any(target_os = "linux", target_os = "nto",)))]
103103
impl Write for Stderr {
104104
fn write_str(&mut self, s: &str) -> fmt::Result {
105105
use iceoryx2_pal_posix::*;
@@ -120,35 +120,47 @@ impl Write for Stderr {
120120
}
121121
}
122122

123-
#[cfg(feature = "posix")]
123+
#[cfg(all(not(feature = "std"), any(target_os = "linux", target_os = "nto",)))]
124124
impl IsTerminal for Stderr {
125125
fn is_terminal(&self) -> bool {
126126
true
127127
}
128128
}
129129

130-
#[cfg(not(any(feature = "std", feature = "posix")))]
130+
#[cfg(all(
131+
not(feature = "std"),
132+
not(any(target_os = "linux", target_os = "nto",))
133+
))]
131134
impl Write for Stdout {
132135
fn write_str(&mut self, _s: &str) -> fmt::Result {
133136
Ok(())
134137
}
135138
}
136139

137-
#[cfg(not(any(feature = "std", feature = "posix")))]
140+
#[cfg(all(
141+
not(feature = "std"),
142+
not(any(target_os = "linux", target_os = "nto",))
143+
))]
138144
impl IsTerminal for Stdout {
139145
fn is_terminal(&self) -> bool {
140146
false
141147
}
142148
}
143149

144-
#[cfg(not(any(feature = "std", feature = "posix")))]
150+
#[cfg(all(
151+
not(feature = "std"),
152+
not(any(target_os = "linux", target_os = "nto",))
153+
))]
145154
impl Write for Stderr {
146155
fn write_str(&mut self, _s: &str) -> fmt::Result {
147156
Ok(())
148157
}
149158
}
150159

151-
#[cfg(not(any(feature = "std", feature = "posix")))]
160+
#[cfg(all(
161+
not(feature = "std"),
162+
not(any(target_os = "linux", target_os = "nto",))
163+
))]
152164
impl IsTerminal for Stderr {
153165
fn is_terminal(&self) -> bool {
154166
false

0 commit comments

Comments
 (0)