-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
executable file
·56 lines (50 loc) · 2.51 KB
/
build.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
#!/bin/bash
CURPWD=`pwd`
PROJNAME=${PWD##*/}
OCFBASEPATH=`jq --raw-output '.ocf_base_path' ${CURPWD}/${PROJNAME}-config.json`
DEVICETYPE=`jq --raw-output '.device_type' ${CURPWD}/${PROJNAME}-config.json`
DEVICENAME=`jq --raw-output '.friendly_name' ${CURPWD}/${PROJNAME}-config.json`
#TODO Go through DeviceBuilder for each of the implementations and platforms (just doing the first array element for this example)
OCFSUBPATH=`jq --raw-output '.implementation_paths[0]' ${CURPWD}/${PROJNAME}-config.json`
OCFPATH="${OCFBASEPATH}${OCFSUBPATH}"
PLATFORM=`jq --raw-output '.platforms[0]' ${CURPWD}/${PROJNAME}-config.json`
if [ "$PLATFORM" == "esp32" ];
then
MY_COMMAND="cp ${CURPWD}/main/${PROJNAME}.c ${OCFPATH}/iotivity-lite/port/${PLATFORM}/main/vscode-esp32-example.c"
eval ${MY_COMMAND}
MY_COMMAND="cp ${CURPWD}/main/${PROJNAME}-main.c ${OCFPATH}/iotivity-lite/port/${PLATFORM}/main/main.c"
eval ${MY_COMMAND}
MY_COMMAND="cp ${CURPWD}/main/pki_certs.h ${OCFPATH}/iotivity-lite/port/${PLATFORM}/main/pki_certs.h"
eval ${MY_COMMAND}
MY_COMMAND="cd ${OCFPATH}/iotivity-lite/port/${PLATFORM}/"
eval ${MY_COMMAND}
MY_COMMAND="idf.py build"
eval ${MY_COMMAND}
elif [ "$PLATFORM" == "arduino" ];
then
MY_COMMAND="cp ${CURPWD}/main/${PROJNAME}.c ${OCFPATH}/../iotivity-lite/apps/server_devicebuilder.c"
eval ${MY_COMMAND}
MY_COMMAND="cp ${CURPWD}/main/${PROJNAME}-main.cpp ${OCFPATH}/../iotivity-lite/apps/server_arduino.cpp"
eval ${MY_COMMAND}
MY_COMMAND="cd ${OCFPATH}/../iotivity-lite/port/${PLATFORM}/"
eval ${MY_COMMAND}
MY_COMMAND="./build_arduino.sh --arch sam --secure"
eval ${MY_COMMAND}
else
#TODO change this to compile from the project source direcotry, but temporarily copy the souce code over.
MY_COMMAND="cp ${CURPWD}/main/${PROJNAME}.c ${OCFPATH}/iotivity-lite/apps/device_builder_server.c"
eval ${MY_COMMAND}
MY_COMMAND="cp ${CURPWD}/main/${PROJNAME}-main.c ${OCFPATH}/iotivity-lite/apps/device_builder_server-main.c"
eval ${MY_COMMAND}
MY_COMMAND="cd ${OCFPATH}/iotivity-lite/port/${PLATFORM}/"
eval ${MY_COMMAND}
MY_COMMAND="make -f ${CURPWD}/devbuildmake DYNAMIC=1 IPV4=1 device_builder_server"
eval ${MY_COMMAND}
#make -f ${CURPWD}/devbuildmake DYNAMIC=1 device_builder_server
#uncomment to make the debug version
#make -f ${CURPWD}/devbuildmake DYNAMIC=1 DEBUG=1 device_builder_server
#TODO remove this command once the above problem is fixed
MY_COMMAND="cp ${OCFPATH}/iotivity-lite/port/${PLATFORM}/device_builder_server ${CURPWD}/bin/${PROJNAME}"
eval ${MY_COMMAND}
fi
cd $CURPWD