forked from kenfred/conan-qwt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconanfile.py
199 lines (172 loc) · 7.6 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
from conans import ConanFile, tools
from conans.util.files import load
from conans.errors import ConanException
import os
import shutil
class QwtConan(ConanFile):
name = "qwt"
# version = "6.1.5", see conandata.yml
license = "LGPL-3.0 with exceptions, http://qwt.sourceforge.net/qwtlicense.html"
# Qwt License, Version 1.0
opt_license = "LGPL-3.0"
url = "https://github.com/sintef-ocean/conan-qwt"
author = "SINTEF Ocean"
homepage = "https://qwt.sourceforge.io"
description = \
"The Qwt library contains GUI Components and utility classes which are "\
"primarily useful for programs with a technical background. Beside a " \
"framework for 2D plots it provides scales, sliders, dials, compasses, "\
"thermometers, wheels and knobs to control or display values, arrays, " \
"or ranges of type double."
topics = ("visualization", "plotting", "qwt", "qt")
settings = "os", "compiler", "build_type", "arch"
options = {
"shared": [True, False],
"plot": [True, False],
"widgets": [True, False],
"svg": [True, False],
"opengl": [True, False],
"mathml": [True, False],
"designer": [True, False],
"examples": [True, False],
"playground": [True, False]
}
default_options = (
"shared=True",
"plot=True",
"widgets=True",
"svg=False",
"opengl=True",
"mathml=False",
"designer=False",
"examples=False",
"playground=False")
generators = ("cmake")
@property
def _qwt_path(self):
return "qwt-{}".format(self.version)
def requirements(self):
if self.settings.compiler == "gcc" \
and self.settings.compiler.version == "6":
self.requires("qt/5.12.8@bincrafters/stable")
else:
self.requires("qt/5.15.2@bincrafters/stable")
self.requires("libffi/3.4.2", override=True)
self.requires("expat/2.4.2", override=True)
def build_requirements(self):
if tools.os_info.is_windows \
and self.settings.compiler == "Visual Studio":
self.build_requires("jom/1.1.3")
def configure(self):
self.options["qt"].qtsvg = self.options.svg
def source(self):
if self.settings.os != "Windows":
platform = 'windows'
else:
platform = 'other'
tools.get(**self.conan_data["sources"][self.version][platform])
src_path = os.path.join(self.source_folder, self._qwt_path)
os.rename(os.path.join(src_path, 'COPYING'),
os.path.join(src_path, 'LICENSE'))
qwt_config_file_path = os.path.join(self.source_folder,
self._qwt_path,
"qwtconfig.pri")
qwt_config = load(qwt_config_file_path)
qwt_config += "\nQWT_CONFIG {}= QwtDLL"\
.format(("+" if self.options.shared else "-"))
qwt_config += "\nQWT_CONFIG {}= QwtPlot"\
.format(("+" if self.options.plot else "-"))
qwt_config += "\nQWT_CONFIG {}= QwtWidgets"\
.format(("+" if self.options.widgets else "-"))
qwt_config += "\nQWT_CONFIG {}= QwtSvg"\
.format(("+" if self.options.svg else "-"))
qwt_config += "\nQWT_CONFIG {}= QwtOpenGL"\
.format(("+" if self.options.opengl else "-"))
qwt_config += "\nQWT_CONFIG {}= QwtMathML"\
.format(("+" if self.options.mathml else "-"))
qwt_config += "\nQWT_CONFIG {}= QwtDesigner"\
.format(("+" if self.options.designer else "-"))
qwt_config += "\nQWT_CONFIG {}= QwtExamples"\
.format(("+" if self.options.examples else "-"))
qwt_config += "\nQWT_CONFIG {}= QwtPlayground"\
.format(("+" if self.options.playground else "-"))
qwt_config = qwt_config.encode("utf-8")
with open(qwt_config_file_path, "wb") as handle:
handle.write(qwt_config)
qwt_build_path = os.path.join(self.source_folder,
self._qwt_path)
os.rename(os.path.join(qwt_build_path, 'qwtbuild.pri'),
os.path.join(qwt_build_path, 'qwtbuild.tmpl'))
def build(self):
qwt_build_string = "CONFIG += {}"\
.format(("release" if self.settings.build_type == "Release"
else "debug"))
qwt_build_file_path = os.path.join(self.source_folder,
self._qwt_path,
'qwtbuild.{}')
shutil.copy(qwt_build_file_path.format('tmpl'),
qwt_build_file_path.format('pri'))
tools.replace_in_file(
qwt_build_file_path.format('pri'),
"CONFIG += release",
qwt_build_string)
tools.replace_in_file(
qwt_build_file_path.format('pri'),
"CONFIG += debug_and_release",
qwt_build_string)
tools.replace_in_file(
qwt_build_file_path.format('pri'),
"CONFIG += build_all", "")
if self.settings.compiler == 'clang':
qwt_build = load(qwt_build_file_path.format('pri'))
qwt_build += "\nQMAKE_CC=clang-{}"\
.format(self.settings.compiler.version)
qwt_build += "\nQMAKE_LINK_C=clang-{}"\
.format(self.settings.compiler.version)
qwt_build += "\nQMAKE_LINK_C_SHLIB=clang-{}"\
.format(self.settings.compiler.version)
qwt_build += "\nQMAKE_CXX=clang++-{}"\
.format(self.settings.compiler.version)
qwt_build += "\nQMAKE_LINK=clang++-{}"\
.format(self.settings.compiler.version)
qwt_build += "\nQMAKE_LINK_SHLIB=clang++-{}"\
.format(self.settings.compiler.version)
qwt_build = qwt_build.encode("utf-8")
with open(qwt_build_file_path.format('pri'), "wb") as handle:
handle.write(qwt_build)
src_path = os.path.join(self.source_folder, self._qwt_path)
if self.settings.os == "Windows":
if self.settings.compiler == "Visual Studio":
with tools.vcvars(self.settings):
self.run("qmake qwt.pro",
cwd=src_path,
run_environment=True)
self.run("jom",
cwd=src_path,
run_environment=True)
else:
raise ConanException("Recipe not implemented for this setting")
else:
self.run("qmake qwt.pro",
cwd=src_path,
run_environment=True)
self.run("make",
cwd=src_path,
run_environment=True)
def package(self):
self.copy("qwt*.h", dst="include",
src=os.path.join("qwt-{}".format(self.version),
"src"))
self.copy("*.lib", dst="lib", keep_path=False)
self.copy("*.pdb", dst="lib", keep_path=False)
self.copy("*.dll", dst="bin", keep_path=False)
self.copy("*.so*", dst="lib", keep_path=False)
self.copy("*.a", dst="lib", keep_path=False)
self.copy("LICENSE", dst="licenses",
src=os.path.join(self.source_folder, self._qwt_path))
def package_info(self):
self.cpp_info.libs = ["qwt"]
if self.settings.build_type == "Debug"\
and self.settings.compiler == "Visual Studio":
self.cpp_info.libs[0] += 'd'
self.cpp_info.name = 'Qwt'