@@ -69,3 +69,53 @@ void process_user_defined_rule(fs::path src_path, string rule_string, InfoPackag
6969
7070}
7171
72+ void process_user_defined_rule_multi_lines (fs::path src_path, string dependency_relationship,
73+ vector<string> commands, InfoPackageScanned& pack)
74+ {
75+ // 分离dependency relationship中的targets与prerequisites
76+ auto colon_pos = dependency_relationship.find (" :" );
77+ string targets = dependency_relationship.substr (0 , colon_pos);
78+ boost::algorithm::trim (targets);
79+ string prerequisites = dependency_relationship.substr (colon_pos + 1 );
80+ boost::algorithm::trim (prerequisites);
81+ // cout << targets << endl;
82+ // cout << prerequisites << endl;
83+
84+ // 分离dependency relationship中的各个target
85+ vector<string> target_vector;
86+ std::string target_delimiters (" " ); // 支持多个分界符
87+ boost::split (target_vector, targets, boost::is_any_of (target_delimiters), boost::token_compress_on); // token_compress_on是为了将单词之间的多个空格视为一个
88+ // for (auto t : target_vector) {
89+ // cout << ">>>" << t << "<<<" << endl;
90+ // }
91+
92+ // 分离prerequisites中的各个prerequisite
93+ vector<string> prerequisite_vector;
94+ std::string prerequisite_delimiters (" " ); // 支持多个分界符
95+ boost::split (prerequisite_vector, prerequisites, boost::is_any_of (prerequisite_delimiters), boost::token_compress_on); // token_compress_on是为了将单词之间的多个空格视为一个
96+ // for (auto p : prerequisite_vector) {
97+ // cout << ">>>" << p << "<<<" << endl;
98+ // }
99+
100+ UserDefinedRule rule;
101+ rule.dir = src_path;
102+ rule.dir .remove_filename ();
103+
104+ for (auto t : target_vector) {
105+ fs::path a = rule.dir ;
106+ a /= t;
107+ rule.targets .push_back (a);
108+ }
109+
110+ for (auto p : prerequisite_vector) {
111+ fs::path a = rule.dir ;
112+ a /= p;
113+ rule.prerequisites .push_back (a);
114+ }
115+
116+
117+ rule.commands = commands;
118+
119+ pack.user_defined_rules .push_back (rule);
120+
121+ }
0 commit comments