libimobiledevice / libplist

A library to handle Apple Property List format in binary or XML
https://libimobiledevice.org
GNU Lesser General Public License v2.1
528 stars 304 forks source link

How to build with `plist_from_memory` breaking change? #227

Closed reitermarkus closed 1 year ago

reitermarkus commented 1 year ago

Version 2.3.0, a minor release, introduced a breaking change for plist_from_memory.

I am trying to build shairport-sync, which uses plist_from_memory with 3 arguments (https://github.com/mikebrady/shairport-sync/issues/1674).

What is the migration path to support building with both 2.2.0 and 2.3.0?

nikias commented 1 year ago

Just add a 4th argument and pass NULL (unless you want to get the detected plist type).

reitermarkus commented 1 year ago

Just add a 4th argument and pass NULL

That's a compiler error for versions 2.0.0 to 2.2.0 though, unless I am missing something.

nikias commented 1 year ago

Obviously you need to increase version requirment for shairport-sync to 2.3.0 or add a version dependent compile time check.

reitermarkus commented 1 year ago

add a version dependent compile time check

Okay, then I guess what I am asking is: What is the recommended compile-time check to use in configure.ac?

In https://github.com/mikebrady/shairport-sync/pull/1675, I did come up with the following, but maybe there is a simpler way:

LIBPLIST_PACKAGE=libplist
PKG_CHECK_EXISTS(libplist-2.0, LIBPLIST_PACKAGE=libplist-2.0)
PKG_CHECK_MODULES(
  [libplist], [${LIBPLIST_PACKAGE} >= 2.3.0],
  [CFLAGS="${libplist_CFLAGS} ${CFLAGS}" LIBS="${libplist_LIBS} ${LIBS}" AC_DEFINE([HAVE_LIBPLIST_GE_2_3_0], 1, [libplist >= 2.3.0])],
  [PKG_CHECK_MODULES(
    [libplist], [${LIBPLIST_PACKAGE} >= 2.0.0],
    [CFLAGS="${libplist_CFLAGS} ${CFLAGS}" LIBS="${libplist_LIBS} ${LIBS}"],
    [AC_MSG_ERROR(AirPlay 2 support requires libplist 2.0.0 or later -- search for pkg libplist-dev on Debian or libplist-2.2.0 or later on FreeBSD!)]
  )]
)
nikias commented 1 year ago

That would be the proper way I assume. If you want a hacky way you can dlsym the address of plist_from_memory and just define it with 4 parameters, as long as you don't call it with a non-Null 4th argument it should be fine I guess...

nikias commented 1 year ago

@reitermarkus does this need further clarification?

reitermarkus commented 1 year ago

No, it's fixed now for my use case, thanks.