Changes to support amalgamation

16 posts / 0 new
Last post
TheVinn
Offline
Last seen: 3 days 20 hours ago
Joined: 29 Aug 2009 - 11:31
Changes to support amalgamation

In order to respect a "one include line per file" rule (needed for a proper amalgamation), these changes are needed:

juce_core.cpp BEFORE

#if JUCE_MAC || JUCE_IOS
 #include "native/juce_osx_ObjCHelpers.h"
 #include "native/juce_mac_ObjCSuffix.h"
 #include "native/juce_posix_NamedPipe.cpp"
 #include "native/juce_posix_SharedCode.h"
 #include "native/juce_mac_Files.mm"
 #include "native/juce_mac_Network.mm"
 #include "native/juce_mac_Strings.mm"
 #include "native/juce_mac_SystemStats.mm"
 #include "native/juce_mac_Threads.mm"

//==============================================================================
#elif JUCE_WINDOWS
 #include "native/juce_win32_ComSmartPtr.h"
 #include "native/juce_win32_Files.cpp"
 #include "native/juce_win32_Network.cpp"
 #include "native/juce_win32_Registry.cpp"
 #include "native/juce_win32_SystemStats.cpp"
 #include "native/juce_win32_Threads.cpp"

//==============================================================================
#elif JUCE_LINUX
 #include "native/juce_posix_SharedCode.h"
 #include "native/juce_posix_NamedPipe.cpp"
 #include "native/juce_linux_Files.cpp"
 #include "native/juce_linux_Network.cpp"
 #include "native/juce_linux_SystemStats.cpp"
 #include "native/juce_linux_Threads.cpp"

//==============================================================================
#elif JUCE_ANDROID
 #include "native/juce_android_JNIHelpers.h"
 #include "native/juce_posix_SharedCode.h"
 #include "native/juce_posix_NamedPipe.cpp"
 #include "native/juce_android_Files.cpp"
 #include "native/juce_android_Misc.cpp"
 #include "native/juce_android_Network.cpp"
 #include "native/juce_android_SystemStats.cpp"
 #include "native/juce_android_Threads.cpp"

#endif

juce_core.cpp AFTER

//==============================================================================
#if JUCE_MAC || JUCE_IOS
 #include "native/juce_osx_ObjCHelpers.h"
 #include "native/juce_mac_ObjCSuffix.h"

#elif JUCE_ANDROID
 #include "native/juce_android_JNIHelpers.h"

#endif

#if (JUCE_MAC || JUCE_IOS) || JUCE_LINUX || JUCE_ANDROID
 #include "native/juce_posix_SharedCode.h"
 #include "native/juce_posix_NamedPipe.cpp"

#endif

//==============================================================================
#if JUCE_MAC || JUCE_IOS
 #include "native/juce_mac_Files.mm"
 #include "native/juce_mac_Network.mm"
 #include "native/juce_mac_Strings.mm"
 #include "native/juce_mac_SystemStats.mm"
 #include "native/juce_mac_Threads.mm"

//==============================================================================
#elif JUCE_WINDOWS
 #include "native/juce_win32_ComSmartPtr.h"
 #include "native/juce_win32_Files.cpp"
 #include "native/juce_win32_Network.cpp"
 #include "native/juce_win32_Registry.cpp"
 #include "native/juce_win32_SystemStats.cpp"
 #include "native/juce_win32_Threads.cpp"

//==============================================================================
#elif JUCE_LINUX
 #include "native/juce_linux_Files.cpp"
 #include "native/juce_linux_Network.cpp"
 #include "native/juce_linux_SystemStats.cpp"
 #include "native/juce_linux_Threads.cpp"

//==============================================================================
#elif JUCE_ANDROID
 #include "native/juce_android_Files.cpp"
 #include "native/juce_android_Misc.cpp"
 #include "native/juce_android_Network.cpp"
 #include "native/juce_android_SystemStats.cpp"
 #include "native/juce_android_Threads.cpp"

#endif

Jules do you see any better way of doing this?

TheVinn
Offline
Last seen: 3 days 20 hours ago
Joined: 29 Aug 2009 - 11:31
Re: Changes to support amalgamation

Module .cpp files #ifdef at the very beginning should look like this:

juce_core.cpp (example)

#if defined (__JUCE_CORE_JUCEHEADER__) && !defined (JUCE_AMALGAMATED_INCLUDE)
...

This goes for all the module .cpp files (juce_audio_basics.cpp, juce_audio_devices.cpp, etc...)

jules
Offline
Last seen: 22 min 37 sec ago
Joined: 29 Apr 2013 - 18:37
Re: Changes to support amalgamation

Thanks Vinnie. Your first request is no problem, but am unclear about why you want all the module headers to have that JUCE_AMALGAMATED_INCLUDE test? Surely you'll be setting that value to 1, so that would mean that none of these files would be processed at all..?

TheVinn
Offline
Last seen: 3 days 20 hours ago
Joined: 29 Aug 2009 - 11:31
Re: Changes to support amalgamation

jules wrote:
Thanks Vinnie. Your first request is no problem, but am unclear about why you want all the module headers to have that JUCE_AMALGAMATED_INCLUDE test? Surely you'll be setting that value to 1, so that would mean that none of these files would be processed at all..?

No actually its right, because those #ifdefs are meant for sanity checking not multiple-inclusion supression:

#if defined(__JUCE_CORE_JUCEHEADER__) && !defined (JUCE_AMALGAMATED_INCLUDE)
 /* When you add this cpp file to your project, you mustn't include it in a file where you've
    already included any other headers - just put it inside a file on its own, possibly with your config
    flags preceding it, but don't include anything else. That also includes avoiding any automatic prefix
    header files that the compiler may be using.
 */
 #error "Incorrect use of JUCE cpp file"
#endif
jules
Offline
Last seen: 22 min 37 sec ago
Joined: 29 Apr 2013 - 18:37
Re: Changes to support amalgamation

But I'm not going to add this:

#if defined(__JUCE_CORE_JUCEHEADER__) && !defined (JUCE_AMALGAMATED_INCLUDE)
/* When you add this cpp file to your project, you mustn't include it in a file where you've
    already included any other headers - just put it inside a file on its own, possibly with your config
    flags preceding it, but don't include anything else. That also includes avoiding any automatic prefix
    header files that the compiler may be using.
*/
#error "Incorrect use of JUCE cpp file"
#endif

..because that would break all the normal builds.

And if I just add this:

#if defined (__JUCE_CORE_JUCEHEADER__) && !defined (JUCE_AMALGAMATED_INCLUDE)

..then that won't help you at all, will it?

I must be missing your point!

TheVinn
Offline
Last seen: 3 days 20 hours ago
Joined: 29 Aug 2009 - 11:31
Re: Changes to support amalgamation

jules wrote:
I must be missing your point!

LOL!!! Yes indeed. These images should clear things up:

BEFORE
[attachment=1]JuceBefore.png[/attachment]

AFTER
[attachment=0]JuceAfter.png[/attachment]

jules
Offline
Last seen: 22 min 37 sec ago
Joined: 29 Apr 2013 - 18:37
Re: Changes to support amalgamation

Sorry, I think I must have been looking at the header file or something, I completely misunderstood..!

Ta, will add those changes!

TheVinn
Offline
Last seen: 3 days 20 hours ago
Joined: 29 Aug 2009 - 11:31
Re: Changes to support amalgamation

jules wrote:
Ta, will add those changes!

Almost there, but not quite. The tip has

#if defined (__JUCE_DATA_STRUCTURES_JUCEHEADER__) && ! JUCE_AMALGAMATED_INCLUDE

Where it should read:

#if defined (__JUCE_DATA_STRUCTURES_JUCEHEADER__) && ! defined(JUCE_AMALGAMATED_INCLUDE)

Not sure how this compiled for you. Unlike the AppConfig.h switches, which are always defined [0,1], "JUCE_AMALGAMATED_INCLUDE" is either defined or undefined depending on whether the amalgamation is being built.

jules
Offline
Last seen: 22 min 37 sec ago
Joined: 29 Apr 2013 - 18:37
Re: Changes to support amalgamation

It compiles just fine in all my compilers.

I always prefer to use macros as explicit boolean values, rather than just considering "being defined" to mean "true".

TheVinn
Offline
Last seen: 3 days 20 hours ago
Joined: 29 Aug 2009 - 11:31
Re: Changes to support amalgamation

jules wrote:
It compiles just fine in all my compilers.

I always prefer to use macros as explicit boolean values, rather than just considering "being defined" to mean "true".

That's not how you did it before. But if it compiles, where do you #define it to 0? I couldn't find the line

jules
Offline
Last seen: 22 min 37 sec ago
Joined: 29 Apr 2013 - 18:37
Re: Changes to support amalgamation

I don't #define it to 0 anywhere. There's no need to. Is it really failing to compile for you, or are you just assuming that it'll fail?

Pages