Pārlūkot izejas kodu

Generate Odin bindings that: (1) Are easier to use with web builds. (2) Compile cleanly with '-vet -strict-style'

Karl Zylinski 6 mēneši atpakaļ
vecāks
revīzija
926a41e417
1 mainītis faili ar 5 papildinājumiem un 0 dzēšanām
  1. 5 0
      bindgen/gen_odin.py

+ 5 - 0
bindgen/gen_odin.py

@@ -360,6 +360,8 @@ def gen_c_imports(inp, c_prefix, prefix):
     linux_gl_libs = get_system_libs(prefix, 'linux', 'gl')
     l( 'import "core:c"')
     l( '')
+    l( '_ :: c')
+    l( '')
     l( 'SOKOL_DEBUG :: #config(SOKOL_DEBUG, ODIN_DEBUG)')
     l( '')
     l(f'DEBUG :: #config(SOKOL_{module_name.upper()}_DEBUG, SOKOL_DEBUG)')
@@ -421,6 +423,9 @@ def gen_c_imports(inp, c_prefix, prefix):
     l(f'        when DEBUG {{ foreign import {clib_import} {{ "{clib_prefix}_linux_x64_gl_debug.a"{linux_gl_libs} }} }}')
     l(f'        else       {{ foreign import {clib_import} {{ "{clib_prefix}_linux_x64_gl_release.a"{linux_gl_libs} }} }}')
     l( '    }')
+    l( '} else when ODIN_ARCH == .wasm32 || ODIN_ARCH == .wasm64p32 {')
+    l(f'    // Feed {clib_prefix}_wasm_gl_debug.a or {clib_prefix}_wasm_gl_release.a into emscripten compiler.')
+    l(f'    foreign import {clib_import} {{ "env.o" }}')
     l( '} else {')
     l( '    #panic("This OS is currently not supported")')
     l( '}')