From 1a8e838a5c1f6dcf71fb551d2ae1eef77dc4da89 Mon Sep 17 00:00:00 2001 From: iphydf Date: Tue, 7 Jan 2025 13:03:08 +0000 Subject: [PATCH] feat: Add a clang-fake to the fedora image. This will help speed up clang-tidy by not actually compiling anything but still letting cmake produce compile_commands.json. --- qtox/clang-fake | 45 ++++++++++++++++++++ qtox/docker/Dockerfile.fedora | 77 ++++++++++++++++++----------------- 2 files changed, 84 insertions(+), 38 deletions(-) create mode 100755 qtox/clang-fake diff --git a/qtox/clang-fake b/qtox/clang-fake new file mode 100755 index 0000000..9220b89 --- /dev/null +++ b/qtox/clang-fake @@ -0,0 +1,45 @@ +#!/usr/bin/env python3 +# Compiles normally unless it's a file from the qtox source tree "src/". +# For src/ files, it just creates an empty object file. +import subprocess +import sys + + +def is_src_file(arg: str) -> bool: + return arg.startswith("/qtox/") and not arg.startswith("/qtox/_build") + + +def has_src_file(args: list[str]) -> bool: + return any(is_src_file(arg) for arg in args) + + +def output_file(args: list[str]) -> str: + for i, arg in enumerate(args): + if arg == "-o": + return args[i + 1] + raise ValueError("No output file specified") + + +def real_compile(args: list[str]) -> None: + subprocess.run(["clang"] + args, check=True) + + +def fake_compile(args: list[str]) -> None: + output = output_file(args) + with open(output, "wb") as f: + f.write(b"Nothing to see here, move along") + + +def main() -> None: + if len(sys.argv) < 2: + print("Usage: fake-clang [ ...]") + sys.exit(1) + + if has_src_file(sys.argv[1:]) or "libqtox_static.a" in sys.argv[1:]: + fake_compile(sys.argv[1:]) + else: + real_compile(sys.argv[1:]) + + +if __name__ == "__main__": + main() diff --git a/qtox/docker/Dockerfile.fedora b/qtox/docker/Dockerfile.fedora index 63d9e3e..fce3f36 100644 --- a/qtox/docker/Dockerfile.fedora +++ b/qtox/docker/Dockerfile.fedora @@ -4,38 +4,37 @@ FROM fedora:latest -RUN dnf --nodocs -y install dnf-plugins-core && \ - dnf --nodocs -y install https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm && \ - dnf --nodocs -y install \ - ccache \ - clang \ - clang-tools-extra \ - cmake \ - extra-cmake-modules \ - ffmpeg-devel \ - gcc \ - gcc-c++ \ - git \ - kf6-sonnet-devel \ - libasan \ - libexif-devel \ - libnotify-devel \ - libsodium-devel \ - libubsan \ - libvpx-devel \ - libXScrnSaver-devel \ - make \ - ninja-build \ - openal-soft-devel \ - opus-devel \ - patch \ - qrencode-devel \ - qt6-linguist \ - qt6-qtbase-devel \ - qt6-qtsvg-devel \ - sqlcipher-devel \ - sqlite-devel && \ - dnf clean all +RUN dnf --nodocs -y install dnf-plugins-core \ + && dnf --nodocs -y install https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm \ + && dnf --nodocs -y install \ + ccache \ + clang \ + clang-tools-extra \ + cmake \ + ffmpeg-devel \ + gcc \ + gcc-c++ \ + git \ + kf6-sonnet-devel \ + libasan \ + libexif-devel \ + libnotify-devel \ + libsodium-devel \ + libubsan \ + libvpx-devel \ + libXScrnSaver-devel \ + make \ + ninja-build \ + openal-soft-devel \ + opus-devel \ + patch \ + qrencode-devel \ + qt6-qtbase-devel \ + qt6-qtsvg-devel \ + qt6-qttools-devel \ + sqlcipher-devel \ + sqlite-devel \ + && dnf clean all ENV PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig @@ -44,13 +43,15 @@ COPY build_utils.sh /build/build_utils.sh COPY download/download_toxcore.sh /build/download/download_toxcore.sh COPY build_toxcore_system.sh /build/build_toxcore_system.sh -RUN mkdir -p /src/tox && \ - cd /src/tox && \ - /build/build_toxcore_system.sh && \ - rm -fr /src/tox +RUN mkdir -p /src/tox \ + && cd /src/tox \ + && /build/build_toxcore_system.sh \ + && rm -fr /src/tox -RUN echo '/usr/local/lib64/' >> /etc/ld.so.conf.d/locallib.conf && \ - ldconfig +RUN echo '/usr/local/lib64/' >> /etc/ld.so.conf.d/locallib.conf \ + && ldconfig + +COPY --chmod=755 clang-fake /usr/local/bin/ WORKDIR /qtox ENV HOME=/qtox