diff --git a/Cargo.lock b/Cargo.lock index afba38b1a..f4236e477 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4490,6 +4490,7 @@ name = "yara-x-capi" version = "0.1.0" dependencies = [ "cbindgen", + "vcpkg", "yara-x", ] @@ -4513,6 +4514,7 @@ dependencies = [ "serde_json", "strum_macros", "superconsole", + "vcpkg", "wild", "yansi 0.5.1", "yara-x", @@ -4598,6 +4600,7 @@ dependencies = [ "pyo3", "pyo3-build-config", "pyo3-file", + "vcpkg", "yara-x", ] diff --git a/Cargo.toml b/Cargo.toml index be717cd44..19ab1b5ca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" @@ -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" @@ -104,4 +106,4 @@ yara-x-proto-yaml = { path = "proto-yaml" } [profile.release-lto] inherits = "release" lto = true -codegen-units = 1 +codegen-units = 1 \ No newline at end of file diff --git a/capi/Cargo.toml b/capi/Cargo.toml index e5d2b6c72..914ad75c9 100644 --- a/capi/Cargo.toml +++ b/capi/Cargo.toml @@ -18,4 +18,5 @@ crate-type = ["staticlib", "cdylib"] yara-x = { workspace = true } [build-dependencies] -cbindgen = "0.26.0" \ No newline at end of file +cbindgen = { workspace = true } +vcpkg = { workspace = true } \ No newline at end of file diff --git a/capi/build.rs b/capi/build.rs index a8d64d4e9..5e78ed866 100644 --- a/capi/build.rs +++ b/capi/build.rs @@ -1,4 +1,5 @@ use std::env; +use vcpkg; fn main() { println!("cargo:rerun-if-changed=src"); @@ -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); diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 8781ec9dc..ef18da0c4 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -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 } @@ -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 } \ No newline at end of file diff --git a/cli/build.rs b/cli/build.rs new file mode 100644 index 000000000..6477b82fd --- /dev/null +++ b/cli/build.rs @@ -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(); +} diff --git a/lib/Cargo.toml b/lib/Cargo.toml index 101316ba0..17178ee47 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -138,6 +138,7 @@ default = [ "console-module", "dotnet-module", "elf-module", + "magic-module", "macho-module", "math-module", "hash-module", @@ -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"] \ No newline at end of file diff --git a/py/Cargo.toml b/py/Cargo.toml index 5228cb845..dd38076cb 100644 --- a/py/Cargo.toml +++ b/py/Cargo.toml @@ -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" \ No newline at end of file +pyo3-build-config = "0.19.2" +vcpkg = { workspace = true } diff --git a/py/build.rs b/py/build.rs index dace4a9ba..2df5e944e 100644 --- a/py/build.rs +++ b/py/build.rs @@ -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(); }