kelvin.zhang | ac22e65 | 2021-10-18 15:09:21 +0800 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | |
| 3 | prj_dir=`pwd` |
| 4 | |
| 5 | input="$prj_dir/.repo/manifests/default.xml" |
| 6 | cmake_file="$prj_dir/CMakeLists.txt" |
| 7 | kconfig_file="$prj_dir/Kconfig" |
| 8 | |
| 9 | cat <<EOF > $cmake_file |
| 10 | enable_language(C CXX ASM) |
| 11 | |
| 12 | target_include_directories( |
| 13 | \${TARGET_NAME} |
| 14 | PUBLIC |
| 15 | include |
| 16 | ) |
| 17 | |
| 18 | EOF |
| 19 | |
| 20 | cat <<EOF > $kconfig_file |
| 21 | EOF |
| 22 | |
| 23 | while IFS= read -r line |
| 24 | do |
| 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 |
| 46 | done < "$input" |
| 47 | |
| 48 | echo "endmenu" >> $kconfig_file |