Assorted OS X build fixes.
authorCarl Hetherington <cth@carlh.net>
Mon, 20 Jan 2020 22:00:23 +0000 (23:00 +0100)
committerCarl Hetherington <cth@carlh.net>
Sat, 28 Mar 2020 18:47:28 +0000 (19:47 +0100)
cscript
src/lib/cross.cc
src/lib/wscript
src/tools/dcpomatic_dist.cc
src/tools/dcpomatic_dist_writer.cc
src/tools/wscript

diff --git a/cscript b/cscript
index ff6320443a80fdad81ce9de5ecdf7ad9274f5b4c..0a0a73c8857f52dac869fdc48a5e83abfc7584f3 100644 (file)
--- 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'
index 2f3ed988ac093d87636c5a6d5395e93c5d095c99..b008d174194d8838e9a1cfbc7b56f033f391483c 100644 (file)
@@ -47,6 +47,8 @@ extern "C" {
 #include <sys/sysctl.h>
 #include <mach-o/dyld.h>
 #include <IOKit/pwr_mgt/IOPMLib.h>
+#include <DiskArbitration/DADisk.h>
+#include <DiskArbitration/DiskArbitration.h>
 #endif
 #ifdef DCPOMATIC_POSIX
 #include <sys/types.h>
@@ -552,7 +554,7 @@ disk_appeared(DADiskRef disk, void* context)
        const char* name = DADiskGetBSDName (disk);
        if (name) {
                list<Drive>* drives = reinterpret_cast<list<Drive>*> (context);
-               drives->push_back (name, 0, false, optional<string>(), optional<string>());
+               drives->push_back (Drive(name, 0, false, optional<string>(), optional<string>()));
        }
 }
 #endif
@@ -683,7 +685,6 @@ get_drives ()
        CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.05, 0);
        DAUnregisterCallback(session, (void *) disk_appeared, &drives);
        CFRelease(session);
-}
 #endif
 
 #ifdef DCPOMATIC_LINUX
index b809f2adada8771fc7fe2934074738e2b2718855..7b559874613f33c835d971c1213de4d6ab292f2e 100644 (file)
@@ -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'
 
index 54784761f7c2f9b8fbaa1cbcebc703b630d02761..b04f8fd6102ef5c1008a796a9acd7310c40893b8 100644 (file)
@@ -32,6 +32,9 @@
 #include "lib/job_manager.h"
 #include <wx/wx.h>
 #include <boost/process.hpp>
+#ifdef __WXOSX__
+#include <ApplicationServices/ApplicationServices.h>
+#endif
 
 using std::string;
 using std::exception;
index 08e5a109ea74c626ccad5281bd2ad3c06af2c5cd..52763185dfbdf856578d9ed0ceaa19a54db4e806 100644 (file)
@@ -32,14 +32,22 @@ extern "C" {
 #include <lwext4/ext4_debug.h>
 #include <lwext4/ext4.h>
 }
-#ifndef WIN32
+
+#ifdef DCPOMATIC_POSIX
 #include <sys/ioctl.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <linux/fs.h>
+#ifdef DCPOMATIC_OSX
+#undef nil
 #endif
-#include <polkit/polkit.h>
 #include <glibmm.h>
+#endif
+
+#ifdef DCPOMATIC_LINUX
+#include <linux/fs.h>
+#include <polkit/polkit.h>
+#endif
+
 #include <unistd.h>
 #include <sys/types.h>
 #include <poll.h>
@@ -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;
 }
index 3bf62288d1fb52a3ecdd486757daf2187c386cf0..59cb38d1037afbfa2fe3fe9eb071eb0396299d98 100644 (file)
@@ -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 '