Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
58 changes: 21 additions & 37 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@ on:

env:
CARGO_TERM_COLOR: always
QT_BUILD_VERSION: 6.2.2

QT_BUILD_VERSION: 6.10.0

jobs:
build:
strategy:
fail-fast: false
matrix:
variants:
# - {os: ubuntu-22.04, config: release, compiler: gcc_64, aqt_os: linux, aqt_compiler: gcc_64}
- {os: ubuntu-24.04, config: release, compiler: gcc_64, aqt_os: linux, aqt_compiler: gcc_64}
# - {os: ubuntu-24.04-arm, config: release, compiler: linux_gcc_arm64, aqt_os: linux_arm64, aqt_compiler: linux_gcc_arm64}
- {os: windows-2019, config: release, compiler: msvc2019_64, aqt_os: windows, aqt_compiler: win64_msvc2019_64}
- {os: macos-13, config: release, compiler: clang_64, aqt_os: mac, aqt_compiler: clang_64}
# - {os: windows-2022, config: release, compiler: msvc2022_64, aqt_os: windows, aqt_compiler: win64_msvc2022_64}
- {os: windows-2025, config: release, compiler: msvc2022_64, aqt_os: windows, aqt_compiler: win64_msvc2022_64}
- {os: macos-14, config: release, compiler: clang_64, aqt_os: mac, aqt_compiler: clang_64}
- {os: macos-15, config: release, compiler: clang_64, aqt_os: mac, aqt_compiler: clang_64}
# - {os: macos-15, config: release, compiler: clang_64, aqt_os: mac, aqt_compiler: clang_64}
runs-on: ${{ matrix.variants.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- uses: actions/cache@v4
with:
path: |
Expand All @@ -38,49 +38,33 @@ jobs:
target/
key: ${{ matrix.variants.os }}-${{ runner.arch }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Build (Linux)
if: startsWith(matrix.variants.os, 'ubuntu-')
run: |
python -m pip install aqtinstall --user --upgrade
python -m aqt install-qt -O libdie++/build ${{ matrix.variants.aqt_os }} desktop ${{ env.QT_BUILD_VERSION }} ${{ matrix.variants.aqt_compiler }}
export QT6_LIB_PATH="`pwd`/libdie++/build/${{ env.QT_BUILD_VERSION }}/${{ matrix.variants.compiler }}/lib"
cargo build -vv --tests --examples
echo QT6_LIB_PATH=${QT6_LIB_PATH} >> $GITHUB_ENV

- name: Build (macOS)
if: startsWith(matrix.variants.os, 'macos-')
run: |
python -m pip install aqtinstall --user --upgrade
python -m aqt install-qt -O libdie++/build ${{ matrix.variants.aqt_os }} desktop ${{ env.QT_BUILD_VERSION }} ${{ matrix.variants.aqt_compiler }}
export QT6_LIB_PATH="`pwd`/libdie++/build/${{ env.QT_BUILD_VERSION }}/macos/lib"
cargo build -vv --tests --examples
echo QT6_LIB_PATH=${QT6_LIB_PATH} >> $GITHUB_ENV

- name: Build (Windows)
if: startsWith(matrix.variants.os, 'windows-')
run: |
python -m pip install aqtinstall --user --upgrade
python -m aqt install-qt -O libdie++/build ${{ matrix.variants.aqt_os }} desktop ${{ env.QT_BUILD_VERSION }} ${{ matrix.variants.aqt_compiler }}
$env:QT6_LIB_PATH="./libdie++/build/${{ env.QT_BUILD_VERSION }}/${{ matrix.variants.compiler }}/lib"
cargo build -vv --tests --examples
$env:DIE_DB_PATH="./libdie++/install/die/db/db"
cargo build -vv --tests --examples --release
cp ./libdie++/install/die/*.dll .
cargo test -vv --release
cargo run --release --example scan_file -- -vv C:\Windows\System32\winver.exe

- name: Tests (Linux)
- name: Build (Linux)
if: startsWith(matrix.variants.os, 'ubuntu-')
run: |
export QT6_LIB_PATH="`pwd`/libdie++/build/${{ env.QT_BUILD_VERSION }}/${{ matrix.variants.compiler }}/lib"
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${QT6_LIB_PATH}
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:`pwd`/libdie++/build/${{ env.QT_BUILD_VERSION }}/${{ matrix.variants.compiler }}/lib"
export DIE_DB_PATH="`pwd`/libdie++/install/die/db/db"
cargo build -vv --tests --examples
cargo test -vv
cargo run --example scan_file -- -vv /bin/ls --database-path ${DIE_DB_PATH}

- name: Tests (macOS)
- name: Build (macOS)
if: startsWith(matrix.variants.os, 'macos-')
run: |
export QT6_LIB_PATH="`pwd`/libdie++/build/${{ env.QT_BUILD_VERSION }}/macos/lib"
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${QT6_LIB_PATH}
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:`pwd`/libdie++/build/${{ env.QT_BUILD_VERSION }}/macos/lib"
export DIE_DB_PATH="`pwd`/libdie++/install/die/db/db"
cargo build -vv --tests --examples
cargo test -vv
cargo run --example scan_file -- -vv /bin/ls --database-path ${DIE_DB_PATH}

- name: Tests (Windows)
if: startsWith(matrix.variants.os, 'windows-')
run: |
$env:QT6_LIB_PATH="./libdie++/build/${{ env.QT_BUILD_VERSION }}/${{ matrix.variants.compiler }}/lib"
cp -v ./libdie++/install/die/*.dll .
cargo test -vv
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ libdie++/build
libdie++/install
.vscode
aqtinstall.log
*.dll
10 changes: 5 additions & 5 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "die"
version = "0.1.0"
edition = "2021"
version = "0.2.0"
edition = "2024"
authors = ["Christophe Alladoum"]
description = "Native Rust bindings for @horsicq's Detect-It-Easy"
homepage = "https://github.com/elastic/die-rust"
Expand All @@ -21,7 +21,7 @@ name = "scan_file"

[dependencies]
bitflags = "2.6.0"
derive_more = { version = "1.0.0", features = ["from", "display"] }
derive_more = { version = "2.0.1", features = ["from", "display"] }

[dev-dependencies]
clap = { version = "4.5.23", features = ["derive"] }
Expand Down
50 changes: 2 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,8 @@ This module provides Rust bindings for the [Detect-It-Easy](https://github.com/h

### Build

> [!IMPORTANT]
> [**Qt6**](https://qt.io) libraries must be installed for Detect-it-Easy to work.
> On Linux and macOS, `die-rust` can be built using the Qt6 provided by the typical package management systems (`apt`, `dnf`, `brew`, etc.).
> If you do not wish to install those packages system-wide, if you are running Windows, or if you wish/need to use a specific version of Qt6, it is possible to build `die-rust` by installing those libraries in a specific folder, using [`aqtinstall`](https://github.com/miurahr/aqtinstall) - (see below). Then build `die-rust` by passing the paths to the Qt6 libraries with the `QT6_LIB_PATH` environment.

### As a dependency

Use `cargo` to add `die-rust` as a dependency to your project:

```console
cargo add --git https://github.com/elastic/die-rust.git
```

### On the terminal
> [!Warning]
> `Detect-It-Easy` has a hard requirement for Qt6 libraries. `cargo build` will manage the entire building process in an automated, but to be able to link against Qt6, it will use the library [`aqtinstall`](). Therefore `python` must be installed on the system. Note that downloading the Qt libraries may take some time, depending on your Internet connection.

The installation can be done using `cargo`.

Expand All @@ -35,40 +23,6 @@ cd die-rust
cargo build
```

The build requires Qt6 libraries. On Linux/macOS they can usually be obtained from the system's package manager. To use a specific Qt6 version, it is possible to use `aqtinstall` as follow

### Linux

```bash
export QT_BUILD_VERSION=6.2.2
git clone https://github.com/elastic/die-rust.git && cd die-rust
python -m pip install aqtinstall
python -m aqt install-qt -O ./libdie++/build/ linux desktop ${QT_BUILD_VERSION} gcc_64
export QT6_LIB_PATH=./libdie++/build/6.2.2/gcc_64/lib
```

### macOS

```bash
export QT_BUILD_VERSION=6.2.2
git clone https://github.com/calladoum-elastic/die-rust.git && cd die-rust
python -m pip install aqtinstall
python -m aqt install-qt -O ./libdie++/build/ mac desktop ${QT_BUILD_VERSION} clang_64
export QT6_LIB_PATH=./libdie++/build/6.2.2/clang_64/lib # macos
```

### Windows

```pwsh
$env:QT_BUILD_VERSION="6.2.2"
git clone https://github.com/calladoum-elastic/die-rust.git && cd die-rust
python -m pip install aqtinstall
python -m aqt install-qt -O ./libdie++/build/ windows desktop $env:QT_BUILD_VERSION win64_msvc2019_64
$env:QT6_LIB_PATH="./libdie++/build/6.2.2/msvc2019_64/lib"
```





## Examples
Expand Down
Loading