Skip to content

Commit 4ef1c0e

Browse files
authored
Merge pull request #45 from madsmtm/sys-crates
Better build script setup
2 parents a680abd + bb150e4 commit 4ef1c0e

File tree

28 files changed

+525
-249
lines changed

28 files changed

+525
-249
lines changed

.github/workflows/apple.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Apple
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
8+
env:
9+
CARGO_TERM_COLOR: always
10+
RUST_BACKTRACE: 1
11+
# Faster compilation and error on warnings
12+
RUSTFLAGS: "-C debuginfo=0 -D warnings"
13+
14+
jobs:
15+
fmt:
16+
name: Check formatting
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v2
20+
- name: Check formatting
21+
uses: actions-rs/cargo@v1
22+
with:
23+
command: fmt
24+
args: -- --check
25+
26+
test:
27+
name: Test
28+
strategy:
29+
matrix:
30+
platform:
31+
- { os: macos-10.15 }
32+
- { os: macos-11 }
33+
# - { target: x86_64-apple-ios, os: macos-latest, }
34+
# - { target: aarch64-apple-ios, os: macos-latest, }
35+
36+
runs-on: ${{ matrix.platform.os }}
37+
38+
steps:
39+
- uses: actions/checkout@v2
40+
41+
- name: Cache Rust
42+
uses: actions/cache@v2
43+
with:
44+
path: |
45+
~/.cargo/
46+
target/
47+
key: ${{ matrix.platform.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}
48+
restore-keys: |
49+
${{ matrix.platform.os }}-cargo-
50+
51+
- name: Install different Rust toolchain
52+
# A default toolchain is already installed
53+
if: matrix.platform.target
54+
uses: actions-rs/toolchain@v1
55+
with:
56+
toolchain: stable
57+
target: ${{ matrix.platform.target }}
58+
profile: minimal
59+
override: true
60+
61+
- name: Check documentation
62+
uses: actions-rs/cargo@v1
63+
with:
64+
# TODO: Disallow warnings here
65+
command: doc
66+
args: --verbose --no-deps --document-private-items
67+
68+
- name: Test without features
69+
uses: actions-rs/cargo@v1
70+
with:
71+
command: test
72+
args: --verbose --no-fail-fast --no-default-features
73+
74+
- name: Test with features
75+
uses: actions-rs/cargo@v1
76+
with:
77+
command: test
78+
# Not using --all-features because some features are nightly-only
79+
args: --verbose --no-fail-fast --features block,exception,verify_message

.github/workflows/ci.yml

Lines changed: 0 additions & 140 deletions
This file was deleted.

.github/workflows/gnustep.yml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: GNUStep
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
8+
env:
9+
CARGO_TERM_COLOR: always
10+
RUST_BACKTRACE: 1
11+
# Faster compilation and error on warnings
12+
RUSTFLAGS: "-C debuginfo=0 -D warnings"
13+
CC: clang
14+
CXX: clang++
15+
16+
jobs:
17+
test:
18+
name: Test
19+
# TODO: 32bit and gcc-multilib
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- uses: actions/checkout@v2
24+
25+
- name: Install Clang
26+
run: sudo apt-get install clang
27+
28+
- name: Cache GNUStep
29+
id: cache-gnustep
30+
uses: actions/cache@v2
31+
with:
32+
# Ideally I would have just cached build-files, and then rerun make
33+
# every time, letting it figure out what's changed. But GNUStep-Base
34+
# ./configure invalidates the cache, which makes it very hard to
35+
# know when to rebuild and when not to.
36+
# So instead we just cache the final output:
37+
# - lib/libobjc.so
38+
# - lib/libgnustep-base.so
39+
# - include/Foundation/*
40+
# - include/objc/*
41+
# - ...
42+
path: |
43+
~/gnustep/lib
44+
~/gnustep/include
45+
key: gnustep-libobjc2_1.9-make_2.9.0-base_1.28.0
46+
47+
- name: Setup environment
48+
run: |
49+
mkdir -p $HOME/gnustep
50+
echo "PATH=$HOME/gnustep/bin:$PATH" >> $GITHUB_ENV
51+
echo "LIBRARY_PATH=$HOME/gnustep/lib:$LIBRARY_PATH" >> $GITHUB_ENV
52+
echo "LD_LIBRARY_PATH=$HOME/gnustep/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
53+
echo "CPATH=$HOME/gnustep/include:$CPATH" >> $GITHUB_ENV
54+
ls -al ~/gnustep/* || true # Ignore failures
55+
56+
- name: Install Make
57+
if: steps.cache-gnustep.outputs.cache-hit != 'true'
58+
run: sudo apt-get install make
59+
60+
- name: Install GNUStep libobjc2
61+
if: steps.cache-gnustep.outputs.cache-hit != 'true'
62+
run: |
63+
wget https://github.com/gnustep/libobjc2/archive/refs/tags/v1.9.tar.gz
64+
tar -xzf v1.9.tar.gz
65+
mkdir -p libobjc2-1.9/build
66+
cd libobjc2-1.9/build
67+
cmake -Wno-dev -DCMAKE_INSTALL_PREFIX=$HOME/gnustep -DTESTS=OFF ..
68+
make install
69+
70+
- name: Install GNUStep make
71+
if: steps.cache-gnustep.outputs.cache-hit != 'true'
72+
run: |
73+
wget https://github.com/gnustep/tools-make/archive/refs/tags/make-2_9_0.tar.gz
74+
tar -xzf make-2_9_0.tar.gz
75+
mkdir -p tools-make-make-2_9_0/build
76+
cd tools-make-make-2_9_0/build
77+
../configure --prefix=$HOME/gnustep --with-library-combo=ng-gnu-gnu
78+
make install
79+
80+
- name: Install GNUStep-Base
81+
if: steps.cache-gnustep.outputs.cache-hit != 'true'
82+
run: |
83+
wget https://github.com/gnustep/libs-base/archive/refs/tags/base-1_28_0.tar.gz
84+
tar -xzf base-1_28_0.tar.gz
85+
cd libs-base-base-1_28_0
86+
./configure --prefix=$HOME/gnustep --disable-tls --disable-xslt
87+
make install
88+
ls -al $HOME/gnustep/*
89+
90+
- name: Cache Rust
91+
uses: actions/cache@v2
92+
with:
93+
path: |
94+
~/.cargo/
95+
target/
96+
key: gnustep-cargo-${{ hashFiles('**/Cargo.toml') }}
97+
restore-keys: |
98+
gnustep-cargo-
99+
100+
- name: Run checks
101+
uses: actions-rs/cargo@v1
102+
with:
103+
command: check
104+
args: --verbose --no-default-features
105+
106+
- name: Test GNUStep
107+
uses: actions-rs/cargo@v1
108+
with:
109+
command: test
110+
# Temporary fix
111+
args: --verbose --no-fail-fast --no-default-features --package objc2_sys --package objc2 --package objc2_encode --package objc2_exception --package objc2_foundation
112+
113+
- name: Test GNUStep with features
114+
uses: actions-rs/cargo@v1
115+
with:
116+
command: test
117+
# Temporary fix
118+
args: --verbose --no-fail-fast --no-default-features --features exception,verify_message --package objc2_sys --package objc2 --package objc2_encode --package objc2_exception --package objc2_foundation

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# [![Rust + \[Obj-C\]](assets/logo-small.png)](https://github.com/madsmtm/objc2) Objective-C in Rust
22

33
[![License](https://badgen.net/badge/license/MIT/blue)](../LICENSE.txt)
4-
[![CI Status](https://github.com/madsmtm/objc2/workflows/CI/badge.svg)](https://github.com/madsmtm/objc2/actions)
4+
[![Apple CI](https://github.com/madsmtm/objc2/actions/workflows/apple.yml/badge.svg)](https://github.com/madsmtm/objc2/actions/workflows/apple.yml)
5+
[![GNUStep CI](https://github.com/madsmtm/objc2/actions/workflows/gnustep.yml/badge.svg)](https://github.com/madsmtm/objc2/actions/workflows/gnustep.yml)

objc2/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ exclude = [
2121
"tests-ios/**",
2222
]
2323

24+
build = "build.rs"
25+
2426
[features]
2527
exception = ["objc2_exception"]
2628
verify_message = []

objc2/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
[![Latest version](https://badgen.net/crates/v/objc2)](https://crates.io/crates/objc2)
44
[![License](https://badgen.net/badge/license/MIT/blue)](../LICENSE.txt)
55
[![Documentation](https://docs.rs/objc2/badge.svg)](https://docs.rs/objc2/)
6-
[![CI Status](https://github.com/madsmtm/objc2/workflows/CI/badge.svg)](https://github.com/madsmtm/objc2/actions)
6+
[![Apple CI](https://github.com/madsmtm/objc2/actions/workflows/apple.yml/badge.svg)](https://github.com/madsmtm/objc2/actions/workflows/apple.yml)
7+
[![GNUStep CI](https://github.com/madsmtm/objc2/actions/workflows/gnustep.yml/badge.svg)](https://github.com/madsmtm/objc2/actions/workflows/gnustep.yml)
78

89
Objective-C Runtime bindings and wrapper for Rust.
910

objc2/build.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
use std::env;
2+
3+
fn main() {
4+
// The script doesn't depend on our code
5+
println!("cargo:rerun-if-changed=build.rs");
6+
7+
let runtime = env::var("DEP_OBJC_RUNTIME").unwrap();
8+
println!("cargo:rustc-cfg={}", runtime);
9+
}

objc2/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ mod test_utils;
106106
///
107107
/// This is a temporary solution to make our CI work for now!
108108
#[doc(hidden)]
109-
#[cfg(not(target_vendor = "apple"))]
109+
#[cfg(any(gnustep, winobjc))]
110110
pub mod __gnustep_hack {
111111
use super::runtime::Class;
112112

objc2/src/message/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ unsafe fn conditional_try<R: Encode>(f: impl FnOnce() -> R) -> Result<R, Message
2828

2929
mod verify;
3030

31-
#[cfg(target_vendor = "apple")]
31+
#[cfg(apple)]
3232
#[path = "apple/mod.rs"]
3333
mod platform;
34-
#[cfg(not(target_vendor = "apple"))]
34+
#[cfg(any(gnustep, winobjc))]
3535
#[path = "gnustep.rs"]
3636
mod platform;
3737

0 commit comments

Comments
 (0)