add 'shared' config to vendor libraries

This commit is contained in:
flysand7
2023-10-14 21:21:34 +11:00
parent 77210ffa56
commit cf937c6341
15 changed files with 249 additions and 77 deletions
+49 -19
View File
@@ -2,30 +2,60 @@ package raylib
import c "core:c/libc"
RAYGUI_SHARED :: #config(RAYGUI_SHARED, false)
when ODIN_OS == .Windows {
foreign import lib {
"windows/raygui.lib",
}
} else when ODIN_OS == .Linux {
foreign import lib {
"linux/libraygui.a",
// "system:dl",
// "system:pthread",
}
} else when ODIN_OS == .Darwin {
when ODIN_ARCH == .arm64 {
when RAYGUI_SHARED {
foreign import lib {
"macos-arm64/libraygui.a",
// "system:Cocoa.framework",
// "system:OpenGL.framework",
// "system:IOKit.framework",
"windows/rayguidll.lib",
}
} else {
foreign import lib {
"macos/libraygui.a",
// "system:Cocoa.framework",
// "system:OpenGL.framework",
// "system:IOKit.framework",
"windows/raygui.lib",
}
}
} else when ODIN_OS == .Linux {
when RAYGUI_SHARED {
// Note(bumbread): can't panic here, because the users might be expecting to
// only use raylib. Let's have them get the error at link-time instead..
//#panic("Cannot link libraygui.so: not in the vendor collection")
// Note(bumbread): unless we import something the rest of the bindings will
// make a compile-time error. This is a bit ugly for now, but in the future
// raygui probably needs to be in a separate package.
foreign import lib {"_"}
} else {
// #panic("Cannot link libraygui.a: not in the vendor collection")
// TODO(bumbread): apparently this one was missing. This might need
// to get rebuilt for linux
// foreign import lib {
// "linux/libraygui.a",
// // "system:dl",
// // "system:pthread",
// }
foreign import lib {"_"}
}
} else when ODIN_OS == .Darwin {
when ODIN_ARCH == .arm64 {
when RAYGUI_SHARED {
// #panic("Cannot link libraygui.450.dylib: not in the vendor collection")
} else {
foreign import lib {
"macos-arm64/libraygui.a",
// "system:Cocoa.framework",
// "system:OpenGL.framework",
// "system:IOKit.framework",
}
}
} else {
when RAYGUI_SHARED {
// #panic("Cannot link libraygui.450.dylib: not in the vendor collection")
} else {
foreign import lib {
"macos/libraygui.a",
// "system:Cocoa.framework",
// "system:OpenGL.framework",
// "system:IOKit.framework",
}
}
}
} else {
+64 -21
View File
@@ -95,35 +95,78 @@ MAX_TEXT_BUFFER_LENGTH :: #config(RAYLIB_MAX_TEXT_BUFFER_LENGTH, 1024)
#assert(size_of(rune) == size_of(c.int))
RAYLIB_SHARED :: #config(RAYLIB_SHARED, false)
when ODIN_OS == .Windows {
@(extra_linker_flags="/NODEFAULTLIB:libcmt")
foreign import lib {
"windows/raylib.lib",
"system:Winmm.lib",
"system:Gdi32.lib",
"system:User32.lib",
"system:Shell32.lib",
when RAYLIB_SHARED {
@(extra_linker_flags="/NODEFAULTLIB:libcmt")
foreign import lib {
"windows/raylibdll.lib",
"system:Winmm.lib",
"system:Gdi32.lib",
"system:User32.lib",
"system:Shell32.lib",
}
} else {
@(extra_linker_flags="/NODEFAULTLIB:libcmt")
foreign import lib {
"windows/raylib.lib",
"system:Winmm.lib",
"system:Gdi32.lib",
"system:User32.lib",
"system:Shell32.lib",
}
}
} else when ODIN_OS == .Linux {
foreign import lib {
"linux/libraylib.a",
"system:dl",
"system:pthread",
when RAYLIB_SHARED {
foreign import lib {
// Note(bumbread): I'm not sure why in `linux/` folder there are
// multiple copies of raylib.so, but since these bindings are for
// particular version of the library, I better specify it. Ideally,
// though, it's best specified in terms of major (.so.4)
"linux/libraylib.so.450",
"system:dl",
"system:pthread",
}
} else {
foreign import lib {
"linux/libraylib.a",
"system:dl",
"system:pthread",
}
}
} else when ODIN_OS == .Darwin {
when ODIN_ARCH == .arm64 {
foreign import lib {
"macos-arm64/libraylib.a",
"system:Cocoa.framework",
"system:OpenGL.framework",
"system:IOKit.framework",
when RAYLIB_SHARED {
foreign import lib {
"macos-arm64/libraylib.450.dylib",
"system:Cocoa.framework",
"system:OpenGL.framework",
"system:IOKit.framework",
}
} else {
foreign import lib {
"macos-arm64/libraylib.a",
"system:Cocoa.framework",
"system:OpenGL.framework",
"system:IOKit.framework",
}
}
} else {
foreign import lib {
"macos/libraylib.a",
"system:Cocoa.framework",
"system:OpenGL.framework",
"system:IOKit.framework",
when RAYLIB_SHARED {
foreign import lib {
"macos/libraylib.450.dylib",
"system:Cocoa.framework",
"system:OpenGL.framework",
"system:IOKit.framework",
}
} else {
foreign import lib {
"macos/libraylib.a",
"system:Cocoa.framework",
"system:OpenGL.framework",
"system:IOKit.framework",
}
}
}
} else {