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.

1793 lines
79KB

  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. bool shouldUseRuntimeDLL (const MSVCBuildConfiguration& config) const
  409. {
  410. return (config.config [Ids::useRuntimeLibDLL].isVoid() ? (getOwner().hasTarget (AAXPlugIn) || getOwner().hasTarget (RTASPlugIn))
  411. : config.isUsingRuntimeLibDLL());
  412. }
  413. virtual String getProjectFileSuffix() const = 0;
  414. File getVCProjFile() const { return getOwner().getProjectFile (getProjectFileSuffix(), getName()); }
  415. String createRebasedPath (const RelativePath& path) const { return getOwner().createRebasedPath (path); }
  416. //==============================================================================
  417. virtual String getProjectVersionString() const = 0;
  418. protected:
  419. const MSVCProjectExporterBase& owner;
  420. String projectGuid;
  421. };
  422. //==============================================================================
  423. bool usesMMFiles() const override { return false; }
  424. bool canCopeWithDuplicateFiles() override { return false; }
  425. bool supportsUserDefinedConfigurations() const override { return true; }
  426. bool isXcode() const override { return false; }
  427. bool isVisualStudio() const override { return true; }
  428. bool isCodeBlocks() const override { return false; }
  429. bool isMakefile() const override { return false; }
  430. bool isAndroidStudio() const override { return false; }
  431. bool isAndroid() const override { return false; }
  432. bool isWindows() const override { return true; }
  433. bool isLinux() const override { return false; }
  434. bool isOSX() const override { return false; }
  435. bool isiOS() const override { return false; }
  436. bool supportsTargetType (ProjectType::Target::Type type) const override
  437. {
  438. switch (type)
  439. {
  440. case ProjectType::Target::StandalonePlugIn:
  441. case ProjectType::Target::GUIApp:
  442. case ProjectType::Target::ConsoleApp:
  443. case ProjectType::Target::StaticLibrary:
  444. case ProjectType::Target::SharedCodeTarget:
  445. case ProjectType::Target::AggregateTarget:
  446. case ProjectType::Target::VSTPlugIn:
  447. case ProjectType::Target::VST3PlugIn:
  448. case ProjectType::Target::AAXPlugIn:
  449. case ProjectType::Target::RTASPlugIn:
  450. case ProjectType::Target::DynamicLibrary:
  451. return true;
  452. default:
  453. break;
  454. }
  455. return false;
  456. }
  457. //==============================================================================
  458. const String& getProjectName() const { return projectName; }
  459. virtual int getVisualStudioVersion() const = 0;
  460. bool launchProject() override
  461. {
  462. #if JUCE_WINDOWS
  463. return getSLNFile().startAsProcess();
  464. #else
  465. return false;
  466. #endif
  467. }
  468. bool canLaunchProject() override
  469. {
  470. #if JUCE_WINDOWS
  471. return true;
  472. #else
  473. return false;
  474. #endif
  475. }
  476. void createExporterProperties (PropertyListBuilder&) override
  477. {
  478. }
  479. enum OptimisationLevel
  480. {
  481. optimisationOff = 1,
  482. optimiseMinSize = 2,
  483. optimiseMaxSpeed = 3
  484. };
  485. //==============================================================================
  486. void addPlatformSpecificSettingsForProjectType (const ProjectType& type) override
  487. {
  488. msvcExtraPreprocessorDefs.set ("_CRT_SECURE_NO_WARNINGS", "");
  489. if (type.isCommandLineApp())
  490. msvcExtraPreprocessorDefs.set("_CONSOLE", "");
  491. }
  492. const MSVCTargetBase* getSharedCodeTarget() const
  493. {
  494. for (auto target : targets)
  495. if (target->type == ProjectType::Target::SharedCodeTarget)
  496. return target;
  497. return nullptr;
  498. }
  499. bool hasTarget (ProjectType::Target::Type type) const
  500. {
  501. for (auto target : targets)
  502. if (target->type == type)
  503. return true;
  504. return false;
  505. }
  506. private:
  507. //==============================================================================
  508. String createRebasedPath (const RelativePath& path) const
  509. {
  510. String rebasedPath = rebaseFromProjectFolderToBuildTarget (path).toWindowsStyle();
  511. return getVisualStudioVersion() < 10 // (VS10 automatically adds escape characters to the quotes for this definition)
  512. ? CppTokeniserFunctions::addEscapeChars (rebasedPath.quoted())
  513. : CppTokeniserFunctions::addEscapeChars (rebasedPath).quoted();
  514. }
  515. protected:
  516. //==============================================================================
  517. mutable File rcFile, iconFile;
  518. OwnedArray<MSVCTargetBase> targets;
  519. File getProjectFile (const String& extension, const String& target) const
  520. {
  521. String filename = project.getProjectFilenameRoot();
  522. if (target.isNotEmpty())
  523. filename += String (" (") + target + String (")");
  524. return getTargetFolder().getChildFile (filename).withFileExtension (extension);
  525. }
  526. File getSLNFile() const { return getProjectFile (".sln", String()); }
  527. static String prependIfNotAbsolute (const String& file, const char* prefix)
  528. {
  529. if (File::isAbsolutePath (file) || file.startsWithChar ('$'))
  530. prefix = "";
  531. return prefix + FileHelpers::windowsStylePath (file);
  532. }
  533. String getIntDirFile (const BuildConfiguration& config, const String& file) const { return prependIfNotAbsolute (replacePreprocessorTokens (config, file), "$(IntDir)\\"); }
  534. String getOutDirFile (const BuildConfiguration& config, const String& file) const { return prependIfNotAbsolute (replacePreprocessorTokens (config, file), "$(OutDir)\\"); }
  535. void updateOldSettings()
  536. {
  537. {
  538. const String oldStylePrebuildCommand (getSettingString (Ids::prebuildCommand));
  539. settings.removeProperty (Ids::prebuildCommand, nullptr);
  540. if (oldStylePrebuildCommand.isNotEmpty())
  541. for (ConfigIterator config (*this); config.next();)
  542. dynamic_cast<MSVCBuildConfiguration&> (*config).getPrebuildCommand() = oldStylePrebuildCommand;
  543. }
  544. {
  545. const String oldStyleLibName (getSettingString ("libraryName_Debug"));
  546. settings.removeProperty ("libraryName_Debug", nullptr);
  547. if (oldStyleLibName.isNotEmpty())
  548. for (ConfigIterator config (*this); config.next();)
  549. if (config->isDebug())
  550. config->getTargetBinaryName() = oldStyleLibName;
  551. }
  552. {
  553. const String oldStyleLibName (getSettingString ("libraryName_Release"));
  554. settings.removeProperty ("libraryName_Release", nullptr);
  555. if (oldStyleLibName.isNotEmpty())
  556. for (ConfigIterator config (*this); config.next();)
  557. if (! config->isDebug())
  558. config->getTargetBinaryName() = oldStyleLibName;
  559. }
  560. }
  561. BuildConfiguration::Ptr createBuildConfig (const ValueTree& v) const override
  562. {
  563. return new MSVCBuildConfiguration (project, v, *this);
  564. }
  565. StringArray getHeaderSearchPaths (const BuildConfiguration& config) const
  566. {
  567. StringArray searchPaths (extraSearchPaths);
  568. searchPaths.addArray (config.getHeaderSearchPaths());
  569. return getCleanedStringArray (searchPaths);
  570. }
  571. String getSharedCodeGuid() const
  572. {
  573. String sharedCodeGuid;
  574. for (int i = 0; i < targets.size(); ++i)
  575. if (MSVCTargetBase* target = targets[i])
  576. if (target->type == ProjectType::Target::SharedCodeTarget)
  577. return target->getProjectGuid();
  578. return String();
  579. }
  580. //==============================================================================
  581. virtual void addSolutionFiles (OutputStream&, StringArray&) const
  582. {
  583. // older VS targets do not support solution files, so do nothing!
  584. }
  585. void writeProjectDependencies (OutputStream& out) const
  586. {
  587. const String sharedCodeGuid = getSharedCodeGuid();
  588. for (int i = 0; i < targets.size(); ++i)
  589. {
  590. if (MSVCTargetBase* target = targets[i])
  591. {
  592. out << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"" << projectName << " ("
  593. << target->getName() << ")\", \""
  594. << target->getVCProjFile().getFileName() << "\", \"" << target->getProjectGuid() << '"' << newLine;
  595. if (sharedCodeGuid.isNotEmpty() && target->type != ProjectType::Target::SharedCodeTarget)
  596. out << "\tProjectSection(ProjectDependencies) = postProject" << newLine
  597. << "\t\t" << sharedCodeGuid << " = " << sharedCodeGuid << newLine
  598. << "\tEndProjectSection" << newLine;
  599. out << "EndProject" << newLine;
  600. }
  601. }
  602. }
  603. void writeSolutionFile (OutputStream& out, const String& versionString, String commentString) const
  604. {
  605. StringArray nestedProjects;
  606. if (commentString.isNotEmpty())
  607. commentString += newLine;
  608. out << "Microsoft Visual Studio Solution File, Format Version " << versionString << newLine
  609. << commentString << newLine;
  610. writeProjectDependencies (out);
  611. addSolutionFiles (out, nestedProjects);
  612. out << "Global" << newLine
  613. << "\tGlobalSection(SolutionConfigurationPlatforms) = preSolution" << newLine;
  614. for (ConstConfigIterator i (*this); i.next();)
  615. {
  616. const MSVCBuildConfiguration& config = dynamic_cast<const MSVCBuildConfiguration&> (*i);
  617. const String configName = config.createMSVCConfigName();
  618. out << "\t\t" << configName << " = " << configName << newLine;
  619. }
  620. out << "\tEndGlobalSection" << newLine
  621. << "\tGlobalSection(ProjectConfigurationPlatforms) = postSolution" << newLine;
  622. for (auto& target : targets)
  623. for (ConstConfigIterator i (*this); i.next();)
  624. {
  625. const MSVCBuildConfiguration& config = dynamic_cast<const MSVCBuildConfiguration&> (*i);
  626. const String configName = config.createMSVCConfigName();
  627. for (auto& suffix : { ".Build.0", ".ActiveCfg" })
  628. out << "\t\t" << target->getProjectGuid() << "." << configName << suffix << " = " << configName << newLine;
  629. }
  630. out << "\tEndGlobalSection" << newLine
  631. << "\tGlobalSection(SolutionProperties) = preSolution" << newLine
  632. << "\t\tHideSolutionNode = FALSE" << newLine
  633. << "\tEndGlobalSection" << newLine;
  634. if (nestedProjects.size() > 0)
  635. {
  636. out << "\tGlobalSection(NestedProjects) = preSolution" << newLine << "\t\t";
  637. out << nestedProjects.joinIntoString ("\n\t\t") << newLine;
  638. out << "\tEndGlobalSection" << newLine;
  639. }
  640. out << "EndGlobal" << newLine;
  641. }
  642. //==============================================================================
  643. static void writeBMPImage (const Image& image, const int w, const int h, MemoryOutputStream& out)
  644. {
  645. const int maskStride = (w / 8 + 3) & ~3;
  646. out.writeInt (40); // bitmapinfoheader size
  647. out.writeInt (w);
  648. out.writeInt (h * 2);
  649. out.writeShort (1); // planes
  650. out.writeShort (32); // bits
  651. out.writeInt (0); // compression
  652. out.writeInt ((h * w * 4) + (h * maskStride)); // size image
  653. out.writeInt (0); // x pixels per meter
  654. out.writeInt (0); // y pixels per meter
  655. out.writeInt (0); // clr used
  656. out.writeInt (0); // clr important
  657. const Image::BitmapData bitmap (image, Image::BitmapData::readOnly);
  658. const int alphaThreshold = 5;
  659. int y;
  660. for (y = h; --y >= 0;)
  661. {
  662. for (int x = 0; x < w; ++x)
  663. {
  664. const Colour pixel (bitmap.getPixelColour (x, y));
  665. if (pixel.getAlpha() <= alphaThreshold)
  666. {
  667. out.writeInt (0);
  668. }
  669. else
  670. {
  671. out.writeByte ((char) pixel.getBlue());
  672. out.writeByte ((char) pixel.getGreen());
  673. out.writeByte ((char) pixel.getRed());
  674. out.writeByte ((char) pixel.getAlpha());
  675. }
  676. }
  677. }
  678. for (y = h; --y >= 0;)
  679. {
  680. int mask = 0, count = 0;
  681. for (int x = 0; x < w; ++x)
  682. {
  683. const Colour pixel (bitmap.getPixelColour (x, y));
  684. mask <<= 1;
  685. if (pixel.getAlpha() <= alphaThreshold)
  686. mask |= 1;
  687. if (++count == 8)
  688. {
  689. out.writeByte ((char) mask);
  690. count = 0;
  691. mask = 0;
  692. }
  693. }
  694. if (mask != 0)
  695. out.writeByte ((char) mask);
  696. for (int i = maskStride - w / 8; --i >= 0;)
  697. out.writeByte (0);
  698. }
  699. }
  700. static void writeIconFile (const Array<Image>& images, MemoryOutputStream& out)
  701. {
  702. out.writeShort (0); // reserved
  703. out.writeShort (1); // .ico tag
  704. out.writeShort ((short) images.size());
  705. MemoryOutputStream dataBlock;
  706. const int imageDirEntrySize = 16;
  707. const int dataBlockStart = 6 + images.size() * imageDirEntrySize;
  708. for (int i = 0; i < images.size(); ++i)
  709. {
  710. const size_t oldDataSize = dataBlock.getDataSize();
  711. const Image& image = images.getReference (i);
  712. const int w = image.getWidth();
  713. const int h = image.getHeight();
  714. if (w >= 256 || h >= 256)
  715. {
  716. PNGImageFormat pngFormat;
  717. pngFormat.writeImageToStream (image, dataBlock);
  718. }
  719. else
  720. {
  721. writeBMPImage (image, w, h, dataBlock);
  722. }
  723. out.writeByte ((char) w);
  724. out.writeByte ((char) h);
  725. out.writeByte (0);
  726. out.writeByte (0);
  727. out.writeShort (1); // colour planes
  728. out.writeShort (32); // bits per pixel
  729. out.writeInt ((int) (dataBlock.getDataSize() - oldDataSize));
  730. out.writeInt (dataBlockStart + (int) oldDataSize);
  731. }
  732. jassert (out.getPosition() == dataBlockStart);
  733. out << dataBlock;
  734. }
  735. bool hasResourceFile() const
  736. {
  737. return ! projectType.isStaticLibrary();
  738. }
  739. void createResourcesAndIcon() const
  740. {
  741. if (hasResourceFile())
  742. {
  743. Array<Image> images;
  744. const int sizes[] = { 16, 32, 48, 256 };
  745. for (int i = 0; i < numElementsInArray (sizes); ++i)
  746. {
  747. Image im (getBestIconForSize (sizes[i], true));
  748. if (im.isValid())
  749. images.add (im);
  750. }
  751. if (images.size() > 0)
  752. {
  753. iconFile = getTargetFolder().getChildFile ("icon.ico");
  754. MemoryOutputStream mo;
  755. writeIconFile (images, mo);
  756. overwriteFileIfDifferentOrThrow (iconFile, mo);
  757. }
  758. createRCFile();
  759. }
  760. }
  761. void createRCFile() const
  762. {
  763. rcFile = getTargetFolder().getChildFile ("resources.rc");
  764. const String version (project.getVersionString());
  765. MemoryOutputStream mo;
  766. mo << "#ifdef JUCE_USER_DEFINED_RC_FILE" << newLine
  767. << " #include JUCE_USER_DEFINED_RC_FILE" << newLine
  768. << "#else" << newLine
  769. << newLine
  770. << "#undef WIN32_LEAN_AND_MEAN" << newLine
  771. << "#define WIN32_LEAN_AND_MEAN" << newLine
  772. << "#include <windows.h>" << newLine
  773. << newLine
  774. << "VS_VERSION_INFO VERSIONINFO" << newLine
  775. << "FILEVERSION " << getCommaSeparatedVersionNumber (version) << newLine
  776. << "BEGIN" << newLine
  777. << " BLOCK \"StringFileInfo\"" << newLine
  778. << " BEGIN" << newLine
  779. << " BLOCK \"040904E4\"" << newLine
  780. << " BEGIN" << newLine;
  781. writeRCValue (mo, "CompanyName", project.getCompanyName().toString());
  782. writeRCValue (mo, "FileDescription", project.getTitle());
  783. writeRCValue (mo, "FileVersion", version);
  784. writeRCValue (mo, "ProductName", project.getTitle());
  785. writeRCValue (mo, "ProductVersion", version);
  786. mo << " END" << newLine
  787. << " END" << newLine
  788. << newLine
  789. << " BLOCK \"VarFileInfo\"" << newLine
  790. << " BEGIN" << newLine
  791. << " VALUE \"Translation\", 0x409, 1252" << newLine
  792. << " END" << newLine
  793. << "END" << newLine
  794. << newLine
  795. << "#endif" << newLine;
  796. if (iconFile != File())
  797. mo << newLine
  798. << "IDI_ICON1 ICON DISCARDABLE " << iconFile.getFileName().quoted()
  799. << newLine
  800. << "IDI_ICON2 ICON DISCARDABLE " << iconFile.getFileName().quoted();
  801. overwriteFileIfDifferentOrThrow (rcFile, mo);
  802. }
  803. static void writeRCValue (MemoryOutputStream& mo, const String& name, const String& value)
  804. {
  805. if (value.isNotEmpty())
  806. mo << " VALUE \"" << name << "\", \""
  807. << CppTokeniserFunctions::addEscapeChars (value) << "\\0\"" << newLine;
  808. }
  809. static String getCommaSeparatedVersionNumber (const String& version)
  810. {
  811. StringArray versionParts;
  812. versionParts.addTokens (version, ",.", "");
  813. versionParts.trim();
  814. versionParts.removeEmptyStrings();
  815. while (versionParts.size() < 4)
  816. versionParts.add ("0");
  817. return versionParts.joinIntoString (",");
  818. }
  819. static String prependDot (const String& filename)
  820. {
  821. return FileHelpers::isAbsolutePath (filename) ? filename
  822. : (".\\" + filename);
  823. }
  824. void initialiseDependencyPathValues()
  825. {
  826. vst3Path.referTo (Value (new DependencyPathValueSource (getSetting (Ids::vst3Folder),
  827. Ids::vst3Path,
  828. TargetOS::windows)));
  829. aaxPath.referTo (Value (new DependencyPathValueSource (getSetting (Ids::aaxFolder),
  830. Ids::aaxPath,
  831. TargetOS::windows)));
  832. rtasPath.referTo (Value (new DependencyPathValueSource (getSetting (Ids::rtasFolder),
  833. Ids::rtasPath,
  834. TargetOS::windows)));
  835. }
  836. static bool shouldUseStdCall (const RelativePath& path)
  837. {
  838. return path.getFileNameWithoutExtension().startsWithIgnoreCase ("juce_audio_plugin_client_RTAS_");
  839. }
  840. StringArray getModuleLibs () const
  841. {
  842. StringArray result;
  843. for (auto& lib : windowsLibs)
  844. result.add (lib + ".lib");
  845. return result;
  846. }
  847. JUCE_DECLARE_NON_COPYABLE (MSVCProjectExporterBase)
  848. };
  849. //==============================================================================
  850. class MSVCProjectExporterVC2010 : public MSVCProjectExporterBase
  851. {
  852. public:
  853. MSVCProjectExporterVC2010 (Project& p, const ValueTree& t, const char* folderName = "VisualStudio2010")
  854. : MSVCProjectExporterBase (p, t, folderName)
  855. {
  856. name = getName();
  857. }
  858. //==============================================================================
  859. class MSVC2010Target : public MSVCTargetBase
  860. {
  861. public:
  862. MSVC2010Target (ProjectType::Target::Type targetType, const MSVCProjectExporterVC2010& exporter)
  863. : MSVCTargetBase (targetType, exporter)
  864. {}
  865. const MSVCProjectExporterVC2010& getOwner() const { return dynamic_cast<const MSVCProjectExporterVC2010&> (owner); }
  866. String getProjectVersionString() const override { return "10.00"; }
  867. String getProjectFileSuffix() const override { return ".vcxproj"; }
  868. String getTopLevelXmlEntity() const override { return "Project"; }
  869. //==============================================================================
  870. void fillInProjectXml (XmlElement& projectXml) const override
  871. {
  872. projectXml.setAttribute ("DefaultTargets", "Build");
  873. projectXml.setAttribute ("ToolsVersion", getOwner().getToolsVersion());
  874. projectXml.setAttribute ("xmlns", "http://schemas.microsoft.com/developer/msbuild/2003");
  875. {
  876. XmlElement* configsGroup = projectXml.createNewChildElement ("ItemGroup");
  877. configsGroup->setAttribute ("Label", "ProjectConfigurations");
  878. for (ConstConfigIterator i (owner); i.next();)
  879. {
  880. const MSVCBuildConfiguration& config = dynamic_cast<const MSVCBuildConfiguration&> (*i);
  881. XmlElement* e = configsGroup->createNewChildElement ("ProjectConfiguration");
  882. e->setAttribute ("Include", config.createMSVCConfigName());
  883. e->createNewChildElement ("Configuration")->addTextElement (config.getName());
  884. e->createNewChildElement ("Platform")->addTextElement (is64Bit (config) ? "x64" : "Win32");
  885. }
  886. }
  887. {
  888. XmlElement* globals = projectXml.createNewChildElement ("PropertyGroup");
  889. globals->setAttribute ("Label", "Globals");
  890. globals->createNewChildElement ("ProjectGuid")->addTextElement (getProjectGuid());
  891. }
  892. {
  893. XmlElement* imports = projectXml.createNewChildElement ("Import");
  894. imports->setAttribute ("Project", "$(VCTargetsPath)\\Microsoft.Cpp.Default.props");
  895. }
  896. for (ConstConfigIterator i (owner); i.next();)
  897. {
  898. const VC2010BuildConfiguration& config = dynamic_cast<const VC2010BuildConfiguration&> (*i);
  899. XmlElement* e = projectXml.createNewChildElement ("PropertyGroup");
  900. setConditionAttribute (*e, config);
  901. e->setAttribute ("Label", "Configuration");
  902. e->createNewChildElement ("ConfigurationType")->addTextElement (getProjectType());
  903. e->createNewChildElement ("UseOfMfc")->addTextElement ("false");
  904. const String charSet (config.getCharacterSet());
  905. if (charSet.isNotEmpty())
  906. e->createNewChildElement ("CharacterSet")->addTextElement (charSet);
  907. if (! (config.isDebug() || config.shouldDisableWholeProgramOpt()))
  908. e->createNewChildElement ("WholeProgramOptimization")->addTextElement ("true");
  909. if (config.shouldLinkIncremental())
  910. e->createNewChildElement ("LinkIncremental")->addTextElement ("true");
  911. if (config.is64Bit())
  912. e->createNewChildElement ("PlatformToolset")->addTextElement (getOwner().getPlatformToolset());
  913. }
  914. {
  915. XmlElement* e = projectXml.createNewChildElement ("Import");
  916. e->setAttribute ("Project", "$(VCTargetsPath)\\Microsoft.Cpp.props");
  917. }
  918. {
  919. XmlElement* e = projectXml.createNewChildElement ("ImportGroup");
  920. e->setAttribute ("Label", "ExtensionSettings");
  921. }
  922. {
  923. XmlElement* e = projectXml.createNewChildElement ("ImportGroup");
  924. e->setAttribute ("Label", "PropertySheets");
  925. XmlElement* p = e->createNewChildElement ("Import");
  926. p->setAttribute ("Project", "$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props");
  927. p->setAttribute ("Condition", "exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')");
  928. p->setAttribute ("Label", "LocalAppDataPlatform");
  929. }
  930. {
  931. XmlElement* e = projectXml.createNewChildElement ("PropertyGroup");
  932. e->setAttribute ("Label", "UserMacros");
  933. }
  934. {
  935. XmlElement* props = projectXml.createNewChildElement ("PropertyGroup");
  936. props->createNewChildElement ("_ProjectFileVersion")->addTextElement ("10.0.30319.1");
  937. props->createNewChildElement ("TargetExt")->addTextElement (getTargetSuffix());
  938. for (ConstConfigIterator i (owner); i.next();)
  939. {
  940. const VC2010BuildConfiguration& config = dynamic_cast<const VC2010BuildConfiguration&> (*i);
  941. if (getConfigTargetPath (config).isNotEmpty())
  942. {
  943. XmlElement* outdir = props->createNewChildElement ("OutDir");
  944. setConditionAttribute (*outdir, config);
  945. outdir->addTextElement (FileHelpers::windowsStylePath (getConfigTargetPath (config)) + "\\");
  946. }
  947. {
  948. XmlElement* intdir = props->createNewChildElement("IntDir");
  949. setConditionAttribute (*intdir, config);
  950. String intermediatesPath = getIntermediatesPath (config);
  951. if (! intermediatesPath.endsWith ("\\"))
  952. intermediatesPath << "\\";
  953. intdir->addTextElement (FileHelpers::windowsStylePath (intermediatesPath));
  954. }
  955. {
  956. XmlElement* targetName = props->createNewChildElement ("TargetName");
  957. setConditionAttribute (*targetName, config);
  958. targetName->addTextElement (config.getOutputFilename ("", false));
  959. }
  960. {
  961. XmlElement* manifest = props->createNewChildElement ("GenerateManifest");
  962. setConditionAttribute (*manifest, config);
  963. manifest->addTextElement (config.shouldGenerateManifest() ? "true" : "false");
  964. }
  965. const StringArray librarySearchPaths (getLibrarySearchPaths (config));
  966. if (librarySearchPaths.size() > 0)
  967. {
  968. XmlElement* libPath = props->createNewChildElement ("LibraryPath");
  969. setConditionAttribute (*libPath, config);
  970. libPath->addTextElement ("$(LibraryPath);" + librarySearchPaths.joinIntoString (";"));
  971. }
  972. }
  973. }
  974. for (ConstConfigIterator i (owner); i.next();)
  975. {
  976. const VC2010BuildConfiguration& config = dynamic_cast<const VC2010BuildConfiguration&> (*i);
  977. const bool isDebug = config.isDebug();
  978. XmlElement* group = projectXml.createNewChildElement ("ItemDefinitionGroup");
  979. setConditionAttribute (*group, config);
  980. {
  981. XmlElement* midl = group->createNewChildElement ("Midl");
  982. midl->createNewChildElement ("PreprocessorDefinitions")->addTextElement (isDebug ? "_DEBUG;%(PreprocessorDefinitions)"
  983. : "NDEBUG;%(PreprocessorDefinitions)");
  984. midl->createNewChildElement ("MkTypLibCompatible")->addTextElement ("true");
  985. midl->createNewChildElement ("SuppressStartupBanner")->addTextElement ("true");
  986. midl->createNewChildElement ("TargetEnvironment")->addTextElement ("Win32");
  987. midl->createNewChildElement ("HeaderFileName");
  988. }
  989. bool isUsingEditAndContinue = false;
  990. {
  991. XmlElement* cl = group->createNewChildElement ("ClCompile");
  992. cl->createNewChildElement ("Optimization")->addTextElement (getOptimisationLevelString (config.getOptimisationLevelInt()));
  993. if (isDebug && config.getOptimisationLevelInt() <= optimisationOff)
  994. {
  995. isUsingEditAndContinue = ! config.is64Bit();
  996. cl->createNewChildElement ("DebugInformationFormat")
  997. ->addTextElement (isUsingEditAndContinue ? "EditAndContinue"
  998. : "ProgramDatabase");
  999. }
  1000. StringArray includePaths (getOwner().getHeaderSearchPaths (config));
  1001. includePaths.addArray (getExtraSearchPaths());
  1002. includePaths.add ("%(AdditionalIncludeDirectories)");
  1003. cl->createNewChildElement ("AdditionalIncludeDirectories")->addTextElement (includePaths.joinIntoString (";"));
  1004. cl->createNewChildElement ("PreprocessorDefinitions")->addTextElement (getPreprocessorDefs (config, ";") + ";%(PreprocessorDefinitions)");
  1005. const bool runtimeDLL = shouldUseRuntimeDLL (config);
  1006. cl->createNewChildElement ("RuntimeLibrary")->addTextElement (runtimeDLL ? (isDebug ? "MultiThreadedDebugDLL" : "MultiThreadedDLL")
  1007. : (isDebug ? "MultiThreadedDebug" : "MultiThreaded"));
  1008. cl->createNewChildElement ("RuntimeTypeInfo")->addTextElement ("true");
  1009. cl->createNewChildElement ("PrecompiledHeader");
  1010. cl->createNewChildElement ("AssemblerListingLocation")->addTextElement ("$(IntDir)\\");
  1011. cl->createNewChildElement ("ObjectFileName")->addTextElement ("$(IntDir)\\");
  1012. cl->createNewChildElement ("ProgramDataBaseFileName")->addTextElement ("$(IntDir)\\");
  1013. cl->createNewChildElement ("WarningLevel")->addTextElement ("Level" + String (config.getWarningLevel()));
  1014. cl->createNewChildElement ("SuppressStartupBanner")->addTextElement ("true");
  1015. cl->createNewChildElement ("MultiProcessorCompilation")->addTextElement ("true");
  1016. if (config.isFastMathEnabled())
  1017. cl->createNewChildElement ("FloatingPointModel")->addTextElement ("Fast");
  1018. const String extraFlags (getOwner().replacePreprocessorTokens (config, getOwner().getExtraCompilerFlagsString()).trim());
  1019. if (extraFlags.isNotEmpty())
  1020. cl->createNewChildElement ("AdditionalOptions")->addTextElement (extraFlags + " %(AdditionalOptions)");
  1021. if (config.areWarningsTreatedAsErrors())
  1022. cl->createNewChildElement ("TreatWarningAsError")->addTextElement ("true");
  1023. }
  1024. {
  1025. XmlElement* res = group->createNewChildElement ("ResourceCompile");
  1026. res->createNewChildElement ("PreprocessorDefinitions")->addTextElement (isDebug ? "_DEBUG;%(PreprocessorDefinitions)"
  1027. : "NDEBUG;%(PreprocessorDefinitions)");
  1028. }
  1029. {
  1030. XmlElement* link = group->createNewChildElement ("Link");
  1031. link->createNewChildElement ("OutputFile")->addTextElement (getOutputFilePath (config));
  1032. link->createNewChildElement ("SuppressStartupBanner")->addTextElement ("true");
  1033. link->createNewChildElement ("IgnoreSpecificDefaultLibraries")->addTextElement (isDebug ? "libcmt.lib; msvcrt.lib;;%(IgnoreSpecificDefaultLibraries)"
  1034. : "%(IgnoreSpecificDefaultLibraries)");
  1035. link->createNewChildElement ("GenerateDebugInformation")->addTextElement ((isDebug || config.shouldGenerateDebugSymbols()) ? "true" : "false");
  1036. link->createNewChildElement ("ProgramDatabaseFile")->addTextElement (getOwner().getIntDirFile (config, config.getOutputFilename (".pdb", true)));
  1037. link->createNewChildElement ("SubSystem")->addTextElement (type == ConsoleApp ? "Console" : "Windows");
  1038. if (! config.is64Bit())
  1039. link->createNewChildElement ("TargetMachine")->addTextElement ("MachineX86");
  1040. if (isUsingEditAndContinue)
  1041. link->createNewChildElement ("ImageHasSafeExceptionHandlers")->addTextElement ("false");
  1042. if (! isDebug)
  1043. {
  1044. link->createNewChildElement ("OptimizeReferences")->addTextElement ("true");
  1045. link->createNewChildElement ("EnableCOMDATFolding")->addTextElement ("true");
  1046. }
  1047. const StringArray librarySearchPaths (config.getLibrarySearchPaths());
  1048. if (librarySearchPaths.size() > 0)
  1049. link->createNewChildElement ("AdditionalLibraryDirectories")->addTextElement (getOwner().replacePreprocessorTokens (config, librarySearchPaths.joinIntoString (";"))
  1050. + ";%(AdditionalLibraryDirectories)");
  1051. link->createNewChildElement ("LargeAddressAware")->addTextElement ("true");
  1052. const String externalLibraries (getExternalLibraries (config, getOwner().getExternalLibrariesString()));
  1053. if (externalLibraries.isNotEmpty())
  1054. link->createNewChildElement ("AdditionalDependencies")->addTextElement (getOwner().replacePreprocessorTokens (config, externalLibraries).trim()
  1055. + ";%(AdditionalDependencies)");
  1056. String extraLinkerOptions (getOwner().getExtraLinkerFlagsString());
  1057. if (extraLinkerOptions.isNotEmpty())
  1058. link->createNewChildElement ("AdditionalOptions")->addTextElement (getOwner().replacePreprocessorTokens (config, extraLinkerOptions).trim()
  1059. + " %(AdditionalOptions)");
  1060. const String delayLoadedDLLs (getDelayLoadedDLLs());
  1061. if (delayLoadedDLLs.isNotEmpty())
  1062. link->createNewChildElement ("DelayLoadDLLs")->addTextElement (delayLoadedDLLs);
  1063. if (config.config [Ids::msvcModuleDefinitionFile].toString().isNotEmpty())
  1064. link->createNewChildElement ("ModuleDefinitionFile")
  1065. ->addTextElement (config.config [Ids::msvcModuleDefinitionFile].toString());
  1066. }
  1067. {
  1068. XmlElement* bsc = group->createNewChildElement ("Bscmake");
  1069. bsc->createNewChildElement ("SuppressStartupBanner")->addTextElement ("true");
  1070. bsc->createNewChildElement ("OutputFile")->addTextElement (getOwner().getIntDirFile (config, config.getOutputFilename (".bsc", true)));
  1071. }
  1072. if (getTargetFileType() == staticLibrary && ! config.is64Bit())
  1073. {
  1074. XmlElement* lib = group->createNewChildElement ("Lib");
  1075. lib->createNewChildElement ("TargetMachine")->addTextElement ("MachineX86");
  1076. }
  1077. const String preBuild = getPreBuildSteps (config);
  1078. if (preBuild.isNotEmpty())
  1079. group->createNewChildElement ("PreBuildEvent")
  1080. ->createNewChildElement ("Command")
  1081. ->addTextElement (preBuild);
  1082. const String postBuild = getPostBuildSteps (config);
  1083. if (postBuild.isNotEmpty())
  1084. group->createNewChildElement ("PostBuildEvent")
  1085. ->createNewChildElement ("Command")
  1086. ->addTextElement (postBuild);
  1087. }
  1088. ScopedPointer<XmlElement> otherFilesGroup (new XmlElement ("ItemGroup"));
  1089. {
  1090. XmlElement* cppFiles = projectXml.createNewChildElement ("ItemGroup");
  1091. XmlElement* headerFiles = projectXml.createNewChildElement ("ItemGroup");
  1092. for (int i = 0; i < getOwner().getAllGroups().size(); ++i)
  1093. {
  1094. const Project::Item& group = getOwner().getAllGroups().getReference (i);
  1095. if (group.getNumChildren() > 0)
  1096. addFilesToCompile (group, *cppFiles, *headerFiles, *otherFilesGroup);
  1097. }
  1098. }
  1099. if (getOwner().iconFile != File())
  1100. {
  1101. XmlElement* e = otherFilesGroup->createNewChildElement ("None");
  1102. e->setAttribute ("Include", prependDot (getOwner().iconFile.getFileName()));
  1103. }
  1104. if (otherFilesGroup->getFirstChildElement() != nullptr)
  1105. projectXml.addChildElement (otherFilesGroup.release());
  1106. if (getOwner().hasResourceFile())
  1107. {
  1108. XmlElement* rcGroup = projectXml.createNewChildElement ("ItemGroup");
  1109. XmlElement* e = rcGroup->createNewChildElement ("ResourceCompile");
  1110. e->setAttribute ("Include", prependDot (getOwner().rcFile.getFileName()));
  1111. }
  1112. {
  1113. XmlElement* e = projectXml.createNewChildElement ("Import");
  1114. e->setAttribute ("Project", "$(VCTargetsPath)\\Microsoft.Cpp.targets");
  1115. }
  1116. {
  1117. XmlElement* e = projectXml.createNewChildElement ("ImportGroup");
  1118. e->setAttribute ("Label", "ExtensionTargets");
  1119. }
  1120. getOwner().addPlatformToolsetToPropertyGroup (projectXml);
  1121. getOwner().addIPPSettingToPropertyGroup (projectXml);
  1122. }
  1123. String getProjectType() const
  1124. {
  1125. switch (getTargetFileType())
  1126. {
  1127. case executable:
  1128. return "Application";
  1129. case staticLibrary:
  1130. return "StaticLibrary";
  1131. default:
  1132. break;
  1133. }
  1134. return "DynamicLibrary";
  1135. }
  1136. //==============================================================================
  1137. void addFilesToCompile (const Project::Item& projectItem, XmlElement& cpps, XmlElement& headers, XmlElement& otherFiles) const
  1138. {
  1139. const Type targetType = (getOwner().getProject().getProjectType().isAudioPlugin() ? type : SharedCodeTarget);
  1140. if (projectItem.isGroup())
  1141. {
  1142. for (int i = 0; i < projectItem.getNumChildren(); ++i)
  1143. addFilesToCompile (projectItem.getChild (i), cpps, headers, otherFiles);
  1144. }
  1145. else if (projectItem.shouldBeAddedToTargetProject())
  1146. {
  1147. const RelativePath path (projectItem.getFile(), getOwner().getTargetFolder(), RelativePath::buildTargetFolder);
  1148. jassert (path.getRoot() == RelativePath::buildTargetFolder);
  1149. if (projectItem.shouldBeCompiled() && (path.hasFileExtension (cOrCppFileExtensions) || path.hasFileExtension (asmFileExtensions))
  1150. && getOwner().getProject().getTargetTypeFromFilePath (projectItem.getFile(), true) == targetType)
  1151. {
  1152. XmlElement* e = cpps.createNewChildElement ("ClCompile");
  1153. e->setAttribute ("Include", path.toWindowsStyle());
  1154. if (shouldUseStdCall (path))
  1155. e->createNewChildElement ("CallingConvention")->addTextElement ("StdCall");
  1156. }
  1157. }
  1158. }
  1159. void setConditionAttribute (XmlElement& xml, const BuildConfiguration& config) const
  1160. {
  1161. const MSVCBuildConfiguration& msvcConfig = dynamic_cast<const MSVCBuildConfiguration&> (config);
  1162. xml.setAttribute ("Condition", "'$(Configuration)|$(Platform)'=='" + msvcConfig.createMSVCConfigName() + "'");
  1163. }
  1164. };
  1165. static const char* getName() { return "Visual Studio 2010"; }
  1166. static const char* getValueTreeTypeName() { return "VS2010"; }
  1167. int getVisualStudioVersion() const override { return 10; }
  1168. virtual String getSolutionComment() const { return "# Visual Studio 2010"; }
  1169. virtual String getToolsVersion() const { return "4.0"; }
  1170. virtual String getDefaultToolset() const { return "Windows7.1SDK"; }
  1171. Value getPlatformToolsetValue() { return getSetting (Ids::toolset); }
  1172. Value getIPPLibraryValue() { return getSetting (Ids::IPPLibrary); }
  1173. String getIPPLibrary() const { return settings [Ids::IPPLibrary]; }
  1174. String getPlatformToolset() const
  1175. {
  1176. const String s (settings [Ids::toolset].toString());
  1177. return s.isNotEmpty() ? s : getDefaultToolset();
  1178. }
  1179. static MSVCProjectExporterVC2010* createForSettings (Project& project, const ValueTree& settings)
  1180. {
  1181. if (settings.hasType (getValueTreeTypeName()))
  1182. return new MSVCProjectExporterVC2010 (project, settings);
  1183. return nullptr;
  1184. }
  1185. void addToolsetProperty (PropertyListBuilder& props, const char** names, const var* values, int num)
  1186. {
  1187. props.add (new ChoicePropertyComponent (getPlatformToolsetValue(), "Platform Toolset",
  1188. StringArray (names, num), Array<var> (values, num)));
  1189. }
  1190. void addIPPLibraryProperty (PropertyListBuilder& props)
  1191. {
  1192. static const char* ippOptions[] = { "No", "Yes (Default Mode)", "Multi-Threaded Static Library", "Single-Threaded Static Library", "Multi-Threaded DLL", "Single-Threaded DLL" };
  1193. static const var ippValues[] = { var(), "true", "Parallel_Static", "Sequential", "Parallel_Dynamic", "Sequential_Dynamic" };
  1194. props.add (new ChoicePropertyComponent (getIPPLibraryValue(), "Use IPP Library",
  1195. StringArray (ippOptions, numElementsInArray (ippValues)),
  1196. Array<var> (ippValues, numElementsInArray (ippValues))));
  1197. }
  1198. void createExporterProperties (PropertyListBuilder& props) override
  1199. {
  1200. MSVCProjectExporterBase::createExporterProperties (props);
  1201. static const char* toolsetNames[] = { "(default)", "v100", "v100_xp", "Windows7.1SDK", "CTP_Nov2013" };
  1202. const var toolsets[] = { var(), "v100", "v100_xp", "Windows7.1SDK", "CTP_Nov2013" };
  1203. addToolsetProperty (props, toolsetNames, toolsets, numElementsInArray (toolsets));
  1204. addIPPLibraryProperty (props);
  1205. }
  1206. //==============================================================================
  1207. void addSolutionFiles (OutputStream& out, StringArray& nestedProjects) const override
  1208. {
  1209. const bool ignoreRootGroup = (getAllGroups().size() == 1);
  1210. const int numberOfGroups = (ignoreRootGroup ? getAllGroups().getReference (0).getNumChildren()
  1211. : getAllGroups().size());
  1212. for (int i = 0; i < numberOfGroups; ++i)
  1213. {
  1214. const Project::Item& group = (ignoreRootGroup ? getAllGroups().getReference (0).getChild (i)
  1215. : getAllGroups().getReference (i));
  1216. if (group.getNumChildren() > 0)
  1217. addSolutionFiles (out, group, nestedProjects, String());
  1218. }
  1219. }
  1220. void addSolutionFiles (OutputStream& out, const Project::Item& item, StringArray& nestedProjectList, const String& parentGuid) const
  1221. {
  1222. jassert (item.isGroup());
  1223. const String groupGuid = createGUID (item.getID());
  1224. out << "Project(\"{2150E333-8FDC-42A3-9474-1A3956D46DE8}\") = \"" << item.getName() << "\""
  1225. << ", \"" << item.getName() << "\", \"" << groupGuid << "\"" << newLine;
  1226. bool hasSubFiles = false;
  1227. const int n = item.getNumChildren();
  1228. for (int i = 0; i < n; ++i)
  1229. {
  1230. const Project::Item& child = item.getChild (i);
  1231. if (child.isFile())
  1232. {
  1233. if (! hasSubFiles)
  1234. {
  1235. out << "\tProjectSection(SolutionItems) = preProject" << newLine;
  1236. hasSubFiles = true;
  1237. }
  1238. const RelativePath path = RelativePath (child.getFilePath(), RelativePath::projectFolder)
  1239. .rebased (getProject().getProjectFolder(), getSLNFile().getParentDirectory(),
  1240. RelativePath::buildTargetFolder);
  1241. out << "\t\t" << path.toWindowsStyle() << " = " << path.toWindowsStyle() << newLine;
  1242. }
  1243. }
  1244. if (hasSubFiles)
  1245. out << "\tEndProjectSection" << newLine;
  1246. out << "EndProject" << newLine;
  1247. for (int i = 0; i < n; ++i)
  1248. {
  1249. const Project::Item& child = item.getChild (i);
  1250. if (child.isGroup())
  1251. addSolutionFiles (out, child, nestedProjectList, groupGuid);
  1252. }
  1253. if (parentGuid.isNotEmpty())
  1254. nestedProjectList.add (groupGuid + String (" = ") + parentGuid);
  1255. }
  1256. //==============================================================================
  1257. void addPlatformSpecificSettingsForProjectType (const ProjectType& type) override
  1258. {
  1259. MSVCProjectExporterBase::addPlatformSpecificSettingsForProjectType (type);
  1260. callForAllSupportedTargets ([this] (ProjectType::Target::Type targetType)
  1261. {
  1262. if (MSVCTargetBase* target = new MSVC2010Target (targetType, *this))
  1263. {
  1264. if (targetType != ProjectType::Target::AggregateTarget)
  1265. targets.add (target);
  1266. }
  1267. });
  1268. // If you hit this assert, you tried to generate a project for an exporter
  1269. // that does not support any of your targets!
  1270. jassert (targets.size() > 0);
  1271. }
  1272. void create (const OwnedArray<LibraryModule>&) const override
  1273. {
  1274. createResourcesAndIcon();
  1275. for (int i = 0; i < targets.size(); ++i)
  1276. if (MSVCTargetBase* target = targets[i])
  1277. target->writeProjectFile();
  1278. {
  1279. MemoryOutputStream mo;
  1280. writeSolutionFile (mo, "11.00", getSolutionComment());
  1281. overwriteFileIfDifferentOrThrow (getSLNFile(), mo);
  1282. }
  1283. }
  1284. protected:
  1285. //==============================================================================
  1286. class VC2010BuildConfiguration : public MSVCBuildConfiguration
  1287. {
  1288. public:
  1289. VC2010BuildConfiguration (Project& p, const ValueTree& settings, const ProjectExporter& e)
  1290. : MSVCBuildConfiguration (p, settings, e)
  1291. {
  1292. if (getArchitectureType().toString().isEmpty())
  1293. getArchitectureType() = get64BitArchName();
  1294. }
  1295. //==============================================================================
  1296. static const char* get32BitArchName() { return "32-bit"; }
  1297. static const char* get64BitArchName() { return "x64"; }
  1298. Value getArchitectureType() { return getValue (Ids::winArchitecture); }
  1299. bool is64Bit() const { return config [Ids::winArchitecture].toString() == get64BitArchName(); }
  1300. Value getFastMathValue() { return getValue (Ids::fastMath); }
  1301. bool isFastMathEnabled() const { return config [Ids::fastMath]; }
  1302. //==============================================================================
  1303. void createConfigProperties (PropertyListBuilder& props) override
  1304. {
  1305. MSVCBuildConfiguration::createConfigProperties (props);
  1306. const char* const archTypes[] = { get32BitArchName(), get64BitArchName() };
  1307. props.add (new ChoicePropertyComponent (getArchitectureType(), "Architecture",
  1308. StringArray (archTypes, numElementsInArray (archTypes)),
  1309. Array<var> (archTypes, numElementsInArray (archTypes))));
  1310. props.add (new BooleanPropertyComponent (getFastMathValue(), "Relax IEEE compliance", "Enabled"),
  1311. "Enable this to use FAST_MATH non-IEEE mode. (Warning: this can have unexpected results!)");
  1312. }
  1313. };
  1314. virtual void addPlatformToolsetToPropertyGroup (XmlElement&) const {}
  1315. void addIPPSettingToPropertyGroup (XmlElement& p) const
  1316. {
  1317. String ippLibrary = getIPPLibrary();
  1318. if (ippLibrary.isNotEmpty())
  1319. forEachXmlChildElementWithTagName (p, e, "PropertyGroup")
  1320. e->createNewChildElement ("UseIntelIPP")->addTextElement (ippLibrary);
  1321. }
  1322. BuildConfiguration::Ptr createBuildConfig (const ValueTree& v) const override
  1323. {
  1324. return new VC2010BuildConfiguration (project, v, *this);
  1325. }
  1326. static bool is64Bit (const BuildConfiguration& config)
  1327. {
  1328. return dynamic_cast<const VC2010BuildConfiguration&> (config).is64Bit();
  1329. }
  1330. //==============================================================================
  1331. File getVCProjFile() const { return getProjectFile (".vcxproj", "App"); }
  1332. File getVCProjFiltersFile() const { return getProjectFile (".vcxproj.filters", String()); }
  1333. JUCE_DECLARE_NON_COPYABLE (MSVCProjectExporterVC2010)
  1334. };
  1335. //==============================================================================
  1336. class MSVCProjectExporterVC2012 : public MSVCProjectExporterVC2010
  1337. {
  1338. public:
  1339. MSVCProjectExporterVC2012 (Project& p, const ValueTree& t,
  1340. const char* folderName = "VisualStudio2012")
  1341. : MSVCProjectExporterVC2010 (p, t, folderName)
  1342. {
  1343. name = getName();
  1344. }
  1345. static const char* getName() { return "Visual Studio 2012"; }
  1346. static const char* getValueTreeTypeName() { return "VS2012"; }
  1347. int getVisualStudioVersion() const override { return 11; }
  1348. String getSolutionComment() const override { return "# Visual Studio 2012"; }
  1349. String getDefaultToolset() const override { return "v110"; }
  1350. static MSVCProjectExporterVC2012* createForSettings (Project& project, const ValueTree& settings)
  1351. {
  1352. if (settings.hasType (getValueTreeTypeName()))
  1353. return new MSVCProjectExporterVC2012 (project, settings);
  1354. return nullptr;
  1355. }
  1356. void createExporterProperties (PropertyListBuilder& props) override
  1357. {
  1358. MSVCProjectExporterBase::createExporterProperties (props);
  1359. static const char* toolsetNames[] = { "(default)", "v110", "v110_xp", "Windows7.1SDK", "CTP_Nov2013" };
  1360. const var toolsets[] = { var(), "v110", "v110_xp", "Windows7.1SDK", "CTP_Nov2013" };
  1361. addToolsetProperty (props, toolsetNames, toolsets, numElementsInArray (toolsets));
  1362. addIPPLibraryProperty (props);
  1363. }
  1364. private:
  1365. void addPlatformToolsetToPropertyGroup (XmlElement& p) const override
  1366. {
  1367. forEachXmlChildElementWithTagName (p, e, "PropertyGroup")
  1368. e->createNewChildElement ("PlatformToolset")->addTextElement (getPlatformToolset());
  1369. }
  1370. JUCE_DECLARE_NON_COPYABLE (MSVCProjectExporterVC2012)
  1371. };
  1372. //==============================================================================
  1373. class MSVCProjectExporterVC2013 : public MSVCProjectExporterVC2012
  1374. {
  1375. public:
  1376. MSVCProjectExporterVC2013 (Project& p, const ValueTree& t)
  1377. : MSVCProjectExporterVC2012 (p, t, "VisualStudio2013")
  1378. {
  1379. name = getName();
  1380. }
  1381. static const char* getName() { return "Visual Studio 2013"; }
  1382. static const char* getValueTreeTypeName() { return "VS2013"; }
  1383. int getVisualStudioVersion() const override { return 12; }
  1384. String getSolutionComment() const override { return "# Visual Studio 2013"; }
  1385. String getToolsVersion() const override { return "12.0"; }
  1386. String getDefaultToolset() const override { return "v120"; }
  1387. static MSVCProjectExporterVC2013* createForSettings (Project& project, const ValueTree& settings)
  1388. {
  1389. if (settings.hasType (getValueTreeTypeName()))
  1390. return new MSVCProjectExporterVC2013 (project, settings);
  1391. return nullptr;
  1392. }
  1393. void createExporterProperties (PropertyListBuilder& props) override
  1394. {
  1395. MSVCProjectExporterBase::createExporterProperties (props);
  1396. static const char* toolsetNames[] = { "(default)", "v120", "v120_xp", "Windows7.1SDK", "CTP_Nov2013" };
  1397. const var toolsets[] = { var(), "v120", "v120_xp", "Windows7.1SDK", "CTP_Nov2013" };
  1398. addToolsetProperty (props, toolsetNames, toolsets, numElementsInArray (toolsets));
  1399. addIPPLibraryProperty (props);
  1400. }
  1401. JUCE_DECLARE_NON_COPYABLE (MSVCProjectExporterVC2013)
  1402. };
  1403. //==============================================================================
  1404. class MSVCProjectExporterVC2015 : public MSVCProjectExporterVC2012
  1405. {
  1406. public:
  1407. MSVCProjectExporterVC2015 (Project& p, const ValueTree& t)
  1408. : MSVCProjectExporterVC2012 (p, t, "VisualStudio2015")
  1409. {
  1410. name = getName();
  1411. }
  1412. static const char* getName() { return "Visual Studio 2015"; }
  1413. static const char* getValueTreeTypeName() { return "VS2015"; }
  1414. int getVisualStudioVersion() const override { return 14; }
  1415. String getSolutionComment() const override { return "# Visual Studio 2015"; }
  1416. String getToolsVersion() const override { return "14.0"; }
  1417. String getDefaultToolset() const override { return "v140"; }
  1418. static MSVCProjectExporterVC2015* createForSettings (Project& project, const ValueTree& settings)
  1419. {
  1420. if (settings.hasType (getValueTreeTypeName()))
  1421. return new MSVCProjectExporterVC2015 (project, settings);
  1422. return nullptr;
  1423. }
  1424. void createExporterProperties (PropertyListBuilder& props) override
  1425. {
  1426. MSVCProjectExporterBase::createExporterProperties (props);
  1427. static const char* toolsetNames[] = { "(default)", "v140", "v140_xp", "CTP_Nov2013" };
  1428. const var toolsets[] = { var(), "v140", "v140_xp", "CTP_Nov2013" };
  1429. addToolsetProperty (props, toolsetNames, toolsets, numElementsInArray (toolsets));
  1430. addIPPLibraryProperty (props);
  1431. }
  1432. JUCE_DECLARE_NON_COPYABLE (MSVCProjectExporterVC2015)
  1433. };