@@ -253,8 +253,9 @@ REM USAGE function: output a usage message
253
253
echo help^ |*?* : output this message and exit; ?? for more options.
254
254
echo 32^ |64 : set the architecture to x86 or x64, respectively;
255
255
echo if none is specified, autodetection is attempted.
256
- echo setup : invoke MSVC's build environment setup script before
257
- echo building (requires 2017 version or later^ ).
256
+ echo setup[:Y] : invoke MSVC's build environment setup script before
257
+ echo building; optional Y specifies the release year
258
+ echo (requires 2017 version or later^ ).
258
259
echo clean : remove all the files in the build dir.
259
260
echo proper : clean libs, builds, project dirs and exit.
260
261
echo type:T : selects the build type, T: Debug or Release.
@@ -308,7 +309,6 @@ REM USAGE function: output a usage message
308
309
echo param (needs Administrator privileges^ ).
309
310
echo regdel : deregister the driver from the registry;
310
311
echo (needs Administrator privileges^ ).
311
- echo tests : (deprecated^ ) synonym with utests.
312
312
echo .
313
313
goto :eof
314
314
@@ -376,22 +376,37 @@ REM CLEAN function: clean up the build dir.
376
376
377
377
REM SETUP function: set-up the build environment
378
378
:SETUP
379
- set RELEASE = 2017
380
- for %%e in (Enterprise, Professional, Community) do (
381
- if exist " C:\Program Files (x86)\Microsoft Visual Studio\%RELEASE% \%%e \Common7\Tools\VsDevCmd.bat" (
382
- if /i " %%e " == " Community" (
383
- echo .
384
- echo %~nx0 : WARNING: Community edition is not licensed to build commerical projects.
385
- echo .
379
+ REM cycle through the args, look for '^setup:' token and use the
380
+ REM remaining string in argument
381
+ for %%a in (%ARG:" =% ) do (
382
+ set crr = %%a
383
+ if /i [" !crr:~0 ,6 ! " ] == [" setup:" ] (
384
+ set VS_YEAR = !crr:~6 !
385
+ )
386
+ )
387
+ if [%VS_YEAR% ] == [] (
388
+ set VS_YEARS = 2019 2017
389
+ ) else (
390
+ set VS_YEARS = %VS_YEAR%
391
+ )
392
+
393
+ for %%r in (%VS_YEARS% ) do (
394
+ for %%e in (Enterprise, Professional, Community) do (
395
+ if exist " C:\Program Files (x86)\Microsoft Visual Studio\%%r \%%e \Common7\Tools\VsDevCmd.bat" (
396
+ if /i " %%e " == " Community" (
397
+ echo .
398
+ echo %~nx0 : WARNING: Community edition is not licensed to build commerical projects.
399
+ echo .
400
+ )
401
+ call " C:\Program Files (x86)\Microsoft Visual Studio\%%r \%%e \Common7\Tools\VsDevCmd.bat" -arch=!TARCH!
402
+ set EDITION = %%r
403
+ goto :eof
386
404
)
387
- call " C:\Program Files (x86)\Microsoft Visual Studio\%RELEASE% \%%e \Common7\Tools\VsDevCmd.bat" -arch=!TARCH!
388
- set EDITION = %%e
389
- goto :eof
390
405
)
391
406
)
392
407
if [%EDITION% ] == [] (
393
408
echo .
394
- echo %~nx0 : WARNING: no MSVC edition found, environment not set.
409
+ echo %~nx0 : WARNING: no Visual Studio edition found, environment not set.
395
410
echo .
396
411
)
397
412
@@ -493,6 +508,28 @@ REM BUILDTYPE function: set the build config to feed MSBuild
493
508
494
509
goto :eof
495
510
511
+ REM SETGENERATOR function: reads the environment variables and sets the
512
+ REM generator string to feed CMake
513
+ :SETGENERATOR
514
+ for /f " tokens=1 delims=. " %%a in (" %VSCMD_VER% " ) do (
515
+ set REL_MAJOR = %%a
516
+ )
517
+ if [%REL_MAJOR% ] == [16] (
518
+ set VS_GENERATOR = " Visual Studio 16 2019"
519
+ ) else if [%REL_MAJOR% ] == [15] (
520
+ set VS_GENERATOR = " Visual Studio 15 2017"
521
+ )
522
+
523
+ if [%VS_GENERATOR% ] == [] (
524
+ echo .
525
+ echo %~nx0 : ERROR: no Visual Studio edition detected (%VSCMD_VER% ^ ).
526
+ echo %~nx0 : Retry running with 'setup' argument.
527
+ echo .
528
+ exit /b 1
529
+ )
530
+
531
+ goto :eof
532
+
496
533
REM BUILD function: build various targets
497
534
:BUILD
498
535
REM set the wanted or previously set build type.
@@ -503,12 +540,13 @@ REM BUILD function: build various targets
503
540
if not exist ALL_BUILD.vcxproj (
504
541
echo %~nx0 : generating the project files.
505
542
506
- REM set the wanted build type.
507
- rem call:BUILDTYPE
543
+ call :SETGENERATOR
544
+ if ERRORLEVEL 1 (
545
+ goto :END
546
+ )
508
547
509
548
set CMAKE_ARGS = -DDRIVER_BASE_NAME=%DRIVER_BASE_NAME%
510
- REM no explicit x86 generator and is the default (MSVC2017 only?).
511
- set CMAKE_ARGS = !CMAKE_ARGS! -G " Visual Studio 15 2017" -DCMAKE_GENERATOR_PLATFORM=%TARCH:x86 =%
549
+ set CMAKE_ARGS = !CMAKE_ARGS! -G !VS_GENERATOR! -A %TARCH:x86 =Win32 %
512
550
513
551
if /i [!BUILD_TYPE! ] == [Debug] (
514
552
set CMAKE_ARGS = !CMAKE_ARGS! -DLIBCURL_BUILD_TYPE=debug
@@ -530,13 +568,7 @@ REM BUILD function: build various targets
530
568
goto :eof
531
569
)
532
570
533
- if /i not [%ARG: tests =% ] == [%ARG% ] ( REM utests dup'd
534
- echo %~nx0 : building all the project.
535
- MSBuild ALL_BUILD.vcxproj %MSBUILD_ARGS%
536
- if ERRORLEVEL 1 (
537
- goto END
538
- )
539
- ) else if /i not [%ARG:utests =% ] == [%ARG% ] (
571
+ if /i not [%ARG:utests =% ] == [%ARG% ] (
540
572
echo %~nx0 : building all the project.
541
573
MSBuild ALL_BUILD.vcxproj %MSBUILD_ARGS%
542
574
if ERRORLEVEL 1 (
@@ -588,12 +620,7 @@ REM BUILD function: build various targets
588
620
589
621
REM TESTS_SUITE_S function: run the compiled unit tests
590
622
:TESTS_SUITE_S
591
- if /i not [%ARG: tests =% ] == [%ARG% ] ( REM utests dup'd
592
- MSBuild RUN_TESTS.vcxproj !MSBUILD_ARGS!
593
- if ERRORLEVEL 1 (
594
- goto END
595
- )
596
- ) else if /i not [%ARG:utests =% ] == [%ARG% ] (
623
+ if /i not [%ARG:utests =% ] == [%ARG% ] (
597
624
MSBuild RUN_TESTS.vcxproj !MSBUILD_ARGS!
598
625
if ERRORLEVEL 1 (
599
626
goto END
0 commit comments