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.

1817 lines
80KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. class MSVCProjectExporterBase : public ProjectExporter
  18. {
  19. public:
  20. MSVCProjectExporterBase (Project& p, const ValueTree& t, const char* const folderName)
  21. : ProjectExporter (p, t)
  22. {
  23. if (getTargetLocationString().isEmpty())
  24. getTargetLocationValue() = getDefaultBuildsRootFolder() + folderName;
  25. updateOldSettings();
  26. initialiseDependencyPathValues();
  27. }
  28. //==============================================================================
  29. class MSVCBuildConfiguration : public BuildConfiguration
  30. {
  31. public:
  32. MSVCBuildConfiguration (Project& p, const ValueTree& settings, const ProjectExporter& e)
  33. : BuildConfiguration (p, settings, e)
  34. {
  35. if (getWarningLevel() == 0)
  36. getWarningLevelValue() = 4;
  37. setValueIfVoid (shouldGenerateManifestValue(), true);
  38. }
  39. Value getWarningLevelValue() { return getValue (Ids::winWarningLevel); }
  40. int getWarningLevel() const { return config [Ids::winWarningLevel]; }
  41. Value getWarningsTreatedAsErrors() { return getValue (Ids::warningsAreErrors); }
  42. bool areWarningsTreatedAsErrors() const { return config [Ids::warningsAreErrors]; }
  43. Value getPrebuildCommand() { return getValue (Ids::prebuildCommand); }
  44. String getPrebuildCommandString() const { return config [Ids::prebuildCommand]; }
  45. Value getPostbuildCommand() { return getValue (Ids::postbuildCommand); }
  46. String getPostbuildCommandString() const { return config [Ids::postbuildCommand]; }
  47. Value shouldGenerateDebugSymbolsValue() { return getValue (Ids::alwaysGenerateDebugSymbols); }
  48. bool shouldGenerateDebugSymbols() const { return config [Ids::alwaysGenerateDebugSymbols]; }
  49. Value shouldGenerateManifestValue() { return getValue (Ids::generateManifest); }
  50. bool shouldGenerateManifest() const { return config [Ids::generateManifest]; }
  51. Value shouldLinkIncrementalValue() { return getValue (Ids::enableIncrementalLinking); }
  52. bool shouldLinkIncremental() const { return config [Ids::enableIncrementalLinking]; }
  53. Value getWholeProgramOptValue() { return getValue (Ids::wholeProgramOptimisation); }
  54. bool shouldDisableWholeProgramOpt() const { return static_cast<int> (config [Ids::wholeProgramOptimisation]) > 0; }
  55. Value getUsingRuntimeLibDLL() { return getValue (Ids::useRuntimeLibDLL); }
  56. bool isUsingRuntimeLibDLL() const { return config [Ids::useRuntimeLibDLL]; }
  57. String getIntermediatesPath() const { return config [Ids::intermediatesPath].toString(); }
  58. Value getIntermediatesPathValue() { return getValue (Ids::intermediatesPath); }
  59. String getCharacterSet() const { return config [Ids::characterSet].toString(); }
  60. Value getCharacterSetValue() { return getValue (Ids::characterSet); }
  61. String createMSVCConfigName() const
  62. {
  63. return getName() + "|" + (config [Ids::winArchitecture] == "x64" ? "x64" : "Win32");
  64. }
  65. String getOutputFilename (const String& suffix, bool forceSuffix) const
  66. {
  67. const String target (File::createLegalFileName (getTargetBinaryNameString().trim()));
  68. if (forceSuffix || ! target.containsChar ('.'))
  69. return target.upToLastOccurrenceOf (".", false, false) + suffix;
  70. return target;
  71. }
  72. var getDefaultOptimisationLevel() const override { return var ((int) (isDebug() ? optimisationOff : optimiseMaxSpeed)); }
  73. void createConfigProperties (PropertyListBuilder& props) override
  74. {
  75. static const char* optimisationLevels[] = { "No optimisation", "Minimise size", "Maximise speed", 0 };
  76. const int optimisationLevelValues[] = { optimisationOff, optimiseMinSize, optimiseMaxSpeed, 0 };
  77. props.add (new ChoicePropertyComponent (getOptimisationLevel(), "Optimisation",
  78. StringArray (optimisationLevels),
  79. Array<var> (optimisationLevelValues)),
  80. "The optimisation level for this configuration");
  81. props.add (new TextPropertyComponent (getIntermediatesPathValue(), "Intermediates path", 2048, false),
  82. "An optional path to a folder to use for the intermediate build files. Note that Visual Studio allows "
  83. "you to use macros in this path, e.g. \"$(TEMP)\\MyAppBuildFiles\\$(Configuration)\", which is a handy way to "
  84. "send them to the user's temp folder.");
  85. static const char* warningLevelNames[] = { "Low", "Medium", "High", nullptr };
  86. const int warningLevels[] = { 2, 3, 4 };
  87. props.add (new ChoicePropertyComponent (getWarningLevelValue(), "Warning Level",
  88. StringArray (warningLevelNames), Array<var> (warningLevels, numElementsInArray (warningLevels))));
  89. props.add (new BooleanPropertyComponent (getWarningsTreatedAsErrors(), "Warnings", "Treat warnings as errors"));
  90. {
  91. static const char* runtimeNames[] = { "(Default)", "Use static runtime", "Use DLL runtime", nullptr };
  92. const var runtimeValues[] = { var(), var (false), var (true) };
  93. props.add (new ChoicePropertyComponent (getUsingRuntimeLibDLL(), "Runtime Library",
  94. StringArray (runtimeNames), Array<var> (runtimeValues, numElementsInArray (runtimeValues))),
  95. "If the static runtime is selected then your app/plug-in will not be dependent upon users having Microsoft's redistributable "
  96. "C++ runtime installed. However, if you are linking libraries from different sources you must select the same type of runtime "
  97. "used by the libraries.");
  98. }
  99. {
  100. static const char* wpoNames[] = { "Enable link-time code generation when possible",
  101. "Always disable link-time code generation", nullptr };
  102. const var wpoValues[] = { var(), var (1) };
  103. props.add (new ChoicePropertyComponent (getWholeProgramOptValue(), "Whole Program Optimisation",
  104. StringArray (wpoNames), Array<var> (wpoValues, numElementsInArray (wpoValues))));
  105. }
  106. {
  107. props.add (new BooleanPropertyComponent (shouldLinkIncrementalValue(), "Incremental Linking", "Enable"),
  108. "Enable to avoid linking from scratch for every new build. "
  109. "Disable to ensure that your final release build does not contain padding or thunks.");
  110. }
  111. if (! isDebug())
  112. props.add (new BooleanPropertyComponent (shouldGenerateDebugSymbolsValue(), "Debug Symbols", "Force generation of debug symbols"));
  113. props.add (new TextPropertyComponent (getPrebuildCommand(), "Pre-build Command", 2048, true));
  114. props.add (new TextPropertyComponent (getPostbuildCommand(), "Post-build Command", 2048, true));
  115. props.add (new BooleanPropertyComponent (shouldGenerateManifestValue(), "Manifest", "Generate Manifest"));
  116. {
  117. static const char* characterSetNames[] = { "Default", "MultiByte", "Unicode", nullptr };
  118. const var charSets[] = { var(), "MultiByte", "Unicode", };
  119. props.add (new ChoicePropertyComponent (getCharacterSetValue(), "Character Set",
  120. StringArray (characterSetNames), Array<var> (charSets, numElementsInArray (charSets))));
  121. }
  122. }
  123. String getLibrarySubdirPath () const override
  124. {
  125. auto result = String ("$(Platform)\\");
  126. result += isUsingRuntimeLibDLL() ? "MD" : "MT";
  127. if (isDebug())
  128. result += "d";
  129. return result;
  130. }
  131. };
  132. //==============================================================================
  133. class MSVCTargetBase : public ProjectType::Target
  134. {
  135. public:
  136. MSVCTargetBase (ProjectType::Target::Type targetType, const MSVCProjectExporterBase& exporter)
  137. : ProjectType::Target (targetType), owner (exporter)
  138. {
  139. projectGuid = createGUID (owner.getProject().getProjectUID() + getName());
  140. }
  141. virtual ~MSVCTargetBase() {}
  142. const MSVCProjectExporterBase& getOwner() const { return owner; }
  143. virtual String getTopLevelXmlEntity() const = 0;
  144. const String& getProjectGuid() const { return projectGuid; }
  145. //==============================================================================
  146. void writeProjectFile()
  147. {
  148. XmlElement projectXml (getTopLevelXmlEntity());
  149. fillInProjectXml (projectXml);
  150. writeXmlOrThrow (projectXml, getVCProjFile(), "UTF-8", 10);
  151. }
  152. virtual void fillInProjectXml (XmlElement& projectXml) const = 0;
  153. String getSolutionTargetPath (const BuildConfiguration& config) const
  154. {
  155. const String binaryPath (config.getTargetBinaryRelativePathString().trim());
  156. if (binaryPath.isEmpty())
  157. return "$(SolutionDir)\\$(Platform)\\$(Configuration)";
  158. RelativePath binaryRelPath (binaryPath, RelativePath::projectFolder);
  159. if (binaryRelPath.isAbsolute())
  160. return binaryRelPath.toWindowsStyle();
  161. return prependDot (binaryRelPath.rebased (getOwner().projectFolder, getOwner().getTargetFolder(), RelativePath::buildTargetFolder)
  162. .toWindowsStyle());
  163. }
  164. String getConfigTargetPath (const BuildConfiguration& config) const
  165. {
  166. String solutionTargetFolder (getSolutionTargetPath (config));
  167. return solutionTargetFolder + String ("\\") + getName();
  168. }
  169. String getIntermediatesPath (const MSVCBuildConfiguration& config) const
  170. {
  171. String intDir = (config.getIntermediatesPath().isNotEmpty() ? config.getIntermediatesPath() : "$(Platform)\\$(Configuration)");
  172. if (! intDir.endsWithChar (L'\\'))
  173. intDir += L'\\';
  174. return intDir + getName();
  175. }
  176. static const char* getOptimisationLevelString (int level)
  177. {
  178. switch (level)
  179. {
  180. case optimiseMaxSpeed: return "Full";
  181. case optimiseMinSize: return "MinSpace";
  182. default: return "Disabled";
  183. }
  184. }
  185. String getTargetSuffix() const
  186. {
  187. const ProjectType::Target::TargetFileType fileType = getTargetFileType();
  188. switch (fileType)
  189. {
  190. case executable:
  191. return ".exe";
  192. case staticLibrary:
  193. return ".lib";
  194. case sharedLibraryOrDLL:
  195. return ".dll";
  196. case pluginBundle:
  197. switch (type)
  198. {
  199. case VST3PlugIn:
  200. return ".vst3";
  201. case AAXPlugIn:
  202. return ".aaxdll";
  203. case RTASPlugIn:
  204. return ".dpm";
  205. default:
  206. break;
  207. }
  208. return ".dll";
  209. default:
  210. break;
  211. }
  212. return String();
  213. }
  214. XmlElement* createToolElement (XmlElement& parent, const String& toolName) const
  215. {
  216. XmlElement* const e = parent.createNewChildElement ("Tool");
  217. e->setAttribute ("Name", toolName);
  218. return e;
  219. }
  220. String getPreprocessorDefs (const BuildConfiguration& config, const String& joinString) const
  221. {
  222. StringPairArray defines (getOwner().msvcExtraPreprocessorDefs);
  223. defines.set ("WIN32", "");
  224. defines.set ("_WINDOWS", "");
  225. if (config.isDebug())
  226. {
  227. defines.set ("DEBUG", "");
  228. defines.set ("_DEBUG", "");
  229. }
  230. else
  231. {
  232. defines.set ("NDEBUG", "");
  233. }
  234. defines = mergePreprocessorDefs (defines, getOwner().getAllPreprocessorDefs (config, type));
  235. addExtraPreprocessorDefines (defines);
  236. if (getTargetFileType() == staticLibrary || getTargetFileType() == sharedLibraryOrDLL)
  237. defines.set("_LIB", "");
  238. StringArray result;
  239. for (int i = 0; i < defines.size(); ++i)
  240. {
  241. String def (defines.getAllKeys()[i]);
  242. const String value (defines.getAllValues()[i]);
  243. if (value.isNotEmpty())
  244. def << "=" << value;
  245. result.add (def);
  246. }
  247. return result.joinIntoString (joinString);
  248. }
  249. //==============================================================================
  250. RelativePath getAAXIconFile() const
  251. {
  252. const RelativePath aaxSDK (getOwner().getAAXPathValue().toString(), RelativePath::projectFolder);
  253. const RelativePath projectIcon ("icon.ico", RelativePath::buildTargetFolder);
  254. if (getOwner().getTargetFolder().getChildFile ("icon.ico").existsAsFile())
  255. return projectIcon.rebased (getOwner().getTargetFolder(),
  256. getOwner().getProject().getProjectFolder(),
  257. RelativePath::projectFolder);
  258. else
  259. return aaxSDK.getChildFile ("Utilities").getChildFile ("PlugIn.ico");
  260. }
  261. String getExtraPostBuildSteps (const MSVCBuildConfiguration& config) const
  262. {
  263. if (type == AAXPlugIn)
  264. {
  265. const RelativePath aaxSDK (getOwner().getAAXPathValue().toString(), RelativePath::projectFolder);
  266. const RelativePath aaxLibsFolder = aaxSDK.getChildFile ("Libs");
  267. const RelativePath bundleScript = aaxSDK.getChildFile ("Utilities").getChildFile ("CreatePackage.bat");
  268. const RelativePath iconFilePath = getAAXIconFile();
  269. const bool is64Bit = (config.config [Ids::winArchitecture] == "x64");
  270. const String bundleDir = getOwner().getOutDirFile (config, config.getOutputFilename (".aaxplugin", true));
  271. const String bundleContents = bundleDir + "\\Contents";
  272. const String macOSDir = bundleContents + String ("\\") + (is64Bit ? "x64" : "Win32");
  273. const String executable = macOSDir + String ("\\") + config.getOutputFilename (".aaxplugin", true);
  274. return String ("copy /Y \"") + getOutputFilePath (config) + String ("\" \"") + executable + String ("\"\r\n") +
  275. createRebasedPath (bundleScript) + String (" \"") + macOSDir + String ("\" ") + createRebasedPath (iconFilePath);
  276. }
  277. return String();
  278. }
  279. String getExtraPreBuildSteps (const MSVCBuildConfiguration& config) const
  280. {
  281. if (type == AAXPlugIn)
  282. {
  283. String script;
  284. const bool is64Bit = (config.config [Ids::winArchitecture] == "x64");
  285. const String bundleDir = getOwner().getOutDirFile (config, config.getOutputFilename (".aaxplugin", false));
  286. const String bundleContents = bundleDir + "\\Contents";
  287. const String macOSDir = bundleContents + String ("\\") + (is64Bit ? "x64" : "Win32");
  288. StringArray folders = {bundleDir.toRawUTF8(), bundleContents.toRawUTF8(), macOSDir.toRawUTF8()};
  289. for (int i = 0; i < folders.size(); ++i)
  290. script += String ("if not exist \"") + folders[i] + String ("\" mkdir \"") + folders[i] + String ("\"\r\n");
  291. return script;
  292. }
  293. return String();
  294. }
  295. String getPostBuildSteps (const MSVCBuildConfiguration& config) const
  296. {
  297. String postBuild = config.getPostbuildCommandString();
  298. const String extraPostBuild = getExtraPostBuildSteps (config);
  299. postBuild += String (postBuild.isNotEmpty() && extraPostBuild.isNotEmpty() ? "\r\n" : "") + extraPostBuild;
  300. return postBuild;
  301. }
  302. String getPreBuildSteps (const MSVCBuildConfiguration& config) const
  303. {
  304. String preBuild = config.getPrebuildCommandString();
  305. const String extraPreBuild = getExtraPreBuildSteps (config);
  306. preBuild += String (preBuild.isNotEmpty() && extraPreBuild.isNotEmpty() ? "\r\n" : "") + extraPreBuild;
  307. return preBuild;
  308. }
  309. void addExtraPreprocessorDefines (StringPairArray& defines) const
  310. {
  311. switch (type)
  312. {
  313. case AAXPlugIn:
  314. {
  315. const RelativePath aaxLibsFolder = RelativePath (getOwner().getAAXPathValue().toString(), RelativePath::projectFolder).getChildFile ("Libs");
  316. defines.set ("JucePlugin_AAXLibs_path", createRebasedPath (aaxLibsFolder));
  317. }
  318. break;
  319. case RTASPlugIn:
  320. {
  321. const RelativePath rtasFolder (getOwner().getRTASPathValue().toString(), RelativePath::projectFolder);
  322. defines.set ("JucePlugin_WinBag_path", createRebasedPath (rtasFolder.getChildFile ("WinBag")));
  323. }
  324. break;
  325. default:
  326. break;
  327. }
  328. }
  329. String getExtraLinkerFlags() const
  330. {
  331. if (type == RTASPlugIn) return "/FORCE:multiple";
  332. return String();
  333. }
  334. StringArray getExtraSearchPaths() const
  335. {
  336. StringArray searchPaths;
  337. if (type == RTASPlugIn)
  338. {
  339. const RelativePath rtasFolder (getOwner().getRTASPathValue().toString(), RelativePath::projectFolder);
  340. static const char* p[] = { "AlturaPorts/TDMPlugins/PluginLibrary/EffectClasses",
  341. "AlturaPorts/TDMPlugins/PluginLibrary/ProcessClasses",
  342. "AlturaPorts/TDMPlugins/PluginLibrary/ProcessClasses/Interfaces",
  343. "AlturaPorts/TDMPlugins/PluginLibrary/Utilities",
  344. "AlturaPorts/TDMPlugins/PluginLibrary/RTASP_Adapt",
  345. "AlturaPorts/TDMPlugins/PluginLibrary/CoreClasses",
  346. "AlturaPorts/TDMPlugins/PluginLibrary/Controls",
  347. "AlturaPorts/TDMPlugins/PluginLibrary/Meters",
  348. "AlturaPorts/TDMPlugins/PluginLibrary/ViewClasses",
  349. "AlturaPorts/TDMPlugins/PluginLibrary/DSPClasses",
  350. "AlturaPorts/TDMPlugins/PluginLibrary/Interfaces",
  351. "AlturaPorts/TDMPlugins/common",
  352. "AlturaPorts/TDMPlugins/common/Platform",
  353. "AlturaPorts/TDMPlugins/common/Macros",
  354. "AlturaPorts/TDMPlugins/SignalProcessing/Public",
  355. "AlturaPorts/TDMPlugIns/DSPManager/Interfaces",
  356. "AlturaPorts/SADriver/Interfaces",
  357. "AlturaPorts/DigiPublic/Interfaces",
  358. "AlturaPorts/DigiPublic",
  359. "AlturaPorts/Fic/Interfaces/DAEClient",
  360. "AlturaPorts/NewFileLibs/Cmn",
  361. "AlturaPorts/NewFileLibs/DOA",
  362. "AlturaPorts/AlturaSource/PPC_H",
  363. "AlturaPorts/AlturaSource/AppSupport",
  364. "AvidCode/AVX2sdk/AVX/avx2/avx2sdk/inc",
  365. "xplat/AVX/avx2/avx2sdk/inc" };
  366. for (int i = 0; i < numElementsInArray (p); ++i)
  367. searchPaths.add (createRebasedPath (rtasFolder.getChildFile (p[i])));
  368. }
  369. return searchPaths;
  370. }
  371. String getBinaryNameWithSuffix (const MSVCBuildConfiguration& config) const
  372. {
  373. return config.getOutputFilename (getTargetSuffix(), true);
  374. }
  375. String getOutputFilePath (const MSVCBuildConfiguration& config) const
  376. {
  377. return getOwner().getOutDirFile (config, getBinaryNameWithSuffix (config));
  378. }
  379. StringArray getLibrarySearchPaths (const BuildConfiguration& config) const
  380. {
  381. StringArray librarySearchPaths (config.getLibrarySearchPaths());
  382. if (type != SharedCodeTarget)
  383. if (const MSVCTargetBase* shared = getOwner().getSharedCodeTarget())
  384. librarySearchPaths.add (shared->getConfigTargetPath (config));
  385. return librarySearchPaths;
  386. }
  387. String getExternalLibraries (const MSVCBuildConfiguration& config, const String& otherLibs) const
  388. {
  389. StringArray libraries;
  390. if (otherLibs.isNotEmpty())
  391. libraries.add (otherLibs);
  392. StringArray moduleLibs = getOwner().getModuleLibs();
  393. if (! moduleLibs.isEmpty())
  394. libraries.addArray (moduleLibs);
  395. if (type != SharedCodeTarget)
  396. if (const MSVCTargetBase* shared = getOwner().getSharedCodeTarget())
  397. libraries.add (shared->getBinaryNameWithSuffix (config));
  398. return libraries.joinIntoString (";");
  399. }
  400. String getDelayLoadedDLLs() const
  401. {
  402. String delayLoadedDLLs = getOwner().msvcDelayLoadedDLLs;
  403. if (type == RTASPlugIn)
  404. delayLoadedDLLs += "DAE.dll; DigiExt.dll; DSI.dll; PluginLib.dll; "
  405. "DSPManager.dll; DSPManager.dll; DSPManagerClientLib.dll; RTASClientLib.dll";
  406. return delayLoadedDLLs;
  407. }
  408. String getModuleDefinitions (const MSVCBuildConfiguration& config) const
  409. {
  410. const String& moduleDefinitions = config.config [Ids::msvcModuleDefinitionFile].toString();
  411. if (moduleDefinitions.isNotEmpty())
  412. return moduleDefinitions;
  413. if (type == RTASPlugIn)
  414. {
  415. const ProjectExporter& exp = getOwner();
  416. RelativePath moduleDefPath
  417. = RelativePath (exp.getPathForModuleString ("juce_audio_plugin_client"), RelativePath::projectFolder)
  418. .getChildFile ("juce_audio_plugin_client").getChildFile ("RTAS").getChildFile ("juce_RTAS_WinExports.def");
  419. return prependDot (moduleDefPath.rebased (exp.getProject().getProjectFolder(),
  420. exp.getTargetFolder(),
  421. RelativePath::buildTargetFolder).toWindowsStyle());
  422. }
  423. return String();
  424. }
  425. bool shouldUseRuntimeDLL (const MSVCBuildConfiguration& config) const
  426. {
  427. return (config.config [Ids::useRuntimeLibDLL].isVoid() ? (getOwner().hasTarget (AAXPlugIn) || getOwner().hasTarget (RTASPlugIn))
  428. : config.isUsingRuntimeLibDLL());
  429. }
  430. virtual String getProjectFileSuffix() const = 0;
  431. File getVCProjFile() const { return getOwner().getProjectFile (getProjectFileSuffix(), getName()); }
  432. String createRebasedPath (const RelativePath& path) const { return getOwner().createRebasedPath (path); }
  433. //==============================================================================
  434. virtual String getProjectVersionString() const = 0;
  435. protected:
  436. const MSVCProjectExporterBase& owner;
  437. String projectGuid;
  438. };
  439. //==============================================================================
  440. bool usesMMFiles() const override { return false; }
  441. bool canCopeWithDuplicateFiles() override { return false; }
  442. bool supportsUserDefinedConfigurations() const override { return true; }
  443. bool isXcode() const override { return false; }
  444. bool isVisualStudio() const override { return true; }
  445. bool isCodeBlocks() const override { return false; }
  446. bool isMakefile() const override { return false; }
  447. bool isAndroidStudio() const override { return false; }
  448. bool isAndroid() const override { return false; }
  449. bool isWindows() const override { return true; }
  450. bool isLinux() const override { return false; }
  451. bool isOSX() const override { return false; }
  452. bool isiOS() const override { return false; }
  453. bool supportsTargetType (ProjectType::Target::Type type) const override
  454. {
  455. switch (type)
  456. {
  457. case ProjectType::Target::StandalonePlugIn:
  458. case ProjectType::Target::GUIApp:
  459. case ProjectType::Target::ConsoleApp:
  460. case ProjectType::Target::StaticLibrary:
  461. case ProjectType::Target::SharedCodeTarget:
  462. case ProjectType::Target::AggregateTarget:
  463. case ProjectType::Target::VSTPlugIn:
  464. case ProjectType::Target::VST3PlugIn:
  465. case ProjectType::Target::AAXPlugIn:
  466. case ProjectType::Target::RTASPlugIn:
  467. case ProjectType::Target::DynamicLibrary:
  468. return true;
  469. default:
  470. break;
  471. }
  472. return false;
  473. }
  474. //==============================================================================
  475. const String& getProjectName() const { return projectName; }
  476. virtual int getVisualStudioVersion() const = 0;
  477. bool launchProject() override
  478. {
  479. #if JUCE_WINDOWS
  480. return getSLNFile().startAsProcess();
  481. #else
  482. return false;
  483. #endif
  484. }
  485. bool canLaunchProject() override
  486. {
  487. #if JUCE_WINDOWS
  488. return true;
  489. #else
  490. return false;
  491. #endif
  492. }
  493. void createExporterProperties (PropertyListBuilder&) override
  494. {
  495. }
  496. enum OptimisationLevel
  497. {
  498. optimisationOff = 1,
  499. optimiseMinSize = 2,
  500. optimiseMaxSpeed = 3
  501. };
  502. //==============================================================================
  503. void addPlatformSpecificSettingsForProjectType (const ProjectType& type) override
  504. {
  505. msvcExtraPreprocessorDefs.set ("_CRT_SECURE_NO_WARNINGS", "");
  506. if (type.isCommandLineApp())
  507. msvcExtraPreprocessorDefs.set("_CONSOLE", "");
  508. }
  509. const MSVCTargetBase* getSharedCodeTarget() const
  510. {
  511. for (auto target : targets)
  512. if (target->type == ProjectType::Target::SharedCodeTarget)
  513. return target;
  514. return nullptr;
  515. }
  516. bool hasTarget (ProjectType::Target::Type type) const
  517. {
  518. for (auto target : targets)
  519. if (target->type == type)
  520. return true;
  521. return false;
  522. }
  523. private:
  524. //==============================================================================
  525. String createRebasedPath (const RelativePath& path) const
  526. {
  527. String rebasedPath = rebaseFromProjectFolderToBuildTarget (path).toWindowsStyle();
  528. return getVisualStudioVersion() < 10 // (VS10 automatically adds escape characters to the quotes for this definition)
  529. ? CppTokeniserFunctions::addEscapeChars (rebasedPath.quoted())
  530. : CppTokeniserFunctions::addEscapeChars (rebasedPath).quoted();
  531. }
  532. protected:
  533. //==============================================================================
  534. mutable File rcFile, iconFile;
  535. OwnedArray<MSVCTargetBase> targets;
  536. File getProjectFile (const String& extension, const String& target) const
  537. {
  538. String filename = project.getProjectFilenameRoot();
  539. if (target.isNotEmpty())
  540. filename += String (" - ") + target;
  541. return getTargetFolder().getChildFile (filename).withFileExtension (extension);
  542. }
  543. File getSLNFile() const { return getProjectFile (".sln", String()); }
  544. static String prependIfNotAbsolute (const String& file, const char* prefix)
  545. {
  546. if (File::isAbsolutePath (file) || file.startsWithChar ('$'))
  547. prefix = "";
  548. return prefix + FileHelpers::windowsStylePath (file);
  549. }
  550. String getIntDirFile (const BuildConfiguration& config, const String& file) const { return prependIfNotAbsolute (replacePreprocessorTokens (config, file), "$(IntDir)\\"); }
  551. String getOutDirFile (const BuildConfiguration& config, const String& file) const { return prependIfNotAbsolute (replacePreprocessorTokens (config, file), "$(OutDir)\\"); }
  552. void updateOldSettings()
  553. {
  554. {
  555. const String oldStylePrebuildCommand (getSettingString (Ids::prebuildCommand));
  556. settings.removeProperty (Ids::prebuildCommand, nullptr);
  557. if (oldStylePrebuildCommand.isNotEmpty())
  558. for (ConfigIterator config (*this); config.next();)
  559. dynamic_cast<MSVCBuildConfiguration&> (*config).getPrebuildCommand() = oldStylePrebuildCommand;
  560. }
  561. {
  562. const String oldStyleLibName (getSettingString ("libraryName_Debug"));
  563. settings.removeProperty ("libraryName_Debug", nullptr);
  564. if (oldStyleLibName.isNotEmpty())
  565. for (ConfigIterator config (*this); config.next();)
  566. if (config->isDebug())
  567. config->getTargetBinaryName() = oldStyleLibName;
  568. }
  569. {
  570. const String oldStyleLibName (getSettingString ("libraryName_Release"));
  571. settings.removeProperty ("libraryName_Release", nullptr);
  572. if (oldStyleLibName.isNotEmpty())
  573. for (ConfigIterator config (*this); config.next();)
  574. if (! config->isDebug())
  575. config->getTargetBinaryName() = oldStyleLibName;
  576. }
  577. }
  578. BuildConfiguration::Ptr createBuildConfig (const ValueTree& v) const override
  579. {
  580. return new MSVCBuildConfiguration (project, v, *this);
  581. }
  582. StringArray getHeaderSearchPaths (const BuildConfiguration& config) const
  583. {
  584. StringArray searchPaths (extraSearchPaths);
  585. searchPaths.addArray (config.getHeaderSearchPaths());
  586. return getCleanedStringArray (searchPaths);
  587. }
  588. String getSharedCodeGuid() const
  589. {
  590. String sharedCodeGuid;
  591. for (int i = 0; i < targets.size(); ++i)
  592. if (MSVCTargetBase* target = targets[i])
  593. if (target->type == ProjectType::Target::SharedCodeTarget)
  594. return target->getProjectGuid();
  595. return String();
  596. }
  597. //==============================================================================
  598. virtual void addSolutionFiles (OutputStream&, StringArray&) const
  599. {
  600. // older VS targets do not support solution files, so do nothing!
  601. }
  602. void writeProjectDependencies (OutputStream& out) const
  603. {
  604. const String sharedCodeGuid = getSharedCodeGuid();
  605. for (int i = 0; i < targets.size(); ++i)
  606. {
  607. if (MSVCTargetBase* target = targets[i])
  608. {
  609. out << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"" << projectName << " - "
  610. << target->getName() << "\", \""
  611. << target->getVCProjFile().getFileName() << "\", \"" << target->getProjectGuid() << '"' << newLine;
  612. if (sharedCodeGuid.isNotEmpty() && target->type != ProjectType::Target::SharedCodeTarget)
  613. out << "\tProjectSection(ProjectDependencies) = postProject" << newLine
  614. << "\t\t" << sharedCodeGuid << " = " << sharedCodeGuid << newLine
  615. << "\tEndProjectSection" << newLine;
  616. out << "EndProject" << newLine;
  617. }
  618. }
  619. }
  620. void writeSolutionFile (OutputStream& out, const String& versionString, String commentString) const
  621. {
  622. StringArray nestedProjects;
  623. if (commentString.isNotEmpty())
  624. commentString += newLine;
  625. out << "Microsoft Visual Studio Solution File, Format Version " << versionString << newLine
  626. << commentString << newLine;
  627. writeProjectDependencies (out);
  628. addSolutionFiles (out, nestedProjects);
  629. out << "Global" << newLine
  630. << "\tGlobalSection(SolutionConfigurationPlatforms) = preSolution" << newLine;
  631. for (ConstConfigIterator i (*this); i.next();)
  632. {
  633. const MSVCBuildConfiguration& config = dynamic_cast<const MSVCBuildConfiguration&> (*i);
  634. const String configName = config.createMSVCConfigName();
  635. out << "\t\t" << configName << " = " << configName << newLine;
  636. }
  637. out << "\tEndGlobalSection" << newLine
  638. << "\tGlobalSection(ProjectConfigurationPlatforms) = postSolution" << newLine;
  639. for (auto& target : targets)
  640. for (ConstConfigIterator i (*this); i.next();)
  641. {
  642. const MSVCBuildConfiguration& config = dynamic_cast<const MSVCBuildConfiguration&> (*i);
  643. const String configName = config.createMSVCConfigName();
  644. for (auto& suffix : { ".Build.0", ".ActiveCfg" })
  645. out << "\t\t" << target->getProjectGuid() << "." << configName << suffix << " = " << configName << newLine;
  646. }
  647. out << "\tEndGlobalSection" << newLine
  648. << "\tGlobalSection(SolutionProperties) = preSolution" << newLine
  649. << "\t\tHideSolutionNode = FALSE" << newLine
  650. << "\tEndGlobalSection" << newLine;
  651. if (nestedProjects.size() > 0)
  652. {
  653. out << "\tGlobalSection(NestedProjects) = preSolution" << newLine << "\t\t";
  654. out << nestedProjects.joinIntoString ("\n\t\t") << newLine;
  655. out << "\tEndGlobalSection" << newLine;
  656. }
  657. out << "EndGlobal" << newLine;
  658. }
  659. //==============================================================================
  660. static void writeBMPImage (const Image& image, const int w, const int h, MemoryOutputStream& out)
  661. {
  662. const int maskStride = (w / 8 + 3) & ~3;
  663. out.writeInt (40); // bitmapinfoheader size
  664. out.writeInt (w);
  665. out.writeInt (h * 2);
  666. out.writeShort (1); // planes
  667. out.writeShort (32); // bits
  668. out.writeInt (0); // compression
  669. out.writeInt ((h * w * 4) + (h * maskStride)); // size image
  670. out.writeInt (0); // x pixels per meter
  671. out.writeInt (0); // y pixels per meter
  672. out.writeInt (0); // clr used
  673. out.writeInt (0); // clr important
  674. const Image::BitmapData bitmap (image, Image::BitmapData::readOnly);
  675. const int alphaThreshold = 5;
  676. int y;
  677. for (y = h; --y >= 0;)
  678. {
  679. for (int x = 0; x < w; ++x)
  680. {
  681. const Colour pixel (bitmap.getPixelColour (x, y));
  682. if (pixel.getAlpha() <= alphaThreshold)
  683. {
  684. out.writeInt (0);
  685. }
  686. else
  687. {
  688. out.writeByte ((char) pixel.getBlue());
  689. out.writeByte ((char) pixel.getGreen());
  690. out.writeByte ((char) pixel.getRed());
  691. out.writeByte ((char) pixel.getAlpha());
  692. }
  693. }
  694. }
  695. for (y = h; --y >= 0;)
  696. {
  697. int mask = 0, count = 0;
  698. for (int x = 0; x < w; ++x)
  699. {
  700. const Colour pixel (bitmap.getPixelColour (x, y));
  701. mask <<= 1;
  702. if (pixel.getAlpha() <= alphaThreshold)
  703. mask |= 1;
  704. if (++count == 8)
  705. {
  706. out.writeByte ((char) mask);
  707. count = 0;
  708. mask = 0;
  709. }
  710. }
  711. if (mask != 0)
  712. out.writeByte ((char) mask);
  713. for (int i = maskStride - w / 8; --i >= 0;)
  714. out.writeByte (0);
  715. }
  716. }
  717. static void writeIconFile (const Array<Image>& images, MemoryOutputStream& out)
  718. {
  719. out.writeShort (0); // reserved
  720. out.writeShort (1); // .ico tag
  721. out.writeShort ((short) images.size());
  722. MemoryOutputStream dataBlock;
  723. const int imageDirEntrySize = 16;
  724. const int dataBlockStart = 6 + images.size() * imageDirEntrySize;
  725. for (int i = 0; i < images.size(); ++i)
  726. {
  727. const size_t oldDataSize = dataBlock.getDataSize();
  728. const Image& image = images.getReference (i);
  729. const int w = image.getWidth();
  730. const int h = image.getHeight();
  731. if (w >= 256 || h >= 256)
  732. {
  733. PNGImageFormat pngFormat;
  734. pngFormat.writeImageToStream (image, dataBlock);
  735. }
  736. else
  737. {
  738. writeBMPImage (image, w, h, dataBlock);
  739. }
  740. out.writeByte ((char) w);
  741. out.writeByte ((char) h);
  742. out.writeByte (0);
  743. out.writeByte (0);
  744. out.writeShort (1); // colour planes
  745. out.writeShort (32); // bits per pixel
  746. out.writeInt ((int) (dataBlock.getDataSize() - oldDataSize));
  747. out.writeInt (dataBlockStart + (int) oldDataSize);
  748. }
  749. jassert (out.getPosition() == dataBlockStart);
  750. out << dataBlock;
  751. }
  752. bool hasResourceFile() const
  753. {
  754. return ! projectType.isStaticLibrary();
  755. }
  756. void createResourcesAndIcon() const
  757. {
  758. if (hasResourceFile())
  759. {
  760. Array<Image> images;
  761. const int sizes[] = { 16, 32, 48, 256 };
  762. for (int i = 0; i < numElementsInArray (sizes); ++i)
  763. {
  764. Image im (getBestIconForSize (sizes[i], true));
  765. if (im.isValid())
  766. images.add (im);
  767. }
  768. if (images.size() > 0)
  769. {
  770. iconFile = getTargetFolder().getChildFile ("icon.ico");
  771. MemoryOutputStream mo;
  772. writeIconFile (images, mo);
  773. overwriteFileIfDifferentOrThrow (iconFile, mo);
  774. }
  775. createRCFile();
  776. }
  777. }
  778. void createRCFile() const
  779. {
  780. rcFile = getTargetFolder().getChildFile ("resources.rc");
  781. const String version (project.getVersionString());
  782. MemoryOutputStream mo;
  783. mo << "#ifdef JUCE_USER_DEFINED_RC_FILE" << newLine
  784. << " #include JUCE_USER_DEFINED_RC_FILE" << newLine
  785. << "#else" << newLine
  786. << newLine
  787. << "#undef WIN32_LEAN_AND_MEAN" << newLine
  788. << "#define WIN32_LEAN_AND_MEAN" << newLine
  789. << "#include <windows.h>" << newLine
  790. << newLine
  791. << "VS_VERSION_INFO VERSIONINFO" << newLine
  792. << "FILEVERSION " << getCommaSeparatedVersionNumber (version) << newLine
  793. << "BEGIN" << newLine
  794. << " BLOCK \"StringFileInfo\"" << newLine
  795. << " BEGIN" << newLine
  796. << " BLOCK \"040904E4\"" << newLine
  797. << " BEGIN" << newLine;
  798. writeRCValue (mo, "CompanyName", project.getCompanyName().toString());
  799. writeRCValue (mo, "FileDescription", project.getTitle());
  800. writeRCValue (mo, "FileVersion", version);
  801. writeRCValue (mo, "ProductName", project.getTitle());
  802. writeRCValue (mo, "ProductVersion", version);
  803. mo << " END" << newLine
  804. << " END" << newLine
  805. << newLine
  806. << " BLOCK \"VarFileInfo\"" << newLine
  807. << " BEGIN" << newLine
  808. << " VALUE \"Translation\", 0x409, 1252" << newLine
  809. << " END" << newLine
  810. << "END" << newLine
  811. << newLine
  812. << "#endif" << newLine;
  813. if (iconFile != File())
  814. mo << newLine
  815. << "IDI_ICON1 ICON DISCARDABLE " << iconFile.getFileName().quoted()
  816. << newLine
  817. << "IDI_ICON2 ICON DISCARDABLE " << iconFile.getFileName().quoted();
  818. overwriteFileIfDifferentOrThrow (rcFile, mo);
  819. }
  820. static void writeRCValue (MemoryOutputStream& mo, const String& name, const String& value)
  821. {
  822. if (value.isNotEmpty())
  823. mo << " VALUE \"" << name << "\", \""
  824. << CppTokeniserFunctions::addEscapeChars (value) << "\\0\"" << newLine;
  825. }
  826. static String getCommaSeparatedVersionNumber (const String& version)
  827. {
  828. StringArray versionParts;
  829. versionParts.addTokens (version, ",.", "");
  830. versionParts.trim();
  831. versionParts.removeEmptyStrings();
  832. while (versionParts.size() < 4)
  833. versionParts.add ("0");
  834. return versionParts.joinIntoString (",");
  835. }
  836. static String prependDot (const String& filename)
  837. {
  838. return FileHelpers::isAbsolutePath (filename) ? filename
  839. : (".\\" + filename);
  840. }
  841. void initialiseDependencyPathValues()
  842. {
  843. vst3Path.referTo (Value (new DependencyPathValueSource (getSetting (Ids::vst3Folder),
  844. Ids::vst3Path,
  845. TargetOS::windows)));
  846. aaxPath.referTo (Value (new DependencyPathValueSource (getSetting (Ids::aaxFolder),
  847. Ids::aaxPath,
  848. TargetOS::windows)));
  849. rtasPath.referTo (Value (new DependencyPathValueSource (getSetting (Ids::rtasFolder),
  850. Ids::rtasPath,
  851. TargetOS::windows)));
  852. }
  853. static bool shouldUseStdCall (const RelativePath& path)
  854. {
  855. return path.getFileNameWithoutExtension().startsWithIgnoreCase ("juce_audio_plugin_client_RTAS_");
  856. }
  857. StringArray getModuleLibs () const
  858. {
  859. StringArray result;
  860. for (auto& lib : windowsLibs)
  861. result.add (lib + ".lib");
  862. return result;
  863. }
  864. JUCE_DECLARE_NON_COPYABLE (MSVCProjectExporterBase)
  865. };
  866. //==============================================================================
  867. class MSVCProjectExporterVC2010 : public MSVCProjectExporterBase
  868. {
  869. public:
  870. MSVCProjectExporterVC2010 (Project& p, const ValueTree& t, const char* folderName = "VisualStudio2010")
  871. : MSVCProjectExporterBase (p, t, folderName)
  872. {
  873. name = getName();
  874. }
  875. //==============================================================================
  876. class MSVC2010Target : public MSVCTargetBase
  877. {
  878. public:
  879. MSVC2010Target (ProjectType::Target::Type targetType, const MSVCProjectExporterVC2010& exporter)
  880. : MSVCTargetBase (targetType, exporter)
  881. {}
  882. const MSVCProjectExporterVC2010& getOwner() const { return dynamic_cast<const MSVCProjectExporterVC2010&> (owner); }
  883. String getProjectVersionString() const override { return "10.00"; }
  884. String getProjectFileSuffix() const override { return ".vcxproj"; }
  885. String getTopLevelXmlEntity() const override { return "Project"; }
  886. //==============================================================================
  887. void fillInProjectXml (XmlElement& projectXml) const override
  888. {
  889. projectXml.setAttribute ("DefaultTargets", "Build");
  890. projectXml.setAttribute ("ToolsVersion", getOwner().getToolsVersion());
  891. projectXml.setAttribute ("xmlns", "http://schemas.microsoft.com/developer/msbuild/2003");
  892. {
  893. XmlElement* configsGroup = projectXml.createNewChildElement ("ItemGroup");
  894. configsGroup->setAttribute ("Label", "ProjectConfigurations");
  895. for (ConstConfigIterator i (owner); i.next();)
  896. {
  897. const MSVCBuildConfiguration& config = dynamic_cast<const MSVCBuildConfiguration&> (*i);
  898. XmlElement* e = configsGroup->createNewChildElement ("ProjectConfiguration");
  899. e->setAttribute ("Include", config.createMSVCConfigName());
  900. e->createNewChildElement ("Configuration")->addTextElement (config.getName());
  901. e->createNewChildElement ("Platform")->addTextElement (is64Bit (config) ? "x64" : "Win32");
  902. }
  903. }
  904. {
  905. XmlElement* globals = projectXml.createNewChildElement ("PropertyGroup");
  906. globals->setAttribute ("Label", "Globals");
  907. globals->createNewChildElement ("ProjectGuid")->addTextElement (getProjectGuid());
  908. }
  909. {
  910. XmlElement* imports = projectXml.createNewChildElement ("Import");
  911. imports->setAttribute ("Project", "$(VCTargetsPath)\\Microsoft.Cpp.Default.props");
  912. }
  913. for (ConstConfigIterator i (owner); i.next();)
  914. {
  915. const VC2010BuildConfiguration& config = dynamic_cast<const VC2010BuildConfiguration&> (*i);
  916. XmlElement* e = projectXml.createNewChildElement ("PropertyGroup");
  917. setConditionAttribute (*e, config);
  918. e->setAttribute ("Label", "Configuration");
  919. e->createNewChildElement ("ConfigurationType")->addTextElement (getProjectType());
  920. e->createNewChildElement ("UseOfMfc")->addTextElement ("false");
  921. const String charSet (config.getCharacterSet());
  922. if (charSet.isNotEmpty())
  923. e->createNewChildElement ("CharacterSet")->addTextElement (charSet);
  924. if (! (config.isDebug() || config.shouldDisableWholeProgramOpt()))
  925. e->createNewChildElement ("WholeProgramOptimization")->addTextElement ("true");
  926. if (config.shouldLinkIncremental())
  927. e->createNewChildElement ("LinkIncremental")->addTextElement ("true");
  928. if (config.is64Bit())
  929. e->createNewChildElement ("PlatformToolset")->addTextElement (getOwner().getPlatformToolset());
  930. }
  931. {
  932. XmlElement* e = projectXml.createNewChildElement ("Import");
  933. e->setAttribute ("Project", "$(VCTargetsPath)\\Microsoft.Cpp.props");
  934. }
  935. {
  936. XmlElement* e = projectXml.createNewChildElement ("ImportGroup");
  937. e->setAttribute ("Label", "ExtensionSettings");
  938. }
  939. {
  940. XmlElement* e = projectXml.createNewChildElement ("ImportGroup");
  941. e->setAttribute ("Label", "PropertySheets");
  942. XmlElement* p = e->createNewChildElement ("Import");
  943. p->setAttribute ("Project", "$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props");
  944. p->setAttribute ("Condition", "exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')");
  945. p->setAttribute ("Label", "LocalAppDataPlatform");
  946. }
  947. {
  948. XmlElement* e = projectXml.createNewChildElement ("PropertyGroup");
  949. e->setAttribute ("Label", "UserMacros");
  950. }
  951. {
  952. XmlElement* props = projectXml.createNewChildElement ("PropertyGroup");
  953. props->createNewChildElement ("_ProjectFileVersion")->addTextElement ("10.0.30319.1");
  954. props->createNewChildElement ("TargetExt")->addTextElement (getTargetSuffix());
  955. for (ConstConfigIterator i (owner); i.next();)
  956. {
  957. const VC2010BuildConfiguration& config = dynamic_cast<const VC2010BuildConfiguration&> (*i);
  958. if (getConfigTargetPath (config).isNotEmpty())
  959. {
  960. XmlElement* outdir = props->createNewChildElement ("OutDir");
  961. setConditionAttribute (*outdir, config);
  962. outdir->addTextElement (FileHelpers::windowsStylePath (getConfigTargetPath (config)) + "\\");
  963. }
  964. {
  965. XmlElement* intdir = props->createNewChildElement("IntDir");
  966. setConditionAttribute (*intdir, config);
  967. String intermediatesPath = getIntermediatesPath (config);
  968. if (! intermediatesPath.endsWith ("\\"))
  969. intermediatesPath << "\\";
  970. intdir->addTextElement (FileHelpers::windowsStylePath (intermediatesPath));
  971. }
  972. {
  973. XmlElement* targetName = props->createNewChildElement ("TargetName");
  974. setConditionAttribute (*targetName, config);
  975. targetName->addTextElement (config.getOutputFilename ("", false));
  976. }
  977. {
  978. XmlElement* manifest = props->createNewChildElement ("GenerateManifest");
  979. setConditionAttribute (*manifest, config);
  980. manifest->addTextElement (config.shouldGenerateManifest() ? "true" : "false");
  981. }
  982. const StringArray librarySearchPaths (getLibrarySearchPaths (config));
  983. if (librarySearchPaths.size() > 0)
  984. {
  985. XmlElement* libPath = props->createNewChildElement ("LibraryPath");
  986. setConditionAttribute (*libPath, config);
  987. libPath->addTextElement ("$(LibraryPath);" + librarySearchPaths.joinIntoString (";"));
  988. }
  989. }
  990. }
  991. for (ConstConfigIterator i (owner); i.next();)
  992. {
  993. const VC2010BuildConfiguration& config = dynamic_cast<const VC2010BuildConfiguration&> (*i);
  994. const bool isDebug = config.isDebug();
  995. XmlElement* group = projectXml.createNewChildElement ("ItemDefinitionGroup");
  996. setConditionAttribute (*group, config);
  997. {
  998. XmlElement* midl = group->createNewChildElement ("Midl");
  999. midl->createNewChildElement ("PreprocessorDefinitions")->addTextElement (isDebug ? "_DEBUG;%(PreprocessorDefinitions)"
  1000. : "NDEBUG;%(PreprocessorDefinitions)");
  1001. midl->createNewChildElement ("MkTypLibCompatible")->addTextElement ("true");
  1002. midl->createNewChildElement ("SuppressStartupBanner")->addTextElement ("true");
  1003. midl->createNewChildElement ("TargetEnvironment")->addTextElement ("Win32");
  1004. midl->createNewChildElement ("HeaderFileName");
  1005. }
  1006. bool isUsingEditAndContinue = false;
  1007. {
  1008. XmlElement* cl = group->createNewChildElement ("ClCompile");
  1009. cl->createNewChildElement ("Optimization")->addTextElement (getOptimisationLevelString (config.getOptimisationLevelInt()));
  1010. if (isDebug && config.getOptimisationLevelInt() <= optimisationOff)
  1011. {
  1012. isUsingEditAndContinue = ! config.is64Bit();
  1013. cl->createNewChildElement ("DebugInformationFormat")
  1014. ->addTextElement (isUsingEditAndContinue ? "EditAndContinue"
  1015. : "ProgramDatabase");
  1016. }
  1017. StringArray includePaths (getOwner().getHeaderSearchPaths (config));
  1018. includePaths.addArray (getExtraSearchPaths());
  1019. includePaths.add ("%(AdditionalIncludeDirectories)");
  1020. cl->createNewChildElement ("AdditionalIncludeDirectories")->addTextElement (includePaths.joinIntoString (";"));
  1021. cl->createNewChildElement ("PreprocessorDefinitions")->addTextElement (getPreprocessorDefs (config, ";") + ";%(PreprocessorDefinitions)");
  1022. const bool runtimeDLL = shouldUseRuntimeDLL (config);
  1023. cl->createNewChildElement ("RuntimeLibrary")->addTextElement (runtimeDLL ? (isDebug ? "MultiThreadedDebugDLL" : "MultiThreadedDLL")
  1024. : (isDebug ? "MultiThreadedDebug" : "MultiThreaded"));
  1025. cl->createNewChildElement ("RuntimeTypeInfo")->addTextElement ("true");
  1026. cl->createNewChildElement ("PrecompiledHeader");
  1027. cl->createNewChildElement ("AssemblerListingLocation")->addTextElement ("$(IntDir)\\");
  1028. cl->createNewChildElement ("ObjectFileName")->addTextElement ("$(IntDir)\\");
  1029. cl->createNewChildElement ("ProgramDataBaseFileName")->addTextElement ("$(IntDir)\\");
  1030. cl->createNewChildElement ("WarningLevel")->addTextElement ("Level" + String (config.getWarningLevel()));
  1031. cl->createNewChildElement ("SuppressStartupBanner")->addTextElement ("true");
  1032. cl->createNewChildElement ("MultiProcessorCompilation")->addTextElement ("true");
  1033. if (config.isFastMathEnabled())
  1034. cl->createNewChildElement ("FloatingPointModel")->addTextElement ("Fast");
  1035. const String extraFlags (getOwner().replacePreprocessorTokens (config, getOwner().getExtraCompilerFlagsString()).trim());
  1036. if (extraFlags.isNotEmpty())
  1037. cl->createNewChildElement ("AdditionalOptions")->addTextElement (extraFlags + " %(AdditionalOptions)");
  1038. if (config.areWarningsTreatedAsErrors())
  1039. cl->createNewChildElement ("TreatWarningAsError")->addTextElement ("true");
  1040. }
  1041. {
  1042. XmlElement* res = group->createNewChildElement ("ResourceCompile");
  1043. res->createNewChildElement ("PreprocessorDefinitions")->addTextElement (isDebug ? "_DEBUG;%(PreprocessorDefinitions)"
  1044. : "NDEBUG;%(PreprocessorDefinitions)");
  1045. }
  1046. {
  1047. XmlElement* link = group->createNewChildElement ("Link");
  1048. link->createNewChildElement ("OutputFile")->addTextElement (getOutputFilePath (config));
  1049. link->createNewChildElement ("SuppressStartupBanner")->addTextElement ("true");
  1050. link->createNewChildElement ("IgnoreSpecificDefaultLibraries")->addTextElement (isDebug ? "libcmt.lib; msvcrt.lib;;%(IgnoreSpecificDefaultLibraries)"
  1051. : "%(IgnoreSpecificDefaultLibraries)");
  1052. link->createNewChildElement ("GenerateDebugInformation")->addTextElement ((isDebug || config.shouldGenerateDebugSymbols()) ? "true" : "false");
  1053. link->createNewChildElement ("ProgramDatabaseFile")->addTextElement (getOwner().getIntDirFile (config, config.getOutputFilename (".pdb", true)));
  1054. link->createNewChildElement ("SubSystem")->addTextElement (type == ConsoleApp ? "Console" : "Windows");
  1055. if (! config.is64Bit())
  1056. link->createNewChildElement ("TargetMachine")->addTextElement ("MachineX86");
  1057. if (isUsingEditAndContinue)
  1058. link->createNewChildElement ("ImageHasSafeExceptionHandlers")->addTextElement ("false");
  1059. if (! isDebug)
  1060. {
  1061. link->createNewChildElement ("OptimizeReferences")->addTextElement ("true");
  1062. link->createNewChildElement ("EnableCOMDATFolding")->addTextElement ("true");
  1063. }
  1064. const StringArray librarySearchPaths (config.getLibrarySearchPaths());
  1065. if (librarySearchPaths.size() > 0)
  1066. link->createNewChildElement ("AdditionalLibraryDirectories")->addTextElement (getOwner().replacePreprocessorTokens (config, librarySearchPaths.joinIntoString (";"))
  1067. + ";%(AdditionalLibraryDirectories)");
  1068. link->createNewChildElement ("LargeAddressAware")->addTextElement ("true");
  1069. const String externalLibraries (getExternalLibraries (config, getOwner().getExternalLibrariesString()));
  1070. if (externalLibraries.isNotEmpty())
  1071. link->createNewChildElement ("AdditionalDependencies")->addTextElement (getOwner().replacePreprocessorTokens (config, externalLibraries).trim()
  1072. + ";%(AdditionalDependencies)");
  1073. String extraLinkerOptions (getOwner().getExtraLinkerFlagsString());
  1074. if (extraLinkerOptions.isNotEmpty())
  1075. link->createNewChildElement ("AdditionalOptions")->addTextElement (getOwner().replacePreprocessorTokens (config, extraLinkerOptions).trim()
  1076. + " %(AdditionalOptions)");
  1077. const String delayLoadedDLLs (getDelayLoadedDLLs());
  1078. if (delayLoadedDLLs.isNotEmpty())
  1079. link->createNewChildElement ("DelayLoadDLLs")->addTextElement (delayLoadedDLLs);
  1080. const String moduleDefinitionsFile (getModuleDefinitions (config));
  1081. if (moduleDefinitionsFile.isNotEmpty())
  1082. link->createNewChildElement ("ModuleDefinitionFile")
  1083. ->addTextElement (moduleDefinitionsFile);
  1084. }
  1085. {
  1086. XmlElement* bsc = group->createNewChildElement ("Bscmake");
  1087. bsc->createNewChildElement ("SuppressStartupBanner")->addTextElement ("true");
  1088. bsc->createNewChildElement ("OutputFile")->addTextElement (getOwner().getIntDirFile (config, config.getOutputFilename (".bsc", true)));
  1089. }
  1090. if (getTargetFileType() == staticLibrary && ! config.is64Bit())
  1091. {
  1092. XmlElement* lib = group->createNewChildElement ("Lib");
  1093. lib->createNewChildElement ("TargetMachine")->addTextElement ("MachineX86");
  1094. }
  1095. const String preBuild = getPreBuildSteps (config);
  1096. if (preBuild.isNotEmpty())
  1097. group->createNewChildElement ("PreBuildEvent")
  1098. ->createNewChildElement ("Command")
  1099. ->addTextElement (preBuild);
  1100. const String postBuild = getPostBuildSteps (config);
  1101. if (postBuild.isNotEmpty())
  1102. group->createNewChildElement ("PostBuildEvent")
  1103. ->createNewChildElement ("Command")
  1104. ->addTextElement (postBuild);
  1105. }
  1106. ScopedPointer<XmlElement> otherFilesGroup (new XmlElement ("ItemGroup"));
  1107. {
  1108. XmlElement* cppFiles = projectXml.createNewChildElement ("ItemGroup");
  1109. XmlElement* headerFiles = projectXml.createNewChildElement ("ItemGroup");
  1110. for (int i = 0; i < getOwner().getAllGroups().size(); ++i)
  1111. {
  1112. const Project::Item& group = getOwner().getAllGroups().getReference (i);
  1113. if (group.getNumChildren() > 0)
  1114. addFilesToCompile (group, *cppFiles, *headerFiles, *otherFilesGroup);
  1115. }
  1116. }
  1117. if (getOwner().iconFile != File())
  1118. {
  1119. XmlElement* e = otherFilesGroup->createNewChildElement ("None");
  1120. e->setAttribute ("Include", prependDot (getOwner().iconFile.getFileName()));
  1121. }
  1122. if (otherFilesGroup->getFirstChildElement() != nullptr)
  1123. projectXml.addChildElement (otherFilesGroup.release());
  1124. if (getOwner().hasResourceFile())
  1125. {
  1126. XmlElement* rcGroup = projectXml.createNewChildElement ("ItemGroup");
  1127. XmlElement* e = rcGroup->createNewChildElement ("ResourceCompile");
  1128. e->setAttribute ("Include", prependDot (getOwner().rcFile.getFileName()));
  1129. }
  1130. {
  1131. XmlElement* e = projectXml.createNewChildElement ("Import");
  1132. e->setAttribute ("Project", "$(VCTargetsPath)\\Microsoft.Cpp.targets");
  1133. }
  1134. {
  1135. XmlElement* e = projectXml.createNewChildElement ("ImportGroup");
  1136. e->setAttribute ("Label", "ExtensionTargets");
  1137. }
  1138. getOwner().addPlatformToolsetToPropertyGroup (projectXml);
  1139. getOwner().addIPPSettingToPropertyGroup (projectXml);
  1140. }
  1141. String getProjectType() const
  1142. {
  1143. switch (getTargetFileType())
  1144. {
  1145. case executable:
  1146. return "Application";
  1147. case staticLibrary:
  1148. return "StaticLibrary";
  1149. default:
  1150. break;
  1151. }
  1152. return "DynamicLibrary";
  1153. }
  1154. //==============================================================================
  1155. void addFilesToCompile (const Project::Item& projectItem, XmlElement& cpps, XmlElement& headers, XmlElement& otherFiles) const
  1156. {
  1157. const Type targetType = (getOwner().getProject().getProjectType().isAudioPlugin() ? type : SharedCodeTarget);
  1158. if (projectItem.isGroup())
  1159. {
  1160. for (int i = 0; i < projectItem.getNumChildren(); ++i)
  1161. addFilesToCompile (projectItem.getChild (i), cpps, headers, otherFiles);
  1162. }
  1163. else if (projectItem.shouldBeAddedToTargetProject())
  1164. {
  1165. const RelativePath path (projectItem.getFile(), getOwner().getTargetFolder(), RelativePath::buildTargetFolder);
  1166. jassert (path.getRoot() == RelativePath::buildTargetFolder);
  1167. if (projectItem.shouldBeCompiled() && (path.hasFileExtension (cOrCppFileExtensions) || path.hasFileExtension (asmFileExtensions))
  1168. && getOwner().getProject().getTargetTypeFromFilePath (projectItem.getFile(), true) == targetType)
  1169. {
  1170. XmlElement* e = cpps.createNewChildElement ("ClCompile");
  1171. e->setAttribute ("Include", path.toWindowsStyle());
  1172. if (shouldUseStdCall (path))
  1173. e->createNewChildElement ("CallingConvention")->addTextElement ("StdCall");
  1174. }
  1175. }
  1176. }
  1177. void setConditionAttribute (XmlElement& xml, const BuildConfiguration& config) const
  1178. {
  1179. const MSVCBuildConfiguration& msvcConfig = dynamic_cast<const MSVCBuildConfiguration&> (config);
  1180. xml.setAttribute ("Condition", "'$(Configuration)|$(Platform)'=='" + msvcConfig.createMSVCConfigName() + "'");
  1181. }
  1182. };
  1183. static const char* getName() { return "Visual Studio 2010"; }
  1184. static const char* getValueTreeTypeName() { return "VS2010"; }
  1185. int getVisualStudioVersion() const override { return 10; }
  1186. virtual String getSolutionComment() const { return "# Visual Studio 2010"; }
  1187. virtual String getToolsVersion() const { return "4.0"; }
  1188. virtual String getDefaultToolset() const { return "Windows7.1SDK"; }
  1189. Value getPlatformToolsetValue() { return getSetting (Ids::toolset); }
  1190. Value getIPPLibraryValue() { return getSetting (Ids::IPPLibrary); }
  1191. String getIPPLibrary() const { return settings [Ids::IPPLibrary]; }
  1192. String getPlatformToolset() const
  1193. {
  1194. const String s (settings [Ids::toolset].toString());
  1195. return s.isNotEmpty() ? s : getDefaultToolset();
  1196. }
  1197. static MSVCProjectExporterVC2010* createForSettings (Project& project, const ValueTree& settings)
  1198. {
  1199. if (settings.hasType (getValueTreeTypeName()))
  1200. return new MSVCProjectExporterVC2010 (project, settings);
  1201. return nullptr;
  1202. }
  1203. void addToolsetProperty (PropertyListBuilder& props, const char** names, const var* values, int num)
  1204. {
  1205. props.add (new ChoicePropertyComponent (getPlatformToolsetValue(), "Platform Toolset",
  1206. StringArray (names, num), Array<var> (values, num)));
  1207. }
  1208. void addIPPLibraryProperty (PropertyListBuilder& props)
  1209. {
  1210. static const char* ippOptions[] = { "No", "Yes (Default Mode)", "Multi-Threaded Static Library", "Single-Threaded Static Library", "Multi-Threaded DLL", "Single-Threaded DLL" };
  1211. static const var ippValues[] = { var(), "true", "Parallel_Static", "Sequential", "Parallel_Dynamic", "Sequential_Dynamic" };
  1212. props.add (new ChoicePropertyComponent (getIPPLibraryValue(), "Use IPP Library",
  1213. StringArray (ippOptions, numElementsInArray (ippValues)),
  1214. Array<var> (ippValues, numElementsInArray (ippValues))));
  1215. }
  1216. void createExporterProperties (PropertyListBuilder& props) override
  1217. {
  1218. MSVCProjectExporterBase::createExporterProperties (props);
  1219. static const char* toolsetNames[] = { "(default)", "v100", "v100_xp", "Windows7.1SDK", "CTP_Nov2013" };
  1220. const var toolsets[] = { var(), "v100", "v100_xp", "Windows7.1SDK", "CTP_Nov2013" };
  1221. addToolsetProperty (props, toolsetNames, toolsets, numElementsInArray (toolsets));
  1222. addIPPLibraryProperty (props);
  1223. }
  1224. //==============================================================================
  1225. void addSolutionFiles (OutputStream& out, StringArray& nestedProjects) const override
  1226. {
  1227. const bool ignoreRootGroup = (getAllGroups().size() == 1);
  1228. const int numberOfGroups = (ignoreRootGroup ? getAllGroups().getReference (0).getNumChildren()
  1229. : getAllGroups().size());
  1230. for (int i = 0; i < numberOfGroups; ++i)
  1231. {
  1232. const Project::Item& group = (ignoreRootGroup ? getAllGroups().getReference (0).getChild (i)
  1233. : getAllGroups().getReference (i));
  1234. if (group.getNumChildren() > 0)
  1235. addSolutionFiles (out, group, nestedProjects, String());
  1236. }
  1237. }
  1238. void addSolutionFiles (OutputStream& out, const Project::Item& item, StringArray& nestedProjectList, const String& parentGuid) const
  1239. {
  1240. jassert (item.isGroup());
  1241. const String groupGuid = createGUID (item.getID());
  1242. out << "Project(\"{2150E333-8FDC-42A3-9474-1A3956D46DE8}\") = \"" << item.getName() << "\""
  1243. << ", \"" << item.getName() << "\", \"" << groupGuid << "\"" << newLine;
  1244. bool hasSubFiles = false;
  1245. const int n = item.getNumChildren();
  1246. for (int i = 0; i < n; ++i)
  1247. {
  1248. const Project::Item& child = item.getChild (i);
  1249. if (child.isFile())
  1250. {
  1251. if (! hasSubFiles)
  1252. {
  1253. out << "\tProjectSection(SolutionItems) = preProject" << newLine;
  1254. hasSubFiles = true;
  1255. }
  1256. const RelativePath path = RelativePath (child.getFilePath(), RelativePath::projectFolder)
  1257. .rebased (getProject().getProjectFolder(), getSLNFile().getParentDirectory(),
  1258. RelativePath::buildTargetFolder);
  1259. out << "\t\t" << path.toWindowsStyle() << " = " << path.toWindowsStyle() << newLine;
  1260. }
  1261. }
  1262. if (hasSubFiles)
  1263. out << "\tEndProjectSection" << newLine;
  1264. out << "EndProject" << newLine;
  1265. for (int i = 0; i < n; ++i)
  1266. {
  1267. const Project::Item& child = item.getChild (i);
  1268. if (child.isGroup())
  1269. addSolutionFiles (out, child, nestedProjectList, groupGuid);
  1270. }
  1271. if (parentGuid.isNotEmpty())
  1272. nestedProjectList.add (groupGuid + String (" = ") + parentGuid);
  1273. }
  1274. //==============================================================================
  1275. void addPlatformSpecificSettingsForProjectType (const ProjectType& type) override
  1276. {
  1277. MSVCProjectExporterBase::addPlatformSpecificSettingsForProjectType (type);
  1278. callForAllSupportedTargets ([this] (ProjectType::Target::Type targetType)
  1279. {
  1280. if (MSVCTargetBase* target = new MSVC2010Target (targetType, *this))
  1281. {
  1282. if (targetType != ProjectType::Target::AggregateTarget)
  1283. targets.add (target);
  1284. }
  1285. });
  1286. // If you hit this assert, you tried to generate a project for an exporter
  1287. // that does not support any of your targets!
  1288. jassert (targets.size() > 0);
  1289. }
  1290. void create (const OwnedArray<LibraryModule>&) const override
  1291. {
  1292. createResourcesAndIcon();
  1293. for (int i = 0; i < targets.size(); ++i)
  1294. if (MSVCTargetBase* target = targets[i])
  1295. target->writeProjectFile();
  1296. {
  1297. MemoryOutputStream mo;
  1298. writeSolutionFile (mo, "11.00", getSolutionComment());
  1299. overwriteFileIfDifferentOrThrow (getSLNFile(), mo);
  1300. }
  1301. }
  1302. protected:
  1303. //==============================================================================
  1304. class VC2010BuildConfiguration : public MSVCBuildConfiguration
  1305. {
  1306. public:
  1307. VC2010BuildConfiguration (Project& p, const ValueTree& settings, const ProjectExporter& e)
  1308. : MSVCBuildConfiguration (p, settings, e)
  1309. {
  1310. if (getArchitectureType().toString().isEmpty())
  1311. getArchitectureType() = get64BitArchName();
  1312. }
  1313. //==============================================================================
  1314. static const char* get32BitArchName() { return "32-bit"; }
  1315. static const char* get64BitArchName() { return "x64"; }
  1316. Value getArchitectureType() { return getValue (Ids::winArchitecture); }
  1317. bool is64Bit() const { return config [Ids::winArchitecture].toString() == get64BitArchName(); }
  1318. Value getFastMathValue() { return getValue (Ids::fastMath); }
  1319. bool isFastMathEnabled() const { return config [Ids::fastMath]; }
  1320. //==============================================================================
  1321. void createConfigProperties (PropertyListBuilder& props) override
  1322. {
  1323. MSVCBuildConfiguration::createConfigProperties (props);
  1324. const char* const archTypes[] = { get32BitArchName(), get64BitArchName() };
  1325. props.add (new ChoicePropertyComponent (getArchitectureType(), "Architecture",
  1326. StringArray (archTypes, numElementsInArray (archTypes)),
  1327. Array<var> (archTypes, numElementsInArray (archTypes))));
  1328. props.add (new BooleanPropertyComponent (getFastMathValue(), "Relax IEEE compliance", "Enabled"),
  1329. "Enable this to use FAST_MATH non-IEEE mode. (Warning: this can have unexpected results!)");
  1330. }
  1331. };
  1332. virtual void addPlatformToolsetToPropertyGroup (XmlElement&) const {}
  1333. void addIPPSettingToPropertyGroup (XmlElement& p) const
  1334. {
  1335. String ippLibrary = getIPPLibrary();
  1336. if (ippLibrary.isNotEmpty())
  1337. forEachXmlChildElementWithTagName (p, e, "PropertyGroup")
  1338. e->createNewChildElement ("UseIntelIPP")->addTextElement (ippLibrary);
  1339. }
  1340. BuildConfiguration::Ptr createBuildConfig (const ValueTree& v) const override
  1341. {
  1342. return new VC2010BuildConfiguration (project, v, *this);
  1343. }
  1344. static bool is64Bit (const BuildConfiguration& config)
  1345. {
  1346. return dynamic_cast<const VC2010BuildConfiguration&> (config).is64Bit();
  1347. }
  1348. //==============================================================================
  1349. File getVCProjFile() const { return getProjectFile (".vcxproj", "App"); }
  1350. File getVCProjFiltersFile() const { return getProjectFile (".vcxproj.filters", String()); }
  1351. JUCE_DECLARE_NON_COPYABLE (MSVCProjectExporterVC2010)
  1352. };
  1353. //==============================================================================
  1354. class MSVCProjectExporterVC2012 : public MSVCProjectExporterVC2010
  1355. {
  1356. public:
  1357. MSVCProjectExporterVC2012 (Project& p, const ValueTree& t,
  1358. const char* folderName = "VisualStudio2012")
  1359. : MSVCProjectExporterVC2010 (p, t, folderName)
  1360. {
  1361. name = getName();
  1362. }
  1363. static const char* getName() { return "Visual Studio 2012"; }
  1364. static const char* getValueTreeTypeName() { return "VS2012"; }
  1365. int getVisualStudioVersion() const override { return 11; }
  1366. String getSolutionComment() const override { return "# Visual Studio 2012"; }
  1367. String getDefaultToolset() const override { return "v110"; }
  1368. static MSVCProjectExporterVC2012* createForSettings (Project& project, const ValueTree& settings)
  1369. {
  1370. if (settings.hasType (getValueTreeTypeName()))
  1371. return new MSVCProjectExporterVC2012 (project, settings);
  1372. return nullptr;
  1373. }
  1374. void createExporterProperties (PropertyListBuilder& props) override
  1375. {
  1376. MSVCProjectExporterBase::createExporterProperties (props);
  1377. static const char* toolsetNames[] = { "(default)", "v110", "v110_xp", "Windows7.1SDK", "CTP_Nov2013" };
  1378. const var toolsets[] = { var(), "v110", "v110_xp", "Windows7.1SDK", "CTP_Nov2013" };
  1379. addToolsetProperty (props, toolsetNames, toolsets, numElementsInArray (toolsets));
  1380. addIPPLibraryProperty (props);
  1381. }
  1382. private:
  1383. void addPlatformToolsetToPropertyGroup (XmlElement& p) const override
  1384. {
  1385. forEachXmlChildElementWithTagName (p, e, "PropertyGroup")
  1386. e->createNewChildElement ("PlatformToolset")->addTextElement (getPlatformToolset());
  1387. }
  1388. JUCE_DECLARE_NON_COPYABLE (MSVCProjectExporterVC2012)
  1389. };
  1390. //==============================================================================
  1391. class MSVCProjectExporterVC2013 : public MSVCProjectExporterVC2012
  1392. {
  1393. public:
  1394. MSVCProjectExporterVC2013 (Project& p, const ValueTree& t)
  1395. : MSVCProjectExporterVC2012 (p, t, "VisualStudio2013")
  1396. {
  1397. name = getName();
  1398. }
  1399. static const char* getName() { return "Visual Studio 2013"; }
  1400. static const char* getValueTreeTypeName() { return "VS2013"; }
  1401. int getVisualStudioVersion() const override { return 12; }
  1402. String getSolutionComment() const override { return "# Visual Studio 2013"; }
  1403. String getToolsVersion() const override { return "12.0"; }
  1404. String getDefaultToolset() const override { return "v120"; }
  1405. static MSVCProjectExporterVC2013* createForSettings (Project& project, const ValueTree& settings)
  1406. {
  1407. if (settings.hasType (getValueTreeTypeName()))
  1408. return new MSVCProjectExporterVC2013 (project, settings);
  1409. return nullptr;
  1410. }
  1411. void createExporterProperties (PropertyListBuilder& props) override
  1412. {
  1413. MSVCProjectExporterBase::createExporterProperties (props);
  1414. static const char* toolsetNames[] = { "(default)", "v120", "v120_xp", "Windows7.1SDK", "CTP_Nov2013" };
  1415. const var toolsets[] = { var(), "v120", "v120_xp", "Windows7.1SDK", "CTP_Nov2013" };
  1416. addToolsetProperty (props, toolsetNames, toolsets, numElementsInArray (toolsets));
  1417. addIPPLibraryProperty (props);
  1418. }
  1419. JUCE_DECLARE_NON_COPYABLE (MSVCProjectExporterVC2013)
  1420. };
  1421. //==============================================================================
  1422. class MSVCProjectExporterVC2015 : public MSVCProjectExporterVC2012
  1423. {
  1424. public:
  1425. MSVCProjectExporterVC2015 (Project& p, const ValueTree& t)
  1426. : MSVCProjectExporterVC2012 (p, t, "VisualStudio2015")
  1427. {
  1428. name = getName();
  1429. }
  1430. static const char* getName() { return "Visual Studio 2015"; }
  1431. static const char* getValueTreeTypeName() { return "VS2015"; }
  1432. int getVisualStudioVersion() const override { return 14; }
  1433. String getSolutionComment() const override { return "# Visual Studio 2015"; }
  1434. String getToolsVersion() const override { return "14.0"; }
  1435. String getDefaultToolset() const override { return "v140"; }
  1436. static MSVCProjectExporterVC2015* createForSettings (Project& project, const ValueTree& settings)
  1437. {
  1438. if (settings.hasType (getValueTreeTypeName()))
  1439. return new MSVCProjectExporterVC2015 (project, settings);
  1440. return nullptr;
  1441. }
  1442. void createExporterProperties (PropertyListBuilder& props) override
  1443. {
  1444. MSVCProjectExporterBase::createExporterProperties (props);
  1445. static const char* toolsetNames[] = { "(default)", "v140", "v140_xp", "CTP_Nov2013" };
  1446. const var toolsets[] = { var(), "v140", "v140_xp", "CTP_Nov2013" };
  1447. addToolsetProperty (props, toolsetNames, toolsets, numElementsInArray (toolsets));
  1448. addIPPLibraryProperty (props);
  1449. }
  1450. JUCE_DECLARE_NON_COPYABLE (MSVCProjectExporterVC2015)
  1451. };