[gnome-bluetooth/wip/hadess/split-ui-libs: 1/2] lib: Split UI and non-UI libraries




commit ee7b7464b398af50d3b10876b52edabb7b11258d
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Jan 18 17:54:10 2022 +0100

    lib: Split UI and non-UI libraries
    
    Both UI and non-UI libraries export a pkg-config file. Only the non-UI
    library exports a Gir as it's the only one that gets to be used from a
    non-native program (gnome-shell).

 lib/gnome-bluetooth-ui.map |  9 +++++
 lib/gnome-bluetooth.map    | 28 ---------------
 lib/meson.build            | 85 +++++++++++++++++++++++++++++++++-------------
 lib/test-pin.c             |  2 +-
 meson.build                |  1 +
 sendto/meson.build         |  2 +-
 tests/meson.build          |  4 +--
 7 files changed, 76 insertions(+), 55 deletions(-)
---
diff --git a/lib/gnome-bluetooth-ui.map b/lib/gnome-bluetooth-ui.map
new file mode 100644
index 00000000..70adc806
--- /dev/null
+++ b/lib/gnome-bluetooth-ui.map
@@ -0,0 +1,9 @@
+{
+global:
+  bluetooth_settings_widget_get_type;
+  bluetooth_settings_widget_new;
+  bluetooth_settings_widget_get_default_adapter_powered;
+  bluetooth_settings_widget_set_default_adapter_powered;
+local:
+       *;
+};
diff --git a/lib/gnome-bluetooth.map b/lib/gnome-bluetooth.map
index 94e97603..cae8ef5f 100644
--- a/lib/gnome-bluetooth.map
+++ b/lib/gnome-bluetooth.map
@@ -1,15 +1,10 @@
 {
 global:
-  bluetooth_client_setup_device;
-  bluetooth_client_setup_device_finish;
-  bluetooth_client_cancel_setup_device;
-  bluetooth_client_cancel_setup_device_finish;
   bluetooth_client_get_type;
   bluetooth_client_new;
   bluetooth_client_get_devices;
   bluetooth_client_connect_service;
   bluetooth_client_connect_service_finish;
-  bluetooth_client_set_trusted;
   bluetooth_class_to_type;
   bluetooth_type_to_string;
   bluetooth_verify_address;
@@ -20,29 +15,6 @@ global:
   bluetooth_device_dump;
   bluetooth_device_get_object_path;
   bluetooth_device_to_string;
-  bluetooth_agent_get_type;
-  bluetooth_agent_error_get_type;
-  bluetooth_agent_new;
-  bluetooth_agent_set_pincode_func;
-  bluetooth_agent_register;
-  bluetooth_agent_unregister;
-  bluetooth_agent_set_confirm_func;
-  bluetooth_agent_set_passkey_func;
-  bluetooth_agent_set_cancel_func;
-  bluetooth_agent_error_quark;
-  bluetooth_agent_set_authorize_func;
-  bluetooth_agent_set_display_passkey_func;
-  bluetooth_agent_set_display_pincode_func;
-  bluetooth_agent_set_authorize_service_func;
-  bluetooth_settings_widget_get_type;
-  bluetooth_settings_widget_new;
-  bluetooth_settings_widget_get_default_adapter_powered;
-  bluetooth_settings_widget_set_default_adapter_powered;
-  bluetooth_pairing_dialog_new;
-  bluetooth_pairing_dialog_get_type;
-  bluetooth_pairing_dialog_set_mode;
-  bluetooth_pairing_dialog_get_mode;
-  bluetooth_pairing_dialog_set_pin_entered;
 local:
        *;
 };
diff --git a/lib/meson.build b/lib/meson.build
index 978cd596..13027e59 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -4,12 +4,14 @@ enum_headers = files('bluetooth-enums.h')
 
 headers = enum_headers + files(
   'bluetooth-client.h',
-  'bluetooth-settings-widget.h',
   'bluetooth-utils.h',
 )
+ui_headers = files(
+  'bluetooth-settings-widget.h',
+)
 
 install_headers(
-  headers,
+  ui_headers,
   subdir: gnomebt_api_name,
 )
 
@@ -17,16 +19,17 @@ sources = files(
   'bluetooth-agent.c',
   'bluetooth-client.c',
   'bluetooth-device.c',
+  'bluetooth-utils.c',
+  'pin.c',
+)
+
+ui_sources = sources + files(
   'bluetooth-pairing-dialog.c',
   'bluetooth-settings-obexpush.c',
   'bluetooth-settings-row.c',
   'bluetooth-settings-widget.c',
-  'bluetooth-utils.c',
-  'pin.c',
 )
 
-built_sources = []
-
 resource_data = files(
   'bluetooth-pairing-dialog.ui',
   'bluetooth-settings.css',
@@ -34,7 +37,7 @@ resource_data = files(
   'settings.ui',
 )
 
-built_sources += gnome.compile_resources(
+ui_built_sources = gnome.compile_resources(
   'bluetooth-settings-resources',
   'bluetooth.gresource.xml',
   c_name: 'bluetooth_settings',
@@ -44,13 +47,11 @@ built_sources += gnome.compile_resources(
 
 enum_sources = gnome.mkenums_simple(
   'gnome-bluetooth-enum-types',
-  sources : headers,
+  sources : enum_headers,
 )
-built_sources += enum_sources
 
 client = 'bluetooth-client'
-
-built_sources += gnome.gdbus_codegen(
+client_built_sources = gnome.gdbus_codegen(
   client + '-glue',
   client + '.xml',
   interface_prefix: 'org.bluez',
@@ -58,15 +59,26 @@ built_sources += gnome.gdbus_codegen(
 
 deps = [
   gio_dep,
+]
+
+private_deps = [
+  gio_unix_dep,
+  libudev_dep,
+  m_dep,
+]
+
+ui_deps = [
+  gio_dep,
   gtk_dep,
   libadwaita_dep,
 ]
 
-private_deps = [
+ui_private_deps = [
   gio_unix_dep,
   gsound_dep,
   libnotify_dep,
   libudev_dep,
+  m_dep,
 ]
 
 cflags = [
@@ -79,10 +91,10 @@ ldflags = cc.get_supported_link_arguments('-Wl,--version-script,' + symbol_map)
 
 libgnome_bluetooth = shared_library(
   gnomebt_api_name,
-  sources: sources + built_sources,
+  sources: sources + enum_sources + client_built_sources,
   version: libversion,
   include_directories: top_inc,
-  dependencies: deps + private_deps + [m_dep],
+  dependencies: deps + private_deps,
   c_args: cflags,
   link_args: ldflags,
   link_depends: symbol_map,
@@ -99,7 +111,7 @@ pkg.generate(
   libraries: libgnome_bluetooth,
   version: gnomebt_version,
   name: gnomebt_api_name,
-  description: 'Widgets for Bluetooth device selection',
+  description: 'Bluetooth libraries for gnome-shell',
   filebase: gnomebt_api_name,
   subdirs: gnomebt_api_name,
   requires: deps,
@@ -110,9 +122,7 @@ if enable_gir
   gir_sources = sources + headers
 
   gir_incs = [
-    'GModule-2.0',
-    'GObject-2.0',
-    'Gtk-4.0',
+    'Gio-2.0',
   ]
 
   gnome.generate_gir(
@@ -131,8 +141,6 @@ if enable_gir
     libgnome_bluetooth,
     sources: gir_sources + [
       'bluetooth-device.h',
-      'bluetooth-client-private.h',
-      'bluetooth-agent.h',
       ],
     nsversion: gnomebt_api_version,
     namespace: 'GnomeBluetoothPriv',
@@ -144,6 +152,38 @@ if enable_gir
   )
 endif
 
+ui_symbol_map = meson.current_source_dir() / (meson.project_name() + '-ui.map')
+ui_ldflags = cc.get_supported_link_arguments('-Wl,--version-script,' + ui_symbol_map)
+
+libgnome_bluetooth_ui = shared_library(
+  gnomebt_ui_api_name,
+  sources: ui_sources + enum_sources + client_built_sources + ui_built_sources,
+  version: libversion,
+  include_directories: top_inc,
+  dependencies: ui_deps + ui_private_deps,
+  c_args: cflags,
+  link_args: ui_ldflags,
+  link_depends: ui_symbol_map,
+  install: true,
+)
+
+libgnome_bluetooth_ui_dep = declare_dependency(
+  link_with: libgnome_bluetooth_ui,
+  include_directories: lib_inc,
+  dependencies: ui_deps,
+)
+
+pkg.generate(
+  libraries: libgnome_bluetooth_ui,
+  version: gnomebt_version,
+  name: gnomebt_ui_api_name,
+  description: 'Bluetooth libraries for gnome-control-center',
+  filebase: gnomebt_ui_api_name,
+  subdirs: gnomebt_api_name,
+  requires: deps,
+  variables: 'exec_prefix=${prefix}',
+)
+
 test_names = [
   'test-agent',
   'test-class',
@@ -156,11 +196,10 @@ test_names = [
 foreach name: test_names
   executable(
     name,
-    [name + '.c'] + built_sources,
+    [name + '.c'] + ui_sources + ui_built_sources + enum_sources + client_built_sources,
     include_directories: top_inc,
-    dependencies: deps + private_deps,
+    dependencies: ui_deps + ui_private_deps,
     c_args: cflags,
-    link_with: libgnome_bluetooth,
   )
 endforeach
 
diff --git a/lib/test-pin.c b/lib/test-pin.c
index 7403c069..405d1e4f 100644
--- a/lib/test-pin.c
+++ b/lib/test-pin.c
@@ -1,5 +1,5 @@
-#include "pin.c"
 #include "bluetooth-enums.h"
+#include "pin.h"
 
 int main (int argc, char **argv)
 {
diff --git a/meson.build b/meson.build
index 1b27f533..895c5070 100644
--- a/meson.build
+++ b/meson.build
@@ -12,6 +12,7 @@ gnomebt_major_version = version_array[0].to_int()
 
 gnomebt_api_version = '3.0'
 gnomebt_api_name = '@0@-@1@'.format(meson.project_name(), gnomebt_api_version)
+gnomebt_ui_api_name = '@0@-ui-@1@'.format(meson.project_name(), gnomebt_api_version)
 gnomebt_gettext_package = gnomebt_api_name
 
 gnomebt_gir_ns = 'GnomeBluetooth'
diff --git a/sendto/meson.build b/sendto/meson.build
index 3e233a03..7694b692 100644
--- a/sendto/meson.build
+++ b/sendto/meson.build
@@ -4,7 +4,7 @@ executable(
   name,
   'main.c',
   include_directories: top_inc,
-  dependencies: libgnome_bluetooth_dep,
+  dependencies: [libgnome_bluetooth_dep, gtk_dep],
   install: true,
 )
 
diff --git a/tests/meson.build b/tests/meson.build
index 1d1b2e0e..7582027a 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -18,7 +18,7 @@ endif
 test_bluetooth_device = executable('test-bluetooth-device',
   'test-bluetooth-device.c',
   include_directories: lib_inc,
-  dependencies: deps + private_deps,
+  dependencies: deps,
   c_args: cflags,
   link_with: libgnome_bluetooth,
 )
@@ -30,7 +30,7 @@ test('test-bluetooth-device-test',
 test_bluetooth_utils = executable('test-bluetooth-utils',
   [ 'test-bluetooth-utils.c', enum_sources ],
   include_directories: [ top_inc, lib_inc],
-  dependencies: deps + private_deps,
+  dependencies: deps,
   c_args: cflags,
   link_with: libgnome_bluetooth,
 )


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]