[sysprof/wip/jtojnar/subprojects: 2/2] build: move libsysprof-capture to subproject



commit d33c110df56efd0c605142db3b58fae2612f2a04
Author: Jan Tojnar <jtojnar gmail com>
Date:   Fri Nov 22 09:27:21 2019 +0100

    build: move libsysprof-capture to subproject
    
    This will allow building it independently.

 meson.build                                        |   6 +
 src/libsysprof/meson.build                         |   6 +-
 src/meson.build                                    |   1 -
 src/tools/meson.build                              |   5 +-
 subprojects/libsysprof-capture/meson.build         | 128 +++++++++++++++++++++
 .../libsysprof-capture/src}/COPYING                |   0
 .../libsysprof-capture/src}/meson.build            |   9 ++
 .../src}/sysprof-address-fallback.h                |   0
 .../libsysprof-capture/src}/sysprof-address.c      |   2 +-
 .../libsysprof-capture/src}/sysprof-address.h      |   0
 .../src}/sysprof-capture-condition.c               |   2 +-
 .../src}/sysprof-capture-condition.h               |   0
 .../src}/sysprof-capture-cursor.c                  |   2 +-
 .../src}/sysprof-capture-cursor.h                  |   0
 .../src}/sysprof-capture-reader.c                  |   2 +-
 .../src}/sysprof-capture-reader.h                  |   0
 .../src}/sysprof-capture-types.h                   |   0
 .../src}/sysprof-capture-util-private.h            |   0
 .../libsysprof-capture/src}/sysprof-capture-util.c |   2 +-
 .../src}/sysprof-capture-writer-cat.c              |   2 +-
 .../src}/sysprof-capture-writer.c                  |   2 +-
 .../src}/sysprof-capture-writer.h                  |   0
 .../libsysprof-capture/src}/sysprof-capture.h      |   0
 .../libsysprof-capture/src}/sysprof-clock.c        |   2 +-
 .../libsysprof-capture/src}/sysprof-clock.h        |   0
 .../libsysprof-capture/src}/sysprof-platform.c     |   2 +-
 .../libsysprof-capture/src}/sysprof-platform.h     |   0
 .../src}/sysprof-version-macros.h                  |   0
 .../libsysprof-capture/src}/sysprof-version.h.in   |   0
 29 files changed, 158 insertions(+), 15 deletions(-)
---
diff --git a/meson.build b/meson.build
index 7a5b83a..d4cf036 100644
--- a/meson.build
+++ b/meson.build
@@ -52,6 +52,12 @@ glib_dep = dependency('glib-2.0', version: glib_req_version)
 gio_dep = dependency('gio-2.0', version: glib_req_version)
 gio_unix_dep = dependency('gio-unix-2.0', version: glib_req_version)
 
+libsysprof_capture_dep = dependency(
+  'sysprof-capture-3',
+  version: '== @0@'.format(meson.project_version()),
+  fallback : ['libsysprof-capture', 'libsysprof_capture_dep'],
+)
+
 if get_option('enable_gtk')
   gtk_dep = dependency('gtk+-3.0', version: gtk_req_version)
   dazzle_dep = dependency('libdazzle-1.0', version: dazzle_req_version)
diff --git a/src/libsysprof/meson.build b/src/libsysprof/meson.build
index 5883674..51d97e3 100644
--- a/src/libsysprof/meson.build
+++ b/src/libsysprof/meson.build
@@ -76,12 +76,11 @@ libsysprof_private_sources = [
   helpers_sources,
 ]
 
-libsysprof_public_sources += libsysprof_capture_sources
-
 libsysprof_deps = [
   gio_dep,
   gio_unix_dep,
   polkit_dep,
+  libsysprof_capture_dep,
 ]
 
 if host_machine.system() == 'linux'
@@ -115,7 +114,6 @@ libsysprof = shared_library(
 
     include_directories: [include_directories('.'),
                           ipc_include_dirs,
-                          libsysprof_capture_include_dirs,
                           conf_include_dirs,
                          ],
            dependencies: libsysprof_deps,
@@ -128,7 +126,7 @@ libsysprof = shared_library(
 libsysprof_dep = declare_dependency(
             link_with: libsysprof,
          dependencies: libsysprof_deps,
-  include_directories: [include_directories('.'), libsysprof_capture_include_dirs],
+  include_directories: include_directories('.'),
 )
 
 pkgconfig.generate(
diff --git a/src/meson.build b/src/meson.build
index f464cbb..2198386 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -48,7 +48,6 @@ helpers_sources = files([
   'helpers.c',
 ])
 
-subdir('libsysprof-capture')
 subdir('sysprofd')
 subdir('libsysprof')
 subdir('libsysprof-ui')
diff --git a/src/tools/meson.build b/src/tools/meson.build
index 0108afd..b4ec647 100644
--- a/src/tools/meson.build
+++ b/src/tools/meson.build
@@ -14,7 +14,10 @@ endif
 
 sysprof_cat = executable('sysprof-cat', 'sysprof-cat.c',
   dependencies: tools_deps,
-  include_directories: [ conf_include_dirs ],
+  include_directories: [
+    conf_include_dirs,
+    include_directories('../../subprojects/libsysprof-capture/src')
+  ],
   install: false,
 )
 
diff --git a/subprojects/libsysprof-capture/meson.build b/subprojects/libsysprof-capture/meson.build
new file mode 100644
index 0000000..63b559d
--- /dev/null
+++ b/subprojects/libsysprof-capture/meson.build
@@ -0,0 +1,128 @@
+project('sysprof-capture', ['c', 'cpp'],
+          license: ['BSD-2-Clause-Patent'],
+          version: '3.35.1',
+    meson_version: '>=0.50.0',
+  default_options: [ 'c_std=gnu11',
+                     'warning_level=2',
+  ]
+)
+
+pkgconfig = import('pkgconfig')
+
+libsysprof_api_version = 3
+version_split = meson.project_version().split('.')
+
+glib_req_version = '>= 2.61.3'
+gtk_req_version = '>= 3.22'
+polkit_req_version = '>= 0.105'
+dazzle_req_version = '>= 3.30.0'
+
+cc = meson.get_compiler('c')
+cxx = meson.get_compiler('cpp')
+
+config_h = configuration_data()
+
+# Detect and set symbol visibility
+if get_option('default_library') != 'static'
+  if host_machine.system() == 'windows'
+    config_h.set('DLL_EXPORT', true)
+    if cc.get_id() == 'msvc'
+      config_h.set('_SYSPROF_EXTERN', '__declspec(dllexport) extern')
+    elif cc.has_argument('-fvisibility=hidden')
+      config_h.set('_SYSPROF_EXTERN', '__attribute__((visibility("default"))) __declspec(dllexport) extern')
+    endif
+  elif cc.has_argument('-fvisibility=hidden')
+    config_h.set('_SYSPROF_EXTERN', '__attribute__((visibility("default"))) extern')
+  endif
+endif
+
+glib_dep = dependency('glib-2.0', version: glib_req_version)
+
+global_c_args = []
+test_c_args = [
+  '-Wcast-align',
+  '-Wdeclaration-after-statement',
+  '-Wformat-nonliteral',
+  '-Wformat-security',
+  '-Wmissing-include-dirs',
+  '-Wnested-externs',
+  '-Wno-missing-field-initializers',
+  '-Wno-sign-compare',
+  '-Wno-unused-parameter',
+  '-Wno-cast-function-type',
+  '-Wpointer-arith',
+  '-Wredundant-decls',
+  '-Wswitch-default',
+  '-Wswitch-enum',
+  '-Wuninitialized',
+  ['-Werror=format-security', '-Werror=format=2' ],
+  '-Werror=empty-body',
+  '-Werror=implicit-function-declaration',
+  '-Werror=incompatible-pointer-types',
+  '-Werror=pointer-arith',
+  '-Werror=init-self',
+  '-Werror=int-conversion',
+  '-Werror=misleading-indentation',
+  '-Werror=missing-include-dirs',
+  '-Werror=overflow',
+  '-Werror=parenthesis',
+  '-Werror=return-type',
+  '-Werror=shadow',
+  '-Werror=strict-prototypes',
+  '-Werror=undef',
+]
+if get_option('buildtype') != 'plain'
+  test_c_args += '-fstack-protector-strong'
+endif
+
+foreach arg: test_c_args
+  if cc.has_multi_arguments(arg)
+    global_c_args += arg
+  endif
+endforeach
+
+add_project_arguments(global_c_args, language: 'c')
+
+release_flags = []
+global_link_args = []
+test_link_args = [
+  '-Wl,-z,relro',
+  '-Wl,-z,now',
+]
+if not get_option('buildtype').startswith('debug')
+  release_flags += [
+    '-DG_DISABLE_CAST_CHECKS',
+    '-DG_DISABLE_ASSERT',
+  ]
+  test_link_args += [
+    '-Wl,-Bsymbolic',
+    '-fno-plt',
+  ]
+endif
+
+foreach link_arg: test_link_args
+  if cc.has_link_argument(link_arg)
+    global_link_args += link_arg
+  endif
+endforeach
+add_project_link_arguments(global_link_args, language: 'c')
+
+if not cc.links('''
+#include <stdatomic.h>
+int main(void) {
+  atomic_thread_fence(memory_order_acquire);
+  atomic_thread_fence(memory_order_seq_cst);
+  return 0;
+}
+''')
+  error('Sysprof requires a C compiler with stdatomic support such as GCC 4.9 or newer')
+endif
+
+conf_include_dirs = include_directories('.')
+
+configure_file(
+         output: 'capture-config.h',
+  configuration: config_h
+)
+
+subdir('src')
diff --git a/src/libsysprof-capture/COPYING b/subprojects/libsysprof-capture/src/COPYING
similarity index 100%
rename from src/libsysprof-capture/COPYING
rename to subprojects/libsysprof-capture/src/COPYING
diff --git a/src/libsysprof-capture/meson.build b/subprojects/libsysprof-capture/src/meson.build
similarity index 83%
rename from src/libsysprof-capture/meson.build
rename to subprojects/libsysprof-capture/src/meson.build
index d772a6b..ad65c8e 100644
--- a/src/libsysprof-capture/meson.build
+++ b/subprojects/libsysprof-capture/src/meson.build
@@ -1,3 +1,12 @@
+sysprof_header_subdir = 'sysprof-@0@'.format(libsysprof_api_version)
+
+sysprof_version_conf = configuration_data()
+sysprof_version = meson.project_version().split('.')
+sysprof_version_conf.set('MAJOR_VERSION', sysprof_version[0])
+sysprof_version_conf.set('MINOR_VERSION', sysprof_version[1])
+sysprof_version_conf.set('MICRO_VERSION', sysprof_version[2])
+sysprof_version_conf.set('VERSION', meson.project_version())
+
 libsysprof_capture_headers = files([
   'sysprof-address.h',
   'sysprof-clock.h',
diff --git a/src/libsysprof-capture/sysprof-address-fallback.h 
b/subprojects/libsysprof-capture/src/sysprof-address-fallback.h
similarity index 100%
rename from src/libsysprof-capture/sysprof-address-fallback.h
rename to subprojects/libsysprof-capture/src/sysprof-address-fallback.h
diff --git a/src/libsysprof-capture/sysprof-address.c b/subprojects/libsysprof-capture/src/sysprof-address.c
similarity index 99%
rename from src/libsysprof-capture/sysprof-address.c
rename to subprojects/libsysprof-capture/src/sysprof-address.c
index e600962..14f92e5 100644
--- a/src/libsysprof-capture/sysprof-address.c
+++ b/subprojects/libsysprof-capture/src/sysprof-address.c
@@ -54,7 +54,7 @@
  * SPDX-License-Identifier: BSD-2-Clause-Patent
  */
 
-#include "config.h"
+#include "capture-config.h"
 
 #ifdef __linux__
 # include <linux/perf_event.h>
diff --git a/src/libsysprof-capture/sysprof-address.h b/subprojects/libsysprof-capture/src/sysprof-address.h
similarity index 100%
rename from src/libsysprof-capture/sysprof-address.h
rename to subprojects/libsysprof-capture/src/sysprof-address.h
diff --git a/src/libsysprof-capture/sysprof-capture-condition.c 
b/subprojects/libsysprof-capture/src/sysprof-capture-condition.c
similarity index 99%
rename from src/libsysprof-capture/sysprof-capture-condition.c
rename to subprojects/libsysprof-capture/src/sysprof-capture-condition.c
index 78fb036..cc429f5 100644
--- a/src/libsysprof-capture/sysprof-capture-condition.c
+++ b/subprojects/libsysprof-capture/src/sysprof-capture-condition.c
@@ -56,7 +56,7 @@
 
 #define G_LOG_DOMAIN "sysprof-capture-condition"
 
-#include "config.h"
+#include "capture-config.h"
 
 #include <string.h>
 
diff --git a/src/libsysprof-capture/sysprof-capture-condition.h 
b/subprojects/libsysprof-capture/src/sysprof-capture-condition.h
similarity index 100%
rename from src/libsysprof-capture/sysprof-capture-condition.h
rename to subprojects/libsysprof-capture/src/sysprof-capture-condition.h
diff --git a/src/libsysprof-capture/sysprof-capture-cursor.c 
b/subprojects/libsysprof-capture/src/sysprof-capture-cursor.c
similarity index 99%
rename from src/libsysprof-capture/sysprof-capture-cursor.c
rename to subprojects/libsysprof-capture/src/sysprof-capture-cursor.c
index d94569f..28bb789 100644
--- a/src/libsysprof-capture/sysprof-capture-cursor.c
+++ b/subprojects/libsysprof-capture/src/sysprof-capture-cursor.c
@@ -56,7 +56,7 @@
 
 #define G_LOG_DOMAIN "sysprof-capture-cursor"
 
-#include "config.h"
+#include "capture-config.h"
 
 #include "sysprof-capture-condition.h"
 #include "sysprof-capture-cursor.h"
diff --git a/src/libsysprof-capture/sysprof-capture-cursor.h 
b/subprojects/libsysprof-capture/src/sysprof-capture-cursor.h
similarity index 100%
rename from src/libsysprof-capture/sysprof-capture-cursor.h
rename to subprojects/libsysprof-capture/src/sysprof-capture-cursor.h
diff --git a/src/libsysprof-capture/sysprof-capture-reader.c 
b/subprojects/libsysprof-capture/src/sysprof-capture-reader.c
similarity index 99%
rename from src/libsysprof-capture/sysprof-capture-reader.c
rename to subprojects/libsysprof-capture/src/sysprof-capture-reader.c
index 5bf03a1..be7a50d 100644
--- a/src/libsysprof-capture/sysprof-capture-reader.c
+++ b/subprojects/libsysprof-capture/src/sysprof-capture-reader.c
@@ -56,7 +56,7 @@
 
 #define G_LOG_DOMAIN "sysprof-capture-reader"
 
-#include "config.h"
+#include "capture-config.h"
 
 #include <errno.h>
 #include <fcntl.h>
diff --git a/src/libsysprof-capture/sysprof-capture-reader.h 
b/subprojects/libsysprof-capture/src/sysprof-capture-reader.h
similarity index 100%
rename from src/libsysprof-capture/sysprof-capture-reader.h
rename to subprojects/libsysprof-capture/src/sysprof-capture-reader.h
diff --git a/src/libsysprof-capture/sysprof-capture-types.h 
b/subprojects/libsysprof-capture/src/sysprof-capture-types.h
similarity index 100%
rename from src/libsysprof-capture/sysprof-capture-types.h
rename to subprojects/libsysprof-capture/src/sysprof-capture-types.h
diff --git a/src/libsysprof-capture/sysprof-capture-util-private.h 
b/subprojects/libsysprof-capture/src/sysprof-capture-util-private.h
similarity index 100%
rename from src/libsysprof-capture/sysprof-capture-util-private.h
rename to subprojects/libsysprof-capture/src/sysprof-capture-util-private.h
diff --git a/src/libsysprof-capture/sysprof-capture-util.c 
b/subprojects/libsysprof-capture/src/sysprof-capture-util.c
similarity index 99%
rename from src/libsysprof-capture/sysprof-capture-util.c
rename to subprojects/libsysprof-capture/src/sysprof-capture-util.c
index cf81c49..d8e89f7 100644
--- a/src/libsysprof-capture/sysprof-capture-util.c
+++ b/subprojects/libsysprof-capture/src/sysprof-capture-util.c
@@ -56,7 +56,7 @@
 
 #define G_LOG_DOMAIN "sysprof-capture-util"
 
-#include "config.h"
+#include "capture-config.h"
 
 #include <errno.h>
 #include <glib.h>
diff --git a/src/libsysprof-capture/sysprof-capture-writer-cat.c 
b/subprojects/libsysprof-capture/src/sysprof-capture-writer-cat.c
similarity index 99%
rename from src/libsysprof-capture/sysprof-capture-writer-cat.c
rename to subprojects/libsysprof-capture/src/sysprof-capture-writer-cat.c
index 6dc2fce..1547e68 100644
--- a/src/libsysprof-capture/sysprof-capture-writer-cat.c
+++ b/subprojects/libsysprof-capture/src/sysprof-capture-writer-cat.c
@@ -56,7 +56,7 @@
 
 #define G_LOG_DOMAIN "sysprof-cat"
 
-#include "config.h"
+#include "capture-config.h"
 
 #include <glib/gstdio.h>
 #include <stdlib.h>
diff --git a/src/libsysprof-capture/sysprof-capture-writer.c 
b/subprojects/libsysprof-capture/src/sysprof-capture-writer.c
similarity index 99%
rename from src/libsysprof-capture/sysprof-capture-writer.c
rename to subprojects/libsysprof-capture/src/sysprof-capture-writer.c
index 6c9362e..52b6a85 100644
--- a/src/libsysprof-capture/sysprof-capture-writer.c
+++ b/subprojects/libsysprof-capture/src/sysprof-capture-writer.c
@@ -56,7 +56,7 @@
 
 #define G_LOG_DOMAIN "sysprof-capture-writer"
 
-#include "config.h"
+#include "capture-config.h"
 
 #ifndef _GNU_SOURCE
 # define _GNU_SOURCE
diff --git a/src/libsysprof-capture/sysprof-capture-writer.h 
b/subprojects/libsysprof-capture/src/sysprof-capture-writer.h
similarity index 100%
rename from src/libsysprof-capture/sysprof-capture-writer.h
rename to subprojects/libsysprof-capture/src/sysprof-capture-writer.h
diff --git a/src/libsysprof-capture/sysprof-capture.h b/subprojects/libsysprof-capture/src/sysprof-capture.h
similarity index 100%
rename from src/libsysprof-capture/sysprof-capture.h
rename to subprojects/libsysprof-capture/src/sysprof-capture.h
diff --git a/src/libsysprof-capture/sysprof-clock.c b/subprojects/libsysprof-capture/src/sysprof-clock.c
similarity index 99%
rename from src/libsysprof-capture/sysprof-clock.c
rename to subprojects/libsysprof-capture/src/sysprof-clock.c
index 066605c..92f0ff5 100644
--- a/src/libsysprof-capture/sysprof-clock.c
+++ b/subprojects/libsysprof-capture/src/sysprof-clock.c
@@ -56,7 +56,7 @@
 
 #define G_LOG_DOMAIN "sysprof-clock"
 
-#include "config.h"
+#include "capture-config.h"
 
 #include "sysprof-clock.h"
 
diff --git a/src/libsysprof-capture/sysprof-clock.h b/subprojects/libsysprof-capture/src/sysprof-clock.h
similarity index 100%
rename from src/libsysprof-capture/sysprof-clock.h
rename to subprojects/libsysprof-capture/src/sysprof-clock.h
diff --git a/src/libsysprof-capture/sysprof-platform.c b/subprojects/libsysprof-capture/src/sysprof-platform.c
similarity index 99%
rename from src/libsysprof-capture/sysprof-platform.c
rename to subprojects/libsysprof-capture/src/sysprof-platform.c
index a81d2ae..28bd307 100644
--- a/src/libsysprof-capture/sysprof-platform.c
+++ b/subprojects/libsysprof-capture/src/sysprof-platform.c
@@ -56,7 +56,7 @@
 
 #define G_LOG_DOMAIN "sysprof-platform"
 
-#include "config.h"
+#include "capture-config.h"
 
 #include <glib.h>
 #include <glib/gstdio.h>
diff --git a/src/libsysprof-capture/sysprof-platform.h b/subprojects/libsysprof-capture/src/sysprof-platform.h
similarity index 100%
rename from src/libsysprof-capture/sysprof-platform.h
rename to subprojects/libsysprof-capture/src/sysprof-platform.h
diff --git a/src/libsysprof-capture/sysprof-version-macros.h 
b/subprojects/libsysprof-capture/src/sysprof-version-macros.h
similarity index 100%
rename from src/libsysprof-capture/sysprof-version-macros.h
rename to subprojects/libsysprof-capture/src/sysprof-version-macros.h
diff --git a/src/libsysprof-capture/sysprof-version.h.in 
b/subprojects/libsysprof-capture/src/sysprof-version.h.in
similarity index 100%
rename from src/libsysprof-capture/sysprof-version.h.in
rename to subprojects/libsysprof-capture/src/sysprof-version.h.in


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