Skip to content

Commit 0961fbf

Browse files
authored
Merge pull request #160 from seal-runtime/env-arch-157
2 parents 2970405 + 8c319d1 commit 0961fbf

File tree

4 files changed

+185
-4
lines changed

4 files changed

+185
-4
lines changed

.seal/typedefs/std/env/init.luau

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ export type env = {
55
--- a list of arguments passed to the program
66
args: { string },
77
--- your operating system
8-
os: "Windows" | "Linux" | "Android" | "MacOS" | "Other",
9-
--- the path of the executable
8+
os: "Windows" | "Linux" | "Android" | "MacOS" | string,
9+
--- your system architecture, most likely `"x86_64"`
10+
arch: ARCH,
11+
--- path to the executable running your code; either *seal* itself or a compiled standalone version of *seal*.
1012
executable_path: string,
1113
--[=[
1214
Get the current working directory of the running process.
@@ -34,4 +36,27 @@ export type env = {
3436
vars: typeof(require("@self/vars"))
3537
}
3638

39+
--- Your CPU processors' architecture; probably `"x86_64"`.
40+
export type ARCH =
41+
| "x86"
42+
| "x86_64"
43+
| "arm"
44+
| "aarch64"
45+
| "m68k"
46+
| "mips"
47+
| "mips32r6"
48+
| "mips64"
49+
| "mips64r6"
50+
| "csky"
51+
| "powerpc"
52+
| "powerpc64"
53+
| "riscv32"
54+
| "riscv64"
55+
| "s390x"
56+
| "sparc"
57+
| "sparc64"
58+
| "hexagon"
59+
| "loongarch32"
60+
| "loongarch64"
61+
3762
return {} :: env

docs/reference/std/env/init.md

Lines changed: 150 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ args: { string },
2828
<h4>
2929

3030
```luau
31-
os: "Windows" | "Linux" | "Android" | "MacOS" | "Other",
31+
os: "Windows" | "Linux" | "Android" | "MacOS" | string,
3232
```
3333

3434
</h4>
@@ -37,6 +37,20 @@ os: "Windows" | "Linux" | "Android" | "MacOS" | "Other",
3737

3838
---
3939

40+
### env.arch
41+
42+
<h4>
43+
44+
```luau
45+
arch: ARCH,
46+
```
47+
48+
</h4>
49+
50+
your system architecture, most likely `"x86_64"`
51+
52+
---
53+
4054
### env.executable_path
4155

4256
<h4>
@@ -47,7 +61,7 @@ executable_path: string,
4761

4862
</h4>
4963

50-
the path of the executable
64+
path to the executable running your code; either *seal* itself or a compiled standalone version of *seal*.
5165

5266
---
5367

@@ -79,6 +93,140 @@ vars: typeof(require("@self/vars"))
7993

8094
---
8195

96+
## `export type` ARCH
97+
98+
<h4>
99+
100+
```luau
101+
export type ARCH =
102+
```
103+
104+
</h4>
105+
106+
Your CPU processors' architecture; probably `"x86_64"`.
107+
108+
---
109+
110+
```luau
111+
| "x86"
112+
```
113+
114+
---
115+
116+
```luau
117+
| "x86_64"
118+
```
119+
120+
---
121+
122+
```luau
123+
| "arm"
124+
```
125+
126+
---
127+
128+
```luau
129+
| "aarch64"
130+
```
131+
132+
---
133+
134+
```luau
135+
| "m68k"
136+
```
137+
138+
---
139+
140+
```luau
141+
| "mips"
142+
```
143+
144+
---
145+
146+
```luau
147+
| "mips32r6"
148+
```
149+
150+
---
151+
152+
```luau
153+
| "mips64"
154+
```
155+
156+
---
157+
158+
```luau
159+
| "mips64r6"
160+
```
161+
162+
---
163+
164+
```luau
165+
| "csky"
166+
```
167+
168+
---
169+
170+
```luau
171+
| "powerpc"
172+
```
173+
174+
---
175+
176+
```luau
177+
| "powerpc64"
178+
```
179+
180+
---
181+
182+
```luau
183+
| "riscv32"
184+
```
185+
186+
---
187+
188+
```luau
189+
| "riscv64"
190+
```
191+
192+
---
193+
194+
```luau
195+
| "s390x"
196+
```
197+
198+
---
199+
200+
```luau
201+
| "sparc"
202+
```
203+
204+
---
205+
206+
```luau
207+
| "sparc64"
208+
```
209+
210+
---
211+
212+
```luau
213+
| "hexagon"
214+
```
215+
216+
---
217+
218+
```luau
219+
| "loongarch32"
220+
```
221+
222+
---
223+
224+
```luau
225+
| "loongarch64"
226+
```
227+
228+
---
229+
82230
Autogenerated from [std/env/init.luau](/.seal/typedefs/std/env/init.luau).
83231

84232
*seal* is best experienced with inline, in-editor documentation. Please see the linked typedefs file if this documentation is confusing, too verbose, or inaccurate.

src/std_env/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ pub fn create(luau: &Lua) -> LuaResult<LuaTable> {
210210

211211
TableBuilder::create(luau)?
212212
.with_value("os", formatted_os)?
213+
.with_value("arch", env::consts::ARCH)?
213214
.with_value("args", luau_args)?
214215
.with_value("executable_path", executable_path)?
215216
.with_value("shell_path", get_current_shell())?

tests/luau/std/env.luau

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
local env = require("@std/env")
22
local _vars = require("@std/env/vars")
33

4+
local function consts()
5+
assert(env.os ~= nil, "we should have an env.os")
6+
assert(env.arch ~= nil, "we should have an env.arch")
7+
end
8+
9+
consts()
10+
411
local function iterate_args()
512
for _, arg in env.args do
613
print(arg)

0 commit comments

Comments
 (0)