From 11f26e5e2322acd92f0e5b7ed451d8bcde82b894 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Wed, 13 Dec 2023 20:55:59 -0500 Subject: [PATCH] feat: generate documentation with `meson` --- .github/workflows/linux.yml | 2 +- configure.py | 11 +++++++---- meson.build | 12 ++++++++++++ meson.options | 3 ++- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index c9951162..6005ef00 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -100,7 +100,7 @@ jobs: run: ls *.tar.gz | xargs -I{} tar xzvf {} - run: tree - name: configure - run: ./configure.py --hipo hipo --fmt fmt --examples + run: ./configure.py --hipo hipo --fmt fmt --examples --no-documentation - name: build run: ./install-iguana.sh - name: dump build log diff --git a/configure.py b/configure.py index 2cae1875..672766d2 100755 --- a/configure.py +++ b/configure.py @@ -3,8 +3,10 @@ from configparser import ConfigParser import argparse, os, sys, textwrap -SYSTEM_ASSUMPTION = 'assume system installation' -SEPARATOR = '-'*50 +# constants +SYSTEM_ASSUMPTION = 'assume system installation' +SEPARATOR = '-'*50 +PKGCONFIG_RELOCATABLE = True # parse user options class Formatter(argparse.ArgumentDefaultsHelpFormatter, argparse.RawDescriptionHelpFormatter): pass @@ -22,10 +24,10 @@ class Formatter(argparse.ArgumentDefaultsHelpFormatter, argparse.RawDescriptionH parser_build = parser.add_argument_group('build settings') parser_build.add_argument( '--prefix', default='iguana', type=str, help='iguana installation prefix') parser_build.add_argument( '--examples', default=False, action=argparse.BooleanOptionalAction, help='build examples or not') +parser_build.add_argument( '--documentation', default=False, action=argparse.BooleanOptionalAction, help='generate API documentation or not') parser_build = parser.add_argument_group('advanced settings') parser_build.add_argument( '--build', default='build-iguana', type=str, help='iguana buildsystem directory') parser_build.add_argument( '--ini', default='build-iguana.ini', type=str, help='name of the output config INI file') -parser_build.add_argument( '--relocatable', default=True, action=argparse.BooleanOptionalAction, help='make pkg-config `.pc` file relocatable or not') args = parser.parse_args() # get prefix absolute path @@ -60,8 +62,9 @@ def meson_string_array(arr): config.set('built-in options', '; installation settings') config.set('built-in options', 'prefix', f'\'{prefix}\'') config.set('built-in options', 'libdir', '\'lib\'') # make all systems use lib/ -config.set('built-in options', 'pkgconfig.relocatable', f'{args.relocatable}') +config.set('built-in options', 'pkgconfig.relocatable', f'{PKGCONFIG_RELOCATABLE}') config.set('built-in options', 'examples', f'{args.examples}') +config.set('built-in options', 'documentation', f'{args.documentation}') # write the INI file with open(args.ini, 'w') as fp: diff --git a/meson.build b/meson.build index 3869d831..15e110d2 100644 --- a/meson.build +++ b/meson.build @@ -35,3 +35,15 @@ pkg.generate( if(get_option('examples')) subdir('examples') endif + +# generate documentation +if(get_option('documentation')) + doxygen = find_program('doxygen', required: false) + if(doxygen.found()) + message('Generating documentation...') + run_command('doxygen', meson.project_source_root() / 'doc' / 'Doxyfile', check: true) + message('...documentation generated.') + else + warning('Cannot generate documentation since `doxygen` is not found') + endif +endif diff --git a/meson.options b/meson.options index a6bc6a7a..e0098741 100644 --- a/meson.options +++ b/meson.options @@ -1 +1,2 @@ -option('examples', type: 'boolean', value: false, description: 'Build examples') +option('examples', type: 'boolean', value: false, description: 'Build examples') +option('documentation', type: 'boolean', value: false, description: 'Generate API documentation')