pjsip: format

This commit is contained in:
linsui 2024-07-09 20:40:54 +08:00 committed by linsui
parent 3c2e182677
commit af3f6ca5ff

View File

@ -1,17 +1,18 @@
{ lib {
, testers lib,
, stdenv testers,
, fetchFromGitHub stdenv,
, openssl fetchFromGitHub,
, libsamplerate openssl,
, swig libsamplerate,
, alsa-lib swig,
, AppKit alsa-lib,
, CoreFoundation AppKit,
, Security CoreFoundation,
, python3 Security,
, pythonSupport ? true python3,
, runCommand pythonSupport ? true,
runCommand,
}: }:
stdenv.mkDerivation (finalAttrs: { stdenv.mkDerivation (finalAttrs: {
pname = "pjsip"; pname = "pjsip";
@ -24,22 +25,28 @@ stdenv.mkDerivation (finalAttrs: {
hash = "sha256-LDA3o1QMrAxcGuOi/YRoMzXmw/wFkfDs2wweZuIJ2RY="; hash = "sha256-LDA3o1QMrAxcGuOi/YRoMzXmw/wFkfDs2wweZuIJ2RY=";
}; };
patches = [ patches = [ ./fix-aarch64.patch ];
./fix-aarch64.patch
nativeBuildInputs = lib.optionals pythonSupport [
swig
python3
]; ];
nativeBuildInputs = buildInputs =
lib.optionals pythonSupport [ swig python3 ]; [
openssl
buildInputs = [ openssl libsamplerate ] libsamplerate
]
++ lib.optional stdenv.isLinux alsa-lib ++ lib.optional stdenv.isLinux alsa-lib
++ lib.optionals stdenv.isDarwin [ AppKit CoreFoundation Security ]; ++ lib.optionals stdenv.isDarwin [
AppKit
CoreFoundation
Security
];
env = lib.optionalAttrs stdenv.cc.isClang { env =
CXXFLAGS = "-std=c++11"; lib.optionalAttrs stdenv.cc.isClang { CXXFLAGS = "-std=c++11"; }
} // lib.optionalAttrs stdenv.isDarwin { // lib.optionalAttrs stdenv.isDarwin { NIX_CFLAGS_LINK = "-headerpad_max_install_names"; };
NIX_CFLAGS_LINK = "-headerpad_max_install_names";
};
preConfigure = '' preConfigure = ''
export LD=$CC export LD=$CC
@ -51,19 +58,21 @@ stdenv.mkDerivation (finalAttrs: {
configureFlags = [ "--enable-shared" ]; configureFlags = [ "--enable-shared" ];
outputs = [ "out" ] outputs = [ "out" ] ++ lib.optional pythonSupport "py";
++ lib.optional pythonSupport "py";
postInstall = '' postInstall =
''
mkdir -p $out/bin mkdir -p $out/bin
cp pjsip-apps/bin/pjsua-* $out/bin/pjsua cp pjsip-apps/bin/pjsua-* $out/bin/pjsua
mkdir -p $out/share/${finalAttrs.pname}-${finalAttrs.version}/samples mkdir -p $out/share/${finalAttrs.pname}-${finalAttrs.version}/samples
cp pjsip-apps/bin/samples/*/* $out/share/${finalAttrs.pname}-${finalAttrs.version}/samples cp pjsip-apps/bin/samples/*/* $out/share/${finalAttrs.pname}-${finalAttrs.version}/samples
'' + lib.optionalString pythonSupport '' ''
+ lib.optionalString pythonSupport ''
(cd pjsip-apps/src/swig/python && \ (cd pjsip-apps/src/swig/python && \
python setup.py install --prefix=$py python setup.py install --prefix=$py
) )
'' + lib.optionalString stdenv.isDarwin '' ''
+ lib.optionalString stdenv.isDarwin ''
# On MacOS relative paths are used to refer to libraries. All libraries use # On MacOS relative paths are used to refer to libraries. All libraries use
# a relative path like ../lib/*.dylib or ../../lib/*.dylib. We need to # a relative path like ../lib/*.dylib or ../../lib/*.dylib. We need to
# rewrite these to use absolute ones. # rewrite these to use absolute ones.
@ -106,9 +115,7 @@ stdenv.mkDerivation (finalAttrs: {
command = "pjsua --version"; command = "pjsua --version";
}; };
passthru.tests.pkg-config = testers.hasPkgConfigModules { passthru.tests.pkg-config = testers.hasPkgConfigModules { package = finalAttrs.finalPackage; };
package = finalAttrs.finalPackage;
};
passthru.tests.python-pjsua2 = runCommand "python-pjsua2" { } '' passthru.tests.python-pjsua2 = runCommand "python-pjsua2" { } ''
${(python3.withPackages (pkgs: [ pkgs.pjsua2 ])).interpreter} -c "import pjsua2" > $out ${(python3.withPackages (pkgs: [ pkgs.pjsua2 ])).interpreter} -c "import pjsua2" > $out
@ -121,8 +128,6 @@ stdenv.mkDerivation (finalAttrs: {
maintainers = with maintainers; [ olynch ]; maintainers = with maintainers; [ olynch ];
mainProgram = "pjsua"; mainProgram = "pjsua";
platforms = platforms.linux ++ platforms.darwin; platforms = platforms.linux ++ platforms.darwin;
pkgConfigModules = [ pkgConfigModules = [ "libpjproject" ];
"libpjproject"
];
}; };
}) })