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.

1894 lines
84KB

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