aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-12-14 21:50:12 +0100
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-12-14 21:50:12 +0100
commit2d445b6517890a826e10ec2f29c32728c395fd2a (patch)
tree93af2806e379cb0805813b56f40f18c9003519e5
parentf61623a582aaa31ad02d72c5aebab6af3408fc38 (diff)
parent7c4c023ace4cd1b94c4fb0b6d8a8c060f10df752 (diff)
downloadlibayatana-common-2d445b6517890a826e10ec2f29c32728c395fd2a.tar.gz
libayatana-common-2d445b6517890a826e10ec2f29c32728c395fd2a.tar.bz2
libayatana-common-2d445b6517890a826e10ec2f29c32728c395fd2a.zip
Merge branch 'tari01-pr/add-enable-lomiri-features-switch'
Attributes GH PR #52: https://github.com/AyatanaIndicators/libayatana-common/pull/52
-rw-r--r--.build.yml6
-rw-r--r--CMakeLists.txt38
-rw-r--r--src/CMakeLists.txt7
-rw-r--r--src/utils.c25
-rw-r--r--tests/CMakeLists.txt15
5 files changed, 45 insertions, 46 deletions
diff --git a/.build.yml b/.build.yml
index 33f2150..fa6294f 100644
--- a/.build.yml
+++ b/.build.yml
@@ -89,11 +89,13 @@ variables:
build_scripts:
- if [ ${DISTRO_NAME} == "debian" ];then
- export CFLAGS+=" -Wsign-compare -Wunused-parameter"
- - cppcheck --enable=warning,style,performance,portability,information,missingInclude .
+ - cppcheck --enable=warning,style,performance,portability,information --suppress=missingInclude .
- fi
-
- if [ -e ./CMakeLists.txt ]; then
- - if [ ${DISTRO_NAME} == "debian" ] || [ ${DISTRO_NAME} == "ubuntu" ]; then
+ - if [ ${DISTRO_NAME} == "debian" ]; then
+ - scan-build $CHECKERS cmake . -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_VERBOSE_MAKEFILE=ON -DENABLE_TESTS=ON -DENABLE_WERROR=ON -DENABLE_LOMIRI_FEATURES=ON
+ - elif [ ${DISTRO_NAME} == "ubuntu" ]; then
- scan-build $CHECKERS cmake . -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_VERBOSE_MAKEFILE=ON -DENABLE_TESTS=ON -DENABLE_WERROR=ON
- else
- scan-build $CHECKERS cmake . -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_VERBOSE_MAKEFILE=ON -DENABLE_WERROR=ON
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ddf2049..dbb9b50 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -17,6 +17,7 @@ set(ABI_VERSION 0)
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)
@@ -39,17 +40,22 @@ set (CMAKE_INSTALL_FULL_PKGLIBEXECDIR "${CMAKE_INSTALL_FULL_LIBEXECDIR}/${CMAKE_
find_package (PkgConfig REQUIRED)
include (FindPkgConfig)
-pkg_check_modules(GLIB REQUIRED
+set (
+ DEPS
glib-2.0>=2.36
gio-2.0>=2.36
)
-include_directories (${GLIB_INCLUDE_DIRS})
-pkg_check_modules(
- URLDISPATCHER
- lomiri-url-dispatcher>=0
-)
-include_directories(${URLDISPATCHER_INCLUDE_DIRS})
+if (ENABLE_LOMIRI_FEATURES)
+ list (
+ APPEND
+ DEPS
+ lomiri-url-dispatcher>=0
+ )
+endif ()
+
+pkg_check_modules (DEPS REQUIRED ${DEPS})
+include_directories (${DEPS_INCLUDE_DIRS})
# for GIR and Vala bindings
find_package (GObjectIntrospection QUIET)
@@ -82,12 +88,14 @@ message(STATUS "Unit tests: ${ENABLE_TESTS}")
message(STATUS "Build with -Werror: ${ENABLE_WERROR}")
if (INTROSPECTION_FOUND)
- message(STATUS "Build GObjectIntrospection: YES")
- if (VALA_COMPILER)
- message(STATUS "Build Vala bindings: YES")
- else()
- message(STATUS "Build Vala bindings: NO")
- endif()
+ message(STATUS "Build GObjectIntrospection: YES")
+ if (VALA_COMPILER)
+ message(STATUS "Build Vala bindings: YES")
+ else()
+ message(STATUS "Build Vala bindings: NO")
+ endif()
else()
- message(STATUS "Build GObjectIntrospection: NO")
-endif() \ No newline at end of file
+ message(STATUS "Build GObjectIntrospection: NO")
+endif()
+
+message(STATUS "Build with Lomiri features: ${ENABLE_LOMIRI_FEATURES}")
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3e4d529..7ca0f5f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -4,12 +4,11 @@ add_library(ayatana-common SHARED
)
target_link_libraries(ayatana-common
- ${GLIB_LIBRARIES}
- ${URLDISPATCHER_LIBRARIES}
+ ${DEPS_LIBRARIES}
)
-if(URLDISPATCHER_FOUND)
- add_definitions( -DHAS_URLDISPATCHER )
+if(ENABLE_LOMIRI_FEATURES)
+ add_definitions( -DLOMIRI_FEATURES_ENABLED )
endif()
set(PUBLIC_HEADERS
diff --git a/src/utils.c b/src/utils.c
index d46c604..95aa1ce 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -19,7 +19,7 @@
#include <string.h>
-#ifdef HAS_URLDISPATCHER
+#ifdef LOMIRI_FEATURES_ENABLED
# include <lomiri-url-dispatcher.h>
#endif
@@ -28,13 +28,11 @@ gboolean
is_xdg_current_desktop (const gchar* desktop, const gchar* session)
{
const gchar *xdg_current_desktop;
- gchar **desktop_names;
- int i;
xdg_current_desktop = g_getenv ("XDG_CURRENT_DESKTOP");
if (xdg_current_desktop != NULL) {
- desktop_names = g_strsplit (xdg_current_desktop, ":", 0);
- for (i = 0; desktop_names[i]; ++i) {
+ gchar **desktop_names = g_strsplit (xdg_current_desktop, ":", 0);
+ for (int i = 0; desktop_names[i]; ++i) {
if (!g_strcmp0 (desktop_names[i], desktop)) {
g_strfreev (desktop_names);
return TRUE;
@@ -159,17 +157,13 @@ char *
find_browser ()
{
static char * browser_path = NULL;
- char* tmp_browser_path;
- gchar **browser_names;
-
- int i;
if (browser_path == NULL)
{
- browser_names = g_strsplit ("x-www-browser,google-chrome,firefox,chromium", ",", 0);
+ gchar **browser_names = g_strsplit ("x-www-browser,google-chrome,firefox,chromium", ",", 0);
- for (i = 0; browser_names[i]; ++i) {
- tmp_browser_path = g_find_program_in_path (browser_names[i]);
+ for (int i = 0; browser_names[i]; ++i) {
+ char* tmp_browser_path = g_find_program_in_path (browser_names[i]);
if (tmp_browser_path) {
browser_path = g_strdup (tmp_browser_path);
@@ -203,11 +197,9 @@ ayatana_common_utils_execute_command (const gchar * cmd)
gboolean
ayatana_common_utils_open_url (const gchar * url)
{
- char * browser = NULL;
-
if (ayatana_common_utils_is_lomiri())
{
-#ifdef HAS_URLDISPATCHER
+#ifdef LOMIRI_FEATURES_ENABLED
lomiri_url_dispatch_send(url, NULL, NULL);
return TRUE;
#else
@@ -215,8 +207,7 @@ ayatana_common_utils_open_url (const gchar * url)
#endif
}
- if (browser == NULL)
- browser = find_browser();
+ char * browser = find_browser();
if (browser != NULL)
return ayatana_common_utils_execute_command(g_strdup_printf("%s '%s'", browser, url));
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 002e4db..7758e59 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -25,8 +25,7 @@ target_include_directories(tst_utils PUBLIC "${CMAKE_SOURCE_DIR}/src")
target_link_libraries(tst_utils
ayatana-common
- ${GLIB_LIBRARIES}
- ${URL_DISPATCHER_LIBRARIES}
+ ${DEPS_LIBRARIES}
${GTEST_LIBRARIES}
${GTEST_BOTH_LIBRARIES}
${GMOCK_LIBRARIES}
@@ -58,11 +57,11 @@ add_custom_command(
if (VALA_COMPILER)
- add_executable("tst_utils_vala" "${CMAKE_CURRENT_BINARY_DIR}/tst_utils.c")
- target_include_directories("tst_utils_vala" PUBLIC "${GLIB_INCLUDE_DIRS};${CMAKE_BINARY_DIR}/src")
- target_link_libraries("tst_utils_vala" "${GLIB_LIBRARIES} -layatana-common -L${CMAKE_BINARY_DIR}/src")
- target_link_directories("tst_utils_vala" PUBLIC "${CMAKE_BINARY_DIR}/src")
- add_dependencies("tst_utils_vala" "src")
+ add_executable("tst_utils_vala" "${CMAKE_CURRENT_BINARY_DIR}/tst_utils.c")
+ target_include_directories("tst_utils_vala" PUBLIC "${DEPS_INCLUDE_DIRS};${CMAKE_BINARY_DIR}/src")
+ target_link_libraries("tst_utils_vala" "${DEPS_LIBRARIES} -layatana-common -L${CMAKE_BINARY_DIR}/src")
+ target_link_directories("tst_utils_vala" PUBLIC "${CMAKE_BINARY_DIR}/src")
+ add_dependencies("tst_utils_vala" "src")
- add_test(NAME "TstUtilsVala" COMMAND "${CMAKE_CURRENT_BINARY_DIR}/tst_utils_vala" "${CMAKE_CURRENT_BINARY_DIR}")
+ add_test(NAME "TstUtilsVala" COMMAND "${CMAKE_CURRENT_BINARY_DIR}/tst_utils_vala" "${CMAKE_CURRENT_BINARY_DIR}")
endif()