def enableCcache( the_compiler, env, source_dir, python_prefix, show_scons_mode, assume_yes_for_downloads, ): # The ccache needs absolute path, otherwise it will not work. ccache_logfile = os.path.abspath( os.path.join(source_dir, "ccache-%d.txt" % os.getpid())) setEnvironmentVariable(env, "CCACHE_LOGFILE", ccache_logfile) env["CCACHE_LOGFILE"] = ccache_logfile # First check if it's not already supposed to be a ccache, then do nothing. cc_path = getExecutablePath(the_compiler, env=env) cc_is_link, cc_link_path = getLinkTarget(cc_path) if cc_is_link and os.path.basename(cc_link_path) == "ccache": if show_scons_mode: scons_logger.info( "Chosen compiler %s is pointing to ccache %s already." % (cc_path, cc_link_path)) return True return _injectCcache( the_compiler=the_compiler, cc_path=cc_path, env=env, python_prefix=python_prefix, show_scons_mode=show_scons_mode, assume_yes_for_downloads=assume_yes_for_downloads, )
def enableCcache( the_compiler, env, source_dir, python_prefix, assume_yes_for_downloads, ): # The ccache needs absolute path, otherwise it will not work. ccache_logfile = os.path.abspath( os.path.join(source_dir, "ccache-%d.txt" % os.getpid()) ) setEnvironmentVariable(env, "CCACHE_LOGFILE", ccache_logfile) env["CCACHE_LOGFILE"] = ccache_logfile # Unless asked to do otherwise, store ccache files in our own directory. if "CCACHE_DIR" not in os.environ: ccache_dir = os.path.join(getCacheDir(), "ccache") makePath(ccache_dir) ccache_dir = getExternalUsePath(ccache_dir) setEnvironmentVariable(env, "CCACHE_DIR", ccache_dir) env["CCACHE_DIR"] = ccache_dir # First check if it's not already supposed to be a ccache, then do nothing. cc_path = getExecutablePath(the_compiler, env=env) cc_is_link, cc_link_path = getLinkTarget(cc_path) if cc_is_link and os.path.basename(cc_link_path) == "ccache": scons_details_logger.info( "Chosen compiler %s is pointing to ccache %s already." % (cc_path, cc_link_path) ) return True return _injectCcache( the_compiler=the_compiler, cc_path=cc_path, env=env, python_prefix=python_prefix, assume_yes_for_downloads=assume_yes_for_downloads, )