blob: 97607216716289310b1a14ee4cef8ff92a046284 [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"
8
9cat <<EOF > $cmake_file
10enable_language(C CXX ASM)
11
12target_include_directories(
13 \${TARGET_NAME}
14 PUBLIC
15 include
16)
17
18EOF
19
20cat <<EOF > $kconfig_file
21EOF
22
23while IFS= read -r line
24do
25 keyword=`echo "$line" | grep 'path=.* name=' | awk '{print $2}'`
26 if [ $keyword ]; then
27 repo_path=`echo ${keyword#*path=} | sed 's/\"//g'`
28 # Generate root CMakeLists.txt
29 if [ -f $repo_path/CMakeLists.txt ]; then
30 echo "add_subdirectory($repo_path)" >> $cmake_file
31 fi
32
33 # Generate root Kconfig
34 if [ -f $repo_path/Kconfig ]; then
35 category=`dirname $repo_path`
36 if [ "$last_category" != "$category" ]; then
37 if [ $last_category ]; then
38 echo -e "endmenu\n" >> $kconfig_file
39 fi
40 echo "menu \"${category^} Options\"" >> $kconfig_file
41 fi
42 echo "source \"$repo_path/Kconfig\"" >> $kconfig_file
43 last_category=$category
44 fi
45 fi
46done < "$input"
47
48echo "endmenu" >> $kconfig_file