From 5865b51a9451110a8b198067b7eedc4e512d1058 Mon Sep 17 00:00:00 2001 From: Arthur Baars Date: Wed, 11 Jan 2023 17:17:20 +0100 Subject: [PATCH] Ruby: build extractor using cross --- ruby/actions/create-extractor-pack/action.yml | 8 +++++--- ruby/scripts/create-extractor-pack.sh | 9 ++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/ruby/actions/create-extractor-pack/action.yml b/ruby/actions/create-extractor-pack/action.yml index 7062dd0cfcd..59aad56ced7 100644 --- a/ruby/actions/create-extractor-pack/action.yml +++ b/ruby/actions/create-extractor-pack/action.yml @@ -10,7 +10,7 @@ runs: uses: actions/cache@v3 with: path: ruby/extractor-pack - key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-extractor-${{ hashFiles('ruby/rust-toolchain.toml', 'ruby/**/Cargo.lock') }}-${{ hashFiles('ruby/**/*.rs') }}-${{ hashFiles('ruby/codeql-extractor.yml', 'ruby/downgrades', 'ruby/tools', 'ruby/ql/lib/ruby.dbscheme', 'ruby/ql/lib/ruby.dbscheme.stats') }} + key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-extractor-${{ hashFiles('ruby/rust-toolchain.toml', 'ruby/scripts/create-extractor-pack.sh', 'ruby/**/Cargo.lock', 'ruby/actions/create-extractor-pack/action.yml') }}-${{ hashFiles('ruby/**/*.rs') }}-${{ hashFiles('ruby/codeql-extractor.yml', 'ruby/downgrades', 'ruby/tools', 'ruby/ql/lib/ruby.dbscheme', 'ruby/ql/lib/ruby.dbscheme.stats') }} - name: Cache cargo uses: actions/cache@v3 if: steps.cache-extractor.outputs.cache-hit != 'true' @@ -19,9 +19,11 @@ runs: ~/.cargo/registry ~/.cargo/git ruby/target - key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-ruby-qltest-cargo-${{ hashFiles('ruby/rust-toolchain.toml', 'ruby/**/Cargo.lock') }} + key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-ruby-qltest-cargo-${{ hashFiles('ruby/rust-toolchain.toml', 'ruby/scripts/create-extractor-pack.sh', 'ruby/**/Cargo.lock') }} - name: Build Extractor if: steps.cache-extractor.outputs.cache-hit != 'true' shell: bash - run: scripts/create-extractor-pack.sh + run: | + cargo install cross --version 0.2.1 + scripts/create-extractor-pack.sh working-directory: ruby diff --git a/ruby/scripts/create-extractor-pack.sh b/ruby/scripts/create-extractor-pack.sh index 4b5fcbcc638..c5f5192994c 100755 --- a/ruby/scripts/create-extractor-pack.sh +++ b/ruby/scripts/create-extractor-pack.sh @@ -1,8 +1,11 @@ #!/bin/bash set -eux - +CARGO=cargo if [[ "$OSTYPE" == "linux-gnu"* ]]; then platform="linux64" + if which cross; then + CARGO=cross + fi elif [[ "$OSTYPE" == "darwin"* ]]; then platform="osx64" else @@ -10,9 +13,9 @@ else exit 1 fi -cargo build --release +"$CARGO" build --release -cargo run --release -p ruby-generator -- --dbscheme ql/lib/ruby.dbscheme --library ql/lib/codeql/ruby/ast/internal/TreeSitter.qll +"$CARGO" run --release -p ruby-generator -- --dbscheme ql/lib/ruby.dbscheme --library ql/lib/codeql/ruby/ast/internal/TreeSitter.qll codeql query format -i ql/lib/codeql/ruby/ast/internal/TreeSitter.qll rm -rf extractor-pack