]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
ccache: enable ccache for all recipes if it is in HOSTTOOLS
authorRoss Burton <ross.burton@arm.com>
Mon, 19 May 2025 12:59:30 +0000 (13:59 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 4 Aug 2025 17:04:00 +0000 (18:04 +0100)
At the moment we don't allow ccache for native recipes to avoid the
dependency loop of native recipes needing ccache-native which then
depends on itself.

One way to avoid this dependency loop is to just provide a host ccache,
so enable ccache globally if ccache is in HOSTTOOLS.  This isn't set
out of the box, but does work.

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/ccache.bbclass

index 7daaa7e3aa246d2654bbc4638f2b52f0b6cc02bb..5ce23e50f342b451eea7114c856cc17e4f60d798 100644 (file)
 #
 # - Disable ccache for a recipe
 #   Add the following line to the recipe if it can't be built with ccache:
-#   CCACHE_DISABLE = '1'
+#   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 = "/path/to/shared_ccache/"
 #
-# - TO debug ccahe
+# - To debug ccache
 #   export CCACHE_DEBUG = "1"
 #   export CCACHE_LOGFILE = "${CCACHE_DIR}/logfile.log"
 #   And also set PARALLEL_MAKE = "-j 1" to get make the log in order
 #
+# By default this class will only use ccache for target builds, and build
+# our own ccache-native.  It is possible to use a host-provided ccache that
+# can then be used by native recipes too by setting:
+#   ASSUME_PROVIDED += "ccache-native"
+#   HOSTTOOLS += "ccache"
 
 # Set it to a shared location for different builds, so that cache files can
 # be shared between different builds.
@@ -46,7 +51,8 @@ python() {
     Enable ccache for the recipe
     """
     pn = d.getVar('PN')
-    if (pn in d.getVar('CCACHE_NATIVE_RECIPES_ALLOWED') or
+    if ("ccache" in d.getVar("HOSTTOOLS").split() or
+        pn in d.getVar('CCACHE_NATIVE_RECIPES_ALLOWED') or
         not (bb.data.inherits_class("native", d) or
         bb.utils.to_boolean(d.getVar('CCACHE_DISABLE')))):
         d.appendVar('DEPENDS', ' ccache-native')