Skip to content
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
4 changes: 4 additions & 0 deletions .github/workflows/compatibility_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jobs:
OPENSWIFTUI_USE_LOCAL_DEPS: 1
OPENGRAPH_USE_LOCAL_DEPS: 1
OPENGRAPH_TARGET_RELEASE: ${{ matrix.release }}
OPENBOX_USE_LOCAL_DEPS: 1
OPENBOX_TARGET_RELEASE: ${{ matrix.release }}
DARWIN_PRIVATE_FRAMEWORKS_TARGET_RELEASE: ${{ matrix.release }}
GH_TOKEN: ${{ github.token }}
steps:
Expand Down Expand Up @@ -75,6 +77,8 @@ jobs:
OPENSWIFTUI_USE_LOCAL_DEPS: 1
OPENGRAPH_USE_LOCAL_DEPS: 1
OPENGRAPH_TARGET_RELEASE: ${{ matrix.release }}
OPENBOX_USE_LOCAL_DEPS: 1
OPENBOX_TARGET_RELEASE: ${{ matrix.release }}
DARWIN_PRIVATE_FRAMEWORKS_TARGET_RELEASE: ${{ matrix.release }}
GH_TOKEN: ${{ github.token }}
steps:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ jobs:
OPENSWIFTUI_USE_LOCAL_DEPS: 1
OPENGRAPH_USE_LOCAL_DEPS: 1
OPENGRAPH_TARGET_RELEASE: ${{ matrix.release }}
OPENBOX_USE_LOCAL_DEPS: 1
OPENBOX_TARGET_RELEASE: ${{ matrix.release }}
DARWIN_PRIVATE_FRAMEWORKS_TARGET_RELEASE: ${{ matrix.release }}
GH_TOKEN: ${{ github.token }}
steps:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
OPENSWIFTUI_USE_LOCAL_DEPS: 1
OPENGRAPH_USE_LOCAL_DEPS: 1
OPENGRAPH_TARGET_RELEASE: ${{ matrix.release }}
OPENBOX_USE_LOCAL_DEPS: 1
OPENBOX_TARGET_RELEASE: ${{ matrix.release }}
DARWIN_PRIVATE_FRAMEWORKS_TARGET_RELEASE: ${{ matrix.release }}
GH_TOKEN: ${{ github.token }}
steps:
Expand Down
15 changes: 12 additions & 3 deletions Package.resolved

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

52 changes: 38 additions & 14 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ let openSwiftUICoreTarget = Target.target(
dependencies: [
"OpenSwiftUI_SPI",
.product(name: "OpenGraphShims", package: "OpenGraph"),
.product(name: "OpenBoxShims", package: "OpenBox"),
],
swiftSettings: sharedSwiftSettings
)
Expand All @@ -95,6 +96,7 @@ let openSwiftUITarget = Target.target(
"COpenSwiftUI",
.target(name: "CoreServices", condition: .when(platforms: [.iOS])),
.product(name: "OpenGraphShims", package: "OpenGraph"),
.product(name: "OpenBoxShims", package: "OpenBox"),
],
swiftSettings: sharedSwiftSettings
)
Expand Down Expand Up @@ -231,12 +233,6 @@ let package = Package(
]
)

#if os(macOS)
let attributeGraphCondition = envEnable("OPENGRAPH_ATTRIBUTEGRAPH", default: true)
#else
let attributeGraphCondition = envEnable("OPENGRAPH_ATTRIBUTEGRAPH")
#endif

extension Target {
func addAGSettings() {
// FIXME: Weird SwiftPM behavior for test Target. Otherwize we'll get the following error message
Expand All @@ -246,6 +242,15 @@ extension Target {
swiftSettings.append(.define("OPENGRAPH_ATTRIBUTEGRAPH"))
self.swiftSettings = swiftSettings
}

func addRBSettings() {
// FIXME: Weird SwiftPM behavior for test Target. Otherwize we'll get the following error message
// "could not determine executable path for bundle 'RenderBox.framework'"
dependencies.append(.product(name: "RenderBox", package: "DarwinPrivateFrameworks"))
var swiftSettings = swiftSettings ?? []
swiftSettings.append(.define("OPENBOX_RENDERBOX"))
self.swiftSettings = swiftSettings
}

func addOpenCombineSettings() {
dependencies.append(.product(name: "OpenCombine", package: "OpenCombine"))
Expand All @@ -271,15 +276,13 @@ extension Target {

let useLocalDeps = envEnable("OPENSWIFTUI_USE_LOCAL_DEPS")

#if os(macOS)
let attributeGraphCondition = envEnable("OPENGRAPH_ATTRIBUTEGRAPH", default: true)
#else
let attributeGraphCondition = envEnable("OPENGRAPH_ATTRIBUTEGRAPH")
#endif

if attributeGraphCondition {
let privateFrameworkRepo: Package.Dependency
if useLocalDeps {
privateFrameworkRepo = Package.Dependency.package(path: "../DarwinPrivateFrameworks")
} else {
privateFrameworkRepo = Package.Dependency.package(url: "https://github.com/OpenSwiftUIProject/DarwinPrivateFrameworks.git", branch: "main")
}
package.dependencies.append(privateFrameworkRepo)

openSwiftUICoreTarget.addAGSettings()
openSwiftUITarget.addAGSettings()

Expand All @@ -290,14 +293,35 @@ if attributeGraphCondition {
openSwiftUIBridgeTestTarget.addAGSettings()
}

#if os(macOS)
let renderBoxCondition = envEnable("OPENBOX_RENDERBOX", default: true)
#else
let renderBoxCondition = envEnable("OPENBOX_RENDERBOX")
#endif

if renderBoxCondition {
openSwiftUICoreTarget.addRBSettings()
openSwiftUITarget.addRBSettings()

OpenSwiftUI_SPITestTarget.addRBSettings()
openSwiftUICoreTestTarget.addRBSettings()
openSwiftUITestTarget.addRBSettings()
openSwiftUICompatibilityTestTarget.addRBSettings()
openSwiftUIBridgeTestTarget.addRBSettings()
}

if useLocalDeps {
package.dependencies += [
.package(path: "../OpenGraph"),
.package(path: "../OpenBox"),
.package(path: "../DarwinPrivateFrameworks"),
]
} else {
package.dependencies += [
// FIXME: on Linux platform: OG contains unsafe build flags which prevents us using version dependency
.package(url: "https://github.com/OpenSwiftUIProject/OpenGraph", branch: "main"),
.package(url: "https://github.com/OpenSwiftUIProject/OpenBox", branch: "main"),
.package(url: "https://github.com/OpenSwiftUIProject/DarwinPrivateFrameworks.git", branch: "main"),
]
}

Expand Down
4 changes: 3 additions & 1 deletion Scripts/CI/darwin_setup_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ filepath() {
REPO_ROOT="$(dirname $(dirname $(dirname $(filepath $0))))"
cd $REPO_ROOT

Scripts/CI/og_setup.sh
Scripts/CI/og_setup.sh
Scripts/CI/ob_setup.sh
Scripts/CI/framework_setup.sh
27 changes: 27 additions & 0 deletions Scripts/CI/framework_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

# A `realpath` alternative using the default C implementation.
filepath() {
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
}

REPO_ROOT="$(dirname $(dirname $(dirname $(filepath $0))))"

clone_checkout_dpf() {
cd $REPO_ROOT
revision=$(Scripts/CI/get_revision.sh darwinprivateframeworks)
cd ..
if [ ! -d DarwinPrivateFrameworks ]; then
gh repo clone OpenSwiftUIProject/DarwinPrivateFrameworks
fi
cd DarwinPrivateFrameworks
git checkout --quiet $revision
}

update_dpf() {
cd $REPO_ROOT/../DarwinPrivateFrameworks
swift package update-xcframeworks --allow-writing-to-package-directory
}

clone_checkout_dpf
update_dpf
27 changes: 27 additions & 0 deletions Scripts/CI/ob_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

# A `realpath` alternative using the default C implementation.
filepath() {
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
}

REPO_ROOT="$(dirname $(dirname $(dirname $(filepath $0))))"

clone_checkout_og() {
cd $REPO_ROOT
revision=$(Scripts/CI/get_revision.sh openbox)
cd ..
if [ ! -d OpenBox ]; then
gh repo clone OpenSwiftUIProject/OpenBox
fi
cd OpenBox
git checkout --quiet $revision
}

update_og() {
cd $REPO_ROOT/../OpenBox
./Scripts/CI/darwin_setup_build.sh
}

clone_checkout_og
update_og
4 changes: 3 additions & 1 deletion Scripts/CI/og_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ clone_checkout_og() {
cd $REPO_ROOT
revision=$(Scripts/CI/get_revision.sh opengraph)
cd ..
gh repo clone OpenSwiftUIProject/OpenGraph
if [ ! -d OpenGraph ]; then
gh repo clone OpenSwiftUIProject/OpenGraph
fi
cd OpenGraph
git checkout --quiet $revision
}
Expand Down
15 changes: 11 additions & 4 deletions Sources/OpenSwiftUICore/Data/StrongHash.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// OpenSwiftUICore
//
// Audited for iOS 18.0
// Status: Blocked by OGTypeGetSignature and RBUUID
// Status: Blocked by OGTypeGetSignature

#if OPENSWIFTUI_SWIFT_CRYPTO
import Crypto
Expand All @@ -12,6 +12,7 @@ import CommonCrypto
#endif

import Foundation
import OpenBoxShims

package protocol StronglyHashable {
func hash(into hasher: inout StrongHasher)
Expand Down Expand Up @@ -212,9 +213,15 @@ extension Float: StronglyHashableByBitPattern {}
extension Double: StronglyHashableByBitPattern {}
extension UUID: StronglyHashableByBitPattern {}

//extension RenderBox.RBUUID {
// package init(hash: StrongHash)
//}
extension OBUUID {
package init(hash: StrongHash) {
self.init(
UInt64(hash.words.0) | (UInt64(hash.words.1) << 32),
UInt64(hash.words.2) | (UInt64(hash.words.3) << 32),
5
)
}
}

extension StrongHash: ProtobufMessage {
package func encode(to encoder: inout ProtobufEncoder) {
Expand Down
27 changes: 27 additions & 0 deletions Tests/OpenSwiftUICoreTests/Data/StrongHashTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import OpenSwiftUICore
import Testing
import Foundation
import OpenBoxShims

struct StrongHashTests {
@Test(
Expand Down Expand Up @@ -101,6 +102,32 @@ struct StrongHashTests {
#expect(s2 == s)
}

@Test(
arguments: [
(StrongHash(), (0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80)),
(StrongHash(of: 1), (0x3D, 0x58, 0x9E, 0xE2, 0x73, 0xBE, 0x13, 0x43, 0x7E, 0x7E, 0xCF, 0x76, 0x0F, 0x3F, 0xBD, 0x8D)),
]
)
func obUUID(hash: StrongHash, expectedBytes: (UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8)) {
let uuid = OBUUID(hash: hash)
#expect(uuid.bytes.0 == expectedBytes.0)
#expect(uuid.bytes.1 == expectedBytes.1)
#expect(uuid.bytes.2 == expectedBytes.2)
#expect(uuid.bytes.3 == expectedBytes.3)
#expect(uuid.bytes.4 == expectedBytes.4)
#expect(uuid.bytes.5 == expectedBytes.5)
#expect(uuid.bytes.6 == expectedBytes.6)
#expect(uuid.bytes.7 == expectedBytes.7)
#expect(uuid.bytes.8 == expectedBytes.8)
#expect(uuid.bytes.9 == expectedBytes.9)
#expect(uuid.bytes.10 == expectedBytes.10)
#expect(uuid.bytes.11 == expectedBytes.11)
#expect(uuid.bytes.12 == expectedBytes.12)
#expect(uuid.bytes.13 == expectedBytes.13)
#expect(uuid.bytes.14 == expectedBytes.14)
#expect(uuid.bytes.15 == expectedBytes.15)
}

@Test(
arguments: [
(StrongHash(), "0a140000000000000000000000000000000000000000"),
Expand Down
Loading