Skip to content

Commit 935b64d

Browse files
committedJun 24, 2022
Prepare for a time when we can make the crates no_std
1 parent 3ca7172 commit 935b64d

File tree

19 files changed

+67
-15
lines changed

19 files changed

+67
-15
lines changed
 

‎.github/workflows/ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ jobs:
149149
CXXFLAGS: ${{ matrix.cflags }}
150150
ASMFLAGS: ${{ matrix.cflags }}
151151
LDFLAGS: ${{ matrix.cflags }}
152-
HOSTARGS: --no-default-features --features ${{ matrix.runtime || 'apple' }}
153-
ARGS: --no-default-features --features ${{ matrix.runtime || 'apple' }} ${{ matrix.args }}
152+
HOSTARGS: --no-default-features --features std --features ${{ matrix.runtime || 'apple' }}
153+
ARGS: --no-default-features --features std --features ${{ matrix.runtime || 'apple' }} ${{ matrix.args }}
154154
# Use --no-fail-fast, except with dinghy
155155
TESTARGS: ${{ matrix.dinghy && ' ' || '--no-fail-fast' }} ${{ matrix.test-args }}
156156
FEATURES: ${{ matrix.features || 'malloc,block,exception,catch_all,verify_message' }}

‎block-sys/Cargo.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ build = "build.rs"
2525
[features]
2626
# The default runtime is Apple's. Other platforms will probably error if the
2727
# correct feature flag is not specified.
28-
default = ["apple"]
28+
default = ["std", "apple"]
29+
30+
# Currently not possible to turn off, put here for forwards compatibility.
31+
std = ["alloc", "objc-sys?/std"]
32+
alloc = ["objc-sys?/alloc"]
2933

3034
# Link to Apple's libclosure (exists in libSystem)
3135
apple = []

‎block-sys/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424

2525
extern crate std;
2626

27+
#[cfg(not(feature = "std"))]
28+
compile_error!("The `std` feature currently must be enabled.");
29+
2730
// Ensure linkage actually happens
2831
#[cfg(feature = "gnustep-1-7")]
2932
extern crate objc_sys as _;

‎block2/Cargo.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ documentation = "https://docs.rs/block2/"
1818
license = "MIT"
1919

2020
[features]
21-
default = ["apple"]
21+
default = ["std", "apple"]
22+
23+
# Currently not possible to turn off, put here for forwards compatibility.
24+
std = ["alloc", "objc2-encode/std", "block-sys/std"]
25+
alloc = ["objc2-encode/alloc", "block-sys/alloc"]
2226

2327
# Runtime selection. Default is `apple`. See `block-sys` for details.
2428
apple = ["block-sys/apple"]

‎block2/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@
8888
extern crate alloc;
8989
extern crate std;
9090

91+
#[cfg(not(feature = "std"))]
92+
compile_error!("The `std` feature currently must be enabled.");
93+
9194
#[cfg(doctest)]
9295
#[doc = include_str!("../README.md")]
9396
extern "C" {}

‎objc-sys/Cargo.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ build = "build.rs"
2727
[features]
2828
# The default runtime is Apple's. Other platforms will probably error if the
2929
# correct feature flag is not specified.
30-
default = ["apple"]
30+
default = ["std", "apple"]
31+
32+
# Currently not possible to turn off, put here for forwards compatibility.
33+
std = ["alloc"]
34+
alloc = []
3135

3236
# Link to Apple's objc4
3337
apple = []

‎objc-sys/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
// See https://github.com/japaric/cty/issues/14.
3535
extern crate std;
3636

37+
#[cfg(not(feature = "std"))]
38+
compile_error!("The `std` feature currently must be enabled.");
39+
3740
#[cfg(doctest)]
3841
#[doc = include_str!("../README.md")]
3942
extern "C" {}

‎objc2-encode/Cargo.toml

+8
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ repository = "https://github.com/madsmtm/objc2"
1818
documentation = "https://docs.rs/objc2-encode/"
1919
license = "MIT"
2020

21+
[features]
22+
default = ["std"]
23+
24+
# Doesn't do anything (this crate works on no_std), put here for forwards
25+
# compatibility.
26+
std = ["alloc"]
27+
alloc = []
28+
2129
[package.metadata.docs.rs]
2230
default-target = "x86_64-apple-darwin"
2331

‎objc2-encode/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@
9999
#[doc = include_str!("../README.md")]
100100
extern "C" {}
101101

102-
#[cfg(doc)]
102+
#[cfg(any(feature = "std", doc))]
103103
extern crate std;
104104

105-
#[cfg(any(test, doc))]
105+
#[cfg(any(feature = "alloc", test, doc))]
106106
extern crate alloc;
107107

108108
mod encode;

‎objc2-foundation/Cargo.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@ documentation = "https://docs.rs/objc2-foundation/"
1717
license = "MIT"
1818

1919
[features]
20-
default = ["apple", "block"]
20+
default = ["std", "apple", "block"]
2121
# Provided as a way to cut down on dependencies
2222
block = ["block2"]
2323

24+
# Currently not possible to turn off, put here for forwards compatibility.
25+
std = ["alloc", "objc2/std", "block2?/std"]
26+
alloc = ["objc2/alloc", "block2?/alloc"]
27+
2428
# Runtime selection. See `objc-sys` and `block-sys` for details.
2529
apple = ["objc2/apple", "block2?/apple"]
2630
gnustep-1-7 = ["objc2/gnustep-1-7", "block2?/gnustep-1-7"]

‎objc2-foundation/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040
extern crate alloc;
4141
extern crate std;
4242

43+
#[cfg(not(feature = "std"))]
44+
compile_error!("The `std` feature currently must be enabled.");
45+
4346
#[cfg(doctest)]
4447
#[doc = include_str!("../README.md")]
4548
extern "C" {}

‎objc2/Cargo.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ license = "MIT"
1919
# NOTE: 'unstable' features are _not_ considered part of the SemVer contract,
2020
# and may be removed in a minor release.
2121
[features]
22-
default = ["apple"]
22+
default = ["std", "apple"]
23+
24+
# Currently not possible to turn off, put here for forwards compatibility.
25+
std = ["alloc", "objc2-encode/std", "objc-sys/std"]
26+
alloc = ["objc2-encode/alloc", "objc-sys/alloc"]
2327

2428
# Enables `objc2::exception::throw` and `objc2::exception::catch`
2529
exception = ["objc-sys/unstable-exception"]

‎objc2/src/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,12 @@
178178
// Update in Cargo.toml as well.
179179
#![doc(html_root_url = "https://docs.rs/objc2/0.3.0-beta.0")]
180180

181+
#[cfg(not(feature = "alloc"))]
182+
compile_error!("The `alloc` feature currently must be enabled.");
183+
184+
#[cfg(not(feature = "std"))]
185+
compile_error!("The `std` feature currently must be enabled.");
186+
181187
extern crate alloc;
182188
extern crate std;
183189

‎tests/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ license = "MIT"
1010
build = "build.rs"
1111

1212
[features]
13-
default = ["apple"]
13+
default = ["apple", "std"]
14+
std = ["block2/std", "objc2-foundation/std"]
1415
# Enable UI tests
1516
#
1617
# These are not enabled by default because trybuild doesn't pass feature flags

‎tests/assembly/test_msg_send_id/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ path = "lib.rs"
1111
objc2 = { path = "../../../objc2", default-features = false }
1212

1313
[features]
14-
default = ["apple"]
14+
default = ["apple", "std"]
15+
std = ["objc2/std"]
1516
# Runtime
1617
apple = ["objc2/apple"]
1718
gnustep-1-7 = ["objc2/gnustep-1-7"]

‎tests/assembly/test_msg_send_static_sel/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ path = "lib.rs"
1111
objc2 = { path = "../../../objc2", default-features = false }
1212

1313
[features]
14-
default = ["apple"]
14+
default = ["apple", "std"]
15+
std = ["objc2/std"]
1516
# Runtime
1617
apple = ["objc2/apple"]
1718
gnustep-1-7 = ["objc2/gnustep-1-7"]

‎tests/assembly/test_msg_send_zero_cost/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ path = "lib.rs"
1111
objc2 = { path = "../../../objc2", default-features = false }
1212

1313
[features]
14-
default = ["apple"]
14+
default = ["apple", "std"]
15+
std = ["objc2/std"]
1516
# Runtime
1617
apple = ["objc2/apple"]
1718
gnustep-1-7 = ["objc2/gnustep-1-7"]

‎tests/assembly/test_retain_autoreleased/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ path = "lib.rs"
1111
objc2 = { path = "../../../objc2", default-features = false }
1212

1313
[features]
14-
default = ["apple"]
14+
default = ["apple", "std"]
15+
std = ["objc2/std"]
1516
# Runtime
1617
apple = ["objc2/apple"]
1718
gnustep-1-7 = ["objc2/gnustep-1-7"]

‎tests/assembly/test_static_sel/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ path = "lib.rs"
1111
objc2 = { path = "../../../objc2", default-features = false }
1212

1313
[features]
14-
default = ["apple"]
14+
default = ["apple", "std"]
15+
std = ["objc2/std"]
1516
# Runtime
1617
apple = ["objc2/apple"]
1718
gnustep-1-7 = ["objc2/gnustep-1-7"]

0 commit comments

Comments
 (0)
Please sign in to comment.