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.

1860 lines
85KB

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