Meson: Use mklink on Windows to create the srcdir link

Create the directory symlink '<builddir>/test/srcdir' -> '<sourcedir>'
as done on UNIX. Invoke mklink /J to create a junction, which doesn't
require developer mode nor admin rights.

Note: we might also set the srcdir environment variable [1]

[1] https://gitlab.freedesktop.org/cairo/cairo/-/blob/1.18.4/test/cairo-test.c?ref_type=tags#L198
This commit is contained in:
Luca Bacci 2025-02-04 11:54:03 +01:00
parent 04656d7450
commit 0ca7d6e6a2

View file

@ -670,6 +670,14 @@ if build_machine.system() != 'windows'
meson.current_source_dir(),
meson.current_build_dir() / 'srcdir',
check: true)
elif not fs.exists(meson.current_build_dir() / 'srcdir')
cmd = find_program(find_program('cmd').full_path().replace('/', '\\'))
run_command(cmd, '/C', 'mklink', '/j', '%LINK%', '%TARGET%',
env: [
'LINK="@0@"'.format(meson.current_build_dir() / 'srcdir'),
'TARGET="@0@"'.format(meson.current_source_dir()),
],
check: true)
endif
if ttx.found()