LUMIERA.clone/admin/scons/ToolCCache.py
benn 406275abbe Upgrade: adapt to use Scons 4.x which uses Python 3
The build system Scons switched from using Python 2.7 to using
Python 3.x, so the build breaks on, for example, Debian Bullseye.

As a first step use `ato3` to convert Python scripts from 2 to 3.
2025-03-16 16:38:07 +01:00

67 lines
2 KiB
Python
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# coding: utf-8
##
## ToolCCache.py - SCons tool for integrating with CCache compiler cache
##
# Copyright (C) Lumiera.org and FreeOrion.org
# 2008, Hermann Vosseler <Ichthyostega@web.de>
#
# **Lumiera** is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version. See the file COPYING for further details.
#####################################################################
# This SCons builder was extracted from http://www.freeorion.org/
# FreeOrion is an open-source platform-independent galactic conquest game
#
# history: 12/2008 adapted for Lumiera build system
import os
from Buildhelper import *
def generate(env):
""" Modify the environment such as to redirect any
C/C++ compiler invocations through CCache, while using
CCache config variables found in the os.environment.
"""
if not exists(env): return
assert env['CCACHE']
if not env['CCACHE'] in env['CC']:
env['CC'] = env.subst('$CCACHE $CC')
if not env['CCACHE'] in env['CXX']:
env['CXX'] = env.subst('$CCACHE $CXX')
print(env.subst("* Build using $CCACHE"))
for i in ['HOME'
,'CCACHE_DIR'
,'CCACHE_TEMPDIR'
,'CCACHE_LOGFILE'
,'CCACHE_PATH'
,'CCACHE_CC'
,'CCACHE_CPP2'
,'CCACHE_PREFIX'
,'CCACHE_DISABLE'
,'CCACHE_READONLY'
,'CCACHE_NOSTATS'
,'CCACHE_NLEVELS'
,'CCACHE_HARDLINK'
,'CCACHE_RECACHE'
,'CCACHE_UMASK'
,'CCACHE_HASHDIR'
,'CCACHE_UNIFY'
,'CCACHE_EXTENSION'
]:
if i in os.environ and i not in env:
env['ENV'][i] = os.environ[i]
def exists(env):
""" Ensure CCache is available.
"""
return checkCommandOption(env, 'CCACHE', cmdName='ccache')