aboutsummaryrefslogtreecommitdiff
path: root/tools/compile_assets
diff options
context:
space:
mode:
Diffstat (limited to 'tools/compile_assets')
-rw-r--r--tools/compile_assets/aseprite/marshal.odin4
-rw-r--r--tools/compile_assets/aseprite/unmarshal.odin8
-rw-r--r--tools/compile_assets/loaders.odin13
-rw-r--r--tools/compile_assets/main.odin9
-rw-r--r--tools/compile_assets/tiled.odin2
5 files changed, 21 insertions, 15 deletions
diff --git a/tools/compile_assets/aseprite/marshal.odin b/tools/compile_assets/aseprite/marshal.odin
index 1b56de1..d94c822 100644
--- a/tools/compile_assets/aseprite/marshal.odin
+++ b/tools/compile_assets/aseprite/marshal.odin
@@ -1,7 +1,7 @@
package aseprite_file_handler
import "core:io"
-import "core:os"
+import os "core:os/old"
import "core:log"
import "core:bytes"
import "core:bufio"
@@ -546,4 +546,4 @@ marshal_to_writer :: proc(doc: ^Document, ww: io.Writer, allocator := context.al
return file_size, Marshal_Errors.Wrong_Write_Size
}
return
-} \ No newline at end of file
+}
diff --git a/tools/compile_assets/aseprite/unmarshal.odin b/tools/compile_assets/aseprite/unmarshal.odin
index 5e5295c..876421e 100644
--- a/tools/compile_assets/aseprite/unmarshal.odin
+++ b/tools/compile_assets/aseprite/unmarshal.odin
@@ -3,12 +3,16 @@ package aseprite_file_handler
import "base:runtime"
import "base:intrinsics"
import "core:io"
-import "core:os"
+import os "core:os/old"
import "core:log"
import "core:bytes"
import "core:bufio"
import "core:mem/virtual"
+Ase_Unmarshal_Error :: union {
+ os.Error,
+ Unmarshal_Error,
+}
unmarshal_from_bytes_buff :: proc(doc: ^Document, r: ^bytes.Reader, alloc: runtime.Allocator = {}) -> (err: Unmarshal_Error) {
rr, ok := io.to_reader(bytes.reader_to_stream(r))
@@ -26,7 +30,7 @@ unmarshal_from_bufio :: proc(doc: ^Document, r: ^bufio.Reader, alloc: runtime.Al
return unmarshal(doc, rr, alloc)
}
-unmarshal_from_filename :: proc(doc: ^Document, name: string, alloc: runtime.Allocator = {}) -> (err: Unmarshal_Error) {
+unmarshal_from_filename :: proc(doc: ^Document, name: string, alloc: runtime.Allocator = {}) -> (err: Ase_Unmarshal_Error) {
fd, fd_err := os.open(name, os.O_RDONLY, 0)
if fd_err != nil {
log.error("Unable to read because of:", fd_err)
diff --git a/tools/compile_assets/loaders.odin b/tools/compile_assets/loaders.odin
index eadbc44..88ddd08 100644
--- a/tools/compile_assets/loaders.odin
+++ b/tools/compile_assets/loaders.odin
@@ -1,6 +1,6 @@
package assets_gen
-import os "core:os/os2"
+import "core:os"
import "core:fmt"
import "core:strings"
import "core:path/filepath"
@@ -78,11 +78,11 @@ load_png :: proc(path: string, png_file: ^os.File, output: ^os.File) {
die("Could not convert PNG to QOI (%v)", qoi_err)
}
- abs_path, found_abs := filepath.abs(
+ abs_path, abs_err := filepath.abs(
compiled_path,
context.temp_allocator
)
- if !found_abs {
+ if abs_err != nil {
die("Could not find absolute path for %v", compiled_path)
}
@@ -159,11 +159,11 @@ _load_sprite_sheet :: proc(
die("Could not save spritesheet %v (%v)", path, qoi_err)
}
- abs_path, found_abs := filepath.abs(
+ abs_path, abs_err := filepath.abs(
compiled_path,
context.temp_allocator
)
- if !found_abs {
+ if abs_err != nil {
die("Could not find absolute path for %v", compiled_path)
}
@@ -240,7 +240,8 @@ load_ase :: proc(path: string, ase_file: ^os.File, output: ^os.File) {
unmarshal_err := ase.unmarshal(&doc, path, alloc = context.temp_allocator)
if unmarshal_err != nil {
- die("Could not unmarshal aseprite file %v (%v)", path, unmarshal_err)
+ // FIXME: Odin bug? Had to not die here because the condition above is borked
+ fmt.eprintfln("Could not unmarshal aseprite file %v (%v)", path, unmarshal_err)
}
// Load animation
diff --git a/tools/compile_assets/main.odin b/tools/compile_assets/main.odin
index d8d8942..1eedee1 100644
--- a/tools/compile_assets/main.odin
+++ b/tools/compile_assets/main.odin
@@ -1,6 +1,6 @@
package assets_gen
-import os "core:os/os2"
+import "core:os"
import "core:fmt"
import "core:path/filepath"
import "core:strings"
@@ -74,7 +74,8 @@ output_dir: string
paths_to_res_type: map[string]string
-die :: proc(msg: string, args: ..any, exit_code := 1) {
+die :: proc(msg: string, args: ..any, exit_code := 1, caller_loc := #caller_location) {
+ fmt.eprintf("[%v] ", caller_loc)
fmt.eprintfln(msg, ..args)
os.exit(exit_code)
}
@@ -220,11 +221,11 @@ main :: proc() {
input_dir := os.args[1]
output_file_path := os.args[2]
- abs_output_path, found_abs := filepath.abs(
+ abs_output_path, abs_err := filepath.abs(
output_file_path,
context.temp_allocator
)
- if !found_abs {
+ if abs_err != nil {
die("Could not find absolute path to output file")
}
diff --git a/tools/compile_assets/tiled.odin b/tools/compile_assets/tiled.odin
index 5c2862c..8397586 100644
--- a/tools/compile_assets/tiled.odin
+++ b/tools/compile_assets/tiled.odin
@@ -1,6 +1,6 @@
package assets_gen
-import os "core:os/os2"
+import "core:os"
import "core:fmt"
import "core:encoding/json"
import "core:path/filepath"