This repository has been archived by the owner on Jul 19, 2021. It is now read-only.
/
conanfile.py
103 lines (86 loc) · 3.81 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
import os
import shutil
from conans import ConanFile, CMake, tools
class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch", "os_build", "arch_build"
generators = "qt"
def build_requirements(self):
if tools.os_info.is_windows and self.settings.compiler == "Visual Studio":
self.build_requires("jom_installer/1.1.2@bincrafters/stable")
def _build_with_qmake(self):
tools.mkdir("qmake_folder")
with tools.chdir("qmake_folder"):
self.output.info("Building with qmake")
def _qmakebuild():
args = [self.source_folder]
def _getenvpath(var):
val = os.getenv(var)
if val and tools.os_info.is_windows:
val = val.replace("\\", "/")
os.environ[var] = val
return val
value = _getenvpath('CC')
if value:
args += ['QMAKE_CC=' + value,
'QMAKE_LINK_C=' + value,
'QMAKE_LINK_C_SHLIB=' + value]
value = _getenvpath('CXX')
if value:
args += ['QMAKE_CXX=' + value,
'QMAKE_LINK=' + value,
'QMAKE_LINK_SHLIB=' + value]
self.run("qmake %s" % " ".join(args), run_environment=True)
if tools.os_info.is_windows:
if self.settings.compiler == "Visual Studio":
self.run("jom", run_environment=True)
else:
self.run("mingw32-make", run_environment=True)
else:
self.run("make", run_environment=True)
if self.settings.compiler == "Visual Studio":
with tools.vcvars(self.settings):
_qmakebuild()
else:
_qmakebuild()
def _build_with_cmake(self):
if not self.options["qt"].shared:
self.output.info(
"disabled cmake test with static Qt, because of https://bugreports.qt.io/browse/QTBUG-38913")
else:
self.output.info("Building with CMake")
cmake = CMake(self)
cmake.configure()
cmake.build()
def build(self):
self._build_with_qmake()
self._build_with_cmake()
def _test_with_qmake(self):
self.output.info("Testing qmake")
if tools.os_info.is_windows:
bin_path = str(self.settings.build_type).lower()
elif tools.os_info.is_linux:
bin_path = "."
else:
bin_path = os.path.join("test_package.app", "Contents", "MacOS")
bin_path = os.path.join("qmake_folder", bin_path)
shutil.copy("qt.conf", bin_path)
self.run(os.path.join(bin_path, "test_package"), run_environment=True)
def _test_with_cmake(self):
if not self.options["qt"].shared:
self.output.info(
"disabled cmake test with static Qt, because of https://bugreports.qt.io/browse/QTBUG-38913")
else:
self.output.info("Testing CMake")
if self.settings.compiler == "Visual Studio":
bin_path = str(self.settings.build_type)
else:
bin_path = self.build_folder
self.run(os.path.join(bin_path, "test_package"), run_environment=True)
def test(self):
if (not tools.cross_building(self.settings)) or\
(self.settings.os_build == self.settings.os and self.settings.arch_build == "x86_64" and self.settings.arch == "x86"):
self._test_with_qmake()
self._test_with_cmake()