-
Notifications
You must be signed in to change notification settings - Fork 16
/
Makefile
89 lines (71 loc) · 2.95 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
SHELL := bash
.ONESHELL:
.SHELLFLAGS := -eu -o pipefail -c
.DELETE_ON_ERROR:
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
PLATFORMS = ios-device macos ios-simulator
IOS_DEVICE_ARCHS = aarch64-apple-ios
IOS_SIM_ARCHS_STABLE = x86_64-apple-ios aarch64-apple-ios-sim
MACOS_ARCHS = x86_64-apple-darwin aarch64-apple-darwin
IOS_SIM_ARCHS = $(IOS_SIM_ARCHS_STABLE)
RUST_SRCS = $(shell find rust -name "*.rs") Cargo.toml
STATIC_LIBS = $(shell find target -name "libzcashlc.a")
install:
rustup toolchain add stable
rustup +stable target add aarch64-apple-ios x86_64-apple-ios x86_64-apple-darwin aarch64-apple-darwin aarch64-apple-ios-sim
.PHONY: install
release: clean xcframework
.PHONY: release
clean:
rm -rf products
rm -rf rust/target
.PHONY: clean
xcframework: products/libzcashlc.xcframework
mkdir -p releases/XCFramework/
rsync -avr --exclude='*.DS_Store' products/libzcashlc.xcframework releases/XCFramework/
.PHONY: xcframework
products/libzcashlc.xcframework: $(PLATFORMS)
rm -rf $@
mkdir -p $@
cp -R products/ios-device/frameworks $@/ios-arm64
cp -R products/ios-simulator/frameworks $@/ios-arm64_x86_64-simulator
cp -R products/macos/frameworks $@/macos-arm64_x86_64
cp support/Info.plist $@
frameworks: $(PLATFORMS)
.PHONY: frameworks
$(PLATFORMS): %: products/%/frameworks/libzcashlc.framework
.PHONY: $(PLATFORMS)
products/%/frameworks/libzcashlc.framework: products/%/universal/libzcashlc.a
rm -rf $@
mkdir -p $@
cp products/$*/universal/libzcashlc.a $@/libzcashlc
cp -R rust/target/Headers $@
mkdir $@/Modules
cp support/module.modulemap $@/Modules
# Workaround for a bug in the XCode 15.3 build system.
# https://github.com/Electric-Coin-Company/zashi-ios/issues/1166
cp support/platform-Info.plist $@/Info.plist
products/macos/universal/libzcashlc.a: $(MACOS_ARCHS)
mkdir -p $(@D)
lipo -create $(shell find products/macos/static-libraries -name "libzcashlc.a") -output $@
products/ios-simulator/universal/libzcashlc.a: $(IOS_SIM_ARCHS)
mkdir -p $(@D)
lipo -create $(shell find products/ios-simulator/static-libraries -name "libzcashlc.a") -output $@
products/ios-device/universal/libzcashlc.a: $(IOS_DEVICE_ARCHS)
mkdir -p $(@D)
lipo -create $(shell find products/ios-device/static-libraries -name "libzcashlc.a") -output $@
$(MACOS_ARCHS): %: stable-%
mkdir -p products/macos/static-libraries/$*
cp rust/target/$*/release/libzcashlc.a products/macos/static-libraries/$*
.PHONY: $(MACOS_ARCHS)
$(IOS_DEVICE_ARCHS): %: stable-%
mkdir -p products/ios-device/static-libraries/$*
cp rust/target/$*/release/libzcashlc.a products/ios-device/static-libraries/$*
.PHONY: $(IOS_DEVICE_ARCHS)
$(IOS_SIM_ARCHS_STABLE): %: stable-%
mkdir -p products/ios-simulator/static-libraries/$*
cp rust/target/$*/release/libzcashlc.a products/ios-simulator/static-libraries/$*
.PHONY: $(IOS_SIM_ARCHS_STABLE)
stable-%: # target/%/release/libzcashlc.a:
sh -c "RUSTUP_TOOLCHAIN=stable cargo build --manifest-path rust/Cargo.toml --target $* --release"