@@ -15,7 +15,7 @@ define log_info
1515endef
1616
1717# Main Target
18- all : CoreCompiler.framework/CoreCompiler
18+ all : LLVM.xcframework
1919
2020# Fetch & Build Swift and LLVM for iOS
2121swift :
@@ -52,33 +52,37 @@ SWIFT_STATIC_LIBS = $(wildcard $(SWIFT_TOOLCHAIN_ROOT)/lib/libswift*.a) \
5252 $(wildcard $(ROOT ) /build/LLVMClangSwift_iphoneos/cmark-iphoneos-arm64/src/libcmark-gfm.a) \
5353 $(wildcard $(ROOT ) /build/LLVMClangSwift_iphoneos/cmark-iphoneos-arm64/extensions/libcmark-gfm-extensions.a)
5454SWIFT_HOST_COMPILER_DYLIBS = $(wildcard $(SWIFT_TOOLCHAIN_ROOT ) /lib/swift/host/compiler/lib_Compiler* .dylib)
55- SWIFT_LINK_PATHS = -L$(SWIFT_TOOLCHAIN_ROOT ) /lib \
56- -L$(SWIFT_TOOLCHAIN_ROOT ) /lib/swift/iphoneos \
57- -L$(SWIFT_TOOLCHAIN_ROOT ) /lib/swift/iphoneos/$(APPLE_ARCH ) \
58- -L$(SWIFT_TOOLCHAIN_ROOT ) /lib/swift/host/compiler
59- INC = -ISource -ISwiftToolchain-iphoneos/include -Illvm-project/lld/include -Illvm-project/clang/include -Illvm-project/llvm/include -Ibuild/LLVMClangSwift_iphoneos/llvm-iphoneos-arm64/tools/clang/include -Iswift/include -Iswift/stdlib/public/SwiftShims
6055
61- CoreCompiler.framework/CoreCompiler : swift-toolchain
62- $(call log_info,building CoreCompiler framework)
56+ LLVM.xcframework : swift-toolchain
57+ LLVM.xcframework :
58+ $(call log_info,bundling CoreCompilerSupportLibs)
6359 -rm -rf CoreCompilerSupportLibs
64- -rm * .o
65- clang -c -target $(TARGET_TRIPLE ) -isysroot $(SDK ) $(INC ) Source/CoreCompiler/* .c
66- clang -c -fobjc-arc -ObjC -target $(TARGET_TRIPLE ) -isysroot $(SDK ) $(INC ) Source/CoreCompiler/* .m
67- clang++ -c -Wno-elaborated-enum-base -std=c++17 -target $(TARGET_TRIPLE ) -isysroot $(SDK ) $(INC ) Source/CoreCompiler/* .cpp
68- clang++ -fobjc-arc -fno-rtti -fno-exceptions -fvisibility=hidden -fvisibility-inlines-hidden -ffunction-sections -fdata-sections -Wl,-dead_strip -flto=full -Os -fno-exceptions -Wl,-x -Wl,-S -Wl,-dead_strip_dylibs -ObjC -target $(TARGET_TRIPLE ) -isysroot $(SDK ) $(SWIFT_LINK_PATHS ) * .o $(SWIFT_STATIC_LIBS ) $(SWIFT_HOST_COMPILER_DYLIBS ) -framework CoreFoundation -lz -lxml2 -lswiftCore -o CoreCompiler.framework/CoreCompiler -shared -fPIC -install_name @rpath/CoreCompiler.framework/CoreCompiler
69- -rm * .o
70- -rm -rf CoreCompiler.framework/Headers
71- mkdir -p CoreCompiler.framework/Headers
72- cp Source/CoreCompiler/* .h CoreCompiler.framework/Headers/
7360 mkdir CoreCompilerSupportLibs
7461 cp $(SWIFT_HOST_COMPILER_DYLIBS ) CoreCompilerSupportLibs/
62+ $(call log_info,bundling LLVM xcframework headers)
63+ -rm -rf Headers
64+ mkdir Headers
65+ cp -r SwiftToolchain-iphoneos/include/* Headers/
66+ cp -r llvm-project/lld/include/* Headers/
67+ cp -r llvm-project/clang/include/* Headers/
68+ cp -r llvm-project/llvm/include/* Headers/
69+ cp -r build/LLVMClangSwift_iphoneos/llvm-iphoneos-arm64/tools/clang/include/* Headers/
70+ rm -rf Headers/swift/Bridging
71+ cp -r swift/include/* Headers/
72+ cp -r swift/stdlib/public/SwiftShims/* Headers/
73+ $(call log_info,create llvm.a)
74+ -rm -rf llvm.a
75+ libtool -static -o llvm.a $(SWIFT_STATIC_LIBS )
76+ $(call log_info,bundling LLVM xcframework)
77+ -rm -rf LLVM.xcframework
78+ xcodebuild -create-xcframework -library " ./llvm.a" -headers " Headers" -output LLVM.xcframework
7579
7680# Cleanup
7781clean-artifacts :
7882 -rm * .o
7983 -rm -rf CoreCompilerSupportLibs
80- -rm CoreCompiler.framework/CoreCompiler
81- -rm CoreCompiler.framework/ Headers/ *
84+ -rm -rf LLVM.xcframework
85+ -rm -rf Headers
8286
8387clean : clean-artifacts
8488 $(call log_info,cleaning up)
@@ -89,7 +93,5 @@ clean: clean-artifacts
8993 ! -name .git \
9094 ! -name .gitignore \
9195 ! -name .github \
92- ! -name CoreCompiler.framework \
93- ! -name Source \
9496 ! -name Scripts \
9597 -exec rm -rf {} +
0 commit comments