Skip to content

Commit 4037bfe

Browse files
authored
Merge pull request #22 from fitzgen/build-on-osx
Add support for OSX
2 parents af3857b + d6df59f commit 4037bfe

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

.travis.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
language: rust
22
sudo: false
3+
4+
os:
5+
- linux
6+
- osx
7+
38
env:
49
global:
510
- secure: gZdvTl4i1QfHQaCUPcVpnLtlrsE4WldSm99AD9C9jiMgjlzhhI4kQmIhssNFhA1BWDW6qDazrKnw4ZT1GA/rlmGSpLxs2lfBNTjPF0CJMVSTEQ1OaFcDGajziTTCSMh7jDml1/CFHuGSc+rS4bNv5wu0bj+pz3ZSRSuB7Vgoa0aRD8JQKc+phnIoXMCCfIh9vxlXWvO9mDMoR84/B35/gN/vWIi3+uuHgvvdKMK8qBbJ0ne25kOIA5CpXzJmOBFHCGblVQM4+AiTWvWtoXJjMcJXn9HZ2g3HWhrnixG07Ee1RrjUPo25tsxrBowHSGq9Bbo+jzmOmx03CRnCBHyXk6e12MXrfVFWRdmFaf7Sl/RBlz8Y2BRgktp8ihB6JQmjNuRptE4RdnWn6CU9liSQ5nzzGEl2ZtBrzN9GR3qyhq5W9e09v93MZfBr0svp/rtBoqDANfkpxvmWqtgO3fjN1fdf092sEcQfq3d7e6NaLSWKkI6V9wJnJ9UulPDAaqGVm8RrA9b0vJR6ouCf5ChZgYirz6LW5uPpMkf+cjESU9JxnX9xVB8tfPSoNrPKolRC/WRZ8gPbRmx0vF4wrDk8z9Fks5nHGwDsPdYe60Qe8m6ZclncCkpUzy2yAZWe/kiDaseOwNbSqEUZW80hLyHpuGi1IFpGBQfc8mYMPvqOHa8=
@@ -9,7 +14,7 @@ script:
914
- cargo test --verbose
1015
- cargo doc
1116

12-
after_success: '[ $TRAVIS_BRANCH = master ] && [ $TRAVIS_PULL_REQUEST = false ] &&
17+
after_success: '[ $TRAVIS_OS_NAME == linux ] && [ $TRAVIS_BRANCH = master ] && [ $TRAVIS_PULL_REQUEST = false ] &&
1318
echo "<meta http-equiv=refresh content=0;url=i2cdev/index.html>" > target/doc/index.html
1419
&& sudo pip install ghp-import && ghp-import -n target/doc && git push -fq https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git
1520
gh-pages'

examples/nunchuck.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111
extern crate i2cdev;
1212
extern crate docopt;
1313

14+
#[cfg(any(target_os = "linux", target_os = "android"))]
1415
use i2cdev::linux::*;
16+
#[cfg(any(target_os = "linux", target_os = "android"))]
1517
use i2cdev::sensors::nunchuck::*;
18+
1619
use std::env::args;
1720
use docopt::Docopt;
1821

19-
2022
const USAGE: &'static str = "
2123
Reading Wii Nunchuck data via Linux i2cdev.
2224
@@ -30,7 +32,10 @@ Options:
3032
--version Show version.
3133
";
3234

35+
#[cfg(not(any(target_os = "linux", target_os = "android")))]
36+
fn main() {}
3337

38+
#[cfg(any(target_os = "linux", target_os = "android"))]
3439
fn main() {
3540
let args = Docopt::new(USAGE)
3641
.and_then(|d| d.argv(args().into_iter()).parse())

examples/sensors.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use docopt::Docopt;
2121
use i2cdev::sensors::{Thermometer, Barometer, Accelerometer};
2222
use i2cdev::sensors::mpl115a2_barometer::*;
2323
use i2cdev::sensors::adxl345_accelerometer::*;
24+
#[cfg(any(target_os = "linux", target_os = "android"))]
2425
use i2cdev::linux::*;
2526

2627
const USAGE: &'static str = "
@@ -36,6 +37,10 @@ Options:
3637
--version Show version.
3738
";
3839

40+
#[cfg(not(any(target_os = "linux", target_os = "android")))]
41+
fn main() {}
42+
43+
#[cfg(any(target_os = "linux", target_os = "android"))]
3944
fn main() {
4045
let args = Docopt::new(USAGE)
4146
.and_then(|d| d.argv(args().into_iter()).parse())

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ extern crate bitflags;
2323
#[macro_use]
2424
extern crate nix;
2525

26+
#[cfg(any(target_os = "linux", target_os = "android"))]
2627
mod ffi;
28+
2729
pub mod core;
2830
pub mod sensors;
2931

0 commit comments

Comments
 (0)