3 :: This is needed so as to avoid static expansion of environment variables
4 :: inside if (...) conditionals.
5 :: See http://stackoverflow.com/questions/305605/weird-scope-issue-in-bat-file
6 :: for more explanation.
7 :: Precisely needed for configuring Visual Studio Environment.
8 setlocal enabledelayedexpansion
10 :: Special case %1 = arm_hosttools %2 = vcvarsall.bat %3 = %CMAKE_GENERATOR%
11 if /I "%1" == "arm_hosttools" (
12 echo Configuring x86 host tools for ARM cross build
14 :: This launches %VSINSTALLDIR%VS\vcvarsall.bat
17 :: Configure host tools for x86
18 cmake -G %3 -DARCH=i386 %~dp0
22 :: Get the source root directory
23 set REACTOS_SOURCE_DIR=%~dp0
26 :: Detect presence of cmake
27 cmd /c cmake --version 2>&1 | find "cmake version" > NUL || goto cmake_notfound
29 :: Detect build environment (MinGW, VS, WDK, ...)
31 echo Detected RosBE for %ROS_ARCH%
32 set BUILD_ENVIRONMENT=MinGW
34 if /I "%1" == "Codeblocks" (
35 set CMAKE_GENERATOR="CodeBlocks - MinGW Makefiles"
36 ) else if /I "%1" == "Eclipse" (
37 set CMAKE_GENERATOR="Eclipse CDT4 - MinGW Makefiles"
38 ) else if /I "%1" == "Makefiles" (
39 set CMAKE_GENERATOR="MinGW Makefiles"
41 set CMAKE_GENERATOR="Ninja"
44 ) else if defined DDK_TARGET_OS (
45 echo Detected DDK/WDK for %DDK_TARGET_OS%-%_BUILDARCH%%
46 set BUILD_ENVIRONMENT=WDK
47 if "%_BUILDARCH%" == "x86" (
49 ) else if "%_BUILDARCH%" == "AMD64" (
55 ) else if defined VCINSTALLDIR (
56 :: VS command prompt does not put this in environment vars
57 cl 2>&1 | find "x86" > NUL && set ARCH=i386
58 cl 2>&1 | find "x64" > NUL && set ARCH=amd64
59 cl 2>&1 | find "ARM" > NUL && set ARCH=arm
60 cl 2>&1 | find "14.00." > NUL && set BUILD_ENVIRONMENT=VS8
61 cl 2>&1 | find "15.00." > NUL && set BUILD_ENVIRONMENT=VS9
62 cl 2>&1 | find "16.00." > NUL && set BUILD_ENVIRONMENT=VS10
63 cl 2>&1 | find "17.00." > NUL && set BUILD_ENVIRONMENT=VS11
64 ::cl 2>&1 | find "18.00." > NUL && set BUILD_ENVIRONMENT=VS12
65 if not defined BUILD_ENVIRONMENT (
66 echo Error: Visual Studio version too old or version detection failed.
70 echo Detected Visual Studio Environment !BUILD_ENVIRONMENT!-!ARCH!
71 if /I "%1" == "VSSolution" (
72 if "!BUILD_ENVIRONMENT!" == "VS8" (
73 if "!ARCH!" == "amd64" (
74 set CMAKE_GENERATOR="Visual Studio 8 2005 Win64"
76 set CMAKE_GENERATOR="Visual Studio 8 2005"
78 ) else if "!BUILD_ENVIRONMENT!" == "VS9" (
79 if "!ARCH!" == "amd64" (
80 set CMAKE_GENERATOR="Visual Studio 9 2008 Win64"
82 set CMAKE_GENERATOR="Visual Studio 9 2008"
84 ) else if "!BUILD_ENVIRONMENT!" == "VS10" (
85 if "!ARCH!" == "amd64" (
86 set CMAKE_GENERATOR="Visual Studio 10 Win64"
88 set CMAKE_GENERATOR="Visual Studio 10"
90 ) else if "!BUILD_ENVIRONMENT!" == "VS11" (
91 if "!ARCH!" == "amd64" (
92 set CMAKE_GENERATOR="Visual Studio 11 Win64"
93 ) else if "!ARCH!" == "arm" (
94 set CMAKE_GENERATOR="Visual Studio 11 ARM"
96 set CMAKE_GENERATOR="Visual Studio 11"
101 echo This script defaults to Ninja. To use Visual Studio GUI specify "VSSolution" as a parameter.
104 ) else if defined sdkdir (
105 echo Detected Windows SDK %TARGET_PLATFORM%-%TARGET_CPU%
106 if "%TARGET_CPU%" == "x86" (
108 ) else if "%TARGET_CPU%" == "x64" (
112 set BUILD_ENVIRONMENT=SDK
116 echo Error: Unable to detect build environment. Configure script failure.
121 if not defined ARCH (
122 echo Unknown build architecture
126 :: Detect VS command line generator
127 if %USE_VSCMD% == 1 (
128 if /I "%1" == "CodeBlocks" (
129 set CMAKE_GENERATOR="CodeBlocks - NMake Makefiles"
130 ) else if /I "%1" == "Eclipse" (
131 set CMAKE_GENERATOR="Eclipse CDT4 - NMake Makefiles"
132 ) else if /I "%1" == "Makefiles" (
133 set CMAKE_GENERATOR="NMake Makefiles"
135 set CMAKE_GENERATOR="Ninja"
139 :: Create directories
140 set REACTOS_OUTPUT_PATH=output-%BUILD_ENVIRONMENT%-%ARCH%
141 if "%REACTOS_SOURCE_DIR%" == "%CD%\" (
142 echo Creating directories in %REACTOS_OUTPUT_PATH%
144 if not exist %REACTOS_OUTPUT_PATH% (
145 mkdir %REACTOS_OUTPUT_PATH%
147 cd %REACTOS_OUTPUT_PATH%
150 if not exist host-tools (
153 if not exist reactos (
157 echo Preparing host tools...
159 if EXIST CMakeCache.txt (
160 del CMakeCache.txt /q
162 set REACTOS_BUILD_TOOLS_DIR=%CD%
164 :: Use x86 for ARM host tools
165 if "%ARCH%" == "arm" (
166 :: Launch new script instance for x86 host tools configuration
167 start "Preparing host tools for ARM cross build..." /I /B /WAIT %~dp0configure.cmd arm_hosttools "%VSINSTALLDIR%VC\vcvarsall.bat" %CMAKE_GENERATOR%
169 cmake -G %CMAKE_GENERATOR% -DARCH=%ARCH% "%REACTOS_SOURCE_DIR%"
174 echo Preparing reactos...
176 if EXIST CMakeCache.txt (
177 del CMakeCache.txt /q
180 if "%BUILD_ENVIRONMENT%" == "MinGW" (
181 cmake -G %CMAKE_GENERATOR% -DENABLE_CCACHE=0 -DPCH=0 -DCMAKE_TOOLCHAIN_FILE=toolchain-gcc.cmake -DARCH=%ARCH% -DREACTOS_BUILD_TOOLS_DIR:DIR="%REACTOS_BUILD_TOOLS_DIR%" "%REACTOS_SOURCE_DIR%"
182 ) else if "%BUILD_ENVIRONMENT%" == "WDK" (
183 cmake -G %CMAKE_GENERATOR% -DCMAKE_TOOLCHAIN_FILE=toolchain-msvc.cmake -DUSE_WDK_HEADERS=%USE_WDK_HEADERS% -DARCH=%ARCH% -DREACTOS_BUILD_TOOLS_DIR:DIR="%REACTOS_BUILD_TOOLS_DIR%" "%REACTOS_SOURCE_DIR%"
185 cmake -G %CMAKE_GENERATOR% -DCMAKE_TOOLCHAIN_FILE=toolchain-msvc.cmake -DARCH=%ARCH% -DREACTOS_BUILD_TOOLS_DIR:DIR="%REACTOS_BUILD_TOOLS_DIR%" "%REACTOS_SOURCE_DIR%"
190 echo Configure script complete^^! Enter directories and execute appropriate build commands (ex: ninja, make, nmake, etc...).
194 echo Unable to find cmake, if it is installed, check your PATH variable.