|
4 | 4 |
|
5 | 5 | #include "compiler/code-gen/files/init-scripts.h" |
6 | 6 |
|
| 7 | +#include <chrono> |
| 8 | +#include <string> |
| 9 | + |
| 10 | +#include <fmt/chrono.h> |
| 11 | + |
7 | 12 | #include "compiler/code-gen/common.h" |
8 | 13 | #include "compiler/code-gen/const-globals-batched-mem.h" |
9 | 14 | #include "compiler/code-gen/declarations.h" |
@@ -293,15 +298,24 @@ void CppMainFile::compile(CodeGenerator &W) const { |
293 | 298 | } |
294 | 299 |
|
295 | 300 | void ComponentInfoFile::compile(CodeGenerator &W) const { |
| 301 | + auto build_time{std::chrono::system_clock::to_time_t(G->settings().build_tp)}; |
| 302 | + auto date_str{fmt::format("{:%b %e %Y %T %Z}", fmt::localtime(build_time))}; |
| 303 | + |
296 | 304 | kphp_assert(G->is_output_mode_k2()); |
297 | | - G->settings().get_version(); |
298 | 305 | W << OpenFile("image_info.cpp"); |
299 | 306 | W << ExternInclude(G->settings().runtime_headers.get()); |
300 | 307 | W << "__attribute__((visibility(\"default\"))) const ImageInfo *k2_describe() " << BEGIN << "static ImageInfo imageInfo {\"" |
301 | | - << G->settings().k2_component_name.get() << "\"" << "," << G->settings().build_timestamp.get() << "," |
| 308 | + << G->settings().k2_component_name.get() << "\"" << "," |
| 309 | + << (G->is_output_mode_k2_multishot() ? "0" : "1") << "," |
| 310 | + << std::to_string( |
| 311 | + std::chrono::duration_cast<std::chrono::seconds>(G->settings().build_tp.time_since_epoch()).count() |
| 312 | + ) << "," |
302 | 313 | << "K2_PLATFORM_HEADER_H_VERSION, " |
303 | 314 | << "{}," // todo:k2 add commit hash |
304 | | - << "{}," // todo:k2 add compiler hash? |
305 | | - << (G->is_output_mode_k2_multishot() ? "0" : "1") << "};" << NL << "return &imageInfo;" << NL << END; |
| 315 | + << "\"" << G->settings().k2_component_name.get() << " compiled at " << date_str << " by " // todo:k2 add commit hash of target into version |
| 316 | + << G->settings().get_version() << "\"," |
| 317 | + << "0" << "," |
| 318 | + << "nullptr" |
| 319 | + << "};" << NL << "return &imageInfo;" << NL << END; |
306 | 320 | W << CloseFile(); |
307 | 321 | } |
0 commit comments