Skip to content

Commit 026e5ca

Browse files
authored
fix: add missing includes for codegen.hh (#54)
1 parent 714b6fe commit 026e5ca

File tree

4 files changed

+50
-8
lines changed

4 files changed

+50
-8
lines changed

ecsact/codegen/plugin.hh

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <iterator>
99
#include <format>
1010
#include <span>
11+
#include <string.h>
1112
#include "ecsact/runtime/common.h"
1213
#include "ecsact/codegen/plugin.h"
1314

@@ -41,20 +42,24 @@ namespace ecsact {
4142
* }
4243
* ```
4344
*/
44-
inline auto set_codegen_plugin_output_filenames(
45-
const auto& filenames,
46-
char* const* out_filenames,
47-
int32_t max_filenames,
48-
int32_t max_filename_length,
49-
int32_t* out_filenames_length
45+
auto set_codegen_plugin_output_filenames(
46+
const auto& filenames,
47+
char* const* out_filenames,
48+
int32_t max_filenames,
49+
[[maybe_unused]] int32_t max_filename_length,
50+
int32_t* out_filenames_length
5051
) -> void {
5152
if(out_filenames != nullptr) {
5253
for(auto i = 0; max_filenames > i; ++i) {
5354
if(i >= std::size(filenames)) {
5455
break;
5556
}
5657
auto filename = std::data(filenames) + i;
58+
#if defined(__STDC_WANT_SECURE_LIB__) && __STDC_WANT_SECURE_LIB__
5759
strcpy_s(out_filenames[i], max_filename_length, filename->c_str());
60+
#else
61+
strcpy(out_filenames[i], filename->c_str());
62+
#endif
5863
}
5964
}
6065

test/BUILD.bazel

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
load("@rules_cc//cc:defs.bzl", "cc_binary")
21
load("@bazel_skylib//rules:build_test.bzl", "build_test")
3-
load("@ecsact_codegen//bazel:copts.bzl", "copts")
42
load("@ecsact_codegen//:codegen_plugin.bzl", "ecsact_codegen_plugin")
3+
load("@ecsact_codegen//bazel:copts.bzl", "copts")
4+
load("@rules_cc//cc:defs.bzl", "cc_binary")
55

66
cc_binary(
77
name = "mock_plugin_bin",
8+
srcs = ["mock_plugin.cc"],
89
linkshared = True,
910
copts = copts,
1011
deps = [

test/MODULE.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module(name = "ecsact_codegen_test")
22

33
bazel_dep(name = "rules_cc", version = "0.0.9")
44
bazel_dep(name = "bazel_skylib", version = "1.5.0")
5+
56
bazel_dep(name = "toolchains_llvm", version = "1.0.0", dev_dependency = True)
67
bazel_dep(name = "hedron_compile_commands", dev_dependency = True)
78

test/mock_plugin.cc

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,37 @@
1+
#include <array>
2+
#include <string>
13
#include "ecsact/codegen/plugin.h"
24
#include "ecsact/codegen/plugin.hh"
5+
6+
using namespace std::string_literals;
7+
8+
auto ecsact_codegen_output_filenames( //
9+
[[maybe_unused]] ecsact_package_id package_id,
10+
char* const* out_filenames,
11+
int32_t max_filenames,
12+
int32_t max_filename_length,
13+
int32_t* out_filenames_length
14+
) -> void {
15+
ecsact::set_codegen_plugin_output_filenames(
16+
std::array{
17+
"test.a"s,
18+
"test.b"s,
19+
"test.c"s,
20+
},
21+
out_filenames,
22+
max_filenames,
23+
max_filename_length,
24+
out_filenames_length
25+
);
26+
}
27+
28+
auto ecsact_codegen_plugin_name() -> const char* {
29+
return "mock";
30+
}
31+
32+
auto ecsact_codegen_plugin( //
33+
[[maybe_unused]] ecsact_package_id package_id,
34+
[[maybe_unused]] ecsact_codegen_write_fn_t write_fn,
35+
[[maybe_unused]] ecsact_codegen_report_fn_t report_fn
36+
) -> void {
37+
}

0 commit comments

Comments
 (0)