Bug 906403 - Avoid subconfigure fail in incremental builds when some variable like CFLAGS change. r=gps

This commit is contained in:
Mike Hommey 2013-08-20 15:26:23 +09:00
parent be41d52866
commit e6301f2519
2 changed files with 88 additions and 0 deletions

View File

@ -6,6 +6,7 @@
# files and subsequently restore their timestamp if they haven't changed.
import os
import re
import subprocess
import sys
import pickle
@ -25,7 +26,50 @@ class File(object):
if open(self._path, 'rb').read() == self._content:
os.utime(self._path, self._times)
# As defined in the various sub-configures in the tree
PRECIOUS_VARS = set([
'build_alias',
'host_alias',
'target_alias',
'CC',
'CFLAGS',
'LDFLAGS',
'LIBS',
'CPPFLAGS',
'CPP',
'CCC',
'CXXFLAGS',
'CXX',
'CCASFLAGS',
'CCAS',
])
# Autoconf, in some of the sub-configures used in the tree, likes to error
# out when "precious" variables change in value. The solution it gives to
# straighten things is to either run make distclean or remove config.cache.
# There's no reason not to do the latter automatically instead of failing,
# doing the cleanup (which, on buildbots means a full clobber), and
# restarting from scratch.
def maybe_clear_cache():
comment = re.compile(r'^\s+#')
cache = {}
with open('config.cache') as f:
for line in f.readlines():
if not comment.match(line) and '=' in line:
key, value = line.split('=', 1)
cache[key] = value
for precious in PRECIOUS_VARS:
entry = 'ac_cv_env_%s_value' % precious
if entry in cache and (not precious in os.environ or os.environ[precious] != cache[entry]):
os.remove('config.cache')
return
def dump(dump_file, shell):
if os.path.exists('config.cache'):
maybe_clear_cache()
if not os.path.exists('config.status'):
if os.path.exists(dump_file):
os.remove(dump_file)

View File

@ -6,6 +6,7 @@
# files and subsequently restore their timestamp if they haven't changed.
import os
import re
import subprocess
import sys
import pickle
@ -25,7 +26,50 @@ class File(object):
if open(self._path, 'rb').read() == self._content:
os.utime(self._path, self._times)
# As defined in the various sub-configures in the tree
PRECIOUS_VARS = set([
'build_alias',
'host_alias',
'target_alias',
'CC',
'CFLAGS',
'LDFLAGS',
'LIBS',
'CPPFLAGS',
'CPP',
'CCC',
'CXXFLAGS',
'CXX',
'CCASFLAGS',
'CCAS',
])
# Autoconf, in some of the sub-configures used in the tree, likes to error
# out when "precious" variables change in value. The solution it gives to
# straighten things is to either run make distclean or remove config.cache.
# There's no reason not to do the latter automatically instead of failing,
# doing the cleanup (which, on buildbots means a full clobber), and
# restarting from scratch.
def maybe_clear_cache():
comment = re.compile(r'^\s+#')
cache = {}
with open('config.cache') as f:
for line in f.readlines():
if not comment.match(line) and '=' in line:
key, value = line.split('=', 1)
cache[key] = value
for precious in PRECIOUS_VARS:
entry = 'ac_cv_env_%s_value' % precious
if entry in cache and (not precious in os.environ or os.environ[precious] != cache[entry]):
os.remove('config.cache')
return
def dump(dump_file, shell):
if os.path.exists('config.cache'):
maybe_clear_cache()
if not os.path.exists('config.status'):
if os.path.exists(dump_file):
os.remove(dump_file)