Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build of iOS simulator libraries. #58

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,34 +1,45 @@
IOS_OUT=ios

IOS_SDK_PATH=$(shell xcrun --sdk iphoneos --show-sdk-path)
IOS_SIM_SDK_PATH=$(shell xcrun --sdk iphonesimulator --show-sdk-path)

ios-arm64:
GOOS=ios \
GOARCH=arm64 \
CLANGARCH=arm64 \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this variable for?

CGO_ENABLED=1 \
SDK=iphoneos \
TARGET=arm64-apple-ios16 \
SDK=iphoneos \
SDK_PATH=$(IOS_SDK_PATH) \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this variable for? If I understand what is going on, it supposed to be redefined in clangwrap.sh. I don't see how this value used.

CGO_LDFLAGS="-target arm64-apple-ios16 -syslibroot \"${IOS_SDK_PATH}\"" \
CC=$(PWD)/clangwrap.sh \
CGO_CFLAGS="-fembed-bitcode" \
go build -tags no_jwz -buildmode=c-archive -o $(IOS_OUT)/libpolygonid-ios.a ./cmd/polygonid
cp $(IOS_OUT)/libpolygonid-ios.h $(IOS_OUT)/libpolygonid.h


ios-simulator-x86_64:
GOOS=darwin \
GOOS=ios \
GOARCH=amd64 \
CLANGARCH=x86_64 \
CGO_ENABLED=1 \
TARGET=x86_64-apple-ios16-simulator \
SDK=iphonesimulator \
TARGET=x86-64-apple-ios16-simulator \
SDK_PATH=$(IOS_SIM_SDK_PATH) \
CGO_LDFLAGS="-target x86_64-apple-ios16-simulator -syslibroot \"${IOS_SIM_SDK_PATH}\"" \
CC=$(PWD)/clangwrap.sh \
CGO_CFLAGS="-fembed-bitcode" \
go build -tags ios,no_jwz -buildmode=c-archive -o $(IOS_OUT)/libpolygonid-ios-simulator-x86_64.a ./cmd/polygonid
cp $(IOS_OUT)/libpolygonid-ios-simulator-x86_64.h $(IOS_OUT)/libpolygonid.h

ios-simulator-arm64:
GOOS=darwin \
GOOS=ios \
GOARCH=arm64 \
CLANGARCH=arm64 \
CGO_ENABLED=1 \
SDK=iphonesimulator \
TARGET=arm64-apple-ios16-simulator \
SDK=iphonesimulator \
SDK_PATH=$(IOS_SIM_SDK_PATH) \
CGO_LDFLAGS="-target arm64-apple-ios16-simulator -syslibroot \"${IOS_SIM_SDK_PATH}\"" \
CC=$(PWD)/clangwrap.sh \
CGO_CFLAGS="-fembed-bitcode" \
go build -tags ios,no_jwz -buildmode=c-archive -o $(IOS_OUT)/libpolygonid-ios-simulator-arm64.a ./cmd/polygonid
Expand All @@ -46,11 +57,14 @@ ios-old: ios-arm64 ios-simulator-x86_64
lipo $(IOS_OUT)/libpolygonid-ios.a $(IOS_OUT)/libpolygonid-ios-simulator-x86_64.a -create -output $(IOS_OUT)/libpolygonid.a
cp $(IOS_OUT)/libpolygonid-ios.h $(IOS_OUT)/libpolygonid.h

ios-device: ios-arm64
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't understand the purpose of this target. ios-arm64 already includes the line cp $(IOS_OUT)/libpolygonid-ios.h $(IOS_OUT)/libpolygonid.h. What ios-device should do that ios-arm64 doesn't?

cp $(IOS_OUT)/libpolygonid-ios.h $(IOS_OUT)/libpolygonid.h

ios-simulator: ios-simulator-x86_64 ios-simulator-arm64
lipo $(IOS_OUT)/libpolygonid-ios-simulator-x86_64.a $(IOS_OUT)/libpolygonid-ios-simulator-arm64.a -create -output $(IOS_OUT)/libpolygonid-ios-simulator.a
cp $(IOS_OUT)/libpolygonid-ios-simulator-arm64.h $(IOS_OUT)/libpolygonid.h

ios: ios-old ios-arm64 ios-simulator
ios: ios-device ios-simulator
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was expected that by calling the ios target, we would get the 'legacy' library libpolygonid.a. Now we do not. Is this the desired behavior, and does everyone (including @demonsh) agree?


dylib:
go build -tags no_jwz -buildmode=c-shared -o $(IOS_OUT)/libpolygonid.dylib ./cmd/polygonid
Expand Down