Skip to content

Commit

Permalink
[CODEQL] workflow script change
Browse files Browse the repository at this point in the history
  • Loading branch information
nots1dd committed Nov 18, 2024
1 parent d4f6dfa commit 5016f4c
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions .github/workflows/build-ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ install_dependencies() {
done

if [ ${#missing_deps[@]} -ne 0 ]; then
gum style --foreground 212 "Installing missing dependencies: ${missing_deps[*]}..."
echo "Installing missing dependencies: ${missing_deps[*]}..."
sudo apt update
for dep in "${missing_deps[@]}"; do
sudo apt install -y "$dep"
Expand All @@ -19,10 +19,10 @@ install_dependencies() {
}

# Check for required dependencies (gum, curl, wget)
install_dependencies gum curl wget
install_dependencies curl wget pkg-config wayland-protocols

# Function to check pkg-config dependencies
gum style --foreground 212 "Checking for required dependencies..."
echo "Checking for required pkg-config dependencies..."

REQUIRED_LIBS=(
wayland-client
Expand All @@ -37,18 +37,18 @@ REQUIRED_LIBS=(
missing_libs=()
for lib in "${REQUIRED_LIBS[@]}"; do
if ! pkg-config --exists "$lib"; then
gum style --foreground 196 "Dependency missing: $lib"
echo "Dependency missing: $lib"
missing_libs+=("$lib")
else
gum style --foreground 118 "Dependency found: $lib"
echo "Dependency found: $lib"
fi
done

if [ ${#missing_libs[@]} -ne 0 ]; then
gum style --foreground 196 "Error: Missing dependencies: ${missing_libs[*]}"
echo "Error: Missing dependencies: ${missing_libs[*]}"
exit 1
else
gum style --foreground 118 "All dependencies are met."
echo "All dependencies are met."
fi

# Download stb_image.h
Expand All @@ -57,19 +57,19 @@ STB_PATH="include/stb_image.h"

mkdir -p include
if [ ! -f "$STB_PATH" ]; then
gum style --foreground 212 "Downloading stb_image.h..."
echo "Downloading stb_image.h..."
if command -v wget &> /dev/null; then
wget -q -O "$STB_PATH" "$STB_URL"
gum style --foreground 118 "stb_image.h downloaded using wget."
echo "stb_image.h downloaded using wget."
elif command -v curl &> /dev/null; then
curl -s -o "$STB_PATH" "$STB_URL"
gum style --foreground 118 "stb_image.h downloaded using curl."
echo "stb_image.h downloaded using curl."
else
gum style --foreground 196 "Error: wget or curl not found. Cannot download stb_image.h."
echo "Error: wget or curl not found. Cannot download stb_image.h."
exit 1
fi
else
gum style --foreground 118 "stb_image.h already exists. Skipping download."
echo "stb_image.h already exists. Skipping download."
fi

# Generate Wayland protocols
Expand All @@ -79,64 +79,64 @@ EXT_PROTOCOL="/usr/share/wayland-protocols/staging/ext-session-lock/ext-session-
XDG_PROTOCOL="/usr/share/wayland-protocols/stable/xdg-shell/xdg-shell.xml"

if [ -f "$EXT_PROTOCOL" ]; then
gum style --foreground 212 "Generating headers and sources for EXT_SESSION_LOCK_V1 protocol..."
echo "Generating headers and sources for EXT_SESSION_LOCK_V1 protocol..."
wayland-scanner client-header "$EXT_PROTOCOL" protocols/ext-session-lock-client-protocol.h
wayland-scanner private-code "$EXT_PROTOCOL" protocols/src/ext-session-lock-client-protocol.c
gum style --foreground 118 "EXT_SESSION_LOCK_V1 protocol generated successfully."
echo "EXT_SESSION_LOCK_V1 protocol generated successfully."
else
gum style --foreground 196 "Error: EXT_SESSION_LOCK_V1 protocol file not found."
echo "Error: EXT_SESSION_LOCK_V1 protocol file not found."
exit 1
fi

if [ -f "$XDG_PROTOCOL" ]; then
gum style --foreground 212 "Generating headers and sources for XDG_SHELL protocol..."
echo "Generating headers and sources for XDG_SHELL protocol..."
wayland-scanner client-header "$XDG_PROTOCOL" protocols/xdg-shell-client-protocol.h
wayland-scanner private-code "$XDG_PROTOCOL" protocols/src/xdg-shell-client-protocol.c
gum style --foreground 118 "XDG_SHELL protocol generated successfully."
echo "XDG_SHELL protocol generated successfully."
else
gum style --foreground 196 "Error: XDG_SHELL protocol file not found."
echo "Error: XDG_SHELL protocol file not found."
exit 1
fi

# Ask user for build system choice
gum style --foreground 212 "Select build system:"
build_system=$(gum choose "Make" "CMake" "Meson")
# Ask user for build system choice (this part is adjusted for GitHub Actions)
echo "Selecting build system: Make"
build_system="Make"

case "$build_system" in
"Make")
gum style --foreground 212 "Building project with Make..."
echo "Building project with Make..."
if make; then
gum style --foreground 118 "Build completed successfully with Make."
echo "Build completed successfully with Make."
else
gum style --foreground 196 "Build failed with Make."
echo "Build failed with Make."
exit 1
fi
;;
"CMake")
gum style --foreground 212 "Building project with CMake..."
echo "Building project with CMake..."
mkdir -p build && cd build
if cmake .. && cmake --build .; then
gum style --foreground 118 "Build completed successfully with CMake."
echo "Build completed successfully with CMake."
else
gum style --foreground 196 "Build failed with CMake."
echo "Build failed with CMake."
exit 1
fi
cd ..
;;
"Meson")
gum style --foreground 212 "Building project with Meson..."
echo "Building project with Meson..."
meson setup build
if meson compile -C build; then
gum style --foreground 118 "Build completed successfully with Meson."
echo "Build completed successfully with Meson."
else
gum style --foreground 196 "Build failed with Meson."
echo "Build failed with Meson."
exit 1
fi
;;
*)
gum style --foreground 196 "Error: Invalid build system selected."
echo "Error: Invalid build system selected."
exit 1
;;
esac

gum style --foreground 118 "Script completed successfully."
echo "Script completed successfully."

0 comments on commit 5016f4c

Please sign in to comment.