1@echo off 2 3REM This is needed so as to avoid static expansion of environment variables 4REM inside if (...) conditionals. 5REM See http://stackoverflow.com/questions/305605/weird-scope-issue-in-bat-file 6REM for more explanation. 7REM Precisely needed for configuring Visual Studio Environment. 8setlocal enabledelayedexpansion 9 10REM Does the user need help? 11if /I "%1" == "help" goto help 12if /I "%1" == "/?" ( 13:help 14 echo Help for configure script 15 echo Syntax: path\to\source\configure.cmd [script-options] [Cmake-options] 16 echo Available script-options: Codeblocks, Eclipse, Makefiles, clang, VSSolution 17 echo Cmake-options: -DVARIABLE:TYPE=VALUE 18 goto quit 19) 20 21REM Get the source root directory 22set REACTOS_SOURCE_DIR=%~dp0 23 24REM Ensure there's no spaces in the source path 25echo %REACTOS_SOURCE_DIR%| find " " > NUL 26if %ERRORLEVEL% == 0 ( 27 echo. && echo Your source path contains at least one space. 28 echo This will cause problems with building. 29 echo Please rename your folders so there are no spaces in the source path, 30 echo or move your source to a different folder. 31 goto quit 32) 33 34REM Set default generator 35set CMAKE_GENERATOR="Ninja" 36set CMAKE_ARCH= 37 38REM Detect presence of cmake 39cmd /c cmake --version 2>&1 | find "cmake version" > NUL || goto cmake_notfound 40 41REM Detect build environment (MinGW, VS, WDK, ...) 42if defined ROS_ARCH ( 43 echo Detected RosBE for %ROS_ARCH% 44 set BUILD_ENVIRONMENT=MinGW 45 set ARCH=%ROS_ARCH% 46 set MINGW_TOOCHAIN_FILE=toolchain-gcc.cmake 47 48) else if defined VCINSTALLDIR ( 49 REM VS command prompt does not put this in environment vars 50 cl 2>&1 | find "x86" > NUL && set ARCH=i386 51 cl 2>&1 | find "x64" > NUL && set ARCH=amd64 52 cl 2>&1 | find "ARM" > NUL && set ARCH=arm 53 cl 2>&1 | find "19.00." > NUL && set VS_VERSION=14 54 cl 2>&1 | findstr /R /c:"19\.1.\." > NUL && set VS_VERSION=15 55 cl 2>&1 | findstr /R /c:"19\.2.\." > NUL && set VS_VERSION=16 56 if not defined VS_VERSION ( 57 echo Error: Visual Studio version too old ^(before 14 ^(2015^)^) or version detection failed. 58 goto quit 59 ) 60 set BUILD_ENVIRONMENT=VS 61 set VS_SOLUTION=0 62 echo Detected Visual Studio Environment !BUILD_ENVIRONMENT!!VS_VERSION!-!ARCH! 63) else ( 64 echo Error: Unable to detect build environment. Configure script failure. 65 goto quit 66) 67 68REM Checkpoint 69if not defined ARCH ( 70 echo Unknown build architecture 71 goto quit 72) 73 74set USE_CLANG_CL=0 75 76REM Parse command line parameters 77:repeat 78 if "%BUILD_ENVIRONMENT%" == "MinGW" ( 79 if /I "%1" == "Codeblocks" ( 80 set CMAKE_GENERATOR="CodeBlocks - MinGW Makefiles" 81 ) else if /I "%1" == "Eclipse" ( 82 set CMAKE_GENERATOR="Eclipse CDT4 - MinGW Makefiles" 83 ) else if /I "%1" == "Makefiles" ( 84 set CMAKE_GENERATOR="MinGW Makefiles" 85 ) else if /I "%1" == "VSSolution" ( 86 echo. && echo Error: Creation of VS Solution files is not supported in a MinGW environment. 87 echo Please run this command in a [Developer] Command Prompt for Visual Studio. 88 goto quit 89 ) else if /I "%1" NEQ "" ( 90 echo %1| find /I "-D" > NUL 91 if %ERRORLEVEL% == 0 ( 92 REM User is passing a switch to CMake 93 REM Ignore it, and ignore the next parameter that follows 94 Shift 95 ) else ( 96 echo. && echo Warning: Unrecognized switch "%1" && echo. 97 ) 98 ) else ( 99 goto continue 100 ) 101 ) else ( 102 if /I "%1" == "CodeBlocks" ( 103 set CMAKE_GENERATOR="CodeBlocks - NMake Makefiles" 104 ) else if /I "%1" == "Eclipse" ( 105 set CMAKE_GENERATOR="Eclipse CDT4 - NMake Makefiles" 106 ) else if /I "%1" == "Makefiles" ( 107 set CMAKE_GENERATOR="NMake Makefiles" 108 ) else if /I "%1" == "clang" ( 109 set USE_CLANG_CL=1 110 ) else if /I "%1" == "VSSolution" ( 111 set VS_SOLUTION=1 112 REM explicitly set VS version for project generator 113 if /I "%2" == "-VS_VER" ( 114 set VS_VERSION=%3 115 echo Visual Studio Environment set to !BUILD_ENVIRONMENT!!VS_VERSION!-!ARCH! 116 ) 117 set CMAKE_GENERATOR="Visual Studio !VS_VERSION!" 118 if "!ARCH!" == "i386" ( 119 set CMAKE_ARCH=-A Win32 120 ) else if "!ARCH!" == "amd64" ( 121 set CMAKE_ARCH=-A x64 122 ) else if "!ARCH!" == "arm" ( 123 set CMAKE_ARCH=-A ARM 124 ) 125 ) else if /I "%1" NEQ "" ( 126 echo %1| find /I "-D" > NUL 127 if %ERRORLEVEL% == 0 ( 128 REM User is passing a switch to CMake 129 REM Ignore it, and ignore the next parameter that follows 130 Shift 131 ) else ( 132 echo. && echo Warning: Unrecognized switch "%1" && echo. 133 ) 134 ) else ( 135 goto continue 136 ) 137 ) 138 139 REM Go to next parameter 140 SHIFT 141 goto repeat 142:continue 143 144REM Inform the user about the default build 145if "!CMAKE_GENERATOR!" == "Ninja" ( 146 echo This script defaults to Ninja. Type "configure help" for alternative options. 147) 148 149REM Create directories 150set REACTOS_OUTPUT_PATH=output-%BUILD_ENVIRONMENT%-%ARCH% 151 152if "%VS_SOLUTION%" == "1" ( 153 set REACTOS_OUTPUT_PATH=%REACTOS_OUTPUT_PATH%-sln 154) 155 156if "%REACTOS_SOURCE_DIR%" == "%CD%\" ( 157 set CD_SAME_AS_SOURCE=1 158 echo Creating directories in %REACTOS_OUTPUT_PATH% 159 160 if not exist %REACTOS_OUTPUT_PATH% ( 161 mkdir %REACTOS_OUTPUT_PATH% 162 ) 163 cd %REACTOS_OUTPUT_PATH% 164) 165 166if "%VS_SOLUTION%" == "1" ( 167 168 if exist build.ninja ( 169 echo. && echo Error: This directory has already been configured for ninja. 170 echo An output folder configured for ninja can't be reconfigured for VSSolution. 171 echo Use an empty folder or delete the contents of this folder, then try again. 172 goto quit 173 ) 174) else if exist REACTOS.sln ( 175 echo. && echo Error: This directory has already been configured for Visual Studio. 176 echo An output folder configured for VSSolution can't be reconfigured for ninja. 177 echo Use an empty folder or delete the contents of this folder, then try again. && echo. 178 goto quit 179) 180 181echo Preparing reactos... 182 183if EXIST CMakeCache.txt ( 184 del CMakeCache.txt /q 185) 186 187 188if "%BUILD_ENVIRONMENT%" == "MinGW" ( 189 cmake -G %CMAKE_GENERATOR% -DENABLE_CCACHE:BOOL=0 -DCMAKE_TOOLCHAIN_FILE:FILEPATH=%MINGW_TOOCHAIN_FILE% -DARCH:STRING=%ARCH% %BUILD_TOOLS_FLAG% %* "%REACTOS_SOURCE_DIR%" 190) else if %USE_CLANG_CL% == 1 ( 191 cmake -G %CMAKE_GENERATOR% -DCMAKE_TOOLCHAIN_FILE:FILEPATH=toolchain-msvc.cmake -DARCH:STRING=%ARCH% %BUILD_TOOLS_FLAG% -DUSE_CLANG_CL:BOOL=1 %* "%REACTOS_SOURCE_DIR%" 192) else ( 193 cmake -G %CMAKE_GENERATOR% %CMAKE_ARCH% -DCMAKE_TOOLCHAIN_FILE:FILEPATH=toolchain-msvc.cmake -DARCH:STRING=%ARCH% %BUILD_TOOLS_FLAG% %* "%REACTOS_SOURCE_DIR%" 194) 195 196if %ERRORLEVEL% NEQ 0 ( 197 goto quit 198) 199 200if "%CD_SAME_AS_SOURCE%" == "1" ( 201 set ENDV= from %REACTOS_OUTPUT_PATH% 202) 203 204if "%VS_SOLUTION%" == "1" ( 205 set ENDV= You can now use msbuild or open REACTOS.sln%ENDV%. 206) else ( 207 set ENDV= Execute appropriate build commands ^(ex: ninja, make, nmake, etc...^)%ENDV% 208) 209 210echo. && echo Configure script complete^^!%ENDV% 211 212goto quit 213 214:cmake_notfound 215echo Unable to find cmake, if it is installed, check your PATH variable. 216 217:quit 218endlocal 219exit /b 220