Skip to content

Commit

Permalink
feat: Add a clang-fake to the fedora image.
Browse files Browse the repository at this point in the history
This will help speed up clang-tidy by not actually compiling anything
but still letting cmake produce compile_commands.json.
  • Loading branch information
iphydf committed Jan 7, 2025
1 parent b863af5 commit 1a8e838
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 38 deletions.
45 changes: 45 additions & 0 deletions qtox/clang-fake
Original file line number Diff line number Diff line change
@@ -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 <option|file> [<option|file> ...]")
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()
77 changes: 39 additions & 38 deletions qtox/docker/Dockerfile.fedora
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

0 comments on commit 1a8e838

Please sign in to comment.