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"
39 SEVENZIP_URL
="http://librepilot.github.io/tools/7za.exe"
41 # Expected tools paths
42 WGET
="$TOOLS_DIR/bin/`basename \"$WGET_URL\"`"
43 MAKE
="$TOOLS_DIR/bin/`basename \"$MAKE_URL\"`"
44 SEVENZIP
="$TOOLS_DIR/bin/`basename \"$SEVENZIP_URL\"`"
46 # wget is necessary to fetch other files
47 WGET_NAME
="`basename \"$WGET\"`"
48 if [ ! -x "$WGET" ]; then
49 echo "$SCRIPT_NAME: $WGET_NAME not found, fetching from $WGET_URL"
50 mkdir
-p "`dirname \"$WGET\"`"
52 VBSCRIPT
="$TOOLS_DIR/fetch.$$.vbs"
53 cat >"$VBSCRIPT" <<-EOF
54 url = WScript.Arguments.Item(0)
55 file = WScript.Arguments.Item(1)
57 Dim xHttp: Set xHttp = CreateObject("MSXML2.ServerXMLHTTP")
58 xHttp.Open "GET", url, False
59 xHttp.setOption 2, SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS
62 If xHttp.Status = 200 Then
63 Dim bStrm: Set bStrm = CreateObject("AdoDb.Stream")
67 .Write xHttp.ResponseBody
68 .SaveToFile file, 2 '// overwrite
77 cscript
"$VBSCRIPT" "$WGET_URL" "$WGET"
81 if [ $rc -ne 0 ]; then
82 echo "$SCRIPT_NAME: $WGET_NAME fetch error, hope it's in the path..."
87 # make is necessary to fetch all SDKs
88 if [ ! -x "$MAKE" ]; then
89 echo "$SCRIPT_NAME: $MAKE_NAME not found, fetching from $MAKE_URL"
90 MAKE_DIR
="`dirname \"$MAKE\"`"
92 $WGET --no-check-certificate -N --content-disposition -P "$MAKE_DIR" "$MAKE_URL"
94 echo "$SCRIPT_NAME: $MAKE_NAME fetch error, hope it's in the path..."
95 MAKE_NAME
="`basename \"$MAKE\"`"
100 # 7-Zip is necessary to install some SDKs
101 if [ ! -x "$SEVENZIP" ]; then
102 echo "$SCRIPT_NAME: $SEVENZIP_NAME not found, fetching from $SEVENZIP_URL"
103 SEVENZIP_DIR
="`dirname \"$SEVENZIP\"`"
104 mkdir
-p "$SEVENZIP_DIR"
105 $WGET --no-check-certificate -N --content-disposition -P "$SEVENZIP_DIR" "$SEVENZIP_URL"
106 if [ $?
-ne 0 ]; then
107 echo "$SCRIPT_NAME: $SEVENZIP_NAME fetch error, hope it's in the path..."
108 SEVENZIP_NAME
="`basename \"$SEVENZIP\"`"
109 SEVENZIP
="$SEVENZIP_NAME"
113 # Finally we can fetch all SDKs using top level Makefile
115 echo "Run 'tools/bin/make all_sdk_install' to install the other tools"
116 echo " or 'tools/bin/make help' for more info on make targets"