From d06038a40993ac285ca061b10791c17df08ceb78 Mon Sep 17 00:00:00 2001 From: Barna Mumtyan Date: Sat, 4 May 2024 16:01:39 +0300 Subject: [PATCH 1/2] Added support for generating dynamic libraries for macos in sokol-odin port. --- bindgen/gen_odin.py | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/bindgen/gen_odin.py b/bindgen/gen_odin.py index dc1a2c37f..31638fd6f 100644 --- a/bindgen/gen_odin.py +++ b/bindgen/gen_odin.py @@ -372,21 +372,32 @@ def gen_c_imports(inp, c_prefix, prefix): l( ' }') l( ' }') l( '} else when ODIN_OS == .Darwin {') - l( ' when USE_GL {') - l( ' when ODIN_ARCH == .arm64 {') - l(f' when DEBUG {{ foreign import {clib_import} {{ "{clib_prefix}_macos_arm64_gl_debug.a"{macos_gl_libs} }} }}') - l(f' else {{ foreign import {clib_import} {{ "{clib_prefix}_macos_arm64_gl_release.a"{macos_gl_libs} }} }}') - l( ' } else {') - l(f' when DEBUG {{ foreign import {clib_import} {{ "{clib_prefix}_macos_x64_gl_debug.a"{macos_gl_libs} }} }}') - l(f' else {{ foreign import {clib_import} {{ "{clib_prefix}_macos_x64_gl_release.a"{macos_gl_libs} }} }}') - l( ' }') + l( ' when USE_DLL {') + l(f' when USE_GL && ODIN_ARCH == .arm64 && DEBUG {{ foreign import {clib_import} {{ "../dylib/sokol_dylib_macos_arm64_gl_debug.dylib" }} }}') + l(f' else when USE_GL && ODIN_ARCH == .arm64 && !DEBUG {{ foreign import {clib_import} {{ "../dylib/sokol_dylib_macos_arm64_gl_release.dylib" }} }}') + l(f' else when USE_GL && ODIN_ARCH == .amd64 && DEBUG {{ foreign import {clib_import} {{ "../dylib/sokol_dylib_macos_x64_gl_debug.dylib" }} }}') + l(f' else when USE_GL && ODIN_ARCH == .amd64 && !DEBUG {{ foreign import {clib_import} {{ "../dylib/sokol_dylib_macos_x64_gl_release.dylib" }} }}') + l(f' else when !USE_GL && ODIN_ARCH == .arm64 && DEBUG {{ foreign import {clib_import} {{ "../dylib/sokol_dylib_macos_arm64_metal_debug.dylib" }} }}') + l(f' else when !USE_GL && ODIN_ARCH == .arm64 && !DEBUG {{ foreign import {clib_import} {{ "../dylib/sokol_dylib_macos_arm64_metal_release.dylib" }} }}') + l(f' else when !USE_GL && ODIN_ARCH == .amd64 && DEBUG {{ foreign import {clib_import} {{ "../dylib/sokol_dylib_macos_x64_metal_debug.dylib" }} }}') + l(f' else when !USE_GL && ODIN_ARCH == .amd64 && !DEBUG {{ foreign import {clib_import} {{ "../dylib/sokol_dylib_macos_x64_metal_release.dylib" }} }}') l( ' } else {') - l( ' when ODIN_ARCH == .arm64 {') - l(f' when DEBUG {{ foreign import {clib_import} {{ "{clib_prefix}_macos_arm64_metal_debug.a"{macos_metal_libs} }} }}') - l(f' else {{ foreign import {clib_import} {{ "{clib_prefix}_macos_arm64_metal_release.a"{macos_metal_libs} }} }}') + l( ' when USE_GL {') + l( ' when ODIN_ARCH == .arm64 {') + l(f' when DEBUG {{ foreign import {clib_import} {{ "{clib_prefix}_macos_arm64_gl_debug.a"{macos_gl_libs} }} }}') + l(f' else {{ foreign import {clib_import} {{ "{clib_prefix}_macos_arm64_gl_release.a"{macos_gl_libs} }} }}') + l( ' } else {') + l(f' when DEBUG {{ foreign import {clib_import} {{ "{clib_prefix}_macos_x64_gl_debug.a"{macos_gl_libs} }} }}') + l(f' else {{ foreign import {clib_import} {{ "{clib_prefix}_macos_x64_gl_release.a"{macos_gl_libs} }} }}') + l( ' }') l( ' } else {') - l(f' when DEBUG {{ foreign import {clib_import} {{ "{clib_prefix}_macos_x64_metal_debug.a"{macos_metal_libs} }} }}') - l(f' else {{ foreign import {clib_import} {{ "{clib_prefix}_macos_x64_metal_release.a"{macos_metal_libs} }} }}') + l( ' when ODIN_ARCH == .arm64 {') + l(f' when DEBUG {{ foreign import {clib_import} {{ "{clib_prefix}_macos_arm64_metal_debug.a"{macos_metal_libs} }} }}') + l(f' else {{ foreign import {clib_import} {{ "{clib_prefix}_macos_arm64_metal_release.a"{macos_metal_libs} }} }}') + l( ' } else {') + l(f' when DEBUG {{ foreign import {clib_import} {{ "{clib_prefix}_macos_x64_metal_debug.a"{macos_metal_libs} }} }}') + l(f' else {{ foreign import {clib_import} {{ "{clib_prefix}_macos_x64_metal_release.a"{macos_metal_libs} }} }}') + l( ' }') l( ' }') l( ' }') l( '} else when ODIN_OS == .Linux {') From 1c34132674de06a248e8c01226ceb35f9c6d79c8 Mon Sep 17 00:00:00 2001 From: Barna Mumtyan Date: Sat, 4 May 2024 20:03:37 +0300 Subject: [PATCH 2/2] Fixed an indentation. --- bindgen/gen_odin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindgen/gen_odin.py b/bindgen/gen_odin.py index 31638fd6f..d2bc55df6 100644 --- a/bindgen/gen_odin.py +++ b/bindgen/gen_odin.py @@ -386,7 +386,7 @@ def gen_c_imports(inp, c_prefix, prefix): l( ' when ODIN_ARCH == .arm64 {') l(f' when DEBUG {{ foreign import {clib_import} {{ "{clib_prefix}_macos_arm64_gl_debug.a"{macos_gl_libs} }} }}') l(f' else {{ foreign import {clib_import} {{ "{clib_prefix}_macos_arm64_gl_release.a"{macos_gl_libs} }} }}') - l( ' } else {') + l( ' } else {') l(f' when DEBUG {{ foreign import {clib_import} {{ "{clib_prefix}_macos_x64_gl_debug.a"{macos_gl_libs} }} }}') l(f' else {{ foreign import {clib_import} {{ "{clib_prefix}_macos_x64_gl_release.a"{macos_gl_libs} }} }}') l( ' }')