[gnome-builder/wip/tingping/meson-build] fixup! build: Initial conversion to Meson



commit 9c7cb2fffa1005255b6428cf62f9ae5649877ae6
Author: Patrick Griffis <tingping tingping se>
Date:   Tue Oct 11 15:55:26 2016 -0400

    fixup! build: Initial conversion to Meson

 config.h.meson                   |   59 ----------
 contrib/egg/meson.build          |    1 +
 contrib/gstyle/meson.build       |    3 +
 contrib/gstyle/tests/Makefile.am |    2 +-
 contrib/gstyle/tests/meson.build |  100 +++++++++++++++++
 contrib/search/meson.build       |    1 +
 contrib/tmpl/meson.build         |    4 +
 meson.build                      |   69 ++++++++++-
 tests/meson.build                |  227 ++++++++++++++++++++++++++++++++++++++
 tests/test-fuzzy.c               |    2 +-
 tests/test-ide-buffer-manager.c  |    2 +-
 tests/test-ide-context.c         |    3 +-
 12 files changed, 403 insertions(+), 70 deletions(-)
---
diff --git a/config.h.meson b/config.h.meson
index 4e2ef40..e28d97d 100644
--- a/config.h.meson
+++ b/config.h.meson
@@ -1,5 +1,3 @@
-/* config.h.in.  Generated from configure.ac by autoheader.  */
-
 /* Define to 1 if translation of program messages to the user's native
    language is requested. */
 #mesondefine ENABLE_NLS
@@ -7,66 +5,12 @@
 /* GETTEXT package name */
 #mesondefine GETTEXT_PACKAGE
 
-/* Name of GNU make on this system */
-#mesondefine GNU_MAKE_NAME
-
-/* Define to 1 if you have the Mac OS X function CFLocaleCopyCurrent in the
-   CoreFoundation framework. */
-#mesondefine HAVE_CFLOCALECOPYCURRENT
-
-/* Define to 1 if you have the Mac OS X function CFPreferencesCopyAppValue in
-   the CoreFoundation framework. */
-#mesondefine HAVE_CFPREFERENCESCOPYAPPVALUE
-
-/* define if the compiler supports basic C++11 syntax */
-#mesondefine HAVE_CXX11
-
-/* Define if the GNU dcgettext() function is already present or preinstalled.
-   */
-#mesondefine HAVE_DCGETTEXT
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#mesondefine HAVE_DLFCN_H
-
 /* Define if the GNU gettext() function is already present or preinstalled. */
 #mesondefine HAVE_GETTEXT
 
-/* Define if you have the iconv() function and it works. */
-#mesondefine HAVE_ICONV
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#mesondefine HAVE_INTTYPES_H
-
-/* Define to 1 if you have the <memory.h> header file. */
-#mesondefine HAVE_MEMORY_H
-
 /* Define to 1 if you have the `sched_getcpu' function. */
 #mesondefine HAVE_SCHED_GETCPU
 
-/* Define to 1 if you have the `shm_open' function. */
-#mesondefine HAVE_SHM_OPEN
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#mesondefine HAVE_STDINT_H
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#mesondefine HAVE_STDLIB_H
-
-/* Define to 1 if you have the <strings.h> header file. */
-#mesondefine HAVE_STRINGS_H
-
-/* Define to 1 if you have the <string.h> header file. */
-#mesondefine HAVE_STRING_H
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#mesondefine HAVE_SYS_STAT_H
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#mesondefine HAVE_SYS_TYPES_H
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#mesondefine HAVE_UNISTD_H
-
 /* Name of package */
 #mesondefine PACKAGE
 
@@ -96,9 +40,6 @@
 
 #mesondefine PACKAGE_LOCALE_DIR
 
-/* Define to 1 if you have the ANSI C header files. */
-#mesondefine STDC_HEADERS
-
 /* Version number of package */
 #mesondefine VERSION
 
diff --git a/contrib/egg/meson.build b/contrib/egg/meson.build
index 5d4e26b..adcb33b 100644
--- a/contrib/egg/meson.build
+++ b/contrib/egg/meson.build
@@ -88,6 +88,7 @@ libegg = shared_library('egg-private', libegg_sources,
 
 libegg_dep = declare_dependency(
   link_with: libegg,
+  dependencies: libegg_deps,
   include_directories: include_directories([
     meson.current_source_dir(),
     meson.current_build_dir(),
diff --git a/contrib/gstyle/meson.build b/contrib/gstyle/meson.build
index a7836d9..cce277a 100644
--- a/contrib/gstyle/meson.build
+++ b/contrib/gstyle/meson.build
@@ -83,6 +83,7 @@ libgstyle = shared_library('gstyle-private', libgstyle_sources,
 
 libgstyle_dep = declare_dependency(
   link_with: libgstyle,
+  dependencies: libgstyle_deps,
   include_directories: include_directories([
     meson.current_source_dir()
   ])
@@ -106,3 +107,5 @@ gnome.generate_gir(libgstyle,
 )
 
 endif
+
+subdir('tests')
diff --git a/contrib/gstyle/tests/Makefile.am b/contrib/gstyle/tests/Makefile.am
index c553ae5..f507cb0 100644
--- a/contrib/gstyle/tests/Makefile.am
+++ b/contrib/gstyle/tests/Makefile.am
@@ -4,7 +4,7 @@ gstyle_cflags =                              \
        $(DEBUG_CFLAGS)                      \
        $(GSTYLE_CFLAGS)                     \
        -I$(top_srcdir)/contrib/gstyle       \
-       -DTEST_DATA_DIR="\"$(abs_builddir)/data\"" \
+       -DTEST_DATA_DIR="\"$(abs_srcdir)/data\"" \
        $(NULL)
 
 gstyle_libs =                                               \
diff --git a/contrib/gstyle/tests/meson.build b/contrib/gstyle/tests/meson.build
new file mode 100644
index 0000000..f763f6c
--- /dev/null
+++ b/contrib/gstyle/tests/meson.build
@@ -0,0 +1,100 @@
+gstyle_test_env = [
+  'GB_IN_TREE_PLUGINS=1',
+  'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
+  'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
+  'G_DEBUG=gc-friendly',
+  'GSETTINGS_BACKEND=memory',
+  'MALLOC_CHECK_=2',
+  'MALLOC_PERTURB_=$((${RANDOM:-256} % 256))',
+]
+gstyle_test_cflags = [
+  '-DTEST_DATA_DIR="@0@/data"'.format(meson.current_source_dir()),
+]
+
+gstyle_color = executable('test-gstyle-color',
+  'test-gstyle-color.c',
+  dependencies: libgstyle_dep,
+)
+test('test-gstyle-color', gstyle_color,
+  env: gstyle_test_env
+)
+
+
+gstyle_color_panel = executable('test-gstyle-color-panel',
+  'test-gstyle-color-panel.c',
+  c_args: gstyle_test_cflags,
+  dependencies: libgstyle_dep,
+)
+test('test-gstyle-color-panel', gstyle_color_panel,
+  env: gstyle_test_env
+)
+
+
+gstyle_color_plane = executable('test-gstyle-color-plane',
+  'test-gstyle-color-plane.c',
+  c_args: gstyle_test_cflags,
+  dependencies: libgstyle_dep,
+)
+#test('test-gstyle-color-plane', gstyle_color_plane,
+#  env: gstyle_test_env
+#)
+
+
+gstyle_color_scale = executable('test-gstyle-color-scale',
+  'test-gstyle-color-scale.c',
+  c_args: gstyle_test_cflags,
+  dependencies: libgstyle_dep,
+)
+#test('test-gstyle-color-scale', gstyle_color_scale,
+#  env: gstyle_test_env
+#)
+
+
+gstyle_color_widget = executable('test-gstyle-color-widget',
+  'test-gstyle-color-widget.c',
+  c_args: gstyle_test_cflags,
+  dependencies: libgstyle_dep,
+)
+#test('test-gstyle-color-widget', gstyle_color_widget,
+#  env: gstyle_test_env
+#)
+
+
+gstyle_filter = executable('test-gstyle-filter',
+  'test-gstyle-filter.c',
+  c_args: gstyle_test_cflags,
+  dependencies: libgstyle_dep,
+)
+#test('test-gstyle-filter', gstyle_filter,
+#  env: gstyle_test_env
+#)
+
+
+gstyle_palette = executable('test-gstyle-palette',
+  'test-gstyle-palette.c',
+  c_args: gstyle_test_cflags,
+  dependencies: libgstyle_dep,
+)
+test('test-gstyle-palette', gstyle_palette,
+  env: gstyle_test_env
+)
+
+
+gstyle_palette_widget = executable('test-gstyle-palette-widget',
+  'test-gstyle-palette-widget.c',
+  c_args: gstyle_test_cflags,
+  dependencies: libgstyle_dep,
+)
+test('test-gstyle-color-palette-widget', gstyle_palette_widget,
+  env: gstyle_test_env
+)
+
+
+gstyle_parse = executable('test-gstyle-color-parse',
+  'test-gstyle-parse.c',
+  c_args: gstyle_test_cflags,
+  dependencies: libgstyle_dep,
+)
+test('test-gstyle-parse', gstyle_parse,
+  env: gstyle_test_env
+)
diff --git a/contrib/search/meson.build b/contrib/search/meson.build
index cbe0678..fe9983e 100644
--- a/contrib/search/meson.build
+++ b/contrib/search/meson.build
@@ -14,6 +14,7 @@ libsearch = static_library('search', libsearch_sources,
 
 libsearch_dep = declare_dependency(
   link_with: libsearch,
+  dependencies: libsearch_deps,
   include_directories: include_directories([
     meson.current_source_dir(),
   ]),
diff --git a/contrib/tmpl/meson.build b/contrib/tmpl/meson.build
index a807951..e2b8a71 100644
--- a/contrib/tmpl/meson.build
+++ b/contrib/tmpl/meson.build
@@ -83,9 +83,13 @@ libtmpl_sources = libtmpl_generated_headers + libtmpl_headers + [
   'tmpl-util.c',
 ]
 
+cc = meson.get_compiler('c')
+libm_dep = cc.find_library('m', required: false)
+
 libtmpl_deps = [
   dependency('gio-2.0'),
   dependency('gobject-introspection-1.0'),
+  libm_dep,
 ]
 
 flex = find_program('flex')
diff --git a/meson.build b/meson.build
index 8816bec..bc06013 100644
--- a/meson.build
+++ b/meson.build
@@ -6,9 +6,10 @@ project('gnome-builder', 'c',
   default_options: ['b_lundef=false'],
 )
 
-MAJOR_VERSION = '3'
-MINOR_VERSION = '20'
-MICRO_VERSION = '0'
+version_split = meson.project_version().split('.')
+MAJOR_VERSION = version_split[0]
+MINOR_VERSION = version_split[1]
+MICRO_VERSION = version_split[2]
 
 conf = configuration_data()
 conf.set_quoted('PACKAGE_NAME', 'gnome-builder')
@@ -22,6 +23,8 @@ conf.set_quoted('PACKAGE_LIBEXECDIR', get_option('libexecdir'))
 conf.set('GETTEXT_PACKAGE', 'PACKAGE_NAME')
 conf.set('LOCALEDIR', 'PACKAGE_LOCALE_DIR')
 
+conf.set10('ENABLE_NLS', true) # Always enabled
+
 # We should probably avoid using these
 conf.set_quoted('SRCDIR', meson.source_root())
 conf.set_quoted('BUILDDIR', meson.build_root())
@@ -30,12 +33,61 @@ add_global_arguments([
   '-DHAVE_CONFIG_H',
   '-I' + meson.build_root(), # config.h
   '-D_GNU_SOURCE',
-  '-fPIC', '-fPIE', # Doesn't work?
 ], language: 'c')
 
-add_global_link_arguments([
-  '-fpie', '-Wl,-z,relro', '-Wl,-z,now',
-], language: 'c')
+cc = meson.get_compiler('c')
+global_c_args = []
+test_c_args = [
+  '-Wall',
+  '-Wcast-align',
+  '-Wdeclaration-after-statement',
+  '-Werror=format-security',
+  '-Werror=format=2',
+  '-Wextra',
+  '-Wformat-nonliteral',
+  '-Wformat-security',
+  '-Wmissing-include-dirs',
+  '-Wnested-externs',
+  '-Wno-missing-field-initializers',
+  '-Wno-sign-compare',
+  '-Wno-strict-aliasing',
+  '-Wno-uninitialized',
+  '-Wno-unused-parameter',
+  '-Wpointer-arith',
+  '-Wredundant-decls',
+  '-Wshadow',
+  '-Wswitch-default',
+  '-Wswitch-enum',
+  '-fstack-protector-strong',
+]
+foreach arg: test_c_args
+  if cc.has_argument(arg)
+    global_c_args += arg
+  endif
+endforeach
+add_global_arguments(
+  global_c_args,
+  language: 'c'
+)
+
+global_link_args = []
+test_link_args = [
+  '-Wl,-z,relro',
+  '-Wl,-z,now',
+]
+foreach arg: test_link_args
+  if cc.has_argument(arg)
+    global_link_args += arg
+  endif
+endforeach
+add_global_link_arguments(
+  global_link_args,
+  language: 'c'
+)
+
+if cc.has_function('sched_getcpu')
+  conf.set('HAVE_SCHED_GETCPU', true)
+endif
 
 configure_file(
   input: 'config.h.meson',
@@ -67,9 +119,12 @@ subdir('libide')
 subdir('doc/reference/libide')
 subdir('plugins')
 subdir('po')
+subdir('tests')
 
 executable('gnome-builder', 'src/main.c',
   gui_app: true,
   install: true,
+  c_args: '-fPIE',
+  link_args: '-pie',
   dependencies: libide_deps + [libide_dep],
 )
diff --git a/tests/meson.build b/tests/meson.build
new file mode 100644
index 0000000..4bf036c
--- /dev/null
+++ b/tests/meson.build
@@ -0,0 +1,227 @@
+ide_test_env = [
+  
'GI_TYPELIB_PATH="@0@/libide:@0@/contrib/tmpl:@0@/contrib/egg:@0@/contrib/pnl:$(GI_TYPELIB_PATH)"'.format(meson.build_root()),
+  'GB_IN_TREE_PLUGINS=1',
+  'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
+  'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
+  'G_DEBUG=gc-friendly',
+  'GSETTINGS_BACKEND=memory',
+  'PYTHONDONTWRITEBYTECODE=yes',
+  'MALLOC_CHECK_=2',
+  'MALLOC_PERTURB_=$((${RANDOM:-256} % 256))',
+]
+ide_test_cflags = [
+       '-DTEST_DATA_DIR="@0@/data"'.format(meson.current_source_dir()),
+]
+
+ide_context = executable('test-ide-context',
+  'test-ide-context.c',
+  c_args: ide_test_cflags,
+  dependencies: libide_dep,
+)
+test('test-ide-context', ide_context,
+  env: ide_test_env,
+)
+
+
+ide_back_forward_list = executable('test-ide-back-forward-list',
+  'test-ide-back-forward-list.c',
+  c_args: ide_test_cflags,
+  dependencies: libide_dep,
+)
+test('test-ide-back-forward-list', ide_back_forward_list,
+  env: ide_test_env,
+)
+
+
+ide_buffer_manager = executable('test-ide-buffer-manager',
+  'test-ide-buffer-manager.c',
+  c_args: ide_test_cflags,
+  dependencies: libide_dep,
+)
+test('test-ide-buffer-manager', ide_buffer_manager,
+  env: ide_test_env,
+)
+
+
+ide_buffer = executable('test-ide-buffer',
+  'test-ide-buffer.c',
+  c_args: ide_test_cflags,
+  dependencies: libide_dep,
+)
+test('test-ide-buffer', ide_buffer,
+  env: ide_test_env,
+)
+
+
+ide_doap = executable('test-ide-doap',
+  'test-ide-doap.c',
+  c_args: ide_test_cflags,
+  dependencies: libide_dep,
+)
+test('test-ide-doap', ide_doap,
+  env: ide_test_env,
+)
+
+
+ide_file_settings = executable('test-ide-file-settings',
+  'test-ide-file-settings.c',
+  c_args: ide_test_cflags,
+  dependencies: libide_dep,
+)
+test('test-ide-file-settings', ide_file_settings,
+  env: ide_test_env,
+)
+
+
+ide_indenter = executable('test-ide-indenter',
+  'test-ide-indenter.c',
+  c_args: ide_test_cflags,
+  dependencies: [
+    libide_dep,
+    dependency('libpeas-1.0'),
+  ],
+)
+test('test-ide-indenter', ide_indenter,
+  env: ide_test_env,
+)
+
+
+ide_vcs_uri = executable('test-ide-vcs-uri',
+  'test-ide-vcs-uri.c',
+  c_args: ide_test_cflags,
+  dependencies: libide_dep,
+)
+test('test-ide-vcs-uri', ide_vcs_uri,
+  env: ide_test_env,
+)
+
+
+ide_uri = executable('test-ide-uri',
+  'test-ide-uri.c',
+  c_args: ide_test_cflags,
+  dependencies: libide_dep,
+)
+test('test-ide-uri', ide_uri,
+  env: ide_test_env,
+)
+
+
+test_vim = executable('test-vim',
+  'test-vim.c',
+  c_args: ide_test_cflags,
+  dependencies: libide_dep,
+)
+test('test-vim', test_vim,
+  env: ide_test_env,
+)
+
+
+test_cpu_graph = executable('test-cpu-graph',
+  'test-cpu-graph.c',
+  c_args: ide_test_cflags,
+  dependencies: [libide_dep, librg_dep],
+)
+#test('test-cpu-graph', test_cpu_graph,
+#  env: ide_test_env,
+#)
+
+
+test_fuzzy = executable('test-fuzzy',
+  'test-fuzzy.c',
+  c_args: ide_test_cflags,
+  dependencies: [libide_dep, libsearch_dep],
+)
+#test('test-fuzzy', test_fuzzy,
+#  env: ide_test_env,
+#)
+
+
+test_egg_slider = executable('test-egg-slider',
+  'test-egg-slider.c',
+  c_args: ide_test_cflags,
+  dependencies: libegg_dep,
+)
+#test('test-egg-slider', test_egg_slider,
+#  env: ide_test_env,
+#)
+
+
+test_snippet_parser = executable('test-snippet-parser',
+  'test-snippet-parser.c',
+  c_args: ide_test_cflags,
+  dependencies: libide_dep,
+)
+#test('test-snippet-parser', test_snippet_parser,
+#  env: ide_test_env,
+#)
+
+
+test_egg_binding_group = executable('test-egg-binding-group',
+  'test-egg-binding-group.c',
+  c_args: ide_test_cflags,
+  dependencies: libegg_dep,
+)
+test('test-egg-binding-group', test_egg_binding_group,
+  env: ide_test_env,
+)
+
+
+test_egg_menu_manager = executable('test-egg-menu-manager',
+  'test-egg-menu-manager.c',
+  c_args: ide_test_cflags,
+  dependencies: libegg_dep,
+)
+#test('test-egg-menu-manager', test_egg_menu_manager,
+#  env: ide_test_env,
+#)
+
+
+test_egg_state_machine = executable('test-egg-state-machine',
+  'test-egg-state-machine.c',
+  c_args: ide_test_cflags,
+  dependencies: libegg_dep,
+)
+test('test-egg-state-machine', test_egg_state_machine,
+  env: ide_test_env,
+)
+
+
+test_egg_radio_box = executable('test-egg-radio-box',
+  'test-egg-radio-box.c',
+  c_args: ide_test_cflags,
+  dependencies: libegg_dep,
+)
+#test('test-egg-radio-box', test_egg_radio_box,
+#  env: ide_test_env,
+#)
+
+
+test_egg_file_chooser_entry = executable('test-egg-file-chooser-entry',
+  'test-egg-file-chooser-entry.c',
+  c_args: ide_test_cflags,
+  dependencies: libegg_dep,
+)
+#test('test-egg-file-chooser-entry', test_egg_file_chooser_entry,
+#  env: ide_test_env,
+#)
+
+
+test_egg_cache = executable('test-egg-cache',
+  'test-egg-cache.c',
+  c_args: ide_test_cflags,
+  dependencies: libegg_dep,
+)
+test('test-egg-cache', test_egg_cache,
+  env: ide_test_env,
+)
+
+
+test_egg_heap = executable('test-egg-heap',
+  'test-egg-heap.c',
+  c_args: ide_test_cflags,
+  dependencies: libegg_dep,
+)
+test('test-egg-heap', test_egg_heap,
+  env: ide_test_env,
+)
+
diff --git a/tests/test-fuzzy.c b/tests/test-fuzzy.c
index 1e21884..e656264 100644
--- a/tests/test-fuzzy.c
+++ b/tests/test-fuzzy.c
@@ -1,5 +1,5 @@
 #include <fuzzy.h>
-#include <ide-line-reader.h>
+#include <ide.h>
 #include <stdlib.h>
 #include <string.h>
 
diff --git a/tests/test-ide-buffer-manager.c b/tests/test-ide-buffer-manager.c
index 3a6d275..3ebc333 100644
--- a/tests/test-ide-buffer-manager.c
+++ b/tests/test-ide-buffer-manager.c
@@ -155,7 +155,7 @@ test_buffer_manager_basic (GCancellable        *cancellable,
 {
   g_autoptr(GFile) project_file = NULL;
   g_autofree gchar *path = NULL;
-  const gchar *builddir = g_getenv ("G_TEST_BUILDDIR");
+  const gchar *builddir = g_getenv ("G_TEST_SRCDIR");
   g_autoptr(GTask) task = NULL;
 
   task = g_task_new (NULL, cancellable, callback, user_data);
diff --git a/tests/test-ide-context.c b/tests/test-ide-context.c
index dc25d41..1e57790 100644
--- a/tests/test-ide-context.c
+++ b/tests/test-ide-context.c
@@ -58,8 +58,9 @@ test_new_async (GCancellable        *cancellable,
   const gchar *builddir;
   GTask *task;
 
-  builddir = g_getenv ("G_TEST_BUILDDIR");
+  builddir = g_getenv ("G_TEST_SRCDIR");
 
+  g_print("%s\n", builddir);
   task = g_task_new (NULL, cancellable, callback, user_data);
   path = g_build_filename (builddir, "data", "project1", "configure.ac", NULL);
   project_file = g_file_new_for_path (path);


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