From 60a45ab6a51a19ce596b0117703348f49048ed90 Mon Sep 17 00:00:00 2001 From: Shital Shah Date: Fri, 19 Jan 2018 23:38:56 -0800 Subject: [PATCH] remove, rpclib as submodule, download from git release, cmake install enhancements --- .gitmodules | 3 - DroneServer/main.cpp | 2 +- build.cmd | 86 ++++++++++++++++++++--------- build.sh | 5 +- check_cmake.bat | 49 ++++++++++++++++ cmake/rpclib_wrapper/CMakeLists.txt | 2 +- external/rpclib | 1 - 7 files changed, 112 insertions(+), 36 deletions(-) create mode 100644 check_cmake.bat delete mode 160000 external/rpclib diff --git a/.gitmodules b/.gitmodules index 0ba865db7a..e69de29bb2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "external/rpclib"] - path = external/rpclib - url = https://github.com/rpclib/rpclib.git diff --git a/DroneServer/main.cpp b/DroneServer/main.cpp index 5040077d7c..de3db9f0ca 100644 --- a/DroneServer/main.cpp +++ b/DroneServer/main.cpp @@ -68,7 +68,7 @@ int main(int argc, const char* argv[]) } else { - std::cout << "Could not load settings from " << Settings::singleton().getFileName() << std::endl; + std::cout << "Could not load settings from " << Settings::singleton().getFullFilePath() << std::endl; return 3; } diff --git a/build.cmd b/build.cmd index 30627c4ed5..de1cfbef87 100644 --- a/build.cmd +++ b/build.cmd @@ -11,17 +11,68 @@ if "%1"=="--no-full-poly-car" set "noFullPolyCar=y" :noargs -REM //---------- make sure we have got all sub modules ---------- chdir /d %ROOT_DIR% -ECHO Updating submodules... -git submodule update --init --recursive -REM //---------- if cmake doesn't exist then install it ---------- -WHERE cmake >nul 2>nul -IF %ERRORLEVEL% NEQ 0 ( - call :installcmake +REM //---------- Check cmake version ---------- +CALL check_cmake.bat +if ERRORLEVEL 1 ( + CALL check_cmake.bat + if ERRORLEVEL 1 ( + echo( + echo ERROR: cmake was not installed correctly. + goto :buildfailed + ) ) +REM //---------- get rpclib ---------- +IF NOT EXIST external\rpclib mkdir external\rpclib +IF NOT EXIST external\rpclib\rpclib-2.2.1 ( + REM //leave some blank lines because powershell shows download banner at top of console + ECHO( + ECHO( + ECHO( + ECHO ***************************************************************************************** + ECHO Downloading rpclib + ECHO ***************************************************************************************** + @echo on + powershell -command "& { iwr https://github.com/rpclib/rpclib/archive/v2.2.1.zip -OutFile external\rpclib.zip }" + @echo off + + REM //remove any previous versions + rmdir external\rpclib /q /s + + powershell -command "& { Expand-Archive -Path external\rpclib.zip -DestinationPath external\rpclib }" + del external\rpclib.zip /q + + REM //Don't fail the build if the high-poly car is unable to be downloaded + REM //Instead, just notify users that the gokart will be used. + IF NOT EXIST external\rpclib\rpclib-2.2.1 ( + ECHO Unable to download high-polycount SUV. Your AirSim build will use the default vehicle. + goto :buildfailed + ) +) + +REM //---------- Build rpclib ------------ +ECHO Starting cmake to build rpclib... +IF NOT EXIST external\rpclib\rpclib-2.2.1\build mkdir external\rpclib\rpclib-2.2.1\build +cd external\rpclib\rpclib-2.2.1\build +REM cmake -G"Visual Studio 15 2017 Win64" .. +cmake -G"Visual Studio 14 2015 Win64" .. +cmake --build . +cmake --build . --config Release +if ERRORLEVEL 1 goto :buildfailed +chdir /d %ROOT_DIR% + + +REM //---------- copy rpclib binaries and include folder inside AirLib folder ---------- +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\rpclib-2.2.1\include %RPCLIB_TARGET_INCLUDE% +robocopy /MIR external\rpclib\rpclib-2.2.1\build\Debug %RPCLIB_TARGET_LIB%\Debug +robocopy /MIR external\rpclib\rpclib-2.2.1\build\Release %RPCLIB_TARGET_LIB%\Release + REM //---------- get High PolyCount SUV Car Model ------------ IF NOT EXIST Unreal\Plugins\AirSim\Content\VehicleAdv mkdir Unreal\Plugins\AirSim\Content\VehicleAdv IF NOT EXIST Unreal\Plugins\AirSim\Content\VehicleAdv\SUV\v1.1.7 ( @@ -67,24 +118,6 @@ IF NOT EXIST AirLib\deps\eigen3 ( ) IF NOT EXIST AirLib\deps\eigen3 goto :buildfailed -ECHO Starting cmake... -REM //---------- compile rpclib that we got from git submodule ---------- -IF NOT EXIST external\rpclib\build mkdir external\rpclib\build -cd external\rpclib\build -REM cmake -G"Visual Studio 15 2017 Win64" .. -cmake -G"Visual Studio 14 2015 Win64" .. -cmake --build . -cmake --build . --config Release -if ERRORLEVEL 1 goto :buildfailed -chdir /d %ROOT_DIR% - -REM //---------- copy rpclib binaries and include folder inside AirLib folder ---------- -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% REM //---------- now we have all dependencies to compile AirSim.sln which will also compile MavLinkCom ---------- msbuild /p:Platform=x64 /p:Configuration=Debug AirSim.sln @@ -109,7 +142,8 @@ goto :eof :buildfailed chdir /d %ROOT_DIR% -echo #### Build failed 1>&2 +echo( +echo #### Build failed - see messages above. 1>&2 goto :eof :installcmake diff --git a/build.sh b/build.sh index 14227fdb25..a03a8acd6c 100755 --- a/build.sh +++ b/build.sh @@ -7,9 +7,6 @@ pushd "$SCRIPT_DIR" >/dev/null set -e set -x -# update any git submodules, currently rpclib -git submodule update --init --recursive - # check for libc++ if [[ !(-d "./llvm-build/output/lib") ]]; then echo "ERROR: clang++ and libc++ is necessary to compile AirSim and run it in Unreal engine" @@ -71,7 +68,7 @@ cp $build_dir/output/lib/libAirSim-rpclib.a AirLib/deps/rpclib/lib/librpc.a # Update AirLib/lib, AirLib/deps, Plugins folders with new binaries rsync -a --delete $build_dir/output/lib/ AirLib/lib/x64/Debug -rsync -a --delete external/rpclib/include AirLib/deps/rpclib +rsync -a --delete external/rpclib/rpclib-2.2.1/include AirLib/deps/rpclib rsync -a --delete MavLinkCom/include AirLib/deps/MavLinkCom rsync -a --delete AirLib Unreal/Plugins/AirSim/Source diff --git a/check_cmake.bat b/check_cmake.bat new file mode 100644 index 0000000000..e998c6cbdc --- /dev/null +++ b/check_cmake.bat @@ -0,0 +1,49 @@ +@echo off +REM //---------- set up variable ---------- +setlocal +set ROOT_DIR=%~dp0 + +set cmake_minversion_minmaj=" 3. 9" + +set "cmake_version= . " + +where /q cmake +if %ERRORLEVEL% EQU 0 ( + for /F "tokens=3" %%a in ('cmake --version ^| find "cmake version"') do set cmake_version=%%a + if "%cmake_version%" == "" ( + echo Unable to get version of cmake. >&2 + exit /b 2 + ) +) else ( + echo cmake was not found in path. + goto :download_install +) + +set cmake_ver_major= +set cmake_ver_minor= +for /F "tokens=1,2 delims=." %%a in ("%cmake_version%") do ( + set "cmake_ver_major= %%a" + set "cmake_ver_minor= %%b" +) +set cmake_ver_minmaj="%cmake_ver_major:~-4%.%cmake_ver_minor:~-4%" +if %cmake_ver_minmaj% LSS %cmake_minversion_minmaj% ( + echo( + echo Newer AirSim requires cmake verion %cmake_minversion_minmaj% but you have %cmake_ver_minmaj% which is older. >&2 + goto :download_install +) + +echo Found cmake version: %cmake_version% +exit /b 0 + +:download_install +set /p choice="Press any key to download and install cmake (make sure to add it in path in install options)" + +IF NOT EXIST %temp%\cmake-3.10.2-win64-x64.msi ( + @echo on + powershell -command "& { iwr https://cmake.org/files/v3.10/cmake-3.10.2-win64-x64.msi -OutFile %temp%\cmake-3.10.2-win64-x64.msi }" + @echo off +) + +msiexec.exe /i "%temp%\cmake-3.10.2-win64-x64.msi" + +exit /b 1 \ No newline at end of file diff --git a/cmake/rpclib_wrapper/CMakeLists.txt b/cmake/rpclib_wrapper/CMakeLists.txt index 88946035bf..43261bd011 100644 --- a/cmake/rpclib_wrapper/CMakeLists.txt +++ b/cmake/rpclib_wrapper/CMakeLists.txt @@ -10,4 +10,4 @@ IF(UNIX) set(CMAKE_CXX_FLAGS "${RPC_LIB_DEFINES} ${CMAKE_CXX_FLAGS}") ENDIF() -add_subdirectory("${AIRSIM_ROOT}/external/rpclib" "${CMAKE_CURRENT_BINARY_DIR}/rpclib") \ No newline at end of file +add_subdirectory("${AIRSIM_ROOT}/external/rpclib/rpclib-2.2.1" "${CMAKE_CURRENT_BINARY_DIR}/rpclib") \ No newline at end of file diff --git a/external/rpclib b/external/rpclib deleted file mode 160000 index 9885c01db6..0000000000 --- a/external/rpclib +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 9885c01db61c6defd412b0c08602d9af5ddf2633