[PATCH weston] configure: Make libjpeg an optional dependency
Pekka Paalanen
ppaalanen at gmail.com
Mon Feb 8 09:34:58 UTC 2016
On Sat, 6 Feb 2016 12:09:59 +0100
Quentin Glidic <sardemff7+wayland at sardemff7.net> wrote:
> On 06/02/2016 06:07, Emmanuel Gil Peyrot wrote:
> > libjpeg is only used in shared/image-loader.c in weston, like libwebp
> > it doesn’t make sense to fail the entire build if it isn’t present, for
> > any reason.
> >
> > I kept libpng a hard dependency in the image-loader because so many
> > other parts of weston depend on PNG, it is already mandatory from
> > everywhere else.
> >
> > Signed-off-by: Emmanuel Gil Peyrot <linkmauve at linkmauve.fr>
> > ---
> > configure.ac | 8 ++++----
> > shared/image-loader.c | 23 ++++++++++++++++-------
> > 2 files changed, 20 insertions(+), 11 deletions(-)
> >
> > diff --git a/configure.ac b/configure.ac
> > index bff6380..c42e32b 100644
> > --- a/configure.ac
> > +++ b/configure.ac
> > @@ -311,13 +311,12 @@ fi
> > AM_CONDITIONAL(ENABLE_VAAPI_RECORDER, test "x$have_libva" = xyes)
> >
> >
> > -AC_CHECK_LIB([jpeg], [jpeg_CreateDecompress], have_jpeglib=yes)
> > +AC_CHECK_LIB([jpeg], [jpeg_CreateDecompress], [have_jpeglib=yes], [have_jpeglib=no])
>
> Please add a proper AC_ARG_ENABLE. I let you decide whether you want
> yes, no or auto as default.
Hi,
yes, agreed. Since not having jpeg was a fatal build error before, I'd
propose to default to "yes". Saves the trouble of "auto".
All Weston image resources are already PNG, so it makes sense to keep
PNG as a mandatory dependency. There is nothing about JPEG except some
examples in weston.ini.in, but I don't care about those.
> > if test x$have_jpeglib = xyes; then
> > JPEG_LIBS="-ljpeg"
> > -else
> > - AC_ERROR([libjpeg not found])
> > + AC_SUBST(JPEG_LIBS)
> > + AC_DEFINE([HAVE_JPEG], [1], [Have jpeg])
> > fi
> > -AC_SUBST(JPEG_LIBS)
> >
> > PKG_CHECK_MODULES(CAIRO, [cairo])
> >
> > @@ -676,6 +675,7 @@ AC_MSG_RESULT([
> >
> > Colord Support ${have_colord}
> > LCMS2 Support ${have_lcms}
> > + libjpeg Support ${have_jpeglib}
> > libwebp Support ${have_webp}
> > libunwind Support ${have_libunwind}
> > VA H.264 encoding Support ${have_libva}
> > diff --git a/shared/image-loader.c b/shared/image-loader.c
> > index ec75bd4..e6c0c7d 100644
> > --- a/shared/image-loader.c
> > +++ b/shared/image-loader.c
> > @@ -30,13 +30,16 @@
> > #include <stdlib.h>
> > #include <stdio.h>
> > #include <string.h>
> > -#include <jpeglib.h>
> > #include <png.h>
> > #include <pixman.h>
> >
> > #include "shared/helpers.h"
> > #include "image-loader.h"
> >
> > +#ifdef HAVE_JPEG
> > +#include <jpeglib.h>
> > +#endif
> > +
> > #ifdef HAVE_WEBP
> > #include <webp/decode.h>
> > #endif
> > @@ -48,6 +51,14 @@ stride_for_width(int width)
> > }
> >
> > static void
> > +pixman_image_destroy_func(pixman_image_t *image, void *data)
> > +{
> > + free(data);
> > +}
> > +
> > +#ifdef HAVE_JPEG
> > +
> > +static void
> > swizzle_row(JSAMPLE *row, JDIMENSION width)
> > {
> > JSAMPLE *s;
> > @@ -68,12 +79,6 @@ error_exit(j_common_ptr cinfo)
> > longjmp(cinfo->client_data, 1);
> > }
> >
> > -static void
> > -pixman_image_destroy_func(pixman_image_t *image, void *data)
> > -{
> > - free(data);
> > -}
> > -
> > static pixman_image_t *
> > load_jpeg(FILE *fp)
> > {
> > @@ -132,6 +137,8 @@ load_jpeg(FILE *fp)
> > return pixman_image;
> > }
> >
> > +#endif
> > +
> > static inline int
> > multiply_alpha(int alpha, int color)
> > {
> > @@ -363,7 +370,9 @@ struct image_loader {
> >
> > static const struct image_loader loaders[] = {
> > { { 0x89, 'P', 'N', 'G' }, 4, load_png },
> > +#ifdef HAVE_JPEG
> > { { 0xff, 0xd8 }, 2, load_jpeg },
> > +#endif
> > #ifdef HAVE_WEBP
> > { { 'R', 'I', 'F', 'F' }, 4, load_webp }
> > #endif
> >
>
> Code is ok.
>
If you wanted to be fancy, you could leave the load_jpeg table entry in
place. If not HAVE_JPEG, the implementation could print a nice error
message about jpeg being disabled in the build. Would be one less #ifdef.
Thanks,
pq
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 811 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20160208/b94fe8f1/attachment-0001.sig>
More information about the wayland-devel
mailing list