From db1941ff2fe38dea52ad522566c75fc861ddabc1 Mon Sep 17 00:00:00 2001 From: DanielGavin Date: Thu, 2 May 2024 20:57:16 +0200 Subject: Use filepath.abs on ols executable path --- src/server/build.odin | 17 ++++++++++++++--- src/server/collector.odin | 23 +++++++++++------------ 2 files changed, 25 insertions(+), 15 deletions(-) (limited to 'src/server') diff --git a/src/server/build.odin b/src/server/build.odin index 9d0d550..aca1796 100644 --- a/src/server/build.odin +++ b/src/server/build.odin @@ -75,8 +75,12 @@ try_build_package :: proc(pkg_name: string) { return } - arena: runtime.Arena - result := runtime.arena_init(&arena, mem.Megabyte * 40, runtime.default_allocator()) + arena: runtime.Arena + result := runtime.arena_init( + &arena, + mem.Megabyte * 40, + runtime.default_allocator(), + ) defer runtime.arena_destroy(&arena) { @@ -156,7 +160,14 @@ setup_index :: proc() { ) indexer.index = make_memory_index(symbol_collection) - dir_exe := path.dir(os.args[0]) + dir_exe, ok := filepath.abs(path.dir(os.args[0], context.temp_allocator)) + + if !ok { + log.error( + "Failed to find ols executable path to build the builtin packages", + ) + return + } try_build_package(path.join({dir_exe, "builtin"})) } diff --git a/src/server/collector.odin b/src/server/collector.odin index fe103cf..e86fa92 100644 --- a/src/server/collector.odin +++ b/src/server/collector.odin @@ -74,14 +74,12 @@ make_symbol_collection :: proc( allocator := context.allocator, config: ^common.Config, ) -> SymbolCollection { - return( - SymbolCollection { - allocator = allocator, - config = config, - packages = make(map[string]SymbolPackage, 16, allocator), - unique_strings = make(map[string]string, 16, allocator), - } \ - ) + return SymbolCollection { + allocator = allocator, + config = config, + packages = make(map[string]SymbolPackage, 16, allocator), + unique_strings = make(map[string]string, 16, allocator), + } } delete_symbol_collection :: proc(collection: SymbolCollection) { @@ -197,8 +195,8 @@ collect_bit_field_fields :: proc( package_map: map[string]string, file: ast.File, ) -> SymbolBitFieldValue { - names := make([dynamic]string, 0, len(fields), collection.allocator) - types := make([dynamic]^ast.Expr, 0, len(fields), collection.allocator) + names := make([dynamic]string, 0, len(fields), collection.allocator) + types := make([dynamic]^ast.Expr, 0, len(fields), collection.allocator) ranges := make([dynamic]common.Range, 0, len(fields), collection.allocator) for field, i in fields { @@ -216,7 +214,7 @@ collect_bit_field_fields :: proc( append(&ranges, common.get_token_range(ident, file.src)) } } - + value := SymbolBitFieldValue { names = names[:], types = types[:], @@ -855,7 +853,8 @@ get_package_mapping :: proc( continue } - if i := strings.index(imp.fullpath, ":"); i != -1 && i != len(imp.fullpath) - 1 { + if i := strings.index(imp.fullpath, ":"); + i != -1 && i != len(imp.fullpath) - 1 { collection := imp.fullpath[1:i] p := imp.fullpath[i + 1:len(imp.fullpath) - 1] -- cgit v1.2.3