Skip to content

Commit

Permalink
efe
Browse files Browse the repository at this point in the history
  • Loading branch information
wardru committed Dec 10, 2023
1 parent e4c055d commit 89d3a1e
Show file tree
Hide file tree
Showing 14 changed files with 3,080 additions and 47 deletions.
60 changes: 37 additions & 23 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,15 @@ jobs:
runs-on: ubuntu-latest
container:
image: ghcr.io/panduza/pzacxx-build-img:latest
options: --user 1001
strategy:
fail-fast: false
matrix:
os: [linux]
compiler: [gcc]
build_type: [Debug]
shared: ["True", "False"]
os: [linux, windows]
compiler: [gcc, clang]
build_type: [debug, release]
lib_type: [shared, static]
exclude:
- os: linux
compiler: mingw
- os: win
compiler: gcc
- os: win
- os: windows
compiler: clang
steps:
- name: Checkout
Expand All @@ -30,23 +26,41 @@ jobs:
run: pacman -S --noconfirm nodejs

- name: "cache"
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.conan2/p
key: conan-cache-${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.build_type }}-${{ matrix.shared }}
key: conan-cache-${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.build_type }}-${{ matrix.lib_type }}

- name: "Install"
run:
conan install -pr:b ./conan_profiles/linux_gcc -pr:h ./conan_profiles/${{ matrix.os }}_${{ matrix.compiler }} --build=missing -s build_type=${{ matrix.build_type }} -o shared=${{ matrix.shared }} .
- id: build_type
uses: ASzc/change-string-case-action@v6
with:
string: ${{ matrix.build_type }}

- name: "Install dependencies"
run: |
if [ "${{ matrix.lib_type }}" = "static" ]; then
shared="False"
else
shared="True"
fi
conan install -pr:b ./conan_profiles/linux_gcc -pr:h ./conan_profiles/${{ matrix.os }}_${{ matrix.compiler }} --build=missing -s build_type=${{ steps.build_type.outputs.capitalized }} -o shared=$shared .
- name: "Build"
- name: "Build for ${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.lib_type }}-${{ matrix.build_type }}"
run: |
if [ "${{ matrix.shared }}" = "True" ]; then
lib_type="shared"
if [ "${{ matrix.compiler }}" = "clang" ] && [ "${{ matrix.build_type }}" = "debug" ] && [ "${{ matrix.lib_type }}" = "shared" ]; then
tidy="True"
else
lib_type="static"
tidy="False"
fi
ls -l build
echo "build folder: ./build/${{ matrix.os }}-${{ matrix.compiler }}-$lib_type"
cmake --preset ${{ matrix.os }}-${{ matrix.compiler }}-$lib_type
cmake --build ./build/${{ matrix.os }}-${{ matrix.compiler }}-$lib_type --config ${{ matrix.build_type }}
cmake --preset ${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.lib_type }} -DWITH_TIDY=$tidy
cmake --build --preset ${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.lib_type }}-${{ matrix.build_type }}
- name: "Test for ${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.lib_type }}-${{ matrix.build_type }}"
run: |
echo "Test for ${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.lib_type }}-${{ matrix.build_type }}"
- name: "Coverage"
if: ${{ matrix.os == 'linux' && matrix.compiler == 'gcc' && matrix.build_type == 'debug' && matrix.lib_type == 'static' }}
run: |
echo "Coverage for ${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.lib_type }}-${{ matrix.build_type }}"
3,022 changes: 3,022 additions & 0 deletions 1

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ set(LIBRARY_NAME pzacxx)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

include(cmake/tidy.cmake)
include(cmake/format.cmake)
include(cmake/compiler.cmake)
include(cmake/format.cmake)
include(cmake/lib.cmake)

find_package(spdlog REQUIRED)
Expand All @@ -24,7 +23,7 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)

add_subdirectory(source)

option(BUILD_EXAMPLES "Build examples" OFF)
if (BUILD_EXAMPLES)
option(WITH_EXAMPLES "Build examples" OFF)
if (WITH_EXAMPLES)
add_subdirectory(examples)
endif()
7 changes: 7 additions & 0 deletions cmake/compiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,10 @@ endif()
if (CMAKE_SYSTEM_NAME MATCHES "Windows" AND NOT BUILD_SHARED_LIBS)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
endif()

option(WITH_TIDY "Enable clang-tidy" OFF)
if (WITH_TIDY)
find_program(CLANG_TIDY_EXECUTABLE clang-tidy REQUIRED)
set(CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY_EXECUTABLE})
set(CMAKE_C_CLANG_TIDY ${CLANG_TIDY_EXECUTABLE})
endif()
4 changes: 0 additions & 4 deletions cmake/tidy.cmake

This file was deleted.

File renamed without changes.
7 changes: 2 additions & 5 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ class PzaCxx(ConanFile):
name = "libpza-cxx"
settings = "os", "compiler", "build_type", "arch"
options = {
"shared": [True, False],
"build_examples": [True, False]
"shared": [True, False]
}
default_options = {
"shared": True,
"build_examples": True
"shared": True
}

def requirements(self):
Expand All @@ -32,7 +30,6 @@ def configure(self):
def generate(self):
tc = CMakeToolchain(self)
tc.generator = "Ninja Multi-Config"
tc.variables["BUILD_EXAMPLES"] = self.options.build_examples
tc.filename = "pzacxx_toolchain.cmake"
tc.user_presets_path = 'ConanPresets.json'
tc.presets_prefix = ""
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ USER root
RUN ln -s /usr/x86_64-w64-mingw32/lib/librpcrt4.a /usr/x86_64-w64-mingw32/lib/libRpcRT4.a
RUN userdel -r mingw

RUN git config --global --add safe.directory '*'
RUN git config --system --add safe.directory '*'
2 changes: 1 addition & 1 deletion include/pza/core/interface.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public:
itf_base(itf_base &&) = delete;
itf_base &operator=(itf_base &&) = delete;

[[nodiscard]] const std::string &get_name() const;
const std::string &get_name() const;
[[nodiscard]] const std::string &get_type() const;

protected:
Expand Down
6 changes: 3 additions & 3 deletions include/pza/interfaces/device.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public:
device &operator=(device &&) = delete;
~device() override;

const std::string &get_model();
const std::string &get_manufacturer();
const std::string &get_family();
[[nodiscard]] const std::string &get_model() const;
[[nodiscard]] const std::string &get_manufacturer() const;
[[nodiscard]] const std::string &get_family() const;

private:
attribute_ptr _identity;
Expand Down
2 changes: 0 additions & 2 deletions source/core/attribute.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ void attribute::on_message(mqtt::const_message_ptr msg)
}
}

void attribute::register_callback(const std::function<void(void)> &cb) { _callbacks.push_back(cb); }

void attribute::remove_callback(const std::function<void(void)> &cb)
{
_callbacks.remove_if([&](const std::function<void(void)> &f) {
Expand Down
2 changes: 1 addition & 1 deletion source/core/attribute.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public:

void on_message(mqtt::const_message_ptr msg);

void register_callback(const std::function<void(void)> &cb);
void register_callback(const std::function<void(void)> &cb) { _callbacks.push_back(cb); }
void remove_callback(const std::function<void(void)> &cb);

void set_msg_callback(const std::function<int(const nlohmann::json &data)> &cb) { _msg_cb = cb; }
Expand Down
6 changes: 3 additions & 3 deletions source/interfaces/device.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ device::device(mqtt_service *mqtt, itf_info &info)

device::~device() = default;

const std::string &device::get_model() { return _identity->get_field<std::string>("model"); }
const std::string &device::get_model() const { return _identity->get_field<std::string>("model"); }

const std::string &device::get_manufacturer() { return _identity->get_field<std::string>("manufacturer"); }
const std::string &device::get_manufacturer() const { return _identity->get_field<std::string>("manufacturer"); }

const std::string &device::get_family() { return _identity->get_field<std::string>("family"); }
const std::string &device::get_family() const { return _identity->get_field<std::string>("family"); }
Empty file added toto
Empty file.

0 comments on commit 89d3a1e

Please sign in to comment.