Skip to content

Commit c28485d

Browse files
committed
Add Dockerfiles to run tests against different clang versions
1 parent 7e90434 commit c28485d

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

dockerfiles/Dockerfile-bindgen

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
ARG LLVM_VERSION=13
2+
3+
FROM clang:${LLVM_VERSION}-ubuntu
4+
5+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain nightly
6+
7+
COPY . /project
8+
WORKDIR /project
9+
10+
CMD ["/root/.cargo/bin/cargo", "test", "-p", "bindgen-tests", "--features", "__testing_only_extra_assertions"]

dockerfiles/Dockerfile-clang

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM ubuntu:jammy
2+
3+
ENV DEBIAN_FRONTEND noninteractive
4+
5+
ARG LLVM_VERSION=13
6+
7+
RUN apt-get update && apt-get install -y \
8+
wget \
9+
curl \
10+
gnupg \
11+
build-essential \
12+
&& wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor | tee /usr/share/keyrings/llvm-archive-keyring.gpg > /dev/null \
13+
&& echo "deb [signed-by=/usr/share/keyrings/llvm-archive-keyring.gpg] https://apt.llvm.org/jammy/ llvm-toolchain-jammy-${LLVM_VERSION} main" > /etc/apt/sources.list.d/llvm.list \
14+
&& apt-get update && apt-get install -y \
15+
clang-${LLVM_VERSION} \
16+
libclang-${LLVM_VERSION}-dev

dockerfiles/README.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Dockerfiles for running cargo test on bindgen-tests
2+
3+
## Dockerfile-clang
4+
5+
LLVM_VERSION can be [13, 18] and correspond to the packages at [apt.llvm.org](https://apt.llvm.org/) for Ubuntu 22.04
6+
7+
From the `rust-bingen` repo,
8+
9+
```
10+
docker build dockerfiles -f dockerfiles/Dockerfile-clang -t clang:14-ubuntu --build-arg LLVM_VERSION=14
11+
```
12+
13+
## Dockerfile-bindgen
14+
15+
From the `rust-bindgen` repo,
16+
17+
```
18+
docker build . -f dockerfiles/Dockerfile-bindgen -t bindgen:clang-14-ubuntu --build-arg LLVM_VERSION=14
19+
```
20+
21+
## Make changes to the repo happen in the docker container
22+
23+
```
24+
docker run -v .:/project bindgen:clang-14-ubuntu
25+
```
26+
27+
To pass an environment variable to the container
28+
29+
```
30+
docker run -v .:/project -e BINDGEN_OVERWRITE_EXPECTED=1 bindgen:clang-14-ubuntu
31+
```

0 commit comments

Comments
 (0)