[gimp] menus: fix validating the XML menu files with meson build.



commit 19e545bc1f9dca37a497811e28976edbd2f07b6a
Author: Jehan <jehan girinstud io>
Date:   Fri Jun 18 14:31:46 2021 +0200

    menus: fix validating the XML menu files with meson build.
    
    Basically the build was never running this target (unless maybe in some
    edge cases as could be demonstrated by the Arch repository build, though
    it doesn't look they did anything particular; this is how we discovered
    the bug #6447 as this was not run on our own local or CI builds).
    Reading the docs of run_target(), it may actually have been normal.
    run_target() looks to be only about creating top-level targets (which
    one could run with `ninja validate_menus` in our case for instance), not
    actually running the command (i.e. badly named function).
    
    For the command to be actually run on a normal build, let's use a
    custom_target() as proposed by Paolo Bonzini. After testing, the xmllint
    validation is properly run on a normal build and dependency works fine
    with both the source XML and generated XML files (touching these files
    trigger a rebuild).
    The output of xmllint is stored in some dummy file, which is only useful
    to prevent re-running the command at each build even though source XML
    were unchanged (so it's more of a flag file).
    
    See discussion in #6447.

 menus/meson.build | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)
---
diff --git a/menus/meson.build b/menus/meson.build
index 796112fc0d..e7147a2d33 100644
--- a/menus/meson.build
+++ b/menus/meson.build
@@ -1,6 +1,6 @@
 menus_dir = prefix / gimpdatadir / 'menus'
 
-menus_files = [
+menus_files = files(
   'brush-editor-menu.xml',
   'brushes-menu.xml',
   'buffers-menu.xml',
@@ -33,7 +33,7 @@ menus_files = [
   'undo-menu.xml',
   'vector-toolpath-menu.xml',
   'vectors-menu.xml',
-]
+)
 
 install_data(menus_files,
   install_dir: menus_dir,
@@ -41,8 +41,9 @@ install_data(menus_files,
 
 unstable_menus_args = stable ? [] : [ '--stringparam', 'unstable-menus', 'yes' ]
 
+menus_built_files = []
 foreach menu_filegen : [ 'dockable-menu.xml', 'image-menu.xml', ]
-  menus_files += custom_target(menu_filegen,
+  menus_built_files += custom_target(menu_filegen,
     input : [ menu_filegen +'.in', 'menus.xsl', ],
     output: [ menu_filegen ],
     command: [
@@ -59,12 +60,18 @@ foreach menu_filegen : [ 'dockable-menu.xml', 'image-menu.xml', ]
 endforeach
 
 if xmllint.found()
-  run_target('validate_menus',
+  custom_target('validate_menus',
     command: [
       xmllint,
-      '--noout', '--valid',
+      '--output', '@OUTPUT@',
+      '--valid',
       '--path', meson.current_source_dir(),
-      menus_files,
+      menus_files, menus_built_files
     ],
+    # The output file is only useful as a flag file, so that the command
+    # knows if it has been run already.
+    output: [ 'validate_menus-output.xml' ],
+    build_by_default: true,
+    install: false
   )
 endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]