forked from Ameba-AIoT/ameba-rtos-z2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
matter_setup.sh
executable file
·79 lines (67 loc) · 1.91 KB
/
matter_setup.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
if [ "$#" -lt 1 ]; then
echo "Usage: $0 <IC type> [optional argument]"
echo "IC type: amebaz2 / amebaz2plus / amebad"
exit 1
fi
AMEBA="$1"
files_to_delete=(
"$PWD/component/soc/realtek/8710c/misc/utilities/include/ctype.h"
)
AMEBAZPLUS_PROJECT="$PWD/project/realtek_amebaz2plus_v0_example"
AMEBAZ2_PROJECT="$PWD/project/realtek_amebaz2_v0_example"
MATTER_AMEBAZ2_DIR="$PWD/component/common/application/matter/project/amebaz2"
MATTER_AMEBAZ2PLUS_DIR="$PWD/component/common/application/matter/project/amebaz2plus"
if [ ! -d third_party ];then
mkdir third_party
else
rm third_party/connectedhomeip
fi
cd third_party
rm -rf connectedhomeip
ln -s ../../connectedhomeip connectedhomeip
cd ../
if [ ! -d component/common/application/matter ] || [ -z "$(find component/common/application/matter -mindepth 1)" ]; then
mkdir -p component/common/application/matter
git clone https://github.com/Ameba-AIoT/ameba-rtos-matter.git component/common/application/matter
fi
delete_files() {
for file_path in "${files_to_delete[@]}"; do
if [ -e "$file_path" ]; then
rm "$file_path"
echo "File $file_path removed."
fi
done
}
modify_makefiles() {
find "$BASE_DIR" -type f -name "Makefile" | while read -r FILE; do
if grep -q "ENABLE_MATTER = 0" "$FILE"; then
echo "Modifying $FILE"
sed -i 's/^ENABLE_MATTER = 0/ENABLE_MATTER = 1/' "$FILE"
fi
done
}
case "$AMEBA" in
amebaz2)
BASE_DIR="$AMEBAZ2_PROJECT"
MATTER_DIR="$MATTER_AMEBAZ2_DIR"
echo "Configuring for $AMEBA"
delete_files
modify_makefiles
;;
amebaz2plus)
BASE_DIR="$AMEBAZPLUS_PROJECT"
MATTER_DIR="$MATTER_AMEBAZ2PLUS_DIR"
echo "Configuring for $AMEBA"
delete_files
modify_makefiles
;;
amebad)
echo "Configuring for $AMEBA"
;;
*)
echo "Invalid argument. Expected 'amebaz2', 'amebaz2plus', or 'amebad'."
exit 1
;;
esac
echo "Matter setup complete"