aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Tari <robert@tari.in>2021-11-26 09:05:18 +0100
committerRobert Tari <robert@tari.in>2021-12-03 12:26:17 +0100
commit5544dd0e3ad817cbe8f433068ee4da32319b10cb (patch)
tree47a9535ec4896aae843035f2d7cd1d9fcdfc8b76
parent87bbf6da491fbbaa5b0d4babe3d3ceb270820695 (diff)
downloadayatana-indicator-datetime-5544dd0e3ad817cbe8f433068ee4da32319b10cb.tar.gz
ayatana-indicator-datetime-5544dd0e3ad817cbe8f433068ee4da32319b10cb.tar.bz2
ayatana-indicator-datetime-5544dd0e3ad817cbe8f433068ee4da32319b10cb.zip
Make Lomiri features configurable at build time
-rw-r--r--CMakeLists.txt70
-rw-r--r--src/CMakeLists.txt6
-rw-r--r--src/main.cpp6
-rw-r--r--src/notifications.cpp6
-rw-r--r--src/snap.cpp2
-rw-r--r--tests/CMakeLists.txt31
6 files changed, 64 insertions, 57 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3370b06..0b2bff3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,6 +14,7 @@ set (PACKAGE ${CMAKE_PROJECT_NAME})
option(ENABLE_TESTS "Enable all tests and checks" OFF)
option(ENABLE_COVERAGE "Enable coverage reports (includes enabling all tests and checks)" OFF)
option(ENABLE_WERROR "Treat all build warnings as errors" OFF)
+option(ENABLE_LOMIRI_FEATURES "Build with Lomiri-specific libraries, schemas and media" OFF)
if(ENABLE_COVERAGE)
set(ENABLE_TESTS ON)
@@ -43,11 +44,6 @@ set (GETTEXT_PACKAGE "ayatana-indicator-datetime")
add_definitions (-DGETTEXT_PACKAGE="${GETTEXT_PACKAGE}"
-DLOCALEDIR="${CMAKE_INSTALL_FULL_LOCALEDIR}")
-set(ALARM_DEFAULT_SOUND "/usr/share/sounds/lomiri/ringtones/Alarm clock.ogg")
-set(CALENDAR_DEFAULT_SOUND "/usr/share/sounds/lomiri/ringtones/Marimbach.ogg")
-add_definitions(-DALARM_DEFAULT_SOUND="${ALARM_DEFAULT_SOUND}"
- -DCALENDAR_DEFAULT_SOUND="${CALENDAR_DEFAULT_SOUND}")
-
##
## Check for prerequisites
##
@@ -56,33 +52,46 @@ find_package (PkgConfig REQUIRED)
include (CheckIncludeFile)
include (FindPkgConfig)
-pkg_check_modules (SERVICE_DEPS REQUIRED
- libayatana-common>=0.9.3
- glib-2.0>=2.36
- gio-unix-2.0>=2.36
- libical>=0.48
- libecal-2.0>=3.16
- libedataserver-1.2>=3.5
- gstreamer-1.0>=1.2
- libnotify>=0.7.6
- properties-cpp>=0.0.1
- libaccounts-glib>=1.18
- messaging-menu>=0.8.2
- uuid>=2.25)
+set (
+ SERVICE_DEPS
+ libayatana-common>=0.9.3
+ glib-2.0>=2.36
+ gio-unix-2.0>=2.36
+ libical>=0.48
+ libecal-2.0>=3.16
+ libedataserver-1.2>=3.5
+ gstreamer-1.0>=1.2
+ libnotify>=0.7.6
+ properties-cpp>=0.0.1
+ libaccounts-glib>=1.18
+ messaging-menu>=0.8.2
+ uuid>=2.25
+)
+
+if (ENABLE_LOMIRI_FEATURES)
+ list (
+ APPEND
+ SERVICE_DEPS
+ lomiri-url-dispatcher>=0
+ lomiri-sounds
+ lomiri-schemas
+ )
+
+ add_definitions (
+ -DLOMIRI_FEATURES_ENABLED
+ -DALARM_DEFAULT_SOUND="/usr/share/sounds/lomiri/ringtones/Alarm clock.ogg"
+ -DCALENDAR_DEFAULT_SOUND="/usr/share/sounds/lomiri/ringtones/Marimbach.ogg"
+ )
+else ()
+ add_definitions (
+ -DALARM_DEFAULT_SOUND="dummy"
+ -DCALENDAR_DEFAULT_SOUND="dummy"
+ )
+endif ()
+
+pkg_check_modules (SERVICE_DEPS REQUIRED ${SERVICE_DEPS})
include_directories (SYSTEM ${SERVICE_DEPS_INCLUDE_DIRS})
-# lomiri-url-dispatcher
-
-pkg_check_modules(URLDISPATCHER lomiri-url-dispatcher>=0)
-include_directories(${URLDISPATCHER_INCLUDE_DIRS})
-
-if(URLDISPATCHER_FOUND)
- add_definitions( -DHAS_URLDISPATCHER )
-endif()
-
-pkg_check_modules(LOMIRI_SOUNDS lomiri-sounds)
-pkg_check_modules(LOMIRI_SCHEMAS lomiri-schemas)
-
##
## custom targets
##
@@ -148,3 +157,4 @@ endif()
message(STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}")
message(STATUS "Unit tests: ${ENABLE_TESTS}")
message(STATUS "Build with -Werror: ${ENABLE_WERROR}")
+message(STATUS "Build with Lomiri features: ${ENABLE_LOMIRI_FEATURES}")
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d6d6844..5409c91 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -47,11 +47,11 @@ set(SERVICE_GENERATED_SOURCES)
add_gdbus_codegen(SERVICE_GENERATED_SOURCES dbus-alarm-properties
org.ayatana.indicator
${CMAKE_SOURCE_DIR}/data/org.ayatana.indicator.datetime.AlarmProperties.xml)
-if(LOMIRI_SCHEMAS_FOUND)
+
+if (ENABLE_LOMIRI_FEATURES)
add_gdbus_codegen(SERVICE_GENERATED_SOURCES dbus-accounts-sound
com.lomiri.touch
/usr/share/accountsservice/interfaces/com.lomiri.touch.AccountsService.Sound.xml)
- add_definitions (-DHAS_LOMIRI_SCHEMAS)
endif()
# add warnings/coverage info on handwritten files
@@ -70,5 +70,5 @@ link_directories (${SERVICE_DEPS_LIBRARY_DIRS})
add_executable (${SERVICE_EXEC} main.cpp)
set_source_files_properties(${SERVICE_SOURCES} main.cpp PROPERTIES COMPILE_FLAGS ${COMPILE_FLAGS})
-target_link_libraries (${SERVICE_EXEC} ${SERVICE_LIB} ${SERVICE_DEPS_LIBRARIES} ${URLDISPATCHER_LIBRARIES})
+target_link_libraries (${SERVICE_EXEC} ${SERVICE_LIB} ${SERVICE_DEPS_LIBRARIES})
install (TARGETS ${SERVICE_EXEC} RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_PKGLIBEXECDIR})
diff --git a/src/main.cpp b/src/main.cpp
index 0dc7198..4590e84 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -32,7 +32,7 @@
#include <datetime/planner-snooze.h>
#include <datetime/planner-range.h>
#include <datetime/settings-live.h>
-#ifdef HAS_LOMIRI_SCHEMAS
+#ifdef LOMIRI_FEATURES_ENABLED
#include <datetime/snap.h>
#endif
#include <datetime/state.h>
@@ -95,7 +95,7 @@ namespace
return state;
}
-#ifdef HAS_LOMIRI_SCHEMAS
+#ifdef LOMIRI_FEATURES_ENABLED
std::shared_ptr<AlarmQueue> create_simple_alarm_queue(const std::shared_ptr<Clock>& clock,
const std::shared_ptr<Planner>& snooze_planner,
const std::shared_ptr<Engine>& engine,
@@ -149,7 +149,7 @@ main(int /*argc*/, char** /*argv*/)
auto actions = std::make_shared<LiveActions>(state);
MenuFactory factory(actions, state);
-#ifdef HAS_LOMIRI_SCHEMAS
+#ifdef LOMIRI_FEATURES_ENABLED
// set up the snap decisions
auto snooze_planner = std::make_shared<SnoozePlanner>(state->settings, state->clock);
auto notification_engine = std::make_shared<ain::Engine>("ayatana-indicator-datetime-service");
diff --git a/src/notifications.cpp b/src/notifications.cpp
index f21b5e8..e38e5dc 100644
--- a/src/notifications.cpp
+++ b/src/notifications.cpp
@@ -1,5 +1,6 @@
/*
* Copyright 2014 Canonical Ltd.
+ * Copyright 2021 Robert Tari
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
@@ -15,6 +16,7 @@
*
* Authors:
* Charles Kerr <charles.kerr@canonical.com>
+ * Robert Tari <robert@tari.in>
*/
#include <notifications/notifications.h>
@@ -24,7 +26,7 @@
#include <messaging-menu/messaging-menu-app.h>
#include <messaging-menu/messaging-menu-message.h>
-#ifdef HAS_URLDISPATCHER
+#ifdef LOMIRI_FEATURES_ENABLED
#include <lomiri-url-dispatcher.h>
#endif
@@ -462,7 +464,7 @@ private:
static std::string calendar_app_id()
{
-#ifdef HAS_URLDISPATCHER
+#ifdef LOMIRI_FEATURES_ENABLED
auto urls = g_strsplit("calendar://", ",", 0);
auto appids = lomiri_url_dispatch_url_appid(const_cast<const gchar**>(urls));
g_strfreev(urls);
diff --git a/src/snap.cpp b/src/snap.cpp
index e306dea..46f1d7b 100644
--- a/src/snap.cpp
+++ b/src/snap.cpp
@@ -19,7 +19,7 @@
* Robert Tari <robert@tari.in>
*/
-#ifdef HAS_LOMIRI_SCHEMAS
+#ifdef LOMIRI_FEATURES_ENABLED
#include "dbus-accounts-sound.h"
#include <datetime/snap.h>
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 7a6a301..247761f 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -41,45 +41,40 @@ function(add_test_by_name name)
add_executable (${TEST_NAME} ${TEST_NAME}.cpp gschemas.compiled)
target_link_options(${TEST_NAME} PRIVATE -no-pie)
add_test (${TEST_NAME} ${TEST_NAME})
- target_link_libraries (${TEST_NAME} indicatordatetimeservice ${DBUSTEST_LIBRARIES} ${SERVICE_DEPS_LIBRARIES} ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES} ${URLDISPATCHER_LIBRARIES})
+ target_link_libraries (${TEST_NAME} indicatordatetimeservice ${DBUSTEST_LIBRARIES} ${SERVICE_DEPS_LIBRARIES} ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES})
endfunction()
add_test_by_name(test-datetime)
-if(LOMIRI_SCHEMAS_FOUND)
- if(LOMIRI_SOUNDS_FOUND)
- add_test_by_name(test-sound)
- add_test_by_name(test-notification)
- endif()
+
+if (ENABLE_LOMIRI_FEATURES)
+ add_test_by_name(test-sound)
+ # This one only succeeds on Lomiri because it needs hfd-service
+ # add_test_by_name(test-notification)
add_test_by_name(test-notification-response)
endif()
+
add_test_by_name(test-actions)
add_test_by_name(test-alarm-queue)
add_test(NAME dear-reader-the-next-test-takes-60-seconds COMMAND true)
add_test_by_name(test-clock)
-
-if (NOT DEFINED ENV{CI})
- #add_test_by_name(test-exporter)
-endif()
-
+# This one is fine, but hangs on Travis CI
+# add_test_by_name(test-exporter)
add_test_by_name(test-formatter)
add_test_by_name(test-live-actions)
add_test_by_name(test-locations)
add_test_by_name(test-menu-appointments)
-
-if (NOT DEFINED ENV{CI})
- #add_test_by_name(test-menus)
-endif()
-
+# This one is fine, but hangs on Travis CI
+# add_test_by_name(test-menus)
add_test_by_name(test-planner)
add_test_by_name(test-settings)
add_test_by_name(test-timezone-timedated)
add_test_by_name(test-utils)
-if(LOMIRI_SCHEMAS_FOUND)
+if (ENABLE_LOMIRI_FEATURES)
set (TEST_NAME manual-test-snap)
set (COVERAGE_TEST_TARGETS ${COVERAGE_TEST_TARGETS} ${TEST_NAME})
add_executable (${TEST_NAME} ${TEST_NAME}.cpp)
target_link_options(${TEST_NAME} PRIVATE -no-pie)
- target_link_libraries (${TEST_NAME} indicatordatetimeservice ${SERVICE_DEPS_LIBRARIES} ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES} ${URLDISPATCHER_LIBRARIES})
+ target_link_libraries (${TEST_NAME} indicatordatetimeservice ${SERVICE_DEPS_LIBRARIES} ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES})
endif()
##