Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 1 | # |
| 2 | # Usage: |
| 3 | # - Enable ccache |
| 4 | # Add the following line to a conffile such as conf/local.conf: |
| 5 | # INHERIT += "ccache" |
| 6 | # |
| 7 | # - Disable ccache for a recipe |
| 8 | # Add the following line to the recipe if it can't be built with ccache: |
| 9 | # CCACHE_DISABLE = '1' |
| 10 | # |
| 11 | # - Share ccache files between different builds |
| 12 | # Set CCACHE_TOP_DIR to a shared dir |
| 13 | # CCACHE_TOP_DIR = /path/to/shared_ccache/ |
| 14 | # |
| 15 | # - TO debug ccahe |
| 16 | # export CCACHE_DEBUG = "1" |
| 17 | # export CCACHE_LOGFILE = "${CCACHE_DIR}/logfile.log" |
| 18 | # And also set PARALLEL_MAKE = "-j 1" to get make the log in order |
| 19 | # |
| 20 | |
| 21 | # Set it to a shared location for different builds, so that cache files can |
| 22 | # be shared between different builds. |
| 23 | CCACHE_TOP_DIR ?= "${TMPDIR}/ccache" |
| 24 | |
| 25 | # ccahe removes CCACHE_BASEDIR from file path, so that hashes will be the same |
| 26 | # in different builds. |
| 27 | export CCACHE_BASEDIR ?= "${TMPDIR}" |
| 28 | |
| 29 | # Used for sharing cache files after compiler is rebuilt |
| 30 | export CCACHE_COMPILERCHECK ?= "%compiler% -dumpspecs" |
| 31 | |
| 32 | export CCACHE_CONFIGPATH ?= "${COREBASE}/meta/conf/ccache.conf" |
| 33 | |
| 34 | export CCACHE_DIR ?= "${CCACHE_TOP_DIR}/${MULTIMACH_TARGET_SYS}/${PN}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 35 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 36 | # We need to stop ccache considering the current directory or the |
| 37 | # debug-prefix-map target directory to be significant when calculating |
| 38 | # its hash. Without this the cache would be invalidated every time |
| 39 | # ${PV} or ${PR} change. |
| 40 | export CCACHE_NOHASHDIR ?= "1" |
| 41 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 42 | python() { |
| 43 | """ |
| 44 | Enable ccache for the recipe |
| 45 | """ |
| 46 | pn = d.getVar('PN') |
| 47 | # quilt-native doesn't need ccache since no c files |
| 48 | if not (pn in ('ccache-native', 'quilt-native') or |
| 49 | bb.utils.to_boolean(d.getVar('CCACHE_DISABLE'))): |
| 50 | d.appendVar('DEPENDS', ' ccache-native') |
| 51 | d.setVar('CCACHE', 'ccache ') |
| 52 | } |
| 53 | |
| 54 | addtask cleanccache after do_clean |
| 55 | python do_cleanccache() { |
| 56 | import shutil |
| 57 | |
| 58 | ccache_dir = d.getVar('CCACHE_DIR') |
| 59 | if os.path.exists(ccache_dir): |
| 60 | bb.note("Removing %s" % ccache_dir) |
| 61 | shutil.rmtree(ccache_dir) |
| 62 | else: |
| 63 | bb.note("%s doesn't exist" % ccache_dir) |
| 64 | } |
| 65 | addtask cleanall after do_cleanccache |
| 66 | do_cleanccache[nostamp] = "1" |