From c0164caaaae1cb18b740c2762e23601229f96529 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Mon, 1 Jan 2024 18:48:27 -0500 Subject: [PATCH] builds(deps): use miniupnpc package instead of submodule (#1971) Co-authored-by: Cameron Gutman --- .codeql-prebuild-cpp.sh | 1 + .github/workflows/CI.yml | 12 ++++++++-- .gitmodules | 4 ---- cmake/compile_definitions/windows.cmake | 4 ++++ cmake/dependencies/common.cmake | 22 ++----------------- cmake/prep/options.cmake | 1 - docker/debian-bookworm.dockerfile | 1 + docker/debian-bullseye.dockerfile | 1 + docker/fedora-38.dockerfile | 1 + docker/fedora-39.dockerfile | 1 + docker/ubuntu-20.04.dockerfile | 1 + docker/ubuntu-22.04.dockerfile | 1 + docs/source/building/linux.rst | 4 ++++ docs/source/building/macos.rst | 4 ++-- docs/source/building/windows.rst | 21 ++++++++++++++---- packaging/linux/Arch/PKGBUILD | 1 + .../linux/flatpak/dev.lizardbyte.sunshine.yml | 17 ++++++++++++++ packaging/macos/Portfile | 1 + src/upnp.cpp | 4 ++-- third-party/miniupnp | 1 - 20 files changed, 67 insertions(+), 36 deletions(-) delete mode 160000 third-party/miniupnp diff --git a/.codeql-prebuild-cpp.sh b/.codeql-prebuild-cpp.sh index ba4e4016..c3e09d84 100644 --- a/.codeql-prebuild-cpp.sh +++ b/.codeql-prebuild-cpp.sh @@ -15,6 +15,7 @@ sudo apt-get install -y \ libcurl4-openssl-dev \ libdrm-dev \ libevdev-dev \ + libminiupnpc-dev \ libmfx-dev \ libnotify-dev \ libnuma-dev \ diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 64e28c6b..fb74710e 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -350,6 +350,7 @@ jobs: libcurl4-openssl-dev \ libdrm-dev \ libevdev-dev \ + libminiupnpc-dev \ libmfx-dev \ libnotify-dev \ libnuma-dev \ @@ -425,7 +426,9 @@ jobs: fi - name: Set AppImage Version - if: ${{ matrix.type == 'AppImage' && ( needs.check_changelog.outputs.next_version_bare != needs.check_changelog.outputs.last_version ) }} # yamllint disable-line rule:line-length + if: | + matrix.type == 'AppImage' && + (needs.check_changelog.outputs.next_version_bare != needs.check_changelog.outputs.last_version) run: | version=${{ needs.check_changelog.outputs.next_version_bare }} echo "VERSION=${version}" >> $GITHUB_ENV @@ -516,7 +519,7 @@ jobs: - name: Setup Dependencies MacOS run: | # install dependencies using homebrew - brew install cmake curl node openssl opus pkg-config + brew install cmake curl miniupnpc node openssl opus pkg-config # fix openssl header not found # ln -sf /usr/local/opt/openssl/include/openssl /usr/local/include/openssl @@ -530,6 +533,10 @@ jobs: ln -sf $(find /usr/local/Cellar -type d -name "opus" -path "*/opus/*/include" | head -n 1) \ /usr/local/include/opus + # fix miniupnpc header not found + ln -sf $(find /usr/local/Cellar -type d -name "miniupnpc" -path "*/miniupnpc/*/include" | head -n 1) \ + /usr/local/include/miniupnpc + - name: Install Boost # installing boost from homebrew takes 30 minutes in a GitHub runner run: | @@ -757,6 +764,7 @@ jobs: mingw-w64-x86_64-boost mingw-w64-x86_64-cmake mingw-w64-x86_64-curl + mingw-w64-x86_64-miniupnpc mingw-w64-x86_64-nodejs mingw-w64-x86_64-nsis mingw-w64-x86_64-onevpl diff --git a/.gitmodules b/.gitmodules index 108269ff..cf12ef6b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,10 +10,6 @@ path = third-party/ViGEmClient url = https://github.com/nefarius/ViGEmClient branch = master -[submodule "third-party/miniupnp"] - path = third-party/miniupnp - url = https://github.com/miniupnp/miniupnp - branch = master [submodule "third-party/nv-codec-headers"] path = third-party/nv-codec-headers url = https://github.com/FFmpeg/nv-codec-headers diff --git a/cmake/compile_definitions/windows.cmake b/cmake/compile_definitions/windows.cmake index ec3e076f..703106f1 100644 --- a/cmake/compile_definitions/windows.cmake +++ b/cmake/compile_definitions/windows.cmake @@ -11,6 +11,9 @@ add_definitions(-DCURL_STATICLIB) include_directories(SYSTEM ${CURL_STATIC_INCLUDE_DIRS}) link_directories(${CURL_STATIC_LIBRARY_DIRS}) +# miniupnpc +add_definitions(-DMINIUPNP_STATICLIB) + # extra tools/binaries for audio/display devices add_subdirectory(tools) # todo - this is temporary, only tools for Windows are needed, for now @@ -70,6 +73,7 @@ list(PREPEND PLATFORM_LIBRARIES userenv synchronization.lib avrt + iphlpapi ${CURL_STATIC_LIBRARIES}) if(SUNSHINE_ENABLE_TRAY) diff --git a/cmake/dependencies/common.cmake b/cmake/dependencies/common.cmake index 1113832c..8aeb92a8 100644 --- a/cmake/dependencies/common.cmake +++ b/cmake/dependencies/common.cmake @@ -16,26 +16,8 @@ find_package(Threads REQUIRED) pkg_check_modules(CURL REQUIRED libcurl) # miniupnp -if(SUNSHINE_SYSTEM_MINIUPNP) - pkg_check_modules(MINIUPNP miniupnpc REQUIRED) - - # Use includedir pkg-config variable rather than MINIUPNP_INCLUDE_DIRS - # defined above. The latter may be blank, as pkg-config sometimes omits -I - # flags for directories that are searched by default (e.g. /usr/include), - # but we need a value to append /miniupnpc to. Normally source files would - # prefix their #include directives with miniupnpc/, but this does not align - # with the directory structure of the git submodule used below. - pkg_get_variable(MINIUPNP_INCLUDE_DIR miniupnpc includedir) - include_directories(SYSTEM ${MINIUPNP_INCLUDE_DIR}/miniupnpc) -else() - set(UPNPC_BUILD_SHARED OFF CACHE BOOL "No shared libraries") - set(UPNPC_BUILD_TESTS OFF CACHE BOOL "Don't build tests for miniupnpc") - set(UPNPC_BUILD_SAMPLE OFF CACHE BOOL "Don't build samples for miniupnpc") - set(UPNPC_NO_INSTALL ON CACHE BOOL "Don't install any libraries build for miniupnpc") - set(MINIUPNP_LIBRARIES libminiupnpc-static) - add_subdirectory(third-party/miniupnp/miniupnpc) - include_directories(SYSTEM third-party/miniupnp/miniupnpc/include) -endif() +pkg_check_modules(MINIUPNP miniupnpc REQUIRED) +include_directories(SYSTEM ${MINIUPNP_INCLUDE_DIRS}) # ffmpeg pre-compiled binaries if(WIN32) diff --git a/cmake/prep/options.cmake b/cmake/prep/options.cmake index dc6b5f6e..0198decb 100644 --- a/cmake/prep/options.cmake +++ b/cmake/prep/options.cmake @@ -4,7 +4,6 @@ option(SUNSHINE_CONFIGURE_ONLY "Configure special files only, then exit." OFF) option(SUNSHINE_ENABLE_TRAY "Enable system tray icon. This option will be ignored on macOS." ON) option(SUNSHINE_REQUIRE_TRAY "Require system tray icon. Fail the build if tray requirements are not met." ON) -option(SUNSHINE_SYSTEM_MINIUPNP "Use system installation of MiniUPnP rather than the submodule." OFF) option(SUNSHINE_SYSTEM_WAYLAND_PROTOCOLS "Use system installation of wayland-protocols rather than the submodule." OFF) if(APPLE) diff --git a/docker/debian-bookworm.dockerfile b/docker/debian-bookworm.dockerfile index c9d4fccd..6eb1108b 100644 --- a/docker/debian-bookworm.dockerfile +++ b/docker/debian-bookworm.dockerfile @@ -43,6 +43,7 @@ apt-get install -y --no-install-recommends \ libcurl4-openssl-dev \ libdrm-dev \ libevdev-dev \ + libminiupnpc-dev \ libnotify-dev \ libnuma-dev \ libopus-dev \ diff --git a/docker/debian-bullseye.dockerfile b/docker/debian-bullseye.dockerfile index 3e602105..d9862432 100644 --- a/docker/debian-bullseye.dockerfile +++ b/docker/debian-bullseye.dockerfile @@ -44,6 +44,7 @@ apt-get install -y --no-install-recommends \ libcurl4-openssl-dev \ libdrm-dev \ libevdev-dev \ + libminiupnpc-dev \ libnotify-dev \ libnuma-dev \ libopus-dev \ diff --git a/docker/fedora-38.dockerfile b/docker/fedora-38.dockerfile index 9f836fb8..5408782d 100644 --- a/docker/fedora-38.dockerfile +++ b/docker/fedora-38.dockerfile @@ -52,6 +52,7 @@ dnf -y install \ libXrandr-devel \ libXtst-devel \ mesa-libGL-devel \ + miniupnpc-devel \ nodejs \ numactl-devel \ openssl-devel \ diff --git a/docker/fedora-39.dockerfile b/docker/fedora-39.dockerfile index 26b10f4b..cc781a67 100644 --- a/docker/fedora-39.dockerfile +++ b/docker/fedora-39.dockerfile @@ -52,6 +52,7 @@ dnf -y install \ libXrandr-devel \ libXtst-devel \ mesa-libGL-devel \ + miniupnpc-devel \ nodejs \ numactl-devel \ openssl-devel \ diff --git a/docker/ubuntu-20.04.dockerfile b/docker/ubuntu-20.04.dockerfile index bad8285d..4715475a 100644 --- a/docker/ubuntu-20.04.dockerfile +++ b/docker/ubuntu-20.04.dockerfile @@ -45,6 +45,7 @@ apt-get install -y --no-install-recommends \ libcurl4-openssl-dev \ libdrm-dev \ libevdev-dev \ + libminiupnpc-dev \ libnotify-dev \ libnuma-dev \ libopus-dev \ diff --git a/docker/ubuntu-22.04.dockerfile b/docker/ubuntu-22.04.dockerfile index 2f37a691..0e975df0 100644 --- a/docker/ubuntu-22.04.dockerfile +++ b/docker/ubuntu-22.04.dockerfile @@ -44,6 +44,7 @@ apt-get install -y --no-install-recommends \ libcurl4-openssl-dev \ libdrm-dev \ libevdev-dev \ + libminiupnpc-dev \ libnotify-dev \ libnuma-dev \ libopus-dev \ diff --git a/docs/source/building/linux.rst b/docs/source/building/linux.rst index eab0aaab..e3d51f6a 100644 --- a/docs/source/building/linux.rst +++ b/docs/source/building/linux.rst @@ -25,6 +25,7 @@ Install Requirements libcurl4-openssl-dev \ libdrm-dev \ # KMS libevdev-dev \ + libminiupnpc-dev \ libmfx-dev \ # x86_64 only libnotify-dev \ libnuma-dev \ @@ -77,6 +78,7 @@ Install Requirements libXrandr-devel \ # X11 libXtst-devel \ # X11 mesa-libGL-devel \ + miniupnpc-devel \ npm \ numactl-devel \ openssl-devel \ @@ -106,6 +108,7 @@ Install Requirements libcap-dev \ # KMS libdrm-dev \ # KMS libevdev-dev \ + libminiupnpc-dev \ libmfx-dev \ # x86_64 only libnotify-dev \ libnuma-dev \ @@ -155,6 +158,7 @@ Install Requirements libcap-dev \ # KMS libdrm-dev \ # KMS libevdev-dev \ + libminiupnpc-dev \ libmfx-dev \ # x86_64 only libnotify-dev \ libnuma-dev \ diff --git a/docs/source/building/macos.rst b/docs/source/building/macos.rst index 6bfa2c70..d64e4572 100644 --- a/docs/source/building/macos.rst +++ b/docs/source/building/macos.rst @@ -12,14 +12,14 @@ MacPorts Install Requirements .. code-block:: bash - sudo port install avahi boost180 cmake curl libopus npm9 pkgconfig + sudo port install avahi boost180 cmake curl libopus miniupnpc npm9 pkgconfig Homebrew """""""" Install Requirements .. code-block:: bash - brew install boost cmake node opus pkg-config + brew install boost cmake miniupnpc node opus pkg-config # if there are issues with an SSL header that is not found: cd /usr/local/include ln -s ../opt/openssl/include/openssl . diff --git a/docs/source/building/windows.rst b/docs/source/building/windows.rst index a8164d3c..6c8b844f 100644 --- a/docs/source/building/windows.rst +++ b/docs/source/building/windows.rst @@ -14,10 +14,23 @@ Update all packages: Install dependencies: .. code-block:: bash - pacman -S base-devel cmake diffutils gcc git make mingw-w64-x86_64-binutils \ - mingw-w64-x86_64-boost mingw-w64-x86_64-cmake mingw-w64-x86_64-curl \ - mingw-w64-x86_64-nodejs mingw-w64-x86_64-onevpl mingw-w64-x86_64-openssl \ - mingw-w64-x86_64-opus mingw-w64-x86_64-toolchain + pacman -S \ + base-devel \ + cmake \ + diffutils \ + gcc \ + git \ + make \ + mingw-w64-x86_64-binutils \ + mingw-w64-x86_64-boost \ + mingw-w64-x86_64-cmake \ + mingw-w64-x86_64-curl \ + mingw-w64-x86_64-miniupnpc \ + mingw-w64-x86_64-nodejs \ + mingw-w64-x86_64-onevpl \ + mingw-w64-x86_64-openssl \ + mingw-w64-x86_64-opus \ + mingw-w64-x86_64-toolchain Build ----- diff --git a/packaging/linux/Arch/PKGBUILD b/packaging/linux/Arch/PKGBUILD index c14b40db..a0ceb6b5 100644 --- a/packaging/linux/Arch/PKGBUILD +++ b/packaging/linux/Arch/PKGBUILD @@ -24,6 +24,7 @@ depends=('avahi' 'libxfixes' 'libxrandr' 'libxtst' + 'miniupnpc' 'numactl' 'openssl' 'opus' diff --git a/packaging/linux/flatpak/dev.lizardbyte.sunshine.yml b/packaging/linux/flatpak/dev.lizardbyte.sunshine.yml index d4f0c164..b62f0e1d 100644 --- a/packaging/linux/flatpak/dev.lizardbyte.sunshine.yml +++ b/packaging/linux/flatpak/dev.lizardbyte.sunshine.yml @@ -253,6 +253,23 @@ modules: commands: - for n in $(cat patches/series); do if [[ $n != "#"* ]]; then patch -Np1 -i "patches/$n" -d .; fi; done + - name: miniupnpc + buildsystem: cmake + config-opts: + - -DUPNPC_BUILD_SAMPLE=OFF + - -DUPNPC_BUILD_SHARED=ON + - -DUPNPC_BUILD_TESTS=OFF + sources: + - type: archive + url: http://archive.ubuntu.com/ubuntu/pool/main/m/miniupnpc/miniupnpc_2.2.5.orig.tar.gz + sha256: 38acd5f4602f7cf8bcdc1ec30b2d58db2e9912e5d9f5350dd99b06bfdffb517c + - type: archive + url: http://archive.ubuntu.com/ubuntu/pool/main/m/miniupnpc/miniupnpc_2.2.5-1.debian.tar.xz + sha256: f6ab181f3c999ae0630508ea1e6c76ae302262414061acaab12bf8763431ffd1 + - type: shell + commands: + - for n in $(cat patches/series); do if [[ $n != "#"* ]]; then patch -Np1 -i "patches/$n" -d .; fi; done + - name: numactl buildsystem: autotools make-args: diff --git a/packaging/macos/Portfile b/packaging/macos/Portfile index 73a775a1..19aeccf2 100644 --- a/packaging/macos/Portfile +++ b/packaging/macos/Portfile @@ -34,6 +34,7 @@ post-fetch { depends_lib port:avahi \ port:curl \ port:libopus \ + port:miniupnpc \ port:npm9 \ port:pkgconfig diff --git a/src/upnp.cpp b/src/upnp.cpp index 55ef25fd..7a296a8b 100644 --- a/src/upnp.cpp +++ b/src/upnp.cpp @@ -2,8 +2,8 @@ * @file src/upnp.cpp * @brief todo */ -#include -#include +#include +#include #include "config.h" #include "confighttp.h" diff --git a/third-party/miniupnp b/third-party/miniupnp deleted file mode 160000 index fb5c328a..00000000 --- a/third-party/miniupnp +++ /dev/null @@ -1 +0,0 @@ -Subproject commit fb5c328a5e8fd57a3ec0f5d33915377a5d3581f3