diff --git a/.bazelignore b/.bazelignore index 5dc6c6f..8185653 100644 --- a/.bazelignore +++ b/.bazelignore @@ -1,3 +1,4 @@ external +test .vsocde .github diff --git a/.bazelrc b/.bazelrc index 3a3bea4..7cddb69 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,17 +1,3 @@ -build --enable_platform_specific_config -build --incompatible_use_platforms_repo_for_constraints -build --incompatible_enable_cc_toolchain_resolution -build --incompatible_strict_action_env -build --enable_runfiles - -build:windows --platforms=//bazel/platforms:windows - -build:linux --platforms=//bazel/platforms:linux -build:linux --extra_toolchains=@llvm_toolchain//:cc-toolchain-x86_64-linux - -build:no-warnings --per_file_copt=//.*@-Werror - -common:ci --announce_rc -common:ci --disk_cache=~/.cache/bazel-disk-cache +import %workspace%/bazel/common.bazelrc try-import %workspace%/user.bazelrc diff --git a/.gitignore b/.gitignore index 793fa8b..50128f7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,9 @@ # bazel -/bazel-* -/user.bazelrc +bazel-*/ +user.bazelrc -# https://github.com/hedronvision/bazel-compile-commands-extractor -/compile_commands.json -/external - -# clangd -/.cache/ +# editor stuff +compile_commands.json +external/ +.cache/ +.helix/ diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 0000000..67d5c0d --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,11 @@ +module( + name = "ecsact_interpret", + version = "0.3.0", + compatibility_level = 3, +) + +bazel_dep(name = "rules_cc", version = "0.0.8") +bazel_dep(name = "bazel_skylib", version = "1.4.2") +bazel_dep(name = "magic_enum", version = "0.9.3") +bazel_dep(name = "ecsact_runtime", version = "0.4.1") +bazel_dep(name = "ecsact_parse", version = "0.2.2") diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel index 7874e7f..de68140 100644 --- a/WORKSPACE.bazel +++ b/WORKSPACE.bazel @@ -1,39 +1,5 @@ -workspace(name = "ecsact_interpret") - load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -http_archive( - name = "magic_enum", - sha256 = "6b948d1680f02542d651fc82154a9e136b341ce55c5bf300736b157e23f9df11", - strip_prefix = "magic_enum-0.8.1", - url = "https://github.com/Neargye/magic_enum/archive/refs/tags/v0.8.1.tar.gz", -) - -http_archive( - name = "ecsact_runtime", - sha256 = "35b03aaef0925fda5b5aefb2d6a6e2c9593f31d6414ab157091f9ca26a992da3", - strip_prefix = "ecsact_runtime-0.3.0", - urls = ["https://github.com/ecsact-dev/ecsact_runtime/archive/refs/tags/0.3.0.tar.gz"], -) - -http_archive( - name = "ecsact_parse", - sha256 = "3f83ae8af26b08472fceef768d2c719a7ea9bedfc907303b9d80d9a7c9b937e9", - strip_prefix = "ecsact_parse-0.2.0", - urls = ["https://github.com/ecsact-dev/ecsact_parse/archive/refs/tags/0.2.0.tar.gz"], -) - -load("@ecsact_parse//:repositories.bzl", "ecsact_parse_dependencies") - -ecsact_parse_dependencies() - -http_archive( - name = "com_google_googletest", - sha256 = "d4cb2430eb82495a49a24310a609b99726726bf126c2fbfa92fd04c14f6a3b31", - strip_prefix = "googletest-d1a0039b97291dd1dc14f123b906bb7622ffe07c", - url = "https://github.com/google/googletest/archive/d1a0039b97291dd1dc14f123b906bb7622ffe07c.zip", -) - http_archive( name = "hedron_compile_commands", sha256 = "ed5aea1dc87856aa2029cb6940a51511557c5cac3dbbcb05a4abd989862c36b4", @@ -47,9 +13,9 @@ hedron_compile_commands_setup() http_archive( name = "com_grail_bazel_toolchain", - sha256 = "c53acf847fb52198758635490c5e987aacc7c64a5731a4027824762ba4e3f961", - strip_prefix = "bazel-toolchain-c217c03479717279035906273702b8bc3309bbb4", - url = "https://github.com/grailbio/bazel-toolchain/archive/c217c03479717279035906273702b8bc3309bbb4.zip", + sha256 = "6c0234db448fea2533c33468ea37207fb4add601667c2e0842f20104ed2ff366", + strip_prefix = "bazel-toolchain-e4fad4e6c1821d805ffd9c21bdd6e2cc52764862", + url = "https://github.com/grailbio/bazel-toolchain/archive/e4fad4e6c1821d805ffd9c21bdd6e2cc52764862.zip", ) load("@com_grail_bazel_toolchain//toolchain:deps.bzl", "bazel_toolchain_dependencies") @@ -60,9 +26,7 @@ load("@com_grail_bazel_toolchain//toolchain:rules.bzl", "llvm_toolchain") llvm_toolchain( name = "llvm_toolchain", - cxx_standard = {"linux": "c++20"}, - distribution = "clang+llvm-15.0.6-x86_64-linux-gnu-ubuntu-18.04.tar.xz", - llvm_version = "15.0.6", + llvm_version = "16.0.4", ) load("@llvm_toolchain//:toolchains.bzl", "llvm_register_toolchains") diff --git a/bazel/common.bazelrc b/bazel/common.bazelrc index 0b43bbe..1bb6433 100644 --- a/bazel/common.bazelrc +++ b/bazel/common.bazelrc @@ -1,5 +1,11 @@ +# This file is maintained by ecsact-dev/ecsact_common +# If changes are required please make them there + startup --windows_enable_symlinks common --enable_bzlmod +common --registry=https://raw.githubusercontent.com/ecsact-dev/bazel_registry/main +common --registry=https://raw.githubusercontent.com/bazelboost/registry/main +common --registry=https://bcr.bazel.build build --enable_platform_specific_config build --incompatible_use_platforms_repo_for_constraints build --incompatible_enable_cc_toolchain_resolution diff --git a/bazel/platforms/BUILD.bazel b/bazel/platforms/BUILD.bazel deleted file mode 100644 index dae4bb2..0000000 --- a/bazel/platforms/BUILD.bazel +++ /dev/null @@ -1,19 +0,0 @@ -package(default_visibility = ["//:__subpackages__"]) - -platform( - name = "windows", - constraint_values = [ - "@platforms//cpu:x86_64", - "@platforms//os:windows", - "@bazel_tools//tools/cpp:msvc", - ], -) - -platform( - name = "linux", - constraint_values = [ - "@platforms//cpu:x86_64", - "@platforms//os:linux", - "@bazel_tools//tools/cpp:clang", - ], -) diff --git a/test/.bazelrc b/test/.bazelrc new file mode 100644 index 0000000..9977a1b --- /dev/null +++ b/test/.bazelrc @@ -0,0 +1,3 @@ +import %workspace%/../bazel/common.bazelrc + +try-import %workspace%/user.bazelrc diff --git a/test/BUILD.bazel b/test/BUILD.bazel index 4a1d559..09409ac 100644 --- a/test/BUILD.bazel +++ b/test/BUILD.bazel @@ -1,14 +1,14 @@ load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") -load("//bazel:copts.bzl", "copts") +load("@ecsact_interpret//bazel:copts.bzl", "copts") cc_library( name = "test_lib", hdrs = ["test_lib.hh"], - visibility = ["//test:__subpackages__"], + visibility = ["//:__subpackages__"], deps = [ - "//:ecsact_interpret", + "@ecsact_interpret", "@bazel_sundry//bazel_sundry:runfiles", - "@com_google_googletest//:gtest", + "@googletest//:gtest", ], ) @@ -18,10 +18,10 @@ cc_test( copts = copts, data = ["test.ecsact"], deps = [ - "//:ecsact_interpret", + "@ecsact_interpret", "@bazel_sundry//bazel_sundry:runfiles", - "@com_google_googletest//:gtest", - "@com_google_googletest//:gtest_main", + "@googletest//:gtest", + "@googletest//:gtest_main", ], ) @@ -32,10 +32,10 @@ cc_test( data = ["comment_before_package.ecsact"], deps = [ ":test_lib", - "//:ecsact_interpret", + "@ecsact_interpret", "@bazel_sundry//bazel_sundry:runfiles", - "@com_google_googletest//:gtest", - "@com_google_googletest//:gtest_main", + "@googletest//:gtest", + "@googletest//:gtest_main", ], ) @@ -51,9 +51,9 @@ cc_test( ], deps = [ ":test_lib", - "//:ecsact_interpret", + "@ecsact_interpret", "@bazel_sundry//bazel_sundry:runfiles", - "@com_google_googletest//:gtest", - "@com_google_googletest//:gtest_main", + "@googletest//:gtest", + "@googletest//:gtest_main", ], ) diff --git a/test/MODULE.bazel b/test/MODULE.bazel new file mode 100644 index 0000000..6b30675 --- /dev/null +++ b/test/MODULE.bazel @@ -0,0 +1,18 @@ +module(name = "ecsact_interpret_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 = "bazel_sundry") +bazel_dep(name = "ecsact_interpret") + +git_override( + module_name = "bazel_sundry", + commit = "a999751b4992fab12a06f1bede2414708c6db540", + remote = "https://github.com/seaube/bazel_sundry", +) + +local_path_override( + module_name = "ecsact_interpret", + path = "..", +) diff --git a/test/WORKSPACE.bazel b/test/WORKSPACE.bazel new file mode 100644 index 0000000..de68140 --- /dev/null +++ b/test/WORKSPACE.bazel @@ -0,0 +1,34 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +http_archive( + name = "hedron_compile_commands", + sha256 = "ed5aea1dc87856aa2029cb6940a51511557c5cac3dbbcb05a4abd989862c36b4", + strip_prefix = "bazel-compile-commands-extractor-e16062717d9b098c3c2ac95717d2b3e661c50608", + url = "https://github.com/hedronvision/bazel-compile-commands-extractor/archive/e16062717d9b098c3c2ac95717d2b3e661c50608.tar.gz", +) + +load("@hedron_compile_commands//:workspace_setup.bzl", "hedron_compile_commands_setup") + +hedron_compile_commands_setup() + +http_archive( + name = "com_grail_bazel_toolchain", + sha256 = "6c0234db448fea2533c33468ea37207fb4add601667c2e0842f20104ed2ff366", + strip_prefix = "bazel-toolchain-e4fad4e6c1821d805ffd9c21bdd6e2cc52764862", + url = "https://github.com/grailbio/bazel-toolchain/archive/e4fad4e6c1821d805ffd9c21bdd6e2cc52764862.zip", +) + +load("@com_grail_bazel_toolchain//toolchain:deps.bzl", "bazel_toolchain_dependencies") + +bazel_toolchain_dependencies() + +load("@com_grail_bazel_toolchain//toolchain:rules.bzl", "llvm_toolchain") + +llvm_toolchain( + name = "llvm_toolchain", + llvm_version = "16.0.4", +) + +load("@llvm_toolchain//:toolchains.bzl", "llvm_register_toolchains") + +llvm_register_toolchains() diff --git a/test/comment_before_package.cc b/test/comment_before_package.cc index 0fb5f17..6b9ceae 100644 --- a/test/comment_before_package.cc +++ b/test/comment_before_package.cc @@ -2,7 +2,7 @@ #include "gtest/gtest.h" #include "ecsact/interpret/eval.h" -#include "test/test_lib.hh" +#include "test_lib.hh" TEST(NoPackageStatementFirst, NoPackageStatementFirst) { auto errs = ecsact_interpret_test_files({"comment_before_package.ecsact"}); diff --git a/test/errors/BUILD.bazel b/test/errors/BUILD.bazel index 7c407e3..ec3452a 100644 --- a/test/errors/BUILD.bazel +++ b/test/errors/BUILD.bazel @@ -1,5 +1,5 @@ load("@rules_cc//cc:defs.bzl", "cc_test") -load("//bazel:copts.bzl", "copts") +load("@ecsact_interpret//bazel:copts.bzl", "copts") _TESTS = [ "no_capabilities", @@ -14,8 +14,9 @@ _TESTS = [ data = ["{}.ecsact".format(test)], args = ["--gtest_catch_exceptions=0"], deps = [ - "//test:test_lib", - "@com_google_googletest//:gtest", - "@com_google_googletest//:gtest_main", + "//:test_lib", + "@ecsact_interpret", + "@googletest//:gtest", + "@googletest//:gtest_main", ], ) for test in _TESTS] diff --git a/test/errors/no_capabilities.cc b/test/errors/no_capabilities.cc index afba490..d0a4ba7 100644 --- a/test/errors/no_capabilities.cc +++ b/test/errors/no_capabilities.cc @@ -1,7 +1,7 @@ #include "gtest/gtest.h" #include "ecsact/interpret/eval.h" -#include "test/test_lib.hh" +#include "test_lib.hh" TEST(NoCapabilities, NoCapabilitiesAction) { auto errs = ecsact_interpret_test_files({"errors/no_capabilities.ecsact"}); diff --git a/test/errors/no_package_statement_first.cc b/test/errors/no_package_statement_first.cc index b5aeec9..26c02c1 100644 --- a/test/errors/no_package_statement_first.cc +++ b/test/errors/no_package_statement_first.cc @@ -1,7 +1,7 @@ #include "gtest/gtest.h" #include "ecsact/interpret/eval.h" -#include "test/test_lib.hh" +#include "test_lib.hh" TEST(NoPackageStatementFirst, NoPackageStatementFirst) { auto errs = diff --git a/test/errors/unknown_association_field.cc b/test/errors/unknown_association_field.cc index 8b10df2..73f40e3 100644 --- a/test/errors/unknown_association_field.cc +++ b/test/errors/unknown_association_field.cc @@ -1,7 +1,7 @@ #include "gtest/gtest.h" #include "ecsact/interpret/eval.h" -#include "test/test_lib.hh" +#include "test_lib.hh" TEST(InterpretError, UnknownAssociationField) { auto errs = diff --git a/test/extra/BUILD.bazel b/test/extra/BUILD.bazel index 8fc0434..7c721e5 100644 --- a/test/extra/BUILD.bazel +++ b/test/extra/BUILD.bazel @@ -1,19 +1,19 @@ -load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") -load("//bazel:copts.bzl", "copts") - -cc_test( - name = "extra", - srcs = ["extra.cc"], - copts = copts, - data = [ - "runtime_test.ecsact", - "imported_pkg.ecsact", - ], - deps = [ - "//test:test_lib", - "//:ecsact_interpret", - "@bazel_sundry//bazel_sundry:runfiles", - "@com_google_googletest//:gtest", - "@com_google_googletest//:gtest_main", - ], -) +load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") +load("@ecsact_interpret//bazel:copts.bzl", "copts") + +cc_test( + name = "extra", + srcs = ["extra.cc"], + copts = copts, + data = [ + "runtime_test.ecsact", + "imported_pkg.ecsact", + ], + deps = [ + "//:test_lib", + "@ecsact_interpret", + "@bazel_sundry//bazel_sundry:runfiles", + "@googletest//:gtest", + "@googletest//:gtest_main", + ], +) diff --git a/test/extra/extra.cc b/test/extra/extra.cc index 34a107a..fa82ba3 100644 --- a/test/extra/extra.cc +++ b/test/extra/extra.cc @@ -2,7 +2,7 @@ #include "ecsact/interpret/eval.h" #include "ecsact/runtime/meta.hh" -#include "test/test_lib.hh" +#include "test_lib.hh" TEST(MultiPkgTest, NoErrors) { auto errs = ecsact_interpret_test_files({ diff --git a/test/multi_pkg.cc b/test/multi_pkg.cc index edcf0e2..002ad97 100644 --- a/test/multi_pkg.cc +++ b/test/multi_pkg.cc @@ -2,7 +2,7 @@ #include "ecsact/interpret/eval.h" #include "ecsact/runtime/meta.hh" -#include "test/test_lib.hh" +#include "test_lib.hh" TEST(MultiPkgTest, NoErrors) { auto errs = ecsact_interpret_test_files({ diff --git a/test/test.cc b/test/test.cc index 55a4960..c36d311 100644 --- a/test/test.cc +++ b/test/test.cc @@ -45,7 +45,7 @@ TEST(EcsactParseRuntimeInterop, Simple) { auto runfiles = bazel_sundry::CreateDefaultRunfiles(); ASSERT_TRUE(runfiles); - auto test_ecsact = runfiles->Rlocation("ecsact_interpret/test/test.ecsact"); + auto test_ecsact = runfiles->Rlocation("ecsact_interpret_test/test.ecsact"); ASSERT_FALSE(test_ecsact.empty()); ASSERT_TRUE(fs::exists(test_ecsact)); diff --git a/test/test_lib.hh b/test/test_lib.hh index a613f49..3f4fdd2 100644 --- a/test/test_lib.hh +++ b/test/test_lib.hh @@ -16,7 +16,7 @@ auto ecsact_interpret_test_files(std::vector relative_file_paths) file_paths.reserve(relative_file_paths.size()); for(auto rel_p : relative_file_paths) { - auto path_rloc = "ecsact_interpret/test/" + rel_p; + auto path_rloc = "ecsact_interpret_test/" + rel_p; auto path = runfiles->Rlocation(path_rloc); [&] { ASSERT_FALSE(path.empty()) << "couldn't find: " << path_rloc << "\n";