From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 7007435916639731712 X-Received: by 2002:a05:6512:33c3:: with SMTP id d3mr8727714lfg.194.1631545816669; Mon, 13 Sep 2021 08:10:16 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a2e:597:: with SMTP id 145ls1279155ljf.7.gmail; Mon, 13 Sep 2021 08:10:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVzDTveRER21BOX4M5Los9uU9vOhNp2M03jwmO9dRknPH2jGyMwVOD49VL4uvHiyuCewLO X-Received: by 2002:a2e:585a:: with SMTP id x26mr10658441ljd.132.1631545815469; Mon, 13 Sep 2021 08:10:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631545815; cv=none; d=google.com; s=arc-20160816; b=Ir1+Y/a0UhoJEPWLAXq4dUpiqZhVLyxGfrhxIHLWg2VqfGrOo8BF7Hf/A0WZ4jrzIg IU9V+ocvODxiZFf3ZZgnQgw8jFU5tghKiKaOV5U2XGh6PwrYnzshDTarrd8/xgoHkJAM 2V7oeVJBkp7uPTOOMn5C54+XwGuUGLGB3FmYmxRWxaIEKTIY7LPaShSoeFvZEdgjG5lA E8VXktJvO4F6/9ZdR6Up+beigkHMPR48pRZfBvEO7QMJqLNzLVEm12XRtseDWyzqJEUq jP5LBp97xLBtKGCpCEhIq73T1xxYmMPC6STWo3To3RHWSTkyCJt9buJ0FKek7kOAGmWK YGSA== 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=kQ016ryJtL+arSYg3o3SPEYvxpaidJ2ybK+g/62Yrmk=; b=fFiD2LXcNonCjxDkmKxtRDyIgM1Zz0HbOFJugHNipSIgJJ8neOFHECer81QC0ws7n8 nEHdVq2Baz0VVaPdjsVp9q1i2OQXOYvh4sututKwzr5cmqGoLtvBLNUlshJKlmn1FkMd IuMnN9P3cEimKU+KItp12YzU8FAw9ausALhb6zCKd79LLvXWWUTFpM0iKPZ2rxW5Zl+K QPjSIyozp0E26ReXlmeMcbGYme7Xkk3ncBaelFtSQB+lOdYYaDgyjMvtqSlI8LT+40Kt TNMaUOfds9QNdTgCqiPF8yX83tr/LniHnEdIRu7c4G0SmR4CrAcJhxgDcGQwbW2m3hNm wxCg== 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 h20si695159lfv.7.2021.09.13.08.10.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 13 Sep 2021 08:10: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 18DFAAGq010048 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 13 Sep 2021 17:10:12 +0200 From: Uladzimir Bely To: isar-users@googlegroups.com Subject: [PATCH 1/2] meta: Support for ccache for custom packages in buildchroot Date: Mon, 13 Sep 2021 17:10:08 +0200 Message-Id: <20210913151009.28655-2-ubely@ilbers.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210913151009.28655-1-ubely@ilbers.de> References: <20210913151009.28655-1-ubely@ilbers.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TUID: JYmC60kSuN/U 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 | 12 +++++++++- .../buildchroot/buildchroot.inc | 1 + .../buildchroot/files/build.sh | 6 +++++ .../buildchroot/files/common.sh | 1 + 7 files changed, 53 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 96a8beb..0f1a030 100644 --- a/meta-isar/conf/local.conf.sample +++ b/meta-isar/conf/local.conf.sample @@ -222,3 +222,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..598458d 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 [ "${@repr(bb.utils.to_boolean(d.getVar('CCACHE_BUILDCHROOT')))}" = 'True' ] + 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..2259417 --- /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: +# CCACHE_DISABLE = '1' +# +# - 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}-${MACHINE}" + +CCACHE_BUILDCHROOT ?= "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..af2ba2e 100644 --- a/meta/classes/dpkg.bbclass +++ b/meta/classes/dpkg.bbclass @@ -32,6 +32,16 @@ addtask devshell after do_install_builddeps dpkg_runbuild() { E="${@ isar_export_proxies(d)}" export PARALLEL_MAKE="${PARALLEL_MAKE}" + if [ "${@repr(bb.utils.to_boolean(d.getVar('CCACHE_BUILDCHROOT')))}" = 'True' ] + then + USE_CCACHE="1" + else + USE_CCACHE="0" + fi + if [ "${@repr(bb.utils.to_boolean(d.getVar('CCACHE_DISABLE')))}" = 'True' ] + then + USE_CCACHE="0" + fi 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