]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
meson: Add target for generating docs images
authorDaniel Gustafsson <dgustafsson@postgresql.org>
Fri, 13 Feb 2026 10:50:14 +0000 (11:50 +0100)
committerDaniel Gustafsson <dgustafsson@postgresql.org>
Fri, 13 Feb 2026 10:50:14 +0000 (11:50 +0100)
This adds an 'images' target to the meson build system in order to
be able to regenerate the images used in the docs.

Author: Nazir Bilal Yavuz <byavuz81@gmail.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Reported-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/CAN55FZ0c0Tcjx9=e-YibWGHa1-xmdV63p=THH4YYznz+pYcfig@mail.gmail.com

doc/src/sgml/images/meson.build [new file with mode: 0644]
doc/src/sgml/meson.build
meson.build

diff --git a/doc/src/sgml/images/meson.build b/doc/src/sgml/images/meson.build
new file mode 100644 (file)
index 0000000..8e601e8
--- /dev/null
@@ -0,0 +1,61 @@
+# doc/src/sgml/images/meson.build
+#
+# see README in this directory about image handling
+
+if not xsltproc_bin.found() or not dot.found() or not ditaa.found()
+  subdir_done()
+endif
+
+image_targets = []
+
+fixup_svg_xsl = files('fixup-svg.xsl')
+
+all_files = [
+  'genetic-algorithm.gv',
+  'gin.gv',
+  'pagelayout.txt',
+  'temporal-entities.txt',
+  'temporal-references.txt',
+]
+
+foreach file : all_files
+
+  str_split = file.split('.')
+  actual_file_name = str_split[0]
+  extension = str_split[1]
+  cur_file = files(file)
+  tmp_name = '@0@.svg.tmp'.format(file)
+  output_name = '@0@.svg'.format(actual_file_name)
+
+  command = []
+  if extension == 'gv'
+    command = [dot, '-T', 'svg', '-o', '@OUTPUT@', '@INPUT@']
+  elif extension == 'txt'
+    command = [ditaa, '-E', '-S', '--svg', '@INPUT@', '@OUTPUT@']
+  else
+    error('Unknown extension: ".@0@" while generating images'.format(extension))
+  endif
+
+  svg_tmp = custom_target(tmp_name,
+    input: cur_file,
+    output: tmp_name,
+    command: command,
+  )
+
+  current_svg = custom_target(output_name,
+    input: svg_tmp,
+    output: output_name,
+    command: [xsltproc_bin,
+      '--nonet',
+      # Use --novalid to avoid loading SVG DTD if a file specifies it, since
+      # it might not be available locally, and we don't need it.
+      '--novalid',
+      '-o', '@OUTPUT@',
+      fixup_svg_xsl,
+      '@INPUT@']
+  )
+
+  image_targets += current_svg
+endforeach
+
+alias_target('images', image_targets)
index d8f40a0b16d64ac771ea12f7a59e1706d0b821f0..a1ae5c54ed62f0abe46a5383a10c708f55bd155b 100644 (file)
@@ -1,5 +1,7 @@
 # Copyright (c) 2022-2026, PostgreSQL Global Development Group
 
+subdir('images')
+
 docs = []
 installdocs = []
 alldocs = []
index 96b3869df86e70a574c5e9411b117168e8054678..f6d5842d85279156224c06ff0e02a5953201c19c 100644 (file)
@@ -355,6 +355,8 @@ cp = find_program('cp', required: false, native: true)
 xmllint_bin = find_program(get_option('XMLLINT'), native: true, required: false)
 xsltproc_bin = find_program(get_option('XSLTPROC'), native: true, required: false)
 nm = find_program('nm', required: false, native: true)
+ditaa = find_program('ditaa', native: true, required: false)
+dot = find_program('dot', native: true, required: false)
 
 bison_flags = []
 if bison.found()