From a51bef308a3be81b15eb9a2126f2255e5a037d20 Mon Sep 17 00:00:00 2001 From: Daniel Gustainis Date: Sun, 24 Dec 2023 01:07:03 +0000 Subject: [PATCH] Added devcontainer and removed dependence on vendored third-party libraries --- .devcontainer/Dockerfile | 39 +++++++ .devcontainer/devcontainer.json | 48 ++++++++ .devcontainer/docker-compose.yml | 13 +++ .gitignore | 2 +- CMakeLists.txt | 108 +++++++++--------- src/blah2.cpp | 6 +- test/unit/process/ambiguity/TestAmbiguity.cpp | 5 +- test/unit/process/tracker/TestTracker.cpp | 3 +- 8 files changed, 161 insertions(+), 63 deletions(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/docker-compose.yml diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..1538acd --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,39 @@ +# ubuntu-22.04 by default +ARG VARIANT="jammy" +FROM mcr.microsoft.com/vscode/devcontainers/cpp:0-${VARIANT} + +ENV DEBIAN_FRONTEND=noninteractive +# Feel like this shouldn't be needed but it drops me in / during build +WORKDIR /workspace + +RUN apt-get update \ + # + # Install dev tools and package dependencies + && apt-get install -y clang-tidy clang-format doxygen graphviz gfortran \ + libfftw3-dev liblapack-dev libopenblas-dev libudev-dev libusb-1.0.0-dev \ + # + # Clean up + && apt-get autoremove -y \ + && apt-get clean -y \ + && rm -rf /var/lib/apt/lists/* + +# Install dependencies from vcpkg +RUN vcpkg integrate install \ + && vcpkg install catch2 \ + && vcpkg install rapidjson \ + && vcpkg install asio \ + && vcpkg install cpp-httplib \ + && vcpkg install armadillo \ + && vcpkg install ryml + +COPY lib/sdrplay-3.0.7/SDRplay_RSP_API-Linux-3.07.1.run /workspace/ + +# Install shitty sdrplay API +RUN chmod +x /workspace/SDRplay_RSP_API-Linux-3.07.1.run \ + && /workspace/SDRplay_RSP_API-Linux-3.07.1.run --tar -xf \ + && cp x86_64/libsdrplay_api.so.3.07 /usr/local/lib/libsdrplay_api.so \ + && ln -s /usr/local/lib/libsdrplay_api.so /usr/local/lib/libsdrplay_api.so.3.07 \ + && cp inc/* /usr/local/include \ + && chmod 644 /usr/local/lib/libsdrplay_api.so /usr/local/lib/libsdrplay_api.so.3.07 \ + && ldconfig + diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..8ee056d --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,48 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-docker-compose +{ + "name": "blah2 dev", + + // Update the 'dockerComposeFile' list if you have more compose files or use different names. + // The .devcontainer/docker-compose.yml file contains any overrides you need/want to make. + "dockerComposeFile": [ + "docker-compose.yml" + ], + + // The 'service' property is the name of the service for the container that VS Code should + // use. Update this value and .devcontainer/docker-compose.yml to the real service name. + "service": "blah2-dev", + + // The optional 'workspaceFolder' property is the path VS Code should open by default when + // connected. This is typically a file mount in .devcontainer/docker-compose.yml + "workspaceFolder": "/workspace", + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Uncomment the next line if you want start specific services in your Docker Compose config. + // "runServices": [], + + // Uncomment the next line if you want to keep your containers running after VS Code shuts down. + // "shutdownAction": "none", + + // Uncomment the next line to run commands after the container is created. + // "postCreateCommand": "cat /etc/os-release", + + // Configure tool-specific properties. + // "customizations": {}, + "customizations": { + "vscode": { + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "ms-vscode.cpptools-extension-pack", + ], + } + }, + + // Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root. + "remoteUser": "vscode" +} diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 0000000..9f4e360 --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,13 @@ +version: "3.2" +services: + blah2-dev: + user: vscode + build: + context: .. + dockerfile: .devcontainer/Dockerfile + volumes: + - type: bind + source: .. + target: /workspace + working_dir: /workspace + command: sleep infinity \ No newline at end of file diff --git a/.gitignore b/.gitignore index f7b541b..0255943 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -build/* +build*/* bin/* !build/README.md !bin/README.md diff --git a/CMakeLists.txt b/CMakeLists.txt index 8f8f8d2..e5d7e75 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,14 @@ -project(blah2) cmake_minimum_required(VERSION 3.8) + if(COMMAND cmake_policy) + cmake_policy(SET CMP0003 NEW) + endif(COMMAND cmake_policy) + +project(blah2) +include(CMakePrintHelpers) -SET(CMAKE_CXX_STANDARD 17) +SET(CMAKE_CXX_STANDARD 20) SET(CMAKE_CXX_STANDARD_REQUIRED ON) SET(CMAKE_CXX_EXTENSIONS OFF) -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") SET (PROJECT_ROOT "${PROJECT_SOURCE_DIR}") SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_ROOT}/bin") @@ -18,59 +22,53 @@ MESSAGE ("Source path: ${PROJECT_SOURCE_DIR}") MESSAGE ("Binary path: ${PROJECT_BINARY_DIR}") MESSAGE ("Binary test path: ${PROJECT_BINARY_TEST_DIR}") MESSAGE ("Lib path: ${PROJECT_LIB_DIR}") +MESSAGE ("CMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}") + +find_package(Threads REQUIRED) +find_package(asio CONFIG REQUIRED) +find_package(RapidJSON REQUIRED) +find_package(ryml CONFIG REQUIRED) +find_package(httplib REQUIRED) +find_package(Armadillo REQUIRED) +find_package(Catch2 CONFIG REQUIRED) + +# find_package(fftw3 REQUIRED) + +# TODO: Create FindSdrplay.cmake for this +add_library(sdrplay /usr/local/include/sdrplay_api.h) +set_target_properties(sdrplay PROPERTIES LINKER_LANGUAGE C) +target_link_libraries(sdrplay PUBLIC /usr/local/lib/libsdrplay_api.so.3.07) add_executable(blah2 - ${PROJECT_SOURCE_DIR}/blah2.cpp - ${PROJECT_SOURCE_DIR}/capture/Capture.cpp - ${PROJECT_SOURCE_DIR}/capture/rspduo/RspDuo.cpp - ${PROJECT_SOURCE_DIR}/process/ambiguity/Ambiguity.cpp - ${PROJECT_SOURCE_DIR}/process/clutter/WienerHopf.cpp - ${PROJECT_SOURCE_DIR}/process/detection/CfarDetector1D.cpp - ${PROJECT_SOURCE_DIR}/process/detection/Centroid.cpp - ${PROJECT_SOURCE_DIR}/process/detection/Interpolate.cpp - ${PROJECT_SOURCE_DIR}/process/tracker/Tracker.cpp - ${PROJECT_SOURCE_DIR}/process/spectrum/SpectrumAnalyser.cpp - ${PROJECT_SOURCE_DIR}/process/meta/HammingNumber.cpp - ${PROJECT_SOURCE_DIR}/data/IqData.cpp - ${PROJECT_SOURCE_DIR}/data/Map.cpp - ${PROJECT_SOURCE_DIR}/data/Detection.cpp - ${PROJECT_SOURCE_DIR}/data/Track.cpp - ${PROJECT_SOURCE_DIR}/data/meta/Timing.cpp + src/blah2.cpp + src/capture/Capture.cpp + src/capture/rspduo/RspDuo.cpp + src/process/ambiguity/Ambiguity.cpp + src/process/clutter/WienerHopf.cpp + src/process/detection/CfarDetector1D.cpp + src/process/detection/Centroid.cpp + src/process/detection/Interpolate.cpp + src/process/tracker/Tracker.cpp + src/process/spectrum/SpectrumAnalyser.cpp + src/process/meta/HammingNumber.cpp + src/data/IqData.cpp + src/data/Map.cpp + src/data/Detection.cpp + src/data/Track.cpp + src/data/meta/Timing.cpp ) -add_library(ryml ${PROJECT_LIB_DIR}/rapidyaml-0.5.0/ryml-0.5.0.hpp) -add_library(rapidjson ${PROJECT_LIB_DIR}/rapidjson-1.1.0/) -add_library(sdrplay /usr/local/include/sdrplay_api.h) -add_library(asio ${PROJECT_LIB_DIR}/asio-1.26.0/asio.hpp) -add_library(httplib ${PROJECT_LIB_DIR}/cpp-httplib-0.12.2/httplib.h) -add_library(catch2 ${PROJECT_LIB_DIR}/catch2/catch_amalgamated.cpp) -target_include_directories(catch2 PUBLIC ${PROJECT_LIB_DIR}/catch2) - -include_directories("${PROJECT_LIB_DIR}/rapidjson-1.1.0/") -set_target_properties(rapidjson PROPERTIES LINKER_LANGUAGE CXX) -target_link_libraries(blah2 rapidjson) - -include_directories("${PROJECT_LIB_DIR}/asio-1.26.0/") -set_target_properties(asio PROPERTIES LINKER_LANGUAGE CXX) -target_link_libraries(blah2 asio) - -include_directories("${PROJECT_LIB_DIR}/cpp-httplib-0.12.2/") -set_target_properties(httplib PROPERTIES LINKER_LANGUAGE CXX) -target_link_libraries(blah2 httplib) - -include_directories("${PROJECT_LIB_DIR}/rapidyaml-0.5.0/") -set_target_properties(ryml PROPERTIES LINKER_LANGUAGE CXX) -target_link_libraries(blah2 ryml) - -set_target_properties(sdrplay PROPERTIES LINKER_LANGUAGE C) -target_link_libraries(sdrplay /usr/local/lib/libsdrplay_api.so.3.07) -target_link_libraries(blah2 sdrplay) - -target_link_libraries(blah2 fftw3) -target_link_libraries(blah2 fftw3_threads) -target_link_libraries(blah2 lapack) -target_link_libraries(blah2 blas) -target_link_libraries(blah2 armadillo) +target_link_libraries(blah2 PRIVATE + Threads::Threads + rapidjson + asio::asio + ryml::ryml + httplib::httplib + armadillo + fftw3 + fftw3_threads + sdrplay + ) include_directories("${PROJECT_SOURCE_DIR}/capture/") include_directories("${PROJECT_SOURCE_DIR}/capture/rspduo/") @@ -90,7 +88,7 @@ add_executable(testAmbiguity ${PROJECT_SOURCE_DIR}/data/Map.cpp ${PROJECT_SOURCE_DIR}/process/ambiguity/Ambiguity.cpp ${PROJECT_SOURCE_DIR}/process/meta/HammingNumber.cpp) -target_link_libraries(testAmbiguity catch2 fftw3 fftw3_threads) +target_link_libraries(testAmbiguity PRIVATE Catch2::Catch2WithMain fftw3 fftw3_threads) set_target_properties(testAmbiguity PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_TEST_UNIT_DIR}") @@ -99,6 +97,6 @@ add_executable(testTracker ${PROJECT_SOURCE_DIR}/data/Detection.cpp ${PROJECT_SOURCE_DIR}/data/Track.cpp ${PROJECT_SOURCE_DIR}/process/tracker/Tracker.cpp) -target_link_libraries(testTracker catch2) +target_link_libraries(testTracker PRIVATE Catch2::Catch2WithMain) set_target_properties(testTracker PROPERTIES - RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_TEST_UNIT_DIR}") + RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_TEST_UNIT_DIR}") \ No newline at end of file diff --git a/src/blah2.cpp b/src/blah2.cpp index aa4d5e8..da49d53 100644 --- a/src/blah2.cpp +++ b/src/blah2.cpp @@ -2,9 +2,9 @@ /// @brief A real-time radar. /// @author 30hours -#define RYML_SINGLE_HDR_DEFINE_NOW - -#include +#include +#include // optional header, provided for std:: interop +#include // needed for the examples below #include #include #include diff --git a/test/unit/process/ambiguity/TestAmbiguity.cpp b/test/unit/process/ambiguity/TestAmbiguity.cpp index c833a8c..cc1879a 100644 --- a/test/unit/process/ambiguity/TestAmbiguity.cpp +++ b/test/unit/process/ambiguity/TestAmbiguity.cpp @@ -5,8 +5,9 @@ /// @todo Add golden data IqData file for testing. /// @todo Declaration match to coding style? -#define CATCH_CONFIG_MAIN -#include "catch_amalgamated.hpp" +#include +#include +#include #include "Ambiguity.h" #include diff --git a/test/unit/process/tracker/TestTracker.cpp b/test/unit/process/tracker/TestTracker.cpp index 95fb28f..19279b6 100644 --- a/test/unit/process/tracker/TestTracker.cpp +++ b/test/unit/process/tracker/TestTracker.cpp @@ -2,8 +2,7 @@ /// @brief Unit test for Tracker.cpp /// @author 30hours -#define CATCH_CONFIG_MAIN -#include "catch_amalgamated.hpp" +#include #include "Detection.h" #include "Tracker.h"