[ghex/gtkdocize: 1/2] docs: Initial setup for gi-docgen




commit 5291d827095b26b89ffe315431c1fb9c1c3c6c06
Author: Logan Rathbone <poprocks gmail com>
Date:   Sat Dec 25 18:55:33 2021 -0500

    docs: Initial setup for gi-docgen

 meson.build       | 16 +++++++++++++--
 meson_options.txt |  2 ++
 src/meson.build   | 60 ++++++++++++++++++++++++++++++++++++++-----------------
 3 files changed, 58 insertions(+), 20 deletions(-)
---
diff --git a/meson.build b/meson.build
index 8a35c2f..aee3a81 100644
--- a/meson.build
+++ b/meson.build
@@ -5,6 +5,8 @@ project(
   license: 'GPL2'
 )
 
+# Options
+
 if get_option('development')
   app_id = 'org.gnome.GHex.Devel'
   resource_base_path = '/org/gnome/GHex/Devel'
@@ -13,10 +15,16 @@ else
   resource_base_path = '/org/gnome/GHex'
 endif
 
+gir = find_program('g-ir-scanner', required : get_option('introspection'))
+generate_gir = gir.found() and (not meson.is_cross_build() or get_option('introspection').enabled())
+build_gtk_doc = get_option('gtk_doc')
+
+# Directories, variables, etc.
+
 version_arr = meson.project_version().split('.')
 ghex_version_major = version_arr[0].to_int()
 
-libghex_version_major = version_arr[0].to_int()
+libgtkhex_version_major = version_arr[0].to_int()
 
 ghex_prefix = get_option('prefix')
 ghex_libdir = join_paths(ghex_prefix, get_option('libdir'))
@@ -28,6 +36,8 @@ ghex_applicationsdir = join_paths(ghex_datadir, 'applications')
 ghex_schemasdir = join_paths(ghex_datadir, 'glib-2.0/schemas')
 ghex_appdatadir = join_paths(ghex_datadir, 'metainfo')
 ghex_iconsdir = join_paths(ghex_datadir, 'icons')
+ghex_girdir = join_paths(ghex_datadir, 'gir-1.0')
+ghex_typelibdir = join_paths(ghex_libdir, 'girepository-1.0')
 
 ghex_root_dir = include_directories('.')
 ghex_po_dir = join_paths(meson.source_root(), 'po')
@@ -73,7 +83,7 @@ if buffer_backend == 'mmap'
   config_h.set('BACKEND_MMAP', true)
 endif
 
-config_h.set_quoted('LIBGTKHEX_RELEASE_STRING', 'gtkhex-@0@.0'.format(libghex_version_major))
+config_h.set_quoted('LIBGTKHEX_RELEASE_STRING', 'gtkhex-@0@.0'.format(libgtkhex_version_major))
 
 config_h.set('DEBUG', get_option('debug'))
 
@@ -121,6 +131,7 @@ compile_schemas_prg = find_program('glib-compile-schemas', required : false)
 
 subdir('src')
 subdir('data')
+subdir('docs')
 subdir('icons')
 subdir('po')
 subdir('help')
@@ -136,5 +147,6 @@ summary({'prefix': ghex_prefix,
         }, section: 'Directories')
 
 summary({'Development build': get_option('development'),
+         'Documentation': build_gtk_doc,
          'Buffer backend': buffer_backend,
         }, section: 'Configuration')
diff --git a/meson_options.txt b/meson_options.txt
index 8bddea0..3e235a4 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,2 +1,4 @@
 option('development', type: 'boolean', value: false, description: 'If this is a development build')
 option('buffer-backend', type : 'combo', choices : ['mmap', 'malloc'], value : 'mmap')
+option('introspection', type: 'feature', value: 'auto', description: 'Generate gir data (requires 
gobject-introspection)')
+option('gtk_doc', type: 'boolean', value: false, description: 'Build reference manual (requires gtk-doc)')
diff --git a/src/meson.build b/src/meson.build
index 1d4b737..74d28d8 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -1,4 +1,4 @@
-libghex_sources = [
+libgtkhex_sources = [
   'gtkhex.c',
   'hex-buffer-iface.c',              # TEST
   'hex-buffer-mmap.c',        # TEST
@@ -8,7 +8,7 @@ libghex_sources = [
   'hex-document.c'
 ]
 
-libghex_headers = [
+libgtkhex_headers = [
   'hex-document.h',
   'hex-buffer-iface.h',
   'hex-buffer-malloc.h',
@@ -17,40 +17,40 @@ libghex_headers = [
   'gtkhex-paste-data.h'
 ]
 
-libghex_deps = [
+libgtkhex_deps = [
   gtk_dep,
 ]
 
-libghex_c_args = [
+libgtkhex_c_args = [
   '-DG_LOG_DOMAIN="libgtkhex-4"'
 ]
 
-libghex_link_args = cc.get_supported_link_arguments([
+libgtkhex_link_args = cc.get_supported_link_arguments([
   '-Wl,--no-undefined'
 ])
 
 install_headers(
-  libghex_headers,
-  subdir: 'gtkhex-@0@'.format(libghex_version_major)
+  libgtkhex_headers,
+  subdir: 'gtkhex-@0@'.format(libgtkhex_version_major)
 )
 
-libghex = library(
-  'gtkhex-@0@'.format(libghex_version_major),
-  libghex_sources + libghex_headers,
+libgtkhex = library(
+  'gtkhex-@0@'.format(libgtkhex_version_major),
+  libgtkhex_sources + libgtkhex_headers,
   version: '0.0.0',
   darwin_versions: ['1', '1.0'],
   include_directories: ghex_root_dir,
-  dependencies: libghex_deps,
-  c_args: libghex_c_args,
-  link_args: libghex_link_args,
+  dependencies: libgtkhex_deps,
+  c_args: libgtkhex_c_args,
+  link_args: libgtkhex_link_args,
   install: true
 )
 
-libghex_dep = declare_dependency(
-  link_with: libghex,
+libgtkhex_dep = declare_dependency(
+  link_with: libgtkhex,
   include_directories: ghex_root_dir,
-  dependencies: libghex_deps,
-  sources: libghex_headers
+  dependencies: libgtkhex_deps,
+  sources: libgtkhex_headers
 )
 
 # for i in `ls *.{c,h}`; do echo "  '${i}',"; done
@@ -118,7 +118,31 @@ ghex = executable(
   meson.project_name(),
   ghex_sources + res,
   include_directories: ghex_root_dir,
-  dependencies: ghex_deps + [libghex_dep, ],
+  dependencies: ghex_deps + [libgtkhex_dep, ],
   c_args: ghex_c_args,
   install: true
 )
+
+
+
+if generate_gir
+  gtkhex_gir_sources = [
+    'gtkhex.c',
+    'gtkhex.h',
+  ]
+
+  gtkhex_gir = gnome.generate_gir(libgtkhex,
+                sources: gtkhex_gir_sources,
+              nsversion: libgtkhex_version_major.to_string(),
+              namespace: 'GtkHex',
+          symbol_prefix: 'gtk_hex',
+      identifier_prefix: 'GtkHex',
+              link_with: libgtkhex,
+           dependencies: libgtkhex_deps,
+               includes: [ 'Gtk-4.0' ],
+                install: true,
+        install_dir_gir: ghex_girdir,
+    install_dir_typelib: ghex_typelibdir,
+             extra_args: [ '--warn-all' ],
+  )
+endif


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