From 21074a2dd360cc333ad93bc9d86f80f3bf4bb9ad Mon Sep 17 00:00:00 2001 From: Hiroshi Takeda Date: Mon, 8 Jan 2018 17:48:12 +0900 Subject: [PATCH] build on macOS High Sierra with Unreal Engine 4.16 --- .gitignore | 24 ++++++++++++- AirLib/src/api/RpcLibClientBase.cpp | 3 ++ .../src/vehicles/car/api/CarRpcLibClient.cpp | 3 ++ .../multirotor/api/MultirotorRpcLibClient.cpp | 3 ++ .../Blocks/GenerateProjectFiles.sh | 27 +++++++++++++++ build.sh | 9 +++-- install_run_all.sh | 34 ++++++------------- setup.sh | 32 +++++++++++++---- 8 files changed, 102 insertions(+), 33 deletions(-) create mode 100755 Unreal/Environments/Blocks/GenerateProjectFiles.sh mode change 100644 => 100755 install_run_all.sh diff --git a/.gitignore b/.gitignore index 413517e601..5b5783d0c7 100644 --- a/.gitignore +++ b/.gitignore @@ -323,4 +323,26 @@ deps/ car_assets.zip /PythonClient/cloud.txt __pycache__/ -/PythonClient/metrics/ \ No newline at end of file +/PythonClient/metrics/ + +### Xcode ### +build/ +DerivedData/ +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata/ +*.moved-aside +*.xccheckout +*.xcscmblueprint +*.xcworkspacedata +*.xcodeproj/* +!*.xcodeproj/project.pbxproj +!*.xcodeproj/xcshareddata/ +!*.xcworkspace/contents.xcworkspacedata +/*.gcno diff --git a/AirLib/src/api/RpcLibClientBase.cpp b/AirLib/src/api/RpcLibClientBase.cpp index 80f13cd393..00e5fa4576 100644 --- a/AirLib/src/api/RpcLibClientBase.cpp +++ b/AirLib/src/api/RpcLibClientBase.cpp @@ -19,6 +19,9 @@ STRICT_MODE_OFF #define RPCLIB_MSGPACK clmdep_msgpack #endif // !RPCLIB_MSGPACK #undef check +#ifdef nil +#undef nil +#endif // nil #include "rpc/client.h" #include "api/RpcLibAdapatorsBase.hpp" STRICT_MODE_ON diff --git a/AirLib/src/vehicles/car/api/CarRpcLibClient.cpp b/AirLib/src/vehicles/car/api/CarRpcLibClient.cpp index 7ff049fc02..4b7801e104 100644 --- a/AirLib/src/vehicles/car/api/CarRpcLibClient.cpp +++ b/AirLib/src/vehicles/car/api/CarRpcLibClient.cpp @@ -17,6 +17,9 @@ STRICT_MODE_OFF #define RPCLIB_MSGPACK clmdep_msgpack #endif // !RPCLIB_MSGPACK #undef check +#ifdef nil +#undef nil +#endif // nil #include "rpc/client.h" #include "vehicles/car/api/CarRpcLibAdapators.hpp" STRICT_MODE_ON diff --git a/AirLib/src/vehicles/multirotor/api/MultirotorRpcLibClient.cpp b/AirLib/src/vehicles/multirotor/api/MultirotorRpcLibClient.cpp index b9ef9440bb..c152a87ab5 100644 --- a/AirLib/src/vehicles/multirotor/api/MultirotorRpcLibClient.cpp +++ b/AirLib/src/vehicles/multirotor/api/MultirotorRpcLibClient.cpp @@ -16,6 +16,9 @@ STRICT_MODE_OFF #define RPCLIB_MSGPACK clmdep_msgpack #endif // !RPCLIB_MSGPACK #undef check +#ifdef nil +#undef nil +#endif // nil #include "rpc/client.h" #include "vehicles/multirotor/api/MultirotorRpcLibAdapators.hpp" STRICT_MODE_ON diff --git a/Unreal/Environments/Blocks/GenerateProjectFiles.sh b/Unreal/Environments/Blocks/GenerateProjectFiles.sh new file mode 100755 index 0000000000..8617ede302 --- /dev/null +++ b/Unreal/Environments/Blocks/GenerateProjectFiles.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +set -x +set -e + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +pushd "$SCRIPT_DIR" >/dev/null + +UnrealDir=$1 +if [[ ! -e "$UnrealDir" ]]; then + # UnrealDir variable must be set like '/Users/Shared/Epic\ Games/UE_4.16' + echo "UnrealDir is not set." + exit 1 +fi + +if [ "$(uname)" == "Darwin" ]; then + # Call UnrealEngine shell scrpit + pushd "$UnrealDir/Engine/Build/BatchFiles/Mac/" >/dev/null + ./GenerateProjectFiles.sh "$SCRIPT_DIR/Blocks.uproject" + popd >/dev/null +else + echo "Not implemented" + exit 1 +fi + +popd >/dev/null +set +x diff --git a/build.sh b/build.sh index fb398021b7..14227fdb25 100755 --- a/build.sh +++ b/build.sh @@ -18,8 +18,13 @@ if [[ !(-d "./llvm-build/output/lib") ]]; then fi # set up paths of clang compiler -export CC="clang-3.9" -export CXX="clang++-3.9" +if [ "$(uname)" == "Darwin" ]; then + export CC=/usr/local/opt/llvm\@3.9/bin/clang + export CXX=/usr/local/opt/llvm\@3.9/bin/clang++ +else + export CC="clang-3.9" + export CXX="clang++-3.9" +fi #install EIGEN library if [[ !(-d "./AirLib/deps/eigen3/Eigen") ]]; then diff --git a/install_run_all.sh b/install_run_all.sh old mode 100644 new mode 100755 index d659e327de..a7c710527e --- a/install_run_all.sh +++ b/install_run_all.sh @@ -9,28 +9,10 @@ set -x #confirm unreal install directory UnrealDir=$1 -if [[ !(-z "UnrealDir") ]]; then - UnrealDir="$SCRIPT_DIR/UnrealEngine" -fi - -read -p "Unreal will be installed in $UnrealDir. To change it invoke script with path argument. Continue? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - popd >/dev/null - exit 0 -fi - -#install unreal -if [[ !(-d "$UnrealDir") ]]; then - git clone -b 4.17 https://github.com/EpicGames/UnrealEngine.git "$UnrealDir" - pushd "$UnrealDir" >/dev/null - - ./Setup.sh - ./GenerateProjectFiles.sh - make - - popd >/dev/null +if [[ -z "$UnrealDir" ]]; then + # UnrealDir variable must be set like '/Users/Shared/Epic\ Games/UE_4.16' + echo "UnrealDir is not set." + exit 1 fi #install airsim @@ -39,7 +21,11 @@ fi #start Unreal editor with Blocks project pushd "$UnrealDir" >/dev/null -Engine/Binaries/Linux/UE4Editor "$SCRIPT_DIR/AirSim/Unreal/Environments/Blocks/Blocks.uproject" -game -log +if [ "$(uname)" == "Darwin" ]; then + Engine/Binaries/Mac/UE4Editor.app/Contents/MacOS/UE4Editor "$SCRIPT_DIR/Unreal/Environments/Blocks/Blocks.uproject" -game -log +else + Engine/Binaries/Linux/UE4Editor "$SCRIPT_DIR/Unreal/Environments/Blocks/Blocks.uproject" -game -log +fi popd >/dev/null -popd >/dev/null \ No newline at end of file +popd >/dev/null diff --git a/setup.sh b/setup.sh index ffcdb1e1fb..a8e93a099f 100755 --- a/setup.sh +++ b/setup.sh @@ -24,7 +24,13 @@ if [ "$(uname)" == "Darwin" ]; then #below takes way too long # brew install llvm@3.9 - brew install --force-bottle homebrew/versions/llvm39 + brew install --force-bottle llvm@3.9 + + brew install wget + brew install cmake + + export C_COMPILER=/usr/local/opt/llvm\@3.9/bin/clang + export COMPILER=/usr/local/opt/llvm\@3.9/bin/clang++ else if [[ ! -z "${whoami}" ]]; then #this happens when running in travis sudo /usr/sbin/useradd -G dialout $USER @@ -37,6 +43,9 @@ else wget -O - http://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add - sudo apt-get update sudo apt-get install -y clang-3.9 clang++-3.9 + + export C_COMPILER=clang-3.9 + export COMPILER=clang++-3.9 fi # Download high-polycount SUV model @@ -84,12 +93,14 @@ else fi #build libc++ -sudo rm -rf llvm-build +if [ "$(uname)" == "Darwin" ]; then + rm -rf llvm-build +else + sudo rm -rf llvm-build +fi mkdir -p llvm-build pushd llvm-build >/dev/null -export C_COMPILER=clang-3.9 -export COMPILER=clang++-3.9 cmake -DCMAKE_C_COMPILER=${C_COMPILER} -DCMAKE_CXX_COMPILER=${COMPILER} \ -LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF -DLIBCXX_INSTALL_EXPERIMENTAL_LIBRARY=OFF \ @@ -99,12 +110,21 @@ cmake -DCMAKE_C_COMPILER=${C_COMPILER} -DCMAKE_CXX_COMPILER=${COMPILER} \ make cxx #install libc++ locally in output folder -sudo make install-libcxx install-libcxxabi +if [ "$(uname)" == "Darwin" ]; then + make install-libcxx install-libcxxabi +else + sudo make install-libcxx install-libcxxabi +fi popd >/dev/null #install EIGEN library -sudo rm -rf ./AirLib/deps/eigen3/Eigen + +if [ "$(uname)" == "Darwin" ]; then + rm -rf ./AirLib/deps/eigen3/Eigen +else + sudo rm -rf ./AirLib/deps/eigen3/Eigen +fi echo "downloading eigen..." wget http://bitbucket.org/eigen/eigen/get/3.3.2.zip unzip 3.3.2.zip -d temp_eigen