-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Copy pathconanfile.py
81 lines (64 loc) · 3.04 KB
/
conanfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import os
import textwrap
from conan import ConanFile, conan_version
from conan.tools.files import copy, get, rmdir, save, replace_in_file
from conan.tools.layout import basic_layout
from conan.tools.scm import Version
required_conan_version = ">=1.52.0"
class MesonConan(ConanFile):
name = "meson"
description = "a project to create the best possible next-generation build system"
license = "Apache-2.0"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/mesonbuild/meson"
topics = ("mesonbuild", "build-system")
package_type = "application"
no_copy_source = True
def layout(self):
basic_layout(self, src_folder="src")
def requirements(self):
if self.conf.get("tools.meson.mesontoolchain:backend", default="ninja", check_type=str) == "ninja":
# Meson requires >=1.8.2 as of 1.5
# https://github.com/mesonbuild/meson/blob/b6b634ad33e5ca9ad4a9d6139dba4244847cc0e8/mesonbuild/backend/ninjabackend.py#L625
self.requires("ninja/[>=1.10.2 <2]")
def package_id(self):
self.info.clear()
def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)
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
set PYTHONDONTWRITEBYTECODE=1
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")
export PYTHONDONTWRITEBYTECODE=1
exec "$meson_dir/meson.py" "$@"
"""))
def finalize(self):
copy(self, "*", src=self.immutable_package_folder, dst=self.package_folder)
replace_in_file(self, os.path.join(self.package_folder, "bin", "meson.cmd"),
"set PYTHONDONTWRITEBYTECODE=1",
"")
replace_in_file(self, os.path.join(self.package_folder, "bin", "meson"),
"export PYTHONDONTWRITEBYTECODE=1",
"")
@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._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.includedirs = []
self.cpp_info.libdirs = []
if Version(conan_version).major < 2:
self.env_info.PATH.append(meson_root)