Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vendor:raylib: add options to link with raylib/raygui from system #4619

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion vendor/raylib/raygui.odin
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import "core:c"

RAYGUI_SHARED :: #config(RAYGUI_SHARED, false)
RAYGUI_WASM_LIB :: #config(RAYGUI_WASM_LIB, "wasm/libraygui.a")
RAYGUI_SYSTEM :: #config(RAYGUI_SYSTEM, false)

when ODIN_OS == .Windows {
when RAYGUI_SYSTEM {
foreign import lib "system:raygui"
} else when ODIN_OS == .Windows {
Comment on lines +9 to +11
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break on Windows.

Copy link
Author

@spitulax spitulax Jan 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RAYLIB_SYSTEM and RAYGUI_SYSTEM allow building in some systems that wouldn't accept bundled libraries like Nix. If you don't enable them on Windows it should just use the bundled libraries.

foreign import lib {
"windows/rayguidll.lib" when RAYGUI_SHARED else "windows/raygui.lib",
}
Expand Down
5 changes: 4 additions & 1 deletion vendor/raylib/raylib.odin
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,11 @@ MAX_TEXT_BUFFER_LENGTH :: #config(RAYLIB_MAX_TEXT_BUFFER_LENGTH, 1024)

RAYLIB_SHARED :: #config(RAYLIB_SHARED, false)
RAYLIB_WASM_LIB :: #config(RAYLIB_WASM_LIB, "wasm/libraylib.a")
RAYLIB_SYSTEM :: #config(RAYLIB_SYSTEM, false)

when ODIN_OS == .Windows {
when RAYLIB_SYSTEM {
foreign import lib "system:raylib"
} else when ODIN_OS == .Windows {
@(extra_linker_flags="/NODEFAULTLIB:" + ("msvcrt" when RAYLIB_SHARED else "libcmt"))
foreign import lib {
"windows/raylibdll.lib" when RAYLIB_SHARED else "windows/raylib.lib" ,
Expand Down
5 changes: 4 additions & 1 deletion vendor/raylib/rlgl/rlgl.odin
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,16 @@ VERSION :: "5.0"

RAYLIB_SHARED :: #config(RAYLIB_SHARED, false)
RAYLIB_WASM_LIB :: #config(RAYLIB_WASM_LIB, "../wasm/libraylib.a")
RAYLIB_SYSTEM :: #config(RAYLIB_SYSTEM, false)

// Note: We pull in the full raylib library. If you want a truly stand-alone rlgl, then:
// - Compile a separate rlgl library and use that in the foreign import blocks below.
// - Remove the `import rl "../."` line
// - Copy the code from raylib.odin for any types we alias from that package (see PixelFormat etc)

when ODIN_OS == .Windows {
when RAYLIB_SYSTEM {
foreign import lib "system:raylib"
} else when ODIN_OS == .Windows {
@(extra_linker_flags="/NODEFAULTLIB:" + ("msvcrt" when RAYLIB_SHARED else "libcmt"))
foreign import lib {
"../windows/raylibdll.lib" when RAYLIB_SHARED else "../windows/raylib.lib" ,
Expand Down