From cdf9f6f74fb5ddc54552f2a02686d98e81035590 Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Sun, 9 Sep 2018 23:24:43 -0500 Subject: [PATCH] include slop --- .gitmodules | 3 +++ Cargo.lock | 17 +++++++++++++++++ Cargo.toml | 5 ++++- slop-sys/Cargo.lock | 4 ++++ slop-sys/Cargo.toml | 13 +++++++++++++ slop-sys/build.rs | 12 ++++++++++++ src/slop.rs => slop-sys/lib.rs | 0 slop-sys/slop | 1 + src/build.rs | 4 ---- src/main.rs | 11 ++++------- src/selection.rs | 2 +- 11 files changed, 59 insertions(+), 13 deletions(-) create mode 100644 .gitmodules create mode 100644 slop-sys/Cargo.lock create mode 100644 slop-sys/Cargo.toml create mode 100644 slop-sys/build.rs rename src/slop.rs => slop-sys/lib.rs (100%) create mode 160000 slop-sys/slop delete mode 100644 src/build.rs diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..ae6ebfb --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "slop-sys/slop"] + path = slop-sys/slop + url = https://github.com/naelstrof/slop.git diff --git a/Cargo.lock b/Cargo.lock index c4c5deb..3a7b3dc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -105,6 +105,14 @@ dependencies = [ "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "cmake" +version = "0.1.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "failure" version = "0.1.1" @@ -360,9 +368,17 @@ dependencies = [ "gdk-pixbuf 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "gio 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "gtk 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "slop-sys 0.1.0", "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "slop-sys" +version = "0.1.0" +dependencies = [ + "cmake 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "strsim" version = "0.7.0" @@ -470,6 +486,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum cc 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)" = "0ebb87d1116151416c0cf66a0e3fb6430cccd120fd6300794b4dfaa050ac40ba" "checksum cfg-if 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "405216fd8fe65f718daa7102ea808a946b6ce40c742998fbfd3463645552de18" "checksum clap 2.31.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f0f16b89cbb9ee36d87483dc939fe9f1e13c05898d56d7b230a0d4dff033a536" +"checksum cmake 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)" = "704fbf3bb5149daab0afb255dbea24a1f08d2f4099cedb9baab6d470d4c5eefb" "checksum failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "934799b6c1de475a012a02dab0ace1ace43789ee4b99bcfbf1a2e3e8ced5de82" "checksum failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c7cdda555bb90c9bb67a3b670a0f42de8e73f5981524123ad8578aafec8ddb8b" "checksum gdk 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dd30051ff3d908ff2fc7e5776ffe1c699821e043809f294c3a61004f11d6c3a9" diff --git a/Cargo.toml b/Cargo.toml index a324d5a..422046a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,9 @@ name = "screenshot" version = "0.2.3" authors = ["Michael Zhang "] -build = "src/build.rs" + +[workspace] +members = [".", "slop-sys"] [dependencies] clap = "2.31.2" @@ -13,3 +15,4 @@ gdk-pixbuf = "0.4.0" gio = "0.4.0" gtk = { version = "0.4.1", features = ["v3_16"] } time = "0.1.40" +slop-sys = { path = "slop-sys" } diff --git a/slop-sys/Cargo.lock b/slop-sys/Cargo.lock new file mode 100644 index 0000000..bd4ff7e --- /dev/null +++ b/slop-sys/Cargo.lock @@ -0,0 +1,4 @@ +[[package]] +name = "slop-sys" +version = "0.1.0" + diff --git a/slop-sys/Cargo.toml b/slop-sys/Cargo.toml new file mode 100644 index 0000000..ef0768a --- /dev/null +++ b/slop-sys/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "slop-sys" +version = "0.1.0" +authors = ["Michael Zhang "] +build = "build.rs" + +[lib] +path = "lib.rs" + +[build-dependencies] +cmake = "0.1" + +[dependencies] diff --git a/slop-sys/build.rs b/slop-sys/build.rs new file mode 100644 index 0000000..6189406 --- /dev/null +++ b/slop-sys/build.rs @@ -0,0 +1,12 @@ +extern crate cmake; + +use cmake::Config; + +fn main() { + let dst = Config::new("slop").define("CMAKE_SKIP_RPATH", "ON").build(); + println!("cargo:rustc-link-search=native={}", dst.display()); + println!("cargo:rustc-link-lib=slopy"); + + // println!("cargo:rustc-link-lib=slopy"); + // println!("cargo:rustc-link-search=native=/usr/lib/usr/lib/x86_64-linux-gnu"); +} diff --git a/src/slop.rs b/slop-sys/lib.rs similarity index 100% rename from src/slop.rs rename to slop-sys/lib.rs diff --git a/slop-sys/slop b/slop-sys/slop new file mode 160000 index 0000000..2196617 --- /dev/null +++ b/slop-sys/slop @@ -0,0 +1 @@ +Subproject commit 2196617d8e10bb4a4a1e4a1520af4cab890f1e00 diff --git a/src/build.rs b/src/build.rs deleted file mode 100644 index 43532e6..0000000 --- a/src/build.rs +++ /dev/null @@ -1,4 +0,0 @@ -fn main() { - println!("cargo:rustc-link-lib=slopy"); - println!("cargo:rustc-link-search=native=/usr/lib:/usr/lib/x86_64-linux-gnu"); -} diff --git a/src/main.rs b/src/main.rs index 991d681..9d54eb3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,13 +9,13 @@ extern crate gdk; extern crate gdk_pixbuf; extern crate gio; extern crate gtk; +extern crate slop_sys; extern crate time; mod capture; mod errors; mod options; mod selection; -mod slop; use std::process::exit; @@ -42,22 +42,19 @@ fn run() -> Result<(), Error> { .help("The region to be captured.") .takes_value(false) .required(true), - ) - .arg( + ).arg( Arg::with_name("output") .alias("o") .long("output") .help("Specify the output file.") .takes_value(true) .required(true), - ) - .arg( + ).arg( Arg::with_name("clip") .alias("c") .long("clip") .help("Copies the image to the clipboard if set."), - ) - .get_matches(); + ).get_matches(); let region = match app.value_of("region").unwrap() { "fullscreen" => Region::Fullscreen, "active" | "window" => Region::ActiveWindow, diff --git a/src/selection.rs b/src/selection.rs index e0e8f78..b7ffeca 100644 --- a/src/selection.rs +++ b/src/selection.rs @@ -4,7 +4,7 @@ use failure::Error; use gdk_pixbuf::{Pixbuf, PixbufExt}; use errors::ScreenshotError; -use slop::{slop_options, slop_select}; +use slop_sys::{slop_options, slop_select}; pub fn select_area(pixbuf: Pixbuf) -> Result { let xdisplay = CString::new(":0")?.as_ptr();