wsl-as-helper: avoid misdetecting builddir!=srcdir with long paths

when the user runs wsl.exe ./autogen.sh in a long path, the build
initially works OK, it will realize that the build is performed in the
source directory.
However if another run of wsl.exe ./autogen.sh is triggered by running
make (i.e. when configure.ac or some of the other files gets changed),
it was run with the shortened version of the path as the value for
SRCDIR, and comparing that with the pathname of the current directory
(which most likely was browsed to by using the long form) resulted in a
misdetection of the builddir != srcdir case, and autogen.sh did try to
create the necessary symlinks and <module>/Makefile and
external/*/Makefile files as if building in a separate build directory.
Especially the self-referencing symlink in the include dir then caused
some parts of the build (skia) to fail.

To avoid this problem, explicitly convert the path to its long-form.
This alone is not enough however to prevent the same issue occuring when
the user changed to the srcdir using the shortened form, then the
conversion would fail the same way (and while it is unlikely that the
user uses that path manually, launching a terminal via the
vscode-integration for example would also use the shortened form). So
also cd to the long form of BUILDDIR when running the automatically
triggered autogen.sh

Change-Id: I02c1ee7d302daa6062b6a049d924f40a49217e5c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180511
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
Tested-by: Jenkins
This commit is contained in:
Christian Lohmaier
2025-01-21 11:42:51 +01:00
parent 524c266f0f
commit 206ac992eb
+5 -3
View File
@@ -40,8 +40,10 @@ Makefile $(BUILDDIR)/Makefile: $(BUILDDIR)/config_host.mk $(BUILDDIR)/config_hos
# run configure in an environment not polluted by config_host.mk
ifneq ($(MSYSTEM),)
WSL:=@WSL@
# wsl needs unix-style path into windows realm
$(BUILDDIR)/config_host.mk : SRCDIR:=/$(shell $(WSL) wslpath -u $(SRCDIR))
# wsl needs unix-style path into windows realm, use long form to avoid confusing autogen.sh wrt
# builddir != srcdir when in actually it is just srcdir-in-shortform vs srcdir-in-longform
# for the same reason cd to the longform of BUILDDIR
$(BUILDDIR)/config_host.mk : SRCDIR:=/$(shell $(WSL) wslpath -u $(shell cygpath -ml $(SRCDIR)))
endif
$(BUILDDIR)/config_host.mk : $(wildcard \
$(SRCDIR)/autogen.sh \
@@ -57,7 +59,7 @@ $(BUILDDIR)/config_host.mk : $(wildcard \
$(BUILDDIR)/autogen.lastrun \
) \
$(shell if test -n '$(JAVA_HOME)' -a ! -d '$(JAVA_HOME)'; then echo force-restart; fi)
sh -c "$(if $(MSYSTEM),$(WSL) )$(SRCDIR)/autogen.sh"
sh -c "$(if $(MSYSTEM),cd $(shell cygpath -ml $(BUILDDIR)); $(WSL) )$(SRCDIR)/autogen.sh"
else # MAKE_RESTARTS