-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconanfile.py
147 lines (125 loc) · 5.33 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
from conans import ConanFile, tools, Meson
import shutil
import os
import platform
class GlibConan(ConanFile):
name = 'glib'
source_version = '2.66.2'
package_version = '0'
version = '%s-%s' % (source_version, package_version)
build_requires = (
'llvm/5.0.2-1@vuo/stable',
'macos-sdk/11.0-0@vuo/stable',
)
requires = (
'libffi/3.4pre-0@vuo/stable',
'gettext/0.21-0@vuo/stable',
)
settings = 'os', 'compiler', 'build_type', 'arch'
url = 'https://github.com/vuo/conan-glib'
license = 'https://developer.gnome.org/glib/stable/glib.html'
description = 'Core application building blocks for GNOME libraries and applications'
source_dir = 'glib-%s' % source_version
generators = 'pkg_config'
build_x86_dir = '_build_x86'
build_arm_dir = '_build_arm'
install_x86_dir = '_install_x86'
install_arm_dir = '_install_arm'
install_universal_dir = '_install_universal_dir'
exports_sources = '*.patch'
def requirements(self):
if platform.system() == 'Linux':
self.requires('patchelf/0.10pre-1@vuo/stable')
elif platform.system() != 'Darwin':
raise Exception('Unknown platform "%s"' % platform.system())
def source(self):
tools.get('https://download.gnome.org/sources/glib/2.66/glib-%s.tar.xz' % self.source_version,
sha256='ec390bed4e8dd0f89e918f385e8d4cfd7470b1ef7c1ce93ec5c4fc6e3c6a17c4')
self.run('mv %s/COPYING %s/%s.txt' % (self.source_dir, self.source_dir, self.name))
def imports(self):
self.copy('*', self.build_x86_dir, 'lib')
self.copy('*', self.build_arm_dir, 'lib')
def build(self):
defs = {
'nls' : 'disabled',
'glib_assert' : 'false',
'glib_checks' : 'false',
'xattr' : 'false',
'libmount' : 'disabled',
'selinux' : 'disabled',
'internal_pcre': 'true',
}
flags = '-isysroot %s' % self.deps_cpp_info['macos-sdk'].rootpath
flags += ' -mmacosx-version-min=10.11'
self.output.info("=== Build for x86_64 ===")
with tools.environment_append({
'CC' : self.deps_cpp_info['llvm'].rootpath + '/bin/clang',
'CXX' : self.deps_cpp_info['llvm'].rootpath + '/bin/clang++',
'CFLAGS' : flags,
'CPPFLAGS': flags,
'LDFLAGS' : flags,
}):
meson = Meson(self)
defs_x86 = defs.copy()
defs_x86['prefix'] = '%s/%s' % (os.getcwd(), self.install_x86_dir)
meson.configure(
source_folder=self.source_dir,
build_folder=self.build_x86_dir,
defs=defs_x86)
meson.build()
meson.meson_install()
self.output.info("=== Build for arm64 ===")
flags += ' -arch arm64 -target arm64-apple-macos10.11.0'
with tools.environment_append({
'CC' : self.deps_cpp_info['llvm'].rootpath + '/bin/clang',
'CXX' : self.deps_cpp_info['llvm'].rootpath + '/bin/clang++',
'CFLAGS' : flags,
'CPPFLAGS': flags,
'LDFLAGS' : flags,
}):
with open('arm64.txt', 'w') as fd:
fd.write("""
[binaries]
c = 'clang'
cpp = 'clang++'
objc = 'clang'
ar = 'ar'
ld = 'clang++'
pkgconfig = 'pkg-config'
strip = 'strip'
[host_machine]
system = 'darwin'
cpu_family = 'arm'
cpu = 'arm64'
endian = 'little'
""")
meson = Meson(self)
defs_arm = defs.copy()
defs_arm['prefix'] = '%s/%s' % (os.getcwd(), self.install_arm_dir)
meson.configure(
source_folder=self.source_dir,
build_folder=self.build_arm_dir,
args=[
'--cross-file=arm64.txt',
],
defs=defs_arm)
meson.build()
meson.meson_install()
def package(self):
if platform.system() == 'Darwin':
libext = 'dylib'
elif platform.system() == 'Linux':
libext = 'so'
else:
raise Exception('Unknown platform "%s"' % platform.system())
self.run('install_name_tool -id @rpath/libglib.dylib %s/lib/libglib-2.0.0.dylib' % self.install_x86_dir)
self.run('install_name_tool -id @rpath/libglib.dylib %s/lib/libglib-2.0.0.dylib' % self.install_arm_dir)
tools.mkdir(self.install_universal_dir)
with tools.chdir(self.install_universal_dir):
self.run('lipo -create ../%s/lib/libglib-2.0.0.%s ../%s/lib/libglib-2.0.0.%s -output libglib.%s' % (self.install_x86_dir, libext, self.install_arm_dir, libext, libext))
self.copy('*.h', src='%s/lib/glib-2.0/include' % self.install_x86_dir, dst='include')
self.copy('*.h', src='%s/include/glib-2.0' % self.install_x86_dir, dst='include')
self.copy('libglib.%s' % libext, src=self.install_universal_dir, dst='lib')
self.copy('%s.txt' % self.name, src=self.source_dir, dst='license')
def package_info(self):
self.cpp_info.libs = ['glib']