Skip to content

Commit

Permalink
update spm structure
Browse files Browse the repository at this point in the history
  • Loading branch information
llbartekll committed Sep 20, 2024
1 parent 2a3c276 commit da52bb0
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 42 deletions.
50 changes: 30 additions & 20 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
// swift-tools-version: 5.10
import PackageDescription
import Foundation

let isDevelopment = ProcessInfo.processInfo.environment["YTTRIUM_DEVELOPMENT"] == "false"

let rustBinaryTarget: Target = {
guard isDevelopment else {
return rustBinaryTarget = .binaryTarget(
name: "RustXcframework",
url: "$REPO_URL/releases/download/$PACKAGE_VERSION/$RUST_XCFRAMEWORK_ZIP",
checksum: "$RUST_CHECKSUM"
)
}
return .binaryTarget(
name: "RustXcframework",
path: "crates/ffi/YttriumCore/RustXcframework.xcframework"
)
}()

let package = Package(
name: "yttrium",
Expand All @@ -31,6 +14,10 @@ let package = Package(
name: "Yttrium",
targets: ["Yttrium"]
),
.library(
name: "YttriumDev",
targets: ["YttriumDev"]
),
],
dependencies: [
.package(url: "https://github.com/thebarndog/swift-dotenv.git", from: "2.0.0")
Expand All @@ -44,18 +31,41 @@ let package = Package(
],
path: "platforms/swift/Sources/Yttrium"
),
.target(
name: "YttriumDev",
dependencies: [
"YttriumCoreDev",
.product(name: "SwiftDotenv", package: "swift-dotenv")
],
path: "platforms/swift/Sources/Yttrium"
),
.target(
name: "YttriumCore",
dependencies: [
"RustXcframework"
"RustXcframeworkRelease"
],
path: "crates/ffi/YttriumCore/Sources/YttriumCore"
),
.target(
name: "YttriumCoreDev",
dependencies: [
"RustXcframeworkDev"
],
path: "crates/ffi/YttriumCore/Sources/YttriumCore"
),
rustBinaryTarget,
.binaryTarget(
name: "RustXcframeworkRelease",
url: "$REPO_URL/releases/download/$PACKAGE_VERSION/$RUST_XCFRAMEWORK_ZIP",
checksum: "$RUST_CHECKSUM"
),
.binaryTarget(
name: "RustXcframeworkDev",
path: "crates/ffi/YttriumCore/RustXcframework.xcframework"
),
.testTarget(
name: "YttriumTests",
dependencies: [
"Yttrium" ,
"Yttrium",
.product(name: "SwiftDotenv", package: "swift-dotenv")
],
path: "platforms/swift/Tests/YttriumTests"
Expand Down
53 changes: 31 additions & 22 deletions scripts/generate_package_swift.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
set -e

# Variables
# PACKAGE_VERSION="${GITHUB_VERSION:-0.0.1-alpha}"
PACKAGE_VERSION="${GITHUB_VERSION:-0.0.1-alpha}-test"
RUST_CHECKSUM=$(cat rust_checksum.txt)
RUST_XCFRAMEWORK_ZIP="RustXcframework.xcframework.zip"
Expand All @@ -13,23 +12,6 @@ REPO_URL="https://github.com/WalletConnect/yttrium"
cat > Package.swift <<EOF
// swift-tools-version: 5.10
import PackageDescription
import Foundation
let isDevelopment = ProcessInfo.processInfo.environment["YTTRIUM_DEVELOPMENT"] == "false"
let rustBinaryTarget: Target = {
guard isDevelopment else {
return .binaryTarget(
name: "RustXcframework",
url: "$REPO_URL/releases/download/$PACKAGE_VERSION/$RUST_XCFRAMEWORK_ZIP",
checksum: "$RUST_CHECKSUM"
),
}
return .binaryTarget(
name: "RustXcframework",
path: "crates/ffi/YttriumCore/RustXcframework.xcframework"
)
}()
let package = Package(
name: "yttrium",
Expand All @@ -44,6 +26,10 @@ let package = Package(
name: "Yttrium",
targets: ["Yttrium"]
),
.library(
name: "YttriumDev",
targets: ["YttriumDev"]
),
],
dependencies: [
.package(url: "https://github.com/thebarndog/swift-dotenv.git", from: "2.0.0")
Expand All @@ -57,18 +43,41 @@ let package = Package(
],
path: "platforms/swift/Sources/Yttrium"
),
.target(
name: "YttriumDev",
dependencies: [
"YttriumCoreDev",
.product(name: "SwiftDotenv", package: "swift-dotenv")
],
path: "platforms/swift/Sources/Yttrium"
),
.target(
name: "YttriumCore",
dependencies: [
"RustXcframework"
"RustXcframeworkRelease"
],
path: "crates/ffi/YttriumCore/Sources/YttriumCore"
),
rustBinaryTarget,
.target(
name: "YttriumCoreDev",
dependencies: [
"RustXcframeworkDev"
],
path: "crates/ffi/YttriumCore/Sources/YttriumCore"
),
.binaryTarget(
name: "RustXcframeworkRelease",
url: "$REPO_URL/releases/download/$PACKAGE_VERSION/$RUST_XCFRAMEWORK_ZIP",
checksum: "$RUST_CHECKSUM"
),
.binaryTarget(
name: "RustXcframeworkDev",
path: "crates/ffi/YttriumCore/RustXcframework.xcframework"
),
.testTarget(
name: "YttriumTests",
dependencies: [
"Yttrium" ,
"Yttrium",
.product(name: "SwiftDotenv", package: "swift-dotenv")
],
path: "platforms/swift/Tests/YttriumTests"
Expand All @@ -77,4 +86,4 @@ let package = Package(
)
EOF

echo "Package.swift generated with Rust XCFramework checksum: $RUST_CHECKSUM"
echo "Package.swift generated with Rust XCFramework checksum: $RUST_CHECKSUM"

0 comments on commit da52bb0

Please sign in to comment.