Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Now compiles on Windows w/ MINGW 4.8 #3

Open
wants to merge 13 commits into
base: devel
Choose a base branch
from
35 changes: 35 additions & 0 deletions .travis.yml
@@ -0,0 +1,35 @@
language: cpp

sudo: required

os:
- linux
- osx

compiler:
- gcc

env:
- BUILD_TYPE=Release

before_script:
- if [ "`uname`" != "Darwin" ] ; then export MOOS_CXX_FLAGS="-fPIC -Wno-long-long"; fi
- cd ..
- git clone -b wOnlineCI --depth=1 https://github.com/msis/core-moos
- cd core-moos
- mkdir build
- cd build
- cmake -DENABLE_EXPORT=ON -DUSE_ASYNC_COMMS=ON -DTIME_WARP_AGGLOMERATION=0.4 -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_CXX_FLAGS=$MOOS_CXX_FLAGS ..
- cmake --build . --config Release
- sudo cmake --build . --config Release --target install
- cd $TRAVIS_BUILD_DIR
- mkdir build/


script:
- cd build/
- cmake -DBUILD_CONSOLE_TOOLS=ON -DBUILD_GRAPHICAL_TOOLS=ON -DBUILD_UPB=ON -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_CXX_FLAGS=$MOOS_CXX_FLAGS ../
- cmake --build . --config Release

after_script:
- sudo cmake --build . --config Release --target install
4 changes: 3 additions & 1 deletion Essentials/CMakeLists.txt
@@ -1,4 +1,6 @@
add_subdirectory(pMOOSBridge)
IF (NOT WIN32)
add_subdirectory(pMOOSBridge)
ENDIF (NOT WIN32)
add_subdirectory(pAntler)
add_subdirectory(pLogger)
add_subdirectory(pScheduler)
Expand Down
4 changes: 4 additions & 0 deletions Essentials/pAntler/CMakeLists.txt
Expand Up @@ -6,6 +6,10 @@ find_package(MOOS 10)
#what files are needed?
SET(SRCS AntlerMain.cpp Antler.cpp)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the pull request! You saved me duplicating half the effort (half, until I realized someone else already did it!).

Just a comment: on this CMakeLists.txt file, I would rather add conditionally to be in WIN32, just in case it breaks UNIXes builds which seem to work as is...

IF (WIN32)
    SET(SRCS ${SRCS} XPCProcess.cpp XPCProcessAttrib.cpp)
ENDIF(WIN32)


IF (WIN32)
SET(SRCS ${SRCS} XPCProcess.cpp XPCProcessAttrib.cpp)
ENDIF(WIN32)

include_directories( ${${EXECNAME}_INCLUDE_DIRS} ${MOOS_INCLUDE_DIRS} ${MOOS_DEPEND_INCLUDE_DIRS})
add_executable(${EXECNAME} ${SRCS} )
target_link_libraries(${EXECNAME} ${MOOS_LIBRARIES} ${MOOS_DEPEND_LIBRARIES})
Expand Down
4 changes: 2 additions & 2 deletions Essentials/pLogger/MOOSLogger.cpp
Expand Up @@ -1032,7 +1032,7 @@ bool CMOOSLogger::CreateDirectory(const std::string & sDirectory)
{

#if _WIN32
int bOK = ::CreateDirectory(sDirectory.c_str(),NULL);
int bOK = ::CreateDirectoryA(sDirectory.c_str(),NULL);

if(!bOK)
{
Expand All @@ -1042,7 +1042,7 @@ bool CMOOSLogger::CreateDirectory(const std::string & sDirectory)
{

LPVOID lpMsgBuf;
FormatMessage(
FormatMessageA(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
Expand Down
5 changes: 5 additions & 0 deletions Essentials/pLogger/MOOSLogger.h
Expand Up @@ -39,6 +39,11 @@
#include <string>
#include "Zipper.h"

#if _WIN32
#include <windows.h>
#include <winbase.h>
#endif // windows

typedef std::vector<std::string> STRING_VECTOR;

class CMOOSLogger : public CMOOSApp
Expand Down
19 changes: 13 additions & 6 deletions Essentials/pShare/Listener.cpp
Expand Up @@ -7,10 +7,17 @@
#ifndef _WIN32
#include "unistd.h"
#endif
#ifdef UNIX
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#elif _WIN32
#define _WIN32_WINNT 0x0600 //will only work with vista and above as XP does not support IPv6
#include <io.h>
#include <winsock2.h>
#include <Ws2tcpip.h>
#endif

#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <string>
#include <cstring>
#include <stdexcept>
Expand Down Expand Up @@ -52,7 +59,7 @@ bool Listener::ListenLoop()

//we want to be able to resuse it (multiple folk are interested)
int reuse = 1;
if (setsockopt(socket_fd, SOL_SOCKET,SO_REUSEADDR/* SO_REUSEPORT*/, &reuse, sizeof(reuse)) == -1)
if (setsockopt(socket_fd, SOL_SOCKET,SO_REUSEADDR/* SO_REUSEPORT*/, (char *)&reuse, sizeof(reuse)) == -1)
throw std::runtime_error("Listener::ListenLoop::setsockopt::reuse");

/* if (setsockopt(socket_fd, SOL_SOCKET, SO_REUSEPORT,
Expand All @@ -63,7 +70,7 @@ bool Listener::ListenLoop()
//give ourselves plenty of receive space
//set aside some space for receiving - just a few multiples of 64K
int rx_buffer_size = 64*1024*28;
if (setsockopt(socket_fd, SOL_SOCKET, SO_RCVBUF, &rx_buffer_size, sizeof(rx_buffer_size)) == -1)
if (setsockopt(socket_fd, SOL_SOCKET, SO_RCVBUF, (char *)&rx_buffer_size, sizeof(rx_buffer_size)) == -1)
throw std::runtime_error("Listener::ListenLoop()::setsockopt::rcvbuf");


Expand Down Expand Up @@ -91,7 +98,7 @@ bool Listener::ListenLoop()
struct ip_mreq mreq;
mreq.imr_multiaddr.s_addr = inet_addr(address_.host().c_str());
mreq.imr_interface.s_addr = INADDR_ANY;
if(setsockopt(socket_fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq))==-1)
if(setsockopt(socket_fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *)&mreq, sizeof(mreq))==-1)
throw std::runtime_error("Listener::ListenLoop()::setsockopt::ADD_MEMBERSHIP");
}

Expand Down
37 changes: 26 additions & 11 deletions Essentials/pShare/Share.cpp
Expand Up @@ -4,9 +4,15 @@
* Created on: Aug 26, 2012
* Author: pnewman
*/
#include <ifaddrs.h>
#include <arpa/inet.h>
#include <netdb.h>
#ifdef UNIX
#include <ifaddrs.h>
#include <arpa/inet.h>
#include <netdb.h>
#elif _WIN32
// #define _WIN32_WINNT 0x0600 //will only work with vista and above as XP does not support IPv6
#include <winsock2.h>
#include <Ws2tcpip.h>
#endif

#include <map>
#include <stdexcept>
Expand Down Expand Up @@ -1091,7 +1097,7 @@ bool Share::Impl::ApplyRoutes(CMOOSMsg & msg)
}

//send here
if (sendto(relevant_socket.socket_fd, buffer.data(), buffer.size(), 0,
if (sendto(relevant_socket.socket_fd, (const char*)buffer.data(), buffer.size(), 0,
(struct sockaddr*) (&relevant_socket.sock_addr),
sizeof(relevant_socket.sock_addr)) < 0)
{
Expand Down Expand Up @@ -1138,7 +1144,7 @@ bool Share::Impl::AddOutputRoute(MOOS::IPV4Address address, bool multicast)

int reuse = 1;
if (setsockopt(new_socket.socket_fd, SOL_SOCKET, SO_REUSEADDR,
&reuse, sizeof(reuse)) == -1)
(char *)&reuse, sizeof(reuse)) == -1)
throw std::runtime_error("failed to set resuse socket option");
/*
if (setsockopt(new_socket.socket_fd, SOL_SOCKET, SO_REUSEPORT,
Expand All @@ -1148,7 +1154,7 @@ bool Share::Impl::AddOutputRoute(MOOS::IPV4Address address, bool multicast)
int send_buffer_size = 4 * 64 * 1024;
if (setsockopt(new_socket.socket_fd,
SOL_SOCKET, SO_SNDBUF,
&send_buffer_size,
(char *)&send_buffer_size,
sizeof(send_buffer_size)) == -1)
{
throw std::runtime_error("failed to set size of socket send buffer");
Expand All @@ -1173,11 +1179,20 @@ bool Share::Impl::AddOutputRoute(MOOS::IPV4Address address, bool multicast)

std::string dotted_ip = MOOS::IPV4Address::GetNumericAddress(new_socket.address.host());

if(inet_aton(dotted_ip.c_str(), &new_socket.sock_addr.sin_addr)==0)
{
throw std::runtime_error("failed to intepret "
+dotted_ip+" as an ip address");
}
#ifdef UNIX
if(inet_aton(dotted_ip.c_str(), &new_socket.sock_addr.sin_addr)==0)
{
throw std::runtime_error("failed to intepret "
+dotted_ip+" as an ip address");
}
#elif _WIN32
if( inet_pton(AF_INET,dotted_ip.c_str(), &new_socket.sock_addr.sin_addr)==0)
{
throw std::runtime_error("failed to intepret "
+dotted_ip+" as an ip address");
}
#endif


//new_socket.sock_addr.sin_addr.s_addr = inet_addr(new_socket.address.ip_num.c_str());
new_socket.sock_addr.sin_port = htons(new_socket.address.port());
Expand Down
12 changes: 12 additions & 0 deletions README.md
@@ -0,0 +1,12 @@
Essential-MOOS
==============
Essential-MOOS contains some useful tools for robotics to use with [Core-MOOS](https://github.com/themoos/core-moos) for Robotics purposes.

# Build Statuses
|OS |Build Status|
|:--------|-----------:|
|Linux/OSX|[![Build Status](https://travis-ci.org/msis/essential-moos.svg?branch=devel)](https://travis-ci.org/msis/essential-moos)|
|Windows |[![Build status](https://ci.appveyor.com/api/projects/status/d3cm6s8l6lko5q6e?svg=true)](https://ci.appveyor.com/project/msis/essential-moos)|

# Build Instructions
(TODO, for now please refer to `.travis.yml` file for Linux/OSX and `appveyor.yml` for Windows.)
40 changes: 40 additions & 0 deletions appveyor.yml
@@ -0,0 +1,40 @@
version: devel-{build}

platform:
- x64
- x86

environment:
matrix:
- BUILD_TYPE: cmake
VS_VERSION: Visual Studio 11 2012

- BUILD_TYPE: cmake
VS_VERSION: Visual Studio 12 2013

- BUILD_TYPE: cmake
VS_VERSION: Visual Studio 14 2015

shallow_clone: true

init:
- if "%platform%" == "x64" SET VS_FULL=%VS_VERSION% Win64
- if "%platform%" == "x86" SET VS_FULL=%VS_VERSION%
- cd ..
- git clone -b wOnlineCI --depth=1 https://github.com/msis/core-moos
- cd core-moos
- mkdir build
- cd build
- cmake -G "%VS_FULL%" -DENABLE_EXPORT=ON -DUSE_ASYNC_COMMS=ON -DTIME_WARP_AGGLOMERATION=0.4 -DCMAKE_BUILD_TYPE=$BUILD_TYPE ../
- cmake --build . --config Release
- cmake --build . --config Release --target install
- cd %APPVEYOR_BUILD_FOLDER%
- mkdir build

build_script:
- cd build
- cmake -G "%VS_FULL%" -DBUILD_CONSOLE_TOOLS=ON -DBUILD_GRAPHICAL_TOOLS=ON -DBUILD_UPB=ON -DCMAKE_BUILD_TYPE=$BUILD_TYPE ../
- cmake --build . --config Release

on_success:
- cmake --build . --config Release --target install