Skip to content

Commit

Permalink
Merge pull request #9 from bw-hro/macos-support
Browse files Browse the repository at this point in the history
macOS support
  • Loading branch information
bw-hro authored Oct 17, 2024
2 parents f08b9a8 + fc9f33f commit aa1865d
Show file tree
Hide file tree
Showing 33 changed files with 88 additions and 30 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: macOS

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

jobs:
build-and-test:
runs-on: macos-latest

steps:
- uses: actions/checkout@v4

- name: Setup vcpkg
run: |
chmod +x ./tools/install-vcpkg.sh
./tools/install-vcpkg.sh
- name: Build
run: |
chmod +x ./build.sh
./build.sh clean release
chmod +x ./build/examples/single-thing
chmod +x ./build/examples/multiple-things
chmod +x ./build/examples/gui-thing
chmod +x ./build/test/tests
- name: Integration tests
working-directory: ${{github.workspace}}/tools
run: |
chmod +x ./run-webthing-tester.sh
./run-webthing-tester.sh
- name: Upload binaries
uses: actions/upload-artifact@v4
with:
name: binaries
path: |
./build/examples/single-thing
./build/examples/multiple-things
./build/examples/gui-thing
./build/test/tests
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.1)
cmake_policy(SET CMP0091 NEW)
project(Webthing-CPP VERSION 1.0.4 DESCRIPTION "Webthing implementation for C++" LANGUAGES CXX)
project(Webthing-CPP VERSION 1.0.5 DESCRIPTION "Webthing implementation for C++" LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)

IF(WIN32)
Expand Down
2 changes: 1 addition & 1 deletion examples/gui-html.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Webthing-CPP
// SPDX-FileCopyrightText: 2023-2024 Benno Waldhauer
// SPDX-FileCopyrightText: 2023-present Benno Waldhauer
// SPDX-License-Identifier: MIT

#pragma once
Expand Down
2 changes: 1 addition & 1 deletion examples/gui-thing.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Webthing-CPP
// SPDX-FileCopyrightText: 2023-2024 Benno Waldhauer
// SPDX-FileCopyrightText: 2023-present Benno Waldhauer
// SPDX-License-Identifier: MIT

#include "bw/webthing/webthing.hpp"
Expand Down
4 changes: 4 additions & 0 deletions examples/multiple-things.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Webthing-CPP
// SPDX-FileCopyrightText: 2023-present Benno Waldhauer
// SPDX-License-Identifier: MIT

#include <csignal>
#include <filesystem>
#include <bw/webthing/webthing.hpp>
Expand Down
4 changes: 4 additions & 0 deletions examples/single-thing.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Webthing-CPP
// SPDX-FileCopyrightText: 2023-present Benno Waldhauer
// SPDX-License-Identifier: MIT

#include <bw/webthing/webthing.hpp>

using namespace bw::webthing;
Expand Down
2 changes: 1 addition & 1 deletion include/bw/webthing/action.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Webthing-CPP
// SPDX-FileCopyrightText: 2023 Benno Waldhauer
// SPDX-FileCopyrightText: 2023-present Benno Waldhauer
// SPDX-License-Identifier: MIT

#pragma once
Expand Down
2 changes: 1 addition & 1 deletion include/bw/webthing/errors.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Webthing-CPP
// SPDX-FileCopyrightText: 2023 Benno Waldhauer
// SPDX-FileCopyrightText: 2023-present Benno Waldhauer
// SPDX-License-Identifier: MIT

#pragma once
Expand Down
2 changes: 1 addition & 1 deletion include/bw/webthing/event.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Webthing-CPP
// SPDX-FileCopyrightText: 2023 Benno Waldhauer
// SPDX-FileCopyrightText: 2023-present Benno Waldhauer
// SPDX-License-Identifier: MIT

#pragma once
Expand Down
2 changes: 1 addition & 1 deletion include/bw/webthing/json.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Webthing-CPP
// SPDX-FileCopyrightText: 2023 Benno Waldhauer
// SPDX-FileCopyrightText: 2023-present Benno Waldhauer
// SPDX-License-Identifier: MIT

#pragma once
Expand Down
2 changes: 1 addition & 1 deletion include/bw/webthing/json_validator.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Webthing-CPP
// SPDX-FileCopyrightText: 2023 Benno Waldhauer
// SPDX-FileCopyrightText: 2023-present Benno Waldhauer
// SPDX-License-Identifier: MIT

#pragma once
Expand Down
2 changes: 1 addition & 1 deletion include/bw/webthing/mdns.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Webthing-CPP
// SPDX-FileCopyrightText: 2023 Benno Waldhauer
// SPDX-FileCopyrightText: 2023-present Benno Waldhauer
// SPDX-License-Identifier: MIT

// MdnsService follows mdns.c example of Mattia Janssons mdns lib.
Expand Down
4 changes: 2 additions & 2 deletions include/bw/webthing/property.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Webthing-CPP
// SPDX-FileCopyrightText: 2023 Benno Waldhauer
// SPDX-FileCopyrightText: 2023-present Benno Waldhauer
// SPDX-License-Identifier: MIT

#pragma once
Expand Down Expand Up @@ -130,7 +130,7 @@ class Property : public PropertyBase
if(metadata.contains("readOnly"))
{
auto json_ro = metadata["readOnly"];
bool read_only = json_ro.is_boolean() && json_ro.get<bool>();
bool read_only = json_ro.is_boolean() && json_ro.template get<bool>();
if(read_only)
throw PropertyError("Read-only property");
}
Expand Down
2 changes: 1 addition & 1 deletion include/bw/webthing/server.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Webthing-CPP
// SPDX-FileCopyrightText: 2023-2024 Benno Waldhauer
// SPDX-FileCopyrightText: 2023-present Benno Waldhauer
// SPDX-License-Identifier: MIT

#pragma once
Expand Down
2 changes: 1 addition & 1 deletion include/bw/webthing/thing.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Webthing-CPP
// SPDX-FileCopyrightText: 2023 Benno Waldhauer
// SPDX-FileCopyrightText: 2023-present Benno Waldhauer
// SPDX-License-Identifier: MIT

#pragma once
Expand Down
2 changes: 1 addition & 1 deletion include/bw/webthing/utils.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Webthing-CPP
// SPDX-FileCopyrightText: 2023 Benno Waldhauer
// SPDX-FileCopyrightText: 2023-present Benno Waldhauer
// SPDX-License-Identifier: MIT

#pragma once
Expand Down
2 changes: 1 addition & 1 deletion include/bw/webthing/value.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Webthing-CPP
// SPDX-FileCopyrightText: 2023-2024 Benno Waldhauer
// SPDX-FileCopyrightText: 2023-present Benno Waldhauer
// SPDX-License-Identifier: MIT

#pragma once
Expand Down
2 changes: 1 addition & 1 deletion include/bw/webthing/webthing.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Webthing-CPP
// SPDX-FileCopyrightText: 2023 Benno Waldhauer
// SPDX-FileCopyrightText: 2023-present Benno Waldhauer
// SPDX-License-Identifier: MIT

#pragma once
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

[![CI Ubuntu](https://github.com/bw-hro/webthing-cpp/actions/workflows/ubuntu.yml/badge.svg?branch=master)](https://github.com/bw-hro/webthing-cpp/actions/workflows/ubuntu.yml)
[![CI Windows](https://github.com/bw-hro/webthing-cpp/actions/workflows/windows.yml/badge.svg?branch=master)](https://github.com/bw-hro/webthing-cpp/actions/workflows/windows.yml)
[![CI macOS](https://github.com/bw-hro/webthing-cpp/actions/workflows/macos.yml/badge.svg?branch=master)](https://github.com/bw-hro/webthing-cpp/actions/workflows/macos.yml)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/bw-hro/webthing-cpp/master/LICENSE.txt)

Webthing-CPP is a modern CPP/C++17 implementation of the [WebThings API](https://webthings.io/api). Goal of the project is to offer an easy way to set up digital twins with web interface for arbitrary things by just specifying their properties, actions and events. This projects focus lies on an easy to use API heavily inspired by similar projects from the [Java](https://github.com/WebThingsIO/webthing-java) and [Python](https://github.com/WebThingsIO/webthing-python) world.
Expand Down
2 changes: 1 addition & 1 deletion test/unit-test/action_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Webthing-CPP
// SPDX-FileCopyrightText: 2023 Benno Waldhauer
// SPDX-FileCopyrightText: 2023-present Benno Waldhauer
// SPDX-License-Identifier: MIT

#include <thread>
Expand Down
2 changes: 1 addition & 1 deletion test/unit-test/event_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Webthing-CPP
// SPDX-FileCopyrightText: 2023 Benno Waldhauer
// SPDX-FileCopyrightText: 2023-present Benno Waldhauer
// SPDX-License-Identifier: MIT

#include <catch2/catch_all.hpp>
Expand Down
2 changes: 1 addition & 1 deletion test/unit-test/json_validator_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Webthing-CPP
// SPDX-FileCopyrightText: 2023 Benno Waldhauer
// SPDX-FileCopyrightText: 2023-present Benno Waldhauer
// SPDX-License-Identifier: MIT

#include <catch2/catch_all.hpp>
Expand Down
2 changes: 1 addition & 1 deletion test/unit-test/property_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Webthing-CPP
// SPDX-FileCopyrightText: 2023 Benno Waldhauer
// SPDX-FileCopyrightText: 2023-present Benno Waldhauer
// SPDX-License-Identifier: MIT

#include <catch2/catch_all.hpp>
Expand Down
2 changes: 1 addition & 1 deletion test/unit-test/server_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Webthing-CPP
// SPDX-FileCopyrightText: 2023 Benno Waldhauer
// SPDX-FileCopyrightText: 2023-present Benno Waldhauer
// SPDX-License-Identifier: MIT

#include <catch2/catch_all.hpp>
Expand Down
2 changes: 1 addition & 1 deletion test/unit-test/thing_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Webthing-CPP
// SPDX-FileCopyrightText: 2023 Benno Waldhauer
// SPDX-FileCopyrightText: 2023-present Benno Waldhauer
// SPDX-License-Identifier: MIT

#include <catch2/catch_all.hpp>
Expand Down
2 changes: 1 addition & 1 deletion test/unit-test/utils_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Webthing-CPP
// SPDX-FileCopyrightText: 2023 Benno Waldhauer
// SPDX-FileCopyrightText: 2023-present Benno Waldhauer
// SPDX-License-Identifier: MIT

#include <catch2/catch_all.hpp>
Expand Down
2 changes: 1 addition & 1 deletion test/unit-test/value_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Webthing-CPP
// SPDX-FileCopyrightText: 2024 Benno Waldhauer
// SPDX-FileCopyrightText: 2023-present Benno Waldhauer
// SPDX-License-Identifier: MIT

#include <catch2/catch_all.hpp>
Expand Down
2 changes: 1 addition & 1 deletion test/unit-test/webthing_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Webthing-CPP
// SPDX-FileCopyrightText: 2023 Benno Waldhauer
// SPDX-FileCopyrightText: 2023-present Benno Waldhauer
// SPDX-License-Identifier: MIT

#include <catch2/catch_all.hpp>
Expand Down
4 changes: 3 additions & 1 deletion tools/run-webthing-tester-windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ def clone_or_update_webthing_tester_repo():
def install_python_dependencies():
"""Install required Python packages."""
print("Installing Python dependencies...")
run_command("pip3 install --user -r webthing-tester/requirements.txt")
run_command("python3 -m venv webthing-tester-venv")
run_command(".\\webthing-tester-venv\\Scripts\\activate.bat")
run_command("pip3 install -r webthing-tester/requirements.txt")

def build_webthing_cpp():
"""Build Webthing-CPP if the binaries do not exist."""
Expand Down
5 changes: 4 additions & 1 deletion tools/run-webthing-tester.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ else
git clone -b time-regex-option https://github.com/bw-hro/webthing-tester.git
fi

pip3 install --user -r webthing-tester/requirements.txt
# Install python dependencies inside a virtual environment
python3 -m venv webthing-tester-venv
source webthing-tester-venv/bin/activate
pip3 install -r webthing-tester/requirements.txt

# build Webthing-CPP with examples when they do not exist
SINGLE_BIN="../build/examples/single-thing"
Expand Down
2 changes: 1 addition & 1 deletion vcpkg-no-ssl.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "webthing-cpp",
"version-string": "1.0.4",
"version-string": "1.0.5",
"builtin-baseline": "c82f74667287d3dc386bce81e44964370c91a289",
"dependencies": [
"catch2",
Expand Down
2 changes: 1 addition & 1 deletion vcpkg-with-ssl.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "webthing-cpp",
"version-string": "1.0.4",
"version-string": "1.0.5",
"builtin-baseline": "c82f74667287d3dc386bce81e44964370c91a289",
"dependencies": [
"catch2",
Expand Down
2 changes: 1 addition & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "webthing-cpp",
"version-string": "1.0.4",
"version-string": "1.0.5",
"builtin-baseline": "c82f74667287d3dc386bce81e44964370c91a289",
"dependencies": [
"catch2",
Expand Down

0 comments on commit aa1865d

Please sign in to comment.