79 lines
1.8 KiB
C++
79 lines
1.8 KiB
C++
#include "target.h"
|
|
#include "tier1/commandline.h"
|
|
#include "tier1/utlstring.h"
|
|
|
|
|
|
CUtlString Target_t::GetTriplet()
|
|
{
|
|
CUtlString triplet = "";
|
|
|
|
if ( cpu == TARGET_CPU_AMD64 )
|
|
triplet.AppendTail("x86_64");
|
|
if ( cpu == TARGET_CPU_AARCH64 )
|
|
triplet.AppendTail("aarch64");
|
|
triplet.AppendTail("-");
|
|
if ( kernel == TARGET_KERNEL_WINDOWS )
|
|
triplet.AppendTail("pc-windows-gnu");
|
|
if ( kernel == TARGET_KERNEL_LINUX )
|
|
triplet.AppendTail("unknown-linux-gnu");
|
|
if ( kernel == TARGET_KERNEL_DARWIN )
|
|
triplet.AppendTail("apple-darwin");
|
|
if ( kernel == TARGET_KERNEL_IOS )
|
|
triplet.AppendTail("apple-ios");
|
|
|
|
|
|
return triplet;
|
|
}
|
|
Target_t Target_t::HostTarget()
|
|
{
|
|
ETargetKernel kernel =
|
|
#if defined(__linux__)
|
|
TARGET_KERNEL_LINUX
|
|
#elif defined(__APPLE__)
|
|
TARGET_KERNEL_DARWIN
|
|
#endif
|
|
;
|
|
ETargetCPU cpu = TARGET_CPU_AMD64;
|
|
return {
|
|
.kernel = kernel,
|
|
.cpu = cpu,
|
|
.optimization = TARGET_DEBUG,
|
|
};
|
|
};
|
|
Target_t Target_t::DefaultTarget()
|
|
{
|
|
CUtlString szDevice = ICommandLine::ParamValue("-device");
|
|
CUtlString szOS = ICommandLine::ParamValue("-os");
|
|
CUtlString szArch = ICommandLine::ParamValue("-arch");
|
|
|
|
ETargetKernel kernel =
|
|
#if defined(__linux__)
|
|
TARGET_KERNEL_LINUX
|
|
#elif defined(__APPLE__)
|
|
TARGET_KERNEL_DARWIN
|
|
#endif
|
|
;
|
|
ETargetCPU cpu = TARGET_CPU_AMD64;
|
|
if ( szArch == "x86_64" )
|
|
cpu = TARGET_CPU_AMD64;
|
|
else if ( szArch == "aarch64" )
|
|
cpu = TARGET_CPU_AARCH64;
|
|
|
|
if ( szOS == "windows" )
|
|
kernel = TARGET_KERNEL_WINDOWS;
|
|
else if ( szOS == "linux" )
|
|
kernel = TARGET_KERNEL_LINUX;
|
|
else if ( szOS == "macos" )
|
|
kernel = TARGET_KERNEL_DARWIN;
|
|
else if ( szOS == "ios" )
|
|
kernel = TARGET_KERNEL_IOS;
|
|
else if ( szOS != 0 )
|
|
V_printf("Unknown OS: %s\n", szOS.GetString());
|
|
|
|
return {
|
|
.kernel = kernel,
|
|
.cpu = cpu,
|
|
.optimization = TARGET_DEBUG,
|
|
};
|
|
}
|