Skip to content

Commit

Permalink
resolved merge conflict with PR43
Browse files Browse the repository at this point in the history
  • Loading branch information
sytelus committed Feb 25, 2017
2 parents 485483d + 9df1c4b commit d5ac3dc
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 17 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Expand Up @@ -288,4 +288,8 @@ deps/
# Eclipse Project file
/.project
/.cproject
/.settings
/.settings

/boost
/eigen
/build_debug
39 changes: 24 additions & 15 deletions Unreal/Plugins/AirSim/Source/AirSim.Build.cs
Expand Up @@ -35,6 +35,7 @@ private void SetupCompileMode(CompileMode mode, TargetInfo Target)
case CompileMode.HeaderOnlyWithRpc:
Definitions.Add("AIRLIB_HEADER_ONLY=1");
AddLibDependency("AirLib", Path.Combine(AirSimPath, "lib"), "AirLib", Target, false);
LoadAirSimDependency(Target, "rpclib", "rpc");
break;
case CompileMode.CppCompileNoRpc:
LoadAirSimDependency(Target, "MavLinkCom", "MavLinkCom");
Expand Down Expand Up @@ -63,7 +64,7 @@ public AirSim(TargetInfo Target)
AddEigenDependency();
PrivateIncludePaths.Add(Path.Combine(AirSimPath, "include"));
AddOSLibDependencies(Target);
AddBoostDependency();
AddBoostDependency(Target);
LoadAirSimDependency(Target, "MavLinkCom", "MavLinkCom");

SetupCompileMode(CompileMode.HeaderOnlyWithRpc, Target);
Expand All @@ -89,29 +90,35 @@ private void AddOSLibDependencies(TargetInfo Target)
}
}

private void AddBoostDependency()
private void AddBoostDependency(TargetInfo Target)
{
string boost = System.Environment.GetEnvironmentVariable("BOOST_ROOT");
if (string.IsNullOrEmpty(boost) || !System.IO.Directory.Exists(boost))
{
throw new System.Exception("BOOST_ROOT is not defined, or points to a non-existant directory, please set this environment variable. " +
"See: " + readmurl);
}
string lib = Path.Combine(boost, "stage", "lib");
if (!System.IO.Directory.Exists(lib))
{
throw new System.Exception("Please build boost and make sure the libraries are at " + lib + ". " +
"See: " + readmurl);
}

bool found = System.IO.Directory.GetFiles(lib, "libboost_system-*.lib").Length > 0;
if (!found)
{
throw new System.Exception("Not finding libboost_system-*.lib in " + lib + ". " +
"See: " + readmurl);
if (Target.Platform == UnrealTargetPlatform.Linux) {
string lib = Path.Combine(boost, "lib");
PublicAdditionalLibraries.Add(Path.Combine(lib, "libboost_system.a"));
PublicAdditionalLibraries.Add(Path.Combine(lib, "libboost_filesystem.a"));
} else {
string lib = Path.Combine(boost, "stage", "lib");
if (!System.IO.Directory.Exists(lib))
{
throw new System.Exception("Please build boost and make sure the libraries are at " + lib + ". " +
"See: " + readmurl);
}

bool found = System.IO.Directory.GetFiles(lib, "libboost_system-*.lib").Length > 0;
if (!found)
{
throw new System.Exception("Not finding libboost_system-*.lib in " + lib + ". " +
"See: " + readmurl);
}
PublicLibraryPaths.Add(Path.Combine(lib));
}

PublicLibraryPaths.Add(Path.Combine(lib));
}


Expand All @@ -133,6 +140,8 @@ private bool AddLibDependency(string LibName, string LibPath, string LibFileName
isLibrarySupported = true;

PublicAdditionalLibraries.Add(Path.Combine(LibPath, PlatformString, ConfigurationString, LibFileName + ".lib"));
} else if (Target.Platform == UnrealTargetPlatform.Linux) {
PublicAdditionalLibraries.Add(Path.Combine(LibPath, "lib" + LibFileName + ".a"));
}

if (isLibrarySupported && IsAddLibInclude)
Expand Down
86 changes: 86 additions & 0 deletions build.sh
@@ -0,0 +1,86 @@
#! /bin/bash

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPT_DIR"

set -e

# we need to use clang because the Unreal Engine is built with clang as well and
# there are some symbol inconsistencies in the C++ library with regard to C++11
# (see GCC Dual ABI: # https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html)
export CC=/usr/bin/clang
export CXX=/usr/bin/clang++


if [[ ! -d eigen ]]; then
echo "downloading eigen..."
wget http://bitbucket.org/eigen/eigen/get/3.3.2.zip
unzip 3.3.2.zip -d eigen
pushd eigen
mv eigen* eigen3
echo "3.3.2" > version
popd &>/dev/null
rm 3.3.2.zip
fi
export EIGEN_ROOT="$(pwd)/eigen"


boost_dir="$(pwd)/boost/boost_1_63_0"
# get & build boost
if [[ ! -d boost ]]; then
# because we are using Clang, we cannot use the system's boost libs, because
# we could run into the same ABI problems as stated above
echo "downloading & building boost..."
wget https://sourceforge.net/projects/boost/files/boost/1.63.0/boost_1_63_0.zip/download
mkdir boost
unzip download -d boost
mkdir "$boost_dir/installation"

pushd "$boost_dir"
./bootstrap.sh --prefix="$boost_dir/installation" --without-libraries=python
./b2 -j8 toolset=clang cxxflags="-fPIC -stdlib=libc++" linkflags="-stdlib=libc++" \
runtime-link=shared variant=release link=static threading=multi install
rm download

popd &>/dev/null
fi

export BOOST_ROOT=$boost_dir/installation


build_dir=build_debug
# to clean, just delete the directory...


if [[ ! -d $build_dir ]]; then
mkdir -p $build_dir
pushd $build_dir
cmake ../cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_FIND_ROOT_PATH="$BOOST_ROOT" \
|| (cd .. && rm -r $build_dir && exit 1)
popd &>/dev/null
fi

pushd $build_dir
# final linking of the binaries can fail due to a missing libc++abi library
# (happens on Fedora, see https://bugzilla.redhat.com/show_bug.cgi?id=1332306).
# So we only build the libraries here for now
make -j8 AirLib MavLinkCom
popd &>/dev/null


cp -p AirLib/deps/rpclib/lib/x64/Debug/librpc.a AirLib/deps/rpclib/lib
cp -p $build_dir/AirLib/lib/libAirLib.a AirLib/lib
cp -rp MavLinkCom/include AirLib/deps/MavLinkCom
cp -rp $build_dir/MavLinkCom/lib AirLib/deps/MavLinkCom
cp -rp AirLib Unreal/Plugins/AirSim/Source
rm -rf Unreal/Plugins/AirSim/Source/AirLib/deps/rpclib/rpclib

echo ""
echo "============================================================"
echo "Now copy the Unreal/Plugins directory to the Unreal project:"
echo "rsync -t -r Unreal/plugins <unreal project_root>"
echo " (<unreal project_root> contains a file named <project>.uproject)"
echo "============================================================"
echo "And do (required for building the Unreal plugin):"
echo "export BOOST_ROOT=\"$BOOST_ROOT\""

4 changes: 3 additions & 1 deletion cmake/cmake-modules/CommonSetup.cmake
Expand Up @@ -18,9 +18,11 @@ macro(CommonSetup)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
set(CMAKE_CXX_STANDARD 14)
else ()
set(CMAKE_CXX_FLAGS "-std=c++14 -ggdb -Wall -Wextra -Wstrict-aliasing -Werror -fmax-errors=2 -Wunreachable-code -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wmissing-include-dirs -Wnoexcept -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wstrict-null-sentinel -Wstrict-overflow=5 -Wswitch-default -Wundef -Wno-unused -Wno-variadic-macros -Wno-parentheses -fdiagnostics-show-option ${MAVLINK_OVERRIDES} ${BOOST_OVERRIDES} ${RPC_LIB_DEFINES} -Wl,--no-as-needed -ldl -ldl ${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "-std=c++14 -stdlib=libc++ -ggdb -Wall -Wextra -Wstrict-aliasing -fmax-errors=2 -Wunreachable-code -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wmissing-include-dirs -Wnoexcept -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wstrict-null-sentinel -Wstrict-overflow=5 -Wswitch-default -Wundef -Wno-unused -Wno-variadic-macros -Wno-parentheses -fdiagnostics-show-option ${MAVLINK_OVERRIDES} ${BOOST_OVERRIDES} ${RPC_LIB_DEFINES} -ldl ${CMAKE_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++ -lc++abi")
endif ()
set(BUILD_PLATFORM "x64")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

ELSE()
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_WIN32_WINNT=0x0600 /GS /W4 /wd4100 /wd4505 /wd4820 /wd4464 /wd4514 /wd4710 /wd4571 /Zc:wchar_t /ZI /Zc:inline /fp:precise /D_SCL_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_WARNINGS /D_UNICODE /DUNICODE /WX- /Zc:forScope /Gd /EHsc ")
Expand Down

0 comments on commit d5ac3dc

Please sign in to comment.