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.

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