Unverified Commit 9b1b5679 authored by lassulus's avatar lassulus Committed by GitHub
Browse files

live555: build dynamic, add check (#396471)

parents b53c0d27 00c8cbbc
Loading
Loading
Loading
Loading
+36 −8
Original line number Diff line number Diff line
{
  lib,
  buildPackages,
  cctools,
  fetchpatch,
  fetchurl,
  lib,
  live555,
  openssl,
  runCommand,
  stdenv,
  vlc,
}:
let
  isStatic = stdenv.hostPlatform.isStatic;
in

stdenv.mkDerivation (finalAttrs: {
  pname = "live555";
@@ -42,8 +47,8 @@ stdenv.mkDerivation (finalAttrs: {
    "PREFIX=${placeholder "out"}"
    "C_COMPILER=$(CC)"
    "CPLUSPLUS_COMPILER=$(CXX)"
    "LIBRARY_LINK=$(AR) cr "
    "LINK=$(CXX) -o "
    "LIBRARY_LINK=${if isStatic then "$(AR) cr " else "$(CC) -o "}"
  ];

  # Since NIX_CFLAGS_COMPILE affects both C and C++ toolchains, we set CXXFLAGS
@@ -83,7 +88,7 @@ stdenv.mkDerivation (finalAttrs: {
    let
      platform =
        if stdenv.hostPlatform.isLinux then
          "linux"
          if isStatic then "linux" else "linux-with-shared-libraries"
        else if stdenv.hostPlatform.isDarwin then
          "macosx-catalina"
        else
@@ -97,9 +102,32 @@ stdenv.mkDerivation (finalAttrs: {
      runHook postConfigure
    '';

  passthru.tests = {
    # Downstream dependency
    inherit vlc;
  doInstallCheck = true;
  installCheckPhase = ''
    if ! ($out/bin/openRTSP || :) 2>&1 | grep -q "Usage: "; then
      echo "Executing example program failed" >&2
      exit 1
    else
      echo "Example program executed successfully"
    fi
  '';

  passthru.tests =
    let
      emulator = stdenv.hostPlatform.emulator buildPackages;
    in
    {
      # The installCheck phase above cannot be ran in cross-compilation scenarios,
      # therefore the passthru test
      run-test-prog = runCommand "live555-run-test-prog" { } ''
        if ! (${emulator} ${live555}/bin/openRTSP || :) 2>&1 | grep -q "Usage: "; then
          echo "Executing example program failed" >&2
          exit 1
        else
          echo "Example program executed successfully"
          touch $out
        fi
      '';
    };

  meta = {