aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/compilers.py
diff options
context:
space:
mode:
authorLoïc Yhuel <loic.yhuel@softathome.com>2020-03-19 14:36:44 +0100
committerJussi Pakkanen <jpakkane@gmail.com>2020-03-29 21:15:08 +0300
commitb9b118b267219e6ac8d6f0d5e5c73152e88b8269 (patch)
tree9ea770f21c26cd44743b0b430de46c8c9234ae7e /mesonbuild/compilers/compilers.py
parentf4d98a3e72d567c18304d61aab731ebdb881f76a (diff)
downloadmeson-b9b118b267219e6ac8d6f0d5e5c73152e88b8269.zip
meson-b9b118b267219e6ac8d6f0d5e5c73152e88b8269.tar.gz
meson-b9b118b267219e6ac8d6f0d5e5c73152e88b8269.tar.bz2
compilers: disable ccache when using temporary source files
When doing a compile test with a testfile.c, ccache fails since the path is random. So it's better to disable it, to avoid reporting this as a cache miss.
Diffstat (limited to 'mesonbuild/compilers/compilers.py')
-rw-r--r--mesonbuild/compilers/compilers.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index b461f2d..2caddde 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -959,11 +959,14 @@ class Compiler:
extra_args = []
try:
with tempfile.TemporaryDirectory(dir=temp_dir) as tmpdirname:
+ no_ccache = False
if isinstance(code, str):
srcname = os.path.join(tmpdirname,
'testfile.' + self.default_suffix)
with open(srcname, 'w') as ofile:
ofile.write(code)
+ # ccache would result in a cache miss
+ no_ccache = True
elif isinstance(code, mesonlib.File):
srcname = code.fname
@@ -987,6 +990,8 @@ class Compiler:
mlog.debug('Code:\n', code)
os_env = os.environ.copy()
os_env['LC_ALL'] = 'C'
+ if no_ccache:
+ os_env['CCACHE_DISABLE'] = '1'
p, p.stdo, p.stde = Popen_safe(commands, cwd=tmpdirname, env=os_env)
mlog.debug('Compiler stdout:\n', p.stdo)
mlog.debug('Compiler stderr:\n', p.stde)