summaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-01-20 23:00:23 +0100
committerCarl Hetherington <cth@carlh.net>2020-03-28 19:47:28 +0100
commit5603b4cae076f286ecf52846dfd317a94a88e559 (patch)
tree46cf9dc9f359029926f4e1806b41c3a64fbaea25 /src/tools
parent9e6d6f9dfe3472dc24f7977d3e24ca923bd95f55 (diff)
Assorted OS X build fixes.
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/dcpomatic_dist.cc3
-rw-r--r--src/tools/dcpomatic_dist_writer.cc47
-rw-r--r--src/tools/wscript5
3 files changed, 40 insertions, 15 deletions
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 <wx/wx.h>
#include <boost/process.hpp>
+#ifdef __WXOSX__
+#include <ApplicationServices/ApplicationServices.h>
+#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 <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;
}
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 '