Bug 97954: Compare SpiderMonkey's copies of build files with originals at check time. r=luser

SpiderMonkey now has its own copy of some of the files from ./config
and ./build.  Since there is a decent amount of churn in that area, I
don't want it to become a burden to make merges back and forth.  This
patch adds a comment explaining the 'identical if present' policy, and
runs a script to verify that it's actually being observed.
This commit is contained in:
Jim Blandy 2008-10-29 08:40:39 -07:00
parent 216f4ef465
commit e8bc490fa7
7 changed files with 148 additions and 7 deletions

View File

@ -8289,6 +8289,7 @@ ac_configure_args="$ac_configure_args --with-nspr-libs='$NSPR_LIBS'"
ac_configure_args="$ac_configure_args --includedir=$dist/include"
ac_configure_args="$ac_configure_args --bindir=$dist/bin"
ac_configure_args="$ac_configure_args --libdir=$dist/lib"
ac_configure_args="$ac_configure_args --with-sync-build-files=$srcdir"
if test "$MOZ_MEMORY"; then
ac_configure_args="$ac_configure_args --enable-jemalloc"
fi

View File

@ -333,6 +333,27 @@ endif
include $(topsrcdir)/config/rules.mk
ifdef MOZ_SYNC_BUILD_FILES
# Because the SpiderMonkey can be distributed and built independently
# of the Mozilla source tree, it contains its own copies of many of
# the files used by the top-level Mozilla build process, from the
# 'config' and 'build' subtrees.
#
# To make it simpler to keep the copies in sync, we follow the policy
# that the SpiderMonkey copies must always be exact copies of those in
# the containing Mozilla tree. If you've made a change in one, it
# belongs in the other as well. If the change isn't right for both
# places, then that's something to bring up with the other developers.
#
# Some files are reasonable to diverge; for example,
# js/config/autoconf.mk.in doesn't need most of the stuff in
# config/autoconf.mk.in.
check-sync-dirs = $(PYTHON) $(srcdir)/config/check-sync-dirs.py
check::
$(check-sync-dirs) $(srcdir)/config $(MOZ_SYNC_BUILD_FILES)/config
$(check-sync-dirs) $(srcdir)/build $(MOZ_SYNC_BUILD_FILES)/build
endif
# our build system doesn't handle subdir srcs very gracefully today
export::
mkdir -p nanojit

View File

@ -68,6 +68,8 @@ DIST = $(DEPTH)/dist
MOZ_JS_LIBS = @MOZ_JS_LIBS@
MOZ_SYNC_BUILD_FILES = @MOZ_SYNC_BUILD_FILES@
MOZ_DEBUG = @MOZ_DEBUG@
MOZ_DEBUG_MODULES = @MOZ_DEBUG_MODULES@
MOZ_PROFILE_MODULES = @MOZ_PROFILE_MODULES@

View File

@ -0,0 +1,108 @@
# check-sync-dirs.py --- check that one directory is an exact subset of another
#
# Usage: python check-sync-dirs.py COPY ORIGINAL
#
# Check that the files present in the directory tree COPY are exact
# copies of their counterparts in the directory tree ORIGINAL. COPY
# need not have all the files in ORIGINAL, but COPY may not have files
# absent from ORIGINAL.
#
# Each directory in COPY may have a file named
# 'check-sync-exceptions', which lists files in COPY that need not be
# the same as the corresponding file in ORIGINAL, or exist at all in
# ORIGINAL. (The 'check-sync-exceptions' file itself is always
# treated as exceptional.) Blank lines and '#' comments in the file
# are ignored.
import sys
import os
from os.path import join
import filecmp
import textwrap
import fnmatch
if len(sys.argv) != 3:
print >> sys.stderr, "Usage: %s COPY ORIGINAL" % sys.argv[0]
sys.exit(1)
copy = sys.argv[1]
original = sys.argv[2]
# Ignore detritus left lying around by editing tools.
ignored_patterns = ['*~', '.#*', '#*#', '*.orig', '*.rej']
# Return the contents of FILENAME, a 'check-sync-exceptions' file, as
# a dictionary whose keys are exactly the list of filenames, along
# with the basename of FILENAME itself. If FILENAME does not exist,
# return the empty dictionary.
def read_exceptions(filename):
if (os.path.exists(filename)):
f = file(filename)
exceptions={}
for line in f:
line = line.strip()
if line != '' and line[0] != '#':
exceptions[line] = None
exceptions[os.path.basename (filename)] = None
f.close()
return exceptions
else:
return {}
# Return true if FILENAME matches any pattern in the list of filename
# patterns PATTERNS.
def fnmatch_any(filename, patterns):
for pattern in patterns:
if fnmatch.fnmatch(filename, pattern):
return True
return False
# Check the contents of COPY/SUBDIR against ORIGINAL/SUBDIR. For each
# file that differs, apply REPORT to COPY, ORIGINAL, and the file's
# relative path. COPY and ORIGINAL should be absolute. Ignore files
# that match patterns given in the list IGNORE.
def check(copy, original, ignore, report):
os.chdir(copy)
for (dirpath, dirnames, filenames) in os.walk('.'):
exceptions = read_exceptions(join(dirpath, 'check-sync-exceptions'))
for filename in filenames:
if filename in exceptions:
continue
if fnmatch_any(filename, ignore):
continue
relative_name = join(dirpath, filename)
original_name = join(original, relative_name)
if (os.path.exists(original_name)
and filecmp.cmp(relative_name, original_name)):
continue
report(copy, original, relative_name)
differences_found = False
# Print an error message for DIFFERING, which was found to differ
# between COPY and ORIGINAL. Set the global variable differences_found.
def report(copy, original, differing):
global differences_found
if not differences_found:
print >> sys.stderr, "TEST-FAIL | build file copies are not in sync"
print >> sys.stderr, "file(s) found in: %s" % (copy)
print >> sys.stderr, ("differ from their originals in: %s"
% (original))
print >> sys.stderr, "file differs: %s" % (differing)
differences_found = True
check(os.path.abspath(copy),
os.path.abspath(original),
ignored_patterns,
report)
if differences_found:
msg=('''In general, the files in '%s' should always be exact copies of
originals in '%s'. A change made to one should also be made to the
other. See 'check-sync-dirs.py' for more details.'''
% (copy, original))
print >> sys.stderr, textwrap.fill(msg, 75)
sys.exit(1)
sys.exit(0)

View File

@ -0,0 +1,6 @@
Makefile.in
autoconf.mk.in
check-sync-dirs.py
# This is a copy of nspr's config/make-system-wrappers.pl.
make-system-wrappers.pl

View File

@ -103,11 +103,7 @@ _SUBDIR_CONFIG_ARGS="$ac_configure_args"
dnl Set the version number of the libs included with mozilla
dnl ========================================================
MOZJPEG=62
MOZPNG=10217
MOZZLIB=0x1230
NSPR_VERSION=4
NSS_VERSION=3
dnl Set the minimum version of toolkit libs used by mozilla
dnl ========================================================
@ -1977,8 +1973,6 @@ case "$target" in
fi
fi
fi
MOZ_JPEG_LIBS='$(call EXPAND_LIBNAME_PATH,jpeg$(MOZ_BITS)$(VERSION_NUMBER),$(DEPTH)/jpeg)'
MOZ_PNG_LIBS='$(call EXPAND_LIBNAME_PATH,png,$(DEPTH)/modules/libimg/png)'
AC_DEFINE(HAVE_SNPRINTF)
AC_DEFINE(_WINDOWS)
AC_DEFINE(_WIN32)
@ -4831,6 +4825,15 @@ if test "$MOZ_DEBUG" || test "$NS_TRACE_MALLOC"; then
MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS=
fi
MOZ_ARG_WITH_STRING(sync-build-files,
[ --with-sync-build-files=DIR
Check that files in 'config' and 'build' match
their originals in 'DIR/config' and 'DIR/build'.
This helps keep the SpiderMonkey build machinery
in sync with Mozilla's, on which it is based.],
[MOZ_SYNC_BUILD_FILES=$withval ] )
AC_SUBST(MOZ_SYNC_BUILD_FILES)
dnl ========================================================
dnl =
dnl = Maintainer debug option (no --enable equivalent)

2
nsprpub/configure vendored
View File

@ -6016,7 +6016,7 @@ s%\[%\\&%g
s%\]%\\&%g
s%\$%$$%g
EOF
DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' ' | tr '\015' ' '`
DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '`
rm -f conftest.defs