improve builddir!=srcdir detection with case-preserving filesystems

on Windows and macOS autogen.sh could misdetect the build directory as
being different from the source directory if the filesystem is
case-preserving but not case-sensitive. e.g.

cd ~/BuildDir ; ~/builddir/autogen.sh

It is the same directory, but treated as a different one and thus
autogen would create the module/Makefile files and also a link to the
include directory. That however then ends up being a include/include
link and that then fails the skia build.

So use the same method to get both paths to avoid the problem.
Change from cwd() to getcwd() since despite the documentation saying it
would be the same, getcwd is actually returning the actual name as
stored in the filesystem. Also use the module's chdir so that the PWD
environment variable doesn't need to be set manually.

Change-Id: I705dc584a91be9f63052bd1f72d4a0c4ba73f3ec
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187536
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
Reviewed-by: Regina Henschel <rb.henschel@t-online.de>
Tested-by: Jenkins
This commit is contained in:
Christian Lohmaier
2025-07-08 12:14:32 +02:00
parent 0591935971
commit 037de86626

View File

@ -17,19 +17,24 @@
if 0;
use strict;
use Cwd ('cwd', 'realpath');
# use Cwd's chdir to also set PWD environment variable
use Cwd ('chdir', 'getcwd', 'realpath');
use File::Basename;
my $src_path=dirname(realpath($0));
my $build_path=realpath(cwd());
my $build_path=realpath(getcwd());
# workaround for case-preserving filesystems to get the canonical name
# otherwise the src_path may be different from the build_path by case only
# and mess up the builddir != srcdir handling
chdir($src_path);
$src_path=getcwd();
# since this looks crazy, if you have a symlink on a path up to and including
# the current directory, we need our configure to run in the realpath of that
# such that compiled (realpath'd) dependency filenames match the filenames
# used in our makefiles - ie. this gets dependencies right via SRC_ROOT
chdir ($build_path);
# more amazingly, if you don't clobber 'PWD' shells will re-assert their
# old path from the environment, not cwd.
$ENV{PWD} = $build_path;
my $aclocal;
my $autoconf;