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" == "Ninja" (
39 set CMAKE_GENERATOR="Ninja"
41 set CMAKE_GENERATOR="MinGW Makefiles"
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." > NUL && set BUILD_ENVIRONMENT=VS8
61 cl 2>&1 | find "15." > NUL && set BUILD_ENVIRONMENT=VS9
62 cl 2>&1 | find "16." > NUL && set BUILD_ENVIRONMENT=VS10
63 cl 2>&1 | find "17." > NUL && set BUILD_ENVIRONMENT=VS11
64 if not defined BUILD_ENVIRONMENT (
65 echo Error: Visual Studio version too old or version detection failed.
69 echo Detected Visual Studio Environment !BUILD_ENVIRONMENT!-!ARCH!
70 if /I "%1" == "VSSolution" (
71 if "!BUILD_ENVIRONMENT!" == "VS8" (
72 if "!ARCH!" == "amd64" (
73 set CMAKE_GENERATOR="Visual Studio 8 2005 Win64"
75 set CMAKE_GENERATOR="Visual Studio 8 2005"
77 ) else if "!BUILD_ENVIRONMENT!" == "VS9" (
78 if "!ARCH!" == "amd64" (
79 set CMAKE_GENERATOR="Visual Studio 9 2008 Win64"
81 set CMAKE_GENERATOR="Visual Studio 9 2008"
83 ) else if "!BUILD_ENVIRONMENT!" == "VS10" (
84 if "!ARCH!" == "amd64" (
85 set CMAKE_GENERATOR="Visual Studio 10 Win64"
87 set CMAKE_GENERATOR="Visual Studio 10"
89 ) else if "!BUILD_ENVIRONMENT!" == "VS11" (
90 if "!ARCH!" == "amd64" (
91 set CMAKE_GENERATOR="Visual Studio 11 Win64"
92 ) else if "!ARCH!" == "arm" (
93 set CMAKE_GENERATOR="Visual Studio 11 ARM"
95 set CMAKE_GENERATOR="Visual Studio 11"
100 echo This script defaults to nmake. To use Visual Studio GUI specify "VSSolution" as a parameter.
103 ) else if defined sdkdir (
104 echo Detected Windows SDK %TARGET_PLATFORM%-%TARGET_CPU%
105 if "%TARGET_CPU%" == "x86" (
107 ) else if "%TARGET_CPU%" == "x64" (
111 set BUILD_ENVIRONMENT=SDK
115 echo Error: Unable to detect build environment. Configure script failure.
120 if not defined ARCH (
121 echo Unknown build architecture
125 :: Detect nmake generator
126 if %USE_NMAKE% == 1 (
127 if /I "%1" == "CodeBlocks" (
128 set CMAKE_GENERATOR="CodeBlocks - NMake Makefiles"
129 ) else if /I "%1" == "Eclipse" (
130 set CMAKE_GENERATOR="Eclipse CDT4 - NMake Makefiles"
131 ) else if /I "%1" == "JOM" (
132 set CMAKE_GENERATOR="NMake Makefiles JOM"
133 ) else if /I "%1" == "Ninja" (
134 set CMAKE_GENERATOR="Ninja"
136 set CMAKE_GENERATOR="NMake Makefiles"
140 :: Create directories
141 set REACTOS_OUTPUT_PATH=output-%BUILD_ENVIRONMENT%-%ARCH%
142 if "%REACTOS_SOURCE_DIR%" == "%CD%\" (
143 echo Creating directories in %REACTOS_OUTPUT_PATH%
145 if not exist %REACTOS_OUTPUT_PATH% (
146 mkdir %REACTOS_OUTPUT_PATH%
148 cd %REACTOS_OUTPUT_PATH%
151 if not exist host-tools (
154 if not exist reactos (
158 echo Preparing host tools...
160 if EXIST CMakeCache.txt (
161 del CMakeCache.txt /q
163 set REACTOS_BUILD_TOOLS_DIR=%CD%
165 :: Use x86 for ARM host tools
166 if "%ARCH%" == "arm" (
167 :: Launch new script instance for x86 host tools configuration
168 start "Preparing host tools for ARM cross build..." /I /B /WAIT %~dp0configure.cmd arm_hosttools "%VSINSTALLDIR%VC\vcvarsall.bat" %CMAKE_GENERATOR%
170 cmake -G %CMAKE_GENERATOR% -DARCH=%ARCH% "%REACTOS_SOURCE_DIR%"
175 echo Preparing reactos...
177 if EXIST CMakeCache.txt (
178 del CMakeCache.txt /q
181 if "%BUILD_ENVIRONMENT%" == "MinGW" (
182 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%"
183 ) else if "%BUILD_ENVIRONMENT%" == "WDK" (
184 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%"
186 cmake -G %CMAKE_GENERATOR% -DCMAKE_TOOLCHAIN_FILE=toolchain-msvc.cmake -DARCH=%ARCH% -DREACTOS_BUILD_TOOLS_DIR:DIR="%REACTOS_BUILD_TOOLS_DIR%" "%REACTOS_SOURCE_DIR%"
191 echo Configure script complete! Enter directories and execute appropriate build commands(ex: make, nmake, jom, etc...).
195 echo Unable to find cmake, if it is installed, check your PATH variable.