diff --git a/.bazelrc b/.bazelrc new file mode 100644 index 000000000..da19f0b83 --- /dev/null +++ b/.bazelrc @@ -0,0 +1 @@ +common --enable_bzlmod diff --git a/.bazelversion b/.bazelversion new file mode 100644 index 000000000..8fae6f6ea --- /dev/null +++ b/.bazelversion @@ -0,0 +1 @@ +7.x diff --git a/.gitignore b/.gitignore index 559f9f0d9..7d8dc0fe2 100644 --- a/.gitignore +++ b/.gitignore @@ -108,3 +108,7 @@ docgen_tmp/ # Parser stuff parser/raylib_parser + +# Bazel stuff +bazel-* +*.bazel.lock diff --git a/BUILD.bazel b/BUILD.bazel new file mode 100644 index 000000000..29ca6f449 --- /dev/null +++ b/BUILD.bazel @@ -0,0 +1,110 @@ +load("@rules_cc//cc:defs.bzl", "cc_library") + +cc_library( + name = "bundled_glfw", + strip_include_prefix = "src/external/glfw/include", + hdrs = glob([ + "src/external/glfw/include/**/*.h", + ]), + linkopts = select({ + "@platforms//os:windows": [ + "/DEFAULTLIB:user32", + "/DEFAULTLIB:gdi32", + "/DEFAULTLIB:shell32", + ], + "//conditions:default": [], + }), +) + +cc_library( + name = "bundled_glfw_sources", + deps = [":bundled_glfw"], + hdrs = glob([ + "src/external/glfw/src/**/*.h", + "src/external/glfw/src/**/*.c", + ]), +) + +cc_library( + name = "bundled_external_misc", + includes = ["src/external"], + hdrs = glob(["src/external/*.h"], exclude = ["src/external/dirent.h"]) + [ + # awkward "headers" + "src/external/qoaplay.c", + ] + select({ + "@platforms//os:windows": ["src/external/dirent.h"], + "//conditions:default": [], + }), + srcs = glob(["src/external/*.c"], exclude = ["src/external/qoaplay.c"]), +) + +cc_library( + name = "rcore", + hdrs = glob(["src/platforms/*.c"]), + srcs = ["src/rcore.c"] + glob(["src/*.h"]), + deps = [ + ":bundled_glfw", + ":bundled_external_misc", + ], + local_defines = select({ + "@platforms//os:android": ["PLATFORM_ANDROID"], + "@platforms//os:wasi": ["PLATFORM_WEB"], + "@platforms//os:emscripten": ["PLATFORM_WEB"], + "//conditions:default": ["PLATFORM_DESKTOP"], + }), +) + +cc_library( + name = "raylib", + visibility = ["//visibility:public"], + strip_include_prefix = "src", + hdrs = [ + "src/raylib.h", + "src/raymath.h", + "src/rlgl.h", + ], + deps = [ + ":rcore", + ":bundled_glfw", + ":bundled_glfw_sources", + ":bundled_external_misc", + ], +) + +cc_binary( + name = "raylib.dll", + visibility = ["//visibility:public"], + linkshared = True, + target_compatible_with = [ + "@platforms//os:windows", + ], + deps = [ + ":rcore", + ":bundled_glfw", + ":bundled_glfw_sources", + ":bundled_external_misc", + ], +) + +cc_binary( + name = "libraylib.so", + visibility = ["//visibility:public"], + linkshared = True, + target_compatible_with = [ + "@platforms//os:linux", + ], + deps = [ + ":rcore", + ":bundled_glfw", + ":bundled_glfw_sources", + ":bundled_external_misc", + ], +) + +alias( + name = "raylib_shared", + actual = select({ + "@platforms//os:windows": ":raylib.dll", + "@platforms//os:linux": ":libraylib.so", + }), +) diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 000000000..01a68dc0b --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,8 @@ +module( + name = "raylib", + version = "5.0", + compatibility_level = 1, +) + +bazel_dep(name = "rules_cc", version = "0.0.9") +bazel_dep(name = "platforms", version = "0.0.10") diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel new file mode 100644 index 000000000..d3f5a12fa --- /dev/null +++ b/WORKSPACE.bazel @@ -0,0 +1 @@ +