Skip to content

Commit

Permalink
[Meson] Using --destdir variable (conan-io#15706)
Browse files Browse the repository at this point in the history
* Removed reconfigure step. Deprecated reconfigure param. Using DESTDIR variable

* Missing build folder slash replacement

* Adding prefix also for Windows

* Simplified. Requiring meson >= 0.57.0
  • Loading branch information
franramirez688 authored Feb 27, 2024
1 parent f71f2d1 commit 4932c50
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions conan/tools/meson/meson.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import os

from conan.tools.build import build_jobs
from conan.tools.meson.toolchain import MesonToolchain
from conan.tools.meson.mesondeps import MesonDeps
from conan.tools.meson.toolchain import MesonToolchain


class Meson(object):
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 +38,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 +55,10 @@ 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("\\", "/")
# Assuming meson >= 0.57.0
cmd = f'meson install -C "{meson_build_folder}" --destdir "{meson_package_folder}"'
self._conanfile.run(cmd)

def test(self):
Expand Down

0 comments on commit 4932c50

Please sign in to comment.