scoop:scoop.platform:0.1.0
src/system/target.scoop
Selected production source · src/system/target.scoop
1
package scoop.platform.system3
/** The operating-system family selected by the compilation target. */4
public enum OperatingSystem {5
/** The Darwin operating-system family. */6
Darwin,7
/** The Linux operating-system family. */8
Linux,9
/** The Windows operating-system family. */10
Windows11
}13
/** The processor architecture selected by the compilation target. */14
public enum Architecture {15
/** The 64-bit Arm architecture. */16
Aarch64,17
/** The 64-bit x86 architecture. */18
X86_6419
}21
/** The operating-system family of the compiled target. */22
public val operatingSystem: OperatingSystem = currentOperatingSystem()24
/** The architecture of the compiled target. */25
public val architecture: Architecture = currentArchitecture()27
private fun currentOperatingSystem(): OperatingSystem {28
@Unsafe29
{30
return when (nativeOperatingSystem()) {31
case 0 -> OperatingSystem.Darwin32
case 1 -> OperatingSystem.Linux33
else -> OperatingSystem.Windows34
}35
}36
}38
private fun currentArchitecture(): Architecture {39
@Unsafe40
{41
return if (nativeArchitecture() == 0)42
Architecture.Aarch6443
else44
Architecture.X86_6445
}46
}48
@GCLeaf49
@Extern(name = "scoop_platform_operating_system")50
private fun nativeOperatingSystem(): Int52
@GCLeaf53
@Extern(name = "scoop_platform_architecture")54
private fun nativeArchitecture(): Int