aboutsummaryrefslogtreecommitdiff
path: root/src/server/when.odin
diff options
context:
space:
mode:
authorDanielGavin <danielgavin5@hotmail.com>2025-06-22 23:06:13 +0200
committerDanielGavin <danielgavin5@hotmail.com>2025-06-22 23:06:13 +0200
commit3d1b2a5d7849c16dac4acea8b205af15be3351f4 (patch)
treee30deffd287d5b746fbd8fb7d951a95b942e8c74 /src/server/when.odin
parentce13ab49907f45331260454477d2c22856baf633 (diff)
Start working on caching the packages of your project that are not used yet.
Diffstat (limited to 'src/server/when.odin')
-rw-r--r--src/server/when.odin26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/server/when.odin b/src/server/when.odin
index cf31bf0..e712596 100644
--- a/src/server/when.odin
+++ b/src/server/when.odin
@@ -1,5 +1,7 @@
+#+feature dynamic-literals
package server
+import "base:runtime"
import "core:fmt"
import "core:log"
import "core:odin/ast"
@@ -14,11 +16,33 @@ When_Expr :: union {
^ast.Expr,
}
+//Because we use configuration with os names that match the files instead of the enum, i.e. my_file_windows.odin, we have to convert back and fourth.
+@(private = "file")
+convert_os_string: map[string]string = {
+ "windows" = "Windows",
+ "darwin" = "Darwin",
+ "linux" = "Linux",
+ "essence" = "Essence",
+ "freebsd" = "FreeBSD",
+ "wasi" = "WASI",
+ "js" = "JS",
+ "freestanding" = "Freestanding",
+ "haiku" = "Haiku",
+ "openbsd" = "OpenBSD",
+ "netbsd" = "NetBSD",
+ "freebsd" = "FreeBSD",
+}
+
resolve_when_ident :: proc(when_expr_map: map[string]When_Expr, ident: string) -> (When_Expr, bool) {
switch ident {
case "ODIN_OS":
if common.config.profile.os != "" {
- return common.config.profile.os, true
+ os, ok := convert_os_string[common.config.profile.os]
+ if ok {
+ return os, true
+ } else {
+ return fmt.tprint(ODIN_OS), true
+ }
} else {
return fmt.tprint(ODIN_OS), true
}