Add a 'Make DKDM' dialogue box to simplify and (hopefully) clarify DKDM creation...
[dcpomatic.git] / src / wx / wscript
1 #
2 #    Copyright (C) 2012-2019 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           barco_alchemy_certificate_panel.cc
35           batch_job_view.cc
36           check_box.cc
37           christie_certificate_panel.cc
38           cinema_dialog.cc
39           colour_conversion_editor.cc
40           config_dialog.cc
41           config_move_dialog.cc
42           confirm_kdm_email_dialog.cc
43           content_colour_conversion_dialog.cc
44           content_menu.cc
45           content_panel.cc
46           content_properties_dialog.cc
47           content_sub_panel.cc
48           content_view.cc
49           controls.cc
50           closed_captions_dialog.cc
51           credentials_download_certificate_panel.cc
52           dcp_panel.cc
53           dcpomatic_button.cc
54           disk_warning_dialog.cc
55           dkdm_output_panel.cc
56           drive_wipe_warning_dialog.cc
57           email_dialog.cc
58           image_sequence_dialog.cc
59           isdcf_metadata_dialog.cc
60           dcp_text_track_dialog.cc
61           dir_picker_ctrl.cc
62           dkdm_dialog.cc
63           dolby_doremi_certificate_panel.cc
64           download_certificate_dialog.cc
65           download_certificate_panel.cc
66           export_dialog.cc
67           file_picker_ctrl.cc
68           film_editor.cc
69           film_name_location_dialog.cc
70           film_viewer.cc
71           filter_dialog.cc
72           filter_editor.cc
73           focus_manager.cc
74           fonts_dialog.cc
75           full_config_dialog.cc
76           gain_calculator_dialog.cc
77           gdc_certificate_panel.cc
78           gl_video_view.cc
79           hints_dialog.cc
80           html_dialog.cc
81           initial_setup_dialog.cc
82           instant_i18n_dialog.cc
83           i18n_hook.cc
84           job_view.cc
85           job_view_dialog.cc
86           job_manager_view.cc
87           kdm_advanced_dialog.cc
88           kdm_cpl_panel.cc
89           kdm_dialog.cc
90           kdm_output_panel.cc
91           kdm_timing_panel.cc
92           key_dialog.cc
93           make_chain_dialog.cc
94           markers_dialog.cc
95           message_dialog.cc
96           metadata_dialog.cc
97           monitor_dialog.cc
98           move_to_dialog.cc
99           nag_dialog.cc
100           name_format_editor.cc
101           new_dkdm_folder_dialog.cc
102           normal_job_view.cc
103           paste_dialog.cc
104           password_entry.cc
105           player_config_dialog.cc
106           player_information.cc
107           player_stress_tester.cc
108           playhead_to_timecode_dialog.cc
109           playhead_to_frame_dialog.cc
110           playlist_controls.cc
111           playlist_editor_config_dialog.cc
112           question_dialog.cc
113           rating_dialog.cc
114           qube_certificate_panel.cc
115           recipients_panel.cc
116           recipient_dialog.cc
117           recreate_chain_dialog.cc
118           repeat_dialog.cc
119           report_problem_dialog.cc
120           rename_template_dialog.cc
121           rgba_colour_picker.cc
122           save_template_dialog.cc
123           screen_dialog.cc
124           screens_panel.cc
125           self_dkdm_dialog.cc
126           send_i18n_dialog.cc
127           server_dialog.cc
128           servers_list_dialog.cc
129           simple_video_view.cc
130           standard_controls.cc
131           static_text.cc
132           subtitle_appearance_dialog.cc
133           suspender.cc
134           system_font_dialog.cc
135           system_information_dialog.cc
136           table_dialog.cc
137           templates_dialog.cc
138           text_panel.cc
139           text_view.cc
140           time_picker.cc
141           timer_display.cc
142           timecode.cc
143           timeline.cc
144           timeline_atmos_content_view.cc
145           timeline_content_view.cc
146           timeline_dialog.cc
147           timeline_audio_content_view.cc
148           timeline_labels_view.cc
149           timeline_text_content_view.cc
150           timeline_reels_view.cc
151           timeline_time_axis_view.cc
152           timeline_video_content_view.cc
153           timeline_view.cc
154           timing_panel.cc
155           try_unmount_dialog.cc
156           update_dialog.cc
157           verify_dcp_dialog.cc
158           video_panel.cc
159           video_view.cc
160           video_waveform_dialog.cc
161           video_waveform_plot.cc
162           wx_util.cc
163           wx_signal_manager.cc
164           """
165
166 def configure(conf):
167
168     wx_libs = 'core,richtext,adv,html,xml'
169
170     try:
171         wx_config = '/usr/lib64/wx/config/gtk2-unicode-3.0'
172         conf.check_cfg(msg='Checking for wxWidgets using gtk2-unicode-3.0',
173                        package='',
174                        path=wx_config,
175                        args='--cppflags --cxxflags --libs %s --gl-libs' % wx_libs,
176                        uselib_store='WXWIDGETS',
177                        mandatory=True)
178     except:
179         try:
180             wx_config = 'wx-config-3.0-gtk2'
181             conf.check_cfg(msg='Checking for wxWidgets using wx-config-3.0-gtk2',
182                            package='',
183                            path=wx_config,
184                            args='--cppflags --cxxflags --libs %s --gl-libs' % wx_libs,
185                            uselib_store='WXWIDGETS',
186                            mandatory=True)
187         except:
188             wx_config = 'wx-config'
189             conf.check_cfg(msg='Checking for wxWidgets using wx-config',
190                            package='',
191                            path=wx_config,
192                            args='--cppflags --cxxflags --libs %s --gl-libs' % wx_libs,
193                            uselib_store='WXWIDGETS',
194                            mandatory=True)
195
196     if conf.env.TARGET_LINUX:
197         conf.env.append_value('CXXFLAGS', ['-DGLX_GLXEXT_PROTOTYPES'])
198     if conf.env.TARGET_WINDOWS:
199         conf.env.append_value('CXXFLAGS', ['-DWGL_WGLEXT_PROTOTYPES'])
200
201     if conf.options.static_wxwidgets:
202         # wx-config returns its static libraries as full paths, without -l prefixes, which confuses
203         # check_cfg().  It puts the static libraries into LINKFLAGS_WXWIDGETS, so fish them out.
204         stlibs = []
205         new_linkflags = []
206         stlib_paths = []
207         for f in conf.env.LINKFLAGS_WXWIDGETS:
208             if f.startswith('/'):
209                 d = os.path.dirname(f)
210                 if not d in stlib_paths:
211                     stlib_paths.append(d)
212                 stlibs.append(os.path.basename(f)[3:-2])
213             else:
214                 new_linkflags.append(f)
215
216         conf.env.STLIB_WXWIDGETS = stlibs
217         conf.env.LINKFLAGS_WXWIDGETS = new_linkflags
218         conf.env.STLIBPATH_WXWIDGETS = stlib_paths
219
220     conf.in_msg = 1
221     wx_version = conf.check_cfg(package='wxwidgets', path=wx_config, args='--version').strip()
222     conf.im_msg = 0
223     if not wx_version.startswith('3.0.'):
224         conf.fatal('wxwidgets version 3.0.x is required; %s found' % wx_version)
225
226     try:
227         conf.check_cfg(msg='Checking for RtAudio using pkg-config',
228                        package='rtaudio',
229                        args='--cflags --libs',
230                        uselib_store='RTAUDIO',
231                        mandatory=True)
232     except:
233         conf.check_cfg(msg='Checking for RtAudio headers using rtaudio-config',
234                        package='',
235                        path='rtaudio-config',
236                        args='--cppflags',
237                        uselib_store='RTAUDIO',
238                        mandatory=True)
239
240         conf.check_cfg(msg='Checking for RtAudio libraries using rtaudio-config',
241                        package='',
242                        path='rtaudio-config',
243                        args='--libs',
244                        uselib_store='RTAUDIO',
245                        mandatory=True)
246
247     # Some rtaudio-configs don't include rtaudio as a link library.  Go figure.
248     conf.env.LIB_RTAUDIO.append('rtaudio')
249     if conf.env.TARGET_WINDOWS:
250         # Don't explicitly link with pthread on Windows
251         conf.env.CFLAGS_RTAUDIO.remove('-pthread')
252         conf.env.LINKFLAGS_RTAUDIO.remove('-pthread')
253         # We need some libraries for WASAPI
254         conf.env.LIB_RTAUDIO.append('mfplat')
255         conf.env.LIB_RTAUDIO.append('mfuuid')
256         conf.env.LIB_RTAUDIO.append('wmcodecdspuuid')
257
258     conf.check_cxx(fragment="""
259                             #include <RtAudio.h>\n
260                             int main() { throw RtError("Hello"); }
261                             """,
262                    msg='Checking for RtError class',
263                    use='RTAUDIO',
264                    uselib_store='',
265                    define_name='DCPOMATIC_USE_RTERROR',
266                    mandatory=False)
267
268     if conf.env.TARGET_WINDOWS or conf.env.TARGET_LINUX:
269         conf.check_cfg(package='gl', args='--cflags --libs', uselib_store='GL', mandatory=True)
270         conf.check_cfg(package='glu', args='--cflags --libs', uselib_store='GLU', mandatory=True)
271     else:
272         conf.env.STLIB_GL = 'gl'
273         conf.env.STLIB_GLU = 'glu'
274
275     if conf.env.TARGET_LINUX:
276         conf.check_cxx(fragment="""
277                                 #include <wx/glcanvas.h>
278                                 #include <GL/glu.h>
279                                 #include <GL/glext.h>
280                                 #include <GL/glxext.h>
281                                 int main() {
282                                     glXSwapIntervalEXT (0, 0, 1);
283                                     return 0;
284                                 }
285                                 """,
286                        msg='Checking for glXSwapIntervalEXT',
287                        okmsg='yes',
288                        uselib='GL WXWIDGETS',
289                        define_name='DCPOMATIC_HAVE_GLX_SWAP_INTERVAL_EXT',
290                        mandatory=False)
291
292
293 def build(bld):
294     if bld.env.STATIC_DCPOMATIC:
295         obj = bld(features='cxx cxxstlib')
296     else:
297         obj = bld(features='cxx cxxshlib')
298
299     obj.name   = 'libdcpomatic2-wx'
300     obj.export_includes = ['..']
301     obj.uselib = 'BOOST_FILESYSTEM BOOST_THREAD BOOST_REGEX WXWIDGETS DCP SUB ZIP CXML RTAUDIO '
302     if bld.env.TARGET_LINUX:
303         obj.uselib += 'GTK GL GLU '
304     if bld.env.TARGET_WINDOWS:
305         obj.uselib += 'WINSOCK2 OLE32 DSOUND WINMM KSUSER GL GLU '
306     if bld.env.TARGET_OSX:
307         obj.framework = ['CoreAudio', 'OpenGL']
308     obj.use = 'libdcpomatic2'
309     if not len(bld.env.VARIANT) == 0 and bld.env.VARIANT.startswith('swaroop-'):
310         obj.source = sources + " swaroop_controls.cc"
311     else:
312         obj.source = sources
313     obj.target = 'dcpomatic2-wx'
314
315     i18n.po_to_mo(os.path.join('src', 'wx'), 'libdcpomatic2-wx', bld)
316
317 def pot(bld):
318     i18n.pot(os.path.join('src', 'wx'), sources + " editable_list.h content_widget.h", 'libdcpomatic-wx')
319
320 def pot_merge(bld):
321     i18n.pot_merge(os.path.join('src', 'wx'), 'libdcpomatic-wx')