From c28485d20628be201fd71fbb6484253adbdd8995 Mon Sep 17 00:00:00 2001 From: Boyd Johnson Date: Sat, 13 Apr 2024 15:26:21 -0500 Subject: [PATCH] Add Dockerfiles to run tests against different clang versions --- dockerfiles/Dockerfile-bindgen | 10 ++++++++++ dockerfiles/Dockerfile-clang | 16 ++++++++++++++++ dockerfiles/README.md | 31 +++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 dockerfiles/Dockerfile-bindgen create mode 100644 dockerfiles/Dockerfile-clang create mode 100644 dockerfiles/README.md diff --git a/dockerfiles/Dockerfile-bindgen b/dockerfiles/Dockerfile-bindgen new file mode 100644 index 0000000000..09a914b6de --- /dev/null +++ b/dockerfiles/Dockerfile-bindgen @@ -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"] diff --git a/dockerfiles/Dockerfile-clang b/dockerfiles/Dockerfile-clang new file mode 100644 index 0000000000..c48914f8c6 --- /dev/null +++ b/dockerfiles/Dockerfile-clang @@ -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 diff --git a/dockerfiles/README.md b/dockerfiles/README.md new file mode 100644 index 0000000000..e020ccc2e7 --- /dev/null +++ b/dockerfiles/README.md @@ -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 +```