#!/usr/bin/env bash set -euo pipefail # Default value for arguments num_processors=$(sysctl -n hw.ncpu) publisher_name="LizardByte" publisher_website="https://app.lizardbyte.dev" publisher_issue_url="https://app.lizardbyte.dev/support" step="all" build_docs="ON" build_type="Release" build_system="Unix Makefiles" # environment variables BUILD_VER="" BRANCH=$(git rev-parse --abbrev-ref HEAD) COMMIT=$(git rev-parse --short HEAD) export BUILD_VER export BRANCH export COMMIT # boost could be included here but cmake will build the right version we need required_formulas=( "cmake" "doxygen" "graphviz" "node" "pkgconf" "icu4c@78" "miniupnpc" "openssl@3" "opus" "llvm" ) function _usage() { local exit_code=$1 cat </dev/null)" "-DSUNSHINE_ASSETS_DIR=sunshine/assets" "-DSUNSHINE_BUILD_HOMEBREW=ON" "-DSUNSHINE_ENABLE_TRAY=ON" "-DBUILD_DOCS=${build_docs}" "-DBOOST_USE_STATIC=OFF" ) # Publisher metadata if [[ -n "$publisher_name" ]]; then cmake_args+=("-DSUNSHINE_PUBLISHER_NAME='${publisher_name}'") fi if [[ -n "$publisher_website" ]]; then cmake_args+=("-DSUNSHINE_PUBLISHER_WEBSITE='${publisher_website}'") fi if [[ -n "$publisher_issue_url" ]]; then cmake_args+=("-DSUNSHINE_PUBLISHER_ISSUE_URL='${publisher_issue_url}'") fi # Cmake stuff here mkdir -p "build" echo "cmake args:" echo "${cmake_args[@]}" cmake "${cmake_args[@]}" return 0 } function run_step_build() { echo "Running step: Build" make -C "${build_dir}" -j "${num_processors}" echo "*** To complete installation, run:" echo echo " sudo make -C \"${build_dir}\" install" echo " /usr/local/bin/sunshine" return 0 } function run_install() { case "$step" in deps) run_step_deps ;; cmake) run_step_cmake ;; build) run_step_build ;; all) run_step_deps run_step_cmake run_step_build ;; *) echo "Invalid step: $step" echo "Valid steps are: deps, cmake, build, all" exit 1 ;; esac return 0 } # Parse named arguments while getopts ":h-:" opt; do case ${opt} in h ) _usage 0 ;; - ) case "${OPTARG}" in help) _usage 0 ;; num-processors=*) num_processors="${OPTARG#*=}" ;; publisher-name=*) publisher_name="${OPTARG#*=}" ;; publisher-website=*) publisher_website="${OPTARG#*=}" ;; publisher-issue-url=*) publisher_issue_url="${OPTARG#*=}" ;; step=*) step="${OPTARG#*=}" ;; debug) build_type="Debug" ;; skip-docs) build_docs="OFF" ;; *) echo "Invalid option: --${OPTARG}" 1>&2 _usage 1 ;; esac ;; \? ) echo "Invalid option: -${OPTARG}" 1>&2 _usage 1 ;; esac done shift $((OPTIND -1)) # get directory of this script script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" build_dir="$script_dir/../build" echo "Script Directory: $script_dir" echo "Build Directory: $build_dir" mkdir -p "$build_dir" run_install