harfbuzz.cc hb-shape (#5474)

* [util] Respect HB_NO_FEATURES_H macro

For builds using harfbuzz.cc and no features file.

* Kill PACKAGE_NAME and PACKAGE_VERSION

Remnants of autotools.

* [BUILD.md] Update
This commit is contained in:
Behdad Esfahbod authored and GitHub committed 2025-08-17 17:12:22 -06:00
1 parent 68c7cfff43
commit 4a1d4fbf0d
4 files changed
+33 -9

No files matched your search

+30 -2
View File
@@ -1,3 +1,19 @@
# Building HarfBuzz
HarfBuzz primarily uses the _meson_ build system. A community-maintained
_CMake_ build system is also available. Finally, you can build HarfBuzz
without a build system by compiling the amalgamated source file.
## Installing dependencies
First, we need to install desired dependencies. None of these are strictly
required to build the library, but when they are present, you can build the
library with additional _integration_ features, such as _FreeType_ integration.
The command-line tools (`hb-view`, `hb-shape`, `hb-info`, `hb-subset`) require
_GLib_, while `hb-view` also requires _Cairo_. Most of the test suite requires
_GLib_ to run.
On Linux, install the development packages for FreeType, Cairo, and GLib. For
example, on Ubuntu / Debian, you would do:
@@ -15,6 +31,8 @@ On macOS:
brew install pkg-config ragel gtk-doc freetype glib cairo meson
## Building HarfBuzz with meson
Then use meson to build the project and run the tests, like:
meson build && ninja -Cbuild && meson test -Cbuild
@@ -27,6 +45,16 @@ or via the Visual Studio installer when building with MSVC, using meson.
Our CI configurations are also a good source of learning how to build HarfBuzz.
## Building without a build system
There is also amalgamated source provided with HarfBuzz which reduces whole process
of building HarfBuzz to `g++ src/harfbuzz.cc -fno-exceptions` but there is
no guarantee provided with buildability and reliability of features you get.
of building HarfBuzz to `c++ -c src/harfbuzz.cc` but there is no guarantee provided
with buildability and reliability of features you get. This can be useful when
embedding HarfBuzz in your project.
For example, the `hb-shape` tool can be built simply as:
$ c++ -O2 src/harfbuzz.cc util/hb-shape.cc -o hb-shape -I src -DHB_NO_FEATURES_H `pkg-config --cflags --libs glib-2.0`
See `CONFIG.md` for ideas on how to shrink the feature set of your custom built
HarfBuzz library.
-3
View File
@@ -801,9 +801,6 @@ endif ()
## Additional harfbuzz build artifacts
if (HB_BUILD_UTILS)
add_definitions("-DPACKAGE_NAME=\"HarfBuzz\"")
add_definitions("-DPACKAGE_VERSION=\"${HB_VERSION}\"")
if (HB_HAVE_CAIRO)
add_executable(hb-view
${PROJECT_SOURCE_DIR}/util/ansi-print.hh
-3
View File
@@ -375,9 +375,6 @@ if host_machine.system() != 'windows'
endif
endif
conf.set_quoted('PACKAGE_NAME', 'HarfBuzz')
conf.set_quoted('PACKAGE_VERSION', meson.project_version())
foreach check : check_headers
name = check[0]
+3 -1
View File
@@ -47,7 +47,9 @@
#endif
#ifndef HB_NO_FEATURES_H
#include <hb-features.h>
#endif
#include <hb.h>
#include <hb-ot.h>
@@ -233,7 +235,7 @@ show_version (const char *name G_GNUC_UNUSED,
gpointer data G_GNUC_UNUSED,
GError **error G_GNUC_UNUSED)
{
g_printf ("%s (%s) %s\n", g_get_prgname (), PACKAGE_NAME, PACKAGE_VERSION);
g_printf ("%s (HarfBuzz) %s\n", g_get_prgname (), HB_VERSION_STRING);
if (strcmp (HB_VERSION_STRING, hb_version_string ()))
g_printf ("Linked HarfBuzz library has a different version: %s\n", hb_version_string ());