소스 검색

Merge pull request #1204 from karl-zylinski/odin-bindgen-wasm

Make Odin bindings respect common vetting rules + easier to use WASM
Andre Weissflog 6 달 전
부모
커밋
1fd10cb16f
1개의 변경된 파일5개의 추가작업 그리고 0개의 파일을 삭제
  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( '}')