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.

1856 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. //==============================================================================
  51. void addToolsetProperty (PropertyListBuilder& props, const char** names, const var* values, int num)
  52. {
  53. props.add (new ChoicePropertyComponent (getPlatformToolsetValue(), "Platform Toolset",
  54. StringArray (names, num), Array<var> (values, num)));
  55. }
  56. void addIPPLibraryProperty (PropertyListBuilder& props)
  57. {
  58. static const char* ippOptions[] = { "No", "Yes (Default Mode)", "Multi-Threaded Static Library", "Single-Threaded Static Library", "Multi-Threaded DLL", "Single-Threaded DLL" };
  59. static const var ippValues[] = { var(), "true", "Parallel_Static", "Sequential", "Parallel_Dynamic", "Sequential_Dynamic" };
  60. props.add (new ChoicePropertyComponent (getIPPLibraryValue(), "Use IPP Library",
  61. StringArray (ippOptions, numElementsInArray (ippValues)),
  62. Array<var> (ippValues, numElementsInArray (ippValues))));
  63. }
  64. void addWindowsTargetPlatformProperties (PropertyListBuilder& props)
  65. {
  66. static const char* targetPlatformNames[] = { "(default)", "8.1", "10.0.10240.0", "10.0.10586.0", "10.0.14393.0", "10.0.15063.0" };
  67. static const var targetPlatforms[] = { var(), "8.1", "10.0.10240.0", "10.0.10586.0", "10.0.14393.0", "10.0.15063.0" };
  68. props.add (new ChoicePropertyComponent (getWindowsTargetPlatformVersionValue(), "Windows Target Platform",
  69. StringArray (targetPlatformNames, numElementsInArray (targetPlatformNames)),
  70. Array<var> (targetPlatforms, numElementsInArray (targetPlatforms))),
  71. "Specifies the version of the Windows SDK that will be used when building this project. "
  72. "The default value for this exporter is " + getDefaultWindowsTargetPlatformVersion());
  73. }
  74. void addPlatformToolsetToPropertyGroup (XmlElement& p) const
  75. {
  76. forEachXmlChildElementWithTagName (p, e, "PropertyGroup")
  77. e->createNewChildElement ("PlatformToolset")->addTextElement (getPlatformToolset());
  78. }
  79. void addWindowsTargetPlatformVersionToPropertyGroup (XmlElement& p) const
  80. {
  81. const String& targetVersion = getWindowsTargetPlatformVersion();
  82. if (targetVersion.isNotEmpty())
  83. forEachXmlChildElementWithTagName (p, e, "PropertyGroup")
  84. e->createNewChildElement ("WindowsTargetPlatformVersion")->addTextElement (getWindowsTargetPlatformVersion());
  85. }
  86. void addIPPSettingToPropertyGroup (XmlElement& p) const
  87. {
  88. String ippLibrary = getIPPLibrary();
  89. if (ippLibrary.isNotEmpty())
  90. forEachXmlChildElementWithTagName (p, e, "PropertyGroup")
  91. e->createNewChildElement ("UseIntelIPP")->addTextElement (ippLibrary);
  92. }
  93. void create (const OwnedArray<LibraryModule>&) const override
  94. {
  95. createResourcesAndIcon();
  96. for (int i = 0; i < targets.size(); ++i)
  97. if (MSVCTargetBase* target = targets[i])
  98. target->writeProjectFile();
  99. {
  100. MemoryOutputStream mo;
  101. writeSolutionFile (mo, "11.00", getSolutionComment());
  102. overwriteFileIfDifferentOrThrow (getSLNFile(), mo);
  103. }
  104. }
  105. //==============================================================================
  106. class MSVCBuildConfiguration : public BuildConfiguration
  107. {
  108. public:
  109. MSVCBuildConfiguration (Project& p, const ValueTree& settings, const ProjectExporter& e)
  110. : BuildConfiguration (p, settings, e)
  111. {
  112. if (getWarningLevel() == 0)
  113. getWarningLevelValue() = 4;
  114. setValueIfVoid (shouldGenerateManifestValue(), true);
  115. setValueIfVoid (getArchitectureType(), get64BitArchName());
  116. }
  117. Value getWarningLevelValue() { return getValue (Ids::winWarningLevel); }
  118. int getWarningLevel() const { return config [Ids::winWarningLevel]; }
  119. Value getWarningsTreatedAsErrors() { return getValue (Ids::warningsAreErrors); }
  120. bool areWarningsTreatedAsErrors() const { return config [Ids::warningsAreErrors]; }
  121. Value getPrebuildCommand() { return getValue (Ids::prebuildCommand); }
  122. String getPrebuildCommandString() const { return config [Ids::prebuildCommand]; }
  123. Value getPostbuildCommand() { return getValue (Ids::postbuildCommand); }
  124. String getPostbuildCommandString() const { return config [Ids::postbuildCommand]; }
  125. Value shouldGenerateDebugSymbolsValue() { return getValue (Ids::alwaysGenerateDebugSymbols); }
  126. bool shouldGenerateDebugSymbols() const { return config [Ids::alwaysGenerateDebugSymbols]; }
  127. Value shouldGenerateManifestValue() { return getValue (Ids::generateManifest); }
  128. bool shouldGenerateManifest() const { return config [Ids::generateManifest]; }
  129. Value shouldLinkIncrementalValue() { return getValue (Ids::enableIncrementalLinking); }
  130. bool shouldLinkIncremental() const { return config [Ids::enableIncrementalLinking]; }
  131. Value getWholeProgramOptValue() { return getValue (Ids::wholeProgramOptimisation); }
  132. bool shouldDisableWholeProgramOpt() const { return static_cast<int> (config [Ids::wholeProgramOptimisation]) > 0; }
  133. Value getUsingRuntimeLibDLL() { return getValue (Ids::useRuntimeLibDLL); }
  134. bool isUsingRuntimeLibDLL() const { return config [Ids::useRuntimeLibDLL]; }
  135. String getIntermediatesPath() const { return config [Ids::intermediatesPath].toString(); }
  136. Value getIntermediatesPathValue() { return getValue (Ids::intermediatesPath); }
  137. String getCharacterSet() const { return config [Ids::characterSet].toString(); }
  138. Value getCharacterSetValue() { return getValue (Ids::characterSet); }
  139. Value getArchitectureType() { return getValue (Ids::winArchitecture); }
  140. bool is64Bit() const { return config [Ids::winArchitecture].toString() == get64BitArchName(); }
  141. Value getFastMathValue() { return getValue (Ids::fastMath); }
  142. bool isFastMathEnabled() const { return config [Ids::fastMath]; }
  143. String get64BitArchName() const { return "x64"; }
  144. String get32BitArchName() const { return "Win32"; }
  145. String createMSVCConfigName() const
  146. {
  147. return getName() + "|" + (config [Ids::winArchitecture] == get64BitArchName() ? "x64" : "Win32");
  148. }
  149. String getOutputFilename (const String& suffix, bool forceSuffix) const
  150. {
  151. const String target (File::createLegalFileName (getTargetBinaryNameString().trim()));
  152. if (forceSuffix || ! target.containsChar ('.'))
  153. return target.upToLastOccurrenceOf (".", false, false) + suffix;
  154. return target;
  155. }
  156. var getDefaultOptimisationLevel() const override { return var ((int) (isDebug() ? optimisationOff : optimiseMaxSpeed)); }
  157. void createConfigProperties (PropertyListBuilder& props) override
  158. {
  159. const String archTypes[] = { get32BitArchName(), get64BitArchName() };
  160. props.add (new ChoicePropertyComponent (getArchitectureType(), "Architecture",
  161. StringArray (archTypes, numElementsInArray (archTypes)),
  162. Array<var> (archTypes, numElementsInArray (archTypes))));
  163. props.add (new BooleanPropertyComponent (getFastMathValue(), "Relax IEEE compliance", "Enabled"),
  164. "Enable this to use FAST_MATH non-IEEE mode. (Warning: this can have unexpected results!)");
  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. auto cppStandard = owner.project.getCppStandardValue().toString();
  392. cl->createNewChildElement ("LanguageStandard")->addTextElement ("stdcpp" + cppStandard);
  393. }
  394. {
  395. XmlElement* res = group->createNewChildElement ("ResourceCompile");
  396. res->createNewChildElement ("PreprocessorDefinitions")->addTextElement (isDebug ? "_DEBUG;%(PreprocessorDefinitions)"
  397. : "NDEBUG;%(PreprocessorDefinitions)");
  398. }
  399. {
  400. XmlElement* link = group->createNewChildElement ("Link");
  401. link->createNewChildElement ("OutputFile")->addTextElement (getOutputFilePath (config));
  402. link->createNewChildElement ("SuppressStartupBanner")->addTextElement ("true");
  403. link->createNewChildElement ("IgnoreSpecificDefaultLibraries")->addTextElement (isDebug ? "libcmt.lib; msvcrt.lib;;%(IgnoreSpecificDefaultLibraries)"
  404. : "%(IgnoreSpecificDefaultLibraries)");
  405. link->createNewChildElement ("GenerateDebugInformation")->addTextElement ((isDebug || config.shouldGenerateDebugSymbols()) ? "true" : "false");
  406. link->createNewChildElement ("ProgramDatabaseFile")->addTextElement (getOwner().getIntDirFile (config, config.getOutputFilename (".pdb", true)));
  407. link->createNewChildElement ("SubSystem")->addTextElement (type == ConsoleApp ? "Console" : "Windows");
  408. if (! config.is64Bit())
  409. link->createNewChildElement ("TargetMachine")->addTextElement ("MachineX86");
  410. if (isUsingEditAndContinue)
  411. link->createNewChildElement ("ImageHasSafeExceptionHandlers")->addTextElement ("false");
  412. if (! isDebug)
  413. {
  414. link->createNewChildElement ("OptimizeReferences")->addTextElement ("true");
  415. link->createNewChildElement ("EnableCOMDATFolding")->addTextElement ("true");
  416. }
  417. const StringArray librarySearchPaths (config.getLibrarySearchPaths());
  418. if (librarySearchPaths.size() > 0)
  419. link->createNewChildElement ("AdditionalLibraryDirectories")->addTextElement (getOwner().replacePreprocessorTokens (config, librarySearchPaths.joinIntoString (";"))
  420. + ";%(AdditionalLibraryDirectories)");
  421. link->createNewChildElement ("LargeAddressAware")->addTextElement ("true");
  422. const String externalLibraries (getExternalLibraries (config, getOwner().getExternalLibrariesString()));
  423. if (externalLibraries.isNotEmpty())
  424. link->createNewChildElement ("AdditionalDependencies")->addTextElement (getOwner().replacePreprocessorTokens (config, externalLibraries).trim()
  425. + ";%(AdditionalDependencies)");
  426. String extraLinkerOptions (getOwner().getExtraLinkerFlagsString());
  427. if (extraLinkerOptions.isNotEmpty())
  428. link->createNewChildElement ("AdditionalOptions")->addTextElement (getOwner().replacePreprocessorTokens (config, extraLinkerOptions).trim()
  429. + " %(AdditionalOptions)");
  430. const String delayLoadedDLLs (getDelayLoadedDLLs());
  431. if (delayLoadedDLLs.isNotEmpty())
  432. link->createNewChildElement ("DelayLoadDLLs")->addTextElement (delayLoadedDLLs);
  433. const String moduleDefinitionsFile (getModuleDefinitions (config));
  434. if (moduleDefinitionsFile.isNotEmpty())
  435. link->createNewChildElement ("ModuleDefinitionFile")
  436. ->addTextElement (moduleDefinitionsFile);
  437. }
  438. {
  439. XmlElement* bsc = group->createNewChildElement ("Bscmake");
  440. bsc->createNewChildElement ("SuppressStartupBanner")->addTextElement ("true");
  441. bsc->createNewChildElement ("OutputFile")->addTextElement (getOwner().getIntDirFile (config, config.getOutputFilename (".bsc", true)));
  442. }
  443. const RelativePath& manifestFile = getOwner().getManifestPath();
  444. if (manifestFile.getRoot() != RelativePath::unknown)
  445. {
  446. XmlElement* bsc = group->createNewChildElement ("Manifest");
  447. bsc->createNewChildElement ("AdditionalManifestFiles")
  448. ->addTextElement (manifestFile.rebased (getOwner().getProject().getFile().getParentDirectory(),
  449. getOwner().getTargetFolder(),
  450. RelativePath::buildTargetFolder).toWindowsStyle());
  451. }
  452. if (getTargetFileType() == staticLibrary && ! config.is64Bit())
  453. {
  454. XmlElement* lib = group->createNewChildElement ("Lib");
  455. lib->createNewChildElement ("TargetMachine")->addTextElement ("MachineX86");
  456. }
  457. const String preBuild = getPreBuildSteps (config);
  458. if (preBuild.isNotEmpty())
  459. group->createNewChildElement ("PreBuildEvent")
  460. ->createNewChildElement ("Command")
  461. ->addTextElement (preBuild);
  462. const String postBuild = getPostBuildSteps (config);
  463. if (postBuild.isNotEmpty())
  464. group->createNewChildElement ("PostBuildEvent")
  465. ->createNewChildElement ("Command")
  466. ->addTextElement (postBuild);
  467. }
  468. ScopedPointer<XmlElement> otherFilesGroup (new XmlElement ("ItemGroup"));
  469. {
  470. XmlElement* cppFiles = projectXml.createNewChildElement ("ItemGroup");
  471. XmlElement* headerFiles = projectXml.createNewChildElement ("ItemGroup");
  472. for (int i = 0; i < getOwner().getAllGroups().size(); ++i)
  473. {
  474. const Project::Item& group = getOwner().getAllGroups().getReference (i);
  475. if (group.getNumChildren() > 0)
  476. addFilesToCompile (group, *cppFiles, *headerFiles, *otherFilesGroup);
  477. }
  478. }
  479. if (getOwner().iconFile != File())
  480. {
  481. XmlElement* e = otherFilesGroup->createNewChildElement ("None");
  482. e->setAttribute ("Include", prependDot (getOwner().iconFile.getFileName()));
  483. }
  484. if (otherFilesGroup->getFirstChildElement() != nullptr)
  485. projectXml.addChildElement (otherFilesGroup.release());
  486. if (getOwner().hasResourceFile())
  487. {
  488. XmlElement* rcGroup = projectXml.createNewChildElement ("ItemGroup");
  489. XmlElement* e = rcGroup->createNewChildElement ("ResourceCompile");
  490. e->setAttribute ("Include", prependDot (getOwner().rcFile.getFileName()));
  491. }
  492. {
  493. XmlElement* e = projectXml.createNewChildElement ("Import");
  494. e->setAttribute ("Project", "$(VCTargetsPath)\\Microsoft.Cpp.targets");
  495. }
  496. {
  497. XmlElement* e = projectXml.createNewChildElement ("ImportGroup");
  498. e->setAttribute ("Label", "ExtensionTargets");
  499. }
  500. getOwner().addPlatformToolsetToPropertyGroup (projectXml);
  501. getOwner().addWindowsTargetPlatformVersionToPropertyGroup (projectXml);
  502. getOwner().addIPPSettingToPropertyGroup (projectXml);
  503. }
  504. String getProjectType() const
  505. {
  506. switch (getTargetFileType())
  507. {
  508. case executable:
  509. return "Application";
  510. case staticLibrary:
  511. return "StaticLibrary";
  512. default:
  513. break;
  514. }
  515. return "DynamicLibrary";
  516. }
  517. //==============================================================================
  518. void addFilesToCompile (const Project::Item& projectItem, XmlElement& cpps, XmlElement& headers, XmlElement& otherFiles) const
  519. {
  520. const Type targetType = (getOwner().getProject().getProjectType().isAudioPlugin() ? type : SharedCodeTarget);
  521. if (projectItem.isGroup())
  522. {
  523. for (int i = 0; i < projectItem.getNumChildren(); ++i)
  524. addFilesToCompile (projectItem.getChild (i), cpps, headers, otherFiles);
  525. }
  526. else if (projectItem.shouldBeAddedToTargetProject()
  527. && getOwner().getProject().getTargetTypeFromFilePath (projectItem.getFile(), true) == targetType)
  528. {
  529. const RelativePath path (projectItem.getFile(), getOwner().getTargetFolder(), RelativePath::buildTargetFolder);
  530. jassert (path.getRoot() == RelativePath::buildTargetFolder);
  531. if (path.hasFileExtension (cOrCppFileExtensions) || path.hasFileExtension (asmFileExtensions))
  532. {
  533. if (targetType == SharedCodeTarget || projectItem.shouldBeCompiled())
  534. {
  535. auto* e = cpps.createNewChildElement ("ClCompile");
  536. e->setAttribute ("Include", path.toWindowsStyle());
  537. if (shouldUseStdCall (path))
  538. e->createNewChildElement ("CallingConvention")->addTextElement ("StdCall");
  539. if (! projectItem.shouldBeCompiled())
  540. e->createNewChildElement ("ExcludedFromBuild")->addTextElement ("true");
  541. }
  542. }
  543. else if (path.hasFileExtension (headerFileExtensions))
  544. {
  545. headers.createNewChildElement ("ClInclude")->setAttribute ("Include", path.toWindowsStyle());
  546. }
  547. else if (! path.hasFileExtension (objCFileExtensions))
  548. {
  549. otherFiles.createNewChildElement ("None")->setAttribute ("Include", path.toWindowsStyle());
  550. }
  551. }
  552. }
  553. void setConditionAttribute (XmlElement& xml, const BuildConfiguration& config) const
  554. {
  555. const MSVCBuildConfiguration& msvcConfig = dynamic_cast<const MSVCBuildConfiguration&> (config);
  556. xml.setAttribute ("Condition", "'$(Configuration)|$(Platform)'=='" + msvcConfig.createMSVCConfigName() + "'");
  557. }
  558. //==============================================================================
  559. void addFilterGroup (XmlElement& groups, const String& path) const
  560. {
  561. XmlElement* e = groups.createNewChildElement ("Filter");
  562. e->setAttribute ("Include", path);
  563. e->createNewChildElement ("UniqueIdentifier")->addTextElement (createGUID (path + "_guidpathsaltxhsdf"));
  564. }
  565. void addFileToFilter (const RelativePath& file, const String& groupPath,
  566. XmlElement& cpps, XmlElement& headers, XmlElement& otherFiles) const
  567. {
  568. XmlElement* e;
  569. if (file.hasFileExtension (headerFileExtensions))
  570. e = headers.createNewChildElement ("ClInclude");
  571. else if (file.hasFileExtension (sourceFileExtensions))
  572. e = cpps.createNewChildElement ("ClCompile");
  573. else
  574. e = otherFiles.createNewChildElement ("None");
  575. jassert (file.getRoot() == RelativePath::buildTargetFolder);
  576. e->setAttribute ("Include", file.toWindowsStyle());
  577. e->createNewChildElement ("Filter")->addTextElement (groupPath);
  578. }
  579. bool addFilesToFilter (const Project::Item& projectItem, const String& path,
  580. XmlElement& cpps, XmlElement& headers, XmlElement& otherFiles, XmlElement& groups) const
  581. {
  582. const Type targetType = (getOwner().getProject().getProjectType().isAudioPlugin() ? type : SharedCodeTarget);
  583. if (projectItem.isGroup())
  584. {
  585. bool filesWereAdded = false;
  586. for (int i = 0; i < projectItem.getNumChildren(); ++i)
  587. if (addFilesToFilter (projectItem.getChild(i),
  588. (path.isEmpty() ? String() : (path + "\\")) + projectItem.getChild(i).getName(),
  589. cpps, headers, otherFiles, groups))
  590. filesWereAdded = true;
  591. if (filesWereAdded)
  592. addFilterGroup (groups, path);
  593. return filesWereAdded;
  594. }
  595. else if (projectItem.shouldBeAddedToTargetProject())
  596. {
  597. const RelativePath relativePath (projectItem.getFile(), getOwner().getTargetFolder(), RelativePath::buildTargetFolder);
  598. jassert (relativePath.getRoot() == RelativePath::buildTargetFolder);
  599. if (getOwner().getProject().getTargetTypeFromFilePath (projectItem.getFile(), true) == targetType
  600. && (targetType == SharedCodeTarget || projectItem.shouldBeCompiled()))
  601. {
  602. addFileToFilter (relativePath, path.upToLastOccurrenceOf ("\\", false, false), cpps, headers, otherFiles);
  603. return true;
  604. }
  605. }
  606. return false;
  607. }
  608. bool addFilesToFilter (const Array<RelativePath>& files, const String& path,
  609. XmlElement& cpps, XmlElement& headers, XmlElement& otherFiles, XmlElement& groups)
  610. {
  611. if (files.size() > 0)
  612. {
  613. addFilterGroup (groups, path);
  614. for (int i = 0; i < files.size(); ++i)
  615. addFileToFilter (files.getReference(i), path, cpps, headers, otherFiles);
  616. return true;
  617. }
  618. return false;
  619. }
  620. void fillInFiltersXml (XmlElement& filterXml) const
  621. {
  622. filterXml.setAttribute ("ToolsVersion", getOwner().getToolsVersion());
  623. filterXml.setAttribute ("xmlns", "http://schemas.microsoft.com/developer/msbuild/2003");
  624. XmlElement* groupsXml = filterXml.createNewChildElement ("ItemGroup");
  625. XmlElement* cpps = filterXml.createNewChildElement ("ItemGroup");
  626. XmlElement* headers = filterXml.createNewChildElement ("ItemGroup");
  627. ScopedPointer<XmlElement> otherFilesGroup (new XmlElement ("ItemGroup"));
  628. for (int i = 0; i < getOwner().getAllGroups().size(); ++i)
  629. {
  630. const Project::Item& group = getOwner().getAllGroups().getReference(i);
  631. if (group.getNumChildren() > 0)
  632. addFilesToFilter (group, group.getName(), *cpps, *headers, *otherFilesGroup, *groupsXml);
  633. }
  634. if (getOwner().iconFile.exists())
  635. {
  636. XmlElement* e = otherFilesGroup->createNewChildElement ("None");
  637. e->setAttribute ("Include", prependDot (getOwner().iconFile.getFileName()));
  638. e->createNewChildElement ("Filter")->addTextElement (ProjectSaver::getJuceCodeGroupName());
  639. }
  640. if (otherFilesGroup->getFirstChildElement() != nullptr)
  641. filterXml.addChildElement (otherFilesGroup.release());
  642. if (getOwner().hasResourceFile())
  643. {
  644. XmlElement* rcGroup = filterXml.createNewChildElement ("ItemGroup");
  645. XmlElement* e = rcGroup->createNewChildElement ("ResourceCompile");
  646. e->setAttribute ("Include", prependDot (getOwner().rcFile.getFileName()));
  647. e->createNewChildElement ("Filter")->addTextElement (ProjectSaver::getJuceCodeGroupName());
  648. }
  649. }
  650. const MSVCProjectExporterBase& getOwner() const { return owner; }
  651. const String& getProjectGuid() const { return projectGuid; }
  652. //==============================================================================
  653. void writeProjectFile()
  654. {
  655. {
  656. XmlElement projectXml (getTopLevelXmlEntity());
  657. fillInProjectXml (projectXml);
  658. writeXmlOrThrow (projectXml, getVCProjFile(), "UTF-8", 10);
  659. }
  660. {
  661. XmlElement filtersXml (getTopLevelXmlEntity());
  662. fillInFiltersXml (filtersXml);
  663. writeXmlOrThrow (filtersXml, getVCProjFiltersFile(), "UTF-8", 100);
  664. }
  665. }
  666. String getSolutionTargetPath (const BuildConfiguration& config) const
  667. {
  668. const String binaryPath (config.getTargetBinaryRelativePathString().trim());
  669. if (binaryPath.isEmpty())
  670. return "$(SolutionDir)$(Platform)\\$(Configuration)";
  671. RelativePath binaryRelPath (binaryPath, RelativePath::projectFolder);
  672. if (binaryRelPath.isAbsolute())
  673. return binaryRelPath.toWindowsStyle();
  674. return prependDot (binaryRelPath.rebased (getOwner().projectFolder, getOwner().getTargetFolder(), RelativePath::buildTargetFolder)
  675. .toWindowsStyle());
  676. }
  677. String getConfigTargetPath (const BuildConfiguration& config) const
  678. {
  679. String solutionTargetFolder (getSolutionTargetPath (config));
  680. return solutionTargetFolder + String ("\\") + getName();
  681. }
  682. String getIntermediatesPath (const MSVCBuildConfiguration& config) const
  683. {
  684. String intDir = (config.getIntermediatesPath().isNotEmpty() ? config.getIntermediatesPath() : "$(Platform)\\$(Configuration)");
  685. if (! intDir.endsWithChar (L'\\'))
  686. intDir += L'\\';
  687. return intDir + getName();
  688. }
  689. static const char* getOptimisationLevelString (int level)
  690. {
  691. switch (level)
  692. {
  693. case optimiseMaxSpeed: return "Full";
  694. case optimiseMinSize: return "MinSpace";
  695. default: return "Disabled";
  696. }
  697. }
  698. String getTargetSuffix() const
  699. {
  700. const ProjectType::Target::TargetFileType fileType = getTargetFileType();
  701. switch (fileType)
  702. {
  703. case executable: return ".exe";
  704. case staticLibrary: return ".lib";
  705. case sharedLibraryOrDLL: return ".dll";
  706. case pluginBundle:
  707. switch (type)
  708. {
  709. case VST3PlugIn: return ".vst3";
  710. case AAXPlugIn: return ".aaxdll";
  711. case RTASPlugIn: return ".dpm";
  712. default: break;
  713. }
  714. return ".dll";
  715. default:
  716. break;
  717. }
  718. return {};
  719. }
  720. XmlElement* createToolElement (XmlElement& parent, const String& toolName) const
  721. {
  722. XmlElement* const e = parent.createNewChildElement ("Tool");
  723. e->setAttribute ("Name", toolName);
  724. return e;
  725. }
  726. String getPreprocessorDefs (const BuildConfiguration& config, const String& joinString) const
  727. {
  728. StringPairArray defines (getOwner().msvcExtraPreprocessorDefs);
  729. defines.set ("WIN32", "");
  730. defines.set ("_WINDOWS", "");
  731. if (config.isDebug())
  732. {
  733. defines.set ("DEBUG", "");
  734. defines.set ("_DEBUG", "");
  735. }
  736. else
  737. {
  738. defines.set ("NDEBUG", "");
  739. }
  740. defines = mergePreprocessorDefs (defines, getOwner().getAllPreprocessorDefs (config, type));
  741. addExtraPreprocessorDefines (defines);
  742. if (getTargetFileType() == staticLibrary || getTargetFileType() == sharedLibraryOrDLL)
  743. defines.set("_LIB", "");
  744. StringArray result;
  745. for (int i = 0; i < defines.size(); ++i)
  746. {
  747. String def (defines.getAllKeys()[i]);
  748. const String value (defines.getAllValues()[i]);
  749. if (value.isNotEmpty())
  750. def << "=" << value;
  751. result.add (def);
  752. }
  753. return result.joinIntoString (joinString);
  754. }
  755. //==============================================================================
  756. RelativePath getAAXIconFile() const
  757. {
  758. const RelativePath aaxSDK (getOwner().getAAXPathValue().toString(), RelativePath::projectFolder);
  759. const RelativePath projectIcon ("icon.ico", RelativePath::buildTargetFolder);
  760. if (getOwner().getTargetFolder().getChildFile ("icon.ico").existsAsFile())
  761. return projectIcon.rebased (getOwner().getTargetFolder(),
  762. getOwner().getProject().getProjectFolder(),
  763. RelativePath::projectFolder);
  764. else
  765. return aaxSDK.getChildFile ("Utilities").getChildFile ("PlugIn.ico");
  766. }
  767. String getExtraPostBuildSteps (const MSVCBuildConfiguration& config) const
  768. {
  769. if (type == AAXPlugIn)
  770. {
  771. const RelativePath aaxSDK (getOwner().getAAXPathValue().toString(), RelativePath::projectFolder);
  772. const RelativePath aaxLibsFolder = aaxSDK.getChildFile ("Libs");
  773. const RelativePath bundleScript = aaxSDK.getChildFile ("Utilities").getChildFile ("CreatePackage.bat");
  774. const RelativePath iconFilePath = getAAXIconFile();
  775. const bool is64Bit = (config.config [Ids::winArchitecture] == "x64");
  776. const String bundleDir = getOwner().getOutDirFile (config, config.getOutputFilename (".aaxplugin", true));
  777. const String bundleContents = bundleDir + "\\Contents";
  778. const String macOSDir = bundleContents + String ("\\") + (is64Bit ? "x64" : "Win32");
  779. const String executable = macOSDir + String ("\\") + config.getOutputFilename (".aaxplugin", true);
  780. return String ("copy /Y \"") + getOutputFilePath (config) + String ("\" \"") + executable + String ("\"\r\ncall ") +
  781. createRebasedPath (bundleScript) + String (" \"") + macOSDir + String ("\" ") + createRebasedPath (iconFilePath);
  782. }
  783. return {};
  784. }
  785. String getExtraPreBuildSteps (const MSVCBuildConfiguration& config) const
  786. {
  787. if (type == AAXPlugIn)
  788. {
  789. String script;
  790. const bool is64Bit = (config.config [Ids::winArchitecture] == "x64");
  791. const String bundleDir = getOwner().getOutDirFile (config, config.getOutputFilename (".aaxplugin", false));
  792. const String bundleContents = bundleDir + "\\Contents";
  793. const String macOSDir = bundleContents + String ("\\") + (is64Bit ? "x64" : "Win32");
  794. StringArray folders = {bundleDir.toRawUTF8(), bundleContents.toRawUTF8(), macOSDir.toRawUTF8()};
  795. for (int i = 0; i < folders.size(); ++i)
  796. script += String ("if not exist \"") + folders[i] + String ("\" mkdir \"") + folders[i] + String ("\"\r\n");
  797. return script;
  798. }
  799. return {};
  800. }
  801. String getPostBuildSteps (const MSVCBuildConfiguration& config) const
  802. {
  803. String postBuild = config.getPostbuildCommandString();
  804. const String extraPostBuild = getExtraPostBuildSteps (config);
  805. postBuild += String (postBuild.isNotEmpty() && extraPostBuild.isNotEmpty() ? "\r\n" : "") + extraPostBuild;
  806. return postBuild;
  807. }
  808. String getPreBuildSteps (const MSVCBuildConfiguration& config) const
  809. {
  810. String preBuild = config.getPrebuildCommandString();
  811. const String extraPreBuild = getExtraPreBuildSteps (config);
  812. preBuild += String (preBuild.isNotEmpty() && extraPreBuild.isNotEmpty() ? "\r\n" : "") + extraPreBuild;
  813. return preBuild;
  814. }
  815. void addExtraPreprocessorDefines (StringPairArray& defines) const
  816. {
  817. switch (type)
  818. {
  819. case AAXPlugIn:
  820. {
  821. const RelativePath aaxLibsFolder = RelativePath (getOwner().getAAXPathValue().toString(), RelativePath::projectFolder).getChildFile ("Libs");
  822. defines.set ("JucePlugin_AAXLibs_path", createRebasedPath (aaxLibsFolder));
  823. }
  824. break;
  825. case RTASPlugIn:
  826. {
  827. const RelativePath rtasFolder (getOwner().getRTASPathValue().toString(), RelativePath::projectFolder);
  828. defines.set ("JucePlugin_WinBag_path", createRebasedPath (rtasFolder.getChildFile ("WinBag")));
  829. }
  830. break;
  831. default:
  832. break;
  833. }
  834. }
  835. String getExtraLinkerFlags() const
  836. {
  837. if (type == RTASPlugIn)
  838. return "/FORCE:multiple";
  839. return {};
  840. }
  841. StringArray getExtraSearchPaths() const
  842. {
  843. StringArray searchPaths;
  844. if (type == RTASPlugIn)
  845. {
  846. const RelativePath rtasFolder (getOwner().getRTASPathValue().toString(), RelativePath::projectFolder);
  847. static const char* p[] = { "AlturaPorts/TDMPlugins/PluginLibrary/EffectClasses",
  848. "AlturaPorts/TDMPlugins/PluginLibrary/ProcessClasses",
  849. "AlturaPorts/TDMPlugins/PluginLibrary/ProcessClasses/Interfaces",
  850. "AlturaPorts/TDMPlugins/PluginLibrary/Utilities",
  851. "AlturaPorts/TDMPlugins/PluginLibrary/RTASP_Adapt",
  852. "AlturaPorts/TDMPlugins/PluginLibrary/CoreClasses",
  853. "AlturaPorts/TDMPlugins/PluginLibrary/Controls",
  854. "AlturaPorts/TDMPlugins/PluginLibrary/Meters",
  855. "AlturaPorts/TDMPlugins/PluginLibrary/ViewClasses",
  856. "AlturaPorts/TDMPlugins/PluginLibrary/DSPClasses",
  857. "AlturaPorts/TDMPlugins/PluginLibrary/Interfaces",
  858. "AlturaPorts/TDMPlugins/common",
  859. "AlturaPorts/TDMPlugins/common/Platform",
  860. "AlturaPorts/TDMPlugins/common/Macros",
  861. "AlturaPorts/TDMPlugins/SignalProcessing/Public",
  862. "AlturaPorts/TDMPlugIns/DSPManager/Interfaces",
  863. "AlturaPorts/SADriver/Interfaces",
  864. "AlturaPorts/DigiPublic/Interfaces",
  865. "AlturaPorts/DigiPublic",
  866. "AlturaPorts/Fic/Interfaces/DAEClient",
  867. "AlturaPorts/NewFileLibs/Cmn",
  868. "AlturaPorts/NewFileLibs/DOA",
  869. "AlturaPorts/AlturaSource/PPC_H",
  870. "AlturaPorts/AlturaSource/AppSupport",
  871. "AvidCode/AVX2sdk/AVX/avx2/avx2sdk/inc",
  872. "xplat/AVX/avx2/avx2sdk/inc" };
  873. for (int i = 0; i < numElementsInArray (p); ++i)
  874. searchPaths.add (createRebasedPath (rtasFolder.getChildFile (p[i])));
  875. }
  876. return searchPaths;
  877. }
  878. String getBinaryNameWithSuffix (const MSVCBuildConfiguration& config) const
  879. {
  880. return config.getOutputFilename (getTargetSuffix(), true);
  881. }
  882. String getOutputFilePath (const MSVCBuildConfiguration& config) const
  883. {
  884. return getOwner().getOutDirFile (config, getBinaryNameWithSuffix (config));
  885. }
  886. StringArray getLibrarySearchPaths (const BuildConfiguration& config) const
  887. {
  888. StringArray librarySearchPaths (config.getLibrarySearchPaths());
  889. if (type != SharedCodeTarget)
  890. if (const MSVCTargetBase* shared = getOwner().getSharedCodeTarget())
  891. librarySearchPaths.add (shared->getConfigTargetPath (config));
  892. return librarySearchPaths;
  893. }
  894. String getExternalLibraries (const MSVCBuildConfiguration& config, const String& otherLibs) const
  895. {
  896. StringArray libraries;
  897. if (otherLibs.isNotEmpty())
  898. libraries.add (otherLibs);
  899. StringArray moduleLibs = getOwner().getModuleLibs();
  900. if (! moduleLibs.isEmpty())
  901. libraries.addArray (moduleLibs);
  902. if (type != SharedCodeTarget)
  903. if (const MSVCTargetBase* shared = getOwner().getSharedCodeTarget())
  904. libraries.add (shared->getBinaryNameWithSuffix (config));
  905. return libraries.joinIntoString (";");
  906. }
  907. String getDelayLoadedDLLs() const
  908. {
  909. String delayLoadedDLLs = getOwner().msvcDelayLoadedDLLs;
  910. if (type == RTASPlugIn)
  911. delayLoadedDLLs += "DAE.dll; DigiExt.dll; DSI.dll; PluginLib.dll; "
  912. "DSPManager.dll; DSPManager.dll; DSPManagerClientLib.dll; RTASClientLib.dll";
  913. return delayLoadedDLLs;
  914. }
  915. String getModuleDefinitions (const MSVCBuildConfiguration& config) const
  916. {
  917. const String& moduleDefinitions = config.config [Ids::msvcModuleDefinitionFile].toString();
  918. if (moduleDefinitions.isNotEmpty())
  919. return moduleDefinitions;
  920. if (type == RTASPlugIn)
  921. {
  922. const ProjectExporter& exp = getOwner();
  923. RelativePath moduleDefPath
  924. = RelativePath (exp.getPathForModuleString ("juce_audio_plugin_client"), RelativePath::projectFolder)
  925. .getChildFile ("juce_audio_plugin_client").getChildFile ("RTAS").getChildFile ("juce_RTAS_WinExports.def");
  926. return prependDot (moduleDefPath.rebased (exp.getProject().getProjectFolder(),
  927. exp.getTargetFolder(),
  928. RelativePath::buildTargetFolder).toWindowsStyle());
  929. }
  930. return {};
  931. }
  932. bool shouldUseRuntimeDLL (const MSVCBuildConfiguration& config) const
  933. {
  934. return (config.config [Ids::useRuntimeLibDLL].isVoid() ? (getOwner().hasTarget (AAXPlugIn) || getOwner().hasTarget (RTASPlugIn))
  935. : config.isUsingRuntimeLibDLL());
  936. }
  937. File getVCProjFile() const { return getOwner().getProjectFile (getProjectFileSuffix(), getName()); }
  938. File getVCProjFiltersFile() const { return getOwner().getProjectFile (getFiltersFileSuffix(), getName()); }
  939. String createRebasedPath (const RelativePath& path) const { return getOwner().createRebasedPath (path); }
  940. protected:
  941. const MSVCProjectExporterBase& owner;
  942. String projectGuid;
  943. };
  944. //==============================================================================
  945. bool usesMMFiles() const override { return false; }
  946. bool canCopeWithDuplicateFiles() override { return false; }
  947. bool supportsUserDefinedConfigurations() const override { return true; }
  948. bool isXcode() const override { return false; }
  949. bool isVisualStudio() const override { return true; }
  950. bool isCodeBlocks() const override { return false; }
  951. bool isMakefile() const override { return false; }
  952. bool isAndroidStudio() const override { return false; }
  953. bool isAndroid() const override { return false; }
  954. bool isWindows() const override { return true; }
  955. bool isLinux() const override { return false; }
  956. bool isOSX() const override { return false; }
  957. bool isiOS() const override { return false; }
  958. bool supportsTargetType (ProjectType::Target::Type type) const override
  959. {
  960. switch (type)
  961. {
  962. case ProjectType::Target::StandalonePlugIn:
  963. case ProjectType::Target::GUIApp:
  964. case ProjectType::Target::ConsoleApp:
  965. case ProjectType::Target::StaticLibrary:
  966. case ProjectType::Target::SharedCodeTarget:
  967. case ProjectType::Target::AggregateTarget:
  968. case ProjectType::Target::VSTPlugIn:
  969. case ProjectType::Target::VST3PlugIn:
  970. case ProjectType::Target::AAXPlugIn:
  971. case ProjectType::Target::RTASPlugIn:
  972. case ProjectType::Target::DynamicLibrary:
  973. return true;
  974. default:
  975. break;
  976. }
  977. return false;
  978. }
  979. //==============================================================================
  980. Value getManifestFile() { return getSetting (Ids::msvcManifestFile); }
  981. RelativePath getManifestPath() const
  982. {
  983. const String& path = settings [Ids::msvcManifestFile].toString();
  984. return path.isEmpty() ? RelativePath() : RelativePath (settings [Ids::msvcManifestFile], RelativePath::projectFolder);
  985. }
  986. //==============================================================================
  987. const String& getProjectName() const { return projectName; }
  988. bool launchProject() override
  989. {
  990. #if JUCE_WINDOWS
  991. return getSLNFile().startAsProcess();
  992. #else
  993. return false;
  994. #endif
  995. }
  996. bool canLaunchProject() override
  997. {
  998. #if JUCE_WINDOWS
  999. return true;
  1000. #else
  1001. return false;
  1002. #endif
  1003. }
  1004. void createExporterProperties (PropertyListBuilder& props) override
  1005. {
  1006. props.add(new TextPropertyComponent(getManifestFile(), "Manifest file", 8192, false),
  1007. "Path to a manifest input file which should be linked into your binary (path is relative to jucer file).");
  1008. }
  1009. enum OptimisationLevel
  1010. {
  1011. optimisationOff = 1,
  1012. optimiseMinSize = 2,
  1013. optimiseMaxSpeed = 3
  1014. };
  1015. //==============================================================================
  1016. void addPlatformSpecificSettingsForProjectType (const ProjectType& type) override
  1017. {
  1018. msvcExtraPreprocessorDefs.set ("_CRT_SECURE_NO_WARNINGS", "");
  1019. if (type.isCommandLineApp())
  1020. msvcExtraPreprocessorDefs.set("_CONSOLE", "");
  1021. callForAllSupportedTargets ([this] (ProjectType::Target::Type targetType)
  1022. {
  1023. if (MSVCTargetBase* target = new MSVCTargetBase (targetType, *this))
  1024. {
  1025. if (targetType != ProjectType::Target::AggregateTarget)
  1026. targets.add (target);
  1027. }
  1028. });
  1029. // If you hit this assert, you tried to generate a project for an exporter
  1030. // that does not support any of your targets!
  1031. jassert (targets.size() > 0);
  1032. }
  1033. const MSVCTargetBase* getSharedCodeTarget() const
  1034. {
  1035. for (auto target : targets)
  1036. if (target->type == ProjectType::Target::SharedCodeTarget)
  1037. return target;
  1038. return nullptr;
  1039. }
  1040. bool hasTarget (ProjectType::Target::Type type) const
  1041. {
  1042. for (auto target : targets)
  1043. if (target->type == type)
  1044. return true;
  1045. return false;
  1046. }
  1047. private:
  1048. //==============================================================================
  1049. String createRebasedPath (const RelativePath& path) const
  1050. {
  1051. String rebasedPath = rebaseFromProjectFolderToBuildTarget (path).toWindowsStyle();
  1052. return getVisualStudioVersion() < 10 // (VS10 automatically adds escape characters to the quotes for this definition)
  1053. ? CppTokeniserFunctions::addEscapeChars (rebasedPath.quoted())
  1054. : CppTokeniserFunctions::addEscapeChars (rebasedPath).quoted();
  1055. }
  1056. protected:
  1057. //==============================================================================
  1058. mutable File rcFile, iconFile;
  1059. OwnedArray<MSVCTargetBase> targets;
  1060. File getProjectFile (const String& extension, const String& target) const
  1061. {
  1062. String filename = project.getProjectFilenameRoot();
  1063. if (target.isNotEmpty())
  1064. filename += String ("_") + target.removeCharacters (" ");
  1065. return getTargetFolder().getChildFile (filename).withFileExtension (extension);
  1066. }
  1067. File getSLNFile() const { return getProjectFile (".sln", String()); }
  1068. static String prependIfNotAbsolute (const String& file, const char* prefix)
  1069. {
  1070. if (File::isAbsolutePath (file) || file.startsWithChar ('$'))
  1071. prefix = "";
  1072. return prefix + FileHelpers::windowsStylePath (file);
  1073. }
  1074. String getIntDirFile (const BuildConfiguration& config, const String& file) const { return prependIfNotAbsolute (replacePreprocessorTokens (config, file), "$(IntDir)\\"); }
  1075. String getOutDirFile (const BuildConfiguration& config, const String& file) const { return prependIfNotAbsolute (replacePreprocessorTokens (config, file), "$(OutDir)\\"); }
  1076. void updateOldSettings()
  1077. {
  1078. {
  1079. const String oldStylePrebuildCommand (getSettingString (Ids::prebuildCommand));
  1080. settings.removeProperty (Ids::prebuildCommand, nullptr);
  1081. if (oldStylePrebuildCommand.isNotEmpty())
  1082. for (ConfigIterator config (*this); config.next();)
  1083. dynamic_cast<MSVCBuildConfiguration&> (*config).getPrebuildCommand() = oldStylePrebuildCommand;
  1084. }
  1085. {
  1086. const String oldStyleLibName (getSettingString ("libraryName_Debug"));
  1087. settings.removeProperty ("libraryName_Debug", nullptr);
  1088. if (oldStyleLibName.isNotEmpty())
  1089. for (ConfigIterator config (*this); config.next();)
  1090. if (config->isDebug())
  1091. config->getTargetBinaryName() = oldStyleLibName;
  1092. }
  1093. {
  1094. const String oldStyleLibName (getSettingString ("libraryName_Release"));
  1095. settings.removeProperty ("libraryName_Release", nullptr);
  1096. if (oldStyleLibName.isNotEmpty())
  1097. for (ConfigIterator config (*this); config.next();)
  1098. if (! config->isDebug())
  1099. config->getTargetBinaryName() = oldStyleLibName;
  1100. }
  1101. }
  1102. BuildConfiguration::Ptr createBuildConfig (const ValueTree& v) const override
  1103. {
  1104. return new MSVCBuildConfiguration (project, v, *this);
  1105. }
  1106. StringArray getHeaderSearchPaths (const BuildConfiguration& config) const
  1107. {
  1108. StringArray searchPaths (extraSearchPaths);
  1109. searchPaths.addArray (config.getHeaderSearchPaths());
  1110. return getCleanedStringArray (searchPaths);
  1111. }
  1112. String getSharedCodeGuid() const
  1113. {
  1114. String sharedCodeGuid;
  1115. for (int i = 0; i < targets.size(); ++i)
  1116. if (MSVCTargetBase* target = targets[i])
  1117. if (target->type == ProjectType::Target::SharedCodeTarget)
  1118. return target->getProjectGuid();
  1119. return {};
  1120. }
  1121. //==============================================================================
  1122. void writeProjectDependencies (OutputStream& out) const
  1123. {
  1124. const String sharedCodeGuid = getSharedCodeGuid();
  1125. for (int addingOtherTargets = 0; addingOtherTargets < (sharedCodeGuid.isNotEmpty() ? 2 : 1); ++addingOtherTargets)
  1126. {
  1127. for (int i = 0; i < targets.size(); ++i)
  1128. {
  1129. if (MSVCTargetBase* target = targets[i])
  1130. {
  1131. if (sharedCodeGuid.isEmpty() || (addingOtherTargets != 0) == (target->type != ProjectType::Target::StandalonePlugIn))
  1132. {
  1133. out << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"" << projectName << " - "
  1134. << target->getName() << "\", \""
  1135. << target->getVCProjFile().getFileName() << "\", \"" << target->getProjectGuid() << '"' << newLine;
  1136. if (sharedCodeGuid.isNotEmpty() && target->type != ProjectType::Target::SharedCodeTarget)
  1137. out << "\tProjectSection(ProjectDependencies) = postProject" << newLine
  1138. << "\t\t" << sharedCodeGuid << " = " << sharedCodeGuid << newLine
  1139. << "\tEndProjectSection" << newLine;
  1140. out << "EndProject" << newLine;
  1141. }
  1142. }
  1143. }
  1144. }
  1145. }
  1146. void writeSolutionFile (OutputStream& out, const String& versionString, String commentString) const
  1147. {
  1148. if (commentString.isNotEmpty())
  1149. commentString += newLine;
  1150. out << "Microsoft Visual Studio Solution File, Format Version " << versionString << newLine
  1151. << commentString << newLine;
  1152. writeProjectDependencies (out);
  1153. out << "Global" << newLine
  1154. << "\tGlobalSection(SolutionConfigurationPlatforms) = preSolution" << newLine;
  1155. for (ConstConfigIterator i (*this); i.next();)
  1156. {
  1157. const MSVCBuildConfiguration& config = dynamic_cast<const MSVCBuildConfiguration&> (*i);
  1158. const String configName = config.createMSVCConfigName();
  1159. out << "\t\t" << configName << " = " << configName << newLine;
  1160. }
  1161. out << "\tEndGlobalSection" << newLine
  1162. << "\tGlobalSection(ProjectConfigurationPlatforms) = postSolution" << newLine;
  1163. for (auto& target : targets)
  1164. for (ConstConfigIterator i (*this); i.next();)
  1165. {
  1166. const MSVCBuildConfiguration& config = dynamic_cast<const MSVCBuildConfiguration&> (*i);
  1167. const String configName = config.createMSVCConfigName();
  1168. for (auto& suffix : { "ActiveCfg", "Build.0" })
  1169. out << "\t\t" << target->getProjectGuid() << "." << configName << "." << suffix << " = " << configName << newLine;
  1170. }
  1171. out << "\tEndGlobalSection" << newLine
  1172. << "\tGlobalSection(SolutionProperties) = preSolution" << newLine
  1173. << "\t\tHideSolutionNode = FALSE" << newLine
  1174. << "\tEndGlobalSection" << newLine;
  1175. out << "EndGlobal" << newLine;
  1176. }
  1177. //==============================================================================
  1178. static void writeBMPImage (const Image& image, const int w, const int h, MemoryOutputStream& out)
  1179. {
  1180. const int maskStride = (w / 8 + 3) & ~3;
  1181. out.writeInt (40); // bitmapinfoheader size
  1182. out.writeInt (w);
  1183. out.writeInt (h * 2);
  1184. out.writeShort (1); // planes
  1185. out.writeShort (32); // bits
  1186. out.writeInt (0); // compression
  1187. out.writeInt ((h * w * 4) + (h * maskStride)); // size image
  1188. out.writeInt (0); // x pixels per meter
  1189. out.writeInt (0); // y pixels per meter
  1190. out.writeInt (0); // clr used
  1191. out.writeInt (0); // clr important
  1192. const Image::BitmapData bitmap (image, Image::BitmapData::readOnly);
  1193. const int alphaThreshold = 5;
  1194. int y;
  1195. for (y = h; --y >= 0;)
  1196. {
  1197. for (int x = 0; x < w; ++x)
  1198. {
  1199. const Colour pixel (bitmap.getPixelColour (x, y));
  1200. if (pixel.getAlpha() <= alphaThreshold)
  1201. {
  1202. out.writeInt (0);
  1203. }
  1204. else
  1205. {
  1206. out.writeByte ((char) pixel.getBlue());
  1207. out.writeByte ((char) pixel.getGreen());
  1208. out.writeByte ((char) pixel.getRed());
  1209. out.writeByte ((char) pixel.getAlpha());
  1210. }
  1211. }
  1212. }
  1213. for (y = h; --y >= 0;)
  1214. {
  1215. int mask = 0, count = 0;
  1216. for (int x = 0; x < w; ++x)
  1217. {
  1218. const Colour pixel (bitmap.getPixelColour (x, y));
  1219. mask <<= 1;
  1220. if (pixel.getAlpha() <= alphaThreshold)
  1221. mask |= 1;
  1222. if (++count == 8)
  1223. {
  1224. out.writeByte ((char) mask);
  1225. count = 0;
  1226. mask = 0;
  1227. }
  1228. }
  1229. if (mask != 0)
  1230. out.writeByte ((char) mask);
  1231. for (int i = maskStride - w / 8; --i >= 0;)
  1232. out.writeByte (0);
  1233. }
  1234. }
  1235. static void writeIconFile (const Array<Image>& images, MemoryOutputStream& out)
  1236. {
  1237. out.writeShort (0); // reserved
  1238. out.writeShort (1); // .ico tag
  1239. out.writeShort ((short) images.size());
  1240. MemoryOutputStream dataBlock;
  1241. const int imageDirEntrySize = 16;
  1242. const int dataBlockStart = 6 + images.size() * imageDirEntrySize;
  1243. for (int i = 0; i < images.size(); ++i)
  1244. {
  1245. const size_t oldDataSize = dataBlock.getDataSize();
  1246. const Image& image = images.getReference (i);
  1247. const int w = image.getWidth();
  1248. const int h = image.getHeight();
  1249. if (w >= 256 || h >= 256)
  1250. {
  1251. PNGImageFormat pngFormat;
  1252. pngFormat.writeImageToStream (image, dataBlock);
  1253. }
  1254. else
  1255. {
  1256. writeBMPImage (image, w, h, dataBlock);
  1257. }
  1258. out.writeByte ((char) w);
  1259. out.writeByte ((char) h);
  1260. out.writeByte (0);
  1261. out.writeByte (0);
  1262. out.writeShort (1); // colour planes
  1263. out.writeShort (32); // bits per pixel
  1264. out.writeInt ((int) (dataBlock.getDataSize() - oldDataSize));
  1265. out.writeInt (dataBlockStart + (int) oldDataSize);
  1266. }
  1267. jassert (out.getPosition() == dataBlockStart);
  1268. out << dataBlock;
  1269. }
  1270. bool hasResourceFile() const
  1271. {
  1272. return ! projectType.isStaticLibrary();
  1273. }
  1274. void createResourcesAndIcon() const
  1275. {
  1276. if (hasResourceFile())
  1277. {
  1278. Array<Image> images;
  1279. const int sizes[] = { 16, 32, 48, 256 };
  1280. for (int i = 0; i < numElementsInArray (sizes); ++i)
  1281. {
  1282. Image im (getBestIconForSize (sizes[i], true));
  1283. if (im.isValid())
  1284. images.add (im);
  1285. }
  1286. if (images.size() > 0)
  1287. {
  1288. iconFile = getTargetFolder().getChildFile ("icon.ico");
  1289. MemoryOutputStream mo;
  1290. writeIconFile (images, mo);
  1291. overwriteFileIfDifferentOrThrow (iconFile, mo);
  1292. }
  1293. createRCFile();
  1294. }
  1295. }
  1296. void createRCFile() const
  1297. {
  1298. rcFile = getTargetFolder().getChildFile ("resources.rc");
  1299. const String version (project.getVersionString());
  1300. MemoryOutputStream mo;
  1301. mo << "#ifdef JUCE_USER_DEFINED_RC_FILE" << newLine
  1302. << " #include JUCE_USER_DEFINED_RC_FILE" << newLine
  1303. << "#else" << newLine
  1304. << newLine
  1305. << "#undef WIN32_LEAN_AND_MEAN" << newLine
  1306. << "#define WIN32_LEAN_AND_MEAN" << newLine
  1307. << "#include <windows.h>" << newLine
  1308. << newLine
  1309. << "VS_VERSION_INFO VERSIONINFO" << newLine
  1310. << "FILEVERSION " << getCommaSeparatedVersionNumber (version) << newLine
  1311. << "BEGIN" << newLine
  1312. << " BLOCK \"StringFileInfo\"" << newLine
  1313. << " BEGIN" << newLine
  1314. << " BLOCK \"040904E4\"" << newLine
  1315. << " BEGIN" << newLine;
  1316. writeRCValue (mo, "CompanyName", project.getCompanyName().toString());
  1317. writeRCValue (mo, "FileDescription", project.getTitle());
  1318. writeRCValue (mo, "FileVersion", version);
  1319. writeRCValue (mo, "ProductName", project.getTitle());
  1320. writeRCValue (mo, "ProductVersion", version);
  1321. mo << " END" << newLine
  1322. << " END" << newLine
  1323. << newLine
  1324. << " BLOCK \"VarFileInfo\"" << newLine
  1325. << " BEGIN" << newLine
  1326. << " VALUE \"Translation\", 0x409, 1252" << newLine
  1327. << " END" << newLine
  1328. << "END" << newLine
  1329. << newLine
  1330. << "#endif" << newLine;
  1331. if (iconFile != File())
  1332. mo << newLine
  1333. << "IDI_ICON1 ICON DISCARDABLE " << iconFile.getFileName().quoted()
  1334. << newLine
  1335. << "IDI_ICON2 ICON DISCARDABLE " << iconFile.getFileName().quoted();
  1336. overwriteFileIfDifferentOrThrow (rcFile, mo);
  1337. }
  1338. static void writeRCValue (MemoryOutputStream& mo, const String& name, const String& value)
  1339. {
  1340. if (value.isNotEmpty())
  1341. mo << " VALUE \"" << name << "\", \""
  1342. << CppTokeniserFunctions::addEscapeChars (value) << "\\0\"" << newLine;
  1343. }
  1344. static String getCommaSeparatedVersionNumber (const String& version)
  1345. {
  1346. StringArray versionParts;
  1347. versionParts.addTokens (version, ",.", "");
  1348. versionParts.trim();
  1349. versionParts.removeEmptyStrings();
  1350. while (versionParts.size() < 4)
  1351. versionParts.add ("0");
  1352. return versionParts.joinIntoString (",");
  1353. }
  1354. static String prependDot (const String& filename)
  1355. {
  1356. return FileHelpers::isAbsolutePath (filename) ? filename
  1357. : (".\\" + filename);
  1358. }
  1359. void initialiseDependencyPathValues()
  1360. {
  1361. vst3Path.referTo (Value (new DependencyPathValueSource (getSetting (Ids::vst3Folder),
  1362. Ids::vst3Path,
  1363. TargetOS::windows)));
  1364. aaxPath.referTo (Value (new DependencyPathValueSource (getSetting (Ids::aaxFolder),
  1365. Ids::aaxPath,
  1366. TargetOS::windows)));
  1367. rtasPath.referTo (Value (new DependencyPathValueSource (getSetting (Ids::rtasFolder),
  1368. Ids::rtasPath,
  1369. TargetOS::windows)));
  1370. }
  1371. static bool shouldUseStdCall (const RelativePath& path)
  1372. {
  1373. return path.getFileNameWithoutExtension().startsWithIgnoreCase ("juce_audio_plugin_client_RTAS_");
  1374. }
  1375. StringArray getModuleLibs() const
  1376. {
  1377. StringArray result;
  1378. for (auto& lib : windowsLibs)
  1379. result.add (lib + ".lib");
  1380. return result;
  1381. }
  1382. JUCE_DECLARE_NON_COPYABLE (MSVCProjectExporterBase)
  1383. };
  1384. //==============================================================================
  1385. class MSVCProjectExporterVC2013 : public MSVCProjectExporterBase
  1386. {
  1387. public:
  1388. MSVCProjectExporterVC2013 (Project& p, const ValueTree& t)
  1389. : MSVCProjectExporterBase (p, t, "VisualStudio2013")
  1390. {
  1391. name = getName();
  1392. }
  1393. static const char* getName() { return "Visual Studio 2013"; }
  1394. static const char* getValueTreeTypeName() { return "VS2013"; }
  1395. int getVisualStudioVersion() const override { return 12; }
  1396. String getSolutionComment() const override { return "# Visual Studio 2013"; }
  1397. String getToolsVersion() const override { return "12.0"; }
  1398. String getDefaultToolset() const override { return "v120"; }
  1399. String getDefaultWindowsTargetPlatformVersion() const override { return "8.1"; }
  1400. static MSVCProjectExporterVC2013* createForSettings (Project& project, const ValueTree& settings)
  1401. {
  1402. if (settings.hasType (getValueTreeTypeName()))
  1403. return new MSVCProjectExporterVC2013 (project, settings);
  1404. return nullptr;
  1405. }
  1406. void createExporterProperties (PropertyListBuilder& props) override
  1407. {
  1408. MSVCProjectExporterBase::createExporterProperties (props);
  1409. static const char* toolsetNames[] = { "(default)", "v120", "v120_xp", "Windows7.1SDK", "CTP_Nov2013" };
  1410. const var toolsets[] = { var(), "v120", "v120_xp", "Windows7.1SDK", "CTP_Nov2013" };
  1411. addToolsetProperty (props, toolsetNames, toolsets, numElementsInArray (toolsets));
  1412. addIPPLibraryProperty (props);
  1413. addWindowsTargetPlatformProperties (props);
  1414. }
  1415. JUCE_DECLARE_NON_COPYABLE (MSVCProjectExporterVC2013)
  1416. };
  1417. //==============================================================================
  1418. class MSVCProjectExporterVC2015 : public MSVCProjectExporterBase
  1419. {
  1420. public:
  1421. MSVCProjectExporterVC2015 (Project& p, const ValueTree& t)
  1422. : MSVCProjectExporterBase (p, t, "VisualStudio2015")
  1423. {
  1424. name = getName();
  1425. }
  1426. static const char* getName() { return "Visual Studio 2015"; }
  1427. static const char* getValueTreeTypeName() { return "VS2015"; }
  1428. int getVisualStudioVersion() const override { return 14; }
  1429. String getSolutionComment() const override { return "# Visual Studio 2015"; }
  1430. String getToolsVersion() const override { return "14.0"; }
  1431. String getDefaultToolset() const override { return "v140"; }
  1432. String getDefaultWindowsTargetPlatformVersion() const override { return "8.1"; }
  1433. static MSVCProjectExporterVC2015* createForSettings (Project& project, const ValueTree& settings)
  1434. {
  1435. if (settings.hasType (getValueTreeTypeName()))
  1436. return new MSVCProjectExporterVC2015 (project, settings);
  1437. return nullptr;
  1438. }
  1439. void createExporterProperties (PropertyListBuilder& props) override
  1440. {
  1441. MSVCProjectExporterBase::createExporterProperties (props);
  1442. static const char* toolsetNames[] = { "(default)", "v140", "v140_xp", "CTP_Nov2013" };
  1443. const var toolsets[] = { var(), "v140", "v140_xp", "CTP_Nov2013" };
  1444. addToolsetProperty (props, toolsetNames, toolsets, numElementsInArray (toolsets));
  1445. addIPPLibraryProperty (props);
  1446. addWindowsTargetPlatformProperties (props);
  1447. }
  1448. JUCE_DECLARE_NON_COPYABLE (MSVCProjectExporterVC2015)
  1449. };
  1450. //==============================================================================
  1451. class MSVCProjectExporterVC2017 : public MSVCProjectExporterBase
  1452. {
  1453. public:
  1454. MSVCProjectExporterVC2017 (Project& p, const ValueTree& t)
  1455. : MSVCProjectExporterBase (p, t, "VisualStudio2017")
  1456. {
  1457. name = getName();
  1458. }
  1459. static const char* getName() { return "Visual Studio 2017"; }
  1460. static const char* getValueTreeTypeName() { return "VS2017"; }
  1461. int getVisualStudioVersion() const override { return 15; }
  1462. String getSolutionComment() const override { return "# Visual Studio 2017"; }
  1463. String getToolsVersion() const override { return "15.0"; }
  1464. String getDefaultToolset() const override { return "v141"; }
  1465. String getDefaultWindowsTargetPlatformVersion() const override { return "10.0.15063.0"; }
  1466. static MSVCProjectExporterVC2017* createForSettings (Project& project, const ValueTree& settings)
  1467. {
  1468. if (settings.hasType (getValueTreeTypeName()))
  1469. return new MSVCProjectExporterVC2017 (project, settings);
  1470. return nullptr;
  1471. }
  1472. void createExporterProperties (PropertyListBuilder& props) override
  1473. {
  1474. MSVCProjectExporterBase::createExporterProperties (props);
  1475. static const char* toolsetNames[] = { "(default)", "v140", "v140_xp", "v141", "v141_xp" };
  1476. const var toolsets[] = { var(), "v140", "v140_xp", "v141", "v141_xp" };
  1477. addToolsetProperty (props, toolsetNames, toolsets, numElementsInArray (toolsets));
  1478. addIPPLibraryProperty (props);
  1479. addWindowsTargetPlatformProperties (props);
  1480. }
  1481. JUCE_DECLARE_NON_COPYABLE (MSVCProjectExporterVC2017)
  1482. };