Platform API
Platform detection helpers are available under ptool.platform and p.platform.
ptool.platform.os
v0.1.0- Introduced.
ptool.platform.os() returns the operating system of the current machine.
- Returns:
linux | macos | windows.
print(ptool.platform.os()) -- macos
Behavior:
- This reports the local machine running
ptool run. ptoolcurrently exposeslinux,macos, andwindows.
ptool.platform.arch
v0.1.0- Introduced.
ptool.platform.arch() returns the CPU architecture of the current machine.
- Returns:
amd64 | arm64 | x86 | arm | riscv64.
print(ptool.platform.arch()) -- arm64
Behavior:
x86_64is exposed asamd64.aarch64is exposed asarm64.- 32-bit x86 variants such as
x86andi686are exposed asx86. - 32-bit ARM variants such as
armv7lare exposed asarm. riscv64is exposed asriscv64.
ptool.platform.target
v0.1.0- Introduced.
ptool.platform.target() returns a normalized platform target string for the
current machine.
- Returns:
string.
local target = ptool.platform.target()
print(target) -- linux-riscv64
Behavior:
- The result is always
ptool.platform.os() .. "-" .. ptool.platform.arch(). - This is intended for platform-based branching such as selecting download artifacts.
- Common values include
linux-amd64,linux-arm64,linux-x86,linux-arm,linux-riscv64,macos-amd64,macos-arm64, andwindows-amd64.