blob: dd9059b65a905c0304495ad5c54b4bce4f4851da [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001#!/bin/sh
2#
3# zxic Yocto Project Build Environment Setup Script
4#
5. sources/meta-zxic-custom/tools/setup-utils.sh
6
7CWD=`pwd`
8PROGNAME="setup-environment"
9exit_message ()
10{
11 echo "To return to this build environment later please run:"
12 echo "source setup-environment <build_dir>"
13}
14
15usage()
16{
17 echo -e "\nUsage: source zxic-setup-release.sh
18 Optional parameters: [-b build-dir] [-h]"
19echo "
20 * [-b build-dir]: Build directory, if unspecified script uses 'build' as output directory
21 * [-h]: help
22"
23}
24
25clean_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
34OLD_OPTIND=$OPTIND
35
36while getopts "k:r:t:b:e:gh" zxic_setup_flag
37do
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
47done
48shift $((OPTIND-1))
49if [ $# -ne 0 ]; then
50 zxic_setup_error=true
51 echo -e "Invalid command line ending: '$@'"
52fi
53OPTIND=$OLD_OPTIND
54if test $zxic_setup_help; then
55 usage && clean_up && return 1
56elif test $zxic_setup_error; then
57 clean_up && return 1
58fi
59
60if [ -z "$DISTRO" ]; then
61 DISTRO='cpe'
62fi
63
64if [ -z "$BUILD_DIR" ]; then
65 BUILD_DIR='build'
66fi
67
68if [ -z "$MACHINE" ]; then
69 MACHINE='zx297520v3'
70fi
71
72if [ -z "$SDK" ]; then
73 MK_SDK_VERSION='no'
74else
75 MK_SDK_VERSION=$SDK
76fi
77
78if [ -z "$BOOT_CTL" ]; then
79 BOOT_CTL='normal'
80else
81 BOOT_CTL=$BOOT_CTL
82fi
83
84if [ -z "$STRORAGE_CONF" ]; then
85 STRORAGE_CONF='nand-config-default'
86else
87 STRORAGE_CONF=$STRORAGE_CONF
88fi
89
90# Set up the basic yocto environment
91rm -fr $BUILD_DIR/conf/
92DISTRO=$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
95BUILD_DIR=.
96
97if [ ! -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
101fi
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.
105if [ ! -e $BUILD_DIR/conf/local.conf.org ]; then
106 cp $BUILD_DIR/conf/local.conf $BUILD_DIR/conf/local.conf.org
107else
108 cp $BUILD_DIR/conf/local.conf.org $BUILD_DIR/conf/local.conf
109fi
110
111if [ ! -e $BUILD_DIR/conf/bblayers.conf.org ]; then
112 cp $BUILD_DIR/conf/bblayers.conf $BUILD_DIR/conf/bblayers.conf.org
113else
114 cp $BUILD_DIR/conf/bblayers.conf.org $BUILD_DIR/conf/bblayers.conf
115fi
116
117echo "" >> $BUILD_DIR/conf/bblayers.conf
118echo "# zxic Yocto Project Release layers" >> $BUILD_DIR/conf/bblayers.conf
119
120hook_in_layer meta-zxic-custom
121echo "" >> $BUILD_DIR/conf/bblayers.conf
122echo "BBLAYERS += \" \${BSPDIR}/sources/meta-zxic \"" >> $BUILD_DIR/conf/bblayers.conf
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
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
128echo "BBLAYERS += \" \${BSPDIR}/sources/meta-openembedded/meta-oe \"" >> $BUILD_DIR/conf/bblayers.conf
129echo "BBLAYERS += \" \${BSPDIR}/sources/meta-openembedded/meta-python \"" >> $BUILD_DIR/conf/bblayers.conf
130echo "BBLAYERS += \" \${BSPDIR}/sources/meta-openembedded/meta-networking \"" >> $BUILD_DIR/conf/bblayers.conf
131if [ 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
134fi
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
141cd $BUILD_DIR
142clean_up
143