Skip to content

Commit 6e71a2b

Browse files
committed
dylib rework
1 parent 5cbf725 commit 6e71a2b

File tree

5 files changed

+82
-25
lines changed

5 files changed

+82
-25
lines changed

dylib/BUILD.bazel

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
load("@rules_cc//cc:defs.bzl", "cc_library")
22
load("//bazel:copts.bzl", "copts")
3+
load("//:index.bzl", "ecsact_runtime_modules")
4+
load(":index.bzl", "cc_ecsact_dylib")
35

46
package(default_visibility = ["//visibility:public"])
57

@@ -11,13 +13,9 @@ cc_library(
1113
copts = copts,
1214
)
1315

14-
cc_library(
15-
name = "meta",
16-
srcs = ["meta-dylib.cc"],
16+
# Convenient targets
17+
[cc_ecsact_dylib(
18+
name = m,
1719
copts = copts,
18-
defines = ["ECSACT_META_API_LOAD_AT_RUNTIME"],
19-
deps = [
20-
":util",
21-
"//:meta",
22-
],
23-
)
20+
ecsact_modules = [m],
21+
) for m in ecsact_runtime_modules]

dylib/README.md

Whitespace-only changes.

dylib/dylib.cc

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,48 @@
22
#include <cassert>
33
#include "ecsact/runtime/dylib.h"
44

5+
#ifdef ECSACT_ASYNC_API_LOAD_AT_RUNTIME
6+
# include "ecsact/runtime/async.h"
7+
#endif
8+
9+
#ifdef ECSACT_CORE_API_LOAD_AT_RUNTIME
10+
# include "ecsact/runtime/core.h"
11+
#endif
12+
13+
#ifdef ECSACT_DYNAMIC_API_LOAD_AT_RUNTIME
14+
# include "ecsact/runtime/dynamic.h"
15+
#endif
16+
517
#ifdef ECSACT_META_API_LOAD_AT_RUNTIME
618
# include "ecsact/runtime/meta.h"
719
#endif
820

21+
#ifdef ECSACT_SERIALIZE_API_LOAD_AT_RUNTIME
22+
# include "ecsact/runtime/serialize.h"
23+
#endif
24+
25+
#include "./dylib-util.hh"
26+
27+
#ifdef ECSACT_ASYNC_API_LOAD_AT_RUNTIME
28+
FOR_EACH_ECSACT_ASYNC_API_FN(ECSACT_DYLIB_UTIL_FN_PTR_DEFN);
29+
#endif
30+
31+
#ifdef ECSACT_CORE_API_LOAD_AT_RUNTIME
32+
FOR_EACH_ECSACT_CORE_API_FN(ECSACT_DYLIB_UTIL_FN_PTR_DEFN);
33+
#endif
34+
35+
#ifdef ECSACT_DYNAMIC_API_LOAD_AT_RUNTIME
36+
FOR_EACH_ECSACT_DYNAMIC_API_FN(ECSACT_DYLIB_UTIL_FN_PTR_DEFN);
37+
#endif
38+
39+
#ifdef ECSACT_META_API_LOAD_AT_RUNTIME
40+
FOR_EACH_ECSACT_META_API_FN(ECSACT_DYLIB_UTIL_FN_PTR_DEFN);
41+
#endif
42+
43+
#ifdef ECSACT_SERIALIZE_API_LOAD_AT_RUNTIME
44+
FOR_EACH_ECSACT_SERIALIZE_API_FN(ECSACT_DYLIB_UTIL_FN_PTR_DEFN);
45+
#endif
46+
947
#define HAS_FN_CHECK(fn_name, target_fn_name) \
1048
if(std::strcmp(target_fn_name, #fn_name) == 0) return true
1149

@@ -16,9 +54,26 @@
1654
static_assert(true, "macro requires ;")
1755

1856
bool ecsact_dylib_has_fn(const char* fn_name) {
57+
#ifdef ECSACT_ASYNC_API_LOAD_AT_RUNTIME
58+
FOR_EACH_ECSACT_ASYNC_API_FN(HAS_FN_CHECK, fn_name);
59+
#endif
60+
61+
#ifdef ECSACT_CORE_API_LOAD_AT_RUNTIME
62+
FOR_EACH_ECSACT_CORE_API_FN(HAS_FN_CHECK, fn_name);
63+
#endif
64+
65+
#ifdef ECSACT_DYNAMIC_API_LOAD_AT_RUNTIME
66+
FOR_EACH_ECSACT_DYNAMIC_API_FN(HAS_FN_CHECK, fn_name);
67+
#endif
68+
1969
#ifdef ECSACT_META_API_LOAD_AT_RUNTIME
2070
FOR_EACH_ECSACT_META_API_FN(HAS_FN_CHECK, fn_name);
2171
#endif
72+
73+
#ifdef ECSACT_SERIALIZE_API_LOAD_AT_RUNTIME
74+
FOR_EACH_ECSACT_SERIALIZE_API_FN(HAS_FN_CHECK, fn_name);
75+
#endif
76+
2277
return false;
2378
}
2479

@@ -30,7 +85,23 @@ void ecsact_dylib_set_fn_addr(const char* fn_name, void (*fn_ptr)()) {
3085
}
3186
#endif // NDEBUG
3287

88+
#ifdef ECSACT_ASYNC_API_LOAD_AT_RUNTIME
89+
FOR_EACH_ECSACT_ASYNC_API_FN(ASSIGN_FN_IF, fn_name, fn_ptr);
90+
#endif
91+
92+
#ifdef ECSACT_CORE_API_LOAD_AT_RUNTIME
93+
FOR_EACH_ECSACT_CORE_API_FN(ASSIGN_FN_IF, fn_name, fn_ptr);
94+
#endif
95+
96+
#ifdef ECSACT_DYNAMIC_API_LOAD_AT_RUNTIME
97+
FOR_EACH_ECSACT_DYNAMIC_API_FN(ASSIGN_FN_IF, fn_name, fn_ptr);
98+
#endif
99+
33100
#ifdef ECSACT_META_API_LOAD_AT_RUNTIME
34101
FOR_EACH_ECSACT_META_API_FN(ASSIGN_FN_IF, fn_name, fn_ptr);
35102
#endif
103+
104+
#ifdef ECSACT_SERIALIZE_API_LOAD_AT_RUNTIME
105+
FOR_EACH_ECSACT_SERIALIZE_API_FN(ASSIGN_FN_IF, fn_name, fn_ptr);
106+
#endif
36107
}

dylib/index.bzl

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,16 @@ def cc_ecsact_dylib(name = None, srcs = [], ecsact_modules = [], deps = [], defi
1717
defines: Passed to underlying cc_library
1818
**kwargs: Passed to underlying cc_library
1919
"""
20-
srcs.append("@ecsact_runtime//dylib:dylib.cc")
21-
deps.append("@ecsact_runtime//:dylib")
2220

2321
for ecsact_module in ecsact_modules:
2422
if not ecsact_module in ecsact_runtime_modules:
2523
fail("Invalid ecsact module '{}'\nAllowed values: {}".format(ecsact_module, ",".join(ecsact_runtime_modules)))
2624

27-
deps.append("@ecsact_runtime//dylib:{}".format(ecsact_module))
28-
defines.append("ECSACT_{}_API_LOAD_AT_RUNTIME".format(ecsact_module.upper()))
29-
3025
cc_library(
3126
name = name,
32-
deps = deps,
33-
defines = defines,
27+
deps = deps + ["@ecsact_runtime//:dylib", "@ecsact_runtime//dylib:util"] + ["@ecsact_runtime//:{}".format(m) for m in ecsact_modules],
28+
srcs = srcs + ["@ecsact_runtime//dylib:dylib.cc"],
29+
defines = defines +
30+
["ECSACT_{}_API_LOAD_AT_RUNTIME".format(m.upper()) for m in ecsact_modules],
3431
**kwargs
3532
)

dylib/meta-dylib.cc

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)