From 3b2d33ef84ed717e875790b34bac028529420c08 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Mon, 19 Oct 2015 00:14:27 +0300 Subject: [PATCH 1/3] Made gtkdochelper take arguments by switches rather than location. --- gtkdochelper.py | 37 ++++++++++++++++++++++++------------- modules/gnome.py | 12 ++++++------ 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/gtkdochelper.py b/gtkdochelper.py index 47090125b..6f1694559 100755 --- a/gtkdochelper.py +++ b/gtkdochelper.py @@ -16,6 +16,17 @@ import sys, os import subprocess import shutil +import argparse + +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('--mainfile', dest='mainfile') +parser.add_argument('--modulename', dest='modulename') + def build_gtkdoc(source_root, build_root, doc_subdir, src_subdir, main_file, module): abs_src = os.path.join(source_root, src_subdir) @@ -35,7 +46,7 @@ def build_gtkdoc(source_root, build_root, doc_subdir, src_subdir, main_file, mod modeflag, '--source-dir=' + abs_src] main_abs = os.path.join(source_root, doc_subdir, main_file) - if len(main_sgml) > 0: + if len(main_file) > 0: # Yes, this is the flag even if the file is in xml. mkdb_cmd.append('--main-sgml-file=' + main_abs) subprocess.check_call(mkdb_cmd, cwd=abs_out) @@ -65,21 +76,21 @@ def install_gtkdoc(build_root, doc_subdir, install_prefix, datadir, module): shutil.copytree(source, final_destination) if __name__ == '__main__': -# source_root = '/home/jpakkane/workspace/meson/test cases/frameworks/10 gtk-doc' -# build_root = '/home/jpakkane/workspace/meson/work area' -# doc_subdir = 'doc' -# src_subdir = 'include' -# module = 'foobar' - if len(sys.argv) != 7: - print(sys.argv) - print("Bad arguments.") - sys.exit(1) - (source_root, build_root, doc_subdir, src_subdir, main_sgml, module) = sys.argv[1:] - build_gtkdoc(source_root, build_root, doc_subdir, src_subdir, main_sgml, module) + options = parser.parse_args(sys.argv[1:]) + build_gtkdoc(options.sourcedir, + options.builddir, + options.subdir, + options.headerdir, + options.mainfile, + options.modulename) if 'MESON_INSTALL_PREFIX' in os.environ: if 'DESTDIR' in os.environ: installdir = os.environ['DESTDIR'] + os.environ['MESON_INSTALL_PREFIX'] else: installdir = os.environ['MESON_INSTALL_PREFIX'] - install_gtkdoc(build_root, doc_subdir, installdir, 'share/gtk-doc/html', module) + install_gtkdoc(options.builddir, + options.subdir, + installdir, + 'share/gtk-doc/html', + options.modulename) diff --git a/modules/gnome.py b/modules/gnome.py index 231cbd402..a744ab222 100644 --- a/modules/gnome.py +++ b/modules/gnome.py @@ -227,12 +227,12 @@ class GnomeModule: 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)) - args = [state.environment.get_source_dir(), - state.environment.get_build_dir(), - state.subdir, - header_dir, - main_file, - modulename] + args = ['--sourcedir=' + state.environment.get_source_dir(), + '--builddir=' + state.environment.get_build_dir(), + '--subdir=' + state.subdir, + '--headerdir=' + header_dir, + '--mainfile=' + main_file, + '--modulename=' + modulename] res = [build.RunTarget(targetname, command, args, state.subdir)] if kwargs.get('install', True): res.append(build.InstallScript([command] + args)) From 0b63f32fe33298bb373522b0a717e186a4d0ebd4 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Mon, 19 Oct 2015 00:26:54 +0300 Subject: [PATCH 2/3] Can specify extra args to gtkdoc-scan. --- gtkdochelper.py | 14 ++++++++++---- modules/gnome.py | 11 +++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/gtkdochelper.py b/gtkdochelper.py index 6f1694559..16ddf6047 100755 --- a/gtkdochelper.py +++ b/gtkdochelper.py @@ -26,9 +26,10 @@ parser.add_argument('--subdir', dest='subdir') parser.add_argument('--headerdir', dest='headerdir') parser.add_argument('--mainfile', dest='mainfile') parser.add_argument('--modulename', dest='modulename') +parser.add_argument('--htmlargs', dest='htmlargs', default='') - -def build_gtkdoc(source_root, build_root, doc_subdir, src_subdir, main_file, module): +def build_gtkdoc(source_root, build_root, doc_subdir, src_subdir, + main_file, module, html_args): abs_src = os.path.join(source_root, src_subdir) abs_out = os.path.join(build_root, doc_subdir) htmldir = os.path.join(abs_out, 'html') @@ -55,7 +56,7 @@ def build_gtkdoc(source_root, build_root, doc_subdir, src_subdir, main_file, mod os.mkdir(htmldir) except Exception: pass - mkhtml_cmd = ['gtkdoc-mkhtml', module] + mkhtml_cmd = ['gtkdoc-mkhtml', module] + html_args if len(main_file) > 0: # Workaround for # https://bugzilla.gnome.org/show_bug.cgi?id=753145 @@ -77,12 +78,17 @@ def install_gtkdoc(build_root, doc_subdir, install_prefix, datadir, module): if __name__ == '__main__': options = parser.parse_args(sys.argv[1:]) + if len(options.htmlargs) >0: + htmlargs = options.htmlargs.split('@@') + else: + htmlargs = [] build_gtkdoc(options.sourcedir, options.builddir, options.subdir, options.headerdir, options.mainfile, - options.modulename) + options.modulename, + htmlargs) if 'MESON_INSTALL_PREFIX' in os.environ: if 'DESTDIR' in os.environ: diff --git a/modules/gnome.py b/modules/gnome.py index a744ab222..9e2b4761e 100644 --- a/modules/gnome.py +++ b/modules/gnome.py @@ -233,6 +233,17 @@ class GnomeModule: '--headerdir=' + header_dir, '--mainfile=' + main_file, '--modulename=' + modulename] + try: + html_args = kwargs['html_args'] + if not isinstance(html_args, list): + html_args = [html_args] + for i in html_args: + if not isinstance(i, str): + raise MesonException('html_args values must be strings.') + except KeyError: + html_args = [] + if len(html_args) > 0: + args.append('--htmlargs=' + '@@'.join(html_args)) res = [build.RunTarget(targetname, command, args, state.subdir)] if kwargs.get('install', True): res.append(build.InstallScript([command] + args)) From bbbe102cc29a19c726095dbd5118c515996e64f0 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Mon, 19 Oct 2015 00:35:41 +0300 Subject: [PATCH 3/3] Can set extra args to gtkdoc scan. --- gtkdochelper.py | 15 +++++++++++---- modules/gnome.py | 25 +++++++++++++++---------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/gtkdochelper.py b/gtkdochelper.py index 16ddf6047..c063bb6d4 100755 --- a/gtkdochelper.py +++ b/gtkdochelper.py @@ -27,16 +27,18 @@ parser.add_argument('--headerdir', dest='headerdir') parser.add_argument('--mainfile', dest='mainfile') parser.add_argument('--modulename', dest='modulename') parser.add_argument('--htmlargs', dest='htmlargs', default='') +parser.add_argument('--scanargs', dest='scanargs', default='') def build_gtkdoc(source_root, build_root, doc_subdir, src_subdir, - main_file, module, html_args): + main_file, module, html_args, scan_args): abs_src = os.path.join(source_root, src_subdir) abs_out = os.path.join(build_root, doc_subdir) htmldir = os.path.join(abs_out, 'html') subprocess.check_call(['gtkdoc-scan', '--module=' + module, '--source-dir=' + abs_src, - '--output-dir=.'], cwd=abs_out) + '--output-dir=.'] + scan_args, + cwd=abs_out) if main_file.endswith('sgml'): modeflag = '--sgml-mode' else: @@ -78,17 +80,22 @@ def install_gtkdoc(build_root, doc_subdir, install_prefix, datadir, module): if __name__ == '__main__': options = parser.parse_args(sys.argv[1:]) - if len(options.htmlargs) >0: + if len(options.htmlargs) > 0: htmlargs = options.htmlargs.split('@@') else: htmlargs = [] + if len(options.scanargs) > 0: + scanargs = options.scanargs.split('@@') + else: + scanargs = [] build_gtkdoc(options.sourcedir, options.builddir, options.subdir, options.headerdir, options.mainfile, options.modulename, - htmlargs) + htmlargs, + scanargs) if 'MESON_INSTALL_PREFIX' in os.environ: if 'DESTDIR' in os.environ: diff --git a/modules/gnome.py b/modules/gnome.py index 9e2b4761e..f126bcf2c 100644 --- a/modules/gnome.py +++ b/modules/gnome.py @@ -233,21 +233,26 @@ class GnomeModule: '--headerdir=' + header_dir, '--mainfile=' + main_file, '--modulename=' + modulename] + args += self.unpack_args('--htmlargs=', 'html_args', kwargs) + args += self.unpack_args('--scanargs=', 'scan_args', kwargs) + res = [build.RunTarget(targetname, command, args, state.subdir)] + if kwargs.get('install', True): + res.append(build.InstallScript([command] + args)) + return res + + def unpack_args(self, arg, kwarg_name, kwargs): try: - html_args = kwargs['html_args'] - if not isinstance(html_args, list): - html_args = [html_args] - for i in html_args: + new_args = kwargs[kwarg_name] + if not isinstance(new_args, list): + new_args = [new_args] + for i in new_args: if not isinstance(i, str): raise MesonException('html_args values must be strings.') except KeyError: - html_args = [] + return[] if len(html_args) > 0: - args.append('--htmlargs=' + '@@'.join(html_args)) - res = [build.RunTarget(targetname, command, args, state.subdir)] - if kwargs.get('install', True): - res.append(build.InstallScript([command] + args)) - return res + return ['--htmlargs=' + '@@'.join(new_args)] + return [] def gdbus_codegen(self, state, args, kwargs): if len(args) != 2: