forked from iotivity/iotivity-lite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_so.sh
executable file
·61 lines (59 loc) · 1.66 KB
/
build_so.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
#!/bin/bash
echo `pwd`
cd ../port/linux
#make clean
make CLOUD=1 CLIENT=1 PKI=1 SECURE=1 libiotivity-lite-client-python.so
#Uncomment for streamlined onboarding
#make OC_SO=1 SO_DPP=1 CLOUD=1 CLIENT=1 PKI=1 SECURE=1 libiotivity-lite-client-python.so
cd ../../python
#mkdir pki_certs
cp -r ../apps/pki_certs/. ./pki_certs
#create certs
cd obt_web
KEY="key.pem"
if [ ! -f "$KEY" ]; then
openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 \
-subj "/C=US/ST=RFOTM/L=Springfield/O=Dis/CN=www.example.com" \
-keyout key.pem -out cert.pem
fi
#Check for virtual environement
VENV="ocf"
if [ ! -d "$VENV" ]; then
#create virtual environement
echo "Create virtual environment"
python3 -m venv ocf
fi
#check version of python, VENV check differs on 2.7 vs 3.X
version=$(python -V 2>&1 | grep -Po '(?<=Python )(.+)')
if [[ -z "$version" ]]
then
echo "No Python!"
exit
fi
MAJOR_VERSION="${version:0:1}"
if [ $MAJOR_VERSION -lt 3 ];then
INVENV=$(python -c 'import sys; print ("1" if hasattr(sys, "real_prefix") else "0")')
else
INVENV=$(python -c 'import sys; print ("0" if sys.prefix == sys.base_prefix else "1")')
fi
#If building within venv
if [ 1 -eq $INVENV ]; then
#don't check for depnedancies every time.
REQUIREMENTS="requirements_met"
if [ ! -f "$REQUIREMENTS" ]; then
echo "Installing required packages"
pip install -r requirements.txt
fi
else
REQUIREMENTS="requirements_met"
if [ ! -f "$REQUIREMENTS" ]; then
source ocf/bin/activate
pip install -r requirements.txt
fi
fi
cd ..
SOF="libiotivity-lite-client-python.so"
if [ ! -f "$SOF" ]; then
echo "Make sure to run the Web-OBT in a virtual environment"
echo "Example: source obt_web/ocf/bin/activate"
fi