1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-16 17:07:43 +03:00

Improve prep_buildtree

When prep_buildtree is used to prepare a build tree when the source
directory already contains another build tree, then it will produce
the directory structure of the first build tree in the second one.
For example, if there is

postgresql/
postgresql/build1/

and a new build tree postgresql/build2/ is prepared, then this will
produce

postgresql/build2/build1/

because it just copies all subdirectories of the source tree.  This is
not harmful, but it's pretty stupid and can be confusing, and it slows
down prep_buildtree when there are many build trees.

When prep_buildtree was first created, it was more common for the
build tree to be outside the source tree, in which case this is not a
problem.  But now with the arrival of meson, it appears to be more
common (and also the way it is documented in the PostgreSQL
documentation) to have the build tree inside the source tree.  (To be
clear: This change does not affect meson at all.  But it would be an
issue for example if you have a meson build tree and a configure build
tree under the same source tree.)

To fix this, change the "find" command to process only those top-level
directories that we know about (namely config, contrib, doc, src).  (I
alternatively looked for ways to ignore directories that looked like
build directories, but that seemed extremely complicated.)  With that,
we can also remove the code that ignores directories related to
source-control management.

In passing, also remove the workaround for handling prebuilt docs,
since that has been obsolete since commit 54fac0e505.

Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/8b96b07f-1f48-46e9-b26e-01b2c9e4ac8d%40eisentraut.org
This commit is contained in:
Peter Eisentraut
2025-08-04 09:08:10 +02:00
parent 07684443b1
commit 6ae268cf28

View File

@@ -22,18 +22,14 @@ sourcetree=`cd $1 && pwd`
buildtree=`cd ${2:-'.'} && pwd` buildtree=`cd ${2:-'.'} && pwd`
# We must not auto-create the subdirectories holding built documentation. for item in `find "$sourcetree"/config "$sourcetree"/contrib "$sourcetree"/doc "$sourcetree"/src -type d -print`; do
# If we did, it would interfere with installation of prebuilt docs from
# the source tree, if a VPATH build is done from a distribution tarball.
# See bug #5595.
for item in `find "$sourcetree" -type d \( \( -name CVS -prune \) -o \( -name .git -prune \) -o -print \) | grep -v "$sourcetree/doc/src/sgml/\+"`; do
subdir=`expr "$item" : "$sourcetree\(.*\)"` subdir=`expr "$item" : "$sourcetree\(.*\)"`
if test ! -d "$buildtree/$subdir"; then if test ! -d "$buildtree/$subdir"; then
mkdir -p "$buildtree/$subdir" || exit 1 mkdir -p "$buildtree/$subdir" || exit 1
fi fi
done done
for item in `find "$sourcetree" -name Makefile -print -o -name GNUmakefile -print | grep -v "$sourcetree/doc/src/sgml/images/"`; do for item in "$sourcetree"/Makefile `find "$sourcetree"/config "$sourcetree"/contrib "$sourcetree"/doc "$sourcetree"/src -name Makefile -print -o -name GNUmakefile -print`; do
filename=`expr "$item" : "$sourcetree\(.*\)"` filename=`expr "$item" : "$sourcetree\(.*\)"`
if test ! -f "${item}.in"; then if test ! -f "${item}.in"; then
if cmp "$item" "$buildtree/$filename" >/dev/null 2>&1; then : ; else if cmp "$item" "$buildtree/$filename" >/dev/null 2>&1; then : ; else