tools/msvs-promote-path script

Script intended to make the compilation instructions for the Microsoft
Visual C++ Compiler ports a little simpler.

This script allows the user to start Cygwin from the appropriate Visual
Studio Command Prompt (e.g. by issuing `C:\cygwin\bin\mintty -`) and then,
from the OCaml sources directory, issue

```bash
eval `tools/msvs-promote-path`
```

This script emits an error if the Microsoft Linker cannot be found in any
of the directories in `PATH` or if the `link` command already refers to the
Microsoft Linker. If, as will usually be the default, `link` refers to the
coreutils `link` command, `PATH` is altered to move the first entry
containing the Microsoft Linker to the start of `PATH`. This has the
effect of overriding the Unix interpretation of the `link` command, but
this will never affect OCaml's build process.

This script is taken from msvs-tools
(https://github.com/metastack/msvs-tools) and re-licensed by the copyright
holder.
master
David Allsopp 2015-12-23 13:57:10 +00:00 committed by Gabriel Scherer
parent 009905a373
commit 0f3b843ba6
2 changed files with 52 additions and 0 deletions

1
.gitattributes vendored
View File

@ -101,6 +101,7 @@ stdlib/sharpbang text eol=lf
tools/check-typo text eol=lf
tools/ci-build text eol=lf
tools/cleanup-header text eol=lf
tools/msvs-promote-path text eol=lf
tools/gdb-macros text eol=lf
tools/magic text eol=lf
tools/make-opcodes text eol=lf

51
tools/msvs-promote-path Executable file
View File

@ -0,0 +1,51 @@
#!/bin/bash
#**************************************************************************
#* *
#* OCaml *
#* *
#* David Allsopp, MetaStack Solutions Ltd. *
#* *
#* Copyright 2015 MetaStack Solutions Ltd. *
#* *
#* All rights reserved. This file is distributed under the terms of *
#* the GNU Lesser General Public License version 2.1, with the *
#* special exception on linking described in the file LICENSE. *
#* *
#**************************************************************************
# Ensure that the Microsoft Linker isn't being messed up by /usr/bin/link
if [ "`link --version | head -1 | \
fgrep "Microsoft (R) Incremental Linker"`" != "" ] ; then
echo "link already refers to the Microsoft Linker">&2
exit 0
fi
IFS=:
T=
FOUND=0
FIRST=1
for i in $PATH
do
if [ $FIRST -eq 1 ] ; then
T="$i"
FIRST=0
else
if [ $FOUND -eq 0 -a -x $i/link ] && [ "`$i/link --version | head -1 | \
fgrep "Microsoft (R) Incremental Linker"`" != "" ] ; then
FOUND=1
T="$i:$T"
PROM=$i
else
T="$T:$i"
fi
fi
done
unset IFS
if [ $FOUND -eq 0 ] ; then
echo The Microsoft Linker was not found in any of the PATH entries!>&2
exit 1
else
echo "$PROM moved to the front of \$PATH">&2
echo export PATH=\"$T\"
fi