Skip to content

Commit

Permalink
Merge pull request #4647 from karl-zylinski/raylib-wasm
Browse files Browse the repository at this point in the history
Make it easier to do Raylib WASM builds
  • Loading branch information
gingerBill authored Jan 1, 2025
2 parents 71b0f7e + dc1b75b commit fdd3b46
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions vendor/raylib/raygui.odin
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package raylib
import "core:c"

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

when ODIN_OS == .Windows {
foreign import lib {
Expand All @@ -22,6 +23,10 @@ when ODIN_OS == .Windows {
"macos/libraygui.dylib" when RAYGUI_SHARED else "macos/libraygui.a",
}
}
} else when ODIN_ARCH == .wasm32 || ODIN_ARCH == .wasm64p32 {
foreign import lib {
RAYGUI_WASM_LIB,
}
} else {
foreign import lib "system:raygui"
}
Expand Down
5 changes: 5 additions & 0 deletions vendor/raylib/raylib.odin
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ 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)
RAYLIB_WASM_LIB :: #config(RAYLIB_WASM_LIB, "wasm/libraylib.a")

when ODIN_OS == .Windows {
@(extra_linker_flags="/NODEFAULTLIB:" + ("msvcrt" when RAYLIB_SHARED else "libcmt"))
Expand Down Expand Up @@ -127,6 +128,10 @@ when ODIN_OS == .Windows {
"system:OpenGL.framework",
"system:IOKit.framework",
}
} else when ODIN_ARCH == .wasm32 || ODIN_ARCH == .wasm64p32 {
foreign import lib {
RAYLIB_WASM_LIB,
}
} else {
foreign import lib "system:raylib"
}
Expand Down
5 changes: 5 additions & 0 deletions vendor/raylib/rlgl/rlgl.odin
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ import rl "../."
VERSION :: "5.0"

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

// 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.
Expand Down Expand Up @@ -145,6 +146,10 @@ when ODIN_OS == .Windows {
"system:OpenGL.framework",
"system:IOKit.framework",
}
} else when ODIN_ARCH == .wasm32 || ODIN_ARCH == .wasm64p32 {
foreign import lib {
RAYLIB_WASM_LIB,
}
} else {
foreign import lib "system:raylib"
}
Expand Down
Binary file added vendor/raylib/wasm/libraygui.a
Binary file not shown.
Binary file added vendor/raylib/wasm/libraylib.a
Binary file not shown.

0 comments on commit fdd3b46

Please sign in to comment.