8206125: [windows] cannot pass relative path to --with-boot-jdk
authorerikj
Mon, 23 Sep 2019 08:52:05 -0700
changeset 58270 2921ee5e9881
parent 58269 7a8de392f9e1
child 58272 e27564cd10e3
8206125: [windows] cannot pass relative path to --with-boot-jdk Reviewed-by: tbell
make/autoconf/basics.m4
make/autoconf/basics_windows.m4
--- a/make/autoconf/basics.m4	Mon Sep 23 09:00:28 2019 -0700
+++ b/make/autoconf/basics.m4	Mon Sep 23 08:52:05 2019 -0700
@@ -205,6 +205,32 @@
   fi
 ])
 
+################################################################################
+# This will make a path absolute. Assumes it's already a unix path. Also
+# resolves ~ to homedir.
+AC_DEFUN([BASIC_ABSOLUTE_PATH],
+[
+  if test "x[$]$1" != x; then
+    new_path="[$]$1"
+
+    if [ [[ "$new_path" = ~* ]] ]; then
+      # Use eval to expand a potential ~
+      eval new_path="$new_path"
+      if test ! -f "$new_path" && test ! -d "$new_path"; then
+        AC_MSG_ERROR([The new_path of $1, which resolves as "$new_path", is not found.])
+      fi
+    fi
+
+    if test -d "$new_path"; then
+      $1="`cd "$new_path"; $THEPWDCMD -L`"
+    else
+      dir="`$DIRNAME "$new_path"`"
+      base="`$BASENAME "$new_path"`"
+      $1="`cd "$dir"; $THEPWDCMD -L`/$base"
+    fi
+  fi
+])
+
 ###############################################################################
 # This will make sure the given variable points to a full and proper
 # path. This means:
@@ -217,7 +243,6 @@
 AC_DEFUN([BASIC_FIXUP_PATH],
 [
   # Only process if variable expands to non-empty
-
   if test "x[$]$1" != x; then
     if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
       BASIC_FIXUP_PATH_CYGWIN($1)
@@ -234,19 +259,8 @@
         AC_MSG_ERROR([Spaces are not allowed in this path.])
       fi
 
-      # Use eval to expand a potential ~
-      eval path="$path"
-      if test ! -f "$path" && test ! -d "$path"; then
-        AC_MSG_ERROR([The path of $1, which resolves as "$path", is not found.])
-      fi
-
-      if test -d "$path"; then
-        $1="`cd "$path"; $THEPWDCMD -L`"
-      else
-        dir="`$DIRNAME "$path"`"
-        base="`$BASENAME "$path"`"
-        $1="`cd "$dir"; $THEPWDCMD -L`/$base"
-      fi
+      BASIC_ABSOLUTE_PATH(path)
+      $1="$path"
     fi
   fi
 ])
--- a/make/autoconf/basics_windows.m4	Mon Sep 23 09:00:28 2019 -0700
+++ b/make/autoconf/basics_windows.m4	Mon Sep 23 08:52:05 2019 -0700
@@ -148,6 +148,8 @@
   path="[$]$1"
   new_path=`$CYGPATH -u "$path"`
 
+  BASIC_ABSOLUTE_PATH(new_path)
+
   # Cygwin tries to hide some aspects of the Windows file system, such that binaries are
   # named .exe but called without that suffix. Therefore, "foo" and "foo.exe" are considered
   # the same file, most of the time (as in "test -f"). But not when running cygpath -s, then
@@ -181,6 +183,8 @@
     new_path=`cmd //c echo $path`
   fi
 
+  BASIC_ABSOLUTE_PATH(new_path)
+
   BASIC_MAKE_WINDOWS_SPACE_SAFE_MSYS([$new_path])
   BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(new_path)
   if test "x$path" != "x$new_path"; then
@@ -199,6 +203,8 @@
   new_path="[$]$1"
   BASIC_WINDOWS_REWRITE_AS_UNIX_PATH([new_path])
 
+  BASIC_ABSOLUTE_PATH(new_path)
+
   # Call helper function which possibly converts this using DOS-style short mode.
   # If so, the updated path is stored in $new_path.
   BASIC_MAKE_WINDOWS_SPACE_SAFE_WSL([$new_path])