-
Notifications
You must be signed in to change notification settings - Fork 5
/
setenv.bat
1377 lines (1285 loc) · 50 KB
/
setenv.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
setlocal enabledelayedexpansion
@rem only for interactive debugging
set _DEBUG=0
@rem #########################################################################
@rem ## Environment setup
set _EXITCODE=0
call :env
if not %_EXITCODE%==0 goto end
call :args %*
if not %_EXITCODE%==0 goto end
@rem #########################################################################
@rem ## Main
if %_HELP%==1 (
call :help
exit /b !_EXITCODE!
)
set _ANT_PATH=
set _BAZEL_PATH=
set _BLOOP_PATH=
set _COURSIER_PATH=
set _GIT_PATH=
set _GRADLE_PATH=
set _JMC_PATH=
set _MAVEN_PATH=
set _MILL_PATH=
set _MSYS_PATH=
set _SBT_PATH=
set _SCALA_CLI_PATH=
set _VSCODE_PATH=
@rem %1=version, %2=vendor
@rem eg. bellsoft, corretto, bellsoft, openj9, redhat, sapmachine, temurin, zulu
call :java 21 "temurin"
if not %_EXITCODE%==0 goto end
@rem last call to :java defines variable JAVA_HOME
call :java 17 "temurin"
if not %_EXITCODE%==0 goto end
call :scala2
if not %_EXITCODE%==0 goto end
call :scalafmt
if not defined _SCALAFMT_CMD (
@rem optional
echo %_WARNING_LABEL% Scalafmt installation not found 1>&2
echo ^(run Coursier command cs.exe install scalafmt^) 1>&2
set _EXITCODE=0
)
call :scala3
if not %_EXITCODE%==0 goto end
call :sbt
if not %_EXITCODE%==0 goto end
call :ant
if not %_EXITCODE%==0 goto end
call :bazel
if not %_EXITCODE%==0 (
@rem optional
echo %_WARNING_LABEL% Bazel installation not found 1>&2
set _EXITCODE=0
)
@rem bloop depends on python
call :python 3
if not %_EXITCODE%==0 goto end
call :bloop
if not %_EXITCODE%==0 (
@rem optional
echo %_WARNING_LABEL% Bloop installation not found 1>&2
set _EXITCODE=0
)
call :cfr
if not %_EXITCODE%==0 goto end
call :coursier
if not %_EXITCODE%==0 (
@rem optional
echo %_WARNING_LABEL% Coursier installation not found 1>&2
set _EXITCODE=0
)
call :gradle
if not %_EXITCODE%==0 goto end
call :jacoco
if not %_EXITCODE%==0 (
@rem optional
echo %_WARNING_LABEL% JaCoCo installation not found 1>&2
set _EXITCODE=0
)
call :javafx
if not %_EXITCODE%==0 (
@rem optional
echo %_WARNING_LABEL% JavaFX installation not found 1>&2
set _EXITCODE=0
)
call :jmc
if not %_EXITCODE%==0 (
@rem optional
echo %_WARNING_LABEL% Java Mission Control installation not found 1>&2
set _EXITCODE=0
)
call :maven
if not %_EXITCODE%==0 goto end
call :mill
if not %_EXITCODE%==0 goto end
call :msys
if not %_EXITCODE%==0 (
@rem optional
echo %_WARNING_LABEL% MSYS2 installation not found 1>&2
set _EXITCODE=0
)
call :msvs
if not %_EXITCODE%==0 goto end
call :scala_cli
if not %_EXITCODE%==0 (
@rem optional
echo %_WARNING_LABEL% Scala-CLI installation not found 1>&2
set _EXITCODE=0
)
call :vscode
if not %_EXITCODE%==0 goto end
call :git
if not %_EXITCODE%==0 goto end
call :maven_plugin
if not %_EXITCODE%==0 (
@rem optional
echo %_WARNING_LABEL% Scala Maven plugin installation not found 1>&2
set _EXITCODE=0
)
if "%~1"=="clean" call :clean
goto end
@rem #########################################################################
@rem ## Subroutines
@rem output parameters: _DEBUG_LABEL, _ERROR_LABEL, _WARNING_LABEL
:env
set _BASENAME=%~n0
set "_ROOT_DIR=%~dp0"
call :env_colors
set _DEBUG_LABEL=%_NORMAL_BG_CYAN%[%_BASENAME%]%_RESET%
set _ERROR_LABEL=%_STRONG_FG_RED%Error%_RESET%:
set _WARNING_LABEL=%_STRONG_FG_YELLOW%Warning%_RESET%:
goto :eof
:env_colors
@rem ANSI colors in standard Windows 10 shell
@rem see https://gist.github.com/mlocati/#file-win10colors-cmd
@rem normal foreground colors
set _NORMAL_FG_BLACK=[30m
set _NORMAL_FG_RED=[31m
set _NORMAL_FG_GREEN=[32m
set _NORMAL_FG_YELLOW=[33m
set _NORMAL_FG_BLUE=[34m
set _NORMAL_FG_MAGENTA=[35m
set _NORMAL_FG_CYAN=[36m
set _NORMAL_FG_WHITE=[37m
@rem normal background colors
set _NORMAL_BG_BLACK=[40m
set _NORMAL_BG_RED=[41m
set _NORMAL_BG_GREEN=[42m
set _NORMAL_BG_YELLOW=[43m
set _NORMAL_BG_BLUE=[44m
set _NORMAL_BG_MAGENTA=[45m
set _NORMAL_BG_CYAN=[46m
set _NORMAL_BG_WHITE=[47m
@rem strong foreground colors
set _STRONG_FG_BLACK=[90m
set _STRONG_FG_RED=[91m
set _STRONG_FG_GREEN=[92m
set _STRONG_FG_YELLOW=[93m
set _STRONG_FG_BLUE=[94m
set _STRONG_FG_MAGENTA=[95m
set _STRONG_FG_CYAN=[96m
set _STRONG_FG_WHITE=[97m
@rem strong background colors
set _STRONG_BG_BLACK=[100m
set _STRONG_BG_RED=[101m
set _STRONG_BG_GREEN=[102m
set _STRONG_BG_YELLOW=[103m
set _STRONG_BG_BLUE=[104m
@rem we define _RESET in last position to avoid crazy console output with type command
set _BOLD=[1m
set _UNDERSCORE=[4m
set _INVERSE=[7m
set _RESET=[0m
goto :eof
@rem input parameter: %*
@rem output parameters: _BASH, _HELP, _VERBOSE
:args
set _BASH=0
set _HELP=0
set _MSYS=0
set _VERBOSE=0
:args_loop
set "__ARG=%~1"
if not defined __ARG goto args_done
if "%__ARG:~0,1%"=="-" (
@rem option
if "%__ARG%"=="-bash" ( set _MSYS=0& set _BASH=1
) else if "%__ARG%"=="-debug" ( set _DEBUG=1
) else if "%__ARG%"=="-msys" ( set _BASH=0& set _MSYS=1
) else if "%__ARG%"=="-verbose" ( set _VERBOSE=1
) else (
echo %_ERROR_LABEL% Unknown option "%__ARG%" 1>&2
set _EXITCODE=1
goto args_done
)
) else (
@rem subcommand
if "%__ARG%"=="help" ( set _HELP=1
) else (
echo %_ERROR_LABEL% Unknown subcommand "%__ARG%" 1>&2
set _EXITCODE=1
goto args_done
)
)
shift
goto args_loop
:args_done
call :drive_name "%_ROOT_DIR%"
if not %_EXITCODE%==0 goto :eof
if %_DEBUG%==1 (
echo %_DEBUG_LABEL% Options : _BASH=%_BASH% _VERBOSE=%_VERBOSE% 1>&2
echo %_DEBUG_LABEL% Subcommands: _HELP=%_HELP% 1>&2
echo %_DEBUG_LABEL% Variables : _DRIVE_NAME=%_DRIVE_NAME% 1>&2
)
goto :eof
@rem input parameter: %1: path to be substituted
@rem output parameter: _DRIVE_NAME (2 characters: letter + ':')
:drive_name
set "__GIVEN_PATH=%~1"
@rem remove trailing path separator if present
if "%__GIVEN_PATH:~-1,1%"=="\" set "__GIVEN_PATH=%__GIVEN_PATH:~0,-1%"
@rem https://serverfault.com/questions/62578/how-to-get-a-list-of-drive-letters-on-a-system-through-a-windows-shell-bat-cmd
set __DRIVE_NAMES=F:G:H:I:J:K:L:M:N:O:P:Q:R:S:T:U:V:W:X:Y:Z:
for /f %%i in ('wmic logicaldisk get deviceid ^| findstr :') do (
set "__DRIVE_NAMES=!__DRIVE_NAMES:%%i=!"
)
if %_DEBUG%==1 echo %_DEBUG_LABEL% __DRIVE_NAMES=%__DRIVE_NAMES% ^(WMIC^) 1>&2
if not defined __DRIVE_NAMES (
echo %_ERROR_LABEL% No more free drive name 1>&2
set _EXITCODE=1
goto :eof
)
for /f "tokens=1,2,*" %%f in ('subst') do (
set "__SUBST_DRIVE=%%f"
set "__SUBST_DRIVE=!__SUBST_DRIVE:~0,2!"
set "__SUBST_PATH=%%h"
@rem Windows local file systems are not case sensitive (by default)
if /i "!__SUBST_DRIVE!"=="!__GIVEN_PATH:~0,2!" (
set _DRIVE_NAME=!__SUBST_DRIVE:~0,2!
if %_DEBUG%==1 ( echo %_DEBUG_LABEL% Select drive !_DRIVE_NAME! for which a substitution already exists 1>&2
) else if %_VERBOSE%==1 ( echo Select drive !_DRIVE_NAME! for which a substitution already exists 1>&2
)
goto :eof
) else if "!__SUBST_PATH!"=="!__GIVEN_PATH!" (
set "_DRIVE_NAME=!__SUBST_DRIVE!"
if %_DEBUG%==1 ( echo %_DEBUG_LABEL% Select drive !_DRIVE_NAME! for which a substitution already exists 1>&2
) else if %_VERBOSE%==1 ( echo Select drive !_DRIVE_NAME! for which a substitution already exists 1>&2
)
goto :eof
)
)
for /f "tokens=1,2,*" %%i in ('subst') do (
set __USED=%%i
call :drive_names "!__USED:~0,2!"
)
if %_DEBUG%==1 echo %_DEBUG_LABEL% __DRIVE_NAMES=%__DRIVE_NAMES% ^(SUBST^) 1>&2
set "_DRIVE_NAME=!__DRIVE_NAMES:~0,2!"
if /i "%_DRIVE_NAME%"=="%__GIVEN_PATH:~0,2%" goto :eof
if %_DEBUG%==1 ( echo %_DEBUG_LABEL% subst "%_DRIVE_NAME%" "%__GIVEN_PATH%" 1>&2
) else if %_VERBOSE%==1 ( echo Assign drive %_DRIVE_NAME% to path "!__GIVEN_PATH:%USERPROFILE%=%%USERPROFILE%%!" 1>&2
)
subst "%_DRIVE_NAME%" "%__GIVEN_PATH%"
if not %ERRORLEVEL%==0 (
echo %_ERROR_LABEL% Failed to assign drive %_DRIVE_NAME% to path "!__GIVEN_PATH:%USERPROFILE%=%%USERPROFILE%%!" 1>&2
set _EXITCODE=1
goto :eof
)
goto :eof
@rem input parameter: %1=Used drive name
@rem output parameter: __DRIVE_NAMES
:drive_names
set "__USED_NAME=%~1"
set "__DRIVE_NAMES=!__DRIVE_NAMES:%__USED_NAME%=!"
goto :eof
:help
if %_VERBOSE%==1 (
set __BEG_P=%_STRONG_FG_CYAN%
set __BEG_O=%_STRONG_FG_GREEN%
set __BEG_N=%_NORMAL_FG_YELLOW%
set __END=%_RESET%
) else (
set __BEG_P=
set __BEG_O=
set __BEG_N=
set __END=
)
echo Usage: %__BEG_O%%_BASENAME% { ^<option^> ^| ^<subcommand^> }%__END%
echo.
echo %__BEG_P%Options:%__END%
echo %__BEG_O%-bash%__END% start Git bash shell instead of Windows command prompt
echo %__BEG_O%-debug%__END% print commands executed by this script
echo %__BEG_O%-msys%__END% start MSYS2 bash shell instead of Windows command prompt
echo %__BEG_O%-verbose%__END% print progress messages
echo.
echo %__BEG_P%Subcommands:%__END%
echo %__BEG_O%help%__END% print this help message
goto :eof
@rem output parameter: _PYTHON_HOME
:python
set _PYTHON_HOME=
set __PYTHON_CMD=
for /f "delims=" %%f in ('where python.exe 2^>NUL') do (
set "__PYTHON_CMD=%%f"
@rem we ignore Scoop/Windows managed Python installation
if not "!__PYTHON_CMD:scoop=!"=="!__PYTHON_CMD!" ( set __PYTHON_CMD=
) else if not "!__PYTHON_CMD:WindowsApps=!"=="%__PYTHON_CMD%" ( set __PYTHON_CMD=
)
)
if defined __PYTHON_CMD (
for /f "delims=" %%i in ("%__PYTHON_CMD%") do set "_PYTHON_HOME=%%~dpi"
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using path of Python executable found in PATH 1>&2
goto :eof
) else if defined PYTHON_HOME (
set "_PYTHON_HOME=%PYTHON_HOME%"
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using environment variable PYTHON_HOME 1>&2
) else (
set __PATH=C:\opt
if exist "!__PATH!\Python\" ( set "_PYTHON_HOME=!__PATH!\Python"
) else (
for /f "delims=" %%f in ('dir /ad /b "!__PATH!\Python-3*" 2^>NUL') do set "_PYTHON_HOME=!__PATH!\%%f"
if not defined _PYTHON_HOME (
set "__PATH=%ProgramFiles%"
for /f "delims=" %%f in ('dir /ad /b "!__PATH!\Python-3*" 2^>NUL') do set "_PYTHON_HOME=!__PATH!\%%f"
)
)
if defined _PYTHON_HOME (
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using default Python installation directory "!_PYTHON_HOME!" 1>&2
)
)
if not exist "%_PYTHON_HOME%\python.exe" (
echo %_ERROR_LABEL% Python executable not found ^("%_PYTHON_HOME%"^) 1>&2
set _EXITCODE=1
goto :eof
)
goto :eof
@rem output parameters: _BLOOP_HOME, _BLOOP_PATH
:bloop
set _BLOOP_HOME=
set _BLOOP_PATH=
set __BLOOP_CMD=
for /f "delims=" %%f in ('where bloop.exe 2^>NUL') do set "__BLOOP_CMD=%%f"
if defined __BLOOP_CMD (
@rem for %%i in ("%__BLOOP_CMD%") do set "__BIN_DIR=%%~dpi"
for /f "delims=" %%f in ("%__BLOOP_CMD%") do set "_BLOOP_HOME=%%~dpf"
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using path of bloop executable found in PATH 1>&2
@rem keep _BLOOP_PATH undefined since executable already in path
goto :eof
) else if defined BLOOP_HOME (
set "_BLOOP_HOME=%BLOOP_HOME%"
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using environment variable BLOOP_HOME 1>&2
) else (
set _PATH=C:\opt
if exist "!__PATH!\bloop\" ( set "_BLOOP_HOME=!__PATH!\bloop"
) else (
for /f "delims=" %%f in ('dir /ad /b "!_PATH!\bloop*" 2^>NUL') do set "_BLOOP_HOME=!_PATH!\%%f"
)
if defined _BLOOP_HOME (
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using default Bloop installation directory "!_BLOOP_HOME!" 1>&2
)
)
if not exist "%_BLOOP_HOME%\bloop.exe" (
echo %_ERROR_LABEL% bloop executable not found ^("%_BLOOP_HOME%"^) 1>&2
set _EXITCODE=1
goto :eof
)
set "_BLOOP_PATH=;%_BLOOP_HOME%"
goto :eof
@rem input parameters:%1=required version %2=vendor
@rem output parameter: _JAVA_HOME (resp. JAVA11_HOME)
:java
set _JAVA_HOME=
set __VERSION=%~1
set __VENDOR=%~2
if not defined __VENDOR ( set __JDK_NAME=jdk-%__VERSION%
) else ( set __JDK_NAME=jdk-%__VENDOR%-%__VERSION%
)
set __JAVAC_CMD=
for /f "delims=" %%f in ('where javac.exe 2^>NUL') do (
set "__JAVAC_CMD=%%f"
@rem we ignore Scoop managed Java installation
if not "!__JAVAC_CMD:scoop=!"=="!__JAVAC_CMD!" set __JAVAC_CMD=
)
if defined __JAVAC_CMD (
call :jdk_version "%__JAVAC_CMD%"
if !_JDK_VERSION!==%__VERSION% (
for /f "delims=" %%i in ("%__JAVAC_CMD%") do set "__BIN_DIR=%%~dpi"
for /f "delims=" %%f in ("%__BIN_DIR%") do set "_JAVA_HOME=%%~dpf"
) else (
echo %_ERROR_LABEL% Required JDK installation not found ^("%__JDK_NAME%"^) 1>&2
set _EXITCODE=1
goto :eof
)
)
if defined JAVA_HOME (
set "_JAVA_HOME=%JAVA_HOME%"
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using environment variable JAVA_HOME 1>&2
) else (
set __PATH=C:\opt
for /f "delims=" %%f in ('dir /ad /b "!__PATH!\%__JDK_NAME%*" 2^>NUL') do set "_JAVA_HOME=!__PATH!\%%f"
if not defined _JAVA_HOME (
set "__PATH=%ProgramFiles%\Java"
for /f "delims=" %%f in ('dir /ad /b "!__PATH!\%__JDK_NAME%*" 2^>NUL') do set "_JAVA_HOME=!__PATH!\%%f"
)
if defined _JAVA_HOME (
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using default Java SDK installation directory "!_JAVA_HOME!" 1>&2
)
)
if not exist "%_JAVA_HOME%\bin\javac.exe" (
echo %_ERROR_LABEL% Executable javac.exe not found ^("%_JAVA_HOME%"^) 1>&2
set _EXITCODE=1
goto :eof
)
call :jdk_version "%_JAVA_HOME%\bin\javac.exe"
set "_JAVA!_JDK_VERSION!_HOME=%_JAVA_HOME%"
goto :eof
@rem input parameter: %1=javac file path
@rem output parameter: _JDK_VERSION
:jdk_version
set "__JAVAC_CMD=%~1"
if not exist "%__JAVAC_CMD%" (
echo %_ERROR_LABEL% Command javac.exe not found ^("%__JAVAC_CMD%"^) 1>&2
set _EXITCODE=1
goto :eof
)
set __JAVAC_VERSION=
for /f "usebackq tokens=1,*" %%i in (`"%__JAVAC_CMD%" -version 2^>^&1`) do set __JAVAC_VERSION=%%j
set "__PREFIX=%__JAVAC_VERSION:~0,2%"
@rem either 1.7, 1.8 or 11..18
if "%__PREFIX%"=="1." ( set _JDK_VERSION=%__JAVAC_VERSION:~2,1%
) else ( set _JDK_VERSION=%__PREFIX%
)
goto :eof
@rem output parameter: SCALA_HOME
:scala2
set _SCALA_HOME=
set __SCALAC_CMD=
for /f "delims=" %%f in ('where scalac.bat 2^>NUL') do (
set __VERSION=
for /f "tokens=1,2,3,4,*" %%i in ('scalac.bat -version 2^>^&1') do set "__VERSION=%%l"
if defined __VERSION if "!__VERSION:~0,1!"=="2" set "__SCALAC_CMD=%%f"
)
if defined __SCALAC_CMD (
for /f "delims=" %%i in ("%__SCALAC_CMD%") do set "__SCALA_BIN_DIR=%%~dpi"
for /f "delims=" %%f in ("!__SCALA_BIN_DIR!..") do set "_SCALA_HOME=%%f"
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using path of Scala 2 executable found in PATH 1>&2
goto :eof
) else if defined SCALA_HOME (
set "_SCALA_HOME=%SCALA_HOME%"
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using environment variable SCALA_HOME 1>&2
) else (
set __PATH=C:\opt
if exist "!__PATH!\scala\" ( set "_SCALA_HOME=!__PATH!\scala"
) else (
for /f "delims=" %%f in ('dir /ad /b "!__PATH!\scala-2*" 2^>NUL') do set "_SCALA_HOME=!__PATH!\%%f"
)
if defined _SCALA_HOME (
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using default Scala 2 installation directory "!_SCALA_HOME!" 1>&2
)
)
if not exist "%_SCALA_HOME%\bin\scalac.bat" (
echo %_ERROR_LABEL% Scala executable not found ^("%_SCALA_HOME%"^) 1>&2
set _EXITCODE=1
goto :eof
)
goto :eof
@rem output parameter: _SCALAFMT_CMD
:scalafmt
set _SCALAFMT_CMD=
@rem Coursier installed software
if exist "%LOCALAPPDATA%\Coursier\data\bin\scalafmt.bat" (
set "_SCALAFMT_CMD=%LOCALAPPDATA%\Coursier\data\bin\scalafmt.bat"
)
goto :eof
@rem output parameter: _SCALA3_HOME
:scala3
set _SCALA3_HOME=
set __SCALAC_CMD=
for /f "delims=" %%f in ('where scalac.bat 2^>NUL') do (
set __VERSION=
for /f "tokens=1,2,3,4,*" %%i in ('scalac.bat -version 2^>^&1') do set "__VERSION=%%l"
if defined __VERSION if "!__VERSION:~0,1!"=="3" set "__SCALAC_CMD=%%f"
)
if defined __SCALAC_CMD (
for /f "delims=" %%i in ("%__SCALAC_CMD%") do set "__SCALA3_BIN_DIR=%%~dpi"
for /f "delims=" %%f in ("!__SCALA3_BIN_DIR!\.") do set "_SCALA3_HOME=%%~dpf"
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using path of Scala 3 executable found in PATH 1>&2
) else if defined SCALA3_HOME (
set "_SCALA3_HOME=%SCALA3_HOME%"
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using environment variable SCALA3_HOME 1>&2
) else (
set __PATH=C:\opt
if exist "!__PATH!\scala3\" ( set "_SCALA3_HOME=!__PATH!\scala3"
) else (
for /f "delims=" %%f in ('dir /ad /b "!__PATH!\scala3-3.3*" 2^>NUL') do set "_SCALA3_HOME=!__PATH!\%%f"
if not defined _SCALA3_HOME (
set "__PATH=%ProgramFiles%"
for /f "delims=" %%f in ('dir /ad /b "!__PATH!\scala3-3.3*" 2^>NUL') do set "_SCALA3_HOME=!__PATH!\%%f"
)
)
if defined _SCALA3_HOME (
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using default Scala 3 installation directory "!_SCALA3_HOME!" 1>&2
)
)
if not exist "%_SCALA3_HOME%\bin\scalac.bat" (
echo %_ERROR_LABEL% Scala 3 executable not found ^("%_SCALA3_HOME%"^) 1>&2
set _EXITCODE=1
goto :eof
)
goto :eof
@rem output parameters: _SBT_HOME, _SBT_PATH
:sbt
set _SBT_HOME=
set _SBT_PATH=
set __SBT_CMD=
for /f "delims=" %%f in ('where sbt.bat 2^>NUL') do set "__SBT_CMD=%%f"
if defined __SBT_CMD (
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using path of sbt executable found in PATH 1>&2
@rem keep _SBT_PATH undefined since executable already in path
goto :eof
) else if defined SBT_HOME (
set "_SBT_HOME=%SBT_HOME%"
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using environment variable SBT_HOME 1>&2
) else (
set __PATH=C:\opt
if exist "!__PATH!\sbt\" ( set "_SBT_HOME=!__PATH!\sbt"
) else (
for /f "delims=" %%f in ('dir /ad /b "!__PATH!\sbt-1*" 2^>NUL') do set "_SBT_HOME=!__PATH!\%%f"
if not defined _SBT_HOME (
set "__PATH=%ProgramFiles%"
for /f "delims=" %%f in ('dir /ad /b "!__PATH!\sbt-1*" 2^>NUL') do set "_SBT_HOME=!__PATH!\%%f"
)
)
if defined _SBT_HOME (
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using default sbt installation directory "!_SBT_HOME!" 1>&2
)
)
if not exist "%_SBT_HOME%\bin\sbt.bat" (
echo %_ERROR_LABEL% sbt executable not found ^("%_SBT_HOME%"^) 1>&2
set _EXITCODE=1
goto :eof
)
set "_SBT_PATH=;%_SBT_HOME%\bin"
goto :eof
@rem output parameters: _ANT_HOME, _ANT_PATH
:ant
set _ANT_HOME=
set _ANT_PATH=
set __ANT_CMD=
for /f "delims=" %%f in ('where ant.bat 2^>NUL') do set "__ANT_CMD=%%f"
if defined __ANT_CMD (
for /f "delims=" %%i in ("%__ANT_CMD%") do set "__ANT_BIN_DIR=%%~dpi"
for /f "delims=" %%f in ("!__ANT_BIN_DIR!\.") do set "_ANT_HOME=%%~dpf"
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using path of Ant executable found in PATH 1>&2
@rem keep _ANT_PATH undefined since executable already in path
goto :eof
) else if defined ANT_HOME (
set "_ANT_HOME=%ANT_HOME%"
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using environment variable ANT_HOME 1>&2
) else (
set __PATH=C:\opt
if exist "!__PATH!\apache-ant\" ( set "_ANT_HOME=!__PATH!\apache-ant"
) else (
for /f "delims=" %%f in ('dir /ad /b "!__PATH!\apache-ant-*" 2^>NUL') do set "_ANT_HOME=!__PATH!\%%f"
if not defined _ANT_HOME (
set "__PATH=%ProgramFiles%"
for /f "delims=" %%f in ('dir /ad /b "!__PATH!\apache-ant-*" 2^>NUL') do set "_ANT_HOME=!__PATH!\%%f"
)
)
if defined _ANT_HOME (
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using default Ant installation directory "!_ANT_HOME!" 1>&2
)
)
if not exist "%_ANT_HOME%\bin\ant.cmd" (
echo %_ERROR_LABEL% Ant executable not found ^("%_ANT_HOME%"^) 1>&2
set _EXITCODE=1
goto :eof
)
set "_ANT_PATH=;%_ANT_HOME%\bin"
goto :eof
@rem output parameters: _BAZEL_HOME, _BAZEL_PATH
:bazel
set _BAZEL_HOME=
set _BAZEL_PATH=
set __BAZEL_CMD=
for /f "delims=" %%f in ('where bazel.exe 2^>NUL') do set "__BAZEL_CMD=%%f"
if defined __BAZEL_CMD (
for /f "delims=" %%i in ("%__BAZEL_CMD%") do set "_BAZEL_HOME=%%~dpi"
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using path of Bazel executable found in PATH 1>&2
@rem keep _BAZEL_PATH undefined since executable already in path
goto :eof
) else if defined BAZEL_HOME (
set "_BAZEL_HOME=%BAZEL_HOME%"
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using environment variable BAZEL_HOME 1>&2
) else (
set __PATH=C:\opt
if exist "!__PATH!\bazel\" ( set "_BAZEL_HOME=!__PATH!\bazel"
) else (
for /f "delims=" %%f in ('dir /ad /b "!__PATH!\bazel-*" 2^>NUL') do set "_BAZEL_HOME=!__PATH!\%%f"
if not defined _BAZEL_HOME (
set "__PATH=%ProgramFiles%"
for /f "delims=" %%f in ('dir /ad /b "!__PATH!\bazel-*" 2^>NUL') do set "_BAZEL_HOME=!__PATH!\%%f"
)
)
if defined _BAZEL_HOME (
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using default Bazel installation directory "!_BAZEL_HOME!" 1>&2
)
)
if not exist "%_BAZEL_HOME%\bazel.exe" (
echo %_ERROR_LABEL% Bazel executable not found ^("%_BAZEL_HOME%"^) 1>&2
set _EXITCODE=1
goto :eof
)
set "_BAZEL_PATH=;%_BAZEL_HOME%"
goto :eof
@rem http://www.benf.org/other/cfr/
@rem output parameter: _CFR_HOME
:cfr
set _CFR_HOME=
set __CFR_CMD=
for /f "delims=" %%f in ('where cfr.bat 2^>NUL') do set "__CFR_CMD=%%f"
if defined __CFR_CMD (
for /f "delims=" %%i in ("%__CFR_CMD%") do set "__CFR_BIN_DIR=%%~dpi"
for /f "delims=" %%f in ("!__CFR_BIN_DIR!\.") do set "_CFR_HOME=%%~dpf"
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using path of CFR executable found in PATH 1>&2
goto :eof
) else if defined CFR_HOME (
set "_CFR_HOME=%CFR_HOME%"
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using environment variable CFR_HOME 1>&2
) else (
set __PATH=C:\opt
for /f "delims=" %%f in ('dir /ad /b "!__PATH!\cfr*" 2^>NUL') do set "_CFR_HOME=!__PATH!\%%f"
if defined _CFR_HOME (
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using default CFR installation directory "!_CFR_HOME!" 1>&2
)
)
if not exist "%_CFR_HOME%\bin\cfr.bat" (
echo %_ERROR_LABEL% CFR executable not found ^("%_CFR_HOME%"^) 1>&2
set _EXITCODE=1
goto :eof
)
goto :eof
@rem output parameters: _COURSIER_HOME, _COURSIER_PATH
:coursier
set _COURSIER_HOME=
set _COURSIER_PATH=
set __CS_CMD=
for /f "delims=" %%f in ('where cs.exe 2^>NUL') do set "__CS_CMD=%%f"
if defined __CS_CMD (
for /f "delims=" %%i in ("%__CS_CMD%") do set "_COURSIER_HOME=%%~dpf"
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using path of Coursier executable found in PATH 1>&2
goto :eof
) else if defined COURSIER_HOME (
set "_COURSIER_HOME=%COURSIER_HOME%"
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using environment variable COURSIER_HOME 1>&2
) else (
set __PATH=C:\opt
if exist "!__PATH!\coursier\" ( set "_COURSIER_HOME=!__PATH!\coursier"
) else (
for /f "delims=" %%f in ('dir /ad /b "!__PATH!\coursier-*" 2^>NUL') do set "_COURSIER_HOME=!__PATH!\%%f"
if not defined _COURSIER_HOME (
set "__PATH=%ProgramFiles%"
for /f "delims=" %%f in ('dir /ad /b "!__PATH!\coursier-*" 2^>NUL') do set "_COURSIER_HOME=!__PATH!\%%f"
)
)
if defined _COURSIER_HOME (
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using default Coursier installation directory "!_COURSIER_HOME!" 1>&2
)
)
if not exist "%_COURSIER_HOME%\cs.exe" (
echo %_ERROR_LABEL% Coursier executable not found ^("%_COURSIER_HOME%"^) 1>&2
set _EXITCODE=1
goto :eof
)
set "_COURSIER_PATH=;%_COURSIER_HOME%"
goto :eof
@rem output parameters: _GRADLE_HOME, _GRADLE_PATH
:gradle
set _GRADLE_HOME=
set _GRADLE_PATH=
set __GRADLE_CMD=
for /f "delims=" %%f in ('where gradle.bat 2^>NUL') do set "__GRADLE_CMD=%%f"
if defined __GRADLE_CMD (
for /f "delims=" %%i in ("%__GRADLE_CMD%") do set "__GRADLE_BIN_DIR=%%~dpi"
for /f "delims=" %%f in ("!__GRADLE_BIN_DIR!\.") do set "_GRADLE_HOME=%%~dpf"
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using path of Gradle executable found in PATH 1>&2
@rem keep _GRADLE_PATH undefined since executable already in path
goto :eof
) else if defined GRADLE_HOME (
set "_GRADLE_HOME=%GRADLE_HOME%"
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using environment variable GRADLE_HOME 1>&2
) else (
set __PATH=C:\opt
if exist "!__PATH!\gradle\" ( set "_GRADLE_HOME=!__PATH!\gradle"
) else (
for /f "delims=" %%f in ('dir /ad /b "!__PATH!\gradle-*" 2^>NUL') do set "_GRADLE_HOME=!__PATH!\%%f"
if not defined _GRADLE_HOME (
set "__PATH=%ProgramFiles%"
for /f "delims=" %%f in ('dir /ad /b "!__PATH!\gradle-*" 2^>NUL') do set "_GRADLE_HOME=!__PATH!\%%f"
)
)
if defined _GRADLE_HOME (
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using default Gradle installation directory "!_GRADLE_HOME!" 1>&2
)
)
if not exist "%_GRADLE_HOME%\bin\gradle.bat" (
echo %_ERROR_LABEL% Gradle executable not found ^("%_GRADLE_HOME%"^) 1>&2
set _EXITCODE=1
goto :eof
)
set "_GRADLE_PATH=;%_GRADLE_HOME%\bin"
goto :eof
@rem output parameters: _JACOCO_HOME
:jacoco
set _JACOCO_HOME=
if defined JACOCO_HOME (
set "_JACOCO_HOME=%JACOCO_HOME%"
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using environment variable JACOCO_HOME 1>&2
) else (
set __PATH=C:\opt
if exist "!__PATH!\jacoco\" ( set "_JACOCO_HOME=!__PATH!\jacoco"
) else (
for /f "delims=" %%f in ('dir /ad /b "!__PATH!\jacoco-*" 2^>NUL') do set "_JACOCO_HOME=!__PATH!\%%f"
if not defined _JACOCO_HOME (
set "__PATH=%ProgramFiles%"
for /f "delims=" %%f in ('dir /ad /b "!__PATH!\jacoco-*" 2^>NUL') do set "_JACOCO_HOME=!__PATH!\%%f"
)
)
if defined _JACOCO_HOME (
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using default JaCoCo installation directory "!_JACOCO_HOME!" 1>&2
)
)
if not exist "%_JACOCO_HOME%\lib\jacococli.jar" (
echo %_ERROR_LABEL% JaCoCo library not found ^("%_JACOCO_HOME%"^) 1>&2
set _EXITCODE=1
goto :eof
)
goto :eof
@rem output parameter: _JAVAFX_HOME
:javafx
set _JAVAFX_HOME=
if defined JAVAFX_HOME (
set "_JAVAFX_HOME=%JAVAFX_HOME%"
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using environment variable JAVAFX_HOME 1>&2
) else (
set __PATH=C:\opt
if exist "!__PATH!\javafx\" ( set "_JAVAFX_HOME=!__PATH!\javafx"
) else (
for /f "delims=" %%f in ('dir /ad /b "!__PATH!\javafx-*" 2^>NUL') do set "_JAVAFX_HOME=!__PATH!\%%f"
if not defined _JAVAFX_HOME (
set "__PATH=%ProgramFiles%"
for /f "delims=" %%f in ('dir /ad /b "!__PATH!\javafx-*" 2^>NUL') do set "_JAVAFX_HOME=!__PATH!\%%f"
)
)
if defined _JAVAFX_HOME (
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using default JavaFX installation directory "!_JAVAFX_HOME!" 1>&2
)
)
if not exist "%_JAVAFX_HOME%\lib\javafx.graphics.jar" (
echo %_ERROR_LABEL% JavaFX Graphics library not found ^("%_JAVAFX_HOME%"^) 1>&2
set _EXITCODE=1
goto :eof
)
goto :eof
@rem output parameters: _JMC_HOME, _JMC_PATH
:jmc
set _JMC_HOME=
set _JMC_PATH=
set __JMC_CMD=
for /f "delims=" %%f in ('where jmc.exe 2^>NUL') do set "__JMC_CMD=%%f"
if defined __JMC_CMD (
for /f "delims=" %%i in ("%__JMC_CMD%") do set "__JMC_BIN_DIR=%%~dpi"
for /f "delims=" %%f in ("!__JMC_BIN_DIR!\.") do set "_JMC_HOME=%%~dpf"
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using path of JMC executable found in PATH 1>&2
@rem keep _JMC_PATH undefined since executable already in path
goto :eof
) else if defined JMC_HOME (
set "_JMC_HOME=%JMC_HOME%"
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using environment variable JMC_HOME 1>&2
) else (
set __PATH=C:\opt
if exist "!__PATH!\jmc\" ( set "_JMC_HOME=!__PATH!\jmc"
) else (
for /f "delims=" %%f in ('dir /ad /b "!__PATH!\jmc-*" 2^>NUL') do set "_JMC_HOME=!__PATH!\%%f"
if not defined _JMC_HOME (
set "__PATH=%ProgramFiles%"
for /f "delims=" %%f in ('dir /ad /b "!__PATH!\jmc-*" 2^>NUL') do set "_JMC_HOME=!__PATH!\%%f"
)
)
if defined _JMC_HOME (
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using default JMC installation directory "!_JMC_HOME!" 1>&2
)
)
if not exist "%_JMC_HOME%\bin\jmc.exe" (
echo %_ERROR_LABEL% JMC executable not found ^("%_JMC_HOME%"^) 1>&2
set _EXITCODE=1
goto :eof
)
set "_JMC_PATH=;%_JMC_HOME%\bin"
goto :eof
@rem output parameters: _MAVEN_HOME, _MAVEN_PATH
:maven
set _MAVEN_HOME=
set _MAVEN_PATH=
set __MVN_CMD=
for /f "delims=" %%f in ('where mvn.cmd 2^>NUL') do (
set "__MVN_CMD=%%f"
@rem we ignore Scoop managed Maven installation
if not "!__MVN_CMD:scoop=!"=="!__MVN_CMD!" set __MVN_CMD=
)
if defined __MVN_CMD (
for /f "delims=" %%i in ("%__MVN_CMD%") do set "__MAVEN_BIN_DIR=%%~dpi"
for /f "delims=" %%f in ("!__MAVEN_BIN_DIR!\.") do set "_MAVEN_HOME=%%~dpf"
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using path of Maven executable found in PATH 1>&2
@rem keep _MAVEN_PATH undefined since executable already in path
goto :eof
) else if defined MAVEN_HOME (
set "_MAVEN_HOME=%MAVEN_HOME%"
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using environment variable MAVEN_HOME 1>&2
) else (
set __PATH=C:\opt
if exist "!__PATH!\apache-maven\" ( set "_MAVEN_HOME=!__PATH!\apache-maven"
) else (
for /f "delims=" %%f in ('dir /ad /b "!__PATH!\apache-maven-*" 2^>NUL') do set "_MAVEN_HOME=!__PATH!\%%f"
if not defined _MAVEN_HOME (
set "__PATH=%ProgramFiles%"
for /f "delims=" %%f in ('dir /ad /b "!__PATH!\apache-maven-*" 2^>NUL') do set "_MAVEN_HOME=!__PATH!\%%f"
)
)
if defined _MAVEN_HOME (
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using default Maven installation directory "!_MAVEN_HOME!" 1>&2
)
)
if not exist "%_MAVEN_HOME%\bin\mvn.cmd" (
echo %_ERROR_LABEL% Maven executable not found ^("%_MAVEN_HOME%"^) 1>&2
set _EXITCODE=1
goto :eof
)
set "_MAVEN_PATH=;%_MAVEN_HOME%\bin"
goto :eof
:maven_plugin
set __JAR_FILE=
for /f "delims=" %%f in ('dir /s /b "%USERPROFILE%\.m2\repository\scala-maven-plugin-*.jar" 2^>NUL') do (
set "__JAR_FILE=%%f"
)
if not defined __JAR_FILE (
echo %_WARNING_LABEL% Scala Maven plugin not found 1>&2
echo ^(archive file is https://github.com/michelou/dotty-examples/tree/master/bin/scala-maven-plugin-1.0.zip^)
)
goto :eof
@rem output parameters: _MILL_HOME, _MILL_PATH
:mill
set _MILL_HOME=
set _MILL_PATH=
set __MILL_CMD=
for /f "delims=" %%f in ('where mill.bat 2^>NUL') do set "__MILL_CMD=%%f"
if defined __MILL_CMD (
for /f "delims=" %%i in ("%__MILL_CMD%") do set "_MILL_HOME=%%~dpi"
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using path of Mill executable found in PATH 1>&2
@rem keep _MILL_PATH undefined since executable already in path
goto :eof
) else if defined MILL_HOME (
set "_MILL_HOME=%MILL_HOME%"
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using environment variable MILL_HOME 1>&2
) else (
set __PATH=C:\opt
if exist "!__PATH!\mill\" ( set "_MILL_HOME=!__PATH!\mill"
) else (
for /f "delims=" %%f in ('dir /ad /b "!__PATH!\mill-*" 2^>NUL') do set "_MILL_HOME=!__PATH!\%%f"
if not defined _MILL_HOME (
set "__PATH=%ProgramFiles%"
for /f "delims=" %%f in ('dir /ad /b "!__PATH!\mill-*" 2^>NUL') do set "_MILL_HOME=!__PATH!\%%f"
)
)
if defined _MILL_HOME (
if %_DEBUG%==1 echo %_DEBUG_LABEL% Using default Mill installation directory "!_MILL_HOME!" 1>&2
)
)
if not exist "%_MILL_HOME%\mill.bat" (
echo %_ERROR_LABEL% Mill executable not found ^("%_MILL_HOME%"^) 1>&2
set _EXITCODE=1
goto :eof
)
set "_MILL_PATH=;%_MILL_HOME%"
goto :eof
@rem output parameter: _MSVS_HOME
:msvs
set _MSVS_HOME=
set "__WSWHERE_CMD=%_ROOT_DIR%bin\vswhere.exe"
for /f "delims=" %%f in ('"%__WSWHERE_CMD%" -property installationPath 2^>NUL') do set "_MSVS_HOME=%%~f"
if not exist "%_MSVS_HOME%\" (
echo %_ERROR_LABEL% Could not find installation directory for Microsoft Visual Studio 2019 1>&2
echo ^(see https://github.com/oracle/graal/blob/master/compiler/README.md^) 1>&2
set _EXITCODE=1
goto :eof
)
call :subst_path "%_MSVS_HOME%"
if not %_EXITCODE%==0 goto :eof
set "_MSVS_HOME=%_SUBST_PATH%"
goto :eof
@rem input parameter: %1=directory path
@rem output parameter: _SUBST_PATH
:subst_path
set "_SUBST_PATH=%~1"
set __DRIVE_NAME=X:
set __ASSIGNED_PATH=
for /f "tokens=1,2,*" %%f in ('subst ^| findstr /b "%__DRIVE_NAME%" 2^>NUL') do (
if not "%%h"=="%_SUBST_PATH%" (
echo %_WARNING_LABEL% Drive %__DRIVE_NAME% already assigned to "%%h" 1>&2
goto subst_path_end
)
set "__ASSIGNED_PATH=%%h"
)
if not defined __ASSIGNED_PATH (
if %_DEBUG%==1 echo %_DEBUG_LABEL% subst "%__DRIVE_NAME%" "%_SUBST_PATH%" 1>&2
subst "%__DRIVE_NAME%" "%_SUBST_PATH%"
if not !ERRORLEVEL!==0 (