File tree Expand file tree Collapse file tree 4 files changed +26
-18
lines changed Expand file tree Collapse file tree 4 files changed +26
-18
lines changed Original file line number Diff line number Diff line change @@ -100,3 +100,27 @@ pub mod runtime;
100
100
101
101
#[ cfg( test) ]
102
102
mod test_utils;
103
+
104
+ /// Hacky way to make GNUStep link properly to Foundation while testing.
105
+ ///
106
+ /// This is a temporary solution to make our CI work for now!
107
+ #[ doc( hidden) ]
108
+ #[ cfg( not( target_vendor = "apple" ) ) ]
109
+ pub mod __gnustep_hack {
110
+ use super :: runtime:: Class ;
111
+
112
+ #[ link( name = "gnustep-base" , kind = "dylib" ) ]
113
+ // This linking doesn't have to be on the correct `extern` block.
114
+ extern "C" {
115
+ static _OBJC_CLASS_NSObject: Class ;
116
+ }
117
+
118
+ pub unsafe fn get_class_to_force_linkage ( ) -> & ' static Class {
119
+ & _OBJC_CLASS_NSObject
120
+ }
121
+
122
+ #[ test]
123
+ fn ensure_linkage ( ) {
124
+ unsafe { get_class_to_force_linkage ( ) } ;
125
+ }
126
+ }
Original file line number Diff line number Diff line change @@ -216,7 +216,7 @@ impl !AutoreleaseSafe for AutoreleasePool {}
216
216
///
217
217
/// Basic usage:
218
218
///
219
- /// ```rust
219
+ /// ```rust,no_run
220
220
/// use objc2::{class, msg_send};
221
221
/// use objc2::rc::{autoreleasepool, AutoreleasePool};
222
222
/// use objc2::runtime::Object;
Original file line number Diff line number Diff line change @@ -25,26 +25,10 @@ pub use self::value::{INSValue, NSValue};
25
25
#[ link( name = "Foundation" , kind = "framework" ) ]
26
26
extern "C" { }
27
27
28
- #[ cfg( not( target_vendor = "apple" ) ) ]
29
- use objc2:: runtime:: Class ;
30
-
31
28
#[ cfg( not( target_vendor = "apple" ) ) ]
32
29
#[ link( name = "gnustep-base" , kind = "dylib" ) ]
33
30
extern "C" { }
34
31
35
- // Split up to illustrate that the linking doesn't have to be annotated on the
36
- // correct `extern` block.
37
- #[ cfg( not( target_vendor = "apple" ) ) ]
38
- extern "C" {
39
- static _OBJC_CLASS_NSObject: Class ;
40
- }
41
-
42
- #[ cfg( not( target_vendor = "apple" ) ) ]
43
- #[ allow( dead_code) ]
44
- unsafe fn get_class_to_force_linkage ( ) -> & ' static Class {
45
- & _OBJC_CLASS_NSObject
46
- }
47
-
48
32
#[ macro_use]
49
33
mod macros;
50
34
Original file line number Diff line number Diff line change @@ -95,7 +95,7 @@ mod tests {
95
95
#[ cfg( not( target_vendor = "apple" ) ) ]
96
96
#[ test]
97
97
fn ensure_linkage ( ) {
98
- unsafe { crate :: get_class_to_force_linkage ( ) } ;
98
+ unsafe { objc2 :: __gnustep_hack :: get_class_to_force_linkage ( ) } ;
99
99
}
100
100
101
101
#[ test]
You can’t perform that action at this time.
0 commit comments