Make binaries available as Swift package

This commit is contained in:
Davide De Rosa 2021-10-25 12:07:44 +02:00
parent 782543ec7b
commit 2ed7369283
3 changed files with 40 additions and 0 deletions

2
.gitignore vendored
View File

@ -5,6 +5,8 @@ src
lib lib
frameworks frameworks
include/openssl include/openssl
.build
swiftpm
*.gz *.gz
*.gz.asc *.gz.asc
*.framework *.framework

26
Package.swift Normal file
View File

@ -0,0 +1,26 @@
// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "openssl-apple",
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "openssl-apple",
targets: ["openssl"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.binaryTarget(
name: "openssl",
url: "https://github.com/keeshux/openssl-apple/releases/download/openssl-1.1.1l/openssl.xcframework.zip",
checksum: "18628fddadcac81c96e5824d62991b93172f58c7539cebb4ddba4df52b99aade")
]
)

12
create-swiftpm-binaries.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/bash
VERSION="1.1.1l"
TARGETS="ios-sim-cross-x86_64 ios-sim-cross-arm64 ios64-cross-arm64 ios64-cross-arm64e macos64-x86_64 macos64-arm64 mac-catalyst-x86_64 mac-catalyst-arm64"
FRAMEWORK="openssl.xcframework"
FRAMEWORK_ZIP="openssl.xcframework.zip"
FRAMEWORK_DIR="swiftpm/$VERSION"
./build-libssl.sh --version="$VERSION" --targets="$TARGETS"
./create-openssl-framework.sh dynamic
( cd frameworks && zip -r $FRAMEWORK_ZIP $FRAMEWORK )
mkdir -p $FRAMEWORK_DIR
mv frameworks/$FRAMEWORK_ZIP $FRAMEWORK_DIR
swift package compute-checksum $FRAMEWORK_DIR/$FRAMEWORK_ZIP