From: Carl Hetherington Date: Thu, 22 Feb 2024 21:51:44 +0000 (+0100) Subject: Allow building with C++17 and updated libxml++/pangomm/cairomm. X-Git-Tag: v2.17.14~7 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=0232d80a625b2ffae687e6473ab3fc2603cf87ea Allow building with C++17 and updated libxml++/pangomm/cairomm. --- diff --git a/hacks/text.cc b/hacks/text.cc index bf391a325..ff5d6f8b8 100644 --- a/hacks/text.cc +++ b/hacks/text.cc @@ -19,10 +19,10 @@ int main () Cairo::RefPtr surface = Cairo::ImageSurface::create ( data, - Cairo::FORMAT_ARGB32, + Cairo::ImageSurface::Format::ARGB32, width, height, /* Cairo ARGB32 means first byte blue, second byte green, third byte red, fourth byte alpha */ - Cairo::ImageSurface::format_stride_for_width (Cairo::FORMAT_ARGB32, width) + Cairo::ImageSurface::format_stride_for_width(Cairo::ImageSurface::Format::ARGB32, width) ); Cairo::RefPtr context = Cairo::Context::create (surface); @@ -33,7 +33,7 @@ int main () context->rectangle (0, 0, width, height); context->fill (); - layout->set_alignment (Pango::ALIGN_LEFT); + layout->set_alignment (Pango::Alignment::LEFT); context->set_line_width (1); // Cairo::FontOptions fo; diff --git a/platform/osx/make_dmg.sh b/platform/osx/make_dmg.sh index 161261faa..9f9cbdd37 100644 --- a/platform/osx/make_dmg.sh +++ b/platform/osx/make_dmg.sh @@ -168,7 +168,7 @@ function copy_libs { copy_lib_env libxml++ "$dest" copy_lib_env libxslt "$dest" copy_lib_env libxml2 "$dest" - copy_lib_env libglibmm-2.4 "$dest" + copy_lib_env libglibmm "$dest" copy_lib_env libgobject "$dest" copy_lib_env libgthread "$dest" copy_lib_env libgmodule "$dest" diff --git a/src/lib/render_text.cc b/src/lib/render_text.cc index 870f3045d..9f1f69edb 100644 --- a/src/lib/render_text.cc +++ b/src/lib/render_text.cc @@ -51,6 +51,15 @@ using boost::optional; using namespace dcpomatic; +#if CAIROMM_MAJOR_VERSION == 1 && CAIROMM_MINOR_VERSION <= 14 +#define DCPOMATIC_OLD_CAIROMM_API +#endif + +#if PANGOMM_MAJOR_VERSION == 2 && PANGOMM_MINOR_VERSION <= 46 +#define DCPOMATIC_OLD_PANGOMM_API +#endif + + /** Create a Pango layout using a dummy context which we can use to calculate the size * of the text we will render. Then we can transfer the layout over to the real context * for the actual render. @@ -66,7 +75,11 @@ create_layout(string font_name, string markup) auto context = Glib::wrap (c_context); auto layout = Pango::Layout::create(context); - layout->set_alignment (Pango::ALIGN_LEFT); +#ifdef DCPOMATIC_OLD_PANGOMM_API + layout->set_alignment(Pango::ALIGN_LEFT); +#else + layout->set_alignment(Pango::Alignment::LEFT); +#endif Pango::FontDescription font (font_name); layout->set_font_description (font); layout->set_markup (markup); @@ -163,11 +176,22 @@ create_surface (shared_ptr image) DCPOMATIC_ASSERT (image->pixel_format() == AV_PIX_FMT_BGRA); return Cairo::ImageSurface::create ( image->data()[0], +#ifdef DCPOMATIC_OLD_CAIROMM_API Cairo::FORMAT_ARGB32, +#else + Cairo::ImageSurface::Format::ARGB32, +#endif image->size().width, image->size().height, /* Cairo ARGB32 means first byte blue, second byte green, third byte red, fourth byte alpha */ - Cairo::ImageSurface::format_stride_for_width (Cairo::FORMAT_ARGB32, image->size().width) + Cairo::ImageSurface::format_stride_for_width( +#ifdef DCPOMATIC_OLD_CAIROMM_API + Cairo::FORMAT_ARGB32, +#else + Cairo::ImageSurface::Format::ARGB32, +#endif + image->size().width + ) ); } @@ -394,7 +418,11 @@ render_line(vector subtitles, dcp::Size target, DCPTime time, int fr /* Border effect */ set_source_rgba (context, first.effect_colour(), fade_factor); context->set_line_width (border_width); +#ifdef DCPOMATIC_OLD_CAIROMM_API context->set_line_join (Cairo::LINE_JOIN_ROUND); +#else + context->set_line_join (Cairo::Context::LineJoin::ROUND); +#endif context->move_to (x_offset, y_offset); layout.pango->add_to_cairo_context (context); context->stroke (); diff --git a/test/film_metadata_test.cc b/test/film_metadata_test.cc index 878e60254..2bd60dc81 100644 --- a/test/film_metadata_test.cc +++ b/test/film_metadata_test.cc @@ -66,7 +66,7 @@ BOOST_AUTO_TEST_CASE (film_metadata_test) film->set_audio_channels(6); film->write_metadata (); - list ignore = { "Key", "ContextID", "LastWrittenBy" }; + list ignore = { "Key", "ContextID", "LastWrittenBy" }; check_xml ("test/data/metadata.xml.ref", dir.string() + "/metadata.xml", ignore); auto g = make_shared(dir); diff --git a/test/test.cc b/test/test.cc index 57f4ae203..9ab7fe480 100644 --- a/test/test.cc +++ b/test/test.cc @@ -584,7 +584,7 @@ check_dcp(boost::filesystem::path ref, boost::filesystem::path check, bool sound } void -check_xml (xmlpp::Element* ref, xmlpp::Element* test, list ignore) +check_xml(xmlpp::Element* ref, xmlpp::Element* test, list ignore) { BOOST_CHECK_EQUAL (ref->get_name (), test->get_name ()); BOOST_CHECK_EQUAL (ref->get_namespace_prefix (), test->get_namespace_prefix ()); @@ -640,7 +640,7 @@ check_xml (xmlpp::Element* ref, xmlpp::Element* test, list ignore) } void -check_xml (boost::filesystem::path ref, boost::filesystem::path test, list ignore) +check_xml(boost::filesystem::path ref, boost::filesystem::path test, list ignore) { auto ref_parser = new xmlpp::DomParser(ref.string()); auto ref_root = ref_parser->get_document()->get_root_node(); diff --git a/test/test.h b/test/test.h index 6687affea..0776d6e5a 100644 --- a/test/test.h +++ b/test/test.h @@ -22,6 +22,7 @@ #include "lib/video_frame_type.h" #include #include +#include #include #include @@ -66,7 +67,7 @@ extern void check_text_file (boost::filesystem::path ref, boost::filesystem::pat extern void check_wav_file (boost::filesystem::path ref, boost::filesystem::path check); extern void check_mxf_audio_file (boost::filesystem::path ref, boost::filesystem::path check); extern bool mxf_atmos_files_same (boost::filesystem::path ref, boost::filesystem::path check, bool verbose = false); -extern void check_xml (boost::filesystem::path, boost::filesystem::path, std::list); +extern void check_xml(boost::filesystem::path, boost::filesystem::path, std::list); extern void check_ffmpeg (boost::filesystem::path, boost::filesystem::path, int audio_tolerance); extern void check_image (boost::filesystem::path, boost::filesystem::path, double threshold = 4); extern boost::filesystem::path test_film_dir (std::string); diff --git a/wscript b/wscript index 6dd7417cd..96d3c030c 100644 --- a/wscript +++ b/wscript @@ -81,6 +81,7 @@ def options(opt): 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') def configure(conf): conf.load('compiler_cxx') @@ -88,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 @@ -119,7 +131,7 @@ def configure(conf): # 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 @@ -328,10 +340,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) @@ -382,10 +394,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: