Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: windows build #208

Merged
merged 7 commits into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: windows build
  • Loading branch information
Aloxaf committed Oct 14, 2022
commit ef92be8ebf85c9e0d23d032c1d61d1e4a0bfdc08
33 changes: 31 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ env:

jobs:

test:
name: Test
test-linux:
name: x86_64-unknown-linux-gnu
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down Expand Up @@ -56,3 +56,32 @@ jobs:
with:
command: test
args: -- --nocapture

test-windows:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v1
with:
fetch-depth: 1

- name: Install rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true

- name: Install dependencies
run: vcpkg install --recurse glib:x64-windows fontconfig:x64-windows freetype:x64-windows cairo:x64-windows

- name: Cargo check
uses: actions-rs/cargo@v1
with:
command: check

- name: Cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: -- --nocapture
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ jobs:
with:
toolchain: stable
override: true
- run: vcpkg install --recurse glib:x64-windows fontconfig:x64-windows freetype:x64-windows cairo:x64-windows
- uses: actions-rs/cargo@v1
with:
command: build
Expand Down
28 changes: 14 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ repository = "https://github.com/Aloxaf/silicon"
license = "MIT"
edition = "2018"

[features]
# fearures required for silicon as a application
# disable it when using as a library
default = ["bin"]
bin = ["structopt", "env_logger", "anyhow", "shell-words"]

[dependencies]
dirs = "4.0"
imageproc = "0.23.0"
Expand All @@ -21,13 +27,6 @@ lazy_static = "1.4.0"
shell-words = { version = "1.0.0", optional = true }
rayon = "1.5.1"

[target.'cfg(target_os = "macos")'.dependencies]
pasteboard = "0.1.3"

[target.'cfg(target_os = "windows")'.dependencies]
clipboard-win = "4.0.2"
image = { version = "0.24", default-features = false, features = ["jpeg", "bmp", "jpeg_rayon"] }

[dependencies.image]
version = "0.24"
default-features = false
Expand Down Expand Up @@ -56,16 +55,17 @@ optional = true

[dependencies.font-kit]
version= "0.11"
features= ["loader-freetype-default", "source-fontconfig-default"]
features= ["loader-freetype-default"]

[dependencies.harfbuzz-sys]
version="0.5.0"

[target.'cfg(target_os = "macos")'.dependencies]
pasteboard = "0.1.3"

[target.'cfg(target_os = "windows")'.dependencies]
clipboard-win = "4.0.2"
image = { version = "0.24", default-features = false, features = ["jpeg", "bmp", "jpeg_rayon"] }

[patch.crates-io]
pathfinder_simd = { version = "0.5.0", git = "https://github.com/servo/pathfinder" }

[features]
# fearures required for silicon as a application
# disable it when using as a library
default = ["bin"]
bin = ["structopt", "env_logger", "anyhow", "shell-words"]
6 changes: 3 additions & 3 deletions src/bin/silicon/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ pub fn dump_image_to_clipboard(image: &DynamicImage) -> Result<(), Error> {

#[cfg(target_os = "windows")]
pub fn dump_image_to_clipboard(image: &DynamicImage) -> Result<(), Error> {
let mut temp: Vec<u8> = Vec::new();
let mut temp = std::io::Cursor::new(Vec::new());

// Convert the image to RGB without alpha because the clipboard
// of windows doesn't support it.
let image = DynamicImage::ImageRgb8(image.to_rgb());
let image = DynamicImage::ImageRgb8(image.to_rgb8());

image.write_to(&mut temp, ImageOutputFormat::Bmp)?;

let _clip =
Clipboard::new_attempts(10).map_err(|e| format_err!("Couldn't open clipboard: {}", e))?;

formats::Bitmap
.write_clipboard(&temp)
.write_clipboard(temp.get_ref())
.map_err(|e| format_err!("Failed copy image: {}", e))?;
Ok(())
}
Expand Down