77 std::vector<std::string> objects_list,
78 std::string target_id) {
79 std::vector<extended_metadata> metadatas;
84 for (
size_t i = 0; i < file_list.size(); i++) {
85 metadatas.push_back({.meta = {.source = file_list.at(i),
86 .
object = objects_list.at(i),
90 .old_metadata_available =
false});
93 for (
size_t i = 0; i < metadatas.size(); i++) {
94 auto meta = &(metadatas.at(i));
97 meta->old_metadata_available =
true;
102 if (toolchain != NULL) {
103 auto cc = toolchain->get_cmds()[0];
104 toolchain->stdargs();
105 auto cargs = toolchain->get_compile_args();
106 for (
size_t i = 0; i < metadatas.size(); i++) {
107 auto meta = &metadatas.at(i);
109 auto file = meta->meta.source;
110 auto cmd = cc +
" " + cargs +
" " + file +
" -MM";
112 std::stringstream ss(ret);
116 std::vector<std::string> deps;
117 while (std::getline(ss, tmp,
' ')) {
118 if (tmp != std::string(
"") && tmp != std::string(
"\\\n") &&
119 tmp != std::string(
"\n")) {
124 for (
auto dep : deps) {
127 }
catch (std::exception& e) {
130 for (
auto elem : deps_selector) {
131 meta->meta.deps.push_back(elem.key);
133 if (!(meta->meta.deps.empty())) {
134 meta->meta.deps.back().pop_back();
137 std::ifstream f(file);
139 std::getline(f, content,
'\0');
145 for (
auto meta : metadatas) {
148 std::string(
"\nObject: ") + meta.meta.object +
149 std::string(
"\nDeps [new]:"));
150 for (
auto dep : meta.meta.deps) {
155 }
catch (std::exception& e) {
159 if (meta.old_metadata_available) {
160 for (
auto dep : meta.old_meta.deps) {
167 std::string(
", Hash [old]: ") +
168 (meta.old_metadata_available ? std::to_string(meta.old_meta.hash)
169 : std::string(
"null")));
174 for (
size_t i = 0; i < header_metadatas.
size(); i++) {
175 auto meta = &(header_metadatas.
ptr_at(i)->data);
177 auto file = header_metadatas.
at(i).key;
178 auto cmd = cc +
" " + cargs +
" " + file +
" -MM";
180 std::stringstream ss(ret);
184 std::vector<std::string> deps;
185 while (std::getline(ss, tmp,
' ')) {
186 if (tmp != std::string(
"") && tmp != std::string(
"\\\n") &&
187 tmp != std::string(
"\n")) {
192 for (
auto dep : deps) {
195 }
catch (std::exception& e) {
198 for (
auto elem : deps_selector) {
199 meta->meta.deps.push_back(elem.key);
201 if (!(meta->meta.deps.empty())) {
202 meta->meta.deps.back().pop_back();
204 for (
auto dep : meta->meta.deps) {
207 }
catch (std::exception& e) {
211 std::ifstream f(file);
213 std::getline(f, content,
'\0');
217 meta->old_metadata_available = (err == 0);
219 meta->meta.source = file;
220 meta->meta.object =
"header";
225 for (
auto meta_container : header_metadatas) {
226 auto meta = meta_container.data;
229 std::string(
"\nObject: ") + meta.meta.object +
230 std::string(
"\nDeps [new]:"));
231 for (
auto dep : meta.meta.deps) {
235 if (meta.old_metadata_available) {
236 for (
auto dep : meta.old_meta.deps) {
243 std::string(
", Hash [old]: ") +
244 (meta.old_metadata_available ? std::to_string(meta.old_meta.hash)
245 : std::string(
"null")));
249 for (
auto file : metadatas) {
251 ret.
push_back(file.meta.source, file.meta.object);
lib::map< std::string, std::string > gcc_hash_impl(std::vector< std::string > file_list, std::vector< std::string > objects_list, std::string target_id)
Implementation of GCC hasher.