提交 0ba08723 编写于 作者: K kevinw

8078437: Enable use of devkits for Windows

Reviewed-by: erikj, ihse
上级 07da4b10
......@@ -458,6 +458,15 @@ AC_DEFUN_ONCE([BASIC_SETUP_PATHS],
AUTOCONF_DIR=$TOPDIR/common/autoconf
])
# Evaluates platform specific overrides for devkit variables.
# $1: Name of variable
AC_DEFUN([BASIC_EVAL_DEVKIT_VARIABLE],
[
if test "x[$]$1" = x; then
eval $1="\${$1_${OPENJDK_TARGET_CPU}}"
fi
])
AC_DEFUN_ONCE([BASIC_SETUP_DEVKIT],
[
AC_ARG_WITH([devkit], [AS_HELP_STRING([--with-devkit],
......@@ -467,12 +476,27 @@ AC_DEFUN_ONCE([BASIC_SETUP_DEVKIT],
DEVKIT_ROOT="$with_devkit"
# Check for a meta data info file in the root of the devkit
if test -f "$DEVKIT_ROOT/devkit.info"; then
# This potentially sets the following:
# DEVKIT_NAME: A descriptive name of the devkit
# DEVKIT_TOOLCHAIN_PATH: Corresponds to --with-toolchain-path
# DEVKIT_EXTRA_PATH: Corresponds to --with-extra-path
# DEVKIT_SYSROOT: Corresponds to --with-sysroot
. $DEVKIT_ROOT/devkit.info
# This potentially sets the following:
# A descriptive name of the devkit
BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_NAME])
# Corresponds to --with-extra-path
BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_EXTRA_PATH])
# Corresponds to --with-toolchain-path
BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_TOOLCHAIN_PATH])
# Corresponds to --with-sysroot
BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_SYSROOT])
# Identifies the Visual Studio version in the devkit
BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_VS_VERSION])
# The Visual Studio include environment variable
BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_VS_INCLUDE])
# The Visual Studio lib environment variable
BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_VS_LIB])
# Corresponds to --with-msvcr-dll
BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_MSVCR_DLL])
# Corresponds to --with-msvcp-dll
BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_MSVCP_DLL])
fi
AC_MSG_CHECKING([for devkit])
......@@ -482,9 +506,7 @@ AC_DEFUN_ONCE([BASIC_SETUP_DEVKIT],
AC_MSG_RESULT([$DEVKIT_ROOT])
fi
if test "x$DEVKIT_EXTRA_PATH" != x; then
BASIC_PREPEND_TO_PATH([EXTRA_PATH],$DEVKIT_EXTRA_PATH)
fi
# Fallback default of just /bin if DEVKIT_PATH is not defined
if test "x$DEVKIT_TOOLCHAIN_PATH" = x; then
......@@ -598,7 +620,11 @@ AC_DEFUN_ONCE([BASIC_SETUP_OUTPUT_DIR],
files_present=`$LS $OUTPUT_ROOT`
# Configure has already touched config.log and confdefs.h in the current dir when this check
# is performed.
filtered_files=`$ECHO "$files_present" | $SED -e 's/config.log//g' -e 's/confdefs.h//g' -e 's/ //g' \
filtered_files=`$ECHO "$files_present" \
| $SED -e 's/config.log//g' \
-e 's/confdefs.h//g' \
-e 's/fixpath.exe//g' \
-e 's/ //g' \
| $TR -d '\n'`
if test "x$filtered_files" != x; then
AC_MSG_NOTICE([Current directory is $CURDIR.])
......
......@@ -66,7 +66,7 @@ AC_DEFUN([BASIC_MAKE_WINDOWS_SPACE_SAFE_CYGWIN],
# Going to short mode and back again did indeed matter. Since short mode is
# case insensitive, let's make it lowercase to improve readability.
shortmode_path=`$ECHO "$shortmode_path" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
# Now convert it back to Unix-stile (cygpath)
# Now convert it back to Unix-style (cygpath)
input_path=`$CYGPATH -u "$shortmode_path"`
new_path="$input_path"
fi
......
......@@ -217,11 +217,15 @@ AC_DEFUN_ONCE([TOOLCHAIN_PRE_DETECTION],
ORG_CXXFLAGS="$CXXFLAGS"
ORG_OBJCFLAGS="$OBJCFLAGS"
# autoconf magic only relies on PATH, so update it if tools dir is specified
OLD_PATH="$PATH"
# On Windows, we need to detect the visual studio installation first.
# This will change the PATH, but we need to keep that new PATH even
# after toolchain detection is done, since the compiler (on x86) uses
# it for DLL resolution in runtime.
if test "x$OPENJDK_BUILD_OS" = "xwindows" && test "x$TOOLCHAIN_TYPE" = "xmicrosoft"; then
if test "x$OPENJDK_BUILD_OS" = "xwindows" \
&& test "x$TOOLCHAIN_TYPE" = "xmicrosoft"; then
TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV
# Reset path to VS_PATH. It will include everything that was on PATH at the time we
# ran TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV.
......@@ -231,9 +235,6 @@ AC_DEFUN_ONCE([TOOLCHAIN_PRE_DETECTION],
export LIB="$VS_LIB"
fi
# autoconf magic only relies on PATH, so update it if tools dir is specified
OLD_PATH="$PATH"
# Before we locate the compilers, we need to sanitize the Xcode build environment
if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
# determine path to Xcode developer directory
......
......@@ -210,6 +210,37 @@ AC_DEFUN([TOOLCHAIN_FIND_VISUAL_STUDIO],
done
exit 0
elif test "x$DEVKIT_VS_VERSION" != x; then
VS_VERSION=$DEVKIT_VS_VERSION
TOOLCHAIN_VERSION=$VS_VERSION
eval VS_DESCRIPTION="\${VS_DESCRIPTION_${VS_VERSION}}"
eval VS_VERSION_INTERNAL="\${VS_VERSION_INTERNAL_${VS_VERSION}}"
eval MSVCR_NAME="\${VS_MSVCR_${VS_VERSION}}"
eval MSVCP_NAME="\${VS_MSVCP_${VS_VERSION}}"
eval PLATFORM_TOOLSET="\${VS_VS_PLATFORM_NAME_${VS_VERSION}}"
VS_PATH="$TOOLCHAIN_PATH:$PATH"
# Convert DEVKIT_VS_INCLUDE into windows style VS_INCLUDE so that it
# can still be exported as INCLUDE for compiler invocations without
# SYSROOT_CFLAGS
OLDIFS="$IFS"
IFS=";"
for i in $DEVKIT_VS_INCLUDE; do
ipath=$i
BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH([ipath])
VS_INCLUDE="$VS_INCLUDE;$ipath"
done
# Convert DEVKIT_VS_LIB into VS_LIB so that it can still be exported
# as LIB for compiler invocations without SYSROOT_LDFLAGS
for i in $DEVKIT_VS_LIB; do
libpath=$i
BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH([libpath])
VS_LIB="$VS_LIB;$libpath"
done
IFS="$OLDIFS"
AC_MSG_NOTICE([Found devkit $VS_DESCRIPTION])
elif test "x$with_toolchain_version" != x; then
# User override; check that it is valid
if test "x${VALID_VS_VERSIONS/$with_toolchain_version/}" = "x${VALID_VS_VERSIONS}"; then
......@@ -262,6 +293,8 @@ AC_DEFUN([TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV],
# First-hand choice is to locate and run the vsvars bat file.
TOOLCHAIN_FIND_VISUAL_STUDIO
# If we have a devkit, skip all of the below.
if test "x$DEVKIT_VS_VERSION" = x; then
if test "x$VS_ENV_CMD" != x; then
# We have found a Visual Studio environment on disk, let's extract variables from the vsvars bat file.
BASIC_FIXUP_EXECUTABLE(VS_ENV_CMD)
......@@ -291,12 +324,18 @@ AC_DEFUN([TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV],
# C:/CygWin/bin/bash -c 'echo VS_PATH=\"$PATH\" > localdevenv.sh
# The trailing space for everyone except PATH is no typo, but is needed due
# to trailing \ in the Windows paths. These will be stripped later.
$ECHO "$WINPATH_BASH -c 'echo VS_PATH="'\"$PATH\" > set-vs-env.sh' >> $EXTRACT_VC_ENV_BAT_FILE
$ECHO "$WINPATH_BASH -c 'echo VS_INCLUDE="'\"$INCLUDE \" >> set-vs-env.sh' >> $EXTRACT_VC_ENV_BAT_FILE
$ECHO "$WINPATH_BASH -c 'echo VS_LIB="'\"$LIB \" >> set-vs-env.sh' >> $EXTRACT_VC_ENV_BAT_FILE
$ECHO "$WINPATH_BASH -c 'echo VCINSTALLDIR="'\"$VCINSTALLDIR \" >> set-vs-env.sh' >> $EXTRACT_VC_ENV_BAT_FILE
$ECHO "$WINPATH_BASH -c 'echo WindowsSdkDir="'\"$WindowsSdkDir \" >> set-vs-env.sh' >> $EXTRACT_VC_ENV_BAT_FILE
$ECHO "$WINPATH_BASH -c 'echo WINDOWSSDKDIR="'\"$WINDOWSSDKDIR \" >> set-vs-env.sh' >> $EXTRACT_VC_ENV_BAT_FILE
$ECHO "$WINPATH_BASH -c 'echo VS_PATH="'\"$PATH\" > set-vs-env.sh' \
>> $EXTRACT_VC_ENV_BAT_FILE
$ECHO "$WINPATH_BASH -c 'echo VS_INCLUDE="'\"$INCLUDE \" >> set-vs-env.sh' \
>> $EXTRACT_VC_ENV_BAT_FILE
$ECHO "$WINPATH_BASH -c 'echo VS_LIB="'\"$LIB \" >> set-vs-env.sh' \
>> $EXTRACT_VC_ENV_BAT_FILE
$ECHO "$WINPATH_BASH -c 'echo VCINSTALLDIR="'\"$VCINSTALLDIR \" >> set-vs-env.sh' \
>> $EXTRACT_VC_ENV_BAT_FILE
$ECHO "$WINPATH_BASH -c 'echo WindowsSdkDir="'\"$WindowsSdkDir \" >> set-vs-env.sh' \
>> $EXTRACT_VC_ENV_BAT_FILE
$ECHO "$WINPATH_BASH -c 'echo WINDOWSSDKDIR="'\"$WINDOWSSDKDIR \" >> set-vs-env.sh' \
>> $EXTRACT_VC_ENV_BAT_FILE
# Now execute the newly created bat file.
# The | cat is to stop SetEnv.Cmd to mess with system colors on msys.
......@@ -322,11 +361,13 @@ AC_DEFUN([TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV],
# We did not find a vsvars bat file, let's hope we are run from a VS command prompt.
AC_MSG_NOTICE([Cannot locate a valid Visual Studio installation, checking current environment])
fi
fi
# At this point, we should have correct variables in the environment, or we can't continue.
AC_MSG_CHECKING([for Visual Studio variables])
if test "x$VCINSTALLDIR" != x || test "x$WindowsSDKDir" != x || test "x$WINDOWSSDKDIR" != x; then
if test "x$VCINSTALLDIR" != x || test "x$WindowsSDKDir" != x \
|| test "x$WINDOWSSDKDIR" != x || test "x$DEVKIT_NAME" != x; then
if test "x$VS_INCLUDE" = x || test "x$VS_LIB" = x; then
AC_MSG_RESULT([present but broken])
AC_MSG_ERROR([Your VC command prompt seems broken, INCLUDE and/or LIB is missing.])
......@@ -367,10 +408,10 @@ AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL],
POSSIBLE_MSVC_DLL="$2"
METHOD="$3"
if test -n "$POSSIBLE_MSVC_DLL" -a -e "$POSSIBLE_MSVC_DLL"; then
AC_MSG_NOTICE([Found $1 at $POSSIBLE_MSVC_DLL using $METHOD])
AC_MSG_NOTICE([Found $DLL_NAME at $POSSIBLE_MSVC_DLL using $METHOD])
# Need to check if the found msvcr is correct architecture
AC_MSG_CHECKING([found $1 architecture])
AC_MSG_CHECKING([found $DLL_NAME architecture])
MSVC_DLL_FILETYPE=`$FILE -b "$POSSIBLE_MSVC_DLL"`
if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
# The MSYS 'file' command returns "PE32 executable for MS Windows (DLL) (GUI) Intel 80386 32-bit"
......@@ -390,19 +431,19 @@ AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL],
if $ECHO "$MSVC_DLL_FILETYPE" | $GREP "$CORRECT_MSVCR_ARCH" 2>&1 > /dev/null; then
AC_MSG_RESULT([ok])
MSVC_DLL="$POSSIBLE_MSVC_DLL"
AC_MSG_CHECKING([for $1])
BASIC_FIXUP_PATH(MSVC_DLL)
AC_MSG_CHECKING([for $DLL_NAME])
AC_MSG_RESULT([$MSVC_DLL])
else
AC_MSG_RESULT([incorrect, ignoring])
AC_MSG_NOTICE([The file type of the located $1 is $MSVC_DLL_FILETYPE])
AC_MSG_NOTICE([The file type of the located $DLL_NAME is $MSVC_DLL_FILETYPE])
fi
fi
])
AC_DEFUN([TOOLCHAIN_SETUP_MSVC_DLL],
[
VAR_NAME="$1"
DLL_NAME="$2"
DLL_NAME="$1"
MSVC_DLL=
if test "x$MSVC_DLL" = x; then
......@@ -481,10 +522,6 @@ AC_DEFUN([TOOLCHAIN_SETUP_MSVC_DLL],
AC_MSG_RESULT([no])
AC_MSG_ERROR([Could not find $DLL_NAME. Please specify using --with-msvcr-dll.])
fi
$1=$MSVC_DLL
BASIC_FIXUP_PATH($1)
AC_SUBST($1, [$]$1)
])
AC_DEFUN([TOOLCHAIN_SETUP_VS_RUNTIME_DLLS],
......@@ -494,14 +531,22 @@ AC_DEFUN([TOOLCHAIN_SETUP_VS_RUNTIME_DLLS],
if test "x$with_msvcr_dll" != x; then
# If given explicitely by user, do not probe. If not present, fail directly.
TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$with_msvcr_dll],
[--with-msvcr-dll])
TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL($MSVCR_NAME, [$with_msvcr_dll], [--with-msvcr-dll])
if test "x$MSVC_DLL" = x; then
AC_MSG_ERROR([Could not find a proper $MSVCR_NAME as specified by --with-msvcr-dll])
fi
MSVCR_DLL="$MSVC_DLL"
elif test "x$DEVKIT_MSVCR_DLL" != x; then
TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL($MSVCR_NAME, [$DEVKIT_MSVCR_DLL], [devkit])
if test "x$MSVC_DLL" = x; then
AC_MSG_ERROR([Could not find a proper $MSVCR_NAME as specified by devkit])
fi
MSVCR_DLL="$MSVC_DLL"
else
TOOLCHAIN_SETUP_MSVC_DLL([MSVCR_DLL], [${MSVCR_NAME}])
TOOLCHAIN_SETUP_MSVC_DLL([${MSVCR_NAME}])
MSVCR_DLL="$MSVC_DLL"
fi
AC_SUBST(MSVCR_DLL)
AC_ARG_WITH(msvcp-dll, [AS_HELP_STRING([--with-msvcp-dll],
[path to microsoft C++ runtime dll (msvcp*.dll) (Windows only) @<:@probed@:>@])])
......@@ -509,14 +554,22 @@ AC_DEFUN([TOOLCHAIN_SETUP_VS_RUNTIME_DLLS],
if test "x$MSVCP_NAME" != "x"; then
if test "x$with_msvcp_dll" != x; then
# If given explicitely by user, do not probe. If not present, fail directly.
TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$with_msvcp_dll],
[--with-msvcp-dll])
TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL($MSVCP_NAME, [$with_msvcp_dll], [--with-msvcp-dll])
if test "x$MSVC_DLL" = x; then
AC_MSG_ERROR([Could not find a proper $MSVCP_NAME as specified by --with-msvcp-dll])
fi
MSVCP_DLL="$MSVC_DLL"
elif test "x$DEVKIT_MSVCP_DLL" != x; then
TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL($MSVCP_NAME, [$DEVKIT_MSVCP_DLL], [devkit])
if test "x$MSVC_DLL" = x; then
AC_MSG_ERROR([Could not find a proper $MSVCP_NAME as specified by devkit])
fi
MSVCP_DLL="$MSVC_DLL"
else
TOOLCHAIN_SETUP_MSVC_DLL([MSVCP_DLL], [${MSVCP_NAME}])
TOOLCHAIN_SETUP_MSVC_DLL([${MSVCP_NAME}])
MSVCP_DLL="$MSVC_DLL"
fi
AC_SUBST(MSVCP_DLL)
fi
])
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册