feat(macos/build): add basic macOS build script based on linux_build.sh (#4598)
This commit is contained in:
parent
aea9512682
commit
f879294449
2 changed files with 276 additions and 62 deletions
|
|
@ -23,19 +23,23 @@ sudo_cmd="sudo"
|
||||||
ubuntu_test_repo=0
|
ubuntu_test_repo=0
|
||||||
step="all"
|
step="all"
|
||||||
|
|
||||||
|
# constants
|
||||||
|
AARCH64="aarch64"
|
||||||
|
DOXYGEN="doxygen"
|
||||||
|
|
||||||
# Reusable function to detect nvcc path
|
# Reusable function to detect nvcc path
|
||||||
function detect_nvcc_path() {
|
function detect_nvcc_path() {
|
||||||
local nvcc_path=""
|
local nvcc_path=""
|
||||||
|
|
||||||
# First check for system-installed CUDA
|
# First check for system-installed CUDA
|
||||||
nvcc_path=$(command -v nvcc 2>/dev/null) || true
|
nvcc_path=$(command -v nvcc 2>/dev/null) || true
|
||||||
if [ -n "$nvcc_path" ]; then
|
if [[ -n "$nvcc_path" ]]; then
|
||||||
echo "$nvcc_path"
|
echo "$nvcc_path"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Then check for locally installed CUDA in build directory
|
# Then check for locally installed CUDA in build directory
|
||||||
if [ -f "${build_dir}/cuda/bin/nvcc" ]; then
|
if [[ -f "${build_dir}/cuda/bin/nvcc" ]]; then
|
||||||
echo "${build_dir}/cuda/bin/nvcc"
|
echo "${build_dir}/cuda/bin/nvcc"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
@ -47,9 +51,9 @@ function detect_nvcc_path() {
|
||||||
# Reusable function to setup NVM environment
|
# Reusable function to setup NVM environment
|
||||||
function setup_nvm_environment() {
|
function setup_nvm_environment() {
|
||||||
# Only setup NVM if it should be used for this distro
|
# Only setup NVM if it should be used for this distro
|
||||||
if [ "$nvm_node" == 1 ]; then
|
if [[ "$nvm_node" == 1 ]]; then
|
||||||
# Check if NVM is installed and source it
|
# Check if NVM is installed and source it
|
||||||
if [ -f "$HOME/.nvm/nvm.sh" ]; then
|
if [[ -f "$HOME/.nvm/nvm.sh" ]]; then
|
||||||
# shellcheck source=/dev/null
|
# shellcheck source=/dev/null
|
||||||
source "$HOME/.nvm/nvm.sh"
|
source "$HOME/.nvm/nvm.sh"
|
||||||
# Use the default node version installed by NVM
|
# Use the default node version installed by NVM
|
||||||
|
|
@ -60,6 +64,7 @@ function setup_nvm_environment() {
|
||||||
echo "NVM not found, using system Node.js if available"
|
echo "NVM not found, using system Node.js if available"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function _usage() {
|
function _usage() {
|
||||||
|
|
@ -191,17 +196,18 @@ function add_arch_deps() {
|
||||||
'wayland'
|
'wayland'
|
||||||
)
|
)
|
||||||
|
|
||||||
if [ "$skip_libva" == 0 ]; then
|
if [[ "$skip_libva" == 0 ]]; then
|
||||||
dependencies+=(
|
dependencies+=(
|
||||||
"libva" # VA-API
|
"libva" # VA-API
|
||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$skip_cuda" == 0 ]; then
|
if [[ "$skip_cuda" == 0 ]]; then
|
||||||
dependencies+=(
|
dependencies+=(
|
||||||
"cuda" # VA-API
|
"cuda" # VA-API
|
||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_debian_based_deps() {
|
function add_debian_based_deps() {
|
||||||
|
|
@ -212,7 +218,7 @@ function add_debian_based_deps() {
|
||||||
"build-essential"
|
"build-essential"
|
||||||
"cmake"
|
"cmake"
|
||||||
"desktop-file-utils"
|
"desktop-file-utils"
|
||||||
"doxygen"
|
"${DOXYGEN}"
|
||||||
"file"
|
"file"
|
||||||
"flex" # required if we need to compile doxygen
|
"flex" # required if we need to compile doxygen
|
||||||
"gcc-${gcc_version}"
|
"gcc-${gcc_version}"
|
||||||
|
|
@ -248,18 +254,20 @@ function add_debian_based_deps() {
|
||||||
"xvfb" # necessary for headless unit testing
|
"xvfb" # necessary for headless unit testing
|
||||||
)
|
)
|
||||||
|
|
||||||
if [ "$skip_libva" == 0 ]; then
|
if [[ "$skip_libva" == 0 ]]; then
|
||||||
dependencies+=(
|
dependencies+=(
|
||||||
"libva-dev" # VA-API
|
"libva-dev" # VA-API
|
||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_test_ppa() {
|
function add_test_ppa() {
|
||||||
if [ "$ubuntu_test_repo" == 1 ]; then
|
if [[ "$ubuntu_test_repo" == 1 ]]; then
|
||||||
$package_install_command "software-properties-common"
|
$package_install_command "software-properties-common"
|
||||||
${sudo_cmd} add-apt-repository ppa:ubuntu-toolchain-r/test -y
|
${sudo_cmd} add-apt-repository ppa:ubuntu-toolchain-r/test -y
|
||||||
fi
|
fi
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_debian_deps() {
|
function add_debian_deps() {
|
||||||
|
|
@ -269,6 +277,7 @@ function add_debian_deps() {
|
||||||
"libayatana-appindicator3-dev"
|
"libayatana-appindicator3-dev"
|
||||||
"systemd-dev"
|
"systemd-dev"
|
||||||
)
|
)
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_ubuntu_deps() {
|
function add_ubuntu_deps() {
|
||||||
|
|
@ -277,6 +286,7 @@ function add_ubuntu_deps() {
|
||||||
dependencies+=(
|
dependencies+=(
|
||||||
"libappindicator3-dev"
|
"libappindicator3-dev"
|
||||||
)
|
)
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_fedora_deps() {
|
function add_fedora_deps() {
|
||||||
|
|
@ -284,7 +294,7 @@ function add_fedora_deps() {
|
||||||
"appstream"
|
"appstream"
|
||||||
"cmake"
|
"cmake"
|
||||||
"desktop-file-utils"
|
"desktop-file-utils"
|
||||||
"doxygen"
|
"${DOXYGEN}"
|
||||||
"gcc${gcc_version}"
|
"gcc${gcc_version}"
|
||||||
"gcc${gcc_version}-c++"
|
"gcc${gcc_version}-c++"
|
||||||
"git"
|
"git"
|
||||||
|
|
@ -319,11 +329,12 @@ function add_fedora_deps() {
|
||||||
"xorg-x11-server-Xvfb" # necessary for headless unit testing
|
"xorg-x11-server-Xvfb" # necessary for headless unit testing
|
||||||
)
|
)
|
||||||
|
|
||||||
if [ "$skip_libva" == 0 ]; then
|
if [[ "$skip_libva" == 0 ]]; then
|
||||||
dependencies+=(
|
dependencies+=(
|
||||||
"libva-devel" # VA-API
|
"libva-devel" # VA-API
|
||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_cuda() {
|
function install_cuda() {
|
||||||
|
|
@ -333,27 +344,27 @@ function install_cuda() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local cuda_override_arg=""
|
local cuda_override_arg=""
|
||||||
if [ "$distro" == "fedora" ]; then
|
if [[ "$distro" == "fedora" ]]; then
|
||||||
cuda_override_arg="--override"
|
cuda_override_arg="--override"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local cuda_prefix="https://developer.download.nvidia.com/compute/cuda/"
|
local cuda_prefix="https://developer.download.nvidia.com/compute/cuda/"
|
||||||
local cuda_suffix=""
|
local cuda_suffix=""
|
||||||
if [ "$architecture" == "aarch64" ]; then
|
if [[ "$architecture" == "${AARCH64}" ]]; then
|
||||||
local cuda_suffix="_sbsa"
|
local cuda_suffix="_sbsa"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$architecture" == "aarch64" ]; then
|
if [[ "$architecture" == "${AARCH64}" ]]; then
|
||||||
# we need to patch the math-vector.h file for aarch64 fedora
|
# we need to patch the math-vector.h file for aarch64 fedora
|
||||||
# back up /usr/include/bits/math-vector.h
|
# back up /usr/include/bits/math-vector.h
|
||||||
math_vector_file=""
|
math_vector_file=""
|
||||||
if [ "$distro" == "ubuntu" ] || [ "$version" == "24.04" ]; then
|
if [[ "$distro" == "ubuntu" ]] || [[ "$version" == "24.04" ]]; then
|
||||||
math_vector_file="/usr/include/aarch64-linux-gnu/bits/math-vector.h"
|
math_vector_file="/usr/include/aarch64-linux-gnu/bits/math-vector.h"
|
||||||
elif [ "$distro" == "fedora" ]; then
|
elif [[ "$distro" == "fedora" ]]; then
|
||||||
math_vector_file="/usr/include/bits/math-vector.h"
|
math_vector_file="/usr/include/bits/math-vector.h"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$math_vector_file" ]; then
|
if [[ -n "$math_vector_file" ]]; then
|
||||||
# patch headers https://bugs.launchpad.net/ubuntu/+source/mumax3/+bug/2032624
|
# patch headers https://bugs.launchpad.net/ubuntu/+source/mumax3/+bug/2032624
|
||||||
${sudo_cmd} cp "$math_vector_file" "$math_vector_file.bak"
|
${sudo_cmd} cp "$math_vector_file" "$math_vector_file.bak"
|
||||||
${sudo_cmd} sed -i 's/__Float32x4_t/int/g' "$math_vector_file"
|
${sudo_cmd} sed -i 's/__Float32x4_t/int/g' "$math_vector_file"
|
||||||
|
|
@ -372,10 +383,10 @@ function install_cuda() {
|
||||||
rm "${build_dir}/cuda.run"
|
rm "${build_dir}/cuda.run"
|
||||||
|
|
||||||
# run cuda patches
|
# run cuda patches
|
||||||
if [ "$cuda_patches" == 1 ]; then
|
if [[ "$cuda_patches" == 1 ]]; then
|
||||||
echo "Applying CUDA patches"
|
echo "Applying CUDA patches"
|
||||||
local patch_dir="${script_dir}/../packaging/linux/patches/${architecture}"
|
local patch_dir="${script_dir}/../packaging/linux/patches/${architecture}"
|
||||||
if [ -d "$patch_dir" ]; then
|
if [[ -d "$patch_dir" ]]; then
|
||||||
for patch in "$patch_dir"/*.patch; do
|
for patch in "$patch_dir"/*.patch; do
|
||||||
echo "Applying patch: $patch"
|
echo "Applying patch: $patch"
|
||||||
patch -p2 \
|
patch -p2 \
|
||||||
|
|
@ -388,6 +399,7 @@ function install_cuda() {
|
||||||
echo "No patches found for architecture: $architecture"
|
echo "No patches found for architecture: $architecture"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_version() {
|
function check_version() {
|
||||||
|
|
@ -398,18 +410,18 @@ function check_version() {
|
||||||
|
|
||||||
echo "Checking if $package_name is installed and at least version $min_version"
|
echo "Checking if $package_name is installed and at least version $min_version"
|
||||||
|
|
||||||
if [ "$distro" == "debian" ] || [ "$distro" == "ubuntu" ]; then
|
if [[ "$distro" == "debian" ]] || [[ "$distro" == "ubuntu" ]]; then
|
||||||
installed_version=$(dpkg -s "$package_name" 2>/dev/null | grep '^Version:' | awk '{print $2}')
|
installed_version=$(dpkg -s "$package_name" 2>/dev/null | grep '^Version:' | awk '{print $2}')
|
||||||
elif [ "$distro" == "fedora" ]; then
|
elif [[ "$distro" == "fedora" ]]; then
|
||||||
installed_version=$(rpm -q --queryformat '%{VERSION}' "$package_name" 2>/dev/null)
|
installed_version=$(rpm -q --queryformat '%{VERSION}' "$package_name" 2>/dev/null)
|
||||||
elif [ "$distro" == "arch" ]; then
|
elif [[ "$distro" == "arch" ]]; then
|
||||||
installed_version=$(pacman -Q "$package_name" | awk '{print $2}' )
|
installed_version=$(pacman -Q "$package_name" | awk '{print $2}' )
|
||||||
else
|
else
|
||||||
echo "Unsupported Distro"
|
echo "Unsupported Distro"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$installed_version" ]; then
|
if [[ -z "$installed_version" ]]; then
|
||||||
echo "Package not installed"
|
echo "Package not installed"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
@ -430,13 +442,13 @@ function run_step_deps() {
|
||||||
# Update the package list
|
# Update the package list
|
||||||
$package_update_command
|
$package_update_command
|
||||||
|
|
||||||
if [ "$distro" == "arch" ]; then
|
if [[ "$distro" == "arch" ]]; then
|
||||||
add_arch_deps
|
add_arch_deps
|
||||||
elif [ "$distro" == "debian" ]; then
|
elif [[ "$distro" == "debian" ]]; then
|
||||||
add_debian_deps
|
add_debian_deps
|
||||||
elif [ "$distro" == "ubuntu" ]; then
|
elif [[ "$distro" == "ubuntu" ]]; then
|
||||||
add_ubuntu_deps
|
add_ubuntu_deps
|
||||||
elif [ "$distro" == "fedora" ]; then
|
elif [[ "$distro" == "fedora" ]]; then
|
||||||
add_fedora_deps
|
add_fedora_deps
|
||||||
${sudo_cmd} dnf group install "$dev_tools_group" -y
|
${sudo_cmd} dnf group install "$dev_tools_group" -y
|
||||||
fi
|
fi
|
||||||
|
|
@ -455,10 +467,10 @@ function run_step_deps() {
|
||||||
# compile cmake if the version is too low
|
# compile cmake if the version is too low
|
||||||
if ! check_version "cmake" "$cmake_min" "inf"; then
|
if ! check_version "cmake" "$cmake_min" "inf"; then
|
||||||
cmake_prefix="https://github.com/Kitware/CMake/releases/download/v"
|
cmake_prefix="https://github.com/Kitware/CMake/releases/download/v"
|
||||||
if [ "$architecture" == "x86_64" ]; then
|
if [[ "$architecture" == "x86_64" ]]; then
|
||||||
cmake_arch="x86_64"
|
cmake_arch="x86_64"
|
||||||
elif [ "$architecture" == "aarch64" ]; then
|
elif [[ "$architecture" == "${AARCH64}" ]]; then
|
||||||
cmake_arch="aarch64"
|
cmake_arch="${AARCH64}"
|
||||||
fi
|
fi
|
||||||
url="${cmake_prefix}${target_cmake_version}/cmake-${target_cmake_version}-linux-${cmake_arch}.sh"
|
url="${cmake_prefix}${target_cmake_version}/cmake-${target_cmake_version}-linux-${cmake_arch}.sh"
|
||||||
echo "cmake url: ${url}"
|
echo "cmake url: ${url}"
|
||||||
|
|
@ -469,27 +481,27 @@ function run_step_deps() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# compile doxygen if version is too low
|
# compile doxygen if version is too low
|
||||||
if ! check_version "doxygen" "$doxygen_min" "$doxygen_max"; then
|
if ! check_version "${DOXYGEN}" "$doxygen_min" "$doxygen_max"; then
|
||||||
if [ "${SUNSHINE_COMPILE_DOXYGEN}" == "true" ]; then
|
if [[ "${SUNSHINE_COMPILE_DOXYGEN}" == "true" ]]; then
|
||||||
echo "Compiling doxygen"
|
echo "Compiling doxygen"
|
||||||
doxygen_url="https://github.com/doxygen/doxygen/releases/download/Release_${_doxygen_min}/doxygen-${doxygen_min}.src.tar.gz"
|
doxygen_url="https://github.com/doxygen/doxygen/releases/download/Release_${_doxygen_min}/${DOXYGEN}-${doxygen_min}.src.tar.gz"
|
||||||
echo "doxygen url: ${doxygen_url}"
|
echo "${DOXYGEN} url: ${doxygen_url}"
|
||||||
pushd "${build_dir}"
|
pushd "${build_dir}"
|
||||||
wget "$doxygen_url" --progress=bar:force:noscroll -q --show-progress -O "doxygen.tar.gz"
|
wget "$doxygen_url" --progress=bar:force:noscroll -q --show-progress -O "${DOXYGEN}.tar.gz"
|
||||||
tar -xzf "doxygen.tar.gz"
|
tar -xzf "${DOXYGEN}.tar.gz"
|
||||||
cd "doxygen-${doxygen_min}"
|
cd "${DOXYGEN}-${doxygen_min}"
|
||||||
cmake -DCMAKE_BUILD_TYPE=Release -G="Ninja" -B="build" -S="."
|
cmake -DCMAKE_BUILD_TYPE=Release -G="Ninja" -B="build" -S="."
|
||||||
ninja -C "build" -j"${num_processors}"
|
ninja -C "build" -j"${num_processors}"
|
||||||
${sudo_cmd} ninja -C "build" install
|
${sudo_cmd} ninja -C "build" install
|
||||||
popd
|
popd
|
||||||
else
|
else
|
||||||
echo "Doxygen version not in range, skipping docs"
|
echo "${DOXYGEN} version not in range, skipping docs"
|
||||||
# Note: cmake_args will be set in cmake step
|
# Note: cmake_args will be set in cmake step
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# install node from nvm
|
# install node from nvm
|
||||||
if [ "$nvm_node" == 1 ]; then
|
if [[ "$nvm_node" == 1 ]]; then
|
||||||
nvm_url="https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh"
|
nvm_url="https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh"
|
||||||
echo "nvm url: ${nvm_url}"
|
echo "nvm url: ${nvm_url}"
|
||||||
wget -qO- ${nvm_url} | bash
|
wget -qO- ${nvm_url} | bash
|
||||||
|
|
@ -501,9 +513,10 @@ function run_step_deps() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# run the cuda install
|
# run the cuda install
|
||||||
if [ "$skip_cuda" == 0 ]; then
|
if [[ "$skip_cuda" == 0 ]]; then
|
||||||
install_cuda
|
install_cuda
|
||||||
fi
|
fi
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function run_step_cmake() {
|
function run_step_cmake() {
|
||||||
|
|
@ -514,7 +527,7 @@ function run_step_cmake() {
|
||||||
|
|
||||||
# Detect CUDA path using the reusable function
|
# Detect CUDA path using the reusable function
|
||||||
nvcc_path=""
|
nvcc_path=""
|
||||||
if [ "$skip_cuda" == 0 ]; then
|
if [[ "$skip_cuda" == 0 ]]; then
|
||||||
nvcc_path=$(detect_nvcc_path)
|
nvcc_path=$(detect_nvcc_path)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -537,32 +550,30 @@ function run_step_cmake() {
|
||||||
"-DSUNSHINE_ENABLE_DRM=ON"
|
"-DSUNSHINE_ENABLE_DRM=ON"
|
||||||
)
|
)
|
||||||
|
|
||||||
if [ "$appimage_build" == 1 ]; then
|
if [[ "$appimage_build" == 1 ]]; then
|
||||||
cmake_args+=("-DSUNSHINE_BUILD_APPIMAGE=ON")
|
cmake_args+=("-DSUNSHINE_BUILD_APPIMAGE=ON")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Publisher metadata
|
# Publisher metadata
|
||||||
if [ -n "$publisher_name" ]; then
|
if [[ -n "$publisher_name" ]]; then
|
||||||
cmake_args+=("-DSUNSHINE_PUBLISHER_NAME='${publisher_name}'")
|
cmake_args+=("-DSUNSHINE_PUBLISHER_NAME='${publisher_name}'")
|
||||||
fi
|
fi
|
||||||
if [ -n "$publisher_website" ]; then
|
if [[ -n "$publisher_website" ]]; then
|
||||||
cmake_args+=("-DSUNSHINE_PUBLISHER_WEBSITE='${publisher_website}'")
|
cmake_args+=("-DSUNSHINE_PUBLISHER_WEBSITE='${publisher_website}'")
|
||||||
fi
|
fi
|
||||||
if [ -n "$publisher_issue_url" ]; then
|
if [[ -n "$publisher_issue_url" ]]; then
|
||||||
cmake_args+=("-DSUNSHINE_PUBLISHER_ISSUE_URL='${publisher_issue_url}'")
|
cmake_args+=("-DSUNSHINE_PUBLISHER_ISSUE_URL='${publisher_issue_url}'")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Handle doxygen docs flag
|
# Handle doxygen docs flag
|
||||||
if ! check_version "doxygen" "$doxygen_min" "$doxygen_max"; then
|
if ! check_version "${DOXYGEN}" "$doxygen_min" "$doxygen_max" && [[ "${SUNSHINE_COMPILE_DOXYGEN}" != "true" ]]; then
|
||||||
if [ "${SUNSHINE_COMPILE_DOXYGEN}" != "true" ]; then
|
cmake_args+=("-DBUILD_DOCS=OFF")
|
||||||
cmake_args+=("-DBUILD_DOCS=OFF")
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Handle CUDA
|
# Handle CUDA
|
||||||
if [ "$skip_cuda" == 0 ]; then
|
if [[ "$skip_cuda" == 0 ]]; then
|
||||||
cmake_args+=("-DSUNSHINE_ENABLE_CUDA=ON")
|
cmake_args+=("-DSUNSHINE_ENABLE_CUDA=ON")
|
||||||
if [ -n "$nvcc_path" ]; then
|
if [[ -n "$nvcc_path" ]]; then
|
||||||
cmake_args+=("-DCMAKE_CUDA_COMPILER:PATH=$nvcc_path")
|
cmake_args+=("-DCMAKE_CUDA_COMPILER:PATH=$nvcc_path")
|
||||||
cmake_args+=("-DCMAKE_CUDA_HOST_COMPILER=gcc-${gcc_version}")
|
cmake_args+=("-DCMAKE_CUDA_HOST_COMPILER=gcc-${gcc_version}")
|
||||||
fi
|
fi
|
||||||
|
|
@ -575,6 +586,7 @@ function run_step_cmake() {
|
||||||
echo "cmake args:"
|
echo "cmake args:"
|
||||||
echo "${cmake_args[@]}"
|
echo "${cmake_args[@]}"
|
||||||
cmake "${cmake_args[@]}"
|
cmake "${cmake_args[@]}"
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function run_step_validation() {
|
function run_step_validation() {
|
||||||
|
|
@ -584,9 +596,10 @@ function run_step_validation() {
|
||||||
appstreamcli validate "build/dev.lizardbyte.app.Sunshine.metainfo.xml"
|
appstreamcli validate "build/dev.lizardbyte.app.Sunshine.metainfo.xml"
|
||||||
appstream-util validate "build/dev.lizardbyte.app.Sunshine.metainfo.xml"
|
appstream-util validate "build/dev.lizardbyte.app.Sunshine.metainfo.xml"
|
||||||
desktop-file-validate "build/dev.lizardbyte.app.Sunshine.desktop"
|
desktop-file-validate "build/dev.lizardbyte.app.Sunshine.desktop"
|
||||||
if [ "$appimage_build" == 0 ]; then
|
if [[ "$appimage_build" == 0 ]]; then
|
||||||
desktop-file-validate "build/dev.lizardbyte.app.Sunshine.terminal.desktop"
|
desktop-file-validate "build/dev.lizardbyte.app.Sunshine.terminal.desktop"
|
||||||
fi
|
fi
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function run_step_build() {
|
function run_step_build() {
|
||||||
|
|
@ -597,30 +610,31 @@ function run_step_build() {
|
||||||
|
|
||||||
# Build the project
|
# Build the project
|
||||||
ninja -C "build"
|
ninja -C "build"
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function run_step_package() {
|
function run_step_package() {
|
||||||
echo "Running step: Package"
|
echo "Running step: Package"
|
||||||
|
|
||||||
# Create the package
|
# Create the package
|
||||||
if [ "$skip_package" == 0 ]; then
|
if [[ "$skip_package" == 0 ]]; then
|
||||||
if [ "$distro" == "debian" ] || [ "$distro" == "ubuntu" ]; then
|
if [[ "$distro" == "debian" ]] || [[ "$distro" == "ubuntu" ]]; then
|
||||||
cpack -G DEB --config ./build/CPackConfig.cmake
|
cpack -G DEB --config ./build/CPackConfig.cmake
|
||||||
elif [ "$distro" == "fedora" ]; then
|
elif [[ "$distro" == "fedora" ]]; then
|
||||||
cpack -G RPM --config ./build/CPackConfig.cmake
|
cpack -G RPM --config ./build/CPackConfig.cmake
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function run_step_cleanup() {
|
function run_step_cleanup() {
|
||||||
echo "Running step: Cleanup"
|
echo "Running step: Cleanup"
|
||||||
|
|
||||||
if [ "$skip_cleanup" == 0 ]; then
|
# restore the math-vector.h file
|
||||||
# restore the math-vector.h file
|
if [[ "$skip_cleanup" == 0 ]] && [[ "$architecture" == "${AARCH64}" ]] && [[ -n "$math_vector_file" ]]; then
|
||||||
if [ "$architecture" == "aarch64" ] && [ -n "$math_vector_file" ]; then
|
${sudo_cmd} mv -f "$math_vector_file.bak" "$math_vector_file"
|
||||||
${sudo_cmd} mv -f "$math_vector_file.bak" "$math_vector_file"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function run_install() {
|
function run_install() {
|
||||||
|
|
@ -657,6 +671,7 @@ function run_install() {
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Determine the OS and call the appropriate function
|
# Determine the OS and call the appropriate function
|
||||||
|
|
@ -764,13 +779,13 @@ echo "Detected Distro: $distro"
|
||||||
echo "Detected Version: $version"
|
echo "Detected Version: $version"
|
||||||
echo "Detected Architecture: $architecture"
|
echo "Detected Architecture: $architecture"
|
||||||
|
|
||||||
if [ "$architecture" != "x86_64" ] && [ "$architecture" != "aarch64" ]; then
|
if [[ "$architecture" != "x86_64" ]] && [[ "$architecture" != "${AARCH64}" ]]; then
|
||||||
echo "Unsupported Architecture"
|
echo "Unsupported Architecture"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# export variables for github actions ci
|
# export variables for github actions ci
|
||||||
if [ -f "$GITHUB_ENV" ]; then
|
if [[ -f "$GITHUB_ENV" ]]; then
|
||||||
{
|
{
|
||||||
echo "CC=gcc-${gcc_version}"
|
echo "CC=gcc-${gcc_version}"
|
||||||
echo "CXX=g++-${gcc_version}"
|
echo "CXX=g++-${gcc_version}"
|
||||||
|
|
|
||||||
199
scripts/macos_build.sh
Executable file
199
scripts/macos_build.sh
Executable file
|
|
@ -0,0 +1,199 @@
|
||||||
|
#!/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 <<EOF
|
||||||
|
This script installs the dependencies and builds the project.
|
||||||
|
The script is intended to be run on an Apple Silicon Mac,
|
||||||
|
but may work on Intel as well.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
$0 [options]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-h, --help Display this help message.
|
||||||
|
--num-processors The number of processors to use for compilation. Default: ${num_processors}.
|
||||||
|
--publisher-name The name of the publisher (not developer) of the application.
|
||||||
|
--publisher-website The URL of the publisher's website.
|
||||||
|
--publisher-issue-url The URL of the publisher's support site or issue tracker.
|
||||||
|
If you provide a modified version of Sunshine, we kindly request that you use your own url.
|
||||||
|
--step Which step(s) to run: deps, cmake, build, or all (default: all)
|
||||||
|
--debug Build in debug mode.
|
||||||
|
--skip-docs Don't build docs.
|
||||||
|
|
||||||
|
Steps:
|
||||||
|
deps Install dependencies only
|
||||||
|
cmake Run cmake configure only
|
||||||
|
build Build the project only
|
||||||
|
all Run all steps (default)
|
||||||
|
EOF
|
||||||
|
|
||||||
|
exit "$exit_code"
|
||||||
|
}
|
||||||
|
|
||||||
|
function run_step_deps() {
|
||||||
|
echo "Running step: Install dependencies"
|
||||||
|
brew update
|
||||||
|
brew install "${required_formulas[@]}"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function run_step_cmake() {
|
||||||
|
echo "Running step: CMake configure"
|
||||||
|
|
||||||
|
# prepare CMAKE args
|
||||||
|
cmake_args=(
|
||||||
|
"-B=build"
|
||||||
|
"-G=${build_system}"
|
||||||
|
"-S=."
|
||||||
|
"-DCMAKE_BUILD_TYPE=${build_type}"
|
||||||
|
"-DBUILD_WERROR=ON"
|
||||||
|
"-DHOMEBREW_ALLOW_FETCHCONTENT=ON"
|
||||||
|
"-DOPENSSL_ROOT_DIR=$(brew --prefix openssl@3 2>/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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue