meson: run pandoc as a build time rule
authorEli Schwartz <eschwartz93@gmail.com>
Wed, 19 Oct 2022 22:08:12 +0000 (18:08 -0400)
committerColin Clark <colin.clark@cclark.uk>
Thu, 20 Oct 2022 11:11:46 +0000 (12:11 +0100)
We don't need a proxy shell script at all, as it turns out. And Meson
can verify that the command succeeded, or update the built HTML if the
README itself changes.

meson.build

index 475b679..b45eb2f 100644 (file)
@@ -507,17 +507,20 @@ endif
 
 pandoc = find_program('pandoc', required : false)
 if pandoc.found()
-    run_command(find_program('gen_readme.sh'), meson.source_root(), meson.build_root(), check : false)
+    readme_html = custom_target(
+        'README.html',
+        input: 'README.md',
+        output: 'README.html',
+        command: [pandoc, '@INPUT@', '-o', '@OUTPUT@'],
+        install: true,
+        install_dir: helpdir)
 
-    install_data('README.md', 'COPYING', 'TODO', 'AUTHORS',
-                 join_paths(meson.build_root(), 'README.html'),
-                 install_dir : helpdir)
     summary({'README' : ['README.html created:', true]}, section : 'Documentation', bool_yn : true)
 else
-    install_data('README.md', 'COPYING', 'TODO', 'AUTHORS',
-                 install_dir : helpdir)
     summary({'README' : ['pandoc not found - README.html created:', false]}, section : 'Documentation', bool_yn : true)
 endif
+install_data('README.md', 'COPYING', 'TODO', 'AUTHORS',
+             install_dir : helpdir)
 
 evince = find_program('evince', required : false)
 if evince.found()