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 :: Does the user need help?
11 if /I "%1" == "help" goto 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, RTC
17 echo Cmake-options: -DVARIABLE:TYPE=VALUE
21 :: Special case %1 = arm_hosttools %2 = vcvarsall.bat %3 = %CMAKE_GENERATOR%
22 if /I "%1" == "arm_hosttools" (
23 echo Configuring x86 host tools for ARM cross build
25 :: This launches %VSINSTALLDIR%VS\vcvarsall.bat
28 :: Configure host tools for x86
29 cmake -G %3 -DARCH:STRING=i386 %~dp0
33 :: Get the source root directory
34 set REACTOS_SOURCE_DIR=%~dp0
36 :: Set default generator
37 set CMAKE_GENERATOR="Ninja"
38 set CMAKE_GENERATOR_HOST=!CMAKE_GENERATOR!
40 :: Detect presence of cmake
41 cmd /c cmake --version 2>&1 | find "cmake version" > NUL || goto cmake_notfound
43 :: Detect build environment (MinGW, VS, WDK, ...)
45 echo Detected RosBE for %ROS_ARCH%
46 set BUILD_ENVIRONMENT=MinGW
48 set MINGW_TOOCHAIN_FILE=toolchain-gcc.cmake
50 ) else if defined VCINSTALLDIR (
51 :: VS command prompt does not put this in environment vars
52 cl 2>&1 | find "x86" > NUL && set ARCH=i386
53 cl 2>&1 | find "x64" > NUL && set ARCH=amd64
54 cl 2>&1 | find "ARM" > NUL && set ARCH=arm
55 cl 2>&1 | find "15.00." > NUL && set VS_VERSION=9
56 cl 2>&1 | find "16.00." > NUL && set VS_VERSION=10
57 cl 2>&1 | find "17.00." > NUL && set VS_VERSION=11
58 cl 2>&1 | find "18.00." > NUL && set VS_VERSION=12
59 cl 2>&1 | find "19.00." > NUL && set VS_VERSION=14
60 if not defined VS_VERSION (
61 echo Error: Visual Studio version too old or version detection failed.
64 set BUILD_ENVIRONMENT=VS
66 set VS_RUNTIME_CHECKS=0
67 echo Detected Visual Studio Environment !BUILD_ENVIRONMENT!!VS_VERSION!-!ARCH!
69 echo Error: Unable to detect build environment. Configure script failure.
75 echo Unknown build architecture
79 :: Parse command line parameters
81 if "%BUILD_ENVIRONMENT%" == "MinGW" (
82 if /I "%1" == "Codeblocks" (
83 set CMAKE_GENERATOR="CodeBlocks - MinGW Makefiles"
84 ) else if /I "%1" == "Eclipse" (
85 set CMAKE_GENERATOR="Eclipse CDT4 - MinGW Makefiles"
86 ) else if /I "%1" == "Makefiles" (
87 set CMAKE_GENERATOR="MinGW Makefiles"
88 ) else if /I "%1" == "clang" (
89 set MINGW_TOOCHAIN_FILE=toolchain-clang.cmake
94 if /I "%1" == "CodeBlocks" (
95 set CMAKE_GENERATOR="CodeBlocks - NMake Makefiles"
96 ) else if /I "%1" == "Eclipse" (
97 set CMAKE_GENERATOR="Eclipse CDT4 - NMake Makefiles"
98 ) else if /I "%1" == "Makefiles" (
99 set CMAKE_GENERATOR="NMake Makefiles"
100 ) else if /I "%1" == "VSSolution" (
102 if "!VS_VERSION!" == "9" (
103 if "!ARCH!" == "amd64" (
104 set CMAKE_GENERATOR="Visual Studio 9 2008 Win64"
106 set CMAKE_GENERATOR="Visual Studio 9 2008"
108 ) else if "!VS_VERSION!" == "10" (
109 if "!ARCH!" == "amd64" (
110 set CMAKE_GENERATOR="Visual Studio 10 Win64"
112 set CMAKE_GENERATOR="Visual Studio 10"
114 ) else if "!VS_VERSION!" == "11" (
115 if "!ARCH!" == "amd64" (
116 set CMAKE_GENERATOR="Visual Studio 11 Win64"
117 ) else if "!ARCH!" == "arm" (
118 set CMAKE_GENERATOR="Visual Studio 11 ARM"
119 set CMAKE_GENERATOR_HOST="Visual Studio 11"
121 set CMAKE_GENERATOR="Visual Studio 11"
123 ) else if "!VS_VERSION!" == "12" (
124 if "!ARCH!" == "amd64" (
125 set CMAKE_GENERATOR="Visual Studio 12 Win64"
126 ) else if "!ARCH!" == "arm" (
127 set CMAKE_GENERATOR="Visual Studio 12 ARM"
128 set CMAKE_GENERATOR_HOST="Visual Studio 12"
130 set CMAKE_GENERATOR="Visual Studio 12"
133 ) else if /I "%1" == "RTC" (
134 echo Runtime checks enabled
135 set VS_RUNTIME_CHECKS=1
141 :: Go to next parameter
146 :: Inform the user about the default build
147 if "!CMAKE_GENERATOR!" == "Ninja" (
148 echo This script defaults to Ninja. Type "configure help" for alternative options.
151 :: Create directories
152 set REACTOS_OUTPUT_PATH=output-%BUILD_ENVIRONMENT%-%ARCH%
153 if "%REACTOS_SOURCE_DIR%" == "%CD%\" (
154 echo Creating directories in %REACTOS_OUTPUT_PATH%
156 if not exist %REACTOS_OUTPUT_PATH% (
157 mkdir %REACTOS_OUTPUT_PATH%
159 cd %REACTOS_OUTPUT_PATH%
162 if not exist host-tools (
165 if not exist reactos (
169 echo Preparing host tools...
171 if EXIST CMakeCache.txt (
172 del CMakeCache.txt /q
174 set REACTOS_BUILD_TOOLS_DIR=%CD%
176 :: Use x86 for ARM host tools
177 if "%ARCH%" == "arm" (
178 :: Launch new script instance for x86 host tools configuration
179 start "Preparing host tools for ARM cross build..." /I /B /WAIT %~dp0configure.cmd arm_hosttools "%VSINSTALLDIR%VC\vcvarsall.bat" %CMAKE_GENERATOR_HOST%
181 cmake -G %CMAKE_GENERATOR% -DARCH:STRING=%ARCH% "%REACTOS_SOURCE_DIR%"
186 echo Preparing reactos...
188 if EXIST CMakeCache.txt (
189 del CMakeCache.txt /q
192 if "%BUILD_ENVIRONMENT%" == "MinGW" (
193 cmake -G %CMAKE_GENERATOR% -DENABLE_CCACHE:BOOL=0 -DCMAKE_TOOLCHAIN_FILE:FILEPATH=%MINGW_TOOCHAIN_FILE% -DARCH:STRING=%ARCH% -DREACTOS_BUILD_TOOLS_DIR:PATH="%REACTOS_BUILD_TOOLS_DIR%" %* "%REACTOS_SOURCE_DIR%"
195 cmake -G %CMAKE_GENERATOR% -DCMAKE_TOOLCHAIN_FILE:FILEPATH=toolchain-msvc.cmake -DARCH:STRING=%ARCH% -DREACTOS_BUILD_TOOLS_DIR:PATH="%REACTOS_BUILD_TOOLS_DIR%" -DRUNTIME_CHECKS:BOOL=%VS_RUNTIME_CHECKS% %* "%REACTOS_SOURCE_DIR%"
200 echo Configure script complete^^! Enter directories and execute appropriate build commands (ex: ninja, make, nmake, etc...).
204 echo Unable to find cmake, if it is installed, check your PATH variable.