From 7918bf39f5f0efc4163a564872a4ae52c2b29434 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Fri, 26 Aug 2022 15:10:26 -0600 Subject: [PATCH] Make capture example its own crate --- Cargo.lock | 15 +++++++++++++ crates/capture/Cargo.toml | 21 +++++++++++++++++++ crates/capture/build.rs | 3 +++ crates/capture/script/capture | 5 +++++ .../capture.rs => capture/src/main.rs} | 10 +++++---- crates/gpui/Cargo.toml | 5 ----- crates/gpui/build.rs | 3 --- crates/gpui/script/capture | 4 ---- 8 files changed, 50 insertions(+), 16 deletions(-) create mode 100644 crates/capture/Cargo.toml create mode 100644 crates/capture/build.rs create mode 100755 crates/capture/script/capture rename crates/{gpui/examples/capture.rs => capture/src/main.rs} (88%) delete mode 100755 crates/gpui/script/capture diff --git a/Cargo.lock b/Cargo.lock index 634ef452a3..e12e49184d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -750,6 +750,21 @@ dependencies = [ "winx", ] +[[package]] +name = "capture" +version = "0.1.0" +dependencies = [ + "block", + "cocoa", + "core-foundation", + "core-graphics", + "foreign-types", + "gpui", + "log", + "objc", + "simplelog", +] + [[package]] name = "castaway" version = "0.1.2" diff --git a/crates/capture/Cargo.toml b/crates/capture/Cargo.toml new file mode 100644 index 0000000000..4dc975353f --- /dev/null +++ b/crates/capture/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "capture" +version = "0.1.0" +edition = "2021" +description = "An example of screen capture" + +[package.metadata.bundle] +name = "Capture" +identifier = "dev.zed.Capture" + +[dependencies] +gpui = { path = "../gpui" } + +block = "0.1" +cocoa = "0.24" +core-foundation = "0.9.3" +core-graphics = "0.22.3" +foreign-types = "0.3" +log = { version = "0.4.16", features = ["kv_unstable_serde"] } +objc = "0.2" +simplelog = "0.9" diff --git a/crates/capture/build.rs b/crates/capture/build.rs new file mode 100644 index 0000000000..5aa9032376 --- /dev/null +++ b/crates/capture/build.rs @@ -0,0 +1,3 @@ +fn main() { + println!("cargo:rustc-link-lib=framework=ScreenCaptureKit"); +} diff --git a/crates/capture/script/capture b/crates/capture/script/capture new file mode 100755 index 0000000000..0e6cf1f409 --- /dev/null +++ b/crates/capture/script/capture @@ -0,0 +1,5 @@ +#!/bin/bash + +cargo bundle +TTY=`tty` +open ../../target/debug/bundle/osx/Capture.app --stdout $TTY --stderr $TTY diff --git a/crates/gpui/examples/capture.rs b/crates/capture/src/main.rs similarity index 88% rename from crates/gpui/examples/capture.rs rename to crates/capture/src/main.rs index 27bb843ab9..6bad5bb7f3 100644 --- a/crates/gpui/examples/capture.rs +++ b/crates/capture/src/main.rs @@ -33,10 +33,12 @@ fn main() { unsafe { let block = ConcreteBlock::new(move |content: id, error: id| { - println!("got response with shareable content"); - dbg!(content); - dbg!(error); - dbg!(string_from_objc(msg_send![error, localizedDescription])); + println!( + "got response with shareable content {:?} {:?} {:?}", + content, + error, + string_from_objc(msg_send![error, localizedDescription]), + ) }); let _: id = msg_send![ diff --git a/crates/gpui/Cargo.toml b/crates/gpui/Cargo.toml index 255e85a527..08c32135fb 100644 --- a/crates/gpui/Cargo.toml +++ b/crates/gpui/Cargo.toml @@ -12,11 +12,6 @@ doctest = false [features] test-support = ["backtrace", "dhat", "env_logger", "collections/test-support"] -[package.metadata.bundle.example.capture] -name = "Capture" -identifier = "rs.gpui.examples.Capture" -description = "An example of screen capture" - [dependencies] collections = { path = "../collections" } gpui_macros = { path = "../gpui_macros" } diff --git a/crates/gpui/build.rs b/crates/gpui/build.rs index 1c6cc11de0..836d586c26 100644 --- a/crates/gpui/build.rs +++ b/crates/gpui/build.rs @@ -9,9 +9,6 @@ fn main() { compile_context_predicate_parser(); compile_metal_shaders(); generate_shader_bindings(); - - // Support screen capture - println!("cargo:rustc-link-lib=framework=ScreenCaptureKit"); } fn generate_dispatch_bindings() { diff --git a/crates/gpui/script/capture b/crates/gpui/script/capture deleted file mode 100755 index 753e5108e7..0000000000 --- a/crates/gpui/script/capture +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -cargo bundle --example capture -open ../../target/debug/examples/bundle/osx/Capture.app