• [gentoo-dev] [PATCH 1/5] ninja-utils.eclass: Support dev-util/samurai

    From Sam James@21:1/5 to All on Mon May 9 01:10:01 2022
    From: orbea <orbea@riseup.net>

    samurai is a ninja-compatible build tool written in C which
    works with cmake, meson and other users of ninja.

    It is feature-complete and supports most of the same options
    as ninja.

    Signed-off-by: orbea <orbea@riseup.net>
    Signed-off-by: Sam James <sam@gentoo.org>
    ---
    eclass/ninja-utils.eclass | 24 +++++++++++++++++++++++-
    1 file changed, 23 insertions(+), 1 deletion(-)

    diff --git a/eclass/ninja-utils.eclass b/eclass/ninja-utils.eclass
    index c5f34934192f..67f7a6b5e8a7 100644
    --- a/eclass/ninja-utils.eclass
    +++ b/eclass/ninja-utils.eclass
    @@ -26,6 +26,15 @@ esac
    if [[ -z ${_NINJA_UTILS_ECLASS} ]]; then
    _NINJA_UTILS_ECLASS=1

    +# @ECLASS_VARIABLE: NINJA
    +# @PRE_INHERIT
    +# @DEFAULT_UNSET
    +# @DESCRIPTION:
    +# Specify a compatible ninja implementation to be used by eninja.
    +# At this point only "ninja" and "samu" are supported.
    +# The default is set to "ninja".
    +: ${NINJA:=ninja}
    +
    # @ECLASS_VARIABLE: NINJAOPTS
    # @DEFAULT_UNSET
    # @DESCRIPTION:
    @@ -35,6 +44,19 @@ _NINJA_UTILS_ECLASS=1

    inherit multiprocessing

    +case "${NINJA}" in
    + ninja)
    + NINJA_DEPEND=">=dev-util/ninja-1.8.2"
    + ;;
    + samu)
    + NINJA_DEPEND="dev-util/samurai"
    + ;;
    + *)
    + eerror "Unknown value for \${NINJA}"
    + die "Value ${NINJA} is not supported"
    + ;;
    +esac
    +
  • From Sam James@21:1/5 to All on Mon May 9 01:10:01 2022
    From: orbea <orbea@riseup.net>

    Signed-off-by: orbea <orbea@riseup.net>
    Closes: https://github.com/gentoo/gentoo/pull/25272
    Signed-off-by: Sam James <sam@gentoo.org>
    ---
    sys-devel/clang/clang-12.0.1.ebuild | 2 +-
    sys-devel/clang/clang-13.0.1.ebuild | 2 +-
    sys-devel/clang/clang-14.0.1-r1.ebuild | 2 +-
    sys-devel/clang/clang-14.0.3.ebuild | 2 +-
    sys-devel/clang/clang-15.0.0.9999.ebuild | 2 +-
    5 files changed, 5 insertions(+), 5 deletions(-)

    diff --git a/sys-devel/clang/clang-12.0.1.ebuild b/sys-devel/clang/clang-12.0.1.ebuild
    index e4b38d294772..45e134c179c8 100644
    --- a/sys-devel/clang/clang-12.0.1.ebuild
    +++ b/sys-devel/clang/clang-12.0.1.ebuild
    @@ -130,7 +130,7 @@ check_distribution_components() {

    all_targets+=( "${l}" )
    fi
    - done < <(ninja -t targets all)
    + done < <(${NINJA} -t targets all)

    while read -r l; do
    my_targets+=( "${l}" )
    diff --git a/sys-devel/clang/clang-13.0.1.ebuild b/sys-devel/clang/clang-13.0.1.ebuild
    index 6f7c66ee8f02..0f9d5f0a2277 100644
    --- a/sys-devel/clang/clang-13.0.1.ebuild
    +++ b/sys-devel/clang/clang-13.0.1.ebuild
    @@ -118,7 +118,7 @@ check_distribution_components() {

    al
  • From Sam James@21:1/5 to All on Mon May 9 01:10:01 2022
    From: orbea <orbea@riseup.net>

    samurai is a ninja-compatible build tool written in C which
    works with cmake, meson and other users of ninja.

    It is feature-complete and supports most of the same options
    as ninja.

    Signed-off-by: orbea <orbea@riseup.net>
    Signed-off-by: Sam James <sam@gentoo.org>
    ---
    eclass/cmake.eclass | 13 +++++++++----
    1 file changed, 9 insertions(+), 4 deletions(-)

    diff --git a/eclass/cmake.eclass b/eclass/cmake.eclass
    index 59e5b60957c2..7ad0f6a7d45e 100644
    --- a/eclass/cmake.eclass
    +++ b/eclass/cmake.eclass
    @@ -136,7 +136,7 @@ case ${CMAKE_MAKEFILE_GENERATOR} in
    BDEPEND="sys-devel/make"
    ;;
    ninja)
    - BDEPEND="dev-util/ninja"
    + BDEPEND="${NINJA_DEPEND}"
    ;;
    *)
    eerror "Unknown value for \${CMAKE_MAKEFILE_GENERATOR}"
    @@ -365,7 +365,7 @@ cmake_src_prepare() {

    # if ninja is enabled but not installed, the build could fail
    # this could happen if ninja is manually enabled (eg. make.conf) but not installed
    - if [[ ${CMAKE_MAKEFILE_GENERATOR} == ninja ]] && ! has_version -b dev-util/ninja; then
    + if [[ ${CMAKE_MAKEFILE_GENERATOR} == ninja ]] && ! has_version -b "${NINJA_DEPEND}"; then
    eerror "CMAKE_MAKEFILE_GENERATOR is set to ninja, but ninja is not installed."
    die "Please install dev-util/ninja or unset CMAKE_MAKEFILE_GENERATOR."
    f
  • From =?UTF-8?Q?Micha=C5=82_G=C3=B3rny?=@21:1/5 to Sam James on Mon May 9 09:20:01 2022
    On Sun, 2022-05-08 at 23:07 +0000, Sam James wrote:
    From: orbea <orbea@riseup.net>

    samurai is a ninja-compatible build tool written in C which
    works with cmake, meson and other users of ninja.

    It is feature-complete and supports most of the same options
    as ninja.

    Signed-off-by: orbea <orbea@riseup.net>
    Signed-off-by: Sam James <sam@gentoo.org>
    ---
    eclass/cmake.eclass | 13 +++++++++----
    1 file changed, 9 insertions(+), 4 deletions(-)

    diff --git a/eclass/cmake.eclass b/eclass/cmake.eclass
    index 59e5b60957c2..7ad0f6a7d45e 100644
    --- a/eclass/cmake.eclass
    +++ b/eclass/cmake.eclass
    @@ -136,7 +136,7 @@ case ${CMAKE_MAKEFILE_GENERATOR} in
    BDEPEND="sys-devel/make"
    ;;
    ninja)
    - BDEPEND="dev-util/ninja"
    + BDEPEND="${NINJA_DEPEND}"
    ;;
    *)
    eerror "Unknown value for \${CMAKE_MAKEFILE_GENERATOR}"
    @@ -365,7 +365,7 @@ cmake_src_prepare() {

    # if ninja is enabled but not installed, the build could fail
    # this could happen if ninja is manually enabled (eg. make.conf) but not installed
    - if [[ ${CMAKE_MAKEFILE_GENERATOR} == ninja ]] && ! has_version -b dev-util/ninja; then
    + if [[ ${CMAKE_MAKEFILE_GENERATOR} == ninja ]] && ! has_version -b "${NINJA_DEPEND}"; then
    eerror "CMAKE_MAKEFILE_GENERATOR is set to ninja, but ninja is not installed."
    die "Please install dev-util/ninja or unset CMAKE_MAKEFILE_GENERATOR."
    fi
    @@ -703,12 +703,17 @@ cmake_src_test() {
    # @DESCRIPTION:
    # Function for installing the package. Automatically detects the build type.
    cmake_src_install() {
    + local generator=${CMAKE_MAKEFILE_GENERATOR}
    + case ${CMAKE_MAKEFILE_GENERATOR} in
    + ninja) generator="eninja" ;;
    + esac
    +
    debug-print-function ${FUNCNAME} "$@"

    _cmake_check_build_dir
    pushd "${BUILD_DIR}" > /dev/null || die
    - DESTDIR="${D}" ${CMAKE_MAKEFILE_GENERATOR} install "$@" ||
    - die "died running ${CMAKE_MAKEFILE_GENERATOR} install"
    + DESTDIR="${D}" ${generator} install "$@" ||
    + die "died running ${generator} install"
    popd > /dev/null || die

    I'm sorry for missing this earlier but could we perhaps reuse
    cmake_build here? Instead of this whole block above, something like:

    DESTDIR="${D}" cmake_build install "$@"


    if [[ ${EAPI} == 7 ]]; then

    --
    Best regards,
    Michał Górny

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Pacho Ramos@21:1/5 to All on Mon May 9 14:00:01 2022
    El dom, 08-05-2022 a las 23:07 +0000, Sam James escribió:
    From: orbea <orbea@riseup.net>

    samurai is a ninja-compatible build tool written in C which
    works with cmake, meson and other users of ninja.

    It is feature-complete and supports most of the same options
    as ninja.

    Signed-off-by: orbea <orbea@riseup.net>
    Signed-off-by: Sam James <sam@gentoo.org>
    ---
     eclass/ninja-utils.eclass | 24 +++++++++++++++++++++++-
     1 file changed, 23 insertions(+), 1 deletion(-)

    diff --git a/eclass/ninja-utils.eclass b/eclass/ninja-utils.eclass
    index c5f34934192f..67f7a6b5e8a7 100644
    --- a/eclass/ninja-utils.eclass
    +++ b/eclass/ninja-utils.eclass
    @@ -26,6 +26,15 @@ esac
     if [[ -z ${_NINJA_UTILS_ECLASS} ]]; then
     _NINJA_UTILS_ECLASS=1
     
    +# @ECLASS_VARIABLE: NINJA
    +# @PRE_INHERIT
    +# @DEFAULT_UNSET
    +# @DESCRIPTION:
    +# Specify a compatible ninja implementation to be used by eninja.
    +# At this point only "ninja" and "samu" are supported.
    +# The default is set to "ninja".
    +: ${NINJA:=ninja}
    +
     # @ECLASS_VARIABLE: NINJAOPTS
     # @DEFAULT_UNSET
     # @DESCRIPTION:
    @@ -35,6 +44,19 @@ _NINJA_UTILS_ECLASS=1
     
     inherit multiprocessing
     
    +case "${NINJA}" in
    +       ninja) +               NINJA_DEPEND=">=dev-util/ninja-1.8.2" +       ;;
    +       samu) +               NINJA_DEPEND="dev-util/samurai" +       ;;
    +       *)
    +               eerror "Unknown value for \${NINJA}" +               die "Value ${NINJA} is not supported" +       ;;
    +esac
    +

    Personally I would add "samurai" as value instead of the abbreviated "samu" form
    (that could come from other words than "samurai")... but has you wish :), it is only a cosmetic change anyway

    Thanks



    -----BEGIN PGP SIGNATURE-----

    iQEzBAABCAAdFiEE808Ng0g83FMNupoifLEMIH/AfbwFAmJ5AAgACgkQfLEMIH/A fbzbrgf+OZYPphhs8XRnnELmkDT4yYyL2gT5RIiolPJev0BD7IDgKPSjJ4RUXl4Z 4p53MzYL2qyHZ1/g1Plx7NedXAQfQ2usv17MTYfZXqcaBznVV3T7tISwWiIIbMff CWfCJp0jcEuic9OTrHa+1mvePjkBBSQkBxGrx5aiZwLmv13IDwzeljlGrs64ki76 +7Iku/ljrQ3eCcYilKulghUxMixej5h+mq/RbPMNtb2ifrZQYpaY7LUwkxyAt56V X6YLqIAW/FnBN6KD0IIm3P2pd89W6jYywNMjxXkAFTMyzi+oU6Pt4tTF073G+IKi P2LcvowK61zdaVz41tHlZvAjytbjSg==
    =0BBz
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mike Gilbert@21:1/5 to sam@gentoo.org on Mon May 9 17:00:01 2022
    On Sun, May 8, 2022 at 7:07 PM Sam James <sam@gentoo.org> wrote:

    From: orbea <orbea@riseup.net>

    samurai is a ninja-compatible build tool written in C which
    works with cmake, meson and other users of ninja.

    It is feature-complete and supports most of the same options
    as ninja.

    Signed-off-by: orbea <orbea@riseup.net>
    Signed-off-by: Sam James <sam@gentoo.org>
    ---
    eclass/ninja-utils.eclass | 24 +++++++++++++++++++++++-
    1 file changed, 23 insertions(+), 1 deletion(-)

    diff --git a/eclass/ninja-utils.eclass b/eclass/ninja-utils.eclass
    index c5f34934192f..67f7a6b5e8a7 100644
    --- a/eclass/ninja-utils.eclass
    +++ b/eclass/ninja-utils.eclass
    @@ -26,6 +26,15 @@ esac
    if [[ -z ${_NINJA_UTILS_ECLASS} ]]; then
    _NINJA_UTILS_ECLASS=1

    +# @ECLASS_VARIABLE: NINJA
    +# @PRE_INHERIT
    +# @DEFAULT_UNSET
    +# @DESCRIPTION:
    +# Specify a compatible ninja implementation to be used by eninja.
    +# At this point only "ninja" and "samu" are supported.
    +# The default is set to "ninja".
    +: ${NINJA:=ninja}

    This is tagged as @DEFAULT_UNSET, but the description and
    implementation indicate that it defaults to "ninja".

    # @ECLASS_VARIABLE: NINJAOPTS
    # @DEFAULT_UNSET
    # @DESCRIPTION:
    @@ -35,6 +44,19 @@ _NINJA_UTILS_ECLASS=1

    inherit multiprocessing

    +case "${NINJA}" in
    + ninja)
    + NINJA_DEPEND=">=dev-util/ninja-1.8.2"
    + ;;
    + samu)
    + NINJA_DEPEND="dev-util/samurai"
    + ;;
    + *)
    + eerror "Unknown value for \${NINJA}"
    + die "Value ${NINJA} is not supported"
    + ;;
    +esac

    The NINJA environment variable is used directly by meson and may
    contain an absolute path. I don't think it makes sense to restrict
    possible values to just "ninja" and "samu". That will make it more
    difficult for users to override it with a local copy of either tool,
    or to use a different implementation should someone write one in the
    future.

    It might make sense to introduce a different eclass variable to
    control NINJA_DEPEND and the default value for NINJA.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mike Gilbert@21:1/5 to orbea@riseup.net on Mon May 9 20:00:01 2022
    On Mon, May 9, 2022 at 1:13 PM orbea <orbea@riseup.net> wrote:

    On Mon, 9 May 2022 10:59:03 -0400
    Mike Gilbert <floppym@gentoo.org> wrote:
    The NINJA environment variable is used directly by meson and may
    contain an absolute path. I don't think it makes sense to restrict
    possible values to just "ninja" and "samu". That will make it more difficult for users to override it with a local copy of either tool,
    or to use a different implementation should someone write one in the future.

    It might make sense to introduce a different eclass variable to
    control NINJA_DEPEND and the default value for NINJA.

    The game antares (https://github.com/arescentral/antares) has a custom
    python based build system that also respects the NINJA variable.

    Your point is a good one, but I'm unsure how this would work? The NINJA_DEPEND variable has to be set to a valid package elsewhere in the eclass scripts, for example the 'has_version -b' check in the cmake
    eclass.

    Allowing the user to set an arbitrary value will require they also
    being able to set NINJA_DEPEND to a correct value. In some of these
    cases there may not be an applicable ebuild to set it to even. Maybe
    I'm missing something, but this seems like a good way to complicate the process and possibly introduce pebkac. Maybe it would be preferable to
    just add additional ninja implementations to the list as they are
    available?

    Also if its just testing local versions I think it could be worked
    around by setting the PATH and / or using symlinks? A user could
    create a dummy ebuild as well.

    We could make the eclass ewarn on unknown NINJA values, and set
    NINJA_DEPEND to empty in that case. Just don't call "die".

    That would allow users to override NINJA without triggering a failure,
    and still alerts ebuild maintainers in case they make a typo when
    setting NINJA in an ebuild.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anna =?utf-8?B?4oCcQ3liZXJUYWlsb3Li@21:1/5 to Sam James on Mon May 30 22:00:01 2022
    On 2022-05-08 23:07, Sam James wrote:
    From: orbea <orbea@riseup.net>

    samurai is a ninja-compatible build tool written in C which
    works with cmake, meson and other users of ninja.

    It is feature-complete and supports most of the same options
    as ninja.

    Signed-off-by: orbea <orbea@riseup.net>
    Signed-off-by: Sam James <sam@gentoo.org>
    ---
    eclass/ninja-utils.eclass | 24 +++++++++++++++++++++++-
    1 file changed, 23 insertions(+), 1 deletion(-)

    diff --git a/eclass/ninja-utils.eclass b/eclass/ninja-utils.eclass
    index c5f34934192f..67f7a6b5e8a7 100644
    --- a/eclass/ninja-utils.eclass
    +++ b/eclass/ninja-utils.eclass
    @@ -26,6 +26,15 @@ esac
    if [[ -z ${_NINJA_UTILS_ECLASS} ]]; then
    _NINJA_UTILS_ECLASS=1

    +# @ECLASS_VARIABLE: NINJA
    +# @PRE_INHERIT

    How about making it @USER_VARIABLE instead? Because it's more likely to
    be set in make.conf rather than in an ebuild.

    +# @DEFAULT_UNSET
    +# @DESCRIPTION:
    +# Specify a compatible ninja implementation to be used by eninja.
    +# At this point only "ninja" and "samu" are supported.
    +# The default is set to "ninja".
    +: ${NINJA:=ninja}
    +
    # @ECLASS_VARIABLE: NINJAOPTS
    # @DEFAULT_UNSET
    # @DESCRIPTION:
    @@ -35,6 +44,19 @@ _NINJA_UTILS_ECLASS=1

    inherit multiprocessing

    +case "${NINJA}" in
    + ninja)
    + NINJA_DEPEND=">=dev-util/ninja-1.8.2"
    + ;;
    + samu)
    + NINJA_DEPEND="dev-util/samurai"
    + ;;
    + *)
    + eerror "Unknown value for \${NINJA}"
    + die "Value ${NINJA} is not supported"
    + ;;
    +esac
    +
    # @FUNCTION: eninja
    # @USAGE: [<args>...]
    # @DESCRIPTION:
    @@ -48,7 +70,7 @@ eninja() {
    if [[ -z ${NINJAOPTS+set} ]]; then
    NINJAOPTS="-j$(makeopts_jobs "${MAKEOPTS}" 999) -l$(makeopts_loadavg "${MAKEOPTS}" 0)"
    fi
    - set -- ninja -v ${NINJAOPTS} "$@"
    + set -- "${NINJA}" -v ${NINJAOPTS} "$@"
    echo "$@" >&2
    "$@" || die "${nonfatal_args[@]}" "${*} failed"
    }
    --
    2.35.1



    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mike Gilbert@21:1/5 to cyber+gentoo@sysrq.in on Mon May 30 23:00:02 2022
    On Mon, May 30, 2022 at 3:57 PM Anna “CyberTailor”
    <cyber+gentoo@sysrq.in> wrote:

    On 2022-05-08 23:07, Sam James wrote:
    From: orbea <orbea@riseup.net>

    samurai is a ninja-compatible build tool written in C which
    works with cmake, meson and other users of ninja.

    It is feature-complete and supports most of the same options
    as ninja.

    Signed-off-by: orbea <orbea@riseup.net>
    Signed-off-by: Sam James <sam@gentoo.org>
    ---
    eclass/ninja-utils.eclass | 24 +++++++++++++++++++++++-
    1 file changed, 23 insertions(+), 1 deletion(-)

    diff --git a/eclass/ninja-utils.eclass b/eclass/ninja-utils.eclass
    index c5f34934192f..67f7a6b5e8a7 100644
    --- a/eclass/ninja-utils.eclass
    +++ b/eclass/ninja-utils.eclass
    @@ -26,6 +26,15 @@ esac
    if [[ -z ${_NINJA_UTILS_ECLASS} ]]; then
    _NINJA_UTILS_ECLASS=1

    +# @ECLASS_VARIABLE: NINJA
    +# @PRE_INHERIT

    How about making it @USER_VARIABLE instead? Because it's more likely to
    be set in make.conf rather than in an ebuild.

    It's "unofficially" supported as a user variable. If users set it in
    make.conf, it will break metadata invariance and the dependency cache
    will need to be rebuilt.

    If we truly want to support it as a user variable, we need to provide
    some alternate means of varying BDEPEND.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)