From 7ad71120d71e3e38d0905d1c49610e181f1e2f62 Mon Sep 17 00:00:00 2001 From: Ivan-lis Date: Sun, 15 Sep 2024 20:50:01 +0000 Subject: [PATCH] Added Arch dev container + vscode Build task --- .devcontainer/Dockerfile | 37 ++++++++++++++++++++++++ .devcontainer/devcontainer.json | 17 +++++++++++ .gitignore | 2 +- .vscode/tasks.json | 51 +++++++++++++++++++++++++++++++++ CMakeLists.txt | 9 ++++-- library/src/encryption.cpp | 2 +- 6 files changed, 113 insertions(+), 5 deletions(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 .vscode/tasks.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..6f5bef1 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,37 @@ +# Base image using Arch Linux +# Date: Sep10 2024 +# Url: https://hub.docker.com/layers/library/archlinux/latest/images/sha256-a10e51dd0694d6c4142754e9d06cbce7baf91ace8031a30df37064d1091ab414?context=explore +FROM archlinux@sha256:a10e51dd0694d6c4142754e9d06cbce7baf91ace8031a30df37064d1091ab414 + +# Update the package database and install clang +RUN pacman -Syyu --noconfirm \ + && pacman -S --noconfirm git less vim sudo base-devel \ + && pacman -S --noconfirm clang cmake make ninja gtk4 gtkmm-4.0 + +# Create a non-root user 'dev' +RUN useradd -ms /bin/bash dev \ + && echo "dev ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/dev \ + && chmod 0440 /etc/sudoers.d/dev + +# Add the custom bash prompt with branch info +RUN printf '\n\ +function modify_prompt { \n\ + local __user_and_host="\[\033[01;32m\]\u@\h" \n\ + local __cur_location="\[\033[01;34m\]\w" \n\ + local __git_branch_color="\[\033[31m\]" \n\ + local __git_branch="\$(git branch 2> /dev/null | sed -e \'"'"'/^[^*]/d\'"'"' -e \'"'"'s/* \(.*\)/(\\1)/\'"'"')" \n\ + local __prompt_tail="\[\033[00m\]$" \n\ + export PS1="$__user_and_host $__cur_location $__git_branch_color$__git_branch$__prompt_tail " \n\ +} \n\ +modify_prompt\n' >> /home/dev/.bashrc + +# Switch to the 'dev' user +USER dev + +RUN git config --global core.editor vim + +# Set the default working directory +WORKDIR /home/dev + +# Set the default command +CMD ["/bin/bash"] diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..b1cbee9 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,17 @@ +{ + "name": "Arch Linux with GCC & Clang++", + "build": { + "dockerfile": "Dockerfile" + }, + "customizations": {"vscode": { + "extensions": [ + "llvm-vs-code-extensions.vscode-clangd", + "vadimcn.vscode-lldb", + "twxs.cmake", + "ms-vscode.cmake-tools", + "zxh404.vscode-proto3", + "ms-azuretools.vscode-docker" + ] + }} + } + \ No newline at end of file diff --git a/.gitignore b/.gitignore index 8fbe10b..3cd684b 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,4 @@ examples/output lib__cmake_cxx23.a liblarra_xmpp.a liblarra_xmpp.so -build +build* diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..b778385 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,51 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "Build Debug GCC", + "type": "shell", + "command": [ + "cd ${workspaceFolder} &&", + "mkdir -p build && cd build &&", + "cmake -DCMAKE_BUILD_TYPE=Debug -DENABLE_EXAMPLES=ON .. &&", + "cmake --build . --parallel `nproc`", + "|| ( printf '\n\n\t\\e[31mERROR: Build failed!\\e[0m\n\n\n' && exit 1 )" + ], + "options": { + "env": { + } + }, + "presentation": { + "clear": true + }, + "problemMatcher": [], + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "Build Debug Clang", + "type": "shell", + "command": [ + "cd ${workspaceFolder} &&", + "mkdir -p build_clang && cd build_clang &&", + "cmake -DCMAKE_BUILD_TYPE=Debug -DENABLE_EXAMPLES=ON .. &&", + "cmake --build . --parallel `nproc`", + "|| ( printf '\n\n\t\\e[31mERROR: Build failed!\\e[0m\n\n\n' && exit 1 )" + ], + "options": { + "env": { + "CC": "/usr/sbin/clang", + "CXX": "/usr/sbin/clang++", + } + }, + "presentation": { + "clear": true + }, + "problemMatcher": [] + } + ] +} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ece727..3ad5242 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,11 +83,12 @@ add_library(larra::larra_xmpp ALIAS larra_xmpp) target_compile_features(larra_xmpp PUBLIC cxx_std_23) + +target_compile_options(larra_xmpp PUBLIC -Wno-changes-meaning) + target_include_directories(larra_xmpp PUBLIC $ - $) - - + $) @@ -190,6 +191,8 @@ if(ENABLE_EXAMPLES) set_property(TARGET ${EXAMPLE_NAME} PROPERTY CXX_STANDARD 23) set_target_properties(${EXAMPLE_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/examples/output") + + target_include_directories(${EXAMPLE_NAME} PRIVATE ${BOOST_LIBRARY_INCLUDES}) endforeach() endif() diff --git a/library/src/encryption.cpp b/library/src/encryption.cpp index 12d86eb..e01c239 100644 --- a/library/src/encryption.cpp +++ b/library/src/encryption.cpp @@ -138,7 +138,7 @@ inline auto GenerateAuthScramMessageImpl(std::string_view password, auto clientSignature = HmacImpl(ToCharStringView(storedKey), ToUnsignedCharStringView(authMessage), tag); auto clientProof = std::views::zip(clientKey, clientSignature) | // No std::views::enumerate in libc++ std::views::transform([&](auto arg) { - return arg.first ^ arg.second; + return std::get<0>(arg) ^ std::get<1>(arg); }) | std::ranges::to(); std::string serverKeyStr = "Server Key";