Skip to content

Commit f4fa04b

Browse files
committed
Use gnustep_libobjc2_src in objc2_sys when the vendor_gnustep feature is enabled
1 parent ac5ff55 commit f4fa04b

File tree

4 files changed

+27
-23
lines changed

4 files changed

+27
-23
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,6 @@ jobs:
7777
command: check
7878
args: --verbose --no-default-features
7979

80-
- name: Install GNUStep libobjc2
81-
if: contains(matrix.platform.os, 'ubuntu')
82-
run: |
83-
wget https://github.com/gnustep/libobjc2/archive/refs/tags/v1.9.tar.gz
84-
tar -xzf v1.9.tar.gz
85-
mkdir libobjc2-1.9/build
86-
cd libobjc2-1.9/build
87-
export CC="clang"
88-
export CXX="clang++"
89-
cmake ../
90-
sudo make install
91-
9280
- name: Install GNUStep make
9381
if: contains(matrix.platform.os, 'ubuntu')
9482
run: |
@@ -122,7 +110,7 @@ jobs:
122110
with:
123111
command: test
124112
# Temporary fix
125-
args: --verbose --no-fail-fast --no-default-features --package objc2_sys --package objc2 --package objc2_encode --package objc2_foundation
113+
args: --verbose --no-fail-fast --no-default-features --features objc2_sys/vendor_gnustep --package objc2_sys --package objc2 --package objc2_encode --package objc2_foundation
126114

127115
- name: Test
128116
if: ${{ !contains(matrix.platform.os, 'ubuntu') }}

gnustep_libobjc2_src/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22

33
Source of GNUStep's libobjc2 and logic to build it for Rust.
44

5-
Using `clang` with at least version `8.0.0` is recommended. You can specify your desired compiler using the `CC` and `CXX` environment variables.
5+
You probably want to use `objc2_sys`, but this is kept separate from that so
6+
that users don't download the entire GNUStep source when they don't need to.
7+
8+
Using `clang` with at least version `8.0.0` is recommended. You can specify
9+
your desired compiler using the `CC` and `CXX` environment variables.

objc2_sys/Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,10 @@ readme = "README.md"
2727
# See https://doc.rust-lang.org/cargo/reference/build-scripts.html#overriding-build-scripts
2828
links = "objc"
2929
build = "build.rs"
30+
31+
[features]
32+
# If enabled, GNUStep's libobjc2 will be compiled and linked from source
33+
vendor_gnustep = ["gnustep_libobjc2_src"]
34+
35+
[build-dependencies]
36+
gnustep_libobjc2_src = { path = "../gnustep_libobjc2_src", optional = true }

objc2_sys/build.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
1-
use std::env;
1+
#[cfg(feature = "vendor_gnustep")]
2+
fn main() {
3+
let artifacts = gnustep_libobjc2_src::build();
4+
artifacts.print_cargo_metadata();
5+
println!("cargo:rustc-cfg=gnustep");
6+
}
27

8+
#[cfg(not(feature = "vendor_gnustep"))]
39
fn main() {
410
// Only rerun if this file changes; the script doesn't depend on our code
511
println!("cargo:rerun-if-changed=build.rs");
6-
// Link to libobjc
7-
println!("cargo:rustc-link-lib=dylib=objc");
812

9-
let target_vendor = env::var("CARGO_CFG_TARGET_VENDOR").unwrap();
13+
let target_vendor = std::env::var("CARGO_CFG_TARGET_VENDOR").unwrap();
1014

11-
// Adds useful #[cfg(apple)] and #[cfg(gnustep)] directives
1215
if target_vendor == "apple" {
16+
// Add #[cfg(apple)] directive
1317
println!("cargo:rustc-cfg=apple");
1418
} else {
1519
// TODO: Are there other possibilities than GNUStep? Airyx? Is it
1620
// possible to use Apple's open source objc4 on other platforms?
21+
22+
// Add #[cfg(gnustep)] directive
1723
println!("cargo:rustc-cfg=gnustep");
18-
// TODO: Should we vendor GNUStep's libobjc2?
19-
// Using Cargo.toml:
20-
// [target.'cfg(not(target_vendor = "apple"))'.build-dependencies]
21-
// cc = "1.0"
2224
}
25+
26+
// Link to libobjc
27+
println!("cargo:rustc-link-lib=dylib=objc");
2328
}

0 commit comments

Comments
 (0)