[libgxps/wip/nacho/meson: 1/6] Add meson build system



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

    Add meson build system
    
    This build system will initially serve to replace the nmake
    script and later on to also replace autotools once we are
    happy with the quality.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=783642

 docs/meson.build           |    7 ++
 docs/reference/meson.build |   42 ++++++++++
 docs/tools/meson.build     |   43 ++++++++++
 libgxps/meson.build        |  111 +++++++++++++++++++++++++
 meson.build                |  191 ++++++++++++++++++++++++++++++++++++++++++++
 meson_options.txt          |    7 ++
 mesonscripts/release.sh    |   20 +++++
 test/meson.build           |   11 +++
 tools/meson.build          |  100 +++++++++++++++++++++++
 9 files changed, 532 insertions(+), 0 deletions(-)
---
diff --git a/docs/meson.build b/docs/meson.build
new file mode 100644
index 0000000..67b24f6
--- /dev/null
+++ b/docs/meson.build
@@ -0,0 +1,7 @@
+if get_option('enable-gtk-doc')
+  subdir('reference')
+endif
+
+if get_option('enable-man')
+  subdir('tools')
+endif
diff --git a/docs/reference/meson.build b/docs/reference/meson.build
new file mode 100644
index 0000000..dbe6201
--- /dev/null
+++ b/docs/reference/meson.build
@@ -0,0 +1,42 @@
+version_conf = configuration_data()
+version_conf.set('PACKAGE_VERSION', meson.project_version())
+configure_file(input: 'version.xml.in',
+               output: 'version.xml',
+               configuration: version_conf)
+
+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',
+]
+
+glib_prefix = dependency('glib-2.0').get_pkgconfig_variable('prefix')
+glib_docpath = join_paths(glib_prefix, 'share', 'gtk-doc', 'html')
+docpath = join_paths(gxps_datadir, 'gtk-doc', 'html')
+
+gnome.gtkdoc('libgxps',
+             main_xml: 'libgxps-docs.sgml',
+             src_dir: [ join_paths(meson.source_root(), 'libgxps'), join_paths(meson.build_root(), 
'libgxps'), ],
+             dependencies: gxps_dep,
+             gobject_typesfile: 'libgxps.types',
+             scan_args: [
+               '--rebuild-types',
+               '--ignore-decorators=_GXPS_EXTERN',
+               '--ignore-headers=' + ' '.join(private_headers),
+             ],
+             fixxref_args: [
+               '--html-dir=@0@'.format(docpath),
+               '--extra-dir=@0@'.format(join_paths(glib_docpath, 'glib')),
+               '--extra-dir=@0@'.format(join_paths(glib_docpath, 'gobject')),
+               '--extra-dir=@0@'.format(join_paths(glib_docpath, 'gio')),
+             ],
+             install: true)
diff --git a/docs/tools/meson.build b/docs/tools/meson.build
new file mode 100644
index 0000000..037fb11
--- /dev/null
+++ b/docs/tools/meson.build
@@ -0,0 +1,43 @@
+xsltproc = find_program('xsltproc', required: false)
+if xsltproc.found()
+  xlstproc_flags = [
+    '--nonet',
+  ]
+
+  man_files = []
+
+  if jpeg_dep.found()
+    man_files += [ 'xpstojpeg' ]
+  endif
+
+  if cairo_pdf_dep.found()
+    man_files += [ 'xpstopdf' ]
+  endif
+
+  if png_dep.found()
+    man_files += [ 'xpstopng' ]
+  endif
+
+  if cairo_ps_dep.found()
+    man_files += [ 'xpstops' ]
+  endif
+
+  if cairo_svg_dep.found()
+    man_files += [ 'xpstosvg' ]
+  endif
+
+  foreach m: man_files
+    custom_target(m + ' man page',
+                  input: '@0@.xml'.format(m),
+                  output: '@0@.1'.format(m),
+                  command: [
+                    xsltproc,
+                    xlstproc_flags,
+                    '-o', '@OUTPUT@',
+                    'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl',
+                    '@INPUT@',
+                  ],
+                  install: true,
+                  install_dir: join_paths(gxps_mandir, 'man1'))
+  endforeach
+endif
diff --git a/libgxps/meson.build b/libgxps/meson.build
new file mode 100644
index 0000000..49da09e
--- /dev/null
+++ b/libgxps/meson.build
@@ -0,0 +1,111 @@
+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',
+  'gxps-resources.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',
+  'gxps-resources.c',
+]
+
+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: 'libgxps')
+
+gxps_deps = [ glib_dep, gobject_dep, gio_dep, cairo_dep, cairo_pdf_dep, cairo_ps_dep, cairo_svg_dep, 
archive_dep, freetype_dep, png_dep, lcms2_dep, jpeg_dep, tiff_dep, libm_dep ]
+
+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: gxps_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, core_inc ],
+                              dependencies: gxps_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..38c78cb
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,191 @@
+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()
+gxps_interface_age = gxps_micro_version
+
+apiversion = '1.0'
+
+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'))
+gxps_mandir = join_paths(get_option('prefix'), get_option('mandir'))
+
+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_dep = dependency('glib-2.0', version: '>=' + glib_req)
+gobject_dep = dependency('gobject-2.0', version: '>=' + glib_req)
+gio_dep = dependency('gio-2.0', version: '>=' + glib_req)
+cairo_dep = dependency('cairo', version: '>=' + cairo_req)
+cairo_pdf_dep = dependency('cairo-pdf', version: '>=' + cairo_req, required: false)
+cairo_ps_dep = dependency('cairo-ps', version: '>=' + cairo_req, required: false)
+cairo_svg_dep = dependency('cairo-svg', version: '>=' + cairo_req, required: false)
+archive_dep = dependency('libarchive', version: '>=' + archive_req)
+freetype_dep = dependency('freetype2')
+png_dep = dependency('libpng', required: false)
+lcms2_dep = dependency('lcms2', required: get_option('with-liblcms2'))
+jpeg_dep = dependency('libjpeg', required: get_option('with-libjpeg'))
+tiff_dep = dependency('libtiff-4', required: get_option('with-libtiff'))
+
+cdata.set('HAVE_CAIRO_PDF', cairo_pdf_dep.found())
+cdata.set('HAVE_CAIRO_PS', cairo_ps_dep.found())
+cdata.set('HAVE_CAIRO_SVG', cairo_svg_dep.found())
+cdata.set('HAVE_LIBPNG', png_dep.found())
+cdata.set('HAVE_LIBLCMS2', lcms2_dep.found())
+cdata.set('HAVE_LIBJPEG', jpeg_dep.found())
+cdata.set('HAVE_LIBTIFF', tiff_dep.found())
+
+# Maths functions might be implemented in libm
+libm_dep = cc.find_library('m')
+
+gnome = import('gnome')
+gir = find_program('g-ir-scanner', required: false)
+build_gir = gir.found() and not meson.is_cross_build() and not get_option('disable-introspection')
+
+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')
+subdir('docs')
+
+if get_option('enable-test')
+  gtk3_dep = dependency('gtk+-3.0')
+  subdir('test')
+endif
+
+run_target('release',
+           command: [join_paths('mesonscripts', 'release.sh'),
+                     meson.project_name(),
+                     meson.project_version()])
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..7c81612
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,7 @@
+option('enable-test', type: 'boolean', value: true, description: 'Compile test application')
+option('enable-gtk-doc', type: 'boolean', value: false, description: 'Enable generating the API reference 
(depends on GTK-Doc)')
+option('enable-man', type: 'boolean', value: false, description: 'Whether to generate the man pages for 
libgxps tools')
+option('disable-introspection', type: 'boolean', value: false, description: 'Whether to disable the 
introspection generation')
+option('with-liblcms2', type: 'boolean', value: true, description: 'With Little CMS 2')
+option('with-libjpeg', type: 'boolean', value: true, description: 'With libjpeg')
+option('with-libtiff', type: 'boolean', value: true, description: 'With libtiff')
diff --git a/mesonscripts/release.sh b/mesonscripts/release.sh
new file mode 100755
index 0000000..6fc6d33
--- /dev/null
+++ b/mesonscripts/release.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+NAME="$1"
+VERSION="$2"
+
+test -n "${MESON_SOURCE_ROOT}" || exit 1
+test -n "${NAME}" || exit 1
+test -n "${VERSION}" || exit 1
+
+cd "${MESON_SOURCE_ROOT}"
+
+echo "Removing old archive…"
+rm -f "${NAME}-${VERSION}.tar"
+rm -f "${NAME}-${VERSION}.tar.xz"
+
+echo "Creating git archive…"
+git archive --prefix="${NAME}-${VERSION}/" --format=tar HEAD -o ${NAME}-${VERSION}.tar
+
+echo "Compressing archive…"
+xz -f "${NAME}-${VERSION}.tar"
diff --git a/test/meson.build b/test/meson.build
new file mode 100644
index 0000000..4dbaf06
--- /dev/null
+++ b/test/meson.build
@@ -0,0 +1,11 @@
+test_programs = [
+  'test-gxps',
+]
+
+foreach test_program: test_programs
+  executable(test_program, test_program + '.c',
+             dependencies: [ gxps_dep, gtk3_dep ],
+             include_directories: gxps_inc)
+endforeach
+
+
diff --git a/tools/meson.build b/tools/meson.build
new file mode 100644
index 0000000..3f0aec7
--- /dev/null
+++ b/tools/meson.build
@@ -0,0 +1,100 @@
+tools_sources = [
+  'gxps-converter.c',
+  'gxps-converter.h',
+  'gxps-image-converter.c',
+  'gxps-image-converter.h',
+  'gxps-image-writer.c',
+  'gxps-image-writer.h',
+  'gxps-print-converter.c',
+  'gxps-print-converter.h',
+]
+
+gxps_tools_deps = [ glib_dep, gobject_dep, gio_dep, cairo_dep, cairo_pdf_dep, cairo_ps_dep, cairo_svg_dep, 
archive_dep, freetype_dep, png_dep, lcms2_dep, jpeg_dep, tiff_dep, libm_dep, gxps_dep ]
+
+gxps_tools = static_library('gxpstools',
+                            include_directories: core_inc,
+                            sources: tools_sources,
+                            install: false,
+                            dependencies: gxps_tools_deps)
+
+gxps_tools_dep = declare_dependency(link_with: gxps_tools,
+                                    dependencies: gxps_tools_deps)
+
+if png_dep.found()
+  xpstopng_sources = [
+    'gxps-converter-main.c',
+    'gxps-png-converter.c',
+    'gxps-png-converter.h',
+    'gxps-png-writer.c',
+    'gxps-png-writer.h',
+  ]
+
+  executable('xpstopng', xpstopng_sources,
+             dependencies: gxps_tools_dep,
+             c_args: [
+               '-DCONVERTER_TYPE=GXPS_TYPE_PNG_CONVERTER',
+               '-DCONVERTER_HEADER=gxps-png-converter.h',
+             ])
+endif
+
+if jpeg_dep.found()
+  xpstojpeg_sources = [
+    'gxps-converter-main.c',
+    'gxps-jpeg-converter.c',
+    'gxps-jpeg-converter.h',
+    'gxps-jpeg-writer.c',
+    'gxps-jpeg-writer.h',
+  ]
+
+  executable('xpstojpeg', xpstojpeg_sources,
+             dependencies: gxps_tools_dep,
+             c_args: [
+               '-DCONVERTER_TYPE=GXPS_TYPE_JPEG_CONVERTER',
+               '-DCONVERTER_HEADER=gxps-jpeg-converter.h',
+             ])
+endif
+
+if cairo_pdf_dep.found()
+  xpstopdf_sources = [
+    'gxps-converter-main.c',
+    'gxps-pdf-converter.c',
+    'gxps-pdf-converter.h',
+  ]
+
+  executable('xpstopdf', xpstopdf_sources,
+             dependencies: gxps_tools_dep,
+             c_args: [
+               '-DCONVERTER_TYPE=GXPS_TYPE_PDF_CONVERTER',
+               '-DCONVERTER_HEADER=gxps-pdf-converter.h',
+             ])
+endif
+
+if cairo_ps_dep.found()
+  xpstops_sources = [
+    'gxps-converter-main.c',
+    'gxps-ps-converter.c',
+    'gxps-ps-converter.h',
+  ]
+
+  executable('xpstops', xpstops_sources,
+             dependencies: gxps_tools_dep,
+             c_args: [
+               '-DCONVERTER_TYPE=GXPS_TYPE_PS_CONVERTER',
+               '-DCONVERTER_HEADER=gxps-ps-converter.h',
+             ])
+endif
+
+if cairo_svg_dep.found()
+  xpstosvg_sources = [
+    'gxps-converter-main.c',
+    'gxps-svg-converter.c',
+    'gxps-svg-converter.h',
+  ]
+
+  executable('xpstosvg', xpstosvg_sources,
+             dependencies: gxps_tools_dep,
+             c_args: [
+               '-DCONVERTER_TYPE=GXPS_TYPE_SVG_CONVERTER',
+               '-DCONVERTER_HEADER=gxps-svg-converter.h',
+             ])
+endif


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