tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: librsvg as tool dependency and LIBRSVG_USE_RUST



Greg Troxel writes:
> Leonardo Taccari <leot%NetBSD.org@localhost> writes:
>
> > after the move of graphics/librsvg to graphics/librsvg-c and
> > introduction of LIBRSVG_USE_RUST it is no longer possible to honor
> > user's LIBRSVG_USE_RUST=no preference when librsvg is picked up via
> > BUILD_DEPENDS or TOOL_DEPENDS (e.g. graphics/adwaita-icon-theme).
>
> Stepping way back, I think that LIBRSVG_USE_RUST is not really the right
> variable name and mental model here.   Really, we have two
> implementations of librsvg.  Yes, that's because one of them uses rust,
> but from the point of view of the pkgsrc machinery, that's not
> important.  What is important is that on any given system, there is a
> choice of which to use.  This is much like FOO_TYPE for various kinds of
> FOO, with the likelihood of FOO_PREFERRED and FOO_ACCEPTED.
>

Should it be renamed to LIBRSVG_TYPE having as possible values `c' and
`rust'?  I would find it (LIBRSVG_TYPE) more consistent with other
pkgsrc variables too and prefer that.

> > I would like to propose the following patch that address these problems
> > by introducing:
> >
> >  - graphics/librsvg/available.mk: that just define LIBRSVG_USE_RUST (so
> >    devel/pango, fonts/harfbuzz, misc/libreoffice or any other package
> >    can just include it to check what is the preferred librsvg
> >    implementation to be used)
> >  - graphics/librsvg/tool.mk: that adds librsvg as a tool dependency by
> >    honoring LIBRSVG_USE_RUST user's preference.  In that way packages
> >    that needs librsvg instead of directly TOOL_DEPENDS will need to
> >    include graphics/librsvg/tool.mk.
>
> Is this really TOOL_DEPENDS, so that it's used only at build time?
>

Yes.

> I'd like to see this as either mk/librsvg.mk, or
> graphics/librsvg/librsvg.mk, that one includes to get a dependency, with
> perhaps a variable to declare which kind.  Basically lining up with
> /usr/pkgsrc/mk/foo.*mk for many values of foo.
>

I would prefer to keep it as tool.mk.  In the pkgsrc tree there are
other tool.mk used similarly and I think that all BUILD_DEPENDS (except
meta-pkgs/bulk-medium that is "special") depends on librsvg as a tool
dependency (TOOL_DEPENDS) for rsvg-convert.

> So basically, I agree in concept, but would like to remove the "this is
> about rust" from the interface and just have it be "which librsvg
> implementation should we use on this system" (even if it is driven by rust).

An updated version of the patch that rename LIBRSVG_USE_RUST to
LIBRSVG_TYPE is attached.
librsvg: Add available.mk and tool.mk mk fragments

Rename LIBRSVG_USE_RUST to LIBRSVG_TYPE.

Isolate the LIBRSVG_TYPE logic in available.mk mk fragments in
order that can be used by other librsvg mk (e.g. tool.mk) or by
other package to check the preferred librsvg implementation to be
used. (e.g. devel/pango, fonts/harfbuzz and misc/libreoffice).

Add a tool.mk mk fragment in order to be able to specify librsvg
as a tool dependency honoring user's LIBRSVG_TYPE.
Thanks to <wiz> for suggesting that!

Index: mk/defaults/mk.conf
===================================================================
RCS file: /cvsroot/pkgsrc/mk/defaults/mk.conf,v
retrieving revision 1.302
diff -u -p -r1.302 mk.conf
--- mk/defaults/mk.conf	29 May 2019 12:38:39 -0000	1.302
+++ mk/defaults/mk.conf	5 Jun 2019 15:40:45 -0000
@@ -1293,11 +1293,12 @@ LEAFNODE_GROUP?=	news
 # Default: news
 # Note: default is the same as INN_GROUP
 
-#LIBRSVG_USE_RUST?=	yes
+#LIBRSVG_TYPE?=	rust
 # Used by dependencies of graphics/librsvg to decide if the outdated
 # librsvg-2.40.xx should be used, which is plain C, or if the latest
 # version should be used, which is partially written in rust.
-# Default: yes on operating systems supported by lang/rust
+# Possible: c rust
+# Default: rust on operating systems supported by lang/rust
 
 LINUX_LOCALES?=								\
 	af ar bg br ca cs cy da de el en eo es et eu fi fo fr ga gl	\
Index: graphics/librsvg/available.mk
===================================================================
RCS file: graphics/librsvg/available.mk
diff -N graphics/librsvg/available.mk
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ graphics/librsvg/available.mk	5 Jun 2019 15:40:45 -0000
@@ -0,0 +1,27 @@
+# $NetBSD$
+#
+# This mk fragment define LIBRSVG_TYPE variable used in other librsvg mk
+# fragments.
+#
+# User-settable variables:
+#
+# LIBRSVG_TYPE
+#	Type of used librsvg implementation.
+#
+#	Possible values: c rust
+#	Default: rust on platforms were Rust is supported
+#
+
+.if !defined(LIBRSVG_AVAILABLE_MK)
+LIBRSVG_AVAILABLE_MK=	defined
+
+.include "../../mk/bsd.prefs.mk"
+
+.include "../../lang/rust/platform.mk"
+.if !empty(PLATFORM_SUPPORTS_RUST:M[Yy][Ee][Ss])
+LIBRSVG_TYPE?=	rust
+.else
+LIBRSVG_TYPE?=	c
+.endif
+
+.endif # LIBRSVG_AVAILABLE_MK
Index: graphics/librsvg/buildlink3.mk
===================================================================
RCS file: /cvsroot/pkgsrc/graphics/librsvg/buildlink3.mk,v
retrieving revision 1.48
diff -u -p -r1.48 buildlink3.mk
--- graphics/librsvg/buildlink3.mk	1 Jun 2019 13:55:31 -0000	1.48
+++ graphics/librsvg/buildlink3.mk	5 Jun 2019 15:40:45 -0000
@@ -10,16 +10,16 @@ BUILDLINK_ABI_DEPENDS.librsvg+=		librsvg
 
 .include "../../mk/bsd.fast.prefs.mk"
 
-# default to rust version on platforms where pkgsrc supports lang/rust
-.include "../../lang/rust/platform.mk"
-LIBRSVG_USE_RUST?=	${PLATFORM_SUPPORTS_RUST}
+.include "../../graphics/librsvg/available.mk"
 
-.if ${LIBRSVG_USE_RUST} == "yes"
+.if ${LIBRSVG_TYPE} == "rust"
 BUILDLINK_PKGSRCDIR.librsvg?=		../../graphics/librsvg
 BUILDLINK_API_DEPENDS.librsvg+=		librsvg>=2.41
-.else
+.elif ${LIBRSVG_TYPE} == "c"
 BUILDLINK_PKGSRCDIR.librsvg?=		../../graphics/librsvg-c
 BUILDLINK_API_DEPENDS.librsvg+=		librsvg<2.41
+.else
+PKG_FAIL_REASON+=       "[graphics/librsvg/buildlink3.mk] Invalid value ${LIBRSVG_TYPE} for LIBRSVG_TYPE."
 .endif
 
 .include "../../devel/pango/buildlink3.mk"
Index: graphics/librsvg/tool.mk
===================================================================
RCS file: graphics/librsvg/tool.mk
diff -N graphics/librsvg/tool.mk
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ graphics/librsvg/tool.mk	5 Jun 2019 15:40:45 -0000
@@ -0,0 +1,18 @@
+# $NetBSD$
+#
+# This mk fragment can be included by all packages that need librsvg as a tool
+# dependency (e.g. for rsvg-convert).
+#
+
+.if !defined(LIBRSVG_TOOL_MK)
+LIBRSVG_TOOL_MK=	defined
+
+.include "../../graphics/librsvg/available.mk"
+
+.if ${LIBRSVG_TYPE} == "rust"
+TOOL_DEPENDS+=	librsvg-[0-9]*:../../graphics/librsvg
+.else
+TOOL_DEPENDS+=	librsvg-[0-9]*:../../graphics/librsvg-c
+.endif
+
+.endif # LIBRSVG_TOOL_MK


Home | Main Index | Thread Index | Old Index