]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
meson: Work around configure_file(copy:true) deprecation
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 23 Mar 2023 10:11:42 +0000 (11:11 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 20 Apr 2023 13:30:18 +0000 (15:30 +0200)
In our meson scripts, we use configure_file(copy:true) to copy
files from srcdir into builddir. However, as of meson-0.64.0,
this is deprecated [1] in favor of using:

  fs = import('fs')
  fs.copyfile(in, out)

Except, the submodule's new method wasn't introduced until
0.64.0. And since we can't bump the minimal meson version we
require, we have to work with both: new and old versions.

Now, the fun part: fs.copyfile() is not a drop in replacement as
it returns different type (a custom_target object). This is
incompatible with places where we store the configure_file()
retval in a variable to process it further.

While we could just replace 'copy:true' with a dummy
'configuration:...' (say 'configuration: configmake_conf') we
can't do that for binary files (like src/fonts/ or src/images/).

Therefore, places where we are not interested in the retval can
be switched to fs.copyfile() and places where we are interested
in the retval will just use a dummy 'configuration:'.

Except, src/network/meson.build. In here we not just copy the
file but also specify alternative install dir and that's not
something that fs.copyfile() can handle. Yet, using 'copy: true'
is viewed wrong [2].

1: https://mesonbuild.com/Release-notes-for-0-64-0.html#fscopyfile-to-replace-configure_filecopy-true
2: https://github.com/mesonbuild/meson/pull/10042

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
docs/css/meson.build
docs/fonts/meson.build
docs/images/meson.build
docs/js/meson.build
docs/logos/meson.build
docs/meson.build
meson.build
src/locking/meson.build
src/network/meson.build

index 384f6e789f9f7e2bb56ee6045910dba5e94358a2..a2a2ccfb28cef25c31a0b4717725dce9e0ae1793 100644 (file)
@@ -11,7 +11,11 @@ install_data(docs_css_files, install_dir: docs_html_dir / 'css')
 foreach file : docs_css_files
   # This hack enables us to view the web pages
   # from within the uninstalled build tree
-  configure_file(input: file, output: file, copy: true)
+  if meson.version().version_compare('>=0.64.0')
+    fs.copyfile(file)
+  else
+    configure_file(input: file, output: file, copy: true)
+  endif
 
   install_web_files += '@0@:@1@'.format(meson.current_source_dir() / file, docs_html_dir / 'css')
 endforeach
index 53a060b97284e6a665080d1457166502dcba3d18..8f2b1c3d28c01ebcdb4aac53db123146567b8559 100644 (file)
@@ -17,7 +17,11 @@ install_data(fonts, install_dir: docs_html_dir / 'fonts')
 foreach file : fonts
   # This hack enables us to view the web pages
   # from within the uninstalled build tree
-  configure_file(input: file, output: file, copy: true)
+  if meson.version().version_compare('>=0.64.0')
+    fs.copyfile(file)
+  else
+    configure_file(input: file, output: file, copy: true)
+  endif
 
   install_web_files += '@0@:@1@'.format(meson.current_source_dir() / file, docs_html_dir / 'fonts')
 endforeach
index 3c3cb5cce1850b846fedb73c3b1a2174fb5bf425..b9ab30fc91af42a4286298023c5252d2d7505abc 100644 (file)
@@ -17,7 +17,11 @@ install_data(docs_image_files, install_dir: docs_html_dir / 'images')
 foreach file : docs_image_files
   # This hack enables us to view the web pages
   # from within the uninstalled build tree
-  configure_file(input: file, output: file, copy: true)
+  if meson.version().version_compare('>=0.64.0')
+    fs.copyfile(file)
+  else
+    configure_file(input: file, output: file, copy: true)
+  endif
 
   install_web_files += '@0@:@1@'.format(meson.current_source_dir() / file, docs_html_dir / 'images')
 endforeach
index cbf2dc2633c529a3e42e592d6c1f4d86b074dc42..9f77b0d85c2214599d1dfc79fde06dc9a0c0239f 100644 (file)
@@ -7,7 +7,11 @@ install_data(docs_js_files, install_dir: docs_html_dir / 'js')
 foreach file : docs_js_files
   # This hack enables us to view the web pages
   # from within the uninstalled build tree
-  configure_file(input: file, output: file, copy: true)
+  if meson.version().version_compare('>=0.64.0')
+    fs.copyfile(file)
+  else
+    configure_file(input: file, output: file, copy: true)
+  endif
 
-    install_web_files += '@0@:@1@'.format(meson.current_source_dir() / file, docs_html_dir / 'js')
+  install_web_files += '@0@:@1@'.format(meson.current_source_dir() / file, docs_html_dir / 'js')
 endforeach
index c65fcdd8ed1c1b32158d7ed347dbf249cad013dd..c3f4c9f522c9ff03ebeadb09ba0010ee553b54f0 100644 (file)
@@ -25,7 +25,11 @@ install_data(docs_logo_files, install_dir: docs_html_dir / 'logos')
 foreach file : docs_logo_files
   # This hack enables us to view the web pages
   # from within the uninstalled build tree
-  configure_file(input: file, output: file, copy: true)
+  if meson.version().version_compare('>=0.64.0')
+    fs.copyfile(file)
+  else
+    configure_file(input: file, output: file, copy: true)
+  endif
 
   install_web_files += '@0@:@1@'.format(meson.current_source_dir() / file, docs_html_dir / 'logos')
 endforeach
index 769efe7b6a276ec862ef85a91cb8f64722ae42cf..4945340a1e46bde11fd797ff4a0513d1ef69a62b 100644 (file)
@@ -342,7 +342,11 @@ subdir('manpages')
 foreach file : docs_assets
   # This hack enables us to view the web pages
   # from within the uninstalled build tree
-  configure_file(input: file, output: file, copy: true)
+  if meson.version().version_compare('>=0.64.0')
+    fs.copyfile(file)
+  else
+    configure_file(input: file, output: file, copy: true)
+  endif
 
   install_web_files += '@0@:@1@'.format(meson.current_source_dir() / file, docs_html_dir)
 endforeach
index de087666f574c914e1dcd18728f82dddf9b800c2..d35d5e076b59402fc43b3f64a554ba96e8ad7044 100644 (file)
@@ -11,6 +11,9 @@ project(
   ],
 )
 
+if meson.version().version_compare('>=0.64.0')
+  fs = import('fs')
+endif
 
 # figure out if we are building from git
 
index 72f778043827fd5d9286e07a2a492bebbb589444..57764b0da6337d6cd2afe61912d83cd9a3464681 100644 (file)
@@ -174,7 +174,7 @@ if conf.has('WITH_LIBVIRTD')
     qemu_lockd_conf = configure_file(
       input: 'lockd.conf',
       output: 'qemu-lockd.conf',
-      copy: true,
+      configuration: configmake_conf,
     )
     virt_conf_files += qemu_lockd_conf
     virt_test_aug_files += {
@@ -191,7 +191,7 @@ if conf.has('WITH_LIBVIRTD')
     libxl_lockd_conf = configure_file(
       input: 'lockd.conf',
       output: 'libxl-lockd.conf',
-      copy: true,
+      configuration: configmake_conf,
     )
     virt_conf_files += libxl_lockd_conf
   endif
@@ -203,7 +203,7 @@ if conf.has('WITH_LIBVIRTD')
       qemu_sanlock_conf = configure_file(
         input: 'sanlock.conf',
         output: 'qemu-sanlock.conf',
-        copy: true,
+        configuration: configmake_conf,
       )
       virt_conf_files += qemu_sanlock_conf
       virt_test_aug_files += {
@@ -220,7 +220,7 @@ if conf.has('WITH_LIBVIRTD')
       libxl_sanlock_conf = configure_file(
         input: 'sanlock.conf',
         output: 'libxl-sanlock.conf',
-        copy: true,
+        configuration: configmake_conf,
       )
       virt_conf_files += libxl_sanlock_conf
     endif
index d266bb225a64a189fb179da3411344bce9ced651..0888d1beaca0ef3b4498ddcd9691bbed6cd2e180 100644 (file)
@@ -84,7 +84,7 @@ if conf.has('WITH_NETWORK')
   configure_file(
     input: 'default.xml.in',
     output: '@BASENAME@',
-    copy: true,
+    configuration: configmake_conf,
     install: true,
     install_dir: confdir / 'qemu' / 'networks',
   )