lin
2025-04-16 ddfd1960bbbcff04beea3129c53b2dbe43482ce8
build.sh
....@@ -2,6 +2,16 @@
22
33 BOARD_CONFIG_DIR=longan/device/config/chips/
44 BOARD_CONFIG_FILE=longan/device/.BoardConfig.mk
5
+DTS_DIR=$BOARD_CONFIG_DIR/a133/configs/c3
6
+
7
+LCD_DTS=(
8
+ "lcd-lvds-7-1024-600.dtsi"
9
+ "lcd-lvds-21-1920-1080.dtsi"
10
+ "lcd-mipi-10-800-1280-v1.dtsi"
11
+ "lcd-mipi-10-800-1280-v2.dtsi"
12
+ "lcd-mipi-8-800-1280.dtsi"
13
+ "lcd-mipi-5-720-1280.dtsi"
14
+)
515
616 function build_lunch() {
717 TARGET_BOARD_PATH_ARRAY=($(find $BOARD_CONFIG_DIR -name "BoardConfig-a133*.mk" | sort))
....@@ -34,10 +44,34 @@
3444 longan/build/mkcommon.sh autoconfig -i a133 -o android -b c3
3545 }
3646
37
-if [ "x$1" == "xlunch" ]; then
38
- build_lunch && exit 0
39
-else
47
+function build() {
48
+ DTS_FILE=${DTS_DIR}/${DTS_NAME}.dts
49
+ for config in "${LCD_DTS[@]}"; do
50
+ # 检查未被注释的配置行(支持行首空格)
51
+ if grep -q -E "^[[:space:]]*#include \"${config}\"" "$DTS_FILE"; then
52
+ # 提取 lcd- 之后 .dtsi 之前的内容(去除头尾字符)
53
+ LCD_NAME=$(echo "$config" | sed 's/^lcd-\(.*\)\.dtsi$/\1/')
54
+ break
55
+ fi
56
+ done
57
+
58
+
59
+sed -i -E "
60
+/^[[:space:]]*export LCD_NAME=/ {
61
+ s|^(export LCD_NAME=).*$|\1${LCD_NAME}|
62
+ h
63
+ \$!{x;b};x
64
+ b done
65
+}
66
+
67
+1 i export LCD_NAME=${LCD_NAME}
68
+
69
+:done
70
+" "${BOARD_CONFIG_FILE}"
71
+
72
+
4073 source $BOARD_CONFIG_FILE
74
+
4175 if [ x"$1" == "xuboot" ] || [ x"$1" == "xu" ] || [ x"$1" == "x" ]; then
4276 echo "Start build uboot"
4377 cd longan/brandy/brandy-2.0
....@@ -95,4 +129,31 @@
95129 pack
96130 cd -
97131
132
+
133
+}
134
+
135
+if [ "x$1" == "xlunch" ]; then
136
+ build_lunch && exit 0
137
+else
138
+ source $BOARD_CONFIG_FILE
139
+ if [ "x$1" == "xall" ]; then
140
+ for config in "${LCD_DTS[@]}"; do
141
+ echo "正在切换设备树: $config"
142
+ # Step 1: 注释所有 LCD 相关行(无论原始是否已注释)
143
+ sed -i -E '/#include "lcd-/s|^([[:space:]]*)(//)?|\1//|' "$DTS_DIR/$DTS_NAME.dts"
144
+
145
+ # Step 2: 解除目标配置的注释
146
+ sed -i -E "s|^([[:space:]]*)//#include \"$config\"|\1#include \"$config\"|" "$DTS_DIR/$DTS_NAME.dts"
147
+
148
+ # # 提取 lcd- 之后 .dtsi 之前的内容(去除头尾字符)
149
+ # LCD_DTS_FILE=$(echo "$config" | sed 's/^lcd-\(.*\)\.dtsi$/\1/')
150
+
151
+ # 执行编译
152
+ echo "开始编译..."
153
+ build
154
+ done
155
+ else
156
+ build && exit 0
157
+ fi
158
+
98159 fi