blob: 024483da57e6fea016e8a3602d0bae7578e27381 [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.zhangc35b0762021-10-20 15:41:46 +08009category_pattern="drivers"
kelvin.zhangac22e652021-10-18 15:09:21 +080010
11cat <<EOF > $cmake_file
12enable_language(C CXX ASM)
13
14target_include_directories(
15 \${TARGET_NAME}
16 PUBLIC
17 include
18)
19
20EOF
21
22cat <<EOF > $kconfig_file
23EOF
24
25while IFS= read -r line
26do
27 keyword=`echo "$line" | grep 'path=.* name=' | awk '{print $2}'`
28 if [ $keyword ]; then
29 repo_path=`echo ${keyword#*path=} | sed 's/\"//g'`
kelvin.zhangc35b0762021-10-20 15:41:46 +080030 if [ "$repo_path" == "$category_pattern" ]; then
31 category=$repo_path
32 else
33 category=`dirname $repo_path`
34 fi
35
kelvin.zhangac22e652021-10-18 15:09:21 +080036 # Generate root CMakeLists.txt
kelvin.zhang60107092021-10-19 18:12:39 +080037 if [ -f $repo_path/CMakeLists.txt ] && [ "$category" != "$exclude_dir" ]; then
kelvin.zhangac22e652021-10-18 15:09:21 +080038 echo "add_subdirectory($repo_path)" >> $cmake_file
39 fi
40
41 # Generate root Kconfig
42 if [ -f $repo_path/Kconfig ]; then
kelvin.zhangac22e652021-10-18 15:09:21 +080043 if [ "$last_category" != "$category" ]; then
44 if [ $last_category ]; then
45 echo -e "endmenu\n" >> $kconfig_file
46 fi
47 echo "menu \"${category^} Options\"" >> $kconfig_file
48 fi
49 echo "source \"$repo_path/Kconfig\"" >> $kconfig_file
50 last_category=$category
51 fi
52 fi
53done < "$input"
54
55echo "endmenu" >> $kconfig_file