From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 7013292876278792192 X-Received: by 2002:a2e:9017:: with SMTP id h23mr5043605ljg.426.1632909497080; Wed, 29 Sep 2021 02:58:17 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a05:6512:3f14:: with SMTP id y20ls1818979lfa.1.gmail; Wed, 29 Sep 2021 02:58:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzw9yZ3UlQDY7sM3DgacaeZddH/sjH4UfEg+U3rbdW69wKP8+w0wUQJVsHyJc5aaIoKBh0B X-Received: by 2002:a05:6512:3982:: with SMTP id j2mr10784888lfu.332.1632909495905; Wed, 29 Sep 2021 02:58:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632909495; cv=none; d=google.com; s=arc-20160816; b=CFSvqVweQNNds+zC27hKXlOJDiVWHSlPEYABx7jEi0CZ7xNeT66AK4dPVCvMkGUZ+1 Jp2qRPVgRmVGUG/fy+mYluOq43OlFmlRGCdetkpTzahxNyr4DUvMzl+Mz+TgWlVOaYK6 OIFTomuUJtka0PaPpkWJj4u/S9yMpUjAyqGZ4cAzjc7cmsC/9lTPGQO1F1XTpo0kLjZd 5BTsyGFiN4aEdRwsBJCSqiP6bTWciR6u3EQmz7q67K1O4/t/qt318Doa0rmsmiq3MUQN yl5lwJ1gY6KJ9A99pdO5mZ/kR0x7TZiUZ453zdBcOc0fB+qrn3AVVKuHpCKGF0US2VBq zraw== 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=b4+QrCcSVaeHftQxVgdWKxTJKkkdNLJFFnckC/D2LJE=; b=kAhxmPw0e6Ooxle3QeqzItPHq+IyLv045AYfxTny5I3Y0JrkuIF+4PUzMNqKfhXyVW hIlM/PwO4V9LXYxJzfZJrWwJ1M5Ol0CQs72+hIq96Ey5X+RIzODT1FQIYagV8g4Yj9u+ Q1o7kq2zaGi65rcTobadC0UVUxSS/eTq0xxiKbVupR4b0dG4qVkkRzdEpObSYZ2Q8YIH iyvyCai1LWIPptf5CqYrBZz+LTkUl9qu/d6QEe0n/vBotl52xjN0H+EoFLKEmq5fo2+k myZPfc/DtjTNmxlQwTIu9jOBq8YMxcc8FOkmhqwYsKJldp18Fauz0MbA7O74QSa7siFp KqlQ== 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 x16si161016ljp.5.2021.09.29.02.58.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 29 Sep 2021 02:58:15 -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 18T9wAhV013444 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 29 Sep 2021 11:58:13 +0200 From: Uladzimir Bely To: isar-users@googlegroups.com Subject: [PATCH v2 1/2] meta: Support for ccache for custom packages in buildchroot Date: Wed, 29 Sep 2021 11:58:09 +0200 Message-Id: <20210929095810.3228-2-ubely@ilbers.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210929095810.3228-1-ubely@ilbers.de> References: <20210929095810.3228-1-ubely@ilbers.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TUID: rf1p6VBqIHp6 Add `INHERIT += "ccache"` to local.conf or package recipe to globally activate the ccache functionality. Add `CCACHE_DISABLE = '1'` to the recipe to disable ccache for it. Signed-off-by: Uladzimir Bely --- meta-isar/conf/local.conf.sample | 5 ++++ meta/classes/buildchroot.bbclass | 6 +++++ meta/classes/ccache.bbclass | 23 +++++++++++++++++++ meta/classes/dpkg.bbclass | 3 ++- .../buildchroot/buildchroot.inc | 1 + .../buildchroot/files/build.sh | 6 +++++ .../buildchroot/files/common.sh | 1 + 7 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 meta/classes/ccache.bbclass diff --git a/meta-isar/conf/local.conf.sample b/meta-isar/conf/local.conf.sample index 88a8175..f180f5a 100644 --- a/meta-isar/conf/local.conf.sample +++ b/meta-isar/conf/local.conf.sample @@ -224,3 +224,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 +#INHERIT += "ccache" +# 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 e9eb9af..274ebdc 100644 --- a/meta/classes/buildchroot.bbclass +++ b/meta/classes/buildchroot.bbclass @@ -32,6 +32,12 @@ 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/ccache.bbclass b/meta/classes/ccache.bbclass new file mode 100644 index 0000000..0053dfa --- /dev/null +++ b/meta/classes/ccache.bbclass @@ -0,0 +1,23 @@ +# +# Usage: +# - Enable ccache +# Add the following line to a conffile such as conf/local.conf: +# INHERIT += "ccache" +# +# - Disable ccache for a recipe +# Add the following line to the recipe if it can't be built with ccache: +# USE_CCACHE = "0" +# +# - Share ccache files between different builds +# Set CCACHE_TOP_DIR to a shared dir +# CCACHE_TOP_DIR = /path/to/shared_ccache/ + +CCACHE_TOP_DIR ?= "${TMPDIR}/ccache" +CCACHE_DIR ?= "${CCACHE_TOP_DIR}/${DISTRO}-${DISTRO_ARCH}" + +USE_CCACHE ?= "1" + +do_init_ccache[dirs] = "${CCACHE_DIR}" +do_init_ccache() { +} +addtask do_init_ccache before do_rootfs diff --git a/meta/classes/dpkg.bbclass b/meta/classes/dpkg.bbclass index 4e7c2f7..4269364 100644 --- a/meta/classes/dpkg.bbclass +++ b/meta/classes/dpkg.bbclass @@ -4,6 +4,7 @@ inherit dpkg-base PACKAGE_ARCH ?= "${DISTRO_ARCH}" +USE_CCACHE ??= "0" # Install build dependencies for package do_install_builddeps() { @@ -33,5 +34,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/recipes-devtools/buildchroot/buildchroot.inc b/meta/recipes-devtools/buildchroot/buildchroot.inc index 31524a1..726c7bb 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 101581d..b642f42 100644 --- a/meta/recipes-devtools/buildchroot/files/build.sh +++ b/meta/recipes-devtools/buildchroot/files/build.sh @@ -14,4 +14,10 @@ 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 0063a38..7085f44 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