Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS support #8

Merged
merged 2 commits into from
Jan 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
174 changes: 173 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Tool
run: cargo run --features=bin --manifest-path=bindgen/Cargo.toml --verbose CoreFoundation --sdk macosx

sys:
sys-macos:
strategy:
matrix:
feature: [
Expand Down Expand Up @@ -224,3 +224,175 @@ jobs:
- uses: actions/checkout@v3
- name: Build
run: cargo build --manifest-path=sys/Cargo.toml --verbose --features ${{ matrix.feature }}
sys-ios:
strategy:
matrix:
feature: [
ARKit,
AVFAudio,
AVFoundation,
AVKit,
AVRouting,
Accelerate,
Accessibility,
Accounts,
ActivityKit,
AdServices,
AdSupport,
AddressBook,
# AddressBookUI,
AppClip,
AppIntents,
AppTrackingTransparency,
AssetsLibrary,
AudioToolbox,
AudioUnit,
AuthenticationServices,
AutomaticAssessmentConfiguration,
BackgroundAssets,
BackgroundTasks,
BusinessChat,
CFNetwork,
CallKit,
CarPlay,
ClassKit,
ClockKit,
CloudKit,
ColorSync,
Contacts,
ContactsUI,
CoreAudio,
CoreAudioKit,
CoreBluetooth,
CoreData,
CoreFoundation,
CoreGraphics,
CoreHaptics,
CoreImage,
CoreLocation,
CoreLocationUI,
CoreMIDI,
CoreML,
CoreMedia,
CoreMotion,
CoreNFC,
CoreServices,
CoreSpotlight,
CoreTelephony,
CoreText,
CoreTransferable,
CoreVideo,
CryptoTokenKit,
DataDetection,
DeviceCheck,
DeviceDiscoveryExtension,
EventKit,
EventKitUI,
ExposureNotification,
ExtensionFoundation,
ExtensionKit,
ExternalAccessory,
FileProvider,
FileProviderUI,
Foundation,
GLKit,
GSS,
GameController,
GameKit,
GameplayKit,
HealthKit,
HealthKitUI,
HomeKit,
IOSurface,
IdentityLookup,
IdentityLookupUI,
ImageCaptureCore,
ImageIO,
Intents,
IntentsUI,
JavaScriptCore,
LinkPresentation,
LocalAuthentication,
LocalAuthenticationEmbeddedUI,
MLCompute,
MapKit,
Matter,
MatterSupport,
MediaAccessibility,
MediaPlayer,
MediaSetup,
MediaToolbox,
MessageUI,
Messages,
Metal,
MetalFX,
MetalKit,
# MetalPerformanceShaders,
# MetalPerformanceShadersGraph,
MetricKit,
MobileCoreServices,
ModelIO,
MultipeerConnectivity,
NaturalLanguage,
NearbyInteraction,
Network,
NetworkExtension,
NewsstandKit,
NotificationCenter,
OSLog,
OpenAL,
OpenGLES,
PDFKit,
PHASE,
PassKit,
PencilKit,
Photos,
PhotosUI,
ProximityReader,
PushKit,
PushToTalk,
QuartzCore,
QuickLook,
QuickLookThumbnailing,
ReplayKit,
RoomPlan,
SafariServices,
SafetyKit,
SceneKit,
ScreenTime,
Security,
SensorKit,
SharedWithYou,
SharedWithYouCore,
ShazamKit,
Social,
SoundAnalysis,
Speech,
SpriteKit,
StoreKit,
SwiftUI,
SystemConfiguration,
ThreadNetwork,
Twitter,
UIKit,
UniformTypeIdentifiers,
UserNotifications,
UserNotificationsUI,
VideoSubscriberAccount,
VideoToolbox,
Vision,
VisionKit,
WatchConnectivity,
# WebKit, -- exceed max arg
WidgetKit,
iAd
]
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: prepare iOS build
uses: dtolnay/rust-toolchain@stable
with:
target: aarch64-apple-ios
- name: Build
run: cargo build --target=aarch64-apple-ios --manifest-path=sys/Cargo.toml --verbose --features ${{ matrix.feature }}
27 changes: 27 additions & 0 deletions bindgen/Bindgen.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,27 @@ impl NSScreen_ for NSScreen {}
pub trait NSScreen_: Sized + std::ops::Deref { #=># }
""",
"""impl NSImage_ for NSImage {}\n\n #=># """,

# UIKit
"""unsafe fn dividerImageForLeftSegmentState_rightSegmentState_(
&self,
state: UIControlState,
state: UIControlState,
) -> UIImage
where
<Self as std::ops::Deref>::Target: objc::Message + Sized,
{
msg_send ! (* self , dividerImageForLeftSegmentState : state rightSegmentState : state)
} #=># unsafe fn dividerImageForLeftSegmentState_rightSegmentState_(
&self,
leftState: UIControlState,
rightState: UIControlState,
) -> UIImage
where
<Self as std::ops::Deref>::Target: objc::Message + Sized,
{
msg_send ! (* self , dividerImageForLeftSegmentState : leftState rightSegmentState : rightState)
}"""
]
[SyncServices]
replacements = [
Expand All @@ -55,3 +76,9 @@ replacements = [
deps = ["PDFKit"]
[QuickLookUI]
deps = ["PDFKit"]

# iOS
[ARKit]
deps = ["PDFKit"]
[QuickLook]
deps = ["PDFKit"]
19 changes: 9 additions & 10 deletions bindgen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "apple-bindgen"
version = "0.1.3"
version = "0.2.0"
edition = "2021"
description = "bindgen helper for Apple frameworks"
keywords = ["sys", "apple", "macos", "bindgen"]
Expand All @@ -14,16 +14,15 @@ include = ["*.toml", "/src"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bindgen = "0.60.1"
serde = { version = "1.0.140", features = ["derive"] }
serde_derive = "1.0.140"
toml = "0.5.9"
derive_more = { version = "0.99.17" }
apple-sdk = "0.1.0"
thiserror = "1.0.31"
bindgen = "0.63"
serde = { version = "1.0", features = ["derive"] }
toml = "0.6"
derive_more = { version = "0.99" }
apple-sdk = "0.4"
thiserror = "1.0"
regex = "1.7"

clap = { version = "3.2.14", features = ["derive"], optional = true }
regex = "1.7.1"
clap = { version = "4.1", features = ["derive"], optional = true }

[features]
default = ["bin"] # required-featues for apple-bindgen binary
Expand Down
8 changes: 7 additions & 1 deletion bindgen/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,13 @@ impl Builder {
clang_args.push(&target_arg);
}

clang_args.extend(&["-isysroot", self.sdk.path().to_str().unwrap()]);
clang_args.extend(&[
"-isysroot",
self.sdk
.path()
.to_str()
.expect("sdk path is not utf-8 representable"),
]);

builder = builder
.clang_args(&clang_args)
Expand Down
4 changes: 2 additions & 2 deletions bindgen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use apple_sdk::Platform;
use clap::Parser;
use std::{path::PathBuf, str::FromStr};

#[derive(Debug)]
#[derive(Debug, Clone)]
enum Sdk {
Name(Platform),
Path(SdkPath),
Expand Down Expand Up @@ -47,7 +47,7 @@ struct Args {
target: Option<String>,

/// Print build details
#[clap(short, long, takes_value = false)]
#[clap(short, long, num_args = 0)]
verbose: bool,
}

Expand Down
2 changes: 1 addition & 1 deletion bindgen/src/sdk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub enum SdkPathError {
XcrunError(std::io::Error),
}

#[derive(Debug)]
#[derive(Debug, Clone)]
pub struct SdkPath(PathBuf);

impl SdkPath {
Expand Down
Loading