Skip to content

Commit

Permalink
chore: release v0.16.2-alpha.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Leeeon233 committed Aug 7, 2024
1 parent 19bc9bb commit e42407f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 70 deletions.
15 changes: 14 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
// swift-tools-version: 5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.

import Foundation
import PackageDescription

let FFIbinaryTarget: PackageDescription.Target

if ProcessInfo.processInfo.environment["LOCAL_BUILD"] != nil {
FFIbinaryTarget = .binaryTarget(name: "LoroFFI", path: "./loroFFI.xcframework.zip")
}else {
FFIbinaryTarget = .binaryTarget(
name: "LoroFFI",
url: "https://github.com/loro/loro-swift/releases/download/0.16.2-alpha.0/loroFFI.xcframework.zip",
checksum: "a98119540ba962f1896243b27cc1e9f94629db831c9477a7fec388359d438c0c"
)
}

let package = Package(
name: "Loro",
platforms: [
Expand All @@ -18,7 +31,7 @@ let package = Package(
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
.binaryTarget(name: "LoroFFI", path: "./loroFFI.xcframework.zip"),
FFIbinaryTarget,
.target(
name: "Loro",
dependencies: ["LoroFFI"]),
Expand Down
85 changes: 16 additions & 69 deletions scripts/build_swift_ffi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ echo "▸ Building for aarch64-apple-ios"
CFLAGS_aarch64_apple_ios="-target aarch64-apple-ios" \
$cargo_build --target aarch64-apple-ios --locked --release

# echo "▸ Building for aarch64-apple-visionos-sim"
# CFLAGS_aarch64_apple_visionos="-target aarch64-apple-visionos-sim" \
# $cargo_build_nightly_with_std --target aarch64-apple-visionos-sim --locked --release
echo "▸ Building for aarch64-apple-visionos-sim"
CFLAGS_aarch64_apple_visionos="-target aarch64-apple-visionos-sim" \
$cargo_build_nightly_with_std --target aarch64-apple-visionos-sim --locked --release

# echo "▸ Building for aarch64-apple-visionos"
# CFLAGS_aarch64_apple_visionos="-target aarch64-apple-visionos" \
# $cargo_build_nightly_with_std --target aarch64-apple-visionos --locked --release
echo "▸ Building for aarch64-apple-visionos"
CFLAGS_aarch64_apple_visionos="-target aarch64-apple-visionos" \
$cargo_build_nightly_with_std --target aarch64-apple-visionos --locked --release

echo "▸ Building for aarch64-apple-darwin"
CFLAGS_aarch64_apple_darwin="-target aarch64-apple-darwin" \
Expand Down Expand Up @@ -110,11 +110,11 @@ lipo -create \
"${BUILD_FOLDER}/aarch64-apple-ios-sim/release/${LIB_NAME}" \
-output "${BUILD_FOLDER}/ios-simulator/release/${LIB_NAME}"

# echo "▸ arm simulator static libraries into a static binary"
# mkdir -p "${BUILD_FOLDER}/visionos-simulator/release"
# lipo -create \
# "${BUILD_FOLDER}/aarch64-apple-visionos-sim/release/${LIB_NAME}" \
# -output "${BUILD_FOLDER}/visionos-simulator/release/${LIB_NAME}"
echo "▸ arm simulator static libraries into a static binary"
mkdir -p "${BUILD_FOLDER}/visionos-simulator/release"
lipo -create \
"${BUILD_FOLDER}/aarch64-apple-visionos-sim/release/${LIB_NAME}" \
-output "${BUILD_FOLDER}/visionos-simulator/release/${LIB_NAME}"

echo "▸ Lipo (merge) x86 and arm macOS static libraries into a fat static binary"
mkdir -p "${BUILD_FOLDER}/apple-darwin/release"
Expand All @@ -131,11 +131,12 @@ lipo -create \
-output "${BUILD_FOLDER}/apple-macabi/release/${LIB_NAME}"


# -library "$BUILD_FOLDER/aarch64-apple-visionos/release/$LIB_NAME" \
# -headers "${BUILD_FOLDER}/includes" \
# -library "${BUILD_FOLDER}/visionos-simulator/release/${LIB_NAME}" \
# -headers "${BUILD_FOLDER}/includes" \

xcodebuild -create-xcframework \
-library "$BUILD_FOLDER/aarch64-apple-visionos/release/$LIB_NAME" \
-headers "${BUILD_FOLDER}/includes" \
-library "${BUILD_FOLDER}/visionos-simulator/release/${LIB_NAME}" \
-headers "${BUILD_FOLDER}/includes" \
-library "$BUILD_FOLDER/aarch64-apple-ios/release/$LIB_NAME" \
-headers "${BUILD_FOLDER}/includes" \
-library "${BUILD_FOLDER}/ios-simulator/release/${LIB_NAME}" \
Expand All @@ -151,57 +152,3 @@ ditto -c -k --sequesterRsrc --keepParent "$XCFRAMEWORK_FOLDER" "$XCFRAMEWORK_FOL

echo "▸ Compute checksum"
openssl dgst -sha256 "$XCFRAMEWORK_FOLDER.zip"


#############
# rm -rf gen-swift
# mkdir -p gen-swift/includes
# cd loro-rs
# cargo run --features=cli --bin uniffi-bindgen generate src/loro.udl --language swift --out-dir ../gen-swift

# echo "Building x86_64-apple-ios"
# CFLAGS_x86_64_apple_ios="-target x86_64-apple-ios" \
# cargo build --target x86_64-apple-ios --locked --release

# echo "Building aarch64-apple-ios-sim"
# CFLAGS_x86_64_apple_ios="-aarch64-apple-ios-sim" \
# cargo build --target aarch64-apple-ios-sim --locked --release

# echo "Building aarch64-apple-ios"
# CFLAGS_x86_64_apple_ios="-target aarch64-apple-ios" \
# cargo build --target aarch64-apple-ios --locked --release

# echo "Building aarch64-apple-visionos-sim"
# CFLAGS_x86_64_apple_ios="-target aarch64-apple-visionos-sim" \
# cargo build --target aarch64-apple-visionos-sim --locked --release

# echo "Building aarch64-apple-visionos"
# CFLAGS_x86_64_apple_ios="-target aarch64-apple-visionos" \
# cargo build --target aarch64-apple-visionos --locked --release

# echo "Building aarch64-apple-darwin"
# CFLAGS_x86_64_apple_ios="-target aarch64-apple-darwin" \
# cargo build --target aarch64-apple-darwin --locked --release

# echo "Building x86_64-apple-darwin"
# CFLAGS_x86_64_apple_ios="-target x86_64-apple-darwin" \
# cargo build --target x86_64-apple-darwin --locked --release

# echo "Building aarch64-apple-ios-macabi"
# CFLAGS_x86_64_apple_ios="-target aarch64-apple-ios-macabi" \
# cargo build --target aarch64-apple-ios-macabi --locked --release

# echo "Building x86_64-apple-ios-macabi"
# CFLAGS_x86_64_apple_ios="-target x86_64-apple-ios-macabi" \
# cargo build --target x86_64-apple-ios-macabi --locked --release



# cd ..
# mv gen-swift/loroFFI.h gen-swift/includes/loroFFI.h
# mv gen-swift/loroFFI.modulemap gen-swift/includes/module.modulemap
# xcodebuild -create-xcframework -library loro-rs/target/release/libloro.a -headers gen-swift/includes -output loroFFI.xcframework
# zip -r loroFFI.xcframework.zip loroFFI.xcframework
# mv gen-swift/loro.swift Sources/Loro/LoroFFI.swift
# sh scripts/refine_trait.sh
# rm -rf gen-swift loroFFI.xcframework

0 comments on commit e42407f

Please sign in to comment.