Files
llgo/compiler/_lldb/common.sh

55 lines
1.3 KiB
Bash
Raw Normal View History

2024-09-21 10:03:49 +08:00
#!/bin/bash
# Function to find LLDB 18+
find_lldb() {
local lldb_paths=(
"/opt/homebrew/bin/lldb"
"/usr/local/bin/lldb"
"/usr/bin/lldb"
"lldb" # This will use the system PATH
)
for lldb_path in "${lldb_paths[@]}"; do
if command -v "$lldb_path" >/dev/null 2>&1; then
local version
version=$("$lldb_path" --version | grep -oE '[0-9]+' | head -1)
2024-09-21 10:03:49 +08:00
if [ "$version" -ge 18 ]; then
echo "$lldb_path"
return 0
fi
fi
done
echo "Error: LLDB 18 or higher not found" >&2
exit 1
}
# Find LLDB 18+
LLDB_PATH=$(find_lldb)
echo "LLDB_PATH: $LLDB_PATH"
$LLDB_PATH --version
export LLDB_PATH
2024-09-21 10:03:49 +08:00
# Default package path
2025-01-08 21:47:22 +08:00
export DEFAULT_PACKAGE_PATH="./_lldb/lldbtest"
2024-09-21 10:03:49 +08:00
# Function to build the project
build_project() {
2025-01-08 21:47:22 +08:00
# package_path parameter is kept for backward compatibility
local current_dir
current_dir=$(pwd) || return
if ! cd "${DEFAULT_PACKAGE_PATH}"; then
echo "Failed to change directory to ${DEFAULT_PACKAGE_PATH}" >&2
return 1
fi
LLGO_DEBUG=1 llgo build -o "debug.out" . || {
local ret=$?
cd "$current_dir" || return
return $ret
}
cd "$current_dir" || return
}