[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2-demos] meson-build a7e138a: [build] Add Meson build files and
From: |
Werner Lemberg |
Subject: |
[freetype2-demos] meson-build a7e138a: [build] Add Meson build files and documentation |
Date: |
Sun, 23 May 2021 17:07:52 -0400 (EDT) |
branch: meson-build
commit a7e138a301497f29319327a18b1d2d775a8558a9
Author: David Turner <david@freetype.org>
Commit: 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. For full
instructions, see the new README.meson file.
---
.gitignore | 2 +
README | 2 +
README.meson | 102 ++++++++++++++++++++++++
graph/meson.build | 80 +++++++++++++++++++
meson.build | 189 +++++++++++++++++++++++++++++++++++++++++++++
src/ftinspect/meson.build | 53 +++++++++++++
subprojects/freetype2.wrap | 6 ++
subprojects/libpng.wrap | 11 +++
subprojects/zlib.wrap | 12 +++
9 files changed, 457 insertions(+)
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..4af8090
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+subprojects/*
+!subprojects/*.wrap
diff --git a/README b/README
index dfc1a5d..20c432e 100644
--- a/README
+++ b/README
@@ -1,5 +1,7 @@
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..cb74e34
--- /dev/null
+++ b/README.meson
@@ -0,0 +1,102 @@
+The FreeType 2 demo programs can now be built with the Meson Build System.
+
+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 will be 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 BUILD_DIR` will clone the HEAD
+revision of the FreeType2 git repository under `subprojects/freetype2`.
+
+You can however use any other revision, using one of these methods *before*
+running `meson setup`:
+
+ - Modify the content 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
+------------------------------
+
+ # Setup build directory named 'build.meson', and optionally clone
+ # FreeType2 source repository, as explained previously.
+
+ meson setup build.meson
+
+ # Compile all demo programs
+ #
+ # You should be able to be able to run all programs directly from
+ # the build.meson/ directory.
+ #
+
+ meson compile -C build.meson
+
+
+Installation with the `meson install`
+-------------------------------------
+
+First, keep in mind that the FreeType demo programs are mostly used to
+develop and debug FreeType, it is very unlikely that you would want to
+install them on your system. Nevertheless, if that's what you want,
+the `meson install` command will work, with a big caveat: it will also
+install the FreeType2 headers, libraries and configuration files as well!
+
+This is the default behaviour for `meson install`, and can be undesirable.
+Fortunately, Meson 0.58 and above support the `--skip-subprojects` option
+to override this
+(https://mesonbuild.com/Release-notes-for-0-58-0.html#skip-subprojects-installation)
+
+A clean build + install using Meson 0.58 or above looks like:
+
+ # Setup compilation to build and install the stripped demo programs to
+ # the /opt directory, instead of the default (i.e. /usr/local on Linux).
+ #
+ # Note the extra options set here:
+ #
+ # * strip=true ensures the installed binaries are properly stripped.
+ # * buildtype=release ensures the binaries are fully optimized.
+
+ meson setup build.meson -Dstrip=true -Dbuildtype=release --prefix=/opt
+ meson install -C build.meson --skip-subprojects
+
+For older Meson releases, simply do not use `--skip-subprojects` and remove the
+extra files manually. For example, assuming that FreeType2 was **not** already
+installed under `/opt`, one could do:
+
+ meson setup build.meson -Dstrip=true -Dbuildtype=release --prefix=/opt
+ meson install -C build.meson
+ rm /opt/lib/x86_64-linux-gnu/libfreetype.a
+ rm /opt/lib/x86_64-linux-gnu/pkgconfig/freetype2.pc
+ rm -rf /opt/include/freetype2
+
+Note that by default, all binaries are statically linked to the FreeType
library.
+This is useful for debugging, and also to ensure 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.meson \
+ -Dstrip=true \
+ -Dbuildtype=release \
+ -Dfreetype2:default_library=shared \
+ --prefix=/opt \
+
+ meson install -C build.meson --skip-subprojects
+
+Note that `--skip-subprojects` will prevent installation of the FreeType 2
+shared library to the destination directory. Do not use if you want to install
+the library as well (along its headers and config files).
+
diff --git a/graph/meson.build b/graph/meson.build
new file mode 100644
index 0000000..d1d28cb
--- /dev/null
+++ b/graph/meson.build
@@ -0,0 +1,80 @@
+#
+# 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,
+)
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..6c1799f
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,189 @@
+#
+# 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')
+
+# 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.c',
+ 'src/ftmemchk.c',
+ dependencies: [libfreetype2_dep],
+ install: false)
+
+executable(
+ 'ftpatchk.c',
+ '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')
diff --git a/src/ftinspect/meson.build b/src/ftinspect/meson.build
new file mode 100644
index 0000000..e71c887
--- /dev/null
+++ b/src/ftinspect/meson.build
@@ -0,0 +1,53 @@
+#
+# 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 was not found. This can happne
+# 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
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
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2-demos] meson-build a7e138a: [build] Add Meson build files and documentation,
Werner Lemberg <=