@@ -30,25 +30,22 @@ build-bridge:
30
30
@cd $(BRIDGE_DIR ) && CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -buildmode=c-archive -o libtsc_darwin_amd64.a .
31
31
@echo " $( YELLOW) Building for macOS arm64...$( NC) "
32
32
@cd $(BRIDGE_DIR ) && CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -buildmode=c-archive -o libtsc_darwin_arm64.a .
33
- @echo " $( YELLOW) Building for iOS arm64...$( NC) "
34
- @cd $(BRIDGE_DIR ) && CGO_ENABLED=1 GOOS=ios GOARCH=arm64 go build -buildmode=c-archive -o libtsc_ios_arm64.a .
35
- @echo " $( YELLOW) Building for iOS Simulator x86_64...$( NC) "
36
- @cd $(BRIDGE_DIR ) && CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -buildmode=c-archive -tags ios -o libtsc_ios_sim_amd64.a .
37
- @echo " $( YELLOW) Building for iOS Simulator arm64...$( NC) "
38
- @cd $(BRIDGE_DIR ) && CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -buildmode=c-archive -tags ios -o libtsc_ios_sim_arm64.a .
39
- @echo " $( YELLOW) Creating universal binary for macOS...$( NC) "
40
- @cd $(BRIDGE_DIR ) && lipo -create libtsc_darwin_amd64.a libtsc_darwin_arm64.a -output libtsc_macos.a
41
- @echo " $( YELLOW) Creating universal binary for iOS Simulator...$( NC) "
42
- @cd $(BRIDGE_DIR ) && lipo -create libtsc_ios_sim_amd64.a libtsc_ios_sim_arm64.a -output libtsc_ios_simulator.a
33
+ @echo " $( YELLOW) Creating universal binary...$( NC) "
34
+ @cd $(BRIDGE_DIR ) && lipo -create libtsc_darwin_amd64.a libtsc_darwin_arm64.a -output libtsc_universal.a
35
+ @echo " $( YELLOW) Creating XCFramework...$( NC) "
36
+ @cd $(BRIDGE_DIR ) && rm -rf TSCBridge.xcframework
37
+ @cd $(BRIDGE_DIR ) && mkdir -p headers && cp libtsc_darwin_amd64.h headers/tsc_bridge.h
38
+ @cd $(BRIDGE_DIR ) && xcodebuild -create-xcframework \
39
+ -library libtsc_universal.a -headers headers \
40
+ -output TSCBridge.xcframework
43
41
@echo " $( YELLOW) Copying files to output directory...$( NC) "
44
- @cp $(BRIDGE_DIR ) /libtsc_macos.a $(OUTPUT_DIR ) /
45
- @cp $(BRIDGE_DIR ) /libtsc_ios_arm64.a $(OUTPUT_DIR ) /
46
- @cp $(BRIDGE_DIR ) /libtsc_ios_simulator.a $(OUTPUT_DIR ) /
42
+ @cp -r $(BRIDGE_DIR ) /TSCBridge.xcframework $(OUTPUT_DIR ) /
47
43
@cp $(BRIDGE_DIR ) /libtsc_darwin_amd64.h $(OUTPUT_DIR ) /tsc_bridge.h
48
44
@echo " $( YELLOW) Creating module map...$( NC) "
49
45
@echo ' module TSCBridge {\n header "tsc_bridge.h"\n export *\n}' > $(OUTPUT_DIR ) /module.modulemap
50
46
@echo " $( YELLOW) Cleaning up intermediate files...$( NC) "
51
- @cd $(BRIDGE_DIR ) && rm -f libtsc_darwin_* .a libtsc_ios_* .a * .h
47
+ @cd $(BRIDGE_DIR ) && rm -f libtsc_* .a * .h
48
+ @cd $(BRIDGE_DIR ) && rm -rf TSCBridge.xcframework headers
52
49
@echo " $( GREEN) C Bridge build completed successfully!$( NC) "
53
50
@$(MAKE ) verify-bridge
54
51
@@ -57,33 +54,32 @@ build-bridge-macos:
57
54
@echo " $( GREEN) Building TypeScript Go C Bridge for macOS only...$( NC) "
58
55
@mkdir -p $(OUTPUT_DIR )
59
56
@echo " $( YELLOW) Cleaning previous builds...$( NC) "
60
- @rm -f $(OUTPUT_DIR ) /libtsc_macos.a $(OUTPUT_DIR ) /tsc_bridge.h $(BRIDGE_DIR ) /libtsc_* .a $(BRIDGE_DIR ) /* .h
57
+ @rm -f $(OUTPUT_DIR ) /TSCBridge.xcframework $(OUTPUT_DIR ) /tsc_bridge.h $(BRIDGE_DIR ) /libtsc_* .a $(BRIDGE_DIR ) /* .h
61
58
@echo " $( YELLOW) Building for macOS x86_64...$( NC) "
62
59
@cd $(BRIDGE_DIR ) && CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -buildmode=c-archive -o libtsc_darwin_amd64.a .
63
60
@echo " $( YELLOW) Building for macOS arm64...$( NC) "
64
61
@cd $(BRIDGE_DIR ) && CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -buildmode=c-archive -o libtsc_darwin_arm64.a .
65
- @echo " $( YELLOW) Creating universal binary for macOS ...$( NC) "
66
- @cd $(BRIDGE_DIR ) && lipo -create libtsc_darwin_amd64.a libtsc_darwin_arm64.a -output libtsc_macos .a
62
+ @echo " $( YELLOW) Creating universal binary...$( NC) "
63
+ @cd $(BRIDGE_DIR ) && lipo -create libtsc_darwin_amd64.a libtsc_darwin_arm64.a -output libtsc_universal .a
67
64
@echo " $( YELLOW) Copying files to output directory...$( NC) "
68
- @cp $(BRIDGE_DIR ) /libtsc_macos .a $(OUTPUT_DIR ) /
65
+ @cp $(BRIDGE_DIR ) /libtsc_universal .a $(OUTPUT_DIR ) /
69
66
@cp $(BRIDGE_DIR ) /libtsc_darwin_amd64.h $(OUTPUT_DIR ) /tsc_bridge.h
70
67
@echo " $( YELLOW) Creating module map...$( NC) "
71
68
@echo ' module TSCBridge {\n header "tsc_bridge.h"\n export *\n}' > $(OUTPUT_DIR ) /module.modulemap
72
69
@echo " $( YELLOW) Cleaning up intermediate files...$( NC) "
73
- @cd $(BRIDGE_DIR ) && rm -f libtsc_darwin_ * .a * .h
70
+ @cd $(BRIDGE_DIR ) && rm -f libtsc_ * .a * .h
74
71
@echo " $( GREEN) C Bridge macOS build completed successfully!$( NC) "
75
72
76
73
77
74
78
75
# Verify bridge builds
79
76
verify-bridge :
80
77
@echo " $( BLUE) Verifying builds...$( NC) "
81
- @for lib in $(OUTPUT_DIR ) /* .a; do \
82
- echo " Checking $$ (basename $$ lib):" ; \
83
- file " $$ lib" ; \
84
- nm " $$ lib" | grep -E " (tsc_build_|tsc_validate_|tsc_free_)" | head -5 || true ; \
78
+ @if [ -d $( OUTPUT_DIR) /TSCBridge.xcframework ]; then \
79
+ echo " Checking TSCBridge.xcframework:" ; \
80
+ find $(OUTPUT_DIR ) /TSCBridge.xcframework -name " *.a" -exec file {} \; || true ; \
85
81
echo " " ; \
86
- done
82
+ fi
87
83
88
84
# Setup development environment
89
85
setup :
@@ -116,6 +112,8 @@ clean-bridge:
116
112
@echo " $( YELLOW) Cleaning C bridge artifacts...$( NC) "
117
113
@rm -rf $(OUTPUT_DIR )
118
114
@cd $(BRIDGE_DIR ) && rm -f * .a * .h
115
+ @cd $(BRIDGE_DIR ) && rm -rf TSCBridge.xcframework headers
116
+
119
117
120
118
# Development helpers
121
119
dev-setup : setup build-bridge-macos
0 commit comments