Skip to content

Commit aac75da

Browse files
committed
Add ObjFW compatibility headers for objc-sys
1 parent 2b48e8e commit aac75da

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

block-sys/build.rs

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ fn main() {
5353
}
5454
}
5555
(false, false, false, true) => {
56+
// Add compability headers to make `#include <Block.h>` work.
5657
let compat_headers = Path::new(env!("CARGO_MANIFEST_DIR")).join("compat-headers/objfw");
5758
cc_args.push_str(" -I");
5859
cc_args.push_str(compat_headers.to_str().unwrap());

objc-sys/build.rs

+15-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::env;
1+
use std::{env, path::Path};
22

33
/// TODO: Better validation of this
44
///
@@ -219,11 +219,21 @@ fn main() {
219219
// - `-miphoneos-version-min={}`
220220
// - `-mmacosx-version-min={}`
221221
// - ...
222-
println!(
223-
"cargo:cc_args=-fobjc-arc -fobjc-arc-exceptions -fobjc-exceptions -fobjc-runtime={}",
224-
// TODO: -fobjc-weak ?
222+
//
223+
// TODO: -fobjc-weak ?
224+
let mut cc_args = format!(
225+
"-fobjc-arc -fobjc-arc-exceptions -fobjc-exceptions -fobjc-runtime={}",
225226
clang_runtime
226-
); // DEP_OBJC_CC_ARGS
227+
);
228+
229+
if let Runtime::ObjFW(_) = &runtime {
230+
// Add compability headers to make `#include <objc/objc.h>` work.
231+
let compat_headers = Path::new(env!("CARGO_MANIFEST_DIR")).join("compat-headers-objfw");
232+
cc_args.push_str(" -I");
233+
cc_args.push_str(compat_headers.to_str().unwrap());
234+
}
235+
236+
println!("cargo:cc_args={}", cc_args); // DEP_OBJC_CC_ARGS
227237

228238
if let Runtime::ObjFW(_) = &runtime {
229239
// Link to libobjfw-rt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#import <ObjFW/ObjFW-RT.h>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#import <ObjFW/ObjFW-RT.h>

0 commit comments

Comments
 (0)