Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
From 31e8aae418a1af681e389f27d3ad57b5fd7e1ba8 Mon Sep 17 00:00:00 2001
From: Marcin Serwin <marcin@serwin.dev>
Date: Sun, 25 May 2025 01:16:37 +0200
Subject: [PATCH] Emit correct pkg-config file if paths are absolute

CMAKE_INSTALL_INCLUDEDIR and CMAKE_INSTALL_LIBDIR may be defined to be
absolute paths. In this situation they should not be appended to the
prefix.

Signed-off-by: Marcin Serwin <marcin@serwin.dev>
---
CMakeLists.txt | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2e84761..f2219e0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -107,6 +107,17 @@ file(RELATIVE_PATH plutosvg_pc_prefix_relative
set(plutosvg_pc_cflags "")
set(plutosvg_pc_libs_private "")
set(plutosvg_pc_requires "")
+set(plutosvg_pc_requires "")
+if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}")
+ set(plutosvg_pc_includedir "${CMAKE_INSTALL_INCLUDEDIR}")
+else()
+ set(plutosvg_pc_includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
+endif()
+if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}")
+ set(plutosvg_pc_libdir "${CMAKE_INSTALL_LIBDIR}")
+else()
+ set(plutosvg_pc_libdir "\${prefix}/${CMAKE_INSTALL_LIBDIR}")
+endif()

if(MATH_LIBRARY)
string(APPEND plutosvg_pc_libs_private " -lm")
@@ -123,8 +134,8 @@ endif()

string(CONFIGURE [[
prefix=${pcfiledir}/@plutosvg_pc_prefix_relative@
-includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
-libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
+includedir=@plutosvg_pc_includedir@
+libdir=@plutosvg_pc_libdir@

Name: PlutoSVG
Description: Tiny SVG rendering library in C
--
2.49.0

56 changes: 56 additions & 0 deletions pkgs/by-name/pl/plutosvg/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
lib,
stdenv,
fetchFromGitHub,
nix-update-script,
validatePkgConfig,
testers,
cmake,
ninja,
plutovg,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "plutosvg";
version = "0.0.7";

src = fetchFromGitHub {
owner = "sammycage";
repo = "plutosvg";
tag = "v${finalAttrs.version}";
hash = "sha256-4JLk4+O9Tf8CGxMP0aDN70ak/8teZH3GWBWlrIkPQm4=";
};

outputs = [
"out"
"dev"
];

patches = [
# https://github.com/sammycage/plutosvg/pull/29
./0001-Emit-correct-pkg-config-file-if-paths-are-absolute.patch
Copy link
Member

@PedroHLC PedroHLC Jun 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I apologize for not seeing this before, trying to use it I get:

>   Imported target "plutosvg::plutosvg" includes non-existent path
>
>     "/nix/store/jk7v5dwymmbj81i2qbmc2c1c2k5csfpn-plutosvg-0.0.7/include/plutosvg"
>
>   in its INTERFACE_INCLUDE_DIRECTORIES.

in that output, there is only one file:

╰─λ find /nix/store/jk7v5dwymmbj81i2qbmc2c1c2k5csfpn-plutosvg-0.0.7 -type f
/nix/store/jk7v5dwymmbj81i2qbmc2c1c2k5csfpn-plutosvg-0.0.7/lib/libplutosvg.so.0
``

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have also noticed this issue, it is already fixed upstream with sammycage/plutosvg#31. I was planning to add it as a patch with the PR updating pcsx2 but I can create a separate PR earlier if you need it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need @marcin-serwin, I've added a postInstall fix. Good work!

];

nativeBuildInputs = [
cmake
ninja
validatePkgConfig
];
propagatedBuildInputs = [
plutovg
];

cmakeFlags = [ (lib.cmakeBool "BUILD_SHARED_LIBS" (!stdenv.hostPlatform.isStatic)) ];

passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have to add two pkg-config validator?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

validatePkgConfig checks whether .pc file is syntactically correct, while testMetaPkgConfig checks that it exports the modules listed in meta.pkgConfigModules.


passthru.updateScript = nix-update-script { };

meta = {
homepage = "https://github.com/sammycage/plutosvg";
changelog = "https://github.com/sammycage/plutosvg/releases/tag/${finalAttrs.src.tag}";
description = "Tiny SVG rendering library in C";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ marcin-serwin ];
pkgConfigModules = [ "plutosvg" ];
};
})