Rolling back symbolic path changes until it works on Windows.

This commit is contained in:
Amitha Perera 2002-01-07 15:49:07 -05:00
parent 8f1b833759
commit b2085d7e9d
4 changed files with 47 additions and 121 deletions

View File

@ -94,7 +94,6 @@ inline int Chdir(const char* dir)
bool cmSystemTools::s_DisableRunCommandOutput = false; bool cmSystemTools::s_DisableRunCommandOutput = false;
bool cmSystemTools::s_ErrorOccured = false; bool cmSystemTools::s_ErrorOccured = false;
bool cmSystemTools::s_DisableMessages = false; bool cmSystemTools::s_DisableMessages = false;
cmSystemTools::PathMap cmSystemTools::s_PathMap;
void (*cmSystemTools::s_ErrorCallback)(const char*, const char*, bool&); void (*cmSystemTools::s_ErrorCallback)(const char*, const char*, bool&);
@ -1177,7 +1176,6 @@ std::string cmSystemTools::GetCurrentWorkingDirectory()
{ {
char buf[2048]; char buf[2048];
std::string path = Getcwd(buf, 2048); std::string path = Getcwd(buf, 2048);
ApplyPathTranslation( path );
return path; return path;
} }
@ -1239,7 +1237,6 @@ void cmSystemTools::SplitProgramPath(const char* in_name,
std::string cmSystemTools::CollapseFullPath(const char* in_name) std::string cmSystemTools::CollapseFullPath(const char* in_name)
{ {
std::string dir, file; std::string dir, file;
std::string return_value;
cmSystemTools::SplitProgramPath(in_name, dir, file); cmSystemTools::SplitProgramPath(in_name, dir, file);
#ifdef _WIN32 #ifdef _WIN32
// Ultra-hack warning: // Ultra-hack warning:
@ -1251,7 +1248,8 @@ std::string cmSystemTools::CollapseFullPath(const char* in_name)
Chdir(cwd.c_str()); Chdir(cwd.c_str());
cmSystemTools::ConvertToUnixSlashes(newDir); cmSystemTools::ConvertToUnixSlashes(newDir);
return_value = newDir; std::string newPath = newDir+"/"+file;
return newPath;
#else #else
# ifdef MAXPATHLEN # ifdef MAXPATHLEN
char resolved_name[MAXPATHLEN]; char resolved_name[MAXPATHLEN];
@ -1271,13 +1269,8 @@ std::string cmSystemTools::CollapseFullPath(const char* in_name)
{ {
dir = cmSystemTools::GetCurrentWorkingDirectory(); dir = cmSystemTools::GetCurrentWorkingDirectory();
} }
return_value = dir; return dir + "/" + file;
#endif #endif
if(file != "")
return_value += "/" + file;
ApplyPathTranslation( return_value );
return return_value;
} }
/** /**
@ -1431,24 +1424,3 @@ void cmSystemTools::GlobDirs(const char *fullPath,
} }
} }
} }
void cmSystemTools::AddPathTranslation( const std::string& from, const std::string& to )
{
s_PathMap[from] = to;
}
void cmSystemTools::ApplyPathTranslation( std::string& path )
{
PathMap::iterator i;
// For each key in the map, see if path starts with it. If so, perform the substitution.
for( i = s_PathMap.begin(); i != s_PathMap.end(); ++i )
{
if( path.substr( 0, i->first.length() ) == i->first )
{
path.replace( 0, i->first.length(), i->second );
return;
}
}
}

View File

@ -254,16 +254,6 @@ public:
std::string& file); std::string& file);
static std::string CollapseFullPath(const char*); static std::string CollapseFullPath(const char*);
/**
* all file path prefixes matching \arg from will be replaced by
* \arg to. Affects the return value of CollapseFullPath and
* GetCurrentWorkingDirectory.
*/
static void AddPathTranslation( const std::string& from, const std::string& to );
///! Apply the current path translations to \arg path.
static void ApplyPathTranslation( std::string& path );
///! return path of a full filename (no trailing slashes). ///! return path of a full filename (no trailing slashes).
static std::string GetFilenamePath(const std::string&); static std::string GetFilenamePath(const std::string&);
@ -305,9 +295,6 @@ private:
static bool s_DisableMessages; static bool s_DisableMessages;
static bool s_DisableRunCommandOutput; static bool s_DisableRunCommandOutput;
static ErrorCallback s_ErrorCallback; static ErrorCallback s_ErrorCallback;
typedef std::map<cmStdString, cmStdString> PathMap;
static PathMap s_PathMap;
}; };

View File

@ -53,7 +53,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
cmake::cmake() cmake::cmake()
{ {
m_Verbose = false; m_Verbose = false;
m_UsePathTranslation = false;
#if defined(_WIN32) && !defined(__CYGWIN__) #if defined(_WIN32) && !defined(__CYGWIN__)
cmMakefileGenerator::RegisterGenerator(new cmMSProjectGenerator); cmMakefileGenerator::RegisterGenerator(new cmMSProjectGenerator);
cmMakefileGenerator::RegisterGenerator(new cmNMakeMakefileGenerator); cmMakefileGenerator::RegisterGenerator(new cmNMakeMakefileGenerator);
@ -68,9 +67,8 @@ void cmake::Usage(const char* program)
std::cerr << "cmake version " << cmMakefile::GetMajorVersion() std::cerr << "cmake version " << cmMakefile::GetMajorVersion()
<< "." << cmMakefile::GetMinorVersion() << " - " << "." << cmMakefile::GetMinorVersion() << " - "
<< cmMakefile::GetReleaseVersion() << "\n"; << cmMakefile::GetReleaseVersion() << "\n";
std::cerr << "Usage: " << program << " [srcdir] [outdir] [options]\n" std::cerr << "Usage: " << program << " [srcdir] [options]\n"
<< "Where cmake is run from the directory where you want the object files written. If srcdir is not specified, the current directory is used for both source and object files.\n"; << "Where cmake is run from the directory where you want the object files written. If srcdir is not specified, the current directory is used for both source and object files.\n";
std::cerr << "If outdir is specified, pathname translation is enabled, and srcdir and outdir are used as given to access the roots of source and output directories.\n";
std::cerr << "Options are:\n"; std::cerr << "Options are:\n";
std::cerr << "\n-i (puts cmake in wizard mode, not available for ccmake)\n"; std::cerr << "\n-i (puts cmake in wizard mode, not available for ccmake)\n";
std::cerr << "\n-DVAR:TYPE=VALUE (create a cache file entry)\n"; std::cerr << "\n-DVAR:TYPE=VALUE (create a cache file entry)\n";
@ -130,9 +128,29 @@ void cmake::SetArgs(cmMakefile& builder, const std::vector<std::string>& args)
{ {
m_Local = false; m_Local = false;
bool directoriesSet = false; bool directoriesSet = false;
// watch for cmake and cmake srcdir invocations
std::string srcdir; if (args.size() <= 2)
std::string outdir; {
directoriesSet = true;
builder.SetHomeOutputDirectory
(cmSystemTools::GetCurrentWorkingDirectory().c_str());
builder.SetStartOutputDirectory
(cmSystemTools::GetCurrentWorkingDirectory().c_str());
if (args.size() == 2)
{
builder.SetHomeDirectory
(cmSystemTools::CollapseFullPath(args[1].c_str()).c_str());
builder.SetStartDirectory
(cmSystemTools::CollapseFullPath(args[1].c_str()).c_str());
}
else
{
builder.SetHomeDirectory
(cmSystemTools::GetCurrentWorkingDirectory().c_str());
builder.SetStartDirectory
(cmSystemTools::GetCurrentWorkingDirectory().c_str());
}
}
for(unsigned int i=1; i < args.size(); ++i) for(unsigned int i=1; i < args.size(); ++i)
{ {
@ -141,12 +159,6 @@ void cmake::SetArgs(cmMakefile& builder, const std::vector<std::string>& args)
{ {
directoriesSet = true; directoriesSet = true;
std::string path = arg.substr(2); std::string path = arg.substr(2);
if( cmSystemTools::CollapseFullPath(path.c_str()) != path &&
path.size() > 0 && path[0] != '.' )
{
cmSystemTools::AddPathTranslation( cmSystemTools::CollapseFullPath(path.c_str()), path );
m_UsePathTranslation = true;
}
builder.SetHomeDirectory(path.c_str()); builder.SetHomeDirectory(path.c_str());
} }
else if(arg.find("-S",0) == 0) else if(arg.find("-S",0) == 0)
@ -166,12 +178,6 @@ void cmake::SetArgs(cmMakefile& builder, const std::vector<std::string>& args)
{ {
directoriesSet = true; directoriesSet = true;
std::string path = arg.substr(2); std::string path = arg.substr(2);
if( cmSystemTools::CollapseFullPath(path.c_str()) != path &&
path.size() > 0 && path[0] != '.' )
{
cmSystemTools::AddPathTranslation( cmSystemTools::CollapseFullPath(path.c_str()), path );
m_UsePathTranslation = true;
}
builder.SetHomeOutputDirectory(path.c_str()); builder.SetHomeOutputDirectory(path.c_str());
} }
else if(arg.find("-V",0) == 0) else if(arg.find("-V",0) == 0)
@ -201,66 +207,31 @@ void cmake::SetArgs(cmMakefile& builder, const std::vector<std::string>& args)
builder.SetMakefileGenerator(gen); builder.SetMakefileGenerator(gen);
} }
} }
// no option assume it is the path to the source or to the output // no option assume it is the path to the source
else else
{ {
if( srcdir.size() == 0 ) directoriesSet = true;
{ builder.SetHomeOutputDirectory
srcdir = arg; (cmSystemTools::GetCurrentWorkingDirectory().c_str());
} builder.SetStartOutputDirectory
else if( outdir.size() == 0 ) (cmSystemTools::GetCurrentWorkingDirectory().c_str());
{ builder.SetHomeDirectory
// Make sure the symbolic output directory specified matches (cmSystemTools::CollapseFullPath(arg.c_str()).c_str());
// the current directory, and that the symbolic path is builder.SetStartDirectory
// absolute. Even if not, set the outdir variable so that (cmSystemTools::CollapseFullPath(arg.c_str()).c_str());
// further attempts to set the output directory (with
// another command line argument) fails.
if( cmSystemTools::CollapseFullPath( arg.c_str() ) == cmSystemTools::GetCurrentWorkingDirectory() )
{
outdir = arg;
if( srcdir.size() > 0 && srcdir[0] != '.' && outdir.size() > 0 && outdir[0] != '.' )
{
cmSystemTools::AddPathTranslation( cmSystemTools::GetCurrentWorkingDirectory(), outdir );
cmSystemTools::AddPathTranslation( cmSystemTools::CollapseFullPath(srcdir.c_str()), srcdir );
m_UsePathTranslation = true;
}
else
{
std::cerr << "Symbolic paths must be absolute for path translation. One of \"" << srcdir
<< "\" or \"" << outdir << "\" is not.\n"
<< "Not performing path name translation." << std::endl;
outdir = cmSystemTools::GetCurrentWorkingDirectory();
}
}
else
{
std::cerr << "The current working directory (" << cmSystemTools::GetCurrentWorkingDirectory() << ")\n"
<< "does not match the binary directory (" << (cmSystemTools::CollapseFullPath(arg.c_str())) << ")\n"
<< "[ given as " << arg << " ].\n"
<< "Not performing path name translation." << std::endl;
outdir = cmSystemTools::GetCurrentWorkingDirectory();
}
}
else
{
std::cerr << "Ignoring parameter " << arg << std::endl;
}
} }
} }
if(!directoriesSet) if(!directoriesSet)
{ {
if( srcdir.size() == 0 ) srcdir = cmSystemTools::GetCurrentWorkingDirectory(); builder.SetHomeOutputDirectory
(cmSystemTools::GetCurrentWorkingDirectory().c_str());
outdir = cmSystemTools::GetCurrentWorkingDirectory(); builder.SetStartOutputDirectory
srcdir = cmSystemTools::CollapseFullPath( srcdir.c_str() ); (cmSystemTools::GetCurrentWorkingDirectory().c_str());
builder.SetHomeDirectory
builder.SetHomeOutputDirectory( outdir.c_str() ); (cmSystemTools::GetCurrentWorkingDirectory().c_str());
builder.SetStartOutputDirectory( outdir.c_str() ); builder.SetStartDirectory
builder.SetHomeDirectory( srcdir.c_str() ); (cmSystemTools::GetCurrentWorkingDirectory().c_str());
builder.SetStartDirectory( srcdir.c_str() );
} }
if (!m_Local) if (!m_Local)
{ {
builder.SetStartDirectory(builder.GetHomeDirectory()); builder.SetStartDirectory(builder.GetHomeDirectory());
@ -271,13 +242,10 @@ void cmake::SetArgs(cmMakefile& builder, const std::vector<std::string>& args)
// at the end of this CMAKE_ROOT and CMAKE_COMMAND should be added to the cache // at the end of this CMAKE_ROOT and CMAKE_COMMAND should be added to the cache
void cmake::AddCMakePaths(const std::vector<std::string>& args) void cmake::AddCMakePaths(const std::vector<std::string>& args)
{ {
// Find our own executable. If path translations are enabled and the // Find our own executable.
// user supplies the full path to cmake, use it as the canonical
// name (i.e. don't translate to a local disk path).
std::string cMakeSelf = args[0]; std::string cMakeSelf = args[0];
cmSystemTools::ConvertToUnixSlashes(cMakeSelf); cmSystemTools::ConvertToUnixSlashes(cMakeSelf);
if(!(m_UsePathTranslation && cmSystemTools::FileExists(cMakeSelf.c_str()) && cMakeSelf[0]!='.')) cMakeSelf = cmSystemTools::FindProgram(cMakeSelf.c_str());
cMakeSelf = cmSystemTools::FindProgram(cMakeSelf.c_str());
if(!cmSystemTools::FileExists(cMakeSelf.c_str())) if(!cmSystemTools::FileExists(cMakeSelf.c_str()))
{ {
#ifdef CMAKE_BUILD_DIR #ifdef CMAKE_BUILD_DIR

View File

@ -83,6 +83,5 @@ class cmake
private: private:
bool m_Verbose; bool m_Verbose;
bool m_Local; bool m_Local;
bool m_UsePathTranslation;
}; };