Use sqlite for cinema and DKDM recipient lists.
[dcpomatic.git] / src / tools / wscript
1 #
2 #    Copyright (C) 2012-2020 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 from __future__ import print_function
21 import os
22 import glob
23 from waflib import Logs
24 import i18n
25
26
27 def description(tool, variant):
28     descriptions = {
29         'dcpomatic': 'DCP-o-matic',
30         'dcpomatic_batch': 'DCP-o-matic Batch Converter',
31         'dcpomatic_server': 'DCP-o-matic Encode Server',
32         'dcpomatic_kdm': 'DCP-o-matic KDM Creator',
33         'dcpomatic_player': 'DCP-o-matic Player',
34         'dcpomatic_playlist': 'DCP-o-matic Playlist Editor',
35         'dcpomatic_combiner': 'DCP-o-matic Combiner',
36         'dcpomatic_verifier': 'DCP-o-matic Verifier',
37     }
38     return descriptions[tool] if tool in descriptions else tool
39
40
41 def make_rc(tool, icon, variant):
42     filename = 'build/src/tools/%s.rc' % tool
43     with open(filename, 'w') as rc:
44         if tool == 'dcpomatic_disk_writer':
45             print('#include "winuser.h"', file=rc)
46             print('1 RT_MANIFEST "dcpomatic2_disk_writer.exe.manifest"', file=rc)
47             with open("build/src/tools/dcpomatic2_disk_writer.exe.manifest", "w") as manifest:
48                 print("""
49 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
50 <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
51     <assemblyIdentity version="1.0.0.0" processorArchitecture="X86" name="dcpomatic2_disk_writer" type="win32"/> 
52     <description>DCP-o-matic Disk Writer</description> 
53     <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
54             <security>
55                     <requestedPrivileges>
56                             <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
57                     </requestedPrivileges>
58             </security>
59     </trustInfo>
60 </assembly>""", file=manifest)
61         else:
62             print("""
63 id ICON "../../graphics/windows/%s"
64 #include "wx-3.1/wx/msw/wx.rc"
65 VS_VERSION_INFO VERSIONINFO
66  FILEVERSION    0,0,0,2
67  PRODUCTVERSION 0,0,0,2
68  FILEFLAGSMASK 0x3fL
69  #ifdef _DEBUG
70  FILEFLAGS 0x1L
71  #else
72  FILEFLAGS 0x0L
73  #endif
74  FILEOS 0x4L
75  FILETYPE 0x1L
76  FILESUBTYPE 0x0L
77  {
78     BLOCK "StringFileInfo"
79     {
80         BLOCK "040904b0"
81         {
82             VALUE "FileDescription", "%s\\0"
83         }
84     }
85     BLOCK "VarFileInfo"
86     {
87         VALUE "Translation", 0x409, 1200
88     }
89  }
90     """ % (icon, description(tool, variant)), file=rc)
91     return filename
92
93 def configure(conf):
94     if conf.env.TARGET_WINDOWS_64 or conf.env.TARGET_WINDOWS_32:
95         conf.env.append_value('CXXFLAGS', ['-mconsole'])
96         conf.env.append_value('LINKFLAGS', ['-mconsole'])
97
98 def build(bld):
99     uselib =  'BOOST_THREAD BOOST_DATETIME DCP XMLSEC CXML XMLPP AVFORMAT AVFILTER AVCODEC '
100     uselib += 'AVUTIL SWSCALE SWRESAMPLE POSTPROC CURL BOOST_FILESYSTEM SSH ZIP CAIROMM FONTCONFIG PANGOMM SUB '
101     uselib += 'SNDFILE SAMPLERATE BOOST_REGEX ICU NETTLE RTAUDIO PNG JPEG LEQM_NRT SQLITE3 '
102
103     if bld.env.ENABLE_DISK:
104         if bld.env.TARGET_LINUX:
105             uselib += 'POLKIT '
106         uselib += 'LWEXT4 NANOMSG '
107
108     if bld.env.TARGET_WINDOWS_64 or bld.env.TARGET_WINDOWS_32:
109         uselib += 'WINSOCK2 DBGHELP SHLWAPI MSWSOCK BOOST_LOCALE WINSOCK2 OLE32 DSOUND WINMM KSUSER SETUPAPI UUID '
110     if bld.env.TARGET_LINUX:
111         uselib += 'DL '
112
113     cli_tools = ['dcpomatic_cli', 'dcpomatic_server_cli', 'server_test', 'dcpomatic_kdm_cli', 'dcpomatic_create', 'dcpomatic_map']
114     if bld.env.ENABLE_DISK and not bld.env.DISABLE_GUI:
115         cli_tools.append('dcpomatic_disk_writer')
116
117     try:
118         os.makedirs('build/src/tools')
119     except:
120         pass
121
122     for t in cli_tools:
123         obj = bld(features='cxx cxxprogram')
124         obj.uselib = uselib
125         obj.includes = ['..']
126         obj.use    = ['libdcpomatic2']
127         obj.source = '%s.cc' % t
128         if (bld.env.TARGET_WINDOWS_64 or bld.env.TARGET_WINDOWS_32) and t == 'dcpomatic_disk_writer':
129             obj.source += ' ../../%s' % (make_rc(t, None, bld.env.VARIANT))
130             # Prevent a console window opening when we start dcpomatic2_disk_writer
131             obj.env.append_value('LINKFLAGS', '-Wl,-subsystem,windows')
132         obj.target = t.replace('dcpomatic', 'dcpomatic2')
133         if t == 'server_test':
134             obj.install_path = None
135
136     gui_tools = []
137     if not bld.env.DISABLE_GUI:
138         gui_tools = ['dcpomatic',
139                      'dcpomatic_batch',
140                      'dcpomatic_server',
141                      'dcpomatic_kdm',
142                      'dcpomatic_player',
143                      'dcpomatic_playlist',
144                      'dcpomatic_combiner',
145                      'dcpomatic_editor',
146                      'dcpomatic_verifier']
147         if bld.env.ENABLE_DISK:
148             gui_tools.append('dcpomatic_disk')
149
150     for t in gui_tools:
151         obj = bld(features='cxx cxxprogram')
152         obj.uselib = uselib
153         if bld.env.BUILD_STATIC or bld.env.TARGET_LINUX:
154             obj.uselib += ' GTK'
155         obj.uselib += ' WXWIDGETS'
156         if not bld.env.TARGET_OSX:
157             obj.uselib += ' GL GLU'
158         if bld.env.TARGET_LINUX:
159             obj.uselib += ' X11'
160         if bld.env.TARGET_WINDOWS_64 or bld.env.TARGET_WINDOWS_32:
161             obj.uselib += ' GLEW'
162         obj.includes = ['..']
163         obj.use    = ['libdcpomatic2', 'libdcpomatic2-wx']
164         obj.source = '%s.cc' % t
165         if bld.env.TARGET_WINDOWS_64 or bld.env.TARGET_WINDOWS_32:
166             obj.source += ' ../../%s' % make_rc(t, t.replace("dcpomatic", "dcpomatic2") + ".ico", bld.env.VARIANT)
167         obj.target = t.replace('dcpomatic', 'dcpomatic2')
168
169     i18n.po_to_mo(os.path.join('src', 'tools'), 'dcpomatic2', bld)
170
171 def pot(bld):
172     cc = """
173          dcpomatic_batch.cc
174          dcpomatic.cc
175          dcpomatic_combiner.cc
176          dcpomatic_disk.cc
177          dcpomatic_editor.cc
178          dcpomatic_kdm.cc
179          dcpomatic_server.cc
180          dcpomatic_player.cc
181          dcpomatic_playlist.cc
182          dcpomatic_server.cc
183          """
184     i18n.pot(os.path.join('src', 'tools'), cc, 'dcpomatic')
185
186 def pot_merge(bld):
187     i18n.pot_merge(os.path.join('src', 'tools'), 'dcpomatic')