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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ DerivedData/
.swiftpm/configuration/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
.claude/
.rb_template/
3 changes: 1 addition & 2 deletions .spi.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
version: 1
builder:
configs:
- swift_version: 6.0
documentation_targets: [OpenRenderBox]
- documentation_targets: [OpenRenderBox]
4 changes: 2 additions & 2 deletions Package.resolved

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

42 changes: 20 additions & 22 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version: 6.0
// swift-tools-version: 6.1

import Foundation
import PackageDescription
Expand Down Expand Up @@ -66,24 +66,25 @@ if libraryEvolutionCondition {

// MARK: - Targets

let openBoxTarget = Target.target(
let openRenderBoxTarget = Target.target(
name: "OpenRenderBox",
cSettings: sharedCSettings,
cxxSettings: sharedCxxSettings
)
let openBoxShimsTarget = Target.target(
let openRenderBoxShimsTarget = Target.target(
name: "OpenRenderBoxShims",
swiftSettings: sharedSwiftSettings
)
let openBoxTestTarget = Target.testTarget(
name: "OpenRenderBoxTests",
let openRenderBoxCxxTestTarget = Target.testTarget(
name: "OpenRenderBoxCxxTests",
dependencies: [
"OpenRenderBox",
],
exclude: ["README.md"],
swiftSettings: sharedSwiftSettings
cSettings: sharedCSettings + [.define("SWIFT_TESTING")],
swiftSettings: sharedSwiftSettings + [.interoperabilityMode(.Cxx)]
)
let openBoxCompatibilityTestTarget = Target.testTarget(
let openRenderBoxCompatibilityTestTarget = Target.testTarget(
name: "OpenRenderBoxCompatibilityTests",
dependencies: [
.product(name: "RealModule", package: "swift-numerics"),
Expand Down Expand Up @@ -114,11 +115,10 @@ let package = Package(
.package(url: "https://github.com/apple/swift-numerics", from: "1.0.2"),
],
targets: [
openBoxTarget,
openBoxShimsTarget,

openBoxTestTarget,
openBoxCompatibilityTestTarget,
openRenderBoxTarget,
openRenderBoxShimsTarget,
openRenderBoxCxxTestTarget,
openRenderBoxCompatibilityTestTarget,
],
cxxLanguageStandard: .cxx20
)
Expand All @@ -135,34 +135,32 @@ if renderBoxCondtion {
privateFrameworkRepo = Package.Dependency.package(url: "https://github.com/OpenSwiftUIProject/DarwinPrivateFrameworks.git", branch: "main")
}
package.dependencies.append(privateFrameworkRepo)
var swiftSettings: [SwiftSetting] = (openBoxShimsTarget.swiftSettings ?? [])
var swiftSettings: [SwiftSetting] = (openRenderBoxShimsTarget.swiftSettings ?? [])
swiftSettings.append(.define("OPENRENDERBOX_RENDERBOX"))
openBoxShimsTarget.swiftSettings = swiftSettings
openBoxShimsTarget.dependencies.append(
openRenderBoxShimsTarget.swiftSettings = swiftSettings
openRenderBoxShimsTarget.dependencies.append(
.product(name: "RenderBox", package: "DarwinPrivateFrameworks")
)

let rbVersion = Context.environment["DARWIN_PRIVATE_FRAMEWORKS_TARGET_RELEASE"].flatMap { Int($0) } ?? 2024
package.platforms = switch rbVersion {
case 2024: [.iOS(.v18), .macOS(.v15), .macCatalyst(.v18), .tvOS(.v18), .watchOS(.v10), .visionOS(.v2)]
case 2021: [.iOS(.v15), .macOS(.v12), .macCatalyst(.v15), .tvOS(.v15), .watchOS(.v7)]
default: nil
}
} else {
openBoxShimsTarget.dependencies.append("OpenRenderBox")
openRenderBoxShimsTarget.dependencies.append("OpenRenderBox")
}

let compatibilityTestCondition = envEnable("OPENRENDERBOX_COMPATIBILITY_TEST")
if compatibilityTestCondition && renderBoxCondtion {
openBoxCompatibilityTestTarget.dependencies.append(
openRenderBoxCompatibilityTestTarget.dependencies.append(
.product(name: "RenderBox", package: "DarwinPrivateFrameworks")
)

var swiftSettings: [SwiftSetting] = (openBoxCompatibilityTestTarget.swiftSettings ?? [])
var swiftSettings: [SwiftSetting] = (openRenderBoxCompatibilityTestTarget.swiftSettings ?? [])
swiftSettings.append(.define("OPENRENDERBOX_COMPATIBILITY_TEST"))
openBoxCompatibilityTestTarget.swiftSettings = swiftSettings
openRenderBoxCompatibilityTestTarget.swiftSettings = swiftSettings
} else {
openBoxCompatibilityTestTarget.dependencies.append("OpenRenderBox")
openRenderBoxCompatibilityTestTarget.dependencies.append("OpenRenderBox")
}

extension [Platform] {
Expand Down
179 changes: 179 additions & 0 deletions Scripts/bump_rb_pr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
#!/bin/zsh

set -e

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

# Capture script name for usage display
SCRIPT_NAME="$(basename "$0")"

# Usage function
show_usage() {
cat << EOF
Usage: $SCRIPT_NAME [branch] [--force] [--help]

Automated script to update DarwinPrivateFrameworks with RenderBox changes.

Arguments:
branch Target branch to generate from (default: main)

Options:
--force Force push the branch when creating PR
--help Show this help message

Examples:
$SCRIPT_NAME # Update from main branch
$SCRIPT_NAME develop # Update from develop branch
$SCRIPT_NAME main --force # Update from main with force push
$SCRIPT_NAME --help # Show this help

Description:
This script automates the process of updating DarwinPrivateFrameworks
with the latest RenderBox changes by:
1. Setting up a git worktree for the target branch
2. Cloning DarwinPrivateFrameworks repository
3. Generating RB template from OpenRenderBox
4. Updating headers and Swift interface templates
5. Creating and pushing a PR with the changes
EOF
}

# Parse command line arguments
TARGET_BRANCH="main"
FORCE_PUSH=""

# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
--help)
show_usage
exit 0
;;
--force)
FORCE_PUSH="--force"
shift
;;
*)
TARGET_BRANCH="$1"
shift
;;
esac
done

SCRIPT_ROOT="$(dirname $(dirname $(filepath $0)))"
ORB_REPO_DIR="$SCRIPT_ROOT/.orb_repo"
OPENRENDERBOX_ROOT="$ORB_REPO_DIR"
RB_REPO_DIR="$SCRIPT_ROOT/.rb_repo"

echo "Starting DarwinPrivateFrameworks bump PR workflow..."
echo "Target branch: $TARGET_BRANCH"
if [[ -n "$FORCE_PUSH" ]]; then
echo "Force push: enabled"
fi

# Cleanup function
cleanup() {
if [[ -d "$RB_REPO_DIR" ]]; then
echo "Cleaning up temporary repository..."
rm -rf "$RB_REPO_DIR"
fi
if [[ -d "$ORB_REPO_DIR" ]]; then
echo "Cleaning up git worktree..."
cd "$SCRIPT_ROOT"
git worktree remove --force "$ORB_REPO_DIR" 2>/dev/null || true
fi
}

# Set trap to cleanup on exit
trap cleanup EXIT

cd "$SCRIPT_ROOT"

# Step 1: Setup git worktree for target branch
echo "Setting up git worktree for branch: $TARGET_BRANCH"
if [[ -d "$ORB_REPO_DIR" ]]; then
git worktree remove --force "$ORB_REPO_DIR" 2>/dev/null || true
fi

git worktree add "$ORB_REPO_DIR" "$TARGET_BRANCH"

# Step 2: Clone DarwinPrivateFrameworks repository
echo "Cloning DarwinPrivateFrameworks repository..."
if [[ -d "$RB_REPO_DIR" ]]; then
rm -rf "$RB_REPO_DIR"
fi

gh repo clone OpenSwiftUIProject/DarwinPrivateFrameworks "$RB_REPO_DIR"

# Step 3: Create new branch based on target branch name
echo "Creating new branch: update-rb-$TARGET_BRANCH"
cd "$RB_REPO_DIR"
git checkout -b "update-rb-$TARGET_BRANCH"

# Step 4: Generate RB template
echo "Generating RB template..."
cd "$OPENRENDERBOX_ROOT"
./Scripts/gen_rb_template.sh

# Step 5: Update DarwinPrivateFrameworks with generated content
echo "Updating DarwinPrivateFrameworks content..."

# Update headers in Sources/Headers
if [[ -d ".rb_template/Headers" ]]; then
echo "Updating headers..."
rm -rf "$RB_REPO_DIR/RB/2024/Sources/Headers"/*
cp -r .rb_template/Headers/* "$RB_REPO_DIR/RB/2024/Sources/Headers/"
fi

# Step 6: Commit changes in DarwinPrivateFrameworks
echo "Committing changes..."
cd "$RB_REPO_DIR"

git add .
if git diff --staged --quiet; then
echo "No changes to commit"
else
git commit -m "feat(rb): Update RenderBox from OpenRenderBox $TARGET_BRANCH

- Updated headers from OpenRenderBox sources
- Generated from OpenRenderBox branch: $TARGET_BRANCH"
fi

# Step 7: Update xcframeworks
echo "Updating xcframeworks..."
swift package update-xcframeworks --allow-writing-to-package-directory

# Commit xcframework updates
git add .
if git diff --staged --quiet; then
echo "No xcframework changes to commit"
else
git commit -m "chore(generated): Update RB framework"
fi

# Step 8: Push branch and create PR
echo "Pushing branch and creating PR..."
git push origin "update-rb-$TARGET_BRANCH" $FORCE_PUSH

# Create PR
PR_TITLE="Update RenderBox from OpenRenderBox $TARGET_BRANCH"
PR_BODY="Automated update of RenderBox framework from OpenRenderBox.

**Changes:**
- Updated headers from OpenRenderBox sources
- Updated xcframework binaries

**Source Branch:** $TARGET_BRANCH
**Generated by:** OpenRenderBox bump script"

gh pr create \
--title "$PR_TITLE" \
--body "$PR_BODY" \
--head "update-rb-$TARGET_BRANCH" \
--base main

echo "✅ PR created successfully!"
echo "Branch: update-rb-$TARGET_BRANCH"
45 changes: 45 additions & 0 deletions Scripts/gen_rb_template.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/zsh

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

gen_interface() {
swift build -c release -Xswiftc -emit-module-interface -Xswiftc -enable-library-evolution -Xswiftc -no-verify-emitted-module-interface -Xswiftc -package-name -Xswiftc OpenRenderBox -Xswiftc -Osize

mkdir -p .rb_template
}

gen_header() {
mkdir -p .rb_template/Headers

cp -r Sources/OpenRenderBox/include/OpenRenderBox/* .rb_template/Headers/

# Rename files from ORBxx to RBxx and OpenRenderBoxxx to RenderBoxxx
find .rb_template/Headers -name "ORB*" -type f | while read file; do
new_name=$(echo "$file" | sed 's/ORB/RB/g')
mv "$file" "$new_name"
done

find .rb_template/Headers -name "OpenRenderBox*" -type f | while read file; do
new_name=$(echo "$file" | sed 's/OpenRenderBox/RenderBox/g')
mv "$file" "$new_name"
done

# Update content in all header files
find .rb_template/Headers -name "*.h" -type f | while read file; do
sed -i '' 's/OpenRenderBox/RenderBox/g' "$file"
sed -i '' 's/OPENRENDERBOX/RENDERBOX/g' "$file"
sed -i '' 's/ORB/RB/g' "$file"
done

echo "Generated template headers successfully"
}

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

cd $OPENRENDERBOX_ROOT

gen_interface
gen_header
2 changes: 1 addition & 1 deletion Sources/OpenRenderBox/Path/ORBPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by Kyle on 2025/3/25.
//

#include "ORBPath.h"
#include <OpenRenderBox/ORBPathStorage.h>

void ORBPathRetain(ORBPath path) {
// TODO
Expand Down
6 changes: 3 additions & 3 deletions Sources/OpenRenderBox/Path/ORBPathStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// ORBPathStorage.cpp
// OpenRenderBox

#include "ORBPathStorage.h"
#include "PathStorage.hpp"
#include "../Util/assert.hpp"
#include <OpenRenderBox/ORBPathStorage.h>
#include <OpenRenderBoxCxx/Path/PathStorage.hpp>
#include <OpenRenderBoxCxx/Util/assert.hpp>

using namespace ORB;

Expand Down
4 changes: 2 additions & 2 deletions Sources/OpenRenderBox/Path/PathStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// PathStorage.cpp
// OpenRenderBox

#include "PathStorage.hpp"
#include "../Util/assert.hpp"
#include <OpenRenderBoxCxx/Path/PathStorage.hpp>
#include <OpenRenderBoxCxx/Util/assert.hpp>

namespace ORB {
namespace Path {
Expand Down
4 changes: 2 additions & 2 deletions Sources/OpenRenderBox/UUID/ORBUUID.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// ORBUUID.mm
// OpenRenderBox

#include "ORBUUID.h"
#include <OpenRenderBox/ORBUUID.h>

#if ORB_TARGET_OS_DARWIN
#if ORB_TARGET_OS_DARWIN && __OBJC__
ORBUUID ORBUUIDInitFromNSUUID(NSUUID *uuid) {
ORBUUID ob_uuid;
[uuid getUUIDBytes:ob_uuid.bytes];
Expand Down
Loading