forked from Skulltrail192/One-Core-Api-Source
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.cmd
177 lines (154 loc) · 5.85 KB
/
configure.cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
@echo off
:: This is needed so as to avoid static expansion of environment variables
:: inside if (...) conditionals.
:: See http://stackoverflow.com/questions/305605/weird-scope-issue-in-bat-file
:: for more explanation.
:: Precisely needed for configuring Visual Studio Environment.
setlocal enabledelayedexpansion
:: Special case %1 = arm_hosttools %2 = vcvarsall.bat %3 = %CMAKE_GENERATOR%
if /I "%1" == "arm_hosttools" (
echo Configuring x86 host tools for ARM cross build
:: This launches %VSINSTALLDIR%VS\vcvarsall.bat
call %2 x86
:: Configure host tools for x86
cmake -G %3 -DARCH:STRING=i386 %~dp0
exit
)
:: Get the source root directory
set REACTOS_SOURCE_DIR=%~dp0
set USE_VSCMD=0
:: Detect presence of cmake
cmd /c cmake --version 2>&1 | find "cmake version" > NUL || goto cmake_notfound
:: Detect build environment (MinGW, VS, WDK, ...)
if defined ROS_ARCH (
echo Detected RosBE for %ROS_ARCH%
set BUILD_ENVIRONMENT=MinGW
set ARCH=%ROS_ARCH%
if /I "%1" == "Codeblocks" (
set CMAKE_GENERATOR="CodeBlocks - MinGW Makefiles"
) else if /I "%1" == "Eclipse" (
set CMAKE_GENERATOR="Eclipse CDT4 - MinGW Makefiles"
) else if /I "%1" == "Makefiles" (
set CMAKE_GENERATOR="MinGW Makefiles"
) else if /I "%1" == "clang" (
set BUILD_ENVIRONMENT=Clang
set CMAKE_GENERATOR="Ninja"
) else (
set CMAKE_GENERATOR="Ninja"
)
) else if defined VCINSTALLDIR (
:: VS command prompt does not put this in environment vars
cl 2>&1 | find "x86" > NUL && set ARCH=i386
cl 2>&1 | find "x64" > NUL && set ARCH=amd64
cl 2>&1 | find "ARM" > NUL && set ARCH=arm
cl 2>&1 | find "15.00." > NUL && set BUILD_ENVIRONMENT=VS9
cl 2>&1 | find "16.00." > NUL && set BUILD_ENVIRONMENT=VS10
cl 2>&1 | find "17.00." > NUL && set BUILD_ENVIRONMENT=VS11
cl 2>&1 | find "18.00." > NUL && set BUILD_ENVIRONMENT=VS12
if not defined BUILD_ENVIRONMENT (
echo Error: Visual Studio version too old or version detection failed.
exit /b
)
echo Detected Visual Studio Environment !BUILD_ENVIRONMENT!-!ARCH!
if /I "%1" == "VSSolution" (
if "!BUILD_ENVIRONMENT!" == "VS9" (
if "!ARCH!" == "amd64" (
set CMAKE_GENERATOR="Visual Studio 9 2008 Win64"
) else (
set CMAKE_GENERATOR="Visual Studio 9 2008"
)
) else if "!BUILD_ENVIRONMENT!" == "VS10" (
if "!ARCH!" == "amd64" (
set CMAKE_GENERATOR="Visual Studio 10 Win64"
) else (
set CMAKE_GENERATOR="Visual Studio 10"
)
) else if "!BUILD_ENVIRONMENT!" == "VS11" (
if "!ARCH!" == "amd64" (
set CMAKE_GENERATOR="Visual Studio 11 Win64"
) else if "!ARCH!" == "arm" (
set CMAKE_GENERATOR="Visual Studio 11 ARM"
) else (
set CMAKE_GENERATOR="Visual Studio 11"
)
) else if "!BUILD_ENVIRONMENT!" == "VS12" (
if "!ARCH!" == "amd64" (
set CMAKE_GENERATOR="Visual Studio 12 Win64"
) else if "!ARCH!" == "arm" (
set CMAKE_GENERATOR="Visual Studio 12 ARM"
) else (
set CMAKE_GENERATOR="Visual Studio 12"
)
)
) else (
set USE_VSCMD=1
echo This script defaults to Ninja. To use Visual Studio GUI specify "VSSolution" as a parameter.
)
) else (
echo Error: Unable to detect build environment. Configure script failure.
exit /b
)
:: Checkpoint
if not defined ARCH (
echo Unknown build architecture
exit /b
)
:: Detect VS command line generator
if %USE_VSCMD% == 1 (
if /I "%1" == "CodeBlocks" (
set CMAKE_GENERATOR="CodeBlocks - NMake Makefiles"
) else if /I "%1" == "Eclipse" (
set CMAKE_GENERATOR="Eclipse CDT4 - NMake Makefiles"
) else if /I "%1" == "Makefiles" (
set CMAKE_GENERATOR="NMake Makefiles"
) else (
set CMAKE_GENERATOR="Ninja"
)
)
:: Create directories
set REACTOS_OUTPUT_PATH=output-%BUILD_ENVIRONMENT%-%ARCH%
if "%REACTOS_SOURCE_DIR%" == "%CD%\" (
echo Creating directories in %REACTOS_OUTPUT_PATH%
if not exist %REACTOS_OUTPUT_PATH% (
mkdir %REACTOS_OUTPUT_PATH%
)
cd %REACTOS_OUTPUT_PATH%
)
if not exist host-tools (
mkdir host-tools
)
if not exist reactos (
mkdir reactos
)
echo Preparing host tools...
cd host-tools
if EXIST CMakeCache.txt (
del CMakeCache.txt /q
)
set REACTOS_BUILD_TOOLS_DIR=%CD%
:: Use x86 for ARM host tools
if "%ARCH%" == "arm" (
:: Launch new script instance for x86 host tools configuration
start "Preparing host tools for ARM cross build..." /I /B /WAIT %~dp0configure.cmd arm_hosttools "%VSINSTALLDIR%VC\vcvarsall.bat" %CMAKE_GENERATOR%
) else (
cmake -G %CMAKE_GENERATOR% -DARCH:STRING=%ARCH% "%REACTOS_SOURCE_DIR%"
)
cd..
echo Preparing reactos...
cd reactos
if EXIST CMakeCache.txt (
del CMakeCache.txt /q
)
if "%BUILD_ENVIRONMENT%" == "MinGW" (
cmake -G %CMAKE_GENERATOR% -DENABLE_CCACHE:BOOL=0 -DCMAKE_TOOLCHAIN_FILE:FILEPATH=toolchain-gcc.cmake -DARCH:STRING=%ARCH% -DREACTOS_BUILD_TOOLS_DIR:PATH="%REACTOS_BUILD_TOOLS_DIR%" "%REACTOS_SOURCE_DIR%"
) else if "%BUILD_ENVIRONMENT%" == "Clang" (
cmake -G %CMAKE_GENERATOR% -DENABLE_CCACHE:BOOL=0 -DCMAKE_TOOLCHAIN_FILE:FILEPATH=toolchain-clang.cmake -DARCH:STRING=%ARCH% -DREACTOS_BUILD_TOOLS_DIR:PATH="%REACTOS_BUILD_TOOLS_DIR%" "%REACTOS_SOURCE_DIR%"
) else (
cmake -G %CMAKE_GENERATOR% -DCMAKE_TOOLCHAIN_FILE:FILEPATH=toolchain-msvc.cmake -DARCH:STRING=%ARCH% -DREACTOS_BUILD_TOOLS_DIR:PATH="%REACTOS_BUILD_TOOLS_DIR%" "%REACTOS_SOURCE_DIR%"
)
cd..
echo Configure script complete^^! Enter directories and execute appropriate build commands (ex: ninja, make, nmake, etc...).
exit /b
:cmake_notfound
echo Unable to find cmake, if it is installed, check your PATH variable.
exit /b