build system: add bzlmod support + tests (#1057)
This commit is contained in:
1
.bazelignore
Normal file
1
.bazelignore
Normal file
@@ -0,0 +1 @@
|
|||||||
|
test
|
||||||
17
.bazelrc
Normal file
17
.bazelrc
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
common --enable_bzlmod
|
||||||
|
build --enable_platform_specific_config
|
||||||
|
build --incompatible_use_platforms_repo_for_constraints
|
||||||
|
build --incompatible_enable_cc_toolchain_resolution
|
||||||
|
build --enable_runfiles
|
||||||
|
build --incompatible_strict_action_env
|
||||||
|
|
||||||
|
# required for googletest
|
||||||
|
build:linux --cxxopt=-std=c++17
|
||||||
|
build:macos --cxxopt=-std=c++17
|
||||||
|
|
||||||
|
common:ci --announce_rc
|
||||||
|
common:ci --verbose_failures
|
||||||
|
common:ci --keep_going
|
||||||
|
test:ci --test_output=errors
|
||||||
|
|
||||||
|
try-import %workspace%/user.bazelrc
|
||||||
1
.bazelversion
Normal file
1
.bazelversion
Normal file
@@ -0,0 +1 @@
|
|||||||
|
6.3.2
|
||||||
20
.github/workflows/bazel-release-archive.yml
vendored
Normal file
20
.github/workflows/bazel-release-archive.yml
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
name: Bazel Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
# A release archive is required for bzlmod
|
||||||
|
# See: https://blog.bazel.build/2023/02/15/github-archive-checksum.html
|
||||||
|
bazel-release-archive:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
continue-on-error: true
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- run: git archive $GITHUB_REF -o "entt-${GITHUB_REF:10}.tar.gz"
|
||||||
|
- run: gh release upload ${GITHUB_REF:10} "entt-${GITHUB_REF:10}.tar.gz"
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
18
.github/workflows/bazel.yml
vendored
Normal file
18
.github/workflows/bazel.yml
vendored
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
name: bazel
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os:
|
||||||
|
- ubuntu-latest
|
||||||
|
- windows-latest
|
||||||
|
- macos-latest
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
continue-on-error: true
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- run: bazelisk test --config=ci ...
|
||||||
|
working-directory: test
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -11,3 +11,5 @@ cpp.hint
|
|||||||
|
|
||||||
# Bazel
|
# Bazel
|
||||||
/bazel-*
|
/bazel-*
|
||||||
|
/test/bazel-*
|
||||||
|
/user.bazelrc
|
||||||
|
|||||||
14
BUILD.bazel
14
BUILD.bazel
@@ -1,14 +1,6 @@
|
|||||||
_msvc_copts = ["/std:c++17"]
|
package(default_visibility = ["//visibility:public"])
|
||||||
_gcc_copts = ["-std=c++17"]
|
|
||||||
|
|
||||||
cc_library(
|
alias(
|
||||||
name = "entt",
|
name = "entt",
|
||||||
visibility = ["//visibility:public"],
|
actual = "//src:entt",
|
||||||
strip_include_prefix = "src",
|
|
||||||
hdrs = glob(["src/**/*.h", "src/**/*.hpp"]),
|
|
||||||
copts = select({
|
|
||||||
"@bazel_tools//src/conditions:windows": _msvc_copts,
|
|
||||||
"@bazel_tools//src/conditions:windows_msvc": _msvc_copts,
|
|
||||||
"//conditions:default": _gcc_copts,
|
|
||||||
}),
|
|
||||||
)
|
)
|
||||||
|
|||||||
8
MODULE.bazel
Normal file
8
MODULE.bazel
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
module(
|
||||||
|
name = "entt",
|
||||||
|
version = "3.12.2",
|
||||||
|
compatibility_level = 3012,
|
||||||
|
)
|
||||||
|
|
||||||
|
bazel_dep(name = "rules_cc", version = "0.0.8")
|
||||||
|
bazel_dep(name = "bazel_skylib", version = "1.4.2")
|
||||||
12
README.md
12
README.md
@@ -327,6 +327,18 @@ If you spot errors or have suggestions, any contribution is welcome!
|
|||||||
[documentation](https://build2.org/build2-toolchain/doc/build2-toolchain-intro.xhtml#guide-repositories)
|
[documentation](https://build2.org/build2-toolchain/doc/build2-toolchain-intro.xhtml#guide-repositories)
|
||||||
for more details.
|
for more details.
|
||||||
|
|
||||||
|
* [`bzlmod`](https://bazel.build/external/overview#bzlmod), Bazel's external
|
||||||
|
dependency management system.<br/>
|
||||||
|
To use the [`entt`](https://registry.bazel.build/modules/entt) module in a
|
||||||
|
`bazel` project, add the following to your `MODULE.bazel` file:
|
||||||
|
|
||||||
|
```starlark
|
||||||
|
bazel_dep(name = "entt", version = "3.12.2")
|
||||||
|
```
|
||||||
|
|
||||||
|
EnTT will now be available as `@entt` (short for `@entt//:entt`) to be used
|
||||||
|
in your `cc_*` rule `deps`.
|
||||||
|
|
||||||
Consider this list a work in progress and help me to make it longer if you like.
|
Consider this list a work in progress and help me to make it longer if you like.
|
||||||
|
|
||||||
## pkg-config
|
## pkg-config
|
||||||
|
|||||||
0
WORKSPACE.bazel
Normal file
0
WORKSPACE.bazel
Normal file
0
bazel/BUILD.bazel
Normal file
0
bazel/BUILD.bazel
Normal file
13
bazel/copts.bzl
Normal file
13
bazel/copts.bzl
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
load("@bazel_skylib//lib:selects.bzl", "selects")
|
||||||
|
|
||||||
|
COPTS = selects.with_or({
|
||||||
|
("//conditions:default", "@rules_cc//cc/compiler:clang", "@rules_cc//cc/compiler:gcc", "@rules_cc//cc/compiler:mingw-gcc"): [
|
||||||
|
"-std=c++17",
|
||||||
|
"-w",
|
||||||
|
],
|
||||||
|
("@rules_cc//cc/compiler:msvc-cl", "@rules_cc//cc/compiler:clang-cl"): [
|
||||||
|
"/std:c++17",
|
||||||
|
"/permissive-",
|
||||||
|
"/w",
|
||||||
|
],
|
||||||
|
})
|
||||||
11
src/BUILD.bazel
Normal file
11
src/BUILD.bazel
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
load("@bazel_skylib//lib:selects.bzl", "selects")
|
||||||
|
load("//bazel:copts.bzl", "COPTS")
|
||||||
|
|
||||||
|
package(default_visibility = ["//:__subpackages__"])
|
||||||
|
|
||||||
|
cc_library(
|
||||||
|
name = "entt",
|
||||||
|
includes = ["."],
|
||||||
|
hdrs = glob(["**/*.h", "**/*.hpp"]),
|
||||||
|
copts = COPTS,
|
||||||
|
)
|
||||||
1
test/.bazelrc
Normal file
1
test/.bazelrc
Normal file
@@ -0,0 +1 @@
|
|||||||
|
import "%workspace%/../.bazelrc"
|
||||||
0
test/BUILD.bazel
Normal file
0
test/BUILD.bazel
Normal file
11
test/MODULE.bazel
Normal file
11
test/MODULE.bazel
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
module(name = "entt_test")
|
||||||
|
|
||||||
|
bazel_dep(name = "rules_cc", version = "0.0.8")
|
||||||
|
bazel_dep(name = "bazel_skylib", version = "1.4.2")
|
||||||
|
bazel_dep(name = "googletest", version = "1.14.0")
|
||||||
|
bazel_dep(name = "entt")
|
||||||
|
|
||||||
|
local_path_override(
|
||||||
|
module_name = "entt",
|
||||||
|
path = "..",
|
||||||
|
)
|
||||||
1
test/WORKSPACE.bazel
Normal file
1
test/WORKSPACE.bazel
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# SEE: MODULE.bazel
|
||||||
10
test/entt/common/BUILD.bazel
Normal file
10
test/entt/common/BUILD.bazel
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
load("@rules_cc//cc:defs.bzl", "cc_library")
|
||||||
|
load("@entt//bazel:copts.bzl", "COPTS")
|
||||||
|
|
||||||
|
package(default_visibility = ["//:__subpackages__"])
|
||||||
|
|
||||||
|
cc_library(
|
||||||
|
name = "common",
|
||||||
|
copts = COPTS,
|
||||||
|
hdrs = glob(["*.h", "*.hpp"]),
|
||||||
|
)
|
||||||
33
test/entt/entity/BUILD.bazel
Normal file
33
test/entt/entity/BUILD.bazel
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
load("@rules_cc//cc:defs.bzl", "cc_test")
|
||||||
|
load("@entt//bazel:copts.bzl", "COPTS")
|
||||||
|
|
||||||
|
# buildifier: keep sorted
|
||||||
|
_TESTS = [
|
||||||
|
"component",
|
||||||
|
"entity",
|
||||||
|
"group",
|
||||||
|
"handle",
|
||||||
|
"helper",
|
||||||
|
"observer",
|
||||||
|
"organizer",
|
||||||
|
"registry",
|
||||||
|
"runtime_view",
|
||||||
|
"sigh_mixin",
|
||||||
|
"snapshot",
|
||||||
|
"sparse_set",
|
||||||
|
"storage",
|
||||||
|
"storage_entity",
|
||||||
|
"view",
|
||||||
|
]
|
||||||
|
|
||||||
|
[cc_test(
|
||||||
|
name = test,
|
||||||
|
srcs = ["{}.cpp".format(test)],
|
||||||
|
copts = COPTS,
|
||||||
|
deps = [
|
||||||
|
"//entt/common",
|
||||||
|
"@entt",
|
||||||
|
"@googletest//:gtest",
|
||||||
|
"@googletest//:gtest_main",
|
||||||
|
],
|
||||||
|
) for test in _TESTS]
|
||||||
34
test/entt/meta/BUILD.bazel
Normal file
34
test/entt/meta/BUILD.bazel
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
load("@rules_cc//cc:defs.bzl", "cc_test")
|
||||||
|
load("@entt//bazel:copts.bzl", "COPTS")
|
||||||
|
|
||||||
|
# buildifier: keep sorted
|
||||||
|
_TESTS = [
|
||||||
|
"meta_any",
|
||||||
|
"meta_base",
|
||||||
|
"meta_container",
|
||||||
|
"meta_context",
|
||||||
|
"meta_conv",
|
||||||
|
"meta_ctor",
|
||||||
|
"meta_data",
|
||||||
|
"meta_dtor",
|
||||||
|
"meta_func",
|
||||||
|
"meta_handle",
|
||||||
|
"meta_pointer",
|
||||||
|
"meta_prop",
|
||||||
|
"meta_range",
|
||||||
|
"meta_template",
|
||||||
|
"meta_type",
|
||||||
|
"meta_utility",
|
||||||
|
]
|
||||||
|
|
||||||
|
[cc_test(
|
||||||
|
name = test,
|
||||||
|
srcs = ["{}.cpp".format(test)],
|
||||||
|
copts = COPTS,
|
||||||
|
deps = [
|
||||||
|
"//entt/common",
|
||||||
|
"@entt",
|
||||||
|
"@googletest//:gtest",
|
||||||
|
"@googletest//:gtest_main",
|
||||||
|
],
|
||||||
|
) for test in _TESTS]
|
||||||
Reference in New Issue
Block a user