:-'Generic Commit'
This commit is contained in:
@ -71,70 +71,6 @@ function check_packages() {
|
||||
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------------
|
||||
# MUSL CROSS COMPILERS
|
||||
# ----------------------------------------------------------------------------------------------------------
|
||||
|
||||
function installmusl() {
|
||||
echo "Installing musl toolchain"
|
||||
|
||||
# Set install directory
|
||||
if [ -n "$SUDO_USER" ] && [ "$SUDO_USER" != "root" ]; then
|
||||
USER_HOME=$(eval echo "~${SUDO_USER}")
|
||||
else
|
||||
USER_HOME="$HOME"
|
||||
fi
|
||||
INSTALL_DIR="$USER_HOME/.musl-cross"
|
||||
mkdir -p "$INSTALL_DIR"
|
||||
|
||||
TMPDIR=$(mktemp -d)
|
||||
trap 'rm -rf "$TMPDIR"' EXIT
|
||||
|
||||
function install_musl_cross() {
|
||||
local TOOLCHAIN="$1"
|
||||
local MUSL_CC_URL="https://musl.cc"
|
||||
if [ ! -d "$INSTALL_DIR/$TOOLCHAIN" ]; then
|
||||
echo "Downloading $TOOLCHAIN musl cross toolchain..."
|
||||
wget -nc -O "$TMPDIR/$TOOLCHAIN.tgz" "$MUSL_CC_URL/$TOOLCHAIN.tgz"
|
||||
tar -C "$INSTALL_DIR" -xvf "$TMPDIR/$TOOLCHAIN.tgz"
|
||||
fi
|
||||
}
|
||||
|
||||
function check_path() {
|
||||
if [ -n "$SUDO_USER" ] && [ "$SUDO_USER" != "root" ]; then
|
||||
local BASHRC="$USER_HOME/.bashrc"
|
||||
local TOOLCHAIN="$1"
|
||||
local MUSL_PATH="$INSTALL_DIR/$TOOLCHAIN/bin"
|
||||
if ! echo "$PATH" | grep -q "$MUSL_PATH"; then
|
||||
echo "Adding $MUSL_PATH to PATH in $BASHRC"
|
||||
PATH_LINE="export PATH=\"$MUSL_PATH:\$PATH\""
|
||||
if ! grep -Fxq "$PATH_LINE" "$BASHRC"; then
|
||||
echo "" >> "$BASHRC"
|
||||
echo "# Add musl cross compilers to PATH for dropshell" >> "$BASHRC"
|
||||
echo "$PATH_LINE" >> "$BASHRC"
|
||||
echo "Added musl cross compilers to $BASHRC"
|
||||
echo "You should run 'source ~/.bashrc' to update your PATH"
|
||||
else
|
||||
echo "You should run 'source ~/.bashrc' to update your PATH"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
TOOLCHAIN_LIST=(
|
||||
"aarch64-linux-musl-cross"
|
||||
"x86_64-linux-musl-cross"
|
||||
"x86_64-linux-musl-native"
|
||||
)
|
||||
|
||||
for TOOLCHAIN in "${TOOLCHAIN_LIST[@]}"; do
|
||||
install_musl_cross "$TOOLCHAIN"
|
||||
check_path "$TOOLCHAIN"
|
||||
done
|
||||
|
||||
# Clean up
|
||||
rm -rf "$TMPDIR"
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------------
|
||||
# BUILD
|
||||
@ -181,7 +117,8 @@ function build_arch() {
|
||||
echo "Building for ${ARCH} in ${ARCH_BUILD_DIR}, from ${SOURCE_DIR}"
|
||||
|
||||
if [ ! -f "${HOME}/.musl-cross/${ARCH}-linux-musl-cross/bin/${ARCH}-linux-musl-g++" ]; then
|
||||
installmusl
|
||||
echo "Musl cross toolchain not found for ${ARCH}."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
CMAKE_BUILD_TYPE="Release"
|
||||
|
Reference in New Issue
Block a user