Request for config flags to exclude 3rd party code


#1

I strip the Zlib, FLAC, Ogg and Vorbis code from the JUCE codebase and link against external .dll/.so versions of them. Currently I’m doing this as part of my buildsystem and it works with no problems on Windows and Linux.

I would like to have some config options in juce_Config.h to configure if JUCE uses the internal version of these 3rd party libs or links against external versions.

By default JUCE_INTERNAL_ZLIB, JUCE_INTERNAL_OGGVORBIS and JUCE_INTERNAL_FLAC are defined to 1, so there is be no change to the current behavior.

[code]namespace zlibNamespace
{
#if JUCE_INTERNAL_ZLIB

extern “C”
{
#undef OS_CODE
#undef fdopen
#define ZLIB_INTERNAL
#define NO_DUMMY_DECL
#include “zlib/zlib.h”

#include "zlib/adler32.c"
#include "zlib/compress.c"
[...]
#include "zlib/zutil.c"
#undef Byte

}

#else

#include <zlib.h>

#endif
}[/code][code]namespace OggVorbisNamespace
{
#if JUCE_INTERNAL_OGGVORBIS

#include “oggvorbis/vorbisenc.h”
#include “oggvorbis/codec.h”
#include “oggvorbis/vorbisfile.h”

#include “oggvorbis/bitwise.c”
#include “oggvorbis/framing.c”
[…]
#include “oggvorbis/libvorbis-1.1.2/lib/vorbisfile.c”
#include “oggvorbis/libvorbis-1.1.2/lib/window.c”

#else

#include <vorbis/vorbisenc.h>
#include <vorbis/codec.h>
#include <vorbis/vorbisfile.h>

#endif
}[/code][code]
namespace FlacNamespace
{
#if JUCE_INTERNAL_FLAC

#define FLAC__NO_DLL 1

#if ! defined (SIZE_MAX)
#define SIZE_MAX 0xffffffff
#endif

#define __STDC_LIMIT_MACROS 1
#include “flac/all.h”
#include “flac/libFLAC/bitmath.c”
[…]
#include “flac/libFLAC/stream_encoder_framing.c”
#include “flac/libFLAC/window_flac.c”

#else

#include <FLAC/all.h>

#endif
}[/code]


#2

Sounds very reasonable, and I’m sure it’ll solve some other people’s problems too. I’ll get that checked-in shortly…


#3

I missed to propose changes for all important places (two ZLib includes). Also I missed to propose such flags for PNG and JPEG 3rd party code, I strip both from the codebase as well but forget to mention it in my first post.

In juce_GZIPCompressorOutputStream.cpp:

namespace zlibNamespace { #if JUCE_INCLUDE_ZLIB_CODE #undef OS_CODE #undef fdopen #include "zlib/zlib.h" #undef OS_CODE #else #include <zlib.h> #endif }

In juce_PNGLoader.cpp:

[code]namespace zlibNamespace
{
#if JUCE_INCLUDE_ZLIB_CODE
#undef OS_CODE
#undef fdopen
#include “…/…/…/…/…/juce_core/io/streams/zlib/zlib.h”
#undef OS_CODE
#else
#include <zlib.h>
#endif
}

namespace pnglibNamespace
{
using namespace zlibNamespace;

#if JUCE_INCLUDE_PNGLIB_CODE
using ::malloc;
using ::free;

extern “C”
{
using ::abs;
#define PNG_INTERNAL
#define NO_DUMMY_DECL
#define PNG_SETJMP_NOT_SUPPORTED

#include "pnglib/png.h"
#include "pnglib/pngconf.h"

#define PNG_NO_EXTERN
#include "pnglib/png.c"
[...]
#include "pnglib/pngwutil.c"

}
#else
#define PNG_INTERNAL
#define PNG_SETJMP_NOT_SUPPORTED

#include <png.h>
#include <pngconf.h>
#endif
}[/code]

In juce_JPEGLoader.cpp:

[code]namespace jpeglibNamespace
{
#if JUCE_INCLUDE_JPEGLIB_CODE
extern “C”
{
#define JPEG_INTERNALS
#undef FAR
#include “jpglib/jpeglib.h”

#include "jpglib/jcapimin.c"
[...]
#include "jpglib/transupp.c"

}
#else
#define JPEG_INTERNALS
#undef FAR

#include <jpeglib.h>
#endif
}[/code]


#4

Great. That should all be checked-in there now…