diff options
| author | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-08-13 16:59:13 -0400 |
|---|---|---|
| committer | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-08-13 16:59:13 -0400 |
| commit | f0b81af6c273c0281e6802bc0f5af756f874cc9f (patch) | |
| tree | a14ed291dff84f2c921a5d557e586be7c3ec42b4 /src | |
| parent | 8c79828ef714d0219cf2585d33a4425cd6cb5370 (diff) | |
Add `odin_root_override` to ols config to allow a user to override the `ODIN_ROOT` `ols` uses
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/config.odin | 1 | ||||
| -rw-r--r-- | src/server/requests.odin | 68 | ||||
| -rw-r--r-- | src/server/types.odin | 1 |
3 files changed, 43 insertions, 27 deletions
diff --git a/src/common/config.odin b/src/common/config.odin index 9954262..103004a 100644 --- a/src/common/config.odin +++ b/src/common/config.odin @@ -38,6 +38,7 @@ Config :: struct { thread_count: int, file_log: bool, odin_command: string, + odin_root_override: string, checker_args: string, checker_targets: []string, client_name: string, diff --git a/src/server/requests.odin b/src/server/requests.odin index aeda500..0572a33 100644 --- a/src/server/requests.odin +++ b/src/server/requests.odin @@ -386,6 +386,16 @@ read_ols_initialize_options :: proc(config: ^common.Config, ols_config: OlsConfi } } + if ols_config.odin_root_override != "" { + config.odin_root_override = strings.clone(ols_config.odin_root_override, context.temp_allocator) + + allocated: bool + config.odin_root_override, allocated = common.resolve_home_dir(config.odin_root_override) + if !allocated { + config.odin_root_override = strings.clone(config.odin_root_override, context.allocator) + } + } + if ols_config.checker_args != "" { config.checker_args = strings.clone(ols_config.checker_args, context.allocator) } @@ -479,39 +489,43 @@ read_ols_initialize_options :: proc(config: ^common.Config, ols_config: OlsConfi // their config and it would break. odin_core_env: string - odin_bin := "odin" if config.odin_command == "" else config.odin_command - - // If we don't have an absolute path - if !filepath.is_abs(odin_bin) { - // Join with the project path - tmp_path := path.join(elems = {uri.path, odin_bin}) - if os.exists(tmp_path) { - odin_bin = tmp_path + if config.odin_root_override != "" { + odin_core_env = config.odin_root_override + } else { + odin_bin := "odin" if config.odin_command == "" else config.odin_command + + // If we don't have an absolute path + if !filepath.is_abs(odin_bin) { + // Join with the project path + tmp_path := path.join(elems = {uri.path, odin_bin}) + if os.exists(tmp_path) { + odin_bin = tmp_path + } } - } - root_buf: [1024]byte - root_slice := root_buf[:] - root_command := strings.concatenate({odin_bin, " root"}, context.temp_allocator) - code, ok, out := common.run_executable(root_command, &root_slice) - if ok && !strings.contains(string(out), "Usage") { - odin_core_env = string(out) - } else { - log.warnf("failed executing %q with code %v", root_command, code) + root_buf: [1024]byte + root_slice := root_buf[:] + root_command := strings.concatenate({odin_bin, " root"}, context.temp_allocator) + code, ok, out := common.run_executable(root_command, &root_slice) + if ok && !strings.contains(string(out), "Usage") { + odin_core_env = string(out) + } else { + log.warnf("failed executing %q with code %v", root_command, code) - // User is probably on an older Odin version, let's try our best. + // User is probably on an older Odin version, let's try our best. - odin_core_env = os.get_env("ODIN_ROOT", context.temp_allocator) - if odin_core_env == "" { - if os.exists(odin_bin) { - odin_core_env = filepath.dir(odin_bin, context.temp_allocator) - } else if exe_path, ok := common.lookup_in_path(odin_bin); ok { - odin_core_env = filepath.dir(exe_path, context.temp_allocator) + odin_core_env = os.get_env("ODIN_ROOT", context.temp_allocator) + if odin_core_env == "" { + if os.exists(odin_bin) { + odin_core_env = filepath.dir(odin_bin, context.temp_allocator) + } else if exe_path, ok := common.lookup_in_path(odin_bin); ok { + odin_core_env = filepath.dir(exe_path, context.temp_allocator) + } } - } - if abs_core_env, ok := filepath.abs(odin_core_env, context.temp_allocator); ok { - odin_core_env = abs_core_env + if abs_core_env, ok := filepath.abs(odin_core_env, context.temp_allocator); ok { + odin_core_env = abs_core_env + } } } diff --git a/src/server/types.odin b/src/server/types.odin index 4909c43..0eda132 100644 --- a/src/server/types.odin +++ b/src/server/types.odin @@ -421,6 +421,7 @@ OlsConfig :: struct { verbose: Maybe(bool), file_log: Maybe(bool), odin_command: string, + odin_root_override: string, checker_args: string, checker_targets: []string, profiles: [dynamic]common.ConfigProfile, |