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.

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