common/autoconf/toolchain_windows.m4

changeset 2208
feba63b3fa36
parent 857
5b4f14990dd1
child 2209
cddffb220808
equal deleted inserted replaced
2207:ddf2d8bf87c0 2208:feba63b3fa36
139 # We have found a Visual Studio environment on disk, let's extract variables from the vsvars bat file. 139 # We have found a Visual Studio environment on disk, let's extract variables from the vsvars bat file.
140 BASIC_FIXUP_EXECUTABLE(VS_ENV_CMD) 140 BASIC_FIXUP_EXECUTABLE(VS_ENV_CMD)
141 141
142 # Lets extract the variables that are set by vcvarsall.bat/vsvars32.bat/vsvars64.bat 142 # Lets extract the variables that are set by vcvarsall.bat/vsvars32.bat/vsvars64.bat
143 AC_MSG_NOTICE([Trying to extract Visual Studio environment variables]) 143 AC_MSG_NOTICE([Trying to extract Visual Studio environment variables])
144 cd $OUTPUT_ROOT 144
145 # FIXME: The code betweeen ---- was inlined from a separate script and is not properly adapted 145 # We need to create a couple of temporary files.
146 # to autoconf standards. 146 VS_ENV_TMP_DIR="$OUTPUT_ROOT/vs-env"
147 147 $MKDIR -p $VS_ENV_TMP_DIR
148 #---- 148
149 149 # Cannot use the VS10 setup script directly (since it only updates the DOS subshell environment).
150 # Cannot use the VS10 setup script directly (since it only updates the DOS subshell environment) 150 # Instead create a shell script which will set the relevant variables when run.
151 # but calculate the difference in Cygwin environment before/after running it and then 151 WINPATH_VS_ENV_CMD="$VS_ENV_CMD"
152 # apply the diff. 152 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH([WINPATH_VS_ENV_CMD])
153 153 WINPATH_BASH="$BASH"
154 if test "x$OPENJDK_BUILD_OS_ENV" = xwindows.cygwin; then 154 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH([WINPATH_BASH])
155 _vs10varsall=`cygpath -a -m -s "$VS_ENV_CMD"` 155
156 _dosvs10varsall=`cygpath -a -w -s $_vs10varsall` 156 # Generate a DOS batch file which runs $VS_ENV_CMD, and then creates a shell
157 _dosbash=`cygpath -a -w -s \`which bash\`.*` 157 # script (executable by bash) that will setup the important variables.
158 else 158 EXTRACT_VC_ENV_BAT_FILE="$VS_ENV_TMP_DIR/extract-vs-env.bat"
159 _dosvs10varsall=`cmd //c echo $VS_ENV_CMD` 159 $ECHO "@echo off" > $EXTRACT_VC_ENV_BAT_FILE
160 _dosbash=`cmd //c echo \`which bash\`` 160 # This will end up something like:
161 fi 161 # call C:/progra~2/micros~2.0/vc/bin/amd64/vcvars64.bat
162 162 $ECHO "call $WINPATH_VS_ENV_CMD $VS_ENV_ARGS" >> $EXTRACT_VC_ENV_BAT_FILE
163 # generate the set of exported vars before/after the vs10 setup 163 # These will end up something like:
164 $ECHO "@echo off" > localdevenvtmp.bat 164 # C:/CygWin/bin/bash -c 'echo VS_PATH=\"$PATH\" > localdevenv.sh
165 $ECHO "$_dosbash -c \"export -p\" > localdevenvtmp.export0" >> localdevenvtmp.bat 165 # The trailing space for everyone except PATH is no typo, but is needed due
166 $ECHO "call $_dosvs10varsall $VS_ENV_ARGS" >> localdevenvtmp.bat 166 # to trailing \ in the Windows paths. These will be stripped later.
167 $ECHO "$_dosbash -c \"export -p\" > localdevenvtmp.export1" >> localdevenvtmp.bat 167 $ECHO "$WINPATH_BASH -c 'echo VS_PATH="'\"$PATH\" > set-vs-env.sh' >> $EXTRACT_VC_ENV_BAT_FILE
168 $ECHO "$WINPATH_BASH -c 'echo VS_INCLUDE="'\"$INCLUDE \" >> set-vs-env.sh' >> $EXTRACT_VC_ENV_BAT_FILE
169 $ECHO "$WINPATH_BASH -c 'echo VS_LIB="'\"$LIB \" >> set-vs-env.sh' >> $EXTRACT_VC_ENV_BAT_FILE
170 $ECHO "$WINPATH_BASH -c 'echo VCINSTALLDIR="'\"$VCINSTALLDIR \" >> set-vs-env.sh' >> $EXTRACT_VC_ENV_BAT_FILE
171 $ECHO "$WINPATH_BASH -c 'echo WindowsSdkDir="'\"$WindowsSdkDir \" >> set-vs-env.sh' >> $EXTRACT_VC_ENV_BAT_FILE
172 $ECHO "$WINPATH_BASH -c 'echo WINDOWSSDKDIR="'\"$WINDOWSSDKDIR \" >> set-vs-env.sh' >> $EXTRACT_VC_ENV_BAT_FILE
168 173
169 # Now execute the newly created bat file. 174 # Now execute the newly created bat file.
170 # The | cat is to stop SetEnv.Cmd to mess with system colors on msys 175 # The | cat is to stop SetEnv.Cmd to mess with system colors on msys.
171 cmd /c localdevenvtmp.bat | cat 176 # Change directory so we don't need to mess with Windows paths in redirects.
172 177 cd $VS_ENV_TMP_DIR
173 # apply the diff (less some non-vs10 vars named by "!") 178 cmd /c extract-vs-env.bat | $CAT
174 $SORT localdevenvtmp.export0 | $GREP -v "!" > localdevenvtmp.export0.sort
175 $SORT localdevenvtmp.export1 | $GREP -v "!" > localdevenvtmp.export1.sort
176 $COMM -1 -3 localdevenvtmp.export0.sort localdevenvtmp.export1.sort > localdevenv.sh
177
178 # cleanup
179 $RM localdevenvtmp*
180 #----
181 cd $CURDIR 179 cd $CURDIR
182 if test ! -s $OUTPUT_ROOT/localdevenv.sh; then 180
183 AC_MSG_RESULT([no]) 181 if test ! -s $VS_ENV_TMP_DIR/set-vs-env.sh; then
184 AC_MSG_NOTICE([Could not succesfully extract the envionment variables needed for the VS setup.]) 182 AC_MSG_NOTICE([Could not succesfully extract the envionment variables needed for the VS setup.])
185 AC_MSG_NOTICE([Try setting --with-tools-dir to the VC/bin directory within the VS installation]) 183 AC_MSG_NOTICE([Try setting --with-tools-dir to the VC/bin directory within the VS installation])
186 AC_MSG_NOTICE([or run "bash.exe -l" from a VS command prompt and then run configure from there.]) 184 AC_MSG_NOTICE([or run "bash.exe -l" from a VS command prompt and then run configure from there.])
187 AC_MSG_ERROR([Cannot continue]) 185 AC_MSG_ERROR([Cannot continue])
188 fi 186 fi
189 187
190 # Now set all paths and other env variables. This will allow the rest of 188 # Now set all paths and other env variables. This will allow the rest of
191 # the configure script to find and run the compiler in the proper way. 189 # the configure script to find and run the compiler in the proper way.
192 AC_MSG_NOTICE([Setting extracted environment variables]) 190 AC_MSG_NOTICE([Setting extracted environment variables])
193 . $OUTPUT_ROOT/localdevenv.sh 191 . $VS_ENV_TMP_DIR/set-vs-env.sh
192 # Now we have VS_PATH, VS_INCLUDE, VS_LIB. For further checking, we
193 # also define VCINSTALLDIR, WindowsSdkDir and WINDOWSSDKDIR.
194 else 194 else
195 # We did not find a vsvars bat file, let's hope we are run from a VS command prompt. 195 # We did not find a vsvars bat file, let's hope we are run from a VS command prompt.
196 AC_MSG_NOTICE([Cannot locate a valid Visual Studio installation, checking current environment]) 196 AC_MSG_NOTICE([Cannot locate a valid Visual Studio installation, checking current environment])
197 fi 197 fi
198 198
199 # At this point, we should have corrent variables in the environment, or we can't continue. 199 # At this point, we should have correct variables in the environment, or we can't continue.
200 AC_MSG_CHECKING([for Visual Studio variables]) 200 AC_MSG_CHECKING([for Visual Studio variables])
201 201
202 if test "x$VCINSTALLDIR" != x || test "x$WindowsSDKDir" != x || test "x$WINDOWSSDKDIR" != x; then 202 if test "x$VCINSTALLDIR" != x || test "x$WindowsSDKDir" != x || test "x$WINDOWSSDKDIR" != x; then
203 if test "x$INCLUDE" = x || test "x$LIB" = x; then 203 if test "x$VS_INCLUDE" = x || test "x$VS_LIB" = x; then
204 AC_MSG_RESULT([present but broken]) 204 AC_MSG_RESULT([present but broken])
205 AC_MSG_ERROR([Your VC command prompt seems broken, INCLUDE and/or LIB is missing.]) 205 AC_MSG_ERROR([Your VC command prompt seems broken, INCLUDE and/or LIB is missing.])
206 else 206 else
207 AC_MSG_RESULT([ok]) 207 AC_MSG_RESULT([ok])
208 # Remove any trailing \ from INCLUDE and LIB to avoid trouble in spec.gmk. 208 # Remove any trailing "\" and " " from the variables.
209 VS_INCLUDE=`$ECHO "$INCLUDE" | $SED 's/\\\\$//'` 209 VS_INCLUDE=`$ECHO "$VS_INCLUDE" | $SED 's/\\\\* *$//'`
210 VS_LIB=`$ECHO "$LIB" | $SED 's/\\\\$//'` 210 VS_LIB=`$ECHO "$VS_LIB" | $SED 's/\\\\* *$//'`
211 # Remove any paths containing # (typically F#) as that messes up make 211 VCINSTALLDIR=`$ECHO "$VCINSTALLDIR" | $SED 's/\\\\* *$//'`
212 PATH=`$ECHO "$PATH" | $SED 's/[[^:#]]*#[^:]*://g'` 212 WindowsSDKDir=`$ECHO "$WindowsSDKDir" | $SED 's/\\\\* *$//'`
213 VS_PATH="$PATH" 213 WINDOWSSDKDIR=`$ECHO "$WINDOWSSDKDIR" | $SED 's/\\\\* *$//'`
214
215 AC_SUBST(VS_PATH)
214 AC_SUBST(VS_INCLUDE) 216 AC_SUBST(VS_INCLUDE)
215 AC_SUBST(VS_LIB) 217 AC_SUBST(VS_LIB)
216 AC_SUBST(VS_PATH)
217 fi 218 fi
218 else 219 else
219 AC_MSG_RESULT([not found]) 220 AC_MSG_RESULT([not found])
220 221
221 if test "x$VS_ENV_CMD" = x; then 222 if test "x$VS_ENV_CMD" = x; then

mercurial