summary history branches tags files
commit:c8a04847e982daad919c18680ca107d456984585
author:Trevor Bentley
committer:GitHub
date:Wed Jul 26 10:31:18 2017 +0200
parents:629c4cf5304a80f7421e60c6749d6e043c4bb215, 1317bd877854f1a5b1e5275ede1b185f2a62c73f
Merge pull request #9 from mrmekon/ignore_xcode_non_osx

Fix builds on non-Mac platforms
diff --git a/.travis.yml b/.travis.yml
line changes: +1/-0
index 0455005..b351460
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,6 +6,7 @@ rust:
   - nightly
 os:
  - osx
+ - linux
 matrix:
   allow_failures:
     - rust: nightly

diff --git a/README.md b/README.md
line changes: +10/-0
index 4805006..bd45fa5
--- a/README.md
+++ b/README.md
@@ -34,12 +34,22 @@ To communicate with the Touch Bar service, apps using Rubrail *must* be executed
 
 The included example comes with a bundling script (examples/example.sh) and a launcher (examples/example_launcher.rs) to move itself into an app bundle and execute.
 
+
 ### Limitations
 
 There is no support for changing the UI of an existing bar.  To change the UI layout, you must create a new bar and completely replace the old one.  Scrubbers are an exception: their contents are managed by callbacks, but they do not live-refresh when the bar is visible.  The user must close and re-open the bar to see scrubber content changes.
 
 The Touch Bar API supports doing just about anything with custom views.  Rubrail does not.  Only a very limited set of UI options are exposed.
 
+#### Linking
+
+Rubrail links against the private Apple framework `DFRFoundation.framework`.  This is handled by adding the private framework path in `build.rs`.  Applications that _use_ Rubrail do not need to link against it themselves, but should be aware that a dependency does.
+
+Linking requires an XCode version high enough to support the Touch Bar and the private framework.  The only tested version of XCode is version 8.3.  Applications that use Rubrail **must** build with a new enough XCode version.  If using Travis-CI, this means adding a line like this to your `.travis.yml`:
+
+`osx_image: xcode8.3`
+
+
 ### Known Bugs
 
 Memory leaks!  Memory leaks as far as the eye can see.

diff --git a/build.rs b/build.rs
line changes: +7/-2
index 4a31dd4..430cd11
--- a/build.rs
+++ b/build.rs
@@ -1,4 +1,5 @@
-fn main() {
+#[allow(dead_code)]
+fn add_xcode_private_framework_path() {
     // PrivateFramework dir:
     // `xcode-select -p`/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/PrivateFrameworks/
     let xcode_dir = std::process::Command::new("xcode-select")
@@ -11,7 +12,11 @@ fn main() {
                                 xcode_dir);
     println!("XCode PrivateFramework dir: {}", framework_dir);
 
+    println!("cargo:rustc-link-search=framework={}", framework_dir);
+}
+
+fn main() {
     #[cfg(target_os = "macos")]
     #[cfg(feature = "private_api")]
-    println!("cargo:rustc-link-search=framework={}", framework_dir);
+    add_xcode_private_framework_path();
 }

diff --git a/examples/example.rs b/examples/example.rs
line changes: +1/-1
index b60d76c..24c4a2b
--- a/examples/example.rs
+++ b/examples/example.rs
@@ -77,7 +77,7 @@ fn populate(bar_rc: Rc<RefCell<Touchbar>>, count: u32) {
     tb.update_label_width(&label1_id, 100);
 
     // Support double-clicking the label with one finger
-    tb.add_item_tap_gesture(&label1_id, 2, 1, Box::new(move |item| {
+    tb.add_item_tap_gesture(&label1_id, 2, 1, Box::new(move |_item| {
         info!("Label double-clicked!");
     }));
 

diff --git a/src/lib.rs b/src/lib.rs
line changes: +22/-21
index 34b5f0c..953f8d1
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -58,15 +58,18 @@
 mod interface;
 pub use interface::*;
 
+#[allow(unused_imports)]
+#[macro_use]
+extern crate log;
+
+//
+// Mac+TouchBar imports
+//
 #[cfg(target_os = "macos")]
 #[cfg(feature = "private_api")]
 #[macro_use]
 mod wrapper;
 
-#[allow(unused_imports)]
-#[macro_use]
-extern crate log;
-
 #[cfg(target_os = "macos")]
 #[cfg(feature = "private_api")]
 #[macro_use]
@@ -77,27 +80,25 @@ extern crate objc;
 #[macro_use]
 mod touchbar;
 
-/// Main controller for creating and using Touch Bar UIs
-///
-/// Blah
 #[cfg(target_os = "macos")]
 #[cfg(feature = "private_api")]
 pub use touchbar::Touchbar as Touchbar;
 
-#[cfg(not(feature = "private_api"))]
-mod dummy;
-
-/// Main controller for creating and using Touch Bar UIs
-///
-/// Blah
-#[cfg(not(feature = "private_api"))]
-pub use dummy::DummyTouchbar as Touchbar;
-
 #[cfg(target_os = "macos")]
 #[cfg(feature = "private_api")]
 pub use touchbar::util;
 
-#[cfg(not(feature = "private_api"))]
+
+//
+// Non-Mac/Dummy TouchBar imports
+//
+#[cfg(not(all(target_os = "macos", feature = "private_api")))]
+mod dummy;
+
+#[cfg(not(all(target_os = "macos", feature = "private_api")))]
+pub use dummy::DummyTouchbar as Touchbar;
+
+#[cfg(not(all(target_os = "macos", feature = "private_api")))]
 pub use dummy::util;
 
 /// Module for creating and running a simple Mac application
@@ -113,7 +114,7 @@ pub mod app {
     extern crate objc;
     extern crate log4rs;
     use std::env;
-    #[cfg(not(feature = "private_api"))]
+    #[cfg(not(all(target_os = "macos", feature = "private_api")))]
     use std::process;
 
     #[cfg(target_os = "macos")]
@@ -135,7 +136,7 @@ pub mod app {
             let _ = msg_send![app, setActivationPolicy: 1]; // NSApplicationActivationPolicyAccessory
         }
     }
-    #[cfg(not(feature = "private_api"))]
+    #[cfg(not(all(target_os = "macos", feature = "private_api")))]
     ///
     pub fn init_app() {}
 
@@ -154,7 +155,7 @@ pub mod app {
             let _ = msg_send![app, run];
         }
     }
-    #[cfg(not(feature = "private_api"))]
+    #[cfg(not(all(target_os = "macos", feature = "private_api")))]
     ///
     pub fn run_forever() { loop {} }
 
@@ -173,7 +174,7 @@ pub mod app {
             let _ = msg_send![app, terminate: 0];
         }
     }
-    #[cfg(not(feature = "private_api"))]
+    #[cfg(not(all(target_os = "macos", feature = "private_api")))]
     ///
     pub fn quit() {
         process::exit(0);