@shd101wyy/yo 0.0.27 → 0.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/out/cjs/index.cjs +513 -513
- package/out/cjs/yo-cli.cjs +677 -552
- package/out/esm/index.mjs +478 -478
- package/out/types/src/build-runner.d.ts +22 -0
- package/out/types/src/cache.d.ts +3 -0
- package/out/types/src/codegen/codegen-c.d.ts +3 -0
- package/out/types/src/codegen/index.d.ts +4 -0
- package/out/types/src/codegen/utils/index.d.ts +3 -0
- package/out/types/src/evaluator/builtins/build.d.ts +135 -0
- package/out/types/src/expr.d.ts +17 -0
- package/out/types/src/fetch-command.d.ts +6 -0
- package/out/types/src/fetch.d.ts +10 -0
- package/out/types/src/init.d.ts +5 -0
- package/out/types/src/install-command.d.ts +6 -0
- package/out/types/src/lock-file.d.ts +16 -0
- package/out/types/src/module-manager.d.ts +3 -1
- package/out/types/src/pkg-config.d.ts +11 -0
- package/out/types/src/target.d.ts +28 -0
- package/out/types/src/tests/build-system.test.d.ts +1 -0
- package/out/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/std/build.yo +287 -0
- package/std/crypto/random.yo +2 -2
- package/std/fs/dir.yo +1 -1
- package/std/fs/temp.yo +1 -1
- package/std/os/env.yo +5 -5
- package/std/os/signal.yo +8 -8
- package/std/path.yo +2 -2
- package/std/process.yo +23 -43
- package/std/regex/compiler.yo +355 -0
- package/std/regex/flags.yo +104 -0
- package/std/regex/match.yo +83 -0
- package/std/regex/node.yo +283 -0
- package/std/regex/parser.yo +847 -0
- package/std/regex/regex.yo +714 -0
- package/std/regex/unicode.yo +365 -0
- package/std/regex/vm.yo +737 -0
- package/std/sys/clock.yo +1 -1
- package/std/sys/constants.yo +3 -3
- package/std/sys/mmap.yo +2 -2
- package/std/sys/signals.yo +4 -4
- package/std/sys/socket.yo +25 -25
- package/std/sys/sysinfo.yo +4 -4
- package/std/time/sleep.yo +18 -0
- package/std/time.yo +0 -13
package/package.json
CHANGED
package/std/build.yo
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
// Build System Module
|
|
2
|
+
//
|
|
3
|
+
// Provides the declarative build API for Yo projects.
|
|
4
|
+
// All functions are compile-time only — they register build artifacts
|
|
5
|
+
// and steps that the build runner uses to orchestrate compilation.
|
|
6
|
+
//
|
|
7
|
+
// Usage in build.yo:
|
|
8
|
+
// build :: import "std/build";
|
|
9
|
+
// build.project({ name: "my-app", root: "./src/lib.yo" });
|
|
10
|
+
// exe :: build.executable({ name: "my-app", root: "./src/main.yo" });
|
|
11
|
+
// install :: build.step("install", "Build all artifacts");
|
|
12
|
+
// install.depend_on(exe);
|
|
13
|
+
|
|
14
|
+
// ── Optimization levels ──────────────────────────────────────────────
|
|
15
|
+
|
|
16
|
+
Optimize :: enum(
|
|
17
|
+
Debug,
|
|
18
|
+
ReleaseSafe,
|
|
19
|
+
ReleaseFast,
|
|
20
|
+
ReleaseSmall
|
|
21
|
+
);
|
|
22
|
+
export Optimize;
|
|
23
|
+
|
|
24
|
+
// ── Memory allocators ────────────────────────────────────────────────
|
|
25
|
+
|
|
26
|
+
Allocator :: enum(
|
|
27
|
+
Mimalloc,
|
|
28
|
+
Libc
|
|
29
|
+
);
|
|
30
|
+
export Allocator;
|
|
31
|
+
|
|
32
|
+
// ── Sanitizers ───────────────────────────────────────────────────────
|
|
33
|
+
|
|
34
|
+
Sanitize :: enum(
|
|
35
|
+
None,
|
|
36
|
+
Address,
|
|
37
|
+
Leak
|
|
38
|
+
);
|
|
39
|
+
export Sanitize;
|
|
40
|
+
|
|
41
|
+
// ── Step kinds ───────────────────────────────────────────────────────
|
|
42
|
+
|
|
43
|
+
StepKind :: enum(
|
|
44
|
+
Executable,
|
|
45
|
+
StaticLibrary,
|
|
46
|
+
SharedLibrary,
|
|
47
|
+
SystemLibrary,
|
|
48
|
+
TestSuite,
|
|
49
|
+
Run,
|
|
50
|
+
Custom
|
|
51
|
+
);
|
|
52
|
+
export StepKind;
|
|
53
|
+
|
|
54
|
+
// ── Target utilities ─────────────────────────────────────────────────
|
|
55
|
+
|
|
56
|
+
target_host :: __yo_build_target_host();
|
|
57
|
+
export target_host;
|
|
58
|
+
|
|
59
|
+
// ── Config struct types ──────────────────────────────────────────────
|
|
60
|
+
// Struct types with defaults, like Zig's options structs.
|
|
61
|
+
// Usage: build.executable({ name: "app", root: "./src/main.yo" })
|
|
62
|
+
// Unspecified fields get their default values.
|
|
63
|
+
|
|
64
|
+
Project :: struct(
|
|
65
|
+
name : comptime_string,
|
|
66
|
+
(root : comptime_string) ?= "./src/lib.yo"
|
|
67
|
+
);
|
|
68
|
+
export Project;
|
|
69
|
+
|
|
70
|
+
Executable :: struct(
|
|
71
|
+
name : comptime_string,
|
|
72
|
+
root : comptime_string,
|
|
73
|
+
(target : comptime_string) ?= __yo_build_target_host(),
|
|
74
|
+
(optimize : Optimize) ?= Optimize.Debug,
|
|
75
|
+
(allocator : Allocator) ?= Allocator.Mimalloc,
|
|
76
|
+
(sanitize : Sanitize) ?= Sanitize.None
|
|
77
|
+
);
|
|
78
|
+
export Executable;
|
|
79
|
+
|
|
80
|
+
StaticLibrary :: struct(
|
|
81
|
+
name : comptime_string,
|
|
82
|
+
root : comptime_string,
|
|
83
|
+
(target : comptime_string) ?= __yo_build_target_host(),
|
|
84
|
+
(optimize : Optimize) ?= Optimize.Debug
|
|
85
|
+
);
|
|
86
|
+
export StaticLibrary;
|
|
87
|
+
|
|
88
|
+
SharedLibrary :: struct(
|
|
89
|
+
name : comptime_string,
|
|
90
|
+
root : comptime_string,
|
|
91
|
+
(target : comptime_string) ?= __yo_build_target_host(),
|
|
92
|
+
(optimize : Optimize) ?= Optimize.Debug
|
|
93
|
+
);
|
|
94
|
+
export SharedLibrary;
|
|
95
|
+
|
|
96
|
+
TestSuite :: struct(
|
|
97
|
+
name : comptime_string,
|
|
98
|
+
root : comptime_string,
|
|
99
|
+
(target : comptime_string) ?= __yo_build_target_host()
|
|
100
|
+
);
|
|
101
|
+
export TestSuite;
|
|
102
|
+
|
|
103
|
+
// ── Step type ────────────────────────────────────────────────────────
|
|
104
|
+
// Returned by all build functions. Used to wire dependencies between steps.
|
|
105
|
+
|
|
106
|
+
Step :: struct(
|
|
107
|
+
name : comptime_string,
|
|
108
|
+
kind : StepKind
|
|
109
|
+
);
|
|
110
|
+
export Step;
|
|
111
|
+
|
|
112
|
+
// ── Step methods ─────────────────────────────────────────────────────
|
|
113
|
+
// Methods on Step for Zig-like API: step.depend_on(other), exe.link(lib).
|
|
114
|
+
|
|
115
|
+
impl(Step,
|
|
116
|
+
depend_on : (fn(comptime(self) : Self, comptime(dep) : Step) -> comptime(unit))({
|
|
117
|
+
__yo_build_step_depend_on(self.name, dep.name, dep.kind);
|
|
118
|
+
}),
|
|
119
|
+
link : (fn(comptime(self) : Self, comptime(library) : Step) -> comptime(unit))({
|
|
120
|
+
__yo_build_link(self.name, library.name);
|
|
121
|
+
})
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
// ── Build option config types ────────────────────────────────────────
|
|
125
|
+
// Like Zig's b.option(), declare user-configurable options.
|
|
126
|
+
// CLI usage: yo build -Dname=value
|
|
127
|
+
|
|
128
|
+
BuildOption :: struct(
|
|
129
|
+
name : comptime_string,
|
|
130
|
+
description : comptime_string,
|
|
131
|
+
(default : comptime_string) ?= ""
|
|
132
|
+
);
|
|
133
|
+
export BuildOption;
|
|
134
|
+
|
|
135
|
+
// ── Dependency config types ──────────────────────────────────────────
|
|
136
|
+
|
|
137
|
+
GitDependency :: struct(
|
|
138
|
+
name : comptime_string,
|
|
139
|
+
url : comptime_string,
|
|
140
|
+
(ref : comptime_string) ?= "HEAD",
|
|
141
|
+
(path : comptime_string) ?= ""
|
|
142
|
+
);
|
|
143
|
+
export GitDependency;
|
|
144
|
+
|
|
145
|
+
PathDependency :: struct(
|
|
146
|
+
name : comptime_string,
|
|
147
|
+
path : comptime_string
|
|
148
|
+
);
|
|
149
|
+
export PathDependency;
|
|
150
|
+
|
|
151
|
+
SystemLibrary :: struct(
|
|
152
|
+
name : comptime_string,
|
|
153
|
+
pkg_config : comptime_string,
|
|
154
|
+
(fallback_include : comptime_string) ?= "",
|
|
155
|
+
(fallback_lib : comptime_string) ?= "",
|
|
156
|
+
(fallback_link : comptime_string) ?= ""
|
|
157
|
+
);
|
|
158
|
+
export SystemLibrary;
|
|
159
|
+
|
|
160
|
+
// ── Dependency handle ────────────────────────────────────────────────
|
|
161
|
+
// Returned by build.dependency() and build.path_dependency().
|
|
162
|
+
// Provides access to artifacts defined in the dependency's build.yo.
|
|
163
|
+
|
|
164
|
+
Dependency :: struct(
|
|
165
|
+
name : comptime_string
|
|
166
|
+
);
|
|
167
|
+
export Dependency;
|
|
168
|
+
|
|
169
|
+
impl(Dependency,
|
|
170
|
+
// Access a named artifact from the dependency's build.yo.
|
|
171
|
+
// Returns a Step that can be linked to the consumer's artifacts.
|
|
172
|
+
artifact : (fn(comptime(self) : Self, comptime(artifact_name) : comptime_string) -> comptime(Step))({
|
|
173
|
+
__yo_build_dep_artifact(self.name, artifact_name);
|
|
174
|
+
Step(name: artifact_name, kind: StepKind.StaticLibrary)
|
|
175
|
+
})
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
// ── Build functions ──────────────────────────────────────────────────
|
|
179
|
+
// All registration functions return a Step value, allowing steps to be
|
|
180
|
+
// wired together as dependencies via step.depend_on(dep).
|
|
181
|
+
|
|
182
|
+
// Register project metadata.
|
|
183
|
+
project :: (fn(comptime(config) : Project) -> comptime(unit)) {
|
|
184
|
+
__yo_build_project(config.name, config.root);
|
|
185
|
+
};
|
|
186
|
+
export project;
|
|
187
|
+
|
|
188
|
+
// Register an executable artifact. Returns a Step for dependency wiring.
|
|
189
|
+
executable :: (fn(comptime(config) : Executable) -> comptime(Step)) {
|
|
190
|
+
opt_str :: match(config.optimize,
|
|
191
|
+
.Debug => "debug",
|
|
192
|
+
.ReleaseSafe => "release-safe",
|
|
193
|
+
.ReleaseFast => "release-fast",
|
|
194
|
+
.ReleaseSmall => "release-small"
|
|
195
|
+
);
|
|
196
|
+
alloc_str :: match(config.allocator,
|
|
197
|
+
.Mimalloc => "mimalloc",
|
|
198
|
+
.Libc => "libc"
|
|
199
|
+
);
|
|
200
|
+
san_str :: match(config.sanitize,
|
|
201
|
+
.None => "none",
|
|
202
|
+
.Address => "address",
|
|
203
|
+
.Leak => "leak"
|
|
204
|
+
);
|
|
205
|
+
__yo_build_executable(config.name, config.root, config.target, opt_str, alloc_str, san_str);
|
|
206
|
+
Step(name: config.name, kind: StepKind.Executable)
|
|
207
|
+
};
|
|
208
|
+
export executable;
|
|
209
|
+
|
|
210
|
+
// Register a static library artifact. Returns a Step for dependency wiring.
|
|
211
|
+
static_library :: (fn(comptime(config) : StaticLibrary) -> comptime(Step)) {
|
|
212
|
+
opt_str :: match(config.optimize,
|
|
213
|
+
.Debug => "debug",
|
|
214
|
+
.ReleaseSafe => "release-safe",
|
|
215
|
+
.ReleaseFast => "release-fast",
|
|
216
|
+
.ReleaseSmall => "release-small"
|
|
217
|
+
);
|
|
218
|
+
__yo_build_static_library(config.name, config.root, config.target, opt_str);
|
|
219
|
+
Step(name: config.name, kind: StepKind.StaticLibrary)
|
|
220
|
+
};
|
|
221
|
+
export static_library;
|
|
222
|
+
|
|
223
|
+
// Register a shared/dynamic library artifact. Returns a Step for dependency wiring.
|
|
224
|
+
shared_library :: (fn(comptime(config) : SharedLibrary) -> comptime(Step)) {
|
|
225
|
+
opt_str :: match(config.optimize,
|
|
226
|
+
.Debug => "debug",
|
|
227
|
+
.ReleaseSafe => "release-safe",
|
|
228
|
+
.ReleaseFast => "release-fast",
|
|
229
|
+
.ReleaseSmall => "release-small"
|
|
230
|
+
);
|
|
231
|
+
__yo_build_shared_library(config.name, config.root, config.target, opt_str);
|
|
232
|
+
Step(name: config.name, kind: StepKind.SharedLibrary)
|
|
233
|
+
};
|
|
234
|
+
export shared_library;
|
|
235
|
+
|
|
236
|
+
// Register a test suite. Returns a Step for dependency wiring.
|
|
237
|
+
test :: (fn(comptime(config) : TestSuite) -> comptime(Step)) {
|
|
238
|
+
__yo_build_test(config.name, config.root, config.target);
|
|
239
|
+
Step(name: config.name, kind: StepKind.TestSuite)
|
|
240
|
+
};
|
|
241
|
+
export test;
|
|
242
|
+
|
|
243
|
+
// Create a run step (compile + execute an artifact). Returns a Step.
|
|
244
|
+
run :: (fn(comptime(artifact) : Step) -> comptime(Step)) {
|
|
245
|
+
__yo_build_run(artifact.name);
|
|
246
|
+
Step(name: artifact.name, kind: StepKind.Run)
|
|
247
|
+
};
|
|
248
|
+
export run;
|
|
249
|
+
|
|
250
|
+
// Register a named build step. Use step.depend_on(dep) to add dependencies.
|
|
251
|
+
step :: (fn(
|
|
252
|
+
comptime(name) : comptime_string,
|
|
253
|
+
comptime(description) : comptime_string
|
|
254
|
+
) -> comptime(Step)) {
|
|
255
|
+
__yo_build_step(name, description);
|
|
256
|
+
Step(name: name, kind: StepKind.Custom)
|
|
257
|
+
};
|
|
258
|
+
export step;
|
|
259
|
+
|
|
260
|
+
// Register a git-hosted dependency. Returns a Dependency handle for accessing artifacts.
|
|
261
|
+
dependency :: (fn(comptime(config) : GitDependency) -> comptime(Dependency)) {
|
|
262
|
+
__yo_build_dependency(config.name, config.url, config.ref, config.path);
|
|
263
|
+
Dependency(name: config.name)
|
|
264
|
+
};
|
|
265
|
+
export dependency;
|
|
266
|
+
|
|
267
|
+
// Register a local path dependency. Returns a Dependency handle for accessing artifacts.
|
|
268
|
+
path_dependency :: (fn(comptime(config) : PathDependency) -> comptime(Dependency)) {
|
|
269
|
+
__yo_build_path_dependency(config.name, config.path);
|
|
270
|
+
Dependency(name: config.name)
|
|
271
|
+
};
|
|
272
|
+
export path_dependency;
|
|
273
|
+
|
|
274
|
+
// Register a system C library discovered via pkg-config. Returns a Step for linking.
|
|
275
|
+
system_library :: (fn(comptime(config) : SystemLibrary) -> comptime(Step)) {
|
|
276
|
+
__yo_build_system_library(config.name, config.pkg_config, config.fallback_include, config.fallback_lib, config.fallback_link);
|
|
277
|
+
Step(name: config.name, kind: StepKind.SystemLibrary)
|
|
278
|
+
};
|
|
279
|
+
export system_library;
|
|
280
|
+
|
|
281
|
+
// Declare a user-configurable build option.
|
|
282
|
+
// Returns the option value (from CLI -Dname=value, or the default).
|
|
283
|
+
// Usage: strip :: build.option({ name: "strip", description: "Strip debug symbols", default: "false" });
|
|
284
|
+
option :: (fn(comptime(config) : BuildOption) -> comptime(str))(
|
|
285
|
+
__yo_build_option(config.name, config.description, config.default)
|
|
286
|
+
);
|
|
287
|
+
export option;
|
package/std/crypto/random.yo
CHANGED
|
@@ -56,10 +56,10 @@ extern "Yo",
|
|
|
56
56
|
|
|
57
57
|
random_bytes :: (fn(buf: *(u8), size: usize, using(exn : Exception)) -> unit)(
|
|
58
58
|
cond(
|
|
59
|
-
(platform == Platform.
|
|
59
|
+
(platform == Platform.Macos) => {
|
|
60
60
|
__yo_arc4random_buf(buf, size);
|
|
61
61
|
},
|
|
62
|
-
(platform == Platform.
|
|
62
|
+
(platform == Platform.Windows) => {
|
|
63
63
|
r := __yo_bcrypt_gen_random(buf, u32(size));
|
|
64
64
|
cond(
|
|
65
65
|
(r == i32(0)) => (),
|
package/std/fs/dir.yo
CHANGED
|
@@ -105,7 +105,7 @@ create_dir_all :: (fn(path: Path, using(io : IO)) -> Impl(Future(unit, IO, Excep
|
|
|
105
105
|
// On Windows, skip past drive letter root (e.g., "C:\")
|
|
106
106
|
// to avoid trying to mkdir "C:" which fails with EACCES
|
|
107
107
|
cond(
|
|
108
|
-
(platform == Platform.
|
|
108
|
+
(platform == Platform.Windows) => {
|
|
109
109
|
cond(
|
|
110
110
|
(bytes.len() >= usize(3)) => {
|
|
111
111
|
first := bytes.get(usize(0)).unwrap();
|
package/std/fs/temp.yo
CHANGED
package/std/os/env.yo
CHANGED
|
@@ -18,7 +18,7 @@ open import "../string";
|
|
|
18
18
|
// Return the current user's home directory, or .None if unavailable.
|
|
19
19
|
home_dir :: (fn() -> Option(String))(
|
|
20
20
|
cond(
|
|
21
|
-
(platform == Platform.
|
|
21
|
+
(platform == Platform.Windows) => match(env.get(`USERPROFILE`),
|
|
22
22
|
.Some(p) => .Some(p),
|
|
23
23
|
.None => match(env.get(`HOMEDRIVE`),
|
|
24
24
|
.None => .None,
|
|
@@ -37,7 +37,7 @@ home_dir :: (fn() -> Option(String))(
|
|
|
37
37
|
// Windows: %APPDATA%
|
|
38
38
|
config_dir :: (fn() -> Option(String))(
|
|
39
39
|
cond(
|
|
40
|
-
(platform == Platform.
|
|
40
|
+
(platform == Platform.Windows) => env.get(`APPDATA`),
|
|
41
41
|
true => match(env.get(`XDG_CONFIG_HOME`),
|
|
42
42
|
.Some(d) => .Some(d),
|
|
43
43
|
.None => match(home_dir(),
|
|
@@ -54,8 +54,8 @@ config_dir :: (fn() -> Option(String))(
|
|
|
54
54
|
// Windows: %LOCALAPPDATA%
|
|
55
55
|
cache_dir :: (fn() -> Option(String))(
|
|
56
56
|
cond(
|
|
57
|
-
(platform == Platform.
|
|
58
|
-
(platform == Platform.
|
|
57
|
+
(platform == Platform.Windows) => env.get(`LOCALAPPDATA`),
|
|
58
|
+
(platform == Platform.Macos) => match(home_dir(),
|
|
59
59
|
.None => .None,
|
|
60
60
|
.Some(h) => .Some(h.concat(`/Library/Caches`))
|
|
61
61
|
),
|
|
@@ -72,7 +72,7 @@ cache_dir :: (fn() -> Option(String))(
|
|
|
72
72
|
// Return the system temporary directory.
|
|
73
73
|
temp_dir :: (fn() -> String)(
|
|
74
74
|
cond(
|
|
75
|
-
(platform == Platform.
|
|
75
|
+
(platform == Platform.Windows) => match(env.get(`TEMP`),
|
|
76
76
|
.Some(t) => t,
|
|
77
77
|
.None => `C:\Temp`
|
|
78
78
|
),
|
package/std/os/signal.yo
CHANGED
|
@@ -35,35 +35,35 @@ export Signal;
|
|
|
35
35
|
_signal_num :: (fn(sig: Signal) -> i32)(
|
|
36
36
|
match(sig,
|
|
37
37
|
.Interrupt => cond(
|
|
38
|
-
(platform == Platform.
|
|
38
|
+
(platform == Platform.Macos) => i32(2),
|
|
39
39
|
true => i32(2)
|
|
40
40
|
),
|
|
41
41
|
.Terminate => cond(
|
|
42
|
-
(platform == Platform.
|
|
42
|
+
(platform == Platform.Macos) => i32(15),
|
|
43
43
|
true => i32(15)
|
|
44
44
|
),
|
|
45
45
|
.Hangup => cond(
|
|
46
|
-
(platform == Platform.
|
|
46
|
+
(platform == Platform.Macos) => i32(1),
|
|
47
47
|
true => i32(1)
|
|
48
48
|
),
|
|
49
49
|
.User1 => cond(
|
|
50
|
-
(platform == Platform.
|
|
50
|
+
(platform == Platform.Macos) => i32(30),
|
|
51
51
|
true => i32(10)
|
|
52
52
|
),
|
|
53
53
|
.User2 => cond(
|
|
54
|
-
(platform == Platform.
|
|
54
|
+
(platform == Platform.Macos) => i32(31),
|
|
55
55
|
true => i32(12)
|
|
56
56
|
),
|
|
57
57
|
.Pipe => cond(
|
|
58
|
-
(platform == Platform.
|
|
58
|
+
(platform == Platform.Macos) => i32(13),
|
|
59
59
|
true => i32(13)
|
|
60
60
|
),
|
|
61
61
|
.Alarm => cond(
|
|
62
|
-
(platform == Platform.
|
|
62
|
+
(platform == Platform.Macos) => i32(14),
|
|
63
63
|
true => i32(14)
|
|
64
64
|
),
|
|
65
65
|
.Child => cond(
|
|
66
|
-
(platform == Platform.
|
|
66
|
+
(platform == Platform.Macos) => i32(20),
|
|
67
67
|
true => i32(17)
|
|
68
68
|
)
|
|
69
69
|
)
|
package/std/path.yo
CHANGED
|
@@ -21,7 +21,7 @@ export PathError;
|
|
|
21
21
|
* TODO: Support Windows paths later
|
|
22
22
|
*/
|
|
23
23
|
PATH_SEPARATOR :: cond(
|
|
24
|
-
(__yo_process_platform() == "
|
|
24
|
+
(__yo_process_platform() == "windows") => u8(92), // '\' for Windows
|
|
25
25
|
true => u8(47) // '/' for Unix
|
|
26
26
|
);
|
|
27
27
|
export PATH_SEPARATOR;
|
|
@@ -32,7 +32,7 @@ export PATH_SEPARATOR;
|
|
|
32
32
|
* TODO: Support Windows paths later
|
|
33
33
|
*/
|
|
34
34
|
PATH_DELIMITER :: cond(
|
|
35
|
-
(__yo_process_platform() == "
|
|
35
|
+
(__yo_process_platform() == "windows") => u8(59), // ';' for Windows
|
|
36
36
|
true => u8(58) // ':' for Unix
|
|
37
37
|
);
|
|
38
38
|
export PATH_DELIMITER;
|
package/std/process.yo
CHANGED
|
@@ -8,64 +8,44 @@ open import "./path";
|
|
|
8
8
|
{ malloc, free } :: GlobalAllocator;
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* - "aix"
|
|
14
|
-
* - "android"
|
|
15
|
-
* - "darwin" (macOS)
|
|
16
|
-
* - "freebsd"
|
|
11
|
+
* Target platform for the current compilation.
|
|
12
|
+
* Uses standard naming:
|
|
17
13
|
* - "linux"
|
|
18
|
-
* - "
|
|
19
|
-
* - "
|
|
20
|
-
* - "
|
|
14
|
+
* - "macos"
|
|
15
|
+
* - "windows"
|
|
16
|
+
* - "freebsd"
|
|
17
|
+
* - "wasi"
|
|
21
18
|
*/
|
|
22
19
|
platform :: __yo_process_platform();
|
|
23
20
|
export platform;
|
|
24
21
|
|
|
25
22
|
Platform :: {
|
|
26
|
-
Aix : "aix",
|
|
27
|
-
Android : "android",
|
|
28
|
-
Darwin : "darwin",
|
|
29
|
-
FreeBSD : "freebsd",
|
|
30
23
|
Linux : "linux",
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
Macos : "macos",
|
|
25
|
+
Windows : "windows",
|
|
26
|
+
FreeBSD : "freebsd",
|
|
27
|
+
Wasi : "wasi"
|
|
34
28
|
};
|
|
35
29
|
export Platform;
|
|
36
30
|
|
|
37
31
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
32
|
+
* Target architecture for the current compilation.
|
|
33
|
+
* Uses standard naming:
|
|
34
|
+
* - "x86_64"
|
|
35
|
+
* - "aarch64"
|
|
36
|
+
* - "x86"
|
|
40
37
|
* - "arm"
|
|
41
|
-
* - "
|
|
42
|
-
* - "ia32"
|
|
43
|
-
* - "loong64"
|
|
44
|
-
* - "mips"
|
|
45
|
-
* - "mipsel"
|
|
46
|
-
* - "ppc"
|
|
47
|
-
* - "ppc64"
|
|
48
|
-
* - "riscv64"
|
|
49
|
-
* - "s390"
|
|
50
|
-
* - "s390x"
|
|
51
|
-
* - "x64"
|
|
38
|
+
* - "wasm32"
|
|
52
39
|
*/
|
|
53
40
|
arch :: __yo_process_arch();
|
|
54
41
|
export arch;
|
|
55
42
|
|
|
56
43
|
Arch :: {
|
|
44
|
+
X86_64 : "x86_64",
|
|
45
|
+
Aarch64 : "aarch64",
|
|
46
|
+
X86 : "x86",
|
|
57
47
|
Arm : "arm",
|
|
58
|
-
|
|
59
|
-
Ia32 : "ia32",
|
|
60
|
-
Loong64 : "loong64",
|
|
61
|
-
Mips : "mips",
|
|
62
|
-
Mipsel : "mipsel",
|
|
63
|
-
Ppc : "ppc",
|
|
64
|
-
Ppc64 : "ppc64",
|
|
65
|
-
Riscv64 : "riscv64",
|
|
66
|
-
S390 : "s390",
|
|
67
|
-
S390x : "s390x",
|
|
68
|
-
X64 : "x64"
|
|
48
|
+
Wasm32 : "wasm32"
|
|
69
49
|
};
|
|
70
50
|
export Arch;
|
|
71
51
|
|
|
@@ -140,7 +120,7 @@ env :: impl {
|
|
|
140
120
|
value_cstr := value.to_cstr().ptr().unwrap();
|
|
141
121
|
|
|
142
122
|
result := cond(
|
|
143
|
-
(platform == Platform.
|
|
123
|
+
(platform == Platform.Windows) => {
|
|
144
124
|
// Windows: use _putenv_s (doesn't have overwrite parameter)
|
|
145
125
|
{ _putenv_s } :: import "./libc/windows";
|
|
146
126
|
|
|
@@ -180,7 +160,7 @@ export env;
|
|
|
180
160
|
*/
|
|
181
161
|
cwd :: (fn() -> Result(Path, String))(
|
|
182
162
|
cond(
|
|
183
|
-
(platform == Platform.
|
|
163
|
+
(platform == Platform.Windows) => {
|
|
184
164
|
// Windows implementation using GetCurrentDirectoryW
|
|
185
165
|
{ GetCurrentDirectoryW, WideCharToMultiByte, CP_UTF8, WCHAR, DWORD } :: import "./libc/windows";
|
|
186
166
|
|
|
@@ -289,7 +269,7 @@ export cwd;
|
|
|
289
269
|
*/
|
|
290
270
|
chdir :: (fn(path: Path) -> Result(unit, String))(
|
|
291
271
|
cond(
|
|
292
|
-
(platform == Platform.
|
|
272
|
+
(platform == Platform.Windows) => {
|
|
293
273
|
// Windows implementation using SetCurrentDirectoryA
|
|
294
274
|
{ SetCurrentDirectoryA, BOOL } :: import "./libc/windows";
|
|
295
275
|
|