From 3a019ffeacb5dc8d06f5fda70449e3c265a39ba7 Mon Sep 17 00:00:00 2001 From: David Rose Date: Wed, 15 Nov 2000 00:10:21 +0000 Subject: [PATCH] *** empty log message *** --- ppremake/ppDependableFile.cxx | 41 +++++++++++++++++++++++++++++++++++ ppremake/ppDependableFile.h | 3 +++ ppremake/ppScope.cxx | 4 ++-- 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/ppremake/ppDependableFile.cxx b/ppremake/ppDependableFile.cxx index c37007cbbb..3c3d298605 100644 --- a/ppremake/ppDependableFile.cxx +++ b/ppremake/ppDependableFile.cxx @@ -11,6 +11,27 @@ #include #include #include +#include + +class SortDependableFilesByName { +public: + bool operator () (PPDependableFile *a, PPDependableFile *b) const { + return a->get_filename() < b->get_filename(); + } +}; + +//////////////////////////////////////////////////////////////////// +// Function: PPDependableFile::Ordering Operator +// Access: Public +// Description: We provide this function so we can sort the +// dependency list into a consistent ordering, so that +// the makefiles won't get randomly regenerated between +// different sessions. +//////////////////////////////////////////////////////////////////// +bool PPDependableFile::Dependency:: +operator < (const Dependency &other) const { + return _file->get_filename() < other._file->get_filename(); +} //////////////////////////////////////////////////////////////////// // Function: PPDependableFile::Constructor @@ -80,6 +101,7 @@ update_from_cache(const vector &words) { } _flags |= F_from_cache; + sort(_dependencies.begin(), _dependencies.end()); } } @@ -204,6 +226,24 @@ get_dependency(int n) { return _dependencies[n]._file; } +//////////////////////////////////////////////////////////////////// +// Function: PPDependableFile::get_complete_dependencies +// Access: Public +// Description: This flavor of get_complete_dependencies() works like +// the one below, except it returns the results in a +// consistently-ordered vector. This allows us to keep +// the dependencies in the same order between sessions +// and prevent makefiles from being arbitrarily +// regenerated. +//////////////////////////////////////////////////////////////////// +void PPDependableFile:: +get_complete_dependencies(vector &files) { + set files_set; + + copy(files_set.begin(), files_set.end(), back_inserter(files)); + sort(files.begin(), files.end(), SortDependableFilesByName()); +} + //////////////////////////////////////////////////////////////////// // Function: PPDependableFile::get_complete_dependencies // Access: Public @@ -377,6 +417,7 @@ compute_dependencies(string &circularity) { } _flags = (_flags & ~F_updating) | F_updated; + sort(_dependencies.begin(), _dependencies.end()); return circ; } diff --git a/ppremake/ppDependableFile.h b/ppremake/ppDependableFile.h index 6b15983c9d..21a3325155 100644 --- a/ppremake/ppDependableFile.h +++ b/ppremake/ppDependableFile.h @@ -39,6 +39,7 @@ public: int get_num_dependencies(); PPDependableFile *get_dependency(int n); + void get_complete_dependencies(vector &files); void get_complete_dependencies(set &files); bool is_circularity(); @@ -70,6 +71,8 @@ private: public: PPDependableFile *_file; bool _okcircular; + + bool operator < (const Dependency &other) const; }; typedef vector Dependencies; diff --git a/ppremake/ppScope.cxx b/ppremake/ppScope.cxx index aafd8fc70b..2aee6b330f 100644 --- a/ppremake/ppScope.cxx +++ b/ppremake/ppScope.cxx @@ -2709,10 +2709,10 @@ expand_dependencies(const string ¶ms) { PPDependableFile *file = _directory->get_dependable_file(*fi, false); assert(file != (PPDependableFile *)NULL); - set files; + vector files; file->get_complete_dependencies(files); - set::const_iterator dfi; + vector::const_iterator dfi; for (dfi = files.begin(); dfi != files.end(); ++dfi) { PPDependableFile *df = (*dfi); string rel_filename =