hello,
I've just changed minisign from C to Zig since this is now supported by
upstream (it was quite the journey though). I noticed we don't have any
packaging guideline for Zig yet so I would like to propose adding one.
The example based on my notes is quite straight-forward:
```
depends=(
glibc
)
makedepends=(
zig
)
build() {
cd "${pkgname}-${pkgver}"
zig build --verbose -Dcpu=baseline -Doptimize=ReleaseSmall
}
package() {
cd "${pkgname}-${pkgver}"
install -Dm755 -t "${pkgdir}/usr/bin" zig-out/bin/example
}
```
Common gotchas were:
- The `zig build` command is essentially fully silent if no interactive
terminal is attached, `--verbose` helped but it's still very little info
- Without `-Dcpu=baseline` the compiler is going to probe the build
server cpu, which both causes problems with Reproducible Builds, but
more importantly can also make the binary crash with `Illegal
instruction` errors, since the default binaries aren't really distributable
Looking at the ncdu PKGBUILD shows there's some room for improvement:
```
build() {
cd "${pkgname}-${pkgver}"
DESTDIR="build" zig build \
--summary all \
--global-cache-dir ../zig-global-cache \
--prefix /usr \
--search-prefix /usr \
--release=safe \
-Dtarget=native-linux.6.1-gnu.2.38 \
-Dcpu=baseline \
-Dpie=true
}
check() {
cd "${pkgname}-${pkgver}"
zig build test \
--summary all \
--global-cache-dir ../zig-global-cache \
--prefix /usr \
--search-prefix /usr \
--release=safe \
-Dtarget=native-linux.6.1-gnu.2.38 \
-Dcpu=baseline \
-Dpie=true
}
```
More input very welcome, but I'm also fine with adding a very basic one
by myself and whoever has something to add can just edit the wiki.
Never lose the plot,
kpcyrd