From 83e3951c37c979a0851425492b438444d68f6c65 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Tue, 9 Jul 2024 16:24:26 +0200 Subject: [PATCH] [Darwin] Treat this code as a framework, which simplifies things a little bit. (#20833) Also move the TimeSpec struct to its own file, this will be necessary for Xcode 16. --- src/Darwin/KernelNotification.cs | 7 ------- src/Darwin/TimeSpec.cs | 15 +++++++++++++++ src/Makefile | 4 ---- src/build/generator-frameworks.g.cs | 3 +++ src/darwin.cs | 2 ++ src/frameworks.sources | 10 ++++++++++ src/rsp/dotnet/macos-defines-dotnet.rsp | 1 + src/rsp/macos-defines.rsp | 1 + 8 files changed, 32 insertions(+), 11 deletions(-) create mode 100644 src/Darwin/TimeSpec.cs create mode 100644 src/darwin.cs diff --git a/src/Darwin/KernelNotification.cs b/src/Darwin/KernelNotification.cs index b1afc87e918c..74234fedb2c9 100644 --- a/src/Darwin/KernelNotification.cs +++ b/src/Darwin/KernelNotification.cs @@ -41,13 +41,6 @@ #endif namespace Darwin { - - [StructLayout (LayoutKind.Sequential)] - public struct TimeSpec { - public nint Seconds; - public nint NanoSeconds; - } - [StructLayout (LayoutKind.Sequential)] public struct KernelEvent { public IntPtr /* uintptr_tr */ Ident; diff --git a/src/Darwin/TimeSpec.cs b/src/Darwin/TimeSpec.cs new file mode 100644 index 000000000000..5c2d0f1e4bbe --- /dev/null +++ b/src/Darwin/TimeSpec.cs @@ -0,0 +1,15 @@ +using System; +using System.Runtime.InteropServices; + +using ObjCRuntime; + +#nullable enable + +namespace Darwin { + [StructLayout (LayoutKind.Sequential)] + [NativeName ("timespec")] + public struct TimeSpec { + public nint Seconds; + public nint NanoSeconds; + } +} diff --git a/src/Makefile b/src/Makefile index 9789e4c000c8..643b1e7ae600 100644 --- a/src/Makefile +++ b/src/Makefile @@ -453,15 +453,11 @@ MACOS_CORE_SOURCES += \ MACOS_DOTNET_SOURCES += \ $(MAC_DOTNET_EXTRA_CORE_SOURCES) \ $(MACOS_BUILD_DIR)/AssemblyInfo.cs \ - Darwin/KernelNotification.cs \ - Darwin/SystemLog.cs \ $(SHARED_DESIGNER_CS) \ MACOS_SOURCES += \ $(MAC_EXTRA_CORE_SOURCES) \ $(MACOS_BUILD_DIR)/AssemblyInfo.cs \ - Darwin/KernelNotification.cs \ - Darwin/SystemLog.cs \ $(SHARED_DESIGNER_CS) \ # CFNetwork is shipped: diff --git a/src/build/generator-frameworks.g.cs b/src/build/generator-frameworks.g.cs index 9e7c8b98ce1f..0d1c687ac53b 100644 --- a/src/build/generator-frameworks.g.cs +++ b/src/build/generator-frameworks.g.cs @@ -192,6 +192,7 @@ partial class Frameworks { "CoreVideo", "CoreWlan", "CryptoTokenKit", + "Darwin", "DeviceCheck", "EventKit", "ExecutionPolicy", @@ -613,6 +614,7 @@ partial class Frameworks { bool? _CoreVideo; bool? _CoreWlan; bool? _CryptoTokenKit; + bool? _Darwin; bool? _DeviceCheck; bool? _DeviceDiscoveryExtension; bool? _DeviceDiscoveryUI; @@ -782,6 +784,7 @@ partial class Frameworks { public bool HaveCoreVideo { get { if (!_CoreVideo.HasValue) _CoreVideo = GetValue ("CoreVideo"); return _CoreVideo.Value; } } public bool HaveCoreWlan { get { if (!_CoreWlan.HasValue) _CoreWlan = GetValue ("CoreWlan"); return _CoreWlan.Value; } } public bool HaveCryptoTokenKit { get { if (!_CryptoTokenKit.HasValue) _CryptoTokenKit = GetValue ("CryptoTokenKit"); return _CryptoTokenKit.Value; } } + public bool HaveDarwin { get { if (!_Darwin.HasValue) _Darwin = GetValue ("Darwin"); return _Darwin.Value; } } public bool HaveDeviceCheck { get { if (!_DeviceCheck.HasValue) _DeviceCheck = GetValue ("DeviceCheck"); return _DeviceCheck.Value; } } public bool HaveDeviceDiscoveryExtension { get { if (!_DeviceDiscoveryExtension.HasValue) _DeviceDiscoveryExtension = GetValue ("DeviceDiscoveryExtension"); return _DeviceDiscoveryExtension.Value; } } public bool HaveDeviceDiscoveryUI { get { if (!_DeviceDiscoveryUI.HasValue) _DeviceDiscoveryUI = GetValue ("DeviceDiscoveryUI"); return _DeviceDiscoveryUI.Value; } } diff --git a/src/darwin.cs b/src/darwin.cs new file mode 100644 index 000000000000..dd2d43774a02 --- /dev/null +++ b/src/darwin.cs @@ -0,0 +1,2 @@ +// Darwin isn't really a framework, but to simplify our build logic we treat it as such. +// This also means this file is needed, even though it's empty, because our build logic will automatically include it in the build. diff --git a/src/frameworks.sources b/src/frameworks.sources index 0781a0aed919..375c76500dae 100644 --- a/src/frameworks.sources +++ b/src/frameworks.sources @@ -731,6 +731,15 @@ COREWLAN_SOURCES = \ CoreWlan/CWInterface.cs \ CoreWlan/CWKeychain.cs \ +# DARWIN + +DARWIN_CORE_SOURCES = \ + Darwin/TimeSpec.cs \ + +DARWIN_SOURCES = \ + Darwin/KernelNotification.cs \ + Darwin/SystemLog.cs \ + # DeviceDiscoveryExtension DEVICEDISCOVERYEXTENSION_API_SOURCES = \ @@ -2101,6 +2110,7 @@ MACOS_FRAMEWORKS = \ CoreSpotlight \ CoreText \ CoreWlan \ + Darwin \ EventKit \ ExecutionPolicy \ ExtensionKit \ diff --git a/src/rsp/dotnet/macos-defines-dotnet.rsp b/src/rsp/dotnet/macos-defines-dotnet.rsp index 186c40fbcfd0..c397de592022 100644 --- a/src/rsp/dotnet/macos-defines-dotnet.rsp +++ b/src/rsp/dotnet/macos-defines-dotnet.rsp @@ -40,6 +40,7 @@ -d:HAS_COREVIDEO -d:HAS_COREWLAN -d:HAS_CRYPTOTOKENKIT +-d:HAS_DARWIN -d:HAS_DEVICECHECK -d:HAS_EVENTKIT -d:HAS_EXECUTIONPOLICY diff --git a/src/rsp/macos-defines.rsp b/src/rsp/macos-defines.rsp index 9e8476d1f5f5..e03677260fe9 100644 --- a/src/rsp/macos-defines.rsp +++ b/src/rsp/macos-defines.rsp @@ -41,6 +41,7 @@ -d:HAS_COREVIDEO -d:HAS_COREWLAN -d:HAS_CRYPTOTOKENKIT +-d:HAS_DARWIN -d:HAS_DEVICECHECK -d:HAS_EVENTKIT -d:HAS_EXECUTIONPOLICY