1@echo off
2
3REM setup variables
4setlocal
5set WIN32_BUILD_PATH=build32
6if "%CMAKE_BUILD_TYPE%" == "" set CMAKE_BUILD_TYPE=Release
7if "%CMAKE_BUILD_TYPE%" == "Debug" set WIN32_BUILD_PATH=build32-debug
8set INSTALL_PATH=%1
9if "%INSTALL_PATH%" == "" set INSTALL_PATH=..\..\..\src\qtcreator-build\session
10
11if "%2" == "clean" rmdir /s /q %WIN32_BUILD_PATH%
12
13setlocal
14
15REM perform 32-bit build
16mkdir %WIN32_BUILD_PATH%
17cd %WIN32_BUILD_PATH%
18if exist CMakeCache.txt del CMakeCache.txt
19
20REM Build the project
21set VS_TOOLS="%ProgramFiles(x86)%\Microsoft Visual Studio\2017\BuildTools\Common7\Tools"
22if not exist %VS_TOOLS% set VS_TOOLS="%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Community\Common7\Tools"
23if not exist %VS_TOOLS% echo "Could not find VsDevCmd.bat. Please ensure Microsoft Visual Studio 2017 Build tools are installed." && exit /b 1
24
25pushd %VS_TOOLS%
26call VsDevCmd.bat -clean_env -no_logo || goto :error
27call VsDevCmd.bat -arch=x86 -startdir=none -host_arch=x86 -winsdk=10.0.17134.0 -no_logo || goto :error
28popd
29
30cmake -G "Ninja" ^
31      -DCMAKE_INSTALL_PREFIX:String=%INSTALL_PATH% ^
32      -DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE% ^
33      -DRSTUDIO_TARGET=SessionWin32 ^
34      -DRSTUDIO_PACKAGE_BUILD=1 ^
35      -DCMAKE_C_COMPILER=cl.exe ^
36      -DCMAKE_CXX_COMPILER=cl.exe ^
37      ..\..\.. || goto :error
38cmake --build . --config %CMAKE_BUILD_TYPE% --target install -- %MAKEFLAGS% || goto :error
39cd ..
40
41endlocal
42
43goto :EOF
44
45:error
46echo Failed to build 32bit components of RStudio! Error: %ERRORLEVEL%
47exit /b %ERRORLEVEL%
48