Skip to content

Commit

Permalink
[eclipse-iceoryx#264] Add out-of-tree build for C++ examples and run …
Browse files Browse the repository at this point in the history
…tests
  • Loading branch information
elBoberido committed Jul 4, 2024
1 parent 41dcd94 commit 90bb6b2
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 23 deletions.
18 changes: 12 additions & 6 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,23 +86,29 @@ iox2_common_build_and_test_no_doc_tests_release_template: &IOX2_COMMON_BUILD_AND

iox2_ffi_common_debug_template: &IOX2_FFI_COMMON_DEBUG
ffi_script:
- cmake -S . -B target/ffi/build -DCMAKE_INSTALL_PREFIX=target/ffi/install -DBUILD_EXAMPLES=ON -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Debug
- ./internal/scripts/ci_build_and_install_iceoryx_hoofs.sh
- cmake -S . -B target/ffi/build -DCMAKE_BUILD_TYPE=Debug -DBUILD_EXAMPLES=ON -DBUILD_TESTING=ON -DCMAKE_INSTALL_PREFIX=target/ffi/install -DCMAKE_INSTALL_PREFIX="$( pwd )/target/iceoryx/install"
- cmake --build target/ffi/build
- cmake --install target/ffi/build
- target/ffi/build/tests/iceoryx2-c-tests
- rm -rf target/ffi/build
- cmake -S examples/c -B target/ffi/out-of-tree -DCMAKE_PREFIX_PATH=$( pwd )/target/ffi/install -DCMAKE_BUILD_TYPE=Debug
- cmake --build target/ffi/out-of-tree
- cmake -S examples/c -B target/ffi/out-of-tree-c -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH="$( pwd )/target/ffi/install;$( pwd )/target/iceoryx/install"
- cmake --build target/ffi/out-of-tree-c
- cmake -S examples/cxx -B target/ffi/out-of-tree-cxx -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH="$( pwd )/target/ffi/install;$( pwd )/target/iceoryx/install"
- cmake --build target/ffi/out-of-tree-cxx

iox2_ffi_common_release_template: &IOX2_FFI_COMMON_RELEASE
ffi_script:
- cmake -S . -B target/ffi/build -DCMAKE_INSTALL_PREFIX=target/ffi/install -DBUILD_EXAMPLES=ON -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Release
- ./internal/scripts/ci_build_and_install_iceoryx_hoofs.sh
- cmake -S . -B target/ffi/build -DCMAKE_BUILD_TYPE=Release -DBUILD_EXAMPLES=ON -DBUILD_TESTING=ON -DCMAKE_INSTALL_PREFIX=target/ffi/install -DCMAKE_INSTALL_PREFIX="$( pwd )/target/iceoryx/install"
- cmake --build target/ffi/build
- cmake --install target/ffi/build
- target/ffi/build/tests/iceoryx2-c-tests
- rm -rf target/ffi/build
- cmake -S examples/c -B target/ffi/out-of-tree -DCMAKE_PREFIX_PATH="$( pwd )/target/ffi/install" -DCMAKE_BUILD_TYPE=Release
- cmake --build target/ffi/out-of-tree
- cmake -S examples/c -B target/ffi/out-of-tree-c -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$( pwd )/target/ffi/install;$( pwd )/target/iceoryx/install"
- cmake --build target/ffi/out-of-tree-c
- cmake -S examples/cxx -B target/ffi/out-of-tree-cxx -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$( pwd )/target/ffi/install;$( pwd )/target/iceoryx/install"
- cmake --build target/ffi/out-of-tree-cxx

iox2_freebsd_setup_template: &IOX2_FREEBSD_SETUP
setup_script:
Expand Down
25 changes: 20 additions & 5 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,13 @@ jobs:
- name: Run cargo nextest
run: cargo nextest run --workspace --no-fail-fast ${{ matrix.mode.arg }}

- name: Build iceoryx_hoofs on Windows
if: ${{ matrix.os == 'windows-latest' }}
run: echo "TODO 262 create bat or powershell file"
- name: Build iceoryx_hoofs on non-Windows
if: ${{ matrix.os != 'windows-latest' }}
run: internal/scripts/ci_build_and_install_iceoryx_hoofs.sh

- name: Print native libs of FFI target
if: false # This step takes 1 to 2 minutes; only enable if there are linker issues with the FFI target
run: |
Expand All @@ -245,24 +252,32 @@ jobs:
- name: Build language bindings
run: |
cmake -S . -B target/ffi/build -DCMAKE_INSTALL_PREFIX=target/ffi/install -DBUILD_EXAMPLES=ON -DBUILD_TESTING=ON ${{ matrix.mode.cmake-build-type }} ${{ matrix.cmake-build-system-generator }}
cmake -S . -B target/ffi/build -DBUILD_EXAMPLES=ON -DBUILD_TESTING=ON ${{ matrix.mode.cmake-build-type }} ${{ matrix.cmake-build-system-generator }} -DCMAKE_INSTALL_PREFIX=target/ffi/install -DCMAKE_PREFIX_PATH="${{ github.workspace }}/target/iceoryx/install"
cmake --build target/ffi/build ${{ matrix.mode.cmake-build-config }}
cmake --install target/ffi/build ${{ matrix.mode.cmake-build-config }}
- name: Run language binding tests
- name: Run C language binding tests
run: target/ffi/build/tests/iceoryx2-c-tests

- name: Run C++ language binding tests
run: target/ffi/build/tests/iceoryx2-cxx-tests

- name: Remove language binding build artifacts on Windows
if: ${{ matrix.os == 'windows-latest' }}
run: rm -r -force target/ffi/build
- name: Remove language binding build artifacts on non-Windows
if: ${{ matrix.os != 'windows-latest' }}
run: rm -rf target/ffi/build

- name: Build language binding examples in out-of-tree configuration
- name: Build C language binding examples in out-of-tree configuration
run: |
cmake -S examples/c -B target/ffi/out-of-tree-c ${{ matrix.mode.cmake-build-type }} ${{ matrix.cmake-build-system-generator }} -DCMAKE_PREFIX_PATH="${{ github.workspace }}/target/ffi/install"
cmake --build target/ffi/out-of-tree-c ${{ matrix.mode.cmake-build-config }}
- name: Build C++ language binding examples in out-of-tree configuration
run: |
cmake -S examples/c -B target/ffi/out-of-tree -DCMAKE_PREFIX_PATH=${{ github.workspace }}/target/ffi/install ${{ matrix.mode.cmake-build-type }} ${{ matrix.cmake-build-system-generator }}
cmake --build target/ffi/out-of-tree ${{ matrix.mode.cmake-build-config }}
cmake -S examples/cxx -B target/ffi/out-of-tree-cxx ${{ matrix.mode.cmake-build-type }} ${{ matrix.cmake-build-system-generator }} -DCMAKE_PREFIX_PATH="${{ github.workspace }}/target/ffi/install;${{ github.workspace }}/target/iceoryx/install"
cmake --build target/ffi/out-of-tree-cxx ${{ matrix.mode.cmake-build-config }}
x86_64_unstable:
needs: [preflight-check, static-code-analysis, cargo-nextest]
Expand Down
18 changes: 9 additions & 9 deletions iceoryx2-ffi/cxx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,28 @@ with `-DCMAKE_PREFIX_PATH`.
`iceoryx_hoofs` can be build with this steps:

```bash
git clone https://github.com/eclipse-iceoryx/iceoryx.git target/ffi/dep/iceoryx
git clone https://github.com/eclipse-iceoryx/iceoryx.git target/iceoryx/src

cmake -S target/ffi/dep/iceoryx/iceoryx_platform -B target/ffi/dep/build/platform -DCMAKE_INSTALL_PREFIX=target/ffi/dep/install
cmake --build target/ffi/dep/build/platform
cmake --install target/ffi/dep/build/platform
cmake -S target/iceoryx/src/iceoryx_platform -B -DCMAKE_BUILD_TYPE=Release target/iceoryx/build/platform -DCMAKE_INSTALL_PREFIX=target/iceoryx/install
cmake --build target/iceoryx/build/platform
cmake --install target/iceoryx/build/platform

cmake -S target/ffi/dep/iceoryx/iceoryx_hoofs -B target/ffi/dep/build/hoofs -DCMAKE_INSTALL_PREFIX=target/ffi/dep/install -DCMAKE_PREFIX_PATH="$( pwd )/target/ffi/dep/install"
cmake --build target/ffi/dep/build/hoofs
cmake --install target/ffi/dep/build/hoofs
cmake -S target/iceoryx/src/iceoryx_hoofs -B target/iceoryx/build/hoofs -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=target/iceoryx/install -DCMAKE_PREFIX_PATH="$( pwd )/target/iceoryx/install"
cmake --build target/iceoryx/build/hoofs
cmake --install target/iceoryx/build/hoofs
```

The C++ bindings can use the installed `iceoryx_hoofs` and be installed to be used by custom projects. This are the steps:

```bash
cmake -S . -B target/ffi/build -DCMAKE_INSTALL_PREFIX=target/ffi/install -DCMAKE_PREFIX_PATH="$( pwd )/target/ffi/dep/install"
cmake -S . -B target/ffi/build -DCMAKE_INSTALL_PREFIX=target/ffi/install -DCMAKE_PREFIX_PATH="$( pwd )/target/iceoryx/install"
cmake --build target/ffi/build
cmake --install target/ffi/build
```

The installed libraries can the be used for out-of-tree builds of the example or custom C++ projects. This are the required steps:

```bash
cmake -S examples/cxx -B target/out-of-tree/examples/cxx -DCMAKE_PREFIX_PATH="$( pwd )/target/ffi/dep/install;$( pwd )/target/ffi/install"
cmake -S examples/cxx -B target/out-of-tree/examples/cxx -DCMAKE_PREFIX_PATH="$( pwd )/target/ffi/install;$( pwd )/target/iceoryx/install"
cmake --build target/out-of-tree/examples/cxx
```
31 changes: 31 additions & 0 deletions internal/scripts/ci_build_and_install_iceoryx_hoofs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright (c) 2024 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache Software License 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0, or the MIT license
# which is available at https://opensource.org/licenses/MIT.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT

#!/bin/sh

set -e

echo "#######################"
echo "# Build iceoryx_hoofs #"
echo "#######################"

cd $(git rev-parse --show-toplevel)

git clone --depth 1 --branch main https://github.com/eclipse-iceoryx/iceoryx.git target/iceoryx/src

cmake -S target/iceoryx/src/iceoryx_platform -B target/iceoryx/build/platform -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=target/iceoryx/install
cmake --build target/iceoryx/build/platform
cmake --install target/iceoryx/build/platform

cmake -S target/iceoryx/src/iceoryx_hoofs -B target/iceoryx/build/hoofs -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=target/iceoryx/install -DCMAKE_PREFIX_PATH="$( pwd )/target/iceoryx/install"
cmake --build target/iceoryx/build/hoofs
cmake --install target/iceoryx/build/hoofs
12 changes: 9 additions & 3 deletions internal/scripts/ci_build_and_test_freebsd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ while (( "$#" )); do
esac
done

cd $(git rev-parse --show-toplevel)

export PATH=$PATH:$HOME/.cargo/bin
export LIBCLANG_PATH=/usr/local/llvm15/lib/
Expand All @@ -73,7 +74,9 @@ echo "###########################"
echo "# Build language bindings #"
echo "###########################"

cmake -S . -B target/ffi/build -DCMAKE_INSTALL_PREFIX=target/ffi/install $CMAKE_BUILD_TYPE_FLAG -DBUILD_EXAMPLES=ON -DBUILD_TESTING=ON
./internal/scripts/ci_build_and_install_iceoryx_hoofs.sh

cmake -S . -B target/ffi/build $CMAKE_BUILD_TYPE_FLAG -DBUILD_EXAMPLES=ON -DBUILD_TESTING=ON -DCMAKE_INSTALL_PREFIX=target/ffi/install -DCMAKE_PREFIX_PATH="$( pwd )/target/iceoryx/install"
cmake --build target/ffi/build
cmake --install target/ffi/build

Expand All @@ -88,5 +91,8 @@ echo "# Build language binding examples in out-of-tree configuration #"
echo "################################################################"

rm -rf target/ffi/build
cmake -S examples/c -B target/ffi/out-of-tree -DCMAKE_PREFIX_PATH=$( pwd )/target/ffi/install $CMAKE_BUILD_TYPE_FLAG
cmake --build target/ffi/out-of-tree
cmake -S examples/c -B target/ffi/out-of-tree-c $CMAKE_BUILD_TYPE_FLAG -DCMAKE_PREFIX_PATH="$( pwd )/target/ffi/install"
cmake --build target/ffi/out-of-tree-c

cmake -S examples/cxx -B target/ffi/out-of-tree-cxx $CMAKE_BUILD_TYPE_FLAG -DCMAKE_PREFIX_PATH="$( pwd )/target/ffi/install;$( pwd )/target/iceoryx/install"
cmake --build target/ffi/out-of-tree-cxx

0 comments on commit 90bb6b2

Please sign in to comment.