// fileread.cc -- read files for gold
-// Copyright (C) 2006-2020 Free Software Foundation, Inc.
+// Copyright (C) 2006-2021 Free Software Foundation, Inc.
// Written by Ian Lance Taylor <iant@google.com>.
// This file is part of gold.
unsigned long long File_read::total_mapped_bytes;
unsigned long long File_read::current_mapped_bytes;
unsigned long long File_read::maximum_mapped_bytes;
+std::vector<std::string> File_read::files_read;
// Class File_read::View.
gold_debug(DEBUG_FILES, "Attempt to open %s succeeded",
this->name_.c_str());
this->token_.add_writer(task);
+ file_counts_initialize_lock.initialize();
+ Hold_optional_lock hl(file_counts_lock);
+ record_file_read(this->name_);
}
return this->descriptor_ >= 0;
binary_to_elf.converted_size());
}
+void
+File_read::record_file_read(const std::string& name)
+{
+ File_read::files_read.push_back(name);
+}
+
+void
+File_read::write_dependency_file(const char* dependency_file_name,
+ const char* output_file_name)
+{
+ FILE *depfile = fopen(dependency_file_name, "w");
+
+ fprintf(depfile, "%s:", output_file_name);
+ for (std::vector<std::string>::const_iterator it = files_read.begin();
+ it != files_read.end();
+ ++it)
+ fprintf(depfile, " \\\n %s", it->c_str());
+ fprintf(depfile, "\n");
+
+ for (std::vector<std::string>::const_iterator it = files_read.begin();
+ it != files_read.end();
+ ++it)
+ fprintf(depfile, "\n%s:\n", it->c_str());
+
+ fclose(depfile);
+}
+
} // End namespace gold.