Skip to content

Commit

Permalink
feat: Add build recipe and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kelwan committed May 10, 2024
1 parent af9e498 commit 653ff0a
Show file tree
Hide file tree
Showing 15 changed files with 564 additions and 285 deletions.
2 changes: 2 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ cc_library(
hdrs = glob(["ecsact/**/*.hh"]),
copts = copts,
)

exports_files(["build_recipe.yml"])
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ bazel_dep(name = "ecsact_lang_cpp", version = "0.4.1")
bazel_dep(name = "boost.mp11", version = "1.83.0.bzl.1")
bazel_dep(name = "entt", version = "3.12.2")
bazel_dep(name = "ecsact_codegen", version = "0.2.0")
bazel_dep(name = "ecsact_cli", version = "0.3.4")
bazel_dep(name = "ecsact_cli", version = "0.3.6")
bazel_dep(name = "xxhash", version = "0.8.2")
bazel_dep(name = "googletest", version = "1.14.0")

Expand Down
150 changes: 76 additions & 74 deletions MODULE.bazel.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions bazel/common.bazelrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
startup --windows_enable_symlinks
common --enable_bzlmod
common --registry=https://raw.githubusercontent.com/ecsact-dev/bazel_registry/main
common --registry=https://raw.githubusercontent.com/zaucy/bazel-central-registry/add-curl-config2 # temporary
common --registry=https://raw.githubusercontent.com/bazelboost/registry/main
common --registry=https://bcr.bazel.build
build --enable_platform_specific_config
Expand Down
74 changes: 45 additions & 29 deletions test/test_recipe.yml → build_recipe.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: RT EnTT Recipe

sources:
- ../test/bazel-bin/_runtime__public_hdrs/runtime_test.ecsact.hh
- ../test/bazel-bin/_runtime__public_hdrs/imported_pkg.ecsact.hh
- ../test/bazel-bin/_runtime__cc_srcs/runtime_test.ecsact.rt_entt.cc
- codegen: ./ecsact_rt_entt_codegen
- codegen:
- ../ecsact_lang_cpp~/cpp_header_codegen/ecsact_cpp_header_codegen
- ../ecsact_rt_entt~/rt_entt_codegen/ecsact_rt_entt_codegen
outdir: _rt_entt_codegen_outdir
# entt
- fetch: https://raw.githubusercontent.com/skypjack/entt/v3.12.2/src/entt/entt.hpp
outdir: include/entt
# entt/graph
- fetch: https://raw.githubusercontent.com/skypjack/entt/v3.12.2/src/entt/graph/adjacency_matrix.hpp
outdir: include/entt/graph
- fetch: https://raw.githubusercontent.com/skypjack/entt/v3.12.2/src/entt/graph/flow.hpp
Expand All @@ -17,23 +17,25 @@ sources:
outdir: include/entt/graph
- fetch: https://raw.githubusercontent.com/skypjack/entt/v3.12.2/src/entt/graph/fwd.hpp
outdir: include/entt/graph
# entt/locator
- fetch: https://raw.githubusercontent.com/skypjack/entt/v3.12.2/src/entt/locator/locator.hpp
outdir: include/entt/locator
# entt/platform
- fetch: https://raw.githubusercontent.com/skypjack/entt/v3.12.2/src/entt/platform/android-ndk-r17.hpp
outdir: include/entt/platform
# poly
# entt/poly
- fetch: https://raw.githubusercontent.com/skypjack/entt/v3.12.2/src/entt/poly/fwd.hpp
outdir: include/entt/poly
- fetch: https://raw.githubusercontent.com/skypjack/entt/v3.12.2/src/entt/poly/poly.hpp
outdir: include/entt/poly
# process
# entt/process
- fetch: https://raw.githubusercontent.com/skypjack/entt/v3.12.2/src/entt/process/fwd.hpp
outdir: include/entt/process
- fetch: https://raw.githubusercontent.com/skypjack/entt/v3.12.2/src/entt/process/process.hpp
outdir: include/entt/process
- fetch: https://raw.githubusercontent.com/skypjack/entt/v3.12.2/src/entt/process/scheduler.hpp
outdir: include/entt/process
# resource
# entt/resource
- fetch: https://raw.githubusercontent.com/skypjack/entt/v3.12.2/src/entt/resource/cache.hpp
outdir: include/entt/resource
- fetch: https://raw.githubusercontent.com/skypjack/entt/v3.12.2/src/entt/resource/fwd.hpp
Expand All @@ -42,7 +44,7 @@ sources:
outdir: include/entt/resource
- fetch: https://raw.githubusercontent.com/skypjack/entt/v3.12.2/src/entt/resource/resource.hpp
outdir: include/entt/resource
# entity
# entt/entity
- fetch: https://raw.githubusercontent.com/skypjack/entt/v3.12.2/src/entt/entity/registry.hpp
outdir: include/entt/entity
- fetch: https://raw.githubusercontent.com/skypjack/entt/v3.12.2/src/entt/entity/storage.hpp
Expand Down Expand Up @@ -77,7 +79,7 @@ sources:
outdir: include/entt/entity
- fetch: https://raw.githubusercontent.com/skypjack/entt/v3.12.2/src/entt/entity/snapshot.hpp
outdir: include/entt/entity
# meta
# entt/meta
- fetch: https://raw.githubusercontent.com/skypjack/entt/v3.12.2/src/entt/meta/adl_pointer.hpp
outdir: include/entt/meta
- fetch: https://raw.githubusercontent.com/skypjack/entt/v3.12.2/src/entt/meta/container.hpp
Expand Down Expand Up @@ -106,7 +108,7 @@ sources:
outdir: include/entt/meta
- fetch: https://raw.githubusercontent.com/skypjack/entt/v3.12.2/src/entt/meta/utility.hpp
outdir: include/entt/meta
# signal
# entt/signal
- fetch: https://raw.githubusercontent.com/skypjack/entt/v3.12.2/src/entt/signal/sigh.hpp
outdir: include/entt/signal
- fetch: https://raw.githubusercontent.com/skypjack/entt/v3.12.2/src/entt/signal/delegate.hpp
Expand All @@ -117,21 +119,21 @@ sources:
outdir: include/entt/signal
- fetch: https://raw.githubusercontent.com/skypjack/entt/v3.12.2/src/entt/signal/fwd.hpp
outdir: include/entt/signal
# config
# entt/config
- fetch: https://raw.githubusercontent.com/skypjack/entt/v3.12.2/src/entt/config/version.h
outdir: include/entt/config
- fetch: https://raw.githubusercontent.com/skypjack/entt/v3.12.2/src/entt/config/macro.h
outdir: include/entt/config
- fetch: https://raw.githubusercontent.com/skypjack/entt/v3.12.2/src/entt/config/config.h
outdir: include/entt/config
# container
# entt/container
- fetch: https://raw.githubusercontent.com/skypjack/entt/v3.12.2/src/entt/container/dense_map.hpp
outdir: include/entt/container
- fetch: https://raw.githubusercontent.com/skypjack/entt/v3.12.2/src/entt/container/fwd.hpp
outdir: include/entt/container
- fetch: https://raw.githubusercontent.com/skypjack/entt/v3.12.2/src/entt/container/dense_set.hpp
outdir: include/entt/container
# core
# entt/core
- fetch: https://raw.githubusercontent.com/skypjack/entt/v3.12.2/src/entt/core/compressed_pair.hpp
outdir: include/entt/core
- fetch: https://raw.githubusercontent.com/skypjack/entt/v3.12.2/src/entt/core/type_traits.hpp
Expand Down Expand Up @@ -164,35 +166,49 @@ sources:
outdir: include/entt/core
- fetch: https://raw.githubusercontent.com/skypjack/entt/v3.12.2/src/entt/core/tuple.hpp
outdir: include/entt/core
- path: ../ecsact/entt/detail/apply_pending.hh
# xxhash
- fetch: https://raw.githubusercontent.com/Cyan4973/xxHash/v0.8.2/xxhash.h
outdir: include/
- fetch: https://raw.githubusercontent.com/Cyan4973/xxHash/v0.8.2/xxhash.c
outdir: src/

# ecsact/entt/detail
- path: ./ecsact/entt/detail/execution_events_collector.hh
outdir: include/ecsact/entt/detail
- path: ../ecsact/entt/detail/execution_events_collector.hh
- path: ./ecsact/entt/detail/apply_pending.hh
outdir: include/ecsact/entt/detail
- path: ../ecsact/entt/detail/globals.hh
- path: ./ecsact/entt/detail/globals.hh
outdir: include/ecsact/entt/detail
- path: ../ecsact/entt/detail/internal_markers.hh
- path: ./ecsact/entt/detail/internal_markers.hh
outdir: include/ecsact/entt/detail
- path: ../ecsact/entt/detail/system_execution_context.hh
- path: ./ecsact/entt/detail/system_execution_context.hh
outdir: include/ecsact/entt/detail/
- path: ../ecsact/entt/wrapper/core.hh
- path: ./ecsact/entt/detail/bytes.hh
outdir: include/ecsact/entt/detail
- path: ./ecsact/entt/detail/hash.hh
outdir: include/ecsact/entt/detail
# ecsact/entt/wrapper
- path: ./ecsact/entt/wrapper/core.hh
outdir: include/ecsact/entt/wrapper
- path: ../ecsact/entt/wrapper/dynamic.hh
- path: ./ecsact/entt/wrapper/dynamic.hh
outdir: include/ecsact/entt/wrapper
- path: ../ecsact/entt/entity.hh
# ecsact/entt
- path: ./ecsact/entt/entity.hh
outdir: include/ecsact/entt
- path: ../ecsact/entt/error_check.hh
- path: ./ecsact/entt/error_check.hh
outdir: include/ecsact/entt
- path: ../ecsact/entt/event_markers.hh
- path: ./ecsact/entt/event_markers.hh
outdir: include/ecsact/entt
- path: ../ecsact/entt/execution.hh
- path: ./ecsact/entt/execution.hh
outdir: include/ecsact/entt
- path: ../ecsact/entt/registry_util.hh
- path: ./ecsact/entt/registry_util.hh
outdir: include/ecsact/entt
- ../runtime/ecsact_rt_entt_core.cc
- ../runtime/ecsact_rt_entt_dynamic.cc
- ./runtime/ecsact_rt_entt_core.cc
- ./runtime/ecsact_rt_entt_dynamic.cc
- ./runtime/hash.cc

exports:
# Core
# core
- ecsact_execute_systems
- ecsact_destroy_registry
- ecsact_clear_registry
Expand All @@ -210,7 +226,7 @@ exports:
- ecsact_get_components
- ecsact_update_component
- ecsact_remove_component
# Dynamic
# dynamic
- ecsact_system_execution_context_same
- ecsact_system_execution_context_entity
- ecsact_system_execution_context_generate
Expand Down
1 change: 1 addition & 0 deletions rt_entt_codegen/rt_entt_codegen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ void ecsact_codegen_plugin(
ctx.write("\n");
inc_package_header(ctx, package_id);
for(auto dep : ecsact::meta::get_dependencies(package_id)) {
assert(package_id != dep);
inc_package_header(ctx, dep);
}
ctx.write("\n");
Expand Down
1 change: 0 additions & 1 deletion rt_entt_codegen/shared/comps_with_caps.hh
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ inline auto comps_with_caps(
}

std::ranges::sort(found_comps);
auto unique_found_comps_range = std::ranges::unique(found_comps);
auto unique_found_comps = std::vector<ecsact_component_like_id>{};
unique_found_comps.reserve(found_comps.size());
std::ranges::copy(found_comps, std::back_inserter(unique_found_comps));
Expand Down
4 changes: 3 additions & 1 deletion rt_entt_codegen/shared/util.hh
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ inline auto inc_package_header( //
) -> void {
namespace fs = std::filesystem;

auto main_ecsact_file_path = ecsact::meta::package_file_path(ctx.package_id);
auto main_ecsact_file_path =
ecsact::meta::package_file_path(ctx.package_id).lexically_normal();

if(ctx.package_id == pkg_id) {
main_ecsact_file_path.replace_extension(
main_ecsact_file_path.extension().string() + ".hh"
Expand Down
66 changes: 49 additions & 17 deletions test/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
load("@ecsact_rt_entt//bazel:copts.bzl", "copts")
load("@ecsact_rt_entt//runtime:index.bzl", "ecsact_entt_runtime")
load("@hedron_compile_commands//:refresh_compile_commands.bzl", "refresh_compile_commands")
load("@rules_cc//cc:defs.bzl", "cc_test")
load("@rules_ecsact//ecsact:defs.bzl", "ecsact_codegen")

Expand All @@ -9,33 +8,66 @@ cc_test(
srcs = ["test_build_recipe.cc"],
copts = copts,
data = [
"test_recipe.yml",
"//:imported_pkg.ecsact",
"//:runtime_test.ecsact",
"@ecsact_cli",
"@ecsact_lang_cpp//cpp_header_codegen:ecsact_cpp_header_codegen",
"@ecsact_rt_entt//:build_recipe.yml",
"@ecsact_rt_entt//:headers",
"@ecsact_rt_entt//rt_entt_codegen:ecsact_rt_entt_codegen",
"@ecsact_rt_entt//runtime:sources",
"@llvm_toolchain_llvm//:bin/clang",
],
env = {
"ECSACT_CLI": "$(rootpath @ecsact_cli)",
"ECSACT_RECIPE_PATH": "$(roothpath test_recipe.yml)",
"ECSACT_RUNTIME_FILE_PATH": "$(rootpath //:runtime_test.ecsact)",
"ECSACT_IMPORTED_FILE_PATH": "$rootpath //:imported_pkg.ecsact)",
"ECSACT_CODEGEN_PLUGIN_PATH": "$(rootpath @ecsact_rt_entt//rt_entt_codegen:ecsact_rt_entt_codegen",
},
env = select({
"@platforms//os:windows": {
"ECSACT_CLI": "$(rootpath @ecsact_cli)",
"ECSACT_RECIPE_PATH": "$(rootpath @ecsact_rt_entt//:build_recipe.yml)",
"ECSACT_RUNTIME_FILE_PATH": "$(rootpath //:runtime_test.ecsact)",
"ECSACT_IMPORTED_FILE_PATH": "$(rootpath //:imported_pkg.ecsact)",
"ECSACT_CODEGEN_PLUGIN_PATH": "$(rootpath @ecsact_rt_entt//rt_entt_codegen:ecsact_rt_entt_codegen)",
},
"//conditions:default": {
"ECSACT_CLI": "$(rootpath @ecsact_cli)",
"ECSACT_RECIPE_PATH": "$(rootpath @ecsact_rt_entt//:build_recipe.yml)",
"ECSACT_RUNTIME_FILE_PATH": "$(rootpath //:runtime_test.ecsact)",
"ECSACT_IMPORTED_FILE_PATH": "$(rootpath //:imported_pkg.ecsact)",
"ECSACT_CODEGEN_PLUGIN_PATH": "$(rootpath @ecsact_rt_entt//rt_entt_codegen:ecsact_rt_entt_codegen)",
"CC": "$(rootpath @llvm_toolchain_llvm//:bin/clang)",
},
}),
env_inherit = select({
"@platforms//os:windows": [
"PATH",
"PATHEXT",
"PWD",
"APPDATA",
"ProgramData",
"ProgramFiles",
"ProgramFiles(x86)",
"PROGRAMDATA",
"PROGRAMFILES",
"PROGRAMFILES(X86)",
"TEMP",
"OS",
"WINDIR",
],
"//conditions:default": [],
}),
deps = [
"@boost.process",
"@ecsact_cli",
":spawn",
"@googletest//:gtest",
"@googletest//:gtest_main",
],
)

refresh_compile_commands(
name = "refresh_compile_commands",
targets = {
# "//:test_build_recipe": "",
"//:test": "",
},
cc_library(
name = "spawn",
srcs = ["spawn.cc"],
hdrs = ["spawn.hh"],
copts = copts,
deps = [
"@boost.process",
],
)

ecsact_codegen(
Expand Down
11 changes: 9 additions & 2 deletions test/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ bazel_dep(name = "ecsact_runtime", version = "0.6.1")
bazel_dep(name = "boost.mp11", version = "1.83.0.bzl.1")
bazel_dep(name = "boost.dll", version = "1.83.0.bzl.2")
bazel_dep(name = "entt", version = "3.12.2")
bazel_dep(name = "ecsact_cli", version = "0.3.4")
bazel_dep(name = "ecsact_cli", version = "0.3.6")
bazel_dep(name = "boost.process", version = "1.83.0.bzl.2")

bazel_dep(name = "toolchains_llvm", version = "1.0.0", dev_dependency = True)
Expand All @@ -20,6 +20,13 @@ git_override(
remote = "https://github.com/hedronvision/bazel-compile-commands-extractor.git",
)

# TODO: https://github.com/bazelbuild/bazel-central-registry/pull/1916
git_override(
module_name = "libarchive",
commit = "7c331f92acea5243c195cdc6fb46ecfa11ce1ce2",
remote = "https://github.com/zaucy/libarchive.git",
)

bazel_dep(name = "ecsact_rt_entt")
bazel_dep(name = "xxhash", version = "0.8.2")

Expand All @@ -32,7 +39,7 @@ register_toolchains("@ecsact_cli//:all")

llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm", dev_dependency = True)
llvm.toolchain(llvm_version = "17.0.6")
use_repo(llvm, "llvm_toolchain")
use_repo(llvm, "llvm_toolchain", "llvm_toolchain_llvm")

ecsact = use_extension("@rules_ecsact//ecsact:extensions.bzl", "ecsact", dev_dependency = True)
ecsact.toolchain(use_ecsact_cli = True)
Expand Down
Loading

0 comments on commit 653ff0a

Please # to comment.