Skip to content

Commit

Permalink
Cleaning up the build to work with the new code, and on Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
mason-bially committed Nov 30, 2021
1 parent bc508e4 commit c64ec77
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 22 deletions.
9 changes: 0 additions & 9 deletions BUILD

This file was deleted.

9 changes: 5 additions & 4 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository")
new_git_repository(
name = "bake",
remote = "[email protected]:SanderMertens/bake.git",
commit = "cfc90745f9daa7b7fba80f229af18cdd5029b066",
shallow_since = "1614835160 -0800",
commit = "e2b3d03b61ef36e17a41aa76cb9395b4260468aa",
shallow_since = "1637826538 -0800",

build_file_content = """
cc_library(
name = "driver-test",
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"],
Expand All @@ -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"],
}),
Expand Down
2 changes: 1 addition & 1 deletion examples/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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"]),
Expand Down
12 changes: 12 additions & 0 deletions include/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

cc_library(
name = "flecs",
visibility = ["//visibility:public"],

hdrs = glob([
"**/*.h",
"**/*.hpp"
]),
includes = ["."],
defines = ["flecs_STATIC"],
)
14 changes: 14 additions & 0 deletions src/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

cc_library(
name = "flecs",
visibility = ["//visibility:public"],

srcs = glob([
"**/*.c",
"**/*.h",
"**/*.inl",
]),
deps = [
"//include:flecs"
],
)
19 changes: 12 additions & 7 deletions test/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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"],
Expand All @@ -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"],
Expand Down
15 changes: 14 additions & 1 deletion test/bake_tests.bzl
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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(),
},
)

0 comments on commit c64ec77

Please sign in to comment.