Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Meson] Using --destdir variable #15706

Merged
merged 4 commits into from
Feb 27, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions conan/tools/meson/meson.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import platform

from conan.tools.build import build_jobs
from conan.tools.meson.toolchain import MesonToolchain
Expand All @@ -10,6 +11,9 @@ def __init__(self, conanfile):
self._conanfile = conanfile

def configure(self, reconfigure=False):
if reconfigure:
self._conanfile.output.warning("reconfigure param has been deprecated."
" Removing in Conan 2.x.")
source_folder = self._conanfile.source_folder
build_folder = self._conanfile.build_folder
cmd = "meson setup"
Expand All @@ -35,10 +39,8 @@ def configure(self, reconfigure=False):

cmd += "".join([f'{cmd_param} "{meson_option}"' for meson_option in meson_filenames])
cmd += ' "{}" "{}"'.format(build_folder, source_folder)
if self._conanfile.package_folder:
cmd += ' -Dprefix="{}"'.format(self._conanfile.package_folder)
if reconfigure:
cmd += ' --reconfigure'
# Issue related: https://github.com/mesonbuild/meson/issues/12880
cmd += ' --prefix=/' # this must be an absolute path, otherwise, meson complains
self._conanfile.output.info("Meson configure cmd: {}".format(cmd))
self._conanfile.run(cmd)

Expand All @@ -54,9 +56,13 @@ def build(self, target=None):
self._conanfile.run(cmd)

def install(self):
self.configure(reconfigure=True) # To re-do the destination package-folder
meson_build_folder = self._conanfile.build_folder
cmd = 'meson install -C "{}"'.format(meson_build_folder)
meson_build_folder = self._conanfile.build_folder.replace("\\", "/")
meson_package_folder = self._conanfile.package_folder.replace("\\", "/")
# TODO: Use --destdir [package_folder] param when requiring meson >= 0.57.
franramirez688 marked this conversation as resolved.
Show resolved Hide resolved
if platform.system() == "Windows":
cmd = f'set "DESTDIR={meson_package_folder}" && meson install -C "{meson_build_folder}"'
else:
cmd = f'DESTDIR="{meson_package_folder}" meson install -C "{meson_build_folder}"'
self._conanfile.run(cmd)

def test(self):
Expand Down