From 9b560c29b66785550a611cc49f10447c139b4ea0 Mon Sep 17 00:00:00 2001 From: Patrick Griffis Date: Tue, 6 Dec 2016 10:58:18 -0500 Subject: [PATCH 1/4] gnome.gtkdoc(): Fix including doc source dir in path --- mesonbuild/scripts/gtkdochelper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesonbuild/scripts/gtkdochelper.py b/mesonbuild/scripts/gtkdochelper.py index e34b541bc..bb0d7429c 100755 --- a/mesonbuild/scripts/gtkdochelper.py +++ b/mesonbuild/scripts/gtkdochelper.py @@ -122,7 +122,7 @@ def build_gtkdoc(source_root, build_root, doc_subdir, src_subdir, # Make HTML documentation mkhtml_cmd = ['gtkdoc-mkhtml', - '--path=' + ':'.join((abs_src, abs_out)), + '--path=' + ':'.join((doc_src, abs_out)), module, ] + html_args if len(main_file) > 0: From a626d1a7bc0759a099e8d7832dd23fadb60fda67 Mon Sep 17 00:00:00 2001 From: Patrick Griffis Date: Tue, 6 Dec 2016 12:23:29 -0500 Subject: [PATCH 2/4] gnome.gtkdoc(): Allow passing multiple source dirs This is valid and used by glib for example. --- mesonbuild/modules/gnome.py | 29 +++++++++++++++++------------ mesonbuild/scripts/gtkdochelper.py | 13 ++++++------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index 241a53117..4658e6d64 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -653,23 +653,28 @@ can not be used with the current version of glib-compiled-resources, due to if main_file != '': raise MesonException('You can only specify main_xml or main_sgml, not both.') main_file = main_xml - src_dir = kwargs['src_dir'] targetname = modulename + '-doc' command = [state.environment.get_build_command(), '--internal', 'gtkdoc'] - if hasattr(src_dir, 'held_object'): - src_dir= src_dir.held_object - if not isinstance(src_dir, build.IncludeDirs): - raise MesonException('Invalid keyword argument for src_dir.') - incdirs = src_dir.get_incdirs() - if len(incdirs) != 1: - raise MesonException('Argument src_dir has more than one directory specified.') - header_dir = os.path.join(state.environment.get_source_dir(), src_dir.get_curdir(), incdirs[0]) - else: - header_dir = os.path.normpath(os.path.join(state.subdir, src_dir)) + + src_dirs = kwargs['src_dir'] + if not isinstance(src_dirs, list): + src_dirs = [src_dirs] + header_dirs = [] + for src_dir in src_dirs: + if hasattr(src_dir, 'held_object'): + src_dir = src_dir.held_object + if not isinstance(src_dir, build.IncludeDirs): + raise MesonException('Invalid keyword argument for src_dir.') + for inc_dir in src_dir.get_incdirs(): + header_dirs.append(os.path.join(state.environment.get_source_dir(), + src_dir.get_curdir(), inc_dir)) + else: + header_dirs.append(os.path.normpath(os.path.join(state.subdir, src_dir))) + args = ['--sourcedir=' + state.environment.get_source_dir(), '--builddir=' + state.environment.get_build_dir(), '--subdir=' + state.subdir, - '--headerdir=' + header_dir, + '--headerdirs=' + '@@'.join(header_dirs), '--mainfile=' + main_file, '--modulename=' + modulename] args += self._unpack_args('--htmlargs=', 'html_args', kwargs) diff --git a/mesonbuild/scripts/gtkdochelper.py b/mesonbuild/scripts/gtkdochelper.py index bb0d7429c..ec7678b88 100755 --- a/mesonbuild/scripts/gtkdochelper.py +++ b/mesonbuild/scripts/gtkdochelper.py @@ -25,7 +25,7 @@ parser = argparse.ArgumentParser() parser.add_argument('--sourcedir', dest='sourcedir') parser.add_argument('--builddir', dest='builddir') parser.add_argument('--subdir', dest='subdir') -parser.add_argument('--headerdir', dest='headerdir') +parser.add_argument('--headerdirs', dest='headerdirs') parser.add_argument('--mainfile', dest='mainfile') parser.add_argument('--modulename', dest='modulename') parser.add_argument('--htmlargs', dest='htmlargs', default='') @@ -54,13 +54,13 @@ def gtkdoc_run_check(cmd, cwd): err_msg.append(stdo.decode(errors='ignore')) raise MesonException('\n'.join(err_msg)) -def build_gtkdoc(source_root, build_root, doc_subdir, src_subdir, +def build_gtkdoc(source_root, build_root, doc_subdir, src_subdirs, main_file, module, html_args, scan_args, fixxref_args, gobject_typesfile, scanobjs_args, ld, cc, ldflags, cflags, html_assets, content_files, ignore_headers): print("Building documentation for %s" % module) - abs_src = os.path.join(source_root, src_subdir) + src_dir_args = ['--source-dir=' + os.path.join(source_root, src_dir) for src_dir in src_subdirs] doc_src = os.path.join(source_root, doc_subdir) abs_out = os.path.join(build_root, doc_subdir) htmldir = os.path.join(abs_out, 'html') @@ -90,7 +90,7 @@ def build_gtkdoc(source_root, build_root, doc_subdir, src_subdir, f_abs = os.path.join(doc_src, f) shutil.copyfile(f_abs, os.path.join(htmldir, os.path.basename(f_abs))) - scan_cmd = ['gtkdoc-scan', '--module=' + module, '--source-dir=' + abs_src] + scan_cmd = ['gtkdoc-scan', '--module=' + module] + src_dir_args if ignore_headers: scan_cmd.append('--ignore-headers=' + ' '.join(ignore_headers)) # Add user-specified arguments @@ -113,8 +113,7 @@ def build_gtkdoc(source_root, build_root, doc_subdir, src_subdir, '--module=' + module, '--output-format=xml', '--expand-content-files=', - modeflag, - '--source-dir=' + abs_src] + modeflag] + src_dir_args if len(main_file) > 0: # Yes, this is the flag even if the file is in xml. mkdb_cmd.append('--main-sgml-file=' + main_file) @@ -166,7 +165,7 @@ def run(args): options.sourcedir, options.builddir, options.subdir, - options.headerdir, + options.headerdirs.split('@@'), options.mainfile, options.modulename, htmlargs, From d764c7dc91f5d679687fa2dc00ad29c2ee0ca875 Mon Sep 17 00:00:00 2001 From: Patrick Griffis Date: Tue, 6 Dec 2016 13:23:58 -0500 Subject: [PATCH 3/4] gnome.gtkdoc(): Add namespace keyword --- mesonbuild/modules/gnome.py | 4 ++++ mesonbuild/scripts/gtkdochelper.py | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index 4658e6d64..7f63753c9 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -656,6 +656,8 @@ can not be used with the current version of glib-compiled-resources, due to targetname = modulename + '-doc' command = [state.environment.get_build_command(), '--internal', 'gtkdoc'] + namespace = kwargs.get('namespace', '') + src_dirs = kwargs['src_dir'] if not isinstance(src_dirs, list): src_dirs = [src_dirs] @@ -677,6 +679,8 @@ can not be used with the current version of glib-compiled-resources, due to '--headerdirs=' + '@@'.join(header_dirs), '--mainfile=' + main_file, '--modulename=' + modulename] + if namespace: + args.append('--namespace=' + namespace) args += self._unpack_args('--htmlargs=', 'html_args', kwargs) args += self._unpack_args('--scanargs=', 'scan_args', kwargs) args += self._unpack_args('--scanobjsargs=', 'scanobjs_args', kwargs) diff --git a/mesonbuild/scripts/gtkdochelper.py b/mesonbuild/scripts/gtkdochelper.py index ec7678b88..286d3ae9a 100755 --- a/mesonbuild/scripts/gtkdochelper.py +++ b/mesonbuild/scripts/gtkdochelper.py @@ -40,6 +40,7 @@ parser.add_argument('--cflags', dest='cflags', default='') parser.add_argument('--content-files', dest='content_files', default='') parser.add_argument('--html-assets', dest='html_assets', default='') parser.add_argument('--ignore-headers', dest='ignore_headers', default='') +parser.add_argument('--namespace', dest='namespace', default='') parser.add_argument('--installdir', dest='install_dir') def gtkdoc_run_check(cmd, cwd): @@ -57,7 +58,7 @@ def gtkdoc_run_check(cmd, cwd): def build_gtkdoc(source_root, build_root, doc_subdir, src_subdirs, main_file, module, html_args, scan_args, fixxref_args, gobject_typesfile, scanobjs_args, ld, cc, ldflags, cflags, - html_assets, content_files, ignore_headers): + html_assets, content_files, ignore_headers, namespace): print("Building documentation for %s" % module) src_dir_args = ['--source-dir=' + os.path.join(source_root, src_dir) for src_dir in src_subdirs] @@ -114,6 +115,8 @@ def build_gtkdoc(source_root, build_root, doc_subdir, src_subdirs, '--output-format=xml', '--expand-content-files=', modeflag] + src_dir_args + if namespace: + mkdb_cmd.append('--name-space=' + namespace) if len(main_file) > 0: # Yes, this is the flag even if the file is in xml. mkdb_cmd.append('--main-sgml-file=' + main_file) @@ -179,7 +182,8 @@ def run(args): options.cflags, options.html_assets.split('@@') if options.html_assets else [], options.content_files.split('@@') if options.content_files else [], - options.ignore_headers.split('@@') if options.ignore_headers else []) + options.ignore_headers.split('@@') if options.ignore_headers else [], + options.namespace) if 'MESON_INSTALL_PREFIX' in os.environ: install_dir = options.install_dir if options.install_dir else options.modulename From e265887ac33bc8de5e96ff52c37f3c94a0d7ce46 Mon Sep 17 00:00:00 2001 From: Patrick Griffis Date: Tue, 6 Dec 2016 14:07:45 -0500 Subject: [PATCH 4/4] gnome.gtkdoc(): Add keyword to override the mode I'm not entirely sure if you ever want to mix and match but I can say that glib required none of them to be passed so this allows for that. --- mesonbuild/modules/gnome.py | 8 +++++++- mesonbuild/scripts/gtkdochelper.py | 31 +++++++++++++++++++++++------- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index 7f63753c9..e32037a4a 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -657,6 +657,10 @@ can not be used with the current version of glib-compiled-resources, due to command = [state.environment.get_build_command(), '--internal', 'gtkdoc'] namespace = kwargs.get('namespace', '') + mode = kwargs.get('mode', 'auto') + VALID_MODES = ('xml', 'sgml', 'none', 'auto') + if not mode in VALID_MODES: + raise MesonException('gtkdoc: Mode {} is not a valid mode: {}'.format(mode, VALID_MODES)) src_dirs = kwargs['src_dir'] if not isinstance(src_dirs, list): @@ -678,7 +682,8 @@ can not be used with the current version of glib-compiled-resources, due to '--subdir=' + state.subdir, '--headerdirs=' + '@@'.join(header_dirs), '--mainfile=' + main_file, - '--modulename=' + modulename] + '--modulename=' + modulename, + '--mode=' + mode] if namespace: args.append('--namespace=' + namespace) args += self._unpack_args('--htmlargs=', 'html_args', kwargs) @@ -688,6 +693,7 @@ can not be used with the current version of glib-compiled-resources, due to args += self._unpack_args('--fixxrefargs=', 'fixxref_args', kwargs) args += self._unpack_args('--html-assets=', 'html_assets', kwargs, state) args += self._unpack_args('--content-files=', 'content_files', kwargs, state) + args += self._unpack_args('--expand-content-files=', 'expand_content_files', kwargs, state) args += self._unpack_args('--ignore-headers=', 'ignore_headers', kwargs) args += self._unpack_args('--installdir=', 'install_dir', kwargs, state) args += self._get_build_args(kwargs, state) diff --git a/mesonbuild/scripts/gtkdochelper.py b/mesonbuild/scripts/gtkdochelper.py index 286d3ae9a..a425d6c73 100755 --- a/mesonbuild/scripts/gtkdochelper.py +++ b/mesonbuild/scripts/gtkdochelper.py @@ -38,9 +38,11 @@ parser.add_argument('--cc', dest='cc', default='') parser.add_argument('--ldflags', dest='ldflags', default='') parser.add_argument('--cflags', dest='cflags', default='') parser.add_argument('--content-files', dest='content_files', default='') +parser.add_argument('--expand-content-files', dest='expand_content_files', default='') parser.add_argument('--html-assets', dest='html_assets', default='') parser.add_argument('--ignore-headers', dest='ignore_headers', default='') parser.add_argument('--namespace', dest='namespace', default='') +parser.add_argument('--mode', dest='mode', default='') parser.add_argument('--installdir', dest='install_dir') def gtkdoc_run_check(cmd, cwd): @@ -58,7 +60,8 @@ def gtkdoc_run_check(cmd, cwd): def build_gtkdoc(source_root, build_root, doc_subdir, src_subdirs, main_file, module, html_args, scan_args, fixxref_args, gobject_typesfile, scanobjs_args, ld, cc, ldflags, cflags, - html_assets, content_files, ignore_headers, namespace): + html_assets, content_files, ignore_headers, namespace, + expand_content_files, mode): print("Building documentation for %s" % module) src_dir_args = ['--source-dir=' + os.path.join(source_root, src_dir) for src_dir in src_subdirs] @@ -106,17 +109,29 @@ def build_gtkdoc(source_root, build_root, doc_subdir, src_subdirs, # Make docbook files - if main_file.endswith('sgml'): - modeflag = '--sgml-mode' - else: + if mode == 'auto': + # Guessing is probably a poor idea but these keeps compat + # with previous behavior + if main_file.endswith('sgml'): + modeflag = '--sgml-mode' + else: + modeflag = '--xml-mode' + elif mode == 'xml': modeflag = '--xml-mode' + elif mode == 'sgml': + modeflag = '--sgml-mode' + else: # none + modeflag = None + mkdb_cmd = ['gtkdoc-mkdb', '--module=' + module, '--output-format=xml', - '--expand-content-files=', - modeflag] + src_dir_args + '--expand-content-files=' + ' '.join(expand_content_files), + ] + src_dir_args if namespace: mkdb_cmd.append('--name-space=' + namespace) + if modeflag: + mkdb_cmd.append(modeflag) if len(main_file) > 0: # Yes, this is the flag even if the file is in xml. mkdb_cmd.append('--main-sgml-file=' + main_file) @@ -183,7 +198,9 @@ def run(args): options.html_assets.split('@@') if options.html_assets else [], options.content_files.split('@@') if options.content_files else [], options.ignore_headers.split('@@') if options.ignore_headers else [], - options.namespace) + options.namespace, + options.expand_content_files.split('@@') if options.expand_content_files else [], + options.mode) if 'MESON_INSTALL_PREFIX' in os.environ: install_dir = options.install_dir if options.install_dir else options.modulename