This commit is contained in:
parent
84fd96e74e
commit
6ac651d4f0
@ -1,86 +1,45 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||||
|
OUTPUT_DIR=${SCRIPT_DIR}/output
|
||||||
|
INSTALL_DIR=${HOME}/.local/bin
|
||||||
|
mkdir -p ${OUTPUT_DIR}
|
||||||
|
|
||||||
# Exit on error
|
# Exit on error
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Colors for output
|
|
||||||
RED='\033[0;31m'
|
|
||||||
GREEN='\033[0;32m'
|
|
||||||
YELLOW='\033[1;33m'
|
|
||||||
NC='\033[0m' # No Color
|
|
||||||
|
|
||||||
JOBS=4
|
|
||||||
# Determine number of CPU cores for parallel build
|
|
||||||
if command -v nproc >/dev/null 2>&1; then
|
|
||||||
JOBS=$(nproc)
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Function to print status messages
|
|
||||||
print_status() {
|
|
||||||
echo -e "${GREEN}[*] $1${NC}"
|
|
||||||
}
|
|
||||||
|
|
||||||
print_error() {
|
|
||||||
echo -e "${RED}[!] $1${NC}"
|
|
||||||
}
|
|
||||||
|
|
||||||
print_warning() {
|
|
||||||
echo -e "${YELLOW}[!] $1${NC}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# ensure we have latest dehydrate.
|
# ensure we have latest dehydrate.
|
||||||
dehydrate -u
|
dehydrate -u
|
||||||
|
|
||||||
# Check if build directory exists, if not create it
|
|
||||||
if [ ! -d "build" ]; then
|
|
||||||
print_status "Creating build directory..."
|
|
||||||
mkdir build
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Enter build directory
|
function build_native() {
|
||||||
cd build
|
local BUILDDIR=${SCRIPT_DIR}/build/native
|
||||||
|
local PREVDIR=$PWD
|
||||||
|
local JOBS=$(nproc) # Set JOBS to the number of available CPU cores
|
||||||
|
mkdir -p ${BUILDDIR}
|
||||||
|
cd ${SCRIPT_DIR}
|
||||||
|
|
||||||
# Check if CMake is installed
|
cmake -B ${BUILDDIR} -G Ninja \
|
||||||
if ! command -v cmake &> /dev/null; then
|
-DCMAKE_BUILD_TYPE=Debug \
|
||||||
print_error "CMake is not installed. Please install CMake first."
|
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
|
||||||
exit 1
|
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
|
||||||
fi
|
-DCMAKE_LINKER=mold \
|
||||||
|
-DCMAKE_C_COMPILER=clang \
|
||||||
|
-DCMAKE_CXX_COMPILER=clang++
|
||||||
|
|
||||||
# Check if Ninja is installed
|
cd ${BUILDDIR}
|
||||||
if ! command -v ninja &> /dev/null; then
|
ninja -j"$JOBS"
|
||||||
print_error "Ninja is not installed. Please install Ninja first."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if ccache is installed
|
upx ${BUILDDIR}/dropshell
|
||||||
if ! command -v ccache &> /dev/null; then
|
cp ${BUILDDIR}/dropshell ${OUTPUT_DIR}/dropshell
|
||||||
print_warning "ccache is not installed. Builds will be slower without it."
|
|
||||||
print_warning "Consider installing ccache for faster builds."
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Configure with CMake
|
cd ${PREVDIR}
|
||||||
print_status "Configuring with CMake..."
|
}
|
||||||
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
|
|
||||||
|
|
||||||
# Build the project
|
build_native
|
||||||
print_status "Building project..."
|
|
||||||
ninja -j"$JOBS"
|
|
||||||
|
|
||||||
# Check if build was successful
|
echo "Auto-installing dropshell locally..."
|
||||||
if [ $? -eq 0 ]; then
|
mkdir -p "${INSTALL_DIR}"
|
||||||
print_status "Build successful!"
|
cp "${OUTPUT_DIR}/dropshell" "${INSTALL_DIR}/dropshell"
|
||||||
else
|
ds version
|
||||||
print_error "Build failed!"
|
echo "Build process completed!"
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
print_status "Auto-installing dropshell locally..."
|
|
||||||
mkdir -p "${HOME}/.local/bin"
|
|
||||||
cp "$SCRIPT_DIR/build/dropshell" "${HOME}/.local/bin/dropshell"
|
|
||||||
|
|
||||||
# Return to original directory
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
print_status "Build process completed!"
|
|
@ -1,11 +1,15 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||||
|
|
||||||
# Create output directory
|
# Create output directory
|
||||||
mkdir -p output
|
mkdir -p ${SCRIPT_DIR}/output
|
||||||
|
|
||||||
|
|
||||||
function build_arch() {
|
function build_arch() {
|
||||||
local arch=$1
|
local arch=$1
|
||||||
|
local PREVDIR=$PWD
|
||||||
|
cd ${SCRIPT_DIR}
|
||||||
|
|
||||||
if [ ! -f "${HOME}/.musl-cross/${arch}-linux-musl-cross/bin/${arch}-linux-musl-c++" ]; then
|
if [ ! -f "${HOME}/.musl-cross/${arch}-linux-musl-cross/bin/${arch}-linux-musl-c++" ]; then
|
||||||
echo "Musl cross compiler for ${arch} not found. Please run install_build_prerequisites.sh first."
|
echo "Musl cross compiler for ${arch} not found. Please run install_build_prerequisites.sh first."
|
||||||
@ -16,14 +20,16 @@ function build_arch() {
|
|||||||
CC="${HOME}/.musl-cross/${arch}-linux-musl-cross/bin/${arch}-linux-musl-gcc"
|
CC="${HOME}/.musl-cross/${arch}-linux-musl-cross/bin/${arch}-linux-musl-gcc"
|
||||||
CXX="${HOME}/.musl-cross/${arch}-linux-musl-cross/bin/${arch}-linux-musl-g++"
|
CXX="${HOME}/.musl-cross/${arch}-linux-musl-cross/bin/${arch}-linux-musl-g++"
|
||||||
|
|
||||||
BUILDDIR=build/${arch}
|
BUILDDIR=${SCRIPT_DIR}/build/${arch}
|
||||||
mkdir -p ${BUILDDIR}
|
mkdir -p ${BUILDDIR}
|
||||||
|
|
||||||
cmake -B ${BUILDDIR} -G Ninja -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_C_COMPILER=${CC} -DCMAKE_CXX_COMPILER=${CXX}
|
cmake -B ${BUILDDIR} -G Ninja -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_C_COMPILER=${CC} -DCMAKE_CXX_COMPILER=${CXX}
|
||||||
cmake --build ${BUILDDIR}
|
cmake --build ${BUILDDIR}
|
||||||
|
|
||||||
upx ${BUILDDIR}/dropshell
|
upx ${BUILDDIR}/dropshell
|
||||||
cp ${BUILDDIR}/dropshell output/dropshell.${arch}
|
cp ${BUILDDIR}/dropshell ${SCRIPT_DIR}/output/dropshell.${arch}
|
||||||
|
|
||||||
|
cd ${PREVDIR}
|
||||||
}
|
}
|
||||||
|
|
||||||
build_arch x86_64
|
build_arch x86_64
|
||||||
|
Loading…
x
Reference in New Issue
Block a user