The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

204 lines
10KB

  1. The JUCE Module Format
  2. ======================
  3. A JUCE module is a collection of header and source files which can be added to a project
  4. to provide a set of classes and libraries or related functionality.
  5. Their structure is designed to make it as simple as possible for modules to be added to
  6. user projects on many platforms, either via automated tools, or by manual inclusion.
  7. Each module may have dependencies on other modules, but should be otherwise self-contained.
  8. File structure
  9. ==============
  10. Each module lives inside a folder whose name is the same as the name of the module. The
  11. JUCE convention for naming modules is lower-case with underscores, e.g.
  12. juce_core
  13. juce_events
  14. juce_graphics
  15. But any name that is a valid C++ identifer is OK.
  16. Inside the root of this folder, there must be a set of public header and source files which
  17. the user's' project will include. The module may have as many other internal source files as
  18. it needs, but these must all be inside sub-folders!
  19. Master header file
  20. ------------------
  21. In this root folder there must be ONE master header file, which includes all the necessary
  22. header files for the module. This header must have the same name as the module, with
  23. a .h/.hpp/.hxx suffix. E.g.
  24. juce_core/juce_core.h
  25. IMPORTANT! All code within a module that includes other files from within its own subfolders
  26. must do so using RELATIVE paths!
  27. A module must be entirely relocatable on disk, and it must not rely on the user's project
  28. having any kind of include path set up correctly for it to work. Even if the user has no
  29. include paths whatsoever and includes the module's master header via an absolute path,
  30. it must still correctly find all of its internally included sub-files.
  31. This master header file must also contain a comment with a BEGIN_JUCE_MODULE_DECLARATION
  32. block which defines the module's requirements - the syntax for this is described later on..
  33. Module CPP files
  34. ----------------
  35. A module consists of a single header file and zero or more .cpp files. Fewer is better!
  36. Ideally, a module could be header-only module, so that a project can use it by simply
  37. including the master header file.
  38. For various reasons it's usually necessary or preferable to have a simpler header and
  39. some .cpp files that the user's project should compile as stand-alone compile units.
  40. In this case you should ideally provide just a single cpp file in the module's root
  41. folder, and this should internally include all your other cpps from their sub-folders,
  42. so that only a single cpp needs to be added to the user's project in order to completely
  43. compile the module.
  44. In some cases (e.g. if your module internally relies on 3rd-party code which can't be
  45. easily combined into a single compile-unit) then you may have more than one source file
  46. here, but avoid this if possible, as it will add a burden for users who are manually
  47. adding these files to their projects.
  48. The names of these source files must begin with the name of the module, but they can have
  49. a number or other suffix if there is more than one.
  50. In order to specify that a source file should only be compiled on a specific platform,
  51. then the filename can be suffixed with one of the following strings:
  52. _OSX
  53. _Windows
  54. _Linux
  55. _Android
  56. _iOS
  57. e.g.
  58. juce_mymodule/juce_mymodule_1.cpp <- compiled on all platforms
  59. juce_mymodule/juce_mymodule_2.cpp <- compiled on all platforms
  60. juce_mymodule/juce_mymodule_OSX.cpp <- compiled only on OSX
  61. juce_mymodule/juce_mymodule_Windows.cpp <- compiled only on Windows
  62. Often this isn't necessary, as in most cases you can easily add checks inside the files
  63. to do different things depending on the platform, but this may be handy just to avoid
  64. clutter in user projects where files aren't needed.
  65. To simplify the use of obj-C++ there's also a special-case rule: If the folder contains
  66. both a .mm and a .cpp file whose names are otherwise identical, then on OSX/iOS the .mm
  67. will be used and the cpp ignored. (And vice-versa for other platforms, of course).
  68. Precompiled libraries
  69. ---------------------
  70. Precompiled libraries can be included in a module by placing them in a libs/ subdirectory.
  71. The following directories are automatically added to the library search paths, and libraries
  72. placed in these directories can be linked with projects via the OSXLibs, iOSLibs,
  73. windowsLibs, linuxLibs and mingwLibs keywords in the module declaration (see the following
  74. section).
  75. OS X:
  76. libs/MacOSX/{arch}, where {arch} is the architecture you are targeting in Xcode ("x86_64" or
  77. "i386", for example).
  78. Visual Studio:
  79. libs/VisualStudio{year}/{arch}/{run-time}, where {year} is the four digit year of the Visual Studio
  80. release, arch is the target architecture in Visual Studio ("x64" or "Win32", for example), and
  81. {runtime} is the type of the run-time library indicated by the corresponding compiler flag
  82. ("MD", "MDd", "MT", "MTd").
  83. Linux:
  84. libs/Linux/{arch}, where {arch} is the architecture you are targeting with the compiler. Some
  85. common examples of {arch} are "x86_64", "i386" and "armv6".
  86. MinGW:
  87. libs/MinGW/{arch}, where {arch} can take the same values as Linux.
  88. iOS:
  89. libs/iOS/{arch}, where {arch} is the architecture you are targeting in Xcode ("arm64" or
  90. "x86_64", for example).
  91. Android:
  92. libs/Android/{arch}, where {arch} is the architecture provided by the Android Studio variable
  93. "${ANDROID_ABI}" ("x86", "armeabi-v7a", "mips", for example).
  94. The BEGIN_JUCE_MODULE_DECLARATION block
  95. =======================================
  96. This block of text needs to go inside the module's main header file. It should be commented-out
  97. and perhaps inside an #if 0 block too, but the Introjucer will just scan the whole file for the
  98. string BEGIN_JUCE_MODULE_DECLARATION, and doesn't care about its context in terms of C++ syntax.
  99. The block needs a corresponding END_JUCE_MODULE_DECLARATION to finish the block.
  100. These should both be on a line of their own.
  101. Inside the block, the parser will expect to find a list of value definitions, one-per-line, with
  102. the very simple syntax
  103. value_name: value
  104. The value_name must be one of the items listed below, and is case-sensitive. Whitespace on the
  105. line is ignored. Some values are compulsory and must be supplied, but others are optional.
  106. The order in which they're declared doesn't matter.
  107. Possible values:
  108. ID: (Compulsory) This ID must match the name of the file and folder, e.g. juce_core.
  109. The main reason for also including it here is as a sanity-check
  110. vendor: (Compulsory) A unique ID for the vendor, e.g. "juce". This should be short
  111. and shouldn't contain any spaces
  112. version: (Compulsory) A version number for the module
  113. name: (Compulsory) A short description of the module
  114. description: (Compulsory) A longer description (but still only one line of text, please!)
  115. dependencies: (Optional) A list (space or comma-separated) of other modules that are required by
  116. this one. The Introjucer can use this to auto-resolve dependencies.
  117. website: (Optional) A URL linking to useful info about the module]
  118. license: (Optional) A description of the type of software license that applies
  119. minimumCppStandard: (Optional) A number indicating the minimum C++ language standard that is required for this module.
  120. This must be just the standard number with no prefix e.g. 14 for C++14
  121. searchpaths: (Optional) A space-separated list of internal include paths, relative to the module's
  122. parent folder, which need to be added to a project's header search path
  123. OSXFrameworks: (Optional) A list (space or comma-separated) of OSX frameworks that are needed
  124. by this module
  125. iOSFrameworks: (Optional) Like OSXFrameworks, but for iOS targets
  126. linuxPackages: (Optional) A list (space or comma-separated) pkg-config packages that should be used to pass
  127. compiler (CFLAGS) and linker (LDFLAGS) flags
  128. linuxLibs: (Optional) A list (space or comma-separated) of static or dynamic libs that should be linked in a
  129. linux build (these are passed to the linker via the -l flag)
  130. mingwLibs: (Optional) A list (space or comma-separated) of static libs that should be linked in a
  131. win32 mingw build (these are passed to the linker via the -l flag)
  132. OSXLibs: (Optional) A list (space or comma-separated) of static or dynamic libs that should be linked in an
  133. OS X build (these are passed to the linker via the -l flag)
  134. iOSLibs: (Optional) A list (space or comma-separated) of static or dynamic libs that should be linked in an
  135. iOS build (these are passed to the linker via the -l flag)
  136. windowsLibs: (Optional) A list (space or comma-separated) of static or dynamic libs that should be linked in a
  137. Visual Studio build (without the .lib suffixes)
  138. Here's an example block:
  139. BEGIN_JUCE_MODULE_DECLARATION
  140. ID: juce_audio_devices
  141. vendor: juce
  142. version: 4.1.0
  143. name: JUCE audio and MIDI I/O device classes
  144. description: Classes to play and record from audio and MIDI I/O devices
  145. website: http://www.juce.com/juce
  146. license: GPL/Commercial
  147. dependencies: juce_audio_basics, juce_audio_formats, juce_events
  148. OSXFrameworks: CoreAudio CoreMIDI DiscRecording
  149. iOSFrameworks: CoreAudio CoreMIDI AudioToolbox AVFoundation
  150. linuxLibs: asound
  151. mingwLibs: winmm
  152. END_JUCE_MODULE_DECLARATION