Home | History | Annotate | Download | only in default
      1 function echo_stdout()
      2 {
      3    echo -e "[setup.sh] $@"
      4 }
      5 
      6 function print_menu()
      7 {
      8     echo_stdout
      9     echo_stdout "Build selection menu... choose from the following:"
     10     echo_stdout
     11     echo_stdout "1. Build for host platform"
     12     echo_stdout "2. Arm device build using OpenCORE (Android) cross-compiler"
     13     echo_stdout "3. Build using default linux-arm cross-compiler"
     14     echo_stdout "4. Arm device build using OpenCORE (Android) cross-compiler inside AccuRev workspace"
     15     echo_stdout
     16 
     17 }
     18 
     19 function clean_env()
     20 {
     21   echo_stdout "=================================="
     22   echo_stdout "Cleaning ARCHITECTURE"
     23   unset ARCHITECTURE
     24   echo_stdout "Cleaning ANDROID_BASE"
     25   unset ANDROID_BASE
     26   echo_stdout "Setting PATH back to the original"
     27   export PATH=$BASE_PATH
     28   echo_stdout "=================================="
     29 }
     30 
     31 function menu()
     32 {
     33     if [ "$1" ] ; then
     34         CHOICE=$1
     35     else
     36         print_menu
     37         read -p "[setup.sh] Which selection would you like? " CHOICE
     38     fi
     39 
     40     case $CHOICE in
     41     1)
     42         echo_stdout "Choice is to build for the host platform."
     43         clean_env
     44         ;;
     45     2)
     46         echo_stdout "Choice is to build for target with OpenCORE (Android) cross-compiler"
     47         ## clean the environment
     48         clean_env
     49         ## set path up for linux OpenCore build
     50         android_gcc_arm_path=/opt/environments/android/toolchain-eabi-4.2.1/bin
     51         export ARCHITECTURE=android
     52         echo_stdout "ARCHITECTURE set to ==> $ARCHITECTURE"
     53         export PATH=$android_gcc_arm_path:$BASE_PATH
     54         export ANDROID_BASE=/opt/environments/android
     55         echo_stdout "ANDROID_BASE set to ==> $ANDROID_BASE"
     56         ;;
     57     3)
     58         echo_stdout "Choice is to build for target with the default linux-arm cross-compiler"
     59         # clean the environment
     60         clean_env
     61         # set path up for linux-arm compiler
     62         linux_arm_path=/opt/environments/linux_arm/data/omapts/linux/arm-tc/gcc-3.4.0-1/bin
     63         export ARCHITECTURE=linux_arm
     64         export PATH=$linux_arm_path:$BASE_PATH
     65         ;;
     66     4)  
     67         echo_stdout "Choice is to build for target with workspace's OpenCORE (Android) cross-compiler"
     68         ## clean the environment
     69         clean_env
     70         ## set path up for linux OpenCore build
     71         android_gcc_arm_path=$BASE_DIR/toolchains/android/toolchain-eabi-4.2.1/bin
     72         export ARCHITECTURE=android
     73         echo_stdout "ARCHITECTURE set to ==> $ARCHITECTURE"
     74         export PATH=$android_gcc_arm_path:$BASE_PATH
     75         export ANDROID_BASE=$BASE_DIR/toolchains/android
     76         echo_stdout "ANDROID_BASE set to ==> $ANDROID_BASE"
     77         ;;
     78     *)
     79         echo_stdout "Invalid selection.  Please enter your selection again."
     80         print_menu
     81         return
     82         ;;
     83     esac
     84 }
     85 
     86 function mkcmdcmpl()
     87 {
     88     printf "\nGetting make cmdline completion values...\n"
     89     export PV_MAKE_COMPLETION_TARGETS=`make -j completion_targets`
     90     printf "Done getting make cmdline completion values.\n\n"
     91 }
     92 
     93 
     94 
     95 echo_stdout "started."
     96 echo_stdout "setting up build environment with default configuration"
     97 
     98 export PROJECT_DIR=$PWD
     99 
    100 if [[ $# -ge 1 ]]; then
    101   export BASE_DIR=${1%/}
    102 fi
    103 
    104 if [[ -z $BASE_DIR ]]; then
    105   echo_stdout "ERROR: BASE_DIR is not set!"
    106 fi
    107 echo_stdout "BASE_DIR   ==> $BASE_DIR"
    108 
    109 export SRC_ROOT=$BASE_DIR
    110 echo_stdout "SRC_ROOT   ==> $SRC_ROOT"
    111 
    112 export BUILD_ROOT=$PROJECT_DIR/build
    113 echo_stdout "BUILD_ROOT ==> $BUILD_ROOT"
    114 
    115 export CFG_DIR=$PWD
    116 echo_stdout "CFG_DIR    ==> $CFG_DIR"
    117 
    118 export MK=$BASE_DIR/tools_v2/build/make
    119 echo_stdout "MK         ==> $MK"
    120 
    121 extern_tools_path=$BASE_DIR/extern_tools_v2/bin/linux
    122 export PATH=$extern_tools_path:$PATH
    123 export BASE_PATH=$PATH
    124 
    125 _pv_make_completion()
    126 {
    127     local cur prev opts
    128     COMPREPLY=()
    129     cur="${COMP_WORDS[COMP_CWORD]}"
    130     prev="${COMP_WORDS[COMP_CWORD-1]}"
    131     opts="${PV_MAKE_COMPLETION_TARGETS}"
    132 
    133     case "${prev}" in 
    134       -f)
    135         COMPREPLY=( $(compgen -f ${cur}) )
    136         return 0
    137         ;;
    138     *)
    139         COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
    140         return 0
    141         ;;
    142     esac
    143 }
    144 
    145 complete -F _pv_make_completion make
    146 ###
    147 
    148 echo_stdout
    149 echo_stdout "environment is ready if no errors reported."
    150 echo_stdout "complete."
    151