On 4/20/23 14:07, Martin Kletzander wrote: > On Thu, Mar 23, 2023 at 05:01:26PM +0100, Michal Privoznik wrote: >> 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 > > Actually, it would be even more clear that it is a dummy configuration > if you used a dict instead of cfg_data. Meson allows this in > configure_file() according to the docs: > > https://mesonbuild.com/Reference-manual_functions.html#configure_file > >> 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@xxxxxxxxxx> >> --- >> docs/css/meson.build | 6 +++++- >> docs/fonts/meson.build | 6 +++++- >> docs/images/meson.build | 6 +++++- >> docs/js/meson.build | 8 ++++++-- >> docs/logos/meson.build | 6 +++++- >> docs/meson.build | 6 +++++- >> meson.build | 3 +++ >> src/locking/meson.build | 8 ++++---- >> src/network/meson.build | 2 +- >> 9 files changed, 39 insertions(+), 12 deletions(-) >> >> diff --git a/src/network/meson.build b/src/network/meson.build >> index d266bb225a..0888d1beac 100644 >> --- a/src/network/meson.build >> +++ b/src/network/meson.build >> @@ -84,7 +84,7 @@ if conf.has('WITH_NETWORK') >> configure_file( >> input: 'default.xml.in', >> output: '@BASENAME@', >> - copy: true, >> + configuration: configmake_conf, > > As mentioned above I'd just use: > > configuration: {}, > > here instead, but honestly, I haven't tried it. That doesn't fly with meson: Configuring default.xml using configuration src/network/meson.build:84: WARNING: Got an empty configuration_data() object and found no substitutions in the input file 'default.xml.in'. If you want to copy a file to the build dir, use the 'copy:' keyword argument added in 0.47.0 So it that's okay with you, I'd like to stick with this patch as is. Michal