-
Notifications
You must be signed in to change notification settings - Fork 563
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(config): save __build_info in compiled config
- Loading branch information
Showing
5 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// Copyright RIME Developers | ||
// Distributed under the BSD License | ||
// | ||
#include <boost/filesystem.hpp> | ||
#include <rime/service.h> | ||
#include <rime/config/config_compiler.h> | ||
#include <rime/config/config_types.h> | ||
#include <rime/config/plugins.h> | ||
|
||
namespace rime { | ||
|
||
bool BuildInfoPlugin::ReviewCompileOutput( | ||
ConfigCompiler* compiler, an<ConfigResource> resource) { | ||
return true; | ||
} | ||
|
||
bool BuildInfoPlugin::ReviewLinkOutput( | ||
ConfigCompiler* compiler, an<ConfigResource> resource) { | ||
auto build_info = (*resource)["__build_info"]; | ||
build_info["rime_version"] = RIME_VERSION; | ||
auto timestamps = build_info["timestamps"]; | ||
compiler->EnumerateResources([&](an<ConfigResource> resource) { | ||
if (!resource->loaded) { | ||
LOG(WARNING) << "resource '" << resource->resource_id << "' not loaded."; | ||
return; | ||
} | ||
auto file_name = resource->data->file_name(); | ||
if (file_name.empty()) { | ||
return; | ||
} | ||
// TODO: store as 64-bit number to avoid the year 2038 problem | ||
timestamps[resource->resource_id] = | ||
(int) boost::filesystem::last_write_time(file_name); | ||
}); | ||
return true; | ||
} | ||
|
||
} // namespace rime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters