Skip to content

Commit 9af0bec

Browse files
committed
DaemonSourceGenerator: provide embedded files as part as the namespace
1 parent fb9e39f commit 9af0bec

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

cmake/DaemonSourceGenerator.cmake

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,17 @@ macro(daemon_embed_files BASENAME SLUG FORMAT TARGETNAME)
6363
set(EMBED_${kind}_TEXT "${DAEMON_GENERATED_HEADER}")
6464
endforeach()
6565

66-
string(APPEND EMBED_CPP_TEXT "#include \"${EMBED_H_FILE}\"\n\n")
66+
string(APPEND EMBED_CPP_TEXT
67+
"#include \"${EMBED_H_FILE}\"\n"
68+
"\n"
69+
"namespace ${BASENAME} {\n"
70+
)
71+
72+
string(APPEND EMBED_H_TEXT
73+
"#include \"common/Common.h\"\n"
74+
"\n"
75+
"namespace ${BASENAME} {\n"
76+
)
6777

6878
set(EMBED_MAP_TEXT "")
6979

@@ -87,26 +97,29 @@ macro(daemon_embed_files BASENAME SLUG FORMAT TARGETNAME)
8797
set_property(TARGET "${TARGETNAME}" APPEND PROPERTY SOURCES "${outpath}")
8898

8999
string(APPEND EMBED_CPP_TEXT
90-
"#include \"${BASENAME}/${filename_symbol}.h\"\n")
100+
"#include \"${BASENAME}/${filename_symbol}.h\"\n"
101+
)
102+
103+
string(APPEND EMBED_H_TEXT
104+
"extern const unsigned char ${filename_symbol}[];\n"
105+
)
106+
91107
string(APPEND EMBED_MAP_TEXT
92108
"\t{ \"${filename}\", "
93109
"std::string(reinterpret_cast<const char *>( ${filename_symbol} ), "
94-
"sizeof( ${filename_symbol} )) },\n")
110+
"sizeof( ${filename_symbol} )) },\n"
111+
)
95112
endforeach()
96113

97114
string(APPEND EMBED_CPP_TEXT
98115
"\n"
99-
"namespace ${BASENAME} {\n"
100116
"const std::unordered_map<std::string, std::string> FileMap\n{\n"
101117
"${EMBED_MAP_TEXT}"
102118
"};\n"
103119
"}"
104120
)
105121

106122
string(APPEND EMBED_H_TEXT
107-
"#include \"common/Common.h\"\n"
108-
"\n"
109-
"namespace ${BASENAME} {\n"
110123
"extern const std::unordered_map<std::string, std::string> FileMap;\n"
111124
"};\n"
112125
)

0 commit comments

Comments
 (0)