aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2015-07-30 00:52:44 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2015-08-02 13:49:11 +0300
commit8b52dec6d9c078082fd2896779c24de9578fe382 (patch)
tree4a6e6c434782bdfd6de961f121b41bc74041bcd6
parentc12a4c1acaf44ba0c5e74e5723fa3d5ce72a90dd (diff)
downloadmeson-8b52dec6d9c078082fd2896779c24de9578fe382.zip
meson-8b52dec6d9c078082fd2896779c24de9578fe382.tar.gz
meson-8b52dec6d9c078082fd2896779c24de9578fe382.tar.bz2
Can generate gtkdoc documentation.
-rwxr-xr-xgtkdochelper.py68
-rw-r--r--interpreter.py4
-rw-r--r--modules/gnome.py20
-rw-r--r--test cases/frameworks/10 gtk-doc/doc/meson.build3
-rw-r--r--test cases/frameworks/10 gtk-doc/include/foo.h15
-rw-r--r--test cases/frameworks/10 gtk-doc/meson.build3
6 files changed, 112 insertions, 1 deletions
diff --git a/gtkdochelper.py b/gtkdochelper.py
new file mode 100755
index 0000000..5ed979f
--- /dev/null
+++ b/gtkdochelper.py
@@ -0,0 +1,68 @@
+#!/usr/bin/env python3
+# Copyright 2015 The Meson development team
+
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+
+# http://www.apache.org/licenses/LICENSE-2.0
+
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import sys, os
+import subprocess
+import shutil
+
+def build_gtkdoc(source_root, build_root, doc_subdir, src_subdir, module):
+ 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)
+ subprocess.check_call(['gtkdoc-mkdb',
+ '--module=' + module,
+ '--output-format=xml',
+ '--source-dir=' + abs_src], cwd=abs_out)
+ shutil.rmtree(htmldir, ignore_errors=True)
+ try:
+ os.mkdir(htmldir)
+ except Exception:
+ pass
+ subprocess.check_call(['gtkdoc-mkhtml',
+ module,
+ '../%s-docs.xml' % module], cwd=htmldir)
+ subprocess.check_call(['gtkdoc-fixxref',
+ '--module=' + module,
+ '--module-dir=html'], cwd=abs_out)
+
+def install_gtkdoc(build_root, doc_subdir, install_prefix, datadir, module):
+ source = os.path.join(build_root, doc_subdir, 'html')
+ final_destination = os.path.join(install_prefix, datadir, module)
+ shutil.rmtree(final_destination, ignore_errors=True)
+ 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) != 6:
+ print(sys.argv)
+ print("Bad arguments.")
+ sys.exit(1)
+ (source_root, build_root, doc_subdir, src_subdir, module) = sys.argv[1:]
+ build_gtkdoc(source_root, build_root, doc_subdir, src_subdir, module)
+
+ 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)
diff --git a/interpreter.py b/interpreter.py
index 60dd4d6..0db5963 100644
--- a/interpreter.py
+++ b/interpreter.py
@@ -908,6 +908,10 @@ class Interpreter():
outvalues.append(self.module_method_callback(v))
elif isinstance(v, build.GeneratedList):
outvalues.append(GeneratedListHolder(v))
+ elif isinstance(v, build.RunTarget):
+ if v.name in self.build.targets:
+ raise InterpreterException('Tried to create target %s which already exists.' % v.name)
+ self.build.targets[v.name] = v
else:
print(v)
raise InterpreterException('Module returned a value of unknown type.')
diff --git a/modules/gnome.py b/modules/gnome.py
index 7a0ef4b..64e91df 100644
--- a/modules/gnome.py
+++ b/modules/gnome.py
@@ -16,7 +16,7 @@
functionality such as gobject-introspection and gresources.'''
import build
-import os
+import os, sys
import subprocess
from coredata import MesonException
import mlog
@@ -176,6 +176,24 @@ class GnomeModule:
target_g = build.CustomTarget(targetname, state.subdir, kwargs)
return target_g
+ def gtkdoc(self, state, args, kwargs):
+ if len(args) != 1:
+ raise MesonException('Gtkdoc must have one positional argument.')
+ modulename = args[0]
+ if not isinstance(modulename, str):
+ raise MesonException('Gtkdoc arg must be string.')
+ if not 'src_dir' in kwargs:
+ raise MesonException('Keyword argument src_dir missing.')
+ src_dir = kwargs['src_dir']
+ targetname = modulename + '-doc'
+ command = os.path.normpath(os.path.join(os.path.split(__file__)[0], "../gtkdochelper.py"))
+ args = [state.environment.get_source_dir(),
+ state.environment.get_build_dir(),
+ state.subdir,
+ os.path.normpath(os.path.join(state.subdir, src_dir)),
+ modulename]
+ return build.RunTarget(targetname, command, args, state.subdir)
+
def gdbus_codegen(self, state, args, kwargs):
if len(args) != 2:
raise MesonException('Gdbus_codegen takes two arguments, name and xml file.')
diff --git a/test cases/frameworks/10 gtk-doc/doc/meson.build b/test cases/frameworks/10 gtk-doc/doc/meson.build
new file mode 100644
index 0000000..4c67a19
--- /dev/null
+++ b/test cases/frameworks/10 gtk-doc/doc/meson.build
@@ -0,0 +1,3 @@
+gnome = import('gnome')
+
+gnome.gtkdoc('foobar', src_dir : '../include')
diff --git a/test cases/frameworks/10 gtk-doc/include/foo.h b/test cases/frameworks/10 gtk-doc/include/foo.h
new file mode 100644
index 0000000..7b8946b
--- /dev/null
+++ b/test cases/frameworks/10 gtk-doc/include/foo.h
@@ -0,0 +1,15 @@
+#pragma once
+
+/**
+ * FooIndecision:
+ * @FOO_MAYBE: Something maybe
+ * @FOO_POSSIBLY: Something possible
+ *
+ * The indecision type.
+ **/
+
+typedef enum {
+ FOO_MAYBE,
+ FOO_POSSIBLY,
+} FooIndecision;
+
diff --git a/test cases/frameworks/10 gtk-doc/meson.build b/test cases/frameworks/10 gtk-doc/meson.build
new file mode 100644
index 0000000..bb2e340
--- /dev/null
+++ b/test cases/frameworks/10 gtk-doc/meson.build
@@ -0,0 +1,3 @@
+project('gtkdoctest', 'c')
+
+subdir('doc')