Skip to content

Commit

Permalink
feat: generate documentation with meson
Browse files Browse the repository at this point in the history
  • Loading branch information
c-dilks committed Dec 14, 2023
1 parent 9a22ed8 commit 11f26e5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 7 additions & 4 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down
12 changes: 12 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion meson.options
Original file line number Diff line number Diff line change
@@ -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')

0 comments on commit 11f26e5

Please sign in to comment.