-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.toml
349 lines (307 loc) · 10.7 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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
env_files = [{ path = "./.env", profile = "release" }]
# vim: set ts=4 sw=4 expandtab:
[config]
default_to_workspace = false
additional_profiles = ["release"]
## Environment setup, some will get overridden in other tasks
[env]
CARGO_MAKE_CRATE_FS_NAME = "rytm"
CARGO_MAKE_WORKSPACE_INCLUDE_MEMBERS = ["rytm-external"]
PACKAGE_TO_BUILD = "rytm-external"
MAX_PACKAGE_NAME = "petunia"
MAX_EXT_NAME = { value = "${CARGO_MAKE_CRATE_FS_NAME}", condition = { env_not_set = [
"MAX_EXT_NAME",
] } }
MAX_EXT_BASE_NAME = "${MAX_EXT_NAME}"
PLATFORM_INSTALL_DIR = { source = "${CARGO_MAKE_RUST_TARGET_OS}", default_value = "ERROR", mapping = { "macos" = "${HOME}/Documents/Max 8/Packages", windows = "${USERPROFILE}/Documents/Max 8/Packages" } }
EXTERNAL_INSTALL_DIR = "${PLATFORM_INSTALL_DIR}/${MAX_PACKAGE_NAME}/externals/"
PACKAGED_LIB_FILE_NAME = "${MAX_EXT_NAME}"
PACKAGE_MEMBERS_DIR = "${CARGO_MAKE_WORKING_DIRECTORY}/${MAX_PACKAGE_NAME}"
PACKAGE_MEMBERS_INSTALL_DIR = "${PLATFORM_INSTALL_DIR}/${MAX_PACKAGE_NAME}/"
TARGET_TRIPLE = "${CARGO_MAKE_RUST_TARGET_TRIPLE}"
TARGET_TRIPLE_WINDOWS = { source = "${CARGO_MAKE_RUST_TARGET_OS}", default_value = "x86_64-pc-windows-gnu", mapping = { "windows" = "x86_64-pc-windows-msvc" } }
TARGET_TRIPLE_MAC_AARCH64 = "aarch64-apple-darwin"
TARGET_TRIPLE_MAC_X86 = "x86_64-apple-darwin"
TARGET_TRIPLE_MAC_UNIVERSAL = "universal-apple-darwin"
IS_MAC_AARCH64 = { source = "${CARGO_MAKE_RUST_TARGET_TRIPLE}", default_value = "false", mapping = { "aarch64-apple-darwin" = "true" } }
IS_MAC_X86 = { source = "${CARGO_MAKE_RUST_TARGET_TRIPLE}", default_value = "false", mapping = { "x86_64-apple-darwin" = "true" } }
IS_WIN_X86 = { source = "${CARGO_MAKE_RUST_TARGET_OS}", default_value = "false", mapping = { "windows" = "true" } }
IS_TILDE = false
WORKSPACE_TARGET_DIR = "target"
[env.development]
BUILD_ARGS = "build"
PROFILE_DIR = "debug"
[env.release]
BUILD_ARGS = "build|--release"
PROFILE_DIR = "release"
## Build Tasks
[tasks.build-target]
private = true
args = [
"@@split(BUILD_ARGS,|)",
"--target",
"${TARGET_TRIPLE}",
"-p",
"${PACKAGE_TO_BUILD}",
]
command = "cargo"
[tasks.build]
clear = true
dependencies = ["setup"]
run_task = [
{ name = "build-windows", condition = { env_true = [
"IS_WIN_X86",
] } },
{ name = "build-mac-x86", condition = { env_true = [
"IS_MAC_X86",
] } },
{ name = "build-mac-aarch64", condition = { env_true = [
"IS_MAC_AARCH64",
] } },
]
[tasks.build-windows]
dependencies = ["env-windows"]
env = { "TARGET_TRIPLE" = "${TARGET_TRIPLE_WINDOWS}" }
run_task = "build-target"
[tasks.build-mac-aarch64]
dependencies = ["env-mac"]
env = { "TARGET_TRIPLE" = "${TARGET_TRIPLE_MAC_AARCH64}" }
run_task = "build-target"
[tasks.build-mac-x86]
dependencies = ["env-mac"]
env = { "TARGET_TRIPLE" = "${TARGET_TRIPLE_MAC_X86}" }
run_task = "build-target"
[tasks.build-mac-universal]
clear = true
dependencies = ["build-mac-x86", "build-mac-aarch64", "name-env"]
env = { "TARGET_TRIPLE" = "${TARGET_TRIPLE_MAC_UNIVERSAL}", "PROFILE_EXTERNAL_PATH" = "${WORKSPACE_TARGET_DIR}/${TARGET_TRIPLE_MAC_UNIVERSAL}/${PROFILE_DIR}/${MAX_EXT_NAME}.${PLATFORM_EXTERNAL_EXT}" }
script_runner = "@shell"
script = '''
mkdir -p ${PROFILE_EXTERNAL_PATH}/Contents/MacOS/
cp "${CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE_DIRECTORY}/PkgInfo" "${PROFILE_EXTERNAL_PATH}/Contents/"
lipo -create -output "${PROFILE_EXTERNAL_PATH}/Contents/MacOS/${PACKAGED_LIB_FILE_NAME}" "${WORKSPACE_TARGET_DIR}/${TARGET_TRIPLE_MAC_X86}/${PROFILE_DIR}/${LIB_FILE_NAME}" "${WORKSPACE_TARGET_DIR}/${TARGET_TRIPLE_MAC_AARCH64}/${PROFILE_DIR}/${LIB_FILE_NAME}"
'''
# Add universal signing task that uses the profile-dependent signing
[tasks.sign-mac-universal]
dependencies = ["build-mac-universal"]
run_task = [
{ name = "codesign-ad-hoc", condition = { profiles = [
"development",
] } },
{ name = "codesign-with-dev-id", condition = { profiles = [
"release",
] } },
]
## Pre build Setup
[tasks.env-mac]
private = true
env = { "PLATFORM_DYLIB_EXT" = "dylib", "PLATFORM_EXTERNAL_EXT" = "mxo", "PLATFORM_DYLIB_PREFIX" = "lib" }
run_task = "env-common"
[tasks.env-windows]
private = true
env = { "PLATFORM_DYLIB_EXT" = "dll", "PLATFORM_EXTERNAL_EXT" = "mxe64", "PLATFORM_DYLIB_PREFIX" = "" }
run_task = "env-common"
[tasks.env-common]
private = true
env = { "LIB_FILE_NAME" = "${PLATFORM_DYLIB_PREFIX}${CARGO_MAKE_CRATE_FS_NAME}.${PLATFORM_DYLIB_EXT}", "LIB_TILDE_FILE_NAME" = "${PLATFORM_DYLIB_PREFIX}${CARGO_MAKE_CRATE_FS_NAME}_tilde.${PLATFORM_DYLIB_EXT}" }
[tasks.setup]
run_task = [
{ name = "env-windows", condition = { platforms = [
"windows",
] } },
{ name = "env-mac", condition = { platforms = [
"mac",
] } },
]
## Post build setup
[tasks.name-env]
env = { "PROFILE_EXTERNAL_PATH" = "${WORKSPACE_TARGET_DIR}/${TARGET_TRIPLE}/${PROFILE_DIR}/${MAX_EXT_NAME}.${PLATFORM_EXTERNAL_EXT}", "PROFILE_TARGET_DIR" = "${WORKSPACE_TARGET_DIR}/${TARGET_TRIPLE}/${PROFILE_DIR}" }
run_task = "add_tilde"
[tasks.add_tilde]
private = true
condition = { files_exist = ["${PROFILE_TARGET_DIR}/${LIB_TILDE_FILE_NAME}"] }
env = { "MAX_EXT_NAME" = "${MAX_EXT_BASE_NAME}~", "PROFILE_EXTERNAL_PATH" = "${PROFILE_TARGET_DIR}/${MAX_EXT_NAME}.${PLATFORM_EXTERNAL_EXT}", "LIB_FILE_NAME" = "${LIB_TILDE_FILE_NAME}", "PACKAGED_LIB_FILE_NAME" = "${MAX_EXT_BASE_NAME}~", IS_TILDE = "true" }
## Utils
[tasks.echo]
dependencies = ["build", "name-env"]
script_runner = "@shell"
script = '''
echo MAX_EXT_NAME: ${MAX_EXT_NAME}
echo PLATFORM_DYLIB_EXT: ${PLATFORM_DYLIB_EXT}
echo PLATFORM_EXTERNAL_EXT: ${PLATFORM_EXTERNAL_EXT}
echo PLATFORM_INSTALL_DIR: ${PLATFORM_INSTALL_DIR}
echo TARGET_ARCH: ${CARGO_MAKE_RUST_TARGET_ARCH}
echo TARGET_OS: ${CARGO_MAKE_RUST_TARGET_OS}
echo TARGET_TRIPLE: ${CARGO_MAKE_RUST_TARGET_TRIPLE}
echo PROFILE_EXTERNAL_PATH: ${PROFILE_EXTERNAL_PATH}
echo INIT_INSTALL_DIR: ${INIT_INSTALL_DIR}
echo EXTERNAL_INSTALL_DIR: ${EXTERNAL_INSTALL_DIR}
echo CARGO_MAKE_PROJECT_NAME: ${CARGO_MAKE_PROJECT_NAME}
echo LIB_FILE_NAME: ${LIB_FILE_NAME}
echo IS_MAC_X86: ${IS_MAC_X86}
echo IS_MAC_AARCH64: ${IS_MAC_AARCH64}
echo IS_WIN_X86: ${IS_WIN_X86}
'''
## Post build actions
[tasks.package-windows]
dependencies = ["build-windows", "name-env"]
private = true
clear = true
script_runner = "@shell"
script = '''
cp "${PROFILE_TARGET_DIR}/${LIB_FILE_NAME}" "${PROFILE_EXTERNAL_PATH}"
'''
[tasks.package-mac]
private = true
clear = true
script_runner = "@shell"
script = '''
mkdir -p ${PROFILE_EXTERNAL_PATH}/Contents/MacOS/
cp "${PROFILE_TARGET_DIR}/${LIB_FILE_NAME}" "${PROFILE_EXTERNAL_PATH}/Contents/MacOS/${PACKAGED_LIB_FILE_NAME}"
cp "${CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE_DIRECTORY}/PkgInfo" "${PROFILE_EXTERNAL_PATH}/Contents/"
'''
[tasks.codesign-ad-hoc]
condition = { profiles = ["development"] }
private = true
clear = true
script_runner = "@shell"
script = '''
codesign -f -s - "${PROFILE_EXTERNAL_PATH}"
'''
[tasks.codesign-with-dev-id]
condition = { profiles = ["release"] }
private = true
clear = true
script_runner = "@shell"
script = '''
codesign --deep -f -v -s "${DEVELOPER_ID}" \
--entitlements "${ENTITLEMENTS}" \
--timestamp \
--options=runtime \
"${PROFILE_EXTERNAL_PATH}" && echo "Signed ${PROFILE_EXTERNAL_PATH}" && \
codesign --verify --verbose=4 ${PROFILE_EXTERNAL_PATH} && \
codesign -d --entitlements :- --verbose=4 ${PROFILE_EXTERNAL_PATH}
'''
[tasks.package]
dependencies = ["build", "name-env"]
clear = true
run_task = [
{ name = [
"package-mac",
"codesign-ad-hoc",
], condition = { platforms = [
"mac",
], profiles = [
"development",
] } },
{ name = [
"package-mac",
"codesign-with-dev-id",
], condition = { platforms = [
"mac",
], profiles = [
"release",
] } },
{ name = "package-windows", condition = { platforms = [
"windows",
] } },
]
[tasks.package-all]
clear = true
run_task = [
{ name = [
"package-windows",
"build-mac-universal",
"sign-mac-universal", # Add signing step for universal binary
"extend-package-members",
"copy-all",
], condition = { platforms = ["mac"] } },
]
[tasks.copy-all]
private = true
# target/debug/petunia
# env = { "PACKAGE_DIR" = "${WORKSPACE_TARGET_DIR}/${PROFILE_DIR}/${MAX_PACKAGE_NAME}" }
env = { "PACKAGE_DIR" = "${CARGO_MAKE_WORKING_DIRECTORY}/${MAX_PACKAGE_NAME}" }
run_task = [
{ name = [
"extend-package-members",
"copy-all-packages",
], condition = { platforms = [
"mac",
] } },
]
[tasks.copy-all-packages]
private = true
script_runner = "@shell"
script = '''
mkdir -p ${PACKAGE_DIR}/externals/
cp -r ${WORKSPACE_TARGET_DIR}/${TARGET_TRIPLE_MAC_UNIVERSAL}/${PROFILE_DIR}/${MAX_EXT_NAME}.mxo ${PACKAGE_DIR}/externals/
cp -r ${WORKSPACE_TARGET_DIR}/${TARGET_TRIPLE_WINDOWS}/${PROFILE_DIR}/${MAX_EXT_NAME}.mxe64 ${PACKAGE_DIR}/externals/
echo PACKAGE_DIR=${PACKAGE_DIR}
'''
# [tasks.copy-all-package-members]
# private = true
# condition = { files_exist = ["${PACKAGE_MEMBERS_DIR}/"] }
# script_runner = "@shell"
# script = '''
# mkdir -p ${PACKAGE_DIR}/
# rm -rf ${PACKAGE_DIR}/*
# cp -r ${PACKAGE_MEMBERS_DIR}/* "${PACKAGE_DIR}/"
# '''
[tasks.install.windows]
clear = true
dependencies = ["package"]
script_runner = "powershell"
script_extension = "ps1"
script = '''
if((Test-Path $env:EXTERNAL_INSTALL_DIR) -eq 0)
{
New-Item $env:EXTERNAL_INSTALL_DIR -ItemType Directory
}
Copy-Item $env:PROFILE_EXTERNAL_PATH -Destination $env:EXTERNAL_INSTALL_DIR
'''
[tasks.install.mac]
clear = true
dependencies = ["package", "extend-package-members", "install-package-members"]
script_runner = "@shell"
script = '''
mkdir -p "${EXTERNAL_INSTALL_DIR}"
cp -r "${PROFILE_EXTERNAL_PATH}" "${EXTERNAL_INSTALL_DIR}"
'''
[tasks.install-universal.mac]
clear = true
dependencies = [
"build-mac-universal",
"sign-mac-universal", # Add signing step
"extend-package-members",
"install-package-members",
]
script_runner = "@shell"
script = '''
mkdir -p "${EXTERNAL_INSTALL_DIR}"
cp -r "${PROFILE_EXTERNAL_PATH}" "${EXTERNAL_INSTALL_DIR}"
'''
[tasks.install]
clear = true
run_task = [
{ name = "install.windows", condition = { platforms = [
"windows",
] } },
{ name = "install-universal.mac", condition = { platforms = [
"mac",
] } },
]
[tasks.install-package-members.mac]
condition = { files_exist = ["${PACKAGE_MEMBERS_DIR}/"] }
script_runner = "@shell"
script = '''
mkdir -p "${PACKAGE_MEMBERS_INSTALL_DIR}"
rm -rf "${PACKAGE_MEMBERS_INSTALL_DIR}"/*
cp -r ${PACKAGE_MEMBERS_DIR}/* "${PACKAGE_MEMBERS_INSTALL_DIR}"
'''
[tasks.extend-package-members]
script_runner = "@shell"
script = '''
cp "${CARGO_MAKE_WORKING_DIRECTORY}/README.md" "${PACKAGE_MEMBERS_DIR}/readme.md"
cp "${CARGO_MAKE_WORKING_DIRECTORY}/LICENSE" "${PACKAGE_MEMBERS_DIR}/license.md"
'''