Skip to content

Commit

Permalink
Fix windows clean build (installs cmake if we need it).
Browse files Browse the repository at this point in the history
  • Loading branch information
lovettchris committed Apr 24, 2017
1 parent 3673979 commit bef8643
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 48 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -309,3 +309,6 @@ deps/
/AirLib/include/controllers/latex
/Eigen3
/AirLib/lib/libAirLib.a
/cmake-3.7.2-win64-x64
/cmake-3.7.2-win64-x64.zip
/3.3.2.zip
50 changes: 2 additions & 48 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -1,52 +1,6 @@
@echo off

setlocal
set ROOT_DIR=%CD%

git submodule update --init --recursive

WHERE cmake >nul 2>nul
IF %ERRORLEVEL% NEQ 0 (
echo cmake was not found! First install the latest version from https://cmake.org/.
goto :buildfailed
)

IF NOT EXIST external\rpclib\build mkdir external\rpclib\build
cd external\rpclib\build
cmake -G"Visual Studio 14 2015 Win64" ..
cmake --build .
cmake --build . --config Release
if ERRORLEVEL 1 goto :buildfailed
chdir /d %ROOT_DIR%

set RPCLIB_TARGET_LIB=AirLib\deps\rpclib\lib\x64
if NOT exist %RPCLIB_TARGET_LIB% mkdir %RPCLIB_TARGET_LIB%

set RPCLIB_TARGET_INCLUDE=AirLib\deps\rpclib\include
if NOT exist %RPCLIB_TARGET_INCLUDE% mkdir %RPCLIB_TARGET_INCLUDE%

robocopy /MIR external\rpclib\include %RPCLIB_TARGET_INCLUDE%
robocopy /MIR external\rpclib\build\output\lib %RPCLIB_TARGET_LIB%


msbuild /p:Platform=x64 /p:Configuration=Debug AirSim.sln
if ERRORLEVEL 1 goto :buildfailed
msbuild /p:Platform=x64 /p:Configuration=Release AirSim.sln
if ERRORLEVEL 1 goto :buildfailed

set MAVLINK_TARGET_LIB=AirLib\deps\MavLinkCom\lib
if NOT exist %MAVLINK_TARGET_LIB% mkdir %MAVLINK_TARGET_LIB%

set MAVLINK_TARGET_INCLUDE=AirLib\deps\MavLinkCom\include
if NOT exist %MAVLINK_TARGET_INCLUDE% mkdir %MAVLINK_TARGET_INCLUDE%

if NOT exist Unreal\Plugins\AirSim\Source\AirLib mkdir Unreal\Plugins\AirSim\Source\AirLib

robocopy /MIR MavLinkCom\include %MAVLINK_TARGET_INCLUDE%
robocopy /MIR MavLinkCom\lib %MAVLINK_TARGET_LIB%
robocopy /MIR AirLib Unreal\Plugins\AirSim\Source\AirLib /XD temp
goto :eof
powershell -f build.ps1

:buildfailed
chdir /d %ROOT_DIR%
echo #### Build failed
goto :eof
98 changes: 98 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@


function Get-ScriptDirectory
{
$Invocation = (Get-Variable MyInvocation -Scope 1).Value
Split-Path $Invocation.MyCommand.Path
}

$scriptDir = Get-ScriptDirectory
Set-Location -Path $scriptDir

function HttpGet($uri)
{
$rc = & $scriptDir\tools\httpget $uri;
echo "httpget returned $rc"
}
function Unzip($zipFile)
{
$rc = & $scriptDir\tools\unzip $zipFile;
echo "unzip returned $rc";
}
function UnzipToDir($zipFile, $dir)
{
echo "$scriptDir\tools\unzip $zipFile -d $dir"
$rc = & $scriptDir\tools\unzip $zipFile "-d" $dir
echo "unzip returned $rc";
}

function InstallCMake()
{
echo "Checking cmake install..."
if (-Not (Get-Command "cmake.exe" -ErrorAction SilentlyContinue))
{
if (-Not (Test-Path "$scriptDir\cmake-3.7.2-win64-x64")) {
HttpGet "https://cmake.org/files/v3.7/cmake-3.7.2-win64-x64.zip";
echo "Decompressing cmake...";
Unzip "cmake-3.7.2-win64-x64.zip";
Remove-Item cmake-3.7.2-win64-x64.zip;
}
$env:Path = "$env:Path;$scriptDir\cmake-3.7.2-win64-x64\bin\";
}
if (-Not (Get-Command "cmake.exe" -ErrorAction SilentlyContinue))
{
throw "Install cmake failed!!!"
}
}

$start = Get-Date
echo "======================= Build Started $start ====================";

git submodule update --init --recursive;
InstallCMake;

if (-Not (Test-Path "external\rpclib\build")) {
mkdir "external\rpclib\build"
}
Set-Location -Path "external\rpclib\build"

cmake -G"Visual Studio 14 2015 Win64" ..
cmake --build .
cmake --build . --config Release

Set-Location -Path $scriptDir

$env:RPCLIB_TARGET_LIB="AirLib\deps\rpclib\lib\x64";
if (-Not (Test-Path "$env:RPCLIB_TARGET_LIB")) {
mkdir $env:RPCLIB_TARGET_LIB
}
$env:RPCLIB_TARGET_INCLUDE="AirLib\deps\rpclib\include"
if (-Not (Test-Path "$env:RPCLIB_TARGET_INCLUDE")) {
mkdir $env:RPCLIB_TARGET_INCLUDE
}

robocopy /MIR external\rpclib\include $env:RPCLIB_TARGET_INCLUDE
robocopy /MIR external\rpclib\build\output\lib $env:RPCLIB_TARGET_LIB

msbuild /p:Platform=x64 /p:Configuration=Debug AirSim.sln
msbuild /p:Platform=x64 /p:Configuration=Release AirSim.sln

$env:MAVLINK_TARGET_LIB="AirLib\deps\MavLinkCom\lib"
if (-Not (Test-Path "$env:MAVLINK_TARGET_LIB")) {
mkdir $env:MAVLINK_TARGET_LIB
}
$env:MAVLINK_TARGET_INCLUDE="AirLib\deps\MavLinkCom\include"
if (-Not (Test-Path "$env:MAVLINK_TARGET_INCLUDE")) {
mkdir $env:MAVLINK_TARGET_INCLUDE
}
$env:UNREAL_AIRLIB_TARGET_DIR="Unreal\Plugins\AirSim\Source\AirLib"
if (-Not (Test-Path "$env:UNREAL_AIRLIB_TARGET_DIR")) {
mkdir "Unreal\Plugins\AirSim\Source\AirLib"
}
robocopy /MIR MavLinkCom\include $env:MAVLINK_TARGET_INCLUDE
robocopy /MIR MavLinkCom\lib $env:MAVLINK_TARGET_LIB
robocopy /MIR AirLib $env:UNREAL_AIRLIB_TARGET_DIR /XD temp

$end = Get-Date
$diff = $end - $start
echo "======================= Build Completed in $diff ====================";
Binary file added tools/HttpGet.exe
Binary file not shown.
Binary file added tools/unzip.exe
Binary file not shown.

0 comments on commit bef8643

Please sign in to comment.