Browse Source

Projucer: Allow VS project variables in the Extra Libraries field

This change allows users to use macro values defined by Visual Studio in
library names, which might be useful e.g. when selecting different
libraries based on the build configuration.

If the filename of a library contains a special character that would
have a special meaning in the Visual Studio project file, you must use
the ASCII escape sequence for this character instead ("$" becomes "%24",
"%" becomes "%25").

This escaping will happen automatically for non-user-specified library
dependencies, including windows libraries specified in module header
blocks, and the plugin shared code target.
v6.1.6
reuk 3 years ago
parent
commit
1dc4db581d
1 changed files with 22 additions and 13 deletions
  1. +22
    -13
      extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_MSVC.h

+ 22
- 13
extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_MSVC.h View File

@@ -34,6 +34,14 @@ inline String msBuildEscape (String str)
return str;
}
inline StringArray msBuildEscape (StringArray range)
{
for (auto& i : range)
i = msBuildEscape (i);
return range;
}
//==============================================================================
class MSVCProjectExporterBase : public ProjectExporter
{
@@ -509,7 +517,6 @@ public:
intdir->addTextElement (build_tools::windowsStylePath (intermediatesPath));
}
{
auto* targetName = props->createNewChildElement ("TargetName");
setConditionAttribute (*targetName, config);
@@ -1332,23 +1339,25 @@ public:
return librarySearchPaths;
}
/* Libraries specified in the Projucer don't get escaped automatically.
To include a special character in the name of a library,
you must use the appropriate escape code instead.
Module and shared code library names are not preprocessed.
Special characters in the names of these libraries will be toEscape
as appropriate.
*/
StringArray getExternalLibraries (const MSVCBuildConfiguration& config, const StringArray& otherLibs) const
{
const auto sharedCodeLib = [&]() -> StringArray
{
if (type != SharedCodeTarget)
if (auto* shared = getOwner().getSharedCodeTarget())
return { shared->getBinaryNameWithSuffix (config, false) };
return {};
}();
auto result = otherLibs;
result.addArray (getOwner().getModuleLibs());
result.addArray (sharedCodeLib);
for (auto& i : result)
i = msBuildEscape (getOwner().replacePreprocessorTokens (config, i).trim());
i = getOwner().replacePreprocessorTokens (config, i).trim();
result.addArray (msBuildEscape (getOwner().getModuleLibs()));
if (type != SharedCodeTarget)
if (auto* shared = getOwner().getSharedCodeTarget())
result.add (msBuildEscape (shared->getBinaryNameWithSuffix (config, false)));
return result;
}


Loading…
Cancel
Save