Skip to content

Commit

Permalink
Migrate bazel build to bzlmod
Browse files Browse the repository at this point in the history
  • Loading branch information
reutermj committed Aug 21, 2024
1 parent c30b164 commit 6471ad3
Show file tree
Hide file tree
Showing 18 changed files with 256 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: build flecs
run: ${{ matrix.compiler }} flecs.c --shared -fPIC -pedantic -Wall -Wextra -Wno-unused-parameter -Werror -Wshadow -Wconversion -Wno-missing-field-initializers
run: ${{ matrix.compiler }} distr/flecs.c --shared -fPIC -pedantic -Wall -Wextra -Wno-unused-parameter -Werror -Wshadow -Wconversion -Wno-missing-field-initializers

test-amalgamated:
needs: build-linux
Expand Down
7 changes: 1 addition & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@ gcov
*.pdb
deps
cmake-build-debug
bazel-bin
bazel-flecs
bazel-bazel
bazel-genfiles
bazel-out
bazel-testlogs
bazel-*
**/CMakeFiles/*
.vs
out
Expand Down
2 changes: 1 addition & 1 deletion BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

cc_library(
name = "flecs",
visibility = ["//visibility:public"],
defines = ["flecs_EXPORTS"],

srcs = glob(["src/**/*.c", "src/**/*.h", "src/**/*.inl"]),
hdrs = glob(["include/**/*.h", "include/**/*.hpp", "include/**/*.inl"]),
Expand Down
53 changes: 53 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
"A fast entity component system (ECS) for C & C++"
module(name = "flecs", version = "4.0.1")

git_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

git_repository(
name = "bake",
remote = "https://github.com/SanderMertens/bake.git",
commit = "10c02123d6e3e200578128d73c3fa3bb996dff4f",
build_file_content = """
cc_library(
name = "driver-test",
visibility = ["//visibility:public"],
deps = [":util", ":bake"],
defines = ["__BAKE__", "bake_test_EXPORTS"],
srcs = glob(["drivers/test/src/**/*.c", "drivers/test/src/**/*.h"]),
hdrs = glob(["drivers/test/include/**/*.h"]),
includes = ["drivers/test/include"],
)
cc_library(
name = "bake",
visibility = ["//visibility:public"],
deps = [":util"],
srcs = glob(["src/*.c", "src/*.h"]),
hdrs = glob(["include/*.h", "include/bake/*.h"]),
includes = ["include"],
)
cc_library(
name = "util",
visibility = ["//visibility:public"],
defines = ["__BAKE__", "_XOPEN_SOURCE=600", "bake_util_EXPORTS", "UT_IMPL"],
linkopts = select({
"@bazel_tools//src/conditions:windows": ["Dbghelp.lib", "Shell32.lib", "Shlwapi.lib"],
"//conditions:default": ["-lrt -lpthread -ldl"],
}),
srcs = glob(["util/src/*.c"]) + select({
"@bazel_tools//src/conditions:windows": glob(["util/src/win/*.c"]),
"//conditions:default": glob(["util/src/posix/*.c"]),
}),
hdrs = glob(["util/include/*.h", "util/include/bake-util/*.h"]) + select({
"@bazel_tools//src/conditions:windows": glob(["util/include/bake-util/win/*.h"]),
"//conditions:default": glob(["util/include/bake-util/posix/*.h"]),
}),
includes = ["util/include"],
)
""",
)
110 changes: 110 additions & 0 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,3 @@ cc_library(
)
"""
)

1 change: 1 addition & 0 deletions WORKSPACE.bzlmod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Overrides WORKSPACE when building with bzlmod
File renamed without changes.
File renamed without changes.
7 changes: 0 additions & 7 deletions examples/build/bazel/BUILD

This file was deleted.

10 changes: 10 additions & 0 deletions examples/build/bazel/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"Example for using the flecs as a dependency using bazel"
module(name = "flecs_bazel_example", version = "1.0.0")

bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "flecs")
git_override(
module_name = "flecs",
remote = "https://github.com/SanderMertens/flecs.git",
commit = "02c8c2666b22ccce5706c8f16efaf813704fe31e",
)
Loading

0 comments on commit 6471ad3

Please sign in to comment.