@@ -27,26 +27,20 @@ constexpr const char *const kGenerateTaskName = "Generate";
27
27
28
28
namespace buildcc {
29
29
30
- void CustomGenerator::AddDefaultArgument (const std::string &identifier,
31
- const std::string &pattern) {
30
+ void CustomGenerator::AddPattern (const std::string &identifier,
31
+ const std::string &pattern) {
32
32
command_.AddDefaultArgument (identifier, command_.Construct (pattern));
33
33
}
34
34
35
- void CustomGenerator::AddDefaultArguments (
36
- const std::unordered_map<std::string, std::string> &arguments ) {
37
- for (const auto &arg_iter : arguments ) {
38
- AddDefaultArgument (arg_iter.first , arg_iter.second );
35
+ void CustomGenerator::AddPatterns (
36
+ const std::unordered_map<std::string, std::string> &pattern_map ) {
37
+ for (const auto &arg_iter : pattern_map ) {
38
+ AddPattern (arg_iter.first , arg_iter.second );
39
39
}
40
40
}
41
41
42
- std::string CustomGenerator::Construct (
43
- const std::string &pattern,
44
- const std::unordered_map<const char *, std::string> &arguments) {
45
- return command_.Construct (pattern, arguments);
46
- }
47
-
48
- const std::string &CustomGenerator::GetValueByIdentifier (
49
- const std::string &file_identifier) const {
42
+ const std::string &
43
+ CustomGenerator::Get (const std::string &file_identifier) const {
50
44
return command_.GetDefaultValueByKey (file_identifier);
51
45
}
52
46
@@ -60,10 +54,16 @@ void CustomGenerator::AddGenInfo(
60
54
61
55
UserGenInfo schema;
62
56
for (const auto &i : inputs) {
63
- schema.inputs .emplace (command_.Construct (path_as_string (i)));
57
+ fs::path input =
58
+ internal::Path::CreateNewPath (command_.Construct (path_as_string (i)))
59
+ .GetPathname ();
60
+ schema.inputs .emplace (std::move (input));
64
61
}
65
62
for (const auto &o : outputs) {
66
- schema.outputs .emplace (command_.Construct (path_as_string (o)));
63
+ fs::path output =
64
+ internal::Path::CreateNewPath (command_.Construct (path_as_string (o)))
65
+ .GetPathname ();
66
+ schema.outputs .emplace (std::move (output));
67
67
}
68
68
schema.generate_cb = generate_cb;
69
69
schema.blob_handler = std::move (blob_handler);
@@ -90,6 +90,8 @@ void CustomGenerator::Initialize() {
90
90
//
91
91
fs::create_directories (env_.GetTargetBuildDir ());
92
92
command_.AddDefaultArguments ({
93
+ {" project_root_dir" , path_as_string (Project::GetRootDir ())},
94
+ {" project_build_dir" , path_as_string (Project::GetBuildDir ())},
93
95
{" gen_root_dir" , path_as_string (env_.GetTargetRootDir ())},
94
96
{" gen_build_dir" , path_as_string (env_.GetTargetBuildDir ())},
95
97
});
0 commit comments