Skip to content

Commit

Permalink
Add the SystemConfiguration framework
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Jan 11, 2025
1 parent 3fe19b2 commit ea34d87
Show file tree
Hide file tree
Showing 12 changed files with 210 additions and 16 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/ci.yml

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion crates/header-translator/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@ impl Config {
Ok(Self { libraries })
}

pub fn try_library(&self, library_name: &str) -> Option<&LibraryConfig> {
self.libraries.get(library_name)
}

pub fn library(&self, library_name: &str) -> &LibraryConfig {
self.libraries.get(library_name).unwrap_or_else(|| {
self.try_library(library_name).unwrap_or_else(|| {
error!("tried to get library config from {library_name:?}");
self.libraries
.get("__builtin__")
Expand Down
4 changes: 2 additions & 2 deletions crates/header-translator/src/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl Location {
match self.library_name() {
"__builtin__" | "__core__" => None,
library if library == emission_library => None,
library => Some(&config.library(library).krate),
library => Some(&config.try_library(library)?.krate),
}
}

Expand Down Expand Up @@ -199,7 +199,7 @@ impl Location {
// Matches e.g. objc2-foundation/NSArray, but not objc2 or
// libc (since that is configured in the source itself).
library => {
let krate = &config.library(library).krate;
let krate = &config.try_library(library)?.krate;
let required = config
.library(emission_library)
.required_crates
Expand Down
1 change: 1 addition & 0 deletions crates/objc2/src/topics/about_generated/list_data.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
| `Speech` | [![`objc2-speech`](https://badgen.net/crates/v/objc2-speech)](https://crates.io/crates/objc2-speech) | [![docs.rs](https://docs.rs/objc2-speech/badge.svg)](https://docs.rs/objc2-speech/) |
| `StoreKit` | [![`objc2-store-kit`](https://badgen.net/crates/v/objc2-store-kit)](https://crates.io/crates/objc2-store-kit) | [![docs.rs](https://docs.rs/objc2-store-kit/badge.svg)](https://docs.rs/objc2-store-kit/) |
| `Symbols` | [![`objc2-symbols`](https://badgen.net/crates/v/objc2-symbols)](https://crates.io/crates/objc2-symbols) | [![docs.rs](https://docs.rs/objc2-symbols/badge.svg)](https://docs.rs/objc2-symbols/) |
| `SystemConfiguration` | [![`objc2-system-configuration`](https://badgen.net/crates/v/objc2-system-configuration)](https://crates.io/crates/objc2-system-configuration) | [![docs.rs](https://docs.rs/objc2-system-configuration/badge.svg)](https://docs.rs/objc2-system-configuration/) |
| `SystemExtensions` | [![`objc2-system-extensions`](https://badgen.net/crates/v/objc2-system-extensions)](https://crates.io/crates/objc2-system-extensions) | [![docs.rs](https://docs.rs/objc2-system-extensions/badge.svg)](https://docs.rs/objc2-system-extensions/) |
| `UIKit` | [![`objc2-ui-kit`](https://badgen.net/crates/v/objc2-ui-kit)](https://crates.io/crates/objc2-ui-kit) | [![docs.rs](https://docs.rs/objc2-ui-kit/badge.svg)](https://docs.rs/objc2-ui-kit/) |
| `UniformTypeIdentifiers` | [![`objc2-uniform-type-identifiers`](https://badgen.net/crates/v/objc2-uniform-type-identifiers)](https://crates.io/crates/objc2-uniform-type-identifiers) | [![docs.rs](https://docs.rs/objc2-uniform-type-identifiers/badge.svg)](https://docs.rs/objc2-uniform-type-identifiers/) |
Expand Down
3 changes: 3 additions & 0 deletions crates/test-frameworks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ test-frameworks = [
"objc2-store-kit/all",
"dep:objc2-symbols",
"objc2-symbols/all",
"dep:objc2-system-configuration",
"objc2-system-configuration/all",
"dep:objc2-system-extensions",
"objc2-system-extensions/all",
"dep:objc2-ui-kit",
Expand Down Expand Up @@ -287,6 +289,7 @@ objc2-metal-performance-shaders-graph = { path = "../../framework-crates/objc2-m
objc2-multipeer-connectivity = { path = "../../framework-crates/objc2-multipeer-connectivity", optional = true }
objc2-photos = { path = "../../framework-crates/objc2-photos", optional = true }
objc2-quartz-core = { path = "../../framework-crates/objc2-quartz-core", optional = true }
objc2-system-configuration = { path = "../../framework-crates/objc2-system-configuration", optional = true }
objc2-vision = { path = "../../framework-crates/objc2-vision", optional = true }

[target.'cfg(any(target_os = "ios", target_os = "tvos", target_os = "visionos"))'.dependencies]
Expand Down
119 changes: 119 additions & 0 deletions framework-crates/objc2-system-configuration/Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions framework-crates/objc2-system-configuration/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions framework-crates/objc2-system-configuration/src/generated

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions framework-crates/objc2-system-configuration/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//! # Bindings to the `SystemConfiguration` framework
//!
//! See [Apple's docs][apple-doc] and [the general docs on framework crates][framework-crates] for more information.
//!
//! [apple-doc]: https://developer.apple.com/documentation/systemconfiguration/
//! [framework-crates]: https://docs.rs/objc2/latest/objc2/topics/about_generated/index.html
#![no_std]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
// Update in Cargo.toml as well.
#![doc(html_root_url = "https://docs.rs/objc2-system-configuration/0.2.2")]

#[cfg(feature = "alloc")]
extern crate alloc;

#[cfg(feature = "std")]
extern crate std;

mod generated;
#[allow(unused_imports, unreachable_pub)]
pub use self::generated::*;

#[allow(dead_code)]
pub(crate) type Boolean = u8; // unsigned char
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
framework = "SystemConfiguration"
crate = "objc2-system-configuration"
required-crates = ["objc2-core-foundation"]
custom-lib-rs = true
macos = "10.1"
maccatalyst = "13.0"
ios = "2.0"
tvos = "9.0"
visionos = "1.0"

# Needs AuthorizationRef from Security framework
fn.SCPreferencesCreateWithAuthorization.skipped = true

# Needs dispatch_queue_t from libdispatch
fn.SCDynamicStoreSetDispatchQueue.skipped = true
fn.SCNetworkConnectionSetDispatchQueue.skipped = true
fn.SCNetworkReachabilitySetDispatchQueue.skipped = true
fn.SCPreferencesSetDispatchQueue.skipped = true

0 comments on commit ea34d87

Please sign in to comment.