Skip to content

Commit

Permalink
Add ObjFW compatibility headers for objc-sys
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Mar 2, 2022
1 parent 2b48e8e commit aac75da
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions block-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ fn main() {
}
}
(false, false, false, true) => {
// Add compability headers to make `#include <Block.h>` work.
let compat_headers = Path::new(env!("CARGO_MANIFEST_DIR")).join("compat-headers/objfw");
cc_args.push_str(" -I");
cc_args.push_str(compat_headers.to_str().unwrap());
Expand Down
20 changes: 15 additions & 5 deletions objc-sys/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::env;
use std::{env, path::Path};

/// TODO: Better validation of this
///
Expand Down Expand Up @@ -219,11 +219,21 @@ fn main() {
// - `-miphoneos-version-min={}`
// - `-mmacosx-version-min={}`
// - ...
println!(
"cargo:cc_args=-fobjc-arc -fobjc-arc-exceptions -fobjc-exceptions -fobjc-runtime={}",
// TODO: -fobjc-weak ?
//
// TODO: -fobjc-weak ?
let mut cc_args = format!(
"-fobjc-arc -fobjc-arc-exceptions -fobjc-exceptions -fobjc-runtime={}",
clang_runtime
); // DEP_OBJC_CC_ARGS
);

if let Runtime::ObjFW(_) = &runtime {
// Add compability headers to make `#include <objc/objc.h>` work.
let compat_headers = Path::new(env!("CARGO_MANIFEST_DIR")).join("compat-headers-objfw");
cc_args.push_str(" -I");
cc_args.push_str(compat_headers.to_str().unwrap());
}

println!("cargo:cc_args={}", cc_args); // DEP_OBJC_CC_ARGS

if let Runtime::ObjFW(_) = &runtime {
// Link to libobjfw-rt
Expand Down
1 change: 1 addition & 0 deletions objc-sys/compat-headers-objfw/objc/objc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#import <ObjFW/ObjFW-RT.h>
1 change: 1 addition & 0 deletions objc-sys/compat-headers-objfw/objc/runtime.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#import <ObjFW/ObjFW-RT.h>

0 comments on commit aac75da

Please sign in to comment.