From 0bbd3360eeb00fbbb9544524a330e405450f44e5 Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Thu, 19 Jan 2023 20:11:35 +0200 Subject: [PATCH 1/4] [doc] Try to fix generating hb-features docs Move it to a separate section, since hb-common says include hb.h, while we want to include hb-features.h here. This still does not fix generating documentation of undefined macros (e.g. HB_HAS_GDI since we build docs on Linux). --- docs/harfbuzz-docs.xml | 1 + docs/harfbuzz-sections.txt | 24 ++++++++++++++---------- src/hb-features.h.in | 8 ++++++++ 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/docs/harfbuzz-docs.xml b/docs/harfbuzz-docs.xml index 738356b8c..cc6c989a1 100644 --- a/docs/harfbuzz-docs.xml +++ b/docs/harfbuzz-docs.xml @@ -56,6 +56,7 @@ + diff --git a/docs/harfbuzz-sections.txt b/docs/harfbuzz-sections.txt index 930cf5479..254e809b7 100644 --- a/docs/harfbuzz-sections.txt +++ b/docs/harfbuzz-sections.txt @@ -166,16 +166,6 @@ HB_TAG_MAX_SIGNED HB_LANGUAGE_INVALID HB_FEATURE_GLOBAL_END HB_FEATURE_GLOBAL_START -HB_HAS_CAIRO -HB_HAS_CORETEXT -HB_HAS_DIRECTWRITE -HB_HAS_FREETYPE -HB_HAS_GDI -HB_HAS_GLIB -HB_HAS_GOBJECT -HB_HAS_GRAPHITE -HB_HAS_ICU -HB_HAS_UNISCRIBE HB_BEGIN_DECLS HB_END_DECLS @@ -194,6 +184,20 @@ HB_DEPRECATED HB_DEPRECATED_FOR +
+hb-features +HB_HAS_CAIRO +HB_HAS_CORETEXT +HB_HAS_DIRECTWRITE +HB_HAS_FREETYPE +HB_HAS_GDI +HB_HAS_GLIB +HB_HAS_GOBJECT +HB_HAS_GRAPHITE +HB_HAS_ICU +HB_HAS_UNISCRIBE +
+
hb-draw hb_draw_funcs_create diff --git a/src/hb-features.h.in b/src/hb-features.h.in index da67f772f..d85749ca9 100644 --- a/src/hb-features.h.in +++ b/src/hb-features.h.in @@ -27,6 +27,14 @@ HB_BEGIN_DECLS +/** + * SECTION: hb-features + * @title: hb-features + * @short_description: Feature detection + * @include: hb-features.h + * + * Macros for detecting optional HarfBuzz features at build time. + **/ /** * HB_HAS_CAIRO: From 12f2ecbddb65328a6e3312921ccb6946a76a665e Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Mon, 23 Jan 2023 23:41:11 +0200 Subject: [PATCH 2/4] [doc] Generate hb-supported-features.h See inline comment. --- docs/meson.build | 1 + src/meson.build | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/docs/meson.build b/docs/meson.build index 1fd75cf56..e0b0e36ec 100644 --- a/docs/meson.build +++ b/docs/meson.build @@ -36,6 +36,7 @@ html_images = [ ] ignore_headers = [ + 'hb-features.h', 'hb-gobject.h', 'hb-gobject-enums.h', 'hb-gobject-enums-tmp.h', diff --git a/src/meson.build b/src/meson.build index 6b87601c8..ee4e88890 100644 --- a/src/meson.build +++ b/src/meson.build @@ -423,6 +423,7 @@ harfbuzz_deps = [thread_dep, m_dep] + harfbuzz_extra_deps libharfbuzz_link_language = 'c' hb_features = configuration_data() +hb_supported_features = configuration_data() if conf.get('HAVE_FREETYPE', 0) == 1 hb_sources += hb_ft_sources @@ -430,6 +431,7 @@ if conf.get('HAVE_FREETYPE', 0) == 1 harfbuzz_deps += [freetype_dep] hb_features.set('HB_HAS_FREETYPE', 1) endif +hb_supported_features.set('HB_HAS_FREETYPE', 1) if conf.get('HAVE_GLIB', 0) == 1 hb_sources += hb_glib_sources @@ -437,10 +439,12 @@ if conf.get('HAVE_GLIB', 0) == 1 harfbuzz_deps += [glib_dep] hb_features.set('HB_HAS_GLIB', 1) endif +hb_supported_features.set('HB_HAS_GLIB', 1) if conf.get('HAVE_GOBJECT', 0) == 1 hb_features.set('HB_HAS_GOBJECT', 1) endif +hb_supported_features.set('HB_HAS_GOBJECT', 1) # We set those here to not include the sources below that are of no use to # GObject Introspection @@ -453,6 +457,7 @@ if conf.get('HAVE_GDI', 0) == 1 harfbuzz_deps += gdi_uniscribe_deps hb_features.set('HB_HAS_GDI', 1) endif +hb_supported_features.set('HB_HAS_GDI', 1) if conf.get('HAVE_GRAPHITE2', 0) == 1 hb_sources += hb_graphite2_sources @@ -460,12 +465,14 @@ if conf.get('HAVE_GRAPHITE2', 0) == 1 harfbuzz_deps += [graphite2_dep, graphite_dep] hb_features.set('HB_HAS_GRAPHITE', 1) endif +hb_supported_features.set('HB_HAS_GRAPHITE', 1) if conf.get('HAVE_UNISCRIBE', 0) == 1 hb_sources += hb_uniscribe_sources hb_headers += hb_uniscribe_headers hb_features.set('HB_HAS_UNISCRIBE', 1) endif +hb_supported_features.set('HB_HAS_UNISCRIBE', 1) if conf.get('HAVE_DIRECTWRITE', 0) == 1 hb_sources += hb_directwrite_sources @@ -474,6 +481,7 @@ if conf.get('HAVE_DIRECTWRITE', 0) == 1 libharfbuzz_link_language = 'cpp' hb_features.set('HB_HAS_DIRECTWRITE', 1) endif +hb_supported_features.set('HB_HAS_DIRECTWRITE', 1) if conf.get('HAVE_CORETEXT', 0) == 1 hb_sources += hb_coretext_sources @@ -481,6 +489,7 @@ if conf.get('HAVE_CORETEXT', 0) == 1 harfbuzz_deps += coretext_deps hb_features.set('HB_HAS_CORETEXT', 1) endif +hb_supported_features.set('HB_HAS_CORETEXT', 1) have_icu = conf.get('HAVE_ICU', 0) == 1 have_icu_builtin = conf.get('HAVE_ICU_BUILTIN', 0) == 1 @@ -491,10 +500,12 @@ if have_icu and have_icu_builtin harfbuzz_deps += [icu_dep] hb_features.set('HB_HAS_ICU', 1) endif +hb_supported_features.set('HB_HAS_ICU', 1) if conf.get('HAVE_CAIRO', 0) == 1 hb_features.set('HB_HAS_CAIRO', 1) endif +hb_supported_features.set('HB_HAS_CAIRO', 1) hb_features_h = configure_file(input: 'hb-features.h.in', output: 'hb-features.h', @@ -502,6 +513,14 @@ hb_features_h = configure_file(input: 'hb-features.h.in', install: true, install_dir: get_option('includedir') / meson.project_name()) +# This file is generated to convince gtk-doc to generate documentation for all +# HB_HAS_* macros, whether they are enabled for the current build or not. +# This file should not be installed. +hb_supported_features_h = configure_file(input: 'hb-features.h.in', + output: 'hb-supported-features.h', + configuration: hb_supported_features, + install: false) + # Base and default-included sources and headers # harfbuzz From 2486d6d22fcbdeb2ec89bb33265665e60dc8461a Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Mon, 23 Jan 2023 23:57:16 +0200 Subject: [PATCH 3/4] [meson] Reduce repetitions --- src/meson.build | 46 +++++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/src/meson.build b/src/meson.build index ee4e88890..20bbb57ad 100644 --- a/src/meson.build +++ b/src/meson.build @@ -423,28 +423,22 @@ harfbuzz_deps = [thread_dep, m_dep] + harfbuzz_extra_deps libharfbuzz_link_language = 'c' hb_features = configuration_data() -hb_supported_features = configuration_data() if conf.get('HAVE_FREETYPE', 0) == 1 hb_sources += hb_ft_sources hb_headers += hb_ft_headers harfbuzz_deps += [freetype_dep] - hb_features.set('HB_HAS_FREETYPE', 1) endif -hb_supported_features.set('HB_HAS_FREETYPE', 1) +hb_features.set('HB_HAS_FREETYPE', conf.get('HAVE_FREETYPE', 0)) if conf.get('HAVE_GLIB', 0) == 1 hb_sources += hb_glib_sources hb_headers += hb_glib_headers harfbuzz_deps += [glib_dep] - hb_features.set('HB_HAS_GLIB', 1) endif -hb_supported_features.set('HB_HAS_GLIB', 1) +hb_features.set('HB_HAS_GLIB', conf.get('HAVE_GLIB', 0)) -if conf.get('HAVE_GOBJECT', 0) == 1 - hb_features.set('HB_HAS_GOBJECT', 1) -endif -hb_supported_features.set('HB_HAS_GOBJECT', 1) +hb_features.set('HB_HAS_GOBJECT', conf.get('HAVE_GOBJECT', 0)) # We set those here to not include the sources below that are of no use to # GObject Introspection @@ -455,41 +449,36 @@ if conf.get('HAVE_GDI', 0) == 1 hb_sources += hb_gdi_sources hb_headers += hb_gdi_headers harfbuzz_deps += gdi_uniscribe_deps - hb_features.set('HB_HAS_GDI', 1) endif -hb_supported_features.set('HB_HAS_GDI', 1) +hb_features.set('HB_HAS_GDI', conf.get('HAVE_GDI', 0)) if conf.get('HAVE_GRAPHITE2', 0) == 1 hb_sources += hb_graphite2_sources hb_headers += hb_graphite2_headers harfbuzz_deps += [graphite2_dep, graphite_dep] - hb_features.set('HB_HAS_GRAPHITE', 1) endif -hb_supported_features.set('HB_HAS_GRAPHITE', 1) +hb_features.set('HB_HAS_GRAPHITE', conf.get('HAVE_GRAPHITE', 0)) if conf.get('HAVE_UNISCRIBE', 0) == 1 hb_sources += hb_uniscribe_sources hb_headers += hb_uniscribe_headers - hb_features.set('HB_HAS_UNISCRIBE', 1) endif -hb_supported_features.set('HB_HAS_UNISCRIBE', 1) +hb_features.set('HB_HAS_UNISCRIBE', conf.get('HAVE_UNISCRIBE', 0)) if conf.get('HAVE_DIRECTWRITE', 0) == 1 hb_sources += hb_directwrite_sources hb_headers += hb_directwrite_headers # hb-directwrite needs a C++ linker libharfbuzz_link_language = 'cpp' - hb_features.set('HB_HAS_DIRECTWRITE', 1) endif -hb_supported_features.set('HB_HAS_DIRECTWRITE', 1) +hb_features.set('HB_HAS_DIRECTWRITE', conf.get('HAVE_DIRECTWRITE', 0)) if conf.get('HAVE_CORETEXT', 0) == 1 hb_sources += hb_coretext_sources hb_headers += hb_coretext_headers harfbuzz_deps += coretext_deps - hb_features.set('HB_HAS_CORETEXT', 1) endif -hb_supported_features.set('HB_HAS_CORETEXT', 1) +hb_features.set('HB_HAS_CORETEXT', conf.get('HAVE_CORETEXT', 0)) have_icu = conf.get('HAVE_ICU', 0) == 1 have_icu_builtin = conf.get('HAVE_ICU_BUILTIN', 0) == 1 @@ -498,15 +487,22 @@ if have_icu and have_icu_builtin hb_sources += hb_icu_sources hb_headers += hb_icu_headers harfbuzz_deps += [icu_dep] - hb_features.set('HB_HAS_ICU', 1) endif -hb_supported_features.set('HB_HAS_ICU', 1) +hb_features.set('HB_HAS_ICU', conf.get('HAVE_ICU', 0)) -if conf.get('HAVE_CAIRO', 0) == 1 - hb_features.set('HB_HAS_CAIRO', 1) -endif -hb_supported_features.set('HB_HAS_CAIRO', 1) +hb_features.set('HB_HAS_CAIRO', conf.get('HAVE_CAIRO', 0)) +hb_supported_features = configuration_data() +foreach key : hb_features.keys() + # Set any feature to 1 here, see below + hb_supported_features.set(key, 1) + if hb_features.get(key) == 0 + # Set to false so meson undefs them, instead of defining to 0. + hb_features.set(key, false) + endif +endforeach + +# The enabled features. This file is installed. hb_features_h = configure_file(input: 'hb-features.h.in', output: 'hb-features.h', configuration: hb_features, From 699485b349030b1b8fdbb742758718b88bee1212 Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Tue, 24 Jan 2023 00:07:45 +0200 Subject: [PATCH 4/4] [meson] Further simplify generating hb-features.h --- src/meson.build | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/src/meson.build b/src/meson.build index 20bbb57ad..a32b21e73 100644 --- a/src/meson.build +++ b/src/meson.build @@ -422,23 +422,17 @@ harfbuzz_deps = [thread_dep, m_dep] + harfbuzz_extra_deps libharfbuzz_link_language = 'c' -hb_features = configuration_data() - if conf.get('HAVE_FREETYPE', 0) == 1 hb_sources += hb_ft_sources hb_headers += hb_ft_headers harfbuzz_deps += [freetype_dep] endif -hb_features.set('HB_HAS_FREETYPE', conf.get('HAVE_FREETYPE', 0)) if conf.get('HAVE_GLIB', 0) == 1 hb_sources += hb_glib_sources hb_headers += hb_glib_headers harfbuzz_deps += [glib_dep] endif -hb_features.set('HB_HAS_GLIB', conf.get('HAVE_GLIB', 0)) - -hb_features.set('HB_HAS_GOBJECT', conf.get('HAVE_GOBJECT', 0)) # We set those here to not include the sources below that are of no use to # GObject Introspection @@ -450,20 +444,17 @@ if conf.get('HAVE_GDI', 0) == 1 hb_headers += hb_gdi_headers harfbuzz_deps += gdi_uniscribe_deps endif -hb_features.set('HB_HAS_GDI', conf.get('HAVE_GDI', 0)) if conf.get('HAVE_GRAPHITE2', 0) == 1 hb_sources += hb_graphite2_sources hb_headers += hb_graphite2_headers harfbuzz_deps += [graphite2_dep, graphite_dep] endif -hb_features.set('HB_HAS_GRAPHITE', conf.get('HAVE_GRAPHITE', 0)) if conf.get('HAVE_UNISCRIBE', 0) == 1 hb_sources += hb_uniscribe_sources hb_headers += hb_uniscribe_headers endif -hb_features.set('HB_HAS_UNISCRIBE', conf.get('HAVE_UNISCRIBE', 0)) if conf.get('HAVE_DIRECTWRITE', 0) == 1 hb_sources += hb_directwrite_sources @@ -471,41 +462,46 @@ if conf.get('HAVE_DIRECTWRITE', 0) == 1 # hb-directwrite needs a C++ linker libharfbuzz_link_language = 'cpp' endif -hb_features.set('HB_HAS_DIRECTWRITE', conf.get('HAVE_DIRECTWRITE', 0)) if conf.get('HAVE_CORETEXT', 0) == 1 hb_sources += hb_coretext_sources hb_headers += hb_coretext_headers harfbuzz_deps += coretext_deps endif -hb_features.set('HB_HAS_CORETEXT', conf.get('HAVE_CORETEXT', 0)) have_icu = conf.get('HAVE_ICU', 0) == 1 have_icu_builtin = conf.get('HAVE_ICU_BUILTIN', 0) == 1 - if have_icu and have_icu_builtin hb_sources += hb_icu_sources hb_headers += hb_icu_headers harfbuzz_deps += [icu_dep] endif -hb_features.set('HB_HAS_ICU', conf.get('HAVE_ICU', 0)) -hb_features.set('HB_HAS_CAIRO', conf.get('HAVE_CAIRO', 0)) +features = [ + 'CAIRO', + 'CORETEXT', + 'DIRECTWRITE', + 'FREETYPE', + 'GDI', + 'GLIB', + 'GOBJECT', + 'GRAPHITE', + 'ICU', + 'UNISCRIBE', +] +hb_enabled_features = configuration_data() hb_supported_features = configuration_data() -foreach key : hb_features.keys() - # Set any feature to 1 here, see below +foreach feature : features + key = 'HB_HAS_@0@'.format(feature) + hb_enabled_features.set(key, conf.get('HAVE_@0@'.format(feature), false)) hb_supported_features.set(key, 1) - if hb_features.get(key) == 0 - # Set to false so meson undefs them, instead of defining to 0. - hb_features.set(key, false) - endif endforeach # The enabled features. This file is installed. hb_features_h = configure_file(input: 'hb-features.h.in', output: 'hb-features.h', - configuration: hb_features, + configuration: hb_enabled_features, install: true, install_dir: get_option('includedir') / meson.project_name())