[libgxps/wip/nacho/meson] Add meson build system



commit f3967f68bfffe877c491bab4e3d1cb375ac208ab
Author: Ignacio Casal Quinteiro <qignacio amazon com>
Date:   Tue May 2 21:55:50 2017 +0200

    Add meson build system

 libgxps/meson.build |  109 ++++++++++++++++++++++++++++++
 meson.build         |  185 +++++++++++++++++++++++++++++++++++++++++++++++++++
 meson_options.txt   |    3 +
 3 files changed, 297 insertions(+), 0 deletions(-)
---
diff --git a/libgxps/meson.build b/libgxps/meson.build
new file mode 100644
index 0000000..d85a72b
--- /dev/null
+++ b/libgxps/meson.build
@@ -0,0 +1,109 @@
+headers = [
+  'gxps.h',
+  'gxps-core-properties.h',
+  'gxps-document.h',
+  'gxps-document-structure.h',
+  'gxps-error.h',
+  'gxps-file.h',
+  'gxps-links.h',
+  'gxps-page.h',
+]
+
+private_headers = [
+  'gxps-archive.h',
+  'gxps-brush.h',
+  'gxps-color.h',
+  'gxps-debug.h',
+  'gxps-fonts.h',
+  'gxps-glyphs.h',
+  'gxps-images.h',
+  'gxps-matrix.h',
+  'gxps-page-private.h',
+  'gxps-parse-utils.h',
+  'gxps-path.h',
+  'gxps-private.h',
+]
+
+introspection_sources = [
+  'gxps-brush.c',
+  'gxps-color.c',
+  'gxps-core-properties.c',
+  'gxps-debug.c',
+  'gxps-document.c',
+  'gxps-document-structure.c',
+  'gxps-error.c',
+  'gxps-file.c',
+  'gxps-glyphs.c',
+  'gxps-links.c',
+  'gxps-matrix.c',
+  'gxps-page.c',
+  'gxps-path.c',
+]
+
+sources = [
+  'gxps-archive.c',
+  'gxps-fonts.c',
+  'gxps-images.c',
+  'gxps-parse-utils.c',
+]
+
+sources = [ sources + introspection_sources ]
+
+version_data = configuration_data()
+version_data.set('GXPS_MAJOR_VERSION', gxps_major_version)
+version_data.set('GXPS_MINOR_VERSION', gxps_minor_version)
+version_data.set('GXPS_MICRO_VERSION', gxps_micro_version)
+version_data.set('PACKAGE_VERSION', meson.project_version())
+
+gxps_version_h = configure_file(input: 'gxps-version.h.in',
+                                output: 'gxps-version.h',
+                                install_dir: gxps_headers_installdir,
+                                install: true,
+                                configuration: version_data)
+
+install_headers(headers, subdir: gxps_headers_installdir)
+
+platform_deps = [ glib, gobject, gio, cairo, archive, freetype, libm ]
+
+common_ldflags = []
+
+if host_system == 'linux'
+  common_ldflags = [ '-Wl,-Bsymbolic' ]
+endif
+
+gxps = shared_library('gxps',
+  include_directories: core_inc,
+  sources: sources + headers + private_headers + [ gxps_version_h ],
+  version: libversion,
+  soversion: soversion,
+  install: true,
+  dependencies: platform_deps,
+  c_args: extra_args + common_flags + [ 
+    '-DG_LOG_DOMAIN="GXPS"',
+    '-DGXPS_COMPILATION',
+  ],
+  link_args: common_ldflags)
+
+# Internal dependency, for tests
+gxps_inc = include_directories([ '.', '..' ])
+gxps_dep = declare_dependency(link_with: gxps,
+                              include_directories: [ gxps_inc ],
+                              dependencies: platform_deps)
+
+if build_gir
+  gir_extra_args = [
+    '--identifier-prefix=GXPS',
+    '--c-include=gxps.h'
+  ]
+  gnome.generate_gir(gxps,
+                     sources: introspection_sources + headers + [ gxps_version_h ],
+                     namespace: 'Gxps',
+                     nsversion: apiversion,
+                     identifier_prefix: 'Gxps',
+                     symbol_prefix: 'gxps',
+                     includes: [ 'GObject-2.0', 'GLib-2.0', 'Gio-2.0', 'cairo-1.0' ],
+                     install: true,
+                     extra_args: gir_extra_args + [
+                       '-DGXPS_COMPILATION',
+                     ])
+endif
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..4837c3c
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,185 @@
+project('libgxps', 'c',
+        version: '0.2.5',
+        default_options: [
+          'buildtype=debugoptimized'
+        ],
+        license: 'LGPL2+',
+        meson_version: '>= 0.36.0')
+
+gxps_version = meson.project_version()
+version_array = gxps_version.split('.')
+gxps_major_version = version_array[0].to_int()
+gxps_minor_version = version_array[1].to_int()
+gxps_micro_version = version_array[2].to_int()
+
+apiversion = '1.0'
+
+# The interface age is reset every time we add new API; this
+# should only happen during development cycles, otherwise the
+# interface age is the same as the micro version
+if gxps_minor_version.is_odd()
+  gxps_interface_age = 0
+else
+  gxps_interface_age = gxps_micro_version
+endif
+
+soversion = 0
+# maintaining compatibility with the previous libtool versioning
+# current = minor * 100 + micro - interface
+# revision = interface
+current = gxps_minor_version * 100 + gxps_micro_version - gxps_interface_age
+revision = gxps_interface_age
+libversion = '@0@.@1@.@2@'.format(soversion, current, revision)
+
+gxps_prefix = get_option('prefix')
+gxps_libdir = join_paths(gxps_prefix, get_option('libdir'))
+gxps_includedir = join_paths(gxps_prefix, get_option('includedir'))
+gxps_headers_installdir = join_paths(gxps_includedir, 'libgxps')
+gxps_datadir = join_paths(gxps_prefix, get_option('datadir'))
+
+cc = meson.get_compiler('c')
+host_system = host_machine.system()
+
+add_project_arguments('-DHAVE_CONFIG_H', language: 'c')
+
+conf = configuration_data()
+
+# Compat variables for pkgconfig
+conf.set('prefix', gxps_prefix)
+conf.set('exec_prefix', gxps_prefix)
+conf.set('libdir', gxps_libdir)
+conf.set('includedir', gxps_includedir)
+
+# Version macros
+conf.set('VERSION', gxps_version)
+
+# Compiler flags
+if cc.get_id() == 'msvc'
+  # Make MSVC more pedantic, this is a recommended pragma list
+  # from _Win32_Programming_ by Rector and Newcomer.  Taken from
+  # glib's msvc_recommended_pragmas.h--please see that file for
+  # the meaning of the warning codes used here
+  test_cflags = [
+    '-we4002', # too many actual parameters for macro
+    '-we4003', # not enough actual parameters for macro
+    '-w14010', # single-line comment contains line-continuation character
+    '-we4013', # 'function' undefined; assuming extern returning int
+    '-w14016', # no function return type; using int as default
+    '-we4020', # too many actual parameters
+    '-we4021', # too few actual parameters
+    '-we4027', # function declared without formal parameter list
+    '-we4029', # declared formal parameter list different from definition
+    '-we4033', # 'function' must return a value
+    '-we4035', # 'function' : no return value
+    '-we4045', # array bounds overflow
+    '-we4047', # different levels of indirection
+    '-we4049', # terminating line number emission
+    '-we4053', # an expression of type void was used as an operand
+    '-we4071', # no function prototype given
+    '-we4819', # the file contains a character that cannot be represented in the current code page
+  ]
+elif cc.get_id() == 'gcc' or cc.get_id() == 'clang'
+  test_cflags = [
+    '-Wpointer-arith',
+    '-Wmissing-declarations',
+    '-Wformat=2',
+    '-Wstrict-prototypes',
+    '-Wmissing-prototypes',
+    '-Wnested-externs',
+    '-Wold-style-definition',
+    '-Wdeclaration-after-statement',
+    '-Wunused',
+    '-Wno-uninitialized',
+    '-Wshadow',
+    '-Wcast-align',
+    '-Wmissing-noreturn',
+    '-Wmissing-format-attribute',
+    '-Wlogical-op',
+    '-Wno-discarded-qualifiers',
+    '-Werror=implicit',
+    '-Werror=nonnull',
+    '-Werror=init-self',
+    '-Werror=main',
+    '-Werror=missing-braces',
+    '-Werror=sequence-point',
+    '-Werror=return-type',
+    '-Werror=trigraphs',
+    '-Werror=array-bounds',
+    '-Werror=write-strings',
+    '-Werror=address',
+    '-Werror=int-to-pointer-cast',
+    '-Werror=pointer-to-int-cast',
+    '-fno-strict-aliasing',
+    '-Wno-int-conversion',
+  ]
+else
+  test_cflags = []
+endif
+common_flags = []
+foreach cflag: test_cflags
+  if cc.has_argument(cflag)
+    common_flags += [ cflag ]
+  endif
+endforeach
+
+extra_args= []
+
+cdata = configuration_data()
+
+if host_system == 'windows'
+  if cc.get_id() == 'msvc'
+    cdata.set('_GXPS_EXTERN', '__declspec(dllexport) extern')
+  else
+    cdata.set('_GXPS_EXTERN', '__attribute__((visibility("default"))) __declspec(dllexport) extern')
+    extra_args += ['-fvisibility=hidden']
+  endif
+else
+  cdata.set('_GXPS_EXTERN', '__attribute__((visibility("default"))) extern')
+  extra_args += ['-fvisibility=hidden']
+endif
+
+core_inc = include_directories('.')
+
+# Required dependencies
+glib_req = '2.36.0'
+cairo_req = '1.10.0'
+archive_req = '2.8.0'
+
+glib = dependency('glib-2.0', version: '>=' + glib_req)
+gobject = dependency('gobject-2.0', version: '>=' + glib_req)
+gio = dependency('gio-2.0', version: '>=' + glib_req)
+cairo = dependency('cairo', version: '>=' + cairo_req)
+archive = dependency('libarchive', version: '>=' + archive_req)
+freetype = dependency('freetype2')
+
+# Maths functions might be implemented in libm
+libm = cc.find_library('m', required: false)
+
+if get_option('enable-introspection')
+  # XXX: Not nice, but probably our best option
+  gir = find_program('g-ir-scanner', required: false)
+  build_gir = gir.found() and not meson.is_cross_build()
+endif
+
+gnome = import('gnome')
+
+configure_file(output: 'config.h', configuration: cdata)
+
+# Generate the pkg-config files
+configure_file(input: 'libgxps.pc.in',
+               output: 'libgxps.pc',
+               configuration: conf,
+               install: true,
+               install_dir: join_paths(gxps_libdir, 'pkgconfig'))
+
+subdir('libgxps')
+#subdir('tools')
+
+#if get_option('enable-test')
+#  gtk3 = dependency('gtk+-3.0')
+#  subdir('test')
+#endif
+
+#if get_option('enable-gtk-doc')
+#  subdir('docs')
+#endif
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..012b071
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,3 @@
+option('enable-test', type: 'boolean', value: false, description: 'Compile test application')
+option('enable-gtk-doc', type: 'boolean', value: false, description: 'Enable generating the API reference 
(depends on GTK-Doc)')
+option('enable-introspection', type: 'boolean', value: true, description: 'Enable GObject Introspection')


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