hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/scripts/dtc/dtx_diff
....@@ -1,10 +1,8 @@
11 #! /bin/bash
2
+# SPDX-License-Identifier: GPL-2.0-only
23
34 # Copyright (C) 2015 Frank Rowand
45 #
5
-# This program is free software; you can redistribute it and/or modify
6
-# it under the terms of the GNU General Public License as published by
7
-# the Free Software Foundation; version 2 of the License.
86
97
108 usage() {
....@@ -21,6 +19,9 @@
2119 diff DTx_1 and DTx_2
2220
2321
22
+ --annotate synonym for -T
23
+ --color synonym for -c (requires diff with --color support)
24
+ -c enable colored output
2425 -f print full dts in diff (--unified=99999)
2526 -h synonym for --help
2627 -help synonym for --help
....@@ -28,6 +29,8 @@
2829 -s SRCTREE linux kernel source tree is at path SRCTREE
2930 (default is current directory)
3031 -S linux kernel source tree is at root of current git repo
32
+ -T annotate output .dts with input source file and line
33
+ (-T -T for more details)
3134 -u unsorted, do not sort DTx
3235
3336
....@@ -170,8 +173,10 @@
170173
171174 # ----- start of script
172175
176
+annotate=""
173177 cmd_diff=0
174178 diff_flags="-u"
179
+diff_color=""
175180 dtx_file_1=""
176181 dtx_file_2=""
177182 dtc_sort="-s"
....@@ -182,6 +187,13 @@
182187 while [ $# -gt 0 ] ; do
183188
184189 case $1 in
190
+
191
+ -c | --color )
192
+ if diff --color /dev/null /dev/null 2>/dev/null ; then
193
+ diff_color="--color=always"
194
+ fi
195
+ shift
196
+ ;;
185197
186198 -f )
187199 diff_flags="--unified=999999"
....@@ -204,6 +216,14 @@
204216 shift
205217 ;;
206218
219
+ -T | --annotate )
220
+ if [ "${annotate}" = "" ] ; then
221
+ annotate="-T"
222
+ elif [ "${annotate}" = "-T" ] ; then
223
+ annotate="-T -T"
224
+ fi
225
+ shift
226
+ ;;
207227 -u )
208228 dtc_sort=""
209229 shift
....@@ -323,14 +343,14 @@
323343 DTC="\
324344 ${DTC} \
325345 -i ${srctree}/scripts/dtc/include-prefixes \
326
- -O dts -qq -f ${dtc_sort} -o -"
346
+ -O dts -qq -f ${dtc_sort} ${annotate} -o -"
327347
328348
329349 # ----- do the diff or decompile
330350
331351 if (( ${cmd_diff} )) ; then
332352
333
- diff ${diff_flags} --label "${dtx_file_1}" --label "${dtx_file_2}" \
353
+ diff ${diff_flags} ${diff_color} --label "${dtx_file_1}" --label "${dtx_file_2}" \
334354 <(compile_to_dts "${dtx_file_1}" "${dtx_path_1_dtc_include}") \
335355 <(compile_to_dts "${dtx_file_2}" "${dtx_path_2_dtc_include}")
336356