From 2f43ca42bedc506b31e9aaba4a35ff8250916396 Mon Sep 17 00:00:00 2001 From: Jonathan White Date: Sun, 2 Jun 2024 07:37:34 -0400 Subject: [PATCH] Fix broken build when using system zxcvbn (#10717) * Fix broken build when using system zxcvbn Fixup of zxcvbn include statement added in 5513ff5. A zxcvbn/ directory prefix breaks building with system zxcvbn. Remove this prefix to align this include statement with ones present in other files. Add zxcvbn libraries as dependency to CliTest. * Move src/zxcvbn/ to src/thirdparty/zxcvbn --- CMakeLists.txt | 8 +++++++- COPYING | 2 +- cmake/CLangFormat.cmake | 1 - codecov.yaml | 19 +++++++++++++++++++ src/CMakeLists.txt | 14 -------------- src/cli/CMakeLists.txt | 2 +- src/thirdparty/zxcvbn/CMakeLists.txt | 9 +++++++++ src/{ => thirdparty}/zxcvbn/dict-src.h | 0 src/{ => thirdparty}/zxcvbn/zxcvbn.c | 0 src/{ => thirdparty}/zxcvbn/zxcvbn.h | 0 tests/CMakeLists.txt | 2 +- tests/TestCli.cpp | 2 +- 12 files changed, 39 insertions(+), 20 deletions(-) create mode 100644 src/thirdparty/zxcvbn/CMakeLists.txt rename src/{ => thirdparty}/zxcvbn/dict-src.h (100%) rename src/{ => thirdparty}/zxcvbn/zxcvbn.c (100%) rename src/{ => thirdparty}/zxcvbn/zxcvbn.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2a3db4d37..76fca7575 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -467,7 +467,7 @@ if(WITH_COVERAGE) append_coverage_compiler_flags() set(COVERAGE_EXCLUDES - "'^(.+/)?(thirdparty|zxcvbn)/.*'" + "'^(.+/)?thirdparty/.*'" "'^(.+/)?main\\.cpp$$'" "'^(.+/)?cli/keepassxc-cli\\.cpp$$'" "'^(.+/)?proxy/keepassxc-proxy\\.cpp$$'") @@ -613,6 +613,12 @@ endif() include_directories(SYSTEM ${ZLIB_INCLUDE_DIR}) +find_library(ZXCVBN_LIBRARIES zxcvbn) +if(NOT ZXCVBN_LIBRARIES) + add_subdirectory(src/thirdparty/zxcvbn) + set(ZXCVBN_LIBRARIES zxcvbn) +endif(NOT ZXCVBN_LIBRARIES) + add_subdirectory(src) add_subdirectory(share) if(WITH_TESTS) diff --git a/COPYING b/COPYING index 6baf4c27e..7e24fcf66 100644 --- a/COPYING +++ b/COPYING @@ -249,7 +249,7 @@ Files: src/streams/qtiocompressor.* Copyright: 2009-2012, Nokia Corporation and/or its subsidiary(-ies) License: LGPL-2.1 or GPL-3 -Files: src/zxcvbn/zxcvbn.* +Files: src/thirdparty/zxcvbn/zxcvbn.* Copyright: 2015-2017, Tony Evans License: MIT diff --git a/cmake/CLangFormat.cmake b/cmake/CLangFormat.cmake index b2df97d4d..df5469c4d 100644 --- a/cmake/CLangFormat.cmake +++ b/cmake/CLangFormat.cmake @@ -16,7 +16,6 @@ set(EXCLUDED_DIRS # third-party directories src/thirdparty - src/zxcvbn # objective-c directories src/touchid src/autotype/mac diff --git a/codecov.yaml b/codecov.yaml index d92656b6f..96ac133ef 100644 --- a/codecov.yaml +++ b/codecov.yaml @@ -1,8 +1,27 @@ +codecov: + require_ci_to_pass: false coverage: range: 60..80 round: nearest precision: 2 + status: + project: + default: + target: auto + threshold: 0.5% + paths: + - "src" + patch: + default: + target: 50% + threshold: 0% + informational: true + paths: + - "src" fixes: - "*/src/::" +ignore: + - "src/gui/styles/**" + - "src/thirdparty/**" comment: require_changes: true diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 40dae9371..baf0543be 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -16,20 +16,6 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) -find_library(ZXCVBN_LIBRARIES zxcvbn) -if(NOT ZXCVBN_LIBRARIES) - add_library(zxcvbn STATIC zxcvbn/zxcvbn.c) - # Disable error-level shadow issues - if(CC_HAS_Wshadow_compatible_local) - set_property(SOURCE zxcvbn/zxcvbn.c APPEND PROPERTY COMPILE_OPTIONS "-Wno-shadow-compatible-local") - endif() - if(CC_HAS_Wshadow_local) - set_property(SOURCE zxcvbn/zxcvbn.c APPEND PROPERTY COMPILE_OPTIONS "-Wno-shadow-local") - endif() - include_directories(${CMAKE_CURRENT_SOURCE_DIR}/zxcvbn) - set(ZXCVBN_LIBRARIES zxcvbn) -endif(NOT ZXCVBN_LIBRARIES) - set(keepassx_SOURCES core/Alloc.cpp core/AutoTypeAssociations.cpp diff --git a/src/cli/CMakeLists.txt b/src/cli/CMakeLists.txt index a3852c800..5d2bb6ba1 100644 --- a/src/cli/CMakeLists.txt +++ b/src/cli/CMakeLists.txt @@ -45,7 +45,7 @@ set(cli_SOURCES Show.cpp) add_library(cli STATIC ${cli_SOURCES}) -target_link_libraries(cli Qt5::Core) +target_link_libraries(cli ${ZXCVBN_LIBRARIES} Qt5::Core) find_package(Readline) diff --git a/src/thirdparty/zxcvbn/CMakeLists.txt b/src/thirdparty/zxcvbn/CMakeLists.txt new file mode 100644 index 000000000..dcc2a5efd --- /dev/null +++ b/src/thirdparty/zxcvbn/CMakeLists.txt @@ -0,0 +1,9 @@ +add_library(zxcvbn STATIC zxcvbn.c) +# Disable error-level shadow issues +if(CC_HAS_Wshadow_compatible_local) + set_property(SOURCE zxcvbn.c APPEND PROPERTY COMPILE_OPTIONS "-Wno-shadow-compatible-local") +endif() +if(CC_HAS_Wshadow_local) + set_property(SOURCE zxcvbn.c APPEND PROPERTY COMPILE_OPTIONS "-Wno-shadow-local") +endif() +target_include_directories(zxcvbn PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/src/zxcvbn/dict-src.h b/src/thirdparty/zxcvbn/dict-src.h similarity index 100% rename from src/zxcvbn/dict-src.h rename to src/thirdparty/zxcvbn/dict-src.h diff --git a/src/zxcvbn/zxcvbn.c b/src/thirdparty/zxcvbn/zxcvbn.c similarity index 100% rename from src/zxcvbn/zxcvbn.c rename to src/thirdparty/zxcvbn/zxcvbn.c diff --git a/src/zxcvbn/zxcvbn.h b/src/thirdparty/zxcvbn/zxcvbn.h similarity index 100% rename from src/zxcvbn/zxcvbn.h rename to src/thirdparty/zxcvbn/zxcvbn.h diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 2285995b5..2ad662609 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -247,7 +247,7 @@ if(WITH_XC_NETWORKING OR WITH_XC_BROWSER) endif() add_unit_test(NAME testcli SOURCES TestCli.cpp - LIBS testsupport cli ${TEST_LIBRARIES}) + LIBS testsupport cli ${ZXCVBN_LIBRARIES} ${TEST_LIBRARIES}) target_compile_definitions(testcli PRIVATE KEEPASSX_CLI_PATH="$") if(WITH_GUI_TESTS) diff --git a/tests/TestCli.cpp b/tests/TestCli.cpp index 5e9c789fb..2235890dc 100644 --- a/tests/TestCli.cpp +++ b/tests/TestCli.cpp @@ -26,7 +26,6 @@ #include "crypto/Crypto.h" #include "keys/FileKey.h" #include "keys/drivers/YubiKey.h" -#include "zxcvbn/zxcvbn.h" #include "cli/Add.h" #include "cli/AddGroup.h" @@ -59,6 +58,7 @@ #include #include #include +#include QTEST_MAIN(TestCli)