From 427c48221da1b9ab678d1b59dbc7d9e2c2b300e7 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 14 Aug 2024 10:28:07 +0100 Subject: [PATCH] Clean up `foreign import` code for library path determination --- vendor/box2d/box2d.odin | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/vendor/box2d/box2d.odin b/vendor/box2d/box2d.odin index 6b821fe5f..7f26e3a0d 100644 --- a/vendor/box2d/box2d.odin +++ b/vendor/box2d/box2d.odin @@ -7,30 +7,19 @@ import "core:c" when ODIN_OS == .Windows { @(private) LIB_PATH :: "lib/box2d_windows_amd64_" + VECTOR_EXT + ".lib" - - foreign import lib { - LIB_PATH, - } +} else when ODIN_OS == .Darwin { + @(private) LIB_PATH :: ("lib/box2d_darwin_amd64_" + VECTOR_EXT + ".a") when ODIN_ARCH == .amd64 else "lib/box2d_darwin_arm64.a" } else { - when ODIN_ARCH == .amd64 { - @(private) OS :: "darwin" when ODIN_OS == .Darwin else "other" - @(private) LIB_PATH :: "lib/box2d_" + OS + "_amd64_" + VECTOR_EXT + ".a" - } else when ODIN_OS == .Darwin && ODIN_ARCH == .arm64 { - @(private) LIB_PATH :: "lib/box2d_darwin_arm64.a" - } else { - @(private) LIB_PATH :: "lib/box2d_other.a" - } - - when !#exists(LIB_PATH) { - #panic("Could not find the compiled box2d libraries at \"" + LIB_PATH + "\", they can be compiled by running the `build.sh` script at `" + ODIN_ROOT + "vendor/box2d/build_box2d.sh\"`") - } - - foreign import lib { - LIB_PATH, - } + @(private) LIB_PATH :: "lib/box2d_other.a" } +when !#exists(LIB_PATH) { + #panic("Could not find the compiled box2d libraries at \"" + LIB_PATH + "\", they can be compiled by running the `build.sh` script at `" + ODIN_ROOT + "vendor/box2d/build_box2d.sh\"`") +} +foreign import lib { + LIB_PATH, +} // Prototype for user allocation function