forked from procivis/one-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.toml
254 lines (215 loc) · 7.62 KB
/
Makefile.toml
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# Docs: https://github.com/sagiegurari/cargo-make
env_files = ["./dev.env"]
[config]
default_to_workspace = false
[tasks.clean]
args = ["clean"]
command = "cargo"
[tasks.build]
args = ["build", "-p", "core-server"]
command = "cargo"
[tasks.clippy]
args = ["clippy", "--all-targets", "--", "-D", "clippy::print_stderr", "-D", "clippy::dbg_macro"]
command = "cargo"
[tasks.format]
args = ["fmt"]
command = "cargo"
toolchain = "nightly"
[tasks.fmt]
alias = "format"
[tasks.run]
args = [
"run",
"-p",
"core-server",
"--",
"--config",
"config/config-procivis-base.yml",
"--config",
"config/config-local.yml",
]
command = "cargo"
[tasks.runwallet]
args = [
"run",
"-p",
"core-server",
"--",
"--config",
"config/config-procivis-base.yml",
"--config",
"config/config-local.yml",
]
command = "cargo"
env = { "ONE_app__serverPort" = "3001", "ONE_app__databaseUrl" = "mysql://core:886eOqVMmlHsayu6Vyxw@localhost:3307/core", "ONE_app__coreBaseUrl" = "http://0.0.0.0:3001" }
[tasks.runw]
args = ["watch", "--ignore", "*.md", "--ignore", "*.yaml", "--ignore", "*.yml", "--exec", "make run"]
command = "cargo"
[tasks.test]
args = ["test"]
command = "cargo"
workspace = true
[tasks.unit-tests]
args = ["test", "--lib"]
command = "cargo"
[tasks.integration-tests]
args = ["test", "--test", "integration_tests"]
command = "cargo"
[tasks.dbstart]
args = ["compose", "-f", "docker/db.yml", "up", "-d"]
command = "docker"
[tasks.dbstop]
args = ["compose", "-f", "docker/db.yml", "down"]
command = "docker"
[tasks.dbdrop]
script = [
"docker rm --force docker-mariadb-1",
"docker rm --force docker-walletdb-1",
"docker volume rm docker_mariadb_data",
]
[tasks.install_seaormcli]
args = ["install", "sea-orm-cli", "--force", "--version", "0.12.1"]
command = "cargo"
[tasks.dbup1]
args = ["run", "-p", "migration", "--", "up", "-n1"]
command = "cargo"
env = { "DATABASE_URL" = "mysql://core:886eOqVMmlHsayu6Vyxw@localhost/core" }
[tasks.dbdown1]
args = ["run", "-p", "migration", "--", "down", "-n1"]
command = "cargo"
env = { "DATABASE_URL" = "mysql://core:886eOqVMmlHsayu6Vyxw@localhost/core" }
[tasks.generate_migration]
args = ["migrate", "generate", "${@}", "-d", "./apps/migration/"]
command = "sea-orm-cli"
[tasks.dbtempent]
args = [
"generate",
"entity",
"--date-time-crate",
"time",
"--database-url",
"mysql://core:886eOqVMmlHsayu6Vyxw@localhost/core",
"-o",
"lib/sql-data-provider/src/entity_new/",
]
command = "sea-orm-cli"
[tasks.mobile-build]
script.pre = '''
export CARGO_PROFILE_RELEASE_OPT_LEVEL=s
export CARGO_PROFILE_RELEASE_LTO=true
export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1
export CARGO_PROFILE_RELEASE_STRIP=symbols
'''
############################################################### ANDROID-UNIFFI
[tasks.add_android_targets]
# x86_64 is skipped due to: https://github.com/rust-lang/rust/issues/109717
args = ["target", "add", "i686-linux-android", "armv7-linux-androideabi", "aarch64-linux-android"]
command = "rustup"
[tasks.install_cross]
args = ["install", "cross", "--git", "https://github.com/cross-rs/cross", "--tag", "v0.2.5"]
command = "cargo"
[tasks.generateuniffi_android]
script = '''
cargo run --features=uniffi/cli -p uniffi-bindgen --bin uniffi-bindgen generate -l kotlin -o target/android_tmp platforms/uniffi/src/one_core.udl
mkdir -p target/uniffi/android/java/ch/procivis/one/core
mv target/android_tmp/ch/procivis/one/core/* target/uniffi/android/java/ch/procivis/one/core
rm -rf target/android_tmp
'''
[tasks.build_android_targets]
extend = "mobile-build"
script.main = '''
for target in "i686-linux-android" "armv7-linux-androideabi" "aarch64-linux-android"
do
cross build -p one-core-uniffi --target $target --release
done
'''
[tasks.collect_android_libs]
script = '''
mkdir -p target/uniffi/android/jniLibs/x86/
cp target/i686-linux-android/release/libone_core_uniffi.so target/uniffi/android/jniLibs/x86/libprocivis_one_core.so
mkdir -p target/uniffi/android/jniLibs/armeabi-v7a/
cp target/armv7-linux-androideabi/release/libone_core_uniffi.so target/uniffi/android/jniLibs/armeabi-v7a/libprocivis_one_core.so
mkdir -p target/uniffi/android/jniLibs/arm64-v8a/
cp target/aarch64-linux-android/release/libone_core_uniffi.so target/uniffi/android/jniLibs/arm64-v8a/libprocivis_one_core.so
'''
[tasks.build_android_uniffi]
dependencies = ["install_cross", "generateuniffi_android", "build_android_targets", "collect_android_libs"]
############################################################### ANDROID-GRADLE
[tasks.prepare_gradle_build_directory]
dependencies = ["build_android_uniffi"]
script = '''
mkdir -p target/platforms/android
cp -r platforms/android/* target/platforms/android/
cp -r target/uniffi/android/* target/platforms/android/onecore/src/main/
'''
[tasks.build_android_gradle]
dependencies = ["prepare_gradle_build_directory"]
script = '''
cd target/platforms/android
./gradlew assemble
'''
[tasks.build_android]
dependencies = ["build_android_gradle"]
script = '''
mkdir -p target/bindings/android/
cp -r target/platforms/android/onecore/build/outputs/aar/* target/bindings/android/
'''
############################################################### iOS
[tasks.generateuniffi_ios]
script = '''
cargo run --features=uniffi/cli -p uniffi-bindgen --bin uniffi-bindgen generate -l swift -o target/uniffi/ios/ platforms/uniffi/src/one_core.udl
'''
[tasks.add_ios_targets]
script = '''
rustup target add aarch64-apple-ios-sim
rustup target add aarch64-apple-ios x86_64-apple-ios
'''
[tasks.build_ios_code]
extend = "mobile-build"
script.main = '''
cargo build --package one-core-uniffi --lib --release --target x86_64-apple-ios
cargo build --package one-core-uniffi --lib --release --target aarch64-apple-ios-sim
cargo build --package one-core-uniffi --lib --release --target aarch64-apple-ios
'''
[tasks.collect_ios_libs]
script = """
sed -i '' 's/^module\\ one_coreFFI/framework\\ module\\ one_coreFFI/' target/uniffi/ios/one_coreFFI.modulemap
find . -type d -name one_coreFFI.framework -exec rm -rf {} \\; 2>/dev/null || true
for arch in "x86_64-apple-ios" "aarch64-apple-ios-sim" "aarch64-apple-ios"
do
pushd target/$arch/release >/dev/null &&
mkdir -p one_coreFFI.framework &&
cd one_coreFFI.framework &&
mkdir -p Headers Modules Resources &&
cp ../../../uniffi/ios/one_coreFFI.modulemap ./Modules/module.modulemap &&
cp ../../../uniffi/ios/one_coreFFI.h ./Headers/one_coreFFI.h &&
strip -S -x -o ./one_coreFFI -r ../libone_core_uniffi.a 2>/dev/null &&
cp ../../../../platforms/ios/Info.plist ./Resources &&
popd >/dev/null
done
"""
[tasks.create_xc_framework]
script = '''
lipo -create target/x86_64-apple-ios/release/one_coreFFI.framework/one_coreFFI target/aarch64-apple-ios-sim/release/one_coreFFI.framework/one_coreFFI -output target/aarch64-apple-ios-sim/release/one_coreFFI.framework/one_coreFFI
rm -rf target/one_coreFFI.xcframework || echo 'skip removing'
xcodebuild -create-xcframework -framework target/aarch64-apple-ios/release/one_coreFFI.framework -framework target/aarch64-apple-ios-sim/release/one_coreFFI.framework -output target/one_coreFFI.xcframework
'''
[tasks.package_ios_bindings]
script = '''
pushd target >/dev/null
rm -rf bindings/ios && mkdir -p bindings/ios/one_core
cp -r ../platforms/ios/Sources bindings/ios/one_core/
cp -r one_coreFFI.xcframework bindings/ios/one_core/Sources/
cp uniffi/ios/one_core.swift bindings/ios/one_core/Sources/
cp ../platforms/ios/Package.swift bindings/ios/one_core/Package.swift
'''
[tasks.build_ios]
dependencies = [
"generateuniffi_ios",
"add_ios_targets",
"build_ios_code",
"collect_ios_libs",
"create_xc_framework",
"package_ios_bindings",
]
script = 'echo "--- output available in target/bindings/ios ---"'