Jianxiong Pan | 61de272 | 2020-07-14 10:57:22 +0800 | [diff] [blame^] | 1 | #!/usr/bin/env bash |
| 2 | source scripts/amlogic/util.sh |
| 3 | #export PATH=/opt/gcc-linaro-aarch64-none-elf-4.9-2014.09_linux/bin/:$PATH |
| 4 | #export RTOS_CROSS_PREFIX=aarch64-none-elf- |
| 5 | #export PATH=/opt/gcc-linaro-7.3.1-2018.05-i686_aarch64-elf/bin:$PATH |
| 6 | |
| 7 | # auto stop when any command return error |
| 8 | set -o errexit |
| 9 | |
| 10 | if [ "$1" == "" ]; then |
| 11 | echo "usage: $0 [board]" |
| 12 | echo "valid boards are:" |
| 13 | list_boards |
| 14 | exit -1 |
| 15 | elif [ "$1" == "--config" ]; then |
| 16 | echo "valid board are:" |
| 17 | list_boards |
| 18 | exit -1 |
| 19 | fi |
| 20 | |
| 21 | board=$1 |
| 22 | shift |
| 23 | other_args=$* |
| 24 | if [ "${other_args}" == "" ]; then |
| 25 | other_args=all |
| 26 | fi |
| 27 | arch_dir=`get_arch "${board}"` |
| 28 | |
| 29 | echo "arch_dir: ${arch_dir}" |
| 30 | |
| 31 | if [ "${arch_dir}" == "" ]; then |
| 32 | echo "invalid board ${board}" |
| 33 | echo "valid boards are:" |
| 34 | list_boards |
| 35 | exit -1 |
| 36 | fi |
| 37 | |
| 38 | if [ "$clean" == "" ]; then |
| 39 | clean=yes #yes no |
| 40 | fi |
| 41 | cpu=1 |
| 42 | |
| 43 | function build_subpath() { |
| 44 | sub="$1/${arch_dir}/${board}" |
| 45 | pushd "$sub" |
| 46 | |
| 47 | [[ "$clean" == "yes" ]] && make clean |
| 48 | make -j8 ${other_args} |
| 49 | #[[ "$clean" == "yes" ]] && make ARCH_DIR="${arch_dir}" BOARD_DIR="${board}" clean |
| 50 | # make ARCH_DIR="${arch_dir}" BOARD_DIR="${board}" -j"$cpu" ${other_args} |
| 51 | |
| 52 | popd |
| 53 | } |
| 54 | |
| 55 | function build_modules() { |
| 56 | build_subpath lib/third_party/amlogic/ |
| 57 | build_subpath lib/third_party/amlogic/audio/util |
| 58 | build_subpath lib/third_party/amlogic/audio/samples |
| 59 | build_subpath lib/third_party/cadence/xaf-hostless |
| 60 | } |
| 61 | |
| 62 | function build_app() { |
| 63 | build_subpath demos/amlogic/ |
| 64 | } |
| 65 | |
| 66 | function add_pre_commit_hook() { |
| 67 | if [ ! -d .git/hooks ] |
| 68 | then |
| 69 | return |
| 70 | fi |
| 71 | if [ -f .git/hooks/pre-commit ] |
| 72 | then |
| 73 | flag=`awk '{if($0 ~ "AMLOGIC_PRE_COMMIT_HOOK"){print $0}}' .git/hooks/pre-commit` |
| 74 | if [ -z "$flag" ] |
| 75 | then |
| 76 | cp .git/hooks/pre-commit .git/hooks/pre-commit-old |
| 77 | cp scripts/amlogic/pre-commit-hook.sh .git/hooks/pre-commit |
| 78 | fi |
| 79 | else |
| 80 | cp scripts/amlogic/pre-commit-hook.sh .git/hooks/pre-commit |
| 81 | fi |
| 82 | } |
| 83 | |
| 84 | #add_pre_commit_hook |
| 85 | #build_modules |
| 86 | build_app |