Zig-Build-Script/build.sh

37 lines
571 B
Bash
Raw Normal View History

2024-10-04 17:17:46 +02:00
#!/bin/bash
input_string="$1"
if [ -z "$input_string" ]; then
echo "Error: No zig script name provided. Exiting."
exit 1
fi
INPUT_NAME=$input_string
FOLDER_NAME="output"
SCRIPT_DIR="$(dirname "$0")"
FOLDER_PATH="$SCRIPT_DIR/$FOLDER_NAME"
if [ ! -d "$FOLDER_PATH" ]; then
mkdir "$FOLDER_PATH"
fi
cd output
zig build-exe "../$INPUT_NAME"
executable_name="${INPUT_NAME%.zig}"
if [ -f "$executable_name" ]; then
./"$executable_name"
else
echo "Error: Executable '$executable_name' not found. Build might have failed. Exiting."
exit 1
fi