Skip to content

Commit e2dc4b3

Browse files
authored
Merge pull request #167 from madsmtm/libobjc2-more-versions
Test `libobjc2` v2.0 and v2.1 as well
2 parents e2064a7 + 5d72415 commit e2dc4b3

File tree

2 files changed

+41
-11
lines changed

2 files changed

+41
-11
lines changed

.github/workflows/ci.yml

+33-9
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
os: macos-11
5454
target: x86_64-apple-darwin
5555
# Oldest macOS version we support
56-
sdk: 10.7
56+
sdk: "10.7"
5757
- name: Test macOS nightly w. ui tests
5858
os: macos-latest
5959
target: x86_64-apple-darwin
@@ -73,17 +73,29 @@ jobs:
7373
# binary, only build it
7474
test-args: --no-run
7575
# Newest SDK that supports 32-bit
76-
sdk: 10.13
77-
- name: Test GNUStep
76+
sdk: "10.13"
77+
- name: Test GNUStep with libobjc2 v1.9
7878
os: ubuntu-latest
7979
target: x86_64-unknown-linux-gnu
8080
runtime: gnustep-1-9
81+
libobjc2: "1.9"
82+
- name: Test GNUStep with libobjc2 v2.0
83+
os: ubuntu-latest
84+
target: x86_64-unknown-linux-gnu
85+
runtime: gnustep-2-0
86+
libobjc2: "2.0"
87+
- name: Test GNUStep with libobjc2 v2.1
88+
os: ubuntu-latest
89+
target: x86_64-unknown-linux-gnu
90+
runtime: gnustep-2-1
91+
libobjc2: "2.1"
8192
- name: Test GNUStep 32bit
8293
os: ubuntu-latest
8394
target: i686-unknown-linux-gnu
8495
cflags: -m32
8596
configureflags: --target=x86-pc-linux-gnu
8697
runtime: gnustep-1-9
98+
libobjc2: "1.9"
8799
- name: Test iOS simulator x86 64bit
88100
os: macos-11
89101
target: x86_64-apple-ios
@@ -234,13 +246,25 @@ jobs:
234246
if: contains(matrix.runtime, 'gnustep') && steps.extern-cache.outputs.cache-hit != 'true'
235247
run: sudo apt-get -y install make cmake
236248

237-
- name: Install GNUStep libobjc2 v1.9
238-
if: contains(matrix.runtime, 'gnustep') && steps.extern-cache.outputs.cache-hit != 'true'
249+
- name: Install GNUStep libobjc2
250+
if: matrix.libobjc2 && steps.extern-cache.outputs.cache-hit != 'true'
239251
run: |
240-
wget https://github.com/gnustep/libobjc2/archive/refs/tags/v1.9.tar.gz
241-
tar -xzf v1.9.tar.gz
242-
mkdir -p libobjc2-1.9/build
243-
cd libobjc2-1.9/build
252+
wget https://github.com/gnustep/libobjc2/archive/refs/tags/v${{ matrix.libobjc2 }}.tar.gz
253+
tar -xzf v${{ matrix.libobjc2 }}.tar.gz
254+
255+
# Install robin-map on v2.1
256+
if test -d libobjc2-2.1; then
257+
cd libobjc2-2.1/third_party
258+
# Remove possibly existing `robin-map` folder
259+
rm -rf robin-map
260+
wget https://github.com/Tessil/robin-map/archive/757de829927489bee55ab02147484850c687b620.tar.gz
261+
tar -xzf 757de829927489bee55ab02147484850c687b620.tar.gz
262+
mv robin-map-757de829927489bee55ab02147484850c687b620 robin-map
263+
cd ../..
264+
fi
265+
266+
mkdir -p libobjc2-${{ matrix.libobjc2 }}/build
267+
cd libobjc2-${{ matrix.libobjc2 }}/build
244268
cmake -Wno-dev -DCMAKE_INSTALL_PREFIX=$HOME/extern -DTESTS=OFF ..
245269
make install
246270

objc2/src/lib.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,17 @@ pub mod __gnustep_hack {
178178
#[link(name = "gnustep-base", kind = "dylib")]
179179
// This linking doesn't have to be on the correct `extern` block.
180180
extern "C" {
181-
static _OBJC_CLASS_NSObject: Class;
181+
// The linking changed in libobjc2 v2.0
182+
#[cfg_attr(feature = "gnustep-2-0", link_name = "._OBJC_CLASS_NSObject")]
183+
#[cfg_attr(not(feature = "gnustep-2-0"), link_name = "_OBJC_CLASS_NSObject")]
184+
static OBJC_CLASS_NSObject: Class;
185+
// Others:
186+
// __objc_class_name_NSObject
187+
// _OBJC_CLASS_REF_NSObject
182188
}
183189

184190
pub unsafe fn get_class_to_force_linkage() -> &'static Class {
185-
unsafe { core::ptr::read_volatile(&&_OBJC_CLASS_NSObject) }
191+
unsafe { core::ptr::read_volatile(&&OBJC_CLASS_NSObject) }
186192
}
187193

188194
#[test]

0 commit comments

Comments
 (0)