lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # zxic Yocto Project Build Environment Setup Script |
| 4 | # |
| 5 | . sources/meta-zxic-custom/tools/setup-utils.sh |
| 6 | |
| 7 | CWD=`pwd` |
| 8 | PROGNAME="setup-environment" |
| 9 | exit_message () |
| 10 | { |
| 11 | echo "To return to this build environment later please run:" |
| 12 | echo "source setup-environment <build_dir>" |
| 13 | } |
| 14 | |
| 15 | usage() |
| 16 | { |
| 17 | echo -e "\nUsage: source zxic-setup-release.sh |
| 18 | Optional parameters: [-b build-dir] [-h]" |
| 19 | echo " |
| 20 | * [-b build-dir]: Build directory, if unspecified script uses 'build' as output directory |
| 21 | * [-h]: help |
| 22 | " |
| 23 | } |
| 24 | |
| 25 | clean_up() |
| 26 | { |
| 27 | unset CWD BUILD_DIR |
| 28 | unset zxic_setup_help zxic_setup_error zxic_setup_flag |
| 29 | unset usage clean_up |
| 30 | exit_message clean_up |
| 31 | } |
| 32 | |
| 33 | # get command line options |
| 34 | OLD_OPTIND=$OPTIND |
| 35 | |
| 36 | while getopts "k:r:t:b:e:gh" zxic_setup_flag |
| 37 | do |
| 38 | case $zxic_setup_flag in |
| 39 | b) BUILD_DIR="$OPTARG"; |
| 40 | echo -e "\n Build directory is " $BUILD_DIR |
| 41 | ;; |
| 42 | h) zxic_setup_help='true'; |
| 43 | ;; |
| 44 | \?) zxic_setup_error='true'; |
| 45 | ;; |
| 46 | esac |
| 47 | done |
| 48 | shift $((OPTIND-1)) |
| 49 | if [ $# -ne 0 ]; then |
| 50 | zxic_setup_error=true |
| 51 | echo -e "Invalid command line ending: '$@'" |
| 52 | fi |
| 53 | OPTIND=$OLD_OPTIND |
| 54 | if test $zxic_setup_help; then |
| 55 | usage && clean_up && return 1 |
| 56 | elif test $zxic_setup_error; then |
| 57 | clean_up && return 1 |
| 58 | fi |
| 59 | |
| 60 | if [ -z "$DISTRO" ]; then |
| 61 | DISTRO='cpe' |
| 62 | fi |
| 63 | |
| 64 | if [ -z "$BUILD_DIR" ]; then |
| 65 | BUILD_DIR='build' |
| 66 | fi |
| 67 | |
| 68 | if [ -z "$MACHINE" ]; then |
| 69 | MACHINE='zx297520v3' |
| 70 | fi |
| 71 | |
| 72 | if [ -z "$SDK" ]; then |
| 73 | MK_SDK_VERSION='no' |
| 74 | else |
| 75 | MK_SDK_VERSION=$SDK |
| 76 | fi |
| 77 | |
| 78 | if [ -z "$BOOT_CTL" ]; then |
| 79 | BOOT_CTL='normal' |
| 80 | else |
| 81 | BOOT_CTL=$BOOT_CTL |
| 82 | fi |
| 83 | |
| 84 | if [ -z "$STRORAGE_CONF" ]; then |
| 85 | STRORAGE_CONF='nand-config-default' |
| 86 | else |
| 87 | STRORAGE_CONF=$STRORAGE_CONF |
| 88 | fi |
| 89 | |
| 90 | # Set up the basic yocto environment |
| 91 | rm -fr $BUILD_DIR/conf/ |
| 92 | DISTRO=$DISTRO MACHINE=$MACHINE MK_SDK_VERSION=$MK_SDK_VERSION BOOT_CTL=$BOOT_CTL STRORAGE_CONF=$STRORAGE_CONF . ./$PROGNAME $BUILD_DIR |
| 93 | |
| 94 | # Point to the current directory since the last command changed the directory to $BUILD_DIR |
| 95 | BUILD_DIR=. |
| 96 | |
| 97 | if [ ! -e $BUILD_DIR/conf/local.conf ]; then |
| 98 | echo -e "\n ERROR - No build directory is set yet. Run the 'setup-environment' script before running this script to create " $BUILD_DIR |
| 99 | echo -e "\n" |
| 100 | return 1 |
| 101 | fi |
| 102 | |
| 103 | # On the first script run, backup the local.conf file |
| 104 | # Consecutive runs, it restores the backup and changes are appended on this one. |
| 105 | if [ ! -e $BUILD_DIR/conf/local.conf.org ]; then |
| 106 | cp $BUILD_DIR/conf/local.conf $BUILD_DIR/conf/local.conf.org |
| 107 | else |
| 108 | cp $BUILD_DIR/conf/local.conf.org $BUILD_DIR/conf/local.conf |
| 109 | fi |
| 110 | |
| 111 | if [ ! -e $BUILD_DIR/conf/bblayers.conf.org ]; then |
| 112 | cp $BUILD_DIR/conf/bblayers.conf $BUILD_DIR/conf/bblayers.conf.org |
| 113 | else |
| 114 | cp $BUILD_DIR/conf/bblayers.conf.org $BUILD_DIR/conf/bblayers.conf |
| 115 | fi |
| 116 | |
| 117 | echo "" >> $BUILD_DIR/conf/bblayers.conf |
| 118 | echo "# zxic Yocto Project Release layers" >> $BUILD_DIR/conf/bblayers.conf |
| 119 | |
| 120 | hook_in_layer meta-zxic-custom |
| 121 | echo "" >> $BUILD_DIR/conf/bblayers.conf |
| 122 | echo "BBLAYERS += \" \${BSPDIR}/sources/meta-zxic \"" >> $BUILD_DIR/conf/bblayers.conf |
lh | 758261d | 2023-07-13 05:52:04 -0700 | [diff] [blame^] | 123 | echo "BBLAYERS += \" \${BSPDIR}/sources/meta-selinux \"" >> $BUILD_DIR/conf/bblayers.conf |
| 124 | echo "BBLAYERS += \" \${BSPDIR}/sources/meta-zxic-selinux \"" >> $BUILD_DIR/conf/bblayers.conf |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 125 | #echo "BBLAYERS += \" \${BSPDIR}/sources/meta-toolchain/meta-external-toolchain \"" >> $BUILD_DIR/conf/bblayers.conf |
| 126 | #echo "BBLAYERS += \" \${BSPDIR}/sources/meta-toolchain/meta-sourcery \"" >> $BUILD_DIR/conf/bblayers.conf |
| 127 | |
| 128 | echo "BBLAYERS += \" \${BSPDIR}/sources/meta-openembedded/meta-oe \"" >> $BUILD_DIR/conf/bblayers.conf |
| 129 | echo "BBLAYERS += \" \${BSPDIR}/sources/meta-openembedded/meta-python \"" >> $BUILD_DIR/conf/bblayers.conf |
| 130 | echo "BBLAYERS += \" \${BSPDIR}/sources/meta-openembedded/meta-networking \"" >> $BUILD_DIR/conf/bblayers.conf |
| 131 | if [ x"$DISTRO" = x"cpe" ] || [ x"$DISTRO" = x"v2x-openwrt" ] || [ x"$DISTRO" = x"v2x-16bit" ]; then |
| 132 | echo "BBLAYERS += \" \${BSPDIR}/sources/meta-openwrt \"" >> $BUILD_DIR/conf/bblayers.conf |
| 133 | ## echo "BBLAYERS += \" \${BSPDIR}/sources/meta-zxic-openwrt-selinux \"" >> $BUILD_DIR/conf/bblayers.conf |
| 134 | fi |
| 135 | #TCLIBC=`bitbake -e | grep 'TCLIBC='|cut -d'=' -f2|tr -d '"'` |
| 136 | #LIBCPATH=$(cat $(pwd)/../sources/meta-toolchain/toolchain/toolchain-$TCLIBC/toolchain-shar-extract.sh |grep 'LIBC_PATH='|cut -d'=' -f2|tr -d '"') |
| 137 | #if [ ! -f $LIBCPATH/toolchain-shar-extract.sh ] ; then |
| 138 | # . $(pwd)/../sources/meta-toolchain/toolchain/toolchain-$TCLIBC/toolchain-shar-extract.sh |
| 139 | #fi |
| 140 | |
| 141 | cd $BUILD_DIR |
| 142 | clean_up |
| 143 | |