freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype-demos][master] [build] Add Meson build files and


From: Werner Lemberg (@wl)
Subject: [Git][freetype/freetype-demos][master] [build] Add Meson build files and documentation.
Date: Mon, 24 May 2021 08:24:05 +0000

Werner Lemberg pushed to branch master at FreeType / FreeType Demo Programs

Commits:

10 changed files:

Changes:

  • .gitignore
    1
    +/build/
    
    2
    +subprojects/*
    
    3
    +!subprojects/*.wrap

  • ChangeLog
    1
    +2021-05-24  David Turner  <david@freetype.org>
    
    2
    +
    
    3
    +	[build] Add Meson build files and documentation.
    
    4
    +
    
    5
    +	This commit adds files necessary to build the demo programs,
    
    6
    +	including `ftinspect`, with the Meson build system.
    
    7
    +
    
    8
    +	* meson.build, graph/meson.build, src/ftinspect/meson.build: New
    
    9
    +	build files for Meson.
    
    10
    +	* subprojects/freetype2.wrap, subprojects/libpng.wrap,
    
    11
    +	subprojects/zlib.wrap: New subproject files for Meson.
    
    12
    +	* README.meson: New file.
    
    13
    +	* README, .gitignore: Updated.
    
    14
    +
    
    1 15
     2021-05-21  Alexei Podtelezhnikov  <apodtele@gmail.com>
    
    2 16
     
    
    3 17
     	* Makefile (LINK_LIBS): Add `-lgdiplus' for PNG saving on Windows.
    

  • README
    1 1
     This package contains example programs for the FreeType 2 library.
    
    2 2
     
    
    3
    +You can build it either using the Meson build tool (see `README.meson`
    
    4
    +for  more details),  or  using GNU  Make,  following the  instructions
    
    5
    +below.
    
    3 6
     
    
    4 7
     WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
    
    5 8
     
    

  • README.meson
    1
    +The FreeType  2 demo programs  can now be  built with the  Meson build
    
    2
    +system (https://mesonbuild.com).
    
    3
    +
    
    4
    +
    
    5
    +Requirements
    
    6
    +------------
    
    7
    +
    
    8
    +The Meson build  tool and its dependencies must be  installed, as well
    
    9
    +as a C and a C++ compiler.
    
    10
    +
    
    11
    +If  Qt5  development  libraries  are available  on  your  system,  the
    
    12
    +`ftinspect` program  is compiled and  linked against them,  or ignored
    
    13
    +otherwise.
    
    14
    +
    
    15
    +A FreeType 2 source repository is always required to build some of the
    
    16
    +test programs, because they depend  on internal headers of the library
    
    17
    +(e.g., `ttdebug`).
    
    18
    +
    
    19
    +By default, the first run of  `meson setup <builddir>` clones the HEAD
    
    20
    +revision of FreeType's git repository under `subprojects/freetype2`.
    
    21
    +
    
    22
    +However, you  can use any  other revision if  you follow one  of these
    
    23
    +methods *before* running `meson setup`:
    
    24
    +
    
    25
    +  - Modify the  contents of  `subprojects/freetype2.wrap` to  point to
    
    26
    +    your chosen URL and/or revision.
    
    27
    +
    
    28
    +  - Alternatively,  create or  replace `subprojects/freetype2`  with a
    
    29
    +    symlink to or a copy of the FreeType2 source tree of your chosing.
    
    30
    +
    
    31
    +
    
    32
    +Quick compilation instructions
    
    33
    +------------------------------
    
    34
    +
    
    35
    +  # Set  up  build  directory  named  'build',  and  optionally  clone
    
    36
    +  # the FreeType 2 source repository, as explained above.
    
    37
    +
    
    38
    +  meson setup build
    
    39
    +
    
    40
    +  # Compile all demo programs
    
    41
    +  #
    
    42
    +  # You should  be able to be  able to run all  programs directly from
    
    43
    +  # the `build/` directory.
    
    44
    +
    
    45
    +  meson compile -C build
    
    46
    +
    
    47
    +The binaries can  then be found in in the  `build` subdirectory except
    
    48
    +`ftinspect`, which is put into `build/src/ftinspect`.
    
    49
    +
    
    50
    +
    
    51
    +Installation with `meson install`
    
    52
    +---------------------------------
    
    53
    +
    
    54
    +Please keep in mind that the  FreeType 2 demo programs are mostly used
    
    55
    +to develop  and debug FreeType;  it is  thus rather unlikely  that you
    
    56
    +want  to  install  them  on your  system.   Nevertheless,  the  `meson
    
    57
    +install` command works, with a big  caveat: it installs the FreeType 2
    
    58
    +headers, libraries, and configuration files as well.
    
    59
    +
    
    60
    +This  is  the  default  behaviour  for `meson  install`,  and  can  be
    
    61
    +undesirable.  Fortunately,  Meson version 0.58 and  above supports the
    
    62
    +`--skip-subprojects` option to override this; see
    
    63
    +
    
    64
    +  https://mesonbuild.com/Release-notes-for-0-58-0.html#skip-subprojects-installation
    
    65
    +
    
    66
    +A clean  build followed by an  installation using Meson 0.58  or above
    
    67
    +looks like the following.
    
    68
    +
    
    69
    +  # Set up compilation to build and install the stripped demo programs
    
    70
    +  # to the `/opt` directory, instead of the default (which would be
    
    71
    +  # `/usr/local` on Linux).
    
    72
    +  #
    
    73
    +  # Note the extra options set here:
    
    74
    +  #
    
    75
    +  # * `strip=true` ensures that the installed binaries don't contain
    
    76
    +  #   debug symbols.
    
    77
    +  # * `buildtype=release` ensures that the binaries are fully
    
    78
    +  #   optimized.
    
    79
    +
    
    80
    +  meson setup build -Dstrip=true -Dbuildtype=release --prefix=/opt
    
    81
    +  meson install -C build --skip-subprojects
    
    82
    +
    
    83
    +For older Meson  releases, simply do not  use `--skip-subprojects` and
    
    84
    +remove the extra files manually.   For example, assuming that FreeType
    
    85
    +was *not* already installed under `/opt`, one could do
    
    86
    +
    
    87
    +  meson setup build -Dstrip=true -Dbuildtype=release --prefix=/opt
    
    88
    +  meson install -C build
    
    89
    +  rm /opt/lib/x86_64-linux-gnu/libfreetype.a
    
    90
    +  rm /opt/lib/x86_64-linux-gnu/pkgconfig/freetype2.pc
    
    91
    +  rm -rf /opt/include/freetype2
    
    92
    +
    
    93
    +The `x86_64-linux-gnu` part  varies depending on the host  OS and used
    
    94
    +architecure.
    
    95
    +
    
    96
    +Note  that  by default  all  binaries  are  statically linked  to  the
    
    97
    +FreeType library, which is useful for debugging.  It also ensures that
    
    98
    +the  programs  always use  the  exact  FreeType  2 version  they  were
    
    99
    +compiled against  at runtime  (which could be  broken if  your library
    
    100
    +search path is not set correctly).
    
    101
    +
    
    102
    +It is possible  to build and link against the  shared library instead,
    
    103
    +by adding the `-Dfreetype2:default_library=shared` option, as in
    
    104
    +
    
    105
    +  meson setup build \
    
    106
    +    -Dstrip=true \
    
    107
    +    -Dbuildtype=release \
    
    108
    +    -Dfreetype2:default_library=shared \
    
    109
    +    --prefix=/opt \
    
    110
    +  meson install -C build --skip-subprojects
    
    111
    +
    
    112
    +Note that `--skip-subprojects` prevents installation of the FreeType 2
    
    113
    +shared library  to the destination  directory.  Do  not use it  if you
    
    114
    +want to  install the  library as  well (along  its headers  and config
    
    115
    +files).
    
    116
    +
    
    117
    +--- end of README.meson ---

  • graph/meson.build
    1
    +#
    
    2
    +# Meson project file for FreeType graph library
    
    3
    +#
    
    4
    +
    
    5
    +# Copyright (C) 2021 by
    
    6
    +# David Turner, Robert Wilhelm, and Werner Lemberg.
    
    7
    +#
    
    8
    +# This file is part of the FreeType project, and may only be used, modified,
    
    9
    +# and distributed under the terms of the FreeType project license,
    
    10
    +# LICENSE.TXT.  By continuing to use, modify, or distribute this file you
    
    11
    +# indicate that you have read the license and understand and accept it
    
    12
    +# fully.
    
    13
    +
    
    14
    +graph_c_args = []
    
    15
    +graph_dependencies = []
    
    16
    +graph_sources = files([
    
    17
    +  'gblany.h',
    
    18
    +  'gblblit.h',
    
    19
    +  'gblblit.c',
    
    20
    +  'gblender.c',
    
    21
    +  'gblender.h',
    
    22
    +  'graph.h',
    
    23
    +  'grblit.c',
    
    24
    +  'grblit.h',
    
    25
    +  'grconfig.h',
    
    26
    +  'grdevice.c',
    
    27
    +  'grdevice.h',
    
    28
    +  'grevents.h',
    
    29
    +  'grfill.c',
    
    30
    +  'grfont.c',
    
    31
    +  'grfont.h',
    
    32
    +  'grinit.c',
    
    33
    +  'grobjs.c',
    
    34
    +  'grswizzle.c',
    
    35
    +  'grswizzle.h',
    
    36
    +  'grtypes.h',
    
    37
    +])
    
    38
    +
    
    39
    +# The batch device is always compiled in.
    
    40
    +graph_sources += files([
    
    41
    +  'batch/grbatch.c',
    
    42
    +  'batch/grbatch.h',
    
    43
    +])
    
    44
    +graph_c_args += ['-DDEVICE_BATCH']
    
    45
    +
    
    46
    +# The Win32 device is available on Windows.
    
    47
    +if host_machine.system() == 'windows'
    
    48
    +  graph_sources += files([
    
    49
    +    'win32/grwin32.c',
    
    50
    +    'win32/grwin32.h',
    
    51
    +  ])
    
    52
    +  graph_c_args += ['-DDEVICE_WIN32']
    
    53
    +  graph_dependencies += [meson.get_compiler('c').find_library('gdiplus')]
    
    54
    +
    
    55
    +elif host_machine.system() == 'darwin'
    
    56
    +  graph_sources += files([
    
    57
    +    'mac/grmac.c',
    
    58
    +    'mac/grmac.h',
    
    59
    +  ])
    
    60
    +  graph_c_args += ['-DDEVICE_MAC']
    
    61
    +endif
    
    62
    +
    
    63
    +x11_dep = dependency('x11',
    
    64
    +  required: false)
    
    65
    +if x11_dep.found()
    
    66
    +  graph_sources += files([
    
    67
    +    'x11/grx11.c',
    
    68
    +    'x11/grx11.h',
    
    69
    +  ])
    
    70
    +  graph_c_args += ['-DDEVICE_X11']
    
    71
    +  graph_dependencies += [x11_dep]
    
    72
    +endif
    
    73
    +
    
    74
    +graph_include_dir = include_directories('.')
    
    75
    +
    
    76
    +graph_lib = static_library('graph',
    
    77
    +  graph_sources,
    
    78
    +  include_directories: graph_include_dir,
    
    79
    +  c_args: graph_c_args,
    
    80
    +  dependencies: graph_dependencies,
    
    81
    +)
    
    82
    +
    
    83
    +# EOF

  • meson.build
    1
    +#
    
    2
    +# Meson project file for FreeType 2 test programs
    
    3
    +#
    
    4
    +
    
    5
    +# Copyright (C) 2021 by
    
    6
    +# David Turner, Robert Wilhelm, and Werner Lemberg.
    
    7
    +#
    
    8
    +# This file is part of the FreeType project, and may only be used, modified,
    
    9
    +# and distributed under the terms of the FreeType project license,
    
    10
    +# LICENSE.TXT.  By continuing to use, modify, or distribute this file you
    
    11
    +# indicate that you have read the license and understand and accept it
    
    12
    +# fully.
    
    13
    +
    
    14
    +
    
    15
    +project('freetype-demos', 'c', 'cpp',
    
    16
    +  version: run_command(
    
    17
    +    'subprojects/freetype2/builds/meson/extract_freetype_version.py',
    
    18
    +    'subprojects/freetype2/include/freetype/freetype.h').stdout().strip(),
    
    19
    +)
    
    20
    +
    
    21
    +
    
    22
    +# Access to the FreeType 2 source tree is required, since some of the demo
    
    23
    +# programs rely on internal headers (e.g., `ttdebug`).  See `README.meson`
    
    24
    +# for more information.
    
    25
    +libfreetype2 = subproject('freetype2',
    
    26
    +  default_options: 'default_library=static')
    
    27
    +libfreetype2_dep = libfreetype2.get_variable('freetype_dep')
    
    28
    +
    
    29
    +libpng_dep = dependency('libpng',
    
    30
    +  required: true)
    
    31
    +
    
    32
    +cc = meson.get_compiler('c')
    
    33
    +
    
    34
    +math_dep = cc.find_library('m',
    
    35
    +  required: false)
    
    36
    +
    
    37
    +subdir('graph')
    
    38
    +
    
    39
    +common_files = files([
    
    40
    +  'src/common.c',
    
    41
    +  'src/common.h',
    
    42
    +  'src/strbuf.c',
    
    43
    +  'src/strbuf.h',
    
    44
    +])
    
    45
    +
    
    46
    +# Use `mlgetopt.h` on non-Unix platforms.
    
    47
    +if host_machine.system() == 'windows'
    
    48
    +  common_files += files([
    
    49
    +    'src/mlgetopt.h',
    
    50
    +    'src/mlgetopt.c',
    
    51
    +  ])
    
    52
    +endif
    
    53
    +
    
    54
    +common_lib = static_library('common',
    
    55
    +  common_files)
    
    56
    +
    
    57
    +output_lib = static_library('output',
    
    58
    +  [
    
    59
    +    'src/output.c',
    
    60
    +    'src/output.h',
    
    61
    +  ],
    
    62
    +  dependencies: libfreetype2_dep
    
    63
    +)
    
    64
    +
    
    65
    +ftcommon_lib = static_library('ftcommon',
    
    66
    +  [
    
    67
    +    'src/ftcommon.c',
    
    68
    +    'src/ftcommon.h',
    
    69
    +    'src/ftpngout.c',
    
    70
    +  ],
    
    71
    +  dependencies: [libpng_dep, libfreetype2_dep],
    
    72
    +  include_directories: graph_include_dir,
    
    73
    +  link_with: [common_lib, graph_lib],
    
    74
    +)
    
    75
    +
    
    76
    +executable('fttimer',
    
    77
    +  'src/fttimer.c',
    
    78
    +  dependencies: libfreetype2_dep,
    
    79
    +  install: false)
    
    80
    +
    
    81
    +executable('ftchkwd',
    
    82
    +  'src/ftchkwd.c',
    
    83
    +  dependencies: libfreetype2_dep,
    
    84
    +  install: false)
    
    85
    +
    
    86
    +executable('ftmemchk',
    
    87
    +  'src/ftmemchk.c',
    
    88
    +  dependencies: libfreetype2_dep,
    
    89
    +  install: false)
    
    90
    +
    
    91
    +executable('ftpatchk',
    
    92
    +  'src/ftpatchk.c',
    
    93
    +  dependencies: libfreetype2_dep,
    
    94
    +  install: false)
    
    95
    +
    
    96
    +executable('ftbench',
    
    97
    +  'src/ftbench.c',
    
    98
    +  dependencies: libfreetype2_dep,
    
    99
    +  link_with: common_lib,
    
    100
    +  install: true)
    
    101
    +
    
    102
    +executable('ftdump',
    
    103
    +  'src/ftdump.c',
    
    104
    +  dependencies: libfreetype2_dep,
    
    105
    +  link_with: [common_lib, output_lib],
    
    106
    +  install: true)
    
    107
    +
    
    108
    +executable('ftlint',
    
    109
    +  'src/ftlint.c',
    
    110
    +  dependencies: libfreetype2_dep,
    
    111
    +  link_with: common_lib,
    
    112
    +  install: true)
    
    113
    +
    
    114
    +executable('ftdiff',
    
    115
    +  'src/ftdiff.c',
    
    116
    +  dependencies: libfreetype2_dep,
    
    117
    +  include_directories: graph_include_dir,
    
    118
    +  link_with: ftcommon_lib,
    
    119
    +  install: true)
    
    120
    +
    
    121
    +executable('ftgamma',
    
    122
    +  'src/ftgamma.c',
    
    123
    +  dependencies: [libfreetype2_dep, math_dep],
    
    124
    +  include_directories: graph_include_dir,
    
    125
    +  link_with: ftcommon_lib,
    
    126
    +  install: true)
    
    127
    +
    
    128
    +executable('ftgrid',
    
    129
    +  'src/ftgrid.c',
    
    130
    +  dependencies: libfreetype2_dep,
    
    131
    +  include_directories: graph_include_dir,
    
    132
    +  link_with: [ftcommon_lib, output_lib],
    
    133
    +  install: true)
    
    134
    +
    
    135
    +executable('ftmulti',
    
    136
    +  'src/ftmulti.c',
    
    137
    +  dependencies: libfreetype2_dep,
    
    138
    +  include_directories: graph_include_dir,
    
    139
    +  link_with: ftcommon_lib,
    
    140
    +  install: true)
    
    141
    +
    
    142
    +executable('ftsdf',
    
    143
    +  'src/ftsdf.c',
    
    144
    +  dependencies: libfreetype2_dep,
    
    145
    +  include_directories: graph_include_dir,
    
    146
    +  link_with: ftcommon_lib,
    
    147
    +  install: true)
    
    148
    +
    
    149
    +executable('ftstring',
    
    150
    +  'src/ftstring.c',
    
    151
    +  dependencies: [libfreetype2_dep, math_dep],
    
    152
    +  include_directories: graph_include_dir,
    
    153
    +  link_with: ftcommon_lib,
    
    154
    +  install: true)
    
    155
    +
    
    156
    +executable('ftview',
    
    157
    +  'src/ftview.c',
    
    158
    +  dependencies: libfreetype2_dep,
    
    159
    +  include_directories: graph_include_dir,
    
    160
    +  link_with: ftcommon_lib,
    
    161
    +  install: true)
    
    162
    +
    
    163
    +executable('ftvalid',
    
    164
    +  'src/ftvalid.c',
    
    165
    +  dependencies: libfreetype2_dep,
    
    166
    +  link_with: common_lib,
    
    167
    +  install: true)
    
    168
    +
    
    169
    +install_man([
    
    170
    +  'man/ftbench.1',
    
    171
    +  'man/ftdiff.1',
    
    172
    +  'man/ftdump.1',
    
    173
    +  'man/ftgamma.1',
    
    174
    +  'man/ftgrid.1',
    
    175
    +  'man/ftlint.1',
    
    176
    +  'man/ftmulti.1',
    
    177
    +  'man/ftstring.1',
    
    178
    +  'man/ftvalid.1',
    
    179
    +  'man/ftview.1',
    
    180
    +  'man/ttdebug.1',
    
    181
    +])
    
    182
    +
    
    183
    +subdir('src/ftinspect')
    
    184
    +
    
    185
    +# EOF

  • src/ftinspect/meson.build
    1
    +#
    
    2
    +# Meson project file for the ftinspect program.
    
    3
    +#
    
    4
    +
    
    5
    +# Copyright (C) 2021 by
    
    6
    +# David Turner, Robert Wilhelm, and Werner Lemberg.
    
    7
    +#
    
    8
    +# This file is part of the FreeType project, and may only be used, modified,
    
    9
    +# and distributed under the terms of the FreeType project license,
    
    10
    +# LICENSE.TXT.  By continuing to use, modify, or distribute this file you
    
    11
    +# indicate that you have read the license and understand and accept it
    
    12
    +# fully.
    
    13
    +
    
    14
    +qt5 = import('qt5')
    
    15
    +qt5_dep = dependency('qt5',
    
    16
    +  required: false,
    
    17
    +  modules: ['Core', 'Gui', 'Widgets'])
    
    18
    +
    
    19
    +# Don't compile `ftinspect` if Qt5 is not found.  This can happen
    
    20
    +# when cross-compiling to a different system.
    
    21
    +if qt5_dep.found()
    
    22
    +  sources = files([
    
    23
    +    'engine/engine.cpp',
    
    24
    +    'rendering/glyphbitmap.cpp',
    
    25
    +    'rendering/glyphoutline.cpp',
    
    26
    +    'rendering/glyphpointnumbers.cpp',
    
    27
    +    'rendering/glyphpoints.cpp',
    
    28
    +    'rendering/grid.cpp',
    
    29
    +    'widgets/qcomboboxx.cpp',
    
    30
    +    'widgets/qgraphicsviewx.cpp',
    
    31
    +    'widgets/qpushbuttonx.cpp',
    
    32
    +    'widgets/qspinboxx.cpp',
    
    33
    +    'ftinspect.cpp',
    
    34
    +    'maingui.cpp',
    
    35
    +  ])
    
    36
    +
    
    37
    +  moc_files = qt5.preprocess(
    
    38
    +    moc_headers: [
    
    39
    +      'widgets/qcomboboxx.hpp',
    
    40
    +      'widgets/qgraphicsviewx.hpp',
    
    41
    +      'widgets/qpushbuttonx.hpp',
    
    42
    +      'widgets/qspinboxx.hpp',
    
    43
    +      'maingui.hpp',
    
    44
    +    ],
    
    45
    +    dependencies: qt5_dep)
    
    46
    +
    
    47
    +  executable('ftinspect',
    
    48
    +    sources,
    
    49
    +    moc_files,
    
    50
    +    dependencies: [qt5_dep, libfreetype2_dep],
    
    51
    +    install: true)
    
    52
    +endif
    
    53
    +
    
    54
    +# EOF

  • subprojects/freetype2.wrap
    1
    +[wrap-git]
    
    2
    +url = "">
    
    3
    +revision = head
    
    4
    +
    
    5
    +[provide]
    
    6
    +freetype2 = freetype_dep

  • subprojects/libpng.wrap
    1
    +[wrap-file]
    
    2
    +directory = libpng-1.6.37
    
    3
    +source_url = https://github.com/glennrp/libpng/archive/v1.6.37.tar.gz
    
    4
    +source_filename = libpng-1.6.37.tar.gz
    
    5
    +source_hash = ca74a0dace179a8422187671aee97dd3892b53e168627145271cad5b5ac81307
    
    6
    +patch_url = https://wrapdb.mesonbuild.com/v1/projects/libpng/1.6.37/3/get_zip
    
    7
    +patch_filename = libpng-1.6.37-3-wrap.zip
    
    8
    +patch_hash = 6c9f32fd9150b3a96ab89be52af664e32207e10aa9f5fb9aa015989ee2dd7100
    
    9
    +
    
    10
    +[provide]
    
    11
    +libpng = libpng_dep

  • subprojects/zlib.wrap
    1
    +[wrap-file]
    
    2
    +directory = zlib-1.2.11
    
    3
    +source_url = http://zlib.net/fossils/zlib-1.2.11.tar.gz
    
    4
    +source_filename = zlib-1.2.11.tar.gz
    
    5
    +source_hash = c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1
    
    6
    +patch_url = https://wrapdb.mesonbuild.com/v1/projects/zlib/1.2.11/5/get_zip
    
    7
    +patch_filename = zlib-1.2.11-5-wrap.zip
    
    8
    +patch_hash = 728c8e24acbc2e6682fbd950fec39e2fc77528af361adb87259f8a8511434004
    
    9
    +
    
    10
    +[provide]
    
    11
    +zlib = zlib_dep
    
    12
    +


  • reply via email to

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