1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-17 07:44:09 +02:00
Beef/IDE/src/util/TargetTriple.bf

56 lines
897 B
Beef
Raw Normal View History

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;
}
}
}