78 lines
2.8 KiB
Bash
Executable File
78 lines
2.8 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Don't use set -e because we want to handle errors ourselves
|
|
# set -e
|
|
|
|
echo "Building Runner - Dropshell Command Execution Library"
|
|
echo "===================================================="
|
|
|
|
# Create build directory if it doesn't exist
|
|
mkdir -p build || {
|
|
echo "ERROR: Failed to create build directory"
|
|
exit 1
|
|
}
|
|
cd build
|
|
|
|
# Check if pkg-config is available and can find libssh
|
|
if command -v pkg-config &> /dev/null && pkg-config --exists libssh; then
|
|
# If libssh is found through pkg-config, use it
|
|
LIBSSH_PREFIX=$(pkg-config --variable=prefix libssh)
|
|
echo "Found libssh through pkg-config at: $LIBSSH_PREFIX"
|
|
CMAKE_ARGS="-DCMAKE_PREFIX_PATH=$LIBSSH_PREFIX"
|
|
else
|
|
# Otherwise, let CMake try to find it
|
|
CMAKE_ARGS=""
|
|
|
|
# Check if libssh-dev/libssh-devel is installed
|
|
if [ ! -f "/usr/include/libssh/libssh.h" ] && [ ! -f "/usr/local/include/libssh/libssh.h" ]; then
|
|
echo "WARNING: libssh development headers not found in standard locations."
|
|
echo "You may need to install the libssh development package:"
|
|
echo " - Ubuntu/Debian: sudo apt install libssh-dev"
|
|
echo " - CentOS/RHEL: sudo yum install libssh-devel"
|
|
echo " - macOS: brew install libssh"
|
|
echo ""
|
|
echo "Continuing build anyway, but it may fail..."
|
|
echo ""
|
|
|
|
# Offer to run the find_libssh.sh helper script
|
|
if [ -x "../examples/find_libssh.sh" ]; then
|
|
echo "Would you like to run the libssh finder helper script? (y/n)"
|
|
read -r answer
|
|
if [[ "$answer" =~ ^[Yy] ]]; then
|
|
cd ..
|
|
./examples/find_libssh.sh
|
|
cd build
|
|
echo ""
|
|
echo "Continuing with build..."
|
|
fi
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
# Configure and build with error handling
|
|
echo "Running cmake with args: $CMAKE_ARGS"
|
|
if ! cmake $CMAKE_ARGS ..; then
|
|
echo ""
|
|
echo "ERROR: CMake configuration failed."
|
|
echo "This is likely due to missing dependencies. Please check the error message above."
|
|
echo "For libssh issues, try:"
|
|
echo " 1. Install libssh development package: sudo apt install libssh-dev"
|
|
echo " 2. Run our helper script: ./examples/find_libssh.sh"
|
|
echo " 3. If you know where libssh is installed, specify it with:"
|
|
echo " cmake -DLIBSSH_LIBRARY=/path/to/libssh.so -DLIBSSH_INCLUDE_DIR=/path/to/include .."
|
|
exit 1
|
|
fi
|
|
|
|
if ! make -j$(nproc); then
|
|
echo ""
|
|
echo "ERROR: Build failed."
|
|
echo "Please check the error messages above for details."
|
|
exit 1
|
|
fi
|
|
|
|
echo ""
|
|
echo "Build complete. Binary is at build/runner"
|
|
echo ""
|
|
echo "Examples:"
|
|
echo " ./run.sh examples/local_command.json # Run a local command"
|
|
echo " ./run.sh examples/env_vars.json # Run with environment variables" |