build: make doxygen run from the source tree
authorRan Benita <ran234@gmail.com>
Tue, 1 Aug 2017 19:19:48 +0000 (22:19 +0300)
committerRan Benita <ran234@gmail.com>
Tue, 1 Aug 2017 20:32:15 +0000 (23:32 +0300)
I couldn't find any other way to make this work!

Signed-off-by: Ran Benita <ran234@gmail.com>
Makefile.am
doc/Doxyfile.in
meson.build
scripts/doxygen-wrapper [new file with mode: 0755]

index 5deef76..42c6ae9 100644 (file)
@@ -8,6 +8,7 @@ EXTRA_DIST = \
        scripts/makekeys \
        scripts/update-keysyms \
        scripts/update-keywords \
+       scripts/doxygen-wrapper \
        src/xkbcomp/keywords.gperf \
        test/data \
        README.md \
@@ -164,7 +165,7 @@ doc/html: doc/Doxyfile $(doxygen_input)
            cat $<; \
            echo "INPUT = $(doxygen_input)"; \
            echo "OUTPUT_DIRECTORY = $(abs_top_builddir)/doc"; \
-       ) | $(DOXYGEN) -
+       ) | $(top_srcdir)/scripts/doxygen-wrapper "$(DOXYGEN)" - "$(abs_top_srcdir)"
 clean-doxygen:
        rm -rf doc/html
 
index 04a2991..798381f 100644 (file)
@@ -2,6 +2,8 @@ PROJECT_NAME           = @PACKAGE_NAME@
 
 PROJECT_NUMBER         = @PACKAGE_VERSION@
 
+OUTPUT_DIRECTORY       = @OUTPUT_DIRECTORY@
+
 BRIEF_MEMBER_DESC      = NO
 
 JAVADOC_AUTOBRIEF      = YES
@@ -32,7 +34,7 @@ ALPHABETICAL_INDEX     = NO
 IGNORE_PREFIX          = xkb_ \
                          XKB_
 
-HTML_EXTRA_STYLESHEET  = @abs_top_srcdir@/doc/doxygen-extra.css
+HTML_EXTRA_STYLESHEET  = doc/doxygen-extra.css
 
 HTML_TIMESTAMP         = NO
 
index 2b4a57a..7d517d7 100644 (file)
@@ -447,36 +447,35 @@ if get_option('enable-docs')
         error('''Documentation requires doxygen which was not found.
 You can disable the documentation with -Denable-docs=false.''')
     endif
+    doxygen_wrapper = find_program('scripts/doxygen-wrapper')
 
     doxygen_input = [
-        join_paths(meson.source_root(), 'README.md'),
-        join_paths(meson.source_root(), 'doc/doxygen-extra.css'),
-        join_paths(meson.source_root(), 'doc/quick-guide.md'),
-        join_paths(meson.source_root(), 'doc/compat.md'),
-        join_paths(meson.source_root(), 'xkbcommon/xkbcommon.h'),
-        join_paths(meson.source_root(), 'xkbcommon/xkbcommon-names.h'),
-        join_paths(meson.source_root(), 'xkbcommon/xkbcommon-x11.h'),
-        join_paths(meson.source_root(), 'xkbcommon/xkbcommon-compose.h'),
+        'README.md',
+        'doc/doxygen-extra.css',
+        'doc/quick-guide.md',
+        'doc/compat.md',
+        'xkbcommon/xkbcommon.h',
+        'xkbcommon/xkbcommon-names.h',
+        'xkbcommon/xkbcommon-x11.h',
+        'xkbcommon/xkbcommon-compose.h',
     ]
     doxygen_data = configuration_data()
     doxygen_data.set('PACKAGE_NAME', meson.project_name())
     doxygen_data.set('PACKAGE_VERSION', meson.project_version())
     doxygen_data.set('INPUT', ' '.join(doxygen_input))
-    doxygen_data.set('abs_top_srcdir', meson.source_root())
+    doxygen_data.set('OUTPUT_DIRECTORY', meson.build_root())
     doxyfile = configure_file(
         input: 'doc/Doxyfile.in',
         output: 'Doxyfile',
         configuration: doxygen_data,
-        install: false,
     )
     # TODO: Meson should provide this.
     docdir = join_paths(get_option('datadir'), 'doc', meson.project_name())
-    # TODO: Relative links in README.md fail.
     custom_target(
         'doc',
         input: [doxyfile] + doxygen_input,
         output: 'html',
-        command: [doxygen, doxyfile],
+        command: [doxygen_wrapper, doxygen.path(), join_paths(meson.build_root(), 'Doxyfile'), meson.source_root()],
         install: true,
         install_dir: docdir,
         build_by_default: true,
diff --git a/scripts/doxygen-wrapper b/scripts/doxygen-wrapper
new file mode 100755 (executable)
index 0000000..baa7b26
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/sh
+# Run doxygen such that the working directory is the source root.
+# This is needed for various reasons (e.g. relative references in md files).
+# Do not use directly.
+DOXYGEN="$1"
+DOXYFILE="$2"
+ABS_TOP_SRCDIR="$3"
+cd "$ABS_TOP_SRCDIR" && exec "$DOXYGEN" "$DOXYFILE"