Skip to content

Commit 856132b

Browse files
committed
Ruby: Fix cross-compilation
Ensure that builds via cargo-cross, which are executed in a docker container, can see the shared library.
1 parent f2fc80b commit 856132b

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

ruby/actions/create-extractor-pack/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ runs:
2424
if: steps.cache-extractor.outputs.cache-hit != 'true'
2525
shell: bash
2626
run: |
27-
cargo install cross --version 0.2.1
27+
cargo install cross --version 0.2.5
2828
scripts/create-extractor-pack.sh
2929
working-directory: ruby

ruby/extractor/Cross.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
[target.x86_64-unknown-linux-gnu]
22
image = "centos/devtoolset-7-toolchain-centos7"
3+
4+
[build.env]
5+
# Provide the path to the shared extractor
6+
# Cross mounts this directory as a volume, so builds inside the docker container
7+
# can see it.
8+
volumes = ["__CODEQL-EXTRACTOR=../../shared/extractor"]

ruby/scripts/create-extractor-pack.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,21 @@ else
1414
fi
1515

1616
(cd extractor && "$CARGO" build --release)
17-
extractor/target/release/generator --dbscheme ql/lib/ruby.dbscheme --library ql/lib/codeql/ruby/ast/internal/TreeSitter.qll
17+
18+
# If building via cross, the binaries will be in extractor/target/<triple>/release
19+
# If building via cargo, the binaries will be in extractor/target/release
20+
BIN_DIR=extractor/target/release
21+
if [[ "$CARGO" == "cross" ]]; then
22+
BIN_DIR=extractor/target/x86_64-unknown-linux-gnu/release
23+
fi
24+
25+
"$BIN_DIR/generator" --dbscheme ql/lib/ruby.dbscheme --library ql/lib/codeql/ruby/ast/internal/TreeSitter.qll
1826

1927
codeql query format -i ql/lib/codeql/ruby/ast/internal/TreeSitter.qll
2028

2129
rm -rf extractor-pack
2230
mkdir -p extractor-pack
2331
cp -r codeql-extractor.yml downgrades tools ql/lib/ruby.dbscheme ql/lib/ruby.dbscheme.stats extractor-pack/
2432
mkdir -p extractor-pack/tools/${platform}
25-
cp extractor/target/release/extractor extractor-pack/tools/${platform}/extractor
26-
cp extractor/target/release/autobuilder extractor-pack/tools/${platform}/autobuilder
33+
cp "$BIN_DIR/extractor" extractor-pack/tools/${platform}/extractor
34+
cp "$BIN_DIR/autobuilder" extractor-pack/tools/${platform}/autobuilder

0 commit comments

Comments
 (0)