diff --git a/Dockerfile b/.devcontainer/Dockerfile similarity index 92% rename from Dockerfile rename to .devcontainer/Dockerfile index 1044fcb..057f3f1 100644 --- a/Dockerfile +++ b/.devcontainer/Dockerfile @@ -11,6 +11,7 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* \ && mkdir /workspace +# Uncoment to install custom libraries #RUN git clone --depth 1 --branch 2024.02.14 https://github.com/Microsoft/vcpkg.git /opt/vcpkg \ # && cd /opt/vcpkg \ # && ./bootstrap-vcpkg.sh \ diff --git a/.devcontainer/README.md b/.devcontainer/README.md new file mode 100644 index 0000000..c9734c1 --- /dev/null +++ b/.devcontainer/README.md @@ -0,0 +1,10 @@ +# Alternatives to Dev Containers + +1. Locally install all required dependencies on your host (dev) machine. + If you're actively developing multiple projects in multiple languages, this kind of setup becomes _messy_ very quickly. + +2. Manually install IDE of choice into a Docker container and than use [X11 window forwarding](https://goteleport.com/blog/x11-forwarding/) to automagically _spawn_ an IDE window onto your host PC. + I mean... yes, you **can** do this — but why? + +3. SSH into Docker while simulatneosly connecting your vim pedal to the nearest free USB port. + Old, but gold 😊 \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..6166378 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,14 @@ +{ + "name": "Telemetry Dev Container", + "customizations": { + "vscode": { + "extensions": [ + "ms-vscode.cmake-tools", + "hbenl.test-adapter-converter", + "matepek.vscode-catch2-test-adapter", + "bierner.markdown-mermaid" + ] + } + }, + "dockerFile": "Dockerfile" + } \ No newline at end of file diff --git a/.gitignore b/.gitignore index 4f0c465..8fcbcd3 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,6 @@ compile_commands.json CTestTestfile.cmake _deps build/* + +# MacOS directory configurations +.DS_Store diff --git a/src/.vscode/launch.json b/.vscode/launch.json similarity index 100% rename from src/.vscode/launch.json rename to .vscode/launch.json diff --git a/src/.vscode/settings.json b/.vscode/settings.json similarity index 97% rename from src/.vscode/settings.json rename to .vscode/settings.json index ddbb281..62f778e 100644 --- a/src/.vscode/settings.json +++ b/.vscode/settings.json @@ -70,5 +70,7 @@ "*.inc": "cpp", "csignal": "cpp", "shared_mutex": "cpp" - } + }, + + "cmake.configureOnOpen": true } \ No newline at end of file diff --git a/src/CMakeLists.txt b/CMakeLists.txt similarity index 100% rename from src/CMakeLists.txt rename to CMakeLists.txt diff --git a/README.md b/README.md index 10c60de..f785733 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,25 @@ -# Telemetry +# Telemetry -A simple yet functional library for capturing runtime analytic events from embedded devices. +A simple yet functional library for capturing runtime analytic events from embedded devices. -# Build & run +# Build & Run -`Dockerfile` with two helper scripts were added into project's root folder. Buy doing so, two useful goals were achieved: -- **Infrastructure as a code**: - All project dependancies and as well as all installation / configuration steps are easily documented as groups of handy scripts inside `Dockerfile`. -- **Containerization**: - Almost instant ability to jump into app development, testing and/or deployment with zero footprint (pollution) on main (host) PC. +Consult the `.devcontainers/Dockerfile` for the list of project dependencies. -## IDE +## VsCode Dev Containers -[VsCode](https://code.visualstudio.com/) IDE was used for in-container development. There is two different ways how one might approach this task: -- [Attach](https://code.visualstudio.com/docs/devcontainers/attach-container) VsCode to already [[#Build & run|running]] container -- Manually [install](https://github.com/ahmadnassri/docker-vscode-server/blob/master/Dockerfile) VsCode IDE into container and use [X11 window forwarding](https://goteleport.com/blog/x11-forwarding/), to automagically *spawn* VsCode IDE window on host PC +I am in no way a M$ fanboy, but the VsCode IDE seems to be a versatile, Swiss-army-knife tool. Long story short: you are highly advised to use the latest version of VsCode for a quick, hassle-free yet comprehensive overview of the project. -# Design goals +1. Upon opening the project's folder, VsCode should ask you to reopen the project as a `devcontainer`. Simply agree, and allow all necessary configuration to happen in the background. + + > ⚠️ If not prompted ⚠️
+ > `Ctrl + Shift + P` > `Dev Containers: Reopen in Container` + +2. Use the pre-installed **CMake** extension to configure and build the project. + +3. Use **Test Explorer** to run and debug tests. + +# Library design goals - agnostic to payload format - adequate runtime overhead diff --git a/src/datapoint/analytics_event.cpp b/datapoint/analytics_event.cpp similarity index 100% rename from src/datapoint/analytics_event.cpp rename to datapoint/analytics_event.cpp diff --git a/src/datapoint/analytics_event.hpp b/datapoint/analytics_event.hpp similarity index 100% rename from src/datapoint/analytics_event.hpp rename to datapoint/analytics_event.hpp diff --git a/src/datapoint/temperature_reading.cpp b/datapoint/temperature_reading.cpp similarity index 100% rename from src/datapoint/temperature_reading.cpp rename to datapoint/temperature_reading.cpp diff --git a/src/datapoint/temperature_reading.hpp b/datapoint/temperature_reading.hpp similarity index 100% rename from src/datapoint/temperature_reading.hpp rename to datapoint/temperature_reading.hpp diff --git a/src/demo/device.cpp b/demo/device.cpp similarity index 100% rename from src/demo/device.cpp rename to demo/device.cpp diff --git a/src/demo/device.hpp b/demo/device.hpp similarity index 100% rename from src/demo/device.hpp rename to demo/device.hpp diff --git a/src/demo/interfaces/analytics_source.hpp b/demo/interfaces/analytics_source.hpp similarity index 100% rename from src/demo/interfaces/analytics_source.hpp rename to demo/interfaces/analytics_source.hpp diff --git a/src/demo/interfaces/temperature_source.hpp b/demo/interfaces/temperature_source.hpp similarity index 100% rename from src/demo/interfaces/temperature_source.hpp rename to demo/interfaces/temperature_source.hpp diff --git a/src/demo/main.cpp b/demo/main.cpp similarity index 100% rename from src/demo/main.cpp rename to demo/main.cpp diff --git a/src/demo/mocks/mock_analytics_source.cpp b/demo/mocks/mock_analytics_source.cpp similarity index 100% rename from src/demo/mocks/mock_analytics_source.cpp rename to demo/mocks/mock_analytics_source.cpp diff --git a/src/demo/mocks/mock_analytics_source.hpp b/demo/mocks/mock_analytics_source.hpp similarity index 100% rename from src/demo/mocks/mock_analytics_source.hpp rename to demo/mocks/mock_analytics_source.hpp diff --git a/src/demo/mocks/mock_temperature_source.cpp b/demo/mocks/mock_temperature_source.cpp similarity index 100% rename from src/demo/mocks/mock_temperature_source.cpp rename to demo/mocks/mock_temperature_source.cpp diff --git a/src/demo/mocks/mock_temperature_source.hpp b/demo/mocks/mock_temperature_source.hpp similarity index 100% rename from src/demo/mocks/mock_temperature_source.hpp rename to demo/mocks/mock_temperature_source.hpp diff --git a/docker-build.sh b/docker-build.sh deleted file mode 100755 index bc3c246..0000000 --- a/docker-build.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash -set -euxo pipefail - -docker build -t telemetry-ide:latest . \ No newline at end of file diff --git a/docker-run.sh b/docker-run.sh deleted file mode 100755 index 32b6362..0000000 --- a/docker-run.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash -set -euxo pipefail - -docker run \ - --name telemetry \ - -v $(pwd)/src:/workspace \ - -it telemetry-ide:latest \ No newline at end of file diff --git a/src/.vscode/tasks.json b/src/.vscode/tasks.json deleted file mode 100644 index 54c0acc..0000000 --- a/src/.vscode/tasks.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "tasks": [ - { - "type": "cppbuild", - "label": "C/C++: g++-12 build active file", - "command": "/usr/bin/g++-12", - "args": [ - "-fdiagnostics-color=always", - "-g", - "${file}", - "-o", - "${fileDirname}/${fileBasenameNoExtension}" - ], - "options": { - "cwd": "${fileDirname}" - }, - "problemMatcher": [ - "$gcc" - ], - "group": { - "kind": "build", - "isDefault": true - }, - "detail": "Task generated by Debugger." - } - ], - "version": "2.0.0" -} \ No newline at end of file diff --git a/src/telemetry/CMakeLists.txt b/telemetry/CMakeLists.txt similarity index 100% rename from src/telemetry/CMakeLists.txt rename to telemetry/CMakeLists.txt diff --git a/src/telemetry/datapoint.hpp b/telemetry/datapoint.hpp similarity index 100% rename from src/telemetry/datapoint.hpp rename to telemetry/datapoint.hpp diff --git a/src/telemetry/message.cpp b/telemetry/message.cpp similarity index 100% rename from src/telemetry/message.cpp rename to telemetry/message.cpp diff --git a/src/telemetry/message.hpp b/telemetry/message.hpp similarity index 100% rename from src/telemetry/message.hpp rename to telemetry/message.hpp diff --git a/src/telemetry/message.proto b/telemetry/message.proto similarity index 100% rename from src/telemetry/message.proto rename to telemetry/message.proto diff --git a/src/telemetry/reader.cpp b/telemetry/reader.cpp similarity index 100% rename from src/telemetry/reader.cpp rename to telemetry/reader.cpp diff --git a/src/telemetry/reader.hpp b/telemetry/reader.hpp similarity index 100% rename from src/telemetry/reader.hpp rename to telemetry/reader.hpp diff --git a/src/telemetry/sink.cpp b/telemetry/sink.cpp similarity index 100% rename from src/telemetry/sink.cpp rename to telemetry/sink.cpp diff --git a/src/telemetry/sink.hpp b/telemetry/sink.hpp similarity index 100% rename from src/telemetry/sink.hpp rename to telemetry/sink.hpp diff --git a/src/tests/data/test_telemetry.cpp b/tests/data/test_telemetry.cpp similarity index 100% rename from src/tests/data/test_telemetry.cpp rename to tests/data/test_telemetry.cpp diff --git a/src/tests/data/test_temperature_reading.cpp b/tests/data/test_temperature_reading.cpp similarity index 100% rename from src/tests/data/test_temperature_reading.cpp rename to tests/data/test_temperature_reading.cpp