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"
40 ) else if /I "%1" == "clang" (
41 set BUILD_ENVIRONMENT=Clang
42 set CMAKE_GENERATOR="Ninja"
44 set CMAKE_GENERATOR="Ninja"
47 ) else if defined VCINSTALLDIR (
48 :: VS command prompt does not put this in environment vars
49 cl 2>&1 | find "x86" > NUL && set ARCH=i386
50 cl 2>&1 | find "x64" > NUL && set ARCH=amd64
51 cl 2>&1 | find "ARM" > NUL && set ARCH=arm
52 cl 2>&1 | find "16.00." > NUL && set BUILD_ENVIRONMENT=VS10
53 cl 2>&1 | find "17.00." > NUL && set BUILD_ENVIRONMENT=VS11
54 cl 2>&1 | find "18.00." > NUL && set BUILD_ENVIRONMENT=VS12
55 if not defined BUILD_ENVIRONMENT (
56 echo Error: Visual Studio version too old or version detection failed.
60 echo Detected Visual Studio Environment !BUILD_ENVIRONMENT!-!ARCH!
61 if /I "%1" == "VSSolution" (
62 if "!BUILD_ENVIRONMENT!" == "VS10" (
63 if "!ARCH!" == "amd64" (
64 set CMAKE_GENERATOR="Visual Studio 10 Win64"
66 set CMAKE_GENERATOR="Visual Studio 10"
68 ) else if "!BUILD_ENVIRONMENT!" == "VS11" (
69 if "!ARCH!" == "amd64" (
70 set CMAKE_GENERATOR="Visual Studio 11 Win64"
71 ) else if "!ARCH!" == "arm" (
72 set CMAKE_GENERATOR="Visual Studio 11 ARM"
74 set CMAKE_GENERATOR="Visual Studio 11"
76 ) else if "!BUILD_ENVIRONMENT!" == "VS12" (
77 if "!ARCH!" == "amd64" (
78 set CMAKE_GENERATOR="Visual Studio 12 Win64"
79 ) else if "!ARCH!" == "arm" (
80 set CMAKE_GENERATOR="Visual Studio 12 ARM"
82 set CMAKE_GENERATOR="Visual Studio 12"
87 echo This script defaults to Ninja. To use Visual Studio GUI specify "VSSolution" as a parameter.
91 echo Error: Unable to detect build environment. Configure script failure.
97 echo Unknown build architecture
101 :: Detect VS command line generator
102 if %USE_VSCMD% == 1 (
103 if /I "%1" == "CodeBlocks" (
104 set CMAKE_GENERATOR="CodeBlocks - NMake Makefiles"
105 ) else if /I "%1" == "Eclipse" (
106 set CMAKE_GENERATOR="Eclipse CDT4 - NMake Makefiles"
107 ) else if /I "%1" == "Makefiles" (
108 set CMAKE_GENERATOR="NMake Makefiles"
110 set CMAKE_GENERATOR="Ninja"
114 :: Create directories
115 set REACTOS_OUTPUT_PATH=output-%BUILD_ENVIRONMENT%-%ARCH%
116 if "%REACTOS_SOURCE_DIR%" == "%CD%\" (
117 echo Creating directories in %REACTOS_OUTPUT_PATH%
119 if not exist %REACTOS_OUTPUT_PATH% (
120 mkdir %REACTOS_OUTPUT_PATH%
122 cd %REACTOS_OUTPUT_PATH%
125 if not exist host-tools (
128 if not exist reactos (
132 echo Preparing host tools...
134 if EXIST CMakeCache.txt (
135 del CMakeCache.txt /q
137 set REACTOS_BUILD_TOOLS_DIR=%CD%
139 :: Use x86 for ARM host tools
140 if "%ARCH%" == "arm" (
141 :: Launch new script instance for x86 host tools configuration
142 start "Preparing host tools for ARM cross build..." /I /B /WAIT %~dp0configure.cmd arm_hosttools "%VSINSTALLDIR%VC\vcvarsall.bat" %CMAKE_GENERATOR%
144 cmake -G %CMAKE_GENERATOR% -DARCH=%ARCH% "%REACTOS_SOURCE_DIR%"
149 echo Preparing reactos...
151 if EXIST CMakeCache.txt (
152 del CMakeCache.txt /q
155 if "%BUILD_ENVIRONMENT%" == "MinGW" (
156 cmake -G %CMAKE_GENERATOR% -DENABLE_CCACHE=0 -DCMAKE_TOOLCHAIN_FILE=toolchain-gcc.cmake -DARCH=%ARCH% -DREACTOS_BUILD_TOOLS_DIR:DIR="%REACTOS_BUILD_TOOLS_DIR%" "%REACTOS_SOURCE_DIR%"
157 ) else if "%BUILD_ENVIRONMENT%" == "Clang" (
158 cmake -G %CMAKE_GENERATOR% -DENABLE_CCACHE=0 -DCMAKE_TOOLCHAIN_FILE=toolchain-clang.cmake -DARCH=%ARCH% -DREACTOS_BUILD_TOOLS_DIR:DIR="%REACTOS_BUILD_TOOLS_DIR%" "%REACTOS_SOURCE_DIR%"
160 cmake -G %CMAKE_GENERATOR% -DCMAKE_TOOLCHAIN_FILE=toolchain-msvc.cmake -DARCH=%ARCH% -DREACTOS_BUILD_TOOLS_DIR:DIR="%REACTOS_BUILD_TOOLS_DIR%" "%REACTOS_SOURCE_DIR%"
165 echo Configure script complete^^! Enter directories and execute appropriate build commands (ex: ninja, make, nmake, etc...).
169 echo Unable to find cmake, if it is installed, check your PATH variable.