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.

163 lines
7.6KB

  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 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. The BEGIN_JUCE_MODULE_DECLARATION block
  69. =======================================
  70. This block of text needs to go inside the module's main header file. It should be commented-out
  71. and perhaps inside an #if 0 block too, but the Introjucer will just scan the whole file for the
  72. string BEGIN_JUCE_MODULE_DECLARATION, and doesn't care about its context in terms of C++ syntax.
  73. The block needs a corresponding END_JUCE_MODULE_DECLARATION to finish the block.
  74. These should both be on a line of their own.
  75. Inside the block, the parser will expect to find a list of value definitions, one-per-line, with
  76. the very simple syntax
  77. value_name: value
  78. The value_name must be one of the items listed below, and is case-sensitive. Whitespace on the
  79. line is ignored. Some values are compulsory and must be supplied, but others are optional.
  80. The order in which they're declared doesn't matter.
  81. Possible values:
  82. ID: (Compulsory) This ID must match the name of the file and folder, e.g. juce_core.
  83. The main reason for also including it here is as a sanity-check
  84. vendor: (Compulsory) A unique ID for the vendor, e.g. "juce". This should be short
  85. and shouldn't contain any spaces
  86. version: (Compulsory) A version number for the module
  87. name: (Compulsory) A short description of the module
  88. description: (Compulsory) A longer description (but still only one line of text, please!)
  89. dependencies: (Optional) A list (space or comma-separated) of other modules that are required by
  90. this one. The Introjucer can use this to auto-resolve dependencies.
  91. website: (Optional) A URL linking to useful info about the module]
  92. license: (Optional) A description of the type of software license that applies
  93. searchpaths: (Optional) A space-separated list of internal include paths, relative to the module's
  94. parent folder, which need to be added to a project's header search path
  95. OSXFrameworks: (Optional) A list (space or comma-separated) of OSX frameworks that are needed
  96. by this module
  97. iOSFrameworks: (Optional) Like OSXFrameworks, but for iOS targets
  98. linuxLibs: (Optional) A list (space or comma-separated) of static or dynamic libs that should be linked in a
  99. linux build (these are passed to the linker via the -l flag)
  100. linuxPackages: (Optional) A list (space or comma-separated) pkg-config packages that should be used to pass
  101. compiler (CFLAGS) and linker (LDFLAGS) flags
  102. mingwLibs: (Optional) A list (space or comma-separated) of static libs that should be linked in a
  103. win32 mingw build (these are passed to the linker via the -l flag)
  104. Here's an example block:
  105. BEGIN_JUCE_MODULE_DECLARATION
  106. ID: juce_audio_devices
  107. vendor: juce
  108. version: 4.1.0
  109. name: JUCE audio and MIDI I/O device classes
  110. description: Classes to play and record from audio and MIDI I/O devices
  111. website: http://www.juce.com/juce
  112. license: GPL/Commercial
  113. dependencies: juce_audio_basics, juce_audio_formats, juce_events
  114. OSXFrameworks: CoreAudio CoreMIDI DiscRecording
  115. iOSFrameworks: CoreAudio CoreMIDI AudioToolbox AVFoundation
  116. linuxLibs: asound
  117. mingwLibs: winmm
  118. END_JUCE_MODULE_DECLARATION