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

[WIP] TravisCI: fix and improve MacOS build #353

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 55 additions & 30 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,25 @@ matrix:
env:
- PX4_DOCKER_REPO=px4io/px4-dev-simulation-bionic:2019-10-04
- BUILD="source ./scripts/validate_sdf.bash"
- name: MacOSX 10.14 (Xcode 11.0) build with Gazebo 9
- name: MacOSX Sierra (Xcode 9.2) build with Gazebo 7
Copy link
Contributor

Choose a reason for hiding this comment

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

I would drop this version. Supporting 2 and with Catalina 3 is enough.

Copy link
Member Author

Choose a reason for hiding this comment

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

I am adding this one so we can have a build pipe for Gazebo 7 also in MacOSX.

os: osx
osx_image: xcode11
osx_image: xcode9.2
language: cpp
cache:
ccache: true
env:
- GAZEBO_VERSION="gazebo7"
- name: MacOSX High Sierra (Xcode 10.1) build with Gazebo 9
os: osx
osx_image: xcode10.1
language: cpp
cache:
ccache: true
env:
- GAZEBO_VERSION="gazebo9"
- name: MacOSX Mojave (Xcode 11.2) build with Gazebo 9
os: osx
osx_image: xcode11.2
language: cpp
cache:
ccache: true
Expand All @@ -90,40 +106,49 @@ matrix:

before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
brew update;
curl https://gstreamer.freedesktop.org/data/pkg/osx/1.0.10/gstreamer-1.0-1.0.10-universal.pkg -LO /tmp/gstreamer-1.0-1.0.10-universal.pkg;
curl https://gstreamer.freedesktop.org/data/pkg/osx/1.0.10/gstreamer-1.0-devel-1.0.10-universal.pkg -LO /tmp/gstreamer-1.0-devel-1.0.10-universal.pkg;
git clone --depth 1 https://github.com/mavlink/c_library_v2.git /usr/local/include/mavlink/v2.0;
rm -rf /usr/local/include/mavlink/v2.0/.git;
git clone https://github.com/google/googletest;
pushd googletest;
mkdir build;
pushd build;
cmake ..;
make;
make install;
popd;
popd;
brew update;
git clone https://github.com/google/googletest;
git clone --depth 1 https://github.com/mavlink/c_library_v2.git /usr/local/include/mavlink/v2.0;
curl https://gstreamer.freedesktop.org/data/pkg/osx/1.0.10/gstreamer-1.0-1.0.10-universal.pkg -vlo gstreamer-1.0-1.0.10-universal.pkg;
curl https://gstreamer.freedesktop.org/data/pkg/osx/1.0.10/gstreamer-1.0-devel-1.0.10-universal.pkg -vlo gstreamer-1.0-devel-1.0.10-universal.pkg;
fi

install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
brew tap PX4/px4;
brew install px4-dev pkg-config;
installer -allowUntrusted -verboseR -pkg /tmp/gstreamer-1.0-1.0.10-universal.pkg -target /;
installer -allowUntrusted -verboseR -pkg /tmp/gstreamer-1.0-devel-1.0.10-universal.pkg -target /;
export PKG_CONFIG_PATH="/Frameworks/GStreamer.framework/Versions/Current/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}";
brew tap osrf/simulation;
brew install opencv ${GAZEBO_VERSION};
brew cask reinstall xquartz java;
sudo -H pip2 install --upgrade pip setuptools;
sudo -H pip2 install rospkg pyserial empy toml numpy pandas jinja2;
sudo -H pip2 install --upgrade --force-reinstall numpy;
pushd googletest;
mkdir build;
pushd build;
cmake ..;
make;
make install;
popd;
popd;
brew tap PX4/px4;
brew install px4-dev;
brew tap osrf/simulation;
brew install opencv ${GAZEBO_VERSION};
sudo -H pip2 install --upgrade pip setuptools;
sudo -H pip2 install rospkg pyserial empy toml numpy pandas jinja2;
sudo installer -allowUntrusted -verboseR -pkg gstreamer-1.0-1.0.10-universal.pkg -target /;
sudo installer -allowUntrusted -verboseR -pkg gstreamer-1.0-devel-1.0.10-universal.pkg -target /;
fi

after_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
brew cleanup;
rm -rf /usr/local/include/mavlink/v2.0/.git googletest/.git;
rm gstreamer-1.0-1.0.10-universal.pkg gstreamer-1.0-devel-1.0.10-universal.pkg;
fi

before_script:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
export PKG_CONFIG_PATH="/Frameworks/GStreamer.framework/Versions/Current/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}";
fi

script:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
mkdir Build;
cd Build && cmake -DENABLE_UNIT_TESTS=On .. && make -j$(sysctl -n hw.physicalcpu) -l$(sysctl -n hw.physicalcpu); make test;
else docker run -it --rm -w ${TRAVIS_BUILD_DIR} --env=CCACHE_DIR="${CCACHE_DIR}" --volume=${CCACHE_DIR}:${CCACHE_DIR}:rw --volume=${TRAVIS_BUILD_DIR}:${TRAVIS_BUILD_DIR}:rw ${PX4_DOCKER_REPO} /bin/bash -e -c "${BUILD}";
mkdir Build;
cd Build && cmake -DENABLE_UNIT_TESTS=On .. && make -j$(sysctl -n hw.physicalcpu) -l$(sysctl -n hw.physicalcpu); make test;
else
docker run -it --rm -w ${TRAVIS_BUILD_DIR} --env=CCACHE_DIR="${CCACHE_DIR}" --volume=${CCACHE_DIR}:${CCACHE_DIR}:rw --volume=${TRAVIS_BUILD_DIR}:${TRAVIS_BUILD_DIR}:rw ${PX4_DOCKER_REPO} /bin/bash -e -c "${BUILD}";
Copy link
Contributor

Choose a reason for hiding this comment

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

@TSC21 what do we use docker for here?

Copy link
Member Author

Choose a reason for hiding this comment

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

To build on the Linux distros.

Copy link
Contributor

Choose a reason for hiding this comment

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

But that's inside the if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, there is the else 🙈

fi
39 changes: 27 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
cmake_policy(SET CMP0042 NEW)
cmake_policy(SET CMP0048 NEW)
cmake_policy(SET CMP0054 NEW)
if(NOT ${CMAKE_VERSION} VERSION_LESS "3.10.0")
cmake_policy(SET CMP0071 NEW)
endif()

if (NOT CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "/usr" CACHE STRING "install prefix" FORCE)
Expand Down Expand Up @@ -37,16 +40,30 @@ find_program(px4 REQUIRED)
find_package(PythonInterp REQUIRED)
find_package(OpenCV REQUIRED)
find_package(TinyXML REQUIRED)
if (BUILD_GSTREAMER_PLUGIN)
if(BUILD_GSTREAMER_PLUGIN)
set(GStreamer_FIND_VERSION "1.0")
find_package(GStreamer)
if (GSTREAMER_FOUND)
find_package(GStreamer REQUIRED)
if(GSTREAMER_FOUND)
# Set AUTOMOC, AUTOGEN and AUTOUIC
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOGEN ON)
set(CMAKE_AUTOUIC ON)
if("${GAZEBO_VERSION}" VERSION_LESS "8.0")
find_package (Qt4)
include (${QT_USE_FILE})
find_package(Qt4)
include(${QT_USE_FILE})
else()
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Core REQUIRED)
# In order to have Qt5 found in MacOS/MacOSX, the Qt5 path needs to be
# added to the CMake prefix path
if(APPLE)
execute_process(COMMAND export Qt5_DIR=$(brew --prefix qt5))
execute_process(COMMAND brew --prefix qt5
ERROR_QUIET
OUTPUT_VARIABLE QT5_PREFIX_PATH
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, actually this one is nicer than my solution.

)
list(APPEND CMAKE_PREFIX_PATH "${QT5_PREFIX_PATH}")
else()
find_package(Qt5 COMPONENTS Core Widgets REQUIRED)
endif()
endif()
endif()
endif()
Expand Down Expand Up @@ -365,25 +382,23 @@ if (GSTREAMER_FOUND)
${plugins}
gazebo_gst_camera_plugin
)
message(STATUS "Found GStreamer: adding gst_camera_plugin")
message(STATUS "Adding gst_camera_plugin")
if("${GAZEBO_VERSION}" VERSION_LESS "8.0")
QT4_WRAP_CPP(headers_MOC include/gazebo_video_stream_widget.h)
add_library(gazebo_video_stream_widget SHARED ${headers_MOC} src/gazebo_video_stream_widget.cpp)
target_link_libraries(gazebo_video_stream_widget ${GAZEBO_LIBRARIES} ${QT_LIBRARIES} ${PROTOBUF_LIBRARIES})
set(plugins
${plugins}
gazebo_video_stream_widget
)
message(STATUS "Found GStreamer: adding gst_video_stream_widget")
message(STATUS "Adding gst_video_stream_widget")
else()
QT5_WRAP_CPP(headers_MOC include/gazebo_video_stream_widget.h)
add_library(gazebo_video_stream_widget SHARED ${headers_MOC} src/gazebo_video_stream_widget.cpp)
target_link_libraries(gazebo_video_stream_widget ${GAZEBO_LIBRARIES} ${Qt5Core_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${PROTOBUF_LIBRARIES} ${Qt5Test_LIBRARIES})
set(plugins
${plugins}
gazebo_video_stream_widget
)
message(STATUS "Found GStreamer: adding gst_video_stream_widget")
message(STATUS "Adding gst_video_stream_widget")
endif()
endif()

Expand Down