Skip to content

<TBBAS-1840> Add CI for Linux-gcc #36

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

Closed
wants to merge 2 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
127 changes: 127 additions & 0 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform.
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml
name: CMake on multiple platforms

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build_linux:
runs-on: ${{ matrix.os }}
timeout-minutes: 180

strategy:
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
fail-fast: false

matrix:
os: [ubuntu-latest]
build_type: [Release]
#c_compiler: [gcc, clang]
c_compiler: [gcc]
include:
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
# - os: ubuntu-latest
# c_compiler: clang
# cpp_compiler: clang++

steps:
- name: Install basic dependencies
run: |
sudo apt-get update
sudo apt-get install -y libpcap-dev

- uses: actions/checkout@v4

- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
known_hosts: ${{ secrets.KNOWN_HOSTS }}
if_key_exists: fail # replace / ignore / fail; optional (defaults to fail)

- name: Set reusable strings
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DASAM_CMP_ENABLE_EXAMPLE=OFF
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-S ${{ github.workspace }}

- name: Build
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}

- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest --build-config ${{ matrix.build_type }}

# build_windows:
# runs-on: ${{ matrix.os }}

# strategy:
# # Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
# fail-fast: false

# matrix:
# os: [windows-latest]
# build_type: [Release]
# c_compiler: [cl]
# include:
# - os: windows-latest
# c_compiler: cl
# cpp_compiler: cl

# steps:
# - uses: actions/checkout@v4

# - name: Install SSH key
# uses: shimataro/ssh-key-action@v2
# with:
# key: ${{ secrets.SSH_KEY }}
# known_hosts: ${{ secrets.KNOWN_HOSTS }}
# if_key_exists: fail # replace / ignore / fail; optional (defaults to fail)

# - name: Set reusable strings
# # Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
# id: strings
# shell: bash
# run: |
# echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"

# - name: Configure CMake
# # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
# run: >
# cmake -B ${{ steps.strings.outputs.build-output-dir }}
# -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
# -DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
# -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
# -S ${{ github.workspace }}

# - name: Build
# # Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}

# - name: Test
# working-directory: ${{ steps.strings.outputs.build-output-dir }}
# # Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
# run: ctest --build-config ${{ matrix.build_type }}
14 changes: 9 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,24 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(AsamCommonUtils)
setup_repo(${REPO_OPTION_PREFIX})

if (${REPO_OPTION_PREFIX}_ENABLE_TESTS)
enable_testing()
endif()

if (${REPO_OPTION_PREFIX}_ENABLE_EXAMPLE)
set(DAQMODULES_REF_DEVICE_MODULE ON)
set(DAQMODULES_REF_FB_MODULE ON)
set(DAQMODULES_REF_DEVICE_MODULE ON)
set(DAQMODULES_REF_FB_MODULE ON)

add_subdirectory(asam_cmp_example)
add_subdirectory(asam_cmp_example)
endif()

add_subdirectory(external)
add_subdirectory(asam_cmp_common_lib)

if (${REPO_OPTION_PREFIX}_BUILD_CAPTURE_MODULE)
add_subdirectory(asam_cmp_capture_module)
add_subdirectory(asam_cmp_capture_module)
endif()

if (${REPO_OPTION_PREFIX}_BUILD_DATA_SINK)
add_subdirectory(asam_cmp_data_sink)
add_subdirectory(asam_cmp_data_sink)
endif()
64 changes: 32 additions & 32 deletions asam_cmp_common_lib/include/asam_cmp_common_lib/capture_common_fb.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,52 +95,52 @@ void CaptureCommonFbImpl<Interfaces...>::initProperties()
.setMinValue(static_cast<Int>(std::numeric_limits<uint16_t>::min()))
.setMaxValue(static_cast<Int>(std::numeric_limits<uint16_t>::max()))
.build();
objPtr.addProperty(prop);
objPtr.getOnPropertyValueWrite(propName) +=
this->objPtr.addProperty(prop);
this->objPtr.getOnPropertyValueWrite(propName) +=
[this](PropertyObjectPtr& obj, PropertyValueEventArgsPtr& args) { propertyChangedIfNotUpdating(); };

propName = "AddInterface";
prop = FunctionPropertyBuilder(propName, ProcedureInfo(List<IArgumentInfo>())).setReadOnly(true).build();
objPtr.addProperty(prop);
objPtr.asPtr<IPropertyObjectProtected>().setProtectedPropertyValue(propName, Procedure([this] { addInterface(); }));
this->objPtr.addProperty(prop);
this->objPtr.template asPtr<IPropertyObjectProtected>().setProtectedPropertyValue(propName, Procedure([this] { addInterface(); }));

propName = "RemoveInterface";
prop = FunctionPropertyBuilder(propName, ProcedureInfo(List<IArgumentInfo>(ArgumentInfo("nInd", ctInt)))).setReadOnly(true).build();
objPtr.addProperty(prop);
objPtr.asPtr<IPropertyObjectProtected>().setProtectedPropertyValue(propName, Procedure([this](IntPtr nInd) { removeInterface(nInd); }));
this->objPtr.addProperty(prop);
this->objPtr.template asPtr<IPropertyObjectProtected>().setProtectedPropertyValue(propName, Procedure([this](IntPtr nInd) { removeInterface(nInd); }));
}

template <typename... Interfaces>
void CaptureCommonFbImpl<Interfaces...>::initDeviceInfoProperties(bool readOnly)
{
StringPtr propName = "DeviceDescription";
auto prop = StringPropertyBuilder(propName, "").setReadOnly(readOnly).build();
objPtr.addProperty(prop);
objPtr.getOnPropertyValueWrite(propName) +=
this->objPtr.addProperty(prop);
this->objPtr.getOnPropertyValueWrite(propName) +=
[this](PropertyObjectPtr& obj, PropertyValueEventArgsPtr& args) { propertyChangedIfNotUpdating(); };

propName = "SerialNumber";
prop = StringPropertyBuilder(propName, "").setReadOnly(readOnly).build();
objPtr.addProperty(prop);
objPtr.getOnPropertyValueWrite(propName) +=
this->objPtr.addProperty(prop);
this->objPtr.getOnPropertyValueWrite(propName) +=
[this](PropertyObjectPtr& obj, PropertyValueEventArgsPtr& args) { propertyChangedIfNotUpdating(); };

propName = "HardwareVersion";
prop = StringPropertyBuilder(propName, "").setReadOnly(readOnly).build();
objPtr.addProperty(prop);
objPtr.getOnPropertyValueWrite(propName) +=
this->objPtr.addProperty(prop);
this->objPtr.getOnPropertyValueWrite(propName) +=
[this](PropertyObjectPtr& obj, PropertyValueEventArgsPtr& args) { propertyChangedIfNotUpdating(); };

propName = "SoftwareVersion";
prop = StringPropertyBuilder(propName, "").setReadOnly(readOnly).build();
objPtr.addProperty(prop);
objPtr.getOnPropertyValueWrite(propName) +=
this->objPtr.addProperty(prop);
this->objPtr.getOnPropertyValueWrite(propName) +=
[this](PropertyObjectPtr& obj, PropertyValueEventArgsPtr& args) { propertyChangedIfNotUpdating(); };

propName = "VendorData";
prop = StringPropertyBuilder(propName, "").setReadOnly(readOnly).build();
objPtr.addProperty(prop);
objPtr.getOnPropertyValueWrite(propName) +=
this->objPtr.addProperty(prop);
this->objPtr.getOnPropertyValueWrite(propName) +=
[this](PropertyObjectPtr& obj, PropertyValueEventArgsPtr& args) { propertyChangedIfNotUpdating(); };
}

Expand All @@ -153,8 +153,8 @@ FunctionBlockPtr CaptureCommonFbImpl<Interfaces...>::addInterfaceWithParams(uint
InterfaceCommonInit init{interfaceId, &interfaceIdManager, &streamIdManager};

StringPtr fbId = fmt::format("asam_cmp_interface_{}", createdInterfaces++);
auto newFb = createWithImplementation<IFunctionBlock, Impl>(context, functionBlocks, fbId, init, std::forward<Params>(params)...);
functionBlocks.addItem(newFb);
auto newFb = createWithImplementation<IFunctionBlock, Impl>(this->context, this->functionBlocks, fbId, init, std::forward<Params>(params)...);
this->functionBlocks.addItem(newFb);
interfaceIdManager.addId(interfaceId);

return newFb;
Expand All @@ -163,31 +163,31 @@ FunctionBlockPtr CaptureCommonFbImpl<Interfaces...>::addInterfaceWithParams(uint
template <typename... Interfaces>
void CaptureCommonFbImpl<Interfaces...>::addInterface()
{
std::scoped_lock lock{sync};
std::scoped_lock lock{this->sync};
addInterfaceInternal();
}

template <typename... Interfaces>
void CaptureCommonFbImpl<Interfaces...>::removeInterface(size_t nInd)
{
std::scoped_lock lock{sync};
std::scoped_lock lock{this->sync};
removeInterfaceInternal(nInd);
}

template <typename... Interfaces>
void CaptureCommonFbImpl<Interfaces...>::updateDeviceIdInternal()
{
deviceId = objPtr.getPropertyValue("DeviceId");
deviceId = this->objPtr.getPropertyValue("DeviceId");
}

template <typename... Interfaces>
void CaptureCommonFbImpl<Interfaces...>::updateDeviceInfoInternal()
{
deviceDescription = objPtr.getPropertyValue("DeviceDescription");
serialNumber = objPtr.getPropertyValue("SerialNumber");
hardwareVersion = objPtr.getPropertyValue("HardwareVersion");
softwareVersion = objPtr.getPropertyValue("SoftwareVersion");
vendorDataAsString = objPtr.getPropertyValue("VendorData").asPtr<IString>().toStdString();
deviceDescription = this->objPtr.getPropertyValue("DeviceDescription");
serialNumber = this->objPtr.getPropertyValue("SerialNumber");
hardwareVersion = this->objPtr.getPropertyValue("HardwareVersion");
softwareVersion = this->objPtr.getPropertyValue("SoftwareVersion");
vendorDataAsString = this->objPtr.getPropertyValue("VendorData").template asPtr<IString>().toStdString();
vendorData = std::vector<uint8_t>(begin(vendorDataAsString), end(vendorDataAsString));
}

Expand All @@ -197,14 +197,14 @@ void CaptureCommonFbImpl<Interfaces...>::removeInterfaceInternal(size_t nInd)
if (isUpdating)
throw std::runtime_error("Removing interfaces is disabled during update");

interfaceIdManager.removeId(functionBlocks.getItems().getItemAt(nInd).getPropertyValue("InterfaceId"));
functionBlocks.removeItem(functionBlocks.getItems().getItemAt(nInd));
interfaceIdManager.removeId(this->functionBlocks.getItems().getItemAt(nInd).getPropertyValue("InterfaceId"));
this->functionBlocks.removeItem(this->functionBlocks.getItems().getItemAt(nInd));
}

template <typename... Interfaces>
daq::ErrCode CaptureCommonFbImpl<Interfaces...>::beginUpdate()
{
daq::ErrCode result = FunctionBlockImpl::beginUpdate();
daq::ErrCode result = FunctionBlockImpl<IFunctionBlock, Interfaces...>::beginUpdate();
if (result == OPENDAQ_SUCCESS)
isUpdating = true;

Expand All @@ -214,8 +214,8 @@ daq::ErrCode CaptureCommonFbImpl<Interfaces...>::beginUpdate()
template <typename... Interfaces>
inline daq::ErrCode INTERFACE_FUNC CaptureCommonFbImpl<Interfaces...>::endUpdate()
{
std::scoped_lock lock{sync};
auto result = FunctionBlockImpl::endUpdate();
std::scoped_lock lock{this->sync};
auto result = FunctionBlockImpl<IFunctionBlock, Interfaces...>::endUpdate();

if (needsPropertyChanged)
{
Expand All @@ -240,7 +240,7 @@ void CaptureCommonFbImpl<Interfaces...>::propertyChangedIfNotUpdating()
{
if (!isUpdating)
{
std::scoped_lock lock{sync};
std::scoped_lock lock{this->sync};
propertyChanged();
}
else
Expand Down
14 changes: 0 additions & 14 deletions asam_cmp_common_lib/tests/test_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
#include <testutils/bb_memcheck_listener.h>
#include <coreobjects/util.h>
#include <opendaq/module_manager_init.h>
#include <asam_cmp_data_sink/module_dll.h>
#include <opendaq/context_factory.h>
#include <iostream>

int main(int argc, char** args)
{
Expand All @@ -15,17 +12,6 @@ int main(int argc, char** args)

testing::InitGoogleTest(&argc, args);

try
{
ModulePtr module;
createModule(&module, NullContext());
module.createFunctionBlock("asam_cmp_data_sink_module", nullptr, "id");
}
catch (std::exception& e)
{
std::cerr << e.what();
}

testing::TestEventListeners& listeners = testing::UnitTest::GetInstance()->listeners();
listeners.Append(new DaqMemCheckListener());

Expand Down