diff --git a/block-sys/build.rs b/block-sys/build.rs index 454ac475c..57bcea0af 100644 --- a/block-sys/build.rs +++ b/block-sys/build.rs @@ -53,6 +53,7 @@ fn main() { } } (false, false, false, true) => { + // Add compability headers to make `#include ` 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()); diff --git a/objc-sys/build.rs b/objc-sys/build.rs index 1f80b3ec2..cc05758f1 100644 --- a/objc-sys/build.rs +++ b/objc-sys/build.rs @@ -1,4 +1,4 @@ -use std::env; +use std::{env, path::Path}; /// TODO: Better validation of this /// @@ -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 ` 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 diff --git a/objc-sys/compat-headers-objfw/objc/objc.h b/objc-sys/compat-headers-objfw/objc/objc.h new file mode 100644 index 000000000..9cc6bbd8f --- /dev/null +++ b/objc-sys/compat-headers-objfw/objc/objc.h @@ -0,0 +1 @@ +#import diff --git a/objc-sys/compat-headers-objfw/objc/runtime.h b/objc-sys/compat-headers-objfw/objc/runtime.h new file mode 100644 index 000000000..9cc6bbd8f --- /dev/null +++ b/objc-sys/compat-headers-objfw/objc/runtime.h @@ -0,0 +1 @@ +#import