Scoop API

scoop:scoop.platform:0.1.0

src/system/target.scoop

Selected production source · src/system/target.scoop

1package scoop.platform.system
3/** The operating-system family selected by the compilation target. */
4public 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 Windows
13/** The processor architecture selected by the compilation target. */
14public enum Architecture {
15 /** The 64-bit Arm architecture. */
16 Aarch64,
17 /** The 64-bit x86 architecture. */
18 X86_64
21/** The operating-system family of the compiled target. */
22public val operatingSystem: OperatingSystem = currentOperatingSystem()
24/** The architecture of the compiled target. */
25public val architecture: Architecture = currentArchitecture()
27private fun currentOperatingSystem(): OperatingSystem {
28 @Unsafe
29 {
30 return when (nativeOperatingSystem()) {
31 case 0 -> OperatingSystem.Darwin
32 case 1 -> OperatingSystem.Linux
33 else -> OperatingSystem.Windows
34 }
35 }
38private fun currentArchitecture(): Architecture {
39 @Unsafe
40 {
41 return if (nativeArchitecture() == 0)
42 Architecture.Aarch64
43 else
44 Architecture.X86_64
45 }
48@GCLeaf
49@Extern(name = "scoop_platform_operating_system")
50private fun nativeOperatingSystem(): Int
52@GCLeaf
53@Extern(name = "scoop_platform_architecture")
54private fun nativeArchitecture(): Int