diff options
Diffstat (limited to 'Source')
635 files changed, 12157 insertions, 8789 deletions
diff --git a/Source/.gitattributes b/Source/.gitattributes index 1cec8a3..f69ad9d 100644 --- a/Source/.gitattributes +++ b/Source/.gitattributes @@ -17,5 +17,4 @@ /cmListFileLexer.c generated # Do not format third-party sources. -/bindexplib.* -format.clang-format /kwsys/** -format.clang-format diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 2835ee6..8d683cb3f 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -344,6 +344,8 @@ set(SRCS cmPropertyDefinitionMap.h cmPropertyMap.cxx cmPropertyMap.h + cmQtAutoGeneratorCommon.cxx + cmQtAutoGeneratorCommon.h cmQtAutoGeneratorInitializer.cxx cmQtAutoGeneratorInitializer.h cmQtAutoGenerators.cxx @@ -381,6 +383,8 @@ set(SRCS cmVariableWatch.h cmVersion.cxx cmVersion.h + cmWorkingDirectory.cxx + cmWorkingDirectory.h cmXMLParser.cxx cmXMLParser.h cmXMLSafe.cxx @@ -440,6 +444,8 @@ set(SRCS cmCreateTestSourceList.h cmDefinePropertyCommand.cxx cmDefinePropertyCommand.h + cmDisallowedCommand.cxx + cmDisallowedCommand.h cmEnableLanguageCommand.cxx cmEnableLanguageCommand.h cmEnableTestingCommand.cxx @@ -637,6 +643,7 @@ if(APPLE) set(SRCS ${SRCS} cmXCodeObject.cxx cmXCode21Object.cxx + cmXCodeScheme.cxx cmGlobalXCodeGenerator.cxx cmGlobalXCodeGenerator.h cmLocalXCodeGenerator.cxx @@ -882,6 +889,12 @@ add_library(CTestLib ${CTEST_SRCS}) target_link_libraries(CTestLib CMakeLib ${CMAKE_CURL_LIBRARIES} ${CMAKE_XMLRPC_LIBRARIES}) # +# CPack +# +include_directories( + "${CMake_SOURCE_DIR}/Source/CPack" + ) +# # Sources for CPack # set(CPACK_SRCS diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 65e7b5d..fcb0b8b 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 8) -set(CMake_VERSION_PATCH 0) -#set(CMake_VERSION_RC 0) +set(CMake_VERSION_PATCH 20170424) +#set(CMake_VERSION_RC 1) diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.cxx b/Source/CPack/IFW/cmCPackIFWGenerator.cxx index ee46d86..fa8982f 100644 --- a/Source/CPack/IFW/cmCPackIFWGenerator.cxx +++ b/Source/CPack/IFW/cmCPackIFWGenerator.cxx @@ -2,12 +2,12 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCPackIFWGenerator.h" -#include "CPack/cmCPackComponentGroup.h" -#include "CPack/cmCPackGenerator.h" -#include "CPack/cmCPackLog.h" +#include "cmCPackComponentGroup.h" +#include "cmCPackGenerator.h" #include "cmCPackIFWInstaller.h" #include "cmCPackIFWPackage.h" #include "cmCPackIFWRepository.h" +#include "cmCPackLog.h" #include "cmGeneratedFileStream.h" #include "cmSystemTools.h" #include "cmTimestamp.h" diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.h b/Source/CPack/IFW/cmCPackIFWGenerator.h index d656063..688db4b 100644 --- a/Source/CPack/IFW/cmCPackIFWGenerator.h +++ b/Source/CPack/IFW/cmCPackIFWGenerator.h @@ -3,10 +3,10 @@ #ifndef cmCPackIFWGenerator_h #define cmCPackIFWGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" -#include "CPack/cmCPackComponentGroup.h" -#include "CPack/cmCPackGenerator.h" +#include "cmCPackComponentGroup.h" +#include "cmCPackGenerator.h" #include "cmCPackIFWInstaller.h" #include "cmCPackIFWPackage.h" #include "cmCPackIFWRepository.h" diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.cxx b/Source/CPack/IFW/cmCPackIFWInstaller.cxx index d8bafee..57b47f1 100644 --- a/Source/CPack/IFW/cmCPackIFWInstaller.cxx +++ b/Source/CPack/IFW/cmCPackIFWInstaller.cxx @@ -2,16 +2,16 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCPackIFWInstaller.h" -#include <cmConfigure.h> +#include "cmConfigure.h" #include <sstream> #include <stddef.h> #include <utility> -#include "CPack/cmCPackGenerator.h" -#include "CPack/cmCPackLog.h" +#include "cmCPackGenerator.h" #include "cmCPackIFWGenerator.h" #include "cmCPackIFWPackage.h" #include "cmCPackIFWRepository.h" +#include "cmCPackLog.h" #include "cmGeneratedFileStream.h" #include "cmSystemTools.h" #include "cmXMLParser.h" @@ -288,7 +288,7 @@ public: hasFiles = false; hasErrors = false; - basePath = cmSystemTools::GetFilenamePath(installer->Resources[r].data()); + basePath = cmSystemTools::GetFilenamePath(installer->Resources[r]); ParseFile(installer->Resources[r].data()); @@ -360,8 +360,7 @@ void cmCPackIFWInstaller::GenerateInstallerFile() cmSystemTools::GetFilenameName(InstallerApplicationIcon); std::string path = Directory + "/config/" + name; name = cmSystemTools::GetFilenameWithoutExtension(name); - cmsys::SystemTools::CopyFileIfDifferent(InstallerApplicationIcon.data(), - path.data()); + cmsys::SystemTools::CopyFileIfDifferent(InstallerApplicationIcon, path); xout.Element("InstallerApplicationIcon", name); } @@ -369,8 +368,7 @@ void cmCPackIFWInstaller::GenerateInstallerFile() if (!InstallerWindowIcon.empty()) { std::string name = cmSystemTools::GetFilenameName(InstallerWindowIcon); std::string path = Directory + "/config/" + name; - cmsys::SystemTools::CopyFileIfDifferent(InstallerWindowIcon.data(), - path.data()); + cmsys::SystemTools::CopyFileIfDifferent(InstallerWindowIcon, path); xout.Element("InstallerWindowIcon", name); } @@ -378,7 +376,7 @@ void cmCPackIFWInstaller::GenerateInstallerFile() if (!Logo.empty()) { std::string name = cmSystemTools::GetFilenameName(Logo); std::string path = Directory + "/config/" + name; - cmsys::SystemTools::CopyFileIfDifferent(Logo.data(), path.data()); + cmsys::SystemTools::CopyFileIfDifferent(Logo, path); xout.Element("Logo", name); } @@ -386,7 +384,7 @@ void cmCPackIFWInstaller::GenerateInstallerFile() if (!Banner.empty()) { std::string name = cmSystemTools::GetFilenameName(Banner); std::string path = Directory + "/config/" + name; - cmsys::SystemTools::CopyFileIfDifferent(Banner.data(), path.data()); + cmsys::SystemTools::CopyFileIfDifferent(Banner, path); xout.Element("Banner", name); } @@ -394,7 +392,7 @@ void cmCPackIFWInstaller::GenerateInstallerFile() if (!Watermark.empty()) { std::string name = cmSystemTools::GetFilenameName(Watermark); std::string path = Directory + "/config/" + name; - cmsys::SystemTools::CopyFileIfDifferent(Watermark.data(), path.data()); + cmsys::SystemTools::CopyFileIfDifferent(Watermark, path); xout.Element("Watermark", name); } @@ -402,7 +400,7 @@ void cmCPackIFWInstaller::GenerateInstallerFile() if (!Background.empty()) { std::string name = cmSystemTools::GetFilenameName(Background); std::string path = Directory + "/config/" + name; - cmsys::SystemTools::CopyFileIfDifferent(Background.data(), path.data()); + cmsys::SystemTools::CopyFileIfDifferent(Background, path); xout.Element("Background", name); } @@ -480,7 +478,7 @@ void cmCPackIFWInstaller::GenerateInstallerFile() if (!IsVersionLess("2.0") && !ControlScript.empty()) { std::string name = cmSystemTools::GetFilenameName(ControlScript); std::string path = Directory + "/config/" + name; - cmsys::SystemTools::CopyFileIfDifferent(ControlScript.data(), path.data()); + cmsys::SystemTools::CopyFileIfDifferent(ControlScript, path); xout.Element("ControlScript", name); } @@ -492,8 +490,7 @@ void cmCPackIFWInstaller::GenerateInstallerFile() if (parser.ParseResource(i)) { std::string name = cmSystemTools::GetFilenameName(Resources[i]); std::string path = Directory + "/resources/" + name; - cmsys::SystemTools::CopyFileIfDifferent(Resources[i].data(), - path.data()); + cmsys::SystemTools::CopyFileIfDifferent(Resources[i], path); resources.push_back(name); } else { cmCPackLogger(cmCPackLog::LOG_WARNING, "Can't copy resources from \"" diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.h b/Source/CPack/IFW/cmCPackIFWInstaller.h index 4ec3e70..64239cf 100644 --- a/Source/CPack/IFW/cmCPackIFWInstaller.h +++ b/Source/CPack/IFW/cmCPackIFWInstaller.h @@ -3,7 +3,7 @@ #ifndef cmCPackIFWInstaller_h #define cmCPackIFWInstaller_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <map> #include <string> diff --git a/Source/CPack/IFW/cmCPackIFWPackage.cxx b/Source/CPack/IFW/cmCPackIFWPackage.cxx index e23b1b9..99e8b9e 100644 --- a/Source/CPack/IFW/cmCPackIFWPackage.cxx +++ b/Source/CPack/IFW/cmCPackIFWPackage.cxx @@ -2,17 +2,17 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCPackIFWPackage.h" -#include "CPack/cmCPackComponentGroup.h" -#include "CPack/cmCPackGenerator.h" -#include "CPack/cmCPackLog.h" +#include "cmCPackComponentGroup.h" +#include "cmCPackGenerator.h" #include "cmCPackIFWGenerator.h" #include "cmCPackIFWInstaller.h" +#include "cmCPackLog.h" #include "cmGeneratedFileStream.h" #include "cmSystemTools.h" #include "cmTimestamp.h" #include "cmXMLWriter.h" -#include <cmConfigure.h> +#include "cmConfigure.h" #include <map> #include <sstream> #include <stddef.h> @@ -590,7 +590,7 @@ void cmCPackIFWPackage::GeneratePackageFile() if (!Script.empty()) { std::string name = cmSystemTools::GetFilenameName(Script); std::string path = Directory + "/meta/" + name; - cmsys::SystemTools::CopyFileIfDifferent(Script.data(), path.data()); + cmsys::SystemTools::CopyFileIfDifferent(Script, path); xout.Element("Script", name); } @@ -599,8 +599,7 @@ void cmCPackIFWPackage::GeneratePackageFile() for (size_t i = 0; i < userInterfaces.size(); i++) { std::string name = cmSystemTools::GetFilenameName(userInterfaces[i]); std::string path = Directory + "/meta/" + name; - cmsys::SystemTools::CopyFileIfDifferent(userInterfaces[i].data(), - path.data()); + cmsys::SystemTools::CopyFileIfDifferent(userInterfaces[i], path); userInterfaces[i] = name; } if (!userInterfaces.empty()) { @@ -616,8 +615,7 @@ void cmCPackIFWPackage::GeneratePackageFile() for (size_t i = 0; i < translations.size(); i++) { std::string name = cmSystemTools::GetFilenameName(translations[i]); std::string path = Directory + "/meta/" + name; - cmsys::SystemTools::CopyFileIfDifferent(translations[i].data(), - path.data()); + cmsys::SystemTools::CopyFileIfDifferent(translations[i], path); translations[i] = name; } if (!translations.empty()) { @@ -675,7 +673,7 @@ void cmCPackIFWPackage::GeneratePackageFile() for (size_t i = 1; i < licenses.size(); i += 2) { std::string name = cmSystemTools::GetFilenameName(licenses[i]); std::string path = Directory + "/meta/" + name; - cmsys::SystemTools::CopyFileIfDifferent(licenses[i].data(), path.data()); + cmsys::SystemTools::CopyFileIfDifferent(licenses[i], path); licenses[i] = name; } if (!licenses.empty()) { diff --git a/Source/CPack/IFW/cmCPackIFWPackage.h b/Source/CPack/IFW/cmCPackIFWPackage.h index bd1d6c5..025a03e 100644 --- a/Source/CPack/IFW/cmCPackIFWPackage.h +++ b/Source/CPack/IFW/cmCPackIFWPackage.h @@ -3,7 +3,7 @@ #ifndef cmCPackIFWPackage_h #define cmCPackIFWPackage_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <set> #include <string> diff --git a/Source/CPack/IFW/cmCPackIFWRepository.cxx b/Source/CPack/IFW/cmCPackIFWRepository.cxx index cc204e8..8ce375e 100644 --- a/Source/CPack/IFW/cmCPackIFWRepository.cxx +++ b/Source/CPack/IFW/cmCPackIFWRepository.cxx @@ -2,14 +2,14 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCPackIFWRepository.h" -#include "CPack/cmCPackGenerator.h" +#include "cmCPackGenerator.h" #include "cmCPackIFWGenerator.h" #include "cmGeneratedFileStream.h" #include "cmSystemTools.h" #include "cmXMLParser.h" #include "cmXMLWriter.h" -#include <cmConfigure.h> +#include "cmConfigure.h" #include <stddef.h> #ifdef cmCPackLogger diff --git a/Source/CPack/IFW/cmCPackIFWRepository.h b/Source/CPack/IFW/cmCPackIFWRepository.h index 36f46da..c09a158 100644 --- a/Source/CPack/IFW/cmCPackIFWRepository.h +++ b/Source/CPack/IFW/cmCPackIFWRepository.h @@ -3,7 +3,7 @@ #ifndef cmCPackIFWRepository_h #define cmCPackIFWRepository_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/CPack/OSXScriptLauncher.cxx b/Source/CPack/OSXScriptLauncher.cxx index b159e64..b48bf12 100644 --- a/Source/CPack/OSXScriptLauncher.cxx +++ b/Source/CPack/OSXScriptLauncher.cxx @@ -1,8 +1,8 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#include <cmsys/FStream.hxx> -#include <cmsys/Process.h> -#include <cmsys/SystemTools.hxx> +#include "cmsys/FStream.hxx" +#include "cmsys/Process.h" +#include "cmsys/SystemTools.hxx" #include <iostream> #include <stddef.h> #include <string> @@ -20,7 +20,6 @@ int main(int argc, char* argv[]) { // if ( cmsys::SystemTools::FileExists( - std::string cwd = cmsys::SystemTools::GetCurrentWorkingDirectory(); cmsys::ofstream ofs("/tmp/output.txt"); CFStringRef fileName; @@ -86,8 +85,6 @@ int main(int argc, char* argv[]) int length; while (cmsysProcess_WaitForData(cp, &data, &length, 0)) { // Translate NULL characters in the output into valid text. - // Visual Studio 7 puts these characters in the output of its - // build process. for (int i = 0; i < length; ++i) { if (data[i] == '\0') { data[i] = ' '; diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 2bccf2e..2df23fd 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -2,14 +2,14 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCPackWIXGenerator.h" -#include <CPack/cmCPackComponentGroup.h> -#include <CPack/cmCPackLog.h> +#include "cmCPackComponentGroup.h" +#include "cmCPackLog.h" +#include "cmCryptoHash.h" +#include "cmGeneratedFileStream.h" +#include "cmInstalledFile.h" +#include "cmSystemTools.h" +#include "cmUuid.h" #include <algorithm> -#include <cmCryptoHash.h> -#include <cmGeneratedFileStream.h> -#include <cmInstalledFile.h> -#include <cmSystemTools.h> -#include <cmUuid.h> #include "cmWIXDirectoriesSourceWriter.h" #include "cmWIXFeaturesSourceWriter.h" @@ -17,10 +17,10 @@ #include "cmWIXRichTextFormatWriter.h" #include "cmWIXSourceWriter.h" -#include <cmsys/Directory.hxx> -#include <cmsys/Encoding.hxx> -#include <cmsys/FStream.hxx> -#include <cmsys/SystemTools.hxx> +#include "cmsys/Directory.hxx" +#include "cmsys/Encoding.hxx" +#include "cmsys/FStream.hxx" +#include "cmsys/SystemTools.hxx" #include <rpc.h> // for GUID generation @@ -437,8 +437,8 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() directoryDefinitions.AddAttribute("Name", "SourceDir"); size_t installRootSize = - directoryDefinitions.BeginInstallationPrefixDirectory( - GetProgramFilesFolderId(), installRoot); + directoryDefinitions.BeginInstallationPrefixDirectory(GetRootFolderId(), + installRoot); std::string fileDefinitionsFilename = this->CPackTopLevel + "/files.wxs"; @@ -570,16 +570,26 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() return this->Patch->CheckForUnappliedFragments(); } -std::string cmCPackWIXGenerator::GetProgramFilesFolderId() const +std::string cmCPackWIXGenerator::GetRootFolderId() const { if (cmSystemTools::IsOn(GetOption("CPACK_WIX_SKIP_PROGRAM_FOLDER"))) { return ""; } + + std::string result = "ProgramFiles<64>Folder"; + + const char* rootFolderId = GetOption("CPACK_WIX_ROOT_FOLDER_ID"); + if (rootFolderId) { + result = rootFolderId; + } + if (GetArchitecture() == "x86") { - return "ProgramFilesFolder"; + cmSystemTools::ReplaceString(result, "<64>", ""); } else { - return "ProgramFiles64Folder"; + cmSystemTools::ReplaceString(result, "<64>", "64"); } + + return result; } bool cmCPackWIXGenerator::GenerateMainSourceFileFromTemplate() diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.h b/Source/CPack/WiX/cmCPackWIXGenerator.h index fc0994c..353d6c0 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.h +++ b/Source/CPack/WiX/cmCPackWIXGenerator.h @@ -3,7 +3,7 @@ #ifndef cmCPackWIXGenerator_h #define cmCPackWIXGenerator_h -#include <CPack/cmCPackGenerator.h> +#include "cmCPackGenerator.h" #include "cmWIXPatch.h" #include "cmWIXShortcut.h" @@ -65,7 +65,7 @@ private: bool CreateWiXSourceFiles(); - std::string GetProgramFilesFolderId() const; + std::string GetRootFolderId() const; bool GenerateMainSourceFileFromTemplate(); diff --git a/Source/CPack/WiX/cmWIXAccessControlList.cxx b/Source/CPack/WiX/cmWIXAccessControlList.cxx index 9f9b39c..744a932 100644 --- a/Source/CPack/WiX/cmWIXAccessControlList.cxx +++ b/Source/CPack/WiX/cmWIXAccessControlList.cxx @@ -2,9 +2,9 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmWIXAccessControlList.h" -#include <CPack/cmCPackGenerator.h> +#include "cmCPackGenerator.h" -#include <cmSystemTools.h> +#include "cmSystemTools.h" cmWIXAccessControlList::cmWIXAccessControlList( cmCPackLog* logger, cmInstalledFile const& installedFile, diff --git a/Source/CPack/WiX/cmWIXAccessControlList.h b/Source/CPack/WiX/cmWIXAccessControlList.h index 0a25ee5..2a23f2f 100644 --- a/Source/CPack/WiX/cmWIXAccessControlList.h +++ b/Source/CPack/WiX/cmWIXAccessControlList.h @@ -5,8 +5,8 @@ #include "cmWIXSourceWriter.h" -#include <CPack/cmCPackLog.h> -#include <cmInstalledFile.h> +#include "cmCPackLog.h" +#include "cmInstalledFile.h" class cmWIXAccessControlList { diff --git a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h index 062efe3..8233331 100644 --- a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h +++ b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h @@ -5,7 +5,7 @@ #include "cmWIXSourceWriter.h" -#include <CPack/cmCPackGenerator.h> +#include "cmCPackGenerator.h" #include <string> diff --git a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.h b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.h index 368b250..e751ca7 100644 --- a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.h +++ b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.h @@ -6,7 +6,7 @@ #include "cmWIXPatch.h" #include "cmWIXSourceWriter.h" -#include <CPack/cmCPackGenerator.h> +#include "cmCPackGenerator.h" /** \class cmWIXFeaturesSourceWriter * \brief Helper class to generate features.wxs diff --git a/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx index a471d26..7aa1212 100644 --- a/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx +++ b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx @@ -4,14 +4,12 @@ #include "cmWIXAccessControlList.h" -#include <cmInstalledFile.h> +#include "cmInstalledFile.h" -#include <cmSystemTools.h> -#include <cmUuid.h> +#include "cmSystemTools.h" +#include "cmUuid.h" -#include <sys/types.h> -// include sys/stat.h after sys/types.h -#include <sys/stat.h> +#include "cm_sys_stat.h" cmWIXFilesSourceWriter::cmWIXFilesSourceWriter(cmCPackLog* logger, std::string const& filename, diff --git a/Source/CPack/WiX/cmWIXFilesSourceWriter.h b/Source/CPack/WiX/cmWIXFilesSourceWriter.h index d7a642d..dc9c636 100644 --- a/Source/CPack/WiX/cmWIXFilesSourceWriter.h +++ b/Source/CPack/WiX/cmWIXFilesSourceWriter.h @@ -8,7 +8,7 @@ #include "cmWIXPatch.h" #include "cmWIXShortcut.h" -#include <CPack/cmCPackGenerator.h> +#include "cmCPackGenerator.h" /** \class cmWIXFilesSourceWriter * \brief Helper class to generate files.wxs diff --git a/Source/CPack/WiX/cmWIXPatch.cxx b/Source/CPack/WiX/cmWIXPatch.cxx index 7c48653..3a7dbfd 100644 --- a/Source/CPack/WiX/cmWIXPatch.cxx +++ b/Source/CPack/WiX/cmWIXPatch.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmWIXPatch.h" -#include <CPack/cmCPackGenerator.h> +#include "cmCPackGenerator.h" cmWIXPatch::cmWIXPatch(cmCPackLog* logger) : Logger(logger) diff --git a/Source/CPack/WiX/cmWIXPatchParser.cxx b/Source/CPack/WiX/cmWIXPatchParser.cxx index 47f98d1..7f2ae19 100644 --- a/Source/CPack/WiX/cmWIXPatchParser.cxx +++ b/Source/CPack/WiX/cmWIXPatchParser.cxx @@ -2,9 +2,9 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmWIXPatchParser.h" -#include <CPack/cmCPackGenerator.h> +#include "cmCPackGenerator.h" -#include <cm_expat.h> +#include "cm_expat.h" cmWIXPatchNode::Type cmWIXPatchText::type() { diff --git a/Source/CPack/WiX/cmWIXPatchParser.h b/Source/CPack/WiX/cmWIXPatchParser.h index a2f0a3c..c0c96cd 100644 --- a/Source/CPack/WiX/cmWIXPatchParser.h +++ b/Source/CPack/WiX/cmWIXPatchParser.h @@ -3,9 +3,9 @@ #ifndef cmCPackWIXPatchParser_h #define cmCPackWIXPatchParser_h -#include <CPack/cmCPackLog.h> +#include "cmCPackLog.h" -#include <cmXMLParser.h> +#include "cmXMLParser.h" #include <list> #include <map> diff --git a/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx b/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx index d819347..2c99a22 100644 --- a/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx +++ b/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmWIXRichTextFormatWriter.h" -#include <cmVersion.h> +#include "cmVersion.h" cmWIXRichTextFormatWriter::cmWIXRichTextFormatWriter( std::string const& filename) diff --git a/Source/CPack/WiX/cmWIXRichTextFormatWriter.h b/Source/CPack/WiX/cmWIXRichTextFormatWriter.h index a3c8394..30df878 100644 --- a/Source/CPack/WiX/cmWIXRichTextFormatWriter.h +++ b/Source/CPack/WiX/cmWIXRichTextFormatWriter.h @@ -3,9 +3,9 @@ #ifndef cmWIXRichTextFormatWriter_h #define cmWIXRichTextFormatWriter_h -#include <cmConfigure.h> +#include "cmConfigure.h" -#include <cmsys/FStream.hxx> +#include "cmsys/FStream.hxx" #include <string> /** \class cmWIXRichtTextFormatWriter diff --git a/Source/CPack/WiX/cmWIXShortcut.h b/Source/CPack/WiX/cmWIXShortcut.h index cba3b34..23ddc6a 100644 --- a/Source/CPack/WiX/cmWIXShortcut.h +++ b/Source/CPack/WiX/cmWIXShortcut.h @@ -3,7 +3,7 @@ #ifndef cmWIXShortcut_h #define cmWIXShortcut_h -#include <cmInstalledFile.h> +#include "cmInstalledFile.h" #include <map> #include <set> diff --git a/Source/CPack/WiX/cmWIXSourceWriter.cxx b/Source/CPack/WiX/cmWIXSourceWriter.cxx index b434334..a86e28d 100644 --- a/Source/CPack/WiX/cmWIXSourceWriter.cxx +++ b/Source/CPack/WiX/cmWIXSourceWriter.cxx @@ -2,9 +2,9 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmWIXSourceWriter.h" -#include <CPack/cmCPackGenerator.h> +#include "cmCPackGenerator.h" -#include <cmUuid.h> +#include "cmUuid.h" #include <windows.h> diff --git a/Source/CPack/WiX/cmWIXSourceWriter.h b/Source/CPack/WiX/cmWIXSourceWriter.h index 45aefe5..4af1ed6 100644 --- a/Source/CPack/WiX/cmWIXSourceWriter.h +++ b/Source/CPack/WiX/cmWIXSourceWriter.h @@ -3,9 +3,9 @@ #ifndef cmWIXSourceWriter_h #define cmWIXSourceWriter_h -#include <CPack/cmCPackLog.h> +#include "cmCPackLog.h" -#include <cmsys/FStream.hxx> +#include "cmsys/FStream.hxx" #include <string> #include <vector> diff --git a/Source/CPack/cmCPack7zGenerator.h b/Source/CPack/cmCPack7zGenerator.h index a617d9b..42a4781 100644 --- a/Source/CPack/cmCPack7zGenerator.h +++ b/Source/CPack/cmCPack7zGenerator.h @@ -3,7 +3,7 @@ #ifndef cmCPack7zGenerator_h #define cmCPack7zGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCPackArchiveGenerator.h" #include "cmCPackGenerator.h" diff --git a/Source/CPack/cmCPackArchiveGenerator.cxx b/Source/CPack/cmCPackArchiveGenerator.cxx index 9d9cd66..cc01b0c 100644 --- a/Source/CPack/cmCPackArchiveGenerator.cxx +++ b/Source/CPack/cmCPackArchiveGenerator.cxx @@ -7,6 +7,7 @@ #include "cmCPackLog.h" #include "cmGeneratedFileStream.h" #include "cmSystemTools.h" +#include "cmWorkingDirectory.h" #include <map> #include <ostream> @@ -37,9 +38,8 @@ int cmCPackArchiveGenerator::addOneComponentToArchive( // Add the files of this component to the archive std::string localToplevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY")); localToplevel += "/" + component->Name; - std::string dir = cmSystemTools::GetCurrentWorkingDirectory(); // Change to local toplevel - cmSystemTools::ChangeDirectory(localToplevel); + cmWorkingDirectory workdir(localToplevel); std::string filePrefix; if (this->IsOn("CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY")) { filePrefix = this->GetOption("CPACK_PACKAGE_FILE_NAME"); @@ -64,8 +64,6 @@ int cmCPackArchiveGenerator::addOneComponentToArchive( return 0; } } - // Go back to previous dir - cmSystemTools::ChangeDirectory(dir); return 1; } @@ -227,8 +225,7 @@ int cmCPackArchiveGenerator::PackageFiles() // CASE 3 : NON COMPONENT package. DECLARE_AND_OPEN_ARCHIVE(packageFileNames[0], archive); std::vector<std::string>::const_iterator fileIt; - std::string dir = cmSystemTools::GetCurrentWorkingDirectory(); - cmSystemTools::ChangeDirectory(toplevel); + cmWorkingDirectory workdir(toplevel); for (fileIt = files.begin(); fileIt != files.end(); ++fileIt) { // Get the relative path to the file std::string rp = @@ -241,7 +238,6 @@ int cmCPackArchiveGenerator::PackageFiles() return 0; } } - cmSystemTools::ChangeDirectory(dir); // The destructor of cmArchiveWrite will close and finish the write return 1; } diff --git a/Source/CPack/cmCPackArchiveGenerator.h b/Source/CPack/cmCPackArchiveGenerator.h index df02ae8..58d67e3 100644 --- a/Source/CPack/cmCPackArchiveGenerator.h +++ b/Source/CPack/cmCPackArchiveGenerator.h @@ -3,7 +3,7 @@ #ifndef cmCPackArchiveGenerator_h #define cmCPackArchiveGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmArchiveWrite.h" #include "cmCPackGenerator.h" diff --git a/Source/CPack/cmCPackBundleGenerator.h b/Source/CPack/cmCPackBundleGenerator.h index c9200c1..861fe4b 100644 --- a/Source/CPack/cmCPackBundleGenerator.h +++ b/Source/CPack/cmCPackBundleGenerator.h @@ -3,7 +3,8 @@ #ifndef cmCPackBundleGenerator_h #define cmCPackBundleGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include "cmCPackDragNDropGenerator.h" diff --git a/Source/CPack/cmCPackComponentGroup.h b/Source/CPack/cmCPackComponentGroup.h index f955daf..26d69ba 100644 --- a/Source/CPack/cmCPackComponentGroup.h +++ b/Source/CPack/cmCPackComponentGroup.h @@ -3,7 +3,7 @@ #ifndef cmCPackComponentGroup_h #define cmCPackComponentGroup_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <string> #include <vector> @@ -78,6 +78,10 @@ public: /// contains the files that are part of this component. std::string ArchiveFile; + /// The file to pass to --component-plist when using the + /// productbuild generator. + std::string Plist; + /// The components that this component depends on. std::vector<cmCPackComponent*> Dependencies; diff --git a/Source/CPack/cmCPackCygwinBinaryGenerator.cxx b/Source/CPack/cmCPackCygwinBinaryGenerator.cxx index e67811d..2119f78 100644 --- a/Source/CPack/cmCPackCygwinBinaryGenerator.cxx +++ b/Source/CPack/cmCPackCygwinBinaryGenerator.cxx @@ -9,7 +9,7 @@ #include "cmSystemTools.h" #include "cmake.h" -#include <cmsys/SystemTools.hxx> +#include "cmsys/SystemTools.hxx" cmCPackCygwinBinaryGenerator::cmCPackCygwinBinaryGenerator() { diff --git a/Source/CPack/cmCPackCygwinSourceGenerator.cxx b/Source/CPack/cmCPackCygwinSourceGenerator.cxx index 92475d9..2c289f6 100644 --- a/Source/CPack/cmCPackCygwinSourceGenerator.cxx +++ b/Source/CPack/cmCPackCygwinSourceGenerator.cxx @@ -9,13 +9,13 @@ #include "cmSystemTools.h" #include "cmake.h" -#include <cmsys/SystemTools.hxx> +#include "cmsys/SystemTools.hxx" // Includes needed for implementation of RenameFile. This is not in // system tools because it is not implemented robustly enough to move // files across directories. #ifdef _WIN32 -#include <sys/stat.h> +#include "cm_sys_stat.h" #include <windows.h> #endif diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 5c50da8..af54fce 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -8,15 +8,15 @@ #include "cmCPackLog.h" #include "cmGeneratedFileStream.h" #include "cmSystemTools.h" +#include "cm_sys_stat.h" -#include <cmsys/Glob.hxx> +#include "cmsys/Glob.hxx" #include <limits.h> #include <map> #include <ostream> #include <set> #include <stdio.h> #include <string.h> -#include <sys/stat.h> #include <utility> // NOTE: diff --git a/Source/CPack/cmCPackDebGenerator.h b/Source/CPack/cmCPackDebGenerator.h index 7db933e..e7cde11 100644 --- a/Source/CPack/cmCPackDebGenerator.h +++ b/Source/CPack/cmCPackDebGenerator.h @@ -3,7 +3,7 @@ #ifndef cmCPackDebGenerator_h #define cmCPackDebGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCPackGenerator.h" diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx index fd67df9..9864cf3 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.cxx +++ b/Source/CPack/cmCPackDragNDropGenerator.cxx @@ -7,8 +7,8 @@ #include "cmGeneratedFileStream.h" #include "cmSystemTools.h" -#include <cmsys/FStream.hxx> -#include <cmsys/RegularExpression.hxx> +#include "cmsys/FStream.hxx" +#include "cmsys/RegularExpression.hxx" #include <iomanip> #include <map> #include <stdlib.h> @@ -390,6 +390,8 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, bool remount_image = !cpack_package_icon.empty() || !cpack_dmg_ds_store_setup_script.empty(); + std::string temp_image_format = "UDZO"; + // Create 1 MB dummy padding file in staging area when we need to remount // image, so we have enough space for storing changes ... if (remount_image) { @@ -401,6 +403,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, return 0; } + temp_image_format = "UDRW"; } // Create a temporary read-write disk image ... @@ -413,7 +416,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, temp_image_command << " -ov"; temp_image_command << " -srcfolder \"" << staging.str() << "\""; temp_image_command << " -volname \"" << cpack_dmg_volume_name << "\""; - temp_image_command << " -format UDRW"; + temp_image_command << " -format " << temp_image_format; temp_image_command << " \"" << temp_image << "\""; if (!this->RunCommand(temp_image_command)) { @@ -632,29 +635,33 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, return 0; } - // convert to UDCO - std::string temp_udco = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); - temp_udco += "/temp-udco.dmg"; + if (temp_image_format != "UDZO") { + temp_image_format = "UDZO"; + // convert to UDZO to enable unflatten/flatten + std::string temp_udzo = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); + temp_udzo += "/temp-udzo.dmg"; - std::ostringstream udco_image_command; - udco_image_command << this->GetOption("CPACK_COMMAND_HDIUTIL"); - udco_image_command << " convert \"" << temp_image << "\""; - udco_image_command << " -format UDCO"; - udco_image_command << " -ov -o \"" << temp_udco << "\""; + std::ostringstream udco_image_command; + udco_image_command << this->GetOption("CPACK_COMMAND_HDIUTIL"); + udco_image_command << " convert \"" << temp_image << "\""; + udco_image_command << " -format UDZO"; + udco_image_command << " -ov -o \"" << temp_udzo << "\""; - if (!this->RunCommand(udco_image_command, &error)) { - cmCPackLogger(cmCPackLog::LOG_ERROR, - "Error converting to UDCO dmg for adding SLA." - << std::endl - << error << std::endl); - return 0; + if (!this->RunCommand(udco_image_command, &error)) { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error converting to UDCO dmg for adding SLA." + << std::endl + << error << std::endl); + return 0; + } + temp_image = temp_udzo; } // unflatten dmg std::ostringstream unflatten_command; unflatten_command << this->GetOption("CPACK_COMMAND_HDIUTIL"); unflatten_command << " unflatten "; - unflatten_command << "\"" << temp_udco << "\""; + unflatten_command << "\"" << temp_image << "\""; if (!this->RunCommand(unflatten_command, &error)) { cmCPackLogger(cmCPackLog::LOG_ERROR, @@ -673,7 +680,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, } embed_sla_command << " \"" << sla_r << "\""; embed_sla_command << " -a -o "; - embed_sla_command << "\"" << temp_udco << "\""; + embed_sla_command << "\"" << temp_image << "\""; if (!this->RunCommand(embed_sla_command, &error)) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Error adding SLA." << std::endl @@ -686,7 +693,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, std::ostringstream flatten_command; flatten_command << this->GetOption("CPACK_COMMAND_HDIUTIL"); flatten_command << " flatten "; - flatten_command << "\"" << temp_udco << "\""; + flatten_command << "\"" << temp_image << "\""; if (!this->RunCommand(flatten_command, &error)) { cmCPackLogger(cmCPackLog::LOG_ERROR, @@ -695,8 +702,6 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, << std::endl); return 0; } - - temp_image = temp_udco; } // Create the final compressed read-only disk image ... diff --git a/Source/CPack/cmCPackDragNDropGenerator.h b/Source/CPack/cmCPackDragNDropGenerator.h index 876eab7..ae2cc17 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.h +++ b/Source/CPack/cmCPackDragNDropGenerator.h @@ -3,7 +3,8 @@ #ifndef cmCPackDragNDropGenerator_h #define cmCPackDragNDropGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <sstream> #include <stddef.h> #include <string> diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 21eda79..a95ca76 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -2,10 +2,10 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCPackGenerator.h" +#include "cmsys/FStream.hxx" +#include "cmsys/Glob.hxx" +#include "cmsys/RegularExpression.hxx" #include <algorithm> -#include <cmsys/FStream.hxx> -#include <cmsys/Glob.hxx> -#include <cmsys/RegularExpression.hxx> #include <list> #include <utility> @@ -16,6 +16,7 @@ #include "cmGlobalGenerator.h" #include "cmMakefile.h" #include "cmStateSnapshot.h" +#include "cmWorkingDirectory.h" #include "cmXMLSafe.h" #include "cm_auto_ptr.hxx" #include "cmake.h" @@ -383,7 +384,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( goToDir += "/" + subdir; cmCPackLogger(cmCPackLog::LOG_DEBUG, "Change dir to: " << goToDir << std::endl); - cmSystemTools::ChangeDirectory(goToDir); + cmWorkingDirectory workdir(goToDir); for (symlinkedIt = symlinkedFiles.begin(); symlinkedIt != symlinkedFiles.end(); ++symlinkedIt) { cmCPackLogger(cmCPackLog::LOG_DEBUG, "Will create a symlink: " @@ -408,7 +409,6 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( } cmCPackLogger(cmCPackLog::LOG_DEBUG, "Going back to: " << curDir << std::endl); - cmSystemTools::ChangeDirectory(curDir); } } } @@ -1396,6 +1396,11 @@ cmCPackComponent* cmCPackGenerator::GetComponent( component->ArchiveFile = archiveFile; } + const char* plist = this->GetOption(macroPrefix + "_PLIST"); + if (plist && *plist) { + component->Plist = plist; + } + const char* groupName = this->GetOption(macroPrefix + "_GROUP"); if (groupName && *groupName) { component->Group = GetComponentGroup(projectName, groupName); diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h index 5354fca..45777fa 100644 --- a/Source/CPack/cmCPackGenerator.h +++ b/Source/CPack/cmCPackGenerator.h @@ -3,7 +3,7 @@ #ifndef cmCPackGenerator_h #define cmCPackGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <map> #include <sstream> @@ -13,25 +13,10 @@ #include "cmCPackComponentGroup.h" #include "cmSystemTools.h" -class cmCPackGenerator; class cmCPackLog; class cmInstalledFile; class cmMakefile; -#define cmCPackTypeMacro(klass, superclass) \ - typedef superclass Superclass; \ - const char* GetNameOfClass() CM_OVERRIDE { return #klass; } \ - static cmCPackGenerator* CreateGenerator() { return new klass; } \ - class cmCPackTypeMacro_UseTrailingSemicolon - -#define cmCPackLogger(logType, msg) \ - do { \ - std::ostringstream cmCPackLog_msg; \ - cmCPackLog_msg << msg; \ - this->Logger->Log(logType, __FILE__, __LINE__, \ - cmCPackLog_msg.str().c_str()); \ - } while (false) - /** \class cmCPackGenerator * \brief A superclass of all CPack Generators * @@ -312,4 +297,18 @@ private: cmMakefile* MakefileMap; }; +#define cmCPackTypeMacro(klass, superclass) \ + typedef superclass Superclass; \ + const char* GetNameOfClass() CM_OVERRIDE { return #klass; } \ + static cmCPackGenerator* CreateGenerator() { return new klass; } \ + class cmCPackTypeMacro_UseTrailingSemicolon + +#define cmCPackLogger(logType, msg) \ + do { \ + std::ostringstream cmCPackLog_msg; \ + cmCPackLog_msg << msg; \ + this->Logger->Log(logType, __FILE__, __LINE__, \ + cmCPackLog_msg.str().c_str()); \ + } while (false) + #endif diff --git a/Source/CPack/cmCPackGeneratorFactory.cxx b/Source/CPack/cmCPackGeneratorFactory.cxx index b012f01..31f48c7 100644 --- a/Source/CPack/cmCPackGeneratorFactory.cxx +++ b/Source/CPack/cmCPackGeneratorFactory.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCPackGeneratorFactory.h" -#include <cmConfigure.h> +#include "cmConfigure.h" #include <ostream> #include <utility> diff --git a/Source/CPack/cmCPackGeneratorFactory.h b/Source/CPack/cmCPackGeneratorFactory.h index 4ee0bc1..7f633e4 100644 --- a/Source/CPack/cmCPackGeneratorFactory.h +++ b/Source/CPack/cmCPackGeneratorFactory.h @@ -3,7 +3,7 @@ #ifndef cmCPackGeneratorFactory_h #define cmCPackGeneratorFactory_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <map> #include <string> diff --git a/Source/CPack/cmCPackLog.cxx b/Source/CPack/cmCPackLog.cxx index 7d5c192..5c71239 100644 --- a/Source/CPack/cmCPackLog.cxx +++ b/Source/CPack/cmCPackLog.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCPackLog.h" -#include <cmConfigure.h> +#include "cmConfigure.h" #include <iostream> #include "cmGeneratedFileStream.h" diff --git a/Source/CPack/cmCPackLog.h b/Source/CPack/cmCPackLog.h index a988ccc..96c5882 100644 --- a/Source/CPack/cmCPackLog.h +++ b/Source/CPack/cmCPackLog.h @@ -3,7 +3,7 @@ #ifndef cmCPackLog_h #define cmCPackLog_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <ostream> #include <string.h> diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index 1940953..beb2d01 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -8,9 +8,9 @@ #include "cmGeneratedFileStream.h" #include "cmSystemTools.h" +#include "cmsys/Directory.hxx" +#include "cmsys/RegularExpression.hxx" #include <algorithm> -#include <cmsys/Directory.hxx> -#include <cmsys/RegularExpression.hxx> #include <map> #include <sstream> #include <stdlib.h> diff --git a/Source/CPack/cmCPackNSISGenerator.h b/Source/CPack/cmCPackNSISGenerator.h index b4bf2d4..77be325 100644 --- a/Source/CPack/cmCPackNSISGenerator.h +++ b/Source/CPack/cmCPackNSISGenerator.h @@ -3,7 +3,7 @@ #ifndef cmCPackNSISGenerator_h #define cmCPackNSISGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCPackGenerator.h" diff --git a/Source/CPack/cmCPackOSXX11Generator.cxx b/Source/CPack/cmCPackOSXX11Generator.cxx index 0d8dc48..8ea88a8 100644 --- a/Source/CPack/cmCPackOSXX11Generator.cxx +++ b/Source/CPack/cmCPackOSXX11Generator.cxx @@ -3,12 +3,12 @@ #include "cmCPackOSXX11Generator.h" #include <sstream> -#include <sys/stat.h> #include "cmCPackGenerator.h" #include "cmCPackLog.h" #include "cmGeneratedFileStream.h" #include "cmSystemTools.h" +#include "cm_sys_stat.h" cmCPackOSXX11Generator::cmCPackOSXX11Generator() { diff --git a/Source/CPack/cmCPackOSXX11Generator.h b/Source/CPack/cmCPackOSXX11Generator.h index 1918e21..0eebc6d 100644 --- a/Source/CPack/cmCPackOSXX11Generator.h +++ b/Source/CPack/cmCPackOSXX11Generator.h @@ -3,7 +3,8 @@ #ifndef cmCPackOSXX11Generator_h #define cmCPackOSXX11Generator_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include "cmCPackGenerator.h" diff --git a/Source/CPack/cmCPackPKGGenerator.h b/Source/CPack/cmCPackPKGGenerator.h index 1e96a62..f873c59 100644 --- a/Source/CPack/cmCPackPKGGenerator.h +++ b/Source/CPack/cmCPackPKGGenerator.h @@ -3,7 +3,8 @@ #ifndef cmCPackPKGGenerator_h #define cmCPackPKGGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <set> #include <sstream> #include <string> diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx index 8000d6e..8db7cfb 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.cxx +++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx @@ -2,9 +2,9 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCPackPackageMakerGenerator.h" +#include "cmsys/FStream.hxx" +#include "cmsys/RegularExpression.hxx" #include <assert.h> -#include <cmsys/FStream.hxx> -#include <cmsys/RegularExpression.hxx> #include <map> #include <sstream> #include <stdio.h> diff --git a/Source/CPack/cmCPackPackageMakerGenerator.h b/Source/CPack/cmCPackPackageMakerGenerator.h index d4c6744..6274515 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.h +++ b/Source/CPack/cmCPackPackageMakerGenerator.h @@ -3,7 +3,7 @@ #ifndef cmCPackPackageMakerGenerator_h #define cmCPackPackageMakerGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCPackGenerator.h" #include "cmCPackPKGGenerator.h" diff --git a/Source/CPack/cmCPackProductBuildGenerator.cxx b/Source/CPack/cmCPackProductBuildGenerator.cxx index a5a18dc..1389eaa 100644 --- a/Source/CPack/cmCPackProductBuildGenerator.cxx +++ b/Source/CPack/cmCPackProductBuildGenerator.cxx @@ -59,12 +59,25 @@ int cmCPackProductBuildGenerator::PackageFiles() } } - // Copy or create all of the resource files we need. std::string resDir = packageDirFileName + "/Contents"; + + if (this->IsSet("CPACK_PRODUCTBUILD_RESOURCES_DIR")) { + std::string userResDir = + this->GetOption("CPACK_PRODUCTBUILD_RESOURCES_DIR"); + + if (!cmSystemTools::CopyADirectory(userResDir, resDir)) { + cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the resource files" + << std::endl); + return 0; + } + } + + // Copy or create all of the resource files we need. if (!this->CopyCreateResourceFile("License", resDir) || !this->CopyCreateResourceFile("ReadMe", resDir) || !this->CopyCreateResourceFile("Welcome", resDir)) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the resource files" + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Problem copying the License, ReadMe and Welcome files" << std::endl); return 0; } @@ -223,6 +236,10 @@ bool cmCPackProductBuildGenerator::GenerateComponentPackage( : " --keychain \"" + keychainPath + "\"") << " \"" << packageFile << "\""; + if (component && !component->Plist.empty()) { + pkgCmd << " --component-plist \"" << component->Plist << "\""; + } + // Run ProductBuild return RunProductBuild(pkgCmd.str()); } diff --git a/Source/CPack/cmCPackProductBuildGenerator.h b/Source/CPack/cmCPackProductBuildGenerator.h index b6da470..12093a0 100644 --- a/Source/CPack/cmCPackProductBuildGenerator.h +++ b/Source/CPack/cmCPackProductBuildGenerator.h @@ -3,7 +3,8 @@ #ifndef cmCPackProductBuildGenerator_h #define cmCPackProductBuildGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include "cmCPackGenerator.h" diff --git a/Source/CPack/cmCPackRPMGenerator.h b/Source/CPack/cmCPackRPMGenerator.h index 4d48bd8..52cfc13 100644 --- a/Source/CPack/cmCPackRPMGenerator.h +++ b/Source/CPack/cmCPackRPMGenerator.h @@ -3,7 +3,7 @@ #ifndef cmCPackRPMGenerator_h #define cmCPackRPMGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCPackGenerator.h" diff --git a/Source/CPack/cmCPackSTGZGenerator.cxx b/Source/CPack/cmCPackSTGZGenerator.cxx index 682394e..c541614 100644 --- a/Source/CPack/cmCPackSTGZGenerator.cxx +++ b/Source/CPack/cmCPackSTGZGenerator.cxx @@ -2,19 +2,16 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCPackSTGZGenerator.h" -#include <cmsys/FStream.hxx> +#include "cmsys/FStream.hxx" #include <sstream> #include <stdio.h> #include <string> #include <vector> -#include <sys/types.h> -// include sys/stat.h after sys/types.h -#include <sys/stat.h> - #include "cmCPackGenerator.h" #include "cmCPackLog.h" #include "cmSystemTools.h" +#include "cm_sys_stat.h" cmCPackSTGZGenerator::cmCPackSTGZGenerator() { diff --git a/Source/CPack/cmCPackSTGZGenerator.h b/Source/CPack/cmCPackSTGZGenerator.h index 4b9c1c6..8304e80 100644 --- a/Source/CPack/cmCPackSTGZGenerator.h +++ b/Source/CPack/cmCPackSTGZGenerator.h @@ -3,7 +3,7 @@ #ifndef cmCPackSTGZGenerator_h #define cmCPackSTGZGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCPackGenerator.h" #include "cmCPackTGZGenerator.h" diff --git a/Source/CPack/cmCPackTGZGenerator.h b/Source/CPack/cmCPackTGZGenerator.h index ee2e975..9426b3a 100644 --- a/Source/CPack/cmCPackTGZGenerator.h +++ b/Source/CPack/cmCPackTGZGenerator.h @@ -3,7 +3,7 @@ #ifndef cmCPackTGZGenerator_h #define cmCPackTGZGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCPackArchiveGenerator.h" #include "cmCPackGenerator.h" diff --git a/Source/CPack/cmCPackTXZGenerator.h b/Source/CPack/cmCPackTXZGenerator.h index 876ca7d..3b96e2d 100644 --- a/Source/CPack/cmCPackTXZGenerator.h +++ b/Source/CPack/cmCPackTXZGenerator.h @@ -3,7 +3,7 @@ #ifndef cmCPackTXZGenerator_h #define cmCPackTXZGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCPackArchiveGenerator.h" #include "cmCPackGenerator.h" diff --git a/Source/CPack/cmCPackTarBZip2Generator.h b/Source/CPack/cmCPackTarBZip2Generator.h index 42214fd..9b4b8f4 100644 --- a/Source/CPack/cmCPackTarBZip2Generator.h +++ b/Source/CPack/cmCPackTarBZip2Generator.h @@ -3,7 +3,7 @@ #ifndef cmCPackTarBZip2Generator_h #define cmCPackTarBZip2Generator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCPackArchiveGenerator.h" #include "cmCPackGenerator.h" diff --git a/Source/CPack/cmCPackTarCompressGenerator.h b/Source/CPack/cmCPackTarCompressGenerator.h index 1476642..381d6eb 100644 --- a/Source/CPack/cmCPackTarCompressGenerator.h +++ b/Source/CPack/cmCPackTarCompressGenerator.h @@ -3,7 +3,7 @@ #ifndef cmCPackTarCompressGenerator_h #define cmCPackTarCompressGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCPackArchiveGenerator.h" #include "cmCPackGenerator.h" diff --git a/Source/CPack/cmCPackZIPGenerator.h b/Source/CPack/cmCPackZIPGenerator.h index 95b6489..00c8720 100644 --- a/Source/CPack/cmCPackZIPGenerator.h +++ b/Source/CPack/cmCPackZIPGenerator.h @@ -3,7 +3,7 @@ #ifndef cmCPackZIPGenerator_h #define cmCPackZIPGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCPackArchiveGenerator.h" #include "cmCPackGenerator.h" diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index af80cbf..a48c8cd 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -1,9 +1,9 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#include <cmConfigure.h> +#include "cmConfigure.h" -#include <cmsys/CommandLineArguments.hxx> -#include <cmsys/Encoding.hxx> +#include "cmsys/CommandLineArguments.hxx" +#include "cmsys/Encoding.hxx" #include <iostream> #include <map> #include <sstream> @@ -13,7 +13,7 @@ #include <vector> #if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE) -#include <cmsys/ConsoleBuf.hxx> +#include "cmsys/ConsoleBuf.hxx" #endif #include "cmCPackGenerator.h" diff --git a/Source/CTest/cmCTestBZR.cxx b/Source/CTest/cmCTestBZR.cxx index b42953b..94f39c2 100644 --- a/Source/CTest/cmCTestBZR.cxx +++ b/Source/CTest/cmCTestBZR.cxx @@ -8,8 +8,8 @@ #include "cmSystemTools.h" #include "cmXMLParser.h" -#include <cm_expat.h> -#include <cmsys/RegularExpression.hxx> +#include "cm_expat.h" +#include "cmsys/RegularExpression.hxx" #include <list> #include <map> #include <ostream> @@ -151,22 +151,24 @@ std::string cmCTestBZR::LoadInfo() return rev; } -void cmCTestBZR::NoteOldRevision() +bool cmCTestBZR::NoteOldRevision() { this->OldRevision = this->LoadInfo(); this->Log << "Revision before update: " << this->OldRevision << "\n"; cmCTestLog(this->CTest, HANDLER_OUTPUT, " Old revision of repository is: " << this->OldRevision << "\n"); this->PriorRev.Rev = this->OldRevision; + return true; } -void cmCTestBZR::NoteNewRevision() +bool cmCTestBZR::NoteNewRevision() { this->NewRevision = this->LoadInfo(); this->Log << "Revision after update: " << this->NewRevision << "\n"; cmCTestLog(this->CTest, HANDLER_OUTPUT, " New revision of repository is: " << this->NewRevision << "\n"); this->Log << "URL = " << this->URL << "\n"; + return true; } class cmCTestBZR::LogParser : public cmCTestVC::OutputLogger, @@ -386,7 +388,7 @@ bool cmCTestBZR::UpdateImpl() return this->RunUpdateCommand(&bzr_update[0], &out, &err); } -void cmCTestBZR::LoadRevisions() +bool cmCTestBZR::LoadRevisions() { cmCTestLog(this->CTest, HANDLER_OUTPUT, " Gathering version information (one . per revision):\n" @@ -400,7 +402,7 @@ void cmCTestBZR::LoadRevisions() // DoRevision takes care of discarding the information about OldRevision revs = this->OldRevision + ".." + this->NewRevision; } else { - return; + return true; } // Run "bzr log" to get all global revisions of interest. @@ -415,6 +417,7 @@ void cmCTestBZR::LoadRevisions() this->RunChild(bzr_log, &out, &err); } cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl); + return true; } class cmCTestBZR::StatusParser : public cmCTestVC::LineParser @@ -460,7 +463,7 @@ private: } }; -void cmCTestBZR::LoadModifications() +bool cmCTestBZR::LoadModifications() { // Run "bzr status" which reports local modifications. const char* bzr = this->CommandLineTool.c_str(); @@ -468,4 +471,5 @@ void cmCTestBZR::LoadModifications() StatusParser out(this, "status-out> "); OutputLogger err(this->Log, "status-err> "); this->RunChild(bzr_status, &out, &err); + return true; } diff --git a/Source/CTest/cmCTestBZR.h b/Source/CTest/cmCTestBZR.h index e7af90b..2e8e88f 100644 --- a/Source/CTest/cmCTestBZR.h +++ b/Source/CTest/cmCTestBZR.h @@ -3,7 +3,7 @@ #ifndef cmCTestBZR_h #define cmCTestBZR_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCTestGlobalVC.h" @@ -26,16 +26,16 @@ public: private: // Implement cmCTestVC internal API. - void NoteOldRevision() CM_OVERRIDE; - void NoteNewRevision() CM_OVERRIDE; + bool NoteOldRevision() CM_OVERRIDE; + bool NoteNewRevision() CM_OVERRIDE; bool UpdateImpl() CM_OVERRIDE; // URL of repository directory checked out in the working tree. std::string URL; std::string LoadInfo(); - void LoadModifications() CM_OVERRIDE; - void LoadRevisions() CM_OVERRIDE; + bool LoadModifications() CM_OVERRIDE; + bool LoadRevisions() CM_OVERRIDE; // Parsing helper classes. class InfoParser; diff --git a/Source/CTest/cmCTestBatchTestHandler.h b/Source/CTest/cmCTestBatchTestHandler.h index 44db252..4a5dac1 100644 --- a/Source/CTest/cmCTestBatchTestHandler.h +++ b/Source/CTest/cmCTestBatchTestHandler.h @@ -3,10 +3,10 @@ #ifndef cmCTestBatchTestHandler_h #define cmCTestBatchTestHandler_h -#include <cmConfigure.h> +#include "cmConfigure.h" -#include <cmCTestMultiProcessHandler.h> -#include <cmsys/FStream.hxx> +#include "cmCTestMultiProcessHandler.h" +#include "cmsys/FStream.hxx" #include <string> /** \class cmCTestBatchTestHandler diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx index 6780a0e..ed7dd5d 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.cxx +++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx @@ -6,9 +6,10 @@ #include "cmCTestTestHandler.h" #include "cmGlobalGenerator.h" #include "cmSystemTools.h" +#include "cmWorkingDirectory.h" #include "cmake.h" -#include <cmsys/Process.h> +#include "cmsys/Process.h" #include <stdlib.h> cmCTestBuildAndTestHandler::cmCTestBuildAndTestHandler() @@ -42,7 +43,7 @@ int cmCTestBuildAndTestHandler::ProcessHandler() int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring, std::ostringstream& out, std::string& cmakeOutString, - std::string& cwd, cmake* cm) + cmake* cm) { unsigned int k; std::vector<std::string> args; @@ -85,8 +86,6 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring, if (cm->Run(args) != 0) { out << "Error: cmake execution failed\n"; out << cmakeOutString << "\n"; - // return to the original directory - cmSystemTools::ChangeDirectory(cwd); if (outstring) { *outstring = out.str(); } else { @@ -99,8 +98,6 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring, if (cm->Run(args) != 0) { out << "Error: cmake execution failed\n"; out << cmakeOutString << "\n"; - // return to the original directory - cmSystemTools::ChangeDirectory(cwd); if (outstring) { *outstring = out.str(); } else { @@ -199,13 +196,12 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) double clock_start = cmSystemTools::GetTime(); // make sure the binary dir is there - std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); out << "Internal cmake changing into directory: " << this->BinaryDir << std::endl; if (!cmSystemTools::FileIsDirectory(this->BinaryDir)) { cmSystemTools::MakeDirectory(this->BinaryDir.c_str()); } - cmSystemTools::ChangeDirectory(this->BinaryDir); + cmWorkingDirectory workdir(this->BinaryDir); if (this->BuildNoCMake) { // Make the generator available for the Build call below. @@ -217,7 +213,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) cm.LoadCache(this->BinaryDir); } else { // do the cmake step, no timeout here since it is not a sub process - if (this->RunCMake(outstring, out, cmakeOutString, cwd, &cm)) { + if (this->RunCMake(outstring, out, cmakeOutString, &cm)) { return 1; } } @@ -304,8 +300,6 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) } else { cmCTestLog(this->CTest, ERROR_MESSAGE, out.str()); } - // return to the original directory - cmSystemTools::ChangeDirectory(cwd); return 1; } diff --git a/Source/CTest/cmCTestBuildAndTestHandler.h b/Source/CTest/cmCTestBuildAndTestHandler.h index 5885738..2e85e9f 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.h +++ b/Source/CTest/cmCTestBuildAndTestHandler.h @@ -3,7 +3,7 @@ #ifndef cmCTestBuildAndTestHandler_h #define cmCTestBuildAndTestHandler_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCTestGenericHandler.h" @@ -46,7 +46,7 @@ protected: ///! Run CMake and build a test and then run it as a single test. int RunCMakeAndTest(std::string* output); int RunCMake(std::string* outstring, std::ostringstream& out, - std::string& cmakeOutString, std::string& cwd, cmake* cm); + std::string& cmakeOutString, cmake* cm); std::string Output; diff --git a/Source/CTest/cmCTestBuildCommand.h b/Source/CTest/cmCTestBuildCommand.h index 9cc6f7e..9cf6a96 100644 --- a/Source/CTest/cmCTestBuildCommand.h +++ b/Source/CTest/cmCTestBuildCommand.h @@ -3,7 +3,7 @@ #ifndef cmCTestBuildCommand_h #define cmCTestBuildCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCTestHandlerCommand.h" diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index 1868a1e..b6075c9 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -11,9 +11,9 @@ #include "cmSystemTools.h" #include "cmXMLWriter.h" -#include <cmsys/Directory.hxx> -#include <cmsys/FStream.hxx> -#include <cmsys/Process.h> +#include "cmsys/Directory.hxx" +#include "cmsys/FStream.hxx" +#include "cmsys/Process.h" #include <set> #include <stdlib.h> #include <string.h> diff --git a/Source/CTest/cmCTestBuildHandler.h b/Source/CTest/cmCTestBuildHandler.h index a2f6112..ef3cddf 100644 --- a/Source/CTest/cmCTestBuildHandler.h +++ b/Source/CTest/cmCTestBuildHandler.h @@ -3,12 +3,12 @@ #ifndef cmCTestBuildHandler_h #define cmCTestBuildHandler_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCTestGenericHandler.h" -#include <cmProcessOutput.h> -#include <cmsys/RegularExpression.hxx> +#include "cmProcessOutput.h" +#include "cmsys/RegularExpression.hxx" #include <deque> #include <iosfwd> #include <stddef.h> diff --git a/Source/CTest/cmCTestCVS.cxx b/Source/CTest/cmCTestCVS.cxx index 98bb678..fad360b 100644 --- a/Source/CTest/cmCTestCVS.cxx +++ b/Source/CTest/cmCTestCVS.cxx @@ -7,8 +7,8 @@ #include "cmSystemTools.h" #include "cmXMLWriter.h" -#include <cmsys/FStream.hxx> -#include <cmsys/RegularExpression.hxx> +#include "cmsys/FStream.hxx" +#include "cmsys/RegularExpression.hxx" #include <utility> cmCTestCVS::cmCTestCVS(cmCTest* ct, std::ostream& log) diff --git a/Source/CTest/cmCTestCVS.h b/Source/CTest/cmCTestCVS.h index d921b1a..1208cfa 100644 --- a/Source/CTest/cmCTestCVS.h +++ b/Source/CTest/cmCTestCVS.h @@ -3,7 +3,7 @@ #ifndef cmCTestCVS_h #define cmCTestCVS_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCTestVC.h" diff --git a/Source/CTest/cmCTestConfigureCommand.h b/Source/CTest/cmCTestConfigureCommand.h index 22d1217..917f5ab 100644 --- a/Source/CTest/cmCTestConfigureCommand.h +++ b/Source/CTest/cmCTestConfigureCommand.h @@ -3,7 +3,7 @@ #ifndef cmCTestConfigureCommand_h #define cmCTestConfigureCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCTestHandlerCommand.h" diff --git a/Source/CTest/cmCTestConfigureHandler.h b/Source/CTest/cmCTestConfigureHandler.h index 7fa95ed..2b45282 100644 --- a/Source/CTest/cmCTestConfigureHandler.h +++ b/Source/CTest/cmCTestConfigureHandler.h @@ -3,7 +3,7 @@ #ifndef cmCTestConfigureHandler_h #define cmCTestConfigureHandler_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCTestGenericHandler.h" diff --git a/Source/CTest/cmCTestCoverageCommand.h b/Source/CTest/cmCTestCoverageCommand.h index bf42aa1..78c4f61 100644 --- a/Source/CTest/cmCTestCoverageCommand.h +++ b/Source/CTest/cmCTestCoverageCommand.h @@ -3,7 +3,7 @@ #ifndef cmCTestCoverageCommand_h #define cmCTestCoverageCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCTestHandlerCommand.h" diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 989c096..87c532c 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -12,14 +12,15 @@ #include "cmParseJacocoCoverage.h" #include "cmParsePHPCoverage.h" #include "cmSystemTools.h" +#include "cmWorkingDirectory.h" #include "cmXMLWriter.h" #include "cmake.h" +#include "cmsys/FStream.hxx" +#include "cmsys/Glob.hxx" +#include "cmsys/Process.h" +#include "cmsys/RegularExpression.hxx" #include <algorithm> -#include <cmsys/FStream.hxx> -#include <cmsys/Glob.hxx> -#include <cmsys/Process.h> -#include <cmsys/RegularExpression.hxx> #include <iomanip> #include <iterator> #include <sstream> @@ -969,9 +970,8 @@ int cmCTestCoverageHandler::HandleGCovCoverage( std::string testingDir = this->CTest->GetBinaryDir() + "/Testing"; std::string tempDir = testingDir + "/CoverageInfo"; - std::string currentDirectory = cmSystemTools::GetCurrentWorkingDirectory(); cmSystemTools::MakeDirectory(tempDir.c_str()); - cmSystemTools::ChangeDirectory(tempDir); + cmWorkingDirectory workdir(tempDir); int gcovStyle = 0; @@ -1294,7 +1294,6 @@ int cmCTestCoverageHandler::HandleGCovCoverage( } } - cmSystemTools::ChangeDirectory(currentDirectory); return file_count; } @@ -1340,7 +1339,6 @@ int cmCTestCoverageHandler::HandleLCovCoverage( return 0; } std::string testingDir = this->CTest->GetBinaryDir(); - std::string currentDirectory = cmSystemTools::GetCurrentWorkingDirectory(); std::set<std::string> missingFiles; @@ -1362,7 +1360,7 @@ int cmCTestCoverageHandler::HandleLCovCoverage( cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "." << std::flush, this->Quiet); std::string fileDir = cmSystemTools::GetFilenamePath(*it); - cmSystemTools::ChangeDirectory(fileDir); + cmWorkingDirectory workdir(fileDir); std::string command = "\"" + lcovCommand + "\" " + lcovExtraFlags + " "; cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, @@ -1552,7 +1550,6 @@ int cmCTestCoverageHandler::HandleLCovCoverage( } } - cmSystemTools::ChangeDirectory(currentDirectory); return file_count; } @@ -1591,13 +1588,8 @@ bool cmCTestCoverageHandler::FindLCovFiles(std::vector<std::string>& files) gl.RecurseOff(); // No need of recurse if -prof_dir${BUILD_DIR} flag is // used while compiling. gl.RecurseThroughSymlinksOff(); - std::string prevBinaryDir; std::string buildDir = this->CTest->GetCTestConfiguration("BuildDirectory"); - if (cmSystemTools::ChangeDirectory(buildDir)) { - cmCTestLog(this->CTest, ERROR_MESSAGE, "Error changing directory to " - << buildDir << std::endl); - return false; - } + cmWorkingDirectory workdir(buildDir); // Run profmerge to merge all *.dyn files into dpi files if (!cmSystemTools::RunSingleCommand("profmerge")) { @@ -1605,11 +1597,9 @@ bool cmCTestCoverageHandler::FindLCovFiles(std::vector<std::string>& files) return false; } - prevBinaryDir = cmSystemTools::GetCurrentWorkingDirectory(); - // DPI file should appear in build directory std::string daGlob; - daGlob = prevBinaryDir; + daGlob = buildDir; daGlob += "/*.dpi"; cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " looking for dpi files in: " << daGlob << std::endl, @@ -1646,11 +1636,7 @@ int cmCTestCoverageHandler::HandleTracePyCoverage( std::string testingDir = this->CTest->GetBinaryDir() + "/Testing"; std::string tempDir = testingDir + "/CoverageInfo"; - std::string currentDirectory = cmSystemTools::GetCurrentWorkingDirectory(); cmSystemTools::MakeDirectory(tempDir.c_str()); - cmSystemTools::ChangeDirectory(tempDir); - - cmSystemTools::ChangeDirectory(currentDirectory); std::vector<std::string>::iterator fileIt; int file_count = 0; @@ -1737,7 +1723,6 @@ int cmCTestCoverageHandler::HandleTracePyCoverage( } ++file_count; } - cmSystemTools::ChangeDirectory(currentDirectory); return file_count; } @@ -2237,7 +2222,8 @@ void cmCTestCoverageHandler::LoadLabels(const char* dir) if (line.empty() || line[0] == '#') { // Ignore blank and comment lines. continue; - } else if (line[0] == ' ') { + } + if (line[0] == ' ') { // Label lines appear indented by one space. std::string label = line.substr(1); int id = this->GetLabelId(label); diff --git a/Source/CTest/cmCTestCoverageHandler.h b/Source/CTest/cmCTestCoverageHandler.h index 339b5d7..933f606 100644 --- a/Source/CTest/cmCTestCoverageHandler.h +++ b/Source/CTest/cmCTestCoverageHandler.h @@ -3,11 +3,11 @@ #ifndef cmCTestCoverageHandler_h #define cmCTestCoverageHandler_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCTestGenericHandler.h" -#include <cmsys/RegularExpression.hxx> +#include "cmsys/RegularExpression.hxx" #include <iosfwd> #include <map> #include <set> diff --git a/Source/CTest/cmCTestCurl.cxx b/Source/CTest/cmCTestCurl.cxx index ab1412d..06b5e81 100644 --- a/Source/CTest/cmCTestCurl.cxx +++ b/Source/CTest/cmCTestCurl.cxx @@ -5,7 +5,7 @@ #include "cmCTest.h" #include "cmSystemTools.h" -#include <cmConfigure.h> +#include "cmConfigure.h" #include <ostream> #include <stdio.h> diff --git a/Source/CTest/cmCTestCurl.h b/Source/CTest/cmCTestCurl.h index cdce393..67608cb 100644 --- a/Source/CTest/cmCTestCurl.h +++ b/Source/CTest/cmCTestCurl.h @@ -3,9 +3,9 @@ #ifndef cmCTestCurl_h #define cmCTestCurl_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep -#include <cm_curl.h> +#include "cm_curl.h" #include <string> #include <vector> diff --git a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h index 4c1438b..bfd4061 100644 --- a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h +++ b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h @@ -3,7 +3,7 @@ #ifndef cmCTestEmptyBinaryDirectoryCommand_h #define cmCTestEmptyBinaryDirectoryCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCTestCommand.h" diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx index d30f6b3..17f822d 100644 --- a/Source/CTest/cmCTestGIT.cxx +++ b/Source/CTest/cmCTestGIT.cxx @@ -2,8 +2,8 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestGIT.h" -#include <cmsys/FStream.hxx> -#include <cmsys/Process.h> +#include "cmsys/FStream.hxx" +#include "cmsys/Process.h" #include <ctype.h> #include <stdio.h> #include <stdlib.h> @@ -67,19 +67,21 @@ std::string cmCTestGIT::GetWorkingRevision() return rev; } -void cmCTestGIT::NoteOldRevision() +bool cmCTestGIT::NoteOldRevision() { this->OldRevision = this->GetWorkingRevision(); cmCTestLog(this->CTest, HANDLER_OUTPUT, " Old revision of repository is: " << this->OldRevision << "\n"); this->PriorRev.Rev = this->OldRevision; + return true; } -void cmCTestGIT::NoteNewRevision() +bool cmCTestGIT::NoteNewRevision() { this->NewRevision = this->GetWorkingRevision(); cmCTestLog(this->CTest, HANDLER_OUTPUT, " New revision of repository is: " << this->NewRevision << "\n"); + return true; } std::string cmCTestGIT::FindGitDir() @@ -607,7 +609,7 @@ private: char const cmCTestGIT::CommitParser::SectionSep[SectionCount] = { '\n', '\n', '\0' }; -void cmCTestGIT::LoadRevisions() +bool cmCTestGIT::LoadRevisions() { // Use 'git rev-list ... | git diff-tree ...' to get revisions. std::string range = this->OldRevision + ".." + this->NewRevision; @@ -634,9 +636,10 @@ void cmCTestGIT::LoadRevisions() out.Process("", 1); cmsysProcess_Delete(cp); + return true; } -void cmCTestGIT::LoadModifications() +bool cmCTestGIT::LoadModifications() { const char* git = this->CommandLineTool.c_str(); @@ -660,4 +663,5 @@ void cmCTestGIT::LoadModifications() ci != out.Changes.end(); ++ci) { this->DoModification(PathModified, ci->Path); } + return true; } diff --git a/Source/CTest/cmCTestGIT.h b/Source/CTest/cmCTestGIT.h index a655502..4bf8294 100644 --- a/Source/CTest/cmCTestGIT.h +++ b/Source/CTest/cmCTestGIT.h @@ -3,7 +3,7 @@ #ifndef cmCTestGIT_h #define cmCTestGIT_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCTestGlobalVC.h" @@ -28,8 +28,8 @@ private: unsigned int CurrentGitVersion; unsigned int GetGitVersion(); std::string GetWorkingRevision(); - void NoteOldRevision() CM_OVERRIDE; - void NoteNewRevision() CM_OVERRIDE; + bool NoteOldRevision() CM_OVERRIDE; + bool NoteNewRevision() CM_OVERRIDE; bool UpdateImpl() CM_OVERRIDE; std::string FindGitDir(); @@ -39,8 +39,8 @@ private: bool UpdateByCustom(std::string const& custom); bool UpdateInternal(); - void LoadRevisions() CM_OVERRIDE; - void LoadModifications() CM_OVERRIDE; + bool LoadRevisions() CM_OVERRIDE; + bool LoadModifications() CM_OVERRIDE; // "public" needed by older Sun compilers public: diff --git a/Source/CTest/cmCTestGenericHandler.cxx b/Source/CTest/cmCTestGenericHandler.cxx index 7638f45..19034c0 100644 --- a/Source/CTest/cmCTestGenericHandler.cxx +++ b/Source/CTest/cmCTestGenericHandler.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestGenericHandler.h" -#include <cmConfigure.h> +#include "cmConfigure.h" #include <sstream> #include <utility> diff --git a/Source/CTest/cmCTestGenericHandler.h b/Source/CTest/cmCTestGenericHandler.h index 2ebbe70..e881252 100644 --- a/Source/CTest/cmCTestGenericHandler.h +++ b/Source/CTest/cmCTestGenericHandler.h @@ -3,7 +3,7 @@ #ifndef cmCTestGenericHandler_h #define cmCTestGenericHandler_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <map> #include <stddef.h> diff --git a/Source/CTest/cmCTestGlobalVC.cxx b/Source/CTest/cmCTestGlobalVC.cxx index 08af179..25294b5 100644 --- a/Source/CTest/cmCTestGlobalVC.cxx +++ b/Source/CTest/cmCTestGlobalVC.cxx @@ -102,14 +102,15 @@ void cmCTestGlobalVC::WriteXMLGlobal(cmXMLWriter& xml) bool cmCTestGlobalVC::WriteXMLUpdates(cmXMLWriter& xml) { + bool result = true; cmCTestLog(this->CTest, HANDLER_OUTPUT, " Gathering version information (one . per revision):\n" " " << std::flush); - this->LoadRevisions(); + result = this->LoadRevisions() && result; cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl); - this->LoadModifications(); + result = this->LoadModifications() && result; this->WriteXMLGlobal(xml); @@ -119,5 +120,5 @@ bool cmCTestGlobalVC::WriteXMLUpdates(cmXMLWriter& xml) this->WriteXMLDirectory(xml, di->first, di->second); } - return true; + return result; } diff --git a/Source/CTest/cmCTestGlobalVC.h b/Source/CTest/cmCTestGlobalVC.h index 9a3757d..a5273d3 100644 --- a/Source/CTest/cmCTestGlobalVC.h +++ b/Source/CTest/cmCTestGlobalVC.h @@ -3,7 +3,7 @@ #ifndef cmCTestGlobalVC_h #define cmCTestGlobalVC_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCTestVC.h" @@ -64,8 +64,8 @@ protected: virtual void DoRevision(Revision const& revision, std::vector<Change> const& changes); virtual void DoModification(PathStatus status, std::string const& path); - virtual void LoadModifications() = 0; - virtual void LoadRevisions() = 0; + virtual bool LoadModifications() = 0; + virtual bool LoadRevisions() = 0; virtual void WriteXMLGlobal(cmXMLWriter& xml); void WriteXMLDirectory(cmXMLWriter& xml, std::string const& path, diff --git a/Source/CTest/cmCTestHG.cxx b/Source/CTest/cmCTestHG.cxx index 8443c93..49f9a65 100644 --- a/Source/CTest/cmCTestHG.cxx +++ b/Source/CTest/cmCTestHG.cxx @@ -8,7 +8,7 @@ #include "cmSystemTools.h" #include "cmXMLParser.h" -#include <cmsys/RegularExpression.hxx> +#include "cmsys/RegularExpression.hxx" #include <ostream> #include <vector> @@ -104,19 +104,21 @@ std::string cmCTestHG::GetWorkingRevision() return rev; } -void cmCTestHG::NoteOldRevision() +bool cmCTestHG::NoteOldRevision() { this->OldRevision = this->GetWorkingRevision(); cmCTestLog(this->CTest, HANDLER_OUTPUT, " Old revision of repository is: " << this->OldRevision << "\n"); this->PriorRev.Rev = this->OldRevision; + return true; } -void cmCTestHG::NoteNewRevision() +bool cmCTestHG::NoteNewRevision() { this->NewRevision = this->GetWorkingRevision(); cmCTestLog(this->CTest, HANDLER_OUTPUT, " New revision of repository is: " << this->NewRevision << "\n"); + return true; } bool cmCTestHG::UpdateImpl() @@ -262,7 +264,7 @@ private: } }; -void cmCTestHG::LoadRevisions() +bool cmCTestHG::LoadRevisions() { // Use 'hg log' to get revisions in a xml format. // @@ -293,9 +295,10 @@ void cmCTestHG::LoadRevisions() OutputLogger err(this->Log, "log-err> "); this->RunChild(hg_log, &out, &err); out.Process("</log>\n"); + return true; } -void cmCTestHG::LoadModifications() +bool cmCTestHG::LoadModifications() { // Use 'hg status' to get modified files. const char* hg = this->CommandLineTool.c_str(); @@ -303,4 +306,5 @@ void cmCTestHG::LoadModifications() StatusParser out(this, "status-out> "); OutputLogger err(this->Log, "status-err> "); this->RunChild(hg_status, &out, &err); + return true; } diff --git a/Source/CTest/cmCTestHG.h b/Source/CTest/cmCTestHG.h index a81c347..ec9eaff 100644 --- a/Source/CTest/cmCTestHG.h +++ b/Source/CTest/cmCTestHG.h @@ -3,7 +3,7 @@ #ifndef cmCTestHG_h #define cmCTestHG_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCTestGlobalVC.h" @@ -26,12 +26,12 @@ public: private: std::string GetWorkingRevision(); - void NoteOldRevision() CM_OVERRIDE; - void NoteNewRevision() CM_OVERRIDE; + bool NoteOldRevision() CM_OVERRIDE; + bool NoteNewRevision() CM_OVERRIDE; bool UpdateImpl() CM_OVERRIDE; - void LoadRevisions() CM_OVERRIDE; - void LoadModifications() CM_OVERRIDE; + bool LoadRevisions() CM_OVERRIDE; + bool LoadModifications() CM_OVERRIDE; // Parsing helper classes. class IdentifyParser; diff --git a/Source/CTest/cmCTestHandlerCommand.cxx b/Source/CTest/cmCTestHandlerCommand.cxx index a989b12..c99e450 100644 --- a/Source/CTest/cmCTestHandlerCommand.cxx +++ b/Source/CTest/cmCTestHandlerCommand.cxx @@ -6,6 +6,7 @@ #include "cmCTestGenericHandler.h" #include "cmMakefile.h" #include "cmSystemTools.h" +#include "cmWorkingDirectory.h" #include "cmake.h" #include <sstream> @@ -123,8 +124,8 @@ bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args, if (capureCMakeError) { this->Makefile->AddDefinition(this->Values[ct_CAPTURE_CMAKE_ERROR], "-1"); - const char* err = this->GetError(); - if (err && !cmSystemTools::FindLastString(err, "unknown error.")) { + std::string const err = this->GetName() + " " + this->GetError(); + if (!cmSystemTools::FindLastString(err.c_str(), "unknown error.")) { cmCTestLog(this->CTest, ERROR_MESSAGE, err << " error from command\n"); } // return success because failure is recorded in CAPTURE_CMAKE_ERROR @@ -216,8 +217,7 @@ bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args, handler->SetSubmitIndex(atoi(this->Values[ct_SUBMIT_INDEX])); } } - std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory(); - cmSystemTools::ChangeDirectory( + cmWorkingDirectory workdir( this->CTest->GetCTestConfiguration("BuildDirectory")); int res = handler->ProcessHandler(); if (this->Values[ct_RETURN_VALUE] && *this->Values[ct_RETURN_VALUE]) { @@ -243,7 +243,6 @@ bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args, this->Makefile->AddDefinition(this->Values[ct_CAPTURE_CMAKE_ERROR], returnString); } - cmSystemTools::ChangeDirectory(current_dir); return true; } diff --git a/Source/CTest/cmCTestHandlerCommand.h b/Source/CTest/cmCTestHandlerCommand.h index c86841f..adc1687 100644 --- a/Source/CTest/cmCTestHandlerCommand.h +++ b/Source/CTest/cmCTestHandlerCommand.h @@ -3,7 +3,7 @@ #ifndef cmCTestHandlerCommand_h #define cmCTestHandlerCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCTestCommand.h" diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx index 03e0319..a782150 100644 --- a/Source/CTest/cmCTestLaunch.cxx +++ b/Source/CTest/cmCTestLaunch.cxx @@ -2,11 +2,11 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestLaunch.h" -#include <cmConfigure.h> +#include "cmConfigure.h" -#include <cmsys/FStream.hxx> -#include <cmsys/Process.h> -#include <cmsys/RegularExpression.hxx> +#include "cmsys/FStream.hxx" +#include "cmsys/Process.h" +#include "cmsys/RegularExpression.hxx" #include <iostream> #include <stdlib.h> #include <string.h> @@ -306,7 +306,8 @@ void cmCTestLaunch::LoadLabels() if (line.empty() || line[0] == '#') { // Ignore blank and comment lines. continue; - } else if (line[0] == ' ') { + } + if (line[0] == ' ') { // Label lines appear indented by one space. if (inTarget || inSource) { this->Labels.insert(line.c_str() + 1); diff --git a/Source/CTest/cmCTestLaunch.h b/Source/CTest/cmCTestLaunch.h index fbc9e2b..29986ff 100644 --- a/Source/CTest/cmCTestLaunch.h +++ b/Source/CTest/cmCTestLaunch.h @@ -3,9 +3,9 @@ #ifndef cmCTestLaunch_h #define cmCTestLaunch_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep -#include <cmsys/RegularExpression.hxx> +#include "cmsys/RegularExpression.hxx" #include <set> #include <string> #include <vector> diff --git a/Source/CTest/cmCTestMemCheckCommand.h b/Source/CTest/cmCTestMemCheckCommand.h index 458ebb0..fea65e8 100644 --- a/Source/CTest/cmCTestMemCheckCommand.h +++ b/Source/CTest/cmCTestMemCheckCommand.h @@ -3,7 +3,7 @@ #ifndef cmCTestMemCheckCommand_h #define cmCTestMemCheckCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCTestTestCommand.h" diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index 620e237..fc4980b 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -7,9 +7,9 @@ #include "cmXMLParser.h" #include "cmXMLWriter.h" -#include <cmsys/FStream.hxx> -#include <cmsys/Glob.hxx> -#include <cmsys/RegularExpression.hxx> +#include "cmsys/FStream.hxx" +#include "cmsys/Glob.hxx" +#include "cmsys/RegularExpression.hxx" #include <iostream> #include <sstream> #include <string.h> diff --git a/Source/CTest/cmCTestMemCheckHandler.h b/Source/CTest/cmCTestMemCheckHandler.h index ff8b593..333c2e2 100644 --- a/Source/CTest/cmCTestMemCheckHandler.h +++ b/Source/CTest/cmCTestMemCheckHandler.h @@ -3,7 +3,7 @@ #ifndef cmCTestMemCheckHandler_h #define cmCTestMemCheckHandler_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCTestTestHandler.h" diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index c1724ab..fdc16b1 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -7,11 +7,12 @@ #include "cmCTestScriptHandler.h" #include "cmCTestTestHandler.h" #include "cmSystemTools.h" +#include "cmWorkingDirectory.h" +#include "cmsys/FStream.hxx" +#include "cmsys/String.hxx" +#include "cmsys/SystemInformation.hxx" #include <algorithm> -#include <cmsys/FStream.hxx> -#include <cmsys/String.hxx> -#include <cmsys/SystemInformation.hxx> #include <iomanip> #include <list> #include <math.h> @@ -138,8 +139,7 @@ void cmCTestMultiProcessHandler::StartTestProcess(int test) } } - std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory(); - cmSystemTools::ChangeDirectory(this->Properties[test]->Directory); + cmWorkingDirectory workdir(this->Properties[test]->Directory); // Lock the resources we'll be using this->LockResources(test); @@ -163,10 +163,11 @@ void cmCTestMultiProcessHandler::StartTestProcess(int test) this->TestRunningMap[test] = false; this->RunningCount -= GetProcessorsUsed(test); testRun->EndTest(this->Completed, this->Total, false); - this->Failed->push_back(this->Properties[test]->Name); + if (!this->Properties[test]->Disabled) { + this->Failed->push_back(this->Properties[test]->Name); + } delete testRun; } - cmSystemTools::ChangeDirectory(current_dir); } void cmCTestMultiProcessHandler::LockResources(int index) @@ -560,7 +561,7 @@ void cmCTestMultiProcessHandler::CreateParallelTestCostList() // In parallel test runs repeatedly move dependencies of the tests on // the current dependency level to the next level until no // further dependencies exist. - while (priorityStack.back().size()) { + while (!priorityStack.back().empty()) { TestSet& previousSet = priorityStack.back(); priorityStack.push_back(TestSet()); TestSet& currentSet = priorityStack.back(); @@ -683,9 +684,7 @@ void cmCTestMultiProcessHandler::PrintTestList() count++; cmCTestTestHandler::cmCTestTestProperties& p = *it->second; - // push working dir - std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory(); - cmSystemTools::ChangeDirectory(p.Directory); + cmWorkingDirectory workdir(p.Directory); cmCTestRunTest testRun(this->TestHandler); testRun.SetIndex(p.Index); @@ -724,8 +723,6 @@ void cmCTestMultiProcessHandler::PrintTestList() cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " ", this->Quiet); cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, p.Name << std::endl, this->Quiet); - // pop working dir - cmSystemTools::ChangeDirectory(current_dir); } cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, std::endl diff --git a/Source/CTest/cmCTestMultiProcessHandler.h b/Source/CTest/cmCTestMultiProcessHandler.h index fe32e15..dccc2c8 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.h +++ b/Source/CTest/cmCTestMultiProcessHandler.h @@ -3,9 +3,9 @@ #ifndef cmCTestMultiProcessHandler_h #define cmCTestMultiProcessHandler_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep -#include <cmCTestTestHandler.h> +#include "cmCTestTestHandler.h" #include <map> #include <set> #include <stddef.h> diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx index 41b45a8..c802216 100644 --- a/Source/CTest/cmCTestP4.cxx +++ b/Source/CTest/cmCTestP4.cxx @@ -7,8 +7,8 @@ #include "cmProcessTools.h" #include "cmSystemTools.h" +#include "cmsys/RegularExpression.hxx" #include <algorithm> -#include <cmsys/RegularExpression.hxx> #include <ostream> #include <time.h> #include <utility> @@ -369,24 +369,26 @@ std::string cmCTestP4::GetWorkingRevision() return rev; } -void cmCTestP4::NoteOldRevision() +bool cmCTestP4::NoteOldRevision() { this->OldRevision = this->GetWorkingRevision(); cmCTestLog(this->CTest, HANDLER_OUTPUT, " Old revision of repository is: " << this->OldRevision << "\n"); this->PriorRev.Rev = this->OldRevision; + return true; } -void cmCTestP4::NoteNewRevision() +bool cmCTestP4::NoteNewRevision() { this->NewRevision = this->GetWorkingRevision(); cmCTestLog(this->CTest, HANDLER_OUTPUT, " New revision of repository is: " << this->NewRevision << "\n"); + return true; } -void cmCTestP4::LoadRevisions() +bool cmCTestP4::LoadRevisions() { std::vector<char const*> p4_changes; SetP4Options(p4_changes); @@ -399,7 +401,7 @@ void cmCTestP4::LoadRevisions() if (this->OldRevision == "<unknown>" || this->NewRevision == "<unknown>") { cmCTestLog(this->CTest, HANDLER_OUTPUT, " At least one of the revisions " << "is unknown. No repository changes will be reported.\n"); - return; + return false; } range.append("@") @@ -418,7 +420,7 @@ void cmCTestP4::LoadRevisions() this->RunChild(&p4_changes[0], &out, &err); if (ChangeLists.empty()) { - return; + return true; } // p4 describe -s ...@1111111,2222222 @@ -435,9 +437,10 @@ void cmCTestP4::LoadRevisions() OutputLogger errDescribe(this->Log, "p4_describe-err> "); this->RunChild(&p4_describe[0], &outDescribe, &errDescribe); } + return true; } -void cmCTestP4::LoadModifications() +bool cmCTestP4::LoadModifications() { std::vector<char const*> p4_diff; SetP4Options(p4_diff); @@ -453,6 +456,7 @@ void cmCTestP4::LoadModifications() DiffParser out(this, "p4_diff-out> "); OutputLogger err(this->Log, "p4_diff-err> "); this->RunChild(&p4_diff[0], &out, &err); + return true; } bool cmCTestP4::UpdateCustom(const std::string& custom) diff --git a/Source/CTest/cmCTestP4.h b/Source/CTest/cmCTestP4.h index eadc4fb..e234efb 100644 --- a/Source/CTest/cmCTestP4.h +++ b/Source/CTest/cmCTestP4.h @@ -3,7 +3,7 @@ #ifndef cmCTestP4_h #define cmCTestP4_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCTestGlobalVC.h" @@ -51,13 +51,13 @@ private: void SetP4Options(std::vector<char const*>& options); std::string GetWorkingRevision(); - void NoteOldRevision() CM_OVERRIDE; - void NoteNewRevision() CM_OVERRIDE; + bool NoteOldRevision() CM_OVERRIDE; + bool NoteNewRevision() CM_OVERRIDE; bool UpdateImpl() CM_OVERRIDE; bool UpdateCustom(const std::string& custom); - void LoadRevisions() CM_OVERRIDE; - void LoadModifications() CM_OVERRIDE; + bool LoadRevisions() CM_OVERRIDE; + bool LoadModifications() CM_OVERRIDE; class ChangesParser; class DescribeParser; diff --git a/Source/CTest/cmCTestReadCustomFilesCommand.h b/Source/CTest/cmCTestReadCustomFilesCommand.h index e155595..04024ab 100644 --- a/Source/CTest/cmCTestReadCustomFilesCommand.h +++ b/Source/CTest/cmCTestReadCustomFilesCommand.h @@ -3,7 +3,7 @@ #ifndef cmCTestReadCustomFilesCommand_h #define cmCTestReadCustomFilesCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCTestCommand.h" diff --git a/Source/CTest/cmCTestRunScriptCommand.h b/Source/CTest/cmCTestRunScriptCommand.h index 01ed62e..aac5114 100644 --- a/Source/CTest/cmCTestRunScriptCommand.h +++ b/Source/CTest/cmCTestRunScriptCommand.h @@ -3,7 +3,7 @@ #ifndef cmCTestRunScriptCommand_h #define cmCTestRunScriptCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCTestCommand.h" diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index ac1644f..a4853b7 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -7,13 +7,14 @@ #include "cmCTestTestHandler.h" #include "cmProcess.h" #include "cmSystemTools.h" - -#include <cmConfigure.h> -#include <cm_curl.h> -#include <cm_zlib.h> -#include <cmsys/Base64.h> -#include <cmsys/Process.h> -#include <cmsys/RegularExpression.hxx> +#include "cmWorkingDirectory.h" + +#include "cmConfigure.h" +#include "cm_curl.h" +#include "cm_zlib.h" +#include "cmsys/Base64.h" +#include "cmsys/Process.h" +#include "cmsys/RegularExpression.hxx" #include <iomanip> #include <sstream> #include <stdio.h> @@ -214,6 +215,9 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started) if (this->TestProperties->SkipReturnCode >= 0 && this->TestProperties->SkipReturnCode == retVal) { this->TestResult.Status = cmCTestTestHandler::NOT_RUN; + std::ostringstream s; + s << "SKIP_RETURN_CODE=" << this->TestProperties->SkipReturnCode; + this->TestResult.CompletionStatus = s.str(); cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Skipped "); } else if ((success && !this->TestProperties->WillFail) || (!success && this->TestProperties->WillFail)) { @@ -252,6 +256,8 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started) cmCTestLog(this->CTest, HANDLER_OUTPUT, "Other"); this->TestResult.Status = cmCTestTestHandler::OTHER_FAULT; } + } else if ("Disabled" == this->TestResult.CompletionStatus) { + cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Not Run (Disabled) "); } else // cmsysProcess_State_Error { cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Not Run "); @@ -270,14 +276,11 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started) *this->TestHandler->LogFile << "Test time = " << buf << std::endl; } - // Set the working directory to the tests directory - std::string oldpath = cmSystemTools::GetCurrentWorkingDirectory(); - cmSystemTools::ChangeDirectory(this->TestProperties->Directory); - - this->DartProcessing(); - - // restore working directory - cmSystemTools::ChangeDirectory(oldpath); + // Set the working directory to the tests directory to process Dart files. + { + cmWorkingDirectory workdir(this->TestProperties->Directory); + this->DartProcessing(); + } // if this is doing MemCheck then all the output needs to be put into // Output since that is what is parsed by cmCTestMemCheckHandler @@ -356,11 +359,8 @@ bool cmCTestRunTest::StartAgain() } this->RunAgain = false; // reset // change to tests directory - std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory(); - cmSystemTools::ChangeDirectory(this->TestProperties->Directory); + cmWorkingDirectory workdir(this->TestProperties->Directory); this->StartTest(this->TotalNumberOfTests); - // change back - cmSystemTools::ChangeDirectory(current_dir); return true; } @@ -418,6 +418,24 @@ bool cmCTestRunTest::StartTest(size_t total) << this->TestProperties->Index << ": " << this->TestProperties->Name << std::endl); this->ProcessOutput.clear(); + + // Return immediately if test is disabled + if (this->TestProperties->Disabled) { + this->TestResult.Properties = this->TestProperties; + this->TestResult.ExecutionTime = 0; + this->TestResult.CompressOutput = false; + this->TestResult.ReturnValue = -1; + this->TestResult.CompletionStatus = "Disabled"; + this->TestResult.Status = cmCTestTestHandler::NOT_RUN; + this->TestResult.TestCount = this->TestProperties->Index; + this->TestResult.Name = this->TestProperties->Name; + this->TestResult.Path = this->TestProperties->Directory; + this->TestProcess = new cmProcess; + this->TestResult.Output = "Disabled"; + this->TestResult.FullCommandLine = ""; + return false; + } + this->ComputeArguments(); std::vector<std::string>& args = this->TestProperties->Args; this->TestResult.Properties = this->TestProperties; @@ -442,7 +460,7 @@ bool cmCTestRunTest::StartTest(size_t total) cmCTestLog(this->CTest, HANDLER_OUTPUT, msg << std::endl); this->TestResult.Output = msg; this->TestResult.FullCommandLine = ""; - this->TestResult.CompletionStatus = "Not Run"; + this->TestResult.CompletionStatus = "Fixture dependency failed"; this->TestResult.Status = cmCTestTestHandler::NOT_RUN; return false; } @@ -462,7 +480,7 @@ bool cmCTestRunTest::StartTest(size_t total) cmCTestLog(this->CTest, ERROR_MESSAGE, msg << std::endl); this->TestResult.Output = msg; this->TestResult.FullCommandLine = ""; - this->TestResult.CompletionStatus = "Not Run"; + this->TestResult.CompletionStatus = "Missing Configuration"; this->TestResult.Status = cmCTestTestHandler::NOT_RUN; return false; } @@ -482,7 +500,7 @@ bool cmCTestRunTest::StartTest(size_t total) "Unable to find required file: " << file << std::endl); this->TestResult.Output = "Unable to find required file: " + file; this->TestResult.FullCommandLine = ""; - this->TestResult.CompletionStatus = "Not Run"; + this->TestResult.CompletionStatus = "Required Files Missing"; this->TestResult.Status = cmCTestTestHandler::NOT_RUN; return false; } @@ -498,7 +516,7 @@ bool cmCTestRunTest::StartTest(size_t total) "Unable to find executable: " << args[1] << std::endl); this->TestResult.Output = "Unable to find executable: " + args[1]; this->TestResult.FullCommandLine = ""; - this->TestResult.CompletionStatus = "Not Run"; + this->TestResult.CompletionStatus = "Unable to find executable"; this->TestResult.Status = cmCTestTestHandler::NOT_RUN; return false; } diff --git a/Source/CTest/cmCTestRunTest.h b/Source/CTest/cmCTestRunTest.h index ee4630a..d3bb229 100644 --- a/Source/CTest/cmCTestRunTest.h +++ b/Source/CTest/cmCTestRunTest.h @@ -3,7 +3,7 @@ #ifndef cmCTestRunTest_h #define cmCTestRunTest_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <set> #include <stddef.h> diff --git a/Source/CTest/cmCTestSVN.cxx b/Source/CTest/cmCTestSVN.cxx index 410e0d4..0b87281 100644 --- a/Source/CTest/cmCTestSVN.cxx +++ b/Source/CTest/cmCTestSVN.cxx @@ -9,7 +9,7 @@ #include "cmXMLParser.h" #include "cmXMLWriter.h" -#include <cmsys/RegularExpression.hxx> +#include "cmsys/RegularExpression.hxx" #include <map> #include <ostream> #include <stdlib.h> @@ -97,9 +97,11 @@ std::string cmCTestSVN::LoadInfo(SVNInfo& svninfo) return rev; } -void cmCTestSVN::NoteOldRevision() +bool cmCTestSVN::NoteOldRevision() { - this->LoadRepositories(); + if (!this->LoadRepositories()) { + return false; + } std::list<SVNInfo>::iterator itbeg = this->Repositories.begin(); std::list<SVNInfo>::iterator itend = this->Repositories.end(); @@ -116,11 +118,14 @@ void cmCTestSVN::NoteOldRevision() // Set the global old revision to the one of the root this->OldRevision = this->RootInfo->OldRevision; this->PriorRev.Rev = this->OldRevision; + return true; } -void cmCTestSVN::NoteNewRevision() +bool cmCTestSVN::NoteNewRevision() { - this->LoadRepositories(); + if (!this->LoadRepositories()) { + return false; + } std::list<SVNInfo>::iterator itbeg = this->Repositories.begin(); std::list<SVNInfo>::iterator itend = this->Repositories.end(); @@ -153,6 +158,7 @@ void cmCTestSVN::NoteNewRevision() // Set the global new revision to the one of the root this->NewRevision = this->RootInfo->NewRevision; + return true; } void cmCTestSVN::GuessBase(SVNInfo& svninfo, @@ -370,18 +376,20 @@ private: } }; -void cmCTestSVN::LoadRevisions() +bool cmCTestSVN::LoadRevisions() { + bool result = true; // Get revisions for all the external repositories std::list<SVNInfo>::iterator itbeg = this->Repositories.begin(); std::list<SVNInfo>::iterator itend = this->Repositories.end(); for (; itbeg != itend; itbeg++) { SVNInfo& svninfo = *itbeg; - LoadRevisions(svninfo); + result = this->LoadRevisions(svninfo) && result; } + return result; } -void cmCTestSVN::LoadRevisions(SVNInfo& svninfo) +bool cmCTestSVN::LoadRevisions(SVNInfo& svninfo) { // We are interested in every revision included in the update. std::string revs; @@ -400,7 +408,7 @@ void cmCTestSVN::LoadRevisions(SVNInfo& svninfo) svn_log.push_back(svninfo.LocalPath.c_str()); LogParser out(this, "log-out> ", svninfo); OutputLogger err(this->Log, "log-err> "); - this->RunSVNCommand(svn_log, &out, &err); + return this->RunSVNCommand(svn_log, &out, &err); } void cmCTestSVN::DoRevisionSVN(Revision const& revision, @@ -468,7 +476,7 @@ private: } }; -void cmCTestSVN::LoadModifications() +bool cmCTestSVN::LoadModifications() { // Run "svn status" which reports local modifications. std::vector<const char*> svn_status; @@ -476,6 +484,7 @@ void cmCTestSVN::LoadModifications() StatusParser out(this, "status-out> "); OutputLogger err(this->Log, "status-err> "); this->RunSVNCommand(svn_status, &out, &err); + return true; } void cmCTestSVN::WriteXMLGlobal(cmXMLWriter& xml) @@ -521,10 +530,10 @@ private: } }; -void cmCTestSVN::LoadRepositories() +bool cmCTestSVN::LoadRepositories() { if (!this->Repositories.empty()) { - return; + return true; } // Info for root repository @@ -536,7 +545,7 @@ void cmCTestSVN::LoadRepositories() svn_status.push_back("status"); ExternalParser out(this, "external-out> "); OutputLogger err(this->Log, "external-err> "); - this->RunSVNCommand(svn_status, &out, &err); + return this->RunSVNCommand(svn_status, &out, &err); } std::string cmCTestSVN::SVNInfo::BuildLocalPath(std::string const& path) const diff --git a/Source/CTest/cmCTestSVN.h b/Source/CTest/cmCTestSVN.h index c0348c2..d90d387 100644 --- a/Source/CTest/cmCTestSVN.h +++ b/Source/CTest/cmCTestSVN.h @@ -3,7 +3,7 @@ #ifndef cmCTestSVN_h #define cmCTestSVN_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCTestGlobalVC.h" @@ -30,8 +30,8 @@ public: private: // Implement cmCTestVC internal API. void CleanupImpl() CM_OVERRIDE; - void NoteOldRevision() CM_OVERRIDE; - void NoteNewRevision() CM_OVERRIDE; + bool NoteOldRevision() CM_OVERRIDE; + bool NoteNewRevision() CM_OVERRIDE; bool UpdateImpl() CM_OVERRIDE; bool RunSVNCommand(std::vector<char const*> const& parameters, @@ -77,10 +77,10 @@ private: SVNInfo* RootInfo; std::string LoadInfo(SVNInfo& svninfo); - void LoadRepositories(); - void LoadModifications() CM_OVERRIDE; - void LoadRevisions() CM_OVERRIDE; - void LoadRevisions(SVNInfo& svninfo); + bool LoadRepositories(); + bool LoadModifications() CM_OVERRIDE; + bool LoadRevisions() CM_OVERRIDE; + bool LoadRevisions(SVNInfo& svninfo); void GuessBase(SVNInfo& svninfo, std::vector<Change> const& changes); diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index b537242..60e48b6 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -2,8 +2,8 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestScriptHandler.h" -#include <cmsys/Directory.hxx> -#include <cmsys/Process.h> +#include "cmsys/Directory.hxx" +#include "cmsys/Process.h" #include <map> #include <sstream> #include <stdio.h> diff --git a/Source/CTest/cmCTestScriptHandler.h b/Source/CTest/cmCTestScriptHandler.h index 47644be..3070796 100644 --- a/Source/CTest/cmCTestScriptHandler.h +++ b/Source/CTest/cmCTestScriptHandler.h @@ -3,7 +3,7 @@ #ifndef cmCTestScriptHandler_h #define cmCTestScriptHandler_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCTestGenericHandler.h" diff --git a/Source/CTest/cmCTestSleepCommand.h b/Source/CTest/cmCTestSleepCommand.h index 1052f76..a55e9d9 100644 --- a/Source/CTest/cmCTestSleepCommand.h +++ b/Source/CTest/cmCTestSleepCommand.h @@ -3,7 +3,7 @@ #ifndef cmCTestSleepCommand_h #define cmCTestSleepCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCTestCommand.h" diff --git a/Source/CTest/cmCTestStartCommand.h b/Source/CTest/cmCTestStartCommand.h index cc72d0c..26a63fb 100644 --- a/Source/CTest/cmCTestStartCommand.h +++ b/Source/CTest/cmCTestStartCommand.h @@ -3,7 +3,7 @@ #ifndef cmCTestStartCommand_h #define cmCTestStartCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCTestCommand.h" diff --git a/Source/CTest/cmCTestSubmitCommand.h b/Source/CTest/cmCTestSubmitCommand.h index f5b52c1..e566abb 100644 --- a/Source/CTest/cmCTestSubmitCommand.h +++ b/Source/CTest/cmCTestSubmitCommand.h @@ -3,7 +3,7 @@ #ifndef cmCTestSubmitCommand_h #define cmCTestSubmitCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCTest.h" #include "cmCTestHandlerCommand.h" diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 5e5119d..96d1491 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -2,10 +2,10 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestSubmitHandler.h" -#include <cm_curl.h> -#include <cm_jsoncpp_reader.h> -#include <cm_jsoncpp_value.h> -#include <cmsys/Process.h> +#include "cm_curl.h" +#include "cm_jsoncpp_reader.h" +#include "cm_jsoncpp_value.h" +#include "cmsys/Process.h" #include <sstream> #include <stdio.h> #include <stdlib.h> @@ -19,13 +19,14 @@ #include "cmState.h" #include "cmSystemTools.h" #include "cmThirdParty.h" +#include "cmWorkingDirectory.h" #include "cmXMLParser.h" #include "cmake.h" #if defined(CTEST_USE_XMLRPC) #include "cmVersion.h" -#include <cm_xmlrpc.h> -#include <sys/stat.h> +#include "cm_sys_stat.h" +#include "cm_xmlrpc.h" #endif #define SUBMIT_TIMEOUT_IN_SECONDS_DEFAULT 120 @@ -1519,7 +1520,6 @@ int cmCTestSubmitHandler::ProcessHandler() #endif } else if (dropMethod == "scp") { std::string url; - std::string oldWorkingDirectory; if (!this->CTest->GetCTestConfiguration("DropSiteUser").empty()) { url += this->CTest->GetCTestConfiguration("DropSiteUser") + "@"; } @@ -1528,19 +1528,16 @@ int cmCTestSubmitHandler::ProcessHandler() // change to the build directory so that we can uses a relative path // on windows since scp dosn't support "c:" a drive in the path - oldWorkingDirectory = cmSystemTools::GetCurrentWorkingDirectory(); - cmSystemTools::ChangeDirectory(buildDirectory); + cmWorkingDirectory workdir(buildDirectory); if (!this->SubmitUsingSCP(this->CTest->GetCTestConfiguration("ScpCommand"), "Testing/" + this->CTest->GetCurrentTag(), files, prefix, url)) { - cmSystemTools::ChangeDirectory(oldWorkingDirectory); cmCTestLog(this->CTest, ERROR_MESSAGE, " Problems when submitting via SCP" << std::endl); ofs << " Problems when submitting via SCP" << std::endl; return -1; } - cmSystemTools::ChangeDirectory(oldWorkingDirectory); cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " Submission successful" << std::endl, this->Quiet); ofs << " Submission successful" << std::endl; @@ -1550,22 +1547,18 @@ int cmCTestSubmitHandler::ProcessHandler() // change to the build directory so that we can uses a relative path // on windows since scp dosn't support "c:" a drive in the path - std::string oldWorkingDirectory = - cmSystemTools::GetCurrentWorkingDirectory(); - cmSystemTools::ChangeDirectory(buildDirectory); + cmWorkingDirectory workdir(buildDirectory); cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Change directory: " << buildDirectory << std::endl, this->Quiet); if (!this->SubmitUsingCP("Testing/" + this->CTest->GetCurrentTag(), files, prefix, location)) { - cmSystemTools::ChangeDirectory(oldWorkingDirectory); cmCTestLog(this->CTest, ERROR_MESSAGE, " Problems when submitting via CP" << std::endl); ofs << " Problems when submitting via cp" << std::endl; return -1; } - cmSystemTools::ChangeDirectory(oldWorkingDirectory); cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " Submission successful" << std::endl, this->Quiet); ofs << " Submission successful" << std::endl; diff --git a/Source/CTest/cmCTestSubmitHandler.h b/Source/CTest/cmCTestSubmitHandler.h index baaf8af..cf36546 100644 --- a/Source/CTest/cmCTestSubmitHandler.h +++ b/Source/CTest/cmCTestSubmitHandler.h @@ -3,7 +3,7 @@ #ifndef cmCTestSubmitHandler_h #define cmCTestSubmitHandler_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCTest.h" #include "cmCTestGenericHandler.h" diff --git a/Source/CTest/cmCTestTestCommand.cxx b/Source/CTest/cmCTestTestCommand.cxx index a756188..21b1003 100644 --- a/Source/CTest/cmCTestTestCommand.cxx +++ b/Source/CTest/cmCTestTestCommand.cxx @@ -33,10 +33,11 @@ cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler() const char* ctestTimeout = this->Makefile->GetDefinition("CTEST_TEST_TIMEOUT"); - double timeout = this->CTest->GetTimeOut(); + double timeout; if (ctestTimeout) { timeout = atof(ctestTimeout); } else { + timeout = this->CTest->GetTimeOut(); if (timeout <= 0) { // By default use timeout of 10 minutes timeout = 600; diff --git a/Source/CTest/cmCTestTestCommand.h b/Source/CTest/cmCTestTestCommand.h index 3250d93..1893104 100644 --- a/Source/CTest/cmCTestTestCommand.h +++ b/Source/CTest/cmCTestTestCommand.h @@ -3,7 +3,7 @@ #ifndef cmCTestTestCommand_h #define cmCTestTestCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCTestHandlerCommand.h" diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 6175e50..167fecf 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -2,11 +2,11 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestTestHandler.h" +#include "cmsys/Base64.h" +#include "cmsys/Directory.hxx" +#include "cmsys/FStream.hxx" +#include "cmsys/RegularExpression.hxx" #include <algorithm> -#include <cmsys/Base64.h> -#include <cmsys/Directory.hxx> -#include <cmsys/FStream.hxx> -#include <cmsys/RegularExpression.hxx> #include <functional> #include <iomanip> #include <iterator> @@ -27,6 +27,7 @@ #include "cmState.h" #include "cmStateSnapshot.h" #include "cmSystemTools.h" +#include "cmWorkingDirectory.h" #include "cmXMLWriter.h" #include "cm_auto_ptr.hxx" #include "cm_utf8.h" @@ -86,22 +87,24 @@ bool cmCTestSubdirCommand::InitialPass(std::vector<std::string> const& args, // No subdirectory? So what... continue; } - cmSystemTools::ChangeDirectory(fname); - const char* testFilename; - if (cmSystemTools::FileExists("CTestTestfile.cmake")) { - // does the CTestTestfile.cmake exist ? - testFilename = "CTestTestfile.cmake"; - } else if (cmSystemTools::FileExists("DartTestfile.txt")) { - // does the DartTestfile.txt exist ? - testFilename = "DartTestfile.txt"; - } else { - // No CTestTestfile? Who cares... - continue; + bool readit = false; + { + cmWorkingDirectory workdir(fname); + const char* testFilename; + if (cmSystemTools::FileExists("CTestTestfile.cmake")) { + // does the CTestTestfile.cmake exist ? + testFilename = "CTestTestfile.cmake"; + } else if (cmSystemTools::FileExists("DartTestfile.txt")) { + // does the DartTestfile.txt exist ? + testFilename = "DartTestfile.txt"; + } else { + // No CTestTestfile? Who cares... + continue; + } + fname += "/"; + fname += testFilename; + readit = this->Makefile->ReadDependentFile(fname.c_str()); } - fname += "/"; - fname += testFilename; - bool readit = this->Makefile->ReadDependentFile(fname.c_str()); - cmSystemTools::ChangeDirectory(cwd); if (!readit) { std::string m = "Could not find include file: "; m += fname; @@ -109,7 +112,6 @@ bool cmCTestSubdirCommand::InitialPass(std::vector<std::string> const& args, return false; } } - cmSystemTools::ChangeDirectory(cwd); return true; } @@ -149,9 +151,7 @@ bool cmCTestAddSubdirectoryCommand::InitialPass( return false; } - std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); - cmSystemTools::ChangeDirectory(cwd); - std::string fname = cwd; + std::string fname = cmSystemTools::GetCurrentWorkingDirectory(); fname += "/"; fname += args[0]; @@ -159,23 +159,23 @@ bool cmCTestAddSubdirectoryCommand::InitialPass( // No subdirectory? So what... return true; } - cmSystemTools::ChangeDirectory(fname); - const char* testFilename; - if (cmSystemTools::FileExists("CTestTestfile.cmake")) { - // does the CTestTestfile.cmake exist ? - testFilename = "CTestTestfile.cmake"; - } else if (cmSystemTools::FileExists("DartTestfile.txt")) { - // does the DartTestfile.txt exist ? - testFilename = "DartTestfile.txt"; - } else { - // No CTestTestfile? Who cares... - cmSystemTools::ChangeDirectory(cwd); - return true; + bool readit = false; + { + const char* testFilename; + if (cmSystemTools::FileExists("CTestTestfile.cmake")) { + // does the CTestTestfile.cmake exist ? + testFilename = "CTestTestfile.cmake"; + } else if (cmSystemTools::FileExists("DartTestfile.txt")) { + // does the DartTestfile.txt exist ? + testFilename = "DartTestfile.txt"; + } else { + // No CTestTestfile? Who cares... + return true; + } + fname += "/"; + fname += testFilename; + readit = this->Makefile->ReadDependentFile(fname.c_str()); } - fname += "/"; - fname += testFilename; - bool readit = this->Makefile->ReadDependentFile(fname.c_str()); - cmSystemTools::ChangeDirectory(cwd); if (!readit) { std::string m = "Could not find include file: "; m += fname; @@ -487,6 +487,19 @@ int cmCTestTestHandler::ProcessHandler() } } + typedef std::set<cmCTestTestHandler::cmCTestTestResult, + cmCTestTestResultLess> + SetOfTests; + SetOfTests resultsSet(this->TestResults.begin(), this->TestResults.end()); + std::vector<cmCTestTestHandler::cmCTestTestResult> disabledTests; + + for (SetOfTests::iterator ftit = resultsSet.begin(); + ftit != resultsSet.end(); ++ftit) { + if (ftit->CompletionStatus == "Disabled") { + disabledTests.push_back(*ftit); + } + } + float percent = float(passed.size()) * 100.0f / float(total); if (!failed.empty() && percent > 99) { percent = 99; @@ -505,21 +518,33 @@ int cmCTestTestHandler::ProcessHandler() "\nTotal Test time (real) = " << realBuf << "\n", this->Quiet); + if (!disabledTests.empty()) { + cmGeneratedFileStream ofs; + cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl + << "The following tests are disabled and did not run:" + << std::endl); + this->StartLogFile("TestsDisabled", ofs); + + for (std::vector<cmCTestTestHandler::cmCTestTestResult>::iterator dtit = + disabledTests.begin(); + dtit != disabledTests.end(); ++dtit) { + ofs << dtit->TestCount << ":" << dtit->Name << std::endl; + cmCTestLog(this->CTest, HANDLER_OUTPUT, "\t" + << std::setw(3) << dtit->TestCount << " - " << dtit->Name + << std::endl); + } + } + if (!failed.empty()) { cmGeneratedFileStream ofs; cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl << "The following tests FAILED:" << std::endl); this->StartLogFile("TestsFailed", ofs); - typedef std::set<cmCTestTestHandler::cmCTestTestResult, - cmCTestTestResultLess> - SetOfTests; - SetOfTests resultsSet(this->TestResults.begin(), - this->TestResults.end()); - for (SetOfTests::iterator ftit = resultsSet.begin(); ftit != resultsSet.end(); ++ftit) { - if (ftit->Status != cmCTestTestHandler::COMPLETED) { + if (ftit->Status != cmCTestTestHandler::COMPLETED && + ftit->CompletionStatus != "Disabled") { ofs << ftit->TestCount << ":" << ftit->Name << std::endl; cmCTestLog( this->CTest, HANDLER_OUTPUT, "\t" @@ -841,6 +866,11 @@ void cmCTestTestHandler::UpdateForFixtures(ListOfTests& tests) const size_t fixtureTestsAdded = 0; std::set<std::string> addedFixtures; for (size_t i = 0; i < tests.size(); ++i) { + // Skip disabled tests + if (tests[i].Disabled) { + continue; + } + // There are two things to do for each test: // 1. For every fixture required by this test, record that fixture as // being required and create dependencies on that fixture's setup @@ -1200,6 +1230,7 @@ void cmCTestTestHandler::GenerateDartOutput(cmXMLWriter& xml) cmCTestTestResult* result = &this->TestResults[cc]; this->WriteTestResultHeader(xml, result); xml.StartElement("Results"); + if (result->Status != cmCTestTestHandler::NOT_RUN) { if (result->Status != cmCTestTestHandler::COMPLETED || result->ReturnValue) { @@ -1208,6 +1239,7 @@ void cmCTestTestHandler::GenerateDartOutput(cmXMLWriter& xml) xml.Attribute("name", "Exit Code"); xml.Element("Value", this->GetTestStatus(result->Status)); xml.EndElement(); // NamedMeasurement + xml.StartElement("NamedMeasurement"); xml.Attribute("type", "text/string"); xml.Attribute("name", "Exit Value"); @@ -1222,8 +1254,7 @@ void cmCTestTestHandler::GenerateDartOutput(cmXMLWriter& xml) xml.EndElement(); // NamedMeasurement if (!result->Reason.empty()) { const char* reasonType = "Pass Reason"; - if (result->Status != cmCTestTestHandler::COMPLETED && - result->Status != cmCTestTestHandler::NOT_RUN) { + if (result->Status != cmCTestTestHandler::COMPLETED) { reasonType = "Fail Reason"; } xml.StartElement("NamedMeasurement"); @@ -1232,12 +1263,14 @@ void cmCTestTestHandler::GenerateDartOutput(cmXMLWriter& xml) xml.Element("Value", result->Reason); xml.EndElement(); // NamedMeasurement } - xml.StartElement("NamedMeasurement"); - xml.Attribute("type", "text/string"); - xml.Attribute("name", "Completion Status"); - xml.Element("Value", result->CompletionStatus); - xml.EndElement(); // NamedMeasurement } + + xml.StartElement("NamedMeasurement"); + xml.Attribute("type", "text/string"); + xml.Attribute("name", "Completion Status"); + xml.Element("Value", result->CompletionStatus); + xml.EndElement(); // NamedMeasurement + xml.StartElement("NamedMeasurement"); xml.Attribute("type", "text/string"); xml.Attribute("name", "Command Line"); @@ -1600,10 +1633,10 @@ void cmCTestTestHandler::UseExcludeRegExp() const char* cmCTestTestHandler::GetTestStatus(int status) { - static const char statuses[][100] = { - "Not Run", "Timeout", "SEGFAULT", "ILLEGAL", "INTERRUPT", - "NUMERICAL", "OTHER_FAULT", "Failed", "BAD_COMMAND", "Completed" - }; + static const char* statuses[] = { "Not Run", "Timeout", "SEGFAULT", + "ILLEGAL", "INTERRUPT", "NUMERICAL", + "OTHER_FAULT", "Failed", "BAD_COMMAND", + "Completed" }; if (status < cmCTestTestHandler::NOT_RUN || status > cmCTestTestHandler::COMPLETED) { @@ -2000,6 +2033,9 @@ bool cmCTestTestHandler::SetTestsProperties( if (key == "WILL_FAIL") { rtit->WillFail = cmSystemTools::IsOn(val.c_str()); } + if (key == "DISABLED") { + rtit->Disabled = cmSystemTools::IsOn(val.c_str()); + } if (key == "ATTACHED_FILES") { cmSystemTools::ExpandListArgument(val, rtit->AttachedFiles); } @@ -2178,6 +2214,7 @@ bool cmCTestTestHandler::AddTest(const std::vector<std::string>& args) test.IsInBasedOnREOptions = true; test.WillFail = false; + test.Disabled = false; test.RunSerial = false; test.Timeout = 0; test.ExplicitTimeout = false; diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h index 5b07e98..3700f8a 100644 --- a/Source/CTest/cmCTestTestHandler.h +++ b/Source/CTest/cmCTestTestHandler.h @@ -3,11 +3,11 @@ #ifndef cmCTestTestHandler_h #define cmCTestTestHandler_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCTestGenericHandler.h" -#include <cmsys/RegularExpression.hxx> +#include "cmsys/RegularExpression.hxx" #include <iosfwd> #include <map> #include <set> @@ -114,6 +114,7 @@ public: std::map<std::string, std::string> Measurements; bool IsInBasedOnREOptions; bool WillFail; + bool Disabled; float Cost; int PreviousRuns; bool RunSerial; diff --git a/Source/CTest/cmCTestUpdateCommand.h b/Source/CTest/cmCTestUpdateCommand.h index 5761f50..3b8f0a6 100644 --- a/Source/CTest/cmCTestUpdateCommand.h +++ b/Source/CTest/cmCTestUpdateCommand.h @@ -3,7 +3,7 @@ #ifndef cmCTestUpdateCommand_h #define cmCTestUpdateCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCTestHandlerCommand.h" diff --git a/Source/CTest/cmCTestUpdateHandler.cxx b/Source/CTest/cmCTestUpdateHandler.cxx index 0998d59..e08a9b7 100644 --- a/Source/CTest/cmCTestUpdateHandler.cxx +++ b/Source/CTest/cmCTestUpdateHandler.cxx @@ -16,7 +16,7 @@ #include "cmVersion.h" #include "cmXMLWriter.h" -#include <cm_auto_ptr.hxx> +#include "cm_auto_ptr.hxx" #include <sstream> static const char* cmCTestUpdateHandlerUpdateStrings[] = { @@ -198,7 +198,7 @@ int cmCTestUpdateHandler::ProcessHandler() xml.Element("UpdateType", cmCTestUpdateHandlerUpdateToString(this->UpdateType)); - vc->WriteXML(xml); + bool loadedMods = vc->WriteXML(xml); int localModifications = 0; int numUpdated = vc->GetPathCount(cmCTestVC::PathUpdated); @@ -246,7 +246,7 @@ int cmCTestUpdateHandler::ProcessHandler() xml.EndElement(); // UpdateReturnStatus xml.EndElement(); // Update xml.EndDocument(); - return updated ? numUpdated : -1; + return updated && loadedMods ? numUpdated : -1; } int cmCTestUpdateHandler::DetectVCS(const char* dir) diff --git a/Source/CTest/cmCTestUpdateHandler.h b/Source/CTest/cmCTestUpdateHandler.h index 87781e8..0cd2844 100644 --- a/Source/CTest/cmCTestUpdateHandler.h +++ b/Source/CTest/cmCTestUpdateHandler.h @@ -3,7 +3,7 @@ #ifndef cmCTestUpdateHandler_h #define cmCTestUpdateHandler_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCTestGenericHandler.h" diff --git a/Source/CTest/cmCTestUploadCommand.h b/Source/CTest/cmCTestUploadCommand.h index 474f699..6e72179 100644 --- a/Source/CTest/cmCTestUploadCommand.h +++ b/Source/CTest/cmCTestUploadCommand.h @@ -3,7 +3,7 @@ #ifndef cmCTestUploadCommand_h #define cmCTestUploadCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCTest.h" #include "cmCTestHandlerCommand.h" diff --git a/Source/CTest/cmCTestUploadHandler.h b/Source/CTest/cmCTestUploadHandler.h index 77c2aec..1e8d3c8 100644 --- a/Source/CTest/cmCTestUploadHandler.h +++ b/Source/CTest/cmCTestUploadHandler.h @@ -3,7 +3,7 @@ #ifndef cmCTestUploadHandler_h #define cmCTestUploadHandler_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCTest.h" #include "cmCTestGenericHandler.h" diff --git a/Source/CTest/cmCTestVC.cxx b/Source/CTest/cmCTestVC.cxx index 444c43d..fb2742e 100644 --- a/Source/CTest/cmCTestVC.cxx +++ b/Source/CTest/cmCTestVC.cxx @@ -6,7 +6,7 @@ #include "cmSystemTools.h" #include "cmXMLWriter.h" -#include <cmsys/Process.h> +#include "cmsys/Process.h" #include <sstream> #include <stdio.h> #include <time.h> @@ -147,23 +147,25 @@ bool cmCTestVC::Update() // just note the current version and finish if (!cmSystemTools::IsOn( this->CTest->GetCTestConfiguration("UpdateVersionOnly").c_str())) { - this->NoteOldRevision(); + result = this->NoteOldRevision() && result; this->Log << "--- Begin Update ---\n"; - result = this->UpdateImpl(); + result = this->UpdateImpl() && result; this->Log << "--- End Update ---\n"; } - this->NoteNewRevision(); + result = this->NoteNewRevision() && result; return result; } -void cmCTestVC::NoteOldRevision() +bool cmCTestVC::NoteOldRevision() { // We do nothing by default. + return true; } -void cmCTestVC::NoteNewRevision() +bool cmCTestVC::NoteNewRevision() { // We do nothing by default. + return true; } bool cmCTestVC::UpdateImpl() diff --git a/Source/CTest/cmCTestVC.h b/Source/CTest/cmCTestVC.h index 2681ba0..6400bcd 100644 --- a/Source/CTest/cmCTestVC.h +++ b/Source/CTest/cmCTestVC.h @@ -3,7 +3,7 @@ #ifndef cmCTestVC_h #define cmCTestVC_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <iosfwd> #include <string> @@ -67,9 +67,9 @@ public: protected: // Internal API to be implemented by subclasses. virtual void CleanupImpl(); - virtual void NoteOldRevision(); + virtual bool NoteOldRevision(); virtual bool UpdateImpl(); - virtual void NoteNewRevision(); + virtual bool NoteNewRevision(); virtual bool WriteXMLUpdates(cmXMLWriter& xml); #if defined(__SUNPRO_CC) && __SUNPRO_CC <= 0x510 diff --git a/Source/CTest/cmParseBlanketJSCoverage.cxx b/Source/CTest/cmParseBlanketJSCoverage.cxx index 6fa982e..54bb422 100644 --- a/Source/CTest/cmParseBlanketJSCoverage.cxx +++ b/Source/CTest/cmParseBlanketJSCoverage.cxx @@ -6,7 +6,7 @@ #include "cmCTestCoverageHandler.h" #include "cmSystemTools.h" -#include <cmsys/FStream.hxx> +#include "cmsys/FStream.hxx" #include <stdio.h> #include <stdlib.h> diff --git a/Source/CTest/cmParseBlanketJSCoverage.h b/Source/CTest/cmParseBlanketJSCoverage.h index 660590d..696121f 100644 --- a/Source/CTest/cmParseBlanketJSCoverage.h +++ b/Source/CTest/cmParseBlanketJSCoverage.h @@ -3,7 +3,7 @@ #ifndef cmParseBlanketJSCoverage_h #define cmParseBlanketJSCoverage_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/CTest/cmParseCacheCoverage.cxx b/Source/CTest/cmParseCacheCoverage.cxx index 23176b5..629010c 100644 --- a/Source/CTest/cmParseCacheCoverage.cxx +++ b/Source/CTest/cmParseCacheCoverage.cxx @@ -4,8 +4,8 @@ #include "cmCTestCoverageHandler.h" #include "cmSystemTools.h" -#include <cmsys/Directory.hxx> -#include <cmsys/FStream.hxx> +#include "cmsys/Directory.hxx" +#include "cmsys/FStream.hxx" #include <map> #include <stdio.h> #include <stdlib.h> diff --git a/Source/CTest/cmParseCacheCoverage.h b/Source/CTest/cmParseCacheCoverage.h index 645d710..005d272 100644 --- a/Source/CTest/cmParseCacheCoverage.h +++ b/Source/CTest/cmParseCacheCoverage.h @@ -3,7 +3,7 @@ #ifndef cmParseCacheCoverage_h #define cmParseCacheCoverage_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmParseMumpsCoverage.h" diff --git a/Source/CTest/cmParseCoberturaCoverage.cxx b/Source/CTest/cmParseCoberturaCoverage.cxx index db17748..ba55cd7 100644 --- a/Source/CTest/cmParseCoberturaCoverage.cxx +++ b/Source/CTest/cmParseCoberturaCoverage.cxx @@ -5,8 +5,8 @@ #include "cmSystemTools.h" #include "cmXMLParser.h" -#include <cmConfigure.h> -#include <cmsys/FStream.hxx> +#include "cmConfigure.h" +#include "cmsys/FStream.hxx" #include <stdlib.h> #include <string.h> diff --git a/Source/CTest/cmParseCoberturaCoverage.h b/Source/CTest/cmParseCoberturaCoverage.h index 077eb80..cb6d097 100644 --- a/Source/CTest/cmParseCoberturaCoverage.h +++ b/Source/CTest/cmParseCoberturaCoverage.h @@ -3,7 +3,7 @@ #ifndef cmParseCoberturaCoverage_h #define cmParseCoberturaCoverage_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/CTest/cmParseDelphiCoverage.cxx b/Source/CTest/cmParseDelphiCoverage.cxx index 7fe91f4..9cdd50b 100644 --- a/Source/CTest/cmParseDelphiCoverage.cxx +++ b/Source/CTest/cmParseDelphiCoverage.cxx @@ -4,8 +4,8 @@ #include "cmCTestCoverageHandler.h" #include "cmSystemTools.h" -#include <cmsys/FStream.hxx> -#include <cmsys/Glob.hxx> +#include "cmsys/FStream.hxx" +#include "cmsys/Glob.hxx" #include <stdio.h> #include <stdlib.h> @@ -46,7 +46,8 @@ public: beginSet.push_back("begin"); coverageVector.push_back(-1); continue; - } else if (line.find('{') != line.npos) { + } + if (line.find('{') != line.npos) { blockComFlag = true; } else if (line.find('}') != line.npos) { blockComFlag = false; diff --git a/Source/CTest/cmParseDelphiCoverage.h b/Source/CTest/cmParseDelphiCoverage.h index 278fbeb..1b37405 100644 --- a/Source/CTest/cmParseDelphiCoverage.h +++ b/Source/CTest/cmParseDelphiCoverage.h @@ -3,7 +3,7 @@ #ifndef cmParseDelphiCoverage_h #define cmParseDelphiCoverage_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/CTest/cmParseGTMCoverage.cxx b/Source/CTest/cmParseGTMCoverage.cxx index 214ce5a..15ef059 100644 --- a/Source/CTest/cmParseGTMCoverage.cxx +++ b/Source/CTest/cmParseGTMCoverage.cxx @@ -4,8 +4,8 @@ #include "cmCTestCoverageHandler.h" #include "cmSystemTools.h" -#include <cmsys/Directory.hxx> -#include <cmsys/FStream.hxx> +#include "cmsys/Directory.hxx" +#include "cmsys/FStream.hxx" #include <map> #include <stdio.h> #include <stdlib.h> diff --git a/Source/CTest/cmParseGTMCoverage.h b/Source/CTest/cmParseGTMCoverage.h index 34721ff..c4949d4 100644 --- a/Source/CTest/cmParseGTMCoverage.h +++ b/Source/CTest/cmParseGTMCoverage.h @@ -3,7 +3,7 @@ #ifndef cmParseGTMCoverage_h #define cmParseGTMCoverage_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmParseMumpsCoverage.h" diff --git a/Source/CTest/cmParseJacocoCoverage.cxx b/Source/CTest/cmParseJacocoCoverage.cxx index 0e36c01..d15864a 100644 --- a/Source/CTest/cmParseJacocoCoverage.cxx +++ b/Source/CTest/cmParseJacocoCoverage.cxx @@ -1,15 +1,15 @@ #include "cmParseJacocoCoverage.h" -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCTest.h" #include "cmCTestCoverageHandler.h" #include "cmSystemTools.h" #include "cmXMLParser.h" -#include <cmsys/Directory.hxx> -#include <cmsys/FStream.hxx> -#include <cmsys/Glob.hxx> +#include "cmsys/Directory.hxx" +#include "cmsys/FStream.hxx" +#include "cmsys/Glob.hxx" #include <stdlib.h> #include <string.h> diff --git a/Source/CTest/cmParseJacocoCoverage.h b/Source/CTest/cmParseJacocoCoverage.h index 04f1949..f2aec6d 100644 --- a/Source/CTest/cmParseJacocoCoverage.h +++ b/Source/CTest/cmParseJacocoCoverage.h @@ -3,7 +3,7 @@ #ifndef cmParseJacocoCoverage_h #define cmParseJacocoCoverage_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <map> #include <string> diff --git a/Source/CTest/cmParseMumpsCoverage.cxx b/Source/CTest/cmParseMumpsCoverage.cxx index ab8be76..eb29f55 100644 --- a/Source/CTest/cmParseMumpsCoverage.cxx +++ b/Source/CTest/cmParseMumpsCoverage.cxx @@ -4,9 +4,9 @@ #include "cmCTestCoverageHandler.h" #include "cmSystemTools.h" -#include <cmConfigure.h> -#include <cmsys/FStream.hxx> -#include <cmsys/Glob.hxx> +#include "cmConfigure.h" +#include "cmsys/FStream.hxx" +#include "cmsys/Glob.hxx" #include <map> #include <string> #include <utility> diff --git a/Source/CTest/cmParseMumpsCoverage.h b/Source/CTest/cmParseMumpsCoverage.h index c4ed175..2c54495 100644 --- a/Source/CTest/cmParseMumpsCoverage.h +++ b/Source/CTest/cmParseMumpsCoverage.h @@ -3,7 +3,7 @@ #ifndef cmParseMumpsCoverage_h #define cmParseMumpsCoverage_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <map> #include <string> diff --git a/Source/CTest/cmParsePHPCoverage.cxx b/Source/CTest/cmParsePHPCoverage.cxx index d8bb31b..761ebec 100644 --- a/Source/CTest/cmParsePHPCoverage.cxx +++ b/Source/CTest/cmParsePHPCoverage.cxx @@ -4,8 +4,8 @@ #include "cmCTestCoverageHandler.h" #include "cmSystemTools.h" -#include <cmsys/Directory.hxx> -#include <cmsys/FStream.hxx> +#include "cmsys/Directory.hxx" +#include "cmsys/FStream.hxx" #include <stdlib.h> #include <string.h> diff --git a/Source/CTest/cmParsePHPCoverage.h b/Source/CTest/cmParsePHPCoverage.h index 4bcad6d..ff0e636 100644 --- a/Source/CTest/cmParsePHPCoverage.h +++ b/Source/CTest/cmParsePHPCoverage.h @@ -3,7 +3,7 @@ #ifndef cmParsePHPCoverage_h #define cmParsePHPCoverage_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <iosfwd> #include <string> diff --git a/Source/CTest/cmProcess.cxx b/Source/CTest/cmProcess.cxx index 32ffa6b..f4ec6da 100644 --- a/Source/CTest/cmProcess.cxx +++ b/Source/CTest/cmProcess.cxx @@ -2,9 +2,9 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmProcess.h" -#include <cmConfigure.h> -#include <cmProcessOutput.h> -#include <cmSystemTools.h> +#include "cmConfigure.h" +#include "cmProcessOutput.h" +#include "cmSystemTools.h" #include <iostream> cmProcess::cmProcess() diff --git a/Source/CTest/cmProcess.h b/Source/CTest/cmProcess.h index 9d201d1..86e905a 100644 --- a/Source/CTest/cmProcess.h +++ b/Source/CTest/cmProcess.h @@ -3,9 +3,9 @@ #ifndef cmProcess_h #define cmProcess_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep -#include <cmsys/Process.h> +#include "cmsys/Process.h" #include <string> #include <vector> diff --git a/Source/Checks/cm_cxx_eq_delete.cxx b/Source/Checks/cm_cxx_eq_delete.cxx new file mode 100644 index 0000000..809e4cf --- /dev/null +++ b/Source/Checks/cm_cxx_eq_delete.cxx @@ -0,0 +1,14 @@ +struct Foo +{ + Foo() {} + ~Foo() {} + Foo(Foo const&) = delete; + Foo& operator=(Foo const&) = delete; + int test() const { return 0; } +}; + +int main() +{ + Foo const foo; + return foo.test(); +} diff --git a/Source/Checks/cm_cxx_features.cmake b/Source/Checks/cm_cxx_features.cmake index 80c9f3b..cd58539 100644 --- a/Source/Checks/cm_cxx_features.cmake +++ b/Source/Checks/cm_cxx_features.cmake @@ -33,6 +33,7 @@ endfunction() if(CMAKE_CXX_STANDARD) cm_check_cxx_feature(auto_ptr) + cm_check_cxx_feature(eq_delete) cm_check_cxx_feature(make_unique) if(CMake_HAVE_CXX_MAKE_UNIQUE) set(CMake_HAVE_CXX_UNIQUE_PTR 1) diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx index ff8e010..1698a84 100644 --- a/Source/CursesDialog/ccmake.cxx +++ b/Source/CursesDialog/ccmake.cxx @@ -1,6 +1,6 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCursesForm.h" #include "cmCursesMainForm.h" @@ -10,7 +10,7 @@ #include "cmSystemTools.h" #include "cmake.h" -#include <cmsys/Encoding.hxx> +#include "cmsys/Encoding.hxx" #include <iostream> #include <signal.h> #include <string.h> diff --git a/Source/CursesDialog/cmCursesBoolWidget.h b/Source/CursesDialog/cmCursesBoolWidget.h index f79f7e8..45f01aa 100644 --- a/Source/CursesDialog/cmCursesBoolWidget.h +++ b/Source/CursesDialog/cmCursesBoolWidget.h @@ -3,7 +3,7 @@ #ifndef cmCursesBoolWidget_h #define cmCursesBoolWidget_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCursesStandardIncludes.h" #include "cmCursesWidget.h" diff --git a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx index 5539fbe..cdde1a3 100644 --- a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx +++ b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx @@ -14,8 +14,8 @@ #include "cmSystemTools.h" #include "cmake.h" +#include "cmConfigure.h" #include <assert.h> -#include <cmConfigure.h> #include <vector> cmCursesCacheEntryComposite::cmCursesCacheEntryComposite( diff --git a/Source/CursesDialog/cmCursesCacheEntryComposite.h b/Source/CursesDialog/cmCursesCacheEntryComposite.h index 59a1fd7..1dbcfa4 100644 --- a/Source/CursesDialog/cmCursesCacheEntryComposite.h +++ b/Source/CursesDialog/cmCursesCacheEntryComposite.h @@ -3,7 +3,7 @@ #ifndef cmCursesCacheEntryComposite_h #define cmCursesCacheEntryComposite_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <string> diff --git a/Source/CursesDialog/cmCursesDummyWidget.h b/Source/CursesDialog/cmCursesDummyWidget.h index fe43de5..0381f25 100644 --- a/Source/CursesDialog/cmCursesDummyWidget.h +++ b/Source/CursesDialog/cmCursesDummyWidget.h @@ -3,7 +3,7 @@ #ifndef cmCursesDummyWidget_h #define cmCursesDummyWidget_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCursesStandardIncludes.h" #include "cmCursesWidget.h" diff --git a/Source/CursesDialog/cmCursesFilePathWidget.h b/Source/CursesDialog/cmCursesFilePathWidget.h index 7df7f00..b4c04cb 100644 --- a/Source/CursesDialog/cmCursesFilePathWidget.h +++ b/Source/CursesDialog/cmCursesFilePathWidget.h @@ -3,7 +3,7 @@ #ifndef cmCursesFilePathWidget_h #define cmCursesFilePathWidget_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCursesPathWidget.h" diff --git a/Source/CursesDialog/cmCursesForm.cxx b/Source/CursesDialog/cmCursesForm.cxx index 0eb16cb..12e5d75 100644 --- a/Source/CursesDialog/cmCursesForm.cxx +++ b/Source/CursesDialog/cmCursesForm.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCursesForm.h" -#include <cmConfigure.h> +#include "cmConfigure.h" cmsys::ofstream cmCursesForm::DebugFile; bool cmCursesForm::Debug = false; diff --git a/Source/CursesDialog/cmCursesForm.h b/Source/CursesDialog/cmCursesForm.h index 85a80c2..7eb94a8 100644 --- a/Source/CursesDialog/cmCursesForm.h +++ b/Source/CursesDialog/cmCursesForm.h @@ -3,11 +3,11 @@ #ifndef cmCursesForm_h #define cmCursesForm_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCursesStandardIncludes.h" -#include <cmsys/FStream.hxx> +#include "cmsys/FStream.hxx" class cmCursesForm { diff --git a/Source/CursesDialog/cmCursesLabelWidget.h b/Source/CursesDialog/cmCursesLabelWidget.h index 4d63f48..a0de4c6 100644 --- a/Source/CursesDialog/cmCursesLabelWidget.h +++ b/Source/CursesDialog/cmCursesLabelWidget.h @@ -3,7 +3,7 @@ #ifndef cmCursesLabelWidget_h #define cmCursesLabelWidget_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCursesStandardIncludes.h" #include "cmCursesWidget.h" diff --git a/Source/CursesDialog/cmCursesLongMessageForm.cxx b/Source/CursesDialog/cmCursesLongMessageForm.cxx index d299547..7fb065d 100644 --- a/Source/CursesDialog/cmCursesLongMessageForm.cxx +++ b/Source/CursesDialog/cmCursesLongMessageForm.cxx @@ -159,7 +159,8 @@ void cmCursesLongMessageForm::HandleInput() // quit if (key == 'o' || key == 'e') { break; - } else if (key == KEY_DOWN || key == ctrl('n')) { + } + if (key == KEY_DOWN || key == ctrl('n')) { form_driver(this->Form, REQ_SCR_FLINE); } else if (key == KEY_UP || key == ctrl('p')) { form_driver(this->Form, REQ_SCR_BLINE); diff --git a/Source/CursesDialog/cmCursesLongMessageForm.h b/Source/CursesDialog/cmCursesLongMessageForm.h index e9eae7c..ab49c07 100644 --- a/Source/CursesDialog/cmCursesLongMessageForm.h +++ b/Source/CursesDialog/cmCursesLongMessageForm.h @@ -3,7 +3,7 @@ #ifndef cmCursesLongMessageForm_h #define cmCursesLongMessageForm_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCursesForm.h" #include "cmCursesStandardIncludes.h" diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index 939c736..ca824c0 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -764,9 +764,8 @@ void cmCursesMainForm::HandleInput() // quit if (key == 'q') { break; - } else { - continue; } + continue; } currentField = current_field(this->Form); @@ -826,7 +825,7 @@ void cmCursesMainForm::HandleInput() // (index always corresponds to the value field) // scroll down with arrow down, ctrl+n (emacs binding), or j (vim // binding) - else if (key == KEY_DOWN || key == ctrl('n') || key == 'j') { + if (key == KEY_DOWN || key == ctrl('n') || key == 'j') { FIELD* cur = current_field(this->Form); size_t findex = field_index(cur); if (findex == 3 * this->NumberOfVisibleEntries - 1) { diff --git a/Source/CursesDialog/cmCursesMainForm.h b/Source/CursesDialog/cmCursesMainForm.h index d891ea0..b91211e 100644 --- a/Source/CursesDialog/cmCursesMainForm.h +++ b/Source/CursesDialog/cmCursesMainForm.h @@ -3,7 +3,7 @@ #ifndef cmCursesMainForm_h #define cmCursesMainForm_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCursesForm.h" #include "cmCursesStandardIncludes.h" diff --git a/Source/CursesDialog/cmCursesOptionsWidget.h b/Source/CursesDialog/cmCursesOptionsWidget.h index 75065a2..4b2e8b4 100644 --- a/Source/CursesDialog/cmCursesOptionsWidget.h +++ b/Source/CursesDialog/cmCursesOptionsWidget.h @@ -3,7 +3,7 @@ #ifndef cmCursesOptionsWidget_h #define cmCursesOptionsWidget_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCursesStandardIncludes.h" #include "cmCursesWidget.h" diff --git a/Source/CursesDialog/cmCursesPathWidget.h b/Source/CursesDialog/cmCursesPathWidget.h index 63ed05b..097eeca 100644 --- a/Source/CursesDialog/cmCursesPathWidget.h +++ b/Source/CursesDialog/cmCursesPathWidget.h @@ -3,7 +3,7 @@ #ifndef cmCursesPathWidget_h #define cmCursesPathWidget_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCursesStandardIncludes.h" #include "cmCursesStringWidget.h" diff --git a/Source/CursesDialog/cmCursesStandardIncludes.h b/Source/CursesDialog/cmCursesStandardIncludes.h index 7818e3e..5c59504 100644 --- a/Source/CursesDialog/cmCursesStandardIncludes.h +++ b/Source/CursesDialog/cmCursesStandardIncludes.h @@ -3,7 +3,7 @@ #ifndef cmCursesStandardIncludes_h #define cmCursesStandardIncludes_h -#include <cmConfigure.h> +#include "cmConfigure.h" #if defined(__hpux) #define _BOOL_DEFINED diff --git a/Source/CursesDialog/cmCursesStringWidget.h b/Source/CursesDialog/cmCursesStringWidget.h index b3c1089..c07bfce 100644 --- a/Source/CursesDialog/cmCursesStringWidget.h +++ b/Source/CursesDialog/cmCursesStringWidget.h @@ -3,7 +3,7 @@ #ifndef cmCursesStringWidget_h #define cmCursesStringWidget_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCursesStandardIncludes.h" #include "cmCursesWidget.h" diff --git a/Source/CursesDialog/cmCursesWidget.cxx b/Source/CursesDialog/cmCursesWidget.cxx index a9918f7..229a050 100644 --- a/Source/CursesDialog/cmCursesWidget.cxx +++ b/Source/CursesDialog/cmCursesWidget.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCursesWidget.h" -#include <cmConfigure.h> +#include "cmConfigure.h" cmCursesWidget::cmCursesWidget(int width, int height, int left, int top) { diff --git a/Source/CursesDialog/cmCursesWidget.h b/Source/CursesDialog/cmCursesWidget.h index d226dd7..5ce8a75 100644 --- a/Source/CursesDialog/cmCursesWidget.h +++ b/Source/CursesDialog/cmCursesWidget.h @@ -3,7 +3,7 @@ #ifndef cmCursesWidget_h #define cmCursesWidget_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCursesStandardIncludes.h" #include "cmStateTypes.h" diff --git a/Source/CursesDialog/form/form.h b/Source/CursesDialog/form/form.h index b65a3ca..39ed75a 100644 --- a/Source/CursesDialog/form/form.h +++ b/Source/CursesDialog/form/form.h @@ -33,7 +33,7 @@ #ifndef FORM_H #define FORM_H -#include <cmFormConfigure.h> +#include "cmFormConfigure.h" /* figure out which curses.h to include */ # if defined(CURSES_HAVE_NCURSES_H) diff --git a/Source/Modules/FindLibUV.cmake b/Source/Modules/FindLibUV.cmake index b8cb365..ba13d75 100644 --- a/Source/Modules/FindLibUV.cmake +++ b/Source/Modules/FindLibUV.cmake @@ -49,7 +49,7 @@ They may be set by end users to point at libuv components. #----------------------------------------------------------------------------- find_library(LibUV_LIBRARY - NAMES uv + NAMES uv libuv ) mark_as_advanced(LibUV_LIBRARY) diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index 10fd718..2e11a8a 100644 --- a/Source/QtDialog/CMakeLists.txt +++ b/Source/QtDialog/CMakeLists.txt @@ -198,7 +198,7 @@ if(UNIX AND NOT APPLE) # install a desktop file so CMake appears in the application start menu # with an icon - install(FILES CMake.desktop + install(FILES cmake-gui.desktop DESTINATION "${CMAKE_XDGDATA_DIR}/applications" ${COMPONENT}) install(FILES cmakecache.xml diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx index 5e03c39..b955d77 100644 --- a/Source/QtDialog/CMakeSetup.cxx +++ b/Source/QtDialog/CMakeSetup.cxx @@ -8,6 +8,9 @@ #include "cmDocumentationEntry.h" #include "cmVersion.h" #include "cmake.h" +#include "cmsys/CommandLineArguments.hxx" +#include "cmsys/Encoding.hxx" +#include "cmsys/SystemTools.hxx" #include <QApplication> #include <QDir> #include <QLocale> @@ -15,9 +18,6 @@ #include <QTextCodec> #include <QTranslator> #include <QtPlugin> -#include <cmsys/CommandLineArguments.hxx> -#include <cmsys/Encoding.hxx> -#include <cmsys/SystemTools.hxx> #include <iostream> #include "cmSystemTools.h" // IWYU pragma: keep @@ -184,9 +184,9 @@ int main(int argc, char** argv) } #if defined(Q_OS_MAC) +#include "cm_sys_stat.h" #include <errno.h> #include <string.h> -#include <sys/stat.h> #include <unistd.h> static bool cmOSXInstall(std::string const& dir, std::string const& tool) { diff --git a/Source/QtDialog/Compilers.h b/Source/QtDialog/Compilers.h index 276e2a5..6c8c8f5 100644 --- a/Source/QtDialog/Compilers.h +++ b/Source/QtDialog/Compilers.h @@ -3,7 +3,7 @@ #ifndef COMPILERS_HPP #define COMPILERS_HPP -#include <cmConfigure.h> +#include "cmConfigure.h" #include <QWidget> diff --git a/Source/QtDialog/QCMake.h b/Source/QtDialog/QCMake.h index 12f6037..e14cdf2 100644 --- a/Source/QtDialog/QCMake.h +++ b/Source/QtDialog/QCMake.h @@ -3,7 +3,7 @@ #ifndef QCMake_h #define QCMake_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmake.h" diff --git a/Source/QtDialog/QCMakeWidgets.h b/Source/QtDialog/QCMakeWidgets.h index 0db810c..1ec666f 100644 --- a/Source/QtDialog/QCMakeWidgets.h +++ b/Source/QtDialog/QCMakeWidgets.h @@ -3,7 +3,7 @@ #ifndef QCMakeWidgets_h #define QCMakeWidgets_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <QComboBox> #include <QCompleter> diff --git a/Source/QtDialog/RegexExplorer.h b/Source/QtDialog/RegexExplorer.h index caef975..8679892 100644 --- a/Source/QtDialog/RegexExplorer.h +++ b/Source/QtDialog/RegexExplorer.h @@ -3,8 +3,8 @@ #ifndef RegexExplorer_h #define RegexExplorer_h +#include "cmsys/RegularExpression.hxx" #include <QDialog> -#include <cmsys/RegularExpression.hxx> #include <string> #include "ui_RegexExplorer.h" diff --git a/Source/QtDialog/CMake.desktop b/Source/QtDialog/cmake-gui.desktop index 842091f..842091f 100644 --- a/Source/QtDialog/CMake.desktop +++ b/Source/QtDialog/cmake-gui.desktop diff --git a/Source/bindexplib.cxx b/Source/bindexplib.cxx index eded883..6026a57 100644 --- a/Source/bindexplib.cxx +++ b/Source/bindexplib.cxx @@ -63,86 +63,93 @@ */ #include "bindexplib.h" -#include <cmsys/Encoding.hxx> -#include <fstream> +#include "cmsys/Encoding.hxx" +#include "cmsys/FStream.hxx" #include <iostream> #include <windows.h> -typedef struct cmANON_OBJECT_HEADER_BIGOBJ { - /* same as ANON_OBJECT_HEADER_V2 */ - WORD Sig1; // Must be IMAGE_FILE_MACHINE_UNKNOWN - WORD Sig2; // Must be 0xffff - WORD Version; // >= 2 (implies the Flags field is present) - WORD Machine; // Actual machine - IMAGE_FILE_MACHINE_xxx - DWORD TimeDateStamp; - CLSID ClassID; // {D1BAA1C7-BAEE-4ba9-AF20-FAF66AA4DCB8} - DWORD SizeOfData; // Size of data that follows the header - DWORD Flags; // 0x1 -> contains metadata - DWORD MetaDataSize; // Size of CLR metadata - DWORD MetaDataOffset; // Offset of CLR metadata +#ifndef IMAGE_FILE_MACHINE_ARMNT +#define IMAGE_FILE_MACHINE_ARMNT 0x01c4 +#endif - /* bigobj specifics */ - DWORD NumberOfSections; // extended from WORD - DWORD PointerToSymbolTable; - DWORD NumberOfSymbols; +typedef struct cmANON_OBJECT_HEADER_BIGOBJ +{ + /* same as ANON_OBJECT_HEADER_V2 */ + WORD Sig1; // Must be IMAGE_FILE_MACHINE_UNKNOWN + WORD Sig2; // Must be 0xffff + WORD Version; // >= 2 (implies the Flags field is present) + WORD Machine; // Actual machine - IMAGE_FILE_MACHINE_xxx + DWORD TimeDateStamp; + CLSID ClassID; // {D1BAA1C7-BAEE-4ba9-AF20-FAF66AA4DCB8} + DWORD SizeOfData; // Size of data that follows the header + DWORD Flags; // 0x1 -> contains metadata + DWORD MetaDataSize; // Size of CLR metadata + DWORD MetaDataOffset; // Offset of CLR metadata + + /* bigobj specifics */ + DWORD NumberOfSections; // extended from WORD + DWORD PointerToSymbolTable; + DWORD NumberOfSymbols; } cmANON_OBJECT_HEADER_BIGOBJ; -typedef struct _cmIMAGE_SYMBOL_EX { - union { - BYTE ShortName[8]; - struct { - DWORD Short; // if 0, use LongName - DWORD Long; // offset into string table - } Name; - DWORD LongName[2]; // PBYTE [2] - } N; - DWORD Value; - LONG SectionNumber; - WORD Type; - BYTE StorageClass; - BYTE NumberOfAuxSymbols; +typedef struct _cmIMAGE_SYMBOL_EX +{ + union + { + BYTE ShortName[8]; + struct + { + DWORD Short; // if 0, use LongName + DWORD Long; // offset into string table + } Name; + DWORD LongName[2]; // PBYTE [2] + } N; + DWORD Value; + LONG SectionNumber; + WORD Type; + BYTE StorageClass; + BYTE NumberOfAuxSymbols; } cmIMAGE_SYMBOL_EX; -typedef cmIMAGE_SYMBOL_EX UNALIGNED *cmPIMAGE_SYMBOL_EX; +typedef cmIMAGE_SYMBOL_EX UNALIGNED* cmPIMAGE_SYMBOL_EX; -PIMAGE_SECTION_HEADER GetSectionHeaderOffset(PIMAGE_FILE_HEADER - pImageFileHeader) +PIMAGE_SECTION_HEADER GetSectionHeaderOffset( + PIMAGE_FILE_HEADER pImageFileHeader) { - return (PIMAGE_SECTION_HEADER) - ((DWORD_PTR)pImageFileHeader + - IMAGE_SIZEOF_FILE_HEADER + - pImageFileHeader->SizeOfOptionalHeader); + return (PIMAGE_SECTION_HEADER)((DWORD_PTR)pImageFileHeader + + IMAGE_SIZEOF_FILE_HEADER + + pImageFileHeader->SizeOfOptionalHeader); } -PIMAGE_SECTION_HEADER GetSectionHeaderOffset(cmANON_OBJECT_HEADER_BIGOBJ* - pImageFileHeader) +PIMAGE_SECTION_HEADER GetSectionHeaderOffset( + cmANON_OBJECT_HEADER_BIGOBJ* pImageFileHeader) { - return (PIMAGE_SECTION_HEADER) - ((DWORD_PTR)pImageFileHeader + - sizeof(cmANON_OBJECT_HEADER_BIGOBJ)); + return (PIMAGE_SECTION_HEADER)((DWORD_PTR)pImageFileHeader + + sizeof(cmANON_OBJECT_HEADER_BIGOBJ)); } /* + * Utility func, strstr with size + */ -const char* StrNStr(const char* start, const char* find, size_t &size) { - size_t len; - const char* hint; +const char* StrNStr(const char* start, const char* find, size_t& size) +{ + size_t len; + const char* hint; - if (!start || !find || !size) { - size = 0; - return 0; - } - len = strlen(find); + if (!start || !find || !size) { + size = 0; + return 0; + } + len = strlen(find); - while ((hint = (const char*) memchr(start, find[0], size-len+1))) { - size -= (hint - start); - if (!strncmp(hint, find, len)) - return hint; - start = hint + 1; - } + while ((hint = (const char*)memchr(start, find[0], size - len + 1))) { + size -= (hint - start); + if (!strncmp(hint, find, len)) + return hint; + start = hint + 1; + } - size = 0; - return 0; + size = 0; + return 0; } template < @@ -162,68 +169,18 @@ public: *---------------------------------------------------------------------- */ - DumpSymbols(ObjectHeaderType* ih, - std::set<std::string>& symbols, - std::set<std::string>& dataSymbols, - bool is64) - :Symbols(symbols), DataSymbols(dataSymbols) - { - this->ObjectImageHeader = ih; - this->SymbolTable = (SymbolTableType*) - ((DWORD_PTR)this->ObjectImageHeader - + this->ObjectImageHeader->PointerToSymbolTable); - this->SectionHeaders = - GetSectionHeaderOffset(this->ObjectImageHeader); - this->SymbolCount = this->ObjectImageHeader->NumberOfSymbols; - this->Is64Bit = is64; - } - - /* - *---------------------------------------------------------------------- - * HaveExportedObjects -- - * - * Returns true if export directives (declspec(dllexport)) exist. - * - *---------------------------------------------------------------------- - */ - - bool HaveExportedObjects() { - WORD i = 0; - size_t size = 0; - const char * rawdata = 0; - PIMAGE_SECTION_HEADER pDirectivesSectionHeader = 0; - PIMAGE_SECTION_HEADER pSectionHeaders = this->SectionHeaders; - for(i = 0; (i < this->ObjectImageHeader->NumberOfSections && - !pDirectivesSectionHeader); i++) - if (!strncmp((const char*)&pSectionHeaders[i].Name[0], ".drectve",8)) - pDirectivesSectionHeader = &pSectionHeaders[i]; - if (!pDirectivesSectionHeader) return 0; - - rawdata=(const char*) - this->ObjectImageHeader+pDirectivesSectionHeader->PointerToRawData; - if (!pDirectivesSectionHeader->PointerToRawData || !rawdata) return 0; - - size = pDirectivesSectionHeader->SizeOfRawData; - const char* posImportFlag = rawdata; - while ((posImportFlag = StrNStr(posImportFlag, " /EXPORT:", size))) { - const char* lookingForDict = posImportFlag + 9; - if (!strncmp(lookingForDict, "_G__cpp_",8) || - !strncmp(lookingForDict, "_G__set_cpp_",12)) { - posImportFlag = lookingForDict; - continue; - } - - const char* lookingForDATA = posImportFlag + 9; - while (*(++lookingForDATA) && *lookingForDATA != ' '); - lookingForDATA -= 5; - // ignore DATA exports - if (strncmp(lookingForDATA, ",DATA", 5)) break; - posImportFlag = lookingForDATA + 5; - } - if(posImportFlag) { - return true; - } - return false; + DumpSymbols(ObjectHeaderType* ih, std::set<std::string>& symbols, + std::set<std::string>& dataSymbols, bool isI386) + : Symbols(symbols) + , DataSymbols(dataSymbols) + { + this->ObjectImageHeader = ih; + this->SymbolTable = + (SymbolTableType*)((DWORD_PTR) this->ObjectImageHeader + + this->ObjectImageHeader->PointerToSymbolTable); + this->SectionHeaders = GetSectionHeaderOffset(this->ObjectImageHeader); + this->SymbolCount = this->ObjectImageHeader->NumberOfSymbols; + this->IsI386 = isI386; } /* @@ -233,9 +190,7 @@ public: * Dump an object file's exported symbols. *---------------------------------------------------------------------- */ - void DumpObjFile() { - this->DumpExternalsObjects(); - } + void DumpObjFile() { this->DumpExternalsObjects(); } /* *---------------------------------------------------------------------- @@ -244,7 +199,8 @@ public: * Dumps a COFF symbol table from an OBJ. *---------------------------------------------------------------------- */ - void DumpExternalsObjects() { + void DumpExternalsObjects() + { unsigned i; PSTR stringTable; std::string symbol; @@ -252,82 +208,66 @@ public: /* * The string table apparently starts right after the symbol table */ - stringTable = (PSTR)&this->SymbolTable[this->SymbolCount]; + stringTable = (PSTR) & this->SymbolTable[this->SymbolCount]; SymbolTableType* pSymbolTable = this->SymbolTable; - for ( i=0; i < this->SymbolCount; i++ ) { + for (i = 0; i < this->SymbolCount; i++) { if (pSymbolTable->SectionNumber > 0 && - ( pSymbolTable->Type == 0x20 || pSymbolTable->Type == 0x0)) { - if (pSymbolTable->StorageClass == IMAGE_SYM_CLASS_EXTERNAL) { - /* - * The name of the Function entry points - */ - if (pSymbolTable->N.Name.Short != 0) { - symbol = ""; - symbol.insert(0, (const char *)pSymbolTable->N.ShortName, 8); - } else { - symbol = stringTable + pSymbolTable->N.Name.Long; - } + (pSymbolTable->Type == 0x20 || pSymbolTable->Type == 0x0)) { + if (pSymbolTable->StorageClass == IMAGE_SYM_CLASS_EXTERNAL) { + /* + * The name of the Function entry points + */ + if (pSymbolTable->N.Name.Short != 0) { + symbol = ""; + symbol.insert(0, (const char*)pSymbolTable->N.ShortName, 8); + } else { + symbol = stringTable + pSymbolTable->N.Name.Long; + } - // clear out any leading spaces - while (isspace(symbol[0])) symbol.erase(0,1); - // if it starts with _ and has an @ then it is a __cdecl - // so remove the @ stuff for the export - if(symbol[0] == '_') { - std::string::size_type posAt = symbol.find('@'); - if (posAt != std::string::npos) { - symbol.erase(posAt); - } + // clear out any leading spaces + while (isspace(symbol[0])) + symbol.erase(0, 1); + // if it starts with _ and has an @ then it is a __cdecl + // so remove the @ stuff for the export + if (symbol[0] == '_') { + std::string::size_type posAt = symbol.find('@'); + if (posAt != std::string::npos) { + symbol.erase(posAt); } - // For 64 bit builds we don't need to remove _ - if(!this->Is64Bit) - { - if (symbol[0] == '_') - { - symbol.erase(0,1); - } + } + // For i386 builds we don't need to remove _ + if (this->IsI386 && symbol[0] == '_') { + symbol.erase(0, 1); + } + + /* + Check whether it is "Scalar deleting destructor" and + "Vector deleting destructor" + */ + const char* scalarPrefix = "??_G"; + const char* vectorPrefix = "??_E"; + // original code had a check for + // symbol.find("real@") == std::string::npos) + // but if this disallows memmber functions with the name real + // if scalarPrefix and vectorPrefix are not found then print + // the symbol + if (symbol.compare(0, 4, scalarPrefix) && + symbol.compare(0, 4, vectorPrefix)) { + SectChar = this->SectionHeaders[pSymbolTable->SectionNumber - 1] + .Characteristics; + if (!pSymbolTable->Type && (SectChar & IMAGE_SCN_MEM_WRITE)) { + // Read only (i.e. constants) must be excluded + this->DataSymbols.insert(symbol); + } else { + if (pSymbolTable->Type || !(SectChar & IMAGE_SCN_MEM_READ) || + (SectChar & IMAGE_SCN_MEM_EXECUTE)) { + this->Symbols.insert(symbol); + } else { + // printf(" strange symbol: %s \n",symbol.c_str()); } - /* - Check whether it is "Scalar deleting destructor" and - "Vector deleting destructor" - */ - const char *scalarPrefix = "??_G"; - const char *vectorPrefix = "??_E"; - // original code had a check for - // symbol.find("real@") == std::string::npos) - // but if this disallows memmber functions with the name real - // if scalarPrefix and vectorPrefix are not found then print - // the symbol - if (symbol.compare(0, 4, scalarPrefix) && - symbol.compare(0, 4, vectorPrefix) ) - { - SectChar = - this-> - SectionHeaders[pSymbolTable->SectionNumber-1].Characteristics; - if (!pSymbolTable->Type && (SectChar & IMAGE_SCN_MEM_WRITE)) { - // Read only (i.e. constants) must be excluded - this->DataSymbols.insert(symbol); - } else { - if ( pSymbolTable->Type || - !(SectChar & IMAGE_SCN_MEM_READ)) { - this->Symbols.insert(symbol); - } else { - // printf(" strange symbol: %s \n",symbol.c_str()); - } - } } - } - } - else if (pSymbolTable->SectionNumber == IMAGE_SYM_UNDEFINED && - !pSymbolTable->Type && 0) { - /* - * The IMPORT global variable entry points - */ - if (pSymbolTable->StorageClass == IMAGE_SYM_CLASS_EXTERNAL) { - symbol = stringTable + pSymbolTable->N.Name.Long; - while (isspace(symbol[0])) symbol.erase(0,1); - if (symbol[0] == '_') symbol.erase(0,1); - this->DataSymbols.insert(symbol); - } + } + } } /* @@ -338,111 +278,129 @@ public: pSymbolTable++; } } + private: std::set<std::string>& Symbols; std::set<std::string>& DataSymbols; DWORD_PTR SymbolCount; PIMAGE_SECTION_HEADER SectionHeaders; ObjectHeaderType* ObjectImageHeader; - SymbolTableType* SymbolTable; - bool Is64Bit; + SymbolTableType* SymbolTable; + bool IsI386; }; -bool -DumpFile(const char* filename, - std::set<std::string>& symbols, - std::set<std::string>& dataSymbols) +bool DumpFile(const char* filename, std::set<std::string>& symbols, + std::set<std::string>& dataSymbols) { - HANDLE hFile; - HANDLE hFileMapping; - LPVOID lpFileBase; - PIMAGE_DOS_HEADER dosHeader; + HANDLE hFile; + HANDLE hFileMapping; + LPVOID lpFileBase; + PIMAGE_DOS_HEADER dosHeader; - hFile = CreateFileW(cmsys::Encoding::ToWide(filename).c_str(), - GENERIC_READ, FILE_SHARE_READ, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); + hFile = CreateFileW(cmsys::Encoding::ToWide(filename).c_str(), GENERIC_READ, + FILE_SHARE_READ, NULL, OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, 0); - if (hFile == INVALID_HANDLE_VALUE) { - fprintf(stderr, "Couldn't open file '%s' with CreateFile()\n", filename); - return false; - } + if (hFile == INVALID_HANDLE_VALUE) { + fprintf(stderr, "Couldn't open file '%s' with CreateFile()\n", filename); + return false; + } - hFileMapping = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL); - if (hFileMapping == 0) { - CloseHandle(hFile); - fprintf(stderr, "Couldn't open file mapping with CreateFileMapping()\n"); - return false; - } + hFileMapping = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL); + if (hFileMapping == 0) { + CloseHandle(hFile); + fprintf(stderr, "Couldn't open file mapping with CreateFileMapping()\n"); + return false; + } - lpFileBase = MapViewOfFile(hFileMapping, FILE_MAP_READ, 0, 0, 0); - if (lpFileBase == 0) { - CloseHandle(hFileMapping); - CloseHandle(hFile); - fprintf(stderr, "Couldn't map view of file with MapViewOfFile()\n"); - return false; - } + lpFileBase = MapViewOfFile(hFileMapping, FILE_MAP_READ, 0, 0, 0); + if (lpFileBase == 0) { + CloseHandle(hFileMapping); + CloseHandle(hFile); + fprintf(stderr, "Couldn't map view of file with MapViewOfFile()\n"); + return false; + } - dosHeader = (PIMAGE_DOS_HEADER)lpFileBase; - if (dosHeader->e_magic == IMAGE_DOS_SIGNATURE) { - fprintf(stderr, "File is an executable. I don't dump those.\n"); - return false; - } - /* Does it look like a i386 COFF OBJ file??? */ - else if ( - ((dosHeader->e_magic == IMAGE_FILE_MACHINE_I386) || - (dosHeader->e_magic == IMAGE_FILE_MACHINE_AMD64)) - && (dosHeader->e_sp == 0) - ) { - /* - * The two tests above aren't what they look like. They're - * really checking for IMAGE_FILE_HEADER.Machine == i386 (0x14C) - * and IMAGE_FILE_HEADER.SizeOfOptionalHeader == 0; - */ - DumpSymbols<IMAGE_FILE_HEADER, IMAGE_SYMBOL> - symbolDumper((PIMAGE_FILE_HEADER) lpFileBase, symbols, dataSymbols, - (dosHeader->e_magic == IMAGE_FILE_MACHINE_AMD64)); + dosHeader = (PIMAGE_DOS_HEADER)lpFileBase; + if (dosHeader->e_magic == IMAGE_DOS_SIGNATURE) { + fprintf(stderr, "File is an executable. I don't dump those.\n"); + return false; + } + /* Does it look like a COFF OBJ file??? */ + else if (((dosHeader->e_magic == IMAGE_FILE_MACHINE_I386) || + (dosHeader->e_magic == IMAGE_FILE_MACHINE_AMD64) || + (dosHeader->e_magic == IMAGE_FILE_MACHINE_ARMNT)) && + (dosHeader->e_sp == 0)) { + /* + * The two tests above aren't what they look like. They're + * really checking for IMAGE_FILE_HEADER.Machine == i386 (0x14C) + * and IMAGE_FILE_HEADER.SizeOfOptionalHeader == 0; + */ + DumpSymbols<IMAGE_FILE_HEADER, IMAGE_SYMBOL> symbolDumper( + (PIMAGE_FILE_HEADER)lpFileBase, symbols, dataSymbols, + (dosHeader->e_magic == IMAGE_FILE_MACHINE_I386)); + symbolDumper.DumpObjFile(); + } else { + // check for /bigobj format + cmANON_OBJECT_HEADER_BIGOBJ* h = (cmANON_OBJECT_HEADER_BIGOBJ*)lpFileBase; + if (h->Sig1 == 0x0 && h->Sig2 == 0xffff) { + DumpSymbols<cmANON_OBJECT_HEADER_BIGOBJ, cmIMAGE_SYMBOL_EX> symbolDumper( + (cmANON_OBJECT_HEADER_BIGOBJ*)lpFileBase, symbols, dataSymbols, + (h->Machine == IMAGE_FILE_MACHINE_I386)); symbolDumper.DumpObjFile(); - } else { - // check for /bigobj format - cmANON_OBJECT_HEADER_BIGOBJ* h = - (cmANON_OBJECT_HEADER_BIGOBJ*) lpFileBase; - if(h->Sig1 == 0x0 && h->Sig2 == 0xffff) { - DumpSymbols<cmANON_OBJECT_HEADER_BIGOBJ, cmIMAGE_SYMBOL_EX> - symbolDumper((cmANON_OBJECT_HEADER_BIGOBJ*) lpFileBase, symbols, - dataSymbols, - (h->Machine == IMAGE_FILE_MACHINE_AMD64)); - symbolDumper.DumpObjFile(); - } else { - printf("unrecognized file format in '%s'\n", filename); - return false; - } - } - UnmapViewOfFile(lpFileBase); - CloseHandle(hFileMapping); - CloseHandle(hFile); - return true; + } else { + printf("unrecognized file format in '%s'\n", filename); + return false; + } + } + UnmapViewOfFile(lpFileBase); + CloseHandle(hFileMapping); + CloseHandle(hFile); + return true; } bool bindexplib::AddObjectFile(const char* filename) { - if(!DumpFile(filename, this->Symbols, this->DataSymbols)) - { + return DumpFile(filename, this->Symbols, this->DataSymbols); +} + +bool bindexplib::AddDefinitionFile(const char* filename) +{ + cmsys::ifstream infile(filename); + if (!infile) { + fprintf(stderr, "Couldn't open definition file '%s'\n", filename); return false; + } + std::string str; + while (std::getline(infile, str)) { + // skip the LIBRAY and EXPORTS lines (if any) + if ((str.compare(0, 7, "LIBRARY") == 0) || + (str.compare(0, 7, "EXPORTS") == 0)) { + continue; + } + // remove leading tabs & spaces + str.erase(0, str.find_first_not_of(" \t")); + std::size_t found = str.find(" \t DATA"); + if (found != std::string::npos) { + str.erase(found, std::string::npos); + this->DataSymbols.insert(str); + } else { + this->Symbols.insert(str); } + } + infile.close(); return true; } void bindexplib::WriteFile(FILE* file) { - fprintf(file,"EXPORTS \n"); - for(std::set<std::string>::const_iterator i = this->DataSymbols.begin(); - i!= this->DataSymbols.end(); ++i) - { + fprintf(file, "EXPORTS \n"); + for (std::set<std::string>::const_iterator i = this->DataSymbols.begin(); + i != this->DataSymbols.end(); ++i) { fprintf(file, "\t%s \t DATA\n", i->c_str()); - } - for(std::set<std::string>::const_iterator i = this->Symbols.begin(); - i!= this->Symbols.end(); ++i) - { + } + for (std::set<std::string>::const_iterator i = this->Symbols.begin(); + i != this->Symbols.end(); ++i) { fprintf(file, "\t%s\n", i->c_str()); - } + } } diff --git a/Source/bindexplib.h b/Source/bindexplib.h index d6900ba..bc904e9 100644 --- a/Source/bindexplib.h +++ b/Source/bindexplib.h @@ -3,7 +3,7 @@ #ifndef bindexplib_h #define bindexplib_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <set> #include <stdio.h> @@ -13,8 +13,10 @@ class bindexplib { public: bindexplib() {} + bool AddDefinitionFile(const char* filename); bool AddObjectFile(const char* filename); void WriteFile(FILE* file); + private: std::set<std::string> Symbols; std::set<std::string> DataSymbols; diff --git a/Source/cmAddCompileOptionsCommand.h b/Source/cmAddCompileOptionsCommand.h index 71009b4..105d323 100644 --- a/Source/cmAddCompileOptionsCommand.h +++ b/Source/cmAddCompileOptionsCommand.h @@ -3,7 +3,8 @@ #ifndef cmAddCompileOptionsCommand_h #define cmAddCompileOptionsCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmAddCustomCommandCommand.h b/Source/cmAddCustomCommandCommand.h index ea92163..912a91a 100644 --- a/Source/cmAddCustomCommandCommand.h +++ b/Source/cmAddCustomCommandCommand.h @@ -3,7 +3,8 @@ #ifndef cmAddCustomCommandCommand_h #define cmAddCustomCommandCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmAddCustomTargetCommand.h b/Source/cmAddCustomTargetCommand.h index b679247..c449b10 100644 --- a/Source/cmAddCustomTargetCommand.h +++ b/Source/cmAddCustomTargetCommand.h @@ -3,7 +3,8 @@ #ifndef cmAddCustomTargetCommand_h #define cmAddCustomTargetCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmAddDefinitionsCommand.h b/Source/cmAddDefinitionsCommand.h index 735f8cc..de4bc1c 100644 --- a/Source/cmAddDefinitionsCommand.h +++ b/Source/cmAddDefinitionsCommand.h @@ -3,7 +3,8 @@ #ifndef cmAddDefinitionsCommand_h #define cmAddDefinitionsCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmAddDependenciesCommand.h b/Source/cmAddDependenciesCommand.h index 8be546c..88ac336 100644 --- a/Source/cmAddDependenciesCommand.h +++ b/Source/cmAddDependenciesCommand.h @@ -3,7 +3,8 @@ #ifndef cmDependenciessCommand_h #define cmDependenciessCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmAddExecutableCommand.h b/Source/cmAddExecutableCommand.h index 62583d8..6531829 100644 --- a/Source/cmAddExecutableCommand.h +++ b/Source/cmAddExecutableCommand.h @@ -3,7 +3,8 @@ #ifndef cmExecutablesCommand_h #define cmExecutablesCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index 9ae4ace..0bdf963 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -297,10 +297,15 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args, return false; } if (type == cmStateEnums::OBJECT_LIBRARY) { - this->Makefile->IssueMessage( - cmake::FATAL_ERROR, - "The OBJECT library type may not be used for IMPORTED libraries."); - return true; + std::string reason; + if (!this->Makefile->GetGlobalGenerator()->HasKnownObjectFileLocation( + &reason)) { + this->Makefile->IssueMessage( + cmake::FATAL_ERROR, + "The OBJECT library type may not be used for IMPORTED libraries" + + reason + "."); + return true; + } } if (type == cmStateEnums::INTERFACE_LIBRARY) { if (!cmGeneratorExpression::IsValidTargetName(libName)) { diff --git a/Source/cmAddLibraryCommand.h b/Source/cmAddLibraryCommand.h index c23b299..977645e 100644 --- a/Source/cmAddLibraryCommand.h +++ b/Source/cmAddLibraryCommand.h @@ -3,7 +3,8 @@ #ifndef cmLibrarysCommand_h #define cmLibrarysCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmAddSubDirectoryCommand.cxx b/Source/cmAddSubDirectoryCommand.cxx index 34ec0e3..dbd4dd1 100644 --- a/Source/cmAddSubDirectoryCommand.cxx +++ b/Source/cmAddSubDirectoryCommand.cxx @@ -32,7 +32,8 @@ bool cmAddSubDirectoryCommand::InitialPass( if (*i == "EXCLUDE_FROM_ALL") { excludeFromAll = true; continue; - } else if (binArg.empty()) { + } + if (binArg.empty()) { binArg = *i; } else { this->SetError("called with incorrect number of arguments"); diff --git a/Source/cmAddSubDirectoryCommand.h b/Source/cmAddSubDirectoryCommand.h index 85305e6..b19477a 100644 --- a/Source/cmAddSubDirectoryCommand.h +++ b/Source/cmAddSubDirectoryCommand.h @@ -3,7 +3,8 @@ #ifndef cmAddSubDirectoryCommand_h #define cmAddSubDirectoryCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmAddTestCommand.h b/Source/cmAddTestCommand.h index 07eff68..1d6c4cc 100644 --- a/Source/cmAddTestCommand.h +++ b/Source/cmAddTestCommand.h @@ -3,7 +3,8 @@ #ifndef cmAddTestCommand_h #define cmAddTestCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h index 7c683ad..4adfe23 100644 --- a/Source/cmAlgorithms.h +++ b/Source/cmAlgorithms.h @@ -3,10 +3,10 @@ #ifndef cmAlgorithms_h #define cmAlgorithms_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep +#include "cm_kwiml.h" #include <algorithm> -#include <cm_kwiml.h> #include <functional> #include <iterator> #include <sstream> @@ -101,6 +101,12 @@ FwdIt cmRotate(FwdIt first, FwdIt middle, FwdIt last) return first; } +template <typename Container, typename Predicate> +void cmEraseIf(Container& cont, Predicate pred) +{ + cont.erase(std::remove_if(cont.begin(), cont.end(), pred), cont.end()); +} + namespace ContainerAlgorithms { template <typename T> @@ -354,7 +360,8 @@ std::string cmWrap(std::string const& prefix, Range const& r, } template <typename Range> -std::string cmWrap(char prefix, Range const& r, char suffix, std::string sep) +std::string cmWrap(char prefix, Range const& r, char suffix, + std::string const& sep) { return cmWrap(std::string(1, prefix), r, std::string(1, suffix), sep); } diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx index 879c2ca..0f13b11 100644 --- a/Source/cmArchiveWrite.cxx +++ b/Source/cmArchiveWrite.cxx @@ -5,10 +5,10 @@ #include "cmLocale.h" #include "cmSystemTools.h" #include "cm_get_date.h" -#include <cm_libarchive.h> -#include <cmsys/Directory.hxx> -#include <cmsys/Encoding.hxx> -#include <cmsys/FStream.hxx> +#include "cm_libarchive.h" +#include "cmsys/Directory.hxx" +#include "cmsys/Encoding.hxx" +#include "cmsys/FStream.hxx" #include <iostream> #include <string.h> #include <time.h> diff --git a/Source/cmArchiveWrite.h b/Source/cmArchiveWrite.h index 27c62b9..4c85c0d 100644 --- a/Source/cmArchiveWrite.h +++ b/Source/cmArchiveWrite.h @@ -3,7 +3,7 @@ #ifndef cmArchiveWrite_h #define cmArchiveWrite_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <iosfwd> #include <stddef.h> diff --git a/Source/cmAuxSourceDirectoryCommand.cxx b/Source/cmAuxSourceDirectoryCommand.cxx index 7cfa4d8..c92c47b 100644 --- a/Source/cmAuxSourceDirectoryCommand.cxx +++ b/Source/cmAuxSourceDirectoryCommand.cxx @@ -2,8 +2,8 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmAuxSourceDirectoryCommand.h" +#include "cmsys/Directory.hxx" #include <algorithm> -#include <cmsys/Directory.hxx> #include <stddef.h> #include "cmAlgorithms.h" diff --git a/Source/cmAuxSourceDirectoryCommand.h b/Source/cmAuxSourceDirectoryCommand.h index d99bf7b..f8800a5 100644 --- a/Source/cmAuxSourceDirectoryCommand.h +++ b/Source/cmAuxSourceDirectoryCommand.h @@ -3,7 +3,8 @@ #ifndef cmAuxSourceDirectoryCommand_h #define cmAuxSourceDirectoryCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmBase32.h b/Source/cmBase32.h index 44bca2f..c6758d4 100644 --- a/Source/cmBase32.h +++ b/Source/cmBase32.h @@ -3,7 +3,7 @@ #ifndef cmBase32_h #define cmBase32_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <stddef.h> #include <string> diff --git a/Source/cmBreakCommand.h b/Source/cmBreakCommand.h index 5113e18..8ce5ca2 100644 --- a/Source/cmBreakCommand.h +++ b/Source/cmBreakCommand.h @@ -3,7 +3,8 @@ #ifndef cmBreakCommand_h #define cmBreakCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmBuildCommand.h b/Source/cmBuildCommand.h index 62f1fd3..7df54ec 100644 --- a/Source/cmBuildCommand.h +++ b/Source/cmBuildCommand.h @@ -3,7 +3,8 @@ #ifndef cmBuildCommand_h #define cmBuildCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmBuildNameCommand.cxx b/Source/cmBuildNameCommand.cxx index 1e1cd21..9d2c0c6 100644 --- a/Source/cmBuildNameCommand.cxx +++ b/Source/cmBuildNameCommand.cxx @@ -2,11 +2,10 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmBuildNameCommand.h" +#include "cmsys/RegularExpression.hxx" #include <algorithm> -#include <cmsys/RegularExpression.hxx> #include "cmMakefile.h" -#include "cmPolicies.h" #include "cmStateTypes.h" #include "cmSystemTools.h" @@ -16,11 +15,6 @@ class cmExecutionStatus; bool cmBuildNameCommand::InitialPass(std::vector<std::string> const& args, cmExecutionStatus&) { - if (this->Disallowed( - cmPolicies::CMP0036, - "The build_name command should not be called; see CMP0036.")) { - return true; - } if (args.empty()) { this->SetError("called with incorrect number of arguments"); return false; diff --git a/Source/cmBuildNameCommand.h b/Source/cmBuildNameCommand.h index 1e1f4b5..00f645a 100644 --- a/Source/cmBuildNameCommand.h +++ b/Source/cmBuildNameCommand.h @@ -3,7 +3,8 @@ #ifndef cmBuildNameCommand_h #define cmBuildNameCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmCLocaleEnvironmentScope.h b/Source/cmCLocaleEnvironmentScope.h index 32cc8df..1e7c42a 100644 --- a/Source/cmCLocaleEnvironmentScope.h +++ b/Source/cmCLocaleEnvironmentScope.h @@ -3,7 +3,7 @@ #ifndef cmCLocaleEnvironmentScope_h #define cmCLocaleEnvironmentScope_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <map> #include <string> @@ -15,6 +15,9 @@ public: ~cmCLocaleEnvironmentScope(); private: + cmCLocaleEnvironmentScope(cmCLocaleEnvironmentScope const&); + cmCLocaleEnvironmentScope& operator=(cmCLocaleEnvironmentScope const&); + std::string GetEnv(std::string const& key); void SetEnv(std::string const& key, std::string const& value); diff --git a/Source/cmCMakeHostSystemInformationCommand.h b/Source/cmCMakeHostSystemInformationCommand.h index 22f3d54..fe148a3 100644 --- a/Source/cmCMakeHostSystemInformationCommand.h +++ b/Source/cmCMakeHostSystemInformationCommand.h @@ -3,7 +3,8 @@ #ifndef cmCMakeHostSystemInformationCommand_h #define cmCMakeHostSystemInformationCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <stddef.h> #include <string> #include <vector> diff --git a/Source/cmCMakeMinimumRequired.h b/Source/cmCMakeMinimumRequired.h index 08a5c38..8db0860 100644 --- a/Source/cmCMakeMinimumRequired.h +++ b/Source/cmCMakeMinimumRequired.h @@ -3,7 +3,8 @@ #ifndef cmCMakeMinimumRequired_h #define cmCMakeMinimumRequired_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmCMakePolicyCommand.h b/Source/cmCMakePolicyCommand.h index 409fc59..789e294 100644 --- a/Source/cmCMakePolicyCommand.h +++ b/Source/cmCMakePolicyCommand.h @@ -3,7 +3,8 @@ #ifndef cmCMakePolicyCommand_h #define cmCMakePolicyCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmCPackPropertiesGenerator.cxx b/Source/cmCPackPropertiesGenerator.cxx index ae6b0a1..57a8b38 100644 --- a/Source/cmCPackPropertiesGenerator.cxx +++ b/Source/cmCPackPropertiesGenerator.cxx @@ -19,7 +19,7 @@ cmCPackPropertiesGenerator::cmCPackPropertiesGenerator( } void cmCPackPropertiesGenerator::GenerateScriptForConfig( - std::ostream& os, const std::string& config, Indent const& indent) + std::ostream& os, const std::string& config, Indent indent) { std::string const& expandedFileName = this->InstalledFile.GetNameExpression().Evaluate(this->LG, config); diff --git a/Source/cmCPackPropertiesGenerator.h b/Source/cmCPackPropertiesGenerator.h index 37c6039..107ccf9 100644 --- a/Source/cmCPackPropertiesGenerator.h +++ b/Source/cmCPackPropertiesGenerator.h @@ -3,7 +3,7 @@ #ifndef cmCPackPropertiesGenerator_h #define cmCPackPropertiesGenerator_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include "cmScriptGenerator.h" @@ -27,7 +27,7 @@ public: protected: void GenerateScriptForConfig(std::ostream& os, const std::string& config, - Indent const& indent) CM_OVERRIDE; + Indent indent) CM_OVERRIDE; cmLocalGenerator* LG; cmInstalledFile const& InstalledFile; diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 559275e..46fa86e 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -2,15 +2,15 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTest.h" -#include <cm_curl.h> -#include <cm_zlib.h> -#include <cmsys/Base64.h> -#include <cmsys/Directory.hxx> -#include <cmsys/FStream.hxx> -#include <cmsys/Glob.hxx> -#include <cmsys/Process.h> -#include <cmsys/String.hxx> -#include <cmsys/SystemInformation.hxx> +#include "cm_curl.h" +#include "cm_zlib.h" +#include "cmsys/Base64.h" +#include "cmsys/Directory.hxx" +#include "cmsys/FStream.hxx" +#include "cmsys/Glob.hxx" +#include "cmsys/Process.h" +#include "cmsys/String.hxx" +#include "cmsys/SystemInformation.hxx" #include <ctype.h> #include <iostream> #include <map> @@ -1122,7 +1122,6 @@ int cmCTest::RunTest(std::vector<const char*> argv, std::string* output, if (log) { *log << "* Run internal CTest" << std::endl; } - std::string oldpath = cmSystemTools::GetCurrentWorkingDirectory(); CM_AUTO_PTR<cmSystemTools::SaveRestoreEnvironment> saveEnv; if (modifyEnv) { @@ -1137,7 +1136,6 @@ int cmCTest::RunTest(std::vector<const char*> argv, std::string* output, if (log && output) { *log << *output; } - cmSystemTools::ChangeDirectory(oldpath); if (output) { cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "Internal cmCTest object used to run test." << std::endl diff --git a/Source/cmCTest.h b/Source/cmCTest.h index 4d33458..60f3295 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -3,10 +3,10 @@ #ifndef cmCTest_h #define cmCTest_h -#include <cmConfigure.h> +#include "cmConfigure.h" -#include <cmProcessOutput.h> -#include <cmsys/String.hxx> +#include "cmProcessOutput.h" +#include "cmsys/String.hxx" #include <map> #include <set> #include <sstream> @@ -14,29 +14,12 @@ #include <time.h> #include <vector> -class cmCTest; class cmCTestGenericHandler; class cmCTestStartCommand; class cmGeneratedFileStream; class cmMakefile; class cmXMLWriter; -#define cmCTestLog(ctSelf, logType, msg) \ - do { \ - std::ostringstream cmCTestLog_msg; \ - cmCTestLog_msg << msg; \ - (ctSelf)->Log(cmCTest::logType, __FILE__, __LINE__, \ - cmCTestLog_msg.str().c_str()); \ - } while (false) - -#define cmCTestOptionalLog(ctSelf, logType, msg, suppress) \ - do { \ - std::ostringstream cmCTestLog_msg; \ - cmCTestLog_msg << msg; \ - (ctSelf)->Log(cmCTest::logType, __FILE__, __LINE__, \ - cmCTestLog_msg.str().c_str(), suppress); \ - } while (false) - /** \class cmCTest * \brief Represents a ctest invocation. * @@ -648,4 +631,20 @@ inline std::ostream& operator<<(std::ostream& os, const cmCTestLogWrite& c) return os; } +#define cmCTestLog(ctSelf, logType, msg) \ + do { \ + std::ostringstream cmCTestLog_msg; \ + cmCTestLog_msg << msg; \ + (ctSelf)->Log(cmCTest::logType, __FILE__, __LINE__, \ + cmCTestLog_msg.str().c_str()); \ + } while (false) + +#define cmCTestOptionalLog(ctSelf, logType, msg, suppress) \ + do { \ + std::ostringstream cmCTestLog_msg; \ + cmCTestLog_msg << msg; \ + (ctSelf)->Log(cmCTest::logType, __FILE__, __LINE__, \ + cmCTestLog_msg.str().c_str(), suppress); \ + } while (false) + #endif diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index cb0ba63..f7fefca 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -2,9 +2,9 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCacheManager.h" +#include "cmsys/FStream.hxx" +#include "cmsys/Glob.hxx" #include <algorithm> -#include <cmsys/FStream.hxx> -#include <cmsys/Glob.hxx> #include <sstream> #include <stdio.h> #include <string.h> diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h index e82c9ef..a72d6cb 100644 --- a/Source/cmCacheManager.h +++ b/Source/cmCacheManager.h @@ -3,7 +3,7 @@ #ifndef cmCacheManager_h #define cmCacheManager_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <iosfwd> #include <map> diff --git a/Source/cmCallVisualStudioMacro.h b/Source/cmCallVisualStudioMacro.h index e9d34e5..ad35d30 100644 --- a/Source/cmCallVisualStudioMacro.h +++ b/Source/cmCallVisualStudioMacro.h @@ -3,7 +3,7 @@ #ifndef cmCallVisualStudioMacro_h #define cmCallVisualStudioMacro_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <string> diff --git a/Source/cmCommand.cxx b/Source/cmCommand.cxx index 181b412..d349c91 100644 --- a/Source/cmCommand.cxx +++ b/Source/cmCommand.cxx @@ -3,7 +3,6 @@ #include "cmCommand.h" #include "cmMakefile.h" -#include "cmake.h" class cmExecutionStatus; struct cmListFileArgument; @@ -23,32 +22,12 @@ bool cmCommand::InvokeInitialPass(const std::vector<cmListFileArgument>& args, const char* cmCommand::GetError() { if (this->Error.empty()) { - this->Error = this->GetName(); - this->Error += " unknown error."; + return "unknown error."; } return this->Error.c_str(); } void cmCommand::SetError(const std::string& e) { - this->Error = this->GetName(); - this->Error += " "; - this->Error += e; -} - -bool cmCommand::Disallowed(cmPolicies::PolicyID pol, const char* e) -{ - switch (this->Makefile->GetPolicyStatus(pol)) { - case cmPolicies::WARN: - this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, - cmPolicies::GetPolicyWarning(pol)); - case cmPolicies::OLD: - return false; - case cmPolicies::REQUIRED_IF_USED: - case cmPolicies::REQUIRED_ALWAYS: - case cmPolicies::NEW: - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e); - break; - } - return true; + this->Error = e; } diff --git a/Source/cmCommand.h b/Source/cmCommand.h index d9fd5a2..f4a75d5 100644 --- a/Source/cmCommand.h +++ b/Source/cmCommand.h @@ -3,13 +3,11 @@ #ifndef cmCommand_h #define cmCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> -#include "cmCommandArgumentsHelper.h" -#include "cmPolicies.h" - class cmExecutionStatus; class cmMakefile; struct cmListFileArgument; @@ -105,12 +103,12 @@ public: */ void SetError(const std::string& e); - /** Check if the command is disallowed by a policy. */ - bool Disallowed(cmPolicies::PolicyID pol, const char* e); +private: + cmCommand(cmCommand const&); // = delete; + cmCommand& operator=(cmCommand const&); // = delete; protected: cmMakefile* Makefile; - cmCommandArgumentsHelper Helper; private: std::string Error; diff --git a/Source/cmCommandArgumentParser.cxx b/Source/cmCommandArgumentParser.cxx index e384f21..aed0826 100644 --- a/Source/cmCommandArgumentParser.cxx +++ b/Source/cmCommandArgumentParser.cxx @@ -1,16 +1,13 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -/* A Bison parser, made by GNU Bison 2.3. */ +/* A Bison parser, made by GNU Bison 3.0.4. */ -/* Skeleton implementation for Bison's Yacc-like parsers in C +/* Bison implementation for Yacc-like parsers in C - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. - This program is free software; you can redistribute it and/or modify + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -18,9 +15,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ + along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -49,7 +44,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.3" +#define YYBISON_VERSION "3.0.4" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -57,58 +52,23 @@ /* Pure parsers. */ #define YYPURE 1 -/* Using locations. */ -#define YYLSP_NEEDED 0 - -/* Substitute the variable and function names. */ -#define yyparse cmCommandArgument_yyparse -#define yylex cmCommandArgument_yylex -#define yyerror cmCommandArgument_yyerror -#define yylval cmCommandArgument_yylval -#define yychar cmCommandArgument_yychar -#define yydebug cmCommandArgument_yydebug -#define yynerrs cmCommandArgument_yynerrs - +/* Push parsers. */ +#define YYPUSH 0 -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - cal_ENVCURLY = 258, - cal_NCURLY = 259, - cal_DCURLY = 260, - cal_DOLLAR = 261, - cal_LCURLY = 262, - cal_RCURLY = 263, - cal_NAME = 264, - cal_BSLASH = 265, - cal_SYMBOL = 266, - cal_AT = 267, - cal_ERROR = 268, - cal_ATNAME = 269 - }; -#endif -/* Tokens. */ -#define cal_ENVCURLY 258 -#define cal_NCURLY 259 -#define cal_DCURLY 260 -#define cal_DOLLAR 261 -#define cal_LCURLY 262 -#define cal_RCURLY 263 -#define cal_NAME 264 -#define cal_BSLASH 265 -#define cal_SYMBOL 266 -#define cal_AT 267 -#define cal_ERROR 268 -#define cal_ATNAME 269 +/* Pull parsers. */ +#define YYPULL 1 +/* Substitute the variable and function names. */ +#define yyparse cmCommandArgument_yyparse +#define yylex cmCommandArgument_yylex +#define yyerror cmCommandArgument_yyerror +#define yydebug cmCommandArgument_yydebug +#define yynerrs cmCommandArgument_yynerrs /* Copy the first part of user declarations. */ -#line 1 "cmCommandArgumentParser.y" +#line 1 "cmCommandArgumentParser.y" /* yacc.c:339 */ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ @@ -121,19 +81,14 @@ Run bison like this: bison --yacc --name-prefix=cmCommandArgument_yy --defines=cmCommandArgumentParserTokens.h -ocmCommandArgumentParser.cxx cmCommandArgumentParser.y Modify cmCommandArgumentParser.cxx: - - remove TABs - - put header block at top of file + - "#if 0" out yyerrorlab block in range ["goto yyerrlab1", "yyerrlab1:"] */ -#include "cmStandardIncludes.h" +#include "cmConfigure.h" // IWYU pragma: keep + +#include <string.h> -/* Configure the parser to use a lexer object. */ -#define YYPARSE_PARAM yyscanner -#define YYLEX_PARAM yyscanner -#define YYERROR_VERBOSE 1 -#define cmCommandArgument_yyerror(x) \ - cmCommandArgumentError(yyscanner, x) #define yyGetParser (cmCommandArgument_yyget_extra(yyscanner)) /* Make sure malloc and free are available on QNX. */ @@ -156,10 +111,9 @@ Modify cmCommandArgumentParser.cxx: /* Forward declare the lexer entry point. */ YY_DECL; -/* Internal utility functions. */ -static void cmCommandArgumentError(yyscan_t yyscanner, const char* message); +/* Helper function to forward error callback from parser. */ +static void cmCommandArgument_yyerror(yyscan_t yyscanner, const char* message); -#define YYDEBUG 1 /* Configure the parser to support large input. */ #define YYMAXDEPTH 100000 #define YYINITDEPTH 10000 @@ -173,39 +127,80 @@ static void cmCommandArgumentError(yyscan_t yyscanner, const char* message); # pragma warning (disable: 4702) /* unreachable code */ #endif +#line 131 "cmCommandArgumentParser.cxx" /* yacc.c:339 */ -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif +# ifndef YY_NULLPTR +# if defined __cplusplus && 201103L <= __cplusplus +# define YY_NULLPTR nullptr +# else +# define YY_NULLPTR 0 +# endif +# endif /* Enabling verbose error messages. */ #ifdef YYERROR_VERBOSE # undef YYERROR_VERBOSE # define YYERROR_VERBOSE 1 #else -# define YYERROR_VERBOSE 0 +# define YYERROR_VERBOSE 1 #endif -/* Enabling the token table. */ -#ifndef YYTOKEN_TABLE -# define YYTOKEN_TABLE 0 +/* In a future release of Bison, this section will be replaced + by #include "cmCommandArgumentParserTokens.h". */ +#ifndef YY_CMCOMMANDARGUMENT_YY_CMCOMMANDARGUMENTPARSERTOKENS_H_INCLUDED +# define YY_CMCOMMANDARGUMENT_YY_CMCOMMANDARGUMENTPARSERTOKENS_H_INCLUDED +/* Debug traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif +#if YYDEBUG +extern int cmCommandArgument_yydebug; #endif -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef int YYSTYPE; -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 +/* Token type. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + enum yytokentype + { + cal_ENVCURLY = 258, + cal_NCURLY = 259, + cal_DCURLY = 260, + cal_DOLLAR = 261, + cal_LCURLY = 262, + cal_RCURLY = 263, + cal_NAME = 264, + cal_BSLASH = 265, + cal_SYMBOL = 266, + cal_AT = 267, + cal_ERROR = 268, + cal_ATNAME = 269 + }; #endif +/* Tokens. */ +#define cal_ENVCURLY 258 +#define cal_NCURLY 259 +#define cal_DCURLY 260 +#define cal_DOLLAR 261 +#define cal_LCURLY 262 +#define cal_RCURLY 263 +#define cal_NAME 264 +#define cal_BSLASH 265 +#define cal_SYMBOL 266 +#define cal_AT 267 +#define cal_ERROR 268 +#define cal_ATNAME 269 +/* Value type. */ -/* Copy the second part of user declarations. */ +int cmCommandArgument_yyparse (yyscan_t yyscanner); + +#endif /* !YY_CMCOMMANDARGUMENT_YY_CMCOMMANDARGUMENTPARSERTOKENS_H_INCLUDED */ + +/* Copy the second part of user declarations. */ -/* Line 216 of yacc.c. */ -#line 227 "cmCommandArgumentParser.cxx" +#line 204 "cmCommandArgumentParser.cxx" /* yacc.c:358 */ #ifdef short # undef short @@ -219,11 +214,8 @@ typedef unsigned char yytype_uint8; #ifdef YYTYPE_INT8 typedef YYTYPE_INT8 yytype_int8; -#elif (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -typedef signed char yytype_int8; #else -typedef short int yytype_int8; +typedef signed char yytype_int8; #endif #ifdef YYTYPE_UINT16 @@ -243,8 +235,7 @@ typedef short int yytype_int16; # define YYSIZE_T __SIZE_TYPE__ # elif defined size_t # define YYSIZE_T size_t -# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) +# elif ! defined YYSIZE_T # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else @@ -258,39 +249,68 @@ typedef short int yytype_int16; # if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ -# define YY_(msgid) dgettext ("bison-runtime", msgid) +# define YY_(Msgid) dgettext ("bison-runtime", Msgid) # endif # endif # ifndef YY_ -# define YY_(msgid) msgid +# define YY_(Msgid) Msgid +# endif +#endif + +#ifndef YY_ATTRIBUTE +# if (defined __GNUC__ \ + && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ + || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C +# define YY_ATTRIBUTE(Spec) __attribute__(Spec) +# else +# define YY_ATTRIBUTE(Spec) /* empty */ +# endif +#endif + +#ifndef YY_ATTRIBUTE_PURE +# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) +#endif + +#ifndef YY_ATTRIBUTE_UNUSED +# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) +#endif + +#if !defined _Noreturn \ + && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) +# if defined _MSC_VER && 1200 <= _MSC_VER +# define _Noreturn __declspec (noreturn) +# else +# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) # endif #endif /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ -# define YYUSE(e) ((void) (e)) +# define YYUSE(E) ((void) (E)) #else -# define YYUSE(e) /* empty */ +# define YYUSE(E) /* empty */ #endif -/* Identity function, used to suppress warnings about constant conditions. */ -#ifndef lint -# define YYID(n) (n) +#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +/* Suppress an incorrect diagnostic about yylval being uninitialized. */ +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ + _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ + _Pragma ("GCC diagnostic pop") #else -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static int -YYID (int i) -#else -static int -YYID (i) - int i; +# define YY_INITIAL_VALUE(Value) Value #endif -{ - return i; -} +#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_END +#endif +#ifndef YY_INITIAL_VALUE +# define YY_INITIAL_VALUE(Value) /* Nothing. */ #endif + #if ! defined yyoverflow || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ @@ -308,11 +328,11 @@ YYID (i) # define alloca _alloca # else # define YYSTACK_ALLOC alloca -# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) +# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ -# ifndef _STDLIB_H -# define _STDLIB_H 1 + /* Use EXIT_SUCCESS as a witness for stdlib.h. */ +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 # endif # endif # endif @@ -320,8 +340,8 @@ YYID (i) # endif # ifdef YYSTACK_ALLOC - /* Pacify GCC's `empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) + /* Pacify GCC's 'empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) # ifndef YYSTACK_ALLOC_MAXIMUM /* The OS might guarantee only one guard page at the bottom of the stack, and a page size can be as small as 4096 bytes. So we cannot safely @@ -335,25 +355,23 @@ YYID (i) # ifndef YYSTACK_ALLOC_MAXIMUM # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM # endif -# if (defined __cplusplus && ! defined _STDLIB_H \ +# if (defined __cplusplus && ! defined EXIT_SUCCESS \ && ! ((defined YYMALLOC || defined malloc) \ && (defined YYFREE || defined free))) # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ -# ifndef _STDLIB_H -# define _STDLIB_H 1 +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 # endif # endif # ifndef YYMALLOC # define YYMALLOC malloc -# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) +# if ! defined malloc && ! defined EXIT_SUCCESS void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ # endif # endif # ifndef YYFREE # define YYFREE free -# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) +# if ! defined free && ! defined EXIT_SUCCESS void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif @@ -368,9 +386,9 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ /* A type that is properly aligned for any stack member. */ union yyalloc { - yytype_int16 yyss; - YYSTYPE yyvs; - }; + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; +}; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) @@ -381,42 +399,46 @@ union yyalloc ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) -/* Copy COUNT objects from FROM to TO. The source and destination do - not overlap. */ -# ifndef YYCOPY -# if defined __GNUC__ && 1 < __GNUC__ -# define YYCOPY(To, From, Count) \ - __builtin_memcpy (To, From, (Count) * sizeof (*(From))) -# else -# define YYCOPY(To, From, Count) \ - do \ - { \ - YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (To)[yyi] = (From)[yyi]; \ - } \ - while (YYID (0)) -# endif -# endif +# define YYCOPY_NEEDED 1 /* Relocate STACK from its old location to the new one. The local variables YYSIZE and YYSTACKSIZE give the old and new number of elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ -# define YYSTACK_RELOCATE(Stack) \ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ - while (YYID (0)) + while (0) #endif +#if defined YYCOPY_NEEDED && YYCOPY_NEEDED +/* Copy COUNT objects from SRC to DST. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(Dst, Src, Count) \ + __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) +# else +# define YYCOPY(Dst, Src, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (Dst)[yyi] = (Src)[yyi]; \ + } \ + while (0) +# endif +# endif +#endif /* !YYCOPY_NEEDED */ + /* YYFINAL -- State number of the termination state. */ #define YYFINAL 25 /* YYLAST -- Last index in YYTABLE. */ @@ -428,17 +450,19 @@ union yyalloc #define YYNNTS 10 /* YYNRULES -- Number of rules. */ #define YYNRULES 24 -/* YYNRULES -- Number of states. */ +/* YYNSTATES -- Number of states. */ #define YYNSTATES 33 -/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned + by yylex, with out-of-bounds checking. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 269 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) -/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM + as returned by yylex, without out-of-bounds checking. */ static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -471,36 +495,16 @@ static const yytype_uint8 yytranslate[] = }; #if YYDEBUG -/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in - YYRHS. */ -static const yytype_uint8 yyprhs[] = -{ - 0, 0, 3, 5, 7, 10, 11, 14, 16, 18, - 20, 22, 24, 26, 28, 30, 34, 38, 42, 44, - 46, 49, 50, 53, 55 -}; - -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const yytype_int8 yyrhs[] = -{ - 16, 0, -1, 17, -1, 18, -1, 18, 10, -1, - -1, 19, 18, -1, 20, -1, 21, -1, 9, -1, - 12, -1, 6, -1, 7, -1, 8, -1, 11, -1, - 3, 22, 8, -1, 4, 23, 8, -1, 5, 23, - 8, -1, 14, -1, 23, -1, 11, 22, -1, -1, - 24, 23, -1, 9, -1, 21, -1 -}; - -/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ + /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_uint8 yyrline[] = { - 0, 116, 116, 123, 128, 134, 138, 144, 149, 155, - 160, 165, 170, 175, 180, 186, 192, 198, 204, 210, - 215, 221, 225, 231, 236 + 0, 96, 96, 102, 105, 110, 113, 118, 121, 126, + 129, 132, 135, 138, 141, 146, 149, 152, 155, 160, + 163, 168, 171, 176, 179 }; #endif -#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +#if YYDEBUG || YYERROR_VERBOSE || 1 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = @@ -509,13 +513,13 @@ static const char *const yytname[] = "cal_DCURLY", "\"$\"", "\"{\"", "\"}\"", "cal_NAME", "\"\\\\\"", "cal_SYMBOL", "\"@\"", "cal_ERROR", "cal_ATNAME", "$accept", "Start", "GoalWithOptionalBackSlash", "Goal", "String", "OuterText", "Variable", - "EnvVarName", "MultipleIds", "ID", 0 + "EnvVarName", "MultipleIds", "ID", YY_NULLPTR }; #endif # ifdef YYPRINT -/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to - token YYLEX-NUM. */ +/* YYTOKNUM[NUM] -- (External) token number corresponding to the + (internal) symbol number NUM (which must be that of a token). */ static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, @@ -523,25 +527,29 @@ static const yytype_uint16 yytoknum[] = }; # endif -/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const yytype_uint8 yyr1[] = -{ - 0, 15, 16, 17, 17, 18, 18, 19, 19, 20, - 20, 20, 20, 20, 20, 21, 21, 21, 21, 22, - 22, 23, 23, 24, 24 -}; +#define YYPACT_NINF -3 -/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const yytype_uint8 yyr2[] = +#define yypact_value_is_default(Yystate) \ + (!!((Yystate) == (-3))) + +#define YYTABLE_NINF -1 + +#define yytable_value_is_error(Yytable_value) \ + 0 + + /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +static const yytype_int8 yypact[] = { - 0, 2, 1, 1, 2, 0, 2, 1, 1, 1, - 1, 1, 1, 1, 1, 3, 3, 3, 1, 1, - 2, 0, 2, 1, 1 + 0, 14, 26, 26, -3, -3, -3, -3, -3, -3, + -3, 10, -3, 3, 0, -3, -3, -3, 14, -3, + 7, -3, 26, 13, 16, -3, -3, -3, -3, -3, + -3, -3, -3 }; -/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state - STATE-NUM when YYTABLE doesn't specify something else to do. Zero - means the default is an error. */ + /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. + Performed when YYTABLE does not specify something else to do. Zero + means the default is an error. */ static const yytype_uint8 yydefact[] = { 5, 21, 21, 21, 11, 12, 13, 9, 14, 10, @@ -550,34 +558,21 @@ static const yytype_uint8 yydefact[] = 22, 16, 17 }; -/* YYDEFGOTO[NTERM-NUM]. */ -static const yytype_int8 yydefgoto[] = -{ - -1, 11, 12, 13, 14, 15, 19, 20, 21, 22 -}; - -/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ -#define YYPACT_NINF -3 -static const yytype_int8 yypact[] = + /* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = { - 0, 14, 26, 26, -3, -3, -3, -3, -3, -3, - -3, 10, -3, 3, 0, -3, -3, -3, 14, -3, - 7, -3, 26, 13, 16, -3, -3, -3, -3, -3, - -3, -3, -3 + -3, -3, -3, 8, -3, -3, 2, 9, -2, -3 }; -/* YYPGOTO[NTERM-NUM]. */ -static const yytype_int8 yypgoto[] = + /* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = { - -3, -3, -3, 8, -3, -3, 2, 9, -2, -3 + -1, 11, 12, 13, 14, 15, 19, 20, 21, 22 }; -/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule which - number is the opposite. If zero, do what YYDEFACT says. - If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -1 + /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule whose + number is the opposite. If YYTABLE_NINF, syntax error. */ static const yytype_uint8 yytable[] = { 23, 24, 16, 1, 2, 3, 4, 5, 6, 7, @@ -596,8 +591,8 @@ static const yytype_int8 yycheck[] = 14 }; -/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ + /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { 0, 3, 4, 5, 6, 7, 8, 9, 11, 12, @@ -606,6 +601,23 @@ static const yytype_uint8 yystos[] = 23, 8, 8 }; + /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 15, 16, 17, 17, 18, 18, 19, 19, 20, + 20, 20, 20, 20, 20, 21, 21, 21, 21, 22, + 22, 23, 23, 24, 24 +}; + + /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 1, 1, 2, 0, 2, 1, 1, 1, + 1, 1, 1, 1, 1, 3, 3, 3, 1, 1, + 2, 0, 2, 1, 1 +}; + + #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) #define YYEMPTY (-2) @@ -616,85 +628,30 @@ static const yytype_uint8 yystos[] = #define YYERROR goto yyerrorlab -/* Like YYERROR except do call yyerror. This remains here temporarily - to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. */ - -#define YYFAIL goto yyerrlab - #define YYRECOVERING() (!!yyerrstatus) #define YYBACKUP(Token, Value) \ do \ - if (yychar == YYEMPTY && yylen == 1) \ + if (yychar == YYEMPTY) \ { \ yychar = (Token); \ yylval = (Value); \ - yytoken = YYTRANSLATE (yychar); \ - YYPOPSTACK (1); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ goto yybackup; \ } \ else \ { \ - yyerror (YY_("syntax error: cannot back up")); \ + yyerror (yyscanner, YY_("syntax error: cannot back up")); \ YYERROR; \ } \ -while (YYID (0)) - +while (0) +/* Error token number */ #define YYTERROR 1 #define YYERRCODE 256 -/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. - If N is 0, then set CURRENT to the empty location which ends - the previous symbol: RHS[0] (always defined). */ - -#define YYRHSLOC(Rhs, K) ((Rhs)[K]) -#ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - do \ - if (YYID (N)) \ - { \ - (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ - (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ - (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ - (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ - } \ - else \ - { \ - (Current).first_line = (Current).last_line = \ - YYRHSLOC (Rhs, 0).last_line; \ - (Current).first_column = (Current).last_column = \ - YYRHSLOC (Rhs, 0).last_column; \ - } \ - while (YYID (0)) -#endif - - -/* YY_LOCATION_PRINT -- Print the location on the stream. - This macro was not mandated originally: define only if we know - we won't break user code: when these are the locations we know. */ - -#ifndef YY_LOCATION_PRINT -# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL -# define YY_LOCATION_PRINT(File, Loc) \ - fprintf (File, "%d.%d-%d.%d", \ - (Loc).first_line, (Loc).first_column, \ - (Loc).last_line, (Loc).last_column) -# else -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -# endif -#endif - - -/* YYLEX -- calling `yylex' with the right arguments. */ - -#ifdef YYLEX_PARAM -# define YYLEX yylex (&yylval, YYLEX_PARAM) -#else -# define YYLEX yylex (&yylval) -#endif /* Enable debugging if requested. */ #if YYDEBUG @@ -708,7 +665,13 @@ while (YYID (0)) do { \ if (yydebug) \ YYFPRINTF Args; \ -} while (YYID (0)) +} while (0) + +/* This macro is provided for backward compatibility. */ +#ifndef YY_LOCATION_PRINT +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +#endif + # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ do { \ @@ -716,42 +679,29 @@ do { \ { \ YYFPRINTF (stderr, "%s ", Title); \ yy_symbol_print (stderr, \ - Type, Value); \ + Type, Value, yyscanner); \ YYFPRINTF (stderr, "\n"); \ } \ -} while (YYID (0)) +} while (0) -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ +/*----------------------------------------. +| Print this symbol's value on YYOUTPUT. | +`----------------------------------------*/ -/*ARGSUSED*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) static void -yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) -#else -static void -yy_symbol_value_print (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE const * const yyvaluep; -#endif +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner) { + FILE *yyo = yyoutput; + YYUSE (yyo); + YYUSE (yyscanner); if (!yyvaluep) return; # ifdef YYPRINT if (yytype < YYNTOKENS) YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); -# else - YYUSE (yyoutput); # endif - switch (yytype) - { - default: - break; - } + YYUSE (yytype); } @@ -759,24 +709,13 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep) | Print this symbol on YYOUTPUT. | `--------------------------------*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) static void -yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) -#else -static void -yy_symbol_print (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE const * const yyvaluep; -#endif +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner) { - if (yytype < YYNTOKENS) - YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); - else - YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + YYFPRINTF (yyoutput, "%s %s (", + yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); - yy_symbol_value_print (yyoutput, yytype, yyvaluep); + yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner); YYFPRINTF (yyoutput, ")"); } @@ -785,20 +724,15 @@ yy_symbol_print (yyoutput, yytype, yyvaluep) | TOP (included). | `------------------------------------------------------------------*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) static void -yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) -#else -static void -yy_stack_print (bottom, top) - yytype_int16 *bottom; - yytype_int16 *top; -#endif +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) { YYFPRINTF (stderr, "Stack now"); - for (; bottom <= top; ++bottom) - YYFPRINTF (stderr, " %d", *bottom); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } YYFPRINTF (stderr, "\n"); } @@ -806,45 +740,38 @@ yy_stack_print (bottom, top) do { \ if (yydebug) \ yy_stack_print ((Bottom), (Top)); \ -} while (YYID (0)) +} while (0) /*------------------------------------------------. | Report that the YYRULE is going to be reduced. | `------------------------------------------------*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) static void -yy_reduce_print (YYSTYPE *yyvsp, int yyrule) -#else -static void -yy_reduce_print (yyvsp, yyrule) - YYSTYPE *yyvsp; - int yyrule; -#endif +yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, yyscan_t yyscanner) { + unsigned long int yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; - unsigned long int yylno = yyrline[yyrule]; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { - fprintf (stderr, " $%d = ", yyi + 1); - yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + YYFPRINTF (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, + yystos[yyssp[yyi + 1 - yynrhs]], &(yyvsp[(yyi + 1) - (yynrhs)]) - ); - fprintf (stderr, "\n"); + , yyscanner); + YYFPRINTF (stderr, "\n"); } } # define YY_REDUCE_PRINT(Rule) \ do { \ if (yydebug) \ - yy_reduce_print (yyvsp, Rule); \ -} while (YYID (0)) + yy_reduce_print (yyssp, yyvsp, Rule, yyscanner); \ +} while (0) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ @@ -873,7 +800,6 @@ int yydebug; # define YYMAXDEPTH 10000 #endif - #if YYERROR_VERBOSE @@ -882,15 +808,8 @@ int yydebug; # define yystrlen strlen # else /* Return the length of YYSTR. */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) static YYSIZE_T yystrlen (const char *yystr) -#else -static YYSIZE_T -yystrlen (yystr) - const char *yystr; -#endif { YYSIZE_T yylen; for (yylen = 0; yystr[yylen]; yylen++) @@ -906,16 +825,8 @@ yystrlen (yystr) # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) static char * yystpcpy (char *yydest, const char *yysrc) -#else -static char * -yystpcpy (yydest, yysrc) - char *yydest; - const char *yysrc; -#endif { char *yyd = yydest; const char *yys = yysrc; @@ -976,165 +887,159 @@ yytnamerr (char *yyres, const char *yystr) } # endif -/* Copy into YYRESULT an error message about the unexpected token - YYCHAR while in state YYSTATE. Return the number of bytes copied, - including the terminating null byte. If YYRESULT is null, do not - copy anything; just return the number of bytes that would be - copied. As a special case, return 0 if an ordinary "syntax error" - message will do. Return YYSIZE_MAXIMUM if overflow occurs during - size calculation. */ -static YYSIZE_T -yysyntax_error (char *yyresult, int yystate, int yychar) -{ - int yyn = yypact[yystate]; +/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message + about the unexpected token YYTOKEN for the state stack whose top is + YYSSP. - if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) - return 0; - else + Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is + not large enough to hold the message. In that case, also set + *YYMSG_ALLOC to the required number of bytes. Return 2 if the + required number of bytes is too large to store. */ +static int +yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, + yytype_int16 *yyssp, int yytoken) +{ + YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); + YYSIZE_T yysize = yysize0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + /* Internationalized format string. */ + const char *yyformat = YY_NULLPTR; + /* Arguments of yyformat. */ + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + /* Number of reported tokens (one for the "unexpected", one per + "expected"). */ + int yycount = 0; + + /* There are many possibilities here to consider: + - If this state is a consistent state with a default action, then + the only way this function was invoked is if the default action + is an error action. In that case, don't check for expected + tokens because there are none. + - The only way there can be no lookahead present (in yychar) is if + this state is a consistent state with a default action. Thus, + detecting the absence of a lookahead is sufficient to determine + that there is no unexpected or expected token to report. In that + case, just report a simple "syntax error". + - Don't assume there isn't a lookahead just because this state is a + consistent state with a default action. There might have been a + previous inconsistent state, consistent state with a non-default + action, or user semantic action that manipulated yychar. + - Of course, the expected token list depends on states to have + correct lookahead information, and it depends on the parser not + to perform extra reductions after fetching a lookahead from the + scanner and before detecting a syntax error. Thus, state merging + (from LALR or IELR) and default reductions corrupt the expected + token list. However, the list is correct for canonical LR with + one exception: it will still contain any token that will not be + accepted due to an error action in a later state. + */ + if (yytoken != YYEMPTY) { - int yytype = YYTRANSLATE (yychar); - YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); - YYSIZE_T yysize = yysize0; - YYSIZE_T yysize1; - int yysize_overflow = 0; - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - int yyx; - -# if 0 - /* This is so xgettext sees the translatable formats that are - constructed on the fly. */ - YY_("syntax error, unexpected %s"); - YY_("syntax error, unexpected %s, expecting %s"); - YY_("syntax error, unexpected %s, expecting %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); -# endif - char *yyfmt; - char const *yyf; - static char const yyunexpected[] = "syntax error, unexpected %s"; - static char const yyexpecting[] = ", expecting %s"; - static char const yyor[] = " or %s"; - char yyformat[sizeof yyunexpected - + sizeof yyexpecting - 1 - + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) - * (sizeof yyor - 1))]; - char const *yyprefix = yyexpecting; - - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn + 1; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yycount = 1; - - yyarg[0] = yytname[yytype]; - yyfmt = yystpcpy (yyformat, yyunexpected); - - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + int yyn = yypact[*yyssp]; + yyarg[yycount++] = yytname[yytoken]; + if (!yypact_value_is_default (yyn)) + { + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. In other words, skip the first -YYN actions for + this state because they are default actions. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yyx; + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR + && !yytable_value_is_error (yytable[yyx + yyn])) { - yycount = 1; - yysize = yysize0; - yyformat[sizeof yyunexpected - 1] = '\0'; - break; + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + break; + } + yyarg[yycount++] = yytname[yyx]; + { + YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); + if (! (yysize <= yysize1 + && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } } - yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yytnamerr (0, yytname[yyx]); - yysize_overflow |= (yysize1 < yysize); - yysize = yysize1; - yyfmt = yystpcpy (yyfmt, yyprefix); - yyprefix = yyor; - } + } + } + + switch (yycount) + { +# define YYCASE_(N, S) \ + case N: \ + yyformat = S; \ + break + YYCASE_(0, YY_("syntax error")); + YYCASE_(1, YY_("syntax error, unexpected %s")); + YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); + YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); + YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); + YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); +# undef YYCASE_ + } - yyf = YY_(yyformat); - yysize1 = yysize + yystrlen (yyf); - yysize_overflow |= (yysize1 < yysize); - yysize = yysize1; + { + YYSIZE_T yysize1 = yysize + yystrlen (yyformat); + if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } - if (yysize_overflow) - return YYSIZE_MAXIMUM; + if (*yymsg_alloc < yysize) + { + *yymsg_alloc = 2 * yysize; + if (! (yysize <= *yymsg_alloc + && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) + *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; + return 1; + } - if (yyresult) + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + { + char *yyp = *yymsg; + int yyi = 0; + while ((*yyp = *yyformat) != '\0') + if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) { - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - char *yyp = yyresult; - int yyi = 0; - while ((*yyp = *yyf) != '\0') - { - if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyf += 2; - } - else - { - yyp++; - yyf++; - } - } + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyformat += 2; } - return yysize; - } + else + { + yyp++; + yyformat++; + } + } + return 0; } #endif /* YYERROR_VERBOSE */ - /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ -/*ARGSUSED*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) -#else static void -yydestruct (yymsg, yytype, yyvaluep) - const char *yymsg; - int yytype; - YYSTYPE *yyvaluep; -#endif +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, yyscan_t yyscanner) { YYUSE (yyvaluep); - + YYUSE (yyscanner); if (!yymsg) yymsg = "Deleting"; YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); - switch (yytype) - { - - default: - break; - } + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + YYUSE (yytype); + YY_IGNORE_MAYBE_UNINITIALIZED_END } - - -/* Prevent warnings from -Wmissing-prototypes. */ - -#ifdef YYPARSE_PARAM -#if defined __STDC__ || defined __cplusplus -int yyparse (void *YYPARSE_PARAM); -#else -int yyparse (); -#endif -#else /* ! YYPARSE_PARAM */ -#if defined __STDC__ || defined __cplusplus -int yyparse (void); -#else -int yyparse (); -#endif -#endif /* ! YYPARSE_PARAM */ - - @@ -1143,99 +1048,76 @@ int yyparse (); | yyparse. | `----------*/ -#ifdef YYPARSE_PARAM -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -int -yyparse (void *YYPARSE_PARAM) -#else -int -yyparse (YYPARSE_PARAM) - void *YYPARSE_PARAM; -#endif -#else /* ! YYPARSE_PARAM */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) int -yyparse (void) -#else -int -yyparse () - -#endif -#endif +yyparse (yyscan_t yyscanner) { - /* The look-ahead symbol. */ +/* The lookahead symbol. */ int yychar; -/* The semantic value of the look-ahead symbol. */ -YYSTYPE yylval; - -/* Number of syntax errors so far. */ -int yynerrs; - - int yystate; - int yyn; - int yyresult; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - /* Look-ahead token as an internal (translated) token number. */ - int yytoken = 0; -#if YYERROR_VERBOSE - /* Buffer for error messages, and its allocated size. */ - char yymsgbuf[128]; - char *yymsg = yymsgbuf; - YYSIZE_T yymsg_alloc = sizeof yymsgbuf; -#endif - /* Three stacks and their tools: - `yyss': related to states, - `yyvs': related to semantic values, - `yyls': related to locations. +/* The semantic value of the lookahead symbol. */ +/* Default value used for initialization, for pacifying older GCCs + or non-GCC compilers. */ +YY_INITIAL_VALUE (static YYSTYPE yyval_default;) +YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ + /* Number of syntax errors so far. */ + int yynerrs; - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss = yyssa; - yytype_int16 *yyssp; + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - YYSTYPE *yyvsp; + /* The stacks and their tools: + 'yyss': related to states. + 'yyvs': related to semantic values. + Refer to the stacks through separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; -#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; - YYSIZE_T yystacksize = YYINITDEPTH; + YYSIZE_T yystacksize; + int yyn; + int yyresult; + /* Lookahead token as an internal (translated) token number. */ + int yytoken = 0; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ int yylen = 0; + yyssp = yyss = yyssa; + yyvsp = yyvs = yyvsa; + yystacksize = YYINITDEPTH; + YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ - - /* Initialize stack pointers. - Waste one element of value and location stack - so that they stay on the same level as the state stack. - The wasted elements are never initialized. */ - - yyssp = yyss; - yyvsp = yyvs; - + yychar = YYEMPTY; /* Cause a token to be read. */ goto yysetstate; /*------------------------------------------------------------. @@ -1262,7 +1144,6 @@ int yynerrs; YYSTYPE *yyvs1 = yyvs; yytype_int16 *yyss1 = yyss; - /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might @@ -1270,7 +1151,6 @@ int yynerrs; yyoverflow (YY_("memory exhausted"), &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), - &yystacksize); yyss = yyss1; @@ -1293,9 +1173,8 @@ int yynerrs; (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss); - YYSTACK_RELOCATE (yyvs); - + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); @@ -1306,7 +1185,6 @@ int yynerrs; yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; - YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); @@ -1316,6 +1194,9 @@ int yynerrs; YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + if (yystate == YYFINAL) + YYACCEPT; + goto yybackup; /*-----------. @@ -1324,20 +1205,20 @@ int yynerrs; yybackup: /* Do appropriate processing given the current state. Read a - look-ahead token if we need one and don't already have one. */ + lookahead token if we need one and don't already have one. */ - /* First try to decide what to do without reference to look-ahead token. */ + /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; - if (yyn == YYPACT_NINF) + if (yypact_value_is_default (yyn)) goto yydefault; - /* Not known => get a look-ahead token if don't already have one. */ + /* Not known => get a lookahead token if don't already have one. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); - yychar = YYLEX; + yychar = yylex (&yylval, yyscanner); } if (yychar <= YYEOF) @@ -1359,29 +1240,27 @@ yybackup: yyn = yytable[yyn]; if (yyn <= 0) { - if (yyn == 0 || yyn == YYTABLE_NINF) + if (yytable_value_is_error (yyn)) goto yyerrlab; yyn = -yyn; goto yyreduce; } - if (yyn == YYFINAL) - YYACCEPT; - /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; - /* Shift the look-ahead token. */ + /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - /* Discard the shifted token unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; + /* Discard the shifted token. */ + yychar = YYEMPTY; yystate = yyn; + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END goto yynewstate; @@ -1404,7 +1283,7 @@ yyreduce: yylen = yyr2[yyn]; /* If YYLEN is nonzero, implement the default value of the action: - `$$ = $1'. + '$$ = $1'. Otherwise, the following line sets YYVAL to garbage. This behavior is undocumented and Bison @@ -1418,175 +1297,205 @@ yyreduce: switch (yyn) { case 2: -#line 117 "cmCommandArgumentParser.y" +#line 96 "cmCommandArgumentParser.y" /* yacc.c:1646 */ { - (yyval.str) = 0; - yyGetParser->SetResult((yyvsp[(1) - (1)].str)); -} + (yyval.str) = 0; + yyGetParser->SetResult((yyvsp[0].str)); + } +#line 1306 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */ break; case 3: -#line 124 "cmCommandArgumentParser.y" +#line 102 "cmCommandArgumentParser.y" /* yacc.c:1646 */ { - (yyval.str) = (yyvsp[(1) - (1)].str); -} + (yyval.str) = (yyvsp[0].str); + } +#line 1314 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */ break; case 4: -#line 129 "cmCommandArgumentParser.y" +#line 105 "cmCommandArgumentParser.y" /* yacc.c:1646 */ { - (yyval.str) = yyGetParser->CombineUnions((yyvsp[(1) - (2)].str), (yyvsp[(2) - (2)].str)); -} + (yyval.str) = yyGetParser->CombineUnions((yyvsp[-1].str), (yyvsp[0].str)); + } +#line 1322 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */ break; case 5: -#line 134 "cmCommandArgumentParser.y" +#line 110 "cmCommandArgumentParser.y" /* yacc.c:1646 */ { - (yyval.str) = 0; -} + (yyval.str) = 0; + } +#line 1330 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */ break; case 6: -#line 139 "cmCommandArgumentParser.y" +#line 113 "cmCommandArgumentParser.y" /* yacc.c:1646 */ { - (yyval.str) = yyGetParser->CombineUnions((yyvsp[(1) - (2)].str), (yyvsp[(2) - (2)].str)); -} + (yyval.str) = yyGetParser->CombineUnions((yyvsp[-1].str), (yyvsp[0].str)); + } +#line 1338 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */ break; case 7: -#line 145 "cmCommandArgumentParser.y" +#line 118 "cmCommandArgumentParser.y" /* yacc.c:1646 */ { - (yyval.str) = (yyvsp[(1) - (1)].str); -} + (yyval.str) = (yyvsp[0].str); + } +#line 1346 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */ break; case 8: -#line 150 "cmCommandArgumentParser.y" +#line 121 "cmCommandArgumentParser.y" /* yacc.c:1646 */ { - (yyval.str) = (yyvsp[(1) - (1)].str); -} + (yyval.str) = (yyvsp[0].str); + } +#line 1354 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */ break; case 9: -#line 156 "cmCommandArgumentParser.y" +#line 126 "cmCommandArgumentParser.y" /* yacc.c:1646 */ { - (yyval.str) = (yyvsp[(1) - (1)].str); -} + (yyval.str) = (yyvsp[0].str); + } +#line 1362 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */ break; case 10: -#line 161 "cmCommandArgumentParser.y" +#line 129 "cmCommandArgumentParser.y" /* yacc.c:1646 */ { - (yyval.str) = (yyvsp[(1) - (1)].str); -} + (yyval.str) = (yyvsp[0].str); + } +#line 1370 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */ break; case 11: -#line 166 "cmCommandArgumentParser.y" +#line 132 "cmCommandArgumentParser.y" /* yacc.c:1646 */ { - (yyval.str) = (yyvsp[(1) - (1)].str); -} + (yyval.str) = (yyvsp[0].str); + } +#line 1378 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */ break; case 12: -#line 171 "cmCommandArgumentParser.y" +#line 135 "cmCommandArgumentParser.y" /* yacc.c:1646 */ { - (yyval.str) = (yyvsp[(1) - (1)].str); -} + (yyval.str) = (yyvsp[0].str); + } +#line 1386 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */ break; case 13: -#line 176 "cmCommandArgumentParser.y" +#line 138 "cmCommandArgumentParser.y" /* yacc.c:1646 */ { - (yyval.str) = (yyvsp[(1) - (1)].str); -} + (yyval.str) = (yyvsp[0].str); + } +#line 1394 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */ break; case 14: -#line 181 "cmCommandArgumentParser.y" +#line 141 "cmCommandArgumentParser.y" /* yacc.c:1646 */ { - (yyval.str) = (yyvsp[(1) - (1)].str); -} + (yyval.str) = (yyvsp[0].str); + } +#line 1402 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */ break; case 15: -#line 187 "cmCommandArgumentParser.y" +#line 146 "cmCommandArgumentParser.y" /* yacc.c:1646 */ { - (yyval.str) = yyGetParser->ExpandSpecialVariable((yyvsp[(1) - (3)].str),(yyvsp[(2) - (3)].str)); - //std::cerr << __LINE__ << " here: [" << $<str>1 << "] [" << $<str>2 << "] [" << $<str>3 << "]" << std::endl; -} + (yyval.str) = yyGetParser->ExpandSpecialVariable((yyvsp[-2].str), (yyvsp[-1].str)); + } +#line 1410 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */ break; case 16: -#line 193 "cmCommandArgumentParser.y" +#line 149 "cmCommandArgumentParser.y" /* yacc.c:1646 */ { - (yyval.str) = yyGetParser->ExpandSpecialVariable((yyvsp[(1) - (3)].str),(yyvsp[(2) - (3)].str)); - //std::cerr << __LINE__ << " here: [" << $<str>1 << "] [" << $<str>2 << "] [" << $<str>3 << "]" << std::endl; -} + (yyval.str) = yyGetParser->ExpandSpecialVariable((yyvsp[-2].str), (yyvsp[-1].str)); + } +#line 1418 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */ break; case 17: -#line 199 "cmCommandArgumentParser.y" +#line 152 "cmCommandArgumentParser.y" /* yacc.c:1646 */ { - (yyval.str) = yyGetParser->ExpandVariable((yyvsp[(2) - (3)].str)); - //std::cerr << __LINE__ << " here: [" << $<str>1 << "] [" << $<str>2 << "] [" << $<str>3 << "]" << std::endl; -} + (yyval.str) = yyGetParser->ExpandVariable((yyvsp[-1].str)); + } +#line 1426 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */ break; case 18: -#line 205 "cmCommandArgumentParser.y" +#line 155 "cmCommandArgumentParser.y" /* yacc.c:1646 */ { - (yyval.str) = yyGetParser->ExpandVariableForAt((yyvsp[(1) - (1)].str)); -} + (yyval.str) = yyGetParser->ExpandVariableForAt((yyvsp[0].str)); + } +#line 1434 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */ break; case 19: -#line 211 "cmCommandArgumentParser.y" +#line 160 "cmCommandArgumentParser.y" /* yacc.c:1646 */ { - (yyval.str) = (yyvsp[(1) - (1)].str); -} + (yyval.str) = (yyvsp[0].str); + } +#line 1442 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */ break; case 20: -#line 216 "cmCommandArgumentParser.y" +#line 163 "cmCommandArgumentParser.y" /* yacc.c:1646 */ { - (yyval.str) = (yyvsp[(1) - (2)].str); -} + (yyval.str) = (yyvsp[-1].str); + } +#line 1450 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */ break; case 21: -#line 221 "cmCommandArgumentParser.y" +#line 168 "cmCommandArgumentParser.y" /* yacc.c:1646 */ { - (yyval.str) = 0; -} + (yyval.str) = 0; + } +#line 1458 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */ break; case 22: -#line 226 "cmCommandArgumentParser.y" +#line 171 "cmCommandArgumentParser.y" /* yacc.c:1646 */ { - (yyval.str) = yyGetParser->CombineUnions((yyvsp[(1) - (2)].str), (yyvsp[(2) - (2)].str)); -} + (yyval.str) = yyGetParser->CombineUnions((yyvsp[-1].str), (yyvsp[0].str)); + } +#line 1466 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */ break; case 23: -#line 232 "cmCommandArgumentParser.y" +#line 176 "cmCommandArgumentParser.y" /* yacc.c:1646 */ { - (yyval.str) = (yyvsp[(1) - (1)].str); -} + (yyval.str) = (yyvsp[0].str); + } +#line 1474 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */ break; case 24: -#line 237 "cmCommandArgumentParser.y" +#line 179 "cmCommandArgumentParser.y" /* yacc.c:1646 */ { - (yyval.str) = (yyvsp[(1) - (1)].str); -} + (yyval.str) = (yyvsp[0].str); + } +#line 1482 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */ break; -/* Line 1267 of yacc.c. */ -#line 1606 "cmCommandArgumentParser.cxx" +#line 1486 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */ default: break; } + /* User semantic actions sometimes alter yychar, and that requires + that yytoken be updated with the new translation. We take the + approach of translating immediately before every use of yytoken. + One alternative is translating here after every semantic action, + but that translation would be missed if the semantic action invokes + YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or + if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an + incorrect destructor might then be invoked immediately. In the + case of YYERROR or YYBACKUP, subsequent parser actions might lead + to an incorrect destructor call or verbose syntax error message + before the lookahead is translated. */ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); YYPOPSTACK (yylen); @@ -1595,8 +1504,7 @@ yyreduce: *++yyvsp = yyval; - - /* Now `shift' the result of the reduction. Determine what state + /* Now 'shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ @@ -1611,48 +1519,51 @@ yyreduce: goto yynewstate; -/*------------------------------------. -| yyerrlab -- here on detecting error | -`------------------------------------*/ +/*--------------------------------------. +| yyerrlab -- here on detecting error. | +`--------------------------------------*/ yyerrlab: + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); + /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs; #if ! YYERROR_VERBOSE - yyerror (YY_("syntax error")); + yyerror (yyscanner, YY_("syntax error")); #else +# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ + yyssp, yytoken) { - YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); - if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + char const *yymsgp = YY_("syntax error"); + int yysyntax_error_status; + yysyntax_error_status = YYSYNTAX_ERROR; + if (yysyntax_error_status == 0) + yymsgp = yymsg; + else if (yysyntax_error_status == 1) { - YYSIZE_T yyalloc = 2 * yysize; - if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) - yyalloc = YYSTACK_ALLOC_MAXIMUM; if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); - yymsg = (char *) YYSTACK_ALLOC (yyalloc); - if (yymsg) - yymsg_alloc = yyalloc; - else + yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); + if (!yymsg) { yymsg = yymsgbuf; yymsg_alloc = sizeof yymsgbuf; + yysyntax_error_status = 2; + } + else + { + yysyntax_error_status = YYSYNTAX_ERROR; + yymsgp = yymsg; } } - - if (0 < yysize && yysize <= yymsg_alloc) - { - (void) yysyntax_error (yymsg, yystate, yychar); - yyerror (yymsg); - } - else - { - yyerror (YY_("syntax error")); - if (yysize != 0) - goto yyexhaustedlab; - } + yyerror (yyscanner, yymsgp); + if (yysyntax_error_status == 2) + goto yyexhaustedlab; } +# undef YYSYNTAX_ERROR #endif } @@ -1660,7 +1571,7 @@ yyerrlab: if (yyerrstatus == 3) { - /* If just tried and failed to reuse look-ahead token after an + /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= YYEOF) @@ -1672,12 +1583,13 @@ yyerrlab: else { yydestruct ("Error: discarding", - yytoken, &yylval); + yytoken, &yylval, yyscanner); yychar = YYEMPTY; } } - /* Else will try to reuse look-ahead token after shifting the error +#if 0 + /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; @@ -1693,7 +1605,7 @@ yyerrorlab: if (/*CONSTCOND*/ 0) goto yyerrorlab; - /* Do not reclaim the symbols of the rule which action triggered + /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ YYPOPSTACK (yylen); yylen = 0; @@ -1706,12 +1618,13 @@ yyerrorlab: | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ yyerrlab1: +#endif yyerrstatus = 3; /* Each real token shifted decrements this. */ for (;;) { yyn = yypact[yystate]; - if (yyn != YYPACT_NINF) + if (!yypact_value_is_default (yyn)) { yyn += YYTERROR; if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) @@ -1728,16 +1641,15 @@ yyerrlab1: yydestruct ("Error: popping", - yystos[yystate], yyvsp); + yystos[yystate], yyvsp, yyscanner); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); } - if (yyn == YYFINAL) - YYACCEPT; - + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END /* Shift the error token. */ @@ -1761,28 +1673,33 @@ yyabortlab: yyresult = 1; goto yyreturn; -#ifndef yyoverflow +#if !defined yyoverflow || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ yyexhaustedlab: - yyerror (YY_("memory exhausted")); + yyerror (yyscanner, YY_("memory exhausted")); yyresult = 2; /* Fall through. */ #endif yyreturn: - if (yychar != YYEOF && yychar != YYEMPTY) - yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval); - /* Do not reclaim the symbols of the rule which action triggered + if (yychar != YYEMPTY) + { + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = YYTRANSLATE (yychar); + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, yyscanner); + } + /* Do not reclaim the symbols of the rule whose action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); YY_STACK_PRINT (yyss, yyssp); while (yyssp != yyss) { yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp); + yystos[*yyssp], yyvsp, yyscanner); YYPOPSTACK (1); } #ifndef yyoverflow @@ -1793,19 +1710,14 @@ yyreturn: if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); #endif - /* Make sure YYID is used. */ - return YYID (yyresult); + return yyresult; } - - -#line 242 "cmCommandArgumentParser.y" +#line 184 "cmCommandArgumentParser.y" /* yacc.c:1906 */ /* End of grammar */ /*--------------------------------------------------------------------------*/ -void cmCommandArgumentError(yyscan_t yyscanner, const char* message) +void cmCommandArgument_yyerror(yyscan_t yyscanner, const char* message) { yyGetParser->Error(message); } - - diff --git a/Source/cmCommandArgumentParser.y b/Source/cmCommandArgumentParser.y index b2f4b1b..d6c8312 100644 --- a/Source/cmCommandArgumentParser.y +++ b/Source/cmCommandArgumentParser.y @@ -10,20 +10,14 @@ Run bison like this: bison --yacc --name-prefix=cmCommandArgument_yy --defines=cmCommandArgumentParserTokens.h -ocmCommandArgumentParser.cxx cmCommandArgumentParser.y Modify cmCommandArgumentParser.cxx: - - remove TABs - - remove use of the 'register' storage class specifier - - put header block at top of file + - "#if 0" out yyerrorlab block in range ["goto yyerrlab1", "yyerrlab1:"] */ -#include "cmStandardIncludes.h" +#include "cmConfigure.h" // IWYU pragma: keep + +#include <string.h> -/* Configure the parser to use a lexer object. */ -#define YYPARSE_PARAM yyscanner -#define YYLEX_PARAM yyscanner -#define YYERROR_VERBOSE 1 -#define cmCommandArgument_yyerror(x) \ - cmCommandArgumentError(yyscanner, x) #define yyGetParser (cmCommandArgument_yyget_extra(yyscanner)) /* Make sure malloc and free are available on QNX. */ @@ -46,10 +40,9 @@ Modify cmCommandArgumentParser.cxx: /* Forward declare the lexer entry point. */ YY_DECL; -/* Internal utility functions. */ -static void cmCommandArgumentError(yyscan_t yyscanner, const char* message); +/* Helper function to forward error callback from parser. */ +static void cmCommandArgument_yyerror(yyscan_t yyscanner, const char* message); -#define YYDEBUG 1 /* Configure the parser to support large input. */ #define YYMAXDEPTH 100000 #define YYINITDEPTH 10000 @@ -65,7 +58,13 @@ static void cmCommandArgumentError(yyscan_t yyscanner, const char* message); %} /* Generate a reentrant parser object. */ -%pure_parser +%define api.pure + +/* Configure the parser to use a lexer object. */ +%lex-param {yyscan_t yyscanner} +%parse-param {yyscan_t yyscanner} + +%define parse.error verbose /* %union { @@ -94,137 +93,99 @@ static void cmCommandArgumentError(yyscan_t yyscanner, const char* message); Start: -GoalWithOptionalBackSlash -{ - $<str>$ = 0; - yyGetParser->SetResult($<str>1); -} + GoalWithOptionalBackSlash { + $<str>$ = 0; + yyGetParser->SetResult($<str>1); + } GoalWithOptionalBackSlash: -Goal -{ - $<str>$ = $<str>1; -} -| -Goal cal_BSLASH -{ - $<str>$ = yyGetParser->CombineUnions($<str>1, $<str>2); -} + Goal { + $<str>$ = $<str>1; + } +| Goal cal_BSLASH { + $<str>$ = yyGetParser->CombineUnions($<str>1, $<str>2); + } Goal: -{ - $<str>$ = 0; -} -| -String Goal -{ - $<str>$ = yyGetParser->CombineUnions($<str>1, $<str>2); -} + { + $<str>$ = 0; + } +| String Goal { + $<str>$ = yyGetParser->CombineUnions($<str>1, $<str>2); + } String: -OuterText -{ - $<str>$ = $<str>1; -} -| -Variable -{ - $<str>$ = $<str>1; -} + OuterText { + $<str>$ = $<str>1; + } +| Variable { + $<str>$ = $<str>1; + } OuterText: -cal_NAME -{ - $<str>$ = $<str>1; -} -| -cal_AT -{ - $<str>$ = $<str>1; -} -| -cal_DOLLAR -{ - $<str>$ = $<str>1; -} -| -cal_LCURLY -{ - $<str>$ = $<str>1; -} -| -cal_RCURLY -{ - $<str>$ = $<str>1; -} -| -cal_SYMBOL -{ - $<str>$ = $<str>1; -} + cal_NAME { + $<str>$ = $<str>1; + } +| cal_AT { + $<str>$ = $<str>1; + } +| cal_DOLLAR { + $<str>$ = $<str>1; + } +| cal_LCURLY { + $<str>$ = $<str>1; + } +| cal_RCURLY { + $<str>$ = $<str>1; + } +| cal_SYMBOL { + $<str>$ = $<str>1; + } Variable: -cal_ENVCURLY EnvVarName cal_RCURLY -{ - $<str>$ = yyGetParser->ExpandSpecialVariable($<str>1,$<str>2); - //std::cerr << __LINE__ << " here: [" << $<str>1 << "] [" << $<str>2 << "] [" << $<str>3 << "]" << std::endl; -} -| -cal_NCURLY MultipleIds cal_RCURLY -{ - $<str>$ = yyGetParser->ExpandSpecialVariable($<str>1,$<str>2); - //std::cerr << __LINE__ << " here: [" << $<str>1 << "] [" << $<str>2 << "] [" << $<str>3 << "]" << std::endl; -} -| -cal_DCURLY MultipleIds cal_RCURLY -{ - $<str>$ = yyGetParser->ExpandVariable($<str>2); - //std::cerr << __LINE__ << " here: [" << $<str>1 << "] [" << $<str>2 << "] [" << $<str>3 << "]" << std::endl; -} -| -cal_ATNAME -{ - $<str>$ = yyGetParser->ExpandVariableForAt($<str>1); -} + cal_ENVCURLY EnvVarName cal_RCURLY { + $<str>$ = yyGetParser->ExpandSpecialVariable($<str>1, $<str>2); + } +| cal_NCURLY MultipleIds cal_RCURLY { + $<str>$ = yyGetParser->ExpandSpecialVariable($<str>1, $<str>2); + } +| cal_DCURLY MultipleIds cal_RCURLY { + $<str>$ = yyGetParser->ExpandVariable($<str>2); + } +| cal_ATNAME { + $<str>$ = yyGetParser->ExpandVariableForAt($<str>1); + } EnvVarName: -MultipleIds -{ - $<str>$ = $<str>1; -} -| -cal_SYMBOL EnvVarName -{ - $<str>$ = $<str>1; -} + MultipleIds { + $<str>$ = $<str>1; + } +| cal_SYMBOL EnvVarName { + $<str>$ = $<str>1; + } MultipleIds: -{ - $<str>$ = 0; -} -| -ID MultipleIds -{ - $<str>$ = yyGetParser->CombineUnions($<str>1, $<str>2); -} + { + $<str>$ = 0; + } +| ID MultipleIds { + $<str>$ = yyGetParser->CombineUnions($<str>1, $<str>2); + } ID: -cal_NAME -{ - $<str>$ = $<str>1; -} -| -Variable -{ - $<str>$ = $<str>1; -} - + cal_NAME { + $<str>$ = $<str>1; + } +| Variable { + $<str>$ = $<str>1; + } +; %% /* End of grammar */ /*--------------------------------------------------------------------------*/ -void cmCommandArgumentError(yyscan_t yyscanner, const char* message) +void cmCommandArgument_yyerror(yyscan_t yyscanner, const char* message) { yyGetParser->Error(message); } diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx index 2d66344..153efc4 100644 --- a/Source/cmCommandArgumentParserHelper.cxx +++ b/Source/cmCommandArgumentParserHelper.cxx @@ -2,15 +2,13 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCommandArgumentParserHelper.h" -#include <cm_kwiml.h> - #include "cmCommandArgumentLexer.h" #include "cmMakefile.h" #include "cmState.h" #include "cmSystemTools.h" #include "cmake.h" -#include <cmConfigure.h> +#include "cmConfigure.h" #include <iostream> #include <sstream> #include <string.h> diff --git a/Source/cmCommandArgumentParserHelper.h b/Source/cmCommandArgumentParserHelper.h index 95bf0ad..c0c1cd9 100644 --- a/Source/cmCommandArgumentParserHelper.h +++ b/Source/cmCommandArgumentParserHelper.h @@ -3,32 +3,20 @@ #ifndef cmCommandArgumentParserHelper_h #define cmCommandArgumentParserHelper_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> -#define YYSTYPE cmCommandArgumentParserHelper::ParserType -#define YYSTYPE_IS_DECLARED -#define YY_EXTRA_TYPE cmCommandArgumentParserHelper* -#define YY_DECL \ - int cmCommandArgument_yylex(YYSTYPE* yylvalp, yyscan_t yyscanner) - -/** \class cmCommandArgumentParserHelper - * \brief Helper class for parsing java source files - * - * Finds dependencies for java file and list of outputs - */ - class cmMakefile; class cmCommandArgumentParserHelper { public: - typedef struct + struct ParserType { char* str; - } ParserType; + }; cmCommandArgumentParserHelper(); ~cmCommandArgumentParserHelper(); @@ -72,6 +60,10 @@ public: char BSLASHVariable[3]; private: + cmCommandArgumentParserHelper(cmCommandArgumentParserHelper const&); + cmCommandArgumentParserHelper& operator=( + cmCommandArgumentParserHelper const&); + std::string::size_type InputBufferPos; std::string InputBuffer; std::vector<char> OutputBuffer; @@ -100,4 +92,10 @@ private: bool RemoveEmpty; }; +#define YYSTYPE cmCommandArgumentParserHelper::ParserType +#define YYSTYPE_IS_DECLARED +#define YY_EXTRA_TYPE cmCommandArgumentParserHelper* +#define YY_DECL \ + int cmCommandArgument_yylex(YYSTYPE* yylvalp, yyscan_t yyscanner) + #endif diff --git a/Source/cmCommandArgumentParserTokens.h b/Source/cmCommandArgumentParserTokens.h index d162b82..3172182 100644 --- a/Source/cmCommandArgumentParserTokens.h +++ b/Source/cmCommandArgumentParserTokens.h @@ -1,16 +1,13 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -/* A Bison parser, made by GNU Bison 2.3. */ +/* A Bison parser, made by GNU Bison 3.0.4. */ -/* Skeleton interface for Bison's Yacc-like parsers in C +/* Bison interface for Yacc-like parsers in C - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. - This program is free software; you can redistribute it and/or modify + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -18,9 +15,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ + along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -35,25 +30,34 @@ This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ -/* Tokens. */ +#ifndef YY_CMCOMMANDARGUMENT_YY_CMCOMMANDARGUMENTPARSERTOKENS_H_INCLUDED +# define YY_CMCOMMANDARGUMENT_YY_CMCOMMANDARGUMENTPARSERTOKENS_H_INCLUDED +/* Debug traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif +#if YYDEBUG +extern int cmCommandArgument_yydebug; +#endif + +/* Token type. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - cal_ENVCURLY = 258, - cal_NCURLY = 259, - cal_DCURLY = 260, - cal_DOLLAR = 261, - cal_LCURLY = 262, - cal_RCURLY = 263, - cal_NAME = 264, - cal_BSLASH = 265, - cal_SYMBOL = 266, - cal_AT = 267, - cal_ERROR = 268, - cal_ATNAME = 269 - }; + enum yytokentype + { + cal_ENVCURLY = 258, + cal_NCURLY = 259, + cal_DCURLY = 260, + cal_DOLLAR = 261, + cal_LCURLY = 262, + cal_RCURLY = 263, + cal_NAME = 264, + cal_BSLASH = 265, + cal_SYMBOL = 266, + cal_AT = 267, + cal_ERROR = 268, + cal_ATNAME = 269 + }; #endif /* Tokens. */ #define cal_ENVCURLY 258 @@ -69,15 +73,10 @@ #define cal_ERROR 268 #define cal_ATNAME 269 +/* Value type. */ -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef int YYSTYPE; -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 -#endif - - +int cmCommandArgument_yyparse (yyscan_t yyscanner); +#endif /* !YY_CMCOMMANDARGUMENT_YY_CMCOMMANDARGUMENTPARSERTOKENS_H_INCLUDED */ diff --git a/Source/cmCommandArgumentsHelper.h b/Source/cmCommandArgumentsHelper.h index b19b0f9..44db374 100644 --- a/Source/cmCommandArgumentsHelper.h +++ b/Source/cmCommandArgumentsHelper.h @@ -3,7 +3,7 @@ #ifndef cmCommandArgumentsHelper_h #define cmCommandArgumentsHelper_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <set> #include <string> diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index 4c5b093..1576722 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -1,6 +1,8 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCommands.h" +#include "cmPolicies.h" +#include "cmState.h" #include "cmAddCustomCommandCommand.h" #include "cmAddCustomTargetCommand.h" @@ -77,6 +79,7 @@ #include "cmAuxSourceDirectoryCommand.h" #include "cmBuildNameCommand.h" #include "cmCMakeHostSystemInformationCommand.h" +#include "cmDisallowedCommand.h" #include "cmExportCommand.h" #include "cmExportLibraryDependenciesCommand.h" #include "cmFLTKWrapUICommand.h" @@ -104,138 +107,162 @@ #include "cmWriteFileCommand.h" #endif -std::vector<cmCommand*> GetPredefinedCommands() +void GetScriptingCommands(cmState* state) { - std::vector<cmCommand*> commands; + state->AddCommand(new cmBreakCommand); + state->AddCommand(new cmCMakeMinimumRequired); + state->AddCommand(new cmCMakePolicyCommand); + state->AddCommand(new cmConfigureFileCommand); + state->AddCommand(new cmContinueCommand); + state->AddCommand(new cmExecProgramCommand); + state->AddCommand(new cmExecuteProcessCommand); + state->AddCommand(new cmFileCommand); + state->AddCommand(new cmFindFileCommand); + state->AddCommand(new cmFindLibraryCommand); + state->AddCommand(new cmFindPackageCommand); + state->AddCommand(new cmFindPathCommand); + state->AddCommand(new cmFindProgramCommand); + state->AddCommand(new cmForEachCommand); + state->AddCommand(new cmFunctionCommand); + state->AddCommand(new cmGetCMakePropertyCommand); + state->AddCommand(new cmGetDirectoryPropertyCommand); + state->AddCommand(new cmGetFilenameComponentCommand); + state->AddCommand(new cmGetPropertyCommand); + state->AddCommand(new cmIfCommand); + state->AddCommand(new cmIncludeCommand); + state->AddCommand(new cmListCommand); + state->AddCommand(new cmMacroCommand); + state->AddCommand(new cmMakeDirectoryCommand); + state->AddCommand(new cmMarkAsAdvancedCommand); + state->AddCommand(new cmMathCommand); + state->AddCommand(new cmMessageCommand); + state->AddCommand(new cmOptionCommand); + state->AddCommand(new cmParseArgumentsCommand); + state->AddCommand(new cmReturnCommand); + state->AddCommand(new cmSeparateArgumentsCommand); + state->AddCommand(new cmSetCommand); + state->AddCommand(new cmSetDirectoryPropertiesCommand); + state->AddCommand(new cmSetPropertyCommand); + state->AddCommand(new cmSiteNameCommand); + state->AddCommand(new cmStringCommand); + state->AddCommand(new cmUnsetCommand); + state->AddCommand(new cmWhileCommand); - commands.push_back(new cmAddCustomCommandCommand); - commands.push_back(new cmAddCustomTargetCommand); - commands.push_back(new cmAddDefinitionsCommand); - commands.push_back(new cmAddDependenciesCommand); - commands.push_back(new cmAddExecutableCommand); - commands.push_back(new cmAddLibraryCommand); - commands.push_back(new cmAddSubDirectoryCommand); - commands.push_back(new cmAddTestCommand); - commands.push_back(new cmBreakCommand); - commands.push_back(new cmBuildCommand); - commands.push_back(new cmCMakeMinimumRequired); - commands.push_back(new cmCMakePolicyCommand); - commands.push_back(new cmConfigureFileCommand); - commands.push_back(new cmContinueCommand); - commands.push_back(new cmCreateTestSourceList); - commands.push_back(new cmDefinePropertyCommand); - commands.push_back(new cmEnableLanguageCommand); - commands.push_back(new cmEnableTestingCommand); - commands.push_back(new cmExecProgramCommand); - commands.push_back(new cmExecuteProcessCommand); - commands.push_back(new cmFileCommand); - commands.push_back(new cmFindFileCommand); - commands.push_back(new cmFindLibraryCommand); - commands.push_back(new cmFindPackageCommand); - commands.push_back(new cmFindPathCommand); - commands.push_back(new cmFindProgramCommand); - commands.push_back(new cmForEachCommand); - commands.push_back(new cmFunctionCommand); - commands.push_back(new cmGetCMakePropertyCommand); - commands.push_back(new cmGetDirectoryPropertyCommand); - commands.push_back(new cmGetFilenameComponentCommand); - commands.push_back(new cmGetPropertyCommand); - commands.push_back(new cmGetSourceFilePropertyCommand); - commands.push_back(new cmGetTargetPropertyCommand); - commands.push_back(new cmGetTestPropertyCommand); - commands.push_back(new cmIfCommand); - commands.push_back(new cmIncludeCommand); - commands.push_back(new cmIncludeDirectoryCommand); - commands.push_back(new cmIncludeRegularExpressionCommand); - commands.push_back(new cmInstallCommand); - commands.push_back(new cmInstallFilesCommand); - commands.push_back(new cmInstallTargetsCommand); - commands.push_back(new cmLinkDirectoriesCommand); - commands.push_back(new cmListCommand); - commands.push_back(new cmMacroCommand); - commands.push_back(new cmMakeDirectoryCommand); - commands.push_back(new cmMarkAsAdvancedCommand); - commands.push_back(new cmMathCommand); - commands.push_back(new cmMessageCommand); - commands.push_back(new cmOptionCommand); - commands.push_back(new cmParseArgumentsCommand); - commands.push_back(new cmProjectCommand); - commands.push_back(new cmReturnCommand); - commands.push_back(new cmSeparateArgumentsCommand); - commands.push_back(new cmSetCommand); - commands.push_back(new cmSetDirectoryPropertiesCommand); - commands.push_back(new cmSetPropertyCommand); - commands.push_back(new cmSetSourceFilesPropertiesCommand); - commands.push_back(new cmSetTargetPropertiesCommand); - commands.push_back(new cmSetTestsPropertiesCommand); - commands.push_back(new cmSiteNameCommand); - commands.push_back(new cmStringCommand); - commands.push_back(new cmSubdirCommand); - commands.push_back(new cmTargetLinkLibrariesCommand); - commands.push_back(new cmTryCompileCommand); - commands.push_back(new cmTryRunCommand); - commands.push_back(new cmUnsetCommand); - commands.push_back(new cmWhileCommand); - - commands.push_back(new cmUnexpectedCommand( + state->AddCommand(new cmUnexpectedCommand( "else", "An ELSE command was found outside of a proper " "IF ENDIF structure. Or its arguments did not match " "the opening IF command.")); - commands.push_back(new cmUnexpectedCommand( + state->AddCommand(new cmUnexpectedCommand( "elseif", "An ELSEIF command was found outside of a proper " "IF ENDIF structure.")); - commands.push_back(new cmUnexpectedCommand( + state->AddCommand(new cmUnexpectedCommand( "endforeach", "An ENDFOREACH command was found outside of a proper " "FOREACH ENDFOREACH structure. Or its arguments did " "not match the opening FOREACH command.")); - commands.push_back(new cmUnexpectedCommand( + state->AddCommand(new cmUnexpectedCommand( "endfunction", "An ENDFUNCTION command was found outside of a proper " "FUNCTION ENDFUNCTION structure. Or its arguments did not " "match the opening FUNCTION command.")); - commands.push_back(new cmUnexpectedCommand( + state->AddCommand(new cmUnexpectedCommand( "endif", "An ENDIF command was found outside of a proper " "IF ENDIF structure. Or its arguments did not match " "the opening IF command.")); - commands.push_back(new cmUnexpectedCommand( + state->AddCommand(new cmUnexpectedCommand( "endmacro", "An ENDMACRO command was found outside of a proper " "MACRO ENDMACRO structure. Or its arguments did not " "match the opening MACRO command.")); - commands.push_back(new cmUnexpectedCommand( + state->AddCommand(new cmUnexpectedCommand( "endwhile", "An ENDWHILE command was found outside of a proper " "WHILE ENDWHILE structure. Or its arguments did not " "match the opening WHILE command.")); #if defined(CMAKE_BUILD_WITH_CMAKE) - commands.push_back(new cmAddCompileOptionsCommand); - commands.push_back(new cmAuxSourceDirectoryCommand); - commands.push_back(new cmBuildNameCommand); - commands.push_back(new cmCMakeHostSystemInformationCommand); - commands.push_back(new cmExportCommand); - commands.push_back(new cmExportLibraryDependenciesCommand); - commands.push_back(new cmFLTKWrapUICommand); - commands.push_back(new cmIncludeExternalMSProjectCommand); - commands.push_back(new cmInstallProgramsCommand); - commands.push_back(new cmLinkLibrariesCommand); - commands.push_back(new cmLoadCacheCommand); - commands.push_back(new cmLoadCommandCommand); - commands.push_back(new cmOutputRequiredFilesCommand); - commands.push_back(new cmQTWrapCPPCommand); - commands.push_back(new cmQTWrapUICommand); - commands.push_back(new cmRemoveCommand); - commands.push_back(new cmRemoveDefinitionsCommand); - commands.push_back(new cmSourceGroupCommand); - commands.push_back(new cmSubdirDependsCommand); - commands.push_back(new cmTargetCompileDefinitionsCommand); - commands.push_back(new cmTargetCompileFeaturesCommand); - commands.push_back(new cmTargetCompileOptionsCommand); - commands.push_back(new cmTargetIncludeDirectoriesCommand); - commands.push_back(new cmTargetSourcesCommand); - commands.push_back(new cmUseMangledMesaCommand); - commands.push_back(new cmUtilitySourceCommand); - commands.push_back(new cmVariableRequiresCommand); - commands.push_back(new cmVariableWatchCommand); - commands.push_back(new cmWriteFileCommand); + state->AddCommand(new cmCMakeHostSystemInformationCommand); + state->AddCommand(new cmRemoveCommand); + state->AddCommand(new cmVariableWatchCommand); + state->AddCommand(new cmWriteFileCommand); + + state->AddCommand(new cmDisallowedCommand( + new cmBuildNameCommand, cmPolicies::CMP0036, + "The build_name command should not be called; see CMP0036.")); + state->AddCommand(new cmDisallowedCommand( + new cmUseMangledMesaCommand, cmPolicies::CMP0030, + "The use_mangled_mesa command should not be called; see CMP0030.")); + #endif +} - return commands; +void GetProjectCommands(cmState* state) +{ + state->AddCommand(new cmAddCustomCommandCommand); + state->AddCommand(new cmAddCustomTargetCommand); + state->AddCommand(new cmAddDefinitionsCommand); + state->AddCommand(new cmAddDependenciesCommand); + state->AddCommand(new cmAddExecutableCommand); + state->AddCommand(new cmAddLibraryCommand); + state->AddCommand(new cmAddSubDirectoryCommand); + state->AddCommand(new cmAddTestCommand); + state->AddCommand(new cmBuildCommand); + state->AddCommand(new cmCreateTestSourceList); + state->AddCommand(new cmDefinePropertyCommand); + state->AddCommand(new cmEnableLanguageCommand); + state->AddCommand(new cmEnableTestingCommand); + state->AddCommand(new cmGetSourceFilePropertyCommand); + state->AddCommand(new cmGetTargetPropertyCommand); + state->AddCommand(new cmGetTestPropertyCommand); + state->AddCommand(new cmIncludeDirectoryCommand); + state->AddCommand(new cmIncludeRegularExpressionCommand); + state->AddCommand(new cmInstallCommand); + state->AddCommand(new cmInstallFilesCommand); + state->AddCommand(new cmInstallTargetsCommand); + state->AddCommand(new cmLinkDirectoriesCommand); + state->AddCommand(new cmProjectCommand); + state->AddCommand(new cmSetSourceFilesPropertiesCommand); + state->AddCommand(new cmSetTargetPropertiesCommand); + state->AddCommand(new cmSetTestsPropertiesCommand); + state->AddCommand(new cmSubdirCommand); + state->AddCommand(new cmTargetLinkLibrariesCommand); + state->AddCommand(new cmTryCompileCommand); + state->AddCommand(new cmTryRunCommand); + +#if defined(CMAKE_BUILD_WITH_CMAKE) + state->AddCommand(new cmAddCompileOptionsCommand); + state->AddCommand(new cmAuxSourceDirectoryCommand); + state->AddCommand(new cmExportCommand); + state->AddCommand(new cmFLTKWrapUICommand); + state->AddCommand(new cmIncludeExternalMSProjectCommand); + state->AddCommand(new cmInstallProgramsCommand); + state->AddCommand(new cmLinkLibrariesCommand); + state->AddCommand(new cmLoadCacheCommand); + state->AddCommand(new cmQTWrapCPPCommand); + state->AddCommand(new cmQTWrapUICommand); + state->AddCommand(new cmRemoveDefinitionsCommand); + state->AddCommand(new cmSourceGroupCommand); + state->AddCommand(new cmTargetCompileDefinitionsCommand); + state->AddCommand(new cmTargetCompileFeaturesCommand); + state->AddCommand(new cmTargetCompileOptionsCommand); + state->AddCommand(new cmTargetIncludeDirectoriesCommand); + state->AddCommand(new cmTargetSourcesCommand); + + state->AddCommand(new cmDisallowedCommand( + new cmExportLibraryDependenciesCommand, cmPolicies::CMP0033, + "The export_library_dependencies command should not be called; " + "see CMP0033.")); + state->AddCommand(new cmDisallowedCommand( + new cmLoadCommandCommand, cmPolicies::CMP0031, + "The load_command command should not be called; see CMP0031.")); + state->AddCommand(new cmDisallowedCommand( + new cmOutputRequiredFilesCommand, cmPolicies::CMP0032, + "The output_required_files command should not be called; " + "see CMP0032.")); + state->AddCommand(new cmDisallowedCommand( + new cmSubdirDependsCommand, cmPolicies::CMP0029, + "The subdir_depends command should not be called; see CMP0029.")); + state->AddCommand(new cmDisallowedCommand( + new cmUtilitySourceCommand, cmPolicies::CMP0034, + "The utility_source command should not be called; see CMP0034.")); + state->AddCommand(new cmDisallowedCommand( + new cmVariableRequiresCommand, cmPolicies::CMP0035, + "The variable_requires command should not be called; see CMP0035.")); +#endif } diff --git a/Source/cmCommands.h b/Source/cmCommands.h index 649dea6..7895ece 100644 --- a/Source/cmCommands.h +++ b/Source/cmCommands.h @@ -3,16 +3,14 @@ #ifndef cmCommands_h #define cmCommands_h -#include <cmConfigure.h> // IWYU pragma: keep +class cmState; -#include <vector> - -class cmCommand; /** - * Global function to return all compiled in commands. + * Global function to register all compiled in commands. * To add a new command edit cmCommands.cxx and add your command. * It is up to the caller to delete the commands created by this call. */ -std::vector<cmCommand*> GetPredefinedCommands(); +void GetScriptingCommands(cmState* state); +void GetProjectCommands(cmState* state); #endif diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 239582f..178a7ce 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCommonTargetGenerator.h" -#include <cmConfigure.h> +#include "cmConfigure.h" #include <set> #include <sstream> #include <utility> @@ -26,7 +26,6 @@ cmCommonTargetGenerator::cmCommonTargetGenerator(cmGeneratorTarget* gt) , GlobalGenerator(static_cast<cmGlobalCommonGenerator*>( gt->LocalGenerator->GetGlobalGenerator())) , ConfigName(LocalGenerator->GetConfigName()) - , ModuleDefinitionFile(GeneratorTarget->GetModuleDefinitionFile(ConfigName)) { } @@ -44,18 +43,13 @@ const char* cmCommonTargetGenerator::GetFeature(const std::string& feature) return this->GeneratorTarget->GetFeature(feature, this->ConfigName); } -bool cmCommonTargetGenerator::GetFeatureAsBool(const std::string& feature) -{ - return this->GeneratorTarget->GetFeatureAsBool(feature, this->ConfigName); -} - void cmCommonTargetGenerator::AddFeatureFlags(std::string& flags, const std::string& lang) { // Add language-specific flags. this->LocalGenerator->AddLanguageFlags(flags, lang, this->ConfigName); - if (this->GetFeatureAsBool("INTERPROCEDURAL_OPTIMIZATION")) { + if (this->GeneratorTarget->IsIPOEnabled(this->ConfigName)) { this->LocalGenerator->AppendFeatureOptions(flags, lang, "IPO"); } } @@ -63,14 +57,9 @@ void cmCommonTargetGenerator::AddFeatureFlags(std::string& flags, void cmCommonTargetGenerator::AddModuleDefinitionFlag( cmLinkLineComputer* linkLineComputer, std::string& flags) { - // A module definition file only makes sense on certain target types. - if (this->GeneratorTarget->GetType() != cmStateEnums::SHARED_LIBRARY && - this->GeneratorTarget->GetType() != cmStateEnums::MODULE_LIBRARY && - this->GeneratorTarget->GetType() != cmStateEnums::EXECUTABLE) { - return; - } - - if (!this->ModuleDefinitionFile) { + cmGeneratorTarget::ModuleDefinitionInfo const* mdi = + this->GeneratorTarget->GetModuleDefinitionInfo(this->GetConfigName()); + if (!mdi || mdi->DefFile.empty()) { return; } @@ -85,8 +74,7 @@ void cmCommonTargetGenerator::AddModuleDefinitionFlag( // vs6's "cl -link" pass it to the linker. std::string flag = defFileFlag; flag += this->LocalGenerator->ConvertToOutputFormat( - linkLineComputer->ConvertToLinkReference( - this->ModuleDefinitionFile->GetFullPath()), + linkLineComputer->ConvertToLinkReference(mdi->DefFile), cmOutputConverter::SHELL); this->LocalGenerator->AppendFlags(flags, flag); } diff --git a/Source/cmCommonTargetGenerator.h b/Source/cmCommonTargetGenerator.h index d67fefb..8ba2e22 100644 --- a/Source/cmCommonTargetGenerator.h +++ b/Source/cmCommonTargetGenerator.h @@ -3,7 +3,8 @@ #ifndef cmCommonTargetGenerator_h #define cmCommonTargetGenerator_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep + #include <map> #include <string> #include <vector> @@ -32,7 +33,6 @@ protected: // Feature query methods. const char* GetFeature(const std::string& feature); - bool GetFeatureAsBool(const std::string& feature); // Helper to add flag for windows .def file. void AddModuleDefinitionFlag(cmLinkLineComputer* linkLineComputer, @@ -44,9 +44,6 @@ protected: cmGlobalCommonGenerator* GlobalGenerator; std::string ConfigName; - // The windows module definition source file (.def), if any. - cmSourceFile const* ModuleDefinitionFile; - void AppendFortranFormatFlags(std::string& flags, cmSourceFile const& source); diff --git a/Source/cmComputeComponentGraph.h b/Source/cmComputeComponentGraph.h index 608dedc..8cd4fe7 100644 --- a/Source/cmComputeComponentGraph.h +++ b/Source/cmComputeComponentGraph.h @@ -3,7 +3,7 @@ #ifndef cmComputeComponentGraph_h #define cmComputeComponentGraph_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include "cmGraphAdjacencyList.h" diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index 6a4e8e0..195b544 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -3,7 +3,7 @@ #ifndef cmComputeLinkDepends_h #define cmComputeLinkDepends_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include "cmGraphAdjacencyList.h" #include "cmLinkItem.h" diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 80e7e7d..b273443 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -500,7 +500,10 @@ bool cmComputeLinkInformation::Compute() cmGeneratorTarget const* tgt = *i; bool implib = (this->UseImportLibrary && (tgt->GetType() == cmStateEnums::SHARED_LIBRARY)); - std::string lib = tgt->GetFullPath(this->Config, implib, true); + cmStateEnums::ArtifactType artifact = implib + ? cmStateEnums::ImportLibraryArtifact + : cmStateEnums::RuntimeBinaryArtifact; + std::string lib = tgt->GetFullPath(this->Config, artifact, true); this->OldLinkDirItems.push_back(lib); } } @@ -596,8 +599,11 @@ void cmComputeLinkInformation::AddItem(std::string const& item, // platform. Add it now. std::string linkItem; linkItem = this->LoaderFlag; + cmStateEnums::ArtifactType artifact = this->UseImportLibrary + ? cmStateEnums::ImportLibraryArtifact + : cmStateEnums::RuntimeBinaryArtifact; - std::string exe = tgt->GetFullPath(config, this->UseImportLibrary, true); + std::string exe = tgt->GetFullPath(config, artifact, true); linkItem += exe; this->Items.push_back(Item(linkItem, true, tgt)); this->Depends.push_back(exe); @@ -617,9 +623,12 @@ void cmComputeLinkInformation::AddItem(std::string const& item, bool implib = (this->UseImportLibrary && (impexe || tgt->GetType() == cmStateEnums::SHARED_LIBRARY)); + cmStateEnums::ArtifactType artifact = implib + ? cmStateEnums::ImportLibraryArtifact + : cmStateEnums::RuntimeBinaryArtifact; // Pass the full path to the target file. - std::string lib = tgt->GetFullPath(config, implib, true); + std::string lib = tgt->GetFullPath(config, artifact, true); if (!this->LinkDependsNoShared || tgt->GetType() != cmStateEnums::SHARED_LIBRARY) { this->Depends.push_back(lib); @@ -689,7 +698,10 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, // linked will be able to find it. std::string lib; if (tgt) { - lib = tgt->GetFullPath(this->Config, this->UseImportLibrary); + cmStateEnums::ArtifactType artifact = this->UseImportLibrary + ? cmStateEnums::ImportLibraryArtifact + : cmStateEnums::RuntimeBinaryArtifact; + lib = tgt->GetFullPath(this->Config, artifact); this->AddLibraryRuntimeInfo(lib, tgt); } else { lib = item; diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 3d26ea7..00e3ad2 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -3,9 +3,9 @@ #ifndef cmComputeLinkInformation_h #define cmComputeLinkInformation_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep -#include <cmsys/RegularExpression.hxx> +#include "cmsys/RegularExpression.hxx" #include <iosfwd> #include <set> #include <string> @@ -36,12 +36,6 @@ public: , Target(CM_NULLPTR) { } - Item(Item const& item) - : Value(item.Value) - , IsPath(item.IsPath) - , Target(item.Target) - { - } Item(std::string const& v, bool p, cmGeneratorTarget const* target = CM_NULLPTR) : Value(v) diff --git a/Source/cmComputeTargetDepends.h b/Source/cmComputeTargetDepends.h index 2b6591f..ccf99de 100644 --- a/Source/cmComputeTargetDepends.h +++ b/Source/cmComputeTargetDepends.h @@ -3,7 +3,7 @@ #ifndef cmComputeTargetDepends_h #define cmComputeTargetDepends_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include "cmGraphAdjacencyList.h" diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx index f2eb601..bcfbfbe 100644 --- a/Source/cmConditionEvaluator.cxx +++ b/Source/cmConditionEvaluator.cxx @@ -2,9 +2,9 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmConditionEvaluator.h" +#include "cmConfigure.h" +#include "cmsys/RegularExpression.hxx" #include <algorithm> -#include <cmConfigure.h> -#include <cmsys/RegularExpression.hxx> #include <sstream> #include <stdio.h> #include <stdlib.h> diff --git a/Source/cmConditionEvaluator.h b/Source/cmConditionEvaluator.h index 5815177..50f4edc 100644 --- a/Source/cmConditionEvaluator.h +++ b/Source/cmConditionEvaluator.h @@ -3,7 +3,7 @@ #ifndef cmConditionEvaluator_h #define cmConditionEvaluator_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <list> #include <string> diff --git a/Source/cmConfigure.cmake.h.in b/Source/cmConfigure.cmake.h.in index 26f1df2..970fde5 100644 --- a/Source/cmConfigure.cmake.h.in +++ b/Source/cmConfigure.cmake.h.in @@ -3,7 +3,7 @@ #ifndef cmConfigure_h #define cmConfigure_h -#include <cmsys/Configure.hxx> // IWYU pragma: keep +#include "cmsys/Configure.hxx" // IWYU pragma: export #ifdef _MSC_VER #pragma warning(disable : 4786) @@ -21,6 +21,7 @@ #cmakedefine CMAKE_USE_MACH_PARSER #cmakedefine CMAKE_USE_LIBUV #cmakedefine CMake_HAVE_CXX_AUTO_PTR +#cmakedefine CMake_HAVE_CXX_EQ_DELETE #cmakedefine CMake_HAVE_CXX_MAKE_UNIQUE #cmakedefine CMake_HAVE_CXX_NULLPTR #cmakedefine CMake_HAVE_CXX_OVERRIDE @@ -30,6 +31,12 @@ #define CMAKE_BIN_DIR "/@CMAKE_BIN_DIR@" #define CMAKE_DATA_DIR "/@CMAKE_DATA_DIR@" +#ifdef CMake_HAVE_CXX_EQ_DELETE +#define CM_EQ_DELETE = delete +#else +#define CM_EQ_DELETE +#endif + #ifdef CMake_HAVE_CXX_NULLPTR #define CM_NULLPTR nullptr #else @@ -42,4 +49,8 @@ #define CM_OVERRIDE #endif +#define CM_DISABLE_COPY(Class) \ + Class(Class const&) CM_EQ_DELETE; \ + Class& operator=(Class const&) CM_EQ_DELETE; + #endif diff --git a/Source/cmConfigureFileCommand.h b/Source/cmConfigureFileCommand.h index e558b85..882219d 100644 --- a/Source/cmConfigureFileCommand.h +++ b/Source/cmConfigureFileCommand.h @@ -3,7 +3,8 @@ #ifndef cmConfigureFileCommand_h #define cmConfigureFileCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmContinueCommand.h b/Source/cmContinueCommand.h index c5b8919..4428d79 100644 --- a/Source/cmContinueCommand.h +++ b/Source/cmContinueCommand.h @@ -3,7 +3,8 @@ #ifndef cmContinueCommand_h #define cmContinueCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index ff9ffc0..2287bc2 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -2,12 +2,13 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCoreTryCompile.h" -#include <cmConfigure.h> -#include <cmsys/Directory.hxx> +#include "cmConfigure.h" +#include "cmsys/Directory.hxx" #include <set> #include <sstream> #include <stdio.h> #include <string.h> +#include <utility> #include "cmAlgorithms.h" #include "cmExportTryCompileFileGenerator.h" diff --git a/Source/cmCoreTryCompile.h b/Source/cmCoreTryCompile.h index 4b96aed..365154d 100644 --- a/Source/cmCoreTryCompile.h +++ b/Source/cmCoreTryCompile.h @@ -3,7 +3,7 @@ #ifndef cmCoreTryCompile_h #define cmCoreTryCompile_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmCreateTestSourceList.h b/Source/cmCreateTestSourceList.h index 5e003cf..47391f3 100644 --- a/Source/cmCreateTestSourceList.h +++ b/Source/cmCreateTestSourceList.h @@ -3,7 +3,7 @@ #ifndef cmCreateTestSourceList_h #define cmCreateTestSourceList_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <string> #include <vector> diff --git a/Source/cmCryptoHash.cxx b/Source/cmCryptoHash.cxx index d5807b1..7995b2c 100644 --- a/Source/cmCryptoHash.cxx +++ b/Source/cmCryptoHash.cxx @@ -2,9 +2,9 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCryptoHash.h" -#include <cm_kwiml.h> -#include <cm_rhash.h> -#include <cmsys/FStream.hxx> +#include "cm_kwiml.h" +#include "cm_rhash.h" +#include "cmsys/FStream.hxx" #include <string.h> static unsigned int const cmCryptoHashAlgoToId[] = { diff --git a/Source/cmCryptoHash.h b/Source/cmCryptoHash.h index 0b562da..ac92c48 100644 --- a/Source/cmCryptoHash.h +++ b/Source/cmCryptoHash.h @@ -3,7 +3,7 @@ #ifndef cmCryptoHash_h #define cmCryptoHash_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <stddef.h> #include <string> @@ -78,6 +78,9 @@ public: std::string FinalizeHex(); private: + cmCryptoHash(cmCryptoHash const&); + cmCryptoHash& operator=(cmCryptoHash const&); + unsigned int Id; struct rhash_context* CTX; }; diff --git a/Source/cmCurl.h b/Source/cmCurl.h index 60ab9fe..a2fa4b1 100644 --- a/Source/cmCurl.h +++ b/Source/cmCurl.h @@ -3,9 +3,9 @@ #ifndef cmCurl_h #define cmCurl_h -#include <cmConfigure.h> +#include "cmConfigure.h" -#include <cm_curl.h> +#include "cm_curl.h" #include <string> std::string cmCurlSetCAInfo(::CURL* curl, const char* cafile = CM_NULLPTR); diff --git a/Source/cmCustomCommand.cxx b/Source/cmCustomCommand.cxx index 050de17..5e377b5 100644 --- a/Source/cmCustomCommand.cxx +++ b/Source/cmCustomCommand.cxx @@ -4,7 +4,7 @@ #include "cmMakefile.h" -#include <cmConfigure.h> +#include "cmConfigure.h" cmCustomCommand::cmCustomCommand() : Backtrace() diff --git a/Source/cmCustomCommand.h b/Source/cmCustomCommand.h index 73d53ff..9e82f25 100644 --- a/Source/cmCustomCommand.h +++ b/Source/cmCustomCommand.h @@ -3,7 +3,7 @@ #ifndef cmCustomCommand_h #define cmCustomCommand_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCustomCommandLines.h" #include "cmListFileCache.h" diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index 8f4ff4b..67213ec 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -13,7 +13,7 @@ #include "cmSystemTools.h" #include "cm_auto_ptr.hxx" -#include <cmConfigure.h> +#include "cmConfigure.h" cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc, const std::string& config, diff --git a/Source/cmCustomCommandGenerator.h b/Source/cmCustomCommandGenerator.h index 286aaf3..0a2adb5 100644 --- a/Source/cmCustomCommandGenerator.h +++ b/Source/cmCustomCommandGenerator.h @@ -3,8 +3,8 @@ #ifndef cmCustomCommandGenerator_h #define cmCustomCommandGenerator_h +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCustomCommandLines.h" -#include <cmConfigure.h> // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmCustomCommandLines.h b/Source/cmCustomCommandLines.h index 87ed4e8..36838f2 100644 --- a/Source/cmCustomCommandLines.h +++ b/Source/cmCustomCommandLines.h @@ -3,7 +3,7 @@ #ifndef cmCustomCommandLines_h #define cmCustomCommandLines_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmDefinePropertyCommand.h b/Source/cmDefinePropertyCommand.h index 02e5b88..7a6e127 100644 --- a/Source/cmDefinePropertyCommand.h +++ b/Source/cmDefinePropertyCommand.h @@ -3,7 +3,8 @@ #ifndef cmDefinesPropertyCommand_h #define cmDefinesPropertyCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx index 47fe76a..7aa7641 100644 --- a/Source/cmDefinitions.cxx +++ b/Source/cmDefinitions.cxx @@ -2,8 +2,8 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmDefinitions.h" +#include "cmConfigure.h" #include <assert.h> -#include <cmConfigure.h> #include <set> #include <utility> diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h index ad40665..ddb8918 100644 --- a/Source/cmDefinitions.h +++ b/Source/cmDefinitions.h @@ -3,7 +3,7 @@ #ifndef cmDefinitions_h #define cmDefinitions_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> @@ -65,12 +65,6 @@ private: , Used(false) { } - Def(Def const& d) - : std_string(d) - , Exists(d.Exists) - , Used(d.Used) - { - } bool Exists; bool Used; }; diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx index c189419..c898d12 100644 --- a/Source/cmDepends.cxx +++ b/Source/cmDepends.cxx @@ -7,8 +7,9 @@ #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmSystemTools.h" +#include "cmWorkingDirectory.h" -#include <cmsys/FStream.hxx> +#include "cmsys/FStream.hxx" #include <sstream> #include <string.h> #include <utility> @@ -75,13 +76,7 @@ bool cmDepends::Check(const char* makeFile, const char* internalFile, std::map<std::string, DependencyVector>& validDeps) { // Dependency checks must be done in proper working directory. - std::string oldcwd = "."; - if (this->CompileDirectory != ".") { - // Get the CWD but do not call CollapseFullPath because - // we only need it to cd back, and the form does not matter - oldcwd = cmSystemTools::GetCurrentWorkingDirectory(false); - cmSystemTools::ChangeDirectory(this->CompileDirectory); - } + cmWorkingDirectory workdir(this->CompileDirectory); // Check whether dependencies must be regenerated. bool okay = true; @@ -93,11 +88,6 @@ bool cmDepends::Check(const char* makeFile, const char* internalFile, okay = false; } - // Restore working directory. - if (oldcwd != ".") { - cmSystemTools::ChangeDirectory(oldcwd); - } - return okay; } diff --git a/Source/cmDepends.h b/Source/cmDepends.h index f677f80..a80b585 100644 --- a/Source/cmDepends.h +++ b/Source/cmDepends.h @@ -3,7 +3,7 @@ #ifndef cmDepends_h #define cmDepends_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <iosfwd> #include <map> diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx index 9d4b9cc..3b84516 100644 --- a/Source/cmDependsC.cxx +++ b/Source/cmDependsC.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmDependsC.h" -#include <cmsys/FStream.hxx> +#include "cmsys/FStream.hxx" #include <utility> #include "cmAlgorithms.h" diff --git a/Source/cmDependsC.h b/Source/cmDependsC.h index 3b5eb62..4f52826 100644 --- a/Source/cmDependsC.h +++ b/Source/cmDependsC.h @@ -3,11 +3,11 @@ #ifndef cmDependsC_h #define cmDependsC_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmDepends.h" -#include <cmsys/RegularExpression.hxx> +#include "cmsys/RegularExpression.hxx" #include <iosfwd> #include <map> #include <queue> diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index 7927402..8b05fab 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -2,8 +2,8 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmDependsFortran.h" +#include "cmsys/FStream.hxx" #include <assert.h> -#include <cmsys/FStream.hxx> #include <iostream> #include <map> #include <stdlib.h> diff --git a/Source/cmDependsFortran.h b/Source/cmDependsFortran.h index 90b82d4..a9a1ed3 100644 --- a/Source/cmDependsFortran.h +++ b/Source/cmDependsFortran.h @@ -3,7 +3,8 @@ #ifndef cmFortran_h #define cmFortran_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <iosfwd> #include <set> #include <string> diff --git a/Source/cmDependsJava.h b/Source/cmDependsJava.h index 1b9cca5..6efa51a 100644 --- a/Source/cmDependsJava.h +++ b/Source/cmDependsJava.h @@ -3,7 +3,7 @@ #ifndef cmDependsJava_h #define cmDependsJava_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmDepends.h" diff --git a/Source/cmDependsJavaParser.cxx b/Source/cmDependsJavaParser.cxx index b99d631..bc45d45 100644 --- a/Source/cmDependsJavaParser.cxx +++ b/Source/cmDependsJavaParser.cxx @@ -1,12 +1,13 @@ -/* A Bison parser, made by GNU Bison 1.875d. */ +/* A Bison parser, made by GNU Bison 3.0.4. */ -/* Skeleton parser for Yacc-like parsing with Bison, Copyright (C) 1984, - 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +/* Bison implementation for Yacc-like parsers in C - This program is free software; you can redistribute it and/or modify + Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,17 +15,23 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ -/* Written by Richard Stallman by simplifying the original so called - ``semantic'' parser. */ +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local @@ -33,145 +40,223 @@ define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ -/* turn off some warning as this is generated code */ -#if defined(_MSC_VER) -# pragma warning ( disable : 4702 ) /* unreachable code */ -#endif - /* Identify Bison output. */ #define YYBISON 1 +/* Bison version. */ +#define YYBISON_VERSION "3.0.4" + /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" /* Pure parsers. */ #define YYPURE 1 -/* Using locations. */ -#define YYLSP_NEEDED 0 +/* Push parsers. */ +#define YYPUSH 0 -/* If NAME_PREFIX is specified substitute the variables and functions - names. */ -#define yyparse cmDependsJava_yyparse -#define yylex cmDependsJava_yylex -#define yyerror cmDependsJava_yyerror -#define yylval cmDependsJava_yylval -#define yychar cmDependsJava_yychar -#define yydebug cmDependsJava_yydebug -#define yynerrs cmDependsJava_yynerrs +/* Pull parsers. */ +#define YYPULL 1 -/* Tokens. */ +/* Substitute the variable and function names. */ +#define yyparse cmDependsJava_yyparse +#define yylex cmDependsJava_yylex +#define yyerror cmDependsJava_yyerror +#define yydebug cmDependsJava_yydebug +#define yynerrs cmDependsJava_yynerrs + + +/* Copy the first part of user declarations. */ +#line 1 "cmDependsJavaParser.y" /* yacc.c:339 */ + +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +/* + +This file must be translated to C and modified to build everywhere. + +Run bison like this: + + bison --yacc --name-prefix=cmDependsJava_yy --defines=cmDependsJavaParserTokens.h -ocmDependsJavaParser.cxx cmDependsJavaParser.y + +Modify cmDependsJavaParser.cxx: + - "#if 0" out yyerrorlab block in range ["goto yyerrlab1", "yyerrlab1:"] + +*/ + +#include "cmConfigure.h" // IWYU pragma: keep + +#include <stdlib.h> +#include <string.h> +#include <string> + +#define yyGetParser (cmDependsJava_yyget_extra(yyscanner)) + +/*-------------------------------------------------------------------------*/ +#include "cmDependsJavaParserHelper.h" /* Interface to parser object. */ +#include "cmDependsJavaLexer.h" /* Interface to lexer object. */ +#include "cmDependsJavaParserTokens.h" /* Need YYSTYPE for YY_DECL. */ + +/* Forward declare the lexer entry point. */ +YY_DECL; + +/* Helper function to forward error callback from parser. */ +static void cmDependsJava_yyerror(yyscan_t yyscanner, const char* message); + +#define YYMAXDEPTH 1000000 + + +#define jpCheckEmpty(cnt) yyGetParser->CheckEmpty(__LINE__, cnt, yyvsp); +#define jpElementStart(cnt) yyGetParser->PrepareElement(&yyval) +#define jpStoreClass(str) yyGetParser->AddClassFound(str); yyGetParser->DeallocateParserType(&(str)) +/* Disable some warnings in the generated code. */ +#ifdef _MSC_VER +# pragma warning (disable: 4102) /* Unused goto label. */ +# pragma warning (disable: 4065) /* Switch statement contains default but no case. */ +#endif + +#line 120 "cmDependsJavaParser.cxx" /* yacc.c:339 */ + +# ifndef YY_NULLPTR +# if defined __cplusplus && 201103L <= __cplusplus +# define YY_NULLPTR nullptr +# else +# define YY_NULLPTR 0 +# endif +# endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 1 +#endif + +/* In a future release of Bison, this section will be replaced + by #include "cmDependsJavaParserTokens.h". */ +#ifndef YY_CMDEPENDSJAVA_YY_CMDEPENDSJAVAPARSERTOKENS_H_INCLUDED +# define YY_CMDEPENDSJAVA_YY_CMDEPENDSJAVAPARSERTOKENS_H_INCLUDED +/* Debug traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif +#if YYDEBUG +extern int cmDependsJava_yydebug; +#endif + +/* Token type. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - jp_ABSTRACT = 258, - jp_ASSERT = 259, - jp_BOOLEAN_TYPE = 260, - jp_BREAK = 261, - jp_BYTE_TYPE = 262, - jp_CASE = 263, - jp_CATCH = 264, - jp_CHAR_TYPE = 265, - jp_CLASS = 266, - jp_CONTINUE = 267, - jp_DEFAULT = 268, - jp_DO = 269, - jp_DOUBLE_TYPE = 270, - jp_ELSE = 271, - jp_EXTENDS = 272, - jp_FINAL = 273, - jp_FINALLY = 274, - jp_FLOAT_TYPE = 275, - jp_FOR = 276, - jp_IF = 277, - jp_IMPLEMENTS = 278, - jp_IMPORT = 279, - jp_INSTANCEOF = 280, - jp_INT_TYPE = 281, - jp_INTERFACE = 282, - jp_LONG_TYPE = 283, - jp_NATIVE = 284, - jp_NEW = 285, - jp_PACKAGE = 286, - jp_PRIVATE = 287, - jp_PROTECTED = 288, - jp_PUBLIC = 289, - jp_RETURN = 290, - jp_SHORT_TYPE = 291, - jp_STATIC = 292, - jp_STRICTFP = 293, - jp_SUPER = 294, - jp_SWITCH = 295, - jp_SYNCHRONIZED = 296, - jp_THIS = 297, - jp_THROW = 298, - jp_THROWS = 299, - jp_TRANSIENT = 300, - jp_TRY = 301, - jp_VOID = 302, - jp_VOLATILE = 303, - jp_WHILE = 304, - jp_BOOLEANLITERAL = 305, - jp_CHARACTERLITERAL = 306, - jp_DECIMALINTEGERLITERAL = 307, - jp_FLOATINGPOINTLITERAL = 308, - jp_HEXINTEGERLITERAL = 309, - jp_NULLLITERAL = 310, - jp_STRINGLITERAL = 311, - jp_NAME = 312, - jp_AND = 313, - jp_ANDAND = 314, - jp_ANDEQUALS = 315, - jp_BRACKETEND = 316, - jp_BRACKETSTART = 317, - jp_CARROT = 318, - jp_CARROTEQUALS = 319, - jp_COLON = 320, - jp_COMMA = 321, - jp_CURLYEND = 322, - jp_CURLYSTART = 323, - jp_DIVIDE = 324, - jp_DIVIDEEQUALS = 325, - jp_DOLLAR = 326, - jp_DOT = 327, - jp_EQUALS = 328, - jp_EQUALSEQUALS = 329, - jp_EXCLAMATION = 330, - jp_EXCLAMATIONEQUALS = 331, - jp_GREATER = 332, - jp_GTEQUALS = 333, - jp_GTGT = 334, - jp_GTGTEQUALS = 335, - jp_GTGTGT = 336, - jp_GTGTGTEQUALS = 337, - jp_LESLESEQUALS = 338, - jp_LESSTHAN = 339, - jp_LTEQUALS = 340, - jp_LTLT = 341, - jp_MINUS = 342, - jp_MINUSEQUALS = 343, - jp_MINUSMINUS = 344, - jp_PAREEND = 345, - jp_PARESTART = 346, - jp_PERCENT = 347, - jp_PERCENTEQUALS = 348, - jp_PIPE = 349, - jp_PIPEEQUALS = 350, - jp_PIPEPIPE = 351, - jp_PLUS = 352, - jp_PLUSEQUALS = 353, - jp_PLUSPLUS = 354, - jp_QUESTION = 355, - jp_SEMICOL = 356, - jp_TILDE = 357, - jp_TIMES = 358, - jp_TIMESEQUALS = 359, - jp_ERROR = 360 - }; + enum yytokentype + { + jp_ABSTRACT = 258, + jp_ASSERT = 259, + jp_BOOLEAN_TYPE = 260, + jp_BREAK = 261, + jp_BYTE_TYPE = 262, + jp_CASE = 263, + jp_CATCH = 264, + jp_CHAR_TYPE = 265, + jp_CLASS = 266, + jp_CONTINUE = 267, + jp_DEFAULT = 268, + jp_DO = 269, + jp_DOUBLE_TYPE = 270, + jp_ELSE = 271, + jp_EXTENDS = 272, + jp_FINAL = 273, + jp_FINALLY = 274, + jp_FLOAT_TYPE = 275, + jp_FOR = 276, + jp_IF = 277, + jp_IMPLEMENTS = 278, + jp_IMPORT = 279, + jp_INSTANCEOF = 280, + jp_INT_TYPE = 281, + jp_INTERFACE = 282, + jp_LONG_TYPE = 283, + jp_NATIVE = 284, + jp_NEW = 285, + jp_PACKAGE = 286, + jp_PRIVATE = 287, + jp_PROTECTED = 288, + jp_PUBLIC = 289, + jp_RETURN = 290, + jp_SHORT_TYPE = 291, + jp_STATIC = 292, + jp_STRICTFP = 293, + jp_SUPER = 294, + jp_SWITCH = 295, + jp_SYNCHRONIZED = 296, + jp_THIS = 297, + jp_THROW = 298, + jp_THROWS = 299, + jp_TRANSIENT = 300, + jp_TRY = 301, + jp_VOID = 302, + jp_VOLATILE = 303, + jp_WHILE = 304, + jp_BOOLEANLITERAL = 305, + jp_CHARACTERLITERAL = 306, + jp_DECIMALINTEGERLITERAL = 307, + jp_FLOATINGPOINTLITERAL = 308, + jp_HEXINTEGERLITERAL = 309, + jp_NULLLITERAL = 310, + jp_STRINGLITERAL = 311, + jp_NAME = 312, + jp_AND = 313, + jp_ANDAND = 314, + jp_ANDEQUALS = 315, + jp_BRACKETEND = 316, + jp_BRACKETSTART = 317, + jp_CARROT = 318, + jp_CARROTEQUALS = 319, + jp_COLON = 320, + jp_COMMA = 321, + jp_CURLYEND = 322, + jp_CURLYSTART = 323, + jp_DIVIDE = 324, + jp_DIVIDEEQUALS = 325, + jp_DOLLAR = 326, + jp_DOT = 327, + jp_EQUALS = 328, + jp_EQUALSEQUALS = 329, + jp_EXCLAMATION = 330, + jp_EXCLAMATIONEQUALS = 331, + jp_GREATER = 332, + jp_GTEQUALS = 333, + jp_GTGT = 334, + jp_GTGTEQUALS = 335, + jp_GTGTGT = 336, + jp_GTGTGTEQUALS = 337, + jp_LESLESEQUALS = 338, + jp_LESSTHAN = 339, + jp_LTEQUALS = 340, + jp_LTLT = 341, + jp_MINUS = 342, + jp_MINUSEQUALS = 343, + jp_MINUSMINUS = 344, + jp_PAREEND = 345, + jp_PARESTART = 346, + jp_PERCENT = 347, + jp_PERCENTEQUALS = 348, + jp_PIPE = 349, + jp_PIPEEQUALS = 350, + jp_PIPEPIPE = 351, + jp_PLUS = 352, + jp_PLUSEQUALS = 353, + jp_PLUSPLUS = 354, + jp_QUESTION = 355, + jp_SEMICOL = 356, + jp_TILDE = 357, + jp_TIMES = 358, + jp_TIMESEQUALS = 359, + jp_ERROR = 360 + }; #endif +/* Tokens. */ #define jp_ABSTRACT 258 #define jp_ASSERT 259 #define jp_BOOLEAN_TYPE 260 @@ -276,141 +361,205 @@ #define jp_TIMESEQUALS 359 #define jp_ERROR 360 +/* Value type. */ -/* Copy the first part of user declarations. */ -#line 1 "cmDependsJavaParser.y" +int cmDependsJava_yyparse (yyscan_t yyscanner); -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -/* +#endif /* !YY_CMDEPENDSJAVA_YY_CMDEPENDSJAVAPARSERTOKENS_H_INCLUDED */ -This file must be translated to C and modified to build everywhere. +/* Copy the second part of user declarations. */ -Run bison like this: +#line 375 "cmDependsJavaParser.cxx" /* yacc.c:358 */ - bison --yacc --name-prefix=cmDependsJava_yy - --defines=cmDependsJavaParserTokens.h -ocmDependsJavaParser.cxx - cmDependsJavaParser.y +#ifdef short +# undef short +#endif -Modify cmDependsJavaParser.c: - - remove TABs +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif -*/ +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#else +typedef signed char yytype_int8; +#endif -/* Configure the parser to use a lexer object. */ -#define YYPARSE_PARAM yyscanner -#define YYLEX_PARAM yyscanner -#define YYERROR_VERBOSE 1 -#define cmDependsJava_yyerror(x) \ - cmDependsJavaError(yyscanner, x) -#define yyGetParser (cmDependsJava_yyget_extra(yyscanner)) +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif -/*-------------------------------------------------------------------------*/ -#include "cmDependsJavaParserHelper.h" /* Interface to parser object. */ -#include "cmDependsJavaLexer.h" /* Interface to lexer object. */ -#include "cmDependsJavaParserTokens.h" /* Need YYSTYPE for YY_DECL. */ +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif -/* Forward declare the lexer entry point. */ -YY_DECL; +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T +# include <stddef.h> /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif -/* Internal utility functions. */ -static void cmDependsJavaError(yyscan_t yyscanner, const char* message); +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) -#define YYDEBUG 1 -#define YYMAXDEPTH 1000000 +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include <libintl.h> /* INFRINGES ON USER NAME SPACE */ +# define YY_(Msgid) dgettext ("bison-runtime", Msgid) +# endif +# endif +# ifndef YY_ +# define YY_(Msgid) Msgid +# endif +#endif +#ifndef YY_ATTRIBUTE +# if (defined __GNUC__ \ + && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ + || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C +# define YY_ATTRIBUTE(Spec) __attribute__(Spec) +# else +# define YY_ATTRIBUTE(Spec) /* empty */ +# endif +#endif -#define jpCheckEmpty(cnt) yyGetParser->CheckEmpty(__LINE__, cnt, yyvsp); -#define jpElementStart(cnt) yyGetParser->PrepareElement(&yyval) -#define jpStoreClass(str) \ -yyGetParser->AddClassFound(str); yyGetParser->DeallocateParserType(&(str)) -/* Disable some warnings in the generated code. */ -#ifdef _MSC_VER -# pragma warning (disable: 4102) /* Unused goto label. */ -# pragma warning (disable: 4065) /* Switch statement contains default but - no case. */ +#ifndef YY_ATTRIBUTE_PURE +# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) #endif +#ifndef YY_ATTRIBUTE_UNUSED +# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) +#endif -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG 0 +#if !defined _Noreturn \ + && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) +# if defined _MSC_VER && 1200 <= _MSC_VER +# define _Noreturn __declspec (noreturn) +# else +# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) +# endif #endif -/* Enabling verbose error messages. */ -#ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(E) ((void) (E)) #else -# define YYERROR_VERBOSE 0 +# define YYUSE(E) /* empty */ #endif -#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) -typedef int YYSTYPE; -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 +#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +/* Suppress an incorrect diagnostic about yylval being uninitialized. */ +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ + _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ + _Pragma ("GCC diagnostic pop") +#else +# define YY_INITIAL_VALUE(Value) Value +#endif +#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_END +#endif +#ifndef YY_INITIAL_VALUE +# define YY_INITIAL_VALUE(Value) /* Nothing. */ #endif - -/* Copy the second part of user declarations. */ - - -/* Line 214 of yacc.c. */ -#line 372 "cmDependsJavaParser.cxx" - -#if ! defined (yyoverflow) || YYERROR_VERBOSE - -# ifndef YYFREE -# define YYFREE free -# endif -# ifndef YYMALLOC -# define YYMALLOC malloc -# endif +#if ! defined yyoverflow || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ # ifdef YYSTACK_USE_ALLOCA # if YYSTACK_USE_ALLOCA -# define YYSTACK_ALLOC alloca -# endif -# else -# if defined (alloca) || defined (_ALLOCA_H) -# define YYSTACK_ALLOC alloca -# else # ifdef __GNUC__ # define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include <alloca.h> /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include <malloc.h> /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS +# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ + /* Use EXIT_SUCCESS as a witness for stdlib.h. */ +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +# endif +# endif # endif # endif # endif # ifdef YYSTACK_ALLOC - /* Pacify GCC's `empty if-body' warning. */ + /* Pacify GCC's 'empty if-body' warning. */ # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) -# else -# if defined (__STDC__) || defined (__cplusplus) -# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ # endif +# else # define YYSTACK_ALLOC YYMALLOC # define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined EXIT_SUCCESS \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined EXIT_SUCCESS +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined EXIT_SUCCESS +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif # endif -#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ -#if (! defined (yyoverflow) \ - && (! defined (__cplusplus) \ - || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc { - short int yyss; - YYSTYPE yyvs; - }; + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; +}; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) @@ -418,74 +567,74 @@ union yyalloc /* The size of an array large to enough to hold all stacks, each with N elements. */ # define YYSTACK_BYTES(N) \ - ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) -/* Copy COUNT objects from FROM to TO. The source and destination do - not overlap. */ -# ifndef YYCOPY -# if defined (__GNUC__) && 1 < __GNUC__ -# define YYCOPY(To, From, Count) \ - __builtin_memcpy (To, From, (Count) * sizeof (*(From))) -# else -# define YYCOPY(To, From, Count) \ - do \ - { \ - YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (To)[yyi] = (From)[yyi]; \ - } \ - while (0) -# endif -# endif +# define YYCOPY_NEEDED 1 /* Relocate STACK from its old location to the new one. The local variables YYSIZE and YYSTACKSIZE give the old and new number of elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ -# define YYSTACK_RELOCATE(Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ while (0) #endif -#if defined (__STDC__) || defined (__cplusplus) - typedef signed char yysigned_char; -#else - typedef short int yysigned_char; -#endif +#if defined YYCOPY_NEEDED && YYCOPY_NEEDED +/* Copy COUNT objects from SRC to DST. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(Dst, Src, Count) \ + __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) +# else +# define YYCOPY(Dst, Src, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (Dst)[yyi] = (Src)[yyi]; \ + } \ + while (0) +# endif +# endif +#endif /* !YYCOPY_NEEDED */ -/* YYFINAL -- State number of the termination state. */ +/* YYFINAL -- State number of the termination state. */ #define YYFINAL 23 /* YYLAST -- Last index in YYTABLE. */ #define YYLAST 2215 -/* YYNTOKENS -- Number of terminals. */ +/* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 106 -/* YYNNTS -- Number of nonterminals. */ +/* YYNNTS -- Number of nonterminals. */ #define YYNNTS 158 -/* YYNRULES -- Number of rules. */ +/* YYNRULES -- Number of rules. */ #define YYNRULES 351 -/* YYNRULES -- Number of states. */ +/* YYNSTATES -- Number of states. */ #define YYNSTATES 575 -/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned + by yylex, with out-of-bounds checking. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 360 -#define YYTRANSLATE(YYX) \ +#define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) -/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ -static const unsigned char yytranslate[] = +/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM + as returned by yylex, without out-of-bounds checking. */ +static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -527,201 +676,51 @@ static const unsigned char yytranslate[] = }; #if YYDEBUG -/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in - YYRHS. */ -static const unsigned short int yyprhs[] = + /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ +static const yytype_uint16 yyrline[] = { - 0, 0, 3, 5, 7, 9, 11, 13, 15, 17, - 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, - 39, 41, 43, 45, 47, 49, 51, 54, 57, 59, - 61, 63, 65, 68, 72, 76, 80, 84, 86, 88, - 92, 93, 95, 96, 99, 100, 103, 107, 109, 111, - 115, 121, 123, 125, 127, 129, 132, 134, 136, 138, - 140, 142, 144, 146, 148, 150, 152, 154, 158, 161, - 165, 169, 174, 175, 177, 180, 183, 185, 189, 193, - 194, 197, 199, 201, 203, 205, 207, 209, 214, 216, - 220, 222, 226, 228, 232, 234, 236, 239, 242, 246, - 251, 256, 257, 259, 264, 268, 269, 271, 273, 277, - 281, 284, 286, 290, 292, 295, 300, 306, 311, 316, - 317, 320, 326, 332, 336, 340, 341, 343, 346, 350, - 354, 355, 358, 360, 362, 364, 367, 369, 372, 374, - 377, 379, 382, 386, 387, 389, 392, 394, 398, 402, - 403, 405, 407, 410, 412, 414, 416, 419, 423, 426, - 428, 430, 432, 434, 436, 438, 440, 442, 444, 446, - 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, - 468, 470, 472, 474, 478, 482, 485, 487, 489, 491, - 493, 495, 497, 499, 505, 513, 521, 527, 532, 533, - 535, 536, 539, 542, 544, 547, 551, 554, 560, 566, - 574, 584, 585, 587, 588, 590, 600, 601, 603, 605, - 607, 609, 611, 615, 619, 625, 629, 630, 632, 636, - 640, 644, 650, 654, 659, 660, 662, 664, 667, 673, - 676, 678, 680, 682, 684, 688, 690, 692, 694, 696, - 703, 704, 706, 707, 709, 711, 715, 720, 725, 730, - 735, 736, 738, 740, 743, 747, 750, 754, 758, 762, - 766, 770, 775, 782, 789, 796, 801, 806, 808, 810, - 814, 816, 818, 821, 824, 826, 828, 831, 834, 836, - 839, 842, 844, 847, 850, 852, 858, 863, 869, 871, - 875, 879, 883, 885, 889, 893, 895, 899, 903, 907, - 909, 913, 917, 921, 925, 929, 931, 935, 939, 941, - 945, 947, 951, 953, 957, 959, 963, 965, 969, 971, - 977, 979, 981, 985, 987, 989, 991, 993, 995, 997, - 999, 1001, 1003, 1005, 1007, 1009, 1011, 1013, 1015, 1017, - 1019, 1021 -}; - -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const short int yyrhs[] = -{ - 107, 0, -1, 122, -1, 109, -1, 53, -1, 50, - -1, 51, -1, 56, -1, 55, -1, 52, -1, 54, - -1, 111, -1, 112, -1, 7, -1, 36, -1, 26, - -1, 28, -1, 10, -1, 20, -1, 15, -1, 5, - -1, 113, -1, 116, -1, 117, -1, 113, -1, 113, - -1, 111, 234, -1, 117, 234, -1, 118, -1, 120, - -1, 119, -1, 57, -1, 71, 57, -1, 117, 72, - 119, -1, 117, 72, 11, -1, 117, 72, 42, -1, - 121, 72, 11, -1, 111, -1, 47, -1, 123, 124, - 125, -1, -1, 126, -1, -1, 124, 127, -1, -1, - 125, 130, -1, 31, 117, 101, -1, 128, -1, 129, - -1, 24, 117, 101, -1, 24, 117, 72, 103, 101, - -1, 134, -1, 165, -1, 101, -1, 132, -1, 131, - 132, -1, 34, -1, 33, -1, 32, -1, 37, -1, - 3, -1, 18, -1, 29, -1, 41, -1, 45, -1, - 48, -1, 38, -1, 135, 11, 119, -1, 133, 139, - -1, 133, 137, 139, -1, 133, 136, 139, -1, 133, - 136, 137, 139, -1, -1, 131, -1, 17, 114, -1, - 23, 138, -1, 115, -1, 138, 66, 115, -1, 68, - 140, 67, -1, -1, 140, 141, -1, 142, -1, 158, - -1, 159, -1, 130, -1, 143, -1, 148, -1, 135, - 110, 144, 101, -1, 145, -1, 144, 66, 145, -1, - 146, -1, 146, 73, 147, -1, 119, -1, 146, 62, - 61, -1, 261, -1, 174, -1, 149, 101, -1, 149, - 157, -1, 149, 157, 101, -1, 135, 110, 151, 150, - -1, 135, 47, 151, 150, -1, -1, 155, -1, 119, - 91, 152, 90, -1, 151, 62, 61, -1, -1, 153, - -1, 154, -1, 153, 66, 154, -1, 135, 110, 146, - -1, 44, 156, -1, 114, -1, 156, 66, 114, -1, - 177, -1, 37, 177, -1, 135, 160, 150, 161, -1, - 135, 160, 150, 161, 101, -1, 118, 91, 152, 90, - -1, 68, 162, 178, 67, -1, -1, 162, 163, -1, - 42, 91, 228, 90, 101, -1, 39, 91, 228, 90, - 101, -1, 135, 27, 119, -1, 164, 166, 168, -1, - -1, 167, -1, 17, 115, -1, 167, 66, 115, -1, - 68, 169, 67, -1, -1, 169, 170, -1, 171, -1, - 172, -1, 134, -1, 134, 101, -1, 165, -1, 165, - 101, -1, 143, -1, 149, 173, -1, 101, -1, 173, - 101, -1, 68, 175, 67, -1, -1, 176, -1, 176, - 66, -1, 147, -1, 176, 66, 147, -1, 68, 178, - 67, -1, -1, 179, -1, 180, -1, 179, 180, -1, - 181, -1, 183, -1, 134, -1, 182, 101, -1, 131, - 110, 144, -1, 110, 144, -1, 185, -1, 187, -1, - 191, -1, 192, -1, 201, -1, 204, -1, 185, -1, - 188, -1, 193, -1, 202, -1, 207, -1, 177, -1, - 186, -1, 189, -1, 194, -1, 203, -1, 213, -1, - 215, -1, 216, -1, 218, -1, 217, -1, 219, -1, - 212, -1, 101, -1, 119, 65, 183, -1, 119, 65, - 184, -1, 190, 101, -1, 258, -1, 242, -1, 243, - -1, 239, -1, 240, -1, 236, -1, 226, -1, 22, - 91, 261, 90, 183, -1, 22, 91, 261, 90, 184, - 16, 183, -1, 22, 91, 261, 90, 184, 16, 184, - -1, 40, 91, 261, 90, 195, -1, 68, 197, 196, - 67, -1, -1, 199, -1, -1, 197, 198, -1, 199, - 179, -1, 200, -1, 199, 200, -1, 8, 262, 65, - -1, 13, 65, -1, 49, 91, 261, 90, 183, -1, - 49, 91, 261, 90, 184, -1, 14, 183, 49, 91, - 261, 90, 101, -1, 21, 91, 206, 101, 208, 101, - 205, 90, 183, -1, -1, 210, -1, -1, 209, -1, - 21, 91, 206, 101, 208, 101, 205, 90, 184, -1, - -1, 261, -1, 211, -1, 182, -1, 211, -1, 190, - -1, 211, 66, 190, -1, 4, 261, 101, -1, 4, - 261, 65, 261, 101, -1, 6, 214, 101, -1, -1, - 119, -1, 12, 214, 101, -1, 35, 208, 101, -1, - 43, 261, 101, -1, 41, 91, 261, 90, 177, -1, - 46, 177, 221, -1, 46, 177, 220, 223, -1, -1, - 221, -1, 222, -1, 221, 222, -1, 9, 91, 154, - 90, 177, -1, 19, 177, -1, 225, -1, 230, -1, - 108, -1, 42, -1, 91, 261, 90, -1, 226, -1, - 235, -1, 236, -1, 237, -1, 263, 114, 91, 228, - 90, 227, -1, -1, 139, -1, -1, 229, -1, 261, - -1, 229, 66, 261, -1, 263, 111, 232, 231, -1, - 263, 113, 232, 231, -1, 263, 111, 234, 174, -1, - 263, 113, 234, 174, -1, -1, 234, -1, 233, -1, - 232, 233, -1, 62, 261, 61, -1, 62, 61, -1, - 234, 62, 61, -1, 224, 72, 119, -1, 39, 72, - 119, -1, 42, 72, 119, -1, 224, 72, 42, -1, - 117, 91, 228, 90, -1, 224, 72, 119, 91, 228, - 90, -1, 39, 72, 119, 91, 228, 90, -1, 42, - 72, 119, 91, 228, 90, -1, 117, 62, 261, 61, - -1, 225, 62, 261, 61, -1, 224, -1, 117, -1, - 116, 72, 11, -1, 239, -1, 240, -1, 238, 99, - -1, 238, 89, -1, 242, -1, 243, -1, 97, 241, - -1, 87, 241, -1, 244, -1, 99, 241, -1, 89, - 241, -1, 238, -1, 102, 241, -1, 75, 241, -1, - 245, -1, 91, 111, 231, 90, 241, -1, 91, 261, - 90, 244, -1, 91, 117, 234, 90, 244, -1, 241, - -1, 246, 103, 241, -1, 246, 69, 241, -1, 246, - 92, 241, -1, 246, -1, 247, 97, 246, -1, 247, - 87, 246, -1, 247, -1, 248, 86, 247, -1, 248, - 79, 247, -1, 248, 81, 247, -1, 248, -1, 249, - 84, 248, -1, 249, 77, 248, -1, 249, 85, 248, - -1, 249, 78, 248, -1, 249, 25, 112, -1, 249, - -1, 250, 74, 249, -1, 250, 76, 249, -1, 250, - -1, 251, 58, 250, -1, 251, -1, 252, 63, 251, - -1, 252, -1, 253, 94, 252, -1, 253, -1, 254, - 59, 253, -1, 254, -1, 255, 96, 254, -1, 255, - -1, 255, 100, 261, 65, 256, -1, 256, -1, 258, - -1, 259, 260, 257, -1, 117, -1, 235, -1, 237, - -1, 73, -1, 104, -1, 70, -1, 93, -1, 98, - -1, 88, -1, 83, -1, 80, -1, 82, -1, 60, - -1, 64, -1, 95, -1, 257, -1, 261, -1, 30, - -1, 117, 72, 30, -1 -}; - -/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const unsigned short int yyrline[] = -{ - 0, 191, 191, 200, 208, 216, 224, 232, 240, 249, - 257, 266, 274, 283, 288, 293, 298, 303, 308, 313, - 318, 324, 332, 341, 351, 360, 369, 377, 387, 393, - 400, 407, 413, 420, 429, 439, 449, 458, 466, 475, - 484, 490, 499, 505, 514, 520, 529, 541, 549, 558, - 570, 583, 591, 599, 608, 616, 625, 625, 625, 626, - 627, 627, 627, 627, 627, 627, 628, 631, 641, 650, - 659, 668, 678, 684, 693, 702, 711, 719, 728, 737, - 743, 752, 760, 768, 776, 785, 793, 802, 808, 816, - 825, 833, 842, 851, 860, 868, 877, 885, 893, 902, - 911, 921, 928, 938, 948, 955, 962, 965, 971, 981, - 991, 1001, 1007, 1017, 1027, 1037, 1046, 1056, 1067, 1077, - 1084, 1094, 1103, 1113, 1122, 1132, 1138, 1148, 1157, 1167, - 1177, 1184, 1193, 1202, 1211, 1220, 1228, 1237, 1246, 1256, - 1266, 1275, 1285, 1295, 1302, 1311, 1321, 1330, 1340, 1349, - 1356, 1366, 1375, 1385, 1394, 1403, 1413, 1423, 1432, 1442, - 1451, 1460, 1469, 1478, 1487, 1497, 1506, 1515, 1524, 1533, - 1543, 1552, 1561, 1570, 1579, 1588, 1597, 1606, 1615, 1624, - 1633, 1642, 1652, 1662, 1673, 1683, 1693, 1702, 1711, 1720, - 1729, 1738, 1747, 1757, 1767, 1777, 1787, 1794, 1801, 1808, - 1818, 1825, 1835, 1845, 1854, 1864, 1873, 1883, 1890, 1897, - 1904, 1912, 1919, 1929, 1936, 1946, 1956, 1963, 1973, 1982, - 1992, 2002, 2011, 2021, 2030, 2040, 2051, 2058, 2065, 2076, - 2086, 2096, 2106, 2115, 2125, 2132, 2142, 2151, 2161, 2168, - 2178, 2187, 2197, 2206, 2212, 2221, 2230, 2239, 2248, 2258, - 2268, 2275, 2285, 2292, 2302, 2311, 2321, 2330, 2339, 2348, - 2358, 2365, 2375, 2384, 2394, 2404, 2410, 2417, 2427, 2437, - 2447, 2458, 2468, 2479, 2489, 2500, 2510, 2520, 2529, 2538, - 2547, 2556, 2566, 2576, 2586, 2595, 2604, 2613, 2622, 2632, - 2642, 2652, 2661, 2670, 2679, 2689, 2698, 2707, 2714, 2723, - 2732, 2741, 2751, 2760, 2769, 2779, 2788, 2797, 2806, 2816, - 2825, 2834, 2843, 2852, 2861, 2871, 2880, 2889, 2899, 2908, - 2918, 2927, 2937, 2946, 2956, 2965, 2975, 2984, 2994, 3003, - 3013, 3022, 3032, 3042, 3052, 3061, 3071, 3080, 3089, 3098, - 3107, 3116, 3125, 3134, 3143, 3152, 3161, 3170, 3180, 3190, - 3200, 3209 + 0, 179, 179, 188, 196, 204, 212, 220, 228, 237, + 245, 254, 262, 271, 276, 281, 286, 291, 296, 301, + 306, 312, 320, 329, 339, 348, 357, 365, 375, 381, + 388, 395, 401, 408, 417, 427, 437, 446, 454, 463, + 472, 478, 487, 493, 502, 508, 517, 529, 537, 546, + 558, 571, 579, 587, 596, 604, 613, 613, 613, 614, + 615, 615, 615, 615, 615, 615, 616, 619, 629, 638, + 647, 656, 666, 672, 681, 690, 699, 707, 716, 725, + 731, 740, 748, 756, 764, 773, 781, 790, 796, 804, + 813, 821, 830, 839, 848, 856, 865, 873, 881, 890, + 899, 909, 916, 926, 936, 943, 950, 953, 959, 969, + 979, 989, 995, 1005, 1015, 1025, 1034, 1044, 1055, 1065, + 1072, 1082, 1091, 1101, 1110, 1120, 1126, 1136, 1145, 1155, + 1165, 1172, 1181, 1190, 1199, 1208, 1216, 1225, 1234, 1244, + 1254, 1263, 1273, 1283, 1290, 1299, 1309, 1318, 1328, 1337, + 1344, 1354, 1363, 1373, 1382, 1391, 1401, 1411, 1420, 1430, + 1439, 1448, 1457, 1466, 1475, 1485, 1494, 1503, 1512, 1521, + 1531, 1540, 1549, 1558, 1567, 1576, 1585, 1594, 1603, 1612, + 1621, 1630, 1640, 1650, 1661, 1671, 1681, 1690, 1699, 1708, + 1717, 1726, 1735, 1745, 1755, 1765, 1775, 1782, 1789, 1796, + 1806, 1813, 1823, 1833, 1842, 1852, 1861, 1871, 1878, 1885, + 1892, 1900, 1907, 1917, 1924, 1934, 1944, 1951, 1961, 1970, + 1980, 1990, 1999, 2009, 2018, 2028, 2039, 2046, 2053, 2064, + 2074, 2084, 2094, 2103, 2113, 2120, 2130, 2139, 2149, 2156, + 2166, 2175, 2185, 2194, 2200, 2209, 2218, 2227, 2236, 2246, + 2256, 2263, 2273, 2280, 2290, 2299, 2309, 2318, 2327, 2336, + 2346, 2353, 2363, 2372, 2382, 2392, 2398, 2405, 2415, 2425, + 2435, 2446, 2456, 2467, 2477, 2488, 2498, 2508, 2517, 2526, + 2535, 2544, 2554, 2564, 2574, 2583, 2592, 2601, 2610, 2620, + 2630, 2640, 2649, 2658, 2667, 2677, 2686, 2695, 2702, 2711, + 2720, 2729, 2739, 2748, 2757, 2767, 2776, 2785, 2794, 2804, + 2813, 2822, 2831, 2840, 2849, 2859, 2868, 2877, 2887, 2896, + 2906, 2915, 2925, 2934, 2944, 2953, 2963, 2972, 2982, 2991, + 3001, 3010, 3020, 3030, 3040, 3049, 3059, 3068, 3077, 3086, + 3095, 3104, 3113, 3122, 3131, 3140, 3149, 3158, 3168, 3178, + 3188, 3197 }; #endif -#if YYDEBUG || YYERROR_VERBOSE -/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +#if YYDEBUG || YYERROR_VERBOSE || 1 +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { "$end", "error", "$undefined", "jp_ABSTRACT", "jp_ASSERT", @@ -798,14 +797,14 @@ static const char *const yytname[] = "ConditionalAndExpression", "ConditionalOrExpression", "ConditionalExpression", "AssignmentExpression", "Assignment", "LeftHandSide", "AssignmentOperator", "Expression", "ConstantExpression", - "New", 0 + "New", YY_NULLPTR }; #endif # ifdef YYPRINT -/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to - token YYLEX-NUM. */ -static const unsigned short int yytoknum[] = +/* YYTOKNUM[NUM] -- (External) token number corresponding to the + (internal) symbol number NUM (which must be that of a token). */ +static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, @@ -821,178 +820,19 @@ static const unsigned short int yytoknum[] = }; # endif -/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const unsigned short int yyr1[] = -{ - 0, 106, 107, 108, 108, 108, 108, 108, 108, 109, - 109, 110, 110, 111, 111, 111, 111, 111, 111, 111, - 111, 112, 112, 113, 114, 115, 116, 116, 117, 117, - 118, 119, 119, 120, 120, 120, 120, 121, 121, 122, - 123, 123, 124, 124, 125, 125, 126, 127, 127, 128, - 129, 130, 130, 130, 131, 131, 132, 132, 132, 132, - 132, 132, 132, 132, 132, 132, 132, 133, 134, 134, - 134, 134, 135, 135, 136, 137, 138, 138, 139, 140, - 140, 141, 141, 141, 141, 142, 142, 143, 144, 144, - 145, 145, 146, 146, 147, 147, 148, 148, 148, 149, - 149, 150, 150, 151, 151, 152, 152, 153, 153, 154, - 155, 156, 156, 157, 158, 159, 159, 160, 161, 162, - 162, 163, 163, 164, 165, 166, 166, 167, 167, 168, - 169, 169, 170, 170, 170, 170, 170, 170, 171, 172, - 173, 173, 174, 175, 175, 175, 176, 176, 177, 178, - 178, 179, 179, 180, 180, 180, 181, 182, 182, 183, - 183, 183, 183, 183, 183, 184, 184, 184, 184, 184, - 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, - 185, 185, 186, 187, 188, 189, 190, 190, 190, 190, - 190, 190, 190, 191, 192, 193, 194, 195, 196, 196, - 197, 197, 198, 199, 199, 200, 200, 201, 202, 203, - 204, 205, 205, 206, 206, 207, 208, 208, 209, 209, - 210, 211, 211, 212, 212, 213, 214, 214, 215, 216, - 217, 218, 219, 219, 220, 220, 221, 221, 222, 223, - 224, 224, 225, 225, 225, 225, 225, 225, 225, 226, - 227, 227, 228, 228, 229, 229, 230, 230, 230, 230, - 231, 231, 232, 232, 233, 234, 234, 235, 235, 235, - 235, 236, 236, 236, 236, 237, 237, 238, 238, 238, - 238, 238, 239, 240, 241, 241, 241, 241, 241, 242, - 243, 244, 244, 244, 244, 245, 245, 245, 246, 246, - 246, 246, 247, 247, 247, 248, 248, 248, 248, 249, - 249, 249, 249, 249, 249, 250, 250, 250, 251, 251, - 252, 252, 253, 253, 254, 254, 255, 255, 256, 256, - 257, 257, 258, 259, 259, 259, 260, 260, 260, 260, - 260, 260, 260, 260, 260, 260, 260, 260, 261, 262, - 263, 263 -}; +#define YYPACT_NINF -503 -/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const unsigned char yyr2[] = -{ - 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, - 1, 1, 2, 3, 3, 3, 3, 1, 1, 3, - 0, 1, 0, 2, 0, 2, 3, 1, 1, 3, - 5, 1, 1, 1, 1, 2, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 3, 2, 3, - 3, 4, 0, 1, 2, 2, 1, 3, 3, 0, - 2, 1, 1, 1, 1, 1, 1, 4, 1, 3, - 1, 3, 1, 3, 1, 1, 2, 2, 3, 4, - 4, 0, 1, 4, 3, 0, 1, 1, 3, 3, - 2, 1, 3, 1, 2, 4, 5, 4, 4, 0, - 2, 5, 5, 3, 3, 0, 1, 2, 3, 3, - 0, 2, 1, 1, 1, 2, 1, 2, 1, 2, - 1, 2, 3, 0, 1, 2, 1, 3, 3, 0, - 1, 1, 2, 1, 1, 1, 2, 3, 2, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 3, 3, 2, 1, 1, 1, 1, - 1, 1, 1, 5, 7, 7, 5, 4, 0, 1, - 0, 2, 2, 1, 2, 3, 2, 5, 5, 7, - 9, 0, 1, 0, 1, 9, 0, 1, 1, 1, - 1, 1, 3, 3, 5, 3, 0, 1, 3, 3, - 3, 5, 3, 4, 0, 1, 1, 2, 5, 2, - 1, 1, 1, 1, 3, 1, 1, 1, 1, 6, - 0, 1, 0, 1, 1, 3, 4, 4, 4, 4, - 0, 1, 1, 2, 3, 2, 3, 3, 3, 3, - 3, 4, 6, 6, 6, 4, 4, 1, 1, 3, - 1, 1, 2, 2, 1, 1, 2, 2, 1, 2, - 2, 1, 2, 2, 1, 5, 4, 5, 1, 3, - 3, 3, 1, 3, 3, 1, 3, 3, 3, 1, - 3, 3, 3, 3, 3, 1, 3, 3, 1, 3, - 1, 3, 1, 3, 1, 3, 1, 3, 1, 5, - 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 3 -}; +#define yypact_value_is_default(Yystate) \ + (!!((Yystate) == (-503))) -/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state - STATE-NUM when YYTABLE doesn't specify something else to do. Zero - means the default is an error. */ -static const unsigned short int yydefact[] = -{ - 40, 0, 0, 2, 42, 41, 20, 13, 17, 19, - 18, 15, 16, 14, 38, 31, 0, 37, 0, 28, - 30, 29, 0, 1, 44, 32, 0, 46, 0, 0, - 72, 43, 47, 48, 34, 35, 33, 36, 0, 60, - 61, 62, 58, 57, 56, 59, 66, 63, 64, 65, - 53, 45, 73, 54, 0, 51, 0, 125, 52, 0, - 49, 55, 0, 0, 79, 0, 0, 68, 0, 0, - 0, 0, 126, 0, 24, 74, 23, 25, 76, 75, - 72, 0, 70, 69, 67, 123, 127, 130, 124, 0, - 50, 0, 59, 78, 84, 0, 80, 81, 85, 86, - 0, 82, 83, 71, 72, 128, 77, 72, 114, 38, - 0, 11, 12, 21, 22, 23, 28, 101, 96, 97, - 113, 129, 134, 0, 138, 0, 136, 131, 132, 133, - 0, 226, 226, 0, 0, 0, 350, 216, 0, 0, - 63, 243, 0, 0, 0, 5, 6, 9, 4, 10, - 8, 7, 0, 0, 0, 182, 242, 3, 0, 22, - 333, 30, 73, 155, 0, 170, 0, 72, 151, 153, - 0, 154, 159, 171, 160, 172, 0, 161, 162, 173, - 163, 174, 164, 181, 175, 176, 177, 179, 178, 180, - 277, 240, 245, 241, 246, 247, 248, 0, 189, 190, - 187, 188, 186, 0, 0, 0, 101, 92, 0, 88, - 90, 101, 0, 26, 27, 72, 0, 0, 102, 98, - 135, 140, 139, 137, 0, 0, 0, 0, 0, 37, - 0, 278, 245, 247, 291, 280, 281, 298, 284, 285, - 288, 294, 302, 305, 309, 315, 318, 320, 322, 324, - 326, 328, 330, 348, 331, 0, 227, 0, 0, 0, - 0, 213, 0, 0, 217, 0, 0, 0, 0, 0, - 234, 0, 278, 246, 248, 290, 0, 289, 92, 158, - 0, 0, 0, 252, 0, 0, 148, 152, 156, 185, - 0, 0, 283, 282, 345, 346, 338, 336, 343, 344, - 342, 341, 339, 347, 340, 337, 0, 37, 24, 0, - 72, 0, 100, 0, 87, 0, 0, 99, 265, 0, - 0, 0, 106, 107, 111, 110, 119, 115, 141, 293, - 287, 37, 278, 0, 286, 292, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 223, 225, - 228, 0, 0, 219, 221, 0, 214, 218, 0, 229, - 268, 0, 0, 269, 230, 0, 0, 232, 236, 0, - 244, 279, 0, 351, 0, 253, 254, 183, 157, 270, - 267, 0, 332, 0, 260, 262, 0, 260, 0, 252, - 0, 104, 89, 93, 143, 91, 95, 94, 266, 0, - 117, 72, 0, 72, 116, 0, 26, 27, 244, 300, - 301, 299, 304, 303, 307, 308, 306, 314, 311, 313, - 310, 312, 316, 317, 319, 321, 323, 325, 327, 0, - 0, 0, 216, 0, 0, 252, 0, 0, 252, 72, - 0, 233, 237, 0, 275, 271, 0, 252, 276, 0, - 256, 263, 261, 258, 257, 259, 0, 103, 146, 0, - 144, 109, 108, 112, 0, 243, 120, 0, 0, 0, - 296, 0, 224, 0, 0, 222, 0, 0, 0, 30, - 193, 0, 159, 166, 167, 168, 169, 0, 200, 196, - 231, 0, 0, 239, 207, 255, 0, 264, 250, 142, - 145, 252, 252, 118, 295, 297, 329, 0, 211, 213, - 0, 0, 0, 0, 273, 198, 274, 0, 272, 251, - 249, 147, 0, 0, 209, 0, 212, 220, 0, 0, - 0, 184, 194, 0, 0, 0, 201, 72, 203, 238, - 0, 0, 0, 216, 0, 0, 349, 0, 206, 197, - 202, 204, 122, 121, 210, 0, 0, 208, 205, 211, - 0, 0, 195, 0, 215 -}; +#define YYTABLE_NINF -336 -/* YYDEFGOTO[NTERM-NUM]. */ -static const short int yydefgoto[] = -{ - -1, 2, 156, 157, 158, 229, 112, 113, 75, 78, - 230, 231, 19, 20, 21, 22, 3, 4, 24, 30, - 5, 31, 32, 33, 51, 52, 53, 54, 163, 164, - 65, 66, 79, 67, 80, 96, 97, 98, 208, 209, - 210, 405, 99, 100, 217, 206, 321, 322, 323, 218, - 325, 119, 101, 102, 117, 327, 413, 476, 57, 58, - 71, 72, 88, 104, 127, 128, 129, 222, 406, 469, - 470, 165, 166, 167, 168, 169, 170, 171, 491, 172, - 173, 174, 493, 175, 176, 177, 178, 494, 179, 499, - 545, 525, 546, 547, 548, 180, 495, 181, 182, 535, - 365, 496, 263, 366, 536, 367, 183, 184, 257, 185, - 186, 187, 188, 189, 376, 377, 378, 451, 190, 191, - 232, 530, 384, 385, 193, 415, 394, 395, 214, 194, - 233, 196, 234, 235, 236, 237, 238, 239, 240, 241, - 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, - 252, 253, 254, 203, 306, 386, 557, 204 -}; +#define yytable_value_is_error(Yytable_value) \ + 0 -/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ -#define YYPACT_NINF -503 -static const short int yypact[] = + /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +static const yytype_int16 yypact[] = { 159, 1039, 236, -503, -503, -503, -503, -503, -503, -503, -503, -503, -503, -503, -503, -503, 186, -503, 56, -503, @@ -1054,8 +894,73 @@ static const short int yypact[] = 1699, 432, -503, 1699, -503 }; -/* YYPGOTO[NTERM-NUM]. */ -static const short int yypgoto[] = + /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. + Performed when YYTABLE does not specify something else to do. Zero + means the default is an error. */ +static const yytype_uint16 yydefact[] = +{ + 40, 0, 0, 2, 42, 41, 20, 13, 17, 19, + 18, 15, 16, 14, 38, 31, 0, 37, 0, 28, + 30, 29, 0, 1, 44, 32, 0, 46, 0, 0, + 72, 43, 47, 48, 34, 35, 33, 36, 0, 60, + 61, 62, 58, 57, 56, 59, 66, 63, 64, 65, + 53, 45, 73, 54, 0, 51, 0, 125, 52, 0, + 49, 55, 0, 0, 79, 0, 0, 68, 0, 0, + 0, 0, 126, 0, 24, 74, 23, 25, 76, 75, + 72, 0, 70, 69, 67, 123, 127, 130, 124, 0, + 50, 0, 59, 78, 84, 0, 80, 81, 85, 86, + 0, 82, 83, 71, 72, 128, 77, 72, 114, 38, + 0, 11, 12, 21, 22, 23, 28, 101, 96, 97, + 113, 129, 134, 0, 138, 0, 136, 131, 132, 133, + 0, 226, 226, 0, 0, 0, 350, 216, 0, 0, + 63, 243, 0, 0, 0, 5, 6, 9, 4, 10, + 8, 7, 0, 0, 0, 182, 242, 3, 0, 22, + 333, 30, 73, 155, 0, 170, 0, 72, 151, 153, + 0, 154, 159, 171, 160, 172, 0, 161, 162, 173, + 163, 174, 164, 181, 175, 176, 177, 179, 178, 180, + 277, 240, 245, 241, 246, 247, 248, 0, 189, 190, + 187, 188, 186, 0, 0, 0, 101, 92, 0, 88, + 90, 101, 0, 26, 27, 72, 0, 0, 102, 98, + 135, 140, 139, 137, 0, 0, 0, 0, 0, 37, + 0, 278, 245, 247, 291, 280, 281, 298, 284, 285, + 288, 294, 302, 305, 309, 315, 318, 320, 322, 324, + 326, 328, 330, 348, 331, 0, 227, 0, 0, 0, + 0, 213, 0, 0, 217, 0, 0, 0, 0, 0, + 234, 0, 278, 246, 248, 290, 0, 289, 92, 158, + 0, 0, 0, 252, 0, 0, 148, 152, 156, 185, + 0, 0, 283, 282, 345, 346, 338, 336, 343, 344, + 342, 341, 339, 347, 340, 337, 0, 37, 24, 0, + 72, 0, 100, 0, 87, 0, 0, 99, 265, 0, + 0, 0, 106, 107, 111, 110, 119, 115, 141, 293, + 287, 37, 278, 0, 286, 292, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 223, 225, + 228, 0, 0, 219, 221, 0, 214, 218, 0, 229, + 268, 0, 0, 269, 230, 0, 0, 232, 236, 0, + 244, 279, 0, 351, 0, 253, 254, 183, 157, 270, + 267, 0, 332, 0, 260, 262, 0, 260, 0, 252, + 0, 104, 89, 93, 143, 91, 95, 94, 266, 0, + 117, 72, 0, 72, 116, 0, 26, 27, 244, 300, + 301, 299, 304, 303, 307, 308, 306, 314, 311, 313, + 310, 312, 316, 317, 319, 321, 323, 325, 327, 0, + 0, 0, 216, 0, 0, 252, 0, 0, 252, 72, + 0, 233, 237, 0, 275, 271, 0, 252, 276, 0, + 256, 263, 261, 258, 257, 259, 0, 103, 146, 0, + 144, 109, 108, 112, 0, 243, 120, 0, 0, 0, + 296, 0, 224, 0, 0, 222, 0, 0, 0, 30, + 193, 0, 159, 166, 167, 168, 169, 0, 200, 196, + 231, 0, 0, 239, 207, 255, 0, 264, 250, 142, + 145, 252, 252, 118, 295, 297, 329, 0, 211, 213, + 0, 0, 0, 0, 273, 198, 274, 0, 272, 251, + 249, 147, 0, 0, 209, 0, 212, 220, 0, 0, + 0, 184, 194, 0, 0, 0, 201, 72, 203, 238, + 0, 0, 0, 216, 0, 0, 349, 0, 206, 197, + 202, 204, 122, 121, 210, 0, 0, 208, 205, 211, + 0, 0, 195, 0, 215 +}; + + /* YYPGOTO[NTERM-NUM]. */ +static const yytype_int16 yypgoto[] = { -503, -503, -503, -503, -85, 2, 181, -41, -198, -45, -87, -1, 431, 14, -503, -503, -503, -503, -503, -503, @@ -1075,12 +980,31 @@ static const short int yypgoto[] = 95, 274, 350, -503, -503, 660, -503, -503 }; -/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule which - number is the opposite. If zero, do what YYDEFACT says. - If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -336 -static const short int yytable[] = + /* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int16 yydefgoto[] = +{ + -1, 2, 156, 157, 158, 229, 112, 113, 75, 78, + 230, 231, 19, 20, 21, 22, 3, 4, 24, 30, + 5, 31, 32, 33, 51, 52, 53, 54, 163, 164, + 65, 66, 79, 67, 80, 96, 97, 98, 208, 209, + 210, 405, 99, 100, 217, 206, 321, 322, 323, 218, + 325, 119, 101, 102, 117, 327, 413, 476, 57, 58, + 71, 72, 88, 104, 127, 128, 129, 222, 406, 469, + 470, 165, 166, 167, 168, 169, 170, 171, 491, 172, + 173, 174, 493, 175, 176, 177, 178, 494, 179, 499, + 545, 525, 546, 547, 548, 180, 495, 181, 182, 535, + 365, 496, 263, 366, 536, 367, 183, 184, 257, 185, + 186, 187, 188, 189, 376, 377, 378, 451, 190, 191, + 232, 530, 384, 385, 193, 415, 394, 395, 214, 194, + 233, 196, 234, 235, 236, 237, 238, 239, 240, 241, + 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, + 252, 253, 254, 203, 306, 386, 557, 204 +}; + + /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule whose + number is the opposite. If YYTABLE_NINF, syntax error. */ +static const yytype_int16 yytable[] = { 18, 82, 83, 17, 287, 61, 309, 56, 114, 364, 110, 363, 279, 468, 34, 108, 537, 103, 324, 107, @@ -1306,7 +1230,7 @@ static const short int yytable[] = 0, 0, 0, 0, 0, 305 }; -static const short int yycheck[] = +static const yytype_int16 yycheck[] = { 1, 65, 66, 1, 167, 52, 204, 30, 95, 261, 95, 261, 158, 404, 11, 92, 518, 81, 216, 68, @@ -1532,9 +1456,9 @@ static const short int yycheck[] = -1, -1, -1, -1, -1, 104 }; -/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ -static const unsigned short int yystos[] = + /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint16 yystos[] = { 0, 31, 107, 122, 123, 126, 5, 7, 10, 15, 20, 26, 28, 36, 47, 57, 71, 111, 117, 118, @@ -1596,78 +1520,123 @@ static const unsigned short int yystos[] = 16, 205, 184, 90, 184 }; -#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) -# define YYSIZE_T __SIZE_TYPE__ -#endif -#if ! defined (YYSIZE_T) && defined (size_t) -# define YYSIZE_T size_t -#endif -#if ! defined (YYSIZE_T) -# if defined (__STDC__) || defined (__cplusplus) -# include <stddef.h> /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# endif -#endif -#if ! defined (YYSIZE_T) -# define YYSIZE_T unsigned int -#endif + /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint16 yyr1[] = +{ + 0, 106, 107, 108, 108, 108, 108, 108, 108, 109, + 109, 110, 110, 111, 111, 111, 111, 111, 111, 111, + 111, 112, 112, 113, 114, 115, 116, 116, 117, 117, + 118, 119, 119, 120, 120, 120, 120, 121, 121, 122, + 123, 123, 124, 124, 125, 125, 126, 127, 127, 128, + 129, 130, 130, 130, 131, 131, 132, 132, 132, 132, + 132, 132, 132, 132, 132, 132, 132, 133, 134, 134, + 134, 134, 135, 135, 136, 137, 138, 138, 139, 140, + 140, 141, 141, 141, 141, 142, 142, 143, 144, 144, + 145, 145, 146, 146, 147, 147, 148, 148, 148, 149, + 149, 150, 150, 151, 151, 152, 152, 153, 153, 154, + 155, 156, 156, 157, 158, 159, 159, 160, 161, 162, + 162, 163, 163, 164, 165, 166, 166, 167, 167, 168, + 169, 169, 170, 170, 170, 170, 170, 170, 171, 172, + 173, 173, 174, 175, 175, 175, 176, 176, 177, 178, + 178, 179, 179, 180, 180, 180, 181, 182, 182, 183, + 183, 183, 183, 183, 183, 184, 184, 184, 184, 184, + 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, + 185, 185, 186, 187, 188, 189, 190, 190, 190, 190, + 190, 190, 190, 191, 192, 193, 194, 195, 196, 196, + 197, 197, 198, 199, 199, 200, 200, 201, 202, 203, + 204, 205, 205, 206, 206, 207, 208, 208, 209, 209, + 210, 211, 211, 212, 212, 213, 214, 214, 215, 216, + 217, 218, 219, 219, 220, 220, 221, 221, 222, 223, + 224, 224, 225, 225, 225, 225, 225, 225, 225, 226, + 227, 227, 228, 228, 229, 229, 230, 230, 230, 230, + 231, 231, 232, 232, 233, 234, 234, 235, 235, 235, + 235, 236, 236, 236, 236, 237, 237, 238, 238, 238, + 238, 238, 239, 240, 241, 241, 241, 241, 241, 242, + 243, 244, 244, 244, 244, 245, 245, 245, 246, 246, + 246, 246, 247, 247, 247, 248, 248, 248, 248, 249, + 249, 249, 249, 249, 249, 250, 250, 250, 251, 251, + 252, 252, 253, 253, 254, 254, 255, 255, 256, 256, + 257, 257, 258, 259, 259, 259, 260, 260, 260, 260, + 260, 260, 260, 260, 260, 260, 260, 260, 261, 262, + 263, 263 +}; -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 + /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, + 1, 1, 2, 3, 3, 3, 3, 1, 1, 3, + 0, 1, 0, 2, 0, 2, 3, 1, 1, 3, + 5, 1, 1, 1, 1, 2, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 3, 2, 3, + 3, 4, 0, 1, 2, 2, 1, 3, 3, 0, + 2, 1, 1, 1, 1, 1, 1, 4, 1, 3, + 1, 3, 1, 3, 1, 1, 2, 2, 3, 4, + 4, 0, 1, 4, 3, 0, 1, 1, 3, 3, + 2, 1, 3, 1, 2, 4, 5, 4, 4, 0, + 2, 5, 5, 3, 3, 0, 1, 2, 3, 3, + 0, 2, 1, 1, 1, 2, 1, 2, 1, 2, + 1, 2, 3, 0, 1, 2, 1, 3, 3, 0, + 1, 1, 2, 1, 1, 1, 2, 3, 2, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 3, 3, 2, 1, 1, 1, 1, + 1, 1, 1, 5, 7, 7, 5, 4, 0, 1, + 0, 2, 2, 1, 2, 3, 2, 5, 5, 7, + 9, 0, 1, 0, 1, 9, 0, 1, 1, 1, + 1, 1, 3, 3, 5, 3, 0, 1, 3, 3, + 3, 5, 3, 4, 0, 1, 1, 2, 5, 2, + 1, 1, 1, 1, 3, 1, 1, 1, 1, 6, + 0, 1, 0, 1, 1, 3, 4, 4, 4, 4, + 0, 1, 1, 2, 3, 2, 3, 3, 3, 3, + 3, 4, 6, 6, 6, 4, 4, 1, 1, 3, + 1, 1, 2, 2, 1, 1, 2, 2, 1, 2, + 2, 1, 2, 2, 1, 5, 4, 5, 1, 3, + 3, 3, 1, 3, 3, 1, 3, 3, 3, 1, + 3, 3, 3, 3, 3, 1, 3, 3, 1, 3, + 1, 3, 1, 3, 1, 3, 1, 3, 1, 5, + 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 3 +}; -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 -/* Like YYERROR except do call yyerror. This remains here temporarily - to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. */ +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab -#define YYFAIL goto yyerrlab #define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY && yylen == 1) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - yytoken = YYTRANSLATE (yychar); \ - YYPOPSTACK; \ - goto yybackup; \ - } \ - else \ - { \ - yyerror ("syntax error: cannot back up");\ - YYERROR; \ - } \ +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (yyscanner, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ while (0) -#define YYTERROR 1 -#define YYERRCODE 256 - -/* YYLLOC_DEFAULT -- Compute the default location (before the actions - are run). */ +/* Error token number */ +#define YYTERROR 1 +#define YYERRCODE 256 -#ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - ((Current).first_line = (Rhs)[1].first_line, \ - (Current).first_column = (Rhs)[1].first_column, \ - (Current).last_line = (Rhs)[N].last_line, \ - (Current).last_column = (Rhs)[N].last_column) -#endif -/* YYLEX -- calling `yylex' with the right arguments. */ - -#ifdef YYLEX_PARAM -# define YYLEX yylex (&yylval, YYLEX_PARAM) -#else -# define YYLEX yylex (&yylval) -#endif /* Enable debugging if requested. */ #if YYDEBUG @@ -1677,54 +1646,85 @@ while (0) # define YYFPRINTF fprintf # endif -# define YYDPRINTF(Args) \ -do { \ - if (yydebug) \ - YYFPRINTF Args; \ +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ } while (0) -# define YYDSYMPRINT(Args) \ -do { \ - if (yydebug) \ - yysymprint Args; \ -} while (0) +/* This macro is provided for backward compatibility. */ +#ifndef YY_LOCATION_PRINT +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +#endif -# define YYDSYMPRINTF(Title, Token, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yysymprint (stderr, \ - Token, Value); \ - YYFPRINTF (stderr, "\n"); \ - } \ + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, yyscanner); \ + YYFPRINTF (stderr, "\n"); \ + } \ } while (0) + +/*----------------------------------------. +| Print this symbol's value on YYOUTPUT. | +`----------------------------------------*/ + +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner) +{ + FILE *yyo = yyoutput; + YYUSE (yyo); + YYUSE (yyscanner); + if (!yyvaluep) + return; +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# endif + YYUSE (yytype); +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner) +{ + YYFPRINTF (yyoutput, "%s %s (", + yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner); + YYFPRINTF (yyoutput, ")"); +} + /*------------------------------------------------------------------. | yy_stack_print -- Print the state stack from its BOTTOM up to its | | TOP (included). | `------------------------------------------------------------------*/ -#if defined (__STDC__) || defined (__cplusplus) static void -yy_stack_print (short int *bottom, short int *top) -#else -static void -yy_stack_print (bottom, top) - short int *bottom; - short int *top; -#endif +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) { YYFPRINTF (stderr, "Stack now"); - for (/* Nothing. */; bottom <= top; ++bottom) - YYFPRINTF (stderr, " %d", *bottom); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } YYFPRINTF (stderr, "\n"); } -# define YY_STACK_PRINT(Bottom, Top) \ -do { \ - if (yydebug) \ - yy_stack_print ((Bottom), (Top)); \ +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ } while (0) @@ -1732,29 +1732,30 @@ do { \ | Report that the YYRULE is going to be reduced. | `------------------------------------------------*/ -#if defined (__STDC__) || defined (__cplusplus) static void -yy_reduce_print (int yyrule) -#else -static void -yy_reduce_print (yyrule) - int yyrule; -#endif +yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, yyscan_t yyscanner) { + unsigned long int yylno = yyrline[yyrule]; + int yynrhs = yyr2[yyrule]; int yyi; - unsigned int yylno = yyrline[yyrule]; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", yyrule - 1, yylno); - /* Print the symbols being reduced, and their result. */ - for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) - YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); - YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + YYFPRINTF (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, + yystos[yyssp[yyi + 1 - yynrhs]], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , yyscanner); + YYFPRINTF (stderr, "\n"); + } } -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug) \ - yy_reduce_print (Rule); \ +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyssp, yyvsp, Rule, yyscanner); \ } while (0) /* Nonzero means print parse trace. It is left uninitialized so that @@ -1762,15 +1763,14 @@ do { \ int yydebug; #else /* !YYDEBUG */ # define YYDPRINTF(Args) -# define YYDSYMPRINT(Args) -# define YYDSYMPRINTF(Title, Token, Value, Location) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) # define YY_STACK_PRINT(Bottom, Top) # define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ /* YYINITDEPTH -- initial size of the parser's stacks. */ -#ifndef YYINITDEPTH +#ifndef YYINITDEPTH # define YYINITDEPTH 200 #endif @@ -1778,58 +1778,40 @@ int yydebug; if the built-in stack extension method is used). Do not make this value too large; the results are undefined if - SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) evaluated with infinite-precision integer arithmetic. */ -#if defined (YYMAXDEPTH) && YYMAXDEPTH == 0 -# undef YYMAXDEPTH -#endif - #ifndef YYMAXDEPTH # define YYMAXDEPTH 10000 #endif - #if YYERROR_VERBOSE # ifndef yystrlen -# if defined (__GLIBC__) && defined (_STRING_H) +# if defined __GLIBC__ && defined _STRING_H # define yystrlen strlen # else /* Return the length of YYSTR. */ static YYSIZE_T -# if defined (__STDC__) || defined (__cplusplus) yystrlen (const char *yystr) -# else -yystrlen (yystr) - const char *yystr; -# endif { - const char *yys = yystr; - - while (*yys++ != '\0') + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) continue; - - return yys - yystr - 1; + return yylen; } # endif # endif # ifndef yystpcpy -# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE # define yystpcpy stpcpy # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ static char * -# if defined (__STDC__) || defined (__cplusplus) yystpcpy (char *yydest, const char *yysrc) -# else -yystpcpy (yydest, yysrc) - char *yydest; - const char *yysrc; -# endif { char *yyd = yydest; const char *yys = yysrc; @@ -1842,91 +1824,207 @@ yystpcpy (yydest, yysrc) # endif # endif -#endif /* !YYERROR_VERBOSE */ +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; - + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } -#if YYDEBUG -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ + if (! yyres) + return yystrlen (yystr); -#if defined (__STDC__) || defined (__cplusplus) -static void -yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) -#else -static void -yysymprint (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE *yyvaluep; -#endif + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message + about the unexpected token YYTOKEN for the state stack whose top is + YYSSP. + + Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is + not large enough to hold the message. In that case, also set + *YYMSG_ALLOC to the required number of bytes. Return 2 if the + required number of bytes is too large to store. */ +static int +yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, + yytype_int16 *yyssp, int yytoken) { - /* Pacify ``unused variable'' warnings. */ - (void) yyvaluep; + YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); + YYSIZE_T yysize = yysize0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + /* Internationalized format string. */ + const char *yyformat = YY_NULLPTR; + /* Arguments of yyformat. */ + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + /* Number of reported tokens (one for the "unexpected", one per + "expected"). */ + int yycount = 0; + + /* There are many possibilities here to consider: + - If this state is a consistent state with a default action, then + the only way this function was invoked is if the default action + is an error action. In that case, don't check for expected + tokens because there are none. + - The only way there can be no lookahead present (in yychar) is if + this state is a consistent state with a default action. Thus, + detecting the absence of a lookahead is sufficient to determine + that there is no unexpected or expected token to report. In that + case, just report a simple "syntax error". + - Don't assume there isn't a lookahead just because this state is a + consistent state with a default action. There might have been a + previous inconsistent state, consistent state with a non-default + action, or user semantic action that manipulated yychar. + - Of course, the expected token list depends on states to have + correct lookahead information, and it depends on the parser not + to perform extra reductions after fetching a lookahead from the + scanner and before detecting a syntax error. Thus, state merging + (from LALR or IELR) and default reductions corrupt the expected + token list. However, the list is correct for canonical LR with + one exception: it will still contain any token that will not be + accepted due to an error action in a later state. + */ + if (yytoken != YYEMPTY) + { + int yyn = yypact[*yyssp]; + yyarg[yycount++] = yytname[yytoken]; + if (!yypact_value_is_default (yyn)) + { + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. In other words, skip the first -YYN actions for + this state because they are default actions. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yyx; + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR + && !yytable_value_is_error (yytable[yyx + yyn])) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + break; + } + yyarg[yycount++] = yytname[yyx]; + { + YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); + if (! (yysize <= yysize1 + && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } + } + } + } - if (yytype < YYNTOKENS) - { - YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); -# ifdef YYPRINT - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); -# endif + switch (yycount) + { +# define YYCASE_(N, S) \ + case N: \ + yyformat = S; \ + break + YYCASE_(0, YY_("syntax error")); + YYCASE_(1, YY_("syntax error, unexpected %s")); + YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); + YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); + YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); + YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); +# undef YYCASE_ } - else - YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); - switch (yytype) + { + YYSIZE_T yysize1 = yysize + yystrlen (yyformat); + if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } + + if (*yymsg_alloc < yysize) { - default: - break; + *yymsg_alloc = 2 * yysize; + if (! (yysize <= *yymsg_alloc + && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) + *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; + return 1; } - YYFPRINTF (yyoutput, ")"); + + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + { + char *yyp = *yymsg; + int yyi = 0; + while ((*yyp = *yyformat) != '\0') + if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyformat += 2; + } + else + { + yyp++; + yyformat++; + } + } + return 0; } +#endif /* YYERROR_VERBOSE */ -#endif /* ! YYDEBUG */ /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ -#if defined (__STDC__) || defined (__cplusplus) -static void -yydestruct (int yytype, YYSTYPE *yyvaluep) -#else static void -yydestruct (yytype, yyvaluep) - int yytype; - YYSTYPE *yyvaluep; -#endif +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, yyscan_t yyscanner) { - /* Pacify ``unused variable'' warnings. */ - (void) yyvaluep; - - switch (yytype) - { + YYUSE (yyvaluep); + YYUSE (yyscanner); + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); - default: - break; - } + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + YYUSE (yytype); + YY_IGNORE_MAYBE_UNINITIALIZED_END } - - -/* Prevent warnings from -Wmissing-prototypes. */ - -#ifdef YYPARSE_PARAM -# if defined (__STDC__) || defined (__cplusplus) -int yyparse (void *YYPARSE_PARAM); -# else -int yyparse (); -# endif -#else /* ! YYPARSE_PARAM */ -#if defined (__STDC__) || defined (__cplusplus) -int yyparse (void); -#else -int yyparse (); -#endif -#endif /* ! YYPARSE_PARAM */ - - @@ -1935,90 +2033,76 @@ int yyparse (); | yyparse. | `----------*/ -#ifdef YYPARSE_PARAM -# if defined (__STDC__) || defined (__cplusplus) -int yyparse (void *YYPARSE_PARAM) -# else -int yyparse (YYPARSE_PARAM) - void *YYPARSE_PARAM; -# endif -#else /* ! YYPARSE_PARAM */ -#if defined (__STDC__) || defined (__cplusplus) int -yyparse (void) -#else -int -yyparse () - -#endif -#endif +yyparse (yyscan_t yyscanner) { - /* The lookahead symbol. */ +/* The lookahead symbol. */ int yychar; -/* The semantic value of the lookahead symbol. */ -YYSTYPE yylval; - -/* Number of syntax errors so far. */ -int yynerrs; - - int yystate; - int yyn; - int yyresult; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - /* Lookahead token as an internal (translated) token number. */ - int yytoken = 0; - /* Three stacks and their tools: - `yyss': related to states, - `yyvs': related to semantic values, - `yyls': related to locations. +/* The semantic value of the lookahead symbol. */ +/* Default value used for initialization, for pacifying older GCCs + or non-GCC compilers. */ +YY_INITIAL_VALUE (static YYSTYPE yyval_default;) +YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ + /* Number of syntax errors so far. */ + int yynerrs; - /* The state stack. */ - short int yyssa[YYINITDEPTH]; - short int *yyss = yyssa; - short int *yyssp; + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - YYSTYPE *yyvsp; + /* The stacks and their tools: + 'yyss': related to states. + 'yyvs': related to semantic values. + Refer to the stacks through separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; -#define YYPOPSTACK (yyvsp--, yyssp--) + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; - YYSIZE_T yystacksize = YYINITDEPTH; + YYSIZE_T yystacksize; + int yyn; + int yyresult; + /* Lookahead token as an internal (translated) token number. */ + int yytoken = 0; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; - /* When reducing, the number of symbols on the RHS of the reduced - rule. */ - int yylen; + yyssp = yyss = yyssa; + yyvsp = yyvs = yyvsa; + yystacksize = YYINITDEPTH; YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ - - /* Initialize stack pointers. - Waste one element of value and location stack - so that they stay on the same level as the state stack. - The wasted elements are never initialized. */ - - yyssp = yyss; - yyvsp = yyvs; - - + yychar = YYEMPTY; /* Cause a token to be read. */ goto yysetstate; /*------------------------------------------------------------. @@ -2026,8 +2110,7 @@ int yynerrs; `------------------------------------------------------------*/ yynewstate: /* In all cases, when you get here, the value and location stacks - have just been pushed. so pushing a state here evens the stacks. - */ + have just been pushed. So pushing a state here evens the stacks. */ yyssp++; yysetstate: @@ -2040,49 +2123,46 @@ int yynerrs; #ifdef yyoverflow { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - YYSTYPE *yyvs1 = yyvs; - short int *yyss1 = yyss; - - - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. This used to be a - conditional around just the two extra args, but that might - be undefined if yyoverflow is a macro. */ - yyoverflow ("parser stack overflow", - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - - &yystacksize); - - yyss = yyss1; - yyvs = yyvs1; + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; } #else /* no yyoverflow */ # ifndef YYSTACK_RELOCATE - goto yyoverflowlab; + goto yyexhaustedlab; # else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) - goto yyoverflowlab; + goto yyexhaustedlab; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) - yystacksize = YYMAXDEPTH; + yystacksize = YYMAXDEPTH; { - short int *yyss1 = yyss; - union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); - if (! yyptr) - goto yyoverflowlab; - YYSTACK_RELOCATE (yyss); - YYSTACK_RELOCATE (yyvs); - + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); # undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); } # endif #endif /* no yyoverflow */ @@ -2090,16 +2170,18 @@ int yynerrs; yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; - YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); + (unsigned long int) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) - YYABORT; + YYABORT; } YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + if (yystate == YYFINAL) + YYACCEPT; + goto yybackup; /*-----------. @@ -2107,14 +2189,12 @@ int yynerrs; `-----------*/ yybackup: -/* Do appropriate processing given the current state. */ -/* Read a lookahead token if we need one and don't already have one. */ -/* yyresume: */ + /* Do appropriate processing given the current state. Read a + lookahead token if we need one and don't already have one. */ /* First try to decide what to do without reference to lookahead token. */ - yyn = yypact[yystate]; - if (yyn == YYPACT_NINF) + if (yypact_value_is_default (yyn)) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ @@ -2123,7 +2203,7 @@ yybackup: if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); - yychar = YYLEX; + yychar = yylex (&yylval, yyscanner); } if (yychar <= YYEOF) @@ -2134,7 +2214,7 @@ yybackup: else { yytoken = YYTRANSLATE (yychar); - YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); } /* If the proper action on seeing token YYTOKEN is to reduce or to @@ -2145,31 +2225,28 @@ yybackup: yyn = yytable[yyn]; if (yyn <= 0) { - if (yyn == 0 || yyn == YYTABLE_NINF) - goto yyerrlab; + if (yytable_value_is_error (yyn)) + goto yyerrlab; yyn = -yyn; goto yyreduce; } - if (yyn == YYFINAL) - YYACCEPT; - - /* Shift the lookahead token. */ - YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); - - /* Discard the token being shifted unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; - - *++yyvsp = yylval; - - /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; + /* Shift the lookahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token. */ + yychar = YYEMPTY; + yystate = yyn; + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END + goto yynewstate; @@ -2191,7 +2268,7 @@ yyreduce: yylen = yyr2[yyn]; /* If YYLEN is nonzero, implement the default value of the action: - `$$ = $1'. + '$$ = $1'. Otherwise, the following line sets YYVAL to garbage. This behavior is undocumented and Bison @@ -2205,3581 +2282,3927 @@ yyreduce: switch (yyn) { case 2: -#line 192 "cmDependsJavaParser.y" +#line 180 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2293 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 3: -#line 201 "cmDependsJavaParser.y" +#line 189 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2304 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 4: -#line 209 "cmDependsJavaParser.y" +#line 197 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2315 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 5: -#line 217 "cmDependsJavaParser.y" +#line 205 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2326 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 6: -#line 225 "cmDependsJavaParser.y" +#line 213 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2337 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 7: -#line 233 "cmDependsJavaParser.y" +#line 221 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2348 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 8: -#line 241 "cmDependsJavaParser.y" +#line 229 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2359 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 9: -#line 250 "cmDependsJavaParser.y" +#line 238 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2370 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 10: -#line 258 "cmDependsJavaParser.y" +#line 246 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2381 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 11: -#line 267 "cmDependsJavaParser.y" +#line 255 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2392 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 12: -#line 275 "cmDependsJavaParser.y" +#line 263 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2403 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 13: -#line 284 "cmDependsJavaParser.y" +#line 272 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(0); } +#line 2411 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 14: -#line 289 "cmDependsJavaParser.y" +#line 277 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(0); } +#line 2419 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 15: -#line 294 "cmDependsJavaParser.y" +#line 282 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(0); } +#line 2427 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 16: -#line 299 "cmDependsJavaParser.y" +#line 287 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(0); } +#line 2435 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 17: -#line 304 "cmDependsJavaParser.y" +#line 292 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(0); } +#line 2443 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 18: -#line 309 "cmDependsJavaParser.y" +#line 297 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(0); } +#line 2451 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 19: -#line 314 "cmDependsJavaParser.y" +#line 302 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(0); } +#line 2459 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 20: -#line 319 "cmDependsJavaParser.y" +#line 307 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(0); } +#line 2467 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 21: -#line 325 "cmDependsJavaParser.y" +#line 313 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2478 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 22: -#line 333 "cmDependsJavaParser.y" +#line 321 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2489 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 23: -#line 342 "cmDependsJavaParser.y" +#line 330 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); - jpStoreClass(yyvsp[0].str); + jpStoreClass((yyvsp[0].str)); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2501 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 24: -#line 352 "cmDependsJavaParser.y" +#line 340 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2512 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 25: -#line 361 "cmDependsJavaParser.y" +#line 349 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2523 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 26: -#line 370 "cmDependsJavaParser.y" +#line 358 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(2); jpCheckEmpty(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2534 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 27: -#line 378 "cmDependsJavaParser.y" +#line 366 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(2); - jpStoreClass(yyvsp[-1].str); + jpStoreClass((yyvsp[-1].str)); jpCheckEmpty(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2546 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 28: -#line 388 "cmDependsJavaParser.y" +#line 376 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); - yyval.str = yyvsp[0].str; + (yyval.str) = (yyvsp[0].str); } +#line 2555 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 29: -#line 394 "cmDependsJavaParser.y" +#line 382 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); - yyval.str = yyvsp[0].str; + (yyval.str) = (yyvsp[0].str); } +#line 2564 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 30: -#line 401 "cmDependsJavaParser.y" +#line 389 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); - yyval.str = yyvsp[0].str; + (yyval.str) = (yyvsp[0].str); } +#line 2573 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 31: -#line 408 "cmDependsJavaParser.y" +#line 396 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); - yyval.str = yyvsp[0].str; + (yyval.str) = (yyvsp[0].str); } +#line 2582 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 32: -#line 414 "cmDependsJavaParser.y" +#line 402 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(2); - yyval.str = yyvsp[0].str; + (yyval.str) = (yyvsp[0].str); } +#line 2591 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 33: -#line 421 "cmDependsJavaParser.y" +#line 409 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); - yyGetParser->AddClassFound(yyvsp[-2].str); - yyGetParser->UpdateCombine(yyvsp[-2].str, yyvsp[0].str); - yyGetParser->DeallocateParserType(&(yyvsp[-2].str)); - yyval.str = const_cast<char*>(yyGetParser->GetCurrentCombine()); + yyGetParser->AddClassFound((yyvsp[-2].str)); + yyGetParser->UpdateCombine((yyvsp[-2].str), (yyvsp[0].str)); + yyGetParser->DeallocateParserType(&((yyvsp[-2].str))); + (yyval.str) = const_cast<char*>(yyGetParser->GetCurrentCombine()); } +#line 2603 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 34: -#line 430 "cmDependsJavaParser.y" +#line 418 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); - jpStoreClass(yyvsp[-2].str); + jpStoreClass((yyvsp[-2].str)); jpCheckEmpty(3); yyGetParser->SetCurrentCombine(""); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2616 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 35: -#line 440 "cmDependsJavaParser.y" +#line 428 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); - jpStoreClass(yyvsp[-2].str); + jpStoreClass((yyvsp[-2].str)); yyGetParser->SetCurrentCombine(""); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2629 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 36: -#line 450 "cmDependsJavaParser.y" +#line 438 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2640 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 37: -#line 459 "cmDependsJavaParser.y" +#line 447 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2651 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 38: -#line 467 "cmDependsJavaParser.y" +#line 455 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2662 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 39: -#line 476 "cmDependsJavaParser.y" +#line 464 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2673 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 40: -#line 484 "cmDependsJavaParser.y" +#line 472 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(0); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2683 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 41: -#line 491 "cmDependsJavaParser.y" +#line 479 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2694 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 42: -#line 499 "cmDependsJavaParser.y" +#line 487 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(0); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2704 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 43: -#line 506 "cmDependsJavaParser.y" +#line 494 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(2); jpCheckEmpty(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2715 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 44: -#line 514 "cmDependsJavaParser.y" +#line 502 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(0); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2725 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 45: -#line 521 "cmDependsJavaParser.y" +#line 509 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(2); jpCheckEmpty(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2736 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 46: -#line 530 "cmDependsJavaParser.y" +#line 518 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); - yyGetParser->SetCurrentPackage(yyvsp[-1].str); - yyGetParser->DeallocateParserType(&(yyvsp[-1].str)); + yyGetParser->SetCurrentPackage((yyvsp[-1].str)); + yyGetParser->DeallocateParserType(&((yyvsp[-1].str))); yyGetParser->SetCurrentCombine(""); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2750 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 47: -#line 542 "cmDependsJavaParser.y" +#line 530 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2761 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 48: -#line 550 "cmDependsJavaParser.y" +#line 538 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2772 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 49: -#line 559 "cmDependsJavaParser.y" +#line 547 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); - yyGetParser->AddPackagesImport(yyvsp[-1].str); - yyGetParser->DeallocateParserType(&(yyvsp[-1].str)); + yyGetParser->AddPackagesImport((yyvsp[-1].str)); + yyGetParser->DeallocateParserType(&((yyvsp[-1].str))); yyGetParser->SetCurrentCombine(""); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2786 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 50: -#line 571 "cmDependsJavaParser.y" +#line 559 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(5); - std::string str = yyvsp[-3].str; + std::string str = (yyvsp[-3].str); str += ".*"; yyGetParser->AddPackagesImport(str.c_str()); - yyGetParser->DeallocateParserType(&(yyvsp[-3].str)); + yyGetParser->DeallocateParserType(&((yyvsp[-3].str))); yyGetParser->SetCurrentCombine(""); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2801 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 51: -#line 584 "cmDependsJavaParser.y" +#line 572 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2812 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 52: -#line 592 "cmDependsJavaParser.y" +#line 580 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2823 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 53: -#line 600 "cmDependsJavaParser.y" +#line 588 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2834 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 54: -#line 609 "cmDependsJavaParser.y" +#line 597 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2845 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 55: -#line 617 "cmDependsJavaParser.y" +#line 605 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(2); jpCheckEmpty(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2856 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 67: -#line 632 "cmDependsJavaParser.y" +#line 620 "cmDependsJavaParser.y" /* yacc.c:1646 */ { - yyGetParser->StartClass(yyvsp[0].str); + yyGetParser->StartClass((yyvsp[0].str)); jpElementStart(3); - yyGetParser->DeallocateParserType(&(yyvsp[0].str)); + yyGetParser->DeallocateParserType(&((yyvsp[0].str))); jpCheckEmpty(3); } +#line 2867 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 68: -#line 642 "cmDependsJavaParser.y" +#line 630 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(2); jpCheckEmpty(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); yyGetParser->EndClass(); } +#line 2879 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 69: -#line 651 "cmDependsJavaParser.y" +#line 639 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); yyGetParser->EndClass(); } +#line 2891 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 70: -#line 660 "cmDependsJavaParser.y" +#line 648 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); yyGetParser->EndClass(); } +#line 2903 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 71: -#line 669 "cmDependsJavaParser.y" +#line 657 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(4); jpCheckEmpty(4); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); yyGetParser->EndClass(); } +#line 2915 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 72: -#line 678 "cmDependsJavaParser.y" +#line 666 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(0); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2925 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 73: -#line 685 "cmDependsJavaParser.y" +#line 673 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2936 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 74: -#line 694 "cmDependsJavaParser.y" +#line 682 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(2); jpCheckEmpty(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2947 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 75: -#line 703 "cmDependsJavaParser.y" +#line 691 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(2); jpCheckEmpty(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2958 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 76: -#line 712 "cmDependsJavaParser.y" +#line 700 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2969 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 77: -#line 720 "cmDependsJavaParser.y" +#line 708 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2980 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 78: -#line 729 "cmDependsJavaParser.y" +#line 717 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 2991 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 79: -#line 737 "cmDependsJavaParser.y" +#line 725 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3001 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 80: -#line 744 "cmDependsJavaParser.y" +#line 732 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(2); jpCheckEmpty(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3012 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 81: -#line 753 "cmDependsJavaParser.y" +#line 741 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3023 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 82: -#line 761 "cmDependsJavaParser.y" +#line 749 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3034 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 83: -#line 769 "cmDependsJavaParser.y" +#line 757 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3045 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 84: -#line 777 "cmDependsJavaParser.y" +#line 765 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3056 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 85: -#line 786 "cmDependsJavaParser.y" +#line 774 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3067 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 86: -#line 794 "cmDependsJavaParser.y" +#line 782 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3078 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 87: -#line 803 "cmDependsJavaParser.y" +#line 791 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(4); } +#line 3086 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 88: -#line 809 "cmDependsJavaParser.y" +#line 797 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3097 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 89: -#line 817 "cmDependsJavaParser.y" +#line 805 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3108 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 90: -#line 826 "cmDependsJavaParser.y" +#line 814 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3119 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 91: -#line 834 "cmDependsJavaParser.y" +#line 822 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3130 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 92: -#line 843 "cmDependsJavaParser.y" +#line 831 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); - yyGetParser->DeallocateParserType(&(yyvsp[0].str)); + yyGetParser->DeallocateParserType(&((yyvsp[0].str))); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3142 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 93: -#line 852 "cmDependsJavaParser.y" +#line 840 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3153 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 94: -#line 861 "cmDependsJavaParser.y" +#line 849 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3164 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 95: -#line 869 "cmDependsJavaParser.y" +#line 857 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3175 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 96: -#line 878 "cmDependsJavaParser.y" +#line 866 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(2); jpCheckEmpty(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3186 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 97: -#line 886 "cmDependsJavaParser.y" +#line 874 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(2); jpCheckEmpty(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3197 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 98: -#line 894 "cmDependsJavaParser.y" +#line 882 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3208 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 99: -#line 903 "cmDependsJavaParser.y" +#line 891 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(4); jpCheckEmpty(4); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3220 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 100: -#line 912 "cmDependsJavaParser.y" +#line 900 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(4); jpCheckEmpty(4); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3232 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 101: -#line 921 "cmDependsJavaParser.y" +#line 909 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(0); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3243 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 102: -#line 929 "cmDependsJavaParser.y" +#line 917 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3255 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 103: -#line 939 "cmDependsJavaParser.y" +#line 927 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(4); - yyGetParser->DeallocateParserType(&(yyvsp[-3].str)); + yyGetParser->DeallocateParserType(&((yyvsp[-3].str))); jpCheckEmpty(4); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3268 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 104: -#line 949 "cmDependsJavaParser.y" +#line 937 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); } +#line 3277 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 105: -#line 955 "cmDependsJavaParser.y" +#line 943 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(0); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3288 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 107: -#line 966 "cmDependsJavaParser.y" +#line 954 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); } +#line 3297 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 108: -#line 972 "cmDependsJavaParser.y" +#line 960 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3309 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 109: -#line 982 "cmDependsJavaParser.y" +#line 970 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3321 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 110: -#line 992 "cmDependsJavaParser.y" +#line 980 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(2); jpCheckEmpty(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3333 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 111: -#line 1002 "cmDependsJavaParser.y" +#line 990 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); } +#line 3342 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 112: -#line 1008 "cmDependsJavaParser.y" +#line 996 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3354 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 113: -#line 1018 "cmDependsJavaParser.y" +#line 1006 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3366 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 114: -#line 1028 "cmDependsJavaParser.y" +#line 1016 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(2); jpCheckEmpty(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3378 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 115: -#line 1038 "cmDependsJavaParser.y" +#line 1026 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(4); jpCheckEmpty(4); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3390 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 116: -#line 1047 "cmDependsJavaParser.y" +#line 1035 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(5); jpCheckEmpty(5); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3402 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 117: -#line 1057 "cmDependsJavaParser.y" +#line 1045 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(4); - yyGetParser->DeallocateParserType(&(yyvsp[-3].str)); + yyGetParser->DeallocateParserType(&((yyvsp[-3].str))); jpCheckEmpty(4); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3415 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 118: -#line 1068 "cmDependsJavaParser.y" +#line 1056 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(4); jpCheckEmpty(4); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3427 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 119: -#line 1077 "cmDependsJavaParser.y" +#line 1065 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(0); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3438 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 120: -#line 1085 "cmDependsJavaParser.y" +#line 1073 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(2); jpCheckEmpty(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3450 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 121: -#line 1095 "cmDependsJavaParser.y" +#line 1083 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(5); jpCheckEmpty(5); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3462 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 122: -#line 1104 "cmDependsJavaParser.y" +#line 1092 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(5); jpCheckEmpty(5); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3474 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 123: -#line 1114 "cmDependsJavaParser.y" +#line 1102 "cmDependsJavaParser.y" /* yacc.c:1646 */ { - yyGetParser->StartClass(yyvsp[0].str); + yyGetParser->StartClass((yyvsp[0].str)); jpElementStart(3); - yyGetParser->DeallocateParserType(&(yyvsp[0].str)); + yyGetParser->DeallocateParserType(&((yyvsp[0].str))); jpCheckEmpty(3); } +#line 3485 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 124: -#line 1123 "cmDependsJavaParser.y" +#line 1111 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(2); jpCheckEmpty(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); yyGetParser->EndClass(); } +#line 3497 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 125: -#line 1132 "cmDependsJavaParser.y" +#line 1120 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(0); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3507 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 126: -#line 1139 "cmDependsJavaParser.y" +#line 1127 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3519 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 127: -#line 1149 "cmDependsJavaParser.y" +#line 1137 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(2); jpCheckEmpty(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3531 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 128: -#line 1158 "cmDependsJavaParser.y" +#line 1146 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3543 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 129: -#line 1168 "cmDependsJavaParser.y" +#line 1156 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3555 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 130: -#line 1177 "cmDependsJavaParser.y" +#line 1165 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(0); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3566 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 131: -#line 1185 "cmDependsJavaParser.y" +#line 1173 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3577 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 132: -#line 1194 "cmDependsJavaParser.y" +#line 1182 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3589 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 133: -#line 1203 "cmDependsJavaParser.y" +#line 1191 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3601 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 134: -#line 1212 "cmDependsJavaParser.y" +#line 1200 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3613 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 135: -#line 1221 "cmDependsJavaParser.y" +#line 1209 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3624 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 136: -#line 1229 "cmDependsJavaParser.y" +#line 1217 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3636 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 137: -#line 1238 "cmDependsJavaParser.y" +#line 1226 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3647 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 138: -#line 1247 "cmDependsJavaParser.y" +#line 1235 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3659 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 139: -#line 1257 "cmDependsJavaParser.y" +#line 1245 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(2); jpCheckEmpty(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3671 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 140: -#line 1267 "cmDependsJavaParser.y" +#line 1255 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3683 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 141: -#line 1276 "cmDependsJavaParser.y" +#line 1264 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(2); jpCheckEmpty(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3695 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 142: -#line 1286 "cmDependsJavaParser.y" +#line 1274 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3707 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 143: -#line 1295 "cmDependsJavaParser.y" +#line 1283 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3718 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 144: -#line 1303 "cmDependsJavaParser.y" +#line 1291 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3730 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 145: -#line 1312 "cmDependsJavaParser.y" +#line 1300 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(2); jpCheckEmpty(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3742 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 146: -#line 1322 "cmDependsJavaParser.y" +#line 1310 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3754 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 147: -#line 1331 "cmDependsJavaParser.y" +#line 1319 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3766 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 148: -#line 1341 "cmDependsJavaParser.y" +#line 1329 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(4); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3777 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 149: -#line 1349 "cmDependsJavaParser.y" +#line 1337 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3788 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 150: -#line 1357 "cmDependsJavaParser.y" +#line 1345 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3800 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 151: -#line 1367 "cmDependsJavaParser.y" +#line 1355 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3812 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 152: -#line 1376 "cmDependsJavaParser.y" +#line 1364 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3824 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 153: -#line 1386 "cmDependsJavaParser.y" +#line 1374 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3836 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 154: -#line 1395 "cmDependsJavaParser.y" +#line 1383 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3848 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 155: -#line 1404 "cmDependsJavaParser.y" +#line 1392 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3860 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 156: -#line 1414 "cmDependsJavaParser.y" +#line 1402 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3872 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 157: -#line 1424 "cmDependsJavaParser.y" +#line 1412 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3884 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 158: -#line 1433 "cmDependsJavaParser.y" +#line 1421 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3896 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 159: -#line 1443 "cmDependsJavaParser.y" +#line 1431 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3908 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 160: -#line 1452 "cmDependsJavaParser.y" +#line 1440 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3920 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 161: -#line 1461 "cmDependsJavaParser.y" +#line 1449 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3932 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 162: -#line 1470 "cmDependsJavaParser.y" +#line 1458 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3944 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 163: -#line 1479 "cmDependsJavaParser.y" +#line 1467 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3956 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 164: -#line 1488 "cmDependsJavaParser.y" +#line 1476 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3968 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 165: -#line 1498 "cmDependsJavaParser.y" +#line 1486 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3980 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 166: -#line 1507 "cmDependsJavaParser.y" +#line 1495 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 3992 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 167: -#line 1516 "cmDependsJavaParser.y" +#line 1504 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4004 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 168: -#line 1525 "cmDependsJavaParser.y" +#line 1513 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4016 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 169: -#line 1534 "cmDependsJavaParser.y" +#line 1522 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4028 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 170: -#line 1544 "cmDependsJavaParser.y" +#line 1532 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4040 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 171: -#line 1553 "cmDependsJavaParser.y" +#line 1541 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4052 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 172: -#line 1562 "cmDependsJavaParser.y" +#line 1550 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4064 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 173: -#line 1571 "cmDependsJavaParser.y" +#line 1559 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4076 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 174: -#line 1580 "cmDependsJavaParser.y" +#line 1568 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4088 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 175: -#line 1589 "cmDependsJavaParser.y" +#line 1577 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4100 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 176: -#line 1598 "cmDependsJavaParser.y" +#line 1586 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4112 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 177: -#line 1607 "cmDependsJavaParser.y" +#line 1595 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4124 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 178: -#line 1616 "cmDependsJavaParser.y" +#line 1604 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4136 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 179: -#line 1625 "cmDependsJavaParser.y" +#line 1613 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4148 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 180: -#line 1634 "cmDependsJavaParser.y" +#line 1622 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4160 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 181: -#line 1643 "cmDependsJavaParser.y" +#line 1631 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4172 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 182: -#line 1653 "cmDependsJavaParser.y" +#line 1641 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4184 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 183: -#line 1663 "cmDependsJavaParser.y" +#line 1651 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); - yyGetParser->DeallocateParserType(&(yyvsp[-2].str)); + yyGetParser->DeallocateParserType(&((yyvsp[-2].str))); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4197 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 184: -#line 1674 "cmDependsJavaParser.y" +#line 1662 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4209 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 185: -#line 1684 "cmDependsJavaParser.y" +#line 1672 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(2); jpCheckEmpty(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4221 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 186: -#line 1694 "cmDependsJavaParser.y" +#line 1682 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4233 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 187: -#line 1703 "cmDependsJavaParser.y" +#line 1691 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4245 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 188: -#line 1712 "cmDependsJavaParser.y" +#line 1700 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4257 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 189: -#line 1721 "cmDependsJavaParser.y" +#line 1709 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4269 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 190: -#line 1730 "cmDependsJavaParser.y" +#line 1718 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4281 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 191: -#line 1739 "cmDependsJavaParser.y" +#line 1727 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4293 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 192: -#line 1748 "cmDependsJavaParser.y" +#line 1736 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4305 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 193: -#line 1758 "cmDependsJavaParser.y" +#line 1746 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(5); jpCheckEmpty(5); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4317 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 194: -#line 1768 "cmDependsJavaParser.y" +#line 1756 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(7); jpCheckEmpty(7); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4329 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 195: -#line 1778 "cmDependsJavaParser.y" +#line 1766 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(7); jpCheckEmpty(7); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4341 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 196: -#line 1788 "cmDependsJavaParser.y" +#line 1776 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(5); } +#line 4350 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 197: -#line 1795 "cmDependsJavaParser.y" +#line 1783 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(4); } +#line 4359 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 198: -#line 1801 "cmDependsJavaParser.y" +#line 1789 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(0); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4370 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 199: -#line 1809 "cmDependsJavaParser.y" +#line 1797 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4382 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 200: -#line 1818 "cmDependsJavaParser.y" +#line 1806 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(0); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4393 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 201: -#line 1826 "cmDependsJavaParser.y" +#line 1814 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(2); jpCheckEmpty(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4405 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 202: -#line 1836 "cmDependsJavaParser.y" +#line 1824 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(2); jpCheckEmpty(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4417 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 203: -#line 1846 "cmDependsJavaParser.y" +#line 1834 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4429 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 204: -#line 1855 "cmDependsJavaParser.y" +#line 1843 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(2); jpCheckEmpty(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4441 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 205: -#line 1865 "cmDependsJavaParser.y" +#line 1853 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4453 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 206: -#line 1874 "cmDependsJavaParser.y" +#line 1862 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(2); jpCheckEmpty(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4465 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 207: -#line 1884 "cmDependsJavaParser.y" +#line 1872 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(5); } +#line 4474 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 208: -#line 1891 "cmDependsJavaParser.y" +#line 1879 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(5); } +#line 4483 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 209: -#line 1898 "cmDependsJavaParser.y" +#line 1886 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(7); } +#line 4492 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 210: -#line 1906 "cmDependsJavaParser.y" +#line 1894 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(9); } +#line 4501 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 211: -#line 1912 "cmDependsJavaParser.y" +#line 1900 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4512 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 212: -#line 1920 "cmDependsJavaParser.y" +#line 1908 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4524 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 213: -#line 1929 "cmDependsJavaParser.y" +#line 1917 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(0); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4535 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 214: -#line 1937 "cmDependsJavaParser.y" +#line 1925 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4547 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 215: -#line 1948 "cmDependsJavaParser.y" +#line 1936 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(9); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4558 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 216: -#line 1956 "cmDependsJavaParser.y" +#line 1944 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(0); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4569 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 217: -#line 1964 "cmDependsJavaParser.y" +#line 1952 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4581 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 218: -#line 1974 "cmDependsJavaParser.y" +#line 1962 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4593 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 219: -#line 1983 "cmDependsJavaParser.y" +#line 1971 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4605 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 220: -#line 1993 "cmDependsJavaParser.y" +#line 1981 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4617 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 221: -#line 2003 "cmDependsJavaParser.y" +#line 1991 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4629 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 222: -#line 2012 "cmDependsJavaParser.y" +#line 2000 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4641 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 223: -#line 2022 "cmDependsJavaParser.y" +#line 2010 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4653 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 224: -#line 2031 "cmDependsJavaParser.y" +#line 2019 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(5); jpCheckEmpty(5); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4665 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 225: -#line 2041 "cmDependsJavaParser.y" +#line 2029 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); - yyGetParser->DeallocateParserType(&(yyvsp[-1].str)); + yyGetParser->DeallocateParserType(&((yyvsp[-1].str))); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4678 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 226: -#line 2051 "cmDependsJavaParser.y" +#line 2039 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(0); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4689 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 227: -#line 2059 "cmDependsJavaParser.y" +#line 2047 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); } +#line 4698 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 228: -#line 2066 "cmDependsJavaParser.y" +#line 2054 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); - yyGetParser->DeallocateParserType(&(yyvsp[-1].str)); + yyGetParser->DeallocateParserType(&((yyvsp[-1].str))); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4711 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 229: -#line 2077 "cmDependsJavaParser.y" +#line 2065 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4723 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 230: -#line 2087 "cmDependsJavaParser.y" +#line 2075 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4735 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 231: -#line 2097 "cmDependsJavaParser.y" +#line 2085 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(5); jpCheckEmpty(5); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4747 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 232: -#line 2107 "cmDependsJavaParser.y" +#line 2095 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4759 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 233: -#line 2116 "cmDependsJavaParser.y" +#line 2104 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(4); jpCheckEmpty(4); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4771 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 234: -#line 2125 "cmDependsJavaParser.y" +#line 2113 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4782 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 235: -#line 2133 "cmDependsJavaParser.y" +#line 2121 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4794 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 236: -#line 2143 "cmDependsJavaParser.y" +#line 2131 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4806 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 237: -#line 2152 "cmDependsJavaParser.y" +#line 2140 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(2); jpCheckEmpty(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4818 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 238: -#line 2162 "cmDependsJavaParser.y" +#line 2150 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(5); } +#line 4827 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 239: -#line 2169 "cmDependsJavaParser.y" +#line 2157 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(2); jpCheckEmpty(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4839 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 240: -#line 2179 "cmDependsJavaParser.y" +#line 2167 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4851 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 241: -#line 2188 "cmDependsJavaParser.y" +#line 2176 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4863 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 242: -#line 2198 "cmDependsJavaParser.y" +#line 2186 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4875 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 243: -#line 2207 "cmDependsJavaParser.y" +#line 2195 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); } +#line 4884 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 244: -#line 2213 "cmDependsJavaParser.y" +#line 2201 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4896 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 245: -#line 2222 "cmDependsJavaParser.y" +#line 2210 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4908 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 246: -#line 2231 "cmDependsJavaParser.y" +#line 2219 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4920 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 247: -#line 2240 "cmDependsJavaParser.y" +#line 2228 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4932 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 248: -#line 2249 "cmDependsJavaParser.y" +#line 2237 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4944 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 249: -#line 2259 "cmDependsJavaParser.y" +#line 2247 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(6); jpCheckEmpty(6); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4956 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 250: -#line 2268 "cmDependsJavaParser.y" +#line 2256 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(0); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4967 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 251: -#line 2276 "cmDependsJavaParser.y" +#line 2264 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4979 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 252: -#line 2285 "cmDependsJavaParser.y" +#line 2273 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(0); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 4990 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 253: -#line 2293 "cmDependsJavaParser.y" +#line 2281 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5002 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 254: -#line 2303 "cmDependsJavaParser.y" +#line 2291 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5014 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 255: -#line 2312 "cmDependsJavaParser.y" +#line 2300 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5026 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 256: -#line 2322 "cmDependsJavaParser.y" +#line 2310 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(4); jpCheckEmpty(4); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5038 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 257: -#line 2331 "cmDependsJavaParser.y" +#line 2319 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(4); jpCheckEmpty(4); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5050 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 258: -#line 2340 "cmDependsJavaParser.y" +#line 2328 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(4); jpCheckEmpty(4); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5062 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 259: -#line 2349 "cmDependsJavaParser.y" +#line 2337 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(4); jpCheckEmpty(4); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5074 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 260: -#line 2358 "cmDependsJavaParser.y" +#line 2346 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(0); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5085 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 261: -#line 2366 "cmDependsJavaParser.y" +#line 2354 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5097 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 262: -#line 2376 "cmDependsJavaParser.y" +#line 2364 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5109 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 263: -#line 2385 "cmDependsJavaParser.y" +#line 2373 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(2); jpCheckEmpty(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5121 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 264: -#line 2395 "cmDependsJavaParser.y" +#line 2383 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5133 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 265: -#line 2405 "cmDependsJavaParser.y" +#line 2393 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(2); } +#line 5142 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 266: -#line 2411 "cmDependsJavaParser.y" +#line 2399 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); } +#line 5151 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 267: -#line 2418 "cmDependsJavaParser.y" +#line 2406 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); - yyGetParser->DeallocateParserType(&(yyvsp[0].str)); + yyGetParser->DeallocateParserType(&((yyvsp[0].str))); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5164 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 268: -#line 2428 "cmDependsJavaParser.y" +#line 2416 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); - yyGetParser->DeallocateParserType(&(yyvsp[0].str)); + yyGetParser->DeallocateParserType(&((yyvsp[0].str))); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5177 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 269: -#line 2438 "cmDependsJavaParser.y" +#line 2426 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); - yyGetParser->DeallocateParserType(&(yyvsp[0].str)); + yyGetParser->DeallocateParserType(&((yyvsp[0].str))); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5190 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 270: -#line 2448 "cmDependsJavaParser.y" +#line 2436 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); - yyGetParser->DeallocateParserType(&(yyvsp[0].str)); + yyGetParser->DeallocateParserType(&((yyvsp[0].str))); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5203 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 271: -#line 2459 "cmDependsJavaParser.y" +#line 2447 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(4); - yyGetParser->DeallocateParserType(&(yyvsp[-3].str)); + yyGetParser->DeallocateParserType(&((yyvsp[-3].str))); jpCheckEmpty(4); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5216 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 272: -#line 2469 "cmDependsJavaParser.y" +#line 2457 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(6); - yyGetParser->DeallocateParserType(&(yyvsp[-5].str)); - yyGetParser->DeallocateParserType(&(yyvsp[-3].str)); + yyGetParser->DeallocateParserType(&((yyvsp[-5].str))); + yyGetParser->DeallocateParserType(&((yyvsp[-3].str))); jpCheckEmpty(6); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5230 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 273: -#line 2480 "cmDependsJavaParser.y" +#line 2468 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(6); - yyGetParser->DeallocateParserType(&(yyvsp[-3].str)); + yyGetParser->DeallocateParserType(&((yyvsp[-3].str))); jpCheckEmpty(6); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5243 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 274: -#line 2490 "cmDependsJavaParser.y" +#line 2478 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(6); - yyGetParser->DeallocateParserType(&(yyvsp[-3].str)); + yyGetParser->DeallocateParserType(&((yyvsp[-3].str))); jpCheckEmpty(6); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5256 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 275: -#line 2501 "cmDependsJavaParser.y" +#line 2489 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(4); - yyGetParser->DeallocateParserType(&(yyvsp[-3].str)); + yyGetParser->DeallocateParserType(&((yyvsp[-3].str))); jpCheckEmpty(4); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5269 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 276: -#line 2511 "cmDependsJavaParser.y" +#line 2499 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(4); jpCheckEmpty(4); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5281 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 277: -#line 2521 "cmDependsJavaParser.y" +#line 2509 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5293 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 278: -#line 2530 "cmDependsJavaParser.y" +#line 2518 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); - yyGetParser->DeallocateParserType(&(yyvsp[0].str)); - yyval.str = 0; + yyGetParser->DeallocateParserType(&((yyvsp[0].str))); + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5305 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 279: -#line 2539 "cmDependsJavaParser.y" +#line 2527 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5317 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 280: -#line 2548 "cmDependsJavaParser.y" +#line 2536 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5329 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 281: -#line 2557 "cmDependsJavaParser.y" +#line 2545 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5341 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 282: -#line 2567 "cmDependsJavaParser.y" +#line 2555 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(2); jpCheckEmpty(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5353 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 283: -#line 2577 "cmDependsJavaParser.y" +#line 2565 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(2); jpCheckEmpty(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5365 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 284: -#line 2587 "cmDependsJavaParser.y" +#line 2575 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5377 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 285: -#line 2596 "cmDependsJavaParser.y" +#line 2584 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5389 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 286: -#line 2605 "cmDependsJavaParser.y" +#line 2593 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(2); jpCheckEmpty(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5401 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 287: -#line 2614 "cmDependsJavaParser.y" +#line 2602 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(2); jpCheckEmpty(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5413 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 288: -#line 2623 "cmDependsJavaParser.y" +#line 2611 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5425 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 289: -#line 2633 "cmDependsJavaParser.y" +#line 2621 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(2); jpCheckEmpty(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5437 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 290: -#line 2643 "cmDependsJavaParser.y" +#line 2631 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(2); jpCheckEmpty(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5449 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 291: -#line 2653 "cmDependsJavaParser.y" +#line 2641 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5461 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 292: -#line 2662 "cmDependsJavaParser.y" +#line 2650 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(2); jpCheckEmpty(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5473 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 293: -#line 2671 "cmDependsJavaParser.y" +#line 2659 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(2); jpCheckEmpty(2); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5485 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 294: -#line 2680 "cmDependsJavaParser.y" +#line 2668 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5497 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 295: -#line 2690 "cmDependsJavaParser.y" +#line 2678 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(5); jpCheckEmpty(5); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5509 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 296: -#line 2699 "cmDependsJavaParser.y" +#line 2687 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(4); jpCheckEmpty(4); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5521 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 297: -#line 2708 "cmDependsJavaParser.y" +#line 2696 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(5); } +#line 5530 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 298: -#line 2715 "cmDependsJavaParser.y" +#line 2703 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5542 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 299: -#line 2724 "cmDependsJavaParser.y" +#line 2712 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5554 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 300: -#line 2733 "cmDependsJavaParser.y" +#line 2721 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5566 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 301: -#line 2742 "cmDependsJavaParser.y" +#line 2730 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5578 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 302: -#line 2752 "cmDependsJavaParser.y" +#line 2740 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5590 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 303: -#line 2761 "cmDependsJavaParser.y" +#line 2749 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5602 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 304: -#line 2770 "cmDependsJavaParser.y" +#line 2758 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5614 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 305: -#line 2780 "cmDependsJavaParser.y" +#line 2768 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5626 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 306: -#line 2789 "cmDependsJavaParser.y" +#line 2777 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5638 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 307: -#line 2798 "cmDependsJavaParser.y" +#line 2786 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5650 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 308: -#line 2807 "cmDependsJavaParser.y" +#line 2795 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5662 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 309: -#line 2817 "cmDependsJavaParser.y" +#line 2805 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5674 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 310: -#line 2826 "cmDependsJavaParser.y" +#line 2814 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5686 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 311: -#line 2835 "cmDependsJavaParser.y" +#line 2823 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5698 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 312: -#line 2844 "cmDependsJavaParser.y" +#line 2832 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5710 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 313: -#line 2853 "cmDependsJavaParser.y" +#line 2841 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5722 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 314: -#line 2862 "cmDependsJavaParser.y" +#line 2850 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5734 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 315: -#line 2872 "cmDependsJavaParser.y" +#line 2860 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5746 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 316: -#line 2881 "cmDependsJavaParser.y" +#line 2869 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5758 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 317: -#line 2890 "cmDependsJavaParser.y" +#line 2878 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5770 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 318: -#line 2900 "cmDependsJavaParser.y" +#line 2888 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5782 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 319: -#line 2909 "cmDependsJavaParser.y" +#line 2897 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5794 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 320: -#line 2919 "cmDependsJavaParser.y" +#line 2907 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5806 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 321: -#line 2928 "cmDependsJavaParser.y" +#line 2916 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5818 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 322: -#line 2938 "cmDependsJavaParser.y" +#line 2926 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5830 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 323: -#line 2947 "cmDependsJavaParser.y" +#line 2935 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5842 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 324: -#line 2957 "cmDependsJavaParser.y" +#line 2945 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5854 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 325: -#line 2966 "cmDependsJavaParser.y" +#line 2954 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5866 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 326: -#line 2976 "cmDependsJavaParser.y" +#line 2964 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5878 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 327: -#line 2985 "cmDependsJavaParser.y" +#line 2973 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5890 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 328: -#line 2995 "cmDependsJavaParser.y" +#line 2983 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5902 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 329: -#line 3004 "cmDependsJavaParser.y" +#line 2992 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(5); jpCheckEmpty(5); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5914 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 330: -#line 3014 "cmDependsJavaParser.y" +#line 3002 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5926 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 331: -#line 3023 "cmDependsJavaParser.y" +#line 3011 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5938 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 332: -#line 3033 "cmDependsJavaParser.y" +#line 3021 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5950 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 333: -#line 3043 "cmDependsJavaParser.y" +#line 3031 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); - yyGetParser->DeallocateParserType(&(yyvsp[0].str)); + yyGetParser->DeallocateParserType(&((yyvsp[0].str))); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5963 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 334: -#line 3053 "cmDependsJavaParser.y" +#line 3041 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5975 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 335: -#line 3062 "cmDependsJavaParser.y" +#line 3050 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5987 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 336: -#line 3072 "cmDependsJavaParser.y" +#line 3060 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 5999 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 337: -#line 3081 "cmDependsJavaParser.y" +#line 3069 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 6011 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 338: -#line 3090 "cmDependsJavaParser.y" +#line 3078 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 6023 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 339: -#line 3099 "cmDependsJavaParser.y" +#line 3087 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 6035 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 340: -#line 3108 "cmDependsJavaParser.y" +#line 3096 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 6047 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 341: -#line 3117 "cmDependsJavaParser.y" +#line 3105 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 6059 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 342: -#line 3126 "cmDependsJavaParser.y" +#line 3114 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 6071 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 343: -#line 3135 "cmDependsJavaParser.y" +#line 3123 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 6083 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 344: -#line 3144 "cmDependsJavaParser.y" +#line 3132 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 6095 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 345: -#line 3153 "cmDependsJavaParser.y" +#line 3141 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 6107 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 346: -#line 3162 "cmDependsJavaParser.y" +#line 3150 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 6119 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 347: -#line 3171 "cmDependsJavaParser.y" +#line 3159 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 6131 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 348: -#line 3181 "cmDependsJavaParser.y" +#line 3169 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 6143 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 349: -#line 3191 "cmDependsJavaParser.y" +#line 3179 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 6155 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 350: -#line 3201 "cmDependsJavaParser.y" +#line 3189 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(1); jpCheckEmpty(1); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 6167 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; case 351: -#line 3210 "cmDependsJavaParser.y" +#line 3198 "cmDependsJavaParser.y" /* yacc.c:1646 */ { jpElementStart(3); - jpStoreClass(yyvsp[-2].str); + jpStoreClass((yyvsp[-2].str)); jpCheckEmpty(3); - yyval.str = 0; + (yyval.str) = 0; yyGetParser->SetCurrentCombine(""); } +#line 6180 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ break; +#line 6184 "cmDependsJavaParser.cxx" /* yacc.c:1646 */ + default: break; } - -/* Line 1010 of yacc.c. */ -#line 5780 "cmDependsJavaParser.cxx" - - yyvsp -= yylen; - yyssp -= yylen; - - + /* User semantic actions sometimes alter yychar, and that requires + that yytoken be updated with the new translation. We take the + approach of translating immediately before every use of yytoken. + One alternative is translating here after every semantic action, + but that translation would be missed if the semantic action invokes + YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or + if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an + incorrect destructor might then be invoked immediately. In the + case of YYERROR or YYBACKUP, subsequent parser actions might lead + to an incorrect destructor call or verbose syntax error message + before the lookahead is translated. */ + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; - - /* Now `shift' the result of the reduction. Determine what state + /* Now 'shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ @@ -5794,74 +6217,52 @@ yyreduce: goto yynewstate; -/*------------------------------------. -| yyerrlab -- here on detecting error | -`------------------------------------*/ +/*--------------------------------------. +| yyerrlab -- here on detecting error. | +`--------------------------------------*/ yyerrlab: + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); + /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs; -#if YYERROR_VERBOSE - yyn = yypact[yystate]; - - if (YYPACT_NINF < yyn && yyn < YYLAST) - { - YYSIZE_T yysize = 0; - int yytype = YYTRANSLATE (yychar); - const char* yyprefix; - char *yymsg; - int yyx; - - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yycount = 0; - - yyprefix = ", expecting "; - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - { - yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]); - yycount += 1; - if (yycount == 5) - { - yysize = 0; - break; - } - } - yysize += (sizeof ("syntax error, unexpected ") - + yystrlen (yytname[yytype])); - yymsg = (char *) YYSTACK_ALLOC (yysize); - if (yymsg != 0) +#if ! YYERROR_VERBOSE + yyerror (yyscanner, YY_("syntax error")); +#else +# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ + yyssp, yytoken) { - char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); - yyp = yystpcpy (yyp, yytname[yytype]); - - if (yycount < 5) - { - yyprefix = ", expecting "; - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + char const *yymsgp = YY_("syntax error"); + int yysyntax_error_status; + yysyntax_error_status = YYSYNTAX_ERROR; + if (yysyntax_error_status == 0) + yymsgp = yymsg; + else if (yysyntax_error_status == 1) { - yyp = yystpcpy (yyp, yyprefix); - yyp = yystpcpy (yyp, yytname[yyx]); - yyprefix = " or "; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); + if (!yymsg) + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + yysyntax_error_status = 2; + } + else + { + yysyntax_error_status = YYSYNTAX_ERROR; + yymsgp = yymsg; + } } - } - yyerror (yymsg); - YYSTACK_FREE (yymsg); + yyerror (yyscanner, yymsgp); + if (yysyntax_error_status == 2) + goto yyexhaustedlab; } - else - yyerror ("syntax error; also virtual memory exhausted"); - } - else -#endif /* YYERROR_VERBOSE */ - yyerror ("syntax error"); +# undef YYSYNTAX_ERROR +#endif } @@ -5869,31 +6270,23 @@ yyerrlab: if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an - error, discard it. */ + error, discard it. */ if (yychar <= YYEOF) { - /* If at end of input, pop the error token, - then the rest of the stack, then return failure. */ - if (yychar == YYEOF) - for (;;) - { - YYPOPSTACK; - if (yyssp == yyss) - YYABORT; - YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); - yydestruct (yystos[*yyssp], yyvsp); - } + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; } else - { - YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); - yydestruct (yytoken, &yylval); - yychar = YYEMPTY; - - } + { + yydestruct ("Error: discarding", + yytoken, &yylval, yyscanner); + yychar = YYEMPTY; + } } +#if 0 /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; @@ -5904,15 +6297,17 @@ yyerrlab: `---------------------------------------------------*/ yyerrorlab: -#if defined(__GNUC__) || defined(__HP_aCC) - /* Pacify GCC when the user code never invokes YYERROR and the label - yyerrorlab therefore never appears in user code. */ - if (0) + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) goto yyerrorlab; -#endif - yyvsp -= yylen; - yyssp -= yylen; + /* Do not reclaim the symbols of the rule whose action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); yystate = *yyssp; goto yyerrlab1; @@ -5921,40 +6316,42 @@ yyerrorlab: | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ yyerrlab1: - yyerrstatus = 3; /* Each real token shifted decrements this. */ +#endif + yyerrstatus = 3; /* Each real token shifted decrements this. */ for (;;) { yyn = yypact[yystate]; - if (yyn != YYPACT_NINF) - { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } - } + if (!yypact_value_is_default (yyn)) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } /* Pop the current state because it cannot handle the error token. */ if (yyssp == yyss) - YYABORT; + YYABORT; - YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); - yydestruct (yystos[yystate], yyvsp); - YYPOPSTACK; + + yydestruct ("Error: popping", + yystos[yystate], yyvsp, yyscanner); + YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); } - if (yyn == YYFINAL) - YYACCEPT; - - YYDPRINTF ((stderr, "Shifting error token, ")); - + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); yystate = yyn; goto yynewstate; @@ -5974,33 +6371,51 @@ yyabortlab: yyresult = 1; goto yyreturn; -#ifndef yyoverflow -/*----------------------------------------------. -| yyoverflowlab -- parser overflow comes here. | -`----------------------------------------------*/ -yyoverflowlab: - yyerror ("parser stack overflow"); +#if !defined yyoverflow || YYERROR_VERBOSE +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (yyscanner, YY_("memory exhausted")); yyresult = 2; /* Fall through. */ #endif yyreturn: + if (yychar != YYEMPTY) + { + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = YYTRANSLATE (yychar); + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, yyscanner); + } + /* Do not reclaim the symbols of the rule whose action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, yyscanner); + YYPOPSTACK (1); + } #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); #endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif return yyresult; } - - -#line 3219 "cmDependsJavaParser.y" +#line 3207 "cmDependsJavaParser.y" /* yacc.c:1906 */ /* End of grammar */ /*--------------------------------------------------------------------------*/ -void cmDependsJavaError(yyscan_t yyscanner, const char* message) +void cmDependsJava_yyerror(yyscan_t yyscanner, const char* message) { yyGetParser->Error(message); } - - diff --git a/Source/cmDependsJavaParser.y b/Source/cmDependsJavaParser.y index 91ee7c8..1137f39 100644 --- a/Source/cmDependsJavaParser.y +++ b/Source/cmDependsJavaParser.y @@ -10,18 +10,16 @@ Run bison like this: bison --yacc --name-prefix=cmDependsJava_yy --defines=cmDependsJavaParserTokens.h -ocmDependsJavaParser.cxx cmDependsJavaParser.y Modify cmDependsJavaParser.cxx: - - remove TABs - - remove use of the 'register' storage class specifier - - add __HP_aCC to the #if test for yyerrorlab warning suppression + - "#if 0" out yyerrorlab block in range ["goto yyerrlab1", "yyerrlab1:"] */ -/* Configure the parser to use a lexer object. */ -#define YYPARSE_PARAM yyscanner -#define YYLEX_PARAM yyscanner -#define YYERROR_VERBOSE 1 -#define cmDependsJava_yyerror(x) \ - cmDependsJavaError(yyscanner, x) +#include "cmConfigure.h" // IWYU pragma: keep + +#include <stdlib.h> +#include <string.h> +#include <string> + #define yyGetParser (cmDependsJava_yyget_extra(yyscanner)) /*-------------------------------------------------------------------------*/ @@ -32,10 +30,9 @@ Modify cmDependsJavaParser.cxx: /* Forward declare the lexer entry point. */ YY_DECL; -/* Internal utility functions. */ -static void cmDependsJavaError(yyscan_t yyscanner, const char* message); +/* Helper function to forward error callback from parser. */ +static void cmDependsJava_yyerror(yyscan_t yyscanner, const char* message); -#define YYDEBUG 1 #define YYMAXDEPTH 1000000 @@ -50,7 +47,13 @@ static void cmDependsJavaError(yyscan_t yyscanner, const char* message); %} /* Generate a reentrant parser object. */ -%pure_parser +%define api.pure + +/* Configure the parser to use a lexer object. */ +%lex-param {yyscan_t yyscanner} +%parse-param {yyscan_t yyscanner} + +%define parse.error verbose /* %union { @@ -3205,7 +3208,7 @@ Name jp_DOT jp_NEW /* End of grammar */ /*--------------------------------------------------------------------------*/ -void cmDependsJavaError(yyscan_t yyscanner, const char* message) +void cmDependsJava_yyerror(yyscan_t yyscanner, const char* message) { yyGetParser->Error(message); } diff --git a/Source/cmDependsJavaParserHelper.cxx b/Source/cmDependsJavaParserHelper.cxx index f5998ef..7bc91bf 100644 --- a/Source/cmDependsJavaParserHelper.cxx +++ b/Source/cmDependsJavaParserHelper.cxx @@ -2,12 +2,12 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmDependsJavaParserHelper.h" -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmDependsJavaLexer.h" #include "cmSystemTools.h" -#include <cmsys/FStream.hxx> +#include "cmsys/FStream.hxx" #include <iostream> #include <stdio.h> #include <stdlib.h> diff --git a/Source/cmDependsJavaParserHelper.h b/Source/cmDependsJavaParserHelper.h index 71b939c..0b445d9 100644 --- a/Source/cmDependsJavaParserHelper.h +++ b/Source/cmDependsJavaParserHelper.h @@ -3,31 +3,23 @@ #ifndef cmDependsJavaParserHelper_h #define cmDependsJavaParserHelper_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> -class cmDependsJavaParserHelper; - -#define YYSTYPE cmDependsJavaParserHelper::ParserType -#define YYSTYPE_IS_DECLARED -#define YY_EXTRA_TYPE cmDependsJavaParserHelper* -#define YY_DECL int cmDependsJava_yylex(YYSTYPE* yylvalp, yyscan_t yyscanner) - /** \class cmDependsJavaParserHelper * \brief Helper class for parsing java source files * * Finds dependencies for java file and list of outputs */ - class cmDependsJavaParserHelper { public: - typedef struct + struct ParserType { char* str; - } ParserType; + }; cmDependsJavaParserHelper(); ~cmDependsJavaParserHelper(); @@ -96,4 +88,9 @@ private: void CleanupParser(); }; +#define YYSTYPE cmDependsJavaParserHelper::ParserType +#define YYSTYPE_IS_DECLARED +#define YY_EXTRA_TYPE cmDependsJavaParserHelper* +#define YY_DECL int cmDependsJava_yylex(YYSTYPE* yylvalp, yyscan_t yyscanner) + #endif diff --git a/Source/cmDependsJavaParserTokens.h b/Source/cmDependsJavaParserTokens.h index c7a414f..7f18f1d 100644 --- a/Source/cmDependsJavaParserTokens.h +++ b/Source/cmDependsJavaParserTokens.h @@ -1,12 +1,13 @@ -/* A Bison parser, made by GNU Bison 1.875d. */ +/* A Bison parser, made by GNU Bison 3.0.4. */ -/* Skeleton parser for Yacc-like parsing with Bison, Copyright (C) 1984, - 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +/* Bison interface for Yacc-like parsers in C - This program is free software; you can redistribute it and/or modify + Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,126 +15,142 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ + along with this program. If not, see <http://www.gnu.org/licenses/>. */ -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. -/* Tokens. */ + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +#ifndef YY_CMDEPENDSJAVA_YY_CMDEPENDSJAVAPARSERTOKENS_H_INCLUDED +# define YY_CMDEPENDSJAVA_YY_CMDEPENDSJAVAPARSERTOKENS_H_INCLUDED +/* Debug traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif +#if YYDEBUG +extern int cmDependsJava_yydebug; +#endif + +/* Token type. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - jp_ABSTRACT = 258, - jp_ASSERT = 259, - jp_BOOLEAN_TYPE = 260, - jp_BREAK = 261, - jp_BYTE_TYPE = 262, - jp_CASE = 263, - jp_CATCH = 264, - jp_CHAR_TYPE = 265, - jp_CLASS = 266, - jp_CONTINUE = 267, - jp_DEFAULT = 268, - jp_DO = 269, - jp_DOUBLE_TYPE = 270, - jp_ELSE = 271, - jp_EXTENDS = 272, - jp_FINAL = 273, - jp_FINALLY = 274, - jp_FLOAT_TYPE = 275, - jp_FOR = 276, - jp_IF = 277, - jp_IMPLEMENTS = 278, - jp_IMPORT = 279, - jp_INSTANCEOF = 280, - jp_INT_TYPE = 281, - jp_INTERFACE = 282, - jp_LONG_TYPE = 283, - jp_NATIVE = 284, - jp_NEW = 285, - jp_PACKAGE = 286, - jp_PRIVATE = 287, - jp_PROTECTED = 288, - jp_PUBLIC = 289, - jp_RETURN = 290, - jp_SHORT_TYPE = 291, - jp_STATIC = 292, - jp_STRICTFP = 293, - jp_SUPER = 294, - jp_SWITCH = 295, - jp_SYNCHRONIZED = 296, - jp_THIS = 297, - jp_THROW = 298, - jp_THROWS = 299, - jp_TRANSIENT = 300, - jp_TRY = 301, - jp_VOID = 302, - jp_VOLATILE = 303, - jp_WHILE = 304, - jp_BOOLEANLITERAL = 305, - jp_CHARACTERLITERAL = 306, - jp_DECIMALINTEGERLITERAL = 307, - jp_FLOATINGPOINTLITERAL = 308, - jp_HEXINTEGERLITERAL = 309, - jp_NULLLITERAL = 310, - jp_STRINGLITERAL = 311, - jp_NAME = 312, - jp_AND = 313, - jp_ANDAND = 314, - jp_ANDEQUALS = 315, - jp_BRACKETEND = 316, - jp_BRACKETSTART = 317, - jp_CARROT = 318, - jp_CARROTEQUALS = 319, - jp_COLON = 320, - jp_COMMA = 321, - jp_CURLYEND = 322, - jp_CURLYSTART = 323, - jp_DIVIDE = 324, - jp_DIVIDEEQUALS = 325, - jp_DOLLAR = 326, - jp_DOT = 327, - jp_EQUALS = 328, - jp_EQUALSEQUALS = 329, - jp_EXCLAMATION = 330, - jp_EXCLAMATIONEQUALS = 331, - jp_GREATER = 332, - jp_GTEQUALS = 333, - jp_GTGT = 334, - jp_GTGTEQUALS = 335, - jp_GTGTGT = 336, - jp_GTGTGTEQUALS = 337, - jp_LESLESEQUALS = 338, - jp_LESSTHAN = 339, - jp_LTEQUALS = 340, - jp_LTLT = 341, - jp_MINUS = 342, - jp_MINUSEQUALS = 343, - jp_MINUSMINUS = 344, - jp_PAREEND = 345, - jp_PARESTART = 346, - jp_PERCENT = 347, - jp_PERCENTEQUALS = 348, - jp_PIPE = 349, - jp_PIPEEQUALS = 350, - jp_PIPEPIPE = 351, - jp_PLUS = 352, - jp_PLUSEQUALS = 353, - jp_PLUSPLUS = 354, - jp_QUESTION = 355, - jp_SEMICOL = 356, - jp_TILDE = 357, - jp_TIMES = 358, - jp_TIMESEQUALS = 359, - jp_ERROR = 360 - }; + enum yytokentype + { + jp_ABSTRACT = 258, + jp_ASSERT = 259, + jp_BOOLEAN_TYPE = 260, + jp_BREAK = 261, + jp_BYTE_TYPE = 262, + jp_CASE = 263, + jp_CATCH = 264, + jp_CHAR_TYPE = 265, + jp_CLASS = 266, + jp_CONTINUE = 267, + jp_DEFAULT = 268, + jp_DO = 269, + jp_DOUBLE_TYPE = 270, + jp_ELSE = 271, + jp_EXTENDS = 272, + jp_FINAL = 273, + jp_FINALLY = 274, + jp_FLOAT_TYPE = 275, + jp_FOR = 276, + jp_IF = 277, + jp_IMPLEMENTS = 278, + jp_IMPORT = 279, + jp_INSTANCEOF = 280, + jp_INT_TYPE = 281, + jp_INTERFACE = 282, + jp_LONG_TYPE = 283, + jp_NATIVE = 284, + jp_NEW = 285, + jp_PACKAGE = 286, + jp_PRIVATE = 287, + jp_PROTECTED = 288, + jp_PUBLIC = 289, + jp_RETURN = 290, + jp_SHORT_TYPE = 291, + jp_STATIC = 292, + jp_STRICTFP = 293, + jp_SUPER = 294, + jp_SWITCH = 295, + jp_SYNCHRONIZED = 296, + jp_THIS = 297, + jp_THROW = 298, + jp_THROWS = 299, + jp_TRANSIENT = 300, + jp_TRY = 301, + jp_VOID = 302, + jp_VOLATILE = 303, + jp_WHILE = 304, + jp_BOOLEANLITERAL = 305, + jp_CHARACTERLITERAL = 306, + jp_DECIMALINTEGERLITERAL = 307, + jp_FLOATINGPOINTLITERAL = 308, + jp_HEXINTEGERLITERAL = 309, + jp_NULLLITERAL = 310, + jp_STRINGLITERAL = 311, + jp_NAME = 312, + jp_AND = 313, + jp_ANDAND = 314, + jp_ANDEQUALS = 315, + jp_BRACKETEND = 316, + jp_BRACKETSTART = 317, + jp_CARROT = 318, + jp_CARROTEQUALS = 319, + jp_COLON = 320, + jp_COMMA = 321, + jp_CURLYEND = 322, + jp_CURLYSTART = 323, + jp_DIVIDE = 324, + jp_DIVIDEEQUALS = 325, + jp_DOLLAR = 326, + jp_DOT = 327, + jp_EQUALS = 328, + jp_EQUALSEQUALS = 329, + jp_EXCLAMATION = 330, + jp_EXCLAMATIONEQUALS = 331, + jp_GREATER = 332, + jp_GTEQUALS = 333, + jp_GTGT = 334, + jp_GTGTEQUALS = 335, + jp_GTGTGT = 336, + jp_GTGTGTEQUALS = 337, + jp_LESLESEQUALS = 338, + jp_LESSTHAN = 339, + jp_LTEQUALS = 340, + jp_LTLT = 341, + jp_MINUS = 342, + jp_MINUSEQUALS = 343, + jp_MINUSMINUS = 344, + jp_PAREEND = 345, + jp_PARESTART = 346, + jp_PERCENT = 347, + jp_PERCENTEQUALS = 348, + jp_PIPE = 349, + jp_PIPEEQUALS = 350, + jp_PIPEPIPE = 351, + jp_PLUS = 352, + jp_PLUSEQUALS = 353, + jp_PLUSPLUS = 354, + jp_QUESTION = 355, + jp_SEMICOL = 356, + jp_TILDE = 357, + jp_TIMES = 358, + jp_TIMESEQUALS = 359, + jp_ERROR = 360 + }; #endif +/* Tokens. */ #define jp_ABSTRACT 258 #define jp_ASSERT 259 #define jp_BOOLEAN_TYPE 260 @@ -238,17 +255,10 @@ #define jp_TIMESEQUALS 359 #define jp_ERROR 360 +/* Value type. */ -#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) -typedef int YYSTYPE; -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 -#endif - - - - +int cmDependsJava_yyparse (yyscan_t yyscanner); +#endif /* !YY_CMDEPENDSJAVA_YY_CMDEPENDSJAVAPARSERTOKENS_H_INCLUDED */ diff --git a/Source/cmDisallowedCommand.cxx b/Source/cmDisallowedCommand.cxx new file mode 100644 index 0000000..ce1965d --- /dev/null +++ b/Source/cmDisallowedCommand.cxx @@ -0,0 +1,31 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#include "cmDisallowedCommand.h" + +#include "cmMakefile.h" +#include "cmake.h" + +class cmExecutionStatus; + +bool cmDisallowedCommand::InitialPass(std::vector<std::string> const& args, + cmExecutionStatus& status) +{ + switch (this->Makefile->GetPolicyStatus(this->Policy)) { + case cmPolicies::WARN: + this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, + cmPolicies::GetPolicyWarning(this->Policy)); + break; + case cmPolicies::OLD: + break; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + this->Makefile->IssueMessage(cmake::FATAL_ERROR, this->Message); + return true; + } + + this->Command->SetMakefile(this->GetMakefile()); + bool const ret = this->Command->InitialPass(args, status); + this->SetError(this->Command->GetError()); + return ret; +} diff --git a/Source/cmDisallowedCommand.h b/Source/cmDisallowedCommand.h new file mode 100644 index 0000000..7c141dd --- /dev/null +++ b/Source/cmDisallowedCommand.h @@ -0,0 +1,58 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#ifndef cmDisallowedCommand_h +#define cmDisallowedCommand_h + +#include "cmConfigure.h" + +#include <string> +#include <vector> + +#include "cmCommand.h" +#include "cmPolicies.h" + +class cmExecutionStatus; + +class cmDisallowedCommand : public cmCommand +{ +public: + cmDisallowedCommand(cmCommand* command, cmPolicies::PolicyID policy, + const char* message) + : Command(command) + , Policy(policy) + , Message(message) + { + } + + ~cmDisallowedCommand() CM_OVERRIDE { delete this->Command; } + + cmCommand* Clone() CM_OVERRIDE + { + return new cmDisallowedCommand(this->Command->Clone(), this->Policy, + this->Message); + } + + bool InitialPass(std::vector<std::string> const& args, + cmExecutionStatus& status) CM_OVERRIDE; + + void FinalPass() CM_OVERRIDE { this->Command->FinalPass(); } + + bool HasFinalPass() const CM_OVERRIDE + { + return this->Command->HasFinalPass(); + } + + bool IsScriptable() const CM_OVERRIDE + { + return this->Command->IsScriptable(); + } + + std::string GetName() const CM_OVERRIDE { return this->Command->GetName(); } + +private: + cmCommand* Command; + cmPolicies::PolicyID Policy; + const char* Message; +}; + +#endif diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx index cb24adf..5f25113 100644 --- a/Source/cmDocumentation.cxx +++ b/Source/cmDocumentation.cxx @@ -9,9 +9,9 @@ #include "cmSystemTools.h" #include "cmVersion.h" +#include "cmsys/FStream.hxx" +#include "cmsys/Glob.hxx" #include <algorithm> -#include <cmsys/FStream.hxx> -#include <cmsys/Glob.hxx> #include <ctype.h> #include <string.h> #include <utility> diff --git a/Source/cmDocumentation.h b/Source/cmDocumentation.h index 66afd2c..2866fef 100644 --- a/Source/cmDocumentation.h +++ b/Source/cmDocumentation.h @@ -3,7 +3,7 @@ #ifndef _cmDocumentation_h #define _cmDocumentation_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmDocumentationFormatter.h" diff --git a/Source/cmDocumentationEntry.h b/Source/cmDocumentationEntry.h index 1ccb82d..ea43b88 100644 --- a/Source/cmDocumentationEntry.h +++ b/Source/cmDocumentationEntry.h @@ -3,7 +3,7 @@ #ifndef cmDocumentationEntry_h #define cmDocumentationEntry_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <string> diff --git a/Source/cmDocumentationFormatter.h b/Source/cmDocumentationFormatter.h index ffa80f1..1f04250 100644 --- a/Source/cmDocumentationFormatter.h +++ b/Source/cmDocumentationFormatter.h @@ -3,7 +3,7 @@ #ifndef _cmDocumentationFormatter_h #define _cmDocumentationFormatter_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <iosfwd> diff --git a/Source/cmDocumentationSection.h b/Source/cmDocumentationSection.h index c1eb5c8..d9e8187 100644 --- a/Source/cmDocumentationSection.h +++ b/Source/cmDocumentationSection.h @@ -3,7 +3,7 @@ #ifndef _cmDocumentationSection_h #define _cmDocumentationSection_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include "cmDocumentationEntry.h" diff --git a/Source/cmDynamicLoader.cxx b/Source/cmDynamicLoader.cxx index a30b642..76a4a29 100644 --- a/Source/cmDynamicLoader.cxx +++ b/Source/cmDynamicLoader.cxx @@ -2,9 +2,8 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmDynamicLoader.h" -#include <cmConfigure.h> +#include "cmConfigure.h" -#include <cmsys/DynamicLoader.hxx> #include <map> #include <string> #include <utility> diff --git a/Source/cmDynamicLoader.h b/Source/cmDynamicLoader.h index d14f81e..dd69b40 100644 --- a/Source/cmDynamicLoader.h +++ b/Source/cmDynamicLoader.h @@ -8,9 +8,9 @@ #ifndef cmDynamicLoader_h #define cmDynamicLoader_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep -#include <cmsys/DynamicLoader.hxx> +#include "cmsys/DynamicLoader.hxx" // IWYU pragma: export class cmDynamicLoader { diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx index 0655da9..2a8137f 100644 --- a/Source/cmELF.cxx +++ b/Source/cmELF.cxx @@ -2,9 +2,9 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmELF.h" -#include <cm_auto_ptr.hxx> -#include <cm_kwiml.h> -#include <cmsys/FStream.hxx> +#include "cm_auto_ptr.hxx" +#include "cm_kwiml.h" +#include "cmsys/FStream.hxx" #include <map> #include <sstream> #include <stddef.h> diff --git a/Source/cmELF.h b/Source/cmELF.h index 763a240..a6e407f 100644 --- a/Source/cmELF.h +++ b/Source/cmELF.h @@ -3,7 +3,7 @@ #ifndef cmELF_h #define cmELF_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <iosfwd> #include <string> diff --git a/Source/cmEnableLanguageCommand.h b/Source/cmEnableLanguageCommand.h index bafb79e..0748283 100644 --- a/Source/cmEnableLanguageCommand.h +++ b/Source/cmEnableLanguageCommand.h @@ -3,7 +3,8 @@ #ifndef cmEnableLanguageCommand_h #define cmEnableLanguageCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmEnableTestingCommand.h b/Source/cmEnableTestingCommand.h index 67cd237..b4ac068 100644 --- a/Source/cmEnableTestingCommand.h +++ b/Source/cmEnableTestingCommand.h @@ -3,7 +3,8 @@ #ifndef cmEnableTestingCommand_h #define cmEnableTestingCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmExecProgramCommand.cxx b/Source/cmExecProgramCommand.cxx index 6a7292d..fcc3c45 100644 --- a/Source/cmExecProgramCommand.cxx +++ b/Source/cmExecProgramCommand.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmExecProgramCommand.h" -#include <cmsys/Process.h> +#include "cmsys/Process.h" #include <stdio.h> #include "cmMakefile.h" diff --git a/Source/cmExecProgramCommand.h b/Source/cmExecProgramCommand.h index 58e948e..53d35cf 100644 --- a/Source/cmExecProgramCommand.h +++ b/Source/cmExecProgramCommand.h @@ -3,7 +3,8 @@ #ifndef cmExecProgramCommand_h #define cmExecProgramCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmExecuteProcessCommand.cxx b/Source/cmExecuteProcessCommand.cxx index 92cdf64..8c10dbe 100644 --- a/Source/cmExecuteProcessCommand.cxx +++ b/Source/cmExecuteProcessCommand.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmExecuteProcessCommand.h" -#include <cmsys/Process.h> +#include "cmsys/Process.h" #include <ctype.h> /* isspace */ #include <sstream> #include <stdio.h> diff --git a/Source/cmExecuteProcessCommand.h b/Source/cmExecuteProcessCommand.h index 9ce4338..65e16d4 100644 --- a/Source/cmExecuteProcessCommand.h +++ b/Source/cmExecuteProcessCommand.h @@ -3,7 +3,8 @@ #ifndef cmExecuteProcessCommand_h #define cmExecuteProcessCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmExpandedCommandArgument.h b/Source/cmExpandedCommandArgument.h index 9770fe6..fe86528 100644 --- a/Source/cmExpandedCommandArgument.h +++ b/Source/cmExpandedCommandArgument.h @@ -3,7 +3,7 @@ #ifndef cmExpandedCommandArgument_h #define cmExpandedCommandArgument_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <string> diff --git a/Source/cmExportBuildAndroidMKGenerator.h b/Source/cmExportBuildAndroidMKGenerator.h index 2a5a42e..d028ef4 100644 --- a/Source/cmExportBuildAndroidMKGenerator.h +++ b/Source/cmExportBuildAndroidMKGenerator.h @@ -3,7 +3,7 @@ #ifndef cmExportBuildAndroidMKGenerator_h #define cmExportBuildAndroidMKGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <iosfwd> #include <string> diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 0c25268..a1c424a 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmExportBuildFileGenerator.h" +#include "cmAlgorithms.h" #include "cmExportSet.h" #include "cmGeneratorExpression.h" #include "cmGeneratorTarget.h" @@ -21,6 +22,8 @@ #include <sstream> #include <utility> +class cmSourceFile; + cmExportBuildFileGenerator::cmExportBuildFileGenerator() { this->LG = CM_NULLPTR; @@ -171,29 +174,51 @@ void cmExportBuildFileGenerator::SetImportLocationProperty( // Get the makefile in which to lookup target information. cmMakefile* mf = target->Makefile; - // Add the main target file. - { - std::string prop = "IMPORTED_LOCATION"; + if (target->GetType() == cmStateEnums::OBJECT_LIBRARY) { + std::string prop = "IMPORTED_OBJECTS"; prop += suffix; - std::string value; - if (target->IsAppBundleOnApple()) { - value = target->GetFullPath(config, false); - } else { - value = target->GetFullPath(config, false, true); + + // Compute all the object files inside this target and setup + // IMPORTED_OBJECTS as a list of object files + std::vector<cmSourceFile const*> objectSources; + target->GetObjectSources(objectSources, config); + std::string const obj_dir = target->GetObjectDirectory(config); + std::vector<std::string> objects; + for (std::vector<cmSourceFile const*>::const_iterator si = + objectSources.begin(); + si != objectSources.end(); ++si) { + const std::string& obj = target->GetObjectName(*si); + objects.push_back(obj_dir + obj); } - properties[prop] = value; - } - // Add the import library for windows DLLs. - if (target->IsDLLPlatform() && - (target->GetType() == cmStateEnums::SHARED_LIBRARY || - target->IsExecutableWithExports()) && - mf->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) { - std::string prop = "IMPORTED_IMPLIB"; - prop += suffix; - std::string value = target->GetFullPath(config, true); - target->GetImplibGNUtoMS(value, value, "${CMAKE_IMPORT_LIBRARY_SUFFIX}"); - properties[prop] = value; + // Store the property. + properties[prop] = cmJoin(objects, ";"); + } else { + // Add the main target file. + { + std::string prop = "IMPORTED_LOCATION"; + prop += suffix; + std::string value; + if (target->IsAppBundleOnApple()) { + value = + target->GetFullPath(config, cmStateEnums::RuntimeBinaryArtifact); + } else { + value = target->GetFullPath(config, + cmStateEnums::RuntimeBinaryArtifact, true); + } + properties[prop] = value; + } + + // Add the import library for windows DLLs. + if (target->HasImportLibrary() && + mf->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) { + std::string prop = "IMPORTED_IMPLIB"; + prop += suffix; + std::string value = + target->GetFullPath(config, cmStateEnums::ImportLibraryArtifact); + target->GetImplibGNUtoMS(value, value, "${CMAKE_IMPORT_LIBRARY_SUFFIX}"); + properties[prop] = value; + } } } diff --git a/Source/cmExportBuildFileGenerator.h b/Source/cmExportBuildFileGenerator.h index 0539b6a..0556983 100644 --- a/Source/cmExportBuildFileGenerator.h +++ b/Source/cmExportBuildFileGenerator.h @@ -3,7 +3,7 @@ #ifndef cmExportBuildFileGenerator_h #define cmExportBuildFileGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmExportFileGenerator.h" diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx index 8102276..38cd511 100644 --- a/Source/cmExportCommand.cxx +++ b/Source/cmExportCommand.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmExportCommand.h" -#include <cmsys/RegularExpression.hxx> +#include "cmsys/RegularExpression.hxx" #include <map> #include <sstream> @@ -149,11 +149,15 @@ bool cmExportCommand::InitialPass(std::vector<std::string> const& args, if (cmTarget* target = gg->FindTarget(*currentTarget)) { if (target->GetType() == cmStateEnums::OBJECT_LIBRARY) { - std::ostringstream e; - e << "given OBJECT library \"" << *currentTarget - << "\" which may not be exported."; - this->SetError(e.str()); - return false; + std::string reason; + if (!this->Makefile->GetGlobalGenerator() + ->HasKnownObjectFileLocation(&reason)) { + std::ostringstream e; + e << "given OBJECT library \"" << *currentTarget + << "\" which may not be exported" << reason << "."; + this->SetError(e.str()); + return false; + } } if (target->GetType() == cmStateEnums::UTILITY) { this->SetError("given custom target \"" + *currentTarget + @@ -279,7 +283,6 @@ bool cmExportCommand::HandlePackage(std::vector<std::string> const& args) #if defined(_WIN32) && !defined(__CYGWIN__) #include <windows.h> -#undef GetCurrentDirectory void cmExportCommand::ReportRegistryError(std::string const& msg, std::string const& key, long err) { diff --git a/Source/cmExportCommand.h b/Source/cmExportCommand.h index 99dac7d..b95ea86 100644 --- a/Source/cmExportCommand.h +++ b/Source/cmExportCommand.h @@ -3,7 +3,8 @@ #ifndef cmExportCommand_h #define cmExportCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> @@ -41,6 +42,7 @@ public: std::string GetName() const CM_OVERRIDE { return "export"; } private: + cmCommandArgumentsHelper Helper; cmCommandArgumentGroup ArgumentGroup; cmCAStringVector Targets; cmCAEnabler Append; diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 6c21eaf..ae3ec3b 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -17,9 +17,9 @@ #include "cmTargetExport.h" #include "cmake.h" +#include "cm_auto_ptr.hxx" +#include "cmsys/FStream.hxx" #include <assert.h> -#include <cm_auto_ptr.hxx> -#include <cmsys/FStream.hxx> #include <sstream> #include <string.h> #include <utility> @@ -441,6 +441,11 @@ void getCompatibleInterfaceProperties(cmGeneratorTarget* target, std::set<std::string>& ifaceProperties, const std::string& config) { + if (target->GetType() == cmStateEnums::OBJECT_LIBRARY) { + // object libraries have no link information, so nothing to compute + return; + } + cmComputeLinkInformation* info = target->GetLinkInformation(config); if (!info) { @@ -927,6 +932,9 @@ void cmExportFileGenerator::GenerateImportTargetCode( case cmStateEnums::UNKNOWN_LIBRARY: os << "add_library(" << targetName << " UNKNOWN IMPORTED)\n"; break; + case cmStateEnums::OBJECT_LIBRARY: + os << "add_library(" << targetName << " OBJECT IMPORTED)\n"; + break; case cmStateEnums::INTERFACE_LIBRARY: os << "add_library(" << targetName << " INTERFACE IMPORTED)\n"; break; diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index e7712d2..985c8f6 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -3,7 +3,7 @@ #ifndef cmExportFileGenerator_h #define cmExportFileGenerator_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include "cmGeneratorExpression.h" #include "cmVersion.h" diff --git a/Source/cmExportInstallAndroidMKGenerator.h b/Source/cmExportInstallAndroidMKGenerator.h index f2f8927..ebef783 100644 --- a/Source/cmExportInstallAndroidMKGenerator.h +++ b/Source/cmExportInstallAndroidMKGenerator.h @@ -3,7 +3,7 @@ #ifndef cmExportInstallAndroidMKGenerator_h #define cmExportInstallAndroidMKGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <iosfwd> #include <set> diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 64ea3c8..16bd5e8 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -195,8 +195,10 @@ void cmExportInstallFileGenerator::GenerateImportPrefix(std::ostream& os) << " \"${CMAKE_CURRENT_LIST_FILE}\" PATH)\n"; if (cmHasLiteralPrefix(absDestS.c_str(), "/lib/") || cmHasLiteralPrefix(absDestS.c_str(), "/lib64/") || + cmHasLiteralPrefix(absDestS.c_str(), "/libx32/") || cmHasLiteralPrefix(absDestS.c_str(), "/usr/lib/") || - cmHasLiteralPrefix(absDestS.c_str(), "/usr/lib64/")) { + cmHasLiteralPrefix(absDestS.c_str(), "/usr/lib64/") || + cmHasLiteralPrefix(absDestS.c_str(), "/usr/libx32/")) { // Handle "/usr move" symlinks created by some Linux distros. /* clang-format off */ os << @@ -329,6 +331,8 @@ void cmExportInstallFileGenerator::GenerateImportTargetsConfig( properties, importedLocations); this->SetImportLocationProperty(config, suffix, te->RuntimeGenerator, properties, importedLocations); + this->SetImportLocationProperty(config, suffix, te->ObjectsGenerator, + properties, importedLocations); this->SetImportLocationProperty(config, suffix, te->FrameworkGenerator, properties, importedLocations); this->SetImportLocationProperty(config, suffix, te->BundleGenerator, @@ -395,6 +399,23 @@ void cmExportInstallFileGenerator::SetImportLocationProperty( // Store the property. properties[prop] = value; importedLocations.insert(prop); + } else if (itgen->GetTarget()->GetType() == cmStateEnums::OBJECT_LIBRARY) { + // Construct the property name. + std::string prop = "IMPORTED_OBJECTS"; + prop += suffix; + + // Compute all the object files inside this target and setup + // IMPORTED_OBJECTS as a list of object files + std::vector<std::string> objects; + itgen->GetInstallObjectNames(config, objects); + for (std::vector<std::string>::iterator i = objects.begin(); + i != objects.end(); ++i) { + *i = value + *i; + } + + // Store the property. + properties[prop] = cmJoin(objects, ";"); + importedLocations.insert(prop); } else { // Construct the property name. std::string prop = "IMPORTED_LOCATION"; diff --git a/Source/cmExportInstallFileGenerator.h b/Source/cmExportInstallFileGenerator.h index 3c9777a..8fa9b7f 100644 --- a/Source/cmExportInstallFileGenerator.h +++ b/Source/cmExportInstallFileGenerator.h @@ -3,7 +3,7 @@ #ifndef cmExportInstallFileGenerator_h #define cmExportInstallFileGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmExportFileGenerator.h" diff --git a/Source/cmExportLibraryDependenciesCommand.cxx b/Source/cmExportLibraryDependenciesCommand.cxx index ac4f040..69150ae 100644 --- a/Source/cmExportLibraryDependenciesCommand.cxx +++ b/Source/cmExportLibraryDependenciesCommand.cxx @@ -2,14 +2,13 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmExportLibraryDependenciesCommand.h" -#include <cmsys/FStream.hxx> +#include "cmsys/FStream.hxx" #include <map> #include <utility> #include "cmGeneratedFileStream.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" -#include "cmPolicies.h" #include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmTarget.h" @@ -23,12 +22,6 @@ class cmExecutionStatus; bool cmExportLibraryDependenciesCommand::InitialPass( std::vector<std::string> const& args, cmExecutionStatus&) { - if (this->Disallowed( - cmPolicies::CMP0033, - "The export_library_dependencies command should not be called; " - "see CMP0033.")) { - return true; - } if (args.empty()) { this->SetError("called with incorrect number of arguments"); return false; diff --git a/Source/cmExportLibraryDependenciesCommand.h b/Source/cmExportLibraryDependenciesCommand.h index be53349..4d3e36e 100644 --- a/Source/cmExportLibraryDependenciesCommand.h +++ b/Source/cmExportLibraryDependenciesCommand.h @@ -3,7 +3,8 @@ #ifndef cmExportLibraryDependenciesCommand_h #define cmExportLibraryDependenciesCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmExportSet.h b/Source/cmExportSet.h index 420f472..58ad617 100644 --- a/Source/cmExportSet.h +++ b/Source/cmExportSet.h @@ -3,7 +3,7 @@ #ifndef cmExportSet_h #define cmExportSet_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmExportSetMap.h b/Source/cmExportSetMap.h index 5090692..0f71c79 100644 --- a/Source/cmExportSetMap.h +++ b/Source/cmExportSetMap.h @@ -3,7 +3,7 @@ #ifndef cmExportSetMap_h #define cmExportSetMap_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <map> #include <string> diff --git a/Source/cmExportTryCompileFileGenerator.h b/Source/cmExportTryCompileFileGenerator.h index 88a70a1..9671fac 100644 --- a/Source/cmExportTryCompileFileGenerator.h +++ b/Source/cmExportTryCompileFileGenerator.h @@ -3,7 +3,7 @@ #ifndef cmExportTryCompileFileGenerator_h #define cmExportTryCompileFileGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmExportFileGenerator.h" diff --git a/Source/cmExprParser.cxx b/Source/cmExprParser.cxx index d11d0b6..19efca1 100644 --- a/Source/cmExprParser.cxx +++ b/Source/cmExprParser.cxx @@ -85,14 +85,17 @@ Modify cmExprParser.cxx: */ +#include "cmConfigure.h" // IWYU pragma: keep + +#include <stdlib.h> +#include <string.h> + /*-------------------------------------------------------------------------*/ #define YYDEBUG 1 #include "cmExprParserHelper.h" /* Interface to parser object. */ #include "cmExprLexer.h" /* Interface to lexer object. */ #include "cmExprParserTokens.h" /* Need YYSTYPE for YY_DECL. */ -#include <math.h> - /* Forward declare the lexer entry point. */ YY_DECL; @@ -105,7 +108,7 @@ static void cmExpr_yyerror(yyscan_t yyscanner, const char* message); # pragma warning (disable: 4065) /* Switch statement contains default but no case. */ #endif -#line 109 "cmExprParser.cxx" /* yacc.c:339 */ +#line 112 "cmExprParser.cxx" /* yacc.c:339 */ # ifndef YY_NULLPTR # if defined __cplusplus && 201103L <= __cplusplus @@ -182,7 +185,7 @@ int cmExpr_yyparse (yyscan_t yyscanner); /* Copy the second part of user declarations. */ -#line 186 "cmExprParser.cxx" /* yacc.c:358 */ +#line 189 "cmExprParser.cxx" /* yacc.c:358 */ #ifdef short # undef short @@ -481,9 +484,9 @@ static const yytype_uint8 yytranslate[] = /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_uint8 yyrline[] = { - 0, 70, 70, 75, 78, 83, 86, 91, 94, 99, - 102, 105, 110, 113, 116, 121, 124, 127, 130, 135, - 138, 141, 146, 149 + 0, 73, 73, 78, 81, 86, 89, 94, 97, 102, + 105, 108, 113, 116, 119, 124, 127, 130, 133, 138, + 141, 144, 149, 152 }; #endif @@ -1278,183 +1281,183 @@ yyreduce: switch (yyn) { case 2: -#line 70 "cmExprParser.y" /* yacc.c:1646 */ +#line 73 "cmExprParser.y" /* yacc.c:1646 */ { cmExpr_yyget_extra(yyscanner)->SetResult((yyvsp[0].Number)); } -#line 1286 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1289 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 3: -#line 75 "cmExprParser.y" /* yacc.c:1646 */ +#line 78 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = (yyvsp[0].Number); } -#line 1294 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1297 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 4: -#line 78 "cmExprParser.y" /* yacc.c:1646 */ +#line 81 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = (yyvsp[-2].Number) | (yyvsp[0].Number); } -#line 1302 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1305 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 5: -#line 83 "cmExprParser.y" /* yacc.c:1646 */ +#line 86 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = (yyvsp[0].Number); } -#line 1310 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1313 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 6: -#line 86 "cmExprParser.y" /* yacc.c:1646 */ +#line 89 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = (yyvsp[-2].Number) ^ (yyvsp[0].Number); } -#line 1318 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1321 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 7: -#line 91 "cmExprParser.y" /* yacc.c:1646 */ +#line 94 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = (yyvsp[0].Number); } -#line 1326 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1329 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 8: -#line 94 "cmExprParser.y" /* yacc.c:1646 */ +#line 97 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = (yyvsp[-2].Number) & (yyvsp[0].Number); } -#line 1334 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1337 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 9: -#line 99 "cmExprParser.y" /* yacc.c:1646 */ +#line 102 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = (yyvsp[0].Number); } -#line 1342 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1345 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 10: -#line 102 "cmExprParser.y" /* yacc.c:1646 */ +#line 105 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = (yyvsp[-2].Number) << (yyvsp[0].Number); } -#line 1350 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1353 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 11: -#line 105 "cmExprParser.y" /* yacc.c:1646 */ +#line 108 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = (yyvsp[-2].Number) >> (yyvsp[0].Number); } -#line 1358 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1361 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 12: -#line 110 "cmExprParser.y" /* yacc.c:1646 */ +#line 113 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = (yyvsp[0].Number); } -#line 1366 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1369 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 13: -#line 113 "cmExprParser.y" /* yacc.c:1646 */ +#line 116 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = (yyvsp[-2].Number) + (yyvsp[0].Number); } -#line 1374 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1377 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 14: -#line 116 "cmExprParser.y" /* yacc.c:1646 */ +#line 119 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = (yyvsp[-2].Number) - (yyvsp[0].Number); } -#line 1382 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1385 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 15: -#line 121 "cmExprParser.y" /* yacc.c:1646 */ +#line 124 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = (yyvsp[0].Number); } -#line 1390 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1393 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 16: -#line 124 "cmExprParser.y" /* yacc.c:1646 */ +#line 127 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = (yyvsp[-2].Number) * (yyvsp[0].Number); } -#line 1398 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1401 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 17: -#line 127 "cmExprParser.y" /* yacc.c:1646 */ +#line 130 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = (yyvsp[-2].Number) / (yyvsp[0].Number); } -#line 1406 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1409 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 18: -#line 130 "cmExprParser.y" /* yacc.c:1646 */ +#line 133 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = (yyvsp[-2].Number) % (yyvsp[0].Number); } -#line 1414 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1417 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 19: -#line 135 "cmExprParser.y" /* yacc.c:1646 */ +#line 138 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = (yyvsp[0].Number); } -#line 1422 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1425 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 20: -#line 138 "cmExprParser.y" /* yacc.c:1646 */ +#line 141 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = + (yyvsp[0].Number); } -#line 1430 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1433 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 21: -#line 141 "cmExprParser.y" /* yacc.c:1646 */ +#line 144 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = - (yyvsp[0].Number); } -#line 1438 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1441 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 22: -#line 146 "cmExprParser.y" /* yacc.c:1646 */ +#line 149 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = (yyvsp[0].Number); } -#line 1446 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1449 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 23: -#line 149 "cmExprParser.y" /* yacc.c:1646 */ +#line 152 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = (yyvsp[-1].Number); } -#line 1454 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1457 "cmExprParser.cxx" /* yacc.c:1646 */ break; -#line 1458 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1461 "cmExprParser.cxx" /* yacc.c:1646 */ default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -1684,7 +1687,7 @@ yyreturn: #endif return yyresult; } -#line 154 "cmExprParser.y" /* yacc.c:1906 */ +#line 157 "cmExprParser.y" /* yacc.c:1906 */ /* End of grammar */ diff --git a/Source/cmExprParser.y b/Source/cmExprParser.y index c7c4a7b..220f7c8 100644 --- a/Source/cmExprParser.y +++ b/Source/cmExprParser.y @@ -14,14 +14,17 @@ Modify cmExprParser.cxx: */ +#include "cmConfigure.h" // IWYU pragma: keep + +#include <stdlib.h> +#include <string.h> + /*-------------------------------------------------------------------------*/ #define YYDEBUG 1 #include "cmExprParserHelper.h" /* Interface to parser object. */ #include "cmExprLexer.h" /* Interface to lexer object. */ #include "cmExprParserTokens.h" /* Need YYSTYPE for YY_DECL. */ -#include <math.h> - /* Forward declare the lexer entry point. */ YY_DECL; diff --git a/Source/cmExprParserHelper.cxx b/Source/cmExprParserHelper.cxx index 1b49def..c3f026a 100644 --- a/Source/cmExprParserHelper.cxx +++ b/Source/cmExprParserHelper.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmExprParserHelper.h" -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmExprLexer.h" diff --git a/Source/cmExprParserHelper.h b/Source/cmExprParserHelper.h index 8f00f1d..dcdaca9 100644 --- a/Source/cmExprParserHelper.h +++ b/Source/cmExprParserHelper.h @@ -3,28 +3,18 @@ #ifndef cmExprParserHelper_h #define cmExprParserHelper_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> -#define YYSTYPE cmExprParserHelper::ParserType -#define YYSTYPE_IS_DECLARED -#define YY_EXTRA_TYPE cmExprParserHelper* -#define YY_DECL int cmExpr_yylex(YYSTYPE* yylvalp, yyscan_t yyscanner) - -/** \class cmExprParserHelper - * \brief Helper class for parsing java source files - * - * Finds dependencies for java file and list of outputs - */ class cmExprParserHelper { public: - typedef struct + struct ParserType { int Number; - } ParserType; + }; cmExprParserHelper(); ~cmExprParserHelper(); @@ -57,4 +47,9 @@ private: std::string ErrorString; }; +#define YYSTYPE cmExprParserHelper::ParserType +#define YYSTYPE_IS_DECLARED +#define YY_EXTRA_TYPE cmExprParserHelper* +#define YY_DECL int cmExpr_yylex(YYSTYPE* yylvalp, yyscan_t yyscanner) + #endif diff --git a/Source/cmExternalMakefileProjectGenerator.h b/Source/cmExternalMakefileProjectGenerator.h index c49d39b..6b89037 100644 --- a/Source/cmExternalMakefileProjectGenerator.h +++ b/Source/cmExternalMakefileProjectGenerator.h @@ -3,7 +3,7 @@ #ifndef cmExternalMakefileProjectGenerator_h #define cmExternalMakefileProjectGenerator_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmExtraCodeBlocksGenerator.h b/Source/cmExtraCodeBlocksGenerator.h index 06aadc4..450a9d0 100644 --- a/Source/cmExtraCodeBlocksGenerator.h +++ b/Source/cmExtraCodeBlocksGenerator.h @@ -3,7 +3,7 @@ #ifndef cmExtraCodeBlocksGenerator_h #define cmExtraCodeBlocksGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmExternalMakefileProjectGenerator.h" diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx index fd7da18..98eebe6 100644 --- a/Source/cmExtraCodeLiteGenerator.cxx +++ b/Source/cmExtraCodeLiteGenerator.cxx @@ -13,7 +13,7 @@ #include "cmXMLWriter.h" #include "cmake.h" -#include <cmsys/SystemInformation.hxx> +#include "cmsys/SystemInformation.hxx" #include <map> #include <set> #include <sstream> @@ -349,6 +349,87 @@ void cmExtraCodeLiteGenerator::FindMatchingHeaderfiles( } } +void cmExtraCodeLiteGenerator::CreateFoldersAndFiles( + std::set<std::string>& cFiles, cmXMLWriter& xml, + const std::string& projectPath) +{ + std::vector<std::string> tmp_path; + std::vector<std::string> components; + size_t numOfEndEl = 0; + + for (std::set<std::string>::const_iterator it = cFiles.begin(); + it != cFiles.end(); ++it) { + std::string frelapath = + cmSystemTools::RelativePath(projectPath.c_str(), it->c_str()); + cmsys::SystemTools::SplitPath(frelapath, components, false); + components.pop_back(); // erase last member -> it is file, not folder + components.erase(components.begin()); // erase "root" + + size_t sizeOfSkip = 0; + + for (size_t i = 0; i < components.size(); ++i) { + // skip relative path + if (components[i] == ".." || components[i] == ".") { + sizeOfSkip++; + continue; + } + + // same folder + if (tmp_path.size() > i - sizeOfSkip && + tmp_path[i - sizeOfSkip] == components[i]) { + continue; + } + + // delete "old" subfolders + if (tmp_path.size() > i - sizeOfSkip) { + numOfEndEl = tmp_path.size() - i + sizeOfSkip; + tmp_path.erase(tmp_path.end() - numOfEndEl, tmp_path.end()); + for (; numOfEndEl--;) { + xml.EndElement(); + } + } + + // add folder + xml.StartElement("VirtualDirectory"); + xml.Attribute("Name", components[i]); + tmp_path.push_back(components[i]); + } + + // delete "old" subfolders + numOfEndEl = tmp_path.size() - components.size() + sizeOfSkip; + if (numOfEndEl) { + tmp_path.erase(tmp_path.end() - numOfEndEl, tmp_path.end()); + for (; numOfEndEl--;) { + xml.EndElement(); + } + } + + // add file + xml.StartElement("File"); + xml.Attribute("Name", frelapath); + xml.EndElement(); + } + + // end of folders + numOfEndEl = tmp_path.size(); + for (; numOfEndEl--;) { + xml.EndElement(); + } +} + +void cmExtraCodeLiteGenerator::CreateFoldersAndFiles( + std::map<std::string, cmSourceFile*>& cFiles, cmXMLWriter& xml, + const std::string& projectPath) +{ + std::set<std::string> s; + for (std::map<std::string, cmSourceFile*>::const_iterator it = + cFiles.begin(); + it != cFiles.end(); ++it) { + s.insert(it->first); + } + this->CreateFoldersAndFiles(s, xml, projectPath); +} + void cmExtraCodeLiteGenerator::CreateProjectSourceEntries( std::map<std::string, cmSourceFile*>& cFiles, std::set<std::string>& otherFiles, cmXMLWriter* _xml, @@ -366,26 +447,12 @@ void cmExtraCodeLiteGenerator::CreateProjectSourceEntries( // insert all source files in the codelite project // first the C/C++ implementation files, then all others - for (std::map<std::string, cmSourceFile*>::const_iterator sit = - cFiles.begin(); - sit != cFiles.end(); ++sit) { - xml.StartElement("File"); - std::string fpath(sit->first); - std::string frelapath = - cmSystemTools::RelativePath(projectPath.c_str(), sit->first.c_str()); - xml.Attribute("Name", frelapath); - xml.EndElement(); - } + this->CreateFoldersAndFiles(cFiles, xml, projectPath); xml.EndElement(); // VirtualDirectory + xml.StartElement("VirtualDirectory"); xml.Attribute("Name", "include"); - for (std::set<std::string>::const_iterator sit = otherFiles.begin(); - sit != otherFiles.end(); ++sit) { - xml.StartElement("File"); - xml.Attribute( - "Name", cmSystemTools::RelativePath(projectPath.c_str(), sit->c_str())); - xml.EndElement(); - } + this->CreateFoldersAndFiles(otherFiles, xml, projectPath); xml.EndElement(); // VirtualDirectory // Get the number of CPUs. We use this information for the make -jN diff --git a/Source/cmExtraCodeLiteGenerator.h b/Source/cmExtraCodeLiteGenerator.h index 773515d..de33098 100644 --- a/Source/cmExtraCodeLiteGenerator.h +++ b/Source/cmExtraCodeLiteGenerator.h @@ -3,7 +3,7 @@ #ifndef cmGlobalCodeLiteGenerator_h #define cmGlobalCodeLiteGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmExternalMakefileProjectGenerator.h" @@ -50,6 +50,10 @@ protected: const cmMakefile* mf, const std::string& projectType, const std::string& targetName); + void CreateFoldersAndFiles(std::set<std::string>& cFiles, cmXMLWriter& xml, + const std::string& projectPath); + void CreateFoldersAndFiles(std::map<std::string, cmSourceFile*>& cFiles, + cmXMLWriter& xml, const std::string& projectPath); public: cmExtraCodeLiteGenerator(); diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index b4fc771..8d1adc7 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -2,9 +2,9 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmExtraEclipseCDT4Generator.h" +#include "cmsys/RegularExpression.hxx" #include <algorithm> #include <assert.h> -#include <cmsys/RegularExpression.hxx> #include <map> #include <sstream> #include <stdio.h> diff --git a/Source/cmExtraEclipseCDT4Generator.h b/Source/cmExtraEclipseCDT4Generator.h index fe71172..1380d18 100644 --- a/Source/cmExtraEclipseCDT4Generator.h +++ b/Source/cmExtraEclipseCDT4Generator.h @@ -3,7 +3,7 @@ #ifndef cmExtraEclipseCDT4Generator_h #define cmExtraEclipseCDT4Generator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmExternalMakefileProjectGenerator.h" diff --git a/Source/cmExtraKateGenerator.h b/Source/cmExtraKateGenerator.h index badaca9..6b9c7af 100644 --- a/Source/cmExtraKateGenerator.h +++ b/Source/cmExtraKateGenerator.h @@ -3,7 +3,7 @@ #ifndef cmExtraKateGenerator_h #define cmExtraKateGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmExternalMakefileProjectGenerator.h" diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 36ba520..1fd1418 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmExtraSublimeTextGenerator.h" -#include <cmsys/RegularExpression.hxx> +#include "cmsys/RegularExpression.hxx" #include <set> #include <sstream> #include <string.h> diff --git a/Source/cmExtraSublimeTextGenerator.h b/Source/cmExtraSublimeTextGenerator.h index a860d34..9022d37 100644 --- a/Source/cmExtraSublimeTextGenerator.h +++ b/Source/cmExtraSublimeTextGenerator.h @@ -3,7 +3,7 @@ #ifndef cmExtraSublimeTextGenerator_h #define cmExtraSublimeTextGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmExternalMakefileProjectGenerator.h" diff --git a/Source/cmFLTKWrapUICommand.h b/Source/cmFLTKWrapUICommand.h index 835f0a7..7dde9c1 100644 --- a/Source/cmFLTKWrapUICommand.h +++ b/Source/cmFLTKWrapUICommand.h @@ -3,7 +3,8 @@ #ifndef cmFLTKWrapUICommand_h #define cmFLTKWrapUICommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 91cecb3..fa166a0 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -2,24 +2,20 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmFileCommand.h" +#include "cm_kwiml.h" +#include "cmsys/Directory.hxx" +#include "cmsys/FStream.hxx" +#include "cmsys/Glob.hxx" +#include "cmsys/RegularExpression.hxx" +#include "cmsys/String.hxx" #include <algorithm> #include <assert.h> -#include <cm_kwiml.h> -#include <cmsys/Directory.hxx> -#include <cmsys/FStream.hxx> -#include <cmsys/Glob.hxx> -#include <cmsys/RegularExpression.hxx> -#include <cmsys/String.hxx> #include <list> #include <sstream> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <sys/types.h> -// include sys/stat.h after sys/types.h -#include <sys/stat.h> - #include "cmAlgorithms.h" #include "cmCommandArgumentsHelper.h" #include "cmCryptoHash.h" @@ -35,11 +31,17 @@ #include "cmSystemTools.h" #include "cmTimestamp.h" #include "cm_auto_ptr.hxx" +#include "cm_sys_stat.h" #include "cmake.h" #if defined(CMAKE_BUILD_WITH_CMAKE) #include "cmCurl.h" #include "cmFileLockResult.h" +#include "cm_curl.h" +#endif + +#if defined(CMAKE_USE_ELF_PARSER) +#include "cmELF.h" #endif class cmSystemToolsFileTime; @@ -166,6 +168,9 @@ bool cmFileCommand::InitialPass(std::vector<std::string> const& args, if (subCommand == "RPATH_REMOVE") { return this->HandleRPathRemoveCommand(args); } + if (subCommand == "READ_ELF") { + return this->HandleReadElfCommand(args); + } if (subCommand == "RELATIVE_PATH") { return this->HandleRelativePathCommand(args); } @@ -608,8 +613,8 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args) continue; } - else if ((c >= 0x20 && c < 0x7F) || c == '\t' || - (c == '\n' && newline_consume)) { + if ((c >= 0x20 && c < 0x7F) || c == '\t' || + (c == '\n' && newline_consume)) { // This is an ASCII character that may be part of a string. // Cast added to avoid compiler warning. Cast is ok because // c is guaranteed to fit in char by the above if... @@ -1024,8 +1029,6 @@ protected: { } }; - struct MatchRule; - friend struct MatchRule; struct MatchRule { cmsys::RegularExpression Regex; @@ -1144,6 +1147,7 @@ protected: bool UseGivenPermissionsDir; bool UseSourcePermissions; std::string Destination; + std::string FilesFromDir; std::vector<std::string> Files; int Doing; @@ -1153,6 +1157,7 @@ protected: DoingNone, DoingError, DoingDestination, + DoingFilesFromDir, DoingFiles, DoingPattern, DoingRegex, @@ -1248,6 +1253,12 @@ bool cmFileCopier::CheckKeyword(std::string const& arg) } else { this->Doing = DoingDestination; } + } else if (arg == "FILES_FROM_DIR") { + if (this->CurrentMatchRule) { + this->NotAfterMatch(arg); + } else { + this->Doing = DoingFilesFromDir; + } } else if (arg == "PATTERN") { this->Doing = DoingPattern; } else if (arg == "REGEX") { @@ -1311,13 +1322,7 @@ bool cmFileCopier::CheckValue(std::string const& arg) { switch (this->Doing) { case DoingFiles: - if (arg.empty() || cmSystemTools::FileIsFullPath(arg.c_str())) { - this->Files.push_back(arg); - } else { - std::string file = this->Makefile->GetCurrentSourceDirectory(); - file += "/" + arg; - this->Files.push_back(file); - } + this->Files.push_back(arg); break; case DoingDestination: if (arg.empty() || cmSystemTools::FileIsFullPath(arg.c_str())) { @@ -1328,6 +1333,16 @@ bool cmFileCopier::CheckValue(std::string const& arg) } this->Doing = DoingNone; break; + case DoingFilesFromDir: + if (cmSystemTools::FileIsFullPath(arg.c_str())) { + this->FilesFromDir = arg; + } else { + this->FilesFromDir = this->Makefile->GetCurrentSourceDirectory(); + this->FilesFromDir += "/" + arg; + } + cmSystemTools::ConvertToUnixSlashes(this->FilesFromDir); + this->Doing = DoingNone; + break; case DoingPattern: { // Convert the pattern to a regular expression. Require a // leading slash and trailing end-of-string in the matched @@ -1387,17 +1402,41 @@ bool cmFileCopier::Run(std::vector<std::string> const& args) return false; } - std::vector<std::string> const& files = this->Files; - for (std::vector<std::string>::size_type i = 0; i < files.size(); ++i) { + for (std::vector<std::string>::const_iterator i = this->Files.begin(); + i != this->Files.end(); ++i) { + std::string file; + if (!i->empty() && !cmSystemTools::FileIsFullPath(*i)) { + if (!this->FilesFromDir.empty()) { + file = this->FilesFromDir; + } else { + file = this->Makefile->GetCurrentSourceDirectory(); + } + file += "/"; + file += *i; + } else if (!this->FilesFromDir.empty()) { + this->FileCommand->SetError("option FILES_FROM_DIR requires all files " + "to be specified as relative paths."); + return false; + } else { + file = *i; + } + // Split the input file into its directory and name components. std::vector<std::string> fromPathComponents; - cmSystemTools::SplitPath(files[i], fromPathComponents); + cmSystemTools::SplitPath(file, fromPathComponents); std::string fromName = *(fromPathComponents.end() - 1); std::string fromDir = cmSystemTools::JoinPath( fromPathComponents.begin(), fromPathComponents.end() - 1); // Compute the full path to the destination file. std::string toFile = this->Destination; + if (!this->FilesFromDir.empty()) { + std::string dir = cmSystemTools::GetFilenamePath(*i); + if (!dir.empty()) { + toFile += "/"; + toFile += dir; + } + } std::string const& toName = this->ToName(fromName); if (!toName.empty()) { toFile += "/"; @@ -1482,6 +1521,9 @@ bool cmFileCopier::InstallSymlink(const char* fromFile, const char* toFile) // Remove the destination file so we can always create the symlink. cmSystemTools::RemoveFile(toFile); + // Create destination directory if it doesn't exist + cmSystemTools::MakeDirectory(cmSystemTools::GetFilenamePath(toFile)); + // Create the symlink. if (!cmSystemTools::CreateSymlink(symlinkTarget, toFile)) { std::ostringstream e; @@ -1745,6 +1787,11 @@ bool cmFileInstaller::Parse(std::vector<std::string> const& args) } if (!this->Rename.empty()) { + if (!this->FilesFromDir.empty()) { + this->FileCommand->SetError("INSTALL option RENAME may not be " + "combined with FILES_FROM_DIR."); + return false; + } if (this->InstallType != cmInstallType_FILES && this->InstallType != cmInstallType_PROGRAMS) { this->FileCommand->SetError("INSTALL option RENAME may be used " @@ -2177,6 +2224,68 @@ bool cmFileCommand::HandleRPathCheckCommand( return true; } +bool cmFileCommand::HandleReadElfCommand(std::vector<std::string> const& args) +{ + if (args.size() < 4) { + this->SetError("READ_ELF must be called with at least three additional " + "arguments."); + return false; + } + + cmCommandArgumentsHelper argHelper; + cmCommandArgumentGroup group; + + cmCAString readArg(&argHelper, "READ_ELF"); + cmCAString fileNameArg(&argHelper, CM_NULLPTR); + + cmCAString rpathArg(&argHelper, "RPATH", &group); + cmCAString runpathArg(&argHelper, "RUNPATH", &group); + cmCAString errorArg(&argHelper, "CAPTURE_ERROR", &group); + + readArg.Follows(CM_NULLPTR); + fileNameArg.Follows(&readArg); + group.Follows(&fileNameArg); + argHelper.Parse(&args, CM_NULLPTR); + + if (!cmSystemTools::FileExists(fileNameArg.GetString(), true)) { + std::ostringstream e; + e << "READ_ELF given FILE \"" << fileNameArg.GetString() + << "\" that does not exist."; + this->SetError(e.str()); + return false; + } + +#if defined(CMAKE_USE_ELF_PARSER) + cmELF elf(fileNameArg.GetCString()); + + if (!rpathArg.GetString().empty()) { + if (cmELF::StringEntry const* se_rpath = elf.GetRPath()) { + std::string rpath(se_rpath->Value); + std::replace(rpath.begin(), rpath.end(), ':', ';'); + this->Makefile->AddDefinition(rpathArg.GetString(), rpath.c_str()); + } + } + if (!runpathArg.GetString().empty()) { + if (cmELF::StringEntry const* se_runpath = elf.GetRunPath()) { + std::string runpath(se_runpath->Value); + std::replace(runpath.begin(), runpath.end(), ':', ';'); + this->Makefile->AddDefinition(runpathArg.GetString(), runpath.c_str()); + } + } + + return true; +#else + std::string error = "ELF parser not available on this platform."; + if (errorArg.GetString().empty()) { + this->SetError(error); + return false; + } else { + this->Makefile->AddDefinition(errorArg.GetString(), error.c_str()); + return true; + } +#endif +} + bool cmFileCommand::HandleInstallCommand(std::vector<std::string> const& args) { cmFileInstaller installer(this); diff --git a/Source/cmFileCommand.h b/Source/cmFileCommand.h index 319864c..121fec0 100644 --- a/Source/cmFileCommand.h +++ b/Source/cmFileCommand.h @@ -3,7 +3,8 @@ #ifndef cmFileCommand_h #define cmFileCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> @@ -53,6 +54,7 @@ protected: bool HandleRelativePathCommand(std::vector<std::string> const& args); bool HandleCMakePathCommand(std::vector<std::string> const& args, bool nativePath); + bool HandleReadElfCommand(std::vector<std::string> const& args); bool HandleRPathChangeCommand(std::vector<std::string> const& args); bool HandleRPathCheckCommand(std::vector<std::string> const& args); bool HandleRPathRemoveCommand(std::vector<std::string> const& args); diff --git a/Source/cmFileLock.h b/Source/cmFileLock.h index ab3cb1f..8f996cf 100644 --- a/Source/cmFileLock.h +++ b/Source/cmFileLock.h @@ -3,7 +3,7 @@ #ifndef cmFileLock_h #define cmFileLock_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <string> diff --git a/Source/cmFileLockPool.h b/Source/cmFileLockPool.h index fbe01c8..09c984c 100644 --- a/Source/cmFileLockPool.h +++ b/Source/cmFileLockPool.h @@ -3,7 +3,7 @@ #ifndef cmFileLockPool_h #define cmFileLockPool_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <list> #include <string> diff --git a/Source/cmFileLockResult.h b/Source/cmFileLockResult.h index 679432a..4cedc0a 100644 --- a/Source/cmFileLockResult.h +++ b/Source/cmFileLockResult.h @@ -3,7 +3,7 @@ #ifndef cmFileLockResult_h #define cmFileLockResult_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <string> diff --git a/Source/cmFileMonitor.cxx b/Source/cmFileMonitor.cxx index 909be78..ed794c3 100644 --- a/Source/cmFileMonitor.cxx +++ b/Source/cmFileMonitor.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmFileMonitor.h" -#include <cmsys/SystemTools.hxx> +#include "cmsys/SystemTools.hxx" #include <cassert> #include <iostream> @@ -236,7 +236,7 @@ public: cmFileMonitor::Callback cb) : Parent(p) , PathSegment(ps) - , CbList({ cb }) + , CbList({ std::move(cb) }) { assert(p); assert(!ps.empty()); diff --git a/Source/cmFileMonitor.h b/Source/cmFileMonitor.h index 48169b8..8574db0 100644 --- a/Source/cmFileMonitor.h +++ b/Source/cmFileMonitor.h @@ -2,6 +2,8 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #pragma once +#include "cmConfigure.h" // IWYU pragma: keep + #include <functional> #include <string> #include <vector> diff --git a/Source/cmFilePathChecksum.cxx b/Source/cmFilePathChecksum.cxx index 3d8b695..62f52e5 100644 --- a/Source/cmFilePathChecksum.cxx +++ b/Source/cmFilePathChecksum.cxx @@ -45,7 +45,7 @@ void cmFilePathChecksum::setupParentDirs(const std::string& currentSrcDir, parentDirs[3].second = "ProjectBinary"; } -std::string cmFilePathChecksum::get(const std::string& filePath) +std::string cmFilePathChecksum::get(const std::string& filePath) const { std::string relPath; std::string relSeed; @@ -82,7 +82,7 @@ std::string cmFilePathChecksum::get(const std::string& filePath) } std::string cmFilePathChecksum::getPart(const std::string& filePath, - size_t length) + size_t length) const { return get(filePath).substr(0, length); } diff --git a/Source/cmFilePathChecksum.h b/Source/cmFilePathChecksum.h index df19053..9d570eb 100644 --- a/Source/cmFilePathChecksum.h +++ b/Source/cmFilePathChecksum.h @@ -3,7 +3,7 @@ #ifndef cmFilePathChecksum_h #define cmFilePathChecksum_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <stddef.h> #include <string> @@ -47,13 +47,13 @@ public: /* @brief Calculates the path checksum for the parent directory of a file * */ - std::string get(const std::string& filePath); + std::string get(const std::string& filePath) const; /* @brief Same as get() but returns only the first length characters * */ std::string getPart(const std::string& filePath, - size_t length = partLengthDefault); + size_t length = partLengthDefault) const; private: /// Size of the parent directory list diff --git a/Source/cmFileTimeComparison.cxx b/Source/cmFileTimeComparison.cxx index 991ebb8..f591a8d 100644 --- a/Source/cmFileTimeComparison.cxx +++ b/Source/cmFileTimeComparison.cxx @@ -10,10 +10,10 @@ // Use a platform-specific API to get file times efficiently. #if !defined(_WIN32) || defined(__CYGWIN__) -#include <sys/stat.h> +#include "cm_sys_stat.h" #define cmFileTimeComparison_Type struct stat #else -#include <cmsys/Encoding.hxx> +#include "cmsys/Encoding.hxx" #include <windows.h> #define cmFileTimeComparison_Type FILETIME #endif diff --git a/Source/cmFileTimeComparison.h b/Source/cmFileTimeComparison.h index 6eb1500..b1f8ed6 100644 --- a/Source/cmFileTimeComparison.h +++ b/Source/cmFileTimeComparison.h @@ -3,7 +3,7 @@ #ifndef cmFileTimeComparison_h #define cmFileTimeComparison_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep class cmFileTimeComparisonInternal; diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx index dce5021..068dcfc 100644 --- a/Source/cmFindBase.cxx +++ b/Source/cmFindBase.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmFindBase.h" -#include <cmConfigure.h> +#include "cmConfigure.h" #include <iostream> #include <map> #include <stddef.h> diff --git a/Source/cmFindBase.h b/Source/cmFindBase.h index 423d453..81494f1 100644 --- a/Source/cmFindBase.h +++ b/Source/cmFindBase.h @@ -3,7 +3,7 @@ #ifndef cmFindBase_h #define cmFindBase_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmFindCommon.h b/Source/cmFindCommon.h index 4d6d569..426d233 100644 --- a/Source/cmFindCommon.h +++ b/Source/cmFindCommon.h @@ -3,7 +3,7 @@ #ifndef cmFindCommon_h #define cmFindCommon_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <map> #include <set> diff --git a/Source/cmFindFileCommand.h b/Source/cmFindFileCommand.h index 5c94ebf..489df65 100644 --- a/Source/cmFindFileCommand.h +++ b/Source/cmFindFileCommand.h @@ -3,7 +3,8 @@ #ifndef cmFindFileCommand_h #define cmFindFileCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include "cmFindPathCommand.h" diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx index c86f9c1..562a9fc 100644 --- a/Source/cmFindLibraryCommand.cxx +++ b/Source/cmFindLibraryCommand.cxx @@ -2,8 +2,8 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmFindLibraryCommand.h" +#include "cmsys/RegularExpression.hxx" #include <algorithm> -#include <cmsys/RegularExpression.hxx> #include <set> #include <stdio.h> #include <string.h> @@ -43,20 +43,29 @@ bool cmFindLibraryCommand::InitialPass(std::vector<std::string> const& argsIn, return true; } - if (this->Makefile->GetState()->GetGlobalPropertyAsBool( - "FIND_LIBRARY_USE_LIB32_PATHS")) { - // add special 32 bit paths if this is a 32 bit compile. - if (this->Makefile->PlatformIs32Bit()) { - this->AddArchitecturePaths("32"); - } + // add custom lib<qual> paths instead of using fixed lib32, lib64 or + // libx32 + if (const char* customLib = this->Makefile->GetDefinition( + "CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX")) { + this->AddArchitecturePaths(customLib); } - - if (this->Makefile->GetState()->GetGlobalPropertyAsBool( - "FIND_LIBRARY_USE_LIB64_PATHS")) { - // add special 64 bit paths if this is a 64 bit compile. - if (this->Makefile->PlatformIs64Bit()) { - this->AddArchitecturePaths("64"); - } + // add special 32 bit paths if this is a 32 bit compile. + else if (this->Makefile->PlatformIs32Bit() && + this->Makefile->GetState()->GetGlobalPropertyAsBool( + "FIND_LIBRARY_USE_LIB32_PATHS")) { + this->AddArchitecturePaths("32"); + } + // add special 64 bit paths if this is a 64 bit compile. + else if (this->Makefile->PlatformIs64Bit() && + this->Makefile->GetState()->GetGlobalPropertyAsBool( + "FIND_LIBRARY_USE_LIB64_PATHS")) { + this->AddArchitecturePaths("64"); + } + // add special 32 bit paths if this is an x32 compile. + else if (this->Makefile->PlatformIsx32() && + this->Makefile->GetState()->GetGlobalPropertyAsBool( + "FIND_LIBRARY_USE_LIBX32_PATHS")) { + this->AddArchitecturePaths("x32"); } std::string library = this->FindLibrary(); diff --git a/Source/cmFindLibraryCommand.h b/Source/cmFindLibraryCommand.h index aeff629..4a60505 100644 --- a/Source/cmFindLibraryCommand.h +++ b/Source/cmFindLibraryCommand.h @@ -3,7 +3,8 @@ #ifndef cmFindLibraryCommand_h #define cmFindLibraryCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 60de74f..17fa92c 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -2,14 +2,14 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmFindPackageCommand.h" +#include "cmSystemTools.h" +#include "cmsys/Directory.hxx" +#include "cmsys/FStream.hxx" +#include "cmsys/Glob.hxx" +#include "cmsys/RegularExpression.hxx" +#include "cmsys/String.h" #include <algorithm> #include <assert.h> -#include <cmSystemTools.h> -#include <cmsys/Directory.hxx> -#include <cmsys/FStream.hxx> -#include <cmsys/Glob.hxx> -#include <cmsys/RegularExpression.hxx> -#include <cmsys/String.h> #include <functional> #include <iterator> #include <sstream> @@ -92,6 +92,7 @@ cmFindPackageCommand::cmFindPackageCommand() this->DebugMode = false; this->UseLib32Paths = false; this->UseLib64Paths = false; + this->UseLibx32Paths = false; this->PolicyScope = true; this->VersionMajor = 0; this->VersionMinor = 0; @@ -173,6 +174,13 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args, this->UseLib64Paths = true; } + // Lookup whether libx32 paths should be used. + if (this->Makefile->PlatformIsx32() && + this->Makefile->GetState()->GetGlobalPropertyAsBool( + "FIND_LIBRARY_USE_LIBX32_PATHS")) { + this->UseLibx32Paths = true; + } + // Check if User Package Registry should be disabled if (this->Makefile->IsOn("CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY")) { this->NoUserRegistry = true; @@ -1165,7 +1173,6 @@ void cmFindPackageCommand::FillPrefixesSystemRegistry() #if defined(_WIN32) && !defined(__CYGWIN__) #include <windows.h> -#undef GetCurrentDirectory // http://msdn.microsoft.com/en-us/library/aa384253%28v=vs.85%29.aspx #if !defined(KEY_WOW64_32KEY) #define KEY_WOW64_32KEY 0x0200 @@ -2002,6 +2009,9 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in) if (this->UseLib64Paths) { common.push_back("lib64"); } + if (this->UseLibx32Paths) { + common.push_back("libx32"); + } common.push_back("lib"); common.push_back("share"); diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h index d454892..c42ecce 100644 --- a/Source/cmFindPackageCommand.h +++ b/Source/cmFindPackageCommand.h @@ -3,8 +3,9 @@ #ifndef cmFindPackageCommand_h #define cmFindPackageCommand_h -#include <cmConfigure.h> -#include <cm_kwiml.h> +#include "cmConfigure.h" + +#include "cm_kwiml.h" #include <map> #include <set> #include <string> @@ -169,6 +170,7 @@ private: bool DebugMode; bool UseLib32Paths; bool UseLib64Paths; + bool UseLibx32Paths; bool PolicyScope; std::string LibraryArchitecture; std::vector<std::string> Names; diff --git a/Source/cmFindPathCommand.cxx b/Source/cmFindPathCommand.cxx index 8d4bcf3..644b025 100644 --- a/Source/cmFindPathCommand.cxx +++ b/Source/cmFindPathCommand.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmFindPathCommand.h" -#include <cmsys/Glob.hxx> +#include "cmsys/Glob.hxx" #include "cmMakefile.h" #include "cmStateTypes.h" diff --git a/Source/cmFindPathCommand.h b/Source/cmFindPathCommand.h index edeeb3a..205bb17 100644 --- a/Source/cmFindPathCommand.h +++ b/Source/cmFindPathCommand.h @@ -3,7 +3,8 @@ #ifndef cmFindPathCommand_h #define cmFindPathCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmFindProgramCommand.h b/Source/cmFindProgramCommand.h index dc17803..73894ba 100644 --- a/Source/cmFindProgramCommand.h +++ b/Source/cmFindProgramCommand.h @@ -3,7 +3,8 @@ #ifndef cmFindProgramCommand_h #define cmFindProgramCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmForEachCommand.h b/Source/cmForEachCommand.h index 93c4676..c71b905 100644 --- a/Source/cmForEachCommand.h +++ b/Source/cmForEachCommand.h @@ -3,7 +3,8 @@ #ifndef cmForEachCommand_h #define cmForEachCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmFortranParser.cxx b/Source/cmFortranParser.cxx index 896e589..2b3452f 100644 --- a/Source/cmFortranParser.cxx +++ b/Source/cmFortranParser.cxx @@ -97,13 +97,17 @@ Modify cmFortranParser.cxx: - "#if 0" out yyerrorlab block in range ["goto yyerrlab1", "yyerrlab1:"] */ +#include "cmConfigure.h" // IWYU pragma: keep + +#include "cmsys/String.h" +#include <stdlib.h> +#include <string.h> + /*-------------------------------------------------------------------------*/ #define cmFortranParser_cxx #include "cmFortranParser.h" /* Interface to parser object. */ #include "cmFortranParserTokens.h" /* Need YYSTYPE for YY_DECL. */ -#include <cmsys/String.h> - /* Forward declare the lexer entry point. */ YY_DECL; @@ -124,7 +128,7 @@ static void cmFortran_yyerror(yyscan_t yyscanner, const char* message) # pragma warning (disable: 4244) /* Conversion to smaller type, data loss. */ #endif -#line 137 "cmFortranParser.cxx" /* yacc.c:339 */ +#line 132 "cmFortranParser.cxx" /* yacc.c:339 */ # ifndef YY_NULLPTR # if defined __cplusplus && 201103L <= __cplusplus @@ -244,11 +248,11 @@ extern int cmFortran_yydebug; union YYSTYPE { -#line 75 "cmFortranParser.y" /* yacc.c:355 */ +#line 70 "cmFortranParser.y" /* yacc.c:355 */ char* string; -#line 261 "cmFortranParser.cxx" /* yacc.c:355 */ +#line 256 "cmFortranParser.cxx" /* yacc.c:355 */ }; typedef union YYSTYPE YYSTYPE; @@ -264,7 +268,7 @@ int cmFortran_yyparse (yyscan_t yyscanner); /* Copy the second part of user declarations. */ -#line 277 "cmFortranParser.cxx" /* yacc.c:358 */ +#line 272 "cmFortranParser.cxx" /* yacc.c:358 */ #ifdef short # undef short @@ -565,13 +569,13 @@ static const yytype_uint8 yytranslate[] = /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_uint8 yyrline[] = { - 0, 103, 103, 103, 106, 110, 115, 124, 130, 137, - 142, 146, 151, 159, 164, 169, 174, 179, 184, 189, - 194, 199, 203, 207, 211, 215, 216, 221, 221, 221, - 222, 222, 223, 223, 224, 224, 225, 225, 226, 226, - 227, 227, 228, 228, 229, 229, 230, 230, 233, 234, - 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, - 245, 246, 247, 248 + 0, 98, 98, 98, 101, 105, 110, 119, 125, 132, + 137, 141, 146, 154, 159, 164, 169, 174, 179, 184, + 189, 194, 198, 202, 206, 210, 211, 216, 216, 216, + 217, 217, 218, 218, 219, 219, 220, 220, 221, 221, + 222, 222, 223, 223, 224, 224, 225, 225, 228, 229, + 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, + 240, 241, 242, 243 }; #endif @@ -1523,26 +1527,26 @@ yyreduce: switch (yyn) { case 4: -#line 106 "cmFortranParser.y" /* yacc.c:1646 */ +#line 101 "cmFortranParser.y" /* yacc.c:1646 */ { cmFortranParser* parser = cmFortran_yyget_extra(yyscanner); cmFortranParser_SetInInterface(parser, true); } -#line 1541 "cmFortranParser.cxx" /* yacc.c:1646 */ +#line 1536 "cmFortranParser.cxx" /* yacc.c:1646 */ break; case 5: -#line 110 "cmFortranParser.y" /* yacc.c:1646 */ +#line 105 "cmFortranParser.y" /* yacc.c:1646 */ { cmFortranParser* parser = cmFortran_yyget_extra(yyscanner); cmFortranParser_RuleUse(parser, (yyvsp[-2].string)); free((yyvsp[-2].string)); } -#line 1551 "cmFortranParser.cxx" /* yacc.c:1646 */ +#line 1546 "cmFortranParser.cxx" /* yacc.c:1646 */ break; case 6: -#line 115 "cmFortranParser.y" /* yacc.c:1646 */ +#line 110 "cmFortranParser.y" /* yacc.c:1646 */ { cmFortranParser* parser = cmFortran_yyget_extra(yyscanner); if (cmsysString_strcasecmp((yyvsp[-2].string), "function") != 0 && @@ -1552,22 +1556,22 @@ yyreduce: } free((yyvsp[-2].string)); } -#line 1565 "cmFortranParser.cxx" /* yacc.c:1646 */ +#line 1560 "cmFortranParser.cxx" /* yacc.c:1646 */ break; case 7: -#line 124 "cmFortranParser.y" /* yacc.c:1646 */ +#line 119 "cmFortranParser.y" /* yacc.c:1646 */ { cmFortranParser* parser = cmFortran_yyget_extra(yyscanner); cmFortranParser_RuleUse(parser, (yyvsp[-4].string)); free((yyvsp[-4].string)); free((yyvsp[-2].string)); } -#line 1576 "cmFortranParser.cxx" /* yacc.c:1646 */ +#line 1571 "cmFortranParser.cxx" /* yacc.c:1646 */ break; case 8: -#line 130 "cmFortranParser.y" /* yacc.c:1646 */ +#line 125 "cmFortranParser.y" /* yacc.c:1646 */ { cmFortranParser* parser = cmFortran_yyget_extra(yyscanner); cmFortranParser_RuleUse(parser, (yyvsp[-6].string)); @@ -1575,40 +1579,40 @@ yyreduce: free((yyvsp[-4].string)); free((yyvsp[-2].string)); } -#line 1588 "cmFortranParser.cxx" /* yacc.c:1646 */ +#line 1583 "cmFortranParser.cxx" /* yacc.c:1646 */ break; case 9: -#line 137 "cmFortranParser.y" /* yacc.c:1646 */ +#line 132 "cmFortranParser.y" /* yacc.c:1646 */ { cmFortranParser* parser = cmFortran_yyget_extra(yyscanner); cmFortranParser_SetInInterface(parser, true); free((yyvsp[-2].string)); } -#line 1598 "cmFortranParser.cxx" /* yacc.c:1646 */ +#line 1593 "cmFortranParser.cxx" /* yacc.c:1646 */ break; case 10: -#line 142 "cmFortranParser.y" /* yacc.c:1646 */ +#line 137 "cmFortranParser.y" /* yacc.c:1646 */ { cmFortranParser* parser = cmFortran_yyget_extra(yyscanner); cmFortranParser_SetInInterface(parser, false); } -#line 1607 "cmFortranParser.cxx" /* yacc.c:1646 */ +#line 1602 "cmFortranParser.cxx" /* yacc.c:1646 */ break; case 11: -#line 146 "cmFortranParser.y" /* yacc.c:1646 */ +#line 141 "cmFortranParser.y" /* yacc.c:1646 */ { cmFortranParser* parser = cmFortran_yyget_extra(yyscanner); cmFortranParser_RuleUse(parser, (yyvsp[-2].string)); free((yyvsp[-2].string)); } -#line 1617 "cmFortranParser.cxx" /* yacc.c:1646 */ +#line 1612 "cmFortranParser.cxx" /* yacc.c:1646 */ break; case 12: -#line 151 "cmFortranParser.y" /* yacc.c:1646 */ +#line 146 "cmFortranParser.y" /* yacc.c:1646 */ { if (cmsysString_strcasecmp((yyvsp[-4].string), "non_intrinsic") == 0) { cmFortranParser* parser = cmFortran_yyget_extra(yyscanner); @@ -1617,139 +1621,139 @@ yyreduce: free((yyvsp[-4].string)); free((yyvsp[-2].string)); } -#line 1630 "cmFortranParser.cxx" /* yacc.c:1646 */ +#line 1625 "cmFortranParser.cxx" /* yacc.c:1646 */ break; case 13: -#line 159 "cmFortranParser.y" /* yacc.c:1646 */ +#line 154 "cmFortranParser.y" /* yacc.c:1646 */ { cmFortranParser* parser = cmFortran_yyget_extra(yyscanner); cmFortranParser_RuleInclude(parser, (yyvsp[-2].string)); free((yyvsp[-2].string)); } -#line 1640 "cmFortranParser.cxx" /* yacc.c:1646 */ +#line 1635 "cmFortranParser.cxx" /* yacc.c:1646 */ break; case 14: -#line 164 "cmFortranParser.y" /* yacc.c:1646 */ +#line 159 "cmFortranParser.y" /* yacc.c:1646 */ { cmFortranParser* parser = cmFortran_yyget_extra(yyscanner); cmFortranParser_RuleLineDirective(parser, (yyvsp[-2].string)); free((yyvsp[-2].string)); } -#line 1650 "cmFortranParser.cxx" /* yacc.c:1646 */ +#line 1645 "cmFortranParser.cxx" /* yacc.c:1646 */ break; case 15: -#line 169 "cmFortranParser.y" /* yacc.c:1646 */ +#line 164 "cmFortranParser.y" /* yacc.c:1646 */ { cmFortranParser* parser = cmFortran_yyget_extra(yyscanner); cmFortranParser_RuleInclude(parser, (yyvsp[-2].string)); free((yyvsp[-2].string)); } -#line 1660 "cmFortranParser.cxx" /* yacc.c:1646 */ +#line 1655 "cmFortranParser.cxx" /* yacc.c:1646 */ break; case 16: -#line 174 "cmFortranParser.y" /* yacc.c:1646 */ +#line 169 "cmFortranParser.y" /* yacc.c:1646 */ { cmFortranParser* parser = cmFortran_yyget_extra(yyscanner); cmFortranParser_RuleInclude(parser, (yyvsp[-2].string)); free((yyvsp[-2].string)); } -#line 1670 "cmFortranParser.cxx" /* yacc.c:1646 */ +#line 1665 "cmFortranParser.cxx" /* yacc.c:1646 */ break; case 17: -#line 179 "cmFortranParser.y" /* yacc.c:1646 */ +#line 174 "cmFortranParser.y" /* yacc.c:1646 */ { cmFortranParser* parser = cmFortran_yyget_extra(yyscanner); cmFortranParser_RuleDefine(parser, (yyvsp[-2].string)); free((yyvsp[-2].string)); } -#line 1680 "cmFortranParser.cxx" /* yacc.c:1646 */ +#line 1675 "cmFortranParser.cxx" /* yacc.c:1646 */ break; case 18: -#line 184 "cmFortranParser.y" /* yacc.c:1646 */ +#line 179 "cmFortranParser.y" /* yacc.c:1646 */ { cmFortranParser* parser = cmFortran_yyget_extra(yyscanner); cmFortranParser_RuleUndef(parser, (yyvsp[-2].string)); free((yyvsp[-2].string)); } -#line 1690 "cmFortranParser.cxx" /* yacc.c:1646 */ +#line 1685 "cmFortranParser.cxx" /* yacc.c:1646 */ break; case 19: -#line 189 "cmFortranParser.y" /* yacc.c:1646 */ +#line 184 "cmFortranParser.y" /* yacc.c:1646 */ { cmFortranParser* parser = cmFortran_yyget_extra(yyscanner); cmFortranParser_RuleIfdef(parser, (yyvsp[-2].string)); free((yyvsp[-2].string)); } -#line 1700 "cmFortranParser.cxx" /* yacc.c:1646 */ +#line 1695 "cmFortranParser.cxx" /* yacc.c:1646 */ break; case 20: -#line 194 "cmFortranParser.y" /* yacc.c:1646 */ +#line 189 "cmFortranParser.y" /* yacc.c:1646 */ { cmFortranParser* parser = cmFortran_yyget_extra(yyscanner); cmFortranParser_RuleIfndef(parser, (yyvsp[-2].string)); free((yyvsp[-2].string)); } -#line 1710 "cmFortranParser.cxx" /* yacc.c:1646 */ +#line 1705 "cmFortranParser.cxx" /* yacc.c:1646 */ break; case 21: -#line 199 "cmFortranParser.y" /* yacc.c:1646 */ +#line 194 "cmFortranParser.y" /* yacc.c:1646 */ { cmFortranParser* parser = cmFortran_yyget_extra(yyscanner); cmFortranParser_RuleIf(parser); } -#line 1719 "cmFortranParser.cxx" /* yacc.c:1646 */ +#line 1714 "cmFortranParser.cxx" /* yacc.c:1646 */ break; case 22: -#line 203 "cmFortranParser.y" /* yacc.c:1646 */ +#line 198 "cmFortranParser.y" /* yacc.c:1646 */ { cmFortranParser* parser = cmFortran_yyget_extra(yyscanner); cmFortranParser_RuleElif(parser); } -#line 1728 "cmFortranParser.cxx" /* yacc.c:1646 */ +#line 1723 "cmFortranParser.cxx" /* yacc.c:1646 */ break; case 23: -#line 207 "cmFortranParser.y" /* yacc.c:1646 */ +#line 202 "cmFortranParser.y" /* yacc.c:1646 */ { cmFortranParser* parser = cmFortran_yyget_extra(yyscanner); cmFortranParser_RuleElse(parser); } -#line 1737 "cmFortranParser.cxx" /* yacc.c:1646 */ +#line 1732 "cmFortranParser.cxx" /* yacc.c:1646 */ break; case 24: -#line 211 "cmFortranParser.y" /* yacc.c:1646 */ +#line 206 "cmFortranParser.y" /* yacc.c:1646 */ { cmFortranParser* parser = cmFortran_yyget_extra(yyscanner); cmFortranParser_RuleEndif(parser); } -#line 1746 "cmFortranParser.cxx" /* yacc.c:1646 */ +#line 1741 "cmFortranParser.cxx" /* yacc.c:1646 */ break; case 48: -#line 233 "cmFortranParser.y" /* yacc.c:1646 */ +#line 228 "cmFortranParser.y" /* yacc.c:1646 */ { free ((yyvsp[0].string)); } -#line 1752 "cmFortranParser.cxx" /* yacc.c:1646 */ +#line 1747 "cmFortranParser.cxx" /* yacc.c:1646 */ break; case 55: -#line 240 "cmFortranParser.y" /* yacc.c:1646 */ +#line 235 "cmFortranParser.y" /* yacc.c:1646 */ { free ((yyvsp[0].string)); } -#line 1758 "cmFortranParser.cxx" /* yacc.c:1646 */ +#line 1753 "cmFortranParser.cxx" /* yacc.c:1646 */ break; -#line 1762 "cmFortranParser.cxx" /* yacc.c:1646 */ +#line 1757 "cmFortranParser.cxx" /* yacc.c:1646 */ default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -1979,6 +1983,6 @@ yyreturn: #endif return yyresult; } -#line 251 "cmFortranParser.y" /* yacc.c:1906 */ +#line 246 "cmFortranParser.y" /* yacc.c:1906 */ /* End of grammar */ diff --git a/Source/cmFortranParser.h b/Source/cmFortranParser.h index 06985d2..d8b0023 100644 --- a/Source/cmFortranParser.h +++ b/Source/cmFortranParser.h @@ -4,9 +4,11 @@ #define cmFortranParser_h #if !defined(cmFortranLexer_cxx) && !defined(cmFortranParser_cxx) -#include <cmConfigure.h> +#include "cmConfigure.h" -#include "cmStandardIncludes.h" +#include <set> +#include <string> +#include <vector> #endif #include <stddef.h> /* size_t */ @@ -52,8 +54,7 @@ void cmFortranParser_RuleElse(cmFortranParser* parser); void cmFortranParser_RuleEndif(cmFortranParser* parser); /* Define the parser stack element type. */ -typedef union cmFortran_yystype_u cmFortran_yystype; -union cmFortran_yystype_u +struct cmFortran_yystype { char* string; }; diff --git a/Source/cmFortranParser.y b/Source/cmFortranParser.y index 7eb5ef5..acfb40a 100644 --- a/Source/cmFortranParser.y +++ b/Source/cmFortranParser.y @@ -26,13 +26,17 @@ Modify cmFortranParser.cxx: - "#if 0" out yyerrorlab block in range ["goto yyerrlab1", "yyerrlab1:"] */ +#include "cmConfigure.h" // IWYU pragma: keep + +#include "cmsys/String.h" +#include <stdlib.h> +#include <string.h> + /*-------------------------------------------------------------------------*/ #define cmFortranParser_cxx #include "cmFortranParser.h" /* Interface to parser object. */ #include "cmFortranParserTokens.h" /* Need YYSTYPE for YY_DECL. */ -#include <cmsys/String.h> - /* Forward declare the lexer entry point. */ YY_DECL; diff --git a/Source/cmFortranParserImpl.cxx b/Source/cmFortranParserImpl.cxx index 1a5e6c5..4e23f36 100644 --- a/Source/cmFortranParserImpl.cxx +++ b/Source/cmFortranParserImpl.cxx @@ -1,11 +1,10 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmFortranParser.h" -#include "cmFortranLexer.h" #include "cmSystemTools.h" +#include "cmConfigure.h" #include <assert.h> -#include <cmConfigure.h> #include <set> #include <stack> #include <stdio.h> diff --git a/Source/cmFortranParserTokens.h b/Source/cmFortranParserTokens.h index 18b9e0a..8d6a5fe 100644 --- a/Source/cmFortranParserTokens.h +++ b/Source/cmFortranParserTokens.h @@ -130,7 +130,7 @@ extern int cmFortran_yydebug; union YYSTYPE { -#line 75 "cmFortranParser.y" /* yacc.c:1909 */ +#line 70 "cmFortranParser.y" /* yacc.c:1909 */ char* string; diff --git a/Source/cmFunctionCommand.h b/Source/cmFunctionCommand.h index afea6f9..d6cc18e 100644 --- a/Source/cmFunctionCommand.h +++ b/Source/cmFunctionCommand.h @@ -3,7 +3,8 @@ #ifndef cmFunctionCommand_h #define cmFunctionCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmGeneratedFileStream.cxx b/Source/cmGeneratedFileStream.cxx index 4731493..6aa593c 100644 --- a/Source/cmGeneratedFileStream.cxx +++ b/Source/cmGeneratedFileStream.cxx @@ -8,7 +8,7 @@ #if defined(CMAKE_BUILD_WITH_CMAKE) #include "cm_codecvt.hxx" -#include <cm_zlib.h> +#include "cm_zlib.h" #endif cmGeneratedFileStream::cmGeneratedFileStream(Encoding encoding) diff --git a/Source/cmGeneratedFileStream.h b/Source/cmGeneratedFileStream.h index a027b01..56f9988 100644 --- a/Source/cmGeneratedFileStream.h +++ b/Source/cmGeneratedFileStream.h @@ -3,10 +3,10 @@ #ifndef cmGeneratedFileStream_h #define cmGeneratedFileStream_h -#include <cmConfigure.h> +#include "cmConfigure.h" -#include <cm_codecvt.hxx> -#include <cmsys/FStream.hxx> +#include "cm_codecvt.hxx" +#include "cmsys/FStream.hxx" #include <string> // This is the first base class of cmGeneratedFileStream. It will be diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index e70bbfe..570aa6e 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmGeneratorExpression.h" -#include <cmsys/RegularExpression.hxx> +#include "cmsys/RegularExpression.hxx" #include <utility> #include "assert.h" diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h index 8f82a6b..694ce8a 100644 --- a/Source/cmGeneratorExpression.h +++ b/Source/cmGeneratorExpression.h @@ -3,11 +3,11 @@ #ifndef cmGeneratorExpression_h #define cmGeneratorExpression_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmListFileCache.h" -#include <cm_auto_ptr.hxx> +#include "cm_auto_ptr.hxx" #include <map> #include <set> #include <string> diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h index 8f10259..557a192 100644 --- a/Source/cmGeneratorExpressionDAGChecker.h +++ b/Source/cmGeneratorExpressionDAGChecker.h @@ -3,7 +3,7 @@ #ifndef cmGeneratorExpressionDAGChecker_h #define cmGeneratorExpressionDAGChecker_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmListFileCache.h" diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx index aeb005f..1526454 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.cxx +++ b/Source/cmGeneratorExpressionEvaluationFile.cxx @@ -2,8 +2,8 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmGeneratorExpressionEvaluationFile.h" -#include <cmConfigure.h> -#include <cmsys/FStream.hxx> +#include "cmConfigure.h" +#include "cmsys/FStream.hxx" #include <sstream> #include <utility> @@ -64,8 +64,10 @@ void cmGeneratorExpressionEvaluationFile::Generate( return; } std::ostringstream e; - e << "Evaluation file to be written multiple times for different " - "configurations or languages with different content:\n " + e << "Evaluation file to be written multiple times with different " + "content. " + "This is generally caused by the content evaluating the " + "configuration type, language, or location of object files:\n " << outputFileName; lg->IssueMessage(cmake::FATAL_ERROR, e.str()); return; diff --git a/Source/cmGeneratorExpressionEvaluationFile.h b/Source/cmGeneratorExpressionEvaluationFile.h index 26135df..9872746 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.h +++ b/Source/cmGeneratorExpressionEvaluationFile.h @@ -3,7 +3,7 @@ #ifndef cmGeneratorExpressionEvaluationFile_h #define cmGeneratorExpressionEvaluationFile_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <map> #include <string> @@ -11,12 +11,7 @@ #include "cmGeneratorExpression.h" #include "cm_auto_ptr.hxx" - -#if defined(_MSC_VER) -typedef unsigned short mode_t; -#else -#include <sys/types.h> -#endif +#include "cm_sys_stat.h" class cmLocalGenerator; diff --git a/Source/cmGeneratorExpressionEvaluator.h b/Source/cmGeneratorExpressionEvaluator.h index 41bea9b..a6a341b 100644 --- a/Source/cmGeneratorExpressionEvaluator.h +++ b/Source/cmGeneratorExpressionEvaluator.h @@ -3,7 +3,7 @@ #ifndef cmGeneratorExpressionEvaluator_h #define cmGeneratorExpressionEvaluator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <stddef.h> #include <string> diff --git a/Source/cmGeneratorExpressionLexer.h b/Source/cmGeneratorExpressionLexer.h index cac255d..e53f0b5 100644 --- a/Source/cmGeneratorExpressionLexer.h +++ b/Source/cmGeneratorExpressionLexer.h @@ -3,7 +3,7 @@ #ifndef cmGeneratorExpressionLexer_h #define cmGeneratorExpressionLexer_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <stddef.h> #include <string> diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 66202df..e065a74 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -14,18 +14,17 @@ #include "cmMakefile.h" #include "cmOutputConverter.h" #include "cmPolicies.h" -#include "cmSourceFile.h" #include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmTarget.h" #include "cm_auto_ptr.hxx" #include "cmake.h" +#include "cmConfigure.h" +#include "cmsys/RegularExpression.hxx" +#include "cmsys/String.h" #include <algorithm> #include <assert.h> -#include <cmConfigure.h> -#include <cmsys/RegularExpression.hxx> -#include <cmsys/String.h> #include <errno.h> #include <map> #include <set> @@ -1227,15 +1226,6 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode cmGeneratorExpressionDAGChecker* /*dagChecker*/) const CM_OVERRIDE { - if (!context->EvaluateForBuildsystem) { - std::ostringstream e; - e << "The evaluation of the TARGET_OBJECTS generator expression " - "is only suitable for consumption by CMake. It is not suitable " - "for writing out elsewhere."; - reportError(context, content->GetOriginalExpression(), e.str()); - return std::string(); - } - std::string tgtName = parameters.front(); cmGeneratorTarget* gt = context->LG->FindGeneratorTargetToUse(tgtName); if (!gt) { @@ -1252,40 +1242,60 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode reportError(context, content->GetOriginalExpression(), e.str()); return std::string(); } + if (!context->EvaluateForBuildsystem) { + cmGlobalGenerator* gg = context->LG->GetGlobalGenerator(); + std::string reason; + if (!gg->HasKnownObjectFileLocation(&reason)) { + std::ostringstream e; + e << "The evaluation of the TARGET_OBJECTS generator expression " + "is only suitable for consumption by CMake (limited" + << reason << "). " + "It is not suitable for writing out elsewhere."; + reportError(context, content->GetOriginalExpression(), e.str()); + return std::string(); + } + } - std::vector<cmSourceFile const*> objectSources; - gt->GetObjectSources(objectSources, context->Config); - std::map<cmSourceFile const*, std::string> mapping; - - for (std::vector<cmSourceFile const*>::const_iterator it = - objectSources.begin(); - it != objectSources.end(); ++it) { - mapping[*it]; - } - - gt->LocalGenerator->ComputeObjectFilenames(mapping, gt); - - std::string obj_dir = gt->ObjectDirectory; - std::string result; - const char* sep = ""; - for (std::vector<cmSourceFile const*>::const_iterator it = - objectSources.begin(); - it != objectSources.end(); ++it) { - // Find the object file name corresponding to this source file. - std::map<cmSourceFile const*, std::string>::const_iterator map_it = - mapping.find(*it); - // It must exist because we populated the mapping just above. - assert(!map_it->second.empty()); - result += sep; - std::string objFile = obj_dir + map_it->second; - cmSourceFile* sf = - context->LG->GetMakefile()->GetOrCreateSource(objFile, true); - sf->SetObjectLibrary(tgtName); - sf->SetProperty("EXTERNAL_OBJECT", "1"); - result += objFile; - sep = ";"; + std::vector<std::string> objects; + + if (gt->IsImported()) { + const char* loc = CM_NULLPTR; + const char* imp = CM_NULLPTR; + std::string suffix; + if (gt->Target->GetMappedConfig(context->Config, &loc, &imp, suffix)) { + cmSystemTools::ExpandListArgument(loc, objects); + } + context->HadContextSensitiveCondition = true; + } else { + gt->GetTargetObjectNames(context->Config, objects); + + std::string obj_dir; + if (context->EvaluateForBuildsystem) { + // Use object file directory with buildsystem placeholder. + obj_dir = gt->ObjectDirectory; + // Here we assume that the set of object files produced + // by an object library does not vary with configuration + // and do not set HadContextSensitiveCondition to true. + } else { + // Use object file directory with per-config location. + obj_dir = gt->GetObjectDirectory(context->Config); + context->HadContextSensitiveCondition = true; + } + + for (std::vector<std::string>::iterator oi = objects.begin(); + oi != objects.end(); ++oi) { + *oi = obj_dir + *oi; + } } - return result; + + // Create the cmSourceFile instances in the referencing directory. + cmMakefile* mf = context->LG->GetMakefile(); + for (std::vector<std::string>::iterator oi = objects.begin(); + oi != objects.end(); ++oi) { + mf->AddTargetObject(tgtName, *oi); + } + + return cmJoin(objects, ";"); } } targetObjectsNode; @@ -1504,6 +1514,8 @@ class ArtifactNameTag; class ArtifactPathTag; class ArtifactPdbTag; class ArtifactSonameTag; +class ArtifactBundleDirTag; +class ArtifactBundleContentDirTag; template <typename ArtifactT> struct TargetFilesystemArtifactResultCreator @@ -1595,7 +1607,60 @@ struct TargetFilesystemArtifactResultCreator<ArtifactLinkerTag> "executables with ENABLE_EXPORTS."); return std::string(); } - return target->GetFullPath(context->Config, target->HasImportLibrary()); + cmStateEnums::ArtifactType artifact = target->HasImportLibrary() + ? cmStateEnums::ImportLibraryArtifact + : cmStateEnums::RuntimeBinaryArtifact; + return target->GetFullPath(context->Config, artifact); + } +}; + +template <> +struct TargetFilesystemArtifactResultCreator<ArtifactBundleDirTag> +{ + static std::string Create(cmGeneratorTarget* target, + cmGeneratorExpressionContext* context, + const GeneratorExpressionContent* content) + { + if (target->IsImported()) { + ::reportError(context, content->GetOriginalExpression(), + "TARGET_BUNDLE_DIR not allowed for IMPORTED targets."); + return std::string(); + } + if (!target->IsBundleOnApple()) { + ::reportError(context, content->GetOriginalExpression(), + "TARGET_BUNDLE_DIR is allowed only for Bundle targets."); + return std::string(); + } + + std::string outpath = target->GetDirectory(context->Config) + '/'; + return target->BuildBundleDirectory(outpath, context->Config, + cmGeneratorTarget::BundleDirLevel); + } +}; + +template <> +struct TargetFilesystemArtifactResultCreator<ArtifactBundleContentDirTag> +{ + static std::string Create(cmGeneratorTarget* target, + cmGeneratorExpressionContext* context, + const GeneratorExpressionContent* content) + { + if (target->IsImported()) { + ::reportError( + context, content->GetOriginalExpression(), + "TARGET_BUNDLE_CONTENT_DIR not allowed for IMPORTED targets."); + return std::string(); + } + if (!target->IsBundleOnApple()) { + ::reportError( + context, content->GetOriginalExpression(), + "TARGET_BUNDLE_CONTENT_DIR is allowed only for Bundle targets."); + return std::string(); + } + + std::string outpath = target->GetDirectory(context->Config) + '/'; + return target->BuildBundleDirectory(outpath, context->Config, + cmGeneratorTarget::ContentLevel); } }; @@ -1606,7 +1671,8 @@ struct TargetFilesystemArtifactResultCreator<ArtifactNameTag> cmGeneratorExpressionContext* context, const GeneratorExpressionContent* /*unused*/) { - return target->GetFullPath(context->Config, false, true); + return target->GetFullPath(context->Config, + cmStateEnums::RuntimeBinaryArtifact, true); } }; @@ -1716,6 +1782,13 @@ static const TargetFilesystemArtifactNodeGroup<ArtifactSonameTag> static const TargetFilesystemArtifactNodeGroup<ArtifactPdbTag> targetPdbNodeGroup; +static const TargetFilesystemArtifact<ArtifactBundleDirTag, ArtifactPathTag> + targetBundleDirNode; + +static const TargetFilesystemArtifact<ArtifactBundleContentDirTag, + ArtifactPathTag> + targetBundleContentDirNode; + static const struct ShellPathNode : public cmGeneratorExpressionNode { ShellPathNode() {} @@ -1772,6 +1845,8 @@ const cmGeneratorExpressionNode* cmGeneratorExpressionNode::GetNode( nodeMap["TARGET_LINKER_FILE_DIR"] = &targetLinkerNodeGroup.FileDir; nodeMap["TARGET_SONAME_FILE_DIR"] = &targetSoNameNodeGroup.FileDir; nodeMap["TARGET_PDB_FILE_DIR"] = &targetPdbNodeGroup.FileDir; + nodeMap["TARGET_BUNDLE_DIR"] = &targetBundleDirNode; + nodeMap["TARGET_BUNDLE_CONTENT_DIR"] = &targetBundleContentDirNode; nodeMap["STREQUAL"] = &strEqualNode; nodeMap["EQUAL"] = &equalNode; nodeMap["LOWER_CASE"] = &lowerCaseNode; diff --git a/Source/cmGeneratorExpressionNode.h b/Source/cmGeneratorExpressionNode.h index ecf745e..ece1c11 100644 --- a/Source/cmGeneratorExpressionNode.h +++ b/Source/cmGeneratorExpressionNode.h @@ -3,7 +3,7 @@ #ifndef cmGeneratorExpressionNode_h #define cmGeneratorExpressionNode_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmGeneratorExpressionParser.h b/Source/cmGeneratorExpressionParser.h index e30cb20..633381c 100644 --- a/Source/cmGeneratorExpressionParser.h +++ b/Source/cmGeneratorExpressionParser.h @@ -3,7 +3,7 @@ #ifndef cmGeneratorExpressionParser_h #define cmGeneratorExpressionParser_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <vector> diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 3fe5c83..a0f677b 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -2,9 +2,9 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmGeneratorTarget.h" +#include "cmsys/RegularExpression.hxx" #include <algorithm> #include <assert.h> -#include <cmsys/RegularExpression.hxx> #include <errno.h> #include <iterator> #include <queue> @@ -75,197 +75,6 @@ public: }; cmLinkImplItem cmGeneratorTarget::TargetPropertyEntry::NoLinkImplItem; -void reportBadObjLib(std::vector<cmSourceFile*> const& badObjLib, - cmGeneratorTarget const* target, cmake* cm) -{ - if (!badObjLib.empty()) { - std::ostringstream e; - e << "OBJECT library \"" << target->GetName() << "\" contains:\n"; - for (std::vector<cmSourceFile*>::const_iterator i = badObjLib.begin(); - i != badObjLib.end(); ++i) { - e << " " << (*i)->GetLocation().GetName() << "\n"; - } - e << "but may contain only sources that compile, header files, and " - "other files that would not affect linking of a normal library."; - cm->IssueMessage(cmake::FATAL_ERROR, e.str(), target->GetBacktrace()); - } -} - -struct ObjectSourcesTag -{ -}; -struct CustomCommandsTag -{ -}; -struct ExtraSourcesTag -{ -}; -struct HeaderSourcesTag -{ -}; -struct ExternalObjectsTag -{ -}; -struct IDLSourcesTag -{ -}; -struct ResxTag -{ -}; -struct ModuleDefinitionFileTag -{ -}; -struct AppManifestTag -{ -}; -struct ManifestsTag -{ -}; -struct CertificatesTag -{ -}; -struct XamlTag -{ -}; - -template <typename Tag, typename OtherTag> -struct IsSameTag -{ - enum - { - Result = false - }; -}; - -template <typename Tag> -struct IsSameTag<Tag, Tag> -{ - enum - { - Result = true - }; -}; - -template <bool> -struct DoAccept -{ - template <typename T> - static void Do(T& /*unused*/, cmSourceFile* /*unused*/) - { - } -}; - -template <> -struct DoAccept<true> -{ - static void Do(std::vector<cmSourceFile const*>& files, cmSourceFile* f) - { - files.push_back(f); - } - static void Do(cmGeneratorTarget::ResxData& data, cmSourceFile* f) - { - // Build and save the name of the corresponding .h file - // This relationship will be used later when building the project files. - // Both names would have been auto generated from Visual Studio - // where the user supplied the file name and Visual Studio - // appended the suffix. - std::string resx = f->GetFullPath(); - std::string hFileName = resx.substr(0, resx.find_last_of('.')) + ".h"; - data.ExpectedResxHeaders.insert(hFileName); - data.ResxSources.push_back(f); - } - static void Do(cmGeneratorTarget::XamlData& data, cmSourceFile* f) - { - // Build and save the name of the corresponding .h and .cpp file - // This relationship will be used later when building the project files. - // Both names would have been auto generated from Visual Studio - // where the user supplied the file name and Visual Studio - // appended the suffix. - std::string xaml = f->GetFullPath(); - std::string hFileName = xaml + ".h"; - std::string cppFileName = xaml + ".cpp"; - data.ExpectedXamlHeaders.insert(hFileName); - data.ExpectedXamlSources.insert(cppFileName); - data.XamlSources.push_back(f); - } - static void Do(std::string& data, cmSourceFile* f) - { - data = f->GetFullPath(); - } -}; - -template <typename Tag, typename DataType = std::vector<cmSourceFile const*> > -struct TagVisitor -{ - DataType& Data; - std::vector<cmSourceFile*> BadObjLibFiles; - cmGeneratorTarget const* Target; - cmGlobalGenerator* GlobalGenerator; - cmsys::RegularExpression Header; - bool IsObjLib; - - TagVisitor(cmGeneratorTarget const* target, DataType& data) - : Data(data) - , Target(target) - , GlobalGenerator(target->GetLocalGenerator()->GetGlobalGenerator()) - , Header(CM_HEADER_REGEX) - , IsObjLib(target->GetType() == cmStateEnums::OBJECT_LIBRARY) - { - } - - ~TagVisitor() - { - reportBadObjLib(this->BadObjLibFiles, this->Target, - this->GlobalGenerator->GetCMakeInstance()); - } - - void Accept(cmSourceFile* sf) - { - std::string ext = cmSystemTools::LowerCase(sf->GetExtension()); - if (sf->GetCustomCommand()) { - DoAccept<IsSameTag<Tag, CustomCommandsTag>::Result>::Do(this->Data, sf); - } else if (this->Target->GetType() == cmStateEnums::UTILITY) { - DoAccept<IsSameTag<Tag, ExtraSourcesTag>::Result>::Do(this->Data, sf); - } else if (sf->GetPropertyAsBool("HEADER_FILE_ONLY")) { - DoAccept<IsSameTag<Tag, HeaderSourcesTag>::Result>::Do(this->Data, sf); - } else if (sf->GetPropertyAsBool("EXTERNAL_OBJECT")) { - DoAccept<IsSameTag<Tag, ExternalObjectsTag>::Result>::Do(this->Data, sf); - if (this->IsObjLib) { - this->BadObjLibFiles.push_back(sf); - } - } else if (!sf->GetLanguage().empty()) { - DoAccept<IsSameTag<Tag, ObjectSourcesTag>::Result>::Do(this->Data, sf); - } else if (ext == "def") { - DoAccept<IsSameTag<Tag, ModuleDefinitionFileTag>::Result>::Do(this->Data, - sf); - if (this->IsObjLib) { - this->BadObjLibFiles.push_back(sf); - } - } else if (ext == "idl") { - DoAccept<IsSameTag<Tag, IDLSourcesTag>::Result>::Do(this->Data, sf); - if (this->IsObjLib) { - this->BadObjLibFiles.push_back(sf); - } - } else if (ext == "resx") { - DoAccept<IsSameTag<Tag, ResxTag>::Result>::Do(this->Data, sf); - } else if (ext == "appxmanifest") { - DoAccept<IsSameTag<Tag, AppManifestTag>::Result>::Do(this->Data, sf); - } else if (ext == "manifest") { - DoAccept<IsSameTag<Tag, ManifestsTag>::Result>::Do(this->Data, sf); - } else if (ext == "pfx") { - DoAccept<IsSameTag<Tag, CertificatesTag>::Result>::Do(this->Data, sf); - } else if (ext == "xaml") { - DoAccept<IsSameTag<Tag, XamlTag>::Result>::Do(this->Data, sf); - } else if (this->Header.find(sf->GetFullPath().c_str())) { - DoAccept<IsSameTag<Tag, HeaderSourcesTag>::Result>::Do(this->Data, sf); - } else if (this->GlobalGenerator->IgnoreFile(sf->GetExtension().c_str())) { - DoAccept<IsSameTag<Tag, ExtraSourcesTag>::Result>::Do(this->Data, sf); - } else { - DoAccept<IsSameTag<Tag, ExtraSourcesTag>::Result>::Do(this->Data, sf); - } - } -}; - void CreatePropertyGeneratorExpressions( cmStringRange const& entries, cmBacktraceRange const& backtraces, std::vector<cmGeneratorTarget::TargetPropertyEntry*>& items, @@ -286,6 +95,7 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) , FortranModuleDirectoryCreated(false) , SourceFileFlagsConstructed(false) , PolicyWarnedCMP0022(false) + , PolicyReportedCMP0069(false) , DebugIncludesDone(false) , DebugCompileOptionsDone(false) , DebugCompileFeaturesDone(false) @@ -406,52 +216,60 @@ const char* cmGeneratorTarget::GetProperty(const std::string& prop) const return this->Target->GetProperty(prop); } -const char* cmGeneratorTarget::GetOutputTargetType(bool implib) const +const char* cmGeneratorTarget::GetOutputTargetType( + cmStateEnums::ArtifactType artifact) const { switch (this->GetType()) { case cmStateEnums::SHARED_LIBRARY: if (this->IsDLLPlatform()) { - if (implib) { - // A DLL import library is treated as an archive target. - return "ARCHIVE"; + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + // A DLL shared library is treated as a runtime target. + return "RUNTIME"; + case cmStateEnums::ImportLibraryArtifact: + // A DLL import library is treated as an archive target. + return "ARCHIVE"; } - // A DLL shared library is treated as a runtime target. - return "RUNTIME"; } else { // For non-DLL platforms shared libraries are treated as // library targets. return "LIBRARY"; } + break; case cmStateEnums::STATIC_LIBRARY: // Static libraries are always treated as archive targets. return "ARCHIVE"; case cmStateEnums::MODULE_LIBRARY: - if (implib) { - // Module libraries are always treated as library targets. - return "ARCHIVE"; - } else { - // Module import libraries are treated as archive targets. - return "LIBRARY"; + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + // Module import libraries are treated as archive targets. + return "LIBRARY"; + case cmStateEnums::ImportLibraryArtifact: + // Module libraries are always treated as library targets. + return "ARCHIVE"; } + break; case cmStateEnums::EXECUTABLE: - if (implib) { - // Executable import libraries are treated as archive targets. - return "ARCHIVE"; - } else { - // Executables are always treated as runtime targets. - return "RUNTIME"; + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + // Executables are always treated as runtime targets. + return "RUNTIME"; + case cmStateEnums::ImportLibraryArtifact: + // Executable import libraries are treated as archive targets. + return "ARCHIVE"; } + break; default: break; } return ""; } -std::string cmGeneratorTarget::GetOutputName(const std::string& config, - bool implib) const +std::string cmGeneratorTarget::GetOutputName( + const std::string& config, cmStateEnums::ArtifactType artifact) const { // Lookup/compute/cache the output name for this configuration. - OutputNameKey key(config, implib); + OutputNameKey key(config, artifact); cmGeneratorTarget::OutputNameMapType::iterator i = this->OutputNameMap.find(key); if (i == this->OutputNameMap.end()) { @@ -461,7 +279,7 @@ std::string cmGeneratorTarget::GetOutputName(const std::string& config, // Compute output name. std::vector<std::string> props; - std::string type = this->GetOutputTargetType(implib); + std::string type = this->GetOutputTargetType(artifact); std::string configUpper = cmSystemTools::UpperCase(config); if (!type.empty() && !configUpper.empty()) { // <ARCHIVE|LIBRARY|RUNTIME>_OUTPUT_NAME_<CONFIG> @@ -515,7 +333,7 @@ void cmGeneratorTarget::AddSourceCommon(const std::string& src) CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(src); cge->SetEvaluateForBuildsystem(true); this->SourceEntries.push_back(new TargetPropertyEntry(cge)); - this->SourceFilesMap.clear(); + this->KindedSourcesMap.clear(); this->LinkImplementationLanguageIsContextDependent = true; } @@ -587,27 +405,22 @@ static void handleSystemIncludesDep( } /* clang-format off */ -#define IMPLEMENT_VISIT_IMPL(DATA, DATATYPE) \ +#define IMPLEMENT_VISIT(KIND) \ { \ - std::vector<cmSourceFile*> sourceFiles; \ - this->GetSourceFiles(sourceFiles, config); \ - TagVisitor< DATA##Tag DATATYPE > visitor(this, data); \ - for (std::vector<cmSourceFile*>::const_iterator si = sourceFiles.begin(); \ - si != sourceFiles.end(); ++si) { \ - visitor.Accept(*si); \ + KindedSources const& kinded = this->GetKindedSources(config); \ + for (std::vector<SourceAndKind>::const_iterator \ + si = kinded.Sources.begin(); si != kinded.Sources.end(); ++si) { \ + if (si->Kind == KIND) { \ + data.push_back(si->Source); \ + } \ } \ } /* clang-format on */ -#define IMPLEMENT_VISIT(DATA) IMPLEMENT_VISIT_IMPL(DATA, EMPTY) - -#define EMPTY -#define COMMA , - void cmGeneratorTarget::GetObjectSources( std::vector<cmSourceFile const*>& data, const std::string& config) const { - IMPLEMENT_VISIT(ObjectSources); + IMPLEMENT_VISIT(SourceKindObjectSource); if (!this->Objects.empty()) { return; @@ -656,10 +469,65 @@ const char* cmGeneratorTarget::GetFeature(const std::string& feature, return this->LocalGenerator->GetFeature(feature, config); } -bool cmGeneratorTarget::GetFeatureAsBool(const std::string& feature, - const std::string& config) const +bool cmGeneratorTarget::IsIPOEnabled(const std::string& config) const { - return cmSystemTools::IsOn(this->GetFeature(feature, config)); + const char* feature = "INTERPROCEDURAL_OPTIMIZATION"; + const bool result = cmSystemTools::IsOn(this->GetFeature(feature, config)); + + if (!result) { + // 'INTERPROCEDURAL_OPTIMIZATION' is off, no need to check policies + return false; + } + + cmPolicies::PolicyStatus cmp0069 = this->GetPolicyStatusCMP0069(); + + if (cmp0069 == cmPolicies::OLD || cmp0069 == cmPolicies::WARN) { + if (this->Makefile->IsOn("_CMAKE_IPO_LEGACY_BEHAVIOR")) { + return true; + } + if (this->PolicyReportedCMP0069) { + // problem is already reported, no need to issue a message + return false; + } + if (cmp0069 == cmPolicies::WARN) { + std::ostringstream w; + w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0069) << "\n"; + w << "INTERPROCEDURAL_OPTIMIZATION property will be ignored for target " + << "'" << this->GetName() << "'."; + this->LocalGenerator->GetCMakeInstance()->IssueMessage( + cmake::AUTHOR_WARNING, w.str(), this->GetBacktrace()); + + this->PolicyReportedCMP0069 = true; + } + return false; + } + + // Note: check consistency with messages from CheckIPOSupported + const char* message = CM_NULLPTR; + if (!this->Makefile->IsOn("_CMAKE_IPO_SUPPORTED_BY_CMAKE")) { + message = "CMake doesn't support IPO for current compiler"; + } else if (!this->Makefile->IsOn( + "_CMAKE_IPO_MAY_BE_SUPPORTED_BY_COMPILER")) { + message = "Compiler doesn't support IPO"; + } else if (!this->GlobalGenerator->IsIPOSupported()) { + message = "CMake doesn't support IPO for current generator"; + } + + if (!message) { + // No error/warning messages + return true; + } + + if (this->PolicyReportedCMP0069) { + // problem is already reported, no need to issue a message + return false; + } + + this->PolicyReportedCMP0069 = true; + + this->LocalGenerator->GetCMakeInstance()->IssueMessage( + cmake::FATAL_ERROR, message, this->GetBacktrace()); + return false; } const std::string& cmGeneratorTarget::GetObjectName(cmSourceFile const* file) @@ -668,6 +536,18 @@ const std::string& cmGeneratorTarget::GetObjectName(cmSourceFile const* file) return this->Objects[file]; } +const char* cmGeneratorTarget::GetCustomObjectExtension() const +{ + static std::string extension; + const bool has_ptx_extension = + this->GetPropertyAsBool("CUDA_PTX_COMPILATION"); + if (has_ptx_extension) { + extension = ".ptx"; + return extension.c_str(); + } + return CM_NULLPTR; +} + void cmGeneratorTarget::AddExplicitObjectName(cmSourceFile const* sf) { this->ExplicitObjectName.insert(sf); @@ -681,84 +561,79 @@ bool cmGeneratorTarget::HasExplicitObjectName(cmSourceFile const* file) const return it != this->ExplicitObjectName.end(); } -void cmGeneratorTarget::GetIDLSources(std::vector<cmSourceFile const*>& data, - const std::string& config) const +void cmGeneratorTarget::GetModuleDefinitionSources( + std::vector<cmSourceFile const*>& data, const std::string& config) const { - IMPLEMENT_VISIT(IDLSources); + IMPLEMENT_VISIT(SourceKindModuleDefinition); } void cmGeneratorTarget::GetHeaderSources( std::vector<cmSourceFile const*>& data, const std::string& config) const { - IMPLEMENT_VISIT(HeaderSources); + IMPLEMENT_VISIT(SourceKindHeader); } void cmGeneratorTarget::GetExtraSources(std::vector<cmSourceFile const*>& data, const std::string& config) const { - IMPLEMENT_VISIT(ExtraSources); + IMPLEMENT_VISIT(SourceKindExtra); } void cmGeneratorTarget::GetCustomCommands( std::vector<cmSourceFile const*>& data, const std::string& config) const { - IMPLEMENT_VISIT(CustomCommands); + IMPLEMENT_VISIT(SourceKindCustomCommand); } void cmGeneratorTarget::GetExternalObjects( std::vector<cmSourceFile const*>& data, const std::string& config) const { - IMPLEMENT_VISIT(ExternalObjects); + IMPLEMENT_VISIT(SourceKindExternalObject); } -void cmGeneratorTarget::GetExpectedResxHeaders(std::set<std::string>& srcs, +void cmGeneratorTarget::GetExpectedResxHeaders(std::set<std::string>& headers, const std::string& config) const { - ResxData data; - IMPLEMENT_VISIT_IMPL(Resx, COMMA cmGeneratorTarget::ResxData) - srcs = data.ExpectedResxHeaders; + KindedSources const& kinded = this->GetKindedSources(config); + headers = kinded.ExpectedResxHeaders; } -void cmGeneratorTarget::GetResxSources(std::vector<cmSourceFile const*>& srcs, +void cmGeneratorTarget::GetResxSources(std::vector<cmSourceFile const*>& data, const std::string& config) const { - ResxData data; - IMPLEMENT_VISIT_IMPL(Resx, COMMA cmGeneratorTarget::ResxData) - srcs = data.ResxSources; + IMPLEMENT_VISIT(SourceKindResx); } void cmGeneratorTarget::GetAppManifest(std::vector<cmSourceFile const*>& data, const std::string& config) const { - IMPLEMENT_VISIT(AppManifest); + IMPLEMENT_VISIT(SourceKindAppManifest); } void cmGeneratorTarget::GetManifests(std::vector<cmSourceFile const*>& data, const std::string& config) const { - IMPLEMENT_VISIT(Manifests); + IMPLEMENT_VISIT(SourceKindManifest); } void cmGeneratorTarget::GetCertificates(std::vector<cmSourceFile const*>& data, const std::string& config) const { - IMPLEMENT_VISIT(Certificates); + IMPLEMENT_VISIT(SourceKindCertificate); } void cmGeneratorTarget::GetExpectedXamlHeaders(std::set<std::string>& headers, const std::string& config) const { - XamlData data; - IMPLEMENT_VISIT_IMPL(Xaml, COMMA cmGeneratorTarget::XamlData) - headers = data.ExpectedXamlHeaders; + KindedSources const& kinded = this->GetKindedSources(config); + headers = kinded.ExpectedXamlHeaders; } void cmGeneratorTarget::GetExpectedXamlSources(std::set<std::string>& srcs, const std::string& config) const { - XamlData data; - IMPLEMENT_VISIT_IMPL(Xaml, COMMA cmGeneratorTarget::XamlData) - srcs = data.ExpectedXamlSources; + KindedSources const& kinded = this->GetKindedSources(config); + srcs = kinded.ExpectedXamlSources; } std::set<cmLinkItem> const& cmGeneratorTarget::GetUtilityItems() const @@ -776,21 +651,20 @@ std::set<cmLinkItem> const& cmGeneratorTarget::GetUtilityItems() const return this->UtilityItems; } -void cmGeneratorTarget::GetXamlSources(std::vector<cmSourceFile const*>& srcs, +void cmGeneratorTarget::GetXamlSources(std::vector<cmSourceFile const*>& data, const std::string& config) const { - XamlData data; - IMPLEMENT_VISIT_IMPL(Xaml, COMMA cmGeneratorTarget::XamlData) - srcs = data.XamlSources; + IMPLEMENT_VISIT(SourceKindXaml); } const char* cmGeneratorTarget::GetLocation(const std::string& config) const { static std::string location; if (this->IsImported()) { - location = this->Target->ImportedGetFullPath(config, false); + location = this->Target->ImportedGetFullPath( + config, cmStateEnums::RuntimeBinaryArtifact); } else { - location = this->GetFullPath(config, false); + location = this->GetFullPath(config, cmStateEnums::RuntimeBinaryArtifact); } return location.c_str(); } @@ -827,7 +701,8 @@ const char* cmGeneratorTarget::GetLocationForBuild() const { static std::string location; if (this->IsImported()) { - location = this->Target->ImportedGetFullPath("", false); + location = this->Target->ImportedGetFullPath( + "", cmStateEnums::RuntimeBinaryArtifact); return location.c_str(); } @@ -840,14 +715,14 @@ const char* cmGeneratorTarget::GetLocationForBuild() const } if (this->IsAppBundleOnApple()) { - std::string macdir = this->BuildMacContentDirectory("", "", false); + std::string macdir = this->BuildBundleDirectory("", "", FullLevel); if (!macdir.empty()) { location += "/"; location += macdir; } } location += "/"; - location += this->GetFullName("", false); + location += this->GetFullName("", cmStateEnums::RuntimeBinaryArtifact); return location.c_str(); } @@ -1088,24 +963,16 @@ void cmGeneratorTarget::GetSourceFiles(std::vector<std::string>& files, void cmGeneratorTarget::GetSourceFiles(std::vector<cmSourceFile*>& files, const std::string& config) const { - - // Lookup any existing link implementation for this configuration. - std::string key = cmSystemTools::UpperCase(config); - - if (!this->LinkImplementationLanguageIsContextDependent) { - files = this->SourceFilesMap.begin()->second; - return; - } - - SourceFilesMapType::iterator it = this->SourceFilesMap.find(key); - if (it != this->SourceFilesMap.end()) { - files = it->second; - } else { + if (!this->GlobalGenerator->GetConfigureDoneCMP0026()) { + // Since we are still configuring not all sources may exist yet, + // so we need to avoid full source classification because that + // requires the absolute paths to all sources to be determined. + // Since this is only for compatibility with old policies that + // projects should not depend on anymore, just compute the files + // without memoizing them. std::vector<std::string> srcs; this->GetSourceFiles(srcs, config); - std::set<cmSourceFile*> emitted; - for (std::vector<std::string>::const_iterator i = srcs.begin(); i != srcs.end(); ++i) { cmSourceFile* sf = this->Makefile->GetOrCreateSource(*i); @@ -1113,7 +980,184 @@ void cmGeneratorTarget::GetSourceFiles(std::vector<cmSourceFile*>& files, files.push_back(sf); } } - this->SourceFilesMap[key] = files; + return; + } + + KindedSources const& kinded = this->GetKindedSources(config); + files.reserve(kinded.Sources.size()); + for (std::vector<SourceAndKind>::const_iterator si = kinded.Sources.begin(); + si != kinded.Sources.end(); ++si) { + files.push_back(si->Source); + } +} + +void cmGeneratorTarget::GetSourceFilesWithoutObjectLibraries( + std::vector<cmSourceFile*>& files, const std::string& config) const +{ + KindedSources const& kinded = this->GetKindedSources(config); + files.reserve(kinded.Sources.size()); + for (std::vector<SourceAndKind>::const_iterator si = kinded.Sources.begin(); + si != kinded.Sources.end(); ++si) { + if (si->Source->GetObjectLibrary().empty()) { + files.push_back(si->Source); + } + } +} + +cmGeneratorTarget::KindedSources const& cmGeneratorTarget::GetKindedSources( + std::string const& config) const +{ + // If we already processed one configuration and found no dependenc + // on configuration then always use the one result. + if (!this->LinkImplementationLanguageIsContextDependent) { + return this->KindedSourcesMap.begin()->second; + } + + // Lookup any existing link implementation for this configuration. + std::string const key = cmSystemTools::UpperCase(config); + KindedSourcesMapType::iterator it = this->KindedSourcesMap.find(key); + if (it != this->KindedSourcesMap.end()) { + return it->second; + } + + // Add an entry to the map for this configuration. + KindedSources& files = this->KindedSourcesMap[key]; + this->ComputeKindedSources(files, config); + return files; +} + +void cmGeneratorTarget::ComputeKindedSources(KindedSources& files, + std::string const& config) const +{ + // Get the source file paths by string. + std::vector<std::string> srcs; + this->GetSourceFiles(srcs, config); + + cmsys::RegularExpression header_regex(CM_HEADER_REGEX); + std::vector<cmSourceFile*> badObjLib; + + std::set<cmSourceFile*> emitted; + for (std::vector<std::string>::const_iterator i = srcs.begin(); + i != srcs.end(); ++i) { + // Create each source at most once. + cmSourceFile* sf = this->Makefile->GetOrCreateSource(*i); + if (!emitted.insert(sf).second) { + continue; + } + + // Compute the kind (classification) of this source file. + SourceKind kind; + std::string ext = cmSystemTools::LowerCase(sf->GetExtension()); + if (sf->GetCustomCommand()) { + kind = SourceKindCustomCommand; + } else if (this->Target->GetType() == cmStateEnums::UTILITY) { + kind = SourceKindExtra; + } else if (sf->GetPropertyAsBool("HEADER_FILE_ONLY")) { + kind = SourceKindHeader; + } else if (sf->GetPropertyAsBool("EXTERNAL_OBJECT")) { + kind = SourceKindExternalObject; + if (this->GetType() == cmStateEnums::OBJECT_LIBRARY) { + badObjLib.push_back(sf); + } + } else if (!sf->GetLanguage().empty()) { + kind = SourceKindObjectSource; + } else if (ext == "def") { + kind = SourceKindModuleDefinition; + if (this->GetType() == cmStateEnums::OBJECT_LIBRARY) { + badObjLib.push_back(sf); + } + } else if (ext == "idl") { + kind = SourceKindIDL; + if (this->GetType() == cmStateEnums::OBJECT_LIBRARY) { + badObjLib.push_back(sf); + } + } else if (ext == "resx") { + kind = SourceKindResx; + // Build and save the name of the corresponding .h file + // This relationship will be used later when building the project files. + // Both names would have been auto generated from Visual Studio + // where the user supplied the file name and Visual Studio + // appended the suffix. + std::string resx = sf->GetFullPath(); + std::string hFileName = resx.substr(0, resx.find_last_of('.')) + ".h"; + files.ExpectedResxHeaders.insert(hFileName); + } else if (ext == "appxmanifest") { + kind = SourceKindAppManifest; + } else if (ext == "manifest") { + kind = SourceKindManifest; + } else if (ext == "pfx") { + kind = SourceKindCertificate; + } else if (ext == "xaml") { + kind = SourceKindXaml; + // Build and save the name of the corresponding .h and .cpp file + // This relationship will be used later when building the project files. + // Both names would have been auto generated from Visual Studio + // where the user supplied the file name and Visual Studio + // appended the suffix. + std::string xaml = sf->GetFullPath(); + std::string hFileName = xaml + ".h"; + std::string cppFileName = xaml + ".cpp"; + files.ExpectedXamlHeaders.insert(hFileName); + files.ExpectedXamlSources.insert(cppFileName); + } else if (header_regex.find(sf->GetFullPath().c_str())) { + kind = SourceKindHeader; + } else { + kind = SourceKindExtra; + } + + // Save this classified source file in the result vector. + SourceAndKind entry = { sf, kind }; + files.Sources.push_back(entry); + } + + if (!badObjLib.empty()) { + std::ostringstream e; + e << "OBJECT library \"" << this->GetName() << "\" contains:\n"; + for (std::vector<cmSourceFile*>::const_iterator i = badObjLib.begin(); + i != badObjLib.end(); ++i) { + e << " " << (*i)->GetLocation().GetName() << "\n"; + } + e << "but may contain only sources that compile, header files, and " + "other files that would not affect linking of a normal library."; + this->GlobalGenerator->GetCMakeInstance()->IssueMessage( + cmake::FATAL_ERROR, e.str(), this->GetBacktrace()); + } +} + +std::vector<cmGeneratorTarget::AllConfigSource> const& +cmGeneratorTarget::GetAllConfigSources() const +{ + if (this->AllConfigSources.empty()) { + this->ComputeAllConfigSources(); + } + return this->AllConfigSources; +} + +void cmGeneratorTarget::ComputeAllConfigSources() const +{ + std::vector<std::string> configs; + this->Makefile->GetConfigurations(configs); + + std::map<cmSourceFile const*, size_t> index; + + for (size_t ci = 0; ci < configs.size(); ++ci) { + KindedSources const& sources = this->GetKindedSources(configs[ci]); + for (std::vector<cmGeneratorTarget::SourceAndKind>::const_iterator si = + sources.Sources.begin(); + si != sources.Sources.end(); ++si) { + std::map<cmSourceFile const*, size_t>::iterator mi = + index.find(si->Source); + if (mi == index.end()) { + AllConfigSource acs; + acs.Source = si->Source; + acs.Kind = si->Kind; + this->AllConfigSources.push_back(acs); + std::map<cmSourceFile const*, size_t>::value_type entry( + si->Source, this->AllConfigSources.size() - 1); + mi = index.insert(entry).first; + } + this->AllConfigSources[mi->second].Configs.push_back(ci); + } } } @@ -1123,7 +1167,8 @@ std::string cmGeneratorTarget::GetCompilePDBName( std::string prefix; std::string base; std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, cmStateEnums::RuntimeBinaryArtifact, + prefix, base, suffix); // Check for a per-configuration output directory target property. std::string configUpper = cmSystemTools::UpperCase(config); @@ -1321,8 +1366,7 @@ bool cmGeneratorTarget::HasMacOSXRpathInstallNameDir( return false; } const char* install_name = this->GetProperty("INSTALL_NAME_DIR"); - bool use_install_name = - this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH"); + bool use_install_name = this->MacOSXUseInstallNameDir(); if (install_name && use_install_name && std::string(install_name) == "@rpath") { install_name_is_rpath = true; @@ -1395,6 +1439,53 @@ bool cmGeneratorTarget::MacOSXRpathInstallNameDirDefault() const return cmp0042 == cmPolicies::NEW; } +bool cmGeneratorTarget::MacOSXUseInstallNameDir() const +{ + const char* build_with_install_name = + this->GetProperty("BUILD_WITH_INSTALL_NAME_DIR"); + if (build_with_install_name) { + return cmSystemTools::IsOn(build_with_install_name); + } + + cmPolicies::PolicyStatus cmp0068 = this->GetPolicyStatusCMP0068(); + if (cmp0068 == cmPolicies::NEW) { + return false; + } + + bool use_install_name = this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH"); + + if (use_install_name && cmp0068 == cmPolicies::WARN) { + this->LocalGenerator->GetGlobalGenerator()->AddCMP0068WarnTarget( + this->GetName()); + } + + return use_install_name; +} + +bool cmGeneratorTarget::CanGenerateInstallNameDir( + InstallNameType name_type) const +{ + cmPolicies::PolicyStatus cmp0068 = this->GetPolicyStatusCMP0068(); + + if (cmp0068 == cmPolicies::NEW) { + return true; + } + + bool skip = this->Makefile->IsOn("CMAKE_SKIP_RPATH"); + if (name_type == INSTALL_NAME_FOR_INSTALL) { + skip |= this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH"); + } else { + skip |= this->GetPropertyAsBool("SKIP_BUILD_RPATH"); + } + + if (skip && cmp0068 == cmPolicies::WARN) { + this->LocalGenerator->GetGlobalGenerator()->AddCMP0068WarnTarget( + this->GetName()); + } + + return !skip; +} + std::string cmGeneratorTarget::GetSOName(const std::string& config) const { if (this->IsImported()) { @@ -1424,19 +1515,31 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const return soName; } -std::string cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, - bool contentOnly) const +static bool shouldAddFullLevel(cmGeneratorTarget::BundleDirectoryLevel level) { - std::string fpath = this->GetFullName(config, false); + return level == cmGeneratorTarget::FullLevel; +} + +static bool shouldAddContentLevel( + cmGeneratorTarget::BundleDirectoryLevel level) +{ + return level == cmGeneratorTarget::ContentLevel || shouldAddFullLevel(level); +} + +std::string cmGeneratorTarget::GetAppBundleDirectory( + const std::string& config, BundleDirectoryLevel level) const +{ + std::string fpath = + this->GetFullName(config, cmStateEnums::RuntimeBinaryArtifact); fpath += "."; const char* ext = this->GetProperty("BUNDLE_EXTENSION"); if (!ext) { ext = "app"; } fpath += ext; - if (!this->Makefile->PlatformIsAppleIos()) { + if (shouldAddContentLevel(level) && !this->Makefile->PlatformIsAppleIos()) { fpath += "/Contents"; - if (!contentOnly) { + if (shouldAddFullLevel(level)) { fpath += "/MacOS"; } } @@ -1449,11 +1552,11 @@ bool cmGeneratorTarget::IsBundleOnApple() const this->IsCFBundleOnApple(); } -std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, - bool contentOnly) const +std::string cmGeneratorTarget::GetCFBundleDirectory( + const std::string& config, BundleDirectoryLevel level) const { std::string fpath; - fpath += this->GetOutputName(config, false); + fpath += this->GetOutputName(config, cmStateEnums::RuntimeBinaryArtifact); fpath += "."; const char* ext = this->GetProperty("BUNDLE_EXTENSION"); if (!ext) { @@ -1464,63 +1567,64 @@ std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, } } fpath += ext; - if (!this->Makefile->PlatformIsAppleIos()) { + if (shouldAddContentLevel(level) && !this->Makefile->PlatformIsAppleIos()) { fpath += "/Contents"; - if (!contentOnly) { + if (shouldAddFullLevel(level)) { fpath += "/MacOS"; } } return fpath; } -std::string cmGeneratorTarget::GetFrameworkDirectory(const std::string& config, - bool rootDir) const +std::string cmGeneratorTarget::GetFrameworkDirectory( + const std::string& config, BundleDirectoryLevel level) const { std::string fpath; - fpath += this->GetOutputName(config, false); + fpath += this->GetOutputName(config, cmStateEnums::RuntimeBinaryArtifact); fpath += "."; const char* ext = this->GetProperty("BUNDLE_EXTENSION"); if (!ext) { ext = "framework"; } fpath += ext; - if (!rootDir && !this->Makefile->PlatformIsAppleIos()) { + if (shouldAddFullLevel(level) && !this->Makefile->PlatformIsAppleIos()) { fpath += "/Versions/"; fpath += this->GetFrameworkVersion(); } return fpath; } -std::string cmGeneratorTarget::GetFullName(const std::string& config, - bool implib) const +std::string cmGeneratorTarget::GetFullName( + const std::string& config, cmStateEnums::ArtifactType artifact) const { if (this->IsImported()) { - return this->GetFullNameImported(config, implib); + return this->GetFullNameImported(config, artifact); } - return this->GetFullNameInternal(config, implib); + return this->GetFullNameInternal(config, artifact); } std::string cmGeneratorTarget::GetInstallNameDirForBuildTree( const std::string& config) const { - // If building directly for installation then the build tree install_name - // is the same as the install tree. - if (this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) { - return this->GetInstallNameDirForInstallTree(); - } + if (this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { - // Use the build tree directory for the target. - if (this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME") && - !this->Makefile->IsOn("CMAKE_SKIP_RPATH") && - !this->GetPropertyAsBool("SKIP_BUILD_RPATH")) { - std::string dir; - if (this->MacOSXRpathInstallNameDirDefault()) { - dir = "@rpath"; - } else { - dir = this->GetDirectory(config); + // If building directly for installation then the build tree install_name + // is the same as the install tree. + if (this->MacOSXUseInstallNameDir()) { + return this->GetInstallNameDirForInstallTree(); + } + + // Use the build tree directory for the target. + if (this->CanGenerateInstallNameDir(INSTALL_NAME_FOR_BUILD)) { + std::string dir; + if (this->MacOSXRpathInstallNameDirDefault()) { + dir = "@rpath"; + } else { + dir = this->GetDirectory(config); + } + dir += "/"; + return dir; } - dir += "/"; - return dir; } return ""; } @@ -1531,8 +1635,7 @@ std::string cmGeneratorTarget::GetInstallNameDirForInstallTree() const std::string dir; const char* install_name_dir = this->GetProperty("INSTALL_NAME_DIR"); - if (!this->Makefile->IsOn("CMAKE_SKIP_RPATH") && - !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH")) { + if (this->CanGenerateInstallNameDir(INSTALL_NAME_FOR_INSTALL)) { if (install_name_dir && *install_name_dir) { dir = install_name_dir; dir += "/"; @@ -1790,44 +1893,43 @@ void cmGeneratorTarget::ComputeLinkClosure(const std::string& config, } } -void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, - std::string& base, - std::string& suffix, - const std::string& config, - bool implib) const +void cmGeneratorTarget::GetFullNameComponents( + std::string& prefix, std::string& base, std::string& suffix, + const std::string& config, cmStateEnums::ArtifactType artifact) const { - this->GetFullNameInternal(config, implib, prefix, base, suffix); + this->GetFullNameInternal(config, artifact, prefix, base, suffix); } -std::string cmGeneratorTarget::BuildMacContentDirectory( - const std::string& base, const std::string& config, bool contentOnly) const +std::string cmGeneratorTarget::BuildBundleDirectory( + const std::string& base, const std::string& config, + BundleDirectoryLevel level) const { std::string fpath = base; if (this->IsAppBundleOnApple()) { - fpath += this->GetAppBundleDirectory(config, contentOnly); + fpath += this->GetAppBundleDirectory(config, level); } if (this->IsFrameworkOnApple()) { - fpath += this->GetFrameworkDirectory(config, contentOnly); + fpath += this->GetFrameworkDirectory(config, level); } if (this->IsCFBundleOnApple()) { - fpath += this->GetCFBundleDirectory(config, contentOnly); + fpath += this->GetCFBundleDirectory(config, level); } return fpath; } std::string cmGeneratorTarget::GetMacContentDirectory( - const std::string& config, bool implib) const + const std::string& config, cmStateEnums::ArtifactType artifact) const { // Start with the output directory for the target. - std::string fpath = this->GetDirectory(config, implib); + std::string fpath = this->GetDirectory(config, artifact); fpath += "/"; - bool contentOnly = true; + BundleDirectoryLevel level = ContentLevel; if (this->IsFrameworkOnApple()) { // additional files with a framework go into the version specific // directory - contentOnly = false; + level = FullLevel; } - fpath = this->BuildMacContentDirectory(fpath, config, contentOnly); + fpath = this->BuildBundleDirectory(fpath, config, level); return fpath; } @@ -1880,57 +1982,51 @@ cmGeneratorTarget::CompileInfo const* cmGeneratorTarget::GetCompileInfo( return &i->second; } -cmSourceFile const* cmGeneratorTarget::GetModuleDefinitionFile( - const std::string& config) const +cmGeneratorTarget::ModuleDefinitionInfo const* +cmGeneratorTarget::GetModuleDefinitionInfo(std::string const& config) const { - std::vector<cmSourceFile const*> data; - IMPLEMENT_VISIT_IMPL(ModuleDefinitionFile, - COMMA std::vector<cmSourceFile const*>) - if (!data.empty()) { - return data.front(); + // A module definition file only makes sense on certain target types. + if (this->GetType() != cmStateEnums::SHARED_LIBRARY && + this->GetType() != cmStateEnums::MODULE_LIBRARY && + !this->IsExecutableWithExports()) { + return CM_NULLPTR; } - return CM_NULLPTR; + // Lookup/compute/cache the compile information for this configuration. + std::string config_upper; + if (!config.empty()) { + config_upper = cmSystemTools::UpperCase(config); + } + ModuleDefinitionInfoMapType::const_iterator i = + this->ModuleDefinitionInfoMap.find(config_upper); + if (i == this->ModuleDefinitionInfoMap.end()) { + ModuleDefinitionInfo info; + this->ComputeModuleDefinitionInfo(config, info); + ModuleDefinitionInfoMapType::value_type entry(config_upper, info); + i = this->ModuleDefinitionInfoMap.insert(entry).first; + } + return &i->second; } -bool cmGeneratorTarget::IsDLLPlatform() const +void cmGeneratorTarget::ComputeModuleDefinitionInfo( + std::string const& config, ModuleDefinitionInfo& info) const { - return this->DLLPlatform; + this->GetModuleDefinitionSources(info.Sources, config); + info.WindowsExportAllSymbols = + this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS") && + this->GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS"); + info.DefFileGenerated = + info.WindowsExportAllSymbols || info.Sources.size() > 1; + if (info.DefFileGenerated) { + info.DefFile = this->ObjectDirectory /* has slash */ + "exports.def"; + } else if (!info.Sources.empty()) { + info.DefFile = info.Sources.front()->GetFullPath(); + } } -void cmGeneratorTarget::UseObjectLibraries(std::vector<std::string>& objs, - const std::string& config) const +bool cmGeneratorTarget::IsDLLPlatform() const { - std::vector<cmSourceFile const*> objectFiles; - this->GetExternalObjects(objectFiles, config); - std::vector<cmGeneratorTarget*> objectLibraries; - for (std::vector<cmSourceFile const*>::const_iterator it = - objectFiles.begin(); - it != objectFiles.end(); ++it) { - std::string objLib = (*it)->GetObjectLibrary(); - if (cmGeneratorTarget* tgt = - this->LocalGenerator->FindGeneratorTargetToUse(objLib)) { - objectLibraries.push_back(tgt); - } - } - - std::vector<cmGeneratorTarget*>::const_iterator end = - cmRemoveDuplicates(objectLibraries); - - for (std::vector<cmGeneratorTarget*>::const_iterator ti = - objectLibraries.begin(); - ti != end; ++ti) { - cmGeneratorTarget* ogt = *ti; - std::vector<cmSourceFile const*> objectSources; - ogt->GetObjectSources(objectSources, config); - for (std::vector<cmSourceFile const*>::const_iterator si = - objectSources.begin(); - si != objectSources.end(); ++si) { - std::string obj = ogt->ObjectDirectory; - obj += ogt->Objects[*si]; - objs.push_back(obj); - } - } + return this->DLLPlatform; } void cmGeneratorTarget::GetAutoUicOptions(std::vector<std::string>& result, @@ -2317,19 +2413,28 @@ void cmGeneratorTarget::GetAppleArchs(const std::string& config, } } +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetFeatureSpecificLinkRuleVariable( + std::string const& var, std::string const& config) const +{ + if (this->IsIPOEnabled(config)) { + std::string varIPO = var + "_IPO"; + if (this->Makefile->IsDefinitionSet(varIPO)) { + return varIPO; + } + } + + return var; +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetCreateRuleVariable( std::string const& lang, std::string const& config) const { switch (this->GetType()) { case cmStateEnums::STATIC_LIBRARY: { std::string var = "CMAKE_" + lang + "_CREATE_STATIC_LIBRARY"; - if (this->GetFeatureAsBool("INTERPROCEDURAL_OPTIMIZATION", config)) { - std::string varIPO = var + "_IPO"; - if (this->Makefile->GetDefinition(varIPO)) { - return varIPO; - } - } - return var; + return this->GetFeatureSpecificLinkRuleVariable(var, config); } case cmStateEnums::SHARED_LIBRARY: return "CMAKE_" + lang + "_CREATE_SHARED_LIBRARY"; @@ -2777,7 +2882,8 @@ void cmGeneratorTarget::ComputeTargetManifest(const std::string& config) const } // Get the directory. - std::string dir = this->GetDirectory(config, false); + std::string dir = + this->GetDirectory(config, cmStateEnums::RuntimeBinaryArtifact); // Add each name. std::string f; @@ -2806,7 +2912,7 @@ void cmGeneratorTarget::ComputeTargetManifest(const std::string& config) const gg->AddToManifest(f); } if (!impName.empty()) { - f = this->GetDirectory(config, true); + f = this->GetDirectory(config, cmStateEnums::ImportLibraryArtifact); f += "/"; f += impName; gg->AddToManifest(f); @@ -2824,32 +2930,39 @@ std::string cmGeneratorTarget::GetImportedLibName( } std::string cmGeneratorTarget::GetFullPath(const std::string& config, - bool implib, bool realname) const + cmStateEnums::ArtifactType artifact, + bool realname) const { if (this->IsImported()) { - return this->Target->ImportedGetFullPath(config, implib); + return this->Target->ImportedGetFullPath(config, artifact); } - return this->NormalGetFullPath(config, implib, realname); + return this->NormalGetFullPath(config, artifact, realname); } -std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config, - bool implib, - bool realname) const +std::string cmGeneratorTarget::NormalGetFullPath( + const std::string& config, cmStateEnums::ArtifactType artifact, + bool realname) const { - std::string fpath = this->GetDirectory(config, implib); + std::string fpath = this->GetDirectory(config, artifact); fpath += "/"; if (this->IsAppBundleOnApple()) { - fpath = this->BuildMacContentDirectory(fpath, config, false); + fpath = this->BuildBundleDirectory(fpath, config, FullLevel); fpath += "/"; } // Add the full name of the target. - if (implib) { - fpath += this->GetFullName(config, true); - } else if (realname) { - fpath += this->NormalGetRealName(config); - } else { - fpath += this->GetFullName(config, false); + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + if (realname) { + fpath += this->NormalGetRealName(config); + } else { + fpath += + this->GetFullName(config, cmStateEnums::RuntimeBinaryArtifact); + } + break; + case cmStateEnums::ImportLibraryArtifact: + fpath += this->GetFullName(config, cmStateEnums::ImportLibraryArtifact); + break; } return fpath; } @@ -2926,7 +3039,8 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, std::string& soName, std::string prefix; std::string base; std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, cmStateEnums::RuntimeBinaryArtifact, + prefix, base, suffix); // The library name. name = prefix + base + suffix; @@ -2951,7 +3065,8 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, std::string& soName, // The import library name. if (this->GetType() == cmStateEnums::SHARED_LIBRARY || this->GetType() == cmStateEnums::MODULE_LIBRARY) { - impName = this->GetFullNameInternal(config, true); + impName = + this->GetFullNameInternal(config, cmStateEnums::ImportLibraryArtifact); } else { impName = ""; } @@ -2992,7 +3107,8 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, std::string prefix; std::string base; std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, cmStateEnums::RuntimeBinaryArtifact, + prefix, base, suffix); // The executable name. name = prefix + base + suffix; @@ -3012,19 +3128,20 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, #endif // The import library name. - impName = this->GetFullNameInternal(config, true); + impName = + this->GetFullNameInternal(config, cmStateEnums::ImportLibraryArtifact); // The program database file name. pdbName = this->GetPDBName(config); } -std::string cmGeneratorTarget::GetFullNameInternal(const std::string& config, - bool implib) const +std::string cmGeneratorTarget::GetFullNameInternal( + const std::string& config, cmStateEnums::ArtifactType artifact) const { std::string prefix; std::string base; std::string suffix; - this->GetFullNameInternal(config, implib, prefix, base, suffix); + this->GetFullNameInternal(config, artifact, prefix, base, suffix); return prefix + base + suffix; } @@ -3033,22 +3150,21 @@ const char* cmGeneratorTarget::ImportedGetLocation( { static std::string location; assert(this->IsImported()); - location = this->Target->ImportedGetFullPath(config, false); + location = this->Target->ImportedGetFullPath( + config, cmStateEnums::RuntimeBinaryArtifact); return location.c_str(); } -std::string cmGeneratorTarget::GetFullNameImported(const std::string& config, - bool implib) const +std::string cmGeneratorTarget::GetFullNameImported( + const std::string& config, cmStateEnums::ArtifactType artifact) const { return cmSystemTools::GetFilenameName( - this->Target->ImportedGetFullPath(config, implib)); + this->Target->ImportedGetFullPath(config, artifact)); } -void cmGeneratorTarget::GetFullNameInternal(const std::string& config, - bool implib, - std::string& outPrefix, - std::string& outBase, - std::string& outSuffix) const +void cmGeneratorTarget::GetFullNameInternal( + const std::string& config, cmStateEnums::ArtifactType artifact, + std::string& outPrefix, std::string& outBase, std::string& outSuffix) const { // Use just the target name for non-main target types. if (this->GetType() != cmStateEnums::STATIC_LIBRARY && @@ -3061,9 +3177,12 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, return; } + const bool isImportedLibraryArtifact = + (artifact == cmStateEnums::ImportLibraryArtifact); + // Return an empty name for the import library if this platform // does not support import libraries. - if (implib && + if (isImportedLibraryArtifact && !this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) { outPrefix = ""; outBase = ""; @@ -3076,14 +3195,16 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, if (this->GetType() != cmStateEnums::SHARED_LIBRARY && this->GetType() != cmStateEnums::MODULE_LIBRARY && this->GetType() != cmStateEnums::EXECUTABLE) { - implib = false; + artifact = cmStateEnums::RuntimeBinaryArtifact; } // Compute the full name for main target types. - const char* targetPrefix = (implib ? this->GetProperty("IMPORT_PREFIX") - : this->GetProperty("PREFIX")); - const char* targetSuffix = (implib ? this->GetProperty("IMPORT_SUFFIX") - : this->GetProperty("SUFFIX")); + const char* targetPrefix = + (isImportedLibraryArtifact ? this->GetProperty("IMPORT_PREFIX") + : this->GetProperty("PREFIX")); + const char* targetSuffix = + (isImportedLibraryArtifact ? this->GetProperty("IMPORT_SUFFIX") + : this->GetProperty("SUFFIX")); const char* configPostfix = CM_NULLPTR; if (!config.empty()) { std::string configProp = cmSystemTools::UpperCase(config); @@ -3095,8 +3216,8 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, configPostfix = CM_NULLPTR; } } - const char* prefixVar = this->Target->GetPrefixVariableInternal(implib); - const char* suffixVar = this->Target->GetSuffixVariableInternal(implib); + const char* prefixVar = this->Target->GetPrefixVariableInternal(artifact); + const char* suffixVar = this->Target->GetSuffixVariableInternal(artifact); // Check for language-specific default prefix and suffix. std::string ll = this->GetLinkerLanguage(config); @@ -3123,20 +3244,14 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, // frameworks have directory prefix but no suffix std::string fw_prefix; if (this->IsFrameworkOnApple()) { - fw_prefix = this->GetOutputName(config, false); - fw_prefix += "."; - const char* ext = this->GetProperty("BUNDLE_EXTENSION"); - if (!ext) { - ext = "framework"; - } - fw_prefix += ext; + fw_prefix = this->GetFrameworkDirectory(config, ContentLevel); fw_prefix += "/"; targetPrefix = fw_prefix.c_str(); targetSuffix = CM_NULLPTR; } if (this->IsCFBundleOnApple()) { - fw_prefix = this->GetCFBundleDirectory(config, false); + fw_prefix = this->GetCFBundleDirectory(config, FullLevel); fw_prefix += "/"; targetPrefix = fw_prefix.c_str(); targetSuffix = CM_NULLPTR; @@ -3146,14 +3261,15 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, outPrefix = targetPrefix ? targetPrefix : ""; // Append the target name or property-specified name. - outBase += this->GetOutputName(config, implib); + outBase += this->GetOutputName(config, artifact); // Append the per-configuration postfix. outBase += configPostfix ? configPostfix : ""; // Name shared libraries with their version number on some platforms. if (const char* soversion = this->GetProperty("SOVERSION")) { - if (this->GetType() == cmStateEnums::SHARED_LIBRARY && !implib && + if (this->GetType() == cmStateEnums::SHARED_LIBRARY && + !isImportedLibraryArtifact && this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION")) { outBase += "-"; outBase += soversion; @@ -3175,7 +3291,8 @@ std::string cmGeneratorTarget::GetPDBName(const std::string& config) const std::string prefix; std::string base; std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, cmStateEnums::RuntimeBinaryArtifact, + prefix, base, suffix); std::vector<std::string> props; std::string configUpper = cmSystemTools::UpperCase(config); @@ -3197,6 +3314,46 @@ std::string cmGeneratorTarget::GetPDBName(const std::string& config) const return prefix + base + ".pdb"; } +std::string cmGeneratorTarget::GetObjectDirectory( + std::string const& config) const +{ + std::string obj_dir = + this->GlobalGenerator->ExpandCFGIntDir(this->ObjectDirectory, config); +#if defined(__APPLE__) + // find and replace $(PROJECT_NAME) xcode placeholder + const std::string projectName = this->LocalGenerator->GetProjectName(); + cmSystemTools::ReplaceString(obj_dir, "$(PROJECT_NAME)", projectName); +#endif + return obj_dir; +} + +void cmGeneratorTarget::GetTargetObjectNames( + std::string const& config, std::vector<std::string>& objects) const +{ + std::vector<cmSourceFile const*> objectSources; + this->GetObjectSources(objectSources, config); + std::map<cmSourceFile const*, std::string> mapping; + + for (std::vector<cmSourceFile const*>::const_iterator it = + objectSources.begin(); + it != objectSources.end(); ++it) { + mapping[*it]; + } + + this->LocalGenerator->ComputeObjectFilenames(mapping, this); + + for (std::vector<cmSourceFile const*>::const_iterator it = + objectSources.begin(); + it != objectSources.end(); ++it) { + // Find the object file name corresponding to this source file. + std::map<cmSourceFile const*, std::string>::const_iterator map_it = + mapping.find(*it); + // It must exist because we populated the mapping just above. + assert(!map_it->second.empty()); + objects.push_back(map_it->second); + } +} + bool cmGeneratorTarget::StrictTargetComparison::operator()( cmGeneratorTarget const* t1, cmGeneratorTarget const* t2) const { @@ -3222,8 +3379,18 @@ cmGeneratorTarget::GetTargetSourceFileFlags(const cmSourceFile* sf) const // were not listed in one of the other lists. if (const char* location = sf->GetProperty("MACOSX_PACKAGE_LOCATION")) { flags.MacFolder = location; + const bool stripResources = + this->GlobalGenerator->ShouldStripResourcePath(this->Makefile); if (strcmp(location, "Resources") == 0) { flags.Type = cmGeneratorTarget::SourceFileTypeResource; + if (stripResources) { + flags.MacFolder = ""; + } + } else if (cmSystemTools::StringStartsWith(location, "Resources/")) { + flags.Type = cmGeneratorTarget::SourceFileTypeDeepResource; + if (stripResources) { + flags.MacFolder += strlen("Resources/"); + } } else { flags.Type = cmGeneratorTarget::SourceFileTypeMacContent; } @@ -3277,7 +3444,7 @@ void cmGeneratorTarget::ConstructSourceFileFlags() const if (cmSourceFile* sf = this->Makefile->GetSource(*it)) { SourceFileFlags& flags = this->SourceFlagsMap[sf]; flags.MacFolder = ""; - if (!this->Makefile->PlatformIsAppleIos()) { + if (!this->GlobalGenerator->ShouldStripResourcePath(this->Makefile)) { flags.MacFolder = "Resources"; } flags.Type = cmGeneratorTarget::SourceFileTypeResource; @@ -3806,15 +3973,14 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt, << theTarget->GetName() << "\".\n"; cmSystemTools::Error(e.str().c_str()); break; - } else { - propContent = consistent.second; - continue; } - } else { - // Explicitly set on target and not set in iface. Can't disagree. + propContent = consistent.second; continue; } - } else if (impliedByUse) { + // Explicitly set on target and not set in iface. Can't disagree. + continue; + } + if (impliedByUse) { propContent = impliedValue<PropertyType>(propContent); if (ifaceIsSet) { @@ -3832,43 +3998,36 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt, << "\" is in conflict.\n"; cmSystemTools::Error(e.str().c_str()); break; - } else { - propContent = consistent.second; - continue; } - } else { - // Implicitly set on target and not set in iface. Can't disagree. + propContent = consistent.second; continue; } - } else { - if (ifaceIsSet) { - if (propInitialized) { - std::pair<bool, PropertyType> consistent = - consistentProperty(propContent, ifacePropContent, t); - report += reportEntry; - report += compatibilityAgree(t, propContent != consistent.second); - if (!consistent.first) { - std::ostringstream e; - e << "The INTERFACE_" << p << " property of \"" - << theTarget->GetName() << "\" does\nnot agree with the value " - "of " - << p << " already determined\nfor \"" << tgt->GetName() - << "\".\n"; - cmSystemTools::Error(e.str().c_str()); - break; - } else { - propContent = consistent.second; - continue; - } - } else { - report += reportEntry + "(Interface set)\n"; - propContent = ifacePropContent; - propInitialized = true; + // Implicitly set on target and not set in iface. Can't disagree. + continue; + } + if (ifaceIsSet) { + if (propInitialized) { + std::pair<bool, PropertyType> consistent = + consistentProperty(propContent, ifacePropContent, t); + report += reportEntry; + report += compatibilityAgree(t, propContent != consistent.second); + if (!consistent.first) { + std::ostringstream e; + e << "The INTERFACE_" << p << " property of \"" + << theTarget->GetName() << "\" does\nnot agree with the value of " + << p << " already determined\nfor \"" << tgt->GetName() << "\".\n"; + cmSystemTools::Error(e.str().c_str()); + break; } - } else { - // Not set. Nothing to agree on. + propContent = consistent.second; continue; } + report += reportEntry + "(Interface set)\n"; + propContent = ifacePropContent; + propInitialized = true; + } else { + // Not set. Nothing to agree on. + continue; } } @@ -4277,26 +4436,31 @@ const cmLinkInterfaceLibraries* cmGeneratorTarget::GetLinkInterfaceLibraries( return iface.Exists ? &iface : CM_NULLPTR; } -std::string cmGeneratorTarget::GetDirectory(const std::string& config, - bool implib) const +std::string cmGeneratorTarget::GetDirectory( + const std::string& config, cmStateEnums::ArtifactType artifact) const { if (this->IsImported()) { // Return the directory from which the target is imported. return cmSystemTools::GetFilenamePath( - this->Target->ImportedGetFullPath(config, implib)); + this->Target->ImportedGetFullPath(config, artifact)); } if (OutputInfo const* info = this->GetOutputInfo(config)) { // Return the directory in which the target will be built. - return implib ? info->ImpDir : info->OutDir; + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + return info->OutDir; + case cmStateEnums::ImportLibraryArtifact: + return info->ImpDir; + } } return ""; } -bool cmGeneratorTarget::UsesDefaultOutputDir(const std::string& config, - bool implib) const +bool cmGeneratorTarget::UsesDefaultOutputDir( + const std::string& config, cmStateEnums::ArtifactType artifact) const { std::string dir; - return this->ComputeOutputDir(config, implib, dir); + return this->ComputeOutputDir(config, artifact, dir); } cmGeneratorTarget::OutputInfo const* cmGeneratorTarget::GetOutputInfo( @@ -4330,8 +4494,10 @@ cmGeneratorTarget::OutputInfo const* cmGeneratorTarget::GetOutputInfo( i = this->OutputInfoMap.insert(entry).first; // Compute output directories. - this->ComputeOutputDir(config, false, info.OutDir); - this->ComputeOutputDir(config, true, info.ImpDir); + this->ComputeOutputDir(config, cmStateEnums::RuntimeBinaryArtifact, + info.OutDir); + this->ComputeOutputDir(config, cmStateEnums::ImportLibraryArtifact, + info.ImpDir); if (!this->ComputePDBOutputDir("PDB", config, info.PdbDir)) { info.PdbDir = info.OutDir; } @@ -4351,14 +4517,15 @@ cmGeneratorTarget::OutputInfo const* cmGeneratorTarget::GetOutputInfo( } bool cmGeneratorTarget::ComputeOutputDir(const std::string& config, - bool implib, std::string& out) const + cmStateEnums::ArtifactType artifact, + std::string& out) const { bool usesDefaultOutputDir = false; std::string conf = config; // Look for a target property defining the target output directory // based on the target type. - std::string targetTypeName = this->GetOutputTargetType(implib); + std::string targetTypeName = this->GetOutputTargetType(artifact); const char* propertyName = CM_NULLPTR; std::string propertyNameStr = targetTypeName; if (!propertyNameStr.empty()) { @@ -4883,11 +5050,11 @@ bool cmGeneratorTarget::GetConfigCommonSourceFiles( std::vector<std::string>::const_iterator it = configs.begin(); const std::string& firstConfig = *it; - this->GetSourceFiles(files, firstConfig); + this->GetSourceFilesWithoutObjectLibraries(files, firstConfig); for (; it != configs.end(); ++it) { std::vector<cmSourceFile*> configFiles; - this->GetSourceFiles(configFiles, *it); + this->GetSourceFilesWithoutObjectLibraries(configFiles, *it); if (configFiles != files) { std::string firstConfigFiles; const char* sep = ""; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index f568699..ae12f97 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -3,7 +3,7 @@ #ifndef cmGeneratorTarget_h #define cmGeneratorTarget_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmLinkItem.h" #include "cmListFileCache.h" @@ -12,6 +12,7 @@ #include <map> #include <set> +#include <stddef.h> #include <string> #include <utility> #include <vector> @@ -69,18 +70,69 @@ public: bool GetPropertyAsBool(const std::string& prop) const; void GetSourceFiles(std::vector<cmSourceFile*>& files, const std::string& config) const; + void GetSourceFilesWithoutObjectLibraries(std::vector<cmSourceFile*>& files, + const std::string& config) const; + + /** Source file kinds (classifications). + Generators use this to decide how to treat a source file. */ + enum SourceKind + { + SourceKindAppManifest, + SourceKindCertificate, + SourceKindCustomCommand, + SourceKindExternalObject, + SourceKindExtra, + SourceKindHeader, + SourceKindIDL, + SourceKindManifest, + SourceKindModuleDefinition, + SourceKindObjectSource, + SourceKindResx, + SourceKindXaml + }; + + /** A source file paired with a kind (classification). */ + struct SourceAndKind + { + cmSourceFile* Source; + SourceKind Kind; + }; + + /** All sources needed for a configuration with kinds assigned. */ + struct KindedSources + { + std::vector<SourceAndKind> Sources; + std::set<std::string> ExpectedResxHeaders; + std::set<std::string> ExpectedXamlHeaders; + std::set<std::string> ExpectedXamlSources; + }; + + /** Get all sources needed for a configuration with kinds assigned. */ + KindedSources const& GetKindedSources(std::string const& config) const; + + struct AllConfigSource + { + cmSourceFile const* Source; + cmGeneratorTarget::SourceKind Kind; + std::vector<size_t> Configs; + }; + + /** Get all sources needed for all configurations with kinds and + per-source configurations assigned. */ + std::vector<AllConfigSource> const& GetAllConfigSources() const; void GetObjectSources(std::vector<cmSourceFile const*>&, const std::string& config) const; const std::string& GetObjectName(cmSourceFile const* file); + const char* GetCustomObjectExtension() const; bool HasExplicitObjectName(cmSourceFile const* file) const; void AddExplicitObjectName(cmSourceFile const* sf); + void GetModuleDefinitionSources(std::vector<cmSourceFile const*>&, + const std::string& config) const; void GetResxSources(std::vector<cmSourceFile const*>&, const std::string& config) const; - void GetIDLSources(std::vector<cmSourceFile const*>&, - const std::string& config) const; void GetExternalObjects(std::vector<cmSourceFile const*>&, const std::string& config) const; void GetHeaderSources(std::vector<cmSourceFile const*>&, @@ -110,8 +162,8 @@ public: const char* GetFeature(const std::string& feature, const std::string& config) const; - bool GetFeatureAsBool(const std::string& feature, - const std::string& config) const; + + bool IsIPOEnabled(const std::string& config) const; bool IsLinkInterfaceDependentBoolProperty(const std::string& p, const std::string& config) const; @@ -152,15 +204,31 @@ public: /** Get the full path to the target according to the settings in its makefile and the configuration type. */ - std::string GetFullPath(const std::string& config = "", bool implib = false, - bool realname = false) const; - std::string NormalGetFullPath(const std::string& config, bool implib, + std::string GetFullPath( + const std::string& config = "", + cmStateEnums::ArtifactType artifact = cmStateEnums::RuntimeBinaryArtifact, + bool realname = false) const; + std::string NormalGetFullPath(const std::string& config, + cmStateEnums::ArtifactType artifact, bool realname) const; std::string NormalGetRealName(const std::string& config) const; + /** Get the names of an object library's object files underneath + its object file directory. */ + void GetTargetObjectNames(std::string const& config, + std::vector<std::string>& objects) const; + + /** What hierarchy level should the reported directory contain */ + enum BundleDirectoryLevel + { + BundleDirLevel, + ContentLevel, + FullLevel + }; + /** @return the Mac App directory without the base */ std::string GetAppBundleDirectory(const std::string& config, - bool contentOnly) const; + BundleDirectoryLevel level) const; /** Return whether this target is an executable Bundle, a framework or CFBundle on Apple. */ @@ -169,11 +237,12 @@ public: /** Get the full name of the target according to the settings in its makefile. */ std::string GetFullName(const std::string& config = "", - bool implib = false) const; + cmStateEnums::ArtifactType artifact = + cmStateEnums::RuntimeBinaryArtifact) const; /** @return the Mac framework directory without the base. */ std::string GetFrameworkDirectory(const std::string& config, - bool rootDir) const; + BundleDirectoryLevel level) const; /** Return the framework version string. Undefined if IsFrameworkOnApple returns false. */ @@ -181,7 +250,7 @@ public: /** @return the Mac CFBundle directory without the base */ std::string GetCFBundleDirectory(const std::string& config, - bool contentOnly) const; + BundleDirectoryLevel level) const; /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", @@ -214,16 +283,18 @@ public: void GetFullNameComponents(std::string& prefix, std::string& base, std::string& suffix, const std::string& config = "", - bool implib = false) const; + cmStateEnums::ArtifactType artifact = + cmStateEnums::RuntimeBinaryArtifact) const; - /** Append to @a base the mac content directory and return it. */ - std::string BuildMacContentDirectory(const std::string& base, - const std::string& config = "", - bool contentOnly = true) const; + /** Append to @a base the bundle directory hierarchy up to a certain @a level + * and return it. */ + std::string BuildBundleDirectory(const std::string& base, + const std::string& config, + BundleDirectoryLevel level) const; /** @return the mac content directory for this target. */ - std::string GetMacContentDirectory(const std::string& config = CM_NULLPTR, - bool implib = false) const; + std::string GetMacContentDirectory( + const std::string& config, cmStateEnums::ArtifactType artifact) const; /** @return folder prefix for IDEs. */ std::string GetEffectiveFolderName() const; @@ -233,7 +304,15 @@ public: cmLocalGenerator* LocalGenerator; cmGlobalGenerator const* GlobalGenerator; - cmSourceFile const* GetModuleDefinitionFile(const std::string& config) const; + struct ModuleDefinitionInfo + { + std::string DefFile; + bool DefFileGenerated; + bool WindowsExportAllSymbols; + std::vector<cmSourceFile const*> Sources; + }; + ModuleDefinitionInfo const* GetModuleDefinitionInfo( + std::string const& config) const; /** Return whether or not the target is for a DLL platform. */ bool IsDLLPlatform() const; @@ -282,8 +361,11 @@ public: std::vector<cmGeneratorTarget*>& objlibs) const; std::string GetFullNameImported(const std::string& config, - bool implib) const; + cmStateEnums::ArtifactType artifact) const; + /** Get source files common to all configurations and diagnose cases + with per-config sources. Excludes sources added by a TARGET_OBJECTS + generator expression. */ bool GetConfigCommonSourceFiles(std::vector<cmSourceFile*>& files) const; bool HaveBuildTreeRPATH(const std::string& config) const; @@ -293,12 +375,16 @@ public: time config name placeholder if needed for the generator. */ std::string ObjectDirectory; - void UseObjectLibraries(std::vector<std::string>& objs, - const std::string& config) const; + /** Full path with trailing slash to the top-level directory + holding object files for the given configuration. */ + std::string GetObjectDirectory(std::string const& config) const; void GetAppleArchs(const std::string& config, std::vector<std::string>& archVec) const; + std::string GetFeatureSpecificLinkRuleVariable( + std::string const& var, std::string const& config) const; + /** Return the rule variable used to create this type of target. */ std::string GetCreateRuleVariable(std::string const& lang, std::string const& config) const; @@ -335,7 +421,8 @@ public: subdirectory for that configuration. Otherwise just the canonical output directory is given. */ std::string GetDirectory(const std::string& config = "", - bool implib = false) const; + cmStateEnums::ArtifactType artifact = + cmStateEnums::RuntimeBinaryArtifact) const; /** Get the directory in which to place the target compiler .pdb file. If the configuration name is given then the generator will add its @@ -349,7 +436,8 @@ public: /** Return whether this target uses the default value for its output directory. */ - bool UsesDefaultOutputDir(const std::string& config, bool implib) const; + bool UsesDefaultOutputDir(const std::string& config, + cmStateEnums::ArtifactType artifact) const; // Cache target output paths for each configuration. struct OutputInfo @@ -390,7 +478,8 @@ public: std::string GetCompilePDBPath(const std::string& config = "") const; // Get the target base name. - std::string GetOutputName(const std::string& config, bool implib) const; + std::string GetOutputName(const std::string& config, + cmStateEnums::ArtifactType artifact) const; void AddSource(const std::string& src); void AddTracedSources(std::vector<std::string> const& srcs); @@ -412,7 +501,9 @@ public: SourceFileTypePublicHeader, // is in "PUBLIC_HEADER" target property SourceFileTypeResource, // is in "RESOURCE" target property *or* // has MACOSX_PACKAGE_LOCATION=="Resources" - SourceFileTypeMacContent // has MACOSX_PACKAGE_LOCATION!="Resources" + SourceFileTypeDeepResource, // MACOSX_PACKAGE_LOCATION starts with + // "Resources/" + SourceFileTypeMacContent // has MACOSX_PACKAGE_LOCATION!="Resources[/]" }; struct SourceFileFlags { @@ -421,11 +512,6 @@ public: , MacFolder(CM_NULLPTR) { } - SourceFileFlags(SourceFileFlags const& r) - : Type(r.Type) - , MacFolder(r.MacFolder) - { - } SourceFileType Type; const char* MacFolder; // location inside Mac content folders }; @@ -461,7 +547,7 @@ public: std::string GetPDBDirectory(const std::string& config) const; ///! Return the preferred linker language for this target - std::string GetLinkerLanguage(const std::string& config = "") const; + std::string GetLinkerLanguage(const std::string& config) const; /** Does this target have a GNU implib to convert to MS format? */ bool HasImplibGNUtoMS() const; @@ -498,19 +584,6 @@ public: struct SourceFileFlags GetTargetSourceFileFlags( const cmSourceFile* sf) const; - struct ResxData - { - mutable std::set<std::string> ExpectedResxHeaders; - mutable std::vector<cmSourceFile const*> ResxSources; - }; - - struct XamlData - { - std::set<std::string> ExpectedXamlHeaders; - std::set<std::string> ExpectedXamlSources; - std::vector<cmSourceFile const*> XamlSources; - }; - void ReportPropertyOrigin(const std::string& p, const std::string& result, const std::string& report, const std::string& compatibilityType) const; @@ -525,6 +598,16 @@ public: /** Whether this library defaults to \@rpath. */ bool MacOSXRpathInstallNameDirDefault() const; + enum InstallNameType + { + INSTALL_NAME_FOR_BUILD, + INSTALL_NAME_FOR_INSTALL + }; + /** Whether to use INSTALL_NAME_DIR. */ + bool MacOSXUseInstallNameDir() const; + /** Whether to generate an install_name. */ + bool CanGenerateInstallNameDir(InstallNameType t) const; + /** Test for special case of a third-party shared library that has no soname at all. */ bool IsImportedSharedLibWithoutSOName(const std::string& config) const; @@ -574,8 +657,9 @@ private: mutable std::map<std::string, bool> DebugCompatiblePropertiesDone; std::string GetFullNameInternal(const std::string& config, - bool implib) const; - void GetFullNameInternal(const std::string& config, bool implib, + cmStateEnums::ArtifactType artifact) const; + void GetFullNameInternal(const std::string& config, + cmStateEnums::ArtifactType artifact, std::string& outPrefix, std::string& outBase, std::string& outSuffix) const; @@ -583,7 +667,7 @@ private: mutable LinkClosureMapType LinkClosureMap; // Returns ARCHIVE, LIBRARY, or RUNTIME based on platform and type. - const char* GetOutputTargetType(bool implib) const; + const char* GetOutputTargetType(cmStateEnums::ArtifactType artifact) const; void ComputeVersionedName(std::string& vName, std::string const& prefix, std::string const& base, std::string const& suffix, @@ -673,9 +757,13 @@ private: const std::string& config, const cmGeneratorTarget* head, bool usage_requirements_only) const; - typedef std::map<std::string, std::vector<cmSourceFile*> > - SourceFilesMapType; - mutable SourceFilesMapType SourceFilesMap; + typedef std::map<std::string, KindedSources> KindedSourcesMapType; + mutable KindedSourcesMapType KindedSourcesMap; + void ComputeKindedSources(KindedSources& files, + std::string const& config) const; + + mutable std::vector<AllConfigSource> AllConfigSources; + void ComputeAllConfigSources() const; std::vector<TargetPropertyEntry*> IncludeDirectoriesEntries; std::vector<TargetPropertyEntry*> CompileOptionsEntries; @@ -705,18 +793,26 @@ private: cmLinkImplementationLibraries const* GetLinkImplementationLibrariesInternal( const std::string& config, const cmGeneratorTarget* head) const; - bool ComputeOutputDir(const std::string& config, bool implib, + bool ComputeOutputDir(const std::string& config, + cmStateEnums::ArtifactType artifact, std::string& out) const; typedef std::map<std::string, OutputInfo> OutputInfoMapType; mutable OutputInfoMapType OutputInfoMap; - typedef std::pair<std::string, bool> OutputNameKey; + typedef std::map<std::string, ModuleDefinitionInfo> + ModuleDefinitionInfoMapType; + mutable ModuleDefinitionInfoMapType ModuleDefinitionInfoMap; + void ComputeModuleDefinitionInfo(std::string const& config, + ModuleDefinitionInfo& info) const; + + typedef std::pair<std::string, cmStateEnums::ArtifactType> OutputNameKey; typedef std::map<OutputNameKey, std::string> OutputNameMapType; mutable OutputNameMapType OutputNameMap; mutable std::set<cmLinkItem> UtilityItems; cmPolicies::PolicyMap PolicyMap; mutable bool PolicyWarnedCMP0022; + mutable bool PolicyReportedCMP0069; mutable bool DebugIncludesDone; mutable bool DebugCompileOptionsDone; mutable bool DebugCompileFeaturesDone; diff --git a/Source/cmGetCMakePropertyCommand.h b/Source/cmGetCMakePropertyCommand.h index 41a51a4..c454e34 100644 --- a/Source/cmGetCMakePropertyCommand.h +++ b/Source/cmGetCMakePropertyCommand.h @@ -3,7 +3,8 @@ #ifndef cmGetCMakePropertyCommand_h #define cmGetCMakePropertyCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmGetDirectoryPropertyCommand.h b/Source/cmGetDirectoryPropertyCommand.h index 1ae3125..0adf818 100644 --- a/Source/cmGetDirectoryPropertyCommand.h +++ b/Source/cmGetDirectoryPropertyCommand.h @@ -3,7 +3,8 @@ #ifndef cmGetDirectoryPropertyCommand_h #define cmGetDirectoryPropertyCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmGetFilenameComponentCommand.h b/Source/cmGetFilenameComponentCommand.h index c0ad903..efc9d7b 100644 --- a/Source/cmGetFilenameComponentCommand.h +++ b/Source/cmGetFilenameComponentCommand.h @@ -3,7 +3,8 @@ #ifndef cmGetFilenameComponentCommand_h #define cmGetFilenameComponentCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmGetPropertyCommand.h b/Source/cmGetPropertyCommand.h index f9a33ac..a57c675 100644 --- a/Source/cmGetPropertyCommand.h +++ b/Source/cmGetPropertyCommand.h @@ -3,7 +3,8 @@ #ifndef cmGetPropertyCommand_h #define cmGetPropertyCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmGetSourceFilePropertyCommand.h b/Source/cmGetSourceFilePropertyCommand.h index 0f71851..558e2ab 100644 --- a/Source/cmGetSourceFilePropertyCommand.h +++ b/Source/cmGetSourceFilePropertyCommand.h @@ -3,7 +3,8 @@ #ifndef cmGetSourceFilePropertyCommand_h #define cmGetSourceFilePropertyCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmGetTargetPropertyCommand.h b/Source/cmGetTargetPropertyCommand.h index 32fe803..9cebb3b 100644 --- a/Source/cmGetTargetPropertyCommand.h +++ b/Source/cmGetTargetPropertyCommand.h @@ -3,7 +3,8 @@ #ifndef cmGetTargetPropertyCommand_h #define cmGetTargetPropertyCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmGetTestPropertyCommand.h b/Source/cmGetTestPropertyCommand.h index 0491cc8..d3d10cb 100644 --- a/Source/cmGetTestPropertyCommand.h +++ b/Source/cmGetTestPropertyCommand.h @@ -3,7 +3,8 @@ #ifndef cmGetTestPropertyCommand_h #define cmGetTestPropertyCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmGhsMultiGpj.h b/Source/cmGhsMultiGpj.h index 2c2b123..7bc7bfc 100644 --- a/Source/cmGhsMultiGpj.h +++ b/Source/cmGhsMultiGpj.h @@ -3,7 +3,7 @@ #ifndef cmGhsMultiGpj_h #define cmGhsMultiGpj_h -#include <cmConfigure.h> +#include "cmConfigure.h" class cmGeneratedFileStream; diff --git a/Source/cmGlobalCommonGenerator.h b/Source/cmGlobalCommonGenerator.h index e8e6ad9..f2ad059 100644 --- a/Source/cmGlobalCommonGenerator.h +++ b/Source/cmGlobalCommonGenerator.h @@ -3,7 +3,7 @@ #ifndef cmGlobalCommonGenerator_h #define cmGlobalCommonGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmGlobalGenerator.h" diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index f118250..50ad1a8 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1,24 +1,21 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#if defined(_WIN32) && !defined(__CYGWIN__) -#include "windows.h" // this must be first to define GetCurrentDirectory -#if defined(_MSC_VER) && _MSC_VER >= 1800 -#define KWSYS_WINDOWS_DEPRECATED_GetVersionEx -#endif -#endif - #include "cmGlobalGenerator.h" +#include "cmsys/Directory.hxx" +#include "cmsys/FStream.hxx" #include <algorithm> #include <assert.h> -#include <cmsys/Directory.hxx> -#include <cmsys/FStream.hxx> #include <iterator> #include <sstream> #include <stdio.h> #include <stdlib.h> #include <string.h> +#if defined(_WIN32) && !defined(__CYGWIN__) +#include <windows.h> +#endif + #include "cmAlgorithms.h" #include "cmCPackPropertiesGenerator.h" #include "cmComputeTargetDepends.h" @@ -42,12 +39,17 @@ #include "cmStateDirectory.h" #include "cmStateTypes.h" #include "cmVersion.h" +#include "cmWorkingDirectory.h" #include "cmake.h" #if defined(CMAKE_BUILD_WITH_CMAKE) #include "cmCryptoHash.h" -#include <cm_jsoncpp_value.h> -#include <cm_jsoncpp_writer.h> +#include "cm_jsoncpp_value.h" +#include "cm_jsoncpp_writer.h" +#endif + +#if defined(_MSC_VER) && _MSC_VER >= 1800 +#define KWSYS_WINDOWS_DEPRECATED_GetVersionEx #endif const std::string kCMAKE_PLATFORM_INFO_INITIALIZED = @@ -94,6 +96,7 @@ cmGlobalGenerator::cmGlobalGenerator(cmake* cm) this->ConfigureDoneCMP0026AndCMP0024 = false; this->FirstTimeProgress = 0.0f; + cm->GetState()->SetIsGeneratorMultiConfig(false); cm->GetState()->SetMinGWMake(false); cm->GetState()->SetMSYSShell(false); cm->GetState()->SetNMake(false); @@ -1194,6 +1197,11 @@ void cmGlobalGenerator::AddCMP0042WarnTarget(const std::string& target) this->CMP0042WarnTargets.insert(target); } +void cmGlobalGenerator::AddCMP0068WarnTarget(const std::string& target) +{ + this->CMP0068WarnTargets.insert(target); +} + bool cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const { // If the property is not enabled then okay. @@ -1235,6 +1243,8 @@ bool cmGlobalGenerator::Compute() // clear targets to issue warning CMP0042 for this->CMP0042WarnTargets.clear(); + // clear targets to issue warning CMP0068 for + this->CMP0068WarnTargets.clear(); // Check whether this generator is allowed to run. if (!this->CheckALLOW_DUPLICATE_CUSTOM_TARGETS()) { @@ -1337,10 +1347,11 @@ void cmGlobalGenerator::Generate() for (std::map<std::string, cmExportBuildFileGenerator*>::iterator it = this->BuildExportSets.begin(); it != this->BuildExportSets.end(); ++it) { - if (!it->second->GenerateImportFile() && - !cmSystemTools::GetErrorOccuredFlag()) { - this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, - "Could not write export file."); + if (!it->second->GenerateImportFile()) { + if (!cmSystemTools::GetErrorOccuredFlag()) { + this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, + "Could not write export file."); + } return; } } @@ -1366,6 +1377,24 @@ void cmGlobalGenerator::Generate() this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, w.str()); } + if (!this->CMP0068WarnTargets.empty()) { + std::ostringstream w; + /* clang-format off */ + w << + cmPolicies::GetPolicyWarning(cmPolicies::CMP0068) << "\n" + "For compatibility with older versions of CMake, the install_name " + "fields for the following targets are still affected by RPATH " + "settings:\n" + ; + /* clang-format on */ + for (std::set<std::string>::iterator iter = + this->CMP0068WarnTargets.begin(); + iter != this->CMP0068WarnTargets.end(); ++iter) { + w << " " << *iter << "\n"; + } + this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + } + this->CMakeInstance->UpdateProgress("Generating done", -1); } @@ -1738,8 +1767,7 @@ int cmGlobalGenerator::Build(const std::string& /*unused*/, /** * Run an executable command and put the stdout in output. */ - std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); - cmSystemTools::ChangeDirectory(bindir); + cmWorkingDirectory workdir(bindir); output += "Change Dir: "; output += bindir; output += "\n"; @@ -1779,8 +1807,6 @@ int cmGlobalGenerator::Build(const std::string& /*unused*/, output += *outputPtr; output += "\nGenerator: execution of make clean failed.\n"; - // return to the original directory - cmSystemTools::ChangeDirectory(cwd); return 1; } output += *outputPtr; @@ -1803,8 +1829,6 @@ int cmGlobalGenerator::Build(const std::string& /*unused*/, output += "\nGenerator: execution of make failed. Make command was: " + makeCommandStr + "\n"; - // return to the original directory - cmSystemTools::ChangeDirectory(cwd); return 1; } output += *outputPtr; @@ -1817,7 +1841,6 @@ int cmGlobalGenerator::Build(const std::string& /*unused*/, retVal = 1; } - cmSystemTools::ChangeDirectory(cwd); return retVal; } @@ -2466,6 +2489,11 @@ std::string cmGlobalGenerator::GenerateRuleFile( return ruleFile; } +bool cmGlobalGenerator::ShouldStripResourcePath(cmMakefile* mf) const +{ + return mf->PlatformIsAppleIos(); +} + std::string cmGlobalGenerator::GetSharedLibFlagsForLanguage( std::string const& l) const { diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 18e3730..cc7ffed 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -3,7 +3,7 @@ #ifndef cmGlobalGenerator_h #define cmGlobalGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <iosfwd> #include <map> @@ -331,12 +331,23 @@ public: i.e. "Can I build Debug and Release in the same tree?" */ virtual bool IsMultiConfig() const { return false; } + /** Return true if we know the exact location of object files. + If false, store the reason in the given string. + This is meaningful only after EnableLanguage has been called. */ + virtual bool HasKnownObjectFileLocation(std::string*) const { return true; } + virtual bool UseFolderProperty() const; + virtual bool IsIPOSupported() const { return false; } + /** Return whether the generator should use EFFECTIVE_PLATFORM_NAME. This is relevant for mixed macOS and iOS builds. */ virtual bool UseEffectivePlatformName(cmMakefile*) const { return false; } + /** Return whether the "Resources" folder prefix should be stripped from + MacFolder. */ + virtual bool ShouldStripResourcePath(cmMakefile*) const; + std::string GetSharedLibFlagsForLanguage(std::string const& lang) const; /** Generate an <output>.rule file path for a given command output. */ @@ -357,6 +368,7 @@ public: cmExportBuildFileGenerator* GetExportedTargetsFile( const std::string& filename) const; void AddCMP0042WarnTarget(const std::string& target); + void AddCMP0068WarnTarget(const std::string& target); virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; @@ -548,12 +560,6 @@ private: : LastDiskTime(-1) { } - DirectoryContent(DirectoryContent const& dc) - : LastDiskTime(dc.LastDiskTime) - , All(dc.All) - , Generated(dc.Generated) - { - } }; std::map<std::string, DirectoryContent> DirectoryContentMap; @@ -562,6 +568,8 @@ private: // track targets to issue CMP0042 warning for. std::set<std::string> CMP0042WarnTargets; + // track targets to issue CMP0068 warning for. + std::set<std::string> CMP0068WarnTargets; mutable std::map<cmSourceFile*, std::set<cmGeneratorTarget const*> > FilenameTargetDepends; diff --git a/Source/cmGlobalGeneratorFactory.h b/Source/cmGlobalGeneratorFactory.h index 5e948f7..d5a6db0 100644 --- a/Source/cmGlobalGeneratorFactory.h +++ b/Source/cmGlobalGeneratorFactory.h @@ -3,7 +3,7 @@ #ifndef cmGlobalGeneratorFactory_h #define cmGlobalGeneratorFactory_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <string> #include <vector> diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx index 286f375..42ab4d9 100644 --- a/Source/cmGlobalGhsMultiGenerator.cxx +++ b/Source/cmGlobalGhsMultiGenerator.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmGlobalGhsMultiGenerator.h" -#include <cmsys/SystemTools.hxx> +#include "cmsys/SystemTools.hxx" #include "cmAlgorithms.h" #include "cmDocumentationEntry.h" diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx index 75209c3..a958a17 100644 --- a/Source/cmGlobalKdevelopGenerator.cxx +++ b/Source/cmGlobalKdevelopGenerator.cxx @@ -14,8 +14,8 @@ #include "cmXMLWriter.h" #include "cmake.h" -#include <cmsys/Directory.hxx> -#include <cmsys/FStream.hxx> +#include "cmsys/Directory.hxx" +#include "cmsys/FStream.hxx" #include <map> #include <set> #include <string.h> diff --git a/Source/cmGlobalKdevelopGenerator.h b/Source/cmGlobalKdevelopGenerator.h index 8121fa8..bdcf8a1 100644 --- a/Source/cmGlobalKdevelopGenerator.h +++ b/Source/cmGlobalKdevelopGenerator.h @@ -3,7 +3,7 @@ #ifndef cmGlobalKdevelopGenerator_h #define cmGlobalKdevelopGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmExternalMakefileProjectGenerator.h" diff --git a/Source/cmGlobalMSYSMakefileGenerator.cxx b/Source/cmGlobalMSYSMakefileGenerator.cxx index 7e0d0d4..3f22382 100644 --- a/Source/cmGlobalMSYSMakefileGenerator.cxx +++ b/Source/cmGlobalMSYSMakefileGenerator.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmGlobalMSYSMakefileGenerator.h" -#include <cmsys/FStream.hxx> +#include "cmsys/FStream.hxx" #include "cmDocumentationEntry.h" #include "cmLocalUnixMakefileGenerator3.h" diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 1bdef53..1a77d7c 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -2,11 +2,11 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmGlobalNinjaGenerator.h" +#include "cm_jsoncpp_reader.h" +#include "cm_jsoncpp_value.h" +#include "cm_jsoncpp_writer.h" +#include "cmsys/FStream.hxx" #include <algorithm> -#include <cm_jsoncpp_reader.h> -#include <cm_jsoncpp_value.h> -#include <cm_jsoncpp_writer.h> -#include <cmsys/FStream.hxx> #include <ctype.h> #include <functional> #include <iterator> @@ -246,7 +246,7 @@ void cmGlobalNinjaGenerator::WriteBuild( bool useResponseFile = false; if (cmdLineLimit < 0 || (cmdLineLimit > 0 && - (args.size() + buildstr.size() + assignments.size()) > + (args.size() + buildstr.size() + assignments.size() + 1000) > static_cast<size_t>(cmdLineLimit))) { variable_assignments.str(std::string()); cmGlobalNinjaGenerator::WriteVariable(variable_assignments, "RSP_FILE", @@ -966,8 +966,14 @@ void cmGlobalNinjaGenerator::WriteAssumedSourceDependencies() } } +std::string OrderDependsTargetForTarget(cmGeneratorTarget const* target) +{ + return "cmake_object_order_depends_target_" + target->GetName(); +} + void cmGlobalNinjaGenerator::AppendTargetOutputs( - cmGeneratorTarget const* target, cmNinjaDeps& outputs) + cmGeneratorTarget const* target, cmNinjaDeps& outputs, + cmNinjaTargetDepends depends) { std::string configName = target->Target->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE"); @@ -979,15 +985,27 @@ void cmGlobalNinjaGenerator::AppendTargetOutputs( bool realname = target->IsFrameworkOnApple(); switch (target->GetType()) { - case cmStateEnums::EXECUTABLE: case cmStateEnums::SHARED_LIBRARY: case cmStateEnums::STATIC_LIBRARY: case cmStateEnums::MODULE_LIBRARY: { - outputs.push_back(this->ConvertToNinjaPath( - target->GetFullPath(configName, false, realname))); + if (depends == DependOnTargetOrdering) { + outputs.push_back(OrderDependsTargetForTarget(target)); + break; + } + } + // FALLTHROUGH + case cmStateEnums::EXECUTABLE: { + outputs.push_back(this->ConvertToNinjaPath(target->GetFullPath( + configName, cmStateEnums::RuntimeBinaryArtifact, realname))); break; } - case cmStateEnums::OBJECT_LIBRARY: + case cmStateEnums::OBJECT_LIBRARY: { + if (depends == DependOnTargetOrdering) { + outputs.push_back(OrderDependsTargetForTarget(target)); + break; + } + } + // FALLTHROUGH case cmStateEnums::GLOBAL_TARGET: case cmStateEnums::UTILITY: { std::string path = @@ -1003,7 +1021,8 @@ void cmGlobalNinjaGenerator::AppendTargetOutputs( } void cmGlobalNinjaGenerator::AppendTargetDepends( - cmGeneratorTarget const* target, cmNinjaDeps& outputs) + cmGeneratorTarget const* target, cmNinjaDeps& outputs, + cmNinjaTargetDepends depends) { if (target->GetType() == cmStateEnums::GLOBAL_TARGET) { // These depend only on other CMake-provided targets, e.g. "all". @@ -1023,7 +1042,7 @@ void cmGlobalNinjaGenerator::AppendTargetDepends( if ((*i)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; } - this->AppendTargetOutputs(*i, outs); + this->AppendTargetOutputs(*i, outs, depends); } std::sort(outs.begin(), outs.end()); outputs.insert(outputs.end(), outs.begin(), outs.end()); diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index a51e919..b1d6155 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -3,7 +3,7 @@ #ifndef cmGlobalNinjaGenerator_h #define cmGlobalNinjaGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <iosfwd> #include <map> @@ -99,6 +99,8 @@ public: */ static bool SupportsPlatform() { return false; } + bool IsIPOSupported() const CM_OVERRIDE { return true; } + /** * Write a build statement to @a os with the @a comment using * the @a rule the list of @a outputs files and inputs. @@ -314,10 +316,12 @@ public: ASD.insert(deps.begin(), deps.end()); } - void AppendTargetOutputs(cmGeneratorTarget const* target, - cmNinjaDeps& outputs); - void AppendTargetDepends(cmGeneratorTarget const* target, - cmNinjaDeps& outputs); + void AppendTargetOutputs( + cmGeneratorTarget const* target, cmNinjaDeps& outputs, + cmNinjaTargetDepends depends = DependOnTargetArtifact); + void AppendTargetDepends( + cmGeneratorTarget const* target, cmNinjaDeps& outputs, + cmNinjaTargetDepends depends = DependOnTargetArtifact); void AppendTargetDependsClosure(cmGeneratorTarget const* target, cmNinjaDeps& outputs); void AddDependencyToAll(cmGeneratorTarget* target); diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 67d7bc9..a656102 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -3,7 +3,7 @@ #ifndef cmGlobalUnixMakefileGenerator3_h #define cmGlobalUnixMakefileGenerator3_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <iosfwd> #include <map> @@ -149,6 +149,8 @@ public: /** Does the make tool tolerate .DELETE_ON_ERROR? */ virtual bool AllowDeleteOnError() const { return true; } + bool IsIPOSupported() const CM_OVERRIDE { return true; } + void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const CM_OVERRIDE; std::string IncludeDirective; diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index e27615a..ee9e47a 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -10,14 +10,25 @@ #include "cmSourceFile.h" #include "cmVS10CLFlagTable.h" #include "cmVS10CSharpFlagTable.h" +#include "cmVS10CudaFlagTable.h" +#include "cmVS10CudaHostFlagTable.h" #include "cmVS10LibFlagTable.h" #include "cmVS10LinkFlagTable.h" #include "cmVS10MASMFlagTable.h" +#include "cmVS10NASMFlagTable.h" #include "cmVS10RCFlagTable.h" +#include "cmVersion.h" #include "cmVisualStudioSlnData.h" #include "cmVisualStudioSlnParser.h" +#include "cmXMLWriter.h" #include "cmake.h" +#include "cmsys/FStream.hxx" +#include "cmsys/Glob.hxx" +#include "cmsys/RegularExpression.hxx" + +#include <algorithm> + static const char vs10generatorName[] = "Visual Studio 10 2010"; // Map generator name without year to name with year. @@ -94,6 +105,7 @@ cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator( "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\10.0\\Setup\\VC;" "ProductDir", vc10Express, cmSystemTools::KeyWOW64_32); + this->CudaEnabled = false; this->SystemIsWindowsCE = false; this->SystemIsWindowsPhone = false; this->SystemIsWindowsStore = false; @@ -112,7 +124,10 @@ cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator( this->DefaultCSharpFlagTable = cmVS10CSharpFlagTable; this->DefaultLibFlagTable = cmVS10LibFlagTable; this->DefaultLinkFlagTable = cmVS10LinkFlagTable; + this->DefaultCudaFlagTable = cmVS10CudaFlagTable; + this->DefaultCudaHostFlagTable = cmVS10CudaHostFlagTable; this->DefaultMasmFlagTable = cmVS10MASMFlagTable; + this->DefaultNasmFlagTable = cmVS10NASMFlagTable; this->DefaultRcFlagTable = cmVS10RCFlagTable; this->Version = VS10; } @@ -153,6 +168,13 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorPlatform( return true; } +static void cmCudaToolVersion(std::string& s) +{ + // "CUDA x.y.props" => "x.y" + s = s.substr(5); + s = s.substr(0, s.size() - 6); +} + bool cmGlobalVisualStudio10Generator::SetGeneratorToolset( std::string const& ts, cmMakefile* mf) { @@ -168,36 +190,119 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset( if (!this->ParseGeneratorToolset(ts, mf)) { return false; } + + if (!this->FindVCTargetsPath(mf)) { + return false; + } + + if (this->GeneratorToolsetCuda.empty()) { + // Find the highest available version of the CUDA tools. + std::vector<std::string> cudaTools; + std::string const bcDir = this->VCTargetsPath + "/BuildCustomizations"; + cmsys::Glob gl; + gl.SetRelative(bcDir.c_str()); + if (gl.FindFiles(bcDir + "/CUDA *.props")) { + cudaTools = gl.GetFiles(); + } + if (!cudaTools.empty()) { + std::for_each(cudaTools.begin(), cudaTools.end(), cmCudaToolVersion); + std::sort(cudaTools.begin(), cudaTools.end(), + cmSystemTools::VersionCompareGreater); + this->GeneratorToolsetCuda = cudaTools.at(0); + } + } + if (const char* toolset = this->GetPlatformToolset()) { mf->AddDefinition("CMAKE_VS_PLATFORM_TOOLSET", toolset); } if (const char* hostArch = this->GetPlatformToolsetHostArchitecture()) { mf->AddDefinition("CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE", hostArch); } + if (const char* cuda = this->GetPlatformToolsetCuda()) { + mf->AddDefinition("CMAKE_VS_PLATFORM_TOOLSET_CUDA", cuda); + } return true; } bool cmGlobalVisualStudio10Generator::ParseGeneratorToolset( std::string const& ts, cmMakefile* mf) { - if (ts.find_first_of(",=") != ts.npos) { - std::ostringstream e; - /* clang-format off */ - e << - "Generator\n" - " " << this->GetName() << "\n" - "does not recognize the toolset\n" - " " << ts << "\n" - "that was specified."; - /* clang-format on */ - mf->IssueMessage(cmake::FATAL_ERROR, e.str()); - return false; + std::vector<std::string> const fields = cmSystemTools::tokenize(ts, ","); + std::vector<std::string>::const_iterator fi = fields.begin(); + if (fi == fields.end()) { + return true; + } + + // The first field may be the VS platform toolset. + if (fi->find('=') == fi->npos) { + this->GeneratorToolset = *fi; + ++fi; + } + + std::set<std::string> handled; + + // The rest of the fields must be key=value pairs. + for (; fi != fields.end(); ++fi) { + std::string::size_type pos = fi->find('='); + if (pos == fi->npos) { + std::ostringstream e; + /* clang-format off */ + e << + "Generator\n" + " " << this->GetName() << "\n" + "given toolset specification\n" + " " << ts << "\n" + "that contains a field after the first ',' with no '='." + ; + /* clang-format on */ + mf->IssueMessage(cmake::FATAL_ERROR, e.str()); + return false; + } + std::string const key = fi->substr(0, pos); + std::string const value = fi->substr(pos + 1); + if (!handled.insert(key).second) { + std::ostringstream e; + /* clang-format off */ + e << + "Generator\n" + " " << this->GetName() << "\n" + "given toolset specification\n" + " " << ts << "\n" + "that contains duplicate field key '" << key << "'." + ; + /* clang-format on */ + mf->IssueMessage(cmake::FATAL_ERROR, e.str()); + return false; + } + if (!this->ProcessGeneratorToolsetField(key, value)) { + std::ostringstream e; + /* clang-format off */ + e << + "Generator\n" + " " << this->GetName() << "\n" + "given toolset specification\n" + " " << ts << "\n" + "that contains invalid field '" << *fi << "'." + ; + /* clang-format on */ + mf->IssueMessage(cmake::FATAL_ERROR, e.str()); + return false; + } } - this->GeneratorToolset = ts; return true; } +bool cmGlobalVisualStudio10Generator::ProcessGeneratorToolsetField( + std::string const& key, std::string const& value) +{ + if (key == "cuda") { + this->GeneratorToolsetCuda = value; + return true; + } + return false; +} + bool cmGlobalVisualStudio10Generator::InitializeSystem(cmMakefile* mf) { if (this->SystemName == "Windows") { @@ -354,6 +459,16 @@ void cmGlobalVisualStudio10Generator::Generate() void cmGlobalVisualStudio10Generator::EnableLanguage( std::vector<std::string> const& lang, cmMakefile* mf, bool optional) { + for (std::vector<std::string>::const_iterator it = lang.begin(); + it != lang.end(); ++it) { + if (*it == "ASM_NASM") { + this->NasmEnabled = true; + } + if (*it == "CUDA") { + this->CudaEnabled = true; + } + } + this->AddPlatformDefinitions(mf); cmGlobalVisualStudio8Generator::EnableLanguage(lang, mf, optional); } @@ -388,6 +503,20 @@ cmGlobalVisualStudio10Generator::GetPlatformToolsetHostArchitecture() const return CM_NULLPTR; } +const char* cmGlobalVisualStudio10Generator::GetPlatformToolsetCuda() const +{ + if (!this->GeneratorToolsetCuda.empty()) { + return this->GeneratorToolsetCuda.c_str(); + } + return CM_NULLPTR; +} + +std::string const& +cmGlobalVisualStudio10Generator::GetPlatformToolsetCudaString() const +{ + return this->GeneratorToolsetCuda; +} + bool cmGlobalVisualStudio10Generator::FindMakeProgram(cmMakefile* mf) { if (!this->cmGlobalVisualStudio8Generator::FindMakeProgram(mf)) { @@ -442,6 +571,208 @@ std::string cmGlobalVisualStudio10Generator::FindDevEnvCommand() return this->cmGlobalVisualStudio71Generator::FindDevEnvCommand(); } +bool cmGlobalVisualStudio10Generator::FindVCTargetsPath(cmMakefile* mf) +{ + // Skip this in special cases within our own test suite. + if (this->GetPlatformName() == "Test Platform" || + this->GetPlatformToolsetString() == "Test Toolset") { + return true; + } + + std::string wd; + if (!this->ConfiguredFilesPath.empty()) { + // In a try-compile we are given the outer CMakeFiles directory. + wd = this->ConfiguredFilesPath; + } else { + wd = this->GetCMakeInstance()->GetHomeOutputDirectory(); + wd += cmake::GetCMakeFilesDirectory(); + } + wd += "/"; + wd += cmVersion::GetCMakeVersion(); + + // We record the result persistently in a file. + std::string const txt = wd + "/VCTargetsPath.txt"; + + // If we have a recorded result, use it. + { + cmsys::ifstream fin(txt.c_str()); + if (fin && cmSystemTools::GetLineFromStream(fin, this->VCTargetsPath) && + cmSystemTools::FileIsDirectory(this->VCTargetsPath)) { + cmSystemTools::ConvertToUnixSlashes(this->VCTargetsPath); + return true; + } + } + + // Prepare the work directory. + if (!cmSystemTools::MakeDirectory(wd)) { + std::string e = "Failed to make directory:\n " + wd; + mf->IssueMessage(cmake::FATAL_ERROR, e.c_str()); + cmSystemTools::SetFatalErrorOccured(); + return false; + } + + // Generate a project file for MSBuild to tell us the VCTargetsPath value. + std::string const vcxproj = "VCTargetsPath.vcxproj"; + { + std::string const vcxprojAbs = wd + "/" + vcxproj; + cmsys::ofstream fout(vcxprojAbs.c_str()); + cmXMLWriter xw(fout); + + /* clang-format off */ + xw.StartDocument(); + xw.StartElement("Project"); + xw.Attribute("DefaultTargets", "Build"); + xw.Attribute("ToolsVersion", "4.0"); + xw.Attribute("xmlns", + "http://schemas.microsoft.com/developer/msbuild/2003"); + if (this->IsNsightTegra()) { + xw.StartElement("PropertyGroup"); + xw.Attribute("Label", "NsightTegraProject"); + xw.StartElement("NsightTegraProjectRevisionNumber"); + xw.Content("6"); + xw.EndElement(); // NsightTegraProjectRevisionNumber + xw.EndElement(); // PropertyGroup + } + xw.StartElement("ItemGroup"); + xw.Attribute("Label", "ProjectConfigurations"); + xw.StartElement("ProjectConfiguration"); + xw.Attribute("Include", "Debug|" + this->GetPlatformName()); + xw.StartElement("Configuration"); + xw.Content("Debug"); + xw.EndElement(); // Configuration + xw.StartElement("Platform"); + xw.Content(this->GetPlatformName()); + xw.EndElement(); // Platform + xw.EndElement(); // ProjectConfiguration + xw.EndElement(); // ItemGroup + xw.StartElement("PropertyGroup"); + xw.Attribute("Label", "Globals"); + xw.StartElement("ProjectGUID"); + xw.Content("{F3FC6D86-508D-3FB1-96D2-995F08B142EC}"); + xw.EndElement(); // ProjectGUID + xw.StartElement("Keyword"); + xw.Content("Win32Proj"); + xw.EndElement(); // Keyword + xw.StartElement("Platform"); + xw.Content(this->GetPlatformName()); + xw.EndElement(); // Platform + if (this->GetSystemName() == "WindowsPhone") { + xw.StartElement("ApplicationType"); + xw.Content("Windows Phone"); + xw.EndElement(); // ApplicationType + xw.StartElement("ApplicationTypeRevision"); + xw.Content(this->GetSystemVersion()); + xw.EndElement(); // ApplicationTypeRevision + } else if (this->GetSystemName() == "WindowsStore") { + xw.StartElement("ApplicationType"); + xw.Content("Windows Store"); + xw.EndElement(); // ApplicationType + xw.StartElement("ApplicationTypeRevision"); + xw.Content(this->GetSystemVersion()); + xw.EndElement(); // ApplicationTypeRevision + } + if (!this->WindowsTargetPlatformVersion.empty()) { + xw.StartElement("WindowsTargetPlatformVersion"); + xw.Content(this->WindowsTargetPlatformVersion); + xw.EndElement(); // WindowsTargetPlatformVersion + } + if (this->GetPlatformName() == "ARM") { + xw.StartElement("WindowsSDKDesktopARMSupport"); + xw.Content("true"); + xw.EndElement(); // WindowsSDKDesktopARMSupport + } + xw.EndElement(); // PropertyGroup + xw.StartElement("Import"); + xw.Attribute("Project", + "$(VCTargetsPath)\\Microsoft.Cpp.Default.props"); + xw.EndElement(); // Import + if (!this->GeneratorToolsetHostArchitecture.empty()) { + xw.StartElement("PropertyGroup"); + xw.StartElement("PreferredToolArchitecture"); + xw.Content(this->GeneratorToolsetHostArchitecture); + xw.EndElement(); // PreferredToolArchitecture + xw.EndElement(); // PropertyGroup + } + xw.StartElement("PropertyGroup"); + xw.Attribute("Label", "Configuration"); + xw.StartElement("ConfigurationType"); + if (this->IsNsightTegra()) { + // Tegra-Android platform does not understand "Utility". + xw.Content("StaticLibrary"); + } else { + xw.Content("Utility"); + } + xw.EndElement(); // ConfigurationType + xw.StartElement("CharacterSet"); + xw.Content("MultiByte"); + xw.EndElement(); // CharacterSet + if (this->IsNsightTegra()) { + xw.StartElement("NdkToolchainVersion"); + xw.Content(this->GetPlatformToolsetString()); + xw.EndElement(); // NdkToolchainVersion + } else { + xw.StartElement("PlatformToolset"); + xw.Content(this->GetPlatformToolsetString()); + xw.EndElement(); // PlatformToolset + } + xw.EndElement(); // PropertyGroup + xw.StartElement("Import"); + xw.Attribute("Project", "$(VCTargetsPath)\\Microsoft.Cpp.props"); + xw.EndElement(); // Import + xw.StartElement("ItemDefinitionGroup"); + xw.StartElement("PostBuildEvent"); + xw.StartElement("Command"); + xw.Content("echo VCTargetsPath=$(VCTargetsPath)"); + xw.EndElement(); // Command + xw.EndElement(); // PostBuildEvent + xw.EndElement(); // ItemDefinitionGroup + xw.StartElement("Import"); + xw.Attribute("Project", + "$(VCTargetsPath)\\Microsoft.Cpp.targets"); + xw.EndElement(); // Import + xw.EndElement(); // Project + xw.EndDocument(); + /* clang-format on */ + } + + std::vector<std::string> cmd; + cmd.push_back(this->GetMSBuildCommand()); + cmd.push_back(vcxproj); + cmd.push_back(std::string("/p:VisualStudioVersion=") + + this->GetIDEVersion()); + std::string out; + int ret = 0; + cmsys::RegularExpression regex("\n *VCTargetsPath=([^%\r\n]+)[\r\n]"); + if (!cmSystemTools::RunSingleCommand(cmd, &out, &out, &ret, wd.c_str(), + cmSystemTools::OUTPUT_NONE) || + ret != 0 || !regex.find(out)) { + cmSystemTools::ReplaceString(out, "\n", "\n "); + std::ostringstream e; + /* clang-format off */ + e << + "Failed to run MSBuild command:\n" + " " << cmd[0] << "\n" + "to get the value of VCTargetsPath:\n" + " " << out << "\n" + ; + /* clang-format on */ + if (ret != 0) { + e << "Exit code: " << ret << "\n"; + } + mf->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + cmSystemTools::SetFatalErrorOccured(); + return false; + } + this->VCTargetsPath = regex.match(1); + cmSystemTools::ConvertToUnixSlashes(this->VCTargetsPath); + + { + cmsys::ofstream fout(txt.c_str()); + fout << this->VCTargetsPath << "\n"; + } + return true; +} + void cmGlobalVisualStudio10Generator::GenerateBuildCommand( std::vector<std::string>& makeCommand, const std::string& makeProgram, const std::string& projectName, const std::string& projectDir, @@ -656,6 +987,17 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetLinkFlagTable() const return (table != CM_NULLPTR) ? table : this->DefaultLinkFlagTable; } +cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCudaFlagTable() const +{ + return this->DefaultCudaFlagTable; +} + +cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCudaHostFlagTable() + const +{ + return this->DefaultCudaHostFlagTable; +} + cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetMasmFlagTable() const { cmIDEFlagTable const* table = this->ToolsetOptions.GetMasmFlagTable( @@ -663,3 +1005,8 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetMasmFlagTable() const return (table != CM_NULLPTR) ? table : this->DefaultMasmFlagTable; } + +cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetNasmFlagTable() const +{ + return this->DefaultNasmFlagTable; +} diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 5bfaf38..20f992a 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -23,7 +23,6 @@ public: virtual bool SetSystemName(std::string const& s, cmMakefile* mf); virtual bool SetGeneratorPlatform(std::string const& p, cmMakefile* mf); virtual bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf); - virtual bool ParseGeneratorToolset(std::string const& ts, cmMakefile* mf); virtual void GenerateBuildCommand( std::vector<std::string>& makeCommand, const std::string& makeProgram, @@ -43,6 +42,8 @@ public: cmMakefile*, bool optional); virtual void WriteSLNHeader(std::ostream& fout); + bool IsCudaEnabled() const { return this->CudaEnabled; } + /** Generating for Nsight Tegra VS plugin? */ bool IsNsightTegra() const; std::string GetNsightTegraVersion() const; @@ -54,6 +55,10 @@ public: /** The toolset host architecture name (e.g. x64 for 64-bit host tools). */ const char* GetPlatformToolsetHostArchitecture() const; + /** The cuda toolset version. */ + const char* GetPlatformToolsetCuda() const; + std::string const& GetPlatformToolsetCudaString() const; + /** Return the CMAKE_SYSTEM_NAME. */ std::string const& GetSystemName() const { return this->SystemName; } @@ -95,7 +100,10 @@ public: cmIDEFlagTable const* GetRcFlagTable() const; cmIDEFlagTable const* GetLibFlagTable() const; cmIDEFlagTable const* GetLinkFlagTable() const; + cmIDEFlagTable const* GetCudaFlagTable() const; + cmIDEFlagTable const* GetCudaHostFlagTable() const; cmIDEFlagTable const* GetMasmFlagTable() const; + cmIDEFlagTable const* GetNasmFlagTable() const; protected: virtual void Generate(); @@ -105,6 +113,9 @@ protected: virtual bool InitializeWindowsPhone(cmMakefile* mf); virtual bool InitializeWindowsStore(cmMakefile* mf); + virtual bool ProcessGeneratorToolsetField(std::string const& key, + std::string const& value); + virtual std::string SelectWindowsCEToolset() const; virtual bool SelectWindowsPhoneToolset(std::string& toolset) const; virtual bool SelectWindowsStoreToolset(std::string& toolset) const; @@ -115,6 +126,7 @@ protected: std::string GeneratorToolset; std::string GeneratorToolsetHostArchitecture; + std::string GeneratorToolsetCuda; std::string DefaultPlatformToolset; std::string WindowsTargetPlatformVersion; std::string SystemName; @@ -124,7 +136,10 @@ protected: cmIDEFlagTable const* DefaultCSharpFlagTable; cmIDEFlagTable const* DefaultLibFlagTable; cmIDEFlagTable const* DefaultLinkFlagTable; + cmIDEFlagTable const* DefaultCudaFlagTable; + cmIDEFlagTable const* DefaultCudaHostFlagTable; cmIDEFlagTable const* DefaultMasmFlagTable; + cmIDEFlagTable const* DefaultNasmFlagTable; cmIDEFlagTable const* DefaultRcFlagTable; bool SystemIsWindowsCE; bool SystemIsWindowsPhone; @@ -154,6 +169,13 @@ private: virtual std::string FindDevEnvCommand(); virtual std::string GetVSMakeProgram() { return this->GetMSBuildCommand(); } + bool ParseGeneratorToolset(std::string const& ts, cmMakefile* mf); + + std::string VCTargetsPath; + bool FindVCTargetsPath(cmMakefile* mf); + + bool CudaEnabled; + // We do not use the reload macros for VS >= 10. virtual std::string GetUserMacrosDirectory() { return ""; } }; diff --git a/Source/cmGlobalVisualStudio11Generator.h b/Source/cmGlobalVisualStudio11Generator.h index ae99408..b4b327d 100644 --- a/Source/cmGlobalVisualStudio11Generator.h +++ b/Source/cmGlobalVisualStudio11Generator.h @@ -3,7 +3,7 @@ #ifndef cmGlobalVisualStudio11Generator_h #define cmGlobalVisualStudio11Generator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <iosfwd> #include <set> diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx index 2656dcc..de62ff0 100644 --- a/Source/cmGlobalVisualStudio12Generator.cxx +++ b/Source/cmGlobalVisualStudio12Generator.cxx @@ -109,19 +109,15 @@ bool cmGlobalVisualStudio12Generator::MatchesGeneratorName( return false; } -bool cmGlobalVisualStudio12Generator::ParseGeneratorToolset( - std::string const& ts, cmMakefile* mf) +bool cmGlobalVisualStudio12Generator::ProcessGeneratorToolsetField( + std::string const& key, std::string const& value) { - std::string::size_type ts_end = ts.size(); - if (cmHasLiteralSuffix(ts, ",host=x64")) { + if (key == "host" && value == "x64") { this->GeneratorToolsetHostArchitecture = "x64"; - ts_end -= 9; - } else if (ts == "host=x64") { - this->GeneratorToolsetHostArchitecture = "x64"; - ts_end = 0; + return true; } - return this->cmGlobalVisualStudio11Generator::ParseGeneratorToolset( - ts.substr(0, ts_end), mf); + return this->cmGlobalVisualStudio11Generator::ProcessGeneratorToolsetField( + key, value); } bool cmGlobalVisualStudio12Generator::InitializeWindowsPhone(cmMakefile* mf) diff --git a/Source/cmGlobalVisualStudio12Generator.h b/Source/cmGlobalVisualStudio12Generator.h index 79efe52..ebc95bb 100644 --- a/Source/cmGlobalVisualStudio12Generator.h +++ b/Source/cmGlobalVisualStudio12Generator.h @@ -3,7 +3,7 @@ #ifndef cmGlobalVisualStudio12Generator_h #define cmGlobalVisualStudio12Generator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <iosfwd> #include <string> @@ -31,8 +31,8 @@ public: // version number virtual const char* GetToolsVersion() { return "12.0"; } protected: - bool ParseGeneratorToolset(std::string const& ts, - cmMakefile* mf) CM_OVERRIDE; + bool ProcessGeneratorToolsetField(std::string const& key, + std::string const& value) CM_OVERRIDE; virtual bool InitializeWindowsPhone(cmMakefile* mf); virtual bool InitializeWindowsStore(cmMakefile* mf); diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx index 81c305c..df086d3 100644 --- a/Source/cmGlobalVisualStudio14Generator.cxx +++ b/Source/cmGlobalVisualStudio14Generator.cxx @@ -217,29 +217,48 @@ struct NoWindowsH std::string cmGlobalVisualStudio14Generator::GetWindows10SDKVersion() { #if defined(_WIN32) && !defined(__CYGWIN__) - // This logic is taken from the vcvarsqueryregistry.bat file from VS2015 - // Try HKLM and then HKCU. - std::string win10Root; - if (!cmSystemTools::ReadRegistryValue( - "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\" - "Windows Kits\\Installed Roots;KitsRoot10", - win10Root, cmSystemTools::KeyWOW64_32) && - !cmSystemTools::ReadRegistryValue( - "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\" - "Windows Kits\\Installed Roots;KitsRoot10", - win10Root, cmSystemTools::KeyWOW64_32)) { + std::vector<std::string> win10Roots; + + { + std::string win10Root; + if (cmSystemTools::GetEnv("CMAKE_WINDOWS_KITS_10_DIR", win10Root)) { + cmSystemTools::ConvertToUnixSlashes(win10Root); + win10Roots.push_back(win10Root); + } + } + + { + // This logic is taken from the vcvarsqueryregistry.bat file from VS2015 + // Try HKLM and then HKCU. + std::string win10Root; + if (cmSystemTools::ReadRegistryValue( + "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\" + "Windows Kits\\Installed Roots;KitsRoot10", + win10Root, cmSystemTools::KeyWOW64_32) || + cmSystemTools::ReadRegistryValue( + "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\" + "Windows Kits\\Installed Roots;KitsRoot10", + win10Root, cmSystemTools::KeyWOW64_32)) { + cmSystemTools::ConvertToUnixSlashes(win10Root); + win10Roots.push_back(win10Root); + } + } + + if (win10Roots.empty()) { return std::string(); } std::vector<std::string> sdks; - std::string path = win10Root + "Include/*"; // Grab the paths of the different SDKs that are installed - cmSystemTools::GlobDirs(path, sdks); + for (std::vector<std::string>::iterator i = win10Roots.begin(); + i != win10Roots.end(); ++i) { + std::string path = *i + "/Include/*"; + cmSystemTools::GlobDirs(path, sdks); + } // Skip SDKs that do not contain <um/windows.h> because that indicates that // only the UCRT MSIs were installed for them. - sdks.erase(std::remove_if(sdks.begin(), sdks.end(), NoWindowsH()), - sdks.end()); + cmEraseIf(sdks, NoWindowsH()); if (!sdks.empty()) { // Only use the filename, which will be the SDK version. diff --git a/Source/cmGlobalVisualStudio14Generator.h b/Source/cmGlobalVisualStudio14Generator.h index ab22978..0ce9a56 100644 --- a/Source/cmGlobalVisualStudio14Generator.h +++ b/Source/cmGlobalVisualStudio14Generator.h @@ -3,7 +3,7 @@ #ifndef cmGlobalVisualStudio14Generator_h #define cmGlobalVisualStudio14Generator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <iosfwd> #include <string> diff --git a/Source/cmGlobalVisualStudio15Generator.h b/Source/cmGlobalVisualStudio15Generator.h index f979b65..4be88f4 100644 --- a/Source/cmGlobalVisualStudio15Generator.h +++ b/Source/cmGlobalVisualStudio15Generator.h @@ -3,7 +3,7 @@ #ifndef cmGlobalVisualStudio15Generator_h #define cmGlobalVisualStudio15Generator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <iosfwd> #include <string> diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index 55a788f..aeceb8d 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -13,58 +13,6 @@ cmGlobalVisualStudio71Generator::cmGlobalVisualStudio71Generator( : cmGlobalVisualStudio7Generator(cm, platformName) { this->ProjectConfigurationSectionName = "ProjectConfiguration"; - this->Version = VS71; -} - -std::string cmGlobalVisualStudio71Generator::GetUserMacrosDirectory() -{ - // Macros not supported on Visual Studio 7.1 and earlier because - // they do not appear to work *during* a build when called by an - // outside agent... - // - return ""; - -#if 0 - // - // The COM result from calling a Visual Studio macro with 7.1 indicates - // that the call succeeds, but the macro does not appear to execute... - // - // So, I am leaving this code here to show how to do it, but have not - // yet figured out what the issue is in terms of why the macro does not - // appear to execute... - // - std::string base; - std::string path; - - // base begins with the VisualStudioProjectsLocation reg value... - if (cmSystemTools::ReadRegistryValue( - "HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\7.1;" - "VisualStudioProjectsLocation", - base)) - { - cmSystemTools::ConvertToUnixSlashes(base); - - // 7.1 macros folder: - path = base + "/VSMacros71"; - } - - // path is (correctly) still empty if we did not read the base value from - // the Registry value - return path; -#endif -} - -std::string cmGlobalVisualStudio71Generator::GetUserMacrosRegKeyBase() -{ - // Macros not supported on Visual Studio 7.1 and earlier because - // they do not appear to work *during* a build when called by an - // outside agent... - // - return ""; - -#if 0 - return "Software\\Microsoft\\VisualStudio\\7.1\\vsmacros"; -#endif } void cmGlobalVisualStudio71Generator::WriteSLNFile( @@ -91,11 +39,6 @@ void cmGlobalVisualStudio71Generator::WriteSLNFile( std::ostringstream targetsSlnString; this->WriteTargetsToSolution(targetsSlnString, root, orderedProjectTargets); - // VS 7 does not support folders specified first. - if (this->GetVersion() <= VS71) { - fout << targetsSlnString.str(); - } - // Generate folder specification. bool useFolderProperty = this->UseFolderProperty(); if (useFolderProperty) { @@ -103,9 +46,7 @@ void cmGlobalVisualStudio71Generator::WriteSLNFile( } // Now write the actual target specification content. - if (this->GetVersion() > VS71) { - fout << targetsSlnString.str(); - } + fout << targetsSlnString.str(); // Write out the configurations information for the solution fout << "Global\n"; @@ -249,7 +190,7 @@ void cmGlobalVisualStudio71Generator::WriteExternalProject( // Write a dsp file into the SLN file, Note, that dependencies from // executables to the libraries it uses are also done here void cmGlobalVisualStudio71Generator::WriteProjectConfigurations( - std::ostream& fout, const std::string& name, cmStateEnums::TargetType, + std::ostream& fout, const std::string& name, cmGeneratorTarget const& target, std::vector<std::string> const& configs, const std::set<std::string>& configsPartOfDefaultBuild, std::string const& platformMapping) @@ -259,13 +200,18 @@ void cmGlobalVisualStudio71Generator::WriteProjectConfigurations( std::string guid = this->GetGUID(name); for (std::vector<std::string>::const_iterator i = configs.begin(); i != configs.end(); ++i) { - fout << "\t\t{" << guid << "}." << *i << ".ActiveCfg = " << *i << "|" - << platformName << std::endl; + const char* dstConfig = target.GetProperty("MAP_IMPORTED_CONFIG_" + + cmSystemTools::UpperCase(*i)); + if (dstConfig == CM_NULLPTR) { + dstConfig = i->c_str(); + } + fout << "\t\t{" << guid << "}." << *i << ".ActiveCfg = " << dstConfig + << "|" << platformName << std::endl; std::set<std::string>::const_iterator ci = configsPartOfDefaultBuild.find(*i); if (!(ci == configsPartOfDefaultBuild.end())) { - fout << "\t\t{" << guid << "}." << *i << ".Build.0 = " << *i << "|" - << platformName << std::endl; + fout << "\t\t{" << guid << "}." << *i << ".Build.0 = " << dstConfig + << "|" << platformName << std::endl; } } } @@ -275,10 +221,3 @@ void cmGlobalVisualStudio71Generator::WriteSLNHeader(std::ostream& fout) { fout << "Microsoft Visual Studio Solution File, Format Version 8.00\n"; } - -void cmGlobalVisualStudio71Generator::GetDocumentation( - cmDocumentationEntry& entry) -{ - entry.Name = cmGlobalVisualStudio71Generator::GetActualName(); - entry.Brief = "Deprecated. Generates Visual Studio .NET 2003 project files."; -} diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h index 9953047..0ce02aa 100644 --- a/Source/cmGlobalVisualStudio71Generator.h +++ b/Source/cmGlobalVisualStudio71Generator.h @@ -15,37 +15,8 @@ class cmGlobalVisualStudio71Generator : public cmGlobalVisualStudio7Generator public: cmGlobalVisualStudio71Generator(cmake* cm, const std::string& platformName = ""); - static cmGlobalGeneratorFactory* NewFactory() - { - return new cmGlobalGeneratorSimpleFactory< - cmGlobalVisualStudio71Generator>(); - } - - ///! Get the name for the generator. - virtual std::string GetName() const - { - return cmGlobalVisualStudio71Generator::GetActualName(); - } - static std::string GetActualName() { return "Visual Studio 7 .NET 2003"; } - - /** Get the documentation entry for this generator. */ - static void GetDocumentation(cmDocumentationEntry& entry); - - /** - * Where does this version of Visual Studio look for macros for the - * current user? Returns the empty string if this version of Visual - * Studio does not implement support for VB macros. - */ - virtual std::string GetUserMacrosDirectory(); - - /** - * What is the reg key path to "vsmacros" for this version of Visual - * Studio? - */ - virtual std::string GetUserMacrosRegKeyBase(); protected: - virtual const char* GetIDEVersion() { return "7.1"; } virtual void WriteSLNFile(std::ostream& fout, cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators); virtual void WriteSolutionConfigurations( @@ -56,8 +27,8 @@ protected: const char* path, cmGeneratorTarget const* t); virtual void WriteProjectConfigurations( - std::ostream& fout, const std::string& name, cmStateEnums::TargetType type, - std::vector<std::string> const& configs, + std::ostream& fout, const std::string& name, + cmGeneratorTarget const& target, std::vector<std::string> const& configs, const std::set<std::string>& configsPartOfDefaultBuild, const std::string& platformMapping = ""); virtual void WriteExternalProject(std::ostream& fout, diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 602666e..1b75a08 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -1,7 +1,5 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#include "windows.h" // this must be first to define GetCurrentDirectory - #include "cmGlobalVisualStudio7Generator.h" #include "cmGeneratedFileStream.h" @@ -11,9 +9,10 @@ #include "cmState.h" #include "cmUuid.h" #include "cmake.h" -#include <cmsys/Encoding.hxx> +#include "cmsys/Encoding.hxx" #include <assert.h> +#include <windows.h> static cmVS7FlagTable cmVS7ExtraFlagTable[] = { // Precompiled header and related options. Note that the @@ -47,6 +46,7 @@ cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator( this->IntelProjectVersion = 0; this->DevEnvCommandInitialized = false; this->MasmEnabled = false; + this->NasmEnabled = false; if (platformName.empty()) { this->DefaultPlatformName = "Win32"; @@ -54,7 +54,6 @@ cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator( this->DefaultPlatformName = platformName; } this->ExtraFlagTable = cmVS7ExtraFlagTable; - this->Version = VS7; } cmGlobalVisualStudio7Generator::~cmGlobalVisualStudio7Generator() @@ -295,16 +294,16 @@ void cmGlobalVisualStudio7Generator::Generate() this->CallVisualStudioMacro(MacroReload); } - if (this->Version == VS71 && !this->CMakeInstance->GetIsInTryCompile()) { - const char* cmakeWarnVS71 = - this->CMakeInstance->GetState()->GetCacheEntryValue("CMAKE_WARN_VS71"); - if (!cmakeWarnVS71 || !cmSystemTools::IsOff(cmakeWarnVS71)) { + if (this->Version == VS8 && !this->CMakeInstance->GetIsInTryCompile()) { + const char* cmakeWarnVS8 = + this->CMakeInstance->GetState()->GetCacheEntryValue("CMAKE_WARN_VS8"); + if (!cmakeWarnVS8 || !cmSystemTools::IsOff(cmakeWarnVS8)) { this->CMakeInstance->IssueMessage( cmake::WARNING, - "The \"Visual Studio 7 .NET 2003\" generator is deprecated " + "The \"Visual Studio 8 2005\" generator is deprecated " "and will be removed in a future version of CMake." "\n" - "Add CMAKE_WARN_VS71=OFF to the cache to disable this warning."); + "Add CMAKE_WARN_VS8=OFF to the cache to disable this warning."); } } } @@ -356,16 +355,16 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations( if (expath) { std::set<std::string> allConfigurations(configs.begin(), configs.end()); const char* mapping = target->GetProperty("VS_PLATFORM_MAPPING"); - this->WriteProjectConfigurations( - fout, target->GetName().c_str(), target->GetType(), configs, - allConfigurations, mapping ? mapping : ""); + this->WriteProjectConfigurations(fout, target->GetName().c_str(), + *target, configs, allConfigurations, + mapping ? mapping : ""); } else { const std::set<std::string>& configsPartOfDefaultBuild = this->IsPartOfDefaultBuild(configs, projectTargets, target); const char* vcprojName = target->GetProperty("GENERATOR_FILE_NAME"); if (vcprojName) { - this->WriteProjectConfigurations(fout, vcprojName, target->GetType(), - configs, configsPartOfDefaultBuild); + this->WriteProjectConfigurations(fout, vcprojName, *target, configs, + configsPartOfDefaultBuild); } } } diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 62194c3..32a8d60 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -95,6 +95,7 @@ public: /** Is the Microsoft Assembler enabled? */ bool IsMasmEnabled() const { return this->MasmEnabled; } + bool IsNasmEnabled() const { return this->NasmEnabled; } // Encoding for Visual Studio files virtual std::string Encoding(); @@ -120,8 +121,8 @@ protected: const char* path, cmGeneratorTarget const* t) = 0; virtual void WriteProjectConfigurations( - std::ostream& fout, const std::string& name, cmStateEnums::TargetType type, - std::vector<std::string> const& configs, + std::ostream& fout, const std::string& name, + cmGeneratorTarget const& target, std::vector<std::string> const& configs, const std::set<std::string>& configsPartOfDefaultBuild, const std::string& platformMapping = "") = 0; virtual void WriteSLNGlobalSections(std::ostream& fout, @@ -163,6 +164,7 @@ protected: std::string GeneratorPlatform; std::string DefaultPlatformName; bool MasmEnabled; + bool NasmEnabled; private: char* IntelProjectVersion; diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 8353a3f..7a42b72 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -54,7 +54,7 @@ public: void GetDocumentation(cmDocumentationEntry& entry) const CM_OVERRIDE { entry.Name = std::string(vs8generatorName) + " [arch]"; - entry.Brief = "Generates Visual Studio 2005 project files. " + entry.Brief = "Deprecated. Generates Visual Studio 2005 project files. " "Optional [arch] can be \"Win64\"."; } @@ -153,13 +153,6 @@ void cmGlobalVisualStudio8Generator::WriteSLNHeader(std::ostream& fout) fout << "# Visual Studio 2005\n"; } -void cmGlobalVisualStudio8Generator::GetDocumentation( - cmDocumentationEntry& entry) -{ - entry.Name = cmGlobalVisualStudio8Generator::GetActualName(); - entry.Brief = "Generates Visual Studio 8 2005 project files."; -} - std::string cmGlobalVisualStudio8Generator::GetGenerateStampList() { return "generate.stamp.list"; @@ -353,7 +346,7 @@ void cmGlobalVisualStudio8Generator::WriteSolutionConfigurations( } void cmGlobalVisualStudio8Generator::WriteProjectConfigurations( - std::ostream& fout, const std::string& name, cmStateEnums::TargetType type, + std::ostream& fout, const std::string& name, cmGeneratorTarget const& target, std::vector<std::string> const& configs, const std::set<std::string>& configsPartOfDefaultBuild, std::string const& platformMapping) @@ -361,8 +354,13 @@ void cmGlobalVisualStudio8Generator::WriteProjectConfigurations( std::string guid = this->GetGUID(name); for (std::vector<std::string>::const_iterator i = configs.begin(); i != configs.end(); ++i) { + const char* dstConfig = target.GetProperty("MAP_IMPORTED_CONFIG_" + + cmSystemTools::UpperCase(*i)); + if (dstConfig == CM_NULLPTR) { + dstConfig = i->c_str(); + } fout << "\t\t{" << guid << "}." << *i << "|" << this->GetPlatformName() - << ".ActiveCfg = " << *i << "|" + << ".ActiveCfg = " << dstConfig << "|" << (!platformMapping.empty() ? platformMapping : this->GetPlatformName()) << "\n"; @@ -370,14 +368,14 @@ void cmGlobalVisualStudio8Generator::WriteProjectConfigurations( configsPartOfDefaultBuild.find(*i); if (!(ci == configsPartOfDefaultBuild.end())) { fout << "\t\t{" << guid << "}." << *i << "|" << this->GetPlatformName() - << ".Build.0 = " << *i << "|" + << ".Build.0 = " << dstConfig << "|" << (!platformMapping.empty() ? platformMapping : this->GetPlatformName()) << "\n"; } - if (this->NeedsDeploy(type)) { + if (this->NeedsDeploy(target.GetType())) { fout << "\t\t{" << guid << "}." << *i << "|" << this->GetPlatformName() - << ".Deploy.0 = " << *i << "|" + << ".Deploy.0 = " << dstConfig << "|" << (!platformMapping.empty() ? platformMapping : this->GetPlatformName()) << "\n"; diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h index 53feb47..4723b83 100644 --- a/Source/cmGlobalVisualStudio8Generator.h +++ b/Source/cmGlobalVisualStudio8Generator.h @@ -20,9 +20,6 @@ public: ///! Get the name for the generator. virtual std::string GetName() const { return this->Name; } - /** Get the documentation entry for this generator. */ - static void GetDocumentation(cmDocumentationEntry& entry); - /** Get the name of the main stamp list file. */ static std::string GetGenerateStampList(); @@ -82,8 +79,8 @@ protected: virtual void WriteSolutionConfigurations( std::ostream& fout, std::vector<std::string> const& configs); virtual void WriteProjectConfigurations( - std::ostream& fout, const std::string& name, cmStateEnums::TargetType type, - std::vector<std::string> const& configs, + std::ostream& fout, const std::string& name, + cmGeneratorTarget const& target, std::vector<std::string> const& configs, const std::set<std::string>& configsPartOfDefaultBuild, const std::string& platformMapping = ""); virtual bool ComputeTargetDepends(); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index ced0c26..87a22d1 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -3,8 +3,9 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmGlobalVisualStudioGenerator.h" -#include <cmsys/Encoding.hxx> +#include "cmsys/Encoding.hxx" #include <iostream> +#include <windows.h> #include "cmAlgorithms.h" #include "cmCallVisualStudioMacro.h" @@ -19,6 +20,7 @@ cmGlobalVisualStudioGenerator::cmGlobalVisualStudioGenerator(cmake* cm) : cmGlobalGenerator(cm) { + cm->GetState()->SetIsGeneratorMultiConfig(true); cm->GetState()->SetWindowsShell(true); cm->GetState()->SetWindowsVSIDE(true); } @@ -441,8 +443,6 @@ std::string cmGlobalVisualStudioGenerator::GetStartupProjectName( return this->GetAllTargetName(); } -#include <windows.h> - bool IsVisualStudioMacrosFileRegistered(const std::string& macrosFile, const std::string& regKeyBase, std::string& nextAvailableSubKeyName) @@ -730,12 +730,26 @@ bool cmGlobalVisualStudioGenerator::TargetIsFortranOnly( return false; } } + // If there's only one source language, Fortran has to be used + // in order for the sources to compile. + // Note: Via linker propagation, LINKER_LANGUAGE could become CXX in + // this situation and mismatch from the actual language of the linker. gt->GetLanguages(languages, ""); if (languages.size() == 1) { if (*languages.begin() == "Fortran") { return true; } } + + // In the case of mixed object files or sources mixed with objects, + // decide the language based on the value of LINKER_LANGUAGE. + // This will not make it possible to mix source files of different + // languages, but object libraries will be linked together in the + // same fashion as other generators do. + if (gt->GetLinkerLanguage("") == "Fortran") { + return true; + } + return false; } @@ -814,10 +828,14 @@ void cmGlobalVisualStudioGenerator::AddSymbolExportCommand( cmGeneratorTarget* gt, std::vector<cmCustomCommand>& commands, std::string const& configName) { + cmGeneratorTarget::ModuleDefinitionInfo const* mdi = + gt->GetModuleDefinitionInfo(configName); + if (!mdi || !mdi->DefFileGenerated) { + return; + } + std::vector<std::string> outputs; - std::string deffile = gt->ObjectDirectory; - deffile += "/exportall.def"; - outputs.push_back(deffile); + outputs.push_back(mdi->DefFile); std::vector<std::string> empty; std::vector<cmSourceFile const*> objectSources; gt->GetObjectSources(objectSources, configName); @@ -835,50 +853,58 @@ void cmGlobalVisualStudioGenerator::AddSymbolExportCommand( cmdl.push_back(cmakeCommand); cmdl.push_back("-E"); cmdl.push_back("__create_def"); - cmdl.push_back(deffile); + cmdl.push_back(mdi->DefFile); std::string obj_dir_expanded = obj_dir; cmSystemTools::ReplaceString(obj_dir_expanded, this->GetCMakeCFGIntDir(), configName.c_str()); - std::string objs_file = obj_dir_expanded; - cmSystemTools::MakeDirectory(objs_file.c_str()); - objs_file += "/objects.txt"; + cmSystemTools::MakeDirectory(obj_dir_expanded); + std::string const objs_file = obj_dir_expanded + "/objects.txt"; cmdl.push_back(objs_file); cmGeneratedFileStream fout(objs_file.c_str()); if (!fout) { cmSystemTools::Error("could not open ", objs_file.c_str()); return; } - std::vector<std::string> objs; - for (std::vector<cmSourceFile const*>::const_iterator it = - objectSources.begin(); - it != objectSources.end(); ++it) { - // Find the object file name corresponding to this source file. - std::map<cmSourceFile const*, std::string>::const_iterator map_it = - mapping.find(*it); - // It must exist because we populated the mapping just above. - assert(!map_it->second.empty()); - std::string objFile = obj_dir + map_it->second; - objs.push_back(objFile); - } - std::vector<cmSourceFile const*> externalObjectSources; - gt->GetExternalObjects(externalObjectSources, configName); - for (std::vector<cmSourceFile const*>::const_iterator it = - externalObjectSources.begin(); - it != externalObjectSources.end(); ++it) { - objs.push_back((*it)->GetFullPath()); - } - gt->UseObjectLibraries(objs, configName); - for (std::vector<std::string>::iterator it = objs.begin(); it != objs.end(); - ++it) { - std::string objFile = *it; - // replace $(ConfigurationName) in the object names - cmSystemTools::ReplaceString(objFile, this->GetCMakeCFGIntDir(), - configName.c_str()); - if (cmHasLiteralSuffix(objFile, ".obj")) { - fout << objFile << "\n"; + if (mdi->WindowsExportAllSymbols) { + std::vector<std::string> objs; + for (std::vector<cmSourceFile const*>::const_iterator it = + objectSources.begin(); + it != objectSources.end(); ++it) { + // Find the object file name corresponding to this source file. + std::map<cmSourceFile const*, std::string>::const_iterator map_it = + mapping.find(*it); + // It must exist because we populated the mapping just above. + assert(!map_it->second.empty()); + std::string objFile = obj_dir + map_it->second; + objs.push_back(objFile); + } + std::vector<cmSourceFile const*> externalObjectSources; + gt->GetExternalObjects(externalObjectSources, configName); + for (std::vector<cmSourceFile const*>::const_iterator it = + externalObjectSources.begin(); + it != externalObjectSources.end(); ++it) { + objs.push_back((*it)->GetFullPath()); + } + + for (std::vector<std::string>::iterator it = objs.begin(); + it != objs.end(); ++it) { + std::string objFile = *it; + // replace $(ConfigurationName) in the object names + cmSystemTools::ReplaceString(objFile, this->GetCMakeCFGIntDir(), + configName.c_str()); + if (cmHasLiteralSuffix(objFile, ".obj")) { + fout << objFile << "\n"; + } } } + + for (std::vector<cmSourceFile const*>::const_iterator i = + mdi->Sources.begin(); + i != mdi->Sources.end(); ++i) { + fout << (*i)->GetFullPath() << "\n"; + } + cmCustomCommandLines commandLines; commandLines.push_back(cmdl); cmCustomCommand command(gt->Target->GetMakefile(), outputs, empty, empty, diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index f32f0bb..c12a933 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -3,7 +3,7 @@ #ifndef cmGlobalVisualStudioGenerator_h #define cmGlobalVisualStudioGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <iosfwd> #include <map> @@ -32,8 +32,6 @@ public: /** Known versions of Visual Studio. */ enum VSVersion { - VS7 = 70, - VS71 = 71, VS8 = 80, VS9 = 90, VS10 = 100, diff --git a/Source/cmGlobalWatcomWMakeGenerator.h b/Source/cmGlobalWatcomWMakeGenerator.h index 1c290f8..b2d6d5d 100644 --- a/Source/cmGlobalWatcomWMakeGenerator.h +++ b/Source/cmGlobalWatcomWMakeGenerator.h @@ -3,7 +3,7 @@ #ifndef cmGlobalWatcomWMakeGenerator_h #define cmGlobalWatcomWMakeGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmGlobalGeneratorFactory.h" #include "cmGlobalUnixMakefileGenerator3.h" diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index dd771b1..6636329 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2,8 +2,8 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmGlobalXCodeGenerator.h" +#include "cmsys/RegularExpression.hxx" #include <assert.h> -#include <cmsys/RegularExpression.hxx> #include <iomanip> #include <sstream> #include <stdio.h> @@ -28,6 +28,7 @@ #include "cmTarget.h" #include "cmXCode21Object.h" #include "cmXCodeObject.h" +#include "cmXCodeScheme.h" #include "cm_auto_ptr.hxx" #include "cmake.h" @@ -132,16 +133,12 @@ public: bool SupportsPlatform() const CM_OVERRIDE { return false; } }; -cmGlobalXCodeGenerator::cmGlobalXCodeGenerator(cmake* cm, - std::string const& version) +cmGlobalXCodeGenerator::cmGlobalXCodeGenerator( + cmake* cm, std::string const& version_string, unsigned int version_number) : cmGlobalGenerator(cm) { - this->VersionString = version; - - // Compute an integer form of the version number. - unsigned int v[2] = { 0, 0 }; - sscanf(this->VersionString.c_str(), "%u.%u", &v[0], &v[1]); - this->XcodeVersion = 10 * v[0] + v[1]; + this->VersionString = version_string; + this->XcodeVersion = version_number; this->RootObject = 0; this->MainGroupChildren = 0; @@ -150,6 +147,11 @@ cmGlobalXCodeGenerator::cmGlobalXCodeGenerator(cmake* cm, this->CurrentMakefile = 0; this->CurrentLocalGenerator = 0; this->XcodeBuildCommandInitialized = false; + + this->ObjectDirArchDefault = "$(CURRENT_ARCH)"; + this->ComputeObjectDirArch(); + + cm->GetState()->SetIsGeneratorMultiConfig(true); } cmGlobalGeneratorFactory* cmGlobalXCodeGenerator::NewFactory() @@ -183,13 +185,21 @@ cmGlobalGenerator* cmGlobalXCodeGenerator::Factory::CreateGlobalGenerator( parser.ParseFile( "/Developer/Applications/Xcode.app/Contents/version.plist"); } - CM_AUTO_PTR<cmGlobalXCodeGenerator> gg( - new cmGlobalXCodeGenerator(cm, parser.Version)); - if (gg->XcodeVersion == 20) { - cmSystemTools::Message("Xcode 2.0 not really supported by cmake, " - "using Xcode 15 generator\n"); - gg->XcodeVersion = 15; + std::string const& version_string = parser.Version; + + // Compute an integer form of the version number. + unsigned int v[2] = { 0, 0 }; + sscanf(version_string.c_str(), "%u.%u", &v[0], &v[1]); + unsigned int version_number = 10 * v[0] + v[1]; + + if (version_number < 30) { + cm->IssueMessage(cmake::FATAL_ERROR, + "Xcode " + version_string + " not supported."); + return CM_NULLPTR; } + + CM_AUTO_PTR<cmGlobalXCodeGenerator> gg( + new cmGlobalXCodeGenerator(cm, version_string, version_number)); return gg.release(); #else std::cerr << "CMake should be built with cmake to use Xcode, " @@ -236,29 +246,25 @@ std::string cmGlobalXCodeGenerator::FindXcodeBuildCommand() bool cmGlobalXCodeGenerator::SetGeneratorToolset(std::string const& ts, cmMakefile* mf) { - if (this->XcodeVersion >= 30) { - if (ts.find_first_of(",=") != ts.npos) { - std::ostringstream e; - /* clang-format off */ - e << - "Generator\n" - " " << this->GetName() << "\n" - "does not recognize the toolset\n" - " " << ts << "\n" - "that was specified."; - /* clang-format on */ - mf->IssueMessage(cmake::FATAL_ERROR, e.str()); - return false; - } - this->GeneratorToolset = ts; - if (!this->GeneratorToolset.empty()) { - mf->AddDefinition("CMAKE_XCODE_PLATFORM_TOOLSET", - this->GeneratorToolset.c_str()); - } - return true; - } else { - return cmGlobalGenerator::SetGeneratorToolset(ts, mf); + if (ts.find_first_of(",=") != ts.npos) { + std::ostringstream e; + /* clang-format off */ + e << + "Generator\n" + " " << this->GetName() << "\n" + "does not recognize the toolset\n" + " " << ts << "\n" + "that was specified."; + /* clang-format on */ + mf->IssueMessage(cmake::FATAL_ERROR, e.str()); + return false; + } + this->GeneratorToolset = ts; + if (!this->GeneratorToolset.empty()) { + mf->AddDefinition("CMAKE_XCODE_PLATFORM_TOOLSET", + this->GeneratorToolset.c_str()); } + return true; } void cmGlobalXCodeGenerator::EnableLanguage( @@ -266,26 +272,17 @@ void cmGlobalXCodeGenerator::EnableLanguage( { mf->AddDefinition("XCODE", "1"); mf->AddDefinition("XCODE_VERSION", this->VersionString.c_str()); - if (this->XcodeVersion == 15) { - } else { - if (!mf->GetDefinition("CMAKE_CONFIGURATION_TYPES")) { - mf->AddCacheDefinition( - "CMAKE_CONFIGURATION_TYPES", "Debug;Release;MinSizeRel;RelWithDebInfo", - "Semicolon separated list of supported configuration types, " - "only supports Debug, Release, MinSizeRel, and RelWithDebInfo, " - "anything else will be ignored.", - cmStateEnums::STRING); - } + if (!mf->GetDefinition("CMAKE_CONFIGURATION_TYPES")) { + mf->AddCacheDefinition( + "CMAKE_CONFIGURATION_TYPES", "Debug;Release;MinSizeRel;RelWithDebInfo", + "Semicolon separated list of supported configuration types, " + "only supports Debug, Release, MinSizeRel, and RelWithDebInfo, " + "anything else will be ignored.", + cmStateEnums::STRING); } mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1"); this->cmGlobalGenerator::EnableLanguage(lang, mf, optional); - const char* osxArch = mf->GetDefinition("CMAKE_OSX_ARCHITECTURES"); - const char* sysroot = mf->GetDefinition("CMAKE_OSX_SYSROOT"); - if (osxArch && sysroot) { - this->Architectures.clear(); - cmSystemTools::ExpandListArgument(std::string(osxArch), - this->Architectures); - } + this->ComputeArchitectures(mf); } void cmGlobalXCodeGenerator::GenerateBuildCommand( @@ -301,9 +298,7 @@ void cmGlobalXCodeGenerator::GenerateBuildCommand( makeCommand.push_back("-project"); std::string projectArg = projectName; projectArg += ".xcode"; - if (this->XcodeVersion > 20) { - projectArg += "proj"; - } + projectArg += "proj"; makeCommand.push_back(projectArg); bool clean = false; @@ -323,13 +318,8 @@ void cmGlobalXCodeGenerator::GenerateBuildCommand( } else { makeCommand.push_back("ALL_BUILD"); } - if (this->XcodeVersion == 15) { - makeCommand.push_back("-buildstyle"); - makeCommand.push_back("Development"); - } else { - makeCommand.push_back("-configuration"); - makeCommand.push_back(!config.empty() ? config : "Debug"); - } + makeCommand.push_back("-configuration"); + makeCommand.push_back(!config.empty() ? config : "Debug"); makeCommand.insert(makeCommand.end(), makeOptions.begin(), makeOptions.end()); } @@ -391,9 +381,7 @@ std::string cmGlobalXCodeGenerator::PostBuildMakeTarget( std::string target = tName; std::replace(target.begin(), target.end(), ' ', '_'); std::string out = "PostBuild." + target; - if (this->XcodeVersion > 20) { - out += "." + configName; - } + out += "." + configName; return out; } @@ -423,14 +411,12 @@ void cmGlobalXCodeGenerator::AddExtraTargets( // Add XCODE depend helper std::string dir = root->GetCurrentBinaryDirectory(); cmCustomCommandLine makeHelper; - if (this->XcodeVersion < 50) { - makeHelper.push_back("make"); - makeHelper.push_back("-C"); - makeHelper.push_back(dir); - makeHelper.push_back("-f"); - makeHelper.push_back(this->CurrentXCodeHackMakefile); - makeHelper.push_back(""); // placeholder, see below - } + makeHelper.push_back("make"); + makeHelper.push_back("-C"); + makeHelper.push_back(dir); + makeHelper.push_back("-f"); + makeHelper.push_back(this->CurrentXCodeHackMakefile); + makeHelper.push_back(""); // placeholder, see below // Add ZERO_CHECK bool regenerate = !mf->IsOn("CMAKE_SUPPRESS_REGENERATION"); @@ -475,13 +461,12 @@ void cmGlobalXCodeGenerator::AddExtraTargets( // run the depend check makefile as a post build rule // this will make sure that when the next target is built // things are up-to-date - if (!makeHelper.empty() && - (target->GetType() == cmStateEnums::EXECUTABLE || - // Nope - no post-build for OBJECT_LIRBRARY - // target->GetType() == cmStateEnums::OBJECT_LIBRARY || - target->GetType() == cmStateEnums::STATIC_LIBRARY || - target->GetType() == cmStateEnums::SHARED_LIBRARY || - target->GetType() == cmStateEnums::MODULE_LIBRARY)) { + if (target->GetType() == cmStateEnums::OBJECT_LIBRARY || + (this->XcodeVersion < 50 && + (target->GetType() == cmStateEnums::EXECUTABLE || + target->GetType() == cmStateEnums::STATIC_LIBRARY || + target->GetType() == cmStateEnums::SHARED_LIBRARY || + target->GetType() == cmStateEnums::MODULE_LIBRARY))) { makeHelper[makeHelper.size() - 1] = // fill placeholder this->PostBuildMakeTarget(target->GetName(), "$(CONFIGURATION)"); cmCustomCommandLines commandLines; @@ -489,7 +474,8 @@ void cmGlobalXCodeGenerator::AddExtraTargets( std::vector<std::string> no_byproducts; lg->GetMakefile()->AddCustomCommandToTarget( target->GetName(), no_byproducts, no_depends, commandLines, - cmTarget::POST_BUILD, "Depend check for xcode", dir.c_str()); + cmTarget::POST_BUILD, "Depend check for xcode", dir.c_str(), true, + false, "", false, cmMakefile::AcceptObjectLibraryCommands); } if (target->GetType() != cmStateEnums::INTERFACE_LIBRARY && @@ -605,12 +591,7 @@ void cmGlobalXCodeGenerator::addObject(cmXCodeObject* obj) cmXCodeObject* cmGlobalXCodeGenerator::CreateObject( cmXCodeObject::PBXType ptype) { - cmXCodeObject* obj; - if (this->XcodeVersion == 15) { - obj = new cmXCodeObject(ptype, cmXCodeObject::OBJECT); - } else { - obj = new cmXCode21Object(ptype, cmXCodeObject::OBJECT); - } + cmXCodeObject* obj = new cmXCode21Object(ptype, cmXCodeObject::OBJECT); this->addObject(obj); return obj; } @@ -653,11 +634,6 @@ std::string GetGroupMapKeyFromPath(cmGeneratorTarget* target, return key; } -std::string GetGroupMapKey(cmGeneratorTarget* target, cmSourceFile* sf) -{ - return GetGroupMapKeyFromPath(target, sf->GetFullPath()); -} - cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFileFromPath( const std::string& fullpath, cmGeneratorTarget* target, const std::string& lang, cmSourceFile* sf) @@ -901,9 +877,6 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeFileReferenceFromPath( fileRef->AddAttribute("name", this->CreateString(name)); fileRef->AddAttribute("path", this->CreateString(path)); fileRef->AddAttribute("sourceTree", this->CreateString(sourceTree)); - if (this->XcodeVersion == 15) { - fileRef->AddAttribute("refType", this->CreateString("4")); - } return fileRef; } @@ -1053,11 +1026,14 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets( // Add object library contents as external objects. (Equivalent to // the externalObjFiles above, except each one is not a cmSourceFile // within the target.) - std::vector<std::string> objs; - gtgt->UseObjectLibraries(objs, ""); - for (std::vector<std::string>::const_iterator oi = objs.begin(); + std::vector<cmSourceFile const*> objs; + gtgt->GetExternalObjects(objs, ""); + for (std::vector<cmSourceFile const*>::const_iterator oi = objs.begin(); oi != objs.end(); ++oi) { - std::string obj = *oi; + if ((*oi)->GetObjectLibrary().empty()) { + continue; + } + std::string const& obj = (*oi)->GetFullPath(); cmXCodeObject* xsf = this->CreateXCodeSourceFileFromPath(obj, gtgt, "", 0); externalObjFiles.push_back(xsf); @@ -1155,8 +1131,12 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets( // dstPath in frameworks is relative to Versions/<version> ostr << mit->first; } else if (mit->first != "MacOS") { - // dstPath in bundles is relative to Contents/MacOS - ostr << "../" << mit->first.c_str(); + if (gtgt->Target->GetMakefile()->PlatformIsAppleIos()) { + ostr << mit->first; + } else { + // dstPath in bundles is relative to Contents/MacOS + ostr << "../" << mit->first; + } } copyFilesBuildPhase->AddAttribute("dstPath", this->CreateString(ostr.str())); @@ -1174,6 +1154,45 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets( } } + // create vector of "resource content file" build phases - only for + // framework or bundle targets + if (isFrameworkTarget || isBundleTarget || isCFBundleTarget) { + typedef std::map<std::string, std::vector<cmSourceFile*> > + mapOfVectorOfSourceFiles; + mapOfVectorOfSourceFiles bundleFiles; + for (std::vector<cmSourceFile*>::const_iterator i = classes.begin(); + i != classes.end(); ++i) { + cmGeneratorTarget::SourceFileFlags tsFlags = + gtgt->GetTargetSourceFileFlags(*i); + if (tsFlags.Type == cmGeneratorTarget::SourceFileTypeDeepResource) { + bundleFiles[tsFlags.MacFolder].push_back(*i); + } + } + mapOfVectorOfSourceFiles::iterator mit; + for (mit = bundleFiles.begin(); mit != bundleFiles.end(); ++mit) { + cmXCodeObject* copyFilesBuildPhase = + this->CreateObject(cmXCodeObject::PBXCopyFilesBuildPhase); + copyFilesBuildPhase->SetComment("Copy files"); + copyFilesBuildPhase->AddAttribute("buildActionMask", + this->CreateString("2147483647")); + copyFilesBuildPhase->AddAttribute("dstSubfolderSpec", + this->CreateString("7")); + copyFilesBuildPhase->AddAttribute("dstPath", + this->CreateString(mit->first)); + copyFilesBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing", + this->CreateString("0")); + buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST); + copyFilesBuildPhase->AddAttribute("files", buildFiles); + std::vector<cmSourceFile*>::iterator sfIt; + for (sfIt = mit->second.begin(); sfIt != mit->second.end(); ++sfIt) { + cmXCodeObject* xsf = this->CreateXCodeSourceFile( + this->CurrentLocalGenerator, *sfIt, gtgt); + buildFiles->AddObject(xsf); + } + contentBuildPhases.push_back(copyFilesBuildPhase); + } + } + // create framework build phase cmXCodeObject* frameworkBuildPhase = 0; if (!externalObjFiles.empty()) { @@ -1522,9 +1541,7 @@ void cmGlobalXCodeGenerator::CreateCustomRulesMakefile( std::vector<cmCustomCommand> const& commands, const std::string& configName) { std::string makefileName = makefileBasename; - if (this->XcodeVersion > 20) { - makefileName += configName; - } + makefileName += configName; cmGeneratedFileStream makefileStream(makefileName.c_str()); if (!makefileStream) { return; @@ -1665,16 +1682,17 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, return; } + // Check IPO related warning/error. + gtgt->IsIPOEnabled(configName); + // Add define flags this->CurrentLocalGenerator->AppendFlags( defFlags, this->CurrentMakefile->GetDefineFlags()); // Add preprocessor definitions for this target and configuration. - BuildObjectListOrString ppDefs(this, this->XcodeVersion >= 30); - if (this->XcodeVersion > 15) { - this->AppendDefines( - ppDefs, "CMAKE_INTDIR=\"$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)\""); - } + BuildObjectListOrString ppDefs(this, true); + this->AppendDefines( + ppDefs, "CMAKE_INTDIR=\"$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)\""); if (const char* exportMacro = gtgt->GetExportMacro()) { // Add the export symbol definition for shared library objects. this->AppendDefines(ppDefs, exportMacro); @@ -1774,15 +1792,11 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, gtgt->GetType() == cmStateEnums::SHARED_LIBRARY || gtgt->GetType() == cmStateEnums::MODULE_LIBRARY || gtgt->GetType() == cmStateEnums::EXECUTABLE) { - if (this->XcodeVersion >= 21) { - if (!gtgt->UsesDefaultOutputDir(configName, false)) { - std::string pncdir = gtgt->GetDirectory(configName); - buildSettings->AddAttribute("CONFIGURATION_BUILD_DIR", - this->CreateString(pncdir)); - } - } else { - buildSettings->AddAttribute("OBJROOT", this->CreateString(pndir)); - pndir = gtgt->GetDirectory(configName); + if (!gtgt->UsesDefaultOutputDir(configName, + cmStateEnums::RuntimeBinaryArtifact)) { + std::string pncdir = gtgt->GetDirectory(configName); + buildSettings->AddAttribute("CONFIGURATION_BUILD_DIR", + this->CreateString(pncdir)); } if (gtgt->IsFrameworkOnApple() || gtgt->IsCFBundleOnApple()) { @@ -1798,16 +1812,10 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, pnbase = gtgt->GetName(); pnsuffix = ".a"; - if (this->XcodeVersion >= 21) { - std::string pncdir = this->GetObjectsNormalDirectory( - this->CurrentProject, configName, gtgt); - buildSettings->AddAttribute("CONFIGURATION_BUILD_DIR", - this->CreateString(pncdir)); - } else { - buildSettings->AddAttribute("OBJROOT", this->CreateString(pndir)); - pndir = this->GetObjectsNormalDirectory(this->CurrentProject, configName, - gtgt); - } + std::string pncdir = + this->GetObjectsNormalDirectory(this->CurrentProject, configName, gtgt); + buildSettings->AddAttribute("CONFIGURATION_BUILD_DIR", + this->CreateString(pncdir)); } // Store the product name for all target types. @@ -1876,7 +1884,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, gtgt, "$(EXECUTABLE_NAME)", plist.c_str()); buildSettings->AddAttribute("INFOPLIST_FILE", this->CreateString(plist)); - } else if (this->XcodeVersion >= 22) { + } else { buildSettings->AddAttribute("MACH_O_TYPE", this->CreateString("mh_bundle")); buildSettings->AddAttribute("GCC_DYNAMIC_NO_PIC", @@ -1888,14 +1896,6 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, extraLinkOptions += " "; extraLinkOptions += createFlags; } - } else { - // Add the flags to create a module. - std::string createFlags = this->LookupFlags( - "CMAKE_SHARED_MODULE_CREATE_", llang, "_FLAGS", "-bundle"); - if (!createFlags.empty()) { - extraLinkOptions += " "; - extraLinkOptions += createFlags; - } } break; } @@ -1961,12 +1961,16 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, default: break; } - if (this->XcodeVersion >= 22 && this->XcodeVersion < 40) { + if (this->XcodeVersion < 40) { buildSettings->AddAttribute("PREBINDING", this->CreateString("NO")); } - BuildObjectListOrString dirs(this, this->XcodeVersion >= 30); - BuildObjectListOrString fdirs(this, this->XcodeVersion >= 30); + BuildObjectListOrString dirs(this, true); + BuildObjectListOrString fdirs(this, true); + BuildObjectListOrString sysdirs(this, true); + BuildObjectListOrString sysfdirs(this, true); + const bool emitSystemIncludes = this->XcodeVersion >= 83; + std::vector<std::string> includes; this->CurrentLocalGenerator->GetIncludeDirectories(includes, gtgt, "C", configName); @@ -1980,11 +1984,22 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, frameworkDir += "/../"; frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir); if (emitted.insert(frameworkDir).second) { - fdirs.Add(this->XCodeEscapePath(frameworkDir)); + std::string incpath = this->XCodeEscapePath(frameworkDir); + if (emitSystemIncludes && + gtgt->IsSystemIncludeDirectory(frameworkDir, configName)) { + sysfdirs.Add(incpath); + } else { + fdirs.Add(incpath); + } } } else { std::string incpath = this->XCodeEscapePath(*i); - dirs.Add(incpath); + if (emitSystemIncludes && + gtgt->IsSystemIncludeDirectory(*i, configName)) { + sysdirs.Add(incpath); + } else { + dirs.Add(incpath); + } } } // Add framework search paths needed for linking. @@ -1993,7 +2008,13 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, for (std::vector<std::string>::const_iterator fdi = fwDirs.begin(); fdi != fwDirs.end(); ++fdi) { if (emitted.insert(*fdi).second) { - fdirs.Add(this->XCodeEscapePath(*fdi)); + std::string incpath = this->XCodeEscapePath(*fdi); + if (emitSystemIncludes && + gtgt->IsSystemIncludeDirectory(*fdi, configName)) { + sysfdirs.Add(incpath); + } else { + fdirs.Add(incpath); + } } } } @@ -2003,8 +2024,16 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, if (!dirs.IsEmpty()) { buildSettings->AddAttribute("HEADER_SEARCH_PATHS", dirs.CreateList()); } + if (!sysfdirs.IsEmpty()) { + buildSettings->AddAttribute("SYSTEM_FRAMEWORK_SEARCH_PATHS", + sysfdirs.CreateList()); + } + if (!sysdirs.IsEmpty()) { + buildSettings->AddAttribute("SYSTEM_HEADER_SEARCH_PATHS", + sysdirs.CreateList()); + } - if (this->XcodeVersion >= 60) { + if (this->XcodeVersion >= 60 && !emitSystemIncludes) { // Add those per-language flags in addition to HEADER_SEARCH_PATHS to gain // system include directory awareness. We need to also keep on setting // HEADER_SEARCH_PATHS to work around a missing compile options flag for @@ -2170,18 +2199,12 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, buildSettings->AddAttribute("OTHER_REZFLAGS", this->CreateString("")); buildSettings->AddAttribute("SECTORDER_FLAGS", this->CreateString("")); buildSettings->AddAttribute("USE_HEADERMAP", this->CreateString("NO")); - if (this->XcodeVersion >= 30) { - cmXCodeObject* group = this->CreateObject(cmXCodeObject::OBJECT_LIST); - group->AddObject(this->CreateString("-Wmost")); - group->AddObject(this->CreateString("-Wno-four-char-constants")); - group->AddObject(this->CreateString("-Wno-unknown-pragmas")); - group->AddObject(this->CreateString("$(inherited)")); - buildSettings->AddAttribute("WARNING_CFLAGS", group); - } else { - buildSettings->AddAttribute( - "WARNING_CFLAGS", this->CreateString("-Wmost -Wno-four-char-constants" - " -Wno-unknown-pragmas")); - } + cmXCodeObject* group = this->CreateObject(cmXCodeObject::OBJECT_LIST); + group->AddObject(this->CreateString("-Wmost")); + group->AddObject(this->CreateString("-Wno-four-char-constants")); + group->AddObject(this->CreateString("-Wno-unknown-pragmas")); + group->AddObject(this->CreateString("$(inherited)")); + buildSettings->AddAttribute("WARNING_CFLAGS", group); // Runtime version information. if (gtgt->GetType() == cmStateEnums::SHARED_LIBRARY) { @@ -2261,16 +2284,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateUtilityTarget( this->CreateCustomCommands(buildPhases, 0, 0, 0, emptyContentVector, 0, gtgt); target->AddAttribute("buildPhases", buildPhases); - if (this->XcodeVersion > 20) { - this->AddConfigurations(target, gtgt); - } else { - std::string theConfig = - this->CurrentMakefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); - cmXCodeObject* buildSettings = - this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); - this->CreateBuildSettings(gtgt, buildSettings, theConfig); - target->AddAttribute("buildSettings", buildSettings); - } + this->AddConfigurations(target, gtgt); cmXCodeObject* dependencies = this->CreateObject(cmXCodeObject::OBJECT_LIST); target->AddAttribute("dependencies", dependencies); target->AddAttribute("name", this->CreateString(gtgt->GetName())); @@ -2372,8 +2386,7 @@ const char* cmGlobalXCodeGenerator::GetTargetFileType( else if (target->IsCFBundleOnApple()) return "wrapper.plug-in"; else - return ((this->XcodeVersion >= 22) ? "compiled.mach-o.executable" - : "compiled.mach-o.dylib"); + return "compiled.mach-o.executable"; case cmStateEnums::SHARED_LIBRARY: return (target->GetPropertyAsBool("FRAMEWORK") ? "wrapper.framework" @@ -2406,9 +2419,7 @@ const char* cmGlobalXCodeGenerator::GetTargetProductType( else if (target->IsCFBundleOnApple()) return "com.apple.product-type.bundle"; else - return ((this->XcodeVersion >= 22) - ? "com.apple.product-type.tool" - : "com.apple.product-type.library.dynamic"); + return "com.apple.product-type.tool"; case cmStateEnums::SHARED_LIBRARY: return (target->GetPropertyAsBool("FRAMEWORK") ? "com.apple.product-type.framework" @@ -2434,15 +2445,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeTarget( cmXCodeObject* buildRules = this->CreateObject(cmXCodeObject::OBJECT_LIST); target->AddAttribute("buildRules", buildRules); std::string defConfig; - if (this->XcodeVersion > 20) { - defConfig = this->AddConfigurations(target, gtgt); - } else { - cmXCodeObject* buildSettings = - this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); - defConfig = this->CurrentMakefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); - this->CreateBuildSettings(gtgt, buildSettings, defConfig); - target->AddAttribute("buildSettings", buildSettings); - } + defConfig = this->AddConfigurations(target, gtgt); cmXCodeObject* dependencies = this->CreateObject(cmXCodeObject::OBJECT_LIST); target->AddAttribute("dependencies", dependencies); target->AddAttribute("name", this->CreateString(gtgt->GetName())); @@ -2461,9 +2464,6 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeTarget( fullName = gtgt->GetFullName(defConfig); } fileRef->AddAttribute("path", this->CreateString(fullName)); - if (this->XcodeVersion == 15) { - fileRef->AddAttribute("refType", this->CreateString("0")); - } fileRef->AddAttribute("sourceTree", this->CreateString("BUILT_PRODUCTS_DIR")); fileRef->SetComment(gtgt->GetName()); @@ -2564,32 +2564,25 @@ void cmGlobalXCodeGenerator::AppendBuildSettingAttribute( cmXCodeObject* target, const char* attribute, const char* value, const std::string& configName) { - if (this->XcodeVersion < 21) { - // There is only one configuration. Add the setting to the buildSettings - // of the target. - this->AppendOrAddBuildSetting(target->GetObject("buildSettings"), - attribute, value); - } else { - // There are multiple configurations. Add the setting to the - // buildSettings of the configuration name given. - cmXCodeObject* configurationList = - target->GetObject("buildConfigurationList")->GetObject(); - cmXCodeObject* buildConfigs = - configurationList->GetObject("buildConfigurations"); - std::vector<cmXCodeObject*> list = buildConfigs->GetObjectList(); - // each configuration and the target itself has a buildSettings in it - // list.push_back(target); - for (std::vector<cmXCodeObject*>::iterator i = list.begin(); - i != list.end(); ++i) { - if (!configName.empty()) { - if ((*i)->GetObject("name")->GetString() == configName) { - cmXCodeObject* settings = (*i)->GetObject("buildSettings"); - this->AppendOrAddBuildSetting(settings, attribute, value); - } - } else { + // There are multiple configurations. Add the setting to the + // buildSettings of the configuration name given. + cmXCodeObject* configurationList = + target->GetObject("buildConfigurationList")->GetObject(); + cmXCodeObject* buildConfigs = + configurationList->GetObject("buildConfigurations"); + std::vector<cmXCodeObject*> list = buildConfigs->GetObjectList(); + // each configuration and the target itself has a buildSettings in it + // list.push_back(target); + for (std::vector<cmXCodeObject*>::iterator i = list.begin(); i != list.end(); + ++i) { + if (!configName.empty()) { + if ((*i)->GetObject("name")->GetString() == configName) { cmXCodeObject* settings = (*i)->GetObject("buildSettings"); this->AppendOrAddBuildSetting(settings, attribute, value); } + } else { + cmXCodeObject* settings = (*i)->GetObject("buildSettings"); + this->AppendOrAddBuildSetting(settings, attribute, value); } } } @@ -2625,13 +2618,16 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target) // Add object library contents as link flags. std::string linkObjs; const char* sep = ""; - std::vector<std::string> objs; - gt->UseObjectLibraries(objs, ""); - for (std::vector<std::string>::const_iterator oi = objs.begin(); + std::vector<cmSourceFile const*> objs; + gt->GetExternalObjects(objs, configName); + for (std::vector<cmSourceFile const*>::const_iterator oi = objs.begin(); oi != objs.end(); ++oi) { + if ((*oi)->GetObjectLibrary().empty()) { + continue; + } linkObjs += sep; sep = " "; - linkObjs += this->XCodeEscapePath(*oi); + linkObjs += this->XCodeEscapePath((*oi)->GetFullPath()); } this->AppendBuildSettingAttribute( target, this->GetTargetLinkFlagsVar(gt), linkObjs.c_str(), configName); @@ -2666,13 +2662,11 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target) for (std::vector<std::string>::const_iterator libDir = libDirs.begin(); libDir != libDirs.end(); ++libDir) { if (libDir->size() && *libDir != "/usr/lib") { - if (this->XcodeVersion > 15) { - // Now add the same one but append - // $(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) to it: - linkDirs += " "; - linkDirs += this->XCodeEscapePath( - *libDir + "/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)"); - } + // Now add the same one but append + // $(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) to it: + linkDirs += " "; + linkDirs += this->XCodeEscapePath( + *libDir + "/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)"); linkDirs += " "; linkDirs += this->XCodeEscapePath(*libDir); } @@ -2738,32 +2732,23 @@ bool cmGlobalXCodeGenerator::CreateGroups( gtgt->AddSource(plist); } - std::vector<cmSourceFile*> classes; - if (!gtgt->GetConfigCommonSourceFiles(classes)) { - return false; - } + std::vector<cmGeneratorTarget::AllConfigSource> const& sources = + gtgt->GetAllConfigSources(); + // Put cmSourceFile instances in proper groups: - for (std::vector<cmSourceFile*>::const_iterator s = classes.begin(); - s != classes.end(); s++) { - cmSourceFile* sf = *s; + for (std::vector<cmGeneratorTarget::AllConfigSource>::const_iterator si = + sources.begin(); + si != sources.end(); ++si) { + cmSourceFile const* sf = si->Source; + if (this->XcodeVersion >= 50 && !sf->GetObjectLibrary().empty()) { + // Object library files go on the link line instead. + continue; + } // Add the file to the list of sources. std::string const& source = sf->GetFullPath(); cmSourceGroup* sourceGroup = mf->FindSourceGroup(source.c_str(), sourceGroups); cmXCodeObject* pbxgroup = this->CreateOrGetPBXGroup(gtgt, sourceGroup); - std::string key = GetGroupMapKey(gtgt, sf); - this->GroupMap[key] = pbxgroup; - } - - // Put OBJECT_LIBRARY objects in proper groups: - std::vector<std::string> objs; - gtgt->UseObjectLibraries(objs, ""); - for (std::vector<std::string>::const_iterator oi = objs.begin(); - oi != objs.end(); ++oi) { - std::string const& source = *oi; - cmSourceGroup* sourceGroup = - mf->FindSourceGroup(source.c_str(), sourceGroups); - cmXCodeObject* pbxgroup = this->CreateOrGetPBXGroup(gtgt, sourceGroup); std::string key = GetGroupMapKeyFromPath(gtgt, source); this->GroupMap[key] = pbxgroup; } @@ -2783,9 +2768,6 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreatePBXGroup(cmXCodeObject* parent, this->CreateObject(cmXCodeObject::OBJECT_LIST); group->AddAttribute("name", this->CreateString(name)); group->AddAttribute("children", groupChildren); - if (this->XcodeVersion == 15) { - group->AddAttribute("refType", this->CreateString("4")); - } group->AddAttribute("sourceTree", this->CreateString("<group>")); if (parentChildren) parentChildren->AddObject(group); @@ -2884,50 +2866,28 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects( this->MainGroupChildren = 0; cmXCodeObject* group = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); group->AddAttribute("COPY_PHASE_STRIP", this->CreateString("NO")); - cmXCodeObject* developBuildStyle = - this->CreateObject(cmXCodeObject::PBXBuildStyle); cmXCodeObject* listObjs = this->CreateObject(cmXCodeObject::OBJECT_LIST); - if (this->XcodeVersion == 15) { - developBuildStyle->AddAttribute("name", this->CreateString("Development")); - developBuildStyle->AddAttribute("buildSettings", group); - listObjs->AddObject(developBuildStyle); - group = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); - group->AddAttribute("COPY_PHASE_STRIP", this->CreateString("YES")); - cmXCodeObject* deployBuildStyle = + for (unsigned int i = 0; i < this->CurrentConfigurationTypes.size(); ++i) { + cmXCodeObject* buildStyle = this->CreateObject(cmXCodeObject::PBXBuildStyle); - deployBuildStyle->AddAttribute("name", this->CreateString("Deployment")); - deployBuildStyle->AddAttribute("buildSettings", group); - listObjs->AddObject(deployBuildStyle); - } else { - for (unsigned int i = 0; i < this->CurrentConfigurationTypes.size(); ++i) { - cmXCodeObject* buildStyle = - this->CreateObject(cmXCodeObject::PBXBuildStyle); - const char* name = this->CurrentConfigurationTypes[i].c_str(); - buildStyle->AddAttribute("name", this->CreateString(name)); - buildStyle->SetComment(name); - cmXCodeObject* sgroup = - this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); - sgroup->AddAttribute("COPY_PHASE_STRIP", this->CreateString("NO")); - buildStyle->AddAttribute("buildSettings", sgroup); - listObjs->AddObject(buildStyle); - } + const char* name = this->CurrentConfigurationTypes[i].c_str(); + buildStyle->AddAttribute("name", this->CreateString(name)); + buildStyle->SetComment(name); + cmXCodeObject* sgroup = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); + sgroup->AddAttribute("COPY_PHASE_STRIP", this->CreateString("NO")); + buildStyle->AddAttribute("buildSettings", sgroup); + listObjs->AddObject(buildStyle); } cmXCodeObject* mainGroup = this->CreateObject(cmXCodeObject::PBXGroup); this->MainGroupChildren = this->CreateObject(cmXCodeObject::OBJECT_LIST); mainGroup->AddAttribute("children", this->MainGroupChildren); - if (this->XcodeVersion == 15) { - mainGroup->AddAttribute("refType", this->CreateString("4")); - } mainGroup->AddAttribute("sourceTree", this->CreateString("<group>")); cmXCodeObject* sourcesGroup = this->CreateObject(cmXCodeObject::PBXGroup); this->SourcesGroupChildren = this->CreateObject(cmXCodeObject::OBJECT_LIST); sourcesGroup->AddAttribute("name", this->CreateString("Sources")); sourcesGroup->AddAttribute("children", this->SourcesGroupChildren); - if (this->XcodeVersion == 15) { - sourcesGroup->AddAttribute("refType", this->CreateString("4")); - } sourcesGroup->AddAttribute("sourceTree", this->CreateString("<group>")); this->MainGroupChildren->AddObject(sourcesGroup); @@ -2936,9 +2896,6 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects( this->CreateObject(cmXCodeObject::OBJECT_LIST); resourcesGroup->AddAttribute("name", this->CreateString("Resources")); resourcesGroup->AddAttribute("children", this->ResourcesGroupChildren); - if (this->XcodeVersion == 15) { - resourcesGroup->AddAttribute("refType", this->CreateString("4")); - } resourcesGroup->AddAttribute("sourceTree", this->CreateString("<group>")); this->MainGroupChildren->AddObject(resourcesGroup); @@ -2949,9 +2906,6 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects( cmXCodeObject* productGroup = this->CreateObject(cmXCodeObject::PBXGroup); productGroup->AddAttribute("name", this->CreateString("Products")); - if (this->XcodeVersion == 15) { - productGroup->AddAttribute("refType", this->CreateString("4")); - } productGroup->AddAttribute("sourceTree", this->CreateString("<group>")); cmXCodeObject* productGroupChildren = this->CreateObject(cmXCodeObject::OBJECT_LIST); @@ -2973,24 +2927,22 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects( this->RootObject->AddAttribute("buildStyles", listObjs); this->RootObject->AddAttribute("hasScannedForEncodings", this->CreateString("0")); - if (this->XcodeVersion >= 30) { - group = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); - group->AddAttribute("BuildIndependentTargetsInParallel", - this->CreateString("YES")); - std::ostringstream v; - v << std::setfill('0') << std::setw(4) << XcodeVersion * 10; - group->AddAttribute("LastUpgradeCheck", this->CreateString(v.str())); - this->RootObject->AddAttribute("attributes", group); - if (this->XcodeVersion >= 32) - this->RootObject->AddAttribute("compatibilityVersion", - this->CreateString("Xcode 3.2")); - else if (this->XcodeVersion >= 31) - this->RootObject->AddAttribute("compatibilityVersion", - this->CreateString("Xcode 3.1")); - else - this->RootObject->AddAttribute("compatibilityVersion", - this->CreateString("Xcode 3.0")); - } + group = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); + group->AddAttribute("BuildIndependentTargetsInParallel", + this->CreateString("YES")); + std::ostringstream v; + v << std::setfill('0') << std::setw(4) << XcodeVersion * 10; + group->AddAttribute("LastUpgradeCheck", this->CreateString(v.str())); + this->RootObject->AddAttribute("attributes", group); + if (this->XcodeVersion >= 32) + this->RootObject->AddAttribute("compatibilityVersion", + this->CreateString("Xcode 3.2")); + else if (this->XcodeVersion >= 31) + this->RootObject->AddAttribute("compatibilityVersion", + this->CreateString("Xcode 3.1")); + else + this->RootObject->AddAttribute("compatibilityVersion", + this->CreateString("Xcode 3.0")); // Point Xcode at the top of the source tree. { std::string pdir = @@ -3005,26 +2957,15 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects( typedef std::vector<std::pair<std::string, cmXCodeObject*> > Configs; Configs configs; const char* defaultConfigName = "Debug"; - if (this->XcodeVersion == 15) { - cmXCodeObject* configDebug = - this->CreateObject(cmXCodeObject::XCBuildConfiguration); - configDebug->AddAttribute("name", this->CreateString("Debug")); - configs.push_back(std::make_pair("Debug", configDebug)); - cmXCodeObject* configRelease = - this->CreateObject(cmXCodeObject::XCBuildConfiguration); - configRelease->AddAttribute("name", this->CreateString("Release")); - configs.push_back(std::make_pair("Release", configRelease)); - } else { - for (unsigned int i = 0; i < this->CurrentConfigurationTypes.size(); ++i) { - const char* name = this->CurrentConfigurationTypes[i].c_str(); - if (0 == i) { - defaultConfigName = name; - } - cmXCodeObject* config = - this->CreateObject(cmXCodeObject::XCBuildConfiguration); - config->AddAttribute("name", this->CreateString(name)); - configs.push_back(std::make_pair(name, config)); + for (unsigned int i = 0; i < this->CurrentConfigurationTypes.size(); ++i) { + const char* name = this->CurrentConfigurationTypes[i].c_str(); + if (0 == i) { + defaultConfigName = name; } + cmXCodeObject* config = + this->CreateObject(cmXCodeObject::XCBuildConfiguration); + config->AddAttribute("name", this->CreateString(name)); + configs.push_back(std::make_pair(name, config)); } for (Configs::iterator c = configs.begin(); c != configs.end(); ++c) { buildConfigurations->AddObject(c->second); @@ -3042,23 +2983,16 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects( this->CreateString(defaultConfigName)); cmXCodeObject* buildSettings = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); - const char* osxArch = - this->CurrentMakefile->GetDefinition("CMAKE_OSX_ARCHITECTURES"); const char* sysroot = this->CurrentMakefile->GetDefinition("CMAKE_OSX_SYSROOT"); const char* deploymentTarget = this->CurrentMakefile->GetDefinition("CMAKE_OSX_DEPLOYMENT_TARGET"); - std::string archs; if (sysroot) { - if (osxArch) { - // recompute this as it may have been changed since enable language - this->Architectures.clear(); - cmSystemTools::ExpandListArgument(std::string(osxArch), - this->Architectures); - archs = cmJoin(this->Architectures, " "); - } buildSettings->AddAttribute("SDKROOT", this->CreateString(sysroot)); } + // recompute this as it may have been changed since enable language + this->ComputeArchitectures(this->CurrentMakefile); + std::string const archs = cmJoin(this->Architectures, " "); if (archs.empty()) { // Tell Xcode to use NATIVE_ARCH instead of ARCHS. buildSettings->AddAttribute("ONLY_ACTIVE_ARCH", this->CreateString("YES")); @@ -3133,10 +3067,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects( cmXCodeObject* t = *i; this->AddDependAndLinkInformation(t); } - if (this->XcodeVersion < 50) { - // now create xcode depend hack makefile - this->CreateXCodeDependHackTarget(targets); - } + this->CreateXCodeDependHackTarget(targets); // now add all targets to the root object cmXCodeObject* allTargets = this->CreateObject(cmXCodeObject::OBJECT_LIST); for (std::vector<cmXCodeObject*>::iterator i = targets.begin(); @@ -3168,6 +3099,38 @@ std::string cmGlobalXCodeGenerator::GetObjectsNormalDirectory( return dir; } +void cmGlobalXCodeGenerator::ComputeArchitectures(cmMakefile* mf) +{ + this->Architectures.clear(); + const char* osxArch = mf->GetDefinition("CMAKE_OSX_ARCHITECTURES"); + const char* sysroot = mf->GetDefinition("CMAKE_OSX_SYSROOT"); + if (osxArch && sysroot) { + cmSystemTools::ExpandListArgument(std::string(osxArch), + this->Architectures); + } + + if (this->Architectures.empty()) { + // With no ARCHS we use ONLY_ACTIVE_ARCH. + // Look up the arch that Xcode chooses in this case. + if (const char* arch = mf->GetDefinition("CMAKE_XCODE_CURRENT_ARCH")) { + this->ObjectDirArchDefault = arch; + } + } + + this->ComputeObjectDirArch(); +} + +void cmGlobalXCodeGenerator::ComputeObjectDirArch() +{ + if (this->Architectures.size() > 1) { + this->ObjectDirArch = "$(CURRENT_ARCH)"; + } else if (!this->Architectures.empty()) { + this->ObjectDirArch = this->Architectures[0]; + } else { + this->ObjectDirArch = this->ObjectDirArchDefault; + } +} + void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( std::vector<cmXCodeObject*>& targets) { @@ -3187,29 +3150,9 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( "default:\n" "\techo \"Do not invoke directly\"\n" "\n"; - makefileStream - << "# For each target create a dummy rule " - "so the target does not have to exist\n"; /* clang-format on */ - std::set<std::string> emitted; - for (std::vector<cmXCodeObject*>::iterator i = targets.begin(); - i != targets.end(); ++i) { - cmXCodeObject* target = *i; - std::map<std::string, cmXCodeObject::StringVec> const& deplibs = - target->GetDependLibraries(); - for (std::map<std::string, cmXCodeObject::StringVec>::const_iterator ci = - deplibs.begin(); - ci != deplibs.end(); ++ci) { - for (cmXCodeObject::StringVec::const_iterator d = ci->second.begin(); - d != ci->second.end(); ++d) { - if (emitted.insert(*d).second) { - makefileStream << this->ConvertToRelativeForMake(d->c_str()) - << ":\n"; - } - } - } - } - makefileStream << "\n\n"; + + std::set<std::string> dummyRules; // Write rules to help Xcode relink things at the right time. /* clang-format off */ @@ -3228,8 +3171,7 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( cmGeneratorTarget* gt = target->GetTarget(); if (gt->GetType() == cmStateEnums::EXECUTABLE || - // Nope - no post-build for OBJECT_LIRBRARY - // gt->GetType() == cmStateEnums::OBJECT_LIBRARY || + gt->GetType() == cmStateEnums::OBJECT_LIBRARY || gt->GetType() == cmStateEnums::STATIC_LIBRARY || gt->GetType() == cmStateEnums::SHARED_LIBRARY || gt->GetType() == cmStateEnums::MODULE_LIBRARY) { @@ -3239,6 +3181,7 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( } if (gt->GetType() == cmStateEnums::EXECUTABLE || + gt->GetType() == cmStateEnums::STATIC_LIBRARY || gt->GetType() == cmStateEnums::SHARED_LIBRARY || gt->GetType() == cmStateEnums::MODULE_LIBRARY) { std::string tfull = gt->GetFullPath(configName); @@ -3256,6 +3199,15 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( } } + std::vector<cmGeneratorTarget*> objlibs; + gt->GetObjectLibrariesCMP0026(objlibs); + for (std::vector<cmGeneratorTarget*>::const_iterator it = + objlibs.begin(); + it != objlibs.end(); ++it) { + makefileStream << this->PostBuildMakeTarget((*it)->GetName(), *ct) + << ": " << trel << "\n"; + } + // Create a rule for this target. makefileStream << trel << ":"; @@ -3266,10 +3218,28 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( std::vector<std::string> const& deplibs = x->second; for (std::vector<std::string>::const_iterator d = deplibs.begin(); d != deplibs.end(); ++d) { - makefileStream << "\\\n\t" - << this->ConvertToRelativeForMake(d->c_str()); + std::string file = this->ConvertToRelativeForMake(d->c_str()); + makefileStream << "\\\n\t" << file; + dummyRules.insert(file); } } + + for (std::vector<cmGeneratorTarget*>::const_iterator it = + objlibs.begin(); + it != objlibs.end(); ++it) { + + const std::string objLibName = (*it)->GetName(); + std::string d = this->GetObjectsNormalDirectory(this->CurrentProject, + configName, *it); + d += "lib"; + d += objLibName; + d += ".a"; + + std::string dependency = this->ConvertToRelativeForMake(d.c_str()); + makefileStream << "\\\n\t" << dependency; + dummyRules.insert(dependency); + } + // Write the action to remove the target if it is out of date. makefileStream << "\n"; makefileStream << "\t/bin/rm -f " @@ -3297,6 +3267,14 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( } } } + + makefileStream << "\n\n" + << "# For each target create a dummy rule" + << "so the target does not have to exist\n"; + for (std::set<std::string>::const_iterator it = dummyRules.begin(); + it != dummyRules.end(); ++it) { + makefileStream << *it << ":\n"; + } } void cmGlobalXCodeGenerator::OutputXCodeProject( @@ -3319,10 +3297,7 @@ void cmGlobalXCodeGenerator::OutputXCodeProject( std::string xcodeDir = root->GetCurrentBinaryDirectory(); xcodeDir += "/"; xcodeDir += root->GetProjectName(); - xcodeDir += ".xcode"; - if (this->XcodeVersion > 20) { - xcodeDir += "proj"; - } + xcodeDir += ".xcodeproj"; cmSystemTools::MakeDirectory(xcodeDir.c_str()); std::string xcodeProjFile = xcodeDir + "/project.pbxproj"; cmGeneratedFileStream fout(xcodeProjFile.c_str()); @@ -3331,6 +3306,15 @@ void cmGlobalXCodeGenerator::OutputXCodeProject( return; } this->WriteXCodePBXProj(fout, root, generators); + + // Since the lowest available Xcode version for testing was 7.0, + // I'm setting this as a limit then + if (root->GetMakefile()->IsOn("CMAKE_XCODE_GENERATE_SCHEME") && + this->XcodeVersion >= 70) { + this->OutputXCodeSharedSchemes(xcodeDir); + this->OutputXCodeWorkspaceSettings(xcodeDir); + } + this->ClearXCodeObjects(); // Since this call may have created new cache entries, save the cache: @@ -3339,6 +3323,54 @@ void cmGlobalXCodeGenerator::OutputXCodeProject( root->GetBinaryDirectory()); } +void cmGlobalXCodeGenerator::OutputXCodeSharedSchemes( + const std::string& xcProjDir) +{ + for (std::vector<cmXCodeObject*>::const_iterator i = + this->XCodeObjects.begin(); + i != this->XCodeObjects.end(); ++i) { + cmXCodeObject* obj = *i; + if (obj->GetType() == cmXCodeObject::OBJECT && + (obj->GetIsA() == cmXCodeObject::PBXNativeTarget || + obj->GetIsA() == cmXCodeObject::PBXAggregateTarget)) { + cmXCodeScheme schm(obj, this->CurrentConfigurationTypes, + this->XcodeVersion); + schm.WriteXCodeSharedScheme(xcProjDir, + this->RelativeToSource(xcProjDir.c_str())); + } + } +} + +void cmGlobalXCodeGenerator::OutputXCodeWorkspaceSettings( + const std::string& xcProjDir) +{ + std::string xcodeSharedDataDir = xcProjDir; + xcodeSharedDataDir += "/project.xcworkspace/xcshareddata"; + cmSystemTools::MakeDirectory(xcodeSharedDataDir); + + std::string workspaceSettingsFile = xcodeSharedDataDir; + workspaceSettingsFile += "/WorkspaceSettings.xcsettings"; + + cmGeneratedFileStream fout(workspaceSettingsFile.c_str()); + fout.SetCopyIfDifferent(true); + if (!fout) { + return; + } + + cmXMLWriter xout(fout); + xout.StartDocument(); + xout.Doctype("plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\"" + "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\""); + xout.StartElement("plist"); + xout.Attribute("version", "1.0"); + xout.StartElement("dict"); + xout.Element("key", "IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded"); + xout.Element("false"); + xout.EndElement(); // dict + xout.EndElement(); // plist + xout.EndDocument(); +} + void cmGlobalXCodeGenerator::WriteXCodePBXProj(std::ostream& fout, cmLocalGenerator*, std::vector<cmLocalGenerator*>&) @@ -3354,20 +3386,13 @@ void cmGlobalXCodeGenerator::WriteXCodePBXProj(std::ostream& fout, cmXCodeObject::Indent(1, fout); fout << "};\n"; cmXCodeObject::Indent(1, fout); - if (this->XcodeVersion >= 21) { - if (this->XcodeVersion >= 32) - fout << "objectVersion = 46;\n"; - else if (this->XcodeVersion >= 31) - fout << "objectVersion = 45;\n"; - else if (this->XcodeVersion >= 30) - fout << "objectVersion = 44;\n"; - else - fout << "objectVersion = 42;\n"; - cmXCode21Object::PrintList(this->XCodeObjects, fout); - } else { - fout << "objectVersion = 39;\n"; - cmXCodeObject::PrintList(this->XCodeObjects, fout); - } + if (this->XcodeVersion >= 32) + fout << "objectVersion = 46;\n"; + else if (this->XcodeVersion >= 31) + fout << "objectVersion = 45;\n"; + else + fout << "objectVersion = 44;\n"; + cmXCode21Object::PrintList(this->XCodeObjects, fout); cmXCodeObject::Indent(1, fout); fout << "rootObject = " << this->RootObject->GetId() << " /* Project object */;\n"; @@ -3376,9 +3401,7 @@ void cmGlobalXCodeGenerator::WriteXCodePBXProj(std::ostream& fout, const char* cmGlobalXCodeGenerator::GetCMakeCFGIntDir() const { - return this->XcodeVersion >= 21 - ? "$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)" - : "."; + return "$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)"; } std::string cmGlobalXCodeGenerator::ExpandCFGIntDir( @@ -3441,12 +3464,10 @@ void cmGlobalXCodeGenerator::AppendDirectoryForConfig( const std::string& prefix, const std::string& config, const std::string& suffix, std::string& dir) { - if (this->XcodeVersion > 20) { - if (!config.empty()) { - dir += prefix; - dir += config; - dir += suffix; - } + if (!config.empty()) { + dir += prefix; + dir += config; + dir += suffix; } } @@ -3571,12 +3592,19 @@ std::string cmGlobalXCodeGenerator::ComputeInfoPListLocation( // i.e. "Can I build Debug and Release in the same tree?" bool cmGlobalXCodeGenerator::IsMultiConfig() const { - // Old Xcode 1.5 is single config: - if (this->XcodeVersion == 15) { + // Newer Xcode versions are multi config: + return true; +} + +bool cmGlobalXCodeGenerator::HasKnownObjectFileLocation( + std::string* reason) const +{ + if (this->ObjectDirArch.find('$') != std::string::npos) { + if (reason != CM_NULLPTR) { + *reason = " under Xcode with multiple architectures"; + } return false; } - - // Newer Xcode versions are multi config: return true; } @@ -3593,21 +3621,19 @@ bool cmGlobalXCodeGenerator::UseEffectivePlatformName(cmMakefile* mf) const return cmSystemTools::IsOn(epnValue); } +bool cmGlobalXCodeGenerator::ShouldStripResourcePath(cmMakefile*) const +{ + // Xcode determines Resource location itself + return true; +} + void cmGlobalXCodeGenerator::ComputeTargetObjectDirectory( cmGeneratorTarget* gt) const { std::string configName = this->GetCMakeCFGIntDir(); std::string dir = this->GetObjectsNormalDirectory("$(PROJECT_NAME)", configName, gt); - if (this->XcodeVersion >= 21) { - dir += "$(CURRENT_ARCH)/"; - } else { -#ifdef __ppc__ - dir += "ppc/"; -#endif -#ifdef __i386 - dir += "i386/"; -#endif - } + dir += this->ObjectDirArch; + dir += "/"; gt->ObjectDirectory = dir; } diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 1aaf9c7..ee06074 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -3,7 +3,8 @@ #ifndef cmGlobalXCodeGenerator_h #define cmGlobalXCodeGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <iosfwd> #include <map> #include <set> @@ -31,7 +32,8 @@ struct cmDocumentationEntry; class cmGlobalXCodeGenerator : public cmGlobalGenerator { public: - cmGlobalXCodeGenerator(cmake* cm, std::string const& version); + cmGlobalXCodeGenerator(cmake* cm, std::string const& version_string, + unsigned int version_number); static cmGlobalGeneratorFactory* NewFactory(); ///! Get the name for the generator. @@ -86,8 +88,12 @@ public: i.e. "Can I build Debug and Release in the same tree?" */ bool IsMultiConfig() const CM_OVERRIDE; + bool HasKnownObjectFileLocation(std::string* reason) const CM_OVERRIDE; + bool UseEffectivePlatformName(cmMakefile* mf) const CM_OVERRIDE; + bool ShouldStripResourcePath(cmMakefile*) const CM_OVERRIDE; + bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf) CM_OVERRIDE; void AppendFlag(std::string& flags, std::string const& flag); @@ -165,6 +171,9 @@ private: std::vector<cmLocalGenerator*>& generators); void OutputXCodeProject(cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators); + // Write shared scheme files for all the native targets + void OutputXCodeSharedSchemes(const std::string& xcProjDir); + void OutputXCodeWorkspaceSettings(const std::string& xcProjDir); void WriteXCodePBXProj(std::ostream& fout, cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators); cmXCodeObject* CreateXCodeFileReferenceFromPath(const std::string& fullpath, @@ -235,6 +244,9 @@ private: const std::string& configName, const cmGeneratorTarget* t) const; + void ComputeArchitectures(cmMakefile* mf); + void ComputeObjectDirArch(); + void addObject(cmXCodeObject* obj); std::string PostBuildMakeTarget(std::string const& tName, std::string const& configName); @@ -256,6 +268,8 @@ private: std::map<std::string, cmXCodeObject*> FileRefs; std::map<cmGeneratorTarget const*, cmXCodeObject*> XCodeObjectMap; std::vector<std::string> Architectures; + std::string ObjectDirArchDefault; + std::string ObjectDirArch; std::string GeneratorToolset; }; diff --git a/Source/cmGraphAdjacencyList.h b/Source/cmGraphAdjacencyList.h index e6aec47..46cf878 100644 --- a/Source/cmGraphAdjacencyList.h +++ b/Source/cmGraphAdjacencyList.h @@ -3,7 +3,7 @@ #ifndef cmGraphAdjacencyList_h #define cmGraphAdjacencyList_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <vector> @@ -15,26 +15,11 @@ class cmGraphEdge { public: - cmGraphEdge() - : Dest(0) - , Strong(true) - { - } - cmGraphEdge(int n) - : Dest(n) - , Strong(true) - { - } - cmGraphEdge(int n, bool s) + cmGraphEdge(int n = 0, bool s = true) : Dest(n) , Strong(s) { } - cmGraphEdge(cmGraphEdge const& r) - : Dest(r.Dest) - , Strong(r.Strong) - { - } operator int() const { return this->Dest; } bool IsStrong() const { return this->Strong; } diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index 0f69aaa..1fcd3cb 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmGraphVizWriter.h" -#include <cmConfigure.h> +#include "cmConfigure.h" #include <iostream> #include <sstream> #include <utility> diff --git a/Source/cmGraphVizWriter.h b/Source/cmGraphVizWriter.h index 1ff07ab..824999b 100644 --- a/Source/cmGraphVizWriter.h +++ b/Source/cmGraphVizWriter.h @@ -3,11 +3,11 @@ #ifndef CMGRAPHVIZWRITER_H #define CMGRAPHVIZWRITER_H -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include "cmStateTypes.h" -#include <cmsys/RegularExpression.hxx> +#include "cmsys/RegularExpression.hxx" #include <map> #include <set> #include <string> diff --git a/Source/cmHexFileConverter.cxx b/Source/cmHexFileConverter.cxx index d9d6598..78dceb7 100644 --- a/Source/cmHexFileConverter.cxx +++ b/Source/cmHexFileConverter.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmHexFileConverter.h" -#include <cmConfigure.h> +#include "cmConfigure.h" #include <stdio.h> #include <string.h> diff --git a/Source/cmIDEFlagTable.h b/Source/cmIDEFlagTable.h index 64ade76..152e293 100644 --- a/Source/cmIDEFlagTable.h +++ b/Source/cmIDEFlagTable.h @@ -24,6 +24,9 @@ struct cmIDEFlagTable // IgnoreDefaultLibraryNames) UserFollowing = (1 << 5), // expect value in following argument CaseInsensitive = (1 << 6), // flag may be any case + SpaceAppendable = (1 << 7), // a flag that if specified multiple times + // should have its value appended to the + // old value with spaces UserValueIgnored = UserValue | UserIgnored, UserValueRequired = UserValue | UserRequired diff --git a/Source/cmIDEOptions.cxx b/Source/cmIDEOptions.cxx index 8d07776..5e872d2 100644 --- a/Source/cmIDEOptions.cxx +++ b/Source/cmIDEOptions.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmIDEOptions.h" -#include <cmsys/String.h> +#include "cmsys/String.h" #include <iterator> #include <string.h> @@ -125,6 +125,8 @@ void cmIDEOptions::FlagMapUpdate(cmIDEFlagTable const* entry, this->FlagMap[entry->IDEName] = entry->value; } else if (entry->special & cmIDEFlagTable::SemicolonAppendable) { this->FlagMap[entry->IDEName].push_back(new_value); + } else if (entry->special & cmIDEFlagTable::SpaceAppendable) { + this->FlagMap[entry->IDEName].append_with_space(new_value); } else { // Use the user-specified value. this->FlagMap[entry->IDEName] = new_value; @@ -177,6 +179,12 @@ void cmIDEOptions::AppendFlag(std::string const& flag, std::copy(value.begin(), value.end(), std::back_inserter(fv)); } +void cmIDEOptions::AppendFlagString(std::string const& flag, + std::string const& value) +{ + this->FlagMap[flag].append_with_space(value); +} + void cmIDEOptions::RemoveFlag(const char* flag) { this->FlagMap.erase(flag); diff --git a/Source/cmIDEOptions.h b/Source/cmIDEOptions.h index be2fd6d..19e96bd 100644 --- a/Source/cmIDEOptions.h +++ b/Source/cmIDEOptions.h @@ -3,7 +3,7 @@ #ifndef cmIDEOptions_h #define cmIDEOptions_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <map> #include <string> @@ -31,6 +31,7 @@ public: void AppendFlag(std::string const& flag, std::string const& value); void AppendFlag(std::string const& flag, std::vector<std::string> const& value); + void AppendFlagString(std::string const& flag, std::string const& value); void RemoveFlag(const char* flag); bool HasFlag(std::string const& flag) const; const char* GetFlag(const char* flag); @@ -59,15 +60,22 @@ protected: this->derived::operator=(r); return *this; } + FlagValue& append_with_space(std::string const& r) + { + this->resize(1); + std::string& l = this->operator[](0); + if (!l.empty()) { + l += " "; + } + l += r; + return *this; + } }; std::map<std::string, FlagValue> FlagMap; // Preprocessor definitions. std::vector<std::string> Defines; - // Unrecognized flags that get no special handling. - std::string FlagString; - bool DoingDefine; bool AllowDefine; bool AllowSlash; diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx index a8fa4f9..421c3dd 100644 --- a/Source/cmIfCommand.cxx +++ b/Source/cmIfCommand.cxx @@ -57,8 +57,19 @@ bool cmIfFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff, // watch for our state change if (scopeDepth == 0 && !cmSystemTools::Strucmp(this->Functions[c].Name.c_str(), "else")) { + + if (this->ElseSeen) { + cmListFileBacktrace bt = mf.GetBacktrace(this->Functions[c]); + mf.GetCMakeInstance()->IssueMessage( + cmake::FATAL_ERROR, + "A duplicate ELSE command was found inside an IF block.", bt); + cmSystemTools::SetFatalErrorOccured(); + return true; + } + this->IsBlocking = this->HasRun; this->HasRun = true; + this->ElseSeen = true; // if trace is enabled, print a (trivially) evaluated "else" // statement @@ -68,6 +79,15 @@ bool cmIfFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff, } else if (scopeDepth == 0 && !cmSystemTools::Strucmp(this->Functions[c].Name.c_str(), "elseif")) { + if (this->ElseSeen) { + cmListFileBacktrace bt = mf.GetBacktrace(this->Functions[c]); + mf.GetCMakeInstance()->IssueMessage( + cmake::FATAL_ERROR, + "An ELSEIF command was found after an ELSE command.", bt); + cmSystemTools::SetFatalErrorOccured(); + return true; + } + if (this->HasRun) { this->IsBlocking = true; } else { diff --git a/Source/cmIfCommand.h b/Source/cmIfCommand.h index 56eef30..59d32e6 100644 --- a/Source/cmIfCommand.h +++ b/Source/cmIfCommand.h @@ -3,7 +3,8 @@ #ifndef cmIfCommand_h #define cmIfCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> @@ -21,6 +22,7 @@ public: cmIfFunctionBlocker() { this->HasRun = false; + this->ElseSeen = false; this->ScopeDepth = 0; } ~cmIfFunctionBlocker() CM_OVERRIDE {} @@ -32,6 +34,7 @@ public: std::vector<cmListFileFunction> Functions; bool IsBlocking; bool HasRun; + bool ElseSeen; unsigned int ScopeDepth; }; diff --git a/Source/cmIncludeCommand.h b/Source/cmIncludeCommand.h index 78edd43..06200cd 100644 --- a/Source/cmIncludeCommand.h +++ b/Source/cmIncludeCommand.h @@ -3,7 +3,8 @@ #ifndef cmIncludeCommand_h #define cmIncludeCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmIncludeDirectoryCommand.h b/Source/cmIncludeDirectoryCommand.h index 287b5d3..abe0c05 100644 --- a/Source/cmIncludeDirectoryCommand.h +++ b/Source/cmIncludeDirectoryCommand.h @@ -3,7 +3,8 @@ #ifndef cmIncludeDirectoryCommand_h #define cmIncludeDirectoryCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmIncludeExternalMSProjectCommand.h b/Source/cmIncludeExternalMSProjectCommand.h index 9fcf467..5274f9e 100644 --- a/Source/cmIncludeExternalMSProjectCommand.h +++ b/Source/cmIncludeExternalMSProjectCommand.h @@ -3,7 +3,8 @@ #ifndef cmIncludeExternalMSProjectCommand_h #define cmIncludeExternalMSProjectCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmIncludeRegularExpressionCommand.h b/Source/cmIncludeRegularExpressionCommand.h index c68d9f2..a003360 100644 --- a/Source/cmIncludeRegularExpressionCommand.h +++ b/Source/cmIncludeRegularExpressionCommand.h @@ -3,7 +3,8 @@ #ifndef cmIncludeRegularExpressionCommand_h #define cmIncludeRegularExpressionCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 4c331c7..ba554aa 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmInstallCommand.h" -#include <cmsys/Glob.hxx> +#include "cmsys/Glob.hxx" #include <sstream> #include <stddef.h> @@ -206,6 +206,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) cmCAStringVector archiveArgVector(&argHelper, "ARCHIVE", &group); cmCAStringVector libraryArgVector(&argHelper, "LIBRARY", &group); cmCAStringVector runtimeArgVector(&argHelper, "RUNTIME", &group); + cmCAStringVector objectArgVector(&argHelper, "OBJECTS", &group); cmCAStringVector frameworkArgVector(&argHelper, "FRAMEWORK", &group); cmCAStringVector bundleArgVector(&argHelper, "BUNDLE", &group); cmCAStringVector includesArgVector(&argHelper, "INCLUDES", &group); @@ -234,6 +235,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) cmInstallCommandArguments archiveArgs(this->DefaultComponentName); cmInstallCommandArguments libraryArgs(this->DefaultComponentName); cmInstallCommandArguments runtimeArgs(this->DefaultComponentName); + cmInstallCommandArguments objectArgs(this->DefaultComponentName); cmInstallCommandArguments frameworkArgs(this->DefaultComponentName); cmInstallCommandArguments bundleArgs(this->DefaultComponentName); cmInstallCommandArguments privateHeaderArgs(this->DefaultComponentName); @@ -246,6 +248,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) archiveArgs.Parse(&archiveArgVector.GetVector(), &unknownArgs); libraryArgs.Parse(&libraryArgVector.GetVector(), &unknownArgs); runtimeArgs.Parse(&runtimeArgVector.GetVector(), &unknownArgs); + objectArgs.Parse(&objectArgVector.GetVector(), &unknownArgs); frameworkArgs.Parse(&frameworkArgVector.GetVector(), &unknownArgs); bundleArgs.Parse(&bundleArgVector.GetVector(), &unknownArgs); privateHeaderArgs.Parse(&privateHeaderArgVector.GetVector(), &unknownArgs); @@ -265,6 +268,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) archiveArgs.SetGenericArguments(&genericArgs); libraryArgs.SetGenericArguments(&genericArgs); runtimeArgs.SetGenericArguments(&genericArgs); + objectArgs.SetGenericArguments(&genericArgs); frameworkArgs.SetGenericArguments(&genericArgs); bundleArgs.SetGenericArguments(&genericArgs); privateHeaderArgs.SetGenericArguments(&genericArgs); @@ -274,6 +278,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) success = success && archiveArgs.Finalize(); success = success && libraryArgs.Finalize(); success = success && runtimeArgs.Finalize(); + success = success && objectArgs.Finalize(); success = success && frameworkArgs.Finalize(); success = success && bundleArgs.Finalize(); success = success && privateHeaderArgs.Finalize(); @@ -287,8 +292,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) // Enforce argument rules too complex to specify for the // general-purpose parser. if (archiveArgs.GetNamelinkOnly() || runtimeArgs.GetNamelinkOnly() || - frameworkArgs.GetNamelinkOnly() || bundleArgs.GetNamelinkOnly() || - privateHeaderArgs.GetNamelinkOnly() || + objectArgs.GetNamelinkOnly() || frameworkArgs.GetNamelinkOnly() || + bundleArgs.GetNamelinkOnly() || privateHeaderArgs.GetNamelinkOnly() || publicHeaderArgs.GetNamelinkOnly() || resourceArgs.GetNamelinkOnly()) { this->SetError( "TARGETS given NAMELINK_ONLY option not in LIBRARY group. " @@ -296,8 +301,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) return false; } if (archiveArgs.GetNamelinkSkip() || runtimeArgs.GetNamelinkSkip() || - frameworkArgs.GetNamelinkSkip() || bundleArgs.GetNamelinkSkip() || - privateHeaderArgs.GetNamelinkSkip() || + objectArgs.GetNamelinkSkip() || frameworkArgs.GetNamelinkSkip() || + bundleArgs.GetNamelinkSkip() || privateHeaderArgs.GetNamelinkSkip() || publicHeaderArgs.GetNamelinkSkip() || resourceArgs.GetNamelinkSkip()) { this->SetError( "TARGETS given NAMELINK_SKIP option not in LIBRARY group. " @@ -356,11 +361,15 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) return false; } if (target->GetType() == cmStateEnums::OBJECT_LIBRARY) { - std::ostringstream e; - e << "TARGETS given OBJECT library \"" << (*targetIt) - << "\" which may not be installed."; - this->SetError(e.str()); - return false; + std::string reason; + if (!this->Makefile->GetGlobalGenerator()->HasKnownObjectFileLocation( + &reason)) { + std::ostringstream e; + e << "TARGETS given OBJECT library \"" << (*targetIt) + << "\" which may not be installed" << reason << "."; + this->SetError(e.str()); + return false; + } } // Store the target in the list to be installed. targets.push_back(target); @@ -379,6 +388,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) bool installsArchive = false; bool installsLibrary = false; bool installsRuntime = false; + bool installsObject = false; bool installsFramework = false; bool installsBundle = false; bool installsPrivateHeader = false; @@ -393,6 +403,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) cmInstallTargetGenerator* archiveGenerator = CM_NULLPTR; cmInstallTargetGenerator* libraryGenerator = CM_NULLPTR; cmInstallTargetGenerator* runtimeGenerator = CM_NULLPTR; + cmInstallTargetGenerator* objectGenerator = CM_NULLPTR; cmInstallTargetGenerator* frameworkGenerator = CM_NULLPTR; cmInstallTargetGenerator* bundleGenerator = CM_NULLPTR; cmInstallFilesGenerator* privateHeaderGenerator = CM_NULLPTR; @@ -522,6 +533,20 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) return false; } } break; + case cmStateEnums::OBJECT_LIBRARY: { + // Objects use OBJECT properties. + if (!objectArgs.GetDestination().empty()) { + objectGenerator = + CreateInstallTargetGenerator(target, objectArgs, false); + } else { + std::ostringstream e; + e << "TARGETS given no OBJECTS DESTINATION for object library " + "target \"" + << target.GetName() << "\"."; + this->SetError(e.str()); + return false; + } + } break; case cmStateEnums::EXECUTABLE: { if (target.IsAppBundleOnApple()) { // Application bundles use the BUNDLE properties. @@ -664,6 +689,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) installsArchive = installsArchive || archiveGenerator != CM_NULLPTR; installsLibrary = installsLibrary || libraryGenerator != CM_NULLPTR; installsRuntime = installsRuntime || runtimeGenerator != CM_NULLPTR; + installsObject = installsObject || objectGenerator != CM_NULLPTR; installsFramework = installsFramework || frameworkGenerator != CM_NULLPTR; installsBundle = installsBundle || bundleGenerator != CM_NULLPTR; installsPrivateHeader = @@ -675,6 +701,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) this->Makefile->AddInstallGenerator(archiveGenerator); this->Makefile->AddInstallGenerator(libraryGenerator); this->Makefile->AddInstallGenerator(runtimeGenerator); + this->Makefile->AddInstallGenerator(objectGenerator); this->Makefile->AddInstallGenerator(frameworkGenerator); this->Makefile->AddInstallGenerator(bundleGenerator); this->Makefile->AddInstallGenerator(privateHeaderGenerator); @@ -692,6 +719,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) te->HeaderGenerator = publicHeaderGenerator; te->LibraryGenerator = libraryGenerator; te->RuntimeGenerator = runtimeGenerator; + te->ObjectsGenerator = objectGenerator; this->Makefile->GetGlobalGenerator() ->GetExportSets()[exports.GetString()] ->AddTargetExport(te); @@ -715,6 +743,10 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) this->Makefile->GetGlobalGenerator()->AddInstallComponent( runtimeArgs.GetComponent().c_str()); } + if (installsObject) { + this->Makefile->GetGlobalGenerator()->AddInstallComponent( + objectArgs.GetComponent().c_str()); + } if (installsFramework) { this->Makefile->GetGlobalGenerator()->AddInstallComponent( frameworkArgs.GetComponent().c_str()); diff --git a/Source/cmInstallCommand.h b/Source/cmInstallCommand.h index 187a6ce..fde629b 100644 --- a/Source/cmInstallCommand.h +++ b/Source/cmInstallCommand.h @@ -3,7 +3,8 @@ #ifndef cmInstallCommand_h #define cmInstallCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmInstallCommandArguments.cxx b/Source/cmInstallCommandArguments.cxx index 6b15468..b73414d 100644 --- a/Source/cmInstallCommandArguments.cxx +++ b/Source/cmInstallCommandArguments.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmInstallCommandArguments.h" -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmSystemTools.h" diff --git a/Source/cmInstallCommandArguments.h b/Source/cmInstallCommandArguments.h index c1523b2..a576e72 100644 --- a/Source/cmInstallCommandArguments.h +++ b/Source/cmInstallCommandArguments.h @@ -3,7 +3,7 @@ #ifndef cmInstallCommandArguments_h #define cmInstallCommandArguments_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmInstallDirectoryGenerator.cxx b/Source/cmInstallDirectoryGenerator.cxx index dfb3aeb..54ad85c 100644 --- a/Source/cmInstallDirectoryGenerator.cxx +++ b/Source/cmInstallDirectoryGenerator.cxx @@ -48,7 +48,7 @@ void cmInstallDirectoryGenerator::Compute(cmLocalGenerator* lg) } void cmInstallDirectoryGenerator::GenerateScriptActions(std::ostream& os, - Indent const& indent) + Indent indent) { if (this->ActionsPerConfig) { this->cmInstallGenerator::GenerateScriptActions(os, indent); @@ -58,7 +58,7 @@ void cmInstallDirectoryGenerator::GenerateScriptActions(std::ostream& os, } void cmInstallDirectoryGenerator::GenerateScriptForConfig( - std::ostream& os, const std::string& config, Indent const& indent) + std::ostream& os, const std::string& config, Indent indent) { std::vector<std::string> dirs; cmGeneratorExpression ge; @@ -82,7 +82,7 @@ void cmInstallDirectoryGenerator::GenerateScriptForConfig( } void cmInstallDirectoryGenerator::AddDirectoryInstallRule( - std::ostream& os, const std::string& config, Indent const& indent, + std::ostream& os, const std::string& config, Indent indent, std::vector<std::string> const& dirs) { // Write code to install the directories. diff --git a/Source/cmInstallDirectoryGenerator.h b/Source/cmInstallDirectoryGenerator.h index 0518092..aa2cbc6 100644 --- a/Source/cmInstallDirectoryGenerator.h +++ b/Source/cmInstallDirectoryGenerator.h @@ -6,7 +6,8 @@ #include "cmInstallGenerator.h" #include "cmScriptGenerator.h" -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <iosfwd> #include <string> #include <vector> @@ -33,12 +34,11 @@ public: std::string GetDestination(std::string const& config) const; protected: - void GenerateScriptActions(std::ostream& os, - Indent const& indent) CM_OVERRIDE; + void GenerateScriptActions(std::ostream& os, Indent indent) CM_OVERRIDE; void GenerateScriptForConfig(std::ostream& os, const std::string& config, - Indent const& indent) CM_OVERRIDE; + Indent indent) CM_OVERRIDE; void AddDirectoryInstallRule(std::ostream& os, const std::string& config, - Indent const& indent, + Indent indent, std::vector<std::string> const& dirs); cmLocalGenerator* LocalGenerator; std::vector<std::string> Directories; diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx index 39fab4f..b176e85 100644 --- a/Source/cmInstallExportGenerator.cxx +++ b/Source/cmInstallExportGenerator.cxx @@ -166,7 +166,7 @@ void cmInstallExportGenerator::GenerateScript(std::ostream& os) } void cmInstallExportGenerator::GenerateScriptConfigs(std::ostream& os, - Indent const& indent) + Indent indent) { // Create the main install rules first. this->cmInstallGenerator::GenerateScriptConfigs(os, indent); @@ -189,7 +189,7 @@ void cmInstallExportGenerator::GenerateScriptConfigs(std::ostream& os, } void cmInstallExportGenerator::GenerateScriptActions(std::ostream& os, - Indent const& indent) + Indent indent) { // Remove old per-configuration export files if the main changes. std::string installedDir = "$ENV{DESTDIR}"; diff --git a/Source/cmInstallExportGenerator.h b/Source/cmInstallExportGenerator.h index b0fe889..047e6b3 100644 --- a/Source/cmInstallExportGenerator.h +++ b/Source/cmInstallExportGenerator.h @@ -3,7 +3,7 @@ #ifndef cmInstallExportGenerator_h #define cmInstallExportGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmInstallGenerator.h" #include "cmScriptGenerator.h" @@ -44,10 +44,8 @@ public: protected: void GenerateScript(std::ostream& os) CM_OVERRIDE; - void GenerateScriptConfigs(std::ostream& os, - Indent const& indent) CM_OVERRIDE; - void GenerateScriptActions(std::ostream& os, - Indent const& indent) CM_OVERRIDE; + void GenerateScriptConfigs(std::ostream& os, Indent indent) CM_OVERRIDE; + void GenerateScriptActions(std::ostream& os, Indent indent) CM_OVERRIDE; void GenerateImportFile(cmExportSet const* exportSet); void GenerateImportFile(const char* config, cmExportSet const* exportSet); void ComputeTempDir(); diff --git a/Source/cmInstallFilesCommand.h b/Source/cmInstallFilesCommand.h index c3e2919..588c289 100644 --- a/Source/cmInstallFilesCommand.h +++ b/Source/cmInstallFilesCommand.h @@ -3,7 +3,8 @@ #ifndef cmInstallFilesCommand_h #define cmInstallFilesCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmInstallFilesGenerator.cxx b/Source/cmInstallFilesGenerator.cxx index 7daea38..6323a91 100644 --- a/Source/cmInstallFilesGenerator.cxx +++ b/Source/cmInstallFilesGenerator.cxx @@ -54,7 +54,7 @@ std::string cmInstallFilesGenerator::GetDestination( } void cmInstallFilesGenerator::AddFilesInstallRule( - std::ostream& os, std::string const& config, Indent const& indent, + std::ostream& os, std::string const& config, Indent indent, std::vector<std::string> const& files) { // Write code to install the files. @@ -67,7 +67,7 @@ void cmInstallFilesGenerator::AddFilesInstallRule( } void cmInstallFilesGenerator::GenerateScriptActions(std::ostream& os, - Indent const& indent) + Indent indent) { if (this->ActionsPerConfig) { this->cmInstallGenerator::GenerateScriptActions(os, indent); @@ -77,7 +77,7 @@ void cmInstallFilesGenerator::GenerateScriptActions(std::ostream& os, } void cmInstallFilesGenerator::GenerateScriptForConfig( - std::ostream& os, const std::string& config, Indent const& indent) + std::ostream& os, const std::string& config, Indent indent) { std::vector<std::string> files; cmGeneratorExpression ge; diff --git a/Source/cmInstallFilesGenerator.h b/Source/cmInstallFilesGenerator.h index ca8c6e1..62b57f9 100644 --- a/Source/cmInstallFilesGenerator.h +++ b/Source/cmInstallFilesGenerator.h @@ -3,7 +3,7 @@ #ifndef cmInstallFilesGenerator_h #define cmInstallFilesGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmInstallGenerator.h" #include "cmScriptGenerator.h" @@ -34,12 +34,11 @@ public: std::string GetDestination(std::string const& config) const; protected: - void GenerateScriptActions(std::ostream& os, - Indent const& indent) CM_OVERRIDE; + void GenerateScriptActions(std::ostream& os, Indent indent) CM_OVERRIDE; void GenerateScriptForConfig(std::ostream& os, const std::string& config, - Indent const& indent) CM_OVERRIDE; + Indent indent) CM_OVERRIDE; void AddFilesInstallRule(std::ostream& os, std::string const& config, - Indent const& indent, + Indent indent, std::vector<std::string> const& files); cmLocalGenerator* LocalGenerator; diff --git a/Source/cmInstallGenerator.h b/Source/cmInstallGenerator.h index 48e1644..bb1dd54 100644 --- a/Source/cmInstallGenerator.h +++ b/Source/cmInstallGenerator.h @@ -3,7 +3,7 @@ #ifndef cmInstallGenerator_h #define cmInstallGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmInstallType.h" #include "cmScriptGenerator.h" diff --git a/Source/cmInstallProgramsCommand.h b/Source/cmInstallProgramsCommand.h index ca07a2f..2381d79 100644 --- a/Source/cmInstallProgramsCommand.h +++ b/Source/cmInstallProgramsCommand.h @@ -3,7 +3,8 @@ #ifndef cmInstallProgramsCommand_h #define cmInstallProgramsCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmInstallScriptGenerator.h b/Source/cmInstallScriptGenerator.h index 0b54994..e183999 100644 --- a/Source/cmInstallScriptGenerator.h +++ b/Source/cmInstallScriptGenerator.h @@ -3,7 +3,7 @@ #ifndef cmInstallScriptGenerator_h #define cmInstallScriptGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmInstallGenerator.h" diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 88fcc56..84d6f7a 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -58,27 +58,8 @@ void cmInstallTargetGenerator::GenerateScript(std::ostream& os) } void cmInstallTargetGenerator::GenerateScriptForConfig( - std::ostream& os, const std::string& config, Indent const& indent) + std::ostream& os, const std::string& config, Indent indent) { - // Compute the build tree directory from which to copy the target. - std::string fromDirConfig; - if (this->Target->NeedRelinkBeforeInstall(config)) { - fromDirConfig = - this->Target->GetLocalGenerator()->GetCurrentBinaryDirectory(); - fromDirConfig += cmake::GetCMakeFilesDirectory(); - fromDirConfig += "/CMakeRelink.dir/"; - } else { - fromDirConfig = this->Target->GetDirectory(config, this->ImportLibrary); - fromDirConfig += "/"; - } - std::string toDir = - this->ConvertToAbsoluteDestination(this->GetDestination(config)); - toDir += "/"; - - // Compute the list of files to install for this target. - std::vector<std::string> filesFrom; - std::vector<std::string> filesTo; - std::string literal_args; cmStateEnums::TargetType targetType = this->Target->GetType(); cmInstallType type = cmInstallType(); switch (targetType) { @@ -100,7 +81,11 @@ void cmInstallTargetGenerator::GenerateScriptForConfig( assert(false && "INTERFACE_LIBRARY targets have no installable outputs."); break; + case cmStateEnums::OBJECT_LIBRARY: + this->GenerateScriptForConfigObjectLibrary(os, config, indent); + return; + case cmStateEnums::UTILITY: case cmStateEnums::GLOBAL_TARGET: case cmStateEnums::UNKNOWN_LIBRARY: @@ -109,6 +94,31 @@ void cmInstallTargetGenerator::GenerateScriptForConfig( "cmInstallTargetGenerator created with non-installable target."); return; } + + // Compute the build tree directory from which to copy the target. + std::string fromDirConfig; + if (this->Target->NeedRelinkBeforeInstall(config)) { + fromDirConfig = + this->Target->GetLocalGenerator()->GetCurrentBinaryDirectory(); + fromDirConfig += cmake::GetCMakeFilesDirectory(); + fromDirConfig += "/CMakeRelink.dir/"; + } else { + cmStateEnums::ArtifactType artifact = this->ImportLibrary + ? cmStateEnums::ImportLibraryArtifact + : cmStateEnums::RuntimeBinaryArtifact; + fromDirConfig = this->Target->GetDirectory(config, artifact); + fromDirConfig += "/"; + } + + std::string toDir = + this->ConvertToAbsoluteDestination(this->GetDestination(config)); + toDir += "/"; + + // Compute the list of files to install for this target. + std::vector<std::string> filesFrom; + std::vector<std::string> filesTo; + std::string literal_args; + if (targetType == cmStateEnums::EXECUTABLE) { // There is a bug in cmInstallCommand if this fails. assert(this->NamelinkMode == NamelinkModeNone); @@ -315,6 +325,49 @@ void cmInstallTargetGenerator::GenerateScriptForConfig( &cmInstallTargetGenerator::PostReplacementTweaks); } +static std::string computeInstallObjectDir(cmGeneratorTarget* gt, + std::string const& config) +{ + std::string objectDir = "objects"; + if (!config.empty()) { + objectDir += "-"; + objectDir += config; + } + objectDir += "/"; + objectDir += gt->GetName(); + return objectDir; +} + +void cmInstallTargetGenerator::GenerateScriptForConfigObjectLibrary( + std::ostream& os, const std::string& config, Indent indent) +{ + // Compute all the object files inside this target + std::vector<std::string> objects; + this->Target->GetTargetObjectNames(config, objects); + + std::string const dest = this->GetDestination(config) + "/" + + computeInstallObjectDir(this->Target, config); + + std::string const obj_dir = this->Target->GetObjectDirectory(config); + std::string const literal_args = " FILES_FROM_DIR \"" + obj_dir + "\""; + + const char* no_dir_permissions = CM_NULLPTR; + const char* no_rename = CM_NULLPTR; + this->AddInstallRule(os, dest, cmInstallType_FILES, objects, this->Optional, + this->FilePermissions.c_str(), no_dir_permissions, + no_rename, literal_args.c_str(), indent); +} + +void cmInstallTargetGenerator::GetInstallObjectNames( + std::string const& config, std::vector<std::string>& objects) const +{ + this->Target->GetTargetObjectNames(config, objects); + for (std::vector<std::string>::iterator i = objects.begin(); + i != objects.end(); ++i) { + *i = computeInstallObjectDir(this->Target, config) + "/" + *i; + } +} + std::string cmInstallTargetGenerator::GetDestination( std::string const& config) const { @@ -391,7 +444,7 @@ void cmInstallTargetGenerator::Compute(cmLocalGenerator* lg) this->Target = lg->FindLocalNonAliasGeneratorTarget(this->TargetName); } -void cmInstallTargetGenerator::AddTweak(std::ostream& os, Indent const& indent, +void cmInstallTargetGenerator::AddTweak(std::ostream& os, Indent indent, const std::string& config, std::string const& file, TweakMethod tweak) @@ -407,7 +460,7 @@ void cmInstallTargetGenerator::AddTweak(std::ostream& os, Indent const& indent, } } -void cmInstallTargetGenerator::AddTweak(std::ostream& os, Indent const& indent, +void cmInstallTargetGenerator::AddTweak(std::ostream& os, Indent indent, const std::string& config, std::vector<std::string> const& files, TweakMethod tweak) @@ -447,7 +500,7 @@ std::string cmInstallTargetGenerator::GetDestDirPath(std::string const& file) } void cmInstallTargetGenerator::PreReplacementTweaks(std::ostream& os, - Indent const& indent, + Indent indent, const std::string& config, std::string const& file) { @@ -455,7 +508,7 @@ void cmInstallTargetGenerator::PreReplacementTweaks(std::ostream& os, } void cmInstallTargetGenerator::PostReplacementTweaks(std::ostream& os, - Indent const& indent, + Indent indent, const std::string& config, std::string const& file) { @@ -467,7 +520,7 @@ void cmInstallTargetGenerator::PostReplacementTweaks(std::ostream& os, } void cmInstallTargetGenerator::AddInstallNamePatchRule( - std::ostream& os, Indent const& indent, const std::string& config, + std::ostream& os, Indent indent, const std::string& config, std::string const& toDestDirPath) { if (this->ImportLibrary || @@ -568,7 +621,7 @@ void cmInstallTargetGenerator::AddInstallNamePatchRule( } void cmInstallTargetGenerator::AddRPathCheckRule( - std::ostream& os, Indent const& indent, const std::string& config, + std::ostream& os, Indent indent, const std::string& config, std::string const& toDestDirPath) { // Skip the chrpath if the target does not need it. @@ -602,7 +655,7 @@ void cmInstallTargetGenerator::AddRPathCheckRule( } void cmInstallTargetGenerator::AddChrpathPatchRule( - std::ostream& os, Indent const& indent, const std::string& config, + std::ostream& os, Indent indent, const std::string& config, std::string const& toDestDirPath) { // Skip the chrpath if the target does not need it. @@ -697,8 +750,7 @@ void cmInstallTargetGenerator::AddChrpathPatchRule( } } -void cmInstallTargetGenerator::AddStripRule(std::ostream& os, - Indent const& indent, +void cmInstallTargetGenerator::AddStripRule(std::ostream& os, Indent indent, const std::string& toDestDirPath) { @@ -726,8 +778,7 @@ void cmInstallTargetGenerator::AddStripRule(std::ostream& os, os << indent << "endif()\n"; } -void cmInstallTargetGenerator::AddRanlibRule(std::ostream& os, - Indent const& indent, +void cmInstallTargetGenerator::AddRanlibRule(std::ostream& os, Indent indent, const std::string& toDestDirPath) { // Static libraries need ranlib on this platform. @@ -752,7 +803,7 @@ void cmInstallTargetGenerator::AddRanlibRule(std::ostream& os, } void cmInstallTargetGenerator::AddUniversalInstallRule( - std::ostream& os, Indent const& indent, const std::string& toDestDirPath) + std::ostream& os, Indent indent, const std::string& toDestDirPath) { cmMakefile const* mf = this->Target->Target->GetMakefile(); diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h index 084a033..cf2de58 100644 --- a/Source/cmInstallTargetGenerator.h +++ b/Source/cmInstallTargetGenerator.h @@ -3,7 +3,7 @@ #ifndef cmInstallTargetGenerator_h #define cmInstallTargetGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmInstallGenerator.h" #include "cmScriptGenerator.h" @@ -41,6 +41,9 @@ public: std::string GetInstallFilename(const std::string& config) const; + void GetInstallObjectNames(std::string const& config, + std::vector<std::string>& objects) const; + enum NameType { NameNormal, @@ -64,39 +67,39 @@ public: protected: void GenerateScript(std::ostream& os) CM_OVERRIDE; void GenerateScriptForConfig(std::ostream& os, const std::string& config, - Indent const& indent) CM_OVERRIDE; - typedef void (cmInstallTargetGenerator::*TweakMethod)(std::ostream&, - Indent const&, + Indent indent) CM_OVERRIDE; + void GenerateScriptForConfigObjectLibrary(std::ostream& os, + const std::string& config, + Indent indent); + typedef void (cmInstallTargetGenerator::*TweakMethod)(std::ostream&, Indent, const std::string&, std::string const&); - void AddTweak(std::ostream& os, Indent const& indent, - const std::string& config, std::string const& file, - TweakMethod tweak); - void AddTweak(std::ostream& os, Indent const& indent, - const std::string& config, + void AddTweak(std::ostream& os, Indent indent, const std::string& config, + std::string const& file, TweakMethod tweak); + void AddTweak(std::ostream& os, Indent indent, const std::string& config, std::vector<std::string> const& files, TweakMethod tweak); std::string GetDestDirPath(std::string const& file); - void PreReplacementTweaks(std::ostream& os, Indent const& indent, + void PreReplacementTweaks(std::ostream& os, Indent indent, const std::string& config, std::string const& file); - void PostReplacementTweaks(std::ostream& os, Indent const& indent, + void PostReplacementTweaks(std::ostream& os, Indent indent, const std::string& config, std::string const& file); - void AddInstallNamePatchRule(std::ostream& os, Indent const& indent, + void AddInstallNamePatchRule(std::ostream& os, Indent indent, const std::string& config, const std::string& toDestDirPath); - void AddChrpathPatchRule(std::ostream& os, Indent const& indent, + void AddChrpathPatchRule(std::ostream& os, Indent indent, const std::string& config, std::string const& toDestDirPath); - void AddRPathCheckRule(std::ostream& os, Indent const& indent, + void AddRPathCheckRule(std::ostream& os, Indent indent, const std::string& config, std::string const& toDestDirPath); - void AddStripRule(std::ostream& os, Indent const& indent, + void AddStripRule(std::ostream& os, Indent indent, const std::string& toDestDirPath); - void AddRanlibRule(std::ostream& os, Indent const& indent, + void AddRanlibRule(std::ostream& os, Indent indent, const std::string& toDestDirPath); - void AddUniversalInstallRule(std::ostream& os, Indent const& indent, + void AddUniversalInstallRule(std::ostream& os, Indent indent, const std::string& toDestDirPath); std::string TargetName; diff --git a/Source/cmInstallTargetsCommand.h b/Source/cmInstallTargetsCommand.h index 150397d..77f461a 100644 --- a/Source/cmInstallTargetsCommand.h +++ b/Source/cmInstallTargetsCommand.h @@ -3,7 +3,8 @@ #ifndef cmInstallTargetsCommand_h #define cmInstallTargetsCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmInstalledFile.cxx b/Source/cmInstalledFile.cxx index 8dd42b6..d51fd8d 100644 --- a/Source/cmInstalledFile.cxx +++ b/Source/cmInstalledFile.cxx @@ -7,7 +7,7 @@ #include "cmMakefile.h" #include "cmSystemTools.h" -#include <cmConfigure.h> +#include "cmConfigure.h" #include <utility> cmInstalledFile::cmInstalledFile() diff --git a/Source/cmLinkDirectoriesCommand.h b/Source/cmLinkDirectoriesCommand.h index 387b3b9..334b1b8 100644 --- a/Source/cmLinkDirectoriesCommand.h +++ b/Source/cmLinkDirectoriesCommand.h @@ -3,7 +3,8 @@ #ifndef cmLinkDirectoriesCommand_h #define cmLinkDirectoriesCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmLinkItem.h b/Source/cmLinkItem.h index 6fd6f50..f0fded2 100644 --- a/Source/cmLinkItem.h +++ b/Source/cmLinkItem.h @@ -3,7 +3,7 @@ #ifndef cmLinkItem_h #define cmLinkItem_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <algorithm> #include <map> @@ -32,11 +32,6 @@ public: , Target(t) { } - cmLinkItem(cmLinkItem const& r) - : std_string(r) - , Target(r.Target) - { - } cmGeneratorTarget const* Target; }; @@ -56,12 +51,6 @@ public: , FromGenex(fromGenex) { } - cmLinkImplItem(cmLinkImplItem const& r) - : cmLinkItem(r) - , Backtrace(r.Backtrace) - , FromGenex(r.FromGenex) - { - } cmListFileBacktrace Backtrace; bool FromGenex; }; diff --git a/Source/cmLinkLibrariesCommand.h b/Source/cmLinkLibrariesCommand.h index 66d7ec4..430e5a8 100644 --- a/Source/cmLinkLibrariesCommand.h +++ b/Source/cmLinkLibrariesCommand.h @@ -3,7 +3,8 @@ #ifndef cmLinkLibrariesCommand_h #define cmLinkLibrariesCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmLinkLineComputer.h b/Source/cmLinkLineComputer.h index 57a70bc..d8dacf3 100644 --- a/Source/cmLinkLineComputer.h +++ b/Source/cmLinkLineComputer.h @@ -4,7 +4,7 @@ #ifndef cmLinkLineComputer_h #define cmLinkLineComputer_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <string> @@ -41,6 +41,9 @@ public: std::string const& config); protected: + cmLinkLineComputer(cmLinkLineComputer const&); + cmLinkLineComputer& operator=(cmLinkLineComputer const&); + std::string ComputeLinkLibs(cmComputeLinkInformation& cli); std::string ComputeRPath(cmComputeLinkInformation& cli); diff --git a/Source/cmLinkLineDeviceComputer.cxx b/Source/cmLinkLineDeviceComputer.cxx index 6a700ff..6789555 100644 --- a/Source/cmLinkLineDeviceComputer.cxx +++ b/Source/cmLinkLineDeviceComputer.cxx @@ -2,10 +2,18 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmLinkLineDeviceComputer.h" + +#include <set> +#include <sstream> +#include <vector> + #include "cmComputeLinkInformation.h" #include "cmGeneratorTarget.h" #include "cmGlobalNinjaGenerator.h" -#include "cmOutputConverter.h" +#include "cmStateDirectory.h" +#include "cmStateTypes.h" + +class cmOutputConverter; cmLinkLineDeviceComputer::cmLinkLineDeviceComputer( cmOutputConverter* outputConverter, cmStateDirectory stateDir) diff --git a/Source/cmLinkLineDeviceComputer.h b/Source/cmLinkLineDeviceComputer.h index f4bb3eb..a827b06 100644 --- a/Source/cmLinkLineDeviceComputer.h +++ b/Source/cmLinkLineDeviceComputer.h @@ -4,8 +4,17 @@ #ifndef cmLinkLineDeviceComputer_h #define cmLinkLineDeviceComputer_h +#include "cmConfigure.h" + +#include <string> + #include "cmLinkLineComputer.h" + +class cmComputeLinkInformation; +class cmGeneratorTarget; class cmGlobalNinjaGenerator; +class cmOutputConverter; +class cmStateDirectory; class cmLinkLineDeviceComputer : public cmLinkLineComputer { diff --git a/Source/cmLinkedTree.h b/Source/cmLinkedTree.h index 4f95522..55592cb 100644 --- a/Source/cmLinkedTree.h +++ b/Source/cmLinkedTree.h @@ -3,7 +3,7 @@ #ifndef cmLinkedTree_h #define cmLinkedTree_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <assert.h> #include <iterator> diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx index 295ea28..0542c4f 100644 --- a/Source/cmListCommand.cxx +++ b/Source/cmListCommand.cxx @@ -2,9 +2,9 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmListCommand.h" +#include "cmsys/RegularExpression.hxx" #include <algorithm> #include <assert.h> -#include <cmsys/RegularExpression.hxx> #include <iterator> #include <sstream> #include <stdio.h> diff --git a/Source/cmListCommand.h b/Source/cmListCommand.h index e7413ca..8d4aeb1 100644 --- a/Source/cmListCommand.h +++ b/Source/cmListCommand.h @@ -3,7 +3,8 @@ #ifndef cmListCommand_h #define cmListCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx index b1cd889..929b1cd 100644 --- a/Source/cmListFileCache.cxx +++ b/Source/cmListFileCache.cxx @@ -9,14 +9,14 @@ #include "cmSystemTools.h" #include "cmake.h" +#include "cmConfigure.h" #include <algorithm> #include <assert.h> -#include <cmConfigure.h> #include <sstream> struct cmListFileParser { - cmListFileParser(cmListFile* lf, cmListFileBacktrace lfbt, + cmListFileParser(cmListFile* lf, cmListFileBacktrace const& lfbt, cmMessenger* messenger, const char* filename); ~cmListFileParser(); void IssueFileOpenError(std::string const& text) const; @@ -39,7 +39,8 @@ struct cmListFileParser } Separation; }; -cmListFileParser::cmListFileParser(cmListFile* lf, cmListFileBacktrace lfbt, +cmListFileParser::cmListFileParser(cmListFile* lf, + cmListFileBacktrace const& lfbt, cmMessenger* messenger, const char* filename) : ListFile(lf) @@ -80,6 +81,13 @@ bool cmListFileParser::ParseFile() return false; } + if (bom == cmListFileLexer_BOM_Broken) { + cmListFileLexer_SetFileName(this->Lexer, CM_NULLPTR, CM_NULLPTR); + this->IssueFileOpenError("Error while reading Byte-Order-Mark. " + "File not seekable?"); + return false; + } + // Verify the Byte-Order-Mark, if any. if (bom != cmListFileLexer_BOM_None && bom != cmListFileLexer_BOM_UTF8) { cmListFileLexer_SetFileName(this->Lexer, CM_NULLPTR, CM_NULLPTR); diff --git a/Source/cmListFileCache.h b/Source/cmListFileCache.h index 1a30f29..aa11ba7 100644 --- a/Source/cmListFileCache.h +++ b/Source/cmListFileCache.h @@ -3,7 +3,7 @@ #ifndef cmListFileCache_h #define cmListFileCache_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <iosfwd> #include <string> @@ -45,12 +45,6 @@ struct cmListFileArgument , Line(0) { } - cmListFileArgument(const cmListFileArgument& r) - : Value(r.Value) - , Delim(r.Delim) - , Line(r.Line) - { - } cmListFileArgument(const std::string& v, Delimiter d, long line) : Value(v) , Delim(d) diff --git a/Source/cmListFileLexer.c b/Source/cmListFileLexer.c index 56559f6..3dd3b85 100644 --- a/Source/cmListFileLexer.c +++ b/Source/cmListFileLexer.c @@ -558,7 +558,7 @@ Modify cmListFileLexer.c: /* IWYU pragma: no_forward_declare yyguts_t */ #ifdef WIN32 -#include <cmsys/Encoding.h> +#include "cmsys/Encoding.h" #endif /* Setup the proper cmListFileLexer_yylex declaration. */ @@ -2559,11 +2559,15 @@ static cmListFileLexer_BOM cmListFileLexer_ReadBOM(FILE* f) if (fread(b, 1, 2, f) == 2 && b[0] == 0 && b[1] == 0) { return cmListFileLexer_BOM_UTF32LE; } - fsetpos(f, &p); + if (fsetpos(f, &p) != 0) { + return cmListFileLexer_BOM_Broken; + } return cmListFileLexer_BOM_UTF16LE; } } - rewind(f); + if (fseek(f, 0, SEEK_SET) != 0) { + return cmListFileLexer_BOM_Broken; + } return cmListFileLexer_BOM_None; } diff --git a/Source/cmListFileLexer.h b/Source/cmListFileLexer.h index c9fb6da..f243010a 100644 --- a/Source/cmListFileLexer.h +++ b/Source/cmListFileLexer.h @@ -32,6 +32,7 @@ struct cmListFileLexer_Token_s enum cmListFileLexer_BOM_e { cmListFileLexer_BOM_None, + cmListFileLexer_BOM_Broken, cmListFileLexer_BOM_UTF8, cmListFileLexer_BOM_UTF16BE, cmListFileLexer_BOM_UTF16LE, diff --git a/Source/cmListFileLexer.in.l b/Source/cmListFileLexer.in.l index dd64923..5152dbf 100644 --- a/Source/cmListFileLexer.in.l +++ b/Source/cmListFileLexer.in.l @@ -21,7 +21,7 @@ Modify cmListFileLexer.c: /* IWYU pragma: no_forward_declare yyguts_t */ #ifdef WIN32 -#include <cmsys/Encoding.h> +#include "cmsys/Encoding.h" #endif /* Setup the proper cmListFileLexer_yylex declaration. */ diff --git a/Source/cmLoadCacheCommand.cxx b/Source/cmLoadCacheCommand.cxx index ea84877..00a30bf 100644 --- a/Source/cmLoadCacheCommand.cxx +++ b/Source/cmLoadCacheCommand.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmLoadCacheCommand.h" -#include <cmsys/FStream.hxx> +#include "cmsys/FStream.hxx" #include "cmMakefile.h" #include "cmStateTypes.h" diff --git a/Source/cmLoadCacheCommand.h b/Source/cmLoadCacheCommand.h index 539c74e..8dee973 100644 --- a/Source/cmLoadCacheCommand.h +++ b/Source/cmLoadCacheCommand.h @@ -3,7 +3,8 @@ #ifndef cmLoadCacheCommand_h #define cmLoadCacheCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <set> #include <string> #include <vector> diff --git a/Source/cmLoadCommandCommand.cxx b/Source/cmLoadCommandCommand.cxx index b6743f1..5cf1853 100644 --- a/Source/cmLoadCommandCommand.cxx +++ b/Source/cmLoadCommandCommand.cxx @@ -2,22 +2,21 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmLoadCommandCommand.h" +#include <signal.h> +#include <sstream> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + #include "cmCPluginAPI.cxx" #include "cmCPluginAPI.h" #include "cmDynamicLoader.h" #include "cmMakefile.h" -#include "cmPolicies.h" #include "cmState.h" #include "cmSystemTools.h" class cmExecutionStatus; -#include <signal.h> -#include <sstream> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - #ifdef __QNX__ #include <malloc.h> /* for malloc/free on QNX */ #endif @@ -174,11 +173,6 @@ cmLoadedCommand::~cmLoadedCommand() bool cmLoadCommandCommand::InitialPass(std::vector<std::string> const& args, cmExecutionStatus&) { - if (this->Disallowed( - cmPolicies::CMP0031, - "The load_command command should not be called; see CMP0031.")) { - return true; - } if (args.empty()) { return true; } diff --git a/Source/cmLoadCommandCommand.h b/Source/cmLoadCommandCommand.h index d16dfea..97a6bd7 100644 --- a/Source/cmLoadCommandCommand.h +++ b/Source/cmLoadCommandCommand.h @@ -3,7 +3,8 @@ #ifndef cmLoadCommandCommand_h #define cmLoadCommandCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmLocalCommonGenerator.h b/Source/cmLocalCommonGenerator.h index f83f371..3de29d7 100644 --- a/Source/cmLocalCommonGenerator.h +++ b/Source/cmLocalCommonGenerator.h @@ -3,7 +3,7 @@ #ifndef cmLocalCommonGenerator_h #define cmLocalCommonGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <string> diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 7077bbb..424ab6f 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -13,7 +13,6 @@ #include "cmInstallScriptGenerator.h" #include "cmInstallTargetGenerator.h" #include "cmLinkLineComputer.h" -#include "cmLinkLineDeviceComputer.h" #include "cmMakefile.h" #include "cmRulePlaceholderExpander.h" #include "cmSourceFile.h" @@ -31,9 +30,9 @@ #include "cmCryptoHash.h" #endif +#include "cmsys/RegularExpression.hxx" #include <algorithm> #include <assert.h> -#include <cmsys/RegularExpression.hxx> #include <iterator> #include <sstream> #include <stdio.h> @@ -1053,7 +1052,7 @@ void cmLocalGenerator::GetTargetCompileFlags(cmGeneratorTarget* target, // Add language-specific flags. this->AddLanguageFlags(flags, lang, config); - if (target->GetFeatureAsBool("INTERPROCEDURAL_OPTIMIZATION", config)) { + if (target->IsIPOEnabled(config)) { this->AppendFeatureOptions(flags, lang, "IPO"); } @@ -2163,7 +2162,7 @@ bool cmLocalGenerator::IsNMake() const std::string cmLocalGenerator::GetObjectFileNameWithoutTarget( const cmSourceFile& source, std::string const& dir_max, - bool* hasSourceExtension) + bool* hasSourceExtension, char const* customOutputExtension) { // Construct the object file name using the full path to the source // file which is its only unique identification. @@ -2224,7 +2223,7 @@ std::string cmLocalGenerator::GetObjectFileNameWithoutTarget( } // Remove the source extension if it is to be replaced. - if (replaceExt) { + if (replaceExt || customOutputExtension) { keptSourceExtension = false; std::string::size_type dot_pos = objectName.rfind('.'); if (dot_pos != std::string::npos) { @@ -2233,7 +2232,11 @@ std::string cmLocalGenerator::GetObjectFileNameWithoutTarget( } // Store the new extension. - objectName += this->GlobalGenerator->GetLanguageOutputExtension(source); + if (customOutputExtension) { + objectName += customOutputExtension; + } else { + objectName += this->GlobalGenerator->GetLanguageOutputExtension(source); + } } if (hasSourceExtension) { *hasSourceExtension = keptSourceExtension; diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 901ca35..1459a05 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -3,9 +3,9 @@ #ifndef cmLocalGenerator_h #define cmLocalGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" -#include <cm_kwiml.h> +#include "cm_kwiml.h" #include <iosfwd> #include <map> #include <set> @@ -273,7 +273,8 @@ public: // Compute object file names. std::string GetObjectFileNameWithoutTarget( const cmSourceFile& source, std::string const& dir_max, - bool* hasSourceExtension = CM_NULLPTR); + bool* hasSourceExtension = CM_NULLPTR, + char const* customOutputExtension = CM_NULLPTR); /** Fill out the static linker flags for the given target. */ void GetStaticLibraryFlags(std::string& flags, std::string const& config, diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index c2d9d57..e0e3e54 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -249,12 +249,15 @@ void cmLocalNinjaGenerator::ComputeObjectFilenames( std::map<cmSourceFile const*, std::string>& mapping, cmGeneratorTarget const* gt) { + // Determine if these object files should use a custom extension + char const* custom_ext = gt->GetCustomObjectExtension(); for (std::map<cmSourceFile const*, std::string>::iterator si = mapping.begin(); si != mapping.end(); ++si) { cmSourceFile const* sf = si->first; - si->second = - this->GetObjectFileNameWithoutTarget(*sf, gt->ObjectDirectory); + bool keptSourceExtension; + si->second = this->GetObjectFileNameWithoutTarget( + *sf, gt->ObjectDirectory, &keptSourceExtension, custom_ext); } } @@ -278,9 +281,11 @@ void cmLocalNinjaGenerator::AppendTargetOutputs(cmGeneratorTarget* target, } void cmLocalNinjaGenerator::AppendTargetDepends(cmGeneratorTarget* target, - cmNinjaDeps& outputs) + cmNinjaDeps& outputs, + cmNinjaTargetDepends depends) { - this->GetGlobalNinjaGenerator()->AppendTargetDepends(target, outputs); + this->GetGlobalNinjaGenerator()->AppendTargetDepends(target, outputs, + depends); } void cmLocalNinjaGenerator::AppendCustomCommandDeps( diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index 1080319..a45e018 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -3,7 +3,7 @@ #ifndef cmLocalNinjaGenerator_h #define cmLocalNinjaGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <iosfwd> #include <map> @@ -63,7 +63,9 @@ public: std::string BuildCommandLine(const std::vector<std::string>& cmdLines); void AppendTargetOutputs(cmGeneratorTarget* target, cmNinjaDeps& outputs); - void AppendTargetDepends(cmGeneratorTarget* target, cmNinjaDeps& outputs); + void AppendTargetDepends( + cmGeneratorTarget* target, cmNinjaDeps& outputs, + cmNinjaTargetDepends depends = DependOnTargetArtifact); void AddCustomCommandTarget(cmCustomCommand const* cc, cmGeneratorTarget* target); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 41a4caf..5f52786 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -2,9 +2,9 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmLocalUnixMakefileGenerator3.h" +#include "cmsys/FStream.hxx" +#include "cmsys/Terminal.h" #include <algorithm> -#include <cmsys/FStream.hxx> -#include <cmsys/Terminal.h> #include <functional> #include <sstream> #include <stdio.h> @@ -159,12 +159,15 @@ void cmLocalUnixMakefileGenerator3::ComputeObjectFilenames( std::map<cmSourceFile const*, std::string>& mapping, cmGeneratorTarget const* gt) { + // Determine if these object files should use a custom extension + char const* custom_ext = gt->GetCustomObjectExtension(); for (std::map<cmSourceFile const*, std::string>::iterator si = mapping.begin(); si != mapping.end(); ++si) { cmSourceFile const* sf = si->first; - si->second = - this->GetObjectFileNameWithoutTarget(*sf, gt->ObjectDirectory); + bool keptSourceExtension; + si->second = this->GetObjectFileNameWithoutTarget( + *sf, gt->ObjectDirectory, &keptSourceExtension, custom_ext); } } @@ -1864,10 +1867,7 @@ void cmLocalUnixMakefileGenerator3::WriteDependLanguageInfo( std::string binaryDir = this->GetState()->GetBinaryDirectory(); if (this->Makefile->IsOn("CMAKE_DEPENDS_IN_PROJECT_ONLY")) { const char* sourceDir = this->GetState()->GetSourceDirectory(); - std::vector<std::string>::iterator itr = - std::remove_if(includes.begin(), includes.end(), - ::NotInProjectDir(sourceDir, binaryDir)); - includes.erase(itr, includes.end()); + cmEraseIf(includes, ::NotInProjectDir(sourceDir, binaryDir)); } for (std::vector<std::string>::iterator i = includes.begin(); i != includes.end(); ++i) { diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index c3ecda4..f64409c 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -3,7 +3,7 @@ #ifndef cmLocalUnixMakefileGenerator3_h #define cmLocalUnixMakefileGenerator3_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmDepends.h" #include "cmLocalCommonGenerator.h" diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx index 0516bdf..85d4a73 100644 --- a/Source/cmLocalVisualStudio10Generator.cxx +++ b/Source/cmLocalVisualStudio10Generator.cxx @@ -8,7 +8,7 @@ #include "cmVisualStudio10TargetGenerator.h" #include "cmXMLParser.h" -#include <cm_expat.h> +#include "cm_expat.h" class cmVS10XMLParser : public cmXMLParser { diff --git a/Source/cmLocalVisualStudio10Generator.h b/Source/cmLocalVisualStudio10Generator.h index 1ed57ec..e57dd8f 100644 --- a/Source/cmLocalVisualStudio10Generator.h +++ b/Source/cmLocalVisualStudio10Generator.h @@ -3,7 +3,7 @@ #ifndef cmLocalVisualStudio10Generator_h #define cmLocalVisualStudio10Generator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <string> diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 38dda04..f86c034 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -9,13 +9,14 @@ #include "cmSourceFile.h" #include "cmSystemTools.h" #include "cmXMLParser.h" +#include "cm_expat.h" #include "cmake.h" -#include <cm_expat.h> #include "cmComputeLinkInformation.h" #include "cmGeneratedFileStream.h" #include <ctype.h> // for isspace +#include <windows.h> static bool cmLVS7G_IsFAT(const char* dir); @@ -29,7 +30,7 @@ public: typedef cmComputeLinkInformation::ItemVector ItemVector; void OutputLibraries(std::ostream& fout, ItemVector const& libs); void OutputObjects(std::ostream& fout, cmGeneratorTarget* t, - const char* isep = 0); + std::string const& config, const char* isep = 0); private: cmLocalVisualStudio7Generator* LocalGenerator; @@ -669,6 +670,9 @@ void cmLocalVisualStudio7Generator::WriteConfiguration( // Add the target-specific flags. this->AddCompileOptions(flags, target, linkLanguage, configName); + + // Check IPO related warning/error. + target->IsIPOEnabled(configName); } if (this->FortranProject) { @@ -745,11 +749,13 @@ void cmLocalVisualStudio7Generator::WriteConfiguration( if (this->FortranProject) { // Intel Fortran >= 15.0 uses TargetName property. - std::string targetNameFull = target->GetFullName(configName); - std::string targetName = + std::string const targetNameFull = target->GetFullName(configName); + std::string const targetName = cmSystemTools::GetFilenameWithoutLastExtension(targetNameFull); - std::string targetExt = - cmSystemTools::GetFilenameLastExtension(targetNameFull); + std::string const targetExt = + target->GetType() == cmStateEnums::OBJECT_LIBRARY + ? ".lib" + : cmSystemTools::GetFilenameLastExtension(targetNameFull); /* clang-format off */ fout << "\t\t\tTargetName=\"" << this->EscapeForXML(targetName) << "\"\n" @@ -787,7 +793,6 @@ void cmLocalVisualStudio7Generator::WriteConfiguration( << this->ConvertToXMLOutputPath(modDir.c_str()) << "\\$(ConfigurationName)\"\n"; } - targetOptions.OutputAdditionalOptions(fout, "\t\t\t\t", "\n"); fout << "\t\t\t\tAdditionalIncludeDirectories=\""; std::vector<std::string> includes; this->GetIncludeDirectories(includes, target, "C", configName); @@ -893,8 +898,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration( // end of <Tool Name=VCMIDLTool // Add manifest tool settings. - if (targetBuilds && - this->GetVersion() >= cmGlobalVisualStudioGenerator::VS8) { + if (targetBuilds) { const char* manifestTool = "VCManifestTool"; if (this->FortranProject) { manifestTool = "VFManifestTool"; @@ -997,19 +1001,14 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( linkOptions.AddTable(cmLocalVisualStudio7GeneratorLinkFlagTable); linkOptions.Parse(extraLinkOptions.c_str()); - if (!this->ModuleDefinitionFile.empty()) { - std::string defFile = this->ConvertToOutputFormat( - this->ModuleDefinitionFile, cmOutputConverter::SHELL); + cmGeneratorTarget::ModuleDefinitionInfo const* mdi = + target->GetModuleDefinitionInfo(configName); + if (mdi && !mdi->DefFile.empty()) { + std::string defFile = + this->ConvertToOutputFormat(mdi->DefFile, cmOutputConverter::SHELL); linkOptions.AddFlag("ModuleDefinitionFile", defFile.c_str()); } - if ((target->GetType() == cmStateEnums::SHARED_LIBRARY || - target->IsExecutableWithExports()) && - this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) { - if (target->GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) { - linkOptions.AddFlag("ModuleDefinitionFile", "$(IntDir)/exportall.def"); - } - } switch (target->GetType()) { case cmStateEnums::UNKNOWN_LIBRARY: break; @@ -1040,10 +1039,9 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( fout << "\t\t\t<Tool\n" << "\t\t\t\tName=\"" << tool << "\"\n"; - if (this->GetVersion() < cmGlobalVisualStudioGenerator::VS8 || - this->FortranProject) { + if (this->FortranProject) { std::ostringstream libdeps; - this->Internal->OutputObjects(libdeps, target); + this->Internal->OutputObjects(libdeps, target, configName); if (!libdeps.str().empty()) { fout << "\t\t\t\tAdditionalDependencies=\"" << libdeps.str() << "\"\n"; @@ -1090,14 +1088,12 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( if (!gg->NeedLinkLibraryDependencies(target)) { fout << "\t\t\t\tLinkLibraryDependencies=\"false\"\n"; } - linkOptions.OutputAdditionalOptions(fout, "\t\t\t\t", "\n"); // Use the NOINHERIT macro to avoid getting VS project default // libraries which may be set by the user to something bad. fout << "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) " << this->Makefile->GetSafeDefinition(standardLibsVar.c_str()); - if (this->GetVersion() < cmGlobalVisualStudioGenerator::VS8 || - this->FortranProject) { - this->Internal->OutputObjects(fout, target, " "); + if (this->FortranProject) { + this->Internal->OutputObjects(fout, target, configName, " "); } fout << " "; this->Internal->OutputLibraries(fout, cli.GetItems()); @@ -1134,7 +1130,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( if (stackVal) { fout << "\t\t\t\tStackReserveSize=\"" << stackVal << "\"\n"; } - temp = target->GetDirectory(configName, true); + temp = + target->GetDirectory(configName, cmStateEnums::ImportLibraryArtifact); temp += "/"; temp += targetNameImport; fout << "\t\t\t\tImportLibrary=\"" @@ -1176,14 +1173,12 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( if (!gg->NeedLinkLibraryDependencies(target)) { fout << "\t\t\t\tLinkLibraryDependencies=\"false\"\n"; } - linkOptions.OutputAdditionalOptions(fout, "\t\t\t\t", "\n"); // Use the NOINHERIT macro to avoid getting VS project default // libraries which may be set by the user to something bad. fout << "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) " << this->Makefile->GetSafeDefinition(standardLibsVar.c_str()); - if (this->GetVersion() < cmGlobalVisualStudioGenerator::VS8 || - this->FortranProject) { - this->Internal->OutputObjects(fout, target, " "); + if (this->FortranProject) { + this->Internal->OutputObjects(fout, target, configName, " "); } fout << " "; this->Internal->OutputLibraries(fout, cli.GetItems()); @@ -1233,7 +1228,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( if (stackVal) { fout << "\t\t\t\tStackReserveSize=\"" << stackVal << "\""; } - temp = target->GetDirectory(configName, true); + temp = + target->GetDirectory(configName, cmStateEnums::ImportLibraryArtifact); temp += "/"; temp += targetNameImport; fout << "\t\t\t\tImportLibrary=\"" @@ -1302,20 +1298,26 @@ void cmLocalVisualStudio7GeneratorInternals::OutputLibraries( } void cmLocalVisualStudio7GeneratorInternals::OutputObjects( - std::ostream& fout, cmGeneratorTarget* gt, const char* isep) + std::ostream& fout, cmGeneratorTarget* gt, std::string const& configName, + const char* isep) { // VS < 8 does not support per-config source locations so we // list object library content on the link line instead. cmLocalVisualStudio7Generator* lg = this->LocalGenerator; std::string currentBinDir = lg->GetCurrentBinaryDirectory(); - std::vector<std::string> objs; - gt->UseObjectLibraries(objs, ""); + + std::vector<cmSourceFile const*> objs; + gt->GetExternalObjects(objs, configName); + const char* sep = isep ? isep : ""; - for (std::vector<std::string>::const_iterator oi = objs.begin(); - oi != objs.end(); ++oi) { - std::string rel = lg->ConvertToRelativePath(currentBinDir, oi->c_str()); - fout << sep << lg->ConvertToXMLOutputPath(rel.c_str()); - sep = " "; + for (std::vector<cmSourceFile const*>::const_iterator i = objs.begin(); + i != objs.end(); ++i) { + if (!(*i)->GetObjectLibrary().empty()) { + std::string const& objFile = (*i)->GetFullPath(); + std::string rel = lg->ConvertToRelativePath(currentBinDir, objFile); + fout << sep << lg->ConvertToXMLOutputPath(rel.c_str()); + sep = " "; + } } } @@ -1364,25 +1366,26 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, // We may be modifying the source groups temporarily, so make a copy. std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups(); - // get the classes from the source lists then add them to the groups - this->ModuleDefinitionFile = ""; - std::vector<cmSourceFile*> classes; - if (!target->GetConfigCommonSourceFiles(classes)) { - return; - } - for (std::vector<cmSourceFile*>::const_iterator i = classes.begin(); - i != classes.end(); i++) { - if (!(*i)->GetObjectLibrary().empty()) { - continue; + std::vector<cmGeneratorTarget::AllConfigSource> const& sources = + target->GetAllConfigSources(); + std::map<cmSourceFile const*, size_t> sourcesIndex; + + for (size_t si = 0; si < sources.size(); ++si) { + cmSourceFile const* sf = sources[si].Source; + sourcesIndex[sf] = si; + if (!sf->GetObjectLibrary().empty()) { + if (this->FortranProject) { + // Intel Fortran does not support per-config source locations + // so we list object library content on the link line instead. + // See OutputObjects. + continue; + } } // Add the file to the list of sources. - std::string source = (*i)->GetFullPath(); - if (cmSystemTools::UpperCase((*i)->GetExtension()) == "DEF") { - this->ModuleDefinitionFile = (*i)->GetFullPath(); - } + std::string const source = sf->GetFullPath(); cmSourceGroup* sourceGroup = this->Makefile->FindSourceGroup(source.c_str(), sourceGroups); - sourceGroup->AssignSource(*i); + sourceGroup->AssignSource(sf); } // open the project @@ -1395,25 +1398,7 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, // Loop through every source group. for (unsigned int i = 0; i < sourceGroups.size(); ++i) { cmSourceGroup sg = sourceGroups[i]; - this->WriteGroup(&sg, target, fout, libName, configs); - } - - if (this->GetVersion() >= cmGlobalVisualStudioGenerator::VS8 && - !this->FortranProject) { - // VS >= 8 support per-config source locations so we - // list object library content as external objects. - std::vector<std::string> objs; - target->UseObjectLibraries(objs, ""); - if (!objs.empty()) { - // TODO: Separate sub-filter for each object library used? - fout << "\t\t<Filter Name=\"Object Libraries\">\n"; - for (std::vector<std::string>::const_iterator oi = objs.begin(); - oi != objs.end(); ++oi) { - std::string o = this->ConvertToXMLOutputPathSingle(oi->c_str()); - fout << "\t\t\t<File RelativePath=\"" << o << "\" />\n"; - } - fout << "\t\t</Filter>\n"; - } + this->WriteGroup(&sg, target, fout, libName, configs, sourcesIndex); } fout << "\t</Files>\n"; @@ -1435,25 +1420,28 @@ struct cmLVS7GFileConfig class cmLocalVisualStudio7GeneratorFCInfo { public: - cmLocalVisualStudio7GeneratorFCInfo(cmLocalVisualStudio7Generator* lg, - cmGeneratorTarget* target, - cmSourceFile const& sf, - std::vector<std::string> const& configs); + cmLocalVisualStudio7GeneratorFCInfo( + cmLocalVisualStudio7Generator* lg, cmGeneratorTarget* target, + cmGeneratorTarget::AllConfigSource const& acs, + std::vector<std::string> const& configs); std::map<std::string, cmLVS7GFileConfig> FileConfigMap; }; cmLocalVisualStudio7GeneratorFCInfo::cmLocalVisualStudio7GeneratorFCInfo( cmLocalVisualStudio7Generator* lg, cmGeneratorTarget* gt, - cmSourceFile const& sf, std::vector<std::string> const& configs) + cmGeneratorTarget::AllConfigSource const& acs, + std::vector<std::string> const& configs) { + cmSourceFile const& sf = *acs.Source; std::string objectName; if (gt->HasExplicitObjectName(&sf)) { objectName = gt->GetObjectName(&sf); } // Compute per-source, per-config information. + size_t ci = 0; for (std::vector<std::string>::const_iterator i = configs.begin(); - i != configs.end(); ++i) { + i != configs.end(); ++i, ++ci) { std::string configUpper = cmSystemTools::UpperCase(*i); cmLVS7GFileConfig fc; bool needfc = false; @@ -1519,7 +1507,9 @@ cmLocalVisualStudio7GeneratorFCInfo::cmLocalVisualStudio7GeneratorFCInfo( } // If HEADER_FILE_ONLY is set, we must suppress this generation in // the project file - fc.ExcludedFromBuild = (sf.GetPropertyAsBool("HEADER_FILE_ONLY")); + fc.ExcludedFromBuild = sf.GetPropertyAsBool("HEADER_FILE_ONLY") || + std::find(acs.Configs.begin(), acs.Configs.end(), ci) == + acs.Configs.end(); if (fc.ExcludedFromBuild) { needfc = true; } @@ -1574,7 +1564,8 @@ std::string cmLocalVisualStudio7Generator::ComputeLongestObjectDirectory( bool cmLocalVisualStudio7Generator::WriteGroup( const cmSourceGroup* sg, cmGeneratorTarget* target, std::ostream& fout, - const std::string& libName, std::vector<std::string> const& configs) + const std::string& libName, std::vector<std::string> const& configs, + std::map<cmSourceFile const*, size_t> const& sourcesIndex) { cmGlobalVisualStudio7Generator* gg = static_cast<cmGlobalVisualStudio7Generator*>(this->GlobalGenerator); @@ -1585,7 +1576,8 @@ bool cmLocalVisualStudio7Generator::WriteGroup( bool hasChildrenWithSources = false; std::ostringstream tmpOut; for (unsigned int i = 0; i < children.size(); ++i) { - if (this->WriteGroup(&children[i], target, tmpOut, libName, configs)) { + if (this->WriteGroup(&children[i], target, tmpOut, libName, configs, + sourcesIndex)) { hasChildrenWithSources = true; } } @@ -1601,15 +1593,26 @@ bool cmLocalVisualStudio7Generator::WriteGroup( this->WriteVCProjBeginGroup(fout, name.c_str(), ""); } + std::vector<cmGeneratorTarget::AllConfigSource> const& sources = + target->GetAllConfigSources(); + // Loop through each source in the source group. for (std::vector<const cmSourceFile*>::const_iterator sf = sourceFiles.begin(); sf != sourceFiles.end(); ++sf) { std::string source = (*sf)->GetFullPath(); - FCInfo fcinfo(this, target, *(*sf), configs); if (source != libName || target->GetType() == cmStateEnums::UTILITY || target->GetType() == cmStateEnums::GLOBAL_TARGET) { + // Look up the source kind and configs. + std::map<cmSourceFile const*, size_t>::const_iterator map_it = + sourcesIndex.find(*sf); + // The map entry must exist because we populated it earlier. + assert(map_it != sourcesIndex.end()); + cmGeneratorTarget::AllConfigSource const& acs = sources[map_it->second]; + + FCInfo fcinfo(this, target, acs, configs); + fout << "\t\t\t<File\n"; std::string d = this->ConvertToXMLOutputPathSingle(source.c_str()); // Tell MS-Dev what the source is. If the compiler knows how to @@ -1649,6 +1652,9 @@ bool cmLocalVisualStudio7Generator::WriteGroup( lang == "ASM_MASM") { aCompilerTool = "MASM"; } + if (acs.Kind == cmGeneratorTarget::SourceKindExternalObject) { + aCompilerTool = "VCCustomBuildTool"; + } for (std::map<std::string, cmLVS7GFileConfig>::const_iterator fci = fcinfo.FileConfigMap.begin(); fci != fcinfo.FileConfigMap.end(); ++fci) { @@ -1675,7 +1681,6 @@ bool cmLocalVisualStudio7Generator::WriteGroup( fileOptions.Parse(fc.CompileFlags.c_str()); fileOptions.AddDefines(fc.CompileDefs.c_str()); fileOptions.AddDefines(fc.CompileDefsConfig.c_str()); - fileOptions.OutputAdditionalOptions(fout, "\t\t\t\t\t", "\n"); fileOptions.OutputFlagMap(fout, "\t\t\t\t\t"); fileOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t\t", "\n", ppLang); @@ -1829,17 +1834,15 @@ void cmLocalVisualStudio7Generator::OutputTargetRules( tool = this->FortranProject ? "VFPreLinkEventTool" : "VCPreLinkEventTool"; event.Start(tool); bool addedPrelink = false; - if ((target->GetType() == cmStateEnums::SHARED_LIBRARY || - target->IsExecutableWithExports()) && - this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) { - if (target->GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) { - addedPrelink = true; - std::vector<cmCustomCommand> commands = target->GetPreLinkCommands(); - cmGlobalVisualStudioGenerator* gg = - static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator); - gg->AddSymbolExportCommand(target, commands, configName); - event.Write(commands); - } + cmGeneratorTarget::ModuleDefinitionInfo const* mdi = + target->GetModuleDefinitionInfo(configName); + if (mdi && mdi->DefFileGenerated) { + addedPrelink = true; + std::vector<cmCustomCommand> commands = target->GetPreLinkCommands(); + cmGlobalVisualStudioGenerator* gg = + static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator); + gg->AddSymbolExportCommand(target, commands, configName); + event.Write(commands); } if (!addedPrelink) { event.Write(target->GetPreLinkCommands()); @@ -1956,11 +1959,7 @@ void cmLocalVisualStudio7Generator::WriteProjectStart( << "<VisualStudioProject\n" << "\tProjectType=\"Visual C++\"\n"; /* clang-format on */ - if (gg->GetVersion() == cmGlobalVisualStudioGenerator::VS71) { - fout << "\tVersion=\"7.10\"\n"; - } else { - fout << "\tVersion=\"" << (gg->GetVersion() / 10) << ".00\"\n"; - } + fout << "\tVersion=\"" << (gg->GetVersion() / 10) << ".00\"\n"; const char* projLabel = target->GetProperty("PROJECT_LABEL"); if (!projLabel) { projLabel = libName.c_str(); @@ -1970,9 +1969,7 @@ void cmLocalVisualStudio7Generator::WriteProjectStart( keyword = "Win32Proj"; } fout << "\tName=\"" << projLabel << "\"\n"; - if (gg->GetVersion() >= cmGlobalVisualStudioGenerator::VS8) { - fout << "\tProjectGUID=\"{" << gg->GetGUID(libName.c_str()) << "}\"\n"; - } + fout << "\tProjectGUID=\"{" << gg->GetGUID(libName.c_str()) << "}\"\n"; this->WriteProjectSCC(fout, target); if (const char* targetFrameworkVersion = target->GetProperty("VS_DOTNET_TARGET_FRAMEWORK_VERSION")) { @@ -2130,7 +2127,6 @@ std::string cmLocalVisualStudio7Generator::GetTargetDirectory( return dir; } -#include <windows.h> static bool cmLVS7G_IsFAT(const char* dir) { if (dir[0] && dir[1] == ':') { diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index d69cce1..89a3ee3 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -3,7 +3,7 @@ #ifndef cmLocalVisualStudio7Generator_h #define cmLocalVisualStudio7Generator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <iosfwd> #include <string> @@ -119,7 +119,8 @@ private: bool WriteGroup(const cmSourceGroup* sg, cmGeneratorTarget* target, std::ostream& fout, const std::string& libName, - std::vector<std::string> const& configs); + std::vector<std::string> const& configs, + std::map<cmSourceFile const*, size_t> const& sourcesIndex); friend class cmLocalVisualStudio7GeneratorFCInfo; friend class cmLocalVisualStudio7GeneratorInternals; @@ -128,7 +129,6 @@ private: friend class EventWriter; - std::string ModuleDefinitionFile; bool FortranProject; bool WindowsCEProject; cmLocalVisualStudio7GeneratorInternals* Internal; diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index e20fe50..41025af 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -32,6 +32,7 @@ void cmLocalVisualStudioGenerator::ComputeObjectFilenames( std::map<cmSourceFile const*, std::string>& mapping, cmGeneratorTarget const* gt) { + char const* custom_ext = gt->GetCustomObjectExtension(); std::string dir_max = this->ComputeLongestObjectDirectory(gt); // Count the number of object files with each name. Note that @@ -44,7 +45,12 @@ void cmLocalVisualStudioGenerator::ComputeObjectFilenames( cmSourceFile const* sf = si->first; std::string objectNameLower = cmSystemTools::LowerCase( cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath())); - objectNameLower += this->GlobalGenerator->GetLanguageOutputExtension(*sf); + if (custom_ext) { + objectNameLower += custom_ext; + } else { + objectNameLower += + this->GlobalGenerator->GetLanguageOutputExtension(*sf); + } counts[objectNameLower] += 1; } @@ -57,10 +63,16 @@ void cmLocalVisualStudioGenerator::ComputeObjectFilenames( cmSourceFile const* sf = si->first; std::string objectName = cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()); - objectName += this->GlobalGenerator->GetLanguageOutputExtension(*sf); + if (custom_ext) { + objectName += custom_ext; + } else { + objectName += this->GlobalGenerator->GetLanguageOutputExtension(*sf); + } if (counts[cmSystemTools::LowerCase(objectName)] > 1) { const_cast<cmGeneratorTarget*>(gt)->AddExplicitObjectName(sf); - objectName = this->GetObjectFileNameWithoutTarget(*sf, dir_max); + bool keptSourceExtension; + objectName = this->GetObjectFileNameWithoutTarget( + *sf, dir_max, &keptSourceExtension, custom_ext); } si->second = objectName; } @@ -80,8 +92,10 @@ cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmGeneratorTarget* target, !(isFortran && target->GetType() == cmStateEnums::SHARED_LIBRARY)) { return pcc; } - std::string outDir = target->GetDirectory(config, false); - std::string impDir = target->GetDirectory(config, true); + std::string outDir = + target->GetDirectory(config, cmStateEnums::RuntimeBinaryArtifact); + std::string impDir = + target->GetDirectory(config, cmStateEnums::ImportLibraryArtifact); if (impDir == outDir) { return pcc; } diff --git a/Source/cmLocalVisualStudioGenerator.h b/Source/cmLocalVisualStudioGenerator.h index 39188f9..85fb8a5 100644 --- a/Source/cmLocalVisualStudioGenerator.h +++ b/Source/cmLocalVisualStudioGenerator.h @@ -3,7 +3,7 @@ #ifndef cmLocalVisualStudioGenerator_h #define cmLocalVisualStudioGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <map> #include <memory> diff --git a/Source/cmLocalXCodeGenerator.h b/Source/cmLocalXCodeGenerator.h index b4a8c6c..4ca02a9 100644 --- a/Source/cmLocalXCodeGenerator.h +++ b/Source/cmLocalXCodeGenerator.h @@ -3,7 +3,8 @@ #ifndef cmLocalXCodeGenerator_h #define cmLocalXCodeGenerator_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep + #include <map> #include <string> diff --git a/Source/cmLocale.h b/Source/cmLocale.h index cca7cf5..086f448 100644 --- a/Source/cmLocale.h +++ b/Source/cmLocale.h @@ -3,15 +3,13 @@ #ifndef cmLocale_h #define cmLocale_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <locale.h> #include <string> class cmLocaleRAII { - std::string OldLocale; - public: cmLocaleRAII() : OldLocale(setlocale(LC_CTYPE, CM_NULLPTR)) @@ -19,6 +17,12 @@ public: setlocale(LC_CTYPE, ""); } ~cmLocaleRAII() { setlocale(LC_CTYPE, this->OldLocale.c_str()); } + +private: + cmLocaleRAII(cmLocaleRAII const&); + cmLocaleRAII& operator=(cmLocaleRAII const&); + + std::string OldLocale; }; #endif diff --git a/Source/cmMSVC60LinkLineComputer.h b/Source/cmMSVC60LinkLineComputer.h index 9a28dca..612658c 100644 --- a/Source/cmMSVC60LinkLineComputer.h +++ b/Source/cmMSVC60LinkLineComputer.h @@ -4,7 +4,7 @@ #ifndef cmMSVC60LinkLineComputer_h #define cmMSVC60LinkLineComputer_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <string> diff --git a/Source/cmMachO.cxx b/Source/cmMachO.cxx index 586e6c6..a4350f7 100644 --- a/Source/cmMachO.cxx +++ b/Source/cmMachO.cxx @@ -2,8 +2,8 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmMachO.h" +#include "cmsys/FStream.hxx" #include <algorithm> -#include <cmsys/FStream.hxx> #include <stddef.h> #include <string> #include <vector> diff --git a/Source/cmMachO.h b/Source/cmMachO.h index 901f17a..42745cf 100644 --- a/Source/cmMachO.h +++ b/Source/cmMachO.h @@ -3,7 +3,7 @@ #ifndef cmMachO_h #define cmMachO_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <iosfwd> #include <string> diff --git a/Source/cmMacroCommand.h b/Source/cmMacroCommand.h index acb4233..f0020ff 100644 --- a/Source/cmMacroCommand.h +++ b/Source/cmMacroCommand.h @@ -3,7 +3,8 @@ #ifndef cmMacroCommand_h #define cmMacroCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmMakeDirectoryCommand.h b/Source/cmMakeDirectoryCommand.h index d9cce6f..54f4ab3 100644 --- a/Source/cmMakeDirectoryCommand.h +++ b/Source/cmMakeDirectoryCommand.h @@ -3,7 +3,8 @@ #ifndef cmMakeDirectoryCommand_h #define cmMakeDirectoryCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 1e995fb..4ed76c7 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2,10 +2,10 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmMakefile.h" +#include "cmsys/FStream.hxx" +#include "cmsys/RegularExpression.hxx" #include <algorithm> #include <assert.h> -#include <cmsys/FStream.hxx> -#include <cmsys/RegularExpression.hxx> #include <ctype.h> #include <sstream> #include <stdlib.h> @@ -36,7 +36,9 @@ #include "cmTest.h" #include "cmTestGenerator.h" // IWYU pragma: keep #include "cmVersion.h" +#include "cmWorkingDirectory.h" #include "cm_auto_ptr.hxx" +#include "cm_sys_stat.h" #include "cmake.h" #ifdef CMAKE_BUILD_WITH_CMAKE @@ -92,6 +94,10 @@ cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator, this->AddSourceGroup("CMake Rules", "\\.rule$"); this->AddSourceGroup("Resources", "\\.plist$"); this->AddSourceGroup("Object Files", "\\.(lo|o|obj)$"); + + this->ObjectLibrariesSourceGroupIndex = this->SourceGroups.size(); + this->SourceGroups.push_back( + cmSourceGroup("Object Libraries", "^MATCH_NO_SOURCES$")); #endif } @@ -281,7 +287,8 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff, if (!invokeSucceeded || hadNestedError) { if (!hadNestedError) { // The command invocation requested that we report an error. - this->IssueMessage(cmake::FATAL_ERROR, pcmd->GetError()); + std::string const error = name + " " + pcmd->GetError(); + this->IssueMessage(cmake::FATAL_ERROR, error); } result = false; if (this->GetCMakeInstance()->GetWorkingMode() != cmake::NORMAL_MODE) { @@ -653,21 +660,12 @@ void cmMakefile::FinalPass() // we don't want cmake to re-run if a configured file is created and deleted // during processing as that would make it a transient file that can't // influence the build process - - // remove_if will move all items that don't have a valid file name to the - // back of the vector - std::vector<std::string>::iterator new_output_files_end = std::remove_if( - this->OutputFiles.begin(), this->OutputFiles.end(), file_not_persistent()); - // we just have to erase all items at the back - this->OutputFiles.erase(new_output_files_end, this->OutputFiles.end()); + cmEraseIf(this->OutputFiles, file_not_persistent()); // if a configured file is used as input for another configured file, // and then deleted it will show up in the input list files so we // need to scan those too - std::vector<std::string>::iterator new_list_files_end = std::remove_if( - this->ListFiles.begin(), this->ListFiles.end(), file_not_persistent()); - - this->ListFiles.erase(new_list_files_end, this->ListFiles.end()); + cmEraseIf(this->ListFiles, file_not_persistent()); } // Generate the output file @@ -692,7 +690,8 @@ void cmMakefile::AddCustomCommandToTarget( const std::vector<std::string>& depends, const cmCustomCommandLines& commandLines, cmTarget::CustomCommandType type, const char* comment, const char* workingDir, bool escapeOldStyle, - bool uses_terminal, const std::string& depfile, bool command_expand_lists) + bool uses_terminal, const std::string& depfile, bool command_expand_lists, + ObjectLibraryCommands objLibraryCommands) { // Find the target to which to add the custom command. cmTargets::iterator ti = this->Targets.find(target); @@ -732,7 +731,8 @@ void cmMakefile::AddCustomCommandToTarget( return; } - if (ti->second.GetType() == cmStateEnums::OBJECT_LIBRARY) { + if (objLibraryCommands == RejectObjectLibraryCommands && + ti->second.GetType() == cmStateEnums::OBJECT_LIBRARY) { std::ostringstream e; e << "Target \"" << target << "\" is an OBJECT library " @@ -2155,6 +2155,12 @@ bool cmMakefile::IsSet(const std::string& name) const bool cmMakefile::PlatformIs32Bit() const { + if (const char* plat_abi = + this->GetDefinition("CMAKE_INTERNAL_PLATFORM_ABI")) { + if (strcmp(plat_abi, "ELF X32") == 0) { + return false; + } + } if (const char* sizeof_dptr = this->GetDefinition("CMAKE_SIZEOF_VOID_P")) { return atoi(sizeof_dptr) == 4; } @@ -2169,6 +2175,17 @@ bool cmMakefile::PlatformIs64Bit() const return false; } +bool cmMakefile::PlatformIsx32() const +{ + if (const char* plat_abi = + this->GetDefinition("CMAKE_INTERNAL_PLATFORM_ABI")) { + if (strcmp(plat_abi, "ELF X32") == 0) { + return true; + } + } + return false; +} + bool cmMakefile::PlatformIsAppleIos() const { std::string sdkRoot; @@ -3111,6 +3128,18 @@ cmSourceFile* cmMakefile::GetOrCreateSource(const std::string& sourceName, return this->CreateSource(sourceName, generated); } +void cmMakefile::AddTargetObject(std::string const& tgtName, + std::string const& objFile) +{ + cmSourceFile* sf = this->GetOrCreateSource(objFile, true); + sf->SetObjectLibrary(tgtName); + sf->SetProperty("EXTERNAL_OBJECT", "1"); +#if defined(CMAKE_BUILD_WITH_CMAKE) + this->SourceGroups[this->ObjectLibrariesSourceGroupIndex].AddGroupFile( + sf->GetFullPath()); +#endif +} + void cmMakefile::EnableLanguage(std::vector<std::string> const& lang, bool optional) { @@ -3153,8 +3182,7 @@ int cmMakefile::TryCompile(const std::string& srcdir, // change to the tests directory and run cmake // use the cmake object instead of calling cmake - std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); - cmSystemTools::ChangeDirectory(bindir); + cmWorkingDirectory workdir(bindir); // make sure the same generator is used // use this program as the cmake to be run, it should not @@ -3168,8 +3196,6 @@ int cmMakefile::TryCompile(const std::string& srcdir, this->GetGlobalGenerator()->GetName() + "' could not be created."); cmSystemTools::SetFatalErrorOccured(); - // return to the original directory - cmSystemTools::ChangeDirectory(cwd); this->IsSourceFileTryCompile = false; return 1; } @@ -3233,8 +3259,6 @@ int cmMakefile::TryCompile(const std::string& srcdir, this->IssueMessage(cmake::FATAL_ERROR, "Failed to configure test project build system."); cmSystemTools::SetFatalErrorOccured(); - // return to the original directory - cmSystemTools::ChangeDirectory(cwd); this->IsSourceFileTryCompile = false; return 1; } @@ -3243,8 +3267,6 @@ int cmMakefile::TryCompile(const std::string& srcdir, this->IssueMessage(cmake::FATAL_ERROR, "Failed to generate test project build system."); cmSystemTools::SetFatalErrorOccured(); - // return to the original directory - cmSystemTools::ChangeDirectory(cwd); this->IsSourceFileTryCompile = false; return 1; } @@ -3253,7 +3275,6 @@ int cmMakefile::TryCompile(const std::string& srcdir, int ret = this->GetGlobalGenerator()->TryCompile( srcdir, bindir, projectName, targetName, fast, output, this); - cmSystemTools::ChangeDirectory(cwd); this->IsSourceFileTryCompile = false; return ret; } diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 9d9e90a..2f4cea6 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -3,12 +3,13 @@ #ifndef cmMakefile_h #define cmMakefile_h -#include <cmConfigure.h> +#include "cmConfigure.h" -#include <cmsys/RegularExpression.hxx> +#include "cmsys/RegularExpression.hxx" #include <map> #include <set> #include <stack> +#include <stddef.h> #include <string> #include <vector> @@ -119,6 +120,13 @@ public: */ void FinalPass(); + /** How to handle custom commands for object libraries */ + enum ObjectLibraryCommands + { + RejectObjectLibraryCommands, + AcceptObjectLibraryCommands + }; + /** Add a custom command to the build. */ void AddCustomCommandToTarget( const std::string& target, const std::vector<std::string>& byproducts, @@ -126,7 +134,8 @@ public: const cmCustomCommandLines& commandLines, cmTarget::CustomCommandType type, const char* comment, const char* workingDir, bool escapeOldStyle = true, bool uses_terminal = false, const std::string& depfile = "", - bool command_expand_lists = false); + bool command_expand_lists = false, + ObjectLibraryCommands objLibraryCommands = RejectObjectLibraryCommands); cmSourceFile* AddCustomCommandToOutput( const std::vector<std::string>& outputs, const std::vector<std::string>& byproducts, @@ -398,6 +407,8 @@ public: cmSourceFile* GetOrCreateSource(const std::string& sourceName, bool generated = false); + void AddTargetObject(std::string const& tgtName, std::string const& objFile); + /** * Given a variable name, return its value (as a string). * If the variable is not found in this makefile instance, the @@ -428,6 +439,8 @@ public: /** Return whether the target platform is 64-bit. */ bool PlatformIs64Bit() const; + /** Return whether the target platform is x32. */ + bool PlatformIsx32() const; /** Return whether the target platform is Apple iOS. */ bool PlatformIsAppleIos() const; @@ -704,6 +717,8 @@ public: } ~ScopePushPop() { this->Makefile->PopScope(); } private: + ScopePushPop(ScopePushPop const&); + ScopePushPop& operator=(ScopePushPop const&); cmMakefile* Makefile; }; @@ -807,6 +822,7 @@ protected: #if defined(CMAKE_BUILD_WITH_CMAKE) std::vector<cmSourceGroup> SourceGroups; + size_t ObjectLibrariesSourceGroupIndex; #endif std::vector<cmCommand*> FinalPassCommands; diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index b76ddeb..a93b42d 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmMakefileExecutableTargetGenerator.h" +#include <algorithm> #include <sstream> #include <string> #include <vector> @@ -20,6 +21,7 @@ #include "cmState.h" #include "cmStateDirectory.h" #include "cmStateSnapshot.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cm_auto_ptr.hxx" #include "cmake.h" @@ -331,7 +333,8 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) } else { cmSystemTools::MakeDirectory(outpath.c_str()); if (!targetNameImport.empty()) { - outpathImp = this->GeneratorTarget->GetDirectory(this->ConfigName, true); + outpathImp = this->GeneratorTarget->GetDirectory( + this->ConfigName, cmStateEnums::ImportLibraryArtifact); cmSystemTools::MakeDirectory(outpathImp.c_str()); outpathImp += "/"; } @@ -555,10 +558,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) } // maybe create .def file from list of objects - if (this->GeneratorTarget->IsExecutableWithExports() && - this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) { - this->GenDefFile(real_link_commands, linkFlags); - } + this->GenDefFile(real_link_commands); std::string manifests = this->GetManifests(); diff --git a/Source/cmMakefileExecutableTargetGenerator.h b/Source/cmMakefileExecutableTargetGenerator.h index 642182b..01aa627 100644 --- a/Source/cmMakefileExecutableTargetGenerator.h +++ b/Source/cmMakefileExecutableTargetGenerator.h @@ -3,7 +3,9 @@ #ifndef cmMakefileExecutableTargetGenerator_h #define cmMakefileExecutableTargetGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" + +#include <string> #include "cmMakefileTargetGenerator.h" diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index ff8b604..e017b29 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -2,8 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmMakefileLibraryTargetGenerator.h" -#include <cmConfigure.h> // IWYU pragma: keep - +#include <algorithm> #include <sstream> #include <vector> @@ -130,14 +129,9 @@ void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules() { std::string linkLanguage = this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); - std::string linkRuleVar = "CMAKE_"; - linkRuleVar += linkLanguage; - linkRuleVar += "_CREATE_STATIC_LIBRARY"; - if (this->GetFeatureAsBool("INTERPROCEDURAL_OPTIMIZATION") && - this->Makefile->GetDefinition(linkRuleVar + "_IPO")) { - linkRuleVar += "_IPO"; - } + std::string linkRuleVar = this->GeneratorTarget->GetCreateRuleVariable( + linkLanguage, this->ConfigName); std::string extraFlags; this->LocalGenerator->GetStaticLibraryFlags( @@ -520,7 +514,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( cmSystemTools::MakeDirectory(outpath.c_str()); outpath += "/"; if (!targetNameImport.empty()) { - outpathImp = this->GeneratorTarget->GetDirectory(this->ConfigName, true); + outpathImp = this->GeneratorTarget->GetDirectory( + this->ConfigName, cmStateEnums::ImportLibraryArtifact); cmSystemTools::MakeDirectory(outpathImp.c_str()); outpathImp += "/"; } @@ -677,18 +672,30 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( std::string arCreateVar = "CMAKE_"; arCreateVar += linkLanguage; arCreateVar += "_ARCHIVE_CREATE"; + + arCreateVar = this->GeneratorTarget->GetFeatureSpecificLinkRuleVariable( + arCreateVar, this->ConfigName); + if (const char* rule = this->Makefile->GetDefinition(arCreateVar)) { cmSystemTools::ExpandListArgument(rule, archiveCreateCommands); } std::string arAppendVar = "CMAKE_"; arAppendVar += linkLanguage; arAppendVar += "_ARCHIVE_APPEND"; + + arAppendVar = this->GeneratorTarget->GetFeatureSpecificLinkRuleVariable( + arAppendVar, this->ConfigName); + if (const char* rule = this->Makefile->GetDefinition(arAppendVar)) { cmSystemTools::ExpandListArgument(rule, archiveAppendCommands); } std::string arFinishVar = "CMAKE_"; arFinishVar += linkLanguage; arFinishVar += "_ARCHIVE_FINISH"; + + arFinishVar = this->GeneratorTarget->GetFeatureSpecificLinkRuleVariable( + arFinishVar, this->ConfigName); + if (const char* rule = this->Makefile->GetDefinition(arFinishVar)) { cmSystemTools::ExpandListArgument(rule, archiveFinishCommands); } @@ -751,10 +758,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( } // maybe create .def file from list of objects - if (this->GeneratorTarget->GetType() == cmStateEnums::SHARED_LIBRARY && - this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) { - this->GenDefFile(real_link_commands, linkFlags); - } + this->GenDefFile(real_link_commands); std::string manifests = this->GetManifests(); diff --git a/Source/cmMakefileLibraryTargetGenerator.h b/Source/cmMakefileLibraryTargetGenerator.h index 93ce902..da1d8b6 100644 --- a/Source/cmMakefileLibraryTargetGenerator.h +++ b/Source/cmMakefileLibraryTargetGenerator.h @@ -3,7 +3,7 @@ #ifndef cmMakefileLibraryTargetGenerator_h #define cmMakefileLibraryTargetGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmMakefileTargetGenerator.h" diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 54b3f36..9c0520e 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -30,10 +30,6 @@ #include "cm_auto_ptr.hxx" #include "cmake.h" -#ifndef _WIN32 -#include <unistd.h> -#endif - cmMakefileTargetGenerator::cmMakefileTargetGenerator(cmGeneratorTarget* target) : cmCommonTargetGenerator(target) , OSXBundleGenerator(CM_NULLPTR) @@ -509,8 +505,8 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY || this->GeneratorTarget->GetType() == cmStateEnums::SHARED_LIBRARY || this->GeneratorTarget->GetType() == cmStateEnums::MODULE_LIBRARY) { - targetFullPathReal = - this->GeneratorTarget->GetFullPath(this->ConfigName, false, true); + targetFullPathReal = this->GeneratorTarget->GetFullPath( + this->ConfigName, cmStateEnums::RuntimeBinaryArtifact, true); targetFullPathPDB = this->GeneratorTarget->GetPDBDirectory(this->ConfigName); targetFullPathPDB += "/"; @@ -593,6 +589,9 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( if (this->GeneratorTarget->GetPropertyAsBool( "CUDA_SEPARABLE_COMPILATION")) { cmdVar = std::string("CMAKE_CUDA_COMPILE_SEPARABLE_COMPILATION"); + } else if (this->GeneratorTarget->GetPropertyAsBool( + "CUDA_PTX_COMPILATION")) { + cmdVar = std::string("CMAKE_CUDA_COMPILE_PTX_COMPILATION"); } else { cmdVar = std::string("CMAKE_CUDA_COMPILE_WHOLE_COMPILATION"); } @@ -1414,8 +1413,14 @@ void cmMakefileTargetGenerator::AppendLinkDepends( this->AppendTargetDepends(depends); // Add a dependency on the link definitions file, if any. - if (this->ModuleDefinitionFile) { - depends.push_back(this->ModuleDefinitionFile->GetFullPath()); + if (cmGeneratorTarget::ModuleDefinitionInfo const* mdi = + this->GeneratorTarget->GetModuleDefinitionInfo( + this->GetConfigName())) { + for (std::vector<cmSourceFile const*>::const_iterator i = + mdi->Sources.begin(); + i != mdi->Sources.end(); ++i) { + depends.push_back((*i)->GetFullPath()); + } } // Add a dependency on user-specified manifest files, if any. @@ -1486,15 +1491,6 @@ void cmMakefileTargetGenerator::CreateLinkScript( makefile_depends.push_back(linkScriptName); } -static size_t calculateCommandLineLengthLimit() -{ -#if defined(_SC_ARG_MAX) - return ((size_t)sysconf(_SC_ARG_MAX)) - 1000; -#else - return 0; -#endif -} - bool cmMakefileTargetGenerator::CheckUseResponseFileForObjects( std::string const& l) const { @@ -1508,7 +1504,7 @@ bool cmMakefileTargetGenerator::CheckUseResponseFileForObjects( } // Check for a system limit. - if (size_t const limit = calculateCommandLineLengthLimit()) { + if (size_t const limit = cmSystemTools::CalculateCommandLineLengthLimit()) { // Compute the total length of our list of object files with room // for argument separation and quoting. This does not convert paths // relative to CMAKE_CURRENT_BINARY_DIR like the final list will be, so the @@ -1718,31 +1714,32 @@ void cmMakefileTargetGenerator::AddIncludeFlags(std::string& flags, } void cmMakefileTargetGenerator::GenDefFile( - std::vector<std::string>& real_link_commands, std::string& linkFlags) + std::vector<std::string>& real_link_commands) { - if (this->GeneratorTarget->GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) { - std::string name_of_def_file = - this->GeneratorTarget->GetSupportDirectory(); - name_of_def_file += std::string("/") + this->GeneratorTarget->GetName(); - name_of_def_file += ".def"; - std::string cmd = cmSystemTools::GetCMakeCommand(); - cmd = this->LocalGenerator->ConvertToOutputFormat( - cmd, cmOutputConverter::SHELL); - cmd += " -E __create_def "; - cmd += this->LocalGenerator->ConvertToOutputFormat( - this->LocalGenerator->MaybeConvertToRelativePath( - this->LocalGenerator->GetCurrentBinaryDirectory(), name_of_def_file), - cmOutputConverter::SHELL); - cmd += " "; - std::string objlist_file = name_of_def_file; - objlist_file += ".objs"; - cmd += this->LocalGenerator->ConvertToOutputFormat( - this->LocalGenerator->MaybeConvertToRelativePath( - this->LocalGenerator->GetCurrentBinaryDirectory(), objlist_file), - cmOutputConverter::SHELL); - real_link_commands.insert(real_link_commands.begin(), cmd); - // create a list of obj files for the -E __create_def to read - cmGeneratedFileStream fout(objlist_file.c_str()); + cmGeneratorTarget::ModuleDefinitionInfo const* mdi = + this->GeneratorTarget->GetModuleDefinitionInfo(this->GetConfigName()); + if (!mdi || !mdi->DefFileGenerated) { + return; + } + std::string cmd = cmSystemTools::GetCMakeCommand(); + cmd = + this->LocalGenerator->ConvertToOutputFormat(cmd, cmOutputConverter::SHELL); + cmd += " -E __create_def "; + cmd += this->LocalGenerator->ConvertToOutputFormat( + this->LocalGenerator->MaybeConvertToRelativePath( + this->LocalGenerator->GetCurrentBinaryDirectory(), mdi->DefFile), + cmOutputConverter::SHELL); + cmd += " "; + std::string objlist_file = mdi->DefFile + ".objs"; + cmd += this->LocalGenerator->ConvertToOutputFormat( + this->LocalGenerator->MaybeConvertToRelativePath( + this->LocalGenerator->GetCurrentBinaryDirectory(), objlist_file), + cmOutputConverter::SHELL); + real_link_commands.insert(real_link_commands.begin(), cmd); + // create a list of obj files for the -E __create_def to read + cmGeneratedFileStream fout(objlist_file.c_str()); + + if (mdi->WindowsExportAllSymbols) { for (std::vector<std::string>::const_iterator i = this->Objects.begin(); i != this->Objects.end(); ++i) { if (cmHasLiteralSuffix(*i, ".obj")) { @@ -1754,13 +1751,11 @@ void cmMakefileTargetGenerator::GenDefFile( i != this->ExternalObjects.end(); ++i) { fout << *i << "\n"; } - // now add the def file link flag - linkFlags += " "; - linkFlags += this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG"); - linkFlags += this->LocalGenerator->ConvertToOutputFormat( - this->LocalGenerator->MaybeConvertToRelativePath( - this->LocalGenerator->GetCurrentBinaryDirectory(), name_of_def_file), - cmOutputConverter::SHELL); - linkFlags += " "; + } + + for (std::vector<cmSourceFile const*>::const_iterator i = + mdi->Sources.begin(); + i != mdi->Sources.end(); ++i) { + fout << (*i)->GetFullPath() << "\n"; } } diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index 347f9f2..32b1fee 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -3,7 +3,7 @@ #ifndef cmMakefileTargetGenerator_h #define cmMakefileTargetGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <iosfwd> #include <map> @@ -166,8 +166,7 @@ protected: bool useWatcomQuote); /** Add commands for generate def files */ - void GenDefFile(std::vector<std::string>& real_link_commands, - std::string& linkFlags); + void GenDefFile(std::vector<std::string>& real_link_commands); void AddIncludeFlags(std::string& flags, const std::string& lang) CM_OVERRIDE; diff --git a/Source/cmMakefileUtilityTargetGenerator.h b/Source/cmMakefileUtilityTargetGenerator.h index 332c04e..8df5dd4 100644 --- a/Source/cmMakefileUtilityTargetGenerator.h +++ b/Source/cmMakefileUtilityTargetGenerator.h @@ -3,7 +3,7 @@ #ifndef cmMakefileUtilityTargetGenerator_h #define cmMakefileUtilityTargetGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmMakefileTargetGenerator.h" diff --git a/Source/cmMarkAsAdvancedCommand.h b/Source/cmMarkAsAdvancedCommand.h index 26caa66..8c2f85b 100644 --- a/Source/cmMarkAsAdvancedCommand.h +++ b/Source/cmMarkAsAdvancedCommand.h @@ -3,7 +3,8 @@ #ifndef cmMarkAsAdvancedCommand_h #define cmMarkAsAdvancedCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmMathCommand.h b/Source/cmMathCommand.h index 9b49b21..496d836 100644 --- a/Source/cmMathCommand.h +++ b/Source/cmMathCommand.h @@ -3,7 +3,8 @@ #ifndef cmMathCommand_h #define cmMathCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmMessageCommand.h b/Source/cmMessageCommand.h index a565635..ca83ed6 100644 --- a/Source/cmMessageCommand.h +++ b/Source/cmMessageCommand.h @@ -3,7 +3,8 @@ #ifndef cmMessageCommand_h #define cmMessageCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmMessenger.cxx b/Source/cmMessenger.cxx index fe1c261..3ae5bc5 100644 --- a/Source/cmMessenger.cxx +++ b/Source/cmMessenger.cxx @@ -8,7 +8,7 @@ #include "cmSystemTools.h" #if defined(CMAKE_BUILD_WITH_CMAKE) -#include <cmsys/SystemInformation.hxx> +#include "cmsys/SystemInformation.hxx" #endif #include <sstream> diff --git a/Source/cmMessenger.h b/Source/cmMessenger.h index 89f8efe..4aafbd4 100644 --- a/Source/cmMessenger.h +++ b/Source/cmMessenger.h @@ -3,7 +3,7 @@ #ifndef cmMessenger_h #define cmMessenger_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include "cmListFileCache.h" #include "cmake.h" diff --git a/Source/cmNewLineStyle.h b/Source/cmNewLineStyle.h index b46414c..397cd2c 100644 --- a/Source/cmNewLineStyle.h +++ b/Source/cmNewLineStyle.h @@ -3,7 +3,7 @@ #ifndef cmNewLineStyle_h #define cmNewLineStyle_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmNinjaLinkLineComputer.h b/Source/cmNinjaLinkLineComputer.h index ff0771b..db6d4a8 100644 --- a/Source/cmNinjaLinkLineComputer.h +++ b/Source/cmNinjaLinkLineComputer.h @@ -4,7 +4,7 @@ #ifndef cmNinjaLinkLineComputer_h #define cmNinjaLinkLineComputer_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <string> diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index b1374c2..cfc91bd 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -5,11 +5,9 @@ #include <algorithm> #include <assert.h> #include <iterator> -#include <limits> #include <map> #include <set> #include <sstream> -#include <stddef.h> #include "cmAlgorithms.h" #include "cmCustomCommand.h" @@ -35,10 +33,6 @@ #include "cm_auto_ptr.hxx" #include "cmake.h" -#ifndef _WIN32 -#include <unistd.h> -#endif - cmNinjaNormalTargetGenerator::cmNinjaNormalTargetGenerator( cmGeneratorTarget* target) : cmNinjaTargetGenerator(target) @@ -260,12 +254,9 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkRule(bool useResponseFile) rulePlaceholderExpander->ExpandRuleVariables(this->GetLocalGenerator(), *i, vars); } - { - // If there is no ranlib the command will be ":". Skip it. - std::vector<std::string>::iterator newEnd = std::remove_if( - linkCmds.begin(), linkCmds.end(), cmNinjaRemoveNoOpCommands()); - linkCmds.erase(newEnd, linkCmds.end()); - } + + // If there is no ranlib the command will be ":". Skip it. + cmEraseIf(linkCmds, cmNinjaRemoveNoOpCommands()); std::string linkCmd = this->GetLocalGenerator()->BuildCommandLine(linkCmds); @@ -388,12 +379,9 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile) rulePlaceholderExpander->ExpandRuleVariables(this->GetLocalGenerator(), *i, vars); } - { - // If there is no ranlib the command will be ":". Skip it. - std::vector<std::string>::iterator newEnd = std::remove_if( - linkCmds.begin(), linkCmds.end(), cmNinjaRemoveNoOpCommands()); - linkCmds.erase(newEnd, linkCmds.end()); - } + + // If there is no ranlib the command will be ":". Skip it. + cmEraseIf(linkCmds, cmNinjaRemoveNoOpCommands()); linkCmds.insert(linkCmds.begin(), "$PRE_LINK"); linkCmds.push_back("$POST_BUILD"); @@ -497,10 +485,9 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd() cmGeneratorTarget& gt = *this->GetGeneratorTarget(); const std::string cfgName = this->GetConfigName(); std::string targetOutput = ConvertToNinjaPath(gt.GetFullPath(cfgName)); - std::string targetOutputReal = - this->ConvertToNinjaPath(gt.GetFullPath(cfgName, - /*implib=*/false, - /*realname=*/true)); + std::string targetOutputReal = this->ConvertToNinjaPath( + gt.GetFullPath(cfgName, cmStateEnums::RuntimeBinaryArtifact, + /*realname=*/true)); cmakeCommand += targetOutputReal; cmakeCommand += " || true"; linkCmds.push_back(cmakeCommand); @@ -522,6 +509,10 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd() std::string linkCmdVar = "CMAKE_"; linkCmdVar += this->TargetLinkLanguage; linkCmdVar += "_ARCHIVE_CREATE"; + + linkCmdVar = this->GeneratorTarget->GetFeatureSpecificLinkRuleVariable( + linkCmdVar, this->GetConfigName()); + const char* linkCmd = mf->GetRequiredDefinition(linkCmdVar); cmSystemTools::ExpandListArgument(linkCmd, linkCmds); } @@ -529,6 +520,10 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd() std::string linkCmdVar = "CMAKE_"; linkCmdVar += this->TargetLinkLanguage; linkCmdVar += "_ARCHIVE_FINISH"; + + linkCmdVar = this->GeneratorTarget->GetFeatureSpecificLinkRuleVariable( + linkCmdVar, this->GetConfigName()); + const char* linkCmd = mf->GetRequiredDefinition(linkCmdVar); cmSystemTools::ExpandListArgument(linkCmd, linkCmds); } @@ -544,36 +539,6 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd() return std::vector<std::string>(); } -static int calculateCommandLineLengthLimit(int linkRuleLength) -{ - static int const limits[] = { -#ifdef _WIN32 - 8000, -#endif -#if defined(__linux) - // #define MAX_ARG_STRLEN (PAGE_SIZE * 32) in Linux's binfmts.h - ((int)sysconf(_SC_PAGESIZE) * 32) - 1000, -#endif - std::numeric_limits<int>::max() - }; - - size_t const arrSz = cmArraySize(limits); - int sz = *std::min_element(limits, limits + arrSz); -#if defined(_SC_ARG_MAX) - // for instance ARG_MAX is 2096152 on Ubuntu or 262144 on Mac - int const szArgMax = static_cast<int>(sysconf(_SC_ARG_MAX)); - // a return value of -1 signifies an unrestricted value - if (szArgMax != -1) { - sz = std::min(sz, szArgMax - 1000); - } -#endif - if (sz == std::numeric_limits<int>::max()) { - return 0; - } - - return sz - linkRuleLength; -} - void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement() { cmGeneratorTarget& genTarget = *this->GetGeneratorTarget(); @@ -614,9 +579,8 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement() std::string const targetOutputReal = ConvertToNinjaPath( genTarget.ObjectDirectory + "cmake_device_link" + objExt); - std::string const targetOutputImplib = - ConvertToNinjaPath(genTarget.GetFullPath(cfgName, - /*implib=*/true)); + std::string const targetOutputImplib = ConvertToNinjaPath( + genTarget.GetFullPath(cfgName, cmStateEnums::ImportLibraryArtifact)); this->DeviceLinkObject = targetOutputReal; @@ -759,8 +723,9 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement() // Device linking currently doesn't support response files so // do not check if the user has explicitly forced a response file. - int const commandLineLengthLimit = calculateCommandLineLengthLimit( - globalGen.GetRuleCmdLength(this->LanguageLinkerDeviceRule())); + int const commandLineLengthLimit = + static_cast<int>(cmSystemTools::CalculateCommandLineLengthLimit()) - + globalGen.GetRuleCmdLength(this->LanguageLinkerDeviceRule()); const std::string rspfile = std::string(cmake::GetCMakeFilesDirectoryPostSlash()) + @@ -786,13 +751,11 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() cmGeneratorTarget& gt = *this->GetGeneratorTarget(); const std::string cfgName = this->GetConfigName(); std::string targetOutput = ConvertToNinjaPath(gt.GetFullPath(cfgName)); - std::string targetOutputReal = - ConvertToNinjaPath(gt.GetFullPath(cfgName, - /*implib=*/false, - /*realname=*/true)); - std::string targetOutputImplib = - ConvertToNinjaPath(gt.GetFullPath(cfgName, - /*implib=*/true)); + std::string targetOutputReal = ConvertToNinjaPath( + gt.GetFullPath(cfgName, cmStateEnums::RuntimeBinaryArtifact, + /*realname=*/true)); + std::string targetOutputImplib = ConvertToNinjaPath( + gt.GetFullPath(cfgName, cmStateEnums::ImportLibraryArtifact)); if (gt.IsAppBundleOnApple()) { // Create the app bundle @@ -869,19 +832,6 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() linkLineComputer.get(), this->GetConfigName(), vars["LINK_LIBRARIES"], vars["FLAGS"], vars["LINK_FLAGS"], frameworkPath, linkPath, &genTarget); - if (this->GetMakefile()->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS") && - (gt.GetType() == cmStateEnums::SHARED_LIBRARY || - gt.IsExecutableWithExports())) { - if (gt.GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) { - std::string name_of_def_file = gt.GetSupportDirectory(); - name_of_def_file += "/" + gt.GetName(); - name_of_def_file += ".def "; - vars["LINK_FLAGS"] += " /DEF:"; - vars["LINK_FLAGS"] += this->GetLocalGenerator()->ConvertToOutputFormat( - name_of_def_file, cmOutputConverter::SHELL); - } - } - // Add OS X version flags, if any. if (this->GeneratorTarget->GetType() == cmStateEnums::SHARED_LIBRARY || this->GeneratorTarget->GetType() == cmStateEnums::MODULE_LIBRARY) { @@ -998,35 +948,39 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() } // maybe create .def file from list of objects - if ((gt.GetType() == cmStateEnums::SHARED_LIBRARY || - gt.IsExecutableWithExports()) && - this->GetMakefile()->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) { - if (gt.GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) { - std::string cmakeCommand = - this->GetLocalGenerator()->ConvertToOutputFormat( - cmSystemTools::GetCMakeCommand(), cmOutputConverter::SHELL); - std::string name_of_def_file = gt.GetSupportDirectory(); - name_of_def_file += "/" + gt.GetName(); - name_of_def_file += ".def"; - std::string cmd = cmakeCommand; - cmd += " -E __create_def "; - cmd += this->GetLocalGenerator()->ConvertToOutputFormat( - name_of_def_file, cmOutputConverter::SHELL); - cmd += " "; + cmGeneratorTarget::ModuleDefinitionInfo const* mdi = + gt.GetModuleDefinitionInfo(this->GetConfigName()); + if (mdi && mdi->DefFileGenerated) { + std::string cmakeCommand = + this->GetLocalGenerator()->ConvertToOutputFormat( + cmSystemTools::GetCMakeCommand(), cmOutputConverter::SHELL); + std::string cmd = cmakeCommand; + cmd += " -E __create_def "; + cmd += this->GetLocalGenerator()->ConvertToOutputFormat( + mdi->DefFile, cmOutputConverter::SHELL); + cmd += " "; + std::string obj_list_file = mdi->DefFile + ".objs"; + cmd += this->GetLocalGenerator()->ConvertToOutputFormat( + obj_list_file, cmOutputConverter::SHELL); + preLinkCmdLines.push_back(cmd); + + // create a list of obj files for the -E __create_def to read + cmGeneratedFileStream fout(obj_list_file.c_str()); + + if (mdi->WindowsExportAllSymbols) { cmNinjaDeps objs = this->GetObjects(); - std::string obj_list_file = name_of_def_file; - obj_list_file += ".objs"; - cmd += this->GetLocalGenerator()->ConvertToOutputFormat( - obj_list_file, cmOutputConverter::SHELL); - preLinkCmdLines.push_back(cmd); - // create a list of obj files for the -E __create_def to read - cmGeneratedFileStream fout(obj_list_file.c_str()); for (cmNinjaDeps::iterator i = objs.begin(); i != objs.end(); ++i) { if (cmHasLiteralSuffix(*i, ".obj")) { fout << *i << "\n"; } } } + + for (std::vector<cmSourceFile const*>::const_iterator i = + mdi->Sources.begin(); + i != mdi->Sources.end(); ++i) { + fout << (*i)->GetFullPath() << "\n"; + } } // If we have any PRE_LINK commands, we need to go back to CMAKE_BINARY_DIR // for @@ -1055,8 +1009,9 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() !(this->TargetLinkLanguage == "RC" || this->TargetLinkLanguage == "CUDA"); int commandLineLengthLimit = -1; if (!lang_supports_response || !this->ForceResponseFile()) { - commandLineLengthLimit = calculateCommandLineLengthLimit( - globalGen.GetRuleCmdLength(this->LanguageLinkerRule())); + commandLineLengthLimit = + static_cast<int>(cmSystemTools::CalculateCommandLineLengthLimit()) - + globalGen.GetRuleCmdLength(this->LanguageLinkerRule()); } const std::string rspfile = diff --git a/Source/cmNinjaNormalTargetGenerator.h b/Source/cmNinjaNormalTargetGenerator.h index e5595ea..677b1c6 100644 --- a/Source/cmNinjaNormalTargetGenerator.h +++ b/Source/cmNinjaNormalTargetGenerator.h @@ -3,7 +3,7 @@ #ifndef cmNinjaNormalTargetGenerator_h #define cmNinjaNormalTargetGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmNinjaTargetGenerator.h" diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index d57b8f7..e0b2217 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -2,10 +2,10 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmNinjaTargetGenerator.h" +#include "cm_jsoncpp_value.h" +#include "cm_jsoncpp_writer.h" #include <algorithm> #include <assert.h> -#include <cm_jsoncpp_value.h> -#include <cm_jsoncpp_writer.h> #include <iterator> #include <map> #include <sstream> @@ -117,7 +117,7 @@ bool cmNinjaTargetGenerator::NeedDyndep(std::string const& lang) const std::string cmNinjaTargetGenerator::OrderDependsTargetForTarget() { - return "cmake_order_depends_target_" + this->GetTargetName(); + return "cmake_object_order_depends_target_" + this->GetTargetName(); } // TODO: Most of the code is picked up from @@ -212,9 +212,14 @@ cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const std::transform(deps.begin(), deps.end(), result.begin(), MapToNinjaPath()); // Add a dependency on the link definitions file, if any. - if (this->ModuleDefinitionFile) { - result.push_back( - this->ConvertToNinjaPath(this->ModuleDefinitionFile->GetFullPath())); + if (cmGeneratorTarget::ModuleDefinitionInfo const* mdi = + this->GeneratorTarget->GetModuleDefinitionInfo( + this->GetConfigName())) { + for (std::vector<cmSourceFile const*>::const_iterator i = + mdi->Sources.begin(); + i != mdi->Sources.end(); ++i) { + result.push_back(this->ConvertToNinjaPath((*i)->GetFullPath())); + } } // Add a dependency on user-specified manifest files, if any. @@ -584,6 +589,9 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang) if (this->GeneratorTarget->GetPropertyAsBool( "CUDA_SEPARABLE_COMPILATION")) { cmdVar = std::string("CMAKE_CUDA_COMPILE_SEPARABLE_COMPILATION"); + } else if (this->GeneratorTarget->GetPropertyAsBool( + "CUDA_PTX_COMPILATION")) { + cmdVar = std::string("CMAKE_CUDA_COMPILE_PTX_COMPILATION"); } else { cmdVar = std::string("CMAKE_CUDA_COMPILE_WHOLE_COMPILATION"); } @@ -710,8 +718,8 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements() } cmNinjaDeps orderOnlyDeps; - this->GetLocalGenerator()->AppendTargetDepends(this->GeneratorTarget, - orderOnlyDeps); + this->GetLocalGenerator()->AppendTargetDepends( + this->GeneratorTarget, orderOnlyDeps, DependOnTargetOrdering); // Add order-only dependencies on other files associated with the target. orderOnlyDeps.insert(orderOnlyDeps.end(), this->ExtraFiles.begin(), @@ -732,7 +740,11 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements() std::back_inserter(orderOnlyDeps), MapToNinjaPath()); } - if (!orderOnlyDeps.empty()) { + std::sort(orderOnlyDeps.begin(), orderOnlyDeps.end()); + orderOnlyDeps.erase(std::unique(orderOnlyDeps.begin(), orderOnlyDeps.end()), + orderOnlyDeps.end()); + + { cmNinjaDeps orderOnlyTarget; orderOnlyTarget.push_back(this->OrderDependsTargetForTarget()); this->GetGlobalGenerator()->WritePhonyBuild( @@ -745,7 +757,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements() for (std::vector<cmSourceFile const*>::const_iterator si = objectSources.begin(); si != objectSources.end(); ++si) { - this->WriteObjectBuildStatement(*si, !orderOnlyDeps.empty()); + this->WriteObjectBuildStatement(*si); } if (!this->DDIFiles.empty()) { @@ -762,6 +774,17 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements() ddOutputs.push_back(this->GetDyndepFilePath("Fortran")); + // Make sure dyndep files for all our dependencies have already + // been generated so that the 'FortranModules.json' files they + // produced as side-effects are available for us to read. + // Ideally we should depend on the 'FortranModules.json' files + // from our dependencies directly, but we don't know which of + // our dependencies produces them. Fixing this will require + // refactoring the Ninja generator to generate targets in + // dependency order so that we can collect the needed information. + this->GetLocalGenerator()->AppendTargetDepends( + this->GeneratorTarget, ddOrderOnlyDeps, DependOnTargetArtifact); + this->GetGlobalGenerator()->WriteBuild( this->GetBuildFileStream(), ddComment, ddRule, ddOutputs, ddImplicitOuts, ddExplicitDeps, ddImplicitDeps, ddOrderOnlyDeps, ddVars); @@ -771,7 +794,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements() } void cmNinjaTargetGenerator::WriteObjectBuildStatement( - cmSourceFile const* source, bool writeOrderDependsTargetForTarget) + cmSourceFile const* source) { std::string const language = source->GetLanguage(); std::string const sourceFileName = @@ -822,9 +845,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( } cmNinjaDeps orderOnlyDeps; - if (writeOrderDependsTargetForTarget) { - orderOnlyDeps.push_back(this->OrderDependsTargetForTarget()); - } + orderOnlyDeps.push_back(this->OrderDependsTargetForTarget()); // If the source file is GENERATED and does not have a custom command // (either attached to this source file or another one), assume that one of diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index 7aba66b..5eb7a9a 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -3,7 +3,7 @@ #ifndef cmNinjaTargetGenerator_h #define cmNinjaTargetGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmCommonTargetGenerator.h" #include "cmGlobalNinjaGenerator.h" @@ -119,8 +119,7 @@ protected: void WriteLanguageRules(const std::string& language); void WriteCompileRule(const std::string& language); void WriteObjectBuildStatements(); - void WriteObjectBuildStatement(cmSourceFile const* source, - bool writeOrderDependsTargetForTarget); + void WriteObjectBuildStatement(cmSourceFile const* source); void WriteTargetDependInfo(std::string const& lang); void ExportObjectCompileCommand( diff --git a/Source/cmNinjaTypes.h b/Source/cmNinjaTypes.h index 3fd536a..ec435d9 100644 --- a/Source/cmNinjaTypes.h +++ b/Source/cmNinjaTypes.h @@ -3,12 +3,18 @@ #ifndef cmNinjaTypes_h #define cmNinjaTypes_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <map> #include <string> #include <vector> +enum cmNinjaTargetDepends +{ + DependOnTargetArtifact, + DependOnTargetOrdering +}; + typedef std::vector<std::string> cmNinjaDeps; typedef std::map<std::string, std::string> cmNinjaVars; diff --git a/Source/cmNinjaUtilityTargetGenerator.h b/Source/cmNinjaUtilityTargetGenerator.h index 897f432..9256e36 100644 --- a/Source/cmNinjaUtilityTargetGenerator.h +++ b/Source/cmNinjaUtilityTargetGenerator.h @@ -3,7 +3,7 @@ #ifndef cmNinjaUtilityTargetGenerator_h #define cmNinjaUtilityTargetGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmNinjaTargetGenerator.h" diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 8139be4..332fa83 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -2,11 +2,12 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmOSXBundleGenerator.h" -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmGeneratorTarget.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmTarget.h" @@ -42,7 +43,8 @@ void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName, // Compute bundle directory names. std::string out = outpath; out += "/"; - out += this->GT->GetAppBundleDirectory(this->ConfigName, false); + out += this->GT->GetAppBundleDirectory(this->ConfigName, + cmGeneratorTarget::FullLevel); cmSystemTools::MakeDirectory(out.c_str()); this->Makefile->AddCMakeOutputFile(out); @@ -52,7 +54,8 @@ void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName, // to be set. std::string plist = outpath; plist += "/"; - plist += this->GT->GetAppBundleDirectory(this->ConfigName, true); + plist += this->GT->GetAppBundleDirectory(this->ConfigName, + cmGeneratorTarget::ContentLevel); plist += "/Info.plist"; this->LocalGenerator->GenerateAppleInfoPList(this->GT, targetName, plist.c_str()); @@ -70,12 +73,14 @@ void cmOSXBundleGenerator::CreateFramework(const std::string& targetName, assert(this->MacContentFolders); // Compute the location of the top-level foo.framework directory. - std::string contentdir = - outpath + "/" + this->GT->GetFrameworkDirectory(this->ConfigName, true); + std::string contentdir = outpath + "/" + + this->GT->GetFrameworkDirectory(this->ConfigName, + cmGeneratorTarget::ContentLevel); contentdir += "/"; - std::string newoutpath = - outpath + "/" + this->GT->GetFrameworkDirectory(this->ConfigName, false); + std::string newoutpath = outpath + "/" + + this->GT->GetFrameworkDirectory(this->ConfigName, + cmGeneratorTarget::FullLevel); std::string frameworkVersion = this->GT->GetFrameworkVersion(); @@ -170,14 +175,16 @@ void cmOSXBundleGenerator::CreateCFBundle(const std::string& targetName, // Compute bundle directory names. std::string out = root; out += "/"; - out += this->GT->GetCFBundleDirectory(this->ConfigName, false); + out += this->GT->GetCFBundleDirectory(this->ConfigName, + cmGeneratorTarget::FullLevel); cmSystemTools::MakeDirectory(out.c_str()); this->Makefile->AddCMakeOutputFile(out); // Configure the Info.plist file. Note that it needs the executable name // to be set. - std::string plist = - root + "/" + this->GT->GetCFBundleDirectory(this->ConfigName, true); + std::string plist = root + "/" + + this->GT->GetCFBundleDirectory(this->ConfigName, + cmGeneratorTarget::ContentLevel); plist += "/Info.plist"; std::string name = cmSystemTools::GetFilenameName(targetName); this->LocalGenerator->GenerateAppleInfoPList(this->GT, name, plist.c_str()); @@ -207,8 +214,8 @@ std::string cmOSXBundleGenerator::InitMacOSXContentDirectory( { // Construct the full path to the content subdirectory. - std::string macdir = this->GT->GetMacContentDirectory(this->ConfigName, - /*implib*/ false); + std::string macdir = this->GT->GetMacContentDirectory( + this->ConfigName, cmStateEnums::RuntimeBinaryArtifact); macdir += "/"; macdir += pkgloc; cmSystemTools::MakeDirectory(macdir.c_str()); diff --git a/Source/cmOSXBundleGenerator.h b/Source/cmOSXBundleGenerator.h index 0a5a6c5..be7e932 100644 --- a/Source/cmOSXBundleGenerator.h +++ b/Source/cmOSXBundleGenerator.h @@ -3,7 +3,7 @@ #ifndef cmOSXBundleGenerator_h #define cmOSXBundleGenerator_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <set> #include <string> diff --git a/Source/cmOptionCommand.h b/Source/cmOptionCommand.h index 09567ff..86fa41f 100644 --- a/Source/cmOptionCommand.h +++ b/Source/cmOptionCommand.h @@ -3,7 +3,8 @@ #ifndef cmOptionCommand_h #define cmOptionCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmOrderDirectories.h b/Source/cmOrderDirectories.h index d9e0126..3a0637a 100644 --- a/Source/cmOrderDirectories.h +++ b/Source/cmOrderDirectories.h @@ -3,9 +3,9 @@ #ifndef cmOrderDirectories_h #define cmOrderDirectories_h -#include <cmConfigure.h> +#include "cmConfigure.h" -#include <cmsys/RegularExpression.hxx> +#include "cmsys/RegularExpression.hxx" #include <map> #include <set> #include <string> diff --git a/Source/cmOutputConverter.h b/Source/cmOutputConverter.h index a3da4cd..12a1773 100644 --- a/Source/cmOutputConverter.h +++ b/Source/cmOutputConverter.h @@ -3,7 +3,7 @@ #ifndef cmOutputConverter_h #define cmOutputConverter_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <string> diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx index 7a17f2c..2339d68 100644 --- a/Source/cmOutputRequiredFilesCommand.cxx +++ b/Source/cmOutputRequiredFilesCommand.cxx @@ -2,15 +2,14 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmOutputRequiredFilesCommand.h" -#include <cmsys/FStream.hxx> -#include <cmsys/RegularExpression.hxx> +#include "cmsys/FStream.hxx" +#include "cmsys/RegularExpression.hxx" #include <map> #include <utility> #include "cmAlgorithms.h" #include "cmGeneratorExpression.h" #include "cmMakefile.h" -#include "cmPolicies.h" #include "cmSourceFile.h" #include "cmSystemTools.h" #include "cmTarget.h" @@ -189,9 +188,8 @@ protected: if (qstart == std::string::npos) { cmSystemTools::Error("unknown include directive ", line.c_str()); continue; - } else { - qend = line.find('>', qstart + 1); } + qend = line.find('>', qstart + 1); } else { qend = line.find('\"', qstart + 1); } @@ -495,11 +493,6 @@ protected: bool cmOutputRequiredFilesCommand::InitialPass( std::vector<std::string> const& args, cmExecutionStatus&) { - if (this->Disallowed(cmPolicies::CMP0032, "The output_required_files " - "command should not be called; " - "see CMP0032.")) { - return true; - } if (args.size() != 2) { this->SetError("called with incorrect number of arguments"); return false; diff --git a/Source/cmOutputRequiredFilesCommand.h b/Source/cmOutputRequiredFilesCommand.h index c4ce680..e261eb0 100644 --- a/Source/cmOutputRequiredFilesCommand.h +++ b/Source/cmOutputRequiredFilesCommand.h @@ -3,7 +3,8 @@ #ifndef cmOutputRequiredFilesCommand_h #define cmOutputRequiredFilesCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <set> #include <stdio.h> #include <string> diff --git a/Source/cmParseArgumentsCommand.h b/Source/cmParseArgumentsCommand.h index 079eadb..4d9416d 100644 --- a/Source/cmParseArgumentsCommand.h +++ b/Source/cmParseArgumentsCommand.h @@ -3,7 +3,8 @@ #ifndef cmParseArgumentsCommand_h #define cmParseArgumentsCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmPathLabel.h b/Source/cmPathLabel.h index cd9743c..97551fb 100644 --- a/Source/cmPathLabel.h +++ b/Source/cmPathLabel.h @@ -3,7 +3,7 @@ #ifndef cmPathLabel_h #define cmPathLabel_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <string> diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index 6339e11..837557b 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -8,8 +8,8 @@ #include "cmVersion.h" #include "cmake.h" +#include "cmConfigure.h" #include <assert.h> -#include <cmConfigure.h> #include <ctype.h> #include <sstream> #include <stdio.h> diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 62e67c7..120beb6 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -3,7 +3,7 @@ #ifndef cmPolicies_h #define cmPolicies_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <bitset> #include <string> @@ -200,7 +200,13 @@ class cmMakefile; 7, 0, cmPolicies::WARN) \ SELECT(POLICY, CMP0067, \ "Honor language standard in try_compile() source-file signature.", \ - 3, 8, 0, cmPolicies::WARN) + 3, 8, 0, cmPolicies::WARN) \ + SELECT(POLICY, CMP0068, \ + "RPATH settings on macOS do not affect install_name.", 3, 9, 0, \ + cmPolicies::WARN) \ + SELECT(POLICY, CMP0069, \ + "INTERPROCEDURAL_OPTIMIZATION is enforced when enabled.", 3, 9, 0, \ + cmPolicies::WARN) #define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1) #define CM_FOR_EACH_POLICY_ID(POLICY) \ @@ -221,7 +227,9 @@ class cmMakefile; F(CMP0052) \ F(CMP0060) \ F(CMP0063) \ - F(CMP0065) + F(CMP0065) \ + F(CMP0068) \ + F(CMP0069) /** \class cmPolicies * \brief Handles changes in CMake behavior and policies diff --git a/Source/cmProcessOutput.h b/Source/cmProcessOutput.h index d2e631f..b5ec4a8 100644 --- a/Source/cmProcessOutput.h +++ b/Source/cmProcessOutput.h @@ -3,7 +3,7 @@ #ifndef cmProcessOutput_h #define cmProcessOutput_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <stddef.h> #include <string> diff --git a/Source/cmProcessTools.cxx b/Source/cmProcessTools.cxx index b756650..de7b061 100644 --- a/Source/cmProcessTools.cxx +++ b/Source/cmProcessTools.cxx @@ -3,7 +3,7 @@ #include "cmProcessTools.h" #include "cmProcessOutput.h" -#include <cmsys/Process.h> +#include "cmsys/Process.h" #include <ostream> void cmProcessTools::RunProcess(struct cmsysProcess_s* cp, OutputParser* out, diff --git a/Source/cmProcessTools.h b/Source/cmProcessTools.h index df131b9..e7d9a10 100644 --- a/Source/cmProcessTools.h +++ b/Source/cmProcessTools.h @@ -3,8 +3,8 @@ #ifndef cmProcessTools_h #define cmProcessTools_h +#include "cmConfigure.h" #include "cmProcessOutput.h" -#include <cmConfigure.h> #include <iosfwd> #include <string.h> diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index 4e0fa57..d47a047 100644 --- a/Source/cmProjectCommand.cxx +++ b/Source/cmProjectCommand.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmProjectCommand.h" -#include <cmsys/RegularExpression.hxx> +#include "cmsys/RegularExpression.hxx" #include <sstream> #include <stdio.h> @@ -62,10 +62,13 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args, bool haveVersion = false; bool haveLanguages = false; + bool haveDescription = false; std::string version; + std::string description; std::vector<std::string> languages; enum Doing { + DoingDescription, DoingLanguages, DoingVersion }; @@ -89,9 +92,21 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args, } haveVersion = true; doing = DoingVersion; + } else if (args[i] == "DESCRIPTION") { + if (haveDescription) { + this->Makefile->IssueMessage( + cmake::FATAL_ERROR, "DESCRITPION may be specified at most once."); + cmSystemTools::SetFatalErrorOccured(); + return true; + } + haveDescription = true; + doing = DoingDescription; } else if (doing == DoingVersion) { doing = DoingLanguages; version = args[i]; + } else if (doing == DoingDescription) { + doing = DoingLanguages; + description = args[i]; } else // doing == DoingLanguages { languages.push_back(args[i]); @@ -197,6 +212,22 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args, } } + if (haveDescription) { + this->Makefile->AddDefinition("PROJECT_DESCRIPTION", description.c_str()); + // Set the CMAKE_PROJECT_DESCRIPTION variable to be the highest-level + // project name in the tree. If there are two project commands + // in the same CMakeLists.txt file, and it is the top level + // CMakeLists.txt file, then go with the last one. + if (!this->Makefile->GetDefinition("CMAKE_PROJECT_DESCRIPTION") || + (this->Makefile->IsRootMakefile())) { + this->Makefile->AddDefinition("CMAKE_PROJECT_DESCRIPTION", + description.c_str()); + this->Makefile->AddCacheDefinition( + "CMAKE_PROJECT_DESCRIPTION", description.c_str(), + "Value Computed by CMake", cmStateEnums::STATIC); + } + } + if (languages.empty()) { // if no language is specified do c and c++ languages.push_back("C"); diff --git a/Source/cmProjectCommand.h b/Source/cmProjectCommand.h index cd92176..8fc90d2 100644 --- a/Source/cmProjectCommand.h +++ b/Source/cmProjectCommand.h @@ -3,7 +3,8 @@ #ifndef cmProjectCommand_h #define cmProjectCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmProperty.cxx b/Source/cmProperty.cxx index 90122a4..222afb4 100644 --- a/Source/cmProperty.cxx +++ b/Source/cmProperty.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmProperty.h" -#include <cmConfigure.h> +#include "cmConfigure.h" void cmProperty::Set(const char* value) { diff --git a/Source/cmProperty.h b/Source/cmProperty.h index 3f2dcfe..d11c5ef 100644 --- a/Source/cmProperty.h +++ b/Source/cmProperty.h @@ -3,7 +3,7 @@ #ifndef cmProperty_h #define cmProperty_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <string> diff --git a/Source/cmPropertyDefinition.h b/Source/cmPropertyDefinition.h index eb8d064..9adff49 100644 --- a/Source/cmPropertyDefinition.h +++ b/Source/cmPropertyDefinition.h @@ -3,7 +3,7 @@ #ifndef cmPropertyDefinition_h #define cmPropertyDefinition_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include "cmProperty.h" diff --git a/Source/cmPropertyDefinitionMap.h b/Source/cmPropertyDefinitionMap.h index e747503..97ba553 100644 --- a/Source/cmPropertyDefinitionMap.h +++ b/Source/cmPropertyDefinitionMap.h @@ -3,7 +3,7 @@ #ifndef cmPropertyDefinitionMap_h #define cmPropertyDefinitionMap_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include "cmProperty.h" #include "cmPropertyDefinition.h" diff --git a/Source/cmPropertyMap.cxx b/Source/cmPropertyMap.cxx index fa92ae2..1e089d1 100644 --- a/Source/cmPropertyMap.cxx +++ b/Source/cmPropertyMap.cxx @@ -2,9 +2,9 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmPropertyMap.h" +#include "cmConfigure.h" #include <algorithm> #include <assert.h> -#include <cmConfigure.h> #include <utility> cmProperty* cmPropertyMap::GetOrCreateProperty(const std::string& name) diff --git a/Source/cmPropertyMap.h b/Source/cmPropertyMap.h index e1db7df..5a05150 100644 --- a/Source/cmPropertyMap.h +++ b/Source/cmPropertyMap.h @@ -3,7 +3,7 @@ #ifndef cmPropertyMap_h #define cmPropertyMap_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include "cmProperty.h" diff --git a/Source/cmQTWrapCPPCommand.h b/Source/cmQTWrapCPPCommand.h index 8eb5ff9..34adf29 100644 --- a/Source/cmQTWrapCPPCommand.h +++ b/Source/cmQTWrapCPPCommand.h @@ -3,7 +3,8 @@ #ifndef cmQTWrapCPPCommand_h #define cmQTWrapCPPCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmQTWrapUICommand.h b/Source/cmQTWrapUICommand.h index 876ddd5..279d4e9 100644 --- a/Source/cmQTWrapUICommand.h +++ b/Source/cmQTWrapUICommand.h @@ -3,7 +3,8 @@ #ifndef cmQTWrapUICommand_h #define cmQTWrapUICommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmQtAutoGeneratorCommon.cxx b/Source/cmQtAutoGeneratorCommon.cxx new file mode 100644 index 0000000..1807514 --- /dev/null +++ b/Source/cmQtAutoGeneratorCommon.cxx @@ -0,0 +1,216 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#include "cmQtAutoGeneratorCommon.h" +#include "cmAlgorithms.h" +#include "cmSystemTools.h" + +#include "cmsys/FStream.hxx" +#include "cmsys/RegularExpression.hxx" + +#include <sstream> +#include <stddef.h> + +// - Static functions + +static std::string utilStripCR(std::string const& line) +{ + // Strip CR characters rcc may have printed (possibly more than one!). + std::string::size_type cr = line.find('\r'); + if (cr != line.npos) { + return line.substr(0, cr); + } + return line; +} + +/// @brief Reads the resource files list from from a .qrc file - Qt4 version +/// @return True if the .qrc file was successfully parsed +static bool RccListInputsQt4(const std::string& fileName, + std::vector<std::string>& files, + std::string* errorMessage) +{ + bool allGood = true; + // Read qrc file content into string + std::string qrcContents; + { + cmsys::ifstream ifs(fileName.c_str()); + if (ifs) { + std::ostringstream osst; + osst << ifs.rdbuf(); + qrcContents = osst.str(); + } else { + if (errorMessage != CM_NULLPTR) { + std::ostringstream ost; + ost << "AutoRcc: Error: Rcc file not readable:\n" + << cmQtAutoGeneratorCommon::Quoted(fileName) << "\n"; + *errorMessage = ost.str(); + } + allGood = false; + } + } + if (allGood) { + // qrc file directory + std::string qrcDir(cmsys::SystemTools::GetFilenamePath(fileName)); + if (!qrcDir.empty()) { + qrcDir += '/'; + } + + cmsys::RegularExpression fileMatchRegex("(<file[^<]+)"); + cmsys::RegularExpression fileReplaceRegex("(^<file[^>]*>)"); + + size_t offset = 0; + while (fileMatchRegex.find(qrcContents.c_str() + offset)) { + std::string qrcEntry = fileMatchRegex.match(1); + offset += qrcEntry.size(); + { + fileReplaceRegex.find(qrcEntry); + std::string tag = fileReplaceRegex.match(1); + qrcEntry = qrcEntry.substr(tag.size()); + } + if (!cmSystemTools::FileIsFullPath(qrcEntry.c_str())) { + qrcEntry = qrcDir + qrcEntry; + } + files.push_back(qrcEntry); + } + } + return allGood; +} + +/// @brief Reads the resource files list from from a .qrc file - Qt5 version +/// @return True if the .qrc file was successfully parsed +static bool RccListInputsQt5(const std::string& rccCommand, + const std::string& fileName, + std::vector<std::string>& files, + std::string* errorMessage) +{ + if (rccCommand.empty()) { + cmSystemTools::Error("AutoRcc: Error: rcc executable not available\n"); + return false; + } + + // Read rcc features + bool hasDashDashList = false; + { + std::vector<std::string> command; + command.push_back(rccCommand); + command.push_back("--help"); + std::string rccStdOut; + std::string rccStdErr; + int retVal = 0; + bool result = + cmSystemTools::RunSingleCommand(command, &rccStdOut, &rccStdErr, &retVal, + CM_NULLPTR, cmSystemTools::OUTPUT_NONE); + if (result && retVal == 0 && + rccStdOut.find("--list") != std::string::npos) { + hasDashDashList = true; + } + } + + // Run rcc list command + bool result = false; + int retVal = 0; + std::string rccStdOut; + std::string rccStdErr; + { + std::vector<std::string> command; + command.push_back(rccCommand); + command.push_back(hasDashDashList ? "--list" : "-list"); + command.push_back(fileName); + result = + cmSystemTools::RunSingleCommand(command, &rccStdOut, &rccStdErr, &retVal, + CM_NULLPTR, cmSystemTools::OUTPUT_NONE); + } + if (!result || retVal) { + if (errorMessage != CM_NULLPTR) { + std::ostringstream ost; + ost << "AutoRcc: Error: Rcc list process for " << fileName + << " failed:\n" + << rccStdOut << "\n" + << rccStdErr << "\n"; + *errorMessage = ost.str(); + } + return false; + } + + // Parse rcc std output + { + std::istringstream ostr(rccStdOut); + std::string oline; + while (std::getline(ostr, oline)) { + oline = utilStripCR(oline); + if (!oline.empty()) { + files.push_back(oline); + } + } + } + // Parse rcc error output + { + std::istringstream estr(rccStdErr); + std::string eline; + while (std::getline(estr, eline)) { + eline = utilStripCR(eline); + if (cmHasLiteralPrefix(eline, "RCC: Error in")) { + static std::string searchString = "Cannot find file '"; + + std::string::size_type pos = eline.find(searchString); + if (pos == std::string::npos) { + if (errorMessage != CM_NULLPTR) { + std::ostringstream ost; + ost << "AutoRcc: Error: Rcc lists unparsable output:\n" + << cmQtAutoGeneratorCommon::Quoted(eline) << "\n"; + *errorMessage = ost.str(); + } + return false; + } + pos += searchString.length(); + std::string::size_type sz = eline.size() - pos - 1; + files.push_back(eline.substr(pos, sz)); + } + } + } + + return true; +} + +// - Class definitions + +const char* cmQtAutoGeneratorCommon::listSep = "@LSEP@"; + +std::string cmQtAutoGeneratorCommon::Quoted(const std::string& text) +{ + static const char* rep[18] = { "\\", "\\\\", "\"", "\\\"", "\a", "\\a", + "\b", "\\b", "\f", "\\f", "\n", "\\n", + "\r", "\\r", "\t", "\\t", "\v", "\\v" }; + + std::string res = text; + for (const char* const* it = cmArrayBegin(rep); it != cmArrayEnd(rep); + it += 2) { + cmSystemTools::ReplaceString(res, *it, *(it + 1)); + } + res = '"' + res; + res += '"'; + return res; +} + +bool cmQtAutoGeneratorCommon::RccListInputs(const std::string& qtMajorVersion, + const std::string& rccCommand, + const std::string& fileName, + std::vector<std::string>& files, + std::string* errorMessage) +{ + bool allGood = false; + if (cmsys::SystemTools::FileExists(fileName.c_str())) { + if (qtMajorVersion == "4") { + allGood = RccListInputsQt4(fileName, files, errorMessage); + } else { + allGood = RccListInputsQt5(rccCommand, fileName, files, errorMessage); + } + } else { + if (errorMessage != CM_NULLPTR) { + std::ostringstream ost; + ost << "AutoRcc: Error: Rcc file does not exist:\n" + << cmQtAutoGeneratorCommon::Quoted(fileName) << "\n"; + *errorMessage = ost.str(); + } + } + return allGood; +} diff --git a/Source/cmQtAutoGeneratorCommon.h b/Source/cmQtAutoGeneratorCommon.h new file mode 100644 index 0000000..a131baf --- /dev/null +++ b/Source/cmQtAutoGeneratorCommon.h @@ -0,0 +1,39 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#ifndef cmQtAutoGeneratorCommon_h +#define cmQtAutoGeneratorCommon_h + +#include "cmConfigure.h" + +#include <string> +#include <vector> + +class cmQtAutoGeneratorCommon +{ + // - Types and statics +public: + static const char* listSep; + + enum GeneratorType + { + MOC, + UIC, + RCC + }; + +public: + /// @brief Returns a the string escaped and enclosed in quotes + /// + static std::string Quoted(const std::string& text); + + /// @brief Reads the resource files list from from a .qrc file + /// @arg fileName Must be the absolute path of the .qrc file + /// @return True if the rcc file was successfully parsed + static bool RccListInputs(const std::string& qtMajorVersion, + const std::string& rccCommand, + const std::string& fileName, + std::vector<std::string>& files, + std::string* errorMessage = CM_NULLPTR); +}; + +#endif diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx index 825eba0..239b18d 100644 --- a/Source/cmQtAutoGeneratorInitializer.cxx +++ b/Source/cmQtAutoGeneratorInitializer.cxx @@ -1,37 +1,33 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmQtAutoGeneratorInitializer.h" +#include "cmQtAutoGeneratorCommon.h" #include "cmAlgorithms.h" #include "cmCustomCommandLines.h" #include "cmFilePathChecksum.h" #include "cmGeneratorTarget.h" -#include "cmGlobalGenerator.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmOutputConverter.h" #include "cmSourceFile.h" -#include "cmSourceFileLocation.h" +#include "cmSourceGroup.h" #include "cmState.h" #include "cmSystemTools.h" #include "cmTarget.h" +#include "cm_sys_stat.h" #include "cmake.h" #if defined(_WIN32) && !defined(__CYGWIN__) #include "cmGlobalVisualStudioGenerator.h" #endif +#include "cmConfigure.h" +#include "cmsys/FStream.hxx" #include <algorithm> -#include <assert.h> -#include <cmConfigure.h> -#include <cmsys/FStream.hxx> -#include <cmsys/RegularExpression.hxx> #include <map> #include <set> -#include <sstream> -#include <string.h> #include <string> -#include <sys/stat.h> #include <utility> #include <vector> @@ -45,14 +41,16 @@ static void utilCopyTargetProperty(cmTarget* destinationTarget, } } -static std::string utilStripCR(std::string const& line) +inline static bool PropertyEnabled(cmSourceFile* sourceFile, const char* key) { - // Strip CR characters rcc may have printed (possibly more than one!). - std::string::size_type cr = line.find('\r'); - if (cr != line.npos) { - return line.substr(0, cr); - } - return line; + return cmSystemTools::IsOn(sourceFile->GetPropertyForUser(key)); +} + +static std::string GetSafeProperty(cmGeneratorTarget const* target, + const char* key) +{ + const char* tmp = target->GetProperty(key); + return std::string((tmp != CM_NULLPTR) ? tmp : ""); } static std::string GetAutogenTargetName(cmGeneratorTarget const* target) @@ -98,21 +96,141 @@ static std::string GetQtMajorVersion(cmGeneratorTarget const* target) return qtMajorVersion; } -static void SetupSourceFiles(cmGeneratorTarget const* target, +static std::string GetQtMinorVersion(cmGeneratorTarget const* target, + const std::string& qtMajorVersion) +{ + cmMakefile* makefile = target->Target->GetMakefile(); + std::string qtMinorVersion; + if (qtMajorVersion == "5") { + qtMinorVersion = makefile->GetSafeDefinition("Qt5Core_VERSION_MINOR"); + } + if (qtMinorVersion.empty()) { + qtMinorVersion = makefile->GetSafeDefinition("QT_VERSION_MINOR"); + } + + const char* targetQtVersion = + target->GetLinkInterfaceDependentStringProperty("QT_MINOR_VERSION", ""); + if (targetQtVersion != CM_NULLPTR) { + qtMinorVersion = targetQtVersion; + } + return qtMinorVersion; +} + +static bool QtVersionGreaterOrEqual(const std::string& major, + const std::string& minor, + unsigned long requestMajor, + unsigned long requestMinor) +{ + unsigned long majorUL(0); + unsigned long minorUL(0); + if (cmSystemTools::StringToULong(major.c_str(), &majorUL) && + cmSystemTools::StringToULong(minor.c_str(), &minorUL)) { + return (majorUL > requestMajor) || + (majorUL == requestMajor && minorUL >= requestMinor); + } + return false; +} + +static void GetCompileDefinitionsAndDirectories( + cmGeneratorTarget const* target, const std::string& config, + std::string& incs, std::string& defs) +{ + cmLocalGenerator* localGen = target->GetLocalGenerator(); + { + std::vector<std::string> includeDirs; + // Get the include dirs for this target, without stripping the implicit + // include dirs off, see + // https://gitlab.kitware.com/cmake/cmake/issues/13667 + localGen->GetIncludeDirectories(includeDirs, target, "CXX", config, false); + incs = cmJoin(includeDirs, ";"); + } + { + std::set<std::string> defines; + localGen->AddCompileDefinitions(defines, target, config, "CXX"); + defs += cmJoin(defines, ";"); + } +} + +static void AddDefinitionEscaped(cmMakefile* makefile, const char* key, + const std::string& value) +{ + makefile->AddDefinition(key, + cmOutputConverter::EscapeForCMake(value).c_str()); +} + +static void AddDefinitionEscaped(cmMakefile* makefile, const char* key, + const std::vector<std::string>& values) +{ + makefile->AddDefinition( + key, cmOutputConverter::EscapeForCMake(cmJoin(values, ";")).c_str()); +} + +static bool AddToSourceGroup(cmMakefile* makefile, const std::string& fileName, + cmQtAutoGeneratorCommon::GeneratorType genType) +{ + cmSourceGroup* sourceGroup = CM_NULLPTR; + // Acquire source group + { + const char* groupName = CM_NULLPTR; + // Use generator specific group name + switch (genType) { + case cmQtAutoGeneratorCommon::MOC: + groupName = + makefile->GetState()->GetGlobalProperty("AUTOMOC_SOURCE_GROUP"); + break; + case cmQtAutoGeneratorCommon::RCC: + groupName = + makefile->GetState()->GetGlobalProperty("AUTORCC_SOURCE_GROUP"); + break; + default: + break; + } + // Use default group name on demand + if ((groupName == CM_NULLPTR) || (*groupName == 0)) { + groupName = + makefile->GetState()->GetGlobalProperty("AUTOGEN_SOURCE_GROUP"); + } + // Generate a source group on demand + if ((groupName != CM_NULLPTR) && (*groupName != 0)) { + { + const char* delimiter = + makefile->GetDefinition("SOURCE_GROUP_DELIMITER"); + if (delimiter == CM_NULLPTR) { + delimiter = "\\"; + } + std::vector<std::string> folders = + cmSystemTools::tokenize(groupName, delimiter); + sourceGroup = makefile->GetSourceGroup(folders); + if (sourceGroup == CM_NULLPTR) { + makefile->AddSourceGroup(folders); + sourceGroup = makefile->GetSourceGroup(folders); + } + } + if (sourceGroup == CM_NULLPTR) { + cmSystemTools::Error( + "Autogen: Could not create or find source group: ", + cmQtAutoGeneratorCommon::Quoted(groupName).c_str()); + return false; + } + } + } + if (sourceGroup != CM_NULLPTR) { + sourceGroup->AddGroupFile(fileName); + } + return true; +} + +static void AcquireScanFiles(cmGeneratorTarget const* target, std::vector<std::string>& mocUicSources, std::vector<std::string>& mocUicHeaders, - std::vector<std::string>& skipMocList, - std::vector<std::string>& skipUicList) + std::vector<std::string>& mocSkipList, + std::vector<std::string>& uicSkipList) { - cmMakefile* makefile = target->Target->GetMakefile(); + const bool mocTarget = target->GetPropertyAsBool("AUTOMOC"); + const bool uicTarget = target->GetPropertyAsBool("AUTOUIC"); std::vector<cmSourceFile*> srcFiles; target->GetConfigCommonSourceFiles(srcFiles); - - const bool targetMoc = target->GetPropertyAsBool("AUTOMOC"); - const bool targetUic = target->GetPropertyAsBool("AUTOUIC"); - - cmFilePathChecksum fpathCheckSum(makefile); for (std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin(); fileIt != srcFiles.end(); ++fileIt) { cmSourceFile* sf = *fileIt; @@ -123,30 +241,24 @@ static void SetupSourceFiles(cmGeneratorTarget const* target, !(fileType == cmSystemTools::HEADER_FILE_FORMAT)) { continue; } - if (cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED"))) { - continue; - } const std::string absFile = cmsys::SystemTools::GetRealPath(sf->GetFullPath()); // Skip flags - const bool skipAll = - cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOGEN")); - const bool skipMoc = - skipAll || cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOMOC")); - const bool skipUic = - skipAll || cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOUIC")); + const bool skipAll = PropertyEnabled(sf, "SKIP_AUTOGEN"); + const bool mocSkip = skipAll || PropertyEnabled(sf, "SKIP_AUTOMOC"); + const bool uicSkip = skipAll || PropertyEnabled(sf, "SKIP_AUTOUIC"); // Add file name to skip lists. // Do this even when the file is not added to the sources/headers lists // because the file name may be extracted from an other file when // processing - if (skipMoc) { - skipMocList.push_back(absFile); + if (mocSkip) { + mocSkipList.push_back(absFile); } - if (skipUic) { - skipUicList.push_back(absFile); + if (uicSkip) { + uicSkipList.push_back(absFile); } - if ((targetMoc && !skipMoc) || (targetUic && !skipUic)) { + if ((mocTarget && !mocSkip) || (uicTarget && !uicSkip)) { // Add file name to sources or headers list switch (fileType) { case cmSystemTools::CXX_FILE_FORMAT: @@ -162,100 +274,95 @@ static void SetupSourceFiles(cmGeneratorTarget const* target, } } -static void GetCompileDefinitionsAndDirectories( - cmGeneratorTarget const* target, const std::string& config, - std::string& incs, std::string& defs) -{ - std::vector<std::string> includeDirs; - cmLocalGenerator* localGen = target->GetLocalGenerator(); - // Get the include dirs for this target, without stripping the implicit - // include dirs off, see https://gitlab.kitware.com/cmake/cmake/issues/13667 - localGen->GetIncludeDirectories(includeDirs, target, "CXX", config, false); - - incs = cmJoin(includeDirs, ";"); - - std::set<std::string> defines; - localGen->AddCompileDefinitions(defines, target, config, "CXX"); - - defs += cmJoin(defines, ";"); -} - static void MocSetupAutoTarget( cmGeneratorTarget const* target, const std::string& autogenTargetName, - std::vector<std::string> const& skipMoc, + const std::string& qtMajorVersion, + std::vector<std::string> const& mocSkipList, std::map<std::string, std::string>& configIncludes, std::map<std::string, std::string>& configDefines) { cmLocalGenerator* lg = target->GetLocalGenerator(); cmMakefile* makefile = target->Target->GetMakefile(); - const char* tmp = target->GetProperty("AUTOMOC_MOC_OPTIONS"); - std::string _moc_options = (tmp != CM_NULLPTR ? tmp : ""); - makefile->AddDefinition( - "_moc_options", cmOutputConverter::EscapeForCMake(_moc_options).c_str()); - makefile->AddDefinition( - "_skip_moc", - cmOutputConverter::EscapeForCMake(cmJoin(skipMoc, ";")).c_str()); - bool relaxedMode = makefile->IsOn("CMAKE_AUTOMOC_RELAXED_MODE"); - makefile->AddDefinition("_moc_relaxed_mode", relaxedMode ? "TRUE" : "FALSE"); - - std::string _moc_incs; - std::string _moc_compile_defs; - std::vector<std::string> configs; - const std::string& config = makefile->GetConfigurations(configs); - GetCompileDefinitionsAndDirectories(target, config, _moc_incs, - _moc_compile_defs); - - makefile->AddDefinition( - "_moc_incs", cmOutputConverter::EscapeForCMake(_moc_incs).c_str()); - makefile->AddDefinition( - "_moc_compile_defs", - cmOutputConverter::EscapeForCMake(_moc_compile_defs).c_str()); - - for (std::vector<std::string>::const_iterator li = configs.begin(); - li != configs.end(); ++li) { - std::string config_moc_incs; - std::string config_moc_compile_defs; - GetCompileDefinitionsAndDirectories(target, *li, config_moc_incs, - config_moc_compile_defs); - if (config_moc_incs != _moc_incs) { - configIncludes[*li] = cmOutputConverter::EscapeForCMake(config_moc_incs); - if (_moc_incs.empty()) { - _moc_incs = config_moc_incs; + AddDefinitionEscaped(makefile, "_moc_options", + GetSafeProperty(target, "AUTOMOC_MOC_OPTIONS")); + AddDefinitionEscaped(makefile, "_moc_skip", mocSkipList); + AddDefinitionEscaped(makefile, "_moc_relaxed_mode", + makefile->IsOn("CMAKE_AUTOMOC_RELAXED_MODE") ? "TRUE" + : "FALSE"); + AddDefinitionEscaped(makefile, "_moc_depend_filters", + GetSafeProperty(target, "AUTOMOC_DEPEND_FILTERS")); + + if (QtVersionGreaterOrEqual( + qtMajorVersion, GetQtMinorVersion(target, qtMajorVersion), 5, 8)) { + AddDefinitionEscaped( + makefile, "_moc_predefs_cmd", + makefile->GetSafeDefinition("CMAKE_CXX_COMPILER_PREDEFINES_COMMAND")); + } + // Moc includes and compile definitions + { + std::string _moc_incs; + std::string _moc_compile_defs; + std::vector<std::string> configs; + { + const std::string& config = makefile->GetConfigurations(configs); + GetCompileDefinitionsAndDirectories(target, config, _moc_incs, + _moc_compile_defs); + AddDefinitionEscaped(makefile, "_moc_incs", _moc_incs); + AddDefinitionEscaped(makefile, "_moc_compile_defs", _moc_compile_defs); + } + for (std::vector<std::string>::const_iterator li = configs.begin(); + li != configs.end(); ++li) { + std::string config_moc_incs; + std::string config_moc_compile_defs; + GetCompileDefinitionsAndDirectories(target, *li, config_moc_incs, + config_moc_compile_defs); + if (config_moc_incs != _moc_incs) { + configIncludes[*li] = + cmOutputConverter::EscapeForCMake(config_moc_incs); + if (_moc_incs.empty()) { + _moc_incs = config_moc_incs; + } } - } - if (config_moc_compile_defs != _moc_compile_defs) { - configDefines[*li] = - cmOutputConverter::EscapeForCMake(config_moc_compile_defs); - if (_moc_compile_defs.empty()) { - _moc_compile_defs = config_moc_compile_defs; + if (config_moc_compile_defs != _moc_compile_defs) { + configDefines[*li] = + cmOutputConverter::EscapeForCMake(config_moc_compile_defs); + if (_moc_compile_defs.empty()) { + _moc_compile_defs = config_moc_compile_defs; + } } } } - const char* qtVersion = makefile->GetDefinition("_target_qt_version"); - if (strcmp(qtVersion, "5") == 0) { - cmGeneratorTarget* qt5Moc = lg->FindGeneratorTargetToUse("Qt5::moc"); - if (!qt5Moc) { - cmSystemTools::Error("Qt5::moc target not found ", - autogenTargetName.c_str()); - return; + // Moc executable + { + std::string err; + const char* mocExec = CM_NULLPTR; + if (qtMajorVersion == "5") { + cmGeneratorTarget* qt5Moc = lg->FindGeneratorTargetToUse("Qt5::moc"); + if (qt5Moc != CM_NULLPTR) { + mocExec = qt5Moc->ImportedGetLocation(""); + } else { + err = "Qt5::moc target not found " + autogenTargetName; + } + } else if (qtMajorVersion == "4") { + cmGeneratorTarget* qt4Moc = lg->FindGeneratorTargetToUse("Qt4::moc"); + if (qt4Moc != CM_NULLPTR) { + mocExec = qt4Moc->ImportedGetLocation(""); + } else { + err = "Qt4::moc target not found " + autogenTargetName; + } + } else { + err = "The CMAKE_AUTOMOC feature supports only Qt 4 and Qt 5 "; + err += autogenTargetName; } - makefile->AddDefinition("_qt_moc_executable", - qt5Moc->ImportedGetLocation("")); - } else if (strcmp(qtVersion, "4") == 0) { - cmGeneratorTarget* qt4Moc = lg->FindGeneratorTargetToUse("Qt4::moc"); - if (!qt4Moc) { - cmSystemTools::Error("Qt4::moc target not found ", - autogenTargetName.c_str()); - return; + // Add definition or error + if (err.empty()) { + AddDefinitionEscaped(makefile, "_qt_moc_executable", + mocExec ? mocExec : ""); + } else { + cmSystemTools::Error(err.c_str()); } - makefile->AddDefinition("_qt_moc_executable", - qt4Moc->ImportedGetLocation("")); - } else { - cmSystemTools::Error("The CMAKE_AUTOMOC feature supports only Qt 4 and " - "Qt 5 ", - autogenTargetName.c_str()); } } @@ -268,126 +375,140 @@ static void UicGetOpts(cmGeneratorTarget const* target, } static void UicSetupAutoTarget( - cmGeneratorTarget const* target, std::vector<std::string> const& skipUic, + cmGeneratorTarget const* target, const std::string& qtMajorVersion, + std::vector<std::string> const& uicSkipList, std::map<std::string, std::string>& configUicOptions) { cmLocalGenerator* lg = target->GetLocalGenerator(); cmMakefile* makefile = target->Target->GetMakefile(); - std::set<std::string> skipped; - skipped.insert(skipUic.begin(), skipUic.end()); + AddDefinitionEscaped(makefile, "_uic_skip", uicSkipList); - makefile->AddDefinition( - "_skip_uic", - cmOutputConverter::EscapeForCMake(cmJoin(skipUic, ";")).c_str()); - - std::vector<cmSourceFile*> uiFilesWithOptions = - makefile->GetQtUiFilesWithOptions(); - - const char* qtVersion = makefile->GetDefinition("_target_qt_version"); - - std::string _uic_opts; - std::vector<std::string> configs; - const std::string& config = makefile->GetConfigurations(configs); - UicGetOpts(target, config, _uic_opts); - - if (!_uic_opts.empty()) { - _uic_opts = cmOutputConverter::EscapeForCMake(_uic_opts); - makefile->AddDefinition("_uic_target_options", _uic_opts.c_str()); - } - for (std::vector<std::string>::const_iterator li = configs.begin(); - li != configs.end(); ++li) { - std::string config_uic_opts; - UicGetOpts(target, *li, config_uic_opts); - if (config_uic_opts != _uic_opts) { - configUicOptions[*li] = - cmOutputConverter::EscapeForCMake(config_uic_opts); - if (_uic_opts.empty()) { - _uic_opts = config_uic_opts; - } + // Uic search paths + { + std::vector<std::string> uicSearchPaths; + cmSystemTools::ExpandListArgument( + GetSafeProperty(target, "AUTOUIC_SEARCH_PATHS"), uicSearchPaths); + const std::string srcDir = makefile->GetCurrentSourceDirectory(); + for (std::vector<std::string>::iterator it = uicSearchPaths.begin(); + it != uicSearchPaths.end(); ++it) { + *it = cmSystemTools::CollapseFullPath(*it, srcDir); } + AddDefinitionEscaped(makefile, "_uic_search_paths", uicSearchPaths); } - std::string uiFileFiles; - std::string uiFileOptions; - const char* sep = ""; - - for (std::vector<cmSourceFile*>::const_iterator fileIt = - uiFilesWithOptions.begin(); - fileIt != uiFilesWithOptions.end(); ++fileIt) { - cmSourceFile* sf = *fileIt; - std::string absFile = cmsys::SystemTools::GetRealPath(sf->GetFullPath()); - - if (!skipped.insert(absFile).second) { - continue; + // Uic target options + { + std::string _uic_opts; + std::vector<std::string> configs; + UicGetOpts(target, makefile->GetConfigurations(configs), _uic_opts); + + AddDefinitionEscaped(makefile, "_uic_target_options", _uic_opts); + + for (std::vector<std::string>::const_iterator li = configs.begin(); + li != configs.end(); ++li) { + std::string config_uic_opts; + UicGetOpts(target, *li, config_uic_opts); + if (config_uic_opts != _uic_opts) { + configUicOptions[*li] = + cmOutputConverter::EscapeForCMake(config_uic_opts); + if (_uic_opts.empty()) { + _uic_opts = config_uic_opts; + } + } } - uiFileFiles += sep; - uiFileFiles += absFile; - uiFileOptions += sep; - std::string opts = sf->GetProperty("AUTOUIC_OPTIONS"); - cmSystemTools::ReplaceString(opts, ";", "@list_sep@"); - uiFileOptions += opts; - sep = ";"; + } + // Uic files options + { + std::vector<std::string> uiFileFiles; + std::vector<std::string> uiFileOptions; + { + std::set<std::string> skipped; + skipped.insert(uicSkipList.begin(), uicSkipList.end()); + + const std::vector<cmSourceFile*> uiFilesWithOptions = + makefile->GetQtUiFilesWithOptions(); + for (std::vector<cmSourceFile*>::const_iterator fileIt = + uiFilesWithOptions.begin(); + fileIt != uiFilesWithOptions.end(); ++fileIt) { + cmSourceFile* sf = *fileIt; + const std::string absFile = + cmsys::SystemTools::GetRealPath(sf->GetFullPath()); + if (skipped.insert(absFile).second) { + // The file wasn't skipped + uiFileFiles.push_back(absFile); + { + std::string opts = sf->GetProperty("AUTOUIC_OPTIONS"); + cmSystemTools::ReplaceString(opts, ";", + cmQtAutoGeneratorCommon::listSep); + uiFileOptions.push_back(opts); + } + } + } + } + AddDefinitionEscaped(makefile, "_qt_uic_options_files", uiFileFiles); + AddDefinitionEscaped(makefile, "_qt_uic_options_options", uiFileOptions); } - makefile->AddDefinition( - "_qt_uic_options_files", - cmOutputConverter::EscapeForCMake(uiFileFiles).c_str()); - makefile->AddDefinition( - "_qt_uic_options_options", - cmOutputConverter::EscapeForCMake(uiFileOptions).c_str()); - - std::string targetName = target->GetName(); - if (strcmp(qtVersion, "5") == 0) { - cmGeneratorTarget* qt5Uic = lg->FindGeneratorTargetToUse("Qt5::uic"); - if (!qt5Uic) { - // Project does not use Qt5Widgets, but has AUTOUIC ON anyway + // Uic executable + { + std::string err; + const char* uicExec = CM_NULLPTR; + if (qtMajorVersion == "5") { + cmGeneratorTarget* qt5Uic = lg->FindGeneratorTargetToUse("Qt5::uic"); + if (qt5Uic != CM_NULLPTR) { + uicExec = qt5Uic->ImportedGetLocation(""); + } else { + // Project does not use Qt5Widgets, but has AUTOUIC ON anyway + } + } else if (qtMajorVersion == "4") { + cmGeneratorTarget* qt4Uic = lg->FindGeneratorTargetToUse("Qt4::uic"); + if (qt4Uic != CM_NULLPTR) { + uicExec = qt4Uic->ImportedGetLocation(""); + } else { + err = "Qt4::uic target not found " + target->GetName(); + } } else { - makefile->AddDefinition("_qt_uic_executable", - qt5Uic->ImportedGetLocation("")); + err = "The CMAKE_AUTOUIC feature supports only Qt 4 and Qt 5 "; + err += target->GetName(); } - } else if (strcmp(qtVersion, "4") == 0) { - cmGeneratorTarget* qt4Uic = lg->FindGeneratorTargetToUse("Qt4::uic"); - if (!qt4Uic) { - cmSystemTools::Error("Qt4::uic target not found ", targetName.c_str()); - return; + // Add definition or error + if (err.empty()) { + AddDefinitionEscaped(makefile, "_qt_uic_executable", + uicExec ? uicExec : ""); + } else { + cmSystemTools::Error(err.c_str()); } - makefile->AddDefinition("_qt_uic_executable", - qt4Uic->ImportedGetLocation("")); - } else { - cmSystemTools::Error("The CMAKE_AUTOUIC feature supports only Qt 4 and " - "Qt 5 ", - targetName.c_str()); } } static std::string RccGetExecutable(cmGeneratorTarget const* target, const std::string& qtMajorVersion) { + std::string rccExec; cmLocalGenerator* lg = target->GetLocalGenerator(); - - std::string const& targetName = target->GetName(); if (qtMajorVersion == "5") { cmGeneratorTarget* qt5Rcc = lg->FindGeneratorTargetToUse("Qt5::rcc"); - if (!qt5Rcc) { - cmSystemTools::Error("Qt5::rcc target not found ", targetName.c_str()); - return std::string(); + if (qt5Rcc != CM_NULLPTR) { + rccExec = qt5Rcc->ImportedGetLocation(""); + } else { + cmSystemTools::Error("Qt5::rcc target not found ", + target->GetName().c_str()); } - return qt5Rcc->ImportedGetLocation(""); - } - if (qtMajorVersion == "4") { + } else if (qtMajorVersion == "4") { cmGeneratorTarget* qt4Rcc = lg->FindGeneratorTargetToUse("Qt4::rcc"); - if (!qt4Rcc) { - cmSystemTools::Error("Qt4::rcc target not found ", targetName.c_str()); - return std::string(); + if (qt4Rcc != CM_NULLPTR) { + rccExec = qt4Rcc->ImportedGetLocation(""); + } else { + cmSystemTools::Error("Qt4::rcc target not found ", + target->GetName().c_str()); } - return qt4Rcc->ImportedGetLocation(""); + } else { + cmSystemTools::Error( + "The CMAKE_AUTORCC feature supports only Qt 4 and Qt 5 ", + target->GetName().c_str()); } - - cmSystemTools::Error("The CMAKE_AUTORCC feature supports only Qt 4 and " - "Qt 5 ", - targetName.c_str()); - return std::string(); + return rccExec; } static void RccMergeOptions(std::vector<std::string>& opts, @@ -397,255 +518,104 @@ static void RccMergeOptions(std::vector<std::string>& opts, static const char* valueOptions[] = { "name", "root", "compress", "threshold" }; std::vector<std::string> extraOpts; - for (std::vector<std::string>::const_iterator it = fileOpts.begin(); - it != fileOpts.end(); ++it) { + for (std::vector<std::string>::const_iterator fit = fileOpts.begin(); + fit != fileOpts.end(); ++fit) { std::vector<std::string>::iterator existingIt = - std::find(opts.begin(), opts.end(), *it); + std::find(opts.begin(), opts.end(), *fit); if (existingIt != opts.end()) { - const char* o = it->c_str(); - if (*o == '-') { - ++o; - } - if (isQt5 && *o == '-') { - ++o; + const char* optName = fit->c_str(); + if (*optName == '-') { + ++optName; + if (isQt5 && *optName == '-') { + ++optName; + } } - if (std::find_if(cmArrayBegin(valueOptions), cmArrayEnd(valueOptions), - cmStrCmp(*it)) != cmArrayEnd(valueOptions)) { - assert(existingIt + 1 != opts.end()); - *(existingIt + 1) = *(it + 1); - ++it; + // Test if this is a value option and change the existing value + if ((optName != fit->c_str()) && + std::find_if(cmArrayBegin(valueOptions), cmArrayEnd(valueOptions), + cmStrCmp(optName)) != cmArrayEnd(valueOptions)) { + const std::vector<std::string>::iterator existValueIt(existingIt + 1); + const std::vector<std::string>::const_iterator fileValueIt(fit + 1); + if ((existValueIt != opts.end()) && (fileValueIt != fileOpts.end())) { + *existValueIt = *fileValueIt; + ++fit; + } } } else { - extraOpts.push_back(*it); + extraOpts.push_back(*fit); } } opts.insert(opts.end(), extraOpts.begin(), extraOpts.end()); } -/// @brief Reads the resource files list from from a .qrc file - Qt5 version -/// @return True if the .qrc file was successfully parsed -static bool RccListInputsQt5(cmSourceFile* sf, cmGeneratorTarget const* target, - std::vector<std::string>& depends) -{ - const std::string rccCommand = RccGetExecutable(target, "5"); - if (rccCommand.empty()) { - cmSystemTools::Error("AUTOGEN: error: rcc executable not available\n"); - return false; - } - - bool hasDashDashList = false; - // Read rcc features - { - std::vector<std::string> command; - command.push_back(rccCommand); - command.push_back("--help"); - std::string rccStdOut; - std::string rccStdErr; - int retVal = 0; - bool result = - cmSystemTools::RunSingleCommand(command, &rccStdOut, &rccStdErr, &retVal, - CM_NULLPTR, cmSystemTools::OUTPUT_NONE); - if (result && retVal == 0 && - rccStdOut.find("--list") != std::string::npos) { - hasDashDashList = true; - } - } - // Run rcc list command - std::vector<std::string> command; - command.push_back(rccCommand); - command.push_back(hasDashDashList ? "--list" : "-list"); - - std::string absFile = cmsys::SystemTools::GetRealPath(sf->GetFullPath()); - command.push_back(absFile); - - std::string rccStdOut; - std::string rccStdErr; - int retVal = 0; - bool result = - cmSystemTools::RunSingleCommand(command, &rccStdOut, &rccStdErr, &retVal, - CM_NULLPTR, cmSystemTools::OUTPUT_NONE); - if (!result || retVal) { - std::ostringstream err; - err << "AUTOGEN: error: Rcc list process for " << sf->GetFullPath() - << " failed:\n" - << rccStdOut << "\n" - << rccStdErr << std::endl; - cmSystemTools::Error(err.str().c_str()); - return false; - } - - // Parse rcc list output - { - std::istringstream ostr(rccStdOut); - std::string oline; - while (std::getline(ostr, oline)) { - oline = utilStripCR(oline); - if (!oline.empty()) { - depends.push_back(oline); - } - } - } - - { - std::istringstream estr(rccStdErr); - std::string eline; - while (std::getline(estr, eline)) { - eline = utilStripCR(eline); - if (cmHasLiteralPrefix(eline, "RCC: Error in")) { - static std::string searchString = "Cannot find file '"; - - std::string::size_type pos = eline.find(searchString); - if (pos == std::string::npos) { - std::ostringstream err; - err << "AUTOGEN: error: Rcc lists unparsable output " << eline - << std::endl; - cmSystemTools::Error(err.str().c_str()); - return false; - } - pos += searchString.length(); - std::string::size_type sz = eline.size() - pos - 1; - depends.push_back(eline.substr(pos, sz)); - } - } - } - - return true; -} - -/// @brief Reads the resource files list from from a .qrc file - Qt4 version -/// @return True if the .qrc file was successfully parsed -static bool RccListInputsQt4(cmSourceFile* sf, - std::vector<std::string>& depends) -{ - // Read file into string - std::string qrcContents; - { - std::ostringstream stream; - stream << cmsys::ifstream(sf->GetFullPath().c_str()).rdbuf(); - qrcContents = stream.str(); - } - - cmsys::RegularExpression fileMatchRegex("(<file[^<]+)"); - - size_t offset = 0; - while (fileMatchRegex.find(qrcContents.c_str() + offset)) { - std::string qrcEntry = fileMatchRegex.match(1); - - offset += qrcEntry.size(); - - cmsys::RegularExpression fileReplaceRegex("(^<file[^>]*>)"); - fileReplaceRegex.find(qrcEntry); - std::string tag = fileReplaceRegex.match(1); - - qrcEntry = qrcEntry.substr(tag.size()); - - if (!cmSystemTools::FileIsFullPath(qrcEntry.c_str())) { - qrcEntry = sf->GetLocation().GetDirectory() + "/" + qrcEntry; - } - - depends.push_back(qrcEntry); - } - return true; -} - -/// @brief Reads the resource files list from from a .qrc file -/// @return True if the rcc file was successfully parsed -static bool RccListInputs(const std::string& qtMajorVersion, cmSourceFile* sf, - cmGeneratorTarget const* target, - std::vector<std::string>& depends) -{ - if (qtMajorVersion == "5") { - return RccListInputsQt5(sf, target, depends); - } - return RccListInputsQt4(sf, depends); -} - static void RccSetupAutoTarget(cmGeneratorTarget const* target, const std::string& qtMajorVersion) { - std::string _rcc_files; - const char* sepRccFiles = ""; cmMakefile* makefile = target->Target->GetMakefile(); - - std::vector<cmSourceFile*> srcFiles; - target->GetConfigCommonSourceFiles(srcFiles); - - std::string qrcInputs; - const char* qrcInputsSep = ""; - - std::string rccFileFiles; - std::string rccFileOptions; - const char* optionSep = ""; - const bool qtMajorVersion5 = (qtMajorVersion == "5"); - - std::vector<std::string> rccOptions; + const std::string rccCommand = RccGetExecutable(target, qtMajorVersion); + std::vector<std::string> _rcc_files; + std::vector<std::string> _rcc_inputs; + std::vector<std::string> rccFileFiles; + std::vector<std::string> rccFileOptions; + std::vector<std::string> rccOptionsTarget; if (const char* opts = target->GetProperty("AUTORCC_OPTIONS")) { - cmSystemTools::ExpandListArgument(opts, rccOptions); + cmSystemTools::ExpandListArgument(opts, rccOptionsTarget); } + std::vector<cmSourceFile*> srcFiles; + target->GetConfigCommonSourceFiles(srcFiles); for (std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin(); fileIt != srcFiles.end(); ++fileIt) { cmSourceFile* sf = *fileIt; - std::string ext = sf->GetExtension(); - if (ext == "qrc") { - std::string absFile = cmsys::SystemTools::GetRealPath(sf->GetFullPath()); - const bool skip = - cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOGEN")) || - cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC")); - - if (!skip) { - _rcc_files += sepRccFiles; - _rcc_files += absFile; - sepRccFiles = ";"; - + if ((sf->GetExtension() == "qrc") && + !PropertyEnabled(sf, "SKIP_AUTOGEN") && + !PropertyEnabled(sf, "SKIP_AUTORCC")) { + const std::string absFile = + cmsys::SystemTools::GetRealPath(sf->GetFullPath()); + // qrc file + _rcc_files.push_back(absFile); + // qrc file entries + { + std::string entriesList = "{"; + // Read input file list only for non generated .qrc files. + if (!PropertyEnabled(sf, "GENERATED")) { + std::string error; + std::vector<std::string> files; + if (cmQtAutoGeneratorCommon::RccListInputs( + qtMajorVersion, rccCommand, absFile, files, &error)) { + entriesList += cmJoin(files, cmQtAutoGeneratorCommon::listSep); + } else { + cmSystemTools::Error(error.c_str()); + } + } + entriesList += "}"; + _rcc_inputs.push_back(entriesList); + } + // rcc options for this qrc file + { + // Merged target and file options + std::vector<std::string> rccOptions(rccOptionsTarget); if (const char* prop = sf->GetProperty("AUTORCC_OPTIONS")) { std::vector<std::string> optsVec; cmSystemTools::ExpandListArgument(prop, optsVec); RccMergeOptions(rccOptions, optsVec, qtMajorVersion5); } - + // Only store non empty options lists if (!rccOptions.empty()) { - rccFileFiles += optionSep; - rccFileFiles += absFile; - rccFileOptions += optionSep; - } - const char* listSep = ""; - for (std::vector<std::string>::const_iterator it = rccOptions.begin(); - it != rccOptions.end(); ++it) { - rccFileOptions += listSep; - rccFileOptions += *it; - listSep = "@list_sep@"; - } - optionSep = ";"; - - std::string entriesList; - if (!cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED"))) { - std::vector<std::string> depends; - if (RccListInputs(qtMajorVersion, sf, target, depends)) { - entriesList = cmJoin(depends, "@list_sep@"); - } else { - return; - } + rccFileFiles.push_back(absFile); + rccFileOptions.push_back( + cmJoin(rccOptions, cmQtAutoGeneratorCommon::listSep)); } - qrcInputs += qrcInputsSep; - qrcInputs += entriesList; - qrcInputsSep = ";"; } } } - makefile->AddDefinition( - "_rcc_inputs", cmOutputConverter::EscapeForCMake(qrcInputs).c_str()); - makefile->AddDefinition( - "_rcc_files", cmOutputConverter::EscapeForCMake(_rcc_files).c_str()); - makefile->AddDefinition( - "_rcc_options_files", - cmOutputConverter::EscapeForCMake(rccFileFiles).c_str()); - makefile->AddDefinition( - "_rcc_options_options", - cmOutputConverter::EscapeForCMake(rccFileOptions).c_str()); - makefile->AddDefinition("_qt_rcc_executable", - RccGetExecutable(target, qtMajorVersion).c_str()); + + AddDefinitionEscaped(makefile, "_qt_rcc_executable", rccCommand); + AddDefinitionEscaped(makefile, "_rcc_files", _rcc_files); + AddDefinitionEscaped(makefile, "_rcc_inputs", _rcc_inputs); + AddDefinitionEscaped(makefile, "_rcc_options_files", rccFileFiles); + AddDefinitionEscaped(makefile, "_rcc_options_options", rccFileOptions); } void cmQtAutoGeneratorInitializer::InitializeAutogenSources( @@ -653,11 +623,14 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenSources( { if (target->GetPropertyAsBool("AUTOMOC")) { cmMakefile* makefile = target->Target->GetMakefile(); - const std::string mocCppFile = - GetAutogenTargetBuildDir(target) + "moc_compilation.cpp"; - cmSourceFile* gf = makefile->GetOrCreateSource(mocCppFile, true); - gf->SetProperty("SKIP_AUTOGEN", "On"); + std::string mocCppFile = GetAutogenTargetBuildDir(target); + mocCppFile += "moc_compilation.cpp"; + { + cmSourceFile* gFile = makefile->GetOrCreateSource(mocCppFile, true); + gFile->SetProperty("SKIP_AUTOGEN", "On"); + } target->AddSource(mocCppFile); + AddToSourceGroup(makefile, mocCppFile, cmQtAutoGeneratorCommon::MOC); } } @@ -667,12 +640,17 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget( cmMakefile* makefile = target->Target->GetMakefile(); // Create a custom target for running generators at buildtime + const bool mocEnabled = target->GetPropertyAsBool("AUTOMOC"); + const bool uicEnabled = target->GetPropertyAsBool("AUTOUIC"); + const bool rccEnabled = target->GetPropertyAsBool("AUTORCC"); const std::string autogenTargetName = GetAutogenTargetName(target); const std::string autogenBuildDir = GetAutogenTargetBuildDir(target); const std::string workingDirectory = cmSystemTools::CollapseFullPath("", makefile->GetCurrentBinaryDirectory()); const std::string qtMajorVersion = GetQtMajorVersion(target); - std::vector<std::string> autogenOutputFiles; + const std::string rccCommand = RccGetExecutable(target, qtMajorVersion); + std::vector<std::string> autogenDepends; + std::vector<std::string> autogenProvides; // Remove old settings on cleanup { @@ -682,32 +660,6 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget( false); } - // Create autogen target build directory and add it to the clean files - cmSystemTools::MakeDirectory(autogenBuildDir); - makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", - autogenBuildDir.c_str(), false); - - if (target->GetPropertyAsBool("AUTOMOC") || - target->GetPropertyAsBool("AUTOUIC")) { - // Create autogen target includes directory and - // add it to the origin target INCLUDE_DIRECTORIES - const std::string incsDir = autogenBuildDir + "include"; - cmSystemTools::MakeDirectory(incsDir); - target->AddIncludeDirectory(incsDir, true); - } - - if (target->GetPropertyAsBool("AUTOMOC")) { - // Register moc compilation file as generated - autogenOutputFiles.push_back(autogenBuildDir + "moc_compilation.cpp"); - } - - // Initialize autogen target dependencies - std::vector<std::string> depends; - if (const char* autogenDepends = - target->GetProperty("AUTOGEN_TARGET_DEPENDS")) { - cmSystemTools::ExpandListArgument(autogenDepends, depends); - } - // Compose command lines cmCustomCommandLines commandLines; { @@ -724,13 +676,13 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget( std::string autogenComment; { std::vector<std::string> toolNames; - if (target->GetPropertyAsBool("AUTOMOC")) { + if (mocEnabled) { toolNames.push_back("MOC"); } - if (target->GetPropertyAsBool("AUTOUIC")) { + if (uicEnabled) { toolNames.push_back("UIC"); } - if (target->GetPropertyAsBool("AUTORCC")) { + if (rccEnabled) { toolNames.push_back("RCC"); } @@ -746,76 +698,132 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget( autogenComment = "Automatic " + tools + " for target " + target->GetName(); } + // Create autogen target build directory and add it to the clean files + cmSystemTools::MakeDirectory(autogenBuildDir); + makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", + autogenBuildDir.c_str(), false); + + // Create autogen target includes directory and + // add it to the origin target INCLUDE_DIRECTORIES + if (mocEnabled || uicEnabled) { + const std::string incsDir = autogenBuildDir + "include"; + cmSystemTools::MakeDirectory(incsDir); + target->AddIncludeDirectory(incsDir, true); + } + + // Register moc compilation file as generated + if (mocEnabled) { + autogenProvides.push_back(autogenBuildDir + "moc_compilation.cpp"); + } + #if defined(_WIN32) && !defined(__CYGWIN__) bool usePRE_BUILD = false; cmGlobalGenerator* gg = lg->GetGlobalGenerator(); if (gg->GetName().find("Visual Studio") != std::string::npos) { cmGlobalVisualStudioGenerator* vsgg = static_cast<cmGlobalVisualStudioGenerator*>(gg); - // Under VS >= 7 use a PRE_BUILD event instead of a separate target to + // Under VS use a PRE_BUILD event instead of a separate target to // reduce the number of targets loaded into the IDE. // This also works around a VS 11 bug that may skip updating the target: // https://connect.microsoft.com/VisualStudio/feedback/details/769495 - usePRE_BUILD = vsgg->GetVersion() >= cmGlobalVisualStudioGenerator::VS7; - if (usePRE_BUILD) { - // If the autogen target depends on an other target - // don't use PRE_BUILD - for (std::vector<std::string>::iterator it = depends.begin(); - it != depends.end(); ++it) { - if (!makefile->FindTargetToUse(it->c_str())) { - usePRE_BUILD = false; - break; - } - } - } + usePRE_BUILD = true; } #endif - if (target->GetPropertyAsBool("AUTORCC")) { + // Initialize autogen target dependencies + if (const char* deps = target->GetProperty("AUTOGEN_TARGET_DEPENDS")) { + cmSystemTools::ExpandListArgument(deps, autogenDepends); + } + // Add link library targets to the autogen dependencies + { + const cmTarget::LinkLibraryVectorType& libVec = + target->Target->GetOriginalLinkLibraries(); + for (cmTarget::LinkLibraryVectorType::const_iterator it = libVec.begin(); + it != libVec.end(); ++it) { + const std::string& libName = it->first; + if (makefile->FindTargetToUse(libName) != CM_NULLPTR) { + autogenDepends.push_back(libName); + } + } + } + { cmFilePathChecksum fpathCheckSum(makefile); + // Iterate over all source files std::vector<cmSourceFile*> srcFiles; target->GetConfigCommonSourceFiles(srcFiles); for (std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin(); fileIt != srcFiles.end(); ++fileIt) { cmSourceFile* sf = *fileIt; - if (sf->GetExtension() == "qrc" && - !cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOGEN")) && - !cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC"))) { - { + if (!PropertyEnabled(sf, "SKIP_AUTOGEN")) { + const std::string ext = sf->GetExtension(); + // Add generated file that will be scanned by moc or uic to + // the dependencies + if (mocEnabled || uicEnabled) { + const cmSystemTools::FileFormat fileType = + cmSystemTools::GetFileFormat(ext.c_str()); + if ((fileType == cmSystemTools::CXX_FILE_FORMAT) || + (fileType == cmSystemTools::HEADER_FILE_FORMAT)) { + if (PropertyEnabled(sf, "GENERATED")) { + if ((mocEnabled && !PropertyEnabled(sf, "SKIP_AUTOMOC")) || + (uicEnabled && !PropertyEnabled(sf, "SKIP_AUTOUIC"))) { + autogenDepends.push_back( + cmsys::SystemTools::GetRealPath(sf->GetFullPath())); +#if defined(_WIN32) && !defined(__CYGWIN__) + // Cannot use PRE_BUILD with generated files + usePRE_BUILD = false; +#endif + } + } + } + } + // Process rcc enabled files + if (rccEnabled && (ext == "qrc") && + !PropertyEnabled(sf, "SKIP_AUTORCC")) { const std::string absFile = cmsys::SystemTools::GetRealPath(sf->GetFullPath()); - // Run cmake again when .qrc file changes - makefile->AddCMakeDependFile(absFile); - - std::string rccOutputFile = autogenBuildDir; - rccOutputFile += fpathCheckSum.getPart(absFile); - rccOutputFile += "/qrc_"; - rccOutputFile += - cmsys::SystemTools::GetFilenameWithoutLastExtension(absFile); - rccOutputFile += ".cpp"; - - // Add rcc output file to origin target sources - cmSourceFile* gf = makefile->GetOrCreateSource(rccOutputFile, true); - gf->SetProperty("SKIP_AUTOGEN", "On"); - target->AddSource(rccOutputFile); - // Register rcc output file as generated - autogenOutputFiles.push_back(rccOutputFile); - } - if (lg->GetGlobalGenerator()->GetName() == "Ninja" -#if defined(_WIN32) && !defined(__CYGWIN__) - || usePRE_BUILD -#endif - ) { - if (!cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED"))) { - RccListInputs(qtMajorVersion, sf, target, depends); + // Compose rcc output file name + { + std::string rccOut = autogenBuildDir; + rccOut += fpathCheckSum.getPart(absFile); + rccOut += "/qrc_"; + rccOut += + cmsys::SystemTools::GetFilenameWithoutLastExtension(absFile); + rccOut += ".cpp"; + + // Register rcc output file as generated + autogenProvides.push_back(rccOut); + + // Add rcc output file to origin target sources + { + cmSourceFile* gFile = makefile->GetOrCreateSource(rccOut, true); + gFile->SetProperty("SKIP_AUTOGEN", "On"); + } + target->AddSource(rccOut); + AddToSourceGroup(makefile, rccOut, cmQtAutoGeneratorCommon::RCC); + } + + if (PropertyEnabled(sf, "GENERATED")) { + // Add generated qrc file to the dependencies + autogenDepends.push_back(absFile); + } else { + // Run cmake again when .qrc file changes + makefile->AddCMakeDependFile(absFile); + + // Add the qrc input files to the dependencies + std::string error; + if (!cmQtAutoGeneratorCommon::RccListInputs( + qtMajorVersion, rccCommand, absFile, autogenDepends, + &error)) { + cmSystemTools::Error(error.c_str()); + } + } #if defined(_WIN32) && !defined(__CYGWIN__) - // Cannot use PRE_BUILD because the resource files themselves - // may not be sources within the target so VS may not know the - // target needs to re-build at all. - usePRE_BUILD = false; + // Cannot use PRE_BUILD because the resource files themselves + // may not be sources within the target so VS may not know the + // target needs to re-build at all. + usePRE_BUILD = false; #endif - } } } } @@ -823,12 +831,21 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget( #if defined(_WIN32) && !defined(__CYGWIN__) if (usePRE_BUILD) { + // If the autogen target depends on an other target don't use PRE_BUILD + for (std::vector<std::string>::iterator it = autogenDepends.begin(); + it != autogenDepends.end(); ++it) { + if (makefile->FindTargetToUse(*it) != CM_NULLPTR) { + usePRE_BUILD = false; + break; + } + } + } + if (usePRE_BUILD) { // Add the pre-build command directly to bypass the OBJECT_LIBRARY // rejection in cmMakefile::AddCustomCommandToTarget because we know // PRE_BUILD will work for an OBJECT_LIBRARY in this specific case. std::vector<std::string> no_output; - std::vector<std::string> no_byproducts; - cmCustomCommand cc(makefile, no_output, no_byproducts, depends, + cmCustomCommand cc(makefile, no_output, autogenProvides, autogenDepends, commandLines, autogenComment.c_str(), workingDirectory.c_str()); cc.SetEscapeOldStyle(false); @@ -839,7 +856,7 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget( { cmTarget* autogenTarget = makefile->AddUtilityCommand( autogenTargetName, true, workingDirectory.c_str(), - /*byproducts=*/autogenOutputFiles, depends, commandLines, false, + /*byproducts=*/autogenProvides, autogenDepends, commandLines, false, autogenComment.c_str()); cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg); @@ -872,47 +889,41 @@ void cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget( cmMakefile::ScopePushPop varScope(makefile); static_cast<void>(varScope); - // create a custom target for running generators at buildtime: - const std::string autogenTargetName = GetAutogenTargetName(target); - const std::string qtMajorVersion = GetQtMajorVersion(target); - - makefile->AddDefinition( - "_moc_target_name", - cmOutputConverter::EscapeForCMake(autogenTargetName).c_str()); - makefile->AddDefinition( - "_origin_target_name", - cmOutputConverter::EscapeForCMake(target->GetName()).c_str()); - makefile->AddDefinition("_target_qt_version", qtMajorVersion.c_str()); - - std::vector<std::string> mocUicSources; - std::vector<std::string> mocUicHeaders; - std::vector<std::string> skipMoc; - std::vector<std::string> skipUic; std::map<std::string, std::string> configMocIncludes; std::map<std::string, std::string> configMocDefines; std::map<std::string, std::string> configUicOptions; + { + const bool mocEnabled = target->GetPropertyAsBool("AUTOMOC"); + const bool uicEnabled = target->GetPropertyAsBool("AUTOUIC"); + const bool rccEnabled = target->GetPropertyAsBool("AUTORCC"); + const std::string autogenTargetName = GetAutogenTargetName(target); + const std::string qtMajorVersion = GetQtMajorVersion(target); + + std::vector<std::string> _sources; + std::vector<std::string> _headers; + + if (mocEnabled || uicEnabled || rccEnabled) { + std::vector<std::string> mocSkipList; + std::vector<std::string> uicSkipList; + AcquireScanFiles(target, _sources, _headers, mocSkipList, uicSkipList); + if (mocEnabled) { + MocSetupAutoTarget(target, autogenTargetName, qtMajorVersion, + mocSkipList, configMocIncludes, configMocDefines); + } + if (uicEnabled) { + UicSetupAutoTarget(target, qtMajorVersion, uicSkipList, + configUicOptions); + } + if (rccEnabled) { + RccSetupAutoTarget(target, qtMajorVersion); + } + } - if (target->GetPropertyAsBool("AUTOMOC") || - target->GetPropertyAsBool("AUTOUIC") || - target->GetPropertyAsBool("AUTORCC")) { - SetupSourceFiles(target, mocUicSources, mocUicHeaders, skipMoc, skipUic); - } - makefile->AddDefinition( - "_moc_uic_sources", - cmOutputConverter::EscapeForCMake(cmJoin(mocUicSources, ";")).c_str()); - makefile->AddDefinition( - "_moc_uic_headers", - cmOutputConverter::EscapeForCMake(cmJoin(mocUicHeaders, ";")).c_str()); - - if (target->GetPropertyAsBool("AUTOMOC")) { - MocSetupAutoTarget(target, autogenTargetName, skipMoc, configMocIncludes, - configMocDefines); - } - if (target->GetPropertyAsBool("AUTOUIC")) { - UicSetupAutoTarget(target, skipUic, configUicOptions); - } - if (target->GetPropertyAsBool("AUTORCC")) { - RccSetupAutoTarget(target, qtMajorVersion); + AddDefinitionEscaped(makefile, "_autogen_target_name", autogenTargetName); + AddDefinitionEscaped(makefile, "_origin_target_name", target->GetName()); + AddDefinitionEscaped(makefile, "_qt_version_major", qtMajorVersion); + AddDefinitionEscaped(makefile, "_sources", _sources); + AddDefinitionEscaped(makefile, "_headers", _headers); } // Generate config file @@ -924,7 +935,7 @@ void cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget( makefile->ConfigureFile(inputFile.c_str(), outputFile.c_str(), false, true, false); - // Append custom definitions to config file + // Append custom config definitions to info file if (!configMocDefines.empty() || !configMocIncludes.empty() || !configUicOptions.empty()) { @@ -946,33 +957,34 @@ void cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget( error += outputFile; error += " for writing."; cmSystemTools::Error(error.c_str()); - return; - } - if (!configMocDefines.empty()) { - for (std::map<std::string, std::string>::iterator - it = configMocDefines.begin(), - end = configMocDefines.end(); - it != end; ++it) { - infoFile << "set(AM_MOC_COMPILE_DEFINITIONS_" << it->first << " " - << it->second << ")\n"; + } else { + infoFile << "# Configuration specific options\n"; + if (!configMocDefines.empty()) { + for (std::map<std::string, std::string>::iterator + it = configMocDefines.begin(), + end = configMocDefines.end(); + it != end; ++it) { + infoFile << "set(AM_MOC_DEFINITIONS_" << it->first << " " + << it->second << ")\n"; + } } - } - if (!configMocIncludes.empty()) { - for (std::map<std::string, std::string>::iterator - it = configMocIncludes.begin(), - end = configMocIncludes.end(); - it != end; ++it) { - infoFile << "set(AM_MOC_INCLUDES_" << it->first << " " << it->second - << ")\n"; + if (!configMocIncludes.empty()) { + for (std::map<std::string, std::string>::iterator + it = configMocIncludes.begin(), + end = configMocIncludes.end(); + it != end; ++it) { + infoFile << "set(AM_MOC_INCLUDES_" << it->first << " " << it->second + << ")\n"; + } } - } - if (!configUicOptions.empty()) { - for (std::map<std::string, std::string>::iterator - it = configUicOptions.begin(), - end = configUicOptions.end(); - it != end; ++it) { - infoFile << "set(AM_UIC_TARGET_OPTIONS_" << it->first << " " - << it->second << ")\n"; + if (!configUicOptions.empty()) { + for (std::map<std::string, std::string>::iterator + it = configUicOptions.begin(), + end = configUicOptions.end(); + it != end; ++it) { + infoFile << "set(AM_UIC_TARGET_OPTIONS_" << it->first << " " + << it->second << ")\n"; + } } } } diff --git a/Source/cmQtAutoGeneratorInitializer.h b/Source/cmQtAutoGeneratorInitializer.h index 26f2c8e..ca806f5 100644 --- a/Source/cmQtAutoGeneratorInitializer.h +++ b/Source/cmQtAutoGeneratorInitializer.h @@ -3,7 +3,7 @@ #ifndef cmQtAutoGeneratorInitializer_h #define cmQtAutoGeneratorInitializer_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep class cmGeneratorTarget; class cmLocalGenerator; diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 1d6972b..eec1fc6 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -1,19 +1,22 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmQtAutoGenerators.h" +#include "cmQtAutoGeneratorCommon.h" +#include "cmConfigure.h" +#include "cmsys/FStream.hxx" +#include "cmsys/Terminal.h" #include <algorithm> #include <assert.h> -#include <cmConfigure.h> -#include <cmsys/FStream.hxx> -#include <cmsys/Terminal.h> -#include <iostream> +#include <list> #include <sstream> #include <stdlib.h> #include <string.h> #include <utility> #include "cmAlgorithms.h" +#include "cmCryptoHash.h" +#include "cmFilePathChecksum.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" #include "cmOutputConverter.h" @@ -29,70 +32,95 @@ // -- Static variables -static const char* MocOldSettingsKey = "AM_MOC_OLD_SETTINGS"; -static const char* UicOldSettingsKey = "AM_UIC_OLD_SETTINGS"; -static const char* RccOldSettingsKey = "AM_RCC_OLD_SETTINGS"; +static const char* SettingsKeyMoc = "AM_MOC_SETTINGS_HASH"; +static const char* SettingsKeyUic = "AM_UIC_SETTINGS_HASH"; +static const char* SettingsKeyRcc = "AM_RCC_SETTINGS_HASH"; // -- Static functions -static std::string GetConfigDefinition(cmMakefile* makefile, - const std::string& key, - const std::string& config) +inline static std::string Quoted(const std::string& text) { - std::string keyConf = key; - if (!config.empty()) { - keyConf += "_"; - keyConf += config; - } - const char* valueConf = makefile->GetDefinition(keyConf); - if (valueConf != CM_NULLPTR) { - return valueConf; + return cmQtAutoGeneratorCommon::Quoted(text); +} + +static std::string QuotedCommand(const std::vector<std::string>& command) +{ + std::string res; + for (std::vector<std::string>::const_iterator cit = command.begin(); + cit != command.end(); ++cit) { + if (!res.empty()) { + res.push_back(' '); + } + const std::string cesc = Quoted(*cit); + if (cit->empty() || (cesc.size() > (cit->size() + 2)) || + (cesc.find(' ') != std::string::npos)) { + res += cesc; + } else { + res += *cit; + } } - return makefile->GetSafeDefinition(key); + return res; } -static std::string OldSettingsFile(const std::string& targetDirectory) +static void InfoGet(cmMakefile* makefile, const char* key, std::string& value) { - std::string filename(cmSystemTools::CollapseFullPath(targetDirectory)); - cmSystemTools::ConvertToUnixSlashes(filename); - filename += "/AutogenOldSettings.cmake"; - return filename; + value = makefile->GetSafeDefinition(key); } -static std::string FindMatchingHeader( - const std::string& absPath, const std::string& mocSubDir, - const std::string& basename, - const std::vector<std::string>& headerExtensions) +static void InfoGet(cmMakefile* makefile, const char* key, bool& value) { - std::string header; - for (std::vector<std::string>::const_iterator ext = headerExtensions.begin(); - ext != headerExtensions.end(); ++ext) { - std::string sourceFilePath = absPath + basename + "." + (*ext); - if (cmsys::SystemTools::FileExists(sourceFilePath.c_str())) { - header = sourceFilePath; - break; - } - // Try subdirectory instead - if (!mocSubDir.empty()) { - sourceFilePath = mocSubDir + basename + "." + (*ext); - if (cmsys::SystemTools::FileExists(sourceFilePath.c_str())) { - header = sourceFilePath; - break; - } + value = makefile->IsOn(key); +} + +static void InfoGet(cmMakefile* makefile, const char* key, + std::vector<std::string>& list) +{ + cmSystemTools::ExpandListArgument(makefile->GetSafeDefinition(key), list); +} + +static void InfoGet(cmMakefile* makefile, const char* key, + const std::string& config, std::vector<std::string>& list) +{ + const char* valueConf = CM_NULLPTR; + { + std::string keyConf = key; + if (!config.empty()) { + keyConf += "_"; + keyConf += config; } + valueConf = makefile->GetDefinition(keyConf); + } + if (valueConf == CM_NULLPTR) { + valueConf = makefile->GetSafeDefinition(key); } + cmSystemTools::ExpandListArgument(valueConf, list); +} - return header; +inline static bool SettingsMatch(cmMakefile* makefile, const char* key, + const std::string& value) +{ + return (value == makefile->GetSafeDefinition(key)); } -static std::string ExtractSubDir(const std::string& absPath, - const std::string& currentMoc) +static void SettingAppend(std::string& str, const char* key, + const std::string& value) { - std::string subDir; - if (currentMoc.find_first_of('/') != std::string::npos) { - subDir = absPath + cmsys::SystemTools::GetFilenamePath(currentMoc) + '/'; + if (!value.empty()) { + str += "set("; + str += key; + str += " "; + str += cmOutputConverter::EscapeForCMake(value); + str += ")\n"; } - return subDir; +} + +static std::string SubDirPrefix(const std::string& fileName) +{ + std::string res(cmsys::SystemTools::GetFilenamePath(fileName)); + if (!res.empty()) { + res += '/'; + } + return res; } static bool FileNameIsUnique(const std::string& filePath, @@ -112,13 +140,19 @@ static bool FileNameIsUnique(const std::string& filePath, return true; } -static std::string ReadAll(const std::string& filename) +static bool ReadAll(std::string& content, const std::string& filename) { - cmsys::ifstream file(filename.c_str()); - std::ostringstream stream; - stream << file.rdbuf(); - file.close(); - return stream.str(); + bool success = false; + { + cmsys::ifstream ifs(filename.c_str()); + if (ifs) { + std::ostringstream osst; + osst << ifs.rdbuf(); + content = osst.str(); + success = true; + } + } + return success; } /** @@ -140,13 +174,19 @@ static bool ListContains(const std::vector<std::string>& list, return (std::find(list.begin(), list.end(), entry) != list.end()); } -static std::string JoinOptions(const std::map<std::string, std::string>& opts) +static std::string JoinOptionsList(const std::vector<std::string>& opts) +{ + return cmOutputConverter::EscapeForCMake(cmJoin(opts, ";")); +} + +static std::string JoinOptionsMap( + const std::map<std::string, std::string>& opts) { std::string result; for (std::map<std::string, std::string>::const_iterator it = opts.begin(); it != opts.end(); ++it) { if (it != opts.begin()) { - result += "%%%"; + result += cmQtAutoGeneratorCommon::listSep; } result += it->first; result += "==="; @@ -211,12 +251,13 @@ static void UicMergeOptions(std::vector<std::string>& opts, cmQtAutoGenerators::cmQtAutoGenerators() : Verbose(cmsys::SystemTools::HasEnv("VERBOSE")) , ColorOutput(true) - , RunMocFailed(false) - , RunUicFailed(false) - , RunRccFailed(false) - , GenerateMocAll(false) - , GenerateUicAll(false) - , GenerateRccAll(false) + , MocSettingsChanged(false) + , MocPredefsChanged(false) + , MocRunFailed(false) + , UicSettingsChanged(false) + , UicRunFailed(false) + , RccSettingsChanged(false) + , RccRunFailed(false) { std::string colorEnv; @@ -229,13 +270,16 @@ cmQtAutoGenerators::cmQtAutoGenerators() } } + this->MocMacroFilters[0].first = "Q_OBJECT"; + this->MocMacroFilters[0].second.compile("[\n][ \t]*Q_OBJECT[^a-zA-Z0-9_]"); + this->MocMacroFilters[1].first = "Q_GADGET"; + this->MocMacroFilters[1].second.compile("[\n][ \t]*Q_GADGET[^a-zA-Z0-9_]"); + // Precompile regular expressions - this->RegExpQObject.compile("[\n][ \t]*Q_OBJECT[^a-zA-Z0-9_]"); - this->RegExpQGadget.compile("[\n][ \t]*Q_GADGET[^a-zA-Z0-9_]"); - this->RegExpMocInclude.compile( + this->MocRegExpInclude.compile( "[\n][ \t]*#[ \t]*include[ \t]+" "[\"<](([^ \">]+/)?moc_[^ \">/]+\\.cpp|[^ \">]+\\.moc)[\">]"); - this->RegExpUicInclude.compile("[\n][ \t]*#[ \t]*include[ \t]+" + this->UicRegExpInclude.compile("[\n][ \t]*#[ \t]*include[ \t]+" "[\"<](([^ \">]+/)?ui_[^ \">/]+\\.h)[\">]"); } @@ -255,23 +299,46 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory, CM_AUTO_PTR<cmMakefile> mf(new cmMakefile(&gg, snapshot)); gg.SetCurrentMakefile(mf.get()); - if (!this->ReadAutogenInfoFile(mf.get(), targetDirectory, config)) { - return false; - } - // Read old settings - this->OldSettingsReadFile(mf.get(), targetDirectory); - // Init and run - this->Init(); - if (this->QtMajorVersion == "4" || this->QtMajorVersion == "5") { - if (!this->RunAutogen(mf.get())) { - return false; + bool success = false; + if (this->ReadAutogenInfoFile(mf.get(), targetDirectory, config)) { + // Read old settings + this->SettingsFileRead(mf.get()); + // Init and run + this->Init(mf.get()); + if (this->RunAutogen()) { + // Write current settings + if (this->SettingsFileWrite()) { + success = true; + } } } - // Write latest settings - if (!this->OldSettingsWriteFile(targetDirectory)) { - return false; + return success; +} + +bool cmQtAutoGenerators::MocDependFilterPush(const std::string& key, + const std::string& regExp) +{ + bool success = false; + if (!key.empty()) { + if (!regExp.empty()) { + MocDependFilter filter; + filter.key = key; + if (filter.regExp.compile(regExp)) { + this->MocDependFilters.push_back(filter); + success = true; + } else { + this->LogError("AutoMoc: Error in AUTOMOC_DEPEND_FILTERS: Compiling " + "regular expression failed.\nKey: " + + Quoted(key) + "\nExp.: " + Quoted(regExp)); + } + } else { + this->LogError("AutoMoc: Error in AUTOMOC_DEPEND_FILTERS: Regular " + "expression is empty"); + } + } else { + this->LogError("AutoMoc: Error in AUTOMOC_DEPEND_FILTERS: Key is empty"); } - return true; + return success; } bool cmQtAutoGenerators::ReadAutogenInfoFile( @@ -283,395 +350,392 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile( filename += "/AutogenInfo.cmake"; if (!makefile->ReadListFile(filename.c_str())) { - std::ostringstream err; - err << "AutoGen: error processing file: " << filename << std::endl; - this->LogError(err.str()); + this->LogError("AutoGen: Error processing file: " + filename); return false; } + // - Old settings file + { + this->SettingsFile = cmSystemTools::CollapseFullPath(targetDirectory); + cmSystemTools::ConvertToUnixSlashes(this->SettingsFile); + this->SettingsFile += "/AutogenOldSettings.cmake"; + } + // - Target names - this->OriginTargetName = - makefile->GetSafeDefinition("AM_ORIGIN_TARGET_NAME"); - this->AutogenTargetName = makefile->GetSafeDefinition("AM_TARGET_NAME"); - - // - Directories - this->ProjectSourceDir = makefile->GetSafeDefinition("AM_CMAKE_SOURCE_DIR"); - this->ProjectBinaryDir = makefile->GetSafeDefinition("AM_CMAKE_BINARY_DIR"); - this->CurrentSourceDir = - makefile->GetSafeDefinition("AM_CMAKE_CURRENT_SOURCE_DIR"); - this->CurrentBinaryDir = - makefile->GetSafeDefinition("AM_CMAKE_CURRENT_BINARY_DIR"); + InfoGet(makefile, "AM_TARGET_NAME", this->AutogenTargetName); + InfoGet(makefile, "AM_ORIGIN_TARGET_NAME", this->OriginTargetName); + + // - Files and directories + InfoGet(makefile, "AM_CMAKE_SOURCE_DIR", this->ProjectSourceDir); + InfoGet(makefile, "AM_CMAKE_BINARY_DIR", this->ProjectBinaryDir); + InfoGet(makefile, "AM_CMAKE_CURRENT_SOURCE_DIR", this->CurrentSourceDir); + InfoGet(makefile, "AM_CMAKE_CURRENT_BINARY_DIR", this->CurrentBinaryDir); + InfoGet(makefile, "AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE", + this->IncludeProjectDirsBefore); + InfoGet(makefile, "AM_SOURCES", this->Sources); + InfoGet(makefile, "AM_HEADERS", this->Headers); // - Qt environment - this->QtMajorVersion = makefile->GetSafeDefinition("AM_QT_VERSION_MAJOR"); - if (this->QtMajorVersion == "") { - this->QtMajorVersion = - makefile->GetSafeDefinition("AM_Qt5Core_VERSION_MAJOR"); + InfoGet(makefile, "AM_QT_VERSION_MAJOR", this->QtMajorVersion); + if (this->QtMajorVersion.empty()) { + InfoGet(makefile, "AM_Qt5Core_VERSION_MAJOR", this->QtMajorVersion); + } + InfoGet(makefile, "AM_QT_MOC_EXECUTABLE", this->MocExecutable); + InfoGet(makefile, "AM_QT_UIC_EXECUTABLE", this->UicExecutable); + InfoGet(makefile, "AM_QT_RCC_EXECUTABLE", this->RccExecutable); + + InfoGet(makefile, "AM_MOC_PREDEFS_CMD", this->MocPredefsCmd); + // Check Qt version + if ((this->QtMajorVersion != "4") && (this->QtMajorVersion != "5")) { + this->LogError("AutoGen: Error: Unsupported Qt version: " + + Quoted(this->QtMajorVersion)); + return false; } - this->MocExecutable = makefile->GetSafeDefinition("AM_QT_MOC_EXECUTABLE"); - this->UicExecutable = makefile->GetSafeDefinition("AM_QT_UIC_EXECUTABLE"); - this->RccExecutable = makefile->GetSafeDefinition("AM_QT_RCC_EXECUTABLE"); - - // - File Lists - cmSystemTools::ExpandListArgument(makefile->GetSafeDefinition("AM_SOURCES"), - this->Sources); - cmSystemTools::ExpandListArgument(makefile->GetSafeDefinition("AM_HEADERS"), - this->Headers); // - Moc - cmSystemTools::ExpandListArgument(makefile->GetSafeDefinition("AM_SKIP_MOC"), - this->SkipMoc); - this->MocCompileDefinitionsStr = - GetConfigDefinition(makefile, "AM_MOC_COMPILE_DEFINITIONS", config); - this->MocIncludesStr = - GetConfigDefinition(makefile, "AM_MOC_INCLUDES", config); - this->MocOptionsStr = makefile->GetSafeDefinition("AM_MOC_OPTIONS"); + if (this->MocEnabled()) { + InfoGet(makefile, "AM_MOC_SKIP", this->MocSkipList); + InfoGet(makefile, "AM_MOC_DEFINITIONS", config, this->MocDefinitions); + InfoGet(makefile, "AM_MOC_INCLUDES", config, this->MocIncludePaths); + InfoGet(makefile, "AM_MOC_OPTIONS", this->MocOptions); + InfoGet(makefile, "AM_MOC_RELAXED_MODE", this->MocRelaxedMode); + { + std::vector<std::string> mocDependFilters; + InfoGet(makefile, "AM_MOC_DEPEND_FILTERS", mocDependFilters); + // Insert Q_PLUGIN_METADATA dependency filter + if (this->QtMajorVersion != "4") { + this->MocDependFilterPush("Q_PLUGIN_METADATA", + "[\n][ \t]*Q_PLUGIN_METADATA[ \t]*\\(" + "[^\\)]*FILE[ \t]*\"([^\"]+)\""); + } + // Insert user defined dependency filters + if ((mocDependFilters.size() % 2) == 0) { + for (std::vector<std::string>::const_iterator dit = + mocDependFilters.begin(); + dit != mocDependFilters.end(); dit += 2) { + if (!this->MocDependFilterPush(*dit, *(dit + 1))) { + return false; + } + } + } else { + this->LogError( + "AutoMoc: Error: AUTOMOC_DEPEND_FILTERS list size is not " + "a multiple of 2 in:\n" + + Quoted(filename)); + return false; + } + } + } // - Uic - cmSystemTools::ExpandListArgument(makefile->GetSafeDefinition("AM_SKIP_UIC"), - this->SkipUic); - cmSystemTools::ExpandListArgument( - GetConfigDefinition(makefile, "AM_UIC_TARGET_OPTIONS", config), - this->UicTargetOptions); - { - std::vector<std::string> uicFilesVec; - std::vector<std::string> uicOptionsVec; - cmSystemTools::ExpandListArgument( - makefile->GetSafeDefinition("AM_UIC_OPTIONS_FILES"), uicFilesVec); - cmSystemTools::ExpandListArgument( - makefile->GetSafeDefinition("AM_UIC_OPTIONS_OPTIONS"), uicOptionsVec); - if (uicFilesVec.size() != uicOptionsVec.size()) { - std::ostringstream err; - err << "AutoGen: Error: Uic files/options lists size missmatch in: " - << filename << std::endl; - this->LogError(err.str()); - return false; - } - for (std::vector<std::string>::iterator fileIt = uicFilesVec.begin(), - optionIt = uicOptionsVec.begin(); - fileIt != uicFilesVec.end(); ++fileIt, ++optionIt) { - cmSystemTools::ReplaceString(*optionIt, "@list_sep@", ";"); - this->UicOptions[*fileIt] = *optionIt; + if (this->UicEnabled()) { + InfoGet(makefile, "AM_UIC_SKIP", this->UicSkipList); + InfoGet(makefile, "AM_UIC_SEARCH_PATHS", this->UicSearchPaths); + InfoGet(makefile, "AM_UIC_TARGET_OPTIONS", config, this->UicTargetOptions); + { + std::vector<std::string> uicFilesVec; + std::vector<std::string> uicOptionsVec; + InfoGet(makefile, "AM_UIC_OPTIONS_FILES", uicFilesVec); + InfoGet(makefile, "AM_UIC_OPTIONS_OPTIONS", uicOptionsVec); + // Compare list sizes + if (uicFilesVec.size() == uicOptionsVec.size()) { + for (std::vector<std::string>::iterator + fileIt = uicFilesVec.begin(), + optionIt = uicOptionsVec.begin(); + fileIt != uicFilesVec.end(); ++fileIt, ++optionIt) { + cmSystemTools::ReplaceString(*optionIt, + cmQtAutoGeneratorCommon::listSep, ";"); + this->UicOptions[*fileIt] = *optionIt; + } + } else { + this->LogError( + "AutoGen: Error: Uic files/options lists size missmatch in:\n" + + Quoted(filename)); + return false; + } } } // - Rcc - cmSystemTools::ExpandListArgument( - makefile->GetSafeDefinition("AM_RCC_SOURCES"), this->RccSources); - { - std::vector<std::string> rccFilesVec; - std::vector<std::string> rccOptionsVec; - cmSystemTools::ExpandListArgument( - makefile->GetSafeDefinition("AM_RCC_OPTIONS_FILES"), rccFilesVec); - cmSystemTools::ExpandListArgument( - makefile->GetSafeDefinition("AM_RCC_OPTIONS_OPTIONS"), rccOptionsVec); - if (rccFilesVec.size() != rccOptionsVec.size()) { - std::ostringstream err; - err << "AutoGen: Error: RCC files/options lists size missmatch in: " - << filename << std::endl; - this->LogError(err.str()); - return false; - } - for (std::vector<std::string>::iterator fileIt = rccFilesVec.begin(), - optionIt = rccOptionsVec.begin(); - fileIt != rccFilesVec.end(); ++fileIt, ++optionIt) { - cmSystemTools::ReplaceString(*optionIt, "@list_sep@", ";"); - this->RccOptions[*fileIt] = *optionIt; - } - } - { - std::vector<std::string> rccInputLists; - cmSystemTools::ExpandListArgument( - makefile->GetSafeDefinition("AM_RCC_INPUTS"), rccInputLists); - - // qrc files in the end of the list may have been empty - if (rccInputLists.size() < this->RccSources.size()) { - rccInputLists.resize(this->RccSources.size()); - } - if (this->RccSources.size() != rccInputLists.size()) { - std::ostringstream err; - err << "AutoGen: Error: RCC sources/inputs lists size missmatch in: " - << filename << std::endl; - this->LogError(err.str()); - return false; + if (this->RccEnabled()) { + InfoGet(makefile, "AM_RCC_SOURCES", this->RccSources); + // File options + { + std::vector<std::string> rccFilesVec; + std::vector<std::string> rccOptionsVec; + InfoGet(makefile, "AM_RCC_OPTIONS_FILES", rccFilesVec); + InfoGet(makefile, "AM_RCC_OPTIONS_OPTIONS", rccOptionsVec); + if (rccFilesVec.size() == rccOptionsVec.size()) { + for (std::vector<std::string>::iterator + fileIt = rccFilesVec.begin(), + optionIt = rccOptionsVec.begin(); + fileIt != rccFilesVec.end(); ++fileIt, ++optionIt) { + // Replace item separator + cmSystemTools::ReplaceString(*optionIt, + cmQtAutoGeneratorCommon::listSep, ";"); + this->RccOptions[*fileIt] = *optionIt; + } + } else { + this->LogError( + "AutoGen: Error: RCC files/options lists size missmatch in:\n" + + Quoted(filename)); + return false; + } } - for (std::vector<std::string>::iterator fileIt = this->RccSources.begin(), - inputIt = rccInputLists.begin(); - fileIt != this->RccSources.end(); ++fileIt, ++inputIt) { - cmSystemTools::ReplaceString(*inputIt, "@list_sep@", ";"); - std::vector<std::string> rccInputFiles; - cmSystemTools::ExpandListArgument(*inputIt, rccInputFiles); - this->RccInputs[*fileIt] = rccInputFiles; + // File lists + { + std::vector<std::string> rccInputLists; + InfoGet(makefile, "AM_RCC_INPUTS", rccInputLists); + if (this->RccSources.size() == rccInputLists.size()) { + for (std::vector<std::string>::iterator + fileIt = this->RccSources.begin(), + inputIt = rccInputLists.begin(); + fileIt != this->RccSources.end(); ++fileIt, ++inputIt) { + // Remove braces + *inputIt = inputIt->substr(1, inputIt->size() - 2); + // Replace item separator + cmSystemTools::ReplaceString(*inputIt, + cmQtAutoGeneratorCommon::listSep, ";"); + std::vector<std::string> rccInputFiles; + cmSystemTools::ExpandListArgument(*inputIt, rccInputFiles); + this->RccInputs[*fileIt] = rccInputFiles; + } + } else { + this->LogError( + "AutoGen: Error: RCC sources/inputs lists size missmatch in:\n" + + Quoted(filename)); + return false; + } } } - // - Flags - this->IncludeProjectDirsBefore = - makefile->IsOn("AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE"); - this->MocRelaxedMode = makefile->IsOn("AM_MOC_RELAXED_MODE"); - return true; } -std::string cmQtAutoGenerators::MocSettingsStringCompose() +void cmQtAutoGenerators::SettingsFileRead(cmMakefile* makefile) { - std::string res; - res += this->MocCompileDefinitionsStr; - res += " ~~~ "; - res += this->MocIncludesStr; - res += " ~~~ "; - res += this->MocOptionsStr; - res += " ~~~ "; - res += this->IncludeProjectDirsBefore ? "TRUE" : "FALSE"; - res += " ~~~ "; - return res; -} - -std::string cmQtAutoGenerators::UicSettingsStringCompose() -{ - std::string res; - res += cmJoin(this->UicTargetOptions, "@osep@"); - res += " ~~~ "; - res += JoinOptions(this->UicOptions); - res += " ~~~ "; - return res; -} - -std::string cmQtAutoGenerators::RccSettingsStringCompose() -{ - std::string res; - res += JoinOptions(this->RccOptions); - res += " ~~~ "; - return res; -} - -void cmQtAutoGenerators::OldSettingsReadFile( - cmMakefile* makefile, const std::string& targetDirectory) -{ - if (!this->MocExecutable.empty() || !this->UicExecutable.empty() || - !this->RccExecutable.empty()) { - // Compose current settings strings - this->MocSettingsString = this->MocSettingsStringCompose(); - this->UicSettingsString = this->UicSettingsStringCompose(); - this->RccSettingsString = this->RccSettingsStringCompose(); + // Compose current settings strings + { + cmCryptoHash crypt(cmCryptoHash::AlgoSHA256); + if (this->MocEnabled()) { + std::string str; + str += JoinOptionsList(this->MocDefinitions); + str += " ~~~ "; + str += JoinOptionsList(this->MocIncludePaths); + str += " ~~~ "; + str += JoinOptionsList(this->MocOptions); + str += " ~~~ "; + str += this->IncludeProjectDirsBefore ? "TRUE" : "FALSE"; + str += " ~~~ "; + str += JoinOptionsList(this->MocPredefsCmd); + str += " ~~~ "; + this->SettingsStringMoc = crypt.HashString(str); + } + if (this->UicEnabled()) { + std::string str; + str += JoinOptionsList(this->UicTargetOptions); + str += " ~~~ "; + str += JoinOptionsMap(this->UicOptions); + str += " ~~~ "; + this->SettingsStringUic = crypt.HashString(str); + } + if (this->RccEnabled()) { + std::string str; + str += JoinOptionsMap(this->RccOptions); + str += " ~~~ "; + this->SettingsStringRcc = crypt.HashString(str); + } + } - // Read old settings - const std::string filename = OldSettingsFile(targetDirectory); - if (makefile->ReadListFile(filename.c_str())) { - if (!this->MocExecutable.empty()) { - const std::string sol = makefile->GetSafeDefinition(MocOldSettingsKey); - if (sol != this->MocSettingsString) { - this->GenerateMocAll = true; - } - } - if (!this->UicExecutable.empty()) { - const std::string sol = makefile->GetSafeDefinition(UicOldSettingsKey); - if (sol != this->UicSettingsString) { - this->GenerateUicAll = true; - } - } - if (!this->RccExecutable.empty()) { - const std::string sol = makefile->GetSafeDefinition(RccOldSettingsKey); - if (sol != this->RccSettingsString) { - this->GenerateRccAll = true; - } - } - // In case any setting changed remove the old settings file. - // This triggers a full rebuild on the next run if the current - // build is aborted before writing the current settings in the end. - if (this->GenerateMocAll || this->GenerateUicAll || - this->GenerateRccAll) { - cmSystemTools::RemoveFile(filename); - } - } else { - // If the file could not be read re-generate everythiung. - this->GenerateMocAll = true; - this->GenerateUicAll = true; - this->GenerateRccAll = true; + // Read old settings + if (makefile->ReadListFile(this->SettingsFile.c_str())) { + if (!SettingsMatch(makefile, SettingsKeyMoc, this->SettingsStringMoc)) { + this->MocSettingsChanged = true; + } + if (!SettingsMatch(makefile, SettingsKeyUic, this->SettingsStringUic)) { + this->UicSettingsChanged = true; } + if (!SettingsMatch(makefile, SettingsKeyRcc, this->SettingsStringRcc)) { + this->RccSettingsChanged = true; + } + // In case any setting changed remove the old settings file. + // This triggers a full rebuild on the next run if the current + // build is aborted before writing the current settings in the end. + if (this->AnySettingsChanged()) { + cmSystemTools::RemoveFile(this->SettingsFile); + } + } else { + // If the file could not be read re-generate everythiung. + this->MocSettingsChanged = true; + this->UicSettingsChanged = true; + this->RccSettingsChanged = true; } } -bool cmQtAutoGenerators::OldSettingsWriteFile( - const std::string& targetDirectory) +bool cmQtAutoGenerators::SettingsFileWrite() { bool success = true; // Only write if any setting changed - if (this->GenerateMocAll || this->GenerateUicAll || this->GenerateRccAll) { - const std::string filename = OldSettingsFile(targetDirectory); - cmsys::ofstream outfile; - outfile.open(filename.c_str(), std::ios::trunc); - if (outfile) { - if (!this->MocExecutable.empty()) { - outfile << "set(" << MocOldSettingsKey << " " - << cmOutputConverter::EscapeForCMake(this->MocSettingsString) - << ")\n"; - } - if (!this->UicExecutable.empty()) { - outfile << "set(" << UicOldSettingsKey << " " - << cmOutputConverter::EscapeForCMake(this->UicSettingsString) - << ")\n"; - } - if (!this->RccExecutable.empty()) { - outfile << "set(" << RccOldSettingsKey << " " - << cmOutputConverter::EscapeForCMake(this->RccSettingsString) - << ")\n"; - } - success = outfile.good(); - outfile.close(); - } else { + if (this->AnySettingsChanged()) { + if (this->Verbose) { + this->LogInfo("AutoGen: Writing settings file " + + Quoted(this->SettingsFile)); + } + // Compose settings file content + std::string settings; + SettingAppend(settings, SettingsKeyMoc, this->SettingsStringMoc); + SettingAppend(settings, SettingsKeyUic, this->SettingsStringUic); + SettingAppend(settings, SettingsKeyRcc, this->SettingsStringRcc); + // Write settings file + if (!this->FileWrite("AutoGen", this->SettingsFile, settings)) { + this->LogError("AutoGen: Error: Could not write old settings file " + + Quoted(this->SettingsFile)); + // Remove old settings file to trigger a full rebuild on the next run + cmSystemTools::RemoveFile(this->SettingsFile); success = false; - // Remove old settings file to trigger full rebuild on next run - cmSystemTools::RemoveFile(filename); - { - std::ostringstream err; - err << "AutoGen: Error: Writing old settings file failed: " << filename - << std::endl; - this->LogError(err.str()); - } } } return success; } -void cmQtAutoGenerators::Init() +void cmQtAutoGenerators::Init(cmMakefile* makefile) { this->AutogenBuildSubDir = this->AutogenTargetName; this->AutogenBuildSubDir += "/"; - this->OutMocCppFilenameRel = this->AutogenBuildSubDir; - this->OutMocCppFilenameRel += "moc_compilation.cpp"; + this->MocCppFilenameRel = this->AutogenBuildSubDir; + this->MocCppFilenameRel += "moc_compilation.cpp"; - this->OutMocCppFilenameAbs = - this->CurrentBinaryDir + this->OutMocCppFilenameRel; + this->MocCppFilenameAbs = this->CurrentBinaryDir + this->MocCppFilenameRel; + + // Moc predefs file + if (!this->MocPredefsCmd.empty()) { + this->MocPredefsFileRel = this->AutogenBuildSubDir + "moc_predefs.h"; + this->MocPredefsFileAbs = this->CurrentBinaryDir + this->MocPredefsFileRel; + } // Init file path checksum generator - fpathCheckSum.setupParentDirs(this->CurrentSourceDir, this->CurrentBinaryDir, + FPathChecksum.setupParentDirs(this->CurrentSourceDir, this->CurrentBinaryDir, this->ProjectSourceDir, this->ProjectBinaryDir); - std::vector<std::string> cdefList; - cmSystemTools::ExpandListArgument(this->MocCompileDefinitionsStr, cdefList); - for (std::vector<std::string>::const_iterator it = cdefList.begin(); - it != cdefList.end(); ++it) { - this->MocDefinitions.push_back("-D" + (*it)); - } - - cmSystemTools::ExpandListArgument(this->MocOptionsStr, this->MocOptions); - - std::vector<std::string> incPaths; - cmSystemTools::ExpandListArgument(this->MocIncludesStr, incPaths); - - std::set<std::string> frameworkPaths; - for (std::vector<std::string>::const_iterator it = incPaths.begin(); - it != incPaths.end(); ++it) { - const std::string& path = *it; - this->MocIncludes.push_back("-I" + path); - if (cmHasLiteralSuffix(path, ".framework/Headers")) { - // Go up twice to get to the framework root - std::vector<std::string> pathComponents; - cmsys::SystemTools::SplitPath(path, pathComponents); - std::string frameworkPath = cmsys::SystemTools::JoinPath( - pathComponents.begin(), pathComponents.end() - 2); - frameworkPaths.insert(frameworkPath); - } - } - - for (std::set<std::string>::const_iterator it = frameworkPaths.begin(); - it != frameworkPaths.end(); ++it) { - this->MocIncludes.push_back("-F"); - this->MocIncludes.push_back(*it); - } + // Acquire header extensions + this->HeaderExtensions = makefile->GetCMakeInstance()->GetHeaderExtensions(); + // Sort include directories on demand if (this->IncludeProjectDirsBefore) { - const std::string binDir = "-I" + this->ProjectBinaryDir; - const std::string srcDir = "-I" + this->ProjectSourceDir; - - std::list<std::string> sortedMocIncludes; - std::list<std::string>::iterator it = this->MocIncludes.begin(); - while (it != this->MocIncludes.end()) { - if (cmsys::SystemTools::StringStartsWith(*it, binDir.c_str())) { - sortedMocIncludes.push_back(*it); - it = this->MocIncludes.erase(it); - } else { - ++it; + // Move strings to temporary list + std::list<std::string> includes; + includes.insert(includes.end(), this->MocIncludePaths.begin(), + this->MocIncludePaths.end()); + this->MocIncludePaths.clear(); + this->MocIncludePaths.reserve(includes.size()); + // Append project directories only + { + const char* movePaths[2] = { this->ProjectBinaryDir.c_str(), + this->ProjectSourceDir.c_str() }; + for (const char* const* mpit = cmArrayBegin(movePaths); + mpit != cmArrayEnd(movePaths); ++mpit) { + std::list<std::string>::iterator it = includes.begin(); + while (it != includes.end()) { + const std::string& path = *it; + if (cmsys::SystemTools::StringStartsWith(path, *mpit)) { + this->MocIncludePaths.push_back(path); + it = includes.erase(it); + } else { + ++it; + } + } } } - it = this->MocIncludes.begin(); - while (it != this->MocIncludes.end()) { - if (cmsys::SystemTools::StringStartsWith(*it, srcDir.c_str())) { - sortedMocIncludes.push_back(*it); - it = this->MocIncludes.erase(it); - } else { - ++it; + // Append remaining directories + this->MocIncludePaths.insert(this->MocIncludePaths.end(), includes.begin(), + includes.end()); + } + // Compose moc includes list + { + std::set<std::string> frameworkPaths; + for (std::vector<std::string>::const_iterator it = + this->MocIncludePaths.begin(); + it != this->MocIncludePaths.end(); ++it) { + const std::string& path = *it; + this->MocIncludes.push_back("-I" + path); + // Extract framework path + if (cmHasLiteralSuffix(path, ".framework/Headers")) { + // Go up twice to get to the framework root + std::vector<std::string> pathComponents; + cmsys::SystemTools::SplitPath(path, pathComponents); + std::string frameworkPath = cmsys::SystemTools::JoinPath( + pathComponents.begin(), pathComponents.end() - 2); + frameworkPaths.insert(frameworkPath); } } - sortedMocIncludes.insert(sortedMocIncludes.end(), - this->MocIncludes.begin(), - this->MocIncludes.end()); - this->MocIncludes = sortedMocIncludes; + // Append framework includes + for (std::set<std::string>::const_iterator it = frameworkPaths.begin(); + it != frameworkPaths.end(); ++it) { + this->MocIncludes.push_back("-F"); + this->MocIncludes.push_back(*it); + } } } -bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile) +bool cmQtAutoGenerators::RunAutogen() { // the program goes through all .cpp files to see which moc files are // included. It is not really interesting how the moc file is named, but // what file the moc is created from. Once a moc is included the same moc // may not be included in the moc_compilation.cpp file anymore. OTOH if // there's a header containing Q_OBJECT where no corresponding moc file - // is included anywhere a moc_<filename>.cpp file is created and included in - // the moc_compilation.cpp file. + // is included anywhere a moc_<filename>.cpp file is created and included + // in the moc_compilation.cpp file. // key = moc source filepath, value = moc output filepath - std::map<std::string, std::string> includedMocs; - std::map<std::string, std::string> notIncludedMocs; - std::map<std::string, std::vector<std::string> > includedUis; + std::map<std::string, std::string> mocsIncluded; + std::map<std::string, std::string> mocsNotIncluded; + std::map<std::string, std::set<std::string> > mocDepends; + std::map<std::string, std::vector<std::string> > uisIncluded; // collects all headers which may need to be mocced - std::set<std::string> headerFilesMoc; - std::set<std::string> headerFilesUic; + std::set<std::string> mocHeaderFiles; + std::set<std::string> uicHeaderFiles; // Parse sources - { - const std::vector<std::string>& headerExtensions = - makefile->GetCMakeInstance()->GetHeaderExtensions(); - - for (std::vector<std::string>::const_iterator it = this->Sources.begin(); - it != this->Sources.end(); ++it) { - const std::string& absFilename = *it; - // Parse source file for MOC/UIC - if (!this->ParseSourceFile(absFilename, headerExtensions, includedMocs, - includedUis, this->MocRelaxedMode)) { - return false; - } - // Find additional headers - this->SearchHeadersForSourceFile(absFilename, headerExtensions, - headerFilesMoc, headerFilesUic); + for (std::vector<std::string>::const_iterator it = this->Sources.begin(); + it != this->Sources.end(); ++it) { + const std::string& absFilename = cmsys::SystemTools::GetRealPath(*it); + // Parse source file for MOC/UIC + if (!this->ParseSourceFile(absFilename, mocsIncluded, mocDepends, + uisIncluded, this->MocRelaxedMode)) { + return false; } + // Find additional headers + this->SearchHeadersForSourceFile(absFilename, mocHeaderFiles, + uicHeaderFiles); } // Parse headers for (std::vector<std::string>::const_iterator it = this->Headers.begin(); it != this->Headers.end(); ++it) { - const std::string& headerName = *it; - if (!this->MocSkipTest(headerName)) { - headerFilesMoc.insert(headerName); + const std::string& headerName = cmsys::SystemTools::GetRealPath(*it); + if (!this->MocSkip(headerName)) { + mocHeaderFiles.insert(headerName); } - if (!this->UicSkipTest(headerName)) { - headerFilesUic.insert(headerName); + if (!this->UicSkip(headerName)) { + uicHeaderFiles.insert(headerName); } } - this->ParseHeaders(headerFilesMoc, headerFilesUic, includedMocs, - notIncludedMocs, includedUis); + if (!this->ParseHeaders(mocHeaderFiles, uicHeaderFiles, mocsIncluded, + mocsNotIncluded, mocDepends, uisIncluded)) { + return false; + }; // Generate files - if (!this->MocGenerateAll(includedMocs, notIncludedMocs)) { + if (!this->MocGenerateAll(mocsIncluded, mocsNotIncluded, mocDepends)) { return false; } - if (!this->UicGenerateAll(includedUis)) { + if (!this->UicGenerateAll(uisIncluded)) { return false; } - if (!this->QrcGenerateAll()) { + if (!this->RccGenerateAll()) { return false; } @@ -682,35 +746,73 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile) * @brief Tests if the C++ content requires moc processing * @return True if moc is required */ -bool cmQtAutoGenerators::MocRequired(const std::string& text, - std::string& macroName) +bool cmQtAutoGenerators::MocRequired(const std::string& contentText, + std::string* macroName) { - // Run a simple check before an expensive regular expression check - if (strstr(text.c_str(), "Q_OBJECT") != CM_NULLPTR) { - if (this->RegExpQObject.find(text)) { - macroName = "Q_OBJECT"; - return true; + for (unsigned int ii = 0; ii != cmArraySize(this->MocMacroFilters); ++ii) { + MocMacroFilter& filter = this->MocMacroFilters[ii]; + // Run a simple find string operation before the expensive + // regular expression check + if (contentText.find(filter.first) != std::string::npos) { + if (filter.second.find(contentText)) { + // Return macro name on demand + if (macroName != CM_NULLPTR) { + *macroName = filter.first; + } + return true; + } } } - if (strstr(text.c_str(), "Q_GADGET") != CM_NULLPTR) { - if (this->RegExpQGadget.find(text)) { - macroName = "Q_GADGET"; - return true; + return false; +} + +void cmQtAutoGenerators::MocFindDepends( + const std::string& absFilename, const std::string& contentText, + std::map<std::string, std::set<std::string> >& mocDepends) +{ + for (std::vector<MocDependFilter>::iterator fit = + this->MocDependFilters.begin(); + fit != this->MocDependFilters.end(); ++fit) { + MocDependFilter& filter = *fit; + // Run a simple find string operation before the expensive + // regular expression check + if (contentText.find(filter.key) != std::string::npos) { + // Run regular expression check loop + const std::string sourcePath = SubDirPrefix(absFilename); + const char* contentChars = contentText.c_str(); + while (filter.regExp.find(contentChars)) { + // Evaluate match + const std::string match = filter.regExp.match(1); + if (!match.empty()) { + // Find the dependency file + std::string incFile; + if (this->MocFindIncludedFile(incFile, sourcePath, match)) { + mocDepends[absFilename].insert(incFile); + if (this->Verbose) { + this->LogInfo("AutoMoc: Found dependency:\n " + + Quoted(absFilename) + "\n " + Quoted(incFile)); + } + } else { + this->LogWarning("AutoMoc: Warning: " + Quoted(absFilename) + + "\n" + "Could not find dependency file " + + Quoted(match)); + } + } + contentChars += filter.regExp.end(); + } } } - return false; } /** * @brief Tests if the file should be ignored for moc scanning * @return True if the file should be ignored */ -bool cmQtAutoGenerators::MocSkipTest(const std::string& absFilename) +bool cmQtAutoGenerators::MocSkip(const std::string& absFilename) const { - // Test if moc scanning is enabled - if (!this->MocExecutable.empty()) { + if (this->MocEnabled()) { // Test if the file name is on the skip list - if (!ListContains(this->SkipMoc, absFilename)) { + if (!ListContains(this->MocSkipList, absFilename)) { return false; } } @@ -720,12 +822,11 @@ bool cmQtAutoGenerators::MocSkipTest(const std::string& absFilename) /** * @brief Tests if the file name is in the skip list */ -bool cmQtAutoGenerators::UicSkipTest(const std::string& absFilename) +bool cmQtAutoGenerators::UicSkip(const std::string& absFilename) const { - // Test if uic scanning is enabled - if (!this->UicExecutable.empty()) { + if (this->UicEnabled()) { // Test if the file name is on the skip list - if (!ListContains(this->SkipUic, absFilename)) { + if (!ListContains(this->UicSkipList, absFilename)) { return false; } } @@ -737,53 +838,50 @@ bool cmQtAutoGenerators::UicSkipTest(const std::string& absFilename) */ bool cmQtAutoGenerators::ParseSourceFile( const std::string& absFilename, - const std::vector<std::string>& headerExtensions, - std::map<std::string, std::string>& includedMocs, - std::map<std::string, std::vector<std::string> >& includedUis, bool relaxed) + std::map<std::string, std::string>& mocsIncluded, + std::map<std::string, std::set<std::string> >& mocDepends, + std::map<std::string, std::vector<std::string> >& uisIncluded, bool relaxed) { - bool success = true; - const std::string contentsString = ReadAll(absFilename); - if (contentsString.empty()) { - std::ostringstream err; - err << "AutoGen: Warning: " << absFilename << "\n" - << "The file is empty\n"; - this->LogWarning(err.str()); - } else { - // Parse source contents for MOC - if (success && !this->MocSkipTest(absFilename)) { - success = this->ParseContentForMoc( - absFilename, contentsString, headerExtensions, includedMocs, relaxed); - } - // Parse source contents for UIC - if (success && !this->UicSkipTest(absFilename)) { - this->ParseContentForUic(absFilename, contentsString, includedUis); + std::string contentText; + bool success = ReadAll(contentText, absFilename); + if (success) { + if (!contentText.empty()) { + // Parse source contents for MOC + if (success && !this->MocSkip(absFilename)) { + success = this->MocParseSourceContent( + absFilename, contentText, mocsIncluded, mocDepends, relaxed); + } + // Parse source contents for UIC + if (success && !this->UicSkip(absFilename)) { + this->UicParseContent(absFilename, contentText, uisIncluded); + } + } else { + std::ostringstream ost; + ost << "AutoGen: Warning: The file is empty:\n" + << Quoted(absFilename) << "\n"; + this->LogWarning(ost.str()); } + } else { + std::ostringstream ost; + ost << "AutoGen: Error: Could not read file:\n" << Quoted(absFilename); + this->LogError(ost.str()); } return success; } -void cmQtAutoGenerators::ParseContentForUic( - const std::string& absFilename, const std::string& contentsString, - std::map<std::string, std::vector<std::string> >& includedUis) +void cmQtAutoGenerators::UicParseContent( + const std::string& absFilename, const std::string& contentText, + std::map<std::string, std::vector<std::string> >& uisIncluded) { - // Process if (this->Verbose) { - std::ostringstream err; - err << "AutoUic: Checking " << absFilename << "\n"; - this->LogInfo(err.str()); + this->LogInfo("AutoUic: Checking " + absFilename); } - const std::string realName = cmsys::SystemTools::GetRealPath(absFilename); - const char* contentChars = contentsString.c_str(); + const char* contentChars = contentText.c_str(); if (strstr(contentChars, "ui_") != CM_NULLPTR) { - while (this->RegExpUicInclude.find(contentChars)) { - const std::string currentUi = this->RegExpUicInclude.match(1); - const std::string basename = - cmsys::SystemTools::GetFilenameWithoutLastExtension(currentUi); - // basename should be the part of the ui filename used for - // finding the correct header, so we need to remove the ui_ part - includedUis[realName].push_back(basename.substr(3)); - contentChars += this->RegExpUicInclude.end(); + while (this->UicRegExpInclude.find(contentChars)) { + uisIncluded[absFilename].push_back(this->UicRegExpInclude.match(1)); + contentChars += this->UicRegExpInclude.end(); } } } @@ -791,79 +889,67 @@ void cmQtAutoGenerators::ParseContentForUic( /** * @return True on success */ -bool cmQtAutoGenerators::ParseContentForMoc( - const std::string& absFilename, const std::string& contentsString, - const std::vector<std::string>& headerExtensions, - std::map<std::string, std::string>& includedMocs, bool relaxed) +bool cmQtAutoGenerators::MocParseSourceContent( + const std::string& absFilename, const std::string& contentText, + std::map<std::string, std::string>& mocsIncluded, + std::map<std::string, std::set<std::string> >& mocDepends, bool relaxed) { - // Process if (this->Verbose) { - std::ostringstream err; - err << "AutoMoc: Checking " << absFilename << "\n"; - this->LogInfo(err.str()); + this->LogInfo("AutoMoc: Checking " + absFilename); } - const std::string scannedFileAbsPath = - cmsys::SystemTools::GetFilenamePath( - cmsys::SystemTools::GetRealPath(absFilename)) + - '/'; + const std::string scannedFileAbsPath = SubDirPrefix(absFilename); const std::string scannedFileBasename = cmsys::SystemTools::GetFilenameWithoutLastExtension(absFilename); std::string macroName; - const bool requiresMoc = this->MocRequired(contentsString, macroName); + const bool requiresMoc = this->MocRequired(contentText, ¯oName); bool ownDotMocIncluded = false; - bool ownMocUnderscoreIncluded = false; - std::string ownMocUnderscoreFile; - std::string ownMocHeaderFile; + std::string ownMocUnderscoreInclude; + std::string ownMocUnderscoreHeader; // first a simple string check for "moc" is *much* faster than the regexp, // and if the string search already fails, we don't have to try the // expensive regexp - const char* contentChars = contentsString.c_str(); + const char* contentChars = contentText.c_str(); if (strstr(contentChars, "moc") != CM_NULLPTR) { // Iterate over all included moc files - while (this->RegExpMocInclude.find(contentChars)) { - const std::string currentMoc = this->RegExpMocInclude.match(1); - // Basename of the current moc include - std::string basename = - cmsys::SystemTools::GetFilenameWithoutLastExtension(currentMoc); + while (this->MocRegExpInclude.find(contentChars)) { + const std::string incString = this->MocRegExpInclude.match(1); + // Basename of the moc include + const std::string incSubDir(SubDirPrefix(incString)); + const std::string incBasename = + cmsys::SystemTools::GetFilenameWithoutLastExtension(incString); // If the moc include is of the moc_foo.cpp style we expect // the Q_OBJECT class declaration in a header file. // If the moc include is of the foo.moc style we need to look for // a Q_OBJECT macro in the current source file, if it contains the // macro we generate the moc file from the source file. - if (cmHasLiteralPrefix(basename, "moc_")) { + if (cmHasLiteralPrefix(incBasename, "moc_")) { // Include: moc_FOO.cxx - // basename should be the part of the moc filename used for - // finding the correct header, so we need to remove the moc_ part - basename = basename.substr(4); - const std::string mocSubDir = - ExtractSubDir(scannedFileAbsPath, currentMoc); - const std::string headerToMoc = FindMatchingHeader( - scannedFileAbsPath, mocSubDir, basename, headerExtensions); - + // Remove the moc_ part + const std::string incRealBasename = incBasename.substr(4); + const std::string headerToMoc = + this->MocFindHeader(scannedFileAbsPath, incSubDir + incRealBasename); if (!headerToMoc.empty()) { - includedMocs[headerToMoc] = currentMoc; - if (relaxed && (basename == scannedFileBasename)) { - ownMocUnderscoreIncluded = true; - ownMocUnderscoreFile = currentMoc; - ownMocHeaderFile = headerToMoc; + // Register moc job + mocsIncluded[headerToMoc] = incString; + this->MocFindDepends(headerToMoc, contentText, mocDepends); + // Store meta information for relaxed mode + if (relaxed && (incRealBasename == scannedFileBasename)) { + ownMocUnderscoreInclude = incString; + ownMocUnderscoreHeader = headerToMoc; } } else { - std::ostringstream err; - err << "AutoMoc: Error: " << absFilename << "\n" - << "The file includes the moc file \"" << currentMoc - << "\", but could not find header \"" << basename << '{' - << JoinExts(headerExtensions) << "}\" "; - if (mocSubDir.empty()) { - err << "in " << scannedFileAbsPath << "\n"; - } else { - err << "neither in " << scannedFileAbsPath << " nor in " - << mocSubDir << "\n"; - } - this->LogError(err.str()); + std::ostringstream ost; + ost << "AutoMoc: Error: " << absFilename << "\n" + << "The file includes the moc file " << Quoted(incString) + << ", but could not find header " + << Quoted(incRealBasename + "{" + + JoinExts(this->HeaderExtensions) + "}"); + ; + this->LogError(ost.str()); return false; } } else { @@ -871,108 +957,122 @@ bool cmQtAutoGenerators::ParseContentForMoc( std::string fileToMoc; if (relaxed) { // Mode: Relaxed - if (!requiresMoc || basename != scannedFileBasename) { - const std::string mocSubDir = - ExtractSubDir(scannedFileAbsPath, currentMoc); - const std::string headerToMoc = FindMatchingHeader( - scannedFileAbsPath, mocSubDir, basename, headerExtensions); + if (requiresMoc && (incBasename == scannedFileBasename)) { + // Include self + fileToMoc = absFilename; + ownDotMocIncluded = true; + } else { + // In relaxed mode try to find a header instead but issue a warning + const std::string headerToMoc = + this->MocFindHeader(scannedFileAbsPath, incSubDir + incBasename); if (!headerToMoc.empty()) { // This is for KDE4 compatibility: fileToMoc = headerToMoc; - if (!requiresMoc && basename == scannedFileBasename) { - std::ostringstream err; - err << "AutoMoc: Warning: " << absFilename << "\n" - << "The file includes the moc file \"" << currentMoc - << "\", but does not contain a " << macroName - << " macro. Running moc on " - << "\"" << headerToMoc << "\" ! Include \"moc_" << basename - << ".cpp\" for a compatibility with " - "strict mode (see CMAKE_AUTOMOC_RELAXED_MODE).\n"; - this->LogWarning(err.str()); + if (!requiresMoc && (incBasename == scannedFileBasename)) { + std::ostringstream ost; + ost << "AutoMoc: Warning: " << Quoted(absFilename) << "\n" + << "The file includes the moc file " << Quoted(incString) + << ", but does not contain a Q_OBJECT or Q_GADGET macro.\n" + << "Running moc on " << Quoted(headerToMoc) << "!\n" + << "Include " << Quoted("moc_" + incBasename + ".cpp") + << " for a compatibility with strict mode (see " + "CMAKE_AUTOMOC_RELAXED_MODE).\n"; + this->LogWarning(ost.str()); } else { - std::ostringstream err; - err << "AutoMoc: Warning: " << absFilename << "\n" - << "The file includes the moc file \"" << currentMoc - << "\" instead of \"moc_" << basename - << ".cpp\". Running moc on " - << "\"" << headerToMoc << "\" ! Include \"moc_" << basename - << ".cpp\" for compatibility with " - "strict mode (see CMAKE_AUTOMOC_RELAXED_MODE).\n"; - this->LogWarning(err.str()); + std::ostringstream ost; + ost << "AutoMoc: Warning: " << Quoted(absFilename) << "\n" + << "The file includes the moc file " << Quoted(incString) + << " instead of " << Quoted("moc_" + incBasename + ".cpp") + << ".\n" + << "Running moc on " << Quoted(headerToMoc) << "!\n" + << "Include " << Quoted("moc_" + incBasename + ".cpp") + << " for compatibility with strict mode (see " + "CMAKE_AUTOMOC_RELAXED_MODE).\n"; + this->LogWarning(ost.str()); } } else { - std::ostringstream err; - err << "AutoMoc: Error: " << absFilename << "\n" - << "The file includes the moc file \"" << currentMoc - << "\", which seems to be the moc file from a different " + std::ostringstream ost; + ost << "AutoMoc: Error: " << Quoted(absFilename) << "\n" + << "The file includes the moc file " << Quoted(incString) + << ". which seems to be the moc file from a different " "source file. CMake also could not find a matching " - "header.\n"; - this->LogError(err.str()); + "header."; + this->LogError(ost.str()); return false; } - } else { - // Include self - fileToMoc = absFilename; - ownDotMocIncluded = true; } } else { // Mode: Strict - if (basename == scannedFileBasename) { + if (incBasename == scannedFileBasename) { // Include self fileToMoc = absFilename; ownDotMocIncluded = true; + // Accept but issue a warning if moc isn't required + if (!requiresMoc) { + std::ostringstream ost; + ost << "AutoMoc: Error: " << Quoted(absFilename) << "\n" + << "The file includes the moc file " << Quoted(incString) + << ", but does not contain a Q_OBJECT or Q_GADGET " + "macro."; + this->LogWarning(ost.str()); + } } else { // Don't allow FOO.moc include other than self in strict mode - std::ostringstream err; - err << "AutoMoc: Error: " << absFilename << "\n" - << "The file includes the moc file \"" << currentMoc - << "\", which seems to be the moc file from a different " - "source file. This is not supported. Include \"" - << scannedFileBasename - << ".moc\" to run moc on this source file.\n"; - this->LogError(err.str()); + std::ostringstream ost; + ost << "AutoMoc: Error: " << Quoted(absFilename) << "\n" + << "The file includes the moc file " << Quoted(incString) + << ", which seems to be the moc file from a different " + "source file. This is not supported. Include " + << Quoted(scannedFileBasename + ".moc") + << " to run moc on this source file."; + this->LogError(ost.str()); return false; } } if (!fileToMoc.empty()) { - includedMocs[fileToMoc] = currentMoc; + mocsIncluded[fileToMoc] = incString; + this->MocFindDepends(fileToMoc, contentText, mocDepends); } } // Forward content pointer - contentChars += this->RegExpMocInclude.end(); + contentChars += this->MocRegExpInclude.end(); } } - // In this case, check whether the scanned file itself contains a Q_OBJECT. - // If this is the case, the moc_foo.cpp should probably be generated from - // foo.cpp instead of foo.h, because otherwise it won't build. - // But warn, since this is not how it is supposed to be used. if (requiresMoc && !ownDotMocIncluded) { - if (relaxed && ownMocUnderscoreIncluded) { + // In this case, check whether the scanned file itself contains a Q_OBJECT. + // If this is the case, the moc_foo.cpp should probably be generated from + // foo.cpp instead of foo.h, because otherwise it won't build. + // But warn, since this is not how it is supposed to be used. + if (relaxed && !ownMocUnderscoreInclude.empty()) { // This is for KDE4 compatibility: - std::ostringstream err; - err << "AutoMoc: Warning: " << absFilename << "\n" + std::ostringstream ost; + ost << "AutoMoc: Warning: " << Quoted(absFilename) << "\n" << "The file contains a " << macroName << " macro, but does not include " - << "\"" << scannedFileBasename << ".moc\", but instead includes " - << "\"" << ownMocUnderscoreFile << "\". Running moc on " - << "\"" << absFilename << "\" ! Better include \"" - << scannedFileBasename - << ".moc\" for compatibility with " - "strict mode (see CMAKE_AUTOMOC_RELAXED_MODE).\n"; - this->LogWarning(err.str()); + << Quoted(scannedFileBasename + ".moc") << ", but instead includes " + << Quoted(ownMocUnderscoreInclude) << ".\n" + << "Running moc on " << Quoted(absFilename) << "!\n" + << "Better include " << Quoted(scannedFileBasename + ".moc") + << " for compatibility with strict mode (see " + "CMAKE_AUTOMOC_RELAXED_MODE)."; + this->LogWarning(ost.str()); // Use scanned source file instead of scanned header file as moc source - includedMocs[absFilename] = ownMocUnderscoreFile; - includedMocs.erase(ownMocHeaderFile); + mocsIncluded[absFilename] = ownMocUnderscoreInclude; + this->MocFindDepends(absFilename, contentText, mocDepends); + // Remove + mocsIncluded.erase(ownMocUnderscoreHeader); } else { // Otherwise always error out since it will not compile: - std::ostringstream err; - err << "AutoMoc: Error: " << absFilename << "\n" + std::ostringstream ost; + ost << "AutoMoc: Error: " << Quoted(absFilename) << "\n" << "The file contains a " << macroName << " macro, but does not include " - << "\"" << scannedFileBasename << ".moc\" !\n"; - this->LogError(err.str()); + << Quoted(scannedFileBasename + ".moc") << "!\n" + << "Consider adding the include or enabling SKIP_AUTOMOC for this " + "file."; + this->LogError(ost.str()); return false; } } @@ -980,146 +1080,195 @@ bool cmQtAutoGenerators::ParseContentForMoc( return true; } +void cmQtAutoGenerators::MocParseHeaderContent( + const std::string& absFilename, const std::string& contentText, + std::map<std::string, std::string>& mocsNotIncluded, + std::map<std::string, std::set<std::string> >& mocDepends) +{ + // Log + if (this->Verbose) { + this->LogInfo("AutoMoc: Checking " + absFilename); + } + if (this->MocRequired(contentText)) { + // Register moc job + mocsNotIncluded[absFilename] = + this->ChecksumedPath(absFilename, "moc_", ".cpp"); + this->MocFindDepends(absFilename, contentText, mocDepends); + } +} + void cmQtAutoGenerators::SearchHeadersForSourceFile( - const std::string& absFilename, - const std::vector<std::string>& headerExtensions, - std::set<std::string>& absHeadersMoc, std::set<std::string>& absHeadersUic) + const std::string& absFilename, std::set<std::string>& mocHeaderFiles, + std::set<std::string>& uicHeaderFiles) const { - // search for header files and private header files we may need to moc: - std::string basepath = cmsys::SystemTools::GetFilenamePath( - cmsys::SystemTools::GetRealPath(absFilename)); - basepath += '/'; - basepath += cmsys::SystemTools::GetFilenameWithoutLastExtension(absFilename); - - // Search for regular header - for (std::vector<std::string>::const_iterator ext = headerExtensions.begin(); - ext != headerExtensions.end(); ++ext) { - const std::string headerName = basepath + "." + (*ext); - if (cmsys::SystemTools::FileExists(headerName.c_str())) { - // Moc headers - if (!this->MocSkipTest(absFilename) && !this->MocSkipTest(headerName)) { - absHeadersMoc.insert(headerName); - } - // Uic headers - if (!this->UicSkipTest(absFilename) && !this->UicSkipTest(headerName)) { - absHeadersUic.insert(headerName); - } - break; - } + std::string basepaths[2]; + { + std::string bpath = SubDirPrefix(absFilename); + bpath += cmsys::SystemTools::GetFilenameWithoutLastExtension(absFilename); + // search for default header files and private header files + basepaths[0] = bpath; + basepaths[1] = bpath + "_p"; } - // Search for private header - for (std::vector<std::string>::const_iterator ext = headerExtensions.begin(); - ext != headerExtensions.end(); ++ext) { - const std::string headerName = basepath + "_p." + (*ext); - if (cmsys::SystemTools::FileExists(headerName.c_str())) { + + for (const std::string* bpit = cmArrayBegin(basepaths); + bpit != cmArrayEnd(basepaths); ++bpit) { + std::string headerName; + if (this->FindHeader(headerName, *bpit)) { // Moc headers - if (!this->MocSkipTest(absFilename) && !this->MocSkipTest(headerName)) { - absHeadersMoc.insert(headerName); + if (!this->MocSkip(absFilename) && !this->MocSkip(headerName)) { + mocHeaderFiles.insert(headerName); } // Uic headers - if (!this->UicSkipTest(absFilename) && !this->UicSkipTest(headerName)) { - absHeadersUic.insert(headerName); + if (!this->UicSkip(absFilename) && !this->UicSkip(headerName)) { + uicHeaderFiles.insert(headerName); } break; } } } -void cmQtAutoGenerators::ParseHeaders( - const std::set<std::string>& absHeadersMoc, - const std::set<std::string>& absHeadersUic, - const std::map<std::string, std::string>& includedMocs, - std::map<std::string, std::string>& notIncludedMocs, - std::map<std::string, std::vector<std::string> >& includedUis) +bool cmQtAutoGenerators::ParseHeaders( + const std::set<std::string>& mocHeaderFiles, + const std::set<std::string>& uicHeaderFiles, + const std::map<std::string, std::string>& mocsIncluded, + std::map<std::string, std::string>& mocsNotIncluded, + std::map<std::string, std::set<std::string> >& mocDepends, + std::map<std::string, std::vector<std::string> >& uisIncluded) { + bool success = true; // Merged header files list to read files only once std::set<std::string> headerFiles; - headerFiles.insert(absHeadersMoc.begin(), absHeadersMoc.end()); - headerFiles.insert(absHeadersUic.begin(), absHeadersUic.end()); + headerFiles.insert(mocHeaderFiles.begin(), mocHeaderFiles.end()); + headerFiles.insert(uicHeaderFiles.begin(), uicHeaderFiles.end()); for (std::set<std::string>::const_iterator hIt = headerFiles.begin(); hIt != headerFiles.end(); ++hIt) { const std::string& headerName = *hIt; - const std::string contents = ReadAll(headerName); - - // Parse header content for MOC - if ((absHeadersMoc.find(headerName) != absHeadersMoc.end()) && - (includedMocs.find(headerName) == includedMocs.end())) { - // Process - if (this->Verbose) { - std::ostringstream err; - err << "AutoMoc: Checking " << headerName << "\n"; - this->LogInfo(err.str()); + std::string contentText; + if (ReadAll(contentText, headerName)) { + // Parse header content for MOC + if ((mocHeaderFiles.find(headerName) != mocHeaderFiles.end()) && + (mocsIncluded.find(headerName) == mocsIncluded.end())) { + this->MocParseHeaderContent(headerName, contentText, mocsNotIncluded, + mocDepends); } - std::string macroName; - if (this->MocRequired(contents, macroName)) { - notIncludedMocs[headerName] = fpathCheckSum.getPart(headerName) + - "/moc_" + - cmsys::SystemTools::GetFilenameWithoutLastExtension(headerName) + - ".cpp"; + // Parse header content for UIC + if (uicHeaderFiles.find(headerName) != uicHeaderFiles.end()) { + this->UicParseContent(headerName, contentText, uisIncluded); } - } - - // Parse header content for UIC - if (absHeadersUic.find(headerName) != absHeadersUic.end()) { - this->ParseContentForUic(headerName, contents, includedUis); + } else { + std::ostringstream ost; + ost << "AutoGen: Error: Could not read header file:\n" + << Quoted(headerName); + this->LogError(ost.str()); + success = false; + break; } } + return success; } bool cmQtAutoGenerators::MocGenerateAll( - const std::map<std::string, std::string>& includedMocs, - const std::map<std::string, std::string>& notIncludedMocs) + const std::map<std::string, std::string>& mocsIncluded, + const std::map<std::string, std::string>& mocsNotIncluded, + const std::map<std::string, std::set<std::string> >& mocDepends) { - if (this->MocExecutable.empty()) { + if (!this->MocEnabled()) { return true; } - // look for name collisions + // Look for name collisions { std::multimap<std::string, std::string> collisions; // Test merged map of included and notIncluded - std::map<std::string, std::string> mergedMocs(includedMocs); - mergedMocs.insert(notIncludedMocs.begin(), notIncludedMocs.end()); + std::map<std::string, std::string> mergedMocs(mocsIncluded); + mergedMocs.insert(mocsNotIncluded.begin(), mocsNotIncluded.end()); if (this->NameCollisionTest(mergedMocs, collisions)) { - std::ostringstream err; - err << "AutoMoc: Error: " + std::ostringstream ost; + ost << "AutoMoc: Error: " "The same moc file will be generated " - "from different sources." - << std::endl - << "To avoid this error either" << std::endl - << "- rename the source files or" << std::endl - << "- do not include the (moc_NAME.cpp|NAME.moc) file" << std::endl; - this->LogErrorNameCollision(err.str(), collisions); + "from different sources.\n" + "To avoid this error either\n" + "- rename the source files or\n" + "- do not include the (moc_NAME.cpp|NAME.moc) file"; + this->LogErrorNameCollision(ost.str(), collisions); return false; } } - // generate moc files that are included by source files. + // Generate moc_predefs + if (!this->MocPredefsCmd.empty()) { + if (this->MocSettingsChanged || + FileAbsentOrOlder(this->MocPredefsFileAbs, this->SettingsFile)) { + this->LogBold("Generating MOC predefs " + this->MocPredefsFileRel); + + std::string output; + { + // Compose command + std::vector<std::string> cmd = this->MocPredefsCmd; + // Add includes + cmd.insert(cmd.end(), this->MocIncludes.begin(), + this->MocIncludes.end()); + // Add definitions + for (std::vector<std::string>::const_iterator it = + this->MocDefinitions.begin(); + it != this->MocDefinitions.end(); ++it) { + cmd.push_back("-D" + (*it)); +#ifdef _WIN32 + cmd.push_back("-DWIN32"); +#endif + } + // Add options + cmd.insert(cmd.end(), this->MocOptions.begin(), + this->MocOptions.end()); + // Execute command + if (!this->RunCommand(cmd, output, false)) { + { + std::ostringstream ost; + ost << "AutoMoc: Error: moc predefs generation command failed\n"; + ost << "AutoMoc: Command:\n" << QuotedCommand(cmd) << "\n"; + ost << "AutoMoc: Command output:\n" << output << "\n"; + this->LogError(ost.str()); + } + return false; + } + } + // (Re)write predefs file only on demand + if (this->FileDiffers(this->MocPredefsFileAbs, output)) { + if (this->FileWrite("AutoMoc", this->MocPredefsFileAbs, output)) { + this->MocPredefsChanged = true; + } else { + return false; + } + } + } + } + + // Generate moc files that are included by source files. { - const std::string subDirPrefix = "include/"; + const std::string subDir = "include/"; for (std::map<std::string, std::string>::const_iterator it = - includedMocs.begin(); - it != includedMocs.end(); ++it) { - if (!this->MocGenerateFile(it->first, it->second, subDirPrefix)) { - if (this->RunMocFailed) { + mocsIncluded.begin(); + it != mocsIncluded.end(); ++it) { + if (!this->MocGenerateFile(it->first, it->second, subDir, mocDepends)) { + if (this->MocRunFailed) { return false; } } } } - // generate moc files that are _not_ included by source files. - bool automocCppChanged = false; + // Generate moc files that are _not_ included by source files. + bool mocCompFileGenerated = false; { - const std::string subDirPrefix; + const std::string subDir; for (std::map<std::string, std::string>::const_iterator it = - notIncludedMocs.begin(); - it != notIncludedMocs.end(); ++it) { - if (this->MocGenerateFile(it->first, it->second, subDirPrefix)) { - automocCppChanged = true; + mocsNotIncluded.begin(); + it != mocsNotIncluded.end(); ++it) { + if (this->MocGenerateFile(it->first, it->second, subDir, mocDepends)) { + mocCompFileGenerated = true; } else { - if (this->RunMocFailed) { + if (this->MocRunFailed) { return false; } } @@ -1129,188 +1278,224 @@ bool cmQtAutoGenerators::MocGenerateAll( // Compose moc_compilation.cpp content std::string automocSource; { - std::ostringstream outStream; - outStream << "/* This file is autogenerated, do not edit*/\n"; - if (notIncludedMocs.empty()) { + std::ostringstream ost; + ost << "/* This file is autogenerated, do not edit*/\n"; + if (mocsNotIncluded.empty()) { // Dummy content - outStream << "enum some_compilers { need_more_than_nothing };\n"; + ost << "enum some_compilers { need_more_than_nothing };\n"; } else { // Valid content for (std::map<std::string, std::string>::const_iterator it = - notIncludedMocs.begin(); - it != notIncludedMocs.end(); ++it) { - outStream << "#include \"" << it->second << "\"\n"; + mocsNotIncluded.begin(); + it != mocsNotIncluded.end(); ++it) { + ost << "#include \"" << it->second << "\"\n"; } } - outStream.flush(); - automocSource = outStream.str(); - } - - // Check if we even need to update moc_compilation.cpp - if (!automocCppChanged) { - // compare contents of the moc_compilation.cpp file - const std::string oldContents = ReadAll(this->OutMocCppFilenameAbs); - if (oldContents == automocSource) { - // nothing changed: don't touch the moc_compilation.cpp file - if (this->Verbose) { - std::ostringstream err; - err << "AutoMoc: " << this->OutMocCppFilenameRel << " still up to date" - << std::endl; - this->LogInfo(err.str()); - } - return true; - } + automocSource = ost.str(); } - // Actually write moc_compilation.cpp - { - std::string msg = "Generating MOC compilation "; - msg += this->OutMocCppFilenameRel; - this->LogBold(msg); - } - // Make sure the parent directory exists - bool success = this->MakeParentDirectory(this->OutMocCppFilenameAbs); - if (success) { - cmsys::ofstream outfile; - outfile.open(this->OutMocCppFilenameAbs.c_str(), std::ios::trunc); - if (!outfile) { - success = false; - std::ostringstream err; - err << "AutoMoc: error opening " << this->OutMocCppFilenameAbs << "\n"; - this->LogError(err.str()); - } else { - outfile << automocSource; - // Check for write errors - if (!outfile.good()) { - success = false; - std::ostringstream err; - err << "AutoMoc: error writing " << this->OutMocCppFilenameAbs << "\n"; - this->LogError(err.str()); - } + if (this->FileDiffers(this->MocCppFilenameAbs, automocSource)) { + // Actually write moc_compilation.cpp + this->LogBold("Generating MOC compilation " + this->MocCppFilenameRel); + if (!this->FileWrite("AutoMoc", this->MocCppFilenameAbs, automocSource)) { + return false; } + } else if (mocCompFileGenerated) { + // Only touch moc_compilation.cpp + if (this->Verbose) { + this->LogInfo("Touching MOC compilation " + this->MocCppFilenameRel); + } + cmSystemTools::Touch(this->MocCppFilenameAbs, false); } - return success; + + return true; } /** * @return True if a moc file was created. False may indicate an error. */ -bool cmQtAutoGenerators::MocGenerateFile(const std::string& sourceFile, - const std::string& mocFileName, - const std::string& subDirPrefix) +bool cmQtAutoGenerators::MocGenerateFile( + const std::string& sourceFile, const std::string& mocFileName, + const std::string& subDir, + const std::map<std::string, std::set<std::string> >& mocDepends) { + bool mocGenerated = false; + bool generateMoc = this->MocSettingsChanged || this->MocPredefsChanged; + const std::string mocFileRel = - this->AutogenBuildSubDir + subDirPrefix + mocFileName; + this->AutogenBuildSubDir + subDir + mocFileName; const std::string mocFileAbs = this->CurrentBinaryDir + mocFileRel; - bool generateMoc = this->GenerateMocAll; - // Test if the source file is newer that the build file if (!generateMoc) { + // Test if the source file is newer that the build file generateMoc = FileAbsentOrOlder(mocFileAbs, sourceFile); + if (!generateMoc) { + // Test if a dependency file changed + std::map<std::string, std::set<std::string> >::const_iterator dit = + mocDepends.find(sourceFile); + if (dit != mocDepends.end()) { + for (std::set<std::string>::const_iterator fit = dit->second.begin(); + fit != dit->second.end(); ++fit) { + if (FileAbsentOrOlder(mocFileAbs, *fit)) { + generateMoc = true; + break; + } + } + } + } } if (generateMoc) { // Log this->LogBold("Generating MOC source " + mocFileRel); // Make sure the parent directory exists - if (!this->MakeParentDirectory(mocFileAbs)) { - this->RunMocFailed = true; - return false; - } - - std::vector<std::string> command; - command.push_back(this->MocExecutable); - command.insert(command.end(), this->MocIncludes.begin(), - this->MocIncludes.end()); - command.insert(command.end(), this->MocDefinitions.begin(), - this->MocDefinitions.end()); - command.insert(command.end(), this->MocOptions.begin(), - this->MocOptions.end()); + if (this->MakeParentDirectory("AutoMoc", mocFileAbs)) { + // Compose moc command + std::vector<std::string> cmd; + cmd.push_back(this->MocExecutable); + // Add includes + cmd.insert(cmd.end(), this->MocIncludes.begin(), + this->MocIncludes.end()); + // Add definitions + for (std::vector<std::string>::const_iterator it = + this->MocDefinitions.begin(); + it != this->MocDefinitions.end(); ++it) { + cmd.push_back("-D" + (*it)); + } #ifdef _WIN32 - command.push_back("-DWIN32"); + cmd.push_back("-DWIN32"); #endif - command.push_back("-o"); - command.push_back(mocFileAbs); - command.push_back(sourceFile); - - if (this->Verbose) { - this->LogCommand(command); + // Add options + cmd.insert(cmd.end(), this->MocOptions.begin(), this->MocOptions.end()); + // Add predefs include + if (!this->MocPredefsFileAbs.empty()) { + cmd.push_back("--include"); + cmd.push_back(this->MocPredefsFileAbs); + } + cmd.push_back("-o"); + cmd.push_back(mocFileAbs); + cmd.push_back(sourceFile); + + // Execute moc command + std::string output; + if (this->RunCommand(cmd, output)) { + // Success + mocGenerated = true; + } else { + // Command failed + { + std::ostringstream ost; + ost << "AutoMoc: Error: moc process failed for\n"; + ost << Quoted(mocFileRel) << "\n"; + ost << "AutoMoc: Command:\n" << QuotedCommand(cmd) << "\n"; + ost << "AutoMoc: Command output:\n" << output << "\n"; + this->LogError(ost.str()); + } + cmSystemTools::RemoveFile(mocFileAbs); + this->MocRunFailed = true; + } + } else { + // Parent directory creation failed + this->MocRunFailed = true; } + } + return mocGenerated; +} - std::string output; - int retVal = 0; - bool result = - cmSystemTools::RunSingleCommand(command, &output, &output, &retVal); - if (!result || retVal) { - { - std::ostringstream err; - err << "AutoMoc: Error: moc process for " << mocFileRel << " failed:\n" - << output << std::endl; - this->LogError(err.str()); +bool cmQtAutoGenerators::UicFindIncludedFile(std::string& absFile, + const std::string& sourceFile, + const std::string& includeString) +{ + bool success = false; + // Search in vicinity of the source + { + std::string testPath = SubDirPrefix(sourceFile); + testPath += includeString; + if (cmsys::SystemTools::FileExists(testPath.c_str())) { + absFile = cmsys::SystemTools::GetRealPath(testPath); + success = true; + } + } + // Search in include directories + if (!success) { + for (std::vector<std::string>::const_iterator iit = + this->UicSearchPaths.begin(); + iit != this->UicSearchPaths.end(); ++iit) { + const std::string fullPath = ((*iit) + '/' + includeString); + if (cmsys::SystemTools::FileExists(fullPath.c_str())) { + absFile = cmsys::SystemTools::GetRealPath(fullPath); + success = true; + break; } - cmSystemTools::RemoveFile(mocFileAbs); - this->RunMocFailed = true; - return false; } - return true; } - return false; + return success; } bool cmQtAutoGenerators::UicGenerateAll( - const std::map<std::string, std::vector<std::string> >& includedUis) + const std::map<std::string, std::vector<std::string> >& uisIncluded) { - if (this->UicExecutable.empty()) { + if (!this->UicEnabled()) { return true; } // single map with input / output names - std::map<std::string, std::map<std::string, std::string> > uiGenMap; - std::map<std::string, std::string> testMap; - for (std::map<std::string, std::vector<std::string> >::const_iterator it = - includedUis.begin(); - it != includedUis.end(); ++it) { - // source file path - std::string sourcePath = cmsys::SystemTools::GetFilenamePath(it->first); - sourcePath += '/'; - // insert new map for source file an use new reference - uiGenMap[it->first] = std::map<std::string, std::string>(); - std::map<std::string, std::string>& sourceMap = uiGenMap[it->first]; - for (std::vector<std::string>::const_iterator sit = it->second.begin(); - sit != it->second.end(); ++sit) { - const std::string& uiFileName = *sit; - const std::string uiInputFile = sourcePath + uiFileName + ".ui"; - const std::string uiOutputFile = "ui_" + uiFileName + ".h"; - sourceMap[uiInputFile] = uiOutputFile; - testMap[uiInputFile] = uiOutputFile; - } - } - - // look for name collisions + std::map<std::string, std::map<std::string, std::string> > sourceGenMap; { - std::multimap<std::string, std::string> collisions; - if (this->NameCollisionTest(testMap, collisions)) { - std::ostringstream err; - err << "AutoUic: Error: The same ui_NAME.h file will be generated " - "from different sources." - << std::endl - << "To avoid this error rename the source files." << std::endl; - this->LogErrorNameCollision(err.str(), collisions); - return false; + // Collision lookup map + std::map<std::string, std::string> testMap; + // Compile maps + for (std::map<std::string, std::vector<std::string> >::const_iterator sit = + uisIncluded.begin(); + sit != uisIncluded.end(); ++sit) { + const std::string& source(sit->first); + const std::vector<std::string>& sourceIncs(sit->second); + // insert new source/destination map + std::map<std::string, std::string>& uiGenMap = sourceGenMap[source]; + for (std::vector<std::string>::const_iterator uit = sourceIncs.begin(); + uit != sourceIncs.end(); ++uit) { + // Remove ui_ from the begin filename by substr() + const std::string uiBasePath = SubDirPrefix(*uit); + const std::string uiBaseName = + cmsys::SystemTools::GetFilenameWithoutLastExtension(*uit).substr(3); + const std::string searchFileName = uiBasePath + uiBaseName + ".ui"; + std::string uiInputFile; + if (UicFindIncludedFile(uiInputFile, source, searchFileName)) { + std::string uiOutputFile = uiBasePath + "ui_" + uiBaseName + ".h"; + cmSystemTools::ReplaceString(uiOutputFile, "..", "__"); + uiGenMap[uiInputFile] = uiOutputFile; + testMap[uiInputFile] = uiOutputFile; + } else { + this->LogError("AutoUic: Error: " + Quoted(sit->first) + + "\nCould not find " + Quoted(searchFileName)); + return false; + } + } + } + // look for name collisions + { + std::multimap<std::string, std::string> collisions; + if (this->NameCollisionTest(testMap, collisions)) { + std::ostringstream ost; + ost << "AutoUic: Error: The same ui_NAME.h file will be generated " + "from different sources.\n" + "To avoid this error rename the source files.\n"; + this->LogErrorNameCollision(ost.str(), collisions); + return false; + } } } - testMap.clear(); // generate ui files for (std::map<std::string, std::map<std::string, std::string> >::const_iterator it = - uiGenMap.begin(); - it != uiGenMap.end(); ++it) { + sourceGenMap.begin(); + it != sourceGenMap.end(); ++it) { for (std::map<std::string, std::string>::const_iterator sit = it->second.begin(); sit != it->second.end(); ++sit) { if (!this->UicGenerateFile(it->first, sit->first, sit->second)) { - if (this->RunUicFailed) { + if (this->UicRunFailed) { return false; } } @@ -1327,13 +1512,15 @@ bool cmQtAutoGenerators::UicGenerateFile(const std::string& realName, const std::string& uiInputFile, const std::string& uiOutputFile) { + bool uicGenerated = false; + bool generateUic = this->UicSettingsChanged; + const std::string uicFileRel = this->AutogenBuildSubDir + "include/" + uiOutputFile; const std::string uicFileAbs = this->CurrentBinaryDir + uicFileRel; - bool generateUic = this->GenerateUicAll; - // Test if the source file is newer that the build file if (!generateUic) { + // Test if the source file is newer that the build file generateUic = FileAbsentOrOlder(uicFileAbs, uiInputFile); } if (generateUic) { @@ -1341,55 +1528,54 @@ bool cmQtAutoGenerators::UicGenerateFile(const std::string& realName, this->LogBold("Generating UIC header " + uicFileRel); // Make sure the parent directory exists - if (!this->MakeParentDirectory(uicFileAbs)) { - this->RunUicFailed = true; - return false; - } - - std::vector<std::string> command; - command.push_back(this->UicExecutable); - - std::vector<std::string> opts = this->UicTargetOptions; - std::map<std::string, std::string>::const_iterator optionIt = - this->UicOptions.find(uiInputFile); - if (optionIt != this->UicOptions.end()) { - std::vector<std::string> fileOpts; - cmSystemTools::ExpandListArgument(optionIt->second, fileOpts); - UicMergeOptions(opts, fileOpts, this->QtMajorVersion == "5"); - } - command.insert(command.end(), opts.begin(), opts.end()); - - command.push_back("-o"); - command.push_back(uicFileAbs); - command.push_back(uiInputFile); - - if (this->Verbose) { - this->LogCommand(command); - } - std::string output; - int retVal = 0; - bool result = - cmSystemTools::RunSingleCommand(command, &output, &output, &retVal); - if (!result || retVal) { + if (this->MakeParentDirectory("AutoUic", uicFileAbs)) { + // Compose uic command + std::vector<std::string> cmd; + cmd.push_back(this->UicExecutable); { - std::ostringstream err; - err << "AutoUic: Error: uic process for " << uicFileRel - << " needed by\n \"" << realName << "\"\nfailed:\n" - << output << std::endl; - this->LogError(err.str()); + std::vector<std::string> allOpts = this->UicTargetOptions; + std::map<std::string, std::string>::const_iterator optionIt = + this->UicOptions.find(uiInputFile); + if (optionIt != this->UicOptions.end()) { + std::vector<std::string> fileOpts; + cmSystemTools::ExpandListArgument(optionIt->second, fileOpts); + UicMergeOptions(allOpts, fileOpts, (this->QtMajorVersion == "5")); + } + cmd.insert(cmd.end(), allOpts.begin(), allOpts.end()); } - cmSystemTools::RemoveFile(uicFileAbs); - this->RunUicFailed = true; - return false; + cmd.push_back("-o"); + cmd.push_back(uicFileAbs); + cmd.push_back(uiInputFile); + + std::string output; + if (this->RunCommand(cmd, output)) { + // Success + uicGenerated = true; + } else { + // Command failed + { + std::ostringstream ost; + ost << "AutoUic: Error: uic process failed for\n"; + ost << Quoted(uicFileRel) << " needed by\n"; + ost << Quoted(realName) << "\n"; + ost << "AutoUic: Command:\n" << QuotedCommand(cmd) << "\n"; + ost << "AutoUic: Command output:\n" << output << "\n"; + this->LogError(ost.str()); + } + cmSystemTools::RemoveFile(uicFileAbs); + this->UicRunFailed = true; + } + } else { + // Parent directory creation failed + this->UicRunFailed = true; } - return true; } - return false; + return uicGenerated; } -bool cmQtAutoGenerators::QrcGenerateAll() +bool cmQtAutoGenerators::RccGenerateAll() { - if (this->RccExecutable.empty()) { + if (!this->RccEnabled()) { return true; } @@ -1399,9 +1585,8 @@ bool cmQtAutoGenerators::QrcGenerateAll() si != this->RccSources.end(); ++si) { const std::string ext = cmsys::SystemTools::GetFilenameLastExtension(*si); if (ext == ".qrc") { - qrcGenMap[*si] = this->AutogenBuildSubDir + fpathCheckSum.getPart(*si) + - "/qrc_" + cmsys::SystemTools::GetFilenameWithoutLastExtension(*si) + - ".cpp"; + qrcGenMap[*si] = + this->AutogenBuildSubDir + this->ChecksumedPath(*si, "qrc_", ".cpp"); } } @@ -1409,12 +1594,11 @@ bool cmQtAutoGenerators::QrcGenerateAll() { std::multimap<std::string, std::string> collisions; if (this->NameCollisionTest(qrcGenMap, collisions)) { - std::ostringstream err; - err << "AutoRcc: Error: The same qrc_NAME.cpp file" - " will be generated from different sources." - << std::endl - << "To avoid this error rename the source .qrc files." << std::endl; - this->LogErrorNameCollision(err.str(), collisions); + std::ostringstream ost; + ost << "AutoRcc: Error: The same qrc_NAME.cpp file" + " will be generated from different sources.\n" + "To avoid this error rename the source .qrc files.\n"; + this->LogErrorNameCollision(ost.str(), collisions); return false; } } @@ -1424,8 +1608,8 @@ bool cmQtAutoGenerators::QrcGenerateAll() qrcGenMap.begin(); si != qrcGenMap.end(); ++si) { bool unique = FileNameIsUnique(si->first, qrcGenMap); - if (!this->QrcGenerateFile(si->first, si->second, unique)) { - if (this->RunRccFailed) { + if (!this->RccGenerateFile(si->first, si->second, unique)) { + if (this->RccRunFailed) { return false; } } @@ -1436,145 +1620,167 @@ bool cmQtAutoGenerators::QrcGenerateAll() /** * @return True if a rcc file was created. False may indicate an error. */ -bool cmQtAutoGenerators::QrcGenerateFile(const std::string& qrcInputFile, - const std::string& qrcOutputFile, +bool cmQtAutoGenerators::RccGenerateFile(const std::string& rccInputFile, + const std::string& rccOutputFile, bool unique_n) { - std::string symbolName = - cmsys::SystemTools::GetFilenameWithoutLastExtension(qrcInputFile); - if (!unique_n) { - symbolName += "_"; - symbolName += fpathCheckSum.getPart(qrcInputFile); - } - // Replace '-' with '_'. The former is valid for - // file names but not for symbol names. - std::replace(symbolName.begin(), symbolName.end(), '-', '_'); - - const std::string qrcBuildFile = this->CurrentBinaryDir + qrcOutputFile; - - bool generateQrc = this->GenerateRccAll; - // Test if the resources list file is newer than build file - if (!generateQrc) { - generateQrc = FileAbsentOrOlder(qrcBuildFile, qrcInputFile); - } - // Test if any resource file is newer than the build file - if (!generateQrc) { - const std::vector<std::string>& files = this->RccInputs[qrcInputFile]; - for (std::vector<std::string>::const_iterator it = files.begin(); - it != files.end(); ++it) { - if (FileAbsentOrOlder(qrcBuildFile, *it)) { - generateQrc = true; - break; + bool rccGenerated = false; + bool generateRcc = this->RccSettingsChanged; + + const std::string rccBuildFile = this->CurrentBinaryDir + rccOutputFile; + + if (!generateRcc) { + // Test if the resources list file is newer than build file + generateRcc = FileAbsentOrOlder(rccBuildFile, rccInputFile); + if (!generateRcc) { + // Acquire input file list + std::vector<std::string> readFiles; + const std::vector<std::string>* files = &this->RccInputs[rccInputFile]; + if (files->empty()) { + // Read input file list from qrc file + std::string error; + if (cmQtAutoGeneratorCommon::RccListInputs( + this->QtMajorVersion, this->RccExecutable, rccInputFile, + readFiles, &error)) { + files = &readFiles; + } else { + files = CM_NULLPTR; + this->LogError(error); + this->RccRunFailed = true; + } + } + // Test if any input file is newer than the build file + if (files != CM_NULLPTR) { + for (std::vector<std::string>::const_iterator it = files->begin(); + it != files->end(); ++it) { + if (FileAbsentOrOlder(rccBuildFile, *it)) { + generateRcc = true; + break; + } + } } } } - if (generateQrc) { - { - std::string msg = "Generating RCC source "; - msg += qrcOutputFile; - this->LogBold(msg); - } + if (generateRcc) { + // Log + this->LogBold("Generating RCC source " + rccOutputFile); // Make sure the parent directory exists - if (!this->MakeParentDirectory(qrcOutputFile)) { - this->RunRccFailed = true; - return false; - } - - std::vector<std::string> command; - command.push_back(this->RccExecutable); - { - std::map<std::string, std::string>::const_iterator optionIt = - this->RccOptions.find(qrcInputFile); - if (optionIt != this->RccOptions.end()) { - cmSystemTools::ExpandListArgument(optionIt->second, command); + if (this->MakeParentDirectory("AutoRcc", rccBuildFile)) { + // Compose symbol name + std::string symbolName = + cmsys::SystemTools::GetFilenameWithoutLastExtension(rccInputFile); + if (!unique_n) { + symbolName += "_"; + symbolName += FPathChecksum.getPart(rccInputFile); } - } - command.push_back("-name"); - command.push_back(symbolName); - command.push_back("-o"); - command.push_back(qrcBuildFile); - command.push_back(qrcInputFile); + // Replace '-' with '_'. The former is valid for + // file names but not for symbol names. + std::replace(symbolName.begin(), symbolName.end(), '-', '_'); - if (this->Verbose) { - this->LogCommand(command); - } - std::string output; - int retVal = 0; - bool result = - cmSystemTools::RunSingleCommand(command, &output, &output, &retVal); - if (!result || retVal) { + // Compose rcc command + std::vector<std::string> cmd; + cmd.push_back(this->RccExecutable); { - std::ostringstream err; - err << "AutoRcc: Error: rcc process for " << qrcOutputFile - << " failed:\n" - << output << std::endl; - this->LogError(err.str()); + std::map<std::string, std::string>::const_iterator optionIt = + this->RccOptions.find(rccInputFile); + if (optionIt != this->RccOptions.end()) { + cmSystemTools::ExpandListArgument(optionIt->second, cmd); + } } - cmSystemTools::RemoveFile(qrcBuildFile); - this->RunRccFailed = true; - return false; + cmd.push_back("-name"); + cmd.push_back(symbolName); + cmd.push_back("-o"); + cmd.push_back(rccBuildFile); + cmd.push_back(rccInputFile); + + std::string output; + if (this->RunCommand(cmd, output)) { + // Success + rccGenerated = true; + } else { + // Command failed + { + std::ostringstream ost; + ost << "AutoRcc: Error: rcc process failed for\n"; + ost << Quoted(rccOutputFile) << "\n"; + ost << "AutoRcc: Command:\n" << QuotedCommand(cmd) << "\n"; + ost << "AutoRcc: Command output:\n" << output << "\n"; + this->LogError(ost.str()); + } + cmSystemTools::RemoveFile(rccBuildFile); + this->RccRunFailed = true; + } + } else { + // Parent directory creation failed + this->RccRunFailed = true; } - return true; } - return false; + return rccGenerated; } void cmQtAutoGenerators::LogErrorNameCollision( const std::string& message, - const std::multimap<std::string, std::string>& collisions) + const std::multimap<std::string, std::string>& collisions) const { typedef std::multimap<std::string, std::string>::const_iterator Iter; - std::ostringstream err; + std::ostringstream ost; // Add message - err << message; + if (!message.empty()) { + ost << message; + if (message[message.size() - 1] != '\n') { + ost << '\n'; + } + } // Append collision list for (Iter it = collisions.begin(); it != collisions.end(); ++it) { - err << it->first << " : " << it->second << std::endl; + ost << it->first << " : " << it->second << '\n'; } - this->LogError(err.str()); + this->LogError(ost.str()); } -void cmQtAutoGenerators::LogBold(const std::string& message) +void cmQtAutoGenerators::LogBold(const std::string& message) const { cmSystemTools::MakefileColorEcho(cmsysTerminal_Color_ForegroundBlue | cmsysTerminal_Color_ForegroundBold, message.c_str(), true, this->ColorOutput); } -void cmQtAutoGenerators::LogInfo(const std::string& message) +void cmQtAutoGenerators::LogInfo(const std::string& message) const { - std::cout << message.c_str(); -} - -void cmQtAutoGenerators::LogWarning(const std::string& message) -{ - std::ostringstream ostr; - ostr << message << "\n"; - std::cout << message.c_str(); + std::string msg(message); + if (!msg.empty()) { + if (msg[msg.size() - 1] != '\n') { + msg.push_back('\n'); + } + cmSystemTools::Stdout(msg.c_str(), msg.size()); + } } -void cmQtAutoGenerators::LogError(const std::string& message) +void cmQtAutoGenerators::LogWarning(const std::string& message) const { - std::ostringstream ostr; - ostr << message << "\n\n"; - std::cerr << ostr.str(); + std::string msg(message); + if (!msg.empty()) { + if (msg[msg.size() - 1] != '\n') { + msg.push_back('\n'); + } + // Append empty line + msg.push_back('\n'); + cmSystemTools::Stdout(msg.c_str(), msg.size()); + } } -void cmQtAutoGenerators::LogCommand(const std::vector<std::string>& command) +void cmQtAutoGenerators::LogError(const std::string& message) const { - std::ostringstream sbuf; - for (std::vector<std::string>::const_iterator cmdIt = command.begin(); - cmdIt != command.end(); ++cmdIt) { - if (cmdIt != command.begin()) { - sbuf << " "; + std::string msg(message); + if (!msg.empty()) { + if (msg[msg.size() - 1] != '\n') { + msg.push_back('\n'); } - sbuf << *cmdIt; - } - if (!sbuf.str().empty()) { - sbuf << std::endl; - this->LogInfo(sbuf.str()); + // Append empty line + msg.push_back('\n'); + cmSystemTools::Stderr(msg.c_str(), msg.size()); } } @@ -1584,7 +1790,7 @@ void cmQtAutoGenerators::LogCommand(const std::vector<std::string>& command) */ bool cmQtAutoGenerators::NameCollisionTest( const std::map<std::string, std::string>& genFiles, - std::multimap<std::string, std::string>& collisions) + std::multimap<std::string, std::string>& collisions) const { typedef std::map<std::string, std::string>::const_iterator Iter; typedef std::map<std::string, std::string>::value_type VType; @@ -1609,19 +1815,174 @@ bool cmQtAutoGenerators::NameCollisionTest( } /** + * @brief Generates a file path based on the checksum of the source file path + * @return The path + */ +std::string cmQtAutoGenerators::ChecksumedPath(const std::string& sourceFile, + const char* basePrefix, + const char* baseSuffix) const +{ + std::string res = FPathChecksum.getPart(sourceFile); + res += "/"; + res += basePrefix; + res += cmsys::SystemTools::GetFilenameWithoutLastExtension(sourceFile); + res += baseSuffix; + return res; +} + +/** * @brief Generates the parent directory of the given file on demand * @return True on success */ -bool cmQtAutoGenerators::MakeParentDirectory(const std::string& filename) +bool cmQtAutoGenerators::MakeParentDirectory(const char* logPrefix, + const std::string& filename) const { bool success = true; const std::string dirName = cmSystemTools::GetFilenamePath(filename); if (!dirName.empty()) { success = cmsys::SystemTools::MakeDirectory(dirName); if (!success) { - std::ostringstream err; - err << "AutoGen: Directory creation failed: " << dirName << std::endl; - this->LogError(err.str()); + std::string error = logPrefix; + error += ": Error: Parent directory creation failed for "; + error += Quoted(filename); + this->LogError(error); + } + } + return success; +} + +bool cmQtAutoGenerators::FileDiffers(const std::string& filename, + const std::string& content) +{ + bool differs = true; + { + std::string oldContents; + if (ReadAll(oldContents, filename)) { + differs = (oldContents != content); + } + } + return differs; +} + +bool cmQtAutoGenerators::FileWrite(const char* logPrefix, + const std::string& filename, + const std::string& content) +{ + std::string error; + // Make sure the parent directory exists + if (this->MakeParentDirectory(logPrefix, filename)) { + cmsys::ofstream outfile; + outfile.open(filename.c_str(), std::ios::trunc); + if (outfile) { + outfile << content; + // Check for write errors + if (!outfile.good()) { + error = logPrefix; + error += ": Error writing "; + error += Quoted(filename); + } + } else { + error = logPrefix; + error = ": Error opening "; + error += Quoted(filename); + } + } + if (!error.empty()) { + this->LogError(error); + return false; + } + return true; +} + +/** + * @brief Runs a command and returns true on success + * @return True on success + */ +bool cmQtAutoGenerators::RunCommand(const std::vector<std::string>& command, + std::string& output, bool verbose) const +{ + // Log command + if (this->Verbose) { + this->LogInfo(QuotedCommand(command)); + } + // Execute command + int retVal = 0; + bool res = cmSystemTools::RunSingleCommand( + command, &output, &output, &retVal, CM_NULLPTR, + verbose ? cmSystemTools::OUTPUT_MERGE : cmSystemTools::OUTPUT_NONE); + return (res && (retVal == 0)); +} + +/** + * @brief Tries to find the header file to the given file base path by + * appending different header extensions + * @return True on success + */ +bool cmQtAutoGenerators::FindHeader(std::string& header, + const std::string& testBasePath) const +{ + for (std::vector<std::string>::const_iterator ext = + this->HeaderExtensions.begin(); + ext != this->HeaderExtensions.end(); ++ext) { + std::string testFilePath(testBasePath); + testFilePath += '.'; + testFilePath += (*ext); + if (cmsys::SystemTools::FileExists(testFilePath.c_str())) { + header = testFilePath; + return true; + } + } + return false; +} + +std::string cmQtAutoGenerators::MocFindHeader( + const std::string& sourcePath, const std::string& includeBase) const +{ + std::string header; + // Search in vicinity of the source + if (!this->FindHeader(header, sourcePath + includeBase)) { + // Search in include directories + for (std::vector<std::string>::const_iterator iit = + this->MocIncludePaths.begin(); + iit != this->MocIncludePaths.end(); ++iit) { + const std::string fullPath = ((*iit) + '/' + includeBase); + if (FindHeader(header, fullPath)) { + break; + } + } + } + // Sanitize + if (!header.empty()) { + header = cmsys::SystemTools::GetRealPath(header); + } + return header; +} + +bool cmQtAutoGenerators::MocFindIncludedFile( + std::string& absFile, const std::string& sourcePath, + const std::string& includeString) const +{ + bool success = false; + // Search in vicinity of the source + { + std::string testPath = sourcePath; + testPath += includeString; + if (cmsys::SystemTools::FileExists(testPath.c_str())) { + absFile = cmsys::SystemTools::GetRealPath(testPath); + success = true; + } + } + // Search in include directories + if (!success) { + for (std::vector<std::string>::const_iterator iit = + this->MocIncludePaths.begin(); + iit != this->MocIncludePaths.end(); ++iit) { + const std::string fullPath = ((*iit) + '/' + includeString); + if (cmsys::SystemTools::FileExists(fullPath.c_str())) { + absFile = cmsys::SystemTools::GetRealPath(fullPath); + success = true; + break; + } } } return success; diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h index 7891eb9..987110f 100644 --- a/Source/cmQtAutoGenerators.h +++ b/Source/cmQtAutoGenerators.h @@ -3,14 +3,15 @@ #ifndef cmQtAutoGenerators_h #define cmQtAutoGenerators_h -#include <cmConfigure.h> // IWYU pragma: keep -#include <cmFilePathChecksum.h> -#include <cmsys/RegularExpression.hxx> +#include "cmConfigure.h" // IWYU pragma: keep + +#include "cmFilePathChecksum.h" +#include "cmsys/RegularExpression.hxx" -#include <list> #include <map> #include <set> #include <string> +#include <utility> #include <vector> class cmMakefile; @@ -22,147 +23,199 @@ public: bool Run(const std::string& targetDirectory, const std::string& config); private: - // - Configuration + // -- Types + + /// @brief Used to extract additional dependencies from content text + struct MocDependFilter + { + std::string key; + cmsys::RegularExpression regExp; + }; + typedef std::pair<std::string, cmsys::RegularExpression> MocMacroFilter; + + // -- Configuration + bool MocDependFilterPush(const std::string& key, const std::string& regExp); bool ReadAutogenInfoFile(cmMakefile* makefile, const std::string& targetDirectory, const std::string& config); - std::string MocSettingsStringCompose(); - std::string UicSettingsStringCompose(); - std::string RccSettingsStringCompose(); - void OldSettingsReadFile(cmMakefile* makefile, - const std::string& targetDirectory); - bool OldSettingsWriteFile(const std::string& targetDirectory); + bool MocEnabled() const { return !this->MocExecutable.empty(); } + bool UicEnabled() const { return !this->UicExecutable.empty(); } + bool RccEnabled() const { return !this->RccExecutable.empty(); } + + // -- Settings file + void SettingsFileRead(cmMakefile* makefile); + bool SettingsFileWrite(); + + bool AnySettingsChanged() const + { + return (this->MocSettingsChanged || this->RccSettingsChanged || + this->UicSettingsChanged); + } + + // -- Init and run + void Init(cmMakefile* makefile); + bool RunAutogen(); - // - Init and run - void Init(); - bool RunAutogen(cmMakefile* makefile); + // -- Content analysis + bool MocRequired(const std::string& contentText, + std::string* macroName = CM_NULLPTR); + void MocFindDepends( + const std::string& absFilename, const std::string& contentText, + std::map<std::string, std::set<std::string> >& mocDepends); - // - Content analysis - bool MocRequired(const std::string& text, std::string& macroName); - bool MocSkipTest(const std::string& absFilename); - bool UicSkipTest(const std::string& absFilename); + bool MocSkip(const std::string& absFilename) const; + bool UicSkip(const std::string& absFilename) const; bool ParseSourceFile( const std::string& absFilename, - const std::vector<std::string>& headerExtensions, - std::map<std::string, std::string>& includedMocs, + std::map<std::string, std::string>& mocsIncluded, + std::map<std::string, std::set<std::string> >& mocDepends, std::map<std::string, std::vector<std::string> >& includedUis, bool relaxed); - void SearchHeadersForSourceFile( - const std::string& absFilename, - const std::vector<std::string>& headerExtensions, - std::set<std::string>& absHeadersMoc, - std::set<std::string>& absHeadersUic); - - void ParseHeaders( - const std::set<std::string>& absHeadersMoc, - const std::set<std::string>& absHeadersUic, - const std::map<std::string, std::string>& includedMocs, - std::map<std::string, std::string>& notIncludedMocs, + void SearchHeadersForSourceFile(const std::string& absFilename, + std::set<std::string>& mocHeaderFiles, + std::set<std::string>& uicHeaderFiles) const; + + bool ParseHeaders( + const std::set<std::string>& mocHeaderFiles, + const std::set<std::string>& uicHeaderFiles, + const std::map<std::string, std::string>& mocsIncluded, + std::map<std::string, std::string>& mocsNotIncluded, + std::map<std::string, std::set<std::string> >& mocDepends, std::map<std::string, std::vector<std::string> >& includedUis); - void ParseContentForUic( - const std::string& fileName, const std::string& contentsString, + void UicParseContent( + const std::string& fileName, const std::string& contentText, std::map<std::string, std::vector<std::string> >& includedUis); - bool ParseContentForMoc(const std::string& absFilename, - const std::string& contentsString, - const std::vector<std::string>& headerExtensions, - std::map<std::string, std::string>& includedMocs, - bool relaxed); + bool MocParseSourceContent( + const std::string& absFilename, const std::string& contentText, + std::map<std::string, std::string>& mocsIncluded, + std::map<std::string, std::set<std::string> >& mocDepends, bool relaxed); - // - Moc file generation - bool MocGenerateAll( - const std::map<std::string, std::string>& includedMocs, - const std::map<std::string, std::string>& notIncludedMocs); - bool MocGenerateFile(const std::string& sourceFile, - const std::string& mocFileName, - const std::string& subDirPrefix); + void MocParseHeaderContent( + const std::string& absFilename, const std::string& contentText, + std::map<std::string, std::string>& mocsNotIncluded, + std::map<std::string, std::set<std::string> >& mocDepends); - // - Uic file generation + // -- Moc file generation + bool MocGenerateAll( + const std::map<std::string, std::string>& mocsIncluded, + const std::map<std::string, std::string>& mocsNotIncluded, + const std::map<std::string, std::set<std::string> >& mocDepends); + bool MocGenerateFile( + const std::string& sourceFile, const std::string& mocFileName, + const std::string& subDir, + const std::map<std::string, std::set<std::string> >& mocDepends); + + // -- Uic file generation + bool UicFindIncludedFile(std::string& absFile, const std::string& sourceFile, + const std::string& includeString); bool UicGenerateAll( const std::map<std::string, std::vector<std::string> >& includedUis); bool UicGenerateFile(const std::string& realName, const std::string& uiInputFile, const std::string& uiOutputFile); - // - Qrc file generation - bool QrcGenerateAll(); - bool QrcGenerateFile(const std::string& qrcInputFile, + // -- Rcc file generation + bool RccGenerateAll(); + bool RccGenerateFile(const std::string& qrcInputFile, const std::string& qrcOutputFile, bool unique_n); - // - Logging + // -- Logging void LogErrorNameCollision( const std::string& message, - const std::multimap<std::string, std::string>& collisions); - void LogBold(const std::string& message); - void LogInfo(const std::string& message); - void LogWarning(const std::string& message); - void LogError(const std::string& message); - void LogCommand(const std::vector<std::string>& command); - - // - Utility - bool NameCollisionTest(const std::map<std::string, std::string>& genFiles, - std::multimap<std::string, std::string>& collisions); - bool MakeParentDirectory(const std::string& filename); - - // - Target names + const std::multimap<std::string, std::string>& collisions) const; + void LogBold(const std::string& message) const; + void LogInfo(const std::string& message) const; + void LogWarning(const std::string& message) const; + void LogError(const std::string& message) const; + void LogCommand(const std::vector<std::string>& command) const; + + // -- Utility + bool NameCollisionTest( + const std::map<std::string, std::string>& genFiles, + std::multimap<std::string, std::string>& collisions) const; + std::string ChecksumedPath(const std::string& sourceFile, + const char* basePrefix, + const char* baseSuffix) const; + bool MakeParentDirectory(const char* logPrefix, + const std::string& filename) const; + bool FileDiffers(const std::string& filename, const std::string& content); + bool FileWrite(const char* logPrefix, const std::string& filename, + const std::string& content); + + bool RunCommand(const std::vector<std::string>& command, std::string& output, + bool verbose = true) const; + + bool FindHeader(std::string& header, const std::string& testBasePath) const; + + std::string MocFindHeader(const std::string& sourcePath, + const std::string& includeBase) const; + bool MocFindIncludedFile(std::string& absFile, const std::string& sourceFile, + const std::string& includeString) const; + + // -- Target names std::string OriginTargetName; std::string AutogenTargetName; - // - Directories + // -- Directories std::string ProjectSourceDir; std::string ProjectBinaryDir; std::string CurrentSourceDir; std::string CurrentBinaryDir; std::string AutogenBuildSubDir; - // - Qt environment + // -- Qt environment std::string QtMajorVersion; std::string MocExecutable; std::string UicExecutable; std::string RccExecutable; - // - File lists + // -- File lists std::vector<std::string> Sources; std::vector<std::string> Headers; - // - Moc - std::vector<std::string> SkipMoc; - std::string MocCompileDefinitionsStr; - std::string MocIncludesStr; - std::string MocOptionsStr; - std::string OutMocCppFilenameRel; - std::string OutMocCppFilenameAbs; - std::list<std::string> MocIncludes; - std::list<std::string> MocDefinitions; + std::vector<std::string> HeaderExtensions; + cmFilePathChecksum FPathChecksum; + // -- Settings + bool IncludeProjectDirsBefore; + bool Verbose; + bool ColorOutput; + std::string SettingsFile; + std::string SettingsStringMoc; + std::string SettingsStringUic; + std::string SettingsStringRcc; + // -- Moc + bool MocSettingsChanged; + bool MocPredefsChanged; + bool MocRelaxedMode; + bool MocRunFailed; + std::string MocCppFilenameRel; + std::string MocCppFilenameAbs; + std::string MocPredefsFileRel; + std::string MocPredefsFileAbs; + std::vector<std::string> MocSkipList; + std::vector<std::string> MocIncludePaths; + std::vector<std::string> MocIncludes; + std::vector<std::string> MocDefinitions; std::vector<std::string> MocOptions; - std::string MocSettingsString; - // - Uic - std::vector<std::string> SkipUic; + std::vector<std::string> MocPredefsCmd; + std::vector<MocDependFilter> MocDependFilters; + MocMacroFilter MocMacroFilters[2]; + cmsys::RegularExpression MocRegExpInclude; + // -- Uic + bool UicSettingsChanged; + bool UicRunFailed; + std::vector<std::string> UicSkipList; std::vector<std::string> UicTargetOptions; std::map<std::string, std::string> UicOptions; - std::string UicSettingsString; - // - Rcc + std::vector<std::string> UicSearchPaths; + cmsys::RegularExpression UicRegExpInclude; + // -- Rcc + bool RccSettingsChanged; + bool RccRunFailed; std::vector<std::string> RccSources; std::map<std::string, std::string> RccOptions; std::map<std::string, std::vector<std::string> > RccInputs; - std::string RccSettingsString; - // - Utility - cmFilePathChecksum fpathCheckSum; - cmsys::RegularExpression RegExpQObject; - cmsys::RegularExpression RegExpQGadget; - cmsys::RegularExpression RegExpMocInclude; - cmsys::RegularExpression RegExpUicInclude; - // - Flags - bool IncludeProjectDirsBefore; - bool Verbose; - bool ColorOutput; - bool RunMocFailed; - bool RunUicFailed; - bool RunRccFailed; - bool GenerateMocAll; - bool GenerateUicAll; - bool GenerateRccAll; - bool MocRelaxedMode; }; #endif diff --git a/Source/cmRST.cxx b/Source/cmRST.cxx index 355b8c4..938cad9 100644 --- a/Source/cmRST.cxx +++ b/Source/cmRST.cxx @@ -6,8 +6,8 @@ #include "cmSystemTools.h" #include "cmVersion.h" +#include "cmsys/FStream.hxx" #include <algorithm> -#include <cmsys/FStream.hxx> #include <ctype.h> #include <iterator> #include <stddef.h> @@ -96,14 +96,14 @@ void cmRST::ProcessModule(std::istream& is) if (line == "#") { this->ProcessLine(""); continue; - } else if (line.substr(0, 2) == "# ") { + } + if (line.substr(0, 2) == "# ") { this->ProcessLine(line.substr(2, line.npos)); continue; - } else { - rst = ""; - this->Reset(); - this->OutputLinePending = true; } + rst = ""; + this->Reset(); + this->OutputLinePending = true; } if (line == "#.rst:") { rst = "#"; diff --git a/Source/cmRST.h b/Source/cmRST.h index 2fedf4b..d1a8e27 100644 --- a/Source/cmRST.h +++ b/Source/cmRST.h @@ -3,9 +3,9 @@ #ifndef _cmRST_h #define _cmRST_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep -#include <cmsys/RegularExpression.hxx> +#include "cmsys/RegularExpression.hxx" #include <iosfwd> #include <map> #include <set> diff --git a/Source/cmRemoveCommand.h b/Source/cmRemoveCommand.h index c935f28..38223a5 100644 --- a/Source/cmRemoveCommand.h +++ b/Source/cmRemoveCommand.h @@ -3,7 +3,8 @@ #ifndef cmRemoveCommand_h #define cmRemoveCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmRemoveDefinitionsCommand.h b/Source/cmRemoveDefinitionsCommand.h index 2bcc12d..2f6c924 100644 --- a/Source/cmRemoveDefinitionsCommand.h +++ b/Source/cmRemoveDefinitionsCommand.h @@ -3,7 +3,8 @@ #ifndef cmRemoveDefinitionsCommand_h #define cmRemoveDefinitionsCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmReturnCommand.h b/Source/cmReturnCommand.h index 9496d67..ceed6b5 100644 --- a/Source/cmReturnCommand.h +++ b/Source/cmReturnCommand.h @@ -3,7 +3,8 @@ #ifndef cmReturnCommand_h #define cmReturnCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmRulePlaceholderExpander.h b/Source/cmRulePlaceholderExpander.h index 8329166..90b4119 100644 --- a/Source/cmRulePlaceholderExpander.h +++ b/Source/cmRulePlaceholderExpander.h @@ -4,7 +4,7 @@ #ifndef cmRulePlaceholderExpander_h #define cmRulePlaceholderExpander_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <map> #include <string> diff --git a/Source/cmScriptGenerator.cxx b/Source/cmScriptGenerator.cxx index 4c5ab64..3cf2537 100644 --- a/Source/cmScriptGenerator.cxx +++ b/Source/cmScriptGenerator.cxx @@ -4,7 +4,7 @@ #include "cmSystemTools.h" -#include <cmConfigure.h> +#include "cmConfigure.h" cmScriptGenerator::cmScriptGenerator( const std::string& config_var, @@ -90,8 +90,7 @@ void cmScriptGenerator::GenerateScript(std::ostream& os) this->GenerateScriptConfigs(os, indent); } -void cmScriptGenerator::GenerateScriptConfigs(std::ostream& os, - Indent const& indent) +void cmScriptGenerator::GenerateScriptConfigs(std::ostream& os, Indent indent) { if (this->ActionsPerConfig) { this->GenerateScriptActionsPerConfig(os, indent); @@ -100,8 +99,7 @@ void cmScriptGenerator::GenerateScriptConfigs(std::ostream& os, } } -void cmScriptGenerator::GenerateScriptActions(std::ostream& os, - Indent const& indent) +void cmScriptGenerator::GenerateScriptActions(std::ostream& os, Indent indent) { if (this->ActionsPerConfig) { // This is reached for single-configuration build generators in a @@ -112,7 +110,7 @@ void cmScriptGenerator::GenerateScriptActions(std::ostream& os, void cmScriptGenerator::GenerateScriptForConfig(std::ostream& /*unused*/, const std::string& /*unused*/, - Indent const& /*unused*/) + Indent /*unused*/) { // No actions for this generator. } @@ -138,7 +136,7 @@ bool cmScriptGenerator::GeneratesForConfig(const std::string& config) } void cmScriptGenerator::GenerateScriptActionsOnce(std::ostream& os, - Indent const& indent) + Indent indent) { if (this->Configurations.empty()) { // This rule is for all configurations. @@ -153,7 +151,7 @@ void cmScriptGenerator::GenerateScriptActionsOnce(std::ostream& os, } void cmScriptGenerator::GenerateScriptActionsPerConfig(std::ostream& os, - Indent const& indent) + Indent indent) { if (this->ConfigurationTypes->empty()) { // In a single-configuration generator there is only one action diff --git a/Source/cmScriptGenerator.h b/Source/cmScriptGenerator.h index a8f6fae..4023f3e 100644 --- a/Source/cmScriptGenerator.h +++ b/Source/cmScriptGenerator.h @@ -3,7 +3,7 @@ #ifndef cmScriptGenerator_h #define cmScriptGenerator_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <ostream> #include <string> @@ -35,7 +35,7 @@ private: int Level; }; inline std::ostream& operator<<(std::ostream& os, - cmScriptGeneratorIndent const& indent) + cmScriptGeneratorIndent indent) { indent.Write(os); return os; @@ -58,12 +58,12 @@ public: protected: typedef cmScriptGeneratorIndent Indent; virtual void GenerateScript(std::ostream& os); - virtual void GenerateScriptConfigs(std::ostream& os, Indent const& indent); - virtual void GenerateScriptActions(std::ostream& os, Indent const& indent); + virtual void GenerateScriptConfigs(std::ostream& os, Indent indent); + virtual void GenerateScriptActions(std::ostream& os, Indent indent); virtual void GenerateScriptForConfig(std::ostream& os, const std::string& config, - Indent const& indent); - virtual void GenerateScriptNoConfig(std::ostream&, Indent const&) {} + Indent indent); + virtual void GenerateScriptNoConfig(std::ostream&, Indent) {} virtual bool NeedsScriptNoConfig() const { return false; } // Test if this generator does something for a given configuration. @@ -87,8 +87,11 @@ protected: bool ActionsPerConfig; private: - void GenerateScriptActionsOnce(std::ostream& os, Indent const& indent); - void GenerateScriptActionsPerConfig(std::ostream& os, Indent const& indent); + cmScriptGenerator(cmScriptGenerator const&); + cmScriptGenerator& operator=(cmScriptGenerator const&); + + void GenerateScriptActionsOnce(std::ostream& os, Indent indent); + void GenerateScriptActionsPerConfig(std::ostream& os, Indent indent); }; #endif diff --git a/Source/cmSearchPath.h b/Source/cmSearchPath.h index 9ffa871..932022a 100644 --- a/Source/cmSearchPath.h +++ b/Source/cmSearchPath.h @@ -3,7 +3,7 @@ #ifndef cmSearchPath_h #define cmSearchPath_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <set> #include <string> diff --git a/Source/cmSeparateArgumentsCommand.h b/Source/cmSeparateArgumentsCommand.h index 1cbf56e..7edde48 100644 --- a/Source/cmSeparateArgumentsCommand.h +++ b/Source/cmSeparateArgumentsCommand.h @@ -3,7 +3,8 @@ #ifndef cmSeparateArgumentsCommand_h #define cmSeparateArgumentsCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmServerConnection.h b/Source/cmServerConnection.h index 3efe28d..1fabe37 100644 --- a/Source/cmServerConnection.h +++ b/Source/cmServerConnection.h @@ -2,6 +2,8 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #pragma once +#include "cmConfigure.h" // IWYU pragma: keep + #include <string> #include <vector> diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx index a5c1a23..8227ab7 100644 --- a/Source/cmServerProtocol.cxx +++ b/Source/cmServerProtocol.cxx @@ -763,9 +763,11 @@ static Json::Value DumpTarget(cmGeneratorTarget* target, if (target->HaveWellDefinedOutputFiles()) { Json::Value artifacts = Json::arrayValue; - artifacts.append(target->GetFullPath(config, false)); + artifacts.append( + target->GetFullPath(config, cmStateEnums::RuntimeBinaryArtifact)); if (target->IsDLLPlatform()) { - artifacts.append(target->GetFullPath(config, true)); + artifacts.append( + target->GetFullPath(config, cmStateEnums::ImportLibraryArtifact)); const cmGeneratorTarget::OutputInfo* output = target->GetOutputInfo(config); if (output && !output->PdbDir.empty()) { diff --git a/Source/cmSetCommand.h b/Source/cmSetCommand.h index 190092a..1c67bf9 100644 --- a/Source/cmSetCommand.h +++ b/Source/cmSetCommand.h @@ -3,7 +3,8 @@ #ifndef cmSetCommand_h #define cmSetCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmSetDirectoryPropertiesCommand.h b/Source/cmSetDirectoryPropertiesCommand.h index 854ad43..e04de6e 100644 --- a/Source/cmSetDirectoryPropertiesCommand.h +++ b/Source/cmSetDirectoryPropertiesCommand.h @@ -3,7 +3,8 @@ #ifndef cmSetDirectoryPropertiesCommand_h #define cmSetDirectoryPropertiesCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmSetPropertyCommand.h b/Source/cmSetPropertyCommand.h index fd7c922..3657f63 100644 --- a/Source/cmSetPropertyCommand.h +++ b/Source/cmSetPropertyCommand.h @@ -3,7 +3,8 @@ #ifndef cmSetsPropertiesCommand_h #define cmSetsPropertiesCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <set> #include <string> #include <vector> diff --git a/Source/cmSetSourceFilesPropertiesCommand.h b/Source/cmSetSourceFilesPropertiesCommand.h index 8fa12c7..7dce437 100644 --- a/Source/cmSetSourceFilesPropertiesCommand.h +++ b/Source/cmSetSourceFilesPropertiesCommand.h @@ -3,7 +3,8 @@ #ifndef cmSetSourceFilesPropertiesCommand_h #define cmSetSourceFilesPropertiesCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmSetTargetPropertiesCommand.cxx b/Source/cmSetTargetPropertiesCommand.cxx index da26972..6425913 100644 --- a/Source/cmSetTargetPropertiesCommand.cxx +++ b/Source/cmSetTargetPropertiesCommand.cxx @@ -32,9 +32,8 @@ bool cmSetTargetPropertiesCommand::InitialPass( } propertyPairs.insert(propertyPairs.end(), j, args.end()); break; - } else { - numFiles++; } + numFiles++; } if (propertyPairs.empty()) { this->SetError("called with illegal arguments, maybe missing " diff --git a/Source/cmSetTargetPropertiesCommand.h b/Source/cmSetTargetPropertiesCommand.h index c3c0d06..bb34d1e 100644 --- a/Source/cmSetTargetPropertiesCommand.h +++ b/Source/cmSetTargetPropertiesCommand.h @@ -3,7 +3,8 @@ #ifndef cmSetTargetsPropertiesCommand_h #define cmSetTargetsPropertiesCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmSetTestsPropertiesCommand.cxx b/Source/cmSetTestsPropertiesCommand.cxx index 4fd379f..e27c675 100644 --- a/Source/cmSetTestsPropertiesCommand.cxx +++ b/Source/cmSetTestsPropertiesCommand.cxx @@ -32,9 +32,8 @@ bool cmSetTestsPropertiesCommand::InitialPass( } propertyPairs.insert(propertyPairs.end(), j, args.end()); break; - } else { - numFiles++; } + numFiles++; } if (propertyPairs.empty()) { this->SetError("called with illegal arguments, maybe " diff --git a/Source/cmSetTestsPropertiesCommand.h b/Source/cmSetTestsPropertiesCommand.h index 45aed79..56a864f 100644 --- a/Source/cmSetTestsPropertiesCommand.h +++ b/Source/cmSetTestsPropertiesCommand.h @@ -3,7 +3,8 @@ #ifndef cmSetTestsPropertiesCommand_h #define cmSetTestsPropertiesCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmSiteNameCommand.cxx b/Source/cmSiteNameCommand.cxx index 4322a6d..7eace26 100644 --- a/Source/cmSiteNameCommand.cxx +++ b/Source/cmSiteNameCommand.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmSiteNameCommand.h" -#include <cmsys/RegularExpression.hxx> +#include "cmsys/RegularExpression.hxx" #include "cmMakefile.h" #include "cmStateTypes.h" diff --git a/Source/cmSiteNameCommand.h b/Source/cmSiteNameCommand.h index 01023b9..c7425f6 100644 --- a/Source/cmSiteNameCommand.h +++ b/Source/cmSiteNameCommand.h @@ -3,7 +3,8 @@ #ifndef cmSiteNameCommand_h #define cmSiteNameCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h index bbcc300..0be659c 100644 --- a/Source/cmSourceFile.h +++ b/Source/cmSourceFile.h @@ -3,7 +3,7 @@ #ifndef cmSourceFile_h #define cmSourceFile_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmPropertyMap.h" #include "cmSourceFileLocation.h" diff --git a/Source/cmSourceFileLocation.cxx b/Source/cmSourceFileLocation.cxx index 4e0880e..86711d7 100644 --- a/Source/cmSourceFileLocation.cxx +++ b/Source/cmSourceFileLocation.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmSourceFileLocation.h" -#include <cmConfigure.h> +#include "cmConfigure.h" #include "cmAlgorithms.h" #include "cmGlobalGenerator.h" diff --git a/Source/cmSourceFileLocation.h b/Source/cmSourceFileLocation.h index aa2e6c7..6dbc2da 100644 --- a/Source/cmSourceFileLocation.h +++ b/Source/cmSourceFileLocation.h @@ -3,7 +3,7 @@ #ifndef cmSourceFileLocation_h #define cmSourceFileLocation_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <string> diff --git a/Source/cmSourceGroup.h b/Source/cmSourceGroup.h index 545da81..97affed 100644 --- a/Source/cmSourceGroup.h +++ b/Source/cmSourceGroup.h @@ -3,9 +3,9 @@ #ifndef cmSourceGroup_h #define cmSourceGroup_h -#include <cmConfigure.h> +#include "cmConfigure.h" -#include <cmsys/RegularExpression.hxx> +#include "cmsys/RegularExpression.hxx" #include <set> #include <string> #include <vector> diff --git a/Source/cmSourceGroupCommand.cxx b/Source/cmSourceGroupCommand.cxx index 23048bf..f54d777 100644 --- a/Source/cmSourceGroupCommand.cxx +++ b/Source/cmSourceGroupCommand.cxx @@ -6,6 +6,7 @@ #include <iterator> #include <set> #include <sstream> +#include <stddef.h> #include "cmMakefile.h" #include "cmSourceGroup.h" diff --git a/Source/cmSourceGroupCommand.h b/Source/cmSourceGroupCommand.h index 5549096..3086177 100644 --- a/Source/cmSourceGroupCommand.h +++ b/Source/cmSourceGroupCommand.h @@ -3,7 +3,8 @@ #ifndef cmSourceGroupCommand_h #define cmSourceGroupCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h deleted file mode 100644 index a2047af..0000000 --- a/Source/cmStandardIncludes.h +++ /dev/null @@ -1,53 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -/** - * Include header files as a function of the build process, compiler, - * and operating system. - */ -#ifndef cmStandardIncludes_h -#define cmStandardIncludes_h - -#include <cmConfigure.h> - -// Provide fixed-size integer types. -#include <cm_kwiml.h> - -#include <fstream> -#include <iomanip> -#include <iostream> -#include <sstream> - -// we must have stl with the standard include style -#include <algorithm> -#include <functional> -#include <iterator> -#include <map> -#include <set> -#include <string> -#include <vector> - -// include the "c" string header -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#if defined(_MSC_VER) -typedef unsigned short mode_t; -#else -#include <sys/types.h> -#endif - -// use this class to shrink the size of symbols in .o files -// std::string is really basic_string<....lots of stuff....> -// when combined with a map or set, the symbols can be > 2000 chars! -#include <cmsys/String.hxx> -// typedef cmsys::String std::string; - -/* Poison this operator to avoid common mistakes. */ -extern void operator<<(std::ostream&, const std::ostringstream&); - -#include "cmCustomCommandLines.h" -#include "cmDocumentationEntry.h" -#include "cmTargetLinkLibraryType.h" - -#endif diff --git a/Source/cmStandardLexer.h b/Source/cmStandardLexer.h index b9adee5..c9f42e4 100644 --- a/Source/cmStandardLexer.h +++ b/Source/cmStandardLexer.h @@ -3,7 +3,7 @@ #ifndef cmStandardLexer_h #define cmStandardLexer_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep /* Disable some warnings. */ #if defined(_MSC_VER) @@ -50,7 +50,7 @@ #define YY_NO_UNPUT 1 #define ECHO -#include <cm_kwiml.h> +#include "cm_kwiml.h" typedef KWIML_INT_int8_t flex_int8_t; typedef KWIML_INT_uint8_t flex_uint8_t; typedef KWIML_INT_int16_t flex_int16_t; diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 18d5ea1..aca0358 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -2,9 +2,9 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmState.h" +#include "cmsys/RegularExpression.hxx" #include <algorithm> #include <assert.h> -#include <cmsys/RegularExpression.hxx> #include <string.h> #include <utility> @@ -20,6 +20,7 @@ cmState::cmState() : IsInTryCompile(false) + , IsGeneratorMultiConfig(false) , WindowsShell(false) , WindowsVSIDE(false) , WatcomWMake(false) @@ -364,6 +365,16 @@ void cmState::SetIsInTryCompile(bool b) this->IsInTryCompile = b; } +bool cmState::GetIsGeneratorMultiConfig() const +{ + return this->IsGeneratorMultiConfig; +} + +void cmState::SetIsGeneratorMultiConfig(bool b) +{ + this->IsGeneratorMultiConfig = b; +} + void cmState::RenameCommand(std::string const& oldName, std::string const& newName) { @@ -481,6 +492,9 @@ const char* cmState::GetGlobalProperty(const std::string& prop) } else if (prop == "IN_TRY_COMPILE") { this->SetGlobalProperty("IN_TRY_COMPILE", this->IsInTryCompile ? "1" : "0"); + } else if (prop == "GENERATOR_IS_MULTI_CONFIG") { + this->SetGlobalProperty("GENERATOR_IS_MULTI_CONFIG", + this->IsGeneratorMultiConfig ? "1" : "0"); } else if (prop == "ENABLED_LANGUAGES") { std::string langs; langs = cmJoin(this->EnabledLanguages, ";"); diff --git a/Source/cmState.h b/Source/cmState.h index 41ffcdc..d2af5ce 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -3,7 +3,7 @@ #ifndef cmState_h #define cmState_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <map> #include <set> @@ -116,6 +116,9 @@ public: bool GetIsInTryCompile() const; void SetIsInTryCompile(bool b); + bool GetIsGeneratorMultiConfig() const; + void SetIsGeneratorMultiConfig(bool b); + cmCommand* GetCommand(std::string const& name) const; void AddCommand(cmCommand* command); void RemoveUnscriptableCommands(); @@ -174,6 +177,7 @@ private: std::string SourceDirectory; std::string BinaryDirectory; bool IsInTryCompile; + bool IsGeneratorMultiConfig; bool WindowsShell; bool WindowsVSIDE; bool WatcomWMake; diff --git a/Source/cmStateDirectory.h b/Source/cmStateDirectory.h index 8accc8e..79bb369 100644 --- a/Source/cmStateDirectory.h +++ b/Source/cmStateDirectory.h @@ -4,7 +4,7 @@ #ifndef cmStateDirectory_h #define cmStateDirectory_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmStatePrivate.h b/Source/cmStatePrivate.h index 20700f2..f36ee37 100644 --- a/Source/cmStatePrivate.h +++ b/Source/cmStatePrivate.h @@ -4,7 +4,7 @@ #ifndef cmStatePrivate_h #define cmStatePrivate_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> @@ -57,11 +57,6 @@ struct cmStateDetail::PolicyStackEntry : public cmPolicies::PolicyMap , Weak(w) { } - PolicyStackEntry(PolicyStackEntry const& r) - : derived(r) - , Weak(r.Weak) - { - } bool Weak; }; diff --git a/Source/cmStateSnapshot.cxx b/Source/cmStateSnapshot.cxx index c6288a5..d2c9d73 100644 --- a/Source/cmStateSnapshot.cxx +++ b/Source/cmStateSnapshot.cxx @@ -18,6 +18,10 @@ #include "cmVersion.h" #include "cmake.h" +#if !defined(_WIN32) +#include <sys/utsname.h> +#endif + #if defined(__CYGWIN__) #include "cmSystemTools.h" #endif @@ -298,9 +302,15 @@ void cmStateSnapshot::SetDefaultDefinitions() #if defined(_WIN32) this->SetDefinition("WIN32", "1"); this->SetDefinition("CMAKE_HOST_WIN32", "1"); + this->SetDefinition("CMAKE_HOST_SYSTEM_NAME", "Windows"); #else this->SetDefinition("UNIX", "1"); this->SetDefinition("CMAKE_HOST_UNIX", "1"); + + struct utsname uts_name; + if (uname(&uts_name) >= 0) { + this->SetDefinition("CMAKE_HOST_SYSTEM_NAME", uts_name.sysname); + } #endif #if defined(__CYGWIN__) std::string legacy; diff --git a/Source/cmStateSnapshot.h b/Source/cmStateSnapshot.h index 72d0349..2e82ef4 100644 --- a/Source/cmStateSnapshot.h +++ b/Source/cmStateSnapshot.h @@ -4,7 +4,7 @@ #ifndef cmStateSnapshot_h #define cmStateSnapshot_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmStateTypes.h b/Source/cmStateTypes.h index 2c974c1..7d6158e 100644 --- a/Source/cmStateTypes.h +++ b/Source/cmStateTypes.h @@ -4,7 +4,7 @@ #ifndef cmStateTypes_h #define cmStateTypes_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include "cmLinkedTree.h" @@ -27,6 +27,9 @@ enum SnapshotType VariableScopeType }; +// There are multiple overlapping ranges represented here. Be aware that adding +// a value to this enumeration may cause failures in numerous places which +// assume details about the ordering. enum TargetType { EXECUTABLE, @@ -50,6 +53,12 @@ enum CacheEntryType STATIC, UNINITIALIZED }; + +enum ArtifactType +{ + RuntimeBinaryArtifact, + ImportLibraryArtifact +}; } #endif diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index eb94080..d6907e3 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmStringCommand.h" -#include <cmsys/RegularExpression.hxx> +#include "cmsys/RegularExpression.hxx" #include <ctype.h> #include <sstream> #include <stdio.h> diff --git a/Source/cmStringCommand.h b/Source/cmStringCommand.h index c63bc3f..89ecb12 100644 --- a/Source/cmStringCommand.h +++ b/Source/cmStringCommand.h @@ -3,7 +3,8 @@ #ifndef cmStringCommand_h #define cmStringCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmSubdirCommand.h b/Source/cmSubdirCommand.h index ce1f876..ce2168d 100644 --- a/Source/cmSubdirCommand.h +++ b/Source/cmSubdirCommand.h @@ -3,7 +3,8 @@ #ifndef cmSubdirCommand_h #define cmSubdirCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmSubdirDependsCommand.cxx b/Source/cmSubdirDependsCommand.cxx index 9259836..0bb2c0a 100644 --- a/Source/cmSubdirDependsCommand.cxx +++ b/Source/cmSubdirDependsCommand.cxx @@ -2,15 +2,10 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmSubdirDependsCommand.h" -#include "cmPolicies.h" - class cmExecutionStatus; bool cmSubdirDependsCommand::InitialPass(std::vector<std::string> const&, cmExecutionStatus&) { - this->Disallowed( - cmPolicies::CMP0029, - "The subdir_depends command should not be called; see CMP0029."); return true; } diff --git a/Source/cmSubdirDependsCommand.h b/Source/cmSubdirDependsCommand.h index 80ff24f..ae8fbaf 100644 --- a/Source/cmSubdirDependsCommand.h +++ b/Source/cmSubdirDependsCommand.h @@ -3,7 +3,8 @@ #ifndef cmSubdirDependsCommand_h #define cmSubdirDependsCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 9efc13b..6d620d9 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -4,11 +4,12 @@ #include "cmAlgorithms.h" #include "cmProcessOutput.h" +#include "cm_sys_stat.h" #if defined(CMAKE_BUILD_WITH_CMAKE) #include "cmArchiveWrite.h" #include "cmLocale.h" -#include <cm_libarchive.h> +#include "cm_libarchive.h" #ifndef __LA_INT64_T #define __LA_INT64_T la_int64_t #endif @@ -26,15 +27,14 @@ #include "cmMachO.h" #endif +#include "cmsys/Directory.hxx" +#include "cmsys/Encoding.hxx" +#include "cmsys/FStream.hxx" +#include "cmsys/RegularExpression.hxx" +#include "cmsys/System.h" +#include "cmsys/Terminal.h" #include <algorithm> #include <assert.h> -#include <cmsys/Directory.hxx> -#include <cmsys/Encoding.hxx> -#include <cmsys/FStream.hxx> -#include <cmsys/RegularExpression.hxx> -#include <cmsys/System.h> -#include <cmsys/SystemTools.hxx> -#include <cmsys/Terminal.h> #include <ctype.h> #include <errno.h> #include <iostream> @@ -43,8 +43,8 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <sys/stat.h> #include <time.h> +#include <utility> #if defined(_WIN32) #include <windows.h> @@ -570,6 +570,46 @@ std::vector<std::string> cmSystemTools::ParseArguments(const char* command) return args; } +size_t cmSystemTools::CalculateCommandLineLengthLimit() +{ + size_t sz = +#ifdef _WIN32 + // There's a maximum of 65536 bytes and thus 32768 WCHARs on Windows + // However, cmd.exe itself can only handle 8191 WCHARs and Ninja for + // example uses it to spawn processes. + size_t(8191); +#elif defined(__linux) + // MAX_ARG_STRLEN is the maximum length of a string permissible for + // the execve() syscall on Linux. It's defined as (PAGE_SIZE * 32) + // in Linux's binfmts.h + static_cast<size_t>(sysconf(_SC_PAGESIZE) * 32); +#else + size_t(0); +#endif + +#if defined(_SC_ARG_MAX) + // ARG_MAX is the maximum size of the command and environment + // that can be passed to the exec functions on UNIX. + // The value in limits.h does not need to be present and may + // depend upon runtime memory constraints, hence sysconf() + // should be used to query it. + long szArgMax = sysconf(_SC_ARG_MAX); + // A return value of -1 signifies an undetermined limit, but + // it does not imply an infinite limit, and thus is ignored. + if (szArgMax != -1) { + // We estimate the size of the environment block to be 1000. + // This isn't accurate at all, but leaves some headroom. + szArgMax = szArgMax < 1000 ? 0 : szArgMax - 1000; +#if defined(_WIN32) || defined(__linux) + sz = std::min(sz, static_cast<size_t>(szArgMax)); +#else + sz = static_cast<size_t>(szArgMax); +#endif + } +#endif + return sz; +} + bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command, std::string* captureStdOut, std::string* captureStdErr, int* retVal, @@ -617,8 +657,6 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command, while ((pipe = cmsysProcess_WaitForData(cp, &data, &length, CM_NULLPTR)) > 0) { // Translate NULL characters in the output into valid text. - // Visual Studio 7 puts these characters in the output of its - // build process. for (int i = 0; i < length; ++i) { if (data[i] == '\0') { data[i] = ' '; @@ -1669,7 +1707,8 @@ int cmSystemTools::WaitForLine(cmsysProcess* process, std::string& line, for (; outiter != out.end(); ++outiter) { if ((*outiter == '\r') && ((outiter + 1) == out.end())) { break; - } else if (*outiter == '\n' || *outiter == '\0') { + } + if (*outiter == '\n' || *outiter == '\0') { std::vector<char>::size_type length = outiter - out.begin(); if (length > 1 && *(outiter - 1) == '\r') { --length; @@ -1686,7 +1725,8 @@ int cmSystemTools::WaitForLine(cmsysProcess* process, std::string& line, for (; erriter != err.end(); ++erriter) { if ((*erriter == '\r') && ((erriter + 1) == err.end())) { break; - } else if (*erriter == '\n' || *erriter == '\0') { + } + if (*erriter == '\n' || *erriter == '\0') { std::vector<char>::size_type length = erriter - err.begin(); if (length > 1 && *(erriter - 1) == '\r') { --length; @@ -1978,6 +2018,7 @@ void cmSystemTools::FindCMakeResources(const char* argv0) // ??? } #endif + exe_dir = cmSystemTools::GetActualCaseForPath(exe_dir); cmSystemToolsCMakeCommand = exe_dir; cmSystemToolsCMakeCommand += "/cmake"; cmSystemToolsCMakeCommand += cmSystemTools::GetExecutableExtension(); @@ -2015,8 +2056,7 @@ void cmSystemTools::FindCMakeResources(const char* argv0) // Install tree has // - "<prefix><CMAKE_BIN_DIR>/cmake" // - "<prefix><CMAKE_DATA_DIR>" - const std::string actual_case = cmSystemTools::GetActualCaseForPath(exe_dir); - if (cmHasSuffix(actual_case, CMAKE_BIN_DIR)) { + if (cmHasSuffix(exe_dir, CMAKE_BIN_DIR)) { std::string const prefix = exe_dir.substr(0, exe_dir.size() - strlen(CMAKE_BIN_DIR)); cmSystemToolsCMakeRoot = prefix + CMAKE_DATA_DIR; @@ -2585,29 +2625,28 @@ bool cmSystemTools::RemoveRPath(std::string const& file, std::string* emsg, it = dentries.erase(it); entriesErased++; continue; - } else { - if (cmELF::TagMipsRldMapRel != 0 && - it->first == cmELF::TagMipsRldMapRel) { - // Background: debuggers need to know the "linker map" which contains - // the addresses each dynamic object is loaded at. Most arches use - // the DT_DEBUG tag which the dynamic linker writes to (directly) and - // contain the location of the linker map, however on MIPS the - // .dynamic section is always read-only so this is not possible. MIPS - // objects instead contain a DT_MIPS_RLD_MAP tag which contains the - // address where the dyanmic linker will write to (an indirect - // version of DT_DEBUG). Since this doesn't work when using PIE, a - // relative equivalent was created - DT_MIPS_RLD_MAP_REL. Since this - // version contains a relative offset, moving it changes the - // calculated address. This may cause the dyanmic linker to write - // into memory it should not be changing. - // - // To fix this, we adjust the value of DT_MIPS_RLD_MAP_REL here. If - // we move it up by n bytes, we add n bytes to the value of this tag. - it->second += entriesErased * sizeof_dentry; - } - - it++; } + if (cmELF::TagMipsRldMapRel != 0 && + it->first == cmELF::TagMipsRldMapRel) { + // Background: debuggers need to know the "linker map" which contains + // the addresses each dynamic object is loaded at. Most arches use + // the DT_DEBUG tag which the dynamic linker writes to (directly) and + // contain the location of the linker map, however on MIPS the + // .dynamic section is always read-only so this is not possible. MIPS + // objects instead contain a DT_MIPS_RLD_MAP tag which contains the + // address where the dyanmic linker will write to (an indirect + // version of DT_DEBUG). Since this doesn't work when using PIE, a + // relative equivalent was created - DT_MIPS_RLD_MAP_REL. Since this + // version contains a relative offset, moving it changes the + // calculated address. This may cause the dyanmic linker to write + // into memory it should not be changing. + // + // To fix this, we adjust the value of DT_MIPS_RLD_MAP_REL here. If + // we move it up by n bytes, we add n bytes to the value of this tag. + it->second += entriesErased * sizeof_dentry; + } + + it++; } // Encode new entries list diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 10e8280..3ba2c22 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -3,21 +3,15 @@ #ifndef cmSystemTools_h #define cmSystemTools_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep -#include <cmProcessOutput.h> -#include <cmsys/Process.h> -#include <cmsys/SystemTools.hxx> +#include "cmProcessOutput.h" +#include "cmsys/Process.h" +#include "cmsys/SystemTools.hxx" // IWYU pragma: export #include <stddef.h> #include <string> #include <vector> -#if defined(_MSC_VER) -typedef unsigned short mode_t; -#else -#include <sys/types.h> -#endif - class cmSystemToolsFileTime; /** \class cmSystemTools @@ -259,6 +253,8 @@ public: static void ParseUnixCommandLine(const char* command, std::vector<std::string>& args); + static size_t CalculateCommandLineLengthLimit(); + static void EnableMessages() { s_DisableMessages = false; } static void DisableMessages() { s_DisableMessages = true; } static void DisableRunCommandOutput() { s_DisableRunCommandOutput = true; } @@ -385,9 +381,12 @@ public: { public: SaveRestoreEnvironment(); - virtual ~SaveRestoreEnvironment(); + ~SaveRestoreEnvironment(); private: + SaveRestoreEnvironment(SaveRestoreEnvironment const&); + SaveRestoreEnvironment& operator=(SaveRestoreEnvironment const&); + std::vector<std::string> Env; }; #endif diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index fe3472d..f675833 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2,9 +2,9 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmTarget.h" +#include "cmsys/RegularExpression.hxx" #include <algorithm> #include <assert.h> -#include <cmsys/RegularExpression.hxx> #include <map> #include <set> #include <sstream> @@ -35,7 +35,7 @@ const char* cmTargetPropertyComputer::ComputeLocationForBuild<cmTarget>( { static std::string loc; if (tgt->IsImported()) { - loc = tgt->ImportedGetFullPath("", false); + loc = tgt->ImportedGetFullPath("", cmStateEnums::RuntimeBinaryArtifact); return loc.c_str(); } @@ -54,7 +54,8 @@ const char* cmTargetPropertyComputer::ComputeLocation<cmTarget>( { static std::string loc; if (tgt->IsImported()) { - loc = tgt->ImportedGetFullPath(config, false); + loc = + tgt->ImportedGetFullPath(config, cmStateEnums::RuntimeBinaryArtifact); return loc.c_str(); } @@ -63,7 +64,7 @@ const char* cmTargetPropertyComputer::ComputeLocation<cmTarget>( gg->CreateGenerationObjects(); } cmGeneratorTarget* gt = gg->FindGeneratorTarget(tgt->GetName()); - loc = gt->GetFullPath(config, false); + loc = gt->GetFullPath(config, cmStateEnums::RuntimeBinaryArtifact); return loc.c_str(); } @@ -230,6 +231,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, this->SetPropertyDefault("INSTALL_NAME_DIR", CM_NULLPTR); this->SetPropertyDefault("INSTALL_RPATH", ""); this->SetPropertyDefault("INSTALL_RPATH_USE_LINK_PATH", "OFF"); + this->SetPropertyDefault("INTERPROCEDURAL_OPTIMIZATION", CM_NULLPTR); this->SetPropertyDefault("SKIP_BUILD_RPATH", "OFF"); this->SetPropertyDefault("BUILD_WITH_INSTALL_RPATH", "OFF"); this->SetPropertyDefault("ARCHIVE_OUTPUT_DIRECTORY", CM_NULLPTR); @@ -245,14 +247,17 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, this->SetPropertyDefault("AUTOMOC", CM_NULLPTR); this->SetPropertyDefault("AUTOUIC", CM_NULLPTR); this->SetPropertyDefault("AUTORCC", CM_NULLPTR); + this->SetPropertyDefault("AUTOMOC_DEPEND_FILTERS", CM_NULLPTR); this->SetPropertyDefault("AUTOMOC_MOC_OPTIONS", CM_NULLPTR); this->SetPropertyDefault("AUTOUIC_OPTIONS", CM_NULLPTR); + this->SetPropertyDefault("AUTOUIC_SEARCH_PATHS", CM_NULLPTR); this->SetPropertyDefault("AUTORCC_OPTIONS", CM_NULLPTR); this->SetPropertyDefault("LINK_DEPENDS_NO_SHARED", CM_NULLPTR); this->SetPropertyDefault("LINK_INTERFACE_LIBRARIES", CM_NULLPTR); this->SetPropertyDefault("WIN32_EXECUTABLE", CM_NULLPTR); this->SetPropertyDefault("MACOSX_BUNDLE", CM_NULLPTR); this->SetPropertyDefault("MACOSX_RPATH", CM_NULLPTR); + this->SetPropertyDefault("BUILD_WITH_INSTALL_NAME_DIR", CM_NULLPTR); this->SetPropertyDefault("C_CLANG_TIDY", CM_NULLPTR); this->SetPropertyDefault("C_COMPILER_LAUNCHER", CM_NULLPTR); this->SetPropertyDefault("C_CPPLINT", CM_NULLPTR); @@ -287,13 +292,10 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, if (this->GetType() != cmStateEnums::UTILITY) { const char* configProps[] = { /* clang-format needs this comment to break after the opening brace */ - "ARCHIVE_OUTPUT_DIRECTORY_", - "LIBRARY_OUTPUT_DIRECTORY_", - "RUNTIME_OUTPUT_DIRECTORY_", - "PDB_OUTPUT_DIRECTORY_", - "COMPILE_PDB_OUTPUT_DIRECTORY_", - "MAP_IMPORTED_CONFIG_", - CM_NULLPTR + "ARCHIVE_OUTPUT_DIRECTORY_", "LIBRARY_OUTPUT_DIRECTORY_", + "RUNTIME_OUTPUT_DIRECTORY_", "PDB_OUTPUT_DIRECTORY_", + "COMPILE_PDB_OUTPUT_DIRECTORY_", "MAP_IMPORTED_CONFIG_", + "INTERPROCEDURAL_OPTIMIZATION_", CM_NULLPTR }; for (std::vector<std::string>::iterator ci = configNames.begin(); ci != configNames.end(); ++ci) { @@ -939,6 +941,14 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) } else if (cmHasLiteralPrefix(prop, "IMPORTED_LIBNAME") && !this->CheckImportedLibName(prop, value ? value : "")) { /* error was reported by check method */ + } else if (prop == "CUDA_PTX_COMPILATION" && + this->GetType() != cmStateEnums::OBJECT_LIBRARY) { + std::ostringstream e; + e << "CUDA_PTX_COMPILATION property can only be applied to OBJECT " + "targets (\"" + << this->Name << "\")\n"; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); + return; } else { this->Properties.SetProperty(prop, value); } @@ -1293,68 +1303,96 @@ bool cmTarget::GetPropertyAsBool(const std::string& prop) const return cmSystemTools::IsOn(this->GetProperty(prop)); } -const char* cmTarget::GetSuffixVariableInternal(bool implib) const +const char* cmTarget::GetSuffixVariableInternal( + cmStateEnums::ArtifactType artifact) const { switch (this->GetType()) { case cmStateEnums::STATIC_LIBRARY: return "CMAKE_STATIC_LIBRARY_SUFFIX"; case cmStateEnums::SHARED_LIBRARY: - return (implib ? "CMAKE_IMPORT_LIBRARY_SUFFIX" - : "CMAKE_SHARED_LIBRARY_SUFFIX"); + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + return "CMAKE_SHARED_LIBRARY_SUFFIX"; + case cmStateEnums::ImportLibraryArtifact: + return "CMAKE_IMPORT_LIBRARY_SUFFIX"; + } + break; case cmStateEnums::MODULE_LIBRARY: - return (implib ? "CMAKE_IMPORT_LIBRARY_SUFFIX" - : "CMAKE_SHARED_MODULE_SUFFIX"); + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + return "CMAKE_SHARED_MODULE_SUFFIX"; + case cmStateEnums::ImportLibraryArtifact: + return "CMAKE_IMPORT_LIBRARY_SUFFIX"; + } + break; case cmStateEnums::EXECUTABLE: - return (implib - ? "CMAKE_IMPORT_LIBRARY_SUFFIX" - // Android GUI application packages store the native - // binary as a shared library. - : (this->IsAndroid && this->GetPropertyAsBool("ANDROID_GUI") - ? "CMAKE_SHARED_LIBRARY_SUFFIX" - : "CMAKE_EXECUTABLE_SUFFIX")); + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + // Android GUI application packages store the native + // binary as a shared library. + return (this->IsAndroid && this->GetPropertyAsBool("ANDROID_GUI") + ? "CMAKE_SHARED_LIBRARY_SUFFIX" + : "CMAKE_EXECUTABLE_SUFFIX"); + case cmStateEnums::ImportLibraryArtifact: + return "CMAKE_IMPORT_LIBRARY_SUFFIX"; + } + break; default: break; } return ""; } -const char* cmTarget::GetPrefixVariableInternal(bool implib) const +const char* cmTarget::GetPrefixVariableInternal( + cmStateEnums::ArtifactType artifact) const { switch (this->GetType()) { case cmStateEnums::STATIC_LIBRARY: return "CMAKE_STATIC_LIBRARY_PREFIX"; case cmStateEnums::SHARED_LIBRARY: - return (implib ? "CMAKE_IMPORT_LIBRARY_PREFIX" - : "CMAKE_SHARED_LIBRARY_PREFIX"); + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + return "CMAKE_SHARED_LIBRARY_PREFIX"; + case cmStateEnums::ImportLibraryArtifact: + return "CMAKE_IMPORT_LIBRARY_PREFIX"; + } + break; case cmStateEnums::MODULE_LIBRARY: - return (implib ? "CMAKE_IMPORT_LIBRARY_PREFIX" - : "CMAKE_SHARED_MODULE_PREFIX"); + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + return "CMAKE_SHARED_MODULE_PREFIX"; + case cmStateEnums::ImportLibraryArtifact: + return "CMAKE_IMPORT_LIBRARY_PREFIX"; + } + break; case cmStateEnums::EXECUTABLE: - return (implib - ? "CMAKE_IMPORT_LIBRARY_PREFIX" - // Android GUI application packages store the native - // binary as a shared library. - : (this->IsAndroid && this->GetPropertyAsBool("ANDROID_GUI") - ? "CMAKE_SHARED_LIBRARY_PREFIX" - : "")); + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + // Android GUI application packages store the native + // binary as a shared library. + return (this->IsAndroid && this->GetPropertyAsBool("ANDROID_GUI") + ? "CMAKE_SHARED_LIBRARY_PREFIX" + : ""); + case cmStateEnums::ImportLibraryArtifact: + return "CMAKE_IMPORT_LIBRARY_PREFIX"; + } + break; default: break; } return ""; } -std::string cmTarget::ImportedGetFullPath(const std::string& config, - bool pimplib) const +std::string cmTarget::ImportedGetFullPath( + const std::string& config, cmStateEnums::ArtifactType artifact) const { assert(this->IsImported()); // Lookup/compute/cache the import information for this // configuration. - std::string config_upper; - if (!config.empty()) { - config_upper = cmSystemTools::UpperCase(config); - } else { - config_upper = "NOCONFIG"; + std::string desired_config = config; + if (config.empty()) { + desired_config = "NOCONFIG"; } std::string result; @@ -1364,33 +1402,38 @@ std::string cmTarget::ImportedGetFullPath(const std::string& config, std::string suffix; if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY && - this->GetMappedConfig(config_upper, &loc, &imp, suffix)) { - if (!pimplib) { - if (loc) { - result = loc; - } else { - std::string impProp = "IMPORTED_LOCATION"; - impProp += suffix; - if (const char* config_location = this->GetProperty(impProp)) { - result = config_location; - } else if (const char* location = - this->GetProperty("IMPORTED_LOCATION")) { - result = location; + this->GetMappedConfig(desired_config, &loc, &imp, suffix)) { + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + if (loc) { + result = loc; + } else { + std::string impProp = "IMPORTED_LOCATION"; + impProp += suffix; + if (const char* config_location = this->GetProperty(impProp)) { + result = config_location; + } else if (const char* location = + this->GetProperty("IMPORTED_LOCATION")) { + result = location; + } } - } - } else { - if (imp) { - result = imp; - } else if (this->GetType() == cmStateEnums::SHARED_LIBRARY || - this->IsExecutableWithExports()) { - std::string impProp = "IMPORTED_IMPLIB"; - impProp += suffix; - if (const char* config_implib = this->GetProperty(impProp)) { - result = config_implib; - } else if (const char* implib = this->GetProperty("IMPORTED_IMPLIB")) { - result = implib; + break; + + case cmStateEnums::ImportLibraryArtifact: + if (imp) { + result = imp; + } else if (this->GetType() == cmStateEnums::SHARED_LIBRARY || + this->IsExecutableWithExports()) { + std::string impProp = "IMPORTED_IMPLIB"; + impProp += suffix; + if (const char* config_implib = this->GetProperty(impProp)) { + result = config_implib; + } else if (const char* implib = + this->GetProperty("IMPORTED_IMPLIB")) { + result = implib; + } } - } + break; } } @@ -1447,18 +1490,28 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config, const char** loc, const char** imp, std::string& suffix) const { - std::string const locPropBase = - this->GetType() == cmStateEnums::INTERFACE_LIBRARY ? "IMPORTED_LIBNAME" - : "IMPORTED_LOCATION"; + std::string config_upper; + if (!desired_config.empty()) { + config_upper = cmSystemTools::UpperCase(desired_config); + } + + std::string locPropBase; + if (this->GetType() == cmStateEnums::INTERFACE_LIBRARY) { + locPropBase = "IMPORTED_LIBNAME"; + } else if (this->GetType() == cmStateEnums::OBJECT_LIBRARY) { + locPropBase = "IMPORTED_OBJECTS"; + } else { + locPropBase = "IMPORTED_LOCATION"; + } // Track the configuration-specific property suffix. suffix = "_"; - suffix += desired_config; + suffix += config_upper; std::vector<std::string> mappedConfigs; { std::string mapProp = "MAP_IMPORTED_CONFIG_"; - mapProp += desired_config; + mapProp += config_upper; if (const char* mapValue = this->GetProperty(mapProp)) { cmSystemTools::ExpandListArgument(mapValue, mappedConfigs, true); } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 1d40d20..1f00c01 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -3,7 +3,7 @@ #ifndef cmTarget_h #define cmTarget_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <iosfwd> #include <map> @@ -267,11 +267,13 @@ public: }; std::string ImportedGetFullPath(const std::string& config, - bool implib) const; + cmStateEnums::ArtifactType artifact) const; private: - const char* GetSuffixVariableInternal(bool implib) const; - const char* GetPrefixVariableInternal(bool implib) const; + const char* GetSuffixVariableInternal( + cmStateEnums::ArtifactType artifact) const; + const char* GetPrefixVariableInternal( + cmStateEnums::ArtifactType artifact) const; // Use a makefile variable to set a default for the given property. // If the variable is not defined use the given default instead. diff --git a/Source/cmTargetCompileDefinitionsCommand.h b/Source/cmTargetCompileDefinitionsCommand.h index caaf23b..663b9d0 100644 --- a/Source/cmTargetCompileDefinitionsCommand.h +++ b/Source/cmTargetCompileDefinitionsCommand.h @@ -3,7 +3,8 @@ #ifndef cmTargetCompileDefinitionsCommand_h #define cmTargetCompileDefinitionsCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmTargetCompileFeaturesCommand.h b/Source/cmTargetCompileFeaturesCommand.h index 01f2938..95214bf 100644 --- a/Source/cmTargetCompileFeaturesCommand.h +++ b/Source/cmTargetCompileFeaturesCommand.h @@ -3,7 +3,8 @@ #ifndef cmTargetCompileFeaturesCommand_h #define cmTargetCompileFeaturesCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmTargetCompileOptionsCommand.h b/Source/cmTargetCompileOptionsCommand.h index 179013b..e4dfa75 100644 --- a/Source/cmTargetCompileOptionsCommand.h +++ b/Source/cmTargetCompileOptionsCommand.h @@ -3,7 +3,8 @@ #ifndef cmTargetCompileOptionsCommand_h #define cmTargetCompileOptionsCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmTargetDepend.h b/Source/cmTargetDepend.h index a953efb..daa902e 100644 --- a/Source/cmTargetDepend.h +++ b/Source/cmTargetDepend.h @@ -3,7 +3,7 @@ #ifndef cmTargetDepend_h #define cmTargetDepend_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <set> @@ -30,7 +30,7 @@ public: operator cmGeneratorTarget const*() const { return this->Target; } cmGeneratorTarget const* operator->() const { return this->Target; } cmGeneratorTarget const& operator*() const { return *this->Target; } - friend bool operator<(cmTargetDepend const& l, cmTargetDepend const& r) + friend bool operator<(cmTargetDepend l, cmTargetDepend r) { return l.Target < r.Target; } diff --git a/Source/cmTargetExport.h b/Source/cmTargetExport.h index b08ede2..9304eab 100644 --- a/Source/cmTargetExport.h +++ b/Source/cmTargetExport.h @@ -3,7 +3,7 @@ #ifndef cmTargetExport_h #define cmTargetExport_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <string> @@ -26,6 +26,7 @@ public: cmInstallTargetGenerator* ArchiveGenerator; cmInstallTargetGenerator* RuntimeGenerator; cmInstallTargetGenerator* LibraryGenerator; + cmInstallTargetGenerator* ObjectsGenerator; cmInstallTargetGenerator* FrameworkGenerator; cmInstallTargetGenerator* BundleGenerator; cmInstallFilesGenerator* HeaderGenerator; diff --git a/Source/cmTargetIncludeDirectoriesCommand.h b/Source/cmTargetIncludeDirectoriesCommand.h index bc6cf0d..d6d33f2 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.h +++ b/Source/cmTargetIncludeDirectoriesCommand.h @@ -3,7 +3,8 @@ #ifndef cmTargetIncludeDirectoriesCommand_h #define cmTargetIncludeDirectoriesCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmTargetLinkLibrariesCommand.h b/Source/cmTargetLinkLibrariesCommand.h index 762b48f..bfa233e 100644 --- a/Source/cmTargetLinkLibrariesCommand.h +++ b/Source/cmTargetLinkLibrariesCommand.h @@ -3,7 +3,8 @@ #ifndef cmTargetLinkLibrariesCommand_h #define cmTargetLinkLibrariesCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmTargetPropCommandBase.h b/Source/cmTargetPropCommandBase.h index 8b49653..46a2f6b 100644 --- a/Source/cmTargetPropCommandBase.h +++ b/Source/cmTargetPropCommandBase.h @@ -3,7 +3,7 @@ #ifndef cmTargetPropCommandBase_h #define cmTargetPropCommandBase_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmTargetPropertyComputer.h b/Source/cmTargetPropertyComputer.h index 45d31be..94688e3 100644 --- a/Source/cmTargetPropertyComputer.h +++ b/Source/cmTargetPropertyComputer.h @@ -3,7 +3,7 @@ #ifndef cmTargetPropertyComputer_h #define cmTargetPropertyComputer_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <string> diff --git a/Source/cmTargetSourcesCommand.h b/Source/cmTargetSourcesCommand.h index b1afac2..6cc1abc 100644 --- a/Source/cmTargetSourcesCommand.h +++ b/Source/cmTargetSourcesCommand.h @@ -3,7 +3,8 @@ #ifndef cmTargetSourcesCommand_h #define cmTargetSourcesCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmTest.h b/Source/cmTest.h index 274a924..d4839d1 100644 --- a/Source/cmTest.h +++ b/Source/cmTest.h @@ -3,7 +3,7 @@ #ifndef cmTest_h #define cmTest_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include "cmListFileCache.h" #include "cmPropertyMap.h" diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx index 4164f3a..be4b378 100644 --- a/Source/cmTestGenerator.cxx +++ b/Source/cmTestGenerator.cxx @@ -35,15 +35,13 @@ void cmTestGenerator::Compute(cmLocalGenerator* lg) this->LG = lg; } -void cmTestGenerator::GenerateScriptConfigs(std::ostream& os, - Indent const& indent) +void cmTestGenerator::GenerateScriptConfigs(std::ostream& os, Indent indent) { // Create the tests. this->cmScriptGenerator::GenerateScriptConfigs(os, indent); } -void cmTestGenerator::GenerateScriptActions(std::ostream& os, - Indent const& indent) +void cmTestGenerator::GenerateScriptActions(std::ostream& os, Indent indent) { if (this->ActionsPerConfig) { // This is the per-config generation in a single-configuration @@ -59,7 +57,7 @@ void cmTestGenerator::GenerateScriptActions(std::ostream& os, void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, const std::string& config, - Indent const& indent) + Indent indent) { this->TestGenerated = true; @@ -125,8 +123,7 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, } } -void cmTestGenerator::GenerateScriptNoConfig(std::ostream& os, - Indent const& indent) +void cmTestGenerator::GenerateScriptNoConfig(std::ostream& os, Indent indent) { os << indent << "add_test(" << this->Test->GetName() << " NOT_AVAILABLE)\n"; } @@ -139,8 +136,7 @@ bool cmTestGenerator::NeedsScriptNoConfig() const !this->ConfigurationTypes->empty()); // config-dependent command } -void cmTestGenerator::GenerateOldStyle(std::ostream& fout, - Indent const& indent) +void cmTestGenerator::GenerateOldStyle(std::ostream& fout, Indent indent) { this->TestGenerated = true; diff --git a/Source/cmTestGenerator.h b/Source/cmTestGenerator.h index b350806..9a25e33 100644 --- a/Source/cmTestGenerator.h +++ b/Source/cmTestGenerator.h @@ -3,7 +3,7 @@ #ifndef cmTestGenerator_h #define cmTestGenerator_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include "cmScriptGenerator.h" @@ -29,16 +29,13 @@ public: void Compute(cmLocalGenerator* lg); protected: - void GenerateScriptConfigs(std::ostream& os, - Indent const& indent) CM_OVERRIDE; - void GenerateScriptActions(std::ostream& os, - Indent const& indent) CM_OVERRIDE; + void GenerateScriptConfigs(std::ostream& os, Indent indent) CM_OVERRIDE; + void GenerateScriptActions(std::ostream& os, Indent indent) CM_OVERRIDE; void GenerateScriptForConfig(std::ostream& os, const std::string& config, - Indent const& indent) CM_OVERRIDE; - void GenerateScriptNoConfig(std::ostream& os, - Indent const& indent) CM_OVERRIDE; + Indent indent) CM_OVERRIDE; + void GenerateScriptNoConfig(std::ostream& os, Indent indent) CM_OVERRIDE; bool NeedsScriptNoConfig() const CM_OVERRIDE; - void GenerateOldStyle(std::ostream& os, Indent const& indent); + void GenerateOldStyle(std::ostream& os, Indent indent); cmLocalGenerator* LG; cmTest* Test; diff --git a/Source/cmTimestamp.cxx b/Source/cmTimestamp.cxx index 3d42e26..4b97188 100644 --- a/Source/cmTimestamp.cxx +++ b/Source/cmTimestamp.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmTimestamp.h" -#include <cmConfigure.h> +#include "cmConfigure.h" #include <cstring> #include <sstream> #include <stdlib.h> diff --git a/Source/cmTimestamp.h b/Source/cmTimestamp.h index fdee564..8dd499a 100644 --- a/Source/cmTimestamp.h +++ b/Source/cmTimestamp.h @@ -3,7 +3,7 @@ #ifndef cmTimestamp_h #define cmTimestamp_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <time.h> diff --git a/Source/cmTryCompileCommand.h b/Source/cmTryCompileCommand.h index 52a0345..8972f7e 100644 --- a/Source/cmTryCompileCommand.h +++ b/Source/cmTryCompileCommand.h @@ -3,7 +3,8 @@ #ifndef cmTryCompileCommand_h #define cmTryCompileCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index c4fc94e..07e20e6 100644 --- a/Source/cmTryRunCommand.cxx +++ b/Source/cmTryRunCommand.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmTryRunCommand.h" -#include <cmsys/FStream.hxx> +#include "cmsys/FStream.hxx" #include <stdio.h> #include <string.h> diff --git a/Source/cmTryRunCommand.h b/Source/cmTryRunCommand.h index 8b44ac5..b086dde 100644 --- a/Source/cmTryRunCommand.h +++ b/Source/cmTryRunCommand.h @@ -3,7 +3,8 @@ #ifndef cmTryRunCommand_h #define cmTryRunCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmUnexpectedCommand.h b/Source/cmUnexpectedCommand.h index 897dfb6..aee5d4d 100644 --- a/Source/cmUnexpectedCommand.h +++ b/Source/cmUnexpectedCommand.h @@ -3,7 +3,8 @@ #ifndef cmUnexpectedCommand_h #define cmUnexpectedCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmUnsetCommand.h b/Source/cmUnsetCommand.h index 5b07202..7e0f5b5 100644 --- a/Source/cmUnsetCommand.h +++ b/Source/cmUnsetCommand.h @@ -3,7 +3,8 @@ #ifndef cmUnsetCommand_h #define cmUnsetCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmUseMangledMesaCommand.cxx b/Source/cmUseMangledMesaCommand.cxx index 3e72d75..07095b1 100644 --- a/Source/cmUseMangledMesaCommand.cxx +++ b/Source/cmUseMangledMesaCommand.cxx @@ -2,10 +2,9 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmUseMangledMesaCommand.h" -#include <cmsys/FStream.hxx> -#include <cmsys/RegularExpression.hxx> +#include "cmsys/FStream.hxx" +#include "cmsys/RegularExpression.hxx" -#include "cmPolicies.h" #include "cmSystemTools.h" class cmExecutionStatus; @@ -13,11 +12,6 @@ class cmExecutionStatus; bool cmUseMangledMesaCommand::InitialPass(std::vector<std::string> const& args, cmExecutionStatus&) { - if (this->Disallowed( - cmPolicies::CMP0030, - "The use_mangled_mesa command should not be called; see CMP0030.")) { - return true; - } // expected two arguments: // arguement one: the full path to gl_mangle.h // arguement two : directory for output of edited headers diff --git a/Source/cmUseMangledMesaCommand.h b/Source/cmUseMangledMesaCommand.h index 9a49f94..e8bd8c6 100644 --- a/Source/cmUseMangledMesaCommand.h +++ b/Source/cmUseMangledMesaCommand.h @@ -3,7 +3,8 @@ #ifndef cmUseMangledMesaCommand_h #define cmUseMangledMesaCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmUtilitySourceCommand.cxx b/Source/cmUtilitySourceCommand.cxx index 3b78abe..37d8bfb 100644 --- a/Source/cmUtilitySourceCommand.cxx +++ b/Source/cmUtilitySourceCommand.cxx @@ -5,7 +5,6 @@ #include <string.h> #include "cmMakefile.h" -#include "cmPolicies.h" #include "cmState.h" #include "cmStateTypes.h" #include "cmSystemTools.h" @@ -16,11 +15,6 @@ class cmExecutionStatus; bool cmUtilitySourceCommand::InitialPass(std::vector<std::string> const& args, cmExecutionStatus&) { - if (this->Disallowed( - cmPolicies::CMP0034, - "The utility_source command should not be called; see CMP0034.")) { - return true; - } if (args.size() < 3) { this->SetError("called with incorrect number of arguments"); return false; diff --git a/Source/cmUtilitySourceCommand.h b/Source/cmUtilitySourceCommand.h index 849b966..fa818bf 100644 --- a/Source/cmUtilitySourceCommand.h +++ b/Source/cmUtilitySourceCommand.h @@ -3,7 +3,8 @@ #ifndef cmUtilitySourceCommand_h #define cmUtilitySourceCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmUtils.hxx b/Source/cmUtils.hxx index 3f65872..c5c767c 100644 --- a/Source/cmUtils.hxx +++ b/Source/cmUtils.hxx @@ -3,7 +3,7 @@ #ifndef cmUtils_hxx #define cmUtils_hxx -#include <cmsys/SystemTools.hxx> +#include "cmsys/SystemTools.hxx" // Use the make system's VERBOSE environment variable to enable // verbose output. This can be skipped by also setting CMAKE_NO_VERBOSE diff --git a/Source/cmUuid.h b/Source/cmUuid.h index 1bc2229..158ce6e 100644 --- a/Source/cmUuid.h +++ b/Source/cmUuid.h @@ -3,7 +3,7 @@ #ifndef cmUuid_h #define cmUuid_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmVS10CudaFlagTable.h b/Source/cmVS10CudaFlagTable.h new file mode 100644 index 0000000..da19d64 --- /dev/null +++ b/Source/cmVS10CudaFlagTable.h @@ -0,0 +1,51 @@ +static cmVS7FlagTable cmVS10CudaFlagTable[] = { + // Collect options meant for the host compiler. + { "AdditionalCompilerOptions", "Xcompiler=", "Host compiler options", "", + cmVS7FlagTable::UserValue | cmVS7FlagTable::SpaceAppendable }, + { "AdditionalCompilerOptions", "Xcompiler", "Host compiler options", "", + cmVS7FlagTable::UserFollowing | cmVS7FlagTable::SpaceAppendable }, + + // Select the CUDA runtime library. + { "CudaRuntime", "cudart=none", "No CUDA runtime library", "None", 0 }, + { "CudaRuntime", "cudart=shared", "Shared/dynamic CUDA runtime library", + "Shared", 0 }, + { "CudaRuntime", "cudart=static", "Static CUDA runtime library", "Static", + 0 }, + { "CudaRuntime", "cudart", "CUDA runtime library", "", + cmVS7FlagTable::UserFollowing }, + + // Capture arch/code arguments into temporaries for post-processing. + { "cmake-temp-gencode", "gencode=", "", "", + cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable }, + { "cmake-temp-gencode", "gencode", "", "", + cmVS7FlagTable::UserFollowing | cmVS7FlagTable::SemicolonAppendable }, + { "cmake-temp-gencode", "-generate-code=", "", "", + cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable }, + { "cmake-temp-gencode", "-generate-code", "", "", + cmVS7FlagTable::UserFollowing | cmVS7FlagTable::SemicolonAppendable }, + + { "cmake-temp-code", "code=", "", "", cmVS7FlagTable::UserValue }, + { "cmake-temp-code", "code", "", "", cmVS7FlagTable::UserFollowing }, + { "cmake-temp-code", "-gpu-code=", "", "", cmVS7FlagTable::UserValue }, + { "cmake-temp-code", "-gpu-code", "", "", cmVS7FlagTable::UserFollowing }, + + { "cmake-temp-arch", "arch=", "", "", cmVS7FlagTable::UserValue }, + { "cmake-temp-arch", "arch", "", "", cmVS7FlagTable::UserFollowing }, + { "cmake-temp-arch", "-gpu-architecture=", "", "", + cmVS7FlagTable::UserValue }, + { "cmake-temp-arch", "-gpu-architecture", "", "", + cmVS7FlagTable::UserFollowing }, + + // Other flags. + + { "FastMath", "use_fast_math", "", "true", 0 }, + { "FastMath", "-use_fast_math", "", "true", 0 }, + + { "GPUDebugInfo", "G", "", "true", 0 }, + { "GPUDebugInfo", "-device-debug", "", "true", 0 }, + + { "HostDebugInfo", "g", "", "true", 0 }, + { "HostDebugInfo", "-debug", "", "true", 0 }, + + { 0, 0, 0, 0, 0 } +}; diff --git a/Source/cmVS10CudaHostFlagTable.h b/Source/cmVS10CudaHostFlagTable.h new file mode 100644 index 0000000..5b61066 --- /dev/null +++ b/Source/cmVS10CudaHostFlagTable.h @@ -0,0 +1,35 @@ +static cmVS7FlagTable cmVS10CudaHostFlagTable[] = { + //{"Optimization", "", "<inherit from host>", "InheritFromHost", 0}, + { "Optimization", "Od", "Disabled", "Od", 0 }, + { "Optimization", "O1", "Minimize Size", "O1", 0 }, + { "Optimization", "O2", "Maximize Speed", "O2", 0 }, + { "Optimization", "Ox", "Full Optimization", "O3", 0 }, + + //{"Runtime", "", "<inherit from host>", "InheritFromHost", 0}, + { "Runtime", "MT", "Multi-Threaded", "MT", 0 }, + { "Runtime", "MTd", "Multi-Threaded Debug", "MTd", 0 }, + { "Runtime", "MD", "Multi-Threaded DLL", "MD", 0 }, + { "Runtime", "MDd", "Multi-threaded Debug DLL", "MDd", 0 }, + { "Runtime", "ML", "Single-Threaded", "ML", 0 }, + { "Runtime", "MLd", "Single-Threaded Debug", "MLd", 0 }, + + //{"RuntimeChecks", "", "<inherit from host>", "InheritFromHost", 0}, + //{"RuntimeChecks", "", "Default", "Default", 0}, + { "RuntimeChecks", "RTCs", "Stack Frames", "RTCs", 0 }, + { "RuntimeChecks", "RTCu", "Uninitialized Variables", "RTCu", 0 }, + { "RuntimeChecks", "RTC1", "Both", "RTC1", 0 }, + + //{"TypeInfo", "", "<inherit from host>", "InheritFromHost", 0}, + { "TypeInfo", "GR", "Yes", "true", 0 }, + { "TypeInfo", "GR-", "No", "false", 0 }, + + //{"Warning", "", "<inherit from host>", "InheritFromHost", 0}, + { "Warning", "W0", "Off: Turn Off All Warnings", "W0", 0 }, + { "Warning", "W1", "Level 1", "W1", 0 }, + { "Warning", "W2", "Level 2", "W2", 0 }, + { "Warning", "W3", "Level 3", "W3", 0 }, + { "Warning", "W4", "Level 4", "W4", 0 }, + { "Warning", "Wall", "Enable All Warnings", "Wall", 0 }, + + { 0, 0, 0, 0, 0 } +}; diff --git a/Source/cmVS10NASMFlagTable.h b/Source/cmVS10NASMFlagTable.h new file mode 100644 index 0000000..b91af92 --- /dev/null +++ b/Source/cmVS10NASMFlagTable.h @@ -0,0 +1,50 @@ +static cmVS7FlagTable cmVS10NASMFlagTable[] = { + + // Enum Properties + { "Outputswitch", "fwin32", "", "0", 0 }, + { "Outputswitch", "fwin", "", "0", 0 }, + { "Outputswitch", "fwin64", "", "1", 0 }, + { "Outputswitch", "felf", "", "2", 0 }, + { "Outputswitch", "felf32", "", "2", 0 }, + { "Outputswitch", "felf64", "", "3", 0 }, + + { "ErrorReportingFormat", "Xgnu", "", "-Xgnu GNU format: Default format", + 0 }, + { "ErrorReportingFormat", "Xvc", "", + "-Xvc Style used by Microsoft Visual C++", 0 }, + + // Bool Properties + { "TreatWarningsAsErrors", "Werror", "", "true", 0 }, + { "GenerateDebugInformation", "g", "", "true", 0 }, + { "floatunderflow", "w+float-underflow", "", "true", 0 }, + { "macrodefaults", "w-macro-defaults", "", "true", 0 }, + { "user", "w-user", "%warning directives (default on)", "true", 0 }, + { "floatoverflow", "w-float-overflow", "", "true", 0 }, + { "floatdenorm", "w+float-denorm", "", "true", 0 }, + { "numberoverflow", "w-number-overflow", "", "true", 0 }, + { "macroselfref", "w+macro-selfref", "", "true", 0 }, + { "floattoolong", "w-float-toolong", "", "true", 0 }, + { "orphanlabels", "w-orphan-labels", "", "true", 0 }, + { "tasmmode", "t", "", "true", 0 }, + + // Bool Properties With Argument + + // String List Properties + { "PreprocessorDefinitions", "D", "Preprocessor Definitions", "", + cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable }, + { "UndefinePreprocessorDefinitions", "U", + "Undefine Preprocessor Definitions", "", + cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable }, + { "IncludePaths", "I", "Include Paths", "", + cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable }, + { "AssembledCodeListingFile", "l", + "Generates an assembled code listing file.", "", + cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable }, + + // String Properties + // Skip [Inputs] - no command line Switch. + // Skip [CommandLineTemplate] - no command line Switch. + // Skip [ExecutionDescription] - no command line Switch. + // Skip [AdditionalOptions] - no command line Switch. + { 0, 0, 0, 0, 0 } +}; diff --git a/Source/cmVariableRequiresCommand.cxx b/Source/cmVariableRequiresCommand.cxx index 1eb1f20..10b0a88 100644 --- a/Source/cmVariableRequiresCommand.cxx +++ b/Source/cmVariableRequiresCommand.cxx @@ -3,7 +3,6 @@ #include "cmVariableRequiresCommand.h" #include "cmMakefile.h" -#include "cmPolicies.h" #include "cmState.h" #include "cmSystemTools.h" @@ -13,11 +12,6 @@ class cmExecutionStatus; bool cmVariableRequiresCommand::InitialPass( std::vector<std::string> const& args, cmExecutionStatus&) { - if (this->Disallowed( - cmPolicies::CMP0035, - "The variable_requires command should not be called; see CMP0035.")) { - return true; - } if (args.size() < 3) { this->SetError("called with incorrect number of arguments"); return false; diff --git a/Source/cmVariableRequiresCommand.h b/Source/cmVariableRequiresCommand.h index baf717c..6afb11a 100644 --- a/Source/cmVariableRequiresCommand.h +++ b/Source/cmVariableRequiresCommand.h @@ -3,7 +3,8 @@ #ifndef cmVariableRequiresCommand_h #define cmVariableRequiresCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmVariableWatch.cxx b/Source/cmVariableWatch.cxx index c94ce17..419e1a4 100644 --- a/Source/cmVariableWatch.cxx +++ b/Source/cmVariableWatch.cxx @@ -4,8 +4,8 @@ #include "cmAlgorithms.h" +#include "cm_auto_ptr.hxx" #include <algorithm> -#include <cm_auto_ptr.hxx> #include <utility> static const char* const cmVariableWatchAccessStrings[] = { diff --git a/Source/cmVariableWatch.h b/Source/cmVariableWatch.h index 0b8b433..a575afe 100644 --- a/Source/cmVariableWatch.h +++ b/Source/cmVariableWatch.h @@ -3,7 +3,7 @@ #ifndef cmVariableWatch_h #define cmVariableWatch_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <map> #include <string> diff --git a/Source/cmVariableWatchCommand.h b/Source/cmVariableWatchCommand.h index 919bac4..7096ed5 100644 --- a/Source/cmVariableWatchCommand.h +++ b/Source/cmVariableWatchCommand.h @@ -3,7 +3,8 @@ #ifndef cmVariableWatchCommand_h #define cmVariableWatchCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <set> #include <string> #include <vector> diff --git a/Source/cmVersion.h b/Source/cmVersion.h index e77ec99..bfd994d 100644 --- a/Source/cmVersion.h +++ b/Source/cmVersion.h @@ -3,7 +3,7 @@ #ifndef cmVersion_h #define cmVersion_h -#include <cm_kwiml.h> +#include "cm_kwiml.h" /** \class cmVersion * \brief Helper class for providing CMake and CTest version information. diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index cb6afe1..d83662e 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -10,10 +10,11 @@ #include "cmLocalVisualStudio7Generator.h" #include "cmMakefile.h" #include "cmSourceFile.h" +#include "cmSystemTools.h" #include "cmVisualStudioGeneratorOptions.h" #include "windows.h" -#include <cm_auto_ptr.hxx> +#include "cm_auto_ptr.hxx" static std::string const kWINDOWS_7_1_SDK = "Windows7.1SDK"; @@ -111,6 +112,10 @@ cmVisualStudio10TargetGenerator::~cmVisualStudio10TargetGenerator() i != this->LinkOptions.end(); ++i) { delete i->second; } + for (OptionsMap::iterator i = this->CudaOptions.begin(); + i != this->CudaOptions.end(); ++i) { + delete i->second; + } if (!this->BuildFileStream) { return; } @@ -205,9 +210,15 @@ void cmVisualStudio10TargetGenerator::Generate() if (!this->ComputeRcOptions()) { return; } + if (!this->ComputeCudaOptions()) { + return; + } if (!this->ComputeMasmOptions()) { return; } + if (!this->ComputeNasmOptions()) { + return; + } if (!this->ComputeLinkOptions()) { return; } @@ -450,11 +461,34 @@ void cmVisualStudio10TargetGenerator::Generate() this->WriteString("<Import Project=\"" VS10_CXX_PROPS "\" />\n", 1); } this->WriteString("<ImportGroup Label=\"ExtensionSettings\">\n", 1); + if (this->GlobalGenerator->IsCudaEnabled()) { + this->WriteString("<Import Project=\"$(VCTargetsPath)\\" + "BuildCustomizations\\CUDA ", + 2); + (*this->BuildFileStream) + << cmVS10EscapeXML(this->GlobalGenerator->GetPlatformToolsetCudaString()) + << ".props\" />\n"; + } if (this->GlobalGenerator->IsMasmEnabled()) { this->WriteString("<Import Project=\"$(VCTargetsPath)\\" "BuildCustomizations\\masm.props\" />\n", 2); } + if (this->GlobalGenerator->IsNasmEnabled()) { + // Always search in the standard modules location. + std::string propsTemplate = + GetCMakeFilePath("Templates/MSBuild/nasm.props.in"); + + std::string propsLocal; + propsLocal += this->DefaultArtifactDir; + propsLocal += "\\nasm.props"; + this->ConvertToWindowsSlash(propsLocal); + this->Makefile->ConfigureFile(propsTemplate.c_str(), propsLocal.c_str(), + false, true, true); + std::string import = std::string("<Import Project=\"") + + cmVS10EscapeXML(propsLocal) + "\" />\n"; + this->WriteString(import.c_str(), 2); + } this->WriteString("</ImportGroup>\n", 1); this->WriteString("<ImportGroup Label=\"PropertySheets\">\n", 1); { @@ -505,11 +539,26 @@ void cmVisualStudio10TargetGenerator::Generate() this->WriteTargetSpecificReferences(); this->WriteString("<ImportGroup Label=\"ExtensionTargets\">\n", 1); this->WriteTargetsFileReferences(); + if (this->GlobalGenerator->IsCudaEnabled()) { + this->WriteString("<Import Project=\"$(VCTargetsPath)\\" + "BuildCustomizations\\CUDA ", + 2); + (*this->BuildFileStream) + << cmVS10EscapeXML(this->GlobalGenerator->GetPlatformToolsetCudaString()) + << ".targets\" />\n"; + } if (this->GlobalGenerator->IsMasmEnabled()) { this->WriteString("<Import Project=\"$(VCTargetsPath)\\" "BuildCustomizations\\masm.targets\" />\n", 2); } + if (this->GlobalGenerator->IsNasmEnabled()) { + std::string nasmTargets = + GetCMakeFilePath("Templates/MSBuild/nasm.targets"); + std::string import = "<Import Project=\""; + import += cmVS10EscapeXML(nasmTargets) + "\" />\n"; + this->WriteString(import.c_str(), 2); + } this->WriteString("</ImportGroup>\n", 1); if (csproj == this->ProjectType) { for (std::vector<std::string>::const_iterator i = @@ -1002,8 +1051,8 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValuesManaged( std::string postfixName = cmSystemTools::UpperCase(config); postfixName += "_POSTFIX"; - std::string assemblyName = - this->GeneratorTarget->GetOutputName(config, false); + std::string assemblyName = this->GeneratorTarget->GetOutputName( + config, cmStateEnums::RuntimeBinaryArtifact); if (const char* postfix = this->GeneratorTarget->GetProperty(postfixName)) { assemblyName += postfix; } @@ -1192,16 +1241,15 @@ void cmVisualStudio10TargetGenerator::WriteGroups() // collect up group information std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups(); - std::vector<cmSourceFile*> classes; - if (!this->GeneratorTarget->GetConfigCommonSourceFiles(classes)) { - return; - } + + std::vector<cmGeneratorTarget::AllConfigSource> const& sources = + this->GeneratorTarget->GetAllConfigSources(); std::set<cmSourceGroup*> groupsUsed; - for (std::vector<cmSourceFile*>::const_iterator s = classes.begin(); - s != classes.end(); s++) { - cmSourceFile* sf = *s; - std::string const& source = sf->GetFullPath(); + for (std::vector<cmGeneratorTarget::AllConfigSource>::const_iterator si = + sources.begin(); + si != sources.end(); ++si) { + std::string const& source = si->Source->GetFullPath(); cmSourceGroup* sourceGroup = this->Makefile->FindSourceGroup(source.c_str(), sourceGroups); groupsUsed.insert(sourceGroup); @@ -1288,23 +1336,6 @@ void cmVisualStudio10TargetGenerator::WriteGroups() this->WriteString("</ItemGroup>\n", 1); } - // Add object library contents as external objects. - std::vector<std::string> objs; - this->GeneratorTarget->UseObjectLibraries(objs, ""); - if (!objs.empty()) { - this->WriteString("<ItemGroup>\n", 1); - for (std::vector<std::string>::const_iterator oi = objs.begin(); - oi != objs.end(); ++oi) { - std::string obj = *oi; - this->WriteString("<Object Include=\"", 2); - this->ConvertToWindowsSlash(obj); - (*this->BuildFileStream) << cmVS10EscapeXML(obj) << "\">\n"; - this->WriteString("<Filter>Object Libraries</Filter>\n", 3); - this->WriteString("</Object>\n", 2); - } - this->WriteString("</ItemGroup>\n", 1); - } - this->WriteString("<ItemGroup>\n", 1); for (std::set<cmSourceGroup*>::iterator g = groupsUsed.begin(); g != groupsUsed.end(); ++g) { @@ -1322,15 +1353,6 @@ void cmVisualStudio10TargetGenerator::WriteGroups() this->WriteString("</Filter>\n", 2); } } - if (!objs.empty()) { - this->WriteString("<Filter Include=\"Object Libraries\">\n", 2); - std::string guidName = "SG_Filter_Object Libraries"; - this->WriteString("<UniqueIdentifier>", 3); - std::string guid = this->GlobalGenerator->GetGUID(guidName.c_str()); - (*this->BuildFileStream) << "{" << guid << "}" - << "</UniqueIdentifier>\n"; - this->WriteString("</Filter>\n", 2); - } if (!resxObjs.empty() || !this->AddedFiles.empty()) { this->WriteString("<Filter Include=\"Resource Files\">\n", 2); @@ -1668,8 +1690,10 @@ void cmVisualStudio10TargetGenerator::WriteSource(std::string const& tool, // // and fail if this exceeds the maximum allowed path length. Our path // conversion uses full paths when possible to allow deeper trees. - bool forceRelative = false; - std::string sourceFile = this->ConvertPath(sf->GetFullPath(), false); + // However, CUDA 8.0 msbuild rules fail on absolute paths so for CUDA + // we must use relative paths. + bool forceRelative = sf->GetLanguage() == "CUDA"; + std::string sourceFile = this->ConvertPath(sf->GetFullPath(), forceRelative); if (this->LocalGenerator->GetVersion() == cmGlobalVisualStudioGenerator::VS10 && cmSystemTools::FileIsFullPath(sourceFile.c_str())) { @@ -1702,15 +1726,6 @@ void cmVisualStudio10TargetGenerator::WriteSource(std::string const& tool, this->Tools[tool].push_back(toolSource); } -void cmVisualStudio10TargetGenerator::WriteSources( - std::string const& tool, std::vector<cmSourceFile const*> const& sources) -{ - for (std::vector<cmSourceFile const*>::const_iterator si = sources.begin(); - si != sources.end(); ++si) { - this->WriteSource(tool, *si); - } -} - void cmVisualStudio10TargetGenerator::WriteAllSources() { if (this->GeneratorTarget->GetType() > cmStateEnums::UTILITY) { @@ -1718,105 +1733,121 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() } this->WriteString("<ItemGroup>\n", 1); - std::vector<cmSourceFile const*> headerSources; - this->GeneratorTarget->GetHeaderSources(headerSources, ""); - for (std::vector<cmSourceFile const*>::const_iterator si = - headerSources.begin(); - si != headerSources.end(); ++si) { - this->WriteHeaderSource(*si); + std::vector<size_t> all_configs; + for (size_t ci = 0; ci < this->Configurations.size(); ++ci) { + all_configs.push_back(ci); } - std::vector<cmSourceFile const*> idlSources; - this->GeneratorTarget->GetIDLSources(idlSources, ""); - this->WriteSources("Midl", idlSources); - std::vector<cmSourceFile const*> objectSources; - this->GeneratorTarget->GetObjectSources(objectSources, ""); - for (std::vector<cmSourceFile const*>::const_iterator si = - objectSources.begin(); - si != objectSources.end(); ++si) { - const std::string& lang = (*si)->GetLanguage(); + std::vector<cmGeneratorTarget::AllConfigSource> const& sources = + this->GeneratorTarget->GetAllConfigSources(); + + for (std::vector<cmGeneratorTarget::AllConfigSource>::const_iterator si = + sources.begin(); + si != sources.end(); ++si) { std::string tool; - if (lang == "C" || lang == "CXX") { - tool = "ClCompile"; - } else if (lang == "ASM_MASM" && this->GlobalGenerator->IsMasmEnabled()) { - tool = "MASM"; - } else if (lang == "RC") { - tool = "ResourceCompile"; - } else if (lang == "CSharp") { - tool = "Compile"; + switch (si->Kind) { + case cmGeneratorTarget::SourceKindAppManifest: + tool = "AppxManifest"; + break; + case cmGeneratorTarget::SourceKindCertificate: + tool = "None"; + break; + case cmGeneratorTarget::SourceKindCustomCommand: + // Handled elsewhere. + break; + case cmGeneratorTarget::SourceKindExternalObject: + tool = "Object"; + if (this->LocalGenerator->GetVersion() < + cmGlobalVisualStudioGenerator::VS11) { + // For VS == 10 we cannot use LinkObjects to avoid linking custom + // command outputs. If an object file is generated in this target, + // then vs10 will use it in the build, and we have to list it as + // None instead of Object. + std::vector<cmSourceFile*> const* d = + this->GeneratorTarget->GetSourceDepends(si->Source); + if (d && !d->empty()) { + tool = "None"; + } + } + break; + case cmGeneratorTarget::SourceKindExtra: + this->WriteExtraSource(si->Source); + break; + case cmGeneratorTarget::SourceKindHeader: + this->WriteHeaderSource(si->Source); + break; + case cmGeneratorTarget::SourceKindIDL: + tool = "Midl"; + break; + case cmGeneratorTarget::SourceKindManifest: + // Handled elsewhere. + break; + case cmGeneratorTarget::SourceKindModuleDefinition: + tool = "None"; + break; + case cmGeneratorTarget::SourceKindObjectSource: { + const std::string& lang = si->Source->GetLanguage(); + if (lang == "C" || lang == "CXX") { + tool = "ClCompile"; + } else if (lang == "ASM_MASM" && + this->GlobalGenerator->IsMasmEnabled()) { + tool = "MASM"; + } else if (lang == "ASM_NASM" && + this->GlobalGenerator->IsNasmEnabled()) { + tool = "NASM"; + } else if (lang == "RC") { + tool = "ResourceCompile"; + } else if (lang == "CSharp") { + tool = "Compile"; + } else if (lang == "CUDA" && this->GlobalGenerator->IsCudaEnabled()) { + tool = "CudaCompile"; + } else { + tool = "None"; + } + } break; + case cmGeneratorTarget::SourceKindResx: + // Handled elsewhere. + break; + case cmGeneratorTarget::SourceKindXaml: + // Handled elsewhere. + break; } if (!tool.empty()) { - this->WriteSource(tool, *si, " "); - if (this->OutputSourceSpecificFlags(*si)) { + // Compute set of configurations to exclude, if any. + std::vector<size_t> const& include_configs = si->Configs; + std::vector<size_t> exclude_configs; + std::set_difference(all_configs.begin(), all_configs.end(), + include_configs.begin(), include_configs.end(), + std::back_inserter(exclude_configs)); + + if (si->Kind == cmGeneratorTarget::SourceKindObjectSource) { + // FIXME: refactor generation to avoid tracking XML syntax state. + this->WriteSource(tool, si->Source, " "); + bool have_nested = this->OutputSourceSpecificFlags(si->Source); + if (!exclude_configs.empty()) { + if (!have_nested) { + (*this->BuildFileStream) << ">\n"; + } + this->WriteExcludeFromBuild(exclude_configs); + have_nested = true; + } + if (have_nested) { + this->WriteString("</", 2); + (*this->BuildFileStream) << tool << ">\n"; + } else { + (*this->BuildFileStream) << " />\n"; + } + } else if (!exclude_configs.empty()) { + this->WriteSource(tool, si->Source, ">\n"); + this->WriteExcludeFromBuild(exclude_configs); this->WriteString("</", 2); (*this->BuildFileStream) << tool << ">\n"; } else { - (*this->BuildFileStream) << " />\n"; + this->WriteSource(tool, si->Source); } - } else { - this->WriteSource("None", *si); - } - } - - std::vector<cmSourceFile const*> manifestSources; - this->GeneratorTarget->GetAppManifest(manifestSources, ""); - this->WriteSources("AppxManifest", manifestSources); - - std::vector<cmSourceFile const*> certificateSources; - this->GeneratorTarget->GetCertificates(certificateSources, ""); - this->WriteSources("None", certificateSources); - - std::vector<cmSourceFile const*> externalObjects; - this->GeneratorTarget->GetExternalObjects(externalObjects, ""); - for (std::vector<cmSourceFile const*>::iterator si = externalObjects.begin(); - si != externalObjects.end();) { - if (!(*si)->GetObjectLibrary().empty()) { - si = externalObjects.erase(si); - } else { - ++si; } } - if (this->LocalGenerator->GetVersion() > - cmGlobalVisualStudioGenerator::VS10) { - // For VS >= 11 we use LinkObjects to avoid linking custom command - // outputs. Use Object for all external objects, generated or not. - this->WriteSources("Object", externalObjects); - } else { - // If an object file is generated in this target, then vs10 will use - // it in the build, and we have to list it as None instead of Object. - for (std::vector<cmSourceFile const*>::const_iterator si = - externalObjects.begin(); - si != externalObjects.end(); ++si) { - std::vector<cmSourceFile*> const* d = - this->GeneratorTarget->GetSourceDepends(*si); - this->WriteSource((d && !d->empty()) ? "None" : "Object", *si); - } - } - - std::vector<cmSourceFile const*> extraSources; - this->GeneratorTarget->GetExtraSources(extraSources, ""); - for (std::vector<cmSourceFile const*>::const_iterator si = - extraSources.begin(); - si != extraSources.end(); ++si) { - this->WriteExtraSource(*si); - } - - // Add object library contents as external objects. - std::vector<std::string> objs; - this->GeneratorTarget->UseObjectLibraries(objs, ""); - for (std::vector<std::string>::const_iterator oi = objs.begin(); - oi != objs.end(); ++oi) { - std::string obj = *oi; - this->WriteString("<Object Include=\"", 2); - this->ConvertToWindowsSlash(obj); - (*this->BuildFileStream) << cmVS10EscapeXML(obj) << "\" />\n"; - } - - if (cmSourceFile const* defsrc = - this->GeneratorTarget->GetModuleDefinitionFile("")) { - this->WriteSource("None", defsrc); - } if (this->IsMissingFiles) { this->WriteMissingFiles(); @@ -1850,7 +1881,8 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( std::string lang = this->GlobalGenerator->GetLanguageFromExtension(sf.GetExtension().c_str()); std::string sourceLang = this->LocalGenerator->GetSourceFileLanguage(sf); - const std::string& linkLanguage = this->GeneratorTarget->GetLinkerLanguage(); + const std::string& linkLanguage = + this->GeneratorTarget->GetLinkerLanguage(""); bool needForceLang = false; // source file does not match its extension language if (lang != sourceLang) { @@ -1932,7 +1964,7 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( } clOptions.AddDefines(configDefines.c_str()); clOptions.SetConfiguration((*config).c_str()); - clOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", ""); + clOptions.PrependInheritedString("AdditionalOptions"); clOptions.OutputFlagMap(*this->BuildFileStream, " "); clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ", "\n", lang); @@ -1995,6 +2027,19 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( return hasFlags; } +void cmVisualStudio10TargetGenerator::WriteExcludeFromBuild( + std::vector<size_t> const& exclude_configs) +{ + for (std::vector<size_t>::const_iterator ci = exclude_configs.begin(); + ci != exclude_configs.end(); ++ci) { + this->WriteString("", 3); + (*this->BuildFileStream) + << "<ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='" + << cmVS10EscapeXML(this->Configurations[*ci]) << "|" + << cmVS10EscapeXML(this->Platform) << "'\">true</ExcludedFromBuild>\n"; + } +} + void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions() { cmStateEnums::TargetType ttype = this->GeneratorTarget->GetType(); @@ -2180,8 +2225,13 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( if (linkLanguage == "CXX") { clOptions.AddFlag("CompileAs", "CompileAsCpp"); } - this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget, - linkLanguage, configName.c_str()); + if (linkLanguage != "CUDA") { + this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget, + linkLanguage, configName.c_str()); + } + + // Check IPO related warning/error. + this->GeneratorTarget->IsIPOEnabled(configName); // Get preprocessor definitions for this directory. std::string defineFlags = @@ -2265,7 +2315,7 @@ void cmVisualStudio10TargetGenerator::WriteClOptions( return; } this->WriteString("<ClCompile>\n", 2); - clOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", ""); + clOptions.PrependInheritedString("AdditionalOptions"); clOptions.AppendFlag("AdditionalIncludeDirectories", includes); clOptions.AppendFlag("AdditionalIncludeDirectories", "%(AdditionalIncludeDirectories)"); @@ -2369,12 +2419,111 @@ void cmVisualStudio10TargetGenerator::WriteRCOptions( rcOptions.AppendFlag("AdditionalIncludeDirectories", includes); rcOptions.AppendFlag("AdditionalIncludeDirectories", "%(AdditionalIncludeDirectories)"); + rcOptions.PrependInheritedString("AdditionalOptions"); rcOptions.OutputFlagMap(*this->BuildFileStream, " "); - rcOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", ""); this->WriteString("</ResourceCompile>\n", 2); } +bool cmVisualStudio10TargetGenerator::ComputeCudaOptions() +{ + if (!this->GlobalGenerator->IsCudaEnabled()) { + return true; + } + for (std::vector<std::string>::const_iterator i = + this->Configurations.begin(); + i != this->Configurations.end(); ++i) { + if (!this->ComputeCudaOptions(*i)) { + return false; + } + } + return true; +} + +bool cmVisualStudio10TargetGenerator::ComputeCudaOptions( + std::string const& configName) +{ + cmGlobalVisualStudio10Generator* gg = + static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator); + CM_AUTO_PTR<Options> pOptions(new Options( + this->LocalGenerator, Options::CudaCompiler, gg->GetCudaFlagTable())); + Options& cudaOptions = *pOptions; + + // Get compile flags for CUDA in this directory. + std::string CONFIG = cmSystemTools::UpperCase(configName); + std::string configFlagsVar = std::string("CMAKE_CUDA_FLAGS_") + CONFIG; + std::string flags = + std::string(this->Makefile->GetSafeDefinition("CMAKE_CUDA_FLAGS")) + + std::string(" ") + + std::string(this->Makefile->GetSafeDefinition(configFlagsVar)); + + // Get preprocessor definitions for this directory. + std::string defineFlags = + this->GeneratorTarget->Target->GetMakefile()->GetDefineFlags(); + + cudaOptions.Parse(flags.c_str()); + cudaOptions.Parse(defineFlags.c_str()); + cudaOptions.ParseFinish(); + + if (this->GeneratorTarget->GetPropertyAsBool("CUDA_SEPARABLE_COMPILATION")) { + cudaOptions.AddFlag("GenerateRelocatableDeviceCode", "true"); + } else if (this->GeneratorTarget->GetPropertyAsBool( + "CUDA_PTX_COMPILATION")) { + cudaOptions.AddFlag("NvccCompilation", "ptx"); + // We drop the %(Extension) component as CMake expects all PTX files + // to not have the source file extension at all + cudaOptions.AddFlag("CompileOut", "$(IntDir)%(Filename).ptx"); + } + + // Convert the host compiler options to the toolset's abstractions + // using a secondary flag table. + cudaOptions.ClearTables(); + cudaOptions.AddTable(gg->GetCudaHostFlagTable()); + cudaOptions.Reparse("AdditionalCompilerOptions"); + + // `CUDA 8.0.targets` places these before nvcc! Just drop whatever + // did not parse and hope it works. + cudaOptions.RemoveFlag("AdditionalCompilerOptions"); + + cudaOptions.FixCudaCodeGeneration(); + + std::vector<std::string> targetDefines; + this->GeneratorTarget->GetCompileDefinitions(targetDefines, + configName.c_str(), "CUDA"); + cudaOptions.AddDefines(targetDefines); + + // Add a definition for the configuration name. + std::string configDefine = "CMAKE_INTDIR=\""; + configDefine += configName; + configDefine += "\""; + cudaOptions.AddDefine(configDefine); + if (const char* exportMacro = this->GeneratorTarget->GetExportMacro()) { + cudaOptions.AddDefine(exportMacro); + } + + this->CudaOptions[configName] = pOptions.release(); + return true; +} + +void cmVisualStudio10TargetGenerator::WriteCudaOptions( + std::string const& configName, std::vector<std::string> const& includes) +{ + if (!this->MSTools || !this->GlobalGenerator->IsCudaEnabled()) { + return; + } + this->WriteString("<CudaCompile>\n", 2); + + Options& cudaOptions = *(this->CudaOptions[configName]); + cudaOptions.AppendFlag("Include", includes); + cudaOptions.AppendFlag("Include", "%(Include)"); + cudaOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ", + "\n", "CUDA"); + cudaOptions.PrependInheritedString("AdditionalOptions"); + cudaOptions.OutputFlagMap(*this->BuildFileStream, " "); + + this->WriteString("</CudaCompile>\n", 2); +} + bool cmVisualStudio10TargetGenerator::ComputeMasmOptions() { if (!this->GlobalGenerator->IsMasmEnabled()) { @@ -2427,12 +2576,77 @@ void cmVisualStudio10TargetGenerator::WriteMasmOptions( Options& masmOptions = *(this->MasmOptions[configName]); masmOptions.AppendFlag("IncludePaths", includes); masmOptions.AppendFlag("IncludePaths", "%(IncludePaths)"); + masmOptions.PrependInheritedString("AdditionalOptions"); masmOptions.OutputFlagMap(*this->BuildFileStream, " "); - masmOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", ""); this->WriteString("</MASM>\n", 2); } +bool cmVisualStudio10TargetGenerator::ComputeNasmOptions() +{ + if (!this->GlobalGenerator->IsNasmEnabled()) { + return true; + } + for (std::vector<std::string>::const_iterator i = + this->Configurations.begin(); + i != this->Configurations.end(); ++i) { + if (!this->ComputeNasmOptions(*i)) { + return false; + } + } + return true; +} + +bool cmVisualStudio10TargetGenerator::ComputeNasmOptions( + std::string const& configName) +{ + cmGlobalVisualStudio10Generator* gg = + static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator); + CM_AUTO_PTR<Options> pOptions(new Options( + this->LocalGenerator, Options::NasmCompiler, gg->GetNasmFlagTable())); + Options& nasmOptions = *pOptions; + + std::string CONFIG = cmSystemTools::UpperCase(configName); + std::string configFlagsVar = std::string("CMAKE_ASM_NASM_FLAGS_") + CONFIG; + std::string flags = + std::string(this->Makefile->GetSafeDefinition("CMAKE_ASM_NASM_FLAGS")) + + std::string(" -f") + std::string(this->Makefile->GetSafeDefinition( + "CMAKE_ASM_NASM_OBJECT_FORMAT")) + + std::string(" ") + + std::string(this->Makefile->GetSafeDefinition(configFlagsVar)); + nasmOptions.Parse(flags.c_str()); + this->NasmOptions[configName] = pOptions.release(); + return true; +} + +void cmVisualStudio10TargetGenerator::WriteNasmOptions( + std::string const& configName, std::vector<std::string> includes) +{ + if (!this->GlobalGenerator->IsNasmEnabled()) { + return; + } + this->WriteString("<NASM>\n", 2); + + Options& nasmOptions = *(this->NasmOptions[configName]); + for (size_t i = 0; i < includes.size(); i++) { + includes[i] += "\\"; + } + + nasmOptions.AppendFlag("IncludePaths", includes); + nasmOptions.AppendFlag("IncludePaths", "%(IncludePaths)"); + nasmOptions.OutputFlagMap(*this->BuildFileStream, " "); + nasmOptions.PrependInheritedString("AdditionalOptions"); + nasmOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ", + "\n", "ASM_NASM"); + + // Preprocessor definitions and includes are shared with clOptions. + Options& clOptions = *(this->ClOptions[configName]); + clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ", + "\n", "ASM_NASM"); + + this->WriteString("</NASM>\n", 2); +} + void cmVisualStudio10TargetGenerator::WriteLibOptions( std::string const& config) { @@ -2451,7 +2665,7 @@ void cmVisualStudio10TargetGenerator::WriteLibOptions( this->LocalGenerator, cmVisualStudioGeneratorOptions::Linker, gg->GetLibFlagTable(), 0, this); libOptions.Parse(libflags.c_str()); - libOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", ""); + libOptions.PrependInheritedString("AdditionalOptions"); libOptions.OutputFlagMap(*this->BuildFileStream, " "); this->WriteString("</Lib>\n", 2); } @@ -2648,8 +2862,10 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( this->LocalGenerator, Options::Linker, gg->GetLinkFlagTable(), 0, this)); Options& linkOptions = *pOptions; - const std::string& linkLanguage = - this->GeneratorTarget->GetLinkerLanguage(config.c_str()); + cmGeneratorTarget::LinkClosure const* linkClosure = + this->GeneratorTarget->GetLinkClosure(config); + + const std::string& linkLanguage = linkClosure->LinkerLanguage; if (linkLanguage.empty()) { cmSystemTools::Error( "CMake can not determine linker language for target: ", @@ -2690,25 +2906,6 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( flags += " "; flags += flagsConfig; } - std::string standardLibsVar = "CMAKE_"; - standardLibsVar += linkLanguage; - standardLibsVar += "_STANDARD_LIBRARIES"; - std::string libs = - this->Makefile->GetSafeDefinition(standardLibsVar.c_str()); - // Remove trailing spaces from libs - std::string::size_type pos = libs.size() - 1; - if (!libs.empty()) { - while (libs[pos] == ' ') { - pos--; - } - } - if (pos != libs.size() - 1) { - libs = libs.substr(0, pos + 1); - } - // Replace spaces in libs with ; - std::replace(libs.begin(), libs.end(), ' ', ';'); - std::vector<std::string> libVec; - cmSystemTools::ExpandListArgument(libs, libVec); cmComputeLinkInformation* pcli = this->GeneratorTarget->GetLinkInformation(config.c_str()); @@ -2718,10 +2915,30 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( this->Name.c_str()); return false; } - // add the libraries for the target to libs string cmComputeLinkInformation& cli = *pcli; + + std::vector<std::string> libVec; std::vector<std::string> vsTargetVec; this->AddLibraries(cli, libVec, vsTargetVec); + if (std::find(linkClosure->Languages.begin(), linkClosure->Languages.end(), + "CUDA") != linkClosure->Languages.end()) { + switch (this->CudaOptions[config]->GetCudaRuntime()) { + case cmVisualStudioGeneratorOptions::CudaRuntimeStatic: + libVec.push_back("cudart_static.lib"); + break; + case cmVisualStudioGeneratorOptions::CudaRuntimeShared: + libVec.push_back("cudart.lib"); + break; + case cmVisualStudioGeneratorOptions::CudaRuntimeNone: + break; + } + } + std::string standardLibsVar = "CMAKE_"; + standardLibsVar += linkLanguage; + standardLibsVar += "_STANDARD_LIBRARIES"; + std::string const libs = + this->Makefile->GetSafeDefinition(standardLibsVar.c_str()); + cmSystemTools::ParseWindowsCommandLine(libs.c_str(), libVec); linkOptions.AddFlag("AdditionalDependencies", libVec); // Populate TargetsFileAndConfigsVec @@ -2803,8 +3020,8 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( std::string pdb = this->GeneratorTarget->GetPDBDirectory(config.c_str()); pdb += "/"; pdb += targetNamePDB; - std::string imLib = - this->GeneratorTarget->GetDirectory(config.c_str(), true); + std::string imLib = this->GeneratorTarget->GetDirectory( + config.c_str(), cmStateEnums::ImportLibraryArtifact); imLib += "/"; imLib += targetNameImport; @@ -2836,24 +3053,15 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( linkOptions.Parse(flags.c_str()); if (this->MSTools) { - if (cmSourceFile const* defsrc = - this->GeneratorTarget->GetModuleDefinitionFile("")) { - linkOptions.AddFlag("ModuleDefinitionFile", - defsrc->GetFullPath().c_str()); + cmGeneratorTarget::ModuleDefinitionInfo const* mdi = + this->GeneratorTarget->GetModuleDefinitionInfo(config); + if (mdi && !mdi->DefFile.empty()) { + linkOptions.AddFlag("ModuleDefinitionFile", mdi->DefFile.c_str()); } linkOptions.AppendFlag("IgnoreSpecificDefaultLibraries", "%(IgnoreSpecificDefaultLibraries)"); } - if ((this->GeneratorTarget->GetType() == cmStateEnums::SHARED_LIBRARY || - this->GeneratorTarget->IsExecutableWithExports()) && - this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) { - if (this->GeneratorTarget->GetPropertyAsBool( - "WINDOWS_EXPORT_ALL_SYMBOLS")) { - linkOptions.AddFlag("ModuleDefinitionFile", "$(IntDir)exportall.def"); - } - } - // Hack to fix flag version selection in a common use case. // FIXME: Select flag table based on toolset instead of VS version. if (this->LocalGenerator->GetVersion() >= @@ -2940,7 +3148,7 @@ void cmVisualStudio10TargetGenerator::WriteLinkOptions( Options& linkOptions = *(this->LinkOptions[config]); this->WriteString("<Link>\n", 2); - linkOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", ""); + linkOptions.PrependInheritedString("AdditionalOptions"); linkOptions.OutputFlagMap(*this->BuildFileStream, " "); this->WriteString("</Link>\n", 2); @@ -3063,7 +3271,9 @@ void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups() this->WriteClOptions(*i, includes); // output rc compile flags <ResourceCompile></ResourceCompile> this->WriteRCOptions(*i, includes); + this->WriteCudaOptions(*i, includes); this->WriteMasmOptions(*i, includes); + this->WriteNasmOptions(*i, includes); } // output midl flags <Midl></Midl> this->WriteMidlOptions(*i, includes); @@ -3090,18 +3300,15 @@ void cmVisualStudio10TargetGenerator::WriteEvents( std::string const& configName) { bool addedPrelink = false; - if ((this->GeneratorTarget->GetType() == cmStateEnums::SHARED_LIBRARY || - this->GeneratorTarget->IsExecutableWithExports()) && - this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) { - if (this->GeneratorTarget->GetPropertyAsBool( - "WINDOWS_EXPORT_ALL_SYMBOLS")) { - addedPrelink = true; - std::vector<cmCustomCommand> commands = - this->GeneratorTarget->GetPreLinkCommands(); - this->GlobalGenerator->AddSymbolExportCommand(this->GeneratorTarget, - commands, configName); - this->WriteEvent("PreLinkEvent", commands, configName); - } + cmGeneratorTarget::ModuleDefinitionInfo const* mdi = + this->GeneratorTarget->GetModuleDefinitionInfo(configName); + if (mdi && mdi->DefFileGenerated) { + addedPrelink = true; + std::vector<cmCustomCommand> commands = + this->GeneratorTarget->GetPreLinkCommands(); + this->GlobalGenerator->AddSymbolExportCommand(this->GeneratorTarget, + commands, configName); + this->WriteEvent("PreLinkEvent", commands, configName); } if (!addedPrelink) { this->WriteEvent("PreLinkEvent", @@ -3985,3 +4192,14 @@ bool cmVisualStudio10TargetGenerator::ForceOld(const std::string& source) const CloseHandle(h); return true; } + +std::string cmVisualStudio10TargetGenerator::GetCMakeFilePath( + const char* relativeFilePath) const +{ + // Always search in the standard modules location. + std::string path = cmSystemTools::GetCMakeRoot() + "/"; + path += relativeFilePath; + this->ConvertToWindowsSlash(path); + + return path; +} diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index 45464c0..bd270bf 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -3,7 +3,7 @@ #ifndef cmVisualStudioTargetGenerator_h #define cmVisualStudioTargetGenerator_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <iosfwd> #include <map> @@ -51,7 +51,7 @@ private: }; std::string ConvertPath(std::string const& path, bool forceRelative); - void ConvertToWindowsSlash(std::string& s); + static void ConvertToWindowsSlash(std::string& s); void WriteString(const char* line, int indentLevel); void WriteProjectConfigurations(); void WriteProjectConfigurationValues(); @@ -62,8 +62,7 @@ private: void WriteNsightTegraConfigurationValues(std::string const& config); void WriteSource(std::string const& tool, cmSourceFile const* sf, const char* end = 0); - void WriteSources(std::string const& tool, - std::vector<cmSourceFile const*> const&); + void WriteExcludeFromBuild(std::vector<size_t> const& exclude_configs); void WriteAllSources(); void WriteDotNetReferences(); void WriteDotNetReference(std::string const& ref, std::string const& hint); @@ -98,10 +97,19 @@ private: bool ComputeRcOptions(std::string const& config); void WriteRCOptions(std::string const& config, std::vector<std::string> const& includes); + bool ComputeCudaOptions(); + bool ComputeCudaOptions(std::string const& config); + void WriteCudaOptions(std::string const& config, + std::vector<std::string> const& includes); bool ComputeMasmOptions(); bool ComputeMasmOptions(std::string const& config); void WriteMasmOptions(std::string const& config, std::vector<std::string> const& includes); + bool ComputeNasmOptions(); + bool ComputeNasmOptions(std::string const& config); + void WriteNasmOptions(std::string const& config, + std::vector<std::string> includes); + bool ComputeLinkOptions(); bool ComputeLinkOptions(std::string const& config); bool ComputeLibOptions(); @@ -145,7 +153,9 @@ private: typedef std::map<std::string, Options*> OptionsMap; OptionsMap ClOptions; OptionsMap RcOptions; + OptionsMap CudaOptions; OptionsMap MasmOptions; + OptionsMap NasmOptions; OptionsMap LinkOptions; std::string PathToProjectFile; std::string ProjectFileExtension; @@ -177,6 +187,7 @@ private: typedef std::map<std::string, ToolSources> ToolSourceMap; ToolSourceMap Tools; + std::string GetCMakeFilePath(const char* name) const; }; #endif diff --git a/Source/cmVisualStudio10ToolsetOptions.cxx b/Source/cmVisualStudio10ToolsetOptions.cxx index afca216..0f15ec4 100644 --- a/Source/cmVisualStudio10ToolsetOptions.cxx +++ b/Source/cmVisualStudio10ToolsetOptions.cxx @@ -11,6 +11,7 @@ #include "cmVS10LibFlagTable.h" #include "cmVS10LinkFlagTable.h" #include "cmVS10MASMFlagTable.h" +#include "cmVS10NASMFlagTable.h" #include "cmVS10RCFlagTable.h" #include "cmVS11CLFlagTable.h" #include "cmVS11CSharpFlagTable.h" diff --git a/Source/cmVisualStudio10ToolsetOptions.h b/Source/cmVisualStudio10ToolsetOptions.h index 2459f5e..4233337 100644 --- a/Source/cmVisualStudio10ToolsetOptions.h +++ b/Source/cmVisualStudio10ToolsetOptions.h @@ -3,7 +3,7 @@ #ifndef cmVisualStudio10ToolsetOptions_h #define cmVisualStudio10ToolsetOptions_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <string> diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx index da6f9a7..1f808c8 100644 --- a/Source/cmVisualStudioGeneratorOptions.cxx +++ b/Source/cmVisualStudioGeneratorOptions.cxx @@ -44,6 +44,8 @@ cmVisualStudioGeneratorOptions::cmVisualStudioGeneratorOptions( this->FortranRuntimeDebug = false; this->FortranRuntimeDLL = false; this->FortranRuntimeMT = false; + + this->UnknownFlagField = "AdditionalOptions"; } cmVisualStudioGeneratorOptions::cmVisualStudioGeneratorOptions( @@ -68,6 +70,8 @@ cmVisualStudioGeneratorOptions::cmVisualStudioGeneratorOptions( this->FortranRuntimeDebug = false; this->FortranRuntimeDLL = false; this->FortranRuntimeMT = false; + + this->UnknownFlagField = "AdditionalOptions"; } void cmVisualStudioGeneratorOptions::AddTable(cmVS7FlagTable const* table) @@ -82,6 +86,13 @@ void cmVisualStudioGeneratorOptions::AddTable(cmVS7FlagTable const* table) } } +void cmVisualStudioGeneratorOptions::ClearTables() +{ + for (int i = 0; i < FlagTableCount; ++i) { + this->FlagTable[i] = CM_NULLPTR; + } +} + void cmVisualStudioGeneratorOptions::FixExceptionHandlingDefault() { // Exception handling is on by default because the platform file has @@ -90,10 +101,6 @@ void cmVisualStudioGeneratorOptions::FixExceptionHandlingDefault() // the flag to disable exception handling. When the user does // remove the flag we need to override the IDE default of on. switch (this->Version) { - case cmGlobalVisualStudioGenerator::VS7: - case cmGlobalVisualStudioGenerator::VS71: - this->FlagMap["ExceptionHandling"] = "FALSE"; - break; case cmGlobalVisualStudioGenerator::VS10: case cmGlobalVisualStudioGenerator::VS11: case cmGlobalVisualStudioGenerator::VS12: @@ -177,6 +184,78 @@ bool cmVisualStudioGeneratorOptions::UsingSBCS() const return false; } +cmVisualStudioGeneratorOptions::CudaRuntime +cmVisualStudioGeneratorOptions::GetCudaRuntime() const +{ + std::map<std::string, FlagValue>::const_iterator i = + this->FlagMap.find("CudaRuntime"); + if (i != this->FlagMap.end() && i->second.size() == 1) { + std::string const& cudaRuntime = i->second[0]; + if (cudaRuntime == "Static") { + return CudaRuntimeStatic; + } + if (cudaRuntime == "Shared") { + return CudaRuntimeShared; + } + if (cudaRuntime == "None") { + return CudaRuntimeNone; + } + } + // nvcc default is static + return CudaRuntimeStatic; +} + +void cmVisualStudioGeneratorOptions::FixCudaCodeGeneration() +{ + // Extract temporary values stored by our flag table. + FlagValue arch = this->TakeFlag("cmake-temp-arch"); + FlagValue code = this->TakeFlag("cmake-temp-code"); + FlagValue gencode = this->TakeFlag("cmake-temp-gencode"); + + // No -code allowed without -arch. + if (arch.empty()) { + code.clear(); + } + + if (arch.empty() && gencode.empty()) { + return; + } + + // Create a CodeGeneration field with [arch],[code] syntax in each entry. + // CUDA will convert it to `-gencode=arch=[arch],code="[code],[arch]"`. + FlagValue& result = this->FlagMap["CodeGeneration"]; + + // First entries for the -arch=<arch> [-code=<code>,...] pair. + if (!arch.empty()) { + std::string arch_name = arch[0]; + std::vector<std::string> codes; + if (!code.empty()) { + codes = cmSystemTools::tokenize(code[0], ","); + } + if (codes.empty()) { + codes.push_back(arch_name); + // nvcc -arch=<arch> has a special case that allows a real + // architecture to be specified instead of a virtual arch. + // It translates to -arch=<virtual> -code=<real>. + cmSystemTools::ReplaceString(arch_name, "sm_", "compute_"); + } + for (std::vector<std::string>::iterator ci = codes.begin(); + ci != codes.end(); ++ci) { + std::string entry = arch_name + "," + *ci; + result.push_back(entry); + } + } + + // Now add entries for the -gencode=<arch>,<code> pairs. + for (std::vector<std::string>::iterator ei = gencode.begin(); + ei != gencode.end(); ++ei) { + std::string entry = *ei; + cmSystemTools::ReplaceString(entry, "arch=", ""); + cmSystemTools::ReplaceString(entry, "code=", ""); + result.push_back(entry); + } +} + void cmVisualStudioGeneratorOptions::Parse(const char* flags) { // Parse the input string as a windows command line since the string @@ -210,6 +289,44 @@ void cmVisualStudioGeneratorOptions::ParseFinish() rl += this->FortranRuntimeDLL ? "DLL" : ""; this->FlagMap["RuntimeLibrary"] = rl; } + + if (this->CurrentTool == CudaCompiler) { + std::map<std::string, FlagValue>::iterator i = + this->FlagMap.find("CudaRuntime"); + if (i != this->FlagMap.end() && i->second.size() == 1) { + std::string& cudaRuntime = i->second[0]; + if (cudaRuntime == "static") { + cudaRuntime = "Static"; + } else if (cudaRuntime == "shared") { + cudaRuntime = "Shared"; + } else if (cudaRuntime == "none") { + cudaRuntime = "None"; + } + } + } +} + +void cmVisualStudioGeneratorOptions::PrependInheritedString( + std::string const& key) +{ + std::map<std::string, FlagValue>::iterator i = this->FlagMap.find(key); + if (i == this->FlagMap.end() || i->second.size() != 1) { + return; + } + std::string& value = i->second[0]; + value = "%(" + key + ") " + value; +} + +void cmVisualStudioGeneratorOptions::Reparse(std::string const& key) +{ + std::map<std::string, FlagValue>::iterator i = this->FlagMap.find(key); + if (i == this->FlagMap.end() || i->second.size() != 1) { + return; + } + std::string const original = i->second[0]; + i->second[0] = ""; + this->UnknownFlagField = key; + this->Parse(original.c_str()); } void cmVisualStudioGeneratorOptions::StoreUnknownFlag(const char* flag) @@ -235,10 +352,22 @@ void cmVisualStudioGeneratorOptions::StoreUnknownFlag(const char* flag) } // This option is not known. Store it in the output flags. - this->FlagString += " "; - this->FlagString += cmOutputConverter::EscapeWindowsShellArgument( + std::string const opts = cmOutputConverter::EscapeWindowsShellArgument( flag, cmOutputConverter::Shell_Flag_AllowMakeVariables | cmOutputConverter::Shell_Flag_VSIDE); + this->AppendFlagString(this->UnknownFlagField, opts); +} + +cmIDEOptions::FlagValue cmVisualStudioGeneratorOptions::TakeFlag( + std::string const& key) +{ + FlagValue value; + std::map<std::string, FlagValue>::iterator i = this->FlagMap.find(key); + if (i != this->FlagMap.end()) { + value = i->second; + this->FlagMap.erase(i); + } + return value; } void cmVisualStudioGeneratorOptions::SetConfiguration(const char* config) @@ -253,19 +382,22 @@ void cmVisualStudioGeneratorOptions::OutputPreprocessorDefinitions( if (this->Defines.empty()) { return; } + const char* tag = "PreprocessorDefinitions"; + if (lang == "CUDA") { + tag = "Defines"; + } if (this->Version >= cmGlobalVisualStudioGenerator::VS10) { // if there are configuration specific flags, then // use the configuration specific tag for PreprocessorDefinitions if (!this->Configuration.empty()) { fout << prefix; this->TargetGenerator->WritePlatformConfigTag( - "PreprocessorDefinitions", this->Configuration.c_str(), 0, 0, 0, - &fout); + tag, this->Configuration.c_str(), 0, 0, 0, &fout); } else { - fout << prefix << "<PreprocessorDefinitions>"; + fout << prefix << "<" << tag << ">"; } } else { - fout << prefix << "PreprocessorDefinitions=\""; + fout << prefix << tag << "=\""; } const char* sep = ""; std::vector<std::string>::const_iterator de = @@ -294,7 +426,7 @@ void cmVisualStudioGeneratorOptions::OutputPreprocessorDefinitions( sep = ";"; } if (this->Version >= cmGlobalVisualStudioGenerator::VS10) { - fout << ";%(PreprocessorDefinitions)</PreprocessorDefinitions>" << suffix; + fout << ";%(" << tag << ")</" << tag << ">" << suffix; } else { fout << "\"" << suffix; } @@ -335,26 +467,3 @@ void cmVisualStudioGeneratorOptions::OutputFlagMap(std::ostream& fout, } } } - -void cmVisualStudioGeneratorOptions::OutputAdditionalOptions( - std::ostream& fout, const char* prefix, const char* suffix) -{ - if (!this->FlagString.empty()) { - if (this->Version >= cmGlobalVisualStudioGenerator::VS10) { - fout << prefix; - if (!this->Configuration.empty()) { - this->TargetGenerator->WritePlatformConfigTag( - "AdditionalOptions", this->Configuration.c_str(), 0, 0, 0, &fout); - } else { - fout << "<AdditionalOptions>"; - } - fout << "%(AdditionalOptions) " - << cmVisualStudio10GeneratorOptionsEscapeForXML(this->FlagString) - << "</AdditionalOptions>\n"; - } else { - fout << prefix << "AdditionalOptions=\""; - fout << cmVisualStudioGeneratorOptionsEscapeForXML(this->FlagString); - fout << "\"" << suffix; - } - } -} diff --git a/Source/cmVisualStudioGeneratorOptions.h b/Source/cmVisualStudioGeneratorOptions.h index ab6b8cc..44d2719 100644 --- a/Source/cmVisualStudioGeneratorOptions.h +++ b/Source/cmVisualStudioGeneratorOptions.h @@ -3,7 +3,7 @@ #ifndef cmVisualStudioGeneratorOptions_h #define cmVisualStudioGeneratorOptions_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <iosfwd> #include <string> @@ -26,7 +26,9 @@ public: { Compiler, ResourceCompiler, + CudaCompiler, MasmCompiler, + NasmCompiler, Linker, FortranCompiler, CSharpCompiler @@ -42,10 +44,19 @@ public: // Add a table of flags. void AddTable(cmVS7FlagTable const* table); + // Clear the flag tables. + void ClearTables(); + // Store options from command line flags. void Parse(const char* flags); void ParseFinish(); + void PrependInheritedString(std::string const& key); + + // Parse the content of the given flag table entry again to extract + // known flags and leave the rest in the original entry. + void Reparse(std::string const& key); + // Fix the ExceptionHandling option to default to off. void FixExceptionHandlingDefault(); @@ -56,6 +67,16 @@ public: bool UsingUnicode() const; bool UsingSBCS() const; + enum CudaRuntime + { + CudaRuntimeStatic, + CudaRuntimeShared, + CudaRuntimeNone + }; + CudaRuntime GetCudaRuntime() const; + + void FixCudaCodeGeneration(); + bool IsDebug() const; bool IsWinRt() const; bool IsManaged() const; @@ -64,8 +85,6 @@ public: const char* suffix, const std::string& lang); void OutputFlagMap(std::ostream& fout, const char* indent); - void OutputAdditionalOptions(std::ostream& fout, const char* prefix, - const char* suffix); void SetConfiguration(const char* config); private: @@ -80,7 +99,11 @@ private: bool FortranRuntimeDLL; bool FortranRuntimeMT; + std::string UnknownFlagField; + virtual void StoreUnknownFlag(const char* flag); + + FlagValue TakeFlag(std::string const& key); }; #endif diff --git a/Source/cmVisualStudioSlnData.h b/Source/cmVisualStudioSlnData.h index b2f8db9..e12047f 100644 --- a/Source/cmVisualStudioSlnData.h +++ b/Source/cmVisualStudioSlnData.h @@ -3,7 +3,7 @@ #ifndef cmVisualStudioSlnData_h #define cmVisualStudioSlnData_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <map> #include <string> diff --git a/Source/cmVisualStudioSlnParser.cxx b/Source/cmVisualStudioSlnParser.cxx index 939120a..1a32aba 100644 --- a/Source/cmVisualStudioSlnParser.cxx +++ b/Source/cmVisualStudioSlnParser.cxx @@ -4,7 +4,7 @@ #include "cmSystemTools.h" #include "cmVisualStudioSlnData.h" -#include <cmsys/FStream.hxx> +#include "cmsys/FStream.hxx" #include <cassert> #include <stack> diff --git a/Source/cmVisualStudioSlnParser.h b/Source/cmVisualStudioSlnParser.h index a3391a6..d517324 100644 --- a/Source/cmVisualStudioSlnParser.h +++ b/Source/cmVisualStudioSlnParser.h @@ -3,7 +3,7 @@ #ifndef cmVisualStudioSlnParser_h #define cmVisualStudioSlnParser_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <bitset> #include <iosfwd> diff --git a/Source/cmVisualStudioWCEPlatformParser.h b/Source/cmVisualStudioWCEPlatformParser.h index 8ed6083..75c3d1a 100644 --- a/Source/cmVisualStudioWCEPlatformParser.h +++ b/Source/cmVisualStudioWCEPlatformParser.h @@ -3,7 +3,7 @@ #ifndef cmVisualStudioWCEPlatformParser_h #define cmVisualStudioWCEPlatformParser_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <map> #include <stddef.h> diff --git a/Source/cmWhileCommand.h b/Source/cmWhileCommand.h index abd36b3..daf1046 100644 --- a/Source/cmWhileCommand.h +++ b/Source/cmWhileCommand.h @@ -3,7 +3,8 @@ #ifndef cmWhileCommand_h #define cmWhileCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmWorkingDirectory.cxx b/Source/cmWorkingDirectory.cxx new file mode 100644 index 0000000..99c9ba8 --- /dev/null +++ b/Source/cmWorkingDirectory.cxx @@ -0,0 +1,24 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#include "cmWorkingDirectory.h" + +#include "cmSystemTools.h" + +cmWorkingDirectory::cmWorkingDirectory(std::string const& newdir) +{ + this->OldDir = cmSystemTools::GetCurrentWorkingDirectory(); + cmSystemTools::ChangeDirectory(newdir); +} + +cmWorkingDirectory::~cmWorkingDirectory() +{ + this->Pop(); +} + +void cmWorkingDirectory::Pop() +{ + if (!this->OldDir.empty()) { + cmSystemTools::ChangeDirectory(this->OldDir); + this->OldDir.clear(); + } +} diff --git a/Source/cmWorkingDirectory.h b/Source/cmWorkingDirectory.h new file mode 100644 index 0000000..aff9267 --- /dev/null +++ b/Source/cmWorkingDirectory.h @@ -0,0 +1,25 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#ifndef cmWorkingDirectory_h +#define cmWorkingDirectory_h + +#include "cmConfigure.h" // IWYU pragma: keep + +#include <string> + +/** \class cmWorkingDirectory + * \brief An RAII class to manipulate the working directory. + */ +class cmWorkingDirectory +{ +public: + cmWorkingDirectory(std::string const& newdir); + ~cmWorkingDirectory(); + + void Pop(); + +private: + std::string OldDir; +}; + +#endif diff --git a/Source/cmWriteFileCommand.cxx b/Source/cmWriteFileCommand.cxx index 96c8e27..f569e80 100644 --- a/Source/cmWriteFileCommand.cxx +++ b/Source/cmWriteFileCommand.cxx @@ -2,14 +2,11 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmWriteFileCommand.h" -#include <cmsys/FStream.hxx> - -#include <sys/types.h> -// include sys/stat.h after sys/types.h -#include <sys/stat.h> +#include "cmsys/FStream.hxx" #include "cmMakefile.h" #include "cmSystemTools.h" +#include "cm_sys_stat.h" class cmExecutionStatus; diff --git a/Source/cmWriteFileCommand.h b/Source/cmWriteFileCommand.h index 73e6e22..7196ccf 100644 --- a/Source/cmWriteFileCommand.h +++ b/Source/cmWriteFileCommand.h @@ -3,7 +3,8 @@ #ifndef cmWriteFileCommand_h #define cmWriteFileCommand_h -#include <cmConfigure.h> +#include "cmConfigure.h" + #include <string> #include <vector> diff --git a/Source/cmXCode21Object.h b/Source/cmXCode21Object.h index 083d229..bcd8d93 100644 --- a/Source/cmXCode21Object.h +++ b/Source/cmXCode21Object.h @@ -3,7 +3,7 @@ #ifndef cmXCode21Object_h #define cmXCode21Object_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <iosfwd> #include <vector> diff --git a/Source/cmXCodeObject.h b/Source/cmXCodeObject.h index 3bfecdf..b92e6e3 100644 --- a/Source/cmXCodeObject.h +++ b/Source/cmXCodeObject.h @@ -3,7 +3,7 @@ #ifndef cmXCodeObject_h #define cmXCodeObject_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <algorithm> #include <iosfwd> diff --git a/Source/cmXCodeScheme.cxx b/Source/cmXCodeScheme.cxx new file mode 100644 index 0000000..5c22531 --- /dev/null +++ b/Source/cmXCodeScheme.cxx @@ -0,0 +1,227 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#include "cmXCodeScheme.h" + +#include <iomanip> +#include <iostream> +#include <sstream> + +#include "cmGeneratedFileStream.h" +#include "cmGeneratorTarget.h" +#include "cmXMLSafe.h" + +cmXCodeScheme::cmXCodeScheme(cmXCodeObject* xcObj, + const std::vector<std::string>& configList, + unsigned int xcVersion) + : Target(xcObj) + , TargetName(xcObj->GetTarget()->GetName()) + , BuildableName(xcObj->GetTarget()->GetFullName()) + , TargetId(xcObj->GetId()) + , ConfigList(configList) + , XcodeVersion(xcVersion) +{ +} + +void cmXCodeScheme::WriteXCodeSharedScheme(const std::string& xcProjDir, + const std::string& container) +{ + // Create shared scheme sub-directory tree + // + std::string xcodeSchemeDir = xcProjDir; + xcodeSchemeDir += "/xcshareddata/xcschemes"; + cmSystemTools::MakeDirectory(xcodeSchemeDir.c_str()); + + std::string xcodeSchemeFile = xcodeSchemeDir; + xcodeSchemeFile += "/"; + xcodeSchemeFile += this->TargetName; + xcodeSchemeFile += ".xcscheme"; + + cmGeneratedFileStream fout(xcodeSchemeFile.c_str()); + fout.SetCopyIfDifferent(true); + if (!fout) { + return; + } + + WriteXCodeXCScheme(fout, container); +} + +void cmXCodeScheme::WriteXCodeXCScheme(std::ostream& fout, + const std::string& container) +{ + cmXMLWriter xout(fout); + xout.SetIndentationElement(std::string(3, ' ')); + xout.StartDocument(); + + xout.StartElement("Scheme"); + xout.BreakAttributes(); + xout.Attribute("LastUpgradeVersion", WriteVersionString()); + xout.Attribute("version", "1.3"); + + WriteBuildAction(xout, container); + WriteTestAction(xout, FindConfiguration("Debug")); + WriteLaunchAction(xout, FindConfiguration("Debug"), container); + WriteProfileAction(xout, FindConfiguration("Release")); + WriteAnalyzeAction(xout, FindConfiguration("Debug")); + WriteArchiveAction(xout, FindConfiguration("Release")); + + xout.EndElement(); +} + +void cmXCodeScheme::WriteBuildAction(cmXMLWriter& xout, + const std::string& container) +{ + xout.StartElement("BuildAction"); + xout.BreakAttributes(); + xout.Attribute("parallelizeBuildables", "YES"); + xout.Attribute("buildImplicitDependencies", "YES"); + + xout.StartElement("BuildActionEntries"); + xout.StartElement("BuildActionEntry"); + xout.BreakAttributes(); + xout.Attribute("buildForTesting", "YES"); + xout.Attribute("buildForRunning", "YES"); + xout.Attribute("buildForProfiling", "YES"); + xout.Attribute("buildForArchiving", "YES"); + xout.Attribute("buildForAnalyzing", "YES"); + + xout.StartElement("BuildableReference"); + xout.BreakAttributes(); + xout.Attribute("BuildableIdentifier", "primary"); + xout.Attribute("BlueprintIdentifier", this->TargetId); + xout.Attribute("BuildableName", this->BuildableName); + xout.Attribute("BlueprintName", this->TargetName); + xout.Attribute("ReferencedContainer", "container:" + container); + xout.EndElement(); + + xout.EndElement(); // BuildActionEntry + xout.EndElement(); // BuildActionEntries + xout.EndElement(); // BuildAction +} + +void cmXCodeScheme::WriteTestAction(cmXMLWriter& xout, + std::string configuration) +{ + xout.StartElement("TestAction"); + xout.BreakAttributes(); + xout.Attribute("buildConfiguration", configuration); + xout.Attribute("selectedDebuggerIdentifier", + "Xcode.DebuggerFoundation.Debugger.LLDB"); + xout.Attribute("selectedLauncherIdentifier", + "Xcode.DebuggerFoundation.Launcher.LLDB"); + xout.Attribute("shouldUseLaunchSchemeArgsEnv", "YES"); + + xout.StartElement("Testables"); + xout.EndElement(); + + xout.StartElement("AdditionalOptions"); + xout.EndElement(); + + xout.EndElement(); // TestAction +} + +void cmXCodeScheme::WriteLaunchAction(cmXMLWriter& xout, + std::string configuration, + const std::string& container) +{ + xout.StartElement("LaunchAction"); + xout.BreakAttributes(); + xout.Attribute("buildConfiguration", configuration); + xout.Attribute("selectedDebuggerIdentifier", + "Xcode.DebuggerFoundation.Debugger.LLDB"); + xout.Attribute("selectedLauncherIdentifier", + "Xcode.DebuggerFoundation.Launcher.LLDB"); + xout.Attribute("launchStyle", "0"); + xout.Attribute("useCustomWorkingDirectory", "NO"); + xout.Attribute("ignoresPersistentStateOnLaunch", "NO"); + xout.Attribute("debugDocumentVersioning", "YES"); + xout.Attribute("debugServiceExtension", "internal"); + xout.Attribute("allowLocationSimulation", "YES"); + + if (IsExecutable(this->Target)) { + xout.StartElement("BuildableProductRunnable"); + xout.BreakAttributes(); + xout.Attribute("runnableDebuggingMode", "0"); + + } else { + xout.StartElement("MacroExpansion"); + } + + xout.StartElement("BuildableReference"); + xout.BreakAttributes(); + xout.Attribute("BuildableIdentifier", "primary"); + xout.Attribute("BlueprintIdentifier", this->TargetId); + xout.Attribute("BuildableName", this->BuildableName); + xout.Attribute("BlueprintName", this->TargetName); + xout.Attribute("ReferencedContainer", "container:" + container); + xout.EndElement(); + + xout.EndElement(); // MacroExpansion + + xout.StartElement("AdditionalOptions"); + xout.EndElement(); + + xout.EndElement(); // LaunchAction +} + +void cmXCodeScheme::WriteProfileAction(cmXMLWriter& xout, + std::string configuration) +{ + xout.StartElement("ProfileAction"); + xout.BreakAttributes(); + xout.Attribute("buildConfiguration", configuration); + xout.Attribute("shouldUseLaunchSchemeArgsEnv", "YES"); + xout.Attribute("savedToolIdentifier", ""); + xout.Attribute("useCustomWorkingDirectory", "NO"); + xout.Attribute("debugDocumentVersioning", "YES"); + xout.EndElement(); +} + +void cmXCodeScheme::WriteAnalyzeAction(cmXMLWriter& xout, + std::string configuration) +{ + xout.StartElement("AnalyzeAction"); + xout.BreakAttributes(); + xout.Attribute("buildConfiguration", configuration); + xout.EndElement(); +} + +void cmXCodeScheme::WriteArchiveAction(cmXMLWriter& xout, + std::string configuration) +{ + xout.StartElement("ArchiveAction"); + xout.BreakAttributes(); + xout.Attribute("buildConfiguration", configuration); + xout.Attribute("revealArchiveInOrganizer", "YES"); + xout.EndElement(); +} + +std::string cmXCodeScheme::WriteVersionString() +{ + std::ostringstream v; + v << std::setfill('0') << std::setw(4) << this->XcodeVersion * 10; + return v.str(); +} + +std::string cmXCodeScheme::FindConfiguration(const std::string& name) +{ + // Try to find the desired configuration by name, + // and if it's not found return first from the list + // + if (std::find(this->ConfigList.begin(), this->ConfigList.end(), name) == + this->ConfigList.end() && + this->ConfigList.size() > 0) + return this->ConfigList[0]; + + return name; +} + +bool cmXCodeScheme::IsExecutable(const cmXCodeObject* target) +{ + cmGeneratorTarget* gt = target->GetTarget(); + if (!gt) { + cmSystemTools::Error("Error no target on xobject\n"); + return false; + } + + return gt->GetType() == cmStateEnums::EXECUTABLE; +} diff --git a/Source/cmXCodeScheme.h b/Source/cmXCodeScheme.h new file mode 100644 index 0000000..379afed --- /dev/null +++ b/Source/cmXCodeScheme.h @@ -0,0 +1,50 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#ifndef cmXCodeScheme_h +#define cmXCodeScheme_h + +#include "cmConfigure.h" // IWYU pragma: keep + +#include "cmGlobalXCodeGenerator.h" +#include "cmSystemTools.h" +#include "cmXCodeObject.h" +#include "cmXMLWriter.h" + +/** \class cmXCodeScheme + * \brief Write shared schemes for native targets in Xcode project. + */ +class cmXCodeScheme +{ +public: + cmXCodeScheme(cmXCodeObject* xcObj, + const std::vector<std::string>& configList, + unsigned int xcVersion); + + void WriteXCodeSharedScheme(const std::string& xcProjDir, + const std::string& container); + +private: + const cmXCodeObject* const Target; + const std::string& TargetName; + const std::string BuildableName; + const std::string& TargetId; + const std::vector<std::string>& ConfigList; + const unsigned int XcodeVersion; + + void WriteXCodeXCScheme(std::ostream& fout, const std::string& container); + + void WriteBuildAction(cmXMLWriter& xout, const std::string& container); + void WriteTestAction(cmXMLWriter& xout, std::string configuration); + void WriteLaunchAction(cmXMLWriter& xout, std::string configuration, + const std::string& container); + void WriteProfileAction(cmXMLWriter& xout, std::string configuration); + void WriteAnalyzeAction(cmXMLWriter& xout, std::string configuration); + void WriteArchiveAction(cmXMLWriter& xout, std::string configuration); + + std::string WriteVersionString(); + std::string FindConfiguration(const std::string& name); + + static bool IsExecutable(const cmXCodeObject* target); +}; + +#endif diff --git a/Source/cmXMLParser.cxx b/Source/cmXMLParser.cxx index 231e95e..18afbf3 100644 --- a/Source/cmXMLParser.cxx +++ b/Source/cmXMLParser.cxx @@ -2,8 +2,8 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmXMLParser.h" -#include <cm_expat.h> -#include <cmsys/FStream.hxx> +#include "cm_expat.h" +#include "cmsys/FStream.hxx" #include <ctype.h> #include <iostream> #include <sstream> diff --git a/Source/cmXMLParser.h b/Source/cmXMLParser.h index 60da51e..98ba049 100644 --- a/Source/cmXMLParser.h +++ b/Source/cmXMLParser.h @@ -3,7 +3,7 @@ #ifndef cmXMLParser_h #define cmXMLParser_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <string> diff --git a/Source/cmXMLSafe.h b/Source/cmXMLSafe.h index c41554d..9aaf2d1 100644 --- a/Source/cmXMLSafe.h +++ b/Source/cmXMLSafe.h @@ -3,7 +3,7 @@ #ifndef cmXMLSafe_h #define cmXMLSafe_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <iosfwd> #include <string> diff --git a/Source/cmXMLWriter.cxx b/Source/cmXMLWriter.cxx index 2f50fe9..3cbc70d 100644 --- a/Source/cmXMLWriter.cxx +++ b/Source/cmXMLWriter.cxx @@ -2,11 +2,12 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmXMLWriter.h" +#include "cmsys/FStream.hxx" #include <cassert> -#include <cmsys/FStream.hxx> cmXMLWriter::cmXMLWriter(std::ostream& output, std::size_t level) : Output(output) + , IndentationElement(1, '\t') , Level(level) , ElementOpen(false) , BreakAttrib(false) @@ -100,10 +101,18 @@ void cmXMLWriter::FragmentFile(const char* fname) this->Output << fin.rdbuf(); } +void cmXMLWriter::SetIndentationElement(std::string const& element) +{ + this->IndentationElement = element; +} + void cmXMLWriter::ConditionalLineBreak(bool condition, std::size_t indent) { if (condition) { - this->Output << '\n' << std::string(indent + this->Level, '\t'); + this->Output << '\n'; + for (std::size_t i = 0; i < indent + this->Level; ++i) { + this->Output << this->IndentationElement; + } } } diff --git a/Source/cmXMLWriter.h b/Source/cmXMLWriter.h index 904f73b..14c82b1 100644 --- a/Source/cmXMLWriter.h +++ b/Source/cmXMLWriter.h @@ -3,7 +3,7 @@ #ifndef cmXMLWiter_h #define cmXMLWiter_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include "cmXMLSafe.h" @@ -60,6 +60,8 @@ public: void FragmentFile(const char* fname); + void SetIndentationElement(std::string const& element); + private: cmXMLWriter(const cmXMLWriter&); cmXMLWriter& operator=(const cmXMLWriter&); @@ -107,6 +109,7 @@ private: private: std::ostream& Output; std::stack<std::string, std::vector<std::string> > Elements; + std::string IndentationElement; std::size_t Level; bool ElementOpen; bool BreakAttrib; diff --git a/Source/cm_auto_ptr.hxx b/Source/cm_auto_ptr.hxx index 5382018..2b5c059 100644 --- a/Source/cm_auto_ptr.hxx +++ b/Source/cm_auto_ptr.hxx @@ -3,7 +3,7 @@ #ifndef CM_AUTO_PTR_HXX #define CM_AUTO_PTR_HXX -#include <cmConfigure.h> +#include "cmConfigure.h" #ifdef CMake_HAVE_CXX_AUTO_PTR diff --git a/Source/cm_codecvt.cxx b/Source/cm_codecvt.cxx index 869dd32..fcd1e48 100644 --- a/Source/cm_codecvt.cxx +++ b/Source/cm_codecvt.cxx @@ -6,7 +6,7 @@ #if defined(_WIN32) #include <windows.h> #undef max -#include <cmsys/Encoding.hxx> +#include "cmsys/Encoding.hxx" #endif codecvt::codecvt(Encoding e) diff --git a/Source/cm_codecvt.hxx b/Source/cm_codecvt.hxx index fcd9954..b9b52ec 100644 --- a/Source/cm_codecvt.hxx +++ b/Source/cm_codecvt.hxx @@ -3,7 +3,7 @@ #ifndef cm_codecvt_hxx #define cm_codecvt_hxx -#include <cmConfigure.h> +#include "cmConfigure.h" #include <locale> #include <vector> diff --git a/Source/cm_sys_stat.h b/Source/cm_sys_stat.h new file mode 100644 index 0000000..26e4baa --- /dev/null +++ b/Source/cm_sys_stat.h @@ -0,0 +1,14 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#ifndef cm_sys_stat_h +#define cm_sys_stat_h + +#if defined(_MSC_VER) +typedef unsigned short mode_t; +#endif + +#include <sys/types.h> +// include sys/stat.h after sys/types.h +#include <sys/stat.h> + +#endif diff --git a/Source/cm_unordered_map.hxx b/Source/cm_unordered_map.hxx index dc8ca35..bf38903 100644 --- a/Source/cm_unordered_map.hxx +++ b/Source/cm_unordered_map.hxx @@ -3,7 +3,7 @@ #ifndef CM_UNORDERED_MAP_HXX #define CM_UNORDERED_MAP_HXX -#include <cmConfigure.h> +#include "cmConfigure.h" #if defined(CMake_HAVE_CXX_UNORDERED_MAP) @@ -12,7 +12,7 @@ #elif defined(CMAKE_BUILD_WITH_CMAKE) -#include <cmsys/hash_map.hxx> +#include "cmsys/hash_map.hxx" #define CM_UNORDERED_MAP cmsys::hash_map #else diff --git a/Source/cm_unordered_set.hxx b/Source/cm_unordered_set.hxx index ce58dbf..dd1a9a1 100644 --- a/Source/cm_unordered_set.hxx +++ b/Source/cm_unordered_set.hxx @@ -3,7 +3,7 @@ #ifndef CM_UNORDERED_SET_HXX #define CM_UNORDERED_SET_HXX -#include <cmConfigure.h> +#include "cmConfigure.h" #if defined(CMake_HAVE_CXX_UNORDERED_SET) @@ -12,7 +12,7 @@ #elif defined(CMAKE_BUILD_WITH_CMAKE) -#include <cmsys/hash_set.hxx> +#include "cmsys/hash_set.hxx" #define CM_UNORDERED_SET cmsys::hash_set #else diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 6141f50..737587d 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -23,10 +23,12 @@ #include "cmTargetLinkLibraryType.h" #include "cmUtils.hxx" #include "cmVersionConfig.h" +#include "cmWorkingDirectory.h" #include "cm_auto_ptr.hxx" +#include "cm_sys_stat.h" #if defined(CMAKE_BUILD_WITH_CMAKE) -#include <cm_jsoncpp_writer.h> +#include "cm_jsoncpp_writer.h" #include "cmGraphVizWriter.h" #include "cmVariableWatch.h" @@ -61,7 +63,6 @@ #include "cmGlobalVisualStudio12Generator.h" #include "cmGlobalVisualStudio14Generator.h" #include "cmGlobalVisualStudio15Generator.h" -#include "cmGlobalVisualStudio71Generator.h" #include "cmGlobalVisualStudio8Generator.h" #include "cmGlobalVisualStudio9Generator.h" #include "cmVSSetupHelper.h" @@ -105,14 +106,10 @@ #include <sys/time.h> #endif -#include <sys/types.h> -// include sys/stat.h after sys/types.h -#include <sys/stat.h> // struct stat - +#include "cmsys/FStream.hxx" +#include "cmsys/Glob.hxx" +#include "cmsys/RegularExpression.hxx" #include <algorithm> -#include <cmsys/FStream.hxx> -#include <cmsys/Glob.hxx> -#include <cmsys/RegularExpression.hxx> #include <iostream> #include <sstream> #include <stdio.h> @@ -120,8 +117,6 @@ #include <string.h> #include <utility> -class cmCommand; - namespace { #if defined(CMAKE_BUILD_WITH_CMAKE) @@ -179,7 +174,8 @@ cmake::cmake() this->AddDefaultGenerators(); this->AddDefaultExtraGenerators(); - this->AddDefaultCommands(); + this->AddScriptingCommands(); + this->AddProjectCommands(); // Make sure we can capture the build tool output. cmSystemTools::EnableVSConsoleOutput(); @@ -1464,8 +1460,7 @@ void cmake::CreateDefaultGlobalGenerator() { "11.0", "Visual Studio 11 2012" }, // { "10.0", "Visual Studio 10 2010" }, // { "9.0", "Visual Studio 9 2008" }, // - { "8.0", "Visual Studio 8 2005" }, // - { "7.1", "Visual Studio 7 .NET 2003" } + { "8.0", "Visual Studio 8 2005" } }; static const char* const vsEntries[] = { "\\Setup\\VC;ProductDir", // @@ -1654,13 +1649,14 @@ const char* cmake::GetCacheDefinition(const std::string& name) const return this->State->GetInitializedCacheValue(name); } -void cmake::AddDefaultCommands() +void cmake::AddScriptingCommands() { - std::vector<cmCommand*> const commands = GetPredefinedCommands(); - for (std::vector<cmCommand*>::const_iterator i = commands.begin(); - i != commands.end(); ++i) { - this->State->AddCommand(*i); - } + GetScriptingCommands(this->State); +} + +void cmake::AddProjectCommands() +{ + GetProjectCommands(this->State); } void cmake::AddDefaultGenerators() @@ -1674,7 +1670,6 @@ void cmake::AddDefaultGenerators() this->Generators.push_back(cmGlobalVisualStudio10Generator::NewFactory()); this->Generators.push_back(cmGlobalVisualStudio9Generator::NewFactory()); this->Generators.push_back(cmGlobalVisualStudio8Generator::NewFactory()); - this->Generators.push_back(cmGlobalVisualStudio71Generator::NewFactory()); this->Generators.push_back(cmGlobalBorlandMakefileGenerator::NewFactory()); this->Generators.push_back(cmGlobalNMakeMakefileGenerator::NewFactory()); this->Generators.push_back(cmGlobalJOMMakefileGenerator::NewFactory()); @@ -2199,24 +2194,23 @@ int cmake::GetSystemInformation(std::vector<std::string>& args) resultFile += "/__cmake_systeminformation/results.txt"; } - // now run cmake on the CMakeLists file - cmSystemTools::ChangeDirectory(destPath); - std::vector<std::string> args2; - args2.push_back(args[0]); - args2.push_back(destPath); - std::string resultArg = "-DRESULT_FILE="; - resultArg += resultFile; - args2.push_back(resultArg); - int res = this->Run(args2, false); + { + // now run cmake on the CMakeLists file + cmWorkingDirectory workdir(destPath); + std::vector<std::string> args2; + args2.push_back(args[0]); + args2.push_back(destPath); + std::string resultArg = "-DRESULT_FILE="; + resultArg += resultFile; + args2.push_back(resultArg); + int res = this->Run(args2, false); - if (res != 0) { - std::cerr << "Error: --system-information failed on internal CMake!\n"; - return res; + if (res != 0) { + std::cerr << "Error: --system-information failed on internal CMake!\n"; + return res; + } } - // change back to the original directory - cmSystemTools::ChangeDirectory(cwd); - // echo results to stdout if needed if (writeToStdout) { FILE* fin = cmsys::SystemTools::Fopen(resultFile, "r"); diff --git a/Source/cmake.h b/Source/cmake.h index 5347745..6a6beb4 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -3,7 +3,7 @@ #ifndef cmake_h #define cmake_h -#include <cmConfigure.h> +#include "cmConfigure.h" #include <map> #include <set> @@ -16,7 +16,7 @@ #include "cmStateTypes.h" #if defined(CMAKE_BUILD_WITH_CMAKE) -#include <cm_jsoncpp_value.h> +#include "cm_jsoncpp_value.h" #endif class cmExternalMakefileProjectGeneratorFactory; @@ -409,7 +409,7 @@ public: void WatchUnusedCli(const std::string& var); cmState* GetState() const { return this->State; } - void SetCurrentSnapshot(cmStateSnapshot snapshot) + void SetCurrentSnapshot(cmStateSnapshot const& snapshot) { this->CurrentSnapshot = snapshot; } @@ -425,7 +425,8 @@ protected: typedef std::vector<cmExternalMakefileProjectGeneratorFactory*> RegisteredExtraGeneratorsVector; RegisteredExtraGeneratorsVector ExtraGenerators; - void AddDefaultCommands(); + void AddScriptingCommands(); + void AddProjectCommands(); void AddDefaultGenerators(); void AddDefaultExtraGenerators(); diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index b8e227f..3d11241 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -1,11 +1,6 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -// include these first, otherwise there will be problems on Windows -// with GetCurrentDirectory() being redefined -#ifdef CMAKE_BUILD_WITH_CMAKE -#include "cmDocumentation.h" -#include "cmDynamicLoader.h" -#endif +#include "cmConfigure.h" #include "cmAlgorithms.h" #include "cmDocumentationEntry.h" @@ -17,10 +12,14 @@ #include "cmake.h" #include "cmcmd.h" -#include <cmConfigure.h> -#include <cmsys/Encoding.hxx> +#ifdef CMAKE_BUILD_WITH_CMAKE +#include "cmDocumentation.h" +#include "cmDynamicLoader.h" +#endif + +#include "cmsys/Encoding.hxx" #if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE) -#include <cmsys/ConsoleBuf.hxx> +#include "cmsys/ConsoleBuf.hxx" #endif #include <iostream> #include <string.h> @@ -28,7 +27,7 @@ #include <vector> #ifdef CMAKE_USE_LIBUV -#include <cm_uv.h> +#include "cm_uv.h" #endif #ifdef CMAKE_BUILD_WITH_CMAKE diff --git a/Source/cmakexbuild.cxx b/Source/cmakexbuild.cxx index e166bee..f1f4bbb 100644 --- a/Source/cmakexbuild.cxx +++ b/Source/cmakexbuild.cxx @@ -1,9 +1,9 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep -#include <cmsys/Process.h> +#include "cmsys/Process.h" #include <iostream> #include <string> #include <vector> diff --git a/Source/cmcldeps.cxx b/Source/cmcldeps.cxx index b86ad6e..0c5bbe2 100644 --- a/Source/cmcldeps.cxx +++ b/Source/cmcldeps.cxx @@ -18,8 +18,8 @@ // /showIncludes is equivalent to -MD, not -MMD, that is, system headers are // included. -#include <cmSystemTools.h> -#include <cmsys/Encoding.hxx> +#include "cmSystemTools.h" +#include "cmsys/Encoding.hxx" #include <algorithm> #include <sstream> diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 823b38f..cc954e6 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -32,12 +32,12 @@ #include "cmVisualStudioWCEPlatformParser.h" #endif +#include "cmConfigure.h" +#include "cmsys/Directory.hxx" +#include "cmsys/FStream.hxx" +#include "cmsys/Process.h" +#include "cmsys/Terminal.h" #include <algorithm> -#include <cmConfigure.h> -#include <cmsys/Directory.hxx> -#include <cmsys/FStream.hxx> -#include <cmsys/Process.h> -#include <cmsys/Terminal.h> #include <iostream> #include <sstream> #include <stdio.h> @@ -258,11 +258,18 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) << "\n"; return 1; } - std::string objfile; + std::string file; bindexplib deffile; - while (cmSystemTools::GetLineFromStream(fin, objfile)) { - if (!deffile.AddObjectFile(objfile.c_str())) { - return 1; + while (cmSystemTools::GetLineFromStream(fin, file)) { + std::string const& ext = cmSystemTools::GetFilenameLastExtension(file); + if (cmSystemTools::LowerCase(ext) == ".def") { + if (!deffile.AddDefinitionFile(file.c_str())) { + return 1; + } + } else { + if (!deffile.AddObjectFile(file.c_str())) { + return 1; + } } } deffile.WriteFile(fout); @@ -1443,7 +1450,8 @@ bool cmVSLink::Parse(std::vector<std::string>::const_iterator argBeg, if (*arg == "--") { ++arg; break; - } else if (*arg == "--manifests") { + } + if (*arg == "--manifests") { for (++arg; arg != argEnd && !cmHasLiteralPrefix(*arg, "-"); ++arg) { this->UserManifests.push_back(*arg); } diff --git a/Source/cmcmd.h b/Source/cmcmd.h index 139d2a8..929f1ae 100644 --- a/Source/cmcmd.h +++ b/Source/cmcmd.h @@ -3,7 +3,7 @@ #ifndef cmcmd_h #define cmcmd_h -#include <cmConfigure.h> // IWYU pragma: keep +#include "cmConfigure.h" // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/ctest.cxx b/Source/ctest.cxx index 1cf75c8..135062d 100644 --- a/Source/ctest.cxx +++ b/Source/ctest.cxx @@ -1,6 +1,6 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#include <cmConfigure.h> +#include "cmConfigure.h" #include "CTest/cmCTestLaunch.h" #include "CTest/cmCTestScriptHandler.h" @@ -9,9 +9,9 @@ #include "cmSystemTools.h" #include "cmake.h" -#include <cmsys/Encoding.hxx> +#include "cmsys/Encoding.hxx" #if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE) -#include <cmsys/ConsoleBuf.hxx> +#include "cmsys/ConsoleBuf.hxx" #endif #include <iostream> #include <string.h> diff --git a/Source/kwsys/.gitattributes b/Source/kwsys/.gitattributes index a121ad1..7065eb5 100644 --- a/Source/kwsys/.gitattributes +++ b/Source/kwsys/.gitattributes @@ -1,12 +1,13 @@ .git* export-ignore -*.c whitespace=tab-in-indent,no-lf-at-eof -*.h whitespace=tab-in-indent,no-lf-at-eof -*.h.in whitespace=tab-in-indent,no-lf-at-eof -*.cxx whitespace=tab-in-indent,no-lf-at-eof -*.hxx whitespace=tab-in-indent,no-lf-at-eof -*.hxx.in whitespace=tab-in-indent,no-lf-at-eof -*.txt whitespace=tab-in-indent,no-lf-at-eof -*.cmake whitespace=tab-in-indent,no-lf-at-eof +*.c kwsys-c-style +*.c.in kwsys-c-style +*.cxx kwsys-c-style +*.h kwsys-c-style +*.h.in kwsys-c-style +*.hxx kwsys-c-style +*.hxx.in kwsys-c-style +*.cmake whitespace=tab-in-indent *.rst whitespace=tab-in-indent conflict-marker-size=79 +*.txt whitespace=tab-in-indent diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt index d4fe8a7..e15b49e 100644 --- a/Source/kwsys/CMakeLists.txt +++ b/Source/kwsys/CMakeLists.txt @@ -69,6 +69,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6.3 FATAL_ERROR) FOREACH(p CMP0025 # CMake 3.0, Compiler id for Apple Clang is now AppleClang. + CMP0048 # CMake 3.0, Let the project command manage version variables. CMP0056 # CMake 3.2, Honor link flags in try_compile() source-file signature. CMP0063 # CMake 3.3, Honor visibility properties for all target types. ) @@ -796,6 +797,8 @@ ENDFOREACH() IF(KWSYS_C_SRCS OR KWSYS_CXX_SRCS) ADD_LIBRARY(${KWSYS_NAMESPACE} ${KWSYS_LIBRARY_TYPE} ${KWSYS_C_SRCS} ${KWSYS_CXX_SRCS}) + SET_PROPERTY(TARGET ${KWSYS_NAMESPACE} PROPERTY C_INCLUDE_WHAT_YOU_USE "") + SET_PROPERTY(TARGET ${KWSYS_NAMESPACE} PROPERTY CXX_INCLUDE_WHAT_YOU_USE "") SET_PROPERTY(TARGET ${KWSYS_NAMESPACE} PROPERTY LABELS ${KWSYS_LABELS_LIB}) IF(KWSYS_USE_DynamicLoader) IF(UNIX) @@ -940,13 +943,15 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) ENDIF() IF(KWSYS_USE_ConsoleBuf) ADD_EXECUTABLE(testConsoleBufChild testConsoleBufChild.cxx) + SET_PROPERTY(TARGET testConsoleBufChild PROPERTY C_INCLUDE_WHAT_YOU_USE "") + SET_PROPERTY(TARGET testConsoleBufChild PROPERTY CXX_INCLUDE_WHAT_YOU_USE "") SET_PROPERTY(TARGET testConsoleBufChild PROPERTY LABELS ${KWSYS_LABELS_EXE}) TARGET_LINK_LIBRARIES(testConsoleBufChild ${KWSYS_NAMESPACE}) SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testConsoleBuf ) IF("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC" AND - NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "19.0") + CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "19.0.23506") set_property(SOURCE testConsoleBuf.cxx testConsoleBufChild.cxx PROPERTY COMPILE_FLAGS /utf-8) ENDIF() SET_PROPERTY(SOURCE testConsoleBuf.cxx APPEND PROPERTY COMPILE_DEFINITIONS @@ -967,6 +972,8 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) ${KWSYS_CXX_TESTS} ) ADD_EXECUTABLE(${KWSYS_NAMESPACE}TestsCxx ${KWSYS_CXX_TEST_SRCS}) + SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestsCxx PROPERTY C_INCLUDE_WHAT_YOU_USE "") + SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestsCxx PROPERTY CXX_INCLUDE_WHAT_YOU_USE "") SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestsCxx PROPERTY LABELS ${KWSYS_LABELS_EXE}) TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE}TestsCxx ${KWSYS_NAMESPACE}) diff --git a/Source/kwsys/ConsoleBuf.hxx.in b/Source/kwsys/ConsoleBuf.hxx.in index cb58865..32e680c 100644 --- a/Source/kwsys/ConsoleBuf.hxx.in +++ b/Source/kwsys/ConsoleBuf.hxx.in @@ -25,8 +25,7 @@ namespace @KWSYS_NAMESPACE@ { #if defined(_WIN32) template <class CharT, class Traits = std::char_traits<CharT> > -class @KWSYS_NAMESPACE@_EXPORT BasicConsoleBuf - : public std::basic_streambuf<CharT, Traits> +class BasicConsoleBuf : public std::basic_streambuf<CharT, Traits> { public: typedef typename Traits::int_type int_type; diff --git a/Source/kwsys/Encoding.hxx.in b/Source/kwsys/Encoding.hxx.in index 6639efd..09691fd 100644 --- a/Source/kwsys/Encoding.hxx.in +++ b/Source/kwsys/Encoding.hxx.in @@ -13,7 +13,7 @@ class @KWSYS_NAMESPACE@_EXPORT Encoding { public: // Container class for argc/argv. - class CommandLineArguments + class @KWSYS_NAMESPACE@_EXPORT CommandLineArguments { public: // On Windows, get the program command line arguments @@ -59,6 +59,17 @@ public: static std::string ToNarrow(const std::wstring& str); static std::string ToNarrow(const wchar_t* str); +#if defined(_WIN32) + /** + * Convert the path to an extended length path to avoid MAX_PATH length + * limitations on Windows. If the input is a local path the result will be + * prefixed with \\?\; if the input is instead a network path, the result + * will be prefixed with \\?\UNC\. All output will also be converted to + * absolute paths with Windows-style backslashes. + **/ + static std::wstring ToWindowsExtendedPath(std::string const&); +#endif + #endif // @KWSYS_NAMESPACE@_STL_HAS_WSTRING }; // class Encoding diff --git a/Source/kwsys/EncodingCXX.cxx b/Source/kwsys/EncodingCXX.cxx index e904c1a..641c0e6 100644 --- a/Source/kwsys/EncodingCXX.cxx +++ b/Source/kwsys/EncodingCXX.cxx @@ -29,6 +29,7 @@ #if defined(_WIN32) #include <windows.h> +#include <ctype.h> #include <shellapi.h> #endif @@ -214,6 +215,63 @@ std::string Encoding::ToNarrow(const wchar_t* wcstr) } return str; } + +#if defined(_WIN32) +// Convert local paths to UNC style paths +std::wstring Encoding::ToWindowsExtendedPath(std::string const& source) +{ + std::wstring wsource = Encoding::ToWide(source); + + // Resolve any relative paths + DWORD wfull_len; + + /* The +3 is a workaround for a bug in some versions of GetFullPathNameW that + * won't return a large enough buffer size if the input is too small */ + wfull_len = GetFullPathNameW(wsource.c_str(), 0, NULL, NULL) + 3; + std::vector<wchar_t> wfull(wfull_len); + GetFullPathNameW(wsource.c_str(), wfull_len, &wfull[0], NULL); + + /* This should get the correct size without any extra padding from the + * previous size workaround. */ + wfull_len = static_cast<DWORD>(wcslen(&wfull[0])); + + if (wfull_len >= 2 && isalpha(wfull[0]) && + wfull[1] == L':') { /* C:\Foo\bar\FooBar.txt */ + return L"\\\\?\\" + std::wstring(&wfull[0]); + } else if (wfull_len >= 2 && wfull[0] == L'\\' && + wfull[1] == L'\\') { /* Starts with \\ */ + if (wfull_len >= 4 && wfull[2] == L'?' && + wfull[3] == L'\\') { /* Starts with \\?\ */ + if (wfull_len >= 8 && wfull[4] == L'U' && wfull[5] == L'N' && + wfull[6] == L'C' && + wfull[7] == L'\\') { /* \\?\UNC\Foo\bar\FooBar.txt */ + return std::wstring(&wfull[0]); + } else if (wfull_len >= 6 && isalpha(wfull[4]) && + wfull[5] == L':') { /* \\?\C:\Foo\bar\FooBar.txt */ + return std::wstring(&wfull[0]); + } else if (wfull_len >= 5) { /* \\?\Foo\bar\FooBar.txt */ + return L"\\\\?\\UNC\\" + std::wstring(&wfull[4]); + } + } else if (wfull_len >= 4 && wfull[2] == L'.' && + wfull[3] == L'\\') { /* Starts with \\.\ a device name */ + if (wfull_len >= 6 && isalpha(wfull[4]) && + wfull[5] == L':') { /* \\.\C:\Foo\bar\FooBar.txt */ + return L"\\\\?\\" + std::wstring(&wfull[4]); + } else if (wfull_len >= + 5) { /* \\.\Foo\bar\ Device name is left unchanged */ + return std::wstring(&wfull[0]); + } + } else if (wfull_len >= 3) { /* \\Foo\bar\FooBar.txt */ + return L"\\\\?\\UNC\\" + std::wstring(&wfull[2]); + } + } + + // If this case has been reached, then the path is invalid. Leave it + // unchanged + return Encoding::ToWide(source); +} +#endif + #endif // KWSYS_STL_HAS_WSTRING } // namespace KWSYS_NAMESPACE diff --git a/Source/kwsys/FStream.hxx.in b/Source/kwsys/FStream.hxx.in index 736214f..a4c65fe 100644 --- a/Source/kwsys/FStream.hxx.in +++ b/Source/kwsys/FStream.hxx.in @@ -33,7 +33,7 @@ public: typedef std::basic_filebuf<CharType, Traits> my_base_type; basic_filebuf* open(char const* s, std::ios_base::openmode mode) { - const std::wstring wstr = Encoding::ToWide(s); + const std::wstring wstr = Encoding::ToWindowsExtendedPath(s); return static_cast<basic_filebuf*>(my_base_type::open(wstr.c_str(), mode)); } #endif @@ -93,7 +93,7 @@ public: #if defined(_MSC_VER) const bool success = buf_->open(file_name, mode) != 0; #else - const std::wstring wstr = Encoding::ToWide(file_name); + const std::wstring wstr = Encoding::ToWindowsExtendedPath(file_name); bool success = false; std::wstring cmode = getcmode(mode); file_ = _wfopen(wstr.c_str(), cmode.c_str()); @@ -170,8 +170,6 @@ template <typename CharType, typename Traits = std::char_traits<CharType> > class basic_ifstream : public std::basic_istream<CharType, Traits>, public basic_efilebuf<CharType, Traits> { - using basic_efilebuf<CharType, Traits>::is_open; - public: typedef typename basic_efilebuf<CharType, Traits>::internal_buffer_type internal_buffer_type; @@ -201,6 +199,8 @@ public: void close() { this->_set_state(this->_close(), this, this); } + using basic_efilebuf<CharType, Traits>::is_open; + internal_buffer_type* rdbuf() const { return this->buf_; } ~basic_ifstream() @KWSYS_NAMESPACE@_FStream_NOEXCEPT { close(); } @@ -269,7 +269,7 @@ enum BOM // If a BOM exists, the stream is advanced to after the BOM. // This function requires a seekable stream (but not a relative // seekable stream). -BOM ReadBOM(std::istream& in); +@KWSYS_NAMESPACE@_EXPORT BOM ReadBOM(std::istream& in); } } diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx index e01dcd7..70f1a43 100644 --- a/Source/kwsys/SystemInformation.cxx +++ b/Source/kwsys/SystemInformation.cxx @@ -35,8 +35,13 @@ #include "SystemInformation.hxx.in" #endif +#include <algorithm> +#include <bitset> +#include <cassert> #include <fstream> #include <iostream> +#include <limits> +#include <set> #include <sstream> #include <string> #include <vector> @@ -394,7 +399,6 @@ public: bool SupportsMP; bool HasMMXPlus; bool HasSSEMMX; - bool SupportsHyperthreading; unsigned int LogicalProcessorsPerPhysical; int APIC_ID; CPUPowerManagement PowerManagement; @@ -463,10 +467,9 @@ protected: unsigned int NumberOfLogicalCPU; unsigned int NumberOfPhysicalCPU; - int CPUCount(); // For windows - unsigned char LogicalCPUPerPhysicalCPU(); + void CPUCountWindows(); // For windows unsigned char GetAPICId(); // For windows - bool IsHyperThreadingSupported(); + bool IsSMTSupported(); static LongLong GetCyclesDifference(DELAY_FUNC, unsigned int); // For windows // For Linux and Cygwin, /proc/cpuinfo formats are slightly different @@ -536,6 +539,7 @@ protected: std::string OSRelease; std::string OSVersion; std::string OSPlatform; + bool OSIs64Bit; }; SystemInformation::SystemInformation() @@ -1496,6 +1500,7 @@ SystemInformationImplementation::SystemInformationImplementation() this->OSRelease = ""; this->OSVersion = ""; this->OSPlatform = ""; + this->OSIs64Bit = (sizeof(void*) == 8); } SystemInformationImplementation::~SystemInformationImplementation() @@ -1542,7 +1547,7 @@ void SystemInformationImplementation::RunCPUCheck() RetrieveProcessorSerialNumber(); } - this->CPUCount(); + this->CPUCountWindows(); #elif defined(__APPLE__) this->ParseSysCtl(); @@ -2090,16 +2095,10 @@ bool SystemInformationImplementation::RetrieveCPUFeatures() // Retrieve Intel specific extended features. if (this->ChipManufacturer == Intel) { - this->Features.ExtendedFeatures.SupportsHyperthreading = - ((cpuinfo[3] & 0x10000000) != - 0); // Intel specific: Hyperthreading --> Bit 28 - this->Features.ExtendedFeatures.LogicalProcessorsPerPhysical = - (this->Features.ExtendedFeatures.SupportsHyperthreading) - ? ((cpuinfo[1] & 0x00FF0000) >> 16) - : 1; - - if ((this->Features.ExtendedFeatures.SupportsHyperthreading) && - (this->Features.HasAPIC)) { + bool SupportsSMT = + ((cpuinfo[3] & 0x10000000) != 0); // Intel specific: SMT --> Bit 28 + + if ((SupportsSMT) && (this->Features.HasAPIC)) { // Retrieve APIC information if there is one present. this->Features.ExtendedFeatures.APIC_ID = ((cpuinfo[1] & 0xFF000000) >> 24); @@ -3401,7 +3400,7 @@ bool SystemInformationImplementation::RetreiveInformationFromCpuInfoFile() fclose(fd); buffer.resize(fileSize - 2); // Number of logical CPUs (combination of multiple processors, multi-core - // and hyperthreading) + // and SMT) size_t pos = buffer.find("processor\t"); while (pos != buffer.npos) { this->NumberOfLogicalCPU++; @@ -3409,30 +3408,25 @@ bool SystemInformationImplementation::RetreiveInformationFromCpuInfoFile() } #ifdef __linux - // Find the largest physical id. - int maxId = -1; + // Count sockets. + std::set<int> PhysicalIDs; std::string idc = this->ExtractValueFromCpuInfoFile(buffer, "physical id"); while (this->CurrentPositionInFile != buffer.npos) { int id = atoi(idc.c_str()); - if (id > maxId) { - maxId = id; - } + PhysicalIDs.insert(id); idc = this->ExtractValueFromCpuInfoFile(buffer, "physical id", this->CurrentPositionInFile + 1); } + uint64_t NumberOfSockets = PhysicalIDs.size(); + NumberOfSockets = std::max(NumberOfSockets, (uint64_t)1); // Physical ids returned by Linux don't distinguish cores. // We want to record the total number of cores in this->NumberOfPhysicalCPU // (checking only the first proc) - std::string cores = this->ExtractValueFromCpuInfoFile(buffer, "cpu cores"); - int numberOfCoresPerCPU = atoi(cores.c_str()); - if (maxId > 0) { - this->NumberOfPhysicalCPU = - static_cast<unsigned int>(numberOfCoresPerCPU * (maxId + 1)); - } else { - // Linux Sparc: get cpu count - this->NumberOfPhysicalCPU = - atoi(this->ExtractValueFromCpuInfoFile(buffer, "ncpus active").c_str()); - } + std::string Cores = this->ExtractValueFromCpuInfoFile(buffer, "cpu cores"); + unsigned int NumberOfCoresPerSocket = (unsigned int)atoi(Cores.c_str()); + NumberOfCoresPerSocket = std::max(NumberOfCoresPerSocket, 1u); + this->NumberOfPhysicalCPU = + NumberOfCoresPerSocket * (unsigned int)NumberOfSockets; #else // __CYGWIN__ // does not have "physical id" entries, neither "cpu cores" @@ -3447,7 +3441,7 @@ bool SystemInformationImplementation::RetreiveInformationFromCpuInfoFile() if (this->NumberOfPhysicalCPU <= 0) { this->NumberOfPhysicalCPU = 1; } - // LogicalProcessorsPerPhysical>1 => hyperthreading. + // LogicalProcessorsPerPhysical>1 => SMT. this->Features.ExtendedFeatures.LogicalProcessorsPerPhysical = this->NumberOfLogicalCPU / this->NumberOfPhysicalCPU; @@ -4322,68 +4316,10 @@ void SystemInformationImplementation::DelayOverhead(unsigned int uiMS) (void)uiMS; } -/** Return the number of logical CPU per physical CPUs Works only for windows - */ -unsigned char SystemInformationImplementation::LogicalCPUPerPhysicalCPU(void) -{ -#ifdef __APPLE__ - size_t len = 4; - int cores_per_package = 0; - int err = sysctlbyname("machdep.cpu.cores_per_package", &cores_per_package, - &len, NULL, 0); - if (err != 0) { - return 1; // That name was not found, default to 1 - } - return static_cast<unsigned char>(cores_per_package); -#else - int Regs[4] = { 0, 0, 0, 0 }; -#if USE_CPUID - if (!this->IsHyperThreadingSupported()) { - return static_cast<unsigned char>(1); // HT not supported - } - call_cpuid(1, Regs); -#endif - return static_cast<unsigned char>((Regs[1] & NUM_LOGICAL_BITS) >> 16); -#endif -} - /** Works only for windows */ -bool SystemInformationImplementation::IsHyperThreadingSupported() +bool SystemInformationImplementation::IsSMTSupported() { - if (this->Features.ExtendedFeatures.SupportsHyperthreading) { - return true; - } - -#if USE_CPUID - int Regs[4] = { 0, 0, 0, 0 }, VendorId[4] = { 0, 0, 0, 0 }; - // Get vendor id string - if (!call_cpuid(0, VendorId)) { - return false; - } - // eax contains family processor type - // edx has info about the availability of hyper-Threading - if (!call_cpuid(1, Regs)) { - return false; - } - - if (((Regs[0] & FAMILY_ID) == PENTIUM4_ID) || (Regs[0] & EXT_FAMILY_ID)) { - if (VendorId[1] == 0x756e6547) // 'uneG' - { - if (VendorId[3] == 0x49656e69) // 'Ieni' - { - if (VendorId[2] == 0x6c65746e) // 'letn' - { - // Genuine Intel with hyper-Threading technology - this->Features.ExtendedFeatures.SupportsHyperthreading = - ((Regs[3] & HT_BIT) != 0); - return this->Features.ExtendedFeatures.SupportsHyperthreading; - } - } - } - } -#endif - - return 0; // Not genuine Intel processor + return this->Features.ExtendedFeatures.LogicalProcessorsPerPhysical > 1; } /** Return the APIC Id. Works only for windows. */ @@ -4392,7 +4328,7 @@ unsigned char SystemInformationImplementation::GetAPICId() int Regs[4] = { 0, 0, 0, 0 }; #if USE_CPUID - if (!this->IsHyperThreadingSupported()) { + if (!this->IsSMTSupported()) { return static_cast<unsigned char>(-1); // HT not supported } // Logical processor = 1 call_cpuid(1, Regs); @@ -4402,102 +4338,63 @@ unsigned char SystemInformationImplementation::GetAPICId() } /** Count the number of CPUs. Works only on windows. */ -int SystemInformationImplementation::CPUCount() +void SystemInformationImplementation::CPUCountWindows() { #if defined(_WIN32) - unsigned char StatusFlag = 0; - SYSTEM_INFO info; - this->NumberOfPhysicalCPU = 0; this->NumberOfLogicalCPU = 0; - info.dwNumberOfProcessors = 0; - GetSystemInfo(&info); - - // Number of physical processors in a non-Intel system - // or in a 32-bit Intel system with Hyper-Threading technology disabled - this->NumberOfPhysicalCPU = (unsigned char)info.dwNumberOfProcessors; - - if (this->IsHyperThreadingSupported()) { - unsigned char HT_Enabled = 0; - this->NumberOfLogicalCPU = this->LogicalCPUPerPhysicalCPU(); - if (this->NumberOfLogicalCPU >= - 1) // >1 Doesn't mean HT is enabled in the BIOS - { - HANDLE hCurrentProcessHandle; -#ifndef _WIN64 -#define DWORD_PTR DWORD -#endif - DWORD_PTR dwProcessAffinity; - DWORD_PTR dwSystemAffinity; - DWORD dwAffinityMask; - - // Calculate the appropriate shifts and mask based on the - // number of logical processors. - unsigned int i = 1; - unsigned char PHY_ID_MASK = 0xFF; - // unsigned char PHY_ID_SHIFT = 0; - - while (i < this->NumberOfLogicalCPU) { - i *= 2; - PHY_ID_MASK <<= 1; - // PHY_ID_SHIFT++; - } - - hCurrentProcessHandle = GetCurrentProcess(); - GetProcessAffinityMask(hCurrentProcessHandle, &dwProcessAffinity, - &dwSystemAffinity); - - // Check if available process affinity mask is equal to the - // available system affinity mask - if (dwProcessAffinity != dwSystemAffinity) { - StatusFlag = HT_CANNOT_DETECT; - this->NumberOfPhysicalCPU = (unsigned char)-1; - return StatusFlag; - } - dwAffinityMask = 1; - while (dwAffinityMask != 0 && dwAffinityMask <= dwProcessAffinity) { - // Check if this CPU is available - if (dwAffinityMask & dwProcessAffinity) { - if (SetProcessAffinityMask(hCurrentProcessHandle, dwAffinityMask)) { - unsigned char APIC_ID, LOG_ID; - Sleep(0); // Give OS time to switch CPU - - APIC_ID = GetAPICId(); - LOG_ID = APIC_ID & ~PHY_ID_MASK; + typedef BOOL(WINAPI * GetLogicalProcessorInformationType)( + PSYSTEM_LOGICAL_PROCESSOR_INFORMATION, PDWORD); + static GetLogicalProcessorInformationType pGetLogicalProcessorInformation = + (GetLogicalProcessorInformationType)GetProcAddress( + GetModuleHandleW(L"kernel32"), "GetLogicalProcessorInformation"); + + if (!pGetLogicalProcessorInformation) { + // Fallback to approximate implementation on ancient Windows versions. + SYSTEM_INFO info; + ZeroMemory(&info, sizeof(info)); + GetSystemInfo(&info); + this->NumberOfPhysicalCPU = + static_cast<unsigned int>(info.dwNumberOfProcessors); + this->NumberOfLogicalCPU = this->NumberOfPhysicalCPU; + return; + } - if (LOG_ID != 0) { - HT_Enabled = 1; - } - } - } - dwAffinityMask = dwAffinityMask << 1; - } - // Reset the processor affinity - SetProcessAffinityMask(hCurrentProcessHandle, dwProcessAffinity); + std::vector<SYSTEM_LOGICAL_PROCESSOR_INFORMATION> ProcInfo; + { + DWORD Length = 0; + DWORD rc = pGetLogicalProcessorInformation(NULL, &Length); + assert(FALSE == rc); + (void)rc; // Silence unused variable warning in Borland C++ 5.81 + assert(GetLastError() == ERROR_INSUFFICIENT_BUFFER); + ProcInfo.resize(Length / sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION)); + rc = pGetLogicalProcessorInformation(&ProcInfo[0], &Length); + assert(rc != FALSE); + (void)rc; // Silence unused variable warning in Borland C++ 5.81 + } + + typedef std::vector<SYSTEM_LOGICAL_PROCESSOR_INFORMATION>::iterator + pinfoIt_t; + for (pinfoIt_t it = ProcInfo.begin(); it != ProcInfo.end(); ++it) { + SYSTEM_LOGICAL_PROCESSOR_INFORMATION PInfo = *it; + if (PInfo.Relationship != RelationProcessorCore) { + continue; + } - if (this->NumberOfLogicalCPU == - 1) // Normal P4 : HT is disabled in hardware - { - StatusFlag = HT_DISABLED; - } else { - if (HT_Enabled) { - // Total physical processors in a Hyper-Threading enabled system. - this->NumberOfPhysicalCPU /= (this->NumberOfLogicalCPU); - StatusFlag = HT_ENABLED; - } else { - StatusFlag = HT_SUPPORTED_NOT_ENABLED; - } - } + std::bitset<std::numeric_limits<ULONG_PTR>::digits> ProcMask( + (unsigned long long)PInfo.ProcessorMask); + unsigned int count = (unsigned int)ProcMask.count(); + if (count == 0) { // I think this should never happen, but just to be safe. + continue; } - } else { - // Processors do not have Hyper-Threading technology - StatusFlag = HT_NOT_CAPABLE; - this->NumberOfLogicalCPU = 1; + this->NumberOfPhysicalCPU++; + this->NumberOfLogicalCPU += (unsigned int)count; + this->Features.ExtendedFeatures.LogicalProcessorsPerPhysical = count; } - return StatusFlag; + this->NumberOfPhysicalCPU = std::max(1u, this->NumberOfPhysicalCPU); + this->NumberOfLogicalCPU = std::max(1u, this->NumberOfLogicalCPU); #else - return 0; #endif } @@ -4559,8 +4456,14 @@ bool SystemInformationImplementation::ParseSysCtl() sysctlbyname("hw.physicalcpu", &this->NumberOfPhysicalCPU, &len, NULL, 0); len = sizeof(this->NumberOfLogicalCPU); sysctlbyname("hw.logicalcpu", &this->NumberOfLogicalCPU, &len, NULL, 0); + + int cores_per_package = 0; + len = sizeof(cores_per_package); + err = sysctlbyname("machdep.cpu.cores_per_package", &cores_per_package, &len, + NULL, 0); + // That name was not found, default to 1 this->Features.ExtendedFeatures.LogicalProcessorsPerPhysical = - this->LogicalCPUPerPhysicalCPU(); + err != 0 ? 1 : static_cast<unsigned char>(cores_per_package); len = sizeof(value); sysctlbyname("hw.cpufrequency", &value, &len, NULL, 0); @@ -5436,10 +5339,20 @@ bool SystemInformationImplementation::QueryOSInformation() this->Hostname = name; const char* arch = getenv("PROCESSOR_ARCHITECTURE"); + const char* wow64 = getenv("PROCESSOR_ARCHITEW6432"); if (arch) { this->OSPlatform = arch; } + if (wow64) { + // the PROCESSOR_ARCHITEW6432 is only defined when running 32bit programs + // on 64bit OS + this->OSIs64Bit = true; + } else if (arch) { + // all values other than x86 map to 64bit architectures + this->OSIs64Bit = (strncmp(arch, "x86", 3) != 0); + } + #else struct utsname unameInfo; @@ -5450,6 +5363,12 @@ bool SystemInformationImplementation::QueryOSInformation() this->OSRelease = unameInfo.release; this->OSVersion = unameInfo.version; this->OSPlatform = unameInfo.machine; + + // This is still insufficient to capture 64bit architecture such + // powerpc and possible mips and sparc + if (this->OSPlatform.find_first_of("64") != std::string::npos) { + this->OSIs64Bit = true; + } } #ifdef __APPLE__ @@ -5503,6 +5422,6 @@ void SystemInformationImplementation::TrimNewline(std::string& output) /** Return true if the machine is 64 bits */ bool SystemInformationImplementation::Is64Bits() { - return (sizeof(void*) == 8); + return this->OSIs64Bit; } } diff --git a/Source/kwsys/SystemInformation.hxx.in b/Source/kwsys/SystemInformation.hxx.in index 0fc1067..54e7fc1 100644 --- a/Source/kwsys/SystemInformation.hxx.in +++ b/Source/kwsys/SystemInformation.hxx.in @@ -65,9 +65,10 @@ public: // on this system. std::string GetOSDescription(); + // returns if the operating system is 64bit or not. bool Is64Bits(); - unsigned int GetNumberOfLogicalCPU(); // per physical cpu + unsigned int GetNumberOfLogicalCPU(); unsigned int GetNumberOfPhysicalCPU(); bool DoesCPUSupportCPUID(); diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 97dd4ae..b6da368 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -54,7 +54,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <sys/stat.h> #include <time.h> #if defined(_WIN32) && !defined(_MSC_VER) && defined(__GNUC__) @@ -217,12 +216,12 @@ static time_t windows_filetime_to_posix_time(const FILETIME& ft) inline int Mkdir(const std::string& dir) { return _wmkdir( - KWSYS_NAMESPACE::SystemTools::ConvertToWindowsExtendedPath(dir).c_str()); + KWSYS_NAMESPACE::Encoding::ToWindowsExtendedPath(dir).c_str()); } inline int Rmdir(const std::string& dir) { return _wrmdir( - KWSYS_NAMESPACE::SystemTools::ConvertToWindowsExtendedPath(dir).c_str()); + KWSYS_NAMESPACE::Encoding::ToWindowsExtendedPath(dir).c_str()); } inline const char* Getcwd(char* buf, unsigned int len) { @@ -746,7 +745,7 @@ const char* SystemTools::GetExecutableExtension() FILE* SystemTools::Fopen(const std::string& file, const char* mode) { #ifdef _WIN32 - return _wfopen(SystemTools::ConvertToWindowsExtendedPath(file).c_str(), + return _wfopen(Encoding::ToWindowsExtendedPath(file).c_str(), Encoding::ToWide(mode).c_str()); #else return fopen(file.c_str(), mode); @@ -1160,8 +1159,7 @@ bool SystemTools::PathExists(const std::string& path) struct stat st; return lstat(path.c_str(), &st) == 0; #elif defined(_WIN32) - return (GetFileAttributesW( - SystemTools::ConvertToWindowsExtendedPath(path).c_str()) != + return (GetFileAttributesW(Encoding::ToWindowsExtendedPath(path).c_str()) != INVALID_FILE_ATTRIBUTES); #else struct stat st; @@ -1192,9 +1190,9 @@ bool SystemTools::FileExists(const std::string& filename) } return access(filename.c_str(), R_OK) == 0; #elif defined(_WIN32) - return (GetFileAttributesW( - SystemTools::ConvertToWindowsExtendedPath(filename).c_str()) != - INVALID_FILE_ATTRIBUTES); + return ( + GetFileAttributesW(Encoding::ToWindowsExtendedPath(filename).c_str()) != + INVALID_FILE_ATTRIBUTES); #else // SCO OpenServer 5.0.7/3.2's command has 711 permission. #if defined(_SCO_DS) @@ -1250,7 +1248,7 @@ bool SystemTools::TestFileAccess(const std::string& filename, permissions &= ~TEST_FILE_EXECUTE; permissions |= TEST_FILE_READ; } - return _waccess(SystemTools::ConvertToWindowsExtendedPath(filename).c_str(), + return _waccess(Encoding::ToWindowsExtendedPath(filename).c_str(), permissions) == 0; #else return access(filename.c_str(), permissions) == 0; @@ -1258,6 +1256,38 @@ bool SystemTools::TestFileAccess(const std::string& filename, } //---------------------------------------------------------------------------- +int SystemTools::Stat(const char* path, SystemTools::Stat_t* buf) +{ + if (!path) { + errno = EFAULT; + return -1; + } + return SystemTools::Stat(std::string(path), buf); +} + +//---------------------------------------------------------------------------- +int SystemTools::Stat(const std::string& path, SystemTools::Stat_t* buf) +{ + if (path.empty()) { + errno = ENOENT; + return -1; + } +#if defined(_WIN32) && !defined(__CYGWIN__) + // Ideally we should use Encoding::ToWindowsExtendedPath to support + // long paths, but _wstat64 rejects paths with '?' in them, thinking + // they are wildcards. + std::wstring const& wpath = Encoding::ToWide(path); +#if defined(__BORLANDC__) + return _wstati64(wpath.c_str(), buf); +#else + return _wstat64(wpath.c_str(), buf); +#endif +#else + return stat(path.c_str(), buf); +#endif +} + +//---------------------------------------------------------------------------- #ifdef __CYGWIN__ bool SystemTools::PathCygwinToWin32(const char* path, char* win32_path) { @@ -1293,10 +1323,9 @@ bool SystemTools::Touch(const std::string& filename, bool create) } } #if defined(_WIN32) && !defined(__CYGWIN__) - HANDLE h = - CreateFileW(SystemTools::ConvertToWindowsExtendedPath(filename).c_str(), - FILE_WRITE_ATTRIBUTES, FILE_SHARE_WRITE, 0, OPEN_EXISTING, - FILE_FLAG_BACKUP_SEMANTICS, 0); + HANDLE h = CreateFileW(Encoding::ToWindowsExtendedPath(filename).c_str(), + FILE_WRITE_ATTRIBUTES, FILE_SHARE_WRITE, 0, + OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0); if (!h) { return false; } @@ -1394,14 +1423,12 @@ bool SystemTools::FileTimeCompare(const std::string& f1, const std::string& f2, // Windows version. Get the modification time from extended file attributes. WIN32_FILE_ATTRIBUTE_DATA f1d; WIN32_FILE_ATTRIBUTE_DATA f2d; - if (!GetFileAttributesExW( - SystemTools::ConvertToWindowsExtendedPath(f1).c_str(), - GetFileExInfoStandard, &f1d)) { + if (!GetFileAttributesExW(Encoding::ToWindowsExtendedPath(f1).c_str(), + GetFileExInfoStandard, &f1d)) { return false; } - if (!GetFileAttributesExW( - SystemTools::ConvertToWindowsExtendedPath(f2).c_str(), - GetFileExInfoStandard, &f2d)) { + if (!GetFileAttributesExW(Encoding::ToWindowsExtendedPath(f2).c_str(), + GetFileExInfoStandard, &f2d)) { return false; } @@ -1929,59 +1956,10 @@ void SystemTools::ConvertToUnixSlashes(std::string& path) } #ifdef _WIN32 -// Convert local paths to UNC style paths std::wstring SystemTools::ConvertToWindowsExtendedPath( const std::string& source) { - std::wstring wsource = Encoding::ToWide(source); - - // Resolve any relative paths - DWORD wfull_len; - - /* The +3 is a workaround for a bug in some versions of GetFullPathNameW that - * won't return a large enough buffer size if the input is too small */ - wfull_len = GetFullPathNameW(wsource.c_str(), 0, NULL, NULL) + 3; - std::vector<wchar_t> wfull(wfull_len); - GetFullPathNameW(wsource.c_str(), wfull_len, &wfull[0], NULL); - - /* This should get the correct size without any extra padding from the - * previous size workaround. */ - wfull_len = static_cast<DWORD>(wcslen(&wfull[0])); - - if (wfull_len >= 2 && isalpha(wfull[0]) && - wfull[1] == L':') { /* C:\Foo\bar\FooBar.txt */ - return L"\\\\?\\" + std::wstring(&wfull[0]); - } else if (wfull_len >= 2 && wfull[0] == L'\\' && - wfull[1] == L'\\') { /* Starts with \\ */ - if (wfull_len >= 4 && wfull[2] == L'?' && - wfull[3] == L'\\') { /* Starts with \\?\ */ - if (wfull_len >= 8 && wfull[4] == L'U' && wfull[5] == L'N' && - wfull[6] == L'C' && - wfull[7] == L'\\') { /* \\?\UNC\Foo\bar\FooBar.txt */ - return std::wstring(&wfull[0]); - } else if (wfull_len >= 6 && isalpha(wfull[4]) && - wfull[5] == L':') { /* \\?\C:\Foo\bar\FooBar.txt */ - return std::wstring(&wfull[0]); - } else if (wfull_len >= 5) { /* \\?\Foo\bar\FooBar.txt */ - return L"\\\\?\\UNC\\" + std::wstring(&wfull[4]); - } - } else if (wfull_len >= 4 && wfull[2] == L'.' && - wfull[3] == L'\\') { /* Starts with \\.\ a device name */ - if (wfull_len >= 6 && isalpha(wfull[4]) && - wfull[5] == L':') { /* \\.\C:\Foo\bar\FooBar.txt */ - return L"\\\\?\\" + std::wstring(&wfull[4]); - } else if (wfull_len >= - 5) { /* \\.\Foo\bar\ Device name is left unchanged */ - return std::wstring(&wfull[0]); - } - } else if (wfull_len >= 3) { /* \\Foo\bar\FooBar.txt */ - return L"\\\\?\\UNC\\" + std::wstring(&wfull[2]); - } - } - - // If this case has been reached, then the path is invalid. Leave it - // unchanged - return Encoding::ToWide(source); + return Encoding::ToWindowsExtendedPath(source); } #endif @@ -2098,15 +2076,14 @@ bool SystemTools::FilesDiffer(const std::string& source, #if defined(_WIN32) WIN32_FILE_ATTRIBUTE_DATA statSource; - if (GetFileAttributesExW( - SystemTools::ConvertToWindowsExtendedPath(source).c_str(), - GetFileExInfoStandard, &statSource) == 0) { + if (GetFileAttributesExW(Encoding::ToWindowsExtendedPath(source).c_str(), + GetFileExInfoStandard, &statSource) == 0) { return true; } WIN32_FILE_ATTRIBUTE_DATA statDestination; if (GetFileAttributesExW( - SystemTools::ConvertToWindowsExtendedPath(destination).c_str(), + Encoding::ToWindowsExtendedPath(destination).c_str(), GetFileExInfoStandard, &statDestination) == 0) { return true; } @@ -2230,8 +2207,7 @@ bool SystemTools::CopyFileAlways(const std::string& source, // Open files #if defined(_WIN32) kwsys::ifstream fin( - Encoding::ToNarrow(SystemTools::ConvertToWindowsExtendedPath(source)) - .c_str(), + Encoding::ToNarrow(Encoding::ToWindowsExtendedPath(source)).c_str(), std::ios::in | std::ios::binary); #else kwsys::ifstream fin(source.c_str(), std::ios::in | std::ios::binary); @@ -2248,8 +2224,7 @@ bool SystemTools::CopyFileAlways(const std::string& source, #if defined(_WIN32) kwsys::ofstream fout( - Encoding::ToNarrow( - SystemTools::ConvertToWindowsExtendedPath(real_destination)) + Encoding::ToNarrow(Encoding::ToWindowsExtendedPath(real_destination)) .c_str(), std::ios::out | std::ios::trunc | std::ios::binary); #else @@ -2314,8 +2289,7 @@ bool SystemTools::CopyADirectory(const std::string& source, { Directory dir; #ifdef _WIN32 - dir.Load( - Encoding::ToNarrow(SystemTools::ConvertToWindowsExtendedPath(source))); + dir.Load(Encoding::ToNarrow(Encoding::ToWindowsExtendedPath(source))); #else dir.Load(source); #endif @@ -2353,9 +2327,8 @@ unsigned long SystemTools::FileLength(const std::string& filename) unsigned long length = 0; #ifdef _WIN32 WIN32_FILE_ATTRIBUTE_DATA fs; - if (GetFileAttributesExW( - SystemTools::ConvertToWindowsExtendedPath(filename).c_str(), - GetFileExInfoStandard, &fs) != 0) { + if (GetFileAttributesExW(Encoding::ToWindowsExtendedPath(filename).c_str(), + GetFileExInfoStandard, &fs) != 0) { /* To support the full 64-bit file size, use fs.nFileSizeHigh * and fs.nFileSizeLow to construct the 64 bit size @@ -2389,9 +2362,8 @@ long int SystemTools::ModifiedTime(const std::string& filename) long int mt = 0; #ifdef _WIN32 WIN32_FILE_ATTRIBUTE_DATA fs; - if (GetFileAttributesExW( - SystemTools::ConvertToWindowsExtendedPath(filename).c_str(), - GetFileExInfoStandard, &fs) != 0) { + if (GetFileAttributesExW(Encoding::ToWindowsExtendedPath(filename).c_str(), + GetFileExInfoStandard, &fs) != 0) { mt = windows_filetime_to_posix_time(fs.ftLastWriteTime); } #else @@ -2409,9 +2381,8 @@ long int SystemTools::CreationTime(const std::string& filename) long int ct = 0; #ifdef _WIN32 WIN32_FILE_ATTRIBUTE_DATA fs; - if (GetFileAttributesExW( - SystemTools::ConvertToWindowsExtendedPath(filename).c_str(), - GetFileExInfoStandard, &fs) != 0) { + if (GetFileAttributesExW(Encoding::ToWindowsExtendedPath(filename).c_str(), + GetFileExInfoStandard, &fs) != 0) { ct = windows_filetime_to_posix_time(fs.ftCreationTime); } #else @@ -2625,7 +2596,7 @@ static bool DeleteJunction(const std::wstring& source) bool SystemTools::RemoveFile(const std::string& source) { #ifdef _WIN32 - std::wstring const& ws = SystemTools::ConvertToWindowsExtendedPath(source); + std::wstring const& ws = Encoding::ToWindowsExtendedPath(source); if (DeleteFileW(ws.c_str())) { return true; } @@ -2675,8 +2646,7 @@ bool SystemTools::RemoveADirectory(const std::string& source) Directory dir; #ifdef _WIN32 - dir.Load( - Encoding::ToNarrow(SystemTools::ConvertToWindowsExtendedPath(source))); + dir.Load(Encoding::ToNarrow(Encoding::ToWindowsExtendedPath(source))); #else dir.Load(source); #endif @@ -3033,8 +3003,8 @@ bool SystemTools::FileIsDirectory(const std::string& inName) // Now check the file node type. #if defined(_WIN32) - DWORD attr = GetFileAttributesW( - SystemTools::ConvertToWindowsExtendedPath(name).c_str()); + DWORD attr = + GetFileAttributesW(Encoding::ToWindowsExtendedPath(name).c_str()); if (attr != INVALID_FILE_ATTRIBUTES) { return (attr & FILE_ATTRIBUTE_DIRECTORY) != 0; #else @@ -3050,8 +3020,8 @@ bool SystemTools::FileIsDirectory(const std::string& inName) bool SystemTools::FileIsSymlink(const std::string& name) { #if defined(_WIN32) - DWORD attr = GetFileAttributesW( - SystemTools::ConvertToWindowsExtendedPath(name).c_str()); + DWORD attr = + GetFileAttributesW(Encoding::ToWindowsExtendedPath(name).c_str()); if (attr != INVALID_FILE_ATTRIBUTES) { return (attr & FILE_ATTRIBUTE_REPARSE_POINT) != 0; } else { @@ -3067,6 +3037,28 @@ bool SystemTools::FileIsSymlink(const std::string& name) #endif } +bool SystemTools::FileIsFIFO(const std::string& name) +{ +#if defined(_WIN32) + HANDLE hFile = + CreateFileW(Encoding::ToWide(name).c_str(), GENERIC_READ, FILE_SHARE_READ, + NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); + if (hFile == INVALID_HANDLE_VALUE) { + return false; + } + const DWORD type = GetFileType(hFile); + CloseHandle(hFile); + return type == FILE_TYPE_PIPE; +#else + struct stat fs; + if (lstat(name.c_str(), &fs) == 0) { + return S_ISFIFO(fs.st_mode); + } else { + return false; + } +#endif +} + #if defined(_WIN32) && !defined(__CYGWIN__) bool SystemTools::CreateSymlink(const std::string&, const std::string&) { @@ -3309,7 +3301,7 @@ std::string SystemTools::CollapseFullPath(const std::string& in_path, SystemTools::SplitPath(in_path, path_components); // If the input path is relative, start with a base path. - if (path_components[0].length() == 0) { + if (path_components[0].empty()) { std::vector<std::string> base_components; if (in_base) { // Use the given base path. @@ -4345,8 +4337,8 @@ bool SystemTools::GetPermissions(const char* file, mode_t& mode) bool SystemTools::GetPermissions(const std::string& file, mode_t& mode) { #if defined(_WIN32) - DWORD attr = GetFileAttributesW( - SystemTools::ConvertToWindowsExtendedPath(file).c_str()); + DWORD attr = + GetFileAttributesW(Encoding::ToWindowsExtendedPath(file).c_str()); if (attr == INVALID_FILE_ATTRIBUTES) { return false; } @@ -4398,8 +4390,7 @@ bool SystemTools::SetPermissions(const std::string& file, mode_t mode, mode &= ~currentMask; } #ifdef _WIN32 - if (_wchmod(SystemTools::ConvertToWindowsExtendedPath(file).c_str(), mode) < - 0) + if (_wchmod(Encoding::ToWindowsExtendedPath(file).c_str(), mode) < 0) #else if (chmod(file.c_str(), mode) < 0) #endif diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in index f3d06fe..0849e1d 100644 --- a/Source/kwsys/SystemTools.hxx.in +++ b/Source/kwsys/SystemTools.hxx.in @@ -13,6 +13,9 @@ #include <@KWSYS_NAMESPACE@/String.hxx> #include <sys/types.h> +// include sys/stat.h after sys/types.h +#include <sys/stat.h> + #if !defined(_WIN32) || defined(__CYGWIN__) #include <unistd.h> // For access permissions for use with access() #endif @@ -262,13 +265,7 @@ public: static void ConvertToUnixSlashes(std::string& path); #ifdef _WIN32 - /** - * Convert the path to an extended length path to avoid MAX_PATH length - * limitations on Windows. If the input is a local path the result will be - * prefixed with \\?\; if the input is instead a network path, the result - * will be prefixed with \\?\UNC\. All output will also be converted to - * absolute paths with Windows-style backslashes. - **/ + /** Calls Encoding::ToWindowsExtendedPath. */ static std::wstring ConvertToWindowsExtendedPath(const std::string&); #endif @@ -324,6 +321,27 @@ public: TestFilePermissions permissions); static bool TestFileAccess(const std::string& filename, TestFilePermissions permissions); +/** + * Cross platform wrapper for stat struct + */ +#if defined(_WIN32) && !defined(__CYGWIN__) +#if defined(__BORLANDC__) + typedef struct stati64 Stat_t; +#else + typedef struct _stat64 Stat_t; +#endif +#else + typedef struct stat Stat_t; +#endif + + /** + * Cross platform wrapper for stat system call + * + * On Windows this may not work for paths longer than 250 characters + * due to limitations of the underlying '_wstat64' call. + */ + static int Stat(const char* path, Stat_t* buf); + static int Stat(const std::string& path, Stat_t* buf); /** * Converts Cygwin path to Win32 path. Uses dictionary container for @@ -654,6 +672,11 @@ public: static bool FileIsSymlink(const std::string& name); /** + * Return true if the file is a FIFO + */ + static bool FileIsFIFO(const std::string& name); + + /** * Return true if the file has a given signature (first set of bytes) */ static bool FileHasSignature(const char* filename, const char* signature, diff --git a/Source/kwsys/testEncoding.cxx b/Source/kwsys/testEncoding.cxx index 03f2ec9..457e8a8 100644 --- a/Source/kwsys/testEncoding.cxx +++ b/Source/kwsys/testEncoding.cxx @@ -180,6 +180,88 @@ static int testCommandLineArguments() return status; } +static int testToWindowsExtendedPath() +{ +#ifdef _WIN32 + int ret = 0; + if (kwsys::Encoding::ToWindowsExtendedPath( + "L:\\Local Mojo\\Hex Power Pack\\Iffy Voodoo") != + L"\\\\?\\L:\\Local Mojo\\Hex Power Pack\\Iffy Voodoo") { + std::cout << "Problem with ToWindowsExtendedPath " + << "\"L:\\Local Mojo\\Hex Power Pack\\Iffy Voodoo\"" + << std::endl; + ++ret; + } + + if (kwsys::Encoding::ToWindowsExtendedPath( + "L:/Local Mojo/Hex Power Pack/Iffy Voodoo") != + L"\\\\?\\L:\\Local Mojo\\Hex Power Pack\\Iffy Voodoo") { + std::cout << "Problem with ToWindowsExtendedPath " + << "\"L:/Local Mojo/Hex Power Pack/Iffy Voodoo\"" << std::endl; + ++ret; + } + + if (kwsys::Encoding::ToWindowsExtendedPath( + "\\\\Foo\\Local Mojo\\Hex Power Pack\\Iffy Voodoo") != + L"\\\\?\\UNC\\Foo\\Local Mojo\\Hex Power Pack\\Iffy Voodoo") { + std::cout << "Problem with ToWindowsExtendedPath " + << "\"\\\\Foo\\Local Mojo\\Hex Power Pack\\Iffy Voodoo\"" + << std::endl; + ++ret; + } + + if (kwsys::Encoding::ToWindowsExtendedPath( + "//Foo/Local Mojo/Hex Power Pack/Iffy Voodoo") != + L"\\\\?\\UNC\\Foo\\Local Mojo\\Hex Power Pack\\Iffy Voodoo") { + std::cout << "Problem with ToWindowsExtendedPath " + << "\"//Foo/Local Mojo/Hex Power Pack/Iffy Voodoo\"" + << std::endl; + ++ret; + } + + if (kwsys::Encoding::ToWindowsExtendedPath("//") != L"//") { + std::cout << "Problem with ToWindowsExtendedPath " + << "\"//\"" << std::endl; + ++ret; + } + + if (kwsys::Encoding::ToWindowsExtendedPath("\\\\.\\") != L"\\\\.\\") { + std::cout << "Problem with ToWindowsExtendedPath " + << "\"\\\\.\\\"" << std::endl; + ++ret; + } + + if (kwsys::Encoding::ToWindowsExtendedPath("\\\\.\\X") != L"\\\\.\\X") { + std::cout << "Problem with ToWindowsExtendedPath " + << "\"\\\\.\\X\"" << std::endl; + ++ret; + } + + if (kwsys::Encoding::ToWindowsExtendedPath("\\\\.\\X:") != L"\\\\?\\X:") { + std::cout << "Problem with ToWindowsExtendedPath " + << "\"\\\\.\\X:\"" << std::endl; + ++ret; + } + + if (kwsys::Encoding::ToWindowsExtendedPath("\\\\.\\X:\\") != + L"\\\\?\\X:\\") { + std::cout << "Problem with ToWindowsExtendedPath " + << "\"\\\\.\\X:\\\"" << std::endl; + ++ret; + } + + if (kwsys::Encoding::ToWindowsExtendedPath("NUL") != L"\\\\.\\NUL") { + std::cout << "Problem with ToWindowsExtendedPath " + << "\"NUL\"" << std::endl; + ++ret; + } + + return ret; +#else + return 0; +#endif +} + //---------------------------------------------------------------------------- int testEncoding(int, char* []) { @@ -196,6 +278,7 @@ int testEncoding(int, char* []) ret |= testRobustEncoding(); ret |= testCommandLineArguments(); ret |= testWithNulls(); + ret |= testToWindowsExtendedPath(); return ret; } diff --git a/Source/kwsys/testSystemInformation.cxx b/Source/kwsys/testSystemInformation.cxx index 86a1e1e..3a9217f 100644 --- a/Source/kwsys/testSystemInformation.cxx +++ b/Source/kwsys/testSystemInformation.cxx @@ -52,6 +52,7 @@ int testSystemInformation(int, char* []) printMethod(info, GetOSRelease); printMethod(info, GetOSVersion); printMethod(info, GetOSPlatform); + printMethod(info, Is64Bits); printMethod(info, GetVendorString); printMethod(info, GetVendorID); printMethod(info, GetTypeID); @@ -63,7 +64,6 @@ int testSystemInformation(int, char* []) printMethod2(info, GetProcessorCacheSize, "KB"); printMethod(info, GetLogicalProcessorsPerPhysical); printMethod2(info, GetProcessorClockFrequency, "MHz"); - printMethod(info, Is64Bits); printMethod(info, GetNumberOfLogicalCPU); printMethod(info, GetNumberOfPhysicalCPU); printMethod(info, DoesCPUSupportCPUID); diff --git a/Source/kwsys/testSystemTools.cxx b/Source/kwsys/testSystemTools.cxx index 8e1ea25..d11bcae 100644 --- a/Source/kwsys/testSystemTools.cxx +++ b/Source/kwsys/testSystemTools.cxx @@ -135,6 +135,19 @@ static bool CheckFileOperations() res = false; } + kwsys::SystemTools::Stat_t buf; + if (kwsys::SystemTools::Stat(testTxtFile.c_str(), &buf) != 0) { + std::cerr << "Problem with Stat - unable to stat text file: " + << testTxtFile << std::endl; + res = false; + } + + if (kwsys::SystemTools::Stat(testBinFile, &buf) != 0) { + std::cerr << "Problem with Stat - unable to stat bin file: " << testBinFile + << std::endl; + res = false; + } + if (!kwsys::SystemTools::MakeDirectory(testNewDir)) { std::cerr << "Problem with MakeDirectory for: " << testNewDir << std::endl; res = false; @@ -572,85 +585,6 @@ static bool CheckStringOperations() res = false; } -#ifdef _WIN32 - if (kwsys::SystemTools::ConvertToWindowsExtendedPath( - "L:\\Local Mojo\\Hex Power Pack\\Iffy Voodoo") != - L"\\\\?\\L:\\Local Mojo\\Hex Power Pack\\Iffy Voodoo") { - std::cerr << "Problem with ConvertToWindowsExtendedPath " - << "\"L:\\Local Mojo\\Hex Power Pack\\Iffy Voodoo\"" - << std::endl; - res = false; - } - - if (kwsys::SystemTools::ConvertToWindowsExtendedPath( - "L:/Local Mojo/Hex Power Pack/Iffy Voodoo") != - L"\\\\?\\L:\\Local Mojo\\Hex Power Pack\\Iffy Voodoo") { - std::cerr << "Problem with ConvertToWindowsExtendedPath " - << "\"L:/Local Mojo/Hex Power Pack/Iffy Voodoo\"" << std::endl; - res = false; - } - - if (kwsys::SystemTools::ConvertToWindowsExtendedPath( - "\\\\Foo\\Local Mojo\\Hex Power Pack\\Iffy Voodoo") != - L"\\\\?\\UNC\\Foo\\Local Mojo\\Hex Power Pack\\Iffy Voodoo") { - std::cerr << "Problem with ConvertToWindowsExtendedPath " - << "\"\\\\Foo\\Local Mojo\\Hex Power Pack\\Iffy Voodoo\"" - << std::endl; - res = false; - } - - if (kwsys::SystemTools::ConvertToWindowsExtendedPath( - "//Foo/Local Mojo/Hex Power Pack/Iffy Voodoo") != - L"\\\\?\\UNC\\Foo\\Local Mojo\\Hex Power Pack\\Iffy Voodoo") { - std::cerr << "Problem with ConvertToWindowsExtendedPath " - << "\"//Foo/Local Mojo/Hex Power Pack/Iffy Voodoo\"" - << std::endl; - res = false; - } - - if (kwsys::SystemTools::ConvertToWindowsExtendedPath("//") != L"//") { - std::cerr << "Problem with ConvertToWindowsExtendedPath " - << "\"//\"" << std::endl; - res = false; - } - - if (kwsys::SystemTools::ConvertToWindowsExtendedPath("\\\\.\\") != - L"\\\\.\\") { - std::cerr << "Problem with ConvertToWindowsExtendedPath " - << "\"\\\\.\\\"" << std::endl; - res = false; - } - - if (kwsys::SystemTools::ConvertToWindowsExtendedPath("\\\\.\\X") != - L"\\\\.\\X") { - std::cerr << "Problem with ConvertToWindowsExtendedPath " - << "\"\\\\.\\X\"" << std::endl; - res = false; - } - - if (kwsys::SystemTools::ConvertToWindowsExtendedPath("\\\\.\\X:") != - L"\\\\?\\X:") { - std::cerr << "Problem with ConvertToWindowsExtendedPath " - << "\"\\\\.\\X:\"" << std::endl; - res = false; - } - - if (kwsys::SystemTools::ConvertToWindowsExtendedPath("\\\\.\\X:\\") != - L"\\\\?\\X:\\") { - std::cerr << "Problem with ConvertToWindowsExtendedPath " - << "\"\\\\.\\X:\\\"" << std::endl; - res = false; - } - - if (kwsys::SystemTools::ConvertToWindowsExtendedPath("NUL") != - L"\\\\.\\NUL") { - std::cerr << "Problem with ConvertToWindowsExtendedPath " - << "\"NUL\"" << std::endl; - res = false; - } - -#endif - if (kwsys::SystemTools::ConvertToWindowsOutputPath( "L://Local Mojo/Hex Power Pack/Iffy Voodoo") != "\"L:\\Local Mojo\\Hex Power Pack\\Iffy Voodoo\"") { |