2025-03-05 14:12:56
This commit is contained in:
parent
2172a67359
commit
ecb55ff49a
2 changed files with 328 additions and 1 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -363,7 +363,7 @@ zzz/*
|
|||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
build/
|
||||
#build/
|
||||
bld/
|
||||
[Bb]in/
|
||||
/cmake-build-debug/
|
||||
|
|
327
scripts/build/build.sh
Executable file
327
scripts/build/build.sh
Executable file
|
@ -0,0 +1,327 @@
|
|||
#!/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 <dev@vgisc.com>
|
||||
################################################################################
|
||||
|
||||
# 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 <arch> <install_dir>"
|
||||
echo -e "<arch>: 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 "<install_dir>: The target directory contains the built results."
|
||||
echo -e " The built results will be placed in the directory"
|
||||
echo -e " <install_dir>/<arch>/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 "<install_dir> 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
|
||||
;;
|
||||
arm-linux-gnueabi)
|
||||
export OS=linux
|
||||
export ARCH=arm32
|
||||
;;
|
||||
arm-linux-gnueabihf)
|
||||
export OS=linux
|
||||
export ARCH=arm32
|
||||
;;
|
||||
aarch64-linux-gnu)
|
||||
export OS=linux
|
||||
export ARCH=arm64
|
||||
;;
|
||||
powerpc-linux-gnu)
|
||||
export OS=linux
|
||||
export ARCH=ppc32
|
||||
;;
|
||||
powerpc64-linux-gnu)
|
||||
export OS=linux
|
||||
export ARCH=ppc64
|
||||
;;
|
||||
powerpc64le-linux-gnu)
|
||||
export OS=linux
|
||||
export ARCH=ppc64
|
||||
;;
|
||||
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
|
||||
;;
|
||||
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
|
||||
;;
|
||||
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
|
||||
;;
|
||||
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
|
||||
;;
|
||||
i686-w64-mingw32)
|
||||
export OS=windows
|
||||
export ARCH=mingw32
|
||||
;;
|
||||
x86_64-w64-mingw32)
|
||||
export OS=windows
|
||||
export ARCH=mingw64
|
||||
;;
|
||||
*)
|
||||
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
|
||||
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 BOOT_DIR=${INSTALL_DIR}/rls/${ARCH_BUILD}/boot
|
||||
export INSTALLERS_DIR=${INSTALL_DIR}/installers
|
||||
|
||||
echo ""
|
||||
echo "=> Change to source directory: ${SRC_DIR}/"
|
||||
cd ${SRC_DIR}
|
||||
|
||||
echo ""
|
||||
echo "=> Clean output and old build"
|
||||
mkdir ${SRC_DIR}/build_${ARCH_BUILD}
|
||||
rm -rf ${SRC_DIR}/build_${ARCH_BUILD}/*
|
||||
cd ${SRC_DIR}/build_${ARCH_BUILD}/
|
||||
|
||||
echo ""
|
||||
echo "=> Building in source tree: ${SRC_DIR}/..."
|
||||
export CROSS_COMPILE=
|
||||
case "${ARCH_BUILD}" in
|
||||
linux-x86_64)
|
||||
cmake .. -DBUILD_CONFIG=mysql_release \
|
||||
-DCMAKE_INSTALL_PREFIX=${PREFIX}
|
||||
cmake --build . --parallel 16
|
||||
make DESTDIR=${RELEASE_DIR} install
|
||||
;;
|
||||
*)
|
||||
cmake .. -DBUILD_CONFIG=mysql_release \
|
||||
-DCMAKE_INSTALL_PREFIX=${PREFIX}
|
||||
cmake --build . --parallel 16
|
||||
make DESTDIR=${RELEASE_DIR} install
|
||||
;;
|
||||
esac
|
||||
|
||||
echo ""
|
||||
echo "=> Clean the build"
|
||||
rm -rf ${SRC_DIR}/build_${ARCH_BUILD}
|
||||
|
||||
echo ""
|
||||
echo "=> Done."
|
||||
echo ""
|
||||
################################################################################
|
||||
# BASH SCRIPT ON LINUX/UNIX - END
|
||||
################################################################################
|
Loading…
Add table
Add a link
Reference in a new issue