Skip to content

Commit d3dc9e5

Browse files
authored
Merge pull request #149 from madsmtm/feature-cleanup
Cargo features cleanup
2 parents c75691e + 08a13d3 commit d3dc9e5

File tree

16 files changed

+62
-50
lines changed

16 files changed

+62
-50
lines changed

.github/workflows/ci.yml

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ env:
1414
RUSTFLAGS: "-C debuginfo=0 -D warnings"
1515
RUSTDOCFLAGS: "-D warnings"
1616
CARGO_TERM_VERBOSE: true
17-
FEATURES: malloc,block,exception,catch_all,verify_message
18-
UNSTABLE_FEATURES: unstable_autoreleasesafe
1917
MACOSX_DEPLOYMENT_TARGET: 10.7
2018
IPHONEOS_DEPLOYMENT_TARGET: 7.0
2119
# We only support compiling Objective-C code with clang
@@ -125,6 +123,13 @@ jobs:
125123
components: rust-src
126124
args: -Zbuild-std -Zdoctest-xcompile
127125
test-args: --no-run
126+
- name: Test Compiler-RT
127+
os: ubuntu-latest
128+
target: x86_64-unknown-linux-gnu
129+
runtime: compiler-rt
130+
args: -p block-sys -p block2
131+
features: ' '
132+
unstable-features: ' '
128133

129134
env:
130135
CARGO_BUILD_TARGET: ${{ matrix.target }}
@@ -136,6 +141,8 @@ jobs:
136141
ARGS: --no-default-features --features ${{ matrix.runtime || 'apple' }} ${{ matrix.args }}
137142
# Use --no-fail-fast, except with dinghy
138143
TESTARGS: ${{ matrix.dinghy && ' ' || '--no-fail-fast' }} ${{ matrix.test-args }}
144+
FEATURES: ${{ matrix.features || 'malloc,block,exception,catch_all,verify_message' }}
145+
UNSTABLE_FEATURES: ${{ matrix.unstable-features || 'unstable-autoreleasesafe' }}
139146

140147
runs-on: ${{ matrix.os }}
141148

@@ -195,6 +202,10 @@ jobs:
195202
sudo apt-get update
196203
sudo apt-get -y install clang valgrind
197204
205+
- name: Install libBlocksRuntime
206+
if: contains(matrix.runtime, 'compiler-rt')
207+
run: sudo apt-get -y install libblocksruntime-dev
208+
198209
- name: Install cross compilation tools
199210
if: matrix.target == 'i686-unknown-linux-gnu'
200211
run: |
@@ -220,11 +231,11 @@ jobs:
220231
mv MacOSX${{ matrix.sdk }}.sdk $HOME/extern/sdk
221232
222233
- name: Install Make and Cmake
223-
if: contains(matrix.os, 'ubuntu') && steps.extern-cache.outputs.cache-hit != 'true'
234+
if: contains(matrix.runtime, 'gnustep') && steps.extern-cache.outputs.cache-hit != 'true'
224235
run: sudo apt-get -y install make cmake
225236

226237
- name: Install GNUStep libobjc2 v1.9
227-
if: contains(matrix.os, 'ubuntu') && steps.extern-cache.outputs.cache-hit != 'true'
238+
if: contains(matrix.runtime, 'gnustep') && steps.extern-cache.outputs.cache-hit != 'true'
228239
run: |
229240
wget https://github.com/gnustep/libobjc2/archive/refs/tags/v1.9.tar.gz
230241
tar -xzf v1.9.tar.gz
@@ -234,7 +245,7 @@ jobs:
234245
make install
235246
236247
- name: Install GNUStep make
237-
if: contains(matrix.os, 'ubuntu') && steps.extern-cache.outputs.cache-hit != 'true'
248+
if: contains(matrix.runtime, 'gnustep') && steps.extern-cache.outputs.cache-hit != 'true'
238249
run: |
239250
wget https://github.com/gnustep/tools-make/archive/refs/tags/make-2_9_0.tar.gz
240251
tar -xzf make-2_9_0.tar.gz
@@ -244,7 +255,7 @@ jobs:
244255
make install
245256
246257
- name: Install GNUStep-Base
247-
if: contains(matrix.os, 'ubuntu') && steps.extern-cache.outputs.cache-hit != 'true'
258+
if: contains(matrix.runtime, 'gnustep') && steps.extern-cache.outputs.cache-hit != 'true'
248259
run: |
249260
wget https://github.com/gnustep/libs-base/archive/refs/tags/base-1_28_0.tar.gz
250261
tar -xzf base-1_28_0.tar.gz
@@ -326,7 +337,7 @@ jobs:
326337
uses: actions-rs/cargo@v1
327338
with:
328339
command: bench
329-
args: ${{ env.ARGS }} ${{ env.TESTARGS }} --bench autorelease
340+
args: ${{ env.ARGS }} ${{ env.TESTARGS }}
330341

331342
- name: Test with unstable features
332343
if: ${{ !matrix.dinghy && matrix.rust.toolchain == 'nightly' }}

block-sys/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ gnustep-2-0 = ["objc-sys/gnustep-2-0", "gnustep-1-9"]
4141
gnustep-2-1 = ["objc-sys/gnustep-2-1", "gnustep-2-0"]
4242

4343
# Link to Microsoft's libobjc2
44-
winobjc = ["objc-sys/winobjc", "gnustep-1-8"]
44+
unstable-winobjc = ["objc-sys/unstable-winobjc", "gnustep-1-8"]
4545

46-
# TODO
47-
objfw = []
46+
# Link to ObjFW
47+
unstable-objfw = []
4848

4949
[dependencies]
5050
objc-sys = { path = "../objc-sys", version = "=0.2.0-alpha.1", default-features = false, optional = true }

block-sys/README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,19 @@ Sources:
7373

7474
### Microsoft's [`WinObjC`](https://github.com/microsoft/WinObjC)
7575

76-
- Feature flag: `winobjc`.
76+
- Feature flag: `unstable-winobjc`.
77+
78+
**Unstable: Hasn't been tested on Windows yet!**
7779

7880
Essentially just [a fork](https://github.com/microsoft/libobjc2) based on
7981
GNUStep's `libobjc2` version 1.8.
8082

8183

82-
### [`ObjFW`](https://github.com/ObjFW/ObjFW) (WIP)
84+
### [`ObjFW`](https://github.com/ObjFW/ObjFW)
85+
86+
- Feature flag: `unstable-objfw`.
8387

84-
- Feature flag: `objfw`.
88+
**Unstable: Doesn't work yet!**
8589

8690
TODO.
8791

block-sys/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ fn main() {
1010
let mut apple = env::var_os("CARGO_FEATURE_APPLE").is_some();
1111
let compiler_rt = env::var_os("CARGO_FEATURE_COMPILER_RT").is_some();
1212
let mut gnustep = env::var_os("CARGO_FEATURE_GNUSTEP_1_7").is_some();
13-
let objfw = env::var_os("CARGO_FEATURE_OBJFW").is_some();
13+
let objfw = env::var_os("CARGO_FEATURE_UNSTABLE_OBJFW").is_some();
1414

1515
if std::env::var("DOCS_RS").is_ok() {
1616
if let "macos" | "ios" | "tvos" | "watchos" = &*target_os {

block2/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ gnustep-1-8 = ["gnustep-1-7", "block-sys/gnustep-1-8"]
2828
gnustep-1-9 = ["gnustep-1-8", "block-sys/gnustep-1-9"]
2929
gnustep-2-0 = ["gnustep-1-9", "block-sys/gnustep-2-0"]
3030
gnustep-2-1 = ["gnustep-2-0", "block-sys/gnustep-2-1"]
31-
winobjc = ["gnustep-1-8", "block-sys/winobjc"]
3231

3332
[dependencies]
3433
objc2-encode = { path = "../objc2-encode", version = "=2.0.0-beta.2", default-features = false }

objc-sys/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ gnustep-2-0 = ["gnustep-1-9"]
4040
gnustep-2-1 = ["gnustep-2-0"]
4141

4242
# Link to Microsoft's libobjc2
43-
winobjc = ["gnustep-1-8"]
43+
unstable-winobjc = ["gnustep-1-8"]
4444

45-
# TODO
46-
objfw = []
45+
# Link to ObjFW
46+
unstable-objfw = []
4747

48-
# Private/unstable features - must not be relied on!
48+
# Private
4949
unstable-exception = ["cc"]
5050

5151
[build-dependencies]

objc-sys/README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,21 @@ chosen using the standard `X_DEPLOYMENT_TARGET` environment variables:
5656
`gnustep-1-8`.
5757

5858

59-
### Window's [`WinObjC`](https://github.com/microsoft/WinObjC)
59+
### Microsoft's [`WinObjC`](https://github.com/microsoft/WinObjC)
6060

61-
- Feature flag: `winobjc`.
61+
- Feature flag: `unstable-winobjc`.
62+
63+
**Unstable: Hasn't been tested on Windows yet!**
6264

6365
This is essentially just [a fork](https://github.com/microsoft/libobjc2) based
6466
on GNUStep's `libobjc2` version 1.8, with very few user-facing changes.
6567

6668

67-
### [`ObjFW`](https://github.com/ObjFW/ObjFW) (WIP)
69+
### [`ObjFW`](https://github.com/ObjFW/ObjFW)
70+
71+
- Feature flag: `unstable-objfw`.
6872

69-
- Feature flag: `objfw`.
73+
**Unstable: Doesn't work yet!**
7074

7175
TODO.
7276

@@ -79,7 +83,7 @@ and `objc_autoreleasePoolPop` is a vital requirement for most applications.
7983

8084
Just so we're being clear, this rules out the GCC [`libobjc`][gcc-libobjc]
8185
runtime (see [this][gcc-objc-support]), the [`mulle-objc`] runtime and
82-
[cocotron]. (But support for [`ObjFW`] and [`darling`] may be added).
86+
[cocotron]. (But support for [`darling`] may be added).
8387
More information on different runtimes can be found in GNUStep's
8488
[Objective-C Compiler and Runtime FAQ][gnustep-faq].
8589

@@ -88,7 +92,6 @@ More information on different runtimes can be found in GNUStep's
8892
[gcc-objc-support]: https://gcc.gnu.org/onlinedocs/gcc/Standards.html#Objective-C-and-Objective-C_002b_002b-Languages
8993
[`mulle-objc`]: https://github.com/mulle-objc/mulle-objc-runtime
9094
[cocotron]: https://cocotron.org/
91-
[`ObjFW`]: https://github.com/ObjFW/ObjFW
9295
[`darling`]: https://github.com/darlinghq/darling-objc4
9396
[gnustep-faq]: http://wiki.gnustep.org/index.php/Objective-C_Compiler_and_Runtime_FAQ
9497

objc-sys/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ fn main() {
7171

7272
let mut apple = env::var_os("CARGO_FEATURE_APPLE").is_some();
7373
let mut gnustep = env::var_os("CARGO_FEATURE_GNUSTEP_1_7").is_some();
74-
let objfw = env::var_os("CARGO_FEATURE_OBJFW").is_some();
74+
let objfw = env::var_os("CARGO_FEATURE_UNSTABLE_OBJFW").is_some();
7575

7676
// Choose defaults when generating docs
7777
if std::env::var("DOCS_RS").is_ok() {
@@ -106,7 +106,7 @@ fn main() {
106106
} else {
107107
GNUStep(1, 7)
108108
}
109-
} else if env::var_os("CARGO_FEATURE_WINOBJC").is_some() {
109+
} else if env::var_os("CARGO_FEATURE_UNSTABLE_WINOBJC").is_some() {
110110
WinObjC
111111
} else if env::var_os("CARGO_FEATURE_GNUSTEP_2_1").is_some() {
112112
GNUStep(2, 1)

objc-sys/src/exception.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ extern_c! {
6161
// objc_exception_get_functions
6262
// objc_exception_set_functions
6363

64-
#[cfg(any(gnustep, winobjc))]
64+
#[cfg(gnustep)]
6565
pub fn objc_exception_rethrow(exc_buf: *mut c_void) -> !;
6666

6767
#[cfg(apple_new)]

objc2-foundation/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ gnustep-1-8 = ["gnustep-1-7", "objc2/gnustep-1-8", "block2?/gnustep-1-8"]
2828
gnustep-1-9 = ["gnustep-1-8", "objc2/gnustep-1-9", "block2?/gnustep-1-9"]
2929
gnustep-2-0 = ["gnustep-1-9", "objc2/gnustep-2-0", "block2?/gnustep-2-0"]
3030
gnustep-2-1 = ["gnustep-2-0", "objc2/gnustep-2-1", "block2?/gnustep-2-1"]
31-
winobjc = ["gnustep-1-8", "objc2/winobjc", "block2?/winobjc"]
3231

3332
[dependencies]
3433
block2 = { path = "../block2", version = "=0.2.0-alpha.3", default-features = false, optional = true }

objc2/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ verify_message = ["malloc"] # TODO: Remove malloc feature here
3838
malloc = ["malloc_buf"]
3939

4040
# Uses nightly features to make AutoreleasePool zero-cost even in debug mode
41-
unstable_autoreleasesafe = []
41+
unstable-autoreleasesafe = []
4242

4343
# Runtime selection. See `objc-sys` for details.
4444
apple = ["objc-sys/apple"]
@@ -47,7 +47,6 @@ gnustep-1-8 = ["gnustep-1-7", "objc-sys/gnustep-1-8"]
4747
gnustep-1-9 = ["gnustep-1-8", "objc-sys/gnustep-1-9"]
4848
gnustep-2-0 = ["gnustep-1-9", "objc-sys/gnustep-2-0"]
4949
gnustep-2-1 = ["gnustep-2-0", "objc-sys/gnustep-2-1"]
50-
winobjc = ["gnustep-1-8", "objc-sys/winobjc"]
5150

5251
[dependencies]
5352
malloc_buf = { version = "1.0", optional = true }

objc2/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
123123
#![no_std]
124124
#![cfg_attr(
125-
feature = "unstable_autoreleasesafe",
125+
feature = "unstable-autoreleasesafe",
126126
feature(negative_impls, auto_traits)
127127
)]
128128
#![warn(elided_lifetimes_in_paths)]

objc2/src/rc/autorelease.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use core::cell::UnsafeCell;
22
use core::ffi::c_void;
33
use core::fmt;
44
use core::marker::PhantomData;
5-
#[cfg(all(debug_assertions, not(feature = "unstable_autoreleasesafe")))]
5+
#[cfg(all(debug_assertions, not(feature = "unstable-autoreleasesafe")))]
66
use std::{cell::RefCell, thread_local, vec::Vec};
77

88
use crate::ffi;
@@ -25,7 +25,7 @@ pub struct AutoreleasePool {
2525
p: PhantomData<*mut UnsafeCell<c_void>>,
2626
}
2727

28-
#[cfg(all(debug_assertions, not(feature = "unstable_autoreleasesafe")))]
28+
#[cfg(all(debug_assertions, not(feature = "unstable-autoreleasesafe")))]
2929
thread_local! {
3030
/// We track the thread's pools to verify that object lifetimes are only
3131
/// taken from the innermost pool.
@@ -49,7 +49,7 @@ impl AutoreleasePool {
4949
unsafe fn new() -> Self {
5050
// TODO: Make this function pub when we're more certain of the API
5151
let context = unsafe { ffi::objc_autoreleasePoolPush() };
52-
#[cfg(all(debug_assertions, not(feature = "unstable_autoreleasesafe")))]
52+
#[cfg(all(debug_assertions, not(feature = "unstable-autoreleasesafe")))]
5353
POOLS.with(|c| c.borrow_mut().push(context));
5454
Self {
5555
context,
@@ -61,7 +61,7 @@ impl AutoreleasePool {
6161
#[inline]
6262
#[doc(hidden)]
6363
pub fn __verify_is_inner(&self) {
64-
#[cfg(all(debug_assertions, not(feature = "unstable_autoreleasesafe")))]
64+
#[cfg(all(debug_assertions, not(feature = "unstable-autoreleasesafe")))]
6565
POOLS.with(|c| {
6666
assert_eq!(
6767
c.borrow().last(),
@@ -140,7 +140,7 @@ impl Drop for AutoreleasePool {
140140
#[inline]
141141
fn drop(&mut self) {
142142
unsafe { ffi::objc_autoreleasePoolPop(self.context) }
143-
#[cfg(all(debug_assertions, not(feature = "unstable_autoreleasesafe")))]
143+
#[cfg(all(debug_assertions, not(feature = "unstable-autoreleasesafe")))]
144144
POOLS.with(|c| {
145145
assert_eq!(
146146
c.borrow_mut().pop(),
@@ -159,15 +159,15 @@ impl fmt::Pointer for AutoreleasePool {
159159

160160
/// We use a macro here so that the documentation is included whether the
161161
/// feature is enabled or not.
162-
#[cfg(not(feature = "unstable_autoreleasesafe"))]
162+
#[cfg(not(feature = "unstable-autoreleasesafe"))]
163163
macro_rules! auto_trait {
164164
{$(#[$fn_meta:meta])* $v:vis unsafe trait AutoreleaseSafe {}} => {
165165
$(#[$fn_meta])*
166166
$v unsafe trait AutoreleaseSafe {}
167167
}
168168
}
169169

170-
#[cfg(feature = "unstable_autoreleasesafe")]
170+
#[cfg(feature = "unstable-autoreleasesafe")]
171171
macro_rules! auto_trait {
172172
{$(#[$fn_meta:meta])* $v:vis unsafe trait AutoreleaseSafe {}} => {
173173
$(#[$fn_meta])*
@@ -179,7 +179,7 @@ auto_trait! {
179179
/// Marks types that are safe to pass across the closure in an
180180
/// [`autoreleasepool`].
181181
///
182-
/// With the `unstable_autoreleasesafe` feature enabled, this is an auto
182+
/// With the `unstable-autoreleasesafe` feature enabled, this is an auto
183183
/// trait that is implemented for all types except [`AutoreleasePool`].
184184
///
185185
/// Otherwise it is just a dummy trait that is implemented for all types;
@@ -194,14 +194,14 @@ auto_trait! {
194194
/// likewise, this should be negatively implemented for that.
195195
///
196196
/// This can easily be accomplished with an `PhantomData<AutoreleasePool>`
197-
/// if the `unstable_autoreleasesafe` feature is enabled.
197+
/// if the `unstable-autoreleasesafe` feature is enabled.
198198
pub unsafe trait AutoreleaseSafe {}
199199
}
200200

201-
#[cfg(not(feature = "unstable_autoreleasesafe"))]
201+
#[cfg(not(feature = "unstable-autoreleasesafe"))]
202202
unsafe impl<T: ?Sized> AutoreleaseSafe for T {}
203203

204-
#[cfg(feature = "unstable_autoreleasesafe")]
204+
#[cfg(feature = "unstable-autoreleasesafe")]
205205
impl !AutoreleaseSafe for AutoreleasePool {}
206206

207207
/// Execute `f` in the context of a new autorelease pool. The pool is
@@ -216,7 +216,7 @@ impl !AutoreleaseSafe for AutoreleasePool {}
216216
/// The given reference must not be used in an inner `autoreleasepool`,
217217
/// doing so will panic with debug assertions enabled, and be a compile
218218
/// error in a future release. You can test the compile error with the
219-
/// `unstable_autoreleasesafe` crate feature on nightly Rust.
219+
/// `unstable-autoreleasesafe` crate feature on nightly Rust.
220220
///
221221
/// # Examples
222222
///
@@ -266,8 +266,8 @@ impl !AutoreleaseSafe for AutoreleasePool {}
266266
/// Incorrect usage which panics (with debug assertions enabled) because we
267267
/// tried to pass an outer pool to an inner pool:
268268
///
269-
#[cfg_attr(feature = "unstable_autoreleasesafe", doc = "```compile_fail")]
270-
#[cfg_attr(not(feature = "unstable_autoreleasesafe"), doc = "```should_panic")]
269+
#[cfg_attr(feature = "unstable-autoreleasesafe", doc = "```compile_fail")]
270+
#[cfg_attr(not(feature = "unstable-autoreleasesafe"), doc = "```should_panic")]
271271
/// # use objc2::{class, msg_send};
272272
/// # use objc2::rc::{autoreleasepool, AutoreleasePool};
273273
/// # use objc2::runtime::Object;
@@ -300,7 +300,7 @@ where
300300
f(&pool)
301301
}
302302

303-
#[cfg(all(test, feature = "unstable_autoreleasesafe"))]
303+
#[cfg(all(test, feature = "unstable-autoreleasesafe"))]
304304
mod tests {
305305
use super::AutoreleaseSafe;
306306
use crate::runtime::Object;

tests/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ gnustep-1-8 = ["gnustep-1-7", "block2/gnustep-1-8", "objc2-foundation/gnustep-1-
2929
gnustep-1-9 = ["gnustep-1-8", "block2/gnustep-1-9", "objc2-foundation/gnustep-1-9"]
3030
gnustep-2-0 = ["gnustep-1-9", "block2/gnustep-2-0", "objc2-foundation/gnustep-2-0"]
3131
gnustep-2-1 = ["gnustep-2-0", "block2/gnustep-2-1", "objc2-foundation/gnustep-2-1"]
32-
winobjc = ["gnustep-1-8", "block2/winobjc", "objc2-foundation/winobjc"]
3332

3433
malloc = ["objc2/malloc"]
3534

tests/assembly/test_msg_send_zero_cost/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,3 @@ gnustep-1-8 = ["gnustep-1-7", "objc2/gnustep-1-8"]
1919
gnustep-1-9 = ["gnustep-1-8", "objc2/gnustep-1-9"]
2020
gnustep-2-0 = ["gnustep-1-9", "objc2/gnustep-2-0"]
2121
gnustep-2-1 = ["gnustep-2-0", "objc2/gnustep-2-1"]
22-
winobjc = ["gnustep-1-8", "objc2/winobjc"]

tests/assembly/test_retain_autoreleased/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,3 @@ gnustep-1-8 = ["gnustep-1-7", "objc2/gnustep-1-8"]
1919
gnustep-1-9 = ["gnustep-1-8", "objc2/gnustep-1-9"]
2020
gnustep-2-0 = ["gnustep-1-9", "objc2/gnustep-2-0"]
2121
gnustep-2-1 = ["gnustep-2-0", "objc2/gnustep-2-1"]
22-
winobjc = ["gnustep-1-8", "objc2/winobjc"]

0 commit comments

Comments
 (0)