This commit is contained in:
parent
c5cb37a5c2
commit
962bfb6ce2
@ -4,17 +4,13 @@ set -euo pipefail
|
|||||||
|
|
||||||
# SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
# SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||||
|
|
||||||
ARCHS=(
|
|
||||||
"x86_64"
|
|
||||||
"aarch64"
|
|
||||||
)
|
|
||||||
|
|
||||||
HOSTARCH=$(uname -m)
|
HOSTARCH=$(uname -m)
|
||||||
|
|
||||||
# set flags from command line
|
# set flags from command line
|
||||||
RELEASE=0
|
RELEASE=0
|
||||||
MULTIBUILD=0
|
MULTIBUILD=0
|
||||||
|
|
||||||
|
MUSL_ROOT_PATH="${HOME}/.musl-cross"
|
||||||
|
|
||||||
function help() {
|
function help() {
|
||||||
echo "Usage: $0 [options]"
|
echo "Usage: $0 [options]"
|
||||||
@ -57,15 +53,22 @@ function centerlittletitle() {
|
|||||||
function set_current_arch() {
|
function set_current_arch() {
|
||||||
local FULLARCH="$1"
|
local FULLARCH="$1"
|
||||||
# e.g. aarch64-linux-musl-cross
|
# e.g. aarch64-linux-musl-cross
|
||||||
# split on -
|
# ARCH=aarch64
|
||||||
|
# ARCH_OS=linux-musl-cross
|
||||||
|
# ARCH_FULL_PREFIX=aarch64-linux-musl-cross
|
||||||
|
# ARCH_SHORT_PREFIX=aarch64-linux-musl
|
||||||
|
# MUSL_PATH=/home/jde/.musl-cross/aarch64-linux-musl-cross
|
||||||
|
# arch should just be x86_64 or aarch64
|
||||||
|
export ARCH="${FULLARCH%%-*}"
|
||||||
export ARCH_OS="${FULLARCH#*-}"
|
export ARCH_OS="${FULLARCH#*-}"
|
||||||
export ARCH_PREFIX="${ARCH}-${OS}"
|
export ARCH_FULL_PREFIX="${FULLARCH}"
|
||||||
export ARCH="${FULLARCH%-*}"
|
export ARCH_SHORT_PREFIX="${FULLARCH%-*}"
|
||||||
export MUSL_PATH="${HOME}/.musl-cross/${FULLARCH}"
|
export MUSL_PATH="${MUSL_ROOT_PATH}/${FULLARCH}"
|
||||||
|
|
||||||
echo "ARCH: ${ARCH}"
|
echo "ARCH: ${ARCH}"
|
||||||
echo "ARCH_OS: ${ARCH_OS}"
|
echo "ARCH_OS: ${ARCH_OS}"
|
||||||
echo "ARCH_PREFIX: ${ARCH_PREFIX}"
|
echo "ARCH_FULL_PREFIX: ${ARCH_FULL_PREFIX}"
|
||||||
|
echo "ARCH_SHORT_PREFIX: ${ARCH_SHORT_PREFIX}"
|
||||||
echo "MUSL_PATH: ${MUSL_PATH}"
|
echo "MUSL_PATH: ${MUSL_PATH}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,8 +93,9 @@ function build_arch() {
|
|||||||
|
|
||||||
echo "Building for ${ARCH} in ${ARCH_BUILD_DIR}"
|
echo "Building for ${ARCH} in ${ARCH_BUILD_DIR}"
|
||||||
|
|
||||||
if [ ! -f "${HOME}/.musl-cross/${ARCH}-linux-musl-cross/bin/${ARCH}-linux-musl-g++" ]; then
|
if [ ! -f "${MUSL_PATH}/bin/${ARCH_SHORT_PREFIX}-g++" ]; then
|
||||||
echo "Musl cross toolchain not found for ${ARCH}."
|
echo "Musl cross toolchain not found for ${ARCH}"
|
||||||
|
echo "Missing file: ${MUSL_PATH}/bin/${ARCH_SHORT_PREFIX}-g++"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -100,8 +104,8 @@ function build_arch() {
|
|||||||
CMAKE_BUILD_TYPE="Debug"
|
CMAKE_BUILD_TYPE="Debug"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export CC="${MUSL_PATH}/bin/${ARCH_PREFIX}-gcc"
|
export CC="${MUSL_PATH}/bin/${ARCH_SHORT_PREFIX}-gcc"
|
||||||
export CXX="${MUSL_PATH}/bin/${ARCH_PREFIX}-g++"
|
export CXX="${MUSL_PATH}/bin/${ARCH_SHORT_PREFIX}-g++"
|
||||||
export SYSROOT="${MUSL_PATH}/${ARCH_OS}/sysroot"
|
export SYSROOT="${MUSL_PATH}/${ARCH_OS}/sysroot"
|
||||||
|
|
||||||
export OPENSSL_ROOT_DIR="${SYSROOT}/usr"
|
export OPENSSL_ROOT_DIR="${SYSROOT}/usr"
|
||||||
@ -157,9 +161,27 @@ function build() {
|
|||||||
|
|
||||||
# if have the -m option, then build for multiple architectures
|
# if have the -m option, then build for multiple architectures
|
||||||
if [ $MULTIBUILD -eq 1 ]; then
|
if [ $MULTIBUILD -eq 1 ]; then
|
||||||
for arch in "${ARCHS[@]}"; do
|
# get all the architectures from the musl-cross-make directory
|
||||||
set_current_arch "$arch"
|
local musl_toolchains
|
||||||
build_arch "$CMAKE_DIR"
|
mapfile -t musl_toolchains < <(ls -d "${MUSL_ROOT_PATH}/"*)
|
||||||
|
|
||||||
|
for tchain in "${musl_toolchains[@]}"; do
|
||||||
|
local arch="${tchain##*/}"
|
||||||
|
local buildthis="false"
|
||||||
|
if [[ "$arch" = "$HOSTARCH"* && "$arch" == *-native ]]; then
|
||||||
|
# Native toolchain for host arch
|
||||||
|
buildthis="true"
|
||||||
|
elif [[ "$arch" != "$HOSTARCH"* && "$arch" != *-native ]]; then
|
||||||
|
# Cross toolchain for non-host arch
|
||||||
|
buildthis="true"
|
||||||
|
fi
|
||||||
|
if [ "$buildthis" = "true" ]; then
|
||||||
|
echo "Building for $arch with $tchain"
|
||||||
|
set_current_arch "$arch"
|
||||||
|
build_arch "$CMAKE_DIR"
|
||||||
|
else
|
||||||
|
echo "Skipping $tchain"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
set_current_arch "$HOSTARCH-linux-musl-native"
|
set_current_arch "$HOSTARCH-linux-musl-native"
|
||||||
|
2
test.sh
2
test.sh
@ -6,7 +6,7 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
|||||||
|
|
||||||
echo "Testing dropshell-build"
|
echo "Testing dropshell-build"
|
||||||
|
|
||||||
DROPSHELL_BUILD_TAG="test" "${SCRIPT_DIR}/src/dropshell-build" "${SCRIPT_DIR}/ipdemo"
|
DROPSHELL_BUILD_TAG="test" "${SCRIPT_DIR}/src/dropshell-build" -r -m "${SCRIPT_DIR}/ipdemo"
|
||||||
|
|
||||||
"${SCRIPT_DIR}/ipdemo/output/ipdemo.x86_64"
|
"${SCRIPT_DIR}/ipdemo/output/ipdemo.x86_64"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user