Apply cmake-format and clang-format
This commit is contained in:
parent
d88df866d2
commit
a30853cfeb
|
@ -124,7 +124,7 @@ bool SyncthingNotifier::isDisconnectRelevant() const
|
|||
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
|
||||
&& ((m_service && m_service->isSystemdAvailable()
|
||||
&& !m_service->isActiveWithoutSleepFor(m_process->activeSince(), m_ignoreInavailabilityAfterStart))
|
||||
|| !m_process->isActiveFor(m_ignoreInavailabilityAfterStart))
|
||||
|| !m_process->isActiveFor(m_ignoreInavailabilityAfterStart))
|
||||
#else
|
||||
&& !m_process->isActiveFor(m_ignoreInavailabilityAfterStart)
|
||||
#endif
|
||||
|
|
|
@ -227,7 +227,7 @@ void SyncthingService::handlePropertiesChanged(
|
|||
if (handlePropertyChanged(
|
||||
m_activeState, &SyncthingService::activeStateChanged, QStringLiteral("ActiveState"), changedProperties, invalidatedProperties)
|
||||
| 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);
|
||||
}
|
||||
const bool currentlyRunning = isRunning();
|
||||
|
|
|
@ -38,12 +38,7 @@ use_syncthingmodel()
|
|||
# link also explicitely against the following Qt and KF modules
|
||||
list(APPEND ADDITIONAL_QT_MODULES Network)
|
||||
list(APPEND ADDITIONAL_KF_MODULES KIO)
|
||||
set(KIO_MODULE_TARGETS
|
||||
KF5::KIOCore
|
||||
KF5::KIOFileWidgets
|
||||
KF5::KIOWidgets
|
||||
KF5::KIONTLM
|
||||
)
|
||||
set(KIO_MODULE_TARGETS KF5::KIOCore KF5::KIOFileWidgets KF5::KIOWidgets KF5::KIONTLM)
|
||||
|
||||
# include modules to apply configuration
|
||||
include(BasicConfig)
|
||||
|
|
|
@ -8,134 +8,110 @@ set(META_APP_DESCRIPTION "Syncthing itself, built as a shared or static library"
|
|||
set(META_PROJECT_VARNAME_UPPER LIB_SYNCTHING)
|
||||
|
||||
# add project files
|
||||
set(HEADER_FILES
|
||||
interface.h
|
||||
)
|
||||
set(SRC_FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/libsyncthinginternal.h"
|
||||
interface.cpp
|
||||
)
|
||||
set(HEADER_FILES interface.h)
|
||||
set(SRC_FILES "${CMAKE_CURRENT_BINARY_DIR}/libsyncthinginternal.h" interface.cpp)
|
||||
|
||||
set(TEST_HEADER_FILES
|
||||
)
|
||||
set(TEST_SRC_FILES
|
||||
tests/interfacetests.cpp
|
||||
)
|
||||
set(TEST_HEADER_FILES)
|
||||
set(TEST_SRC_FILES tests/interfacetests.cpp)
|
||||
|
||||
# find the go binary
|
||||
find_program(GO_BIN go)
|
||||
if(NOT GO_BIN)
|
||||
if (NOT GO_BIN)
|
||||
message(FATAL_ERROR "The go binary could not be located.")
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
# determine GOARCH for target
|
||||
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}")
|
||||
elseif(NOT CMAKE_CROSSCOMPILING)
|
||||
elseif (NOT CMAKE_CROSSCOMPILING)
|
||||
set(GO_TARGET_ARCH "")
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
|
||||
elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
|
||||
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")
|
||||
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}")
|
||||
else()
|
||||
else ()
|
||||
message(FATAL_ERROR "Unable to auto-determine GOARCH. Please set GO_TARGET_ARCH_OVERRIDE manually.")
|
||||
endif()
|
||||
endif ()
|
||||
# determine GOOS for target
|
||||
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}")
|
||||
elseif(NOT CMAKE_CROSSCOMPILING)
|
||||
elseif (NOT CMAKE_CROSSCOMPILING)
|
||||
set(GO_TARGET_OS "")
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
set(GO_TARGET_OS "linux")
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
|
||||
elseif (CMAKE_SYSTEM_NAME STREQUAL "Android")
|
||||
set(GO_TARGET_OS "android")
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
set(GO_TARGET_OS "windows")
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
|
||||
elseif (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
|
||||
set(GO_TARGET_OS "freebsd")
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||
elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||
set(GO_TARGET_OS "darwin")
|
||||
else()
|
||||
else ()
|
||||
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}")
|
||||
|
||||
# locate the Syncthing checkout
|
||||
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
|
||||
# caveat: newly added assets will not cause CMake to automatically regenerate
|
||||
file(GLOB_RECURSE SRC_FILES_SYNCTHING_ASSETS
|
||||
LIST_DIRECTORIES false
|
||||
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
"${SYNCTHING_PATH}/gui/*"
|
||||
)
|
||||
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()
|
||||
# find Syncthing's assets caveat: newly added assets will not cause CMake to automatically regenerate
|
||||
file(GLOB_RECURSE SRC_FILES_SYNCTHING_ASSETS LIST_DIRECTORIES false
|
||||
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${SYNCTHING_PATH}/gui/*")
|
||||
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 ()
|
||||
|
||||
# find Syncthing's source code
|
||||
# caveat: newly added files will not cause CMake to automatically regenerate
|
||||
file(GLOB_RECURSE SRC_FILES_SYNCTHING
|
||||
LIST_DIRECTORIES false
|
||||
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
"${SYNCTHING_PATH}/cmd/*.go"
|
||||
"${SYNCTHING_PATH}/cmd/*.h"
|
||||
"${SYNCTHING_PATH}/cmd/*.c"
|
||||
)
|
||||
if(NOT SRC_FILES_SYNCTHING)
|
||||
message(FATAL_ERROR "No *.go files found in Syncthing checkout \"${CMAKE_CURRENT_SOURCE_DIR}/go/src/github.com/syncthing/syncthing\".")
|
||||
endif()
|
||||
# find Syncthing's source code caveat: newly added files will not cause CMake to automatically regenerate
|
||||
file(GLOB_RECURSE SRC_FILES_SYNCTHING LIST_DIRECTORIES false
|
||||
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
"${SYNCTHING_PATH}/cmd/*.go"
|
||||
"${SYNCTHING_PATH}/cmd/*.h"
|
||||
"${SYNCTHING_PATH}/cmd/*.c")
|
||||
if (NOT SRC_FILES_SYNCTHING)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"No *.go files found in Syncthing checkout \"${CMAKE_CURRENT_SOURCE_DIR}/go/src/github.com/syncthing/syncthing\"."
|
||||
)
|
||||
endif ()
|
||||
list(APPEND SRC_FILES_SYNCTHING "${SYNCTHING_PATH}/lib/auto/gui.files.go")
|
||||
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
|
||||
add_custom_command(
|
||||
OUTPUT
|
||||
"${SYNCTHING_PATH}/lib/auto/gui.files.go"
|
||||
COMMAND
|
||||
"GOPATH=${GO_DEVELOPMENT_PATH}"
|
||||
"${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"
|
||||
)
|
||||
add_custom_command(OUTPUT "${SYNCTHING_PATH}/lib/auto/gui.files.go"
|
||||
COMMAND "GOPATH=${GO_DEVELOPMENT_PATH}" "${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
|
||||
add_custom_command(
|
||||
OUTPUT
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/libsyncthinginternal.a"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/libsyncthinginternal.h"
|
||||
COMMAND
|
||||
"CC=${CMAKE_C_COMPILER}"
|
||||
"CXX=${CMAKE_CXX_COMPILER}"
|
||||
"AR=${CMAKE_C_COMPILER_AR}"
|
||||
"GOOS=${GO_TARGET_OS}"
|
||||
"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"
|
||||
)
|
||||
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libsyncthinginternal.a"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/libsyncthinginternal.h"
|
||||
COMMAND "CC=${CMAKE_C_COMPILER}" "CXX=${CMAKE_CXX_COMPILER}" "AR=${CMAKE_C_COMPILER_AR}"
|
||||
"GOOS=${GO_TARGET_OS}" "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
|
||||
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)
|
||||
if(WIN32)
|
||||
if (WIN32)
|
||||
list(APPEND PRIVATE_LIBRARIES -lws2_32 -lwinmm)
|
||||
elseif(UNIX)
|
||||
elseif (UNIX)
|
||||
list(APPEND PRIVATE_LIBRARIES -lpthread)
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
# ensure we can find libsyncthing.h from Syncthing's source tree when building the interface
|
||||
list(APPEND PRIVATE_INCLUDE_DIRS "${SYNCTHING_PATH}/cmd/syncthing")
|
||||
|
@ -155,10 +131,8 @@ include(Doxygen)
|
|||
include(ConfigHeader)
|
||||
|
||||
# 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)
|
||||
install(
|
||||
FILES "${CMAKE_CURRENT_BINARY_DIR}/libsyncthinginternal.a"
|
||||
DESTINATION "lib${SELECTED_LIB_SUFFIX}"
|
||||
COMPONENT binary
|
||||
)
|
||||
endif()
|
||||
if (BUILD_STATIC_LIBS AND NOT META_NO_INSTALL_TARGETS AND ENABLE_INSTALL_TARGETS)
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libsyncthinginternal.a"
|
||||
DESTINATION "lib${SELECTED_LIB_SUFFIX}"
|
||||
COMPONENT binary)
|
||||
endif ()
|
||||
|
|
|
@ -306,7 +306,10 @@ QVariant SyncthingDeviceModel::data(const QModelIndex &index, int role) const
|
|||
|
||||
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
|
||||
|
|
|
@ -364,7 +364,10 @@ QVariant SyncthingDirectoryModel::data(const QModelIndex &index, int role) const
|
|||
|
||||
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
|
||||
|
|
|
@ -189,7 +189,10 @@ QVariant SyncthingDownloadModel::data(const QModelIndex &index, int role) const
|
|||
|
||||
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
|
||||
|
|
|
@ -161,7 +161,8 @@ public:
|
|||
#endif
|
||||
}
|
||||
// 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
|
||||
if (!m_emittedConnection) {
|
||||
CPPUNIT_FAIL(argsToString("Unable to connect signal ", signalName().data(), " to check for signal emmitation"));
|
||||
|
|
|
@ -54,7 +54,7 @@ bool InternalError::isRelevant(const SyncthingConnection &connection, SyncthingE
|
|||
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
|
||||
&& ((service && service->isSystemdAvailable()
|
||||
&& !service->isActiveWithoutSleepFor(launcher->activeSince(), settings.ignoreInavailabilityAfterStart))
|
||||
|| !launcher->isActiveFor(settings.ignoreInavailabilityAfterStart))
|
||||
|| !launcher->isActiveFor(settings.ignoreInavailabilityAfterStart))
|
||||
#else
|
||||
&& !launcher->isActiveFor(settings.ignoreInavailabilityAfterStart)
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue