blob: 913cf17ac3b506e6b58f722a4301fe6c106b6cf2 [file] [log] [blame]
kelvin.zhangac22e652021-10-18 15:09:21 +08001#!/bin/bash
2
3prj_dir=`pwd`
4
5input="$prj_dir/.repo/manifests/default.xml"
6cmake_file="$prj_dir/CMakeLists.txt"
7kconfig_file="$prj_dir/Kconfig"
kelvin.zhang60107092021-10-19 18:12:39 +08008exclude_dir="products"
kelvin.zhangac22e652021-10-18 15:09:21 +08009
10cat <<EOF > $cmake_file
11enable_language(C CXX ASM)
12
13target_include_directories(
14 \${TARGET_NAME}
15 PUBLIC
16 include
17)
18
19EOF
20
21cat <<EOF > $kconfig_file
22EOF
23
24while IFS= read -r line
25do
26 keyword=`echo "$line" | grep 'path=.* name=' | awk '{print $2}'`
27 if [ $keyword ]; then
28 repo_path=`echo ${keyword#*path=} | sed 's/\"//g'`
kelvin.zhang60107092021-10-19 18:12:39 +080029 category=`dirname $repo_path`
kelvin.zhangac22e652021-10-18 15:09:21 +080030 # Generate root CMakeLists.txt
kelvin.zhang60107092021-10-19 18:12:39 +080031 if [ -f $repo_path/CMakeLists.txt ] && [ "$category" != "$exclude_dir" ]; then
kelvin.zhangac22e652021-10-18 15:09:21 +080032 echo "add_subdirectory($repo_path)" >> $cmake_file
33 fi
34
35 # Generate root Kconfig
36 if [ -f $repo_path/Kconfig ]; then
kelvin.zhangac22e652021-10-18 15:09:21 +080037 if [ "$last_category" != "$category" ]; then
38 if [ $last_category ]; then
39 echo -e "endmenu\n" >> $kconfig_file
40 fi
41 echo "menu \"${category^} Options\"" >> $kconfig_file
42 fi
43 echo "source \"$repo_path/Kconfig\"" >> $kconfig_file
44 last_category=$category
45 fi
46 fi
47done < "$input"
48
49echo "endmenu" >> $kconfig_file