From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 7024486976540639232 X-Received: by 2002:a1c:4681:: with SMTP id t123mr2410397wma.83.1635515826708; Fri, 29 Oct 2021 06:57:06 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a5d:4e85:: with SMTP id e5ls1053650wru.1.gmail; Fri, 29 Oct 2021 06:57:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7BNZ2qkaGEr33NG7TOVXto+Y9wF3wnLogMx6jSmSb8gv7q7dpWqYOoMHOvhDm3Xsfr8ev X-Received: by 2002:a5d:6441:: with SMTP id d1mr14411850wrw.367.1635515825694; Fri, 29 Oct 2021 06:57:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635515825; cv=none; d=google.com; s=arc-20160816; b=HaWZu4UfEOoI0i92rbSVewGMJz2wSfiK/eqOjlhFv4QuHFNT8nk70dV0ifwtGsOY+H bRZtyZiIAEFXzUDWbeWxiPeAdKbhAu8E19UW7GVvL3ZyESoX7i8FkZn7SIyfx3LAMJnh XDuaRgb7ulFmALb5s5uHifJUde2+hbRp2iCrmK4qiP3kMBOLPrA+tHKQ4Pfmejaqrpep 8rGE6/S0AahLEQVly/cEciwl6kHGa5meht3d/jYcnmGZlxTlhGJvc22Pv3LUQ50LmzBq z5XFKbJuuRPpVqO+H+b/0DSh8yC/dTxWifOdnZ/l5XC3BqQvkvGx9Yy3JZjR2V6fqKbr 4Pug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from; bh=XlEYiGZkJFJ+6F6FnyoHHBEah5VFKnruekht5xujEac=; b=nL+e2pfjYmUExa9vILTjDL8jLmb6roMcD2CGc5pfD9zCDdTsBs4rT9ptjkrEP8gotb Bym/EMO/SX1J39qq4JdspYaHwf8igL6ZzJj48/1VpchKIy0JHjx2lQsQ5S3IJjkb7hjQ ltjxIqz781axWl94Y3K2RfDIAJH9eBecrQZGqttPrj2NnQbqBZMbiHn0AbFYghC+R4wx makA360qOCGHei8m39YRW+7jPXqFES7GjwXwP/JoVWgpPp1Bw9bN8Pr8gq9tx506DvA/ owsBri9q159SubIxJhnPN7P/R5waNSEb/xVE+6qNwEKYzNQRutcu00jtYSnhjWp7VtJ/ VcpA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of ubely@ilbers.de designates 85.214.156.166 as permitted sender) smtp.mailfrom=ubely@ilbers.de Return-Path: Received: from shymkent.ilbers.de (shymkent.ilbers.de. [85.214.156.166]) by gmr-mx.google.com with ESMTPS id f9si833728wmg.2.2021.10.29.06.57.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 29 Oct 2021 06:57:05 -0700 (PDT) Received-SPF: pass (google.com: domain of ubely@ilbers.de designates 85.214.156.166 as permitted sender) client-ip=85.214.156.166; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of ubely@ilbers.de designates 85.214.156.166 as permitted sender) smtp.mailfrom=ubely@ilbers.de Received: from baighyz.m.ilbers.de (host-80-81-17-52.static.customer.m-online.net [80.81.17.52]) (authenticated bits=0) by shymkent.ilbers.de (8.15.2/8.15.2/Debian-8) with ESMTPSA id 19TDv0m4022514 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 29 Oct 2021 15:57:03 +0200 From: Uladzimir Bely To: isar-users@googlegroups.com Subject: [PATCH v3 1/3] meta: Support for ccache for custom packages Date: Fri, 29 Oct 2021 15:56:58 +0200 Message-Id: <20211029135700.27885-2-ubely@ilbers.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211029135700.27885-1-ubely@ilbers.de> References: <20211029135700.27885-1-ubely@ilbers.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TUID: 36sgQqK6CjFd Add `USE_CCACHE = "1"` to local.conf to globally activate the ccache functionality for dpkg-based recipes. Add `USE_CCACHE = "0"` to the recipe to disable ccache for it even if globaly enabled. Signed-off-by: Uladzimir Bely --- meta-isar/conf/local.conf.sample | 5 +++++ meta/classes/buildchroot.bbclass | 9 +++++++++ meta/classes/dpkg.bbclass | 2 +- meta/conf/bitbake.conf | 5 +++++ meta/recipes-devtools/buildchroot/buildchroot.inc | 1 + meta/recipes-devtools/buildchroot/files/build.sh | 5 +++++ meta/recipes-devtools/buildchroot/files/common.sh | 1 + 7 files changed, 27 insertions(+), 1 deletion(-) diff --git a/meta-isar/conf/local.conf.sample b/meta-isar/conf/local.conf.sample index 1ab640d0..42a69aed 100644 --- a/meta-isar/conf/local.conf.sample +++ b/meta-isar/conf/local.conf.sample @@ -227,3 +227,8 @@ USER_isar[flags] += "clear-text-password" # Uncomment the below line to debug WIC. # WIC_CREATE_EXTRA_ARGS += "-D" + +# Uncomment this to use ccache for custom packages +#USE_CCACHE = "1" +# Uncomment and set own top level ccache directory to share between builds +#CCACHE_TOP_DIR ?= "${TMPDIR}/ccache" diff --git a/meta/classes/buildchroot.bbclass b/meta/classes/buildchroot.bbclass index e9eb9afa..dd8f4206 100644 --- a/meta/classes/buildchroot.bbclass +++ b/meta/classes/buildchroot.bbclass @@ -24,6 +24,10 @@ python __anonymous() { MOUNT_LOCKFILE = "${BUILDCHROOT_DIR}.lock" buildchroot_do_mounts() { + if [ "${USE_CCACHE}" = "1" ]; then + mkdir -p ${CCACHE_DIR} + fi + sudo -s <<'EOSUDO' ( flock 9 set -e @@ -32,6 +36,11 @@ buildchroot_do_mounts() { mount --bind '${REPO_ISAR_DIR}/${DISTRO}' '${BUILDCHROOT_DIR}/isar-apt' mountpoint -q '${BUILDCHROOT_DIR}/downloads' || mount --bind '${DL_DIR}' '${BUILDCHROOT_DIR}/downloads' + if [ "${USE_CCACHE}" = "1" ]; then + mkdir -p '${BUILDCHROOT_DIR}/ccache' + mountpoint -q '${BUILDCHROOT_DIR}/ccache' || + mount --bind '${CCACHE_DIR}' '${BUILDCHROOT_DIR}/ccache' + fi mountpoint -q '${BUILDCHROOT_DIR}/dev' || mount --rbind /dev '${BUILDCHROOT_DIR}/dev' mount --make-rslave '${BUILDCHROOT_DIR}/dev' diff --git a/meta/classes/dpkg.bbclass b/meta/classes/dpkg.bbclass index 4e7c2f77..86b47c28 100644 --- a/meta/classes/dpkg.bbclass +++ b/meta/classes/dpkg.bbclass @@ -33,5 +33,5 @@ dpkg_runbuild() { E="${@ isar_export_proxies(d)}" export PARALLEL_MAKE="${PARALLEL_MAKE}" sudo -E chroot --userspec=$( id -u ):$( id -g ) ${BUILDCHROOT_DIR} \ - /isar/build.sh ${PP}/${PPS} ${PACKAGE_ARCH} + /isar/build.sh ${PP}/${PPS} ${PACKAGE_ARCH} ${USE_CCACHE} } diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf index 7f5901d7..dce467b2 100644 --- a/meta/conf/bitbake.conf +++ b/meta/conf/bitbake.conf @@ -115,6 +115,11 @@ BBINCLUDELOGS ??= "yes" # Add event handlers for bitbake INHERIT += "isar-events" +# Default values for ccache +USE_CCACHE ??= "0" +CCACHE_TOP_DIR ?= "${TMPDIR}/ccache" +CCACHE_DIR ?= "${CCACHE_TOP_DIR}/${DISTRO}-${DISTRO_ARCH}" + include conf/local.conf include conf/multiconfig/${BB_CURRENT_MC}.conf include conf/machine/${MACHINE}.conf diff --git a/meta/recipes-devtools/buildchroot/buildchroot.inc b/meta/recipes-devtools/buildchroot/buildchroot.inc index 31524a11..726c7bbd 100644 --- a/meta/recipes-devtools/buildchroot/buildchroot.inc +++ b/meta/recipes-devtools/buildchroot/buildchroot.inc @@ -32,6 +32,7 @@ BUILDCHROOT_PREINSTALL_COMMON = " \ make \ debhelper \ autotools-dev \ + ccache \ dpkg \ locales \ docbook-to-man \ diff --git a/meta/recipes-devtools/buildchroot/files/build.sh b/meta/recipes-devtools/buildchroot/files/build.sh index 101581db..8e6507c6 100644 --- a/meta/recipes-devtools/buildchroot/files/build.sh +++ b/meta/recipes-devtools/buildchroot/files/build.sh @@ -14,4 +14,9 @@ for i in configure aclocal.m4 Makefile.am Makefile.in; do fi done +if [ "$use_ccache" == "1" ]; then + export CCACHE_DIR=/ccache + export PATH=/usr/lib/ccache:$PATH +fi + ${GBP_PREFIX}dpkg-buildpackage -a$target_arch -d --source-option=-I diff --git a/meta/recipes-devtools/buildchroot/files/common.sh b/meta/recipes-devtools/buildchroot/files/common.sh index 0063a38e..7085f443 100644 --- a/meta/recipes-devtools/buildchroot/files/common.sh +++ b/meta/recipes-devtools/buildchroot/files/common.sh @@ -17,6 +17,7 @@ fi # Create human-readable names target_arch=$2 +use_ccache=$3 set_arch="--host-arch $target_arch" -- 2.20.1