-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: follow symlinks when searching for xcframework directories (#983)
One of the packages we depend on puts its XCFramework behind a symlink for some reason. Without this change rspm doesn't follow the symlink to find the contents of the actual framework. mimic behavior of [_list_files_under](https://github.com/cgrindel/rules_swift_package_manager/blob/85a704df7fb25d861ba8e54a584c08e07a7de748/swiftpkg/internal/repository_files.bzl#L44-L45)
- Loading branch information
Showing
44 changed files
with
1,074 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Import Shared settings | ||
import %workspace%/../../shared.bazelrc | ||
|
||
# Import CI settings. | ||
import %workspace%/../../ci.bazelrc | ||
|
||
# Try to import a local.rc file; typically, written by CI | ||
try-import %workspace%/../../local.bazelrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary") | ||
load("@cgrindel_bazel_starlib//bzltidy:defs.bzl", "tidy") | ||
load("@rules_swift_package_manager//swiftpkg:defs.bzl", "swift_update_packages") | ||
|
||
tidy( | ||
name = "tidy", | ||
targets = [ | ||
":swift_update_pkgs", | ||
":update_build_files", | ||
], | ||
) | ||
|
||
# MARK: - Gazelle | ||
|
||
# Ignore the Swift build folder | ||
# gazelle:exclude .build | ||
|
||
gazelle_binary( | ||
name = "gazelle_bin", | ||
languages = [ | ||
"@bazel_skylib_gazelle_plugin//bzl", | ||
"@rules_swift_package_manager//gazelle", | ||
], | ||
) | ||
|
||
gazelle( | ||
name = "update_build_files", | ||
gazelle = ":gazelle_bin", | ||
) | ||
|
||
swift_update_packages( | ||
name = "swift_update_pkgs", | ||
gazelle = ":gazelle_bin", | ||
generate_swift_deps_for_workspace = False, | ||
package_manifest = "Package.swift", | ||
update_bzlmod_stanzas = True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
bazel_dep( | ||
name = "rules_swift_package_manager", | ||
version = "0.0.0", | ||
) | ||
local_path_override( | ||
module_name = "rules_swift_package_manager", | ||
path = "../..", | ||
) | ||
|
||
bazel_dep(name = "cgrindel_bazel_starlib", version = "0.20.2") | ||
bazel_dep(name = "bazel_skylib", version = "1.5.0") | ||
bazel_dep(name = "apple_support", version = "1.15.1") | ||
bazel_dep( | ||
name = "rules_swift", | ||
version = "1.17.0", | ||
repo_name = "build_bazel_rules_swift", | ||
) | ||
bazel_dep( | ||
name = "rules_apple", | ||
version = "3.4.0", | ||
repo_name = "build_bazel_rules_apple", | ||
) | ||
|
||
bazel_dep( | ||
name = "bazel_skylib_gazelle_plugin", | ||
version = "1.5.0", | ||
dev_dependency = True, | ||
) | ||
bazel_dep( | ||
name = "gazelle", | ||
version = "0.36.0", | ||
dev_dependency = True, | ||
repo_name = "bazel_gazelle", | ||
) | ||
|
||
apple_cc_configure = use_extension( | ||
"@apple_support//crosstool:setup.bzl", | ||
"apple_cc_configure_extension", | ||
) | ||
use_repo(apple_cc_configure, "local_config_apple_cc") | ||
|
||
# swift_deps START | ||
swift_deps = use_extension( | ||
"@rules_swift_package_manager//:extensions.bzl", | ||
"swift_deps", | ||
) | ||
swift_deps.from_file( | ||
deps_index = "//:swift_deps_index.json", | ||
) | ||
use_repo( | ||
swift_deps, | ||
"swiftpkg_empty_framework", | ||
) | ||
# swift_deps END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// swift-tools-version: 5.7 | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "symlink_example", | ||
dependencies: [ | ||
.package(path: "third_party/empty_framework"), | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Symlink to XCFramework | ||
|
||
This example demonstrates using an external package that contains an XCFramework that is | ||
dependended on through a symlink. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library") | ||
|
||
swift_library( | ||
name = "ImportFramework", | ||
srcs = ["Import.swift"], | ||
module_name = "ImportFramework", | ||
visibility = ["//visibility:public"], | ||
deps = ["@swiftpkg_empty_framework//:EmptyFramework"], | ||
) |
3 changes: 3 additions & 0 deletions
3
examples/symlink_example/Sources/ImportFramework/Import.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import EmptyFramework | ||
|
||
func getFrameworkVersion() -> Double { EmptyFrameworkVersionNumber } |
17 changes: 17 additions & 0 deletions
17
examples/symlink_example/Tests/ImportFrameworkTests/BUILD.bazel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_unit_test") | ||
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library") | ||
|
||
swift_library( | ||
name = "ImportFrameworkTestsLib", | ||
testonly = True, | ||
srcs = ["ImportFrameworkTests.swift"], | ||
module_name = "ImportFrameworkTests", | ||
tags = ["manual"], | ||
deps = ["//Sources/ImportFramework"], | ||
) | ||
|
||
ios_unit_test( | ||
name = "ImportFrameworkTests", | ||
minimum_os_version = "15.0", | ||
deps = [":ImportFrameworkTestsLib"], | ||
) |
8 changes: 8 additions & 0 deletions
8
examples/symlink_example/Tests/ImportFrameworkTests/ImportFrameworkTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import XCTest | ||
@testable import ImportFramework | ||
|
||
final class ImportFrameworkTests: XCTestCase { | ||
func testVersionNumber() throws { | ||
XCTAssertEqual(getFrameworkVersion(), 1.0) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Intentionally blank: Using bzlmod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Intentionally blank | ||
# This exists to force Bazel in bzlmod mode to be strict. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o errexit -o nounset -o pipefail | ||
|
||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && pwd)" | ||
|
||
# Use the Bazel binary specified by the integration test. Otherise, fall back | ||
# to bazel. | ||
bazel="${BIT_BAZEL_BINARY:-bazel}" | ||
|
||
# Generate Swift external deps and update build files | ||
"${bazel}" run //:tidy | ||
"${bazel}" run //:swift_update_pkgs | ||
|
||
# Ensure that it builds and tests pass | ||
"${bazel}" test //... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"direct_dep_identities": [ | ||
"empty_framework" | ||
], | ||
"modules": [ | ||
{ | ||
"name": "EmptyFramework", | ||
"c99name": "EmptyFramework", | ||
"src_type": "binary", | ||
"label": "@swiftpkg_empty_framework//:EmptyFramework.rspm", | ||
"package_identity": "empty_framework", | ||
"product_memberships": [ | ||
"EmptyFramework" | ||
] | ||
} | ||
], | ||
"products": [ | ||
{ | ||
"identity": "empty_framework", | ||
"name": "EmptyFramework", | ||
"type": "library", | ||
"label": "@swiftpkg_empty_framework//:EmptyFramework" | ||
} | ||
], | ||
"packages": [ | ||
{ | ||
"name": "swiftpkg_empty_framework", | ||
"identity": "empty_framework", | ||
"local": { | ||
"path": "third_party/empty_framework" | ||
} | ||
} | ||
] | ||
} |
1 change: 1 addition & 0 deletions
1
examples/symlink_example/third_party/empty_framework/EmptyFramework.xcframework
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Framework/EmptyFramework.xcframework |
59 changes: 59 additions & 0 deletions
59
...mlink_example/third_party/empty_framework/Framework/EmptyFramework.xcframework/Info.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>AvailableLibraries</key> | ||
<array> | ||
<dict> | ||
<key>BinaryPath</key> | ||
<string>EmptyFramework.framework/EmptyFramework</string> | ||
<key>LibraryIdentifier</key> | ||
<string>ios-arm64</string> | ||
<key>LibraryPath</key> | ||
<string>EmptyFramework.framework</string> | ||
<key>SupportedArchitectures</key> | ||
<array> | ||
<string>arm64</string> | ||
</array> | ||
<key>SupportedPlatform</key> | ||
<string>ios</string> | ||
</dict> | ||
<dict> | ||
<key>BinaryPath</key> | ||
<string>EmptyFramework.framework/Versions/A/EmptyFramework</string> | ||
<key>LibraryIdentifier</key> | ||
<string>macos-arm64_x86_64</string> | ||
<key>LibraryPath</key> | ||
<string>EmptyFramework.framework</string> | ||
<key>SupportedArchitectures</key> | ||
<array> | ||
<string>arm64</string> | ||
<string>x86_64</string> | ||
</array> | ||
<key>SupportedPlatform</key> | ||
<string>macos</string> | ||
</dict> | ||
<dict> | ||
<key>BinaryPath</key> | ||
<string>EmptyFramework.framework/EmptyFramework</string> | ||
<key>LibraryIdentifier</key> | ||
<string>ios-arm64_x86_64-simulator</string> | ||
<key>LibraryPath</key> | ||
<string>EmptyFramework.framework</string> | ||
<key>SupportedArchitectures</key> | ||
<array> | ||
<string>arm64</string> | ||
<string>x86_64</string> | ||
</array> | ||
<key>SupportedPlatform</key> | ||
<string>ios</string> | ||
<key>SupportedPlatformVariant</key> | ||
<string>simulator</string> | ||
</dict> | ||
</array> | ||
<key>CFBundlePackageType</key> | ||
<string>XFWK</string> | ||
<key>XCFrameworkFormatVersion</key> | ||
<string>1.0</string> | ||
</dict> | ||
</plist> |
Binary file added
BIN
+50.5 KB
...rk/Framework/EmptyFramework.xcframework/ios-arm64/EmptyFramework.framework/EmptyFramework
Binary file not shown.
Oops, something went wrong.