SourceInsight精確匯入只與平臺相關的原始碼
阿新 • • 發佈:2018-12-25
#!/bin/sh
#STEP1:編譯核心,將編譯時的輸出資訊儲存到檔案中
# make ARCH=arm > build_log.txt
#
#STEP2:修改指令碼變數&執行指令碼
# ARCH=arm -->改成相應平臺
# MACH=omap2 -->改成相應平臺
# ./sg.sh build_log.txt file_list.txt
#STEP3:SourceInsight Project->Add and Remove Project File->Add from List 新增 file_list.txt
#
ARCH=arm
MACH=omap2
FILE_IN=$1
FILE_OUT=$2
# .c
SOURCE_LIST=""
# generated file list
FILE_LIST=""
# nest depth for function get_includes()
NEST_DTPTH=0
# recursive function, used to get included files from files.
# result is stored in FILE_LIST
# $1 : file list, e.g. "fs/ext4/file.c fs/ext4/fsync.c"
get_includes()
{
local includes
local file
for file in $1
do
if [ ! -e ${file} ]; then
continue
fi
if echo "${FILE_LIST}" | grep -E ${file} > /dev/null; then
continue
fi
FILE_LIST="${FILE_LIST} ${file}"
NEST_DTPTH=$((NEST_DTPTH+1))
echo "<${NEST_DTPTH} : ${file}"
includes=$( \
grep -E -H '^#include' ${file} | \
sed -r \
-e ' [email protected]^.*<(acpi/.*)>@include/\[email protected]' \
-e '[email protected]^.*<(asm-generic/.*)>@include/\[email protected]'\
-e '[email protected]^.*<(config/.*)>@include/\[email protected]' \
-e '[email protected]^.*<(crypto/.*)>@include/\ [email protected]' \
-e '[email protected]^.*<(drm/.*)>@include/\[email protected]' \
-e '[email protected]^.*<(generated/.*)>@include/\[email protected]' \
-e '[email protected]^.*<(keys/.*)>@include/\[email protected]' \
-e '[email protected] ^.*<(linux/.*)>@include/\[email protected]' \
-e '[email protected]^.*<(math-emu/.*)>@include/\[email protected]' \
-e '[email protected]^.*<(media/.*)>@include/\[email protected]' \
-e '[email protected]^.*<(misc/.*)>@include/\[email protected]' \
-e '[email protected]^.*<(mtd/.*)>@include/\[email protected]' \
-e '[email protected]^.*<(net/.*)>@include/\[email protected]' \
-e '[email protected]^.*<(pcmcia/.*)>@include/\[email protected]' \
-e '[email protected]^.*<(rdma/.*)>@include/\[email protected]' \
-e '[email protected]^.*<(rxrpc/.*)>@include/\[email protected]' \
-e '[email protected]^.*<(scsi/.*)>@include/\[email protected]' \
-e '[email protected]^.*<(sound/.*)>@include/\[email protected]' \
-e '[email protected]^.*<(target/.*)>@include/\[email protected]' \
-e '[email protected]^.*<(trace/.*)>@include/\[email protected]' \
-e '[email protected]^.*<(uapi/.*)>@include/\[email protected]' \
-e '[email protected]^.*<(video/.*)>@include/\[email protected]' \
-e '[email protected]^.*<(xen/.*)>@include/\[email protected]' \
-e "[email protected]^.*<(asm/.*)>@arch/${ARCH}/include/\1 arch/${ARCH}/include/generated/\[email protected]" \
-e "[email protected]^.*<(mach/.*)>@arch/${ARCH}/mach-${MACH}/include/\[email protected]" \
-e '[email protected](^.*/)[^/]+\.c.*\"(.*)\"@\1\[email protected]' \
-e '[email protected]/\*.*@@' \
-e '[email protected]^.*\#include.*[email protected]@' \
-e '[email protected]^@ @' | \
sort | \
uniq | \
tr -d '\n' | \
tr -d '\r' \
)
if [ -n "${includes}" ]; then
get_includes "${includes}"
fi
echo ">${NEST_DTPTH}) : ${file}"
NEST_DTPTH=$((NEST_DTPTH-1))
done
}
# get *.c from kernel build log
SOURCE_LIST=$( \
grep -E '^\s*CC' ${FILE_IN} | \
sed -r \
-e 's/^\s*CC\s*/ /' \
-e 's/\.o/\.c/' | \
tr -d '\n' | \
tr -d '\r' \
)
echo ${SOURCE_LIST}
get_includes "${SOURCE_LIST}"
FILE_LIST=$(echo "${FILE_LIST}" | sed -r -e 's/\s/\r\n/g' )
echo "${FILE_LIST}" > ${FILE_OUT}