Skip to content

Commit b6b9f9c

Browse files
committed
Merge remote-tracking branch '0fork/crate-runtime-features'
2 parents 2b1eefb + 29c3d97 commit b6b9f9c

File tree

34 files changed

+213
-189
lines changed

34 files changed

+213
-189
lines changed

.github/workflows/ci.yml

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,13 @@ jobs:
7979
- name: Test GNUStep
8080
os: ubuntu-latest
8181
target: x86_64-unknown-linux-gnu
82-
host-args: --features block-sys/gnustep-1-9,objc-sys/gnustep-1-9
83-
args: --features block-sys/gnustep-1-9,objc-sys/gnustep-1-9
82+
runtime: gnustep-1-9
8483
- name: Test GNUStep 32bit
8584
os: ubuntu-latest
8685
target: i686-unknown-linux-gnu
8786
cflags: -m32
8887
configureflags: --target=x86-pc-linux-gnu
89-
host-args: --features block-sys/gnustep-1-9,objc-sys/gnustep-1-9
90-
args: --features block-sys/gnustep-1-9,objc-sys/gnustep-1-9
88+
runtime: gnustep-1-9
9189
- name: Test iOS simulator x86 64bit
9290
os: macos-11
9391
target: x86_64-apple-ios
@@ -134,8 +132,10 @@ jobs:
134132
CXXFLAGS: ${{ matrix.cflags }}
135133
ASMFLAGS: ${{ matrix.cflags }}
136134
LDFLAGS: ${{ matrix.cflags }}
135+
HOSTARGS: --no-default-features --features ${{ matrix.runtime || 'apple' }}
136+
ARGS: --no-default-features --features ${{ matrix.runtime || 'apple' }} ${{ matrix.args }}
137137
# Use --no-fail-fast, except with dinghy
138-
TESTARGS: ${{ matrix.dinghy && ' ' || '--no-fail-fast' }} ${{ matrix.args }} ${{ matrix.test-args }}
138+
TESTARGS: ${{ matrix.dinghy && ' ' || '--no-fail-fast' }} ${{ matrix.test-args }}
139139

140140
runs-on: ${{ matrix.os }}
141141

@@ -169,7 +169,7 @@ jobs:
169169
~/extern/include
170170
~/extern/sdk
171171
# Change this key if we start caching more things
172-
key: ${{ matrix.name }}-extern-v1
172+
key: ${{ matrix.name }}-extern-v2
173173

174174
- name: Setup environment
175175
# These add to PATH-like variables, so they can always be set
@@ -273,49 +273,51 @@ jobs:
273273

274274
- name: Install Cargo Dinghy
275275
if: matrix.dinghy && steps.extern-cache.outputs.cache-hit != 'true'
276-
run: cargo install cargo-dinghy --version=^0.4 --root=$HOME/extern --target=x86_64-apple-darwin
276+
# TODO: Replace once cargo dinghy gets updated
277+
# cargo install cargo-dinghy --version=^0.4 --root=$HOME/extern --target=x86_64-apple-darwin
278+
run: cargo install --git https://github.com/madsmtm/dinghy.git --branch update-cargo --bin cargo-dinghy --root=$HOME/extern --target=x86_64-apple-darwin
277279

278280
- name: Build
279281
if: ${{ !matrix.dinghy }}
280282
uses: actions-rs/cargo@v1
281283
with:
282284
command: build
283-
args: ${{ matrix.args }}
285+
args: ${{ env.ARGS }}
284286

285287
- name: Check documentation
286288
if: ${{ !matrix.dinghy }}
287289
uses: actions-rs/cargo@v1
288290
with:
289291
command: doc
290-
args: --no-deps --document-private-items ${{ matrix.args }}
292+
args: ${{ env.ARGS }} --no-deps --document-private-items
291293

292294
- name: Test without features
293295
if: ${{ !matrix.dinghy }}
294296
uses: actions-rs/cargo@v1
295297
with:
296298
command: test
297-
args: --no-default-features ${{ env.TESTARGS }}
299+
args: ${{ env.ARGS }} ${{ env.TESTARGS }}
298300

299301
- name: Test with features
300302
if: ${{ !matrix.dinghy }}
301303
uses: actions-rs/cargo@v1
302304
with:
303305
command: test
304-
args: --features ${{ env.FEATURES }} ${{ env.TESTARGS }}
306+
args: ${{ env.ARGS }} ${{ env.TESTARGS }} --features ${{ env.FEATURES }}
305307

306-
- name: Test in release mode
308+
- name: Test in release mode without features
307309
if: ${{ !matrix.dinghy }}
308310
uses: actions-rs/cargo@v1
309311
with:
310312
command: test
311-
args: --no-default-features ${{ env.TESTARGS }} --release
313+
args: ${{ env.ARGS }} ${{ env.TESTARGS }} --release
312314

313315
- name: Test in release mode with features
314316
if: ${{ !matrix.dinghy }}
315317
uses: actions-rs/cargo@v1
316318
with:
317319
command: test
318-
args: --features ${{ env.FEATURES }} ${{ env.TESTARGS }} --release
320+
args: ${{ env.ARGS }} ${{ env.TESTARGS }} --features ${{ env.FEATURES }} --release
319321

320322
- name: Run benchmarks
321323
# Difficult to install Valgrind on macOS
@@ -324,15 +326,15 @@ jobs:
324326
uses: actions-rs/cargo@v1
325327
with:
326328
command: bench
327-
args: --bench autorelease ${{ env.TESTARGS }}
329+
args: ${{ env.ARGS }} ${{ env.TESTARGS }} --bench autorelease
328330

329331
- name: Test with unstable features
330332
if: ${{ !matrix.dinghy && matrix.rust.toolchain == 'nightly' }}
331333
uses: actions-rs/cargo@v1
332334
with:
333335
command: test
334336
# Not using --all-features because that would enable e.g. gnustep
335-
args: --features ${{ env.FEATURES }},${{ env.UNSTABLE_FEATURES }} ${{ env.TESTARGS }}
337+
args: ${{ env.ARGS }} ${{ env.TESTARGS }} --features ${{ env.FEATURES }},${{ env.UNSTABLE_FEATURES }}
336338

337339
- name: Run assembly tests
338340
# Not run on GNUStep yet since a lot of function labels are mangled and
@@ -343,28 +345,26 @@ jobs:
343345
run:
344346
export HOST_TARGET=$(rustc -vV | grep host | cut -f2 -d' ')
345347

346-
cargo run ${{ matrix.host-args }} --features assembly --target=$HOST_TARGET test_assembly ${{ matrix.args }}
348+
cargo run ${{ env.HOSTARGS }} --features assembly --target=$HOST_TARGET test_assembly ${{ env.ARGS }}
347349

348-
- name: Run Cargo Dinghy
350+
- name: Launch XCode Simulator
349351
if: matrix.dinghy
350352
run: |
351-
# Launch the simulator
353+
# Get system info
352354
xcrun simctl list runtimes
355+
356+
# Launch the simulator
353357
RUNTIME_ID=$(xcrun simctl list runtimes | grep iOS | cut -d ' ' -f 7 | tail -1)
354358
export SIM_ID=$(xcrun simctl create My-iphone7 com.apple.CoreSimulator.SimDeviceType.iPhone-7 $RUNTIME_ID)
355359
xcrun simctl boot $SIM_ID
356360
357-
# Build
358-
cargo dinghy --device=$SIM_ID build
359-
360-
# Run tests
361-
cargo dinghy --device=$SIM_ID test --no-default-features
362-
cargo dinghy --device=$SIM_ID test --release
361+
- name: Build w. Cargo Dinghy
362+
if: matrix.dinghy
363+
run: cargo dinghy --device=$SIM_ID build ${{ matrix.args }}
363364

364-
# Enable a few features. We're doing it this way because cargo dingy
365-
# doesn't support specifying features from a workspace.
366-
sed -i -e '/\[features\]/a\
367-
default = ["exception", "verify_message", "catch_all"]
368-
' objc2/Cargo.toml
369-
cargo dinghy --device=$SIM_ID test
370-
cargo dinghy --device=$SIM_ID test --release
365+
- name: Test w. Cargo Dinghy
366+
if: matrix.dinghy
367+
# Note that we're not testing more complex configurations, since that
368+
# takes a very long time to run in CI, and that impedes general
369+
# development work.
370+
run: cargo dinghy --device=$SIM_ID test ${{ matrix.args }}

block-sys/CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
88

99
### Changed
1010
* **BREAKING**: Changed `links` key from `block` to `block_0_0` for better
11-
future compatibility, until we reach 1.0 (so `DEP_BLOCK_X` in build scripts
12-
becomes `DEP_BLOCK_0_0_X`).
11+
future compatibility, until we reach 1.0 (so `DEP_BLOCK_CC_ARGS` in build
12+
scripts becomes `DEP_BLOCK_0_0_CC_ARGS`).
13+
* **BREAKING**: Apple's runtime is now always the default.
1314

1415

1516
## 0.0.3 - 2022-01-03

block-sys/Cargo.toml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@ links = "block_0_0"
2323
build = "build.rs"
2424

2525
[features]
26+
# The default runtime is Apple's. Other platforms will probably error if the
27+
# correct feature flag is not specified.
28+
default = ["apple"]
29+
2630
# Link to Apple's libclosure (exists in libSystem)
27-
#
28-
# This is the default on Apple platforms
2931
apple = []
3032

3133
# Link to libBlocksRuntime from compiler-rt
32-
#
33-
# This is the default on non-Apple platforms
3434
compiler-rt = []
3535

3636
# Link to GNUStep's libobjc2 (which contains the block implementation)
37-
gnustep-1-7 = ["objc-sys/gnustep-1-7"]
37+
gnustep-1-7 = ["objc-sys", "objc-sys/gnustep-1-7"]
3838
gnustep-1-8 = ["objc-sys/gnustep-1-8", "gnustep-1-7"]
3939
gnustep-1-9 = ["objc-sys/gnustep-1-9", "gnustep-1-8"]
4040
gnustep-2-0 = ["objc-sys/gnustep-2-0", "gnustep-1-9"]
@@ -47,7 +47,8 @@ winobjc = ["objc-sys/winobjc", "gnustep-1-8"]
4747
objfw = []
4848

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

5252
[package.metadata.docs.rs]
5353
default-target = "x86_64-apple-darwin"
54+
no-default-features = true

block-sys/README.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,17 @@ several different helper functions), the most important aspect being that the
2020
libraries are named differently, so the linking must take that into account.
2121

2222
The user can choose the desired runtime by using the relevant cargo feature
23-
flags, see the following sections. Note that if the `objc-sys` crate is
24-
present in the module tree, this should have the same feature flag enabled as
25-
that.
23+
flags, see the following sections (might have to disable the default `apple`
24+
feature first). Note that if the `objc-sys` crate is present in the module
25+
tree, this should have the same feature flag enabled as that.
2626

2727

2828
### Apple's [`libclosure`](https://github.com/apple-oss-distributions/libclosure)
2929

3030
- Feature flag: `apple`.
3131

3232
This is naturally the most sophisticated runtime, and it has quite a lot more
33-
features than the specification mandates. This is used by default on Apple
34-
platforms when no feature flags are specified.
33+
features than the specification mandates. This is used by default.
3534

3635
The minimum required operating system versions are as follows:
3736
- macOS: `10.6`
@@ -46,9 +45,6 @@ Though in practice Rust itself requires higher versions than this.
4645

4746
- Feature flag: `compiler-rt`.
4847

49-
This is the default runtime on all non-Apple platforms when no feature flags
50-
are specified.
51-
5248
This is effectively just a copy of Apple's older (around macOS 10.6) runtime,
5349
and is now used in [Swift's `libdispatch`] and [Swift's Foundation] as well.
5450

block-sys/build.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,23 @@ fn main() {
55
// Only rerun if this file changes; the script doesn't depend on our code
66
println!("cargo:rerun-if-changed=build.rs");
77

8+
let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap();
9+
810
let mut apple = env::var_os("CARGO_FEATURE_APPLE").is_some();
9-
let mut compiler_rt = env::var_os("CARGO_FEATURE_COMPILER_RT").is_some();
10-
let gnustep = env::var_os("CARGO_FEATURE_GNUSTEP_1_7").is_some();
11+
let compiler_rt = env::var_os("CARGO_FEATURE_COMPILER_RT").is_some();
12+
let mut gnustep = env::var_os("CARGO_FEATURE_GNUSTEP_1_7").is_some();
1113
let objfw = env::var_os("CARGO_FEATURE_OBJFW").is_some();
1214

13-
if let (false, false, false, false) = (apple, compiler_rt, gnustep, objfw) {
14-
let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap();
15+
if std::env::var("DOCS_RS").is_ok() {
1516
if let "macos" | "ios" | "tvos" | "watchos" = &*target_os {
1617
apple = true;
1718
// Add cheaty #[cfg(feature = "apple")] directive
1819
println!("cargo:rustc-cfg=feature=\"apple\"");
1920
} else {
20-
compiler_rt = true;
21-
// Add cheaty #[cfg(feature = "compiler-rt")] directive
22-
println!("cargo:rustc-cfg=feature=\"compiler-rt\"");
21+
// Also winobjc
22+
gnustep = true;
23+
// Add cheaty #[cfg(feature = "gnustep-1-7")] directive
24+
println!("cargo:rustc-cfg=feature=\"gnustep-1-7\"");
2325
}
2426
}
2527

@@ -61,7 +63,9 @@ fn main() {
6163
unimplemented!("ObjFW is not yet supported")
6264
}
6365
// Checked in if-let above
64-
(false, false, false, false) => unreachable!(),
66+
(false, false, false, false) => {
67+
panic!("Invalid feature combination; at least one runtime must be selected!")
68+
}
6569
(_, _, _, _) => panic!("Invalid feature combination; only one runtime may be selected!"),
6670
}
6771

block2/Cargo.toml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,22 @@ repository = "https://github.com/madsmtm/objc2"
1717
documentation = "https://docs.rs/block2/"
1818
license = "MIT"
1919

20+
[features]
21+
default = ["apple"]
22+
23+
# Runtime selection. Default is `apple`. See `block-sys` for details.
24+
apple = ["block-sys/apple"]
25+
compiler-rt = ["block-sys/compiler-rt"]
26+
gnustep-1-7 = ["block-sys/gnustep-1-7"]
27+
gnustep-1-8 = ["gnustep-1-7", "block-sys/gnustep-1-8"]
28+
gnustep-1-9 = ["gnustep-1-8", "block-sys/gnustep-1-9"]
29+
gnustep-2-0 = ["gnustep-1-9", "block-sys/gnustep-2-0"]
30+
gnustep-2-1 = ["gnustep-2-0", "block-sys/gnustep-2-1"]
31+
winobjc = ["gnustep-1-8", "block-sys/winobjc"]
32+
2033
[dependencies]
21-
objc2-encode = { path = "../objc2-encode", version = "=2.0.0-beta.2" }
22-
block-sys = { path = "../block-sys", version = "0.0.3" }
34+
objc2-encode = { path = "../objc2-encode", version = "=2.0.0-beta.2", default-features = false }
35+
block-sys = { path = "../block-sys", version = "0.0.3", default-features = false }
2336

2437
[package.metadata.docs.rs]
2538
default-target = "x86_64-apple-darwin"

objc-sys/CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
88

99
### Changed
1010
* **BREAKING**: Changed `links` key from `objc` to `objc_0_2` for better
11-
future compatibility, until we reach 1.0 (so `DEP_OBJC_X` in build scripts
12-
becomes `DEP_OBJC_0_2_X`).
11+
future compatibility, until we reach 1.0 (so `DEP_OBJC_CC_ARGS` in build
12+
scripts becomes `DEP_OBJC_0_2_CC_ARGS`).
13+
* **BREAKING**: Apple's runtime is now always the default.
1314

1415
### Removed
1516
* **BREAKING**: Removed type aliases `Class`, `Ivar`, `Method` and `Protocol`
@@ -18,6 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1819
* **BREAKING**: Removed `objc_property_t`.
1920
* **BREAKING**: Removed `objc_hook_getClass` and `objc_hook_lazyClassNamer`
2021
type aliases (for now).
22+
* **BREAKING**: Removed `DEP_OBJC_RUNTIME` build script output.
2123

2224

2325
## 0.2.0-alpha.1 - 2022-01-03

objc-sys/Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ readme = "README.md"
2222
links = "objc_0_2"
2323
build = "build.rs"
2424

25-
# The default is `apple` on Apple platforms; all other platforms will error
26-
# if no feature flag is specified.
2725
[features]
26+
# The default runtime is Apple's. Other platforms will probably error if the
27+
# correct feature flag is not specified.
28+
default = ["apple"]
29+
2830
# Link to Apple's objc4
2931
apple = []
3032

@@ -43,6 +45,7 @@ objfw = []
4345

4446
[package.metadata.docs.rs]
4547
default-target = "x86_64-apple-darwin"
48+
no-default-features = true
4649

4750
targets = [
4851
# MacOS

objc-sys/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ see that for related crates.
1616
Objective-C has a runtime, different implementations of said runtime exist,
1717
and they act in slightly different ways. By default, Apple platforms link to
1818
Apple's runtime, but if you're using another runtime you must tell it to this
19-
library using feature flags.
19+
library using feature flags (you might have to disable the default `apple`
20+
feature first).
2021

2122
One could ask, why even bother supporting other runtimes? To that, there's a
2223
simple answer: _Robustness_. By testing with these alternative runtimes in CI,
@@ -29,8 +30,7 @@ iOS versions.
2930

3031
- Feature flag: `apple`.
3132

32-
This is used by default on Apple platforms when no other feature flags are
33-
specified.
33+
This is used by default.
3434

3535
The supported runtime version (higher versions lets the compiler enable newer
3636
optimizations, at the cost of not supporting older operating systems) can be

0 commit comments

Comments
 (0)