diff --git a/.github/actions/checkout-swift-headers/action.yml b/.github/actions/checkout-swift-headers/action.yml deleted file mode 100644 index 400728d4..00000000 --- a/.github/actions/checkout-swift-headers/action.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Checkout Swift Headers -description: | - This action checks-out certain header files from the swiftlang/swift - repository by running Scripts/clone-swift.sh. - -inputs: - path: - description: Relative path under $GITHUB_WORKSPACE to place the repository - required: false - default: '' - swift-version: - description: "Swift version as major.minor (e.g. 6.1). Detected from swift --version if not set." - required: false - default: '' - -runs: - using: "composite" - steps: - - name: Checkout Swift headers - run: | - ARGS="" - if [ -n "${{ inputs.path }}" ]; then - ARGS="$ARGS --path ${{ inputs.path }}" - fi - if [ -n "${{ inputs.swift-version }}" ]; then - ARGS="$ARGS --swift-version ${{ inputs.swift-version }}" - fi - ./Scripts/clone-swift.sh $ARGS - shell: bash diff --git a/.github/workflows/compatibility_tests.yml b/.github/workflows/compatibility_tests.yml index 828d12ad..202d433a 100644 --- a/.github/workflows/compatibility_tests.yml +++ b/.github/workflows/compatibility_tests.yml @@ -25,6 +25,8 @@ jobs: GH_TOKEN: ${{ github.token }} steps: - uses: actions/checkout@v4 + with: + submodules: true - name: Setup Xcode uses: OpenSwiftUIProject/OpenSwiftUI/.github/actions/setup-xcode@main with: @@ -32,8 +34,6 @@ jobs: - name: Set up build environment run: Scripts/CI/darwin_setup_build.sh shell: bash - - name: Checkout Swift headers - uses: ./.github/actions/checkout-swift-headers - name: Run tests against Apple's AttributeGraph on macOS via SwiftPM run: | swift test \ diff --git a/.github/workflows/compute.yml b/.github/workflows/compute.yml index ee834c79..b86318ef 100644 --- a/.github/workflows/compute.yml +++ b/.github/workflows/compute.yml @@ -22,11 +22,11 @@ jobs: container: swift:${{ matrix.swift_version }}-jammy steps: - uses: actions/checkout@v4 + with: + submodules: true - name: Set up Linux build environment run: Scripts/CI/linux_compute_build.sh shell: bash - - name: Checkout Swift headers - uses: ./.github/actions/checkout-swift-headers - name: Build in debug mode run: swift build -c debug -Xcc -Wno-elaborated-enum-base @@ -44,12 +44,12 @@ jobs: OPENATTRIBUTEGRAPH_OPENATTRIBUTESHIMS_COMPUTE_USE_BINARY: 1 steps: - uses: actions/checkout@v4 + with: + submodules: true - name: Setup Xcode uses: OpenSwiftUIProject/OpenSwiftUI/.github/actions/setup-xcode@main with: xcode-version: ${{ matrix.xcode-version }} - - name: Checkout Swift headers - uses: ./.github/actions/checkout-swift-headers - name: Build in debug mode run: swift build -c debug @@ -71,12 +71,12 @@ jobs: OPENATTRIBUTEGRAPH_OPENATTRIBUTESHIMS_COMPUTE_USE_BINARY: 1 steps: - uses: actions/checkout@v4 + with: + submodules: true - name: Setup Xcode uses: OpenSwiftUIProject/OpenSwiftUI/.github/actions/setup-xcode@main with: xcode-version: ${{ matrix.xcode-version }} - - name: Checkout Swift headers - uses: ./.github/actions/checkout-swift-headers - name: Build in debug mode on iOS Simulator run: | xcodebuild build \ diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index dc383466..9efb4fd5 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -27,6 +27,8 @@ jobs: GH_TOKEN: ${{ github.token }} steps: - uses: actions/checkout@v4 + with: + submodules: true - name: Setup Xcode uses: OpenSwiftUIProject/OpenSwiftUI/.github/actions/setup-xcode@main with: @@ -34,8 +36,6 @@ jobs: - name: Set up build environment run: Scripts/CI/darwin_setup_build.sh shell: bash - - name: Checkout Swift headers - uses: ./.github/actions/checkout-swift-headers - name: Build in debug mode on iOS run: | xcodebuild build \ diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 2b9230f4..1db9c349 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -23,6 +23,8 @@ jobs: GH_TOKEN: ${{ github.token }} steps: - uses: actions/checkout@v4 + with: + submodules: true - name: Setup Xcode uses: OpenSwiftUIProject/OpenSwiftUI/.github/actions/setup-xcode@main with: @@ -30,8 +32,6 @@ jobs: - name: Set up build environment run: Scripts/CI/darwin_setup_build.sh shell: bash - - name: Checkout Swift headers - uses: ./.github/actions/checkout-swift-headers - name: Build and run tests in debug mode with coverage run: | swift test \ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6c93b16c..5bf0867a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,12 +17,11 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 + submodules: true - name: Setup Xcode uses: OpenSwiftUIProject/OpenSwiftUI/.github/actions/setup-xcode@main with: xcode-version: "16.4" - - name: Checkout Swift headers - uses: ./.github/actions/checkout-swift-headers - name: Build XCFramework run: ./Scripts/build_xcframework.sh - name: Compute Checksum diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index b0f1b020..7642134f 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -19,8 +19,8 @@ jobs: container: swift:${{ matrix.swift_version }}-jammy steps: - uses: actions/checkout@v4 - - name: Checkout Swift headers - uses: ./.github/actions/checkout-swift-headers + with: + submodules: true - name: Building and running tests in debug mode with coverage run: | swift test \ diff --git a/.github/workflows/xcframework.yml b/.github/workflows/xcframework.yml index cb15746f..3211eda9 100644 --- a/.github/workflows/xcframework.yml +++ b/.github/workflows/xcframework.yml @@ -19,12 +19,12 @@ jobs: GH_TOKEN: ${{ github.token }} steps: - uses: actions/checkout@v4 + with: + submodules: true - name: Setup Xcode uses: OpenSwiftUIProject/OpenSwiftUI/.github/actions/setup-xcode@main with: xcode-version: ${{ matrix.xcode-version }} - - name: Checkout Swift headers - uses: ./.github/actions/checkout-swift-headers - name: Build XCFramework run: ./Scripts/build_xcframework.sh - name: Upload XCFramework diff --git a/.gitignore b/.gitignore index b364717c..13cac52d 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,8 @@ DerivedData/ .netrc coverage.txt TODO.md -Checkouts/ +Checkouts/* +!Checkouts/swift .ag_template/ build/ .ag_repo/ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..ad3cb7b2 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "Checkouts/swift"] + path = Checkouts/swift + url = https://github.com/OpenSwiftUIProject/swift-runtime-headers.git + branch = release/6.1 diff --git a/Checkouts/swift b/Checkouts/swift new file mode 160000 index 00000000..358e0e0c --- /dev/null +++ b/Checkouts/swift @@ -0,0 +1 @@ +Subproject commit 358e0e0c5d8e4df91c6d20d2f152f7c6f6cbccf1 diff --git a/Package.resolved b/Package.resolved index bdbc7a6d..b50b5e50 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "956284da357dd33ed447f04ebcc26181bf2917ab63797f96df49660c25b7adcd", + "originHash" : "83037cc9b10aa3ac767684b89c921b28273c84901f64f2f2b15ee513ee4b246e", "pins" : [ { "identity" : "swift-numerics", diff --git a/Package.swift b/Package.swift index ef7c6c63..4591133b 100644 --- a/Package.swift +++ b/Package.swift @@ -266,13 +266,6 @@ extension [SwiftSetting] { } } -// MARK: - Plugin - -let swiftClonePlugin = Target.plugin( - name: "CloneSwiftPlugin", - capability: .buildTool() -) - // MARK: - Targets let platformTarget = Target.target( @@ -304,7 +297,7 @@ let openAttributeGraphCxxTarget = Target.target( linkerSettings: [ .linkedLibrary("z"), ], - plugins: [.plugin(name: swiftClonePlugin.name)] + plugins: [] ) let openAttributeGraphTarget = Target.target( name: "OpenAttributeGraph", @@ -447,7 +440,6 @@ if computeCondition { package.targets.append(target) } else { package.targets.append(contentsOf: [ - swiftClonePlugin, platformTarget, utilitiesTarget, openAttributeGraphTarget, diff --git a/Plugins/CloneSwiftPlugin/plugin.swift b/Plugins/CloneSwiftPlugin/plugin.swift deleted file mode 100644 index b10a350a..00000000 --- a/Plugins/CloneSwiftPlugin/plugin.swift +++ /dev/null @@ -1,33 +0,0 @@ -import Foundation -import PackagePlugin - -@main -struct CloneSwiftPlugin: BuildToolPlugin { - func createBuildCommands(context: PluginContext, target: Target) throws -> [Command] { - let packageDir = context.package.directoryURL - let checkoutPath = packageDir.appending(path: "Checkouts/swift") - let script = packageDir.appending(path: "Scripts/clone-swift.sh") - - let env = ProcessInfo.processInfo.environment - - let effectivePath = env["SWIFT_TOOLCHAIN_PATH"] ?? checkoutPath.path() - var scriptArgs = "\(script.path()) --path \(effectivePath)" - - if let version = env["SWIFT_TOOLCHAIN_VERSION"], - !version.isEmpty { - scriptArgs += " --swift-version \(version)" - } - - return [ - .prebuildCommand( - displayName: "Clone Swift repository headers", - executable: URL(filePath: "/bin/bash"), - arguments: [ - "-c", - "\(scriptArgs) 2>&1 || echo 'warning: CloneSwiftPlugin: clone-swift.sh failed. Run Scripts/clone-swift.sh manually or use swift build --disable-sandbox.'", - ], - outputFilesDirectory: context.pluginWorkDirectoryURL - ) - ] - } -} diff --git a/README.md b/README.md index 429e2d39..6ba6f7c3 100644 --- a/README.md +++ b/README.md @@ -64,14 +64,10 @@ The current suggested toolchain to build the project is Swift 6.1.2 / Xcode 16.4 ### Clone Swift headers -The project requires Swift toolchain headers for compilation. You can either clone them manually or let the build plugin handle it: +The project requires Swift toolchain headers for compilation. They are included as a git submodule: ```shell -# Option 1: Clone headers manually -./Scripts/clone-swift.sh - -# Option 2: Let the build plugin clone headers (requires --disable-sandbox) -swift build --disable-sandbox +git submodule update --init ``` ## License diff --git a/Scripts/clone-swift.sh b/Scripts/clone-swift.sh deleted file mode 100755 index 431d8edd..00000000 --- a/Scripts/clone-swift.sh +++ /dev/null @@ -1,100 +0,0 @@ -#!/bin/bash - -# clone-swift.sh -# -# Adapted from https://github.com/jcmosc/Compute -# -# Copyright (c) 2024 James Moschou -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -set -e - -# Default values -CHECKOUT_PATH="Checkouts/swift" -SWIFT_VERSION="" - -# Parse arguments -while [[ $# -gt 0 ]]; do - case $1 in - --path) - CHECKOUT_PATH="$2" - shift 2 - ;; - --swift-version) - SWIFT_VERSION="$2" - shift 2 - ;; - *) - echo "Unknown option: $1" - echo "Usage: $0 [--path ] [--swift-version ]" - exit 1 - ;; - esac -done - -# Detect Swift version if not provided -if [ -z "$SWIFT_VERSION" ]; then - SWIFT_VERSION=$(swift --version 2>/dev/null | grep -oE 'Swift version [0-9]+\.[0-9]+' | grep -oE '[0-9]+\.[0-9]+') - echo "Detected Swift version: $SWIFT_VERSION" -fi - -if [ -z "$SWIFT_VERSION" ]; then - echo "Error: Could not detect Swift version. Please specify with --swift-version" - exit 1 -fi - -SWIFT_VERSION_MAJOR=$(echo "$SWIFT_VERSION" | cut -d. -f1) -SWIFT_VERSION_MINOR=$(echo "$SWIFT_VERSION" | cut -d. -f2) - -# Skip if checkout directory already exists and is not empty -if [ -d "$CHECKOUT_PATH" ] && [ -n "$(ls -A "$CHECKOUT_PATH")" ]; then - echo "Swift headers already exist at $CHECKOUT_PATH, skipping clone." - exit 0 -fi - -# Remove existing checkout if present -rm -rf "$CHECKOUT_PATH" -mkdir -p "$CHECKOUT_PATH" - -# Clone with sparse checkout -git clone --filter=blob:none --no-checkout --depth 1 \ - --branch "release/$SWIFT_VERSION_MAJOR.$SWIFT_VERSION_MINOR" \ - https://github.com/swiftlang/swift.git "$CHECKOUT_PATH" - -cd "$CHECKOUT_PATH" - -git sparse-checkout set --no-cone \ - include/swift \ - stdlib/include \ - stdlib/public/SwiftShims \ - stdlib/public/runtime/MetadataAllocatorTags.def - -git checkout - -# Write CMakeConfig.h file -cat > include/swift/Runtime/CMakeConfig.h << EOF -#ifndef SWIFT_RUNTIME_CMAKECONFIG_H -#define SWIFT_RUNTIME_CMAKECONFIG_H -#define SWIFT_VERSION_MAJOR $SWIFT_VERSION_MAJOR -#define SWIFT_VERSION_MINOR $SWIFT_VERSION_MINOR -#endif -EOF - -echo "The Swift repository has been cloned to $CHECKOUT_PATH"