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.

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