forked from datastax/cpp-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vc_build.bat
1533 lines (1420 loc) · 65.3 KB
/
vc_build.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
REM Copyright 2014-2015 DataStax
REM
REM Licensed under the Apache License, Version 2.0 (the "License");
REM you may not use this file except in compliance with the License.
REM You may obtain a copy of the License at
REM
REM http://www.apache.org/licenses/LICENSE-2.0
REM
REM Unless required by applicable law or agreed to in writing, software
REM distributed under the License is distributed on an "AS IS" BASIS,
REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
REM See the License for the specific language governing permissions and
REM limitations under the License.
REM Enable delayed expansion (multiple var assignments) and local variables
SETLOCAL ENABLEDELAYEDEXPANSION
SET BATCH_DIRECTORY=%~D0%~P0
SET ABSOLUTE_BATCH_DIRECTORY=%~DP0
SET BATCH_FILENAME=%~N0%~X0
REM Exit code constants
SET EXIT_CODE_INVALID_SYSTEM_ARCHITECTURE=1
SET EXIT_CODE_MISSING_VISUAL_STUDIO=2
SET EXIT_CODE_MISSING_BUILD_DEPENDENCY=3
SET EXIT_CODE_INVALID_BUILD_DEPENDENCY_VERSION=4
SET EXIT_CODE_CLONE_FAILED=5
SET EXIT_CODE_BUILD_DEPENDENCY_FAILED=6
SET EXIT_CODE_BUILD_DRIVER_FAILED=7
SET EXIT_CODE_INVALID_VERSION=8
SET EXIT_CODE_PACKAGE_FAILED=9
REM Argument constants
SET ARGUMENT_BUILD_TYPE_DEBUG=--DEBUG
SET ARGUMENT_BUILD_TYPE_RELEASE=--RELEASE
SET ARGUMENT_DISABLE_CLEAN_BUILD=--DISABLE-CLEAN
SET ARGUMENT_DISABLE_OPENSSL=--DISABLE-OPENSSL
SET ARGUMENT_ENABLE_EXAMPLES=--ENABLE-EXAMPLES
SET ARGUMENT_ENABLE_BUILD_PACKAGES=--ENABLE-PACKAGES
SET ARGUMENT_ENABLE_TESTS=--ENABLE-TESTS
SET ARGUMENT_ENABLE_ZLIB=--ENABLE-ZLIB
SET ARGUMENT_GENERATE_SOLUTION=--GENERATE-SOLUTION
SET ARGUMENT_INSTALLATION_DIRECTORY=--INSTALL-DIR
SET ARGUMENT_USE_BOOST_ATOMIC=--USE-BOOST-ATOMIC
SET ARGUMENT_LIBRARY_TYPE_SHARED=--SHARED
SET ARGUMENT_LIBRARY_TYPE_STATIC=--STATIC
SET ARGUMENT_TARGET_ARCHITECTURE_32BIT=--X86
SET ARGUMENT_TARGET_ARCHITECTURE_64BIT=--X64
SET ARGUMENT_TARGET_COMPILER=--TARGET-COMPILER
SET ARGUMENT_HELP=--HELP
REM Option/Value constants
SET ARCHITECTURE_32BIT=32
SET ARCHITECTURE_64BIT=64
SET BUILD_TYPE_DEBUG=DEBUG
SET BUILD_TYPE_RELEASE=RELEASE
SET LIBRARY_TYPE_SHARED=SHARED
SET LIBRARY_TYPE_STATIC=STATIC
SET TRUE=1
SET FALSE=0
SET YES=1
SET NO=2
REM Determine the system architecture (32/64 bit)
SET ARCHITECTURE_REGISTRY_LOCATION_QUERY=HKLM\HARDWARE\DESCRIPTION\System\CentralProcessor\0
SET ARCHITECTURE_REGISTRY_LOCATION_KEY=Identifier
REG QUERY %ARCHITECTURE_REGISTRY_LOCATION_QUERY% /V %ARCHITECTURE_REGISTRY_LOCATION_KEY% | FIND /I "x86" > NUL && SET SYSTEM_ARCHITECTURE=%ARCHITECTURE_32BIT% || SET SYSTEM_ARCHITECTURE=%ARCHITECTURE_64BIT%
REM Dependency executable constants
SET CMAKE=cmake.exe
SET "DOWNLOAD_URL_CMAKE=http://www.cmake.org/download"
SET GIT=git.exe
SET "DOWNLOAD_URL_GIT=http://git-scm.com/downloads"
SET PERL=perl.exe
SET "DOWNLOAD_URL_PERL=https://www.perl.org/get.html#win32"
SET PYTHON=python.exe
SET "DOWNLOAD_URL_PYTHON=https://www.python.org/downloads/"
SET DEVENV=devenv.exe
SET MSBUILD=msbuild.exe
SET NMAKE=nmake.exe
SET "DOWNLOAD_URL_VISUAL_STUDIO=https://go.microsoft.com/fwlink/?LinkId=615464&clcid=0x409"
SET ZIP=7z.exe
SET "DOWNLOAD_URL_ZIP=http://www.7-zip.org/download.html"
REM Minimum version build dependency constants
SET MINIMUM_VERSION_REQUIRED_CMAKE=3.1.2
SET MINIMUM_VERSION_REQUIRED_PYTHON=2.7.0
REM Build constants
SET BUILD_DIRECTORY=build
SET "ABSOLUTE_BUILD_DIRECTORY=%BATCH_DIRECTORY%\%BUILD_DIRECTORY%"
SET BUILD_PACKAGE_PREFIX=cassandra-cpp-driver
SET DRIVER_DRIVER_DIRECTORY=driver
SET PACKAGES_DIRECTORY=packages
SET "ABSOLUTE_PACKAGES_DIRECTORY=%ABSOLUTE_BUILD_DIRECTORY%\%PACKAGES_DIRECTORY%"
REM Build dependency constants
SET DEPENDENCIES_DIRECTORY=dependencies
SET "ABSOLUTE_DEPENDENCIES_DIRECTORY=%ABSOLUTE_BUILD_DIRECTORY%\%DEPENDENCIES_DIRECTORY%"
SET DEPENDENCIES_SOURCE_DIRECTORY=src
SET DEPENDENCIES_LIBRARIES_DIRECTORY=libs
SET BOOST_REPOSITORY_URL=https://github.com/boostorg/
SET BOOST_DIRECTORY=boost
SET BOOST_BRANCH_TAG_VERSION=boost-1.59.0
SET LIBUV_REPOSITORY_URL=https://github.com/libuv/libuv.git
SET LIBUV_DIRECTORY=libuv
SET LIBUV_BRANCH_TAG_VERSION=v1.7.5
SET LIBUV_PACKAGE_VERSION=1.7.5
SET GYP_REPOSITORY_URL=https://chromium.googlesource.com/external/gyp.git
SET LIBSSH2_REPOSITORY_URL=https://github.com/libssh2/libssh2.git
SET LIBSSH2_DIRECTORY=libssh2
SET LIBSSH2_BRANCH_TAG_VERSION=master
SET OPENSSL_REPOSITORY_URL=https://github.com/openssl/openssl.git
SET OPENSSL_DIRECTORY=openssl
SET OPENSSL_BRANCH_TAG_VERSION=OpenSSL_1_0_2d
SET OPENSSL_PACKAGE_VERSION=1.0.2d
SET ZLIB_REPOSITORY_URL=https://github.com/madler/zlib.git
SET ZLIB_DIRECTORY=zlib
SET ZLIB_BRANCH_TAG_VERSION=v1.2.8
REM Library directory constants
SET LIBRARY_INCLUDE_DIRECTORY=include
SET LIBRARY_BINARY_DIRECTORY=lib
SET LIBRARY_RUNTIME_DIRECTORY=bin
SET "ABSOLUTE_DRIVER_LIBRARY_DIRECTORY=%ABSOLUTE_BUILD_DIRECTORY%\%LIBRARY_BINARY_DIRECTORY%"
SET "ABSOLUTE_DEPENDENCIES_LIBRARIES_DIRECTORY=%ABSOLUTE_DEPENDENCIES_DIRECTORY%\%DEPENDENCIES_LIBRARIES_DIRECTORY%"
SET "ABSOLUTE_LIBUV_LIBRARY_DIRECTORY=%ABSOLUTE_DEPENDENCIES_LIBRARIES_DIRECTORY%\%LIBUV_DIRECTORY%"
SET "ABSOLUTE_LIBSSH2_LIBRARY_DIRECTORY=%ABSOLUTE_DEPENDENCIES_LIBRARIES_DIRECTORY%\%LIBSSH2_DIRECTORY%"
SET "ABSOLUTE_OPENSSL_LIBRARY_DIRECTORY=%ABSOLUTE_DEPENDENCIES_LIBRARIES_DIRECTORY%\%OPENSSL_DIRECTORY%"
SET "ABSOLUTE_ZLIB_LIBRARY_DIRECTORY=%ABSOLUTE_DEPENDENCIES_LIBRARIES_DIRECTORY%\%ZLIB_DIRECTORY%"
REM Log filename constants
SET LOG_DIRECTORY=log
SET "ABSOLUTE_LOG_DIRECTORY=%ABSOLUTE_BUILD_DIRECTORY%\%LOG_DIRECTORY%"
SET "LOG_BOOST_CLONE=%ABSOLUTE_LOG_DIRECTORY%\boost.log"
SET "LOG_DRIVER_BUILD=%ABSOLUTE_LOG_DIRECTORY%\driver.log"
SET "LOG_LIBUV_BUILD=%ABSOLUTE_LOG_DIRECTORY%\libuv.log"
SET "LOG_LIBSSH2_BUILD=%ABSOLUTE_LOG_DIRECTORY%\libssh2.log"
SET "LOG_OPENSSL_BUILD=%ABSOLUTE_LOG_DIRECTORY%\openssl.log"
SET "LOG_PACKAGE_BUILD=%ABSOLUTE_LOG_DIRECTORY%\package.log"
SET "LOG_ZLIB_BUILD=%ABSOLUTE_LOG_DIRECTORY%\zlib.log"
REM Build defaults (can be updated via command line)
SET BUILD_TYPE=%BUILD_TYPE_RELEASE%
SET ENABLE_BUILD_PACKAGES=%FALSE%
SET ENABLE_CLEAN_BUILD=%TRUE%
SET ENABLE_EXAMPLES=%FALSE%
SET ENABLE_LIBSSH2=%FALSE%
SET ENABLE_OPENSSL=%TRUE%
SET ENABLE_TESTS=%FALSE%
SET ENABLE_ZLIB=%FALSE%
SET GENERATE_SOLUTION=%FALSE%
SET LIBRARY_TYPE=%LIBRARY_TYPE_SHARED%
SET TARGET_ARCHITECTURE=%SYSTEM_ARCHITECTURE%
SET USE_BOOST_ATOMIC=%FALSE%
REM Parse command line arguments
:ARGUMENT_LOOP
IF NOT [%1] == [] (
REM Get the current argument
CALL :UPPERCASE %1 ARGUMENT
SHIFT
REM Build type (debug/release)
IF "!ARGUMENT!" == "!ARGUMENT_BUILD_TYPE_DEBUG!" (
SET BUILD_TYPE=!BUILD_TYPE_DEBUG!
)
IF "!ARGUMENT!" == "!ARGUMENT_BUILD_TYPE_RELEASE!" (
SET BUILD_TYPE=!BUILD_TYPE_RELEASE!
)
REM Library type
IF "!ARGUMENT!" == "!ARGUMENT_LIBRARY_TYPE_SHARED!" (
SET LIBRARY_TYPE=!LIBRARY_TYPE_SHARED!
)
IF "!ARGUMENT!" == "!ARGUMENT_LIBRARY_TYPE_STATIC!" (
SET LIBRARY_TYPE=!LIBRARY_TYPE_STATIC!
)
REM Target architecture (32/64 bit)
IF "!ARGUMENT!" == "!ARGUMENT_TARGET_ARCHITECTURE_32BIT!" (
SET TARGET_ARCHITECTURE=!ARCHITECTURE_32BIT!
)
IF "!ARGUMENT!" == "!ARGUMENT_TARGET_ARCHITECTURE_64BIT!" (
REM Ensure the 64-bit build would be able to proceed
IF NOT !SYSTEM_ARCHITECTURE! EQU !ARCHITECTURE_64BIT! (
ECHO Invalid System Architecture: Unable to build 64-bit project on 32-bit OS
EXIT /B !EXIT_CODE_INVALID_SYSTEM_ARCHITECTURE!
)
SET TARGET_ARCHITECTURE=!ARCHITECTURE_64BIT!
)
REM Target compiler (VS/Windows SDK)
IF "!ARGUMENT!" == "!ARGUMENT_TARGET_COMPILER!" (
REM Make sure the compiler is valid
IF [%2] == [] (
ECHO Invalid Compiler: Visual Studio/Windows SDK version must be supplied
EXIT /B !EXIT_CODE_MISSING_VISUAL_STUDIO!
) ELSE (
REM Get the compiler version to use
CALL :UPPERCASE %2 TARGET_COMPILER_VERSION
SHIFT
REM Ensure the targeted compiler is valid
IF NOT "!TARGET_COMPILER_VERSION!" == "100" (
IF NOT "!TARGET_COMPILER_VERSION!" == "110" (
IF NOT "!TARGET_COMPILER_VERSION!" == "120" (
IF NOT "!TARGET_COMPILER_VERSION!" == "140" (
IF NOT "!TARGET_COMPILER_VERSION!" == "WINSDK" (
ECHO Invalid Compiler Version: 100, 110, 120, 140, or WINSDK must be supplied
EXIT /B !EXIT_CODE_MISSING_VISUAL_STUDIO!
)
)
)
)
)
)
)
REM Enable build of examples
IF "!ARGUMENT!" == "!ARGUMENT_ENABLE_EXAMPLES!" (
SET ENABLE_EXAMPLES=!TRUE!
)
REM Enable package build
IF "!ARGUMENT!" == "!ARGUMENT_ENABLE_BUILD_PACKAGES!" (
SET ENABLE_BUILD_PACKAGES=!TRUE!
REM Make sure the version information exists
IF [%2] == [] (
ECHO Invalid Version: Version must be supplied when enabling packages
EXIT /B !EXIT_CODE_INVALID_VERSION!
) ELSE (
REM Get the version information
SET "BUILD_PACKAGE_VERSION=%2"
SHIFT
)
)
REM Enable build of tests
IF "!ARGUMENT!" == "!ARGUMENT_ENABLE_TESTS!" (
SET ENABLE_TESTS=!TRUE!
REM Make sure the Boost root directory exists
IF [%2] == [] (
ECHO Invalid Boost Root Directory: Location of Boost must be supplied
EXIT /B !EXIT_CODE_MISSING_BUILD_DEPENDENCY!
) ELSE (
REM Get the Boost root directory
SET "BOOST_ROOT_DIRECTORY=%2"
IF NOT EXIST "!BOOST_ROOT_DIRECTORY!" (
ECHO Invalid Boost Root Directory: Location does not exist [%2]
EXIT /B !EXIT_CODE_MISSING_BUILD_DEPENDENCY!
)
SHIFT
)
)
REM Enable zlib (clone and build)
IF "!ARGUMENT!" == "!ARGUMENT_ENABLE_ZLIB!" (
SET ENABLE_ZLIB=!TRUE!
)
REM Disable clean build
IF "!ARGUMENT!" == "!ARGUMENT_DISABLE_CLEAN_BUILD!" (
SET ENABLE_CLEAN_BUILD=!FALSE!
)
REM Disable OpenSSL (clone and build)
IF "!ARGUMENT!" == "!ARGUMENT_DISABLE_OPENSSL!" (
SET ENABLE_OPENSSL=!FALSE!
)
REM Generate Visual Studio solution (no build)
IF "!ARGUMENT!" == "!ARGUMENT_GENERATE_SOLUTION!" (
SET GENERATE_SOLUTION=!TRUE!
)
REM Update installation directory for the driver
IF "!ARGUMENT!" == "!ARGUMENT_INSTALLATION_DIRECTORY!" (
REM Make sure the installation directory is available
IF [%2] == [] (
ECHO Invalid Installation Directory: Directory must be supplied
EXIT /B !EXIT_CODE_MISSING_BUILD_DEPENDENCY!
) ELSE (
REM Get the driver installation directory
SET "DRIVER_INSTALLATION_DIRECTORY=%2"
SHIFT
)
)
REM Enable the use of Boost atomic library (header only)
IF "!ARGUMENT!" == "!ARGUMENT_USE_BOOST_ATOMIC!" (
SET USE_BOOST_ATOMIC=!TRUE!
)
REM Help message
IF "!ARGUMENT!" == "!ARGUMENT_HELP!" (
CALL :DISPLAYHELP 0
EXIT /B
)
REM Continue to loop through the command line arguments
GOTO :ARGUMENT_LOOP
)
REM Ensure static builds, OpenSSL is enabled, and packages are disabled
IF !ENABLE_TESTS! EQU !TRUE! (
REM Enable test dependencies
SET LIBRARY_TYPE=!LIBRARY_TYPE_STATIC!
SET ENABLE_LIBSSH2=!TRUE!
SET ENABLE_OPENSSL=!TRUE!
REM Determine if package build should be disabled
IF !ENABLE_BUILD_PACKAGES! EQU !TRUE! (
ECHO Disabling Package Build: !ARGUMENT_ENABLE_TESTS! overrides packages
SET ENABLE_BUILD_PACKAGES=!FALSE!
)
)
REM Determine if zlib should be enabled
IF !ENABLE_ZLIB! EQU !TRUE! (
SET ENABLE_ZLIB_IS_VALID=!FALSE!
IF !ENABLE_LIBSSH! EQU !TRUE! SET ENABLE_ZLIB_IS_VALID=!TRUE!
IF !ENABLE_OPENSSL! EQU !TRUE! SET ENABLE_ZLIB_IS_VALID=!TRUE!
SET ENABLE_ZLIB=!ENABLE_ZLIB_IS_VALID!
)
REM Determine Visual Studio Version(s) available
SET "VISUAL_STUDIO_INTERNAL_VERSIONS=140 120 110 100"
SET "VISUAL_STUDIO_INTERNAL_SHORTHAND_VERSIONS=14 12 11 10"
SET "VISUAL_STUDIO_VERSIONS=2015 2013 2012 2010"
SET INDEX=0
SET TARGET_COMPILER_VERSION_FOUND=!FALSE!
FOR %%A IN (!VISUAL_STUDIO_INTERNAL_VERSIONS!) DO (
SET /A INDEX+=1
IF DEFINED VS%%ACOMNTOOLS (
SET "AVAILABLE_VISUAL_STUDIO_VERSIONS=!AVAILABLE_VISUAL_STUDIO_VERSIONS! !INDEX!"
REM Determine if targeted version can be detected
IF NOT "!TARGET_COMPILER_VERSION!" == "WINSDK" (
IF %%A EQU !TARGET_COMPILER_VERSION! (
REM Indicate the compiler was found and set the user choice
SET TARGET_COMPILER_VERSION_FOUND=!TRUE!
SET USER_CHOICE_ENTRY=!INDEX!
)
)
)
)
REM Determine Windows SDK Version(s) available
SET "WINDOWS_SDK_VERSIONS=v7.1 v8.0 v8.1"
IF DEFINED WindowsSDKDir (
IF DEFINED WindowsSDKVersionOverride (
CALL :GETVALUE WindowsSDKVersionOverride WINDOWS_SDK_VERSION
SET INDEX=0
FOR %%A IN (!WINDOWS_SDK_VERSIONS!) DO (
SET /A INDEX+=1
CALL :GETARRAYELEMENT WINDOWS_SDK_VERSIONS !INDEX! CHECK_WINDOWS_SDK_VERSION
IF "!WINDOWS_SDK_VERSION!" == "!CHECK_WINDOWS_SDK_VERSION!" (
SET WINDOWS_SDK_FOUND=!TRUE!
REM Determine if targeted version can be detected
IF "!TARGET_COMPILER_VERSION!" == "WINSDK" (
SET TARGET_COMPILER_VERSION_FOUND=!TRUE!
)
)
)
)
)
REM Determine if targeted compiler was detected
IF NOT "!TARGET_COMPILER_VERSION!" == "" (
IF !TARGET_COMPILER_VERSION_FOUND! EQU !FALSE! (
ECHO Could Not Detect Compiler: !TARGET_COMPILER_VERSION! is not installed
)
)
REM Display discovered Visual Studio version(s) and Windows SDK version
set NUMBER_OF_VERSIONS=0
FOR %%A IN (!AVAILABLE_VISUAL_STUDIO_VERSIONS!) DO (
SET /A NUMBER_OF_VERSIONS+=1
)
IF DEFINED WINDOWS_SDK_FOUND SET /A NUMBER_OF_VERSIONS+=1
REM Determine if build can proceed
IF !NUMBER_OF_VERSIONS! EQU 0 (
ECHO Visual Studio Not Found: Install Visual Studio 2010 - 2015 to complete build
ECHO !DOWNLOAD_URL_VISUAL_STUDIO!
CHOICE /N /T 15 /D N /M "Would you like to download Visual Studio 2015 Express now?"
IF !ERRORLEVEL! EQU !YES! START !DOWNLOAD_URL_VISUAL_STUDIO!
EXIT /B !EXIT_CODE_MISSING_VISUAL_STUDIO!
)
REM Ensure additional build dependencies are installed
CALL :GETFULLPATH "!CMAKE!" CMAKE_FOUND
IF NOT DEFINED CMAKE_FOUND (
ECHO CMake Not Found in PATH: CMake v!MINIMUM_VERSION_REQUIRED_CMAKE! is required to complete build
ECHO !DOWNLOAD_URL_CMAKE!
CHOICE /N /T 15 /D N /M "Would you like to download CMake now?"
IF !ERRORLEVEL! EQU !YES! START !DOWNLOAD_URL_CMAKE!
EXIT /B !EXIT_CODE_MISSING_BUILD_DEPENDENCY!
) ELSE (
FOR /F "TOKENS=1,2,3* DELIMS= " %%A IN ('!CMAKE! --version') DO IF NOT DEFINED CMAKE_VERSION SET CMAKE_VERSION=%%C
CALL :COMPAREVERSION !CMAKE_VERSION! !MINIMUM_VERSION_REQUIRED_CMAKE!
IF !ERRORLEVEL! EQU -1 (
ECHO Invalid CMake Version Found: CMake v!MINIMUM_VERSION_REQUIRED_CMAKE! is required to complete build
ECHO !DOWNLOAD_URL_CMAKE!
CHOICE /N /T 15 /D N /M "Would you like to download CMake now?"
IF !ERRORLEVEL! EQU !YES! START !DOWNLOAD_URL_CMAKE!
EXIT /B !EXIT_CODE_INVALID_BUILD_DEPENDENCY_VERSION!
)
)
CALL :GETFULLPATH "!GIT!" GIT_FOUND
IF NOT DEFINED GIT_FOUND (
ECHO Git Not Found in PATH: Git is required to complete build
ECHO !DOWNLOAD_URL_GIT!
CHOICE /N /T 15 /D N /M "Would you like to download Git now?"
IF !ERRORLEVEL! EQU !YES! START !DOWNLOAD_URL_GIT!
EXIT /B !EXIT_CODE_MISSING_BUILD_DEPENDENCY!
)
CALL :GETFULLPATH "!PERL!" PERL_FOUND
IF NOT DEFINED PERL_FOUND (
REM Perl is only required for building/configuring OpenSSL
IF !ENABLE_OPENSSL! EQU !TRUE! (
ECHO Perl Not Found in PATH: Perl is required to complete build
ECHO !DOWNLOAD_URL_PERL!
CHOICE /N /T 15 /D N /M "Would you like to download Perl now?"
IF !ERRORLEVEL! EQU !YES! START !DOWNLOAD_URL_PERL!
EXIT /B !EXIT_CODE_MISSING_BUILD_DEPENDENCY!
)
)
CALL :GETFULLPATH "!PYTHON!" PYTHON_FOUND
IF NOT DEFINED PYTHON_FOUND (
ECHO Python Not Found in PATH: Python v!MINIMUM_VERSION_REQUIRED_PYTHON! is required to complete build
ECHO !DOWNLOAD_URL_PYTHON!
CHOICE /N /T 15 /D N /M "Would you like to download Python now?"
IF !ERRORLEVEL! EQU !YES! START !DOWNLOAD_URL_PYTHON!
EXIT /B !EXIT_CODE_MISSING_BUILD_DEPENDENCY!
) ELSE (
FOR /F "TOKENS=1,2* DELIMS= " %%A IN ('!PYTHON! --version 2^>^&1') DO IF NOT DEFINED PYTHON_VERSION SET PYTHON_VERSION=%%B
CALL :COMPAREVERSION !PYTHON_VERSION! !MINIMUM_VERSION_REQUIRED_PYTHON!
IF !ERRORLEVEL! EQU -1 (
ECHO Invalid Python Version Found: Python v!MINIMUM_VERSION_REQUIRED_PYTHON! is required to complete build
ECHO !DOWNLOAD_URL_PYTHON!
CHOICE /N /T 15 /D N /M "Would you like to download Python now?"
IF !ERRORLEVEL! EQU !YES! START !DOWNLOAD_URL_PYTHON!
EXIT /B !EXIT_CODE_INVALID_BUILD_DEPENDENCY_VERSION!
)
REM Python v3.x does not work properly with GYP (libuv build dependency)
CALL :COMPAREVERSION !PYTHON_VERSION! 3.0.0
IF !ERRORLEVEL! GEQ 0 (
ECHO Invalid Python Version Found: Python v3.x is not supported
ECHO !DOWNLOAD_URL_PYTHON!
CHOICE /N /T 15 /D N /M "Would you like to download Python now?"
IF !ERRORLEVEL! EQU !YES! START !DOWNLOAD_URL_PYTHON!
EXIT /B !EXIT_CODE_INVALID_BUILD_DEPENDENCY_VERSION!
)
)
REM Determine if we should allow the user to choose compiler version
IF "!ENABLE_BUILD_PACKAGES!" == "!FALSE!" (
IF !NUMBER_OF_VERSIONS! GTR 1 (
REM Display discovered Visual Studio versions for selection
SET INDEX=0
SET SELECTION_OPTIONS=
FOR %%A IN (!AVAILABLE_VISUAL_STUDIO_VERSIONS!) DO (
SET /A INDEX+=1
SET "SELECTION_OPTIONS=!SELECTION_OPTIONS!!INDEX!"
CALL :GETARRAYELEMENT VISUAL_STUDIO_VERSIONS %%A VISUAL_STUDIO_VERSION
ECHO !INDEX!^) Visual Studio !VISUAL_STUDIO_VERSION!
)
REM Display discovered Windows SDK version for selection
IF DEFINED WINDOWS_SDK_FOUND (
SET /A INDEX+=1
SET "SELECTION_OPTIONS=!SELECTION_OPTIONS!!INDEX!"
SET WINDOWS_SDK_SELECTION_OPTION=!INDEX!
ECHO !INDEX!^) Windows SDK !WINDOWS_SDK_VERSION!
)
REM Add the exit option
ECHO E^) Exit
SET "SELECTION_OPTIONS=!SELECTION_OPTIONS!E"
REM Determine if the targeted compiler should be used
IF !TARGET_COMPILER_VERSION_FOUND! EQU !TRUE! (
REM Make selection choice for the user
IF "!TARGET_COMPILER_VERSION!" == "WINSDK" SET USER_CHOICE_ENTRY=!WINDOWS_SDK_SELECTION_OPTION!
ECHO Please Select a Compiler: !USER_CHOICE_ENTRY!
) ELSE (
REM Present selection to the user
CHOICE /C !SELECTION_OPTIONS! /N /T 60 /D E /M "Please Select a Compiler:"
IF !ERRORLEVEL! GTR !NUMBER_OF_VERSIONS! (
EXIT /B
)
SET USER_CHOICE_ENTRY=!ERRORLEVEL!
)
ECHO.
REM Determine the selection
IF !USER_CHOICE_ENTRY! NEQ !WINDOWS_SDK_SELECTION_OPTION! (
CALL :GETARRAYELEMENT AVAILABLE_VISUAL_STUDIO_VERSIONS !USER_CHOICE_ENTRY! USER_SELECTION
CALL :GETARRAYELEMENT VISUAL_STUDIO_INTERNAL_VERSIONS !USER_SELECTION! VISUAL_STUDIO_INTERNAL_VERSION
CALL :GETARRAYELEMENT VISUAL_STUDIO_INTERNAL_SHORTHAND_VERSIONS !USER_SELECTION! VISUAL_STUDIO_INTERNAL_SHORTHAND_VERSION
CALL :GETARRAYELEMENT VISUAL_STUDIO_VERSIONS !USER_SELECTION! VISUAL_STUDIO_VERSION
REM Ensure the other versions of VSXXXCOMNTOOLS are undefined (unset)
FOR %%A IN (!VISUAL_STUDIO_INTERNAL_VERSIONS!) DO (
IF NOT %%A EQU !VISUAL_STUDIO_INTERNAL_VERSION! SET VS%%ACOMNTOOLS=
)
REM Ensure the Windows SDK version is undefined (unset)
IF DEFINED WindowsSDKDir SET WindowsSDKDir=
) ELSE (
SET WINDOWS_SDK_SELECTED=!TRUE!
)
) ELSE (
IF NOT DEFINED WINDOWS_SDK_FOUND (
CALL :GETARRAYELEMENT VISUAL_STUDIO_INTERNAL_VERSIONS !AVAILABLE_VISUAL_STUDIO_VERSIONS! VISUAL_STUDIO_INTERNAL_VERSION
CALL :GETARRAYELEMENT VISUAL_STUDIO_INTERNAL_SHORTHAND_VERSIONS !AVAILABLE_VISUAL_STUDIO_VERSIONS! VISUAL_STUDIO_INTERNAL_SHORTHAND_VERSION
CALL :GETARRAYELEMENT VISUAL_STUDIO_VERSIONS !AVAILABLE_VISUAL_STUDIO_VERSIONS! VISUAL_STUDIO_VERSION
) ELSE (
SET WINDOWS_SDK_SELECTED=!TRUE!
)
)
REM Ensure the environment is setup correctly; if Windows SDK build environment
IF DEFINED WINDOWS_SDK_FOUND (
CALL :CONFIGUREWINDOWSSDKENVIRONMENT !BUILD_TYPE! !TARGET_ARCHITECTURE!
)
REM Setup the Visual Studio environment for compiling
IF NOT DEFINED WINDOWS_SDK_SELECTED (
CALL :CONFIGUREVISUALSTUDIOENVIRONMENT !VISUAL_STUDIO_INTERNAL_VERSION! !TARGET_ARCHITECTURE!
)
CALL :GETFULLPATH "!DEVENV!" DEVENV_FOUND
CALL :GETFULLPATH "!MSBUILD!" MSBUILD_FOUND
CALL :GETFULLPATH "!NMAKE!" NMAKE_FOUND
REM Display summary of build options
ECHO Build Type: !BUILD_TYPE!
ECHO Clean Build: !ENABLE_CLEAN_BUILD!
ECHO Examples Enabled: !ENABLE_EXAMPLES!
ECHO Library Type: !LIBRARY_TYPE!
ECHO OpenSSL Enabled: !ENABLE_OPENSSL!
ECHO Tests Enabled: !ENABLE_TESTS!
ECHO zlib Enabled: !ENABLE_ZLIB!
ECHO Generate Solution !GENERATE_SOLUTION!
ECHO Target Architecture: !TARGET_ARCHITECTURE!
ECHO Use Boost Atomic: !USE_BOOST_ATOMIC!
IF NOT DEFINED WINDOWS_SDK_SELECTED (
ECHO Visual Studio: !VISUAL_STUDIO_VERSION!
) ELSE (
ECHO Windows SDK: !WINDOWS_SDK_VERSION!
)
ECHO.
) ELSE (
REM Ensure package properties are set (ignore commandline arguments)
SET BUILD_TYPE=!BUILD_TYPE_RELEASE!
SET ENABLE_CLEAN_BUILD=!TRUE!
SET ENABLE_EXAMPLES=!FALSE!
SET ENABLE_OPENSSL=!TRUE!
SET ENABLE_TESTS=!FALSE!
SET ENABLE_ZLIB=!FALSE!
SET GENERATE_SOLUTION=!FALSE!
SET USE_BOOST_ATOMIC=!TRUE!
REM Add common 7-zip locations to system path
SET "PATH=!PATH!;!PROGRAMFILES!\7-zip;!PROGRAMFILES(X86)!\7-zip"
REM Check for 7-zip to perform package installation
CALL :GETFULLPATH "!ZIP!" ZIP_FOUND
IF NOT DEFINED ZIP_FOUND (
ECHO 7-zip Not Found in PATH: 7-zip is required to build packages
ECHO !DOWNLOAD_URL_ZIP!
CHOICE /N /T 15 /D N /M "Would you like to download 7-zip now?"
IF !ERRORLEVEL! EQU !YES! START !DOWNLOAD_URL_ZIP!
EXIT /B !EXIT_CODE_MISSING_BUILD_DEPENDENCY!
)
)
REM Determine if the build should be cleaned
IF !ENABLE_CLEAN_BUILD! EQU !TRUE! (
CALL :CLEANDIRECTORY "!ABSOLUTE_BUILD_DIRECTORY!" "Cleaning build directory"
ECHO.
)
REM Prepare the build directories
IF NOT EXIST "!ABSOLUTE_BUILD_DIRECTORY!" MKDIR "!ABSOLUTE_BUILD_DIRECTORY!"
IF NOT EXIST "!ABSOLUTE_DEPENDENCIES_DIRECTORY!" MKDIR "!ABSOLUTE_DEPENDENCIES_DIRECTORY!"
IF NOT EXIST "!ABSOLUTE_LOG_DIRECTORY!" MKDIR "!ABSOLUTE_LOG_DIRECTORY!"
REM Move to the dependencies directory
PUSHD "!ABSOLUTE_DEPENDENCIES_DIRECTORY!" > NUL
ECHO Cloning Library Dependencies
REM Determine if Boost atomic dependency is required
IF !USE_BOOST_ATOMIC! EQU !TRUE! (
REM Determine if Boost atomic should be cloned
IF !ENABLE_TESTS! EQU !FALSE! (
REM Clone Boost atomic and checkout the appropriate tag
ECHO Gathering Boost atomic ^(and dependencies^) !BOOST_BRANCH_TAG_VERSION! > "!LOG_BOOST_CLONE!"
ECHO | SET /P=Gathering Boost atomic ^(and dependencies^) !BOOST_BRANCH_TAG_VERSION! ...
SET "BOOST_ATOMIC_DEPENDENCIES=atomic assert config mpl preprocessor static_assert type_traits"
IF NOT EXIST "!ABSOLUTE_DEPENDENCIES_DIRECTORY!\!DEPENDENCIES_SOURCE_DIRECTORY!\!BOOST_DIRECTORY!\include" MKDIR "!ABSOLUTE_DEPENDENCIES_DIRECTORY!\!DEPENDENCIES_SOURCE_DIRECTORY!\!BOOST_DIRECTORY!\include"
REM Store current Visual Studio tools environment variables
FOR %%A IN (!BOOST_ATOMIC_DEPENDENCIES!) DO (
!GIT! clone --depth 1 --branch !BOOST_BRANCH_TAG_VERSION! --single-branch !BOOST_REPOSITORY_URL!/%%A "!DEPENDENCIES_SOURCE_DIRECTORY!\!BOOST_DIRECTORY!\%%A" >> "!LOG_BOOST_CLONE!" 2>&1
IF !ERRORLEVEL! EQU 0 (
XCOPY /E /Y "!ABSOLUTE_DEPENDENCIES_DIRECTORY!\!DEPENDENCIES_SOURCE_DIRECTORY!\!BOOST_DIRECTORY!\%%A\include" "!ABSOLUTE_DEPENDENCIES_DIRECTORY!\!DEPENDENCIES_SOURCE_DIRECTORY!\!BOOST_DIRECTORY!\include" >> "!LOG_BOOST_CLONE!" 2>&1
IF NOT !ERRORLEVEL! EQU 0 (
ECHO FAILED!
ECHO See !LOG_BOOST_CLONE! for more details
EXIT /B !EXIT_CODE_CHECKOUT_FAILED!
)
) ELSE (
ECHO FAILED!
ECHO See !LOG_BOOST_CLONE! for more details
EXIT /B !EXIT_CODE_CLONE_FAILED!
)
)
ECHO done.
)
)
REM Clone libuv and checkout the appropriate tag
IF NOT EXIST "!DEPENDENCIES_SOURCE_DIRECTORY!\!LIBUV_DIRECTORY!" (
ECHO Cloning libuv !LIBUV_BRANCH_TAG_VERSION! > "!LOG_LIBUV_BUILD!"
ECHO | SET /P=Cloning libuv !LIBUV_BRANCH_TAG_VERSION! ...
!GIT! clone --depth 1 --branch !LIBUV_BRANCH_TAG_VERSION! --single-branch !LIBUV_REPOSITORY_URL! "!DEPENDENCIES_SOURCE_DIRECTORY!\!LIBUV_DIRECTORY!" >> "!LOG_LIBUV_BUILD!" 2>&1
IF !ERRORLEVEL! EQU 0 (
ECHO done.
REM Clone GYP (libuv dependency) to correctly use googlesource URL
ECHO. >> "!LOG_LIBUV_BUILD!"
ECHO Cloning gyp >> "!LOG_LIBUV_BUILD!"
ECHO | SET /P=Cloning gyp ...
!GIT! clone --depth 1 --single-branch !GYP_REPOSITORY_URL! "!DEPENDENCIES_SOURCE_DIRECTORY!\!LIBUV_DIRECTORY!\build\gyp" >> "!LOG_LIBUV_BUILD!" 2>&1
IF !ERRORLEVEL! EQU 0 (
ECHO done.
) ELSE (
ECHO FAILED!
ECHO See !LOG_LIBUV_BUILD! for more details
EXIT /B !EXIT_CODE_CLONE_FAILED!
)
) ELSE (
ECHO FAILED!
ECHO See !LOG_LIBUV_BUILD! for more details
EXIT /B !EXIT_CODE_CLONE_FAILED!
)
)
REM Clone zlib (libssh2 dependency) and checkout the appropriate tag
IF !ENABLE_ZLIB! EQU !TRUE! (
IF NOT EXIST "!DEPENDENCIES_SOURCE_DIRECTORY!\!ZLIB_DIRECTORY!" (
ECHO Cloning zlib !ZLIB_BRANCH_TAG_VERSION! > "!LOG_ZLIB_BUILD!"
ECHO | SET /P=Cloning zlib !ZLIB_BRANCH_TAG_VERSION! ...
!GIT! clone --depth 1 --branch !ZLIB_BRANCH_TAG_VERSION! --single-branch !ZLIB_REPOSITORY_URL! "!DEPENDENCIES_SOURCE_DIRECTORY!\!ZLIB_DIRECTORY!" >> "!LOG_ZLIB_BUILD!" 2>&1
IF !ERRORLEVEL! EQU 0 (
ECHO done.
) ELSE (
ECHO FAILED!
ECHO See !LOG_ZLIB_BUILD! for more details
EXIT /B !EXIT_CODE_CLONE_FAILED!
)
)
)
REM Determine if libssh2 should be cloned
IF !ENABLE_LIBSSH2! EQU !TRUE! (
REM Clone libssh2
IF NOT EXIST "!DEPENDENCIES_SOURCE_DIRECTORY!\!LIBSSH2_DIRECTORY!" (
ECHO Cloning libssh2 !LIBSSH2_BRANCH_TAG_VERSION! > "!LOG_LIBSSH2_BUILD!"
ECHO | SET /P=Cloning libssh2 !LIBSSH2_BRANCH_TAG_VERSION! ...
!GIT! clone --depth 1 --branch !LIBSSH2_BRANCH_TAG_VERSION! --single-branch !LIBSSH2_REPOSITORY_URL! "!DEPENDENCIES_SOURCE_DIRECTORY!\!LIBSSH2_DIRECTORY!" >> "!LOG_LIBSSH2_BUILD!" 2>&1
IF !ERRORLEVEL! EQU 0 (
ECHO done.
) ELSE (
ECHO FAILED!
ECHO See !LOG_LIBSSH2_BUILD! for more details
EXIT /B !EXIT_CODE_CLONE_FAILED!
)
)
)
REM Determine is OpenSSL should be cloned
IF !ENABLE_OPENSSL! EQU !TRUE! (
REM Clone OpenSSL and checkout the appropriate tag
IF NOT EXIST "!DEPENDENCIES_SOURCE_DIRECTORY!\!OPENSSL_DIRECTORY!" (
ECHO Cloning OpenSSL !OPENSSL_BRANCH_TAG_VERSION! > "!LOG_OPENSSL_BUILD!"
ECHO | SET /P=Cloning OpenSSL !OPENSSL_BRANCH_TAG_VERSION! ...
!GIT! clone --depth 1 --branch !OPENSSL_BRANCH_TAG_VERSION! --single-branch !OPENSSL_REPOSITORY_URL! "!DEPENDENCIES_SOURCE_DIRECTORY!\!OPENSSL_DIRECTORY!" >> "!LOG_OPENSSL_BUILD!" 2>&1
IF !ERRORLEVEL! EQU 0 (
ECHO done.
) ELSE (
ECHO FAILED!
ECHO See !LOG_OPENSSL_BUILD! for more details
EXIT /B !EXIT_CODE_CLONE_FAILED!
)
)
)
REM Move back to working directory
POPD
REM Determine if the packages are being built
ECHO.
IF "!ENABLE_BUILD_PACKAGES!" == "!FALSE!" (
ECHO Building Library Dependencies
REM Determine if libuv needs to be built
IF NOT EXIST "!ABSOLUTE_LIBUV_LIBRARY_DIRECTORY!" (
SET IS_WINDOWS_SDK_ENABLED=!FALSE!
IF DEFINED WINDOWS_SDK_SELECTED SET IS_WINDOWS_SDK_ENABLED=!TRUE!
CALL :BUILDLIBUV "!ABSOLUTE_DEPENDENCIES_DIRECTORY!\!DEPENDENCIES_SOURCE_DIRECTORY!\!LIBUV_DIRECTORY!" "!ABSOLUTE_LIBUV_LIBRARY_DIRECTORY!" !TARGET_ARCHITECTURE! !LIBRARY_TYPE! !IS_WINDOWS_SDK_ENABLED! !FALSE! "!LOG_LIBUV_BUILD!"
IF !ERRORLEVEL! NEQ 0 EXIT /B !ERRORLEVEL!
)
REM Determine if zlib needs to be built
IF !ENABLE_ZLIB! EQU !TRUE! (
IF NOT EXIST "!ABSOLUTE_ZLIB_LIBRARY_DIRECTORY!" (
CALL :BUILDZLIB "!ABSOLUTE_DEPENDENCIES_DIRECTORY!\!DEPENDENCIES_SOURCE_DIRECTORY!\!ZLIB_DIRECTORY!" "!ABSOLUTE_ZLIB_LIBRARY_DIRECTORY!" "!LOG_ZLIB_BUILD!"
IF !ERRORLEVEL! NEQ 0 EXIT /B !ERRORLEVEL!
)
) ELSE (
REM Indicate zlib is disable
SET ABSOLUTE_ZLIB_LIBRARY_DIRECTORY=
)
REM Determine is OpenSSL should be built
IF !ENABLE_OPENSSL! EQU !TRUE! (
REM Determine if OpenSSL needs to be built
IF NOT EXIST "!ABSOLUTE_OPENSSL_LIBRARY_DIRECTORY!" (
REM Determine if OpenSSL should be built with zlib support
CALL :BUILDOPENSSL "!ABSOLUTE_DEPENDENCIES_DIRECTORY!\!DEPENDENCIES_SOURCE_DIRECTORY!\!OPENSSL_DIRECTORY!" "!ABSOLUTE_OPENSSL_LIBRARY_DIRECTORY!" "!ABSOLUTE_ZLIB_LIBRARY_DIRECTORY!" !TARGET_ARCHITECTURE! !LIBRARY_TYPE! !FALSE! "!LOG_OPENSSL_BUILD!"
IF !ERRORLEVEL! NEQ 0 EXIT /B !ERRORLEVEL!
)
)
REM Determine is libssh2 should be built
IF !ENABLE_LIBSSH2! EQU !TRUE! (
REM Determine if libssh2 needs to be built
IF NOT EXIST "!ABSOLUTE_LIBSSH2_LIBRARY_DIRECTORY!" (
CALL :BUILDLIBSSH2 "!ABSOLUTE_DEPENDENCIES_DIRECTORY!\!DEPENDENCIES_SOURCE_DIRECTORY!\!LIBSSH2_DIRECTORY!" "!ABSOLUTE_LIBSSH2_LIBRARY_DIRECTORY!" "!ABSOLUTE_OPENSSL_LIBRARY_DIRECTORY!" "!ABSOLUTE_ZLIB_LIBRARY_DIRECTORY!" !TARGET_ARCHITECTURE! !VISUAL_STUDIO_INTERNAL_SHORTHAND_VERSION! "!LOG_LIBSSH2_BUILD!"
IF !ERRORLEVEL! NEQ 0 EXIT /B !ERRORLEVEL!
)
)
ECHO.
ECHO Building Driver
REM Determine if the driver needs to be built
SET DRIVER_INSTALLATION_DIRECTORY_OVERRIDDEN=!TRUE!
IF "!DRIVER_INSTALLATION_DIRECTORY!" == "" (
SET "DRIVER_INSTALLATION_DIRECTORY=!ABSOLUTE_DRIVER_LIBRARY_DIRECTORY!"
SET DRIVER_INSTALLATION_DIRECTORY_OVERRIDDEN=!FALSE!
)
IF NOT EXIST "!DRIVER_INSTALLATION_DIRECTORY!" (
SET BOOST_DEPENDENCY_SOURCE_DIRECTORY=
IF !USE_BOOST_ATOMIC! EQU !TRUE! SET "BOOST_DEPENDENCY_SOURCE_DIRECTORY=!ABSOLUTE_DEPENDENCIES_DIRECTORY!\!DEPENDENCIES_SOURCE_DIRECTORY!\!BOOST_DIRECTORY!"
CALL :BUILDDRIVER "!ABSOLUTE_BATCH_DIRECTORY!" "!ABSOLUTE_BUILD_DIRECTORY!\!DRIVER_DRIVER_DIRECTORY!" "!DRIVER_INSTALLATION_DIRECTORY!" "!ABSOLUTE_LIBUV_LIBRARY_DIRECTORY!" "!ABSOLUTE_OPENSSL_LIBRARY_DIRECTORY!" "!BOOST_ROOT_DIRECTORY!" "!ABSOLUTE_LIBSSH2_LIBRARY_DIRECTORY!" "!ABSOLUTE_ZLIB_LIBRARY_DIRECTORY!" !BUILD_TYPE! !TARGET_ARCHITECTURE! !LIBRARY_TYPE! !VISUAL_STUDIO_INTERNAL_SHORTHAND_VERSION! !ENABLE_EXAMPLES! !GENERATE_SOLUTION! "!BOOST_DEPENDENCY_SOURCE_DIRECTORY!" "!LOG_DRIVER_BUILD!"
IF !ERRORLEVEL! NEQ 0 EXIT /B !ERRORLEVEL!
)
REM Determine if dependencies should be copied
IF !DRIVER_INSTALLATION_DIRECTORY_OVERRIDDEN! EQU !TRUE! (
IF EXIST "!DRIVER_INSTALLATION_DIRECTORY!\..\" (
ECHO | SET /P=Installing cpp-driver dependencies ...
XCOPY /E /Y "!ABSOLUTE_DEPENDENCIES_LIBRARIES_DIRECTORY!" "!DRIVER_INSTALLATION_DIRECTORY!\..\" >> "!LOG_DRIVER_BUILD!" 2>&1
IF NOT !ERRORLEVEL! EQU 0 (
ECHO FAILED!
ECHO See !LOG_DRIVER_BUILD! for more details
)
ECHO done.
)
)
REM Display success message with location to built driver library
ECHO.
IF !DRIVER_GENERATE_SOLUTION! EQU !TRUE! (
ECHO Visual Studio !VISUAL_STUDIO_INTERNAL_SHORTHAND_VERSION! solution has been successfully generated
ECHO !ABSOLUTE_BUILD_DIRECTORY!\!DRIVER_DRIVER_DIRECTORY!\cassandra.sln
) ELSE (
ECHO Driver has been successfully built [!TARGET_ARCHITECTURE!-bit !BUILD_TYPE!]
ECHO !DRIVER_INSTALLATION_DIRECTORY!
)
) ELSE (
REM Ensure the Windows SDK version is undefined (unset)
IF DEFINED WindowsSDKDir SET WindowsSDKDir=
REM Store current Visual Studio tools environment variables
FOR %%A IN (!VISUAL_STUDIO_INTERNAL_VERSIONS!) DO (
SET "STORED_VS%%ACOMNTOOLS=!VS%%ACOMNTOOLS!"
)
REM Iterate through all available Visual Studio versions
SET INDEX=0
SET "STORED_PATH=!PATH!"
FOR %%A IN (!AVAILABLE_VISUAL_STUDIO_VERSIONS!) DO (
SET /A INDEX+=1
CALL :GETARRAYELEMENT VISUAL_STUDIO_VERSIONS %%A VISUAL_STUDIO_VERSION
CALL :GETARRAYELEMENT AVAILABLE_VISUAL_STUDIO_VERSIONS !INDEX! USER_SELECTION
CALL :GETARRAYELEMENT VISUAL_STUDIO_INTERNAL_VERSIONS !USER_SELECTION! VISUAL_STUDIO_INTERNAL_VERSION
CALL :GETARRAYELEMENT VISUAL_STUDIO_INTERNAL_SHORTHAND_VERSIONS !USER_SELECTION! VISUAL_STUDIO_INTERNAL_SHORTHAND_VERSION
CALL :GETARRAYELEMENT VISUAL_STUDIO_VERSIONS !USER_SELECTION! VISUAL_STUDIO_VERSION
REM Determine if both 32 and 64-bit targets can be built
SET AVAILABLE_TARGET_ARCHITECTURES=!ARCHITECTURE_32BIT!
IF !SYSTEM_ARCHITECTURE! EQU !ARCHITECTURE_64BIT! (
SET "AVAILABLE_TARGET_ARCHITECTURES=!AVAILABLE_TARGET_ARCHITECTURES! !ARCHITECTURE_64BIT!"
)
REM Ensure the other versions of VSXXXCOMNTOOLS are undefined (unset)
FOR %%B IN (!VISUAL_STUDIO_INTERNAL_VERSIONS!) DO (
SET VS%%BCOMNTOOLS=
IF %%B EQU !VISUAL_STUDIO_INTERNAL_VERSION! SET "VS%%BCOMNTOOLS=!STORED_VS%%BCOMNTOOLS!"
)
REM Iterate through all available target architectures
FOR %%C IN (!AVAILABLE_TARGET_ARCHITECTURES!) DO (
REM Setup the Visual Studio environment
CALL :CONFIGUREVISUALSTUDIOENVIRONMENT !VISUAL_STUDIO_INTERNAL_VERSION! %%C
CALL :GETFULLPATH "!DEVENV!" DEVENV_FOUND
CALL :GETFULLPATH "!MSBUILD!" MSBUILD_FOUND
CALL :GETFULLPATH "!NMAKE!" NMAKE_FOUND
REM Create the base installation locations
SET DRIVER_PACKAGE_INSTALLATION_DIRECTORY=win%%C\msvc!VISUAL_STUDIO_INTERNAL_VERSION!
SET DEPENDENCY_PACKAGE_INSTALLATION_DIRECTORY=!DRIVER_PACKAGE_INSTALLATION_DIRECTORY!\!DEPENDENCIES_DIRECTORY!
SET "ABSOLUTE_DRIVER_PACKAGE_INSTALLATION_DIRECTORY=!ABSOLUTE_PACKAGES_DIRECTORY!\!DRIVER_PACKAGE_INSTALLATION_DIRECTORY!"
REM Iterate through shared and static builds
FOR %%D IN (!LIBRARY_TYPE_SHARED! !LIBRARY_TYPE_STATIC!) DO (
REM Display summary of build options
ECHO Building %%D Visual Studio !VISUAL_STUDIO_VERSION! Win%%C Package
REM Create the installation locations
CALL :LOWERCASE %%D LOWECASE_LIBRARY_TYPE
SET DEPENDENCY_PACKAGE_LIBUV_INSTALLATION_DIRECTORY=!DEPENDENCY_PACKAGE_INSTALLATION_DIRECTORY!\!LIBUV_DIRECTORY!\!LOWECASE_LIBRARY_TYPE!
SET DEPENDENCY_PACKAGE_OPENSSL_INSTALLATION_DIRECTORY=!DEPENDENCY_PACKAGE_INSTALLATION_DIRECTORY!\!OPENSSL_DIRECTORY!\!LOWECASE_LIBRARY_TYPE!
SET "ABSOLUTE_DEPENDENCY_PACKAGE_LIBUV_INSTALLATION_DIRECTORY=!ABSOLUTE_PACKAGES_DIRECTORY!\!DEPENDENCY_PACKAGE_LIBUV_INSTALLATION_DIRECTORY!"
SET "ABSOLUTE_DEPENDENCY_PACKAGE_OPENSSL_INSTALLATION_DIRECTORY=!ABSOLUTE_PACKAGES_DIRECTORY!\!DEPENDENCY_PACKAGE_OPENSSL_INSTALLATION_DIRECTORY!"
REM Build the dependencies and driver
CALL :BUILDLIBUV "!ABSOLUTE_DEPENDENCIES_DIRECTORY!\!DEPENDENCIES_SOURCE_DIRECTORY!\!LIBUV_DIRECTORY!" "!ABSOLUTE_DEPENDENCY_PACKAGE_LIBUV_INSTALLATION_DIRECTORY!" %%C %%D !FALSE! !TRUE! "!LOG_LIBUV_BUILD!"
IF !ERRORLEVEL! NEQ 0 EXIT /B !ERRORLEVEL!
CALL :BUILDOPENSSL "!ABSOLUTE_DEPENDENCIES_DIRECTORY!\!DEPENDENCIES_SOURCE_DIRECTORY!\!OPENSSL_DIRECTORY!" "!ABSOLUTE_DEPENDENCY_PACKAGE_OPENSSL_INSTALLATION_DIRECTORY!" "" %%C %%D !TRUE! "!LOG_OPENSSL_BUILD!"
IF !ERRORLEVEL! NEQ 0 EXIT /B !ERRORLEVEL!
IF EXIST "!ABSOLUTE_BUILD_DIRECTORY!\!DRIVER_DRIVER_DIRECTORY!" CALL :CLEANDIRECTORY "!ABSOLUTE_BUILD_DIRECTORY!\!DRIVER_DRIVER_DIRECTORY!" "Cleaning driver library directory"
SET BOOST_DEPENDENCY_SOURCE_DIRECTORY=
IF !VISUAL_STUDIO_VERSION! EQU 2010 SET "BOOST_DEPENDENCY_SOURCE_DIRECTORY=!ABSOLUTE_DEPENDENCIES_DIRECTORY!\!DEPENDENCIES_SOURCE_DIRECTORY!\!BOOST_DIRECTORY!"
CALL :BUILDDRIVER "!ABSOLUTE_BATCH_DIRECTORY!" "!ABSOLUTE_BUILD_DIRECTORY!\!DRIVER_DRIVER_DIRECTORY!" "!ABSOLUTE_DRIVER_PACKAGE_INSTALLATION_DIRECTORY!" "!ABSOLUTE_DEPENDENCY_PACKAGE_LIBUV_INSTALLATION_DIRECTORY!" "!ABSOLUTE_DEPENDENCY_PACKAGE_OPENSSL_INSTALLATION_DIRECTORY!" "" "" "" !BUILD_TYPE_RELEASE! %%C %%D !VISUAL_STUDIO_INTERNAL_SHORTHAND_VERSION! !FALSE! !GENERATE_SOLUTION! "!BOOST_DEPENDENCY_SOURCE_DIRECTORY!" "!LOG_DRIVER_BUILD!"
IF !ERRORLEVEL! NEQ 0 EXIT /B !ERRORLEVEL!
REM Clean-up the dependency packages
IF NOT EXIST "!ABSOLUTE_DEPENDENCY_PACKAGE_LIBUV_INSTALLATION_DIRECTORY!\..\!LIBRARY_INCLUDE_DIRECTORY!" MOVE /Y "!ABSOLUTE_DEPENDENCY_PACKAGE_LIBUV_INSTALLATION_DIRECTORY!\!LIBRARY_INCLUDE_DIRECTORY!" "!ABSOLUTE_DEPENDENCY_PACKAGE_LIBUV_INSTALLATION_DIRECTORY!\..\!LIBRARY_INCLUDE_DIRECTORY!" >> "!LOG_PACKAGE_BUILD!" 2>&1
IF EXIST "!ABSOLUTE_DEPENDENCY_PACKAGE_LIBUV_INSTALLATION_DIRECTORY!\!LIBRARY_INCLUDE_DIRECTORY!" RMDIR /S /Q "!ABSOLUTE_DEPENDENCY_PACKAGE_LIBUV_INSTALLATION_DIRECTORY!\!LIBRARY_INCLUDE_DIRECTORY!" >> "!LOG_PACKAGE_BUILD!" 2>&1
IF NOT EXIST "!ABSOLUTE_DEPENDENCY_PACKAGE_OPENSSL_INSTALLATION_DIRECTORY!\..\!LIBRARY_INCLUDE_DIRECTORY!" MOVE /Y "!ABSOLUTE_DEPENDENCY_PACKAGE_OPENSSL_INSTALLATION_DIRECTORY!\!LIBRARY_INCLUDE_DIRECTORY!" "!ABSOLUTE_DEPENDENCY_PACKAGE_OPENSSL_INSTALLATION_DIRECTORY!\..\!LIBRARY_INCLUDE_DIRECTORY!" >> "!LOG_PACKAGE_BUILD!" 2>&1
IF NOT EXIST "!ABSOLUTE_DEPENDENCY_PACKAGE_OPENSSL_INSTALLATION_DIRECTORY!\openssl.cnf" MOVE /Y "!ABSOLUTE_DEPENDENCY_PACKAGE_OPENSSL_INSTALLATION_DIRECTORY!\openssl.cnf" "!ABSOLUTE_DEPENDENCY_PACKAGE_OPENSSL_INSTALLATION_DIRECTORY!" >> "!LOG_PACKAGE_BUILD!" 2>&1
IF EXIST "!ABSOLUTE_DEPENDENCY_PACKAGE_OPENSSL_INSTALLATION_DIRECTORY!\!LIBRARY_INCLUDE_DIRECTORY!" RMDIR /S /Q "!ABSOLUTE_DEPENDENCY_PACKAGE_OPENSSL_INSTALLATION_DIRECTORY!\!LIBRARY_INCLUDE_DIRECTORY!" >> "!LOG_PACKAGE_BUILD!" 2>&1
IF EXIST "!ABSOLUTE_DEPENDENCY_PACKAGE_OPENSSL_INSTALLATION_DIRECTORY!\openssl.cnf" ERASE /S /Q "!ABSOLUTE_DEPENDENCY_PACKAGE_OPENSSL_INSTALLATION_DIRECTORY!\openssl.cnf" >> "!LOG_PACKAGE_BUILD!" 2>&1
REM Copy distribution files into packages
IF NOT EXIST "!ABSOLUTE_DEPENDENCY_PACKAGE_LIBUV_INSTALLATION_DIRECTORY!\..\LICENSE" COPY /Y "!ABSOLUTE_DEPENDENCIES_DIRECTORY!\!DEPENDENCIES_SOURCE_DIRECTORY!\!LIBUV_DIRECTORY!\LICENSE" "!ABSOLUTE_DEPENDENCY_PACKAGE_LIBUV_INSTALLATION_DIRECTORY!\.." >> "!LOG_PACKAGE_BUILD!" 2>&1
IF NOT EXIST "!ABSOLUTE_DEPENDENCY_PACKAGE_OPENSSL_INSTALLATION_DIRECTORY!\..\LICENSE" COPY /Y "!ABSOLUTE_DEPENDENCIES_DIRECTORY!\!DEPENDENCIES_SOURCE_DIRECTORY!\!OPENSSL_DIRECTORY!\LICENSE" "!ABSOLUTE_DEPENDENCY_PACKAGE_OPENSSL_INSTALLATION_DIRECTORY!\.." >> "!LOG_PACKAGE_BUILD!" 2>&1
IF NOT EXIST "!ABSOLUTE_DRIVER_PACKAGE_INSTALLATION_DIRECTORY!\CHANGELOG.md" COPY /Y "!ABSOLUTE_BATCH_DIRECTORY!\CHANGELOG.md" "!ABSOLUTE_DRIVER_PACKAGE_INSTALLATION_DIRECTORY!" >> "!LOG_PACKAGE_BUILD!" 2>&1
IF NOT EXIST "!ABSOLUTE_DRIVER_PACKAGE_INSTALLATION_DIRECTORY!\LICENSE.txt" COPY /Y "!ABSOLUTE_BATCH_DIRECTORY!\LICENSE.txt" "!ABSOLUTE_DRIVER_PACKAGE_INSTALLATION_DIRECTORY!" >> "!LOG_PACKAGE_BUILD!" 2>&1
IF NOT EXIST "!ABSOLUTE_DRIVER_PACKAGE_INSTALLATION_DIRECTORY!\README.md" COPY /Y "!ABSOLUTE_BATCH_DIRECTORY!\README.md" "!ABSOLUTE_DRIVER_PACKAGE_INSTALLATION_DIRECTORY!" >> "!LOG_PACKAGE_BUILD!" 2>&1
REM Skip a line on the display
ECHO.
)
REM Build the zip packages for the current target architecture and Visual Studio version
ECHO | SET /P=Building the driver package for Win%%C MSVC!VISUAL_STUDIO_INTERNAL_VERSION! ...
ECHO !ZIP! a -tzip !ABSOLUTE_PACKAGES_DIRECTORY!\!BUILD_PACKAGE_PREFIX!-!BUILD_PACKAGE_VERSION!-win%%C-msvc!VISUAL_STUDIO_INTERNAL_VERSION!.zip -r !ABSOLUTE_DRIVER_PACKAGE_INSTALLATION_DIRECTORY!\ -xr^^!!DEPENDENCIES_DIRECTORY! >> "!LOG_PACKAGE_BUILD!"
!ZIP! a -tzip "!ABSOLUTE_PACKAGES_DIRECTORY!\!BUILD_PACKAGE_PREFIX!-!BUILD_PACKAGE_VERSION!-win%%C-msvc!VISUAL_STUDIO_INTERNAL_VERSION!.zip" -r "!ABSOLUTE_DRIVER_PACKAGE_INSTALLATION_DIRECTORY!\*" -xr^^!!DEPENDENCIES_DIRECTORY! >> "!LOG_PACKAGE_BUILD!" 2>&1
IF NOT !ERRORLEVEL! EQU 0 (
ECHO FAILED!
ECHO See !LOG_PACKAGE_BUILD! for more details
EXIT /B !EXIT_CODE_PACKAGE_FAILED!
)
ECHO done.
ECHO | SET /P=Building the libuv package for Win%%C MSVC!VISUAL_STUDIO_INTERNAL_VERSION! ...
ECHO !ZIP! a -tzip "!ABSOLUTE_PACKAGES_DIRECTORY!\libuv-!LIBUV_PACKAGE_VERSION!-win%%C-msvc!VISUAL_STUDIO_INTERNAL_VERSION!.zip" -r !ABSOLUTE_DRIVER_PACKAGE_INSTALLATION_DIRECTORY!\!DEPENDENCIES_DIRECTORY!\!LIBUV_DIRECTORY!\ >> "!LOG_PACKAGE_BUILD!"
!ZIP! a -tzip "!ABSOLUTE_PACKAGES_DIRECTORY!\libuv-!LIBUV_PACKAGE_VERSION!-win%%C-msvc!VISUAL_STUDIO_INTERNAL_VERSION!.zip" -r "!ABSOLUTE_DRIVER_PACKAGE_INSTALLATION_DIRECTORY!\!DEPENDENCIES_DIRECTORY!\!LIBUV_DIRECTORY!\*" >> "!LOG_PACKAGE_BUILD!" 2>&1
IF NOT !ERRORLEVEL! EQU 0 (
ECHO FAILED!
ECHO See !LOG_PACKAGE_BUILD! for more details
EXIT /B !EXIT_CODE_PACKAGE_FAILED!
)
ECHO done.
ECHO | SET /P=Building the OpenSSL package for Win%%C MSVC!VISUAL_STUDIO_INTERNAL_VERSION! ...
ECHO !ZIP! a -tzip !ABSOLUTE_PACKAGES_DIRECTORY!\openssl-!OPENSSL_PACKAGE_VERSION!-win%%C-msvc!VISUAL_STUDIO_INTERNAL_VERSION!.zip -r !ABSOLUTE_DRIVER_PACKAGE_INSTALLATION_DIRECTORY!\!OPENSSL_DIRECTORY!\ >> "!LOG_PACKAGE_BUILD!"
!ZIP! a -tzip "!ABSOLUTE_PACKAGES_DIRECTORY!\openssl-!OPENSSL_PACKAGE_VERSION!-win%%C-msvc!VISUAL_STUDIO_INTERNAL_VERSION!.zip" -r "!ABSOLUTE_DRIVER_PACKAGE_INSTALLATION_DIRECTORY!\!DEPENDENCIES_DIRECTORY!\!OPENSSL_DIRECTORY!\*" >> "!LOG_PACKAGE_BUILD!" 2>&1
IF NOT !ERRORLEVEL! EQU 0 (
ECHO FAILED!
ECHO See !LOG_PACKAGE_BUILD! for more details
EXIT /B !EXIT_CODE_PACKAGE_FAILED!
)
ECHO done.
ECHO.
REM Reset the system PATH
SET "PATH=!STORED_PATH!"
)
)
)
REM Disable delayed expansion
ENDLOCAL
REM Exit the batch operation (Ensures below functions are skipped)
EXIT /B
REM Convert a string to uppercase
REM
REM @param string String to convert to uppercase
REM @param return Uppercase converted string
:UPPERCASE [string] [return]
SET "UPPERCASE_ALPHABET=A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"
SET RETURN=%~1
FOR %%A IN (!UPPERCASE_ALPHABET!) DO SET RETURN=!RETURN:%%A=%%A!
SET %2=!RETURN!
GOTO:EOF
REM Convert a string to lowercase
REM
REM @param string String to convert to lowercase
REM @param return Lowercase converted string
:LOWERCASE [string] [return]
SET "LOWERCASE_ALPHABET=a b c d e f g h i j k l m n o p q r s t u v w x y z"
SET RETURN=%~1
FOR %%A IN (!LOWERCASE_ALPHABET!) DO SET RETURN=!RETURN:%%A=%%A!
SET %2=!RETURN!
GOTO:EOF
REM Display the help message and exit with error code
:DISPLAYHELP
CALL :UPPERCASE !BATCH_FILENAME! BATCH_FILENAME_UPPERCASE
ECHO Usage: !BATCH_FILENAME_UPPERCASE! [OPTION...]
ECHO.
ECHO !ARGUMENT_BUILD_TYPE_DEBUG! Enable debug build
ECHO !ARGUMENT_BUILD_TYPE_RELEASE! Enable release build ^(default^)
ECHO !ARGUMENT_DISABLE_CLEAN_BUILD! Disable clean build
ECHO !ARGUMENT_TARGET_COMPILER! [version] 140, 120, 110, 100, or WINSDK
ECHO !ARGUMENT_DISABLE_OPENSSL! Disable OpenSSL support
ECHO !ARGUMENT_ENABLE_EXAMPLES! Enable example builds
ECHO !ARGUMENT_ENABLE_BUILD_PACKAGES! [version] Enable package generation
ECHO !ARGUMENT_ENABLE_TESTS! [boost-root-dir] Enable test builds
ECHO !ARGUMENT_ENABLE_ZLIB! Enable zlib
ECHO !ARGUMENT_GENERATE_SOLUTION! Generate Visual Studio solution
ECHO !ARGUMENT_INSTALLATION_DIRECTORY! [install-dir] Override installation directory
ECHO !ARGUMENT_LIBRARY_TYPE_SHARED! Build shared library ^(default^)
ECHO !ARGUMENT_LIBRARY_TYPE_STATIC! Build static library
IF !SYSTEM_ARCHITECTURE! EQU !ARCHITECTURE_32BIT! (
ECHO !ARGUMENT_TARGET_ARCHITECTURE_32BIT! Target 32-bit build ^(default^)
ECHO !ARGUMENT_TARGET_ARCHITECTURE_64BIT! Target 64-bit build
) ELSE (
ECHO !ARGUMENT_TARGET_ARCHITECTURE_32BIT! Target 32-bit build
ECHO !ARGUMENT_TARGET_ARCHITECTURE_64BIT! Target 64-bit build ^(default^)
)
ECHO !ARGUMENT_USE_BOOST_ATOMIC! Use Boost atomic
ECHO.
ECHO !ARGUMENT_HELP! Display this message
EXIT /B
REM Get an element from an array
REM
REM @param array Global array to iterate through
REM @param index Index to retrieve
REM @param return Variable to assign retrieved value
:GETARRAYELEMENT [array] [index] [return]
FOR /F "TOKENS=%~2" %%A IN ("!%~1!") DO SET %~3=%%A
EXIT /B
REM Get a value from a key=value pair in an environment variable
REM
REM @param pair Key/Value pair to parse
REM @param return Value parsed from key/value pair
:GETVALUE [pair] [return]
FOR /F "TOKENS=1,2* DELIMS==" %%A IN ('SET %~1') DO SET %~2=%%B
EXIT /B
REM Get full path for a given executable in the system PATH
REM
REM @param executable Executable to search for in PATH
REM @param return Full path with executable
:GETFULLPATH [executable] [return]
FOR %%A IN ("%~1") DO SET %~2=%%~$PATH:A
EXIT /B
REM Compare two version numbers
REM
REM @param version-one Version to compare against another version number
REM @param version-two Version to compare against another version number
REM @return 1 if version-one > version-two
REM 0 if version-one == version-two