From 0688ab32c00746a6420bc49d3345148f8bac0401 Mon Sep 17 00:00:00 2001 From: MolassesLover Date: Mon, 20 Jul 2026 17:20:05 +0200 Subject: [PATCH 1/4] Initial (possibly broken) work on the Docker build --- Dockerfile | 43 +++++++++++++++++++++++++++++++++++++++++++ compose.yml | 11 +++++++++++ 2 files changed, 54 insertions(+) create mode 100644 Dockerfile create mode 100644 compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..322ac917 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,43 @@ +FROM ubuntu:latest + +RUN apt-get -y update +RUN apt-get -y install \ + clang++-22 \ + clang-22 \ + cmake \ + curl \ + libclang-22-dev \ + libcurl4-openssl-dev \ + libedit-dev \ + libzstd-dev \ + ninja-build \ + zlib1g-dev \ + rustup + +#RUN useradd -m workuser +#RUN chown -R workuser:workuser /home/workuser +#RUN mkdir -p /opt/workdir /home/workuser/.rustup/downloads +#RUN chown workuser:workuser /opt/workdir +#RUN chmod u+rw /opt/workdir /home/workuser +# +#USER workuser +# +#RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y + +RUN rustup toolchain install "1.96.1-x86_64-unknown-linux-gnu" +RUN rustup toolchain install "nightly-2026-06-30-x86_64-unknown-linux-gnu" +RUN rustup component add --toolchain "nightly-2026-06-30-x86_64-unknown-linux-gnu" rust-src rustc-dev llvm-tools-preview +RUN rustup component add --toolchain "1.96.1-x86_64-unknown-linux-gnu" rust-src rustc-dev llvm-tools-preview + +ENV PATH="/root/.cargo/bin:${PATH}" +ENV RUST_BACKTRACE=full + +WORKDIR /opt/workdir + +CMD cmake \ + -G Ninja \ + -B target/container/ubuntu/release \ + -D CMAKE_C_COMPILER="$(which clang-22)" \ + -D CMAKE_CXX_COMPILER="$(which clang++-22)" \ + .; \ + cmake --build target/container/ubuntu/release -j$(nproc) diff --git a/compose.yml b/compose.yml new file mode 100644 index 00000000..228fd8e7 --- /dev/null +++ b/compose.yml @@ -0,0 +1,11 @@ +services: + build: + image: cpp2rust/local-build:ubuntu + build: + context: . + volumes: + - "$PWD:/opt/workdir" + dns: 1.1.1.1 + cap_add: + - NET_ADMIN + From d512a1ca7eb9e47b8ce6f5ddff3fd032ceee63a2 Mon Sep 17 00:00:00 2001 From: MolassesLover Date: Mon, 20 Jul 2026 17:36:14 +0200 Subject: [PATCH 2/4] Fixed build failure caused by incorrect build path --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 322ac917..9e56555b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -36,8 +36,8 @@ WORKDIR /opt/workdir CMD cmake \ -G Ninja \ - -B target/container/ubuntu/release \ + -B build \ -D CMAKE_C_COMPILER="$(which clang-22)" \ -D CMAKE_CXX_COMPILER="$(which clang++-22)" \ .; \ - cmake --build target/container/ubuntu/release -j$(nproc) + cmake --build build -j$(nproc) From 579c7af98104b09026e825b7049cd099388de74c Mon Sep 17 00:00:00 2001 From: MolassesLover Date: Mon, 20 Jul 2026 17:37:46 +0200 Subject: [PATCH 3/4] Remove unecessary code and old comments --- Dockerfile | 12 +----------- compose.yml | 5 +---- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9e56555b..9f5ce740 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,16 +14,6 @@ RUN apt-get -y install \ zlib1g-dev \ rustup -#RUN useradd -m workuser -#RUN chown -R workuser:workuser /home/workuser -#RUN mkdir -p /opt/workdir /home/workuser/.rustup/downloads -#RUN chown workuser:workuser /opt/workdir -#RUN chmod u+rw /opt/workdir /home/workuser -# -#USER workuser -# -#RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y - RUN rustup toolchain install "1.96.1-x86_64-unknown-linux-gnu" RUN rustup toolchain install "nightly-2026-06-30-x86_64-unknown-linux-gnu" RUN rustup component add --toolchain "nightly-2026-06-30-x86_64-unknown-linux-gnu" rust-src rustc-dev llvm-tools-preview @@ -34,7 +24,7 @@ ENV RUST_BACKTRACE=full WORKDIR /opt/workdir -CMD cmake \ +CMD cmake \ -G Ninja \ -B build \ -D CMAKE_C_COMPILER="$(which clang-22)" \ diff --git a/compose.yml b/compose.yml index 228fd8e7..dcb27647 100644 --- a/compose.yml +++ b/compose.yml @@ -5,7 +5,4 @@ services: context: . volumes: - "$PWD:/opt/workdir" - dns: 1.1.1.1 - cap_add: - - NET_ADMIN - + \ No newline at end of file From de223ff6ba90e1a75187ef603ef3996461066b9a Mon Sep 17 00:00:00 2001 From: MolassesLover Date: Mon, 20 Jul 2026 18:57:50 +0200 Subject: [PATCH 4/4] Create an entrypoint script for Docker service --- Dockerfile | 18 ++++++++++++++++-- compose.yml | 2 +- misc/containers/build.sh | 25 +++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 3 deletions(-) create mode 100755 misc/containers/build.sh diff --git a/Dockerfile b/Dockerfile index 9f5ce740..0b708ffc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,8 @@ FROM ubuntu:latest +RUN mkdir /opt/source +RUN mkdir /opt/workdir + RUN apt-get -y update RUN apt-get -y install \ clang++-22 \ @@ -22,12 +25,23 @@ RUN rustup component add --toolchain "1.96.1-x86_64-unknown-linux-gnu" rust-src ENV PATH="/root/.cargo/bin:${PATH}" ENV RUST_BACKTRACE=full -WORKDIR /opt/workdir +COPY cpp2rust /opt/source/cpp2rust +COPY libc-dep /opt/source/libc-dep +COPY libcc2rs /opt/source/libcc2rs +COPY libcc2rs-macros /opt/source/libcc2rs-macros +COPY cmake /opt/source/cmake +COPY tests /opt/source/tests + +COPY CMakeLists.txt /opt/source/CMakeLists.txt -CMD cmake \ +WORKDIR /opt/source + +RUN cmake \ -G Ninja \ -B build \ -D CMAKE_C_COMPILER="$(which clang-22)" \ -D CMAKE_CXX_COMPILER="$(which clang++-22)" \ .; \ cmake --build build -j$(nproc) + +WORKDIR /opt/workdir \ No newline at end of file diff --git a/compose.yml b/compose.yml index dcb27647..a5bd5384 100644 --- a/compose.yml +++ b/compose.yml @@ -5,4 +5,4 @@ services: context: . volumes: - "$PWD:/opt/workdir" - \ No newline at end of file + entrypoint: ./misc/containers/build.sh diff --git a/misc/containers/build.sh b/misc/containers/build.sh new file mode 100755 index 00000000..624b18da --- /dev/null +++ b/misc/containers/build.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env sh + +# DO NOT RUN! +# This image is intended to be used from an OCI compose file. + +set -eo pipefail + +if [ -d "/opt/workdir/build" ]; then + echo "Build directory already exists, moving it." + if [ -d "/opt/workdir/build-backup" ]; then + echo "Build backup directory already exists, exiting as error." + exit 1 + else + mv /opt/workdir/build /opt/workdir/build-backup + fi +fi + +cmake \ + -G Ninja \ + -B build \ + -D CMAKE_C_COMPILER="$(which clang-22)" \ + -D CMAKE_CXX_COMPILER="$(which clang++-22)" \ + . + +cmake --build build "-j$(nproc)"