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" |
kelvin.zhang | 6010709 | 2021-10-19 18:12:39 +0800 | [diff] [blame^] | 8 | exclude_dir="products" |
kelvin.zhang | ac22e65 | 2021-10-18 15:09:21 +0800 | [diff] [blame] | 9 | |
| 10 | cat <<EOF > $cmake_file |
| 11 | enable_language(C CXX ASM) |
| 12 | |
| 13 | target_include_directories( |
| 14 | \${TARGET_NAME} |
| 15 | PUBLIC |
| 16 | include |
| 17 | ) |
| 18 | |
| 19 | EOF |
| 20 | |
| 21 | cat <<EOF > $kconfig_file |
| 22 | EOF |
| 23 | |
| 24 | while IFS= read -r line |
| 25 | do |
| 26 | keyword=`echo "$line" | grep 'path=.* name=' | awk '{print $2}'` |
| 27 | if [ $keyword ]; then |
| 28 | repo_path=`echo ${keyword#*path=} | sed 's/\"//g'` |
kelvin.zhang | 6010709 | 2021-10-19 18:12:39 +0800 | [diff] [blame^] | 29 | category=`dirname $repo_path` |
kelvin.zhang | ac22e65 | 2021-10-18 15:09:21 +0800 | [diff] [blame] | 30 | # Generate root CMakeLists.txt |
kelvin.zhang | 6010709 | 2021-10-19 18:12:39 +0800 | [diff] [blame^] | 31 | if [ -f $repo_path/CMakeLists.txt ] && [ "$category" != "$exclude_dir" ]; then |
kelvin.zhang | ac22e65 | 2021-10-18 15:09:21 +0800 | [diff] [blame] | 32 | echo "add_subdirectory($repo_path)" >> $cmake_file |
| 33 | fi |
| 34 | |
| 35 | # Generate root Kconfig |
| 36 | if [ -f $repo_path/Kconfig ]; then |
kelvin.zhang | ac22e65 | 2021-10-18 15:09:21 +0800 | [diff] [blame] | 37 | 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 |
| 47 | done < "$input" |
| 48 | |
| 49 | echo "endmenu" >> $kconfig_file |