Skip to content

Commit

Permalink
Add Dockerfiles to run tests against different clang versions
Browse files Browse the repository at this point in the history
  • Loading branch information
boydjohnson committed Apr 13, 2024
1 parent 7e90434 commit c28485d
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
10 changes: 10 additions & 0 deletions dockerfiles/Dockerfile-bindgen
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
ARG LLVM_VERSION=13

FROM clang:${LLVM_VERSION}-ubuntu

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain nightly

COPY . /project
WORKDIR /project

CMD ["/root/.cargo/bin/cargo", "test", "-p", "bindgen-tests", "--features", "__testing_only_extra_assertions"]
16 changes: 16 additions & 0 deletions dockerfiles/Dockerfile-clang
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM ubuntu:jammy

ENV DEBIAN_FRONTEND noninteractive

ARG LLVM_VERSION=13

RUN apt-get update && apt-get install -y \
wget \
curl \
gnupg \
build-essential \
&& wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor | tee /usr/share/keyrings/llvm-archive-keyring.gpg > /dev/null \
&& 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 \
&& apt-get update && apt-get install -y \
clang-${LLVM_VERSION} \
libclang-${LLVM_VERSION}-dev
31 changes: 31 additions & 0 deletions dockerfiles/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Dockerfiles for running cargo test on bindgen-tests

## Dockerfile-clang

LLVM_VERSION can be [13, 18] and correspond to the packages at [apt.llvm.org](https://apt.llvm.org/) for Ubuntu 22.04

From the `rust-bingen` repo,

```
docker build dockerfiles -f dockerfiles/Dockerfile-clang -t clang:14-ubuntu --build-arg LLVM_VERSION=14
```

## Dockerfile-bindgen

From the `rust-bindgen` repo,

```
docker build . -f dockerfiles/Dockerfile-bindgen -t bindgen:clang-14-ubuntu --build-arg LLVM_VERSION=14
```

## Make changes to the repo happen in the docker container

```
docker run -v .:/project bindgen:clang-14-ubuntu
```

To pass an environment variable to the container

```
docker run -v .:/project -e BINDGEN_OVERWRITE_EXPECTED=1 bindgen:clang-14-ubuntu
```

0 comments on commit c28485d

Please sign in to comment.