freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] master 82fc87a: [build] Add Meson build files and docu


From: Werner Lemberg
Subject: [freetype2-demos] master 82fc87a: [build] Add Meson build files and documentation.
Date: Mon, 24 May 2021 04:24:11 -0400 (EDT)

branch: master
commit 82fc87a8eaadc5c24ab8e30a1f13a33c02fe1dd9
Author: David Turner <david@freetype.org>
Commit: Werner Lemberg <wl@gnu.org>

    [build] Add Meson build files and documentation.
    
    This commit adds files necessary to build the demo programs,
    including `ftinspect`, with the Meson build system.
    
    * meson.build, graph/meson.build, src/ftinspect/meson.build: New
    build files for Meson.
    * subprojects/freetype2.wrap, subprojects/libpng.wrap,
    subprojects/zlib.wrap: New subproject files for Meson.
    * README.meson: New file.
    * README, .gitignore: Updated.
---
 .gitignore                 |   3 +
 ChangeLog                  |  14 ++++
 README                     |   3 +
 README.meson               | 117 ++++++++++++++++++++++++++++
 graph/meson.build          |  83 ++++++++++++++++++++
 meson.build                | 185 +++++++++++++++++++++++++++++++++++++++++++++
 src/ftinspect/meson.build  |  54 +++++++++++++
 subprojects/freetype2.wrap |   6 ++
 subprojects/libpng.wrap    |  11 +++
 subprojects/zlib.wrap      |  12 +++
 10 files changed, 488 insertions(+)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..0e892bc
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+/build/
+subprojects/*
+!subprojects/*.wrap
diff --git a/ChangeLog b/ChangeLog
index 9a11371..c8290fb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2021-05-24  David Turner  <david@freetype.org>
+
+       [build] Add Meson build files and documentation.
+
+       This commit adds files necessary to build the demo programs,
+       including `ftinspect`, with the Meson build system.
+
+       * meson.build, graph/meson.build, src/ftinspect/meson.build: New
+       build files for Meson.
+       * subprojects/freetype2.wrap, subprojects/libpng.wrap,
+       subprojects/zlib.wrap: New subproject files for Meson.
+       * README.meson: New file.
+       * README, .gitignore: Updated.
+
 2021-05-21  Alexei Podtelezhnikov  <apodtele@gmail.com>
 
        * Makefile (LINK_LIBS): Add `-lgdiplus' for PNG saving on Windows.
diff --git a/README b/README
index dfc1a5d..e0d7556 100644
--- a/README
+++ b/README
@@ -1,5 +1,8 @@
 This package contains example programs for the FreeType 2 library.
 
+You can build it either using the Meson build tool (see `README.meson`
+for  more details),  or  using GNU  Make,  following the  instructions
+below.
 
 WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
 
diff --git a/README.meson b/README.meson
new file mode 100644
index 0000000..d8a4cdb
--- /dev/null
+++ b/README.meson
@@ -0,0 +1,117 @@
+The FreeType  2 demo programs  can now be  built with the  Meson build
+system (https://mesonbuild.com).
+
+
+Requirements
+------------
+
+The Meson build  tool and its dependencies must be  installed, as well
+as a C and a C++ compiler.
+
+If  Qt5  development  libraries  are available  on  your  system,  the
+`ftinspect` program  is compiled and  linked against them,  or ignored
+otherwise.
+
+A FreeType 2 source repository is always required to build some of the
+test programs, because they depend  on internal headers of the library
+(e.g., `ttdebug`).
+
+By default, the first run of  `meson setup <builddir>` clones the HEAD
+revision of FreeType's git repository under `subprojects/freetype2`.
+
+However, you  can use any  other revision if  you follow one  of these
+methods *before* running `meson setup`:
+
+  - Modify the  contents of  `subprojects/freetype2.wrap` to  point to
+    your chosen URL and/or revision.
+
+  - Alternatively,  create or  replace `subprojects/freetype2`  with a
+    symlink to or a copy of the FreeType2 source tree of your chosing.
+
+
+Quick compilation instructions
+------------------------------
+
+  # Set  up  build  directory  named  'build',  and  optionally  clone
+  # the FreeType 2 source repository, as explained above.
+
+  meson setup build
+
+  # Compile all demo programs
+  #
+  # You should  be able to be  able to run all  programs directly from
+  # the `build/` directory.
+
+  meson compile -C build
+
+The binaries can  then be found in in the  `build` subdirectory except
+`ftinspect`, which is put into `build/src/ftinspect`.
+
+
+Installation with `meson install`
+---------------------------------
+
+Please keep in mind that the  FreeType 2 demo programs are mostly used
+to develop  and debug FreeType;  it is  thus rather unlikely  that you
+want  to  install  them  on your  system.   Nevertheless,  the  `meson
+install` command works, with a big  caveat: it installs the FreeType 2
+headers, libraries, and configuration files as well.
+
+This  is  the  default  behaviour  for `meson  install`,  and  can  be
+undesirable.  Fortunately,  Meson version 0.58 and  above supports the
+`--skip-subprojects` option to override this; see
+
+  
https://mesonbuild.com/Release-notes-for-0-58-0.html#skip-subprojects-installation
+
+A clean  build followed by an  installation using Meson 0.58  or above
+looks like the following.
+
+  # Set up compilation to build and install the stripped demo programs
+  # to the `/opt` directory, instead of the default (which would be
+  # `/usr/local` on Linux).
+  #
+  # Note the extra options set here:
+  #
+  # * `strip=true` ensures that the installed binaries don't contain
+  #   debug symbols.
+  # * `buildtype=release` ensures that the binaries are fully
+  #   optimized.
+
+  meson setup build -Dstrip=true -Dbuildtype=release --prefix=/opt
+  meson install -C build --skip-subprojects
+
+For older Meson  releases, simply do not  use `--skip-subprojects` and
+remove the extra files manually.   For example, assuming that FreeType
+was *not* already installed under `/opt`, one could do
+
+  meson setup build -Dstrip=true -Dbuildtype=release --prefix=/opt
+  meson install -C build
+  rm /opt/lib/x86_64-linux-gnu/libfreetype.a
+  rm /opt/lib/x86_64-linux-gnu/pkgconfig/freetype2.pc
+  rm -rf /opt/include/freetype2
+
+The `x86_64-linux-gnu` part  varies depending on the host  OS and used
+architecure.
+
+Note  that  by default  all  binaries  are  statically linked  to  the
+FreeType library, which is useful for debugging.  It also ensures that
+the  programs  always use  the  exact  FreeType  2 version  they  were
+compiled against  at runtime  (which could be  broken if  your library
+search path is not set correctly).
+
+It is possible  to build and link against the  shared library instead,
+by adding the `-Dfreetype2:default_library=shared` option, as in
+
+  meson setup build \
+    -Dstrip=true \
+    -Dbuildtype=release \
+    -Dfreetype2:default_library=shared \
+    --prefix=/opt \
+  meson install -C build --skip-subprojects
+
+Note that `--skip-subprojects` prevents installation of the FreeType 2
+shared library  to the destination  directory.  Do  not use it  if you
+want to  install the  library as  well (along  its headers  and config
+files).
+
+--- end of README.meson ---
diff --git a/graph/meson.build b/graph/meson.build
new file mode 100644
index 0000000..3ebe085
--- /dev/null
+++ b/graph/meson.build
@@ -0,0 +1,83 @@
+#
+# Meson project file for FreeType graph library
+#
+
+# Copyright (C) 2021 by
+# David Turner, Robert Wilhelm, and Werner Lemberg.
+#
+# This file is part of the FreeType project, and may only be used, modified,
+# and distributed under the terms of the FreeType project license,
+# LICENSE.TXT.  By continuing to use, modify, or distribute this file you
+# indicate that you have read the license and understand and accept it
+# fully.
+
+graph_c_args = []
+graph_dependencies = []
+graph_sources = files([
+  'gblany.h',
+  'gblblit.h',
+  'gblblit.c',
+  'gblender.c',
+  'gblender.h',
+  'graph.h',
+  'grblit.c',
+  'grblit.h',
+  'grconfig.h',
+  'grdevice.c',
+  'grdevice.h',
+  'grevents.h',
+  'grfill.c',
+  'grfont.c',
+  'grfont.h',
+  'grinit.c',
+  'grobjs.c',
+  'grswizzle.c',
+  'grswizzle.h',
+  'grtypes.h',
+])
+
+# The batch device is always compiled in.
+graph_sources += files([
+  'batch/grbatch.c',
+  'batch/grbatch.h',
+])
+graph_c_args += ['-DDEVICE_BATCH']
+
+# The Win32 device is available on Windows.
+if host_machine.system() == 'windows'
+  graph_sources += files([
+    'win32/grwin32.c',
+    'win32/grwin32.h',
+  ])
+  graph_c_args += ['-DDEVICE_WIN32']
+  graph_dependencies += [meson.get_compiler('c').find_library('gdiplus')]
+
+elif host_machine.system() == 'darwin'
+  graph_sources += files([
+    'mac/grmac.c',
+    'mac/grmac.h',
+  ])
+  graph_c_args += ['-DDEVICE_MAC']
+endif
+
+x11_dep = dependency('x11',
+  required: false)
+if x11_dep.found()
+  graph_sources += files([
+    'x11/grx11.c',
+    'x11/grx11.h',
+  ])
+  graph_c_args += ['-DDEVICE_X11']
+  graph_dependencies += [x11_dep]
+endif
+
+graph_include_dir = include_directories('.')
+
+graph_lib = static_library('graph',
+  graph_sources,
+  include_directories: graph_include_dir,
+  c_args: graph_c_args,
+  dependencies: graph_dependencies,
+)
+
+# EOF
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..c316429
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,185 @@
+#
+# Meson project file for FreeType 2 test programs
+#
+
+# Copyright (C) 2021 by
+# David Turner, Robert Wilhelm, and Werner Lemberg.
+#
+# This file is part of the FreeType project, and may only be used, modified,
+# and distributed under the terms of the FreeType project license,
+# LICENSE.TXT.  By continuing to use, modify, or distribute this file you
+# indicate that you have read the license and understand and accept it
+# fully.
+
+
+project('freetype-demos', 'c', 'cpp',
+  version: run_command(
+    'subprojects/freetype2/builds/meson/extract_freetype_version.py',
+    'subprojects/freetype2/include/freetype/freetype.h').stdout().strip(),
+)
+
+
+# Access to the FreeType 2 source tree is required, since some of the demo
+# programs rely on internal headers (e.g., `ttdebug`).  See `README.meson`
+# for more information.
+libfreetype2 = subproject('freetype2',
+  default_options: 'default_library=static')
+libfreetype2_dep = libfreetype2.get_variable('freetype_dep')
+
+libpng_dep = dependency('libpng',
+  required: true)
+
+cc = meson.get_compiler('c')
+
+math_dep = cc.find_library('m',
+  required: false)
+
+subdir('graph')
+
+common_files = files([
+  'src/common.c',
+  'src/common.h',
+  'src/strbuf.c',
+  'src/strbuf.h',
+])
+
+# Use `mlgetopt.h` on non-Unix platforms.
+if host_machine.system() == 'windows'
+  common_files += files([
+    'src/mlgetopt.h',
+    'src/mlgetopt.c',
+  ])
+endif
+
+common_lib = static_library('common',
+  common_files)
+
+output_lib = static_library('output',
+  [
+    'src/output.c',
+    'src/output.h',
+  ],
+  dependencies: libfreetype2_dep
+)
+
+ftcommon_lib = static_library('ftcommon',
+  [
+    'src/ftcommon.c',
+    'src/ftcommon.h',
+    'src/ftpngout.c',
+  ],
+  dependencies: [libpng_dep, libfreetype2_dep],
+  include_directories: graph_include_dir,
+  link_with: [common_lib, graph_lib],
+)
+
+executable('fttimer',
+  'src/fttimer.c',
+  dependencies: libfreetype2_dep,
+  install: false)
+
+executable('ftchkwd',
+  'src/ftchkwd.c',
+  dependencies: libfreetype2_dep,
+  install: false)
+
+executable('ftmemchk',
+  'src/ftmemchk.c',
+  dependencies: libfreetype2_dep,
+  install: false)
+
+executable('ftpatchk',
+  'src/ftpatchk.c',
+  dependencies: libfreetype2_dep,
+  install: false)
+
+executable('ftbench',
+  'src/ftbench.c',
+  dependencies: libfreetype2_dep,
+  link_with: common_lib,
+  install: true)
+
+executable('ftdump',
+  'src/ftdump.c',
+  dependencies: libfreetype2_dep,
+  link_with: [common_lib, output_lib],
+  install: true)
+
+executable('ftlint',
+  'src/ftlint.c',
+  dependencies: libfreetype2_dep,
+  link_with: common_lib,
+  install: true)
+
+executable('ftdiff',
+  'src/ftdiff.c',
+  dependencies: libfreetype2_dep,
+  include_directories: graph_include_dir,
+  link_with: ftcommon_lib,
+  install: true)
+
+executable('ftgamma',
+  'src/ftgamma.c',
+  dependencies: [libfreetype2_dep, math_dep],
+  include_directories: graph_include_dir,
+  link_with: ftcommon_lib,
+  install: true)
+
+executable('ftgrid',
+  'src/ftgrid.c',
+  dependencies: libfreetype2_dep,
+  include_directories: graph_include_dir,
+  link_with: [ftcommon_lib, output_lib],
+  install: true)
+
+executable('ftmulti',
+  'src/ftmulti.c',
+  dependencies: libfreetype2_dep,
+  include_directories: graph_include_dir,
+  link_with: ftcommon_lib,
+  install: true)
+
+executable('ftsdf',
+  'src/ftsdf.c',
+  dependencies: libfreetype2_dep,
+  include_directories: graph_include_dir,
+  link_with: ftcommon_lib,
+  install: true)
+
+executable('ftstring',
+  'src/ftstring.c',
+  dependencies: [libfreetype2_dep, math_dep],
+  include_directories: graph_include_dir,
+  link_with: ftcommon_lib,
+  install: true)
+
+executable('ftview',
+  'src/ftview.c',
+  dependencies: libfreetype2_dep,
+  include_directories: graph_include_dir,
+  link_with: ftcommon_lib,
+  install: true)
+
+executable('ftvalid',
+  'src/ftvalid.c',
+  dependencies: libfreetype2_dep,
+  link_with: common_lib,
+  install: true)
+
+install_man([
+  'man/ftbench.1',
+  'man/ftdiff.1',
+  'man/ftdump.1',
+  'man/ftgamma.1',
+  'man/ftgrid.1',
+  'man/ftlint.1',
+  'man/ftmulti.1',
+  'man/ftstring.1',
+  'man/ftvalid.1',
+  'man/ftview.1',
+  'man/ttdebug.1',
+])
+
+subdir('src/ftinspect')
+
+# EOF
diff --git a/src/ftinspect/meson.build b/src/ftinspect/meson.build
new file mode 100644
index 0000000..2f25223
--- /dev/null
+++ b/src/ftinspect/meson.build
@@ -0,0 +1,54 @@
+#
+# Meson project file for the ftinspect program.
+#
+
+# Copyright (C) 2021 by
+# David Turner, Robert Wilhelm, and Werner Lemberg.
+#
+# This file is part of the FreeType project, and may only be used, modified,
+# and distributed under the terms of the FreeType project license,
+# LICENSE.TXT.  By continuing to use, modify, or distribute this file you
+# indicate that you have read the license and understand and accept it
+# fully.
+
+qt5 = import('qt5')
+qt5_dep = dependency('qt5',
+  required: false,
+  modules: ['Core', 'Gui', 'Widgets'])
+
+# Don't compile `ftinspect` if Qt5 is not found.  This can happen
+# when cross-compiling to a different system.
+if qt5_dep.found()
+  sources = files([
+    'engine/engine.cpp',
+    'rendering/glyphbitmap.cpp',
+    'rendering/glyphoutline.cpp',
+    'rendering/glyphpointnumbers.cpp',
+    'rendering/glyphpoints.cpp',
+    'rendering/grid.cpp',
+    'widgets/qcomboboxx.cpp',
+    'widgets/qgraphicsviewx.cpp',
+    'widgets/qpushbuttonx.cpp',
+    'widgets/qspinboxx.cpp',
+    'ftinspect.cpp',
+    'maingui.cpp',
+  ])
+
+  moc_files = qt5.preprocess(
+    moc_headers: [
+      'widgets/qcomboboxx.hpp',
+      'widgets/qgraphicsviewx.hpp',
+      'widgets/qpushbuttonx.hpp',
+      'widgets/qspinboxx.hpp',
+      'maingui.hpp',
+    ],
+    dependencies: qt5_dep)
+
+  executable('ftinspect',
+    sources,
+    moc_files,
+    dependencies: [qt5_dep, libfreetype2_dep],
+    install: true)
+endif
+
+# EOF
diff --git a/subprojects/freetype2.wrap b/subprojects/freetype2.wrap
new file mode 100644
index 0000000..e1171e3
--- /dev/null
+++ b/subprojects/freetype2.wrap
@@ -0,0 +1,6 @@
+[wrap-git]
+url = https://gitlab.freedesktop.org/freetype/freetype.git
+revision = head
+
+[provide]
+freetype2 = freetype_dep
diff --git a/subprojects/libpng.wrap b/subprojects/libpng.wrap
new file mode 100644
index 0000000..599045b
--- /dev/null
+++ b/subprojects/libpng.wrap
@@ -0,0 +1,11 @@
+[wrap-file]
+directory = libpng-1.6.37
+source_url = https://github.com/glennrp/libpng/archive/v1.6.37.tar.gz
+source_filename = libpng-1.6.37.tar.gz
+source_hash = ca74a0dace179a8422187671aee97dd3892b53e168627145271cad5b5ac81307
+patch_url = https://wrapdb.mesonbuild.com/v1/projects/libpng/1.6.37/3/get_zip
+patch_filename = libpng-1.6.37-3-wrap.zip
+patch_hash = 6c9f32fd9150b3a96ab89be52af664e32207e10aa9f5fb9aa015989ee2dd7100
+
+[provide]
+libpng = libpng_dep
diff --git a/subprojects/zlib.wrap b/subprojects/zlib.wrap
new file mode 100644
index 0000000..ce20fb0
--- /dev/null
+++ b/subprojects/zlib.wrap
@@ -0,0 +1,12 @@
+[wrap-file]
+directory = zlib-1.2.11
+source_url = http://zlib.net/fossils/zlib-1.2.11.tar.gz
+source_filename = zlib-1.2.11.tar.gz
+source_hash = c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1
+patch_url = https://wrapdb.mesonbuild.com/v1/projects/zlib/1.2.11/5/get_zip
+patch_filename = zlib-1.2.11-5-wrap.zip
+patch_hash = 728c8e24acbc2e6682fbd950fec39e2fc77528af361adb87259f8a8511434004
+
+[provide]
+zlib = zlib_dep
+



reply via email to

[Prev in Thread] Current Thread [Next in Thread]