From 38b9eabb4f92f2e784ced4eed34961106171cc46 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Wed, 11 Jan 2023 22:07:01 +0100 Subject: [PATCH 1/3] Allow omitting the developer directory in header-translator --- .github/workflows/ci.yml | 5 ++++- crates/header-translator/src/main.rs | 17 ++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9e4da6fd3..1154078b1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -262,6 +262,9 @@ jobs: - fmt - lint + env: + DEVELOPER_DIR: /Applications/Xcode_14.0.1.app/Contents/Developer + steps: - uses: actions/checkout@v3 with: @@ -277,7 +280,7 @@ jobs: key: cargo-${{ github.job }}-${{ matrix.name }}-${{ hashFiles('**/Cargo.lock') }} - name: Run header translator - run: cargo run --features=run --bin=header-translator -- /Applications/Xcode.app/Contents/Developer + run: cargo run --features=run --bin=header-translator - name: Verify that no files changed run: git diff --exit-code --submodule=diff diff --git a/crates/header-translator/src/main.rs b/crates/header-translator/src/main.rs index d46ee9951..c53d0cc26 100644 --- a/crates/header-translator/src/main.rs +++ b/crates/header-translator/src/main.rs @@ -3,7 +3,7 @@ use std::path::{Path, PathBuf}; use apple_sdk::{AppleSdk, DeveloperDirectory, Platform, SdkPath, SimpleSdk}; use clang::{Clang, EntityKind, EntityVisitResult, Index, TranslationUnit}; -use tracing::{debug_span, info, info_span, trace, trace_span}; +use tracing::{debug_span, error, info, info_span, trace, trace_span}; use tracing_subscriber::filter::LevelFilter; use tracing_subscriber::layer::{Layer, SubscriberExt}; use tracing_subscriber::registry::Registry; @@ -36,6 +36,7 @@ fn main() -> Result<(), BoxError> { .with_filter(LevelFilter::INFO), ) .init(); + let _span = info_span!("running").entered(); let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR")); let workspace_dir = manifest_dir.parent().unwrap(); @@ -46,11 +47,11 @@ fn main() -> Result<(), BoxError> { let clang = Clang::new()?; let index = Index::new(&clang, true, true); - let developer_dir = DeveloperDirectory::from(PathBuf::from( - std::env::args_os() - .nth(1) - .expect("must specify developer directory as first argument"), - )); + let developer_dir = if let Some(path) = std::env::args_os().nth(1) { + DeveloperDirectory::from(PathBuf::from(path)) + } else { + DeveloperDirectory::from_xcode_select()? + }; let sdks: Vec<_> = developer_dir .platforms() @@ -70,7 +71,9 @@ fn main() -> Result<(), BoxError> { }) .collect(); - assert_eq!(sdks.len(), 8, "should have one of each platform: {sdks:?}"); + if sdks.len() != 8 { + error!("should have one of each platform: {sdks:?}"); + } let mut final_result = None; From 9c7d0cbbfb3d338265340c89a0155a03f9f17ef7 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Wed, 11 Jan 2023 22:04:04 +0100 Subject: [PATCH 2/3] icrate: Update the SDK to the one in XCode 14.2 --- .github/workflows/ci.yml | 2 +- crates/header-translator/src/context.rs | 1 + crates/header-translator/src/id.rs | 5 +++- .../header-translator/translation-config.toml | 9 ++++++ crates/icrate/CHANGELOG.md | 2 ++ crates/icrate/Cargo.toml | 28 +++++++++++++++++++ crates/icrate/README.md | 10 +++---- crates/icrate/src/common.rs | 2 +- crates/icrate/src/generated | 2 +- 9 files changed, 52 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1154078b1..598ea6298 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -263,7 +263,7 @@ jobs: - lint env: - DEVELOPER_DIR: /Applications/Xcode_14.0.1.app/Contents/Developer + DEVELOPER_DIR: /Applications/Xcode_14.2.app/Contents/Developer steps: - uses: actions/checkout@v3 diff --git a/crates/header-translator/src/context.rs b/crates/header-translator/src/context.rs index ad5e2d5d5..94eb6659a 100644 --- a/crates/header-translator/src/context.rs +++ b/crates/header-translator/src/context.rs @@ -25,6 +25,7 @@ impl<'a> Context<'a> { include_dir: sdk.path.join("usr/include"), system_headers: HashSet::from([ Path::new("MacTypes.h"), + Path::new("objc/objc.h"), Path::new("objc/NSObject.h"), Path::new("objc/NSObjCRuntime.h"), ]), diff --git a/crates/header-translator/src/id.rs b/crates/header-translator/src/id.rs index e3219263c..adc21a1be 100644 --- a/crates/header-translator/src/id.rs +++ b/crates/header-translator/src/id.rs @@ -35,7 +35,10 @@ impl ItemIdentifier { pub fn with_name(name: N, entity: &Entity<'_>, context: &Context<'_>) -> Self { let (mut library_name, mut file_name) = context .get_library_and_file_name(entity) - .expect("ItemIdentifier get library and file"); + .unwrap_or_else(|| { + warn!(?entity, "ItemIdentifier from unknown header"); + ("Unknown".to_string(), None) + }); // TODO: Get rid of this hack if library_name == "CoreGraphics" { diff --git a/crates/header-translator/translation-config.toml b/crates/header-translator/translation-config.toml index 3e1bd74f6..85e49d2e2 100644 --- a/crates/header-translator/translation-config.toml +++ b/crates/header-translator/translation-config.toml @@ -230,6 +230,10 @@ skipped = true skipped = true [class.NSString.methods.initWithFormat_locale_arguments] skipped = true +[class.NSString.methods.initWithValidatedFormat_validFormatSpecifiers_arguments_error] +skipped = true +[class.NSString.methods.initWithValidatedFormat_validFormatSpecifiers_locale_arguments_error] +skipped = true [fn.NSLogv] skipped = true @@ -626,6 +630,10 @@ skipped = true skipped = true [protocol.MTLTexture.methods.iosurface] skipped = true +[class.ASAuthorizationProviderExtensionLoginManager.methods] +saveCertificate_keyType = { skipped = true } +copyKeyForKeyType = { skipped = true } +copyIdentityForKeyType = { skipped = true } # Uses a pointer to SEL, which doesn't implement Encode yet [protocol.NSMenuDelegate.methods] @@ -785,6 +793,7 @@ newRenderPipelineStateWithDescriptor_options_reflection_error = { skipped = true newComputePipelineStateWithFunction_options_reflection_error = { skipped = true } newComputePipelineStateWithDescriptor_options_reflection_error = { skipped = true } newRenderPipelineStateWithTileDescriptor_options_reflection_error = { skipped = true } +newRenderPipelineStateWithMeshDescriptor_options_reflection_error = { skipped = true } # Uses unions internally [struct.MTLPackedFloat3] diff --git a/crates/icrate/CHANGELOG.md b/crates/icrate/CHANGELOG.md index bba837eb3..a6c147a33 100644 --- a/crates/icrate/CHANGELOG.md +++ b/crates/icrate/CHANGELOG.md @@ -12,6 +12,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Added * Added the `CoreAnimation` framework. +* Updated the SDK version from XCode `14.0.1` to `14.2`. + - See differences [here](https://sdk.news/macOS-13.0/). ## icrate 0.0.1 - 2022-12-24 diff --git a/crates/icrate/Cargo.toml b/crates/icrate/Cargo.toml index 2deb2214c..788f13812 100644 --- a/crates/icrate/Cargo.toml +++ b/crates/icrate/Cargo.toml @@ -309,6 +309,9 @@ AppKit_NSComboBox = [ AppKit_NSComboBoxCell = [ "AppKit_NSTextFieldCell", ] +AppKit_NSComboButton = [ + "AppKit_NSControl", +] AppKit_NSControl = [ "AppKit_NSView", ] @@ -492,6 +495,7 @@ AppKit_NSPressGestureRecognizer = [ "AppKit_NSGestureRecognizer", ] AppKit_NSPressureConfiguration = [] +AppKit_NSPreviewRepresentingActivityItem = [] AppKit_NSPrintInfo = [] AppKit_NSPrintOperation = [] AppKit_NSPrintPanel = [] @@ -677,6 +681,9 @@ AppKit_NSTextLayoutFragment = [] AppKit_NSTextLayoutManager = [] AppKit_NSTextLineFragment = [] AppKit_NSTextList = [] +AppKit_NSTextListElement = [ + "AppKit_NSTextParagraph", +] AppKit_NSTextParagraph = [ "AppKit_NSTextElement", ] @@ -816,6 +823,7 @@ AppKit_all = [ "AppKit_NSColorWell", "AppKit_NSComboBox", "AppKit_NSComboBoxCell", + "AppKit_NSComboButton", "AppKit_NSControl", "AppKit_NSController", "AppKit_NSCursor", @@ -911,6 +919,7 @@ AppKit_all = [ "AppKit_NSPredicateEditorRowTemplate", "AppKit_NSPressGestureRecognizer", "AppKit_NSPressureConfiguration", + "AppKit_NSPreviewRepresentingActivityItem", "AppKit_NSPrintInfo", "AppKit_NSPrintOperation", "AppKit_NSPrintPanel", @@ -1002,6 +1011,7 @@ AppKit_all = [ "AppKit_NSTextLayoutManager", "AppKit_NSTextLineFragment", "AppKit_NSTextList", + "AppKit_NSTextListElement", "AppKit_NSTextParagraph", "AppKit_NSTextRange", "AppKit_NSTextSelection", @@ -1078,6 +1088,9 @@ AuthenticationServices_ASAuthorizationPlatformPublicKeyCredentialRegistrationReq ] AuthenticationServices_ASAuthorizationProviderExtensionAuthorizationRequest = [] AuthenticationServices_ASAuthorizationProviderExtensionAuthorizationResult = [] +AuthenticationServices_ASAuthorizationProviderExtensionKerberosMapping = [] +AuthenticationServices_ASAuthorizationProviderExtensionLoginConfiguration = [] +AuthenticationServices_ASAuthorizationProviderExtensionLoginManager = [] AuthenticationServices_ASAuthorizationPublicKeyCredentialParameters = [] AuthenticationServices_ASAuthorizationRequest = [] AuthenticationServices_ASAuthorizationSecurityKeyPublicKeyCredentialAssertion = [] @@ -1129,6 +1142,9 @@ AuthenticationServices_all = [ "AuthenticationServices_ASAuthorizationPlatformPublicKeyCredentialRegistrationRequest", "AuthenticationServices_ASAuthorizationProviderExtensionAuthorizationRequest", "AuthenticationServices_ASAuthorizationProviderExtensionAuthorizationResult", + "AuthenticationServices_ASAuthorizationProviderExtensionKerberosMapping", + "AuthenticationServices_ASAuthorizationProviderExtensionLoginConfiguration", + "AuthenticationServices_ASAuthorizationProviderExtensionLoginManager", "AuthenticationServices_ASAuthorizationPublicKeyCredentialParameters", "AuthenticationServices_ASAuthorizationRequest", "AuthenticationServices_ASAuthorizationSecurityKeyPublicKeyCredentialAssertion", @@ -1409,6 +1425,7 @@ Foundation_NSArray = [] Foundation_NSAssertionHandler = [] Foundation_NSAttributedString = [] Foundation_NSAttributedStringMarkdownParsingOptions = [] +Foundation_NSAttributedStringMarkdownSourcePosition = [] Foundation_NSAutoreleasePool = [] Foundation_NSBackgroundActivityScheduler = [] Foundation_NSBlockOperation = [ @@ -1903,6 +1920,7 @@ Foundation_all = [ "Foundation_NSAssertionHandler", "Foundation_NSAttributedString", "Foundation_NSAttributedStringMarkdownParsingOptions", + "Foundation_NSAttributedStringMarkdownSourcePosition", "Foundation_NSAutoreleasePool", "Foundation_NSBackgroundActivityScheduler", "Foundation_NSBlockOperation", @@ -2172,6 +2190,9 @@ Metal_MTLAccelerationStructureMotionBoundingBoxGeometryDescriptor = [ Metal_MTLAccelerationStructureMotionTriangleGeometryDescriptor = [ "Metal_MTLAccelerationStructureGeometryDescriptor", ] +Metal_MTLAccelerationStructurePassDescriptor = [] +Metal_MTLAccelerationStructurePassSampleBufferAttachmentDescriptor = [] +Metal_MTLAccelerationStructurePassSampleBufferAttachmentDescriptorArray = [] Metal_MTLAccelerationStructureTriangleGeometryDescriptor = [ "Metal_MTLAccelerationStructureGeometryDescriptor", ] @@ -2208,6 +2229,7 @@ Metal_MTLFunctionStitchingFunctionNode = [] Metal_MTLFunctionStitchingGraph = [] Metal_MTLFunctionStitchingInputNode = [] Metal_MTLHeapDescriptor = [] +Metal_MTLIOCommandQueueDescriptor = [] Metal_MTLIndirectCommandBufferDescriptor = [] Metal_MTLInstanceAccelerationStructureDescriptor = [ "Metal_MTLAccelerationStructureDescriptor", @@ -2217,6 +2239,7 @@ Metal_MTLIntersectionFunctionDescriptor = [ ] Metal_MTLIntersectionFunctionTableDescriptor = [] Metal_MTLLinkedFunctions = [] +Metal_MTLMeshRenderPipelineDescriptor = [] Metal_MTLMotionKeyframeData = [] Metal_MTLPipelineBufferDescriptor = [] Metal_MTLPipelineBufferDescriptorArray = [] @@ -2285,6 +2308,9 @@ Metal_all = [ "Metal_MTLAccelerationStructureGeometryDescriptor", "Metal_MTLAccelerationStructureMotionBoundingBoxGeometryDescriptor", "Metal_MTLAccelerationStructureMotionTriangleGeometryDescriptor", + "Metal_MTLAccelerationStructurePassDescriptor", + "Metal_MTLAccelerationStructurePassSampleBufferAttachmentDescriptor", + "Metal_MTLAccelerationStructurePassSampleBufferAttachmentDescriptorArray", "Metal_MTLAccelerationStructureTriangleGeometryDescriptor", "Metal_MTLArgument", "Metal_MTLArgumentDescriptor", @@ -2317,11 +2343,13 @@ Metal_all = [ "Metal_MTLFunctionStitchingGraph", "Metal_MTLFunctionStitchingInputNode", "Metal_MTLHeapDescriptor", + "Metal_MTLIOCommandQueueDescriptor", "Metal_MTLIndirectCommandBufferDescriptor", "Metal_MTLInstanceAccelerationStructureDescriptor", "Metal_MTLIntersectionFunctionDescriptor", "Metal_MTLIntersectionFunctionTableDescriptor", "Metal_MTLLinkedFunctions", + "Metal_MTLMeshRenderPipelineDescriptor", "Metal_MTLMotionKeyframeData", "Metal_MTLPipelineBufferDescriptor", "Metal_MTLPipelineBufferDescriptorArray", diff --git a/crates/icrate/README.md b/crates/icrate/README.md index eaed779b5..b429c887a 100644 --- a/crates/icrate/README.md +++ b/crates/icrate/README.md @@ -7,13 +7,13 @@ Rust bindings to Apple's frameworks. -These are automatically generated from the SDKs in Xcode 14.0.1 (will be periodically updated). +These are automatically generated from the SDKs in Xcode 14.2 (will be periodically updated). Currently supports: -- macOS: `10.7-12.3` -- iOS/iPadOS: `7.0-16.0` (WIP) -- tvOS: `9.0-16.0` (WIP) -- watchOS: `1.0-9.0` (WIP) +- macOS: `10.7-13.1` +- iOS/iPadOS: `7.0-16.2` (WIP) +- tvOS: `9.0-16.1` (WIP) +- watchOS: `1.0-9.1` (WIP) This crate is part of the [`objc2` project](https://github.com/madsmtm/objc2), see that for related crates. diff --git a/crates/icrate/src/common.rs b/crates/icrate/src/common.rs index 3014ae281..603700bfc 100644 --- a/crates/icrate/src/common.rs +++ b/crates/icrate/src/common.rs @@ -11,7 +11,7 @@ pub(crate) use std::os::raw::{ }; #[cfg(feature = "objective-c")] -pub(crate) use objc2::ffi::{NSInteger, NSIntegerMax, NSUInteger, NSUIntegerMax}; +pub(crate) use objc2::ffi::{NSInteger, NSIntegerMax, NSUInteger, NSUIntegerMax, IMP}; #[cfg(feature = "objective-c")] pub(crate) use objc2::rc::{Allocated, Id, Owned, Ownership, Shared}; #[cfg(feature = "objective-c")] diff --git a/crates/icrate/src/generated b/crates/icrate/src/generated index 4c4aa5ea2..b8830e559 160000 --- a/crates/icrate/src/generated +++ b/crates/icrate/src/generated @@ -1 +1 @@ -Subproject commit 4c4aa5ea24cabec2b660fac8d1143c79ab69abac +Subproject commit b8830e559d93afb4b495f3a1f7f18ff20552eb64 From 06159ce40d7276404ebaaeaec723d84448e5dfe2 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Thu, 12 Jan 2023 06:56:07 +0100 Subject: [PATCH 3/3] Make a bit of the new Metal functionality safe --- crates/header-translator/src/data/Metal.rs | 16 +++++++--------- crates/icrate/src/generated | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/crates/header-translator/src/data/Metal.rs b/crates/header-translator/src/data/Metal.rs index 6015f32b7..e33f222f4 100644 --- a/crates/header-translator/src/data/Metal.rs +++ b/crates/header-translator/src/data/Metal.rs @@ -10,13 +10,12 @@ data! { unsafe -setGeometryDescriptors; } - // TODO macOS 13 - // class MTLAccelerationStructureGeometryDescriptor { - // unsafe -setPrimitiveDataBuffer; - // unsafe -setPrimitiveDataStride; - // unsafe -setPrimitiveDataElementSize; - // unsafe -setIntersectionFunctionTableOffset; - // } + class MTLAccelerationStructureGeometryDescriptor { + unsafe -setPrimitiveDataBuffer; + unsafe -setPrimitiveDataStride; + unsafe -setPrimitiveDataElementSize; + unsafe -setIntersectionFunctionTableOffset; + } class MTLAccelerationStructureTriangleGeometryDescriptor { unsafe +descriptor; @@ -110,8 +109,7 @@ data! { unsafe -removeAllDebugMarkers; unsafe -remoteStorageBuffer; unsafe -newRemoteBufferViewForDevice; - // TODO macOS 13 - // unsafe -gpuAddress; + unsafe -gpuAddress; } class MTLCaptureDescriptor { diff --git a/crates/icrate/src/generated b/crates/icrate/src/generated index b8830e559..e59158acd 160000 --- a/crates/icrate/src/generated +++ b/crates/icrate/src/generated @@ -1 +1 @@ -Subproject commit b8830e559d93afb4b495f3a1f7f18ff20552eb64 +Subproject commit e59158acdd64687438597dc1a81267db09cfcc07