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