-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcpp2b.build.cppm.tpl
More file actions
66 lines (56 loc) · 2.25 KB
/
cpp2b.build.cppm.tpl
File metadata and controls
66 lines (56 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
module;
#if defined(_WIN32)
# define CPP2B_BUILD_API extern "C" __declspec(dllexport)
#else
# define CPP2B_BUILD_API extern "C" __attribute__((visibility("default")))
#endif
export module cpp2b.build;
import std;
struct cpp2b_detail_build_impl;
CPP2B_BUILD_API void (*cpp2b_detail_build_binary_name)(
cpp2b_detail_build_impl *, std::filesystem::path,
std::string_view) = nullptr;
CPP2B_BUILD_API void (*cpp2b_detail_build_cppfront_reflect_inject)(
cpp2b_detail_build_impl *, std::filesystem::path) = nullptr;
export namespace cpp2b {
class build {
cpp2b_detail_build_impl *impl;
public:
inline build(cpp2b_detail_build_impl *impl) : impl(impl) {}
inline build(const build &other) : impl(other.impl) {}
inline build(build &&other) : impl(other.impl) { other.impl = nullptr; }
inline ~build() = default;
/**
* Renames a binary. By default binary names are the same name as their source
* file path with the extension replaced with the target platforms executable
* extension.
*/
inline auto binary_name(std::filesystem::path binary_source_path,
std::string_view new_binary_name) -> void {
return (*cpp2b_detail_build_binary_name)(impl, binary_source_path,
new_binary_name);
}
/**
* Parses the .h2 header looking for functions with any of these signatures:
*
* (inout _: cpp2::meta::declaration) -> void
* (inout _: cpp2::meta::type_declaration) -> void
* (inout _: cpp2::meta::function_declaration) -> void
* (inout _: cpp2::meta::object_declaration) -> void
* (inout _: cpp2::meta::alias_declaration) -> void
*
* Every function with one of these signatures are injected into cppfront's
* reflect.h2 `apply_metafunctions`, making them available as user-defined
* metafunctions. Additionally the header_path is injected as an #include at
* the top of the reflect.h2 header.
*/
inline auto cppfront_reflect_inject(std::filesystem::path header_path) -> void {
return (*cpp2b_detail_build_cppfront_reflect_inject)(impl, header_path);
}
};
} // namespace cpp2b
extern "C" void build(cpp2b::build &b);
CPP2B_BUILD_API void cpp2b_detail_build(cpp2b_detail_build_impl *impl) {
cpp2b::build b(impl);
::build(b);
}