Skip to content

Commit

Permalink
build heif from source
Browse files Browse the repository at this point in the history
  • Loading branch information
woelper committed Nov 4, 2023
1 parent 39530e7 commit 9ff4b5b
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .github/workflows/check_ubuntu_no_default_features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
run: sudo apt update

- name: Install linux deps
run: sudo apt-get install libxcb-shape0-dev libxcb-xfixes0-dev libgtk-3-dev libasound2-dev libheif-dev libheif1
run: sudo apt-get install libxcb-shape0-dev libxcb-xfixes0-dev libgtk-3-dev libasound2-dev

- name: Update Rust
run: rustup update
Expand All @@ -27,3 +27,6 @@ jobs:
- name: cargo check without default features
run: cargo check --no-default-features

- name: cargo check without build features
run: cargo check --features heif

2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ trash = "3.1"
lutgen = {version ="0.9.0", features = ["lutgen-palettes"]}
libheif-rs = { version = "0.22.0", default-features = false, optional = true}

[env]
PKG_CONFIG_PATH = "libheif"

[features]
avif_native = ["avif-decode"]
dav1d = ["libavif-image"]
Expand All @@ -89,6 +92,8 @@ windres = "0.2"
env_logger = "0.10.0"
log = "0.4.14"
winres = "0.1"
cc = "1.0.46"
cmake = "0.1"

[dev-dependencies]
cmd_lib = "1.3.0"
Expand Down
25 changes: 25 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,36 @@
use std::env;
use std::fs::read_to_string;
use std::fs::remove_dir_all;
use std::fs::remove_file;
use std::fs::File;
use std::io::Read;
use std::io::Write;
use std::path::Path;
use std::process::Command;

use log::error;
use log::info;

fn setup_heif() {
#[cfg(target_os = "linux")]
{
_ = remove_dir_all("libheif").unwrap();
Command::new("git")
.args(["clone", "[email protected]:strukturag/libheif.git"])
.status()
.unwrap();
Command::new("cd").args(["libheif"]).status().unwrap();
Command::new("mkdir").args(["build"]).status().unwrap();
Command::new("cd").args(["build"]).status().unwrap();
Command::new("cmake")
.args(["--preset=release", ".."])
.status()
.unwrap();
Command::new("make").status().unwrap();
println!("cargo:rustc-link-search=native={}", "libheif");
}
}

fn main() {
info!("Build script");
// #[cfg(windows)]
Expand Down Expand Up @@ -77,5 +100,7 @@ fn main() {
.unwrap();

remove_file(shortcut_file).unwrap();

setup_heif();
}
}

0 comments on commit 9ff4b5b

Please sign in to comment.