From c64ec77a74b9fac51227b5829bde6c9e566bf0a6 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 --------- WORKSPACE | 9 +++++---- examples/BUILD.bazel | 2 +- include/BUILD.bazel | 12 ++++++++++++ src/BUILD.bazel | 14 ++++++++++++++ test/BUILD.bazel | 19 ++++++++++++------- test/bake_tests.bzl | 15 ++++++++++++++- 7 files changed, 58 insertions(+), 22 deletions(-) delete mode 100644 BUILD create mode 100644 include/BUILD.bazel create mode 100644 src/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/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/examples/BUILD.bazel b/examples/BUILD.bazel index 0327fb4488..5c6362a9bc 100644 --- a/examples/BUILD.bazel +++ b/examples/BUILD.bazel @@ -1,7 +1,7 @@ cc_library( name = "os-api", visibility = ["//:__subpackages__"], - deps = ["//:flecs", "@bake//:util"], + deps = ["//src:flecs", "@bake//:util"], srcs = glob(["os_api/flecs-os_api-bake/src/**/*.c", "os_api/flecs-os_api-bake/src/**/*.h"]), hdrs = glob(["os_api/flecs-os_api-bake/include/**/*.h"]), diff --git a/include/BUILD.bazel b/include/BUILD.bazel new file mode 100644 index 0000000000..4bebfa7519 --- /dev/null +++ b/include/BUILD.bazel @@ -0,0 +1,12 @@ + +cc_library( + name = "flecs", + visibility = ["//visibility:public"], + + hdrs = glob([ + "**/*.h", + "**/*.hpp" + ]), + includes = ["."], + defines = ["flecs_STATIC"], +) diff --git a/src/BUILD.bazel b/src/BUILD.bazel new file mode 100644 index 0000000000..fd14be6091 --- /dev/null +++ b/src/BUILD.bazel @@ -0,0 +1,14 @@ + +cc_library( + name = "flecs", + visibility = ["//visibility:public"], + + srcs = glob([ + "**/*.c", + "**/*.h", + "**/*.inl", + ]), + deps = [ + "//include:flecs" + ], +) diff --git a/test/BUILD.bazel b/test/BUILD.bazel index dadce385b4..032674c10b 100644 --- a/test/BUILD.bazel +++ b/test/BUILD.bazel @@ -1,18 +1,23 @@ load(":bake_tests.bzl", "persuite_bake_tests") -cc_library( - name = "test-api", - deps = ["//:flecs", "//examples:os-api", "@bake//:driver-test"], +cc_test( + name = "api", + deps = ["//src: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", - deps = ["//:flecs", "@bake//:driver-test"], + deps = ["//src:flecs", "@bake//:driver-test"], srcs = glob(["collections/src/*.c", "collections/**/*.h"]), includes = ["collections/include"], @@ -21,8 +26,8 @@ cc_test( ) cc_test( - name = "cpp_api", - deps = ["//:flecs", "@bake//:driver-test"], + name = "cpp-api", + deps = ["//src:flecs", "@bake//:driver-test"], srcs = glob(["cpp_api/src/*.cpp", "cpp_api/**/*.h"]), includes = ["cpp_api/include"], 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(), + }, +)