Skip to content

Commit

Permalink
Pass a few Clang flags that Xcode also passes
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Dec 15, 2024
1 parent cd49441 commit aede91f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
18 changes: 17 additions & 1 deletion crates/header-translator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,14 +387,21 @@ fn get_translation_unit<'i: 'c, 'c>(
"-Wextra",
"-fobjc-arc",
"-fobjc-arc-exceptions",
"-fexceptions",
"-fobjc-exceptions",
"-fobjc-abi-version=2", // 3??
"-fblocks",
// "-fparse-all-comments",
// TODO: "-fretain-comments-from-system-headers"
"-isysroot",
sdk.path.to_str().unwrap(),
// See ClangImporter.cpp and Foundation/NSObjCRuntime.h
"-D",
"__SWIFT_ATTR_SUPPORTS_SENDABLE_DECLS=1",
"-D",
"__SWIFT_ATTR_SUPPORTS_SENDING=1",
// "-D",
// "__swift__=51000",
// Enable modules. We do this by parsing the `.modulemap` instead
// of a combined file containing includes, as the Clang AST from
// dependent modules does not seem possible to access otherwise.
Expand All @@ -409,10 +416,19 @@ fn get_translation_unit<'i: 'c, 'c>(
// "-Xclang",
// "-fmodule-format=raw",
&format!("-fmodules-cache-path={}", tempdir.to_str().unwrap()),
// "-fsystem-module",
"-Xclang",
"-emit-module",
&format!("-fmodule-name={module}"),
"-fsystem-module",
// "-fmodules-validate-system-headers",
// "-fmodules-search-all",
"-Xclang",
"-fno-modules-prune-non-affecting-module-map-files",
// "-Xclang",
// "-fmodule-feature",
// "-Xclang",
// "swift",
"-disable-objc-default-synthesize-properties",
// Explicitly enable API notes (implicitly enabled by -fmodules).
"-fapinotes",
"-fapinotes-modules",
Expand Down
5 changes: 4 additions & 1 deletion crates/header-translator/src/unexposed_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ impl UnexposedAttr {
| "__TVOS_DEPRECATED"
| "__WATCHOS_AVAILABLE"
| "__WATCHOS_DEPRECATED"
| "_NS_SCANNER_DEPRECATED_FOR_SWIFT_ONLY_WITH_REPLACEMENT"
| "API_AVAILABLE_BEGIN"
| "API_AVAILABLE"
| "API_DEPRECATED"
Expand All @@ -134,6 +135,7 @@ impl UnexposedAttr {
| "API_UNAVAILABLE_BEGIN"
| "API_UNAVAILABLE"
| "AUGRAPH_DEPRECATED"
| "AVF_DEPRECATED_FOR_SWIFT_ONLY"
| "CF_AVAILABLE"
| "CF_AVAILABLE_IOS"
| "CF_AVAILABLE_MAC"
Expand All @@ -146,8 +148,9 @@ impl UnexposedAttr {
| "CI_GL_DEPRECATED_IOS"
| "CI_GL_DEPRECATED_MAC"
| "CIKL_DEPRECATED"
| "CK_UNAVAILABLE"
| "CK_NEWLY_UNAVAILABLE"
| "CK_SWIFT_DEPRECATED"
| "CK_UNAVAILABLE"
| "CT_AVAILABLE"
| "CT_DEPRECATED"
| "CT_DEPRECATED_WITH_REPLACEMENT"
Expand Down

0 comments on commit aede91f

Please sign in to comment.