-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·63 lines (52 loc) · 1.74 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env bash
# Copyright 2017 Rafal Zajac <rzajac@gmail.com>.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# ESP8266 library installation script.
#
# Installer expects that:
# - The ESPROOT environment variable set.
# - The esp-open-sdk is installed and compiled at ESPROOT/esp-open-sdk.
# The full GitHub URL to the library.
LIB_FULL_NAME="rzajac/esp-drv"
# No modifications below this comment unless you know what you're doing.
TMP_DIR=`mktemp -d`
LIB_REPO="https://github.com/${LIB_FULL_NAME}"
LIB_NAME=${LIB_FULL_NAME##*/}
CMAKE=`which cmake`
# Remove temporary directory.
function rm_tmp() {
echo "Removing ${TMP_DIR}"
rm -rf ${TMP_DIR}
}
# Check / set ESPROOT.
if [ "${ESPROOT}" == "" ]; then ESPROOT=$HOME/esproot; fi
if ! [ -d "${ESPROOT}" ]; then mkdir -p ${ESPROOT}; fi
echo "Using ${ESPROOT} as ESPROOT"
echo "Cloning ${LIB_REPO} to temporary directory ${TMP_DIR}."
git clone ${LIB_REPO} ${TMP_DIR}
if [ $? != 0 ]; then
echo "Error: Cloning ${LIB_REPO} failed!"
rm_tmp
exit 1
fi
echo "Installing library ${LIB_NAME} to ${ESPROOT}"
mkdir ${TMP_DIR}/auto-build
(cd ${TMP_DIR}/auto-build && ${CMAKE} .. && make install)
if [ $? != 0 ]; then
echo "Error: Installing library ${LIB_NAME} failed!"
rm_tmp
exit 1
fi
rm_tmp
exit 0