Hello!
Accidentally I found that shared libraries autoinc.so and refint.so
rewrites in the "tmp_install" folder during the regression tests.
This happens because these libraries builds again for regression tests
purposes and rewrites by the "install_test_files" test [0].
I tried to change this bahavior, but there are few problems:
It seems, Meson doesn't have a function to just copy a file from one
build directory to another.
There is no way to install the product of the "shared_module()" function
into the two different locations.
"configure_file()" function in "copy mode" runs at setup time and cannot
be used.
"fs.copyfile()" function runs at build time, but I couldn't find the way
to start it after the building of necessary modules. So this function
fails with the "file not found" error. Also it needs the Meson version
>= 0.64
And also there is no single cross platform copy program. I tried to use
"cp" on Linux and "cmd /c copy..." on Windows, but the code has
increased in size very much. Especially, after fixing the slash in the
return value of the "meson.current_build_dir()" function on Windows.
That slash arrives from the "subdir('src/test')" call [1].
To avoid double building of autoinc and refint libraries I suggest to
use the "custom_target()" Meson function and own copy program. The
"custom_target()" function can depends on contrib modules and use any
script to just a copy libraries to the regression tests build directory.
I included the patch which adds copy.py script into the regression tests
directory and uses it to "build" autoinc and refint modules.
What do you think?
Thanks!
Best regards, Roman Zharkov.
[0]
https://github.com/postgres/postgres/blob/f95da9f0e091ddbc5d50ec6c11be772da009b24e/src/test/regress/meson.build#L46
[1]
https://github.com/postgres/postgres/blob/f95da9f0e091ddbc5d50ec6c11be772da009b24e/meson.build#L3095diff --git a/src/test/regress/copy.py b/src/test/regress/copy.py
new file mode 100644
index 0000000000000000000000000000000000000000..9996e64474649855606a8968cf2f3129e792042f
--- /dev/null
+++ b/src/test/regress/copy.py
@@ -0,0 +1,9 @@
+#! /usr/bin/env python3
+
+import sys
+import shutil
+
+if len(sys.argv) == 3:
+ shutil.copy(sys.argv[1], sys.argv[2])
+else:
+ raise Exception("this homemade copy program accepts two arguments")
diff --git a/src/test/regress/meson.build b/src/test/regress/meson.build
index 5a9be73531e9c38595d7aabbd1b17d0d94c2a8fd..df010b7dc02bf46cfb2bc8c1a2df47fd83f1b598 100644
--- a/src/test/regress/meson.build
+++ b/src/test/regress/meson.build
@@ -43,23 +43,19 @@ regress_module = shared_module('regress',
)
test_install_libs += regress_module
-# Get some extra C modules from contrib/spi but mark them as not to be
-# installed.
-# FIXME: avoid the duplication.
-
-autoinc_regress = shared_module('autoinc',
- ['../../../contrib/spi/autoinc.c'],
- kwargs: pg_test_mod_args,
+autoinc_regress = custom_target('autoinc',
+ command: ['copy.py', autoinc.full_path(), meson.current_build_dir()],
+ output: fs.name(autoinc.full_path()),
+ depends: [autoinc],
+ build_by_default: true,
)
-test_install_libs += autoinc_regress
-refint_regress = shared_module('refint',
- ['../../../contrib/spi/refint.c'],
- c_args: refint_cflags,
- kwargs: pg_test_mod_args,
+refint_regress = custom_target('refint',
+ command: ['copy.py', refint.full_path(), meson.current_build_dir()],
+ output: fs.name(refint.full_path()),
+ depends: [refint],
+ build_by_default: true,
)
-test_install_libs += refint_regress
-
tests += {
'name': 'regress',