Apply cmake-format and clang-format

This commit is contained in:
Martchus 2019-05-04 22:10:37 +02:00
parent d88df866d2
commit a30853cfeb
9 changed files with 85 additions and 106 deletions

View File

@ -124,7 +124,7 @@ bool SyncthingNotifier::isDisconnectRelevant() const
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD #ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
&& ((m_service && m_service->isSystemdAvailable() && ((m_service && m_service->isSystemdAvailable()
&& !m_service->isActiveWithoutSleepFor(m_process->activeSince(), m_ignoreInavailabilityAfterStart)) && !m_service->isActiveWithoutSleepFor(m_process->activeSince(), m_ignoreInavailabilityAfterStart))
|| !m_process->isActiveFor(m_ignoreInavailabilityAfterStart)) || !m_process->isActiveFor(m_ignoreInavailabilityAfterStart))
#else #else
&& !m_process->isActiveFor(m_ignoreInavailabilityAfterStart) && !m_process->isActiveFor(m_ignoreInavailabilityAfterStart)
#endif #endif

View File

@ -227,7 +227,7 @@ void SyncthingService::handlePropertiesChanged(
if (handlePropertyChanged( if (handlePropertyChanged(
m_activeState, &SyncthingService::activeStateChanged, QStringLiteral("ActiveState"), changedProperties, invalidatedProperties) m_activeState, &SyncthingService::activeStateChanged, QStringLiteral("ActiveState"), changedProperties, invalidatedProperties)
| handlePropertyChanged( | handlePropertyChanged(
m_subState, &SyncthingService::subStateChanged, QStringLiteral("SubState"), changedProperties, invalidatedProperties)) { m_subState, &SyncthingService::subStateChanged, QStringLiteral("SubState"), changedProperties, invalidatedProperties)) {
emit stateChanged(m_activeState, m_subState, m_activeSince); emit stateChanged(m_activeState, m_subState, m_activeSince);
} }
const bool currentlyRunning = isRunning(); const bool currentlyRunning = isRunning();

View File

@ -38,12 +38,7 @@ use_syncthingmodel()
# link also explicitely against the following Qt and KF modules # link also explicitely against the following Qt and KF modules
list(APPEND ADDITIONAL_QT_MODULES Network) list(APPEND ADDITIONAL_QT_MODULES Network)
list(APPEND ADDITIONAL_KF_MODULES KIO) list(APPEND ADDITIONAL_KF_MODULES KIO)
set(KIO_MODULE_TARGETS set(KIO_MODULE_TARGETS KF5::KIOCore KF5::KIOFileWidgets KF5::KIOWidgets KF5::KIONTLM)
KF5::KIOCore
KF5::KIOFileWidgets
KF5::KIOWidgets
KF5::KIONTLM
)
# include modules to apply configuration # include modules to apply configuration
include(BasicConfig) include(BasicConfig)

View File

@ -8,134 +8,110 @@ set(META_APP_DESCRIPTION "Syncthing itself, built as a shared or static library"
set(META_PROJECT_VARNAME_UPPER LIB_SYNCTHING) set(META_PROJECT_VARNAME_UPPER LIB_SYNCTHING)
# add project files # add project files
set(HEADER_FILES set(HEADER_FILES interface.h)
interface.h set(SRC_FILES "${CMAKE_CURRENT_BINARY_DIR}/libsyncthinginternal.h" interface.cpp)
)
set(SRC_FILES
"${CMAKE_CURRENT_BINARY_DIR}/libsyncthinginternal.h"
interface.cpp
)
set(TEST_HEADER_FILES set(TEST_HEADER_FILES)
) set(TEST_SRC_FILES tests/interfacetests.cpp)
set(TEST_SRC_FILES
tests/interfacetests.cpp
)
# find the go binary # find the go binary
find_program(GO_BIN go) find_program(GO_BIN go)
if(NOT GO_BIN) if (NOT GO_BIN)
message(FATAL_ERROR "The go binary could not be located.") message(FATAL_ERROR "The go binary could not be located.")
endif() endif ()
# determine GOARCH for target # determine GOARCH for target
set(GO_TARGET_ARCH_OVERRIDE "" CACHE STRING "overrides the 'GOARCH' variable") set(GO_TARGET_ARCH_OVERRIDE "" CACHE STRING "overrides the 'GOARCH' variable")
if(GO_TARGET_ARCH_OVERRIDE) if (GO_TARGET_ARCH_OVERRIDE)
set(GO_TARGET_ARCH "${GO_TARGET_ARCH_OVERRIDE}") set(GO_TARGET_ARCH "${GO_TARGET_ARCH_OVERRIDE}")
elseif(NOT CMAKE_CROSSCOMPILING) elseif (NOT CMAKE_CROSSCOMPILING)
set(GO_TARGET_ARCH "") set(GO_TARGET_ARCH "")
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
set(GO_TARGET_ARCH "amd64") set(GO_TARGET_ARCH "amd64")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i[3-6]86") elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "i[3-6]86")
set(GO_TARGET_ARCH "386") set(GO_TARGET_ARCH "386")
elseif(CMAKE_SYSTEM_NAME MATCHES "(ppc64|ppc64le|arm|arm64|s390x)") elseif (CMAKE_SYSTEM_NAME MATCHES "(ppc64|ppc64le|arm|arm64|s390x)")
set(GO_TARGET_ARCH "${CMAKE_SYSTEM_NAME}") set(GO_TARGET_ARCH "${CMAKE_SYSTEM_NAME}")
else() else ()
message(FATAL_ERROR "Unable to auto-determine GOARCH. Please set GO_TARGET_ARCH_OVERRIDE manually.") message(FATAL_ERROR "Unable to auto-determine GOARCH. Please set GO_TARGET_ARCH_OVERRIDE manually.")
endif() endif ()
# determine GOOS for target # determine GOOS for target
set(GO_TARGET_OS_OVERRIDE "" CACHE STRING "overrides the 'GOOS' variable") set(GO_TARGET_OS_OVERRIDE "" CACHE STRING "overrides the 'GOOS' variable")
if(GO_TARGET_OS_OVERRIDE) if (GO_TARGET_OS_OVERRIDE)
set(GO_TARGET_OS "${GO_TARGET_OS_OVERRIDE}") set(GO_TARGET_OS "${GO_TARGET_OS_OVERRIDE}")
elseif(NOT CMAKE_CROSSCOMPILING) elseif (NOT CMAKE_CROSSCOMPILING)
set(GO_TARGET_OS "") set(GO_TARGET_OS "")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(GO_TARGET_OS "linux") set(GO_TARGET_OS "linux")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Android") elseif (CMAKE_SYSTEM_NAME STREQUAL "Android")
set(GO_TARGET_OS "android") set(GO_TARGET_OS "android")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows") elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(GO_TARGET_OS "windows") set(GO_TARGET_OS "windows")
elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") elseif (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
set(GO_TARGET_OS "freebsd") set(GO_TARGET_OS "freebsd")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(GO_TARGET_OS "darwin") set(GO_TARGET_OS "darwin")
else() else ()
message(FATAL_ERROR "Unable to auto-determine GOOS. Please set GO_TARGET_OS_OVERRIDE manually.") message(FATAL_ERROR "Unable to auto-determine GOOS. Please set GO_TARGET_OS_OVERRIDE manually.")
endif() endif ()
message(STATUS "Using GOOS=${GO_TARGET_OS} and GOARCH=${GO_TARGET_ARCH}") message(STATUS "Using GOOS=${GO_TARGET_OS} and GOARCH=${GO_TARGET_ARCH}")
# locate the Syncthing checkout # locate the Syncthing checkout
set(GO_DEVELOPMENT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/go" CACHE PATH "the 'GOPATH'") set(GO_DEVELOPMENT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/go" CACHE PATH "the 'GOPATH'")
set(SYNCTHING_PATH "${CMAKE_CURRENT_SOURCE_DIR}/go/src/github.com/syncthing/syncthing" CACHE PATH "path of Syncthing checkout") set(SYNCTHING_PATH "${CMAKE_CURRENT_SOURCE_DIR}/go/src/github.com/syncthing/syncthing"
CACHE PATH "path of Syncthing checkout")
# find Syncthing's assets # find Syncthing's assets caveat: newly added assets will not cause CMake to automatically regenerate
# caveat: newly added assets will not cause CMake to automatically regenerate file(GLOB_RECURSE SRC_FILES_SYNCTHING_ASSETS LIST_DIRECTORIES false
file(GLOB_RECURSE SRC_FILES_SYNCTHING_ASSETS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${SYNCTHING_PATH}/gui/*")
LIST_DIRECTORIES false if (NOT SRC_FILES_SYNCTHING_ASSETS)
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" message(
"${SYNCTHING_PATH}/gui/*" FATAL_ERROR
) "No asset files found in Syncthing checkout \"${CMAKE_CURRENT_SOURCE_DIR}/go/src/github.com/syncthing/syncthing\"."
if(NOT SRC_FILES_SYNCTHING_ASSETS) )
message(FATAL_ERROR "No asset files found in Syncthing checkout \"${CMAKE_CURRENT_SOURCE_DIR}/go/src/github.com/syncthing/syncthing\".") endif ()
endif()
# find Syncthing's source code # find Syncthing's source code caveat: newly added files will not cause CMake to automatically regenerate
# caveat: newly added files will not cause CMake to automatically regenerate file(GLOB_RECURSE SRC_FILES_SYNCTHING LIST_DIRECTORIES false
file(GLOB_RECURSE SRC_FILES_SYNCTHING RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
LIST_DIRECTORIES false "${SYNCTHING_PATH}/cmd/*.go"
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${SYNCTHING_PATH}/cmd/*.h"
"${SYNCTHING_PATH}/cmd/*.go" "${SYNCTHING_PATH}/cmd/*.c")
"${SYNCTHING_PATH}/cmd/*.h" if (NOT SRC_FILES_SYNCTHING)
"${SYNCTHING_PATH}/cmd/*.c" message(
) FATAL_ERROR
if(NOT SRC_FILES_SYNCTHING) "No *.go files found in Syncthing checkout \"${CMAKE_CURRENT_SOURCE_DIR}/go/src/github.com/syncthing/syncthing\"."
message(FATAL_ERROR "No *.go files found in Syncthing checkout \"${CMAKE_CURRENT_SOURCE_DIR}/go/src/github.com/syncthing/syncthing\".") )
endif() endif ()
list(APPEND SRC_FILES_SYNCTHING "${SYNCTHING_PATH}/lib/auto/gui.files.go") list(APPEND SRC_FILES_SYNCTHING "${SYNCTHING_PATH}/lib/auto/gui.files.go")
message(STATUS "Syncthing's go files: ${SRC_FILES_SYNCTHING}") message(STATUS "Syncthing's go files: ${SRC_FILES_SYNCTHING}")
# generate Syncthing's assets: don't set GOARCH/GOOS here, this is supposed to run on the host # generate Syncthing's assets: don't set GOARCH/GOOS here, this is supposed to run on the host
add_custom_command( add_custom_command(OUTPUT "${SYNCTHING_PATH}/lib/auto/gui.files.go"
OUTPUT COMMAND "GOPATH=${GO_DEVELOPMENT_PATH}" "${GO_BIN}" run ./script/genassets.go gui > lib/auto/gui.files.go
"${SYNCTHING_PATH}/lib/auto/gui.files.go" DEPENDS ${SRC_FILES_SYNCTHING_ASSETS}
COMMAND WORKING_DIRECTORY "${SYNCTHING_PATH}"
"GOPATH=${GO_DEVELOPMENT_PATH}" COMMENT "Building Syncthing's assets")
"${GO_BIN}" run ./script/genassets.go gui > lib/auto/gui.files.go
DEPENDS ${SRC_FILES_SYNCTHING_ASSETS}
WORKING_DIRECTORY "${SYNCTHING_PATH}"
COMMENT "Building Syncthing's assets"
)
# compile Syncthing as static library # compile Syncthing as static library
add_custom_command( add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libsyncthinginternal.a"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libsyncthinginternal.h"
"${CMAKE_CURRENT_BINARY_DIR}/libsyncthinginternal.a" COMMAND "CC=${CMAKE_C_COMPILER}" "CXX=${CMAKE_CXX_COMPILER}" "AR=${CMAKE_C_COMPILER_AR}"
"${CMAKE_CURRENT_BINARY_DIR}/libsyncthinginternal.h" "GOOS=${GO_TARGET_OS}" "GOARCH=${GO_TARGET_ARCH}" "CGO_ENABLED=1" "GOPATH=${GO_DEVELOPMENT_PATH}"
COMMAND "${GO_BIN}" build -v -buildmode c-archive -o "${CMAKE_CURRENT_BINARY_DIR}/libsyncthinginternal.a"
"CC=${CMAKE_C_COMPILER}" ./cmd/syncthing && "${CMAKE_RANLIB}" "${CMAKE_CURRENT_BINARY_DIR}/libsyncthinginternal.a"
"CXX=${CMAKE_CXX_COMPILER}" DEPENDS ${SRC_FILES_SYNCTHING}
"AR=${CMAKE_C_COMPILER_AR}" WORKING_DIRECTORY "${SYNCTHING_PATH}"
"GOOS=${GO_TARGET_OS}" COMMENT "Building Syncthing itself")
"GOARCH=${GO_TARGET_ARCH}"
"CGO_ENABLED=1"
"GOPATH=${GO_DEVELOPMENT_PATH}"
"${GO_BIN}" build -v -buildmode c-archive
-o "${CMAKE_CURRENT_BINARY_DIR}/libsyncthinginternal.a"
./cmd/syncthing
&& "${CMAKE_RANLIB}" "${CMAKE_CURRENT_BINARY_DIR}/libsyncthinginternal.a"
DEPENDS ${SRC_FILES_SYNCTHING}
WORKING_DIRECTORY "${SYNCTHING_PATH}"
COMMENT "Building Syncthing itself"
)
# do not use this library directly but depend on it # do not use this library directly but depend on it
list(APPEND PRIVATE_LIBRARIES "${CMAKE_CURRENT_BINARY_DIR}/libsyncthinginternal.a") list(APPEND PRIVATE_LIBRARIES "${CMAKE_CURRENT_BINARY_DIR}/libsyncthinginternal.a")
# add additional libraries (not sure if go build could provide this list somehow to make this more generic) # add additional libraries (not sure if go build could provide this list somehow to make this more generic)
if(WIN32) if (WIN32)
list(APPEND PRIVATE_LIBRARIES -lws2_32 -lwinmm) list(APPEND PRIVATE_LIBRARIES -lws2_32 -lwinmm)
elseif(UNIX) elseif (UNIX)
list(APPEND PRIVATE_LIBRARIES -lpthread) list(APPEND PRIVATE_LIBRARIES -lpthread)
endif() endif ()
# ensure we can find libsyncthing.h from Syncthing's source tree when building the interface # ensure we can find libsyncthing.h from Syncthing's source tree when building the interface
list(APPEND PRIVATE_INCLUDE_DIRS "${SYNCTHING_PATH}/cmd/syncthing") list(APPEND PRIVATE_INCLUDE_DIRS "${SYNCTHING_PATH}/cmd/syncthing")
@ -155,10 +131,8 @@ include(Doxygen)
include(ConfigHeader) include(ConfigHeader)
# create install target for static libsyncthinginternal.a if we're also creating a static libsyncthing.a # create install target for static libsyncthinginternal.a if we're also creating a static libsyncthing.a
if(BUILD_STATIC_LIBS AND NOT META_NO_INSTALL_TARGETS AND ENABLE_INSTALL_TARGETS) if (BUILD_STATIC_LIBS AND NOT META_NO_INSTALL_TARGETS AND ENABLE_INSTALL_TARGETS)
install( install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libsyncthinginternal.a"
FILES "${CMAKE_CURRENT_BINARY_DIR}/libsyncthinginternal.a" DESTINATION "lib${SELECTED_LIB_SUFFIX}"
DESTINATION "lib${SELECTED_LIB_SUFFIX}" COMPONENT binary)
COMPONENT binary endif ()
)
endif()

View File

@ -306,7 +306,10 @@ QVariant SyncthingDeviceModel::data(const QModelIndex &index, int role) const
bool SyncthingDeviceModel::setData(const QModelIndex &index, const QVariant &value, int role) bool SyncthingDeviceModel::setData(const QModelIndex &index, const QVariant &value, int role)
{ {
Q_UNUSED(index) Q_UNUSED(value) Q_UNUSED(role) return false; Q_UNUSED(index)
Q_UNUSED(value)
Q_UNUSED(role)
return false;
} }
int SyncthingDeviceModel::rowCount(const QModelIndex &parent) const int SyncthingDeviceModel::rowCount(const QModelIndex &parent) const

View File

@ -364,7 +364,10 @@ QVariant SyncthingDirectoryModel::data(const QModelIndex &index, int role) const
bool SyncthingDirectoryModel::setData(const QModelIndex &index, const QVariant &value, int role) bool SyncthingDirectoryModel::setData(const QModelIndex &index, const QVariant &value, int role)
{ {
Q_UNUSED(index) Q_UNUSED(value) Q_UNUSED(role) return false; Q_UNUSED(index)
Q_UNUSED(value)
Q_UNUSED(role)
return false;
} }
int SyncthingDirectoryModel::rowCount(const QModelIndex &parent) const int SyncthingDirectoryModel::rowCount(const QModelIndex &parent) const

View File

@ -189,7 +189,10 @@ QVariant SyncthingDownloadModel::data(const QModelIndex &index, int role) const
bool SyncthingDownloadModel::setData(const QModelIndex &index, const QVariant &value, int role) bool SyncthingDownloadModel::setData(const QModelIndex &index, const QVariant &value, int role)
{ {
Q_UNUSED(index) Q_UNUSED(value) Q_UNUSED(role) return false; Q_UNUSED(index)
Q_UNUSED(value)
Q_UNUSED(role)
return false;
} }
int SyncthingDownloadModel::rowCount(const QModelIndex &parent) const int SyncthingDownloadModel::rowCount(const QModelIndex &parent) const

View File

@ -161,7 +161,8 @@ public:
#endif #endif
} }
// register own handler to detect whether signal has been emitted // register own handler to detect whether signal has been emitted
m_emittedConnection = QObject::connect(sender, signal, sender, [this] { m_signalEmitted = true; }, Qt::DirectConnection); m_emittedConnection = QObject::connect(
sender, signal, sender, [this] { m_signalEmitted = true; }, Qt::DirectConnection);
#ifndef SYNCTHINGTESTHELPER_FOR_CLI #ifndef SYNCTHINGTESTHELPER_FOR_CLI
if (!m_emittedConnection) { if (!m_emittedConnection) {
CPPUNIT_FAIL(argsToString("Unable to connect signal ", signalName().data(), " to check for signal emmitation")); CPPUNIT_FAIL(argsToString("Unable to connect signal ", signalName().data(), " to check for signal emmitation"));

View File

@ -54,7 +54,7 @@ bool InternalError::isRelevant(const SyncthingConnection &connection, SyncthingE
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD #ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
&& ((service && service->isSystemdAvailable() && ((service && service->isSystemdAvailable()
&& !service->isActiveWithoutSleepFor(launcher->activeSince(), settings.ignoreInavailabilityAfterStart)) && !service->isActiveWithoutSleepFor(launcher->activeSince(), settings.ignoreInavailabilityAfterStart))
|| !launcher->isActiveFor(settings.ignoreInavailabilityAfterStart)) || !launcher->isActiveFor(settings.ignoreInavailabilityAfterStart))
#else #else
&& !launcher->isActiveFor(settings.ignoreInavailabilityAfterStart) && !launcher->isActiveFor(settings.ignoreInavailabilityAfterStart)
#endif #endif