LP-551 Remove BankMode string and use UavObject definitions
[librepilot.git] / make / scripts / win_sdk_install.sh
blob9837a3c97421976807b6ca078154d3f3e262fb0e
1 #!/bin/bash
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
15 # for more details.
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
25 # work under cygwin.
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"
32 if [ -x "$1" ]; then
33 TOOLS_DIR="$1"
36 # Tools URLs to fetch
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
58 xHttp.Send
60 If xHttp.Status = 200 Then
61 Dim bStrm: Set bStrm = CreateObject("AdoDb.Stream")
62 With bStrm
63 .Type = 1 '// binary
64 .Open
65 .Write xHttp.ResponseBody
66 .SaveToFile file, 2 '// overwrite
67 .Close
68 End With
69 WScript.Quit(0)
70 Else
71 WScript.Quit(1)
72 End IF
73 EOF
75 cscript "$VBSCRIPT" "$WGET_URL" "$WGET"
76 rc=$?
77 rm "$VBSCRIPT"
79 if [ $rc -ne 0 ]; then
80 echo "$SCRIPT_NAME: $WGET_NAME fetch error, hope it's in the path..."
81 WGET="$WGET_NAME"
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\"`"
89 mkdir -p "$MAKE_DIR"
90 $WGET --no-check-certificate -N --content-disposition -P "$MAKE_DIR" "$MAKE_URL"
91 if [ $? -ne 0 ]; then
92 echo "$SCRIPT_NAME: $MAKE_NAME fetch error, hope it's in the path..."
93 MAKE_NAME="`basename \"$MAKE\"`"
94 MAKE="$MAKE_NAME"
99 # Finally we can fetch all SDKs using top level Makefile
100 cd "$ROOT_DIR"
101 ./tool_install.sh 7z
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"