ccache.bbclass 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. # Set it to a shared location for different builds, so that cache files can
  21. # be shared between different builds.
  22. CCACHE_TOP_DIR ?= "${TMPDIR}/ccache"
  23. # ccahe removes CCACHE_BASEDIR from file path, so that hashes will be the same
  24. # in different builds.
  25. export CCACHE_BASEDIR ?= "${TMPDIR}"
  26. # Used for sharing cache files after compiler is rebuilt
  27. export CCACHE_COMPILERCHECK ?= "%compiler% -dumpspecs"
  28. export CCACHE_CONFIGPATH ?= "${COREBASE}/meta/conf/ccache.conf"
  29. export CCACHE_DIR ?= "${CCACHE_TOP_DIR}/${MULTIMACH_TARGET_SYS}/${PN}"
  30. # We need to stop ccache considering the current directory or the
  31. # debug-prefix-map target directory to be significant when calculating
  32. # its hash. Without this the cache would be invalidated every time
  33. # ${PV} or ${PR} change.
  34. export CCACHE_NOHASHDIR ?= "1"
  35. python() {
  36. """
  37. Enable ccache for the recipe
  38. """
  39. pn = d.getVar('PN')
  40. # quilt-native doesn't need ccache since no c files
  41. if not (pn in ('ccache-native', 'quilt-native') or
  42. bb.utils.to_boolean(d.getVar('CCACHE_DISABLE'))):
  43. d.appendVar('DEPENDS', ' ccache-native')
  44. d.setVar('CCACHE', 'ccache ')
  45. }
  46. addtask cleanccache after do_clean
  47. python do_cleanccache() {
  48. import shutil
  49. ccache_dir = d.getVar('CCACHE_DIR')
  50. if os.path.exists(ccache_dir):
  51. bb.note("Removing %s" % ccache_dir)
  52. shutil.rmtree(ccache_dir)
  53. else:
  54. bb.note("%s doesn't exist" % ccache_dir)
  55. }
  56. addtask cleanall after do_cleanccache
  57. do_cleanccache[nostamp] = "1"