summaryrefslogtreecommitdiffstats
path: root/Source/cmSourceFileLocation.h
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2007-06-18 15:59:23 (GMT)
committerBrad King <brad.king@kitware.com>2007-06-18 15:59:23 (GMT)
commit35936433e11728397dcdb2beab615674bfa79ec7 (patch)
tree8222a4daea955055c852d6db058421a570a8f6b2 /Source/cmSourceFileLocation.h
parentef81ac50e5d6e981088c00e822fde538d9da9e37 (diff)
downloadCMake-35936433e11728397dcdb2beab615674bfa79ec7.zip
CMake-35936433e11728397dcdb2beab615674bfa79ec7.tar.gz
CMake-35936433e11728397dcdb2beab615674bfa79ec7.tar.bz2
ENH: Merging changes from branch CMake-SourceFile2-b between tags
CMake-SourceFile2-bp and CMake-SourceFile2-b-mp1 to trunk. This commit is surrounded by tags CMake-SourceFile2-b-mp1-pre and CMake-SourceFile2-b-mp1-post on the trunk. The changes re-implement cmSourceFile and the use of it to allow instances to be created much earlier. The use of cmSourceFileLocation allows locating a source file referenced by a user to be much simpler and more robust. The two SetName methods are no longer needed so some duplicate code has been removed. The strange "SourceName" stuff is gone. Code that created cmSourceFile instances on the stack and then sent them to cmMakefile::AddSource has been simplified and converted to getting cmSourceFile instances from cmMakefile. The CPluginAPI has preserved the old API through a compatibility interface. Source lists are gone. Targets now get real instances of cmSourceFile right away instead of storing a list of strings until the final pass. TraceVSDependencies has been re-written to avoid the use of SourceName. It is now called TraceDependencies since it is not just for VS. It is now implemented with a helper object which makes the code simpler.
Diffstat (limited to 'Source/cmSourceFileLocation.h')
-rw-r--r--Source/cmSourceFileLocation.h104
1 files changed, 104 insertions, 0 deletions
diff --git a/Source/cmSourceFileLocation.h b/Source/cmSourceFileLocation.h
new file mode 100644
index 0000000..c14b2fa
--- /dev/null
+++ b/Source/cmSourceFileLocation.h
@@ -0,0 +1,104 @@
+/*=========================================================================
+
+ Program: CMake - Cross-Platform Makefile Generator
+ Module: $RCSfile$
+ Language: C++
+ Date: $Date$
+ Version: $Revision$
+
+ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
+ See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+#ifndef cmSourceFileLocation_h
+#define cmSourceFileLocation_h
+
+#include "cmStandardIncludes.h"
+
+class cmMakefile;
+
+/** \class cmSourceFileLocation
+ * \brief cmSourceFileLocation tracks knowledge about a source file location
+ *
+ * Source files can be referenced by a variety of names. The
+ * directory and/or extension may be omitted leading to a certain
+ * level of ambiguity about the source file location. This class is
+ * used by cmSourceFile to keep track of what is known about the
+ * source file location. Each reference may add some information
+ * about the directory or extension of the file.
+ */
+class cmSourceFileLocation
+{
+public:
+ /**
+ * Construct for a source file created in a given cmMakefile
+ * instance with an initial name.
+ */
+ cmSourceFileLocation(cmMakefile* mf, const char* name);
+
+ /**
+ * Return whether the givne source file location could refers to the
+ * same source file as this location given the level of ambiguity in
+ * each location.
+ */
+ bool Matches(cmSourceFileLocation const& loc);
+
+ /**
+ * Explicity state that the source file is located in the source tree.
+ */
+ void DirectoryUseSource();
+
+ /**
+ * Explicity state that the source file is located in the build tree.
+ */
+ void DirectoryUseBinary();
+
+ /**
+ * Return whether the directory containing the source is ambiguous.
+ */
+ bool DirectoryIsAmbiguous() const { return this->AmbiguousDirectory; }
+
+ /**
+ * Return whether the extension of the source name is ambiguous.
+ */
+ bool ExtensionIsAmbiguous() const { return this->AmbiguousExtension; }
+
+ /**
+ * Get the directory containing the file as best is currently known.
+ * If DirectoryIsAmbiguous() returns false this will be a full path.
+ * Otherwise it will be a relative path (possibly empty) that is
+ * either with respect to the source or build tree.
+ */
+ const char* GetDirectory() const { return this->Directory.c_str(); }
+
+ /**
+ * Get the file name as best is currently known. If
+ * ExtensionIsAmbiguous() returns true this name may not be the
+ * final name (but could be). Otherwise the returned name is the
+ * final name.
+ */
+ const char* GetName() const { return this->Name.c_str(); }
+
+ /**
+ * Get the cmMakefile instance for which the source file was created.
+ */
+ cmMakefile* GetMakefile() const { return this->Makefile; }
+private:
+ cmMakefile* Makefile;
+ bool AmbiguousDirectory;
+ bool AmbiguousExtension;
+ std::string Directory;
+ std::string Name;
+
+ // Update the location with additional knowledge.
+ void Update(cmSourceFileLocation const& loc);
+ void Update(const char* name);
+ void UpdateExtension(const char* name);
+ void UpdateDirectory(const char* name);
+};
+
+#endif