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
This commit is contained in:
Jonathan White 2024-06-02 07:37:34 -04:00
parent 95b91a0890
commit 2f43ca42be
No known key found for this signature in database
GPG Key ID: 440FC65F2E0C6E01
12 changed files with 39 additions and 20 deletions

View File

@ -467,7 +467,7 @@ if(WITH_COVERAGE)
append_coverage_compiler_flags() append_coverage_compiler_flags()
set(COVERAGE_EXCLUDES set(COVERAGE_EXCLUDES
"'^(.+/)?(thirdparty|zxcvbn)/.*'" "'^(.+/)?thirdparty/.*'"
"'^(.+/)?main\\.cpp$$'" "'^(.+/)?main\\.cpp$$'"
"'^(.+/)?cli/keepassxc-cli\\.cpp$$'" "'^(.+/)?cli/keepassxc-cli\\.cpp$$'"
"'^(.+/)?proxy/keepassxc-proxy\\.cpp$$'") "'^(.+/)?proxy/keepassxc-proxy\\.cpp$$'")
@ -613,6 +613,12 @@ endif()
include_directories(SYSTEM ${ZLIB_INCLUDE_DIR}) 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(src)
add_subdirectory(share) add_subdirectory(share)
if(WITH_TESTS) if(WITH_TESTS)

View File

@ -249,7 +249,7 @@ Files: src/streams/qtiocompressor.*
Copyright: 2009-2012, Nokia Corporation and/or its subsidiary(-ies) Copyright: 2009-2012, Nokia Corporation and/or its subsidiary(-ies)
License: LGPL-2.1 or GPL-3 License: LGPL-2.1 or GPL-3
Files: src/zxcvbn/zxcvbn.* Files: src/thirdparty/zxcvbn/zxcvbn.*
Copyright: 2015-2017, Tony Evans Copyright: 2015-2017, Tony Evans
License: MIT License: MIT

View File

@ -16,7 +16,6 @@
set(EXCLUDED_DIRS set(EXCLUDED_DIRS
# third-party directories # third-party directories
src/thirdparty src/thirdparty
src/zxcvbn
# objective-c directories # objective-c directories
src/touchid src/touchid
src/autotype/mac src/autotype/mac

View File

@ -1,8 +1,27 @@
codecov:
require_ci_to_pass: false
coverage: coverage:
range: 60..80 range: 60..80
round: nearest round: nearest
precision: 2 precision: 2
status:
project:
default:
target: auto
threshold: 0.5%
paths:
- "src"
patch:
default:
target: 50%
threshold: 0%
informational: true
paths:
- "src"
fixes: fixes:
- "*/src/::" - "*/src/::"
ignore:
- "src/gui/styles/**"
- "src/thirdparty/**"
comment: comment:
require_changes: true require_changes: true

View File

@ -16,20 +16,6 @@
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) 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 set(keepassx_SOURCES
core/Alloc.cpp core/Alloc.cpp
core/AutoTypeAssociations.cpp core/AutoTypeAssociations.cpp

View File

@ -45,7 +45,7 @@ set(cli_SOURCES
Show.cpp) Show.cpp)
add_library(cli STATIC ${cli_SOURCES}) add_library(cli STATIC ${cli_SOURCES})
target_link_libraries(cli Qt5::Core) target_link_libraries(cli ${ZXCVBN_LIBRARIES} Qt5::Core)
find_package(Readline) find_package(Readline)

9
src/thirdparty/zxcvbn/CMakeLists.txt vendored Normal file
View File

@ -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})

View File

@ -247,7 +247,7 @@ if(WITH_XC_NETWORKING OR WITH_XC_BROWSER)
endif() endif()
add_unit_test(NAME testcli SOURCES TestCli.cpp 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="$<TARGET_FILE:keepassxc-cli>") target_compile_definitions(testcli PRIVATE KEEPASSX_CLI_PATH="$<TARGET_FILE:keepassxc-cli>")
if(WITH_GUI_TESTS) if(WITH_GUI_TESTS)

View File

@ -26,7 +26,6 @@
#include "crypto/Crypto.h" #include "crypto/Crypto.h"
#include "keys/FileKey.h" #include "keys/FileKey.h"
#include "keys/drivers/YubiKey.h" #include "keys/drivers/YubiKey.h"
#include "zxcvbn/zxcvbn.h"
#include "cli/Add.h" #include "cli/Add.h"
#include "cli/AddGroup.h" #include "cli/AddGroup.h"
@ -59,6 +58,7 @@
#include <QSignalSpy> #include <QSignalSpy>
#include <QTest> #include <QTest>
#include <QtConcurrent> #include <QtConcurrent>
#include <zxcvbn.h>
QTEST_MAIN(TestCli) QTEST_MAIN(TestCli)