[sysprof] build: split profiler and gtk widgets into separate libraries



commit 61fed5b8f20d05c62aac042c4ed7a435ddaca5e3
Author: Christian Hergert <christian hergert me>
Date:   Wed Apr 13 21:09:52 2016 -0700

    build: split profiler and gtk widgets into separate libraries
    
    This will make it easier to support installing just sysprof-cli and the
    sysprofd helper daemon on systems where GTK is not feasible or necessary.
    This does not, however, do that. It simply gets things broken up into
    pieces.

 configure.ac              |   16 +++--
 data/Makefile.am          |    4 +-
 data/sysprof-ui.pc.in     |   11 ++++
 data/sysprof.pc.in        |    4 +-
 lib/Makefile.am           |  142 +++++++++++++++++++++++++++++++--------------
 lib/sysprof-ui.h          |   41 +++++++++++++
 lib/sysprof.h             |    9 ---
 src/Makefile.am           |    8 ++-
 src/sp-window.c           |    1 +
 tests/Makefile.am         |   14 ++++-
 tests/test-model-filter.c |    2 +-
 11 files changed, 184 insertions(+), 68 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 124649d..1e290f4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -82,12 +82,15 @@ VAPIGEN_CHECK
 dnl ***********************************************************************
 dnl Check for required packages
 dnl ***********************************************************************
-PKG_CHECK_MODULES(SYSPROF, [gio-2.0 >= 2.44
-                            gtk+-3.0 >= 3.16
-                            polkit-gobject-1])
-PKG_CHECK_MODULES(SYSTEMD, [libsystemd >= 222],
-                           [have_systemd=yes],
-                           [have_systemd=no])
+PKG_CHECK_MODULES(SYSPROF,    [gio-2.0 >= 2.44
+                              gio-unix-2.0 >= 2.44
+                               polkit-gobject-1])
+PKG_CHECK_MODULES(SYSPROF_UI, [gio-2.0 >= 2.44
+                               gtk+-3.0 >= 3.16
+                               polkit-gobject-1])
+PKG_CHECK_MODULES(SYSTEMD,    [libsystemd >= 222],
+                              [have_systemd=yes],
+                              [have_systemd=no])
 
 
 # we require systemd for sysprofd
@@ -163,6 +166,7 @@ AC_CONFIG_FILES([
        data/Makefile
        data/icons/Makefile
        data/sysprof-$API_VERSION.pc:data/sysprof.pc.in
+       data/sysprof-ui-$API_VERSION.pc:data/sysprof-ui.pc.in
        data/org.gnome.Sysprof2.conf
        data/org.gnome.sysprof2.policy
 
diff --git a/data/Makefile.am b/data/Makefile.am
index d76e65c..5d0fa1d 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -7,7 +7,9 @@ desktopdir = $(datadir)/applications
 desktop_DATA = org.gnome.Sysprof2.desktop
 
 pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = sysprof-$(API_VERSION).pc
+pkgconfig_DATA = \
+       sysprof-$(API_VERSION).pc \
+       sysprof-ui-$(API_VERSION).pc
 
 gsettings_SCHEMAS = org.gnome.sysprof2.gschema.xml
 
diff --git a/data/sysprof-ui.pc.in b/data/sysprof-ui.pc.in
new file mode 100644
index 0000000..e8f9f17
--- /dev/null
+++ b/data/sysprof-ui.pc.in
@@ -0,0 +1,11 @@
+prefix= prefix@
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=${exec_prefix}/include
+
+Name: libsysprof-ui- API_VERSION@
+Description: The sysprof library containing reusable GTK widgets
+Version: @VERSION@
+Libs: -L${libdir} -lsysprof-ui- API_VERSION@
+Cflags: -I${includedir}/sysprof- API_VERSION@
+Requires: gio-2.0 gtk+-3.0 sysprof- API_VERSION@
diff --git a/data/sysprof.pc.in b/data/sysprof.pc.in
index bfdb998..ebccdad 100644
--- a/data/sysprof.pc.in
+++ b/data/sysprof.pc.in
@@ -4,8 +4,8 @@ libdir=${exec_prefix}/lib
 includedir=${exec_prefix}/include
 
 Name: libsysprof- API_VERSION@
-Description: The sysprof library for integrating profiling into IDEs
+Description: The sysprof profiler library
 Version: @VERSION@
 Libs: -L${libdir} -lsysprof- API_VERSION@
 Cflags: -I${includedir}/sysprof- API_VERSION@
-Requires: gio-2.0 gtk+-3.0
+Requires: gio-2.0
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 5636c1a..a2cad63 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -1,45 +1,66 @@
+noinst_LTLIBRARIES =
+lib_LTLIBRARIES =
 EXTRA_DIST =
 CLEANFILES =
 DISTCLEANFILES =
 BUILT_SOURCES =
 
-lib_LTLIBRARIES = libsysprof- API_VERSION@.la
+# Both the profiler library and the UI library need to share some
+# data-structures. Notably, the StackStash. So we build a private
+# static library that can be used from both. It adds a little bit
+# of overhead in terms of duplicated procedures, but they should
+# always be installed in sync, and therefore no big deal.
+noinst_LTLIBRARIES += libutil.la
+libutil_la_SOURCES = \
+       util/binfile.c \
+       util/binfile.h \
+       util/demangle.cpp \
+       util/demangle.h \
+       util/elfparser.c \
+       util/elfparser.h \
+       util/stackstash.c \
+       util/stackstash.h \
+       util/util.h \
+       $(NULL)
+libutil_la_CFLAGS = \
+       -I$(srcdir)/util \
+       $(SYSPROF_CFLAGS) \
+       $(WARN_CFLAGS) \
+       $(NULL)
+libutil_la_CXXFLAGS = \
+       -I$(srcdir)/util \
+       $(SYSPROF_CFLAGS) \
+       $(WARN_CXXFLAGS) \
+       $(NULL)
 
-nodist_libsysprof_ API_VERSION@_la_SOURCES = \
-       sp-resources.c \
-       sp-resources.h
 
+# We split up the library code into two libraries.  One containing the
+# minimum necessary to do profiling on a particular host (that might not
+# have GTK+ installed), and the library containing reusable GTK
+# components (for IDE integration).
+#
+lib_LTLIBRARIES += libsysprof- API_VERSION@.la
 headersdir = $(includedir)/sysprof- API_VERSION@
 headers_DATA = \
        sysprof.h \
        sysprof-version.h \
        sp-address.h \
        sp-callgraph-profile.h \
-       sp-callgraph-view.h \
        sp-capture-reader.h \
        sp-capture-writer.h \
        sp-capture-types.h \
-       sp-cell-renderer-percent.h \
        sp-clock.h \
        sp-elf-symbol-resolver.h \
-       sp-empty-state-view.h \
-       sp-failed-state-view.h \
        sp-error.h \
        sp-gjs-source.h \
        sp-jitmap-symbol-resolver.h \
        sp-kernel-symbol.h \
        sp-kernel-symbol-resolver.h \
        sp-map-lookaside.h \
-       sp-model-filter.h \
        sp-perf-source.h \
        sp-proc-source.h \
-       sp-process-model.h \
-       sp-process-model-item.h \
-       sp-process-model-row.h \
        sp-profile.h \
        sp-profiler.h \
-       sp-profiler-menu-button.h \
-       sp-recording-state-view.h \
        sp-source.h \
        sp-symbol-resolver.h \
        $(NULL)
@@ -49,14 +70,10 @@ libsysprof_ API_VERSION@_la_SOURCES = \
        sp-address.c \
        sp-callgraph-profile.c \
        sp-callgraph-profile-private.h \
-       sp-callgraph-view.c \
        sp-capture-reader.c \
        sp-capture-writer.c \
-       sp-cell-renderer-percent.c \
        sp-clock.c \
        sp-elf-symbol-resolver.c \
-       sp-empty-state-view.c \
-       sp-failed-state-view.c \
        sp-error.c \
        sp-gjs-source.c \
        sp-jitmap-symbol-resolver.c \
@@ -65,51 +82,29 @@ libsysprof_ API_VERSION@_la_SOURCES = \
        sp-line-reader.c \
        sp-line-reader.h \
        sp-map-lookaside.c \
-       sp-model-filter.c \
        sp-perf-counter.c \
        sp-perf-counter.h \
        sp-perf-source.c \
        sp-proc-source.c \
-       sp-process-model.c \
-       sp-process-model-item.c \
-       sp-process-model-row.c \
        sp-profile.c \
        sp-profiler.c \
-       sp-profiler-menu-button.c \
-       sp-recording-state-view.c \
-       sp-scrolled-window.c \
-       sp-scrolled-window.h \
        sp-source.c \
        sp-symbol-resolver.c \
-       util/binfile.c \
-       util/binfile.h \
-       util/demangle.cpp \
-       util/demangle.h \
-       util/elfparser.c \
-       util/elfparser.h \
-       util/stackstash.c \
-       util/stackstash.h \
-       util/util.h \
        $(NULL)
 
-
 libsysprof_ API_VERSION@_la_CFLAGS = \
        -I$(srcdir)/util \
        $(SYSPROF_CFLAGS) \
        $(WARN_CFLAGS) \
        $(NULL)
-
-libsysprof_ API_VERSION@_la_CXXFLAGS = \
-       -I$(srcdir)/util \
-       $(SYSPROF_CFLAGS) \
-       $(WARN_CXXFLAGS) \
-       $(NULL)
-
 if ENABLE_SYSPROFD
-libsysprof_ API_VERSION@_la_CFLAGS += -DENABLE_SYSPROFD
+libsysprof_ API_VERSION@_la_CFLAGS += \
+       -DENABLE_SYSPROFD
 endif
 
 libsysprof_ API_VERSION@_la_LIBADD = \
+       libutil.la \
+       -lstdc++ \
        $(SYSPROF_LIBS) \
        $(NULL)
 
@@ -121,6 +116,65 @@ libsysprof_ API_VERSION@_la_LDFLAGS = \
        $(NULL)
 
 
+# This is our GTK library containing the widgets suitable for viewing
+# and manipulating the various profiler API in libsysprof.  This is
+# meant to be used by IDEs and the sysprof gui.
+lib_LTLIBRARIES += libsysprof-ui- API_VERSION@.la
+
+uiheadersdir = $(includedir)/sysprof- API_VERSION@
+uiheaders_DATA = \
+       sp-callgraph-view.h \
+       sp-cell-renderer-percent.h \
+       sp-empty-state-view.h \
+       sp-failed-state-view.h \
+       sp-model-filter.h \
+       sp-process-model.h \
+       sp-process-model-item.h \
+       sp-process-model-row.h \
+       sp-profiler-menu-button.h \
+       sp-recording-state-view.h \
+       sp-scrolled-window.h \
+       sysprof-ui.h \
+       $(NULL)
+
+libsysprof_ui_ API_VERSION@_la_SOURCES = \
+       $(uiheaders_DATA) \
+       sp-callgraph-view.c \
+       sp-cell-renderer-percent.c \
+       sp-empty-state-view.c \
+       sp-failed-state-view.c \
+       sp-model-filter.c \
+       sp-process-model.c \
+       sp-process-model-item.c \
+       sp-process-model-row.c \
+       sp-profiler-menu-button.c \
+       sp-recording-state-view.c \
+       sp-scrolled-window.c \
+       $(NULL)
+
+libsysprof_ui_ API_VERSION@_la_CFLAGS = \
+       -I$(srcdir)/util \
+       $(SYSPROF_UI_CFLAGS) \
+       $(WARN_CFLAGS) \
+       $(NULL)
+
+libsysprof_ui_ API_VERSION@_la_LIBADD = \
+       libutil.la \
+       libsysprof- API_VERSION@.la \
+       $(SYSPROF_UI_LIBS) \
+       $(NULL)
+
+libsysprof_ui_ API_VERSION@_la_LDFLAGS = \
+       -avoid-version \
+       -no-undefined \
+       -export-symbols-regex '^(sp_).*' \
+       $(WARN_LDFLAGS) \
+       $(NULL)
+
+nodist_libsysprof_ui_ API_VERSION@_la_SOURCES = \
+       sp-resources.c \
+       sp-resources.h
+
 glib_resources_xml = resources/libsysprof.gresource.xml
 glib_resources_c = sp-resources.c
 glib_resources_h = sp-resources.h
diff --git a/lib/sysprof-ui.h b/lib/sysprof-ui.h
new file mode 100644
index 0000000..6212ece
--- /dev/null
+++ b/lib/sysprof-ui.h
@@ -0,0 +1,41 @@
+/* sysprof-ui.h
+ *
+ * Copyright (C) 2016 Christian Hergert <christian hergert me>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef SYSPROF_UI_H
+#define SYSPROF_UI_H
+
+#include <sysprof.h>
+
+G_BEGIN_DECLS
+
+#define SYSPROF_INSIDE
+# include "sp-callgraph-view.h"
+# include "sp-cell-renderer-percent.h"
+# include "sp-empty-state-view.h"
+# include "sp-model-filter.h"
+# include "sp-recording-state-view.h"
+# include "sp-process-model.h"
+# include "sp-process-model-item.h"
+# include "sp-process-model-row.h"
+# include "sp-profiler-menu-button.h"
+# include "sp-scrolled-window.h"
+#undef SYSPROF_INSIDE
+
+G_END_DECLS
+
+#endif /* SYSPROF_UI_H */
diff --git a/lib/sysprof.h b/lib/sysprof.h
index 776bb26..f864b70 100644
--- a/lib/sysprof.h
+++ b/lib/sysprof.h
@@ -26,29 +26,20 @@ G_BEGIN_DECLS
 #define SYSPROF_INSIDE
 # include "sp-address.h"
 # include "sp-callgraph-profile.h"
-# include "sp-callgraph-view.h"
 # include "sp-capture-reader.h"
 # include "sp-capture-writer.h"
-# include "sp-cell-renderer-percent.h"
 # include "sp-clock.h"
 # include "sp-elf-symbol-resolver.h"
-# include "sp-empty-state-view.h"
 # include "sp-error.h"
 # include "sp-gjs-source.h"
 # include "sp-jitmap-symbol-resolver.h"
 # include "sp-kernel-symbol.h"
 # include "sp-kernel-symbol-resolver.h"
 # include "sp-map-lookaside.h"
-# include "sp-model-filter.h"
-# include "sp-recording-state-view.h"
 # include "sp-perf-source.h"
 # include "sp-proc-source.h"
-# include "sp-process-model.h"
-# include "sp-process-model-item.h"
-# include "sp-process-model-row.h"
 # include "sp-profile.h"
 # include "sp-profiler.h"
-# include "sp-profiler-menu-button.h"
 # include "sp-source.h"
 # include "sp-symbol-resolver.h"
 # include "sysprof-version.h"
diff --git a/src/Makefile.am b/src/Makefile.am
index 9973c6f..d789526 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,7 +1,7 @@
 bin_PROGRAMS = sysprof
 
 sysprof_CFLAGS = \
-       $(SYSPROF_CFLAGS) \
+       $(SYSPROF_UI_CFLAGS) \
        -I$(top_srcdir)/lib \
        -I$(top_builddir)/lib
 
@@ -21,8 +21,10 @@ nodist_sysprof_SOURCES = \
        sp-resources.h
 
 sysprof_LDADD = \
-       $(SYSPROF_LIBS) \
-       $(top_builddir)/lib/libsysprof- API_VERSION@.la
+       $(SYSPROF_UI_LIBS) \
+       $(top_builddir)/lib/libsysprof- API_VERSION@.la \
+       $(top_builddir)/lib/libsysprof-ui- API_VERSION@.la \
+       $(NULL)
 
 EXTRA_DIST =
 CLEANFILES =
diff --git a/src/sp-window.c b/src/sp-window.c
index 822a676..06ffbf8 100644
--- a/src/sp-window.c
+++ b/src/sp-window.c
@@ -19,6 +19,7 @@
 #include <errno.h>
 #include <glib/gi18n.h>
 #include <sysprof.h>
+#include <sysprof-ui.h>
 
 #include "sp-application.h"
 #include "sp-window.h"
diff --git a/tests/Makefile.am b/tests/Makefile.am
index ec5b646..4b64ad5 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -9,11 +9,21 @@ test_libs = \
        $(SYSPROF_LIBS) \
        $(top_builddir)/lib/libsysprof- API_VERSION@.la
 
+test_ui_cflags = \
+       $(SYSPROF_UI_CFLAGS) \
+       -I$(top_srcdir)/lib \
+       -I$(top_builddir)/lib
+
+test_ui_libs = \
+       $(SYSPROF_UI_LIBS) \
+       $(top_builddir)/lib/libsysprof- API_VERSION@.la \
+       $(top_builddir)/lib/libsysprof-ui- API_VERSION@.la
+
 
 TESTS += test-model-filter
 test_model_filter_SOURCES = test-model-filter.c
-test_model_filter_CFLAGS = $(test_cflags)
-test_model_filter_LDADD = $(test_libs)
+test_model_filter_CFLAGS = $(test_ui_cflags)
+test_model_filter_LDADD = $(test_ui_libs)
 
 TESTS += test-capture
 test_capture_SOURCES = test-capture.c
diff --git a/tests/test-model-filter.c b/tests/test-model-filter.c
index 8923084..f7f1cf0 100644
--- a/tests/test-model-filter.c
+++ b/tests/test-model-filter.c
@@ -1,4 +1,4 @@
-#include <sysprof.h>
+#include <sysprof-ui.h>
 
 #include "sp-model-filter.h"
 


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