Skip to content

Commit c22f554

Browse files
authored
Merge branch 'main' into perf/sync-benchmarks-and-optimizations
2 parents bcfdd43 + c509ba5 commit c22f554

3 files changed

Lines changed: 47 additions & 9 deletions

File tree

.github/workflows/main.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
if: ${{ !contains(github.event.head_commit.message, '[auto-update]') }}
1818
runs-on: ${{ matrix.os }}
1919
container: ${{ matrix.container && matrix.container || '' }}
20-
name: ${{ matrix.name }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }} build${{ matrix.arch != 'arm64-v8a' && matrix.arch != 'armeabi-v7a' && matrix.name != 'ios-sim' && matrix.name != 'ios' && matrix.name != 'apple-xcframework' && matrix.name != 'android-aar' && ( matrix.name != 'macos' || matrix.arch != 'x86_64' ) && ' + test' || ''}}
20+
name: ${{ matrix.name }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }} build${{ matrix.arch != 'arm64-v8a' && matrix.arch != 'armeabi-v7a' && matrix.name != 'ios-sim' && matrix.name != 'ios' && matrix.name != 'mac-catalyst' && matrix.name != 'apple-xcframework' && matrix.name != 'android-aar' && ( matrix.name != 'macos' || matrix.arch != 'x86_64' ) && ' + test' || ''}}
2121
timeout-minutes: 20
2222
strategy:
2323
fail-fast: false
@@ -69,6 +69,9 @@ jobs:
6969
- os: macos-15
7070
name: ios-sim
7171
make: PLATFORM=ios-sim
72+
- os: macos-15
73+
name: mac-catalyst
74+
make: PLATFORM=mac-catalyst
7275
- os: macos-15
7376
name: apple-xcframework
7477
make: xcframework

Makefile

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ endif
3030
# Speed up builds by using all available CPU cores
3131
MAKEFLAGS += -j$(CPUS)
3232

33+
# Mac Catalyst uses the Apple-native NSURLSession networking path. This needs to
34+
# be set before the common linker flags decide whether libcurl is required.
35+
ifeq ($(PLATFORM),mac-catalyst)
36+
override NATIVE_NETWORK := ON
37+
endif
38+
3339
# Compiler and flags
3440
CC = gcc
3541
CFLAGS = -Wall -Wextra -Wno-unused-parameter -I$(SRC_DIR) -I$(SRC_DIR)/sqlite -I$(SRC_DIR)/postgresql -I$(SRC_DIR)/network -I$(SQLITE_DIR) -I$(CURL_DIR)/include -Imodules/fractional-indexing
@@ -150,6 +156,19 @@ else ifeq ($(PLATFORM),ios-sim)
150156
CFLAGS += -arch x86_64 -arch arm64 $(SDK)
151157
CURL_CONFIG = --host=arm64-apple-darwin --with-secure-transport CFLAGS="-arch x86_64 -arch arm64 -isysroot $$(xcrun --sdk iphonesimulator --show-sdk-path) -miphonesimulator-version-min=11.0"
152158
STRIP = strip -x -S $@
159+
else ifeq ($(PLATFORM),mac-catalyst)
160+
TARGET := $(DIST_DIR)/cloudsync.dylib
161+
MAC_CATALYST_DEPLOYMENT_TARGET ?= 14.0
162+
ifndef ARCH
163+
MAC_CATALYST_UNIVERSAL := true
164+
STRIP = strip -x -S $@
165+
else
166+
SDK := -isysroot $(shell xcrun --sdk macosx --show-sdk-path) -target $(ARCH)-apple-ios$(MAC_CATALYST_DEPLOYMENT_TARGET)-macabi
167+
LDFLAGS += -framework Security -framework CoreFoundation -dynamiclib $(SDK) -headerpad_max_install_names
168+
T_LDFLAGS = -framework Security
169+
CFLAGS += $(SDK)
170+
STRIP = strip -x -S $@
171+
endif
153172
else # linux
154173
TARGET := $(DIST_DIR)/cloudsync.so
155174
LDFLAGS += -shared -lssl -lcrypto -lm
@@ -195,6 +214,20 @@ $(shell mkdir -p $(BUILD_DIRS) $(DIST_DIR))
195214
extension: $(TARGET)
196215
all: $(TARGET)
197216

217+
ifeq ($(MAC_CATALYST_UNIVERSAL),true)
218+
MAC_CATALYST_ARCHS = x86_64 arm64
219+
MAC_CATALYST_DYLIBS = $(foreach arch,$(MAC_CATALYST_ARCHS),$(DIST_DIR)/cloudsync-mac-catalyst-$(arch).dylib)
220+
221+
$(TARGET):
222+
@for arch in $(MAC_CATALYST_ARCHS); do \
223+
rm -rf $(BUILD_DIRS); \
224+
$(MAKE) PLATFORM=mac-catalyst ARCH=$$arch MAC_CATALYST_DEPLOYMENT_TARGET=$(MAC_CATALYST_DEPLOYMENT_TARGET); \
225+
mv $(DIST_DIR)/cloudsync.dylib $(DIST_DIR)/cloudsync-mac-catalyst-$$arch.dylib; \
226+
done
227+
lipo -create $(MAC_CATALYST_DYLIBS) -output $@
228+
rm -f $(MAC_CATALYST_DYLIBS)
229+
$(STRIP)
230+
else
198231
# Loadable library
199232
ifdef NATIVE_NETWORK
200233
$(TARGET): $(RELEASE_OBJ) $(DEF_FILE)
@@ -208,6 +241,7 @@ ifeq ($(PLATFORM),windows)
208241
endif
209242
# Strip debug symbols
210243
$(STRIP)
244+
endif
211245

212246
# Test executable
213247
$(TEST_TARGET): $(TEST_OBJ)
@@ -404,10 +438,10 @@ framework module CloudSync {\
404438
}
405439
endef
406440

407-
LIB_NAMES = ios.dylib ios-sim.dylib macos.dylib
408-
FMWK_NAMES = ios-arm64 ios-arm64_x86_64-simulator macos-arm64_x86_64
441+
LIB_NAMES = ios.dylib ios-sim.dylib mac-catalyst.dylib macos.dylib
442+
FMWK_NAMES = ios-arm64 ios-arm64_x86_64-simulator ios-arm64_x86_64-maccatalyst macos-arm64_x86_64
409443
$(DIST_DIR)/%.xcframework: $(LIB_NAMES)
410-
@$(foreach i,1 2,\
444+
@$(foreach i,1 2 3,\
411445
lib=$(word $(i),$(LIB_NAMES)); \
412446
fmwk=$(word $(i),$(FMWK_NAMES)); \
413447
mkdir -p $(DIST_DIR)/$$fmwk/CloudSync.framework/Headers; \
@@ -418,8 +452,8 @@ $(DIST_DIR)/%.xcframework: $(LIB_NAMES)
418452
mv $(DIST_DIR)/$$lib $(DIST_DIR)/$$fmwk/CloudSync.framework/CloudSync; \
419453
install_name_tool -id "@rpath/CloudSync.framework/CloudSync" $(DIST_DIR)/$$fmwk/CloudSync.framework/CloudSync; \
420454
)
421-
@lib=$(word 3,$(LIB_NAMES)); \
422-
fmwk=$(word 3,$(FMWK_NAMES)); \
455+
@lib=$(word 4,$(LIB_NAMES)); \
456+
fmwk=$(word 4,$(FMWK_NAMES)); \
423457
mkdir -p $(DIST_DIR)/$$fmwk/CloudSync.framework/Versions/A/Headers; \
424458
mkdir -p $(DIST_DIR)/$$fmwk/CloudSync.framework/Versions/A/Modules; \
425459
mkdir -p $(DIST_DIR)/$$fmwk/CloudSync.framework/Versions/A/Resources; \
@@ -473,6 +507,7 @@ help:
473507
@echo " android (needs ARCH to be set to x86_64, arm64-v8a, or armeabi-v7a and ANDROID_NDK to be set)"
474508
@echo " ios (only on macOS - can be compiled with native network support)"
475509
@echo " ios-sim (only on macOS - can be compiled with native network support)"
510+
@echo " mac-catalyst (only on macOS - builds a universal arm64 + x86_64 Catalyst dylib)"
476511
@echo ""
477512
@echo "Targets:"
478513
@echo " all - Build the extension (default)"

Package.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import PackageDescription
55

66
let package = Package(
77
name: "CloudSync",
8-
platforms: [.macOS(.v11), .iOS(.v11)],
8+
platforms: [.macOS(.v11), .iOS(.v11), .macCatalyst(.v14)],
99
products: [
1010
.library(
1111
name: "CloudSync",
@@ -14,8 +14,8 @@ let package = Package(
1414
targets: [
1515
.binaryTarget(
1616
name: "CloudSyncBinary",
17-
url: "https://github.com/sqliteai/sqlite-sync/releases/download/1.0.18/cloudsync-apple-xcframework-1.0.18.zip",
18-
checksum: "b7d49ba48641f67dbaa005ab9743f7f6703b45347b8fed9ff5b3726b6ef520dd"
17+
url: "https://github.com/sqliteai/sqlite-sync/releases/download/1.0.19/cloudsync-apple-xcframework-1.0.19.zip",
18+
checksum: "1b7beca51414844cd7ad1cae483f08f208b0a717dcbaaffd764034f9385deb1f"
1919
),
2020
.target(
2121
name: "CloudSync",

0 commit comments

Comments
 (0)