diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml index 7f851c92..3ad22f4b 100644 --- a/.github/workflows/build_linux.yml +++ b/.github/workflows/build_linux.yml @@ -7,46 +7,64 @@ on: jobs: build-linux: - runs-on: ubuntu-20.04 + strategy: + matrix: + ros_distribution: + - foxy + - humble + include: + # Foxy Fitzroy (June 2020 - May 2023) + - os: ubuntu-20.04 + test_target_framework: net6.0 + ros_distribution: foxy + ros_version: 2 + # Humble Hawksbill (May 2022 - May 2027) + - os: ubuntu-22.04 + test_target_framework: net6.0 + ros_distribution: humble + ros_version: 2 + + runs-on: ${{ matrix.os }} + env: + RCLDOTNET_TEST_TARGET_FRAMEWORK: ${{ matrix.test_target_framework }} steps: - name: Checkout source uses: actions/checkout@v2 - # https://docs.microsoft.com/en-us/dotnet/core/install/linux-package-manager-ubuntu-1804 - - name: Install .NET SDK v2.1 + # https://learn.microsoft.com/en-us/dotnet/core/install/linux-ubuntu#supported-distributions + - name: Install .NET SDK v6.0 + if: matrix.os == 'ubuntu-20.04' run: | - wget https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb + wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb sudo dpkg -i packages-microsoft-prod.deb - sudo add-apt-repository universe - sudo apt-get update - sudo apt-get install -y apt-transport-https + rm packages-microsoft-prod.deb sudo apt-get update - sudo apt-get install -y dotnet-sdk-2.1 + sudo apt-get install -y dotnet-sdk-6.0 - name: Setup ROS2 - uses: ros-tooling/setup-ros@v0.2 + uses: ros-tooling/setup-ros@v0.6 with: - required-ros-distributions: foxy + required-ros-distributions: ${{ matrix.ros_distribution }} - name: Configure ros2_dotnet workspace run: | mkdir -p ~/ros2_dotnet_ws/src cd ~/ros2_dotnet_ws - cp ${{github.workspace}}/ros2_dotnet.repos . - vcs import src < ros2_dotnet.repos + cp ${{github.workspace}}/ros2_dotnet_${{ matrix.ros_distribution }}.repos . + vcs import src < ros2_dotnet_${{ matrix.ros_distribution }}.repos rm -rf src/ros2_dotnet/ros2_dotnet cp -r ${{github.workspace}} src/ros2_dotnet/ros2_dotnet vcs branch - name: Build ros2_dotnet source run: | - source /opt/ros/foxy/setup.bash + source /opt/ros/${{ matrix.ros_distribution }}/setup.bash cd ~/ros2_dotnet_ws colcon build --event-handlers console_cohesion+ console_package_list+ - name: Run tests run: | - source /opt/ros/foxy/setup.bash + source /opt/ros/${{ matrix.ros_distribution }}/setup.bash cd ~/ros2_dotnet_ws colcon test --event-handlers console_cohesion+ --return-code-on-test-failure --packages-select rcldotnet diff --git a/README.md b/README.md index 27e9f12a..5b8dd439 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,12 @@ ROS2 for .NET ============= -Build status ------------- - | Target | Status | |----------|--------| -| **Universal Windows Platform (x86/x64)** | ![Build (UWP)](https://github.com/ros2-dotnet/ros2_dotnet/workflows/Build%20(UWP)/badge.svg) | -| **Windows Desktop (x64)** | ![Build (Desktop)](https://github.com/ros2-dotnet/ros2_dotnet/workflows/Build%20(Desktop)/badge.svg) | -| **Linux** | ![Build (Desktop)](https://github.com/ros2-dotnet/ros2_dotnet/workflows/Build%20(Linux)/badge.svg) | +| **Linux** | [![Build (Linux)](https://github.com/ros2-dotnet/ros2_dotnet/actions/workflows/build_linux.yml/badge.svg)](https://github.com/ros2-dotnet/ros2_dotnet/actions/workflows/build_linux.yml) | +| **Windows Desktop** | [![Build (Desktop)](https://github.com/ros2-dotnet/ros2_dotnet/actions/workflows/build_desktop.yml/badge.svg)](https://github.com/ros2-dotnet/ros2_dotnet/actions/workflows/build_desktop.yml) | + +_Windows UWP CI Builds are currently disabled, see [this issue](https://github.com/ros2-dotnet/ros2_dotnet/issues/92) for more information._ Introduction ------------ @@ -47,12 +45,12 @@ see the relevant section below): https://github.com/ros2/ros2/wiki/Installation# Next make sure you've either installed .Net Core (preferred) https://www.microsoft.com/net/learn/get-started or Mono -https://www.mono-project.com/. (**NOTE**: For building unit tests, .NET 2.1 is +https://www.mono-project.com/. (**NOTE**: For building unit tests, .NET 6 is required). For running on Linux or Windows Desktop, one can build `ros2_dotnet` (along with all desired packages containing interface definitions) as an overlay on top -of an existing ROS2 installation. The `ros2_dotnet.repos` contains all +of an existing ROS2 installation. The `ros2_dotnet_foxy.repos` contains all necessary repositories to build the core `ros2_dotnet` project along with all standard ROS2 interface packages. If you are using other packages which provide interface definitions, those must also be included in the `ros2_dotnet` workspace @@ -65,7 +63,7 @@ core of ROS2 must be compiled for UWP compatibility. Windows (Desktop) ----------------- Assuming you've installed ROS2 (pre-built binary packages) to the directory -c:\dev\ros2_eloquent per the official [installation instructions](https://index.ros.org/doc/ros2/Installation/Eloquent/Windows-Install-Binary/), +c:\dev\ros2_foxy per the official [installation instructions](https://index.ros.org/doc/ros2/Installation/Foxy/Windows-Install-Binary/), run the following from an Administrator Visual Studio 2019 Developer Command Prompt: @@ -76,25 +74,25 @@ This is done for you below in the line preceding `colcon build`. This step can/should be omitted if building on top of a built-from-source ROS2 workspace) ``` -call \dev\ros2_eloquent\local_setup.bat +call \dev\ros2_foxy\local_setup.bat md \dev\ros2_dotnet_ws\src cd \dev\ros2_dotnet_ws -curl -sk https://raw.githubusercontent.com/ros2-dotnet/ros2_dotnet/master/ros2_dotnet.repos -o ros2_dotnet.repos -vcs import \dev\ros2_dotnet_ws\src < ros2_dotnet.repos -git clone --branch eloquent https://github.com/ros2/rosidl src\ros2\rosidl +curl -sk https://raw.githubusercontent.com/ros2-dotnet/ros2_dotnet/master/ros2_dotnet_foxy.repos -o ros2_dotnet_foxy.repos +vcs import \dev\ros2_dotnet_ws\src < ros2_dotnet_foxy.repos +git clone --branch foxy https://github.com/ros2/rosidl src\ros2\rosidl colcon build --merge-install ``` Linux ----- -Assuming ROS2 eloquent installed to the standard location, run the following commands: +Assuming ROS2 foxy installed to the standard location, run the following commands: ``` -source /opt/ros/eloquent/setup.bash +source /opt/ros/foxy/setup.bash mkdir -p ~/ros2_dotnet_ws/src cd ~/ros2_dotnet_ws -wget https://raw.githubusercontent.com/ros2-dotnet/ros2_dotnet/master/ros2_dotnet.repos -vcs import ~/ros2_dotnet_ws/src < ros2_dotnet.repos +wget https://raw.githubusercontent.com/ros2-dotnet/ros2_dotnet/master/ros2_dotnet_foxy.repos +vcs import ~/ros2_dotnet_ws/src < ros2_dotnet_foxy.repos colcon build ``` diff --git a/rcldotnet/CMakeLists.txt b/rcldotnet/CMakeLists.txt index 30b01cc6..f466ee4c 100644 --- a/rcldotnet/CMakeLists.txt +++ b/rcldotnet/CMakeLists.txt @@ -97,7 +97,17 @@ if(BUILD_TESTING) ${builtin_interfaces_ASSEMBLIES_DLL} ) + # Used by CI to test the different target frameworks in a matrix. + if(DEFINED ENV{RCLDOTNET_TEST_TARGET_FRAMEWORK}) + set(RCLDOTNET_TEST_TARGET_FRAMEWORK $ENV{RCLDOTNET_TEST_TARGET_FRAMEWORK}) + else() + set(RCLDOTNET_TEST_TARGET_FRAMEWORK "net6.0") + endif() + add_dotnet_test(test_messages + TARGET_FRAMEWORK + ${RCLDOTNET_TEST_TARGET_FRAMEWORK} + SOURCES ${CS_SOURCES} test/test_messages.cs INCLUDE_DLLS diff --git a/rcldotnet_common/DllLoadUtils.cs b/rcldotnet_common/DllLoadUtils.cs index 280ca654..6aff8e38 100644 --- a/rcldotnet_common/DllLoadUtils.cs +++ b/rcldotnet_common/DllLoadUtils.cs @@ -54,10 +54,10 @@ public class DllLoadUtilsFactory { [DllImport ("kernel32.dll", EntryPoint = "FreeLibrary", SetLastError = true, ExactSpelling = true)] private static extern int FreeLibraryDesktop (IntPtr handle); - [DllImport ("libdl.so", EntryPoint = "dlopen")] + [DllImport ("libdl.so.2", EntryPoint = "dlopen")] private static extern IntPtr dlopen_unix (String fileName, int flags); - [DllImport ("libdl.so", EntryPoint = "dlclose")] + [DllImport ("libdl.so.2", EntryPoint = "dlclose")] private static extern int dlclose_unix (IntPtr handle); [DllImport ("libdl.dylib", EntryPoint = "dlopen")] @@ -106,7 +106,7 @@ private static bool IsWindowsDesktop () { private static bool IsUnix () { try { - IntPtr ptr = dlopen_unix ("libdl.so", RTLD_NOW); + IntPtr ptr = dlopen_unix ("libdl.so.2", RTLD_NOW); dlclose_unix (ptr); return true; } catch (TypeLoadException) { @@ -205,16 +205,16 @@ IntPtr DllLoadUtils.LoadLibrary (string fileName) { internal class DllLoadUtilsUnix : DllLoadUtils { - [DllImport ("libdl.so", ExactSpelling = true)] + [DllImport ("libdl.so.2", ExactSpelling = true)] private static extern IntPtr dlopen (String fileName, int flags); - [DllImport ("libdl.so", ExactSpelling = true)] + [DllImport ("libdl.so.2", ExactSpelling = true)] private static extern IntPtr dlsym (IntPtr handle, String symbol); - [DllImport ("libdl.so", ExactSpelling = true)] + [DllImport ("libdl.so.2", ExactSpelling = true)] private static extern int dlclose (IntPtr handle); - [DllImport ("libdl.so", ExactSpelling = true)] + [DllImport ("libdl.so.2", ExactSpelling = true)] private static extern IntPtr dlerror (); const int RTLD_NOW = 2; diff --git a/ros2_dotnet.repos b/ros2_dotnet_foxy.repos similarity index 100% rename from ros2_dotnet.repos rename to ros2_dotnet_foxy.repos diff --git a/ros2_dotnet_humble.repos b/ros2_dotnet_humble.repos new file mode 100644 index 00000000..ff1307d5 --- /dev/null +++ b/ros2_dotnet_humble.repos @@ -0,0 +1,33 @@ +repositories: + ament_dotnet/ament_cmake_export_assemblies: + type: git + url: https://github.com/esteve/ament_cmake_export_assemblies.git + version: master + ros2/common_interfaces: + type: git + url: https://github.com/ros2/common_interfaces.git + version: humble + ros2/rcl_interfaces: + type: git + url: https://github.com/ros2/rcl_interfaces.git + version: humble + ros2/rosidl_defaults: + type: git + url: https://github.com/ros2/rosidl_defaults.git + version: humble + ros2/test_interface_files: + type: git + url: https://github.com/ros2/test_interface_files.git + version: humble + ros2/unique_identifier_msgs: + type: git + url: https://github.com/ros2/unique_identifier_msgs.git + version: humble + ros2_dotnet/dotnet_cmake_module: + type: git + url: https://github.com/ros2-dotnet/dotnet_cmake_module.git + version: master + ros2_dotnet/ros2_dotnet: + type: git + url: https://github.com/ros2-dotnet/ros2_dotnet.git + version: master