-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
115 lines (89 loc) · 3.97 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
rust_toolchain = 1.73
cargo = cargo +$(rust_toolchain)
# Targets from building the individual components to assembling a complete framework.
# Cargo already does incremental building so no targets depend on any files.
.PHONY: default
default:
# No default target.
exit 1
# CONFIGURE #
# Installing targets as dependencies of the actual builds was also an option...
.PHONY: setup
setup:
rustup toolchain install $(rust_toolchain)
rustup target add --toolchain=$(rust_toolchain) \
x86_64-apple-darwin \
aarch64-apple-darwin \
aarch64-apple-ios \
x86_64-apple-ios \
aarch64-apple-ios-sim
# BUILD FRAMEWORK #
.PHONY: framework # produces './generated/ConcordiumWalletCryptoUniffi.xcframework'
framework: clean-generated swift-bindings lib-darwin lib-ios lib-ios-sim
xcodebuild -create-xcframework \
-library ./generated/target/universal-darwin/libconcordium_wallet_crypto_uniffi.a -headers ./generated/bindings \
-library ./target/aarch64-apple-ios/release/libconcordium_wallet_crypto_uniffi.a -headers ./generated/bindings \
-library ./generated/target/universal-ios/libconcordium_wallet_crypto_uniffi.a -headers ./generated/bindings \
-output ./generated/ConcordiumWalletCryptoUniffi.xcframework
# GENERATE BINDINGS #
.PHONY: swift-bindings
swift-bindings: # produces './generated/bindings'
$(cargo) run --bin=uniffi-bindgen generate src/lib.udl --language=swift --out-dir=./generated/bindings
mkdir -p ./Sources/ConcordiumWalletCrypto
# Move Swift bridge code to source folder.
# The remaining files (header and renamed modulemap) should go into the framework
# (the directory is passed to 'xcodebuild -create-xcframework' via '-headers').
mv ./generated/bindings/crypto.swift ./Sources/ConcordiumWalletCrypto/generated.swift
mv ./generated/bindings/cryptoFFI.modulemap ./generated/bindings/module.modulemap
# BUILD STATIC LIBRARIES #
.PHONY: lib-darwin-x86_64
lib-darwin-x86_64: # produces './target/x86_64-apple-darwin/release/libconcordium_wallet_crypto_uniffi.a'
$(cargo) build --target=x86_64-apple-darwin --release
.PHONY: lib-darwin-aarch64
lib-darwin-aarch64: # produces './target/aarch64-apple-darwin/release/libconcordium_wallet_crypto_uniffi.a'
$(cargo) build --target=aarch64-apple-darwin --release
.PHONY: lib-darwin
lib-darwin: lib-darwin-x86_64 lib-darwin-aarch64 # produces './generated/target/universal-darwin/libconcordium_wallet_crypto_uniffi.a'
mkdir -p ./generated/target/universal-darwin
lipo \
./target/x86_64-apple-darwin/release/libconcordium_wallet_crypto_uniffi.a \
./target/aarch64-apple-darwin/release/libconcordium_wallet_crypto_uniffi.a \
-create -output ./generated/target/universal-darwin/libconcordium_wallet_crypto_uniffi.a
.PHONY: lib-ios # produces './target/aarch64-apple-ios/release/libconcordium_wallet_crypto_uniffi.a'
lib-ios:
$(cargo) build --target=aarch64-apple-ios --release
.PHONY: lib-ios-sim-x86_64 # produces './target/x86_64-apple-ios/release/libconcordium_wallet_crypto_uniffi.a'
lib-ios-sim-x86_64:
$(cargo) build --target=x86_64-apple-ios --release
.PHONY: lib-ios-sim-aarch64 # produces './target/aarch64-apple-ios-sim/release/libconcordium_wallet_crypto_uniffi.a'
lib-ios-sim-aarch64:
$(cargo) build --target=aarch64-apple-ios-sim --release
.PHONY: lib-ios-sim # produces './generated/target/universal-ios/libconcordium_wallet_crypto_uniffi.a'
lib-ios-sim: lib-ios-sim-x86_64 lib-ios-sim-aarch64
mkdir -p ./generated/target/universal-ios
lipo \
./target/x86_64-apple-ios/release/libconcordium_wallet_crypto_uniffi.a \
./target/aarch64-apple-ios-sim/release/libconcordium_wallet_crypto_uniffi.a \
-create -output ./generated/target/universal-ios/libconcordium_wallet_crypto_uniffi.a
# CLEANUP #
.PHONY: clean-target
clean-target:
rm -rf ./target
.PHONY: clean-generated
clean-generated:
rm -rf ./generated
.PHONY: clean
clean: clean-target clean-generated
# CONVENIENCE #
.PHONY: fmt
fmt:
$(cargo) fmt
.PHONY: lint
lint:
$(cargo) clippy
.PHONY: lint-fix
lint-fix:
$(cargo) clippy --fix
.PHONY: test
test:
$(cargo) test