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 VCINSTALLDIR (
45 :: VS command prompt does not put this in environment vars
46 cl 2>&1 | find "x86" > NUL && set ARCH=i386
47 cl 2>&1 | find "x64" > NUL && set ARCH=amd64
48 cl 2>&1 | find "ARM" > NUL && set ARCH=arm
49 cl 2>&1 | find "16.00." > NUL && set BUILD_ENVIRONMENT=VS10
50 cl 2>&1 | find "17.00." > NUL && set BUILD_ENVIRONMENT=VS11
51 cl 2>&1 | find "18.00." > NUL && set BUILD_ENVIRONMENT=VS12
52 if not defined BUILD_ENVIRONMENT (
53 echo Error: Visual Studio version too old or version detection failed.
57 echo Detected Visual Studio Environment !BUILD_ENVIRONMENT!-!ARCH!
58 if /I "%1" == "VSSolution" (
59 if "!BUILD_ENVIRONMENT!" == "VS10" (
60 if "!ARCH!" == "amd64" (
61 set CMAKE_GENERATOR="Visual Studio 10 Win64"
63 set CMAKE_GENERATOR="Visual Studio 10"
65 ) else if "!BUILD_ENVIRONMENT!" == "VS11" (
66 if "!ARCH!" == "amd64" (
67 set CMAKE_GENERATOR="Visual Studio 11 Win64"
68 ) else if "!ARCH!" == "arm" (
69 set CMAKE_GENERATOR="Visual Studio 11 ARM"
71 set CMAKE_GENERATOR="Visual Studio 11"
73 ) else if "!BUILD_ENVIRONMENT!" == "VS12" (
74 if "!ARCH!" == "amd64" (
75 set CMAKE_GENERATOR="Visual Studio 12 Win64"
76 ) else if "!ARCH!" == "arm" (
77 set CMAKE_GENERATOR="Visual Studio 12 ARM"
79 set CMAKE_GENERATOR="Visual Studio 12"
84 echo This script defaults to Ninja. To use Visual Studio GUI specify "VSSolution" as a parameter.
88 echo Error: Unable to detect build environment. Configure script failure.
94 echo Unknown build architecture
98 :: Detect VS command line generator
100 if /I "%1" == "CodeBlocks" (
101 set CMAKE_GENERATOR="CodeBlocks - NMake Makefiles"
102 ) else if /I "%1" == "Eclipse" (
103 set CMAKE_GENERATOR="Eclipse CDT4 - NMake Makefiles"
104 ) else if /I "%1" == "Makefiles" (
105 set CMAKE_GENERATOR="NMake Makefiles"
107 set CMAKE_GENERATOR="Ninja"
111 :: Create directories
112 set REACTOS_OUTPUT_PATH=output-%BUILD_ENVIRONMENT%-%ARCH%
113 if "%REACTOS_SOURCE_DIR%" == "%CD%\" (
114 echo Creating directories in %REACTOS_OUTPUT_PATH%
116 if not exist %REACTOS_OUTPUT_PATH% (
117 mkdir %REACTOS_OUTPUT_PATH%
119 cd %REACTOS_OUTPUT_PATH%
122 if not exist host-tools (
125 if not exist reactos (
129 echo Preparing host tools...
131 if EXIST CMakeCache.txt (
132 del CMakeCache.txt /q
134 set REACTOS_BUILD_TOOLS_DIR=%CD%
136 :: Use x86 for ARM host tools
137 if "%ARCH%" == "arm" (
138 :: Launch new script instance for x86 host tools configuration
139 start "Preparing host tools for ARM cross build..." /I /B /WAIT %~dp0configure.cmd arm_hosttools "%VSINSTALLDIR%VC\vcvarsall.bat" %CMAKE_GENERATOR%
141 cmake -G %CMAKE_GENERATOR% -DARCH=%ARCH% "%REACTOS_SOURCE_DIR%"
146 echo Preparing reactos...
148 if EXIST CMakeCache.txt (
149 del CMakeCache.txt /q
152 if "%BUILD_ENVIRONMENT%" == "MinGW" (
153 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%"
155 cmake -G %CMAKE_GENERATOR% -DCMAKE_TOOLCHAIN_FILE=toolchain-msvc.cmake -DARCH=%ARCH% -DREACTOS_BUILD_TOOLS_DIR:DIR="%REACTOS_BUILD_TOOLS_DIR%" "%REACTOS_SOURCE_DIR%"
160 echo Configure script complete^^! Enter directories and execute appropriate build commands (ex: ninja, make, nmake, etc...).
164 echo Unable to find cmake, if it is installed, check your PATH variable.