meson/megadriver: Add megadriver_libdir argument

To be able to install symlinks to megadriver in different directory.

Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31079>
This commit is contained in:
David Rosca 2024-09-08 10:45:30 +02:00 committed by Marge Bot
parent 7ebb2d1dc8
commit 39f7ed5412

View File

@ -26,21 +26,29 @@ import argparse
import os
def resolve_libdir(libdir):
if os.path.isabs(libdir):
destdir = os.environ.get('DESTDIR')
if destdir:
return os.path.join(destdir, libdir[1:])
else:
return libdir
return os.path.join(os.environ['MESON_INSTALL_DESTDIR_PREFIX'], libdir)
def main():
parser = argparse.ArgumentParser()
parser.add_argument('megadriver')
parser.add_argument('libdir')
parser.add_argument('drivers', nargs='+')
parser.add_argument('--megadriver_libdir')
args = parser.parse_args()
if os.path.isabs(args.libdir):
destdir = os.environ.get('DESTDIR')
if destdir:
to = os.path.join(destdir, args.libdir[1:])
else:
to = args.libdir
to = resolve_libdir(args.libdir)
if args.megadriver_libdir:
md_to = resolve_libdir(args.megadriver_libdir)
else:
to = os.path.join(os.environ['MESON_INSTALL_DESTDIR_PREFIX'], args.libdir)
md_to = to
basename = os.path.basename(args.megadriver)
master = os.path.join(to, basename)
@ -55,8 +63,11 @@ def main():
if os.path.lexists(abs_driver):
os.unlink(abs_driver)
print(f'Installing symlink pointing to {basename} to {abs_driver}')
os.symlink(basename, abs_driver)
symlink = os.path.relpath(os.path.join(md_to, basename), start=to)
print(f'Installing symlink pointing to {symlink} to {abs_driver}')
os.symlink(symlink, abs_driver)
try:
ret = os.getcwd()