-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile.toml
1419 lines (1231 loc) · 43.3 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
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
env_scripts = [
'''
#!@duckscript
os = os_family
qtpaths_path = which qtpaths
if is_empty "${qtpaths_path}"
echo "qtpaths not in PATH"
qtpaths_path = set "/__/__"
end
qtdir = get_env QTDIR
if is_empty "${qtdir}"
qtdir = set "/__/__"
end
if not is_path_exists "${qtpaths_path}"
if is_path_exists "${qtdir}"
echo "QTDIR ${qtdir} exists, checking if qtpaths is present"
qtpaths_path = set ${qtdir}/bin/qtpaths
if not is_path_exists "${qtpaths_path}"
qtpaths_path = set ${qtdir}/qtpaths.exe
if not is_path_exists "${qtpaths_path}"
qtpaths_path = set ""
end
end
end
end
set_env QTPATHS_PATH "${qtpaths_path}"
num_processes = cpu_count
num_processes = calc ${num_processes} + 1
set_env NUM_PROCESSES "${num_processes}"
# set os specific env vars
set_env OS "${os}"
if eq ${os} windows
set_env STANDALONE_PY_URL "${PY_BASE_URL}/cpython-3.11.1+20230116-x86_64-pc-windows-msvc-shared-pgo-full.tar.zst"
set_env PYTHON "${WORKSPACE}\\py311\\python.exe"
set_env DIST_PYTHON "${WORKSPACE}\\py311-dist\\python"
set_env DIST_PYSIDE6_RCC "${WORKSPACE}\\py311-dist\\Lib\\site-packages\\PySide6\\rcc.exe"
set_env PYSIDE6_RCC "${WORKSPACE}\\py311\\Lib\\site-packages\\PySide6\\rcc.exe"
set_env BACKEND_WHEEL console_backend-0.1.0-cp311-cp311-win_amd64.whl
set_env BUILD_TRIPLET "x86_64-pc-windows-msvc"
set_env PYO3_CONFIG_FILE "${WORKSPACE}\\standalone-py\\pyo3_config.txt"
set_env CONSOLE_PYO3_CONFIG_FILE "${WORKSPACE}\\standalone-py\\pyo3_config.txt"
set_env PYSIDE_WHEEL fill_me_in.whl
set_env SHIBOKEN_WHEEL fill_me_in.whl
elseif eq ${os} linux
set_env STANDALONE_PY_URL "${PY_BASE_URL}/cpython-3.11.1+20230116-x86_64-unknown-linux-gnu-pgo+lto-full.tar.zst"
set_env PYTHON "${WORKSPACE}/py311/bin/python3"
set_env DIST_PYTHON "${WORKSPACE}/py311-dist/bin/python3"
set_env DIST_PYSIDE6_RCC "${WORKSPACE}/py311-dist/bin/pyside6-rcc"
set_env PYSIDE6_RCC "${WORKSPACE}/py311/bin/pyside6-rcc"
set_env BACKEND_WHEEL console_backend-0.1.0-cp311-cp311-linux_x86_64.whl
set_env PYO3_CONFIG_FILE "${WORKSPACE}/standalone-py/pyo3_config.txt"
set_env CONSOLE_PYO3_CONFIG_FILE "${WORKSPACE}/standalone-py/pyo3_config_console.txt"
output = exec --fail-on-error gcc -dumpmachine
triplet = trim ${output.stdout}
set_env BUILD_TRIPLET ${triplet}
set_env PYSIDE_WHEEL PySide6-\${qt_version}-\${qt_version}-cp311-cp311-linux_x86_64.whl
set_env SHIBOKEN_WHEEL shiboken6-\${qt_version}-\${qt_version}-cp311-cp311-linux_x86_64.whl
else
set_env STANDALONE_PY_URL "${PY_BASE_URL}/cpython-3.11.1+20230116-x86_64-apple-darwin-pgo+lto-full.tar.zst"
set_env PYTHON "${WORKSPACE}/py311/bin/python3"
set_env DIST_PYTHON "${WORKSPACE}/py311-dist/bin/python3"
set_env DIST_PYSIDE6_RCC "${WORKSPACE}/py311-dist/bin/pyside6-rcc"
set_env PYSIDE6_RCC "${WORKSPACE}/py311/bin/pyside6-rcc"
set_env BACKEND_WHEEL console_backend-0.1.0-cp311-cp311-macosx_10_15_x86_64.whl
set_env PYO3_CONFIG_FILE "${WORKSPACE}/standalone-py/pyo3_config.txt"
set_env CONSOLE_PYO3_CONFIG_FILE "${WORKSPACE}/standalone-py/pyo3_config_console.txt"
output = exec --fail-on-error gcc -dumpmachine
triplet = trim ${output.stdout}
set_env BUILD_TRIPLET ${triplet}
set_env PYSIDE_WHEEL PySide6-\${qt_version}-\${qt_version}-cp311-cp311-macosx_12_x86_64.whl
set_env SHIBOKEN_WHEEL shiboken6-\${qt_version}-\${qt_version}-cp311-cp311-macosx_12_x86_64.whl
end
''',
]
[config]
default_to_workspace = false
init_task = "init"
skip_git_env_info = true
skip_rust_env_info = true
skip_crate_env_info = true
[env]
WORKSPACE = "${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}"
PY_BASE_URL = "https://github.com/indygreg/python-build-standalone/releases/download/20230116"
MACOSX_DEPLOYMENT_TARGET = "10.15"
APP_NAME = "swift-console"
QT_VERSION = "6.4.3" # Also needs to be updated in .github/workflows/main.yml
CARGO_MAKE_TOOL_PROJECT_NAME = "swift-console-tools"
[env.'release+mac_intel']
CARGO_MAKE_RELEASE_FLOW_TARGET = "x86_64-apple-darwin"
[env.'release+mac_arm']
CARGO_MAKE_RELEASE_FLOW_TARGET = "aarch64-apple-darwin"
[env.'release+x86_64']
CARGO_MAKE_RELEASE_FLOW_TARGET = "x86_64-unknown-linux-gnu"
[env.'release+aarch64']
CARGO_MAKE_RELEASE_FLOW_TARGET = "aarch64-unknown-linux-gnu"
#
[tasks.init]
# Two proposed methods of simplifying path globbing # https://github.com/sagiegurari/cargo-make/issues/542 # https://github.com/sagiegurari/cargo-make/issues/543
[tasks.set-qml-files]
private = true
condition = { env_not_set = ["QML_FILES"] }
script_runner = "@duckscript"
script = '''
!include_files ./utils/glob.ds
qml_files = glob_paths_excluding_target resources/**/*.qml
set_env QML_FILES ${qml_files}
'''
[tasks.set-qml-app]
private = true
condition = { env_not_set = ["QT_APP"] }
script_runner = "@duckscript"
script = '''
python = get_env PYTHON
output = exec ${python} utils/echo-qt-dir.py
qt_app = trim ${output.stdout}
set_env QT_APP ${qt_app}
'''
[tasks.set-python-files]
private = true
condition = { env_not_set = ["PYTHON_FILES"] }
script_runner = "@duckscript"
script = '''
!include_files ./utils/glob.ds
py_files = glob_paths_excluding_target ./**/*.py
set_env PYTHON_FILES ${py_files}
'''
[tasks.rustup-update]
command = "rustup"
args = ["update", "stable"]
[tasks.cargo-make-deps-update]
dependencies = ["rustup-update"]
script = '''
cargo install [email protected] --locked
'''
[tasks.generate-common-constants-rs]
script_runner = "@duckscript"
script = '''
python = get_env PYTHON
exec ${python} -m py2many --rust=1 swiftnav_console/constants.py
mv swiftnav_console/constants.rs console_backend/src/common_constants.rs
'''
[tasks.extract-piksi-constants-rs]
script_runner = "@duckscript"
script = '''
python = get_env PYTHON
output = exec --fail-on-error ${python} utils/extract_piksi_tools_constants.py
writefile /tmp/piksi_tools_constants.py ${output.stdout}
exec --fail-on-error ${python} -m py2many --rust=1 /tmp/piksi_tools_constants.py --outdir console_backend/src/
'''
[tasks.check-python-exists]
script_runner = "@duckscript"
script = '''
if not is_path_exists py311
echo "'cargo make setup-builder' needs to be run first."
end
'''
[tasks.dist-generate-resources]
dependencies = ["build-splash-version", "map-js-token"]
command = "${DIST_PYSIDE6_RCC}"
args = [
"resources/console_resources.qrc",
"-o",
"swiftnav_console/console_resources.py",
"-g",
"python",
]
[tasks.generate-resources]
dependencies = ["build-splash-version", "map-js-token"]
script_runner = "@duckscript"
script = '''
exec --fail-on-error "${PYSIDE6_RCC}" "resources/console_resources.qrc" "-o" "swiftnav_console/console_resources.py" "-g" "python"
'''
[tasks.check-capnp]
script_runner = "@shell"
script = '''
capnp compile -oc++ src/main/resources/base/console_backend.capnp
rm src/main/resources/base/console_backend.capnp.c++
rm src/main/resources/base/console_backend.capnp.h
'''
[tasks.copy-capnp]
dependencies = ["check-capnp"]
script_runner = "@shell"
script = '''
cp src/main/resources/base/console_backend.capnp console_backend/console_backend.capnp
'''
[tasks.remove-egg-dist]
script_runner = "@shell"
script = '''
rm -rf console_backend/*.dist-info
rm -rf console_backend/*.egg-info
'''
[tasks.remove-egg-dist.windows]
script_runner = "powershell"
script_extension = "ps1"
script = '''
Get-ChildItem .\console_backend -Recurse -Include @("*.egg-info", "*.dist-info") | Remove-Item -Force -Recurse
'''
[tasks.start-console]
command = "${PYTHON}"
args = ["-m", "swiftnav_console.main", "${@}"]
[tasks.start-console-callgrind]
command = "valgrind"
args = ["--tool=callgrind", "${PYTHON}", "-m", "swiftnav_console.main", "${@}"]
[tasks.start-console-cprofile]
command = "${PYTHON}"
args = ["-m", "cProfile", "-m", "swiftnav_console.main", "${@}"]
[tasks.start-console-gdb]
command = "rust-gdb"
args = [
"-ex",
"run",
"--args",
"${PYTHON}",
"-m",
"swiftnav_console.main",
"${@}",
]
[tasks.qml-run]
dependencies = ["check-python-exists", "generate-resources"]
run_task = "start-console"
[tasks.prepare-run]
dependencies = [
"check-python-exists",
"copy-capnp",
"generate-resources",
"remove-egg-dist",
"store-version",
"install-backend",
]
[tasks.run]
dependencies = ["prepare-run"]
run_task = "start-console"
[tasks.gdb-run]
dependencies = ["prepare-run"]
run_task = "start-console-gdb"
[tasks.callgrind-run]
dependencies = ["prepare-run"]
run_task = "start-console-callgrind"
[tasks.cprofile-run]
dependencies = ["prepare-run"]
run_task = "start-console-cprofile"
[tasks.prod-run]
dependencies = [
"check-python-exists",
"copy-capnp",
"generate-resources",
"remove-egg-dist",
"store-version",
"prod-install-backend",
]
run_task = "start-console"
[tasks.headless-run]
command = "cargo"
args = [
"run",
"--bin",
"headless-console",
"--release",
"--no-default-features",
"${@}",
]
[tasks.store-version]
script_runner = "@shell"
script = '''
git describe --tags --always > console_backend/src/version.txt
'''
[tasks.install-backend]
command = "${PYTHON}"
args = ["-m", "pip", "install", "-e", "./console_backend"]
[tasks.prod-install-backend]
command = "${PYTHON}"
args = [
"-m",
"pip",
"install",
"-v",
"--upgrade",
"--force",
"./console_backend",
]
[tasks.dist-install-pip-flit]
command = "${DIST_PYTHON}"
args = ["-m", "pip", "install", "flit"]
[tasks.check-git-status]
command = "git"
args = ["status"]
[tasks.build-frontend-wheel]
dependencies = ["dist-install-pip-flit", "check-git-status"]
command = "${DIST_PYTHON}"
args = ["-m", "flit", "build", "--no-setup-py"]
[tasks.dist-install-pip-setuptools-rust]
command = "${DIST_PYTHON}"
args = ["-m", "pip", "install", "setuptools_rust"]
[tasks.build-backend-wheel]
dependencies = ["dist-install-pip-setuptools-rust"]
cwd = "console_backend"
command = "${DIST_PYTHON}"
args = ["setup.py", "-vv", "bdist_wheel"]
[tasks.clean-backend]
dependencies = ["dist-install-pip-setuptools-rust"]
cwd = "console_backend"
command = "${DIST_PYTHON}"
args = ["setup.py", "-vv", "clean"]
[tasks.get-get-pip]
script_runner = "@duckscript"
script = '''
wget -O ./get-pip.py https://bootstrap.pypa.io/get-pip.py
'''
[tasks.write-pyo3-config-console]
script_runner = "@duckscript"
cwd = "standalone-py"
condition = { files_not_exist = ["${CONSOLE_PYO3_CONFIG_FILE}"] }
script = '''
writefile pyo3_config_console.txt "implementation=CPython\nversion=3.11\nshared=true\nabi3=false\nlib_name=python3.11\nlib_dir=${WORKSPACE}/standalone-py/python/install/lib\nexecutable=${WORKSPACE}/standalone-py/python/install/bin/python3.11\npointer_width=64\nbuild_flags=WITH_THREAD\nsuppress_build_script_link_lines=false\nextra_build_script_line=cargo:rustc-link-lib=python3.11\nextra_build_script_line=cargo:rustc-link-search=${WORKSPACE}/standalone-py/python/install/lib\n"
'''
[tasks.write-pyo3-config-console.windows]
script_runner = "@duckscript"
script = ""
[tasks.write-pyo3-config]
script_runner = "@duckscript"
cwd = "standalone-py"
condition = { files_not_exist = ["${PYO3_CONFIG_FILE}"] }
script = '''
writefile pyo3_config.txt "implementation=CPython\nversion=3.11\nshared=true\nabi3=false\nlib_name=python3.11\nlib_dir=${WORKSPACE}/standalone-py/python/install/lib\nexecutable=${WORKSPACE}/standalone-py/python/install/bin/python3.11\npointer_width=64\nbuild_flags=WITH_THREAD\nsuppress_build_script_link_lines=false\nextra_build_script_line=\n"
'''
[tasks.write-pyo3-config.windows]
script_runner = "@duckscript"
cwd = "standalone-py"
condition = { files_not_exist = ["${PYO3_CONFIG_FILE}"] }
script = '''
writefile pyo3_config.txt "implementation=CPython\nversion=3.11\nshared=true\nabi3=false\nlib_name=python311\nlib_dir=${WORKSPACE}\\standalone-py\\python\\install\\libs\nexecutable=${WORKSPACE}\\standalone-py\\python\\install\\python.exe\npointer_width=64\nbuild_flags=WITH_THREAD\nsuppress_build_script_link_lines=false\nextra_build_script_line=\n"
'''
[tasks.get-standalone-py]
dependencies = ["get-get-pip", "write-pyo3-config"]
cwd = "standalone-py"
condition = { files_not_exist = ["${WORKSPACE}/standalone-py/python"] }
script_runner = "@duckscript"
script = '''
wget -O py311.tar.zst ${STANDALONE_PY_URL}
exec --fail-on-error zstd -f -d py311.tar.zst
exec --fail-on-error tar -xf py311.tar
'''
[tasks.get-qt-version]
script_runner = "@duckscript"
script = '''
qtpaths_path_exists = is_path_exists "${QTPATHS_PATH}"
assert ${qtpaths_path_exists} "Couldn't find qtpaths executable.\nPlease install the desired Qt version from qt.io, and make sure that the bin directory is in the path.\nFor more information see README.debug.md."
qtpaths_output = exec --fail-on-error ${QTPATHS_PATH} -query QT_VERSION
qt_version = trim ${qtpaths_output.stdout}
set_env QT_VERSION ${qt_version}
# Now that we know the Qt version, expand PYSIDE_WHEEL and SHIBOKEN_WHEEL env
# vars to insert the qt version.
pyside_wheel = eval set_env PYSIDE_WHEEL ${PYSIDE_WHEEL}
shiboken_wheel = eval set_env SHIBOKEN_WHEEL ${SHIBOKEN_WHEEL}
'''
[tasks.setup-builder]
dependencies = ["get-standalone-py"]
script_runner = "@duckscript"
script = '''
if is_path_exists py311
rm -r py311
end
mkdir py311
cd standalone-py/python/install
cp . ../../../py311
cd ../../../
exec --fail-on-error ${PYTHON} ./get-pip.py
exec --fail-on-error ${PYTHON} -m pip install wheel flit . ".[test]" ".[ssh-tunnel]"
# If pyside-setup exists, then assume user wants to build and install pyside6
if is_path_exists "${WORKSPACE}/pyside-setup/setup.py"
cm_run_task get-qt-version
cm_run_task build-install-pyside
else
exec --fail-on-error ${PYTHON} -m pip install PySide6==${QT_VERSION}
end
cm_run_task generate-resources
'''
[tasks.prep-dist]
script_runner = "@duckscript"
script = '''
cm_run_task copy-capnp
cm_run_task store-version
if is_path_exists py311-dist
rm -r py311-dist
end
mkdir py311-dist
cd standalone-py/python/install/
cp . ../../../py311-dist
cd ../../..
exec --fail-on-error ${DIST_PYTHON} ./get-pip.py
# If pyside-setup exists, then assume user wants to build and install pyside6
if is_path_exists "${WORKSPACE}/pyside-setup/setup.py"
# This will install to both dist and non-dist python
cm_run_task build-dist-install-pyside
else
exec --fail-on-error ${DIST_PYTHON} -m pip install PySide6==${QT_VERSION}
end
'''
[tasks.install-imagemagick]
[tasks.install-imagemagick.windows]
script_runner = "@duckscript"
script = '''
wget -O imagemagick.tool.7.1.0.nupkg https://github.com/swift-nav/swift-toolchains/releases/download/imagemagick-7.1.0/imagemagick.tool.7.1.0.nupkg
exec --fail-on-error choco install -q -y --side-by-side vcredist2010 --version=10.0.40219.32503
exec --fail-on-error choco install -q -y imagemagick.tool --version="7.1.0" --source="."
rm imagemagick.tool.7.1.0.nupkg
'''
[tasks.install-imagemagick.linux]
script = "sudo apt-get install gsfonts imagemagick ghostscript fonts-freefont-otf"
[tasks.install-imagemagick.mac]
script = "brew install imagemagick"
[tasks.build-splash-version]
script_runner = "@duckscript"
script = '''
output = exec --fail-on-error git describe --always --tags --dirty
version = trim ${output.stdout}
os = os_family
if eq ${os} windows
echo "Creating splash screen (OS: Windows, font: Arial)"
exec --fail-on-error magick convert -font ./utils/arial.ttf -pointsize 14 -fill "#FFA400" -gravity south -annotate +0+5 ${version} ./resources/images/splash.jpg ./resources/images/splash-version.jpg
else
echo "Creating splash screen (OS: Linux/macOS, font: Arial)"
exec --fail-on-error convert -font ./utils/arial.ttf -pointsize 14 -fill "#FFA400" -gravity south -annotate +0+5 ${version} ./resources/images/splash.jpg ./resources/images/splash-version.jpg
end
'''
[tasks.build-windowpos-bin]
dependencies = ["build-splash-version"]
command = "cargo"
args = [
"build",
"--release",
"-vv",
"--features",
"winit",
"--bin",
"windowpos",
]
[tasks.build-console-bin]
command = "cargo"
args = [
"build",
"--release",
"-vv",
"--features=entrypoint",
"--bin",
"${APP_NAME}",
]
[tasks.build-console-bin.linux]
dependencies = ["build-windowpos-bin"]
command = "cargo"
args = [
"build",
"--release",
"-vv",
"--features",
"entrypoint,splash",
"--bin",
"${APP_NAME}",
]
[tasks.build-console]
env = { PYO3_CONFIG_FILE = "${CONSOLE_PYO3_CONFIG_FILE}" }
dependencies = ["write-pyo3-config-console"]
run_task = "build-console-bin"
[tasks.build-console.windows]
dependencies = ["build-console-bin"]
[tasks.build-dist-install-console]
dependencies = ["build-console"]
script_runner = "@duckscript"
script = '''
app_name = get_env APP_NAME
cp target/release/${app_name} py311-dist/${app_name}
os = os_family
if eq ${os} mac
exec --fail-on-error install_name_tool -change /install/lib/libpython3.11.dylib @rpath/libpython3.11.dylib py311-dist/${app_name}
exec --fail-on-error install_name_tool -add_rpath @executable_path/../Resources/lib py311-dist/${app_name}
exec --fail-on-error install_name_tool -add_rpath @executable_path/lib py311-dist/${app_name}
cd py311-dist
echo "START OF QTWEBENGINE TRANSLATIONS DISTRIBUTION"
mkdir ./lib/python3.11/site-packages/PySide6/Qt/translations
mv ./lib/python3.11/site-packages/PySide6/Qt/lib/QtWebEngineCore.framework/Resources/qtwebengine_locales ./lib/python3.11/site-packages/PySide6/Qt/translations
echo "START OF QTWEBENGINE RESOURCE DISTRIBUTION"
mkdir ./lib/python3.11/site-packages/PySide6/Qt/resources
web_resources = glob_array ./lib/python3.11/site-packages/PySide6/Qt/lib/QtWebEngineCore.framework/Resources/*
for r in ${web_resources}
mv ${r} ./lib/python3.11/site-packages/PySide6/Qt/resources
end
elseif eq ${os} linux
cp target/release/windowpos py311-dist/windowpos
end
'''
[tasks.build-dist-install-console.windows]
script = '''
cp target/release/${APP_NAME}.exe py311-dist/${APP_NAME}.exe
cp target/release/${APP_NAME}.d py311-dist/${APP_NAME}.d
if is_path_exists target/release/swift_console.pdb
cp target/release/swift_console.pdb py311-dist/swift_console.pdb
end
cp target/release/console_backend.pdb py311-dist/Lib/site-packages/console_backend/console_backend.pdb
'''
[tasks.build-dist-install-frontend-wheel]
env = { USE_PYTHON = "${DIST_PYTHON}" }
dependencies = ["build-frontend-wheel"]
script_runner = "@duckscript"
script = '''
exec --fail-on-error ${DIST_PYTHON} -m pip install ./dist/swiftnav_console-0.1.0-py3-none-any.whl --force-reinstall
'''
[tasks.build-dist-install-backend-wheel]
dependencies = ["build-backend-wheel"]
command = "${DIST_PYTHON}"
args = ["-m", "pip", "install", "console_backend/dist/${BACKEND_WHEEL}"]
[tasks.build-dist-copy-resources]
script_runner = "@duckscript"
script = '''
cp src/main/resources py311-dist/
os = os_family
glob_cp binaries/${os}/rtcm3tosbp* py311-dist/binaries/${os}
'''
[tasks.build-dist-freeze]
script_runner = "@duckscript"
script = '''
touch ./py311-dist/.frozen
'''
[tasks.pre-build-dist]
dependencies = [
"setup-builder",
"prep-dist",
"build-dist-copy-resources",
"build-dist-freeze",
]
[tasks.prep-debug-pyside]
condition = { files_not_exist = ["${WORKSPACE}/pyside-setup/setup.py"] }
dependencies = ["get-qt-version"]
script_runner = "@duckscript"
script = '''
qt_version = get_env QT_VERSION
exec --fail-on-error git clone -b v${qt_version} http://code.qt.io/pyside/pyside-setup.git
exec --fail-on-error git -C pyside-setup am ../utils/pyside-setup-6.3-includepy-fallback.patch
'''
[tasks.build-pyside]
condition = { files_not_exist = [
"${WORKSPACE}/pyside-setup/dist/${PYSIDE_WHEEL}",
] }
dependencies = ["prep-debug-pyside"]
cwd = "pyside-setup"
script_runner = "@duckscript"
script = '''
# Note: To make build-install-pyside work on Windows, you need to run from a powershell or cmd shell
# that is a VS2019 or other visual studio command line (vcvars*.bat needs to be sourced).
# To set up a powershell with the Visual Studio environment, run these two commands:
# Import-Module "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
# Enter-VsDevShell -VsInstanceId fdbeecbc -SkipAutomaticLocation -DevCmdArguments '-arch=x64 -no_logo'
qtpaths_path = get_env QTPATHS_PATH
qt_version = get_env QT_VERSION
exec --fail-on-error ${PYTHON} -m pip install -r requirements.txt
exec --fail-on-error ${PYTHON} setup.py bdist_wheel --debug --qt ${qt_version} --qtpaths=${qtpaths_path} --parallel=${NUM_PROCESSES} --no-examples --skip-docs --module-subset Core,Network,Gui,Qml,OpenGL,Quick,QuickControls2,Widgets,Charts
'''
[tasks.build-dist-install-pyside]
dependencies = ["build-pyside"]
script_runner = "@duckscript"
script = '''
exec --fail-on-error ${DIST_PYTHON} -m pip install setuptools wheel packaging
exec --fail-on-error ${DIST_PYTHON} -m pip install --force-reinstall ${WORKSPACE}/pyside-setup/dist/${SHIBOKEN_WHEEL} ${WORKSPACE}/pyside-setup/dist/${PYSIDE_WHEEL}
'''
[tasks.build-install-pyside]
dependencies = ["build-pyside"]
script_runner = "@duckscript"
script = '''
exec --fail-on-error ${PYTHON} -m pip install --force-reinstall ${WORKSPACE}/pyside-setup/dist/${SHIBOKEN_WHEEL} ${WORKSPACE}/pyside-setup/dist/${PYSIDE_WHEEL}
'''
[tasks.build-dist]
script_runner = "@duckscript"
script = '''
if is_path_exists ${DIST_PYTHON}
output = exec --fail-on-error ${DIST_PYTHON} -m pip freeze
out = set ${output.stdout}
a = contains "${out}" "PySide6=="
if not ${a}
cm_run_task pre-build-dist
end
else
cm_run_task pre-build-dist
end
cm_run_task dist-generate-resources
cm_run_task build-dist-install-frontend-wheel
cm_run_task build-dist-install-backend-wheel
cm_run_task build-dist-install-console
'''
[tasks.purge-dist]
env = { PYTHONDONTWRITEBYTECODE = "1" }
cwd = "py311-dist"
script_runner = "@duckscript"
script = '''
py_folders = array test tests examples __pycache__ demos turtledemo idlelib lib/tcl8 lib/tcl8.6 lib/tk8.6 shiboken6/docs ensurepip lib2to3 tkinter unittest include
qt_folders = array plugins/geoservices plugins/virtualkeyboard plugins/sqldrivers lib/Tix8.4.3 tcl/tix8.4.3
qml_folders = array qml/QtBluetooth* qml/QtNfc* qml/QtGamepad qml/QtTest qml/QtQuick3D qml/Qt3D qml/QtSensors qml/QtLocation
all_folders = array_concat ${py_folders} ${qt_folders} ${qml_folders}
for name in ${all_folders}
folders = glob_array **/${name}/
for folder in ${folders}
rm -r ${folder}
end
end
file_exts = array pyc pyi tcl gif png
for ext in ${file_exts}
files = glob_array **/*.${ext}
for file in ${files}
if eq ${ext} png
is_qtquick = contains ${file} QtQuick
if not is_qtquick
rm ${file}
end
else
rm ${file}
end
end
end
libs_a = array Qt3D QtBluetooth QtCconcurrent QtDataVisualization QtDesigner QtHelp QtMultimedia QtNfs
libs_b = array QtQuick3D QtRemoteObjects QtScxml QtSensors QtSerialPort QtSql QtStateMachine QtTest QtUiTools QtXml
libs = array_concat ${libs_a} ${libs_b}
for lib in ${libs}
files = glob_array ./**/*${lib}*
for file in ${files}
echo ${file}
rm -r ${file}
end
end
os = os_family
if eq ${os} windows
rm -r ./Scripts
rm -r ./include
rm -r ./tcl
globs = array _test*.pyd libcrypto*.dll libssl*.dll tcl*.dll tk*.dll
for glob in ${globs}
files = glob_array ./DLLs/${glob}
for file in ${files}
rm ${file}
end
end
qtbins = glob_array ./Lib/site-packages/PySide6/*.exe
for bin in ${qtbins}
if not contains ${bin} "QtWebEngineProcess"
rm ./Lib/site-packages/PySide6/${bin}
end
end
all_dlls = glob_array ./**/*.dll
for dll in ${all_dlls}
if ends_with ${dll} "d.dll"
dll_no_debug = substring ${dll} -5 # remove d.dll
dll_no_debug = concat ${dll_no_debug} ".dll"
if is_path_exists ${dll_no_debug}
rm ${dll}
end
end
end
elseif eq ${os} mac
rm -r ./share
rm -r ./lib/python3.11/site-packages/PySide6/Qt/libexec
bins = array qmllint lupdate lrelease scripts qmlls qmlformat
for bin in ${bins}
files = glob_array ./lib/python3.11/site-packages/PySide6/${bin}
for bin in ${files}
rm -r ${bin}
end
end
# The Mac signing process needed to be fine tuned. There were a bunch of variations in the paths
# that we purge or sign which needed fixing. Also there were quite a few "Resources" folders buried
# within all of the PySide6 .framework files that were causing issues with the signing. I'm not sure
# if it was simply due to the folder named "Resources" or that each folder contained an Info.plist file.
# That being said after deleting them the app runs fine and passes the mac signing gauntlet.
# See: https://stackoverflow.com/a/29271922/12265938
echo "REMOVING EXCESS RESOURCES"
resources_a = glob_array ./lib/python3.11/site-packages/PySide6/Qt/lib/*.framework/Versions/A/Resources
resources_b = glob_array ./lib/python3.11/site-packages/PySide6/Qt/lib/*.framework/Resources
resources = array_concat ${resources_a} ${resources_b}
for dir in ${resources}
rm -r ${dir}
end
# remove helper directory since this exists relatively at
# ./lib/python3.11/site-packages/PySide6/Qt/lib/QtWebEngineCore.framework/Versions/A/Helpers
rm -r ./lib/python3.11/site-packages/PySide6/Qt/lib/QtWebEngineCore.framework/Helpers
else
rm -r ./share
bins = array rcc uic designer pyside6-lupdate Designer.app qmllint qmlls qmlformat
for bin in ${bins}
files = glob_array ./**/PySide6/${bin}
for bin in ${files}
rm -r ${bin}
end
end
end
exec --fail-on-error ${DIST_PYTHON} -m pip uninstall -y pip setuptools wheel flit
exec --fail-on-error ${DIST_PYTHON} -m compileall -b -f -o 1 -o 2 .
if eq ${os} windows
globs = array pyexpat.* sqlite3.* _ctypes_test.* _bz2.* _decimal.* _elementtree.* _multiprocessing.* _sqlite3.* _ssl.* _tkinter.* _uuid.* _zoneinfo.* _msi.* _test*.*
for glob in ${globs}
files = glob_array ./DLLs/${glob}
for file in ${files}
rm ${file}
end
files = glob_array ./libs/${glob}
for file in ${files}
rm ${file}
end
end
else
globs = array *.a
for glob in ${globs}
files = glob_array ./lib/**/${glob}
for file in ${files}
rm ${file}
end
end
endif
if eq ${os} mac
rm -r lib/python3.11/site-packages/PySide6/Designer.app/
rm -r lib/python3.11/site-packages/PySide6/Assistant.app/
rm -r lib/python3.11/site-packages/PySide6/Linguist.app/
rm lib/python3.11/lib-dynload/_testcapi.cpython-311-darwin.so
rm lib/python3.11/lib-dynload/xxlimited.cpython-311-darwin.so
rm -r lib/python3.11/venv/
rm -r lib/pkgconfig/
rm -r lib/thread2.8.5/
endif
py_internal_libs = array Lib/email Lib/distutils Lib/http Lib/multiprocessing Lib/msilib Lib/http Lib/dbm Lib/curses Lib/xml Lib/xmlrpc Lib/ensurepip Lib/venv Lib/wsgiref Lib/lib2to3
for name in ${py_internal_libs}
folders = glob_array **/${name}/
for folder in ${folders}
rm -r ${folder}
end
end
files = glob_array ./**/*.py
for file in ${files}
rm ${file}
end
'''
[tasks.strip-dist-pdb.windows]
cwd = "py311-dist"
script_runner = "@duckscript"
script = '''
files = glob_array **/*.pdb
for file in ${files}
echo "Removing ${file}..."
rm -f ${file}
end
'''
[tasks.strip-dist]
script_runner = "@duckscript"
script = '''
app_name = get_env APP_NAME
exec --fail-on-error strip ./py311-dist/${app_name}
rm -r ./py311-dist/bin
'''
[tasks.strip-dist.windows]
script_runner = "@duckscript"
script = '''
cm_run_task strip-dist-pdb
app_name = get_env APP_NAME
exec --fail-on-error strip.exe ./py311-dist/${app_name}.exe
rm ./py311-dist/python.exe
rm ./py311-dist/pythonw.exe
'''
[tasks.compress-dist]
env = { ARCHIVE_NAME = "swift-toolbox" }
script_runner = "@duckscript"
script = '''
output = exec --fail-on-error date +%Y-%m-%d
date = trim ${output.stdout}
output = exec --fail-on-error git describe --always --tags --dirty
version = trim ${output.stdout}
output_name = set "${ARCHIVE_NAME}-${version}-${BUILD_TRIPLET}-${date}"
exec --fail-on-error tar -C "py311-dist" -cvf "${output_name}-debug.tar" .
cm_run_task strip-dist
exec --fail-on-error tar -C "py311-dist" -cvf "${output_name}.tar" .
exec --fail-on-error rm -f "${output_name}.tar.xz"
exec --fail-on-error xz -T 0 -e -9 "${output_name}-debug.tar"
exec --fail-on-error xz -T 0 -e -9 "${output_name}.tar"
'''
[tasks.create-dist]
run_task = [{ name = ["build-dist", "purge-dist", "compress-dist"] }]
[tasks.dist-to-installer]
[tasks.create-mac-icns-file]
script_runner = "@duckscript"
script = '''
exec --fail-on-error iconutil --convert icns ./installers/macOS/desktop-icon.iconset --output ./installers/macOS/icon.icns
'''
[tasks.dist-to-installer-env]
[tasks.dist-to-installer-env.mac]
script_runner = "@duckscript"
script = '''
app_name = get_env APP_NAME
set_env FINAL_DIR "installers/macOS"
set_env TMP_DIR "target/installer"
set_env CONTENTS_MACOS_DIR "MacOS"
set_env CONTENTS_RESOURCES_DIR "Resources"
set_env APP_FILE_PREFIX "Swift Console"
set_env APP_ORIGINAL_NAME "${app_name}"
set_env VERSION_PATH "console_backend/src/version.txt"
set_env INFO_PLIST_PATH "installers/macOS/Info.plist"
set_env ICNS_PATH "installers/macOS/icon.icns"
set_env BACKGROUND_PATH "resources/images/LogoBackground.jpg"
'''
[tasks.dist-to-installer-app]
[tasks.dist-to-installer-app.mac]
dependencies = ["dist-to-installer-env", "store-version"]
script_runner = "@duckscript"
script = '''
final_dir = get_env FINAL_DIR
tmp_dir = get_env TMP_DIR
app_original_name = get_env APP_ORIGINAL_NAME
app_file_prefix = get_env APP_FILE_PREFIX
app_dir_name = set "${app_file_prefix}.app"
contents_dir = set ${tmp_dir}/${app_dir_name}/Contents
contents_mac_os = get_env CONTENTS_MACOS_DIR
contents_mac_os = set ${contents_dir}/${contents_mac_os}
contents_resources_dir = get_env CONTENTS_RESOURCES_DIR
contents_resources_dir = set ${contents_dir}/${contents_resources_dir}
info_plist_path = get_env INFO_PLIST_PATH
icns_path = get_env ICNS_PATH
version_path = get_env VERSION_PATH
version = readfile ${version_path}
version = trim_end ${version}
if is_path_exists ${tmp_dir}
rm -r ${tmp_dir}
end
mkdir ${contents_dir}
mkdir ${contents_mac_os}
exec --fail-on-error cp -r py311-dist "${contents_resources_dir}"
exec --fail-on-error mv ./${contents_resources_dir}/${app_original_name} "./${contents_mac_os}/${app_file_prefix}"
cp ./${info_plist_path} ./${contents_dir}/Info.plist
exec --fail-on-error sed -i "" -e "s/@@VERSION@@/${version}/g" "${contents_dir}/Info.plist"
mkdir ${contents_resources_dir}
cp ${icns_path} ./${contents_resources_dir}/${app_file_prefix}.icns
'''
[tasks.dist-to-installer-dmg]
[tasks.dist-to-installer-dmg.mac]
dependencies = ["dist-to-installer-env"]
script_runner = "@duckscript"
script = '''
final_dir = get_env FINAL_DIR
tmp_dir = get_env TMP_DIR
app_original_name = get_env APP_ORIGINAL_NAME
app_file_prefix = get_env APP_FILE_PREFIX
app_dir_name = set "${app_file_prefix}.app"
icns_path = get_env ICNS_PATH
background_path = get_env BACKGROUND_PATH
version_path = get_env VERSION_PATH
version = readfile ${version_path}
version = trim_end ${version}
dmg_path = set ./${final_dir}/${app_original_name}_${version}_macos.dmg
old_dmgs = glob_array "./${final_dir}/*.dmg"
for path in ${old_dmgs}
rm ${path}
end
exec --fail-on-error create-dmg --volname "${app_file_prefix}" --volicon "${icns_path}" --background "${background_path}" --hdiutil-verbose --window-pos 200 120 --window-size 800 400 --icon-size 100 --icon "${app_dir_name}" 200 190 --hide-extension "${app_dir_name}" --app-drop-link 600 185 "${dmg_path}" "${tmp_dir}"
'''
[tasks.dist-to-installer.mac]
dependencies = ["dist-to-installer-app", "dist-to-installer-dmg"]
[tasks.dist-to-installer-env.linux]
script_runner = "@duckscript"
script = '''
app_name = get_env APP_NAME
set_env TMP_DIR "target/installer"
set_env OPT_DIR "opt"
set_env USR_DIR "usr"
set_env APP_DIR_NAME "${app_name}"
set_env APPS_DIR "share/applications"
set_env ICONS_DIR "share/icons/hicolor"
version = readfile console_backend/src/version.txt
version = trim_end ${version}
set_env VERSION ${version}
set_env VLESS_VERSION ${version}
if starts_with ${version} v
vless_version = substring ${version} 1