mirror of
https://github.com/reactos/CMake.git
synced 2024-11-24 20:19:53 +00:00
Add single quotes feature.
This commit is contained in:
parent
e273223d6d
commit
ecca17cfdd
@ -620,7 +620,17 @@ void CMakeSetupDialog::FillCacheGUIFromCacheManager()
|
||||
i != cache.end(); ++i)
|
||||
{
|
||||
const char* key = i->first.c_str();
|
||||
const cmCacheManager::CacheEntry& value = i->second;
|
||||
cmCacheManager::CacheEntry value = i->second;
|
||||
|
||||
// if value has trailing space or tab, enclose it in single quotes
|
||||
// to enforce the fact that it has 'invisible' trailing stuff
|
||||
if (value.m_Value.size() &&
|
||||
(value.m_Value[value.m_Value.size() - 1] == ' ' ||
|
||||
value.m_Value[value.m_Value.size() - 1] == '\t'))
|
||||
{
|
||||
value.m_Value = '\'' + value.m_Value + '\'';
|
||||
}
|
||||
|
||||
if(!m_AdvancedValues)
|
||||
{
|
||||
std::string advancedVar = key;
|
||||
@ -722,7 +732,20 @@ void CMakeSetupDialog::FillCacheManagerFromCacheGUI()
|
||||
(const char*)item->m_propName);
|
||||
if (entry)
|
||||
{
|
||||
entry->m_Value = item->m_curValue;
|
||||
// if value is enclosed in single quotes ('foo') then remove them
|
||||
// they were used to enforce the fact that it had 'invisible'
|
||||
// trailing stuff
|
||||
if (item->m_curValue.GetLength() >= 2 &&
|
||||
item->m_curValue[0] == '\'' &&
|
||||
item->m_curValue[item->m_curValue.GetLength() - 1] == '\'')
|
||||
{
|
||||
entry->m_Value = item->m_curValue.Mid(1,
|
||||
item->m_curValue.GetLength() - 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
entry->m_Value = item->m_curValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -127,21 +127,34 @@ bool cmCacheManager::ParseEntry(const char* entry,
|
||||
cmRegularExpression reg("^([^:]*):([^=]*)=(.*[^\t ]|[\t ]*)[\t ]*$");
|
||||
// input line is: "key":type=value
|
||||
cmRegularExpression regQuoted("^\"([^\"]*)\":([^=]*)=(.*[^\t ]|[\t ]*)[\t ]*$");
|
||||
bool flag = false;
|
||||
if(regQuoted.find(entry))
|
||||
{
|
||||
var = regQuoted.match(1);
|
||||
type = cmCacheManager::StringToType(regQuoted.match(2).c_str());
|
||||
value = regQuoted.match(3);
|
||||
return true;
|
||||
flag = true;
|
||||
}
|
||||
else if (reg.find(entry))
|
||||
{
|
||||
var = reg.match(1);
|
||||
type = cmCacheManager::StringToType(reg.match(2).c_str());
|
||||
value = reg.match(3);
|
||||
return true;
|
||||
flag = true;
|
||||
}
|
||||
return false;
|
||||
|
||||
// if value is enclosed in single quotes ('foo') then remove them
|
||||
// it is used to enclose trailing space or tab
|
||||
if (flag &&
|
||||
value.size() >= 2 &&
|
||||
value[0] == '\'' &&
|
||||
value[value.size() - 1] == '\'')
|
||||
{
|
||||
value = value.substr(1,
|
||||
value.size() - 2);
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
bool cmCacheManager::LoadCache(const char* path,
|
||||
@ -365,8 +378,19 @@ bool cmCacheManager::SaveCache(const char* path)
|
||||
key = i->first;
|
||||
}
|
||||
fout << key.c_str() << ":"
|
||||
<< cmCacheManagerTypes[t] << "="
|
||||
<< ce.m_Value << "\n\n";
|
||||
<< cmCacheManagerTypes[t] << "=";
|
||||
// if value has trailing space or tab, enclose it in single quotes
|
||||
if (ce.m_Value.size() &&
|
||||
(ce.m_Value[ce.m_Value.size() - 1] == ' ' ||
|
||||
ce.m_Value[ce.m_Value.size() - 1] == '\t'))
|
||||
{
|
||||
fout << '\'' << ce.m_Value << '\'';
|
||||
}
|
||||
else
|
||||
{
|
||||
fout << ce.m_Value;
|
||||
}
|
||||
fout << "\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
@ -398,8 +422,19 @@ bool cmCacheManager::SaveCache(const char* path)
|
||||
key = i->first;
|
||||
}
|
||||
fout << key.c_str() << ":"
|
||||
<< cmCacheManagerTypes[t] << "="
|
||||
<< ce.m_Value << "\n";
|
||||
<< cmCacheManagerTypes[t] << "=";
|
||||
// if value has trailing space or tab, enclose it in single quotes
|
||||
if (ce.m_Value.size() &&
|
||||
(ce.m_Value[ce.m_Value.size() - 1] == ' ' ||
|
||||
ce.m_Value[ce.m_Value.size() - 1] == '\t'))
|
||||
{
|
||||
fout << '\'' << ce.m_Value << '\'';
|
||||
}
|
||||
else
|
||||
{
|
||||
fout << ce.m_Value;
|
||||
}
|
||||
fout << "\n";
|
||||
}
|
||||
}
|
||||
fout << "\n";
|
||||
@ -408,7 +443,7 @@ bool cmCacheManager::SaveCache(const char* path)
|
||||
cacheFile.c_str());
|
||||
cmSystemTools::RemoveFile(tempFile.c_str());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void cmCacheManager::OutputHelpString(std::ofstream& fout,
|
||||
const std::string& helpString)
|
||||
|
@ -51,7 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
cmNMakeMakefileGenerator::cmNMakeMakefileGenerator()
|
||||
{
|
||||
m_LibraryPathOption = "$(CMAKE_C_LIBPATH_FLAG)";
|
||||
this->SetLibraryPathOption("@CMAKE_C_LIBPATH_FLAG@"); // Use @ here
|
||||
this->SetObjectFileExtension("$(CMAKE_OBJECT_FILE_SUFFIX)");
|
||||
this->SetExecutableExtension("$(CMAKE_EXECUTABLE_SUFFIX)");
|
||||
this->SetLibraryPrefix("");
|
||||
@ -151,19 +151,14 @@ void cmNMakeMakefileGenerator::OutputMakeVariables(std::ostream& fout)
|
||||
"CMAKE_C_COMPILER = @CMAKE_C_COMPILER@\n"
|
||||
"CMAKE_C_FLAGS = @CMAKE_C_FLAGS@ @BUILD_FLAGS@\n"
|
||||
|
||||
"CMAKE_C_OUTPUT_OBJECT_FILE_FLAG = @CMAKE_C_OUTPUT_OBJECT_FILE_FLAG@\n"
|
||||
"CMAKE_C_OUTPUT_EXECUTABLE_FILE_FLAG = @CMAKE_C_OUTPUT_EXECUTABLE_FILE_FLAG@\n"
|
||||
"CMAKE_C_LINK_EXECUTABLE_FLAG = @CMAKE_C_LINK_EXECUTABLE_FLAG@\n"
|
||||
"CMAKE_C_LIBPATH_FLAG = @CMAKE_C_LIBPATH_FLAG@\n"
|
||||
"CMAKE_CXX_FLAGS = @CMAKE_CXX_FLAGS@ @BUILD_FLAGS@\n"
|
||||
"CMAKE_CXX_COMPILER = @CMAKE_CXX_COMPILER@\n"
|
||||
"CMAKE_LINKER = @CMAKE_LINKER@\n"
|
||||
"CMAKE_LINKER_FLAGS = @CMAKE_LINKER_FLAGS@ @LINKER_BUILD_FLAGS@\n"
|
||||
"CMAKE_LINKER_SHARED_LIBRARY_FLAG = @CMAKE_LINKER_SHARED_LIBRARY_FLAG@\n"
|
||||
"CMAKE_LINKER_OUTPUT_FILE_FLAG = @CMAKE_LINKER_OUTPUT_FILE_FLAG@\n"
|
||||
"CMAKE_LIBRARY_MANAGER = @CMAKE_LIBRARY_MANAGER@\n"
|
||||
"CMAKE_LIBRARY_MANAGER_FLAGS = @CMAKE_LIBRARY_MANAGER_FLAGS@\n"
|
||||
"CMAKE_LIBRARY_MANAGER_OUTPUT_FILE_FLAG = @CMAKE_LIBRARY_MANAGER_OUTPUT_FILE_FLAG@\n"
|
||||
"CMAKE_OBJECT_FILE_SUFFIX = @CMAKE_OBJECT_FILE_SUFFIX@\n"
|
||||
"CMAKE_EXECUTABLE_SUFFIX = @CMAKE_EXECUTABLE_SUFFIX@\n"
|
||||
"CMAKE_STATICLIB_SUFFIX = @CMAKE_STATICLIB_SUFFIX@\n"
|
||||
@ -350,7 +345,14 @@ OutputBuildObjectFromSource(std::ostream& fout,
|
||||
compileCommand += "$(INCLUDE_FLAGS) -c ";
|
||||
compileCommand +=
|
||||
cmSystemTools::EscapeSpaces(source.GetFullPath().c_str());
|
||||
compileCommand += " $(CMAKE_C_OUTPUT_OBJECT_FILE_FLAG)";
|
||||
|
||||
// Need to get the definition here because this value might have
|
||||
// trailing space (since it is directly prepended to the filename)
|
||||
std::string output_object_file_flag =
|
||||
m_Makefile->GetDefinition("CMAKE_C_OUTPUT_OBJECT_FILE_FLAG");
|
||||
m_Makefile->ExpandVariablesInString(output_object_file_flag);
|
||||
|
||||
compileCommand += " " + output_object_file_flag;
|
||||
compileCommand += objectFile;
|
||||
}
|
||||
else if (ext == "rc")
|
||||
@ -378,7 +380,14 @@ OutputBuildObjectFromSource(std::ostream& fout,
|
||||
compileCommand += "$(INCLUDE_FLAGS) -c ";
|
||||
compileCommand +=
|
||||
cmSystemTools::EscapeSpaces(source.GetFullPath().c_str());
|
||||
compileCommand += " $(CMAKE_C_OUTPUT_OBJECT_FILE_FLAG)";
|
||||
|
||||
// Need to get the definition here because this value might have
|
||||
// trailing space (since it is directly prepended to the filename)
|
||||
std::string output_object_file_flag =
|
||||
m_Makefile->GetDefinition("CMAKE_C_OUTPUT_OBJECT_FILE_FLAG");
|
||||
m_Makefile->ExpandVariablesInString(output_object_file_flag);
|
||||
|
||||
compileCommand += " " + output_object_file_flag;
|
||||
compileCommand += objectFile;
|
||||
}
|
||||
m_QuoteNextCommand = false;
|
||||
@ -398,11 +407,20 @@ void cmNMakeMakefileGenerator::OutputSharedLibraryRule(std::ostream& fout,
|
||||
std::string depend = "$(";
|
||||
depend += name;
|
||||
depend += "_SRC_OBJS) $(" + std::string(name) + "_DEPEND_LIBS)";
|
||||
std::string command = "$(CMAKE_LINKER) $(CMAKE_LINKER_SHARED_LIBRARY_FLAG) @<<\n\t";
|
||||
command += " $(" + std::string(name) + "_SRC_OBJS) $(CMAKE_LINKER_FLAGS) $(CMAKE_LINKER_OUTPUT_FILE_FLAG)";
|
||||
|
||||
// Need to get the definition here because this value might have
|
||||
// trailing space (since it is directly prepended to the filename)
|
||||
std::string linker_output_file_flag =
|
||||
m_Makefile->GetDefinition("CMAKE_LINKER_OUTPUT_FILE_FLAG");
|
||||
m_Makefile->ExpandVariablesInString(linker_output_file_flag);
|
||||
|
||||
std::string command = "$(CMAKE_LINKER) $(CMAKE_LINKER_SHARED_LIBRARY_FLAG) @<<\n\t $(CMAKE_LINKER_FLAGS) " + linker_output_file_flag;
|
||||
|
||||
std::string dllpath = m_LibraryOutputPath + std::string(name) + m_SharedLibraryExtension;
|
||||
command += cmSystemTools::EscapeSpaces(dllpath.c_str());
|
||||
command += " ";
|
||||
|
||||
command += " $(" + std::string(name) + "_SRC_OBJS) ";
|
||||
|
||||
std::strstream linklibs;
|
||||
this->OutputLinkLibraries(linklibs, name, t);
|
||||
linklibs << std::ends;
|
||||
@ -440,7 +458,15 @@ void cmNMakeMakefileGenerator::OutputStaticLibraryRule(std::ostream& fout,
|
||||
std::string target = m_LibraryOutputPath + std::string(name) + m_StaticLibraryExtension;
|
||||
std::string depend = "$(";
|
||||
depend += std::string(name) + "_SRC_OBJS)";
|
||||
std::string command = "$(CMAKE_LIBRARY_MANAGER) $(CMAKE_LIBRARY_MANAGER_FLAGS) @<<\n\t $(CMAKE_LIBRARY_MANAGER_OUTPUT_FILE_FLAG)";
|
||||
|
||||
// Need to get the definition here because this value might have
|
||||
// trailing space (since it is directly prepended to the filename)
|
||||
std::string library_manager_output_file_flag =
|
||||
m_Makefile->GetDefinition("CMAKE_LIBRARY_MANAGER_OUTPUT_FILE_FLAG");
|
||||
m_Makefile->ExpandVariablesInString(library_manager_output_file_flag);
|
||||
|
||||
std::string command = "$(CMAKE_LIBRARY_MANAGER) $(CMAKE_LIBRARY_MANAGER_FLAGS) @<<\n\t " + library_manager_output_file_flag;
|
||||
|
||||
std::string libpath = m_LibraryOutputPath + std::string(name) + m_StaticLibraryExtension;
|
||||
command += cmSystemTools::EscapeSpaces(libpath.c_str());
|
||||
command += " $(";
|
||||
@ -468,8 +494,16 @@ void cmNMakeMakefileGenerator::OutputExecutableRule(std::ostream& fout,
|
||||
"$(CMAKE_CXX_COMPILER) $(CMAKE_CXX_FLAGS) ";
|
||||
command += "$(" + std::string(name) + "_SRC_OBJS) ";
|
||||
std::string path = m_ExecutableOutputPath + name + m_ExecutableExtension;
|
||||
command += " $(CMAKE_C_OUTPUT_EXECUTABLE_FILE_FLAG)" +
|
||||
|
||||
// Need to get the definition here because this value might have
|
||||
// trailing space (since it is directly prepended to the filename)
|
||||
std::string output_executable_file_flag =
|
||||
m_Makefile->GetDefinition("CMAKE_C_OUTPUT_EXECUTABLE_FILE_FLAG");
|
||||
m_Makefile->ExpandVariablesInString(output_executable_file_flag);
|
||||
|
||||
command += " " + output_executable_file_flag +
|
||||
cmSystemTools::EscapeSpaces(path.c_str());
|
||||
|
||||
command += " $(CMAKE_C_LINK_EXECUTABLE_FLAG) ";
|
||||
if(t.GetType() == cmTarget::WIN32_EXECUTABLE)
|
||||
{
|
||||
@ -508,7 +542,12 @@ void cmNMakeMakefileGenerator::OutputLinkLibraries(std::ostream& fout,
|
||||
std::string libpath = ShortPath(libDir->c_str());
|
||||
if(emitted.insert(libpath).second)
|
||||
{
|
||||
linkLibs += m_LibraryPathOption;
|
||||
// Expand content because this value might have
|
||||
// trailing space (since it is directly prepended to the filename)
|
||||
std::string replaceVars = m_LibraryPathOption;
|
||||
m_Makefile->ExpandVariablesInString(replaceVars);
|
||||
|
||||
linkLibs += replaceVars;
|
||||
cmSystemTools::ConvertToWindowsSlashes(libpath);
|
||||
linkLibs += libpath;
|
||||
linkLibs += " ";
|
||||
|
Loading…
Reference in New Issue
Block a user