From dff4893a73f81f67a29033409783232f52b8b1cc Mon Sep 17 00:00:00 2001 From: Mason Bially Date: Mon, 29 Nov 2021 17:21:24 -0800 Subject: [PATCH] Cleaning up the build to work with the new code, and on Windows. --- BUILD | 9 --------- BUILD.bazel | 30 ++++++++++++++++++++++++++++++ WORKSPACE | 9 +++++---- test/BUILD.bazel | 15 ++++++++++----- test/bake_tests.bzl | 15 ++++++++++++++- 5 files changed, 59 insertions(+), 19 deletions(-) delete mode 100644 BUILD create mode 100644 BUILD.bazel diff --git a/BUILD b/BUILD deleted file mode 100644 index f940b57cec..0000000000 --- a/BUILD +++ /dev/null @@ -1,9 +0,0 @@ - -cc_library( - name = "flecs", - visibility = ["//visibility:public"], - - srcs = glob(["src/**/*.c", "src/**/*.h"]), - hdrs = glob(["include/**/*.h", "include/**/*.hpp"]), - includes = ["include"], -) diff --git a/BUILD.bazel b/BUILD.bazel new file mode 100644 index 0000000000..9c8d951eec --- /dev/null +++ b/BUILD.bazel @@ -0,0 +1,30 @@ + +# MSVC+Bazel can't stand for the header at the root, so we have to use the amalgamated one +cc_library( + name = "flecs", + visibility = ["//visibility:public"], + + srcs = ["flecs.c"], + hdrs = ["flecs.h"], +) + +# In theory this is the correct build rule (if it was named `:flecs`) +cc_library( + name = "flecs-broken", + + srcs = glob(["src/**/*.h*", "src/**/*.c*", "src/**/*.inl"]), + hdrs = glob(["include/**/*.h*"]), + includes = ["include"], + strip_include_prefix = "include", + + # because the MSVC include path generator is just wrong + # see gh: https://github.com/bazelbuild/bazel/issues/8706#issuecomment-985133244 + features = select({ + "@bazel_tools//src/conditions:windows": ["-include_paths"], + "//conditions:default": [], + }), + copts = select({ + "@bazel_tools//src/conditions:windows": ["/Iinclude"], + "//conditions:default": [], + }), +) diff --git a/WORKSPACE b/WORKSPACE index 34536ebfa8..51c693c198 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -3,8 +3,8 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") new_git_repository( name = "bake", remote = "git@github.com:SanderMertens/bake.git", - commit = "cfc90745f9daa7b7fba80f229af18cdd5029b066", - shallow_since = "1614835160 -0800", + commit = "e2b3d03b61ef36e17a41aa76cb9395b4260468aa", + shallow_since = "1637826538 -0800", build_file_content = """ cc_library( @@ -12,6 +12,7 @@ cc_library( visibility = ["//visibility:public"], deps = [":util", ":bake"], + defines = ["bake_test_STATIC"], srcs = glob(["drivers/test/src/**/*.c", "drivers/test/src/**/*.h"]), hdrs = glob(["drivers/test/include/**/*.h"]), includes = ["drivers/test/include"], @@ -30,10 +31,10 @@ cc_library( cc_library( name = "util", visibility = ["//visibility:public"], - defines = ["__BAKE__", "_XOPEN_SOURCE=600"], + defines = ["UT_IMPL", "__BAKE__", "_XOPEN_SOURCE=600"], linkopts = select({ - "@bazel_tools//src/conditions:windows": [], + "@bazel_tools//src/conditions:windows": ["-DEFAULTLIB:dbghelp -DEFAULTLIB:shell32 -DEFAULTLIB:shlwapi"], "//conditions:default": ["-lrt -lpthread -ldl"], }), diff --git a/test/BUILD.bazel b/test/BUILD.bazel index dadce385b4..91954b1193 100644 --- a/test/BUILD.bazel +++ b/test/BUILD.bazel @@ -1,14 +1,19 @@ load(":bake_tests.bzl", "persuite_bake_tests") -cc_library( - name = "test-api", +cc_test( + name = "api", deps = ["//:flecs", "//examples:os-api", "@bake//:driver-test"], srcs = glob(["api/src/*.c", "api/**/*.h"]), + includes = ["api/include"], ) -persuite_bake_tests("api", [":test-api"], glob(["api/src/*.c"], exclude=["api/src/main.c", "api/src/util.c"])) +#persuite_bake_tests( +# name = "api", +# deps = [":test-api"], +# suites = glob(["api/src/*.c"], exclude=["api/src/main.c", "api/src/util.c"]), +#) cc_test( name = "collections", @@ -21,11 +26,11 @@ cc_test( ) cc_test( - name = "cpp_api", + name = "cpp-api", deps = ["//:flecs", "@bake//:driver-test"], srcs = glob(["cpp_api/src/*.cpp", "cpp_api/**/*.h"]), includes = ["cpp_api/include"], - timeout = "short", + timeout = "moderate", ) diff --git a/test/bake_tests.bzl b/test/bake_tests.bzl index 969f6cb779..ba7daf0d54 100644 --- a/test/bake_tests.bzl +++ b/test/bake_tests.bzl @@ -1,5 +1,10 @@ -def persuite_bake_tests(name, deps, suites, visibility=None): +def _impl(ctx): + name = ctx.attr.name + deps = ctx.attr.deps + suites = ctx.attr.suites + visibility = None # ctx.attr.visibility + suites_mangled = [s.partition(".")[0].rpartition("/")[2] for s in suites] for s in suites_mangled: @@ -14,3 +19,11 @@ def persuite_bake_tests(name, deps, suites, visibility=None): name = name, tests = [":{}-{}".format(name, s) for s in suites_mangled] ) + +persuite_bake_tests = rule( + implementation = _impl, + attrs = { + "deps": attr.label_list(), + "suites": attr.string_list(), + }, +)