Skip to content

Commit

Permalink
chore: use vcpkg for building libmagic and its dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
plusvic committed Mar 13, 2024
1 parent 4575de3 commit 96da175
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 12 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock

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

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ bincode = "1.3.3"
bitmask = "0.5.0"
bitvec = "1.0.1"
bstr = "1.8.0"
cbindgen = "0.26.0"
chrono = "0.4.34"
clap = "4.4.8"
crc32fast = "1.3.2"
Expand Down Expand Up @@ -85,6 +86,7 @@ serde = "1.0"
serde_json = "1.0"
thiserror = "1.0.50"
uuid = "1.4.1"
vcpkg = "0.2.15"
walrus = "0.20.2"
wasmtime = "18.0.2"
yaml-rust = "0.4.5"
Expand All @@ -104,4 +106,4 @@ yara-x-proto-yaml = { path = "proto-yaml" }
[profile.release-lto]
inherits = "release"
lto = true
codegen-units = 1
codegen-units = 1
3 changes: 2 additions & 1 deletion capi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ crate-type = ["staticlib", "cdylib"]
yara-x = { workspace = true }

[build-dependencies]
cbindgen = "0.26.0"
cbindgen = { workspace = true }
vcpkg = { workspace = true }
5 changes: 5 additions & 0 deletions capi/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::env;
use vcpkg;

fn main() {
println!("cargo:rerun-if-changed=src");
Expand All @@ -7,6 +8,10 @@ fn main() {
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
let output_file = "include/yara-x.h".to_owned();

vcpkg::find_package("libmagic").unwrap();
vcpkg::find_package("bzip2").unwrap();
vcpkg::find_package("zlib").unwrap();

match cbindgen::generate(crate_dir) {
Ok(header) => {
header.write_to_file(output_file);
Expand Down
10 changes: 7 additions & 3 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ logging = ["dep:log", "dep:env_logger"]
[dependencies]
ascii_tree = { workspace = true }
anyhow = { workspace = true }
clap = { workspace = true, features=["cargo", "derive"] }
clap = { workspace = true, features = ["cargo", "derive"] }
globwalk = { workspace = true }
enable-ansi-support = { workspace = true }
env_logger = { workspace = true , optional = true, features = ["auto-color"] }
env_logger = { workspace = true, optional = true, features = ["auto-color"] }
log = { workspace = true, optional = true }
protobuf = { workspace = true }
protobuf-json-mapping = { workspace = true }
Expand All @@ -55,7 +55,11 @@ yara-x-fmt = { workspace = true }
colored_json = "4.0.0"
crossbeam = "0.8.2"
crossterm = "0.27.0"
pprof = { version = "0.13.0", features = ["flamegraph"], optional=true }
pprof = { version = "0.13.0", features = ["flamegraph"], optional = true }
strum_macros = "0.25"
superconsole = "0.2.0"
wild = "2.1.0"


[build-dependencies]
vcpkg = { workspace = true }
9 changes: 9 additions & 0 deletions cli/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use vcpkg;

fn main() {
println!("cargo:rerun-if-changed=src");

vcpkg::find_package("libmagic").unwrap();
vcpkg::find_package("bzip2").unwrap();
vcpkg::find_package("zlib").unwrap();
}
12 changes: 7 additions & 5 deletions lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ default = [
"console-module",
"dotnet-module",
"elf-module",
"magic-module",
"macho-module",
"math-module",
"hash-module",
Expand Down Expand Up @@ -217,11 +218,12 @@ yara = { version = "0.26.0", features = ["vendored"] }
yara-x-proto-yaml = { workspace = true }
zip = "0.6.6"

[package.metadata.vcpkg]
git = "https://github.com/microsoft/vcpkg"
rev = "fba75d0"
dependencies = ["libmagic"]

[[bench]]
name = "benches"
harness = false


[package.metadata.vcpkg]
git = "https://github.com/microsoft/vcpkg"
rev = "fba75d0"
dependencies = ["bzip2", "zlib"]
6 changes: 4 additions & 2 deletions py/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ doc = false
crate-type = ["cdylib"]

[dependencies]
pyo3 = { version = "0.19.2", features = ["abi3", "abi3-py38", "extension-module"]}
pyo3 = { version = "0.19.2", features = ["abi3", "abi3-py38", "extension-module"] }
pyo3-file = "0.7.0"

protobuf-json-mapping = { workspace = true }
yara-x = { workspace = true }
vcpkg = "0.2.15"

[build-dependencies]
pyo3-build-config = "0.19.2"
pyo3-build-config = "0.19.2"
vcpkg = { workspace = true }
4 changes: 4 additions & 0 deletions py/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
fn main() {
vcpkg::find_package("libmagic").unwrap();
vcpkg::find_package("bzip2").unwrap();
vcpkg::find_package("zlib").unwrap();

pyo3_build_config::add_extension_module_link_args();
}

0 comments on commit 96da175

Please sign in to comment.