|
| 1 | +@echo off |
| 2 | +:: prebuild.bat --vs 2019 |
| 3 | +SETLOCAL |
| 4 | + |
| 5 | +rem Print help message |
| 6 | +if "%1"=="-h" goto :print_help |
| 7 | +if "%1"=="-help" goto :print_help |
| 8 | +if "%1"=="--h" goto :print_help |
| 9 | +if "%1"=="--help" goto :print_help |
| 10 | +if "%1"=="/?" goto :print_help |
| 11 | + |
| 12 | +goto :start |
| 13 | + |
| 14 | +:print_help |
| 15 | +echo: |
| 16 | +echo This script generates Visual Studio project and solution files for IsaSpecManager on Windows. |
| 17 | +echo: |
| 18 | +echo Usage: prebuild.bat ^[options^] |
| 19 | +echo: |
| 20 | +echo Options: |
| 21 | +echo --cmake Path to cmake executable to use. If not specified, the cmake from PATH env variable will be used. |
| 22 | +echo --vs Microsoft Visual Studio version. Currently supported values are: "2015", "2017", "2019" and "2022". The default is "2019". |
| 23 | +echo: |
| 24 | +echo Examples: |
| 25 | +echo prebuild.bat |
| 26 | +echo prebuild.bat --vs 2017 |
| 27 | + |
| 28 | +goto :exit |
| 29 | + |
| 30 | +:start |
| 31 | +set SCRIPT_DIR=%~dp0 |
| 32 | +set CURRENT_DIR=%CD% |
| 33 | + |
| 34 | +rem Default values |
| 35 | +set CMAKE_PATH=cmake |
| 36 | +set VS_VER=2019 |
| 37 | +set TEST=-DTEST_PROJECT=ON |
| 38 | +set BUILD_INTERNAL=-DBuildInternal=OFF |
| 39 | + |
| 40 | +:begin |
| 41 | +if [%1]==[] goto :start_cmake |
| 42 | +if "%1"=="--no-test" goto :set_notest_flag |
| 43 | +if "%1"=="--public-only" goto :set_public_build_flag |
| 44 | +if "%1"=="--cmake" goto :set_cmake |
| 45 | +if "%1"=="--vs" goto :set_vs |
| 46 | +if "%1"=="--internal" goto :set_internal_build_flag |
| 47 | +goto :bad_arg |
| 48 | + |
| 49 | +:set_notest_flag |
| 50 | +goto :start_cmake |
| 51 | + |
| 52 | +:set_internal_build_flag |
| 53 | +goto :start_cmake |
| 54 | + |
| 55 | +:set_cmake |
| 56 | +set CMAKE_PATH=%2 |
| 57 | +goto :shift_2args |
| 58 | + |
| 59 | +:set_vs |
| 60 | +set VS_VER=%2 |
| 61 | +goto :shift_2args |
| 62 | + |
| 63 | +:set_verbose |
| 64 | +@echo on |
| 65 | +goto :shift_arg |
| 66 | + |
| 67 | +:shift_2args |
| 68 | +rem Shift to the next pair of arguments |
| 69 | +shift |
| 70 | +:shift_arg |
| 71 | +shift |
| 72 | +goto :begin |
| 73 | + |
| 74 | +:bad_arg |
| 75 | +echo Error: Unexpected argument: %1%. Aborting... |
| 76 | +exit /b 1 |
| 77 | + |
| 78 | +:start_cmake |
| 79 | +set CMAKE_VSARCH= |
| 80 | +if "%VS_VER%"=="2015" ( |
| 81 | + set CMAKE_VS="Visual Studio 14 2015 Win64" |
| 82 | +) else ( |
| 83 | + if "%VS_VER%"=="2017" ( |
| 84 | + set CMAKE_VS="Visual Studio 15 2017 Win64" |
| 85 | + ) else ( |
| 86 | + if "%VS_VER%"=="2019" ( |
| 87 | + set CMAKE_VS="Visual Studio 16 2019" |
| 88 | + set CMAKE_VSARCH=-A x64 |
| 89 | + ) else ( |
| 90 | + if "%VS_VER%"=="2022" ( |
| 91 | + set CMAKE_VS="Visual Studio 17 2022" |
| 92 | + set CMAKE_VSARCH=-A x64 |
| 93 | + ) else ( |
| 94 | + echo Error: Unknown VisualStudio version provided. Aborting... |
| 95 | + exit /b 1 |
| 96 | + ) |
| 97 | + ) |
| 98 | + ) |
| 99 | +) |
| 100 | + |
| 101 | +rem Create an output folder |
| 102 | +set VS_FOLDER=VS%VS_VER% |
| 103 | +set OUTPUT_FOLDER=%SCRIPT_DIR%windows\%VS_FOLDER% |
| 104 | +if not exist %OUTPUT_FOLDER% ( |
| 105 | + mkdir %OUTPUT_FOLDER% |
| 106 | +) |
| 107 | + |
| 108 | +rem Invoke cmake with required arguments. |
| 109 | +echo: |
| 110 | +echo Running cmake to generate a VisualStudio solution... |
| 111 | +cd %OUTPUT_FOLDER% |
| 112 | +%CMAKE_PATH% -G %CMAKE_VS% %CMAKE_VSARCH% ..\..\.. |
| 113 | +if not %ERRORLEVEL%==0 ( |
| 114 | + echo "ERROR: cmake failed. Aborting..." |
| 115 | + exit /b 1 |
| 116 | +) |
| 117 | +cd %CURRENT_DIR% |
| 118 | +echo Done. |
0 commit comments