diff --git a/scripts/build/build.sh b/scripts/build/build.sh new file mode 100755 index 0000000000..5c87c32871 --- /dev/null +++ b/scripts/build/build.sh @@ -0,0 +1,378 @@ +#!/bin/bash +################################################################################ +# Intended use: Compile and extract software packages +# +# Notes: This script support Linux Bash shell script only +# Install Bash from https://www.gnu.org/software/bash/ +# +# Copyright (C) 2015 - 2025, VGISC Dev Team +################################################################################ + +# Source path +export SCRIPT=$(readlink -f "$0") +export SCRIPT_PATH=$(dirname "$SCRIPT") +export SRC_DIR=${SCRIPT_PATH}/../.. +export APP_NAME=$(basename $(dirname $(dirname "${SCRIPT_PATH}"))) + +# Declare input +ARCH_BUILD=$1 +INSTALL_DIR=$2 +export BUILD_TYPE=release + +# ********************************************************************* +# Function: print_help +# - Print: Help +# ********************************************************************* +print_help () +{ + # Print + echo -e "" + echo -e "Syntax: build.sh " + echo -e ": Arch of device hardware. Only support" + echo -e " linux-x86_64 Linux AMD 64 bit general plaform" + echo -e " arm-linux-gnueabi Linux ARM 32 bit for gnueabi general platform" + echo -e " arm-linux-gnueabihf Linux ARM 32 bit for gnueabihf general platform" + echo -e " aarch64-linux-gnu Linux ARM 64 bit for general platform" + echo -e " powerpc-linux-gnu Linux PPC 32 bit for general platform" + echo -e " powerpc64-linux-gnu Linux PPC 64 bit big endian for general platform" + echo -e " powerpc64le-linux-gnu Linux PPC 64 bit little endian for general platform" + echo -e " arm-linux-gnueabihf-xilinx Linux ARM 32 bit for Xilinx platform" + echo -e " aarch64-linux-gnu-xilinx Linux ARM 64 bit for Xilinx platform" + echo -e " powerpc64-fsl-linux Linux PowerPC 64 bit for NXP QorIQ platform" + echo -e " i686-w64-mingw32 Windows AMD 32 bit platform" + echo -e " x86_64-w64-mingw32 Windows AMD 64 bit platform" + echo -e " arm-openwrt-linux Linux for OpenWRT Kirkwood platform" + echo -e ": The target directory contains the built results." + echo -e " The built results will be placed in the directory" + echo -e " //opt/vgisc/usr/" + echo -e " If value a is not provided, the default output directory is" + echo -e " /opt/vgisc/6t/workspace/BUILD/" + echo -e "" + echo -e "Example:" + echo -e "- Example: build.sh arm-linux-gnueabihf /opt/vgisc/6t/workspace/BUILD" + echo -e "- Example: build.sh \"linux-x86_64\"" + echo -e "" +} + +# Validate input +if [[ -z $ARCH_BUILD ]]; then + echo -e "You must enter enough information. Cannot execute the command." + print_help + exit +fi + +# Variables +item_exists="0" +names=("linux-x86_64" \ +"arm-linux-gnueabi" \ +"arm-linux-gnueabihf" \ +"aarch64-linux-gnu" \ +"powerpc-linux-gnu" \ +"powerpc64-linux-gnu" \ +"powerpc64le-linux-gnu" \ +"arm-linux-gnueabihf-xilinx" \ +"aarch64-linux-gnu-xilinx" \ +"powerpc64-fsl-linux" \ +"i686-w64-mingw32" \ +"x86_64-w64-mingw32" \ +"arm-openwrt-linux") +for item in ${names[@]}; do + if [[ "${item}" = "${ARCH_BUILD}" ]]; then + item_exists="1" + fi +done +if [[ "$item_exists" == "0" ]]; then + echo -e "The build arch is invalid. Cannot execute the command." + echo -e "Build arch must be in supported list." + print_help + exit +fi + +if [[ -z $INSTALL_DIR ]]; then + echo -e " value a is not provided, the default output directory is" + echo -e " /opt/vgisc/6t/workspace/BUILD/" + export INSTALL_DIR="/opt/vgisc/6t/workspace/BUILD" +fi + +if [[ ! -d $INSTALL_DIR ]]; then + echo -e "Folder $INSTALL_DIR does not exist, please create this folder first." + print_help + exit +fi + +echo "" +echo "===========================================================================" +echo "Build ${APP_NAME} for platform ${ARCH_BUILD}" +echo "Build type: ${BUILD_TYPE}" +echo "==========================================================================" + +echo "=> Setting up the build environment for ${ARCH_BUILD}..." +unset LD_LIBRARY_PATH + +case "${ARCH_BUILD}" in +linux-x86_64) + export OS=linux + export ARCH=x86_64 + export LIBZ_FILE=libz.so + ;; +arm-linux-gnueabi) + export OS=linux + export ARCH=arm32 + export LIBZ_FILE=libz.so + ;; +arm-linux-gnueabihf) + export OS=linux + export ARCH=arm32 + export LIBZ_FILE=libz.so + ;; +aarch64-linux-gnu) + export OS=linux + export ARCH=arm64 + export LIBZ_FILE=libz.so + ;; +powerpc-linux-gnu) + export OS=linux + export ARCH=ppc32 + export LIBZ_FILE=libz.so + ;; +powerpc64-linux-gnu) + export OS=linux + export ARCH=ppc64 + export LIBZ_FILE=libz.so + ;; +powerpc64le-linux-gnu) + export OS=linux + export ARCH=ppc64 + export LIBZ_FILE=libz.so + ;; +arm-linux-gnueabihf-xilinx) + export PATH="/opt/Xilinx/arm-buildroot-linux-gnueabihf_sdk/bin:$PATH" + export SYS_ROOT=/opt/Xilinx/arm-buildroot-linux-gnueabihf_sdk/usr/arm-buildroot-linux-gnueabihf/sysroot/usr + export OS=linux + export ARCH=arm32 + export LIBZ_FILE=libz.so + ;; +aarch64-linux-gnu-xilinx) + export PATH="/opt/Xilinx/aarch64-buildroot-linux-gnu_sdk/bin:$PATH" + export SYS_ROOT=/opt/Xilinx/aarch64-buildroot-linux-gnu_sdk/usr/aarch64-buildroot-linux-gnu/sysroot/usr + export OS=linux + export ARCH=arm64 + export LIBZ_FILE=libz.so + ;; +powerpc64-fsl-linux) + . /opt/fsl-qoriq/3.0/environment-setup-ppc64e6500-fsl-linux + export SYSROOT_ALT=/opt/fsl-qoriq/3.0/sysroots/ppc64e6500-fsl-linux/usr + export OS=linux + export ARCH=ppc64 + export LIBZ_FILE=libz.so + ;; +arm-openwrt-linux) + export PATH="/opt/openwrt/arm_xscale_gcc-11.2.0_musl_eabi/bin:$PATH" + export SYS_ROOT=/opt/openwrt/arm_xscale_gcc-11.2.0_musl_eabi + export STAGING_DIR=/opt/openwrt/ + export OS=linux + export ARCH=arm32 + export LIBZ_FILE=libz.so + ;; +i686-w64-mingw32) + export OS=windows + export ARCH=mingw32 + export LIBZ_FILE=zlib1.dll + ;; +x86_64-w64-mingw32) + export OS=windows + export ARCH=mingw64 + export LIBZ_FILE=zlib1.dll + ;; +*) + echo "The build environment cannot be determined. Exit" + exit + ;; +esac + +case "${ARCH_BUILD}" in +linux-x86_64) + export CC=gcc + export LD=ld + export RANLIB=ranlib + export AR=ar + export STRIP=strip + + gcc_bin="$(which gcc)" + if [[ ! -f "${gcc_bin}" ]]; then + echo -e "GCC compiler for ${ARCH_BUILD} does not exist. Exit." + exit + fi + gpp_bin=$(which g++) + if [[ ! -f "${gpp_bin}" ]]; then + echo -e "G++ compiler for ${ARCH_BUILD} does not exist. Exit." + exit + fi + ;; +arm-linux-gnueabihf-xilinx) + export ARM_XILINX=arm-linux-gnueabihf + export TARGET=${ARM_XILINX} + export HOST=${ARM_XILINX} + export CC=${ARM_XILINX}-gcc + export LD=${ARM_XILINX}-ld + export RANLIB=${ARM_XILINX}-ranlib + export AR=${ARM_XILINX}-ar + export STRIP=${ARM_XILINX}-strip + + gcc_bin="$(which ${ARM_XILINX}-gcc)" + if [[ ! -f "${gcc_bin}" ]]; then + echo -e "GCC compiler for ${ARM_XILINX} does not exist. Exit." + exit + fi + gpp_bin=$(which ${ARM_XILINX}-g++) + if [[ ! -f "${gpp_bin}" ]]; then + echo -e "G++ compiler for ${ARM_XILINX} does not exist. Exit." + exit + fi + ;; +aarch64-linux-gnu-xilinx) + export AARCH64_XILINX=aarch64-linux-gnu + export TARGET=${AARCH64_XILINX} + export HOST=${AARCH64_XILINX} + export CC=${AARCH64_XILINX}-gcc + export LD=${AARCH64_XILINX}-ld + export RANLIB=${AARCH64_XILINX}-ranlib + export AR=${AARCH64_XILINX}-ar + export STRIP=${AARCH64_XILINX}-strip + + gcc_bin="$(which ${AARCH64_XILINX}-gcc)" + if [[ ! -f "${gcc_bin}" ]]; then + echo -e "GCC compiler for ${AARCH64_XILINX} does not exist. Exit." + exit + fi + gpp_bin=$(which ${AARCH64_XILINX}-g++) + if [[ ! -f "${gpp_bin}" ]]; then + echo -e "G++ compiler for ${AARCH64_XILINX} does not exist. Exit." + exit + fi + ;; +powerpc64-fsl-linux) + export TARGET=powerpc64-fsl-linux + export HOST=powerpc64-fsl-linux + export STRIP=powerpc64-fsl-linux-strip + + gcc_bin="$(which ${ARCH_BUILD}-gcc)" + if [[ ! -f "${gcc_bin}" ]]; then + echo -e "GCC compiler for ${ARCH_BUILD} does not exist. Exit." + exit + fi + gpp_bin=$(which ${ARCH_BUILD}-g++) + if [[ ! -f "${gpp_bin}" ]]; then + echo -e "G++ compiler for ${ARCH_BUILD} does not exist. Exit." + exit + fi + ;; +*) + export TARGET=${ARCH_BUILD} + export HOST=${ARCH_BUILD} + export CC=${ARCH_BUILD}-gcc + export LD=${ARCH_BUILD}-ld + export RANLIB=${ARCH_BUILD}-ranlib + export AR=${ARCH_BUILD}-ar + export STRIP=${ARCH_BUILD}-strip + + gcc_bin="$(which ${ARCH_BUILD}-gcc)" + if [[ ! -f "${gcc_bin}" ]]; then + echo -e "GCC compiler for ${ARCH_BUILD} does not exist. Exit." + exit + fi + gpp_bin=$(which ${ARCH_BUILD}-g++) + if [[ ! -f "${gpp_bin}" ]]; then + echo -e "G++ compiler for ${ARCH_BUILD} does not exist. Exit." + exit + fi + ;; +esac + +# Output path +export PREFIX=/opt/vgisc/usr +export ETC_DIR=/opt/vgisc/etc/openssl +export THIRD_PARTY_PREFIX=/opt/third_party +export OUTPUT_DIR=output/${APP_NAME}-${ARCH_BUILD}-${BUILD_TYPE} +export ZIP_DIR=${INSTALL_DIR}/zip +export RELEASE_DIR=${INSTALL_DIR}/rls/${ARCH_BUILD}/release +export STATIC_DIR=${INSTALL_DIR}/rls/${ARCH_BUILD}/static +export DYNAMIC_DIR=${INSTALL_DIR}/rls/${ARCH_BUILD}/dynamic +export BOOT_DIR=${INSTALL_DIR}/rls/${ARCH_BUILD}/boot +export INSTALLERS_DIR=${INSTALL_DIR}/installers + +export LIBVCRYPT_SRC=${SRC_DIR}/../libvcrypt-3.3.2 +export ZLIB_SRC=${SRC_DIR}/../../../UTIL/src/zlib-1.3.1 + +echo "" +echo "=> Checking zlib..." +if [[ (! -f ${RELEASE_DIR}${PREFIX}/include/zlib.h) || (! -f ${RELEASE_DIR}${PREFIX}/lib/${LIBZ_FILE}) ]] +then + echo "=> Building zlib in: ${SRC_DIR}/../${ZLIB_SRC}" + ${ZLIB_SRC}/scripts/build/build.sh ${ARCH_BUILD} +else + echo "=> Library zlib is exist in: ${RELEASE_DIR}${PREFIX}/" +fi + +if [[ (! -f ${RELEASE_DIR}${PREFIX}/include/zlib.h) || (! -f ${RELEASE_DIR}${PREFIX}/lib/${LIBZ_FILE}) ]] +then + echo "=> Cannot build without zlib in: ${RELEASE_DIR}${PREFIX}/" + exit +fi + +echo "" +echo "=> Change to source directory: ${SRC_DIR}/" +cd ${SRC_DIR} + +echo "" +echo "=> Clean output and old build" +make clean +make distclean +rm -rf ${SRC_DIR}/${OUTPUT_DIR} +rm -rf ${SRC_DIR}/${OUTPUT_DIR}.tar.gz + +echo "" +echo "=> Building in source tree: ${SRC_DIR}/..." +export CROSS_COMPILE= +case "${ARCH_BUILD}" in +linux-x86_64) +./configure \ + --prefix=${PREFIX} + ;; +*) +./configure \ + --prefix=${PREFIX} --host=${HOST} + ;; +esac + +make -j16 +make -j8 DESTDIR=${SRC_DIR}/${OUTPUT_DIR} install + +echo "" +echo "=> Make output tar.gz file: ${SRC_DIR}/${OUTPUT_DIR}.tar.gz" +rm -rf ${SRC_DIR}/${OUTPUT_DIR}.tar.gz +tar -zcvf ${SRC_DIR}/${OUTPUT_DIR}.tar.gz ${SRC_DIR}/${OUTPUT_DIR}/ + +echo "" +echo "=> Copy output to release directory: ${RELEASE_DIR}${PREFIX}/" +mkdir -p ${RELEASE_DIR} +cp -rf ${SRC_DIR}/${OUTPUT_DIR}/* ${RELEASE_DIR}/ + +echo "" +echo "=> Copy output ${OUTPUT_DIR}.tar.gz to compress directory: ${ZIP_DIR}/" +mkdir -p ${ZIP_DIR}/ +cp -rf ${SRC_DIR}/${OUTPUT_DIR}.tar.gz ${ZIP_DIR}/ + +echo "" +echo "=> Clean the build" +make clean +make distclean +rm -rf ${SRC_DIR}/${OUTPUT_DIR} +rm -rf ${SRC_DIR}/${OUTPUT_DIR}.tar.gz + +echo "" +echo "=> Done." +echo "" +################################################################################ +# BASH SCRIPT ON LINUX/UNIX - END +################################################################################ \ No newline at end of file diff --git a/scripts/util/util_git_push.sh b/scripts/util/util_git_push.sh new file mode 100755 index 0000000000..12bf57dd75 --- /dev/null +++ b/scripts/util/util_git_push.sh @@ -0,0 +1,20 @@ +################################################################################ +# BASH SCRIPT ON LINUX/UNIX - BEGIN +################################################################################ +#!/bin/bash + +export GIT_BRACNH="main" + +export TIMESTAMP=`date +"%Y-%m-%d %H:%M:%S"` +export SCRIPT=$(readlink -f "$0") +export SCRIPT_PATH=$(dirname "$SCRIPT") +export SRC_DIR=${SCRIPT_PATH}/../.. + +cd ${SRC_DIR} +git add . +git checkout ${GIT_BRACNH} +git commit -m "${TIMESTAMP}" +git push -u origin ${GIT_BRACNH} +################################################################################ +# BASH SCRIPT ON LINUX/UNIX - END +################################################################################ \ No newline at end of file diff --git a/scripts/util/util_git_release.sh b/scripts/util/util_git_release.sh new file mode 100755 index 0000000000..f370acaf1c --- /dev/null +++ b/scripts/util/util_git_release.sh @@ -0,0 +1,24 @@ +################################################################################ +# BASH SCRIPT ON LINUX/UNIX - BEGIN +################################################################################ +#!/bin/bash + +export GIT_BRACNH="main" +export GIT_TAG="17.4" + +export TIMESTAMP=`date +"%Y-%m-%d %H:%M:%S"` +export SCRIPT=$(readlink -f "$0") +export SCRIPT_PATH=$(dirname "$SCRIPT") +export SRC_DIR=${SCRIPT_PATH}/../.. + +cd ${SRC_DIR} +git add . +git checkout ${GIT_BRACNH} +git commit -m "${TIMESTAMP}" +git tag -d ${GIT_TAG} +git push origin :refs/tags/${GIT_TAG} +git tag -a ${GIT_TAG} -m ${GIT_TAG} +git push --tags +################################################################################ +# BASH SCRIPT ON LINUX/UNIX - END +################################################################################ \ No newline at end of file