Unverified Commit 7393b1e6 authored by Jasi's avatar Jasi
Browse files

duckstation: add patches for cubeb and git

parent 8bbcf7a1
Loading
Loading
Loading
Loading
+33 −0
Original line number Diff line number Diff line
diff --git a/dep/CMakeLists.txt b/dep/CMakeLists.txt
index 633267c66..b5ab0904c 100644
--- a/dep/CMakeLists.txt
+++ b/dep/CMakeLists.txt
@@ -25,9 +25,8 @@ add_subdirectory(rcheevos EXCLUDE_FROM_ALL)
 disable_compiler_warnings_for_target(rcheevos)
 add_subdirectory(rapidyaml EXCLUDE_FROM_ALL)
 disable_compiler_warnings_for_target(rapidyaml)
-add_subdirectory(cubeb EXCLUDE_FROM_ALL)
-disable_compiler_warnings_for_target(cubeb)
-disable_compiler_warnings_for_target(speex)
+find_package(cubeb REQUIRED GLOBAL)
+add_library(cubeb ALIAS cubeb::cubeb)
 
 if(ENABLE_OPENGL)
   add_subdirectory(glad EXCLUDE_FROM_ALL)
diff --git a/src/util/cubeb_audio_stream.cpp b/src/util/cubeb_audio_stream.cpp
index 52c7299c9..e20b52426 100644
--- a/src/util/cubeb_audio_stream.cpp
+++ b/src/util/cubeb_audio_stream.cpp
@@ -262,9 +262,9 @@ std::vector<std::pair<std::string, std::string>> AudioStream::GetCubebDriverName
   std::vector<std::pair<std::string, std::string>> names;
   names.emplace_back(std::string(), TRANSLATE_STR("AudioStream", "Default"));
 
-  const char** cubeb_names = cubeb_get_backend_names();
-  for (u32 i = 0; cubeb_names[i] != nullptr; i++)
-    names.emplace_back(cubeb_names[i], cubeb_names[i]);
+  cubeb_backend_names backends = cubeb_get_backend_names();
+  for (u32 i = 0; i < backends.count; i++)
+    names.emplace_back(backends.names[i], backends.names[i]);
   return names;
 }
 
+20 −0
Original line number Diff line number Diff line
diff --git a/src/scmversion/gen_scmversion.sh b/src/scmversion/gen_scmversion.sh
index 0f8fa4239..2cc91a4a8 100755
--- a/src/scmversion/gen_scmversion.sh
+++ b/src/scmversion/gen_scmversion.sh
@@ -10,11 +10,11 @@ else
 fi
 
 
-HASH=$(git rev-parse HEAD)
-BRANCH=$(git rev-parse --abbrev-ref HEAD | tr -d '\r\n')
-TAG=$(git describe --dirty | tr -d '\r\n')
+HASH="@gitHash@"
+BRANCH="@gitBranch@"
+TAG="@gitTag@"
 VERSION=$(echo "${TAG}" | sed -E 's/-g[0-9a-f]+//')
-DATE=$(git log -1 --date=iso8601-strict --format=%cd)
+DATE="@gitDate@"
 
 cd $CURDIR
 
+35 −15
Original line number Diff line number Diff line
@@ -29,10 +29,7 @@
  udev,
  libbacktrace,
  ffmpeg_8-headless,
  alsa-lib,
  libjack2,
  libpulseaudio,
  pipewire,
  cubeb,
  fetchurl,
  zip,
  unzip,
@@ -70,14 +67,40 @@ let
      owner = "stenzek";
      repo = "duckstation";
      tag = "v${finalAttrs.version}";
      hash = pkgSources.duckstation.hash_linux;
      deepClone = true;
      hash = "sha256-z6hpjMkz7zlt/NUzGl+Px058O99bfDCXV1l5lBqC6vw=";

      postFetch = ''
        cd $out
        mkdir -p .nixpkgs-auxfiles/
        git rev-parse HEAD > .nixpkgs-auxfiles/git_hash
        git rev-parse --abbrev-ref HEAD | tr -d '\r\n' > .nixpkgs-auxfiles/git_branch
        git describe | tr -d '\r\n' > .nixpkgs-auxfiles/git_tag
        git log -1 --date=iso8601-strict --format=%cd > .nixpkgs-auxfiles/git_date
        rm -rf .git
      '';
    };

    # TODO: Remove once this is fixed upstream.
    postPatch = ''
    patches = [
      ./cubeb-remove-vendor.patch
      ./git-version-info.patch
    ];

    postPatch =
      # Fixes compilation error with nixpkgs libapng
      ''
        substituteInPlace src/util/animated_image.cpp \
          --replace-fail "png_write_frame_head(png_ptr, info_ptr," \
                         "png_write_frame_head(png_ptr, info_ptr, 0,"
      ''
      # Fills in git-info obtained in the `postFetch` step for version
      # information in the UI
      + ''
        gitHash=$(cat .nixpkgs-auxfiles/git_hash) \
        gitBranch=$(cat .nixpkgs-auxfiles/git_branch) \
        gitTag=$(cat .nixpkgs-auxfiles/git_tag) \
        gitDate=$(cat .nixpkgs-auxfiles/git_date) \
        substituteAllInPlace src/scmversion/gen_scmversion.sh
      '';

    vendorDiscordRPC = llvmPackages.stdenv.mkDerivation {
@@ -233,10 +256,7 @@ let
      udev
      libbacktrace
      ffmpeg_8-headless
      alsa-lib
      libjack2
      pipewire
      libpulseaudio
      cubeb
    ]
    ++ [
      finalAttrs.vendorDiscordRPC