Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build scripts configured for zsh, not bash? #116

Open
twilwa opened this issue Jun 19, 2024 · 3 comments
Open

build scripts configured for zsh, not bash? #116

twilwa opened this issue Jun 19, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@twilwa
Copy link

twilwa commented Jun 19, 2024

hey, not sure if i'm missing something -- it looks to me like the scripts are only built for zsh rather than bash in the .github folder. I replaced a few of the variables but I'm still getting errors -- is there a for-bash-not-zsh script somewhere or is the script intended to handle both types of shell?

@twilwa
Copy link
Author

twilwa commented Jun 19, 2024

Did some rerigging, script i'm working with currently is:

#!/usr/bin/env bash

set -e
set -u
set -o pipefail

## Enable for script debugging
# set -x

SCRIPT_HOME=$(dirname "$(realpath "$0")")
CMAKE_PREFIX_PATH=~/Qt/6.7.2/gcc_64

function trap_exit {
  local return_value=$?
  if [[ -n ${CI:-} ]]; then unset NSUnbufferedIO; fi
  return ${return_value}
}
trap trap_exit EXIT

function trap_err {
  echo "Script execution error occurred!" >&2
  echo "Callstack:" >&2
  for line in "${BASH_SOURCE[@]}"; do
    echo "$line" >&2
  done
  exit 2
}
trap trap_err ERR

function check_linux {
  echo "Checking Linux dependencies..."
  if ! command -v ninja &> /dev/null; then
    echo "Ninja build system is not installed. Installing..."
    sudo apt-get update && sudo apt-get install -y ninja-build
  fi
  if ! command -v gcc &> /dev/null; then
    echo "GCC compiler is not installed. Installing..."
    sudo apt-get update && sudo apt-get install -y build-essential
  fi
  if ! dpkg -l | grep -q libobs-dev; then
    echo "libobs-dev is not installed. Installing..."
    sudo apt-get update && sudo apt-get install -y libobs-dev
  fi
  if ! dpkg -l | grep -q qtbase5-dev; then
    echo "Qt base development packages are not installed. Installing..."
    sudo apt-get update && sudo apt-get install -y qtbase5-dev qt5-qmake qttools5-dev-tools
  fi
}

function setup_ccache {
  echo "Setting up ccache..."
  if ! command -v ccache &> /dev/null; then
    echo "ccache is not installed. Installing..."
    sudo apt-get update && sudo apt-get install -y ccache
  fi
}

function build {
  local host_os=$(uname | tr '[:upper:]' '[:lower:]')
  local project_root=$(dirname "$(dirname "$SCRIPT_HOME")")
  local buildspec_file="${project_root}/buildspec.json"

  if [[ ! -r "$buildspec_file" ]]; then
    echo 'No buildspec.json found. Please create a build specification for your project.' >&2
    return 2
  fi

  local target="${host_os}-${HOSTTYPE}"
  local config='RelWithDebInfo'
  local verbosity=1

  check_linux
  setup_ccache

  if [[ ! -d "$CMAKE_PREFIX_PATH/include/QtWidgets" ]]; then
    echo "QtWidgets not found. Please verify your Qt installation." >&2
    exit 2
  fi

  local build_dir="${project_root}/build"

  mkdir -p "$build_dir"

  pushd "$project_root"
  echo "Configuring project..."

  local cmake_args=(
    -DCMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH"
    -DCMAKE_BUILD_TYPE="$config"
    -G "Ninja"
  )

  echo "CMake arguments: ${cmake_args[*]}"

  cmake -S "$project_root" -B "$build_dir" "${cmake_args[@]}"

  echo "Building project..."
  cmake --build "$build_dir"

  echo "Installing project..."
  cmake --install "$build_dir"

  popd
}

build "$@"

image

is the current error, i beleive i got a different one on one run of the script but it seems to have landed here. will tweak it a bit more later, but i'm presuming i'm missing something about the bash/zsh thing that may save me much more trouble lol

@twilwa
Copy link
Author

twilwa commented Jun 20, 2024

Ended up installing zsh -- I'm still failing on Pop! OS with the following error:
image
which now occurs after re-running the script, the first script erroring out on the GPG key step:

image

@royshil
Copy link
Collaborator

royshil commented Jun 25, 2024

i'm using the build scripts from https://github.com/obsproject/obs-plugintemplate
they use zsh
but zsh should be available or installable in all *nix OSs frankly

i don't have capacity to translate to bash. unfortunately

@royshil royshil added the enhancement New feature or request label Jun 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
2 participants