diff --git a/.github/workflows/build_linux.yaml b/.github/workflows/build_linux.yaml new file mode 100644 index 00000000..6083af74 --- /dev/null +++ b/.github/workflows/build_linux.yaml @@ -0,0 +1,37 @@ +name: Build Linux + +on: + push: + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-22.04] + architecture: ["x64"] + + steps: + - uses: actions/checkout@v3 + - name: Set up APT + if: ${{ matrix.os == 'ubuntu-20.04' || matrix.os == 'ubuntu-22.04' }} + run: | + sudo apt-get update -y + sudo apt-get -y install g++ cmake-data cmake ninja-build libzmq3-dev liblog4cxx-dev libboost-filesystem-dev libboost-system-dev libboost-thread-dev libboost-date-time-dev libboost-program-options-dev libcurl4-openssl-dev + - name: Install RapidJSON + run: | + set -e + git clone https://github.com/Tencent/rapidjson.git && mkdir rapidjson/build + cd rapidjson/build + # there are no stable version available + cmake .. -GNinja -DRAPIDJSON_HAS_STDSTRING=ON -DRAPIDJSON_BUILD_DOC=OFF -DRAPIDJSON_BUILD_EXAMPLES=OFF -DRAPIDJSON_BUILD_TESTS=OFF + ninja -j4 && sudo ninja install + cd ../.. + - name: Install + run: | + set -e + mkdir -p build + cd build + cmake .. -GNinja -DOPT_SAMPLES=OFF -DOPT_BUILD_TESTS=OFF + ninja -j4 && sudo ninja install + cd .. diff --git a/.github/workflows/build_windows.yaml b/.github/workflows/build_windows.yaml new file mode 100644 index 00000000..7388c497 --- /dev/null +++ b/.github/workflows/build_windows.yaml @@ -0,0 +1,48 @@ +name: Build Windows + +on: + push: + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [windows-2022] + architecture: ["x64"] + + steps: + - uses: actions/checkout@v3 + - uses: microsoft/setup-msbuild@v1.1 + - name: Set up Boost + run: | + choco install boost-msvc-14.3 -f -y + - name: Set up curl + run: | + curl -O -L https://curl.se/windows/dl-8.5.0_1/curl-8.5.0_1-win64-mingw.zip + 7z x -y curl-8.5.0_1-win64-mingw.zip + - name: Install RapidJSON + run: | + git clone https://github.com/Tencent/rapidjson.git && mkdir rapidjson\build + cd rapidjson\build + # there are no stable version available + # but take the last version without -targets.cmake + git checkout 516d0473949fdcf0a6dc9fbb40fa92b3b85db184 + cmake .. -G 'Visual Studio 17 2022' -A x64 -DRAPIDJSON_HAS_STDSTRING=ON -DRAPIDJSON_BUILD_DOC=OFF -DRAPIDJSON_BUILD_EXAMPLES=OFF -DRAPIDJSON_BUILD_TESTS=OFF + msbuild ALL_BUILD.vcxproj /p:Configuration=Release + cd ..\.. + - name: Install libzmq + run: | + git clone https://github.com/zeromq/libzmq.git && mkdir libzmq\build + cd libzmq\build + git checkout v4.3.5 + cmake .. -G 'Visual Studio 17 2022' -A x64 -DBUILD_TESTS=OFF + msbuild ALL_BUILD.vcxproj /p:Configuration=Release + cd ..\.. + - name: Install + run: | + mkdir -p build + cd build + cmake .. -G 'Visual Studio 17 2022' -A x64 -DCMAKE_CXX_STANDARD=17 "-DZeroMQ_DIR=${PWD}\..\libzmq\build" "-DCURL_INCLUDE_DIR=${PWD}\..\curl-8.5.0_1-win64-mingw\include" "-DCURL_LIBRARY=${PWD}\..\curl-8.5.0_1-win64-mingw\lib\libcurl.dll.a" -DCMAKE_CONFIGURATION_TYPES=Release -DOPT_SAMPLES=OFF -DOPT_BUILD_TESTS=OFF + msbuild ALL_BUILD.vcxproj /p:Configuration=Release + cd .. diff --git a/include/mujincontrollerclient/mujincontrollerclient.h b/include/mujincontrollerclient/mujincontrollerclient.h index c0aa3499..7ca9f662 100644 --- a/include/mujincontrollerclient/mujincontrollerclient.h +++ b/include/mujincontrollerclient/mujincontrollerclient.h @@ -20,6 +20,7 @@ #ifdef _MSC_VER +#define NOMINMAX #pragma warning(disable:4251)// needs to have dll-interface to be used by clients of class #pragma warning(disable:4190)// C-linkage specified, but returns UDT 'boost::shared_ptr' which is incompatible with C #pragma warning(disable:4819)//The file contains a character that cannot be represented in the current code page (932). Save the file in Unicode format to prevent data loss using native typeof diff --git a/include/mujincontrollerclient/mujinjson.h b/include/mujincontrollerclient/mujinjson.h index cc8dd659..960d7d6c 100644 --- a/include/mujincontrollerclient/mujinjson.h +++ b/include/mujincontrollerclient/mujinjson.h @@ -461,6 +461,7 @@ inline void LoadJsonValue(const rapidjson::GenericValue& v, } } +#ifndef _MSC_VER template , typename Allocator=rapidjson::MemoryPoolAllocator<> > inline void LoadJsonValue(const rapidjson::GenericValue& v, uint64_t& t) { if (v.IsUint64()) { @@ -486,6 +487,7 @@ inline void LoadJsonValue(const rapidjson::GenericValue& v, throw MujinJSONException("Cannot convert json type " + GetJsonString(v) + " to Int64"); } } +#endif template , typename Allocator=rapidjson::MemoryPoolAllocator<> > inline void LoadJsonValue(const rapidjson::GenericValue& v, double& t) { @@ -802,10 +804,12 @@ inline void SaveJsonValue(rapidjson::GenericValue& v, const v.SetInt64(t); } +#ifndef _MSC_VER template inline void SaveJsonValue(rapidjson::GenericValue& v, const int64_t& t, Allocator2& alloc) { v.SetInt64(t); } +#endif template inline void SaveJsonValue(rapidjson::GenericValue& v, const unsigned long long& t, Allocator2& alloc) { diff --git a/src/controllerclientimpl.cpp b/src/controllerclientimpl.cpp index 43f32345..6be81002 100644 --- a/src/controllerclientimpl.cpp +++ b/src/controllerclientimpl.cpp @@ -2289,7 +2289,7 @@ GraphSubscriptionWebSocketHandler::GraphSubscriptionWebSocketHandler(const Contr MUJIN_LOG_INFO(boost::format("Create TCP socket connected to host %s") % host); boost::asio::ip::tcp::socket socket(*ioContext); - boost::asio::ip::tcp::endpoint endpoint(boost::asio::ip::address::from_string(host), port); + boost::asio::ip::tcp::endpoint endpoint(boost::asio::ip::make_address(host), port); socket.connect(endpoint); _tcpStream = boost::make_shared>(std::move(socket)); } else { diff --git a/src/mujincontrollerclient.cpp b/src/mujincontrollerclient.cpp index 295d9dcf..07a36fc7 100644 --- a/src/mujincontrollerclient.cpp +++ b/src/mujincontrollerclient.cpp @@ -15,8 +15,6 @@ #include "controllerclientimpl.h" #include // for sleep #include -#include -#include #include diff --git a/src/mujinjson.cpp b/src/mujinjson.cpp index 1f2e4aca..50113e24 100644 --- a/src/mujinjson.cpp +++ b/src/mujinjson.cpp @@ -4,7 +4,17 @@ #include #include + +#if defined(_WIN32) +#include +#else #include +#endif + +#if defined(_MSC_VER) +#include +typedef SSIZE_T ssize_t; +#endif namespace mujinjson {