-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_dev.bat
1339 lines (976 loc) · 41.7 KB
/
install_dev.bat
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
@echo off
set ERROR_RETURN=0
:: Installer paths
:: NOTE: %7 is an input in batch script, so using 'S' to indicate '7' in "7-Zip"
set SZ_INSTALLER=7z.msi
set ARIA2_INSTALLER=aria2.zip
set GIT_INSTALLER=GitSetup.exe
set MSVC_INSTALLER=vs_BuildTools.exe
set LLVM_INSTALLER=LLVM-win64.exe
set CMAKE_INSTALLER=cmake-windows.msi
set NINJA_INSTALLER=ninja-win.zip
set CCACHE_INSTALLER=ccache-x86_64.zip
set MAKE_INSTALLER=make.exe
set PYTHON_INSTALLER=python-amd64.exe
set NODEJS_INSTALLER=node-x64.msi
set VSCODE_INSTALLER=VSCodeSetup.exe
set MSYS2_INSTALLER=msys2.exe
set OVPN_INSTALLER=openvpn.msi
:: Common fullpaths
:: fresh installation with registry update will no be reflected in current cmd session
:: Rerunning this script will not have new PATH included
set SZ_FULLPATH=%ProgramFiles%\7-Zip
set ARIA2_FULLPATH=%ProgramFiles%\aria2
set PTTB_FULLPATH=%ProgramFiles%\pttb
:: Do not use 3.11, there is a module bug requiring MSVC, which should never be the case with Python modules
set PYTHON_PATH=Python310
set PYTHON_FULLPATH=%ProgramFiles%\%PYTHON_PATH%
set PIP_FULLPATH=%PYTHON_FULLPATH%\Scripts
set NODEJS_FULLPATH=%ProgramFiles%\nodejs
set SZ_EXE=%SZ_FULLPATH%\7z.exe
set ARIA2_EXE=%ARIA2_FULLPATH%\aria2c.exe
set PTTB_EXE=%PTTB_FULLPATH%\pttb.exe
set PYTHON_EXE=%PYTHON_FULLPATH%\python.exe
set PIP_EXE=%PIP_FULLPATH%\pip.exe
set CODE_EXE=%ProgramFiles%\Microsoft VS Code\bin\code
mkdir "%USERPROFILE%\Downloads\temp" > nul 2>&1
pushd %USERPROFILE%\Downloads\temp
call:installAll
set ERROR_RETURN=%ERRORLEVEL%
popd
if %ERROR_RETURN%==0 (
call:displaySshKey
call:deleteInstallers
)
echo Exiting Installation Script . . .
exit /b %ERROR_RETURN%
:: ===================================================================
:: Start of main installation for all
:: ===================================================================
:installAll
call:checkAdmin
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:: Make a developer directory
mkdir "%USERPROFILE%\_dev" > nul 2>&1
type nul > nul
call:installConfig7z
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
call:installConfigAria2
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
call:installConfigWget
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
call:installConfigPttb
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
call:installConfigGit
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
call:installConfigMsvc
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
call:installConfigLlvm
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
call:installConfigCmake
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
call:installConfigNinja
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
call:installConfigCcache
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
call:installConfigMake
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
call:installConfigPkgconf
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
call:installConfigPthreads
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
call:installConfigZlib
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
call:installConfigFlexBison
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
call:installConfigTbb
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
call:installConfigEigen
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
call:installConfigPerl
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
call:installConfigPython
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
call:installConfigNodejs
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:: call:installConfigMsys2
:: if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
call:installConfigVscode
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
call:installConfigOvpn
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
exit /b %ERRORLEVEL%
:: ===================================================================
:: Start of 7-Zip Installation
:: ===================================================================
:installConfig7z
if not exist "%SZ_EXE%" call:install7z
:: Fail if installation fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:config7z
:: Add to PATH environment variable
call:appendPath %%%%ProgramFiles%%%%\7-Zip
exit /b %ERRORLEVEL%
:install7z
:: Download
echo Downloading 7-Zip . . .
call:download "https://www.7-zip.org/a/7z2201-x64.msi" %SZ_INSTALLER%
:: Fail if download fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:: Install
echo Installing 7-Zip . . .
start /wait MsiExec.exe /i %SZ_INSTALLER% /qn
exit /b %ERRORLEVEL%
:: ===================================================================
:: Start of aria2 Installation
:: ===================================================================
:installConfigAria2
if not exist "%ARIA2_EXE%" call:installAria2
:: Fail if installation fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:configAria2
:: Add to PATH environment variable
call:appendPath %%%%ProgramFiles%%%%\aria2
exit /b %ERRORLEVEL%
:installAria2
:: Download
echo Downloading aria2 . . .
call:download "https://github.com/aria2/aria2/releases/download/release-1.36.0/aria2-1.36.0-win-64bit-build1.zip" %ARIA2_INSTALLER%
:: Fail if download fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:: Install
echo Installing aria2 . . .
:: Aria2 does not require directory structure
call "%SZ_EXE%" e %ARIA2_INSTALLER% -o"%ARIA2_FULLPATH%"
exit /b %ERRORLEVEL%
:: ===================================================================
:: Start of wget Installation
:: ===================================================================
:installConfigWget
if not exist "%ProgramFiles%\wget\wget.exe" call:installWget
:: Fail if installation fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:configWget
:: Add to PATH environment variable
call:appendPath %%%%ProgramFiles%%%%\wget
exit /b %ERRORLEVEL%
:installWget
:: Download
echo Downloading wget . . .
call "%ARIA2_EXE%" -d "%ProgramFiles%\wget" -o wget.exe "https://eternallybored.org/misc/wget/1.21.3/64/wget.exe"
exit /b %ERRORLEVEL%
:: ===================================================================
:: Start of Pin to TaskBar Installation
:: ===================================================================
:installConfigPttb
if not exist "%PTTB_EXE%" call:installPttb
:: Fail if installation fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:configPttb
:: Add to PATH environment variable
call:appendPath %%%%ProgramFiles%%%%\pttb
exit /b %ERRORLEVEL%
:installPttb
:: Make directory if it doesn't exist
if not exist "%PTTB_FULLPATH%" mkdir "%PTTB_FULLPATH%"
:: Download
echo Downloading Pin To Taskbar . . .
call:download "https://github.com/0x546F6D/pttb_-_Pin_To_TaskBar/raw/main/pttb.exe" pttb.exe
:: Fail if download fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:installPttb
echo Installing Pin To Taskbar . . .
mkdir "%PTTB_FULLPATH%" > nul 2>&1
move /y pttb.exe "%PTTB_FULLPATH%"
exit /b %ERRORLEVEL%
:: ===================================================================
:: Start of Git Installation
:: ===================================================================
:installConfigGit
set GIT_EXE=%ProgramFiles%\Git\cmd\git.exe
if not exist "%GIT_EXE%" call:installGit
:: Fail if installation fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:configGit
echo Configuring Git . . .
:: Add to PATH environment variable
call:appendPath %%%%ProgramFiles%%%%\Git\cmd
:: Set username
set TEMP=
for /f "tokens=* USEBACKQ" %%A in (`git config --global user.name`) do set TEMP=%%A
if "%TEMP%"=="" call git config --global user.name %USERNAME%
:: Rebase on Pull
set TEMP=
for /f "tokens=* USEBACKQ" %%A in (`git config --global pull.rebase ^| findstr true`) do set TEMP=%%A
if %ERRORLEVEL% neq 0 call git config --global pull.rebase true
:: Generate SSH Key
call "%PROGRAMFILES%\Git\bin\sh.exe" --login -c "[[ -f ~/.ssh/id_rsa.pub ]] || ssh-keygen -q -t rsa -N '' <<< \"\"$'\n'\"y\" 2>&1 >/dev/null"
:: Add Github.com as known host
call "%PROGRAMFILES%\Git\bin\sh.exe" --login -c "[[ -n \"`grep -m1 github.com ~/.ssh/known_hosts`\" ]] || ssh-keyscan github.com >> ~/.ssh/known_hosts"
:: Add Gitlab.com as known host
call "%PROGRAMFILES%\Git\bin\sh.exe" --login -c "[[ -n \"`grep -m1 gitlab.com ~/.ssh/known_hosts`\" ]] || ssh-keyscan gitlab.com >> ~/.ssh/known_hosts"
exit /b %ERRORLEVEL%
:installGit
:: Download
:: https://github.com/git-for-windows/git/releases/latest
echo Downloading Git . . .
call:download "https://github.com/git-for-windows/git/releases/download/v2.38.1.windows.1/Git-2.38.1-64-bit.exe" %GIT_INSTALLER%
:: Fail if download fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:installGit
echo Installing Git . . .
call %GIT_INSTALLER% /VERYSILENT /NORESTART
exit /b %ERRORLEVEL%
:: ===================================================================
:: Start of Microsoft C++ Build Tools Installation
:: ===================================================================
:installConfigMsvc
set MSVC_FULLPATH=%ProgramFiles(x86)%\Microsoft Visual Studio
if not exist "%MSVC_FULLPATH%" call:installMsvc
:configMsvc
:: Nothing to configure for now
exit /b %ERRORLEVEL%
:installMsvc
:: Download if not installed
echo Downloading Microsoft C++ Build Tools . . .
call:download "https://aka.ms/vs/17/release/vs_BuildTools.exe" %MSVC_INSTALLER%
:: Fail if download fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:: Install
:: https://dimitri.janczak.net/2018/10/22/visual-c-build-tools-silent-installation/
:: https://learn.microsoft.com/en-us/visualstudio/install/use-command-line-parameters-to-install-visual-studio?view=vs-2019
:: MSVC and Windows SDK is required for LLVM
echo Installing Microsoft C++ Build Tools . . .
call %MSVC_INSTALLER% --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended --includeOptional --passive --norestart --wait
exit /b %ERRORLEVEL%
:: ===================================================================
:: Start of LLVM Installation
:: ===================================================================
:installConfigLlvm
set LLVM_FULLPATH=%ProgramFiles%\LLVM\bin
if not exist "%LLVM_FULLPATH%\clang++.exe" call:installLlvm
:: Fail if installation fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:configLlvm
:: Add to PATH environment variable
call:appendPath %%%%ProgramFiles%%%%\LLVM\bin
exit /b %ERRORLEVEL%
:installLlvm
:: Download
:: https://github.com/llvm/llvm-project/releases/latest
echo Downloading LLVM . . .
call:download "https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.6/LLVM-15.0.6-win64.exe" %LLVM_INSTALLER%
:: Fail if download fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:: Install
:: https://silentinstallhq.com/llvm-silent-install-how-to-guide/
echo Installing LLVM . . .
call %LLVM_INSTALLER% /S
exit /b %ERRORLEVEL%
:: ===================================================================
:: Start of CMake Installation
:: ===================================================================
:installConfigCmake
set CMAKE_FULLPATH=%ProgramFiles%\CMake\bin
if not exist "%CMAKE_FULLPATH%\cmake.exe" call:installCmake
:: Fail if installation fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:configCmake
:: Add to PATH environment variable
call:appendPath %%%%ProgramFiles%%%%\CMake\bin
exit /b %ERRORLEVEL%
:installCmake
:: Download if not installed
:: https://github.com/Kitware/CMake/releases/latest
echo Downloading CMake . . .
call:download "https://github.com/Kitware/CMake/releases/download/v3.25.1/cmake-3.25.1-windows-x86_64.msi" %CMAKE_INSTALLER%
:: Fail if download fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:: Install
:: https://silentinstallhq.com/cmake-silent-install-how-to-guide/
echo Installing CMake . . .
start /wait MsiExec.exe /i %CMAKE_INSTALLER% /qn
exit /b %ERRORLEVEL%
:: ===================================================================
:: Start of Ninja Installation
:: ===================================================================
:installConfigNinja
set NINJA_FULLPATH=%ProgramFiles%\Ninja
if not exist "%NINJA_FULLPATH%\ninja.exe" call:installNinja
:: Fail if installation fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:configNinja
:: Add to PATH environment variable
call:appendPath %%%%ProgramFiles%%%%\Ninja
exit /b %ERRORLEVEL%
:installNinja
:: Download
:: https://github.com/ninja-build/ninja/releases/latest
echo Downloading Ninja . . .
call:download "https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-win.zip" %NINJA_INSTALLER%
:: Fail if download fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:: Install
echo Installing Ninja . . .
call "%SZ_EXE%" x %NINJA_INSTALLER% -o"%NINJA_FULLPATH%"
exit /b %ERRORLEVEL%
:: ===================================================================
:: Start of Ccache Installation
:: ===================================================================
:installConfigCcache
set CCACHE_FULLPATH=%ProgramFiles%\Ccache
if not exist "%CCACHE_FULLPATH%\ccache.exe" call:installCcache
:: Fail if installation fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:configCcache
:: Add to PATH environment variable
call:appendPath %%%%ProgramFiles%%%%\Ccache
exit /b %ERRORLEVEL%
:installCcache
:: Download
:: https://github.com/ccache/ccache/releases/latest
echo Downloading Ccache . . .
call:download "https://github.com/ccache/ccache/releases/download/v4.7.4/ccache-4.7.4-windows-x86_64.zip" %CCACHE_INSTALLER%
:: Fail if download fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:: Install
echo Installing Ccache . . .
:: Ccache does not require directory structure
call "%SZ_EXE%" e %CCACHE_INSTALLER% -o"%CCACHE_FULLPATH%"
exit /b %ERRORLEVEL%
:: ===================================================================
:: Start of GNU Make Installation
:: ===================================================================
:installConfigMake
set MAKE_FULLPATH=%ProgramFiles(x86)%\GnuWin32\bin
if not exist "%MAKE_FULLPATH%\make.exe" call:installMake
:: Fail if installation fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:configMake
:: Add to PATH environment variable
call:appendPath %%%%ProgramFiles(x86)%%%%\GnuWin32\bin
:: Somehow (x86) path is buggy - does not exist
set ERRORLEVEL=0
exit /b 0
:installMake
:: https://gnuwin32.sourceforge.net/packages/make.htm
echo Downloading GNU Make . . .
call:download "https://jaist.dl.sourceforge.net/project/gnuwin32/make/3.81/make-3.81.exe" %MAKE_INSTALLER%
:: Fail if download fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:: Install
:: https://gnuwin32.sourceforge.net/setup.html
echo Installing GNU Make . . .
call %MAKE_INSTALLER% /SP- /VERYSILENT /NORESTART /SUPPRESSMSGBOXES /MERGETASKS="fileassoc"
exit /b %ERRORLEVEL%
:: ===================================================================
:: Start of pkg-config Installation
:: ===================================================================
:installConfigPkgconf
set PKGCONF_FULLPATH=%ProgramFiles%\pkg-config
if not exist "%PKGCONF_FULLPATH%\bin\pkg-config.exe" call:installPkgconf
:: Fail if installation fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:configPkgconf
:: Add to PATH environment variable
call:appendPath %%%%ProgramFiles%%%%\pkg-config\bin
exit /b %ERRORLEVEL%
:installPkgconf
echo Downloading pkg-config . . .
set PKGCONF_INSTALLER=pkgconf.zip
call:download "https://jaist.dl.sourceforge.net/project/pkgconfiglite/0.28-1/pkg-config-lite-0.28-1_bin-win32.zip" %PKGCONF_INSTALLER%
:: Fail if download fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:: Extract
if not exist pkg-config call "%SZ_EXE%" x %PKGCONF_INSTALLER% -o"pkg-config"
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:: Install
set PKGCONF_DIR=
for /f "tokens=* USEBACKQ" %%A in (`dir /a:d /b pkg-config`) do set PKGCONF_DIR=%%A
if "%PKGCONF_DIR%"=="" exit /b 1
:: Copy and rename
echo Installing pkg-config . . .
xcopy pkg-config\%PKGCONF_DIR% "%PKGCONF_FULLPATH%" /E /C /I /Q /Y
exit /b %ERRORLEVEL%
:: ===================================================================
:: Start of pthreads4w Installation
:: ===================================================================
:installConfigPthreads
set PTHREADS_FULLPATH=%ProgramFiles%\pthreads
if not exist "%PTHREADS_FULLPATH%" call:installPthreads
:: Fail if installation fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:configPthreads
:: Add to PATH environment variable
call:appendPath %%%%ProgramFiles%%%%\pthreads
call:appendPath %%%%ProgramFiles%%%%\pthreads\bin
exit /b %ERRORLEVEL%
:installPthreads
echo Downloading pthreads . . .
call:download "https://github.com/jonnysoe/pthreads4w/archive/refs/heads/main.zip" pthreads4w.zip
:: Fail if download fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:: Install
echo Installing pthreads . . .
:: Extract
if not exist pthreads4w call "%SZ_EXE%" x pthreads4w.zip -o"pthreads4w"
:: Fail if extraction fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:: Build pthreads
pushd pthreads4w\pthreads4w-main
if not exist ..\PTHREADS-BUILT call compile.bat all install
popd
:: Failed to build pthreads
if not exist pthreads4w\PTHREADS-BUILT exit /b 1
:: Copy and rename
xcopy pthreads4w\PTHREADS-BUILT "%PTHREADS_FULLPATH%" /E /C /I /Q /Y
exit /b %ERRORLEVEL%
:: ===================================================================
:: Start of Zlib Installation
:: ===================================================================
:installConfigZlib
set ZLIB_FULLPATH=%ProgramFiles%\zlib
if not exist "%ZLIB_FULLPATH%" call:installZlib
:: Fail if installation fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:configZlib
:: Add to PATH environment variable
call:appendPath %%%%ProgramFiles%%%%\zlib
exit /b %ERRORLEVEL%
:installZlib
:: Download
echo Downloading Zlib . . .
call:download "http://www.winimage.com/zLibDll/zlib123.zip" zlib123.zip
:: Fail if download fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
call:download "http://www.winimage.com/zLibDll/zlib123dllx64.zip" zlib123dllx64.zip
:: Fail if download fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:: Install
echo Installing Zlib . . .
mkdir "%ProgramFiles%\zlib" > nul 2>&1
mkdir "%ProgramFiles%\zlib\include" > nul 2>&1
call "%SZ_EXE%" x zlib123.zip -o"%ProgramFiles%\zlib\include"
call "%SZ_EXE%" x zlib123dllx64.zip -o"%ProgramFiles%\zlib"
pushd "%ProgramFiles%\zlib\"
rename static_x64 lib
rename dll_x64 bin
popd
exit /b %ERRORLEVEL%
:: ===================================================================
:: Start of Flex/Bison Installation
:: ===================================================================
:installConfigFlexBison
if not exist "%ProgramFiles%\win_flex_bison" call:installFlexBison
:: Fail if installation fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:configFlexBison
:: Add to PATH environment variable
call:appendPath %%%%ProgramFiles%%%%\win_flex_bison
exit /b %ERRORLEVEL%
:installFlexBison
echo Downloading Flex/Bison . . .
call:download "https://github.com/lexxmark/winflexbison/releases/download/v2.5.25/win_flex_bison-2.5.25.zip" win_flex_bison.zip
:: Fail if download fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:: Install
echo Installing Flex/Bison . . .
if not exist "%ProgramFiles%\win_flex_bison" call "%SZ_EXE%" x win_flex_bison.zip -o"%ProgramFiles%\win_flex_bison"
exit /b %ERRORLEVEL%
:: ===================================================================
:: Start of Intel Thread Building Block Installation
:: ===================================================================
:installConfigTbb
set TBB_FULLPATH=%ProgramFiles%\tbb
if not exist "%TBB_FULLPATH%" call:installTbb
:: Fail if installation fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:configTbb
:: Add to PATH environment variable
call:appendPath %%%%ProgramFiles%%%%\tbb
call:appendPath %%%%ProgramFiles%%%%\tbb\cmake
:: Set TBB_ARCH_PLATFORM environment variable
set TBB_ARCH=
set TBB_VC=
if "%PROCESSOR_ARCHITECTURE%"=="AMD64" set TBB_ARCH=intel64
if "%PROCESSOR_ARCHITECTURE%"=="x86" set TBB_ARCH=ia32
:: Use the library that ends with numbers, eg. vc14 instead of vc14_uwp
for /f "tokens=* USEBACKQ" %%A in (`dir /a:d /b "%ProgramFiles%\tbb\bin\%TBB_ARCH%" ^| findstr "[0-9]$"`) do set TBB_VC=%%A
call:appendPath %%%%ProgramFiles%%%%\tbb\bin\%TBB_ARCH%\%TBB_VC%
exit /b %ERRORLEVEL%
:installTbb
:: Download
echo Downloading Intel Thread Building Block . . .
call:download "https://github.com/oneapi-src/oneTBB/releases/download/v2020.1/tbb-2020.1-win.zip" tbb.zip
:: Fail if download fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:: Install
echo Installing Intel Thread Building Block . . .
if not exist tbb call "%SZ_EXE%" x tbb.zip -o"tbb"
:: Copy and rename
if not exist "%ProgramFiles%\tbb" xcopy tbb\tbb "%ProgramFiles%\tbb" /E /C /I /Q /Y
exit /b %ERRORLEVEL%
:: ===================================================================
:: Start of Eigen3 Installation
:: ===================================================================
:installConfigEigen
set EIGEN_FULLPATH=%ProgramFiles%\CMake\share\eigen3
if not exist "%EIGEN_FULLPATH%" call:installEigen
:: Fail if installation fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:configEigen
:: Nothing to configure for now as its installed in CMake's share directory
exit /b %ERRORLEVEL%
:installEigen
:: Download
echo Downloading Eigen3 . . .
call:download "https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.zip" eigen.zip
:: Fail if download fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:: Install
echo Installing Eigen3 . . .
if not exist eigen call "%SZ_EXE%" x eigen.zip -o"eigen"
set EIGEN_DIR=
for /f "tokens=* USEBACKQ" %%A in (`dir /a:d /b eigen`) do set EIGEN_DIR=%%A
if "%EIGEN_DIR%"=="" exit /b 1
:: Configure CMake install
pushd eigen\%EIGEN_DIR%
cmake -S . -B build --install-prefix "%ProgramFiles%\CMake"
if %ERRORLEVEL%==0 cmake --install build
set ERROR_RETURN=%ERRORLEVEL%
popd
exit /b %ERROR_RETURN%
:: ===================================================================
:: Start of Perl Installation
:: ===================================================================
:installConfigPerl
if not exist "C:\Perl64\bin\perl.exe" call:installPerl
:: Fail if installation fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:configPerl
:: Add to PATH environment variable
call:prependPath C:\Perl64\bin
:: Fail if append fails
if %ERRORLEVEL% neq 0 goto failInstall
:: Add to PATH environment variable
call:prependPath C:\Perl64\site\bin
:: Fail if append fails
if %ERRORLEVEL% neq 0 goto failInstall
exit /b %ERRORLEVEL%
:installPerl
:: Download
echo Downloading Perl . . .
:: https://www.reddit.com/r/perl/comments/l1wv8i/comment/gk1wpje/?utm_source=share&utm_medium=web2x&context=3
call:download "https://cli-msi.s3.amazonaws.com/ActivePerl-5.28.msi" ActivePerl.msi
:: Fail if download fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:: Install
echo Installing Perl . . .
start /wait MsiExec.exe /i ActivePerl.msi /qn
exit /b %ERRORLEVEL%
:: ===================================================================
:: Start of Python Installation
:: ===================================================================
:installConfigPython
if not exist "%PYTHON_EXE%" call:installPython
:: Fail if installation fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:configPython
:: Add to PATH environment variable
call:prependPath %%%%ProgramFiles%%%%\%PYTHON_PATH%
:: Fail if append fails
if %ERRORLEVEL% neq 0 goto failInstall
:: Add to PATH environment variable
call:prependPath %%%%ProgramFiles%%%%\%PYTHON_PATH%\Scripts
:: Fail if append fails
if %ERRORLEVEL% neq 0 goto failInstall
exit /b %ERRORLEVEL%
:installPython
:: Download
echo Downloading Python . . .
call:download "https://www.python.org/ftp/python/3.10.9/python-3.10.9-amd64.exe" %PYTHON_INSTALLER%
:: Fail if download fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:: Install
echo Installing Python . . .
call %PYTHON_INSTALLER% /quiet InstallAllUsers=1 PrependPath=1 AssociateFiles=1
exit /b %ERRORLEVEL%
:: ===================================================================
:: Start of Nodejs Installation
:: ===================================================================
:installConfigNodejs
if not exist "%NODEJS_FULLPATH%" call:installNodejs
:: Fail if installation fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:configNodejs
echo Configuring Nodejs . . .
:: Allow script execution
PowerShell -Command "Set-ExecutionPolicy Unrestricted -Scope LocalMachine -Force"
:: Add to PATH environment variable
call:appendPath %%%%ProgramFiles%%%%\nodejs
:: Fail if append fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:: Install Global Node Modules (ignore errors)
:: NOTE:
:: - Need to add "call" as npm/npx will invoke another process, executing them without "call" will not return control
:: https://stackoverflow.com/a/42306073/19336104
:: - Do not add yo and generator-code as they will invoke another process which will call Node with outdated PATH
call npm install -g yarn npm@latest
call npx yarn global add @vscode/vsce
exit /b %ERRORLEVEL%
:installNodejs
:: Download
echo Downloading Nodejs . . .
call:download "https://nodejs.org/download/release/v16.18.1/node-v16.18.1-x64.msi" %NODEJS_INSTALLER%
:: Fail if download fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:: Install
:: https://silentinstallhq.com/node-js-silent-install-how-to-guide/
echo Installing Nodejs . . .
start /wait MsiExec.exe /i %NODEJS_INSTALLER% /qn
exit /b %ERRORLEVEL%
:: ===================================================================
:: Start of MSYS2 Installation
:: ===================================================================
:installConfigMsys2
set MSYS2_FULLPATH=C:\msys64
if not exist %MSYS2_FULLPATH% call:installMsys2
:: Fail if installation fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:configMsys2
echo Configuring MSYS2 . . .
:: Add to PATH environment variable
call:appendPath %%MSYS2_FULLPATH%%\usr\bin
:: Fail if append fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:: Add to PATH environment variable
call:appendPath %%MSYS2_FULLPATH%%\mingw64\bin
:: Fail if append fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:: Install MinGW and dependencies for MSYS2
set MSYSTEM=MSYS
%MSYS2_FULLPATH%\usr\bin\bash --login -c "pacman -S --noconfirm --needed mingw-w64-x86_64-ccache mingw-w64-x86_64-cmake mingw-w64-x86_64-dlfcn mingw-w64-x86_64-eigen3 mingw-w64-x86_64-gcc mingw-w64-x86_64-make mingw-w64-x86_64-ninja mingw-w64-x86_64-zlib msys2-runtime-devel bison flex git make pkgconf unzip"
:: Fail if installation fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:: Add /mingw64/bin to PATH variable
%MSYS2_FULLPATH%\usr\bin\bash --login -c "[[ -n \"`grep mingw64 ~/.bashrc`\" ]] || echo \"export PATH=\$PATH:/mingw64/bin\" >> ~/.bashrc"
:: Fail if installation fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:: Symlink librt.a
%MSYS2_FULLPATH%\usr\bin\bash --login -c "[[ -f /mingw64/lib/librt.a ]] || ln -s /usr/lib/librt.a /mingw64/lib"
:: Fail if installation fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:: Symlink Py.exe
%MSYS2_FULLPATH%\usr\bin\bash --login -c "[[ -f /usr/bin/python ]] || ln -s /c/Windows/py.exe /usr/bin/python"
:: Fail if installation fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:: Symlink Py.exe
%MSYS2_FULLPATH%\usr\bin\bash --login -c "[[ -f /usr/bin/python3 ]] || ln -s /c/Windows/py.exe /usr/bin/python3"
:: Fail if installation fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:: Symlink pip.exe
%MSYS2_FULLPATH%\usr\bin\bash --login -c "[[ -f /usr/bin/pip ]] || ln -s /c/Program\ Files/Python310/Scripts/pip.exe /usr/bin/pip"
:: Fail if installation fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:: Symlink directories in MSYS2 to Windows' (Git Bash) user directory to share directories
:: NOTE: This needs to be Windows' symlink to be visible in Windows
mklink /D "%MSYS2_FULLPATH%\home\%USERNAME%\.ssh" "%USERPROFILE%\.ssh" > nul 2>&1
mklink /D "%MSYS2_FULLPATH%\home\%USERNAME%\_dev" "%USERPROFILE%\_dev" > nul 2>&1
exit /b %ERRORLEVEL%
:installMsys2
:: Download if not installed
echo Downloading MSYS2 . . .
call:download "https://github.com/msys2/msys2-installer/releases/download/2022-10-28/msys2-x86_64-20221028.exe" %MSYS2_INSTALLER%
:: Fail if download fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:: Install
:: https://silentinstallhq.com/msys2-silent-install-how-to-guide/
echo Installing MSYS2 . . .
call %MSYS2_INSTALLER% install --root %MSYS2_FULLPATH% --confirm-command
exit /b %ERRORLEVEL%
:: ===================================================================
:: Start of VS Code Installation
:: ===================================================================
:installConfigVscode
if not exist "%CODE_EXE%" call:installVscode
:: Fail if installation fails
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
:configVscode
echo Configuring VS Code . . .
:: Add to PATH environment variable
call:appendPath %%%%ProgramFiles%%%%\Microsoft VS Code
set VSCODE_SETTINGS_DIR=%APPDATA%\Code\User
mkdir %VSCODE_SETTINGS_DIR% > nul 2>&1
:: @todo use jq to update settings.json
set VSCODE_SETTINGS=%VSCODE_SETTINGS_DIR%\settings.json
:: file doesn't exist, touch file
if not exist %VSCODE_SETTINGS% (
echo {
echo "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
echo "tabnine.experimentalAutoImports": true,
echo "C_Cpp.default.includePath": [
echo "${default}",