mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
fix caching
This commit is contained in:
parent
82a8cc00cf
commit
c72ae36a9f
@ -73,7 +73,7 @@ update_from_cache(const vector<string> &words) {
|
|||||||
time_t mtime = strtol(words[1].c_str(), (char **)NULL, 10);
|
time_t mtime = strtol(words[1].c_str(), (char **)NULL, 10);
|
||||||
if (mtime == get_mtime()) {
|
if (mtime == get_mtime()) {
|
||||||
// The modification matches; preserve the cache information.
|
// The modification matches; preserve the cache information.
|
||||||
PPDirectoryTree *tree = _directory->get_tree()->get_main_tree();
|
PPDirectoryTree *tree = _directory->get_tree();
|
||||||
|
|
||||||
_dependencies.clear();
|
_dependencies.clear();
|
||||||
vector<string>::const_iterator wi;
|
vector<string>::const_iterator wi;
|
||||||
@ -125,6 +125,9 @@ write_cache(ostream &out) {
|
|||||||
if ((*di)._okcircular) {
|
if ((*di)._okcircular) {
|
||||||
out << "/";
|
out << "/";
|
||||||
}
|
}
|
||||||
|
if ((*di)._file->get_directory()->get_tree() != get_directory()->get_tree()) {
|
||||||
|
out << "+";
|
||||||
|
}
|
||||||
out << (*di)._file->get_dirpath();
|
out << (*di)._file->get_dirpath();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -361,18 +364,23 @@ compute_dependencies(string &circularity) {
|
|||||||
|
|
||||||
if ((_flags & F_from_cache) == 0) {
|
if ((_flags & F_from_cache) == 0) {
|
||||||
// Now open the file and scan it for #include statements.
|
// Now open the file and scan it for #include statements.
|
||||||
ifstream in(get_fullpath().c_str());
|
Filename filename(get_fullpath());
|
||||||
if (!in) {
|
filename.set_text();
|
||||||
|
ifstream in;
|
||||||
|
if (!filename.open_read(in)) {
|
||||||
// Can't read the file, or the file doesn't exist. Interesting.
|
// Can't read the file, or the file doesn't exist. Interesting.
|
||||||
if (exists()) {
|
if (exists()) {
|
||||||
cerr << "Warning: dependent file " << get_fullpath()
|
cerr << "Warning: dependent file " << filename
|
||||||
<< " exists but cannot be read.\n";
|
<< " exists but cannot be read.\n";
|
||||||
} else {
|
} else {
|
||||||
cerr << "Warning: dependent file " << get_fullpath()
|
cerr << "Warning: dependent file " << filename
|
||||||
<< " does not exist.\n";
|
<< " does not exist.\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
if (verbose) {
|
||||||
|
cerr << "Reading (dep) \"" << filename << "\"\n";
|
||||||
|
}
|
||||||
PPDirectoryTree *tree = _directory->get_tree()->get_main_tree();
|
PPDirectoryTree *tree = _directory->get_tree()->get_main_tree();
|
||||||
|
|
||||||
bool okcircular = false;
|
bool okcircular = false;
|
||||||
|
@ -491,6 +491,10 @@ scan_extra_depends(const string &cache_filename) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (verbose) {
|
||||||
|
cerr << "Scanning external directory " << get_fullpath() << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
vector<string>::const_iterator fi;
|
vector<string>::const_iterator fi;
|
||||||
for (fi = filenames.begin(); fi != filenames.end(); ++fi) {
|
for (fi = filenames.begin(); fi != filenames.end(); ++fi) {
|
||||||
string filename = (*fi);
|
string filename = (*fi);
|
||||||
@ -512,10 +516,11 @@ scan_extra_depends(const string &cache_filename) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
bool PPDirectory::
|
bool PPDirectory::
|
||||||
read_source_file(const string &prefix, PPNamedScopes *named_scopes) {
|
read_source_file(const string &prefix, PPNamedScopes *named_scopes) {
|
||||||
string source_filename = prefix + SOURCE_FILENAME;
|
Filename source_filename = prefix + SOURCE_FILENAME;
|
||||||
|
source_filename.set_text();
|
||||||
|
|
||||||
ifstream in(source_filename.c_str());
|
ifstream in;
|
||||||
if (in) {
|
if (source_filename.open_read(in)) {
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
cerr << "Reading (dir) \"" << source_filename << "\"\n";
|
cerr << "Reading (dir) \"" << source_filename << "\"\n";
|
||||||
}
|
}
|
||||||
@ -706,14 +711,18 @@ compute_depends_index() {
|
|||||||
void PPDirectory::
|
void PPDirectory::
|
||||||
read_file_dependencies(const string &cache_filename) {
|
read_file_dependencies(const string &cache_filename) {
|
||||||
// Open up the dependency cache file in the directory.
|
// Open up the dependency cache file in the directory.
|
||||||
string cache_pathname = get_path() + "/" + cache_filename;
|
Filename cache_pathname(get_fullpath(), cache_filename);
|
||||||
ifstream in(cache_pathname.c_str());
|
cache_pathname.set_text();
|
||||||
if (!in) {
|
ifstream in;
|
||||||
|
|
||||||
|
if (!cache_pathname.open_read(in)) {
|
||||||
// Can't read it. Maybe it's not there. No problem.
|
// Can't read it. Maybe it's not there. No problem.
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
cerr << "Reading (dep) \"" << cache_pathname.c_str() << "\"\n";
|
cerr << "Couldn't read \"" << cache_pathname << "\"\n";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (verbose) {
|
||||||
|
cerr << "Loading cache \"" << cache_pathname << "\"\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
string line;
|
string line;
|
||||||
@ -727,6 +736,7 @@ read_file_dependencies(const string &cache_filename) {
|
|||||||
}
|
}
|
||||||
getline(in, line);
|
getline(in, line);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Children::iterator ci;
|
Children::iterator ci;
|
||||||
for (ci = _children.begin(); ci != _children.end(); ++ci) {
|
for (ci = _children.begin(); ci != _children.end(); ++ci) {
|
||||||
@ -772,12 +782,17 @@ update_file_dependencies(const string &cache_filename) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (verbose) {
|
||||||
|
cerr << "Rewriting cache " << cache_pathname << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
// Walk through our list of dependable files, writing them out the
|
// Walk through our list of dependable files, writing them out the
|
||||||
// the cache file.
|
// the cache file.
|
||||||
|
bool external_tree = (_tree->get_main_tree() != _tree);
|
||||||
Dependables::const_iterator di;
|
Dependables::const_iterator di;
|
||||||
for (di = _dependables.begin(); di != _dependables.end(); ++di) {
|
for (di = _dependables.begin(); di != _dependables.end(); ++di) {
|
||||||
PPDependableFile *file = (*di).second;
|
PPDependableFile *file = (*di).second;
|
||||||
if (file->was_examined()) {
|
if (file->was_examined() || external_tree) {
|
||||||
if (file->is_circularity()) {
|
if (file->is_circularity()) {
|
||||||
cerr << "Warning: circular #include directives:\n"
|
cerr << "Warning: circular #include directives:\n"
|
||||||
<< " " << file->get_circularity() << "\n";
|
<< " " << file->get_circularity() << "\n";
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include "ppDirectoryTree.h"
|
#include "ppDirectoryTree.h"
|
||||||
#include "ppDirectory.h"
|
#include "ppDirectory.h"
|
||||||
|
#include "ppDependableFile.h"
|
||||||
#include "tokenize.h"
|
#include "tokenize.h"
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -257,6 +258,16 @@ get_dependable_file_by_dirpath(const string &dirpath, bool is_header) {
|
|||||||
string dirname = dirpath.substr(0, slash);
|
string dirname = dirpath.substr(0, slash);
|
||||||
string filename = dirpath.substr(slash + 1);
|
string filename = dirpath.substr(slash + 1);
|
||||||
|
|
||||||
|
if (!dirname.empty() && dirname[0] == '+') {
|
||||||
|
// "+dirname/filename" means to look first for the file as an
|
||||||
|
// external file, meaning it has no dirname.
|
||||||
|
dirname = dirname.substr(1);
|
||||||
|
PPDependableFile *result = get_main_tree()->find_dependable_file(filename);
|
||||||
|
if (result != (PPDependableFile *)NULL) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PPDirectory *dir = find_dirname(dirname);
|
PPDirectory *dir = find_dirname(dirname);
|
||||||
if (dir == (PPDirectory *)NULL) {
|
if (dir == (PPDirectory *)NULL) {
|
||||||
// No valid directory name.
|
// No valid directory name.
|
||||||
@ -276,6 +287,11 @@ get_dependable_file_by_dirpath(const string &dirpath, bool is_header) {
|
|||||||
void PPDirectoryTree::
|
void PPDirectoryTree::
|
||||||
read_file_dependencies(const string &cache_filename) {
|
read_file_dependencies(const string &cache_filename) {
|
||||||
_root->read_file_dependencies(cache_filename);
|
_root->read_file_dependencies(cache_filename);
|
||||||
|
|
||||||
|
RelatedTrees::iterator ri;
|
||||||
|
for (ri = _related_trees.begin(); ri != _related_trees.end(); ++ri) {
|
||||||
|
(*ri)->read_file_dependencies(cache_filename);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user