Skip to content

Commit 2babe53

Browse files
committed
First idea on dependency handling
I chose this approach, since we cannot expect users to run our programs inside a docker container or a micromamba/mise managed environment.
1 parent d028298 commit 2babe53

4 files changed

Lines changed: 71 additions & 5 deletions

File tree

.dependencies/clear.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
# Get the absolute location of this script
4+
THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
5+
6+
rm -rf $THIS_DIR/bin
7+
rm -rf $THIS_DIR/include
8+
rm -rf $THIS_DIR/lib
9+
rm -rf $THIS_DIR/libexec
10+
rm -rf $THIS_DIR/local
11+
rm -rf $THIS_DIR/share
12+
rm -rf $THIS_DIR/venv

.dependencies/init.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
3+
# Get the absolute location of this script
4+
THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
5+
6+
LLVM_VERSION="21.1.0"
7+
LLVM_URL="https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VERSION}/LLVM-${LLVM_VERSION}-Linux-X64.tar.xz"
8+
TARBALL=$(basename "$LLVM_URL")
9+
10+
# 1. Check if llvm is already present
11+
if [ ! -x "$THIS_DIR/bin/clang" ]; then
12+
echo "LLVM not found in $THIS_DIR/bin. Downloading..."
13+
curl -LO "$LLVM_URL" -o "$TARBALL"
14+
15+
echo "Extracting LLVM directly into $THIS_DIR (this may take a moment)..."
16+
tar -xf "$TARBALL" -C "$THIS_DIR" --strip-components=1
17+
18+
rm "$TARBALL"
19+
echo "Setup complete."
20+
else
21+
echo "LLVM tools already present in $THIS_DIR/bin."
22+
fi
23+
24+
# Create virtual python environment
25+
python3 -m venv $THIS_DIR/venv
26+
27+
# Add bin to PATH
28+
export PATH="$THIS_DIR/bin:$PATH"
29+
source $THIS_DIR/venv/bin/activate
30+
31+
pip3 install codechecker pytest pylint
32+
33+
echo "Added $THIS_DIR/bin and $THIS_DIR/venv/bin to PATH."
34+
35+
# Verify it works
36+
which pylint
37+
which pytest
38+
which CodeChecker
39+
which clang
40+
which clang-tidy
41+
which diagtool
42+
which clang-extdef-mapping
43+
which python3

.gitignore

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,13 @@ venv
2020
.ci/micromamba/bin/
2121
.ci/micromamba/micromamba/
2222

23-
# Ignore test specific bazelversion files
24-
test/unit/external_repository/.bazelversion
25-
test/unit/external_repository/third_party/my_lib/.bazelversion
23+
# Ignore manual environment artifacts
24+
.dependencies/bin/
25+
.dependencies/include/
26+
.dependencies/lib/
27+
.dependencies/libexec/
28+
.dependencies/local/
29+
.dependencies/share/
2630

2731
# Ignore Bazel specific files
2832
.bazelversion

run_tests.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
#!/usr/bin/env bash
2-
# This script currently assumes that the user have set up their environment.
2+
# This script currently assumes that the user have bazel
3+
# set up inside their environment.
34
# This means users using bazelisk have set their bazel version.
45
# Either with the environment variable: USE_BAZEL_VERSION
5-
# or with the .bazelversion file.
6+
# or with a .bazelversion file.
7+
8+
# Get the absolute location of this script
9+
THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
10+
# We handle llvm and python dependencies here
11+
source $THIS_DIR/.dependencies/init.sh
12+
613
pylint .
714
bazel test //...
815
pytest test/

0 commit comments

Comments
 (0)