Cleanup: missing word in comment.
[dcpomatic.git] / wscript
diff --git a/wscript b/wscript
index d97a2f97cd594d1bebc6d2c74db396215b1db0f2..0fae054bfb3135d8af08fba218616f533873b6bb 100644 (file)
--- a/wscript
+++ b/wscript
@@ -35,7 +35,7 @@ except ImportError:
 from waflib import Logs, Context
 
 APPNAME = 'dcpomatic'
-libdcp_version = '1.8.73'
+libdcp_version = '1.8.100'
 libsub_version = '1.6.42'
 
 this_version = subprocess.Popen(['git', 'tag', '-l', '--points-at', 'HEAD'], stdout=subprocess.PIPE).communicate()[0]
@@ -75,10 +75,13 @@ def options(opt):
     opt.add_option('--workaround-gssapi', action='store_true', default=False, help='link to gssapi_krb5')
     opt.add_option('--use-lld',           action='store_true', default=False, help='use lld linker')
     opt.add_option('--enable-disk',       action='store_true', default=False, help='build dcpomatic2_disk tool; requires Boost process, lwext4 and nanomsg libraries')
+    opt.add_option('--enable-grok',       action='store_true', default=False, help='build with support for grok J2K encoder')
     opt.add_option('--warnings-are-errors', action='store_true', default=False, help='build with -Werror')
     opt.add_option('--wx-config',         help='path to wx-config')
     opt.add_option('--enable-asan',       action='store_true', help='build with asan')
     opt.add_option('--disable-more-warnings', action='store_true', default=False, help='disable some warnings raised by Xcode 15 with the 2.16 branch')
+    opt.add_option('--c++17', action='store_true', default=False, help='build with C++17 and libxml++-4.0')
+    opt.add_option('--variant', help="build with variant")
 
 def configure(conf):
     conf.load('compiler_cxx')
@@ -86,6 +89,17 @@ def configure(conf):
     if conf.options.target_windows_64 or conf.options.target_windows_32:
         conf.load('winres')
 
+    if vars(conf.options)['c++17']:
+        cpp_std = '17'
+        conf.env.XMLPP_API = '4.0'
+        conf.env.PANGOMM_API = '2.48'
+        conf.env.CAIROMM_API = '1.16'
+    else:
+        cpp_std = '11'
+        conf.env.XMLPP_API = '2.6'
+        conf.env.PANGOMM_API = '1.4'
+        conf.env.CAIROMM_API = '1.0'
+
     # Save conf.options that we need elsewhere in conf.env
     conf.env.DISABLE_GUI = conf.options.disable_gui
     conf.env.DISABLE_TESTS = conf.options.disable_tests
@@ -97,10 +111,12 @@ def configure(conf):
     conf.env.DEBUG = conf.options.enable_debug
     conf.env.STATIC_DCPOMATIC = conf.options.static_dcpomatic
     conf.env.ENABLE_DISK = conf.options.enable_disk
+    conf.env.ENABLE_GROK = conf.options.enable_grok
     if conf.options.destdir == '':
         conf.env.INSTALL_PREFIX = conf.options.prefix
     else:
         conf.env.INSTALL_PREFIX = conf.options.destdir
+    conf.env.VARIANT = conf.options.variant if conf.options.variant else "dcpomatic"
 
     conf.check_cxx(cxxflags=['-msse', '-mfpmath=sse'], msg='Checking for SSE support', mandatory=False, define_name='SSE')
 
@@ -112,11 +128,13 @@ def configure(conf):
                                        '-Wall',
                                        '-Wextra',
                                        '-Wwrite-strings',
+                                       # getMessengerLogger() in the grok code triggers these warnings
+                                       '-Wno-nonnull',
                                        '-Wno-error=deprecated',
                                        # I tried and failed to ignore these with _Pragma
                                        '-Wno-ignored-qualifiers',
                                        '-D_FILE_OFFSET_BITS=64',
-                                       '-std=c++11'])
+                                       '-std=c++' + cpp_std])
 
     if conf.options.disable_more_warnings:
         # These are for Xcode 15.0.1 with the v2.16.x-era
@@ -144,8 +162,10 @@ def configure(conf):
             conf.env.append_value('CXXFLAGS', ['-Wno-cast-function-type'])
         # Most gccs still give these warnings from boost::optional
         conf.env.append_value('CXXFLAGS', ['-Wno-maybe-uninitialized'])
-        if int(gcc[0]) > 4:
+        if int(gcc[0]) > 8:
             # gcc 4.8.5 on Centos 7 does not have this warning
+            # gcc 7.5.0 on Ubuntu 18.04 and gcc 8.3.0 on Debian 10 do, but
+            # I didn't manage to turn it back off again with a pragma
             conf.env.append_value('CXXFLAGS', ['-Wsuggest-override'])
 
     if conf.options.enable_debug:
@@ -156,6 +176,9 @@ def configure(conf):
     if conf.options.enable_disk:
         conf.env.append_value('CXXFLAGS', '-DDCPOMATIC_DISK')
 
+    if conf.options.enable_grok:
+        conf.env.append_value('CXXFLAGS', '-DDCPOMATIC_GROK')
+
     if conf.options.use_lld:
         try:
             conf.find_program('ld.lld')
@@ -228,6 +251,16 @@ def configure(conf):
     # linked and others that should be dynamic.  This doesn't work too well with waf
     # as it wants them separate.
 
+    def check_via_pkg_config(conf, package, uselib_store, mandatory, static, minimum_version):
+        args = package if minimum_version is None else '%s >= %s' % (package, minimum_version)
+        args += ' --cflags'
+        if not static:
+            args += ' --libs'
+        msg = 'Checking for %s' % package
+        if minimum_version is not None:
+            msg += ' >= %s' % minimum_version
+        conf.check_cfg(package=package, args=args, uselib_store=uselib_store, mandatory=mandatory, msg=msg)
+
     # libcurl
     if conf.options.static_curl:
         conf.env.STLIB_CURL = ['curl']
@@ -316,10 +349,10 @@ def configure(conf):
     conf.check_cfg(package='fontconfig', args='--cflags --libs', uselib_store='FONTCONFIG', mandatory=True)
 
     # pangomm
-    conf.check_cfg(package='pangomm-1.4', args='--cflags --libs', uselib_store='PANGOMM', mandatory=True)
+    conf.check_cfg(package='pangomm-' + conf.env.PANGOMM_API, args='--cflags --libs', uselib_store='PANGOMM', mandatory=True)
 
     # cairomm
-    conf.check_cfg(package='cairomm-1.0', args='--cflags --libs', uselib_store='CAIROMM', mandatory=True)
+    conf.check_cfg(package='cairomm-' + conf.env.CAIROMM_API, args='--cflags --libs', uselib_store='CAIROMM', mandatory=True)
 
     # leqm_nrt
     conf.check_cfg(package='leqm_nrt', args='--cflags --libs', uselib_store='LEQM_NRT', mandatory=True)
@@ -351,12 +384,12 @@ def configure(conf):
 
     # libdcp
     if conf.options.static_dcp:
-        conf.check_cfg(package='libdcp-1.0', args='libdcp-1.0 >= %s --cflags' % libdcp_version, uselib_store='DCP', mandatory=True)
+        check_via_pkg_config(conf, 'libdcp-1.0', 'DCP', mandatory=True, static=True, minimum_version=libdcp_version)
         conf.env.DEFINES_DCP = [f.replace('\\', '') for f in conf.env.DEFINES_DCP]
-        conf.env.STLIB_DCP = ['dcp-1.0', 'asdcp-carl', 'kumu-carl', 'openjp2']
+        conf.env.STLIB_DCP = ['dcp-1.0', 'asdcp-dcpomatic', 'kumu-dcpomatic', 'openjp2']
         conf.env.LIB_DCP = ['glibmm-2.4', 'ssl', 'crypto', 'bz2', 'xslt', 'xerces-c']
     else:
-        conf.check_cfg(package='libdcp-1.0', args='libdcp-1.0 >= %s --cflags --libs' % libdcp_version, uselib_store='DCP', mandatory=True)
+        check_via_pkg_config(conf, 'libdcp-1.0', 'DCP', mandatory=True, static=False, minimum_version=libdcp_version)
         conf.env.DEFINES_DCP = [f.replace('\\', '') for f in conf.env.DEFINES_DCP]
 
     # libsub
@@ -370,10 +403,10 @@ def configure(conf):
 
     # libxml++
     if conf.options.static_xmlpp:
-        conf.env.STLIB_XMLPP = ['xml++-2.6']
+        conf.env.STLIB_XMLPP = ['xml++-' + conf.env.XMLPP_API]
         conf.env.LIB_XMLPP = ['xml2']
     else:
-        conf.check_cfg(package='libxml++-2.6', args='--cflags --libs', uselib_store='XMLPP', mandatory=True)
+        conf.check_cfg(package='libxml++-' + conf.env.XMLPP_API, args='--cflags --libs', uselib_store='XMLPP', mandatory=True)
 
     # libxmlsec
     if conf.options.static_xmlsec:
@@ -463,7 +496,7 @@ def configure(conf):
                             int main () { av_ebur128_get_true_peaks (0); }\n
                             """,
                    msg='Checking for EBUR128-patched FFmpeg',
-                   uselib='AVCODEC AVFILTER',
+                   uselib='AVCODEC AVFILTER AVUTIL SWRESAMPLE',
                    define_name='DCPOMATIC_HAVE_EBUR128_PATCHED_FFMPEG',
                    mandatory=False)
 
@@ -596,6 +629,18 @@ def configure(conf):
                            lib=deps,
                            uselib_store='BOOST_PROCESS')
 
+    # sqlite3
+    conf.check_cfg(package="sqlite3", args='--cflags --libs', uselib_store='SQLITE3', mandatory=True)
+    conf.check_cxx(fragment="""
+                       #include <sqlite3.h>
+                       int main() { sqlite3_prepare_v3(nullptr, "", -1, 0, nullptr, nullptr); }
+                       """,
+                   msg='Checking for sqlite3_prepare_v3',
+                   uselib='SQLITE3',
+                   define_name="DCPOMATIC_HAVE_SQLITE3_PREPARE_V3",
+                   mandatory=False)
+
+
     # Other stuff
 
     conf.find_program('msgfmt', var='MSGFMT')
@@ -644,6 +689,21 @@ def configure(conf):
 def build(bld):
     create_version_cc(VERSION, bld.env.CXXFLAGS)
 
+    # waf can't find these dependencies by itself because they are only included if DCPOMATIC_GROK is defined,
+    # and I can't find a way to pass that to waf's dependency scanner
+    if bld.env.ENABLE_GROK:
+        for dep in (
+                'src/lib/j2k_encoder.cc',
+                'src/tools/dcpomatic.cc',
+                'src/tools/dcpomatic_server.cc',
+                'src/tools/dcpomatic_server_cli.cc',
+                'src/tools/dcpomatic_batch.cc'
+        ):
+            bld.add_manual_dependency(bld.path.find_node(dep), bld.path.find_node('src/lib/grok/context.h'))
+            bld.add_manual_dependency(bld.path.find_node(dep), bld.path.find_node('src/lib/grok/messenger.h'))
+
+        bld.add_manual_dependency(bld.path.find_node('src/wx/full_config_dialog.cc'), bld.path.find_node('src/wx/grok/gpu_config_panel.h'))
+
     bld.recurse('src')
     bld.recurse('graphics')