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

Add stb #3469

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Add stb #3469

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
7 changes: 7 additions & 0 deletions modules/stb/0.0.0-20241109-5c20573/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module(
name = "stb",
version = "0.0.0-20241109-5c20573",
compatibility_level = 0,
)

bazel_dep(name = "rules_cc", version = "0.0.17")
22 changes: 22 additions & 0 deletions modules/stb/0.0.0-20241109-5c20573/overlay/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

cc_library(
name = "stb_image",
hdrs = ["stb_image.h"],
defines = ["STB_IMAGE_IMPLEMENTATION"],
Copy link
Contributor

Choose a reason for hiding this comment

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

Based on https://github.com/nothings/stb?tab=readme-ov-file#how-do-i-use-these-libraries, wouldn't all targets need to look like this?

cc_library(
    name = "stb_thing",
    hdrs = ["stb_thing.h"],
    # A generated file that includes the header after defining `STB_THING_IMPLEMENTATION`.
    srcs = ["stb_thing.c"],
    ...
)

This would allow users to use the headers without having to worry about the "include in exactly one source file" bit. You could probably get away with an empty source file if you use local_defines to set the macro and -include to force inclusion of the header.

includes = ["."],
visibility = ["//visibility:public"],
)

[
cc_library(
name = header.split(".")[0],
hdrs = [header],
includes = ["."],
visibility = ["//visibility:public"],
)
for header in glob(
["stb_*.h"],
exclude = ["stb_image.h"],
)
]
1 change: 1 addition & 0 deletions modules/stb/0.0.0-20241109-5c20573/overlay/MODULE.bazel
21 changes: 21 additions & 0 deletions modules/stb/0.0.0-20241109-5c20573/presubmit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
matrix:
platform:
- debian10
- debian11
- macos
- macos_arm64
- ubuntu2004
- ubuntu2204
- ubuntu2404
- windows
bazel: [7.x, 8.x]
tasks:
verify_targets:
name: Verify build targets
platform: ${{ platform }}
bazel: ${{ bazel }}
build_flags:
- '--process_headers_in_dependencies'
- '--features=parse_headers'
build_targets:
- '@stb//...'
hofbi marked this conversation as resolved.
Show resolved Hide resolved
10 changes: 10 additions & 0 deletions modules/stb/0.0.0-20241109-5c20573/source.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"url": "https://github.com/nothings/stb/archive/5c205738c191bcb0abc65c4febfa9bd25ff35234.tar.gz",
"integrity": "sha256-z+q5+ACWGILW0i3fNullUjszAC9Pk33ggyEwTJunKvM=",
"strip_prefix": "stb-5c205738c191bcb0abc65c4febfa9bd25ff35234",
"patch_strip": 0,
"overlay": {
"BUILD.bazel": "sha256-kZIQc1csNAuEu8Elo8OMJksy7ZJbDfXkXqgYNSLLUYU=",
"MODULE.bazel": "sha256-OVRPBnEBUp917qFg9XnpqBYVfVkWDYRT5BHJgnjkcxI="
}
}
16 changes: 16 additions & 0 deletions modules/stb/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"homepage": "https://github.com/nothings/stb",
"maintainers": [
{
"github": "hofbi",
"name": "Markus Hofbauer"
}
],
"repository": [
"github:nothings/stb"
],
"versions": [
"0.0.0-20241109-5c20573"
],
"yanked_versions": {}
}
Loading