diff --git a/.github/workflows/makefile.yml b/.github/workflows/makefile.yml index c49768e..e088c61 100644 --- a/.github/workflows/makefile.yml +++ b/.github/workflows/makefile.yml @@ -2,59 +2,146 @@ name: C/C++ CI on: push: - branches: [ "master" ] + branches: ["master"] pull_request: - branches: [ "master" ] + branches: ["master"] jobs: - build: + build_on_ubuntu_22_04: runs-on: [ubuntu-22.04] - - steps: - - name: "Checkout" - uses: actions/checkout@v3 - - - name: "Checkout capicxx-core-runtime" - uses: actions/checkout@v3 - with: - repository: COVESA/capicxx-core-runtime - path: 'capicxx-core-runtime' - - - name: "Install dbus and googletest" - run: | - wget http://dbus.freedesktop.org/releases/dbus/dbus-1.13.6.tar.gz - tar -xzf dbus-1.13.6.tar.gz - for patch in src/dbus-patches/*.patch - do - patch -d dbus-1.13.6 -Np1 -i "$PWD/$patch" || continue - done - - cmake -B build-dbus/libdbus -D DBUS_BUILD_TESTS=N -D CMAKE_INSTALL_PREFIX=install -S dbus-1.13.6/cmake - cmake --build build-dbus/libdbus - cmake --install build-dbus/libdbus --strip - - sudo apt-get install libgtest-dev - cd /usr/src/gtest - sudo cmake CMakeLists.txt - sudo make - sudo cp lib/*.a /usr/lib - sudo ln -s /usr/lib/libgtest.a /usr/local/lib/libgtest.a - sudo ln -s /usr/lib/libgtest_main.a /usr/local/lib/libgtest_main.a - - - name: "Build capicxx-core-runtime" - run: | - cmake -S capicxx-core-runtime -B build-core-runtime -D CMAKE_INSTALL_PREFIX=install - cmake --build build-core-runtime --target install - - - name: "Build capicxx-dbus-runtime" - run: | - cmake -S . -B build-dbus-runtime -D GTEST_ROOT=/usr/src/googletest -D CMAKE_PREFIX_PATH=install -D CMAKE_INSTALL_PREFIX=install + + steps: + - name: "Checkout" + uses: actions/checkout@v4 + + - name: "Checkout capicxx-core-runtime" + uses: actions/checkout@v4 + with: + repository: COVESA/capicxx-core-runtime + path: "capicxx-core-runtime" + + - name: "Install dbus" + run: | + wget http://dbus.freedesktop.org/releases/dbus/dbus-1.13.6.tar.gz + tar -xzf dbus-1.13.6.tar.gz + for patch in src/dbus-patches/*.patch + do + patch -d dbus-1.13.6 -Np1 -i "$PWD/$patch" || continue + done + + cmake -B build-dbus/libdbus -D DBUS_BUILD_TESTS=N -D CMAKE_INSTALL_PREFIX=install -S dbus-1.13.6/cmake + cmake --build build-dbus/libdbus + cmake --install build-dbus/libdbus --strip + + - name: "Checkout googletest" + uses: actions/checkout@v4 + with: + repository: google/googletest + ref: v1.12.0 + path: "googletest" + + - name: "Build capicxx-core-runtime" + run: | + cmake -S capicxx-core-runtime -B build-core-runtime -D CMAKE_INSTALL_PREFIX=install + cmake --build build-core-runtime --target install + + - name: "Build capicxx-dbus-runtime" + run: | + cmake -S . -B build-dbus-runtime -D GTEST_ROOT=${{ runner.workspace }}/capicxx-dbus-runtime/googletest -D CMAKE_PREFIX_PATH=install -D CMAKE_INSTALL_PREFIX=install cmake --build build-dbus-runtime --target build_tests cmake --install build-dbus-runtime --strip - - name: "Run tests" - run: | - ls -l ${{ github.workspace }}/install/lib - export LD_LIBRARY_PATH=${{ github.workspace }}/install/lib - export COMMONAPI_CONFIG=${{ github.workspace }}/src/test/commonapi-dbus.ini - env -C build-dbus-runtime ctest -V + - name: "Run tests" + run: | + ls -l ${{ github.workspace }}/install/lib + export LD_LIBRARY_PATH=${{ github.workspace }}/install/lib + export COMMONAPI_CONFIG=${{ github.workspace }}/src/test/commonapi-dbus.ini + env -C build-dbus-runtime ctest -V + + build_on_windows_latest: + runs-on: windows-latest + + steps: + - name: "Checkout" + uses: actions/checkout@v4 + + - name: "Checkout capicxx-core-runtime" + uses: actions/checkout@v4 + with: + repository: COVESA/capicxx-core-runtime + path: "capicxx-core-runtime" + + - name: "Checkout googletest" + uses: actions/checkout@v4 + with: + repository: google/googletest + ref: v1.12.0 + path: "googletest" + + - name: "Checkout expat" + uses: actions/checkout@v4 + with: + repository: libexpat/libexpat + ref: R_2_2_9 + path: "libexpat" + + - name: Windows - Install boost 1.83.0 with gcc and x86 + uses: MarkusJx/install-boost@v2.4.4 + id: windows-gcc-1_83-x86 + with: + boost_version: 1.83.0 + platform: windows + boost_install_dir: C:\runner + toolset: msvc + arch: x86 + cache: true + + - name: "Build expat" + run: | + cmake -A x64 -B build-expat -D CMAKE_INSTALL_PREFIX=${{ runner.workspace }}\install -S ${{ runner.workspace }}\capicxx-dbus-runtime\libexpat\expat + cmake --build build-expat --config Release --target install + + - name: "Install dbus" + run: | + curl -L -o dbus-1.13.6.tar.gz http://dbus.freedesktop.org/releases/dbus/dbus-1.13.6.tar.gz + tar -zxvf dbus-1.13.6.tar.gz + $dbus = "${{ runner.workspace }}\capicxx-dbus-runtime\dbus-1.13.6" + $patches = Get-ChildItem -Path src\dbus-patches -Filter "*.patch" + + foreach ($patch in $patches) { + patch -d $dbus -Np1 -i $patch.FullName + } + + cmake -A x64 -B build-dbus\libdbus -D DBUS_BUILD_TESTS=N -D CMAKE_INSTALL_PREFIX=${{ runner.workspace }}\install -S ${{ runner.workspace }}\capicxx-dbus-runtime\dbus-1.13.6\cmake + cmake --build build-dbus\libdbus --config Release --target install + + - name: "Build capicxx-core-runtime" + run: | + cmake -S capicxx-core-runtime -B build-core-runtime -D BOOST_ROOT=C:\runner\boost -DCMAKE_INSTALL_PREFIX=${{ runner.workspace }}\install + cmake --build build-core-runtime --target install + + - name: "Build capicxx-dbus-runtime" + run: | + cmake -B build-dbus-runtime -D GTEST_ROOT=${{ runner.workspace }}\capicxx-dbus-runtime\googletest -D CMAKE_PREFIX_PATH=${{ runner.workspace }}\install -D CMAKE_INSTALL_PREFIX=${{ runner.workspace }}\install . + cmake --build build-dbus-runtime --target build_tests install + + - name: "Run tests" + run: | + ls -l ${{ runner.workspace }}\install\bin + echo "$env:${{ runner.workspace }}\install\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + ls -l ${{ runner.workspace }}\capicxx-dbus-runtime\build-core-runtime\Debug + echo "$env:${{ runner.workspace }}\capicxx-dbus-runtime\build-core-runtime\Debug" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + ls -l ${{ runner.workspace }}\capicxx-dbus-runtime\build-dbus-runtime\Debug + echo "$env:${{ runner.workspace }}\capicxx-dbus-runtime\build-dbus-runtime\Debug" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + ls -l ${{ runner.workspace }}\install\share\dbus-1 + $dbus_daemon = Start-Job -ScriptBlock { + & ${{ runner.workspace }}\install\bin\dbus-daemon --config-file=${{ runner.workspace }}\install\share\dbus-1\session.conf --nofork --print-address + } + Start-Sleep -Seconds 1 + $env:DBUS_SESSION_BUS_ADDRESS = Receive-Job $dbus_daemon + try { + ctest --test-dir ${{ runner.workspace }}\capicxx-dbus-runtime\build-core-runtime -V + exit $LASTEXITCODE + } finally { + Stop-Job $dbus_daemon + } diff --git a/CMakeLists.txt b/CMakeLists.txt index be200ff..72e5209 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -138,31 +138,13 @@ message(STATUS "CommonAPI Version: ${CommonAPI_VERSION}") ############################################################################### # find DBus by using the 'pkg-config' tool -if (MSVC) - #Not beautiful, but it works - if (DBus_DIR) - if (DBus_BUILD_DIR) - set(DBus_INCLUDE_DIRS "${DBus_DIR};${DBus_BUILD_DIR};") - set(DBus_LIBRARY_RELEASE "${DBus_BUILD_DIR}/bin/Release/dbus-1.lib") - set(DBus_LIBRARY_DEBUG "${DBus_BUILD_DIR}/bin/Debug/dbus-1d.lib") - endif() - endif() - - if (NOT DBus_LIBRARIES) - include(SelectLibraryConfigurations) - select_library_configurations(DBus) - endif() - if (NOT DBus_INCLUDE_DIRS OR NOT DBus_LIBRARIES) - message(SEND_ERROR "Set DBus_INCLUDE_DIRS and DBus_LIBRARIES to your D-Bus installation (e.g. cmake -DDBus_INCLUDE_DIRS=C:\\D-Bus\\include -DDBus_LIBRARIES=C:\\DBus\\lib\\dbus-1.lib") - endif() +if ("${USE_INSTALLED_DBUS}" STREQUAL "ON") + FIND_PACKAGE(DBus1 1.4 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY) else() - if ("${USE_INSTALLED_DBUS}" STREQUAL "ON") - FIND_PACKAGE(DBus1 1.4 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY) - else() - FIND_PACKAGE(DBus1 1.4 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) - endif() + FIND_PACKAGE(DBus1 1.4 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) endif() +message(STATUS "DBus1_INCLUDE_DIRS: ${DBus1_INCLUDE_DIRS}") ############################################################################## # CommonAPI-DBus build section @@ -182,6 +164,7 @@ message(STATUS "Compiler options: ${CMAKE_CXX_FLAGS}") include_directories( include ${COMMONAPI_INCLUDE_DIRS} + ${DBus1_INCLUDE_DIRS} ) # DBus source files