Skip to content

Commit 8f4fe36

Browse files
committed
fix(build): update macOS build configuration to support separate build architectures
1 parent bb3aa37 commit 8f4fe36

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

.github/workflows/main.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
build:
1313
runs-on: ${{ matrix.os }}
1414
container: ${{ matrix.container && matrix.container || '' }}
15-
name: ${{ matrix.name }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }} build${{ matrix.arch != 'arm64-v8a' && matrix.name != 'ios-sim' && matrix.name != 'ios' && matrix.name != 'apple-xcframework' && matrix.name != 'android-aar' && ' + test' || ''}}
15+
name: ${{ matrix.name }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }} build${{ matrix.arch != 'arm64-v8a' && matrix.name != 'ios-sim' && matrix.name != 'ios' && matrix.name != 'apple-xcframework' && matrix.name != 'android-aar' && ( matrix.name != 'macos' || matrix.arch != 'x86_64' ) && ' + test' || ''}}
1616
timeout-minutes: 20
1717
strategy:
1818
fail-fast: false
@@ -34,6 +34,14 @@ jobs:
3434
- os: macos-15
3535
name: macos
3636
make: COVERAGE=ON
37+
- os: macos-15
38+
arch: x86_64
39+
name: macos
40+
make: ARCH=x86_64
41+
- os: macos-15
42+
arch: arm64
43+
name: macos
44+
make: ARCH=arm64
3745
- os: windows-2022
3846
arch: x86_64
3947
name: windows
@@ -196,11 +204,11 @@ jobs:
196204
adb shell "sh /data/local/tmp/commands.sh"
197205
198206
- name: test sqlite-sync
199-
if: contains(matrix.name, 'linux') || matrix.name == 'windows' || matrix.name == 'macos'
207+
if: contains(matrix.name, 'linux') || matrix.name == 'windows' || ( matrix.name == 'macos' && matrix.arch != 'x86_64' )
200208
run: ${{ matrix.name == 'linux-musl' && matrix.arch == 'arm64' && 'docker exec alpine' || '' }} make test ${{ matrix.make && matrix.make || ''}}
201209

202210
- uses: actions/[email protected]
203-
if: matrix.name == 'macos'
211+
if: matrix.name == 'macos' && !matrix.arch
204212
with:
205213
path: coverage
206214

Makefile

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,17 @@ ifeq ($(PLATFORM),windows)
7272
STRIP = strip --strip-unneeded $@
7373
else ifeq ($(PLATFORM),macos)
7474
TARGET := $(DIST_DIR)/cloudsync.dylib
75-
LDFLAGS += -arch x86_64 -arch arm64 -framework Security -dynamiclib -undefined dynamic_lookup
75+
ifndef ARCH
76+
LDFLAGS += -arch x86_64 -arch arm64
77+
CFLAGS += -arch x86_64 -arch arm64
78+
CURL_CONFIG = --with-secure-transport CFLAGS="-arch x86_64 -arch arm64"
79+
else
80+
LDFLAGS += -arch $(ARCH)
81+
CFLAGS += -arch $(ARCH)
82+
CURL_CONFIG = --with-secure-transport CFLAGS="-arch $(ARCH)"
83+
endif
84+
LDFLAGS += -framework Security -dynamiclib -undefined dynamic_lookup -headerpad_max_install_names
7685
T_LDFLAGS = -framework Security
77-
CFLAGS += -arch x86_64 -arch arm64
78-
CURL_CONFIG = --with-secure-transport CFLAGS="-arch x86_64 -arch arm64"
7986
STRIP = strip -x -S $@
8087
else ifeq ($(PLATFORM),android)
8188
ifndef ARCH # Set ARCH to find Android NDK's Clang compiler, the user should set the ARCH
@@ -101,15 +108,15 @@ else ifeq ($(PLATFORM),android)
101108
else ifeq ($(PLATFORM),ios)
102109
TARGET := $(DIST_DIR)/cloudsync.dylib
103110
SDK := -isysroot $(shell xcrun --sdk iphoneos --show-sdk-path) -miphoneos-version-min=11.0
104-
LDFLAGS += -framework Security -framework CoreFoundation -dynamiclib $(SDK)
111+
LDFLAGS += -framework Security -framework CoreFoundation -dynamiclib $(SDK) -headerpad_max_install_names
105112
T_LDFLAGS = -framework Security
106113
CFLAGS += -arch arm64 $(SDK)
107114
CURL_CONFIG = --host=arm64-apple-darwin --with-secure-transport CFLAGS="-arch arm64 -isysroot $$(xcrun --sdk iphoneos --show-sdk-path) -miphoneos-version-min=11.0"
108115
STRIP = strip -x -S $@
109116
else ifeq ($(PLATFORM),ios-sim)
110117
TARGET := $(DIST_DIR)/cloudsync.dylib
111118
SDK := -isysroot $(shell xcrun --sdk iphonesimulator --show-sdk-path) -miphonesimulator-version-min=11.0
112-
LDFLAGS += -arch x86_64 -arch arm64 -framework Security -framework CoreFoundation -dynamiclib $(SDK)
119+
LDFLAGS += -arch x86_64 -arch arm64 -framework Security -framework CoreFoundation -dynamiclib $(SDK) -headerpad_max_install_names
113120
T_LDFLAGS = -framework Security
114121
CFLAGS += -arch x86_64 -arch arm64 $(SDK)
115122
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"

0 commit comments

Comments
 (0)