From f31d1b00253cd70666d6fd610fc72959221aedc1 Mon Sep 17 00:00:00 2001 From: "Victor M. Alvarez" Date: Tue, 2 Apr 2024 09:44:23 +0200 Subject: [PATCH 01/11] ci: fix Golang workflow --- .github/workflows/golang.yaml | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/.github/workflows/golang.yaml b/.github/workflows/golang.yaml index 8012e99e3..b85cbf69a 100644 --- a/.github/workflows/golang.yaml +++ b/.github/workflows/golang.yaml @@ -15,12 +15,12 @@ jobs: fail-fast: false matrix: go-version: [ '1.19', '1.20', '1.21.x' ] - os: [ubuntu-latest, macos-latest] + os: [ ubuntu-latest, macos-latest ] runs-on: ${{ matrix.os }} steps: - name: Checkout uses: actions/checkout@v4 - + - name: Setup Go ${{ matrix.go-version }} uses: actions/setup-go@v4 with: @@ -30,7 +30,10 @@ jobs: uses: dtolnay/rust-toolchain@master with: toolchain: stable - + + - name: Install cargo-c + run: cargo install cargo-c + # Install OpenSSL on Windows - name: Install OpenSSL if: runner.os == 'Windows' @@ -52,16 +55,11 @@ jobs: run: | sudo apt-get update sudo apt-get install -y libssl-dev - - - name: Build Rust library - run: cargo build --release -p yara-x -p yara-x-capi - - - name: Set LD_LIBRARY_PATH environment variable - if: runner.os == 'Linux' - shell: bash - run: echo "LD_LIBRARY_PATH=${{ github.workspace }}/target/release" >> $GITHUB_ENV - + + - name: Build and install Rust library + run: cargo cinstall -p yara-x-capi --release + - name: Run Go tests run: | - cd go - go test \ No newline at end of file + cd go + go test \ No newline at end of file From 88db6b1aac5cf5e08bc06507bfc5bf80bd0ba431 Mon Sep 17 00:00:00 2001 From: "Victor M. Alvarez" Date: Tue, 2 Apr 2024 09:59:41 +0200 Subject: [PATCH 02/11] ci: fix permissions issue --- .github/workflows/golang.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/golang.yaml b/.github/workflows/golang.yaml index b85cbf69a..032fb8c10 100644 --- a/.github/workflows/golang.yaml +++ b/.github/workflows/golang.yaml @@ -57,7 +57,7 @@ jobs: sudo apt-get install -y libssl-dev - name: Build and install Rust library - run: cargo cinstall -p yara-x-capi --release + run: sudo cargo cinstall -p yara-x-capi --release - name: Run Go tests run: | From da122ab13dd15e5b926568f21f4d93325d2ce6c4 Mon Sep 17 00:00:00 2001 From: "Victor M. Alvarez" Date: Tue, 2 Apr 2024 10:13:22 +0200 Subject: [PATCH 03/11] fix: wrong include statement. --- go/compiler.go | 2 +- go/scanner.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/go/compiler.go b/go/compiler.go index 8282d72bc..6db9e6af0 100644 --- a/go/compiler.go +++ b/go/compiler.go @@ -1,6 +1,6 @@ package yara_x -// #include +// #include import "C" import ( "errors" diff --git a/go/scanner.go b/go/scanner.go index 1a7acd2c1..9243872a8 100644 --- a/go/scanner.go +++ b/go/scanner.go @@ -15,7 +15,7 @@ import ( "github.com/golang/protobuf/proto" ) -// #include +// #include // void onMatchingRule(YRX_RULE*, void*); import "C" From 52e9620b15de756364cf1e92a03d533b88a7ffe1 Mon Sep 17 00:00:00 2001 From: "Victor M. Alvarez" Date: Tue, 2 Apr 2024 10:14:14 +0200 Subject: [PATCH 04/11] ci: trying fixing build issue. --- .github/workflows/golang.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/golang.yaml b/.github/workflows/golang.yaml index 032fb8c10..666ecc352 100644 --- a/.github/workflows/golang.yaml +++ b/.github/workflows/golang.yaml @@ -32,7 +32,7 @@ jobs: toolchain: stable - name: Install cargo-c - run: cargo install cargo-c + run: sudo cargo install cargo-c # Install OpenSSL on Windows - name: Install OpenSSL From a4f950062cf9e7b29951ca1c50e6de7053f6dd6b Mon Sep 17 00:00:00 2001 From: "Victor M. Alvarez" Date: Tue, 2 Apr 2024 10:38:54 +0200 Subject: [PATCH 05/11] fix: try fixing workflow --- .github/workflows/golang.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/golang.yaml b/.github/workflows/golang.yaml index 666ecc352..7f6c084dc 100644 --- a/.github/workflows/golang.yaml +++ b/.github/workflows/golang.yaml @@ -30,9 +30,6 @@ jobs: uses: dtolnay/rust-toolchain@master with: toolchain: stable - - - name: Install cargo-c - run: sudo cargo install cargo-c # Install OpenSSL on Windows - name: Install OpenSSL @@ -56,8 +53,11 @@ jobs: sudo apt-get update sudo apt-get install -y libssl-dev + - name: Install cargo-c + run: cargo install cargo-c + - name: Build and install Rust library - run: sudo cargo cinstall -p yara-x-capi --release + run: sudo /home/runner/.cargo/bin/cargo cinstall -p yara-x-capi --release - name: Run Go tests run: | From f2a27dc25574ca3c57dbfbfceb431c1d15b245ed Mon Sep 17 00:00:00 2001 From: "Victor M. Alvarez" Date: Tue, 2 Apr 2024 10:55:03 +0200 Subject: [PATCH 06/11] ci: try fixing workflow --- .github/workflows/golang.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/golang.yaml b/.github/workflows/golang.yaml index 7f6c084dc..baaf04e1b 100644 --- a/.github/workflows/golang.yaml +++ b/.github/workflows/golang.yaml @@ -52,12 +52,13 @@ jobs: run: | sudo apt-get update sudo apt-get install -y libssl-dev + sudo mkdir -p /usr/local/lib/pkgconfig - name: Install cargo-c run: cargo install cargo-c - name: Build and install Rust library - run: sudo /home/runner/.cargo/bin/cargo cinstall -p yara-x-capi --release + run: cargo cinstall -p yara-x-capi --release - name: Run Go tests run: | From 75a14965611f0e0689f60dd79676927284a7be8e Mon Sep 17 00:00:00 2001 From: "Victor M. Alvarez" Date: Tue, 2 Apr 2024 11:08:07 +0200 Subject: [PATCH 07/11] ci: try fixing workflow --- .github/workflows/golang.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/golang.yaml b/.github/workflows/golang.yaml index baaf04e1b..ea51d0d03 100644 --- a/.github/workflows/golang.yaml +++ b/.github/workflows/golang.yaml @@ -52,15 +52,16 @@ jobs: run: | sudo apt-get update sudo apt-get install -y libssl-dev - sudo mkdir -p /usr/local/lib/pkgconfig - name: Install cargo-c run: cargo install cargo-c - name: Build and install Rust library - run: cargo cinstall -p yara-x-capi --release + run: cargo cinstall -p yara-x-capi --release --pkgconfigdir=${{ github.workspace }} - name: Run Go tests run: | cd go - go test \ No newline at end of file + go test + env: + PKG_CONFIG_PATH: ${{ github.workspace }} \ No newline at end of file From cf2de301e07243bc1a76de076c3d07c6c05490b0 Mon Sep 17 00:00:00 2001 From: "Victor M. Alvarez" Date: Tue, 2 Apr 2024 11:25:32 +0200 Subject: [PATCH 08/11] ci: try fix workflow --- .github/workflows/golang.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/golang.yaml b/.github/workflows/golang.yaml index ea51d0d03..0746ffec2 100644 --- a/.github/workflows/golang.yaml +++ b/.github/workflows/golang.yaml @@ -57,7 +57,7 @@ jobs: run: cargo install cargo-c - name: Build and install Rust library - run: cargo cinstall -p yara-x-capi --release --pkgconfigdir=${{ github.workspace }} + run: cargo cinstall -p yara-x-capi --release --pkgconfigdir=${{ github.workspace }} --includedir=${{ github.workspace }} --libdir=${{ github.workspace }} - name: Run Go tests run: | From 792c54f2d615bc61d99f37d2d6373d0f7d3a5de3 Mon Sep 17 00:00:00 2001 From: "Victor M. Alvarez" Date: Tue, 2 Apr 2024 11:47:04 +0200 Subject: [PATCH 09/11] ci: try fix workflow --- .github/workflows/golang.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/golang.yaml b/.github/workflows/golang.yaml index 0746ffec2..0fe707912 100644 --- a/.github/workflows/golang.yaml +++ b/.github/workflows/golang.yaml @@ -64,4 +64,5 @@ jobs: cd go go test env: - PKG_CONFIG_PATH: ${{ github.workspace }} \ No newline at end of file + PKG_CONFIG_PATH: ${{ github.workspace }} + LD_LIBRARY_PATH: ${{ github.workspace }} \ No newline at end of file From df57f06c680e9419f509f08a328b9b2bc8e828d3 Mon Sep 17 00:00:00 2001 From: "Victor M. Alvarez" Date: Tue, 2 Apr 2024 11:59:17 +0200 Subject: [PATCH 10/11] style: remove trailing whitespaces --- capi/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/capi/src/lib.rs b/capi/src/lib.rs index 063d496d1..29bfd55cb 100644 --- a/capi/src/lib.rs +++ b/capi/src/lib.rs @@ -38,7 +38,7 @@ bootstrap-vcpkg.bat vcpkg install openssl:x64-windows-static set OPENSSL_DIR=%cd%\installed\x64-windows-static ``` - + Once you have installed the pre-requisites, go to the root directory of the YARA-X repository and type: @@ -48,7 +48,7 @@ cargo cinstall -p yara-x-capi --release The command above will put the library and header files in the correct path in your system (usually `/usr/local/lib` and `/usr/local/include` for Linux -and MacOS users), and will generate a `.pc` file so that `pkg-config` knows +and MacOS users), and will generate a `.pc` file so that `pkg-config` knows about the library. In Linux and MacOS you can check if everything went fine by compiling a simple @@ -71,7 +71,7 @@ gcc `pkg-config --cflags yara_x_capi` `pkg-config --libs yara_x_capi` test.c The compilation should succeed without errors. -Windows users can find all the files you need for importing the YARA-X library +Windows users can find all the files you need for importing the YARA-X library in your project in the `target/x86_64-pc-windows-msvc/release` directory. This includes: From 873f3457ba5e5144bbd02cf12338d4fadaa326f5 Mon Sep 17 00:00:00 2001 From: "Victor M. Alvarez" Date: Tue, 2 Apr 2024 12:00:37 +0200 Subject: [PATCH 11/11] style: replace `#import` with `#include` --- go/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/main.go b/go/main.go index ed80ee9c7..2185418b7 100644 --- a/go/main.go +++ b/go/main.go @@ -3,7 +3,7 @@ package yara_x // #cgo !static_link pkg-config: yara_x_capi // #cgo static_link pkg-config: --static yara_x_capi -// #import +// #include import "C" import ( "errors"