Re: [gentoo-dev] [PATCH] profiles/thirdpartymirrors: add final fallback for apache

2024-10-25 Thread Sam James
Eli Schwartz  writes:

> Apache has a mirror network, which only covers the most recent release
> of any given package. They also have an additional site which does not
> appear to be a CDN, and is throttled and can maybe ban you if you use it
> too much. Unfortunately, it is also the ONLY way to actually get
> historic releases of many packages.
>
> Use it, and use it last -- after every other mirror has been tried,
> which should handle latest releases. In combination with GENTOO_MIRRORS
> this should ensure that users can actually download software when
> needed, without running afoul of throttling.
>
> Signed-off-by: Eli Schwartz 
> ---

LGTM.

>  profiles/thirdpartymirrors | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/profiles/thirdpartymirrors b/profiles/thirdpartymirrors
> index bb5398896976..d3a857327495 100644
> --- a/profiles/thirdpartymirrors
> +++ b/profiles/thirdpartymirrors
> @@ -1,4 +1,4 @@
> -apache https://dlcdn.apache.org/ https://apache.mirror.iphh.net/
> https://artfiles.org/apache.org/
> https://ftp-stud.hs-esslingen.de/pub/Mirrors/ftp.apache.org/dist/
> https://ftp.fau.de/apache/ https://apache.osuosl.org/
> +apache https://dlcdn.apache.org/ https://apache.mirror.iphh.net/
> https://artfiles.org/apache.org/
> https://ftp-stud.hs-esslingen.de/pub/Mirrors/ftp.apache.org/dist/
> https://ftp.fau.de/apache/ https://apache.osuosl.org/
> https://archive.apache.org/dist/
>  cpan https://cpan.metacpan.org https://www.cpan.org
>  debian https://deb.debian.org/debian/
> http://ftp.au.debian.org/debian/ http://ftp.at.debian.org/debian/
> http://ftp.by.debian.org/debian/ http://ftp.be.debian.org/debian/
> http://ftp.br.debian.org/debian/ http://ftp.bg.debian.org/debian/
> http://ftp.ca.debian.org/debian/ http://ftp2.cn.debian.org/debian/
> http://ftp.cn.debian.org/debian/ http://ftp.hr.debian.org/debian/
> http://ftp.cz.debian.org/debian/ http://ftp.dk.debian.org/debian/
> http://ftp.sv.debian.org/debian/ http://ftp.ee.debian.org/debian/
> http://ftp.fi.debian.org/debian/ http://ftp.fr.debian.org/debian/
> http://ftp2.de.debian.org/debian/ http://ftp.de.debian.org/debian/
> http://ftp.gr.debian.org/debian/ http://ftp.hu.debian.org/debian/
> http://ftp.is.debian.org/debian/ http://ftp.ie.debian.org/debian/
> http://ftp.it.debian.org/debian/ http://ftp.jp.debian.org/debian/
> http://ftp.lt.debian.org/debian/ http://ftp.mx.debian.org/debian/
> http://ftp.md.debian.org/debian/ http://ftp.nl.debian.org/debian/
> http://ftp.nc.debian.org/debian/ http://ftp.nz.debian.org/debian/
> http://ftp.no.debian.org/debian/ http://ftp.pl.debian.org/debian/
> http://ftp.pt.debian.org/debian/ http://ftp.ro.debian.org/debian/
> http://ftp.ru.debian.org/debian/ http://ftp.sg.debian.org/debian/
> http://ftp.sk.debian.org/debian/ http://ftp.si.debian.org/debian/
> http://ftp.es.debian.org/debian/ http://ftp.se.debian.org/debian/
> http://ftp.ch.debian.org/debian/ http://ftp.tw.debian.org/debian/
> http://ftp.tr.debian.org/debian/ http://ftp.ua.debian.org/debian/
> http://ftp.uk.debian.org/debian/ http://ftp.us.debian.org/debian/
>  gentoo   https://distfiles.gentoo.org/distfiles 
> https://gentoo.osuosl.org/distfiles 
> https://ftp.halifax.rwth-aachen.de/gentoo/distfiles 
> https://ftp.fau.de/gentoo/distfiles



Re: [gentoo-dev] [PATCH 2/2] eclass/dotnet-pkg-base: add efsi function for running FSI

2024-10-25 Thread Sam James
x...@gentoo.org writes:

> From: Maciej Barć 
>
> This will replace "edotnet fsi" as used in "app-shells/pwsh" package.
>
> Signed-off-by: Maciej Barć 

OK given people will likely forget nologo, so probably worth having.

> ---
>  eclass/dotnet-pkg-base.eclass | 12 
>  1 file changed, 12 insertions(+)
>
> diff --git a/eclass/dotnet-pkg-base.eclass b/eclass/dotnet-pkg-base.eclass
> index 8cedde073b..26db694f59 100644
> --- a/eclass/dotnet-pkg-base.eclass
> +++ b/eclass/dotnet-pkg-base.eclass
> @@ -294,6 +294,18 @@ edotnet() {
>   edo "${DOTNET_PKG_EXECUTABLE}" "${@}"
>  }
>  
> +# @FUNCTION: efsi
> +# @USAGE:  [args...]
> +# @DESCRIPTION:
> +# Call dotnet fsi, passing the supplied arguments.
> +# FSI is the F# interpreter shipped with .NET SDK, it is useful for running 
> F#
> +# maintenance scripts.
> +efsi() {
> + debug-print-function ${FUNCNAME} "$@"
> +
> + edotnet fsi --nologo "${@}"
> +}
> +
>  # @FUNCTION: dotnet-pkg-base_info
>  # @DESCRIPTION:
>  # Show information about current .NET SDK that is being used.



Re: [gentoo-dev] [PATCH] profiles/thirdpartymirrors: add final fallback for apache

2024-10-25 Thread Robin H. Johnson
On Tue, Oct 22, 2024 at 11:24:29PM -0400, Eli Schwartz wrote:
> Apache has a mirror network, which only covers the most recent release
> of any given package. They also have an additional site which does not
> appear to be a CDN, and is throttled and can maybe ban you if you use it
> too much. Unfortunately, it is also the ONLY way to actually get
> historic releases of many packages.
> 
> Use it, and use it last -- after every other mirror has been tried,
> which should handle latest releases. In combination with GENTOO_MIRRORS
> this should ensure that users can actually download software when
> needed, without running afoul of throttling.
This does not actually do it "last" as you claim.

Portage shuffles the list of thirdpartymirrors:
https://gitweb.gentoo.org/proj/portage.git/tree/lib/portage/package/ebuild/fetch.py#n1140

While it increases mirror burden; this should likely be done as a
distinct thirdpartymirror:
apache-historical https://archive.apache.org/dist/

And that gets used in ebuilds when distfiles fall off the main mirrors
[until such time as strictly ordered behavior is available].

In likelihood, unless the ebuild has RESTRICT=mirror, I'd hope that that
the primary request is made to Gentoo's mirrors before the upstreams: so
that we are better open-source participants.

Users who are also trying to use old ebuilds, where the distfile is no
longer on the Gentoo mirrors should also consider thirdpartymirrors in
their profiles, in which case inserting this entry locally would be
appropriate.

-- 
Robin Hugh Johnson
Gentoo Linux: Dev, Infra Lead, Foundation Treasurer
E-Mail   : robb...@gentoo.org
GnuPG FP : 11ACBA4F 4778E3F6 E4EDF38E B27B944E 34884E85
GnuPG FP : 7D0B3CEB E9B85B1F 825BCECF EE05E6F6 A48F6136


signature.asc
Description: PGP signature


[gentoo-dev] [PATCH 2/5] zig-build.eclass: new eclass

2024-10-25 Thread Eric Joldasov
Signed-off-by: Eric Joldasov 
---
 eclass/zig-build.eclass | 580 
 1 file changed, 580 insertions(+)
 create mode 100644 eclass/zig-build.eclass

diff --git a/eclass/zig-build.eclass b/eclass/zig-build.eclass
new file mode 100644
index ..ffa075043cde
--- /dev/null
+++ b/eclass/zig-build.eclass
@@ -0,0 +1,580 @@
+# Copyright 2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: zig-build.eclass
+# @MAINTAINER:
+# Eric Joldasov 
+# @AUTHOR:
+# Alfred Wingate 
+# Violet Purcell 
+# Eric Joldasov 
+# @SUPPORTED_EAPIS: 8
+# @PROVIDES: zig-toolchain
+# @BLURB: Functions for working with ZBS (Zig Build System)
+# @DESCRIPTION:
+# Functions for working with Zig build system and package manager.  
+# Supports Zig 0.13+.  Exports default functions for convenience.  
+#
+# Note that zig-build.eclass is mostly tailored for projects that:
+# 1) Install something in build.zig steps: "artifacts" (executable,
+# libraries, objects), source codes, assets, tests, scripts etc.   But
+# many authors also use it to write Zig "modules", build logic
+# and/or bindings/wrappers for C/C++ libraries.  They install nothing
+# and are only used at build-time, so it's unneccessary and mostly
+# useless to make ebuilds for them.  
+# 2) Have required `target`, `cpu` and optional `optimize` options in
+# build.zig that accept standard Zig-style target and optimize mode.  
+# They are usually created by calling `b.standardTargetOptions` and
+# `b.standardOptimizeOption` functions.  
+#
+# For end-user executables, usually it's recommended to patch to call
+# these options and upstream it, but in some cases authors have good
+# reasons to not have them, f.e. if it is built only for WASM
+# platform with ReleaseSmall, and is not intended to run in /usr/bin/.  
+# In this case, declare dummy options using `b.option` and  ignore
+# their values, or else eclass wouldn't work.  
+#
+# Another case is when upstream has `target` option but it has
+# custom format and does not accept usual Zig targets, but rather
+# something specific to the project like "linux-baseline-lts", or
+# combine CPU and target in one option.  
+# In this case, it's best to rename that option to something like
+# `target-custom`, then declare `target` option and make converter
+# from one value to other.  
+#
+# For non-executable binaries like C libraries, objects etc. our
+# policy is stricter, all 3 options are required and should not
+# be ignored, with no exceptions.  
+
+if [[ ! ${_ZIG_BUILD_ECLASS} ]]; then
+_ZIG_BUILD_ECLASS=1
+
+case ${EAPI} in
+   8) ;;
+   *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
+esac
+
+inherit multiprocessing zig-toolchain
+
+# @ECLASS_VARIABLE: ZIG_OPTIONAL
+# @PRE_INHERIT
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# If set to a non-empty value, all logic in zig-toolchain and
+# zig-build eclasses will be considered optional.  No dependencies
+# will be added and no phase functions will be exported.  
+#
+# For zig-build.eclass users:
+# You need to add Zig and pkgconfig dependencies in your BDEPEND, set
+# QA_FLAGS_IGNORED and call all phase functions manually.  If you want
+# to use "ezig build" directly, call "zig-build_pkg_setup" before it.  
+#
+# For zig-toolchain.eclass users: see documentation in
+# zig-toolchain.eclass instead.  
+if [[ ! ${ZIG_OPTIONAL} ]]; then
+   BDEPEND="virtual/pkgconfig"
+
+   # See https://github.com/ziglang/zig/issues/3382
+   # Zig Build System does not support CFLAGS/LDFLAGS/etc.
+   QA_FLAGS_IGNORED=".*"
+fi
+
+# @ECLASS_VARIABLE: ZBS_DEPENDENCIES
+# @PRE_INHERIT
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# Bash associative array with all tarballs that will be fetched by
+# "ezig fetch" in zig-build_src_unpack phase.  Value is URL where
+# tarball is located, key is name under which it would be downloaded
+# and renamed.  So generally it has effect of "value -> key".  
+#
+# Note: if Zig Build System dependency can't be represented in SRC_URI
+# (like direct Git commit URIs), you should do the following
+# (zig-ebuilder does archiving automatically for you):
+#   1. Archive each folder with dependency content in some tarball,
+#  so f.e. if you have 2 Git dependencies, create 2 tarballs.  
+#   2. Archive all previous tarballs into one combined tarball (also
+#  called tarball-tarball from now on), no subdirs, so that eclass
+#  can firstly unpack this tarball with "unpack",
+#  and secondly unpack its content with "zig fetch".  
+#   3. (zig-ebuilder can't do this) Host this tarball somewhere
+#  and put URL of this tarball in SRC_URI, and archives in
+#  ZBS_DEPENDENCIES, keys must be names of archives, values empty.  
+#
+# Example:
+# @CODE
+# declare -r -A ZBS_DEPENDENCIES=(
+#  [tarball_a-.tar.gz]='URL_A'
+#  [tarball_b-.tar.gz]='URL_B'
+#
+#  # If there are Git dependencies:
+#  [git_c-.tar.gz]=''
+#  # Tarball-tarball should conta

[gentoo-dev] [PATCH 1/5] zig-toolchain.eclass: new eclass

2024-10-25 Thread Eric Joldasov
Signed-off-by: Eric Joldasov 
---
 eclass/zig-toolchain.eclass | 375 
 1 file changed, 375 insertions(+)
 create mode 100644 eclass/zig-toolchain.eclass

diff --git a/eclass/zig-toolchain.eclass b/eclass/zig-toolchain.eclass
new file mode 100644
index ..42a3f8ec3706
--- /dev/null
+++ b/eclass/zig-toolchain.eclass
@@ -0,0 +1,375 @@
+# Copyright 2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: zig-toolchain.eclass
+# @MAINTAINER:
+# Eric Joldasov 
+# @AUTHOR:
+# Eric Joldasov 
+# @SUPPORTED_EAPIS: 8
+# @BLURB: Prepare Zig toolchain and set environment variables
+# @DESCRIPTION:
+# Prepare Zig toolchain and set environment variables.
+# Supports Zig 0.13+.
+# Does not set any default function, ebuilds must call them manually.
+# Generally, only "zig-toolchain_populate_env_vars" is needed.
+#
+# Intended to be used by ebuilds that call "zig build-exe/lib/obj"
+# or "zig test" directly and by "dev-lang/zig".
+# For ebuilds with ZBS (Zig Build System), it's usually better
+# to inherit zig-build instead, as it has default phases-functions.
+
+if [[ ! ${_ZIG_TOOLCHAIN_ECLASS} ]]; then
+_ZIG_TOOLCHAIN_ECLASS=1
+
+case ${EAPI} in
+   8) ;;
+   *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
+esac
+
+inherit edo flag-o-matic
+
+# @ECLASS_VARIABLE: ZIG_SLOT
+# @PRE_INHERIT
+# @REQUIRED
+# @DESCRIPTION:
+# Zig slot that will be used in "ezig" function.  Also, if
+# ZIG_OPTIONAL is empty, adds dev-lang/zig and dev-lang/zig-bin
+# dependency to BDEPEND.  Must be >= "0.13".
+#
+# Example:
+# @CODE
+# 0.13
+# @CODE
+#
+# When a new Zig release occurs, it is advisable for maintainers to
+# check whether their ebuild supports that new version.  If yes, they
+# they should bump ZIG_SLOT to the latest version; if not supported,
+# they need to patch any issues with new version and again bump
+# ZIG_SLOT.  This helps to reduce dependencies on outdated Zig
+# versions.
+#
+# This policy of "1 exclusive Zig slot" will work until it
+# stabilizes enough (probably near 1.0), then it will be re-evaluated
+# and most likely changed to more common in other eclasses ZIG_MIN/
+# ZIG_MAX form.
+
+# @ECLASS_VARIABLE: ZIG_OPTIONAL
+# @PRE_INHERIT
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# If set to a non-empty value, all logic in zig-toolchain and
+# zig-build eclasses will be considered optional.  No dependencies
+# will be added and no phase functions will be exported.
+#
+# For zig-toolchain.eclass users:
+# You have to add Zig dependency in your BDEPEND manually and call
+# at least "zig-toolchain_populate_env_vars" before using "ezig".
+#
+# For zig-build.eclass users: see documentation in zig-build.eclass
+# instead.
+if [[ ! ${ZIG_OPTIONAL} ]]; then
+   BDEPEND="|| (
+   dev-lang/zig:${ZIG_SLOT}
+   dev-lang/zig-bin:${ZIG_SLOT}
+   )"
+fi
+
+# @ECLASS_VARIABLE: ZIG_TARGET
+# @DESCRIPTION:
+# Zig target triple to use.  Has the following format:
+# arch-os[.os_version_range]-abi[.abi_version]
+# Can be passed as:
+# * "-target " option in "zig test" or "zig build-exe/lib/obj",
+# * "-Dtarget=" option in "zig build"
+#   (if project uses "std.Build.standardTargetOptions").
+#
+# Can be overriden by user.  If not overriden, then set by
+# "zig-toolchain_populate_env_vars".
+#
+# Example:
+# @CODE
+# # Autodetected by Zig:
+# native
+# # Machine running Linux x86_64 system, with glibc:
+# x86_64-linux-gnu
+# # Similar to above, but versions are passed explicitly:
+# x86_64-linux.6.1.12...6.6.16-gnu.2.38
+# # Machine running Linux PPC64 little-endian system, with musl
+# powerpc64le-linux-musl
+# @CODE
+#
+
+# @ECLASS_VARIABLE: ZIG_CPU
+# @DESCRIPTION:
+# Zig target CPU and features to use.  Has the following format:
+# family_name(\+enable_feature|\-disable_feature)*
+# Can be passed as:
+# * "-mcpu " option in "zig test" or "zig build-exe/lib/obj",
+# * "-Dcpu=" option in "zig build"
+#   (if project uses "std.Build.standardTargetOptions").
+#
+# Can be overriden by user.  If not overriden, then set by
+# "zig-toolchain_populate_env_vars".
+#
+# Example:
+# @CODE
+# # Autodetected by Zig:
+# native
+# # AMD Zen 2 processor
+# znver2
+# # x86_64 processor, X87 support enabled, SSE2 support disabled
+# x86_64+x87-sse2
+# @CODE
+
+# @ECLASS_VARIABLE: ZIG_EXE
+# @DESCRIPTION:
+# Absolute path to the used Zig executable.
+#
+# Please note that when passing one flag several times with different
+# values:
+# * (only "zig build") in "-Dbar=false -Dbar" form:
+#   errors due to conflict of flags,
+# * (only "zig build") in "-Dbar=false -Dbar=true" form:
+#   "bar" becomes a list, which is likely not what you want,
+# * in "-fbar -fno-bar" form:
+#   latest value overwrites values before.
+# Example above shows only boolean option, but it is same with other
+# types of options (enums, "std.zig.BuildId", "std.SemanticVersion",
+# integers, strings, etc.).
+#
+# Can be overriden by user.  If not overriden, t

[gentoo-dev] [PATCH 5/5] sys-fs/ncdu: add 2.6-r1

2024-10-25 Thread Eric Joldasov
Now uses "zig-build" eclass.

Signed-off-by: Eric Joldasov 
---
 sys-fs/ncdu/ncdu-2.6-r1.ebuild | 50 ++
 1 file changed, 50 insertions(+)
 create mode 100644 sys-fs/ncdu/ncdu-2.6-r1.ebuild

diff --git a/sys-fs/ncdu/ncdu-2.6-r1.ebuild b/sys-fs/ncdu/ncdu-2.6-r1.ebuild
new file mode 100644
index ..6fb3c76328cc
--- /dev/null
+++ b/sys-fs/ncdu/ncdu-2.6-r1.ebuild
@@ -0,0 +1,50 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/openpgp-keys/yoranheling.asc
+# Upstream states 0.12.x and 0.13.x support,
+# but eclass supports only one slot.
+ZIG_SLOT="0.13"
+inherit verify-sig zig-build
+
+DESCRIPTION="NCurses Disk Usage"
+HOMEPAGE="https://dev.yorhel.nl/ncdu";
+SRC_URI="
+   https://dev.yorhel.nl/download/${P}.tar.gz
+   verify-sig? ( https://dev.yorhel.nl/download/${P}.tar.gz.asc )
+"
+
+LICENSE="MIT"
+SLOT="0"
+KEYWORDS="~amd64"
+
+BDEPEND="verify-sig? ( sec-keys/openpgp-keys-yorhel )"
+DEPEND="
+   app-arch/zstd
+   sys-libs/ncurses:=[unicode(+)]
+"
+RDEPEND="${DEPEND}"
+
+DOCS=("README.md" "ChangeLog")
+
+src_unpack() {
+   verify-sig_src_unpack
+}
+
+src_configure() {
+   local my_zbs_args=(
+   -Dpie=true
+   # Upstream recommends this default:
+   --release=fast
+   )
+
+   zig-build_src_configure
+}
+
+src_install() {
+   zig-build_src_install
+
+   doman ncdu.1
+}
-- 
2.47.0




[gentoo-dev] [PATCH 0/5] Ziglang eclasses for 0.13+

2024-10-25 Thread Eric Joldasov
Hello everyone,

This patch series adds new eclasses for packages that use Zig
toolchain with varying level of integration. Since some projects
or ebuilds use only Zig compiler directly, without touching Zig Build
System, I have decided to split eclasses into 2:

* zig-toolchain.eclass: handles dependency on Zig toolchain and
  finds appropriate versions/slots, converts C-style target tuples/triples
  to Zig format and sets environment variables to be used in other
  eclasses and ebuilds. This eclass is more low-level and intended
  to be used by programs and libraries that call "zig" commands directly,
  without having build.zig file and using "zig build" command. For example,
  authors could use "zig build-exe" and "zig test" directly in Makefile,
  or add "zig cc" and compile both C and Zig version of library etc.
  In this patchset it is also used by dev-lang/zig to convert targets
  during bootstrapping, and other logic is suppressed.
* zig-build.eclass: handles working with "zig build" sub-command and build.zig 
files.
  This eclass is more high-level and for most ebuilds it's the only
  one which needs to be inherited. It sets default functions for
  ebuild phases, deals with dependencies in package manager, allows
  ebuilds and end users to configure used flags, respects multi-threading
  and verboseness preferences, has some small support for cross-compilation
  and so on.

Github PR and discussion here: https://github.com/gentoo/gentoo/pull/37283 .
I have also wrote small generator for Zig ebuild skeletons here:
https://github.com/BratishkaErik/zig-ebuild . Example output in that PR.
It requires dev-lang/zig: to compile, but at runtime it works
with any version supported by eclass (currently 0.13 and ).

In "v2" revision, including suggestions on mailing list:
 * Move EAPI check after inherit guard
 * Change BDEPEND from "+=" to "=" and remove initial space here,
 * Keep length below 80 characters, and add 2 spaces after full stop,
 * Align lines in switch cases (according to Neovim, on nano I had
   not noticed it before),
 * Add "die -n" to ezig(),
 * Move and rewrite TODO comments in zig-build_start_base_args to be
   shorter and move less relevant information to patch itself.

...and GitHub. Also remove old leftovers of Zig 0.12 compatibility.

Eric Joldasov (5):
  zig-toolchain.eclass: new eclass
  zig-build.eclass: new eclass
  dev-lang/zig: add 0.13.0-r1
  dev-lang/zig: sync  with 0.13.0-r1
  sys-fs/ncdu: add 2.6-r1

 .../zig-0.13.0-skip-test-stack_iterator.patch |  32 +
 dev-lang/zig/zig-0.13.0-r1.ebuild | 245 
 dev-lang/zig/zig-.ebuild  | 244 
 eclass/zig-build.eclass   | 580 ++
 eclass/zig-toolchain.eclass   | 375 +++
 sys-fs/ncdu/ncdu-2.6-r1.ebuild|  50 ++
 6 files changed, 1407 insertions(+), 119 deletions(-)
 create mode 100644 dev-lang/zig/files/zig-0.13.0-skip-test-stack_iterator.patch
 create mode 100644 dev-lang/zig/zig-0.13.0-r1.ebuild
 create mode 100644 eclass/zig-build.eclass
 create mode 100644 eclass/zig-toolchain.eclass
 create mode 100644 sys-fs/ncdu/ncdu-2.6-r1.ebuild

Interdiff:
diff --git a/eclass/zig-build.eclass b/eclass/zig-build.eclass
index b1fc89e38d9d..ffa075043cde 100644
--- a/eclass/zig-build.eclass
+++ b/eclass/zig-build.eclass
@@ -1,572 +1,580 @@
 # Copyright 2024 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 # @ECLASS: zig-build.eclass
 # @MAINTAINER:
 # Eric Joldasov 
 # @AUTHOR:
 # Alfred Wingate 
 # Violet Purcell 
 # Eric Joldasov 
 # @SUPPORTED_EAPIS: 8
 # @PROVIDES: zig-toolchain
-# @BLURB: Functions for working with ZBS (Zig Build System).
+# @BLURB: Functions for working with ZBS (Zig Build System)
 # @DESCRIPTION:
-# Functions for working with Zig build system and package manager.
-# Supports Zig 0.13+. Exports default functions for convenience.
+# Functions for working with Zig build system and package manager.  
+# Supports Zig 0.13+.  Exports default functions for convenience.  
 #
 # Note that zig-build.eclass is mostly tailored for projects that:
 # 1) Install something in build.zig steps: "artifacts" (executable,
-# libraries, objects), source codes, assets, tests, scripts etc. But many 
authors
-# also use it to write Zig "modules", build logic and/or bindings/wrappers
-# for C/C++ libraries. They install nothing and are only used at build-time,
-# so it's unneccessary and mostly useless to make ebuilds for them.
-# 2) Have required `target`, `cpu` and optional `optimize` options
-# in build.zig that accept standard Zig-style target and optimize mode.
-# They are usually created by `standardTargetOptions` and 
`standardOptimizeOption`.
+# libraries, objects), source codes, assets, tests, scripts etc.   But
+# many authors also use it to write Zig "modules", build logic
+# and/or bindings/wrappers for C/C++ libraries.  They install nothing
+# and are only used at build-

[gentoo-dev] [PATCH 4/5] dev-lang/zig: sync 9999 with 0.13.0-r1

2024-10-25 Thread Eric Joldasov
From: Eric Joldasov 

* Update to use zig-build and zig-toolchain functions instead of
  local get_zig_mcpu etc. functions.
* Port "sys-apps/sandbox-2.39" test dependency requirement from
  0.13.0 ebuild.
* Stage3 compilation is unified by combining build.zig options,
  now both cmake (+llvm) and bootstrap.c (-llvm) build up to "zig2"
  target, after that we use zig-build.eclass with common options.
* Before migrating to the zig-build.eclass, test steps in src_test
  have been ran sequentially in for-loop, which allowed logic inside
  each step to ran parallelly but not several steps at a time. Now we use
  upstream "test" step instead of separately calling all dependant
  steps, so that build system can now ran all of them paralelly.
  This means time spent in src_test is now significantly shorter.
* "zig2" in both scenarios now has explicit target which is set by
  using zig-toolchain functions on a CBUILD/CHOST. This allows us
  to skip convertion logic in CMake and bootstrap.c, so that instead
  of patching them we can just update converter in zig-toolchain.eclass
  and unify target behaviour.
* Disable autodocs generation for "std" module, since it can now
  be generated on-fly with "zig std" command.

Signed-off-by: Eric Joldasov 
---
 dev-lang/zig/zig-.ebuild | 244 ++-
 1 file changed, 125 insertions(+), 119 deletions(-)

diff --git a/dev-lang/zig/zig-.ebuild b/dev-lang/zig/zig-.ebuild
index 335ac0eab28c..65650ac5c781 100644
--- a/dev-lang/zig/zig-.ebuild
+++ b/dev-lang/zig/zig-.ebuild
@@ -1,234 +1,240 @@
 # Copyright 2019-2024 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=8
 
 LLVM_COMPAT=( 19 )
 LLVM_OPTIONAL=1
 
-inherit check-reqs cmake edo llvm-r1 toolchain-funcs
+ZIG_SLOT="$(ver_cut 1-2)"
+ZIG_OPTIONAL=1
+
+inherit check-reqs cmake flag-o-matic edo llvm-r1 toolchain-funcs zig-build
 
 DESCRIPTION="A robust, optimal, and maintainable programming language"
-HOMEPAGE="https://ziglang.org/";
+HOMEPAGE="https://ziglang.org/ https://github.com/ziglang/zig/";
 if [[ ${PV} ==  ]]; then
EGIT_REPO_URI="https://github.com/ziglang/zig.git";
inherit git-r3
 else
VERIFY_SIG_METHOD=minisig

VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/minisig-keys/zig-software-foundation.pub
inherit verify-sig
 
SRC_URI="
https://ziglang.org/download/${PV}/${P}.tar.xz
verify-sig? ( 
https://ziglang.org/download/${PV}/${P}.tar.xz.minisig )
"
KEYWORDS="~amd64 ~arm ~arm64"
 
BDEPEND="verify-sig? ( sec-keys/minisig-keys-zig-software-foundation )"
 fi
 
 # project itself: MIT
 # There are bunch of projects under "lib/" folder that are needed for 
cross-compilation.
 # Files that are unnecessary for cross-compilation are removed by upstream
 # and therefore their licenses (if any special) are not included.
 # lib/libunwind: Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT )
 # lib/libcxxabi: Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT )
 # lib/libcxx: Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT )
 # lib/libc/wasi: || ( Apache-2.0-with-LLVM-exceptions Apache-2.0 MIT BSD-2 ) 
public-domain
 # lib/libc/musl: MIT BSD-2
 # lib/libc/mingw: ZPL public-domain BSD-2 ISC HPND
 # lib/libc/glibc: BSD HPND ISC inner-net LGPL-2.1+
 LICENSE="MIT Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT ) || ( 
Apache-2.0-with-LLVM-exceptions Apache-2.0 MIT BSD-2 ) public-domain BSD-2 ZPL 
ISC HPND BSD inner-net LGPL-2.1+"
-SLOT="$(ver_cut 1-2)"
-IUSE="doc +llvm"
+SLOT="${ZIG_SLOT}"
+IUSE="doc +llvm test"
+RESTRICT="!test? ( test )"
 REQUIRED_USE="
!llvm? ( !doc )
llvm? ( ${LLVM_REQUIRED_USE} )
 "
 
-BUILD_DIR="${S}/build"
+# Used by both cmake and zig-build eclass.
+BUILD_DIR="${WORKDIR}/${P}_build"
 
 # Zig requires zstd and zlib compression support in LLVM, if using LLVM 
backend.
 # (non-LLVM backends don't require these)
 # They are not required "on their own", so please don't add them here.
 # You can check https://github.com/ziglang/zig-bootstrap in future, to see
 # options that are passed to LLVM CMake building (excluding "static" ofc).
 DEPEND="
llvm? (
$(llvm_gen_dep '
sys-devel/clang:${LLVM_SLOT}
sys-devel/lld:${LLVM_SLOT}
sys-devel/llvm:${LLVM_SLOT}[zstd]
')
)
 "
-
-RDEPEND="
+BDEPEND+="
+   test? ( !!https://github.com/ziglang/zig/issues/3382
-# For now, Zig Build System doesn't support enviromental CFLAGS/LDFLAGS/etc.
-QA_FLAGS_IGNORED="usr/.*/zig/${PV}/bin/zig"
+DOCS=("README.md" "doc/build.zig.zon.md")
 
-RESTRICT="!llvm? ( test )"
+# zig-build does not set this for us since we use ZIG_OPTIONAL=1
+QA_FLAGS_IGNORED="usr/.*/zig/${PV}/bin/zig"
 
 # Since commit 
https://github.com/ziglang/zig/commit/e7d28344fa3ee81d6ad7ca5ce1f83d50d8502118
 # Zig uses self-hosted compiler only
 CHECKREQS_MEMORY=

[gentoo-dev] [PATCH v2 1/5] zig-toolchain.eclass: new eclass

2024-10-25 Thread Eric Joldasov
Signed-off-by: Eric Joldasov 
---
 eclass/zig-toolchain.eclass | 375 
 1 file changed, 375 insertions(+)
 create mode 100644 eclass/zig-toolchain.eclass

diff --git a/eclass/zig-toolchain.eclass b/eclass/zig-toolchain.eclass
new file mode 100644
index ..42a3f8ec3706
--- /dev/null
+++ b/eclass/zig-toolchain.eclass
@@ -0,0 +1,375 @@
+# Copyright 2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: zig-toolchain.eclass
+# @MAINTAINER:
+# Eric Joldasov 
+# @AUTHOR:
+# Eric Joldasov 
+# @SUPPORTED_EAPIS: 8
+# @BLURB: Prepare Zig toolchain and set environment variables
+# @DESCRIPTION:
+# Prepare Zig toolchain and set environment variables.
+# Supports Zig 0.13+.
+# Does not set any default function, ebuilds must call them manually.
+# Generally, only "zig-toolchain_populate_env_vars" is needed.
+#
+# Intended to be used by ebuilds that call "zig build-exe/lib/obj"
+# or "zig test" directly and by "dev-lang/zig".
+# For ebuilds with ZBS (Zig Build System), it's usually better
+# to inherit zig-build instead, as it has default phases-functions.
+
+if [[ ! ${_ZIG_TOOLCHAIN_ECLASS} ]]; then
+_ZIG_TOOLCHAIN_ECLASS=1
+
+case ${EAPI} in
+   8) ;;
+   *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
+esac
+
+inherit edo flag-o-matic
+
+# @ECLASS_VARIABLE: ZIG_SLOT
+# @PRE_INHERIT
+# @REQUIRED
+# @DESCRIPTION:
+# Zig slot that will be used in "ezig" function.  Also, if
+# ZIG_OPTIONAL is empty, adds dev-lang/zig and dev-lang/zig-bin
+# dependency to BDEPEND.  Must be >= "0.13".
+#
+# Example:
+# @CODE
+# 0.13
+# @CODE
+#
+# When a new Zig release occurs, it is advisable for maintainers to
+# check whether their ebuild supports that new version.  If yes, they
+# they should bump ZIG_SLOT to the latest version; if not supported,
+# they need to patch any issues with new version and again bump
+# ZIG_SLOT.  This helps to reduce dependencies on outdated Zig
+# versions.
+#
+# This policy of "1 exclusive Zig slot" will work until it
+# stabilizes enough (probably near 1.0), then it will be re-evaluated
+# and most likely changed to more common in other eclasses ZIG_MIN/
+# ZIG_MAX form.
+
+# @ECLASS_VARIABLE: ZIG_OPTIONAL
+# @PRE_INHERIT
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# If set to a non-empty value, all logic in zig-toolchain and
+# zig-build eclasses will be considered optional.  No dependencies
+# will be added and no phase functions will be exported.
+#
+# For zig-toolchain.eclass users:
+# You have to add Zig dependency in your BDEPEND manually and call
+# at least "zig-toolchain_populate_env_vars" before using "ezig".
+#
+# For zig-build.eclass users: see documentation in zig-build.eclass
+# instead.
+if [[ ! ${ZIG_OPTIONAL} ]]; then
+   BDEPEND="|| (
+   dev-lang/zig:${ZIG_SLOT}
+   dev-lang/zig-bin:${ZIG_SLOT}
+   )"
+fi
+
+# @ECLASS_VARIABLE: ZIG_TARGET
+# @DESCRIPTION:
+# Zig target triple to use.  Has the following format:
+# arch-os[.os_version_range]-abi[.abi_version]
+# Can be passed as:
+# * "-target " option in "zig test" or "zig build-exe/lib/obj",
+# * "-Dtarget=" option in "zig build"
+#   (if project uses "std.Build.standardTargetOptions").
+#
+# Can be overriden by user.  If not overriden, then set by
+# "zig-toolchain_populate_env_vars".
+#
+# Example:
+# @CODE
+# # Autodetected by Zig:
+# native
+# # Machine running Linux x86_64 system, with glibc:
+# x86_64-linux-gnu
+# # Similar to above, but versions are passed explicitly:
+# x86_64-linux.6.1.12...6.6.16-gnu.2.38
+# # Machine running Linux PPC64 little-endian system, with musl
+# powerpc64le-linux-musl
+# @CODE
+#
+
+# @ECLASS_VARIABLE: ZIG_CPU
+# @DESCRIPTION:
+# Zig target CPU and features to use.  Has the following format:
+# family_name(\+enable_feature|\-disable_feature)*
+# Can be passed as:
+# * "-mcpu " option in "zig test" or "zig build-exe/lib/obj",
+# * "-Dcpu=" option in "zig build"
+#   (if project uses "std.Build.standardTargetOptions").
+#
+# Can be overriden by user.  If not overriden, then set by
+# "zig-toolchain_populate_env_vars".
+#
+# Example:
+# @CODE
+# # Autodetected by Zig:
+# native
+# # AMD Zen 2 processor
+# znver2
+# # x86_64 processor, X87 support enabled, SSE2 support disabled
+# x86_64+x87-sse2
+# @CODE
+
+# @ECLASS_VARIABLE: ZIG_EXE
+# @DESCRIPTION:
+# Absolute path to the used Zig executable.
+#
+# Please note that when passing one flag several times with different
+# values:
+# * (only "zig build") in "-Dbar=false -Dbar" form:
+#   errors due to conflict of flags,
+# * (only "zig build") in "-Dbar=false -Dbar=true" form:
+#   "bar" becomes a list, which is likely not what you want,
+# * in "-fbar -fno-bar" form:
+#   latest value overwrites values before.
+# Example above shows only boolean option, but it is same with other
+# types of options (enums, "std.zig.BuildId", "std.SemanticVersion",
+# integers, strings, etc.).
+#
+# Can be overriden by user.  If not overriden, t

[gentoo-dev] [PATCH v2 4/5] dev-lang/zig: sync 9999 with 0.13.0-r1

2024-10-25 Thread Eric Joldasov
From: Eric Joldasov 

* Update to use zig-build and zig-toolchain functions instead of
  local get_zig_mcpu etc. functions.
* Port "sys-apps/sandbox-2.39" test dependency requirement from
  0.13.0 ebuild.
* Stage3 compilation is unified by combining build.zig options,
  now both cmake (+llvm) and bootstrap.c (-llvm) build up to "zig2"
  target, after that we use zig-build.eclass with common options.
* Before migrating to the zig-build.eclass, test steps in src_test
  have been ran sequentially in for-loop, which allowed logic inside
  each step to ran parallelly but not several steps at a time. Now we use
  upstream "test" step instead of separately calling all dependant
  steps, so that build system can now ran all of them paralelly.
  This means time spent in src_test is now significantly shorter.
* "zig2" in both scenarios now has explicit target which is set by
  using zig-toolchain functions on a CBUILD/CHOST. This allows us
  to skip convertion logic in CMake and bootstrap.c, so that instead
  of patching them we can just update converter in zig-toolchain.eclass
  and unify target behaviour.
* Disable autodocs generation for "std" module, since it can now
  be generated on-fly with "zig std" command.

Signed-off-by: Eric Joldasov 
---
 dev-lang/zig/zig-.ebuild | 244 ++-
 1 file changed, 125 insertions(+), 119 deletions(-)

diff --git a/dev-lang/zig/zig-.ebuild b/dev-lang/zig/zig-.ebuild
index 335ac0eab28c..65650ac5c781 100644
--- a/dev-lang/zig/zig-.ebuild
+++ b/dev-lang/zig/zig-.ebuild
@@ -1,234 +1,240 @@
 # Copyright 2019-2024 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=8
 
 LLVM_COMPAT=( 19 )
 LLVM_OPTIONAL=1
 
-inherit check-reqs cmake edo llvm-r1 toolchain-funcs
+ZIG_SLOT="$(ver_cut 1-2)"
+ZIG_OPTIONAL=1
+
+inherit check-reqs cmake flag-o-matic edo llvm-r1 toolchain-funcs zig-build
 
 DESCRIPTION="A robust, optimal, and maintainable programming language"
-HOMEPAGE="https://ziglang.org/";
+HOMEPAGE="https://ziglang.org/ https://github.com/ziglang/zig/";
 if [[ ${PV} ==  ]]; then
EGIT_REPO_URI="https://github.com/ziglang/zig.git";
inherit git-r3
 else
VERIFY_SIG_METHOD=minisig

VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/minisig-keys/zig-software-foundation.pub
inherit verify-sig
 
SRC_URI="
https://ziglang.org/download/${PV}/${P}.tar.xz
verify-sig? ( 
https://ziglang.org/download/${PV}/${P}.tar.xz.minisig )
"
KEYWORDS="~amd64 ~arm ~arm64"
 
BDEPEND="verify-sig? ( sec-keys/minisig-keys-zig-software-foundation )"
 fi
 
 # project itself: MIT
 # There are bunch of projects under "lib/" folder that are needed for 
cross-compilation.
 # Files that are unnecessary for cross-compilation are removed by upstream
 # and therefore their licenses (if any special) are not included.
 # lib/libunwind: Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT )
 # lib/libcxxabi: Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT )
 # lib/libcxx: Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT )
 # lib/libc/wasi: || ( Apache-2.0-with-LLVM-exceptions Apache-2.0 MIT BSD-2 ) 
public-domain
 # lib/libc/musl: MIT BSD-2
 # lib/libc/mingw: ZPL public-domain BSD-2 ISC HPND
 # lib/libc/glibc: BSD HPND ISC inner-net LGPL-2.1+
 LICENSE="MIT Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT ) || ( 
Apache-2.0-with-LLVM-exceptions Apache-2.0 MIT BSD-2 ) public-domain BSD-2 ZPL 
ISC HPND BSD inner-net LGPL-2.1+"
-SLOT="$(ver_cut 1-2)"
-IUSE="doc +llvm"
+SLOT="${ZIG_SLOT}"
+IUSE="doc +llvm test"
+RESTRICT="!test? ( test )"
 REQUIRED_USE="
!llvm? ( !doc )
llvm? ( ${LLVM_REQUIRED_USE} )
 "
 
-BUILD_DIR="${S}/build"
+# Used by both cmake and zig-build eclass.
+BUILD_DIR="${WORKDIR}/${P}_build"
 
 # Zig requires zstd and zlib compression support in LLVM, if using LLVM 
backend.
 # (non-LLVM backends don't require these)
 # They are not required "on their own", so please don't add them here.
 # You can check https://github.com/ziglang/zig-bootstrap in future, to see
 # options that are passed to LLVM CMake building (excluding "static" ofc).
 DEPEND="
llvm? (
$(llvm_gen_dep '
sys-devel/clang:${LLVM_SLOT}
sys-devel/lld:${LLVM_SLOT}
sys-devel/llvm:${LLVM_SLOT}[zstd]
')
)
 "
-
-RDEPEND="
+BDEPEND+="
+   test? ( !!https://github.com/ziglang/zig/issues/3382
-# For now, Zig Build System doesn't support enviromental CFLAGS/LDFLAGS/etc.
-QA_FLAGS_IGNORED="usr/.*/zig/${PV}/bin/zig"
+DOCS=("README.md" "doc/build.zig.zon.md")
 
-RESTRICT="!llvm? ( test )"
+# zig-build does not set this for us since we use ZIG_OPTIONAL=1
+QA_FLAGS_IGNORED="usr/.*/zig/${PV}/bin/zig"
 
 # Since commit 
https://github.com/ziglang/zig/commit/e7d28344fa3ee81d6ad7ca5ce1f83d50d8502118
 # Zig uses self-hosted compiler only
 CHECKREQS_MEMORY=

[gentoo-dev] [PATCH v2 3/5] dev-lang/zig: add 0.13.0-r1

2024-10-25 Thread Eric Joldasov
From: Eric Joldasov 

* Update to use llvm-r1 eclass instead of llvm, zig-build and
  zig-toolchain functions instead of local get_zig_mcpu etc. functions.
* Port "llvm USE-flag" and "removing memory limit flags" from 
  ebuild.
* Stage3 compilation is unified by combining build.zig options,
  now both cmake (+llvm) and bootstrap.c (-llvm) build up to "zig2"
  target, after that we use zig-build.eclass with common options.
* Before migrating to the zig-build.eclass, test steps in src_test
  have been ran sequentially in for-loop, which allowed logic inside
  each step to ran parallelly but not several steps at a time. Now we use
  upstream "test" step instead of separately calling all dependant
  steps, so that build system can now ran all of them paralelly.
  This means time spent in src_test is now significantly shorter.
* "zig2" in both scenarios now has explicit target which is set by
  using zig-toolchain functions on a CBUILD/CHOST. This allows us
  to skip convertion logic in CMake and bootstrap.c, so that instead
  of patching them we can just update converter in zig-toolchain.eclass
  and unify target behaviour.
* Disable autodocs generation for "std" module, since it can now
  be generated on-fly with "zig std" command.

Signed-off-by: Eric Joldasov 
---
 .../zig-0.13.0-skip-test-stack_iterator.patch |  32 +++
 dev-lang/zig/zig-0.13.0-r1.ebuild | 245 ++
 2 files changed, 277 insertions(+)
 create mode 100644 dev-lang/zig/files/zig-0.13.0-skip-test-stack_iterator.patch
 create mode 100644 dev-lang/zig/zig-0.13.0-r1.ebuild

diff --git a/dev-lang/zig/files/zig-0.13.0-skip-test-stack_iterator.patch 
b/dev-lang/zig/files/zig-0.13.0-skip-test-stack_iterator.patch
new file mode 100644
index ..e088af2102ed
--- /dev/null
+++ b/dev-lang/zig/files/zig-0.13.0-skip-test-stack_iterator.patch
@@ -0,0 +1,32 @@
+From: Eric Joldasov 
+
+Skip standalone test "stack_iterator" that fail on Gentoo Linux x86_64.
+Fails in ReleaseSafe, ReleaseFast and ReleaseSmall, but not in Debug.
+Reported to upstream here https://github.com/ziglang/zig/issues/19944 .
+
+Signed-off-by: Eric Joldasov 
+
+diff --git a/test/standalone/stack_iterator/shared_lib_unwind.zig 
b/test/standalone/stack_iterator/shared_lib_unwind.zig
+index 57513a49c6..75fddb04c9 100644
+--- a/test/standalone/stack_iterator/shared_lib_unwind.zig
 b/test/standalone/stack_iterator/shared_lib_unwind.zig
+@@ -35,6 +35,7 @@ extern fn frame0(
+ ) void;
+
+ pub fn main() !void {
++if (true) return;
+ // Disabled until the DWARF unwinder bugs on .aarch64 are solved
+ if (builtin.omit_frame_pointer and comptime builtin.target.isDarwin() and 
builtin.cpu.arch == .aarch64) return;
+
+diff --git a/test/standalone/stack_iterator/unwind.zig 
b/test/standalone/stack_iterator/unwind.zig
+index 69c463a0c1..40963af63d 100644
+--- a/test/standalone/stack_iterator/unwind.zig
 b/test/standalone/stack_iterator/unwind.zig
+@@ -87,6 +87,7 @@ noinline fn frame0(expected: *[4]usize, unwound: *[4]usize) 
void {
+ }
+
+ pub fn main() !void {
++if (true) return;
+ // Disabled until the DWARF unwinder bugs on .aarch64 are solved
+ if (builtin.omit_frame_pointer and comptime builtin.target.isDarwin() and 
builtin.cpu.arch == .aarch64) return;
+
diff --git a/dev-lang/zig/zig-0.13.0-r1.ebuild 
b/dev-lang/zig/zig-0.13.0-r1.ebuild
new file mode 100644
index ..5cca5e3efad6
--- /dev/null
+++ b/dev-lang/zig/zig-0.13.0-r1.ebuild
@@ -0,0 +1,245 @@
+# Copyright 2019-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+LLVM_COMPAT=( 18 )
+LLVM_OPTIONAL=1
+
+ZIG_SLOT="$(ver_cut 1-2)"
+ZIG_OPTIONAL=1
+
+inherit check-reqs cmake flag-o-matic edo llvm-r1 toolchain-funcs zig-build
+
+DESCRIPTION="A robust, optimal, and maintainable programming language"
+HOMEPAGE="https://ziglang.org/ https://github.com/ziglang/zig/";
+if [[ ${PV} ==  ]]; then
+   EGIT_REPO_URI="https://github.com/ziglang/zig.git";
+   inherit git-r3
+else
+   VERIFY_SIG_METHOD=minisig
+   
VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/minisig-keys/zig-software-foundation.pub
+   inherit verify-sig
+
+   SRC_URI="
+   https://ziglang.org/download/${PV}/${P}.tar.xz
+   verify-sig? ( 
https://ziglang.org/download/${PV}/${P}.tar.xz.minisig )
+   "
+   KEYWORDS="~amd64 ~arm ~arm64"
+
+   BDEPEND="verify-sig? ( sec-keys/minisig-keys-zig-software-foundation )"
+fi
+
+# project itself: MIT
+# There are bunch of projects under "lib/" folder that are needed for 
cross-compilation.
+# Files that are unnecessary for cross-compilation are removed by upstream
+# and therefore their licenses (if any special) are not included.
+# lib/libunwind: Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT )
+# lib/libcxxabi: Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT )
+# lib/libcxx: Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT )
+# lib/libc/wasi: || ( Apache-2.0-wi

[gentoo-dev] [PATCH v2 0/5] Ziglang eclasses for 0.13+

2024-10-25 Thread Eric Joldasov
Hello everyone,

This patch series adds new eclasses for packages that use Zig
toolchain with varying level of integration. Since some projects
or ebuilds use only Zig compiler directly, without touching Zig Build
System, I have decided to split eclasses into 2:

* zig-toolchain.eclass: handles dependency on Zig toolchain and
  finds appropriate versions/slots, converts C-style target tuples/triples
  to Zig format and sets environment variables to be used in other
  eclasses and ebuilds. This eclass is more low-level and intended
  to be used by programs and libraries that call "zig" commands directly,
  without having build.zig file and using "zig build" command. For example,
  authors could use "zig build-exe" and "zig test" directly in Makefile,
  or add "zig cc" and compile both C and Zig version of library etc.
  In this patchset it is also used by dev-lang/zig to convert targets
  during bootstrapping, and other logic is suppressed.
* zig-build.eclass: handles working with "zig build" sub-command and build.zig 
files.
  This eclass is more high-level and for most ebuilds it's the only
  one which needs to be inherited. It sets default functions for
  ebuild phases, deals with dependencies in package manager, allows
  ebuilds and end users to configure used flags, respects multi-threading
  and verboseness preferences, has some small support for cross-compilation
  and so on.

Github PR and discussion here: https://github.com/gentoo/gentoo/pull/37283 .
I have also wrote small generator for Zig ebuild skeletons here:
https://github.com/BratishkaErik/zig-ebuild . Example output in that PR.
It requires dev-lang/zig: to compile, but at runtime it works
with any version supported by eclass (currently 0.13 and ).

In "v2" revision, including suggestions on mailing list:
 * Move EAPI check after inherit guard
 * Change BDEPEND from "+=" to "=" and remove initial space here,
 * Keep length below 80 characters, and add 2 spaces after full stop,
 * Align lines in switch cases (according to Neovim, on nano I had
   not noticed it before),
 * Add "die -n" to ezig(),
 * Move and rewrite TODO comments in zig-build_start_base_args to be
   shorter and move less relevant information to patch itself.

...and GitHub. Also remove old leftovers of Zig 0.12 compatibility.

Eric Joldasov (5):
  zig-toolchain.eclass: new eclass
  zig-build.eclass: new eclass
  dev-lang/zig: add 0.13.0-r1
  dev-lang/zig: sync  with 0.13.0-r1
  sys-fs/ncdu: add 2.6-r1

 .../zig-0.13.0-skip-test-stack_iterator.patch |  32 +
 dev-lang/zig/zig-0.13.0-r1.ebuild | 245 
 dev-lang/zig/zig-.ebuild  | 244 
 eclass/zig-build.eclass   | 580 ++
 eclass/zig-toolchain.eclass   | 375 +++
 sys-fs/ncdu/ncdu-2.6-r1.ebuild|  50 ++
 6 files changed, 1407 insertions(+), 119 deletions(-)
 create mode 100644 dev-lang/zig/files/zig-0.13.0-skip-test-stack_iterator.patch
 create mode 100644 dev-lang/zig/zig-0.13.0-r1.ebuild
 create mode 100644 eclass/zig-build.eclass
 create mode 100644 eclass/zig-toolchain.eclass
 create mode 100644 sys-fs/ncdu/ncdu-2.6-r1.ebuild

Interdiff against v1:
diff --git a/eclass/zig-build.eclass b/eclass/zig-build.eclass
index b1fc89e38d9d..ffa075043cde 100644
--- a/eclass/zig-build.eclass
+++ b/eclass/zig-build.eclass
@@ -1,572 +1,580 @@
 # Copyright 2024 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 # @ECLASS: zig-build.eclass
 # @MAINTAINER:
 # Eric Joldasov 
 # @AUTHOR:
 # Alfred Wingate 
 # Violet Purcell 
 # Eric Joldasov 
 # @SUPPORTED_EAPIS: 8
 # @PROVIDES: zig-toolchain
-# @BLURB: Functions for working with ZBS (Zig Build System).
+# @BLURB: Functions for working with ZBS (Zig Build System)
 # @DESCRIPTION:
-# Functions for working with Zig build system and package manager.
-# Supports Zig 0.13+. Exports default functions for convenience.
+# Functions for working with Zig build system and package manager.  
+# Supports Zig 0.13+.  Exports default functions for convenience.  
 #
 # Note that zig-build.eclass is mostly tailored for projects that:
 # 1) Install something in build.zig steps: "artifacts" (executable,
-# libraries, objects), source codes, assets, tests, scripts etc. But many 
authors
-# also use it to write Zig "modules", build logic and/or bindings/wrappers
-# for C/C++ libraries. They install nothing and are only used at build-time,
-# so it's unneccessary and mostly useless to make ebuilds for them.
-# 2) Have required `target`, `cpu` and optional `optimize` options
-# in build.zig that accept standard Zig-style target and optimize mode.
-# They are usually created by `standardTargetOptions` and 
`standardOptimizeOption`.
+# libraries, objects), source codes, assets, tests, scripts etc.   But
+# many authors also use it to write Zig "modules", build logic
+# and/or bindings/wrappers for C/C++ libraries.  They install nothing
+# and are only use

[gentoo-dev] [PATCH 3/5] dev-lang/zig: add 0.13.0-r1

2024-10-25 Thread Eric Joldasov
From: Eric Joldasov 

* Update to use llvm-r1 eclass instead of llvm, zig-build and
  zig-toolchain functions instead of local get_zig_mcpu etc. functions.
* Port "llvm USE-flag" and "removing memory limit flags" from 
  ebuild.
* Stage3 compilation is unified by combining build.zig options,
  now both cmake (+llvm) and bootstrap.c (-llvm) build up to "zig2"
  target, after that we use zig-build.eclass with common options.
* Before migrating to the zig-build.eclass, test steps in src_test
  have been ran sequentially in for-loop, which allowed logic inside
  each step to ran parallelly but not several steps at a time. Now we use
  upstream "test" step instead of separately calling all dependant
  steps, so that build system can now ran all of them paralelly.
  This means time spent in src_test is now significantly shorter.
* "zig2" in both scenarios now has explicit target which is set by
  using zig-toolchain functions on a CBUILD/CHOST. This allows us
  to skip convertion logic in CMake and bootstrap.c, so that instead
  of patching them we can just update converter in zig-toolchain.eclass
  and unify target behaviour.
* Disable autodocs generation for "std" module, since it can now
  be generated on-fly with "zig std" command.

Signed-off-by: Eric Joldasov 
---
 .../zig-0.13.0-skip-test-stack_iterator.patch |  32 +++
 dev-lang/zig/zig-0.13.0-r1.ebuild | 245 ++
 2 files changed, 277 insertions(+)
 create mode 100644 dev-lang/zig/files/zig-0.13.0-skip-test-stack_iterator.patch
 create mode 100644 dev-lang/zig/zig-0.13.0-r1.ebuild

diff --git a/dev-lang/zig/files/zig-0.13.0-skip-test-stack_iterator.patch 
b/dev-lang/zig/files/zig-0.13.0-skip-test-stack_iterator.patch
new file mode 100644
index ..e088af2102ed
--- /dev/null
+++ b/dev-lang/zig/files/zig-0.13.0-skip-test-stack_iterator.patch
@@ -0,0 +1,32 @@
+From: Eric Joldasov 
+
+Skip standalone test "stack_iterator" that fail on Gentoo Linux x86_64.
+Fails in ReleaseSafe, ReleaseFast and ReleaseSmall, but not in Debug.
+Reported to upstream here https://github.com/ziglang/zig/issues/19944 .
+
+Signed-off-by: Eric Joldasov 
+
+diff --git a/test/standalone/stack_iterator/shared_lib_unwind.zig 
b/test/standalone/stack_iterator/shared_lib_unwind.zig
+index 57513a49c6..75fddb04c9 100644
+--- a/test/standalone/stack_iterator/shared_lib_unwind.zig
 b/test/standalone/stack_iterator/shared_lib_unwind.zig
+@@ -35,6 +35,7 @@ extern fn frame0(
+ ) void;
+
+ pub fn main() !void {
++if (true) return;
+ // Disabled until the DWARF unwinder bugs on .aarch64 are solved
+ if (builtin.omit_frame_pointer and comptime builtin.target.isDarwin() and 
builtin.cpu.arch == .aarch64) return;
+
+diff --git a/test/standalone/stack_iterator/unwind.zig 
b/test/standalone/stack_iterator/unwind.zig
+index 69c463a0c1..40963af63d 100644
+--- a/test/standalone/stack_iterator/unwind.zig
 b/test/standalone/stack_iterator/unwind.zig
+@@ -87,6 +87,7 @@ noinline fn frame0(expected: *[4]usize, unwound: *[4]usize) 
void {
+ }
+
+ pub fn main() !void {
++if (true) return;
+ // Disabled until the DWARF unwinder bugs on .aarch64 are solved
+ if (builtin.omit_frame_pointer and comptime builtin.target.isDarwin() and 
builtin.cpu.arch == .aarch64) return;
+
diff --git a/dev-lang/zig/zig-0.13.0-r1.ebuild 
b/dev-lang/zig/zig-0.13.0-r1.ebuild
new file mode 100644
index ..5cca5e3efad6
--- /dev/null
+++ b/dev-lang/zig/zig-0.13.0-r1.ebuild
@@ -0,0 +1,245 @@
+# Copyright 2019-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+LLVM_COMPAT=( 18 )
+LLVM_OPTIONAL=1
+
+ZIG_SLOT="$(ver_cut 1-2)"
+ZIG_OPTIONAL=1
+
+inherit check-reqs cmake flag-o-matic edo llvm-r1 toolchain-funcs zig-build
+
+DESCRIPTION="A robust, optimal, and maintainable programming language"
+HOMEPAGE="https://ziglang.org/ https://github.com/ziglang/zig/";
+if [[ ${PV} ==  ]]; then
+   EGIT_REPO_URI="https://github.com/ziglang/zig.git";
+   inherit git-r3
+else
+   VERIFY_SIG_METHOD=minisig
+   
VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/minisig-keys/zig-software-foundation.pub
+   inherit verify-sig
+
+   SRC_URI="
+   https://ziglang.org/download/${PV}/${P}.tar.xz
+   verify-sig? ( 
https://ziglang.org/download/${PV}/${P}.tar.xz.minisig )
+   "
+   KEYWORDS="~amd64 ~arm ~arm64"
+
+   BDEPEND="verify-sig? ( sec-keys/minisig-keys-zig-software-foundation )"
+fi
+
+# project itself: MIT
+# There are bunch of projects under "lib/" folder that are needed for 
cross-compilation.
+# Files that are unnecessary for cross-compilation are removed by upstream
+# and therefore their licenses (if any special) are not included.
+# lib/libunwind: Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT )
+# lib/libcxxabi: Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT )
+# lib/libcxx: Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT )
+# lib/libc/wasi: || ( Apache-2.0-wi

[gentoo-dev] [PATCH v2 5/5] sys-fs/ncdu: add 2.6-r1

2024-10-25 Thread Eric Joldasov
Now uses "zig-build" eclass.

Signed-off-by: Eric Joldasov 
---
 sys-fs/ncdu/ncdu-2.6-r1.ebuild | 50 ++
 1 file changed, 50 insertions(+)
 create mode 100644 sys-fs/ncdu/ncdu-2.6-r1.ebuild

diff --git a/sys-fs/ncdu/ncdu-2.6-r1.ebuild b/sys-fs/ncdu/ncdu-2.6-r1.ebuild
new file mode 100644
index ..6fb3c76328cc
--- /dev/null
+++ b/sys-fs/ncdu/ncdu-2.6-r1.ebuild
@@ -0,0 +1,50 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/openpgp-keys/yoranheling.asc
+# Upstream states 0.12.x and 0.13.x support,
+# but eclass supports only one slot.
+ZIG_SLOT="0.13"
+inherit verify-sig zig-build
+
+DESCRIPTION="NCurses Disk Usage"
+HOMEPAGE="https://dev.yorhel.nl/ncdu";
+SRC_URI="
+   https://dev.yorhel.nl/download/${P}.tar.gz
+   verify-sig? ( https://dev.yorhel.nl/download/${P}.tar.gz.asc )
+"
+
+LICENSE="MIT"
+SLOT="0"
+KEYWORDS="~amd64"
+
+BDEPEND="verify-sig? ( sec-keys/openpgp-keys-yorhel )"
+DEPEND="
+   app-arch/zstd
+   sys-libs/ncurses:=[unicode(+)]
+"
+RDEPEND="${DEPEND}"
+
+DOCS=("README.md" "ChangeLog")
+
+src_unpack() {
+   verify-sig_src_unpack
+}
+
+src_configure() {
+   local my_zbs_args=(
+   -Dpie=true
+   # Upstream recommends this default:
+   --release=fast
+   )
+
+   zig-build_src_configure
+}
+
+src_install() {
+   zig-build_src_install
+
+   doman ncdu.1
+}
-- 
2.47.0




Re: [gentoo-dev] [PATCH 1/2] eclass/dotnet-pkg-base: turn off DOTNET_NUGET_SIGNATURE_VERIFICATION

2024-10-25 Thread Sam James
x...@gentoo.org writes:

> From: Maciej Barć 
>
> Speeds up "dotnet restore". Especially can be noticed when running
> without network sandbox.
> Suggested by vimproved on IRC - thanks!
>
> See also: https://github.com/NuGet/Home/issues/13062
>
> Signed-off-by: Maciej Barć 

lgtm

> ---
>  eclass/dotnet-pkg-base.eclass | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/eclass/dotnet-pkg-base.eclass b/eclass/dotnet-pkg-base.eclass
> index 15e9ba703b..8cedde073b 100644
> --- a/eclass/dotnet-pkg-base.eclass
> +++ b/eclass/dotnet-pkg-base.eclass
> @@ -101,6 +101,9 @@ export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
>  export MSBUILDDISABLENODEREUSE=1
>  export POWERSHELL_TELEMETRY_OPTOUT=1
>  export POWERSHELL_UPDATECHECK=0
> +# Speeds up restore. Using this is redundant with Portage manifests.
> +# See also: https://github.com/NuGet/Home/issues/13062
> +export DOTNET_NUGET_SIGNATURE_VERIFICATION=false
>  # Overwrite selected MSBuild properties ("-p:XYZ").
>  export UseSharedCompilation=false