diff --git a/.githooks/pre-commit b/.githooks/pre-commit index a24e546..9cb6f0f 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -5,6 +5,7 @@ NC='\033[0m' # No Color SCRIPTS_FOLDER=$( dirname "$(realpath "$0")" ) PROJECT_FOLDER=$( dirname "$SCRIPTS_FOLDER" ) +cd $PROJECT_FOLDER || exit 1 GIT_STAGED_FILES=$(git diff --cached --name-only --diff-filter=d | grep -E -i "\.(h|hpp|c|cpp)$") GIT_SCRIPT_FILES="$(git diff --cached --name-only --diff-filter=d | grep -E -i "\.(sh)$") .githooks/pre-commit" @@ -49,14 +50,16 @@ fi # # Description: Temporal solution before CI # Test tools: default compiler, gtest execution -# Manual cmd command: cd /workspaces/larra ; mkdir temp_pre_commit_check ; cd temp_pre_commit_check ; cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTS=ON .. ; cmake --build . --target larra_xmpp_tests --parallel `nproc` ; ./larra_xmpp_tests --gtest_brief=1 +# Manual cmd command: cd /workspaces/larra ; mkdir temp_pre_commit_check ; cd temp_pre_commit_check ; cmake -Wno-dev -S .. -B . -GNinja -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTS=ON -DCMAKE_CXX_FLAGS="-Wno-non-template-friend" ; cmake --build . --target larra_xmpp_tests --parallel `nproc` ; ./larra_xmpp_tests --gtest_brief=1 # GTEST_FOLDER=${PROJECT_FOLDER?}/temp_pre_commit_check +rm -rf ${GTEST_FOLDER} || exit 1 printf "\n\tPrepare GTests to check (takes up to 10 seconds)" -mkdir -p ${GTEST_FOLDER}; cd ${GTEST_FOLDER} || exit 1; cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTS=ON .. > /dev/null 2>&1 +mkdir -p ${GTEST_FOLDER}; cd ${GTEST_FOLDER} || exit 1; cmake -Wno-dev -S ${PROJECT_FOLDER} -B ${GTEST_FOLDER} -GNinja -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTS=ON -DCMAKE_CXX_FLAGS="-Wno-non-template-friend" > /dev/null 2>&1 + printf "\n\tBuild GTests to check (takes up to 30 seconds)" -cmake --build . --target larra_xmpp_tests --parallel "`nproc`" > /dev/null 2>&1 +cmake --build ${GTEST_FOLDER} --target larra_xmpp_tests --parallel "$(nproc)" printf "\n\tLaunch GTests to check\n" ./larra_xmpp_tests --gtest_brief=1 diff --git a/.vscode/tasks.json b/.vscode/tasks.json index b0f68e3..55a74f4 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -23,7 +23,7 @@ "command": [ "cd ${workspaceFolder} &&", "mkdir -p build && cd build &&", - "cmake -DCMAKE_BUILD_TYPE=Debug -DENABLE_EXAMPLES=ON -DENABLE_TESTS=ON .. &&", + "cmake -Wno-dev -DCMAKE_BUILD_TYPE=Debug -DENABLE_EXAMPLES=ON -DENABLE_TESTS=ON .. &&", "cmake --build . --parallel `nproc`", "|| ( printf '\n\n\t\\e[31mERROR: Build failed!\\e[0m\n\n\n' && exit 1 )" ], @@ -45,7 +45,7 @@ "command": [ "cd ${workspaceFolder} &&", "mkdir -p build_clang && cd build_clang &&", - "cmake -DCMAKE_BUILD_TYPE=Debug -DENABLE_EXAMPLES=ON -DENABLE_TESTS=ON .. &&", + "cmake -Wno-dev -DCMAKE_BUILD_TYPE=Debug -DENABLE_EXAMPLES=ON -DENABLE_TESTS=ON .. &&", "cmake --build . --parallel `nproc`", "|| ( printf '\n\n\t\\e[31mERROR: Build failed!\\e[0m\n\n\n' && exit 1 )" ], diff --git a/CMakeLists.txt b/CMakeLists.txt index e96e89f..bd3315d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,12 @@ cmake_minimum_required(VERSION 3.28) +# Configure local githooks +execute_process( + COMMAND git config core.hooksPath .githooks + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + RESULT_VARIABLE GIT_COMMAND_RESULT + ) + project(larra VERSION 0.1 LANGUAGES CXX)