Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 40 additions & 4 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,33 @@ YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color

JOBS=""

# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
-j)
if [[ -z "${2:-}" || "$2" == -* ]]; then
echo -e "${RED}Error: -j requires a number (e.g. -j 4).${NC}"
echo "Usage: $0 [-j N]"
exit 1
fi
if ! [[ "$2" =~ ^[0-9]+$ ]] || [[ "$2" -le 0 ]]; then
echo -e "${RED}Error: -j must be a positive integer (got: $2).${NC}"
echo "Usage: $0 [-j N]"
exit 1
fi
JOBS="$2"
shift 2
;;
*)
echo -e "${RED}Unknown argument: $1${NC}"
echo "Usage: $0 [-j N]"
exit 1
;;
esac
done

echo "Installing..."
echo ""

Expand All @@ -19,9 +46,17 @@ if ! command -v cargo &> /dev/null; then
exit 1
fi

# Run cargo install from the script directory
# Build command
CARGO_CMD=(cargo install --path "$SCRIPT_DIR/crates/pcb")

if [[ -n "$JOBS" ]]; then
echo -e "${YELLOW}Limiting build to $JOBS threads${NC}"
CARGO_CMD+=( -j "$JOBS" )
fi

echo "Building and installing pcb binary..."
if cargo install --path "$SCRIPT_DIR/crates/pcb"; then

if "${CARGO_CMD[@]}"; then
echo ""
echo -e "${GREEN}✓ Zener successfully installed!${NC}"
echo ""
Expand All @@ -30,8 +65,9 @@ if cargo install --path "$SCRIPT_DIR/crates/pcb"; then
else
echo ""
echo -e "${RED}✗ Installation failed.${NC}"
echo -e "${YELLOW} If the build failed because of memory issues, you can try limiting the number of jobs using the -j flag."
echo -e "Try running: ./install.sh -j 1 ${NC}"
echo ""
echo "Please check the error messages above."
exit 1
fi


Loading