-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconanfile.py
120 lines (102 loc) · 4.83 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
import os
from conans import ConanFile, CMake, tools
from conans.errors import ConanException
class XmsinterpConan(ConanFile):
name = "xmsmesh"
# version = None # This no longer worked after conan version 1.11
license = "BSD2"
url = "https://github.com/Aquaveo/xmsmesh"
description = "Meshing library for XMS products"
settings = "os", "compiler", "build_type", "arch"
options = {
"xms": [True, False],
"pybind": [True, False],
"testing": [True, False],
}
default_options = "xms=False", "pybind=False", "testing=False"
generators = "cmake"
build_requires = "cxxtest/4.4@aquaveo/stable"
exports = "CMakeLists.txt", "LICENSE", "test_files/*"
exports_sources = "xmsmesh/*"
def configure(self):
# Set verion dynamically using XMS_VERSION env variable.
self.version = self.env.get('XMS_VERSION', '99.99.99')
# Raise ConanExceptions for Unsupported Versions
s_os = self.settings.os
s_compiler = self.settings.compiler
s_compiler_version = self.settings.compiler.version
self.options['xmscore'].xms = self.options.xms
self.options['xmscore'].pybind = self.options.pybind
self.options['xmscore'].testing = self.options.testing
self.options['xmsinterp'].xms = self.options.xms
self.options['xmsinterp'].pybind = self.options.pybind
self.options['xmsinterp'].testing = self.options.testing
self.options['xmsgrid'].xms = self.options.xms
self.options['xmsgrid'].pybind = self.options.pybind
self.options['xmsgrid'].testing = self.options.testing
if s_compiler == "apple-clang" and s_os == 'Linux':
raise ConanException("Clang on Linux is not supported.")
if s_compiler == "apple-clang" \
and s_os == 'Macos' \
and float(s_compiler_version.value) < 9.0:
raise ConanException("Clang > 9.0 is required for Mac.")
def requirements(self):
"""Requirments"""
# If building for XMS, use the older, custom boost
if self.options.xms:
self.requires("boost/1.60.0@aquaveo/testing")
else:
self.requires("boost/1.66.0@conan/stable")
# Pybind if not visual studio 2013
if not (self.settings.compiler == 'Visual Studio' \
and self.settings.compiler.version == "12") \
and self.options.pybind:
self.requires("pybind11/2.2.2@aquaveo/stable")
self.requires("xmscore/[>=2.0.0,<3.0.0]@aquaveo/stable")
self.requires("xmsinterp/[>=2.0.0,<3.0.0]@aquaveo/stable")
self.requires("xmsgrid/[>=2.0.0,<3.0.0]@aquaveo/stable")
def build(self):
cmake = CMake(self)
if self.settings.compiler == 'Visual Studio' \
and self.settings.compiler.version == "12":
cmake.definitions["XMS_BUILD"] = self.options.xms
# CXXTest doesn't play nice with PyBind. Also, it would be nice to not
# have tests in release code. Thus, if we want to run tests, we will
# build a test version (without python), run the tests, and then (on
# sucess) rebuild the library without tests.
cmake.definitions["XMS_VERSION"] = '{}'.format(self.version)
cmake.definitions["IS_PYTHON_BUILD"] = self.options.pybind
cmake.definitions["BUILD_TESTING"] = self.options.testing
cmake.definitions["XMS_TEST_PATH"] = "test_files"
cmake.definitions["PYTHON_TARGET_VERSION"] = self.env.get("PYTHON_TARGET_VERSION", "3.6")
cmake.configure(source_folder=".")
cmake.build()
cmake.install()
if self.options.testing:
print("***********(0.0)*************")
try:
cmake.test()
except ConanException:
raise
finally:
if os.path.isfile("TEST-cxxtest.xml"):
with open("TEST-cxxtest.xml", "r") as f:
for line in f.readlines():
no_newline = line.strip('\n')
print(no_newline)
print("***********(0.0)*************")
elif self.options.pybind:
with tools.pythonpath(self):
if not self.settings.os == "Macos":
self.run('pip install --user numpy')
else:
self.run('pip install numpy')
self.run('python -m unittest discover -v -p *_pyt.py -s ../xmsmesh/python', cwd="./lib")
def package(self):
self.copy("license", dst="licenses", ignore_case=True, keep_path=False)
def package_info(self):
self.env_info.PYTHONPATH.append(os.path.join(self.package_folder, "site-packages"))
if self.settings.build_type == 'Debug':
self.cpp_info.libs = ["xmsmeshlib_d"]
else:
self.cpp_info.libs = ["xmsmeshlib"]