author | rriggs |
Fri, 04 Jan 2019 12:30:20 -0500 | |
changeset 53145 | 41af13b70efd |
parent 53141 | 6f2d65f29de3 |
child 53992 | cf4c3a118d2b |
permissions | -rw-r--r-- |
31124 | 1 |
#!/bin/bash |
2 |
# |
|
53141 | 3 |
# Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. |
31124 | 4 |
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5 |
# |
|
6 |
# This code is free software; you can redistribute it and/or modify it |
|
7 |
# under the terms of the GNU General Public License version 2 only, as |
|
8 |
# published by the Free Software Foundation. Oracle designates this |
|
9 |
# particular file as subject to the "Classpath" exception as provided |
|
10 |
# by Oracle in the LICENSE file that accompanied this code. |
|
11 |
# |
|
12 |
# This code is distributed in the hope that it will be useful, but WITHOUT |
|
13 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 |
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 |
# version 2 for more details (a copy is included in the LICENSE file that |
|
16 |
# accompanied this code). |
|
17 |
# |
|
18 |
# You should have received a copy of the GNU General Public License version |
|
19 |
# 2 along with this work; if not, write to the Free Software Foundation, |
|
20 |
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
21 |
# |
|
22 |
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
23 |
# or visit www.oracle.com if you need additional information or have any |
|
24 |
# questions. |
|
25 |
# |
|
26 |
||
48678 | 27 |
# This script copies parts of a Visual Studio installation into a devkit |
53141 | 28 |
# suitable for building OpenJDK and OracleJDK. Needs to run in Cygwin or WSL. |
31124 | 29 |
# erik.joelsson@oracle.com |
30 |
||
48678 | 31 |
VS_VERSION="2017" |
32 |
VS_VERSION_NUM_NODOT="150" |
|
33 |
VS_DLL_VERSION="140" |
|
34 |
SDK_VERSION="10" |
|
35 |
SDK_FULL_VERSION="10.0.16299.0" |
|
36 |
MSVC_DIR="Microsoft.VC141.CRT" |
|
53141 | 37 |
MSVC_FULL_VERSION="14.12.25827" |
38 |
REDIST_FULL_VERSION="14.12.25810" |
|
31124 | 39 |
|
40 |
SCRIPT_DIR="$(cd "$(dirname $0)" > /dev/null && pwd)" |
|
41 |
BUILD_DIR="${SCRIPT_DIR}/../../build/devkit" |
|
48678 | 42 |
|
43 |
################################################################################ |
|
44 |
# Prepare settings |
|
45 |
||
53141 | 46 |
UNAME_SYSTEM=`uname -s` |
47 |
UNAME_RELEASE=`uname -r` |
|
48 |
||
49 |
# Detect cygwin or WSL |
|
50 |
IS_CYGWIN=`echo $UNAME_SYSTEM | grep -i CYGWIN` |
|
51 |
IS_WSL=`echo $UNAME_RELEASE | grep Microsoft` |
|
52 |
if test "x$IS_CYGWIN" != "x"; then |
|
53 |
BUILD_ENV="cygwin" |
|
54 |
elif test "x$IS_WSL" != "x"; then |
|
55 |
BUILD_ENV="wsl" |
|
56 |
else |
|
57 |
echo "Unknown environment; only Cygwin and WSL are supported." |
|
58 |
exit 1 |
|
59 |
fi |
|
60 |
||
61 |
if test "x$BUILD_ENV" = "xcygwin"; then |
|
62 |
WINDOWS_PATH_TO_UNIX_PATH="cygpath -u" |
|
63 |
elif test "x$BUILD_ENV" = "xwsl"; then |
|
64 |
WINDOWS_PATH_TO_UNIX_PATH="wslpath -u" |
|
65 |
fi |
|
66 |
||
48678 | 67 |
# Work around the insanely named ProgramFiles(x86) env variable |
53141 | 68 |
PROGRAMFILES_X86="$($WINDOWS_PATH_TO_UNIX_PATH "$(cmd.exe /c set | sed -n 's/^ProgramFiles(x86)=//p' | tr -d '\r')")" |
48678 | 69 |
|
70 |
# Find Visual Studio installation dir |
|
53141 | 71 |
VSNNNCOMNTOOLS=`cmd.exe /c echo %VS${VS_VERSION_NUM_NODOT}COMNTOOLS% | tr -d '\r'` |
48678 | 72 |
if [ -d "$VSNNNCOMNTOOLS" ]; then |
53141 | 73 |
VS_INSTALL_DIR="$($WINDOWS_PATH_TO_UNIX_PATH "$VSNNNCOMNTOOLS/../..")" |
48678 | 74 |
else |
75 |
VS_INSTALL_DIR="${PROGRAMFILES_X86}/Microsoft Visual Studio/2017" |
|
53141 | 76 |
VS_INSTALL_DIR="$(ls -d "${VS_INSTALL_DIR}/"{Community,Professional,Enterprise} 2>/dev/null | head -n1)" |
48678 | 77 |
fi |
78 |
echo "VS_INSTALL_DIR: $VS_INSTALL_DIR" |
|
79 |
||
80 |
# Extract semantic version |
|
53141 | 81 |
POTENTIAL_INI_FILES="Common7/IDE/wdexpress.isolation.ini Common7/IDE/devenv.isolation.ini" |
48678 | 82 |
for f in $POTENTIAL_INI_FILES; do |
83 |
if [ -f "$VS_INSTALL_DIR/$f" ]; then |
|
84 |
VS_VERSION_SP="$(grep ^SemanticVersion= "$VS_INSTALL_DIR/$f")" |
|
85 |
# Remove SemnaticVersion= |
|
86 |
VS_VERSION_SP="${VS_VERSION_SP#*=}" |
|
87 |
# Remove suffix of too detailed numbering starting with + |
|
88 |
VS_VERSION_SP="${VS_VERSION_SP%+*}" |
|
89 |
break |
|
90 |
fi |
|
91 |
done |
|
92 |
if [ -z "$VS_VERSION_SP" ]; then |
|
93 |
echo "Failed to find SP version" |
|
94 |
exit 1 |
|
95 |
fi |
|
96 |
echo "Found Version SP: $VS_VERSION_SP" |
|
97 |
||
98 |
# Setup output dirs |
|
99 |
DEVKIT_ROOT="${BUILD_DIR}/VS${VS_VERSION}-${VS_VERSION_SP}-devkit" |
|
31124 | 100 |
DEVKIT_BUNDLE="${DEVKIT_ROOT}.tar.gz" |
101 |
||
102 |
echo "Creating devkit in $DEVKIT_ROOT" |
|
103 |
||
48678 | 104 |
MSVCR_DLL=${MSVC_DIR}/vcruntime${VS_DLL_VERSION}.dll |
105 |
MSVCP_DLL=${MSVC_DIR}/msvcp${VS_DLL_VERSION}.dll |
|
31124 | 106 |
|
107 |
################################################################################ |
|
108 |
# Copy Visual Studio files |
|
109 |
||
110 |
if [ ! -d $DEVKIT_ROOT/VC ]; then |
|
53141 | 111 |
VC_SUBDIR="VC/Tools/MSVC/$MSVC_FULL_VERSION" |
112 |
REDIST_SUBDIR="VC/Redist/MSVC/$REDIST_FULL_VERSION" |
|
31124 | 113 |
echo "Copying VC..." |
114 |
mkdir -p $DEVKIT_ROOT/VC/bin |
|
48678 | 115 |
cp -r "$VS_INSTALL_DIR/${VC_SUBDIR}/bin/Hostx64/x64" $DEVKIT_ROOT/VC/bin/ |
116 |
cp -r "$VS_INSTALL_DIR/${VC_SUBDIR}/bin/Hostx86/x86" $DEVKIT_ROOT/VC/bin/ |
|
31124 | 117 |
mkdir -p $DEVKIT_ROOT/VC/lib |
48678 | 118 |
cp -r "$VS_INSTALL_DIR/${VC_SUBDIR}/lib/x64" $DEVKIT_ROOT/VC/lib/ |
119 |
cp -r "$VS_INSTALL_DIR/${VC_SUBDIR}/lib/x86" $DEVKIT_ROOT/VC/lib/ |
|
120 |
cp -r "$VS_INSTALL_DIR/${VC_SUBDIR}/include" $DEVKIT_ROOT/VC/ |
|
31124 | 121 |
mkdir -p $DEVKIT_ROOT/VC/atlmfc/lib |
48678 | 122 |
cp -r "$VS_INSTALL_DIR/${VC_SUBDIR}/atlmfc/lib/x64" $DEVKIT_ROOT/VC/atlmfc/lib/ |
123 |
cp -r "$VS_INSTALL_DIR/${VC_SUBDIR}/atlmfc/lib/x86" $DEVKIT_ROOT/VC/atlmfc/lib/ |
|
124 |
cp -r "$VS_INSTALL_DIR/${VC_SUBDIR}/atlmfc/include" $DEVKIT_ROOT/VC/atlmfc/ |
|
125 |
mkdir -p $DEVKIT_ROOT/VC/Auxiliary |
|
126 |
cp -r "$VS_INSTALL_DIR/VC/Auxiliary/Build" $DEVKIT_ROOT/VC/Auxiliary/ |
|
31124 | 127 |
mkdir -p $DEVKIT_ROOT/VC/redist |
48678 | 128 |
cp -r "$VS_INSTALL_DIR/$REDIST_SUBDIR/x64" $DEVKIT_ROOT/VC/redist/ |
129 |
cp -r "$VS_INSTALL_DIR/$REDIST_SUBDIR/x86" $DEVKIT_ROOT/VC/redist/ |
|
130 |
||
31124 | 131 |
# The redist runtime libs are needed to run the compiler but may not be |
132 |
# installed on the machine where the devkit will be used. |
|
50295
84256425a4e9
8203932: Windows devkit has wrong dlls in 32 bit tools dir
erikj
parents:
50073
diff
changeset
|
133 |
cp $DEVKIT_ROOT/VC/redist/x86/$MSVCR_DLL $DEVKIT_ROOT/VC/bin/x86 |
84256425a4e9
8203932: Windows devkit has wrong dlls in 32 bit tools dir
erikj
parents:
50073
diff
changeset
|
134 |
cp $DEVKIT_ROOT/VC/redist/x86/$MSVCP_DLL $DEVKIT_ROOT/VC/bin/x86 |
48678 | 135 |
cp $DEVKIT_ROOT/VC/redist/x64/$MSVCR_DLL $DEVKIT_ROOT/VC/bin/x64 |
136 |
cp $DEVKIT_ROOT/VC/redist/x64/$MSVCP_DLL $DEVKIT_ROOT/VC/bin/x64 |
|
31124 | 137 |
fi |
138 |
||
139 |
################################################################################ |
|
140 |
# Copy SDK files |
|
141 |
||
53141 | 142 |
SDK_INSTALL_DIR="$PROGRAMFILES_X86/Windows Kits/$SDK_VERSION" |
31124 | 143 |
echo "SDK_INSTALL_DIR: $SDK_INSTALL_DIR" |
144 |
||
145 |
if [ ! -d $DEVKIT_ROOT/$SDK_VERSION ]; then |
|
146 |
echo "Copying SDK..." |
|
147 |
mkdir -p $DEVKIT_ROOT/$SDK_VERSION/bin |
|
48678 | 148 |
cp -r "$SDK_INSTALL_DIR/bin/$SDK_FULL_VERSION/x64" $DEVKIT_ROOT/$SDK_VERSION/bin/ |
149 |
cp -r "$SDK_INSTALL_DIR/bin/$SDK_FULL_VERSION/x86" $DEVKIT_ROOT/$SDK_VERSION/bin/ |
|
31124 | 150 |
mkdir -p $DEVKIT_ROOT/$SDK_VERSION/lib |
48678 | 151 |
cp -r "$SDK_INSTALL_DIR/lib/$SDK_FULL_VERSION/um/x64" $DEVKIT_ROOT/$SDK_VERSION/lib/ |
152 |
cp -r "$SDK_INSTALL_DIR/lib/$SDK_FULL_VERSION/um/x86" $DEVKIT_ROOT/$SDK_VERSION/lib/ |
|
153 |
cp -r "$SDK_INSTALL_DIR/lib/$SDK_FULL_VERSION/ucrt/x64" $DEVKIT_ROOT/$SDK_VERSION/lib/ |
|
154 |
cp -r "$SDK_INSTALL_DIR/lib/$SDK_FULL_VERSION/ucrt/x86" $DEVKIT_ROOT/$SDK_VERSION/lib/ |
|
50073
35b22ca681d1
8202557: OpenJDK fails to start in Windows 7 and 8.1 after upgrading compiler to VC 2017
erikj
parents:
48678
diff
changeset
|
155 |
mkdir -p $DEVKIT_ROOT/$SDK_VERSION/Redist |
35b22ca681d1
8202557: OpenJDK fails to start in Windows 7 and 8.1 after upgrading compiler to VC 2017
erikj
parents:
48678
diff
changeset
|
156 |
cp -r "$SDK_INSTALL_DIR/Redist/ucrt" $DEVKIT_ROOT/$SDK_VERSION/Redist/ |
48678 | 157 |
mkdir -p $DEVKIT_ROOT/$SDK_VERSION/include |
158 |
cp -r "$SDK_INSTALL_DIR/include/$SDK_FULL_VERSION/"* $DEVKIT_ROOT/$SDK_VERSION/include/ |
|
31124 | 159 |
fi |
160 |
||
161 |
################################################################################ |
|
162 |
# Generate devkit.info |
|
163 |
||
164 |
echo-info() { |
|
165 |
echo "$1" >> $DEVKIT_ROOT/devkit.info |
|
166 |
} |
|
167 |
||
168 |
echo "Generating devkit.info..." |
|
169 |
rm -f $DEVKIT_ROOT/devkit.info |
|
170 |
echo-info "# This file describes to configure how to interpret the contents of this devkit" |
|
33029
06a8c5e5959b
8139735: Switch compilers in JPRT for windows and linux
erikj
parents:
31124
diff
changeset
|
171 |
echo-info "DEVKIT_NAME=\"Microsoft Visual Studio $VS_VERSION $VS_VERSION_SP (devkit)\"" |
31124 | 172 |
echo-info "DEVKIT_VS_VERSION=\"$VS_VERSION\"" |
173 |
echo-info "" |
|
48678 | 174 |
echo-info "DEVKIT_TOOLCHAIN_PATH_x86=\"\$DEVKIT_ROOT/VC/bin/x86:\$DEVKIT_ROOT/$SDK_VERSION/bin/x86\"" |
175 |
echo-info "DEVKIT_VS_INCLUDE_x86=\"\$DEVKIT_ROOT/VC/include;\$DEVKIT_ROOT/VC/atlmfc/include;\$DEVKIT_ROOT/$SDK_VERSION/include/shared;\$DEVKIT_ROOT/$SDK_VERSION/include/ucrt;\$DEVKIT_ROOT/$SDK_VERSION/include/um;\$DEVKIT_ROOT/$SDK_VERSION/include/winrt\"" |
|
176 |
echo-info "DEVKIT_VS_LIB_x86=\"\$DEVKIT_ROOT/VC/lib/x86;\$DEVKIT_ROOT/VC/atlmfc/lib/x86;\$DEVKIT_ROOT/$SDK_VERSION/lib/x86\"" |
|
31124 | 177 |
echo-info "DEVKIT_MSVCR_DLL_x86=\"\$DEVKIT_ROOT/VC/redist/x86/$MSVCR_DLL\"" |
178 |
echo-info "DEVKIT_MSVCP_DLL_x86=\"\$DEVKIT_ROOT/VC/redist/x86/$MSVCP_DLL\"" |
|
50073
35b22ca681d1
8202557: OpenJDK fails to start in Windows 7 and 8.1 after upgrading compiler to VC 2017
erikj
parents:
48678
diff
changeset
|
179 |
echo-info "DEVKIT_UCRT_DLL_DIR_x86=\"\$DEVKIT_ROOT/10/Redist/ucrt/DLLs/x86\"" |
31124 | 180 |
echo-info "" |
48678 | 181 |
echo-info "DEVKIT_TOOLCHAIN_PATH_x86_64=\"\$DEVKIT_ROOT/VC/bin/x64:\$DEVKIT_ROOT/$SDK_VERSION/bin/x64:\$DEVKIT_ROOT/$SDK_VERSION/bin/x86\"" |
182 |
echo-info "DEVKIT_VS_INCLUDE_x86_64=\"\$DEVKIT_ROOT/VC/include;\$DEVKIT_ROOT/VC/atlmfc/include;\$DEVKIT_ROOT/$SDK_VERSION/include/shared;\$DEVKIT_ROOT/$SDK_VERSION/include/ucrt;\$DEVKIT_ROOT/$SDK_VERSION/include/um;\$DEVKIT_ROOT/$SDK_VERSION/include/winrt\"" |
|
183 |
echo-info "DEVKIT_VS_LIB_x86_64=\"\$DEVKIT_ROOT/VC/lib/x64;\$DEVKIT_ROOT/VC/atlmfc/lib/x64;\$DEVKIT_ROOT/$SDK_VERSION/lib/x64\"" |
|
31124 | 184 |
echo-info "DEVKIT_MSVCR_DLL_x86_64=\"\$DEVKIT_ROOT/VC/redist/x64/$MSVCR_DLL\"" |
185 |
echo-info "DEVKIT_MSVCP_DLL_x86_64=\"\$DEVKIT_ROOT/VC/redist/x64/$MSVCP_DLL\"" |
|
50073
35b22ca681d1
8202557: OpenJDK fails to start in Windows 7 and 8.1 after upgrading compiler to VC 2017
erikj
parents:
48678
diff
changeset
|
186 |
echo-info "DEVKIT_UCRT_DLL_DIR_x86_64=\"\$DEVKIT_ROOT/10/Redist/ucrt/DLLs/x64\"" |
31124 | 187 |
|
188 |
################################################################################ |
|
189 |
# Copy this script |
|
190 |
||
191 |
echo "Copying this script..." |
|
192 |
cp $0 $DEVKIT_ROOT/ |
|
193 |
||
194 |
################################################################################ |
|
195 |
# Create bundle |
|
196 |
||
197 |
echo "Creating bundle: $DEVKIT_BUNDLE" |
|
198 |
(cd "$DEVKIT_ROOT" && tar zcf "$DEVKIT_BUNDLE" .) |