1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-16 15:24:10 +02:00
Beef/IDE/src/util/TargetTriple.bf
Brian Fiete 3883a3674d Added Android support, and generalized target triple support
Added PICLevel, RelocKind
DarwinCommon/LinuxCommon/AndroidCommon merged into PosixCommon
Mangling changed to avoid '@'
2019-10-23 07:12:36 -07:00

55 lines
897 B
Beef

using System;
namespace IDE.Util
{
class TargetTriple
{
public static bool IsTargetTriple(StringView str)
{
int dashCount = 0;
for (let c in str.RawChars)
if (c == '-')
dashCount++;
return dashCount >= 2;
}
public static Workspace.PlatformType GetPlatformType(StringView str)
{
var str;
// Remove version from the end
while (!str.IsEmpty)
{
char8 c = str[str.Length - 1];
if ((c.IsDigit) || (c == '.'))
str.RemoveFromEnd(1);
else
break;
}
bool hasLinux = false;
for (let elem in str.Split('-'))
{
switch (elem)
{
case "linux":
hasLinux = true;
case "windows":
return .Windows;
case "macosx":
return .macOS;
case "ios":
return .iOS;
case "android",
"androideabi":
return .Android;
}
}
if (hasLinux)
return .Linux;
return .Unknown;
}
}
}