From 0ce1342263ce94837015db6a96c0e819fc0cf016 Mon Sep 17 00:00:00 2001 From: "Jeffrey C. Ollie" Date: Sat, 15 Feb 2025 16:17:46 -0600 Subject: [PATCH 1/5] gtk: fix building on Debian 12 `std.debug.assert(x)` _is not_ the same as `if (!x) unreachable` because the function call is not `inline`. Since it's not inline the Zig compiler will try to compile any code that might otherwise be unreachable. Also, added a CI test that compiles Ghostty in a Debian 12 container to ensure that regressions do not happen. --- .github/workflows/test.yml | 26 ++++++++++++++++ src/apprt/gtk/Window.zig | 7 +++-- src/build/docker/debian/Dockerfile | 49 ++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 src/build/docker/debian/Dockerfile diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 20ca3f419..c3a61a560 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -626,3 +626,29 @@ jobs: - name: Test ${{ matrix.pkg }} Build run: | nix develop -c sh -c "cd pkg/${{ matrix.pkg }} ; zig build test" + + test-debian-12: + strategy: + fail-fast: false + matrix: + platform: ["linux/amd64", "linux/arm64"] + name: Test build on Debian 12 ${{ matrix.platform }} + runs-on: namespace-profile-ghostty-sm + needs: test + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install and configure Namespace CLI + uses: namespacelabs/nscloud-setup@v0 + + - name: Configure Namespace powered Buildx + uses: namespacelabs/nscloud-setup-buildx-action@v0 + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + file: src/build/docker/debian/Dockerfile + build-args: DISTRO_VERSION=12 + platform: ${{ matrix.platform }} diff --git a/src/apprt/gtk/Window.zig b/src/apprt/gtk/Window.zig index bbf53b351..ab5e54d9f 100644 --- a/src/apprt/gtk/Window.zig +++ b/src/apprt/gtk/Window.zig @@ -152,7 +152,7 @@ pub fn init(self: *Window, app: *App) !void { // If we're using an AdwWindow then we can support the tab overview. if (self.tab_overview) |tab_overview| { - assert(adwaita.versionAtLeast(1, 4, 0)); + if (!adwaita.versionAtLeast(1, 4, 0)) unreachable; const btn = switch (app.config.@"gtk-tabs-location") { .top, .bottom => btn: { const btn = c.gtk_toggle_button_new(); @@ -228,6 +228,7 @@ pub fn init(self: *Window, app: *App) !void { // If we have a tab overview then we can set it on our notebook. if (self.tab_overview) |tab_overview| { + if (!adwaita.versionAtLeast(1, 4, 0)) unreachable; c.adw_tab_overview_set_view(@ptrCast(tab_overview), self.notebook.tab_view); } @@ -364,7 +365,7 @@ pub fn syncAppearance(self: *Window, config: *const configpkg.Config) !void { // *inside* the tab overview if CSDs are disabled. // We do spare the search button, though. if (self.tab_overview) |tab_overview| { - assert(adwaita.versionAtLeast(1, 4, 0)); + if (!adwaita.versionAtLeast(1, 4, 0)) unreachable; c.adw_tab_overview_set_show_start_title_buttons( @ptrCast(tab_overview), @intFromBool(csd_enabled), @@ -509,7 +510,7 @@ pub fn gotoTab(self: *Window, n: usize) bool { /// Toggle tab overview (if present) pub fn toggleTabOverview(self: *Window) void { if (self.tab_overview) |tab_overview_widget| { - assert(adwaita.versionAtLeast(1, 4, 0)); + if (!adwaita.versionAtLeast(1, 4, 0)) unreachable; const tab_overview: *c.AdwTabOverview = @ptrCast(@alignCast(tab_overview_widget)); c.adw_tab_overview_set_open(tab_overview, 1 - c.adw_tab_overview_get_open(tab_overview)); } diff --git a/src/build/docker/debian/Dockerfile b/src/build/docker/debian/Dockerfile new file mode 100644 index 000000000..61e9e75c1 --- /dev/null +++ b/src/build/docker/debian/Dockerfile @@ -0,0 +1,49 @@ +ARG DISTRO_VERSION="12" +FROM docker.io/library/debian:${DISTRO_VERSION} + +# Install Dependencies +RUN DEBIAN_FRONTEND="noninteractive" apt-get -qq update && \ + apt-get -qq -y --no-install-recommends install \ + # Build Tools + build-essential \ + libbz2-dev \ + libonig-dev \ + lintian \ + lsb-release \ + pandoc \ + wget \ + # Ghostty Dependencies + libadwaita-1-dev \ + libgtk-4-dev && \ + # Clean up for better caching + rm -rf /var/lib/apt/lists/* + +# work around the fact that Debian 12 doesn't ship a pkg-config file for bzip2 +RUN . /etc/os-release; if [ $VERSION_ID -le 12 ]; then ln -s libbz2.so /usr/lib/$(gcc -dumpmachine)/libbzip2.so; fi + +# Install zig +# https://ziglang.org/download/ +ARG ZIG_VERSION="0.13.0" +RUN wget -q "https://ziglang.org/download/$ZIG_VERSION/zig-linux-$(uname -m)-$ZIG_VERSION.tar.xz" && \ + tar -xf "zig-linux-$(uname -m)-$ZIG_VERSION.tar.xz" -C /opt && \ + rm zig-linux-* && \ + ln -s "/opt/zig-linux-$(uname -m)-$ZIG_VERSION/zig" /usr/local/bin/zig + +WORKDIR /src + +COPY ./dist/linux /src/dist/linux +COPY ./images /src/images +COPY ./include /src/include +COPY ./pkg /src/pkg +COPY ./nix /src/nix +COPY ./vendor /src/vendor +COPY ./build.zig /src/build.zig +COPY ./build.zig.zon /src/build.zig.zon +COPY ./build.zig.zon.txt /src/build.zig.zon.txt + +RUN ZIG_GLOBAL_CACHE_DIR=/zig/global-cache ./nix/build-support/fetch-zig-cache.sh + +COPY ./src /src/src + +RUN zig build -Doptimize=Debug -Dcpu=baseline -Dapp-runtime=gtk --system /zig/global-cache/p + From c7b3cbd3979f2d64fbdcecea86f5aa0b35750380 Mon Sep 17 00:00:00 2001 From: "Jeffrey C. Ollie" Date: Sat, 15 Feb 2025 17:57:19 -0600 Subject: [PATCH 2/5] gtk: only test Debian 12 builds on amd64 --- .github/workflows/test.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c3a61a560..693870a7e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -628,11 +628,7 @@ jobs: nix develop -c sh -c "cd pkg/${{ matrix.pkg }} ; zig build test" test-debian-12: - strategy: - fail-fast: false - matrix: - platform: ["linux/amd64", "linux/arm64"] - name: Test build on Debian 12 ${{ matrix.platform }} + name: Test build on Debian 12 runs-on: namespace-profile-ghostty-sm needs: test steps: @@ -651,4 +647,3 @@ jobs: context: . file: src/build/docker/debian/Dockerfile build-args: DISTRO_VERSION=12 - platform: ${{ matrix.platform }} From 191b19f9a5067f0746406615a6af787d371b721a Mon Sep 17 00:00:00 2001 From: "Jeffrey C. Ollie" Date: Sat, 15 Feb 2025 17:58:25 -0600 Subject: [PATCH 3/5] gtk: add debian build to list of required checks --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 693870a7e..f870dfe36 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,6 +26,7 @@ jobs: - alejandra - typos - test-pkg-linux + - test-debian-12 steps: - id: status name: Determine status From fb35d109817d693cc33d0895247848736211685e Mon Sep 17 00:00:00 2001 From: "Jeffrey C. Ollie" Date: Sat, 15 Feb 2025 18:01:07 -0600 Subject: [PATCH 4/5] gtk: add Zig version as arg to Debian 12 build --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f870dfe36..ad29856c4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -647,4 +647,4 @@ jobs: with: context: . file: src/build/docker/debian/Dockerfile - build-args: DISTRO_VERSION=12 + build-args: DISTRO_VERSION=12,ZIG_VERSION=0.13.0 From b0d68324a681825927da10934b9a217957d2d120 Mon Sep 17 00:00:00 2001 From: "Jeffrey C. Ollie" Date: Sat, 15 Feb 2025 18:11:42 -0600 Subject: [PATCH 5/5] gtk: fix multiple build args in docker build --- .github/workflows/test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ad29856c4..e64b2c4d8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -647,4 +647,6 @@ jobs: with: context: . file: src/build/docker/debian/Dockerfile - build-args: DISTRO_VERSION=12,ZIG_VERSION=0.13.0 + build-args: | + DISTRO_VERSION=12 + ZIG_VERSION=0.13.0