1 Commits

Author SHA1 Message Date
10756b4f61 port to meson cargo
Some checks failed
Gentoo Utils / build (push) Has been cancelled
Gentoo Utils / test (push) Has been cancelled
Gentoo Utils / fuzz (push) Has been cancelled
Gentoo Utils / build-oci-image (push) Has been cancelled
Gentoo Utils / check-format (push) Has been cancelled
Gentoo Utils / docs (push) Has been cancelled
Gentoo Utils / grep (push) Has been cancelled
Use the new unstable meson cargo support. This simplifies the
meson.build script and allows to use crates such as clap that require
picking up features from Cargo.toml.

This also allows us to not embed thiserror in subprojects, and instead
use a wrap file with a custom meson.build and some patches to make it
compile without running its build.rs script.
2025-12-22 08:03:02 +00:00
4 changed files with 54 additions and 112 deletions

View File

@@ -6,19 +6,22 @@ RUN getuto
RUN emerge-webrsync
RUN mkdir -p /var/cache/distfiles/git3-src && chown portage:portage /var/cache/distfiles/git3-src
ENV EGIT_OVERRIDE_REPO_MESONBUILD_MESON=https://jturnerusa.dev/cgit/meson
RUN emerge \
=dev-lang/rust-bin-9999 \
=dev-build/meson-9999::gentoo \
llvm-core/clang \
llvm-core/lld \
dev-vcs/git \
sys-process/parallel \
net-libs/nodejs
RUN git clone https://jturnerusa.dev/cgit/ebuilds/ /var/db/repos/spawns
COPY etc/portage/repos.conf /etc/portage/
RUN mkdir -p /var/cache/distfiles/git3-src && chown portage:portage /var/cache/distfiles/git3-src
RUN emerge =dev-build/meson-9999::spawns
RUN useradd -m gentooligan
USER gentooligan

View File

@@ -15,55 +15,61 @@ jobs:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Checkout repo
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Restore git cache
uses: actions/cache@v4
with:
path: .git
key: gitea-repo-${{ gitea.repository }}-${{ gitea.ref }}
- name: Detect Changes
uses: dorny/paths-filter@v3
id: image-changes
- name: Checkout repo
uses: actions/checkout@v5
with:
filters: |
docker:
- ".docker/**"
fetch-depth: 0
- name: Metadata
id: metadata
- name: Check for changes before building
id: image-changes
# build image only if 1. changes are detected or 2. an image for the working branch doesnt exist
run: |
branch_name="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
default_branch_name="${{ gitea.event.repository.default_branch }}"
image_tag=latest
if [[ $default_branch_name != $branch_name ]]; then
this_image_tag="$(echo "$branch_name" | sed -E 's/[^a-zA-Z0-9]/-/g')"
echo "steps... ${{ steps.image-changes.outputs.docker }}"
if [[ ${{ steps.image-changes.outputs.docker }} == true ]] || docker manifest inspect ${{ vars.REGISTRY_URL }}/${{ gitea.repository }}:${this_image_tag} >/dev/null 2>&1; then
image_tag=$this_image_tag
fi
else
comparison_hash="${{ gitea.event.before }}"
if [[ "$branch_name" != "$default_branch_name" ]]; then
image_tag=$branch_name
fi
# slugify
image_tag="$(echo "$image_tag" | sed -E 's/[^a-zA-Z0-9]/-/g')"
# rebase breaks gitea.event.before, so check to make sure the hash provided exists
if ! git merge-base --is-ancestor $comparison_hash $branch_name >/dev/null 2>&1; then
comparison_hash=$(git merge-base origin/$default_branch_name $branch_name)
fi
if ! git diff $comparison_hash ${{ gitea.sha }} --no-patch --exit-code .docker; then
build_image=true
else
if ! docker manifest inspect ${{ vars.REGISTRY_URL }}/${{ gitea.repository }}:${image_tag} >/dev/null 2>&1; then
build_image=true
else
build_image=false
fi
fi
echo "default_branch_name=$default_branch_name" >> $GITEA_OUTPUT
echo "branch_name=$branch_name" >> $GITEA_OUTPUT
echo "image_tag=$image_tag" >> $GITEA_OUTPUT
echo "build_image=${build_image:-${{ steps.image-changes.outputs.docker }}}" >> $GITEA_OUTPUT
echo "comparison_hash=$comparison_hash" >> $GITEA_OUTPUT
echo "build_image=$build_image" >> $GITEA_OUTPUT
cat $GITEA_OUTPUT
- name: Set up Docker buildx
if: steps.metadata.outputs.build_image == 'true'
if: steps.image-changes.outputs.build_image == 'true'
uses: docker/setup-buildx-action@v3
with:
driver-opts: network=runners-net
- name: Log in to Github Container Registry
if: steps.metadata.outputs.build_image == 'true'
if: steps.image-changes.outputs.build_image == 'true'
uses: docker/login-action@v3
with:
registry: ${{ vars.REGISTRY_URL }}
@@ -71,32 +77,26 @@ jobs:
password: ${{ secrets.CI_BOT_TOKEN }}
- name: Build and push
if: steps.metadata.outputs.build_image == 'true'
if: steps.image-changes.outputs.build_image == 'true'
uses: docker/build-push-action@v6
with:
push: true
tags: ${{ vars.REGISTRY_URL }}/${{ gitea.repository }}:${{ steps.metadata.outputs.image_tag }}
tags: ${{ vars.REGISTRY_URL }}/${{ gitea.repository }}:${{ steps.image-changes.outputs.image_tag }}
context: "{{defaultContext}}:.docker"
cache-from: type=gha
cache-to: type=gha,mode=max
outputs:
image_tag: ${{ steps.metadata.outputs.image_tag }}
image_tag: ${{ steps.image-changes.outputs.image_tag }}
build:
runs-on: gentoo
runs-on: brutalisk
env:
CC: "clang"
CXX: "clang++"
CC: 'clang'
CXX: 'clang++'
needs: build-oci-image
container:
image: ${{ vars.REGISTRY_URL }}/${{ gitea.repository }}:${{ needs.build-oci-image.outputs.image_tag }}
steps:
- name: Restore git cache
uses: actions/cache@v4
with:
path: build
key: gitea-repo-${{ gitea.repository }}-${{ gitea.ref }}
- name: Checkout repo
uses: actions/checkout@v5
@@ -108,19 +108,14 @@ jobs:
# FIXME: Currently this rebuilds everything. Instead we should bring over the build dir from the build job. This will come in handy
# when we have multiple build targets and configs. What we have currently is fine until we get lots of builds going
test:
runs-on: gentoo
runs-on: brutalisk
env:
CC: "clang"
CXX: "clang++"
CC: 'clang'
CXX: 'clang++'
needs: [build-oci-image, build]
container:
image: ${{ vars.REGISTRY_URL }}/${{ gitea.repository }}:${{ needs.build-oci-image.outputs.image_tag }}
steps:
- name: Restore git cache
uses: actions/cache@v4
with:
path: build
key: gitea-repo-${{ gitea.repository }}-${{ gitea.ref }}
- name: Checkout repo
uses: actions/checkout@v5
@@ -131,20 +126,15 @@ jobs:
ninja test -C build
fuzz:
runs-on: gentoo
runs-on: brutalisk
env:
CC: "clang"
CXX: "clang++"
CC: 'clang'
CXX: 'clang++'
FUZZER_TIMEOUT_S: 300
needs: [build-oci-image, build]
container:
image: ${{ vars.REGISTRY_URL }}/${{ gitea.repository }}:${{ needs.build-oci-image.outputs.image_tag }}
steps:
- name: Restore git cache
uses: actions/cache@v4
with:
path: build
key: gitea-repo-${{ gitea.repository }}-${{ gitea.ref }}
- name: Checkout repo
uses: actions/checkout@v5
@@ -168,7 +158,7 @@ jobs:
continue-on-error: true
check-format:
runs-on: gentoo
runs-on: brutalisk
needs: [build-oci-image]
container:
image: ${{ vars.REGISTRY_URL }}/${{ gitea.repository }}:${{ needs.build-oci-image.outputs.image_tag }}
@@ -183,7 +173,7 @@ jobs:
ninja rustfmt -C build
docs:
runs-on: gentoo
runs-on: brutalisk
needs: [build-oci-image]
container:
image: ${{ vars.REGISTRY_URL }}/${{ gitea.repository }}:${{ needs.build-oci-image.outputs.image_tag }}
@@ -197,7 +187,7 @@ jobs:
ninja rustdoc -C docs
grep:
runs-on: gentoo
runs-on: brutalisk
needs: [build-oci-image]
container:
image: ${{ vars.REGISTRY_URL }}/${{ gitea.repository }}:${{ needs.build-oci-image.outputs.image_tag }}

View File

@@ -6,5 +6,4 @@ edition = "2024"
[dependencies]
mon = { git = "https://jturnerusa.dev/cgit/mon/", rev = "67861a4df8a5abdd70651d47cf265b20c41d2acc" }
get = { git = "https://jturnerusa.dev/cgit/get/", rev = "cd5f75b65777a855ab010c3137304ac05f2e56b8" }
itertools = "0.14.0"
thiserror = { version = "2.0.17", features = ["derive"] }
itertools = "0.14.0"

View File

@@ -1,50 +0,0 @@
#+title: Gentoo Utils
* Getting Started
Gentoo Utils must be compiled from source currently. See the compiling from source section for more information.
* Development :development:contributing:
There are two main avenues for development:
- compiling normally using packages via portage
- using the podman container
** Development without using a podman container
*** Install Build Prerequisites
- dev-lang/rust-bin-9999
- llvm-core/clang
- llvm-core/lld
- sys-process/parallel (Needed for =check.sh=)
- dev-build/meson
Install build deps:
#+begin_src bash :noeval
emerge -a dev-lang/rust-bin-9999 \
llvm-core/clang \
llvm-core/lld \
sys-process/parallel
#+end_src
Compiling this project currently requires using a patched meson. Install patched meson:
#+begin_src bash :noeval
EGIT_OVERRIDE_REPO_MESONBUILD_MESON=https://jturnerusa.dev/cgit/meson emerge -a =dev-build/meson-9999::gentoo
#+end_src
** Development using a podman container
The podman image comes with all the tools required to compile gentoo-utils.
Clone the repo
#+begin_src bash :noeval
git clone https://git.epenguin.net/gentoo-utils/gentoo-utils.git
cd gentoo-utils
#+end_src
Run the check script:
#+begin_src bash :noeval
podman run --rm --userns=keep-id -v $PWD:/workspace git.epenguin.net/gentoo-utils/gentoo-utils:latest ./check.sh
#+end_src
* Resources
pms-utils spec link