-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwscript
More file actions
219 lines (183 loc) · 4.93 KB
/
wscript
File metadata and controls
219 lines (183 loc) · 4.93 KB
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
import os
import glob
import shutil
### PROJECT CONFIGURATION ###
APPNAME = 'cap2re'
VERSION = '1.0'
top = os.getcwd()
extras = top + '/waf-extras'
out = top + '/build'
#############################
import waflib.Logs as Logs
import copy
def yesno(b):
if b:
return "yes"
return "no"
def yesnocolor(b):
res = yesno(b)
if res == "yes":
col = 'GREEN'
else:
col = 'RED'
return res, col
def options(ctx):
ctx.load('compiler_c')
ctx.load('compiler_cxx')
ctx.add_option(
'--with-backends',
action='store',
type='str',
default="basler,libgphoto2",
dest="backends",
help="Comma-separated names of backends to compile. By default, all available backends are built (basler, libgphoto2)."
)
ctx.load('check_pylon', tooldir=extras)
ctx.add_option(
'--disable-python',
action='store_false',
default=True,
dest='buildPythonWrapper',
help="Do not build Python wrapper for the library"
)
ctx.add_option(
'--disable-mt',
action='store_false',
default=True,
dest='useMultiThreading',
help="Disable the support for parallel (multithreaded) captures"
)
def configure(ctx):
backends = ctx.options.backends.split(',') or ['basler, libgphoto2']
# check if valid names are given
for b in backends:
if b not in ['basler', 'libgphoto2']:
ctx.fatal("Unknown backend '%s' given!" % b)
ctx.load('compiler_c')
ctx.load('compiler_cxx')
ctx.env.PREFIX = '/usr'
# -- check for libraries supporting libgphoto2 backend --
if 'libgphoto2' in backends:
# check for Boost.RegEx, needed for configuration tree
ctx.check_cxx(
header_name = 'boost/regex.hpp',
lib = 'boost_regex',
uselib_store = 'BOOST_REGEX',
msg = "Checking for Boost.RegEx"
)
# look for libgphoto2
ctx.check_cfg(
package = 'libgphoto2',
args = '--cflags --libs',
uselib_store = 'GPHOTO2',
msg = "Checking for libgphoto2",
mandatory = False,
)
# -- check for multithreaded captures feature supporting libraries --
if ctx.options.useMultiThreading:
ctx.check_cxx(
header_name = 'boost/thread.hpp',
lib = 'boost_thread',
uselib_store = 'BOOST_THREAD',
msg = "Checking for Boost.Thread"
)
# -- check for python wrapper supporting libraries --
if ctx.options.buildPythonWrapper:
# we need Python headers
for prog in ['python-config', 'PYTHON-config']:
if ctx.find_program(prog, var='PYTHON_CONFIG', mandatory=False):
break
if not ctx.env.PYTHON_CONFIG:
ctx.fatal('python-config is missing')
ctx.check_cfg(
path=ctx.env.PYTHON_CONFIG,
package = '',
args = '--include',
uselib_store = 'PYTHON',
msg = "Checking for Python headers"
)
# -- basler backend supporting libraries search --
if 'basler' in backends:
# look for Pylon SDK
ctx.load('check_pylon', tooldir=top)
# check for libjpeg, needed for basler backend
ctx.check_cxx(
lib='jpeg',
uselib_store = 'LIBJPEG',
msg = "Checking for libjpeg",
)
ctx.env.CXXFLAGS += ['-fPIC']
# summary printout
print
print "Available backends:"
ctx.msg(" libgphoto2", *yesnocolor(ctx.env.HAVE_GPHOTO2))
ctx.msg(" Basler GiGE", *yesnocolor(ctx.env.HAVE_PYLON))
print
print "Features:"
ctx.msg(" Parallel captures:", *yesnocolor(ctx.env.HAVE_BOOST_THREAD_HPP))
ctx.msg(" Python wrapper:", *yesnocolor(ctx.env.HAVE_PYTHON))
ctx.env.DEFINES = []
ctx.define('HAVE_PYLON', ctx.env.HAVE_PYLON, False)
ctx.define('HAVE_GPHOTO2', ctx.env.HAVE_GPHOTO2 or 0, False)
ctx.define('HAVE_BOOST_THREAD', ctx.env.HAVE_BOOST_THREAD_HPP or 0, False)
ctx.define('PYLON_ROOT', ctx.env.PYLON_ROOT, True)
ctx.define('GENICAM_ROOT', ctx.env.GENICAM_ROOT, True)
ctx.write_config_header('../src/config.h', remove=False)
def build(ctx):
components = ['Core']
libs = []
# -- Build core library --
sources = [
'src/Camera.cpp',
'src/CameraManager.cpp',
]
if ctx.get_define('HAVE_BOOST_THREAD') == "1":
libs.append('BOOST_THREAD')
ctx.objects(
source = sources,
target = 'Core',
uselib = libs,
)
# -- Build libgphoto2 backend, if we can --
if ctx.get_define('HAVE_GPHOTO2') == "1":
sources = [
'src/Node.cpp',
'src/ConfigOptsTree.cpp',
'src/Gphoto2Camera.cpp',
'src/Gphoto2CameraManager.cpp',
]
ctx.objects(
source = sources,
target = 'Gphoto2Backend',
uselib = ['BOOST_REGEX', 'GPHOTO2'],
)
libs += ['BOOST_REGEX', 'GPHOTO2']
components.append('Gphoto2Backend')
# -- Build basler backend, possibly --
if ctx.get_define('HAVE_PYLON') == "1":
sources = [
'src/BaslerCamera.cpp',
'src/BaslerCameraManager.cpp',
]
ctx.objects(
source = sources,
target = 'BaslerBackend',
uselib = ['PYLON', 'LIBJPEG'],
)
libs += ['PYLON', 'LIBJPEG']
components.append('BaslerBackend')
# -- Build the C++ library --
ctx.shlib(
source = 'src/Cap2re.cpp',
target = 'cap2re',
uselib = libs,
use = components
)
# -- Build Python wrapper for library, if needed --
if ctx.env.HAVE_PYTHON:
ctx.shlib(
source = 'src/PythonWrapper.cpp',
target = 'pycap2re',
uselib = ['PYTHON'],
use = 'cap2re'
)