-
Notifications
You must be signed in to change notification settings - Fork 152
/
vc_build.bat
1525 lines (1422 loc) · 72.4 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 2015-2017 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_CONFIGURATION_DRIVER_FAILED=8
SET EXIT_CODE_INVALID_VERSION=9
SET EXIT_CODE_PACKAGE_FAILED=10
REM Argument constants
SET ARGUMENT_BUILD_TYPE_DEBUG=--DEBUG
SET ARGUMENT_BUILD_TYPE_RELEASE=--RELEASE
SET ARGUMENT_DISABLE_CLEAN_BUILD=--DISABLE-CLEAN
SET ARGUMENT_ENABLE_THREAD_SAFETY=--ENABLE-THREAD-SAFETY
SET ARGUMENT_ENABLE_TEST_CONFIGURATION=--ENABLE-TEST-CONFIGURATION
SET ARGUMENT_ENABLE_BUILD_PACKAGES=--ENABLE-PACKAGES
SET ARGUMENT_PHP_VERSION=--PHP-VERSION
SET ARGUMENT_TARGET_ARCHITECTURE_32BIT=--X86
SET ARGUMENT_TARGET_ARCHITECTURE_64BIT=--X64
SET ARGUMENT_USE_BOOST_ATOMIC=--USE-BOOST-ATOMIC
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 BISON=bison.exe
SET "DOWNLOAD_URL_BISON=http://gnuwin32.sourceforge.net/downlinks/bison.php"
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 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-php-driver
SET DRIVER_DRIVER_DIRECTORY=driver
SET PACKAGES_DIRECTORY=packages
SET "ABSOLUTE_PACKAGES_DIRECTORY=%ABSOLUTE_BUILD_DIRECTORY%\%PACKAGES_DIRECTORY%"
SET "ABSOLUTE_CHANGELOG_PATH=%ABSOLUTE_BATCH_DIRECTORY%\..\CHANGELOG.md"
SET "ABSOLUTE_LICENSE_PATH=%ABSOLUTE_BATCH_DIRECTORY%\..\LICENSE"
SET "ABSOLUTE_README_PATH=%ABSOLUTE_BATCH_DIRECTORY%\..\README.md"
SET "ABSOLUTE_EXTENSION_DOCUMENT_DIRECTORY=%ABSOLUTE_BATCH_DIRECTORY%\doc"
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%"
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 CPP_DRIVER_DIRECTORY=cpp-driver
SET LIBUV_DIRECTORY=libuv
SET OPENSSL_DIRECTORY=openssl
SET ZLIB_DIRECTORY=zlib
SET MPIR_REPOSITORY_URL=https://github.com/wbhart/mpir.git
SET MPIR_DIRECTORY=mpir
REM MPIR updated versions but did not create a release or tag on GitHub for 3.0.0
SET MPIR_BRANCH_TAG_VERSION=3.0.0
SET MPIR_SHA_CHANGESET=a6ad489
SET PHP_REPOSITORY_URL=https://github.com/php/php-src.git
SET PHP_DIRECTORY=php
SET PHP_5_6_BRANCH_TAG_VERSION=php-5.6.31
SET PHP_7_0_BRANCH_TAG_VERSION=php-7.0.21
SET PHP_7_1_BRANCH_TAG_VERSION=php-7.1.7
SET "SUPPORTED_PHP_VERSIONS=5_6 7_0 7_1"
SET "SUPPORTED_PHP_DISPLAY_VERSIONS=5.6 7.0 7.1"
SET "SUPPORTED_PHP_VISUAL_STUDIO_VERSIONS=2012 2015 2015"
SET LIBICONV_REPOSITORY_URL=https://github.com/winlibs/libiconv.git
SET LIBICONV_DIRECTORY=libiconv
REM libiconv v1.14 with solutions for Visual Studio 2012 and 2015
SET LIBICONV_BRANCH_TAG_VERSION=1.14
SET LIBICONV_SHA_CHANGESET=d70c3d8
SET LIBXML2_REPOSITORY_URL=https://github.com/winlibs/libxml2.git
SET LIBXML2_DIRECTORY=libxml2
SET LIBXML2_BRANCH_TAG_VERSION=libxml2-2.9.4-1
SET "ABSOLUTE_DEPENDENCIES_CPP_DRIVER_SOURCE_DIRECTORY=%ABSOLUTE_BATCH_DIRECTORY%\..\%LIBRARY_BINARY_DIRECTORY%\%CPP_DRIVER_DIRECTORY%"
SET "ABSOLUTE_DEPENDENCIES_CPP_DRIVER_LIBRARIES_DIRECTORY=%ABSOLUTE_BUILD_DIRECTORY%\%DEPENDENCIES_DIRECTORY%\%DEPENDENCIES_LIBRARIES_DIRECTORY%\%CPP_DRIVER_DIRECTORY%"
SET "ABSOLUTE_DEPENDENCIES_LIBUV_LIBRARIES_DIRECTORY=%ABSOLUTE_BUILD_DIRECTORY%\%DEPENDENCIES_DIRECTORY%\%DEPENDENCIES_LIBRARIES_DIRECTORY%\%LIBUV_DIRECTORY%"
SET "ABSOLUTE_DEPENDENCIES_OPENSSL_LIBRARIES_DIRECTORY=%ABSOLUTE_BUILD_DIRECTORY%\%DEPENDENCIES_DIRECTORY%\%DEPENDENCIES_LIBRARIES_DIRECTORY%\%OPENSSL_DIRECTORY%"
SET "ABSOLUTE_DEPENDENCIES_ZLIB_LIBRARIES_DIRECTORY=%ABSOLUTE_BUILD_DIRECTORY%\%DEPENDENCIES_DIRECTORY%\%DEPENDENCIES_LIBRARIES_DIRECTORY%\%ZLIB_DIRECTORY%"
SET "ABSOLUTE_DEPENDENCIES_MPIR_SOURCE_DIRECTORY=%ABSOLUTE_BUILD_DIRECTORY%\%DEPENDENCIES_DIRECTORY%\%DEPENDENCIES_SOURCE_DIRECTORY%\%MPIR_DIRECTORY%"
SET "ABSOLUTE_DEPENDENCIES_MPIR_LIBRARIES_DIRECTORY=%ABSOLUTE_BUILD_DIRECTORY%\%DEPENDENCIES_DIRECTORY%\%DEPENDENCIES_LIBRARIES_DIRECTORY%\%MPIR_DIRECTORY%"
SET "ABSOLUTE_DEPENDENCIES_LIBICONV_SOURCE_DIRECTORY=%ABSOLUTE_BUILD_DIRECTORY%\%DEPENDENCIES_DIRECTORY%\%DEPENDENCIES_SOURCE_DIRECTORY%\%LIBICONV_DIRECTORY%"
SET "ABSOLUTE_DEPENDENCIES_LIBICONV_LIBRARIES_DIRECTORY=%ABSOLUTE_BUILD_DIRECTORY%\%DEPENDENCIES_DIRECTORY%\%DEPENDENCIES_LIBRARIES_DIRECTORY%\%LIBICONV_DIRECTORY%"
SET "ABSOLUTE_DEPENDENCIES_LIBXML2_SOURCE_DIRECTORY=%ABSOLUTE_BUILD_DIRECTORY%\%DEPENDENCIES_DIRECTORY%\%DEPENDENCIES_SOURCE_DIRECTORY%\%LIBXML2_DIRECTORY%"
SET "ABSOLUTE_DEPENDENCIES_LIBXML2_LIBRARIES_DIRECTORY=%ABSOLUTE_BUILD_DIRECTORY%\%DEPENDENCIES_DIRECTORY%\%DEPENDENCIES_LIBRARIES_DIRECTORY%\%LIBXML2_DIRECTORY%"
SET "ABSOLUTE_DEPENDENCIES_PHP_SOURCE_DIRECTORY=%ABSOLUTE_BUILD_DIRECTORY%\%DEPENDENCIES_DIRECTORY%\%DEPENDENCIES_SOURCE_DIRECTORY%\%PHP_DIRECTORY%"
SET "ABSOLUTE_DEPENDENCIES_PHP_LIBRARIES_DIRECTORY=%ABSOLUTE_BUILD_DIRECTORY%\%DEPENDENCIES_DIRECTORY%\%DEPENDENCIES_LIBRARIES_DIRECTORY%\%PHP_DIRECTORY%"
REM Log filename constants
SET LOG_DIRECTORY=log
SET "ABSOLUTE_LOG_DIRECTORY=%ABSOLUTE_BUILD_DIRECTORY%\%LOG_DIRECTORY%"
SET "LOG_CPP_DRIVER_BUILD=%ABSOLUTE_LOG_DIRECTORY%\cpp-driver.log"
SET "LOG_MPIR_BUILD=%ABSOLUTE_LOG_DIRECTORY%\mpir.log"
SET "LOG_LIBICONV_BUILD=%ABSOLUTE_LOG_DIRECTORY%\libiconv.log"
SET "LOG_LIBXML2_BUILD=%ABSOLUTE_LOG_DIRECTORY%\libxml2.log"
SET "LOG_DRIVER_BUILD=%ABSOLUTE_LOG_DIRECTORY%\driver.log"
SET "LOG_PACKAGE_BUILD=%ABSOLUTE_LOG_DIRECTORY%\package.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_THREAD_SAFETY=%FALSE%
SET ENABLE_TEST_CONFIGURATION=%FALSE%
SET PHP_VERSION=7_1
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 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 Enable package build
IF "!ARGUMENT!" == "!ARGUMENT_ENABLE_TEST_CONFIGURATION!" (
SET ENABLE_TEST_CONFIGURATION=!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 PHP version (5.6, 7.0, and 7.1)
IF "!ARGUMENT!" == "!ARGUMENT_PHP_VERSION!" (
REM Make sure the version information exists
IF [%2] == [] (
ECHO Invalid Version: Version must be supplied when choosing PHP version
EXIT /B !EXIT_CODE_INVALID_VERSION!
) ELSE (
REM Ensure the PHP version is valid
IF NOT "%2" == "5.6" (
IF NOT "%2" == "7.0" (
IF NOT "%2" == "7.1" (
ECHO Invalid Version: Version not within range [5.6, 7.0, and 7.1]
EXIT /B !EXIT_CODE_INVALID_VERSION!
)
)
)
REM Get the version information and format for branch/tag variable use
IF "%2" == "5.6" (
SET PHP_VERSION=5_6
)
IF "%2" == "7.0" (
SET PHP_VERSION=7_0
)
IF "%2" == "7.1" (
SET PHP_VERSION=7_1
)
SHIFT
)
)
REM Disable clean build
IF "!ARGUMENT!" == "!ARGUMENT_DISABLE_CLEAN_BUILD!" (
SET ENABLE_CLEAN_BUILD=!FALSE!
)
REM Disable thread safety
IF "!ARGUMENT!" == "!ARGUMENT_ENABLE_THREAD_SAFETY!" (
SET ENABLE_THREAD_SAFETY=!TRUE!
)
REM Enable the use of Boost atomics library in the cpp-driver
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 Set the PHP branch/tag version to use
FOR %%A IN (!PHP_VERSION!) DO (
SET "PHP_BRANCH_TAG_VERSION=!PHP_%%A_BRANCH_TAG_VERSION!"
)
REM Determine Visual Studio Version(s) available (2012 and 2015 only)
SET "VISUAL_STUDIO_INTERNAL_VERSIONS=140 110"
SET "VISUAL_STUDIO_INTERNAL_SHORTHAND_VERSIONS=14 11"
SET "VISUAL_STUDIO_VERSIONS=2015 2012"
SET INDEX=0
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 Find all available versions of Visual Studio
SET FOUND_VISUAL_STUDIO_INTERNAL_VERSIONS=
FOR /F "TOKENS=1,2 DELIMS==" %%A IN ('SET VS') DO (
SET EXTRACT_VISUAL_STUDIO_INTERNAL_VERSION=%%A
SET EXTRACT_VISUAL_STUDIO_INTERNAL_VERSION=!EXTRACT_VISUAL_STUDIO_INTERNAL_VERSION:VS=!
SET EXTRACT_VISUAL_STUDIO_INTERNAL_VERSION=!EXTRACT_VISUAL_STUDIO_INTERNAL_VERSION:COMNTOOLS=!
SET "FOUND_VISUAL_STUDIO_INTERNAL_VERSIONS=!FOUND_VISUAL_STUDIO_INTERNAL_VERSIONS! !EXTRACT_VISUAL_STUDIO_INTERNAL_VERSION!"
)
SET "FOUND_VISUAL_STUDIO_INTERNAL_VERSIONS=!FOUND_VISUAL_STUDIO_INTERNAL_VERSIONS:~1!"
REM Remove versions of Visual Studio that are not applicable for PHP driver
FOR %%A IN (!FOUND_VISUAL_STUDIO_INTERNAL_VERSIONS!) DO (
REM Ensure the other versions of VSXXXCOMNTOOLS are undefined (unset)
SET KEEP_VISUAL_STUDIO_VERSION=!FALSE!
FOR %%B IN (!VISUAL_STUDIO_INTERNAL_VERSIONS!) DO (
IF %%A EQU %%B SET KEEP_VISUAL_STUDIO_VERSION=!TRUE!
)
IF !KEEP_VISUAL_STUDIO_VERSION! EQU !FALSE! SET VS%%ACOMNTOOLS=
)
REM Determine if Windows SDK is available and ensure it is disabled
IF DEFINED WindowsSDKDir (
REM Indicate Windows SDK was found
SET WINDOWS_SDK_FOUND=!TRUE!
REM Ensure the Windows SDK version is undefined (unset)
IF DEFINED WindowsSDKDir SET WindowsSDKDir=
)
REM Display discovered Visual Studio version(s)
set NUMBER_OF_VERSIONS=0
FOR %%A IN (!AVAILABLE_VISUAL_STUDIO_VERSIONS!) DO (
SET /A NUMBER_OF_VERSIONS+=1
)
REM Determine if build can proceed
IF !NUMBER_OF_VERSIONS! EQU 0 (
CALL :DISPLAYMISSINGVSMESSAGE
EXIT /B !EXIT_CODE_MISSING_VISUAL_STUDIO!
)
REM Ensure additional build dependencies are installed
SET "PATH=!PATH!;!SYSTEMDRIVE!\GnuWin32\bin"
CALL :GETFULLPATH "!BISON!" BISON_FOUND
IF NOT DEFINED BISON_FOUND (
ECHO Bison Not Found in PATH: Bison is required to complete build
ECHO Ensure Bison is installed in !SYSTEMDRIVE!\GnuWin32
ECHO.
ECHO !DOWNLOAD_URL_BISON!
CHOICE /N /T 15 /D N /M "Would you like to download Bison now?"
IF !ERRORLEVEL! EQU !YES! START !DOWNLOAD_URL_BISON!
EXIT /B !EXIT_CODE_MISSING_BUILD_DEPENDENCY!
)
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.
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.
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.
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 (
ECHO Perl Not Found in PATH: Perl is required to complete build
ECHO.
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.
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.
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.
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 the build type (packages or regular build)
IF "!ENABLE_BUILD_PACKAGES!" == "!FALSE!" (
IF !NUMBER_OF_VERSIONS! GTR 1 (
REM Determine the supported Visual Studio version for the PHP version
SET PHP_INDEX=0
FOR %%A IN (!SUPPORTED_PHP_VERSIONS!) DO (
SET /A PHP_INDEX+=1
IF "%%A" == "!PHP_VERSION!" CALL :GETARRAYELEMENT SUPPORTED_PHP_VISUAL_STUDIO_VERSIONS !PHP_INDEX! PHP_VISUAL_STUDIO_VERSION
)
REM Iterate through all available Visual Studio versions
SET VISUAL_STUDIO_FOUND=!FALSE!
SET VS_INDEX=0
SET "STORED_PATH=!PATH!"
FOR %%A IN (!AVAILABLE_VISUAL_STUDIO_VERSIONS!) DO (
SET /A VS_INDEX+=1
CALL :GETARRAYELEMENT VISUAL_STUDIO_VERSIONS %%A CURRENT_VISUAL_STUDIO_VERSION
IF "!PHP_VISUAL_STUDIO_VERSION!" == "!CURRENT_VISUAL_STUDIO_VERSION!" (
SET VISUAL_STUDIO_FOUND=!TRUE!
SET VISUAL_STUDIO_VERSION=!CURRENT_VISUAL_STUDIO_VERSION!
CALL :GETARRAYELEMENT AVAILABLE_VISUAL_STUDIO_VERSIONS !VS_INDEX! VS_COMPILER_SELECTION
CALL :GETARRAYELEMENT VISUAL_STUDIO_INTERNAL_VERSIONS !VS_COMPILER_SELECTION! VISUAL_STUDIO_INTERNAL_VERSION
CALL :GETARRAYELEMENT VISUAL_STUDIO_INTERNAL_SHORTHAND_VERSIONS !VS_COMPILER_SELECTION! VISUAL_STUDIO_INTERNAL_SHORTHAND_VERSION
)
)
REM Make sure Visual Studio was found for PHP version
IF !VISUAL_STUDIO_FOUND! EQU !TRUE! (
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=
)
) ELSE (
CALL :DISPLAYMISSINGVSMESSAGE
EXIT /B !EXIT_CODE_MISSING_VISUAL_STUDIO!
)
) ELSE (
REM Assign the discovered version of Visual Studio as the selection
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
)
REM Setup the Visual Studio environment for compiling
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 Target Architecture: !TARGET_ARCHITECTURE!
ECHO Test Configuration: !ENABLE_TEST_CONFIGURATION!
ECHO Visual Studio: !VISUAL_STUDIO_VERSION!
ECHO C/C++ Driver
ECHO Use Boost Atomic: !USE_BOOST_ATOMIC!
ECHO PHP Executable
ECHO PHP Version: !PHP_BRANCH_TAG_VERSION!
ECHO ZTS: !ENABLE_THREAD_SAFETY!
ECHO.
) ELSE (
REM Ensure package properties are set (ignore commandline arguments)
SET BUILD_TYPE=!BUILD_TYPE_RELEASE!
SET ENABLE_CLEAN_BUILD=!TRUE!
SET ENABLE_TEST_CONFIGURATION=!FALSE!
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.
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"
CALL :CLEANDIRECTORY "!ABSOLUTE_DEPENDENCIES_CPP_DRIVER_SOURCE_DIRECTORY!" "Cleaning cpp-driver submodule 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!"
ECHO Cloning Library Dependencies
REM Initialize and update the cpp-driver submodule
IF NOT EXIST "!ABSOLUTE_DEPENDENCIES_CPP_DRIVER_SOURCE_DIRECTORY!\include\cassandra.h" (
PUSHD "!ABSOLUTE_BATCH_DIRECTORY!\.." > NUL
ECHO Update cpp-driver submodule > "!LOG_CPP_DRIVER_BUILD!"
ECHO | SET /P="Update cpp-driver submodule ... "
!GIT! submodule update --init --recursive >> "!LOG_CPP_DRIVER_BUILD!" 2>&1
IF !ERRORLEVEL! EQU 0 (
ECHO done.
POPD
) ELSE (
ECHO FAILED!
ECHO See !LOG_CPP_DRIVER_BUILD! for more details
EXIT /B !EXIT_CODE_CLONE_FAILED!
)
)
REM Clone MPIR and checkout the appropriate tag
IF NOT EXIST "!ABSOLUTE_DEPENDENCIES_MPIR_SOURCE_DIRECTORY!" (
ECHO Cloning MPIR !!MPIR_BRANCH_TAG_VERSION!! > "!LOG_MPIR_BUILD!"
ECHO | SET /P="Cloning MPIR !!MPIR_BRANCH_TAG_VERSION!! ... "
!GIT! clone !MPIR_REPOSITORY_URL! "!ABSOLUTE_DEPENDENCIES_MPIR_SOURCE_DIRECTORY!" >> "!LOG_MPIR_BUILD!" 2>&1
IF !ERRORLEVEL! EQU 0 (
PUSHD "!ABSOLUTE_DEPENDENCIES_MPIR_SOURCE_DIRECTORY!" > NUL
!GIT! reset !MPIR_SHA_CHANGESET! --hard >> "!LOG_MPIR_BUILD!" 2>&1
IF !ERRORLEVEL! EQU 0 (
POPD > NUL
ECHO done.
) ELSE (
POPD > NUL
ECHO FAILED!
ECHO See !LOG_MPIR_BUILD! for more details
EXIT /B !EXIT_CODE_CLONE_FAILED!
)
) ELSE (
ECHO FAILED!
ECHO See !LOG_MPIR_BUILD! for more details
EXIT /B !EXIT_CODE_CLONE_FAILED!
)
)
REM Clone libiconv and checkout the appropriate tag
IF !ENABLE_TEST_CONFIGURATION! EQU !TRUE! (
IF NOT EXIST "!ABSOLUTE_DEPENDENCIES_LIBICONV_SOURCE_DIRECTORY!" (
ECHO Cloning libiconv !LIBICONV_BRANCH_TAG_VERSION! > "!LOG_LIBICONV_BUILD!"
ECHO | SET /P="Cloning libiconv !LIBICONV_BRANCH_TAG_VERSION! ... "
!GIT! clone !LIBICONV_REPOSITORY_URL! "!ABSOLUTE_DEPENDENCIES_LIBICONV_SOURCE_DIRECTORY!" >> "!LOG_LIBICONV_BUILD!" 2>&1
IF !ERRORLEVEL! EQU 0 (
PUSHD "!ABSOLUTE_DEPENDENCIES_LIBICONV_SOURCE_DIRECTORY!" > NUL
!GIT! reset !LIBICONV_SHA_CHANGESET! --hard >> "!LOG_LIBICONV_BUILD!" 2>&1
IF !ERRORLEVEL! EQU 0 (
POPD > NUL
ECHO done.
) ELSE (
POPD > NUL
ECHO FAILED!
ECHO See !LOG_LIBICONV_BUILD! for more details
EXIT /B !EXIT_CODE_CLONE_FAILED!
)
) ELSE (
ECHO FAILED!
ECHO See !LOG_LIBICONV_BUILD! for more details
EXIT /B !EXIT_CODE_CLONE_FAILED!
)
)
)
REM Clone libxml2 and checkout the appropriate tag
IF !ENABLE_TEST_CONFIGURATION! EQU !TRUE! (
IF NOT EXIST "!ABSOLUTE_DEPENDENCIES_LIBXML2_SOURCE_DIRECTORY!" (
ECHO Cloning libxml2 !LIBXML2_BRANCH_TAG_VERSION! > "!LOG_LIBXML2_BUILD!"
ECHO | SET /P="Cloning libxml2 !LIBXML2_BRANCH_TAG_VERSION! ... "
!GIT! clone --depth 1 --branch !LIBXML2_BRANCH_TAG_VERSION! --single-branch !LIBXML2_REPOSITORY_URL! "!ABSOLUTE_DEPENDENCIES_LIBXML2_SOURCE_DIRECTORY!" >> "!LOG_LIBXML2_BUILD!" 2>&1
IF !ERRORLEVEL! EQU 0 (
ECHO done.
) ELSE (
ECHO FAILED!
ECHO See !LOG_LIBXML2_BUILD! for more details
EXIT /B !EXIT_CODE_CLONE_FAILED!
)
)
)
REM Clone PHP and checkout the appropriate tag
IF !ENABLE_BUILD_PACKAGES! EQU !TRUE! (
SET "PHP_VERSIONS=!SUPPORTED_PHP_VERSIONS!"
) ELSE (
SET PHP_VERSIONS=!PHP_VERSION!
)
FOR %%A IN (!PHP_VERSIONS!) DO (
IF !ENABLE_BUILD_PACKAGES! EQU !TRUE! (
SET "PHP_BRANCH_TAG_VERSION=!PHP_%%A_BRANCH_TAG_VERSION!"
SET "ABSOLUTE_DEPENDENCIES_PHP_SOURCE_DIRECTORY=!ABSOLUTE_BUILD_DIRECTORY!\!DEPENDENCIES_DIRECTORY!\!DEPENDENCIES_SOURCE_DIRECTORY!\!PHP_DIRECTORY!\%%A"
)
IF NOT EXIST "!ABSOLUTE_DEPENDENCIES_PHP_SOURCE_DIRECTORY!" (
ECHO Cloning PHP !PHP_BRANCH_TAG_VERSION! > "!LOG_DRIVER_BUILD!"
ECHO | SET /P="Cloning PHP !PHP_BRANCH_TAG_VERSION! ... "
!GIT! clone --depth 1 --branch !PHP_BRANCH_TAG_VERSION! --single-branch !PHP_REPOSITORY_URL! "!ABSOLUTE_DEPENDENCIES_PHP_SOURCE_DIRECTORY!" >> "!LOG_DRIVER_BUILD!" 2>&1
IF !ERRORLEVEL! EQU 0 (
ECHO done.
) ELSE (
ECHO FAILED!
ECHO See !LOG_DRIVER_BUILD! for more details
EXIT /B !EXIT_CODE_CLONE_FAILED!
)
)
)
REM Determine if the packages are being built
ECHO.
IF !ENABLE_BUILD_PACKAGES! EQU !FALSE! (
ECHO Building Library Dependencies
REM Determine if the cpp-driver needs to be built
IF NOT EXIST "!ABSOLUTE_DEPENDENCIES_CPP_DRIVER_LIBRARIES_DIRECTORY!" (
SET CPP_DRIVER_TARGET_COMPILER=!VISUAL_STUDIO_INTERNAL_VERSION!
CALL :BUILDCPPDRIVER "!ABSOLUTE_DEPENDENCIES_CPP_DRIVER_SOURCE_DIRECTORY!" !CPP_DRIVER_TARGET_COMPILER! "!ABSOLUTE_DEPENDENCIES_CPP_DRIVER_LIBRARIES_DIRECTORY!" !BUILD_TYPE! !TARGET_ARCHITECTURE! !USE_BOOST_ATOMIC! "!LOG_CPP_DRIVER_BUILD!"
IF !ERRORLEVEL! NEQ 0 EXIT /B !ERRORLEVEL!
)
REM Determine if the MPIR library needs to be built
IF NOT EXIST "!ABSOLUTE_DEPENDENCIES_MPIR_LIBRARIES_DIRECTORY!" (
CALL :BUILDMPIR "!ABSOLUTE_DEPENDENCIES_MPIR_SOURCE_DIRECTORY!" "!ABSOLUTE_DEPENDENCIES_MPIR_LIBRARIES_DIRECTORY!" !BUILD_TYPE! !TARGET_ARCHITECTURE! !VISUAL_STUDIO_VERSION! "!LOG_MPIR_BUILD!"
IF !ERRORLEVEL! NEQ 0 EXIT /B !ERRORLEVEL!
)
REM Determine if the libiconv library needs to be built
IF EXIST "!ABSOLUTE_DEPENDENCIES_LIBICONV_SOURCE_DIRECTORY!" (
IF NOT EXIST "!ABSOLUTE_DEPENDENCIES_LIBICONV_LIBRARIES_DIRECTORY!" (
CALL :BUILDLIBICONV "!ABSOLUTE_DEPENDENCIES_LIBICONV_SOURCE_DIRECTORY!" "!ABSOLUTE_DEPENDENCIES_LIBICONV_LIBRARIES_DIRECTORY!" !TARGET_ARCHITECTURE! !VISUAL_STUDIO_VERSION! "!LOG_LIBICONV_BUILD!"
IF !ERRORLEVEL! NEQ 0 EXIT /B !ERRORLEVEL!
)
)
REM Determine if the libxml2 library needs to be built
IF EXIST "!ABSOLUTE_DEPENDENCIES_LIBXML2_SOURCE_DIRECTORY!" (
IF NOT EXIST "!ABSOLUTE_DEPENDENCIES_LIBXML2_LIBRARIES_DIRECTORY!" (
CALL :BUILDLIBXML2 "!ABSOLUTE_DEPENDENCIES_LIBXML2_SOURCE_DIRECTORY!" "!ABSOLUTE_DEPENDENCIES_LIBXML2_LIBRARIES_DIRECTORY!" "!ABSOLUTE_DEPENDENCIES_LIBICONV_LIBRARIES_DIRECTORY!" "!LOG_LIBXML2_BUILD!"
IF !ERRORLEVEL! NEQ 0 EXIT /B !ERRORLEVEL!
)
)
REM Determine if the driver needs to be built
IF NOT EXIST "!ABSOLUTE_DRIVER_LIBRARY_DIRECTORY!" (
CALL :BUILDDRIVER "!PHP_VERSION!" "!ABSOLUTE_DEPENDENCIES_PHP_SOURCE_DIRECTORY!" "!ABSOLUTE_BATCH_DIRECTORY!" "!ABSOLUTE_DRIVER_LIBRARY_DIRECTORY!" !ENABLE_TEST_CONFIGURATION! !ENABLE_THREAD_SAFETY! !BUILD_TYPE! "!ABSOLUTE_DEPENDENCIES_LIBICONV_LIBRARIES_DIRECTORY!" "!ABSOLUTE_DEPENDENCIES_LIBXML2_LIBRARIES_DIRECTORY!" "!ABSOLUTE_DEPENDENCIES_CPP_DRIVER_LIBRARIES_DIRECTORY!" "!ABSOLUTE_DEPENDENCIES_LIBUV_LIBRARIES_DIRECTORY!" "!ABSOLUTE_DEPENDENCIES_OPENSSL_LIBRARIES_DIRECTORY!" "!ABSOLUTE_DEPENDENCIES_ZLIB_LIBRARIES_DIRECTORY!" "!ABSOLUTE_DEPENDENCIES_MPIR_LIBRARIES_DIRECTORY!" "!LOG_DRIVER_BUILD!"
IF !ERRORLEVEL! NEQ 0 EXIT /B !ERRORLEVEL!
ECHO extension=php_cassandra.dll >> "!ABSOLUTE_DRIVER_LIBRARY_DIRECTORY!\php.ini"
IF NOT "!PHP_VERSION!" == "5_6" (
ECHO extension=php_openssl.dll >> "!ABSOLUTE_DRIVER_LIBRARY_DIRECTORY!\php.ini"
)
REM Configure PHP for use with OpenSSL runtime libraries
ECHO | SET /P="Copying runtime libraries ... "
XCOPY /Y /E "!ABSOLUTE_DEPENDENCIES_OPENSSL_LIBRARIES_DIRECTORY!\!LIBRARY_RUNTIME_DIRECTORY!\*.dll" "!ABSOLUTE_DRIVER_LIBRARY_DIRECTORY!" >> "!PHP_DRIVER_LOG_FILENAME!" 2>&1
IF NOT !ERRORLEVEL! EQU 0 (
ECHO FAILED!
ECHO See !PHP_DRIVER_LOG_FILENAME! for more details
EXIT /B !EXIT_CODE_BUILD_DRIVER_FAILED!
)
PUSHD "!ABSOLUTE_BATCH_DIRECTORY!\.." > NUL
IF EXIST bin RMDIR /S /Q bin
MKDIR bin
ECHO @ECHO %%PATH%% ^| FIND /C /I ^"!ABSOLUTE_DRIVER_LIBRARY_DIRECTORY!^"^>NUL ^|^| @SET ^"PATH=!ABSOLUTE_DRIVER_LIBRARY_DIRECTORY!;%%PATH%%^" > bin\php.bat
ECHO "!ABSOLUTE_DRIVER_LIBRARY_DIRECTORY!\php.exe" %%* >> bin\php.bat
POPD
ECHO done.
)
REM Configure PHP instance for use with the driver (or keep just driver)
IF !ENABLE_TEST_CONFIGURATION! EQU !TRUE! (
SET "PATH=!ABSOLUTE_DRIVER_LIBRARY_DIRECTORY!;!PATH!"
PUSHD "!ABSOLUTE_BATCH_DIRECTORY!\.." > NUL
IF EXIST vendor RMDIR /S /Q vendor
IF EXIST composer.phar ERASE composer.phar
ECHO | SET /P="Installing composer ... "
php -r "readfile('https://getcomposer.org/installer');" | php >> "!LOG_DRIVER_BUILD!" 2>&1
IF NOT !ERRORLEVEL! EQU 0 (
ECHO FAILED!
ECHO See !LOG_DRIVER_BUILD! for more details
EXIT /B !EXIT_CODE_CONFIGURATION_DRIVER_FAILED!
)
php composer.phar install >> "!LOG_DRIVER_BUILD!" 2>&1
IF NOT !ERRORLEVEL! EQU 0 (
ECHO FAILED!
ECHO See !LOG_DRIVER_BUILD! for more details
EXIT /B !EXIT_CODE_CONFIGURATION_DRIVER_FAILED!
)
IF EXIST bin\behat.bat (
RENAME bin\behat.bat behat.bak
ECHO @ECHO %%PATH%% ^| FIND /C /I ^"!ABSOLUTE_DRIVER_LIBRARY_DIRECTORY!^"^>NUL ^|^| @SET ^"PATH=!ABSOLUTE_DRIVER_LIBRARY_DIRECTORY!;%%PATH%%^" > bin\behat.bat
TYPE bin\behat.bak >> bin\behat.bat
ERASE bin\behat.bak
)
IF EXIST bin\phpunit.bat (
RENAME bin\phpunit.bat phpunit.bak
ECHO @ECHO %%PATH%% ^| FIND /C /I ^"!ABSOLUTE_DRIVER_LIBRARY_DIRECTORY!^"^>NUL ^|^| @SET ^"PATH=!ABSOLUTE_DRIVER_LIBRARY_DIRECTORY!;%%PATH%%^" > bin\phpunit.bat
TYPE bin\phpunit.bak >> bin\phpunit.bat
ERASE bin\phpunit.bak
)
ECHO done.
POPD
)
REM Display success message with location to built driver library
ECHO.
ECHO Driver has been successfully built [!TARGET_ARCHITECTURE!-bit !BUILD_TYPE!]
ECHO !ABSOLUTE_DRIVER_LIBRARY_DIRECTORY!
) ELSE (
REM Initialize the packages directory
IF NOT EXIST "!ABSOLUTE_PACKAGES_DIRECTORY!" MKDIR "!ABSOLUTE_PACKAGES_DIRECTORY!"
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 the supported versions of PHP
SET PACKAGE_INDEX=0
FOR %%A IN (!SUPPORTED_PHP_VERSIONS!) DO (
SET /A PACKAGE_INDEX+=1
CALL :GETARRAYELEMENT SUPPORTED_PHP_DISPLAY_VERSIONS !PACKAGE_INDEX! PHP_DISPLAY_VERSION
CALL :GETARRAYELEMENT SUPPORTED_PHP_VISUAL_STUDIO_VERSIONS !PACKAGE_INDEX! PHP_VISUAL_STUDIO_VERSION
SET "ABSOLUTE_DEPENDENCIES_PHP_SOURCE_DIRECTORY=!ABSOLUTE_BUILD_DIRECTORY!\!DEPENDENCIES_DIRECTORY!\!DEPENDENCIES_SOURCE_DIRECTORY!\!PHP_DIRECTORY!\%%A"
REM Iterate through all available Visual Studio versions
SET VISUAL_STUDIO_FOUND=!FALSE!
SET VS_INDEX=0
SET "STORED_PATH=!PATH!"
FOR %%B IN (!AVAILABLE_VISUAL_STUDIO_VERSIONS!) DO (
SET /A VS_INDEX+=1
CALL :GETARRAYELEMENT VISUAL_STUDIO_VERSIONS %%B VISUAL_STUDIO_VERSION
IF "!PHP_VISUAL_STUDIO_VERSION!" == "!VISUAL_STUDIO_VERSION!" (
SET VISUAL_STUDIO_FOUND=!TRUE!
CALL :GETARRAYELEMENT AVAILABLE_VISUAL_STUDIO_VERSIONS !VS_INDEX! VS_COMPILER_SELECTION
CALL :GETARRAYELEMENT VISUAL_STUDIO_INTERNAL_VERSIONS !VS_COMPILER_SELECTION! VISUAL_STUDIO_INTERNAL_VERSION
CALL :GETARRAYELEMENT VISUAL_STUDIO_INTERNAL_SHORTHAND_VERSIONS !VS_COMPILER_SELECTION! VISUAL_STUDIO_INTERNAL_SHORTHAND_VERSION
)
)
REM Make sure Visual Studio was found for PHP version
IF !VISUAL_STUDIO_FOUND! EQU !TRUE! (
REM Get the discovered Visual Studio version
CALL :GETARRAYELEMENT VISUAL_STUDIO_VERSIONS !VS_COMPILER_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 %%B IN (!AVAILABLE_TARGET_ARCHITECTURES!) DO (
SET TARGET_ARCHITECTURE_ARCHIVE_NAME=%%B
IF !TARGET_ARCHITECTURE_ARCHIVE_NAME! EQU !ARCHITECTURE_32BIT! SET TARGET_ARCHITECTURE_ARCHIVE_NAME=86
SET TARGET_ARCHITECTURE_ARCHIVE_NAME=x!TARGET_ARCHITECTURE_ARCHIVE_NAME!
ECHO Building Visual Studio !VISUAL_STUDIO_VERSION! Win%%B Packages for PHP v!PHP_DISPLAY_VERSION!
REM Setup the Visual Studio environment
CALL :CONFIGUREVISUALSTUDIOENVIRONMENT !VISUAL_STUDIO_INTERNAL_VERSION! %%B
CALL :GETFULLPATH "!DEVENV!" DEVENV_FOUND
CALL :GETFULLPATH "!MSBUILD!" MSBUILD_FOUND
CALL :GETFULLPATH "!NMAKE!" NMAKE_FOUND
REM Create the base installation locations
SET COMPILER_DIRECTORY=win%%B\msvc!VISUAL_STUDIO_INTERNAL_VERSION!
SET DRIVER_PACKAGE_INSTALLATION_DIRECTORY=php-!PHP_DISPLAY_VERSION!\!COMPILER_DIRECTORY!
SET "ABSOLUTE_DEPENDENCY_PACKAGE_INSTALLATION_DIRECTORY=!ABSOLUTE_DEPENDENCIES_DIRECTORY!\!COMPILER_DIRECTORY!"
SET "ABSOLUTE_DRIVER_DEPENDENCY_CPP_DRIVER_PACKAGE_INSTALLATION_DIRECTORY=!ABSOLUTE_DEPENDENCY_PACKAGE_INSTALLATION_DIRECTORY!\!CPP_DRIVER_DIRECTORY!"
SET "ABSOLUTE_DRIVER_DEPENDENCY_MPIR_PACKAGE_INSTALLATION_DIRECTORY=!ABSOLUTE_DEPENDENCY_PACKAGE_INSTALLATION_DIRECTORY!\!MPIR_DIRECTORY!"
SET "ABSOLUTE_CPP_DRIVER_DEPENDENCY_LIBUV_PACKAGE_INSTALLATION_DIRECTORY=!ABSOLUTE_DEPENDENCY_PACKAGE_INSTALLATION_DIRECTORY!\!LIBUV_DIRECTORY!"
SET "ABSOLUTE_CPP_DRIVER_DEPENDENCY_OPENSSL_PACKAGE_INSTALLATION_DIRECTORY=!ABSOLUTE_DEPENDENCY_PACKAGE_INSTALLATION_DIRECTORY!\!OPENSSL_DIRECTORY!"
SET "ABSOLUTE_CPP_DRIVER_DEPENDENCY_ZLIB_PACKAGE_INSTALLATION_DIRECTORY=!ABSOLUTE_DEPENDENCY_PACKAGE_INSTALLATION_DIRECTORY!\!ZLIB_DIRECTORY!"
SET "ABSOLUTE_DRIVER_PACKAGE_INSTALLATION_DIRECTORY=!ABSOLUTE_PACKAGES_DIRECTORY!\!DRIVER_PACKAGE_INSTALLATION_DIRECTORY!"
REM Build the cpp-driver
IF NOT EXIST "!ABSOLUTE_DRIVER_DEPENDENCY_CPP_DRIVER_PACKAGE_INSTALLATION_DIRECTORY!" (
SET USE_BOOST_ATOMIC=!FALSE!
IF !VISUAL_STUDIO_VERSION! EQU 2010 SET USE_BOOST_ATOMIC=!TRUE!
SET CPP_DRIVER_TARGET_COMPILER=!VISUAL_STUDIO_INTERNAL_VERSION!
CALL :BUILDCPPDRIVER "!ABSOLUTE_DEPENDENCIES_CPP_DRIVER_SOURCE_DIRECTORY!" !CPP_DRIVER_TARGET_COMPILER! "!ABSOLUTE_DRIVER_DEPENDENCY_CPP_DRIVER_PACKAGE_INSTALLATION_DIRECTORY!" !BUILD_TYPE! %%B !USE_BOOST_ATOMIC! "!LOG_CPP_DRIVER_BUILD!"
IF !ERRORLEVEL! NEQ 0 EXIT /B !ERRORLEVEL!
)
REM Build MPIR
IF NOT EXIST "!ABSOLUTE_DRIVER_DEPENDENCY_MPIR_PACKAGE_INSTALLATION_DIRECTORY!" (
CALL :BUILDMPIR "!ABSOLUTE_DEPENDENCIES_MPIR_SOURCE_DIRECTORY!" "!ABSOLUTE_DRIVER_DEPENDENCY_MPIR_PACKAGE_INSTALLATION_DIRECTORY!" !BUILD_TYPE! %%B !VISUAL_STUDIO_VERSION! "!LOG_MPIR_BUILD!"
IF !ERRORLEVEL! NEQ 0 EXIT /B !ERRORLEVEL!
)
REM Build the php-driver
ECHO Building PHP driver [TS]
CALL :BUILDDRIVER "!PHP_VERSION!" "!ABSOLUTE_DEPENDENCIES_PHP_SOURCE_DIRECTORY!" "!ABSOLUTE_BATCH_DIRECTORY!" "!ABSOLUTE_DRIVER_LIBRARY_DIRECTORY!" !FALSE! !TRUE! !BUILD_TYPE_RELEASE! "" "" "!ABSOLUTE_DRIVER_DEPENDENCY_CPP_DRIVER_PACKAGE_INSTALLATION_DIRECTORY!" "!ABSOLUTE_CPP_DRIVER_DEPENDENCY_LIBUV_PACKAGE_INSTALLATION_DIRECTORY!" "!ABSOLUTE_CPP_DRIVER_DEPENDENCY_OPENSSL_PACKAGE_INSTALLATION_DIRECTORY!" "!ABSOLUTE_CPP_DRIVER_DEPENDENCY_ZLIB_PACKAGE_INSTALLATION_DIRECTORY!" "!ABSOLUTE_DRIVER_DEPENDENCY_MPIR_PACKAGE_INSTALLATION_DIRECTORY!" "!LOG_DRIVER_BUILD!"
IF !ERRORLEVEL! NEQ 0 EXIT /B !ERRORLEVEL!
MKDIR "!ABSOLUTE_PACKAGES_DIRECTORY!\!DRIVER_PACKAGE_INSTALLATION_DIRECTORY!\ts\doc"
SET "ABSOLUTE_DRIVER_LIBRARY=!ABSOLUTE_DRIVER_LIBRARY_DIRECTORY!\php_cassandra.dll"
IF NOT EXIST "!ABSOLUTE_DRIVER_LIBRARY!" SET "ABSOLUTE_DRIVER_LIBRARY=!ABSOLUTE_DRIVER_LIBRARY_DIRECTORY!\ext\php_cassandra.dll"
ECHO COPY /Y !ABSOLUTE_DRIVER_LIBRARY! !ABSOLUTE_PACKAGES_DIRECTORY!\!DRIVER_PACKAGE_INSTALLATION_DIRECTORY!\ts >> "!LOG_PACKAGE_BUILD!"
COPY /Y "!ABSOLUTE_DRIVER_LIBRARY!" "!ABSOLUTE_PACKAGES_DIRECTORY!\!DRIVER_PACKAGE_INSTALLATION_DIRECTORY!\ts" >> "!LOG_PACKAGE_BUILD!" 2>&1
ECHO COPY /Y !ABSOLUTE_CHANGELOG_PATH! !ABSOLUTE_PACKAGES_DIRECTORY!\!DRIVER_PACKAGE_INSTALLATION_DIRECTORY!\ts >> "!LOG_PACKAGE_BUILD!"
COPY /Y "!ABSOLUTE_CHANGELOG_PATH!" "!ABSOLUTE_PACKAGES_DIRECTORY!\!DRIVER_PACKAGE_INSTALLATION_DIRECTORY!\ts" >> "!LOG_PACKAGE_BUILD!" 2>&1
ECHO COPY /Y !ABSOLUTE_LICENSE_PATH! !ABSOLUTE_PACKAGES_DIRECTORY!\!DRIVER_PACKAGE_INSTALLATION_DIRECTORY!\ts >> "!LOG_PACKAGE_BUILD!"
COPY /Y "!ABSOLUTE_LICENSE_PATH!" "!ABSOLUTE_PACKAGES_DIRECTORY!\!DRIVER_PACKAGE_INSTALLATION_DIRECTORY!\ts" >> "!LOG_PACKAGE_BUILD!" 2>&1
ECHO COPY /Y !ABSOLUTE_README_PATH! !ABSOLUTE_PACKAGES_DIRECTORY!\!DRIVER_PACKAGE_INSTALLATION_DIRECTORY!\ts >> "!LOG_PACKAGE_BUILD!"
COPY /Y "!ABSOLUTE_README_PATH!" "!ABSOLUTE_PACKAGES_DIRECTORY!\!DRIVER_PACKAGE_INSTALLATION_DIRECTORY!\ts" >> "!LOG_PACKAGE_BUILD!" 2>&1
ECHO XCOPY /E /Y !ABSOLUTE_EXTENSION_DOCUMENT_DIRECTORY! !ABSOLUTE_PACKAGES_DIRECTORY!\!DRIVER_PACKAGE_INSTALLATION_DIRECTORY!\ts\doc >> "!LOG_PACKAGE_BUILD!"
XCOPY /E /Y "!ABSOLUTE_EXTENSION_DOCUMENT_DIRECTORY!" "!ABSOLUTE_PACKAGES_DIRECTORY!\!DRIVER_PACKAGE_INSTALLATION_DIRECTORY!\ts\doc" >> "!LOG_PACKAGE_BUILD!" 2>&1
CALL :CLEANGITSOURCE "!ABSOLUTE_DEPENDENCIES_PHP_SOURCE_DIRECTORY!" "!LOG_DRIVER_BUILD!"
IF !ERRORLEVEL! NEQ 0 EXIT /B !ERRORLEVEL!
CALL :CLEANDIRECTORY "!ABSOLUTE_DRIVER_LIBRARY_DIRECTORY!" "Cleaning library directory"
ECHO Building PHP driver [NTS]
CALL :BUILDDRIVER "!PHP_VERSION!" "!ABSOLUTE_DEPENDENCIES_PHP_SOURCE_DIRECTORY!" "!ABSOLUTE_BATCH_DIRECTORY!" "!ABSOLUTE_DRIVER_LIBRARY_DIRECTORY!" !FALSE! !FALSE! !BUILD_TYPE_RELEASE! "" "" "!ABSOLUTE_DRIVER_DEPENDENCY_CPP_DRIVER_PACKAGE_INSTALLATION_DIRECTORY!" "!ABSOLUTE_CPP_DRIVER_DEPENDENCY_LIBUV_PACKAGE_INSTALLATION_DIRECTORY!" "!ABSOLUTE_CPP_DRIVER_DEPENDENCY_OPENSSL_PACKAGE_INSTALLATION_DIRECTORY!" "!ABSOLUTE_CPP_DRIVER_DEPENDENCY_ZLIB_PACKAGE_INSTALLATION_DIRECTORY!" "!ABSOLUTE_DRIVER_DEPENDENCY_MPIR_PACKAGE_INSTALLATION_DIRECTORY!" "!LOG_DRIVER_BUILD!"
IF !ERRORLEVEL! NEQ 0 EXIT /B !ERRORLEVEL!
MKDIR "!ABSOLUTE_PACKAGES_DIRECTORY!\!DRIVER_PACKAGE_INSTALLATION_DIRECTORY!\nts\doc"
SET "ABSOLUTE_DRIVER_LIBRARY=!ABSOLUTE_DRIVER_LIBRARY_DIRECTORY!\php_cassandra.dll"
IF NOT EXIST "!ABSOLUTE_DRIVER_LIBRARY!" SET "ABSOLUTE_DRIVER_LIBRARY=!ABSOLUTE_DRIVER_LIBRARY_DIRECTORY!\ext\php_cassandra.dll"
ECHO COPY /Y !ABSOLUTE_DRIVER_LIBRARY! !ABSOLUTE_PACKAGES_DIRECTORY!\!DRIVER_PACKAGE_INSTALLATION_DIRECTORY!\nts >> "!LOG_PACKAGE_BUILD!"
COPY /Y "!ABSOLUTE_DRIVER_LIBRARY!" "!ABSOLUTE_PACKAGES_DIRECTORY!\!DRIVER_PACKAGE_INSTALLATION_DIRECTORY!\nts" >> "!LOG_PACKAGE_BUILD!" 2>&1
ECHO COPY /Y !ABSOLUTE_CHANGELOG_PATH! !ABSOLUTE_PACKAGES_DIRECTORY!\!DRIVER_PACKAGE_INSTALLATION_DIRECTORY!\nts >> "!LOG_PACKAGE_BUILD!"
COPY /Y "!ABSOLUTE_CHANGELOG_PATH!" "!ABSOLUTE_PACKAGES_DIRECTORY!\!DRIVER_PACKAGE_INSTALLATION_DIRECTORY!\nts" >> "!LOG_PACKAGE_BUILD!" 2>&1
ECHO COPY /Y !ABSOLUTE_LICENSE_PATH! !ABSOLUTE_PACKAGES_DIRECTORY!\!DRIVER_PACKAGE_INSTALLATION_DIRECTORY!\nts >> "!LOG_PACKAGE_BUILD!"
COPY /Y "!ABSOLUTE_LICENSE_PATH!" "!ABSOLUTE_PACKAGES_DIRECTORY!\!DRIVER_PACKAGE_INSTALLATION_DIRECTORY!\nts" >> "!LOG_PACKAGE_BUILD!" 2>&1
ECHO COPY /Y !ABSOLUTE_README_PATH! !ABSOLUTE_PACKAGES_DIRECTORY!\!DRIVER_PACKAGE_INSTALLATION_DIRECTORY!\nts >> "!LOG_PACKAGE_BUILD!"
COPY /Y "!ABSOLUTE_README_PATH!" "!ABSOLUTE_PACKAGES_DIRECTORY!\!DRIVER_PACKAGE_INSTALLATION_DIRECTORY!\nts" >> "!LOG_PACKAGE_BUILD!" 2>&1
ECHO XCOPY /E /Y !ABSOLUTE_EXTENSION_DOCUMENT_DIRECTORY! !ABSOLUTE_PACKAGES_DIRECTORY!\!DRIVER_PACKAGE_INSTALLATION_DIRECTORY!\nts\doc >> "!LOG_PACKAGE_BUILD!"
XCOPY /E /Y "!ABSOLUTE_EXTENSION_DOCUMENT_DIRECTORY!" "!ABSOLUTE_PACKAGES_DIRECTORY!\!DRIVER_PACKAGE_INSTALLATION_DIRECTORY!\nts\doc" >> "!LOG_PACKAGE_BUILD!" 2>&1
CALL :CLEANGITSOURCE "!ABSOLUTE_DEPENDENCIES_PHP_SOURCE_DIRECTORY!" "!LOG_DRIVER_BUILD!"
IF !ERRORLEVEL! NEQ 0 EXIT /B !ERRORLEVEL!
CALL :CLEANDIRECTORY "!ABSOLUTE_DRIVER_LIBRARY_DIRECTORY!" "Cleaning library directory"
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 packages for !TARGET_ARCHITECTURE_ARCHIVE_NAME! VC!VISUAL_STUDIO_INTERNAL_SHORTHAND_VERSION! [TS] ... "
ECHO !ZIP! a -tzip !ABSOLUTE_PACKAGES_DIRECTORY!\!BUILD_PACKAGE_PREFIX!-!BUILD_PACKAGE_VERSION!-!PHP_DISPLAY_VERSION!-ts-vc!VISUAL_STUDIO_INTERNAL_SHORTHAND_VERSION!-!TARGET_ARCHITECTURE_ARCHIVE_NAME!.zip -r !ABSOLUTE_PACKAGES_DIRECTORY!\!DRIVER_PACKAGE_INSTALLATION_DIRECTORY!\ts\ >> "!LOG_PACKAGE_BUILD!"
!ZIP! a -tzip "!ABSOLUTE_PACKAGES_DIRECTORY!\!BUILD_PACKAGE_PREFIX!-!BUILD_PACKAGE_VERSION!-!PHP_DISPLAY_VERSION!-ts-vc!VISUAL_STUDIO_INTERNAL_SHORTHAND_VERSION!-!TARGET_ARCHITECTURE_ARCHIVE_NAME!.zip" -r "!ABSOLUTE_PACKAGES_DIRECTORY!\!DRIVER_PACKAGE_INSTALLATION_DIRECTORY!\ts\*" >> "!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 driver packages for !TARGET_ARCHITECTURE_ARCHIVE_NAME! VC!VISUAL_STUDIO_INTERNAL_SHORTHAND_VERSION! [NTS] ... "
ECHO !ZIP! a -tzip !ABSOLUTE_PACKAGES_DIRECTORY!\!BUILD_PACKAGE_PREFIX!-!BUILD_PACKAGE_VERSION!-!PHP_DISPLAY_VERSION!-nts-vc!VISUAL_STUDIO_INTERNAL_SHORTHAND_VERSION!-!TARGET_ARCHITECTURE_ARCHIVE_NAME!.zip -r !ABSOLUTE_PACKAGES_DIRECTORY!\!DRIVER_PACKAGE_INSTALLATION_DIRECTORY!\nts\ >> "!LOG_PACKAGE_BUILD!"
!ZIP! a -tzip "!ABSOLUTE_PACKAGES_DIRECTORY!\!BUILD_PACKAGE_PREFIX!-!BUILD_PACKAGE_VERSION!-!PHP_DISPLAY_VERSION!-nts-vc!VISUAL_STUDIO_INTERNAL_SHORTHAND_VERSION!-!TARGET_ARCHITECTURE_ARCHIVE_NAME!.zip" -r "!ABSOLUTE_PACKAGES_DIRECTORY!\!DRIVER_PACKAGE_INSTALLATION_DIRECTORY!\nts\*" >> "!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.
REM Clean source and build directories
CALL :CLEANDIRECTORY "!ABSOLUTE_DEPENDENCIES_DIRECTORY!\!DEPENDENCIES_LIBRARIES_DIRECTORY!" "Cleaning library dependencies directory"
CALL :CLEANGITSOURCE "!ABSOLUTE_DEPENDENCIES_CPP_DRIVER_SOURCE_DIRECTORY!" "!LOG_DRIVER_BUILD!"
CALL :CLEANGITSOURCE "!ABSOLUTE_DEPENDENCIES_MPIR_SOURCE_DIRECTORY!" "!LOG_DRIVER_BUILD!"
ECHO.
REM Reset the system PATH
SET "PATH=!STORED_PATH!"
)
) ELSE (
ECHO Visual Studio !PHP_VISUAL_STUDIO_VERSION! not Detected: PHP v%%A package will not be created
)
)
)
REM Disable delayed expansion
ENDLOCAL
REM Exit the batch operation (Ensures below functions are skipped
GOTO :EOF
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_ENABLE_THREAD_SAFETY! Enable thread safety
ECHO !ARGUMENT_ENABLE_BUILD_PACKAGES! [version] Enable package generation ^(5.6, 7.0, 7.1^) ^(*^)
ECHO !ARGUMENT_ENABLE_TEST_CONFIGURATION! Enable test configuration build
ECHO !ARGUMENT_PHP_VERSION! [version] PHP version 5.6, 7.0 and 7.1
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.
ECHO C/C++ Driver Options
ECHO !ARGUMENT_USE_BOOST_ATOMIC! Use Boost atomic
ECHO.
ECHO !ARGUMENT_HELP! Display this message
ECHO.
ECHO * Minimum supported officially released PHP binary installations
EXIT /B
REM Display a message for missing Visual Studio
:DISPLAYMISSINGVSMESSAGE
SET "DOWNLOAD_URL_VISUAL_STUDIO=https://go.microsoft.com/fwlink/?LinkId=691984&clcid=0x409"
SET "DOWNLOAD_VISUAL_STUDIO_MESSAGE=Would you like to download Visual Studio 2015 Community now?"
SET PHP_IS_7_X=!FASLE!
IF "!PHP_VERSION!" == "7_1" SET PHP_IS_7_X=!TRUE!
IF "!PHP_VERSION!" == "7_0" SET PHP_IS_7_X=!TRUE!
IF !PHP_IS_7_X! EQU !TRUE! (
ECHO Visual Studio Not Found: Install Visual Studio 2015 to complete build
) ELSE (
ECHO Visual Studio Not Found: Install Visual Studio 2012 to complete build
SET "DOWNLOAD_VISUAL_STUDIO_MESSAGE=Would you like to download Visual Studio 2012 Express now?"
SET "DOWNLOAD_URL_VISUAL_STUDIO=https://www.microsoft.com/en-us/download/details.aspx?id=34673"
)
ECHO.
CHOICE /N /T 15 /D N /M "!DOWNLOAD_VISUAL_STUDIO_MESSAGE!"
IF !ERRORLEVEL! EQU !YES! START !DOWNLOAD_URL_VISUAL_STUDIO!
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
REM -1 if version-one < version-two
:COMPAREVERSION [version-one] [version-two]
CALL :GETVERSIONINFORMATION %~1 VERSION_ONE_MAJOR VERSION_ONE_MINOR VERSION_ONE_PATCH
CALL :GETVERSIONINFORMATION %~2 VERSION_TWO_MAJOR VERSION_TWO_MINOR VERSION_TWO_PATCH
IF !VERSION_ONE_MAJOR! GTR !VERSION_TWO_MAJOR! EXIT /B 1
IF !VERSION_ONE_MAJOR! LSS !VERSION_TWO_MAJOR! EXIT /B -1
IF NOT DEFINED VERSION_ONE_MINOR IF NOT DEFINED VERSION_TWO_MINOR EXIT /B 0
IF !VERSION_ONE_MINOR! GTR !VERSION_TWO_MINOR! EXIT /B 1
IF !VERSION_ONE_MINOR! LSS !VERSION_TWO_MINOR! EXIT /B -1
IF NOT DEFINED VERSION_ONE_PATCH IF NOT DEFINED VERSION_TWO_PATCH EXIT /B 0
IF !VERSION_ONE_PATCH! GTR !VERSION_TWO_PATCH! EXIT /B 1
IF !VERSION_ONE_PATCH! LSS !VERSION_TWO_PATCH! EXIT /B -1
EXIT /B 0
REM Get version breakdown [major.minor.patch]
REM
REM @param version String representing the full version
REM @param return-major Major version number parsed from version