From: Carl Hetherington Date: Mon, 20 Jan 2020 22:00:23 +0000 (+0100) Subject: Assorted OS X build fixes. X-Git-Url: https://main.carlh.net/gitweb/?a=commitdiff_plain;ds=sidebyside;h=5603b4cae076f286ecf52846dfd317a94a88e559;hp=9e6d6f9dfe3472dc24f7977d3e24ca923bd95f55;p=dcpomatic.git Assorted OS X build fixes. --- diff --git a/cscript b/cscript index ff6320443..0a0a73c88 100644 --- a/cscript +++ b/cscript @@ -203,7 +203,7 @@ def build_dist(target): # - Lots of Linux distros don't have a new enough boost (1.64 or above) # - On Centos 6 we can't build lwext4 because it needs a new CMake which Centos 6's g++ is not new enough to build. # - On Centos 7 there is a build error in lwext4 related to __unused - return target.platform == 'windows' or (target.platform == 'linux' and target.distro == 'ubuntu' and target.version in ['18.04', '18.10', '19.04']) + return target.platform == 'windows' or target.platform == 'osx' or (target.platform == 'linux' and target.distro == 'ubuntu' and target.version in ['18.04', '18.10', '19.04']) def packages(name, packages, f): s = '%s: ' % name @@ -401,6 +401,8 @@ def configure_options(target, options): # I worry that this will cause ABI problems but I don't have # a better solution. opt += ' --force-cpp11' + elif target.platform == 'osx' and target.bits == 64: + opt += ' --force-cpp11' if not options['gui']: opt += ' --disable-gui' diff --git a/src/lib/cross.cc b/src/lib/cross.cc index 2f3ed988a..b008d1741 100644 --- a/src/lib/cross.cc +++ b/src/lib/cross.cc @@ -47,6 +47,8 @@ extern "C" { #include #include #include +#include +#include #endif #ifdef DCPOMATIC_POSIX #include @@ -552,7 +554,7 @@ disk_appeared(DADiskRef disk, void* context) const char* name = DADiskGetBSDName (disk); if (name) { list* drives = reinterpret_cast*> (context); - drives->push_back (name, 0, false, optional(), optional()); + drives->push_back (Drive(name, 0, false, optional(), optional())); } } #endif @@ -683,7 +685,6 @@ get_drives () CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.05, 0); DAUnregisterCallback(session, (void *) disk_appeared, &drives); CFRelease(session); -} #endif #ifdef DCPOMATIC_LINUX diff --git a/src/lib/wscript b/src/lib/wscript index b809f2ada..7b5598746 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -197,7 +197,7 @@ def build(bld): """ if bld.env.TARGET_OSX: - obj.framework = ['IOKit', 'Foundation'] + obj.framework = ['IOKit', 'Foundation', 'DiskArbitration'] obj.source = sources + ' version.cc' diff --git a/src/tools/dcpomatic_dist.cc b/src/tools/dcpomatic_dist.cc index 54784761f..b04f8fd61 100644 --- a/src/tools/dcpomatic_dist.cc +++ b/src/tools/dcpomatic_dist.cc @@ -32,6 +32,9 @@ #include "lib/job_manager.h" #include #include +#ifdef __WXOSX__ +#include +#endif using std::string; using std::exception; diff --git a/src/tools/dcpomatic_dist_writer.cc b/src/tools/dcpomatic_dist_writer.cc index 08e5a109e..52763185d 100644 --- a/src/tools/dcpomatic_dist_writer.cc +++ b/src/tools/dcpomatic_dist_writer.cc @@ -32,14 +32,22 @@ extern "C" { #include #include } -#ifndef WIN32 + +#ifdef DCPOMATIC_POSIX #include #include #include -#include +#ifdef DCPOMATIC_OSX +#undef nil #endif -#include #include +#endif + +#ifdef DCPOMATIC_LINUX +#include +#include +#endif + #include #include #include @@ -51,7 +59,9 @@ using std::cin; using std::min; using std::string; +#ifdef DCPOMATIC_LINUX static PolkitAuthority* polkit_authority = 0; +#endif static boost::filesystem::path dcp_path; static std::string device; static uint64_t const block_size = 4096; @@ -205,6 +215,7 @@ copy (boost::filesystem::path from, boost::filesystem::path to, uint64_t& total_ static void write () +try { // ext4_dmask_set (DEBUG_ALL); @@ -246,7 +257,7 @@ write () throw CopyError ("Failed to write MBR", r); } -#ifdef WIN32 +#ifdef DCPOMATIC_WINDOWS struct ext4_mbr_bdevs bdevs; r = ext4_mbr_scan (bd, &bdevs); if (r != EOK) { @@ -254,12 +265,16 @@ write () } file_windows_partition_set (bdevs.partitions[0].part_offset, bdevs.partitions[0].part_size); -#else +#endif + +#ifdef DCPOMATIC_LINUX /* Re-read the partition table */ int fd = open(device.c_str(), O_RDONLY); ioctl(fd, BLKRRPART, NULL); close(fd); +#endif +#ifdef DCPOMATIC_POSIX string partition = device; /* XXX: don't know if this logic is sensible */ if (partition.size() > 0 && isdigit(partition[partition.length() - 1])) { @@ -302,28 +317,28 @@ write () cout << DIST_WRITER_OK "\n"; cout.flush (); +} catch (CopyError& e) { + cout << DIST_WRITER_ERROR "\n" << e.message() << "\n" << e.number() << "\n"; + cout.flush (); +} catch (VerifyError& e) { + cout << DIST_WRITER_ERROR "\n" << e.message() << "\n" << e.number() << "\n"; + cout.flush (); } +#ifdef DCPOMATIC_LINUX static void polkit_callback (GObject *, GAsyncResult* res, gpointer) { PolkitAuthorizationResult* result = polkit_authority_check_authorization_finish (polkit_authority, res, 0); if (result && polkit_authorization_result_get_is_authorized(result)) { - try { - write (); - } catch (CopyError& e) { - cout << DIST_WRITER_ERROR "\n" << e.message() << "\n" << e.number() << "\n"; - cout.flush (); - } catch (VerifyError& e) { - cout << DIST_WRITER_ERROR "\n" << e.message() << "\n" << e.number() << "\n"; - cout.flush (); - } + write (); } if (result) { g_object_unref (result); } } +#endif bool idle () @@ -340,11 +355,15 @@ idle () getline (cin, s); device = "/dev/" + s; +#ifdef DCPOMATIC_LINUX polkit_authority = polkit_authority_get_sync (0, 0); PolkitSubject* subject = polkit_unix_process_new (getppid()); polkit_authority_check_authorization ( polkit_authority, subject, "com.dcpomatic.write-drive", 0, POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION, 0, polkit_callback, 0 ); +#else + write (); +#endif } return true; } diff --git a/src/tools/wscript b/src/tools/wscript index 3bf62288d..59cb38d10 100644 --- a/src/tools/wscript +++ b/src/tools/wscript @@ -33,7 +33,10 @@ def build(bld): uselib += 'SNDFILE SAMPLERATE BOOST_REGEX ICU NETTLE RTAUDIO PNG ' if bld.env.TARGET_LINUX: - uselib += 'POLKIT LWEXT4 ' + uselib += 'POLKIT ' + + if bld.env.TARGET_LINUX or bld.env.TARGET_OSX: + uselib += 'LWEXT4 ' if bld.env.TARGET_WINDOWS: uselib += 'WINSOCK2 DBGHELP SHLWAPI MSWSOCK BOOST_LOCALE WINSOCK2 OLE32 DSOUND WINMM KSUSER '