3 # win_sdk_install.sh - Windows toolchain install script.
4 # Copyright (C) 2015, The LibrePilot Project, http://www.librepilot.org
5 # Copyright (c) 2013, The OpenPilot Team, http://www.openpilot.org
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 # You should have received a copy of the GNU General Public License along
18 # with this program; if not, write to the Free Software Foundation, Inc.,
19 # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 # This script should be launched from git bash prompt. It assumes MSYS
23 # environment and expects path names in the form of /C/some/path, where
24 # C is a drive letter, and paths are in MSYS format. It probably won't
27 SCRIPT_PATH
="`echo "$BASH_SOURCE" | sed 's|\\\\|/|g; s|^\(.\):|/\1|'`"
28 SCRIPT_NAME
="`basename \"$SCRIPT_PATH\"`"
29 SCRIPT_DIR
="`dirname \"$SCRIPT_PATH\"`"
30 ROOT_DIR
="`pushd \"$SCRIPT_DIR/../..\" >/dev/null && pwd && popd >/dev/null`"
31 TOOLS_DIR
="$ROOT_DIR/tools"
37 WGET_URL
="http://librepilot.github.io/tools/wget.exe"
38 MAKE_URL
="http://librepilot.github.io/tools/make.exe"
40 # Expected tools paths
41 WGET
="$TOOLS_DIR/bin/`basename \"$WGET_URL\"`"
42 MAKE
="$TOOLS_DIR/bin/`basename \"$MAKE_URL\"`"
44 # wget is necessary to fetch other files
45 WGET_NAME
="`basename \"$WGET\"`"
46 if [ ! -x "$WGET" ]; then
47 echo "$SCRIPT_NAME: $WGET_NAME not found, fetching from $WGET_URL"
48 mkdir
-p "`dirname \"$WGET\"`"
50 VBSCRIPT
="$TOOLS_DIR/fetch.$$.vbs"
51 cat >"$VBSCRIPT" <<-EOF
52 url = WScript.Arguments.Item(0)
53 file = WScript.Arguments.Item(1)
55 Dim xHttp: Set xHttp = CreateObject("MSXML2.ServerXMLHTTP")
56 xHttp.Open "GET", url, False
57 xHttp.setOption 2, SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS
60 If xHttp.Status = 200 Then
61 Dim bStrm: Set bStrm = CreateObject("AdoDb.Stream")
65 .Write xHttp.ResponseBody
66 .SaveToFile file, 2 '// overwrite
75 cscript
"$VBSCRIPT" "$WGET_URL" "$WGET"
79 if [ $rc -ne 0 ]; then
80 echo "$SCRIPT_NAME: $WGET_NAME fetch error, hope it's in the path..."
85 # make is necessary to fetch all SDKs
86 if [ ! -x "$MAKE" ]; then
87 echo "$SCRIPT_NAME: $MAKE_NAME not found, fetching from $MAKE_URL"
88 MAKE_DIR
="`dirname \"$MAKE\"`"
90 $WGET --no-check-certificate -N --content-disposition -P "$MAKE_DIR" "$MAKE_URL"
92 echo "$SCRIPT_NAME: $MAKE_NAME fetch error, hope it's in the path..."
93 MAKE_NAME
="`basename \"$MAKE\"`"
99 # Finally we can fetch all SDKs using top level Makefile
102 echo "Run 'tools/bin/make all_sdk_install' to install the other tools"
103 echo " or 'tools/bin/make help' for more info on make targets"