Skip to content

Commit

Permalink
fix writing on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
dresswithpockets committed Feb 28, 2024
1 parent b9bb482 commit 52cf3be
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
11 changes: 5 additions & 6 deletions bindgen/gen.odin
Original file line number Diff line number Diff line change
Expand Up @@ -309,20 +309,19 @@ _builtin_class_method_default_arg_backing_field_name :: proc(method: StateBuilti
UNIX_ALLOW_READ_WRITE_ALL :: 0o666

generate_global_enums :: proc(state: ^State) {
fhandle, ferr := os.open("core/enums.gen.odin", os.O_CREATE | os.O_TRUNC, UNIX_ALLOW_READ_WRITE_ALL)
fhandle, ferr := os.open("core/enums.gen.odin", os.O_CREATE | os.O_TRUNC | os.O_RDWR, UNIX_ALLOW_READ_WRITE_ALL)
if ferr != 0 {
fmt.eprintf("Error opening core/enums.gen.odin\n")
return
}
defer os.close(fhandle)

fstream := os.stream_from_handle(fhandle)

enums_template.with(fstream, state)
}

generate_utility_functions :: proc(state: ^State) {
fhandle, ferr := os.open("core/util.gen.odin", os.O_CREATE | os.O_TRUNC, UNIX_ALLOW_READ_WRITE_ALL)
fhandle, ferr := os.open("core/util.gen.odin", os.O_CREATE | os.O_TRUNC | os.O_RDWR, UNIX_ALLOW_READ_WRITE_ALL)
if ferr != 0 {
fmt.eprintf("Error opening core/util.gen.odin\n")
return
Expand All @@ -345,7 +344,7 @@ generate_builtin_classes :: proc(state: ^State) {
file_name := strings.concatenate(file_name_parts[:])
defer delete(file_name)

fhandle, ferr := os.open(file_name, os.O_CREATE | os.O_TRUNC, UNIX_ALLOW_READ_WRITE_ALL)
fhandle, ferr := os.open(file_name, os.O_CREATE | os.O_TRUNC | os.O_RDWR, UNIX_ALLOW_READ_WRITE_ALL)
if ferr != 0 {
fmt.eprintf("Error opening %v\n", file_name)
return
Expand All @@ -360,7 +359,7 @@ generate_builtin_classes :: proc(state: ^State) {
// Variant and Object are special cases which arent provided by the API
// N.B. Object is actually a core API class and should be declared in core/, but for now isnt
file_name := "variant/Variant.gen.odin"
fhandle, ferr := os.open(file_name, os.O_CREATE | os.O_TRUNC, UNIX_ALLOW_READ_WRITE_ALL)
fhandle, ferr := os.open(file_name, os.O_CREATE | os.O_TRUNC | os.O_RDWR, UNIX_ALLOW_READ_WRITE_ALL)
if ferr != 0 {
fmt.eprintf("Error opening %v\n", file_name)
return
Expand All @@ -378,7 +377,7 @@ generate_classes :: proc(state: ^State) {
file_name := strings.concatenate(file_name_parts[:])
defer delete(file_name)

fhandle, ferr := os.open(file_name, os.O_CREATE | os.O_TRUNC, UNIX_ALLOW_READ_WRITE_ALL)
fhandle, ferr := os.open(file_name, os.O_CREATE | os.O_TRUNC | os.O_RDWR, UNIX_ALLOW_READ_WRITE_ALL)
if ferr != 0 {
fmt.eprintf("Error opening %v\n", file_name)
return
Expand Down
3 changes: 3 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ Bindings for all enums, classes, utility functions, singletons, and native struc
> [!NOTE]
> `make bindings` expects odin on path, all submodules updated, and odin-godot (this repo) is the working directory.
> [!WARNING]
> bindgen writes many files synchronously, for the time being. This should be fast on Windows, but is very slow on Linux.
Alternatively, you may build and run `bindgen` yourself:
```sh
# temple is the templating engine used by bindgen, temple_cli is temple's preprocessor.
Expand Down

0 comments on commit 52cf3be

Please sign in to comment.