Add TAL-Reverb-II plugin to test
[juce-lv2.git] / juce / source / extras / Introjucer / Source / Project / jucer_ProjectExporter.h
blob92bfeb1bb84b3b3f7933661110bed957c918bb3a
1 /*
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_PROJECTEXPORTER_JUCEHEADER__
27 #define __JUCER_PROJECTEXPORTER_JUCEHEADER__
29 #include "../jucer_Headers.h"
30 #include "jucer_Project.h"
33 //==============================================================================
34 class ProjectExporter
36 protected:
37 //==============================================================================
38 ProjectExporter (Project& project, const ValueTree& settings);
40 public:
41 virtual ~ProjectExporter();
43 static int getNumExporters();
44 static const StringArray getExporterNames();
45 static ProjectExporter* createNewExporter (Project& project, const int index);
47 static ProjectExporter* createExporter (Project& project, const ValueTree& settings);
48 static ProjectExporter* createPlatformDefaultExporter (Project& project);
50 //=============================================================================
51 virtual bool isDefaultFormatForCurrentOS() = 0;
52 virtual bool isPossibleForCurrentProject() = 0;
53 virtual bool usesMMFiles() const = 0;
54 virtual void createPropertyEditors (Array <PropertyComponent*>& props);
55 virtual void launchProject() = 0;
56 virtual void create() = 0; // may throw a SaveError
57 virtual bool shouldFileBeCompiledByDefault (const RelativePath& path) const;
59 //==============================================================================
60 const String getName() const { return name; }
61 const File getTargetFolder() const;
63 const ValueTree& getSettings() const { return settings; }
64 Value getSetting (const Identifier& name_) const { return settings.getPropertyAsValue (name_, project.getUndoManagerFor (settings)); }
66 Value getJuceFolder() const { return getSetting (Ids::juceFolder); }
67 Value getTargetLocation() const { return getSetting (Ids::targetFolder); }
69 Value getVSTFolder() const { return getSetting (Ids::vstFolder); }
70 Value getRTASFolder() const { return getSetting (Ids::rtasFolder); }
71 Value getAUFolder() const { return getSetting (Ids::auFolder); }
73 bool isVST() const { return (bool) project.isAudioPlugin() && (bool) project.shouldBuildVST().getValue(); }
74 bool isRTAS() const { return (bool) project.isAudioPlugin() && (bool) project.shouldBuildRTAS().getValue(); }
75 bool isAU() const { return (bool) project.isAudioPlugin() && (bool) project.shouldBuildAU().getValue(); }
77 Value getExtraCompilerFlags() const { return getSetting (Ids::extraCompilerFlags); }
78 Value getExtraLinkerFlags() const { return getSetting (Ids::extraLinkerFlags); }
80 Value getExporterPreprocessorDefs() const { return getSetting (Ids::extraDefs); }
82 // includes exporter, project + config defs
83 const StringPairArray getAllPreprocessorDefs (const Project::BuildConfiguration& config) const;
84 // includes exporter + project defs..
85 const StringPairArray getAllPreprocessorDefs() const;
87 const String replacePreprocessorTokens (const Project::BuildConfiguration& config,
88 const String& sourceString) const;
90 // This adds the quotes, and may return angle-brackets, eg: <foo/bar.h> or normal quotes.
91 const String getIncludePathForFileInJuceFolder (const String& pathFromJuceFolder, const File& targetIncludeFile) const;
93 const String getExporterIdentifierMacro() const
95 return "JUCER_" + settings.getType().toString() + "_"
96 + String::toHexString (settings [Ids::targetFolder].toString().hashCode()).toUpperCase();
99 Array<RelativePath> juceWrapperFiles;
100 RelativePath juceWrapperFolder;
102 // An exception that can be thrown by the create() method.
103 class SaveError
105 public:
106 SaveError (const String& error) : message (error)
109 SaveError (const File& fileThatFailedToWrite)
110 : message ("Can't write to the file: " + fileThatFailedToWrite.getFullPathName())
113 String message;
116 protected:
117 //==============================================================================
118 Project& project;
119 ValueTree settings;
120 String name;
122 const RelativePath getJucePathFromTargetFolder() const;
124 static const String getDefaultBuildsRootFolder() { return "Builds/"; }
126 const Array<RelativePath> getVSTFilesRequired() const;
128 static const String getLibbedFilename (String name)
130 if (! name.startsWith ("lib"))
131 name = "lib" + name;
132 if (! name.endsWithIgnoreCase (".a"))
133 name = name + ".a";
134 return name;
137 const RelativePath rebaseFromProjectFolderToBuildTarget (const RelativePath& path) const;
139 //==============================================================================
140 static void overwriteFileIfDifferentOrThrow (const File& file, const MemoryOutputStream& newData)
142 if (! FileHelpers::overwriteFileWithNewDataIfDifferent (file, newData))
143 throw SaveError (file);
146 static void createDirectoryOrThrow (const File& dirToCreate)
148 if (! dirToCreate.createDirectory())
149 throw SaveError ("Can't create folder: " + dirToCreate.getFullPathName());
152 static void writeXmlOrThrow (const XmlElement& xml, const File& file, const String& encoding, int maxCharsPerLine)
154 MemoryOutputStream mo;
155 xml.writeToStream (mo, String::empty, false, true, encoding, maxCharsPerLine);
156 overwriteFileIfDifferentOrThrow (file, mo);
159 private:
160 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ProjectExporter);
164 #endif // __JUCER_PROJECTEXPORTER_JUCEHEADER__