raylib/BUILD.bazel
2024-06-06 16:01:41 -07:00

130 lines
3.1 KiB
Python

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",
],
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",
srcs = [
"src/rglfw.c",
"src/rtext.c",
"src/utils.c",
"src/rshapes.c",
"src/rtextures.c",
"src/raudio.c",
"src/rmodels.c",
],
hdrs = [
"src/raylib.h",
"src/rcamera.h",
"src/raymath.h",
"src/rlgl.h",
],
deps = [
":rcore",
":bundled_glfw",
":bundled_glfw_sources",
":bundled_external_misc",
],
linkopts = select({
"@platforms//os:windows": [
"/DEFAULTLIB:winmm",
],
"//conditions:default": [],
}),
)
cc_binary(
name = "raylib.dll",
visibility = ["//visibility:public"],
linkshared = True,
target_compatible_with = [
"@platforms//os:windows",
],
linkopts = [
"/DEFAULTLIB:winmm",
],
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",
}),
)