-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconanfile.py
235 lines (205 loc) · 7.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
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
from conans import ConanFile, CMake, AutoToolsBuildEnvironment, tools
from conans.errors import ConanInvalidConfiguration
import os, platform
class SpeexDSPConan(ConanFile):
name = "SpeexDSP"
version = "1.2rc3"
license = "BSD"
author = "Xiph.Org Foundation"
url = "https://github.com/qno/conan-speexdsp"
homepage = "https://github.com/xiph/speexdsp"
description = "SpeexDSP is a patent-free, Open Source/Free Software DSP library."
settings = "os", "compiler", "build_type", "arch"
options = {
"shared": [True, False],
"fPIC": [True, False]
}
default_options = {
"shared": False,
"fPIC": True
}
generators = "cmake"
_pkg_name = "speexdsp-1.2rc3"
_libname = "speexdsp"
def source(self):
url = "http://downloads.xiph.org/releases/speex/{}.tar.gz".format(self._pkg_name)
self.output.info("Downloading {}".format(url))
tools.get(url)
self._createCMakeLists()
def configure(self):
del self.settings.compiler.libcxx
if self._isVisualStudioBuild():
del self.options.fPIC
if self.options.shared:
raise ConanInvalidConfiguration("This library doesn't support dll's on Windows")
def build(self):
if self._isVisualStudioBuild():
cmake = CMake(self)
cmake.configure(source_dir=self._pkg_name)
cmake.build()
else:
is_windows_build = platform.system() == "Windows"
config_args = []
if self.options.fPIC:
config_args.append("--with-pic")
if self.options.shared:
config_args.append("--disable-static")
else:
config_args.append("--disable-shared")
autotools = AutoToolsBuildEnvironment(self, win_bash=is_windows_build)
autotools.configure(configure_dir=self._pkg_name, args=config_args)
autotools.make()
autotools.install()
def package(self):
self.copy("include/speex/*.h", dst=".", src=self._pkg_name)
self.copy("speexdsp_config_types.h", dst="include/speex", src=".")
if self._isVisualStudioBuild():
self.copy("win32/config.h", dst="include", src=self._pkg_name)
self.copy("*.lib", dst="lib", keep_path=False)
self.copy("*.dll", dst="lib", keep_path=False)
self.copy("*.so*", dst="lib", keep_path=False)
self.copy("*.dylib", dst="lib", keep_path=False)
self.copy("*.a", dst="lib", keep_path=False)
def package_info(self):
self.cpp_info.libs = [self._libname]
if self._isVisualStudioBuild():
# in include/win32 config.h is provided
self.cpp_info.includedirs = ["include", "include/win32"]
def _isVisualStudioBuild(self):
return self.settings.os == "Windows" and self.settings.compiler == "Visual Studio"
def _isMinGWBuild(self):
return self.settings.os == "Windows" and self.settings.compiler == "gcc"
def _createCMakeLists(self):
content = '''\
# THIS FILE WAS GENERATED BY CONAN RECIPE. DO NOT EDIT THIS FILE!
cmake_minimum_required(VERSION 3.5)
project(SpeexDSP)
if (NOT MSVC)
message(FATAL_ERROR "Abort proccessing - this CMake project has only support for MS Visual Studio!")
endif ()
# the following checks and configure_file steps are trying somehow to reproduce the steps from
# https://github.com/xiph/speexdsp/blob/887ac103dbbd0533ed501fc3dd599c876cc0eec7/configure.ac#L280
# this is not 100% exactly the same, but as this CMakeLists.txt is only for used for MSVC compiler, the
# obtained types for the typdefs are correct. It even just works without to configure the
# speexdsp_config_types.h.in at all for building with Visual Studio.
include (CheckTypeSize)
include (CheckIncludeFiles)
check_include_files (stdint.h HAVE_STDINT_H)
check_include_files (inttypes.h HAVE_INTTYPES_H)
check_include_files (sys/types.h HAVE_SYS_TYPES_H)
check_type_size ("int16_t" INT16_T)
message ("size: ${{INT16_T}}")
check_type_size ("short" SHORT16)
message ("size: ${{SHORT16}}")
check_type_size ("int" INT16)
message ("size: ${{INT16}}")
if (HAVE_INT16_T)
set (SIZE16 "int16_t")
elseif (HAVE_SHORT16)
set (SIZE16 "short")
elseif (HAVE_INT16)
set (SIZE16 "int")
endif ()
if (NOT DEFINED SIZE16)
message (configure of speexdsp_config_types.h.in will fail - WARNING "SIZE16 type check failed")
endif ()
check_type_size ("uint16_t" UINT16_T)
message ("size: ${{UINT16_T}}")
check_type_size ("u_int16_t" U_INT16_T)
message ("size: ${{U_INT16_T}}")
check_type_size ("unsigned short" USHORT16)
message ("size: ${{USHORT16}}")
check_type_size ("unsigned int" UINT16)
message ("size: ${{UINT16}}")
if (HAVE_UINT16_T)
set (USIZE16 "uint16_t")
elseif (HAVE_U_INT16_T)
set (USIZE16 "u_int16_t")
elseif (HAVE_USHORT16)
set (USIZE16 "unsigned short")
elseif (HAVE_UINT16)
set (USIZE16 "unsigned int")
endif ()
if (NOT DEFINED USIZE16)
message (configure of speexdsp_config_types.h.in will fail - WARNING "USIZE16 type check failed")
endif ()
check_type_size ("int32_t" INT32_T)
message ("size: ${{INT32_T}}")
check_type_size ("int" INT32)
message ("size: ${{INT32}}")
check_type_size ("long" LONG)
message ("size: ${{LONG}}")
check_type_size ("short" SHORT32)
message ("size: ${{SHORT32}}")
if (HAVE_INT32_T)
set (SIZE32 "int32_t")
elseif (HAVE_INT32)
set (SIZE32 "int")
elseif (HAVE_LONG)
set (SIZE32 "long")
elseif (HAVE_SHORT32)
set (SIZE32 "short")
endif ()
if (NOT DEFINED SIZE32)
message (configure of speexdsp_config_types.h.in will fail - WARNING "SIZE32 type check failed")
endif ()
check_type_size ("uint32_t" UINT32_T)
message ("size: ${{UINT32_T}}")
check_type_size ("u_int32_t" U_INT32_T)
message ("size: ${{U_INT32_T}}")
check_type_size ("unsigned short" USHORT32)
message ("size: ${{USHORT32}}")
check_type_size ("unsigned int" UINT32)
message ("size: ${{UINT32}}")
check_type_size ("unsigned long" ULONG)
message ("size: ${{ULONG}}")
set (USIZE32 FALSE)
if (HAVE_UINT32_T)
set (USIZE32 "uint32_t")
elseif (HAVE_U_INT32_T)
set (USIZE32 "u_int32_t")
elseif (HAVE_USHORT32)
set (USIZE32 "unsigned short")
elseif (HAVE_UINT32)
set (USIZE32 "unsigned int")
elseif (HAVE_ULONG)
set (USIZE32 "unsigned long")
endif ()
if (NOT DEFINED USIZE32)
message (WARNING "configure of speexdsp_config_types.h.in will fail - USIZE32 type check failed")
endif ()
message ("determined 'SIZE16' type as '${{SIZE16}}'")
message ("determined 'USIZE16' type as '${{USIZE16}}'")
message ("determined 'SIZE32' type as '${{SIZE32}}'")
message ("determined 'USIZE32' type as '${{USIZE32}}'")
configure_file(include/speex/speexdsp_config_types.h.in speexdsp_config_types.h)
include(${{CMAKE_BINARY_DIR}}/conanbuildinfo.cmake)
conan_basic_setup()
set(LIBSPEEXDSP "{}")
set(SOURCES libspeexdsp/buffer.c
libspeexdsp/fftwrap.c
libspeexdsp/filterbank.c
libspeexdsp/jitter.c
libspeexdsp/kiss_fft.c
libspeexdsp/kiss_fftr.c
libspeexdsp/mdf.c
libspeexdsp/preprocess.c
libspeexdsp/resample.c
libspeexdsp/scal.c
libspeexdsp/smallft.c)
add_library(${{LIBSPEEXDSP}} ${{SOURCES}})
target_include_directories(${{LIBSPEEXDSP}} PRIVATE include libspeexdsp win32 ${{CMAKE_CURRENT_BINARY_DIR}})
target_compile_definitions(${{LIBSPEEXDSP}} PRIVATE D_LIB HAVE_CONFIG_H)
if (HAVE_STDINT_H)
target_compile_definitions(${{LIBSPEEXDSP}} PRIVATE HAVE_STDINT_H)
elseif (HAVE_INTTYPES_H)
target_compile_definitions(${{LIBSPEEXDSP}} PRIVATE HAVE_INTTYPES_H)
elseif (HAVE_SYS_TYPES_H)
target_compile_definitions(${{LIBSPEEXDSP}} PRIVATE HAVE_SYS_TYPES_H)
endif ()
'''.format(self._libname)
self.output.info("create CMakeLists.txt file")
cmake_file = os.path.join(self._pkg_name, "CMakeLists.txt")
f = open(cmake_file, "w+")
f.write(content)
f.close()