mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
build-system: start adding a headless build
Right now this doesn't do a thing, but it gives us a nice target that has far fewer dependencies and should contain enough parts to download stuff from a divecomputer and then sync that with cloud storage. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
a23c3d0bb1
commit
057c151fe8
5 changed files with 162 additions and 6 deletions
|
@ -52,8 +52,8 @@ option(FTDISUPPORT "enable support for libftdi based serial" OFF)
|
||||||
# Options regarding What should we build on subsurface
|
# Options regarding What should we build on subsurface
|
||||||
option(MAKE_TESTS "Make the tests" ON)
|
option(MAKE_TESTS "Make the tests" ON)
|
||||||
|
|
||||||
SET(SUBSURFACE_TARGET_EXECUTABLE "DesktopExecutable" CACHE STRING "The type of application, DesktopExecutable or MobileExecutable")
|
SET(SUBSURFACE_TARGET_EXECUTABLE "DesktopExecutable" CACHE STRING "The type of application, DesktopExecutable, MobileExecutable, or DownloaderExecutable")
|
||||||
LIST(APPEND SUBSURFACE_ACCEPTED_EXECUTABLES "DesktopExecutable" "MobileExecutable")
|
LIST(APPEND SUBSURFACE_ACCEPTED_EXECUTABLES "DesktopExecutable" "MobileExecutable" "DownloaderExecutable")
|
||||||
SET_PROPERTY(CACHE SUBSURFACE_TARGET_EXECUTABLE PROPERTY STRINGS ${SUBSURFACE_ACCEPTED_EXECUTABLES})
|
SET_PROPERTY(CACHE SUBSURFACE_TARGET_EXECUTABLE PROPERTY STRINGS ${SUBSURFACE_ACCEPTED_EXECUTABLES})
|
||||||
|
|
||||||
#verify if Platform is correct and warn on wxit with example.
|
#verify if Platform is correct and warn on wxit with example.
|
||||||
|
@ -199,6 +199,11 @@ elseif (SUBSURFACE_TARGET_EXECUTABLE MATCHES "MobileExecutable")
|
||||||
|
|
||||||
message(STATUS "Building Subsurface-mobile requires BT support")
|
message(STATUS "Building Subsurface-mobile requires BT support")
|
||||||
set(BTSUPPORT ON)
|
set(BTSUPPORT ON)
|
||||||
|
elseif (SUBSURFACE_TARGET_EXECUTABLE MATCHES "DownloaderExecutable")
|
||||||
|
set(SUBSURFACE_TARGET subsurface-downloader)
|
||||||
|
set(BTSUPPORT ON)
|
||||||
|
add_definitions(-DSUBSURFACE_DOWNLOADER)
|
||||||
|
message(STATUS "building the embedded Subsurface-downloader app")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ANDROID)
|
if(ANDROID)
|
||||||
|
@ -269,13 +274,17 @@ endif()
|
||||||
set(QT_FIND_COMPONENTS Core Concurrent Widgets Network Svg Positioning Quick Location ${QT_EXTRA_COMPONENTS})
|
set(QT_FIND_COMPONENTS Core Concurrent Widgets Network Svg Positioning Quick Location ${QT_EXTRA_COMPONENTS})
|
||||||
if (SUBSURFACE_TARGET_EXECUTABLE MATCHES "DesktopExecutable")
|
if (SUBSURFACE_TARGET_EXECUTABLE MATCHES "DesktopExecutable")
|
||||||
find_package(Qt5 5.9.1 REQUIRED COMPONENTS ${QT_FIND_COMPONENTS} LinguistTools Test QuickTest)
|
find_package(Qt5 5.9.1 REQUIRED COMPONENTS ${QT_FIND_COMPONENTS} LinguistTools Test QuickTest)
|
||||||
else()
|
elseif (SUBSURFACE_TARGET_EXECUTABLE MATCHES "MobileExecutable")
|
||||||
# Kirigami 5.62 and newer require at least Qt 5.12
|
# Kirigami 5.62 and newer require at least Qt 5.12
|
||||||
if(ANDROID)
|
if(ANDROID)
|
||||||
find_package(Qt5 5.12 REQUIRED COMPONENTS ${QT_FIND_COMPONENTS} LinguistTools)
|
find_package(Qt5 5.12 REQUIRED COMPONENTS ${QT_FIND_COMPONENTS} LinguistTools)
|
||||||
else()
|
else()
|
||||||
find_package(Qt5 5.12 REQUIRED COMPONENTS ${QT_FIND_COMPONENTS} LinguistTools Test QuickTest)
|
find_package(Qt5 5.12 REQUIRED COMPONENTS ${QT_FIND_COMPONENTS} LinguistTools Test QuickTest)
|
||||||
endif()
|
endif()
|
||||||
|
elseif (SUBSURFACE_TARGET_EXECUTABLE MATCHES "DownloaderExecutable")
|
||||||
|
# let's pick a version that's not ancient
|
||||||
|
find_package(Qt5 5.12 REQUIRED COMPONENTS ${QT_FIND_COMPONENTS})
|
||||||
|
set(MAKE_TESTS OFF)
|
||||||
endif()
|
endif()
|
||||||
foreach(_QT_COMPONENT ${QT_FIND_COMPONENTS})
|
foreach(_QT_COMPONENT ${QT_FIND_COMPONENTS})
|
||||||
list(APPEND QT_LIBRARIES Qt5::${_QT_COMPONENT})
|
list(APPEND QT_LIBRARIES Qt5::${_QT_COMPONENT})
|
||||||
|
@ -286,7 +295,9 @@ endif()
|
||||||
|
|
||||||
#set up the subsurface_link_libraries variable
|
#set up the subsurface_link_libraries variable
|
||||||
set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} ${LIBDIVECOMPUTER_LIBRARIES} ${LIBGIT2_LIBRARIES} ${LIBUSB_LIBRARIES} ${LIBMTP_LIBRARIES})
|
set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} ${LIBDIVECOMPUTER_LIBRARIES} ${LIBGIT2_LIBRARIES} ${LIBUSB_LIBRARIES} ${LIBMTP_LIBRARIES})
|
||||||
qt5_add_resources(SUBSURFACE_RESOURCES subsurface.qrc map-widget/qml/map-widget.qrc)
|
if (NOT SUBSURFACE_TARGET_EXECUTABLE MATCHES "DownloaderExecutable")
|
||||||
|
qt5_add_resources(SUBSURFACE_RESOURCES subsurface.qrc map-widget/qml/map-widget.qrc)
|
||||||
|
endif()
|
||||||
|
|
||||||
# hack to build successfully on LGTM
|
# hack to build successfully on LGTM
|
||||||
if(DEFINED ENV{LGTM_SRC})
|
if(DEFINED ENV{LGTM_SRC})
|
||||||
|
@ -294,13 +305,17 @@ if(DEFINED ENV{LGTM_SRC})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# include translations
|
# include translations
|
||||||
|
if (NOT SUBSURFACE_TARGET_EXECUTABLE MATCHES "DownloaderExecutable")
|
||||||
add_subdirectory(translations)
|
add_subdirectory(translations)
|
||||||
|
endif()
|
||||||
add_subdirectory(core)
|
add_subdirectory(core)
|
||||||
add_subdirectory(qt-models)
|
add_subdirectory(qt-models)
|
||||||
add_subdirectory(commands)
|
add_subdirectory(commands)
|
||||||
|
if (NOT SUBSURFACE_TARGET_EXECUTABLE MATCHES "DownloaderExecutable")
|
||||||
add_subdirectory(profile-widget)
|
add_subdirectory(profile-widget)
|
||||||
add_subdirectory(map-widget)
|
add_subdirectory(map-widget)
|
||||||
add_subdirectory(mobile-widgets)
|
add_subdirectory(mobile-widgets)
|
||||||
|
endif()
|
||||||
add_subdirectory(backend-shared)
|
add_subdirectory(backend-shared)
|
||||||
|
|
||||||
if (SUBSURFACE_TARGET_EXECUTABLE MATCHES "DesktopExecutable")
|
if (SUBSURFACE_TARGET_EXECUTABLE MATCHES "DesktopExecutable")
|
||||||
|
@ -370,6 +385,17 @@ elseif (SUBSURFACE_TARGET_EXECUTABLE MATCHES "DesktopExecutable")
|
||||||
add_dependencies(subsurface_profile subsurface_generated_ui)
|
add_dependencies(subsurface_profile subsurface_generated_ui)
|
||||||
add_dependencies(subsurface_models_desktop subsurface_generated_ui)
|
add_dependencies(subsurface_models_desktop subsurface_generated_ui)
|
||||||
add_dependencies(subsurface_generated_ui version)
|
add_dependencies(subsurface_generated_ui version)
|
||||||
|
elseif (SUBSURFACE_TARGET_EXECUTABLE MATCHES "DownloaderExecutable")
|
||||||
|
set(DOWNLOADER_APP
|
||||||
|
subsurface-downloader-main.cpp
|
||||||
|
)
|
||||||
|
source_group("Downloader App" FILES ${DOWNLOADER_APP})
|
||||||
|
add_executable(${SUBSURFACE_TARGET} MACOSX_BUNDLE WIN32 ${SUBSURFACE_PKG} ${DOWNLOADER_APP} ${SUBSURFACE_RESOURCES})
|
||||||
|
target_link_libraries(
|
||||||
|
${SUBSURFACE_TARGET}
|
||||||
|
subsurface_corelib
|
||||||
|
${SUBSURFACE_LINK_LIBRARIES}
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_dependencies(subsurface_corelib version)
|
add_dependencies(subsurface_corelib version)
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include "gettextfromc.h"
|
#include "gettextfromc.h"
|
||||||
#include "qthelper.h"
|
#include "qthelper.h"
|
||||||
#include "subsurface-qt/divelistnotifier.h"
|
#include "subsurface-qt/divelistnotifier.h"
|
||||||
#ifndef SUBSURFACE_MOBILE
|
#if !defined(SUBSURFACE_MOBILE) && !defined(SUBSURFACE_DOWNLOADER)
|
||||||
#include "desktop-widgets/mapwidget.h"
|
#include "desktop-widgets/mapwidget.h"
|
||||||
#include "desktop-widgets/mainwindow.h"
|
#include "desktop-widgets/mainwindow.h"
|
||||||
#include "desktop-widgets/divelistview.h"
|
#include "desktop-widgets/divelistview.h"
|
||||||
|
@ -103,7 +103,7 @@ bool DiveFilter::showDive(const struct dive *d) const
|
||||||
[d] (const filter_constraint &c) { return filter_constraint_match_dive(c, d); });
|
[d] (const filter_constraint &c) { return filter_constraint_match_dive(c, d); });
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef SUBSURFACE_MOBILE
|
#if !defined(SUBSURFACE_MOBILE) && !defined(SUBSURFACE_DOWNLOADER)
|
||||||
void DiveFilter::startFilterDiveSites(QVector<dive_site *> ds)
|
void DiveFilter::startFilterDiveSites(QVector<dive_site *> ds)
|
||||||
{
|
{
|
||||||
if (++diveSiteRefCount > 1) {
|
if (++diveSiteRefCount > 1) {
|
||||||
|
|
|
@ -419,6 +419,8 @@ QString getUserAgent()
|
||||||
// replace all other ':' with ' ' so that this is easy to parse
|
// replace all other ':' with ' ' so that this is easy to parse
|
||||||
#ifdef SUBSURFACE_MOBILE
|
#ifdef SUBSURFACE_MOBILE
|
||||||
QString userAgent = QString("Subsurface-mobile:%1(%2):").arg(subsurface_mobile_version()).arg(subsurface_canonical_version());
|
QString userAgent = QString("Subsurface-mobile:%1(%2):").arg(subsurface_mobile_version()).arg(subsurface_canonical_version());
|
||||||
|
#elif SUBSURFACE_DOWNLOADER
|
||||||
|
QString userAgent = QString("Subsurface-downloader:%1:").arg(subsurface_canonical_version());
|
||||||
#else
|
#else
|
||||||
QString userAgent = QString("Subsurface:%1:").arg(subsurface_canonical_version());
|
QString userAgent = QString("Subsurface:%1:").arg(subsurface_canonical_version());
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -132,7 +132,11 @@ void print_version()
|
||||||
static bool version_printed = false;
|
static bool version_printed = false;
|
||||||
if (version_printed)
|
if (version_printed)
|
||||||
return;
|
return;
|
||||||
|
#if defined(SUBSURFACE_DOWNLOADER)
|
||||||
|
printf("Subsurface-downloader v%s,\n", subsurface_git_version());
|
||||||
|
#else
|
||||||
printf("Subsurface v%s,\n", subsurface_git_version());
|
printf("Subsurface v%s,\n", subsurface_git_version());
|
||||||
|
#endif
|
||||||
printf("built with libdivecomputer v%s\n", dc_version(NULL));
|
printf("built with libdivecomputer v%s\n", dc_version(NULL));
|
||||||
print_qt_versions();
|
print_qt_versions();
|
||||||
int git_maj, git_min, git_rev;
|
int git_maj, git_min, git_rev;
|
||||||
|
|
124
subsurface-downloader-main.cpp
Normal file
124
subsurface-downloader-main.cpp
Normal file
|
@ -0,0 +1,124 @@
|
||||||
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
|
/* main.c */
|
||||||
|
#include "core/downloadfromdcthread.h" // for fill_computer_list
|
||||||
|
#include "core/errorhelper.h"
|
||||||
|
#include "core/parse.h"
|
||||||
|
#include "core/qthelper.h"
|
||||||
|
#include "core/subsurfacestartup.h"
|
||||||
|
#include "core/settings/qPref.h"
|
||||||
|
#include "core/tag.h"
|
||||||
|
#include "core/dive.h"
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QLoggingCategory>
|
||||||
|
#include <QStringList>
|
||||||
|
#include <git2.h>
|
||||||
|
|
||||||
|
static bool filesOnCommandLine = false;
|
||||||
|
static void messageHandler(QtMsgType type, const QMessageLogContext &ctx, const QString &msg);
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
qInstallMessageHandler(messageHandler);
|
||||||
|
// we always run this in verbose mode as there is no UI
|
||||||
|
verbose = 1;
|
||||||
|
|
||||||
|
// now let's say Hi
|
||||||
|
print_version();
|
||||||
|
|
||||||
|
// supporting BT makes sense when used with an iPhone and an rfcomm BT device?
|
||||||
|
QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
|
||||||
|
|
||||||
|
int i;
|
||||||
|
bool no_filenames = true;
|
||||||
|
std::unique_ptr<QApplication> app(new QApplication(argc, argv));
|
||||||
|
QStringList files;
|
||||||
|
QStringList importedFiles;
|
||||||
|
QStringList arguments = QCoreApplication::arguments();
|
||||||
|
|
||||||
|
const char *default_directory = system_default_directory();
|
||||||
|
const char *default_filename = system_default_filename();
|
||||||
|
subsurface_mkdir(default_directory);
|
||||||
|
|
||||||
|
if (subsurface_user_is_root() && !force_root) {
|
||||||
|
printf("You are running Subsurface as root. This is not recommended.\n");
|
||||||
|
printf("If you insist to do so, run with option --allow_run_as_root.\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
git_libgit2_init();
|
||||||
|
setup_system_prefs();
|
||||||
|
copy_prefs(&default_prefs, &prefs);
|
||||||
|
|
||||||
|
// now handle the arguments
|
||||||
|
for (i = 1; i < arguments.length(); i++) {
|
||||||
|
QString a = arguments.at(i);
|
||||||
|
if (a.isEmpty())
|
||||||
|
continue;
|
||||||
|
if (a.at(0) == '-') {
|
||||||
|
parse_argument(qPrintable(a));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (imported) {
|
||||||
|
importedFiles.push_back(a);
|
||||||
|
} else {
|
||||||
|
no_filenames = false;
|
||||||
|
files.push_back(a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fill_computer_list();
|
||||||
|
parse_xml_init();
|
||||||
|
taglist_init_global();
|
||||||
|
|
||||||
|
if (no_filenames) {
|
||||||
|
if (prefs.default_file_behavior == LOCAL_DEFAULT_FILE) {
|
||||||
|
QString defaultFile(prefs.default_filename);
|
||||||
|
if (!defaultFile.isEmpty())
|
||||||
|
files.push_back(QString(prefs.default_filename));
|
||||||
|
} else if (prefs.default_file_behavior == CLOUD_DEFAULT_FILE) {
|
||||||
|
QString cloudURL;
|
||||||
|
if (getCloudURL(cloudURL) == 0)
|
||||||
|
files.push_back(cloudURL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
filesOnCommandLine = !files.isEmpty() || !importedFiles.isEmpty();
|
||||||
|
if (!files.isEmpty())
|
||||||
|
qDebug() << "loading dive data from" << files;
|
||||||
|
print_files();
|
||||||
|
if (!quit) {
|
||||||
|
// do something
|
||||||
|
;
|
||||||
|
}
|
||||||
|
taglist_free(g_tag_list);
|
||||||
|
parse_xml_exit();
|
||||||
|
free((void *)default_directory);
|
||||||
|
free((void *)default_filename);
|
||||||
|
|
||||||
|
// Sync struct preferences to disk
|
||||||
|
qPref::sync();
|
||||||
|
|
||||||
|
free_prefs();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// install this message handler primarily so that the Windows build can log to files
|
||||||
|
void messageHandler(QtMsgType type, const QMessageLogContext &, const QString &msg)
|
||||||
|
{
|
||||||
|
QByteArray localMsg = msg.toUtf8();
|
||||||
|
switch (type) {
|
||||||
|
case QtDebugMsg:
|
||||||
|
fprintf(stdout, "%s\n", localMsg.constData());
|
||||||
|
break;
|
||||||
|
case QtInfoMsg:
|
||||||
|
fprintf(stdout, "%s\n", localMsg.constData());
|
||||||
|
break;
|
||||||
|
case QtWarningMsg:
|
||||||
|
fprintf(stderr, "%s\n", localMsg.constData());
|
||||||
|
break;
|
||||||
|
case QtCriticalMsg:
|
||||||
|
fprintf(stderr, "%s\n", localMsg.constData());
|
||||||
|
break;
|
||||||
|
case QtFatalMsg:
|
||||||
|
fprintf(stderr, "%s\n", localMsg.constData());
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue