Skip to content

Commit

Permalink
Update CI
Browse files Browse the repository at this point in the history
- Add tvOS, watchOS and visionOS.
- Add more docs.
- Remove `new-versions` branch.
- Fix confusions around x86_64 vs Aarch64 runners, see:
  https://github.com/actions/runner-images.
- Fix GNUStep.
- Fix compiling examples on Mac Catalyst.
  • Loading branch information
madsmtm committed Nov 14, 2024
1 parent e58bb10 commit 4ec407e
Show file tree
Hide file tree
Showing 7 changed files with 172 additions and 65 deletions.
167 changes: 106 additions & 61 deletions .github/workflows/ci.yml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ If you're confused about this, don't worry too much about it, if you enable
Copy and fill out the following checklist into the release PR:

```markdown
- [ ] The branch is named `new-versions`, such that the full CI will run.
- [ ] The branch is named `ci-full`, such that the full CI will run.
- [ ] Changelogs have only been modified under the `Unreleased` header.
- [ ] Version numbers are bumped in the following order:
- `objc2-proc-macros`
Expand Down
36 changes: 34 additions & 2 deletions crates/header-translator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,15 +490,15 @@ fn update_ci(workspace_dir: &Path, config: &Config) -> io::Result<()> {
.is_some_and(|v| VersionReq::parse("<=10.12").unwrap().matches(v))
// HACK: These depend on `objc2-uniform-type-identifiers`, which
// is not available on macOS 10.12, but will be enabled by `"all"`
&& !["objc2-file-provider", "objc2-health-kit", "objc2-photos"].contains(&&*lib.krate)
&& !["objc2-app-kit", "objc2-file-provider", "objc2-health-kit", "objc2-photos"].contains(&&*lib.krate)
})?;
writer(&mut ci, config, "FRAMEWORKS_MACOS_10_13", |lib| {
lib.macos
.as_ref()
.is_some_and(|v| VersionReq::parse("<=10.13").unwrap().matches(v))
// HACK: These depend on `objc2-uniform-type-identifiers`, which
// is not available on macOS 10.13, but will be enabled by `"all"`
&& !["objc2-file-provider", "objc2-health-kit", "objc2-photos"].contains(&&*lib.krate)
&& !["objc2-app-kit", "objc2-file-provider", "objc2-health-kit", "objc2-photos"].contains(&&*lib.krate)
})?;
writer(&mut ci, config, "FRAMEWORKS_MACOS_11", |lib| {
lib.macos
Expand All @@ -520,11 +520,43 @@ fn update_ci(workspace_dir: &Path, config: &Config) -> io::Result<()> {
.as_ref()
.is_some_and(|v| VersionReq::parse("<=14.0").unwrap().matches(v))
})?;
writer(&mut ci, config, "FRAMEWORKS_MACOS_15", |lib| {
lib.macos
.as_ref()
.is_some_and(|v| VersionReq::parse("<=15.0").unwrap().matches(v))
})?;
writer(&mut ci, config, "FRAMEWORKS_IOS_10", |lib| {
lib.ios
.as_ref()
.is_some_and(|v| VersionReq::parse("<=10.0").unwrap().matches(v))
})?;
writer(&mut ci, config, "FRAMEWORKS_IOS_17", |lib| {
lib.ios
.as_ref()
.is_some_and(|v| VersionReq::parse("<=17.0").unwrap().matches(v))
// HACK: MLCompute and MetalFX are only available on Aarch64
&& !["objc2-ml-compute", "objc2-metal-fx"].contains(&&*lib.krate)
})?;
writer(&mut ci, config, "FRAMEWORKS_TVOS_17", |lib| {
lib.tvos
.as_ref()
.is_some_and(|v| VersionReq::parse("<=17.0").unwrap().matches(v))
})?;
writer(&mut ci, config, "FRAMEWORKS_MAC_CATALYST_17", |lib| {
lib.maccatalyst
.as_ref()
.is_some_and(|v| VersionReq::parse("<=17.0").unwrap().matches(v))
})?;
writer(&mut ci, config, "FRAMEWORKS_VISIONOS_1", |lib| {
lib.visionos
.as_ref()
.is_some_and(|v| VersionReq::parse("<=1.0").unwrap().matches(v))
})?;
writer(&mut ci, config, "FRAMEWORKS_WATCHOS_10", |lib| {
lib.watchos
.as_ref()
.is_some_and(|v| VersionReq::parse("<=10.0").unwrap().matches(v))
})?;
writer(&mut ci, config, "FRAMEWORKS_GNUSTEP", |lib| lib.gnustep)?;

write!(&mut ci, " # END AUTOMATICALLY GENERATED{after}")?;
Expand Down
1 change: 1 addition & 0 deletions crates/objc2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ static_assertions = "1.1.0"
memoffset = "0.9.0"
block2 = { path = "../block2", default-features = false }
objc2-foundation = { path = "../../framework-crates/objc2-foundation", default-features = false, features = [
"NSArray",
"NSDate",
"NSDictionary",
"NSEnumerator",
Expand Down
13 changes: 13 additions & 0 deletions framework-crates/objc2-metal/examples/triangle.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![deny(unsafe_op_in_unsafe_fn)]
#![allow(clippy::incompatible_msrv)]
#![cfg_attr(not(target_os = "macos"), allow(dead_code, unused))]

use core::{cell::OnceCell, ptr::NonNull};

Expand All @@ -8,6 +9,7 @@ use objc2::runtime::ProtocolObject;
use objc2::{
declare_class, msg_send_id, ClassType, DeclaredClass, MainThreadMarker, MainThreadOnly,
};
#[cfg(target_os = "macos")]
use objc2_app_kit::{
NSApplication, NSApplicationActivationPolicy, NSApplicationDelegate, NSBackingStoreType,
NSWindow, NSWindowStyleMask,
Expand All @@ -20,6 +22,7 @@ use objc2_metal::{
MTLLibrary, MTLPackedFloat3, MTLPrimitiveType, MTLRenderCommandEncoder,
MTLRenderPipelineDescriptor, MTLRenderPipelineState,
};
#[cfg(target_os = "macos")]
use objc2_metal_kit::{MTKView, MTKViewDelegate};

#[derive(Copy, Clone)]
Expand Down Expand Up @@ -58,6 +61,7 @@ struct Ivars {
start_date: Retained<NSDate>,
command_queue: OnceCell<Retained<ProtocolObject<dyn MTLCommandQueue>>>,
pipeline_state: OnceCell<Retained<ProtocolObject<dyn MTLRenderPipelineState>>>,
#[cfg(target_os = "macos")]
window: OnceCell<Retained<NSWindow>>,
}

Expand All @@ -82,6 +86,7 @@ declare_class!(
unsafe impl NSObjectProtocol for Delegate {}

// define the delegate methods for the `NSApplicationDelegate` protocol
#[cfg(target_os = "macos")]
unsafe impl NSApplicationDelegate for Delegate {
#[method(applicationDidFinishLaunching:)]
#[allow(non_snake_case)]
Expand Down Expand Up @@ -176,6 +181,7 @@ declare_class!(
}

// define the delegate methods for the `MTKViewDelegate` protocol
#[cfg(target_os = "macos")] // TODO: Support iOS
unsafe impl MTKViewDelegate for Delegate {
#[method(drawInMTKView:)]
#[allow(non_snake_case)]
Expand Down Expand Up @@ -288,12 +294,14 @@ impl Delegate {
start_date: unsafe { NSDate::now() },
command_queue: OnceCell::default(),
pipeline_state: OnceCell::default(),
#[cfg(target_os = "macos")]
window: OnceCell::default(),
});
unsafe { msg_send_id![super(this), init] }
}
}

#[cfg(target_os = "macos")]
fn main() {
let mtm = MainThreadMarker::new().unwrap();
// configure the app
Expand All @@ -308,3 +316,8 @@ fn main() {
// run the app
app.run();
}

#[cfg(not(target_os = "macos"))]
fn main() {
panic!("This example is currently only supported on macOS");
}
16 changes: 16 additions & 0 deletions framework-crates/objc2-web-kit/examples/browser.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![deny(unsafe_op_in_unsafe_fn)]
#![allow(clippy::incompatible_msrv)]
#![cfg_attr(not(target_os = "macos"), allow(dead_code, unused))]
use core::cell::OnceCell;

use objc2::{
Expand All @@ -9,6 +10,7 @@ use objc2::{
sel, ClassType, DeclaredClass, MainThreadMarker, MainThreadOnly,
};
#[allow(deprecated)]
#[cfg(target_os = "macos")]
use objc2_app_kit::{
NSApplication, NSApplicationActivationPolicy, NSApplicationDelegate, NSBackingStoreType,
NSBezelStyle, NSButton, NSColor, NSControl, NSControlTextEditingDelegate, NSLayoutAttribute,
Expand All @@ -19,6 +21,7 @@ use objc2_foundation::{
ns_string, NSNotification, NSObject, NSObjectProtocol, NSPoint, NSRect, NSSize, NSURLRequest,
NSURL,
};
#[cfg(target_os = "macos")]
use objc2_web_kit::{WKNavigation, WKNavigationDelegate, WKWebView};

macro_rules! idcell {
Expand All @@ -41,8 +44,11 @@ macro_rules! idcell {

#[derive(Default)]
struct Ivars {
#[cfg(target_os = "macos")]
nav_url: OnceCell<Retained<NSTextField>>,
#[cfg(target_os = "macos")]
web_view: OnceCell<Retained<WKWebView>>,
#[cfg(target_os = "macos")]
window: OnceCell<Retained<NSWindow>>,
}

Expand All @@ -65,6 +71,7 @@ declare_class!(

unsafe impl NSObjectProtocol for Delegate {}

#[cfg(target_os = "macos")]
unsafe impl NSApplicationDelegate for Delegate {
#[method(applicationDidFinishLaunching:)]
#[allow(non_snake_case)]
Expand Down Expand Up @@ -245,6 +252,7 @@ declare_class!(
}
}

#[cfg(target_os = "macos")]
unsafe impl NSControlTextEditingDelegate for Delegate {
#[method(control:textView:doCommandBySelector:)]
#[allow(non_snake_case)]
Expand All @@ -265,8 +273,10 @@ declare_class!(
}
}

#[cfg(target_os = "macos")]
unsafe impl NSTextFieldDelegate for Delegate {}

#[cfg(target_os = "macos")] // TODO: Enable this on iOS
unsafe impl WKNavigationDelegate for Delegate {
#[method(webView:didFinishNavigation:)]
#[allow(non_snake_case)]
Expand All @@ -293,6 +303,7 @@ impl Delegate {
}
}

#[cfg(target_os = "macos")]
fn main() {
let mtm = MainThreadMarker::new().unwrap();
let app = NSApplication::sharedApplication(mtm);
Expand All @@ -306,3 +317,8 @@ fn main() {
// run the app
app.run();
}

#[cfg(not(target_os = "macos"))]
fn main() {
panic!("This example is currently only supported on macOS");
}
2 changes: 1 addition & 1 deletion helper-scripts/test-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set -euxo pipefail
export CARGO_TARGET_DIR=$HOME/Desktop/objc2-target
export MACOSX_DEPLOYMENT_TARGET=10.12
export CRATES='--package=block2 --package=objc2 --package=objc2-encode --package=objc2-proc-macros --package=tests'
export FRAMEWORKS_MACOS_10_12='--package=objc2-accounts --package=objc2-app-kit --package=objc2-automator --package=objc2-av-kit --package=objc2-cloud-kit --package=objc2-contacts --package=objc2-contacts-ui --package=objc2-core-bluetooth --package=objc2-core-data --package=objc2-core-image --package=objc2-core-location --package=objc2-core-wlan --package=objc2-event-kit --package=objc2-exception-handling --package=objc2-finder-sync --package=objc2-foundation --package=objc2-game-controller --package=objc2-game-kit --package=objc2-input-method-kit --package=objc2-local-authentication --package=objc2-map-kit --package=objc2-media-player --package=objc2-metal --package=objc2-metal-kit --package=objc2-multipeer-connectivity --package=objc2-network-extension --package=objc2-osa-kit --package=objc2-photos-ui --package=objc2-quartz-core --package=objc2-screen-saver --package=objc2-service-management --package=objc2-social --package=objc2-store-kit --package=objc2-web-kit'
export FRAMEWORKS_MACOS_10_12='--package=objc2-accounts --package=objc2-automator --package=objc2-av-kit --package=objc2-cloud-kit --package=objc2-contacts --package=objc2-contacts-ui --package=objc2-core-bluetooth --package=objc2-core-data --package=objc2-core-image --package=objc2-core-location --package=objc2-core-wlan --package=objc2-event-kit --package=objc2-exception-handling --package=objc2-finder-sync --package=objc2-foundation --package=objc2-game-controller --package=objc2-game-kit --package=objc2-input-method-kit --package=objc2-local-authentication --package=objc2-map-kit --package=objc2-media-player --package=objc2-metal --package=objc2-metal-kit --package=objc2-multipeer-connectivity --package=objc2-network-extension --package=objc2-osa-kit --package=objc2-photos-ui --package=objc2-quartz-core --package=objc2-screen-saver --package=objc2-service-management --package=objc2-social --package=objc2-store-kit --package=objc2-web-kit'
export FRAMEWORKS_IOS_9='--package=objc2-foundation --package=objc2-metal'

# Test on macOS 32bit
Expand Down

0 comments on commit 4ec407e

Please sign in to comment.