Skip to content
This repository has been archived by the owner on May 3, 2021. It is now read-only.

Commit

Permalink
Adding "BuildOfficialDistribution.bat" batch script for generating of…
Browse files Browse the repository at this point in the history
…ficial Windows releases

* BuildOfficialDistribution.bat does the following:
  - Fully Builds Win32/x64 Debug/Release configurations
  - Generates distribution zip from the RELEASE|x64 configuration
* Updated GenerateProjectFiles_*.bat and InitialSetup_*.bat to handle error return codes
* Updated cmake install action in all cmake scripts to output to seperate debug and release folders
  • Loading branch information
HipsterSloth committed Aug 13, 2017
1 parent b8345bc commit fed2af3
Show file tree
Hide file tree
Showing 11 changed files with 398 additions and 60 deletions.
147 changes: 147 additions & 0 deletions BuildOfficialDistribution.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
@echo off
setlocal

::Select the path to the root Boost folder
if DEFINED BOOST_ROOT_PATH (goto build_thirdparty)
set "psCommand="(new-object -COM 'Shell.Application')^
.BrowseForFolder(0,'Please select the root folder for 64-bit Boost (ex: c:\local\boost_1_61_0).',0,0).self.path""
for /f "usebackq delims=" %%I in (`powershell %psCommand%`) do set "BOOST_ROOT_PATH=%%I"
if NOT DEFINED BOOST_ROOT_PATH (goto failure)

:: Cleanup any prior distribution folders
For /D %%D in ("PSMoveService_*") Do (
echo "Cleaning up old distro: %%~fD"
del /f /s /q "%%~fD" > nul
rmdir /s /q "%%~fD"
)

:: Generate the 32-bit project files and dependencies for PSMoveService
call InitialSetup_Win32.bat || goto failure
IF %ERRORLEVEL% NEQ 0 (
echo "Error setting up 32-bit PSMoveService project"
goto failure
)

:: Add MSVC build tools to the path
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86
IF %ERRORLEVEL% NEQ 0 (
echo "Unable to initialize 32-bit visual studio build environment"
goto failure
)

:: Compile and install the DEBUG|Win32 build of PSMoveService to the distribution folder
pushd build\
echo "Building PSMoveService DEBUG|Win32..."
MSBuild.exe opencv.vcxproj /p:configuration=DEBUG /p:Platform="Win32" /t:Build
IF %ERRORLEVEL% NEQ 0 (
echo "Error building OpenCV DEBUG|Win32!"
goto failure
)
MSBuild.exe PSMoveService.sln /p:configuration=DEBUG /p:Platform="Win32" /t:Build
IF %ERRORLEVEL% NEQ 0 (
echo "Error building PSMoveService DEBUG|Win32!"
goto failure
)
MSBuild.exe INSTALL.vcxproj /p:configuration=DEBUG /p:Platform="Win32" /t:Build
IF %ERRORLEVEL% NEQ 0 (
echo "Error deploying PSMoveService DEBUG|Win32 to distribution folder!"
goto failure
)

:: Compile and install the RELEASE|Win32 build of PSMoveService to the distribution folder
echo "Building PSMoveService RELEASE|Win32..."
MSBuild.exe opencv.vcxproj /p:configuration=RELEASE /p:Platform="Win32" /t:Build
IF %ERRORLEVEL% NEQ 0 (
echo "Error building OpenCV RELEASE|Win32!"
goto failure
)
MSBuild.exe PSMoveService.sln /p:configuration=RELEASE /p:Platform="Win32" /t:Build
IF %ERRORLEVEL% NEQ 0 (
echo "Error building PSMoveService RELEASE|Win32!"
goto failure
)
MSBuild.exe INSTALL.vcxproj /p:configuration=RELEASE /p:Platform="Win32" /t:Build
IF %ERRORLEVEL% NEQ 0 (
echo "Error deploying PSMoveService RELEASE|Win32 to distribution folder!"
goto failure
)
popd

:: Generate the 64-bit project files and dependencies for PSMoveService
call InitialSetup_X64.bat || goto failure
IF %ERRORLEVEL% NEQ 0 (
echo "Error setting up 64-bit PSMoveService project"
goto failure
)

:: Add MSVC build tools to the path
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
IF %ERRORLEVEL% NEQ 0 (
echo "Unable to initialize 64-bit visual studio build environment"
goto failure
)

:: Compile and install the DEBUG|x64 build of PSMoveService to the distribution folder
pushd build\
echo "Building PSMoveService DEBUG|x64..."
MSBuild.exe opencv.vcxproj /p:configuration=DEBUG /p:Platform="x64" /t:Build
IF %ERRORLEVEL% NEQ 0 (
echo "Error building OpenCV DEBUG|x64!"
goto failure
)
MSBuild.exe PSMoveService.sln /p:configuration=DEBUG /p:Platform="x64" /t:Build
IF %ERRORLEVEL% NEQ 0 (
echo "Error building PSMoveService DEBUG|x64!"
goto failure
)
MSBuild.exe INSTALL.vcxproj /p:configuration=DEBUG /p:Platform="x64" /t:Build
IF %ERRORLEVEL% NEQ 0 (
echo "Error deploying PSMoveService DEBUG|x64 to distribution folder!"
goto failure
)

:: Compile and install the RELEASE|x64 build of PSMoveService to the distribution folder
echo "Building PSMoveService RELEASE|x64..."
MSBuild.exe opencv.vcxproj /p:configuration=RELEASE /p:Platform="x64" /t:Build
IF %ERRORLEVEL% NEQ 0 (
echo "Error building OpenCV RELEASE|x64!"
goto failure
)
MSBuild.exe PSMoveService.sln /p:configuration=RELEASE /p:Platform="x64" /t:Build
IF %ERRORLEVEL% NEQ 0 (
echo "Error building PSMoveService RELEASE|x64!"
goto failure
)
MSBuild.exe INSTALL.vcxproj /p:configuration=RELEASE /p:Platform="x64" /t:Build
IF %ERRORLEVEL% NEQ 0 (
echo "Error deploying PSMoveService RELEASE|x64 to distribution folder!"
goto failure
)
popd

:: Find the distribution folder
For /D %%D in ("PSMoveService_*") Do (
set "DISTRIBUTION_LABEL=%%~fD"
)
if NOT DEFINED DISTRIBUTION_LABEL (
echo "Failed to find the distribution folder generated from the builds!"
goto failure
)

:: Create the distribution zip from the Release|x64 folder
set "DISTRIBUTION_FOLDER=%DISTRIBUTION_LABEL%\Win64\Release"
set "DISTRIBUTION_ZIP=%DISTRIBUTION_LABEL%.zip"
echo "Creating distribution zip (%DISTRIBUTION_ZIP%) from: %DISTRIBUTION_FOLDER%"
powershell -nologo -noprofile -command "& { Add-Type -A 'System.IO.Compression.FileSystem'; [IO.Compression.ZipFile]::CreateFromDirectory('%DISTRIBUTION_FOLDER%', '%DISTRIBUTION_ZIP%'); }"
IF %ERRORLEVEL% NEQ 0 (
echo "Failed to generate the distribution zip!"
goto failure
)

echo "Successfully created distribution zip: %DISTRIBUTION_ZIP%"
pause
EXIT /B 0

:failure
pause
EXIT /B 1
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ include(cmake/Environment.cmake)
include(cmake/Version.cmake)

set(PSM_PROJECT_NAME "PSMoveService_${PSM_VERSION_STRING}")
set(PSM_DEBUG_INSTALL_PATH "${ROOT_DIR}/${PSM_PROJECT_NAME}/${ARCH_LABEL}/Debug")
set(PSM_RELEASE_INSTALL_PATH "${ROOT_DIR}/${PSM_PROJECT_NAME}/${ARCH_LABEL}/Release")

include(cmake/ThirdParty.cmake)

Expand Down
11 changes: 10 additions & 1 deletion GenerateProjectFiles_Win32.bat
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,13 @@ cd build

echo "Rebuilding PSMoveService Project files..."
cmake .. -G "Visual Studio 14 2015" -DBOOST_ROOT=%BOOST_ROOT_PATH% -DBOOST_LIBRARYDIR=%BOOST_LIB_PATH% -DPROTOBUF_SRC_ROOT_FOLDER=..\thirdparty\protobuf
pause
IF %ERRORLEVEL% NEQ 0 (
echo "Error generating PSMoveService 32-bit project files"
goto failure
)

EXIT /B 0

:failure
pause
EXIT /B 1
11 changes: 10 additions & 1 deletion GenerateProjectFiles_X64.bat
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,13 @@ cd build

echo "Rebuilding PSMoveService x64 Project files..."
cmake .. -G "Visual Studio 14 2015 Win64" -DOpenCV_DIR=%OPENCV_BUILD_PATH% -DBOOST_ROOT=%BOOST_ROOT_PATH% -DBOOST_LIBRARYDIR=%BOOST_LIB_PATH% -DPROTOBUF_SRC_ROOT_FOLDER=..\thirdparty\protobuf
pause
IF %ERRORLEVEL% NEQ 0 (
echo "Error generating PSMoveService 64-bit project files"
goto failure
)

EXIT /B 0

:failure
pause
EXIT /B 1
62 changes: 52 additions & 10 deletions InitialSetup_Win32.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ del /f /s /q deps > nul
rmdir /s /q deps
)


::Select the path to the root Boost folder
if DEFINED BOOST_ROOT_PATH (goto build_thirdparty)
set "psCommand="(new-object -COM 'Shell.Application')^
.BrowseForFolder(0,'Please select the root folder for Boost (ex: c:\local\boost_1_61_0).',0,0).self.path""
.BrowseForFolder(0,'Please select the root folder for 32-bit Boost (ex: c:\local\boost_1_61_0).',0,0).self.path""
for /f "usebackq delims=" %%I in (`powershell %psCommand%`) do set "BOOST_ROOT_PATH=%%I"
if NOT DEFINED BOOST_ROOT_PATH (goto failure)

Expand All @@ -25,8 +27,14 @@ echo @echo off >> SetBuildVars_Win32.bat
echo set BOOST_ROOT_PATH=%BOOST_ROOT_PATH% >> SetBuildVars_Win32.bat
echo set BOOST_LIB_PATH=%BOOST_ROOT_PATH%/lib32-msvc-14.0 >> SetBuildVars_Win32.bat

:build_thirdparty

:: Add MSVC build tools to the path
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86
IF %ERRORLEVEL% NEQ 0 (
echo "Unable to initialize 32-bit visual studio build environment"
goto failure
)

:: Compile the DEBUG|Win32 and RELEASE|Win32 builds of protobuf
echo "Creating protobuf project files..."
Expand All @@ -37,18 +45,38 @@ mkdir vsprojects
pushd vsprojects
cmake -G "Visual Studio 14 2015" -Dprotobuf_DEBUG_POSTFIX="" -Dprotobuf_BUILD_TESTS=OFF ../cmake
echo "Building protobuf DEBUG|Win32"
IF %ERRORLEVEL% NEQ 0 (
echo "Error generating protobuf project files!"
goto failure
)
MSBuild.exe protobuf.sln /p:configuration=DEBUG /t:Clean;Build
IF %ERRORLEVEL% NEQ 0 (
echo "Error building protobuf DEBUG|Win32!"
goto failure
)
echo "Building protobuf RELEASE|Win32"
MSBuild.exe protobuf.sln /p:configuration=RELEASE /t:Clean;Build
IF %ERRORLEVEL% NEQ 0 (
echo "Error building protobuf Release|Win64!"
goto failure
)
popd
popd

:: Compile the DEBUG|Win32 and RELEASE|Win32 builds of libusb
pushd thirdparty\libusb\msvc\
echo "Building libusb DEBUG|Win32..."
MSBuild.exe libusb_2015.sln /p:configuration=DEBUG /p:Platform="Win32" /t:Clean;Build
MSBuild.exe libusb_2015.sln /p:configuration=DEBUG /p:Platform="Win32" /t:Clean;Build
IF %ERRORLEVEL% NEQ 0 (
echo "Error building libusb DEBUG|Win32!"
goto failure
)
echo "Building libusb RELEASE|Win32..."
MSBuild.exe libusb_2015.sln /p:configuration=RELEASE /p:Platform="Win32" /t:Clean;Build
IF %ERRORLEVEL% NEQ 0 (
echo "Error building libusb RELEASE|Win32!"
goto failure
)
popd

:: Compile the RELEASE|Win32 build of SDL2
Expand All @@ -59,20 +87,34 @@ rmdir /s /q build
mkdir build
pushd build
cmake .. -G "Visual Studio 14 2015" -DDIRECTX=OFF -DDIRECTX=OFF -DSDL_STATIC=ON -DFORCE_STATIC_VCRT=ON -DEXTRA_CFLAGS="-MT -Z7 -DSDL_MAIN_HANDLED -DWIN32 -DNDEBUG -D_CRT_SECURE_NO_WARNINGS -DHAVE_LIBC -D_USE_MATH_DEFINES
IF %ERRORLEVEL% NEQ 0 (
echo "Error generating SDL2 project files!"
goto failure
)

echo "Building SDL2 Release|Win32..."
MSBuild.exe SDL2.sln /p:configuration=RELEASE /p:Platform="Win32" /t:Clean
MSBuild.exe SDL2-static.vcxproj /p:configuration=RELEASE /p:Platform="Win32" /t:Build
IF %ERRORLEVEL% NEQ 0 (
echo "Error building SDL2 Release|Win32!"
goto failure
)
MSBuild.exe SDL2-static.vcxproj /p:configuration=RELEASE /p:Platform="Win32" /t:Build
IF %ERRORLEVEL% NEQ 0 (
echo "Error building SDL2-static Release|Win32!"
goto failure
)
MSBuild.exe SDL2main.vcxproj /p:configuration=RELEASE /p:Platform="Win32" /t:Build
IF %ERRORLEVEL% NEQ 0 (
echo "Error building SDL2main Release|Win32!"
goto failure
)
popd
popd

:: Generate the project files for PSMoveService
call GenerateProjectFiles_Win32.bat
pause
goto exit
call GenerateProjectFiles_Win32.bat || goto failure
EXIT /B 0

:failure
goto exit

:exit
endlocal
pause
EXIT /B 1
Loading

0 comments on commit fed2af3

Please sign in to comment.