// fileread.cc -- read files for gold
-// Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012
-// 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;
File_read::lock(const Task* task)
{
gold_assert(this->released_);
+ gold_debug(DEBUG_FILES, "Locking file \"%s\"", this->name_.c_str());
this->token_.add_writer(task);
this->released_ = false;
}
void
File_read::unlock(const Task* task)
{
+ gold_debug(DEBUG_FILES, "Unlocking file \"%s\"", this->name_.c_str());
this->release();
this->token_.remove_writer(task);
}
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.