Skip to content

Commit

Permalink
(#12727) meson: add 0.63.2 + conan v2 support
Browse files Browse the repository at this point in the history
* conan v2 support

* drop meson < 0.55.0

these versions are not compatible with MesonToolchain generator of conan v2

* tool_requires in test_package

* add meson/0.63.2
  • Loading branch information
SpaceIm authored Sep 8, 2022
1 parent c9e7c6e commit c394ece
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 197 deletions.
135 changes: 36 additions & 99 deletions recipes/meson/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,103 +1,40 @@
sources:
# "0.51.0":
# url: "https://github.com/mesonbuild/meson/archive/0.51.0.tar.gz"
# sha256: "ec1e3942215a858d82c3d2e095d18adcf1ede94a34144662643d88db4dcb5263"
"0.51.2":
url: "https://github.com/mesonbuild/meson/archive/0.51.2.tar.gz"
sha256: "96871cf62c9cf2b212e2f38aa3e543323403b1314fd3835e14120ef837c00f01"
# "0.52.0":
# url: "https://github.com/mesonbuild/meson/archive/0.52.0.tar.gz"
# sha256: "0f426ed1362c38bcc5b9027ec6aec3445d6db88e8d7249ed992e9af88a42d0e0"
"0.52.1":
url: "https://github.com/mesonbuild/meson/archive/0.52.1.tar.gz"
sha256: "ad8dbad61d4c22cb7d768cb1f8a212b4abf0f3fbc17c298d816140ecd9f5d1df"
# "0.53.0":
# url: "https://github.com/mesonbuild/meson/archive/0.53.0.tar.gz"
# sha256: "cc15f416d0b538fb079c15a59ee2cd106895ca115fa5d654731a695c85c992fc"
# "0.53.1":
# url: "https://github.com/mesonbuild/meson/archive/0.53.1.tar.gz"
# sha256: "f69ff8ce6cb52cbfb9bcc844086fade76920a292a017e68201317eeacd3ab943"
"0.53.2":
url: "https://github.com/mesonbuild/meson/archive/0.53.2.tar.gz"
sha256: "eab4f5d5dde12d002b7ddd958a9a0658589b63622b6cea2715e0235b95917888"
# "0.54.0":
# url: "https://github.com/mesonbuild/meson/archive/0.54.0.tar.gz"
# sha256: "95efdbaa7cb3e915ab9a7b26b1412475398fdc3e834842a780f1646c7764f2d9"
# "0.54.1":
# url: "https://github.com/mesonbuild/meson/archive/0.54.1.tar.gz"
# sha256: "854e8b94ab36e5aece813d2b2aee8a639bd52201dfea50890722ac9128e2f59e"
# "0.54.2":
# url: "https://github.com/mesonbuild/meson/archive/0.54.2.tar.gz"
# sha256: "85cafdc70ae7d1d9d506e7356b917c649c4df2077bd6a0382db37648aa4ecbdb"
"0.54.3":
url: "https://github.com/mesonbuild/meson/archive/0.54.3.tar.gz"
sha256: "c25caff342b5368bfe33fab6108f454fcf12e2f2cef70817205872ddef669e8b"
# "0.55.0":
# url: "https://github.com/mesonbuild/meson/archive/0.55.0.tar.gz"
# sha256: "9034c943c8cf4d734c0e18e5ba038dd762fcdcc614c45b41703305da8382e90c"
# "0.55.1":
# url: "https://github.com/mesonbuild/meson/archive/0.55.1.tar.gz"
# sha256: "c7ebf2fff5934a974c7edd1aebb5fc9c3e1da5ae3184a29581fde917638eea39"
# "0.55.2":
# url: "https://github.com/mesonbuild/meson/archive/0.55.2.tar.gz"
# sha256: "56244896e56c2b619f819d047b6de412ecc5250975ee8717f1e329113d178e06"
"0.55.3":
url: "https://github.com/mesonbuild/meson/archive/0.55.3.tar.gz"
sha256: "2b276df50c5b13ccdbfb14d3333141e9e7985aca31b60400b3f3e0be2ee6897e"
# "0.56.0":
# url: "https://github.com/mesonbuild/meson/archive/0.56.0.tar.gz"
# sha256: "a9ca7adf66dc69fbb7e583f7c7aef16b9fe56ec2874a3d58747e69a3affdf300"
# "0.56.1":
# url: "https://github.com/mesonbuild/meson/archive/0.56.1.tar.gz"
# sha256: "db3545231bb8f3ae3186a1a0f49f0acd239724af91781b783e843b80400f10ec"
"0.56.2":
url: "https://github.com/mesonbuild/meson/archive/0.56.2.tar.gz"
sha256: "aaae961c3413033789248ffe6762589e80b6cf487c334d0b808e31a32c48f35f"
# "0.57.0":
# url: "https://github.com/mesonbuild/meson/archive/0.57.0.tar.gz"
# sha256: "fd26a27c1a509240c668ebd29d280649d9239cf8684ead51d5cb499d1e1188bd"
# "0.57.1":
# url: "https://github.com/mesonbuild/meson/archive/0.57.1.tar.gz"
# sha256: "0c043c9b5350e9087cd4f6becf6c0d10b1d618ca3f919e0dcca2cdf342360d5d"
"0.57.2":
url: "https://github.com/mesonbuild/meson/archive/0.57.2.tar.gz"
sha256: "cd3773625253df4fd1c380faf03ffae3d02198d6301e7c8bc7bba6c66af66096"
# "0.58.0":
# url: "https://github.com/mesonbuild/meson/archive/0.58.0.tar.gz"
# sha256: "991b882bfe4d37acc23c064a29ca209458764a580d52f044f3d50055a132bed4"
"0.58.1":
url: "https://github.com/mesonbuild/meson/archive/0.58.1.tar.gz"
sha256: "78e0f553dd3bc632d5f96ab943b1bbccb599c2c84ff27c5fb7f7fff9c8a3f6b4"
# "0.59.0":
# url: "https://github.com/mesonbuild/meson/archive/0.59.0.tar.gz"
# sha256: "fdbbe8ea8a47f9e21cf4f578f85be8ec3d9c030df3d8cb17df1ae59d8683813a"
# "0.59.1":
# url: "https://github.com/mesonbuild/meson/archive/0.59.1.tar.gz"
# sha256: "f256eb15329a6064f8cc1f23b29de1fa8d21e324f939041e1a4efe77cf1362ef"
# "0.59.2":
# url: "https://github.com/mesonbuild/meson/archive/0.59.2.tar.gz"
# sha256: "e6d5ccd503d41f938f6cfc4dc9e7326ffe28acabe091b1ff0c6535bdf09732dd"
"0.59.3":
url: "https://github.com/mesonbuild/meson/archive/0.59.3.tar.gz"
sha256: "b2c5bfd5032189a66cf6a32d98ba82d94d7d314577d8efe4d9dc159c4073f282"
"0.60.2":
url: "https://github.com/mesonbuild/meson/archive/0.60.2.tar.gz"
sha256: "fc7c2f315b5b63fee0414b0b94b5a7d0e9c71c8c9bb8487314eb5a9a33984b8d"
"0.61.2":
url: "https://github.com/mesonbuild/meson/archive/0.61.2.tar.gz"
sha256: "33cd555314a94d52acfbb3f6f44d4e61c4ad0bfec7acf4301be7e40bb969b3a8"
"0.62.0":
url: "https://github.com/mesonbuild/meson/archive/0.62.0.tar.gz"
sha256: "72ac3bab701dfd597604de29cc74baaa1cc0ad8ca26ae23d5288de26abfe1c80"
"0.62.1":
url: "https://github.com/mesonbuild/meson/archive/0.62.1.tar.gz"
sha256: "9fb52e66dbc613479a5f70e46cc2e8faf5aa65e09313f2c71fa63b8afd018107"
0.62.2:
sha256: "97108f4d9bb16bc758c44749bd25ec7d42c6a762961efbed8b7589a2a3551ea6"
url: "https://github.com/mesonbuild/meson/archive/0.62.2.tar.gz"
"0.63.0":
url: "https://github.com/mesonbuild/meson/archive/0.63.0.tar.gz"
sha256: "77808d47fa05875c2553d66cb6c6140c2f687b46256dc537eeb8a63889e0bea2"
"0.63.2":
url: "https://github.com/mesonbuild/meson/archive/0.63.2.tar.gz"
sha256: "023a3f7c74e68991154c3205a6975705861eedbf8130e013d15faa1df1af216e"
"0.63.1":
url: "https://github.com/mesonbuild/meson/archive/0.63.1.tar.gz"
sha256: "f355829f0e8c714423f03a06604c04c216d4cbe3586f3154cb2181076b19207a"
"0.63.0":
url: "https://github.com/mesonbuild/meson/archive/0.63.0.tar.gz"
sha256: "77808d47fa05875c2553d66cb6c6140c2f687b46256dc537eeb8a63889e0bea2"
"0.62.2":
url: "https://github.com/mesonbuild/meson/archive/0.62.2.tar.gz"
sha256: "97108f4d9bb16bc758c44749bd25ec7d42c6a762961efbed8b7589a2a3551ea6"
"0.62.1":
url: "https://github.com/mesonbuild/meson/archive/0.62.1.tar.gz"
sha256: "9fb52e66dbc613479a5f70e46cc2e8faf5aa65e09313f2c71fa63b8afd018107"
"0.62.0":
url: "https://github.com/mesonbuild/meson/archive/0.62.0.tar.gz"
sha256: "72ac3bab701dfd597604de29cc74baaa1cc0ad8ca26ae23d5288de26abfe1c80"
"0.61.2":
url: "https://github.com/mesonbuild/meson/archive/0.61.2.tar.gz"
sha256: "33cd555314a94d52acfbb3f6f44d4e61c4ad0bfec7acf4301be7e40bb969b3a8"
"0.60.2":
url: "https://github.com/mesonbuild/meson/archive/0.60.2.tar.gz"
sha256: "fc7c2f315b5b63fee0414b0b94b5a7d0e9c71c8c9bb8487314eb5a9a33984b8d"
"0.59.3":
url: "https://github.com/mesonbuild/meson/archive/0.59.3.tar.gz"
sha256: "b2c5bfd5032189a66cf6a32d98ba82d94d7d314577d8efe4d9dc159c4073f282"
"0.58.1":
url: "https://github.com/mesonbuild/meson/archive/0.58.1.tar.gz"
sha256: "78e0f553dd3bc632d5f96ab943b1bbccb599c2c84ff27c5fb7f7fff9c8a3f6b4"
"0.57.2":
url: "https://github.com/mesonbuild/meson/archive/0.57.2.tar.gz"
sha256: "cd3773625253df4fd1c380faf03ffae3d02198d6301e7c8bc7bba6c66af66096"
"0.56.2":
url: "https://github.com/mesonbuild/meson/archive/0.56.2.tar.gz"
sha256: "aaae961c3413033789248ffe6762589e80b6cf487c334d0b808e31a32c48f35f"
"0.55.3":
url: "https://github.com/mesonbuild/meson/archive/0.55.3.tar.gz"
sha256: "2b276df50c5b13ccdbfb14d3333141e9e7985aca31b60400b3f3e0be2ee6897e"
78 changes: 47 additions & 31 deletions recipes/meson/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,76 +1,92 @@
from conans import ConanFile, tools
from conan import ConanFile
from conan.tools.files import copy, get, rmdir, save
from conan.tools.layout import basic_layout
import os
import textwrap

required_conan_version = ">=1.33.0"
required_conan_version = ">=1.50.0"


class MesonInstallerConan(ConanFile):
class MesonConan(ConanFile):
name = "meson"
description = "Meson is a project to create the best possible next-generation build system"
topics = ("meson", "mesonbuild", "build-system")
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/mesonbuild/meson"
license = "Apache-2.0"
settings = "os", "arch", "compiler", "build_type"
no_copy_source = True

_source_subfolder = "source_subfolder"
@property
def _settings_build(self):
return getattr(self, "settings_build", self.settings)

def requirements(self):
self.requires("ninja/1.10.2")
self.requires("ninja/1.11.0")

def package_id(self):
self.info.header_only()
self.info.clear()

def source(self):
tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder)
def layout(self):
basic_layout(self, src_folder="src")

# create wrapper scripts
tools.save(os.path.join(self._source_subfolder, "meson.cmd"), textwrap.dedent("""\
@echo off
CALL python %~dp0/meson.py %*
"""))
tools.save(os.path.join(self._source_subfolder, "meson"), textwrap.dedent("""\
#!/usr/bin/env bash
meson_dir=$(dirname "$0")
exec "$meson_dir/meson.py" "$@"
"""))

@staticmethod
def _chmod_plus_x(filename):
if os.name == "posix":
os.chmod(filename, os.stat(filename).st_mode | 0o111)
def source(self):
get(self, **self.conan_data["sources"][self.version],
destination=self.source_folder, strip_root=True)

def package(self):
# FIXME: https://github.com/conan-io/conan/issues/10726
def _fix_symlinks(root, files):
if not tools.os_info.is_windows:
if not self._settings_build.os == "Windows":
return
for filename in files:
filename = os.path.join(root, filename)
if os.path.islink(filename):
target = os.readlink(filename)
if "/" in target:
self.output.info("fixing broken link {}".format(target))
self.output.info(f"fixing broken link {target}")
target = target.replace("/", "\\")
os.unlink(filename)
os.symlink(target, filename)

for root, dirs, files in os.walk(self.source_folder, self._source_subfolder):
for root, dirs, files in os.walk(self.source_folder):
_fix_symlinks(root, dirs)
_fix_symlinks(root, files)
self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder)
self.copy(pattern="*", dst="bin", src=self._source_subfolder)
tools.rmdir(os.path.join(self.package_folder, "bin", "test cases"))

def build(self):
pass

def package(self):
copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
copy(self, "*", src=self.source_folder, dst=os.path.join(self.package_folder, "bin"))
rmdir(self, os.path.join(self.package_folder, "bin", "test cases"))

# create wrapper scripts
save(self, os.path.join(self.package_folder, "bin", "meson.cmd"), textwrap.dedent("""\
@echo off
CALL python %~dp0/meson.py %*
"""))
save(self, os.path.join(self.package_folder, "bin", "meson"), textwrap.dedent("""\
#!/usr/bin/env bash
meson_dir=$(dirname "$0")
exec "$meson_dir/meson.py" "$@"
"""))

@staticmethod
def _chmod_plus_x(filename):
if os.name == "posix":
os.chmod(filename, os.stat(filename).st_mode | 0o111)

def package_info(self):
meson_root = os.path.join(self.package_folder, "bin")
self.output.info("Appending PATH environment variable: {}".format(meson_root))
self.output.info(f"Appending PATH environment variable: {meson_root}")
self.env_info.PATH.append(meson_root)

self._chmod_plus_x(os.path.join(meson_root, "meson"))
self._chmod_plus_x(os.path.join(meson_root, "meson.py"))

self.cpp_info.builddirs = [os.path.join("bin", "mesonbuild", "cmake", "data")]

self.cpp_info.frameworkdirs = []
self.cpp_info.includedirs = []
self.cpp_info.libdirs = []
self.cpp_info.resdirs = []
33 changes: 20 additions & 13 deletions recipes/meson/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
from conans import ConanFile, Meson, tools
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.layout import basic_layout
from conan.tools.meson import Meson
import os


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "pkg_config"
settings = "os", "arch", "compiler", "build_type"
generators = "MesonToolchain", "VirtualBuildEnv", "VirtualRunEnv"
test_type = "explicit"

def build_requirements(self):
self.tool_requires(self.tested_reference_str)

def layout(self):
basic_layout(self)

def build(self):
if not tools.cross_building(self):
with tools.environment_append(tools.RunEnvironment(self).vars):
meson = Meson(self)
meson.configure(build_folder="build")
meson.build()
meson = Meson(self)
meson.configure()
meson.build()

def test(self):
if not tools.cross_building(self):
bin_path = os.path.join("build", "test_package")
self.run(bin_path, run_environment=True)

self.run("meson --version", run_environment=True)
self.run("meson --version")
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")
22 changes: 22 additions & 0 deletions recipes/meson/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from conans import ConanFile, Meson, tools
import os


class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
test_type = "explicit"

def build_requirements(self):
self.build_requires(self.tested_reference_str)

def build(self):
if not tools.cross_building(self):
meson = Meson(self)
meson.configure(build_folder="build")
meson.build()

def test(self):
self.run("meson --version")
if not tools.cross_building(self):
bin_path = os.path.join("build", "test_package")
self.run(bin_path, run_environment=True)
2 changes: 2 additions & 0 deletions recipes/meson/all/test_v1_package/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
project('test_package', 'cpp')
executable('test_package', '../test_package/test_package.cpp')
Loading

0 comments on commit c394ece

Please sign in to comment.