Rename TimelineVideoContentView -> ContentTimelineVideoView.
[dcpomatic.git] / src / wx / wscript
1 #
2 #    Copyright (C) 2012-2022 Carl Hetherington <cth@carlh.net>
3 #
4 #    This file is part of DCP-o-matic.
5 #
6 #    DCP-o-matic is free software; you can redistribute it and/or modify
7 #    it under the terms of the GNU General Public License as published by
8 #    the Free Software Foundation; either version 2 of the License, or
9 #    (at your option) any later version.
10 #
11 #    DCP-o-matic is distributed in the hope that it will be useful,
12 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 #    GNU General Public License for more details.
15 #
16 #    You should have received a copy of the GNU General Public License
17 #    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
18 #
19
20 import os
21 import subprocess
22 import shlex
23 import glob
24 from waflib import Logs
25 import i18n
26
27 sources = """
28           about_dialog.cc
29           audio_dialog.cc
30           audio_gain_dialog.cc
31           audio_mapping_view.cc
32           audio_panel.cc
33           audio_plot.cc
34           auto_crop_dialog.cc
35           barco_alchemy_certificate_panel.cc
36           batch_job_view.cc
37           check_box.cc
38           christie_certificate_panel.cc
39           cinema_dialog.cc
40           closed_captions_dialog.cc
41           colour_conversion_editor.cc
42           config_dialog.cc
43           config_move_dialog.cc
44           confirm_kdm_email_dialog.cc
45           content_advanced_dialog.cc
46           content_colour_conversion_dialog.cc
47           content_menu.cc
48           content_panel.cc
49           content_properties_dialog.cc
50           content_sub_panel.cc
51           content_timeline.cc
52           content_timeline_atmos_view.cc
53           content_timeline_audio_view.cc
54           content_timeline_dialog.cc
55           content_timeline_video_view.cc
56           content_timeline_view.cc
57           content_version_dialog.cc
58           content_view.cc
59           controls.cc
60           credentials_download_certificate_panel.cc
61           custom_scale_dialog.cc
62           dcp_referencing_dialog.cc
63           dcp_panel.cc
64           dcp_text_track_dialog.cc
65           dcpomatic_button.cc
66           dcpomatic_choice.cc
67           dcpomatic_spin_ctrl.cc
68           dir_dialog.cc
69           dir_picker_ctrl.cc
70           disk_warning_dialog.cc
71           dkdm_dialog.cc
72           dkdm_output_panel.cc
73           dolby_doremi_certificate_panel.cc
74           download_certificate_dialog.cc
75           download_certificate_panel.cc
76           drive_wipe_warning_dialog.cc
77           email_dialog.cc
78           export_subtitles_dialog.cc
79           export_video_file_dialog.cc
80           extra_kdm_email_dialog.cc
81           file_dialog.cc
82           file_picker_ctrl.cc
83           film_editor.cc
84           film_name_location_dialog.cc
85           film_viewer.cc
86           filter_dialog.cc
87           focus_manager.cc
88           fonts_dialog.cc
89           full_config_dialog.cc
90           full_language_tag_dialog.cc
91           gain_calculator_dialog.cc
92           gdc_certificate_panel.cc
93           gl_video_view.cc
94           hints_dialog.cc
95           html_dialog.cc
96           i18n_hook.cc
97           image_sequence_dialog.cc
98           invalid_certificate_period_dialog.cc
99           instant_i18n_dialog.cc
100           interop_metadata_dialog.cc
101           job_manager_view.cc
102           job_view.cc
103           job_view_dialog.cc
104           kdm_advanced_dialog.cc
105           kdm_cpl_panel.cc
106           kdm_dialog.cc
107           kdm_output_panel.cc
108           kdm_timing_panel.cc
109           language_subtag_panel.cc
110           language_tag_dialog.cc
111           language_tag_widget.cc
112           kdm_choice.cc
113           make_chain_dialog.cc
114           markers.cc
115           markers_dialog.cc
116           markers_panel.cc
117           message_dialog.cc
118           metadata_dialog.cc
119           move_to_dialog.cc
120           nag_dialog.cc
121           name_format_editor.cc
122           new_dkdm_folder_dialog.cc
123           normal_job_view.cc
124           paste_dialog.cc
125           password_entry.cc
126           player_config_dialog.cc
127           player_information.cc
128           player_stress_tester.cc
129           playhead_to_timecode_dialog.cc
130           playhead_to_frame_dialog.cc
131           playlist_controls.cc
132           playlist_editor_config_dialog.cc
133           question_dialog.cc
134           rating_dialog.cc
135           qube_certificate_panel.cc
136           recipients_panel.cc
137           recipient_dialog.cc
138           recreate_chain_dialog.cc
139           region_subtag_dialog.cc
140           region_subtag_widget.cc
141           repeat_dialog.cc
142           report_problem_dialog.cc
143           rename_template_dialog.cc
144           rgba_colour_picker.cc
145           save_template_dialog.cc
146           screen_dialog.cc
147           screens_panel.cc
148           self_dkdm_dialog.cc
149           send_i18n_dialog.cc
150           send_test_email_dialog.cc
151           server_dialog.cc
152           servers_list_dialog.cc
153           simple_video_view.cc
154           smpte_metadata_dialog.cc
155           standard_controls.cc
156           static_text.cc
157           subtag_list_ctrl.cc
158           subtitle_appearance_dialog.cc
159           suspender.cc
160           system_font_dialog.cc
161           system_information_dialog.cc
162           table_dialog.cc
163           templates_dialog.cc
164           text_panel.cc
165           text_view.cc
166           time_picker.cc
167           timer_display.cc
168           timecode.cc
169           timeline.cc
170           timeline_content_view.cc
171           timeline_labels_view.cc
172           timeline_text_content_view.cc
173           timeline_reels_view.cc
174           timeline_time_axis_view.cc
175           timing_panel.cc
176           try_unmount_dialog.cc
177           update_dialog.cc
178           verify_dcp_dialog.cc
179           verify_dcp_progress_dialog.cc
180           video_panel.cc
181           video_view.cc
182           video_waveform_dialog.cc
183           video_waveform_plot.cc
184           wx_util.cc
185           wx_signal_manager.cc
186           """
187
188 def configure(conf):
189
190     wx_libs = 'core,richtext,adv,html,xml,propgrid'
191
192     if conf.options.wx_config is not None:
193         wx_config = conf.options.wx_config
194         conf.check_cfg(msg='Checking for wxWidgets using %s' % wx_config,
195                        package='',
196                        path=wx_config,
197                        args='--cppflags --cxxflags --libs %s --gl-libs' % wx_libs,
198                        uselib_store='WXWIDGETS',
199                        mandatory=True)
200     else:
201         try:
202             wx_config = '/usr/lib64/wx/config/gtk2-unicode-3.0'
203             conf.check_cfg(msg='Checking for wxWidgets using gtk2-unicode-3.0',
204                            package='',
205                            path=wx_config,
206                            args='--cppflags --cxxflags --libs %s --gl-libs' % wx_libs,
207                            uselib_store='WXWIDGETS',
208                            mandatory=True)
209         except:
210             try:
211                 wx_config = 'wx-config-3.0-gtk2'
212                 conf.check_cfg(msg='Checking for wxWidgets using wx-config-3.0-gtk2',
213                                package='',
214                                path=wx_config,
215                                args='--cppflags --cxxflags --libs %s --gl-libs' % wx_libs,
216                                uselib_store='WXWIDGETS',
217                                mandatory=True)
218             except:
219                 wx_config = 'wx-config'
220                 conf.check_cfg(msg='Checking for wxWidgets using wx-config',
221                                package='',
222                                path=wx_config,
223                                args='--cppflags --cxxflags --libs %s --gl-libs' % wx_libs,
224                                uselib_store='WXWIDGETS',
225                                mandatory=True)
226
227     if conf.env.TARGET_LINUX:
228         conf.env.append_value('CXXFLAGS', ['-DGL_GLEXT_PROTOTYPES', '-DGLX_GLXEXT_PROTOTYPES'])
229     if conf.env.TARGET_WINDOWS_64 or conf.env.TARGET_WINDOWS_32:
230         conf.env.append_value('CXXFLAGS', ['-DWGL_WGLEXT_PROTOTYPES'])
231     conf.env.append_value('CXXFLAGS', ['-DwxNO_UNSAFE_WXSTRING_CONV'])
232
233     if conf.options.static_wxwidgets:
234         # wx-config returns its static libraries as full paths, without -l prefixes, which confuses
235         # check_cfg().  It puts the static libraries into LINKFLAGS_WXWIDGETS, so fish them out.
236         stlibs = []
237         new_linkflags = []
238         stlib_paths = []
239         for f in conf.env.LINKFLAGS_WXWIDGETS:
240             if f.startswith('/'):
241                 d = os.path.dirname(f)
242                 if not d in stlib_paths:
243                     stlib_paths.append(d)
244                 stlibs.append(os.path.basename(f)[3:-2])
245             else:
246                 new_linkflags.append(f)
247
248         conf.env.STLIB_WXWIDGETS = stlibs
249         conf.env.LINKFLAGS_WXWIDGETS = new_linkflags
250         conf.env.STLIBPATH_WXWIDGETS = stlib_paths
251
252     conf.in_msg = 1
253     wx_version = conf.check_cfg(package='wxwidgets', path=wx_config, args='--version').strip()
254     conf.in_msg = 0
255     if not wx_version.startswith('3.'):
256         conf.fatal('wxwidgets version 3.x.y is required; %s found' % wx_version)
257
258     config = conf.check_cfg(package='wxwidgets', path=wx_config, args='--selected-config').strip()
259     if config.find('gtk2') != -1:
260         conf.check_cfg(package='gtk+-2.0', args='--cflags --libs', uselib_store='GTK', mandatory=True)
261
262     try:
263         conf.check_cfg(msg='Checking for RtAudio using pkg-config',
264                        package='rtaudio',
265                        args='--cflags --libs',
266                        uselib_store='RTAUDIO',
267                        mandatory=True)
268     except:
269         conf.check_cfg(msg='Checking for RtAudio headers using rtaudio-config',
270                        package='',
271                        path='rtaudio-config',
272                        args='--cppflags',
273                        uselib_store='RTAUDIO',
274                        mandatory=True)
275
276         conf.check_cfg(msg='Checking for RtAudio libraries using rtaudio-config',
277                        package='',
278                        path='rtaudio-config',
279                        args='--libs',
280                        uselib_store='RTAUDIO',
281                        mandatory=True)
282
283     # Some rtaudio-configs don't include rtaudio as a link library.  Go figure.
284     conf.env.LIB_RTAUDIO.append('rtaudio')
285     if conf.env.TARGET_WINDOWS_64 or conf.env.TARGET_WINDOWS_32:
286         # Don't explicitly link with pthread on Windows
287         conf.env.CFLAGS_RTAUDIO.remove('-pthread')
288         conf.env.LINKFLAGS_RTAUDIO.remove('-pthread')
289         # We need some libraries for WASAPI
290         conf.env.LIB_RTAUDIO.append('mfplat')
291         conf.env.LIB_RTAUDIO.append('mfuuid')
292         conf.env.LIB_RTAUDIO.append('wmcodecdspuuid')
293
294     if conf.env.TARGET_WINDOWS_64 or conf.env.TARGET_WINDOWS_32 or conf.env.TARGET_LINUX:
295         conf.check_cfg(package='gl', args='--cflags --libs', uselib_store='GL', mandatory=True)
296         conf.check_cfg(package='glu', args='--cflags --libs', uselib_store='GLU', mandatory=True)
297         if conf.env.TARGET_WINDOWS_64 or conf.env.TARGET_WINDOWS_32:
298             conf.check_cfg(package='glew', args='--cflags --libs', uselib_store='GLEW', mandatory=True)
299     else:
300         conf.env.STLIB_GL = 'gl'
301         conf.env.STLIB_GLU = 'glu'
302
303     if conf.env.TARGET_LINUX:
304         conf.check_cxx(fragment="""
305                                 #include <wx/glcanvas.h>
306                                 #include <GL/glu.h>
307                                 #include <GL/glext.h>
308                                 #include <GL/glxext.h>
309                                 int main() {
310                                     glXSwapIntervalEXT (0, 0, 1);
311                                     return 0;
312                                 }
313                                 """,
314                        msg='Checking for glXSwapIntervalEXT',
315                        okmsg='yes',
316                        uselib='GL WXWIDGETS',
317                        define_name='DCPOMATIC_HAVE_GLX_SWAP_INTERVAL_EXT',
318                        mandatory=False)
319
320
321 def build(bld):
322     if bld.env.STATIC_DCPOMATIC:
323         obj = bld(features='cxx cxxstlib')
324     else:
325         obj = bld(features='cxx cxxshlib')
326
327     obj.name   = 'libdcpomatic2-wx'
328     obj.export_includes = ['..']
329     obj.uselib = 'BOOST_FILESYSTEM BOOST_THREAD BOOST_REGEX WXWIDGETS DCP SUB ZIP CXML RTAUDIO ICU '
330     if bld.env.TARGET_LINUX:
331         obj.uselib += 'GTK GL GLU '
332     if bld.env.TARGET_WINDOWS_64 or bld.env.TARGET_WINDOWS_32:
333         obj.uselib += 'WINSOCK2 OLE32 DSOUND WINMM KSUSER GL GLU GLEW '
334     if bld.env.TARGET_OSX:
335         obj.framework = ['CoreAudio', 'OpenGL']
336     obj.use = 'libdcpomatic2'
337     obj.source = sources
338     obj.target = 'dcpomatic2-wx'
339
340     i18n.po_to_mo(os.path.join('src', 'wx'), 'libdcpomatic2-wx', bld)
341
342 def pot(bld):
343     i18n.pot(os.path.join('src', 'wx'), sources + " editable_list.h content_widget.h", 'libdcpomatic-wx')
344
345 def pot_merge(bld):
346     i18n.pot_merge(os.path.join('src', 'wx'), 'libdcpomatic-wx')