Skip to content

Commit

Permalink
Update MacOS build
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher committed Jun 13, 2022
1 parent 65c4f01 commit cc7fc62
Show file tree
Hide file tree
Showing 4 changed files with 175 additions and 40 deletions.
100 changes: 94 additions & 6 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -264,27 +264,106 @@ jobs:
# fix openssl header not found
cd /usr/local/include
ln -s ../opt/openssl/include/openssl .
# update paths for macports
echo "/opt/local/sbin" >> $GITHUB_PATH
echo "/opt/local/bin" >> $GITHUB_PATH
- name: Build MacOS
run: |
# variables for Portfile
owner=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]' )
repo=$(echo ${GITHUB_REPOSITORY#*/} | tr '[:upper:]' '[:lower:]' )
branch=${GITHUB_HEAD_REF}
# check the branch variable
if [ -z "$branch" ]
then
echo "This is a PUSH event"
branch=${GITHUB_BASE_REF}
else
echo "This is a PR event"
fi
echo "Owner: ${owner}"
echo "Repo: ${repo}"
echo "Branch: ${branch}"
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DSUNSHINE_ASSETS_DIR=/usr/local/sunshine/assets -DSUNSHINE_CONFIG_DIR=/usr/local/sunshine/config ..
make -j ${nproc}
cmake -DCMAKE_BUILD_TYPE=Release -DSUNSHINE_ASSETS_DIR=/usr/local/sunshine/assets -DSUNSHINE_CONFIG_DIR=/usr/local/sunshine/config -DGITHUB_OWNER=${owner} -DGITHUB_REPO=${repo} -DGITHUB_BRANCH=${branch} ..
# temporary disable
# make -j ${nproc}
- name: Package MacOS
run: |
mkdir -p artifacts
cd build
# package
cpack -G DragNDrop
cpack -G ZIP
# cpack -G DragNDrop
# mv ./cpack_artifacts/Sunshine.dmg ../artifacts/sunshine-macos-experimental-dragndrop.dmg
# cpack -G Bundle
# mv ./cpack_artifacts/Sunshine.dmg ../artifacts/sunshine-macos-experimental-bundle.dmg
# cpack -G ZIP
# mv ./cpack_artifacts/Sunshine.zip ../artifacts/sunshine-macos-experimental-archive.zip
# move
mv Portfile ../artifacts/Portfile
mv ./cpack_artifacts/Sunshine.dmg ../artifacts/sunshine-macos.dmg
mv ./cpack_artifacts/Sunshine.zip ../artifacts/sunshine-macos.zip
- name: Setup Macports
run : |
curl -O https://distfiles.macports.org/MacPorts/MacPorts-2.7.2.tar.bz2
tar xf MacPorts-2.7.2.tar.bz2
cd MacPorts-2.7.2
./configure
make
sudo make install
cd ../
rm -rf MacPorts-2.7.2*
# update sources
sudo port -v selfupdate
# use custom sources
sudo chmod 777 /opt/local/etc/macports/sources.conf
echo file://$(echo ~)/ports > /opt/local/etc/macports/sources.conf
echo rsync://rsync.macports.org/macports/release/tarballs/ports.tar [default] >> /opt/local/etc/macports/sources.conf
sudo chmod 644 /opt/local/etc/macports/sources.conf
- name: Package with MacPorts
run: |
# setup custom port
mkdir -p ~/ports/multimedia/sunshine
# copy configured Portfile
cp ./artifacts/Portfile ~/ports/multimedia/sunshine/
# index the ports
cd ~/ports
portindex
# build port
sudo port install sunshine
# || cat /opt/local/var/macports/logs/_Users_runner_ports_multimedia_sunshine/Sunshine/main.log \
# && exit 1
# create packages
sudo port dmg sunshine
sudo port pkg sunshine
# move
mv $(port work sunshine)/Sunshine*.dmg ./artifacts/sunshine.dmg
mv $(port work sunshine)/Sunshine*.ppkg ./artifacts/sunshine.pkg
# testing only
ls ~/ports/multimedia/sunshine
cat ~/ports/multimedia/sunshine/Portfile
cat /opt/local/etc/macports/sources.conf
cat ~/ports/Portindex
port search sunshine
- name: Upload Artifacts
if: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }}
Expand All @@ -293,6 +372,15 @@ jobs:
name: sunshine-macos
path: artifacts/

# this step can be removed after packages are fixed
- name: Delete experimental packages
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
working-directory: artifacts
run: |
rm -f ./sunshine-macos-experimental-dragndrop.dmg
rm -f ./sunshine-macos-experimental-bundle.dmg
rm -f ./sunshine-macos-experimental-archive.zip
- name: Create Release
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
uses: SunshineStream/actions/create_release@master
Expand Down
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -443,9 +443,7 @@ endforeach()

target_compile_options(sunshine PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${SUNSHINE_COMPILE_OPTIONS}>;$<$<COMPILE_LANGUAGE:CUDA>:${SUNSHINE_COMPILE_OPTIONS_CUDA};-std=c++17>)

#############
# CPACK / Packaging
####

# Common options
set(CPACK_PACKAGE_NAME "SunshineStream")
Expand Down Expand Up @@ -562,6 +560,7 @@ if(APPLE) # TODO: test
set(CPACK_BUNDLE_NAME "${CMAKE_PROJECT_NAME}")
set(CPACK_BUNDLE_PLIST "${APPLE_PLIST_FILE}")
set(CPACK_BUNDLE_ICON "${PROJECT_SOURCE_DIR}/sunshine.icns")
# set(CPACK_BUNDLE_STARTUP_COMMAND "${INSTALL_RUNTIME_DIR}/sunshine")

# Portfile
configure_file(Portfile.in Portfile @ONLY)
Expand Down
86 changes: 56 additions & 30 deletions Portfile.in
Original file line number Diff line number Diff line change
@@ -1,49 +1,75 @@
# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem 1.0
PortGroup cmake 1.1
PortGroup github 1.0
PortGroup boost 1.0
PortSystem 1.0
PortGroup cmake 1.1
PortGroup github 1.0
PortGroup boost 1.0

github.setup sunshinestream sunshine master
version @PROJECT_VERSION@
revision 1
# bump revision when changes are made to this file
revision 1

categories multimedia
license GPL-3
maintainers {sunshinestream @SunshineStream} {outlook.com:anselm.busse}
platforms darwin
github.setup @GITHUB_OWNER@ @GITHUB_REPO@ @GITHUB_BRANCH@
name @PROJECT_NAME@
version @PROJECT_VERSION@
categories multimedia emulators games
platforms darwin
license GPL-3
maintainers {@SunshineStream sunshinestream}
description @PROJECT_DESCRIPTION@
long_description {*}${description}
homepage @PROJECT_HOMEPAGE_URL@
master_sites https://github.com/@GITHUB_OWNER@/@GITHUB_REPO@/releases

fetch.type git
fetch.type git
post-fetch {
system -W ${worksrcpath} "${git.cmd} submodule update --init --recursive"
}

description @PROJECT_DESCRIPTION@
long_description {*}${description}
homepage @PROJECT_HOMEPAGE_URL@
depends_lib port:avahi \
port:ffmpeg \
port:libopus

depends_lib port:avahi \
port:ffmpeg \
port:libopus
boost.version 1.76

configure.args -DBOOST_ROOT=[boost::install_area] \
-DSUNSHINE_ASSETS_DIR=${prefix}/etc/sunshine/assets \
-DSUNSHINE_CONFIG_DIR=${prefix}/etc/sunshine/config

boost.version 1.76
cmake.out_of_source yes

configure.args -DBOOST_ROOT=[boost::install_area] \
-DSUNSHINE_ASSETS_DIR=${prefix}/etc/sunshine/assets
-DSUNSHINE_CONFIG_DIR=${prefix}/etc/sunshine/config

cmake.out_of_source yes
startupitem.create yes
startupitem.executable "${prefix}/bin/{$name}"
startupitem.location LaunchDaemons
startupitem.name ${name}
startupitem.netchange yes

# is this actually necessary? this should all be handled by CMakeLists
destroot {
xinstall -d -m 755 ${destroot}${prefix}/usr/local/${name}/.assets
xinstall {*}[glob ${worksrcpath}/src_assets/common/assets/*] ${destroot}${prefix}/usr/local/${name}/.assets
xinstall {*}[glob ${worksrcpath}/src_assets/macos/assets/*] ${destroot}${prefix}/usr/local/${name}/.assets
# install assets
xinstall -d -m 755 ${destroot}${prefix}/etc/${name}/assets
xinstall {*}[glob ${worksrcpath}/src_assets/common/assets/*.*] ${destroot}${prefix}/etc/${name}/assets
xinstall {*}[glob ${worksrcpath}/src_assets/macos/assets/*.*] ${destroot}${prefix}/etc/${name}/assets

# install web assets
xinstall -d -m 755 ${destroot}${prefix}/etc/${name}/assets/web/fonts/fontawesome-free-web/css
xinstall -d -m 755 ${destroot}${prefix}/etc/${name}/assets/web/fonts/fontawesome-free-web/webfonts
xinstall {*}[glob ${worksrcpath}/src_assets/common/assets/web/*.*] ${destroot}${prefix}/etc/${name}/assets/web
xinstall {*}[glob ${worksrcpath}/src_assets/common/assets/web/fonts/fontawesome-free-web/*.*] ${destroot}${prefix}/etc/${name}/assets/web/fonts/fontawesome-free-web
xinstall {*}[glob ${worksrcpath}/src_assets/common/assets/web/fonts/fontawesome-free-web/css/*.*] ${destroot}${prefix}/etc/${name}/assets/web/fonts/fontawesome-free-web/css
xinstall {*}[glob ${worksrcpath}/src_assets/common/assets/web/fonts/fontawesome-free-web/webfonts/*.*] ${destroot}${prefix}/etc/${name}/assets/web/fonts/fontawesome-free-web/webfonts
xinstall -d -m 755 ${destroot}${prefix}/etc/${name}/assets/web/images
xinstall -d -m 755 ${destroot}${prefix}/etc/${name}/assets/web/third_party
xinstall {*}[glob ${worksrcpath}/src_assets/common/assets/web/images/*.*] ${destroot}${prefix}/etc/${name}/assets/web/images
xinstall {*}[glob ${worksrcpath}/src_assets/common/assets/web/third_party/*.*] ${destroot}${prefix}/etc/${name}/assets/web/third_party

xinstall -d -m 755 ${destroot}${prefix}/etc/${name}/config

# install sunshine.conf
xinstall {*}[glob ${worksrcpath}/src_assets/common/config/*.*] ${destroot}${prefix}/etc/${name}/config

xinstall -d -m 755 ${destroot}${prefix}/usr/local/${name}/config
xinstall {*}[glob ${worksrcpath}/src_assets/common/config/*] ${destroot}${prefix}/usr/local/${name}/config
xinstall {*}[glob ${worksrcpath}/src_assets/macos/config/*] ${destroot}${prefix}/usr/local/${name}/config
# install apps.json
xinstall {*}[glob ${worksrcpath}/src_assets/macos/config/*.*] ${destroot}${prefix}/etc/${name}/config

# install the binary
xinstall ${workpath}/build/${name} ${destroot}${prefix}/bin
}
26 changes: 24 additions & 2 deletions docs/source/about/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,35 @@ Disk Image File option:

Portfile option:
#. Install `MacPorts <https://www.macports.org>`_
#. Download the ``Portfile`` to ``/tmp`` and run the following code.
#. Update the Macports sources.

.. code-block:: bash
cd /tmp && sudo port install
sudo nano /opt/local/etc/macports/sources.conf
Add this line, replacing your username, below the line that starts with ``rsync``.

file://Users/<username>/ports

``Ctrl+x``, then ``Y`` to exit and save changes.

#. Download the ``Portfile`` to ``~/Downloads`` and run the following code.

.. code-block:: bash
mkdir -p ~/ports/multimedia/sunshine
mv ~/Downlaods/Portfile ~/ports/multimedia/sunshine
cd ~/ports
portindex
sudo port install sunshine
#. The first time you start Sunshine, you will be asked to grant access to screen recording and your microphone.
#. Try to run the following code if you get this error: `Dynamic session lookup supported but failed: launchd did
not provide a socket path, verify that org.freedesktop.dbus-session.plist is loaded!`

.. code-block:: bash
launchctl load -w /Library/LaunchAgents/org.freedesktop.dbus-session.plist
Standalone option:
#. Download and extract ``sunshine-macos.zip``
Expand Down

0 comments on commit cc7fc62

Please sign in to comment.