2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-10 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 #ifndef __JUCER_PROJECT_JUCEHEADER__
27 #define __JUCER_PROJECT_JUCEHEADER__
29 #include "../jucer_Headers.h"
30 class ProjectExporter
;
32 //==============================================================================
33 class Project
: public FileBasedDocument
,
34 public ValueTree::Listener
37 //==============================================================================
38 Project (const File
& file
);
41 //==============================================================================
42 // FileBasedDocument stuff..
43 const String
getDocumentTitle();
44 const String
loadDocument (const File
& file
);
45 const String
saveDocument (const File
& file
);
46 const File
getLastDocumentOpened();
47 void setLastDocumentOpened (const File
& file
);
49 void setTitle (const String
& newTitle
);
51 //==============================================================================
52 ValueTree
getProjectRoot() const { return projectRoot
; }
53 Value
getProjectName() { return getMainGroup().getName(); }
54 const String
getProjectFilenameRoot() { return File::createLegalFileName (getDocumentTitle()); }
55 const String
getProjectUID() const { return projectRoot
[Ids::id_
]; }
57 //==============================================================================
58 bool shouldBeAddedToBinaryResourcesByDefault (const File
& file
);
59 const File
resolveFilename (String filename
) const;
60 const String
getRelativePathForFile (const File
& file
) const;
62 //==============================================================================
63 // Creates editors for the project settings
64 void createPropertyEditors (Array
<PropertyComponent
*>& properties
);
66 //==============================================================================
68 static const char* const application
;
69 static const char* const commandLineApp
;
70 static const char* const audioPlugin
;
71 static const char* const library
;
72 static const char* const browserPlugin
;
74 Value
getProjectType() const { return getProjectValue ("projectType"); }
76 bool isLibrary() const;
77 bool isGUIApplication() const;
78 bool isCommandLineApp() const;
79 bool isAudioPlugin() const;
80 bool isBrowserPlugin() const;
82 Value
getVersion() const { return getProjectValue ("version"); }
83 Value
getBundleIdentifier() const { return getProjectValue ("bundleIdentifier"); }
84 void setBundleIdentifierToDefault() { getBundleIdentifier() = "com.yourcompany." + CodeHelpers::makeValidIdentifier (getProjectName().toString(), false, true, false); }
86 //==============================================================================
88 static const char* const notLinkedToJuce
;
89 static const char* const useLinkedJuce
;
90 static const char* const useAmalgamatedJuce
;
91 static const char* const useAmalgamatedJuceViaSingleTemplate
;
92 static const char* const useAmalgamatedJuceViaMultipleTemplates
;
94 Value
getJuceLinkageModeValue() const { return getProjectValue ("juceLinkage"); }
95 const String
getJuceLinkageMode() const { return getJuceLinkageModeValue().toString(); }
97 bool isUsingWrapperFiles() const { return isUsingFullyAmalgamatedFile() || isUsingSingleTemplateFile() || isUsingMultipleTemplateFiles(); }
98 bool isUsingFullyAmalgamatedFile() const { return getJuceLinkageMode() == useAmalgamatedJuce
; }
99 bool isUsingSingleTemplateFile() const { return getJuceLinkageMode() == useAmalgamatedJuceViaSingleTemplate
; }
100 bool isUsingMultipleTemplateFiles() const { return getJuceLinkageMode() == useAmalgamatedJuceViaMultipleTemplates
; }
102 //==============================================================================
103 Value
getProjectValue (const Identifier
& name
) const { return projectRoot
.getPropertyAsValue (name
, getUndoManagerFor (projectRoot
)); }
105 Value
getProjectPreprocessorDefs() const { return getProjectValue (Ids::defines
); }
106 const StringPairArray
getPreprocessorDefs() const;
108 Value
getBigIconImageItemID() const { return getProjectValue ("bigIcon"); }
109 Value
getSmallIconImageItemID() const { return getProjectValue ("smallIcon"); }
110 const Image
getBigIcon();
111 const Image
getSmallIcon();
112 const Image
getBestIconForSize (int size
, bool returnNullIfNothingBigEnough
);
114 Value
shouldBuildVST() const { return getProjectValue ("buildVST"); }
115 Value
shouldBuildRTAS() const { return getProjectValue ("buildRTAS"); }
116 Value
shouldBuildAU() const { return getProjectValue ("buildAU"); }
117 bool shouldAddVSTFolderToPath() { return (isAudioPlugin() && (bool) shouldBuildVST().getValue()) || getJuceConfigFlag ("JUCE_PLUGINHOST_VST").toString() == configFlagEnabled
; }
119 Value
getPluginName() const { return getProjectValue ("pluginName"); }
120 Value
getPluginDesc() const { return getProjectValue ("pluginDesc"); }
121 Value
getPluginManufacturer() const { return getProjectValue ("pluginManufacturer"); }
122 Value
getPluginManufacturerCode() const { return getProjectValue ("pluginManufacturerCode"); }
123 Value
getPluginCode() const { return getProjectValue ("pluginCode"); }
124 Value
getPluginChannelConfigs() const { return getProjectValue ("pluginChannelConfigs"); }
125 Value
getPluginIsSynth() const { return getProjectValue ("pluginIsSynth"); }
126 Value
getPluginWantsMidiInput() const { return getProjectValue ("pluginWantsMidiIn"); }
127 Value
getPluginProducesMidiOut() const { return getProjectValue ("pluginProducesMidiOut"); }
128 Value
getPluginSilenceInProducesSilenceOut() const { return getProjectValue ("pluginSilenceInIsSilenceOut"); }
129 Value
getPluginTailLengthSeconds() const { return getProjectValue ("pluginTailLength"); }
130 Value
getPluginEditorNeedsKeyFocus() const { return getProjectValue ("pluginEditorRequiresKeys"); }
131 Value
getPluginAUExportPrefix() const { return getProjectValue ("pluginAUExportPrefix"); }
132 Value
getPluginAUCocoaViewClassName() const { return getProjectValue ("pluginAUViewClass"); }
133 Value
getPluginRTASCategory() const { return getProjectValue ("pluginRTASCategory"); }
135 //==============================================================================
136 const File
getAppIncludeFile() const { return getWrapperFolder().getChildFile (getJuceSourceHFilename()); }
137 const File
getWrapperFolder() const { return getFile().getSiblingFile ("JuceLibraryCode"); }
138 const File
getPluginCharacteristicsFile() const { return getWrapperFolder().getChildFile (getPluginCharacteristicsFilename()); }
140 //==============================================================================
141 const String
getAmalgamatedHeaderFileName() const { return "juce_amalgamated.h"; }
142 const String
getAmalgamatedMMFileName() const { return "juce_amalgamated.mm"; }
143 const String
getAmalgamatedCppFileName() const { return "juce_amalgamated.cpp"; }
145 const String
getAppConfigFilename() const { return "AppConfig.h"; }
146 const String
getJuceSourceFilenameRoot() const { return "JuceLibraryCode"; }
147 int getNumSeparateAmalgamatedFiles() const { return 4; }
148 const String
getJuceSourceHFilename() const { return "JuceHeader.h"; }
149 const String
getJuceCodeGroupName() const { return "Juce Library Code"; }
150 const String
getPluginCharacteristicsFilename() const { return "JucePluginCharacteristics.h"; }
152 //==============================================================================
156 //==============================================================================
157 Item (Project
& project
, const ValueTree
& itemNode
);
158 Item (const Item
& other
);
159 Item
& operator= (const Item
& other
);
162 void initialiseNodeValues();
164 //==============================================================================
165 bool isValid() const { return node
.isValid(); }
166 const ValueTree
& getNode() const noexcept
{ return node
; }
167 ValueTree
& getNode() noexcept
{ return node
; }
168 Project
& getProject() const noexcept
{ return *project
; }
169 bool operator== (const Item
& other
) const { return node
== other
.node
&& project
== other
.project
; }
170 bool operator!= (const Item
& other
) const { return ! operator== (other
); }
172 //==============================================================================
174 bool isGroup() const;
175 bool isMainGroup() const;
176 bool isImageFile() const;
178 const String
getID() const;
179 Item
findItemWithID (const String
& targetId
) const; // (recursive search)
180 const String
getImageFileID() const;
182 //==============================================================================
183 Value
getName() const;
184 const File
getFile() const;
185 void setFile (const File
& file
);
186 const File
determineGroupFolder() const;
187 bool renameFile (const File
& newFile
);
189 bool shouldBeAddedToTargetProject() const;
190 bool shouldBeCompiled() const;
191 Value
getShouldCompileValue() const;
192 bool shouldBeAddedToBinaryResources() const;
193 Value
getShouldAddToResourceValue() const;
195 //==============================================================================
196 bool canContain (const Item
& child
) const;
197 int getNumChildren() const { return node
.getNumChildren(); }
198 Item
getChild (int index
) const { return Item (*project
, node
.getChild (index
)); }
199 void addChild (const Item
& newChild
, int insertIndex
);
200 bool addFile (const File
& file
, int insertIndex
);
201 void removeItemFromProject();
202 void sortAlphabetically();
203 Item
findItemForFile (const File
& file
) const;
205 Item
getParent() const;
207 const Drawable
* getIcon() const;
210 //==============================================================================
214 UndoManager
* getUndoManager() const { return project
->getUndoManagerFor (node
); }
218 Item
createNewGroup();
219 Item
createNewItem (const File
& file
);
221 void findAllImageItems (OwnedArray
<Item
>& items
);
223 //==============================================================================
224 class BuildConfiguration
227 BuildConfiguration (const BuildConfiguration
&);
228 const BuildConfiguration
& operator= (const BuildConfiguration
&);
229 ~BuildConfiguration();
231 //==============================================================================
232 Project
& getProject() const { return *project
; }
234 void createPropertyEditors (Array
<PropertyComponent
*>& properties
);
236 //==============================================================================
237 Value
getName() const { return getValue (Ids::name
); }
238 Value
isDebug() const { return getValue (Ids::isDebug
); }
239 Value
getTargetBinaryName() const { return getValue (Ids::targetName
); }
240 // the path relative to the build folder in which the binary should go
241 Value
getTargetBinaryRelativePath() const { return getValue (Ids::binaryPath
); }
242 Value
getOptimisationLevel() const { return getValue (Ids::optimisation
); }
243 const String
getGCCOptimisationFlag() const;
244 Value
getBuildConfigPreprocessorDefs() const { return getValue (Ids::defines
); }
245 const StringPairArray
getAllPreprocessorDefs() const; // includes inherited definitions
246 Value
getHeaderSearchPath() const { return getValue (Ids::headerPath
); }
247 const StringArray
getHeaderSearchPaths() const;
249 static const char* const osxVersionDefault
;
250 static const char* const osxVersion10_4
;
251 static const char* const osxVersion10_5
;
252 static const char* const osxVersion10_6
;
253 Value
getMacSDKVersion() const { return getValue (Ids::osxSDK
); }
254 Value
getMacCompatibilityVersion() const { return getValue (Ids::osxCompatibility
); }
256 static const char* const osxArch_Default
;
257 static const char* const osxArch_Native
;
258 static const char* const osxArch_32BitUniversal
;
259 static const char* const osxArch_64BitUniversal
;
260 static const char* const osxArch_64Bit
;
261 Value
getMacArchitecture() const { return getValue (Ids::osxArchitecture
); }
263 //==============================================================================
265 friend class Project
;
269 Value
getValue (const Identifier
& name
) const { return config
.getPropertyAsValue (name
, getUndoManager()); }
270 UndoManager
* getUndoManager() const { return project
->getUndoManagerFor (config
); }
272 BuildConfiguration (Project
* project
, const ValueTree
& configNode
);
275 int getNumConfigurations() const;
276 BuildConfiguration
getConfiguration (int index
);
277 void addNewConfiguration (BuildConfiguration
* configToCopy
);
278 void deleteConfiguration (int index
);
279 bool hasConfigurationNamed (const String
& name
) const;
280 const String
getUniqueConfigName (String name
) const;
282 //==============================================================================
283 ValueTree
getExporters();
284 int getNumExporters();
285 ProjectExporter
* createExporter (int index
);
286 void addNewExporter (int exporterIndex
);
287 void deleteExporter (int index
);
288 void createDefaultExporters();
290 //==============================================================================
291 struct JuceConfigFlag
293 String symbol
, description
;
294 Value value
; // 1 = true, 2 = false, anything else = use default
297 void getJuceConfigFlags (OwnedArray
<JuceConfigFlag
>& flags
);
299 static const char* const configFlagDefault
;
300 static const char* const configFlagEnabled
;
301 static const char* const configFlagDisabled
;
302 Value
getJuceConfigFlag (const String
& name
);
304 //==============================================================================
305 const String
getFileTemplate (const String
& templateName
);
307 //==============================================================================
308 void valueTreePropertyChanged (ValueTree
& tree
, const Identifier
& property
);
309 void valueTreeChildAdded (ValueTree
& parentTree
, ValueTree
& childWhichHasBeenAdded
);
310 void valueTreeChildRemoved (ValueTree
& parentTree
, ValueTree
& childWhichHasBeenRemoved
);
311 void valueTreeChildOrderChanged (ValueTree
& parentTree
);
312 void valueTreeParentChanged (ValueTree
& tree
);
314 //==============================================================================
315 UndoManager
* getUndoManagerFor (const ValueTree
& node
) const { return 0; }
317 //==============================================================================
318 static const char* projectFileExtension
;
320 static void resaveJucerFile (const File
& file
);
324 ValueTree projectRoot
;
325 static File lastDocumentOpened
;
326 DrawableImage mainProjectIcon
;
328 const File
getLocalJuceFolder();
329 void updateProjectSettings();
330 void setMissingDefaultValues();
331 ValueTree
getConfigurations() const;
332 void createDefaultConfigs();
333 ValueTree
getJuceConfigNode();
335 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Project
);
339 #endif // __JUCER_PROJECT_JUCEHEADER__