From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id E5F43139694 for ; Sun, 30 Apr 2017 20:28:47 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B0F42E0DA0; Sun, 30 Apr 2017 20:28:39 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 5DCECE0D13 for ; Sun, 30 Apr 2017 20:28:39 +0000 (UTC) Received: from localhost.localdomain (d202-252.icpnet.pl [109.173.202.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mgorny) by smtp.gentoo.org (Postfix) with ESMTPSA id 9AD123416A0; Sun, 30 Apr 2017 20:28:37 +0000 (UTC) From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= To: gentoo-dev@lists.gentoo.org Cc: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Subject: [gentoo-dev] [PATCH 1/4] ninja-utils.eclass: Add a new eclass to handle calling ninja Date: Sun, 30 Apr 2017 22:28:27 +0200 Message-Id: <20170430202830.12974-1-mgorny@gentoo.org> X-Mailer: git-send-email 2.13.0.rc1 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Archives-Salt: 32aa281c-b8f8-4c13-b3c3-3fc4020aa510 X-Archives-Hash: da25e7a8176c0ab42fb996f98f4e3c3e --- eclass/ninja-utils.eclass | 57 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 eclass/ninja-utils.eclass diff --git a/eclass/ninja-utils.eclass b/eclass/ninja-utils.eclass new file mode 100644 index 000000000000..69216176ba61 --- /dev/null +++ b/eclass/ninja-utils.eclass @@ -0,0 +1,57 @@ +# Copyright 1999-2017 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +# @ECLASS: ninja-utils.eclass +# @MAINTAINER: +# Michał Górny +# Mike Gilbert +# @AUTHOR: +# Michał Górny +# Mike Gilbert +# @BLURB: common bits to run dev-util/ninja builder +# @DESCRIPTION: +# This eclass provides a single function -- eninja -- that can be used +# to run the ninja builder alike emake. It does not define any +# dependencies, you need to depend on dev-util/ninja yourself. Since +# ninja is rarely used stand-alone, most of the time this eclass will +# be used indirectly by the eclasses for other build systems (CMake, +# Meson). + +if [[ -z ${_NINJA_UTILS_ECLASS} ]]; then + +case ${EAPI:-0} in + 0|1|3) die "EAPI=${EAPI:-0} is not supported (too old)";; + # copied from cmake-utils + 2|4|5|6) ;; + *) die "EAPI=${EAPI} is not yet supported" ;; +esac + +# @ECLASS-VARIABLE: NINJAOPTS +# @DEFAULT_UNSET +# @DESCRIPTION: +# The default set of options to pass to Ninja. Similar to MAKEOPTS, +# supposed to be set in make.conf. If unset, eninja() will convert +# MAKEOPTS instead. + +inherit multiprocessing + +# @FUNCTION: eninja +# @USAGE: [...] +# @DESCRIPTION: +# Call Ninja, passing the NINJAOPTS (or converted MAKEOPTS), followed +# by the supplied arguments. This function dies if ninja fails. Starting +# with EAPI 6, it also supports being called via 'nonfatal'. +eninja() { + local nonfatal_args=() + [[ ${EAPI:-0} != [245] ]] && nonfatal_args+=( -n ) + + if [[ -z ${NINJAOPTS+set} ]]; then + NINJAOPTS="-j$(makeopts_jobs) -l$(makeopts_loadavg "${MAKEOPTS}" 0)" + fi + set -- ninja -v ${NINJAOPTS} "$@" + echo "$@" >&2 + "$@" || die "${nonfatal_args[@]}" "${*} failed" +} + +_NINJA_UTILS_ECLASS=1 +fi -- 2.13.0.rc1