aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanielGavin <danielgavin5@hotmail.com>2024-05-02 20:57:16 +0200
committerDanielGavin <danielgavin5@hotmail.com>2024-05-02 20:57:16 +0200
commitdb1941ff2fe38dea52ad522566c75fc861ddabc1 (patch)
treeb07f6ea0482c2d97365894e2c7af03c449dc0eb3
parent49a63471d91120a23ec86f1621e99155d1be55c2 (diff)
Use filepath.abs on ols executable path
-rw-r--r--src/common/ast.odin2
-rw-r--r--src/server/build.odin17
-rw-r--r--src/server/collector.odin23
3 files changed, 26 insertions, 16 deletions
diff --git a/src/common/ast.odin b/src/common/ast.odin
index dbe236a..29d3e6c 100644
--- a/src/common/ast.odin
+++ b/src/common/ast.odin
@@ -924,7 +924,7 @@ node_equal_node :: proc(a, b: ^ast.Node) -> bool {
if n, ok := a.derived.(^Bit_Field_Type); ok {
if len(n.fields) != len(m.fields) do return false
ret := node_equal(n.backing_type, m.backing_type)
- for i in 0..<len(n.fields) {
+ for i in 0 ..< len(n.fields) {
ret &= node_equal(n.fields[i], m.fields[i])
}
return ret
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]