diff --git a/.github/workflows/golang.yaml b/.github/workflows/golang.yaml index 8012e99e3..0fe707912 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,7 @@ jobs: uses: dtolnay/rust-toolchain@master with: toolchain: stable - + # Install OpenSSL on Windows - name: Install OpenSSL if: runner.os == 'Windows' @@ -52,16 +52,17 @@ 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: Install cargo-c + run: cargo install cargo-c + + - name: Build and install Rust library + run: cargo cinstall -p yara-x-capi --release --pkgconfigdir=${{ github.workspace }} --includedir=${{ github.workspace }} --libdir=${{ github.workspace }} + - name: Run Go tests run: | - cd go - go test \ No newline at end of file + cd go + go test + env: + PKG_CONFIG_PATH: ${{ github.workspace }} + LD_LIBRARY_PATH: ${{ github.workspace }} \ No newline at end of file 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: 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/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" 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"