Skip to content

Commit

Permalink
Fixes Issue 19212 - Add versions for C++ runtimes.
Browse files Browse the repository at this point in the history
  • Loading branch information
TurkeyMan committed Sep 5, 2018
1 parent d6ad81d commit 69d1d1b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
5 changes: 5 additions & 0 deletions src/dmd/cond.d
Expand Up @@ -653,6 +653,11 @@ extern (C++) final class VersionCondition : DVCondition
case "CRuntime_Microsoft":
case "CRuntime_Musl":
case "CRuntime_UClibc":
case "CppRuntime_Clang":
case "CppRuntime_DigitalMars":
case "CppRuntime_Gcc":
case "CppRuntime_Microsoft":
case "CppRuntime_Sun":
case "unittest":
case "assert":
case "all":
Expand Down
30 changes: 17 additions & 13 deletions src/dmd/mars.d
Expand Up @@ -1307,18 +1307,30 @@ void addDefaultVersionIdentifiers(const ref Param params)
if (params.isWindows)
{
VersionCondition.addPredefinedGlobalIdent("Windows");
if (global.params.mscoff)
{
VersionCondition.addPredefinedGlobalIdent("CRuntime_Microsoft");
VersionCondition.addPredefinedGlobalIdent("CppRuntime_Microsoft");
}
else
{
VersionCondition.addPredefinedGlobalIdent("CRuntime_DigitalMars");
VersionCondition.addPredefinedGlobalIdent("CppRuntime_DigitalMars");
}
}
else if (params.isLinux)
{
VersionCondition.addPredefinedGlobalIdent("Posix");
VersionCondition.addPredefinedGlobalIdent("linux");
VersionCondition.addPredefinedGlobalIdent("ELFv1");
VersionCondition.addPredefinedGlobalIdent("CRuntime_Glibc");
VersionCondition.addPredefinedGlobalIdent("CppRuntime_Gcc");
}
else if (params.isOSX)
{
VersionCondition.addPredefinedGlobalIdent("Posix");
VersionCondition.addPredefinedGlobalIdent("OSX");

VersionCondition.addPredefinedGlobalIdent("CppRuntime_Clang");
// For legacy compatibility
VersionCondition.addPredefinedGlobalIdent("darwin");
}
Expand All @@ -1327,24 +1339,28 @@ void addDefaultVersionIdentifiers(const ref Param params)
VersionCondition.addPredefinedGlobalIdent("Posix");
VersionCondition.addPredefinedGlobalIdent("FreeBSD");
VersionCondition.addPredefinedGlobalIdent("ELFv1");
VersionCondition.addPredefinedGlobalIdent("CppRuntime_Clang");
}
else if (params.isOpenBSD)
{
VersionCondition.addPredefinedGlobalIdent("Posix");
VersionCondition.addPredefinedGlobalIdent("OpenBSD");
VersionCondition.addPredefinedGlobalIdent("ELFv1");
VersionCondition.addPredefinedGlobalIdent("CppRuntime_Gcc");
}
else if (params.isDragonFlyBSD)
{
VersionCondition.addPredefinedGlobalIdent("Posix");
VersionCondition.addPredefinedGlobalIdent("DragonFlyBSD");
VersionCondition.addPredefinedGlobalIdent("ELFv1");
VersionCondition.addPredefinedGlobalIdent("CppRuntime_Gcc");
}
else if (params.isSolaris)
{
VersionCondition.addPredefinedGlobalIdent("Posix");
VersionCondition.addPredefinedGlobalIdent("Solaris");
VersionCondition.addPredefinedGlobalIdent("ELFv1");
VersionCondition.addPredefinedGlobalIdent("CppRuntime_Sun");
}
else
{
Expand Down Expand Up @@ -1383,18 +1399,6 @@ void addDefaultVersionIdentifiers(const ref Param params)
}
}

if (params.isWindows)
{
if (params.mscoff)
VersionCondition.addPredefinedGlobalIdent("CRuntime_Microsoft");
else
VersionCondition.addPredefinedGlobalIdent("CRuntime_DigitalMars");
}
else if (params.isLinux)
{
VersionCondition.addPredefinedGlobalIdent("CRuntime_Glibc");
}

if (params.isLP64)
VersionCondition.addPredefinedGlobalIdent("D_LP64");
if (params.doDocComments)
Expand Down

0 comments on commit 69d1d1b

Please sign in to comment.