-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathMakefile
1077 lines (914 loc) · 43.8 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
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
.DEFAULT_GOAL := help
# Some basic helpers
define n
endef
# Directory containing this Makefile
PROJECT_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
# Formatting
RED := $(shell tput setaf 1)
YELLOW := $(shell tput setaf 3)
GREEN := $(shell tput setaf 2)
NC := $(shell tput sgr0)
# Build system types
LINUX_BUILD_PLATFORM := linux
MAC_BUILD_PLATFORM := darwin
X64_64_ARCH := x86_64
AARCH64_ARCH := aarch64
ARM_ARCH := arm64
BUILD_PLATFORM := $(shell uname -s | tr '[:upper:]' '[:lower:]')
ifeq ($(filter $(BUILD_PLATFORM),$(LINUX_BUILD_PLATFORM) $(MAC_BUILD_PLATFORM)),)
$(error $n $(RED)ERROR$(NC): Your platform ($(GREEN)$(BUILD_PLATFORM)$(NC)) is unrecognized, cannot continue)
endif
BUILD_PLATFORM_ARCH := $(shell uname -m)
ifeq ($(filter $(BUILD_PLATFORM_ARCH),$(X64_64_ARCH) $(AARCH64_ARCH) $(ARM_ARCH)),)
$(error $n $(RED)ERROR$(NC): Your platform architecture ($(GREEN)$(BUILD_PLATFORM_ARCH)$(NC)) is not supported, cannot continue)
endif
# Glocal options
export CC := clang
export CXX := clang++
# Build variable(s)
BUILD := build
# Directories for external dependencies and their builds
DEPS_DIR := deps
DEPS_MODULES_DIR := $(DEPS_DIR)/modules
DEPS_BUILD_DIR := $(DEPS_DIR)/build
DEPS_ARTIFACTS_DIR := $(DEPS_DIR)/artifacts
# Android
ANDROID := android
ANDROID_BUILD_PLATFORM := $(BUILD_PLATFORM)-x86_64
ANDROID_NDK_HOME ?= /opt/homebrew/share/android-ndk
ANDROID_API_VERSION ?= 24
# Android Tool chain
AR := $(ANDROID_NDK_HOME)/toolchains/llvm/prebuilt/$(ANDROID_BUILD_PLATFORM)/bin/llvm-ar
AS := $(ANDROID_NDK_HOME)/toolchains/llvm/prebuilt/$(ANDROID_BUILD_PLATFORM)/bin/llvm-as
RANLIB := $(ANDROID_NDK_HOME)/toolchains/llvm/prebuilt/$(ANDROID_BUILD_PLATFORM)/bin/llvm-ranlib
LD := $(ANDROID_NDK_HOME)/toolchains/llvm/prebuilt/$(ANDROID_BUILD_PLATFORM)/bin/ld
STRIP := $(ANDROID_NDK_HOME)/toolchains/llvm/prebuilt/$(ANDROID_BUILD_PLATFORM)/bin/llvm-strip
# Apple
APPLE := apple
DARWIN := darwin
APPLE_BUILD := $(BUILD)/$(APPLE)
APPLE_IOS := ios
APPLE_IOS_PLATFORM := iPhoneOS
APPLE_IOS_SDK ?= iPhoneOS
APPLE_MACOS_VERSION_MIN ?= 11.0
APPLE_IOS_VERSION_MIN ?= 13.0
APPLE_XCODE_APP_NAME ?= Xcode.app
APPLE_IOS_SIMULATOR := ios-simulator
APPLE_IOS_SIMULATOR_PLATFORM := iPhoneSimulator
APPLE_IOS_SIMULATOR_SDK ?= iPhoneSimulator
APPLE_MACOSX := macosx
APPLE_MACOSX_PLATFORM := MacOSX
APPLE_MACOSX_SDK ?= MacOSX
APPLE_IOS_FRAMEWORK_TYPE := $(APPLE_IOS)
APPLE_IOS_SIMULATOR_FRAMEWORK_TYPE := $(APPLE_IOS_SIMULATOR)
APPLE_MACOSX_FRAMEWORK_TYPE := $(APPLE_MACOSX)
APPLE_FRAMEWORK_TYPES := $(APPLE_IOS_FRAMEWORK_TYPE) $(APPLE_IOS_SIMULATOR_FRAMEWORK_TYPE) $(APPLE_MACOSX_FRAMEWORK_TYPE)
# Apple tools
LIPO := lipo
PLISTBUDDY_EXEC := /usr/libexec/PlistBuddy
INSTALL_NAME_TOOL := install_name_tool
XCODEBUILD := xcodebuild
# Wasm
WASM := wasm
WASM_BUILD := $(BUILD)/$(WASM)
EMSDK := emsdk
EMSDK_DIR := $(PROJECT_DIR)/$(DEPS_MODULES_DIR)/$(EMSDK)
EMSDK_VERSION := 3.1.73
EMSDK_ENV := emsdk_env.sh
UNIFFI_BINDGEN_CPP := uniffi-bindgen-cpp
UNIFFI_BINDGEN_CPP_VERSION := v0.6.3+v0.25.0
WASM_MODULE := DotLottiePlayer
# Native
NATIVE := native
# External dependencies
THORVG := thorvg
LIBJPEG_TURBO := libjpeg-turbo
LIBPNG := libpng
ZLIB := zlib
WEBP := libwebp
# External dependency artifacts
MESON_CROSS_FILE := cross.txt
MESON_BUILD_FILE := meson.build
NINJA_BUILD_FILE := build.ninja
THORVG_LIB := libthorvg.a
CMAKE_TOOLCHAIN_FILE := toolchain.cmake
CMAKE_MAKEFILE := Makefile
CMAKE_CACHE := CMakeCache.txt
LIBPNG_LIB := libpng.a
LIBJPEG_TURBO_LIB := libturbojpeg.a
ZLIB_LIB := libz.a
WEBP_LIB := libwebp.a
# Release artifacts will be placed in this directory
RELEASE := release
# Build artifact types
CORE := dotlottie-rs
RUNTIME_FFI := dotlottie-ffi
DOTLOTTIE_PLAYER := dotlottie-player
# Build artifacts
RUNTIME_FFI_UNIFFI_BINDINGS := uniffi-bindings
RUNTIME_FFI_HEADER := dotlottie_player.h
RUNTIME_FFI_LIB_BASE := libdotlottie_player
RUNTIME_FFI_STATIC_LIB := $(RUNTIME_FFI_LIB_BASE).a
RUNTIME_FFI_LIB := $(RUNTIME_FFI_LIB_BASE).so
RUNTIME_FFI_DYLIB := $(RUNTIME_FFI_LIB_BASE).dylib
DOTLOTTIE_PLAYER_HEADER := dotlottie_player.h
DOTLOTTIE_PLAYER_SWIFT := dotlottie_player.swift
DOTLOTTIE_PLAYER_MODULE := DotLottiePlayer
DOTLOTTIE_PLAYER_FRAMEWORK := $(DOTLOTTIE_PLAYER_MODULE).framework
DOTLOTTIE_PLAYER_XCFRAMEWORK := $(DOTLOTTIE_PLAYER_MODULE).xcframework
FRAMEWORK_HEADERS := Headers
FRAMEWORK_MODULES := Modules
MODULE_MAP := module.modulemap
INFO_PLIST := Info.plist
KOTLIN := kotlin
SWIFT := swift
CPLUSPLUS := cpp
RUNTIME_FFI_ANDROID_ASSETS := assets
DOTLOTTIE_PLAYER_ANDROID_RELEASE_DIR := $(RELEASE)/$(ANDROID)/$(DOTLOTTIE_PLAYER)
DOTLOTTIE_PLAYER_ANDROID_SRC_DIR := $(DOTLOTTIE_PLAYER_ANDROID_RELEASE_DIR)/src/main/$(KOTLIN)
DOTLOTTIE_PLAYER_LIB := libuniffi_dotlottie_player.so
DOTLOTTIE_PLAYER_GRADLE_PROPERTIES := gradle.properties
DOTLOTTIE_PLAYER_NATIVE_RELEASE_DIR := $(RELEASE)/$(NATIVE)/$(DOTLOTTIE_PLAYER)
DOTLOTTIE_PLAYER_NATIVE_RELEASE_INCLUDE_DIR := $(DOTLOTTIE_PLAYER_NATIVE_RELEASE_DIR)/include
DOTLOTTIE_PLAYER_NATIVE_RELEASE_LIB_DIR := $(DOTLOTTIE_PLAYER_NATIVE_RELEASE_DIR)/lib
# Dependency build directories for the current machine architecture
LOCAL_ARCH := local-arch
LOCAL_ARCH_BUILD_DIR := $(DEPS_BUILD_DIR)/$(LOCAL_ARCH)
LOCAL_ARCH_ARTIFACTS_DIR := $(DEPS_ARTIFACTS_DIR)/$(LOCAL_ARCH)/usr
LOCAL_ARCH_INCLUDE_DIR := $(LOCAL_ARCH_ARTIFACTS_DIR)/include
LOCAL_ARCH_LIB_DIR := $(LOCAL_ARCH_ARTIFACTS_DIR)/lib
LOCAL_ARCH_LIB64_DIR := $(LOCAL_ARCH_ARTIFACTS_DIR)/lib64
THORVG_LOCAL_ARCH_BUILD_DIR := $(LOCAL_ARCH_BUILD_DIR)/$(THORVG)/build
LIBJPEG_TURBO_LOCAL_ARCH_BUILD_DIR := $(LOCAL_ARCH_BUILD_DIR)/$(LIBJPEG_TURBO)/build
LIBPNG_LOCAL_ARCH_BUILD_DIR := $(LOCAL_ARCH_BUILD_DIR)/$(LIBPNG)/build
ZLIB_LOCAL_ARCH_BUILD_DIR := $(LOCAL_ARCH_BUILD_DIR)/$(ZLIB)/build
WEBP_LOCAL_ARCH_BUILD_DIR := $(LOCAL_ARCH_BUILD_DIR)/$(WEBP)/build
# Other build flags for dependencies
ZLIB_LDFLAGS := -Wl,--undefined-version
# Sources
CORE_SRC := $(shell find $(CORE)/src -name "*.rs")
RUNTIME_FFI_SRC := $(shell find $(RUNTIME_FFI)/src -name "*.rs") $(shell find $(RUNTIME_FFI)/src -name "*.udl")
# Helper functions
define ANDROID_CROSS_FILE
[binaries]
cpp = '$(CPP)'
ar = '$(AR)'
as = '$(AS)'
ranlib = '$(RANLIB)'
ld = '$(LD)'
strip = '$(STRIP)'
pkg-config = 'pkg-config'
[host_machine]
system = '$(ANDROID)'
cpu_family = '$(CPU_FAMILY)'
cpu = '$(CPU)'
endian = 'little'
endef
define APPLE_CROSS_FILE
[binaries]
cpp = ['clang++', '-arch', '$(ARCH)', '-isysroot', '/Applications/$(APPLE_XCODE_APP_NAME)/Contents/Developer/Platforms/$(PLATFORM).platform/Developer/SDKs/$(SDK).sdk']
ld = 'ld'
ar = 'ar'
strip = 'strip'
pkg-config = 'pkg-config'
[properties]
root = '/Applications/$(APPLE_XCODE_APP_NAME)/Contents/Developer/Platforms/$(SDK).platform/Developer'
has_function_printf = true
$(if $(filter $(PLATFORM),$(APPLE_IOS_PLATFORM) $(APPLE_IOS_SIMULATOR_PLATFORM)),\
[built-in options]\n\
cpp_args = ['-miphoneos-version-min=$(APPLE_IOS_VERSION_MIN)']\n\
cpp_link_args = ['-miphoneos-version-min=$(APPLE_IOS_VERSION_MIN)']\n\
,)
$(if $(filter $(PLATFORM),$(APPLE_MACOSX_PLATFORM)),\
[built-in options]\n\
cpp_args = ['-mmacosx-version-min=$(APPLE_MACOS_VERSION_MIN)']\n\
cpp_link_args = ['-mmacosx-version-min=$(APPLE_MACOS_VERSION_MIN)']\n\
,)
[host_machine]
system = 'darwin'
subsystem = '$(SUBSYSTEM)'
kernel = 'xnu'
cpu_family = '$(CPU_FAMILY)'
cpu = '$(CPU)'
endian = 'little'
endef
define WASM_CROSS_FILE
[binaries]
cpp = ['$(EMSDK_DIR)/upstream/emscripten/em++.py', '-std=c++20']
ar = '$(EMSDK_DIR)/upstream/emscripten/emar.py'
strip = '-strip'
[properties]
root = '$(EMSDK_DIR)/upstream/emscripten/system'
shared_lib_suffix = 'js'
static_lib_suffix = 'js'
shared_module_suffix = 'js'
exe_suffix = 'js'
[built-in options]
cpp_args = ['-Wshift-negative-value', '-flto', '-Oz', '-ffunction-sections', '-fdata-sections']
cpp_link_args = [
'-sMALLOC=emmalloc',
'-Wl,-u,htons',
'-Wl,-u,ntohs',
'-Wl,-u,htonl',
'-Wshift-negative-value',
'-flto', '-Oz', '--bind', '-sWASM=1',
'-sALLOW_MEMORY_GROWTH=1',
'-sFORCE_FILESYSTEM=0',
'-sMODULARIZE=1',
'-sEXPORT_NAME=create$(WASM_MODULE)Module',
'-sEXPORT_ES6=1',
'-sUSE_ES6_IMPORT_META=0',
'-sENVIRONMENT=web',
'-sFILESYSTEM=0',
'-sDYNAMIC_EXECUTION=0',
'--no-entry',
'--strip-all',
'--emit-tsd=${WASM_MODULE}.d.ts',
'--closure=1']
[host_machine]
system = '$(SYSTEM)'
cpu_family = '$(CPU_FAMILY)'
cpu = '$(CPU)'
endian = 'little'
endef
# Helper functions
define ANDROID_CMAKE_TOOLCHAIN_FILE
set(CMAKE_SYSTEM_NAME Android)
set(CMAKE_SYSTEM_VERSION $(ANDROID_API_VERSION))
set(CMAKE_ANDROID_ARCH_ABI $(ANDROID_ABI))
set(CMAKE_ANDROID_NDK $(ANDROID_NDK_HOME))
endef
define APPLE_MODULE_MAP_FILE
framework module $(MODULE_NAME) {
umbrella header "$(UMBRELLA_HEADER)"
export *
module * { export * }
}
endef
define WASM_MESON_BUILD_FILE
project('$(WASM_MODULE)', 'cpp')
cc = meson.get_compiler('cpp')
if cc.get_id() == 'emscripten'
executable('$(WASM_MODULE)',
[$(shell find $(FFI_BINDINGS_DIR) -name "*.cpp" -exec printf "'%s'," {} \; 2>/dev/null)],
include_directories: '$(FFI_BINDINGS_DIR)',
link_args: ['-L$(DEPS_LIB_DIR)', '-L$(FFI_BUILD_DIR)', '-lthorvg', '-ldotlottie_player'],
)
else
message('The compiler is not Emscripten.')
endif
endef
define CREATE_OUTPUT_FILE
mkdir -p $$(dirname $@)
echo "$$OUTPUT_FILE" > $@
endef
define SETUP_MESON
meson setup \
--prefix=/ \
--backend=ninja \
-Dloaders="lottie, png, jpg, webp" \
-Ddefault_library=static \
-Dengines=sw \
-Dbindings=capi \
-Dlog=false \
-Dthreads=false \
-Dstatic=$(STATIC) \
-Dextra=$(EXTRA) \
-Dfile=$(FILE) \
$(CROSS_FILE) "$(THORVG_DEP_SOURCE_DIR)" "$(THORVG_DEP_BUILD_DIR)"
endef
define SETUP_WASM_MESON
meson setup \
--prefix=/ \
--backend=ninja \
--cross-file "$(CROSS_FILE)" "$(WASM_SRC_DIR)" "$(WASM_BUILD_DIR)"
endef
define NINJA_BUILD
DESTDIR=$(ARTIFACTS_DIR) ninja -C $(DEP_BUILD_DIR) install
endef
define SETUP_CMAKE
cmake -DCMAKE_INSTALL_PREFIX=$(DEP_ARTIFACTS_DIR) \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DBUILD_SHARED_LIBS=OFF $(CMAKE_BUILD_SETTINGS) $(PLATFORM) $(TOOLCHAIN_FILE) \
-B $(DEP_BUILD_DIR) \
$(DEP_SOURCE_DIR)
endef
define CMAKE_MAKE_BUILD
$(MAKE) -C $(CMAKE_BUILD_DIR) install
endef
define CMAKE_BUILD
cmake --build $(CMAKE_BUILD_DIR) --config Release --target install -- $(CMAKE_BUILD_OPTIONS)
endef
define CLEAN_LIBGJPEG
echo "Removing libjpeg from rm /usr/local/lib/libjpeg*"
rm -f /usr/local/lib/libjpeg*
endef
define SIMPLE_CARGO_BUILD
IPHONEOS_DEPLOYMENT_TARGET=$(APPLE_IOS_VERSION_MIN) \
MACOSX_DEPLOYMENT_TARGET=$(APPLE_MACOS_VERSION_MIN) \
cargo build \
--manifest-path $(PROJECT_DIR)/Cargo.toml \
--release;
endef
define CARGO_BUILD
if [ "$(CARGO_TARGET)" = "wasm32-unknown-emscripten" ]; then \
source $(EMSDK_DIR)/$(EMSDK)_env.sh && \
RUSTFLAGS="-Zlocation-detail=none" cargo +nightly build \
-Z build-std=std,panic_abort \
-Z build-std-features="panic_immediate_abort,optimize_for_size" \
--manifest-path $(PROJECT_DIR)/Cargo.toml \
--target $(CARGO_TARGET) \
--no-default-features \
--features thorvg-v1 \
--release; \
else \
IPHONEOS_DEPLOYMENT_TARGET=$(APPLE_IOS_VERSION_MIN) \
MACOSX_DEPLOYMENT_TARGET=$(APPLE_MACOS_VERSION_MIN) \
cargo build \
--manifest-path $(PROJECT_DIR)/Cargo.toml \
--target $(CARGO_TARGET) \
--no-default-features \
--features thorvg-v1 \
--release; \
fi
endef
define UNIFFI_BINDINGS_BUILD
rm -rf $(RUNTIME_FFI)/$(RUNTIME_FFI_UNIFFI_BINDINGS)/$(BINDINGS_LANGUAGE)
cargo run \
--manifest-path $(RUNTIME_FFI)/Cargo.toml \
--no-default-features \
--features=uniffi/cli,thorvg-v1 \
--bin uniffi-bindgen \
generate $(RUNTIME_FFI)/src/dotlottie_player.udl \
--language $(BINDINGS_LANGUAGE) \
--out-dir $(RUNTIME_FFI)/$(RUNTIME_FFI_UNIFFI_BINDINGS)/$(BINDINGS_LANGUAGE)
endef
define UNIFFI_BINDINGS_CPP_BUILD
rm -rf $(RUNTIME_FFI)/$(RUNTIME_FFI_UNIFFI_BINDINGS)/$(CPLUSPLUS)
$(UNIFFI_BINDGEN_CPP) \
--config $(RUNTIME_FFI)/uniffi.toml \
--out-dir $(RUNTIME_FFI)/$(RUNTIME_FFI_UNIFFI_BINDINGS)/$(CPLUSPLUS) \
$(RUNTIME_FFI)/src/dotlottie_player_cpp.udl
sed -i .bak 's/uint8_t/char/g' $(RUNTIME_FFI)/$(RUNTIME_FFI_UNIFFI_BINDINGS)/$(CPLUSPLUS)/*
cp $(RUNTIME_FFI)/emscripten_bindings.cpp $(RUNTIME_FFI)/$(RUNTIME_FFI_UNIFFI_BINDINGS)/$(CPLUSPLUS)/.
endef
define ANDROID_RELEASE
mkdir -p $(DOTLOTTIE_PLAYER_ANDROID_RELEASE_DIR) $(DOTLOTTIE_PLAYER_ANDROID_SRC_DIR) $(DOTLOTTIE_PLAYER_LIB_DIR)
cp -r $(RUNTIME_FFI)/$(RUNTIME_FFI_UNIFFI_BINDINGS)/$(KOTLIN)/* $(DOTLOTTIE_PLAYER_ANDROID_SRC_DIR)
cp $(RUNTIME_FFI_TARGET_LIB) $(DOTLOTTIE_PLAYER_LIB_DIR)/$(DOTLOTTIE_PLAYER_LIB)
cp $(RUNTIME_FFI)/$(RUNTIME_FFI_ANDROID_ASSETS)/$(ANDROID)/* $(DOTLOTTIE_PLAYER_ANDROID_RELEASE_DIR)
echo "dlplayer-version=$(CRATE_VERSION)-$(COMMIT_HASH)" > $(DOTLOTTIE_PLAYER_ANDROID_RELEASE_DIR)/$(DOTLOTTIE_PLAYER_GRADLE_PROPERTIES)
cd $(RELEASE)/$(ANDROID) && \
rm -f $(DOTLOTTIE_PLAYER).$(ANDROID).tar.gz && \
tar zcf $(DOTLOTTIE_PLAYER).$(ANDROID).tar.gz *
endef
define NATIVE_RELEASE
rm -rf $(DOTLOTTIE_PLAYER_NATIVE_RELEASE_DIR)
mkdir -p $(DOTLOTTIE_PLAYER_NATIVE_RELEASE_INCLUDE_DIR) $(DOTLOTTIE_PLAYER_NATIVE_RELEASE_LIB_DIR)
cp $(RUNTIME_FFI)/bindings.h $(DOTLOTTIE_PLAYER_NATIVE_RELEASE_INCLUDE_DIR)/$(RUNTIME_FFI_HEADER)
find $(RUNTIME_FFI)/target/$(RELEASE)/ -maxdepth 1 \( -name '*.so' -or -name '*.dylib' -or -name "*.dll" \) \
-exec cp {} $(DOTLOTTIE_PLAYER_NATIVE_RELEASE_LIB_DIR) \;
cd $(RELEASE)/$(NATIVE) && \
rm -f $(DOTLOTTIE_PLAYER).$(NATIVE).tar.gz && \
tar zcf $(DOTLOTTIE_PLAYER).$(NATIVE).tar.gz *
endef
define LIPO_CREATE
rm -f $@
mkdir -p $$(dirname $@)
$(LIPO) \
-create $(LIBS) \
-o $@
endef
define CREATE_FRAMEWORK
rm -rf $(BASE_DIR)/$(DOTLOTTIE_PLAYER_FRAMEWORK) $(RELEASE)/$(APPLE)/$(DOTLOTTIE_PLAYER_XCFRAMEWORK)
mkdir -p $(BASE_DIR)/$(DOTLOTTIE_PLAYER_FRAMEWORK)/{$(FRAMEWORK_HEADERS),$(FRAMEWORK_MODULES)}
cp $(BASE_DIR)/$(RUNTIME_FFI_DYLIB) $(BASE_DIR)/$(DOTLOTTIE_PLAYER_FRAMEWORK)/$(DOTLOTTIE_PLAYER_MODULE)
cp $(RUNTIME_FFI)/$(RUNTIME_FFI_UNIFFI_BINDINGS)/$(SWIFT)/$(DOTLOTTIE_PLAYER_MODULE).h $(BASE_DIR)/$(DOTLOTTIE_PLAYER_FRAMEWORK)/$(FRAMEWORK_HEADERS)/$(DOTLOTTIE_PLAYER_HEADER)
cp $(RUNTIME_FFI)/$(APPLE_BUILD)/$(MODULE_MAP) $(BASE_DIR)/$(DOTLOTTIE_PLAYER_FRAMEWORK)/$(FRAMEWORK_MODULES)
$(PLISTBUDDY_EXEC) -c "Add :CFBundleIdentifier string com.dotlottie.$(DOTLOTTIE_PLAYER_MODULE)" \
-c "Add :CFBundleName string $(DOTLOTTIE_PLAYER_MODULE)" \
-c "Add :CFBundleDisplayName string $(DOTLOTTIE_PLAYER_MODULE)" \
-c "Add :CFBundleVersion string 1.0.0" \
-c "Add :CFBundleShortVersionString string 1.0.0" \
-c "Add :CFBundlePackageType string FMWK" \
-c "Add :CFBundleExecutable string $(DOTLOTTIE_PLAYER_MODULE)" \
-c "Add :MinimumOSVersion string $(if $(findstring macosx,$(BASE_DIR)),$(APPLE_MACOS_VERSION_MIN),$(APPLE_IOS_VERSION_MIN))" \
-c "Add :CFBundleSupportedPlatforms array" \
$(foreach platform,$(PLIST_DISABLE),-c "Add :CFBundleSupportedPlatforms:0 string $(platform)" ) \
$(foreach platform,$(PLIST_ENABLE),-c "Add :CFBundleSupportedPlatforms:1 string $(platform)" ) \
$(BASE_DIR)/$(DOTLOTTIE_PLAYER_FRAMEWORK)/$(INFO_PLIST)
$(INSTALL_NAME_TOOL) -id @rpath/$(DOTLOTTIE_PLAYER_FRAMEWORK)/$(DOTLOTTIE_PLAYER_MODULE) $(BASE_DIR)/$(DOTLOTTIE_PLAYER_FRAMEWORK)/$(DOTLOTTIE_PLAYER_MODULE)
endef
define APPLE_RELEASE
rm -rf $(RELEASE)/$(APPLE)
mkdir -p $(RELEASE)/$(APPLE)
$(XCODEBUILD) -create-xcframework \
$$(find $(RUNTIME_FFI)/$(APPLE_BUILD) -type d -depth 2 | sed 's/^/-framework /' | tr '\n' ' ') \
-output $(RELEASE)/$(APPLE)/$(DOTLOTTIE_PLAYER_XCFRAMEWORK)
cp $(RUNTIME_FFI)/$(RUNTIME_FFI_UNIFFI_BINDINGS)/$(SWIFT)/$(DOTLOTTIE_PLAYER_SWIFT) $(RELEASE)/$(APPLE)/.
cd $(RELEASE)/$(APPLE) && \
rm -f $(DOTLOTTIE_PLAYER).$(DARWIN).tar.gz && \
tar zcf $(DOTLOTTIE_PLAYER).$(DARWIN).tar.gz *
endef
define WASM_RELEASE
rm -rf $(RELEASE)/$(WASM)
mkdir -p $(RELEASE)/$(WASM)
cp $(RUNTIME_FFI)/$(WASM_BUILD)/$(BUILD)/$(WASM_MODULE).wasm \
$(RELEASE)/$(WASM)
cp $(RUNTIME_FFI)/$(WASM_BUILD)/$(BUILD)/$(WASM_MODULE).d.ts \
$(RELEASE)/$(WASM)
cp $(RUNTIME_FFI)/$(WASM_BUILD)/$(BUILD)/$(WASM_MODULE).js \
$(RELEASE)/$(WASM)/$(WASM_MODULE).mjs
cd $(RELEASE)/$(WASM) && \
rm -f $(DOTLOTTIE_PLAYER).$(WASM).tar.gz && \
tar zcf $(DOTLOTTIE_PLAYER).$(WASM).tar.gz *
endef
# $1: rust target triple, e.g. aarch64-linux-android
# $2: rust target triple in screaming snake case, e.g. AARCH64_LINUX_ANDROID
# $3: build specific, i.e. android/apple, target
# $4: build specific, i.e. android/apple, abi
# $5: CPU Family, e.g. arm
# $6: CPU, e.g. aarch64
define NEW_BUILD_TARGET
# Setup architecture variables
$2 := $1
$2_ARCH := $3
$2_ABI := $4
$2_CPU_FAMILY := $5
$2_CPU := $6
# Setup dependency build variables
$2_DEPS_BUILD_DIR := $(DEPS_BUILD_DIR)/$1
$2_THORVG_DEP_BUILD_DIR := $$($2_DEPS_BUILD_DIR)/$(THORVG)
$2_LIBJPEG_TURBO_DEP_BUILD_DIR := $$($2_DEPS_BUILD_DIR)/$(LIBJPEG_TURBO)
$2_LIBPNG_DEP_BUILD_DIR := $$($2_DEPS_BUILD_DIR)/$(LIBPNG)
$2_ZLIB_DEP_BUILD_DIR := $$($2_DEPS_BUILD_DIR)/$(ZLIB)
$2_WEBP_DEP_BUILD_DIR := $$($2_DEPS_BUILD_DIR)/$(WEBP)
$2_DEPS_ARTIFACTS_DIR := $(DEPS_ARTIFACTS_DIR)/$1/usr
$2_DEPS_INCLUDE_DIR := $$($2_DEPS_ARTIFACTS_DIR)/include
$2_DEPS_LIB_DIR := $$($2_DEPS_ARTIFACTS_DIR)/lib
$2_DEPS_LIB64_DIR := $$($2_DEPS_ARTIFACTS_DIR)/lib64
endef
define NEW_APPLE_TARGET
# Setup Apple-specific variables
$1_SUBSYSTEM := $2
$1_PLATFORM := $3
$1_SDK := $4
# Setup the framework type for this target
$(if $(filter $3,$(APPLE_IOS_PLATFORM)),\
$1_FRAMEWORK_TYPE := $(APPLE_IOS_FRAMEWORK_TYPE)
APPLE_IOS_FRAMEWORK_TARGETS += $$($1))
$(if $(filter $3,$(APPLE_IOS_SIMULATOR_PLATFORM)),\
$1_FRAMEWORK_TYPE := $(APPLE_IOS_SIMULATOR_FRAMEWORK_TYPE)
APPLE_IOS_SIMULATOR_FRAMEWORK_TARGETS += $$($1))
$(if $(filter $3,$(APPLE_MACOSX_PLATFORM)),\
$1_FRAMEWORK_TYPE := $(APPLE_MACOSX_FRAMEWORK_TYPE)
APPLE_MACOSX_FRAMEWORK_TARGETS += $$($1))
endef
define NEW_ANDROID_CMAKE_BUILD
# Create toolchain file
$4/../$(CMAKE_TOOLCHAIN_FILE): DEP_BUILD_DIR := $4
$4/../$(CMAKE_TOOLCHAIN_FILE): ANDROID_ABI := $$($1_ABI)
$4/../$(CMAKE_TOOLCHAIN_FILE): export OUTPUT_FILE := $$(ANDROID_CMAKE_TOOLCHAIN_FILE)
$4/../$(CMAKE_TOOLCHAIN_FILE):
$$(CREATE_OUTPUT_FILE)
# Setup cmake
$4/$(CMAKE_MAKEFILE): export LDFLAGS := $$($2_LDFLAGS)
$4/$(CMAKE_MAKEFILE): DEP_SOURCE_DIR := $(DEPS_MODULES_DIR)/$3
$4/$(CMAKE_MAKEFILE): DEP_BUILD_DIR := $4
$4/$(CMAKE_MAKEFILE): DEP_ARTIFACTS_DIR := $$($1_DEPS_ARTIFACTS_DIR)
$4/$(CMAKE_MAKEFILE): CMAKE_BUILD_SETTINGS := -DANDROID_NDK=$(ANDROID_NDK_HOME) -DANDROID_ABI=$$($1_ABI)
$4/$(CMAKE_MAKEFILE): TOOLCHAIN_FILE := -DCMAKE_TOOLCHAIN_FILE=../$(CMAKE_TOOLCHAIN_FILE)
$4/$(CMAKE_MAKEFILE): $4/../$(CMAKE_TOOLCHAIN_FILE)
$$(SETUP_CMAKE)
# Build
$$($1_DEPS_LIB_DIR)/$5: CMAKE_BUILD_DIR := $4
$$($1_DEPS_LIB_DIR)/$5: $4/$(CMAKE_MAKEFILE)
$$(CMAKE_MAKE_BUILD)
endef
define NEW_APPLE_CMAKE_BUILD
# Setup cmake
$4/$(CMAKE_CACHE): DEP_SOURCE_DIR := $(DEPS_MODULES_DIR)/$3
$4/$(CMAKE_CACHE): DEP_BUILD_DIR := $4
$4/$(CMAKE_CACHE): DEP_ARTIFACTS_DIR := $$($1_DEPS_ARTIFACTS_DIR)
$4/$(CMAKE_CACHE): CMAKE_BUILD_SETTINGS := -GXcode -DCMAKE_MACOSX_BUNDLE=NO -DDEPLOYMENT_TARGET=$(if $(findstring DARWIN,$1),$(APPLE_MACOS_VERSION_MIN),$(APPLE_IOS_VERSION_MIN))
$4/$(CMAKE_CACHE): PLATFORM := -DPLATFORM=$$($1_ARCH)
$4/$(CMAKE_CACHE): TOOLCHAIN_FILE := -DCMAKE_TOOLCHAIN_FILE=$(PWD)/$(DEPS_MODULES_DIR)/ios-cmake/ios.toolchain.cmake
$4/$(CMAKE_CACHE):
$$(SETUP_CMAKE)
# Build
$(call CLEAN_LIBGJPEG)
$$($1_DEPS_LIB_DIR)/$5: CMAKE_BUILD_DIR := $4
$$($1_DEPS_LIB_DIR)/$5: CMAKE_BUILD_OPTIONS := $(if $(filter $($1_SUBSYSTEM),$(APPLE_IOS)),CODE_SIGNING_ALLOWED=NO,)
$$($1_DEPS_LIB_DIR)/$5: $4/$(CMAKE_CACHE)
$$(CMAKE_BUILD)
endef
define NEW_ANDROID_CROSS_FILE
# Create cross file for thorvg
$$($1_THORVG_DEP_BUILD_DIR)/../$(MESON_CROSS_FILE): SYSROOT := $(ANDROID_NDK_HOME)/toolchains/llvm/prebuilt/$(ANDROID_BUILD_PLATFORM)/sysroot/usr/lib/$$($1_ARCH)/$(ANDROID_API_VERSION)
$$($1_THORVG_DEP_BUILD_DIR)/../$(MESON_CROSS_FILE): CPP := $(ANDROID_NDK_HOME)/toolchains/llvm/prebuilt/$(ANDROID_BUILD_PLATFORM)/bin/$$($1_ARCH)$(ANDROID_API_VERSION)-clang++
$$($1_THORVG_DEP_BUILD_DIR)/../$(MESON_CROSS_FILE): CPU_FAMILY := $$($1_CPU_FAMILY)
$$($1_THORVG_DEP_BUILD_DIR)/../$(MESON_CROSS_FILE): CPU := $$($1_CPU)
$$($1_THORVG_DEP_BUILD_DIR)/../$(MESON_CROSS_FILE): export OUTPUT_FILE := $$(ANDROID_CROSS_FILE)
$$($1_THORVG_DEP_BUILD_DIR)/../$(MESON_CROSS_FILE):
$$(CREATE_OUTPUT_FILE)
endef
define NEW_APPLE_CROSS_FILE
# Create cross file for thorvg
$$($1_THORVG_DEP_BUILD_DIR)/../$(MESON_CROSS_FILE): ARCH := $$($1_ABI)
$$($1_THORVG_DEP_BUILD_DIR)/../$(MESON_CROSS_FILE): PLATFORM := $$($1_PLATFORM)
$$($1_THORVG_DEP_BUILD_DIR)/../$(MESON_CROSS_FILE): SDK := $$($1_SDK)
$$($1_THORVG_DEP_BUILD_DIR)/../$(MESON_CROSS_FILE): SUBSYSTEM := $$($1_SUBSYSTEM)
$$($1_THORVG_DEP_BUILD_DIR)/../$(MESON_CROSS_FILE): CPU_FAMILY := $$($1_CPU_FAMILY)
$$($1_THORVG_DEP_BUILD_DIR)/../$(MESON_CROSS_FILE): CPU := $$($1_CPU)
$$($1_THORVG_DEP_BUILD_DIR)/../$(MESON_CROSS_FILE): export OUTPUT_FILE := $$(APPLE_CROSS_FILE)
$$($1_THORVG_DEP_BUILD_DIR)/../$(MESON_CROSS_FILE):
$$(CREATE_OUTPUT_FILE)
endef
define NEW_WASM_CROSS_FILE
# Create cross file for thorvg
$2/$(MESON_CROSS_FILE): SYSTEM := $3
$2/$(MESON_CROSS_FILE): CPU_FAMILY := $$($1_CPU_FAMILY)
$2/$(MESON_CROSS_FILE): CPU := $$($1_CPU)
$2/$(MESON_CROSS_FILE): export OUTPUT_FILE := $$(WASM_CROSS_FILE)
$2/$(MESON_CROSS_FILE):
$$(CREATE_OUTPUT_FILE)
endef
define NEW_THORVG_BUILD
# Setup meson for thorvg
$$($1_THORVG_DEP_BUILD_DIR)/$(NINJA_BUILD_FILE): export PKG_CONFIG_PATH := $(PWD)/$$($1_DEPS_LIB_DIR)/pkgconfig:$(PWD)/$$($1_DEPS_LIB64_DIR)
$$($1_THORVG_DEP_BUILD_DIR)/$(NINJA_BUILD_FILE): THORVG_DEP_SOURCE_DIR := $(DEPS_MODULES_DIR)/$(THORVG)
$$($1_THORVG_DEP_BUILD_DIR)/$(NINJA_BUILD_FILE): THORVG_DEP_BUILD_DIR := $$($1_THORVG_DEP_BUILD_DIR)
$$($1_THORVG_DEP_BUILD_DIR)/$(NINJA_BUILD_FILE): CROSS_FILE := --cross-file $$($1_THORVG_DEP_BUILD_DIR)/../$(MESON_CROSS_FILE)
$$($1_THORVG_DEP_BUILD_DIR)/$(NINJA_BUILD_FILE): LOG := false
$$($1_THORVG_DEP_BUILD_DIR)/$(NINJA_BUILD_FILE): STATIC := $3
$$($1_THORVG_DEP_BUILD_DIR)/$(NINJA_BUILD_FILE): EXTRA := $4
$$($1_THORVG_DEP_BUILD_DIR)/$(NINJA_BUILD_FILE): FILE := $5
$$($1_THORVG_DEP_BUILD_DIR)/$(NINJA_BUILD_FILE): $$($1_THORVG_DEP_BUILD_DIR)/../$(MESON_CROSS_FILE)
$(if $(filter $3,false),
$$($1_THORVG_DEP_BUILD_DIR)/$(NINJA_BUILD_FILE): $$($1_DEPS_LIB_DIR)/$(LIBJPEG_TURBO_LIB)
$$($1_THORVG_DEP_BUILD_DIR)/$(NINJA_BUILD_FILE): $$($1_DEPS_LIB_DIR)/$(LIBPNG_LIB)
$$($1_THORVG_DEP_BUILD_DIR)/$(NINJA_BUILD_FILE): $$($1_DEPS_LIB_DIR)/$(WEBP_LIB)
$$($1_THORVG_DEP_BUILD_DIR)/$(NINJA_BUILD_FILE): $$($1_DEPS_LIB_DIR)/$(ZLIB_LIB),)
$$(SETUP_MESON)
# Build thorvg
$$($1_DEPS_LIB_DIR)/$(THORVG_LIB): DEP_BUILD_DIR := $$($1_THORVG_DEP_BUILD_DIR)
$$($1_DEPS_LIB_DIR)/$(THORVG_LIB): ARTIFACTS_DIR := ../../../artifacts/$$($1)/usr
$$($1_DEPS_LIB_DIR)/$(THORVG_LIB): $$($1_THORVG_DEP_BUILD_DIR)/$(NINJA_BUILD_FILE)
$$(NINJA_BUILD)
endef
define NEW_ANDROID_DEPS_BUILD
$(eval $(call NEW_ANDROID_CMAKE_BUILD,$1,LIBJPEG_TURBO,$(LIBJPEG_TURBO),$$($1_LIBJPEG_TURBO_DEP_BUILD_DIR),$(LIBJPEG_TURBO_LIB)))
$(eval $(call NEW_ANDROID_CMAKE_BUILD,$1,LIBPNG_LIB,$(LIBPNG),$$($1_LIBPNG_DEP_BUILD_DIR),$(LIBPNG_LIB)))
$(eval $(call NEW_ANDROID_CMAKE_BUILD,$1,ZLIB,$(ZLIB),$$($1_ZLIB_DEP_BUILD_DIR),$(ZLIB_LIB)))
$(eval $(call NEW_ANDROID_CMAKE_BUILD,$1,WEBP,$(WEBP),$$($1_WEBP_DEP_BUILD_DIR),$(WEBP_LIB)))
$(eval $(call NEW_ANDROID_CROSS_FILE,$1))
$(eval $(call NEW_THORVG_BUILD,$1,false,false,"lottie_expressions",true))
endef
define NEW_APPLE_DEPS_BUILD
$(eval $(call NEW_APPLE_CMAKE_BUILD,$1,LIBJPEG_TURBO,$(LIBJPEG_TURBO),$$($1_LIBJPEG_TURBO_DEP_BUILD_DIR),$(LIBJPEG_TURBO_LIB)))
$(eval $(call NEW_APPLE_CMAKE_BUILD,$1,LIBPNG_LIB,$(LIBPNG),$$($1_LIBPNG_DEP_BUILD_DIR),$(LIBPNG_LIB)))
$(eval $(call NEW_APPLE_CMAKE_BUILD,$1,ZLIB,$(ZLIB),$$($1_ZLIB_DEP_BUILD_DIR),$(ZLIB_LIB)))
$(eval $(call NEW_APPLE_CMAKE_BUILD,$1,WEBP,$(WEBP),$$($1_WEBP_DEP_BUILD_DIR),$(WEBP_LIB)))
$(eval $(call NEW_APPLE_CROSS_FILE,$1))
$(eval $(call NEW_THORVG_BUILD,$1,false,false,"lottie_expressions",true))
endef
define NEW_WASM_DEPS_BUILD
$(eval $(call NEW_WASM_CROSS_FILE,$1,$$($1_THORVG_DEP_BUILD_DIR)/..,windows))
$(eval $(call NEW_THORVG_BUILD,$1,false,true,"lottie_expressions",false))
endef
define NEW_ANDROID_BUILD
# Setup final artifact variables
$1_RUNTIME_FFI_DEPS_BUILD_DIR := $(RUNTIME_FFI)/target/$$($1)/release
$1_DOTLOTTIE_PLAYER_LIB_DIR := $(DOTLOTTIE_PLAYER_ANDROID_RELEASE_DIR)/src/main/jniLibs/$$($1_ABI)
# Build dotlottie-ffi
$$($1_RUNTIME_FFI_DEPS_BUILD_DIR)/$(RUNTIME_FFI_LIB): export ARTIFACTS_INCLUDE_DIR := ../$$($1_DEPS_INCLUDE_DIR)
$$($1_RUNTIME_FFI_DEPS_BUILD_DIR)/$(RUNTIME_FFI_LIB): export ARTIFACTS_LIB_DIR := ../$$($1_DEPS_LIB_DIR)
$$($1_RUNTIME_FFI_DEPS_BUILD_DIR)/$(RUNTIME_FFI_LIB): export ARTIFACTS_LIB64_DIR := ../$$($1_DEPS_LIB_DIR)64
$$($1_RUNTIME_FFI_DEPS_BUILD_DIR)/$(RUNTIME_FFI_LIB): export CARGO_TARGET := $$($1)
$$($1_RUNTIME_FFI_DEPS_BUILD_DIR)/$(RUNTIME_FFI_LIB): export CARGO_TARGET_$1_LINKER := $(ANDROID_NDK_HOME)/toolchains/llvm/prebuilt/$(ANDROID_BUILD_PLATFORM)/bin/$$($1_ARCH)$(ANDROID_API_VERSION)-clang
$$($1_RUNTIME_FFI_DEPS_BUILD_DIR)/$(RUNTIME_FFI_LIB): PROJECT_DIR := $(RUNTIME_FFI)
$$($1_RUNTIME_FFI_DEPS_BUILD_DIR)/$(RUNTIME_FFI_LIB): $$($1_DEPS_LIB_DIR)/$(THORVG_LIB)
$$($1_RUNTIME_FFI_DEPS_BUILD_DIR)/$(RUNTIME_FFI_LIB): $(RUNTIME_FFI)/$(RUNTIME_FFI_UNIFFI_BINDINGS)/$(KOTLIN) $(CORE_SRC)
$$(CARGO_BUILD)
# Build release
$$($1_DOTLOTTIE_PLAYER_LIB_DIR)/$(DOTLOTTIE_PLAYER_LIB): DOTLOTTIE_PLAYER_LIB_DIR := $$($1_DOTLOTTIE_PLAYER_LIB_DIR)
$$($1_DOTLOTTIE_PLAYER_LIB_DIR)/$(DOTLOTTIE_PLAYER_LIB): RUNTIME_FFI_TARGET_LIB := $$($1_RUNTIME_FFI_DEPS_BUILD_DIR)/$(RUNTIME_FFI_LIB)
$$($1_DOTLOTTIE_PLAYER_LIB_DIR)/$(DOTLOTTIE_PLAYER_LIB): CRATE_VERSION := $(shell grep -m 1 version $(RUNTIME_FFI)/Cargo.toml | sed 's/.*"\([0-9.]\+\)"/\1/')
$$($1_DOTLOTTIE_PLAYER_LIB_DIR)/$(DOTLOTTIE_PLAYER_LIB): COMMIT_HASH := $(shell git rev-parse --short HEAD)
$$($1_DOTLOTTIE_PLAYER_LIB_DIR)/$(DOTLOTTIE_PLAYER_LIB): $$($1_RUNTIME_FFI_DEPS_BUILD_DIR)/$(RUNTIME_FFI_LIB)
$$(ANDROID_RELEASE)
.PHONY: $$($1)
$$($1): $$($1_DOTLOTTIE_PLAYER_LIB_DIR)/$(DOTLOTTIE_PLAYER_LIB)
ANDROID_BUILD_TARGETS += $$($1)
endef
define NEW_APPLE_BUILD
# Setup final artifact variables
$1_RUNTIME_FFI_DEPS_BUILD_DIR := $(RUNTIME_FFI)/target/$$($1)/release
# Build dotlottie-ffi
$$($1_RUNTIME_FFI_DEPS_BUILD_DIR)/$(RUNTIME_FFI_LIB): export ARTIFACTS_INCLUDE_DIR := ../$$($1_DEPS_INCLUDE_DIR)
$$($1_RUNTIME_FFI_DEPS_BUILD_DIR)/$(RUNTIME_FFI_LIB): export ARTIFACTS_LIB_DIR := ../$$($1_DEPS_LIB_DIR)
$$($1_RUNTIME_FFI_DEPS_BUILD_DIR)/$(RUNTIME_FFI_LIB): export ARTIFACTS_LIB64_DIR := ../$$($1_DEPS_LIB_DIR)64
$$($1_RUNTIME_FFI_DEPS_BUILD_DIR)/$(RUNTIME_FFI_LIB): export CARGO_TARGET := $$($1)
$$($1_RUNTIME_FFI_DEPS_BUILD_DIR)/$(RUNTIME_FFI_LIB): PROJECT_DIR := $(RUNTIME_FFI)
$$($1_RUNTIME_FFI_DEPS_BUILD_DIR)/$(RUNTIME_FFI_LIB): $$($1_DEPS_LIB_DIR)/$(THORVG_LIB)
$$($1_RUNTIME_FFI_DEPS_BUILD_DIR)/$(RUNTIME_FFI_LIB): $(RUNTIME_FFI)/$(RUNTIME_FFI_UNIFFI_BINDINGS)/$(SWIFT)
$$($1_RUNTIME_FFI_DEPS_BUILD_DIR)/$(RUNTIME_FFI_LIB): $(CORE_SRC)
$$(CARGO_BUILD)
# Ensure that the release artifact depends on this build
$(RUNTIME_FFI)/$(APPLE_BUILD)/$$($1_FRAMEWORK_TYPE)/$(RUNTIME_FFI_DYLIB): $$($1_RUNTIME_FFI_DEPS_BUILD_DIR)/$(RUNTIME_FFI_LIB)
.PHONY: $$($1)
$$($1): $(RUNTIME_FFI)/$(APPLE_BUILD)/$$($1_FRAMEWORK_TYPE)/$(DOTLOTTIE_PLAYER_FRAMEWORK) $(RELEASE)/$(APPLE)/$(DOTLOTTIE_PLAYER_XCFRAMEWORK)
APPLE_BUILD_TARGETS += $$($1)
endef
# $1: framework type
# $2: framework targets
# $3: plist enable
# $4: plist disable
define NEW_APPLE_FRAMEWORK
# Build lipo library
$(RUNTIME_FFI)/$(APPLE_BUILD)/$1/$(RUNTIME_FFI_DYLIB): ALL_LIBS := $$(foreach target,$2,$(RUNTIME_FFI)/target/$$(target)/release/$(RUNTIME_FFI_DYLIB))
$(RUNTIME_FFI)/$(APPLE_BUILD)/$1/$(RUNTIME_FFI_DYLIB): LIBS = $$(foreach lib,$$(ALL_LIBS),$$(wildcard $$(lib)))
$(RUNTIME_FFI)/$(APPLE_BUILD)/$1/$(RUNTIME_FFI_DYLIB):
$$(LIPO_CREATE)
# Build framework & xcframework
$(RUNTIME_FFI)/$(APPLE_BUILD)/$1/$(DOTLOTTIE_PLAYER_FRAMEWORK): BASE_DIR := $(RUNTIME_FFI)/$(APPLE_BUILD)/$1
$(RUNTIME_FFI)/$(APPLE_BUILD)/$1/$(DOTLOTTIE_PLAYER_FRAMEWORK): PLIST_ENABLE := $3
$(RUNTIME_FFI)/$(APPLE_BUILD)/$1/$(DOTLOTTIE_PLAYER_FRAMEWORK): PLIST_DISABLE := $4
$(RUNTIME_FFI)/$(APPLE_BUILD)/$1/$(DOTLOTTIE_PLAYER_FRAMEWORK): $(RUNTIME_FFI)/$(RUNTIME_FFI_UNIFFI_BINDINGS)/$(SWIFT) $(RUNTIME_FFI)/$(APPLE_BUILD)/$(MODULE_MAP)
$(RUNTIME_FFI)/$(APPLE_BUILD)/$1/$(DOTLOTTIE_PLAYER_FRAMEWORK): $(RUNTIME_FFI)/$(APPLE_BUILD)/$1/$(RUNTIME_FFI_DYLIB)
$$(CREATE_FRAMEWORK)
$$(APPLE_RELEASE)
endef
define NEW_WASM_BUILD
# Setup final artifact variables
$1_RUNTIME_FFI_DEPS_BUILD_DIR := $(RUNTIME_FFI)/target/$$($1)/release
# Build dotlottie-ffi
$$($1_RUNTIME_FFI_DEPS_BUILD_DIR)/$(RUNTIME_FFI_STATIC_LIB): export ARTIFACTS_INCLUDE_DIR := ../$$($1_DEPS_INCLUDE_DIR)
$$($1_RUNTIME_FFI_DEPS_BUILD_DIR)/$(RUNTIME_FFI_STATIC_LIB): export ARTIFACTS_LIB_DIR := ../$$($1_DEPS_LIB_DIR)
$$($1_RUNTIME_FFI_DEPS_BUILD_DIR)/$(RUNTIME_FFI_STATIC_LIB): export ARTIFACTS_LIB64_DIR := ../$$($1_DEPS_LIB_DIR)64
$$($1_RUNTIME_FFI_DEPS_BUILD_DIR)/$(RUNTIME_FFI_STATIC_LIB): export CARGO_TARGET := $$($1)
$$($1_RUNTIME_FFI_DEPS_BUILD_DIR)/$(RUNTIME_FFI_STATIC_LIB): PROJECT_DIR := $(RUNTIME_FFI)
$$($1_RUNTIME_FFI_DEPS_BUILD_DIR)/$(RUNTIME_FFI_STATIC_LIB): $$($1_DEPS_LIB_DIR)/$(THORVG_LIB)
$$(CARGO_BUILD)
# Setup WASM build cross file
$(call NEW_WASM_CROSS_FILE,$1,$(RUNTIME_FFI)/$(WASM_BUILD),emscripten)
# Setup WASM meson build
$(RUNTIME_FFI)/$(WASM_BUILD)/$(MESON_BUILD_FILE): DEPS_INCLUDE_DIR := $(PROJECT_DIR)/$$($1_DEPS_INCLUDE_DIR)
$(RUNTIME_FFI)/$(WASM_BUILD)/$(MESON_BUILD_FILE): DEPS_LIB_DIR := $(PROJECT_DIR)/$$($1_DEPS_LIB_DIR)
$(RUNTIME_FFI)/$(WASM_BUILD)/$(MESON_BUILD_FILE): FFI_BUILD_DIR := $(PROJECT_DIR)/$$($1_RUNTIME_FFI_DEPS_BUILD_DIR)
$(RUNTIME_FFI)/$(WASM_BUILD)/$(MESON_BUILD_FILE): FFI_BINDINGS_DIR := $(PROJECT_DIR)/$(RUNTIME_FFI)/$(RUNTIME_FFI_UNIFFI_BINDINGS)/$(CPLUSPLUS)
$(RUNTIME_FFI)/$(WASM_BUILD)/$(MESON_BUILD_FILE): export OUTPUT_FILE = $$(WASM_MESON_BUILD_FILE)
$(RUNTIME_FFI)/$(WASM_BUILD)/$(MESON_BUILD_FILE): $$($1_RUNTIME_FFI_DEPS_BUILD_DIR)/$(RUNTIME_FFI_STATIC_LIB)
$(RUNTIME_FFI)/$(WASM_BUILD)/$(MESON_BUILD_FILE): $(RUNTIME_FFI)/$(RUNTIME_FFI_UNIFFI_BINDINGS)/$(CPLUSPLUS)
$(RUNTIME_FFI)/$(WASM_BUILD)/$(MESON_BUILD_FILE): $(RUNTIME_FFI)/$(WASM_BUILD)/$(MESON_CROSS_FILE)
$$(CREATE_OUTPUT_FILE)
# Setup meson for WASM
$(RUNTIME_FFI)/$(WASM_BUILD)/$(NINJA_BUILD_FILE): WASM_SRC_DIR := $(RUNTIME_FFI)/$(WASM_BUILD)
$(RUNTIME_FFI)/$(WASM_BUILD)/$(NINJA_BUILD_FILE): WASM_BUILD_DIR := $(RUNTIME_FFI)/$(WASM_BUILD)/$(BUILD)
$(RUNTIME_FFI)/$(WASM_BUILD)/$(NINJA_BUILD_FILE): CROSS_FILE := $(RUNTIME_FFI)/$(WASM_BUILD)/$(MESON_CROSS_FILE)
$(RUNTIME_FFI)/$(WASM_BUILD)/$(NINJA_BUILD_FILE): $(RUNTIME_FFI)/$(WASM_BUILD)/$(MESON_BUILD_FILE)
$$(SETUP_WASM_MESON)
# Build release
$(RELEASE)/$(WASM)/$(WASM_MODULE).wasm $(RELEASE)/$(WASM)/$(WASM_MODULE).js: DEP_BUILD_DIR := $(RUNTIME_FFI)/$(WASM_BUILD)/$(BUILD)
$(RELEASE)/$(WASM)/$(WASM_MODULE).wasm $(RELEASE)/$(WASM)/$(WASM_MODULE).js: ARTIFACTS_DIR := $(RELEASE)/$(WASM)
$(RELEASE)/$(WASM)/$(WASM_MODULE).wasm $(RELEASE)/$(WASM)/$(WASM_MODULE).js: $(RUNTIME_FFI)/$(WASM_BUILD)/$(NINJA_BUILD_FILE)
$$(NINJA_BUILD)
$$(WASM_RELEASE)
.PHONY: $$($1)
$$($1): $(RELEASE)/$(WASM)/$(WASM_MODULE).wasm $(RELEASE)/$(WASM)/$(WASM_MODULE).js
WASM_BUILD_TARGETS += $$($1)
endef
define TARGET_PREFIX
$(shell echo $(1) | tr '[:lower:]-' '[:upper:]_')
endef
define DEFINE_TARGET
$(eval $(call NEW_BUILD_TARGET,$1,$(call TARGET_PREFIX,$1),$2,$3,$4,$5))
endef
define DEFINE_APPLE_TARGET
$(eval $(call DEFINE_TARGET,$1,$2,$3,$4,$5))
$(eval $(call NEW_APPLE_TARGET,$(call TARGET_PREFIX,$1),$6,$7,$8))
endef
# Local architecture dependencies builds
define NEW_LOCAL_ARCH_CMAKE_BUILD
# Setup cmake for local arch build
$$($1_LOCAL_ARCH_BUILD_DIR)/$(CMAKE_MAKEFILE): DEP_SOURCE_DIR := $(DEPS_MODULES_DIR)/$2
$$($1_LOCAL_ARCH_BUILD_DIR)/$(CMAKE_MAKEFILE): DEP_BUILD_DIR := $$($1_LOCAL_ARCH_BUILD_DIR)
$$($1_LOCAL_ARCH_BUILD_DIR)/$(CMAKE_MAKEFILE): DEP_ARTIFACTS_DIR := $(LOCAL_ARCH_ARTIFACTS_DIR)
$$($1_LOCAL_ARCH_BUILD_DIR)/$(CMAKE_MAKEFILE):
$$(SETUP_CMAKE)
# Build local arch
$(LOCAL_ARCH_LIB_DIR)/$3: CMAKE_BUILD_DIR := $$($1_LOCAL_ARCH_BUILD_DIR)
$(LOCAL_ARCH_LIB_DIR)/$3: $$($1_LOCAL_ARCH_BUILD_DIR)/$(CMAKE_MAKEFILE)
$$(CMAKE_BUILD)
endef
# Define local deps builds
$(eval $(call NEW_LOCAL_ARCH_CMAKE_BUILD,LIBJPEG_TURBO,$(LIBJPEG_TURBO),$(LIBJPEG_TURBO_LIB)))
$(eval $(call NEW_LOCAL_ARCH_CMAKE_BUILD,LIBPNG,$(LIBPNG),$(LIBPNG_LIB)))
$(eval $(call NEW_LOCAL_ARCH_CMAKE_BUILD,ZLIB,$(ZLIB),$(ZLIB_LIB)))
$(eval $(call NEW_LOCAL_ARCH_CMAKE_BUILD,WEBP,$(WEBP),$(WEBP_LIB)))
# Setup meson for thorvg local arch build
$(THORVG_LOCAL_ARCH_BUILD_DIR)/$(NINJA_BUILD_FILE): export PKG_CONFIG_PATH := $(PWD)/$(LOCAL_ARCH_LIB_DIR)/pkgconfig:$(PWD)/$(LOCAL_ARCH_LIB64_DIR)
$(THORVG_LOCAL_ARCH_BUILD_DIR)/$(NINJA_BUILD_FILE): THORVG_DEP_SOURCE_DIR := $(DEPS_MODULES_DIR)/$(THORVG)
$(THORVG_LOCAL_ARCH_BUILD_DIR)/$(NINJA_BUILD_FILE): THORVG_DEP_BUILD_DIR := $(THORVG_LOCAL_ARCH_BUILD_DIR)
$(THORVG_LOCAL_ARCH_BUILD_DIR)/$(NINJA_BUILD_FILE): LOG := false
$(THORVG_LOCAL_ARCH_BUILD_DIR)/$(NINJA_BUILD_FILE): STATIC := false
$(THORVG_LOCAL_ARCH_BUILD_DIR)/$(NINJA_BUILD_FILE): EXTRA := lottie_expressions
$(THORVG_LOCAL_ARCH_BUILD_DIR)/$(NINJA_BUILD_FILE): FILE := true
$(THORVG_LOCAL_ARCH_BUILD_DIR)/$(NINJA_BUILD_FILE): $(LOCAL_ARCH_LIB_DIR)/$(LIBJPEG_TURBO_LIB)
$(THORVG_LOCAL_ARCH_BUILD_DIR)/$(NINJA_BUILD_FILE): $(LOCAL_ARCH_LIB_DIR)/$(LIBPNG_LIB)
$(THORVG_LOCAL_ARCH_BUILD_DIR)/$(NINJA_BUILD_FILE): $(LOCAL_ARCH_LIB_DIR)/$(ZLIB_LIB)
$(THORVG_LOCAL_ARCH_BUILD_DIR)/$(NINJA_BUILD_FILE): $(LOCAL_ARCH_LIB_DIR)/$(WEBP_LIB)
$(SETUP_MESON)
# Build thorvg local arch
$(LOCAL_ARCH_LIB_DIR)/$(THORVG_LIB): DEP_BUILD_DIR := $(THORVG_LOCAL_ARCH_BUILD_DIR)
$(LOCAL_ARCH_LIB_DIR)/$(THORVG_LIB): ARTIFACTS_DIR := ../../../../artifacts/$(LOCAL_ARCH)/usr
$(LOCAL_ARCH_LIB_DIR)/$(THORVG_LIB): $(THORVG_LOCAL_ARCH_BUILD_DIR)/$(NINJA_BUILD_FILE)
$(NINJA_BUILD)
# Uniffi Bindings - kotlin
$(RUNTIME_FFI)/$(RUNTIME_FFI_UNIFFI_BINDINGS)/$(KOTLIN): export ARTIFACTS_INCLUDE_DIR := ../$(LOCAL_ARCH_INCLUDE_DIR)
$(RUNTIME_FFI)/$(RUNTIME_FFI_UNIFFI_BINDINGS)/$(KOTLIN): export ARTIFACTS_LIB_DIR := ../$(LOCAL_ARCH_LIB_DIR)
$(RUNTIME_FFI)/$(RUNTIME_FFI_UNIFFI_BINDINGS)/$(KOTLIN): export ARTIFACTS_LIB64_DIR := ../$(LOCAL_ARCH_LIB_DIR)64
$(RUNTIME_FFI)/$(RUNTIME_FFI_UNIFFI_BINDINGS)/$(KOTLIN): BINDINGS_LANGUAGE := $(KOTLIN)
$(RUNTIME_FFI)/$(RUNTIME_FFI_UNIFFI_BINDINGS)/$(KOTLIN): $(LOCAL_ARCH_LIB_DIR)/$(THORVG_LIB)
$(RUNTIME_FFI)/$(RUNTIME_FFI_UNIFFI_BINDINGS)/$(KOTLIN): $(RUNTIME_FFI_SRC)
$(UNIFFI_BINDINGS_BUILD)
# Uniffi Bindings - swift
$(RUNTIME_FFI)/$(RUNTIME_FFI_UNIFFI_BINDINGS)/$(SWIFT): export ARTIFACTS_INCLUDE_DIR := ../$(LOCAL_ARCH_INCLUDE_DIR)
$(RUNTIME_FFI)/$(RUNTIME_FFI_UNIFFI_BINDINGS)/$(SWIFT): export ARTIFACTS_LIB_DIR := ../$(LOCAL_ARCH_LIB_DIR)
$(RUNTIME_FFI)/$(RUNTIME_FFI_UNIFFI_BINDINGS)/$(SWIFT): export ARTIFACTS_LIB64_DIR := ../$(LOCAL_ARCH_LIB_DIR)64
$(RUNTIME_FFI)/$(RUNTIME_FFI_UNIFFI_BINDINGS)/$(SWIFT): BINDINGS_LANGUAGE := $(SWIFT)
$(RUNTIME_FFI)/$(RUNTIME_FFI_UNIFFI_BINDINGS)/$(SWIFT): $(LOCAL_ARCH_LIB_DIR)/$(THORVG_LIB)
$(RUNTIME_FFI)/$(RUNTIME_FFI_UNIFFI_BINDINGS)/$(SWIFT): $(RUNTIME_FFI_SRC)
$(UNIFFI_BINDINGS_BUILD)
# Uniffi Bindings - cpp (for wasm)
$(RUNTIME_FFI)/$(RUNTIME_FFI_UNIFFI_BINDINGS)/$(CPLUSPLUS): $(RUNTIME_FFI_SRC)
$(UNIFFI_BINDINGS_CPP_BUILD)
# Uniffi
$(RUNTIME_FFI)/target/$(RELEASE)/$(RUNTIME_FFI_LIB): PROJECT_DIR := $(RUNTIME_FFI)
$(RUNTIME_FFI)/target/$(RELEASE)/$(RUNTIME_FFI_LIB):
$(SIMPLE_CARGO_BUILD)
# Define all android targets
$(eval $(call DEFINE_TARGET,aarch64-linux-android,aarch64-linux-android,arm64-v8a,arm,aarch64))
$(eval $(call DEFINE_TARGET,armv7-linux-androideabi,armv7a-linux-androideabi,armeabi-v7a,arm,armv7))
$(eval $(call DEFINE_TARGET,x86_64-linux-android,x86_64-linux-android,x86_64,x86_64,x86_64))
$(eval $(call DEFINE_TARGET,i686-linux-android,i686-linux-android,x86,x86,x86))
# Define all android deps builds
$(eval $(call NEW_ANDROID_DEPS_BUILD,AARCH64_LINUX_ANDROID))
$(eval $(call NEW_ANDROID_DEPS_BUILD,ARMV7_LINUX_ANDROIDEABI))
$(eval $(call NEW_ANDROID_DEPS_BUILD,X86_64_LINUX_ANDROID))
$(eval $(call NEW_ANDROID_DEPS_BUILD,I686_LINUX_ANDROID))
# Define all android builds
$(eval $(call NEW_ANDROID_BUILD,AARCH64_LINUX_ANDROID))
$(eval $(call NEW_ANDROID_BUILD,ARMV7_LINUX_ANDROIDEABI))
$(eval $(call NEW_ANDROID_BUILD,X86_64_LINUX_ANDROID))
$(eval $(call NEW_ANDROID_BUILD,I686_LINUX_ANDROID))
# Define all apple targets
$(eval $(call DEFINE_APPLE_TARGET,aarch64-apple-darwin,MAC_ARM64,arm64,arm,aarch64,$(APPLE_MACOSX),$(APPLE_MACOSX_PLATFORM),$(APPLE_MACOSX_SDK)))
$(eval $(call DEFINE_APPLE_TARGET,x86_64-apple-darwin,MAC,x86_64,x86_64,x86_64,$(APPLE_MACOSX),$(APPLE_MACOSX_PLATFORM),$(APPLE_MACOSX_SDK)))
$(eval $(call DEFINE_APPLE_TARGET,aarch64-apple-ios,OS64,arm64,arm,aarch64,$(APPLE_IOS),$(APPLE_IOS_PLATFORM),$(APPLE_IOS_SDK)))
$(eval $(call DEFINE_APPLE_TARGET,x86_64-apple-ios,SIMULATOR64,x86_64,x86_64,x86_64,$(APPLE_IOS),$(APPLE_IOS_SIMULATOR_PLATFORM),$(APPLE_IOS_SIMULATOR_SDK)))
$(eval $(call DEFINE_APPLE_TARGET,aarch64-apple-ios-sim,SIMULATORARM64,arm64,arm,aarch64,$(APPLE_IOS),$(APPLE_IOS_SIMULATOR_PLATFORM),$(APPLE_IOS_SIMULATOR_SDK)))
# Define all apple deps builds
$(eval $(call NEW_APPLE_DEPS_BUILD,AARCH64_APPLE_DARWIN))
$(eval $(call NEW_APPLE_DEPS_BUILD,X86_64_APPLE_DARWIN))
$(eval $(call NEW_APPLE_DEPS_BUILD,AARCH64_APPLE_IOS))
$(eval $(call NEW_APPLE_DEPS_BUILD,X86_64_APPLE_IOS))
$(eval $(call NEW_APPLE_DEPS_BUILD,AARCH64_APPLE_IOS_SIM))
# Define all apple builds
$(eval $(call NEW_APPLE_BUILD,AARCH64_APPLE_DARWIN))
$(eval $(call NEW_APPLE_BUILD,X86_64_APPLE_DARWIN))
$(eval $(call NEW_APPLE_BUILD,AARCH64_APPLE_IOS))
$(eval $(call NEW_APPLE_BUILD,X86_64_APPLE_IOS))
$(eval $(call NEW_APPLE_BUILD,AARCH64_APPLE_IOS_SIM))
# Define all apple framework builds (for release)
$(eval $(call NEW_APPLE_FRAMEWORK,$(APPLE_IOS_FRAMEWORK_TYPE),$(APPLE_IOS_FRAMEWORK_TARGETS),$(APPLE_IOS_PLATFORM),))
$(eval $(call NEW_APPLE_FRAMEWORK,$(APPLE_IOS_SIMULATOR_FRAMEWORK_TYPE),$(APPLE_IOS_SIMULATOR_FRAMEWORK_TARGETS),$(APPLE_IOS_SIMULATOR_PLATFORM),))
$(eval $(call NEW_APPLE_FRAMEWORK,$(APPLE_MACOSX_FRAMEWORK_TYPE),$(APPLE_MACOSX_FRAMEWORK_TARGETS),$(APPLE_MACOSX_PLATFORM),))
# Define WASM targets
$(eval $(call DEFINE_TARGET,wasm32-unknown-emscripten,emscripten,emscripten,x86,i686))
# Define WASM deps builds
$(eval $(call NEW_WASM_DEPS_BUILD,WASM32_UNKNOWN_EMSCRIPTEN))
# Define all WASM builds
$(eval $(call NEW_WASM_BUILD,WASM32_UNKNOWN_EMSCRIPTEN))
# Build apple module-map file
$(RUNTIME_FFI)/$(APPLE_BUILD)/$(MODULE_MAP): MODULE_NAME := $(DOTLOTTIE_PLAYER_MODULE)
$(RUNTIME_FFI)/$(APPLE_BUILD)/$(MODULE_MAP): UMBRELLA_HEADER := $(DOTLOTTIE_PLAYER_HEADER)
$(RUNTIME_FFI)/$(APPLE_BUILD)/$(MODULE_MAP): export OUTPUT_FILE := $(APPLE_MODULE_MAP_FILE)
$(RUNTIME_FFI)/$(APPLE_BUILD)/$(MODULE_MAP): $(RUNTIME_FFI)/$(RUNTIME_FFI_UNIFFI_BINDINGS)/$(SWIFT)
$(CREATE_OUTPUT_FILE)
.PHONY: demo-player
demo-player:
cargo build --manifest-path examples/demo-player/Cargo.toml
.PHONY: demo-state-machine
demo-state-machine:
cargo build --manifest-path examples/demo-state-machine/Cargo.toml
.PHONY: $(ANDROID)
$(ANDROID): $(ANDROID_BUILD_TARGETS)
.PHONY: $(APPLE)
$(APPLE): $(APPLE_BUILD_TARGETS)
.PHONY: pre-make-wasm
pre-make-wasm:
@echo "Copy Cargo.wasm.toml to Cargo.toml..."
@cp $(RUNTIME_FFI)/Cargo.wasm.toml $(RUNTIME_FFI)/Cargo.toml
.PHONY: post-make-wasm
post-make-wasm:
@echo "Reset Cargo.toml..."
@git -C $(RUNTIME_FFI) checkout -- Cargo.toml
.PHONY: $(WASM)
$(WASM):
@$(MAKE) pre-make-wasm
@$(MAKE) $(WASM_BUILD_TARGETS)
@$(MAKE) post-make-wasm
.PHONY: $(NATIVE)
$(NATIVE): $(RUNTIME_FFI)/target/$(RELEASE)/$(RUNTIME_FFI_LIB)
$(NATIVE_RELEASE)
.PHONY: all
all: $(APPLE) $(ANDROID) $(WASM) $(NATIVE)
.PHONY: deps
deps:
@git submodule update --init --recursive
# Cleanup extraneous files from the zlib dependency build...
.PHONY: clean-build
clean-build:
@git --git-dir=$(DEPS_MODULES_DIR)/$(ZLIB)/.git clean -fd &>/dev/null
@git --git-dir=$(DEPS_MODULES_DIR)/$(ZLIB)/.git checkout . &>/dev/null
.PHONY: clean-deps
clean-deps: clean-build
@rm -rf $(DEPS_BUILD_DIR) $(DEPS_ARTIFACTS_DIR)
.PHONY: clean
clean: clean-build
@rm -rf $(RELEASE)
@cargo clean --manifest-path $(CORE)/Cargo.toml
@cargo clean --manifest-path $(RUNTIME_FFI)/Cargo.toml
@rm -rf $(RUNTIME_FFI)/$(RUNTIME_FFI_UNIFFI_BINDINGS)