commit:     d512221f0d58d0d628a9598cf87d2182b1ac82fd
Author:     Sergey Torokhov <torokhov-s-a <AT> yandex <DOT> ru>
AuthorDate: Wed Dec 15 22:32:03 2021 +0000
Commit:     Sergey Torokhov <torokhov-s-a <AT> yandex <DOT> ru>
CommitDate: Wed Dec 15 22:32:03 2021 +0000
URL:        https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=d512221f

games-board/fairy-stockfish: 14.0.1 version bump

Add embed built-in NNUE support for Xiangqi and Janggi

Signed-off-by: Sergey Torokhov <torokhov-s-a <AT> yandex.ru>

 games-board/fairy-stockfish/Manifest               |   3 +
 .../fairy-stockfish/fairy-stockfish-14.0.1.ebuild  | 116 +++++++++++++++++++++
 games-board/fairy-stockfish/metadata.xml           |   3 +-
 3 files changed, 121 insertions(+), 1 deletion(-)

diff --git a/games-board/fairy-stockfish/Manifest 
b/games-board/fairy-stockfish/Manifest
index 031cae2a0..9f011abcb 100644
--- a/games-board/fairy-stockfish/Manifest
+++ b/games-board/fairy-stockfish/Manifest
@@ -1 +1,4 @@
 DIST fairy-stockfish-14.tar.gz 326041 BLAKE2B 
16c8f07e60a2df19d0c87c5acb2a5d0e9fe3ffcba5791ac36a33337a35eebaaa01296f86a9cfbecc2916744c73c3d3f6f4ae03f2ea74759bfa96cb92c32f30b4
 SHA512 
7b684009447ddc0083cf356b1859215c11817a81892d887c1e47d34b26da5338a2f12846fac804995a2d21903ccc74132870a71bec46644ac0a8bba453ba7666
+DIST fairy-stockfish-14.0.1.tar.gz 330996 BLAKE2B 
18bfe84edae242800f1e75d76d674012680972e44ba341ac429f90e39d075883fc66a808c2b85ed3c3a5aaabec2a290d0c0b2f47076b6cadc92519673ebcbfe9
 SHA512 
267837285c735ad7579233b6b6635c227b28727be1c63edb471b54b74f69330003aa3c6abf0667a0697868e8fd059c0ba23b3956ead269708abf61764bd33f3d
+DIST janggi-85de3dae670a.nnue 11261915 BLAKE2B 
97436ab482e4754cc7f13fea66dcacb2a6cf57876467b0756bc6360ed9bac281e4ec19b31abb0743973f4a5e01ac3b2f669bb973e667657b171582adfc79da24
 SHA512 
7aee208cb68952ef2fc1365de7c2dc5e2778af59f98a8adbf4d63225e6838133976b9d6c2cdf8ac5342f79259cf47ffc1a2e3e5a83747d77b804399da09e2604
+DIST xiangqi-83f16c17fe26.nnue 11261915 BLAKE2B 
3c77b4827331fdfa23bbc5d09d232e2d1c039dbd1fdbf4c22a1a78fa250f48f65d25fd01f222a7bd74e0da8b5b90be9a114f13fa6edcbee30b08420ce81530b9
 SHA512 
2111284ea97d5b08af0f444dd5d8a9277edc6f8b5feb3da36165de22f67cdba8c39172294cc5a5c308ac17bae50cf4c7ce1ed2a345a33ec29a39ee1ed37120fe

diff --git a/games-board/fairy-stockfish/fairy-stockfish-14.0.1.ebuild 
b/games-board/fairy-stockfish/fairy-stockfish-14.0.1.ebuild
new file mode 100644
index 000000000..09b8e5d5f
--- /dev/null
+++ b/games-board/fairy-stockfish/fairy-stockfish-14.0.1.ebuild
@@ -0,0 +1,116 @@
+# Copyright 1999-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit toolchain-funcs
+
+DESCRIPTION="Chess variant engine derived from Stockfish to support fairy 
chess variants"
+HOMEPAGE="https://github.com/ianfab/Fairy-Stockfish";
+
+MY_PV=$(ver_rs 1-2 _)
+
+SRC_URI="
+       
https://github.com/ianfab/Fairy-Stockfish/archive/fairy_sf_${MY_PV}_xq.tar.gz 
-> ${P}.tar.gz
+       nnue? (
+               
https://github.com/ianfab/Fairy-Stockfish/releases/download/fairy_sf_${MY_PV}_xq/janggi-85de3dae670a.nnue
+               
https://github.com/ianfab/Fairy-Stockfish/releases/download/fairy_sf_${MY_PV}_xq/xiangqi-83f16c17fe26.nnue
+       )
+"
+
+LICENSE="GPL-3"
+SLOT="0"
+KEYWORDS="~amd64 ~x86"
+IUSE="cpu_flags_arm_v7 cpu_flags_x86_avx2 cpu_flags_x86_popcnt 
cpu_flags_x86_sse debug
+       general-32 general-64 largeboards nnue test"
+
+# Require largeboards for nnue support as it also built-in .nnue files for 
Xiangqi and Janggi
+REQUIRED_USE="nnue? ( largeboards )"
+RESTRICT="!test? ( test )"
+
+DEPEND="
+       || ( app-arch/unzip app-arch/zip )
+       test? ( dev-tcltk/expect )
+"
+RDEPEND=""
+
+S="${WORKDIR}/Fairy-Stockfish-fairy_sf_${MY_PV}_xq/src"
+
+src_unpack() {
+       unpack ${P}.tar.gz
+       if use nnue ; then
+               cp "${DISTDIR}"/janggi-85de3dae670a.nnue "${S}/" || die
+               cp "${DISTDIR}"/xiangqi-83f16c17fe26.nnue "${S}/" || die
+       fi
+}
+
+src_prepare() {
+       default
+
+       local item
+       # Rename Stockfish to Fairy-Stockfish
+       sed -i -e 's:EXE = stockfish:EXE = fairy-stockfish:' Makefile || die
+               for item in ../tests/*.sh ; do
+                       sed -i -e 's:./stockfish:./fairy-stockfish:' $item || 
die
+               done
+       # protocol.sh test 'ucci.exp' fails for timeout 5 but pass with 15
+       sed -i -e 's:timeout 5:timeout 15:' ../tests/protocol.sh || die
+       # instrumented.sh syzygy test data tarball get differ size every time, 
drop it
+       sed -i -e '112,141d' ../tests/instrumented.sh || die
+
+       # prevent pre-stripping
+       sed -e 's:-strip $(BINDIR)/$(EXE)::' -i Makefile \
+               || die 'failed to disable stripping in the Makefile'
+}
+
+src_compile() {
+       local my_arch
+
+       # generic unoptimized first
+       use general-32 && my_arch=general-32
+       use general-64 && my_arch=general-64
+
+       # x86
+       use x86 && my_arch=x86-32-old
+       use cpu_flags_x86_sse && my_arch=x86-32
+
+       # amd64
+       use amd64 && my_arch=x86-64
+       use cpu_flags_x86_popcnt && my_arch=x86-64-modern
+
+       # both bmi2 and avx2 are part of hni (haswell new instructions)
+       use cpu_flags_x86_avx2 && my_arch=x86-64-bmi2
+
+       # other architectures
+       use cpu_flags_arm_v7 && my_arch=armv7
+       use ppc && my_arch=ppc
+       use ppc64 && my_arch=ppc64
+
+       # Skip the "build" target and use "all" instead to avoid the config
+       # sanity check (which would throw a fit about our compiler). There's
+       # a nice hack in the Makefile that overrides the value of CXX with
+       # COMPILER to support Travis CI and we abuse it to make sure that we
+       # build with our compiler of choice.
+       # Build all variants (add Amazons game) and disable default optimize 
(-O3/-ffast)
+       emake all ARCH="${my_arch}" \
+               COMP=$(tc-getCXX) \
+               COMPILER=$(tc-getCXX) \
+               all=yes \
+               debug=$(usex debug "yes" "no") \
+               largeboards=$(usex largeboards "yes" "no") \
+               nnue=$(usex nnue "yes" "no") \
+               optimize=no
+}
+
+src_test() {
+       ../tests/instrumented.sh || die
+       ../tests/perft.sh || die
+       ../tests/protocol.sh || die
+       ../tests/reprosearch.sh || die
+       ../tests/signature.sh || die
+}
+
+src_install() {
+       dobin "${PN}"
+       dodoc ../AUTHORS ../README.md
+}

diff --git a/games-board/fairy-stockfish/metadata.xml 
b/games-board/fairy-stockfish/metadata.xml
index 2537e2779..7e1faff62 100644
--- a/games-board/fairy-stockfish/metadata.xml
+++ b/games-board/fairy-stockfish/metadata.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd";>
+<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd";>
 <pkgmetadata>
        <maintainer type="person">
                <email>torokhov-...@yandex.ru</email>
@@ -9,6 +9,7 @@
                <flag name="general-32">Generic unoptimized 32-bits build</flag>
                <flag name="general-64">Generic unoptimized 64-bits build</flag>
                <flag name="largeboards">Support for board sizes more than 8x8 
(e.g., Xiangqi, Shogi). Engine is slower</flag>
+               <flag name="nnue">Embed and enable NNUE support (built-in for 
Xiangqi and Janggi, executable file is larger)</flag>
        </use>
        <upstream>
                <remote-id type="github">ianfab/Fairy-Stockfish</remote-id>

Reply via email to