44 lines
1.0 KiB
Python
44 lines
1.0 KiB
Python
import os
|
|
from cache import hash_dict
|
|
|
|
|
|
def build_ccache_env(project):
|
|
"""
|
|
Configure compiler caching layer safely.
|
|
"""
|
|
|
|
env = {}
|
|
|
|
# ----------------------------
|
|
# enable ccache
|
|
# ----------------------------
|
|
env["USE_CCACHE"] = "1"
|
|
env["CCACHE_DIR"] = "/var/cache/ccache"
|
|
|
|
# ----------------------------
|
|
# distcc + ccache integration
|
|
# critical ordering fix
|
|
# ----------------------------
|
|
env["CC"] = "ccache gcc"
|
|
env["CXX"] = "ccache g++"
|
|
|
|
# ensure distcc wraps AFTER ccache
|
|
env["CCACHE_PREFIX"] = "distcc"
|
|
|
|
# ----------------------------
|
|
# tuning for distributed builds
|
|
# ----------------------------
|
|
env["CCACHE_COMPRESS"] = "1"
|
|
env["CCACHE_COMPRESSLEVEL"] = "5"
|
|
env["CCACHE_MAXSIZE"] = "20G"
|
|
|
|
# ----------------------------
|
|
# project-specific salt
|
|
# ensures correct cache isolation
|
|
# ----------------------------
|
|
env["CCACHE_SLOPPINESS"] = "time_macros,locale"
|
|
|
|
env["FESTER_CCACHE_KEY"] = hash_dict(project.get("build_env", {}))
|
|
|
|
return env
|