-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
572 lines (485 loc) · 22.2 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
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
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
# Make all for this file should build every artifact in Cosmos, from the various
# rust binaries to the js packages to the websites(s) and windows and android installers.
#
# Finished artifacts will be in dist.
#
# Prerequisites for using this makefile locally:
#
# - nvm should be installed. https://github.com/nvm-sh/nvm#install--update-script
# - docker needs to be installed and configured
# - able to access dockerhub
# - the various docker images used for the build should be up to date
#
# You can use make prepare to update the docker images and install required tools.
#
# Useful make targets (<arch> should be replaced by one of the values in the `architectures`
# variable):
# Prepare your environment:
# prepare
#
# Validate code (unit tests):
# validate
# validate-{actyx-win-installer,js,js-sdk,wix,os,os-android,website,website-developer,website-downloads}
#
# Generate artifacts (stored in dist/):
# all (default target)
# all-{windows,android,macos,linux,js}
# linux-<arch>
#
# Build Actyx Docker images
# docker-<arch>
# docker-all
# docker-multiarch
# docker-current
#
# Useful environment variable overrides:
# CARGO_TEST_JOBS (default 8) will set the number of threads that cargo will use for testing
# CARGO_BUILD_JOBS (default 8) will set the number of threads that cargo will use for compiling
# BUILD_RUST_TOOLCHAIN set to test building with a different toolchain than the default
# LOCAL_IMAGE_VERSION set to change the Git commit to be used for the musl and buildrs images
SHELL := /bin/bash
MIN_MAKE_VERSION := 4.2
# This checks the make version and aborts with an error if it's not at least MIN_MAKE_VERSION
ok := $(filter $(MIN_MAKE_VERSION),$(firstword $(sort $(MAKE_VERSION) $(MIN_MAKE_VERSION))))
ifndef ok
$(error Please upgrade to GNU Make $(MIN_MAKE_VERSION) you are on: $(MAKE_VERSION))
endif
#############################
##### Configuration variables
#############################
architectures = aarch64 x86_64 armv7
unix-bins = ax
windows-bins = ax.exe actyx-x64.msi
android-bins = actyx.apk
CARGO_TEST_JOBS ?= 8
CARGO_BUILD_JOBS ?= 8
# Previously used for migrations, kept as placeholder for future use
CARGO_BUILD_ARGS ?=
export BUILD_RUST_TOOLCHAIN ?= 1.72.1
# The stable image version is the git commit hash inside `Actyx/Actyx`, with
# which the respective images was built. Whenever the build images (inside
# docker/{buildrs,musl}/Dockerfile) are modified (meaning built and
# pushed), this needs to be changed.
export LATEST_STABLE_IMAGE_VERSION := 3bfa52039d5cd166e8cd9509d447fea251ab82d1
# Mapping from os-arch to target
target-linux-aarch64 = aarch64-unknown-linux-musl
target-linux-x86_64 = x86_64-unknown-linux-musl
target-linux-armv7 = armv7-unknown-linux-musleabihf
target-windows-x86_64 = x86_64-pc-windows-gnu
target-macos-x86_64 = x86_64-apple-darwin
target-macos-aarch64 = aarch64-apple-darwin
# non-musl targets
target-nonmusl-linux-aarch64 = aarch64-unknown-linux-gnu
target-nonmusl-linux-x86_64 = x86_64-unknown-linux-gnu
target-nonmusl-linux-armv7 = armv7-unknown-linux-gnueabihf
target-nonmusl-windows-x86_64 = x86_64-pc-windows-gnu
# Mapping from arch to Docker buildx platform
docker-platform-x86_64 = linux/amd64
docker-platform-aarch64 = linux/arm64/v8
docker-platform-armv7 = linux/arm/v7
# Mapping from os to builder image name
image-linux = actyx/util:musl-$(TARGET)-$(IMAGE_VERSION)
image-windows = actyx/util:buildrs-x64-$(IMAGE_VERSION)
# This image is for the self-hosted runners
image-darwin = ghcr.io/actyx/osxbuilder:445876eadcf144b88ec4893636a80fb5e12301be
# list all os-arch and binary names
osArch = $(foreach a,$(architectures),linux-$(a)) windows-x86_64 macos-x86_64 macos-aarch64
binaries = ax ax.exe
# targets for which we need a .so file for android
android_so_targets = x86_64-linux-android i686-linux-android aarch64-linux-android armv7-linux-androideabi
CARGO := RUST_BACKTRACE=1 cargo +$(BUILD_RUST_TOOLCHAIN)
#################################
##### END Configuration variables
#################################
export GIT_COMMIT := $(shell git rev-parse HEAD)$(shell [ `git status --porcelain | wc -l` -gt 0 ] && echo _dirty)
export ACTYX_VERSION_NODEMANAGER ?= $(or $(shell git log --format=%H | while read hash; do grep node-manager-.*$$hash versions && exit; done | (IFS="- " read n1 n2 v r; echo $$v)), 0.0.0)_dev-$(GIT_COMMIT)
# This leaks a lot of information, we can either remove it or extend it
# to only run when GITHUB_CI (or whatever it's called/similar) is NOT present
# $(shell env GIT_COMMIT=$(GIT_COMMIT) | sort >&2)
ifeq ($(origin ACTYX_VERSION), undefined)
AXV :=
AXV_DOCKER :=
export ACTYX_VERSION_MSI := $(or $(shell git log --format=%H | while read hash; do grep actyx-.*$$hash versions && exit; done | (IFS="- " read n1 v r; echo $$v)), 0.0.0)_dev-$(GIT_COMMIT)
else
AXV := -e "ACTYX_VERSION=$(ACTYX_VERSION)"
AXV_DOCKER := --build-arg "ACTYX_VERSION=$(ACTYX_VERSION)"
export ACTYX_VERSION_MSI := $(ACTYX_VERSION)
endif
ifeq ($(origin ACTYX_VERSION_CLI), undefined)
AXVC :=
AXVC_DOCKER :=
else
AXVC := -e "ACTYX_VERSION_CLI=$(ACTYX_VERSION_CLI)"
AXVC_DOCKER := --build-arg "ACTYX_VERSION_CLI=$(ACTYX_VERSION_CLI)"
endif
ifeq ($(origin ACTYX_PUBLIC_KEY), undefined)
AXP :=
AXP_DOCKER :=
else
AXP := -e AX_PUBLIC_KEY=$(ACTYX_PUBLIC_KEY)
AXP_DOCKER := --build-arg AX_PUBLIC_KEY=$(ACTYX_PUBLIC_KEY)
export AX_PUBLIC_KEY = $(ACTYX_PUBLIC_KEY)
endif
all-WINDOWS := $(foreach t,$(windows-bins),windows-x86_64/$t)
all-ANDROID := $(android-bins)
all-MACOS := $(foreach t,$(unix-bins),macos-x86_64/$t macos-aarch64/$t)
docker-platforms = $(foreach arch,$(architectures),$(docker-platform-$(arch)))
docker-build-args = ${AXP_DOCKER} ${AXV_DOCKER} --build-arg GIT_COMMIT=$(GIT_COMMIT) --build-arg CARGO_BUILD_ARGS="$(CARGO_BUILD_ARGS)"
docker-multiarch-build-args = $(docker-build-args) --platform $(shell echo $(docker-platforms) | sed 's/ /,/g')
export CARGO_HOME ?= $(HOME)/.cargo
# Use docker run -ti only if the input device is a TTY (so that Ctrl+C works)
export DOCKER_FLAGS ?= ${AXP} ${AXV} ${AXVC} $(shell if test -t 0; then echo "-ti"; else echo ""; fi)
# Helper to try out local builds of Docker images
export IMAGE_VERSION := $(or $(LOCAL_IMAGE_VERSION),$(LATEST_STABLE_IMAGE_VERSION))
# this needs to remain the first so it is the default target
# THIS TARGET IS NOT RUN FOR ARTIFACTS — see azure-piplines
all: all-linux all-android all-windows all-macos all-js assert-clean
all-android: $(patsubst %,dist/bin/%,$(all-ANDROID))
all-windows: $(patsubst %,dist/bin/%,$(all-WINDOWS))
all-macos: $(patsubst %,dist/bin/%,$(all-MACOS))
all-linux: $(foreach arch,$(architectures),linux-$(arch))
define mkLinuxRule =
linux-$(1): $(foreach bin,$(unix-bins),dist/bin/linux-$(1)/$(bin))
endef
$(foreach arch,$(architectures),$(eval $(call mkLinuxRule,$(arch))))
current: dist/bin/current/ax
all-js: dist/js/sdk
# Create a `make-always` target that always has the current timestamp.
# Depending on this ensures that the rule is always executed.
.PHONY: make-always
make-always:
touch $@
# Debug helpers
print-%:
@echo $* = $($*)
.PHONY: assert-clean
assert-clean:
@if [ `git status --porcelain | wc -l` -gt 0 ]; then \
git status --porcelain; echo "Git directory not clean, exiting"; git diff; exit 3; \
else echo "Git directory is clean"; fi
# delete almost all generated artifacts
# this does not need to be run from CI, since it always starts with a fresh checkout anyway.
# use this locally to ensure a truly fresh build.
clean:
rm -rf rust/actyx/target/*
rm -rf web/downloads.actyx.com/node_modules
rm -rf web/developer.actyx.com/node_modules
rm -rf js/sdk/node_modules
rm -rf jvm/os-android/gradle/build
rm -rf dist
# mark things with this dependency to run whenever requested
.PHONY: prepare prepare-js prepare-rs prepare-docker prepare-docker-crosscompile
prepare: prepare-js prepare-rs prepare-docker prepare-docker-crosscompile
prepare-docker:
# used for windows and android rust builds
docker pull actyx/util:buildrs-x64-$(IMAGE_VERSION)
# used for linux rust builds
docker pull actyx/util:musl-aarch64-unknown-linux-musl-$(IMAGE_VERSION)
docker pull actyx/util:musl-x86_64-unknown-linux-musl-$(IMAGE_VERSION)
docker pull actyx/util:musl-armv7-unknown-linux-musleabihf-$(IMAGE_VERSION)
# used to build the node manager for windows on linux
docker pull actyx/util:node-manager-win-builder-$(IMAGE_VERSION)
prepare-docker-crosscompile:
for i in `docker buildx ls | awk '{print $$1}'`; do docker buildx rm $$i; done
docker buildx create --use
prepare-rs:
# install rustup
curl https://sh.rustup.rs -sSf | sh -s -- -y
rustup install $(BUILD_RUST_TOOLCHAIN)
prepare-js:
# install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.36.0/install.sh | bash
# execute linter, style checker and tests for everything
# THIS TARGET IS NOT RUN FOR PR VALIDATION — see azure-piplines
validate: validate-rust validate-os validate-netsim validate-release validate-os-android validate-js assert-clean
# declare all the validate targets to be phony
.PHONY: validate-os validate-os-android validate-js
.PHONY: diagnostics
diagnostics:
@echo HOME = $(HOME)
@echo USER = $(shell whoami)
@echo PATH = ${PATH}
@echo PWD = $(shell pwd)
.PHONY: validate-os
# execute fmt check, clippy and tests for rust/actyx
validate-os: diagnostics
cd rust/actyx && $(CARGO) fmt --all -- --check --config imports_granularity=Crate
cd rust/actyx && $(CARGO) --locked clippy --no-deps -j $(CARGO_BUILD_JOBS) -- -D warnings
cd rust/actyx && $(CARGO) --locked clippy --no-deps -j $(CARGO_BUILD_JOBS) --tests -- -D warnings
cd rust/actyx && $(CARGO) --locked test --all-features -j $(CARGO_TEST_JOBS)
.PHONY: validate-rust
# execute fmt check, clippy and tests for rust/actyx
validate-rust: diagnostics
cd rust/sdk && $(CARGO) fmt --all -- --check --config imports_granularity=Crate
cd rust/sdk && $(CARGO) --locked clippy --no-deps -j $(CARGO_BUILD_JOBS) -- -D warnings
cd rust/sdk && $(CARGO) --locked clippy --no-deps -j $(CARGO_BUILD_JOBS) --tests -- -D warnings
cd rust/sdk && $(CARGO) --locked test --all-features -j $(CARGO_TEST_JOBS)
.PHONY: validate-release
# execute fmt check, clippy and tests for rust/actyx
validate-release: diagnostics
cd rust/release && $(CARGO) fmt --all -- --check --config imports_granularity=Crate
cd rust/release && $(CARGO) --locked clippy --no-deps -j $(CARGO_BUILD_JOBS) -- -D warnings
cd rust/release && $(CARGO) --locked clippy --no-deps -j $(CARGO_BUILD_JOBS) --tests -- -D warnings
validate-netsim: diagnostics
cd rust/actyx && $(CARGO) build -p swarm-cli -p swarm-harness --release -j $(CARGO_BUILD_JOBS)
NETSIM_TEST_LOGFILE=gossip-8-fast rust/actyx/target/release/gossip --n-nodes 8 --enable-fast-path
NETSIM_TEST_LOGFILE=gossip-8-slow rust/actyx/target/release/gossip --n-nodes 8 --enable-slow-path
NETSIM_TEST_LOGFILE=gossip-8-root rust/actyx/target/release/gossip --n-nodes 8 --enable-root-map
NETSIM_TEST_LOGFILE=gossip_protocol-8 rust/actyx/target/release/gossip_protocol --n-nodes 8
NETSIM_TEST_LOGFILE=rootmap rust/actyx/target/release/root_map --n-nodes 8 --enable-root-map
NETSIM_TEST_LOGFILE=discovery rust/actyx/target/release/discovery --n-bootstrap 1 --enable-root-map
NETSIM_TEST_LOGFILE=discovery_multi_net rust/actyx/target/release/discovery_multi_net
NETSIM_TEST_LOGFILE=discovery_external rust/actyx/target/release/discovery_external
NETSIM_TEST_LOGFILE=subscribe rust/actyx/target/release/subscribe --n-nodes 8
NETSIM_TEST_LOGFILE=query rust/actyx/target/release/query --n-nodes 8
NETSIM_TEST_LOGFILE=quickcheck_subscribe rust/actyx/target/release/quickcheck_subscribe
NETSIM_TEST_LOGFILE=quickcheck_interleaved rust/actyx/target/release/quickcheck_interleaved
NETSIM_TEST_LOGFILE=quickcheck_stress_single_store rust/actyx/target/release/quickcheck_stress_single_store
NETSIM_TEST_LOGFILE=quickcheck_ephemeral rust/actyx/target/release/quickcheck_ephemeral
NETSIM_TEST_LOGFILE=versions rust/actyx/target/release/versions
# https://github.com/Actyx/Actyx/issues/160
# rust/actyx/target/release/health
NETSIM_TEST_LOGFILE=read_only rust/actyx/target/release/read_only
.PHONY: validate-os-android
# execute linter for os-android
validate-os-android: diagnostics
docker run \
-u builder \
-v `pwd`:/src \
-w /src/jvm/os-android \
--rm \
$(DOCKER_FLAGS) \
actyx/util:buildrs-x64-$(IMAGE_VERSION) \
./gradlew clean ktlintCheck
# validate all js
validate-js: diagnostics validate-js-sdk
# validate js sdk
validate-js-sdk:
cd js/sdk && source ~/.nvm/nvm.sh --no-use && nvm install && \
npm ci && \
npm run test && \
npm run build:prod
# fix and test all js projects
fix-js: diagnostics fix-js-sdk
fix-js-sdk:
cd js/sdk && source ~/.nvm/nvm.sh --no-use && nvm install && \
npm install && \
npm run lint:fix && \
npm run test && \
npm run build && \
npm run api:accept
# make js sdk
# this is running directly on the host container, so it needs to have nvm installed
dist/js/sdk: make-always
mkdir -p $@
cd js/sdk && source ~/.nvm/nvm.sh --no-use && nvm install && \
npm ci && \
npm run build:prod && \
mv `npm pack` ../../$@/
validate-node-manager-bindings:
cd rust/actyx/node-manager-bindings && \
source ~/.nvm/nvm.sh --no-use && nvm install && \
npm ci && \
npm run build
node-manager-win:
docker run \
-e BUILD_RUST_TOOLCHAIN=$(BUILD_RUST_TOOLCHAIN) \
-v `pwd`:/src \
-w /src/js/node-manager \
--rm \
actyx/util:node-manager-win-builder-$(IMAGE_VERSION) \
bash -c "source /home/builder/.nvm/nvm.sh --no-use && nvm install && npm ci && npm version $(ACTYX_VERSION_NODEMANAGER) && npm run build && npm run dist -- --win --x64 && npm run artifacts"
node-manager-mac-linux:
cd js/node-manager && \
source ~/.nvm/nvm.sh --no-use && nvm install && \
npm ci && \
npm version $(ACTYX_VERSION_NODEMANAGER) && \
npm run build && \
npm run dist && \
npm run artifacts
# combines all the .so files to build actyxos on android
android-libaxosnodeffi: \
jvm/os-android/app/src/main/jniLibs/x86/libaxosnodeffi.so \
jvm/os-android/app/src/main/jniLibs/x86_64/libaxosnodeffi.so \
jvm/os-android/app/src/main/jniLibs/arm64-v8a/libaxosnodeffi.so \
jvm/os-android/app/src/main/jniLibs/armeabi-v7a/libaxosnodeffi.so
jvm/os-android/app/src/main/jniLibs/x86/libaxosnodeffi.so: rust/actyx/target/i686-linux-android/release/libaxosnodeffi.so
mkdir -p $(dir $@)
cp $< $@
jvm/os-android/app/src/main/jniLibs/x86_64/libaxosnodeffi.so: rust/actyx/target/x86_64-linux-android/release/libaxosnodeffi.so
mkdir -p $(dir $@)
cp $< $@
jvm/os-android/app/src/main/jniLibs/arm64-v8a/libaxosnodeffi.so: rust/actyx/target/aarch64-linux-android/release/libaxosnodeffi.so
mkdir -p $(dir $@)
cp $< $@
jvm/os-android/app/src/main/jniLibs/armeabi-v7a/libaxosnodeffi.so: rust/actyx/target/armv7-linux-androideabi/release/libaxosnodeffi.so
mkdir -p $(dir $@)
cp $< $@
# compute list of all OSs (e.g. linux, windows) and rust targets (looking into the target-* vars)
os = $(sort $(foreach oa,$(osArch),$(word 1,$(subst -, ,$(oa)))))
targets = $(sort $(foreach oa,$(osArch),$(target-$(oa))))
targets-nonmusl = $(sort $(foreach oa,$(osArch),$(target-nonmusl-$(oa))))
# build rules for binaries on the current platform (i.e. no cross-building), like ax.exe
# two-step process:
# - declare dependency from dist/bin/* to the right file in rust/actyx/target/...
# - declare how to build the file in rust/actyx/target/...
dist/bin/current/%: rust/actyx/target/release/%
mkdir -p $(dir $@)
rm -f $@
mv $< $@
# here % (and thus $*) matches something like ax.exe, so we need to strip the suffix with `basename`
rust/actyx/target/release/%: make-always
cd rust/actyx && $(CARGO) --locked build --release -j $(CARGO_BUILD_JOBS) --bin $(basename $*)
# In the following the same two-step process is used as for the current os/arch above.
# The difference is that %-patterns won’t works since there are two variables to fill:
# the os-arch string and the binary name. Therefore, we generate all rules by multiplying
# the list of os-arch strings with the possible binaries and using `eval` to synthesize
# one rule for each such combination.
# mkDistRule is the template that is then instantiated by the nested `foreach` below,
# where $(1) and $(2) will be replaced by the loop values for os-arch and binary name, respectively.
define mkDistRule =
dist/bin/$(1)/$(2): rust/actyx/target/$(target-$(1))/release/$(2)
mkdir -p $$(dir $$@)
rm -f $$@
mv $$< $$@
endef
$(foreach oa,$(osArch),$(foreach bin,$(binaries),$(eval $(call mkDistRule,$(oa),$(bin)))))
$(foreach a,$(architectures),$(foreach bin,docker-logging-plugin,$(eval $(call mkDistRule,linux-$(a),$(bin)))))
# Make a list of pattern rules (with %) for all possible rust binaries
# containing e.g. rust/actyx/target/aarch64-unknown-linux-musl/release/%.
# These will be used below to define how to build all binaries for that target.
targetPatterns = $(foreach t,$(targets),rust/actyx/target/$(t)/release/%)
# define a pattern rule for making any binary for a given target
# where the build image is computed by first extracting the OS from the target string and then
# looking into the image-* mapping - this requires the TARGET variable to be set while evaluating!
define mkBinaryRule =
rust/actyx/target/$(TARGET)/release/%: cargo-init make-always
docker run \
-u builder \
-w /src/rust/actyx \
-e HOME=/home/builder \
-e GITHUB_SHA=$(GITHUB_SHA) \
-v `pwd`:/src \
--rm \
$(DOCKER_FLAGS) \
$(image-$(word 3,$(subst -, ,$(TARGET)))) \
cargo +$(BUILD_RUST_TOOLCHAIN) --locked build --release -j $(CARGO_BUILD_JOBS) $(CARGO_BUILD_ARGS) --bin $$(basename $$*) --target $(TARGET)
endef
$(foreach TARGET,$(targets),$(eval $(mkBinaryRule)))
# make a list of pattern rules (with %) for all possible .so files needed for android
soTargetPatterns = $(foreach t,$(android_so_targets),rust/actyx/target/$(t)/release/libaxosnodeffi.so)
# same principle as above for targetPatterns
# Generate the libaxosnodeffi.so for all android targets
$(soTargetPatterns): TARGET = $(word 4,$(subst /, ,$@))
$(soTargetPatterns): cargo-init make-always
docker run \
-u builder \
-w /src/rust/actyx \
-e HOME=/home/builder \
-v `pwd`:/src \
--rm \
$(DOCKER_FLAGS) \
actyx/util:buildrs-x64-$(IMAGE_VERSION) \
cargo +$(BUILD_RUST_TOOLCHAIN) --locked build -p node-ffi --lib --release -j $(CARGO_BUILD_JOBS) $(CARGO_BUILD_ARGS) --target $(TARGET)
# create this with permissions for everyone so that `builder` inside docker can use it
# but only really share the `git` and `registry` folders within this!
# (otherwise Docker will create them as root since they are used as volumes)
# (formulating as rule dependencies only runs mkdir when they are missing)
cargo-init: $(CARGO_HOME)/for_builder/git $(CARGO_HOME)/for_builder/registry
$(CARGO_HOME)/%:
mkdir -p $@
chmod 777 $@
# Generate the Android App Bundle
jvm/os-android/app/build/outputs/bundle/release/app-release.aab: android-libaxosnodeffi make-always
jvm/os-android/bin/get-keystore.sh
docker run \
-u builder \
-v `pwd`:/src \
-w /src/jvm/os-android \
--rm \
$(DOCKER_FLAGS) \
actyx/util:buildrs-x64-$(IMAGE_VERSION) \
./gradlew --stacktrace ktlintCheck build bundleRelease
# Generate the actual APK
dist/bin/actyx.apk: jvm/os-android/app/build/outputs/bundle/release/app-release.aab make-always
jvm/os-android/bin/get-keystore.sh
rm -f dist/bin/actyx.apks
docker run \
-u builder \
-v `pwd`:/src \
-w /src/jvm/os-android \
--rm \
$(DOCKER_FLAGS) \
actyx/util:buildrs-x64-$(IMAGE_VERSION) \
java -jar /usr/local/lib/bundletool.jar build-apks \
--bundle /src/$< \
--output=/src/dist/bin/actyx.apks \
--mode=universal \
--ks=/src/jvm/os-android/actyx-local/axosandroid.jks \
--ks-key-alias=axosandroid \
--ks-pass=pass:$(shell grep actyxKeyPassword jvm/os-android/actyx-local/actyx.properties|cut -f2 -d\")
unzip -o dist/bin/actyx.apks universal.apk
mv -f universal.apk dist/bin/actyx.apk
# Windows MSI build recipe. Requires Docker to work
dist/bin/windows-x86_64/actyx-x64.msi: dist/bin/windows-x86_64/ax.exe make-always
docker run \
-v `pwd`:/src \
-e WIN_CODESIGN_CERTIFICATE \
-e WIN_CODESIGN_PASSWORD \
--rm \
actyx/util:actyx-win-installer-builder \
bash /src/wix/actyx-installer/build.sh ${ACTYX_VERSION_MSI} "/src/dist/bin/windows-x86_64"
define mkDockerRule =
docker-$(1):
docker buildx build \
--platform $(docker-platform-$(1)) \
$(docker-build-args) \
-f docker/actyx/Dockerfile \
--tag actyx/actyx-ci:actyx-$(1)-$(GIT_COMMIT) \
--load \
.
endef
$(foreach arch,$(architectures),$(eval $(call mkDockerRule,$(arch))))
docker-all: $(foreach arch,$(architectures),docker-$(arch))
# this will build the actyx docker image for all supported architectures. the
# resulting images won't be loaded into the local docker daemon, because that
# is not supported yet by docker, but will just remain in the build cache. One
# can either load a single one of them providing the appropriate `--platform`
# and `--load`, or `--push` them to a remote registry (or use the appropriate
# `make docker-build-actyx-<arch>` target)
docker-multiarch:
docker buildx build \
$(docker-multiarch-build-args) \
-f docker/actyx/Dockerfile \
.
# build for local architecture and load into docker daemon
docker-current:
docker buildx build --load $(docker-build-args) -f docker/actyx/Dockerfile .
# This is here to ensure that we use the same build-args here and in artifacts.yml
docker-multiarch-build-args:
@echo $(docker-multiarch-build-args)
docker-push-actyx:
docker buildx build \
$(docker-multiarch-build-args) \
--push \
--tag actyx/actyx-ci:actyx-$(GIT_COMMIT) $(ADDITIONAL_DOCKER_ARGS) \
-f docker/actyx/Dockerfile \
.
# Previous docker recipes are a bit too complex due to the use of loops etc,
# the following recipe aims to be dead simple, with the following goal:
# Build and push the images with build_and_push.sh scripts
.PHONY: docker-build-and-push
docker-build-and-push: assert-clean
git rev-parse HEAD
cd docker/buildrs && bash ./build_and_push.sh
cd docker/musl && bash ./build_and_push.sh
cd docker/node-manager-win-builder && bash ./build_and_push.sh
# Cargo will complain but formatting will still be done accordingly.
.PHONY: fmt
fmt:
cd rust/actyx && cargo fmt -- --config imports_granularity=Crate
cd rust/sdk && cargo fmt -- --config imports_granularity=Crate
cd rust/release && cargo fmt -- --config imports_granularity=Crate
.PHONY: validate-release-version
validate-release-version:
cd rust/release && $(CARGO) run -- check