Skip to content

Commit d0366bf

Browse files
committed
meson: windows: Determine path to tmp_install + prefix using meson
Previously some paths (like c:\ or d:/) worked, but plenty others (like /path/to or //computer/share/path) didn't. As we'd like to change the default prefix to /usr/local/pgsql, that's a problem. Instead of trying to do this in meson.build, call out to the implementation meson install uses. This isn't pretty, but it's more reliable than what we had before. Discussion: https://postgr.es/CAEG8a3LGWE-gG6vuddmH91RORhi8gWs0mMB-hcTmP3_NVgM7dg@mail.gmail.com
1 parent a9d58bf commit d0366bf

File tree

1 file changed

+16
-24
lines changed

1 file changed

+16
-24
lines changed

meson.build

+16-24
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ fs = import('fs')
2929
pkgconfig = import('pkgconfig')
3030

3131
host_system = host_machine.system()
32+
build_system = build_machine.system()
3233
host_cpu = host_machine.cpu_family()
3334

3435
cc = meson.get_compiler('c')
@@ -2748,32 +2749,23 @@ endif
27482749
# Test prep
27492750
###############################################################
27502751

2751-
# The determination of where a DESTDIR install points to is ugly, it's somewhat hard
2752-
# to combine two absolute paths portably...
2753-
2754-
prefix = get_option('prefix')
2755-
2756-
test_prefix = fs.as_posix(prefix)
2757-
2758-
if fs.is_absolute(get_option('prefix'))
2759-
if host_system == 'windows'
2760-
if prefix.split(':/').length() == 1
2761-
# just a drive
2762-
test_prefix = ''
2763-
else
2764-
test_prefix = prefix.split(':/')[1]
2765-
endif
2766-
else
2767-
assert(prefix.startswith('/'))
2768-
test_prefix = './@0@'.format(prefix)
2769-
endif
2770-
endif
2771-
2772-
# DESTDIR for the installation used to run tests in
2752+
# DESTDIR for the installation we'll run tests in
27732753
test_install_destdir = meson.build_root() / 'tmp_install/'
2774-
# DESTDIR + prefix appropriately munged
2775-
test_install_location = test_install_destdir / test_prefix
27762754

2755+
# DESTDIR + prefix appropriately munged
2756+
if build_system != 'windows'
2757+
# On unixoid systems this is trivial, we just prepend the destdir
2758+
assert(dir_prefix.startswith('/')) # enforced by meson
2759+
test_install_location = '@0@@1@'.format(test_install_destdir, dir_prefix)
2760+
else
2761+
# drives, drive-relative paths, etc make this complicated on windows, call
2762+
# meson's logic for it
2763+
command = [
2764+
meson_bin, meson_args, 'runpython', '-c',
2765+
'import sys; from mesonbuild.scripts import destdir_join; print(destdir_join(sys.argv[4], sys.argv[5]))',
2766+
test_install_destdir, dir_prefix]
2767+
test_install_location = run_command(command, check: true).stdout().strip()
2768+
endif
27772769

27782770
meson_install_args = meson_args + ['install'] + {
27792771
'meson': ['--quiet', '--only-changed', '--no-rebuild'],

0 commit comments

Comments
 (0)