summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Modules/FindQt3.cmake4
1 files changed, 2 insertions, 2 deletions
diff --git a/Modules/FindQt3.cmake b/Modules/FindQt3.cmake
index c177012..b58519f 100644
--- a/Modules/FindQt3.cmake
+++ b/Modules/FindQt3.cmake
@@ -217,7 +217,7 @@ IF(QT_FOUND)
IF (WIN32 AND NOT CYGWIN)
IF (QT_QTMAIN_LIBRARY)
# for version 3
- SET (QT_DEFINITIONS "-DQT_DLL -DQT_THREAD_SUPPORT -DNO_DEBUG")
+ SET (QT_DEFINITIONS -DQT_DLL -DQT_THREAD_SUPPORT -DNO_DEBUG)
SET (QT_LIBRARIES imm32.lib ${QT_QT_LIBRARY} ${QT_QTMAIN_LIBRARY} )
SET (QT_LIBRARIES ${QT_LIBRARIES} winmm wsock32)
ELSE (QT_QTMAIN_LIBRARY)
@@ -227,7 +227,7 @@ IF(QT_FOUND)
ELSE (WIN32 AND NOT CYGWIN)
SET (QT_LIBRARIES ${QT_QT_LIBRARY} )
- SET (QT_DEFINITIONS "-DQT_SHARED -DQT_NO_DEBUG")
+ SET (QT_DEFINITIONS -DQT_SHARED -DQT_NO_DEBUG)
IF(QT_QT_LIBRARY MATCHES "qt-mt")
SET (QT_DEFINITIONS ${QT_DEFINITIONS} -DQT_THREAD_SUPPORT -D_REENTRANT)
ENDIF(QT_QT_LIBRARY MATCHES "qt-mt")
of this commit to see older history for the content. * See the parent commit for instructions to rebase a change across this style transition commit.
Diffstat (limited to 'Source')
-rw-r--r--Source/CPack/IFW/cmCPackIFWGenerator.cxx499
-rw-r--r--Source/CPack/IFW/cmCPackIFWGenerator.h22
-rw-r--r--Source/CPack/IFW/cmCPackIFWInstaller.cxx451
-rw-r--r--Source/CPack/IFW/cmCPackIFWInstaller.h6
-rw-r--r--Source/CPack/IFW/cmCPackIFWPackage.cxx389
-rw-r--r--Source/CPack/IFW/cmCPackIFWPackage.h32
-rw-r--r--Source/CPack/OSXScriptLauncher.cxx92
-rw-r--r--Source/CPack/WiX/cmCPackWIXGenerator.cxx831
-rw-r--r--Source/CPack/WiX/cmCPackWIXGenerator.h83
-rw-r--r--Source/CPack/WiX/cmWIXAccessControlList.cxx76
-rw-r--r--Source/CPack/WiX/cmWIXAccessControlList.h12
-rw-r--r--Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx29
-rw-r--r--Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h6
-rw-r--r--Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx43
-rw-r--r--Source/CPack/WiX/cmWIXFeaturesSourceWriter.h8
-rw-r--r--Source/CPack/WiX/cmWIXFilesSourceWriter.cxx71
-rw-r--r--Source/CPack/WiX/cmWIXFilesSourceWriter.h37
-rw-r--r--Source/CPack/WiX/cmWIXPatch.cxx88
-rw-r--r--Source/CPack/WiX/cmWIXPatch.h5
-rw-r--r--Source/CPack/WiX/cmWIXPatchParser.cxx133
-rw-r--r--Source/CPack/WiX/cmWIXPatchParser.h4
-rw-r--r--Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx126
-rw-r--r--Source/CPack/WiX/cmWIXShortcut.cxx78
-rw-r--r--Source/CPack/WiX/cmWIXShortcut.h21
-rw-r--r--Source/CPack/WiX/cmWIXSourceWriter.cxx176
-rw-r--r--Source/CPack/WiX/cmWIXSourceWriter.h17
-rw-r--r--Source/CPack/cmCPack7zGenerator.cxx3
-rw-r--r--Source/CPack/cmCPackArchiveGenerator.cxx238
-rw-r--r--Source/CPack/cmCPackArchiveGenerator.h6
-rw-r--r--Source/CPack/cmCPackBundleGenerator.cxx188
-rw-r--r--Source/CPack/cmCPackComponentGroup.cxx18
-rw-r--r--Source/CPack/cmCPackComponentGroup.h29
-rw-r--r--Source/CPack/cmCPackCygwinBinaryGenerator.cxx25
-rw-r--r--Source/CPack/cmCPackCygwinBinaryGenerator.h1
-rw-r--r--Source/CPack/cmCPackCygwinSourceGenerator.cxx76
-rw-r--r--Source/CPack/cmCPackCygwinSourceGenerator.h1
-rw-r--r--Source/CPack/cmCPackDebGenerator.cxx791
-rw-r--r--Source/CPack/cmCPackDebGenerator.h9
-rw-r--r--Source/CPack/cmCPackDragNDropGenerator.cxx756
-rw-r--r--Source/CPack/cmCPackDragNDropGenerator.h14
-rw-r--r--Source/CPack/cmCPackGenerator.cxx1373
-rw-r--r--Source/CPack/cmCPackGenerator.h54
-rw-r--r--Source/CPack/cmCPackGeneratorFactory.cxx178
-rw-r--r--Source/CPack/cmCPackGeneratorFactory.h8
-rw-r--r--Source/CPack/cmCPackLog.cxx180
-rw-r--r--Source/CPack/cmCPackLog.h47
-rw-r--r--Source/CPack/cmCPackNSISGenerator.cxx866
-rw-r--r--Source/CPack/cmCPackNSISGenerator.h29
-rw-r--r--Source/CPack/cmCPackOSXX11Generator.cxx193
-rw-r--r--Source/CPack/cmCPackOSXX11Generator.h5
-rw-r--r--Source/CPack/cmCPackPackageMakerGenerator.cxx760
-rw-r--r--Source/CPack/cmCPackPackageMakerGenerator.h18
-rw-r--r--Source/CPack/cmCPackRPMGenerator.cxx206
-rw-r--r--Source/CPack/cmCPackRPMGenerator.h6
-rw-r--r--Source/CPack/cmCPackSTGZGenerator.cxx61
-rw-r--r--Source/CPack/cmCPackTGZGenerator.cxx4
-rw-r--r--Source/CPack/cmCPackTGZGenerator.h1
-rw-r--r--Source/CPack/cmCPackTXZGenerator.cxx3
-rw-r--r--Source/CPack/cmCPackTXZGenerator.h1
-rw-r--r--Source/CPack/cmCPackTarBZip2Generator.cxx4
-rw-r--r--Source/CPack/cmCPackTarBZip2Generator.h1
-rw-r--r--Source/CPack/cmCPackTarCompressGenerator.cxx4
-rw-r--r--Source/CPack/cmCPackZIPGenerator.cxx4
-rw-r--r--Source/CPack/cpack.cxx378
-rw-r--r--Source/CTest/cmCTestBZR.cxx400
-rw-r--r--Source/CTest/cmCTestBZR.h2
-rw-r--r--Source/CTest/cmCTestBatchTestHandler.cxx62
-rw-r--r--Source/CTest/cmCTestBatchTestHandler.h1
-rw-r--r--Source/CTest/cmCTestBuildAndTestHandler.cxx424
-rw-r--r--Source/CTest/cmCTestBuildAndTestHandler.h39
-rw-r--r--Source/CTest/cmCTestBuildCommand.cxx145
-rw-r--r--Source/CTest/cmCTestBuildCommand.h13
-rw-r--r--Source/CTest/cmCTestBuildHandler.cxx931
-rw-r--r--Source/CTest/cmCTestBuildHandler.h81
-rw-r--r--Source/CTest/cmCTestCVS.cxx192
-rw-r--r--Source/CTest/cmCTestCVS.h6
-rw-r--r--Source/CTest/cmCTestCommand.h12
-rw-r--r--Source/CTest/cmCTestConfigureCommand.cxx105
-rw-r--r--Source/CTest/cmCTestConfigureCommand.h10
-rw-r--r--Source/CTest/cmCTestConfigureHandler.cxx87
-rw-r--r--Source/CTest/cmCTestCoverageCommand.cxx29
-rw-r--r--Source/CTest/cmCTestCoverageCommand.h9
-rw-r--r--Source/CTest/cmCTestCoverageHandler.cxx2198
-rw-r--r--Source/CTest/cmCTestCoverageHandler.h38
-rw-r--r--Source/CTest/cmCTestCurl.cxx181
-rw-r--r--Source/CTest/cmCTestCurl.h15
-rw-r--r--Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx16
-rw-r--r--Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h18
-rw-r--r--Source/CTest/cmCTestGIT.cxx466
-rw-r--r--Source/CTest/cmCTestGIT.h3
-rw-r--r--Source/CTest/cmCTestGenericHandler.cxx108
-rw-r--r--Source/CTest/cmCTestGenericHandler.h30
-rw-r--r--Source/CTest/cmCTestGlobalVC.cxx57
-rw-r--r--Source/CTest/cmCTestGlobalVC.h11
-rw-r--r--Source/CTest/cmCTestHG.cxx228
-rw-r--r--Source/CTest/cmCTestHG.h2
-rw-r--r--Source/CTest/cmCTestHandlerCommand.cxx169
-rw-r--r--Source/CTest/cmCTestHandlerCommand.h12
-rw-r--r--Source/CTest/cmCTestLaunch.cxx431
-rw-r--r--Source/CTest/cmCTestLaunch.h4
-rw-r--r--Source/CTest/cmCTestMemCheckCommand.cxx33
-rw-r--r--Source/CTest/cmCTestMemCheckCommand.h9
-rw-r--r--Source/CTest/cmCTestMemCheckHandler.cxx1094
-rw-r--r--Source/CTest/cmCTestMemCheckHandler.h50
-rw-r--r--Source/CTest/cmCTestMultiProcessHandler.cxx701
-rw-r--r--Source/CTest/cmCTestMultiProcessHandler.h52
-rw-r--r--Source/CTest/cmCTestP4.cxx347
-rw-r--r--Source/CTest/cmCTestP4.h16
-rw-r--r--Source/CTest/cmCTestReadCustomFilesCommand.cxx19
-rw-r--r--Source/CTest/cmCTestReadCustomFilesCommand.h11
-rw-r--r--Source/CTest/cmCTestRunScriptCommand.cxx42
-rw-r--r--Source/CTest/cmCTestRunScriptCommand.h10
-rw-r--r--Source/CTest/cmCTestRunTest.cxx635
-rw-r--r--Source/CTest/cmCTestRunTest.h62
-rw-r--r--Source/CTest/cmCTestSVN.cxx383
-rw-r--r--Source/CTest/cmCTestSVN.h15
-rw-r--r--Source/CTest/cmCTestScriptHandler.cxx691
-rw-r--r--Source/CTest/cmCTestScriptHandler.h16
-rw-r--r--Source/CTest/cmCTestSleepCommand.cxx26
-rw-r--r--Source/CTest/cmCTestSleepCommand.h11
-rw-r--r--Source/CTest/cmCTestStartCommand.cxx129
-rw-r--r--Source/CTest/cmCTestStartCommand.h20
-rw-r--r--Source/CTest/cmCTestSubmitCommand.cxx243
-rw-r--r--Source/CTest/cmCTestSubmitCommand.h14
-rw-r--r--Source/CTest/cmCTestSubmitHandler.cxx1506
-rw-r--r--Source/CTest/cmCTestSubmitHandler.h31
-rw-r--r--Source/CTest/cmCTestTestCommand.cxx107
-rw-r--r--Source/CTest/cmCTestTestCommand.h11
-rw-r--r--Source/CTest/cmCTestTestHandler.cxx1719
-rw-r--r--Source/CTest/cmCTestTestHandler.h114
-rw-r--r--Source/CTest/cmCTestUpdateCommand.cxx128
-rw-r--r--Source/CTest/cmCTestUpdateCommand.h8
-rw-r--r--Source/CTest/cmCTestUpdateHandler.cxx330
-rw-r--r--Source/CTest/cmCTestUpdateHandler.h12
-rw-r--r--Source/CTest/cmCTestUploadCommand.cxx35
-rw-r--r--Source/CTest/cmCTestUploadCommand.h12
-rw-r--r--Source/CTest/cmCTestUploadHandler.cxx35
-rw-r--r--Source/CTest/cmCTestVC.cxx69
-rw-r--r--Source/CTest/cmCTestVC.h36
-rw-r--r--Source/CTest/cmParseBlanketJSCoverage.cxx132
-rw-r--r--Source/CTest/cmParseBlanketJSCoverage.h4
-rw-r--r--Source/CTest/cmParseCacheCoverage.cxx189
-rw-r--r--Source/CTest/cmParseCacheCoverage.h8
-rw-r--r--Source/CTest/cmParseCoberturaCoverage.cxx158
-rw-r--r--Source/CTest/cmParseCoberturaCoverage.h4
-rw-r--r--Source/CTest/cmParseDelphiCoverage.cxx217
-rw-r--r--Source/CTest/cmParseDelphiCoverage.h30
-rw-r--r--Source/CTest/cmParseGTMCoverage.cxx207
-rw-r--r--Source/CTest/cmParseGTMCoverage.h15
-rw-r--r--Source/CTest/cmParseJacocoCoverage.cxx284
-rw-r--r--Source/CTest/cmParseJacocoCoverage.h11
-rw-r--r--Source/CTest/cmParseMumpsCoverage.cxx114
-rw-r--r--Source/CTest/cmParseMumpsCoverage.h8
-rw-r--r--Source/CTest/cmParsePHPCoverage.cxx183
-rw-r--r--Source/CTest/cmParsePHPCoverage.h5
-rw-r--r--Source/CTest/cmProcess.cxx182
-rw-r--r--Source/CTest/cmProcess.h23
-rw-r--r--Source/Checks/cm_c11_thread_local.c5
-rw-r--r--Source/Checks/cm_cxx11_unordered_map.cpp3
-rw-r--r--Source/Checks/cm_cxx14_cstdio.cpp5
-rw-r--r--Source/CursesDialog/ccmake.cxx147
-rw-r--r--Source/CursesDialog/cmCursesBoolWidget.cxx49
-rw-r--r--Source/CursesDialog/cmCursesBoolWidget.h1
-rw-r--r--Source/CursesDialog/cmCursesCacheEntryComposite.cxx77
-rw-r--r--Source/CursesDialog/cmCursesCacheEntryComposite.h5
-rw-r--r--Source/CursesDialog/cmCursesDummyWidget.cxx10
-rw-r--r--Source/CursesDialog/cmCursesDummyWidget.h1
-rw-r--r--Source/CursesDialog/cmCursesFilePathWidget.cxx7
-rw-r--r--Source/CursesDialog/cmCursesFilePathWidget.h1
-rw-r--r--Source/CursesDialog/cmCursesForm.cxx15
-rw-r--r--Source/CursesDialog/cmCursesForm.h7
-rw-r--r--Source/CursesDialog/cmCursesLabelWidget.cxx15
-rw-r--r--Source/CursesDialog/cmCursesLongMessageForm.cxx133
-rw-r--r--Source/CursesDialog/cmCursesLongMessageForm.h1
-rw-r--r--Source/CursesDialog/cmCursesMainForm.cxx1136
-rw-r--r--Source/CursesDialog/cmCursesMainForm.h17
-rw-r--r--Source/CursesDialog/cmCursesOptionsWidget.cxx61
-rw-r--r--Source/CursesDialog/cmCursesOptionsWidget.h3
-rw-r--r--Source/CursesDialog/cmCursesPathWidget.cxx54
-rw-r--r--Source/CursesDialog/cmCursesStandardIncludes.h9
-rw-r--r--Source/CursesDialog/cmCursesStringWidget.cxx166
-rw-r--r--Source/CursesDialog/cmCursesWidget.cxx23
-rw-r--r--Source/CursesDialog/cmCursesWidget.h18
-rw-r--r--Source/QtDialog/AddCacheEntry.cxx64
-rw-r--r--Source/QtDialog/AddCacheEntry.h5
-rw-r--r--Source/QtDialog/CMakeSetup.cxx164
-rw-r--r--Source/QtDialog/CMakeSetupDialog.cxx795
-rw-r--r--Source/QtDialog/CMakeSetupDialog.h12
-rw-r--r--Source/QtDialog/Compilers.h5
-rw-r--r--Source/QtDialog/FirstConfigure.cxx182
-rw-r--r--Source/QtDialog/FirstConfigure.h173
-rw-r--r--Source/QtDialog/QCMake.cxx234
-rw-r--r--Source/QtDialog/QCMake.h33
-rw-r--r--Source/QtDialog/QCMakeCacheView.cxx394
-rw-r--r--Source/QtDialog/QCMakeCacheView.h57
-rw-r--r--Source/QtDialog/QCMakeWidgets.cxx58
-rw-r--r--Source/QtDialog/QCMakeWidgets.h9
-rw-r--r--Source/QtDialog/RegexExplorer.cxx80
-rw-r--r--Source/QtDialog/WarningMessagesDialog.cxx27
-rw-r--r--Source/cmAddCompileOptionsCommand.cxx16
-rw-r--r--Source/cmAddCompileOptionsCommand.h9
-rw-r--r--Source/cmAddCustomCommandCommand.cxx395
-rw-r--r--Source/cmAddCustomCommandCommand.h11
-rw-r--r--Source/cmAddCustomTargetCommand.cxx165
-rw-r--r--Source/cmAddCustomTargetCommand.h10
-rw-r--r--Source/cmAddDefinitionsCommand.cxx17
-rw-r--r--Source/cmAddDefinitionsCommand.h11
-rw-r--r--Source/cmAddDependenciesCommand.cxx27
-rw-r--r--Source/cmAddDependenciesCommand.h10
-rw-r--r--Source/cmAddExecutableCommand.cxx202
-rw-r--r--Source/cmAddExecutableCommand.h10
-rw-r--r--Source/cmAddLibraryCommand.cxx339
-rw-r--r--Source/cmAddLibraryCommand.h10
-rw-r--r--Source/cmAddSubDirectoryCommand.cxx75
-rw-r--r--Source/cmAddSubDirectoryCommand.h11
-rw-r--r--Source/cmAddTestCommand.cxx101
-rw-r--r--Source/cmAddTestCommand.h11
-rw-r--r--Source/cmAlgorithms.h216
-rw-r--r--Source/cmArchiveWrite.cxx248
-rw-r--r--Source/cmArchiveWrite.h63
-rw-r--r--Source/cmAuxSourceDirectoryCommand.cxx56
-rw-r--r--Source/cmAuxSourceDirectoryCommand.h11
-rw-r--r--Source/cmBreakCommand.cxx37
-rw-r--r--Source/cmBreakCommand.h11
-rw-r--r--Source/cmBuildCommand.cxx117
-rw-r--r--Source/cmBuildCommand.h10
-rw-r--r--Source/cmBuildNameCommand.cxx71
-rw-r--r--Source/cmBuildNameCommand.h6
-rw-r--r--Source/cmCLocaleEnvironmentScope.cxx25
-rw-r--r--Source/cmCMakeHostSystemInformationCommand.cxx81
-rw-r--r--Source/cmCMakeHostSystemInformationCommand.h28
-rw-r--r--Source/cmCMakeMinimumRequired.cxx88
-rw-r--r--Source/cmCMakeMinimumRequired.h11
-rw-r--r--Source/cmCMakePolicyCommand.cxx130
-rw-r--r--Source/cmCMakePolicyCommand.h24
-rw-r--r--Source/cmCPackPropertiesGenerator.cxx40
-rw-r--r--Source/cmCPackPropertiesGenerator.h12
-rw-r--r--Source/cmCPluginAPI.cxx636
-rw-r--r--Source/cmCPluginAPI.h237
-rw-r--r--Source/cmCTest.cxx2630
-rw-r--r--Source/cmCTest.h244
-rw-r--r--Source/cmCacheManager.cxx473
-rw-r--r--Source/cmCacheManager.h92
-rw-r--r--Source/cmCallVisualStudioMacro.cxx322
-rw-r--r--Source/cmCallVisualStudioMacro.h4
-rw-r--r--Source/cmCommand.h71
-rw-r--r--Source/cmCommandArgumentParserHelper.cxx265
-rw-r--r--Source/cmCommandArgumentParserHelper.h13
-rw-r--r--Source/cmCommandArgumentsHelper.cxx210
-rw-r--r--Source/cmCommandArgumentsHelper.h237
-rw-r--r--Source/cmCommands.h1
-rw-r--r--Source/cmCommonTargetGenerator.cxx294
-rw-r--r--Source/cmCommonTargetGenerator.h12
-rw-r--r--Source/cmComputeComponentGraph.cxx60
-rw-r--r--Source/cmComputeComponentGraph.h18
-rw-r--r--Source/cmComputeLinkDepends.cxx455
-rw-r--r--Source/cmComputeLinkDepends.h40
-rw-r--r--Source/cmComputeLinkInformation.cxx1085
-rw-r--r--Source/cmComputeLinkInformation.h32
-rw-r--r--Source/cmComputeTargetDepends.cxx442
-rw-r--r--Source/cmComputeTargetDepends.h17
-rw-r--r--Source/cmConditionEvaluator.cxx746
-rw-r--r--Source/cmConditionEvaluator.h101
-rw-r--r--Source/cmConfigureFileCommand.cxx99
-rw-r--r--Source/cmConfigureFileCommand.h11
-rw-r--r--Source/cmContinueCommand.cxx14
-rw-r--r--Source/cmContinueCommand.h9
-rw-r--r--Source/cmCoreTryCompile.cxx626
-rw-r--r--Source/cmCoreTryCompile.h5
-rw-r--r--Source/cmCreateTestSourceList.cxx120
-rw-r--r--Source/cmCreateTestSourceList.h11
-rw-r--r--Source/cmCryptoHash.cxx90
-rw-r--r--Source/cmCryptoHash.h35
-rw-r--r--Source/cmCurl.cxx57
-rw-r--r--Source/cmCurl.h2
-rw-r--r--Source/cmCustomCommand.cxx39
-rw-r--r--Source/cmCustomCommand.h11
-rw-r--r--Source/cmCustomCommandGenerator.cxx111
-rw-r--r--Source/cmCustomCommandGenerator.h4
-rw-r--r--Source/cmDefinePropertyCommand.cxx108
-rw-r--r--Source/cmDefinePropertyCommand.h12
-rw-r--r--Source/cmDefinitions.cxx94
-rw-r--r--Source/cmDefinitions.h51
-rw-r--r--Source/cmDepends.cxx197
-rw-r--r--Source/cmDepends.h29
-rw-r--r--Source/cmDependsC.cxx442
-rw-r--r--Source/cmDependsC.h17
-rw-r--r--Source/cmDependsFortran.cxx507
-rw-r--r--Source/cmDependsFortran.h21
-rw-r--r--Source/cmDependsJava.cxx10
-rw-r--r--Source/cmDependsJava.h17
-rw-r--r--Source/cmDependsJavaParserHelper.cxx333
-rw-r--r--Source/cmDependsJavaParserHelper.h44
-rw-r--r--Source/cmDocumentation.cxx599
-rw-r--r--Source/cmDocumentation.h50
-rw-r--r--Source/cmDocumentationFormatter.cxx169
-rw-r--r--Source/cmDocumentationFormatter.h22
-rw-r--r--Source/cmDocumentationSection.cxx27
-rw-r--r--Source/cmDocumentationSection.h38
-rw-r--r--Source/cmDynamicLoader.cxx54
-rw-r--r--Source/cmDynamicLoader.h3
-rw-r--r--Source/cmELF.cxx699
-rw-r--r--Source/cmELF.h7
-rw-r--r--Source/cmElseCommand.cxx2
-rw-r--r--Source/cmElseCommand.h10
-rw-r--r--Source/cmElseIfCommand.cxx2
-rw-r--r--Source/cmElseIfCommand.h10
-rw-r--r--Source/cmEnableLanguageCommand.cxx26
-rw-r--r--Source/cmEnableLanguageCommand.h11
-rw-r--r--Source/cmEnableTestingCommand.cxx4
-rw-r--r--Source/cmEnableTestingCommand.h11
-rw-r--r--Source/cmEndForEachCommand.cxx6
-rw-r--r--Source/cmEndForEachCommand.h16
-rw-r--r--Source/cmEndFunctionCommand.cxx6
-rw-r--r--Source/cmEndFunctionCommand.h16
-rw-r--r--Source/cmEndIfCommand.cxx12
-rw-r--r--Source/cmEndIfCommand.h10
-rw-r--r--Source/cmEndMacroCommand.cxx6
-rw-r--r--Source/cmEndMacroCommand.h16
-rw-r--r--Source/cmEndWhileCommand.cxx15
-rw-r--r--Source/cmEndWhileCommand.h16
-rw-r--r--Source/cmExecProgramCommand.cxx221
-rw-r--r--Source/cmExecProgramCommand.h16
-rw-r--r--Source/cmExecuteProcessCommand.cxx316
-rw-r--r--Source/cmExecuteProcessCommand.h10
-rw-r--r--Source/cmExecutionStatus.h22
-rw-r--r--Source/cmExpandedCommandArgument.cxx15
-rw-r--r--Source/cmExpandedCommandArgument.h2
-rw-r--r--Source/cmExportBuildFileGenerator.cxx279
-rw-r--r--Source/cmExportBuildFileGenerator.h26
-rw-r--r--Source/cmExportCommand.cxx287
-rw-r--r--Source/cmExportCommand.h20
-rw-r--r--Source/cmExportFileGenerator.cxx907
-rw-r--r--Source/cmExportFileGenerator.h119
-rw-r--r--Source/cmExportInstallFileGenerator.cxx392
-rw-r--r--Source/cmExportInstallFileGenerator.h23
-rw-r--r--Source/cmExportLibraryDependenciesCommand.cxx125
-rw-r--r--Source/cmExportLibraryDependenciesCommand.h5
-rw-r--r--Source/cmExportSet.cxx5
-rw-r--r--Source/cmExportSet.h13
-rw-r--r--Source/cmExportSetMap.cxx6
-rw-r--r--Source/cmExportSetMap.h3
-rw-r--r--Source/cmExportTryCompileFileGenerator.cxx103
-rw-r--r--Source/cmExportTryCompileFileGenerator.h20
-rw-r--r--Source/cmExprParserHelper.cxx61
-rw-r--r--Source/cmExprParserHelper.h6
-rw-r--r--Source/cmExternalMakefileProjectGenerator.cxx46
-rw-r--r--Source/cmExternalMakefileProjectGenerator.h15
-rw-r--r--Source/cmExtraCodeBlocksGenerator.cxx596
-rw-r--r--Source/cmExtraCodeBlocksGenerator.h26
-rw-r--r--Source/cmExtraCodeLiteGenerator.cxx281
-rw-r--r--Source/cmExtraCodeLiteGenerator.h15
-rw-r--r--Source/cmExtraEclipseCDT4Generator.cxx912
-rw-r--r--Source/cmExtraEclipseCDT4Generator.h62
-rw-r--r--Source/cmExtraKateGenerator.cxx273
-rw-r--r--Source/cmExtraKateGenerator.h20
-rw-r--r--Source/cmExtraSublimeTextGenerator.cxx372
-rw-r--r--Source/cmExtraSublimeTextGenerator.h36
-rw-r--r--Source/cmFLTKWrapUICommand.cxx75
-rw-r--r--Source/cmFLTKWrapUICommand.h13
-rw-r--r--Source/cmFileCommand.cxx2974
-rw-r--r--Source/cmFileCommand.h17
-rw-r--r--Source/cmFileLock.cxx40
-rw-r--r--Source/cmFileLock.h6
-rw-r--r--Source/cmFileLockPool.cxx103
-rw-r--r--Source/cmFileLockPool.h28
-rw-r--r--Source/cmFileLockResult.cxx36
-rw-r--r--Source/cmFileLockResult.h6
-rw-r--r--Source/cmFileLockUnix.cxx61
-rw-r--r--Source/cmFileLockWin32.cxx83
-rw-r--r--Source/cmFileTimeComparison.cxx179
-rw-r--r--Source/cmFileTimeComparison.h3
-rw-r--r--Source/cmFindBase.cxx268
-rw-r--r--Source/cmFindBase.h3
-rw-r--r--Source/cmFindCommon.cxx260
-rw-r--r--Source/cmFindCommon.h21
-rw-r--r--Source/cmFindFileCommand.h9
-rw-r--r--Source/cmFindLibraryCommand.cxx322
-rw-r--r--Source/cmFindLibraryCommand.h16
-rw-r--r--Source/cmFindPackageCommand.cxx1738
-rw-r--r--Source/cmFindPackageCommand.h34
-rw-r--r--Source/cmFindPathCommand.cxx145
-rw-r--r--Source/cmFindPathCommand.h13
-rw-r--r--Source/cmFindProgramCommand.cxx191
-rw-r--r--Source/cmFindProgramCommand.h12
-rw-r--r--Source/cmForEachCommand.cxx211
-rw-r--r--Source/cmForEachCommand.h19
-rw-r--r--Source/cmFortranParser.h70
-rw-r--r--Source/cmFortranParserImpl.cxx218
-rw-r--r--Source/cmFunctionBlocker.h20
-rw-r--r--Source/cmFunctionCommand.cxx113
-rw-r--r--Source/cmFunctionCommand.h19
-rw-r--r--Source/cmGeneratedFileStream.cxx118
-rw-r--r--Source/cmGeneratedFileStream.h10
-rw-r--r--Source/cmGeneratorExpression.cxx362
-rw-r--r--Source/cmGeneratorExpression.h71
-rw-r--r--Source/cmGeneratorExpressionContext.cxx32
-rw-r--r--Source/cmGeneratorExpressionContext.h5
-rw-r--r--Source/cmGeneratorExpressionDAGChecker.cxx213
-rw-r--r--Source/cmGeneratorExpressionDAGChecker.h63
-rw-r--r--Source/cmGeneratorExpressionEvaluationFile.cxx150
-rw-r--r--Source/cmGeneratorExpressionEvaluationFile.h11
-rw-r--r--Source/cmGeneratorExpressionEvaluator.cxx246
-rw-r--r--Source/cmGeneratorExpressionEvaluator.h69
-rw-r--r--Source/cmGeneratorExpressionLexer.cxx45
-rw-r--r--Source/cmGeneratorExpressionLexer.h11
-rw-r--r--Source/cmGeneratorExpressionNode.cxx1561
-rw-r--r--Source/cmGeneratorExpressionNode.h29
-rw-r--r--Source/cmGeneratorExpressionParser.cxx235
-rw-r--r--Source/cmGeneratorExpressionParser.h9
-rw-r--r--Source/cmGeneratorTarget.cxx4648
-rw-r--r--Source/cmGeneratorTarget.h248
-rw-r--r--Source/cmGetCMakePropertyCommand.cxx46
-rw-r--r--Source/cmGetCMakePropertyCommand.h11
-rw-r--r--Source/cmGetDirectoryPropertyCommand.cxx84
-rw-r--r--Source/cmGetDirectoryPropertyCommand.h9
-rw-r--r--Source/cmGetFilenameComponentCommand.cxx121
-rw-r--r--Source/cmGetFilenameComponentCommand.h11
-rw-r--r--Source/cmGetPropertyCommand.cxx327
-rw-r--r--Source/cmGetPropertyCommand.h19
-rw-r--r--Source/cmGetSourceFilePropertyCommand.cxx35
-rw-r--r--Source/cmGetSourceFilePropertyCommand.h11
-rw-r--r--Source/cmGetTargetPropertyCommand.cxx58
-rw-r--r--Source/cmGetTargetPropertyCommand.h11
-rw-r--r--Source/cmGetTestPropertyCommand.cxx27
-rw-r--r--Source/cmGetTestPropertyCommand.h11
-rw-r--r--Source/cmGhsMultiGpj.cxx9
-rw-r--r--Source/cmGhsMultiGpj.h2
-rw-r--r--Source/cmGhsMultiTargetGenerator.cxx554
-rw-r--r--Source/cmGhsMultiTargetGenerator.h90
-rw-r--r--Source/cmGlobalBorlandMakefileGenerator.cxx18
-rw-r--r--Source/cmGlobalBorlandMakefileGenerator.h22
-rw-r--r--Source/cmGlobalCommonGenerator.cxx4
-rw-r--r--Source/cmGlobalGenerator.cxx2018
-rw-r--r--Source/cmGlobalGenerator.h204
-rw-r--r--Source/cmGlobalGeneratorFactory.h29
-rw-r--r--Source/cmGlobalGhsMultiGenerator.cxx305
-rw-r--r--Source/cmGlobalGhsMultiGenerator.h89
-rw-r--r--Source/cmGlobalJOMMakefileGenerator.cxx20
-rw-r--r--Source/cmGlobalJOMMakefileGenerator.h20
-rw-r--r--Source/cmGlobalKdevelopGenerator.cxx475
-rw-r--r--Source/cmGlobalKdevelopGenerator.h11
-rw-r--r--Source/cmGlobalMSYSMakefileGenerator.cxx51
-rw-r--r--Source/cmGlobalMSYSMakefileGenerator.h19
-rw-r--r--Source/cmGlobalMinGWMakefileGenerator.cxx25
-rw-r--r--Source/cmGlobalMinGWMakefileGenerator.h20
-rw-r--r--Source/cmGlobalNMakeMakefileGenerator.cxx20
-rw-r--r--Source/cmGlobalNMakeMakefileGenerator.h21
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx948
-rw-r--r--Source/cmGlobalNinjaGenerator.h192
-rw-r--r--Source/cmGlobalUnixMakefileGenerator3.cxx869
-rw-r--r--Source/cmGlobalUnixMakefileGenerator3.h97
-rw-r--r--Source/cmGlobalVisualStudio10Generator.cxx372
-rw-r--r--Source/cmGlobalVisualStudio10Generator.h49
-rw-r--r--Source/cmGlobalVisualStudio11Generator.cxx232
-rw-r--r--Source/cmGlobalVisualStudio11Generator.h7
-rw-r--r--Source/cmGlobalVisualStudio12Generator.cxx188
-rw-r--r--Source/cmGlobalVisualStudio12Generator.h12
-rw-r--r--Source/cmGlobalVisualStudio14Generator.cxx197
-rw-r--r--Source/cmGlobalVisualStudio14Generator.h6
-rw-r--r--Source/cmGlobalVisualStudio71Generator.cxx163
-rw-r--r--Source/cmGlobalVisualStudio71Generator.h34
-rw-r--r--Source/cmGlobalVisualStudio7Generator.cxx586
-rw-r--r--Source/cmGlobalVisualStudio7Generator.h69
-rw-r--r--Source/cmGlobalVisualStudio8Generator.cxx429
-rw-r--r--Source/cmGlobalVisualStudio8Generator.h20
-rw-r--r--Source/cmGlobalVisualStudio9Generator.cxx86
-rw-r--r--Source/cmGlobalVisualStudio9Generator.h7
-rw-r--r--Source/cmGlobalVisualStudioGenerator.cxx670
-rw-r--r--Source/cmGlobalVisualStudioGenerator.h59
-rw-r--r--Source/cmGlobalWatcomWMakeGenerator.cxx10
-rw-r--r--Source/cmGlobalWatcomWMakeGenerator.h19
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx3190
-rw-r--r--Source/cmGlobalXCodeGenerator.h114
-rw-r--r--Source/cmGraphAdjacencyList.h36
-rw-r--r--Source/cmGraphVizWriter.cxx430
-rw-r--r--Source/cmGraphVizWriter.h2
-rw-r--r--Source/cmHexFileConverter.cxx205
-rw-r--r--Source/cmHexFileConverter.h7
-rw-r--r--Source/cmIDEFlagTable.h30
-rw-r--r--Source/cmIDEOptions.cxx117
-rw-r--r--Source/cmIDEOptions.h20
-rw-r--r--Source/cmIfCommand.cxx161
-rw-r--r--Source/cmIfCommand.h31
-rw-r--r--Source/cmIncludeCommand.cxx150
-rw-r--r--Source/cmIncludeCommand.h11
-rw-r--r--Source/cmIncludeDirectoryCommand.cxx101
-rw-r--r--Source/cmIncludeDirectoryCommand.h15
-rw-r--r--Source/cmIncludeExternalMSProjectCommand.cxx84
-rw-r--r--Source/cmIncludeExternalMSProjectCommand.h11
-rw-r--r--Source/cmIncludeRegularExpressionCommand.cxx15
-rw-r--r--Source/cmIncludeRegularExpressionCommand.h11
-rw-r--r--Source/cmInstallCommand.cxx1180
-rw-r--r--Source/cmInstallCommand.h10
-rw-r--r--Source/cmInstallCommandArguments.cxx183
-rw-r--r--Source/cmInstallCommandArguments.h110
-rw-r--r--Source/cmInstallDirectoryGenerator.cxx101
-rw-r--r--Source/cmInstallDirectoryGenerator.h14
-rw-r--r--Source/cmInstallExportGenerator.cxx126
-rw-r--r--Source/cmInstallExportGenerator.h19
-rw-r--r--Source/cmInstallFilesCommand.cxx113
-rw-r--r--Source/cmInstallFilesCommand.h12
-rw-r--r--Source/cmInstallFilesGenerator.cxx99
-rw-r--r--Source/cmInstallFilesGenerator.h11
-rw-r--r--Source/cmInstallGenerator.cxx242
-rw-r--r--Source/cmInstallGenerator.h24
-rw-r--r--Source/cmInstallProgramsCommand.cxx81
-rw-r--r--Source/cmInstallProgramsCommand.h11
-rw-r--r--Source/cmInstallScriptGenerator.cxx26
-rw-r--r--Source/cmInstallScriptGenerator.h4
-rw-r--r--Source/cmInstallTargetGenerator.cxx601
-rw-r--r--Source/cmInstallTargetGenerator.h26
-rw-r--r--Source/cmInstallTargetsCommand.cxx38
-rw-r--r--Source/cmInstallTargetsCommand.h10
-rw-r--r--Source/cmInstalledFile.cxx39
-rw-r--r--Source/cmInstalledFile.h14
-rw-r--r--Source/cmLinkDirectoriesCommand.cxx29
-rw-r--r--Source/cmLinkDirectoriesCommand.h12
-rw-r--r--Source/cmLinkItem.h106
-rw-r--r--Source/cmLinkLibrariesCommand.cxx40
-rw-r--r--Source/cmLinkLibrariesCommand.h11
-rw-r--r--Source/cmLinkedTree.h50
-rw-r--r--Source/cmListCommand.cxx392
-rw-r--r--Source/cmListCommand.h20
-rw-r--r--Source/cmListFileCache.cxx401
-rw-r--r--Source/cmListFileCache.h54
-rw-r--r--Source/cmListFileLexer.h6
-rw-r--r--Source/cmLoadCacheCommand.cxx136
-rw-r--r--Source/cmLoadCacheCommand.h12
-rw-r--r--Source/cmLoadCommandCommand.cxx195
-rw-r--r--Source/cmLoadCommandCommand.h6
-rw-r--r--Source/cmLocalCommonGenerator.cxx13
-rw-r--r--Source/cmLocalCommonGenerator.h2
-rw-r--r--Source/cmLocalGenerator.cxx2181
-rw-r--r--Source/cmLocalGenerator.h110
-rw-r--r--Source/cmLocalGhsMultiGenerator.cxx14
-rw-r--r--Source/cmLocalNinjaGenerator.cxx263
-rw-r--r--Source/cmLocalNinjaGenerator.h25
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx1740
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.h144
-rw-r--r--Source/cmLocalVisualStudio10Generator.cxx105
-rw-r--r--Source/cmLocalVisualStudio10Generator.h2
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx2214
-rw-r--r--Source/cmLocalVisualStudio7Generator.h52
-rw-r--r--Source/cmLocalVisualStudioGenerator.cxx102
-rw-r--r--Source/cmLocalVisualStudioGenerator.h14
-rw-r--r--Source/cmLocalXCodeGenerator.cxx35
-rw-r--r--Source/cmLocalXCodeGenerator.h14
-rw-r--r--Source/cmLocale.h13
-rw-r--r--Source/cmMachO.cxx260
-rw-r--r--Source/cmMachO.h2
-rw-r--r--Source/cmMacroCommand.cxx136
-rw-r--r--Source/cmMacroCommand.h19
-rw-r--r--Source/cmMakeDirectoryCommand.cxx25
-rw-r--r--Source/cmMakeDirectoryCommand.h11
-rw-r--r--Source/cmMakefile.cxx3226
-rw-r--r--Source/cmMakefile.h325
-rw-r--r--Source/cmMakefileExecutableTargetGenerator.cxx390
-rw-r--r--Source/cmMakefileExecutableTargetGenerator.h2
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.cxx755
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.h6
-rw-r--r--Source/cmMakefileTargetGenerator.cxx1304
-rw-r--r--Source/cmMakefileTargetGenerator.h59
-rw-r--r--Source/cmMakefileUtilityTargetGenerator.cxx57
-rw-r--r--Source/cmMakefileUtilityTargetGenerator.h4
-rw-r--r--Source/cmMarkAsAdvancedCommand.cxx42
-rw-r--r--Source/cmMarkAsAdvancedCommand.h11
-rw-r--r--Source/cmMathCommand.cxx30
-rw-r--r--Source/cmMathCommand.h13
-rw-r--r--Source/cmMessageCommand.cxx82
-rw-r--r--Source/cmMessageCommand.h10
-rw-r--r--Source/cmNewLineStyle.cxx41
-rw-r--r--Source/cmNewLineStyle.h11
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx591
-rw-r--r--Source/cmNinjaTargetGenerator.cxx554
-rw-r--r--Source/cmNinjaTargetGenerator.h52
-rw-r--r--Source/cmNinjaUtilityTargetGenerator.cxx96
-rw-r--r--Source/cmOSXBundleGenerator.cxx102
-rw-r--r--Source/cmOSXBundleGenerator.h11
-rw-r--r--Source/cmObject.h7
-rw-r--r--Source/cmOptionCommand.cxx39
-rw-r--r--Source/cmOptionCommand.h11
-rw-r--r--Source/cmOrderDirectories.cxx374
-rw-r--r--Source/cmOrderDirectories.h5
-rw-r--r--Source/cmOutputConverter.cxx719
-rw-r--r--Source/cmOutputConverter.h58
-rw-r--r--Source/cmOutputRequiredFilesCommand.cxx429
-rw-r--r--Source/cmOutputRequiredFilesCommand.h12
-rw-r--r--Source/cmParseArgumentsCommand.cxx128
-rw-r--r--Source/cmParseArgumentsCommand.h11
-rw-r--r--Source/cmPathLabel.cxx12
-rw-r--r--Source/cmPathLabel.h4
-rw-r--r--Source/cmPolicies.cxx293
-rw-r--r--Source/cmPolicies.h435
-rw-r--r--Source/cmProcessTools.cxx56
-rw-r--r--Source/cmProcessTools.h22
-rw-r--r--Source/cmProjectCommand.cxx192
-rw-r--r--Source/cmProjectCommand.h11
-rw-r--r--Source/cmProperty.cxx16
-rw-r--r--Source/cmProperty.h20
-rw-r--r--Source/cmPropertyDefinition.cxx21
-rw-r--r--Source/cmPropertyDefinition.h20
-rw-r--r--Source/cmPropertyDefinitionMap.cxx29
-rw-r--r--Source/cmPropertyDefinitionMap.h10
-rw-r--r--Source/cmPropertyMap.cxx40
-rw-r--r--Source/cmPropertyMap.h11
-rw-r--r--Source/cmQTWrapCPPCommand.cxx68
-rw-r--r--Source/cmQTWrapCPPCommand.h11
-rw-r--r--Source/cmQTWrapUICommand.cxx89
-rw-r--r--Source/cmQTWrapUICommand.h11
-rw-r--r--Source/cmQtAutoGeneratorInitializer.cxx942
-rw-r--r--Source/cmQtAutoGenerators.cxx1464
-rw-r--r--Source/cmQtAutoGenerators.h76
-rw-r--r--Source/cmRST.cxx382
-rw-r--r--Source/cmRST.h1
-rw-r--r--Source/cmRemoveCommand.cxx39
-rw-r--r--Source/cmRemoveCommand.h11
-rw-r--r--Source/cmRemoveDefinitionsCommand.cxx17
-rw-r--r--Source/cmRemoveDefinitionsCommand.h11
-rw-r--r--Source/cmReturnCommand.cxx3
-rw-r--r--Source/cmReturnCommand.h11
-rw-r--r--Source/cmScriptGenerator.cxx132
-rw-r--r--Source/cmScriptGenerator.h22
-rw-r--r--Source/cmSearchPath.cxx161
-rw-r--r--Source/cmSearchPath.h6
-rw-r--r--Source/cmSeparateArgumentsCommand.cxx87
-rw-r--r--Source/cmSeparateArgumentsCommand.h11
-rw-r--r--Source/cmSetCommand.cxx122
-rw-r--r--Source/cmSetCommand.h11
-rw-r--r--Source/cmSetDirectoryPropertiesCommand.cxx56
-rw-r--r--Source/cmSetDirectoryPropertiesCommand.h15
-rw-r--r--Source/cmSetPropertyCommand.cxx391
-rw-r--r--Source/cmSetPropertyCommand.h11
-rw-r--r--Source/cmSetSourceFilesPropertiesCommand.cxx136
-rw-r--r--Source/cmSetSourceFilesPropertiesCommand.h15
-rw-r--r--Source/cmSetTargetPropertiesCommand.cxx77
-rw-r--r--Source/cmSetTargetPropertiesCommand.h15
-rw-r--r--Source/cmSetTestsPropertiesCommand.cxx71
-rw-r--r--Source/cmSetTestsPropertiesCommand.h16
-rw-r--r--Source/cmSiteNameCommand.cxx69
-rw-r--r--Source/cmSiteNameCommand.h11
-rw-r--r--Source/cmSourceFile.cxx208
-rw-r--r--Source/cmSourceFile.h15
-rw-r--r--Source/cmSourceFileLocation.cxx217
-rw-r--r--Source/cmSourceGroup.cxx70
-rw-r--r--Source/cmSourceGroup.h9
-rw-r--r--Source/cmSourceGroupCommand.cxx63
-rw-r--r--Source/cmSourceGroupCommand.h11
-rw-r--r--Source/cmStandardIncludes.h90
-rw-r--r--Source/cmStandardLexer.h30
-rw-r--r--Source/cmState.cxx1205
-rw-r--r--Source/cmState.h83
-rw-r--r--Source/cmStringCommand.cxx737
-rw-r--r--Source/cmStringCommand.h34
-rw-r--r--Source/cmSubdirCommand.cxx57
-rw-r--r--Source/cmSubdirCommand.h11
-rw-r--r--Source/cmSubdirDependsCommand.cxx7
-rw-r--r--Source/cmSubdirDependsCommand.h4
-rw-r--r--Source/cmSystemTools.cxx2303
-rw-r--r--Source/cmSystemTools.h135
-rw-r--r--Source/cmTarget.cxx1173
-rw-r--r--Source/cmTarget.h168
-rw-r--r--Source/cmTargetCompileDefinitionsCommand.cxx44
-rw-r--r--Source/cmTargetCompileDefinitionsCommand.h19
-rw-r--r--Source/cmTargetCompileFeaturesCommand.cxx37
-rw-r--r--Source/cmTargetCompileFeaturesCommand.h19
-rw-r--r--Source/cmTargetCompileOptionsCommand.cxx27
-rw-r--r--Source/cmTargetCompileOptionsCommand.h19
-rw-r--r--Source/cmTargetDepend.h26
-rw-r--r--Source/cmTargetIncludeDirectoriesCommand.cxx84
-rw-r--r--Source/cmTargetIncludeDirectoriesCommand.h25
-rw-r--r--Source/cmTargetLinkLibrariesCommand.cxx433
-rw-r--r--Source/cmTargetLinkLibrariesCommand.h15
-rw-r--r--Source/cmTargetPropCommandBase.cxx157
-rw-r--r--Source/cmTargetPropCommandBase.h30
-rw-r--r--Source/cmTargetSourcesCommand.cxx25
-rw-r--r--Source/cmTargetSourcesCommand.h19
-rw-r--r--Source/cmTest.cxx20
-rw-r--r--Source/cmTest.h18
-rw-r--r--Source/cmTestGenerator.cxx115
-rw-r--r--Source/cmTestGenerator.h6
-rw-r--r--Source/cmTimestamp.cxx98
-rw-r--r--Source/cmTimestamp.h12
-rw-r--r--Source/cmTryCompileCommand.cxx29
-rw-r--r--Source/cmTryCompileCommand.h11
-rw-r--r--Source/cmTryRunCommand.cxx289
-rw-r--r--Source/cmTryRunCommand.h11
-rw-r--r--Source/cmUnsetCommand.cxx39
-rw-r--r--Source/cmUnsetCommand.h11
-rw-r--r--Source/cmUseMangledMesaCommand.cxx81
-rw-r--r--Source/cmUseMangledMesaCommand.h7
-rw-r--r--Source/cmUtilitySourceCommand.cxx111
-rw-r--r--Source/cmUtilitySourceCommand.h4
-rw-r--r--Source/cmUuid.cxx112
-rw-r--r--Source/cmUuid.h14
-rw-r--r--Source/cmVS10CLFlagTable.h464
-rw-r--r--Source/cmVS10LibFlagTable.h154
-rw-r--r--Source/cmVS10LinkFlagTable.h531
-rw-r--r--Source/cmVS10MASMFlagTable.h144
-rw-r--r--Source/cmVS10RCFlagTable.h9
-rw-r--r--Source/cmVS11CLFlagTable.h497
-rw-r--r--Source/cmVS11LibFlagTable.h154
-rw-r--r--Source/cmVS11LinkFlagTable.h556
-rw-r--r--Source/cmVS11MASMFlagTable.h144
-rw-r--r--Source/cmVS11RCFlagTable.h9
-rw-r--r--Source/cmVS12CLFlagTable.h505
-rw-r--r--Source/cmVS12LibFlagTable.h154
-rw-r--r--Source/cmVS12LinkFlagTable.h556
-rw-r--r--Source/cmVS12MASMFlagTable.h144
-rw-r--r--Source/cmVS12RCFlagTable.h9
-rw-r--r--Source/cmVS14CLFlagTable.h544
-rw-r--r--Source/cmVS14LibFlagTable.h154
-rw-r--r--Source/cmVS14LinkFlagTable.h560
-rw-r--r--Source/cmVS14MASMFlagTable.h144
-rw-r--r--Source/cmVS14RCFlagTable.h9
-rw-r--r--Source/cmVariableRequiresCommand.cxx54
-rw-r--r--Source/cmVariableRequiresCommand.h5
-rw-r--r--Source/cmVariableWatch.cxx74
-rw-r--r--Source/cmVariableWatch.h36
-rw-r--r--Source/cmVariableWatchCommand.cxx96
-rw-r--r--Source/cmVariableWatchCommand.h12
-rw-r--r--Source/cmVersion.cxx20
-rw-r--r--Source/cmVersion.h9
-rw-r--r--Source/cmVersionMacros.h2
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx2900
-rw-r--r--Source/cmVisualStudio10TargetGenerator.h27
-rw-r--r--Source/cmVisualStudioGeneratorOptions.cxx294
-rw-r--r--Source/cmVisualStudioGeneratorOptions.h15
-rw-r--r--Source/cmVisualStudioSlnData.cxx22
-rw-r--r--Source/cmVisualStudioSlnData.h19
-rw-r--r--Source/cmVisualStudioSlnParser.cxx362
-rw-r--r--Source/cmVisualStudioSlnParser.h20
-rw-r--r--Source/cmVisualStudioWCEPlatformParser.cxx110
-rw-r--r--Source/cmVisualStudioWCEPlatformParser.h31
-rw-r--r--Source/cmWhileCommand.cxx122
-rw-r--r--Source/cmWhileCommand.h24
-rw-r--r--Source/cmWriteFileCommand.cxx56
-rw-r--r--Source/cmWriteFileCommand.h10
-rw-r--r--Source/cmXCode21Object.cxx52
-rw-r--r--Source/cmXCode21Object.h6
-rw-r--r--Source/cmXCodeObject.cxx209
-rw-r--r--Source/cmXCodeObject.h184
-rw-r--r--Source/cmXMLParser.cxx94
-rw-r--r--Source/cmXMLParser.h27
-rw-r--r--Source/cmXMLSafe.cxx72
-rw-r--r--Source/cmXMLSafe.h1
-rw-r--r--Source/cmXMLWriter.cxx34
-rw-r--r--Source/cmXMLWriter.h36
-rw-r--r--Source/cm_get_date.h2
-rw-r--r--Source/cm_utf8.c67
-rw-r--r--Source/cmake.cxx2247
-rw-r--r--Source/cmake.h343
-rw-r--r--Source/cmakemain.cxx348
-rw-r--r--Source/cmakexbuild.cxx51
-rw-r--r--Source/cmcldeps.cxx130
-rw-r--r--Source/cmcmd.cxx1329
-rw-r--r--Source/cmcmd.h3
-rw-r--r--Source/ctest.cxx236
758 files changed, 56831 insertions, 78042 deletions
diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.cxx b/Source/CPack/IFW/cmCPackIFWGenerator.cxx
index cf8587c..2c25f43 100644
--- a/Source/CPack/IFW/cmCPackIFWGenerator.cxx
+++ b/Source/CPack/IFW/cmCPackIFWGenerator.cxx
@@ -39,22 +39,22 @@ cmCPackIFWGenerator::~cmCPackIFWGenerator()
{
}
-bool cmCPackIFWGenerator::IsVersionLess(const char *version)
+bool cmCPackIFWGenerator::IsVersionLess(const char* version)
{
return cmSystemTools::VersionCompare(cmSystemTools::OP_LESS,
- FrameworkVersion.data(), version);
+ FrameworkVersion.data(), version);
}
-bool cmCPackIFWGenerator::IsVersionGreater(const char *version)
+bool cmCPackIFWGenerator::IsVersionGreater(const char* version)
{
return cmSystemTools::VersionCompare(cmSystemTools::OP_GREATER,
- FrameworkVersion.data(), version);
+ FrameworkVersion.data(), version);
}
-bool cmCPackIFWGenerator::IsVersionEqual(const char *version)
+bool cmCPackIFWGenerator::IsVersionEqual(const char* version)
{
return cmSystemTools::VersionCompare(cmSystemTools::OP_EQUAL,
- FrameworkVersion.data(), version);
+ FrameworkVersion.data(), version);
}
int cmCPackIFWGenerator::PackageFiles()
@@ -72,168 +72,141 @@ int cmCPackIFWGenerator::PackageFiles()
ifwTmpFile += "/IFWOutput.log";
// Run repogen
- if (!Installer.Repositories.empty())
- {
+ if (!Installer.Repositories.empty()) {
std::string ifwCmd = RepoGen;
- if(IsVersionLess("2.0.0"))
- {
+ if (IsVersionLess("2.0.0")) {
ifwCmd += " -c " + this->toplevel + "/config/config.xml";
- }
+ }
ifwCmd += " -p " + this->toplevel + "/packages";
- if(!PkgsDirsVector.empty())
- {
- for(std::vector<std::string>::iterator it = PkgsDirsVector.begin();
- it != PkgsDirsVector.end(); ++it)
- {
+ if (!PkgsDirsVector.empty()) {
+ for (std::vector<std::string>::iterator it = PkgsDirsVector.begin();
+ it != PkgsDirsVector.end(); ++it) {
ifwCmd += " -p " + *it;
- }
}
+ }
- if (!OnlineOnly && !DownloadedPackages.empty())
- {
+ if (!OnlineOnly && !DownloadedPackages.empty()) {
ifwCmd += " -i ";
- std::set<cmCPackIFWPackage*>::iterator it
- = DownloadedPackages.begin();
+ std::set<cmCPackIFWPackage*>::iterator it = DownloadedPackages.begin();
ifwCmd += (*it)->Name;
++it;
- while(it != DownloadedPackages.end())
- {
+ while (it != DownloadedPackages.end()) {
ifwCmd += "," + (*it)->Name;
++it;
- }
}
+ }
ifwCmd += " " + this->toplevel + "/repository";
- cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << ifwCmd
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << ifwCmd << std::endl);
std::string output;
int retVal = 1;
- cmCPackLogger(cmCPackLog::LOG_OUTPUT,
- "- Generate repository" << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Generate repository"
+ << std::endl);
bool res = cmSystemTools::RunSingleCommand(
- ifwCmd.c_str(), &output, &output,
- &retVal, 0, this->GeneratorVerbose, 0);
- if ( !res || retVal )
- {
+ ifwCmd.c_str(), &output, &output, &retVal, 0, this->GeneratorVerbose, 0);
+ if (!res || retVal) {
cmGeneratedFileStream ofs(ifwTmpFile.c_str());
ofs << "# Run command: " << ifwCmd << std::endl
<< "# Output:" << std::endl
<< output << std::endl;
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running IFW command: "
- << ifwCmd << std::endl
- << "Please check " << ifwTmpFile << " for errors"
- << std::endl);
+ << ifwCmd << std::endl
+ << "Please check " << ifwTmpFile << " for errors"
+ << std::endl);
return 0;
- }
- cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- repository: " << this->toplevel
- << "/repository generated" << std::endl);
}
+ cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- repository: "
+ << this->toplevel << "/repository generated" << std::endl);
+ }
// Run binary creator
{
- std::string ifwCmd = BinCreator;
- ifwCmd += " -c " + this->toplevel + "/config/config.xml";
- ifwCmd += " -p " + this->toplevel + "/packages";
-
- if(!PkgsDirsVector.empty())
- {
- for(std::vector<std::string>::iterator it = PkgsDirsVector.begin();
- it != PkgsDirsVector.end(); ++it)
- {
- ifwCmd += " -p " + *it;
+ std::string ifwCmd = BinCreator;
+ ifwCmd += " -c " + this->toplevel + "/config/config.xml";
+ ifwCmd += " -p " + this->toplevel + "/packages";
+
+ if (!PkgsDirsVector.empty()) {
+ for (std::vector<std::string>::iterator it = PkgsDirsVector.begin();
+ it != PkgsDirsVector.end(); ++it) {
+ ifwCmd += " -p " + *it;
}
}
- if (OnlineOnly)
- {
- ifwCmd += " --online-only";
- }
- else if (!DownloadedPackages.empty() && !Installer.Repositories.empty())
- {
- ifwCmd += " -e ";
- std::set<cmCPackIFWPackage*>::iterator it
- = DownloadedPackages.begin();
- ifwCmd += (*it)->Name;
- ++it;
- while(it != DownloadedPackages.end())
- {
- ifwCmd += "," + (*it)->Name;
+ if (OnlineOnly) {
+ ifwCmd += " --online-only";
+ } else if (!DownloadedPackages.empty() &&
+ !Installer.Repositories.empty()) {
+ ifwCmd += " -e ";
+ std::set<cmCPackIFWPackage*>::iterator it = DownloadedPackages.begin();
+ ifwCmd += (*it)->Name;
++it;
+ while (it != DownloadedPackages.end()) {
+ ifwCmd += "," + (*it)->Name;
+ ++it;
}
- }
- else if (!DependentPackages.empty())
- {
- ifwCmd += " -i ";
- // Binary
- std::set<cmCPackIFWPackage*>::iterator bit = BinaryPackages.begin();
- while(bit != BinaryPackages.end())
- {
- ifwCmd += (*bit)->Name + ",";
- ++bit;
+ } else if (!DependentPackages.empty()) {
+ ifwCmd += " -i ";
+ // Binary
+ std::set<cmCPackIFWPackage*>::iterator bit = BinaryPackages.begin();
+ while (bit != BinaryPackages.end()) {
+ ifwCmd += (*bit)->Name + ",";
+ ++bit;
}
- // Depend
- DependenceMap::iterator it = DependentPackages.begin();
- ifwCmd += it->second.Name;
- ++it;
- while(it != DependentPackages.end())
- {
- ifwCmd += "," + it->second.Name;
+ // Depend
+ DependenceMap::iterator it = DependentPackages.begin();
+ ifwCmd += it->second.Name;
++it;
+ while (it != DependentPackages.end()) {
+ ifwCmd += "," + it->second.Name;
+ ++it;
}
}
- // TODO: set correct name for multipackages
- if (!this->packageFileNames.empty())
- {
- ifwCmd += " " + packageFileNames[0];
- }
- else
- {
- ifwCmd += " installer";
+ // TODO: set correct name for multipackages
+ if (!this->packageFileNames.empty()) {
+ ifwCmd += " " + packageFileNames[0];
+ } else {
+ ifwCmd += " installer";
}
- cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << ifwCmd
- << std::endl);
- std::string output;
- int retVal = 1;
- cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Generate package" << std::endl);
- bool res = cmSystemTools::RunSingleCommand(
- ifwCmd.c_str(), &output, &output,
- &retVal, 0, this->GeneratorVerbose, 0);
- if ( !res || retVal )
- {
- cmGeneratedFileStream ofs(ifwTmpFile.c_str());
- ofs << "# Run command: " << ifwCmd << std::endl
- << "# Output:" << std::endl
- << output << std::endl;
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running IFW command: "
- << ifwCmd << std::endl
- << "Please check " << ifwTmpFile << " for errors"
- << std::endl);
- return 0;
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << ifwCmd << std::endl);
+ std::string output;
+ int retVal = 1;
+ cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Generate package" << std::endl);
+ bool res = cmSystemTools::RunSingleCommand(
+ ifwCmd.c_str(), &output, &output, &retVal, 0, this->GeneratorVerbose, 0);
+ if (!res || retVal) {
+ cmGeneratedFileStream ofs(ifwTmpFile.c_str());
+ ofs << "# Run command: " << ifwCmd << std::endl
+ << "# Output:" << std::endl
+ << output << std::endl;
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running IFW command: "
+ << ifwCmd << std::endl
+ << "Please check " << ifwTmpFile << " for errors"
+ << std::endl);
+ return 0;
}
}
return 1;
}
-const char *cmCPackIFWGenerator::GetPackagingInstallPrefix()
+const char* cmCPackIFWGenerator::GetPackagingInstallPrefix()
{
- const char *defPrefix = cmCPackGenerator::GetPackagingInstallPrefix();
+ const char* defPrefix = cmCPackGenerator::GetPackagingInstallPrefix();
std::string tmpPref = defPrefix ? defPrefix : "";
- if(this->Components.empty())
- {
+ if (this->Components.empty()) {
tmpPref += "packages/" + GetRootPackageName() + "/data";
- }
+ }
this->SetOption("CPACK_IFW_PACKAGING_INSTALL_PREFIX", tmpPref.c_str());
return this->GetOption("CPACK_IFW_PACKAGING_INSTALL_PREFIX");
}
-const char *cmCPackIFWGenerator::GetOutputExtension()
+const char* cmCPackIFWGenerator::GetOutputExtension()
{
return ExecutableSuffix.c_str();
}
@@ -246,56 +219,43 @@ int cmCPackIFWGenerator::InitializeInternal()
const std::string RepoGenOpt = "CPACK_IFW_REPOGEN_EXECUTABLE";
const std::string FrameworkVersionOpt = "CPACK_IFW_FRAMEWORK_VERSION";
- if(!this->IsSet(BinCreatorOpt) ||
- !this->IsSet(RepoGenOpt) ||
- !this->IsSet(FrameworkVersionOpt))
- {
+ if (!this->IsSet(BinCreatorOpt) || !this->IsSet(RepoGenOpt) ||
+ !this->IsSet(FrameworkVersionOpt)) {
this->ReadListFile("CPackIFW.cmake");
- }
+ }
// Look 'binarycreator' executable (needs)
- const char *BinCreatorStr = this->GetOption(BinCreatorOpt);
- if(!BinCreatorStr || cmSystemTools::IsNOTFOUND(BinCreatorStr))
- {
+ const char* BinCreatorStr = this->GetOption(BinCreatorOpt);
+ if (!BinCreatorStr || cmSystemTools::IsNOTFOUND(BinCreatorStr)) {
BinCreator = "";
- }
- else
- {
+ } else {
BinCreator = BinCreatorStr;
- }
+ }
- if (BinCreator.empty())
- {
+ if (BinCreator.empty()) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Cannot find QtIFW compiler \"binarycreator\": "
"likely it is not installed, or not in your PATH"
- << std::endl);
+ << std::endl);
return 0;
- }
+ }
// Look 'repogen' executable (optional)
- const char *RepoGenStr = this->GetOption(RepoGenOpt);
- if(!RepoGenStr || cmSystemTools::IsNOTFOUND(RepoGenStr))
- {
+ const char* RepoGenStr = this->GetOption(RepoGenOpt);
+ if (!RepoGenStr || cmSystemTools::IsNOTFOUND(RepoGenStr)) {
RepoGen = "";
- }
- else
- {
+ } else {
RepoGen = RepoGenStr;
- }
+ }
// Framework version
- if(const char* FrameworkVersionSrt =
- this->GetOption(FrameworkVersionOpt))
- {
+ if (const char* FrameworkVersionSrt = this->GetOption(FrameworkVersionOpt)) {
FrameworkVersion = FrameworkVersionSrt;
- }
- else
- {
+ } else {
FrameworkVersion = "1.9.9";
- }
+ }
// Variables that Change Behavior
@@ -304,158 +264,130 @@ int cmCPackIFWGenerator::InitializeInternal()
// Additional packages dirs
PkgsDirsVector.clear();
- if(const char* dirs = this->GetOption("CPACK_IFW_PACKAGES_DIRECTORIES"))
- {
- cmSystemTools::ExpandListArgument(dirs,
- PkgsDirsVector);
- }
+ if (const char* dirs = this->GetOption("CPACK_IFW_PACKAGES_DIRECTORIES")) {
+ cmSystemTools::ExpandListArgument(dirs, PkgsDirsVector);
+ }
// Installer
Installer.Generator = this;
Installer.ConfigureFromOptions();
- if (const char* ifwDownloadAll =
- this->GetOption("CPACK_IFW_DOWNLOAD_ALL"))
- {
+ if (const char* ifwDownloadAll = this->GetOption("CPACK_IFW_DOWNLOAD_ALL")) {
OnlineOnly = cmSystemTools::IsOn(ifwDownloadAll);
- }
- else if (const char* cpackDownloadAll =
- this->GetOption("CPACK_DOWNLOAD_ALL"))
- {
+ } else if (const char* cpackDownloadAll =
+ this->GetOption("CPACK_DOWNLOAD_ALL")) {
OnlineOnly = cmSystemTools::IsOn(cpackDownloadAll);
- }
- else
- {
+ } else {
OnlineOnly = false;
- }
+ }
if (!Installer.Repositories.empty() && RepoGen.empty()) {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Cannot find QtIFW repository generator \"repogen\": "
- "likely it is not installed, or not in your PATH"
- << std::endl);
- return 0;
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Cannot find QtIFW repository generator \"repogen\": "
+ "likely it is not installed, or not in your PATH"
+ << std::endl);
+ return 0;
}
// Executable suffix
- if(const char *optExeSuffix = this->GetOption("CMAKE_EXECUTABLE_SUFFIX"))
- {
+ if (const char* optExeSuffix = this->GetOption("CMAKE_EXECUTABLE_SUFFIX")) {
ExecutableSuffix = optExeSuffix;
- if(ExecutableSuffix.empty())
- {
+ if (ExecutableSuffix.empty()) {
std::string sysName(this->GetOption("CMAKE_SYSTEM_NAME"));
- if(sysName == "Linux")
- {
+ if (sysName == "Linux") {
ExecutableSuffix = ".run";
- }
}
}
- else
- {
+ } else {
ExecutableSuffix = cmCPackGenerator::GetOutputExtension();
- }
+ }
return this->Superclass::InitializeInternal();
}
-std::string
-cmCPackIFWGenerator::GetComponentInstallDirNameSuffix(
+std::string cmCPackIFWGenerator::GetComponentInstallDirNameSuffix(
const std::string& componentName)
{
const std::string prefix = "packages/";
const std::string suffix = "/data";
if (componentPackageMethod == ONE_PACKAGE) {
- return std::string(prefix + GetRootPackageName() + suffix);
+ return std::string(prefix + GetRootPackageName() + suffix);
}
- return prefix
- + GetComponentPackageName(&Components[componentName])
- + suffix;
+ return prefix + GetComponentPackageName(&Components[componentName]) + suffix;
}
-cmCPackComponent*
-cmCPackIFWGenerator::GetComponent(const std::string &projectName,
- const std::string &componentName)
+cmCPackComponent* cmCPackIFWGenerator::GetComponent(
+ const std::string& projectName, const std::string& componentName)
{
ComponentsMap::iterator cit = Components.find(componentName);
- if ( cit != Components.end() ) return &(cit->second);
+ if (cit != Components.end())
+ return &(cit->second);
- cmCPackComponent* component
- = cmCPackGenerator::GetComponent(projectName, componentName);
- if(!component) return component;
+ cmCPackComponent* component =
+ cmCPackGenerator::GetComponent(projectName, componentName);
+ if (!component)
+ return component;
std::string name = GetComponentPackageName(component);
PackagesMap::iterator pit = Packages.find(name);
- if(pit != Packages.end()) return component;
+ if (pit != Packages.end())
+ return component;
- cmCPackIFWPackage *package = &Packages[name];
+ cmCPackIFWPackage* package = &Packages[name];
package->Name = name;
package->Generator = this;
- if(package->ConfigureFromComponent(component))
- {
+ if (package->ConfigureFromComponent(component)) {
package->Installer = &Installer;
Installer.Packages.insert(
- std::pair<std::string, cmCPackIFWPackage*>(
- name, package));
+ std::pair<std::string, cmCPackIFWPackage*>(name, package));
ComponentPackages.insert(
- std::pair<cmCPackComponent*, cmCPackIFWPackage*>(
- component, package));
- if(component->IsDownloaded)
- {
+ std::pair<cmCPackComponent*, cmCPackIFWPackage*>(component, package));
+ if (component->IsDownloaded) {
DownloadedPackages.insert(package);
- }
- else
- {
+ } else {
BinaryPackages.insert(package);
- }
}
- else
- {
+ } else {
Packages.erase(name);
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Cannot configure package \"" << name <<
- "\" for component \"" << component->Name << "\""
- << std::endl);
- }
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot configure package \""
+ << name << "\" for component \"" << component->Name << "\""
+ << std::endl);
+ }
return component;
}
-cmCPackComponentGroup*
-cmCPackIFWGenerator::GetComponentGroup(const std::string &projectName,
- const std::string &groupName)
+cmCPackComponentGroup* cmCPackIFWGenerator::GetComponentGroup(
+ const std::string& projectName, const std::string& groupName)
{
- cmCPackComponentGroup* group
- = cmCPackGenerator::GetComponentGroup(projectName, groupName);
- if(!group) return group;
+ cmCPackComponentGroup* group =
+ cmCPackGenerator::GetComponentGroup(projectName, groupName);
+ if (!group)
+ return group;
std::string name = GetGroupPackageName(group);
PackagesMap::iterator pit = Packages.find(name);
- if(pit != Packages.end()) return group;
+ if (pit != Packages.end())
+ return group;
- cmCPackIFWPackage *package = &Packages[name];
+ cmCPackIFWPackage* package = &Packages[name];
package->Name = name;
package->Generator = this;
- if(package->ConfigureFromGroup(group))
- {
+ if (package->ConfigureFromGroup(group)) {
package->Installer = &Installer;
Installer.Packages.insert(
- std::pair<std::string, cmCPackIFWPackage*>(
- name, package));
+ std::pair<std::string, cmCPackIFWPackage*>(name, package));
GroupPackages.insert(
- std::pair<cmCPackComponentGroup*, cmCPackIFWPackage*>(
- group, package));
+ std::pair<cmCPackComponentGroup*, cmCPackIFWPackage*>(group, package));
BinaryPackages.insert(package);
- }
- else
- {
+ } else {
Packages.erase(name);
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Cannot configure package \"" << name <<
- "\" for component group \"" << group->Name << "\""
- << std::endl);
- }
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot configure package \""
+ << name << "\" for component group \"" << group->Name
+ << "\"" << std::endl);
+ }
return group;
}
@@ -485,123 +417,106 @@ std::string cmCPackIFWGenerator::GetRootPackageName()
// Default value
std::string name = "root";
if (const char* optIFW_PACKAGE_GROUP =
- this->GetOption("CPACK_IFW_PACKAGE_GROUP"))
- {
+ this->GetOption("CPACK_IFW_PACKAGE_GROUP")) {
// Configure from root group
cmCPackIFWPackage package;
package.Generator = this;
package.ConfigureFromGroup(optIFW_PACKAGE_GROUP);
name = package.Name;
- }
- else if (const char* optIFW_PACKAGE_NAME =
- this->GetOption("CPACK_IFW_PACKAGE_NAME"))
- {
+ } else if (const char* optIFW_PACKAGE_NAME =
+ this->GetOption("CPACK_IFW_PACKAGE_NAME")) {
// Configure from root package name
name = optIFW_PACKAGE_NAME;
- }
- else if (const char* optPACKAGE_NAME =
- this->GetOption("CPACK_PACKAGE_NAME"))
- {
+ } else if (const char* optPACKAGE_NAME =
+ this->GetOption("CPACK_PACKAGE_NAME")) {
// Configure from package name
name = optPACKAGE_NAME;
- }
+ }
return name;
}
-std::string
-cmCPackIFWGenerator::GetGroupPackageName(cmCPackComponentGroup *group) const
+std::string cmCPackIFWGenerator::GetGroupPackageName(
+ cmCPackComponentGroup* group) const
{
std::string name;
- if (!group) return name;
- if (cmCPackIFWPackage* package = GetGroupPackage(group))
- {
+ if (!group)
+ return name;
+ if (cmCPackIFWPackage* package = GetGroupPackage(group)) {
return package->Name;
- }
- const char* option = GetOption(
- "CPACK_IFW_COMPONENT_GROUP_"
- + cmsys::SystemTools::UpperCase(group->Name)
- + "_NAME");
+ }
+ const char* option =
+ GetOption("CPACK_IFW_COMPONENT_GROUP_" +
+ cmsys::SystemTools::UpperCase(group->Name) + "_NAME");
name = option ? option : group->Name;
- if(group->ParentGroup)
- {
+ if (group->ParentGroup) {
cmCPackIFWPackage* package = GetGroupPackage(group->ParentGroup);
bool dot = !ResolveDuplicateNames;
- if(dot && name.substr(0, package->Name.size()) == package->Name)
- {
+ if (dot && name.substr(0, package->Name.size()) == package->Name) {
dot = false;
- }
- if(dot)
- {
+ }
+ if (dot) {
name = package->Name + "." + name;
- }
}
+ }
return name;
}
std::string cmCPackIFWGenerator::GetComponentPackageName(
- cmCPackComponent *component) const
+ cmCPackComponent* component) const
{
std::string name;
- if (!component) return name;
- if (cmCPackIFWPackage* package = GetComponentPackage(component))
- {
+ if (!component)
+ return name;
+ if (cmCPackIFWPackage* package = GetComponentPackage(component)) {
return package->Name;
- }
- std::string prefix = "CPACK_IFW_COMPONENT_"
- + cmsys::SystemTools::UpperCase(component->Name)
- + "_";
+ }
+ std::string prefix = "CPACK_IFW_COMPONENT_" +
+ cmsys::SystemTools::UpperCase(component->Name) + "_";
const char* option = GetOption(prefix + "NAME");
name = option ? option : component->Name;
- if(component->Group)
- {
+ if (component->Group) {
cmCPackIFWPackage* package = GetGroupPackage(component->Group);
- if((componentPackageMethod == ONE_PACKAGE_PER_GROUP)
- || IsOn(prefix + "COMMON"))
- {
+ if ((componentPackageMethod == ONE_PACKAGE_PER_GROUP) ||
+ IsOn(prefix + "COMMON")) {
return package->Name;
- }
+ }
bool dot = !ResolveDuplicateNames;
- if(dot && name.substr(0, package->Name.size()) == package->Name)
- {
+ if (dot && name.substr(0, package->Name.size()) == package->Name) {
dot = false;
- }
- if(dot)
- {
+ }
+ if (dot) {
name = package->Name + "." + name;
- }
}
+ }
return name;
}
cmCPackIFWPackage* cmCPackIFWGenerator::GetGroupPackage(
- cmCPackComponentGroup *group) const
+ cmCPackComponentGroup* group) const
{
- std::map<cmCPackComponentGroup*, cmCPackIFWPackage*>::const_iterator pit
- = GroupPackages.find(group);
+ std::map<cmCPackComponentGroup*, cmCPackIFWPackage*>::const_iterator pit =
+ GroupPackages.find(group);
return pit != GroupPackages.end() ? pit->second : 0;
}
cmCPackIFWPackage* cmCPackIFWGenerator::GetComponentPackage(
- cmCPackComponent *component) const
+ cmCPackComponent* component) const
{
- std::map<cmCPackComponent*, cmCPackIFWPackage*>::const_iterator pit
- = ComponentPackages.find(component);
+ std::map<cmCPackComponent*, cmCPackIFWPackage*>::const_iterator pit =
+ ComponentPackages.find(component);
return pit != ComponentPackages.end() ? pit->second : 0;
}
-void cmCPackIFWGenerator::WriteGeneratedByToStrim(cmXMLWriter &xout)
+void cmCPackIFWGenerator::WriteGeneratedByToStrim(cmXMLWriter& xout)
{
std::stringstream comment;
comment << "Generated by CPack " << CMake_VERSION << " IFW generator "
- << "for QtIFW ";
- if(IsVersionLess("2.0"))
- {
+ << "for QtIFW ";
+ if (IsVersionLess("2.0")) {
comment << "less 2.0";
- }
- else
- {
+ } else {
comment << FrameworkVersion;
- }
+ }
comment << " tools at " << cmTimestamp().CurrentTime("", true);
xout.Comment(comment.str().c_str());
}
diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.h b/Source/CPack/IFW/cmCPackIFWGenerator.h
index d02f9d2..d8cc562 100644
--- a/Source/CPack/IFW/cmCPackIFWGenerator.h
+++ b/Source/CPack/IFW/cmCPackIFWGenerator.h
@@ -49,17 +49,17 @@ public:
/**
* Compare \a version with QtIFW framework version
*/
- bool IsVersionLess(const char *version);
+ bool IsVersionLess(const char* version);
/**
* Compare \a version with QtIFW framework version
*/
- bool IsVersionGreater(const char *version);
+ bool IsVersionGreater(const char* version);
/**
* Compare \a version with QtIFW framework version
*/
- bool IsVersionEqual(const char *version);
+ bool IsVersionEqual(const char* version);
protected:
// cmCPackGenerator reimplementation
@@ -90,9 +90,8 @@ protected:
*
* @return Pointer to component
*/
- virtual cmCPackComponent* GetComponent(
- const std::string& projectName,
- const std::string& componentName);
+ virtual cmCPackComponent* GetComponent(const std::string& projectName,
+ const std::string& componentName);
/**
* @brief Get group of component
@@ -104,8 +103,7 @@ protected:
* @return Pointer to component group
*/
virtual cmCPackComponentGroup* GetComponentGroup(
- const std::string& projectName,
- const std::string& groupName);
+ const std::string& projectName, const std::string& groupName);
enum cmCPackGenerator::CPackSetDestdirSupport SupportsSetDestdir() const;
virtual bool SupportsAbsoluteDestination() const;
@@ -118,11 +116,11 @@ protected:
std::string GetRootPackageName();
- std::string GetGroupPackageName(cmCPackComponentGroup *group) const;
- std::string GetComponentPackageName(cmCPackComponent *component) const;
+ std::string GetGroupPackageName(cmCPackComponentGroup* group) const;
+ std::string GetComponentPackageName(cmCPackComponent* component) const;
- cmCPackIFWPackage* GetGroupPackage(cmCPackComponentGroup *group) const;
- cmCPackIFWPackage* GetComponentPackage(cmCPackComponent *component) const;
+ cmCPackIFWPackage* GetGroupPackage(cmCPackComponentGroup* group) const;
+ cmCPackIFWPackage* GetComponentPackage(cmCPackComponent* component) const;
void WriteGeneratedByToStrim(cmXMLWriter& xout);
diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.cxx b/Source/CPack/IFW/cmCPackIFWInstaller.cxx
index dfb336c..b9a9861 100644
--- a/Source/CPack/IFW/cmCPackIFWInstaller.cxx
+++ b/Source/CPack/IFW/cmCPackIFWInstaller.cxx
@@ -20,310 +20,239 @@
#include <cmXMLWriter.h>
#ifdef cmCPackLogger
-# undef cmCPackLogger
+#undef cmCPackLogger
#endif
-#define cmCPackLogger(logType, msg) \
- do { \
- std::ostringstream cmCPackLog_msg; \
- cmCPackLog_msg << msg; \
- if(Generator) { \
- Generator->Logger->Log(logType, __FILE__, __LINE__, \
- cmCPackLog_msg.str().c_str()); \
- } \
- } while ( 0 )
-
-cmCPackIFWInstaller::cmCPackIFWInstaller() :
- Generator(0)
+#define cmCPackLogger(logType, msg) \
+ do { \
+ std::ostringstream cmCPackLog_msg; \
+ cmCPackLog_msg << msg; \
+ if (Generator) { \
+ Generator->Logger->Log(logType, __FILE__, __LINE__, \
+ cmCPackLog_msg.str().c_str()); \
+ } \
+ } while (0)
+
+cmCPackIFWInstaller::cmCPackIFWInstaller()
+ : Generator(0)
{
}
-const char *cmCPackIFWInstaller::GetOption(const std::string &op) const
+const char* cmCPackIFWInstaller::GetOption(const std::string& op) const
{
return Generator ? Generator->GetOption(op) : 0;
}
-bool cmCPackIFWInstaller::IsOn(const std::string &op) const
+bool cmCPackIFWInstaller::IsOn(const std::string& op) const
{
return Generator ? Generator->IsOn(op) : false;
}
-bool cmCPackIFWInstaller::IsVersionLess(const char *version)
+bool cmCPackIFWInstaller::IsVersionLess(const char* version)
{
return Generator ? Generator->IsVersionLess(version) : false;
}
-bool cmCPackIFWInstaller::IsVersionGreater(const char *version)
+bool cmCPackIFWInstaller::IsVersionGreater(const char* version)
{
return Generator ? Generator->IsVersionGreater(version) : false;
}
-bool cmCPackIFWInstaller::IsVersionEqual(const char *version)
+bool cmCPackIFWInstaller::IsVersionEqual(const char* version)
{
return Generator ? Generator->IsVersionEqual(version) : false;
}
-
void cmCPackIFWInstaller::ConfigureFromOptions()
{
// Name;
if (const char* optIFW_PACKAGE_NAME =
- this->GetOption("CPACK_IFW_PACKAGE_NAME"))
- {
+ this->GetOption("CPACK_IFW_PACKAGE_NAME")) {
Name = optIFW_PACKAGE_NAME;
- }
- else if (const char* optPACKAGE_NAME =
- this->GetOption("CPACK_PACKAGE_NAME"))
- {
+ } else if (const char* optPACKAGE_NAME =
+ this->GetOption("CPACK_PACKAGE_NAME")) {
Name = optPACKAGE_NAME;
- }
- else
- {
+ } else {
Name = "Your package";
- }
+ }
// Title;
if (const char* optIFW_PACKAGE_TITLE =
- GetOption("CPACK_IFW_PACKAGE_TITLE"))
- {
+ GetOption("CPACK_IFW_PACKAGE_TITLE")) {
Title = optIFW_PACKAGE_TITLE;
- }
- else if (const char* optPACKAGE_DESCRIPTION_SUMMARY =
- GetOption("CPACK_PACKAGE_DESCRIPTION_SUMMARY"))
- {
+ } else if (const char* optPACKAGE_DESCRIPTION_SUMMARY =
+ GetOption("CPACK_PACKAGE_DESCRIPTION_SUMMARY")) {
Title = optPACKAGE_DESCRIPTION_SUMMARY;
- }
- else
- {
+ } else {
Title = "Your package description";
- }
+ }
// Version;
- if (const char* option = GetOption("CPACK_PACKAGE_VERSION"))
- {
+ if (const char* option = GetOption("CPACK_PACKAGE_VERSION")) {
Version = option;
- }
- else
- {
+ } else {
Version = "1.0.0";
- }
+ }
// Publisher
- if(const char* optIFW_PACKAGE_PUBLISHER =
- GetOption("CPACK_IFW_PACKAGE_PUBLISHER"))
- {
+ if (const char* optIFW_PACKAGE_PUBLISHER =
+ GetOption("CPACK_IFW_PACKAGE_PUBLISHER")) {
Publisher = optIFW_PACKAGE_PUBLISHER;
- }
- else if(const char* optPACKAGE_VENDOR = GetOption("CPACK_PACKAGE_VENDOR"))
- {
+ } else if (const char* optPACKAGE_VENDOR =
+ GetOption("CPACK_PACKAGE_VENDOR")) {
Publisher = optPACKAGE_VENDOR;
- }
+ }
// ProductUrl
- if(const char* option = GetOption("CPACK_IFW_PRODUCT_URL"))
- {
+ if (const char* option = GetOption("CPACK_IFW_PRODUCT_URL")) {
ProductUrl = option;
- }
+ }
// ApplicationIcon
- if(const char* option = GetOption("CPACK_IFW_PACKAGE_ICON"))
- {
- if(cmSystemTools::FileExists(option))
- {
+ if (const char* option = GetOption("CPACK_IFW_PACKAGE_ICON")) {
+ if (cmSystemTools::FileExists(option)) {
InstallerApplicationIcon = option;
- }
- else
- {
+ } else {
// TODO: implement warning
- }
}
+ }
// WindowIcon
- if(const char* option = GetOption("CPACK_IFW_PACKAGE_WINDOW_ICON"))
- {
- if(cmSystemTools::FileExists(option))
- {
+ if (const char* option = GetOption("CPACK_IFW_PACKAGE_WINDOW_ICON")) {
+ if (cmSystemTools::FileExists(option)) {
InstallerWindowIcon = option;
- }
- else
- {
+ } else {
// TODO: implement warning
- }
}
+ }
// Logo
- if(const char* option = GetOption("CPACK_IFW_PACKAGE_LOGO"))
- {
- if(cmSystemTools::FileExists(option))
- {
+ if (const char* option = GetOption("CPACK_IFW_PACKAGE_LOGO")) {
+ if (cmSystemTools::FileExists(option)) {
Logo = option;
- }
- else
- {
+ } else {
// TODO: implement warning
- }
}
+ }
// Start menu
if (const char* optIFW_START_MENU_DIR =
- this->GetOption("CPACK_IFW_PACKAGE_START_MENU_DIRECTORY"))
- {
+ this->GetOption("CPACK_IFW_PACKAGE_START_MENU_DIRECTORY")) {
StartMenuDir = optIFW_START_MENU_DIR;
- }
- else
- {
+ } else {
StartMenuDir = Name;
- }
+ }
// Default target directory for installation
if (const char* optIFW_TARGET_DIRECTORY =
- GetOption("CPACK_IFW_TARGET_DIRECTORY"))
- {
+ GetOption("CPACK_IFW_TARGET_DIRECTORY")) {
TargetDir = optIFW_TARGET_DIRECTORY;
- }
- else if (const char *optPACKAGE_INSTALL_DIRECTORY =
- GetOption("CPACK_PACKAGE_INSTALL_DIRECTORY"))
- {
+ } else if (const char* optPACKAGE_INSTALL_DIRECTORY =
+ GetOption("CPACK_PACKAGE_INSTALL_DIRECTORY")) {
TargetDir = "@ApplicationsDir@/";
TargetDir += optPACKAGE_INSTALL_DIRECTORY;
- }
- else
- {
+ } else {
TargetDir = "@RootDir@/usr/local";
- }
+ }
// Default target directory for installation with administrator rights
- if (const char* option = GetOption("CPACK_IFW_ADMIN_TARGET_DIRECTORY"))
- {
+ if (const char* option = GetOption("CPACK_IFW_ADMIN_TARGET_DIRECTORY")) {
AdminTargetDir = option;
- }
+ }
// Repositories
Repositories.clear();
RepositoryStruct Repo;
- if(const char *site = this->GetOption("CPACK_DOWNLOAD_SITE"))
- {
+ if (const char* site = this->GetOption("CPACK_DOWNLOAD_SITE")) {
Repo.Url = site;
Repositories.push_back(Repo);
- }
- if(const char *RepoAllStr = this->GetOption("CPACK_IFW_REPOSITORIES_ALL"))
- {
+ }
+ if (const char* RepoAllStr = this->GetOption("CPACK_IFW_REPOSITORIES_ALL")) {
std::vector<std::string> RepoAllVector;
- cmSystemTools::ExpandListArgument(RepoAllStr,
- RepoAllVector);
- for(std::vector<std::string>::iterator
- rit = RepoAllVector.begin(); rit != RepoAllVector.end(); ++rit)
- {
- std::string prefix = "CPACK_IFW_REPOSITORY_"
- + cmsys::SystemTools::UpperCase(*rit)
- + "_";
- // Url
- if (const char* url = GetOption(prefix + "URL"))
- {
- Repo.Url = url;
- }
- else
- {
- Repo.Url = "";
- }
- // Enabled
- if (IsOn(prefix + "DISABLED"))
- {
- Repo.Enabled = "0";
- }
- else
- {
- Repo.Enabled = "";
- }
- // Username
- if (const char* username = GetOption(prefix + "USERNAME"))
- {
- Repo.Username = username;
- }
- else
- {
- Repo.Username = "";
- }
- // Password
- if (const char* password = GetOption(prefix + "PASSWORD"))
- {
- Repo.Password = password;
- }
- else
- {
- Repo.Password = "";
- }
- // DisplayName
- if (const char* displayName = GetOption(prefix + "DISPLAY_NAME"))
- {
- Repo.DisplayName = displayName;
- }
- else
- {
- Repo.DisplayName = "";
- }
-
- if(!Repo.Url.empty())
- {
- Repositories.push_back(Repo);
- }
+ cmSystemTools::ExpandListArgument(RepoAllStr, RepoAllVector);
+ for (std::vector<std::string>::iterator rit = RepoAllVector.begin();
+ rit != RepoAllVector.end(); ++rit) {
+ std::string prefix =
+ "CPACK_IFW_REPOSITORY_" + cmsys::SystemTools::UpperCase(*rit) + "_";
+ // Url
+ if (const char* url = GetOption(prefix + "URL")) {
+ Repo.Url = url;
+ } else {
+ Repo.Url = "";
+ }
+ // Enabled
+ if (IsOn(prefix + "DISABLED")) {
+ Repo.Enabled = "0";
+ } else {
+ Repo.Enabled = "";
+ }
+ // Username
+ if (const char* username = GetOption(prefix + "USERNAME")) {
+ Repo.Username = username;
+ } else {
+ Repo.Username = "";
+ }
+ // Password
+ if (const char* password = GetOption(prefix + "PASSWORD")) {
+ Repo.Password = password;
+ } else {
+ Repo.Password = "";
+ }
+ // DisplayName
+ if (const char* displayName = GetOption(prefix + "DISPLAY_NAME")) {
+ Repo.DisplayName = displayName;
+ } else {
+ Repo.DisplayName = "";
+ }
+
+ if (!Repo.Url.empty()) {
+ Repositories.push_back(Repo);
}
}
+ }
// Maintenance tool
- if(const char* optIFW_MAINTENANCE_TOOL =
- this->GetOption("CPACK_IFW_PACKAGE_MAINTENANCE_TOOL_NAME"))
- {
+ if (const char* optIFW_MAINTENANCE_TOOL =
+ this->GetOption("CPACK_IFW_PACKAGE_MAINTENANCE_TOOL_NAME")) {
MaintenanceToolName = optIFW_MAINTENANCE_TOOL;
- }
+ }
// Maintenance tool ini file
- if(const char* optIFW_MAINTENANCE_TOOL_INI =
- this->GetOption("CPACK_IFW_PACKAGE_MAINTENANCE_TOOL_INI_FILE"))
- {
+ if (const char* optIFW_MAINTENANCE_TOOL_INI =
+ this->GetOption("CPACK_IFW_PACKAGE_MAINTENANCE_TOOL_INI_FILE")) {
MaintenanceToolIniFile = optIFW_MAINTENANCE_TOOL_INI;
- }
+ }
// Allow non-ASCII characters
- if(this->GetOption("CPACK_IFW_PACKAGE_ALLOW_NON_ASCII_CHARACTERS"))
- {
- if(IsOn("CPACK_IFW_PACKAGE_ALLOW_NON_ASCII_CHARACTERS"))
- {
+ if (this->GetOption("CPACK_IFW_PACKAGE_ALLOW_NON_ASCII_CHARACTERS")) {
+ if (IsOn("CPACK_IFW_PACKAGE_ALLOW_NON_ASCII_CHARACTERS")) {
AllowNonAsciiCharacters = "true";
- }
- else
- {
+ } else {
AllowNonAsciiCharacters = "false";
- }
}
+ }
// Space in path
- if(this->GetOption("CPACK_IFW_PACKAGE_ALLOW_SPACE_IN_PATH"))
- {
- if(IsOn("CPACK_IFW_PACKAGE_ALLOW_SPACE_IN_PATH"))
- {
+ if (this->GetOption("CPACK_IFW_PACKAGE_ALLOW_SPACE_IN_PATH")) {
+ if (IsOn("CPACK_IFW_PACKAGE_ALLOW_SPACE_IN_PATH")) {
AllowSpaceInPath = "true";
- }
- else
- {
+ } else {
AllowSpaceInPath = "false";
- }
}
+ }
// Control script
- if(const char* optIFW_CONTROL_SCRIPT =
- this->GetOption("CPACK_IFW_PACKAGE_CONTROL_SCRIPT"))
- {
+ if (const char* optIFW_CONTROL_SCRIPT =
+ this->GetOption("CPACK_IFW_PACKAGE_CONTROL_SCRIPT")) {
ControlScript = optIFW_CONTROL_SCRIPT;
- }
+ }
}
void cmCPackIFWInstaller::GenerateInstallerFile()
{
// Lazy directory initialization
- if(Directory.empty() && Generator)
- {
+ if (Directory.empty() && Generator) {
Directory = Generator->toplevel;
- }
+ }
// Output stream
cmGeneratedFileStream fout((Directory + "/config/config.xml").data());
@@ -339,140 +268,118 @@ void cmCPackIFWInstaller::GenerateInstallerFile()
xout.Element("Version", Version);
xout.Element("Title", Title);
- if(!Publisher.empty())
- {
+ if (!Publisher.empty()) {
xout.Element("Publisher", Publisher);
- }
+ }
- if(!ProductUrl.empty())
- {
+ if (!ProductUrl.empty()) {
xout.Element("ProductUrl", ProductUrl);
- }
+ }
// ApplicationIcon
- if(!InstallerApplicationIcon.empty())
- {
+ if (!InstallerApplicationIcon.empty()) {
std::string name =
cmSystemTools::GetFilenameName(InstallerApplicationIcon);
std::string path = Directory + "/config/" + name;
name = cmSystemTools::GetFilenameWithoutExtension(name);
- cmsys::SystemTools::CopyFileIfDifferent(
- InstallerApplicationIcon.data(), path.data());
+ cmsys::SystemTools::CopyFileIfDifferent(InstallerApplicationIcon.data(),
+ path.data());
xout.Element("InstallerApplicationIcon", name);
- }
+ }
// WindowIcon
- if(!InstallerWindowIcon.empty())
- {
+ 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.data(),
+ path.data());
xout.Element("InstallerWindowIcon", name);
- }
+ }
// Logo
- if(!Logo.empty())
- {
+ if (!Logo.empty()) {
std::string name = cmSystemTools::GetFilenameName(Logo);
std::string path = Directory + "/config/" + name;
cmsys::SystemTools::CopyFileIfDifferent(Logo.data(), path.data());
xout.Element("Logo", name);
- }
+ }
// Start menu
- if(!IsVersionLess("2.0"))
- {
+ if (!IsVersionLess("2.0")) {
xout.Element("StartMenuDir", StartMenuDir);
- }
+ }
// Target dir
- if(!TargetDir.empty())
- {
+ if (!TargetDir.empty()) {
xout.Element("TargetDir", TargetDir);
- }
+ }
// Admin target dir
- if(!AdminTargetDir.empty())
- {
+ if (!AdminTargetDir.empty()) {
xout.Element("AdminTargetDir", AdminTargetDir);
- }
+ }
// Remote repositories
- if (!Repositories.empty())
- {
+ if (!Repositories.empty()) {
xout.StartElement("RemoteRepositories");
- for(std::vector<RepositoryStruct>::iterator
- rit = Repositories.begin(); rit != Repositories.end(); ++rit)
- {
+ for (std::vector<RepositoryStruct>::iterator rit = Repositories.begin();
+ rit != Repositories.end(); ++rit) {
xout.StartElement("Repository");
// Url
xout.Element("Url", rit->Url);
// Enabled
- if(!rit->Enabled.empty())
- {
+ if (!rit->Enabled.empty()) {
xout.Element("Enabled", rit->Enabled);
- }
+ }
// Username
- if(!rit->Username.empty())
- {
+ if (!rit->Username.empty()) {
xout.Element("Username", rit->Username);
- }
+ }
// Password
- if(!rit->Password.empty())
- {
+ if (!rit->Password.empty()) {
xout.Element("Password", rit->Password);
- }
+ }
// DisplayName
- if(!rit->DisplayName.empty())
- {
+ if (!rit->DisplayName.empty()) {
xout.Element("DisplayName", rit->DisplayName);
- }
- xout.EndElement();
}
- xout.EndElement();
+ xout.EndElement();
}
+ xout.EndElement();
+ }
// Maintenance tool
- if(!IsVersionLess("2.0") && !MaintenanceToolName.empty())
- {
+ if (!IsVersionLess("2.0") && !MaintenanceToolName.empty()) {
xout.Element("MaintenanceToolName", MaintenanceToolName);
- }
+ }
// Maintenance tool ini file
- if(!IsVersionLess("2.0") && !MaintenanceToolIniFile.empty())
- {
+ if (!IsVersionLess("2.0") && !MaintenanceToolIniFile.empty()) {
xout.Element("MaintenanceToolIniFile", MaintenanceToolIniFile);
- }
+ }
// Different allows
- if(IsVersionLess("2.0"))
- {
+ if (IsVersionLess("2.0")) {
// CPack IFW default policy
xout.Comment("CPack IFW default policy for QtIFW less 2.0");
xout.Element("AllowNonAsciiCharacters", "true");
xout.Element("AllowSpaceInPath", "true");
+ } else {
+ if (!AllowNonAsciiCharacters.empty()) {
+ xout.Element("AllowNonAsciiCharacters", AllowNonAsciiCharacters);
}
- else
- {
- if(!AllowNonAsciiCharacters.empty())
- {
- xout.Element("AllowNonAsciiCharacters", AllowNonAsciiCharacters);
- }
- if(!AllowSpaceInPath.empty())
- {
- xout.Element("AllowSpaceInPath", AllowSpaceInPath);
- }
+ if (!AllowSpaceInPath.empty()) {
+ xout.Element("AllowSpaceInPath", AllowSpaceInPath);
}
+ }
// Control script (copy to config dir)
- if(!IsVersionLess("2.0") && !ControlScript.empty())
- {
+ 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());
xout.Element("ControlScript", name);
- }
+ }
xout.EndElement();
xout.EndDocument();
@@ -480,36 +387,32 @@ void cmCPackIFWInstaller::GenerateInstallerFile()
void cmCPackIFWInstaller::GeneratePackageFiles()
{
- if (Packages.empty() || Generator->IsOnePackage())
- {
+ if (Packages.empty() || Generator->IsOnePackage()) {
// Generate default package
cmCPackIFWPackage package;
package.Generator = Generator;
package.Installer = this;
// Check package group
- if (const char* option = GetOption("CPACK_IFW_PACKAGE_GROUP"))
- {
+ if (const char* option = GetOption("CPACK_IFW_PACKAGE_GROUP")) {
package.ConfigureFromGroup(option);
package.ForcedInstallation = "true";
- }
- else
- {
+ } else {
package.ConfigureFromOptions();
- }
+ }
package.GeneratePackageFile();
return;
- }
+ }
// Generate packages meta information
- for(PackagesMap::iterator pit = Packages.begin();
- pit != Packages.end(); ++pit)
- {
+ for (PackagesMap::iterator pit = Packages.begin(); pit != Packages.end();
+ ++pit) {
cmCPackIFWPackage* package = pit->second;
package->GeneratePackageFile();
}
}
-void cmCPackIFWInstaller::WriteGeneratedByToStrim(cmXMLWriter &xout)
+void cmCPackIFWInstaller::WriteGeneratedByToStrim(cmXMLWriter& xout)
{
- if(Generator) Generator->WriteGeneratedByToStrim(xout);
+ if (Generator)
+ Generator->WriteGeneratedByToStrim(xout);
}
diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.h b/Source/CPack/IFW/cmCPackIFWInstaller.h
index 9cb7d5b..84a789e 100644
--- a/Source/CPack/IFW/cmCPackIFWInstaller.h
+++ b/Source/CPack/IFW/cmCPackIFWInstaller.h
@@ -103,9 +103,9 @@ public:
const char* GetOption(const std::string& op) const;
bool IsOn(const std::string& op) const;
- bool IsVersionLess(const char *version);
- bool IsVersionGreater(const char *version);
- bool IsVersionEqual(const char *version);
+ bool IsVersionLess(const char* version);
+ bool IsVersionGreater(const char* version);
+ bool IsVersionEqual(const char* version);
void ConfigureFromOptions();
diff --git a/Source/CPack/IFW/cmCPackIFWPackage.cxx b/Source/CPack/IFW/cmCPackIFWPackage.cxx
index a22c0b9..5bc1a0b 100644
--- a/Source/CPack/IFW/cmCPackIFWPackage.cxx
+++ b/Source/CPack/IFW/cmCPackIFWPackage.cxx
@@ -22,21 +22,21 @@
//----------------------------------------------------------------- Logger ---
#ifdef cmCPackLogger
-# undef cmCPackLogger
+#undef cmCPackLogger
#endif
-#define cmCPackLogger(logType, msg) \
- do { \
- std::ostringstream cmCPackLog_msg; \
- cmCPackLog_msg << msg; \
- if(Generator) { \
- Generator->Logger->Log(logType, __FILE__, __LINE__, \
- cmCPackLog_msg.str().c_str()); \
- } \
- } while ( 0 )
+#define cmCPackLogger(logType, msg) \
+ do { \
+ std::ostringstream cmCPackLog_msg; \
+ cmCPackLog_msg << msg; \
+ if (Generator) { \
+ Generator->Logger->Log(logType, __FILE__, __LINE__, \
+ cmCPackLog_msg.str().c_str()); \
+ } \
+ } while (0)
//---------------------------------------------------------- CompareStruct ---
-cmCPackIFWPackage::CompareStruct::CompareStruct() :
- Type(CompareNone)
+cmCPackIFWPackage::CompareStruct::CompareStruct()
+ : Type(CompareNone)
{
}
@@ -46,64 +46,47 @@ cmCPackIFWPackage::DependenceStruct::DependenceStruct()
}
cmCPackIFWPackage::DependenceStruct::DependenceStruct(
- const std::string &dependence)
+ const std::string& dependence)
{
// Search compare section
size_t pos = std::string::npos;
- if((pos = dependence.find("<=")) != std::string::npos)
- {
+ if ((pos = dependence.find("<=")) != std::string::npos) {
Compare.Type = CompareLessOrEqual;
Compare.Value = dependence.substr(pos + 2);
- }
- else if((pos = dependence.find(">=")) != std::string::npos)
- {
+ } else if ((pos = dependence.find(">=")) != std::string::npos) {
Compare.Type = CompareGreaterOrEqual;
Compare.Value = dependence.substr(pos + 2);
- }
- else if((pos = dependence.find("<")) != std::string::npos)
- {
+ } else if ((pos = dependence.find("<")) != std::string::npos) {
Compare.Type = CompareLess;
Compare.Value = dependence.substr(pos + 1);
- }
- else if((pos = dependence.find("=")) != std::string::npos)
- {
+ } else if ((pos = dependence.find("=")) != std::string::npos) {
Compare.Type = CompareEqual;
Compare.Value = dependence.substr(pos + 1);
- }
- else if((pos = dependence.find(">")) != std::string::npos)
- {
+ } else if ((pos = dependence.find(">")) != std::string::npos) {
Compare.Type = CompareGreater;
Compare.Value = dependence.substr(pos + 1);
- }
+ }
Name = pos == std::string::npos ? dependence : dependence.substr(0, pos);
}
std::string cmCPackIFWPackage::DependenceStruct::NameWithCompare() const
{
- if (Compare.Type == CompareNone) return Name;
+ if (Compare.Type == CompareNone)
+ return Name;
std::string result = Name;
- if (Compare.Type == CompareLessOrEqual)
- {
+ if (Compare.Type == CompareLessOrEqual) {
result += "<=";
- }
- else if (Compare.Type == CompareGreaterOrEqual)
- {
+ } else if (Compare.Type == CompareGreaterOrEqual) {
result += ">=";
- }
- else if (Compare.Type == CompareLess)
- {
+ } else if (Compare.Type == CompareLess) {
result += "<";
- }
- else if (Compare.Type == CompareEqual)
- {
+ } else if (Compare.Type == CompareEqual) {
result += "=";
- }
- else if (Compare.Type == CompareGreater)
- {
+ } else if (Compare.Type == CompareGreater) {
result += ">";
- }
+ }
result += Compare.Value;
@@ -111,45 +94,45 @@ std::string cmCPackIFWPackage::DependenceStruct::NameWithCompare() const
}
//------------------------------------------------------ cmCPackIFWPackage ---
-cmCPackIFWPackage::cmCPackIFWPackage() :
- Generator(0),
- Installer(0)
+cmCPackIFWPackage::cmCPackIFWPackage()
+ : Generator(0)
+ , Installer(0)
{
}
-const char *cmCPackIFWPackage::GetOption(const std::string &op) const
+const char* cmCPackIFWPackage::GetOption(const std::string& op) const
{
- const char *option = Generator ? Generator->GetOption(op) : 0;
+ const char* option = Generator ? Generator->GetOption(op) : 0;
return option && *option ? option : 0;
}
-bool cmCPackIFWPackage::IsOn(const std::string &op) const
+bool cmCPackIFWPackage::IsOn(const std::string& op) const
{
return Generator ? Generator->IsOn(op) : false;
}
-bool cmCPackIFWPackage::IsVersionLess(const char *version)
+bool cmCPackIFWPackage::IsVersionLess(const char* version)
{
return Generator ? Generator->IsVersionLess(version) : false;
}
-bool cmCPackIFWPackage::IsVersionGreater(const char *version)
+bool cmCPackIFWPackage::IsVersionGreater(const char* version)
{
return Generator ? Generator->IsVersionGreater(version) : false;
}
-bool cmCPackIFWPackage::IsVersionEqual(const char *version)
+bool cmCPackIFWPackage::IsVersionEqual(const char* version)
{
return Generator ? Generator->IsVersionEqual(version) : false;
}
-std::string cmCPackIFWPackage::GetComponentName(cmCPackComponent *component)
+std::string cmCPackIFWPackage::GetComponentName(cmCPackComponent* component)
{
- if (!component) return "";
- const char* option = GetOption(
- "CPACK_IFW_COMPONENT_"
- + cmsys::SystemTools::UpperCase(component->Name)
- + "_NAME");
+ if (!component)
+ return "";
+ const char* option =
+ GetOption("CPACK_IFW_COMPONENT_" +
+ cmsys::SystemTools::UpperCase(component->Name) + "_NAME");
return option ? option : component->Name;
}
@@ -177,51 +160,42 @@ int cmCPackIFWPackage::ConfigureFromOptions()
Name = Generator->GetRootPackageName();
// Display name
- if (const char *option = this->GetOption("CPACK_PACKAGE_NAME"))
- {
+ if (const char* option = this->GetOption("CPACK_PACKAGE_NAME")) {
DisplayName = option;
- }
- else
- {
+ } else {
DisplayName = "Your package";
- }
+ }
// Description
if (const char* option =
- this->GetOption("CPACK_PACKAGE_DESCRIPTION_SUMMARY"))
- {
+ this->GetOption("CPACK_PACKAGE_DESCRIPTION_SUMMARY")) {
Description = option;
- }
- else
- {
+ } else {
Description = "Your package description";
- }
+ }
// Version
- if(const char* option = GetOption("CPACK_PACKAGE_VERSION"))
- {
+ if (const char* option = GetOption("CPACK_PACKAGE_VERSION")) {
Version = option;
- }
- else
- {
+ } else {
Version = "1.0.0";
- }
+ }
ForcedInstallation = "true";
return 1;
}
-int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent *component)
+int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent* component)
{
- if(!component) return 0;
+ if (!component)
+ return 0;
// Restore defaul configuration
DefaultConfiguration();
- std::string prefix = "CPACK_IFW_COMPONENT_"
- + cmsys::SystemTools::UpperCase(component->Name)
- + "_";
+ std::string prefix = "CPACK_IFW_COMPONENT_" +
+ cmsys::SystemTools::UpperCase(component->Name) + "_";
// Display name
DisplayName = component->DisplayName;
@@ -230,81 +204,65 @@ int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent *component)
Description = component->Description;
// Version
- if(const char* optVERSION = GetOption(prefix + "VERSION"))
- {
+ if (const char* optVERSION = GetOption(prefix + "VERSION")) {
Version = optVERSION;
- }
- else if(const char* optPACKAGE_VERSION =
- GetOption("CPACK_PACKAGE_VERSION"))
- {
+ } else if (const char* optPACKAGE_VERSION =
+ GetOption("CPACK_PACKAGE_VERSION")) {
Version = optPACKAGE_VERSION;
- }
- else
- {
+ } else {
Version = "1.0.0";
- }
+ }
// Script
- if (const char* option = GetOption(prefix + "SCRIPT"))
- {
+ if (const char* option = GetOption(prefix + "SCRIPT")) {
Script = option;
- }
+ }
// CMake dependencies
- if (!component->Dependencies.empty())
- {
+ if (!component->Dependencies.empty()) {
std::vector<cmCPackComponent*>::iterator dit;
- for(dit = component->Dependencies.begin();
- dit != component->Dependencies.end();
- ++dit)
- {
+ for (dit = component->Dependencies.begin();
+ dit != component->Dependencies.end(); ++dit) {
Dependencies.insert(Generator->ComponentPackages[*dit]);
- }
}
+ }
// QtIFW dependencies
- if(const char* option = this->GetOption(prefix + "DEPENDS"))
- {
+ if (const char* option = this->GetOption(prefix + "DEPENDS")) {
std::vector<std::string> deps;
- cmSystemTools::ExpandListArgument(option,
- deps);
- for(std::vector<std::string>::iterator
- dit = deps.begin(); dit != deps.end(); ++dit)
- {
+ cmSystemTools::ExpandListArgument(option, deps);
+ for (std::vector<std::string>::iterator dit = deps.begin();
+ dit != deps.end(); ++dit) {
DependenceStruct dep(*dit);
- if (!Generator->Packages.count(dep.Name))
- {
+ if (!Generator->Packages.count(dep.Name)) {
bool hasDep = Generator->DependentPackages.count(dep.Name) > 0;
- DependenceStruct &depRef =
- Generator->DependentPackages[dep.Name];
- if(!hasDep)
- {
+ DependenceStruct& depRef = Generator->DependentPackages[dep.Name];
+ if (!hasDep) {
depRef = dep;
- }
- AlienDependencies.insert(&depRef);
}
+ AlienDependencies.insert(&depRef);
}
}
+ }
// Licenses
- if (const char* option = this->GetOption(prefix + "LICENSES"))
- {
+ if (const char* option = this->GetOption(prefix + "LICENSES")) {
Licenses.clear();
- cmSystemTools::ExpandListArgument( option, Licenses );
- if ( Licenses.size() % 2 != 0 )
- {
- cmCPackLogger(cmCPackLog::LOG_WARNING, prefix << "LICENSES"
- << " should contain pairs of <display_name> and <file_path>."
- << std::endl);
+ cmSystemTools::ExpandListArgument(option, Licenses);
+ if (Licenses.size() % 2 != 0) {
+ cmCPackLogger(
+ cmCPackLog::LOG_WARNING, prefix
+ << "LICENSES"
+ << " should contain pairs of <display_name> and <file_path>."
+ << std::endl);
Licenses.clear();
- }
}
+ }
// Priority
- if(const char* option = this->GetOption(prefix + "PRIORITY"))
- {
+ if (const char* option = this->GetOption(prefix + "PRIORITY")) {
SortingPriority = option;
- }
+ }
// Default
Default = component->IsDisabledByDefault ? "false" : "true";
@@ -318,87 +276,74 @@ int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent *component)
return 1;
}
-int
-cmCPackIFWPackage::ConfigureFromGroup(cmCPackComponentGroup *group)
+int cmCPackIFWPackage::ConfigureFromGroup(cmCPackComponentGroup* group)
{
- if(!group) return 0;
+ if (!group)
+ return 0;
// Restore defaul configuration
DefaultConfiguration();
- std::string prefix = "CPACK_IFW_COMPONENT_GROUP_"
- + cmsys::SystemTools::UpperCase(group->Name)
- + "_";
+ std::string prefix = "CPACK_IFW_COMPONENT_GROUP_" +
+ cmsys::SystemTools::UpperCase(group->Name) + "_";
DisplayName = group->DisplayName;
Description = group->Description;
// Version
- if(const char* optVERSION = GetOption(prefix + "VERSION"))
- {
+ if (const char* optVERSION = GetOption(prefix + "VERSION")) {
Version = optVERSION;
- }
- else if(const char* optPACKAGE_VERSION =
- GetOption("CPACK_PACKAGE_VERSION"))
- {
+ } else if (const char* optPACKAGE_VERSION =
+ GetOption("CPACK_PACKAGE_VERSION")) {
Version = optPACKAGE_VERSION;
- }
- else
- {
+ } else {
Version = "1.0.0";
- }
+ }
// Script
- if (const char* option = GetOption(prefix + "SCRIPT"))
- {
+ if (const char* option = GetOption(prefix + "SCRIPT")) {
Script = option;
- }
+ }
// Licenses
- if (const char* option = this->GetOption(prefix + "LICENSES"))
- {
+ if (const char* option = this->GetOption(prefix + "LICENSES")) {
Licenses.clear();
- cmSystemTools::ExpandListArgument( option, Licenses );
- if ( Licenses.size() % 2 != 0 )
- {
- cmCPackLogger(cmCPackLog::LOG_WARNING, prefix << "LICENSES"
- << " should contain pairs of <display_name> and <file_path>."
- << std::endl);
+ cmSystemTools::ExpandListArgument(option, Licenses);
+ if (Licenses.size() % 2 != 0) {
+ cmCPackLogger(
+ cmCPackLog::LOG_WARNING, prefix
+ << "LICENSES"
+ << " should contain pairs of <display_name> and <file_path>."
+ << std::endl);
Licenses.clear();
- }
}
+ }
// Priority
- if(const char* option = this->GetOption(prefix + "PRIORITY"))
- {
+ if (const char* option = this->GetOption(prefix + "PRIORITY")) {
SortingPriority = option;
- }
+ }
return 1;
}
-int cmCPackIFWPackage::ConfigureFromGroup(const std::string &groupName)
+int cmCPackIFWPackage::ConfigureFromGroup(const std::string& groupName)
{
// Group configuration
cmCPackComponentGroup group;
- std::string prefix = "CPACK_COMPONENT_GROUP_"
- + cmsys::SystemTools::UpperCase(groupName)
- + "_";
+ std::string prefix =
+ "CPACK_COMPONENT_GROUP_" + cmsys::SystemTools::UpperCase(groupName) + "_";
- if (const char *option = GetOption(prefix + "DISPLAY_NAME"))
- {
+ if (const char* option = GetOption(prefix + "DISPLAY_NAME")) {
group.DisplayName = option;
- }
- else
- {
+ } else {
group.DisplayName = group.Name;
- }
+ }
- if (const char* option = GetOption(prefix + "DESCRIPTION"))
- {
+ if (const char* option = GetOption(prefix + "DESCRIPTION")) {
group.Description = option;
- }
+ }
group.IsBold = IsOn(prefix + "BOLD_TITLE");
group.IsExpandedByDefault = IsOn(prefix + "EXPANDED");
@@ -406,14 +351,11 @@ int cmCPackIFWPackage::ConfigureFromGroup(const std::string &groupName)
group.Name = groupName;
- if(Generator)
- {
+ if (Generator) {
Name = Generator->GetGroupPackageName(&group);
- }
- else
- {
+ } else {
Name = group.Name;
- }
+ }
return ConfigureFromGroup(&group);
}
@@ -421,17 +363,13 @@ int cmCPackIFWPackage::ConfigureFromGroup(const std::string &groupName)
void cmCPackIFWPackage::GeneratePackageFile()
{
// Lazy directory initialization
- if (Directory.empty())
- {
- if(Installer)
- {
+ if (Directory.empty()) {
+ if (Installer) {
Directory = Installer->Directory + "/packages/" + Name;
- }
- else if (Generator)
- {
+ } else if (Generator) {
Directory = Generator->toplevel + "/packages/" + Name;
- }
}
+ }
// Output stream
cmGeneratedFileStream fout((Directory + "/meta/package.xml").data());
@@ -448,98 +386,83 @@ void cmCPackIFWPackage::GeneratePackageFile()
xout.Element("Name", Name);
xout.Element("Version", Version);
- if (!ReleaseDate.empty())
- {
+ if (!ReleaseDate.empty()) {
xout.Element("ReleaseDate", ReleaseDate);
- }
- else
- {
+ } else {
xout.Element("ReleaseDate", cmTimestamp().CurrentTime("%Y-%m-%d", true));
- }
+ }
// Script (copy to meta dir)
- if(!Script.empty())
- {
+ if (!Script.empty()) {
std::string name = cmSystemTools::GetFilenameName(Script);
std::string path = Directory + "/meta/" + name;
cmsys::SystemTools::CopyFileIfDifferent(Script.data(), path.data());
xout.Element("Script", name);
- }
+ }
// Dependencies
std::set<DependenceStruct> compDepSet;
- for(std::set<DependenceStruct*>::iterator ait = AlienDependencies.begin();
- ait != AlienDependencies.end(); ++ait)
- {
+ for (std::set<DependenceStruct*>::iterator ait = AlienDependencies.begin();
+ ait != AlienDependencies.end(); ++ait) {
compDepSet.insert(*(*ait));
- }
- for(std::set<cmCPackIFWPackage*>::iterator it = Dependencies.begin();
- it != Dependencies.end(); ++it)
- {
+ }
+ for (std::set<cmCPackIFWPackage*>::iterator it = Dependencies.begin();
+ it != Dependencies.end(); ++it) {
compDepSet.insert(DependenceStruct((*it)->Name));
- }
+ }
// Write dependencies
- if (!compDepSet.empty())
- {
+ if (!compDepSet.empty()) {
std::stringstream dependencies;
std::set<DependenceStruct>::iterator it = compDepSet.begin();
dependencies << it->NameWithCompare();
++it;
- while(it != compDepSet.end())
- {
+ while (it != compDepSet.end()) {
dependencies << "," << it->NameWithCompare();
++it;
- }
- xout.Element("Dependencies", dependencies.str());
}
+ xout.Element("Dependencies", dependencies.str());
+ }
// Licenses (copy to meta dir)
std::vector<std::string> licenses = Licenses;
- for(size_t i = 1; i < licenses.size(); i += 2)
- {
+ 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());
licenses[i] = name;
- }
- if(!licenses.empty())
- {
+ }
+ if (!licenses.empty()) {
xout.StartElement("Licenses");
- for(size_t i = 0; i < licenses.size(); i += 2)
- {
+ for (size_t i = 0; i < licenses.size(); i += 2) {
xout.StartElement("License");
xout.Attribute("name", licenses[i]);
xout.Attribute("file", licenses[i + 1]);
xout.EndElement();
- }
- xout.EndElement();
}
+ xout.EndElement();
+ }
- if (!ForcedInstallation.empty())
- {
+ if (!ForcedInstallation.empty()) {
xout.Element("ForcedInstallation", ForcedInstallation);
- }
+ }
- if (!Virtual.empty())
- {
+ if (!Virtual.empty()) {
xout.Element("Virtual", Virtual);
- }
- else if (!Default.empty())
- {
+ } else if (!Default.empty()) {
xout.Element("Default", Default);
- }
+ }
// Priority
- if(!SortingPriority.empty())
- {
+ if (!SortingPriority.empty()) {
xout.Element("SortingPriority", SortingPriority);
- }
+ }
xout.EndElement();
xout.EndDocument();
}
-void cmCPackIFWPackage::WriteGeneratedByToStrim(cmXMLWriter &xout)
+void cmCPackIFWPackage::WriteGeneratedByToStrim(cmXMLWriter& xout)
{
- if(Generator) Generator->WriteGeneratedByToStrim(xout);
+ if (Generator)
+ Generator->WriteGeneratedByToStrim(xout);
}
diff --git a/Source/CPack/IFW/cmCPackIFWPackage.h b/Source/CPack/IFW/cmCPackIFWPackage.h
index 4f3f40b..8a566cb 100644
--- a/Source/CPack/IFW/cmCPackIFWPackage.h
+++ b/Source/CPack/IFW/cmCPackIFWPackage.h
@@ -31,11 +31,11 @@ public:
enum CompareTypes
{
- CompareNone = 0x0,
- CompareEqual = 0x1,
- CompareLess = 0x2,
- CompareLessOrEqual = 0x3,
- CompareGreater = 0x4,
+ CompareNone = 0x0,
+ CompareEqual = 0x1,
+ CompareLess = 0x2,
+ CompareLessOrEqual = 0x3,
+ CompareGreater = 0x4,
CompareGreaterOrEqual = 0x5
};
@@ -50,17 +50,17 @@ public:
struct DependenceStruct
{
DependenceStruct();
- DependenceStruct(const std::string &dependence);
+ DependenceStruct(const std::string& dependence);
std::string Name;
CompareStruct Compare;
std::string NameWithCompare() const;
- bool operator < (const DependenceStruct &other) const
- {
+ bool operator<(const DependenceStruct& other) const
+ {
return Name < other.Name;
- }
+ }
};
public:
@@ -113,18 +113,18 @@ public:
const char* GetOption(const std::string& op) const;
bool IsOn(const std::string& op) const;
- bool IsVersionLess(const char *version);
- bool IsVersionGreater(const char *version);
- bool IsVersionEqual(const char *version);
+ bool IsVersionLess(const char* version);
+ bool IsVersionGreater(const char* version);
+ bool IsVersionEqual(const char* version);
- std::string GetComponentName(cmCPackComponent *component);
+ std::string GetComponentName(cmCPackComponent* component);
void DefaultConfiguration();
int ConfigureFromOptions();
- int ConfigureFromComponent(cmCPackComponent *component);
- int ConfigureFromGroup(cmCPackComponentGroup *group);
- int ConfigureFromGroup(const std::string &groupName);
+ int ConfigureFromComponent(cmCPackComponent* component);
+ int ConfigureFromGroup(cmCPackComponentGroup* group);
+ int ConfigureFromGroup(const std::string& groupName);
void GeneratePackageFile();
diff --git a/Source/CPack/OSXScriptLauncher.cxx b/Source/CPack/OSXScriptLauncher.cxx
index b3ddeee..19204a2 100644
--- a/Source/CPack/OSXScriptLauncher.cxx
+++ b/Source/CPack/OSXScriptLauncher.cxx
@@ -20,72 +20,65 @@
// For the PATH_MAX constant
#include <sys/syslimits.h>
-#define DebugError(x) \
- ofs << x << std::endl; \
+#define DebugError(x) \
+ ofs << x << std::endl; \
std::cout << x << std::endl
int main(int argc, char* argv[])
{
- //if ( cmsys::SystemTools::FileExists(
+ // if ( cmsys::SystemTools::FileExists(
std::string cwd = cmsys::SystemTools::GetCurrentWorkingDirectory();
cmsys::ofstream ofs("/tmp/output.txt");
CFStringRef fileName;
CFBundleRef appBundle;
CFURLRef scriptFileURL;
- UInt8 *path;
+ UInt8* path;
- //get CF URL for script
- if (! (appBundle = CFBundleGetMainBundle()))
- {
+ // get CF URL for script
+ if (!(appBundle = CFBundleGetMainBundle())) {
DebugError("Cannot get main bundle");
return 1;
- }
+ }
fileName = CFSTR("RuntimeScript");
- if (! (scriptFileURL = CFBundleCopyResourceURL(appBundle, fileName, NULL,
- NULL)))
- {
+ if (!(scriptFileURL =
+ CFBundleCopyResourceURL(appBundle, fileName, NULL, NULL))) {
DebugError("CFBundleCopyResourceURL failed");
return 1;
- }
+ }
- //create path string
- if (! (path = new UInt8[PATH_MAX]))
- {
+ // create path string
+ if (!(path = new UInt8[PATH_MAX])) {
return 1;
- }
+ }
- //get the file system path of the url as a cstring
- //in an encoding suitable for posix apis
- if ( CFURLGetFileSystemRepresentation(scriptFileURL, true, path,
- PATH_MAX) == false)
- {
+ // get the file system path of the url as a cstring
+ // in an encoding suitable for posix apis
+ if (CFURLGetFileSystemRepresentation(scriptFileURL, true, path, PATH_MAX) ==
+ false) {
DebugError("CFURLGetFileSystemRepresentation failed");
return 1;
- }
+ }
- //dispose of the CF variable
+ // dispose of the CF variable
CFRelease(scriptFileURL);
std::string fullScriptPath = reinterpret_cast<char*>(path);
- delete [] path;
+ delete[] path;
-
- if (! cmsys::SystemTools::FileExists(fullScriptPath.c_str()))
- {
+ if (!cmsys::SystemTools::FileExists(fullScriptPath.c_str())) {
return 1;
- }
+ }
- std::string scriptDirectory = cmsys::SystemTools::GetFilenamePath(
- fullScriptPath);
+ std::string scriptDirectory =
+ cmsys::SystemTools::GetFilenamePath(fullScriptPath);
ofs << fullScriptPath.c_str() << std::endl;
std::vector<const char*> args;
args.push_back(fullScriptPath.c_str());
int cc;
- for ( cc = 1; cc < argc; ++ cc )
- {
+ for (cc = 1; cc < argc; ++cc) {
args.push_back(argv[cc]);
- }
+ }
args.push_back(0);
cmsysProcess* cp = cmsysProcess_New();
@@ -98,49 +91,38 @@ int main(int argc, char* argv[])
std::vector<char> tempOutput;
char* data;
int length;
- while(cmsysProcess_WaitForData(cp, &data, &length, 0))
- {
+ 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')
- {
+ for (int i = 0; i < length; ++i) {
+ if (data[i] == '\0') {
data[i] = ' ';
- }
}
- std::cout.write(data, length);
}
+ std::cout.write(data, length);
+ }
cmsysProcess_WaitForExit(cp, 0);
bool result = true;
- if(cmsysProcess_GetState(cp) == cmsysProcess_State_Exited)
- {
- if ( cmsysProcess_GetExitValue(cp) != 0 )
- {
+ if (cmsysProcess_GetState(cp) == cmsysProcess_State_Exited) {
+ if (cmsysProcess_GetExitValue(cp) != 0) {
result = false;
- }
}
- else if(cmsysProcess_GetState(cp) == cmsysProcess_State_Exception)
- {
+ } else if (cmsysProcess_GetState(cp) == cmsysProcess_State_Exception) {
const char* exception_str = cmsysProcess_GetExceptionString(cp);
std::cerr << exception_str << std::endl;
result = false;
- }
- else if(cmsysProcess_GetState(cp) == cmsysProcess_State_Error)
- {
+ } else if (cmsysProcess_GetState(cp) == cmsysProcess_State_Error) {
const char* error_str = cmsysProcess_GetErrorString(cp);
std::cerr << error_str << std::endl;
result = false;
- }
- else if(cmsysProcess_GetState(cp) == cmsysProcess_State_Expired)
- {
+ } else if (cmsysProcess_GetState(cp) == cmsysProcess_State_Expired) {
const char* error_str = "Process terminated due to timeout\n";
std::cerr << error_str << std::endl;
result = false;
- }
+ }
cmsysProcess_Delete(cp);
diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx
index a98c684..8777296 100644
--- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx
+++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx
@@ -32,18 +32,16 @@
#include <rpc.h> // for GUID generation
-cmCPackWIXGenerator::cmCPackWIXGenerator():
- Patch(0)
+cmCPackWIXGenerator::cmCPackWIXGenerator()
+ : Patch(0)
{
-
}
cmCPackWIXGenerator::~cmCPackWIXGenerator()
{
- if(this->Patch)
- {
+ if (this->Patch) {
delete this->Patch;
- }
+ }
}
int cmCPackWIXGenerator::InitializeInternal()
@@ -58,41 +56,39 @@ bool cmCPackWIXGenerator::RunWiXCommand(std::string const& command)
{
std::string logFileName = this->CPackTopLevel + "/wix.log";
- cmCPackLogger(cmCPackLog::LOG_DEBUG,
- "Running WiX command: " << command << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_DEBUG, "Running WiX command: " << command
+ << std::endl);
std::string output;
int returnValue = 0;
- bool status = cmSystemTools::RunSingleCommand(
- command.c_str(), &output, &output,
- &returnValue, 0, cmSystemTools::OUTPUT_NONE);
+ bool status = cmSystemTools::RunSingleCommand(command.c_str(), &output,
+ &output, &returnValue, 0,
+ cmSystemTools::OUTPUT_NONE);
cmsys::ofstream logFile(logFileName.c_str(), std::ios::app);
logFile << command << std::endl;
logFile << output;
logFile.close();
- if(!status || returnValue)
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Problem running WiX candle. "
- "Please check '" << logFileName << "' for errors." << std::endl);
+ if (!status || returnValue) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running WiX candle. "
+ "Please check '"
+ << logFileName << "' for errors." << std::endl);
return false;
- }
+ }
return true;
}
-bool cmCPackWIXGenerator::RunCandleCommand(
- std::string const& sourceFile, std::string const& objectFile)
+bool cmCPackWIXGenerator::RunCandleCommand(std::string const& sourceFile,
+ std::string const& objectFile)
{
std::string executable;
- if(!RequireOption("CPACK_WIX_CANDLE_EXECUTABLE", executable))
- {
+ if (!RequireOption("CPACK_WIX_CANDLE_EXECUTABLE", executable)) {
return false;
- }
+ }
std::stringstream command;
command << QuotePath(executable);
@@ -100,11 +96,10 @@ bool cmCPackWIXGenerator::RunCandleCommand(
command << " -arch " << GetArchitecture();
command << " -out " << QuotePath(objectFile);
- for(extension_set_t::const_iterator i = CandleExtensions.begin();
- i != CandleExtensions.end(); ++i)
- {
+ for (extension_set_t::const_iterator i = CandleExtensions.begin();
+ i != CandleExtensions.end(); ++i) {
command << " -ext " << QuotePath(*i);
- }
+ }
AddCustomFlags("CPACK_WIX_CANDLE_EXTRA_FLAGS", command);
@@ -116,27 +111,24 @@ bool cmCPackWIXGenerator::RunCandleCommand(
bool cmCPackWIXGenerator::RunLightCommand(std::string const& objectFiles)
{
std::string executable;
- if(!RequireOption("CPACK_WIX_LIGHT_EXECUTABLE", executable))
- {
+ if (!RequireOption("CPACK_WIX_LIGHT_EXECUTABLE", executable)) {
return false;
- }
+ }
std::stringstream command;
command << QuotePath(executable);
command << " -nologo";
command << " -out " << QuotePath(packageFileNames.at(0));
- for(extension_set_t::const_iterator i = this->LightExtensions.begin();
- i != this->LightExtensions.end(); ++i)
- {
+ for (extension_set_t::const_iterator i = this->LightExtensions.begin();
+ i != this->LightExtensions.end(); ++i) {
command << " -ext " << QuotePath(*i);
- }
+ }
const char* const cultures = GetOption("CPACK_WIX_CULTURES");
- if(cultures)
- {
+ if (cultures) {
command << " -cultures:" << cultures;
- }
+ }
AddCustomFlags("CPACK_WIX_LIGHT_EXTRA_FLAGS", command);
@@ -147,90 +139,80 @@ bool cmCPackWIXGenerator::RunLightCommand(std::string const& objectFiles)
int cmCPackWIXGenerator::PackageFiles()
{
- if(!PackageFilesImpl() || cmSystemTools::GetErrorOccuredFlag())
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Fatal WiX Generator Error" << std::endl);
+ if (!PackageFilesImpl() || cmSystemTools::GetErrorOccuredFlag()) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Fatal WiX Generator Error"
+ << std::endl);
return false;
- }
+ }
return true;
}
bool cmCPackWIXGenerator::InitializeWiXConfiguration()
{
- if(!ReadListFile("CPackWIX.cmake"))
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error while executing CPackWIX.cmake" << std::endl);
+ if (!ReadListFile("CPackWIX.cmake")) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Error while executing CPackWIX.cmake"
+ << std::endl);
return false;
- }
+ }
- if(GetOption("CPACK_WIX_PRODUCT_GUID") == 0)
- {
+ if (GetOption("CPACK_WIX_PRODUCT_GUID") == 0) {
std::string guid = GenerateGUID();
SetOption("CPACK_WIX_PRODUCT_GUID", guid.c_str());
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
- "CPACK_WIX_PRODUCT_GUID implicitly set to " << guid << " . "
- << std::endl);
- }
+ "CPACK_WIX_PRODUCT_GUID implicitly set to " << guid << " . "
+ << std::endl);
+ }
- if(GetOption("CPACK_WIX_UPGRADE_GUID") == 0)
- {
+ if (GetOption("CPACK_WIX_UPGRADE_GUID") == 0) {
std::string guid = GenerateGUID();
SetOption("CPACK_WIX_UPGRADE_GUID", guid.c_str());
- cmCPackLogger(cmCPackLog::LOG_WARNING,
- "CPACK_WIX_UPGRADE_GUID implicitly set to " << guid << " . "
- "Please refer to the documentation on how and why "
- "you might want to set this explicitly." << std::endl);
- }
+ cmCPackLogger(
+ cmCPackLog::LOG_WARNING, "CPACK_WIX_UPGRADE_GUID implicitly set to "
+ << guid << " . "
+ "Please refer to the documentation on how and why "
+ "you might want to set this explicitly."
+ << std::endl);
+ }
- if(!RequireOption("CPACK_TOPLEVEL_DIRECTORY", this->CPackTopLevel))
- {
+ if (!RequireOption("CPACK_TOPLEVEL_DIRECTORY", this->CPackTopLevel)) {
return false;
- }
+ }
- if(GetOption("CPACK_WIX_LICENSE_RTF") == 0)
- {
+ if (GetOption("CPACK_WIX_LICENSE_RTF") == 0) {
std::string licenseFilename = this->CPackTopLevel + "/License.rtf";
SetOption("CPACK_WIX_LICENSE_RTF", licenseFilename.c_str());
- if(!CreateLicenseFile())
- {
+ if (!CreateLicenseFile()) {
return false;
- }
}
+ }
- if(GetOption("CPACK_PACKAGE_VENDOR") == 0)
- {
+ if (GetOption("CPACK_PACKAGE_VENDOR") == 0) {
std::string defaultVendor = "Humanity";
SetOption("CPACK_PACKAGE_VENDOR", defaultVendor.c_str());
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
- "CPACK_PACKAGE_VENDOR implicitly set to " << defaultVendor << " . "
- << std::endl);
- }
+ "CPACK_PACKAGE_VENDOR implicitly set to "
+ << defaultVendor << " . " << std::endl);
+ }
- if(GetOption("CPACK_WIX_UI_REF") == 0)
- {
+ if (GetOption("CPACK_WIX_UI_REF") == 0) {
std::string defaultRef = "WixUI_InstallDir";
- if(!this->Components.empty())
- {
+ if (!this->Components.empty()) {
defaultRef = "WixUI_FeatureTree";
- }
+ }
SetOption("CPACK_WIX_UI_REF", defaultRef.c_str());
- }
+ }
const char* packageContact = GetOption("CPACK_PACKAGE_CONTACT");
- if(packageContact != 0 &&
- GetOption("CPACK_WIX_PROPERTY_ARPCONTACT") == 0)
- {
+ if (packageContact != 0 && GetOption("CPACK_WIX_PROPERTY_ARPCONTACT") == 0) {
SetOption("CPACK_WIX_PROPERTY_ARPCONTACT", packageContact);
- }
+ }
CollectExtensions("CPACK_WIX_EXTENSIONS", this->CandleExtensions);
CollectExtensions("CPACK_WIX_CANDLE_EXTENSIONS", this->CandleExtensions);
@@ -240,46 +222,40 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration()
CollectExtensions("CPACK_WIX_LIGHT_EXTENSIONS", this->LightExtensions);
const char* patchFilePath = GetOption("CPACK_WIX_PATCH_FILE");
- if(patchFilePath)
- {
+ if (patchFilePath) {
std::vector<std::string> patchFilePaths;
cmSystemTools::ExpandListArgument(patchFilePath, patchFilePaths);
- for(size_t i = 0; i < patchFilePaths.size(); ++i)
- {
- if(!this->Patch->LoadFragments(patchFilePaths[i]))
- {
+ for (size_t i = 0; i < patchFilePaths.size(); ++i) {
+ if (!this->Patch->LoadFragments(patchFilePaths[i])) {
return false;
- }
}
}
+ }
return true;
}
bool cmCPackWIXGenerator::PackageFilesImpl()
{
- if(!InitializeWiXConfiguration())
- {
+ if (!InitializeWiXConfiguration()) {
return false;
- }
+ }
CreateWiXVariablesIncludeFile();
CreateWiXPropertiesIncludeFile();
CreateWiXProductFragmentIncludeFile();
- if(!CreateWiXSourceFiles())
- {
+ if (!CreateWiXSourceFiles()) {
return false;
- }
+ }
AppendUserSuppliedExtraSources();
std::set<std::string> usedBaseNames;
std::stringstream objectFiles;
- for(size_t i = 0; i < this->WixSources.size(); ++i)
- {
+ for (size_t i = 0; i < this->WixSources.size(); ++i) {
std::string const& sourceFilename = this->WixSources[i];
std::string baseName =
@@ -288,25 +264,23 @@ bool cmCPackWIXGenerator::PackageFilesImpl()
unsigned int counter = 0;
std::string uniqueBaseName = baseName;
- while(usedBaseNames.find(uniqueBaseName) != usedBaseNames.end())
- {
+ while (usedBaseNames.find(uniqueBaseName) != usedBaseNames.end()) {
std::stringstream tmp;
tmp << baseName << ++counter;
uniqueBaseName = tmp.str();
- }
+ }
usedBaseNames.insert(uniqueBaseName);
std::string objectFilename =
this->CPackTopLevel + "/" + uniqueBaseName + ".wixobj";
- if(!RunCandleCommand(sourceFilename, objectFilename))
- {
+ if (!RunCandleCommand(sourceFilename, objectFilename)) {
return false;
- }
+ }
objectFiles << " " << QuotePath(objectFilename);
- }
+ }
AppendUserSuppliedExtraObjects(objectFiles);
@@ -315,35 +289,34 @@ bool cmCPackWIXGenerator::PackageFilesImpl()
void cmCPackWIXGenerator::AppendUserSuppliedExtraSources()
{
- const char *cpackWixExtraSources = GetOption("CPACK_WIX_EXTRA_SOURCES");
- if(!cpackWixExtraSources) return;
+ const char* cpackWixExtraSources = GetOption("CPACK_WIX_EXTRA_SOURCES");
+ if (!cpackWixExtraSources)
+ return;
cmSystemTools::ExpandListArgument(cpackWixExtraSources, this->WixSources);
}
void cmCPackWIXGenerator::AppendUserSuppliedExtraObjects(std::ostream& stream)
{
- const char *cpackWixExtraObjects = GetOption("CPACK_WIX_EXTRA_OBJECTS");
- if(!cpackWixExtraObjects) return;
+ const char* cpackWixExtraObjects = GetOption("CPACK_WIX_EXTRA_OBJECTS");
+ if (!cpackWixExtraObjects)
+ return;
std::vector<std::string> expandedExtraObjects;
- cmSystemTools::ExpandListArgument(
- cpackWixExtraObjects, expandedExtraObjects);
+ cmSystemTools::ExpandListArgument(cpackWixExtraObjects,
+ expandedExtraObjects);
- for(size_t i = 0; i < expandedExtraObjects.size(); ++i)
- {
+ for (size_t i = 0; i < expandedExtraObjects.size(); ++i) {
stream << " " << QuotePath(expandedExtraObjects[i]);
- }
+ }
}
void cmCPackWIXGenerator::CreateWiXVariablesIncludeFile()
{
- std::string includeFilename =
- this->CPackTopLevel + "/cpack_variables.wxi";
+ std::string includeFilename = this->CPackTopLevel + "/cpack_variables.wxi";
- cmWIXSourceWriter includeFile(
- this->Logger, includeFilename, true);
+ cmWIXSourceWriter includeFile(this->Logger, includeFilename, true);
CopyDefinition(includeFile, "CPACK_WIX_PRODUCT_GUID");
CopyDefinition(includeFile, "CPACK_WIX_UPGRADE_GUID");
@@ -355,29 +328,25 @@ void cmCPackWIXGenerator::CreateWiXVariablesIncludeFile()
CopyDefinition(includeFile, "CPACK_WIX_UI_BANNER");
CopyDefinition(includeFile, "CPACK_WIX_UI_DIALOG");
SetOptionIfNotSet("CPACK_WIX_PROGRAM_MENU_FOLDER",
- GetOption("CPACK_PACKAGE_NAME"));
+ GetOption("CPACK_PACKAGE_NAME"));
CopyDefinition(includeFile, "CPACK_WIX_PROGRAM_MENU_FOLDER");
CopyDefinition(includeFile, "CPACK_WIX_UI_REF");
}
void cmCPackWIXGenerator::CreateWiXPropertiesIncludeFile()
{
- std::string includeFilename =
- this->CPackTopLevel + "/properties.wxi";
+ std::string includeFilename = this->CPackTopLevel + "/properties.wxi";
- cmWIXSourceWriter includeFile(
- this->Logger, includeFilename, true);
+ cmWIXSourceWriter includeFile(this->Logger, includeFilename, true);
std::string prefix = "CPACK_WIX_PROPERTY_";
std::vector<std::string> options = GetOptions();
- for(size_t i = 0; i < options.size(); ++i)
- {
+ for (size_t i = 0; i < options.size(); ++i) {
std::string const& name = options[i];
- if(name.length() > prefix.length() &&
- name.substr(0, prefix.length()) == prefix)
- {
+ if (name.length() > prefix.length() &&
+ name.substr(0, prefix.length()) == prefix) {
std::string id = name.substr(prefix.length());
std::string value = GetOption(name.c_str());
@@ -385,11 +354,10 @@ void cmCPackWIXGenerator::CreateWiXPropertiesIncludeFile()
includeFile.AddAttribute("Id", id);
includeFile.AddAttribute("Value", value);
includeFile.EndElement("Property");
- }
}
+ }
- if(GetOption("CPACK_WIX_PROPERTY_ARPINSTALLLOCATION") == 0)
- {
+ if (GetOption("CPACK_WIX_PROPERTY_ARPINSTALLLOCATION") == 0) {
includeFile.BeginElement("Property");
includeFile.AddAttribute("Id", "INSTALL_ROOT");
includeFile.AddAttribute("Secure", "yes");
@@ -397,8 +365,9 @@ void cmCPackWIXGenerator::CreateWiXPropertiesIncludeFile()
includeFile.BeginElement("RegistrySearch");
includeFile.AddAttribute("Id", "FindInstallLocation");
includeFile.AddAttribute("Root", "HKLM");
- includeFile.AddAttribute("Key", "Software\\Microsoft\\Windows\\"
- "CurrentVersion\\Uninstall\\[WIX_UPGRADE_DETECTED]");
+ includeFile.AddAttribute(
+ "Key", "Software\\Microsoft\\Windows\\"
+ "CurrentVersion\\Uninstall\\[WIX_UPGRADE_DETECTED]");
includeFile.AddAttribute("Name", "InstallLocation");
includeFile.AddAttribute("Type", "raw");
includeFile.EndElement("RegistrySearch");
@@ -409,38 +378,36 @@ void cmCPackWIXGenerator::CreateWiXPropertiesIncludeFile()
includeFile.AddAttribute("Value", "[INSTALL_ROOT]");
includeFile.AddAttribute("After", "CostFinalize");
includeFile.EndElement("SetProperty");
- }
+ }
}
void cmCPackWIXGenerator::CreateWiXProductFragmentIncludeFile()
{
- std::string includeFilename =
- this->CPackTopLevel + "/product_fragment.wxi";
+ std::string includeFilename = this->CPackTopLevel + "/product_fragment.wxi";
- cmWIXSourceWriter includeFile(
- this->Logger, includeFilename, true);
+ cmWIXSourceWriter includeFile(this->Logger, includeFilename, true);
- this->Patch->ApplyFragment("#PRODUCT", includeFile);
+ this->Patch->ApplyFragment("#PRODUCT", includeFile);
}
-void cmCPackWIXGenerator::CopyDefinition(
- cmWIXSourceWriter &source, std::string const& name)
+void cmCPackWIXGenerator::CopyDefinition(cmWIXSourceWriter& source,
+ std::string const& name)
{
const char* value = GetOption(name.c_str());
- if(value)
- {
+ if (value) {
AddDefinition(source, name, value);
- }
+ }
}
void cmCPackWIXGenerator::AddDefinition(cmWIXSourceWriter& source,
- std::string const& name, std::string const& value)
+ std::string const& name,
+ std::string const& value)
{
std::stringstream tmp;
tmp << name << "=\"" << value << '"';
- source.AddProcessingInstruction("define",
- cmWIXSourceWriter::CMakeEncodingToUtf8(tmp.str()));
+ source.AddProcessingInstruction(
+ "define", cmWIXSourceWriter::CMakeEncodingToUtf8(tmp.str()));
}
bool cmCPackWIXGenerator::CreateWiXSourceFiles()
@@ -455,10 +422,9 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
directoryDefinitions.BeginElement("Fragment");
std::string installRoot;
- if(!RequireOption("CPACK_PACKAGE_INSTALL_DIRECTORY", installRoot))
- {
+ if (!RequireOption("CPACK_PACKAGE_INSTALL_DIRECTORY", installRoot)) {
return false;
- }
+ }
directoryDefinitions.BeginElement("Directory");
directoryDefinitions.AddAttribute("Id", "TARGETDIR");
@@ -468,23 +434,22 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
directoryDefinitions.BeginInstallationPrefixDirectory(
GetProgramFilesFolderId(), installRoot);
- std::string fileDefinitionsFilename =
- this->CPackTopLevel + "/files.wxs";
+ std::string fileDefinitionsFilename = this->CPackTopLevel + "/files.wxs";
this->WixSources.push_back(fileDefinitionsFilename);
- cmWIXFilesSourceWriter fileDefinitions(
- this->Logger, fileDefinitionsFilename);
+ cmWIXFilesSourceWriter fileDefinitions(this->Logger,
+ fileDefinitionsFilename);
fileDefinitions.BeginElement("Fragment");
std::string featureDefinitionsFilename =
- this->CPackTopLevel +"/features.wxs";
+ this->CPackTopLevel + "/features.wxs";
this->WixSources.push_back(featureDefinitionsFilename);
- cmWIXFeaturesSourceWriter featureDefinitions(
- this->Logger, featureDefinitionsFilename);
+ cmWIXFeaturesSourceWriter featureDefinitions(this->Logger,
+ featureDefinitionsFilename);
featureDefinitions.BeginElement("Fragment");
@@ -495,45 +460,39 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
featureDefinitions.AddAttribute("ConfigurableDirectory", "INSTALL_ROOT");
std::string cpackPackageName;
- if(!RequireOption("CPACK_PACKAGE_NAME", cpackPackageName))
- {
+ if (!RequireOption("CPACK_PACKAGE_NAME", cpackPackageName)) {
return false;
- }
+ }
featureDefinitions.AddAttribute("Title", cpackPackageName);
featureDefinitions.AddAttribute("Level", "1");
this->Patch->ApplyFragment("#PRODUCTFEATURE", featureDefinitions);
const char* package = GetOption("CPACK_WIX_CMAKE_PACKAGE_REGISTRY");
- if(package)
- {
+ if (package) {
featureDefinitions.CreateCMakePackageRegistryEntry(
- package, GetOption("CPACK_WIX_UPGRADE_GUID"));
- }
+ package, GetOption("CPACK_WIX_UPGRADE_GUID"));
+ }
- if(!CreateFeatureHierarchy(featureDefinitions))
- {
+ if (!CreateFeatureHierarchy(featureDefinitions)) {
return false;
- }
+ }
featureDefinitions.EndElement("Feature");
std::set<cmWIXShortcuts::Type> emittedShortcutTypes;
cmWIXShortcuts globalShortcuts;
- if(Components.empty())
- {
- AddComponentsToFeature(toplevel, "ProductFeature",
- directoryDefinitions, fileDefinitions, featureDefinitions,
- globalShortcuts);
+ if (Components.empty()) {
+ AddComponentsToFeature(toplevel, "ProductFeature", directoryDefinitions,
+ fileDefinitions, featureDefinitions,
+ globalShortcuts);
globalShortcuts.AddShortcutTypes(emittedShortcutTypes);
- }
- else
- {
- for(std::map<std::string, cmCPackComponent>::const_iterator
- i = this->Components.begin(); i != this->Components.end(); ++i)
- {
+ } else {
+ for (std::map<std::string, cmCPackComponent>::const_iterator i =
+ this->Components.begin();
+ i != this->Components.end(); ++i) {
cmCPackComponent const& component = i->second;
std::string componentPath = toplevel;
@@ -544,102 +503,91 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
cmWIXShortcuts featureShortcuts;
AddComponentsToFeature(componentPath, componentFeatureId,
- directoryDefinitions, fileDefinitions,
- featureDefinitions, featureShortcuts);
+ directoryDefinitions, fileDefinitions,
+ featureDefinitions, featureShortcuts);
featureShortcuts.AddShortcutTypes(emittedShortcutTypes);
- if(!CreateShortcuts(component.Name, componentFeatureId,
- featureShortcuts, false, fileDefinitions, featureDefinitions))
- {
+ if (!CreateShortcuts(component.Name, componentFeatureId,
+ featureShortcuts, false, fileDefinitions,
+ featureDefinitions)) {
return false;
- }
}
}
+ }
- bool emitUninstallShortcut = emittedShortcutTypes.find(
- cmWIXShortcuts::START_MENU) != emittedShortcutTypes.end();
+ bool emitUninstallShortcut =
+ emittedShortcutTypes.find(cmWIXShortcuts::START_MENU) !=
+ emittedShortcutTypes.end();
- if(!CreateShortcuts(std::string(), "ProductFeature",
- globalShortcuts, emitUninstallShortcut,
- fileDefinitions, featureDefinitions))
- {
+ if (!CreateShortcuts(std::string(), "ProductFeature", globalShortcuts,
+ emitUninstallShortcut, fileDefinitions,
+ featureDefinitions)) {
return false;
- }
+ }
featureDefinitions.EndElement("Fragment");
fileDefinitions.EndElement("Fragment");
- directoryDefinitions.EndInstallationPrefixDirectory(
- installRootSize);
+ directoryDefinitions.EndInstallationPrefixDirectory(installRootSize);
- if(emittedShortcutTypes.find(cmWIXShortcuts::START_MENU) !=
- emittedShortcutTypes.end())
- {
+ if (emittedShortcutTypes.find(cmWIXShortcuts::START_MENU) !=
+ emittedShortcutTypes.end()) {
directoryDefinitions.EmitStartMenuFolder(
GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER"));
- }
+ }
- if(emittedShortcutTypes.find(cmWIXShortcuts::DESKTOP) !=
- emittedShortcutTypes.end())
- {
+ if (emittedShortcutTypes.find(cmWIXShortcuts::DESKTOP) !=
+ emittedShortcutTypes.end()) {
directoryDefinitions.EmitDesktopFolder();
- }
+ }
- if(emittedShortcutTypes.find(cmWIXShortcuts::STARTUP) !=
- emittedShortcutTypes.end())
- {
+ if (emittedShortcutTypes.find(cmWIXShortcuts::STARTUP) !=
+ emittedShortcutTypes.end()) {
directoryDefinitions.EmitStartupFolder();
- }
+ }
directoryDefinitions.EndElement("Directory");
directoryDefinitions.EndElement("Fragment");
- if(!GenerateMainSourceFileFromTemplate())
- {
+ if (!GenerateMainSourceFileFromTemplate()) {
return false;
- }
+ }
return this->Patch->CheckForUnappliedFragments();
}
std::string cmCPackWIXGenerator::GetProgramFilesFolderId() const
{
- if(GetArchitecture() == "x86")
- {
+ if (GetArchitecture() == "x86") {
return "ProgramFilesFolder";
- }
- else
- {
+ } else {
return "ProgramFiles64Folder";
- }
+ }
}
bool cmCPackWIXGenerator::GenerateMainSourceFileFromTemplate()
{
std::string wixTemplate = FindTemplate("WIX.template.in");
- if(GetOption("CPACK_WIX_TEMPLATE") != 0)
- {
+ if (GetOption("CPACK_WIX_TEMPLATE") != 0) {
wixTemplate = GetOption("CPACK_WIX_TEMPLATE");
- }
+ }
- if(wixTemplate.empty())
- {
+ if (wixTemplate.empty()) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Could not find CPack WiX template file WIX.template.in" << std::endl);
+ "Could not find CPack WiX template file WIX.template.in"
+ << std::endl);
return false;
- }
+ }
std::string mainSourceFilePath = this->CPackTopLevel + "/main.wxs";
- if(!ConfigureFile(wixTemplate.c_str(), mainSourceFilePath .c_str()))
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Failed creating '" << mainSourceFilePath <<
- "'' from template." << std::endl);
+ if (!ConfigureFile(wixTemplate.c_str(), mainSourceFilePath.c_str())) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Failed creating '"
+ << mainSourceFilePath << "'' from template." << std::endl);
return false;
- }
+ }
this->WixSources.push_back(mainSourceFilePath);
@@ -649,70 +597,64 @@ bool cmCPackWIXGenerator::GenerateMainSourceFileFromTemplate()
bool cmCPackWIXGenerator::CreateFeatureHierarchy(
cmWIXFeaturesSourceWriter& featureDefinitions)
{
- for(std::map<std::string, cmCPackComponentGroup>::const_iterator
- i = ComponentGroups.begin(); i != ComponentGroups.end(); ++i)
- {
+ for (std::map<std::string, cmCPackComponentGroup>::const_iterator i =
+ ComponentGroups.begin();
+ i != ComponentGroups.end(); ++i) {
cmCPackComponentGroup const& group = i->second;
- if(group.ParentGroup == 0)
- {
+ if (group.ParentGroup == 0) {
featureDefinitions.EmitFeatureForComponentGroup(group);
- }
}
+ }
- for(std::map<std::string, cmCPackComponent>::const_iterator
- i = this->Components.begin(); i != this->Components.end(); ++i)
- {
+ for (std::map<std::string, cmCPackComponent>::const_iterator i =
+ this->Components.begin();
+ i != this->Components.end(); ++i) {
cmCPackComponent const& component = i->second;
- if(!component.Group)
- {
+ if (!component.Group) {
featureDefinitions.EmitFeatureForComponent(component);
- }
}
+ }
return true;
}
bool cmCPackWIXGenerator::AddComponentsToFeature(
- std::string const& rootPath,
- std::string const& featureId,
+ std::string const& rootPath, std::string const& featureId,
cmWIXDirectoriesSourceWriter& directoryDefinitions,
cmWIXFilesSourceWriter& fileDefinitions,
- cmWIXFeaturesSourceWriter& featureDefinitions,
- cmWIXShortcuts& shortcuts)
+ cmWIXFeaturesSourceWriter& featureDefinitions, cmWIXShortcuts& shortcuts)
{
featureDefinitions.BeginElement("FeatureRef");
featureDefinitions.AddAttribute("Id", featureId);
std::vector<std::string> cpackPackageExecutablesList;
- const char *cpackPackageExecutables = GetOption("CPACK_PACKAGE_EXECUTABLES");
- if(cpackPackageExecutables)
- {
- cmSystemTools::ExpandListArgument(cpackPackageExecutables,
- cpackPackageExecutablesList);
- if(cpackPackageExecutablesList.size() % 2 != 0 )
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "CPACK_PACKAGE_EXECUTABLES should contain pairs of <executable> and "
- "<text label>." << std::endl);
- return false;
- }
+ const char* cpackPackageExecutables = GetOption("CPACK_PACKAGE_EXECUTABLES");
+ if (cpackPackageExecutables) {
+ cmSystemTools::ExpandListArgument(cpackPackageExecutables,
+ cpackPackageExecutablesList);
+ if (cpackPackageExecutablesList.size() % 2 != 0) {
+ cmCPackLogger(
+ cmCPackLog::LOG_ERROR,
+ "CPACK_PACKAGE_EXECUTABLES should contain pairs of <executable> and "
+ "<text label>."
+ << std::endl);
+ return false;
}
+ }
std::vector<std::string> cpackPackageDesktopLinksList;
- const char *cpackPackageDesktopLinks =
+ const char* cpackPackageDesktopLinks =
GetOption("CPACK_CREATE_DESKTOP_LINKS");
- if(cpackPackageDesktopLinks)
- {
- cmSystemTools::ExpandListArgument(cpackPackageDesktopLinks,
- cpackPackageDesktopLinksList);
- }
+ if (cpackPackageDesktopLinks) {
+ cmSystemTools::ExpandListArgument(cpackPackageDesktopLinks,
+ cpackPackageDesktopLinksList);
+ }
- AddDirectoryAndFileDefinitons(
- rootPath, "INSTALL_ROOT",
- directoryDefinitions, fileDefinitions, featureDefinitions,
- cpackPackageExecutablesList, cpackPackageDesktopLinksList,
- shortcuts);
+ AddDirectoryAndFileDefinitons(rootPath, "INSTALL_ROOT", directoryDefinitions,
+ fileDefinitions, featureDefinitions,
+ cpackPackageExecutablesList,
+ cpackPackageDesktopLinksList, shortcuts);
featureDefinitions.EndElement("FeatureRef");
@@ -720,62 +662,48 @@ bool cmCPackWIXGenerator::AddComponentsToFeature(
}
bool cmCPackWIXGenerator::CreateShortcuts(
- std::string const& cpackComponentName,
- std::string const& featureId,
- cmWIXShortcuts const& shortcuts,
- bool emitUninstallShortcut,
+ std::string const& cpackComponentName, std::string const& featureId,
+ cmWIXShortcuts const& shortcuts, bool emitUninstallShortcut,
cmWIXFilesSourceWriter& fileDefinitions,
cmWIXFeaturesSourceWriter& featureDefinitions)
{
- if(!shortcuts.empty(cmWIXShortcuts::START_MENU))
- {
- if(!this->CreateShortcutsOfSpecificType(cmWIXShortcuts::START_MENU,
- cpackComponentName, featureId, "",
- shortcuts, emitUninstallShortcut,
- fileDefinitions, featureDefinitions))
- {
+ if (!shortcuts.empty(cmWIXShortcuts::START_MENU)) {
+ if (!this->CreateShortcutsOfSpecificType(
+ cmWIXShortcuts::START_MENU, cpackComponentName, featureId, "",
+ shortcuts, emitUninstallShortcut, fileDefinitions,
+ featureDefinitions)) {
return false;
- }
}
+ }
- if(!shortcuts.empty(cmWIXShortcuts::DESKTOP))
- {
- if(!this->CreateShortcutsOfSpecificType(cmWIXShortcuts::DESKTOP,
- cpackComponentName, featureId, "DESKTOP",
- shortcuts, false,
- fileDefinitions, featureDefinitions))
- {
+ if (!shortcuts.empty(cmWIXShortcuts::DESKTOP)) {
+ if (!this->CreateShortcutsOfSpecificType(
+ cmWIXShortcuts::DESKTOP, cpackComponentName, featureId, "DESKTOP",
+ shortcuts, false, fileDefinitions, featureDefinitions)) {
return false;
- }
}
+ }
- if(!shortcuts.empty(cmWIXShortcuts::STARTUP))
- {
- if(!this->CreateShortcutsOfSpecificType(cmWIXShortcuts::STARTUP,
- cpackComponentName, featureId, "STARTUP",
- shortcuts, false,
- fileDefinitions, featureDefinitions))
- {
+ if (!shortcuts.empty(cmWIXShortcuts::STARTUP)) {
+ if (!this->CreateShortcutsOfSpecificType(
+ cmWIXShortcuts::STARTUP, cpackComponentName, featureId, "STARTUP",
+ shortcuts, false, fileDefinitions, featureDefinitions)) {
return false;
- }
}
+ }
return true;
}
bool cmCPackWIXGenerator::CreateShortcutsOfSpecificType(
- cmWIXShortcuts::Type type,
- std::string const& cpackComponentName,
- std::string const& featureId,
- std::string const& idPrefix,
- cmWIXShortcuts const& shortcuts,
- bool emitUninstallShortcut,
+ cmWIXShortcuts::Type type, std::string const& cpackComponentName,
+ std::string const& featureId, std::string const& idPrefix,
+ cmWIXShortcuts const& shortcuts, bool emitUninstallShortcut,
cmWIXFilesSourceWriter& fileDefinitions,
cmWIXFeaturesSourceWriter& featureDefinitions)
{
std::string directoryId;
- switch(type)
- {
+ switch (type) {
case cmWIXShortcuts::START_MENU:
directoryId = "PROGRAM_MENU_FOLDER";
break;
@@ -787,35 +715,31 @@ bool cmCPackWIXGenerator::CreateShortcutsOfSpecificType(
break;
default:
return false;
- }
+ }
featureDefinitions.BeginElement("FeatureRef");
featureDefinitions.AddAttribute("Id", featureId);
std::string cpackVendor;
- if(!RequireOption("CPACK_PACKAGE_VENDOR", cpackVendor))
- {
+ if (!RequireOption("CPACK_PACKAGE_VENDOR", cpackVendor)) {
return false;
- }
+ }
std::string cpackPackageName;
- if(!RequireOption("CPACK_PACKAGE_NAME", cpackPackageName))
- {
+ if (!RequireOption("CPACK_PACKAGE_NAME", cpackPackageName)) {
return false;
- }
+ }
std::string idSuffix;
- if(!cpackComponentName.empty())
- {
- idSuffix += "_";
- idSuffix += cpackComponentName;
- }
+ if (!cpackComponentName.empty()) {
+ idSuffix += "_";
+ idSuffix += cpackComponentName;
+ }
std::string componentId = "CM_SHORTCUT";
- if(idPrefix.size())
- {
+ if (idPrefix.size()) {
componentId += "_" + idPrefix;
- }
+ }
componentId += idSuffix;
@@ -828,22 +752,20 @@ bool cmCPackWIXGenerator::CreateShortcutsOfSpecificType(
this->Patch->ApplyFragment(componentId, fileDefinitions);
- std::string registryKey = std::string("Software\\") +
- cpackVendor + "\\" + cpackPackageName;
+ std::string registryKey =
+ std::string("Software\\") + cpackVendor + "\\" + cpackPackageName;
- shortcuts.EmitShortcuts(type, registryKey,
- cpackComponentName, fileDefinitions);
+ shortcuts.EmitShortcuts(type, registryKey, cpackComponentName,
+ fileDefinitions);
- if(type == cmWIXShortcuts::START_MENU)
- {
- fileDefinitions.EmitRemoveFolder(
- "CM_REMOVE_PROGRAM_MENU_FOLDER" + idSuffix);
- }
+ if (type == cmWIXShortcuts::START_MENU) {
+ fileDefinitions.EmitRemoveFolder("CM_REMOVE_PROGRAM_MENU_FOLDER" +
+ idSuffix);
+ }
- if(emitUninstallShortcut)
- {
+ if (emitUninstallShortcut) {
fileDefinitions.EmitUninstallShortcut(cpackPackageName);
- }
+ }
fileDefinitions.EndElement("Component");
fileDefinitions.EndElement("DirectoryRef");
@@ -857,53 +779,43 @@ bool cmCPackWIXGenerator::CreateShortcutsOfSpecificType(
bool cmCPackWIXGenerator::CreateLicenseFile()
{
std::string licenseSourceFilename;
- if(!RequireOption("CPACK_RESOURCE_FILE_LICENSE", licenseSourceFilename))
- {
+ if (!RequireOption("CPACK_RESOURCE_FILE_LICENSE", licenseSourceFilename)) {
return false;
- }
+ }
std::string licenseDestinationFilename;
- if(!RequireOption("CPACK_WIX_LICENSE_RTF", licenseDestinationFilename))
- {
+ if (!RequireOption("CPACK_WIX_LICENSE_RTF", licenseDestinationFilename)) {
return false;
- }
+ }
std::string extension = GetRightmostExtension(licenseSourceFilename);
- if(extension == ".rtf")
- {
- cmSystemTools::CopyAFile(
- licenseSourceFilename.c_str(),
- licenseDestinationFilename.c_str());
- }
- else if(extension == ".txt")
- {
+ if (extension == ".rtf") {
+ cmSystemTools::CopyAFile(licenseSourceFilename.c_str(),
+ licenseDestinationFilename.c_str());
+ } else if (extension == ".txt") {
cmWIXRichTextFormatWriter rtfWriter(licenseDestinationFilename);
cmsys::ifstream licenseSource(licenseSourceFilename.c_str());
std::string line;
- while(std::getline(licenseSource, line))
- {
+ while (std::getline(licenseSource, line)) {
rtfWriter.AddText(line);
rtfWriter.AddText("\n");
- }
}
- else
- {
+ } else {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "unsupported WiX License file extension '" <<
- extension << "'" << std::endl);
+ "unsupported WiX License file extension '"
+ << extension << "'" << std::endl);
return false;
- }
+ }
return true;
}
void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons(
- std::string const& topdir,
- std::string const& directoryId,
+ std::string const& topdir, std::string const& directoryId,
cmWIXDirectoriesSourceWriter& directoryDefinitions,
cmWIXFilesSourceWriter& fileDefinitions,
cmWIXFeaturesSourceWriter& featureDefinitions,
@@ -917,61 +829,51 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons(
std::string relativeDirectoryPath =
cmSystemTools::RelativePath(toplevel.c_str(), topdir.c_str());
- if(relativeDirectoryPath.empty())
- {
+ if (relativeDirectoryPath.empty()) {
relativeDirectoryPath = ".";
- }
+ }
cmInstalledFile const* directoryInstalledFile = this->GetInstalledFile(
- this->RelativePathWithoutComponentPrefix(relativeDirectoryPath)
- );
+ this->RelativePathWithoutComponentPrefix(relativeDirectoryPath));
bool emptyDirectory = dir.GetNumberOfFiles() == 2;
bool createDirectory = false;
- if(emptyDirectory)
- {
+ if (emptyDirectory) {
createDirectory = true;
- }
+ }
- if(directoryInstalledFile)
- {
- if(directoryInstalledFile->HasProperty("CPACK_WIX_ACL"))
- {
+ if (directoryInstalledFile) {
+ if (directoryInstalledFile->HasProperty("CPACK_WIX_ACL")) {
createDirectory = true;
- }
}
+ }
- if(createDirectory)
- {
+ if (createDirectory) {
std::string componentId = fileDefinitions.EmitComponentCreateFolder(
directoryId, GenerateGUID(), directoryInstalledFile);
featureDefinitions.EmitComponentRef(componentId);
- }
+ }
- if(emptyDirectory)
- {
+ if (emptyDirectory) {
return;
- }
+ }
- for(size_t i = 0; i < dir.GetNumberOfFiles(); ++i)
- {
+ for (size_t i = 0; i < dir.GetNumberOfFiles(); ++i) {
std::string fileName = dir.GetFile(static_cast<unsigned long>(i));
- if(fileName == "." || fileName == "..")
- {
+ if (fileName == "." || fileName == "..") {
continue;
- }
+ }
std::string fullPath = topdir + "/" + fileName;
- std::string relativePath = cmSystemTools::RelativePath(
- toplevel.c_str(), fullPath.c_str());
+ std::string relativePath =
+ cmSystemTools::RelativePath(toplevel.c_str(), fullPath.c_str());
std::string id = PathToId(relativePath);
- if(cmSystemTools::FileIsDirectory(fullPath.c_str()))
- {
+ if (cmSystemTools::FileIsDirectory(fullPath.c_str())) {
std::string subDirectoryId = std::string("CM_D") + id;
directoryDefinitions.BeginElement("Directory");
@@ -979,77 +881,60 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons(
directoryDefinitions.AddAttribute("Name", fileName);
AddDirectoryAndFileDefinitons(
- fullPath, subDirectoryId,
- directoryDefinitions,
- fileDefinitions,
- featureDefinitions,
- packageExecutables,
- desktopExecutables,
- shortcuts);
+ fullPath, subDirectoryId, directoryDefinitions, fileDefinitions,
+ featureDefinitions, packageExecutables, desktopExecutables, shortcuts);
this->Patch->ApplyFragment(subDirectoryId, directoryDefinitions);
directoryDefinitions.EndElement("Directory");
- }
- else
- {
+ } else {
cmInstalledFile const* installedFile = this->GetInstalledFile(
- this->RelativePathWithoutComponentPrefix(relativePath)
- );
+ this->RelativePathWithoutComponentPrefix(relativePath));
- if(installedFile)
- {
+ if (installedFile) {
shortcuts.CreateFromProperties(id, directoryId, *installedFile);
- }
+ }
std::string componentId = fileDefinitions.EmitComponentFile(
directoryId, id, fullPath, *(this->Patch), installedFile);
featureDefinitions.EmitComponentRef(componentId);
- for(size_t j = 0; j < packageExecutables.size(); ++j)
- {
+ for (size_t j = 0; j < packageExecutables.size(); ++j) {
std::string const& executableName = packageExecutables[j++];
std::string const& textLabel = packageExecutables[j];
- if(cmSystemTools::LowerCase(fileName) ==
- cmSystemTools::LowerCase(executableName) + ".exe")
- {
+ if (cmSystemTools::LowerCase(fileName) ==
+ cmSystemTools::LowerCase(executableName) + ".exe") {
cmWIXShortcut shortcut;
- shortcut.label= textLabel;
+ shortcut.label = textLabel;
shortcut.workingDirectoryId = directoryId;
shortcuts.insert(cmWIXShortcuts::START_MENU, id, shortcut);
- if(!desktopExecutables.empty() &&
- std::find(desktopExecutables.begin(),
- desktopExecutables.end(),
- executableName)
- != desktopExecutables.end())
- {
- shortcuts.insert(cmWIXShortcuts::DESKTOP, id, shortcut);
- }
+ if (!desktopExecutables.empty() &&
+ std::find(desktopExecutables.begin(), desktopExecutables.end(),
+ executableName) != desktopExecutables.end()) {
+ shortcuts.insert(cmWIXShortcuts::DESKTOP, id, shortcut);
}
}
}
}
+ }
}
-bool cmCPackWIXGenerator::RequireOption(
- std::string const& name, std::string &value) const
+bool cmCPackWIXGenerator::RequireOption(std::string const& name,
+ std::string& value) const
{
const char* tmp = GetOption(name.c_str());
- if(tmp)
- {
+ if (tmp) {
value = tmp;
return true;
- }
- else
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Required variable " << name << " not set" << std::endl);
+ } else {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Required variable "
+ << name << " not set" << std::endl);
return false;
- }
+ }
}
std::string cmCPackWIXGenerator::GetArchitecture() const
@@ -1057,14 +942,11 @@ std::string cmCPackWIXGenerator::GetArchitecture() const
std::string void_p_size;
RequireOption("CPACK_WIX_SIZEOF_VOID_P", void_p_size);
- if(void_p_size == "8")
- {
+ if (void_p_size == "8") {
return "x64";
- }
- else
- {
+ } else {
return "x86";
- }
+ }
}
std::string cmCPackWIXGenerator::GenerateGUID()
@@ -1072,7 +954,7 @@ std::string cmCPackWIXGenerator::GenerateGUID()
UUID guid;
UuidCreate(&guid);
- unsigned short *tmp = 0;
+ unsigned short* tmp = 0;
UuidToStringW(&guid, &tmp);
std::string result =
@@ -1093,10 +975,9 @@ std::string cmCPackWIXGenerator::GetRightmostExtension(
std::string extension;
std::string::size_type i = filename.rfind(".");
- if(i != std::string::npos)
- {
+ if (i != std::string::npos) {
extension = filename.substr(i);
- }
+ }
return cmSystemTools::LowerCase(extension);
}
@@ -1104,7 +985,8 @@ std::string cmCPackWIXGenerator::GetRightmostExtension(
std::string cmCPackWIXGenerator::PathToId(std::string const& path)
{
id_map_t::const_iterator i = PathToIdMap.find(path);
- if(i != PathToIdMap.end()) return i->second;
+ if (i != PathToIdMap.end())
+ return i->second;
std::string id = CreateNewIdForPath(path);
return id;
@@ -1120,41 +1002,37 @@ std::string cmCPackWIXGenerator::CreateNewIdForPath(std::string const& path)
std::string identifier;
std::string currentComponent;
- for(size_t i = 1; i < components.size(); ++i)
- {
- if(i != 1) identifier += '.';
+ for (size_t i = 1; i < components.size(); ++i) {
+ if (i != 1)
+ identifier += '.';
- currentComponent = NormalizeComponentForId(
- components[i], replacementCount);
+ currentComponent =
+ NormalizeComponentForId(components[i], replacementCount);
identifier += currentComponent;
- }
+ }
std::string idPrefix = "P";
size_t replacementPercent = replacementCount * 100 / identifier.size();
- if(replacementPercent > 33 || identifier.size() > 60)
- {
+ if (replacementPercent > 33 || identifier.size() > 60) {
identifier = CreateHashedId(path, currentComponent);
idPrefix = "H";
- }
+ }
std::stringstream result;
result << idPrefix << "_" << identifier;
size_t ambiguityCount = ++IdAmbiguityCounter[identifier];
- if(ambiguityCount > 999)
- {
+ if (ambiguityCount > 999) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error while trying to generate a unique Id for '" <<
- path << "'" << std::endl);
+ "Error while trying to generate a unique Id for '"
+ << path << "'" << std::endl);
return std::string();
- }
- else if(ambiguityCount > 1)
- {
+ } else if (ambiguityCount > 1) {
result << "_" << ambiguityCount;
- }
+ }
std::string resultString = result.str();
@@ -1173,15 +1051,12 @@ std::string cmCPackWIXGenerator::CreateHashedId(
identifier += hash.substr(0, 7) + "_";
const size_t maxFileNameLength = 52;
- if(normalizedFilename.length() > maxFileNameLength)
- {
+ if (normalizedFilename.length() > maxFileNameLength) {
identifier += normalizedFilename.substr(0, maxFileNameLength - 3);
identifier += "...";
- }
- else
- {
+ } else {
identifier += normalizedFilename;
- }
+ }
return identifier;
}
@@ -1192,65 +1067,59 @@ std::string cmCPackWIXGenerator::NormalizeComponentForId(
std::string result;
result.resize(component.size());
- for(size_t i = 0; i < component.size(); ++i)
- {
+ for (size_t i = 0; i < component.size(); ++i) {
char c = component[i];
- if(IsLegalIdCharacter(c))
- {
+ if (IsLegalIdCharacter(c)) {
result[i] = c;
- }
- else
- {
+ } else {
result[i] = '_';
- ++ replacementCount;
- }
+ ++replacementCount;
}
+ }
return result;
}
bool cmCPackWIXGenerator::IsLegalIdCharacter(char c)
{
- return (c >= '0' && c <= '9') ||
- (c >= 'a' && c <= 'z') ||
- (c >= 'A' && c <= 'Z') ||
- c == '_' || c == '.';
+ return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') ||
+ (c >= 'A' && c <= 'Z') || c == '_' || c == '.';
}
-void cmCPackWIXGenerator::CollectExtensions(
- std::string const& variableName, extension_set_t& extensions)
+void cmCPackWIXGenerator::CollectExtensions(std::string const& variableName,
+ extension_set_t& extensions)
{
- const char *variableContent = GetOption(variableName.c_str());
- if(!variableContent) return;
+ const char* variableContent = GetOption(variableName.c_str());
+ if (!variableContent)
+ return;
std::vector<std::string> list;
cmSystemTools::ExpandListArgument(variableContent, list);
extensions.insert(list.begin(), list.end());
}
-void cmCPackWIXGenerator::AddCustomFlags(
- std::string const& variableName, std::ostream& stream)
+void cmCPackWIXGenerator::AddCustomFlags(std::string const& variableName,
+ std::ostream& stream)
{
- const char *variableContent = GetOption(variableName.c_str());
- if(!variableContent) return;
+ const char* variableContent = GetOption(variableName.c_str());
+ if (!variableContent)
+ return;
std::vector<std::string> list;
cmSystemTools::ExpandListArgument(variableContent, list);
- for(std::vector<std::string>::const_iterator i = list.begin();
- i != list.end(); ++i)
- {
- stream << " " << QuotePath(*i);
- }
+ for (std::vector<std::string>::const_iterator i = list.begin();
+ i != list.end(); ++i) {
+ stream << " " << QuotePath(*i);
+ }
}
std::string cmCPackWIXGenerator::RelativePathWithoutComponentPrefix(
std::string const& path)
{
- if(this->Components.empty())
- {
+ if (this->Components.empty()) {
return path;
- }
+ }
std::string::size_type pos = path.find('/');
diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.h b/Source/CPack/WiX/cmCPackWIXGenerator.h
index 871527b..9d3a522 100644
--- a/Source/CPack/WiX/cmCPackWIXGenerator.h
+++ b/Source/CPack/WiX/cmCPackWIXGenerator.h
@@ -42,25 +42,16 @@ protected:
virtual int PackageFiles();
- virtual const char* GetOutputExtension()
- {
- return ".msi";
- }
+ virtual const char* GetOutputExtension() { return ".msi"; }
virtual enum CPackSetDestdirSupport SupportsSetDestdir() const
- {
+ {
return SETDESTDIR_UNSUPPORTED;
- }
+ }
- virtual bool SupportsAbsoluteDestination() const
- {
- return false;
- }
+ virtual bool SupportsAbsoluteDestination() const { return false; }
- virtual bool SupportsComponentInstallation() const
- {
- return true;
- }
+ virtual bool SupportsComponentInstallation() const { return true; }
private:
typedef std::map<std::string, std::string> id_map_t;
@@ -77,11 +68,10 @@ private:
void CreateWiXProductFragmentIncludeFile();
- void CopyDefinition(
- cmWIXSourceWriter &source, std::string const& name);
+ void CopyDefinition(cmWIXSourceWriter& source, std::string const& name);
- void AddDefinition(cmWIXSourceWriter& source,
- std::string const& name, std::string const& value);
+ void AddDefinition(cmWIXSourceWriter& source, std::string const& name,
+ std::string const& value);
bool CreateWiXSourceFiles();
@@ -89,32 +79,25 @@ private:
bool GenerateMainSourceFileFromTemplate();
- bool CreateFeatureHierarchy(
- cmWIXFeaturesSourceWriter& featureDefinitions);
+ bool CreateFeatureHierarchy(cmWIXFeaturesSourceWriter& featureDefinitions);
bool AddComponentsToFeature(
- std::string const& rootPath,
- std::string const& featureId,
+ std::string const& rootPath, std::string const& featureId,
cmWIXDirectoriesSourceWriter& directoryDefinitions,
cmWIXFilesSourceWriter& fileDefinitions,
- cmWIXFeaturesSourceWriter& featureDefinitions,
- cmWIXShortcuts& shortcuts);
+ cmWIXFeaturesSourceWriter& featureDefinitions, cmWIXShortcuts& shortcuts);
- bool CreateShortcuts(
- std::string const& cpackComponentName,
- std::string const& featureId,
- cmWIXShortcuts const& shortcuts,
- bool emitUninstallShortcut,
- cmWIXFilesSourceWriter& fileDefinitions,
- cmWIXFeaturesSourceWriter& featureDefinitions);
+ bool CreateShortcuts(std::string const& cpackComponentName,
+ std::string const& featureId,
+ cmWIXShortcuts const& shortcuts,
+ bool emitUninstallShortcut,
+ cmWIXFilesSourceWriter& fileDefinitions,
+ cmWIXFeaturesSourceWriter& featureDefinitions);
bool CreateShortcutsOfSpecificType(
- cmWIXShortcuts::Type type,
- std::string const& cpackComponentName,
- std::string const& featureId,
- std::string const& idPrefix,
- cmWIXShortcuts const& shortcuts,
- bool emitUninstallShortcut,
+ cmWIXShortcuts::Type type, std::string const& cpackComponentName,
+ std::string const& featureId, std::string const& idPrefix,
+ cmWIXShortcuts const& shortcuts, bool emitUninstallShortcut,
cmWIXFilesSourceWriter& fileDefinitions,
cmWIXFeaturesSourceWriter& featureDefinitions);
@@ -126,13 +109,13 @@ private:
bool RunWiXCommand(std::string const& command);
- bool RunCandleCommand(
- std::string const& sourceFile, std::string const& objectFile);
+ bool RunCandleCommand(std::string const& sourceFile,
+ std::string const& objectFile);
bool RunLightCommand(std::string const& objectFiles);
- void AddDirectoryAndFileDefinitons(std::string const& topdir,
- std::string const& directoryId,
+ void AddDirectoryAndFileDefinitons(
+ std::string const& topdir, std::string const& directoryId,
cmWIXDirectoriesSourceWriter& directoryDefinitions,
cmWIXFilesSourceWriter& fileDefinitions,
cmWIXFeaturesSourceWriter& featureDefinitions,
@@ -154,22 +137,20 @@ private:
std::string CreateNewIdForPath(std::string const& path);
- static std::string CreateHashedId(
- std::string const& path, std::string const& normalizedFilename);
+ static std::string CreateHashedId(std::string const& path,
+ std::string const& normalizedFilename);
- std::string NormalizeComponentForId(
- std::string const& component, size_t& replacementCount);
+ std::string NormalizeComponentForId(std::string const& component,
+ size_t& replacementCount);
static bool IsLegalIdCharacter(char c);
- void CollectExtensions(
- std::string const& variableName, extension_set_t& extensions);
+ void CollectExtensions(std::string const& variableName,
+ extension_set_t& extensions);
- void AddCustomFlags(
- std::string const& variableName, std::ostream& stream);
+ void AddCustomFlags(std::string const& variableName, std::ostream& stream);
- std::string RelativePathWithoutComponentPrefix(
- std::string const& path);
+ std::string RelativePathWithoutComponentPrefix(std::string const& path);
std::vector<std::string> WixSources;
id_map_t PathToIdMap;
diff --git a/Source/CPack/WiX/cmWIXAccessControlList.cxx b/Source/CPack/WiX/cmWIXAccessControlList.cxx
index 16a71e0..043cdff 100644
--- a/Source/CPack/WiX/cmWIXAccessControlList.cxx
+++ b/Source/CPack/WiX/cmWIXAccessControlList.cxx
@@ -17,14 +17,12 @@
#include <cmSystemTools.h>
cmWIXAccessControlList::cmWIXAccessControlList(
- cmCPackLog *logger,
- cmInstalledFile const& installedFile,
- cmWIXSourceWriter &sourceWriter):
- Logger(logger),
- InstalledFile(installedFile),
- SourceWriter(sourceWriter)
+ cmCPackLog* logger, cmInstalledFile const& installedFile,
+ cmWIXSourceWriter& sourceWriter)
+ : Logger(logger)
+ , InstalledFile(installedFile)
+ , SourceWriter(sourceWriter)
{
-
}
bool cmWIXAccessControlList::Apply()
@@ -32,23 +30,20 @@ bool cmWIXAccessControlList::Apply()
std::vector<std::string> entries;
this->InstalledFile.GetPropertyAsList("CPACK_WIX_ACL", entries);
- for(size_t i = 0; i < entries.size(); ++i)
- {
+ for (size_t i = 0; i < entries.size(); ++i) {
this->CreatePermissionElement(entries[i]);
- }
+ }
return true;
}
-void cmWIXAccessControlList::CreatePermissionElement(
- std::string const& entry)
+void cmWIXAccessControlList::CreatePermissionElement(std::string const& entry)
{
std::string::size_type pos = entry.find('=');
- if(pos == std::string::npos)
- {
+ if (pos == std::string::npos) {
this->ReportError(entry, "Did not find mandatory '='");
return;
- }
+ }
std::string user_and_domain = entry.substr(0, pos);
std::string permission_string = entry.substr(pos + 1);
@@ -56,46 +51,38 @@ void cmWIXAccessControlList::CreatePermissionElement(
pos = user_and_domain.find('@');
std::string user;
std::string domain;
- if(pos != std::string::npos)
- {
+ if (pos != std::string::npos) {
user = user_and_domain.substr(0, pos);
domain = user_and_domain.substr(pos + 1);
- }
- else
- {
+ } else {
user = user_and_domain;
- }
+ }
std::vector<std::string> permissions =
cmSystemTools::tokenize(permission_string, ",");
this->SourceWriter.BeginElement("Permission");
this->SourceWriter.AddAttribute("User", user);
- if(!domain.empty())
- {
+ if (!domain.empty()) {
this->SourceWriter.AddAttribute("Domain", domain);
- }
- for(size_t i = 0; i < permissions.size(); ++i)
- {
+ }
+ for (size_t i = 0; i < permissions.size(); ++i) {
this->EmitBooleanAttribute(entry,
- cmSystemTools::TrimWhitespace(permissions[i]));
- }
+ cmSystemTools::TrimWhitespace(permissions[i]));
+ }
this->SourceWriter.EndElement("Permission");
}
-void cmWIXAccessControlList::ReportError(
- std::string const& entry,
- std::string const& message)
+void cmWIXAccessControlList::ReportError(std::string const& entry,
+ std::string const& message)
{
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Failed processing ACL entry '" << entry <<
- "': " << message << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Failed processing ACL entry '"
+ << entry << "': " << message << std::endl);
}
bool cmWIXAccessControlList::IsBooleanAttribute(std::string const& name)
{
- static const char* validAttributes[] =
- {
+ static const char* validAttributes[] = {
/* clang-format needs this comment to break after the opening brace */
"Append",
"ChangePermission",
@@ -128,23 +115,22 @@ bool cmWIXAccessControlList::IsBooleanAttribute(std::string const& name)
};
size_t i = 0;
- while(validAttributes[i])
- {
- if(name == validAttributes[i++]) return true;
- }
+ while (validAttributes[i]) {
+ if (name == validAttributes[i++])
+ return true;
+ }
return false;
}
-void cmWIXAccessControlList::EmitBooleanAttribute(
- std::string const& entry, std::string const& name)
+void cmWIXAccessControlList::EmitBooleanAttribute(std::string const& entry,
+ std::string const& name)
{
- if(!this->IsBooleanAttribute(name))
- {
+ if (!this->IsBooleanAttribute(name)) {
std::stringstream message;
message << "Unknown boolean attribute '" << name << "'";
this->ReportError(entry, message.str());
- }
+ }
this->SourceWriter.AddAttribute(name, "yes");
}
diff --git a/Source/CPack/WiX/cmWIXAccessControlList.h b/Source/CPack/WiX/cmWIXAccessControlList.h
index 7293995..a1ac593 100644
--- a/Source/CPack/WiX/cmWIXAccessControlList.h
+++ b/Source/CPack/WiX/cmWIXAccessControlList.h
@@ -21,10 +21,9 @@
class cmWIXAccessControlList
{
public:
- cmWIXAccessControlList(
- cmCPackLog *logger,
- cmInstalledFile const& installedFile,
- cmWIXSourceWriter &sourceWriter);
+ cmWIXAccessControlList(cmCPackLog* logger,
+ cmInstalledFile const& installedFile,
+ cmWIXSourceWriter& sourceWriter);
bool Apply();
@@ -35,12 +34,11 @@ private:
bool IsBooleanAttribute(std::string const& name);
- void EmitBooleanAttribute(
- std::string const& entry, std::string const& name);
+ void EmitBooleanAttribute(std::string const& entry, std::string const& name);
cmCPackLog* Logger;
cmInstalledFile const& InstalledFile;
- cmWIXSourceWriter &SourceWriter;
+ cmWIXSourceWriter& SourceWriter;
};
#endif
diff --git a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx
index 7bd4315..60ecae6 100644
--- a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx
+++ b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx
@@ -12,11 +12,10 @@
#include "cmWIXDirectoriesSourceWriter.h"
-cmWIXDirectoriesSourceWriter::cmWIXDirectoriesSourceWriter(cmCPackLog* logger,
- std::string const& filename):
- cmWIXSourceWriter(logger, filename)
+cmWIXDirectoriesSourceWriter::cmWIXDirectoriesSourceWriter(
+ cmCPackLog* logger, std::string const& filename)
+ : cmWIXSourceWriter(logger, filename)
{
-
}
void cmWIXDirectoriesSourceWriter::EmitStartMenuFolder(
@@ -60,25 +59,20 @@ size_t cmWIXDirectoriesSourceWriter::BeginInstallationPrefixDirectory(
cmSystemTools::SplitPath(installRootString.c_str(), installRoot);
- if(!installRoot.empty() && installRoot.back().empty())
- {
+ if (!installRoot.empty() && installRoot.back().empty()) {
installRoot.pop_back();
- }
+ }
- for(size_t i = 1; i < installRoot.size(); ++i)
- {
+ for (size_t i = 1; i < installRoot.size(); ++i) {
BeginElement("Directory");
- if(i == installRoot.size() - 1)
- {
+ if (i == installRoot.size() - 1) {
AddAttribute("Id", "INSTALL_ROOT");
- }
- else
- {
+ } else {
std::stringstream tmp;
tmp << "INSTALL_PREFIX_" << i;
AddAttribute("Id", tmp.str());
- }
+ }
AddAttribute("Name", installRoot[i]);
}
@@ -88,8 +82,7 @@ size_t cmWIXDirectoriesSourceWriter::BeginInstallationPrefixDirectory(
void cmWIXDirectoriesSourceWriter::EndInstallationPrefixDirectory(size_t size)
{
- for(size_t i = 0; i < size; ++i)
- {
+ for (size_t i = 0; i < size; ++i) {
EndElement("Directory");
- }
+ }
}
diff --git a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h
index f8c8166..023f4b8 100644
--- a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h
+++ b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h
@@ -26,7 +26,7 @@ class cmWIXDirectoriesSourceWriter : public cmWIXSourceWriter
{
public:
cmWIXDirectoriesSourceWriter(cmCPackLog* logger,
- std::string const& filename);
+ std::string const& filename);
void EmitStartMenuFolder(std::string const& startMenuFolder);
@@ -35,8 +35,8 @@ public:
void EmitStartupFolder();
size_t BeginInstallationPrefixDirectory(
- std::string const& programFilesFolderId,
- std::string const& installRootString);
+ std::string const& programFilesFolderId,
+ std::string const& installRootString);
void EndInstallationPrefixDirectory(size_t size);
};
diff --git a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx
index 0bcfc38..16dd0ab 100644
--- a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx
+++ b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx
@@ -12,16 +12,14 @@
#include "cmWIXFeaturesSourceWriter.h"
-cmWIXFeaturesSourceWriter::cmWIXFeaturesSourceWriter(cmCPackLog* logger,
- std::string const& filename):
- cmWIXSourceWriter(logger, filename)
+cmWIXFeaturesSourceWriter::cmWIXFeaturesSourceWriter(
+ cmCPackLog* logger, std::string const& filename)
+ : cmWIXSourceWriter(logger, filename)
{
-
}
void cmWIXFeaturesSourceWriter::CreateCMakePackageRegistryEntry(
- std::string const& package,
- std::string const& upgradeGuid)
+ std::string const& package, std::string const& upgradeGuid)
{
BeginElement("Component");
AddAttribute("Id", "CM_PACKAGE_REGISTRY");
@@ -29,7 +27,7 @@ void cmWIXFeaturesSourceWriter::CreateCMakePackageRegistryEntry(
AddAttribute("Guid", "*");
std::string registryKey =
- std::string("Software\\Kitware\\CMake\\Packages\\") + package;
+ std::string("Software\\Kitware\\CMake\\Packages\\") + package;
BeginElement("RegistryValue");
AddAttribute("Root", "HKLM");
@@ -49,25 +47,24 @@ void cmWIXFeaturesSourceWriter::EmitFeatureForComponentGroup(
BeginElement("Feature");
AddAttribute("Id", "CM_G_" + group.Name);
- if(group.IsExpandedByDefault)
- {
+ if (group.IsExpandedByDefault) {
AddAttribute("Display", "expand");
- }
+ }
AddAttributeUnlessEmpty("Title", group.DisplayName);
AddAttributeUnlessEmpty("Description", group.Description);
- for(std::vector<cmCPackComponentGroup*>::const_iterator
- i = group.Subgroups.begin(); i != group.Subgroups.end(); ++i)
- {
+ for (std::vector<cmCPackComponentGroup*>::const_iterator i =
+ group.Subgroups.begin();
+ i != group.Subgroups.end(); ++i) {
EmitFeatureForComponentGroup(**i);
- }
+ }
- for(std::vector<cmCPackComponent*>::const_iterator
- i = group.Components.begin(); i != group.Components.end(); ++i)
- {
+ for (std::vector<cmCPackComponent*>::const_iterator i =
+ group.Components.begin();
+ i != group.Components.end(); ++i) {
EmitFeatureForComponent(**i);
- }
+ }
EndElement("Feature");
}
@@ -81,15 +78,13 @@ void cmWIXFeaturesSourceWriter::EmitFeatureForComponent(
AddAttributeUnlessEmpty("Title", component.DisplayName);
AddAttributeUnlessEmpty("Description", component.Description);
- if(component.IsRequired)
- {
+ if (component.IsRequired) {
AddAttribute("Absent", "disallow");
- }
+ }
- if(component.IsHidden)
- {
+ if (component.IsHidden) {
AddAttribute("Display", "hidden");
- }
+ }
EndElement("Feature");
}
diff --git a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.h b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.h
index ff12e6c..ee9c17a 100644
--- a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.h
+++ b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.h
@@ -23,12 +23,10 @@
class cmWIXFeaturesSourceWriter : public cmWIXSourceWriter
{
public:
- cmWIXFeaturesSourceWriter(cmCPackLog* logger,
- std::string const& filename);
+ cmWIXFeaturesSourceWriter(cmCPackLog* logger, std::string const& filename);
- void CreateCMakePackageRegistryEntry(
- std::string const& package,
- std::string const& upgradeGuid);
+ void CreateCMakePackageRegistryEntry(std::string const& package,
+ std::string const& upgradeGuid);
void EmitFeatureForComponentGroup(const cmCPackComponentGroup& group);
diff --git a/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx
index 2833d53..1341fa5 100644
--- a/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx
+++ b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx
@@ -21,25 +21,22 @@
#include <sys/stat.h>
cmWIXFilesSourceWriter::cmWIXFilesSourceWriter(cmCPackLog* logger,
- std::string const& filename):
- cmWIXSourceWriter(logger, filename)
+ std::string const& filename)
+ : cmWIXSourceWriter(logger, filename)
{
-
}
-void cmWIXFilesSourceWriter::EmitShortcut(
- std::string const& id,
- cmWIXShortcut const& shortcut,
- std::string const& shortcutPrefix,
- size_t shortcutIndex)
+void cmWIXFilesSourceWriter::EmitShortcut(std::string const& id,
+ cmWIXShortcut const& shortcut,
+ std::string const& shortcutPrefix,
+ size_t shortcutIndex)
{
std::stringstream shortcutId;
shortcutId << shortcutPrefix << id;
- if(shortcutIndex > 0)
- {
- shortcutId << "_" << shortcutIndex;
- }
+ if (shortcutIndex > 0) {
+ shortcutId << "_" << shortcutIndex;
+ }
std::string fileId = std::string("CM_F") + id;
@@ -61,15 +58,13 @@ void cmWIXFilesSourceWriter::EmitRemoveFolder(std::string const& id)
}
void cmWIXFilesSourceWriter::EmitInstallRegistryValue(
- std::string const& registryKey,
- std::string const& cpackComponentName,
+ std::string const& registryKey, std::string const& cpackComponentName,
std::string const& suffix)
{
std::string valueName;
- if(!cpackComponentName.empty())
- {
- valueName = cpackComponentName + "_";
- }
+ if (!cpackComponentName.empty()) {
+ valueName = cpackComponentName + "_";
+ }
valueName += "installed";
valueName += suffix;
@@ -97,12 +92,10 @@ void cmWIXFilesSourceWriter::EmitUninstallShortcut(
}
std::string cmWIXFilesSourceWriter::EmitComponentCreateFolder(
- std::string const& directoryId,
- std::string const& guid,
+ std::string const& directoryId, std::string const& guid,
cmInstalledFile const* installedFile)
{
- std::string componentId =
- std::string("CM_C_EMPTY_") + directoryId;
+ std::string componentId = std::string("CM_C_EMPTY_") + directoryId;
BeginElement("DirectoryRef");
AddAttribute("Id", directoryId);
@@ -113,11 +106,10 @@ std::string cmWIXFilesSourceWriter::EmitComponentCreateFolder(
BeginElement("CreateFolder");
- if(installedFile)
- {
+ if (installedFile) {
cmWIXAccessControlList acl(Logger, *installedFile, *this);
acl.Apply();
- }
+ }
EndElement("CreateFolder");
EndElement("Component");
@@ -127,10 +119,8 @@ std::string cmWIXFilesSourceWriter::EmitComponentCreateFolder(
}
std::string cmWIXFilesSourceWriter::EmitComponentFile(
- std::string const& directoryId,
- std::string const& id,
- std::string const& filePath,
- cmWIXPatch &patch,
+ std::string const& directoryId, std::string const& id,
+ std::string const& filePath, cmWIXPatch& patch,
cmInstalledFile const* installedFile)
{
std::string componentId = std::string("CM_C") + id;
@@ -143,17 +133,14 @@ std::string cmWIXFilesSourceWriter::EmitComponentFile(
AddAttribute("Id", componentId);
AddAttribute("Guid", "*");
- if(installedFile)
- {
- if(installedFile->GetPropertyAsBool("CPACK_NEVER_OVERWRITE"))
- {
+ if (installedFile) {
+ if (installedFile->GetPropertyAsBool("CPACK_NEVER_OVERWRITE")) {
AddAttribute("NeverOverwrite", "yes");
- }
- if(installedFile->GetPropertyAsBool("CPACK_PERMANENT"))
- {
+ }
+ if (installedFile->GetPropertyAsBool("CPACK_PERMANENT")) {
AddAttribute("Permanent", "yes");
- }
}
+ }
BeginElement("File");
AddAttribute("Id", fileId);
@@ -163,16 +150,14 @@ std::string cmWIXFilesSourceWriter::EmitComponentFile(
mode_t fileMode = 0;
cmSystemTools::GetPermissions(filePath.c_str(), fileMode);
- if(!(fileMode & S_IWRITE))
- {
+ if (!(fileMode & S_IWRITE)) {
AddAttribute("ReadOnly", "yes");
- }
+ }
- if(installedFile)
- {
+ if (installedFile) {
cmWIXAccessControlList acl(Logger, *installedFile, *this);
acl.Apply();
- }
+ }
patch.ApplyFragment(fileId, *this);
EndElement("File");
diff --git a/Source/CPack/WiX/cmWIXFilesSourceWriter.h b/Source/CPack/WiX/cmWIXFilesSourceWriter.h
index 734f901..c577e5b 100644
--- a/Source/CPack/WiX/cmWIXFilesSourceWriter.h
+++ b/Source/CPack/WiX/cmWIXFilesSourceWriter.h
@@ -26,36 +26,27 @@
class cmWIXFilesSourceWriter : public cmWIXSourceWriter
{
public:
- cmWIXFilesSourceWriter(cmCPackLog* logger,
- std::string const& filename);
+ cmWIXFilesSourceWriter(cmCPackLog* logger, std::string const& filename);
- void EmitShortcut(
- std::string const& id,
- cmWIXShortcut const& shortcut,
- std::string const& shortcutPrefix,
- size_t shortcutIndex);
+ void EmitShortcut(std::string const& id, cmWIXShortcut const& shortcut,
+ std::string const& shortcutPrefix, size_t shortcutIndex);
void EmitRemoveFolder(std::string const& id);
- void EmitInstallRegistryValue(
- std::string const& registryKey,
- std::string const& cpackComponentName,
- std::string const& suffix);
+ void EmitInstallRegistryValue(std::string const& registryKey,
+ std::string const& cpackComponentName,
+ std::string const& suffix);
void EmitUninstallShortcut(std::string const& packageName);
- std::string EmitComponentCreateFolder(
- std::string const& directoryId,
- std::string const& guid,
- cmInstalledFile const* installedFile);
-
- std::string EmitComponentFile(
- std::string const& directoryId,
- std::string const& id,
- std::string const& filePath,
- cmWIXPatch &patch,
- cmInstalledFile const* installedFile);
-};
+ std::string EmitComponentCreateFolder(std::string const& directoryId,
+ std::string const& guid,
+ cmInstalledFile const* installedFile);
+ std::string EmitComponentFile(std::string const& directoryId,
+ std::string const& id,
+ std::string const& filePath, cmWIXPatch& patch,
+ cmInstalledFile const* installedFile);
+};
#endif
diff --git a/Source/CPack/WiX/cmWIXPatch.cxx b/Source/CPack/WiX/cmWIXPatch.cxx
index 07375da..c9d010e 100644
--- a/Source/CPack/WiX/cmWIXPatch.cxx
+++ b/Source/CPack/WiX/cmWIXPatch.cxx
@@ -14,31 +14,29 @@
#include <CPack/cmCPackGenerator.h>
-cmWIXPatch::cmWIXPatch(cmCPackLog* logger):
- Logger(logger)
+cmWIXPatch::cmWIXPatch(cmCPackLog* logger)
+ : Logger(logger)
{
-
}
bool cmWIXPatch::LoadFragments(std::string const& patchFilePath)
{
cmWIXPatchParser parser(Fragments, Logger);
- if(!parser.ParseFile(patchFilePath.c_str()))
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Failed parsing XML patch file: '" <<
- patchFilePath << "'" << std::endl);
+ if (!parser.ParseFile(patchFilePath.c_str())) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Failed parsing XML patch file: '"
+ << patchFilePath << "'" << std::endl);
return false;
- }
+ }
return true;
}
-void cmWIXPatch::ApplyFragment(
- std::string const& id, cmWIXSourceWriter& writer)
+void cmWIXPatch::ApplyFragment(std::string const& id,
+ cmWIXSourceWriter& writer)
{
cmWIXPatchParser::fragment_map_t::iterator i = Fragments.find(id);
- if(i == Fragments.end()) return;
+ if (i == Fragments.end())
+ return;
const cmWIXPatchElement& fragment = i->second;
@@ -47,36 +45,35 @@ void cmWIXPatch::ApplyFragment(
Fragments.erase(i);
}
-void cmWIXPatch::ApplyElementChildren(
- const cmWIXPatchElement& element, cmWIXSourceWriter& writer)
+void cmWIXPatch::ApplyElementChildren(const cmWIXPatchElement& element,
+ cmWIXSourceWriter& writer)
{
- for(cmWIXPatchElement::child_list_t::const_iterator
- j = element.children.begin(); j != element.children.end(); ++j)
- {
- cmWIXPatchNode *node = *j;
-
- switch(node->type())
- {
- case cmWIXPatchNode::ELEMENT:
- ApplyElement(dynamic_cast<const cmWIXPatchElement&>(*node), writer);
- break;
- case cmWIXPatchNode::TEXT:
- writer.AddTextNode(dynamic_cast<const cmWIXPatchText&>(*node).text);
- break;
+ for (cmWIXPatchElement::child_list_t::const_iterator j =
+ element.children.begin();
+ j != element.children.end(); ++j) {
+ cmWIXPatchNode* node = *j;
+
+ switch (node->type()) {
+ case cmWIXPatchNode::ELEMENT:
+ ApplyElement(dynamic_cast<const cmWIXPatchElement&>(*node), writer);
+ break;
+ case cmWIXPatchNode::TEXT:
+ writer.AddTextNode(dynamic_cast<const cmWIXPatchText&>(*node).text);
+ break;
}
}
}
-void cmWIXPatch::ApplyElement(
- const cmWIXPatchElement& element, cmWIXSourceWriter& writer)
+void cmWIXPatch::ApplyElement(const cmWIXPatchElement& element,
+ cmWIXSourceWriter& writer)
{
writer.BeginElement(element.name);
- for(cmWIXPatchElement::attributes_t::const_iterator
- i = element.attributes.begin(); i != element.attributes.end(); ++i)
- {
+ for (cmWIXPatchElement::attributes_t::const_iterator i =
+ element.attributes.begin();
+ i != element.attributes.end(); ++i) {
writer.AddAttribute(i->first, i->second);
- }
+ }
this->ApplyElementChildren(element, writer);
@@ -86,26 +83,23 @@ void cmWIXPatch::ApplyElement(
bool cmWIXPatch::CheckForUnappliedFragments()
{
std::string fragmentList;
- for(cmWIXPatchParser::fragment_map_t::const_iterator
- i = Fragments.begin(); i != Fragments.end(); ++i)
- {
- if(!fragmentList.empty())
- {
+ for (cmWIXPatchParser::fragment_map_t::const_iterator i = Fragments.begin();
+ i != Fragments.end(); ++i) {
+ if (!fragmentList.empty()) {
fragmentList += ", ";
- }
+ }
fragmentList += "'";
fragmentList += i->first;
fragmentList += "'";
- }
+ }
- if(!fragmentList.empty())
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Some XML patch fragments did not have matching IDs: " <<
- fragmentList << std::endl);
- return false;
- }
+ if (!fragmentList.empty()) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Some XML patch fragments did not have matching IDs: "
+ << fragmentList << std::endl);
+ return false;
+ }
return true;
}
diff --git a/Source/CPack/WiX/cmWIXPatch.h b/Source/CPack/WiX/cmWIXPatch.h
index 5b0eb3b..57b74cd 100644
--- a/Source/CPack/WiX/cmWIXPatch.h
+++ b/Source/CPack/WiX/cmWIXPatch.h
@@ -34,15 +34,14 @@ public:
private:
void ApplyElementChildren(const cmWIXPatchElement& element,
- cmWIXSourceWriter& writer);
+ cmWIXSourceWriter& writer);
void ApplyElement(const cmWIXPatchElement& element,
- cmWIXSourceWriter& writer);
+ cmWIXSourceWriter& writer);
cmCPackLog* Logger;
cmWIXPatchParser::fragment_map_t Fragments;
};
-
#endif
diff --git a/Source/CPack/WiX/cmWIXPatchParser.cxx b/Source/CPack/WiX/cmWIXPatchParser.cxx
index 14c5413..b750dcf 100644
--- a/Source/CPack/WiX/cmWIXPatchParser.cxx
+++ b/Source/CPack/WiX/cmWIXPatchParser.cxx
@@ -28,149 +28,124 @@ cmWIXPatchNode::Type cmWIXPatchElement::type()
cmWIXPatchNode::~cmWIXPatchNode()
{
-
}
cmWIXPatchElement::~cmWIXPatchElement()
{
- for(child_list_t::iterator i = children.begin(); i != children.end(); ++i)
- {
+ for (child_list_t::iterator i = children.begin(); i != children.end(); ++i) {
delete *i;
- }
+ }
}
-cmWIXPatchParser::cmWIXPatchParser(
- fragment_map_t& fragments, cmCPackLog* logger):
- Logger(logger),
- State(BEGIN_DOCUMENT),
- Valid(true),
- Fragments(fragments)
+cmWIXPatchParser::cmWIXPatchParser(fragment_map_t& fragments,
+ cmCPackLog* logger)
+ : Logger(logger)
+ , State(BEGIN_DOCUMENT)
+ , Valid(true)
+ , Fragments(fragments)
{
-
}
-void cmWIXPatchParser::StartElement(const std::string& name, const char **atts)
+void cmWIXPatchParser::StartElement(const std::string& name, const char** atts)
{
- if(State == BEGIN_DOCUMENT)
- {
- if(name == "CPackWiXPatch")
- {
+ if (State == BEGIN_DOCUMENT) {
+ if (name == "CPackWiXPatch") {
State = BEGIN_FRAGMENTS;
- }
- else
- {
+ } else {
ReportValidationError("Expected root element 'CPackWiXPatch'");
- }
}
- else if(State == BEGIN_FRAGMENTS)
- {
- if(name == "CPackWiXFragment")
- {
- State = INSIDE_FRAGMENT;
- StartFragment(atts);
- }
- else
- {
- ReportValidationError("Expected 'CPackWixFragment' element");
- }
+ } else if (State == BEGIN_FRAGMENTS) {
+ if (name == "CPackWiXFragment") {
+ State = INSIDE_FRAGMENT;
+ StartFragment(atts);
+ } else {
+ ReportValidationError("Expected 'CPackWixFragment' element");
}
- else if(State == INSIDE_FRAGMENT)
- {
- cmWIXPatchElement &parent = *ElementStack.back();
-
- cmWIXPatchElement *element = new cmWIXPatchElement;
- parent.children.push_back(element);
+ } else if (State == INSIDE_FRAGMENT) {
+ cmWIXPatchElement& parent = *ElementStack.back();
- element->name = name;
+ cmWIXPatchElement* element = new cmWIXPatchElement;
+ parent.children.push_back(element);
- for(size_t i = 0; atts[i]; i += 2)
- {
- std::string key = atts[i];
- std::string value = atts[i+1];
+ element->name = name;
- element->attributes[key] = value;
- }
+ for (size_t i = 0; atts[i]; i += 2) {
+ std::string key = atts[i];
+ std::string value = atts[i + 1];
- ElementStack.push_back(element);
+ element->attributes[key] = value;
}
+
+ ElementStack.push_back(element);
+ }
}
-void cmWIXPatchParser::StartFragment(const char **attributes)
+void cmWIXPatchParser::StartFragment(const char** attributes)
{
- for(size_t i = 0; attributes[i]; i += 2)
- {
+ for (size_t i = 0; attributes[i]; i += 2) {
std::string key = attributes[i];
- std::string value = attributes[i+1];
+ std::string value = attributes[i + 1];
- if(key == "Id")
- {
- if(Fragments.find(value) != Fragments.end())
- {
+ if (key == "Id") {
+ if (Fragments.find(value) != Fragments.end()) {
std::stringstream tmp;
tmp << "Invalid reuse of 'CPackWixFragment' 'Id': " << value;
ReportValidationError(tmp.str());
- }
+ }
ElementStack.push_back(&Fragments[value]);
- }
- else
- {
+ } else {
ReportValidationError(
"The only allowed 'CPackWixFragment' attribute is 'Id'");
- }
}
+ }
}
void cmWIXPatchParser::EndElement(const std::string& name)
{
- if(State == INSIDE_FRAGMENT)
- {
- if(name == "CPackWiXFragment")
- {
- State = BEGIN_FRAGMENTS;
- ElementStack.clear();
- }
- else
- {
- ElementStack.pop_back();
- }
+ if (State == INSIDE_FRAGMENT) {
+ if (name == "CPackWiXFragment") {
+ State = BEGIN_FRAGMENTS;
+ ElementStack.clear();
+ } else {
+ ElementStack.pop_back();
}
+ }
}
void cmWIXPatchParser::CharacterDataHandler(const char* data, int length)
{
const char* whitespace = "\x20\x09\x0d\x0a";
- if(State == INSIDE_FRAGMENT)
- {
- cmWIXPatchElement &parent = *ElementStack.back();
+ if (State == INSIDE_FRAGMENT) {
+ cmWIXPatchElement& parent = *ElementStack.back();
std::string text(data, length);
std::string::size_type first = text.find_first_not_of(whitespace);
std::string::size_type last = text.find_last_not_of(whitespace);
- if(first != std::string::npos && last != std::string::npos)
- {
- cmWIXPatchText *text_node = new cmWIXPatchText;
+ if (first != std::string::npos && last != std::string::npos) {
+ cmWIXPatchText* text_node = new cmWIXPatchText;
text_node->text = text.substr(first, last - first + 1);
parent.children.push_back(text_node);
- }
}
+ }
}
void cmWIXPatchParser::ReportError(int line, int column, const char* msg)
{
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error while processing XML patch file at " << line << ":" << column <<
- ": "<< msg << std::endl);
+ "Error while processing XML patch file at "
+ << line << ":" << column << ": " << msg << std::endl);
Valid = false;
}
void cmWIXPatchParser::ReportValidationError(std::string const& message)
{
- ReportError(XML_GetCurrentLineNumber(static_cast<XML_Parser>(this->Parser)),
+ ReportError(
+ XML_GetCurrentLineNumber(static_cast<XML_Parser>(this->Parser)),
XML_GetCurrentColumnNumber(static_cast<XML_Parser>(this->Parser)),
message.c_str());
}
diff --git a/Source/CPack/WiX/cmWIXPatchParser.h b/Source/CPack/WiX/cmWIXPatchParser.h
index 8ce4026..f9b85bd 100644
--- a/Source/CPack/WiX/cmWIXPatchParser.h
+++ b/Source/CPack/WiX/cmWIXPatchParser.h
@@ -65,9 +65,9 @@ public:
cmWIXPatchParser(fragment_map_t& Fragments, cmCPackLog* logger);
private:
- virtual void StartElement(const std::string& name, const char **atts);
+ virtual void StartElement(const std::string& name, const char** atts);
- void StartFragment(const char **attributes);
+ void StartFragment(const char** attributes);
virtual void EndElement(const std::string& name);
diff --git a/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx b/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx
index f27caa9..f3dbcb9 100644
--- a/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx
+++ b/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx
@@ -15,8 +15,8 @@
#include <cmVersion.h>
cmWIXRichTextFormatWriter::cmWIXRichTextFormatWriter(
- std::string const& filename):
- File(filename.c_str(), std::ios::binary)
+ std::string const& filename)
+ : File(filename.c_str(), std::ios::binary)
{
StartGroup();
WriteHeader();
@@ -37,74 +37,50 @@ void cmWIXRichTextFormatWriter::AddText(std::string const& text)
{
typedef unsigned char rtf_byte_t;
- for(size_t i = 0; i < text.size(); ++i)
- {
+ for (size_t i = 0; i < text.size(); ++i) {
rtf_byte_t c = rtf_byte_t(text[i]);
- switch(c)
- {
- case '\\':
- File << "\\\\";
- break;
- case '{':
- File << "\\{";
- break;
- case '}':
- File << "\\}";
- break;
- case '\n':
- File << "\\par\r\n";
- break;
- case '\r':
- continue;
- default:
- {
- if(c <= 0x7F)
- {
+ switch (c) {
+ case '\\':
+ File << "\\\\";
+ break;
+ case '{':
+ File << "\\{";
+ break;
+ case '}':
+ File << "\\}";
+ break;
+ case '\n':
+ File << "\\par\r\n";
+ break;
+ case '\r':
+ continue;
+ default: {
+ if (c <= 0x7F) {
File << c;
- }
- else
- {
- if(c <= 0xC0)
- {
- EmitInvalidCodepoint(c);
- }
- else if(c < 0xE0 && i+1 < text.size())
- {
- EmitUnicodeCodepoint(
- (text[i+1] & 0x3F) |
- ((c & 0x1F) << 6)
- );
- i+= 1;
- }
- else if(c < 0xF0 && i+2 < text.size())
- {
- EmitUnicodeCodepoint(
- (text[i+2] & 0x3F) |
- ((text[i+1] & 0x3F) << 6) |
- ((c & 0xF) << 12)
- );
- i += 2;
- }
- else if(c < 0xF8 && i+3 < text.size())
- {
- EmitUnicodeCodepoint(
- (text[i+3] & 0x3F) |
- ((text[i+2] & 0x3F) << 6) |
- ((text[i+1] & 0x3F) << 12) |
- ((c & 0x7) << 18)
- );
- i += 3;
- }
- else
- {
- EmitInvalidCodepoint(c);
- }
+ } else {
+ if (c <= 0xC0) {
+ EmitInvalidCodepoint(c);
+ } else if (c < 0xE0 && i + 1 < text.size()) {
+ EmitUnicodeCodepoint((text[i + 1] & 0x3F) | ((c & 0x1F) << 6));
+ i += 1;
+ } else if (c < 0xF0 && i + 2 < text.size()) {
+ EmitUnicodeCodepoint((text[i + 2] & 0x3F) |
+ ((text[i + 1] & 0x3F) << 6) |
+ ((c & 0xF) << 12));
+ i += 2;
+ } else if (c < 0xF8 && i + 3 < text.size()) {
+ EmitUnicodeCodepoint(
+ (text[i + 3] & 0x3F) | ((text[i + 2] & 0x3F) << 6) |
+ ((text[i + 1] & 0x3F) << 12) | ((c & 0x7) << 18));
+ i += 3;
+ } else {
+ EmitInvalidCodepoint(c);
}
}
- break;
- }
+ } break;
}
+ }
}
void cmWIXRichTextFormatWriter::WriteHeader()
@@ -190,33 +166,25 @@ void cmWIXRichTextFormatWriter::EndGroup()
void cmWIXRichTextFormatWriter::EmitUnicodeCodepoint(int c)
{
// Do not emit byte order mark (BOM)
- if(c == 0xFEFF)
- {
+ if (c == 0xFEFF) {
return;
- }
- else if(c <= 0xFFFF)
- {
+ } else if (c <= 0xFFFF) {
EmitUnicodeSurrogate(c);
- }
- else
- {
+ } else {
c -= 0x10000;
EmitUnicodeSurrogate(((c >> 10) & 0x3FF) + 0xD800);
EmitUnicodeSurrogate((c & 0x3FF) + 0xDC00);
- }
+ }
}
void cmWIXRichTextFormatWriter::EmitUnicodeSurrogate(int c)
{
ControlWord("u");
- if(c <= 32767)
- {
+ if (c <= 32767) {
File << c;
- }
- else
- {
+ } else {
File << (c - 65536);
- }
+ }
File << "?";
}
diff --git a/Source/CPack/WiX/cmWIXShortcut.cxx b/Source/CPack/WiX/cmWIXShortcut.cxx
index d721872..2685a23 100644
--- a/Source/CPack/WiX/cmWIXShortcut.cxx
+++ b/Source/CPack/WiX/cmWIXShortcut.cxx
@@ -14,8 +14,8 @@
#include "cmWIXFilesSourceWriter.h"
-void cmWIXShortcuts::insert(
- Type type, std::string const& id, cmWIXShortcut const& shortcut)
+void cmWIXShortcuts::insert(Type type, std::string const& id,
+ cmWIXShortcut const& shortcut)
{
this->Shortcuts[type][id].push_back(shortcut);
}
@@ -26,25 +26,22 @@ bool cmWIXShortcuts::empty(Type type) const
}
bool cmWIXShortcuts::EmitShortcuts(
- Type type,
- std::string const& registryKey,
+ Type type, std::string const& registryKey,
std::string const& cpackComponentName,
cmWIXFilesSourceWriter& fileDefinitions) const
{
shortcut_type_map_t::const_iterator i = this->Shortcuts.find(type);
- if(i == this->Shortcuts.end())
- {
+ if (i == this->Shortcuts.end()) {
return false;
- }
+ }
shortcut_id_map_t const& id_map = i->second;
std::string shortcutPrefix;
std::string registrySuffix;
- switch(type)
- {
+ switch (type) {
case START_MENU:
shortcutPrefix = "CM_S";
break;
@@ -58,68 +55,61 @@ bool cmWIXShortcuts::EmitShortcuts(
break;
default:
return false;
- }
+ }
- for(shortcut_id_map_t::const_iterator j = id_map.begin();
- j != id_map.end(); ++j)
- {
+ for (shortcut_id_map_t::const_iterator j = id_map.begin(); j != id_map.end();
+ ++j) {
std::string const& id = j->first;
shortcut_list_t const& shortcutList = j->second;
- for(size_t shortcutListIndex = 0;
- shortcutListIndex < shortcutList.size(); ++shortcutListIndex)
- {
+ for (size_t shortcutListIndex = 0; shortcutListIndex < shortcutList.size();
+ ++shortcutListIndex) {
cmWIXShortcut const& shortcut = shortcutList[shortcutListIndex];
- fileDefinitions.EmitShortcut(id, shortcut,
- shortcutPrefix, shortcutListIndex);
- }
+ fileDefinitions.EmitShortcut(id, shortcut, shortcutPrefix,
+ shortcutListIndex);
}
+ }
- fileDefinitions.EmitInstallRegistryValue(
- registryKey, cpackComponentName, registrySuffix);
+ fileDefinitions.EmitInstallRegistryValue(registryKey, cpackComponentName,
+ registrySuffix);
return true;
}
void cmWIXShortcuts::AddShortcutTypes(std::set<Type>& types)
{
- for(shortcut_type_map_t::const_iterator i = this->Shortcuts.begin();
- i != this->Shortcuts.end(); ++i)
- {
+ for (shortcut_type_map_t::const_iterator i = this->Shortcuts.begin();
+ i != this->Shortcuts.end(); ++i) {
types.insert(i->first);
- }
+ }
}
-void cmWIXShortcuts::CreateFromProperties(
- std::string const& id,
- std::string const& directoryId,
- cmInstalledFile const& installedFile)
+void cmWIXShortcuts::CreateFromProperties(std::string const& id,
+ std::string const& directoryId,
+ cmInstalledFile const& installedFile)
{
- CreateFromProperty("CPACK_START_MENU_SHORTCUTS",
- START_MENU, id, directoryId, installedFile);
+ CreateFromProperty("CPACK_START_MENU_SHORTCUTS", START_MENU, id, directoryId,
+ installedFile);
- CreateFromProperty("CPACK_DESKTOP_SHORTCUTS",
- DESKTOP, id, directoryId, installedFile);
+ CreateFromProperty("CPACK_DESKTOP_SHORTCUTS", DESKTOP, id, directoryId,
+ installedFile);
- CreateFromProperty("CPACK_STARTUP_SHORTCUTS",
- STARTUP, id, directoryId, installedFile);
+ CreateFromProperty("CPACK_STARTUP_SHORTCUTS", STARTUP, id, directoryId,
+ installedFile);
}
-void cmWIXShortcuts::CreateFromProperty(
- std::string const& propertyName,
- Type type,
- std::string const& id,
- std::string const& directoryId,
- cmInstalledFile const& installedFile)
+void cmWIXShortcuts::CreateFromProperty(std::string const& propertyName,
+ Type type, std::string const& id,
+ std::string const& directoryId,
+ cmInstalledFile const& installedFile)
{
std::vector<std::string> list;
installedFile.GetPropertyAsList(propertyName, list);
- for(size_t i = 0; i < list.size(); ++i)
- {
+ for (size_t i = 0; i < list.size(); ++i) {
cmWIXShortcut shortcut;
shortcut.label = list[i];
shortcut.workingDirectoryId = directoryId;
insert(type, id, shortcut);
- }
+ }
}
diff --git a/Source/CPack/WiX/cmWIXShortcut.h b/Source/CPack/WiX/cmWIXShortcut.h
index 598aa0d..593ba34 100644
--- a/Source/CPack/WiX/cmWIXShortcut.h
+++ b/Source/CPack/WiX/cmWIXShortcut.h
@@ -45,26 +45,23 @@ public:
bool empty(Type type) const;
- bool EmitShortcuts(
- Type type,
- std::string const& registryKey,
- std::string const& cpackComponentName,
- cmWIXFilesSourceWriter& fileDefinitions) const;
+ bool EmitShortcuts(Type type, std::string const& registryKey,
+ std::string const& cpackComponentName,
+ cmWIXFilesSourceWriter& fileDefinitions) const;
void AddShortcutTypes(std::set<Type>& types);
void CreateFromProperties(std::string const& id,
- std::string const& directoryId, cmInstalledFile const& installedFile);
+ std::string const& directoryId,
+ cmInstalledFile const& installedFile);
private:
typedef std::map<Type, shortcut_id_map_t> shortcut_type_map_t;
- void CreateFromProperty(
- std::string const& propertyName,
- Type type,
- std::string const& id,
- std::string const& directoryId,
- cmInstalledFile const& installedFile);
+ void CreateFromProperty(std::string const& propertyName, Type type,
+ std::string const& id,
+ std::string const& directoryId,
+ cmInstalledFile const& installedFile);
shortcut_type_map_t Shortcuts;
shortcut_id_map_t EmptyIdMap;
diff --git a/Source/CPack/WiX/cmWIXSourceWriter.cxx b/Source/CPack/WiX/cmWIXSourceWriter.cxx
index 2e5194c..2c0384e 100644
--- a/Source/CPack/WiX/cmWIXSourceWriter.cxx
+++ b/Source/CPack/WiX/cmWIXSourceWriter.cxx
@@ -17,46 +17,41 @@
#include <windows.h>
cmWIXSourceWriter::cmWIXSourceWriter(cmCPackLog* logger,
- std::string const& filename,
- bool isIncludeFile):
- Logger(logger),
- File(filename.c_str()),
- State(DEFAULT),
- SourceFilename(filename)
+ std::string const& filename,
+ bool isIncludeFile)
+ : Logger(logger)
+ , File(filename.c_str())
+ , State(DEFAULT)
+ , SourceFilename(filename)
{
WriteXMLDeclaration();
- if(isIncludeFile)
- {
+ if (isIncludeFile) {
BeginElement("Include");
- }
- else
- {
+ } else {
BeginElement("Wix");
- }
+ }
AddAttribute("xmlns", "http://schemas.microsoft.com/wix/2006/wi");
}
cmWIXSourceWriter::~cmWIXSourceWriter()
{
- if(Elements.size() > 1)
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- Elements.size() - 1 << " WiX elements were still open when closing '" <<
- SourceFilename << "'" << std::endl);
+ if (Elements.size() > 1) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, Elements.size() - 1
+ << " WiX elements were still open when closing '"
+ << SourceFilename << "'" << std::endl);
return;
- }
+ }
EndElement(Elements.back());
}
void cmWIXSourceWriter::BeginElement(std::string const& name)
{
- if(State == BEGIN)
- {
+ if (State == BEGIN) {
File << ">";
- }
+ }
File << "\n";
Indent(Elements.size());
@@ -68,33 +63,27 @@ void cmWIXSourceWriter::BeginElement(std::string const& name)
void cmWIXSourceWriter::EndElement(std::string const& name)
{
- if(Elements.empty())
- {
+ if (Elements.empty()) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "can not end WiX element with no open elements in '" <<
- SourceFilename << "'" << std::endl);
+ "can not end WiX element with no open elements in '"
+ << SourceFilename << "'" << std::endl);
return;
- }
+ }
- if(Elements.back() != name)
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "WiX element <" << Elements.back() <<
- "> can not be closed by </" << name << "> in '" <<
- SourceFilename << "'" << std::endl);
+ if (Elements.back() != name) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "WiX element <"
+ << Elements.back() << "> can not be closed by </" << name
+ << "> in '" << SourceFilename << "'" << std::endl);
return;
- }
+ }
- if(State == DEFAULT)
- {
+ if (State == DEFAULT) {
File << "\n";
- Indent(Elements.size()-1);
+ Indent(Elements.size() - 1);
File << "</" << Elements.back() << ">";
- }
- else
- {
+ } else {
File << "/>";
- }
+ }
Elements.pop_back();
State = DEFAULT;
@@ -102,30 +91,27 @@ void cmWIXSourceWriter::EndElement(std::string const& name)
void cmWIXSourceWriter::AddTextNode(std::string const& text)
{
- if(State == BEGIN)
- {
+ if (State == BEGIN) {
File << ">";
- }
+ }
- if(Elements.empty())
- {
+ if (Elements.empty()) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "can not add text without open WiX element in '" <<
- SourceFilename << "'" << std::endl);
+ "can not add text without open WiX element in '"
+ << SourceFilename << "'" << std::endl);
return;
- }
+ }
File << this->EscapeAttributeValue(text);
State = DEFAULT;
}
-void cmWIXSourceWriter::AddProcessingInstruction(
- std::string const& target, std::string const& content)
+void cmWIXSourceWriter::AddProcessingInstruction(std::string const& target,
+ std::string const& content)
{
- if(State == BEGIN)
- {
+ if (State == BEGIN) {
File << ">";
- }
+ }
File << "\n";
Indent(Elements.size());
@@ -134,21 +120,20 @@ void cmWIXSourceWriter::AddProcessingInstruction(
State = DEFAULT;
}
-void cmWIXSourceWriter::AddAttribute(
- std::string const& key, std::string const& value)
+void cmWIXSourceWriter::AddAttribute(std::string const& key,
+ std::string const& value)
{
std::string utf8 = CMakeEncodingToUtf8(value);
File << " " << key << "=\"" << EscapeAttributeValue(utf8) << '"';
}
-void cmWIXSourceWriter::AddAttributeUnlessEmpty(
- std::string const& key, std::string const& value)
+void cmWIXSourceWriter::AddAttributeUnlessEmpty(std::string const& key,
+ std::string const& value)
{
- if(!value.empty())
- {
+ if (!value.empty()) {
AddAttribute(key, value);
- }
+ }
}
std::string cmWIXSourceWriter::CMakeEncodingToUtf8(std::string const& value)
@@ -156,43 +141,38 @@ std::string cmWIXSourceWriter::CMakeEncodingToUtf8(std::string const& value)
#ifdef CMAKE_ENCODING_UTF8
return value;
#else
- if(value.empty())
- {
+ if (value.empty()) {
return std::string();
- }
+ }
int characterCount = MultiByteToWideChar(
CP_ACP, 0, value.c_str(), static_cast<int>(value.size()), 0, 0);
- if(characterCount == 0)
- {
+ if (characterCount == 0) {
return std::string();
- }
+ }
std::vector<wchar_t> utf16(characterCount);
- MultiByteToWideChar(
- CP_ACP, 0, value.c_str(), static_cast<int>(value.size()),
- &utf16[0], static_cast<int>(utf16.size()));
+ MultiByteToWideChar(CP_ACP, 0, value.c_str(), static_cast<int>(value.size()),
+ &utf16[0], static_cast<int>(utf16.size()));
int utf8ByteCount = WideCharToMultiByte(
CP_UTF8, 0, &utf16[0], static_cast<int>(utf16.size()), 0, 0, 0, 0);
- if(utf8ByteCount == 0)
- {
+ if (utf8ByteCount == 0) {
return std::string();
- }
+ }
std::vector<char> utf8(utf8ByteCount);
WideCharToMultiByte(CP_UTF8, 0, &utf16[0], static_cast<int>(utf16.size()),
- &utf8[0], static_cast<int>(utf8.size()), 0, 0);
+ &utf8[0], static_cast<int>(utf8.size()), 0, 0);
return std::string(&utf8[0], utf8.size());
#endif
}
-
void cmWIXSourceWriter::WriteXMLDeclaration()
{
File << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl;
@@ -200,41 +180,37 @@ void cmWIXSourceWriter::WriteXMLDeclaration()
void cmWIXSourceWriter::Indent(size_t count)
{
- for(size_t i = 0; i < count; ++i)
- {
+ for (size_t i = 0; i < count; ++i) {
File << " ";
- }
+ }
}
-std::string cmWIXSourceWriter::EscapeAttributeValue(
- std::string const& value)
+std::string cmWIXSourceWriter::EscapeAttributeValue(std::string const& value)
{
std::string result;
result.reserve(value.size());
char c = 0;
- for(size_t i = 0 ; i < value.size(); ++i)
- {
+ for (size_t i = 0; i < value.size(); ++i) {
c = value[i];
- switch(c)
- {
- case '<':
- result += "&lt;";
- break;
- case '>':
- result += "&gt;";
- break;
- case '&':
- result +="&amp;";
- break;
- case '"':
- result += "&quot;";
- break;
- default:
- result += c;
- break;
- }
- }
+ switch (c) {
+ case '<':
+ result += "&lt;";
+ break;
+ case '>':
+ result += "&gt;";
+ break;
+ case '&':
+ result += "&amp;";
+ break;
+ case '"':
+ result += "&quot;";
+ break;
+ default:
+ result += c;
+ break;
+ }
+ }
return result;
}
diff --git a/Source/CPack/WiX/cmWIXSourceWriter.h b/Source/CPack/WiX/cmWIXSourceWriter.h
index 2bf9674..4efc026 100644
--- a/Source/CPack/WiX/cmWIXSourceWriter.h
+++ b/Source/CPack/WiX/cmWIXSourceWriter.h
@@ -26,8 +26,8 @@
class cmWIXSourceWriter
{
public:
- cmWIXSourceWriter(cmCPackLog* logger,
- std::string const& filename, bool isIncludeFile = false);
+ cmWIXSourceWriter(cmCPackLog* logger, std::string const& filename,
+ bool isIncludeFile = false);
~cmWIXSourceWriter();
@@ -37,19 +37,18 @@ public:
void AddTextNode(std::string const& text);
- void AddProcessingInstruction(
- std::string const& target, std::string const& content);
+ void AddProcessingInstruction(std::string const& target,
+ std::string const& content);
- void AddAttribute(
- std::string const& key, std::string const& value);
+ void AddAttribute(std::string const& key, std::string const& value);
- void AddAttributeUnlessEmpty(
- std::string const& key, std::string const& value);
+ void AddAttributeUnlessEmpty(std::string const& key,
+ std::string const& value);
static std::string CMakeEncodingToUtf8(std::string const& value);
protected:
- cmCPackLog* Logger;
+ cmCPackLog* Logger;
private:
enum State
diff --git a/Source/CPack/cmCPack7zGenerator.cxx b/Source/CPack/cmCPack7zGenerator.cxx
index 06bf7e7..b01c216 100644
--- a/Source/CPack/cmCPack7zGenerator.cxx
+++ b/Source/CPack/cmCPack7zGenerator.cxx
@@ -13,8 +13,7 @@
#include "cmCPack7zGenerator.h"
cmCPack7zGenerator::cmCPack7zGenerator()
- :cmCPackArchiveGenerator(cmArchiveWrite::CompressNone,
- "7zip")
+ : cmCPackArchiveGenerator(cmArchiveWrite::CompressNone, "7zip")
{
}
diff --git a/Source/CPack/cmCPackArchiveGenerator.cxx b/Source/CPack/cmCPackArchiveGenerator.cxx
index 05ea1d8..7db20a4 100644
--- a/Source/CPack/cmCPackArchiveGenerator.cxx
+++ b/Source/CPack/cmCPackArchiveGenerator.cxx
@@ -25,7 +25,7 @@
#include <cmsys/SystemTools.hxx>
cmCPackArchiveGenerator::cmCPackArchiveGenerator(cmArchiveWrite::Compress t,
- std::string const& format)
+ std::string const& format)
{
this->Compress = t;
this->ArchiveFormat = format;
@@ -40,48 +40,41 @@ int cmCPackArchiveGenerator::InitializeInternal()
this->SetOptionIfNotSet("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", "1");
return this->Superclass::InitializeInternal();
}
-int cmCPackArchiveGenerator::addOneComponentToArchive(cmArchiveWrite& archive,
- cmCPackComponent* component)
+int cmCPackArchiveGenerator::addOneComponentToArchive(
+ cmArchiveWrite& archive, cmCPackComponent* component)
{
- cmCPackLogger(cmCPackLog::LOG_VERBOSE, " - packaging component: "
- << component->Name
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE,
+ " - packaging component: " << component->Name << std::endl);
// Add the files of this component to the archive
std::string localToplevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY"));
- localToplevel += "/"+ component->Name;
+ localToplevel += "/" + component->Name;
std::string dir = cmSystemTools::GetCurrentWorkingDirectory();
// Change to local toplevel
cmSystemTools::ChangeDirectory(localToplevel);
std::string filePrefix;
- if (this->IsOn("CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY"))
- {
+ if (this->IsOn("CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY")) {
filePrefix = this->GetOption("CPACK_PACKAGE_FILE_NAME");
filePrefix += "/";
- }
+ }
const char* installPrefix =
this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX");
- if(installPrefix && installPrefix[0] == '/' && installPrefix[1] != 0)
- {
+ if (installPrefix && installPrefix[0] == '/' && installPrefix[1] != 0) {
// add to file prefix and remove the leading '/'
- filePrefix += installPrefix+1;
+ filePrefix += installPrefix + 1;
filePrefix += "/";
- }
+ }
std::vector<std::string>::const_iterator fileIt;
for (fileIt = component->Files.begin(); fileIt != component->Files.end();
- ++fileIt )
- {
+ ++fileIt) {
std::string rp = filePrefix + *fileIt;
- cmCPackLogger(cmCPackLog::LOG_DEBUG,"Adding file: "
- << rp << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_DEBUG, "Adding file: " << rp << std::endl);
archive.Add(rp, 0, 0, false);
- if (!archive)
- {
+ if (!archive) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "ERROR while packaging files: "
- << archive.GetError()
- << std::endl);
+ << archive.GetError() << std::endl);
return 0;
- }
}
+ }
// Go back to previous dir
cmSystemTools::ChangeDirectory(dir);
return 1;
@@ -92,26 +85,21 @@ int cmCPackArchiveGenerator::addOneComponentToArchive(cmArchiveWrite& archive,
* an declare and open the associated
* cmArchiveWrite 'archive' object.
*/
-#define DECLARE_AND_OPEN_ARCHIVE(filename,archive) \
-cmGeneratedFileStream gf; \
-gf.Open(filename.c_str(), false, true); \
-if (!GenerateHeader(&gf)) \
- { \
- cmCPackLogger(cmCPackLog::LOG_ERROR, \
- "Problem to generate Header for archive < " \
- << filename \
- << ">." << std::endl); \
- return 0; \
- } \
-cmArchiveWrite archive(gf,this->Compress, this->ArchiveFormat); \
-if (!archive) \
- { \
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem to create archive < " \
- << filename \
- << ">. ERROR =" \
- << archive.GetError() \
- << std::endl); \
- return 0; \
+#define DECLARE_AND_OPEN_ARCHIVE(filename, archive) \
+ cmGeneratedFileStream gf; \
+ gf.Open(filename.c_str(), false, true); \
+ if (!GenerateHeader(&gf)) { \
+ cmCPackLogger(cmCPackLog::LOG_ERROR, \
+ "Problem to generate Header for archive < " \
+ << filename << ">." << std::endl); \
+ return 0; \
+ } \
+ cmArchiveWrite archive(gf, this->Compress, this->ArchiveFormat); \
+ if (!archive) { \
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem to create archive < " \
+ << filename << ">. ERROR =" << archive.GetError() \
+ << std::endl); \
+ return 0; \
}
int cmCPackArchiveGenerator::PackageComponents(bool ignoreGroup)
@@ -119,99 +107,86 @@ int cmCPackArchiveGenerator::PackageComponents(bool ignoreGroup)
packageFileNames.clear();
// The default behavior is to have one package by component group
// unless CPACK_COMPONENTS_IGNORE_GROUP is specified.
- if (!ignoreGroup)
- {
+ if (!ignoreGroup) {
std::map<std::string, cmCPackComponentGroup>::iterator compGIt;
- for (compGIt=this->ComponentGroups.begin();
- compGIt!=this->ComponentGroups.end(); ++compGIt)
- {
+ for (compGIt = this->ComponentGroups.begin();
+ compGIt != this->ComponentGroups.end(); ++compGIt) {
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: "
- << compGIt->first
- << std::endl);
+ << compGIt->first << std::endl);
// Begin the archive for this group
- std::string packageFileName= std::string(toplevel);
- packageFileName += "/"+
- GetComponentPackageFileName(this->GetOption("CPACK_PACKAGE_FILE_NAME"),
- compGIt->first,
- true)
- + this->GetOutputExtension();
+ std::string packageFileName = std::string(toplevel);
+ packageFileName += "/" +
+ GetComponentPackageFileName(this->GetOption("CPACK_PACKAGE_FILE_NAME"),
+ compGIt->first, true) +
+ this->GetOutputExtension();
// open a block in order to automatically close archive
// at the end of the block
{
- DECLARE_AND_OPEN_ARCHIVE(packageFileName,archive);
+ DECLARE_AND_OPEN_ARCHIVE(packageFileName, archive);
// now iterate over the component of this group
std::vector<cmCPackComponent*>::iterator compIt;
- for (compIt=(compGIt->second).Components.begin();
- compIt!=(compGIt->second).Components.end();
- ++compIt)
- {
+ for (compIt = (compGIt->second).Components.begin();
+ compIt != (compGIt->second).Components.end(); ++compIt) {
// Add the files of this component to the archive
- addOneComponentToArchive(archive,*compIt);
- }
+ addOneComponentToArchive(archive, *compIt);
+ }
}
// add the generated package to package file names list
packageFileNames.push_back(packageFileName);
- }
+ }
// Handle Orphan components (components not belonging to any groups)
std::map<std::string, cmCPackComponent>::iterator compIt;
- for (compIt=this->Components.begin();
- compIt!=this->Components.end(); ++compIt )
- {
+ for (compIt = this->Components.begin(); compIt != this->Components.end();
+ ++compIt) {
// Does the component belong to a group?
- if (compIt->second.Group==NULL)
- {
- cmCPackLogger(cmCPackLog::LOG_VERBOSE,
- "Component <"
- << compIt->second.Name
- << "> does not belong to any group, package it separately."
- << std::endl);
+ if (compIt->second.Group == NULL) {
+ cmCPackLogger(
+ cmCPackLog::LOG_VERBOSE, "Component <"
+ << compIt->second.Name
+ << "> does not belong to any group, package it separately."
+ << std::endl);
std::string localToplevel(
- this->GetOption("CPACK_TEMPORARY_DIRECTORY")
- );
+ this->GetOption("CPACK_TEMPORARY_DIRECTORY"));
std::string packageFileName = std::string(toplevel);
- localToplevel += "/"+ compIt->first;
- packageFileName += "/"+
- GetComponentPackageFileName(this->GetOption("CPACK_PACKAGE_FILE_NAME"),
- compIt->first,
- false)
- + this->GetOutputExtension();
+ localToplevel += "/" + compIt->first;
+ packageFileName += "/" + GetComponentPackageFileName(
+ this->GetOption("CPACK_PACKAGE_FILE_NAME"),
+ compIt->first, false) +
+ this->GetOutputExtension();
{
- DECLARE_AND_OPEN_ARCHIVE(packageFileName,archive);
+ DECLARE_AND_OPEN_ARCHIVE(packageFileName, archive);
// Add the files of this component to the archive
- addOneComponentToArchive(archive,&(compIt->second));
+ addOneComponentToArchive(archive, &(compIt->second));
}
// add the generated package to package file names list
packageFileNames.push_back(packageFileName);
- }
}
}
+ }
// CPACK_COMPONENTS_IGNORE_GROUPS is set
// We build 1 package per component
- else
- {
+ else {
std::map<std::string, cmCPackComponent>::iterator compIt;
- for (compIt=this->Components.begin();
- compIt!=this->Components.end(); ++compIt )
- {
+ for (compIt = this->Components.begin(); compIt != this->Components.end();
+ ++compIt) {
std::string localToplevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY"));
std::string packageFileName = std::string(toplevel);
- localToplevel += "/"+ compIt->first;
- packageFileName += "/"+
- GetComponentPackageFileName(this->GetOption("CPACK_PACKAGE_FILE_NAME"),
- compIt->first,
- false)
- + this->GetOutputExtension();
+ localToplevel += "/" + compIt->first;
+ packageFileName += "/" +
+ GetComponentPackageFileName(this->GetOption("CPACK_PACKAGE_FILE_NAME"),
+ compIt->first, false) +
+ this->GetOutputExtension();
{
- DECLARE_AND_OPEN_ARCHIVE(packageFileName,archive);
+ DECLARE_AND_OPEN_ARCHIVE(packageFileName, archive);
// Add the files of this component to the archive
- addOneComponentToArchive(archive,&(compIt->second));
+ addOneComponentToArchive(archive, &(compIt->second));
}
// add the generated package to package file names list
packageFileNames.push_back(packageFileName);
- }
}
+ }
return 1;
}
@@ -220,23 +195,22 @@ int cmCPackArchiveGenerator::PackageComponentsAllInOne()
// reset the package file names
packageFileNames.clear();
packageFileNames.push_back(std::string(toplevel));
- packageFileNames[0] += "/"
- +std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME"))
- + this->GetOutputExtension();
+ packageFileNames[0] += "/" +
+ std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) +
+ this->GetOutputExtension();
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
"Packaging all groups in one package..."
"(CPACK_COMPONENTS_ALL_GROUPS_IN_ONE_PACKAGE is set)"
- << std::endl);
- DECLARE_AND_OPEN_ARCHIVE(packageFileNames[0],archive);
+ << std::endl);
+ DECLARE_AND_OPEN_ARCHIVE(packageFileNames[0], archive);
// The ALL COMPONENTS in ONE package case
std::map<std::string, cmCPackComponent>::iterator compIt;
- for (compIt=this->Components.begin();compIt!=this->Components.end();
- ++compIt )
- {
+ for (compIt = this->Components.begin(); compIt != this->Components.end();
+ ++compIt) {
// Add the files of this component to the archive
- addOneComponentToArchive(archive,&(compIt->second));
- }
+ addOneComponentToArchive(archive, &(compIt->second));
+ }
// archive goes out of scope so it will finalized and closed.
return 1;
@@ -244,50 +218,42 @@ int cmCPackArchiveGenerator::PackageComponentsAllInOne()
int cmCPackArchiveGenerator::PackageFiles()
{
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "Toplevel: "
- << toplevel << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_DEBUG, "Toplevel: " << toplevel << std::endl);
if (WantsComponentInstallation()) {
// CASE 1 : COMPONENT ALL-IN-ONE package
// If ALL COMPONENTS in ONE package has been requested
// then the package file is unique and should be open here.
- if (componentPackageMethod == ONE_PACKAGE)
- {
+ if (componentPackageMethod == ONE_PACKAGE) {
return PackageComponentsAllInOne();
- }
+ }
// CASE 2 : COMPONENT CLASSICAL package(s) (i.e. not all-in-one)
// There will be 1 package for each component group
// however one may require to ignore component group and
// in this case you'll get 1 package for each component.
- else
- {
+ else {
return PackageComponents(componentPackageMethod ==
ONE_PACKAGE_PER_COMPONENT);
- }
+ }
}
// CASE 3 : NON COMPONENT package.
- DECLARE_AND_OPEN_ARCHIVE(packageFileNames[0],archive);
+ DECLARE_AND_OPEN_ARCHIVE(packageFileNames[0], archive);
std::vector<std::string>::const_iterator fileIt;
std::string dir = cmSystemTools::GetCurrentWorkingDirectory();
cmSystemTools::ChangeDirectory(toplevel);
- for ( fileIt = files.begin(); fileIt != files.end(); ++ fileIt )
- {
+ for (fileIt = files.begin(); fileIt != files.end(); ++fileIt) {
// Get the relative path to the file
- std::string rp = cmSystemTools::RelativePath(toplevel.c_str(),
- fileIt->c_str());
+ std::string rp =
+ cmSystemTools::RelativePath(toplevel.c_str(), fileIt->c_str());
archive.Add(rp, 0, 0, false);
- if(!archive)
- {
+ if (!archive) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem while adding file< "
- << *fileIt
- << "> to archive <"
- << packageFileNames[0] << "> .ERROR ="
- << archive.GetError()
- << std::endl);
+ << *fileIt << "> to archive <" << packageFileNames[0]
+ << "> .ERROR =" << archive.GetError() << std::endl);
return 0;
- }
}
+ }
cmSystemTools::ChangeDirectory(dir);
// The destructor of cmArchiveWrite will close and finish the write
return 1;
@@ -298,16 +264,14 @@ int cmCPackArchiveGenerator::GenerateHeader(std::ostream*)
return 1;
}
-bool cmCPackArchiveGenerator::SupportsComponentInstallation() const {
+bool cmCPackArchiveGenerator::SupportsComponentInstallation() const
+{
// The Component installation support should only
// be activated if explicitly requested by the user
// (for backward compatibility reason)
- if (IsOn("CPACK_ARCHIVE_COMPONENT_INSTALL"))
- {
+ if (IsOn("CPACK_ARCHIVE_COMPONENT_INSTALL")) {
return true;
- }
- else
- {
+ } else {
return false;
- }
+ }
}
diff --git a/Source/CPack/cmCPackArchiveGenerator.h b/Source/CPack/cmCPackArchiveGenerator.h
index 8b07339..9eb38b1 100644
--- a/Source/CPack/cmCPackArchiveGenerator.h
+++ b/Source/CPack/cmCPackArchiveGenerator.h
@@ -17,7 +17,6 @@
#include "cmArchiveWrite.h"
-
/** \class cmCPackArchiveGenerator
* \brief A generator base for libarchive generation.
* The generator itself uses the libarchive wrapper
@@ -25,7 +24,7 @@
*
*/
class cmCPackArchiveGenerator : public cmCPackGenerator
- {
+{
public:
cmTypeMacro(cmCPackArchiveGenerator, cmCPackGenerator);
@@ -38,6 +37,7 @@ public:
virtual int GenerateHeader(std::ostream* os);
// component support
virtual bool SupportsComponentInstallation() const;
+
protected:
virtual int InitializeInternal();
/**
@@ -70,6 +70,6 @@ protected:
virtual const char* GetOutputExtension() = 0;
cmArchiveWrite::Compress Compress;
std::string ArchiveFormat;
- };
+};
#endif
diff --git a/Source/CPack/cmCPackBundleGenerator.cxx b/Source/CPack/cmCPackBundleGenerator.cxx
index 6cc48aa..1164021 100644
--- a/Source/CPack/cmCPackBundleGenerator.cxx
+++ b/Source/CPack/cmCPackBundleGenerator.cxx
@@ -28,29 +28,25 @@ cmCPackBundleGenerator::~cmCPackBundleGenerator()
int cmCPackBundleGenerator::InitializeInternal()
{
const char* name = this->GetOption("CPACK_BUNDLE_NAME");
- if(0 == name)
- {
+ if (0 == name) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "CPACK_BUNDLE_NAME must be set to use the Bundle generator."
- << std::endl);
+ "CPACK_BUNDLE_NAME must be set to use the Bundle generator."
+ << std::endl);
return 0;
- }
+ }
- if(this->GetOption("CPACK_BUNDLE_APPLE_CERT_APP"))
- {
- const std::string codesign_path = cmSystemTools::FindProgram("codesign",
- std::vector<std::string>(), false);
+ if (this->GetOption("CPACK_BUNDLE_APPLE_CERT_APP")) {
+ const std::string codesign_path = cmSystemTools::FindProgram(
+ "codesign", std::vector<std::string>(), false);
- if(codesign_path.empty())
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Cannot locate codesign command"
- << std::endl);
+ if (codesign_path.empty()) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot locate codesign command"
+ << std::endl);
return 0;
- }
- this->SetOptionIfNotSet("CPACK_COMMAND_CODESIGN", codesign_path.c_str());
}
+ this->SetOptionIfNotSet("CPACK_COMMAND_CODESIGN", codesign_path.c_str());
+ }
return this->Superclass::InitializeInternal();
}
@@ -69,42 +65,40 @@ int cmCPackBundleGenerator::ConstructBundle()
// Get required arguments ...
const std::string cpack_bundle_name = this->GetOption("CPACK_BUNDLE_NAME")
- ? this->GetOption("CPACK_BUNDLE_NAME") : "";
- if(cpack_bundle_name.empty())
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "CPACK_BUNDLE_NAME must be set."
- << std::endl);
+ ? this->GetOption("CPACK_BUNDLE_NAME")
+ : "";
+ if (cpack_bundle_name.empty()) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "CPACK_BUNDLE_NAME must be set."
+ << std::endl);
return 0;
- }
+ }
const std::string cpack_bundle_plist = this->GetOption("CPACK_BUNDLE_PLIST")
- ? this->GetOption("CPACK_BUNDLE_PLIST") : "";
- if(cpack_bundle_plist.empty())
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "CPACK_BUNDLE_PLIST must be set."
- << std::endl);
+ ? this->GetOption("CPACK_BUNDLE_PLIST")
+ : "";
+ if (cpack_bundle_plist.empty()) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "CPACK_BUNDLE_PLIST must be set."
+ << std::endl);
return 0;
- }
+ }
const std::string cpack_bundle_icon = this->GetOption("CPACK_BUNDLE_ICON")
- ? this->GetOption("CPACK_BUNDLE_ICON") : "";
- if(cpack_bundle_icon.empty())
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "CPACK_BUNDLE_ICON must be set."
- << std::endl);
+ ? this->GetOption("CPACK_BUNDLE_ICON")
+ : "";
+ if (cpack_bundle_icon.empty()) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "CPACK_BUNDLE_ICON must be set."
+ << std::endl);
return 0;
- }
+ }
// Get optional arguments ...
const std::string cpack_bundle_startup_command =
this->GetOption("CPACK_BUNDLE_STARTUP_COMMAND")
- ? this->GetOption("CPACK_BUNDLE_STARTUP_COMMAND") : "";
+ ? this->GetOption("CPACK_BUNDLE_STARTUP_COMMAND")
+ : "";
// The staging directory contains everything that will end-up inside the
// final disk image ...
@@ -112,30 +106,33 @@ int cmCPackBundleGenerator::ConstructBundle()
staging << toplevel;
std::ostringstream contents;
- contents << staging.str() << "/" << cpack_bundle_name
- << ".app/" << "Contents";
+ contents << staging.str() << "/" << cpack_bundle_name << ".app/"
+ << "Contents";
std::ostringstream application;
- application << contents.str() << "/" << "MacOS";
+ application << contents.str() << "/"
+ << "MacOS";
std::ostringstream resources;
- resources << contents.str() << "/" << "Resources";
+ resources << contents.str() << "/"
+ << "Resources";
// Install a required, user-provided bundle metadata file ...
std::ostringstream plist_source;
plist_source << cpack_bundle_plist;
std::ostringstream plist_target;
- plist_target << contents.str() << "/" << "Info.plist";
+ plist_target << contents.str() << "/"
+ << "Info.plist";
- if(!this->CopyFile(plist_source, plist_target))
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
+ if (!this->CopyFile(plist_source, plist_target)) {
+ cmCPackLogger(
+ cmCPackLog::LOG_ERROR,
"Error copying plist. Check the value of CPACK_BUNDLE_PLIST."
- << std::endl);
+ << std::endl);
return 0;
- }
+ }
// Install a user-provided bundle icon ...
std::ostringstream icon_source;
@@ -144,52 +141,48 @@ int cmCPackBundleGenerator::ConstructBundle()
std::ostringstream icon_target;
icon_target << resources.str() << "/" << cpack_bundle_name << ".icns";
- if(!this->CopyFile(icon_source, icon_target))
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
+ if (!this->CopyFile(icon_source, icon_target)) {
+ cmCPackLogger(
+ cmCPackLog::LOG_ERROR,
"Error copying bundle icon. Check the value of CPACK_BUNDLE_ICON."
- << std::endl);
+ << std::endl);
return 0;
- }
+ }
// Optionally a user-provided startup command (could be an
// executable or a script) ...
- if(!cpack_bundle_startup_command.empty())
- {
+ if (!cpack_bundle_startup_command.empty()) {
std::ostringstream command_source;
command_source << cpack_bundle_startup_command;
std::ostringstream command_target;
command_target << application.str() << "/" << cpack_bundle_name;
- if(!this->CopyFile(command_source, command_target))
- {
+ if (!this->CopyFile(command_source, command_target)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error copying startup command. "
" Check the value of CPACK_BUNDLE_STARTUP_COMMAND."
- << std::endl);
+ << std::endl);
return 0;
- }
+ }
cmSystemTools::SetPermissions(command_target.str().c_str(), 0777);
- }
+ }
return 1;
}
int cmCPackBundleGenerator::PackageFiles()
{
- if(!this->ConstructBundle())
- {
+ if (!this->ConstructBundle()) {
return 0;
- }
+ }
- if(!this->SignBundle(toplevel))
- {
+ if (!this->SignBundle(toplevel)) {
return 0;
- }
+ }
return this->CreateDMG(toplevel, packageFileNames[0]);
}
@@ -199,16 +192,15 @@ bool cmCPackBundleGenerator::SupportsComponentInstallation() const
return false;
}
-
int cmCPackBundleGenerator::SignBundle(const std::string& src_dir)
{
const std::string cpack_apple_cert_app =
this->GetOption("CPACK_BUNDLE_APPLE_CERT_APP")
- ? this->GetOption("CPACK_BUNDLE_APPLE_CERT_APP") : "";
+ ? this->GetOption("CPACK_BUNDLE_APPLE_CERT_APP")
+ : "";
// codesign the application.
- if(!cpack_apple_cert_app.empty())
- {
+ if (!cpack_apple_cert_app.empty()) {
std::string output;
std::string bundle_path;
bundle_path = src_dir + "/";
@@ -223,15 +215,15 @@ int cmCPackBundleGenerator::SignBundle(const std::string& src_dir)
const std::string sign_files =
this->GetOption("CPACK_BUNDLE_APPLE_CODESIGN_FILES")
- ? this->GetOption("CPACK_BUNDLE_APPLE_CODESIGN_FILES") : "";
+ ? this->GetOption("CPACK_BUNDLE_APPLE_CODESIGN_FILES")
+ : "";
std::vector<std::string> relFiles;
cmSystemTools::ExpandListArgument(sign_files, relFiles);
// sign the files supplied by the user, ie. frameworks.
- for(std::vector<std::string>::iterator it = relFiles.begin();
- it != relFiles.end(); ++it)
- {
+ for (std::vector<std::string>::iterator it = relFiles.begin();
+ it != relFiles.end(); ++it) {
std::ostringstream temp_sign_file_cmd;
temp_sign_file_cmd << this->GetOption("CPACK_COMMAND_CODESIGN");
temp_sign_file_cmd << " " << sign_parameter << " -s \""
@@ -242,15 +234,14 @@ int cmCPackBundleGenerator::SignBundle(const std::string& src_dir)
temp_sign_file_cmd << bundle_path;
temp_sign_file_cmd << it->c_str() << "\"";
- if(!this->RunCommand(temp_sign_file_cmd, &output))
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error signing file:"
- << bundle_path << it->c_str() << std::endl << output << std::endl);
+ if (!this->RunCommand(temp_sign_file_cmd, &output)) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Error signing file:"
+ << bundle_path << it->c_str() << std::endl
+ << output << std::endl);
return 0;
- }
}
+ }
// sign main binary
std::ostringstream temp_sign_binary_cmd;
@@ -259,43 +250,42 @@ int cmCPackBundleGenerator::SignBundle(const std::string& src_dir)
<< cpack_apple_cert_app;
temp_sign_binary_cmd << "\" \"" << bundle_path << "\"";
- if(!this->RunCommand(temp_sign_binary_cmd, &output))
- {
+ if (!this->RunCommand(temp_sign_binary_cmd, &output)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error signing the application binary."
- << std::endl << output << std::endl);
+ "Error signing the application binary." << std::endl
+ << output
+ << std::endl);
return 0;
- }
+ }
// sign app bundle
std::ostringstream temp_codesign_cmd;
temp_codesign_cmd << this->GetOption("CPACK_COMMAND_CODESIGN");
temp_codesign_cmd << " " << sign_parameter << " -s \""
<< cpack_apple_cert_app << "\"";
- if(this->GetOption("CPACK_BUNDLE_APPLE_ENTITLEMENTS"))
- {
+ if (this->GetOption("CPACK_BUNDLE_APPLE_ENTITLEMENTS")) {
temp_codesign_cmd << " --entitlements ";
temp_codesign_cmd << this->GetOption("CPACK_BUNDLE_APPLE_ENTITLEMENTS");
- }
+ }
temp_codesign_cmd << " \"" << bundle_path << "\"";
- if(!this->RunCommand(temp_codesign_cmd, &output))
- {
+ if (!this->RunCommand(temp_codesign_cmd, &output)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error signing the application package."
- << std::endl << output << std::endl);
+ "Error signing the application package." << std::endl
+ << output
+ << std::endl);
return 0;
- }
+ }
- cmCPackLogger(cmCPackLog::LOG_OUTPUT,
- "- Application has been codesigned"
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Application has been codesigned"
+ << std::endl);
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
- (this->GetOption("CPACK_BUNDLE_APPLE_ENTITLEMENTS")
- ? "with entitlement sandboxing" : "without entitlement sandboxing")
- << std::endl);
+ (this->GetOption("CPACK_BUNDLE_APPLE_ENTITLEMENTS")
+ ? "with entitlement sandboxing"
+ : "without entitlement sandboxing")
+ << std::endl);
}
return 1;
diff --git a/Source/CPack/cmCPackComponentGroup.cxx b/Source/CPack/cmCPackComponentGroup.cxx
index 88c59f3..d262ac9 100644
--- a/Source/CPack/cmCPackComponentGroup.cxx
+++ b/Source/CPack/cmCPackComponentGroup.cxx
@@ -18,28 +18,26 @@
#include <vector>
unsigned long cmCPackComponent::GetInstalledSize(
- const std::string& installDir) const
+ const std::string& installDir) const
{
- if (this->TotalSize != 0)
- {
+ if (this->TotalSize != 0) {
return this->TotalSize;
- }
+ }
std::vector<std::string>::const_iterator fileIt;
- for (fileIt = this->Files.begin(); fileIt != this->Files.end(); ++fileIt)
- {
+ for (fileIt = this->Files.begin(); fileIt != this->Files.end(); ++fileIt) {
std::string path = installDir;
path += '/';
path += *fileIt;
this->TotalSize += cmSystemTools::FileLength(path);
- }
+ }
return this->TotalSize;
}
-unsigned long
-cmCPackComponent::GetInstalledSizeInKbytes(const std::string& installDir) const
+unsigned long cmCPackComponent::GetInstalledSizeInKbytes(
+ const std::string& installDir) const
{
unsigned long result = (GetInstalledSize(installDir) + 512) / 1024;
- return result? result : 1;
+ return result ? result : 1;
}
diff --git a/Source/CPack/cmCPackComponentGroup.h b/Source/CPack/cmCPackComponentGroup.h
index 0679638..5361d95 100644
--- a/Source/CPack/cmCPackComponentGroup.h
+++ b/Source/CPack/cmCPackComponentGroup.h
@@ -42,9 +42,15 @@ public:
class cmCPackComponent
{
public:
- cmCPackComponent() : Group(0), IsRequired(true), IsHidden(false),
- IsDisabledByDefault(false), IsDownloaded(false),
- TotalSize(0) { }
+ cmCPackComponent()
+ : Group(0)
+ , IsRequired(true)
+ , IsHidden(false)
+ , IsDisabledByDefault(false)
+ , IsDownloaded(false)
+ , TotalSize(0)
+ {
+ }
/// The name of the component (used to reference the component).
std::string Name;
@@ -53,7 +59,7 @@ public:
std::string DisplayName;
/// The component group that contains this component (if any).
- cmCPackComponentGroup *Group;
+ cmCPackComponentGroup* Group;
/// Whether this component group must always be installed.
bool IsRequired : 1;
@@ -73,17 +79,17 @@ public:
std::string Description;
/// The installation types that this component is a part of.
- std::vector<cmCPackInstallationType *> InstallationTypes;
+ std::vector<cmCPackInstallationType*> InstallationTypes;
/// If IsDownloaded is true, the name of the archive file that
/// contains the files that are part of this component.
std::string ArchiveFile;
/// The components that this component depends on.
- std::vector<cmCPackComponent *> Dependencies;
+ std::vector<cmCPackComponent*> Dependencies;
/// The components that depend on this component.
- std::vector<cmCPackComponent *> ReverseDependencies;
+ std::vector<cmCPackComponent*> ReverseDependencies;
/// The list of installed files that are part of this component.
std::vector<std::string> Files;
@@ -100,7 +106,7 @@ public:
/// kilobytes.
unsigned long GetInstalledSizeInKbytes(const std::string& installDir) const;
- private:
+private:
mutable unsigned long TotalSize;
};
@@ -110,7 +116,10 @@ public:
class cmCPackComponentGroup
{
public:
- cmCPackComponentGroup() : ParentGroup(0) { }
+ cmCPackComponentGroup()
+ : ParentGroup(0)
+ {
+ }
/// The name of the group (used to reference the group).
std::string Name;
@@ -131,7 +140,7 @@ public:
std::vector<cmCPackComponent*> Components;
/// The parent group of this component group (if any).
- cmCPackComponentGroup *ParentGroup;
+ cmCPackComponentGroup* ParentGroup;
/// The subgroups of this group.
std::vector<cmCPackComponentGroup*> Subgroups;
diff --git a/Source/CPack/cmCPackCygwinBinaryGenerator.cxx b/Source/CPack/cmCPackCygwinBinaryGenerator.cxx
index a3176e9..83af89e 100644
--- a/Source/CPack/cmCPackCygwinBinaryGenerator.cxx
+++ b/Source/CPack/cmCPackCygwinBinaryGenerator.cxx
@@ -45,8 +45,7 @@ int cmCPackCygwinBinaryGenerator::PackageFiles()
std::string manifest = "/usr/share/doc/";
manifest += packageName;
manifest += "/MANIFEST";
- std::string manifestFile
- = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
+ std::string manifestFile = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
// Create a MANIFEST file that contains all of the files in
// the tar file
std::string tempdir = manifestFile;
@@ -54,14 +53,13 @@ int cmCPackCygwinBinaryGenerator::PackageFiles()
// create an extra scope to force the stream
// to create the file before the super class is called
{
- cmGeneratedFileStream ofs(manifestFile.c_str());
- for(std::vector<std::string>::const_iterator i = files.begin();
- i != files.end(); ++i)
- {
- // remove the temp dir and replace with /usr
- ofs << (*i).substr(tempdir.size()) << "\n";
+ cmGeneratedFileStream ofs(manifestFile.c_str());
+ for (std::vector<std::string>::const_iterator i = files.begin();
+ i != files.end(); ++i) {
+ // remove the temp dir and replace with /usr
+ ofs << (*i).substr(tempdir.size()) << "\n";
}
- ofs << manifest << "\n";
+ ofs << manifest << "\n";
}
// add the manifest file to the list of all files
files.push_back(manifestFile);
@@ -73,14 +71,13 @@ int cmCPackCygwinBinaryGenerator::PackageFiles()
const char* cmCPackCygwinBinaryGenerator::GetOutputExtension()
{
this->OutputExtension = "-";
- const char* patchNumber =this->GetOption("CPACK_CYGWIN_PATCH_NUMBER");
- if(!patchNumber)
- {
+ const char* patchNumber = this->GetOption("CPACK_CYGWIN_PATCH_NUMBER");
+ if (!patchNumber) {
patchNumber = "1";
cmCPackLogger(cmCPackLog::LOG_WARNING,
"CPACK_CYGWIN_PATCH_NUMBER not specified using 1"
- << std::endl);
- }
+ << std::endl);
+ }
this->OutputExtension += patchNumber;
this->OutputExtension += ".tar.bz2";
return this->OutputExtension.c_str();
diff --git a/Source/CPack/cmCPackCygwinBinaryGenerator.h b/Source/CPack/cmCPackCygwinBinaryGenerator.h
index 38f6df1..8de4bae 100644
--- a/Source/CPack/cmCPackCygwinBinaryGenerator.h
+++ b/Source/CPack/cmCPackCygwinBinaryGenerator.h
@@ -28,6 +28,7 @@ public:
*/
cmCPackCygwinBinaryGenerator();
virtual ~cmCPackCygwinBinaryGenerator();
+
protected:
virtual int InitializeInternal();
int PackageFiles();
diff --git a/Source/CPack/cmCPackCygwinSourceGenerator.cxx b/Source/CPack/cmCPackCygwinSourceGenerator.cxx
index 132ebcf..5fcfaf4 100644
--- a/Source/CPack/cmCPackCygwinSourceGenerator.cxx
+++ b/Source/CPack/cmCPackCygwinSourceGenerator.cxx
@@ -25,8 +25,8 @@
// system tools because it is not implemented robustly enough to move
// files across directories.
#ifdef _WIN32
-# include <sys/stat.h>
-# include <windows.h>
+#include <sys/stat.h>
+#include <windows.h>
#endif
cmCPackCygwinSourceGenerator::cmCPackCygwinSourceGenerator()
@@ -46,8 +46,8 @@ int cmCPackCygwinSourceGenerator::InitializeInternal()
int cmCPackCygwinSourceGenerator::PackageFiles()
{
// Create a tar file of the sources
- std::string packageDirFileName
- = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
+ std::string packageDirFileName =
+ this->GetOption("CPACK_TEMPORARY_DIRECTORY");
packageDirFileName += ".tar.bz2";
packageFileNames[0] = packageDirFileName;
std::string output;
@@ -55,10 +55,9 @@ int cmCPackCygwinSourceGenerator::PackageFiles()
// to create tar.bz2 file with the list of source
// files
this->Compress = cmArchiveWrite::CompressBZip2;
- if ( !this->cmCPackTarBZip2Generator::PackageFiles() )
- {
+ if (!this->cmCPackTarBZip2Generator::PackageFiles()) {
return 0;
- }
+ }
// Now create a tar file that contains the above .tar.bz2 file
// and the CPACK_CYGWIN_PATCH_FILE and CPACK_TOPLEVEL_DIRECTORY
// files
@@ -76,47 +75,41 @@ int cmCPackCygwinSourceGenerator::PackageFiles()
// to the toplevel cpack temp dir
// copy the patch file into place
- if(!this->GetOption("CPACK_CYGWIN_PATCH_FILE"))
- {
+ if (!this->GetOption("CPACK_CYGWIN_PATCH_FILE")) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"No patch file specified for cygwin sources.");
return 0;
- }
- if(!cmSystemTools::CopyFileAlways(
- this->GetOption("CPACK_CYGWIN_PATCH_FILE"),
- this->GetOption("CPACK_TOPLEVEL_DIRECTORY")))
- {
+ }
+ if (!cmSystemTools::CopyFileAlways(
+ this->GetOption("CPACK_CYGWIN_PATCH_FILE"),
+ this->GetOption("CPACK_TOPLEVEL_DIRECTORY"))) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "problem copying: ["
- << this->GetOption("CPACK_CYGWIN_PATCH_FILE") << "]\nto\n["
- << this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "]\n");
+ << this->GetOption("CPACK_CYGWIN_PATCH_FILE") << "]\nto\n["
+ << this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "]\n");
return 0;
- }
- if(!this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT"))
- {
+ }
+ if (!this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT")) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"No build script specified for cygwin sources.");
return 0;
- }
+ }
// copy the build script into place
- if(!cmSystemTools::CopyFileAlways(
- this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT"),
- this->GetOption("CPACK_TOPLEVEL_DIRECTORY")))
- {
+ if (!cmSystemTools::CopyFileAlways(
+ this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT"),
+ this->GetOption("CPACK_TOPLEVEL_DIRECTORY"))) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "problem copying: "
- << this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT") << "\nto\n"
- << this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "]\n");
+ << this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT") << "\nto\n"
+ << this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "]\n");
return 0;
- }
- std::string outerTarFile
- = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
+ }
+ std::string outerTarFile = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
outerTarFile += "-";
const char* patch = this->GetOption("CPACK_CYGWIN_PATCH_NUMBER");
- if(!patch)
- {
+ if (!patch) {
cmCPackLogger(cmCPackLog::LOG_WARNING, "CPACK_CYGWIN_PATCH_NUMBER"
- << " not specified, defaulting to 1\n");
+ << " not specified, defaulting to 1\n");
patch = "1";
- }
+ }
outerTarFile += patch;
outerTarFile += "-src.tar.bz2";
std::string tmpDir = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
@@ -126,8 +119,8 @@ int cmCPackCygwinSourceGenerator::PackageFiles()
this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT"));
std::string patchFile = tmpDir;
patchFile += "/";
- patchFile += cmSystemTools::GetFilenameName(
- this->GetOption("CPACK_CYGWIN_PATCH_FILE"));
+ patchFile +=
+ cmSystemTools::GetFilenameName(this->GetOption("CPACK_CYGWIN_PATCH_FILE"));
std::string file = cmSystemTools::GetFilenameName(compressOutFile);
std::string sourceTar = cmSystemTools::GetFilenamePath(compressOutFile);
@@ -146,10 +139,9 @@ int cmCPackCygwinSourceGenerator::PackageFiles()
packageFileNames[0] = outerTarFile;
/* update the toplevel dir */
toplevel = tmpDir;
- if ( !this->cmCPackTarBZip2Generator::PackageFiles() )
- {
+ if (!this->cmCPackTarBZip2Generator::PackageFiles()) {
return 0;
- }
+ }
return 1;
}
@@ -164,14 +156,12 @@ const char* cmCPackCygwinSourceGenerator::GetOutputExtension()
{
this->OutputExtension = "-";
const char* patch = this->GetOption("CPACK_CYGWIN_PATCH_NUMBER");
- if(!patch)
- {
+ if (!patch) {
cmCPackLogger(cmCPackLog::LOG_WARNING, "CPACK_CYGWIN_PATCH_NUMBER"
- << " not specified, defaulting to 1\n");
+ << " not specified, defaulting to 1\n");
patch = "1";
- }
+ }
this->OutputExtension += patch;
this->OutputExtension += "-src.tar.bz2";
return this->OutputExtension.c_str();
}
-
diff --git a/Source/CPack/cmCPackCygwinSourceGenerator.h b/Source/CPack/cmCPackCygwinSourceGenerator.h
index 9d98a9b..4aba8b9 100644
--- a/Source/CPack/cmCPackCygwinSourceGenerator.h
+++ b/Source/CPack/cmCPackCygwinSourceGenerator.h
@@ -28,6 +28,7 @@ public:
*/
cmCPackCygwinSourceGenerator();
virtual ~cmCPackCygwinSourceGenerator();
+
protected:
const char* GetPackagingInstallPrefix();
virtual int InitializeInternal();
diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx
index aec06b7..7675677 100644
--- a/Source/CPack/cmCPackDebGenerator.cxx
+++ b/Source/CPack/cmCPackDebGenerator.cxx
@@ -30,7 +30,8 @@
// a GNU ar.
// See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=161593 for more info
// Therefore we provide our own implementation of a BSD-ar:
-static int ar_append(const char*archive,const std::vector<std::string>& files);
+static int ar_append(const char* archive,
+ const std::vector<std::string>& files);
cmCPackDebGenerator::cmCPackDebGenerator()
{
@@ -43,70 +44,63 @@ cmCPackDebGenerator::~cmCPackDebGenerator()
int cmCPackDebGenerator::InitializeInternal()
{
this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr");
- if (cmSystemTools::IsOff(this->GetOption("CPACK_SET_DESTDIR")))
- {
+ if (cmSystemTools::IsOff(this->GetOption("CPACK_SET_DESTDIR"))) {
this->SetOption("CPACK_SET_DESTDIR", "I_ON");
- }
+ }
return this->Superclass::InitializeInternal();
}
int cmCPackDebGenerator::PackageOnePack(std::string initialTopLevel,
std::string packageName)
- {
+{
int retval = 1;
// Begin the archive for this pack
std::string localToplevel(initialTopLevel);
- std::string packageFileName(
- cmSystemTools::GetParentDirectory(toplevel)
- );
- std::string outputFileName(
- cmsys::SystemTools::LowerCase(
- std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")))
- +"-"+packageName + this->GetOutputExtension()
- );
-
- localToplevel += "/"+ packageName;
+ std::string packageFileName(cmSystemTools::GetParentDirectory(toplevel));
+ std::string outputFileName(cmsys::SystemTools::LowerCase(std::string(
+ this->GetOption("CPACK_PACKAGE_FILE_NAME"))) +
+ "-" + packageName + this->GetOutputExtension());
+
+ localToplevel += "/" + packageName;
/* replace the TEMP DIRECTORY with the component one */
- this->SetOption("CPACK_TEMPORARY_DIRECTORY",localToplevel.c_str());
- packageFileName += "/"+ outputFileName;
+ this->SetOption("CPACK_TEMPORARY_DIRECTORY", localToplevel.c_str());
+ packageFileName += "/" + outputFileName;
/* replace proposed CPACK_OUTPUT_FILE_NAME */
- this->SetOption("CPACK_OUTPUT_FILE_NAME",outputFileName.c_str());
+ this->SetOption("CPACK_OUTPUT_FILE_NAME", outputFileName.c_str());
/* replace the TEMPORARY package file name */
this->SetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME",
- packageFileName.c_str());
+ packageFileName.c_str());
// Tell CPackDeb.cmake the name of the component GROUP.
- this->SetOption("CPACK_DEB_PACKAGE_COMPONENT",packageName.c_str());
+ this->SetOption("CPACK_DEB_PACKAGE_COMPONENT", packageName.c_str());
// Tell CPackDeb.cmake the path where the component is.
std::string component_path = "/";
component_path += packageName;
this->SetOption("CPACK_DEB_PACKAGE_COMPONENT_PART_PATH",
component_path.c_str());
- if (!this->ReadListFile("CPackDeb.cmake"))
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error while execution CPackDeb.cmake" << std::endl);
+ if (!this->ReadListFile("CPackDeb.cmake")) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Error while execution CPackDeb.cmake"
+ << std::endl);
retval = 0;
return retval;
- }
+ }
cmsys::Glob gl;
std::string findExpr(this->GetOption("GEN_WDIR"));
findExpr += "/*";
gl.RecurseOn();
gl.SetRecurseListDirs(true);
- if ( !gl.FindFiles(findExpr) )
- {
+ if (!gl.FindFiles(findExpr)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Cannot find any files in the installed directory" << std::endl);
+ "Cannot find any files in the installed directory"
+ << std::endl);
return 0;
- }
+ }
packageFiles = gl.GetFiles();
int res = createDeb();
- if (res != 1)
- {
+ if (res != 1) {
retval = 0;
- }
+ }
// add the generated package to package file names list
packageFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
packageFileName += "/";
@@ -125,53 +119,46 @@ int cmCPackDebGenerator::PackageComponents(bool ignoreGroup)
// The default behavior is to have one package by component group
// unless CPACK_COMPONENTS_IGNORE_GROUP is specified.
- if (!ignoreGroup)
- {
+ if (!ignoreGroup) {
std::map<std::string, cmCPackComponentGroup>::iterator compGIt;
- for (compGIt=this->ComponentGroups.begin();
- compGIt!=this->ComponentGroups.end(); ++compGIt)
- {
+ for (compGIt = this->ComponentGroups.begin();
+ compGIt != this->ComponentGroups.end(); ++compGIt) {
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: "
- << compGIt->first
- << std::endl);
+ << compGIt->first << std::endl);
// Begin the archive for this group
- retval &= PackageOnePack(initialTopLevel,compGIt->first);
- }
+ retval &= PackageOnePack(initialTopLevel, compGIt->first);
+ }
// Handle Orphan components (components not belonging to any groups)
std::map<std::string, cmCPackComponent>::iterator compIt;
- for (compIt=this->Components.begin();
- compIt!=this->Components.end(); ++compIt )
- {
+ for (compIt = this->Components.begin(); compIt != this->Components.end();
+ ++compIt) {
// Does the component belong to a group?
- if (compIt->second.Group==NULL)
- {
- cmCPackLogger(cmCPackLog::LOG_VERBOSE,
- "Component <"
+ if (compIt->second.Group == NULL) {
+ cmCPackLogger(
+ cmCPackLog::LOG_VERBOSE, "Component <"
<< compIt->second.Name
<< "> does not belong to any group, package it separately."
<< std::endl);
// Begin the archive for this orphan component
- retval &= PackageOnePack(initialTopLevel,compIt->first);
- }
+ retval &= PackageOnePack(initialTopLevel, compIt->first);
}
}
+ }
// CPACK_COMPONENTS_IGNORE_GROUPS is set
// We build 1 package per component
- else
- {
+ else {
std::map<std::string, cmCPackComponent>::iterator compIt;
- for (compIt=this->Components.begin();
- compIt!=this->Components.end(); ++compIt )
- {
- retval &= PackageOnePack(initialTopLevel,compIt->first);
- }
+ for (compIt = this->Components.begin(); compIt != this->Components.end();
+ ++compIt) {
+ retval &= PackageOnePack(initialTopLevel, compIt->first);
}
+ }
return retval;
}
//----------------------------------------------------------------------
int cmCPackDebGenerator::PackageComponentsAllInOne(
- const std::string& compInstDirName)
+ const std::string& compInstDirName)
{
int retval = 1;
/* Reset package file name list it will be populated during the
@@ -182,65 +169,57 @@ int cmCPackDebGenerator::PackageComponentsAllInOne(
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
"Packaging all groups in one package..."
"(CPACK_COMPONENTS_ALL_[GROUPS_]IN_ONE_PACKAGE is set)"
- << std::endl);
+ << std::endl);
// The ALL GROUPS in ONE package case
std::string localToplevel(initialTopLevel);
- std::string packageFileName(
- cmSystemTools::GetParentDirectory(toplevel)
- );
- std::string outputFileName(
- cmsys::SystemTools::LowerCase(
- std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")))
- + this->GetOutputExtension()
- );
+ std::string packageFileName(cmSystemTools::GetParentDirectory(toplevel));
+ std::string outputFileName(cmsys::SystemTools::LowerCase(std::string(
+ this->GetOption("CPACK_PACKAGE_FILE_NAME"))) +
+ this->GetOutputExtension());
// all GROUP in one vs all COMPONENT in one
- localToplevel += "/"+compInstDirName;
+ localToplevel += "/" + compInstDirName;
/* replace the TEMP DIRECTORY with the component one */
- this->SetOption("CPACK_TEMPORARY_DIRECTORY",localToplevel.c_str());
- packageFileName += "/"+ outputFileName;
+ this->SetOption("CPACK_TEMPORARY_DIRECTORY", localToplevel.c_str());
+ packageFileName += "/" + outputFileName;
/* replace proposed CPACK_OUTPUT_FILE_NAME */
- this->SetOption("CPACK_OUTPUT_FILE_NAME",outputFileName.c_str());
+ this->SetOption("CPACK_OUTPUT_FILE_NAME", outputFileName.c_str());
/* replace the TEMPORARY package file name */
this->SetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME",
- packageFileName.c_str());
+ packageFileName.c_str());
- if(!compInstDirName.empty())
- {
+ if (!compInstDirName.empty()) {
// Tell CPackDeb.cmake the path where the component is.
std::string component_path = "/";
component_path += compInstDirName;
this->SetOption("CPACK_DEB_PACKAGE_COMPONENT_PART_PATH",
component_path.c_str());
- }
- if (!this->ReadListFile("CPackDeb.cmake"))
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error while execution CPackDeb.cmake" << std::endl);
+ }
+ if (!this->ReadListFile("CPackDeb.cmake")) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Error while execution CPackDeb.cmake"
+ << std::endl);
retval = 0;
return retval;
- }
+ }
cmsys::Glob gl;
std::string findExpr(this->GetOption("GEN_WDIR"));
findExpr += "/*";
gl.RecurseOn();
gl.SetRecurseListDirs(true);
- if ( !gl.FindFiles(findExpr) )
- {
+ if (!gl.FindFiles(findExpr)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Cannot find any files in the installed directory" << std::endl);
+ "Cannot find any files in the installed directory"
+ << std::endl);
return 0;
- }
+ }
packageFiles = gl.GetFiles();
-
int res = createDeb();
- if (res != 1)
- {
+ if (res != 1) {
retval = 0;
- }
+ }
// add the generated package to package file names list
packageFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
packageFileName += "/";
@@ -256,25 +235,22 @@ int cmCPackDebGenerator::PackageFiles()
// CASE 1 : COMPONENT ALL-IN-ONE package
// If ALL GROUPS or ALL COMPONENTS in ONE package has been requested
// then the package file is unique and should be open here.
- if (componentPackageMethod == ONE_PACKAGE)
- {
+ if (componentPackageMethod == ONE_PACKAGE) {
return PackageComponentsAllInOne("ALL_COMPONENTS_IN_ONE");
- }
+ }
// CASE 2 : COMPONENT CLASSICAL package(s) (i.e. not all-in-one)
// There will be 1 package for each component group
// however one may require to ignore component group and
// in this case you'll get 1 package for each component.
- else
- {
+ else {
return PackageComponents(componentPackageMethod ==
ONE_PACKAGE_PER_COMPONENT);
- }
+ }
}
// CASE 3 : NON COMPONENT package.
- else
- {
+ else {
return PackageComponentsAllInOne("");
- }
+ }
}
int cmCPackDebGenerator::createDeb()
@@ -282,11 +258,11 @@ int cmCPackDebGenerator::createDeb()
// debian-binary file
const std::string strGenWDIR(this->GetOption("GEN_WDIR"));
const std::string dbfilename = strGenWDIR + "/debian-binary";
- { // the scope is needed for cmGeneratedFileStream
+ { // the scope is needed for cmGeneratedFileStream
cmGeneratedFileStream out(dbfilename.c_str());
out << "2.0";
out << std::endl; // required for valid debian package
- }
+ }
// control file
std::string ctlfilename = strGenWDIR + "/control";
@@ -294,194 +270,171 @@ int cmCPackDebGenerator::createDeb()
// debian policy enforce lower case for package name
// mandatory entries:
std::string debian_pkg_name = cmsys::SystemTools::LowerCase(
- this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_NAME") );
+ this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_NAME"));
const char* debian_pkg_version =
- this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_VERSION");
+ this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_VERSION");
const char* debian_pkg_section =
- this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SECTION");
+ this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SECTION");
const char* debian_pkg_priority =
- this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_PRIORITY");
+ this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_PRIORITY");
const char* debian_pkg_arch =
- this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_ARCHITECTURE");
+ this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_ARCHITECTURE");
const char* maintainer =
- this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_MAINTAINER");
- const char* desc =
- this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_DESCRIPTION");
+ this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_MAINTAINER");
+ const char* desc = this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_DESCRIPTION");
// optional entries
const char* debian_pkg_dep =
- this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_DEPENDS");
+ this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_DEPENDS");
const char* debian_pkg_rec =
- this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_RECOMMENDS");
+ this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_RECOMMENDS");
const char* debian_pkg_sug =
- this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SUGGESTS");
+ this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SUGGESTS");
const char* debian_pkg_url =
- this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_HOMEPAGE");
+ this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_HOMEPAGE");
const char* debian_pkg_predep =
- this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_PREDEPENDS");
+ this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_PREDEPENDS");
const char* debian_pkg_enhances =
- this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_ENHANCES");
+ this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_ENHANCES");
const char* debian_pkg_breaks =
- this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_BREAKS");
+ this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_BREAKS");
const char* debian_pkg_conflicts =
- this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_CONFLICTS");
+ this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_CONFLICTS");
const char* debian_pkg_provides =
- this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_PROVIDES");
+ this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_PROVIDES");
const char* debian_pkg_replaces =
- this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_REPLACES");
+ this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_REPLACES");
const char* debian_pkg_source =
- this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SOURCE");
-
+ this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SOURCE");
- { // the scope is needed for cmGeneratedFileStream
+ { // the scope is needed for cmGeneratedFileStream
cmGeneratedFileStream out(ctlfilename.c_str());
out << "Package: " << debian_pkg_name << "\n";
out << "Version: " << debian_pkg_version << "\n";
out << "Section: " << debian_pkg_section << "\n";
out << "Priority: " << debian_pkg_priority << "\n";
out << "Architecture: " << debian_pkg_arch << "\n";
- if(debian_pkg_source && *debian_pkg_source)
- {
+ if (debian_pkg_source && *debian_pkg_source) {
out << "Source: " << debian_pkg_source << "\n";
- }
- if(debian_pkg_dep && *debian_pkg_dep)
- {
+ }
+ if (debian_pkg_dep && *debian_pkg_dep) {
out << "Depends: " << debian_pkg_dep << "\n";
- }
- if(debian_pkg_rec && *debian_pkg_rec)
- {
+ }
+ if (debian_pkg_rec && *debian_pkg_rec) {
out << "Recommends: " << debian_pkg_rec << "\n";
- }
- if(debian_pkg_sug && *debian_pkg_sug)
- {
+ }
+ if (debian_pkg_sug && *debian_pkg_sug) {
out << "Suggests: " << debian_pkg_sug << "\n";
- }
- if(debian_pkg_url && *debian_pkg_url)
- {
+ }
+ if (debian_pkg_url && *debian_pkg_url) {
out << "Homepage: " << debian_pkg_url << "\n";
- }
- if (debian_pkg_predep && *debian_pkg_predep)
- {
+ }
+ if (debian_pkg_predep && *debian_pkg_predep) {
out << "Pre-Depends: " << debian_pkg_predep << "\n";
- }
- if (debian_pkg_enhances && *debian_pkg_enhances)
- {
+ }
+ if (debian_pkg_enhances && *debian_pkg_enhances) {
out << "Enhances: " << debian_pkg_enhances << "\n";
- }
- if (debian_pkg_breaks && *debian_pkg_breaks)
- {
+ }
+ if (debian_pkg_breaks && *debian_pkg_breaks) {
out << "Breaks: " << debian_pkg_breaks << "\n";
- }
- if (debian_pkg_conflicts && *debian_pkg_conflicts)
- {
+ }
+ if (debian_pkg_conflicts && *debian_pkg_conflicts) {
out << "Conflicts: " << debian_pkg_conflicts << "\n";
- }
- if (debian_pkg_provides && *debian_pkg_provides)
- {
+ }
+ if (debian_pkg_provides && *debian_pkg_provides) {
out << "Provides: " << debian_pkg_provides << "\n";
- }
- if (debian_pkg_replaces && *debian_pkg_replaces)
- {
+ }
+ if (debian_pkg_replaces && *debian_pkg_replaces) {
out << "Replaces: " << debian_pkg_replaces << "\n";
- }
+ }
unsigned long totalSize = 0;
{
std::string dirName = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
dirName += '/';
for (std::vector<std::string>::const_iterator fileIt =
- packageFiles.begin();
- fileIt != packageFiles.end(); ++ fileIt )
- {
+ packageFiles.begin();
+ fileIt != packageFiles.end(); ++fileIt) {
totalSize += cmSystemTools::FileLength(*fileIt);
- }
+ }
}
out << "Installed-Size: " << (totalSize + 1023) / 1024 << "\n";
out << "Maintainer: " << maintainer << "\n";
out << "Description: " << desc << "\n";
out << std::endl;
- }
+ }
const std::string shlibsfilename = strGenWDIR + "/shlibs";
- const char* debian_pkg_shlibs = this->GetOption(
- "GEN_CPACK_DEBIAN_PACKAGE_SHLIBS");
- const bool gen_shibs = this->IsOn("CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS")
- && debian_pkg_shlibs && *debian_pkg_shlibs;
- if( gen_shibs )
- {
+ const char* debian_pkg_shlibs =
+ this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SHLIBS");
+ const bool gen_shibs = this->IsOn("CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS") &&
+ debian_pkg_shlibs && *debian_pkg_shlibs;
+ if (gen_shibs) {
cmGeneratedFileStream out(shlibsfilename.c_str());
out << debian_pkg_shlibs;
out << std::endl;
- }
+ }
const std::string postinst = strGenWDIR + "/postinst";
const std::string postrm = strGenWDIR + "/postrm";
- if(this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTINST"))
- {
+ if (this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTINST")) {
cmGeneratedFileStream out(postinst.c_str());
- out <<
- "#!/bin/sh\n\n"
- "set -e\n\n"
- "if [ \"$1\" = \"configure\" ]; then\n"
- "\tldconfig\n"
- "fi\n";
- }
- if(this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTRM"))
- {
+ out << "#!/bin/sh\n\n"
+ "set -e\n\n"
+ "if [ \"$1\" = \"configure\" ]; then\n"
+ "\tldconfig\n"
+ "fi\n";
+ }
+ if (this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTRM")) {
cmGeneratedFileStream out(postrm.c_str());
- out <<
- "#!/bin/sh\n\n"
- "set -e\n\n"
- "if [ \"$1\" = \"remove\" ]; then\n"
- "\tldconfig\n"
- "fi\n";
- }
+ out << "#!/bin/sh\n\n"
+ "set -e\n\n"
+ "if [ \"$1\" = \"remove\" ]; then\n"
+ "\tldconfig\n"
+ "fi\n";
+ }
cmArchiveWrite::Compress tar_compression_type = cmArchiveWrite::CompressGZip;
const char* debian_compression_type =
- this->GetOption("GEN_CPACK_DEBIAN_COMPRESSION_TYPE");
- if(!debian_compression_type)
- {
+ this->GetOption("GEN_CPACK_DEBIAN_COMPRESSION_TYPE");
+ if (!debian_compression_type) {
debian_compression_type = "gzip";
- }
+ }
std::string compression_suffix;
- if(!strcmp(debian_compression_type, "lzma")) {
- compression_suffix = ".lzma";
- tar_compression_type = cmArchiveWrite::CompressLZMA;
- } else if(!strcmp(debian_compression_type, "xz")) {
- compression_suffix = ".xz";
- tar_compression_type = cmArchiveWrite::CompressXZ;
- } else if(!strcmp(debian_compression_type, "bzip2")) {
- compression_suffix = ".bz2";
- tar_compression_type = cmArchiveWrite::CompressBZip2;
- } else if(!strcmp(debian_compression_type, "gzip")) {
- compression_suffix = ".gz";
- tar_compression_type = cmArchiveWrite::CompressGZip;
- } else if(!strcmp(debian_compression_type, "none")) {
- compression_suffix = "";
- tar_compression_type = cmArchiveWrite::CompressNone;
+ if (!strcmp(debian_compression_type, "lzma")) {
+ compression_suffix = ".lzma";
+ tar_compression_type = cmArchiveWrite::CompressLZMA;
+ } else if (!strcmp(debian_compression_type, "xz")) {
+ compression_suffix = ".xz";
+ tar_compression_type = cmArchiveWrite::CompressXZ;
+ } else if (!strcmp(debian_compression_type, "bzip2")) {
+ compression_suffix = ".bz2";
+ tar_compression_type = cmArchiveWrite::CompressBZip2;
+ } else if (!strcmp(debian_compression_type, "gzip")) {
+ compression_suffix = ".gz";
+ tar_compression_type = cmArchiveWrite::CompressGZip;
+ } else if (!strcmp(debian_compression_type, "none")) {
+ compression_suffix = "";
+ tar_compression_type = cmArchiveWrite::CompressNone;
} else {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error unrecognized compression type: "
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error unrecognized compression type: "
<< debian_compression_type << std::endl);
}
-
- std::string filename_data_tar = strGenWDIR
- + "/data.tar" + compression_suffix;
+ std::string filename_data_tar =
+ strGenWDIR + "/data.tar" + compression_suffix;
// atomic file generation for data.tar
{
cmGeneratedFileStream fileStream_data_tar;
fileStream_data_tar.Open(filename_data_tar.c_str(), false, true);
- if(!fileStream_data_tar)
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error opening the file \"" << filename_data_tar << "\" for writing"
- << std::endl);
+ if (!fileStream_data_tar) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Error opening the file \""
+ << filename_data_tar << "\" for writing" << std::endl);
return 0;
- }
+ }
cmArchiveWrite data_tar(fileStream_data_tar, tar_compression_type, "paxr");
// uid/gid should be the one of the root user, and this root user has
@@ -495,81 +448,69 @@ int cmCPackDebGenerator::createDeb()
// give /usr and /opt
size_t topLevelLength = strGenWDIR.length();
cmCPackLogger(cmCPackLog::LOG_DEBUG, "WDIR: \""
- << strGenWDIR
- << "\", length = " << topLevelLength
- << std::endl);
+ << strGenWDIR << "\", length = " << topLevelLength
+ << std::endl);
std::set<std::string> orderedFiles;
// we have to reconstruct the parent folders as well
for (std::vector<std::string>::const_iterator fileIt =
- packageFiles.begin();
- fileIt != packageFiles.end(); ++ fileIt )
- {
+ packageFiles.begin();
+ fileIt != packageFiles.end(); ++fileIt) {
std::string currentPath = *fileIt;
- while(currentPath != strGenWDIR)
- {
+ while (currentPath != strGenWDIR) {
// the last one IS strGenWDIR, but we do not want this one:
// XXX/application/usr/bin/myprogram with GEN_WDIR=XXX/application
// should not add XXX/application
orderedFiles.insert(currentPath);
currentPath = cmSystemTools::CollapseCombinedPath(currentPath, "..");
- }
}
+ }
-
- for (std::set<std::string>::const_iterator fileIt =
- orderedFiles.begin();
- fileIt != orderedFiles.end(); ++ fileIt )
- {
+ for (std::set<std::string>::const_iterator fileIt = orderedFiles.begin();
+ fileIt != orderedFiles.end(); ++fileIt) {
cmCPackLogger(cmCPackLog::LOG_DEBUG, "FILEIT: \"" << *fileIt << "\""
- << std::endl);
- std::string::size_type slashPos = fileIt->find('/', topLevelLength+1);
- std::string relativeDir = fileIt->substr(topLevelLength,
- slashPos - topLevelLength);
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "RELATIVEDIR: \"" << relativeDir
- << "\"" << std::endl);
+ << std::endl);
+ std::string::size_type slashPos = fileIt->find('/', topLevelLength + 1);
+ std::string relativeDir =
+ fileIt->substr(topLevelLength, slashPos - topLevelLength);
+ cmCPackLogger(cmCPackLog::LOG_DEBUG, "RELATIVEDIR: \""
+ << relativeDir << "\"" << std::endl);
// do not recurse because the loop will do it
- if(!data_tar.Add(*fileIt, topLevelLength, ".", false))
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Problem adding file to tar:" << std::endl
- << "#top level directory: "
- << strGenWDIR << std::endl
- << "#file: " << *fileIt << std::endl
- << "#error:" << data_tar.GetError() << std::endl);
+ if (!data_tar.Add(*fileIt, topLevelLength, ".", false)) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem adding file to tar:"
+ << std::endl
+ << "#top level directory: " << strGenWDIR << std::endl
+ << "#file: " << *fileIt << std::endl
+ << "#error:" << data_tar.GetError() << std::endl);
return 0;
- }
}
+ }
} // scope for file generation
-
std::string md5filename = strGenWDIR + "/md5sums";
{
// the scope is needed for cmGeneratedFileStream
cmGeneratedFileStream out(md5filename.c_str());
std::string topLevelWithTrailingSlash =
- this->GetOption("CPACK_TEMPORARY_DIRECTORY");
+ this->GetOption("CPACK_TEMPORARY_DIRECTORY");
topLevelWithTrailingSlash += '/';
for (std::vector<std::string>::const_iterator fileIt =
packageFiles.begin();
- fileIt != packageFiles.end(); ++ fileIt )
- {
+ fileIt != packageFiles.end(); ++fileIt) {
// hash only regular files
- if( cmSystemTools::FileIsDirectory(*fileIt)
- || cmSystemTools::FileIsSymlink(*fileIt))
- {
+ if (cmSystemTools::FileIsDirectory(*fileIt) ||
+ cmSystemTools::FileIsSymlink(*fileIt)) {
continue;
- }
+ }
char md5sum[33];
- if(!cmSystemTools::ComputeFileMD5(*fileIt, md5sum))
- {
+ if (!cmSystemTools::ComputeFileMD5(*fileIt, md5sum)) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem computing the md5 of "
- << *fileIt << std::endl);
- }
+ << *fileIt << std::endl);
+ }
md5sum[32] = 0;
@@ -578,31 +519,27 @@ int cmCPackDebGenerator::createDeb()
// debian md5sums entries are like this:
// 014f3604694729f3bf19263bac599765 usr/bin/ccmake
// thus strip the full path (with the trailing slash)
- cmSystemTools::ReplaceString(output,
- topLevelWithTrailingSlash.c_str(), "");
+ cmSystemTools::ReplaceString(output, topLevelWithTrailingSlash.c_str(),
+ "");
out << output;
- }
+ }
// each line contains a eol.
// Do not end the md5sum file with yet another (invalid)
}
-
-
std::string filename_control_tar = strGenWDIR + "/control.tar.gz";
// atomic file generation for control.tar
{
cmGeneratedFileStream fileStream_control_tar;
fileStream_control_tar.Open(filename_control_tar.c_str(), false, true);
- if(!fileStream_control_tar)
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error opening the file \"" << filename_control_tar
- << "\" for writing" << std::endl);
+ if (!fileStream_control_tar) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Error opening the file \""
+ << filename_control_tar << "\" for writing"
+ << std::endl);
return 0;
- }
+ }
cmArchiveWrite control_tar(fileStream_control_tar,
- cmArchiveWrite::CompressGZip,
- "paxr");
+ cmArchiveWrite::CompressGZip, "paxr");
// sets permissions and uid/gid for the files
control_tar.SetUIDAndGID(0u, 0u);
@@ -623,113 +560,96 @@ int cmCPackDebGenerator::createDeb()
control_tar.SetPermissions(permission644);
// adds control and md5sums
- if( !control_tar.Add(md5filename, strGenWDIR.length(), ".")
- || !control_tar.Add(strGenWDIR + "/control", strGenWDIR.length(), "."))
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error adding file to tar:" << std::endl
- << "#top level directory: "
- << strGenWDIR << std::endl
- << "#file: \"control\" or \"md5sums\"" << std::endl
- << "#error:" << control_tar.GetError() << std::endl);
- return 0;
- }
+ if (!control_tar.Add(md5filename, strGenWDIR.length(), ".") ||
+ !control_tar.Add(strGenWDIR + "/control", strGenWDIR.length(), ".")) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Error adding file to tar:"
+ << std::endl
+ << "#top level directory: " << strGenWDIR << std::endl
+ << "#file: \"control\" or \"md5sums\"" << std::endl
+ << "#error:" << control_tar.GetError() << std::endl);
+ return 0;
+ }
// adds generated shlibs file
- if( gen_shibs )
- {
- if( !control_tar.Add(shlibsfilename, strGenWDIR.length(), ".") )
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error adding file to tar:" << std::endl
- << "#top level directory: "
- << strGenWDIR << std::endl
- << "#file: \"shlibs\"" << std::endl
- << "#error:" << control_tar.GetError() << std::endl);
- return 0;
- }
+ if (gen_shibs) {
+ if (!control_tar.Add(shlibsfilename, strGenWDIR.length(), ".")) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Error adding file to tar:"
+ << std::endl
+ << "#top level directory: " << strGenWDIR << std::endl
+ << "#file: \"shlibs\"" << std::endl
+ << "#error:" << control_tar.GetError() << std::endl);
+ return 0;
}
+ }
// adds LDCONFIG related files
- if(this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTINST"))
- {
+ if (this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTINST")) {
control_tar.SetPermissions(permission755);
- if(!control_tar.Add(postinst, strGenWDIR.length(), "."))
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error adding file to tar:" << std::endl
- << "#top level directory: "
- << strGenWDIR << std::endl
- << "#file: \"postinst\"" << std::endl
- << "#error:" << control_tar.GetError() << std::endl);
- return 0;
- }
- control_tar.SetPermissions(permission644);
+ if (!control_tar.Add(postinst, strGenWDIR.length(), ".")) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Error adding file to tar:"
+ << std::endl
+ << "#top level directory: " << strGenWDIR << std::endl
+ << "#file: \"postinst\"" << std::endl
+ << "#error:" << control_tar.GetError() << std::endl);
+ return 0;
}
+ control_tar.SetPermissions(permission644);
+ }
- if(this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTRM"))
- {
+ if (this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTRM")) {
control_tar.SetPermissions(permission755);
- if(!control_tar.Add(postrm, strGenWDIR.length(), "."))
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error adding file to tar:" << std::endl
- << "#top level directory: "
- << strGenWDIR << std::endl
- << "#file: \"postinst\"" << std::endl
- << "#error:" << control_tar.GetError() << std::endl);
- return 0;
- }
- control_tar.SetPermissions(permission644);
+ if (!control_tar.Add(postrm, strGenWDIR.length(), ".")) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Error adding file to tar:"
+ << std::endl
+ << "#top level directory: " << strGenWDIR << std::endl
+ << "#file: \"postinst\"" << std::endl
+ << "#error:" << control_tar.GetError() << std::endl);
+ return 0;
}
+ control_tar.SetPermissions(permission644);
+ }
// for the other files, we use
// -either the original permission on the files
// -either a permission strictly defined by the Debian policies
const char* controlExtra =
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA");
- if( controlExtra )
- {
+ if (controlExtra) {
// permissions are now controlled by the original file permissions
const bool permissionStrictPolicy =
this->IsSet("GEN_CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION");
- static const char* strictFiles[] = {
- "config", "postinst", "postrm", "preinst", "prerm"
- };
+ static const char* strictFiles[] = { "config", "postinst", "postrm",
+ "preinst", "prerm" };
std::set<std::string> setStrictFiles(
strictFiles,
- strictFiles + sizeof(strictFiles)/sizeof(strictFiles[0]));
+ strictFiles + sizeof(strictFiles) / sizeof(strictFiles[0]));
// default
control_tar.ClearPermissions();
std::vector<std::string> controlExtraList;
cmSystemTools::ExpandListArgument(controlExtra, controlExtraList);
- for(std::vector<std::string>::iterator i = controlExtraList.begin();
- i != controlExtraList.end(); ++i)
- {
- std::string filenamename =
- cmsys::SystemTools::GetFilenameName(*i);
+ for (std::vector<std::string>::iterator i = controlExtraList.begin();
+ i != controlExtraList.end(); ++i) {
+ std::string filenamename = cmsys::SystemTools::GetFilenameName(*i);
std::string localcopy = strGenWDIR + "/" + filenamename;
- if(permissionStrictPolicy)
- {
- control_tar.SetPermissions(setStrictFiles.count(filenamename) ?
- permission755 : permission644);
- }
+ if (permissionStrictPolicy) {
+ control_tar.SetPermissions(setStrictFiles.count(filenamename)
+ ? permission755
+ : permission644);
+ }
// if we can copy the file, it means it does exist, let's add it:
- if( cmsys::SystemTools::CopyFileIfDifferent(*i, localcopy) )
- {
+ if (cmsys::SystemTools::CopyFileIfDifferent(*i, localcopy)) {
control_tar.Add(localcopy, strGenWDIR.length(), ".");
- }
}
}
+ }
}
-
// ar -r your-package-name.deb debian-binary control.tar.* data.tar.*
// since debian packages require BSD ar (most Linux distros and even
// FreeBSD and NetBSD ship GNU ar) we use a copy of OpenBSD ar here.
@@ -742,33 +662,29 @@ int cmCPackDebGenerator::createDeb()
outputFileName += "/";
outputFileName += this->GetOption("GEN_CPACK_OUTPUT_FILE_NAME");
int res = ar_append(outputFileName.c_str(), arFiles);
- if ( res!=0 )
- {
- std::string tmpFile = this->GetOption(
- "GEN_CPACK_TEMPORARY_PACKAGE_FILE_NAME");
+ if (res != 0) {
+ std::string tmpFile =
+ this->GetOption("GEN_CPACK_TEMPORARY_PACKAGE_FILE_NAME");
tmpFile += "/Deb.log";
cmGeneratedFileStream ofs(tmpFile.c_str());
ofs << "# Problem creating archive using: " << res << std::endl;
return 0;
- }
+ }
return 1;
}
bool cmCPackDebGenerator::SupportsComponentInstallation() const
- {
- if (IsOn("CPACK_DEB_COMPONENT_INSTALL"))
- {
- return true;
- }
- else
- {
- return false;
- }
+{
+ if (IsOn("CPACK_DEB_COMPONENT_INSTALL")) {
+ return true;
+ } else {
+ return false;
}
+}
std::string cmCPackDebGenerator::GetComponentInstallDirNameSuffix(
- const std::string& componentName)
- {
+ const std::string& componentName)
+{
if (componentPackageMethod == ONE_PACKAGE_PER_COMPONENT) {
return componentName;
}
@@ -778,18 +694,14 @@ std::string cmCPackDebGenerator::GetComponentInstallDirNameSuffix(
}
// We have to find the name of the COMPONENT GROUP
// the current COMPONENT belongs to.
- std::string groupVar = "CPACK_COMPONENT_" +
- cmSystemTools::UpperCase(componentName) + "_GROUP";
- if (NULL != GetOption(groupVar))
- {
- return std::string(GetOption(groupVar));
- }
- else
- {
- return componentName;
- }
+ std::string groupVar =
+ "CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP";
+ if (NULL != GetOption(groupVar)) {
+ return std::string(GetOption(groupVar));
+ } else {
+ return componentName;
}
-
+}
// The following code is taken from OpenBSD ar:
// http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ar/
@@ -840,58 +752,61 @@ std::string cmCPackDebGenerator::GetComponentInstallDirNameSuffix(
#include <stdlib.h>
#include <string.h>
-#define ARMAG "!<arch>\n" /* ar "magic number" */
-#define SARMAG 8 /* strlen(ARMAG); */
+#define ARMAG "!<arch>\n" /* ar "magic number" */
+#define SARMAG 8 /* strlen(ARMAG); */
-#define AR_EFMT1 "#1/" /* extended format #1 */
-#define ARFMAG "`\n"
+#define AR_EFMT1 "#1/" /* extended format #1 */
+#define ARFMAG "`\n"
/* Header format strings. */
-#define HDR1 "%s%-13d%-12ld%-6u%-6u%-8o%-10lld%2s"
-#define HDR2 "%-16.16s%-12ld%-6u%-6u%-8o%-10lld%2s"
-
-struct ar_hdr {
- char ar_name[16]; /* name */
- char ar_date[12]; /* modification time */
- char ar_uid[6]; /* user id */
- char ar_gid[6]; /* group id */
- char ar_mode[8]; /* octal file permissions */
- char ar_size[10]; /* size in bytes */
- char ar_fmag[2]; /* consistency check */
+#define HDR1 "%s%-13d%-12ld%-6u%-6u%-8o%-10lld%2s"
+#define HDR2 "%-16.16s%-12ld%-6u%-6u%-8o%-10lld%2s"
+
+struct ar_hdr
+{
+ char ar_name[16]; /* name */
+ char ar_date[12]; /* modification time */
+ char ar_uid[6]; /* user id */
+ char ar_gid[6]; /* group id */
+ char ar_mode[8]; /* octal file permissions */
+ char ar_size[10]; /* size in bytes */
+ char ar_fmag[2]; /* consistency check */
};
/* Set up file copy. */
-#define SETCF(from, fromname, to, toname, pad) { \
- cf.rFile = from; \
- cf.rname = fromname; \
- cf.wFile = to; \
- cf.wname = toname; \
- cf.flags = pad; \
-}
+#define SETCF(from, fromname, to, toname, pad) \
+ { \
+ cf.rFile = from; \
+ cf.rname = fromname; \
+ cf.wFile = to; \
+ cf.wname = toname; \
+ cf.flags = pad; \
+ }
/* File copy structure. */
-typedef struct {
- FILE* rFile; /* read file descriptor */
- const char *rname; /* read name */
- FILE* wFile; /* write file descriptor */
- const char *wname; /* write name */
-#define NOPAD 0x00 /* don't pad */
-#define WPAD 0x02 /* pad on writes */
- unsigned int flags; /* pad flags */
+typedef struct
+{
+ FILE* rFile; /* read file descriptor */
+ const char* rname; /* read name */
+ FILE* wFile; /* write file descriptor */
+ const char* wname; /* write name */
+#define NOPAD 0x00 /* don't pad */
+#define WPAD 0x02 /* pad on writes */
+ unsigned int flags; /* pad flags */
} CF;
/* misc.c */
-static const char * ar_rname(const char *path)
+static const char* ar_rname(const char* path)
{
- const char *ind = strrchr(path, '/');
- return (ind ) ? ind + 1 : path;
+ const char* ind = strrchr(path, '/');
+ return (ind) ? ind + 1 : path;
}
/* archive.c */
typedef struct ar_hdr HDR;
-static char ar_hb[sizeof(HDR) + 1]; /* real header */
+static char ar_hb[sizeof(HDR) + 1]; /* real header */
static size_t ar_already_written;
@@ -908,12 +823,12 @@ static size_t ar_already_written;
* because 16-bit word addressed copies were faster?) Anyhow, it should
* have been ripped out long ago.
*/
-static int copy_ar(CF *cfp, off_t size)
+static int copy_ar(CF* cfp, off_t size)
{
static char pad = '\n';
off_t sz = size;
size_t nr, nw;
- char buf[8*1024];
+ char buf[8 * 1024];
if (sz == 0)
return 0;
@@ -921,60 +836,59 @@ static int copy_ar(CF *cfp, off_t size)
FILE* from = cfp->rFile;
FILE* to = cfp->wFile;
while (sz &&
- (nr = fread(buf, 1, sz < static_cast<off_t>(sizeof(buf))
- ? static_cast<size_t>(sz) : sizeof(buf), from ))
- > 0) {
+ (nr = fread(buf, 1, sz < static_cast<off_t>(sizeof(buf))
+ ? static_cast<size_t>(sz)
+ : sizeof(buf),
+ from)) > 0) {
sz -= nr;
for (size_t off = 0; off < nr; nr -= off, off += nw)
if ((nw = fwrite(buf + off, 1, nr, to)) < nr)
return -1;
- }
+ }
if (sz)
return -2;
- if (cfp->flags & WPAD && (size + ar_already_written) & 1
- && fwrite(&pad, 1, 1, to) != 1)
+ if (cfp->flags & WPAD && (size + ar_already_written) & 1 &&
+ fwrite(&pad, 1, 1, to) != 1)
return -4;
return 0;
}
/* put_arobj -- Write an archive member to a file. */
-static int put_arobj(CF *cfp, struct stat *sb)
+static int put_arobj(CF* cfp, struct stat* sb)
{
int result = 0;
- struct ar_hdr *hdr;
+ struct ar_hdr* hdr;
- /* If passed an sb structure, reading a file from disk. Get stat(2)
- * information, build a name and construct a header. (Files are named
- * by their last component in the archive.) */
+ /* If passed an sb structure, reading a file from disk. Get stat(2)
+ * information, build a name and construct a header. (Files are named
+ * by their last component in the archive.) */
const char* name = ar_rname(cfp->rname);
(void)stat(cfp->rname, sb);
- /* If not truncating names and the name is too long or contains
- * a space, use extended format 1. */
+ /* If not truncating names and the name is too long or contains
+ * a space, use extended format 1. */
size_t lname = strlen(name);
uid_t uid = sb->st_uid;
gid_t gid = sb->st_gid;
if (uid > USHRT_MAX) {
uid = USHRT_MAX;
- }
+ }
if (gid > USHRT_MAX) {
gid = USHRT_MAX;
- }
+ }
if (lname > sizeof(hdr->ar_name) || strchr(name, ' '))
- (void)sprintf(ar_hb, HDR1, AR_EFMT1, (int)lname,
- (long int)sb->st_mtime, (unsigned)uid, (unsigned)gid,
- (unsigned)sb->st_mode, (long long)sb->st_size + lname,
+ (void)sprintf(ar_hb, HDR1, AR_EFMT1, (int)lname, (long int)sb->st_mtime,
+ (unsigned)uid, (unsigned)gid, (unsigned)sb->st_mode,
+ (long long)sb->st_size + lname, ARFMAG);
+ else {
+ lname = 0;
+ (void)sprintf(ar_hb, HDR2, name, (long int)sb->st_mtime, (unsigned)uid,
+ (unsigned)gid, (unsigned)sb->st_mode, (long long)sb->st_size,
ARFMAG);
- else {
- lname = 0;
- (void)sprintf(ar_hb, HDR2, name,
- (long int)sb->st_mtime, (unsigned)uid, (unsigned)gid,
- (unsigned)sb->st_mode, (long long)sb->st_size,
- ARFMAG);
- }
- off_t size = sb->st_size;
+ }
+ off_t size = sb->st_size;
if (fwrite(ar_hb, 1, sizeof(HDR), cfp->wFile) != sizeof(HDR))
return -1;
@@ -983,7 +897,7 @@ static int put_arobj(CF *cfp, struct stat *sb)
if (fwrite(name, 1, lname, cfp->wFile) != lname)
return -2;
ar_already_written = lname;
- }
+ }
result = copy_ar(cfp, size);
ar_already_written = 0;
return result;
@@ -995,42 +909,41 @@ static int put_arobj(CF *cfp, struct stat *sb)
* Append files to the archive - modifies original archive or creates
* a new archive if named archive does not exist.
*/
-static int ar_append(const char* archive,const std::vector<std::string>& files)
+static int ar_append(const char* archive,
+ const std::vector<std::string>& files)
{
int eval = 0;
FILE* aFile = cmSystemTools::Fopen(archive, "wb+");
- if (aFile!=NULL) {
+ if (aFile != NULL) {
fwrite(ARMAG, SARMAG, 1, aFile);
if (fseek(aFile, 0, SEEK_END) != -1) {
CF cf;
struct stat sb;
/* Read from disk, write to an archive; pad on write. */
SETCF(NULL, 0, aFile, archive, WPAD);
- for(std::vector<std::string>::const_iterator fileIt = files.begin();
- fileIt!=files.end(); ++fileIt) {
+ for (std::vector<std::string>::const_iterator fileIt = files.begin();
+ fileIt != files.end(); ++fileIt) {
const char* filename = fileIt->c_str();
FILE* file = cmSystemTools::Fopen(filename, "rb");
if (file == NULL) {
eval = -1;
continue;
- }
+ }
cf.rFile = file;
cf.rname = filename;
int result = put_arobj(&cf, &sb);
(void)fclose(file);
- if (result!=0) {
+ if (result != 0) {
eval = -2;
break;
- }
}
}
- else {
- eval = -3;
- }
- fclose(aFile);
+ } else {
+ eval = -3;
}
- else {
+ fclose(aFile);
+ } else {
eval = -4;
- }
+ }
return eval;
}
diff --git a/Source/CPack/cmCPackDebGenerator.h b/Source/CPack/cmCPackDebGenerator.h
index 439b7ea..f640ab4 100644
--- a/Source/CPack/cmCPackDebGenerator.h
+++ b/Source/CPack/cmCPackDebGenerator.h
@@ -31,18 +31,18 @@ public:
virtual ~cmCPackDebGenerator();
static bool CanGenerate()
- {
+ {
#ifdef __APPLE__
// on MacOS enable CPackDeb iff dpkg is found
std::vector<std::string> locations;
locations.push_back("/sw/bin"); // Fink
locations.push_back("/opt/local/bin"); // MacPorts
- return cmSystemTools::FindProgram("dpkg",locations) != "" ? true : false;
+ return cmSystemTools::FindProgram("dpkg", locations) != "" ? true : false;
#else
// legacy behavior on other systems
return true;
#endif
- }
+ }
protected:
virtual int InitializeInternal();
@@ -65,12 +65,11 @@ protected:
virtual const char* GetOutputExtension() { return ".deb"; }
virtual bool SupportsComponentInstallation() const;
virtual std::string GetComponentInstallDirNameSuffix(
- const std::string& componentName);
+ const std::string& componentName);
private:
int createDeb();
std::vector<std::string> packageFiles;
-
};
#endif
diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx
index ea90c67..e401657 100644
--- a/Source/CPack/cmCPackDragNDropGenerator.cxx
+++ b/Source/CPack/cmCPackDragNDropGenerator.cxx
@@ -31,35 +31,35 @@
#endif
static const char* SLAHeader =
-"data 'LPic' (5000) {\n"
-" $\"0002 0011 0003 0001 0000 0000 0002 0000\"\n"
-" $\"0008 0003 0000 0001 0004 0000 0004 0005\"\n"
-" $\"0000 000E 0006 0001 0005 0007 0000 0007\"\n"
-" $\"0008 0000 0047 0009 0000 0034 000A 0001\"\n"
-" $\"0035 000B 0001 0020 000C 0000 0011 000D\"\n"
-" $\"0000 005B 0004 0000 0033 000F 0001 000C\"\n"
-" $\"0010 0000 000B 000E 0000\"\n"
-"};\n"
-"\n";
+ "data 'LPic' (5000) {\n"
+ " $\"0002 0011 0003 0001 0000 0000 0002 0000\"\n"
+ " $\"0008 0003 0000 0001 0004 0000 0004 0005\"\n"
+ " $\"0000 000E 0006 0001 0005 0007 0000 0007\"\n"
+ " $\"0008 0000 0047 0009 0000 0034 000A 0001\"\n"
+ " $\"0035 000B 0001 0020 000C 0000 0011 000D\"\n"
+ " $\"0000 005B 0004 0000 0033 000F 0001 000C\"\n"
+ " $\"0010 0000 000B 000E 0000\"\n"
+ "};\n"
+ "\n";
static const char* SLASTREnglish =
-"resource 'STR#' (5002, \"English\") {\n"
-" {\n"
-" \"English\",\n"
-" \"Agree\",\n"
-" \"Disagree\",\n"
-" \"Print\",\n"
-" \"Save...\",\n"
-" \"You agree to the License Agreement terms when you click \"\n"
-" \"the \\\"Agree\\\" button.\",\n"
-" \"Software License Agreement\",\n"
-" \"This text cannot be saved. This disk may be full or locked, "
-"or the \"\n"
-" \"file may be locked.\",\n"
-" \"Unable to print. Make sure you have selected a printer.\"\n"
-" }\n"
-"};\n"
-"\n";
+ "resource 'STR#' (5002, \"English\") {\n"
+ " {\n"
+ " \"English\",\n"
+ " \"Agree\",\n"
+ " \"Disagree\",\n"
+ " \"Print\",\n"
+ " \"Save...\",\n"
+ " \"You agree to the License Agreement terms when you click \"\n"
+ " \"the \\\"Agree\\\" button.\",\n"
+ " \"Software License Agreement\",\n"
+ " \"This text cannot be saved. This disk may be full or locked, "
+ "or the \"\n"
+ " \"file may be locked.\",\n"
+ " \"Unable to print. Make sure you have selected a printer.\"\n"
+ " }\n"
+ "};\n"
+ "\n";
cmCPackDragNDropGenerator::cmCPackDragNDropGenerator()
: singleLicense(false)
@@ -80,102 +80,84 @@ int cmCPackDragNDropGenerator::InitializeInternal()
paths.push_back("/Applications/Xcode.app/Contents/Developer/Tools");
paths.push_back("/Developer/Tools");
- const std::string hdiutil_path = cmSystemTools::FindProgram("hdiutil",
- std::vector<std::string>(), false);
- if(hdiutil_path.empty())
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Cannot locate hdiutil command"
- << std::endl);
+ const std::string hdiutil_path =
+ cmSystemTools::FindProgram("hdiutil", std::vector<std::string>(), false);
+ if (hdiutil_path.empty()) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot locate hdiutil command"
+ << std::endl);
return 0;
- }
+ }
this->SetOptionIfNotSet("CPACK_COMMAND_HDIUTIL", hdiutil_path.c_str());
- const std::string setfile_path = cmSystemTools::FindProgram("SetFile",
- paths, false);
- if(setfile_path.empty())
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Cannot locate SetFile command"
- << std::endl);
+ const std::string setfile_path =
+ cmSystemTools::FindProgram("SetFile", paths, false);
+ if (setfile_path.empty()) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot locate SetFile command"
+ << std::endl);
return 0;
- }
+ }
this->SetOptionIfNotSet("CPACK_COMMAND_SETFILE", setfile_path.c_str());
- const std::string rez_path = cmSystemTools::FindProgram("Rez",
- paths, false);
- if(rez_path.empty())
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Cannot locate Rez command"
- << std::endl);
+ const std::string rez_path = cmSystemTools::FindProgram("Rez", paths, false);
+ if (rez_path.empty()) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot locate Rez command"
+ << std::endl);
return 0;
- }
+ }
this->SetOptionIfNotSet("CPACK_COMMAND_REZ", rez_path.c_str());
- if(this->IsSet("CPACK_DMG_SLA_DIR"))
- {
+ if (this->IsSet("CPACK_DMG_SLA_DIR")) {
slaDirectory = this->GetOption("CPACK_DMG_SLA_DIR");
- if(!slaDirectory.empty() && this->IsSet("CPACK_RESOURCE_FILE_LICENSE"))
- {
+ if (!slaDirectory.empty() && this->IsSet("CPACK_RESOURCE_FILE_LICENSE")) {
std::string license_file =
this->GetOption("CPACK_RESOURCE_FILE_LICENSE");
- if(!license_file.empty() &&
- (license_file.find("CPack.GenericLicense.txt") == std::string::npos))
- {
- cmCPackLogger(cmCPackLog::LOG_OUTPUT,
+ if (!license_file.empty() &&
+ (license_file.find("CPack.GenericLicense.txt") ==
+ std::string::npos)) {
+ cmCPackLogger(
+ cmCPackLog::LOG_OUTPUT,
"Both CPACK_DMG_SLA_DIR and CPACK_RESOURCE_FILE_LICENSE specified, "
"using CPACK_RESOURCE_FILE_LICENSE as a license for all languages."
- << std::endl);
+ << std::endl);
singleLicense = true;
- }
}
- if(!this->IsSet("CPACK_DMG_SLA_LANGUAGES"))
- {
+ }
+ if (!this->IsSet("CPACK_DMG_SLA_LANGUAGES")) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "CPACK_DMG_SLA_DIR set but no languages defined "
- "(set CPACK_DMG_SLA_LANGUAGES)"
- << std::endl);
+ "CPACK_DMG_SLA_DIR set but no languages defined "
+ "(set CPACK_DMG_SLA_LANGUAGES)"
+ << std::endl);
return 0;
- }
- if(!cmSystemTools::FileExists(slaDirectory, false))
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "CPACK_DMG_SLA_DIR does not exist"
- << std::endl);
+ }
+ if (!cmSystemTools::FileExists(slaDirectory, false)) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "CPACK_DMG_SLA_DIR does not exist"
+ << std::endl);
return 0;
- }
+ }
std::vector<std::string> languages;
cmSystemTools::ExpandListArgument(
this->GetOption("CPACK_DMG_SLA_LANGUAGES"), languages);
- if(languages.empty())
- {
+ if (languages.empty()) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "CPACK_DMG_SLA_LANGUAGES set but empty"
- << std::endl);
+ "CPACK_DMG_SLA_LANGUAGES set but empty" << std::endl);
return 0;
- }
- for(size_t i = 0; i < languages.size(); ++i)
- {
+ }
+ for (size_t i = 0; i < languages.size(); ++i) {
std::string license = slaDirectory + "/" + languages[i] + ".license.txt";
- if (!singleLicense && !cmSystemTools::FileExists(license))
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Missing license file " << languages[i] << ".license.txt"
- << std::endl);
+ if (!singleLicense && !cmSystemTools::FileExists(license)) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Missing license file "
+ << languages[i] << ".license.txt" << std::endl);
return 0;
- }
+ }
std::string menu = slaDirectory + "/" + languages[i] + ".menu.txt";
- if (!cmSystemTools::FileExists(menu))
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Missing menu file " << languages[i] << ".menu.txt"
- << std::endl);
+ if (!cmSystemTools::FileExists(menu)) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Missing menu file "
+ << languages[i] << ".menu.txt" << std::endl);
return 0;
- }
}
}
+ }
return this->Superclass::InitializeInternal();
}
@@ -191,40 +173,32 @@ int cmCPackDragNDropGenerator::PackageFiles()
// multiple directories occur if packaging components or groups separately
// monolith
- if(this->Components.empty())
- {
+ if (this->Components.empty()) {
return this->CreateDMG(toplevel, packageFileNames[0]);
- }
+ }
// component install
std::vector<std::string> package_files;
std::map<std::string, cmCPackComponent>::iterator compIt;
- for (compIt=this->Components.begin();
- compIt!=this->Components.end(); ++compIt )
- {
+ for (compIt = this->Components.begin(); compIt != this->Components.end();
+ ++compIt) {
std::string name = GetComponentInstallDirNameSuffix(compIt->first);
package_files.push_back(name);
- }
+ }
std::sort(package_files.begin(), package_files.end());
- package_files.erase(std::unique(package_files.begin(),
- package_files.end()),
+ package_files.erase(std::unique(package_files.begin(), package_files.end()),
package_files.end());
-
// loop to create dmg files
packageFileNames.clear();
- for(size_t i=0; i<package_files.size(); i++)
- {
+ for (size_t i = 0; i < package_files.size(); i++) {
std::string full_package_name = std::string(toplevel) + std::string("/");
- if(package_files[i] == "ALL_IN_ONE")
- {
+ if (package_files[i] == "ALL_IN_ONE") {
full_package_name += this->GetOption("CPACK_PACKAGE_FILE_NAME");
- }
- else
- {
+ } else {
full_package_name += package_files[i];
- }
+ }
full_package_name += std::string(GetOutputExtension());
packageFileNames.push_back(full_package_name);
@@ -232,30 +206,23 @@ int cmCPackDragNDropGenerator::PackageFiles()
src_dir += "/";
src_dir += package_files[i];
- if(0 == this->CreateDMG(src_dir, full_package_name))
- {
+ if (0 == this->CreateDMG(src_dir, full_package_name)) {
return 0;
- }
}
+ }
return 1;
}
bool cmCPackDragNDropGenerator::CopyFile(std::ostringstream& source,
- std::ostringstream& target)
+ std::ostringstream& target)
{
- if(!cmSystemTools::CopyFileIfDifferent(
- source.str().c_str(),
- target.str().c_str()))
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error copying "
- << source.str()
- << " to "
- << target.str()
- << std::endl);
+ if (!cmSystemTools::CopyFileIfDifferent(source.str().c_str(),
+ target.str().c_str())) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Error copying "
+ << source.str() << " to " << target.str() << std::endl);
return false;
- }
+ }
return true;
}
@@ -263,46 +230,35 @@ bool cmCPackDragNDropGenerator::CopyFile(std::ostringstream& source,
bool cmCPackDragNDropGenerator::CreateEmptyFile(std::ostringstream& target,
size_t size)
{
- cmsys::ofstream fout(target.str().c_str(),
- std::ios::out | std::ios::binary);
- if(!fout)
- {
+ cmsys::ofstream fout(target.str().c_str(), std::ios::out | std::ios::binary);
+ if (!fout) {
return false;
- }
- else
- {
+ } else {
// Seek to desired size - 1 byte
fout.seekp(size - 1, std::ios_base::beg);
char byte = 0;
// Write one byte to ensure file grows
fout.write(&byte, 1);
- }
+ }
return true;
}
bool cmCPackDragNDropGenerator::RunCommand(std::ostringstream& command,
- std::string* output)
+ std::string* output)
{
int exit_code = 1;
- bool result = cmSystemTools::RunSingleCommand(
- command.str().c_str(),
- output, output,
- &exit_code,
- 0,
- this->GeneratorVerbose,
- 0);
+ bool result =
+ cmSystemTools::RunSingleCommand(command.str().c_str(), output, output,
+ &exit_code, 0, this->GeneratorVerbose, 0);
- if(!result || exit_code)
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error executing: "
- << command.str()
- << std::endl);
+ if (!result || exit_code) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Error executing: " << command.str()
+ << std::endl);
return false;
- }
+ }
return true;
}
@@ -312,51 +268,54 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
{
// Get optional arguments ...
const std::string cpack_package_icon = this->GetOption("CPACK_PACKAGE_ICON")
- ? this->GetOption("CPACK_PACKAGE_ICON") : "";
+ ? this->GetOption("CPACK_PACKAGE_ICON")
+ : "";
const std::string cpack_dmg_volume_name =
this->GetOption("CPACK_DMG_VOLUME_NAME")
? this->GetOption("CPACK_DMG_VOLUME_NAME")
- : this->GetOption("CPACK_PACKAGE_FILE_NAME");
+ : this->GetOption("CPACK_PACKAGE_FILE_NAME");
- const std::string cpack_dmg_format =
- this->GetOption("CPACK_DMG_FORMAT")
- ? this->GetOption("CPACK_DMG_FORMAT") : "UDZO";
+ const std::string cpack_dmg_format = this->GetOption("CPACK_DMG_FORMAT")
+ ? this->GetOption("CPACK_DMG_FORMAT")
+ : "UDZO";
// Get optional arguments ...
std::string cpack_license_file =
- this->GetOption("CPACK_RESOURCE_FILE_LICENSE") ?
- this->GetOption("CPACK_RESOURCE_FILE_LICENSE") : "";
+ this->GetOption("CPACK_RESOURCE_FILE_LICENSE")
+ ? this->GetOption("CPACK_RESOURCE_FILE_LICENSE")
+ : "";
const std::string cpack_dmg_background_image =
this->GetOption("CPACK_DMG_BACKGROUND_IMAGE")
- ? this->GetOption("CPACK_DMG_BACKGROUND_IMAGE") : "";
+ ? this->GetOption("CPACK_DMG_BACKGROUND_IMAGE")
+ : "";
- const std::string cpack_dmg_ds_store =
- this->GetOption("CPACK_DMG_DS_STORE")
- ? this->GetOption("CPACK_DMG_DS_STORE") : "";
+ const std::string cpack_dmg_ds_store = this->GetOption("CPACK_DMG_DS_STORE")
+ ? this->GetOption("CPACK_DMG_DS_STORE")
+ : "";
const std::string cpack_dmg_languages =
this->GetOption("CPACK_DMG_SLA_LANGUAGES")
- ? this->GetOption("CPACK_DMG_SLA_LANGUAGES") : "";
+ ? this->GetOption("CPACK_DMG_SLA_LANGUAGES")
+ : "";
const std::string cpack_dmg_ds_store_setup_script =
this->GetOption("CPACK_DMG_DS_STORE_SETUP_SCRIPT")
- ? this->GetOption("CPACK_DMG_DS_STORE_SETUP_SCRIPT") : "";
+ ? this->GetOption("CPACK_DMG_DS_STORE_SETUP_SCRIPT")
+ : "";
// only put license on dmg if is user provided
- if(!cpack_license_file.empty() &&
- cpack_license_file.find("CPack.GenericLicense.txt") != std::string::npos)
- {
+ if (!cpack_license_file.empty() &&
+ cpack_license_file.find("CPack.GenericLicense.txt") !=
+ std::string::npos) {
cpack_license_file = "";
- }
+ }
// use sla_dir if both sla_dir and license_file are set
- if(!cpack_license_file.empty() &&
- !slaDirectory.empty() && !singleLicense)
- {
+ if (!cpack_license_file.empty() && !slaDirectory.empty() && !singleLicense) {
cpack_license_file = "";
- }
+ }
// The staging directory contains everything that will end-up inside the
// final disk image ...
@@ -368,56 +327,52 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
std::ostringstream application_link;
application_link << staging.str() << "/Applications";
cmSystemTools::CreateSymlink("/Applications",
- application_link.str().c_str());
+ application_link.str().c_str());
// Optionally add a custom volume icon ...
- if(!cpack_package_icon.empty())
- {
+ if (!cpack_package_icon.empty()) {
std::ostringstream package_icon_source;
package_icon_source << cpack_package_icon;
std::ostringstream package_icon_destination;
package_icon_destination << staging.str() << "/.VolumeIcon.icns";
- if(!this->CopyFile(package_icon_source, package_icon_destination))
- {
+ if (!this->CopyFile(package_icon_source, package_icon_destination)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error copying disk volume icon. "
+ "Error copying disk volume icon. "
"Check the value of CPACK_PACKAGE_ICON."
- << std::endl);
+ << std::endl);
return 0;
- }
}
+ }
// Optionally add a custom .DS_Store file
// (e.g. for setting background/layout) ...
- if(!cpack_dmg_ds_store.empty())
- {
+ if (!cpack_dmg_ds_store.empty()) {
std::ostringstream package_settings_source;
package_settings_source << cpack_dmg_ds_store;
std::ostringstream package_settings_destination;
package_settings_destination << staging.str() << "/.DS_Store";
- if(!this->CopyFile(package_settings_source, package_settings_destination))
- {
+ if (!this->CopyFile(package_settings_source,
+ package_settings_destination)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error copying disk volume settings file. "
+ "Error copying disk volume settings file. "
"Check the value of CPACK_DMG_DS_STORE."
- << std::endl);
+ << std::endl);
return 0;
- }
}
+ }
// Optionally add a custom background image ...
// Make sure the background file type is the same as the custom image
// and that the file is hidden so it doesn't show up.
- if(!cpack_dmg_background_image.empty())
- {
+ if (!cpack_dmg_background_image.empty()) {
const std::string extension =
- cmSystemTools::GetFilenameLastExtension(cpack_dmg_background_image);
+ cmSystemTools::GetFilenameLastExtension(cpack_dmg_background_image);
std::ostringstream package_background_source;
package_background_source << cpack_dmg_background_image;
@@ -425,36 +380,32 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
package_background_destination << staging.str()
<< "/.background/background" << extension;
- if(!this->CopyFile(package_background_source,
- package_background_destination))
- {
+ if (!this->CopyFile(package_background_source,
+ package_background_destination)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error copying disk volume background image. "
+ "Error copying disk volume background image. "
"Check the value of CPACK_DMG_BACKGROUND_IMAGE."
- << std::endl);
+ << std::endl);
return 0;
- }
}
+ }
- bool remount_image = !cpack_package_icon.empty() ||
- !cpack_dmg_ds_store_setup_script.empty();
+ bool remount_image =
+ !cpack_package_icon.empty() || !cpack_dmg_ds_store_setup_script.empty();
// 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)
- {
+ if (remount_image) {
std::ostringstream dummy_padding;
dummy_padding << staging.str() << "/.dummy-padding-file";
- if(!this->CreateEmptyFile(dummy_padding, 1048576))
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error creating dummy padding file."
- << std::endl);
+ if (!this->CreateEmptyFile(dummy_padding, 1048576)) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Error creating dummy padding file."
+ << std::endl);
return 0;
- }
}
+ }
// Create a temporary read-write disk image ...
std::string temp_image = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
@@ -465,22 +416,18 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
temp_image_command << " create";
temp_image_command << " -ov";
temp_image_command << " -srcfolder \"" << staging.str() << "\"";
- temp_image_command << " -volname \""
- << cpack_dmg_volume_name << "\"";
+ temp_image_command << " -volname \"" << cpack_dmg_volume_name << "\"";
temp_image_command << " -format UDRW";
temp_image_command << " \"" << temp_image << "\"";
- if(!this->RunCommand(temp_image_command))
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error generating temporary disk image."
- << std::endl);
+ if (!this->RunCommand(temp_image_command)) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error generating temporary disk image." << std::endl);
return 0;
- }
+ }
- if(remount_image)
- {
+ if (remount_image) {
// Store that we have a failure so that we always unmount the image
// before we exit.
bool had_error = false;
@@ -491,14 +438,12 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
attach_command << " \"" << temp_image << "\"";
std::string attach_output;
- if(!this->RunCommand(attach_command, &attach_output))
- {
+ if (!this->RunCommand(attach_command, &attach_output)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error attaching temporary disk image."
- << std::endl);
+ "Error attaching temporary disk image." << std::endl);
return 0;
- }
+ }
cmsys::RegularExpression mountpoint_regex(".*(/Volumes/[^\n]+)\n.*");
mountpoint_regex.find(attach_output.c_str());
@@ -508,95 +453,81 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
// Remove dummy padding file so we have enough space on RW image ...
std::ostringstream dummy_padding;
dummy_padding << temp_mount.str() << "/.dummy-padding-file";
- if(!cmSystemTools::RemoveFile(dummy_padding.str()))
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error removing dummy padding file."
- << std::endl);
+ if (!cmSystemTools::RemoveFile(dummy_padding.str())) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Error removing dummy padding file."
+ << std::endl);
had_error = true;
- }
+ }
// Optionally set the custom icon flag for the image ...
- if(!had_error && !cpack_package_icon.empty())
- {
+ if (!had_error && !cpack_package_icon.empty()) {
std::ostringstream setfile_command;
setfile_command << this->GetOption("CPACK_COMMAND_SETFILE");
setfile_command << " -a C";
setfile_command << " \"" << temp_mount.str() << "\"";
- if(!this->RunCommand(setfile_command))
- {
+ if (!this->RunCommand(setfile_command)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error assigning custom icon to temporary disk image."
- << std::endl);
+ "Error assigning custom icon to temporary disk image."
+ << std::endl);
had_error = true;
- }
}
+ }
// Optionally we can execute a custom apple script to generate
// the .DS_Store for the volume folder ...
- if(!had_error && !cpack_dmg_ds_store_setup_script.empty())
- {
+ if (!had_error && !cpack_dmg_ds_store_setup_script.empty()) {
std::ostringstream setup_script_command;
setup_script_command << "osascript"
<< " \"" << cpack_dmg_ds_store_setup_script << "\""
<< " \"" << cpack_dmg_volume_name << "\"";
std::string error;
- if(!this->RunCommand(setup_script_command, &error))
- {
+ if (!this->RunCommand(setup_script_command, &error)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error executing custom script on disk image." << std::endl
- << error
- << std::endl);
+ "Error executing custom script on disk image."
+ << std::endl
+ << error << std::endl);
had_error = true;
- }
}
+ }
std::ostringstream detach_command;
detach_command << this->GetOption("CPACK_COMMAND_HDIUTIL");
detach_command << " detach";
detach_command << " \"" << temp_mount.str() << "\"";
- if(!this->RunCommand(detach_command))
- {
+ if (!this->RunCommand(detach_command)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error detaching temporary disk image."
- << std::endl);
+ "Error detaching temporary disk image." << std::endl);
return 0;
- }
+ }
- if(had_error)
- {
+ if (had_error) {
return 0;
- }
}
+ }
- if(!cpack_license_file.empty() || !slaDirectory.empty())
- {
+ if (!cpack_license_file.empty() || !slaDirectory.empty()) {
// Use old hardcoded style if sla_dir is not set
bool oldStyle = slaDirectory.empty();
std::string sla_r = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
sla_r += "/sla.r";
std::vector<std::string> languages;
- if(!oldStyle)
- {
+ if (!oldStyle) {
cmSystemTools::ExpandListArgument(cpack_dmg_languages, languages);
- }
+ }
cmGeneratedFileStream ofs(sla_r.c_str());
ofs << "#include <CoreServices/CoreServices.r>\n\n";
- if(oldStyle)
- {
+ if (oldStyle) {
ofs << SLAHeader;
ofs << "\n";
- }
- else
- {
+ } else {
/*
* LPic Layout
* (https://github.com/pypt/dmg-add-license/blob/master/main.c)
@@ -619,111 +550,92 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
std::vector<uint16_t> header_data;
header_data.push_back(0);
header_data.push_back(languages.size());
- for(size_t i = 0; i < languages.size(); ++i)
- {
+ for (size_t i = 0; i < languages.size(); ++i) {
CFStringRef language_cfstring = CFStringCreateWithCString(
NULL, languages[i].c_str(), kCFStringEncodingUTF8);
CFStringRef iso_language =
CFLocaleCreateCanonicalLanguageIdentifierFromString(
NULL, language_cfstring);
- if (!iso_language)
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- languages[i] << " is not a recognized language"
- << std::endl);
- }
- char *iso_language_cstr = (char *) malloc(65);
+ if (!iso_language) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, languages[i]
+ << " is not a recognized language" << std::endl);
+ }
+ char* iso_language_cstr = (char*)malloc(65);
CFStringGetCString(iso_language, iso_language_cstr, 64,
kCFStringEncodingMacRoman);
LangCode lang = 0;
RegionCode region = 0;
#ifdef HAVE_CoreServices
- OSStatus err = LocaleStringToLangAndRegionCodes(iso_language_cstr,
- &lang, &region);
+ OSStatus err =
+ LocaleStringToLangAndRegionCodes(iso_language_cstr, &lang, &region);
if (err != noErr)
#endif
- {
+ {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "No language/region code available for " << iso_language_cstr
- << std::endl);
+ "No language/region code available for "
+ << iso_language_cstr << std::endl);
free(iso_language_cstr);
return 0;
- }
+ }
#ifdef HAVE_CoreServices
free(iso_language_cstr);
header_data.push_back(region);
header_data.push_back(i);
header_data.push_back(0);
#endif
- }
+ }
ofs << "data 'LPic' (5000) {\n";
ofs << std::hex << std::uppercase << std::setfill('0');
- for(size_t i = 0; i < header_data.size(); ++i)
- {
- if(i % 8 == 0)
- {
+ for (size_t i = 0; i < header_data.size(); ++i) {
+ if (i % 8 == 0) {
ofs << " $\"";
- }
+ }
ofs << std::setw(4) << header_data[i];
- if(i % 8 == 7 || i == header_data.size() - 1)
- {
+ if (i % 8 == 7 || i == header_data.size() - 1) {
ofs << "\"\n";
- }
- else
- {
+ } else {
ofs << " ";
- }
}
+ }
ofs << "};\n\n";
// Reset ofs options
ofs << std::dec << std::nouppercase << std::setfill(' ');
- }
+ }
bool have_write_license_error = false;
std::string error;
- if(oldStyle)
- {
- if(!this->WriteLicense(ofs, 0, "", cpack_license_file, &error))
- {
+ if (oldStyle) {
+ if (!this->WriteLicense(ofs, 0, "", cpack_license_file, &error)) {
have_write_license_error = true;
- }
}
- else
- {
- for(size_t i = 0; i < languages.size() && !have_write_license_error; ++i)
- {
- if(singleLicense)
- {
- if(!this->WriteLicense(ofs, i + 5000, languages[i],
- cpack_license_file, &error))
- {
+ } else {
+ for (size_t i = 0; i < languages.size() && !have_write_license_error;
+ ++i) {
+ if (singleLicense) {
+ if (!this->WriteLicense(ofs, i + 5000, languages[i],
+ cpack_license_file, &error)) {
have_write_license_error = true;
- }
}
- else
- {
- if(!this->WriteLicense(ofs, i + 5000, languages[i], "", &error))
- {
+ } else {
+ if (!this->WriteLicense(ofs, i + 5000, languages[i], "", &error)) {
have_write_license_error = true;
- }
}
}
}
+ }
ofs.Close();
- if(have_write_license_error)
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error writing license file to SLA." << std::endl
- << error
- << std::endl);
+ if (have_write_license_error) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Error writing license file to SLA."
+ << std::endl
+ << error << std::endl);
return 0;
- }
+ }
// convert to UDCO
std::string temp_udco = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
@@ -735,14 +647,13 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
udco_image_command << " -format UDCO";
udco_image_command << " -ov -o \"" << temp_udco << "\"";
- if(!this->RunCommand(udco_image_command, &error))
- {
+ if (!this->RunCommand(udco_image_command, &error)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error converting to UDCO dmg for adding SLA." << std::endl
- << error
- << std::endl);
+ "Error converting to UDCO dmg for adding SLA."
+ << std::endl
+ << error << std::endl);
return 0;
- }
+ }
// unflatten dmg
std::ostringstream unflatten_command;
@@ -750,35 +661,31 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
unflatten_command << " unflatten ";
unflatten_command << "\"" << temp_udco << "\"";
- if(!this->RunCommand(unflatten_command, &error))
- {
+ if (!this->RunCommand(unflatten_command, &error)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error unflattening dmg for adding SLA." << std::endl
- << error
- << std::endl);
+ "Error unflattening dmg for adding SLA." << std::endl
+ << error
+ << std::endl);
return 0;
- }
+ }
// Rez the SLA
std::ostringstream embed_sla_command;
embed_sla_command << this->GetOption("CPACK_COMMAND_REZ");
const char* sysroot = this->GetOption("CPACK_OSX_SYSROOT");
- if(sysroot && sysroot[0] != '\0')
- {
+ if (sysroot && sysroot[0] != '\0') {
embed_sla_command << " -isysroot \"" << sysroot << "\"";
- }
+ }
embed_sla_command << " \"" << sla_r << "\"";
embed_sla_command << " -a -o ";
embed_sla_command << "\"" << temp_udco << "\"";
- if(!this->RunCommand(embed_sla_command, &error))
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error adding SLA." << std::endl
- << error
- << std::endl);
+ if (!this->RunCommand(embed_sla_command, &error)) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Error adding SLA." << std::endl
+ << error
+ << std::endl);
return 0;
- }
+ }
// flatten dmg
std::ostringstream flatten_command;
@@ -786,18 +693,16 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
flatten_command << " flatten ";
flatten_command << "\"" << temp_udco << "\"";
- if(!this->RunCommand(flatten_command, &error))
- {
+ if (!this->RunCommand(flatten_command, &error)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error flattening dmg for adding SLA." << std::endl
- << error
- << std::endl);
+ "Error flattening dmg for adding SLA." << std::endl
+ << error
+ << std::endl);
return 0;
- }
-
- temp_image = temp_udco;
}
+ temp_image = temp_udco;
+ }
// Create the final compressed read-only disk image ...
std::ostringstream final_image_command;
@@ -809,14 +714,12 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
final_image_command << " zlib-level=9";
final_image_command << " -o \"" << output_file << "\"";
- if(!this->RunCommand(final_image_command))
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error compressing disk image."
- << std::endl);
+ if (!this->RunCommand(final_image_command)) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Error compressing disk image."
+ << std::endl);
return 0;
- }
+ }
return 1;
}
@@ -826,9 +729,8 @@ bool cmCPackDragNDropGenerator::SupportsComponentInstallation() const
return true;
}
-std::string
-cmCPackDragNDropGenerator::GetComponentInstallDirNameSuffix(
- const std::string& componentName)
+std::string cmCPackDragNDropGenerator::GetComponentInstallDirNameSuffix(
+ const std::string& componentName)
{
// we want to group components together that go in the same dmg package
std::string package_file_name = this->GetOption("CPACK_PACKAGE_FILE_NAME");
@@ -840,179 +742,153 @@ cmCPackDragNDropGenerator::GetComponentInstallDirNameSuffix(
// 3. ignore groups - if grouping is defined, it is ignored
// and each component goes in its own package
- if(this->componentPackageMethod == ONE_PACKAGE)
- {
+ if (this->componentPackageMethod == ONE_PACKAGE) {
return "ALL_IN_ONE";
- }
+ }
- if(this->componentPackageMethod == ONE_PACKAGE_PER_GROUP)
- {
+ if (this->componentPackageMethod == ONE_PACKAGE_PER_GROUP) {
// We have to find the name of the COMPONENT GROUP
// the current COMPONENT belongs to.
- std::string groupVar = "CPACK_COMPONENT_" +
- cmSystemTools::UpperCase(componentName) + "_GROUP";
+ std::string groupVar =
+ "CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP";
const char* _groupName = GetOption(groupVar.c_str());
- if (_groupName)
- {
+ if (_groupName) {
std::string groupName = _groupName;
- groupName = GetComponentPackageFileName(package_file_name,
- groupName, true);
+ groupName =
+ GetComponentPackageFileName(package_file_name, groupName, true);
return groupName;
- }
}
+ }
return GetComponentPackageFileName(package_file_name, componentName, false);
}
-bool
-cmCPackDragNDropGenerator::WriteLicense(cmGeneratedFileStream& outputStream,
- int licenseNumber, std::string licenseLanguage, std::string licenseFile,
- std::string *error)
+bool cmCPackDragNDropGenerator::WriteLicense(
+ cmGeneratedFileStream& outputStream, int licenseNumber,
+ std::string licenseLanguage, std::string licenseFile, std::string* error)
{
- if(!licenseFile.empty() && !singleLicense)
- {
+ if (!licenseFile.empty() && !singleLicense) {
licenseNumber = 5002;
licenseLanguage = "English";
- }
+ }
// License header
- outputStream << "data 'TEXT' (" << licenseNumber << ", \""
- << licenseLanguage << "\") {\n";
+ outputStream << "data 'TEXT' (" << licenseNumber << ", \"" << licenseLanguage
+ << "\") {\n";
// License body
- std::string actual_license = !licenseFile.empty() ? licenseFile :
- (slaDirectory + "/" + licenseLanguage + ".license.txt");
+ std::string actual_license = !licenseFile.empty()
+ ? licenseFile
+ : (slaDirectory + "/" + licenseLanguage + ".license.txt");
cmsys::ifstream license_ifs;
license_ifs.open(actual_license.c_str());
- if(license_ifs.is_open())
- {
- while(license_ifs.good())
- {
+ if (license_ifs.is_open()) {
+ while (license_ifs.good()) {
std::string line;
std::getline(license_ifs, line);
- if(!line.empty())
- {
+ if (!line.empty()) {
EscapeQuotesAndBackslashes(line);
std::vector<std::string> lines;
- if(!this->BreakLongLine(line, lines, error))
- {
+ if (!this->BreakLongLine(line, lines, error)) {
return false;
- }
- for(size_t i = 0; i < lines.size(); ++i)
- {
+ }
+ for (size_t i = 0; i < lines.size(); ++i) {
outputStream << " \"" << lines[i] << "\"\n";
- }
}
- outputStream << " \"\\n\"\n";
}
- license_ifs.close();
+ outputStream << " \"\\n\"\n";
}
+ license_ifs.close();
+ }
// End of License
outputStream << "};\n\n";
- if(!licenseFile.empty() && !singleLicense)
- {
+ if (!licenseFile.empty() && !singleLicense) {
outputStream << SLASTREnglish;
- }
- else
- {
+ } else {
// Menu header
outputStream << "resource 'STR#' (" << licenseNumber << ", \""
- << licenseLanguage << "\") {\n";
+ << licenseLanguage << "\") {\n";
outputStream << " {\n";
// Menu body
cmsys::ifstream menu_ifs;
- menu_ifs.open((slaDirectory+"/"+licenseLanguage+".menu.txt").c_str());
- if(menu_ifs.is_open())
- {
+ menu_ifs.open(
+ (slaDirectory + "/" + licenseLanguage + ".menu.txt").c_str());
+ if (menu_ifs.is_open()) {
size_t lines_written = 0;
- while(menu_ifs.good())
- {
+ while (menu_ifs.good()) {
// Lines written from original file, not from broken up lines
std::string line;
std::getline(menu_ifs, line);
- if(!line.empty())
- {
+ if (!line.empty()) {
EscapeQuotesAndBackslashes(line);
std::vector<std::string> lines;
- if(!this->BreakLongLine(line, lines, error))
- {
+ if (!this->BreakLongLine(line, lines, error)) {
return false;
- }
- for(size_t i = 0; i < lines.size(); ++i)
- {
+ }
+ for (size_t i = 0; i < lines.size(); ++i) {
std::string comma;
// We need a comma after every complete string,
// but not on the very last line
- if(lines_written != 8 && i == lines.size() - 1)
- {
+ if (lines_written != 8 && i == lines.size() - 1) {
comma = ",";
- }
- else
- {
+ } else {
comma = "";
- }
- outputStream << " \"" << lines[i] << "\"" << comma << "\n";
}
- ++lines_written;
+ outputStream << " \"" << lines[i] << "\"" << comma << "\n";
}
+ ++lines_written;
}
- menu_ifs.close();
}
+ menu_ifs.close();
+ }
- //End of menu
+ // End of menu
outputStream << " }\n";
outputStream << "};\n";
outputStream << "\n";
- }
+ }
return true;
}
-bool
-cmCPackDragNDropGenerator::BreakLongLine(const std::string& line,
- std::vector<std::string>& lines, std::string *error)
+bool cmCPackDragNDropGenerator::BreakLongLine(const std::string& line,
+ std::vector<std::string>& lines,
+ std::string* error)
{
const size_t max_line_length = 512;
- for(size_t i = 0; i < line.size(); i += max_line_length)
- {
+ for (size_t i = 0; i < line.size(); i += max_line_length) {
size_t line_length = max_line_length;
- if(i + line_length > line.size())
- {
+ if (i + line_length > line.size()) {
line_length = line.size() - i;
- }
- else while(line_length > 0 && line[i + line_length - 1] != ' ')
- {
- line_length = line_length - 1;
+ } else
+ while (line_length > 0 && line[i + line_length - 1] != ' ') {
+ line_length = line_length - 1;
}
- if(line_length == 0)
- {
+ if (line_length == 0) {
*error = "Please make sure there are no words "
"(or character sequences not broken up by spaces or newlines) "
"in your license file which are more than 512 characters long.";
return false;
- }
- lines.push_back(line.substr(i, line_length));
}
+ lines.push_back(line.substr(i, line_length));
+ }
return true;
}
-void
-cmCPackDragNDropGenerator::EscapeQuotesAndBackslashes(std::string& line)
+void cmCPackDragNDropGenerator::EscapeQuotesAndBackslashes(std::string& line)
{
std::string::size_type backslash_pos = line.find('\\');
- while(backslash_pos != std::string::npos)
- {
+ while (backslash_pos != std::string::npos) {
line.replace(backslash_pos, 1, "\\\\");
backslash_pos = line.find('\\', backslash_pos + 2);
- }
+ }
std::string::size_type quote_pos = line.find('\"');
- while(quote_pos != std::string::npos)
- {
+ while (quote_pos != std::string::npos) {
line.replace(quote_pos, 1, "\\\"");
quote_pos = line.find('\"', quote_pos + 2);
- }
+ }
}
diff --git a/Source/CPack/cmCPackDragNDropGenerator.h b/Source/CPack/cmCPackDragNDropGenerator.h
index 604cdf5..1392b21 100644
--- a/Source/CPack/cmCPackDragNDropGenerator.h
+++ b/Source/CPack/cmCPackDragNDropGenerator.h
@@ -34,13 +34,12 @@ protected:
int PackageFiles();
bool SupportsComponentInstallation() const;
-
bool CopyFile(std::ostringstream& source, std::ostringstream& target);
bool CreateEmptyFile(std::ostringstream& target, size_t size);
bool RunCommand(std::ostringstream& command, std::string* output = 0);
- std::string
- GetComponentInstallDirNameSuffix(const std::string& componentName);
+ std::string GetComponentInstallDirNameSuffix(
+ const std::string& componentName);
int CreateDMG(const std::string& src_dir, const std::string& output_file);
@@ -51,11 +50,10 @@ private:
bool singleLicense;
bool WriteLicense(cmGeneratedFileStream& outputStream, int licenseNumber,
- std::string licenseLanguage, std::string licenseFile,
- std::string *error);
- bool BreakLongLine(const std::string& line,
- std::vector<std::string>& lines,
- std::string *error);
+ std::string licenseLanguage, std::string licenseFile,
+ std::string* error);
+ bool BreakLongLine(const std::string& line, std::vector<std::string>& lines,
+ std::string* error);
void EscapeQuotesAndBackslashes(std::string& line);
};
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx
index 04ee21a..c8b075d 100644
--- a/Source/CPack/cmCPackGenerator.cxx
+++ b/Source/CPack/cmCPackGenerator.cxx
@@ -44,14 +44,13 @@ cmCPackGenerator::~cmCPackGenerator()
this->MakefileMap = 0;
}
-void cmCPackGeneratorProgress(const char *msg, float prog, void* ptr)
+void cmCPackGeneratorProgress(const char* msg, float prog, void* ptr)
{
cmCPackGenerator* self = static_cast<cmCPackGenerator*>(ptr);
self->DisplayVerboseOutput(msg, prog);
}
-void cmCPackGenerator::DisplayVerboseOutput(const char* msg,
- float progress)
+void cmCPackGenerator::DisplayVerboseOutput(const char* msg, float progress)
{
(void)progress;
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "" << msg << std::endl);
@@ -59,63 +58,52 @@ void cmCPackGenerator::DisplayVerboseOutput(const char* msg,
int cmCPackGenerator::PrepareNames()
{
- cmCPackLogger(cmCPackLog::LOG_DEBUG,
- "Create temp directory." << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_DEBUG, "Create temp directory." << std::endl);
// checks CPACK_SET_DESTDIR support
- if (IsOn("CPACK_SET_DESTDIR"))
- {
- if (SETDESTDIR_UNSUPPORTED==SupportsSetDestdir())
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "CPACK_SET_DESTDIR is set to ON but the '"
- << Name << "' generator does NOT support it."
- << std::endl);
- return 0;
- }
- else if (SETDESTDIR_SHOULD_NOT_BE_USED==SupportsSetDestdir())
- {
- cmCPackLogger(cmCPackLog::LOG_WARNING,
- "CPACK_SET_DESTDIR is set to ON but it is "
- << "usually a bad idea to do that with '"
- << Name << "' generator. Use at your own risk."
- << std::endl);
- }
+ if (IsOn("CPACK_SET_DESTDIR")) {
+ if (SETDESTDIR_UNSUPPORTED == SupportsSetDestdir()) {
+ cmCPackLogger(
+ cmCPackLog::LOG_ERROR, "CPACK_SET_DESTDIR is set to ON but the '"
+ << Name << "' generator does NOT support it." << std::endl);
+ return 0;
+ } else if (SETDESTDIR_SHOULD_NOT_BE_USED == SupportsSetDestdir()) {
+ cmCPackLogger(cmCPackLog::LOG_WARNING,
+ "CPACK_SET_DESTDIR is set to ON but it is "
+ << "usually a bad idea to do that with '" << Name
+ << "' generator. Use at your own risk." << std::endl);
+ }
}
std::string tempDirectory = this->GetOption("CPACK_PACKAGE_DIRECTORY");
tempDirectory += "/_CPack_Packages/";
const char* toplevelTag = this->GetOption("CPACK_TOPLEVEL_TAG");
- if ( toplevelTag )
- {
+ if (toplevelTag) {
tempDirectory += toplevelTag;
tempDirectory += "/";
- }
+ }
tempDirectory += this->GetOption("CPACK_GENERATOR");
std::string topDirectory = tempDirectory;
const char* pfname = this->GetOption("CPACK_PACKAGE_FILE_NAME");
- if(!pfname)
- {
+ if (!pfname) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"CPACK_PACKAGE_FILE_NAME not specified" << std::endl);
return 0;
- }
+ }
std::string outName = pfname;
tempDirectory += "/" + outName;
- if(!this->GetOutputExtension())
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "No output extension specified" << std::endl);
+ if (!this->GetOutputExtension()) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "No output extension specified"
+ << std::endl);
return 0;
- }
+ }
outName += this->GetOutputExtension();
const char* pdir = this->GetOption("CPACK_PACKAGE_DIRECTORY");
- if(!pdir)
- {
+ if (!pdir) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"CPACK_PACKAGE_DIRECTORY not specified" << std::endl);
return 0;
- }
+ }
std::string destFile = pdir;
this->SetOptionIfNotSet("CPACK_OUTPUT_FILE_PREFIX", destFile.c_str());
@@ -128,52 +116,49 @@ int cmCPackGenerator::PrepareNames()
this->SetOptionIfNotSet("CPACK_TEMPORARY_PACKAGE_FILE_NAME",
outFile.c_str());
this->SetOptionIfNotSet("CPACK_INSTALL_DIRECTORY", this->GetInstallPath());
- this->SetOptionIfNotSet("CPACK_NATIVE_INSTALL_DIRECTORY",
+ this->SetOptionIfNotSet(
+ "CPACK_NATIVE_INSTALL_DIRECTORY",
cmsys::SystemTools::ConvertToOutputPath(this->GetInstallPath()).c_str());
this->SetOptionIfNotSet("CPACK_TEMPORARY_INSTALL_DIRECTORY",
tempDirectory.c_str());
cmCPackLogger(cmCPackLog::LOG_DEBUG,
- "Look for: CPACK_PACKAGE_DESCRIPTION_FILE" << std::endl);
- const char* descFileName
- = this->GetOption("CPACK_PACKAGE_DESCRIPTION_FILE");
- if ( descFileName )
- {
- cmCPackLogger(cmCPackLog::LOG_DEBUG,
- "Look for: " << descFileName << std::endl);
- if ( !cmSystemTools::FileExists(descFileName) )
- {
+ "Look for: CPACK_PACKAGE_DESCRIPTION_FILE" << std::endl);
+ const char* descFileName = this->GetOption("CPACK_PACKAGE_DESCRIPTION_FILE");
+ if (descFileName) {
+ cmCPackLogger(cmCPackLog::LOG_DEBUG, "Look for: " << descFileName
+ << std::endl);
+ if (!cmSystemTools::FileExists(descFileName)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Cannot find description file name: ["
- << descFileName << "]" << std::endl);
+ << descFileName << "]" << std::endl);
return 0;
- }
+ }
cmsys::ifstream ifs(descFileName);
- if ( !ifs )
- {
+ if (!ifs) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Cannot open description file name: " << descFileName << std::endl);
+ "Cannot open description file name: " << descFileName
+ << std::endl);
return 0;
- }
+ }
std::ostringstream ostr;
std::string line;
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
- "Read description file: " << descFileName << std::endl);
- while ( ifs && cmSystemTools::GetLineFromStream(ifs, line) )
- {
+ "Read description file: " << descFileName << std::endl);
+ while (ifs && cmSystemTools::GetLineFromStream(ifs, line)) {
ostr << cmXMLSafe(line) << std::endl;
- }
- this->SetOptionIfNotSet("CPACK_PACKAGE_DESCRIPTION", ostr.str().c_str());
}
- if ( !this->GetOption("CPACK_PACKAGE_DESCRIPTION") )
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
+ this->SetOptionIfNotSet("CPACK_PACKAGE_DESCRIPTION", ostr.str().c_str());
+ }
+ if (!this->GetOption("CPACK_PACKAGE_DESCRIPTION")) {
+ cmCPackLogger(
+ cmCPackLog::LOG_ERROR,
"Project description not specified. Please specify "
"CPACK_PACKAGE_DESCRIPTION or CPACK_PACKAGE_DESCRIPTION_FILE."
- << std::endl);
+ << std::endl);
return 0;
- }
+ }
this->SetOptionIfNotSet("CPACK_REMOVE_TOPLEVEL_DIRECTORY", "1");
@@ -185,78 +170,66 @@ int cmCPackGenerator::InstallProject()
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Install projects" << std::endl);
this->CleanTemporaryDirectory();
- std::string bareTempInstallDirectory
- = this->GetOption("CPACK_TEMPORARY_INSTALL_DIRECTORY");
+ std::string bareTempInstallDirectory =
+ this->GetOption("CPACK_TEMPORARY_INSTALL_DIRECTORY");
std::string tempInstallDirectoryStr = bareTempInstallDirectory;
- bool setDestDir = cmSystemTools::IsOn(this->GetOption("CPACK_SET_DESTDIR"))
- | cmSystemTools::IsInternallyOn(
- this->GetOption("CPACK_SET_DESTDIR"));
- if (!setDestDir)
- {
+ bool setDestDir = cmSystemTools::IsOn(this->GetOption("CPACK_SET_DESTDIR")) |
+ cmSystemTools::IsInternallyOn(this->GetOption("CPACK_SET_DESTDIR"));
+ if (!setDestDir) {
tempInstallDirectoryStr += this->GetPackagingInstallPrefix();
- }
+ }
const char* tempInstallDirectory = tempInstallDirectoryStr.c_str();
int res = 1;
- if ( !cmsys::SystemTools::MakeDirectory(bareTempInstallDirectory.c_str()))
- {
+ if (!cmsys::SystemTools::MakeDirectory(bareTempInstallDirectory.c_str())) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Problem creating temporary directory: "
- << (tempInstallDirectory ? tempInstallDirectory : "(NULL)")
- << std::endl);
+ "Problem creating temporary directory: "
+ << (tempInstallDirectory ? tempInstallDirectory : "(NULL)")
+ << std::endl);
return 0;
- }
+ }
- if ( setDestDir )
- {
+ if (setDestDir) {
std::string destDir = "DESTDIR=";
destDir += tempInstallDirectory;
cmSystemTools::PutEnv(destDir);
- }
- else
- {
+ } else {
// Make sure there is no destdir
cmSystemTools::PutEnv("DESTDIR=");
- }
+ }
// If the CPackConfig file sets CPACK_INSTALL_COMMANDS then run them
// as listed
- if ( !this->InstallProjectViaInstallCommands(
- setDestDir, tempInstallDirectory) )
- {
+ if (!this->InstallProjectViaInstallCommands(setDestDir,
+ tempInstallDirectory)) {
return 0;
- }
+ }
// If the CPackConfig file sets CPACK_INSTALL_SCRIPT then run them
// as listed
- if ( !this->InstallProjectViaInstallScript(
- setDestDir, tempInstallDirectory) )
- {
+ if (!this->InstallProjectViaInstallScript(setDestDir,
+ tempInstallDirectory)) {
return 0;
- }
+ }
// If the CPackConfig file sets CPACK_INSTALLED_DIRECTORIES
// then glob it and copy it to CPACK_TEMPORARY_DIRECTORY
// This is used in Source packaging
- if ( !this->InstallProjectViaInstalledDirectories(
- setDestDir, tempInstallDirectory) )
- {
+ if (!this->InstallProjectViaInstalledDirectories(setDestDir,
+ tempInstallDirectory)) {
return 0;
- }
-
+ }
// If the project is a CMAKE project then run pre-install
// and then read the cmake_install script to run it
- if ( !this->InstallProjectViaInstallCMakeProjects(
- setDestDir, bareTempInstallDirectory) )
- {
+ if (!this->InstallProjectViaInstallCMakeProjects(setDestDir,
+ bareTempInstallDirectory)) {
return 0;
- }
+ }
- if ( setDestDir )
- {
+ if (setDestDir) {
cmSystemTools::PutEnv("DESTDIR=");
- }
+ }
return res;
}
@@ -264,43 +237,37 @@ int cmCPackGenerator::InstallProject()
int cmCPackGenerator::InstallProjectViaInstallCommands(
bool setDestDir, const std::string& tempInstallDirectory)
{
- (void) setDestDir;
+ (void)setDestDir;
const char* installCommands = this->GetOption("CPACK_INSTALL_COMMANDS");
- if ( installCommands && *installCommands )
- {
+ if (installCommands && *installCommands) {
std::string tempInstallDirectoryEnv = "CMAKE_INSTALL_PREFIX=";
tempInstallDirectoryEnv += tempInstallDirectory;
cmSystemTools::PutEnv(tempInstallDirectoryEnv);
std::vector<std::string> installCommandsVector;
- cmSystemTools::ExpandListArgument(installCommands,installCommandsVector);
+ cmSystemTools::ExpandListArgument(installCommands, installCommandsVector);
std::vector<std::string>::iterator it;
- for ( it = installCommandsVector.begin();
- it != installCommandsVector.end();
- ++it )
- {
- cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << *it
- << std::endl);
+ for (it = installCommandsVector.begin(); it != installCommandsVector.end();
+ ++it) {
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << *it << std::endl);
std::string output;
int retVal = 1;
bool resB = cmSystemTools::RunSingleCommand(
- it->c_str(), &output, &output,
- &retVal, 0, this->GeneratorVerbose, 0);
- if ( !resB || retVal )
- {
+ it->c_str(), &output, &output, &retVal, 0, this->GeneratorVerbose, 0);
+ if (!resB || retVal) {
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
tmpFile += "/InstallOutput.log";
cmGeneratedFileStream ofs(tmpFile.c_str());
ofs << "# Run command: " << *it << std::endl
- << "# Output:" << std::endl
- << output << std::endl;
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Problem running install command: " << *it << std::endl
- << "Please check " << tmpFile << " for errors"
- << std::endl);
+ << "# Output:" << std::endl
+ << output << std::endl;
+ cmCPackLogger(
+ cmCPackLog::LOG_ERROR, "Problem running install command: "
+ << *it << std::endl
+ << "Please check " << tmpFile << " for errors" << std::endl);
return 0;
- }
}
}
+ }
return 1;
}
@@ -311,265 +278,230 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
(void)tempInstallDirectory;
std::vector<cmsys::RegularExpression> ignoreFilesRegex;
const char* cpackIgnoreFiles = this->GetOption("CPACK_IGNORE_FILES");
- if ( cpackIgnoreFiles )
- {
+ if (cpackIgnoreFiles) {
std::vector<std::string> ignoreFilesRegexString;
cmSystemTools::ExpandListArgument(cpackIgnoreFiles,
ignoreFilesRegexString);
std::vector<std::string>::iterator it;
- for ( it = ignoreFilesRegexString.begin();
- it != ignoreFilesRegexString.end();
- ++it )
- {
+ for (it = ignoreFilesRegexString.begin();
+ it != ignoreFilesRegexString.end(); ++it) {
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
- "Create ignore files regex for: " << *it << std::endl);
+ "Create ignore files regex for: " << *it << std::endl);
ignoreFilesRegex.push_back(it->c_str());
- }
}
- const char* installDirectories
- = this->GetOption("CPACK_INSTALLED_DIRECTORIES");
- if ( installDirectories && *installDirectories )
- {
+ }
+ const char* installDirectories =
+ this->GetOption("CPACK_INSTALLED_DIRECTORIES");
+ if (installDirectories && *installDirectories) {
std::vector<std::string> installDirectoriesVector;
cmSystemTools::ExpandListArgument(installDirectories,
- installDirectoriesVector);
- if ( installDirectoriesVector.size() % 2 != 0 )
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
+ installDirectoriesVector);
+ if (installDirectoriesVector.size() % 2 != 0) {
+ cmCPackLogger(
+ cmCPackLog::LOG_ERROR,
"CPACK_INSTALLED_DIRECTORIES should contain pairs of <directory> and "
"<subdirectory>. The <subdirectory> can be '.' to be installed in "
- "the toplevel directory of installation." << std::endl);
+ "the toplevel directory of installation."
+ << std::endl);
return 0;
- }
+ }
std::vector<std::string>::iterator it;
const std::string& tempDir = tempInstallDirectory;
- for ( it = installDirectoriesVector.begin();
- it != installDirectoriesVector.end();
- ++it )
- {
- std::list<std::pair<std::string,std::string> > symlinkedFiles;
+ for (it = installDirectoriesVector.begin();
+ it != installDirectoriesVector.end(); ++it) {
+ std::list<std::pair<std::string, std::string> > symlinkedFiles;
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Find files" << std::endl);
cmsys::Glob gl;
std::string top = *it;
- it ++;
+ it++;
std::string subdir = *it;
std::string findExpr = top;
findExpr += "/*";
cmCPackLogger(cmCPackLog::LOG_OUTPUT,
- "- Install directory: " << top << std::endl);
+ "- Install directory: " << top << std::endl);
gl.RecurseOn();
gl.SetRecurseListDirs(true);
- if ( !gl.FindFiles(findExpr) )
- {
+ if (!gl.FindFiles(findExpr)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Cannot find any files in the installed directory" << std::endl);
+ "Cannot find any files in the installed directory"
+ << std::endl);
return 0;
- }
+ }
files = gl.GetFiles();
std::vector<std::string>::iterator gfit;
std::vector<cmsys::RegularExpression>::iterator regIt;
- for ( gfit = files.begin(); gfit != files.end(); ++ gfit )
- {
+ for (gfit = files.begin(); gfit != files.end(); ++gfit) {
bool skip = false;
std::string inFile = *gfit;
- if(cmSystemTools::FileIsDirectory(*gfit))
- {
+ if (cmSystemTools::FileIsDirectory(*gfit)) {
inFile += '/';
- }
- for ( regIt= ignoreFilesRegex.begin();
- regIt!= ignoreFilesRegex.end();
- ++ regIt)
- {
- if ( regIt->find(inFile.c_str()) )
- {
- cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Ignore file: "
- << inFile << std::endl);
+ }
+ for (regIt = ignoreFilesRegex.begin(); regIt != ignoreFilesRegex.end();
+ ++regIt) {
+ if (regIt->find(inFile.c_str())) {
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE,
+ "Ignore file: " << inFile << std::endl);
skip = true;
- }
}
- if ( skip )
- {
+ }
+ if (skip) {
continue;
- }
+ }
std::string filePath = tempDir;
- filePath += "/" + subdir + "/"
- + cmSystemTools::RelativePath(top.c_str(), gfit->c_str());
+ filePath += "/" + subdir + "/" +
+ cmSystemTools::RelativePath(top.c_str(), gfit->c_str());
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Copy file: "
- << inFile << " -> " << filePath << std::endl);
+ << inFile << " -> " << filePath << std::endl);
/* If the file is a symlink we will have to re-create it */
- if ( cmSystemTools::FileIsSymlink(inFile))
- {
+ if (cmSystemTools::FileIsSymlink(inFile)) {
std::string targetFile;
std::string inFileRelative =
- cmSystemTools::RelativePath(top.c_str(),inFile.c_str());
- cmSystemTools::ReadSymlink(inFile,targetFile);
- symlinkedFiles.push_back(std::pair<std::string,
- std::string>(targetFile,inFileRelative));
- }
+ cmSystemTools::RelativePath(top.c_str(), inFile.c_str());
+ cmSystemTools::ReadSymlink(inFile, targetFile);
+ symlinkedFiles.push_back(
+ std::pair<std::string, std::string>(targetFile, inFileRelative));
+ }
/* If it is not a symlink then do a plain copy */
- else if (!(
- cmSystemTools::CopyFileIfDifferent(inFile.c_str(),filePath.c_str())
- &&
- cmSystemTools::CopyFileTime(inFile.c_str(),filePath.c_str())
- ) )
- {
+ else if (!(cmSystemTools::CopyFileIfDifferent(inFile.c_str(),
+ filePath.c_str()) &&
+ cmSystemTools::CopyFileTime(inFile.c_str(),
+ filePath.c_str()))) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying file: "
- << inFile << " -> " << filePath << std::endl);
+ << inFile << " -> " << filePath << std::endl);
return 0;
- }
}
+ }
/* rebuild symlinks in the installed tree */
- if (!symlinkedFiles.empty())
- {
- std::list< std::pair<std::string,std::string> >::iterator symlinkedIt;
+ if (!symlinkedFiles.empty()) {
+ std::list<std::pair<std::string, std::string> >::iterator symlinkedIt;
std::string curDir = cmSystemTools::GetCurrentWorkingDirectory();
std::string goToDir = tempDir;
- goToDir += "/"+subdir;
- cmCPackLogger(cmCPackLog::LOG_DEBUG,
- "Change dir to: " << goToDir <<std::endl);
+ goToDir += "/" + subdir;
+ cmCPackLogger(cmCPackLog::LOG_DEBUG, "Change dir to: " << goToDir
+ << std::endl);
cmSystemTools::ChangeDirectory(goToDir);
- for (symlinkedIt=symlinkedFiles.begin();
- symlinkedIt != symlinkedFiles.end();
- ++symlinkedIt)
- {
+ for (symlinkedIt = symlinkedFiles.begin();
+ symlinkedIt != symlinkedFiles.end(); ++symlinkedIt) {
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Will create a symlink: "
- << symlinkedIt->second << "--> "
- << symlinkedIt->first << std::endl);
+ << symlinkedIt->second << "--> "
+ << symlinkedIt->first << std::endl);
// make sure directory exists for symlink
std::string destDir =
cmSystemTools::GetFilenamePath(symlinkedIt->second);
- if(!destDir.empty() && !cmSystemTools::MakeDirectory(destDir))
- {
+ if (!destDir.empty() && !cmSystemTools::MakeDirectory(destDir)) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot create dir: "
- << destDir
- << "\nTrying to create symlink: "
- << symlinkedIt->second << "--> "
- << symlinkedIt->first
- << std::endl);
- }
+ << destDir << "\nTrying to create symlink: "
+ << symlinkedIt->second << "--> "
+ << symlinkedIt->first << std::endl);
+ }
if (!cmSystemTools::CreateSymlink(symlinkedIt->first,
- symlinkedIt->second))
- {
+ symlinkedIt->second)) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot create symlink: "
<< symlinkedIt->second << "--> "
<< symlinkedIt->first << std::endl);
return 0;
- }
}
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "Going back to: "
- << curDir <<std::endl);
- cmSystemTools::ChangeDirectory(curDir);
}
+ cmCPackLogger(cmCPackLog::LOG_DEBUG, "Going back to: " << curDir
+ << std::endl);
+ cmSystemTools::ChangeDirectory(curDir);
}
}
+ }
return 1;
}
int cmCPackGenerator::InstallProjectViaInstallScript(
bool setDestDir, const std::string& tempInstallDirectory)
{
- const char* cmakeScripts
- = this->GetOption("CPACK_INSTALL_SCRIPT");
- if ( cmakeScripts && *cmakeScripts )
- {
- cmCPackLogger(cmCPackLog::LOG_OUTPUT,
- "- Install scripts: " << cmakeScripts << std::endl);
+ const char* cmakeScripts = this->GetOption("CPACK_INSTALL_SCRIPT");
+ if (cmakeScripts && *cmakeScripts) {
+ cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Install scripts: " << cmakeScripts
+ << std::endl);
std::vector<std::string> cmakeScriptsVector;
- cmSystemTools::ExpandListArgument(cmakeScripts,
- cmakeScriptsVector);
+ cmSystemTools::ExpandListArgument(cmakeScripts, cmakeScriptsVector);
std::vector<std::string>::iterator it;
- for ( it = cmakeScriptsVector.begin();
- it != cmakeScriptsVector.end();
- ++it )
- {
+ for (it = cmakeScriptsVector.begin(); it != cmakeScriptsVector.end();
+ ++it) {
std::string installScript = *it;
cmCPackLogger(cmCPackLog::LOG_OUTPUT,
- "- Install script: " << installScript << std::endl);
+ "- Install script: " << installScript << std::endl);
- if ( setDestDir )
- {
+ if (setDestDir) {
// For DESTDIR based packaging, use the *project* CMAKE_INSTALL_PREFIX
// underneath the tempInstallDirectory. The value of the project's
// CMAKE_INSTALL_PREFIX is sent in here as the value of the
// CPACK_INSTALL_PREFIX variable.
std::string dir;
- if (this->GetOption("CPACK_INSTALL_PREFIX"))
- {
+ if (this->GetOption("CPACK_INSTALL_PREFIX")) {
dir += this->GetOption("CPACK_INSTALL_PREFIX");
- }
+ }
this->SetOption("CMAKE_INSTALL_PREFIX", dir.c_str());
- cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ cmCPackLogger(
+ cmCPackLog::LOG_DEBUG,
"- Using DESTDIR + CPACK_INSTALL_PREFIX... (this->SetOption)"
- << std::endl);
+ << std::endl);
cmCPackLogger(cmCPackLog::LOG_DEBUG,
- "- Setting CMAKE_INSTALL_PREFIX to '" << dir << "'" << std::endl);
- }
- else
- {
+ "- Setting CMAKE_INSTALL_PREFIX to '" << dir << "'"
+ << std::endl);
+ } else {
this->SetOption("CMAKE_INSTALL_PREFIX", tempInstallDirectory.c_str());
cmCPackLogger(cmCPackLog::LOG_DEBUG,
- "- Using non-DESTDIR install... (this->SetOption)" << std::endl);
+ "- Using non-DESTDIR install... (this->SetOption)"
+ << std::endl);
cmCPackLogger(cmCPackLog::LOG_DEBUG,
- "- Setting CMAKE_INSTALL_PREFIX to '" << tempInstallDirectory
- << "'" << std::endl);
- }
+ "- Setting CMAKE_INSTALL_PREFIX to '"
+ << tempInstallDirectory << "'" << std::endl);
+ }
this->SetOptionIfNotSet("CMAKE_CURRENT_BINARY_DIR",
- tempInstallDirectory.c_str());
+ tempInstallDirectory.c_str());
this->SetOptionIfNotSet("CMAKE_CURRENT_SOURCE_DIR",
- tempInstallDirectory.c_str());
+ tempInstallDirectory.c_str());
int res = this->MakefileMap->ReadListFile(installScript.c_str());
- if ( cmSystemTools::GetErrorOccuredFlag() || !res )
- {
+ if (cmSystemTools::GetErrorOccuredFlag() || !res) {
return 0;
- }
}
}
+ }
return 1;
}
int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
bool setDestDir, const std::string& baseTempInstallDirectory)
{
- const char* cmakeProjects
- = this->GetOption("CPACK_INSTALL_CMAKE_PROJECTS");
- const char* cmakeGenerator
- = this->GetOption("CPACK_CMAKE_GENERATOR");
+ const char* cmakeProjects = this->GetOption("CPACK_INSTALL_CMAKE_PROJECTS");
+ const char* cmakeGenerator = this->GetOption("CPACK_CMAKE_GENERATOR");
std::string absoluteDestFiles;
- if ( cmakeProjects && *cmakeProjects )
- {
- if ( !cmakeGenerator )
- {
+ if (cmakeProjects && *cmakeProjects) {
+ if (!cmakeGenerator) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"CPACK_INSTALL_CMAKE_PROJECTS is specified, but "
"CPACK_CMAKE_GENERATOR is not. CPACK_CMAKE_GENERATOR "
"is required to install the project."
- << std::endl);
+ << std::endl);
return 0;
- }
+ }
std::vector<std::string> cmakeProjectsVector;
- cmSystemTools::ExpandListArgument(cmakeProjects,
- cmakeProjectsVector);
+ cmSystemTools::ExpandListArgument(cmakeProjects, cmakeProjectsVector);
std::vector<std::string>::iterator it;
- for ( it = cmakeProjectsVector.begin();
- it != cmakeProjectsVector.end();
- ++it )
- {
- if ( it+1 == cmakeProjectsVector.end() ||
- it+2 == cmakeProjectsVector.end() ||
- it+3 == cmakeProjectsVector.end() )
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
+ for (it = cmakeProjectsVector.begin(); it != cmakeProjectsVector.end();
+ ++it) {
+ if (it + 1 == cmakeProjectsVector.end() ||
+ it + 2 == cmakeProjectsVector.end() ||
+ it + 3 == cmakeProjectsVector.end()) {
+ cmCPackLogger(
+ cmCPackLog::LOG_ERROR,
"Not enough items on list: CPACK_INSTALL_CMAKE_PROJECTS. "
"CPACK_INSTALL_CMAKE_PROJECTS should hold quadruplet of install "
"directory, install project name, install component, and install "
"subdirectory."
- << std::endl);
+ << std::endl);
return 0;
- }
+ }
std::string installDirectory = *it;
++it;
std::string installProjectName = *it;
@@ -589,60 +521,50 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
* (this works at CPack time too)
*/
if (this->SupportsComponentInstallation() &
- !(this->IsOn("CPACK_MONOLITHIC_INSTALL")))
- {
+ !(this->IsOn("CPACK_MONOLITHIC_INSTALL"))) {
// Determine the installation types for this project (if provided).
- std::string installTypesVar = "CPACK_"
- + cmSystemTools::UpperCase(installComponent) + "_INSTALL_TYPES";
- const char *installTypes = this->GetOption(installTypesVar);
- if (installTypes && *installTypes)
- {
+ std::string installTypesVar = "CPACK_" +
+ cmSystemTools::UpperCase(installComponent) + "_INSTALL_TYPES";
+ const char* installTypes = this->GetOption(installTypesVar);
+ if (installTypes && *installTypes) {
std::vector<std::string> installTypesVector;
cmSystemTools::ExpandListArgument(installTypes, installTypesVector);
std::vector<std::string>::iterator installTypeIt;
for (installTypeIt = installTypesVector.begin();
- installTypeIt != installTypesVector.end();
- ++installTypeIt)
- {
- this->GetInstallationType(installProjectName,
- *installTypeIt);
- }
+ installTypeIt != installTypesVector.end(); ++installTypeIt) {
+ this->GetInstallationType(installProjectName, *installTypeIt);
}
+ }
// Determine the set of components that will be used in this project
- std::string componentsVar
- = "CPACK_COMPONENTS_" + cmSystemTools::UpperCase(installComponent);
- const char *components = this->GetOption(componentsVar);
- if (components && *components)
- {
+ std::string componentsVar =
+ "CPACK_COMPONENTS_" + cmSystemTools::UpperCase(installComponent);
+ const char* components = this->GetOption(componentsVar);
+ if (components && *components) {
cmSystemTools::ExpandListArgument(components, componentsVector);
std::vector<std::string>::iterator compIt;
for (compIt = componentsVector.begin();
- compIt != componentsVector.end();
- ++compIt)
- {
+ compIt != componentsVector.end(); ++compIt) {
GetComponent(installProjectName, *compIt);
- }
- componentInstall = true;
}
+ componentInstall = true;
}
- if (componentsVector.empty())
- {
+ }
+ if (componentsVector.empty()) {
componentsVector.push_back(installComponent);
- }
+ }
const char* buildConfigCstr = this->GetOption("CPACK_BUILD_CONFIG");
std::string buildConfig = buildConfigCstr ? buildConfigCstr : "";
- cmGlobalGenerator* globalGenerator
- = this->MakefileMap->GetCMakeInstance()->CreateGlobalGenerator(
+ cmGlobalGenerator* globalGenerator =
+ this->MakefileMap->GetCMakeInstance()->CreateGlobalGenerator(
cmakeGenerator);
- if ( !globalGenerator )
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Specified package generator not found. "
- "CPACK_CMAKE_GENERATOR value is invalid."
- << std::endl);
- return 0;
+ if (!globalGenerator) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Specified package generator not found. "
+ "CPACK_CMAKE_GENERATOR value is invalid."
+ << std::endl);
+ return 0;
}
// set the global flag for unix style paths on cmSystemTools as
// soon as the generator is set. This allows gmake to be used
@@ -650,59 +572,49 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
cmSystemTools::SetForceUnixPaths(globalGenerator->GetForceUnixPaths());
// Does this generator require pre-install?
- if (const char* preinstall = globalGenerator->GetPreinstallTargetName())
- {
- std::string buildCommand =
- globalGenerator->GenerateCMakeBuildCommand(
- preinstall, buildConfig, "", false);
+ if (const char* preinstall =
+ globalGenerator->GetPreinstallTargetName()) {
+ std::string buildCommand = globalGenerator->GenerateCMakeBuildCommand(
+ preinstall, buildConfig, "", false);
cmCPackLogger(cmCPackLog::LOG_DEBUG,
- "- Install command: " << buildCommand << std::endl);
- cmCPackLogger(cmCPackLog::LOG_OUTPUT,
- "- Run preinstall target for: " << installProjectName << std::endl);
+ "- Install command: " << buildCommand << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Run preinstall target for: "
+ << installProjectName << std::endl);
std::string output;
int retVal = 1;
- bool resB =
- cmSystemTools::RunSingleCommand(buildCommand.c_str(),
- &output, &output,
- &retVal,
- installDirectory.c_str(),
- this->GeneratorVerbose, 0);
- if ( !resB || retVal )
- {
+ bool resB = cmSystemTools::RunSingleCommand(
+ buildCommand.c_str(), &output, &output, &retVal,
+ installDirectory.c_str(), this->GeneratorVerbose, 0);
+ if (!resB || retVal) {
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
tmpFile += "/PreinstallOutput.log";
cmGeneratedFileStream ofs(tmpFile.c_str());
ofs << "# Run command: " << buildCommand << std::endl
- << "# Directory: " << installDirectory << std::endl
- << "# Output:" << std::endl
- << output << std::endl;
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Problem running install command: " << buildCommand
- << std::endl
- << "Please check " << tmpFile << " for errors"
- << std::endl);
+ << "# Directory: " << installDirectory << std::endl
+ << "# Output:" << std::endl
+ << output << std::endl;
+ cmCPackLogger(
+ cmCPackLog::LOG_ERROR, "Problem running install command: "
+ << buildCommand << std::endl
+ << "Please check " << tmpFile << " for errors" << std::endl);
return 0;
- }
}
+ }
delete globalGenerator;
cmCPackLogger(cmCPackLog::LOG_OUTPUT,
- "- Install project: " << installProjectName << std::endl);
+ "- Install project: " << installProjectName << std::endl);
// Run the installation for each component
std::vector<std::string>::iterator componentIt;
for (componentIt = componentsVector.begin();
- componentIt != componentsVector.end();
- ++componentIt)
- {
+ componentIt != componentsVector.end(); ++componentIt) {
std::string tempInstallDirectory = baseTempInstallDirectory;
installComponent = *componentIt;
- if (componentInstall)
- {
- cmCPackLogger(cmCPackLog::LOG_OUTPUT,
- "- Install component: " << installComponent
- << std::endl);
- }
+ if (componentInstall) {
+ cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Install component: "
+ << installComponent << std::endl);
+ }
cmake cm;
cm.SetHomeDirectory("");
@@ -712,13 +624,11 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
cm.SetProgressCallback(cmCPackGeneratorProgress, this);
cmGlobalGenerator gg(&cm);
cmsys::auto_ptr<cmMakefile> mf(
- new cmMakefile(&gg, cm.GetCurrentSnapshot()));
- if ( !installSubDirectory.empty() && installSubDirectory != "/" )
- {
+ new cmMakefile(&gg, cm.GetCurrentSnapshot()));
+ if (!installSubDirectory.empty() && installSubDirectory != "/") {
tempInstallDirectory += installSubDirectory;
- }
- if (componentInstall)
- {
+ }
+ if (componentInstall) {
tempInstallDirectory += "/";
// Some CPack generators would rather chose
// the local installation directory suffix.
@@ -728,20 +638,17 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
// one install directory for each component.
tempInstallDirectory +=
GetComponentInstallDirNameSuffix(installComponent);
- if (this->IsOn("CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY"))
- {
+ if (this->IsOn("CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY")) {
tempInstallDirectory += "/";
tempInstallDirectory += this->GetOption("CPACK_PACKAGE_FILE_NAME");
- }
}
+ }
- if (!setDestDir)
- {
+ if (!setDestDir) {
tempInstallDirectory += this->GetPackagingInstallPrefix();
- }
+ }
- if ( setDestDir )
- {
+ if (setDestDir) {
// For DESTDIR based packaging, use the *project*
// CMAKE_INSTALL_PREFIX underneath the tempInstallDirectory. The
// value of the project's CMAKE_INSTALL_PREFIX is sent in here as
@@ -754,37 +661,32 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
// I know this is tricky and awkward but it's the price for
// CPACK_SET_DESTDIR backward compatibility.
if (cmSystemTools::IsInternallyOn(
- this->GetOption("CPACK_SET_DESTDIR")))
- {
+ this->GetOption("CPACK_SET_DESTDIR"))) {
this->SetOption("CPACK_INSTALL_PREFIX",
this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX"));
- }
+ }
std::string dir;
- if (this->GetOption("CPACK_INSTALL_PREFIX"))
- {
+ if (this->GetOption("CPACK_INSTALL_PREFIX")) {
dir += this->GetOption("CPACK_INSTALL_PREFIX");
- }
+ }
mf->AddDefinition("CMAKE_INSTALL_PREFIX", dir.c_str());
cmCPackLogger(
cmCPackLog::LOG_DEBUG,
"- Using DESTDIR + CPACK_INSTALL_PREFIX... (mf->AddDefinition)"
- << std::endl);
+ << std::endl);
cmCPackLogger(cmCPackLog::LOG_DEBUG,
"- Setting CMAKE_INSTALL_PREFIX to '" << dir << "'"
- << std::endl);
+ << std::endl);
// Make sure that DESTDIR + CPACK_INSTALL_PREFIX directory
// exists:
//
- if (cmSystemTools::StringStartsWith(dir.c_str(), "/"))
- {
+ if (cmSystemTools::StringStartsWith(dir.c_str(), "/")) {
dir = tempInstallDirectory + dir;
- }
- else
- {
+ } else {
dir = tempInstallDirectory + "/" + dir;
- }
+ }
/*
* We must re-set DESTDIR for each component
* We must not add the CPACK_INSTALL_PREFIX part because
@@ -796,178 +698,157 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
* - Because it was already used for component install
* in order to put things in subdirs...
*/
- cmSystemTools::PutEnv(
- std::string("DESTDIR=")+tempInstallDirectory
- );
- cmCPackLogger(cmCPackLog::LOG_DEBUG,
- "- Creating directory: '" << dir << "'" << std::endl);
-
- if ( !cmsys::SystemTools::MakeDirectory(dir.c_str()))
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Problem creating temporary directory: "
- << dir << std::endl);
+ cmSystemTools::PutEnv(std::string("DESTDIR=") +
+ tempInstallDirectory);
+ cmCPackLogger(cmCPackLog::LOG_DEBUG, "- Creating directory: '"
+ << dir << "'" << std::endl);
+
+ if (!cmsys::SystemTools::MakeDirectory(dir.c_str())) {
+ cmCPackLogger(
+ cmCPackLog::LOG_ERROR,
+ "Problem creating temporary directory: " << dir << std::endl);
return 0;
- }
}
- else
- {
+ } else {
mf->AddDefinition("CMAKE_INSTALL_PREFIX",
tempInstallDirectory.c_str());
- if ( !cmsys::SystemTools::MakeDirectory(
- tempInstallDirectory.c_str()))
- {
+ if (!cmsys::SystemTools::MakeDirectory(
+ tempInstallDirectory.c_str())) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Problem creating temporary directory: "
- << tempInstallDirectory << std::endl);
+ << tempInstallDirectory << std::endl);
return 0;
- }
+ }
cmCPackLogger(cmCPackLog::LOG_DEBUG,
"- Using non-DESTDIR install... (mf->AddDefinition)"
- << std::endl);
+ << std::endl);
cmCPackLogger(cmCPackLog::LOG_DEBUG,
"- Setting CMAKE_INSTALL_PREFIX to '"
- << tempInstallDirectory
- << "'" << std::endl);
- }
+ << tempInstallDirectory << "'" << std::endl);
+ }
- if (!buildConfig.empty())
- {
+ if (!buildConfig.empty()) {
mf->AddDefinition("BUILD_TYPE", buildConfig.c_str());
- }
- std::string installComponentLowerCase
- = cmSystemTools::LowerCase(installComponent);
- if ( installComponentLowerCase != "all" )
- {
+ }
+ std::string installComponentLowerCase =
+ cmSystemTools::LowerCase(installComponent);
+ if (installComponentLowerCase != "all") {
mf->AddDefinition("CMAKE_INSTALL_COMPONENT",
installComponent.c_str());
- }
+ }
// strip on TRUE, ON, 1, one or several file names, but not on
// FALSE, OFF, 0 and an empty string
- if (!cmSystemTools::IsOff(this->GetOption("CPACK_STRIP_FILES")))
- {
+ if (!cmSystemTools::IsOff(this->GetOption("CPACK_STRIP_FILES"))) {
mf->AddDefinition("CMAKE_INSTALL_DO_STRIP", "1");
- }
+ }
// Remember the list of files before installation
// of the current component (if we are in component install)
const char* InstallPrefix = tempInstallDirectory.c_str();
std::vector<std::string> filesBefore;
std::string findExpr(InstallPrefix);
- if (componentInstall)
- {
+ if (componentInstall) {
cmsys::Glob glB;
findExpr += "/*";
glB.RecurseOn();
glB.SetRecurseListDirs(true);
glB.FindFiles(findExpr);
filesBefore = glB.GetFiles();
- std::sort(filesBefore.begin(),filesBefore.end());
- }
+ std::sort(filesBefore.begin(), filesBefore.end());
+ }
// If CPack was asked to warn on ABSOLUTE INSTALL DESTINATION
// then forward request to cmake_install.cmake script
- if (this->IsOn("CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION"))
- {
- mf->AddDefinition("CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION",
- "1");
- }
+ if (this->IsOn("CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION")) {
+ mf->AddDefinition("CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION", "1");
+ }
// If current CPack generator does support
// ABSOLUTE INSTALL DESTINATION or CPack has been asked for
// then ask cmake_install.cmake script to error out
// as soon as it occurs (before installing file)
if (!SupportsAbsoluteDestination() ||
- this->IsOn("CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION"))
- {
- mf->AddDefinition("CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION",
- "1");
- }
+ this->IsOn("CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION")) {
+ mf->AddDefinition("CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION",
+ "1");
+ }
// do installation
int res = mf->ReadListFile(installFile.c_str());
// forward definition of CMAKE_ABSOLUTE_DESTINATION_FILES
// to CPack (may be used by generators like CPack RPM or DEB)
// in order to transparently handle ABSOLUTE PATH
- if (mf->GetDefinition("CMAKE_ABSOLUTE_DESTINATION_FILES"))
- {
- mf->AddDefinition("CPACK_ABSOLUTE_DESTINATION_FILES",
- mf->GetDefinition("CMAKE_ABSOLUTE_DESTINATION_FILES"));
- }
+ if (mf->GetDefinition("CMAKE_ABSOLUTE_DESTINATION_FILES")) {
+ mf->AddDefinition(
+ "CPACK_ABSOLUTE_DESTINATION_FILES",
+ mf->GetDefinition("CMAKE_ABSOLUTE_DESTINATION_FILES"));
+ }
// Now rebuild the list of files after installation
// of the current component (if we are in component install)
- if (componentInstall)
- {
+ if (componentInstall) {
cmsys::Glob glA;
glA.RecurseOn();
glA.SetRecurseListDirs(true);
glA.FindFiles(findExpr);
std::vector<std::string> filesAfter = glA.GetFiles();
- std::sort(filesAfter.begin(),filesAfter.end());
+ std::sort(filesAfter.begin(), filesAfter.end());
std::vector<std::string>::iterator diff;
std::vector<std::string> result(filesAfter.size());
- diff = std::set_difference (
- filesAfter.begin(),filesAfter.end(),
- filesBefore.begin(),filesBefore.end(),
- result.begin());
+ diff = std::set_difference(filesAfter.begin(), filesAfter.end(),
+ filesBefore.begin(), filesBefore.end(),
+ result.begin());
std::vector<std::string>::iterator fit;
std::string localFileName;
// Populate the File field of each component
- for (fit=result.begin();fit!=diff;++fit)
- {
- localFileName =
- cmSystemTools::RelativePath(InstallPrefix, fit->c_str());
+ for (fit = result.begin(); fit != diff; ++fit) {
localFileName =
- localFileName.substr(localFileName.find_first_not_of('/'),
- std::string::npos);
+ cmSystemTools::RelativePath(InstallPrefix, fit->c_str());
+ localFileName = localFileName.substr(
+ localFileName.find_first_not_of('/'), std::string::npos);
Components[installComponent].Files.push_back(localFileName);
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Adding file <"
- <<localFileName<<"> to component <"
- <<installComponent<<">"<<std::endl);
- }
+ << localFileName << "> to component <"
+ << installComponent << ">" << std::endl);
}
+ }
- if (NULL !=mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES")) {
+ if (NULL != mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES")) {
if (!absoluteDestFiles.empty()) {
- absoluteDestFiles +=";";
+ absoluteDestFiles += ";";
}
absoluteDestFiles +=
mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES");
cmCPackLogger(cmCPackLog::LOG_DEBUG,
- "Got some ABSOLUTE DESTINATION FILES: "
- << absoluteDestFiles << std::endl);
+ "Got some ABSOLUTE DESTINATION FILES: "
+ << absoluteDestFiles << std::endl);
// define component specific var
- if (componentInstall)
- {
+ if (componentInstall) {
std::string absoluteDestFileComponent =
- std::string("CPACK_ABSOLUTE_DESTINATION_FILES")
- + "_" + GetComponentInstallDirNameSuffix(installComponent);
- if (NULL != this->GetOption(absoluteDestFileComponent))
- {
- std::string absoluteDestFilesListComponent =
- this->GetOption(absoluteDestFileComponent);
- absoluteDestFilesListComponent +=";";
- absoluteDestFilesListComponent +=
- mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES");
- this->SetOption(absoluteDestFileComponent,
- absoluteDestFilesListComponent.c_str());
- }
- else
- {
+ std::string("CPACK_ABSOLUTE_DESTINATION_FILES") + "_" +
+ GetComponentInstallDirNameSuffix(installComponent);
+ if (NULL != this->GetOption(absoluteDestFileComponent)) {
+ std::string absoluteDestFilesListComponent =
+ this->GetOption(absoluteDestFileComponent);
+ absoluteDestFilesListComponent += ";";
+ absoluteDestFilesListComponent +=
+ mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES");
this->SetOption(absoluteDestFileComponent,
- mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES"));
- }
+ absoluteDestFilesListComponent.c_str());
+ } else {
+ this->SetOption(
+ absoluteDestFileComponent,
+ mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES"));
}
+ }
}
- if ( cmSystemTools::GetErrorOccuredFlag() || !res )
- {
+ if (cmSystemTools::GetErrorOccuredFlag() || !res) {
return 0;
- }
}
}
}
+ }
this->SetOption("CPACK_ABSOLUTE_DESTINATION_FILES",
absoluteDestFiles.c_str());
return 1;
@@ -979,84 +860,73 @@ bool cmCPackGenerator::ReadListFile(const char* moduleName)
std::string fullPath = this->MakefileMap->GetModulesFile(moduleName);
retval = this->MakefileMap->ReadListFile(fullPath.c_str());
// include FATAL_ERROR and ERROR in the return status
- retval = retval && (! cmSystemTools::GetErrorOccuredFlag());
+ retval = retval && (!cmSystemTools::GetErrorOccuredFlag());
return retval;
}
void cmCPackGenerator::SetOptionIfNotSet(const std::string& op,
- const char* value)
+ const char* value)
{
const char* def = this->MakefileMap->GetDefinition(op);
- if ( def && *def )
- {
+ if (def && *def) {
return;
- }
+ }
this->SetOption(op, value);
}
void cmCPackGenerator::SetOption(const std::string& op, const char* value)
{
- if ( !value )
- {
+ if (!value) {
this->MakefileMap->RemoveDefinition(op);
return;
- }
+ }
cmCPackLogger(cmCPackLog::LOG_DEBUG, this->GetNameOfClass()
- << "::SetOption(" << op << ", " << value << ")" << std::endl);
+ << "::SetOption(" << op << ", " << value << ")"
+ << std::endl);
this->MakefileMap->AddDefinition(op, value);
}
int cmCPackGenerator::DoPackage()
{
- cmCPackLogger(cmCPackLog::LOG_OUTPUT,
- "Create package using " << this->Name << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Create package using " << this->Name
+ << std::endl);
// Prepare CPack internal name and check
// values for many CPACK_xxx vars
- if ( !this->PrepareNames() )
- {
+ if (!this->PrepareNames()) {
return 0;
- }
+ }
// Digest Component grouping specification
- if ( !this->PrepareGroupingKind() )
- {
+ if (!this->PrepareGroupingKind()) {
return 0;
- }
+ }
- if ( cmSystemTools::IsOn(
- this->GetOption("CPACK_REMOVE_TOPLEVEL_DIRECTORY")) )
- {
- const char* toplevelDirectory
- = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
- if ( cmSystemTools::FileExists(toplevelDirectory) )
- {
- cmCPackLogger(cmCPackLog::LOG_VERBOSE,
- "Remove toplevel directory: "
- << toplevelDirectory << std::endl);
- if ( !cmSystemTools::RepeatedRemoveDirectory(toplevelDirectory) )
- {
+ if (cmSystemTools::IsOn(
+ this->GetOption("CPACK_REMOVE_TOPLEVEL_DIRECTORY"))) {
+ const char* toplevelDirectory =
+ this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
+ if (cmSystemTools::FileExists(toplevelDirectory)) {
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Remove toplevel directory: "
+ << toplevelDirectory << std::endl);
+ if (!cmSystemTools::RepeatedRemoveDirectory(toplevelDirectory)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Problem removing toplevel directory: "
- << toplevelDirectory
- << std::endl);
+ "Problem removing toplevel directory: "
+ << toplevelDirectory << std::endl);
return 0;
- }
}
}
- cmCPackLogger(cmCPackLog::LOG_DEBUG,
- "About to install project " << std::endl);
+ }
+ cmCPackLogger(cmCPackLog::LOG_DEBUG, "About to install project "
+ << std::endl);
- if ( !this->InstallProject() )
- {
+ if (!this->InstallProject()) {
return 0;
- }
- cmCPackLogger(cmCPackLog::LOG_DEBUG,
- "Done install project " << std::endl);
-
+ }
+ cmCPackLogger(cmCPackLog::LOG_DEBUG, "Done install project " << std::endl);
- const char* tempPackageFileName = this->GetOption(
- "CPACK_TEMPORARY_PACKAGE_FILE_NAME");
+ const char* tempPackageFileName =
+ this->GetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME");
const char* tempDirectory = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Find files" << std::endl);
@@ -1066,27 +936,25 @@ int cmCPackGenerator::DoPackage()
gl.RecurseOn();
gl.SetRecurseListDirs(true);
gl.SetRecurseThroughSymlinks(false);
- if ( !gl.FindFiles(findExpr) )
- {
+ if (!gl.FindFiles(findExpr)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Cannot find any files in the packaging tree" << std::endl);
+ "Cannot find any files in the packaging tree" << std::endl);
return 0;
- }
+ }
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Create package" << std::endl);
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Package files to: "
- << (tempPackageFileName ? tempPackageFileName : "(NULL)") << std::endl);
- if ( cmSystemTools::FileExists(tempPackageFileName) )
- {
+ << (tempPackageFileName ? tempPackageFileName : "(NULL)")
+ << std::endl);
+ if (cmSystemTools::FileExists(tempPackageFileName)) {
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Remove old package file"
- << std::endl);
+ << std::endl);
cmSystemTools::RemoveFile(tempPackageFileName);
- }
- if ( cmSystemTools::IsOn(this->GetOption(
- "CPACK_INCLUDE_TOPLEVEL_DIRECTORY")) )
- {
+ }
+ if (cmSystemTools::IsOn(
+ this->GetOption("CPACK_INCLUDE_TOPLEVEL_DIRECTORY"))) {
tempDirectory = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
- }
+ }
// The files to be installed
files = gl.GetFiles();
@@ -1099,12 +967,11 @@ int cmCPackGenerator::DoPackage()
*/
packageFileNames.push_back(tempPackageFileName ? tempPackageFileName : "");
toplevel = tempDirectory;
- if ( !this->PackageFiles() || cmSystemTools::GetErrorOccuredFlag())
- {
+ if (!this->PackageFiles() || cmSystemTools::GetErrorOccuredFlag()) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem compressing the directory"
- << std::endl);
+ << std::endl);
return 0;
- }
+ }
/*
* Copy the generated packages to final destination
@@ -1113,35 +980,29 @@ int cmCPackGenerator::DoPackage()
* (because the specific generator did 'normalize' it)
*/
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Copying final package(s) ["
- <<packageFileNames.size()
- <<"]:"<<std::endl);
+ << packageFileNames.size() << "]:" << std::endl);
std::vector<std::string>::iterator it;
/* now copy package one by one */
- for (it=packageFileNames.begin();it!=packageFileNames.end();++it)
- {
+ for (it = packageFileNames.begin(); it != packageFileNames.end(); ++it) {
std::string tmpPF(this->GetOption("CPACK_OUTPUT_FILE_PREFIX"));
tempPackageFileName = it->c_str();
- tmpPF += "/"+cmSystemTools::GetFilenameName(*it);
+ tmpPF += "/" + cmSystemTools::GetFilenameName(*it);
const char* packageFileName = tmpPF.c_str();
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Copy final package(s): "
- << (tempPackageFileName ? tempPackageFileName : "(NULL)" )
- << " to "
- << (packageFileName ? packageFileName : "(NULL)")
- << std::endl);
- if ( !cmSystemTools::CopyFileIfDifferent(tempPackageFileName,
- packageFileName) )
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the package: "
- << (tempPackageFileName ? tempPackageFileName : "(NULL)" )
- << " to "
- << (packageFileName ? packageFileName : "(NULL)")
- << std::endl);
+ << (tempPackageFileName ? tempPackageFileName : "(NULL)")
+ << " to " << (packageFileName ? packageFileName : "(NULL)")
+ << std::endl);
+ if (!cmSystemTools::CopyFileIfDifferent(tempPackageFileName,
+ packageFileName)) {
+ cmCPackLogger(
+ cmCPackLog::LOG_ERROR, "Problem copying the package: "
+ << (tempPackageFileName ? tempPackageFileName : "(NULL)") << " to "
+ << (packageFileName ? packageFileName : "(NULL)") << std::endl);
return 0;
- }
- cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- package: "
- << packageFileName
- << " generated." << std::endl);
}
+ cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- package: "
+ << packageFileName << " generated." << std::endl);
+ }
return 1;
}
@@ -1153,17 +1014,14 @@ int cmCPackGenerator::Initialize(const std::string& name, cmMakefile* mf)
// set the running generator name
this->SetOption("CPACK_GENERATOR", this->Name.c_str());
// Load the project specific config file
- const char* config =
- this->GetOption("CPACK_PROJECT_CONFIG_FILE");
- if(config)
- {
+ const char* config = this->GetOption("CPACK_PROJECT_CONFIG_FILE");
+ if (config) {
mf->ReadListFile(config);
- }
+ }
int result = this->InitializeInternal();
- if (cmSystemTools::GetErrorOccuredFlag())
- {
+ if (cmSystemTools::GetErrorOccuredFlag()) {
return 0;
- }
+ }
// If a generator subclass did not already set this option in its
// InitializeInternal implementation, and the project did not already set
@@ -1191,13 +1049,10 @@ bool cmCPackGenerator::IsOn(const std::string& name) const
const char* cmCPackGenerator::GetOption(const std::string& op) const
{
const char* ret = this->MakefileMap->GetDefinition(op);
- if(!ret)
- {
+ if (!ret) {
cmCPackLogger(cmCPackLog::LOG_DEBUG,
- "Warning, GetOption return NULL for: "
- << op
- << std::endl);
- }
+ "Warning, GetOption return NULL for: " << op << std::endl);
+ }
return ret;
}
@@ -1213,40 +1068,32 @@ int cmCPackGenerator::PackageFiles()
const char* cmCPackGenerator::GetInstallPath()
{
- if ( !this->InstallPath.empty() )
- {
+ if (!this->InstallPath.empty()) {
return this->InstallPath.c_str();
- }
+ }
#if defined(_WIN32) && !defined(__CYGWIN__)
const char* prgfiles = cmsys::SystemTools::GetEnv("ProgramFiles");
const char* sysDrive = cmsys::SystemTools::GetEnv("SystemDrive");
- if ( prgfiles )
- {
+ if (prgfiles) {
this->InstallPath = prgfiles;
- }
- else if ( sysDrive )
- {
+ } else if (sysDrive) {
this->InstallPath = sysDrive;
this->InstallPath += "/Program Files";
- }
- else
- {
+ } else {
this->InstallPath = "c:/Program Files";
- }
+ }
this->InstallPath += "/";
this->InstallPath += this->GetOption("CPACK_PACKAGE_NAME");
this->InstallPath += "-";
this->InstallPath += this->GetOption("CPACK_PACKAGE_VERSION");
#elif defined(__HAIKU__)
char dir[B_PATH_NAME_LENGTH];
- if (find_directory(B_SYSTEM_DIRECTORY, -1, false, dir, sizeof(dir)) == B_OK)
- {
+ if (find_directory(B_SYSTEM_DIRECTORY, -1, false, dir, sizeof(dir)) ==
+ B_OK) {
this->InstallPath = dir;
- }
- else
- {
+ } else {
this->InstallPath = "/boot/system";
- }
+ }
#else
this->InstallPath = "/usr/local/";
#endif
@@ -1256,7 +1103,8 @@ const char* cmCPackGenerator::GetInstallPath()
const char* cmCPackGenerator::GetPackagingInstallPrefix()
{
cmCPackLogger(cmCPackLog::LOG_DEBUG, "GetPackagingInstallPrefix: '"
- << this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX") << "'" << std::endl);
+ << this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX") << "'"
+ << std::endl);
return this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX");
}
@@ -1264,47 +1112,42 @@ const char* cmCPackGenerator::GetPackagingInstallPrefix()
std::string cmCPackGenerator::FindTemplate(const char* name)
{
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Look for template: "
- << (name ? name : "(NULL)") << std::endl);
+ << (name ? name : "(NULL)") << std::endl);
std::string ffile = this->MakefileMap->GetModulesFile(name);
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "Found template: "
- << ffile << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_DEBUG, "Found template: " << ffile
+ << std::endl);
return ffile;
}
bool cmCPackGenerator::ConfigureString(const std::string& inString,
- std::string& outString)
+ std::string& outString)
{
- this->MakefileMap->ConfigureString(inString,
- outString, true, false);
+ this->MakefileMap->ConfigureString(inString, outString, true, false);
return true;
}
-bool cmCPackGenerator::ConfigureFile(const char* inName,
- const char* outName, bool copyOnly /* = false */)
+bool cmCPackGenerator::ConfigureFile(const char* inName, const char* outName,
+ bool copyOnly /* = false */)
{
- return this->MakefileMap->ConfigureFile(inName, outName,
- copyOnly, true, false) == 1;
+ return this->MakefileMap->ConfigureFile(inName, outName, copyOnly, true,
+ false) == 1;
}
int cmCPackGenerator::CleanTemporaryDirectory()
{
- std::string tempInstallDirectoryWithPostfix
- = this->GetOption("CPACK_TEMPORARY_INSTALL_DIRECTORY");
+ std::string tempInstallDirectoryWithPostfix =
+ this->GetOption("CPACK_TEMPORARY_INSTALL_DIRECTORY");
const char* tempInstallDirectory = tempInstallDirectoryWithPostfix.c_str();
- if(cmsys::SystemTools::FileExists(tempInstallDirectory))
- {
+ if (cmsys::SystemTools::FileExists(tempInstallDirectory)) {
cmCPackLogger(cmCPackLog::LOG_OUTPUT,
- "- Clean temporary : "
- << tempInstallDirectory << std::endl);
- if(!cmSystemTools::RepeatedRemoveDirectory(tempInstallDirectory))
- {
+ "- Clean temporary : " << tempInstallDirectory << std::endl);
+ if (!cmSystemTools::RepeatedRemoveDirectory(tempInstallDirectory)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Problem removing temporary directory: " <<
- tempInstallDirectory
- << std::endl);
+ "Problem removing temporary directory: "
+ << tempInstallDirectory << std::endl);
return 0;
- }
}
+ }
return 1;
}
@@ -1320,138 +1163,116 @@ int cmCPackGenerator::PrepareGroupingKind()
// find a component package method specified by the user
ComponentPackageMethod method = UNKNOWN_COMPONENT_PACKAGE_METHOD;
- if(this->GetOption("CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE"))
- {
+ if (this->GetOption("CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE")) {
method = ONE_PACKAGE;
- }
+ }
- if(this->GetOption("CPACK_COMPONENTS_IGNORE_GROUPS"))
- {
+ if (this->GetOption("CPACK_COMPONENTS_IGNORE_GROUPS")) {
method = ONE_PACKAGE_PER_COMPONENT;
- }
+ }
- if(this->GetOption("CPACK_COMPONENTS_ONE_PACKAGE_PER_GROUP"))
- {
+ if (this->GetOption("CPACK_COMPONENTS_ONE_PACKAGE_PER_GROUP")) {
method = ONE_PACKAGE_PER_GROUP;
- }
+ }
std::string groupingType;
// Second way to specify grouping
if (NULL != this->GetOption("CPACK_COMPONENTS_GROUPING")) {
- groupingType = this->GetOption("CPACK_COMPONENTS_GROUPING");
+ groupingType = this->GetOption("CPACK_COMPONENTS_GROUPING");
}
- if (!groupingType.empty())
- {
- cmCPackLogger(cmCPackLog::LOG_VERBOSE, "["
- << this->Name << "]"
- << " requested component grouping = "<< groupingType <<std::endl);
- if (groupingType == "ALL_COMPONENTS_IN_ONE")
- {
+ if (!groupingType.empty()) {
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE, "["
+ << this->Name << "]"
+ << " requested component grouping = " << groupingType
+ << std::endl);
+ if (groupingType == "ALL_COMPONENTS_IN_ONE") {
method = ONE_PACKAGE;
- }
- else if (groupingType == "IGNORE")
- {
+ } else if (groupingType == "IGNORE") {
method = ONE_PACKAGE_PER_COMPONENT;
- }
- else if (groupingType == "ONE_PER_GROUP")
- {
+ } else if (groupingType == "ONE_PER_GROUP") {
method = ONE_PACKAGE_PER_GROUP;
- }
- else
- {
- cmCPackLogger(cmCPackLog::LOG_WARNING, "["
+ } else {
+ cmCPackLogger(
+ cmCPackLog::LOG_WARNING, "["
<< this->Name << "]"
- << " requested component grouping type <"<< groupingType
+ << " requested component grouping type <" << groupingType
<< "> UNKNOWN not in (ALL_COMPONENTS_IN_ONE,IGNORE,ONE_PER_GROUP)"
<< std::endl);
- }
}
+ }
// Some components were defined but NO group
// fallback to default if not group based
- if(method == ONE_PACKAGE_PER_GROUP &&
- this->ComponentGroups.empty() && !this->Components.empty())
- {
- if(componentPackageMethod == ONE_PACKAGE)
- {
+ if (method == ONE_PACKAGE_PER_GROUP && this->ComponentGroups.empty() &&
+ !this->Components.empty()) {
+ if (componentPackageMethod == ONE_PACKAGE) {
method = ONE_PACKAGE;
- }
- else
- {
+ } else {
method = ONE_PACKAGE_PER_COMPONENT;
- }
- cmCPackLogger(cmCPackLog::LOG_WARNING, "["
- << this->Name << "]"
- << " One package per component group requested, "
- << "but NO component groups exist: Ignoring component group."
- << std::endl);
}
+ cmCPackLogger(
+ cmCPackLog::LOG_WARNING, "["
+ << this->Name << "]"
+ << " One package per component group requested, "
+ << "but NO component groups exist: Ignoring component group."
+ << std::endl);
+ }
// if user specified packaging method, override the default packaging method
- if(method != UNKNOWN_COMPONENT_PACKAGE_METHOD)
- {
+ if (method != UNKNOWN_COMPONENT_PACKAGE_METHOD) {
componentPackageMethod = method;
- }
+ }
- const char* method_names[] =
- {
- "ALL_COMPONENTS_IN_ONE",
- "IGNORE_GROUPS",
- "ONE_PER_GROUP"
- };
+ const char* method_names[] = { "ALL_COMPONENTS_IN_ONE", "IGNORE_GROUPS",
+ "ONE_PER_GROUP" };
- cmCPackLogger(cmCPackLog::LOG_VERBOSE, "["
- << this->Name << "]"
- << " requested component grouping = "
- << method_names[componentPackageMethod]
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE, "["
+ << this->Name << "]"
+ << " requested component grouping = "
+ << method_names[componentPackageMethod] << std::endl);
return 1;
}
std::string cmCPackGenerator::GetComponentInstallDirNameSuffix(
- const std::string& componentName) {
+ const std::string& componentName)
+{
return componentName;
}
std::string cmCPackGenerator::GetComponentPackageFileName(
- const std::string& initialPackageFileName,
- const std::string& groupOrComponentName,
- bool isGroupName) {
+ const std::string& initialPackageFileName,
+ const std::string& groupOrComponentName, bool isGroupName)
+{
/*
* the default behavior is to use the
* component [group] name as a suffix
*/
- std::string suffix="-"+groupOrComponentName;
+ std::string suffix = "-" + groupOrComponentName;
/* check if we should use DISPLAY name */
- std::string dispNameVar = "CPACK_"+Name+"_USE_DISPLAY_NAME_IN_FILENAME";
- if (IsOn(dispNameVar))
- {
+ std::string dispNameVar = "CPACK_" + Name + "_USE_DISPLAY_NAME_IN_FILENAME";
+ if (IsOn(dispNameVar)) {
/* the component Group case */
- if (isGroupName)
- {
- std::string groupDispVar = "CPACK_COMPONENT_GROUP_"
- + cmSystemTools::UpperCase(groupOrComponentName) + "_DISPLAY_NAME";
+ if (isGroupName) {
+ std::string groupDispVar = "CPACK_COMPONENT_GROUP_" +
+ cmSystemTools::UpperCase(groupOrComponentName) + "_DISPLAY_NAME";
const char* groupDispName = GetOption(groupDispVar);
- if (groupDispName)
- {
- suffix = "-"+std::string(groupDispName);
- }
+ if (groupDispName) {
+ suffix = "-" + std::string(groupDispName);
}
+ }
/* the [single] component case */
- else
- {
- std::string dispVar = "CPACK_COMPONENT_"
- + cmSystemTools::UpperCase(groupOrComponentName) + "_DISPLAY_NAME";
- const char* dispName = GetOption(dispVar);
- if(dispName)
- {
- suffix = "-"+std::string(dispName);
- }
- }
+ else {
+ std::string dispVar = "CPACK_COMPONENT_" +
+ cmSystemTools::UpperCase(groupOrComponentName) + "_DISPLAY_NAME";
+ const char* dispName = GetOption(dispVar);
+ if (dispName) {
+ suffix = "-" + std::string(dispName);
}
+ }
+ }
return initialPackageFileName + suffix;
}
@@ -1473,183 +1294,137 @@ bool cmCPackGenerator::SupportsComponentInstallation() const
bool cmCPackGenerator::WantsComponentInstallation() const
{
- return (!IsOn("CPACK_MONOLITHIC_INSTALL")
- && SupportsComponentInstallation()
- // check that we have at least one group or component
- && (!this->ComponentGroups.empty() || !this->Components.empty()));
+ return (!IsOn("CPACK_MONOLITHIC_INSTALL") && SupportsComponentInstallation()
+ // check that we have at least one group or component
+ && (!this->ComponentGroups.empty() || !this->Components.empty()));
}
-cmCPackInstallationType*
-cmCPackGenerator::GetInstallationType(const std::string& projectName,
- const std::string& name)
+cmCPackInstallationType* cmCPackGenerator::GetInstallationType(
+ const std::string& projectName, const std::string& name)
{
- (void) projectName;
+ (void)projectName;
bool hasInstallationType = this->InstallationTypes.count(name) != 0;
- cmCPackInstallationType *installType = &this->InstallationTypes[name];
- if (!hasInstallationType)
- {
+ cmCPackInstallationType* installType = &this->InstallationTypes[name];
+ if (!hasInstallationType) {
// Define the installation type
- std::string macroPrefix = "CPACK_INSTALL_TYPE_"
- + cmsys::SystemTools::UpperCase(name);
+ std::string macroPrefix =
+ "CPACK_INSTALL_TYPE_" + cmsys::SystemTools::UpperCase(name);
installType->Name = name;
- const char* displayName
- = this->GetOption(macroPrefix + "_DISPLAY_NAME");
- if (displayName && *displayName)
- {
+ const char* displayName = this->GetOption(macroPrefix + "_DISPLAY_NAME");
+ if (displayName && *displayName) {
installType->DisplayName = displayName;
- }
- else
- {
+ } else {
installType->DisplayName = installType->Name;
- }
-
- installType->Index = static_cast<unsigned>(
- this->InstallationTypes.size());
}
+
+ installType->Index = static_cast<unsigned>(this->InstallationTypes.size());
+ }
return installType;
}
-cmCPackComponent*
-cmCPackGenerator::GetComponent(const std::string& projectName,
- const std::string& name)
+cmCPackComponent* cmCPackGenerator::GetComponent(
+ const std::string& projectName, const std::string& name)
{
bool hasComponent = this->Components.count(name) != 0;
- cmCPackComponent *component = &this->Components[name];
- if (!hasComponent)
- {
+ cmCPackComponent* component = &this->Components[name];
+ if (!hasComponent) {
// Define the component
- std::string macroPrefix = "CPACK_COMPONENT_"
- + cmsys::SystemTools::UpperCase(name);
+ std::string macroPrefix =
+ "CPACK_COMPONENT_" + cmsys::SystemTools::UpperCase(name);
component->Name = name;
- const char* displayName
- = this->GetOption(macroPrefix + "_DISPLAY_NAME");
- if (displayName && *displayName)
- {
+ const char* displayName = this->GetOption(macroPrefix + "_DISPLAY_NAME");
+ if (displayName && *displayName) {
component->DisplayName = displayName;
- }
- else
- {
+ } else {
component->DisplayName = component->Name;
- }
- component->IsHidden
- = this->IsOn(macroPrefix + "_HIDDEN");
- component->IsRequired
- = this->IsOn(macroPrefix + "_REQUIRED");
- component->IsDisabledByDefault
- = this->IsOn(macroPrefix + "_DISABLED");
- component->IsDownloaded
- = this->IsOn(macroPrefix + "_DOWNLOADED")
- || cmSystemTools::IsOn(this->GetOption("CPACK_DOWNLOAD_ALL"));
-
- const char* archiveFile = this->GetOption(macroPrefix +
- "_ARCHIVE_FILE");
- if (archiveFile && *archiveFile)
- {
+ }
+ component->IsHidden = this->IsOn(macroPrefix + "_HIDDEN");
+ component->IsRequired = this->IsOn(macroPrefix + "_REQUIRED");
+ component->IsDisabledByDefault = this->IsOn(macroPrefix + "_DISABLED");
+ component->IsDownloaded = this->IsOn(macroPrefix + "_DOWNLOADED") ||
+ cmSystemTools::IsOn(this->GetOption("CPACK_DOWNLOAD_ALL"));
+
+ const char* archiveFile = this->GetOption(macroPrefix + "_ARCHIVE_FILE");
+ if (archiveFile && *archiveFile) {
component->ArchiveFile = archiveFile;
- }
+ }
const char* groupName = this->GetOption(macroPrefix + "_GROUP");
- if (groupName && *groupName)
- {
+ if (groupName && *groupName) {
component->Group = GetComponentGroup(projectName, groupName);
component->Group->Components.push_back(component);
- }
- else
- {
+ } else {
component->Group = 0;
- }
+ }
- const char* description
- = this->GetOption(macroPrefix + "_DESCRIPTION");
- if (description && *description)
- {
+ const char* description = this->GetOption(macroPrefix + "_DESCRIPTION");
+ if (description && *description) {
component->Description = description;
- }
+ }
// Determine the installation types.
- const char *installTypes
- = this->GetOption(macroPrefix + "_INSTALL_TYPES");
- if (installTypes && *installTypes)
- {
+ const char* installTypes = this->GetOption(macroPrefix + "_INSTALL_TYPES");
+ if (installTypes && *installTypes) {
std::vector<std::string> installTypesVector;
cmSystemTools::ExpandListArgument(installTypes, installTypesVector);
std::vector<std::string>::iterator installTypesIt;
for (installTypesIt = installTypesVector.begin();
- installTypesIt != installTypesVector.end();
- ++installTypesIt)
- {
+ installTypesIt != installTypesVector.end(); ++installTypesIt) {
component->InstallationTypes.push_back(
this->GetInstallationType(projectName, *installTypesIt));
- }
}
+ }
// Determine the component dependencies.
- const char *depends = this->GetOption(macroPrefix + "_DEPENDS");
- if (depends && *depends)
- {
+ const char* depends = this->GetOption(macroPrefix + "_DEPENDS");
+ if (depends && *depends) {
std::vector<std::string> dependsVector;
cmSystemTools::ExpandListArgument(depends, dependsVector);
std::vector<std::string>::iterator dependIt;
- for (dependIt = dependsVector.begin();
- dependIt != dependsVector.end();
- ++dependIt)
- {
- cmCPackComponent *child = GetComponent(projectName,
- *dependIt);
+ for (dependIt = dependsVector.begin(); dependIt != dependsVector.end();
+ ++dependIt) {
+ cmCPackComponent* child = GetComponent(projectName, *dependIt);
component->Dependencies.push_back(child);
child->ReverseDependencies.push_back(component);
- }
}
}
+ }
return component;
}
-cmCPackComponentGroup*
-cmCPackGenerator::GetComponentGroup(const std::string& projectName,
- const std::string& name)
+cmCPackComponentGroup* cmCPackGenerator::GetComponentGroup(
+ const std::string& projectName, const std::string& name)
{
- (void) projectName;
- std::string macroPrefix = "CPACK_COMPONENT_GROUP_"
- + cmsys::SystemTools::UpperCase(name);
+ (void)projectName;
+ std::string macroPrefix =
+ "CPACK_COMPONENT_GROUP_" + cmsys::SystemTools::UpperCase(name);
bool hasGroup = this->ComponentGroups.count(name) != 0;
- cmCPackComponentGroup *group = &this->ComponentGroups[name];
- if (!hasGroup)
- {
+ cmCPackComponentGroup* group = &this->ComponentGroups[name];
+ if (!hasGroup) {
// Define the group
group->Name = name;
- const char* displayName
- = this->GetOption(macroPrefix + "_DISPLAY_NAME");
- if (displayName && *displayName)
- {
+ const char* displayName = this->GetOption(macroPrefix + "_DISPLAY_NAME");
+ if (displayName && *displayName) {
group->DisplayName = displayName;
- }
- else
- {
+ } else {
group->DisplayName = group->Name;
- }
+ }
- const char* description
- = this->GetOption(macroPrefix + "_DESCRIPTION");
- if (description && *description)
- {
+ const char* description = this->GetOption(macroPrefix + "_DESCRIPTION");
+ if (description && *description) {
group->Description = description;
- }
- group->IsBold
- = this->IsOn(macroPrefix + "_BOLD_TITLE");
- group->IsExpandedByDefault
- = this->IsOn(macroPrefix + "_EXPANDED");
- const char* parentGroupName
- = this->GetOption(macroPrefix + "_PARENT_GROUP");
- if (parentGroupName && *parentGroupName)
- {
+ }
+ group->IsBold = this->IsOn(macroPrefix + "_BOLD_TITLE");
+ group->IsExpandedByDefault = this->IsOn(macroPrefix + "_EXPANDED");
+ const char* parentGroupName =
+ this->GetOption(macroPrefix + "_PARENT_GROUP");
+ if (parentGroupName && *parentGroupName) {
group->ParentGroup = GetComponentGroup(projectName, parentGroupName);
group->ParentGroup->Subgroups.push_back(group);
- }
- else
- {
+ } else {
group->ParentGroup = 0;
- }
}
+ }
return group;
}
diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h
index 3a53d05..ce93715 100644
--- a/Source/CPack/cmCPackGenerator.h
+++ b/Source/CPack/cmCPackGenerator.h
@@ -20,29 +20,29 @@
#include <vector>
#include "cmCPackComponentGroup.h" // cmCPackComponent and friends
- // Forward declarations are insufficient since we use them in
- // std::map data members below...
+// Forward declarations are insufficient since we use them in
+// std::map data members below...
-#define cmCPackTypeMacro(klass, superclass) \
- cmTypeMacro(klass, superclass); \
- static cmCPackGenerator* CreateGenerator() { return new klass; } \
+#define cmCPackTypeMacro(klass, superclass) \
+ cmTypeMacro(klass, superclass); \
+ 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 ( 0 )
+#define cmCPackLogger(logType, msg) \
+ do { \
+ std::ostringstream cmCPackLog_msg; \
+ cmCPackLog_msg << msg; \
+ this->Logger->Log(logType, __FILE__, __LINE__, \
+ cmCPackLog_msg.str().c_str()); \
+ } while (0)
#ifdef cerr
-# undef cerr
+#undef cerr
#endif
#define cerr no_cerr_use_cmCPack_Log
#ifdef cout
-# undef cout
+#undef cout
#endif
#define cout no_cout_use_cmCPack_Log
@@ -62,8 +62,10 @@ public:
* If verbose then more information is printed out
*/
void SetVerbose(bool val)
- { this->GeneratorVerbose = val ?
- cmSystemTools::OUTPUT_MERGE : cmSystemTools::OUTPUT_NONE; }
+ {
+ this->GeneratorVerbose =
+ val ? cmSystemTools::OUTPUT_MERGE : cmSystemTools::OUTPUT_NONE;
+ }
/**
* Returns true if the generator may work on this system.
@@ -157,7 +159,7 @@ protected:
* default is "componentName"
*/
virtual std::string GetComponentInstallDirNameSuffix(
- const std::string& componentName);
+ const std::string& componentName);
/**
* CPack specific generator may mangle CPACK_PACKAGE_FILE_NAME
@@ -169,9 +171,8 @@ protected:
* false otherwise
*/
virtual std::string GetComponentPackageFileName(
- const std::string& initialPackageFileName,
- const std::string& groupOrComponentName,
- bool isGroupName);
+ const std::string& initialPackageFileName,
+ const std::string& groupOrComponentName, bool isGroupName);
/**
* Package the list of files and/or components which
@@ -188,11 +189,10 @@ protected:
virtual std::string FindTemplate(const char* name);
virtual bool ConfigureFile(const char* inName, const char* outName,
- bool copyOnly = false);
+ bool copyOnly = false);
virtual bool ConfigureString(const std::string& input, std::string& output);
virtual int InitializeInternal();
-
//! Run install commands if specified
virtual int InstallProjectViaInstallCommands(
bool setDestDir, const std::string& tempInstallDirectory);
@@ -207,7 +207,8 @@ protected:
* The various level of support of
* CPACK_SET_DESTDIR used by the generator.
*/
- enum CPackSetDestdirSupport {
+ enum CPackSetDestdirSupport
+ {
/* the generator works with or without it */
SETDESTDIR_SUPPORTED,
/* the generator works best if automatically handled */
@@ -251,13 +252,11 @@ protected:
*/
virtual bool WantsComponentInstallation() const;
virtual cmCPackInstallationType* GetInstallationType(
- const std::string& projectName,
- const std::string& name);
+ const std::string& projectName, const std::string& name);
virtual cmCPackComponent* GetComponent(const std::string& projectName,
const std::string& name);
virtual cmCPackComponentGroup* GetComponentGroup(
- const std::string& projectName,
- const std::string& name);
+ const std::string& projectName, const std::string& name);
cmSystemTools::OutputOption GeneratorVerbose;
std::string Name;
@@ -324,6 +323,7 @@ protected:
ComponentPackageMethod componentPackageMethod;
cmCPackLog* Logger;
+
private:
cmMakefile* MakefileMap;
};
diff --git a/Source/CPack/cmCPackGeneratorFactory.cxx b/Source/CPack/cmCPackGeneratorFactory.cxx
index 5a63dbc..b17f52e 100644
--- a/Source/CPack/cmCPackGeneratorFactory.cxx
+++ b/Source/CPack/cmCPackGeneratorFactory.cxx
@@ -24,134 +24,115 @@
#include "cmCPackZIPGenerator.h"
#ifdef __APPLE__
-# include "cmCPackBundleGenerator.h"
-# include "cmCPackDragNDropGenerator.h"
-# include "cmCPackOSXX11Generator.h"
-# include "cmCPackPackageMakerGenerator.h"
+#include "cmCPackBundleGenerator.h"
+#include "cmCPackDragNDropGenerator.h"
+#include "cmCPackOSXX11Generator.h"
+#include "cmCPackPackageMakerGenerator.h"
#endif
#ifdef __CYGWIN__
-# include "cmCPackCygwinBinaryGenerator.h"
-# include "cmCPackCygwinSourceGenerator.h"
+#include "cmCPackCygwinBinaryGenerator.h"
+#include "cmCPackCygwinSourceGenerator.h"
#endif
-#if !defined(_WIN32) \
- && !defined(__QNXNTO__) && !defined(__BEOS__) && !defined(__HAIKU__)
-# include "cmCPackDebGenerator.h"
-# include "cmCPackRPMGenerator.h"
+#if !defined(_WIN32) && !defined(__QNXNTO__) && !defined(__BEOS__) && \
+ !defined(__HAIKU__)
+#include "cmCPackDebGenerator.h"
+#include "cmCPackRPMGenerator.h"
#endif
#ifdef _WIN32
-# include "WiX/cmCPackWIXGenerator.h"
+#include "WiX/cmCPackWIXGenerator.h"
#endif
#include "cmAlgorithms.h"
#include "cmCPackLog.h"
-
cmCPackGeneratorFactory::cmCPackGeneratorFactory()
{
- if (cmCPackTGZGenerator::CanGenerate())
- {
+ if (cmCPackTGZGenerator::CanGenerate()) {
this->RegisterGenerator("TGZ", "Tar GZip compression",
- cmCPackTGZGenerator::CreateGenerator);
- }
- if (cmCPackTXZGenerator::CanGenerate())
- {
+ cmCPackTGZGenerator::CreateGenerator);
+ }
+ if (cmCPackTXZGenerator::CanGenerate()) {
this->RegisterGenerator("TXZ", "Tar XZ compression",
- cmCPackTXZGenerator::CreateGenerator);
- }
- if (cmCPackSTGZGenerator::CanGenerate())
- {
+ cmCPackTXZGenerator::CreateGenerator);
+ }
+ if (cmCPackSTGZGenerator::CanGenerate()) {
this->RegisterGenerator("STGZ", "Self extracting Tar GZip compression",
- cmCPackSTGZGenerator::CreateGenerator);
- }
- if (cmCPackNSISGenerator::CanGenerate())
- {
+ cmCPackSTGZGenerator::CreateGenerator);
+ }
+ if (cmCPackNSISGenerator::CanGenerate()) {
this->RegisterGenerator("NSIS", "Null Soft Installer",
- cmCPackNSISGenerator::CreateGenerator);
+ cmCPackNSISGenerator::CreateGenerator);
this->RegisterGenerator("NSIS64", "Null Soft Installer (64-bit)",
- cmCPackNSISGenerator::CreateGenerator64);
- }
- if (cmCPackIFWGenerator::CanGenerate())
- {
+ cmCPackNSISGenerator::CreateGenerator64);
+ }
+ if (cmCPackIFWGenerator::CanGenerate()) {
this->RegisterGenerator("IFW", "Qt Installer Framework",
- cmCPackIFWGenerator::CreateGenerator);
- }
+ cmCPackIFWGenerator::CreateGenerator);
+ }
#ifdef __CYGWIN__
- if (cmCPackCygwinBinaryGenerator::CanGenerate())
- {
+ if (cmCPackCygwinBinaryGenerator::CanGenerate()) {
this->RegisterGenerator("CygwinBinary", "Cygwin Binary Installer",
cmCPackCygwinBinaryGenerator::CreateGenerator);
- }
- if (cmCPackCygwinSourceGenerator::CanGenerate())
- {
+ }
+ if (cmCPackCygwinSourceGenerator::CanGenerate()) {
this->RegisterGenerator("CygwinSource", "Cygwin Source Installer",
cmCPackCygwinSourceGenerator::CreateGenerator);
- }
+ }
#endif
- if (cmCPackZIPGenerator::CanGenerate())
- {
+ if (cmCPackZIPGenerator::CanGenerate()) {
this->RegisterGenerator("ZIP", "ZIP file format",
- cmCPackZIPGenerator::CreateGenerator);
- }
- if (cmCPack7zGenerator::CanGenerate())
- {
+ cmCPackZIPGenerator::CreateGenerator);
+ }
+ if (cmCPack7zGenerator::CanGenerate()) {
this->RegisterGenerator("7Z", "7-Zip file format",
- cmCPack7zGenerator::CreateGenerator);
- }
+ cmCPack7zGenerator::CreateGenerator);
+ }
#ifdef _WIN32
- if (cmCPackWIXGenerator::CanGenerate())
- {
+ if (cmCPackWIXGenerator::CanGenerate()) {
this->RegisterGenerator("WIX", "MSI file format via WiX tools",
- cmCPackWIXGenerator::CreateGenerator);
- }
+ cmCPackWIXGenerator::CreateGenerator);
+ }
#endif
- if (cmCPackTarBZip2Generator::CanGenerate())
- {
+ if (cmCPackTarBZip2Generator::CanGenerate()) {
this->RegisterGenerator("TBZ2", "Tar BZip2 compression",
- cmCPackTarBZip2Generator::CreateGenerator);
- }
- if (cmCPackTarCompressGenerator::CanGenerate())
- {
+ cmCPackTarBZip2Generator::CreateGenerator);
+ }
+ if (cmCPackTarCompressGenerator::CanGenerate()) {
this->RegisterGenerator("TZ", "Tar Compress compression",
- cmCPackTarCompressGenerator::CreateGenerator);
- }
+ cmCPackTarCompressGenerator::CreateGenerator);
+ }
#ifdef __APPLE__
- if (cmCPackDragNDropGenerator::CanGenerate())
- {
+ if (cmCPackDragNDropGenerator::CanGenerate()) {
this->RegisterGenerator("DragNDrop", "Mac OSX Drag And Drop",
- cmCPackDragNDropGenerator::CreateGenerator);
- }
- if (cmCPackBundleGenerator::CanGenerate())
- {
+ cmCPackDragNDropGenerator::CreateGenerator);
+ }
+ if (cmCPackBundleGenerator::CanGenerate()) {
this->RegisterGenerator("Bundle", "Mac OSX bundle",
- cmCPackBundleGenerator::CreateGenerator);
- }
- if (cmCPackPackageMakerGenerator::CanGenerate())
- {
+ cmCPackBundleGenerator::CreateGenerator);
+ }
+ if (cmCPackPackageMakerGenerator::CanGenerate()) {
this->RegisterGenerator("PackageMaker", "Mac OSX Package Maker installer",
- cmCPackPackageMakerGenerator::CreateGenerator);
- }
- if (cmCPackOSXX11Generator::CanGenerate())
- {
+ cmCPackPackageMakerGenerator::CreateGenerator);
+ }
+ if (cmCPackOSXX11Generator::CanGenerate()) {
this->RegisterGenerator("OSXX11", "Mac OSX X11 bundle",
- cmCPackOSXX11Generator::CreateGenerator);
- }
+ cmCPackOSXX11Generator::CreateGenerator);
+ }
#endif
-#if !defined(_WIN32) \
- && !defined(__QNXNTO__) && !defined(__BEOS__) && !defined(__HAIKU__)
- if (cmCPackDebGenerator::CanGenerate())
- {
+#if !defined(_WIN32) && !defined(__QNXNTO__) && !defined(__BEOS__) && \
+ !defined(__HAIKU__)
+ if (cmCPackDebGenerator::CanGenerate()) {
this->RegisterGenerator("DEB", "Debian packages",
- cmCPackDebGenerator::CreateGenerator);
- }
- if (cmCPackRPMGenerator::CanGenerate())
- {
+ cmCPackDebGenerator::CreateGenerator);
+ }
+ if (cmCPackRPMGenerator::CanGenerate()) {
this->RegisterGenerator("RPM", "RPM packages",
- cmCPackRPMGenerator::CreateGenerator);
- }
+ cmCPackRPMGenerator::CreateGenerator);
+ }
#endif
}
@@ -161,13 +142,12 @@ cmCPackGeneratorFactory::~cmCPackGeneratorFactory()
}
cmCPackGenerator* cmCPackGeneratorFactory::NewGenerator(
- const std::string& name)
+ const std::string& name)
{
cmCPackGenerator* gen = this->NewGeneratorInternal(name);
- if ( !gen )
- {
+ if (!gen) {
return 0;
- }
+ }
this->Generators.push_back(gen);
gen->SetLogger(this->Logger);
return gen;
@@ -176,25 +156,23 @@ cmCPackGenerator* cmCPackGeneratorFactory::NewGenerator(
cmCPackGenerator* cmCPackGeneratorFactory::NewGeneratorInternal(
const std::string& name)
{
- cmCPackGeneratorFactory::t_GeneratorCreatorsMap::iterator it
- = this->GeneratorCreators.find(name);
- if ( it == this->GeneratorCreators.end() )
- {
+ cmCPackGeneratorFactory::t_GeneratorCreatorsMap::iterator it =
+ this->GeneratorCreators.find(name);
+ if (it == this->GeneratorCreators.end()) {
return 0;
- }
+ }
return (it->second)();
}
-void cmCPackGeneratorFactory::RegisterGenerator(const std::string& name,
- const char* generatorDescription,
+void cmCPackGeneratorFactory::RegisterGenerator(
+ const std::string& name, const char* generatorDescription,
CreateGeneratorCall* createGenerator)
{
- if ( !createGenerator )
- {
+ if (!createGenerator) {
cmCPack_Log(this->Logger, cmCPackLog::LOG_ERROR,
- "Cannot register generator" << std::endl);
+ "Cannot register generator" << std::endl);
return;
- }
+ }
this->GeneratorCreators[name] = createGenerator;
this->GeneratorDescriptions[name] = generatorDescription;
}
diff --git a/Source/CPack/cmCPackGeneratorFactory.h b/Source/CPack/cmCPackGeneratorFactory.h
index 010777f..a55ec6e 100644
--- a/Source/CPack/cmCPackGeneratorFactory.h
+++ b/Source/CPack/cmCPackGeneratorFactory.h
@@ -37,14 +37,16 @@ public:
typedef cmCPackGenerator* CreateGeneratorCall();
void RegisterGenerator(const std::string& name,
- const char* generatorDescription,
- CreateGeneratorCall* createGenerator);
+ const char* generatorDescription,
+ CreateGeneratorCall* createGenerator);
void SetLogger(cmCPackLog* logger) { this->Logger = logger; }
typedef std::map<std::string, std::string> DescriptionsMap;
const DescriptionsMap& GetGeneratorsList() const
- { return this->GeneratorDescriptions; }
+ {
+ return this->GeneratorDescriptions;
+ }
private:
cmCPackGenerator* NewGeneratorInternal(const std::string& name);
diff --git a/Source/CPack/cmCPackLog.cxx b/Source/CPack/cmCPackLog.cxx
index 61d97c8..ff06eb8 100644
--- a/Source/CPack/cmCPackLog.cxx
+++ b/Source/CPack/cmCPackLog.cxx
@@ -39,37 +39,33 @@ cmCPackLog::~cmCPackLog()
void cmCPackLog::SetLogOutputStream(std::ostream* os)
{
- if ( this->LogOutputCleanup && this->LogOutput )
- {
+ if (this->LogOutputCleanup && this->LogOutput) {
delete this->LogOutput;
- }
+ }
this->LogOutputCleanup = false;
this->LogOutput = os;
}
bool cmCPackLog::SetLogOutputFile(const char* fname)
{
- cmGeneratedFileStream *cg = 0;
- if ( fname )
- {
+ cmGeneratedFileStream* cg = 0;
+ if (fname) {
cg = new cmGeneratedFileStream(fname);
- }
- if ( cg && !*cg )
- {
+ }
+ if (cg && !*cg) {
delete cg;
cg = 0;
- }
+ }
this->SetLogOutputStream(cg);
- if ( !cg )
- {
+ if (!cg) {
return false;
- }
+ }
this->LogOutputCleanup = true;
return true;
}
-void cmCPackLog::Log(int tag, const char* file, int line,
- const char* msg, size_t length)
+void cmCPackLog::Log(int tag, const char* file, int line, const char* msg,
+ size_t length)
{
// By default no logging
bool display = false;
@@ -77,144 +73,118 @@ void cmCPackLog::Log(int tag, const char* file, int line,
// Display file and line number if debug
bool useFileAndLine = this->Debug;
- bool output = false;
- bool debug = false;
+ bool output = false;
+ bool debug = false;
bool warning = false;
- bool error = false;
+ bool error = false;
bool verbose = false;
// When writing in file, add list of tags whenever tag changes.
std::string tagString;
bool needTagString = false;
- if ( this->LogOutput && this->LastTag != tag )
- {
+ if (this->LogOutput && this->LastTag != tag) {
needTagString = true;
- }
+ }
- if ( tag & LOG_OUTPUT )
- {
+ if (tag & LOG_OUTPUT) {
output = true;
display = true;
- if ( needTagString )
- {
- if (!tagString.empty()) { tagString += ","; }
- tagString = "VERBOSE";
+ if (needTagString) {
+ if (!tagString.empty()) {
+ tagString += ",";
}
+ tagString = "VERBOSE";
}
- if ( tag & LOG_WARNING )
- {
+ }
+ if (tag & LOG_WARNING) {
warning = true;
display = true;
- if ( needTagString )
- {
- if (!tagString.empty()) { tagString += ","; }
- tagString = "WARNING";
+ if (needTagString) {
+ if (!tagString.empty()) {
+ tagString += ",";
}
+ tagString = "WARNING";
}
- if ( tag & LOG_ERROR )
- {
+ }
+ if (tag & LOG_ERROR) {
error = true;
display = true;
- if ( needTagString )
- {
- if (!tagString.empty()) { tagString += ","; }
- tagString = "ERROR";
+ if (needTagString) {
+ if (!tagString.empty()) {
+ tagString += ",";
}
+ tagString = "ERROR";
}
- if ( tag & LOG_DEBUG && this->Debug )
- {
+ }
+ if (tag & LOG_DEBUG && this->Debug) {
debug = true;
display = true;
- if ( needTagString )
- {
- if (!tagString.empty()) { tagString += ","; }
- tagString = "DEBUG";
+ if (needTagString) {
+ if (!tagString.empty()) {
+ tagString += ",";
}
- useFileAndLine = true;
+ tagString = "DEBUG";
}
- if ( tag & LOG_VERBOSE && this->Verbose )
- {
+ useFileAndLine = true;
+ }
+ if (tag & LOG_VERBOSE && this->Verbose) {
verbose = true;
display = true;
- if ( needTagString )
- {
- if (!tagString.empty()) { tagString += ","; }
- tagString = "VERBOSE";
+ if (needTagString) {
+ if (!tagString.empty()) {
+ tagString += ",";
}
+ tagString = "VERBOSE";
}
- if ( this->Quiet )
- {
+ }
+ if (this->Quiet) {
display = false;
+ }
+ if (this->LogOutput) {
+ if (needTagString) {
+ *this->LogOutput << "[" << file << ":" << line << " " << tagString
+ << "] ";
}
- if ( this->LogOutput )
- {
- if ( needTagString )
- {
- *this->LogOutput << "[" << file << ":" << line << " "
- << tagString << "] ";
- }
this->LogOutput->write(msg, length);
- }
+ }
this->LastTag = tag;
- if ( !display )
- {
+ if (!display) {
return;
- }
- if ( this->NewLine )
- {
- if ( error && !this->ErrorPrefix.empty() )
- {
+ }
+ if (this->NewLine) {
+ if (error && !this->ErrorPrefix.empty()) {
*this->DefaultError << this->ErrorPrefix;
- }
- else if ( warning && !this->WarningPrefix.empty() )
- {
+ } else if (warning && !this->WarningPrefix.empty()) {
*this->DefaultError << this->WarningPrefix;
- }
- else if ( output && !this->OutputPrefix.empty() )
- {
+ } else if (output && !this->OutputPrefix.empty()) {
*this->DefaultOutput << this->OutputPrefix;
- }
- else if ( verbose && !this->VerbosePrefix.empty() )
- {
+ } else if (verbose && !this->VerbosePrefix.empty()) {
*this->DefaultOutput << this->VerbosePrefix;
- }
- else if ( debug && !this->DebugPrefix.empty() )
- {
+ } else if (debug && !this->DebugPrefix.empty()) {
*this->DefaultOutput << this->DebugPrefix;
- }
- else if ( !this->Prefix.empty() )
- {
+ } else if (!this->Prefix.empty()) {
*this->DefaultOutput << this->Prefix;
- }
- if ( useFileAndLine )
- {
- if ( error || warning )
- {
+ }
+ if (useFileAndLine) {
+ if (error || warning) {
*this->DefaultError << file << ":" << line << " ";
- }
- else
- {
+ } else {
*this->DefaultOutput << file << ":" << line << " ";
- }
}
}
- if ( error || warning )
- {
+ }
+ if (error || warning) {
this->DefaultError->write(msg, length);
this->DefaultError->flush();
- }
- else
- {
+ } else {
this->DefaultOutput->write(msg, length);
this->DefaultOutput->flush();
- }
- if ( msg[length-1] == '\n' || length > 2 )
- {
+ }
+ if (msg[length - 1] == '\n' || length > 2) {
this->NewLine = true;
- }
+ }
- if ( error )
- {
+ if (error) {
cmSystemTools::SetErrorOccured();
- }
+ }
}
diff --git a/Source/CPack/cmCPackLog.h b/Source/CPack/cmCPackLog.h
index 7a7ff58..41871cc 100644
--- a/Source/CPack/cmCPackLog.h
+++ b/Source/CPack/cmCPackLog.h
@@ -15,24 +15,23 @@
#include "cmObject.h"
-#define cmCPack_Log(ctSelf, logType, msg) \
- do { \
- std::ostringstream cmCPackLog_msg; \
- cmCPackLog_msg << msg; \
- (ctSelf)->Log(logType, __FILE__, __LINE__, cmCPackLog_msg.str().c_str());\
- } while ( 0 )
+#define cmCPack_Log(ctSelf, logType, msg) \
+ do { \
+ std::ostringstream cmCPackLog_msg; \
+ cmCPackLog_msg << msg; \
+ (ctSelf)->Log(logType, __FILE__, __LINE__, cmCPackLog_msg.str().c_str()); \
+ } while (0)
#ifdef cerr
-# undef cerr
+#undef cerr
#endif
#define cerr no_cerr_use_cmCPack_Log
#ifdef cout
-# undef cout
+#undef cout
#endif
#define cout no_cout_use_cmCPack_Log
-
/** \class cmCPackLog
* \brief A container for CPack generators
*
@@ -45,7 +44,8 @@ public:
cmCPackLog();
~cmCPackLog();
- enum __log_tags {
+ enum __log_tags
+ {
NOTAG = 0,
LOG_OUTPUT = 0x1,
LOG_VERBOSE = 0x2,
@@ -56,19 +56,19 @@ public:
//! Various signatures for logging.
void Log(const char* file, int line, const char* msg)
- {
+ {
this->Log(LOG_OUTPUT, file, line, msg);
- }
+ }
void Log(const char* file, int line, const char* msg, size_t length)
- {
+ {
this->Log(LOG_OUTPUT, file, line, msg, length);
- }
+ }
void Log(int tag, const char* file, int line, const char* msg)
- {
+ {
this->Log(tag, file, line, msg, strlen(msg));
- }
+ }
void Log(int tag, const char* file, int line, const char* msg,
- size_t length);
+ size_t length);
//! Set Verbose
void VerboseOn() { this->SetVerbose(true); }
@@ -126,11 +126,11 @@ private:
std::string WarningPrefix;
std::string ErrorPrefix;
- std::ostream *DefaultOutput;
- std::ostream *DefaultError;
+ std::ostream* DefaultOutput;
+ std::ostream* DefaultError;
std::string LogOutputFileName;
- std::ostream *LogOutput;
+ std::ostream* LogOutput;
// Do we need to cleanup log output stream
bool LogOutputCleanup;
};
@@ -139,13 +139,16 @@ class cmCPackLogWrite
{
public:
cmCPackLogWrite(const char* data, size_t length)
- : Data(data), Length(length) {}
+ : Data(data)
+ , Length(length)
+ {
+ }
const char* Data;
size_t Length;
};
-inline std::ostream& operator<< (std::ostream& os, const cmCPackLogWrite& c)
+inline std::ostream& operator<<(std::ostream& os, const cmCPackLogWrite& c)
{
os.write(c.Data, c.Length);
os.flush();
diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx
index 9d6a457..4d48cb5 100644
--- a/Source/CPack/cmCPackNSISGenerator.cxx
+++ b/Source/CPack/cmCPackNSISGenerator.cxx
@@ -26,9 +26,9 @@
/* NSIS uses different command line syntax on Windows and others */
#ifdef _WIN32
-# define NSIS_OPT "/"
+#define NSIS_OPT "/"
#else
-# define NSIS_OPT "-"
+#define NSIS_OPT "-"
#endif
cmCPackNSISGenerator::cmCPackNSISGenerator(bool nsis64)
@@ -45,22 +45,20 @@ int cmCPackNSISGenerator::PackageFiles()
// TODO: Fix nsis to force out file name
std::string nsisInFileName = this->FindTemplate("NSIS.template.in");
- if (nsisInFileName.empty())
- {
+ if (nsisInFileName.empty()) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "CPack error: Could not find NSIS installer template file."
- << std::endl);
+ "CPack error: Could not find NSIS installer template file."
+ << std::endl);
return false;
- }
- std::string nsisInInstallOptions
- = this->FindTemplate("NSIS.InstallOptions.ini.in");
- if (nsisInInstallOptions.empty())
- {
+ }
+ std::string nsisInInstallOptions =
+ this->FindTemplate("NSIS.InstallOptions.ini.in");
+ if (nsisInInstallOptions.empty()) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "CPack error: Could not find NSIS installer options file."
- << std::endl);
+ "CPack error: Could not find NSIS installer options file."
+ << std::endl);
return false;
- }
+ }
std::string nsisFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
std::string tmpFile = nsisFileName;
@@ -69,93 +67,80 @@ int cmCPackNSISGenerator::PackageFiles()
nsisFileName += "/project.nsi";
std::ostringstream str;
std::vector<std::string>::const_iterator it;
- for ( it = files.begin(); it != files.end(); ++ it )
- {
- std::string fileN = cmSystemTools::RelativePath(toplevel.c_str(),
- it->c_str());
- if (!this->Components.empty())
- {
+ for (it = files.begin(); it != files.end(); ++it) {
+ std::string fileN =
+ cmSystemTools::RelativePath(toplevel.c_str(), it->c_str());
+ if (!this->Components.empty()) {
// Strip off the component part of the path.
- fileN = fileN.substr(fileN.find('/')+1, std::string::npos);
- }
+ fileN = fileN.substr(fileN.find('/') + 1, std::string::npos);
+ }
cmSystemTools::ReplaceString(fileN, "/", "\\");
str << " Delete \"$INSTDIR\\" << fileN << "\"" << std::endl;
- }
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Files: "
- << str.str() << std::endl);
+ }
+ cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Files: " << str.str()
+ << std::endl);
this->SetOptionIfNotSet("CPACK_NSIS_DELETE_FILES", str.str().c_str());
std::vector<std::string> dirs;
this->GetListOfSubdirectories(toplevel.c_str(), dirs);
std::vector<std::string>::const_iterator sit;
std::ostringstream dstr;
- for ( sit = dirs.begin(); sit != dirs.end(); ++ sit )
- {
+ for (sit = dirs.begin(); sit != dirs.end(); ++sit) {
std::string componentName;
- std::string fileN = cmSystemTools::RelativePath(toplevel.c_str(),
- sit->c_str());
- if ( fileN.empty() )
- {
+ std::string fileN =
+ cmSystemTools::RelativePath(toplevel.c_str(), sit->c_str());
+ if (fileN.empty()) {
continue;
- }
- if (!Components.empty())
- {
+ }
+ if (!Components.empty()) {
// If this is a component installation, strip off the component
// part of the path.
std::string::size_type slash = fileN.find('/');
- if (slash != std::string::npos)
- {
+ if (slash != std::string::npos) {
// If this is a component installation, determine which component it
// is.
componentName = fileN.substr(0, slash);
// Strip off the component part of the path.
- fileN = fileN.substr(slash+1, std::string::npos);
- }
+ fileN = fileN.substr(slash + 1, std::string::npos);
}
+ }
cmSystemTools::ReplaceString(fileN, "/", "\\");
dstr << " RMDir \"$INSTDIR\\" << fileN << "\"" << std::endl;
- if (!componentName.empty())
- {
+ if (!componentName.empty()) {
this->Components[componentName].Directories.push_back(fileN);
- }
}
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Dirs: "
- << dstr.str() << std::endl);
- this->SetOptionIfNotSet("CPACK_NSIS_DELETE_DIRECTORIES",
- dstr.str().c_str());
-
- cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: " << nsisInFileName
- << " to " << nsisFileName << std::endl);
- if(this->IsSet("CPACK_NSIS_MUI_ICON")
- || this->IsSet("CPACK_NSIS_MUI_UNIICON"))
- {
+ }
+ cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Dirs: " << dstr.str()
+ << std::endl);
+ this->SetOptionIfNotSet("CPACK_NSIS_DELETE_DIRECTORIES", dstr.str().c_str());
+
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: "
+ << nsisInFileName << " to " << nsisFileName << std::endl);
+ if (this->IsSet("CPACK_NSIS_MUI_ICON") ||
+ this->IsSet("CPACK_NSIS_MUI_UNIICON")) {
std::string installerIconCode;
- if(this->IsSet("CPACK_NSIS_MUI_ICON"))
- {
+ if (this->IsSet("CPACK_NSIS_MUI_ICON")) {
installerIconCode += "!define MUI_ICON \"";
installerIconCode += this->GetOption("CPACK_NSIS_MUI_ICON");
installerIconCode += "\"\n";
- }
- if(this->IsSet("CPACK_NSIS_MUI_UNIICON"))
- {
+ }
+ if (this->IsSet("CPACK_NSIS_MUI_UNIICON")) {
installerIconCode += "!define MUI_UNICON \"";
installerIconCode += this->GetOption("CPACK_NSIS_MUI_UNIICON");
installerIconCode += "\"\n";
- }
+ }
this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_MUI_ICON_CODE",
installerIconCode.c_str());
- }
- if(this->IsSet("CPACK_PACKAGE_ICON"))
- {
+ }
+ if (this->IsSet("CPACK_PACKAGE_ICON")) {
std::string installerIconCode = "!define MUI_HEADERIMAGE_BITMAP \"";
installerIconCode += this->GetOption("CPACK_PACKAGE_ICON");
installerIconCode += "\"\n";
this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_ICON_CODE",
installerIconCode.c_str());
- }
+ }
- if (this->IsSet("CPACK_NSIS_MUI_WELCOMEFINISHPAGE_BITMAP"))
- {
+ if (this->IsSet("CPACK_NSIS_MUI_WELCOMEFINISHPAGE_BITMAP")) {
std::string installerBitmapCode =
"!define MUI_WELCOMEFINISHPAGE_BITMAP \"";
installerBitmapCode +=
@@ -163,10 +148,9 @@ int cmCPackNSISGenerator::PackageFiles()
installerBitmapCode += "\"\n";
this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_MUI_WELCOMEFINISH_CODE",
installerBitmapCode.c_str());
- }
+ }
- if (this->IsSet("CPACK_NSIS_MUI_UNWELCOMEFINISHPAGE_BITMAP"))
- {
+ if (this->IsSet("CPACK_NSIS_MUI_UNWELCOMEFINISHPAGE_BITMAP")) {
std::string installerBitmapCode =
"!define MUI_UNWELCOMEFINISHPAGE_BITMAP \"";
installerBitmapCode +=
@@ -174,10 +158,9 @@ int cmCPackNSISGenerator::PackageFiles()
installerBitmapCode += "\"\n";
this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_MUI_UNWELCOMEFINISH_CODE",
installerBitmapCode.c_str());
- }
+ }
- if(this->IsSet("CPACK_NSIS_MUI_FINISHPAGE_RUN"))
- {
+ if (this->IsSet("CPACK_NSIS_MUI_FINISHPAGE_RUN")) {
std::string installerRunCode = "!define MUI_FINISHPAGE_RUN \"$INSTDIR\\";
installerRunCode += this->GetOption("CPACK_NSIS_EXECUTABLES_DIRECTORY");
installerRunCode += "\\";
@@ -185,11 +168,10 @@ int cmCPackNSISGenerator::PackageFiles()
installerRunCode += "\"\n";
this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_MUI_FINISHPAGE_RUN_CODE",
installerRunCode.c_str());
- }
+ }
// Setup all of the component sections
- if (this->Components.empty())
- {
+ if (this->Components.empty()) {
this->SetOptionIfNotSet("CPACK_NSIS_INSTALLATION_TYPES", "");
this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_MUI_COMPONENTS_DESC", "");
this->SetOptionIfNotSet("CPACK_NSIS_PAGE_COMPONENTS", "");
@@ -198,9 +180,7 @@ int cmCPackNSISGenerator::PackageFiles()
this->SetOptionIfNotSet("CPACK_NSIS_COMPONENT_SECTIONS", "");
this->SetOptionIfNotSet("CPACK_NSIS_COMPONENT_SECTION_LIST", "");
this->SetOptionIfNotSet("CPACK_NSIS_SECTION_SELECTED_VARS", "");
- }
- else
- {
+ } else {
std::string componentCode;
std::string sectionList;
std::string selectedVarsList;
@@ -213,66 +193,54 @@ int cmCPackNSISGenerator::PackageFiles()
// Create installation types. The order is significant, so we first fill
// in a vector based on the indices, and print them in that order.
- std::vector<cmCPackInstallationType *>
- installTypes(this->InstallationTypes.size());
+ std::vector<cmCPackInstallationType*> installTypes(
+ this->InstallationTypes.size());
std::map<std::string, cmCPackInstallationType>::iterator installTypeIt;
for (installTypeIt = this->InstallationTypes.begin();
- installTypeIt != this->InstallationTypes.end();
- ++installTypeIt)
- {
- installTypes[installTypeIt->second.Index-1] = &installTypeIt->second;
- }
- std::vector<cmCPackInstallationType *>::iterator installTypeIt2;
+ installTypeIt != this->InstallationTypes.end(); ++installTypeIt) {
+ installTypes[installTypeIt->second.Index - 1] = &installTypeIt->second;
+ }
+ std::vector<cmCPackInstallationType*>::iterator installTypeIt2;
for (installTypeIt2 = installTypes.begin();
- installTypeIt2 != installTypes.end();
- ++installTypeIt2)
- {
+ installTypeIt2 != installTypes.end(); ++installTypeIt2) {
installTypesCode += "InstType \"";
installTypesCode += (*installTypeIt2)->DisplayName;
installTypesCode += "\"\n";
- }
+ }
// Create installation groups first
std::map<std::string, cmCPackComponentGroup>::iterator groupIt;
for (groupIt = this->ComponentGroups.begin();
- groupIt != this->ComponentGroups.end();
- ++groupIt)
- {
- if (groupIt->second.ParentGroup == 0)
- {
+ groupIt != this->ComponentGroups.end(); ++groupIt) {
+ if (groupIt->second.ParentGroup == 0) {
componentCode +=
this->CreateComponentGroupDescription(&groupIt->second, macrosOut);
- }
+ }
// Add the group description, if any.
- if (!groupIt->second.Description.empty())
- {
- groupDescriptions += " !insertmacro MUI_DESCRIPTION_TEXT ${"
- + groupIt->first + "} \""
- + this->TranslateNewlines(groupIt->second.Description) + "\"\n";
- }
+ if (!groupIt->second.Description.empty()) {
+ groupDescriptions += " !insertmacro MUI_DESCRIPTION_TEXT ${" +
+ groupIt->first + "} \"" +
+ this->TranslateNewlines(groupIt->second.Description) + "\"\n";
}
+ }
// Create the remaining components, which aren't associated with groups.
std::map<std::string, cmCPackComponent>::iterator compIt;
- for (compIt = this->Components.begin();
- compIt != this->Components.end();
- ++compIt)
- {
- if (compIt->second.Files.empty())
- {
+ for (compIt = this->Components.begin(); compIt != this->Components.end();
+ ++compIt) {
+ if (compIt->second.Files.empty()) {
// NSIS cannot cope with components that have no files.
continue;
- }
+ }
anyDownloadedComponents =
anyDownloadedComponents || compIt->second.IsDownloaded;
- if (!compIt->second.Group)
- {
- componentCode
- += this->CreateComponentDescription(&compIt->second, macrosOut);
- }
+ if (!compIt->second.Group) {
+ componentCode +=
+ this->CreateComponentDescription(&compIt->second, macrosOut);
+ }
// Add this component to the various section lists.
sectionList += " !insertmacro \"${MacroName}\" \"";
@@ -282,41 +250,33 @@ int cmCPackNSISGenerator::PackageFiles()
selectedVarsList += "Var " + compIt->first + "_was_installed\n";
// Add the component description, if any.
- if (!compIt->second.Description.empty())
- {
- componentDescriptions += " !insertmacro MUI_DESCRIPTION_TEXT ${"
- + compIt->first + "} \""
- + this->TranslateNewlines(compIt->second.Description) + "\"\n";
- }
+ if (!compIt->second.Description.empty()) {
+ componentDescriptions += " !insertmacro MUI_DESCRIPTION_TEXT ${" +
+ compIt->first + "} \"" +
+ this->TranslateNewlines(compIt->second.Description) + "\"\n";
}
+ }
componentCode += macrosOut.str();
- if (componentDescriptions.empty() && groupDescriptions.empty())
- {
+ if (componentDescriptions.empty() && groupDescriptions.empty()) {
// Turn off the "Description" box
this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_MUI_COMPONENTS_DESC",
"!define MUI_COMPONENTSPAGE_NODESC");
- }
- else
- {
- componentDescriptions =
- "!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN\n"
- + componentDescriptions
- + groupDescriptions
- + "!insertmacro MUI_FUNCTION_DESCRIPTION_END\n";
+ } else {
+ componentDescriptions = "!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN\n" +
+ componentDescriptions + groupDescriptions +
+ "!insertmacro MUI_FUNCTION_DESCRIPTION_END\n";
this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_MUI_COMPONENTS_DESC",
componentDescriptions.c_str());
- }
+ }
- if (anyDownloadedComponents)
- {
+ if (anyDownloadedComponents) {
defines += "!define CPACK_USES_DOWNLOAD\n";
- if (cmSystemTools::IsOn(this->GetOption("CPACK_ADD_REMOVE")))
- {
+ if (cmSystemTools::IsOn(this->GetOption("CPACK_ADD_REMOVE"))) {
defines += "!define CPACK_NSIS_ADD_REMOVE\n";
- }
}
+ }
this->SetOptionIfNotSet("CPACK_NSIS_INSTALLATION_TYPES",
installTypesCode.c_str());
@@ -330,7 +290,7 @@ int cmCPackNSISGenerator::PackageFiles()
this->SetOptionIfNotSet("CPACK_NSIS_SECTION_SELECTED_VARS",
selectedVarsList.c_str());
this->SetOption("CPACK_NSIS_DEFINES", defines.c_str());
- }
+ }
this->ConfigureFile(nsisInInstallOptions.c_str(),
nsisInstallOptions.c_str());
@@ -338,350 +298,308 @@ int cmCPackNSISGenerator::PackageFiles()
std::string nsisCmd = "\"";
nsisCmd += this->GetOption("CPACK_INSTALLER_PROGRAM");
nsisCmd += "\" \"" + nsisFileName + "\"";
- cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << nsisCmd
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << nsisCmd << std::endl);
std::string output;
int retVal = 1;
- bool res = cmSystemTools::RunSingleCommand(nsisCmd.c_str(), &output, &output,
- &retVal, 0, this->GeneratorVerbose, 0);
- if ( !res || retVal )
- {
+ bool res = cmSystemTools::RunSingleCommand(
+ nsisCmd.c_str(), &output, &output, &retVal, 0, this->GeneratorVerbose, 0);
+ if (!res || retVal) {
cmGeneratedFileStream ofs(tmpFile.c_str());
ofs << "# Run command: " << nsisCmd << std::endl
- << "# Output:" << std::endl
- << output << std::endl;
+ << "# Output:" << std::endl
+ << output << std::endl;
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running NSIS command: "
- << nsisCmd << std::endl
- << "Please check " << tmpFile << " for errors" << std::endl);
+ << nsisCmd << std::endl
+ << "Please check " << tmpFile << " for errors"
+ << std::endl);
return 0;
- }
+ }
return 1;
}
int cmCPackNSISGenerator::InitializeInternal()
{
- if ( cmSystemTools::IsOn(this->GetOption(
- "CPACK_INCLUDE_TOPLEVEL_DIRECTORY")) )
- {
- cmCPackLogger(cmCPackLog::LOG_WARNING,
+ if (cmSystemTools::IsOn(
+ this->GetOption("CPACK_INCLUDE_TOPLEVEL_DIRECTORY"))) {
+ cmCPackLogger(
+ cmCPackLog::LOG_WARNING,
"NSIS Generator cannot work with CPACK_INCLUDE_TOPLEVEL_DIRECTORY set. "
"This option will be reset to 0 (for this generator only)."
- << std::endl);
+ << std::endl);
this->SetOption("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", 0);
- }
+ }
cmCPackLogger(cmCPackLog::LOG_DEBUG, "cmCPackNSISGenerator::Initialize()"
- << std::endl);
+ << std::endl);
std::vector<std::string> path;
std::string nsisPath;
bool gotRegValue = false;
#ifdef _WIN32
- if (Nsis64)
- {
- if ( !gotRegValue && cmsys::SystemTools::ReadRegistryValue(
- "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS\\Unicode", nsisPath,
- cmsys::SystemTools::KeyWOW64_64) )
- {
+ if (Nsis64) {
+ if (!gotRegValue && cmsys::SystemTools::ReadRegistryValue(
+ "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS\\Unicode",
+ nsisPath, cmsys::SystemTools::KeyWOW64_64)) {
gotRegValue = true;
- }
- if ( !gotRegValue && cmsys::SystemTools::ReadRegistryValue(
- "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS", nsisPath,
- cmsys::SystemTools::KeyWOW64_64) )
- {
+ }
+ if (!gotRegValue && cmsys::SystemTools::ReadRegistryValue(
+ "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS", nsisPath,
+ cmsys::SystemTools::KeyWOW64_64)) {
gotRegValue = true;
- }
}
- if ( !gotRegValue && cmsys::SystemTools::ReadRegistryValue(
- "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS\\Unicode", nsisPath,
- cmsys::SystemTools::KeyWOW64_32) )
- {
+ }
+ if (!gotRegValue && cmsys::SystemTools::ReadRegistryValue(
+ "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS\\Unicode",
+ nsisPath, cmsys::SystemTools::KeyWOW64_32)) {
gotRegValue = true;
- }
- if ( !gotRegValue && cmsys::SystemTools::ReadRegistryValue(
- "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS\\Unicode", nsisPath) )
- {
+ }
+ if (!gotRegValue &&
+ cmsys::SystemTools::ReadRegistryValue(
+ "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS\\Unicode", nsisPath)) {
gotRegValue = true;
- }
- if ( !gotRegValue && cmsys::SystemTools::ReadRegistryValue(
- "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS", nsisPath,
- cmsys::SystemTools::KeyWOW64_32) )
- {
+ }
+ if (!gotRegValue && cmsys::SystemTools::ReadRegistryValue(
+ "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS", nsisPath,
+ cmsys::SystemTools::KeyWOW64_32)) {
gotRegValue = true;
- }
- if ( !gotRegValue && cmsys::SystemTools::ReadRegistryValue(
- "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS", nsisPath) )
- {
+ }
+ if (!gotRegValue && cmsys::SystemTools::ReadRegistryValue(
+ "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS", nsisPath)) {
gotRegValue = true;
- }
+ }
- if (gotRegValue)
- {
+ if (gotRegValue) {
path.push_back(nsisPath);
- }
+ }
#endif
nsisPath = cmSystemTools::FindProgram("makensis", path, false);
- if ( nsisPath.empty() )
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
+ if (nsisPath.empty()) {
+ cmCPackLogger(
+ cmCPackLog::LOG_ERROR,
"Cannot find NSIS compiler makensis: likely it is not installed, "
"or not in your PATH"
- << std::endl);
-
- if (!gotRegValue)
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Could not read NSIS registry value. This is usually caused by "
- "NSIS not being installed. Please install NSIS from "
- "http://nsis.sourceforge.net"
- << std::endl);
- }
+ << std::endl);
+
+ if (!gotRegValue) {
+ cmCPackLogger(
+ cmCPackLog::LOG_ERROR,
+ "Could not read NSIS registry value. This is usually caused by "
+ "NSIS not being installed. Please install NSIS from "
+ "http://nsis.sourceforge.net"
+ << std::endl);
+ }
return 0;
- }
+ }
std::string nsisCmd = "\"" + nsisPath + "\" " NSIS_OPT "VERSION";
- cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Test NSIS version: "
- << nsisCmd << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Test NSIS version: " << nsisCmd
+ << std::endl);
std::string output;
int retVal = 1;
bool resS = cmSystemTools::RunSingleCommand(
nsisCmd.c_str(), &output, &output, &retVal, 0, this->GeneratorVerbose, 0);
cmsys::RegularExpression versionRex("v([0-9]+.[0-9]+)");
cmsys::RegularExpression versionRexCVS("v(.*)\\.cvs");
- if ( !resS || retVal ||
- (!versionRex.find(output) && !versionRexCVS.find(output))
- )
- {
+ if (!resS || retVal ||
+ (!versionRex.find(output) && !versionRexCVS.find(output))) {
const char* topDir = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
std::string tmpFile = topDir ? topDir : ".";
tmpFile += "/NSISOutput.log";
cmGeneratedFileStream ofs(tmpFile.c_str());
ofs << "# Run command: " << nsisCmd << std::endl
- << "# Output:" << std::endl
- << output << std::endl;
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Problem checking NSIS version with command: "
- << nsisCmd << std::endl
- << "Please check " << tmpFile << " for errors" << std::endl);
+ << "# Output:" << std::endl
+ << output << std::endl;
+ cmCPackLogger(
+ cmCPackLog::LOG_ERROR, "Problem checking NSIS version with command: "
+ << nsisCmd << std::endl
+ << "Please check " << tmpFile << " for errors" << std::endl);
return 0;
- }
- if ( versionRex.find(output))
- {
+ }
+ if (versionRex.find(output)) {
double nsisVersion = atof(versionRex.match(1).c_str());
double minNSISVersion = 2.09;
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "NSIS Version: "
- << nsisVersion << std::endl);
- if ( nsisVersion < minNSISVersion )
- {
+ cmCPackLogger(cmCPackLog::LOG_DEBUG, "NSIS Version: " << nsisVersion
+ << std::endl);
+ if (nsisVersion < minNSISVersion) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "CPack requires NSIS Version 2.09 or greater. "
- "NSIS found on the system was: "
- << nsisVersion << std::endl);
+ "CPack requires NSIS Version 2.09 or greater. "
+ "NSIS found on the system was: "
+ << nsisVersion << std::endl);
return 0;
- }
}
- if ( versionRexCVS.find(output))
- {
+ }
+ if (versionRexCVS.find(output)) {
// No version check for NSIS cvs build
cmCPackLogger(cmCPackLog::LOG_DEBUG, "NSIS Version: CVS "
- << versionRexCVS.match(1) << std::endl);
- }
+ << versionRexCVS.match(1) << std::endl);
+ }
this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM", nsisPath.c_str());
this->SetOptionIfNotSet("CPACK_NSIS_EXECUTABLES_DIRECTORY", "bin");
- const char* cpackPackageExecutables
- = this->GetOption("CPACK_PACKAGE_EXECUTABLES");
- const char* cpackPackageDeskTopLinks
- = this->GetOption("CPACK_CREATE_DESKTOP_LINKS");
- const char* cpackNsisExecutablesDirectory
- = this->GetOption("CPACK_NSIS_EXECUTABLES_DIRECTORY");
+ const char* cpackPackageExecutables =
+ this->GetOption("CPACK_PACKAGE_EXECUTABLES");
+ const char* cpackPackageDeskTopLinks =
+ this->GetOption("CPACK_CREATE_DESKTOP_LINKS");
+ const char* cpackNsisExecutablesDirectory =
+ this->GetOption("CPACK_NSIS_EXECUTABLES_DIRECTORY");
std::vector<std::string> cpackPackageDesktopLinksVector;
- if(cpackPackageDeskTopLinks)
- {
+ if (cpackPackageDeskTopLinks) {
cmCPackLogger(cmCPackLog::LOG_DEBUG, "CPACK_CREATE_DESKTOP_LINKS: "
- << cpackPackageDeskTopLinks << std::endl);
-
- cmSystemTools::
- ExpandListArgument(cpackPackageDeskTopLinks,
- cpackPackageDesktopLinksVector);
- for(std::vector<std::string>::iterator i =
- cpackPackageDesktopLinksVector.begin(); i !=
- cpackPackageDesktopLinksVector.end(); ++i)
- {
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "CPACK_CREATE_DESKTOP_LINKS: "
- << *i << std::endl);
- }
+ << cpackPackageDeskTopLinks << std::endl);
+
+ cmSystemTools::ExpandListArgument(cpackPackageDeskTopLinks,
+ cpackPackageDesktopLinksVector);
+ for (std::vector<std::string>::iterator i =
+ cpackPackageDesktopLinksVector.begin();
+ i != cpackPackageDesktopLinksVector.end(); ++i) {
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "CPACK_CREATE_DESKTOP_LINKS: " << *i << std::endl);
}
- else
- {
+ } else {
cmCPackLogger(cmCPackLog::LOG_DEBUG, "CPACK_CREATE_DESKTOP_LINKS: "
- << "not set" << std::endl);
- }
+ << "not set" << std::endl);
+ }
std::ostringstream str;
std::ostringstream deleteStr;
- if ( cpackPackageExecutables )
- {
+ if (cpackPackageExecutables) {
cmCPackLogger(cmCPackLog::LOG_DEBUG, "The cpackPackageExecutables: "
- << cpackPackageExecutables << "." << std::endl);
+ << cpackPackageExecutables << "." << std::endl);
std::vector<std::string> cpackPackageExecutablesVector;
cmSystemTools::ExpandListArgument(cpackPackageExecutables,
- cpackPackageExecutablesVector);
- if ( cpackPackageExecutablesVector.size() % 2 != 0 )
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
+ cpackPackageExecutablesVector);
+ if (cpackPackageExecutablesVector.size() % 2 != 0) {
+ cmCPackLogger(
+ cmCPackLog::LOG_ERROR,
"CPACK_PACKAGE_EXECUTABLES should contain pairs of <executable> and "
- "<icon name>." << std::endl);
+ "<icon name>."
+ << std::endl);
return 0;
- }
+ }
std::vector<std::string>::iterator it;
- for ( it = cpackPackageExecutablesVector.begin();
- it != cpackPackageExecutablesVector.end();
- ++it )
- {
+ for (it = cpackPackageExecutablesVector.begin();
+ it != cpackPackageExecutablesVector.end(); ++it) {
std::string execName = *it;
- ++ it;
+ ++it;
std::string linkName = *it;
- str << " CreateShortCut \"$SMPROGRAMS\\$STARTMENU_FOLDER\\"
- << linkName << ".lnk\" \"$INSTDIR\\"
- << cpackNsisExecutablesDirectory << "\\" << execName << ".exe\""
- << std::endl;
+ str << " CreateShortCut \"$SMPROGRAMS\\$STARTMENU_FOLDER\\" << linkName
+ << ".lnk\" \"$INSTDIR\\" << cpackNsisExecutablesDirectory << "\\"
+ << execName << ".exe\"" << std::endl;
deleteStr << " Delete \"$SMPROGRAMS\\$MUI_TEMP\\" << linkName
- << ".lnk\"" << std::endl;
+ << ".lnk\"" << std::endl;
// see if CPACK_CREATE_DESKTOP_LINK_ExeName is on
// if so add a desktop link
- if(!cpackPackageDesktopLinksVector.empty() &&
- std::find(cpackPackageDesktopLinksVector.begin(),
- cpackPackageDesktopLinksVector.end(),
- execName)
- != cpackPackageDesktopLinksVector.end())
- {
+ if (!cpackPackageDesktopLinksVector.empty() &&
+ std::find(cpackPackageDesktopLinksVector.begin(),
+ cpackPackageDesktopLinksVector.end(),
+ execName) != cpackPackageDesktopLinksVector.end()) {
str << " StrCmp \"$INSTALL_DESKTOP\" \"1\" 0 +2\n";
- str << " CreateShortCut \"$DESKTOP\\"
- << linkName << ".lnk\" \"$INSTDIR\\"
- << cpackNsisExecutablesDirectory << "\\" << execName << ".exe\""
- << std::endl;
+ str << " CreateShortCut \"$DESKTOP\\" << linkName
+ << ".lnk\" \"$INSTDIR\\" << cpackNsisExecutablesDirectory << "\\"
+ << execName << ".exe\"" << std::endl;
deleteStr << " StrCmp \"$INSTALL_DESKTOP\" \"1\" 0 +2\n";
- deleteStr << " Delete \"$DESKTOP\\" << linkName
- << ".lnk\"" << std::endl;
- }
+ deleteStr << " Delete \"$DESKTOP\\" << linkName << ".lnk\""
+ << std::endl;
}
}
+ }
this->CreateMenuLinks(str, deleteStr);
this->SetOptionIfNotSet("CPACK_NSIS_CREATE_ICONS", str.str().c_str());
- this->SetOptionIfNotSet("CPACK_NSIS_DELETE_ICONS",
- deleteStr.str().c_str());
+ this->SetOptionIfNotSet("CPACK_NSIS_DELETE_ICONS", deleteStr.str().c_str());
this->SetOptionIfNotSet("CPACK_NSIS_COMPRESSOR", "lzma");
return this->Superclass::InitializeInternal();
}
-void cmCPackNSISGenerator::CreateMenuLinks( std::ostringstream& str,
- std::ostringstream& deleteStr)
+void cmCPackNSISGenerator::CreateMenuLinks(std::ostringstream& str,
+ std::ostringstream& deleteStr)
{
- const char* cpackMenuLinks
- = this->GetOption("CPACK_NSIS_MENU_LINKS");
- if(!cpackMenuLinks)
- {
+ const char* cpackMenuLinks = this->GetOption("CPACK_NSIS_MENU_LINKS");
+ if (!cpackMenuLinks) {
return;
- }
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "The cpackMenuLinks: "
- << cpackMenuLinks << "." << std::endl);
+ }
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "The cpackMenuLinks: " << cpackMenuLinks << "." << std::endl);
std::vector<std::string> cpackMenuLinksVector;
- cmSystemTools::ExpandListArgument(cpackMenuLinks,
- cpackMenuLinksVector);
- if ( cpackMenuLinksVector.size() % 2 != 0 )
- {
+ cmSystemTools::ExpandListArgument(cpackMenuLinks, cpackMenuLinksVector);
+ if (cpackMenuLinksVector.size() % 2 != 0) {
cmCPackLogger(
cmCPackLog::LOG_ERROR,
"CPACK_NSIS_MENU_LINKS should contain pairs of <shortcut target> and "
- "<shortcut label>." << std::endl);
+ "<shortcut label>."
+ << std::endl);
return;
- }
+ }
- static cmsys::RegularExpression
- urlRegex("^(mailto:|(ftps?|https?|news)://).*$");
+ static cmsys::RegularExpression urlRegex(
+ "^(mailto:|(ftps?|https?|news)://).*$");
std::vector<std::string>::iterator it;
- for ( it = cpackMenuLinksVector.begin();
- it != cpackMenuLinksVector.end();
- ++it )
- {
+ for (it = cpackMenuLinksVector.begin(); it != cpackMenuLinksVector.end();
+ ++it) {
std::string sourceName = *it;
const bool url = urlRegex.find(sourceName);
// Convert / to \ in filenames, but not in urls:
//
- if(!url)
- {
+ if (!url) {
cmSystemTools::ReplaceString(sourceName, "/", "\\");
- }
+ }
- ++ it;
+ ++it;
std::string linkName = *it;
- if(!url)
- {
- str << " CreateShortCut \"$SMPROGRAMS\\$STARTMENU_FOLDER\\"
- << linkName << ".lnk\" \"$INSTDIR\\" << sourceName << "\""
- << std::endl;
+ if (!url) {
+ str << " CreateShortCut \"$SMPROGRAMS\\$STARTMENU_FOLDER\\" << linkName
+ << ".lnk\" \"$INSTDIR\\" << sourceName << "\"" << std::endl;
deleteStr << " Delete \"$SMPROGRAMS\\$MUI_TEMP\\" << linkName
<< ".lnk\"" << std::endl;
- }
- else
- {
- str << " WriteINIStr \"$SMPROGRAMS\\$STARTMENU_FOLDER\\"
- << linkName << ".url\" \"InternetShortcut\" \"URL\" \""
- << sourceName << "\""
+ } else {
+ str << " WriteINIStr \"$SMPROGRAMS\\$STARTMENU_FOLDER\\" << linkName
+ << ".url\" \"InternetShortcut\" \"URL\" \"" << sourceName << "\""
<< std::endl;
deleteStr << " Delete \"$SMPROGRAMS\\$MUI_TEMP\\" << linkName
<< ".url\"" << std::endl;
- }
+ }
// see if CPACK_CREATE_DESKTOP_LINK_ExeName is on
// if so add a desktop link
std::string desktop = "CPACK_CREATE_DESKTOP_LINK_";
desktop += linkName;
- if(this->IsSet(desktop))
- {
+ if (this->IsSet(desktop)) {
str << " StrCmp \"$INSTALL_DESKTOP\" \"1\" 0 +2\n";
- str << " CreateShortCut \"$DESKTOP\\"
- << linkName << ".lnk\" \"$INSTDIR\\" << sourceName << "\""
- << std::endl;
+ str << " CreateShortCut \"$DESKTOP\\" << linkName
+ << ".lnk\" \"$INSTDIR\\" << sourceName << "\"" << std::endl;
deleteStr << " StrCmp \"$INSTALL_DESKTOP\" \"1\" 0 +2\n";
- deleteStr << " Delete \"$DESKTOP\\" << linkName
- << ".lnk\"" << std::endl;
- }
+ deleteStr << " Delete \"$DESKTOP\\" << linkName << ".lnk\""
+ << std::endl;
}
+ }
}
-bool cmCPackNSISGenerator::GetListOfSubdirectories(const char* topdir,
- std::vector<std::string>& dirs)
+bool cmCPackNSISGenerator::GetListOfSubdirectories(
+ const char* topdir, std::vector<std::string>& dirs)
{
cmsys::Directory dir;
dir.Load(topdir);
size_t fileNum;
- for (fileNum = 0; fileNum < dir.GetNumberOfFiles(); ++fileNum)
- {
- if (strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)),".") &&
- strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)),".."))
- {
+ for (fileNum = 0; fileNum < dir.GetNumberOfFiles(); ++fileNum) {
+ if (strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), ".") &&
+ strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), "..")) {
std::string fullPath = topdir;
fullPath += "/";
fullPath += dir.GetFile(static_cast<unsigned long>(fileNum));
- if(cmsys::SystemTools::FileIsDirectory(fullPath) &&
- !cmsys::SystemTools::FileIsSymlink(fullPath))
- {
- if (!this->GetListOfSubdirectories(fullPath.c_str(), dirs))
- {
+ if (cmsys::SystemTools::FileIsDirectory(fullPath) &&
+ !cmsys::SystemTools::FileIsSymlink(fullPath)) {
+ if (!this->GetListOfSubdirectories(fullPath.c_str(), dirs)) {
return false;
- }
}
}
}
+ }
dirs.push_back(topdir);
return true;
}
@@ -694,116 +612,95 @@ cmCPackNSISGenerator::SupportsSetDestdir() const
bool cmCPackNSISGenerator::SupportsAbsoluteDestination() const
{
- return false;
+ return false;
}
bool cmCPackNSISGenerator::SupportsComponentInstallation() const
{
- return true;
+ return true;
}
-std::string
-cmCPackNSISGenerator::
-CreateComponentDescription(cmCPackComponent *component,
- std::ostringstream& macrosOut)
+std::string cmCPackNSISGenerator::CreateComponentDescription(
+ cmCPackComponent* component, std::ostringstream& macrosOut)
{
// Basic description of the component
std::string componentCode = "Section ";
- if (component->IsDisabledByDefault)
- {
+ if (component->IsDisabledByDefault) {
componentCode += "/o ";
- }
+ }
componentCode += "\"";
- if (component->IsHidden)
- {
+ if (component->IsHidden) {
componentCode += "-";
- }
+ }
componentCode += component->DisplayName + "\" " + component->Name + "\n";
- if (component->IsRequired)
- {
+ if (component->IsRequired) {
componentCode += " SectionIn RO\n";
- }
- else if (!component->InstallationTypes.empty())
- {
+ } else if (!component->InstallationTypes.empty()) {
std::ostringstream out;
- std::vector<cmCPackInstallationType *>::iterator installTypeIter;
+ std::vector<cmCPackInstallationType*>::iterator installTypeIter;
for (installTypeIter = component->InstallationTypes.begin();
installTypeIter != component->InstallationTypes.end();
- ++installTypeIter)
- {
+ ++installTypeIter) {
out << " " << (*installTypeIter)->Index;
- }
- componentCode += " SectionIn" + out.str() + "\n";
}
+ componentCode += " SectionIn" + out.str() + "\n";
+ }
componentCode += " SetOutPath \"$INSTDIR\"\n";
// Create the actual installation commands
- if (component->IsDownloaded)
- {
- if (component->ArchiveFile.empty())
- {
+ if (component->IsDownloaded) {
+ if (component->ArchiveFile.empty()) {
// Compute the name of the archive.
std::string packagesDir = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
packagesDir += ".dummy";
std::ostringstream out;
- out << cmSystemTools::GetFilenameWithoutLastExtension(packagesDir)
- << "-" << component->Name << ".zip";
+ out << cmSystemTools::GetFilenameWithoutLastExtension(packagesDir) << "-"
+ << component->Name << ".zip";
component->ArchiveFile = out.str();
- }
+ }
// Create the directory for the upload area
const char* userUploadDirectory =
this->GetOption("CPACK_UPLOAD_DIRECTORY");
std::string uploadDirectory;
- if (userUploadDirectory && *userUploadDirectory)
- {
+ if (userUploadDirectory && *userUploadDirectory) {
uploadDirectory = userUploadDirectory;
- }
- else
- {
- uploadDirectory= this->GetOption("CPACK_PACKAGE_DIRECTORY");
+ } else {
+ uploadDirectory = this->GetOption("CPACK_PACKAGE_DIRECTORY");
uploadDirectory += "/CPackUploads";
- }
- if(!cmSystemTools::FileExists(uploadDirectory.c_str()))
- {
- if (!cmSystemTools::MakeDirectory(uploadDirectory.c_str()))
- {
+ }
+ if (!cmSystemTools::FileExists(uploadDirectory.c_str())) {
+ if (!cmSystemTools::MakeDirectory(uploadDirectory.c_str())) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Unable to create NSIS upload directory " << uploadDirectory
- << std::endl);
+ "Unable to create NSIS upload directory "
+ << uploadDirectory << std::endl);
return "";
- }
}
+ }
// Remove the old archive, if one exists
std::string archiveFile = uploadDirectory + '/' + component->ArchiveFile;
cmCPackLogger(cmCPackLog::LOG_OUTPUT,
- "- Building downloaded component archive: "
- << archiveFile << std::endl);
- if (cmSystemTools::FileExists(archiveFile.c_str(), true))
- {
- if (!cmSystemTools::RemoveFile(archiveFile))
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Unable to remove archive file " << archiveFile
- << std::endl);
+ "- Building downloaded component archive: " << archiveFile
+ << std::endl);
+ if (cmSystemTools::FileExists(archiveFile.c_str(), true)) {
+ if (!cmSystemTools::RemoveFile(archiveFile)) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Unable to remove archive file "
+ << archiveFile << std::endl);
return "";
- }
}
+ }
// Find a ZIP program
- if (!this->IsSet("ZIP_EXECUTABLE"))
- {
+ if (!this->IsSet("ZIP_EXECUTABLE")) {
this->ReadListFile("CPackZIP.cmake");
- if (!this->IsSet("ZIP_EXECUTABLE"))
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Unable to find ZIP program"
- << std::endl);
+ if (!this->IsSet("ZIP_EXECUTABLE")) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Unable to find ZIP program"
+ << std::endl);
return "";
- }
}
+ }
// The directory where this component's files reside
std::string dirName = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
@@ -815,29 +712,25 @@ CreateComponentDescription(cmCPackComponent *component,
// size of the installed component.
std::string zipListFileName = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
zipListFileName += "/winZip.filelist";
- bool needQuotesInFile
- = cmSystemTools::IsOn(this->GetOption("CPACK_ZIP_NEED_QUOTES"));
+ bool needQuotesInFile =
+ cmSystemTools::IsOn(this->GetOption("CPACK_ZIP_NEED_QUOTES"));
unsigned long totalSize = 0;
{ // the scope is needed for cmGeneratedFileStream
cmGeneratedFileStream out(zipListFileName.c_str());
std::vector<std::string>::iterator fileIt;
- for (fileIt = component->Files.begin();
- fileIt != component->Files.end();
- ++fileIt)
- {
- if ( needQuotesInFile )
- {
+ for (fileIt = component->Files.begin(); fileIt != component->Files.end();
+ ++fileIt) {
+ if (needQuotesInFile) {
out << "\"";
- }
+ }
out << *fileIt;
- if ( needQuotesInFile )
- {
+ if (needQuotesInFile) {
out << "\"";
- }
+ }
out << std::endl;
totalSize += cmSystemTools::FileLength(dirName + *fileIt);
- }
+ }
}
// Build the archive in the upload area
@@ -847,29 +740,28 @@ CreateComponentDescription(cmCPackComponent *component,
zipListFileName.c_str());
std::string output;
int retVal = -1;
- int res = cmSystemTools::RunSingleCommand(
- cmd.c_str(), &output, &output,
- &retVal, dirName.c_str(), cmSystemTools::OUTPUT_NONE, 0);
- if ( !res || retVal )
- {
+ int res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output, &output,
+ &retVal, dirName.c_str(),
+ cmSystemTools::OUTPUT_NONE, 0);
+ if (!res || retVal) {
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
tmpFile += "/CompressZip.log";
cmGeneratedFileStream ofs(tmpFile.c_str());
ofs << "# Run command: " << cmd << std::endl
- << "# Output:" << std::endl
- << output << std::endl;
+ << "# Output:" << std::endl
+ << output << std::endl;
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running zip command: "
- << cmd << std::endl
- << "Please check " << tmpFile << " for errors" << std::endl);
+ << cmd << std::endl
+ << "Please check " << tmpFile << " for errors"
+ << std::endl);
return "";
}
// Create the NSIS code to download this file on-the-fly.
unsigned long totalSizeInKbytes = (totalSize + 512) / 1024;
- if (totalSizeInKbytes == 0)
- {
+ if (totalSizeInKbytes == 0) {
totalSizeInKbytes = 1;
- }
+ }
std::ostringstream out;
/* clang-format off */
out << " AddSize " << totalSizeInKbytes << "\n"
@@ -883,12 +775,10 @@ CreateComponentDescription(cmCPackComponent *component,
" Delete $INSTDIR\\$0\n";
/* clang-format on */
componentCode += out.str();
- }
- else
- {
- componentCode += " File /r \"${INST_DIR}\\" +
- component->Name + "\\*.*\"\n";
- }
+ } else {
+ componentCode +=
+ " File /r \"${INST_DIR}\\" + component->Name + "\\*.*\"\n";
+ }
componentCode += "SectionEnd\n";
// Macro used to remove the component
@@ -897,32 +787,24 @@ CreateComponentDescription(cmCPackComponent *component,
<< component->Name << "\n";
std::vector<std::string>::iterator pathIt;
std::string path;
- for (pathIt = component->Files.begin();
- pathIt != component->Files.end();
- ++pathIt)
- {
+ for (pathIt = component->Files.begin(); pathIt != component->Files.end();
+ ++pathIt) {
path = *pathIt;
cmSystemTools::ReplaceString(path, "/", "\\");
- macrosOut << " Delete \"$INSTDIR\\"
- << path
- << "\"\n";
- }
+ macrosOut << " Delete \"$INSTDIR\\" << path << "\"\n";
+ }
for (pathIt = component->Directories.begin();
- pathIt != component->Directories.end();
- ++pathIt)
- {
+ pathIt != component->Directories.end(); ++pathIt) {
path = *pathIt;
cmSystemTools::ReplaceString(path, "/", "\\");
- macrosOut << " RMDir \"$INSTDIR\\"
- << path
- << "\"\n";
- }
+ macrosOut << " RMDir \"$INSTDIR\\" << path << "\"\n";
+ }
macrosOut << " noremove_" << component->Name << ":\n";
macrosOut << "!macroend\n";
// Macro used to select each of the components that this component
// depends on.
- std::set<cmCPackComponent *> visited;
+ std::set<cmCPackComponent*> visited;
macrosOut << "!macro Select_" << component->Name << "_depends\n";
macrosOut << CreateSelectionDependenciesDescription(component, visited);
macrosOut << "!macroend\n";
@@ -936,23 +818,19 @@ CreateComponentDescription(cmCPackComponent *component,
return componentCode;
}
-std::string cmCPackNSISGenerator::CreateSelectionDependenciesDescription
- (cmCPackComponent *component,
- std::set<cmCPackComponent *>& visited)
+std::string cmCPackNSISGenerator::CreateSelectionDependenciesDescription(
+ cmCPackComponent* component, std::set<cmCPackComponent*>& visited)
{
// Don't visit a component twice
- if (visited.count(component))
- {
+ if (visited.count(component)) {
return std::string();
- }
+ }
visited.insert(component);
std::ostringstream out;
- std::vector<cmCPackComponent *>::iterator dependIt;
+ std::vector<cmCPackComponent*>::iterator dependIt;
for (dependIt = component->Dependencies.begin();
- dependIt != component->Dependencies.end();
- ++dependIt)
- {
+ dependIt != component->Dependencies.end(); ++dependIt) {
// Write NSIS code to select this dependency
out << " SectionGetFlags ${" << (*dependIt)->Name << "} $0\n";
out << " IntOp $0 $0 | ${SF_SELECTED}\n";
@@ -961,29 +839,24 @@ std::string cmCPackNSISGenerator::CreateSelectionDependenciesDescription
<< "_selected 0 + ${SF_SELECTED}\n";
// Recurse
out << CreateSelectionDependenciesDescription(*dependIt, visited).c_str();
- }
+ }
return out.str();
}
-
-std::string cmCPackNSISGenerator::CreateDeselectionDependenciesDescription
- (cmCPackComponent *component,
- std::set<cmCPackComponent *>& visited)
+std::string cmCPackNSISGenerator::CreateDeselectionDependenciesDescription(
+ cmCPackComponent* component, std::set<cmCPackComponent*>& visited)
{
// Don't visit a component twice
- if (visited.count(component))
- {
+ if (visited.count(component)) {
return std::string();
- }
+ }
visited.insert(component);
std::ostringstream out;
- std::vector<cmCPackComponent *>::iterator dependIt;
+ std::vector<cmCPackComponent*>::iterator dependIt;
for (dependIt = component->ReverseDependencies.begin();
- dependIt != component->ReverseDependencies.end();
- ++dependIt)
- {
+ dependIt != component->ReverseDependencies.end(); ++dependIt) {
// Write NSIS code to deselect this dependency
out << " SectionGetFlags ${" << (*dependIt)->Name << "} $0\n";
out << " IntOp $1 ${SF_SELECTED} ~\n";
@@ -992,57 +865,46 @@ std::string cmCPackNSISGenerator::CreateDeselectionDependenciesDescription
out << " IntOp $" << (*dependIt)->Name << "_selected 0 + 0\n";
// Recurse
- out <<
- CreateDeselectionDependenciesDescription(*dependIt, visited).c_str();
- }
+ out
+ << CreateDeselectionDependenciesDescription(*dependIt, visited).c_str();
+ }
return out.str();
}
-std::string
-cmCPackNSISGenerator::
-CreateComponentGroupDescription(cmCPackComponentGroup *group,
- std::ostringstream& macrosOut)
+std::string cmCPackNSISGenerator::CreateComponentGroupDescription(
+ cmCPackComponentGroup* group, std::ostringstream& macrosOut)
{
- if (group->Components.empty() && group->Subgroups.empty())
- {
+ if (group->Components.empty() && group->Subgroups.empty()) {
// Silently skip empty groups. NSIS doesn't support them.
return std::string();
- }
+ }
std::string code = "SectionGroup ";
- if (group->IsExpandedByDefault)
- {
+ if (group->IsExpandedByDefault) {
code += "/e ";
- }
- if (group->IsBold)
- {
+ }
+ if (group->IsBold) {
code += "\"!" + group->DisplayName + "\" " + group->Name + "\n";
- }
- else
- {
+ } else {
code += "\"" + group->DisplayName + "\" " + group->Name + "\n";
- }
+ }
std::vector<cmCPackComponentGroup*>::iterator groupIt;
for (groupIt = group->Subgroups.begin(); groupIt != group->Subgroups.end();
- ++groupIt)
- {
+ ++groupIt) {
code += this->CreateComponentGroupDescription(*groupIt, macrosOut);
- }
+ }
std::vector<cmCPackComponent*>::iterator comp;
- for (comp = group->Components.begin();
- comp != group->Components.end();
- ++comp)
- {
- if ((*comp)->Files.empty())
- {
+ for (comp = group->Components.begin(); comp != group->Components.end();
+ ++comp) {
+ if ((*comp)->Files.empty()) {
continue;
- }
+ }
code += this->CreateComponentDescription(*comp, macrosOut);
- }
+ }
code += "SectionGroupEnd\n";
return code;
}
diff --git a/Source/CPack/cmCPackNSISGenerator.h b/Source/CPack/cmCPackNSISGenerator.h
index ab8ece4..fa52902 100644
--- a/Source/CPack/cmCPackNSISGenerator.h
+++ b/Source/CPack/cmCPackNSISGenerator.h
@@ -28,7 +28,9 @@ public:
cmCPackTypeMacro(cmCPackNSISGenerator, cmCPackGenerator);
static cmCPackGenerator* CreateGenerator64()
- { return new cmCPackNSISGenerator(true); }
+ {
+ return new cmCPackNSISGenerator(true);
+ }
/**
* Construct generator
@@ -38,14 +40,13 @@ public:
protected:
virtual int InitializeInternal();
- void CreateMenuLinks( std::ostringstream& str,
- std::ostringstream& deleteStr);
+ void CreateMenuLinks(std::ostringstream& str, std::ostringstream& deleteStr);
int PackageFiles();
virtual const char* GetOutputExtension() { return ".exe"; }
virtual const char* GetOutputPostfix() { return "win32"; }
bool GetListOfSubdirectories(const char* dir,
- std::vector<std::string>& dirs);
+ std::vector<std::string>& dirs);
enum cmCPackGenerator::CPackSetDestdirSupport SupportsSetDestdir() const;
virtual bool SupportsAbsoluteDestination() const;
@@ -54,28 +55,24 @@ protected:
/// Produce a string that contains the NSIS code to describe a
/// particular component. Any added macros will be emitted via
/// macrosOut.
- std::string
- CreateComponentDescription(cmCPackComponent *component,
- std::ostringstream& macrosOut);
+ std::string CreateComponentDescription(cmCPackComponent* component,
+ std::ostringstream& macrosOut);
/// Produce NSIS code that selects all of the components that this component
/// depends on, recursively.
- std::string CreateSelectionDependenciesDescription
- (cmCPackComponent *component,
- std::set<cmCPackComponent *>& visited);
+ std::string CreateSelectionDependenciesDescription(
+ cmCPackComponent* component, std::set<cmCPackComponent*>& visited);
/// Produce NSIS code that de-selects all of the components that are
/// dependent on this component, recursively.
- std::string CreateDeselectionDependenciesDescription
- (cmCPackComponent *component,
- std::set<cmCPackComponent *>& visited);
+ std::string CreateDeselectionDependenciesDescription(
+ cmCPackComponent* component, std::set<cmCPackComponent*>& visited);
/// Produce a string that contains the NSIS code to describe a
/// particular component group, including its components. Any
/// added macros will be emitted via macrosOut.
- std::string
- CreateComponentGroupDescription(cmCPackComponentGroup *group,
- std::ostringstream& macrosOut);
+ std::string CreateComponentGroupDescription(cmCPackComponentGroup* group,
+ std::ostringstream& macrosOut);
/// Translations any newlines found in the string into \\r\\n, so that the
/// resulting string can be used within NSIS.
diff --git a/Source/CPack/cmCPackOSXX11Generator.cxx b/Source/CPack/cmCPackOSXX11Generator.cxx
index 42b8c62..d5691be 100644
--- a/Source/CPack/cmCPackOSXX11Generator.cxx
+++ b/Source/CPack/cmCPackOSXX11Generator.cxx
@@ -36,41 +36,38 @@ int cmCPackOSXX11Generator::PackageFiles()
// TODO: Use toplevel ?
// It is used! Is this an obsolete comment?
- const char* cpackPackageExecutables
- = this->GetOption("CPACK_PACKAGE_EXECUTABLES");
- if ( cpackPackageExecutables )
- {
+ const char* cpackPackageExecutables =
+ this->GetOption("CPACK_PACKAGE_EXECUTABLES");
+ if (cpackPackageExecutables) {
cmCPackLogger(cmCPackLog::LOG_DEBUG, "The cpackPackageExecutables: "
- << cpackPackageExecutables << "." << std::endl);
+ << cpackPackageExecutables << "." << std::endl);
std::ostringstream str;
std::ostringstream deleteStr;
std::vector<std::string> cpackPackageExecutablesVector;
cmSystemTools::ExpandListArgument(cpackPackageExecutables,
- cpackPackageExecutablesVector);
- if ( cpackPackageExecutablesVector.size() % 2 != 0 )
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
+ cpackPackageExecutablesVector);
+ if (cpackPackageExecutablesVector.size() % 2 != 0) {
+ cmCPackLogger(
+ cmCPackLog::LOG_ERROR,
"CPACK_PACKAGE_EXECUTABLES should contain pairs of <executable> and "
- "<icon name>." << std::endl);
+ "<icon name>."
+ << std::endl);
return 0;
- }
+ }
std::vector<std::string>::iterator it;
- for ( it = cpackPackageExecutablesVector.begin();
- it != cpackPackageExecutablesVector.end();
- ++it )
- {
+ for (it = cpackPackageExecutablesVector.begin();
+ it != cpackPackageExecutablesVector.end(); ++it) {
std::string cpackExecutableName = *it;
- ++ it;
+ ++it;
this->SetOptionIfNotSet("CPACK_EXECUTABLE_NAME",
- cpackExecutableName.c_str());
- }
+ cpackExecutableName.c_str());
}
+ }
// Disk image directories
std::string diskImageDirectory = toplevel;
- std::string diskImageBackgroundImageDir
- = diskImageDirectory + "/.background";
-
+ std::string diskImageBackgroundImageDir =
+ diskImageDirectory + "/.background";
// App bundle directories
std::string packageDirFileName = toplevel;
@@ -90,48 +87,45 @@ int cmCPackOSXX11Generator::PackageFiles()
const char* contDir = contentsDirectory.c_str();
const char* rsrcFile = resourceFileName.c_str();
const char* iconFile = this->GetOption("CPACK_PACKAGE_ICON");
- if ( iconFile )
- {
- std::string iconFileName = cmsys::SystemTools::GetFilenameName(
- iconFile);
- if ( !cmSystemTools::FileExists(iconFile) )
- {
+ if (iconFile) {
+ std::string iconFileName = cmsys::SystemTools::GetFilenameName(iconFile);
+ if (!cmSystemTools::FileExists(iconFile)) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find icon file: "
- << iconFile << ". Please check CPACK_PACKAGE_ICON setting."
- << std::endl);
+ << iconFile
+ << ". Please check CPACK_PACKAGE_ICON setting."
+ << std::endl);
return 0;
- }
+ }
std::string destFileName = resourcesDirectory + "/" + iconFileName;
this->ConfigureFile(iconFile, destFileName.c_str(), true);
this->SetOptionIfNotSet("CPACK_APPLE_GUI_ICON", iconFileName.c_str());
- }
+ }
std::string applicationsLinkName = diskImageDirectory + "/Applications";
cmSystemTools::CreateSymlink("/Applications", applicationsLinkName.c_str());
- if (
- !this->CopyResourcePlistFile("VolumeIcon.icns",
- diskImageDirectory.c_str(),
- ".VolumeIcon.icns", true ) ||
- !this->CopyResourcePlistFile("DS_Store", diskImageDirectory.c_str(),
- ".DS_Store", true ) ||
- !this->CopyResourcePlistFile("background.png",
- diskImageBackgroundImageDir.c_str(), "background.png", true ) ||
- !this->CopyResourcePlistFile("RuntimeScript", dir) ||
- !this->CopyResourcePlistFile("OSXX11.Info.plist", contDir,
- "Info.plist" ) ||
- !this->CopyResourcePlistFile("OSXX11.main.scpt", scrDir,
- "main.scpt", true ) ||
- !this->CopyResourcePlistFile("OSXScriptLauncher.rsrc", dir,
- rsrcFile, true) ||
- !this->CopyResourcePlistFile("OSXScriptLauncher", appdir,
- this->GetOption("CPACK_PACKAGE_FILE_NAME"), true)
- )
- {
+ if (!this->CopyResourcePlistFile("VolumeIcon.icns",
+ diskImageDirectory.c_str(),
+ ".VolumeIcon.icns", true) ||
+ !this->CopyResourcePlistFile("DS_Store", diskImageDirectory.c_str(),
+ ".DS_Store", true) ||
+ !this->CopyResourcePlistFile("background.png",
+ diskImageBackgroundImageDir.c_str(),
+ "background.png", true) ||
+ !this->CopyResourcePlistFile("RuntimeScript", dir) ||
+ !this->CopyResourcePlistFile("OSXX11.Info.plist", contDir,
+ "Info.plist") ||
+ !this->CopyResourcePlistFile("OSXX11.main.scpt", scrDir, "main.scpt",
+ true) ||
+ !this->CopyResourcePlistFile("OSXScriptLauncher.rsrc", dir, rsrcFile,
+ true) ||
+ !this->CopyResourcePlistFile("OSXScriptLauncher", appdir,
+ this->GetOption("CPACK_PACKAGE_FILE_NAME"),
+ true)) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the resource files"
- << std::endl);
+ << std::endl);
return 0;
- }
+ }
// Two of the files need to have execute permission, so ensure they do:
std::string runTimeScript = dir;
@@ -143,21 +137,21 @@ int cmCPackOSXX11Generator::PackageFiles()
appScriptName += this->GetOption("CPACK_PACKAGE_FILE_NAME");
mode_t mode;
- if (cmsys::SystemTools::GetPermissions(runTimeScript.c_str(), mode))
- {
+ if (cmsys::SystemTools::GetPermissions(runTimeScript.c_str(), mode)) {
mode |= (S_IXUSR | S_IXGRP | S_IXOTH);
cmsys::SystemTools::SetPermissions(runTimeScript.c_str(), mode);
- cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Setting: " << runTimeScript
- << " to permission: " << mode << std::endl);
- }
+ cmCPackLogger(cmCPackLog::LOG_OUTPUT,
+ "Setting: " << runTimeScript << " to permission: " << mode
+ << std::endl);
+ }
- if (cmsys::SystemTools::GetPermissions(appScriptName.c_str(), mode))
- {
+ if (cmsys::SystemTools::GetPermissions(appScriptName.c_str(), mode)) {
mode |= (S_IXUSR | S_IXGRP | S_IXOTH);
cmsys::SystemTools::SetPermissions(appScriptName.c_str(), mode);
- cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Setting: " << appScriptName
- << " to permission: " << mode << std::endl);
- }
+ cmCPackLogger(cmCPackLog::LOG_OUTPUT,
+ "Setting: " << appScriptName << " to permission: " << mode
+ << std::endl);
+ }
std::string output;
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
@@ -165,56 +159,52 @@ int cmCPackOSXX11Generator::PackageFiles()
std::ostringstream dmgCmd;
dmgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM_DISK_IMAGE")
<< "\" create -ov -format UDZO -srcfolder \""
- << diskImageDirectory.c_str()
- << "\" \"" << packageFileNames[0] << "\"";
- cmCPackLogger(cmCPackLog::LOG_VERBOSE,
- "Compress disk image using command: "
- << dmgCmd.str().c_str() << std::endl);
+ << diskImageDirectory.c_str() << "\" \"" << packageFileNames[0]
+ << "\"";
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Compress disk image using command: "
+ << dmgCmd.str().c_str() << std::endl);
// since we get random dashboard failures with this one
// try running it more than once
int retVal = 1;
int numTries = 10;
bool res = false;
- while(numTries > 0)
- {
- res = cmSystemTools::RunSingleCommand(
- dmgCmd.str().c_str(), &output, &output,
- &retVal, 0, this->GeneratorVerbose, 0);
- if ( res && !retVal )
- {
+ while (numTries > 0) {
+ res =
+ cmSystemTools::RunSingleCommand(dmgCmd.str().c_str(), &output, &output,
+ &retVal, 0, this->GeneratorVerbose, 0);
+ if (res && !retVal) {
numTries = -1;
break;
- }
+ }
cmSystemTools::Delay(500);
numTries--;
- }
- if ( !res || retVal )
- {
+ }
+ if (!res || retVal) {
cmGeneratedFileStream ofs(tmpFile.c_str());
ofs << "# Run command: " << dmgCmd.str().c_str() << std::endl
- << "# Output:" << std::endl
- << output.c_str() << std::endl;
+ << "# Output:" << std::endl
+ << output.c_str() << std::endl;
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running hdiutil command: "
- << dmgCmd.str().c_str() << std::endl
- << "Please check " << tmpFile.c_str() << " for errors" << std::endl);
+ << dmgCmd.str().c_str() << std::endl
+ << "Please check " << tmpFile.c_str() << " for errors"
+ << std::endl);
return 0;
- }
+ }
return 1;
}
int cmCPackOSXX11Generator::InitializeInternal()
{
- cmCPackLogger(cmCPackLog::LOG_DEBUG,
- "cmCPackOSXX11Generator::Initialize()" << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_DEBUG, "cmCPackOSXX11Generator::Initialize()"
+ << std::endl);
std::vector<std::string> path;
std::string pkgPath = cmSystemTools::FindProgram("hdiutil", path, false);
- if ( pkgPath.empty() )
- {
+ if (pkgPath.empty()) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find hdiutil compiler"
- << std::endl);
+ << std::endl);
return 0;
- }
+ }
this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM_DISK_IMAGE",
pkgPath.c_str());
@@ -265,32 +255,31 @@ bool cmCPackOSXX11Generator::CopyCreateResourceFile(const std::string& name)
}
*/
-bool cmCPackOSXX11Generator::CopyResourcePlistFile(const std::string& name,
- const std::string& dir, const char* outputFileName /* = 0 */,
- bool copyOnly /* = false */)
+bool cmCPackOSXX11Generator::CopyResourcePlistFile(
+ const std::string& name, const std::string& dir,
+ const char* outputFileName /* = 0 */, bool copyOnly /* = false */)
{
std::string inFName = "CPack.";
inFName += name;
inFName += ".in";
std::string inFileName = this->FindTemplate(inFName.c_str());
- if ( inFileName.empty() )
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find input file: "
- << inFName << std::endl);
+ if (inFileName.empty()) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Cannot find input file: " << inFName << std::endl);
return false;
- }
+ }
- if ( !outputFileName )
- {
+ if (!outputFileName) {
outputFileName = name.c_str();
- }
+ }
std::string destFileName = dir;
destFileName += "/";
destFileName += outputFileName;
- cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: "
- << inFileName.c_str() << " to " << destFileName.c_str() << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE,
+ "Configure file: " << inFileName.c_str() << " to "
+ << destFileName.c_str() << std::endl);
this->ConfigureFile(inFileName.c_str(), destFileName.c_str(), copyOnly);
return true;
}
diff --git a/Source/CPack/cmCPackOSXX11Generator.h b/Source/CPack/cmCPackOSXX11Generator.h
index 9d0a6d1..adc05d2 100644
--- a/Source/CPack/cmCPackOSXX11Generator.h
+++ b/Source/CPack/cmCPackOSXX11Generator.h
@@ -37,10 +37,11 @@ protected:
virtual const char* GetPackagingInstallPrefix();
virtual const char* GetOutputExtension() { return ".dmg"; }
- //bool CopyCreateResourceFile(const std::string& name,
+ // bool CopyCreateResourceFile(const std::string& name,
// const std::string& dir);
bool CopyResourcePlistFile(const std::string& name, const std::string& dir,
- const char* outputFileName = 0, bool copyOnly = false);
+ const char* outputFileName = 0,
+ bool copyOnly = false);
std::string InstallPrefix;
};
diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx
index 71a5b12..5ca3ff7 100644
--- a/Source/CPack/cmCPackPackageMakerGenerator.cxx
+++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx
@@ -25,8 +25,7 @@
#include <assert.h>
-static inline
-unsigned int getVersion(unsigned int major, unsigned int minor)
+static inline unsigned int getVersion(unsigned int major, unsigned int minor)
{
assert(major < 256 && minor < 256);
return ((major & 0xFF) << 16 | minor);
@@ -55,10 +54,9 @@ int cmCPackPackageMakerGenerator::CopyInstallScript(const std::string& resdir,
dst += "/";
dst += name;
cmSystemTools::CopyFileAlways(script.c_str(), dst.c_str());
- cmSystemTools::SetPermissions(dst.c_str(),0777);
- cmCPackLogger(cmCPackLog::LOG_VERBOSE,
- "copy script : " << script << "\ninto " << dst.c_str() <<
- std::endl);
+ cmSystemTools::SetPermissions(dst.c_str(), 0777);
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE, "copy script : "
+ << script << "\ninto " << dst.c_str() << std::endl);
return 1;
}
@@ -69,102 +67,80 @@ int cmCPackPackageMakerGenerator::PackageFiles()
// It is used! Is this an obsolete comment?
std::string resDir; // Where this package's resources will go.
- std::string packageDirFileName
- = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
- if (this->Components.empty())
- {
+ std::string packageDirFileName =
+ this->GetOption("CPACK_TEMPORARY_DIRECTORY");
+ if (this->Components.empty()) {
packageDirFileName += ".pkg";
resDir = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
resDir += "/Resources";
- }
- else
- {
+ } else {
packageDirFileName += ".mpkg";
- if ( !cmsys::SystemTools::MakeDirectory(packageDirFileName.c_str()))
- {
+ if (!cmsys::SystemTools::MakeDirectory(packageDirFileName.c_str())) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "unable to create package directory "
- << packageDirFileName << std::endl);
- return 0;
- }
+ "unable to create package directory " << packageDirFileName
+ << std::endl);
+ return 0;
+ }
resDir = packageDirFileName;
resDir += "/Contents";
- if ( !cmsys::SystemTools::MakeDirectory(resDir.c_str()))
- {
+ if (!cmsys::SystemTools::MakeDirectory(resDir.c_str())) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"unable to create package subdirectory " << resDir
- << std::endl);
- return 0;
- }
+ << std::endl);
+ return 0;
+ }
resDir += "/Resources";
- if ( !cmsys::SystemTools::MakeDirectory(resDir.c_str()))
- {
+ if (!cmsys::SystemTools::MakeDirectory(resDir.c_str())) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"unable to create package subdirectory " << resDir
- << std::endl);
- return 0;
- }
+ << std::endl);
+ return 0;
+ }
resDir += "/en.lproj";
- }
+ }
const char* preflight = this->GetOption("CPACK_PREFLIGHT_SCRIPT");
const char* postflight = this->GetOption("CPACK_POSTFLIGHT_SCRIPT");
const char* postupgrade = this->GetOption("CPACK_POSTUPGRADE_SCRIPT");
- if(this->Components.empty())
- {
+ if (this->Components.empty()) {
// Create directory structure
std::string preflightDirName = resDir + "/PreFlight";
std::string postflightDirName = resDir + "/PostFlight";
// if preflight or postflight scripts not there create directories
// of the same name, I think this makes it work
- if(!preflight)
- {
- if ( !cmsys::SystemTools::MakeDirectory(preflightDirName.c_str()))
- {
+ if (!preflight) {
+ if (!cmsys::SystemTools::MakeDirectory(preflightDirName.c_str())) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Problem creating installer directory: "
- << preflightDirName.c_str() << std::endl);
+ << preflightDirName.c_str() << std::endl);
return 0;
- }
}
- if(!postflight)
- {
- if ( !cmsys::SystemTools::MakeDirectory(postflightDirName.c_str()))
- {
+ }
+ if (!postflight) {
+ if (!cmsys::SystemTools::MakeDirectory(postflightDirName.c_str())) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Problem creating installer directory: "
- << postflightDirName.c_str() << std::endl);
+ << postflightDirName.c_str() << std::endl);
return 0;
- }
}
+ }
// if preflight, postflight, or postupgrade are set
// then copy them into the resource directory and make
// them executable
- if(preflight)
- {
- this->CopyInstallScript(resDir.c_str(),
- preflight,
- "preflight");
- }
- if(postflight)
- {
- this->CopyInstallScript(resDir.c_str(),
- postflight,
- "postflight");
- }
- if(postupgrade)
- {
- this->CopyInstallScript(resDir.c_str(),
- postupgrade,
- "postupgrade");
- }
+ if (preflight) {
+ this->CopyInstallScript(resDir.c_str(), preflight, "preflight");
}
- else if(postflight)
- {
+ if (postflight) {
+ this->CopyInstallScript(resDir.c_str(), postflight, "postflight");
+ }
+ if (postupgrade) {
+ this->CopyInstallScript(resDir.c_str(), postupgrade, "postupgrade");
+ }
+ } else if (postflight) {
// create a postflight component to house the script
this->PostFlightComponent.Name = "PostFlight";
this->PostFlightComponent.DisplayName = "PostFlight";
@@ -173,121 +149,101 @@ int cmCPackPackageMakerGenerator::PackageFiles()
// empty directory for pkg contents
std::string packageDir = toplevel + "/" + PostFlightComponent.Name;
- if (!cmsys::SystemTools::MakeDirectory(packageDir.c_str()))
- {
+ if (!cmsys::SystemTools::MakeDirectory(packageDir.c_str())) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Problem creating component packages directory: "
- << packageDir.c_str() << std::endl);
+ << packageDir.c_str() << std::endl);
return 0;
- }
+ }
// create package
std::string packageFileDir = packageDirFileName + "/Contents/Packages/";
- if (!cmsys::SystemTools::MakeDirectory(packageFileDir.c_str()))
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Problem creating component PostFlight Packages directory: "
- << packageFileDir.c_str() << std::endl);
+ if (!cmsys::SystemTools::MakeDirectory(packageFileDir.c_str())) {
+ cmCPackLogger(
+ cmCPackLog::LOG_ERROR,
+ "Problem creating component PostFlight Packages directory: "
+ << packageFileDir.c_str() << std::endl);
return 0;
- }
- std::string packageFile = packageFileDir +
- this->GetPackageName(PostFlightComponent);
- if (!this->GenerateComponentPackage(packageFile.c_str(),
- packageDir.c_str(),
- PostFlightComponent))
- {
+ }
+ std::string packageFile =
+ packageFileDir + this->GetPackageName(PostFlightComponent);
+ if (!this->GenerateComponentPackage(
+ packageFile.c_str(), packageDir.c_str(), PostFlightComponent)) {
return 0;
- }
+ }
// copy postflight script into resource directory of .pkg
std::string resourceDir = packageFile + "/Contents/Resources";
- this->CopyInstallScript(resourceDir.c_str(),
- postflight,
- "postflight");
- }
+ this->CopyInstallScript(resourceDir.c_str(), postflight, "postflight");
+ }
- if (!this->Components.empty())
- {
+ if (!this->Components.empty()) {
// Create the directory where component packages will be built.
std::string basePackageDir = packageDirFileName;
basePackageDir += "/Contents/Packages";
- if (!cmsys::SystemTools::MakeDirectory(basePackageDir.c_str()))
- {
+ if (!cmsys::SystemTools::MakeDirectory(basePackageDir.c_str())) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Problem creating component packages directory: "
- << basePackageDir.c_str() << std::endl);
+ << basePackageDir.c_str() << std::endl);
return 0;
- }
+ }
// Create the directory where downloaded component packages will
// be placed.
const char* userUploadDirectory =
this->GetOption("CPACK_UPLOAD_DIRECTORY");
std::string uploadDirectory;
- if (userUploadDirectory && *userUploadDirectory)
- {
+ if (userUploadDirectory && *userUploadDirectory) {
uploadDirectory = userUploadDirectory;
- }
- else
- {
- uploadDirectory= this->GetOption("CPACK_PACKAGE_DIRECTORY");
+ } else {
+ uploadDirectory = this->GetOption("CPACK_PACKAGE_DIRECTORY");
uploadDirectory += "/CPackUploads";
- }
+ }
// Create packages for each component
bool warnedAboutDownloadCompatibility = false;
std::map<std::string, cmCPackComponent>::iterator compIt;
for (compIt = this->Components.begin(); compIt != this->Components.end();
- ++compIt)
- {
+ ++compIt) {
std::string packageFile;
- if (compIt->second.IsDownloaded)
- {
+ if (compIt->second.IsDownloaded) {
if (this->PackageCompatibilityVersion >= getVersion(10, 5) &&
- this->PackageMakerVersion >= 3.0)
- {
+ this->PackageMakerVersion >= 3.0) {
// Build this package within the upload directory.
packageFile = uploadDirectory;
- if(!cmSystemTools::FileExists(uploadDirectory.c_str()))
- {
- if (!cmSystemTools::MakeDirectory(uploadDirectory.c_str()))
- {
+ if (!cmSystemTools::FileExists(uploadDirectory.c_str())) {
+ if (!cmSystemTools::MakeDirectory(uploadDirectory.c_str())) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Unable to create package upload directory "
- << uploadDirectory << std::endl);
+ << uploadDirectory << std::endl);
return 0;
- }
}
}
- else if (!warnedAboutDownloadCompatibility)
- {
- if (this->PackageCompatibilityVersion < getVersion(10, 5))
- {
+ } else if (!warnedAboutDownloadCompatibility) {
+ if (this->PackageCompatibilityVersion < getVersion(10, 5)) {
cmCPackLogger(
cmCPackLog::LOG_WARNING,
"CPack warning: please set CPACK_OSX_PACKAGE_VERSION to 10.5 "
"or greater enable downloaded packages. CPack will build a "
"non-downloaded package."
- << std::endl);
- }
+ << std::endl);
+ }
- if (this->PackageMakerVersion < 3)
- {
+ if (this->PackageMakerVersion < 3) {
cmCPackLogger(cmCPackLog::LOG_WARNING,
- "CPack warning: unable to build downloaded "
+ "CPack warning: unable to build downloaded "
"packages with PackageMaker versions prior "
"to 3.0. CPack will build a non-downloaded package."
- << std::endl);
- }
+ << std::endl);
+ }
warnedAboutDownloadCompatibility = true;
- }
}
+ }
- if (packageFile.empty())
- {
+ if (packageFile.empty()) {
// Build this package within the overall distribution
// metapackage.
packageFile = basePackageDir;
@@ -295,7 +251,7 @@ int cmCPackPackageMakerGenerator::PackageFiles()
// We're not downloading this component, even if the user
// requested it.
compIt->second.IsDownloaded = false;
- }
+ }
packageFile += '/';
packageFile += GetPackageName(compIt->second);
@@ -303,97 +259,85 @@ int cmCPackPackageMakerGenerator::PackageFiles()
std::string packageDir = toplevel;
packageDir += '/';
packageDir += compIt->first;
- if (!this->GenerateComponentPackage(packageFile.c_str(),
- packageDir.c_str(),
- compIt->second))
- {
+ if (!this->GenerateComponentPackage(
+ packageFile.c_str(), packageDir.c_str(), compIt->second)) {
return 0;
- }
}
}
+ }
this->SetOption("CPACK_MODULE_VERSION_SUFFIX", "");
// Copy or create all of the resource files we need.
- if ( !this->CopyCreateResourceFile("License", resDir.c_str())
- || !this->CopyCreateResourceFile("ReadMe", resDir.c_str())
- || !this->CopyCreateResourceFile("Welcome", resDir.c_str())
- || !this->CopyResourcePlistFile("Info.plist")
- || !this->CopyResourcePlistFile("Description.plist") )
- {
+ if (!this->CopyCreateResourceFile("License", resDir.c_str()) ||
+ !this->CopyCreateResourceFile("ReadMe", resDir.c_str()) ||
+ !this->CopyCreateResourceFile("Welcome", resDir.c_str()) ||
+ !this->CopyResourcePlistFile("Info.plist") ||
+ !this->CopyResourcePlistFile("Description.plist")) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the resource files"
- << std::endl);
+ << std::endl);
return 0;
- }
+ }
- if (this->Components.empty())
- {
+ if (this->Components.empty()) {
// Use PackageMaker to build the package.
std::ostringstream pkgCmd;
pkgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM")
<< "\" -build -p \"" << packageDirFileName << "\"";
- if (this->Components.empty())
- {
+ if (this->Components.empty()) {
pkgCmd << " -f \"" << this->GetOption("CPACK_TEMPORARY_DIRECTORY");
- }
- else
- {
+ } else {
pkgCmd << " -mi \"" << this->GetOption("CPACK_TEMPORARY_DIRECTORY")
<< "/packages/";
- }
+ }
pkgCmd << "\" -r \"" << this->GetOption("CPACK_TOPLEVEL_DIRECTORY")
<< "/Resources\" -i \""
<< this->GetOption("CPACK_TOPLEVEL_DIRECTORY")
<< "/Info.plist\" -d \""
<< this->GetOption("CPACK_TOPLEVEL_DIRECTORY")
<< "/Description.plist\"";
- if ( this->PackageMakerVersion > 2.0 )
- {
+ if (this->PackageMakerVersion > 2.0) {
pkgCmd << " -v";
- }
+ }
if (!RunPackageMaker(pkgCmd.str().c_str(), packageDirFileName.c_str()))
return 0;
- }
- else
- {
+ } else {
// We have built the package in place. Generate the
// distribution.dist file to describe it for the installer.
WriteDistributionFile(packageDirFileName.c_str());
- }
+ }
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
tmpFile += "/hdiutilOutput.log";
std::ostringstream dmgCmd;
dmgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM_DISK_IMAGE")
- << "\" create -ov -format UDZO -srcfolder \"" << packageDirFileName
- << "\" \"" << packageFileNames[0] << "\"";
+ << "\" create -ov -format UDZO -srcfolder \"" << packageDirFileName
+ << "\" \"" << packageFileNames[0] << "\"";
std::string output;
int retVal = 1;
int numTries = 10;
bool res = false;
- while(numTries > 0)
- {
- res = cmSystemTools::RunSingleCommand(
- dmgCmd.str().c_str(), &output, &output,
- &retVal, 0, this->GeneratorVerbose, 0);
- if ( res && !retVal )
- {
+ while (numTries > 0) {
+ res =
+ cmSystemTools::RunSingleCommand(dmgCmd.str().c_str(), &output, &output,
+ &retVal, 0, this->GeneratorVerbose, 0);
+ if (res && !retVal) {
numTries = -1;
break;
- }
+ }
cmSystemTools::Delay(500);
numTries--;
- }
- if ( !res || retVal )
- {
+ }
+ if (!res || retVal) {
cmGeneratedFileStream ofs(tmpFile.c_str());
ofs << "# Run command: " << dmgCmd.str().c_str() << std::endl
- << "# Output:" << std::endl
- << output.c_str() << std::endl;
+ << "# Output:" << std::endl
+ << output.c_str() << std::endl;
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running hdiutil command: "
- << dmgCmd.str().c_str() << std::endl
- << "Please check " << tmpFile.c_str() << " for errors" << std::endl);
+ << dmgCmd.str().c_str() << std::endl
+ << "Please check " << tmpFile.c_str() << " for errors"
+ << std::endl);
return 0;
- }
+ }
return 1;
}
@@ -401,7 +345,7 @@ int cmCPackPackageMakerGenerator::PackageFiles()
int cmCPackPackageMakerGenerator::InitializeInternal()
{
cmCPackLogger(cmCPackLog::LOG_DEBUG,
- "cmCPackPackageMakerGenerator::Initialize()" << std::endl);
+ "cmCPackPackageMakerGenerator::Initialize()" << std::endl);
this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr");
// Starting with Xcode 4.3, PackageMaker is a separate app, and you
@@ -418,39 +362,30 @@ int cmCPackPackageMakerGenerator::InitializeInternal()
// If found, save result in the CPACK_INSTALLER_PROGRAM variable.
std::vector<std::string> paths;
- paths.push_back(
- "/Applications/Xcode.app/Contents/Applications"
- "/PackageMaker.app/Contents/MacOS");
- paths.push_back(
- "/Applications/Utilities"
- "/PackageMaker.app/Contents/MacOS");
- paths.push_back(
- "/Applications"
- "/PackageMaker.app/Contents/MacOS");
- paths.push_back(
- "/Developer/Applications/Utilities"
- "/PackageMaker.app/Contents/MacOS");
- paths.push_back(
- "/Developer/Applications"
- "/PackageMaker.app/Contents/MacOS");
+ paths.push_back("/Applications/Xcode.app/Contents/Applications"
+ "/PackageMaker.app/Contents/MacOS");
+ paths.push_back("/Applications/Utilities"
+ "/PackageMaker.app/Contents/MacOS");
+ paths.push_back("/Applications"
+ "/PackageMaker.app/Contents/MacOS");
+ paths.push_back("/Developer/Applications/Utilities"
+ "/PackageMaker.app/Contents/MacOS");
+ paths.push_back("/Developer/Applications"
+ "/PackageMaker.app/Contents/MacOS");
std::string pkgPath;
- const char *inst_program = this->GetOption("CPACK_INSTALLER_PROGRAM");
- if (inst_program && *inst_program)
- {
+ const char* inst_program = this->GetOption("CPACK_INSTALLER_PROGRAM");
+ if (inst_program && *inst_program) {
pkgPath = inst_program;
- }
- else
- {
+ } else {
pkgPath = cmSystemTools::FindProgram("PackageMaker", paths, false);
- if ( pkgPath.empty() )
- {
+ if (pkgPath.empty()) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find PackageMaker compiler"
- << std::endl);
+ << std::endl);
return 0;
- }
- this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM", pkgPath.c_str());
}
+ this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM", pkgPath.c_str());
+ }
// Get path to the real PackageMaker, not a symlink:
pkgPath = cmSystemTools::GetRealPath(pkgPath.c_str());
@@ -461,100 +396,85 @@ int cmCPackPackageMakerGenerator::InitializeInternal()
std::string versionFile = contents_dir + "/version.plist";
- if ( !cmSystemTools::FileExists(versionFile.c_str()) )
- {
+ if (!cmSystemTools::FileExists(versionFile.c_str())) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Cannot find PackageMaker compiler version file: "
- << versionFile.c_str()
- << std::endl);
+ "Cannot find PackageMaker compiler version file: "
+ << versionFile.c_str() << std::endl);
return 0;
- }
+ }
cmsys::ifstream ifs(versionFile.c_str());
- if ( !ifs )
- {
+ if (!ifs) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Cannot open PackageMaker compiler version file" << std::endl);
+ "Cannot open PackageMaker compiler version file"
+ << std::endl);
return 0;
- }
+ }
// Check the PackageMaker version
cmsys::RegularExpression rexKey("<key>CFBundleShortVersionString</key>");
cmsys::RegularExpression rexVersion("<string>([0-9]+.[0-9.]+)</string>");
std::string line;
bool foundKey = false;
- while ( cmSystemTools::GetLineFromStream(ifs, line) )
- {
- if ( rexKey.find(line) )
- {
+ while (cmSystemTools::GetLineFromStream(ifs, line)) {
+ if (rexKey.find(line)) {
foundKey = true;
break;
- }
}
- if ( !foundKey )
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
+ }
+ if (!foundKey) {
+ cmCPackLogger(
+ cmCPackLog::LOG_ERROR,
"Cannot find CFBundleShortVersionString in the PackageMaker compiler "
- "version file" << std::endl);
+ "version file"
+ << std::endl);
return 0;
- }
- if ( !cmSystemTools::GetLineFromStream(ifs, line) ||
- !rexVersion.find(line) )
- {
+ }
+ if (!cmSystemTools::GetLineFromStream(ifs, line) || !rexVersion.find(line)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Problem reading the PackageMaker compiler version file: "
- << versionFile.c_str() << std::endl);
+ "Problem reading the PackageMaker compiler version file: "
+ << versionFile.c_str() << std::endl);
return 0;
- }
+ }
this->PackageMakerVersion = atof(rexVersion.match(1).c_str());
- if ( this->PackageMakerVersion < 1.0 )
- {
+ if (this->PackageMakerVersion < 1.0) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Require PackageMaker 1.0 or higher"
- << std::endl);
+ << std::endl);
return 0;
- }
+ }
cmCPackLogger(cmCPackLog::LOG_DEBUG, "PackageMaker version is: "
- << this->PackageMakerVersion << std::endl);
+ << this->PackageMakerVersion << std::endl);
// Determine the package compatibility version. If it wasn't
// specified by the user, we define it based on which features the
// user requested.
- const char *packageCompat = this->GetOption("CPACK_OSX_PACKAGE_VERSION");
- if (packageCompat && *packageCompat)
- {
+ const char* packageCompat = this->GetOption("CPACK_OSX_PACKAGE_VERSION");
+ if (packageCompat && *packageCompat) {
unsigned int majorVersion = 10;
unsigned int minorVersion = 5;
int res = sscanf(packageCompat, "%u.%u", &majorVersion, &minorVersion);
- if (res == 2)
- {
+ if (res == 2) {
this->PackageCompatibilityVersion =
getVersion(majorVersion, minorVersion);
- }
}
- else if (this->GetOption("CPACK_DOWNLOAD_SITE"))
- {
+ } else if (this->GetOption("CPACK_DOWNLOAD_SITE")) {
this->SetOption("CPACK_OSX_PACKAGE_VERSION", "10.5");
this->PackageCompatibilityVersion = getVersion(10, 5);
- }
- else if (this->GetOption("CPACK_COMPONENTS_ALL"))
- {
+ } else if (this->GetOption("CPACK_COMPONENTS_ALL")) {
this->SetOption("CPACK_OSX_PACKAGE_VERSION", "10.4");
this->PackageCompatibilityVersion = getVersion(10, 4);
- }
- else
- {
+ } else {
this->SetOption("CPACK_OSX_PACKAGE_VERSION", "10.3");
this->PackageCompatibilityVersion = getVersion(10, 3);
- }
+ }
std::vector<std::string> no_paths;
pkgPath = cmSystemTools::FindProgram("hdiutil", no_paths, false);
- if ( pkgPath.empty() )
- {
+ if (pkgPath.empty()) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find hdiutil compiler"
- << std::endl);
+ << std::endl);
return 0;
- }
+ }
this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM_DISK_IMAGE",
pkgPath.c_str());
@@ -562,36 +482,34 @@ int cmCPackPackageMakerGenerator::InitializeInternal()
}
bool cmCPackPackageMakerGenerator::CopyCreateResourceFile(
- const std::string& name,
- const std::string& dirName)
+ const std::string& name, const std::string& dirName)
{
std::string uname = cmSystemTools::UpperCase(name);
std::string cpackVar = "CPACK_RESOURCE_FILE_" + uname;
const char* inFileName = this->GetOption(cpackVar.c_str());
- if ( !inFileName )
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "CPack option: " << cpackVar.c_str()
- << " not specified. It should point to "
- << (!name.empty() ? name : "<empty>")
- << ".rtf, " << name
- << ".html, or " << name << ".txt file" << std::endl);
+ if (!inFileName) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "CPack option: "
+ << cpackVar.c_str()
+ << " not specified. It should point to "
+ << (!name.empty() ? name : "<empty>") << ".rtf, " << name
+ << ".html, or " << name << ".txt file" << std::endl);
return false;
- }
- if ( !cmSystemTools::FileExists(inFileName) )
- {
+ }
+ if (!cmSystemTools::FileExists(inFileName)) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find "
- << (!name.empty() ? name : "<empty>")
- << " resource file: " << inFileName << std::endl);
+ << (!name.empty() ? name : "<empty>")
+ << " resource file: " << inFileName << std::endl);
return false;
- }
+ }
std::string ext = cmSystemTools::GetFilenameLastExtension(inFileName);
- if ( ext != ".rtfd" && ext != ".rtf" && ext != ".html" && ext != ".txt" )
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Bad file extension specified: "
- << ext << ". Currently only .rtfd, .rtf, .html, and .txt files allowed."
- << std::endl);
+ if (ext != ".rtfd" && ext != ".rtf" && ext != ".html" && ext != ".txt") {
+ cmCPackLogger(
+ cmCPackLog::LOG_ERROR, "Bad file extension specified: "
+ << ext
+ << ". Currently only .rtfd, .rtf, .html, and .txt files allowed."
+ << std::endl);
return false;
- }
+ }
std::string destFileName = dirName;
destFileName += '/';
@@ -603,44 +521,42 @@ bool cmCPackPackageMakerGenerator::CopyCreateResourceFile(
(name + ext).c_str());
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: "
- << (inFileName ? inFileName : "(NULL)")
- << " to " << destFileName.c_str() << std::endl);
+ << (inFileName ? inFileName : "(NULL)") << " to "
+ << destFileName.c_str() << std::endl);
this->ConfigureFile(inFileName, destFileName.c_str());
return true;
}
bool cmCPackPackageMakerGenerator::CopyResourcePlistFile(
- const std::string& name,
- const char* outName)
+ const std::string& name, const char* outName)
{
- if (!outName)
- {
+ if (!outName) {
outName = name.c_str();
- }
+ }
std::string inFName = "CPack.";
inFName += name;
inFName += ".in";
std::string inFileName = this->FindTemplate(inFName.c_str());
- if ( inFileName.empty() )
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find input file: "
- << inFName << std::endl);
+ if (inFileName.empty()) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Cannot find input file: " << inFName << std::endl);
return false;
- }
+ }
std::string destFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
destFileName += "/";
destFileName += outName;
- cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: "
- << inFileName.c_str() << " to " << destFileName.c_str() << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE,
+ "Configure file: " << inFileName.c_str() << " to "
+ << destFileName.c_str() << std::endl);
this->ConfigureFile(inFileName.c_str(), destFileName.c_str());
return true;
}
-bool cmCPackPackageMakerGenerator::RunPackageMaker(const char *command,
- const char *packageFile)
+bool cmCPackPackageMakerGenerator::RunPackageMaker(const char* command,
+ const char* packageFile)
{
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
tmpFile += "/PackageMakerOutput.log";
@@ -649,78 +565,65 @@ bool cmCPackPackageMakerGenerator::RunPackageMaker(const char *command,
std::string output;
int retVal = 1;
bool res = cmSystemTools::RunSingleCommand(
- command, &output, &output,
- &retVal, 0, this->GeneratorVerbose, 0);
+ command, &output, &output, &retVal, 0, this->GeneratorVerbose, 0);
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Done running package maker"
- << std::endl);
- if ( !res || retVal )
- {
+ << std::endl);
+ if (!res || retVal) {
cmGeneratedFileStream ofs(tmpFile.c_str());
ofs << "# Run command: " << command << std::endl
- << "# Output:" << std::endl
- << output.c_str() << std::endl;
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Problem running PackageMaker command: " << command
- << std::endl << "Please check " << tmpFile.c_str() << " for errors"
- << std::endl);
+ << "# Output:" << std::endl
+ << output.c_str() << std::endl;
+ cmCPackLogger(
+ cmCPackLog::LOG_ERROR, "Problem running PackageMaker command: "
+ << command << std::endl
+ << "Please check " << tmpFile.c_str() << " for errors" << std::endl);
return false;
- }
+ }
// sometimes the command finishes but the directory is not yet
// created, so try 10 times to see if it shows up
int tries = 10;
- while(tries > 0 &&
- !cmSystemTools::FileExists(packageFile))
- {
+ while (tries > 0 && !cmSystemTools::FileExists(packageFile)) {
cmSystemTools::Delay(500);
tries--;
- }
- if(!cmSystemTools::FileExists(packageFile))
- {
- cmCPackLogger(
- cmCPackLog::LOG_ERROR,
- "Problem running PackageMaker command: " << command
- << std::endl << "Package not created: " << packageFile
- << std::endl);
+ }
+ if (!cmSystemTools::FileExists(packageFile)) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Problem running PackageMaker command: "
+ << command << std::endl
+ << "Package not created: " << packageFile << std::endl);
return false;
- }
+ }
return true;
}
-std::string
-cmCPackPackageMakerGenerator::GetPackageName(const cmCPackComponent& component)
+std::string cmCPackPackageMakerGenerator::GetPackageName(
+ const cmCPackComponent& component)
{
- if (component.ArchiveFile.empty())
- {
+ if (component.ArchiveFile.empty()) {
std::string packagesDir = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
packagesDir += ".dummy";
std::ostringstream out;
- out << cmSystemTools::GetFilenameWithoutLastExtension(packagesDir)
- << "-" << component.Name << ".pkg";
+ out << cmSystemTools::GetFilenameWithoutLastExtension(packagesDir) << "-"
+ << component.Name << ".pkg";
return out.str();
- }
- else
- {
+ } else {
return component.ArchiveFile + ".pkg";
- }
+ }
}
-bool
-cmCPackPackageMakerGenerator::
-GenerateComponentPackage(const char *packageFile,
- const char *packageDir,
- const cmCPackComponent& component)
+bool cmCPackPackageMakerGenerator::GenerateComponentPackage(
+ const char* packageFile, const char* packageDir,
+ const cmCPackComponent& component)
{
- cmCPackLogger(cmCPackLog::LOG_OUTPUT,
- "- Building component package: " <<
- packageFile << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Building component package: "
+ << packageFile << std::endl);
// The command that will be used to run PackageMaker
std::ostringstream pkgCmd;
if (this->PackageCompatibilityVersion < getVersion(10, 5) ||
- this->PackageMakerVersion < 3.0)
- {
+ this->PackageMakerVersion < 3.0) {
// Create Description.plist and Info.plist files for normal Mac OS
// X packages, which work on Mac OS X 10.3 and newer.
std::string descriptionFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
@@ -750,20 +653,17 @@ GenerateComponentPackage(const char *packageFile,
moduleVersionSuffix.c_str());
std::string infoFileName = component.Name;
infoFileName += "-Info.plist";
- if (!this->CopyResourcePlistFile("Info.plist", infoFileName.c_str()))
- {
+ if (!this->CopyResourcePlistFile("Info.plist", infoFileName.c_str())) {
return false;
- }
+ }
pkgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM")
<< "\" -build -p \"" << packageFile << "\""
<< " -f \"" << packageDir << "\""
- << " -i \"" << this->GetOption("CPACK_TOPLEVEL_DIRECTORY")
- << "/" << infoFileName << "\""
+ << " -i \"" << this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "/"
+ << infoFileName << "\""
<< " -d \"" << descriptionFile << "\"";
- }
- else
- {
+ } else {
// Create a "flat" package on Mac OS X 10.5 and newer. Flat
// packages are stored in a single file, rather than a directory
// like normal packages, and can be downloaded by the installer
@@ -778,27 +678,25 @@ GenerateComponentPackage(const char *packageFile,
pkgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM")
<< "\" --root \"" << packageDir << "\""
- << " --id " << pkgId
- << " --target " << this->GetOption("CPACK_OSX_PACKAGE_VERSION")
- << " --out \"" << packageFile << "\"";
- }
+ << " --id " << pkgId << " --target "
+ << this->GetOption("CPACK_OSX_PACKAGE_VERSION") << " --out \""
+ << packageFile << "\"";
+ }
// Run PackageMaker
return RunPackageMaker(pkgCmd.str().c_str(), packageFile);
}
-void
-cmCPackPackageMakerGenerator::
-WriteDistributionFile(const char* metapackageFile)
+void cmCPackPackageMakerGenerator::WriteDistributionFile(
+ const char* metapackageFile)
{
- std::string distributionTemplate
- = this->FindTemplate("CPack.distribution.dist.in");
- if ( distributionTemplate.empty() )
- {
+ std::string distributionTemplate =
+ this->FindTemplate("CPack.distribution.dist.in");
+ if (distributionTemplate.empty()) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find input file: "
- << distributionTemplate << std::endl);
+ << distributionTemplate << std::endl);
return;
- }
+ }
std::string distributionFile = metapackageFile;
distributionFile += "/Contents/distribution.dist";
@@ -811,102 +709,83 @@ WriteDistributionFile(const char* metapackageFile)
// Emit the outline for the groups
std::map<std::string, cmCPackComponentGroup>::iterator groupIt;
for (groupIt = this->ComponentGroups.begin();
- groupIt != this->ComponentGroups.end();
- ++groupIt)
- {
- if (groupIt->second.ParentGroup == 0)
- {
+ groupIt != this->ComponentGroups.end(); ++groupIt) {
+ if (groupIt->second.ParentGroup == 0) {
CreateChoiceOutline(groupIt->second, choiceOut);
- }
}
+ }
// Emit the outline for the non-grouped components
std::map<std::string, cmCPackComponent>::iterator compIt;
for (compIt = this->Components.begin(); compIt != this->Components.end();
- ++compIt)
- {
- if (!compIt->second.Group)
- {
+ ++compIt) {
+ if (!compIt->second.Group) {
choiceOut << "<line choice=\"" << compIt->first << "Choice\"></line>"
<< std::endl;
- }
- }
- if(!this->PostFlightComponent.Name.empty())
- {
- choiceOut << "<line choice=\"" << PostFlightComponent.Name
- << "Choice\"></line>" << std::endl;
}
+ }
+ if (!this->PostFlightComponent.Name.empty()) {
+ choiceOut << "<line choice=\"" << PostFlightComponent.Name
+ << "Choice\"></line>" << std::endl;
+ }
choiceOut << "</choices-outline>" << std::endl;
// Create the actual choices
for (groupIt = this->ComponentGroups.begin();
- groupIt != this->ComponentGroups.end();
- ++groupIt)
- {
+ groupIt != this->ComponentGroups.end(); ++groupIt) {
CreateChoice(groupIt->second, choiceOut);
- }
+ }
for (compIt = this->Components.begin(); compIt != this->Components.end();
- ++compIt)
- {
+ ++compIt) {
CreateChoice(compIt->second, choiceOut);
- }
+ }
- if(!this->PostFlightComponent.Name.empty())
- {
+ if (!this->PostFlightComponent.Name.empty()) {
CreateChoice(PostFlightComponent, choiceOut);
- }
+ }
this->SetOption("CPACK_PACKAGEMAKER_CHOICES", choiceOut.str().c_str());
// Create the distribution.dist file in the metapackage to turn it
// into a distribution package.
- this->ConfigureFile(distributionTemplate.c_str(),
- distributionFile.c_str());
+ this->ConfigureFile(distributionTemplate.c_str(), distributionFile.c_str());
}
-void
-cmCPackPackageMakerGenerator::
-CreateChoiceOutline(const cmCPackComponentGroup& group,
- std::ostringstream& out)
+void cmCPackPackageMakerGenerator::CreateChoiceOutline(
+ const cmCPackComponentGroup& group, std::ostringstream& out)
{
out << "<line choice=\"" << group.Name << "Choice\">" << std::endl;
std::vector<cmCPackComponentGroup*>::const_iterator groupIt;
for (groupIt = group.Subgroups.begin(); groupIt != group.Subgroups.end();
- ++groupIt)
- {
+ ++groupIt) {
CreateChoiceOutline(**groupIt, out);
- }
+ }
std::vector<cmCPackComponent*>::const_iterator compIt;
for (compIt = group.Components.begin(); compIt != group.Components.end();
- ++compIt)
- {
+ ++compIt) {
out << " <line choice=\"" << (*compIt)->Name << "Choice\"></line>"
<< std::endl;
- }
+ }
out << "</line>" << std::endl;
}
-void
-cmCPackPackageMakerGenerator::CreateChoice(const cmCPackComponentGroup& group,
- std::ostringstream& out)
+void cmCPackPackageMakerGenerator::CreateChoice(
+ const cmCPackComponentGroup& group, std::ostringstream& out)
{
out << "<choice id=\"" << group.Name << "Choice\" "
<< "title=\"" << group.DisplayName << "\" "
<< "start_selected=\"true\" "
<< "start_enabled=\"true\" "
<< "start_visible=\"true\" ";
- if (!group.Description.empty())
- {
- out << "description=\"" << EscapeForXML(group.Description)
- << "\"";
- }
+ if (!group.Description.empty()) {
+ out << "description=\"" << EscapeForXML(group.Description) << "\"";
+ }
out << "></choice>" << std::endl;
}
-void
-cmCPackPackageMakerGenerator::CreateChoice(const cmCPackComponent& component,
- std::ostringstream& out)
+void cmCPackPackageMakerGenerator::CreateChoice(
+ const cmCPackComponent& component, std::ostringstream& out)
{
std::string packageId = "com.";
packageId += this->GetOption("CPACK_PACKAGE_VENDOR");
@@ -918,21 +797,18 @@ cmCPackPackageMakerGenerator::CreateChoice(const cmCPackComponent& component,
out << "<choice id=\"" << component.Name << "Choice\" "
<< "title=\"" << component.DisplayName << "\" "
<< "start_selected=\""
- << (component.IsDisabledByDefault &&
- !component.IsRequired? "false" : "true")
+ << (component.IsDisabledByDefault && !component.IsRequired ? "false"
+ : "true")
<< "\" "
- << "start_enabled=\""
- << (component.IsRequired? "false" : "true")
+ << "start_enabled=\"" << (component.IsRequired ? "false" : "true")
<< "\" "
- << "start_visible=\"" << (component.IsHidden? "false" : "true") << "\" ";
- if (!component.Description.empty())
- {
- out << "description=\"" << EscapeForXML(component.Description)
- << "\" ";
- }
+ << "start_visible=\"" << (component.IsHidden ? "false" : "true")
+ << "\" ";
+ if (!component.Description.empty()) {
+ out << "description=\"" << EscapeForXML(component.Description) << "\" ";
+ }
if (!component.Dependencies.empty() ||
- !component.ReverseDependencies.empty())
- {
+ !component.ReverseDependencies.empty()) {
// The "selected" expression is evaluated each time any choice is
// selected, for all choices *except* the one that the user
// selected. A component is marked selected if it has been
@@ -948,12 +824,12 @@ cmCPackPackageMakerGenerator::CreateChoice(const cmCPackComponent& component,
// on (B and A), while selecting something that depends on C--either D
// or E--will automatically cause C to get selected.
out << "selected=\"my.choice.selected";
- std::set<const cmCPackComponent *> visited;
+ std::set<const cmCPackComponent*> visited;
AddDependencyAttributes(component, visited, out);
visited.clear();
AddReverseDependencyAttributes(component, visited, out);
out << "\"";
- }
+ }
out << ">" << std::endl;
out << " <pkg-ref id=\"" << packageId << "\"></pkg-ref>" << std::endl;
out << "</choice>" << std::endl;
@@ -968,68 +844,54 @@ cmCPackPackageMakerGenerator::CreateChoice(const cmCPackComponent& component,
dirName += '/';
dirName += component.Name;
dirName += this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX");
- unsigned long installedSize
- = component.GetInstalledSizeInKbytes(dirName.c_str());
+ unsigned long installedSize =
+ component.GetInstalledSizeInKbytes(dirName.c_str());
out << "<pkg-ref id=\"" << packageId << "\" "
<< "version=\"" << this->GetOption("CPACK_PACKAGE_VERSION") << "\" "
<< "installKBytes=\"" << installedSize << "\" "
<< "auth=\"Admin\" onConclusion=\"None\">";
- if (component.IsDownloaded)
- {
+ if (component.IsDownloaded) {
out << this->GetOption("CPACK_DOWNLOAD_SITE")
<< this->GetPackageName(component);
- }
- else
- {
+ } else {
out << "file:./" << relativePackageLocation;
- }
+ }
out << "</pkg-ref>" << std::endl;
}
-void
-cmCPackPackageMakerGenerator::
-AddDependencyAttributes(const cmCPackComponent& component,
- std::set<const cmCPackComponent *>& visited,
- std::ostringstream& out)
+void cmCPackPackageMakerGenerator::AddDependencyAttributes(
+ const cmCPackComponent& component,
+ std::set<const cmCPackComponent*>& visited, std::ostringstream& out)
{
- if (visited.find(&component) != visited.end())
- {
+ if (visited.find(&component) != visited.end()) {
return;
- }
+ }
visited.insert(&component);
- std::vector<cmCPackComponent *>::const_iterator dependIt;
+ std::vector<cmCPackComponent*>::const_iterator dependIt;
for (dependIt = component.Dependencies.begin();
- dependIt != component.Dependencies.end();
- ++dependIt)
- {
- out << " &amp;&amp; choices['" <<
- (*dependIt)->Name << "Choice'].selected";
+ dependIt != component.Dependencies.end(); ++dependIt) {
+ out << " &amp;&amp; choices['" << (*dependIt)->Name << "Choice'].selected";
AddDependencyAttributes(**dependIt, visited, out);
- }
+ }
}
-void
-cmCPackPackageMakerGenerator::
-AddReverseDependencyAttributes(const cmCPackComponent& component,
- std::set<const cmCPackComponent *>& visited,
- std::ostringstream& out)
+void cmCPackPackageMakerGenerator::AddReverseDependencyAttributes(
+ const cmCPackComponent& component,
+ std::set<const cmCPackComponent*>& visited, std::ostringstream& out)
{
- if (visited.find(&component) != visited.end())
- {
+ if (visited.find(&component) != visited.end()) {
return;
- }
+ }
visited.insert(&component);
- std::vector<cmCPackComponent *>::const_iterator dependIt;
+ std::vector<cmCPackComponent*>::const_iterator dependIt;
for (dependIt = component.ReverseDependencies.begin();
- dependIt != component.ReverseDependencies.end();
- ++dependIt)
- {
+ dependIt != component.ReverseDependencies.end(); ++dependIt) {
out << " || choices['" << (*dependIt)->Name << "Choice'].selected";
AddReverseDependencyAttributes(**dependIt, visited, out);
- }
+ }
}
std::string cmCPackPackageMakerGenerator::EscapeForXML(std::string str)
diff --git a/Source/CPack/cmCPackPackageMakerGenerator.h b/Source/CPack/cmCPackPackageMakerGenerator.h
index 4e8ff03..2b8d253 100644
--- a/Source/CPack/cmCPackPackageMakerGenerator.h
+++ b/Source/CPack/cmCPackPackageMakerGenerator.h
@@ -37,8 +37,7 @@ public:
virtual bool SupportsComponentInstallation() const;
protected:
- int CopyInstallScript(const std::string& resdir,
- const std::string& script,
+ int CopyInstallScript(const std::string& resdir, const std::string& script,
const std::string& name);
virtual int InitializeInternal();
int PackageFiles();
@@ -57,7 +56,7 @@ protected:
// Run PackageMaker with the given command line, which will (if
// successful) produce the given package file. Returns true if
// PackageMaker succeeds, false otherwise.
- bool RunPackageMaker(const char *command, const char *packageFile);
+ bool RunPackageMaker(const char* command, const char* packageFile);
// Retrieve the name of package file that will be generated for this
// component. The name is just the file name with extension, and
@@ -68,8 +67,8 @@ protected:
// component. All of the files within this component are stored in
// the directory packageDir. Returns true if successful, false
// otherwise.
- bool GenerateComponentPackage(const char *packageFile,
- const char *packageDir,
+ bool GenerateComponentPackage(const char* packageFile,
+ const char* packageDir,
const cmCPackComponent& component);
// Writes a distribution.dist file, which turns a metapackage into a
@@ -82,15 +81,14 @@ protected:
// Subroutine of WriteDistributionFile that writes out the
// dependency attributes for inter-component dependencies.
void AddDependencyAttributes(const cmCPackComponent& component,
- std::set<const cmCPackComponent *>& visited,
+ std::set<const cmCPackComponent*>& visited,
std::ostringstream& out);
// Subroutine of WriteDistributionFile that writes out the
// reverse dependency attributes for inter-component dependencies.
- void
- AddReverseDependencyAttributes(const cmCPackComponent& component,
- std::set<const cmCPackComponent *>& visited,
- std::ostringstream& out);
+ void AddReverseDependencyAttributes(
+ const cmCPackComponent& component,
+ std::set<const cmCPackComponent*>& visited, std::ostringstream& out);
// Generates XML that encodes the hierarchy of component groups and
// their components in a form that can be used by distribution
diff --git a/Source/CPack/cmCPackRPMGenerator.cxx b/Source/CPack/cmCPackRPMGenerator.cxx
index 2640404..fc6603a 100644
--- a/Source/CPack/cmCPackRPMGenerator.cxx
+++ b/Source/CPack/cmCPackRPMGenerator.cxx
@@ -25,24 +25,23 @@ cmCPackRPMGenerator::~cmCPackRPMGenerator()
int cmCPackRPMGenerator::InitializeInternal()
{
this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr");
- if (cmSystemTools::IsOff(this->GetOption("CPACK_SET_DESTDIR")))
- {
+ if (cmSystemTools::IsOff(this->GetOption("CPACK_SET_DESTDIR"))) {
this->SetOption("CPACK_SET_DESTDIR", "I_ON");
- }
+ }
/* Replace space in CPACK_PACKAGE_NAME in order to avoid
* rpmbuild scream on unwanted space in filename issue
* Moreover RPM file do not usually embed space in filename
*/
if (this->GetOption("CPACK_PACKAGE_NAME")) {
- std::string packageName=this->GetOption("CPACK_PACKAGE_NAME");
- cmSystemTools::ReplaceString(packageName," ","-");
- this->SetOption("CPACK_PACKAGE_NAME",packageName.c_str());
+ std::string packageName = this->GetOption("CPACK_PACKAGE_NAME");
+ cmSystemTools::ReplaceString(packageName, " ", "-");
+ this->SetOption("CPACK_PACKAGE_NAME", packageName.c_str());
}
/* same for CPACK_PACKAGE_FILE_NAME */
if (this->GetOption("CPACK_PACKAGE_FILE_NAME")) {
- std::string packageName=this->GetOption("CPACK_PACKAGE_FILE_NAME");
- cmSystemTools::ReplaceString(packageName," ","-");
- this->SetOption("CPACK_PACKAGE_FILE_NAME",packageName.c_str());
+ std::string packageName = this->GetOption("CPACK_PACKAGE_FILE_NAME");
+ cmSystemTools::ReplaceString(packageName, " ", "-");
+ this->SetOption("CPACK_PACKAGE_FILE_NAME", packageName.c_str());
}
return this->Superclass::InitializeInternal();
}
@@ -53,14 +52,13 @@ void cmCPackRPMGenerator::AddGeneratedPackageNames()
std::string fileNames(this->GetOption("GEN_CPACK_OUTPUT_FILES"));
const char sep = ';';
std::string::size_type pos1 = 0;
- std::string::size_type pos2 = fileNames.find(sep, pos1+1);
- while(pos2 != std::string::npos)
- {
- packageFileNames.push_back(fileNames.substr(pos1, pos2-pos1));
- pos1 = pos2+1;
- pos2 = fileNames.find(sep, pos1+1);
- }
- packageFileNames.push_back(fileNames.substr(pos1, pos2-pos1));
+ std::string::size_type pos2 = fileNames.find(sep, pos1 + 1);
+ while (pos2 != std::string::npos) {
+ packageFileNames.push_back(fileNames.substr(pos1, pos2 - pos1));
+ pos1 = pos2 + 1;
+ pos2 = fileNames.find(sep, pos1 + 1);
+ }
+ packageFileNames.push_back(fileNames.substr(pos1, pos2 - pos1));
}
int cmCPackRPMGenerator::PackageOnePack(std::string initialToplevel,
@@ -69,38 +67,33 @@ int cmCPackRPMGenerator::PackageOnePack(std::string initialToplevel,
int retval = 1;
// Begin the archive for this pack
std::string localToplevel(initialToplevel);
- std::string packageFileName(
- cmSystemTools::GetParentDirectory(toplevel)
- );
+ std::string packageFileName(cmSystemTools::GetParentDirectory(toplevel));
std::string outputFileName(
- GetComponentPackageFileName(this->GetOption("CPACK_PACKAGE_FILE_NAME"),
- packageName,
- true)
- + this->GetOutputExtension()
- );
+ GetComponentPackageFileName(this->GetOption("CPACK_PACKAGE_FILE_NAME"),
+ packageName, true) +
+ this->GetOutputExtension());
- localToplevel += "/"+ packageName;
+ localToplevel += "/" + packageName;
/* replace the TEMP DIRECTORY with the component one */
- this->SetOption("CPACK_TEMPORARY_DIRECTORY",localToplevel.c_str());
- packageFileName += "/"+ outputFileName;
+ this->SetOption("CPACK_TEMPORARY_DIRECTORY", localToplevel.c_str());
+ packageFileName += "/" + outputFileName;
/* replace proposed CPACK_OUTPUT_FILE_NAME */
- this->SetOption("CPACK_OUTPUT_FILE_NAME",outputFileName.c_str());
+ this->SetOption("CPACK_OUTPUT_FILE_NAME", outputFileName.c_str());
/* replace the TEMPORARY package file name */
this->SetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME",
packageFileName.c_str());
// Tell CPackRPM.cmake the name of the component NAME.
- this->SetOption("CPACK_RPM_PACKAGE_COMPONENT",packageName.c_str());
+ this->SetOption("CPACK_RPM_PACKAGE_COMPONENT", packageName.c_str());
// Tell CPackRPM.cmake the path where the component is.
std::string component_path = "/";
component_path += packageName;
this->SetOption("CPACK_RPM_PACKAGE_COMPONENT_PART_PATH",
component_path.c_str());
- if (!this->ReadListFile("CPackRPM.cmake"))
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error while execution CPackRPM.cmake" << std::endl);
+ if (!this->ReadListFile("CPackRPM.cmake")) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Error while execution CPackRPM.cmake"
+ << std::endl);
retval = 0;
- }
+ }
return retval;
}
@@ -115,56 +108,48 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup)
// The default behavior is to have one package by component group
// unless CPACK_COMPONENTS_IGNORE_GROUP is specified.
- if (!ignoreGroup)
- {
+ if (!ignoreGroup) {
std::map<std::string, cmCPackComponentGroup>::iterator compGIt;
- for (compGIt=this->ComponentGroups.begin();
- compGIt!=this->ComponentGroups.end(); ++compGIt)
- {
+ for (compGIt = this->ComponentGroups.begin();
+ compGIt != this->ComponentGroups.end(); ++compGIt) {
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: "
- << compGIt->first
- << std::endl);
- retval &= PackageOnePack(initialTopLevel,compGIt->first);
- }
+ << compGIt->first << std::endl);
+ retval &= PackageOnePack(initialTopLevel, compGIt->first);
+ }
// Handle Orphan components (components not belonging to any groups)
std::map<std::string, cmCPackComponent>::iterator compIt;
- for (compIt=this->Components.begin();
- compIt!=this->Components.end(); ++compIt )
- {
+ for (compIt = this->Components.begin(); compIt != this->Components.end();
+ ++compIt) {
// Does the component belong to a group?
- if (compIt->second.Group==NULL)
- {
- cmCPackLogger(cmCPackLog::LOG_VERBOSE,
- "Component <"
+ if (compIt->second.Group == NULL) {
+ cmCPackLogger(
+ cmCPackLog::LOG_VERBOSE, "Component <"
<< compIt->second.Name
<< "> does not belong to any group, package it separately."
<< std::endl);
- retval &= PackageOnePack(initialTopLevel,compIt->first);
- }
+ retval &= PackageOnePack(initialTopLevel, compIt->first);
}
}
+ }
// CPACK_COMPONENTS_IGNORE_GROUPS is set
// We build 1 package per component
- else
- {
+ else {
std::map<std::string, cmCPackComponent>::iterator compIt;
- for (compIt=this->Components.begin();
- compIt!=this->Components.end(); ++compIt )
- {
- retval &= PackageOnePack(initialTopLevel,compIt->first);
- }
+ for (compIt = this->Components.begin(); compIt != this->Components.end();
+ ++compIt) {
+ retval &= PackageOnePack(initialTopLevel, compIt->first);
}
+ }
- if(retval)
- {
+ if (retval) {
AddGeneratedPackageNames();
- }
+ }
return retval;
}
int cmCPackRPMGenerator::PackageComponentsAllInOne(
- const std::string& compInstDirName)
+ const std::string& compInstDirName)
{
int retval = 1;
/* Reset package file name list it will be populated during the
@@ -175,98 +160,84 @@ int cmCPackRPMGenerator::PackageComponentsAllInOne(
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
"Packaging all groups in one package..."
"(CPACK_COMPONENTS_ALL_[GROUPS_]IN_ONE_PACKAGE is set)"
- << std::endl);
+ << std::endl);
// The ALL GROUPS in ONE package case
std::string localToplevel(initialTopLevel);
- std::string packageFileName(
- cmSystemTools::GetParentDirectory(toplevel)
- );
+ std::string packageFileName(cmSystemTools::GetParentDirectory(toplevel));
std::string outputFileName(
- std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME"))
- + this->GetOutputExtension()
- );
+ std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) +
+ this->GetOutputExtension());
// all GROUP in one vs all COMPONENT in one
- localToplevel += "/"+compInstDirName;
+ localToplevel += "/" + compInstDirName;
/* replace the TEMP DIRECTORY with the component one */
- this->SetOption("CPACK_TEMPORARY_DIRECTORY",localToplevel.c_str());
- packageFileName += "/"+ outputFileName;
+ this->SetOption("CPACK_TEMPORARY_DIRECTORY", localToplevel.c_str());
+ packageFileName += "/" + outputFileName;
/* replace proposed CPACK_OUTPUT_FILE_NAME */
- this->SetOption("CPACK_OUTPUT_FILE_NAME",outputFileName.c_str());
+ this->SetOption("CPACK_OUTPUT_FILE_NAME", outputFileName.c_str());
/* replace the TEMPORARY package file name */
this->SetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME",
- packageFileName.c_str());
+ packageFileName.c_str());
- if(!compInstDirName.empty())
- {
+ if (!compInstDirName.empty()) {
// Tell CPackRPM.cmake the path where the component is.
std::string component_path = "/";
component_path += compInstDirName;
this->SetOption("CPACK_RPM_PACKAGE_COMPONENT_PART_PATH",
component_path.c_str());
- }
+ }
- if (this->ReadListFile("CPackRPM.cmake"))
- {
+ if (this->ReadListFile("CPackRPM.cmake")) {
AddGeneratedPackageNames();
- }
- else
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error while execution CPackRPM.cmake" << std::endl);
+ } else {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Error while execution CPackRPM.cmake"
+ << std::endl);
retval = 0;
- }
+ }
return retval;
}
int cmCPackRPMGenerator::PackageFiles()
{
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "Toplevel: "
- << toplevel << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_DEBUG, "Toplevel: " << toplevel << std::endl);
/* Are we in the component packaging case */
if (WantsComponentInstallation()) {
// CASE 1 : COMPONENT ALL-IN-ONE package
// If ALL COMPONENTS in ONE package has been requested
// then the package file is unique and should be open here.
- if (componentPackageMethod == ONE_PACKAGE)
- {
+ if (componentPackageMethod == ONE_PACKAGE) {
return PackageComponentsAllInOne("ALL_COMPONENTS_IN_ONE");
- }
+ }
// CASE 2 : COMPONENT CLASSICAL package(s) (i.e. not all-in-one)
// There will be 1 package for each component group
// however one may require to ignore component group and
// in this case you'll get 1 package for each component.
- else
- {
+ else {
return PackageComponents(componentPackageMethod ==
ONE_PACKAGE_PER_COMPONENT);
- }
+ }
}
// CASE 3 : NON COMPONENT package.
- else
- {
+ else {
return PackageComponentsAllInOne("");
- }
+ }
}
bool cmCPackRPMGenerator::SupportsComponentInstallation() const
- {
- if (IsOn("CPACK_RPM_COMPONENT_INSTALL"))
- {
- return true;
- }
- else
- {
- return false;
- }
+{
+ if (IsOn("CPACK_RPM_COMPONENT_INSTALL")) {
+ return true;
+ } else {
+ return false;
}
+}
std::string cmCPackRPMGenerator::GetComponentInstallDirNameSuffix(
- const std::string& componentName)
- {
+ const std::string& componentName)
+{
if (componentPackageMethod == ONE_PACKAGE_PER_COMPONENT) {
return componentName;
}
@@ -276,14 +247,11 @@ std::string cmCPackRPMGenerator::GetComponentInstallDirNameSuffix(
}
// We have to find the name of the COMPONENT GROUP
// the current COMPONENT belongs to.
- std::string groupVar = "CPACK_COMPONENT_" +
- cmSystemTools::UpperCase(componentName) + "_GROUP";
- if (NULL != GetOption(groupVar))
- {
- return std::string(GetOption(groupVar));
- }
- else
- {
- return componentName;
- }
+ std::string groupVar =
+ "CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP";
+ if (NULL != GetOption(groupVar)) {
+ return std::string(GetOption(groupVar));
+ } else {
+ return componentName;
}
+}
diff --git a/Source/CPack/cmCPackRPMGenerator.h b/Source/CPack/cmCPackRPMGenerator.h
index 9987cf4..40b9bb8 100644
--- a/Source/CPack/cmCPackRPMGenerator.h
+++ b/Source/CPack/cmCPackRPMGenerator.h
@@ -35,7 +35,7 @@ public:
virtual ~cmCPackRPMGenerator();
static bool CanGenerate()
- {
+ {
#ifdef __APPLE__
// on MacOS enable CPackRPM iff rpmbuild is found
std::vector<std::string> locations;
@@ -46,7 +46,7 @@ public:
// legacy behavior on other systems
return true;
#endif
- }
+ }
protected:
virtual int InitializeInternal();
@@ -69,7 +69,7 @@ protected:
virtual const char* GetOutputExtension() { return ".rpm"; }
virtual bool SupportsComponentInstallation() const;
virtual std::string GetComponentInstallDirNameSuffix(
- const std::string& componentName);
+ const std::string& componentName);
void AddGeneratedPackageNames();
};
diff --git a/Source/CPack/cmCPackSTGZGenerator.cxx b/Source/CPack/cmCPackSTGZGenerator.cxx
index 41e67c7..4d07a7e 100644
--- a/Source/CPack/cmCPackSTGZGenerator.cxx
+++ b/Source/CPack/cmCPackSTGZGenerator.cxx
@@ -37,12 +37,11 @@ int cmCPackSTGZGenerator::InitializeInternal()
this->SetOptionIfNotSet("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", "0");
std::string inFile = this->FindTemplate("CPack.STGZ_Header.sh.in");
- if ( inFile.empty() )
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find template file: "
- << inFile << std::endl);
+ if (inFile.empty()) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Cannot find template file: " << inFile << std::endl);
return 0;
- }
+ }
this->SetOptionIfNotSet("CPACK_STGZ_HEADER_FILE", inFile.c_str());
this->SetOptionIfNotSet("CPACK_AT_SIGN", "@");
@@ -51,28 +50,26 @@ int cmCPackSTGZGenerator::InitializeInternal()
int cmCPackSTGZGenerator::PackageFiles()
{
- bool retval = true;
- if ( !this->Superclass::PackageFiles() )
- {
+ bool retval = true;
+ if (!this->Superclass::PackageFiles()) {
return 0;
- }
+ }
/* TGZ generator (our Superclass) may
* have generated several packages (component packaging)
* so we must iterate over generated packages.
*/
- for (std::vector<std::string>::iterator it=packageFileNames.begin();
- it != packageFileNames.end(); ++it)
- {
+ for (std::vector<std::string>::iterator it = packageFileNames.begin();
+ it != packageFileNames.end(); ++it) {
retval &= cmSystemTools::SetPermissions((*it).c_str(),
-#if defined( _MSC_VER ) || defined( __MINGW32__ )
- S_IREAD | S_IWRITE | S_IEXEC
+#if defined(_MSC_VER) || defined(__MINGW32__)
+ S_IREAD | S_IWRITE | S_IEXEC
#else
- S_IRUSR | S_IWUSR | S_IXUSR |
- S_IRGRP | S_IWGRP | S_IXGRP |
- S_IROTH | S_IWOTH | S_IXOTH
+ S_IRUSR | S_IWUSR | S_IXUSR |
+ S_IRGRP | S_IWGRP | S_IXGRP |
+ S_IROTH | S_IWOTH | S_IXOTH
#endif
- );
+ );
}
return retval;
}
@@ -87,10 +84,9 @@ int cmCPackSTGZGenerator::GenerateHeader(std::ostream* os)
std::string line;
cmsys::ifstream ilfs(inLicFile.c_str());
std::string licenseText;
- while ( cmSystemTools::GetLineFromStream(ilfs, line) )
- {
+ while (cmSystemTools::GetLineFromStream(ilfs, line)) {
licenseText += line + "\n";
- }
+ }
this->SetOptionIfNotSet("CPACK_RESOURCE_FILE_LICENSE_CONTENT",
licenseText.c_str());
@@ -100,10 +96,9 @@ int cmCPackSTGZGenerator::GenerateHeader(std::ostream* os)
std::string inFile = this->GetOption("CPACK_STGZ_HEADER_FILE");
cmsys::ifstream ifs(inFile.c_str());
std::string packageHeaderText;
- while ( cmSystemTools::GetLineFromStream(ifs, line) )
- {
+ while (cmSystemTools::GetLineFromStream(ifs, line)) {
packageHeaderText += line + "\n";
- }
+ }
// Configure in the values
std::string res;
@@ -111,17 +106,15 @@ int cmCPackSTGZGenerator::GenerateHeader(std::ostream* os)
// Count the lines
const char* ptr = res.c_str();
- while ( *ptr )
- {
- if ( *ptr == '\n' )
- {
- counter ++;
- }
- ++ptr;
+ while (*ptr) {
+ if (*ptr == '\n') {
+ counter++;
}
- counter ++;
- cmCPackLogger(cmCPackLog::LOG_DEBUG,
- "Number of lines: " << counter << std::endl);
+ ++ptr;
+ }
+ counter++;
+ cmCPackLogger(cmCPackLog::LOG_DEBUG, "Number of lines: " << counter
+ << std::endl);
char buffer[1024];
sprintf(buffer, "%d", counter);
cmSystemTools::ReplaceString(res, headerLengthTag, buffer);
diff --git a/Source/CPack/cmCPackTGZGenerator.cxx b/Source/CPack/cmCPackTGZGenerator.cxx
index 90eb1a3..7c5c245 100644
--- a/Source/CPack/cmCPackTGZGenerator.cxx
+++ b/Source/CPack/cmCPackTGZGenerator.cxx
@@ -13,12 +13,10 @@
#include "cmCPackTGZGenerator.h"
cmCPackTGZGenerator::cmCPackTGZGenerator()
- :cmCPackArchiveGenerator(cmArchiveWrite::CompressGZip,
- "paxr")
+ : cmCPackArchiveGenerator(cmArchiveWrite::CompressGZip, "paxr")
{
}
cmCPackTGZGenerator::~cmCPackTGZGenerator()
{
}
-
diff --git a/Source/CPack/cmCPackTGZGenerator.h b/Source/CPack/cmCPackTGZGenerator.h
index 3a9fc6b..408422b 100644
--- a/Source/CPack/cmCPackTGZGenerator.h
+++ b/Source/CPack/cmCPackTGZGenerator.h
@@ -28,6 +28,7 @@ public:
*/
cmCPackTGZGenerator();
virtual ~cmCPackTGZGenerator();
+
protected:
virtual const char* GetOutputExtension() { return ".tar.gz"; }
};
diff --git a/Source/CPack/cmCPackTXZGenerator.cxx b/Source/CPack/cmCPackTXZGenerator.cxx
index 454e062..d17a164 100644
--- a/Source/CPack/cmCPackTXZGenerator.cxx
+++ b/Source/CPack/cmCPackTXZGenerator.cxx
@@ -13,8 +13,7 @@
#include "cmCPackTXZGenerator.h"
cmCPackTXZGenerator::cmCPackTXZGenerator()
- :cmCPackArchiveGenerator(cmArchiveWrite::CompressXZ,
- "paxr")
+ : cmCPackArchiveGenerator(cmArchiveWrite::CompressXZ, "paxr")
{
}
diff --git a/Source/CPack/cmCPackTXZGenerator.h b/Source/CPack/cmCPackTXZGenerator.h
index bf8152f..05052a1 100644
--- a/Source/CPack/cmCPackTXZGenerator.h
+++ b/Source/CPack/cmCPackTXZGenerator.h
@@ -28,6 +28,7 @@ public:
*/
cmCPackTXZGenerator();
virtual ~cmCPackTXZGenerator();
+
protected:
virtual const char* GetOutputExtension() { return ".tar.xz"; }
};
diff --git a/Source/CPack/cmCPackTarBZip2Generator.cxx b/Source/CPack/cmCPackTarBZip2Generator.cxx
index b05b399..694d392 100644
--- a/Source/CPack/cmCPackTarBZip2Generator.cxx
+++ b/Source/CPack/cmCPackTarBZip2Generator.cxx
@@ -13,12 +13,10 @@
#include "cmCPackTarBZip2Generator.h"
cmCPackTarBZip2Generator::cmCPackTarBZip2Generator()
- :cmCPackArchiveGenerator(cmArchiveWrite::CompressBZip2,
- "paxr")
+ : cmCPackArchiveGenerator(cmArchiveWrite::CompressBZip2, "paxr")
{
}
cmCPackTarBZip2Generator::~cmCPackTarBZip2Generator()
{
}
-
diff --git a/Source/CPack/cmCPackTarBZip2Generator.h b/Source/CPack/cmCPackTarBZip2Generator.h
index 74c244e..4033197 100644
--- a/Source/CPack/cmCPackTarBZip2Generator.h
+++ b/Source/CPack/cmCPackTarBZip2Generator.h
@@ -27,6 +27,7 @@ public:
*/
cmCPackTarBZip2Generator();
virtual ~cmCPackTarBZip2Generator();
+
protected:
virtual const char* GetOutputExtension() { return ".tar.bz2"; }
};
diff --git a/Source/CPack/cmCPackTarCompressGenerator.cxx b/Source/CPack/cmCPackTarCompressGenerator.cxx
index ddfe248..aec6893 100644
--- a/Source/CPack/cmCPackTarCompressGenerator.cxx
+++ b/Source/CPack/cmCPackTarCompressGenerator.cxx
@@ -13,12 +13,10 @@
#include "cmCPackTarCompressGenerator.h"
cmCPackTarCompressGenerator::cmCPackTarCompressGenerator()
- :cmCPackArchiveGenerator(cmArchiveWrite::CompressCompress,
- "paxr")
+ : cmCPackArchiveGenerator(cmArchiveWrite::CompressCompress, "paxr")
{
}
cmCPackTarCompressGenerator::~cmCPackTarCompressGenerator()
{
}
-
diff --git a/Source/CPack/cmCPackZIPGenerator.cxx b/Source/CPack/cmCPackZIPGenerator.cxx
index d316ab6..9b42e6d 100644
--- a/Source/CPack/cmCPackZIPGenerator.cxx
+++ b/Source/CPack/cmCPackZIPGenerator.cxx
@@ -13,12 +13,10 @@
#include "cmCPackZIPGenerator.h"
cmCPackZIPGenerator::cmCPackZIPGenerator()
- :cmCPackArchiveGenerator(cmArchiveWrite::CompressNone,
- "zip")
+ : cmCPackArchiveGenerator(cmArchiveWrite::CompressNone, "zip")
{
}
cmCPackZIPGenerator::~cmCPackZIPGenerator()
{
}
-
diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx
index 6b2323c..e54be2c 100644
--- a/Source/CPack/cpack.cxx
+++ b/Source/CPack/cpack.cxx
@@ -26,33 +26,28 @@
#include <cmsys/Encoding.hxx>
#include <cmsys/SystemTools.hxx>
-static const char * cmDocumentationName[][2] =
-{
- {0,
- " cpack - Packaging driver provided by CMake."},
- {0,0}
+static const char* cmDocumentationName[][2] = {
+ { 0, " cpack - Packaging driver provided by CMake." },
+ { 0, 0 }
};
-static const char * cmDocumentationUsage[][2] =
-{
- {0,
- " cpack -G <generator> [options]"},
- {0,0}
+static const char* cmDocumentationUsage[][2] = {
+ { 0, " cpack -G <generator> [options]" },
+ { 0, 0 }
};
-static const char * cmDocumentationOptions[][2] =
-{
- {"-G <generator>", "Use the specified generator to generate package."},
- {"-C <Configuration>", "Specify the project configuration"},
- {"-D <var>=<value>", "Set a CPack variable."},
- {"--config <config file>", "Specify the config file."},
- {"--verbose,-V","enable verbose output"},
- {"--debug","enable debug output (for CPack developers)"},
- {"-P <package name>","override/define CPACK_PACKAGE_NAME"},
- {"-R <package version>","override/define CPACK_PACKAGE_VERSION"},
- {"-B <package directory>","override/define CPACK_PACKAGE_DIRECTORY"},
- {"--vendor <vendor name>","override/define CPACK_PACKAGE_VENDOR"},
- {0,0}
+static const char* cmDocumentationOptions[][2] = {
+ { "-G <generator>", "Use the specified generator to generate package." },
+ { "-C <Configuration>", "Specify the project configuration" },
+ { "-D <var>=<value>", "Set a CPack variable." },
+ { "--config <config file>", "Specify the config file." },
+ { "--verbose,-V", "enable verbose output" },
+ { "--debug", "enable debug output (for CPack developers)" },
+ { "-P <package name>", "override/define CPACK_PACKAGE_NAME" },
+ { "-R <package version>", "override/define CPACK_PACKAGE_VERSION" },
+ { "-B <package directory>", "override/define CPACK_PACKAGE_DIRECTORY" },
+ { "--vendor <vendor name>", "override/define CPACK_PACKAGE_VENDOR" },
+ { 0, 0 }
};
int cpackUnknownArgument(const char*, void*)
@@ -64,33 +59,31 @@ struct cpackDefinitions
{
typedef std::map<std::string, std::string> MapType;
MapType Map;
- cmCPackLog *Log;
+ cmCPackLog* Log;
};
int cpackDefinitionArgument(const char* argument, const char* cValue,
- void* call_data)
+ void* call_data)
{
(void)argument;
cpackDefinitions* def = static_cast<cpackDefinitions*>(call_data);
std::string value = cValue;
size_t pos = value.find_first_of("=");
- if ( pos == std::string::npos )
- {
+ if (pos == std::string::npos) {
cmCPack_Log(def->Log, cmCPackLog::LOG_ERROR,
- "Please specify CPack definitions as: KEY=VALUE" << std::endl);
+ "Please specify CPack definitions as: KEY=VALUE" << std::endl);
return 0;
- }
+ }
std::string key = value.substr(0, pos);
value = value.c_str() + pos + 1;
def->Map[key] = value;
cmCPack_Log(def->Log, cmCPackLog::LOG_DEBUG, "Set CPack variable: "
- << key << " to \"" << value << "\"" << std::endl);
+ << key << " to \"" << value << "\"" << std::endl);
return 1;
}
-
// this is CPack.
-int main (int argc, char const* const* argv)
+int main(int argc, char const* const* argv)
{
cmsys::Encoding::CommandLineArguments args =
cmsys::Encoding::CommandLineArguments::Main(argc, argv);
@@ -107,12 +100,12 @@ int main (int argc, char const* const* argv)
cmSystemTools::EnableMSVCDebugHook();
- if (cmSystemTools::GetCurrentWorkingDirectory().empty())
- {
+ if (cmSystemTools::GetCurrentWorkingDirectory().empty()) {
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
- "Current working directory cannot be established." << std::endl);
+ "Current working directory cannot be established."
+ << std::endl);
return 1;
- }
+ }
std::string generator;
bool help = false;
@@ -142,9 +135,9 @@ int main (int argc, char const* const* argv)
// Help arguments
arg.AddArgument("--help", argT::NO_ARGUMENT, &help, "CPack help");
arg.AddArgument("--help-full", argT::SPACE_ARGUMENT, &helpFull,
- "CPack help");
+ "CPack help");
arg.AddArgument("--help-html", argT::SPACE_ARGUMENT, &helpHTML,
- "CPack help");
+ "CPack help");
arg.AddArgument("--help-man", argT::SPACE_ARGUMENT, &helpMAN, "CPack help");
arg.AddArgument("--version", argT::NO_ARGUMENT, &helpVersion, "CPack help");
@@ -152,42 +145,39 @@ int main (int argc, char const* const* argv)
arg.AddArgument("--verbose", argT::NO_ARGUMENT, &verbose, "-V");
arg.AddArgument("--debug", argT::NO_ARGUMENT, &debug, "-V");
arg.AddArgument("--config", argT::SPACE_ARGUMENT, &cpackConfigFile,
- "CPack configuration file");
+ "CPack configuration file");
arg.AddArgument("-C", argT::SPACE_ARGUMENT, &cpackBuildConfig,
- "CPack build configuration");
- arg.AddArgument("-G", argT::SPACE_ARGUMENT,
- &generator, "CPack generator");
- arg.AddArgument("-P", argT::SPACE_ARGUMENT,
- &cpackProjectName, "CPack project name");
- arg.AddArgument("-R", argT::SPACE_ARGUMENT,
- &cpackProjectVersion, "CPack project version");
- arg.AddArgument("-B", argT::SPACE_ARGUMENT,
- &cpackProjectDirectory, "CPack project directory");
- arg.AddArgument("--patch", argT::SPACE_ARGUMENT,
- &cpackProjectPatch, "CPack project patch");
- arg.AddArgument("--vendor", argT::SPACE_ARGUMENT,
- &cpackProjectVendor, "CPack project vendor");
- arg.AddCallback("-D", argT::SPACE_ARGUMENT,
- cpackDefinitionArgument, &definitions, "CPack Definitions");
+ "CPack build configuration");
+ arg.AddArgument("-G", argT::SPACE_ARGUMENT, &generator, "CPack generator");
+ arg.AddArgument("-P", argT::SPACE_ARGUMENT, &cpackProjectName,
+ "CPack project name");
+ arg.AddArgument("-R", argT::SPACE_ARGUMENT, &cpackProjectVersion,
+ "CPack project version");
+ arg.AddArgument("-B", argT::SPACE_ARGUMENT, &cpackProjectDirectory,
+ "CPack project directory");
+ arg.AddArgument("--patch", argT::SPACE_ARGUMENT, &cpackProjectPatch,
+ "CPack project patch");
+ arg.AddArgument("--vendor", argT::SPACE_ARGUMENT, &cpackProjectVendor,
+ "CPack project vendor");
+ arg.AddCallback("-D", argT::SPACE_ARGUMENT, cpackDefinitionArgument,
+ &definitions, "CPack Definitions");
arg.SetUnknownArgumentCallback(cpackUnknownArgument);
// Parse command line
int parsed = arg.Parse();
// Setup logging
- if ( verbose )
- {
+ if (verbose) {
log.SetVerbose(verbose);
cmCPack_Log(&log, cmCPackLog::LOG_OUTPUT, "Enable Verbose" << std::endl);
- }
- if ( debug )
- {
+ }
+ if (debug) {
log.SetDebug(debug);
cmCPack_Log(&log, cmCPackLog::LOG_OUTPUT, "Enable Debug" << std::endl);
- }
+ }
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
- "Read CPack config file: " << cpackConfigFile << std::endl);
+ "Read CPack config file: " << cpackConfigFile << std::endl);
cmake cminst;
cminst.SetHomeDirectory("");
@@ -196,18 +186,17 @@ int main (int argc, char const* const* argv)
cminst.GetState()->RemoveUnscriptableCommands();
cmGlobalGenerator cmgg(&cminst);
cmsys::auto_ptr<cmMakefile> globalMF(
- new cmMakefile(&cmgg, cminst.GetCurrentSnapshot()));
+ new cmMakefile(&cmgg, cminst.GetCurrentSnapshot()));
#if defined(__CYGWIN__)
globalMF->AddDefinition("CMAKE_LEGACY_CYGWIN_WIN32", "0");
#endif
bool cpackConfigFileSpecified = true;
- if ( cpackConfigFile.empty() )
- {
+ if (cpackConfigFile.empty()) {
cpackConfigFile = cmSystemTools::GetCurrentWorkingDirectory();
cpackConfigFile += "/CPackConfig.cmake";
cpackConfigFileSpecified = false;
- }
+ }
cmCPackGeneratorFactory generators;
generators.SetLogger(&log);
@@ -220,262 +209,225 @@ int main (int argc, char const* const* argv)
* should launch cpack using "cpackConfigFile" if it exists
* in the current directory.
*/
- if((doc.CheckOptions(argc, argv,"-G")) && !(argc==1))
- {
- help = true;
- }
- else
- {
- help = false;
- }
+ if ((doc.CheckOptions(argc, argv, "-G")) && !(argc == 1)) {
+ help = true;
+ } else {
+ help = false;
+ }
// This part is used for cpack documentation lookup as well.
cminst.AddCMakePaths();
- if ( parsed && !help )
- {
+ if (parsed && !help) {
// find out which system cpack is running on, so it can setup the search
// paths, so FIND_XXX() commands can be used in scripts
std::string systemFile =
globalMF->GetModulesFile("CMakeDetermineSystem.cmake");
- if (!globalMF->ReadListFile(systemFile.c_str()))
- {
+ if (!globalMF->ReadListFile(systemFile.c_str())) {
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
- "Error reading CMakeDetermineSystem.cmake" << std::endl);
+ "Error reading CMakeDetermineSystem.cmake" << std::endl);
return 1;
- }
+ }
systemFile =
globalMF->GetModulesFile("CMakeSystemSpecificInformation.cmake");
- if (!globalMF->ReadListFile(systemFile.c_str()))
- {
+ if (!globalMF->ReadListFile(systemFile.c_str())) {
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
- "Error reading CMakeSystemSpecificInformation.cmake" << std::endl);
+ "Error reading CMakeSystemSpecificInformation.cmake"
+ << std::endl);
return 1;
- }
+ }
- if ( !cpackBuildConfig.empty() )
- {
+ if (!cpackBuildConfig.empty()) {
globalMF->AddDefinition("CPACK_BUILD_CONFIG", cpackBuildConfig.c_str());
- }
+ }
- if ( cmSystemTools::FileExists(cpackConfigFile.c_str()) )
- {
- cpackConfigFile =
- cmSystemTools::CollapseFullPath(cpackConfigFile);
+ if (cmSystemTools::FileExists(cpackConfigFile.c_str())) {
+ cpackConfigFile = cmSystemTools::CollapseFullPath(cpackConfigFile);
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
- "Read CPack configuration file: " << cpackConfigFile
- << std::endl);
- if ( !globalMF->ReadListFile(cpackConfigFile.c_str()) )
- {
+ "Read CPack configuration file: " << cpackConfigFile
+ << std::endl);
+ if (!globalMF->ReadListFile(cpackConfigFile.c_str())) {
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
- "Problem reading CPack config file: \""
- << cpackConfigFile << "\"" << std::endl);
+ "Problem reading CPack config file: \""
+ << cpackConfigFile << "\"" << std::endl);
return 1;
- }
}
- else if ( cpackConfigFileSpecified )
- {
+ } else if (cpackConfigFileSpecified) {
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
- "Cannot find CPack config file: \"" <<
- cpackConfigFile << "\"" << std::endl);
+ "Cannot find CPack config file: \"" << cpackConfigFile
+ << "\"" << std::endl);
return 1;
- }
+ }
- if ( !generator.empty() )
- {
+ if (!generator.empty()) {
globalMF->AddDefinition("CPACK_GENERATOR", generator.c_str());
- }
- if ( !cpackProjectName.empty() )
- {
+ }
+ if (!cpackProjectName.empty()) {
globalMF->AddDefinition("CPACK_PACKAGE_NAME", cpackProjectName.c_str());
- }
- if ( !cpackProjectVersion.empty() )
- {
+ }
+ if (!cpackProjectVersion.empty()) {
globalMF->AddDefinition("CPACK_PACKAGE_VERSION",
- cpackProjectVersion.c_str());
- }
- if ( !cpackProjectVendor.empty() )
- {
+ cpackProjectVersion.c_str());
+ }
+ if (!cpackProjectVendor.empty()) {
globalMF->AddDefinition("CPACK_PACKAGE_VENDOR",
- cpackProjectVendor.c_str());
- }
+ cpackProjectVendor.c_str());
+ }
// if this is not empty it has been set on the command line
// go for it. Command line override values set in config file.
- if ( !cpackProjectDirectory.empty() )
- {
+ if (!cpackProjectDirectory.empty()) {
globalMF->AddDefinition("CPACK_PACKAGE_DIRECTORY",
cpackProjectDirectory.c_str());
- }
+ }
// The value has not been set on the command line
- else
- {
+ else {
// get a default value (current working directory)
cpackProjectDirectory = cmsys::SystemTools::GetCurrentWorkingDirectory();
// use default value iff no value has been provided by the config file
- if (!globalMF->IsSet("CPACK_PACKAGE_DIRECTORY"))
- {
+ if (!globalMF->IsSet("CPACK_PACKAGE_DIRECTORY")) {
globalMF->AddDefinition("CPACK_PACKAGE_DIRECTORY",
cpackProjectDirectory.c_str());
- }
}
+ }
cpackDefinitions::MapType::iterator cdit;
- for ( cdit = definitions.Map.begin();
- cdit != definitions.Map.end();
- ++cdit )
- {
+ for (cdit = definitions.Map.begin(); cdit != definitions.Map.end();
+ ++cdit) {
globalMF->AddDefinition(cdit->first, cdit->second.c_str());
- }
+ }
const char* cpackModulesPath =
globalMF->GetDefinition("CPACK_MODULE_PATH");
- if ( cpackModulesPath )
- {
+ if (cpackModulesPath) {
globalMF->AddDefinition("CMAKE_MODULE_PATH", cpackModulesPath);
- }
+ }
const char* genList = globalMF->GetDefinition("CPACK_GENERATOR");
- if ( !genList )
- {
- cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
- "CPack generator not specified" << std::endl);
- }
- else
- {
+ if (!genList) {
+ cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "CPack generator not specified"
+ << std::endl);
+ } else {
std::vector<std::string> generatorsVector;
- cmSystemTools::ExpandListArgument(genList,
- generatorsVector);
+ cmSystemTools::ExpandListArgument(genList, generatorsVector);
std::vector<std::string>::iterator it;
- for ( it = generatorsVector.begin();
- it != generatorsVector.end();
- ++it )
- {
+ for (it = generatorsVector.begin(); it != generatorsVector.end(); ++it) {
const char* gen = it->c_str();
cmMakefile::ScopePushPop raii(globalMF.get());
cmMakefile* mf = globalMF.get();
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
- "Specified generator: " << gen << std::endl);
- if ( parsed && !mf->GetDefinition("CPACK_PACKAGE_NAME") )
- {
+ "Specified generator: " << gen << std::endl);
+ if (parsed && !mf->GetDefinition("CPACK_PACKAGE_NAME")) {
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
- "CPack project name not specified" << std::endl);
+ "CPack project name not specified" << std::endl);
parsed = 0;
- }
+ }
if (parsed &&
!(mf->GetDefinition("CPACK_PACKAGE_VERSION") ||
(mf->GetDefinition("CPACK_PACKAGE_VERSION_MAJOR") &&
mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR") &&
- mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH"))))
- {
+ mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH")))) {
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
- "CPack project version not specified" << std::endl
- << "Specify CPACK_PACKAGE_VERSION, or "
- "CPACK_PACKAGE_VERSION_MAJOR, "
- "CPACK_PACKAGE_VERSION_MINOR, and CPACK_PACKAGE_VERSION_PATCH."
- << std::endl);
+ "CPack project version not specified"
+ << std::endl
+ << "Specify CPACK_PACKAGE_VERSION, or "
+ "CPACK_PACKAGE_VERSION_MAJOR, "
+ "CPACK_PACKAGE_VERSION_MINOR, and "
+ "CPACK_PACKAGE_VERSION_PATCH."
+ << std::endl);
parsed = 0;
- }
- if ( parsed )
- {
+ }
+ if (parsed) {
cpackGenerator = generators.NewGenerator(gen);
- if ( !cpackGenerator )
- {
+ if (!cpackGenerator) {
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
- "Cannot initialize CPack generator: "
- << gen << std::endl);
+ "Cannot initialize CPack generator: " << gen
+ << std::endl);
parsed = 0;
- }
- if ( parsed && !cpackGenerator->Initialize(gen, mf) )
- {
+ }
+ if (parsed && !cpackGenerator->Initialize(gen, mf)) {
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
- "Cannot initialize the generator " << gen << std::endl);
+ "Cannot initialize the generator " << gen
+ << std::endl);
parsed = 0;
- }
+ }
- if ( !mf->GetDefinition("CPACK_INSTALL_COMMANDS") &&
- !mf->GetDefinition("CPACK_INSTALLED_DIRECTORIES") &&
- !mf->GetDefinition("CPACK_INSTALL_CMAKE_PROJECTS") )
- {
- cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
+ if (!mf->GetDefinition("CPACK_INSTALL_COMMANDS") &&
+ !mf->GetDefinition("CPACK_INSTALLED_DIRECTORIES") &&
+ !mf->GetDefinition("CPACK_INSTALL_CMAKE_PROJECTS")) {
+ cmCPack_Log(
+ &log, cmCPackLog::LOG_ERROR,
"Please specify build tree of the project that uses CMake "
"using CPACK_INSTALL_CMAKE_PROJECTS, specify "
"CPACK_INSTALL_COMMANDS, or specify "
"CPACK_INSTALLED_DIRECTORIES."
- << std::endl);
+ << std::endl);
parsed = 0;
- }
- if ( parsed )
- {
+ }
+ if (parsed) {
const char* projName = mf->GetDefinition("CPACK_PACKAGE_NAME");
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Use generator: "
- << cpackGenerator->GetNameOfClass() << std::endl);
- cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "For project: "
- << projName << std::endl);
+ << cpackGenerator->GetNameOfClass() << std::endl);
+ cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
+ "For project: " << projName << std::endl);
const char* projVersion =
mf->GetDefinition("CPACK_PACKAGE_VERSION");
- if ( !projVersion )
- {
- const char* projVersionMajor
- = mf->GetDefinition("CPACK_PACKAGE_VERSION_MAJOR");
- const char* projVersionMinor
- = mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR");
- const char* projVersionPatch
- = mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH");
+ if (!projVersion) {
+ const char* projVersionMajor =
+ mf->GetDefinition("CPACK_PACKAGE_VERSION_MAJOR");
+ const char* projVersionMinor =
+ mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR");
+ const char* projVersionPatch =
+ mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH");
std::ostringstream ostr;
ostr << projVersionMajor << "." << projVersionMinor << "."
- << projVersionPatch;
- mf->AddDefinition("CPACK_PACKAGE_VERSION",
- ostr.str().c_str());
- }
+ << projVersionPatch;
+ mf->AddDefinition("CPACK_PACKAGE_VERSION", ostr.str().c_str());
+ }
int res = cpackGenerator->DoPackage();
- if ( !res )
- {
+ if (!res) {
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
- "Error when generating package: " << projName << std::endl);
+ "Error when generating package: " << projName
+ << std::endl);
return 1;
- }
}
}
}
}
}
+ }
/* In this case we are building the documentation object
* instance in order to create appropriate structure
* in order to satisfy the appropriate --help-xxx request
*/
- if ( help )
- {
+ if (help) {
// Construct and print requested documentation.
doc.SetName("cpack");
- doc.SetSection("Name",cmDocumentationName);
- doc.SetSection("Usage",cmDocumentationUsage);
- doc.PrependSection("Options",cmDocumentationOptions);
+ doc.SetSection("Name", cmDocumentationName);
+ doc.SetSection("Usage", cmDocumentationUsage);
+ doc.PrependSection("Options", cmDocumentationOptions);
std::vector<cmDocumentationEntry> v;
cmCPackGeneratorFactory::DescriptionsMap::const_iterator generatorIt;
- for( generatorIt = generators.GetGeneratorsList().begin();
- generatorIt != generators.GetGeneratorsList().end();
- ++ generatorIt )
- {
+ for (generatorIt = generators.GetGeneratorsList().begin();
+ generatorIt != generators.GetGeneratorsList().end(); ++generatorIt) {
cmDocumentationEntry e;
e.Name = generatorIt->first.c_str();
e.Brief = generatorIt->second.c_str();
v.push_back(e);
- }
- doc.SetSection("Generators",v);
+ }
+ doc.SetSection("Generators", v);
#undef cout
- return doc.PrintRequestedDocumentation(std::cout)? 0:1;
+ return doc.PrintRequestedDocumentation(std::cout) ? 0 : 1;
#define cout no_cout_use_cmCPack_Log
- }
+ }
- if (cmSystemTools::GetErrorOccuredFlag())
- {
+ if (cmSystemTools::GetErrorOccuredFlag()) {
return 1;
- }
+ }
return 0;
}
diff --git a/Source/CTest/cmCTestBZR.cxx b/Source/CTest/cmCTestBZR.cxx
index 6dd17b0..dd53be8 100644
--- a/Source/CTest/cmCTestBZR.cxx
+++ b/Source/CTest/cmCTestBZR.cxx
@@ -19,63 +19,58 @@
#include <cm_expat.h>
-extern "C"
-int cmBZRXMLParserUnknownEncodingHandler(void*,
- const XML_Char *name,
- XML_Encoding *info)
+extern "C" int cmBZRXMLParserUnknownEncodingHandler(void*,
+ const XML_Char* name,
+ XML_Encoding* info)
{
- static const int latin1[]=
- {
- 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
- 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
- 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
- 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
- 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
- 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
- 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
- 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
- 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
- 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
- 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
- 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
- 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
- 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
- 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
- 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
- 0x20AC, 0x0081, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
- 0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0x008D, 0x017D, 0x008F,
- 0x0090, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
- 0x02DC, 0x2122, 0x0161, 0x203A, 0x0153, 0x009D, 0x017E, 0x0178,
- 0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
- 0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
- 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
- 0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
- 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7,
- 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
- 0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7,
- 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF,
- 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7,
- 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
- 0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7,
- 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF
- };
+ static const int latin1[] = {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008,
+ 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F, 0x0010, 0x0011,
+ 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001A,
+ 0x001B, 0x001C, 0x001D, 0x001E, 0x001F, 0x0020, 0x0021, 0x0022, 0x0023,
+ 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002A, 0x002B, 0x002C,
+ 0x002D, 0x002E, 0x002F, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035,
+ 0x0036, 0x0037, 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E,
+ 0x003F, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, 0x0050,
+ 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059,
+ 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F, 0x0060, 0x0061, 0x0062,
+ 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006A, 0x006B,
+ 0x006C, 0x006D, 0x006E, 0x006F, 0x0070, 0x0071, 0x0072, 0x0073, 0x0074,
+ 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D,
+ 0x007E, 0x007F, 0x20AC, 0x0081, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020,
+ 0x2021, 0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0x008D, 0x017D, 0x008F,
+ 0x0090, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, 0x02DC,
+ 0x2122, 0x0161, 0x203A, 0x0153, 0x009D, 0x017E, 0x0178, 0x00A0, 0x00A1,
+ 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, 0x00A8, 0x00A9, 0x00AA,
+ 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF, 0x00B0, 0x00B1, 0x00B2, 0x00B3,
+ 0x00B4, 0x00B5, 0x00B6, 0x00B7, 0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC,
+ 0x00BD, 0x00BE, 0x00BF, 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5,
+ 0x00C6, 0x00C7, 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE,
+ 0x00CF, 0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7,
+ 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF, 0x00E0,
+ 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, 0x00E8, 0x00E9,
+ 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, 0x00F0, 0x00F1, 0x00F2,
+ 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, 0x00F8, 0x00F9, 0x00FA, 0x00FB,
+ 0x00FC, 0x00FD, 0x00FE, 0x00FF
+ };
// The BZR xml output plugin can use some encodings that are not
// recognized by expat. This will lead to an error, e.g. "Error
// parsing bzr log xml: unknown encoding", the following is a
// workaround for these unknown encodings.
- if(name == std::string("ascii") || name == std::string("cp1252") ||
- name == std::string("ANSI_X3.4-1968"))
- {
- for(unsigned int i=0;i<256;++i) info->map[i] = latin1[i];
+ if (name == std::string("ascii") || name == std::string("cp1252") ||
+ name == std::string("ANSI_X3.4-1968")) {
+ for (unsigned int i = 0; i < 256; ++i)
+ info->map[i] = latin1[i];
return 1;
- }
+ }
return 0;
}
-cmCTestBZR::cmCTestBZR(cmCTest* ct, std::ostream& log):
- cmCTestGlobalVC(ct, log)
+cmCTestBZR::cmCTestBZR(cmCTest* ct, std::ostream& log)
+ : cmCTestGlobalVC(ct, log)
{
this->PriorRev = this->Unknown;
// Even though it is specified in the documentation, with bzr 1.13
@@ -88,69 +83,68 @@ cmCTestBZR::~cmCTestBZR()
{
}
-class cmCTestBZR::InfoParser: public cmCTestVC::LineParser
+class cmCTestBZR::InfoParser : public cmCTestVC::LineParser
{
public:
- InfoParser(cmCTestBZR* bzr, const char* prefix):
- BZR(bzr), CheckOutFound(false)
- {
+ InfoParser(cmCTestBZR* bzr, const char* prefix)
+ : BZR(bzr)
+ , CheckOutFound(false)
+ {
this->SetLog(&bzr->Log, prefix);
this->RegexCheckOut.compile("checkout of branch: *([^\t\r\n]+)$");
this->RegexParent.compile("parent branch: *([^\t\r\n]+)$");
- }
+ }
+
private:
cmCTestBZR* BZR;
bool CheckOutFound;
cmsys::RegularExpression RegexCheckOut;
cmsys::RegularExpression RegexParent;
virtual bool ProcessLine()
- {
- if(this->RegexCheckOut.find(this->Line))
- {
+ {
+ if (this->RegexCheckOut.find(this->Line)) {
this->BZR->URL = this->RegexCheckOut.match(1);
CheckOutFound = true;
- }
- else if(!CheckOutFound && this->RegexParent.find(this->Line))
- {
+ } else if (!CheckOutFound && this->RegexParent.find(this->Line)) {
this->BZR->URL = this->RegexParent.match(1);
- }
- return true;
}
+ return true;
+ }
};
-class cmCTestBZR::RevnoParser: public cmCTestVC::LineParser
+class cmCTestBZR::RevnoParser : public cmCTestVC::LineParser
{
public:
- RevnoParser(cmCTestBZR* bzr, const char* prefix, std::string& rev):
- Rev(rev)
- {
+ RevnoParser(cmCTestBZR* bzr, const char* prefix, std::string& rev)
+ : Rev(rev)
+ {
this->SetLog(&bzr->Log, prefix);
this->RegexRevno.compile("^([0-9]+)$");
- }
+ }
+
private:
std::string& Rev;
cmsys::RegularExpression RegexRevno;
virtual bool ProcessLine()
- {
- if(this->RegexRevno.find(this->Line))
- {
+ {
+ if (this->RegexRevno.find(this->Line)) {
this->Rev = this->RegexRevno.match(1);
- }
- return true;
}
+ return true;
+ }
};
std::string cmCTestBZR::LoadInfo()
{
// Run "bzr info" to get the repository info from the work tree.
const char* bzr = this->CommandLineTool.c_str();
- const char* bzr_info[] = {bzr, "info", 0};
+ const char* bzr_info[] = { bzr, "info", 0 };
InfoParser iout(this, "info-out> ");
OutputLogger ierr(this->Log, "info-err> ");
this->RunChild(bzr_info, &iout, &ierr);
// Run "bzr revno" to get the repository revision number from the work tree.
- const char* bzr_revno[] = {bzr, "revno", 0};
+ const char* bzr_revno[] = { bzr, "revno", 0 };
std::string rev;
RevnoParser rout(this, "revno-out> ", rev);
OutputLogger rerr(this->Log, "revno-err> ");
@@ -164,7 +158,7 @@ void 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->OldRevision << "\n");
this->PriorRev.Rev = this->OldRevision;
}
@@ -173,35 +167,38 @@ void 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->NewRevision << "\n");
this->Log << "URL = " << this->URL << "\n";
}
-class cmCTestBZR::LogParser: public cmCTestVC::OutputLogger,
- private cmXMLParser
+class cmCTestBZR::LogParser : public cmCTestVC::OutputLogger,
+ private cmXMLParser
{
public:
- LogParser(cmCTestBZR* bzr, const char* prefix):
- OutputLogger(bzr->Log, prefix), BZR(bzr),
- EmailRegex("(.*) <([A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+)>")
- { this->InitializeParser(); }
+ LogParser(cmCTestBZR* bzr, const char* prefix)
+ : OutputLogger(bzr->Log, prefix)
+ , BZR(bzr)
+ , EmailRegex("(.*) <([A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+)>")
+ {
+ this->InitializeParser();
+ }
~LogParser() { this->CleanupParser(); }
virtual int InitializeParser()
- {
- int res = cmXMLParser::InitializeParser();
- if (res)
- {
- XML_SetUnknownEncodingHandler(static_cast<XML_Parser>(this->Parser),
- cmBZRXMLParserUnknownEncodingHandler, 0);
- }
- return res;
- }
+ {
+ int res = cmXMLParser::InitializeParser();
+ if (res) {
+ XML_SetUnknownEncodingHandler(static_cast<XML_Parser>(this->Parser),
+ cmBZRXMLParserUnknownEncodingHandler, 0);
+ }
+ return res;
+ }
+
private:
cmCTestBZR* BZR;
typedef cmCTestBZR::Revision Revision;
- typedef cmCTestBZR::Change Change;
+ typedef cmCTestBZR::Change Change;
Revision Rev;
std::vector<Change> Changes;
Change CurChange;
@@ -210,194 +207,161 @@ private:
cmsys::RegularExpression EmailRegex;
virtual bool ProcessChunk(const char* data, int length)
- {
+ {
this->OutputLogger::ProcessChunk(data, length);
this->ParseChunk(data, length);
return true;
- }
+ }
virtual void StartElement(const std::string& name, const char**)
- {
+ {
this->CData.clear();
- if(name == "log")
- {
+ if (name == "log") {
this->Rev = Revision();
this->Changes.clear();
- }
+ }
// affected-files can contain blocks of
// modified, unknown, renamed, kind-changed, removed, conflicts, added
- else if(name == "modified"
- || name == "renamed"
- || name == "kind-changed")
- {
+ else if (name == "modified" || name == "renamed" ||
+ name == "kind-changed") {
this->CurChange = Change();
this->CurChange.Action = 'M';
- }
- else if(name == "added")
- {
+ } else if (name == "added") {
this->CurChange = Change();
this->CurChange = 'A';
- }
- else if(name == "removed")
- {
+ } else if (name == "removed") {
this->CurChange = Change();
this->CurChange = 'D';
- }
- else if(name == "unknown"
- || name == "conflicts")
- {
+ } else if (name == "unknown" || name == "conflicts") {
// Should not happen here
this->CurChange = Change();
- }
}
+ }
virtual void CharacterDataHandler(const char* data, int length)
- {
- this->CData.insert(this->CData.end(), data, data+length);
- }
+ {
+ this->CData.insert(this->CData.end(), data, data + length);
+ }
virtual void EndElement(const std::string& name)
- {
- if(name == "log")
- {
+ {
+ if (name == "log") {
this->BZR->DoRevision(this->Rev, this->Changes);
- }
- else if(!this->CData.empty() &&
- (name == "file" || name == "directory"))
- {
+ } else if (!this->CData.empty() &&
+ (name == "file" || name == "directory")) {
this->CurChange.Path.assign(&this->CData[0], this->CData.size());
cmSystemTools::ConvertToUnixSlashes(this->CurChange.Path);
this->Changes.push_back(this->CurChange);
- }
- else if(!this->CData.empty() && name == "symlink")
- {
+ } else if (!this->CData.empty() && name == "symlink") {
// symlinks have an arobase at the end in the log
- this->CurChange.Path.assign(&this->CData[0], this->CData.size()-1);
+ this->CurChange.Path.assign(&this->CData[0], this->CData.size() - 1);
cmSystemTools::ConvertToUnixSlashes(this->CurChange.Path);
this->Changes.push_back(this->CurChange);
- }
- else if(!this->CData.empty() && name == "committer")
- {
+ } else if (!this->CData.empty() && name == "committer") {
this->Rev.Author.assign(&this->CData[0], this->CData.size());
- if(this->EmailRegex.find(this->Rev.Author))
- {
+ if (this->EmailRegex.find(this->Rev.Author)) {
this->Rev.Author = this->EmailRegex.match(1);
this->Rev.EMail = this->EmailRegex.match(2);
- }
}
- else if(!this->CData.empty() && name == "timestamp")
- {
+ } else if (!this->CData.empty() && name == "timestamp") {
this->Rev.Date.assign(&this->CData[0], this->CData.size());
- }
- else if(!this->CData.empty() && name == "message")
- {
+ } else if (!this->CData.empty() && name == "message") {
this->Rev.Log.assign(&this->CData[0], this->CData.size());
- }
- else if(!this->CData.empty() && name == "revno")
- {
+ } else if (!this->CData.empty() && name == "revno") {
this->Rev.Rev.assign(&this->CData[0], this->CData.size());
- }
- this->CData.clear();
}
+ this->CData.clear();
+ }
virtual void ReportError(int, int, const char* msg)
- {
+ {
this->BZR->Log << "Error parsing bzr log xml: " << msg << "\n";
- }
+ }
};
-class cmCTestBZR::UpdateParser: public cmCTestVC::LineParser
+class cmCTestBZR::UpdateParser : public cmCTestVC::LineParser
{
public:
- UpdateParser(cmCTestBZR* bzr, const char* prefix): BZR(bzr)
- {
+ UpdateParser(cmCTestBZR* bzr, const char* prefix)
+ : BZR(bzr)
+ {
this->SetLog(&bzr->Log, prefix);
this->RegexUpdate.compile("^([-+R?XCP ])([NDKM ])([* ]) +(.+)$");
- }
+ }
+
private:
cmCTestBZR* BZR;
cmsys::RegularExpression RegexUpdate;
virtual bool ProcessChunk(const char* first, int length)
- {
+ {
bool last_is_new_line = (*first == '\r' || *first == '\n');
const char* const last = first + length;
- for(const char* c = first; c != last; ++c)
- {
- if(*c == '\r' || *c == '\n')
- {
- if(!last_is_new_line)
- {
+ for (const char* c = first; c != last; ++c) {
+ if (*c == '\r' || *c == '\n') {
+ if (!last_is_new_line) {
// Log this line.
- if(this->Log && this->Prefix)
- {
+ if (this->Log && this->Prefix) {
*this->Log << this->Prefix << this->Line << "\n";
- }
+ }
// Hand this line to the subclass implementation.
- if(!this->ProcessLine())
- {
+ if (!this->ProcessLine()) {
this->Line = "";
return false;
- }
+ }
this->Line = "";
last_is_new_line = true;
- }
}
- else
- {
+ } else {
// Append this character to the line under construction.
this->Line.append(1, *c);
last_is_new_line = false;
- }
}
- return true;
}
+ return true;
+ }
bool ProcessLine()
- {
- if(this->RegexUpdate.find(this->Line))
- {
+ {
+ if (this->RegexUpdate.find(this->Line)) {
this->DoPath(this->RegexUpdate.match(1)[0],
this->RegexUpdate.match(2)[0],
- this->RegexUpdate.match(3)[0],
- this->RegexUpdate.match(4));
- }
- return true;
+ this->RegexUpdate.match(3)[0], this->RegexUpdate.match(4));
}
+ return true;
+ }
void DoPath(char c0, char c1, char c2, std::string path)
- {
- if(path.empty()) return;
+ {
+ if (path.empty())
+ return;
cmSystemTools::ConvertToUnixSlashes(path);
const std::string dir = cmSystemTools::GetFilenamePath(path);
const std::string name = cmSystemTools::GetFilenameName(path);
- if ( c0=='C' )
- {
+ if (c0 == 'C') {
this->BZR->Dirs[dir][name].Status = PathConflicting;
return;
- }
+ }
- if ( c1=='M' || c1=='K' || c1=='N' || c1=='D' || c2 =='*' )
- {
+ if (c1 == 'M' || c1 == 'K' || c1 == 'N' || c1 == 'D' || c2 == '*') {
this->BZR->Dirs[dir][name].Status = PathUpdated;
return;
- }
}
+ }
};
bool cmCTestBZR::UpdateImpl()
{
// Get user-specified update options.
std::string opts = this->CTest->GetCTestConfiguration("UpdateOptions");
- if(opts.empty())
- {
+ if (opts.empty()) {
opts = this->CTest->GetCTestConfiguration("BZRUpdateOptions");
- }
+ }
std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
// TODO: if(this->CTest->GetTestModel() == cmCTest::NIGHTLY)
@@ -407,11 +371,10 @@ bool cmCTestBZR::UpdateImpl()
bzr_update.push_back(this->CommandLineTool.c_str());
bzr_update.push_back("pull");
- for(std::vector<std::string>::const_iterator ai = args.begin();
- ai != args.end(); ++ai)
- {
+ for (std::vector<std::string>::const_iterator ai = args.begin();
+ ai != args.end(); ++ai) {
bzr_update.push_back(ai->c_str());
- }
+ }
bzr_update.push_back(this->URL.c_str());
@@ -427,82 +390,79 @@ void cmCTestBZR::LoadRevisions()
{
cmCTestLog(this->CTest, HANDLER_OUTPUT,
" Gathering version information (one . per revision):\n"
- " " << std::flush);
+ " "
+ << std::flush);
// We are interested in every revision included in the update.
this->Revisions.clear();
std::string revs;
- if(atoi(this->OldRevision.c_str()) <= atoi(this->NewRevision.c_str()))
- {
+ if (atoi(this->OldRevision.c_str()) <= atoi(this->NewRevision.c_str())) {
// DoRevision takes care of discarding the information about OldRevision
revs = this->OldRevision + ".." + this->NewRevision;
- }
- else
- {
+ } else {
return;
- }
+ }
// Run "bzr log" to get all global revisions of interest.
const char* bzr = this->CommandLineTool.c_str();
- const char* bzr_log[] = {bzr, "log", "-v", "-r", revs.c_str(), "--xml",
- this->URL.c_str(), 0};
+ const char* bzr_log[] = {
+ bzr, "log", "-v", "-r", revs.c_str(), "--xml", this->URL.c_str(), 0
+ };
{
- LogParser out(this, "log-out> ");
- OutputLogger err(this->Log, "log-err> ");
- this->RunChild(bzr_log, &out, &err);
+ LogParser out(this, "log-out> ");
+ OutputLogger err(this->Log, "log-err> ");
+ this->RunChild(bzr_log, &out, &err);
}
cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl);
}
-class cmCTestBZR::StatusParser: public cmCTestVC::LineParser
+class cmCTestBZR::StatusParser : public cmCTestVC::LineParser
{
public:
- StatusParser(cmCTestBZR* bzr, const char* prefix): BZR(bzr)
- {
+ StatusParser(cmCTestBZR* bzr, const char* prefix)
+ : BZR(bzr)
+ {
this->SetLog(&bzr->Log, prefix);
this->RegexStatus.compile("^([-+R?XCP ])([NDKM ])([* ]) +(.+)$");
- }
+ }
+
private:
cmCTestBZR* BZR;
cmsys::RegularExpression RegexStatus;
bool ProcessLine()
- {
- if(this->RegexStatus.find(this->Line))
- {
+ {
+ if (this->RegexStatus.find(this->Line)) {
this->DoPath(this->RegexStatus.match(1)[0],
this->RegexStatus.match(2)[0],
- this->RegexStatus.match(3)[0],
- this->RegexStatus.match(4));
- }
- return true;
+ this->RegexStatus.match(3)[0], this->RegexStatus.match(4));
}
+ return true;
+ }
void DoPath(char c0, char c1, char c2, std::string path)
- {
- if(path.empty()) return;
+ {
+ if (path.empty())
+ return;
cmSystemTools::ConvertToUnixSlashes(path);
- if ( c0=='C' )
- {
+ if (c0 == 'C') {
this->BZR->DoModification(PathConflicting, path);
return;
- }
+ }
- if ( c0 == '+' || c0 == 'R' || c0 == 'P'
- || c1=='M' || c1=='K' || c1=='N' || c1=='D'
- || c2 =='*' )
- {
+ if (c0 == '+' || c0 == 'R' || c0 == 'P' || c1 == 'M' || c1 == 'K' ||
+ c1 == 'N' || c1 == 'D' || c2 == '*') {
this->BZR->DoModification(PathModified, path);
return;
- }
}
+ }
};
void cmCTestBZR::LoadModifications()
{
// Run "bzr status" which reports local modifications.
const char* bzr = this->CommandLineTool.c_str();
- const char* bzr_status[] = {bzr, "status", "-SV", 0};
+ const char* bzr_status[] = { bzr, "status", "-SV", 0 };
StatusParser out(this, "status-out> ");
OutputLogger err(this->Log, "status-err> ");
this->RunChild(bzr_status, &out, &err);
diff --git a/Source/CTest/cmCTestBZR.h b/Source/CTest/cmCTestBZR.h
index df688e1..4f44136 100644
--- a/Source/CTest/cmCTestBZR.h
+++ b/Source/CTest/cmCTestBZR.h
@@ -18,7 +18,7 @@
* \brief Interaction with bzr command-line tool
*
*/
-class cmCTestBZR: public cmCTestGlobalVC
+class cmCTestBZR : public cmCTestGlobalVC
{
public:
/** Construct with a CTest instance and update log stream. */
diff --git a/Source/CTest/cmCTestBatchTestHandler.cxx b/Source/CTest/cmCTestBatchTestHandler.cxx
index 6127551..386c8d5 100644
--- a/Source/CTest/cmCTestBatchTestHandler.cxx
+++ b/Source/CTest/cmCTestBatchTestHandler.cxx
@@ -30,18 +30,17 @@ void cmCTestBatchTestHandler::RunTests()
void cmCTestBatchTestHandler::WriteBatchScript()
{
- this->Script = this->CTest->GetBinaryDir()
- + "/Testing/CTestBatch.txt";
+ this->Script = this->CTest->GetBinaryDir() + "/Testing/CTestBatch.txt";
cmsys::ofstream fout;
fout.open(this->Script.c_str());
fout << "#!/bin/sh\n";
- for(TestMap::iterator i = this->Tests.begin(); i != this->Tests.end(); ++i)
- {
+ for (TestMap::iterator i = this->Tests.begin(); i != this->Tests.end();
+ ++i) {
this->WriteSrunArgs(i->first, fout);
this->WriteTestCommand(i->first, fout);
fout << "\n";
- }
+ }
fout.flush();
fout.close();
}
@@ -49,13 +48,13 @@ void cmCTestBatchTestHandler::WriteBatchScript()
void cmCTestBatchTestHandler::WriteSrunArgs(int test, cmsys::ofstream& fout)
{
cmCTestTestHandler::cmCTestTestProperties* properties =
- this->Properties[test];
+ this->Properties[test];
fout << "srun ";
- //fout << "--jobid=" << test << " ";
+ // fout << "--jobid=" << test << " ";
fout << "-J=" << properties->Name << " ";
- //Write dependency information
+ // Write dependency information
/*if(!this->Tests[test].empty())
{
fout << "-P=afterany";
@@ -66,14 +65,12 @@ void cmCTestBatchTestHandler::WriteSrunArgs(int test, cmsys::ofstream& fout)
}
fout << " ";
}*/
- if(properties->RunSerial)
- {
+ if (properties->RunSerial) {
fout << "--exclusive ";
- }
- if(properties->Processors > 1)
- {
+ }
+ if (properties->Processors > 1) {
fout << "-n" << properties->Processors << " ";
- }
+ }
}
void cmCTestBatchTestHandler::WriteTestCommand(int test, cmsys::ofstream& fout)
@@ -85,36 +82,32 @@ void cmCTestBatchTestHandler::WriteTestCommand(int test, cmsys::ofstream& fout)
command = this->TestHandler->FindTheExecutable(args[1].c_str());
command = cmSystemTools::ConvertToOutputPath(command.c_str());
- //Prepends memcheck args to our command string if this is a memcheck
+ // Prepends memcheck args to our command string if this is a memcheck
this->TestHandler->GenerateTestCommand(processArgs, test);
processArgs.push_back(command);
- for(std::vector<std::string>::iterator arg = processArgs.begin();
- arg != processArgs.end(); ++arg)
- {
+ for (std::vector<std::string>::iterator arg = processArgs.begin();
+ arg != processArgs.end(); ++arg) {
fout << *arg << " ";
- }
+ }
std::vector<std::string>::iterator i = args.begin();
- ++i; //the test name
- ++i; //the executable (command)
- if(args.size() > 2)
- {
+ ++i; // the test name
+ ++i; // the executable (command)
+ if (args.size() > 2) {
fout << "'";
- }
- while(i != args.end())
- {
- fout << "\"" << *i << "\""; //args to the test executable
+ }
+ while (i != args.end()) {
+ fout << "\"" << *i << "\""; // args to the test executable
++i;
- if(i == args.end() && args.size() > 2)
- {
+ if (i == args.end() && args.size() > 2) {
fout << "'";
- }
- fout << " ";
}
- //TODO ZACH build TestResult.FullCommandLine
- //this->TestResult.FullCommandLine = this->TestCommand;
+ fout << " ";
+ }
+ // TODO ZACH build TestResult.FullCommandLine
+ // this->TestResult.FullCommandLine = this->TestCommand;
}
void cmCTestBatchTestHandler::SubmitBatchScript()
@@ -123,8 +116,7 @@ void cmCTestBatchTestHandler::SubmitBatchScript()
std::vector<std::string> args;
args.push_back(this->Script);
args.push_back("-o");
- args.push_back(this->CTest->GetBinaryDir()
- + "/Testing/CTestBatch.txt");
+ args.push_back(this->CTest->GetBinaryDir() + "/Testing/CTestBatch.txt");
sbatch.SetCommand("sbatch");
sbatch.SetCommandArguments(args);
diff --git a/Source/CTest/cmCTestBatchTestHandler.h b/Source/CTest/cmCTestBatchTestHandler.h
index b0fc8d5..7a2a4a2 100644
--- a/Source/CTest/cmCTestBatchTestHandler.h
+++ b/Source/CTest/cmCTestBatchTestHandler.h
@@ -30,6 +30,7 @@ class cmCTestBatchTestHandler : public cmCTestMultiProcessHandler
public:
~cmCTestBatchTestHandler();
virtual void RunTests();
+
protected:
void WriteBatchScript();
void WriteSrunArgs(int test, cmsys::ofstream& fout);
diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx
index 6ea9a89..0cba8b2 100644
--- a/Source/CTest/cmCTestBuildAndTestHandler.cxx
+++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx
@@ -21,9 +21,9 @@
cmCTestBuildAndTestHandler::cmCTestBuildAndTestHandler()
{
- this->BuildTwoConfig = false;
- this->BuildNoClean = false;
- this->BuildNoCMake = false;
+ this->BuildTwoConfig = false;
+ this->BuildNoClean = false;
+ this->BuildNoCMake = false;
this->Timeout = 0;
}
@@ -48,91 +48,75 @@ int cmCTestBuildAndTestHandler::ProcessHandler()
}
int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring,
- std::ostringstream &out, std::string &cmakeOutString, std::string &cwd,
- cmake *cm)
+ std::ostringstream& out,
+ std::string& cmakeOutString,
+ std::string& cwd, cmake* cm)
{
unsigned int k;
std::vector<std::string> args;
args.push_back(cmSystemTools::GetCMakeCommand());
args.push_back(this->SourceDir);
- if(!this->BuildGenerator.empty())
- {
+ if (!this->BuildGenerator.empty()) {
std::string generator = "-G";
generator += this->BuildGenerator;
args.push_back(generator);
- }
- if(!this->BuildGeneratorPlatform.empty())
- {
+ }
+ if (!this->BuildGeneratorPlatform.empty()) {
std::string platform = "-A";
platform += this->BuildGeneratorPlatform;
args.push_back(platform);
- }
- if(!this->BuildGeneratorToolset.empty())
- {
+ }
+ if (!this->BuildGeneratorToolset.empty()) {
std::string toolset = "-T";
toolset += this->BuildGeneratorToolset;
args.push_back(toolset);
- }
+ }
const char* config = 0;
- if (!this->CTest->GetConfigType().empty())
- {
+ if (!this->CTest->GetConfigType().empty()) {
config = this->CTest->GetConfigType().c_str();
- }
+ }
#ifdef CMAKE_INTDIR
- if(!config)
- {
+ if (!config) {
config = CMAKE_INTDIR;
- }
+ }
#endif
- if ( config )
- {
- std::string btype
- = "-DCMAKE_BUILD_TYPE:STRING=" + std::string(config);
+ if (config) {
+ std::string btype = "-DCMAKE_BUILD_TYPE:STRING=" + std::string(config);
args.push_back(btype);
- }
+ }
- for(k=0; k < this->BuildOptions.size(); ++k)
- {
+ for (k = 0; k < this->BuildOptions.size(); ++k) {
args.push_back(this->BuildOptions[k]);
- }
- if (cm->Run(args) != 0)
- {
+ }
+ if (cm->Run(args) != 0) {
out << "Error: cmake execution failed\n";
out << cmakeOutString << "\n";
// return to the original directory
cmSystemTools::ChangeDirectory(cwd);
- if(outstring)
- {
+ if (outstring) {
*outstring = out.str();
- }
- else
- {
+ } else {
cmCTestLog(this->CTest, ERROR_MESSAGE, out.str() << std::endl);
- }
- return 1;
}
+ return 1;
+ }
// do another config?
- if(this->BuildTwoConfig)
- {
- if (cm->Run(args) != 0)
- {
+ if (this->BuildTwoConfig) {
+ if (cm->Run(args) != 0) {
out << "Error: cmake execution failed\n";
out << cmakeOutString << "\n";
// return to the original directory
cmSystemTools::ChangeDirectory(cwd);
- if(outstring)
- {
+ if (outstring) {
*outstring = out.str();
- }
- else
- {
+ } else {
cmCTestLog(this->CTest, ERROR_MESSAGE, out.str() << std::endl);
- }
- return 1;
}
+ return 1;
}
+ }
out << "======== CMake output ======\n";
out << cmakeOutString;
out << "======== End CMake output ======\n";
@@ -146,7 +130,7 @@ void CMakeMessageCallback(const char* m, const char*, bool&, void* s)
*out += "\n";
}
-void CMakeProgressCallback(const char*msg, float , void * s)
+void CMakeProgressCallback(const char* msg, float, void* s)
{
std::string* out = (std::string*)s;
*out += msg;
@@ -162,37 +146,36 @@ void CMakeOutputCallback(const char* m, size_t len, void* s)
class cmCTestBuildAndTestCaptureRAII
{
cmake& CM;
+
public:
- cmCTestBuildAndTestCaptureRAII(cmake& cm, std::string& s): CM(cm)
- {
+ cmCTestBuildAndTestCaptureRAII(cmake& cm, std::string& s)
+ : CM(cm)
+ {
cmSystemTools::SetMessageCallback(CMakeMessageCallback, &s);
cmSystemTools::SetStdoutCallback(CMakeOutputCallback, &s);
cmSystemTools::SetStderrCallback(CMakeOutputCallback, &s);
this->CM.SetProgressCallback(CMakeProgressCallback, &s);
- }
+ }
~cmCTestBuildAndTestCaptureRAII()
- {
+ {
this->CM.SetProgressCallback(0, 0);
cmSystemTools::SetStderrCallback(0, 0);
cmSystemTools::SetStdoutCallback(0, 0);
cmSystemTools::SetMessageCallback(0, 0);
- }
+ }
};
int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
{
// if the generator and make program are not specified then it is an error
- if (this->BuildGenerator.empty())
- {
- if(outstring)
- {
- *outstring =
- "--build-and-test requires that the generator "
- "be provided using the --build-generator "
- "command line option. ";
- }
- return 1;
+ if (this->BuildGenerator.empty()) {
+ if (outstring) {
+ *outstring = "--build-and-test requires that the generator "
+ "be provided using the --build-generator "
+ "command line option. ";
}
+ return 1;
+ }
cmake cm;
cm.SetHomeDirectory("");
@@ -202,27 +185,21 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
static_cast<void>(captureRAII);
std::ostringstream out;
- if ( this->CTest->GetConfigType().empty() &&
- !this->ConfigSample.empty())
- {
+ if (this->CTest->GetConfigType().empty() && !this->ConfigSample.empty()) {
// use the config sample to set the ConfigType
std::string fullPath;
std::string resultingConfig;
std::vector<std::string> extraPaths;
std::vector<std::string> failed;
- fullPath =
- cmCTestTestHandler::FindExecutable(this->CTest,
- this->ConfigSample.c_str(),
- resultingConfig,
- extraPaths,
- failed);
- if (!fullPath.empty() && !resultingConfig.empty())
- {
+ fullPath = cmCTestTestHandler::FindExecutable(
+ this->CTest, this->ConfigSample.c_str(), resultingConfig, extraPaths,
+ failed);
+ if (!fullPath.empty() && !resultingConfig.empty()) {
this->CTest->SetConfigType(resultingConfig.c_str());
- }
- out << "Using config sample with results: "
- << fullPath << " and " << resultingConfig << std::endl;
}
+ out << "Using config sample with results: " << fullPath << " and "
+ << resultingConfig << std::endl;
+ }
// we need to honor the timeout specified, the timeout include cmake, build
// and test time
@@ -230,100 +207,79 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
// 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))
- {
+ 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);
- if(this->BuildNoCMake)
- {
+ if (this->BuildNoCMake) {
// Make the generator available for the Build call below.
- cm.SetGlobalGenerator(cm.CreateGlobalGenerator(
- this->BuildGenerator));
+ cm.SetGlobalGenerator(cm.CreateGlobalGenerator(this->BuildGenerator));
cm.SetGeneratorPlatform(this->BuildGeneratorPlatform);
cm.SetGeneratorToolset(this->BuildGeneratorToolset);
// Load the cache to make CMAKE_MAKE_PROGRAM available.
cm.LoadCache(this->BinaryDir);
- }
- else
- {
+ } 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, cwd, &cm)) {
return 1;
- }
}
+ }
// do the build
std::vector<std::string>::iterator tarIt;
- if (this->BuildTargets.empty())
- {
+ if (this->BuildTargets.empty()) {
this->BuildTargets.push_back("");
- }
- for ( tarIt = this->BuildTargets.begin();
- tarIt != this->BuildTargets.end(); ++ tarIt )
- {
+ }
+ for (tarIt = this->BuildTargets.begin(); tarIt != this->BuildTargets.end();
+ ++tarIt) {
double remainingTime = 0;
- if (this->Timeout > 0)
- {
+ if (this->Timeout > 0) {
remainingTime = this->Timeout - cmSystemTools::GetTime() + clock_start;
- if (remainingTime <= 0)
- {
- if(outstring)
- {
+ if (remainingTime <= 0) {
+ if (outstring) {
*outstring = "--build-and-test timeout exceeded. ";
- }
- return 1;
}
+ return 1;
}
+ }
std::string output;
const char* config = 0;
- if (!this->CTest->GetConfigType().empty())
- {
+ if (!this->CTest->GetConfigType().empty()) {
config = this->CTest->GetConfigType().c_str();
- }
+ }
#ifdef CMAKE_INTDIR
- if(!config)
- {
+ if (!config) {
config = CMAKE_INTDIR;
- }
+ }
#endif
- if(!config)
- {
+ if (!config) {
config = "Debug";
- }
+ }
int retVal = cm.GetGlobalGenerator()->Build(
- this->SourceDir, this->BinaryDir,
- this->BuildProject, *tarIt,
- output, this->BuildMakeProgram,
- config,
- !this->BuildNoClean,
- false, false, remainingTime);
+ this->SourceDir, this->BinaryDir, this->BuildProject, *tarIt, output,
+ this->BuildMakeProgram, config, !this->BuildNoClean, false, false,
+ remainingTime);
out << output;
// if the build failed then return
- if (retVal)
- {
- if(outstring)
- {
- *outstring = out.str();
- }
- return 1;
+ if (retVal) {
+ if (outstring) {
+ *outstring = out.str();
}
+ return 1;
}
- if(outstring)
- {
- *outstring = out.str();
- }
+ }
+ if (outstring) {
+ *outstring = out.str();
+ }
// if no test was specified then we are done
- if (this->TestCommand.empty())
- {
+ if (this->TestCommand.empty()) {
return 0;
- }
+ }
// now run the compiled test if we can find it
// store the final location in fullPath
@@ -331,99 +287,80 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
std::string resultingConfig;
std::vector<std::string> extraPaths;
// if this->ExecutableDirectory is set try that as well
- if (!this->ExecutableDirectory.empty())
- {
+ if (!this->ExecutableDirectory.empty()) {
std::string tempPath = this->ExecutableDirectory;
tempPath += "/";
tempPath += this->TestCommand;
extraPaths.push_back(tempPath);
- }
+ }
std::vector<std::string> failed;
fullPath =
- cmCTestTestHandler::FindExecutable(this->CTest,
- this->TestCommand.c_str(),
- resultingConfig,
- extraPaths,
- failed);
-
- if(!cmSystemTools::FileExists(fullPath.c_str()))
- {
+ cmCTestTestHandler::FindExecutable(this->CTest, this->TestCommand.c_str(),
+ resultingConfig, extraPaths, failed);
+
+ if (!cmSystemTools::FileExists(fullPath.c_str())) {
out << "Could not find path to executable, perhaps it was not built: "
- << this->TestCommand << "\n";
+ << this->TestCommand << "\n";
out << "tried to find it in these places:\n";
out << fullPath.c_str() << "\n";
- for(unsigned int i=0; i < failed.size(); ++i)
- {
+ for (unsigned int i = 0; i < failed.size(); ++i) {
out << failed[i] << "\n";
- }
- if(outstring)
- {
- *outstring = out.str();
- }
- else
- {
+ }
+ if (outstring) {
+ *outstring = out.str();
+ } else {
cmCTestLog(this->CTest, ERROR_MESSAGE, out.str());
- }
+ }
// return to the original directory
cmSystemTools::ChangeDirectory(cwd);
return 1;
- }
+ }
std::vector<const char*> testCommand;
testCommand.push_back(fullPath.c_str());
- for(size_t k=0; k < this->TestCommandArgs.size(); ++k)
- {
+ for (size_t k = 0; k < this->TestCommandArgs.size(); ++k) {
testCommand.push_back(this->TestCommandArgs[k].c_str());
- }
+ }
testCommand.push_back(0);
std::string outs;
int retval = 0;
// run the test from the this->BuildRunDir if set
- if(!this->BuildRunDir.empty())
- {
+ if (!this->BuildRunDir.empty()) {
out << "Run test in directory: " << this->BuildRunDir << "\n";
cmSystemTools::ChangeDirectory(this->BuildRunDir);
- }
+ }
out << "Running test command: \"" << fullPath << "\"";
- for(size_t k=0; k < this->TestCommandArgs.size(); ++k)
- {
+ for (size_t k = 0; k < this->TestCommandArgs.size(); ++k) {
out << " \"" << this->TestCommandArgs[k] << "\"";
- }
+ }
out << "\n";
// how much time is remaining
double remainingTime = 0;
- if (this->Timeout > 0)
- {
+ if (this->Timeout > 0) {
remainingTime = this->Timeout - cmSystemTools::GetTime() + clock_start;
- if (remainingTime <= 0)
- {
- if(outstring)
- {
+ if (remainingTime <= 0) {
+ if (outstring) {
*outstring = "--build-and-test timeout exceeded. ";
- }
- return 1;
}
+ return 1;
}
+ }
- int runTestRes = this->CTest->RunTest(testCommand, &outs, &retval, 0,
- remainingTime, 0);
+ int runTestRes =
+ this->CTest->RunTest(testCommand, &outs, &retval, 0, remainingTime, 0);
- if(runTestRes != cmsysProcess_State_Exited || retval != 0)
- {
+ if (runTestRes != cmsysProcess_State_Exited || retval != 0) {
out << "Test command failed: " << testCommand[0] << "\n";
retval = 1;
- }
+ }
out << outs << "\n";
- if(outstring)
- {
+ if (outstring) {
*outstring = out.str();
- }
- else
- {
+ } else {
cmCTestLog(this->CTest, OUTPUT, out.str() << std::endl);
- }
+ }
return retval;
}
@@ -432,114 +369,89 @@ int cmCTestBuildAndTestHandler::ProcessCommandLineArguments(
const std::vector<std::string>& allArgs)
{
// --build-and-test options
- if(currentArg.find("--build-and-test",0) == 0 && idx < allArgs.size() - 1)
- {
- if(idx+2 < allArgs.size())
- {
+ if (currentArg.find("--build-and-test", 0) == 0 &&
+ idx < allArgs.size() - 1) {
+ if (idx + 2 < allArgs.size()) {
idx++;
this->SourceDir = allArgs[idx];
idx++;
this->BinaryDir = allArgs[idx];
// dir must exist before CollapseFullPath is called
cmSystemTools::MakeDirectory(this->BinaryDir.c_str());
- this->BinaryDir
- = cmSystemTools::CollapseFullPath(this->BinaryDir);
- this->SourceDir
- = cmSystemTools::CollapseFullPath(this->SourceDir);
- }
- else
- {
+ this->BinaryDir = cmSystemTools::CollapseFullPath(this->BinaryDir);
+ this->SourceDir = cmSystemTools::CollapseFullPath(this->SourceDir);
+ } else {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "--build-and-test must have source and binary dir" << std::endl);
+ "--build-and-test must have source and binary dir"
+ << std::endl);
return 0;
- }
}
- if(currentArg.find("--build-target",0) == 0 && idx < allArgs.size() - 1)
- {
+ }
+ if (currentArg.find("--build-target", 0) == 0 && idx < allArgs.size() - 1) {
idx++;
this->BuildTargets.push_back(allArgs[idx]);
- }
- if(currentArg.find("--build-nocmake",0) == 0)
- {
+ }
+ if (currentArg.find("--build-nocmake", 0) == 0) {
this->BuildNoCMake = true;
- }
- if(currentArg.find("--build-run-dir",0) == 0 && idx < allArgs.size() - 1)
- {
+ }
+ if (currentArg.find("--build-run-dir", 0) == 0 && idx < allArgs.size() - 1) {
idx++;
this->BuildRunDir = allArgs[idx];
- }
- if(currentArg.find("--build-two-config",0) == 0)
- {
+ }
+ if (currentArg.find("--build-two-config", 0) == 0) {
this->BuildTwoConfig = true;
- }
- if(currentArg.find("--build-exe-dir",0) == 0 && idx < allArgs.size() - 1)
- {
+ }
+ if (currentArg.find("--build-exe-dir", 0) == 0 && idx < allArgs.size() - 1) {
idx++;
this->ExecutableDirectory = allArgs[idx];
- }
- if(currentArg.find("--test-timeout",0) == 0 && idx < allArgs.size() - 1)
- {
+ }
+ if (currentArg.find("--test-timeout", 0) == 0 && idx < allArgs.size() - 1) {
idx++;
this->Timeout = atof(allArgs[idx].c_str());
- }
- if(currentArg == "--build-generator" && idx < allArgs.size() - 1)
- {
+ }
+ if (currentArg == "--build-generator" && idx < allArgs.size() - 1) {
idx++;
this->BuildGenerator = allArgs[idx];
- }
- if(currentArg == "--build-generator-platform" &&
- idx < allArgs.size() - 1)
- {
+ }
+ if (currentArg == "--build-generator-platform" && idx < allArgs.size() - 1) {
idx++;
this->BuildGeneratorPlatform = allArgs[idx];
- }
- if(currentArg == "--build-generator-toolset" &&
- idx < allArgs.size() - 1)
- {
+ }
+ if (currentArg == "--build-generator-toolset" && idx < allArgs.size() - 1) {
idx++;
this->BuildGeneratorToolset = allArgs[idx];
- }
- if(currentArg.find("--build-project",0) == 0 && idx < allArgs.size() - 1)
- {
+ }
+ if (currentArg.find("--build-project", 0) == 0 && idx < allArgs.size() - 1) {
idx++;
this->BuildProject = allArgs[idx];
- }
- if(currentArg.find("--build-makeprogram",0) == 0 &&
- idx < allArgs.size() - 1)
- {
+ }
+ if (currentArg.find("--build-makeprogram", 0) == 0 &&
+ idx < allArgs.size() - 1) {
idx++;
this->BuildMakeProgram = allArgs[idx];
- }
- if(currentArg.find("--build-config-sample",0) == 0 &&
- idx < allArgs.size() - 1)
- {
+ }
+ if (currentArg.find("--build-config-sample", 0) == 0 &&
+ idx < allArgs.size() - 1) {
idx++;
this->ConfigSample = allArgs[idx];
- }
- if(currentArg.find("--build-noclean",0) == 0)
- {
+ }
+ if (currentArg.find("--build-noclean", 0) == 0) {
this->BuildNoClean = true;
- }
- if(currentArg.find("--build-options",0) == 0)
- {
- while(idx+1 < allArgs.size() &&
- allArgs[idx+1] != "--build-target" &&
- allArgs[idx+1] != "--test-command")
- {
+ }
+ if (currentArg.find("--build-options", 0) == 0) {
+ while (idx + 1 < allArgs.size() && allArgs[idx + 1] != "--build-target" &&
+ allArgs[idx + 1] != "--test-command") {
++idx;
this->BuildOptions.push_back(allArgs[idx]);
- }
}
- if(currentArg.find("--test-command",0) == 0 && idx < allArgs.size() - 1)
- {
+ }
+ if (currentArg.find("--test-command", 0) == 0 && idx < allArgs.size() - 1) {
++idx;
this->TestCommand = allArgs[idx];
- while(idx+1 < allArgs.size())
- {
+ while (idx + 1 < allArgs.size()) {
++idx;
this->TestCommandArgs.push_back(allArgs[idx]);
- }
}
+ }
return 1;
}
-
diff --git a/Source/CTest/cmCTestBuildAndTestHandler.h b/Source/CTest/cmCTestBuildAndTestHandler.h
index a75c631..d0443ae 100644
--- a/Source/CTest/cmCTestBuildAndTestHandler.h
+++ b/Source/CTest/cmCTestBuildAndTestHandler.h
@@ -13,7 +13,6 @@
#ifndef cmCTestBuildAndTestHandler_h
#define cmCTestBuildAndTestHandler_h
-
#include "cmCTestGenericHandler.h"
#include "cmListFileCache.h"
@@ -50,31 +49,29 @@ public:
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);
+ int RunCMake(std::string* outstring, std::ostringstream& out,
+ std::string& cmakeOutString, std::string& cwd, cmake* cm);
- std::string Output;
+ std::string Output;
- std::string BuildGenerator;
- std::string BuildGeneratorPlatform;
- std::string BuildGeneratorToolset;
+ std::string BuildGenerator;
+ std::string BuildGeneratorPlatform;
+ std::string BuildGeneratorToolset;
std::vector<std::string> BuildOptions;
- bool BuildTwoConfig;
- std::string BuildMakeProgram;
- std::string ConfigSample;
- std::string SourceDir;
- std::string BinaryDir;
- std::string BuildProject;
- std::string TestCommand;
- bool BuildNoClean;
- std::string BuildRunDir;
- std::string ExecutableDirectory;
+ bool BuildTwoConfig;
+ std::string BuildMakeProgram;
+ std::string ConfigSample;
+ std::string SourceDir;
+ std::string BinaryDir;
+ std::string BuildProject;
+ std::string TestCommand;
+ bool BuildNoClean;
+ std::string BuildRunDir;
+ std::string ExecutableDirectory;
std::vector<std::string> TestCommandArgs;
std::vector<std::string> BuildTargets;
- bool BuildNoCMake;
- double Timeout;
+ bool BuildNoCMake;
+ double Timeout;
};
#endif
-
diff --git a/Source/CTest/cmCTestBuildCommand.cxx b/Source/CTest/cmCTestBuildCommand.cxx
index ca3960f..05cccbf 100644
--- a/Source/CTest/cmCTestBuildCommand.cxx
+++ b/Source/CTest/cmCTestBuildCommand.cxx
@@ -17,7 +17,6 @@
#include "cmGlobalGenerator.h"
#include "cmake.h"
-
cmCTestBuildCommand::cmCTestBuildCommand()
{
this->GlobalGenerator = 0;
@@ -33,37 +32,31 @@ cmCTestBuildCommand::cmCTestBuildCommand()
cmCTestBuildCommand::~cmCTestBuildCommand()
{
- if ( this->GlobalGenerator )
- {
+ if (this->GlobalGenerator) {
delete this->GlobalGenerator;
this->GlobalGenerator = 0;
- }
+ }
}
cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler()
{
- cmCTestGenericHandler* handler
- = this->CTest->GetInitializedHandler("build");
- if ( !handler )
- {
+ cmCTestGenericHandler* handler = this->CTest->GetInitializedHandler("build");
+ if (!handler) {
this->SetError("internal CTest error. Cannot instantiate build handler");
return 0;
- }
- this->Handler = (cmCTestBuildHandler*)handler;
+ }
+ this->Handler = (cmCTestBuildHandler*)handler;
- const char* ctestBuildCommand
- = this->Makefile->GetDefinition("CTEST_BUILD_COMMAND");
- if ( ctestBuildCommand && *ctestBuildCommand )
- {
+ const char* ctestBuildCommand =
+ this->Makefile->GetDefinition("CTEST_BUILD_COMMAND");
+ if (ctestBuildCommand && *ctestBuildCommand) {
this->CTest->SetCTestConfiguration("MakeCommand", ctestBuildCommand,
- this->Quiet);
- }
- else
- {
- const char* cmakeGeneratorName
- = this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR");
- const char* cmakeProjectName
- = (this->Values[ctb_PROJECT_NAME] && *this->Values[ctb_PROJECT_NAME])
+ this->Quiet);
+ } else {
+ const char* cmakeGeneratorName =
+ this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR");
+ const char* cmakeProjectName =
+ (this->Values[ctb_PROJECT_NAME] && *this->Values[ctb_PROJECT_NAME])
? this->Values[ctb_PROJECT_NAME]
: this->Makefile->GetDefinition("CTEST_PROJECT_NAME");
@@ -72,81 +65,71 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler()
// CTEST_CONFIGURATION_TYPE script variable, or ctest -C command
// line argument... in that order.
//
- const char* ctestBuildConfiguration
- = this->Makefile->GetDefinition("CTEST_BUILD_CONFIGURATION");
- const char* cmakeBuildConfiguration
- = (this->Values[ctb_CONFIGURATION] && *this->Values[ctb_CONFIGURATION])
+ const char* ctestBuildConfiguration =
+ this->Makefile->GetDefinition("CTEST_BUILD_CONFIGURATION");
+ const char* cmakeBuildConfiguration =
+ (this->Values[ctb_CONFIGURATION] && *this->Values[ctb_CONFIGURATION])
? this->Values[ctb_CONFIGURATION]
: ((ctestBuildConfiguration && *ctestBuildConfiguration)
- ? ctestBuildConfiguration
- : this->CTest->GetConfigType().c_str());
+ ? ctestBuildConfiguration
+ : this->CTest->GetConfigType().c_str());
- const char* cmakeBuildAdditionalFlags
- = (this->Values[ctb_FLAGS] && *this->Values[ctb_FLAGS])
+ const char* cmakeBuildAdditionalFlags =
+ (this->Values[ctb_FLAGS] && *this->Values[ctb_FLAGS])
? this->Values[ctb_FLAGS]
: this->Makefile->GetDefinition("CTEST_BUILD_FLAGS");
- const char* cmakeBuildTarget
- = (this->Values[ctb_TARGET] && *this->Values[ctb_TARGET])
+ const char* cmakeBuildTarget =
+ (this->Values[ctb_TARGET] && *this->Values[ctb_TARGET])
? this->Values[ctb_TARGET]
: this->Makefile->GetDefinition("CTEST_BUILD_TARGET");
- if ( cmakeGeneratorName && *cmakeGeneratorName &&
- cmakeProjectName && *cmakeProjectName )
- {
- if ( !cmakeBuildConfiguration )
- {
+ if (cmakeGeneratorName && *cmakeGeneratorName && cmakeProjectName &&
+ *cmakeProjectName) {
+ if (!cmakeBuildConfiguration) {
cmakeBuildConfiguration = "Release";
- }
- if ( this->GlobalGenerator )
- {
- if ( this->GlobalGenerator->GetName() != cmakeGeneratorName )
- {
+ }
+ if (this->GlobalGenerator) {
+ if (this->GlobalGenerator->GetName() != cmakeGeneratorName) {
delete this->GlobalGenerator;
this->GlobalGenerator = 0;
- }
}
- if ( !this->GlobalGenerator )
- {
+ }
+ if (!this->GlobalGenerator) {
this->GlobalGenerator =
this->Makefile->GetCMakeInstance()->CreateGlobalGenerator(
cmakeGeneratorName);
- if(!this->GlobalGenerator)
- {
+ if (!this->GlobalGenerator) {
std::string e = "could not create generator named \"";
e += cmakeGeneratorName;
e += "\"";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e);
cmSystemTools::SetFatalErrorOccured();
return 0;
- }
}
- if(strlen(cmakeBuildConfiguration) == 0)
- {
+ }
+ if (strlen(cmakeBuildConfiguration) == 0) {
const char* config = 0;
#ifdef CMAKE_INTDIR
config = CMAKE_INTDIR;
#endif
- if(!config)
- {
+ if (!config) {
config = "Debug";
- }
- cmakeBuildConfiguration = config;
}
+ cmakeBuildConfiguration = config;
+ }
std::string dir = this->CTest->GetCTestConfiguration("BuildDirectory");
- std::string buildCommand
- = this->GlobalGenerator->
- GenerateCMakeBuildCommand(cmakeBuildTarget ? cmakeBuildTarget : "",
- cmakeBuildConfiguration,
+ std::string buildCommand =
+ this->GlobalGenerator->GenerateCMakeBuildCommand(
+ cmakeBuildTarget ? cmakeBuildTarget : "", cmakeBuildConfiguration,
cmakeBuildAdditionalFlags ? cmakeBuildAdditionalFlags : "",
this->Makefile->IgnoreErrorsCMP0061());
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "SetMakeCommand:" << buildCommand << "\n", this->Quiet);
+ "SetMakeCommand:" << buildCommand << "\n",
+ this->Quiet);
this->CTest->SetCTestConfiguration("MakeCommand", buildCommand.c_str(),
- this->Quiet);
- }
- else
- {
+ this->Quiet);
+ } else {
std::ostringstream ostr;
/* clang-format off */
ostr << "has no project to build. If this is a "
@@ -163,39 +146,35 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler()
/* clang-format on */
this->SetError(ostr.str());
return 0;
- }
}
+ }
- if(const char* useLaunchers =
- this->Makefile->GetDefinition("CTEST_USE_LAUNCHERS"))
- {
+ if (const char* useLaunchers =
+ this->Makefile->GetDefinition("CTEST_USE_LAUNCHERS")) {
this->CTest->SetCTestConfiguration("UseLaunchers", useLaunchers,
- this->Quiet);
- }
+ this->Quiet);
+ }
handler->SetQuiet(this->Quiet);
return handler;
}
-
bool cmCTestBuildCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus &status)
+ cmExecutionStatus& status)
{
- bool ret = cmCTestHandlerCommand::InitialPass(args, status);
- if ( this->Values[ctb_NUMBER_ERRORS] && *this->Values[ctb_NUMBER_ERRORS])
- {
+ bool ret = cmCTestHandlerCommand::InitialPass(args, status);
+ if (this->Values[ctb_NUMBER_ERRORS] && *this->Values[ctb_NUMBER_ERRORS]) {
std::ostringstream str;
str << this->Handler->GetTotalErrors();
- this->Makefile->AddDefinition(
- this->Values[ctb_NUMBER_ERRORS], str.str().c_str());
- }
- if ( this->Values[ctb_NUMBER_WARNINGS]
- && *this->Values[ctb_NUMBER_WARNINGS])
- {
+ this->Makefile->AddDefinition(this->Values[ctb_NUMBER_ERRORS],
+ str.str().c_str());
+ }
+ if (this->Values[ctb_NUMBER_WARNINGS] &&
+ *this->Values[ctb_NUMBER_WARNINGS]) {
std::ostringstream str;
str << this->Handler->GetTotalWarnings();
- this->Makefile->AddDefinition(
- this->Values[ctb_NUMBER_WARNINGS], str.str().c_str());
- }
+ this->Makefile->AddDefinition(this->Values[ctb_NUMBER_WARNINGS],
+ str.str().c_str());
+ }
return ret;
}
diff --git a/Source/CTest/cmCTestBuildCommand.h b/Source/CTest/cmCTestBuildCommand.h
index 2632ebc..f420c2f 100644
--- a/Source/CTest/cmCTestBuildCommand.h
+++ b/Source/CTest/cmCTestBuildCommand.h
@@ -25,7 +25,6 @@ class cmCTestBuildHandler;
class cmCTestBuildCommand : public cmCTestHandlerCommand
{
public:
-
cmCTestBuildCommand();
~cmCTestBuildCommand();
@@ -33,20 +32,20 @@ public:
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
- {
+ {
cmCTestBuildCommand* ni = new cmCTestBuildCommand;
ni->CTest = this->CTest;
ni->CTestScriptHandler = this->CTestScriptHandler;
return ni;
- }
+ }
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const { return "ctest_build";}
+ virtual std::string GetName() const { return "ctest_build"; }
virtual bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus &status);
+ cmExecutionStatus& status);
cmTypeMacro(cmCTestBuildCommand, cmCTestHandlerCommand);
@@ -54,7 +53,8 @@ public:
protected:
cmCTestBuildHandler* Handler;
- enum {
+ enum
+ {
ctb_BUILD = ct_LAST,
ctb_NUMBER_ERRORS,
ctb_NUMBER_WARNINGS,
@@ -68,5 +68,4 @@ protected:
cmCTestGenericHandler* InitializeHandler();
};
-
#endif
diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx
index ed0cad7..20b0e9c 100644
--- a/Source/CTest/cmCTestBuildHandler.cxx
+++ b/Source/CTest/cmCTestBuildHandler.cxx
@@ -36,7 +36,6 @@
#include <stdlib.h>
#include <time.h>
-
static const char* cmCTestErrorMatches[] = {
"^[Bb]us [Ee]rror",
"^[Ss]egmentation [Vv]iolation",
@@ -163,16 +162,15 @@ struct cmCTestBuildCompileErrorWarningRex
int LineIndex;
};
-static cmCTestBuildCompileErrorWarningRex
-cmCTestWarningErrorFileLine[] = {
- { "^Warning W[0-9]+ ([a-zA-Z.\\:/0-9_+ ~-]+) ([0-9]+):", 1, 2 },
- { "^([a-zA-Z./0-9_+ ~-]+):([0-9]+):", 1, 2 },
- { "^([a-zA-Z.\\:/0-9_+ ~-]+)\\(([0-9]+)\\)", 1, 2 },
- { "^[0-9]+>([a-zA-Z.\\:/0-9_+ ~-]+)\\(([0-9]+)\\)", 1, 2 },
- { "^([a-zA-Z./0-9_+ ~-]+)\\(([0-9]+)\\)", 1, 2 },
- { "\"([a-zA-Z./0-9_+ ~-]+)\", line ([0-9]+)", 1, 2 },
- { "File = ([a-zA-Z./0-9_+ ~-]+), Line = ([0-9]+)", 1, 2 },
- { 0, 0, 0 }
+static cmCTestBuildCompileErrorWarningRex cmCTestWarningErrorFileLine[] = {
+ { "^Warning W[0-9]+ ([a-zA-Z.\\:/0-9_+ ~-]+) ([0-9]+):", 1, 2 },
+ { "^([a-zA-Z./0-9_+ ~-]+):([0-9]+):", 1, 2 },
+ { "^([a-zA-Z.\\:/0-9_+ ~-]+)\\(([0-9]+)\\)", 1, 2 },
+ { "^[0-9]+>([a-zA-Z.\\:/0-9_+ ~-]+)\\(([0-9]+)\\)", 1, 2 },
+ { "^([a-zA-Z./0-9_+ ~-]+)\\(([0-9]+)\\)", 1, 2 },
+ { "\"([a-zA-Z./0-9_+ ~-]+)\", line ([0-9]+)", 1, 2 },
+ { "File = ([a-zA-Z./0-9_+ ~-]+), Line = ([0-9]+)", 1, 2 },
+ { 0, 0, 0 }
};
cmCTestBuildHandler::cmCTestBuildHandler()
@@ -233,131 +231,113 @@ void cmCTestBuildHandler::Initialize()
this->UseCTestLaunch = false;
}
-void cmCTestBuildHandler::PopulateCustomVectors(cmMakefile *mf)
+void cmCTestBuildHandler::PopulateCustomVectors(cmMakefile* mf)
{
this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_ERROR_MATCH",
- this->CustomErrorMatches);
+ this->CustomErrorMatches);
this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_ERROR_EXCEPTION",
- this->CustomErrorExceptions);
+ this->CustomErrorExceptions);
this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_WARNING_MATCH",
- this->CustomWarningMatches);
+ this->CustomWarningMatches);
this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_WARNING_EXCEPTION",
- this->CustomWarningExceptions);
- this->CTest->PopulateCustomInteger(mf,
- "CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS",
- this->MaxErrors);
- this->CTest->PopulateCustomInteger(mf,
- "CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS",
- this->MaxWarnings);
+ this->CustomWarningExceptions);
+ this->CTest->PopulateCustomInteger(
+ mf, "CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS", this->MaxErrors);
+ this->CTest->PopulateCustomInteger(
+ mf, "CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS", this->MaxWarnings);
int n = -1;
this->CTest->PopulateCustomInteger(mf, "CTEST_CUSTOM_ERROR_PRE_CONTEXT", n);
- if (n != -1)
- {
+ if (n != -1) {
this->MaxPreContext = static_cast<size_t>(n);
- }
+ }
n = -1;
this->CTest->PopulateCustomInteger(mf, "CTEST_CUSTOM_ERROR_POST_CONTEXT", n);
- if (n != -1)
- {
+ if (n != -1) {
this->MaxPostContext = static_cast<size_t>(n);
- }
+ }
// Record the user-specified custom warning rules.
- if(const char* customWarningMatchers =
- mf->GetDefinition("CTEST_CUSTOM_WARNING_MATCH"))
- {
+ if (const char* customWarningMatchers =
+ mf->GetDefinition("CTEST_CUSTOM_WARNING_MATCH")) {
cmSystemTools::ExpandListArgument(customWarningMatchers,
this->ReallyCustomWarningMatches);
- }
- if(const char* customWarningExceptions =
- mf->GetDefinition("CTEST_CUSTOM_WARNING_EXCEPTION"))
- {
+ }
+ if (const char* customWarningExceptions =
+ mf->GetDefinition("CTEST_CUSTOM_WARNING_EXCEPTION")) {
cmSystemTools::ExpandListArgument(customWarningExceptions,
this->ReallyCustomWarningExceptions);
- }
+ }
}
std::string cmCTestBuildHandler::GetMakeCommand()
{
- std::string makeCommand
- = this->CTest->GetCTestConfiguration("MakeCommand");
- cmCTestOptionalLog(this->CTest,
- HANDLER_VERBOSE_OUTPUT, "MakeCommand:" << makeCommand << "\n",
- this->Quiet);
+ std::string makeCommand = this->CTest->GetCTestConfiguration("MakeCommand");
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "MakeCommand:" << makeCommand << "\n", this->Quiet);
std::string configType = this->CTest->GetConfigType();
- if (configType == "")
- {
- configType
- = this->CTest->GetCTestConfiguration("DefaultCTestConfigurationType");
- }
- if (configType == "")
- {
+ if (configType == "") {
+ configType =
+ this->CTest->GetCTestConfiguration("DefaultCTestConfigurationType");
+ }
+ if (configType == "") {
configType = "Release";
- }
+ }
- cmSystemTools::ReplaceString(makeCommand,
- "${CTEST_CONFIGURATION_TYPE}", configType.c_str());
+ cmSystemTools::ReplaceString(makeCommand, "${CTEST_CONFIGURATION_TYPE}",
+ configType.c_str());
return makeCommand;
}
-//clearly it would be nice if this were broken up into a few smaller
-//functions and commented...
+// clearly it would be nice if this were broken up into a few smaller
+// functions and commented...
int cmCTestBuildHandler::ProcessHandler()
{
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "Build project" << std::endl,
- this->Quiet);
+ this->Quiet);
// do we have time for this
- if (this->CTest->GetRemainingTimeAllowed() < 120)
- {
+ if (this->CTest->GetRemainingTimeAllowed() < 120) {
return 0;
- }
+ }
int entry;
- for ( entry = 0;
- cmCTestWarningErrorFileLine[entry].RegularExpressionString;
- ++ entry )
- {
+ for (entry = 0; cmCTestWarningErrorFileLine[entry].RegularExpressionString;
+ ++entry) {
cmCTestBuildHandler::cmCTestCompileErrorWarningRex r;
- if ( r.RegularExpression.compile(
- cmCTestWarningErrorFileLine[entry].RegularExpressionString) )
- {
+ if (r.RegularExpression.compile(
+ cmCTestWarningErrorFileLine[entry].RegularExpressionString)) {
r.FileIndex = cmCTestWarningErrorFileLine[entry].FileIndex;
r.LineIndex = cmCTestWarningErrorFileLine[entry].LineIndex;
this->ErrorWarningFileLineRegex.push_back(r);
- }
- else
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Problem Compiling regular expression: "
- << cmCTestWarningErrorFileLine[entry].RegularExpressionString
- << std::endl);
- }
+ } else {
+ cmCTestLog(
+ this->CTest, ERROR_MESSAGE, "Problem Compiling regular expression: "
+ << cmCTestWarningErrorFileLine[entry].RegularExpressionString
+ << std::endl);
}
+ }
// Determine build command and build directory
std::string makeCommand = this->GetMakeCommand();
- if (makeCommand.empty())
- {
+ if (makeCommand.empty()) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Cannot find MakeCommand key in the DartConfiguration.tcl"
- << std::endl);
+ "Cannot find MakeCommand key in the DartConfiguration.tcl"
+ << std::endl);
return -1;
- }
+ }
- const std::string &buildDirectory
- = this->CTest->GetCTestConfiguration("BuildDirectory");
- if (buildDirectory.empty())
- {
+ const std::string& buildDirectory =
+ this->CTest->GetCTestConfiguration("BuildDirectory");
+ if (buildDirectory.empty()) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Cannot find BuildDirectory key in the DartConfiguration.tcl"
- << std::endl);
+ "Cannot find BuildDirectory key in the DartConfiguration.tcl"
+ << std::endl);
return -1;
- }
+ }
std::string const& useLaunchers =
this->CTest->GetCTestConfiguration("UseLaunchers");
@@ -366,94 +346,81 @@ int cmCTestBuildHandler::ProcessHandler()
// Create a last build log
cmGeneratedFileStream ofs;
double elapsed_time_start = cmSystemTools::GetTime();
- if ( !this->StartLogFile("Build", ofs) )
- {
+ if (!this->StartLogFile("Build", ofs)) {
cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot create build log file"
- << std::endl);
- }
+ << std::endl);
+ }
// Create lists of regular expression strings for errors, error exceptions,
// warnings and warning exceptions.
std::vector<std::string>::size_type cc;
- for ( cc = 0; cmCTestErrorMatches[cc]; cc ++ )
- {
+ for (cc = 0; cmCTestErrorMatches[cc]; cc++) {
this->CustomErrorMatches.push_back(cmCTestErrorMatches[cc]);
- }
- for ( cc = 0; cmCTestErrorExceptions[cc]; cc ++ )
- {
+ }
+ for (cc = 0; cmCTestErrorExceptions[cc]; cc++) {
this->CustomErrorExceptions.push_back(cmCTestErrorExceptions[cc]);
- }
- for ( cc = 0; cmCTestWarningMatches[cc]; cc ++ )
- {
+ }
+ for (cc = 0; cmCTestWarningMatches[cc]; cc++) {
this->CustomWarningMatches.push_back(cmCTestWarningMatches[cc]);
- }
+ }
- for ( cc = 0; cmCTestWarningExceptions[cc]; cc ++ )
- {
+ for (cc = 0; cmCTestWarningExceptions[cc]; cc++) {
this->CustomWarningExceptions.push_back(cmCTestWarningExceptions[cc]);
- }
+ }
// Pre-compile regular expressions objects for all regular expressions
std::vector<std::string>::iterator it;
-#define cmCTestBuildHandlerPopulateRegexVector(strings, regexes) \
- regexes.clear(); \
- cmCTestOptionalLog(this->CTest, DEBUG, this << "Add " #regexes \
- << std::endl, this->Quiet); \
- for ( it = strings.begin(); it != strings.end(); ++it ) \
- { \
- cmCTestOptionalLog(this->CTest, DEBUG, "Add " #strings ": " \
- << *it << std::endl, this->Quiet); \
- regexes.push_back(it->c_str()); \
- }
- cmCTestBuildHandlerPopulateRegexVector(
- this->CustomErrorMatches, this->ErrorMatchRegex);
- cmCTestBuildHandlerPopulateRegexVector(
- this->CustomErrorExceptions, this->ErrorExceptionRegex);
- cmCTestBuildHandlerPopulateRegexVector(
- this->CustomWarningMatches, this->WarningMatchRegex);
- cmCTestBuildHandlerPopulateRegexVector(
- this->CustomWarningExceptions, this->WarningExceptionRegex);
-
+#define cmCTestBuildHandlerPopulateRegexVector(strings, regexes) \
+ regexes.clear(); \
+ cmCTestOptionalLog(this->CTest, DEBUG, \
+ this << "Add " #regexes << std::endl, this->Quiet); \
+ for (it = strings.begin(); it != strings.end(); ++it) { \
+ cmCTestOptionalLog(this->CTest, DEBUG, \
+ "Add " #strings ": " << *it << std::endl, \
+ this->Quiet); \
+ regexes.push_back(it->c_str()); \
+ }
+ cmCTestBuildHandlerPopulateRegexVector(this->CustomErrorMatches,
+ this->ErrorMatchRegex);
+ cmCTestBuildHandlerPopulateRegexVector(this->CustomErrorExceptions,
+ this->ErrorExceptionRegex);
+ cmCTestBuildHandlerPopulateRegexVector(this->CustomWarningMatches,
+ this->WarningMatchRegex);
+ cmCTestBuildHandlerPopulateRegexVector(this->CustomWarningExceptions,
+ this->WarningExceptionRegex);
// Determine source and binary tree substitutions to simplify the output.
this->SimplifySourceDir = "";
this->SimplifyBuildDir = "";
- if ( this->CTest->GetCTestConfiguration("SourceDirectory").size() > 20 )
- {
- std::string srcdir
- = this->CTest->GetCTestConfiguration("SourceDirectory") + "/";
+ if (this->CTest->GetCTestConfiguration("SourceDirectory").size() > 20) {
+ std::string srcdir =
+ this->CTest->GetCTestConfiguration("SourceDirectory") + "/";
std::string srcdirrep;
- for ( cc = srcdir.size()-2; cc > 0; cc -- )
- {
- if ( srcdir[cc] == '/' )
- {
+ for (cc = srcdir.size() - 2; cc > 0; cc--) {
+ if (srcdir[cc] == '/') {
srcdirrep = srcdir.c_str() + cc;
srcdirrep = "/..." + srcdirrep;
- srcdir = srcdir.substr(0, cc+1);
+ srcdir = srcdir.substr(0, cc + 1);
break;
- }
}
- this->SimplifySourceDir = srcdir;
}
- if ( this->CTest->GetCTestConfiguration("BuildDirectory").size() > 20 )
- {
- std::string bindir
- = this->CTest->GetCTestConfiguration("BuildDirectory") + "/";
+ this->SimplifySourceDir = srcdir;
+ }
+ if (this->CTest->GetCTestConfiguration("BuildDirectory").size() > 20) {
+ std::string bindir =
+ this->CTest->GetCTestConfiguration("BuildDirectory") + "/";
std::string bindirrep;
- for ( cc = bindir.size()-2; cc > 0; cc -- )
- {
- if ( bindir[cc] == '/' )
- {
+ for (cc = bindir.size() - 2; cc > 0; cc--) {
+ if (bindir[cc] == '/') {
bindirrep = bindir.c_str() + cc;
bindirrep = "/..." + bindirrep;
- bindir = bindir.substr(0, cc+1);
+ bindir = bindir.substr(0, cc + 1);
break;
- }
}
- this->SimplifyBuildDir = bindir;
}
-
+ this->SimplifyBuildDir = bindir;
+ }
// Ok, let's do the build
@@ -462,16 +429,14 @@ int cmCTestBuildHandler::ProcessHandler()
this->StartBuildTime = cmSystemTools::GetTime();
int retVal = 0;
int res = cmsysProcess_State_Exited;
- if ( !this->CTest->GetShowOnly() )
- {
+ if (!this->CTest->GetShowOnly()) {
res = this->RunMakeCommand(makeCommand.c_str(), &retVal,
- buildDirectory.c_str(), 0, ofs);
- }
- else
- {
- cmCTestOptionalLog(this->CTest, DEBUG, "Build with command: " <<
- makeCommand << std::endl, this->Quiet);
- }
+ buildDirectory.c_str(), 0, ofs);
+ } else {
+ cmCTestOptionalLog(this->CTest, DEBUG,
+ "Build with command: " << makeCommand << std::endl,
+ this->Quiet);
+ }
// Remember end build time and calculate elapsed time
this->EndBuild = this->CTest->CurrentTime();
@@ -480,69 +445,60 @@ int cmCTestBuildHandler::ProcessHandler()
// Cleanups strings in the errors and warnings list.
t_ErrorsAndWarningsVector::iterator evit;
- if ( !this->SimplifySourceDir.empty() )
- {
- for ( evit = this->ErrorsAndWarnings.begin();
- evit != this->ErrorsAndWarnings.end();
- ++ evit )
- {
- cmSystemTools::ReplaceString(
- evit->Text, this->SimplifySourceDir.c_str(), "/.../");
- cmSystemTools::ReplaceString(
- evit->PreContext, this->SimplifySourceDir.c_str(), "/.../");
- cmSystemTools::ReplaceString(
- evit->PostContext, this->SimplifySourceDir.c_str(), "/.../");
- }
+ if (!this->SimplifySourceDir.empty()) {
+ for (evit = this->ErrorsAndWarnings.begin();
+ evit != this->ErrorsAndWarnings.end(); ++evit) {
+ cmSystemTools::ReplaceString(evit->Text, this->SimplifySourceDir.c_str(),
+ "/.../");
+ cmSystemTools::ReplaceString(evit->PreContext,
+ this->SimplifySourceDir.c_str(), "/.../");
+ cmSystemTools::ReplaceString(evit->PostContext,
+ this->SimplifySourceDir.c_str(), "/.../");
}
-
- if ( !this->SimplifyBuildDir.empty() )
- {
- for ( evit = this->ErrorsAndWarnings.begin();
- evit != this->ErrorsAndWarnings.end();
- ++ evit )
- {
- cmSystemTools::ReplaceString(
- evit->Text, this->SimplifyBuildDir.c_str(), "/.../");
- cmSystemTools::ReplaceString(
- evit->PreContext, this->SimplifyBuildDir.c_str(), "/.../");
- cmSystemTools::ReplaceString(
- evit->PostContext, this->SimplifyBuildDir.c_str(), "/.../");
- }
+ }
+
+ if (!this->SimplifyBuildDir.empty()) {
+ for (evit = this->ErrorsAndWarnings.begin();
+ evit != this->ErrorsAndWarnings.end(); ++evit) {
+ cmSystemTools::ReplaceString(evit->Text, this->SimplifyBuildDir.c_str(),
+ "/.../");
+ cmSystemTools::ReplaceString(evit->PreContext,
+ this->SimplifyBuildDir.c_str(), "/.../");
+ cmSystemTools::ReplaceString(evit->PostContext,
+ this->SimplifyBuildDir.c_str(), "/.../");
}
+ }
// Generate XML output
cmGeneratedFileStream xofs;
- if(!this->StartResultingXML(cmCTest::PartBuild, "Build", xofs))
- {
+ if (!this->StartResultingXML(cmCTest::PartBuild, "Build", xofs)) {
cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot create build XML file"
- << std::endl);
+ << std::endl);
return -1;
- }
+ }
cmXMLWriter xml(xofs);
this->GenerateXMLHeader(xml);
- if(this->UseCTestLaunch)
- {
+ if (this->UseCTestLaunch) {
this->GenerateXMLLaunched(xml);
- }
- else
- {
+ } else {
this->GenerateXMLLogScraped(xml);
- }
+ }
this->GenerateXMLFooter(xml, elapsed_build_time);
- if (res != cmsysProcess_State_Exited || retVal || this->TotalErrors > 0)
- {
+ if (res != cmsysProcess_State_Exited || retVal || this->TotalErrors > 0) {
cmCTestLog(this->CTest, ERROR_MESSAGE, "Error(s) when building project"
- << std::endl);
- }
+ << std::endl);
+ }
// Display message about number of errors and warnings
- cmCTestLog(this->CTest, HANDLER_OUTPUT, " " << this->TotalErrors
- << (this->TotalErrors >= this->MaxErrors ? " or more" : "")
- << " Compiler errors" << std::endl);
- cmCTestLog(this->CTest, HANDLER_OUTPUT, " " << this->TotalWarnings
- << (this->TotalWarnings >= this->MaxWarnings ? " or more" : "")
- << " Compiler warnings" << std::endl);
+ cmCTestLog(this->CTest, HANDLER_OUTPUT, " "
+ << this->TotalErrors
+ << (this->TotalErrors >= this->MaxErrors ? " or more" : "")
+ << " Compiler errors" << std::endl);
+ cmCTestLog(this->CTest, HANDLER_OUTPUT, " "
+ << this->TotalWarnings
+ << (this->TotalWarnings >= this->MaxWarnings ? " or more" : "")
+ << " Compiler warnings" << std::endl);
return retVal;
}
@@ -553,40 +509,43 @@ void cmCTestBuildHandler::GenerateXMLHeader(cmXMLWriter& xml)
xml.StartElement("Build");
xml.Element("StartDateTime", this->StartBuild);
xml.Element("StartBuildTime",
- static_cast<unsigned int>(this->StartBuildTime));
+ static_cast<unsigned int>(this->StartBuildTime));
xml.Element("BuildCommand", this->GetMakeCommand());
}
class cmCTestBuildHandler::FragmentCompare
{
public:
- FragmentCompare(cmFileTimeComparison* ftc): FTC(ftc) {}
- FragmentCompare(): FTC(0) {}
+ FragmentCompare(cmFileTimeComparison* ftc)
+ : FTC(ftc)
+ {
+ }
+ FragmentCompare()
+ : FTC(0)
+ {
+ }
bool operator()(std::string const& l, std::string const& r)
- {
+ {
// Order files by modification time. Use lexicographic order
// among files with the same time.
int result;
- if(this->FTC->FileTimeCompare(l.c_str(), r.c_str(), &result) &&
- result != 0)
- {
+ if (this->FTC->FileTimeCompare(l.c_str(), r.c_str(), &result) &&
+ result != 0) {
return result < 0;
- }
- else
- {
+ } else {
return l < r;
- }
}
+ }
+
private:
cmFileTimeComparison* FTC;
};
void cmCTestBuildHandler::GenerateXMLLaunched(cmXMLWriter& xml)
{
- if(this->CTestLaunchDir.empty())
- {
+ if (this->CTestLaunchDir.empty()) {
return;
- }
+ }
// Sort XML fragments in chronological order.
cmFileTimeComparison ftc;
@@ -601,29 +560,24 @@ void cmCTestBuildHandler::GenerateXMLLaunched(cmXMLWriter& xml)
cmsys::Directory launchDir;
launchDir.Load(this->CTestLaunchDir);
unsigned long n = launchDir.GetNumberOfFiles();
- for(unsigned long i=0; i < n; ++i)
- {
+ for (unsigned long i = 0; i < n; ++i) {
const char* fname = launchDir.GetFile(i);
- if(this->IsLaunchedErrorFile(fname) && numErrorsAllowed)
- {
+ if (this->IsLaunchedErrorFile(fname) && numErrorsAllowed) {
numErrorsAllowed--;
fragments.insert(this->CTestLaunchDir + "/" + fname);
++this->TotalErrors;
- }
- else if(this->IsLaunchedWarningFile(fname) && numWarningsAllowed)
- {
+ } else if (this->IsLaunchedWarningFile(fname) && numWarningsAllowed) {
numWarningsAllowed--;
fragments.insert(this->CTestLaunchDir + "/" + fname);
++this->TotalWarnings;
- }
}
+ }
// Copy the fragments into the final XML file.
- for(Fragments::const_iterator fi = fragments.begin();
- fi != fragments.end(); ++fi)
- {
+ for (Fragments::const_iterator fi = fragments.begin(); fi != fragments.end();
+ ++fi) {
xml.FragmentFile(fi->c_str());
- }
+ }
}
void cmCTestBuildHandler::GenerateXMLLogScraped(cmXMLWriter& xml)
@@ -639,87 +593,69 @@ void cmCTestBuildHandler::GenerateXMLLogScraped(cmXMLWriter& xml)
// via a call to collapse full path.
srcdir = cmSystemTools::CollapseFullPath(srcdir);
srcdir += "/";
- for ( it = ew.begin();
- it != ew.end() && (numErrorsAllowed || numWarningsAllowed); it++ )
- {
- cmCTestBuildErrorWarning *cm = &(*it);
+ for (it = ew.begin();
+ it != ew.end() && (numErrorsAllowed || numWarningsAllowed); it++) {
+ cmCTestBuildErrorWarning* cm = &(*it);
if ((cm->Error && numErrorsAllowed) ||
- (!cm->Error && numWarningsAllowed))
- {
- if (cm->Error)
- {
+ (!cm->Error && numWarningsAllowed)) {
+ if (cm->Error) {
numErrorsAllowed--;
- }
- else
- {
+ } else {
numWarningsAllowed--;
- }
+ }
xml.StartElement(cm->Error ? "Error" : "Warning");
xml.Element("BuildLogLine", cm->LogLine);
xml.Element("Text", cm->Text);
std::vector<cmCTestCompileErrorWarningRex>::iterator rit;
- for ( rit = this->ErrorWarningFileLineRegex.begin();
- rit != this->ErrorWarningFileLineRegex.end(); ++ rit )
- {
+ for (rit = this->ErrorWarningFileLineRegex.begin();
+ rit != this->ErrorWarningFileLineRegex.end(); ++rit) {
cmsys::RegularExpression* re = &rit->RegularExpression;
- if ( re->find(cm->Text.c_str() ) )
- {
+ if (re->find(cm->Text.c_str())) {
cm->SourceFile = re->match(rit->FileIndex);
// At this point we need to make this->SourceFile relative to
// the source root of the project, so cvs links will work
cmSystemTools::ConvertToUnixSlashes(cm->SourceFile);
- if(cm->SourceFile.find("/.../") != cm->SourceFile.npos)
- {
+ if (cm->SourceFile.find("/.../") != cm->SourceFile.npos) {
cmSystemTools::ReplaceString(cm->SourceFile, "/.../", "");
std::string::size_type p = cm->SourceFile.find("/");
- if(p != cm->SourceFile.npos)
- {
- cm->SourceFile = cm->SourceFile.substr(
- p+1, cm->SourceFile.size()-p);
- }
+ if (p != cm->SourceFile.npos) {
+ cm->SourceFile =
+ cm->SourceFile.substr(p + 1, cm->SourceFile.size() - p);
}
- else
- {
+ } else {
// make sure it is a full path with the correct case
- cm->SourceFile = cmSystemTools::CollapseFullPath(
- cm->SourceFile);
- cmSystemTools::ReplaceString(
- cm->SourceFile, srcdir.c_str(), "");
- }
+ cm->SourceFile = cmSystemTools::CollapseFullPath(cm->SourceFile);
+ cmSystemTools::ReplaceString(cm->SourceFile, srcdir.c_str(), "");
+ }
cm->LineNumber = atoi(re->match(rit->LineIndex).c_str());
break;
- }
}
- if ( !cm->SourceFile.empty() && cm->LineNumber >= 0 )
- {
- if (!cm->SourceFile.empty())
- {
+ }
+ if (!cm->SourceFile.empty() && cm->LineNumber >= 0) {
+ if (!cm->SourceFile.empty()) {
xml.Element("SourceFile", cm->SourceFile);
- }
- if (!cm->SourceFileTail.empty())
- {
+ }
+ if (!cm->SourceFileTail.empty()) {
xml.Element("SourceFileTail", cm->SourceFileTail);
- }
- if ( cm->LineNumber >= 0 )
- {
+ }
+ if (cm->LineNumber >= 0) {
xml.Element("SourceLineNumber", cm->LineNumber);
- }
}
+ }
xml.Element("PreContext", cm->PreContext);
xml.StartElement("PostContext");
xml.Content(cm->PostContext);
// is this the last warning or error, if so notify
if ((cm->Error && !numErrorsAllowed) ||
- (!cm->Error && !numWarningsAllowed))
- {
+ (!cm->Error && !numWarningsAllowed)) {
xml.Content("\nThe maximum number of reported warnings or errors "
- "has been reached!!!\n");
- }
+ "has been reached!!!\n");
+ }
xml.EndElement(); // PostContext
xml.Element("RepeatCount", "0");
xml.EndElement(); // "Error" / "Warning"
- }
}
+ }
}
void cmCTestBuildHandler::GenerateXMLFooter(cmXMLWriter& xml,
@@ -732,7 +668,8 @@ void cmCTestBuildHandler::GenerateXMLFooter(cmXMLWriter& xml,
xml.Element("EndDateTime", this->EndBuild);
xml.Element("EndBuildTime", static_cast<unsigned int>(this->EndBuildTime));
- xml.Element("ElapsedMinutes", static_cast<int>(elapsed_build_time/6)/10.0);
+ xml.Element("ElapsedMinutes",
+ static_cast<int>(elapsed_build_time / 6) / 10.0);
xml.EndElement(); // Build
this->CTest->EndXML(xml);
}
@@ -741,14 +678,14 @@ bool cmCTestBuildHandler::IsLaunchedErrorFile(const char* fname)
{
// error-{hash}.xml
return (cmHasLiteralPrefix(fname, "error-") &&
- strcmp(fname+strlen(fname)-4, ".xml") == 0);
+ strcmp(fname + strlen(fname) - 4, ".xml") == 0);
}
bool cmCTestBuildHandler::IsLaunchedWarningFile(const char* fname)
{
// warning-{hash}.xml
return (cmHasLiteralPrefix(fname, "warning-") &&
- strcmp(fname+strlen(fname)-4, ".xml") == 0);
+ strcmp(fname + strlen(fname) - 4, ".xml") == 0);
}
//######################################################################
@@ -761,6 +698,7 @@ class cmCTestBuildHandler::LaunchHelper
public:
LaunchHelper(cmCTestBuildHandler* handler);
~LaunchHelper();
+
private:
cmCTestBuildHandler* Handler;
cmCTest* CTest;
@@ -770,18 +708,16 @@ private:
std::vector<std::string> const& matchers);
};
-cmCTestBuildHandler::LaunchHelper::LaunchHelper(cmCTestBuildHandler* handler):
- Handler(handler), CTest(handler->CTest)
+cmCTestBuildHandler::LaunchHelper::LaunchHelper(cmCTestBuildHandler* handler)
+ : Handler(handler)
+ , CTest(handler->CTest)
{
std::string tag = this->CTest->GetCurrentTag();
- if(tag.empty())
- {
+ if (tag.empty()) {
// This is not for a dashboard submission, so there is no XML.
// Skip enabling the launchers.
this->Handler->UseCTestLaunch = false;
- }
- else
- {
+ } else {
// Compute a directory in which to store launcher fragments.
std::string& launchDir = this->Handler->CTestLaunchDir;
launchDir = this->CTest->GetBinaryDir();
@@ -792,30 +728,27 @@ cmCTestBuildHandler::LaunchHelper::LaunchHelper(cmCTestBuildHandler* handler):
// Clean out any existing launcher fragments.
cmSystemTools::RemoveADirectory(launchDir);
- if(this->Handler->UseCTestLaunch)
- {
+ if (this->Handler->UseCTestLaunch) {
// Enable launcher fragments.
cmSystemTools::MakeDirectory(launchDir.c_str());
this->WriteLauncherConfig();
std::string launchEnv = "CTEST_LAUNCH_LOGS=";
launchEnv += launchDir;
cmSystemTools::PutEnv(launchEnv);
- }
}
+ }
// If not using launchers, make sure they passthru.
- if(!this->Handler->UseCTestLaunch)
- {
+ if (!this->Handler->UseCTestLaunch) {
cmSystemTools::UnsetEnv("CTEST_LAUNCH_LOGS");
- }
+ }
}
cmCTestBuildHandler::LaunchHelper::~LaunchHelper()
{
- if(this->Handler->UseCTestLaunch)
- {
+ if (this->Handler->UseCTestLaunch) {
cmSystemTools::UnsetEnv("CTEST_LAUNCH_LOGS");
- }
+ }
}
void cmCTestBuildHandler::LaunchHelper::WriteLauncherConfig()
@@ -833,56 +766,50 @@ void cmCTestBuildHandler::LaunchHelper::WriteLauncherConfig()
fout << "set(CTEST_SOURCE_DIRECTORY \"" << srcdir << "\")\n";
}
-void
-cmCTestBuildHandler::LaunchHelper
-::WriteScrapeMatchers(const char* purpose,
- std::vector<std::string> const& matchers)
+void cmCTestBuildHandler::LaunchHelper::WriteScrapeMatchers(
+ const char* purpose, std::vector<std::string> const& matchers)
{
- if(matchers.empty())
- {
+ if (matchers.empty()) {
return;
- }
+ }
std::string fname = this->Handler->CTestLaunchDir;
fname += "/Custom";
fname += purpose;
fname += ".txt";
cmGeneratedFileStream fout(fname.c_str());
- for(std::vector<std::string>::const_iterator mi = matchers.begin();
- mi != matchers.end(); ++mi)
- {
+ for (std::vector<std::string>::const_iterator mi = matchers.begin();
+ mi != matchers.end(); ++mi) {
fout << *mi << "\n";
- }
+ }
}
-int cmCTestBuildHandler::RunMakeCommand(const char* command,
- int* retVal, const char* dir, int timeout, std::ostream& ofs)
+int cmCTestBuildHandler::RunMakeCommand(const char* command, int* retVal,
+ const char* dir, int timeout,
+ std::ostream& ofs)
{
// First generate the command and arguments
std::vector<std::string> args = cmSystemTools::ParseArguments(command);
- if(args.size() < 1)
- {
+ if (args.size() < 1) {
return false;
- }
+ }
std::vector<const char*> argv;
- for(std::vector<std::string>::const_iterator a = args.begin();
- a != args.end(); ++a)
- {
+ for (std::vector<std::string>::const_iterator a = args.begin();
+ a != args.end(); ++a) {
argv.push_back(a->c_str());
- }
+ }
argv.push_back(0);
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run command:",
- this->Quiet);
+ this->Quiet);
std::vector<const char*>::iterator ait;
- for ( ait = argv.begin(); ait != argv.end() && *ait; ++ ait )
- {
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " \"" << *ait <<
- "\"", this->Quiet);
- }
+ for (ait = argv.begin(); ait != argv.end() && *ait; ++ait) {
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ " \"" << *ait << "\"", this->Quiet);
+ }
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl,
- this->Quiet);
+ this->Quiet);
// Optionally use make rule launchers to record errors and warnings.
LaunchHelper launchHelper(this);
@@ -902,12 +829,14 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command,
char* data;
int length;
- cmCTestOptionalLog(this->CTest, HANDLER_PROGRESS_OUTPUT,
- " Each symbol represents " << tick_len << " bytes of output."
- << std::endl
- << (this->UseCTestLaunch? "" :
- " '!' represents an error and '*' a warning.\n")
- << " " << std::flush, this->Quiet);
+ cmCTestOptionalLog(
+ this->CTest, HANDLER_PROGRESS_OUTPUT, " Each symbol represents "
+ << tick_len << " bytes of output." << std::endl
+ << (this->UseCTestLaunch
+ ? ""
+ : " '!' represents an error and '*' a warning.\n")
+ << " " << std::flush,
+ this->Quiet);
// Initialize building structures
this->BuildProcessingQueue.clear();
@@ -922,96 +851,84 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command,
// For every chunk of data
int res;
- while((res = cmsysProcess_WaitForData(cp, &data, &length, 0)))
- {
+ while ((res = cmsysProcess_WaitForData(cp, &data, &length, 0))) {
// Replace '\0' with '\n', since '\0' does not really make sense. This is
// for Visual Studio output
- for(int cc =0; cc < length; ++cc)
- {
- if(data[cc] == 0)
- {
+ for (int cc = 0; cc < length; ++cc) {
+ if (data[cc] == 0) {
data[cc] = '\n';
- }
}
+ }
// Process the chunk of data
- if ( res == cmsysProcess_Pipe_STDERR )
- {
+ if (res == cmsysProcess_Pipe_STDERR) {
this->ProcessBuffer(data, length, tick, tick_len, ofs,
- &this->BuildProcessingErrorQueue);
- }
- else
- {
+ &this->BuildProcessingErrorQueue);
+ } else {
this->ProcessBuffer(data, length, tick, tick_len, ofs,
- &this->BuildProcessingQueue);
- }
+ &this->BuildProcessingQueue);
}
+ }
this->ProcessBuffer(0, 0, tick, tick_len, ofs, &this->BuildProcessingQueue);
this->ProcessBuffer(0, 0, tick, tick_len, ofs,
- &this->BuildProcessingErrorQueue);
+ &this->BuildProcessingErrorQueue);
cmCTestOptionalLog(this->CTest, HANDLER_PROGRESS_OUTPUT, " Size of output: "
- << ((this->BuildOutputLogSize + 512) / 1024) << "K" << std::endl,
- this->Quiet);
+ << ((this->BuildOutputLogSize + 512) / 1024) << "K"
+ << std::endl,
+ this->Quiet);
// Properly handle output of the build command
cmsysProcess_WaitForExit(cp, 0);
int result = cmsysProcess_GetState(cp);
- if(result == cmsysProcess_State_Exited)
- {
- if (retVal)
- {
+ if (result == cmsysProcess_State_Exited) {
+ if (retVal) {
*retVal = cmsysProcess_GetExitValue(cp);
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Command exited with the value: " << *retVal << std::endl, this->Quiet);
+ "Command exited with the value: " << *retVal
+ << std::endl,
+ this->Quiet);
// if a non zero return value
- if (*retVal)
- {
+ if (*retVal) {
// If there was an error running command, report that on the
// dashboard.
cmCTestBuildErrorWarning errorwarning;
- errorwarning.LogLine = 1;
- errorwarning.Text
- = "*** WARNING non-zero return value in ctest from: ";
- errorwarning.Text += argv[0];
- errorwarning.PreContext = "";
+ errorwarning.LogLine = 1;
+ errorwarning.Text =
+ "*** WARNING non-zero return value in ctest from: ";
+ errorwarning.Text += argv[0];
+ errorwarning.PreContext = "";
errorwarning.PostContext = "";
- errorwarning.Error = false;
+ errorwarning.Error = false;
this->ErrorsAndWarnings.push_back(errorwarning);
- this->TotalWarnings ++;
- }
+ this->TotalWarnings++;
}
}
- else if(result == cmsysProcess_State_Exception)
- {
- if (retVal)
- {
+ } else if (result == cmsysProcess_State_Exception) {
+ if (retVal) {
*retVal = cmsysProcess_GetExitException(cp);
- cmCTestOptionalLog(this->CTest, WARNING, "There was an exception: " <<
- *retVal << std::endl, this->Quiet);
- }
+ cmCTestOptionalLog(this->CTest, WARNING,
+ "There was an exception: " << *retVal << std::endl,
+ this->Quiet);
}
- else if(result == cmsysProcess_State_Expired)
- {
- cmCTestOptionalLog(this->CTest, WARNING, "There was a timeout" <<
- std::endl, this->Quiet);
- }
- else if(result == cmsysProcess_State_Error)
- {
+ } else if (result == cmsysProcess_State_Expired) {
+ cmCTestOptionalLog(this->CTest, WARNING,
+ "There was a timeout" << std::endl, this->Quiet);
+ } else if (result == cmsysProcess_State_Error) {
// If there was an error running command, report that on the dashboard.
cmCTestBuildErrorWarning errorwarning;
- errorwarning.LogLine = 1;
- errorwarning.Text = "*** ERROR executing: ";
- errorwarning.Text += cmsysProcess_GetErrorString(cp);
- errorwarning.PreContext = "";
+ errorwarning.LogLine = 1;
+ errorwarning.Text = "*** ERROR executing: ";
+ errorwarning.Text += cmsysProcess_GetErrorString(cp);
+ errorwarning.PreContext = "";
errorwarning.PostContext = "";
- errorwarning.Error = true;
+ errorwarning.Error = true;
this->ErrorsAndWarnings.push_back(errorwarning);
- this->TotalErrors ++;
+ this->TotalErrors++;
cmCTestLog(this->CTest, ERROR_MESSAGE, "There was an error: "
- << cmsysProcess_GetErrorString(cp) << std::endl);
- }
+ << cmsysProcess_GetErrorString(cp) << std::endl);
+ }
cmsysProcess_Delete(cp);
return result;
@@ -1023,46 +940,38 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command,
//######################################################################
void cmCTestBuildHandler::ProcessBuffer(const char* data, int length,
- size_t& tick, size_t tick_len, std::ostream& ofs,
- t_BuildProcessingQueueType* queue)
+ size_t& tick, size_t tick_len,
+ std::ostream& ofs,
+ t_BuildProcessingQueueType* queue)
{
const std::string::size_type tick_line_len = 50;
const char* ptr;
- for ( ptr = data; ptr < data+length; ptr ++ )
- {
+ for (ptr = data; ptr < data + length; ptr++) {
queue->push_back(*ptr);
- }
+ }
this->BuildOutputLogSize += length;
// until there are any lines left in the buffer
- while ( 1 )
- {
+ while (1) {
// Find the end of line
t_BuildProcessingQueueType::iterator it;
- for ( it = queue->begin();
- it != queue->end();
- ++ it )
- {
- if ( *it == '\n' )
- {
+ for (it = queue->begin(); it != queue->end(); ++it) {
+ if (*it == '\n') {
break;
- }
}
+ }
// Once certain number of errors or warnings reached, ignore future errors
// or warnings.
- if ( this->TotalWarnings >= this->MaxWarnings )
- {
+ if (this->TotalWarnings >= this->MaxWarnings) {
this->WarningQuotaReached = true;
- }
- if ( this->TotalErrors >= this->MaxErrors )
- {
+ }
+ if (this->TotalErrors >= this->MaxErrors) {
this->ErrorQuotaReached = true;
- }
+ }
// If the end of line was found
- if ( it != queue->end() )
- {
+ if (it != queue->end()) {
// Create a contiguous array for the line
this->CurrentProcessingLine.clear();
this->CurrentProcessingLine.insert(this->CurrentProcessingLine.end(),
@@ -1074,106 +983,93 @@ void cmCTestBuildHandler::ProcessBuffer(const char* data, int length,
int lineType = this->ProcessSingleLine(line);
// Erase the line from the queue
- queue->erase(queue->begin(), it+1);
+ queue->erase(queue->begin(), it + 1);
// Depending on the line type, produce error or warning, or nothing
cmCTestBuildErrorWarning errorwarning;
bool found = false;
- switch ( lineType )
- {
- case b_WARNING_LINE:
- this->LastTickChar = '*';
- errorwarning.Error = false;
- found = true;
- this->TotalWarnings ++;
- break;
- case b_ERROR_LINE:
- this->LastTickChar = '!';
- errorwarning.Error = true;
- found = true;
- this->TotalErrors ++;
- break;
- }
- if ( found )
- {
+ switch (lineType) {
+ case b_WARNING_LINE:
+ this->LastTickChar = '*';
+ errorwarning.Error = false;
+ found = true;
+ this->TotalWarnings++;
+ break;
+ case b_ERROR_LINE:
+ this->LastTickChar = '!';
+ errorwarning.Error = true;
+ found = true;
+ this->TotalErrors++;
+ break;
+ }
+ if (found) {
// This is an error or warning, so generate report
- errorwarning.LogLine = static_cast<int>(this->OutputLineCounter+1);
- errorwarning.Text = line;
- errorwarning.PreContext = "";
+ errorwarning.LogLine = static_cast<int>(this->OutputLineCounter + 1);
+ errorwarning.Text = line;
+ errorwarning.PreContext = "";
errorwarning.PostContext = "";
// Copy pre-context to report
std::deque<std::string>::iterator pcit;
- for ( pcit = this->PreContext.begin();
- pcit != this->PreContext.end();
- ++pcit )
- {
+ for (pcit = this->PreContext.begin(); pcit != this->PreContext.end();
+ ++pcit) {
errorwarning.PreContext += *pcit + "\n";
- }
+ }
this->PreContext.clear();
// Store report
this->ErrorsAndWarnings.push_back(errorwarning);
- this->LastErrorOrWarning = this->ErrorsAndWarnings.end()-1;
+ this->LastErrorOrWarning = this->ErrorsAndWarnings.end() - 1;
this->PostContextCount = 0;
- }
- else
- {
+ } else {
// This is not an error or warning.
// So, figure out if this is a post-context line
- if ( !this->ErrorsAndWarnings.empty() &&
- this->LastErrorOrWarning != this->ErrorsAndWarnings.end() &&
- this->PostContextCount < this->MaxPostContext )
- {
- this->PostContextCount ++;
+ if (!this->ErrorsAndWarnings.empty() &&
+ this->LastErrorOrWarning != this->ErrorsAndWarnings.end() &&
+ this->PostContextCount < this->MaxPostContext) {
+ this->PostContextCount++;
this->LastErrorOrWarning->PostContext += line;
- if ( this->PostContextCount < this->MaxPostContext )
- {
+ if (this->PostContextCount < this->MaxPostContext) {
this->LastErrorOrWarning->PostContext += "\n";
- }
}
- else
- {
+ } else {
// Otherwise store pre-context for the next error
this->PreContext.push_back(line);
- if ( this->PreContext.size() > this->MaxPreContext )
- {
+ if (this->PreContext.size() > this->MaxPreContext) {
this->PreContext.erase(this->PreContext.begin(),
- this->PreContext.end()-this->MaxPreContext);
- }
+ this->PreContext.end() -
+ this->MaxPreContext);
}
}
- this->OutputLineCounter ++;
}
- else
- {
+ this->OutputLineCounter++;
+ } else {
break;
- }
}
+ }
// Now that the buffer is processed, display missing ticks
int tickDisplayed = false;
- while ( this->BuildOutputLogSize > (tick * tick_len) )
- {
- tick ++;
+ while (this->BuildOutputLogSize > (tick * tick_len)) {
+ tick++;
cmCTestOptionalLog(this->CTest, HANDLER_PROGRESS_OUTPUT,
- this->LastTickChar, this->Quiet);
+ this->LastTickChar, this->Quiet);
tickDisplayed = true;
- if ( tick % tick_line_len == 0 && tick > 0 )
- {
+ if (tick % tick_line_len == 0 && tick > 0) {
cmCTestOptionalLog(this->CTest, HANDLER_PROGRESS_OUTPUT, " Size: "
- << ((this->BuildOutputLogSize + 512) / 1024) << "K" << std::endl
- << " ", this->Quiet);
- }
+ << ((this->BuildOutputLogSize + 512) / 1024) << "K"
+ << std::endl
+ << " ",
+ this->Quiet);
}
- if ( tickDisplayed )
- {
+ }
+ if (tickDisplayed) {
this->LastTickChar = '.';
- }
+ }
// And if this is verbose output, display the content of the chunk
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- cmCTestLogWrite(data, length));
+ cmCTestLogWrite(data, length));
// Always store the chunk to the file
ofs << cmCTestLogWrite(data, length);
@@ -1181,14 +1077,13 @@ void cmCTestBuildHandler::ProcessBuffer(const char* data, int length,
int cmCTestBuildHandler::ProcessSingleLine(const char* data)
{
- if(this->UseCTestLaunch)
- {
+ if (this->UseCTestLaunch) {
// No log scraping when using launchers.
return b_REGULAR_LINE;
- }
+ }
- cmCTestOptionalLog(this->CTest, DEBUG, "Line: [" << data << "]" <<
- std::endl, this->Quiet);
+ cmCTestOptionalLog(this->CTest, DEBUG, "Line: [" << data << "]" << std::endl,
+ this->Quiet);
std::vector<cmsys::RegularExpression>::iterator it;
@@ -1197,86 +1092,76 @@ int cmCTestBuildHandler::ProcessSingleLine(const char* data)
// Check for regular expressions
- if ( !this->ErrorQuotaReached )
- {
+ if (!this->ErrorQuotaReached) {
// Errors
int wrxCnt = 0;
- for ( it = this->ErrorMatchRegex.begin();
- it != this->ErrorMatchRegex.end();
- ++ it )
- {
- if ( it->find(data) )
- {
+ for (it = this->ErrorMatchRegex.begin(); it != this->ErrorMatchRegex.end();
+ ++it) {
+ if (it->find(data)) {
errorLine = 1;
- cmCTestOptionalLog(this->CTest, DEBUG, " Error Line: " << data
- << " (matches: " << this->CustomErrorMatches[wrxCnt] << ")"
- << std::endl, this->Quiet);
+ cmCTestOptionalLog(this->CTest, DEBUG,
+ " Error Line: " << data << " (matches: "
+ << this->CustomErrorMatches[wrxCnt]
+ << ")" << std::endl,
+ this->Quiet);
break;
- }
- wrxCnt ++;
}
+ wrxCnt++;
+ }
// Error exceptions
wrxCnt = 0;
- for ( it = this->ErrorExceptionRegex.begin();
- it != this->ErrorExceptionRegex.end();
- ++ it )
- {
- if ( it->find(data) )
- {
+ for (it = this->ErrorExceptionRegex.begin();
+ it != this->ErrorExceptionRegex.end(); ++it) {
+ if (it->find(data)) {
errorLine = 0;
- cmCTestOptionalLog(this->CTest, DEBUG, " Not an error Line: " << data
- << " (matches: " << this->CustomErrorExceptions[wrxCnt] << ")"
- << std::endl, this->Quiet);
+ cmCTestOptionalLog(this->CTest, DEBUG, " Not an error Line: "
+ << data << " (matches: "
+ << this->CustomErrorExceptions[wrxCnt] << ")"
+ << std::endl,
+ this->Quiet);
break;
- }
- wrxCnt ++;
}
+ wrxCnt++;
}
- if ( !this->WarningQuotaReached )
- {
+ }
+ if (!this->WarningQuotaReached) {
// Warnings
int wrxCnt = 0;
- for ( it = this->WarningMatchRegex.begin();
- it != this->WarningMatchRegex.end();
- ++ it )
- {
- if ( it->find(data) )
- {
+ for (it = this->WarningMatchRegex.begin();
+ it != this->WarningMatchRegex.end(); ++it) {
+ if (it->find(data)) {
warningLine = 1;
- cmCTestOptionalLog(this->CTest, DEBUG,
- " Warning Line: " << data
- << " (matches: " << this->CustomWarningMatches[wrxCnt] << ")"
- << std::endl, this->Quiet);
+ cmCTestOptionalLog(this->CTest, DEBUG, " Warning Line: "
+ << data << " (matches: "
+ << this->CustomWarningMatches[wrxCnt] << ")"
+ << std::endl,
+ this->Quiet);
break;
- }
- wrxCnt ++;
}
+ wrxCnt++;
+ }
wrxCnt = 0;
// Warning exceptions
- for ( it = this->WarningExceptionRegex.begin();
- it != this->WarningExceptionRegex.end();
- ++ it )
- {
- if ( it->find(data) )
- {
+ for (it = this->WarningExceptionRegex.begin();
+ it != this->WarningExceptionRegex.end(); ++it) {
+ if (it->find(data)) {
warningLine = 0;
- cmCTestOptionalLog(this->CTest, DEBUG, " Not a warning Line: " << data
- << " (matches: " << this->CustomWarningExceptions[wrxCnt] << ")"
- << std::endl, this->Quiet);
+ cmCTestOptionalLog(this->CTest, DEBUG, " Not a warning Line: "
+ << data << " (matches: "
+ << this->CustomWarningExceptions[wrxCnt] << ")"
+ << std::endl,
+ this->Quiet);
break;
- }
- wrxCnt ++;
}
+ wrxCnt++;
}
- if ( errorLine )
- {
+ }
+ if (errorLine) {
return b_ERROR_LINE;
- }
- if ( warningLine )
- {
+ }
+ if (warningLine) {
return b_WARNING_LINE;
- }
+ }
return b_REGULAR_LINE;
}
-
diff --git a/Source/CTest/cmCTestBuildHandler.h b/Source/CTest/cmCTestBuildHandler.h
index 9231170..48a37b7 100644
--- a/Source/CTest/cmCTestBuildHandler.h
+++ b/Source/CTest/cmCTestBuildHandler.h
@@ -40,48 +40,48 @@ public:
cmCTestBuildHandler();
- void PopulateCustomVectors(cmMakefile *mf);
+ void PopulateCustomVectors(cmMakefile* mf);
/**
* Initialize handler
*/
virtual void Initialize();
- int GetTotalErrors() { return this->TotalErrors;}
- int GetTotalWarnings() { return this->TotalWarnings;}
+ int GetTotalErrors() { return this->TotalErrors; }
+ int GetTotalWarnings() { return this->TotalWarnings; }
private:
std::string GetMakeCommand();
//! Run command specialized for make and configure. Returns process status
// and retVal is return value or exception.
- int RunMakeCommand(const char* command,
- int* retVal, const char* dir, int timeout,
- std::ostream& ofs);
+ int RunMakeCommand(const char* command, int* retVal, const char* dir,
+ int timeout, std::ostream& ofs);
- enum {
+ enum
+ {
b_REGULAR_LINE,
b_WARNING_LINE,
b_ERROR_LINE
};
class cmCTestCompileErrorWarningRex
- {
+ {
public:
cmCTestCompileErrorWarningRex() {}
int FileIndex;
int LineIndex;
cmsys::RegularExpression RegularExpression;
- };
+ };
struct cmCTestBuildErrorWarning
{
- bool Error;
- int LogLine;
+ bool Error;
+ int LogLine;
std::string Text;
std::string SourceFile;
std::string SourceFileTail;
- int LineNumber;
+ int LineNumber;
std::string PreContext;
std::string PostContext;
};
@@ -94,10 +94,10 @@ private:
bool IsLaunchedErrorFile(const char* fname);
bool IsLaunchedWarningFile(const char* fname);
- std::string StartBuild;
- std::string EndBuild;
- double StartBuildTime;
- double EndBuildTime;
+ std::string StartBuild;
+ std::string EndBuild;
+ double StartBuildTime;
+ double EndBuildTime;
std::vector<std::string> CustomErrorMatches;
std::vector<std::string> CustomErrorExceptions;
@@ -115,34 +115,35 @@ private:
typedef std::deque<char> t_BuildProcessingQueueType;
void ProcessBuffer(const char* data, int length, size_t& tick,
- size_t tick_len, std::ostream& ofs, t_BuildProcessingQueueType* queue);
+ size_t tick_len, std::ostream& ofs,
+ t_BuildProcessingQueueType* queue);
int ProcessSingleLine(const char* data);
- t_BuildProcessingQueueType BuildProcessingQueue;
- t_BuildProcessingQueueType BuildProcessingErrorQueue;
- size_t BuildOutputLogSize;
- std::vector<char> CurrentProcessingLine;
+ t_BuildProcessingQueueType BuildProcessingQueue;
+ t_BuildProcessingQueueType BuildProcessingErrorQueue;
+ size_t BuildOutputLogSize;
+ std::vector<char> CurrentProcessingLine;
- std::string SimplifySourceDir;
- std::string SimplifyBuildDir;
- size_t OutputLineCounter;
+ std::string SimplifySourceDir;
+ std::string SimplifyBuildDir;
+ size_t OutputLineCounter;
typedef std::vector<cmCTestBuildErrorWarning> t_ErrorsAndWarningsVector;
- t_ErrorsAndWarningsVector ErrorsAndWarnings;
- t_ErrorsAndWarningsVector::iterator LastErrorOrWarning;
- size_t PostContextCount;
- size_t MaxPreContext;
- size_t MaxPostContext;
- std::deque<std::string> PreContext;
-
- int TotalErrors;
- int TotalWarnings;
- char LastTickChar;
-
- bool ErrorQuotaReached;
- bool WarningQuotaReached;
-
- int MaxErrors;
- int MaxWarnings;
+ t_ErrorsAndWarningsVector ErrorsAndWarnings;
+ t_ErrorsAndWarningsVector::iterator LastErrorOrWarning;
+ size_t PostContextCount;
+ size_t MaxPreContext;
+ size_t MaxPostContext;
+ std::deque<std::string> PreContext;
+
+ int TotalErrors;
+ int TotalWarnings;
+ char LastTickChar;
+
+ bool ErrorQuotaReached;
+ bool WarningQuotaReached;
+
+ int MaxErrors;
+ int MaxWarnings;
bool UseCTestLaunch;
std::string CTestLaunchDir;
diff --git a/Source/CTest/cmCTestCVS.cxx b/Source/CTest/cmCTestCVS.cxx
index 7ab87c2..5ddafbb 100644
--- a/Source/CTest/cmCTestCVS.cxx
+++ b/Source/CTest/cmCTestCVS.cxx
@@ -18,7 +18,8 @@
#include <cmsys/FStream.hxx>
#include <cmsys/RegularExpression.hxx>
-cmCTestCVS::cmCTestCVS(cmCTest* ct, std::ostream& log): cmCTestVC(ct, log)
+cmCTestCVS::cmCTestCVS(cmCTest* ct, std::ostream& log)
+ : cmCTestVC(ct, log)
{
}
@@ -26,11 +27,12 @@ cmCTestCVS::~cmCTestCVS()
{
}
-class cmCTestCVS::UpdateParser: public cmCTestVC::LineParser
+class cmCTestCVS::UpdateParser : public cmCTestVC::LineParser
{
public:
- UpdateParser(cmCTestCVS* cvs, const char* prefix): CVS(cvs)
- {
+ UpdateParser(cmCTestCVS* cvs, const char* prefix)
+ : CVS(cvs)
+ {
this->SetLog(&cvs->Log, prefix);
// See "man cvs", section "update output".
this->RegexFileUpdated.compile("^([UP]) *(.*)");
@@ -41,7 +43,8 @@ public:
this->RegexFileRemoved2.compile(
"cvs[^ ]* update: "
"warning: `?([^']*)'? is not \\(any longer\\) pertinent");
- }
+ }
+
private:
cmCTestCVS* CVS;
cmsys::RegularExpression RegexFileUpdated;
@@ -51,68 +54,55 @@ private:
cmsys::RegularExpression RegexFileRemoved2;
virtual bool ProcessLine()
- {
- if(this->RegexFileUpdated.find(this->Line))
- {
+ {
+ if (this->RegexFileUpdated.find(this->Line)) {
this->DoFile(PathUpdated, this->RegexFileUpdated.match(2));
- }
- else if(this->RegexFileModified.find(this->Line))
- {
+ } else if (this->RegexFileModified.find(this->Line)) {
this->DoFile(PathModified, this->RegexFileModified.match(2));
- }
- else if(this->RegexFileConflicting.find(this->Line))
- {
+ } else if (this->RegexFileConflicting.find(this->Line)) {
this->DoFile(PathConflicting, this->RegexFileConflicting.match(2));
- }
- else if(this->RegexFileRemoved1.find(this->Line))
- {
+ } else if (this->RegexFileRemoved1.find(this->Line)) {
this->DoFile(PathUpdated, this->RegexFileRemoved1.match(1));
- }
- else if(this->RegexFileRemoved2.find(this->Line))
- {
+ } else if (this->RegexFileRemoved2.find(this->Line)) {
this->DoFile(PathUpdated, this->RegexFileRemoved2.match(1));
- }
- return true;
}
+ return true;
+ }
void DoFile(PathStatus status, std::string const& file)
- {
+ {
std::string dir = cmSystemTools::GetFilenamePath(file);
std::string name = cmSystemTools::GetFilenameName(file);
this->CVS->Dirs[dir][name] = status;
- }
+ }
};
bool cmCTestCVS::UpdateImpl()
{
// Get user-specified update options.
std::string opts = this->CTest->GetCTestConfiguration("UpdateOptions");
- if(opts.empty())
- {
+ if (opts.empty()) {
opts = this->CTest->GetCTestConfiguration("CVSUpdateOptions");
- if(opts.empty())
- {
+ if (opts.empty()) {
opts = "-dP";
- }
}
+ }
std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
// Specify the start time for nightly testing.
- if(this->CTest->GetTestModel() == cmCTest::NIGHTLY)
- {
+ if (this->CTest->GetTestModel() == cmCTest::NIGHTLY) {
args.push_back("-D" + this->GetNightlyTime() + " UTC");
- }
+ }
// Run "cvs update" to update the work tree.
std::vector<char const*> cvs_update;
cvs_update.push_back(this->CommandLineTool.c_str());
cvs_update.push_back("-z3");
cvs_update.push_back("update");
- for(std::vector<std::string>::const_iterator ai = args.begin();
- ai != args.end(); ++ai)
- {
+ for (std::vector<std::string>::const_iterator ai = args.begin();
+ ai != args.end(); ++ai) {
cvs_update.push_back(ai->c_str());
- }
+ }
cvs_update.push_back(0);
UpdateParser out(this, "up-out> ");
@@ -120,83 +110,76 @@ bool cmCTestCVS::UpdateImpl()
return this->RunUpdateCommand(&cvs_update[0], &out, &err);
}
-class cmCTestCVS::LogParser: public cmCTestVC::LineParser
+class cmCTestCVS::LogParser : public cmCTestVC::LineParser
{
public:
typedef cmCTestCVS::Revision Revision;
- LogParser(cmCTestCVS* cvs, const char* prefix, std::vector<Revision>& revs):
- CVS(cvs), Revisions(revs), Section(SectionHeader)
- {
+ LogParser(cmCTestCVS* cvs, const char* prefix, std::vector<Revision>& revs)
+ : CVS(cvs)
+ , Revisions(revs)
+ , Section(SectionHeader)
+ {
this->SetLog(&cvs->Log, prefix),
- this->RegexRevision.compile("^revision +([^ ]*) *$");
+ this->RegexRevision.compile("^revision +([^ ]*) *$");
this->RegexBranches.compile("^branches: .*$");
this->RegexPerson.compile("^date: +([^;]+); +author: +([^;]+);");
- }
+ }
+
private:
cmCTestCVS* CVS;
std::vector<Revision>& Revisions;
cmsys::RegularExpression RegexRevision;
cmsys::RegularExpression RegexBranches;
cmsys::RegularExpression RegexPerson;
- enum SectionType { SectionHeader, SectionRevisions, SectionEnd };
+ enum SectionType
+ {
+ SectionHeader,
+ SectionRevisions,
+ SectionEnd
+ };
SectionType Section;
Revision Rev;
virtual bool ProcessLine()
- {
- if(this->Line == ("======================================="
- "======================================"))
- {
+ {
+ if (this->Line == ("======================================="
+ "======================================")) {
// This line ends the revision list.
- if(this->Section == SectionRevisions)
- {
+ if (this->Section == SectionRevisions) {
this->FinishRevision();
- }
- this->Section = SectionEnd;
}
- else if(this->Line == "----------------------------")
- {
+ this->Section = SectionEnd;
+ } else if (this->Line == "----------------------------") {
// This line divides revisions from the header and each other.
- if(this->Section == SectionHeader)
- {
+ if (this->Section == SectionHeader) {
this->Section = SectionRevisions;
- }
- else if(this->Section == SectionRevisions)
- {
+ } else if (this->Section == SectionRevisions) {
this->FinishRevision();
- }
}
- else if(this->Section == SectionRevisions)
- {
- if(!this->Rev.Log.empty())
- {
+ } else if (this->Section == SectionRevisions) {
+ if (!this->Rev.Log.empty()) {
// Continue the existing log.
this->Rev.Log += this->Line;
this->Rev.Log += "\n";
- }
- else if(this->Rev.Rev.empty() && this->RegexRevision.find(this->Line))
- {
+ } else if (this->Rev.Rev.empty() &&
+ this->RegexRevision.find(this->Line)) {
this->Rev.Rev = this->RegexRevision.match(1);
- }
- else if(this->Rev.Date.empty() && this->RegexPerson.find(this->Line))
- {
+ } else if (this->Rev.Date.empty() &&
+ this->RegexPerson.find(this->Line)) {
this->Rev.Date = this->RegexPerson.match(1);
this->Rev.Author = this->RegexPerson.match(2);
- }
- else if(!this->RegexBranches.find(this->Line))
- {
+ } else if (!this->RegexBranches.find(this->Line)) {
// Start the log.
this->Rev.Log += this->Line;
this->Rev.Log += "\n";
- }
}
- return this->Section != SectionEnd;
}
+ return this->Section != SectionEnd;
+ }
void FinishRevision()
- {
- if(!this->Rev.Rev.empty())
- {
+ {
+ if (!this->Rev.Rev.empty()) {
// Record this revision.
/* clang-format off */
this->CVS->Log << "Found revision " << this->Rev.Rev << "\n"
@@ -206,65 +189,57 @@ private:
this->Revisions.push_back(this->Rev);
// We only need two revisions.
- if(this->Revisions.size() >= 2)
- {
+ if (this->Revisions.size() >= 2) {
this->Section = SectionEnd;
- }
}
- this->Rev = Revision();
}
+ this->Rev = Revision();
+ }
};
std::string cmCTestCVS::ComputeBranchFlag(std::string const& dir)
{
// Compute the tag file location for this directory.
std::string tagFile = this->SourceDirectory;
- if(!dir.empty())
- {
+ if (!dir.empty()) {
tagFile += "/";
tagFile += dir;
- }
+ }
tagFile += "/CVS/Tag";
// Lookup the branch in the tag file, if any.
std::string tagLine;
cmsys::ifstream tagStream(tagFile.c_str());
- if(tagStream && cmSystemTools::GetLineFromStream(tagStream, tagLine) &&
- tagLine.size() > 1 && tagLine[0] == 'T')
- {
+ if (tagStream && cmSystemTools::GetLineFromStream(tagStream, tagLine) &&
+ tagLine.size() > 1 && tagLine[0] == 'T') {
// Use the branch specified in the tag file.
std::string flag = "-r";
flag += tagLine.substr(1);
return flag;
- }
- else
- {
+ } else {
// Use the default branch.
return "-b";
- }
+ }
}
-void cmCTestCVS::LoadRevisions(std::string const& file,
- const char* branchFlag,
+void cmCTestCVS::LoadRevisions(std::string const& file, const char* branchFlag,
std::vector<Revision>& revisions)
{
cmCTestLog(this->CTest, HANDLER_OUTPUT, "." << std::flush);
// Run "cvs log" to get revisions of this file on this branch.
const char* cvs = this->CommandLineTool.c_str();
- const char* cvs_log[] =
- {cvs, "log", "-N", branchFlag, file.c_str(), 0};
+ const char* cvs_log[] = { cvs, "log", "-N", branchFlag, file.c_str(), 0 };
LogParser out(this, "log-out> ", revisions);
OutputLogger err(this->Log, "log-err> ");
this->RunChild(cvs_log, &out, &err);
}
-void cmCTestCVS::WriteXMLDirectory(cmXMLWriter& xml,
- std::string const& path,
+void cmCTestCVS::WriteXMLDirectory(cmXMLWriter& xml, std::string const& path,
Directory const& dir)
{
- const char* slash = path.empty()? "":"/";
+ const char* slash = path.empty() ? "" : "/";
xml.StartElement("Directory");
xml.Element("Name", path);
@@ -273,25 +248,23 @@ void cmCTestCVS::WriteXMLDirectory(cmXMLWriter& xml,
// Load revisions and write an entry for each file in this directory.
std::vector<Revision> revisions;
- for(Directory::const_iterator fi = dir.begin(); fi != dir.end(); ++fi)
- {
+ for (Directory::const_iterator fi = dir.begin(); fi != dir.end(); ++fi) {
std::string full = path + slash + fi->first;
// Load two real or unknown revisions.
revisions.clear();
- if(fi->second != PathUpdated)
- {
+ if (fi->second != PathUpdated) {
// For local modifications the current rev is unknown and the
// prior rev is the latest from cvs.
revisions.push_back(this->Unknown);
- }
+ }
this->LoadRevisions(full, branchFlag.c_str(), revisions);
revisions.resize(2, this->Unknown);
// Write the entry for this file with these revisions.
File f(fi->second, &revisions[0], &revisions[1]);
this->WriteXMLEntry(xml, path, fi->first, full, f);
- }
+ }
xml.EndElement(); // Directory
}
@@ -299,13 +272,14 @@ bool cmCTestCVS::WriteXMLUpdates(cmXMLWriter& xml)
{
cmCTestLog(this->CTest, HANDLER_OUTPUT,
" Gathering version information (one . per updated file):\n"
- " " << std::flush);
+ " "
+ << std::flush);
- for(std::map<std::string, Directory>::const_iterator
- di = this->Dirs.begin(); di != this->Dirs.end(); ++di)
- {
+ for (std::map<std::string, Directory>::const_iterator di =
+ this->Dirs.begin();
+ di != this->Dirs.end(); ++di) {
this->WriteXMLDirectory(xml, di->first, di->second);
- }
+ }
cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl);
diff --git a/Source/CTest/cmCTestCVS.h b/Source/CTest/cmCTestCVS.h
index f2c0a73..62fe01b 100644
--- a/Source/CTest/cmCTestCVS.h
+++ b/Source/CTest/cmCTestCVS.h
@@ -18,7 +18,7 @@
* \brief Interaction with cvs command-line tool
*
*/
-class cmCTestCVS: public cmCTestVC
+class cmCTestCVS : public cmCTestVC
{
public:
/** Construct with a CTest instance and update log stream. */
@@ -32,7 +32,9 @@ private:
virtual bool WriteXMLUpdates(cmXMLWriter& xml);
// Update status for files in each directory.
- class Directory: public std::map<std::string, PathStatus> {};
+ class Directory : public std::map<std::string, PathStatus>
+ {
+ };
std::map<std::string, Directory> Dirs;
std::string ComputeBranchFlag(std::string const& dir);
diff --git a/Source/CTest/cmCTestCommand.h b/Source/CTest/cmCTestCommand.h
index e2ebba8..22a2c8e 100644
--- a/Source/CTest/cmCTestCommand.h
+++ b/Source/CTest/cmCTestCommand.h
@@ -27,14 +27,16 @@ class cmCTestScriptHandler;
class cmCTestCommand : public cmCommand
{
public:
+ cmCTestCommand()
+ {
+ this->CTest = 0;
+ this->CTestScriptHandler = 0;
+ }
- cmCTestCommand() {this->CTest = 0; this->CTestScriptHandler = 0;}
-
- cmCTest *CTest;
- cmCTestScriptHandler *CTestScriptHandler;
+ cmCTest* CTest;
+ cmCTestScriptHandler* CTestScriptHandler;
cmTypeMacro(cmCTestCommand, cmCommand);
};
-
#endif
diff --git a/Source/CTest/cmCTestConfigureCommand.cxx b/Source/CTest/cmCTestConfigureCommand.cxx
index 8f15c6d..a90f27a 100644
--- a/Source/CTest/cmCTestConfigureCommand.cxx
+++ b/Source/CTest/cmCTestConfigureCommand.cxx
@@ -26,64 +26,56 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
{
std::vector<std::string> options;
- if (this->Values[ctc_OPTIONS])
- {
+ if (this->Values[ctc_OPTIONS]) {
cmSystemTools::ExpandListArgument(this->Values[ctc_OPTIONS], options);
- }
+ }
- if ( this->CTest->GetCTestConfiguration("BuildDirectory").empty() )
- {
- this->SetError("Build directory not specified. Either use BUILD "
+ if (this->CTest->GetCTestConfiguration("BuildDirectory").empty()) {
+ this->SetError(
+ "Build directory not specified. Either use BUILD "
"argument to CTEST_CONFIGURE command or set CTEST_BINARY_DIRECTORY "
"variable");
return 0;
- }
+ }
- const char* ctestConfigureCommand
- = this->Makefile->GetDefinition("CTEST_CONFIGURE_COMMAND");
+ const char* ctestConfigureCommand =
+ this->Makefile->GetDefinition("CTEST_CONFIGURE_COMMAND");
- if ( ctestConfigureCommand && *ctestConfigureCommand )
- {
+ if (ctestConfigureCommand && *ctestConfigureCommand) {
this->CTest->SetCTestConfiguration("ConfigureCommand",
- ctestConfigureCommand, this->Quiet);
- }
- else
- {
- const char* cmakeGeneratorName
- = this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR");
- if ( cmakeGeneratorName && *cmakeGeneratorName )
- {
- const std::string& source_dir
- = this->CTest->GetCTestConfiguration("SourceDirectory");
- if ( source_dir.empty() )
- {
- this->SetError("Source directory not specified. Either use SOURCE "
+ ctestConfigureCommand, this->Quiet);
+ } else {
+ const char* cmakeGeneratorName =
+ this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR");
+ if (cmakeGeneratorName && *cmakeGeneratorName) {
+ const std::string& source_dir =
+ this->CTest->GetCTestConfiguration("SourceDirectory");
+ if (source_dir.empty()) {
+ this->SetError(
+ "Source directory not specified. Either use SOURCE "
"argument to CTEST_CONFIGURE command or set CTEST_SOURCE_DIRECTORY "
"variable");
return 0;
- }
+ }
const std::string cmakelists_file = source_dir + "/CMakeLists.txt";
- if ( !cmSystemTools::FileExists(cmakelists_file.c_str()) )
- {
+ if (!cmSystemTools::FileExists(cmakelists_file.c_str())) {
std::ostringstream e;
- e << "CMakeLists.txt file does not exist ["
- << cmakelists_file << "]";
+ e << "CMakeLists.txt file does not exist [" << cmakelists_file << "]";
this->SetError(e.str());
return 0;
- }
+ }
bool multiConfig = false;
bool cmakeBuildTypeInOptions = false;
- cmGlobalGenerator *gg =
+ cmGlobalGenerator* gg =
this->Makefile->GetCMakeInstance()->CreateGlobalGenerator(
cmakeGeneratorName);
- if(gg)
- {
+ if (gg) {
multiConfig = gg->IsMultiConfig();
delete gg;
- }
+ }
std::string cmakeConfigureCommand = "\"";
cmakeConfigureCommand += cmSystemTools::GetCMakeCommand();
@@ -91,8 +83,7 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
std::vector<std::string>::const_iterator it;
std::string option;
- for (it= options.begin(); it!=options.end(); ++it)
- {
+ for (it = options.begin(); it != options.end(); ++it) {
option = *it;
cmakeConfigureCommand += " \"";
@@ -100,19 +91,17 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
cmakeConfigureCommand += "\"";
if ((0 != strstr(option.c_str(), "CMAKE_BUILD_TYPE=")) ||
- (0 != strstr(option.c_str(), "CMAKE_BUILD_TYPE:STRING=")))
- {
+ (0 != strstr(option.c_str(), "CMAKE_BUILD_TYPE:STRING="))) {
cmakeBuildTypeInOptions = true;
- }
}
+ }
if (!multiConfig && !cmakeBuildTypeInOptions &&
- !this->CTest->GetConfigType().empty())
- {
+ !this->CTest->GetConfigType().empty()) {
cmakeConfigureCommand += " \"-DCMAKE_BUILD_TYPE:STRING=";
cmakeConfigureCommand += this->CTest->GetConfigType();
cmakeConfigureCommand += "\"";
- }
+ }
cmakeConfigureCommand += " \"-G";
cmakeConfigureCommand += cmakeGeneratorName;
@@ -120,46 +109,42 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
const char* cmakeGeneratorPlatform =
this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR_PLATFORM");
- if(cmakeGeneratorPlatform && *cmakeGeneratorPlatform)
- {
+ if (cmakeGeneratorPlatform && *cmakeGeneratorPlatform) {
cmakeConfigureCommand += " \"-A";
cmakeConfigureCommand += cmakeGeneratorPlatform;
cmakeConfigureCommand += "\"";
- }
+ }
const char* cmakeGeneratorToolset =
this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR_TOOLSET");
- if(cmakeGeneratorToolset && *cmakeGeneratorToolset)
- {
+ if (cmakeGeneratorToolset && *cmakeGeneratorToolset) {
cmakeConfigureCommand += " \"-T";
cmakeConfigureCommand += cmakeGeneratorToolset;
cmakeConfigureCommand += "\"";
- }
+ }
cmakeConfigureCommand += " \"";
cmakeConfigureCommand += source_dir;
cmakeConfigureCommand += "\"";
- this->CTest->SetCTestConfiguration("ConfigureCommand",
- cmakeConfigureCommand.c_str(), this->Quiet);
- }
- else
- {
- this->SetError("Configure command is not specified. If this is a "
+ this->CTest->SetCTestConfiguration(
+ "ConfigureCommand", cmakeConfigureCommand.c_str(), this->Quiet);
+ } else {
+ this->SetError(
+ "Configure command is not specified. If this is a "
"\"built with CMake\" project, set CTEST_CMAKE_GENERATOR. If not, "
"set CTEST_CONFIGURE_COMMAND.");
return 0;
- }
}
+ }
- cmCTestGenericHandler* handler
- = this->CTest->GetInitializedHandler("configure");
- if ( !handler )
- {
+ cmCTestGenericHandler* handler =
+ this->CTest->GetInitializedHandler("configure");
+ if (!handler) {
this->SetError(
"internal CTest error. Cannot instantiate configure handler");
return 0;
- }
+ }
handler->SetQuiet(this->Quiet);
return handler;
}
diff --git a/Source/CTest/cmCTestConfigureCommand.h b/Source/CTest/cmCTestConfigureCommand.h
index 7941d4e..9ff3d4a 100644
--- a/Source/CTest/cmCTestConfigureCommand.h
+++ b/Source/CTest/cmCTestConfigureCommand.h
@@ -28,29 +28,29 @@ public:
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
- {
+ {
cmCTestConfigureCommand* ni = new cmCTestConfigureCommand;
ni->CTest = this->CTest;
ni->CTestScriptHandler = this->CTestScriptHandler;
return ni;
- }
+ }
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const { return "ctest_configure";}
+ virtual std::string GetName() const { return "ctest_configure"; }
cmTypeMacro(cmCTestConfigureCommand, cmCTestHandlerCommand);
protected:
cmCTestGenericHandler* InitializeHandler();
- enum {
+ enum
+ {
ctc_FIRST = ct_LAST,
ctc_OPTIONS,
ctc_LAST
};
};
-
#endif
diff --git a/Source/CTest/cmCTestConfigureHandler.cxx b/Source/CTest/cmCTestConfigureHandler.cxx
index ea4cf72..b99455f 100644
--- a/Source/CTest/cmCTestConfigureHandler.cxx
+++ b/Source/CTest/cmCTestConfigureHandler.cxx
@@ -18,7 +18,6 @@
#include "cmake.h"
#include <cmsys/Process.h>
-
cmCTestConfigureHandler::cmCTestConfigureHandler()
{
}
@@ -28,64 +27,58 @@ void cmCTestConfigureHandler::Initialize()
this->Superclass::Initialize();
}
-//clearly it would be nice if this were broken up into a few smaller
-//functions and commented...
+// clearly it would be nice if this were broken up into a few smaller
+// functions and commented...
int cmCTestConfigureHandler::ProcessHandler()
{
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- "Configure project" << std::endl, this->Quiet);
- std::string cCommand
- = this->CTest->GetCTestConfiguration("ConfigureCommand");
- if (cCommand.empty())
- {
+ "Configure project" << std::endl, this->Quiet);
+ std::string cCommand =
+ this->CTest->GetCTestConfiguration("ConfigureCommand");
+ if (cCommand.empty()) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Cannot find ConfigureCommand key in the DartConfiguration.tcl"
- << std::endl);
+ "Cannot find ConfigureCommand key in the DartConfiguration.tcl"
+ << std::endl);
return -1;
- }
+ }
- std::string buildDirectory
- = this->CTest->GetCTestConfiguration("BuildDirectory");
- if (buildDirectory.empty())
- {
+ std::string buildDirectory =
+ this->CTest->GetCTestConfiguration("BuildDirectory");
+ if (buildDirectory.empty()) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Cannot find BuildDirectory key in the DartConfiguration.tcl"
- << std::endl);
+ "Cannot find BuildDirectory key in the DartConfiguration.tcl"
+ << std::endl);
return -1;
- }
+ }
double elapsed_time_start = cmSystemTools::GetTime();
std::string output;
int retVal = 0;
int res = 0;
- if ( !this->CTest->GetShowOnly() )
- {
+ if (!this->CTest->GetShowOnly()) {
cmGeneratedFileStream os;
- if(!this->StartResultingXML(cmCTest::PartConfigure, "Configure", os))
- {
+ if (!this->StartResultingXML(cmCTest::PartConfigure, "Configure", os)) {
cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open configure file"
- << std::endl);
+ << std::endl);
return 1;
- }
+ }
std::string start_time = this->CTest->CurrentTime();
- unsigned int start_time_time = static_cast<unsigned int>(
- cmSystemTools::GetTime());
+ unsigned int start_time_time =
+ static_cast<unsigned int>(cmSystemTools::GetTime());
cmGeneratedFileStream ofs;
this->StartLogFile("Configure", ofs);
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Configure with command: " << cCommand << std::endl, this->Quiet);
- res = this->CTest->RunMakeCommand(cCommand.c_str(), output,
- &retVal, buildDirectory.c_str(),
- 0, ofs);
+ "Configure with command: " << cCommand << std::endl,
+ this->Quiet);
+ res = this->CTest->RunMakeCommand(cCommand.c_str(), output, &retVal,
+ buildDirectory.c_str(), 0, ofs);
- if ( ofs )
- {
+ if (ofs) {
ofs.close();
- }
+ }
- if ( os )
- {
+ if (os) {
cmXMLWriter xml(os);
this->CTest->StartXML(xml, this->AppendXML);
xml.StartElement("Configure");
@@ -97,23 +90,23 @@ int cmCTestConfigureHandler::ProcessHandler()
xml.Element("ConfigureStatus", retVal);
xml.Element("EndDateTime", this->CTest->CurrentTime());
xml.Element("EndConfigureTime",
- static_cast<unsigned int>(cmSystemTools::GetTime()));
- xml.Element("ElapsedMinutes", static_cast<int>(
- (cmSystemTools::GetTime() - elapsed_time_start)/6)/10.0);
+ static_cast<unsigned int>(cmSystemTools::GetTime()));
+ xml.Element(
+ "ElapsedMinutes",
+ static_cast<int>((cmSystemTools::GetTime() - elapsed_time_start) / 6) /
+ 10.0);
xml.EndElement(); // Configure
this->CTest->EndXML(xml);
- }
}
- else
- {
+ } else {
cmCTestOptionalLog(this->CTest, DEBUG,
- "Configure with command: " << cCommand << std::endl, this->Quiet);
- }
- if (! res || retVal )
- {
+ "Configure with command: " << cCommand << std::endl,
+ this->Quiet);
+ }
+ if (!res || retVal) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Error(s) when configuring the project" << std::endl);
+ "Error(s) when configuring the project" << std::endl);
return -1;
- }
+ }
return 0;
}
diff --git a/Source/CTest/cmCTestCoverageCommand.cxx b/Source/CTest/cmCTestCoverageCommand.cxx
index bf6a321..223d010 100644
--- a/Source/CTest/cmCTestCoverageCommand.cxx
+++ b/Source/CTest/cmCTestCoverageCommand.cxx
@@ -21,23 +21,22 @@ cmCTestCoverageCommand::cmCTestCoverageCommand()
cmCTestGenericHandler* cmCTestCoverageCommand::InitializeHandler()
{
- this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
- "CoverageCommand", "CTEST_COVERAGE_COMMAND", this->Quiet);
- this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
- "CoverageExtraFlags", "CTEST_COVERAGE_EXTRA_FLAGS", this->Quiet);
+ this->CTest->SetCTestConfigurationFromCMakeVariable(
+ this->Makefile, "CoverageCommand", "CTEST_COVERAGE_COMMAND", this->Quiet);
+ this->CTest->SetCTestConfigurationFromCMakeVariable(
+ this->Makefile, "CoverageExtraFlags", "CTEST_COVERAGE_EXTRA_FLAGS",
+ this->Quiet);
cmCTestCoverageHandler* handler = static_cast<cmCTestCoverageHandler*>(
this->CTest->GetInitializedHandler("coverage"));
- if ( !handler )
- {
+ if (!handler) {
this->SetError("internal CTest error. Cannot instantiate test handler");
return 0;
- }
+ }
// If a LABELS option was given, select only files with the labels.
- if(this->LabelsMentioned)
- {
+ if (this->LabelsMentioned) {
handler->SetLabelFilter(this->Labels);
- }
+ }
handler->SetQuiet(this->Quiet);
return handler;
@@ -46,12 +45,11 @@ cmCTestGenericHandler* cmCTestCoverageCommand::InitializeHandler()
bool cmCTestCoverageCommand::CheckArgumentKeyword(std::string const& arg)
{
// Look for arguments specific to this command.
- if(arg == "LABELS")
- {
+ if (arg == "LABELS") {
this->ArgumentDoing = ArgumentDoingLabels;
this->LabelsMentioned = true;
return true;
- }
+ }
// Look for other arguments.
return this->Superclass::CheckArgumentKeyword(arg);
@@ -60,11 +58,10 @@ bool cmCTestCoverageCommand::CheckArgumentKeyword(std::string const& arg)
bool cmCTestCoverageCommand::CheckArgumentValue(std::string const& arg)
{
// Handle states specific to this command.
- if(this->ArgumentDoing == ArgumentDoingLabels)
- {
+ if (this->ArgumentDoing == ArgumentDoingLabels) {
this->Labels.insert(arg);
return true;
- }
+ }
// Look for other arguments.
return this->Superclass::CheckArgumentValue(arg);
diff --git a/Source/CTest/cmCTestCoverageCommand.h b/Source/CTest/cmCTestCoverageCommand.h
index 5762e07..f60ffd5 100644
--- a/Source/CTest/cmCTestCoverageCommand.h
+++ b/Source/CTest/cmCTestCoverageCommand.h
@@ -22,24 +22,23 @@
class cmCTestCoverageCommand : public cmCTestHandlerCommand
{
public:
-
cmCTestCoverageCommand();
/**
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
- {
+ {
cmCTestCoverageCommand* ni = new cmCTestCoverageCommand;
ni->CTest = this->CTest;
ni->CTestScriptHandler = this->CTestScriptHandler;
return ni;
- }
+ }
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const { return "ctest_coverage";}
+ virtual std::string GetName() const { return "ctest_coverage"; }
cmTypeMacro(cmCTestCoverageCommand, cmCTestHandlerCommand);
@@ -59,6 +58,4 @@ protected:
std::set<std::string> Labels;
};
-
#endif
-
diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx
index ed15834..550a774 100644
--- a/Source/CTest/cmCTestCoverageHandler.cxx
+++ b/Source/CTest/cmCTestCoverageHandler.cxx
@@ -34,95 +34,82 @@
#include <math.h>
#include <stdlib.h>
-#define SAFEDIV(x,y) (((y)!=0)?((x)/(y)):(0))
+#define SAFEDIV(x, y) (((y) != 0) ? ((x) / (y)) : (0))
class cmCTestRunProcess
{
public:
cmCTestRunProcess()
- {
- this->Process = cmsysProcess_New();
- this->PipeState = -1;
- this->TimeOut = -1;
- }
+ {
+ this->Process = cmsysProcess_New();
+ this->PipeState = -1;
+ this->TimeOut = -1;
+ }
~cmCTestRunProcess()
- {
- if(!(this->PipeState == -1)
- && !(this->PipeState == cmsysProcess_Pipe_None )
- && !(this->PipeState == cmsysProcess_Pipe_Timeout))
- {
- this->WaitForExit();
- }
- cmsysProcess_Delete(this->Process);
+ {
+ if (!(this->PipeState == -1) &&
+ !(this->PipeState == cmsysProcess_Pipe_None) &&
+ !(this->PipeState == cmsysProcess_Pipe_Timeout)) {
+ this->WaitForExit();
}
+ cmsysProcess_Delete(this->Process);
+ }
void SetCommand(const char* command)
- {
- this->CommandLineStrings.clear();
- this->CommandLineStrings.push_back(command);;
- }
+ {
+ this->CommandLineStrings.clear();
+ this->CommandLineStrings.push_back(command);
+ ;
+ }
void AddArgument(const char* arg)
- {
- if(arg)
- {
- this->CommandLineStrings.push_back(arg);
- }
- }
- void SetWorkingDirectory(const char* dir)
- {
- this->WorkingDirectory = dir;
- }
- void SetTimeout(double t)
- {
- this->TimeOut = t;
+ {
+ if (arg) {
+ this->CommandLineStrings.push_back(arg);
}
+ }
+ void SetWorkingDirectory(const char* dir) { this->WorkingDirectory = dir; }
+ void SetTimeout(double t) { this->TimeOut = t; }
bool StartProcess()
- {
- std::vector<const char*> args;
- for(std::vector<std::string>::iterator i =
- this->CommandLineStrings.begin();
- i != this->CommandLineStrings.end(); ++i)
- {
- args.push_back(i->c_str());
- }
- args.push_back(0); // null terminate
- cmsysProcess_SetCommand(this->Process, &*args.begin());
- if(!this->WorkingDirectory.empty())
- {
- cmsysProcess_SetWorkingDirectory(this->Process,
- this->WorkingDirectory.c_str());
- }
-
- cmsysProcess_SetOption(this->Process,
- cmsysProcess_Option_HideWindow, 1);
- if(this->TimeOut != -1)
- {
- cmsysProcess_SetTimeout(this->Process, this->TimeOut);
- }
- cmsysProcess_Execute(this->Process);
- this->PipeState = cmsysProcess_GetState(this->Process);
- // if the process is running or exited return true
- if(this->PipeState == cmsysProcess_State_Executing
- || this->PipeState == cmsysProcess_State_Exited)
- {
- return true;
- }
- return false;
+ {
+ std::vector<const char*> args;
+ for (std::vector<std::string>::iterator i =
+ this->CommandLineStrings.begin();
+ i != this->CommandLineStrings.end(); ++i) {
+ args.push_back(i->c_str());
+ }
+ args.push_back(0); // null terminate
+ cmsysProcess_SetCommand(this->Process, &*args.begin());
+ if (!this->WorkingDirectory.empty()) {
+ cmsysProcess_SetWorkingDirectory(this->Process,
+ this->WorkingDirectory.c_str());
+ }
+
+ cmsysProcess_SetOption(this->Process, cmsysProcess_Option_HideWindow, 1);
+ if (this->TimeOut != -1) {
+ cmsysProcess_SetTimeout(this->Process, this->TimeOut);
+ }
+ cmsysProcess_Execute(this->Process);
+ this->PipeState = cmsysProcess_GetState(this->Process);
+ // if the process is running or exited return true
+ if (this->PipeState == cmsysProcess_State_Executing ||
+ this->PipeState == cmsysProcess_State_Exited) {
+ return true;
}
+ return false;
+ }
void SetStdoutFile(const char* fname)
- {
+ {
cmsysProcess_SetPipeFile(this->Process, cmsysProcess_Pipe_STDOUT, fname);
- }
+ }
void SetStderrFile(const char* fname)
- {
+ {
cmsysProcess_SetPipeFile(this->Process, cmsysProcess_Pipe_STDERR, fname);
- }
- int WaitForExit(double* timeout =0)
- {
- this->PipeState = cmsysProcess_WaitForExit(this->Process,
- timeout);
- return this->PipeState;
- }
- int GetProcessState() { return this->PipeState;}
+ }
+ int WaitForExit(double* timeout = 0)
+ {
+ this->PipeState = cmsysProcess_WaitForExit(this->Process, timeout);
+ return this->PipeState;
+ }
+ int GetProcessState() { return this->PipeState; }
private:
int PipeState;
cmsysProcess* Process;
@@ -131,8 +118,6 @@ private:
double TimeOut;
};
-
-
cmCTestCoverageHandler::cmCTestCoverageHandler()
{
}
@@ -157,12 +142,11 @@ void cmCTestCoverageHandler::CleanCoverageLogFiles(std::ostream& log)
cmsys::Glob gl;
gl.FindFiles(logGlob);
std::vector<std::string> const& files = gl.GetFiles();
- for(std::vector<std::string>::const_iterator fi = files.begin();
- fi != files.end(); ++fi)
- {
+ for (std::vector<std::string>::const_iterator fi = files.begin();
+ fi != files.end(); ++fi) {
log << "Removing old coverage log: " << *fi << "\n";
cmSystemTools::RemoveFile(*fi);
- }
+ }
}
bool cmCTestCoverageHandler::StartCoverageLogFile(
@@ -170,25 +154,26 @@ bool cmCTestCoverageHandler::StartCoverageLogFile(
{
char covLogFilename[1024];
sprintf(covLogFilename, "CoverageLog-%d", logFileCount);
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Open file: "
- << covLogFilename << std::endl, this->Quiet);
- if(!this->StartResultingXML(cmCTest::PartCoverage,
- covLogFilename, covLogFile))
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open log file: "
- << covLogFilename << std::endl);
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Open file: " << covLogFilename << std::endl,
+ this->Quiet);
+ if (!this->StartResultingXML(cmCTest::PartCoverage, covLogFilename,
+ covLogFile)) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Cannot open log file: " << covLogFilename << std::endl);
return false;
- }
+ }
return true;
}
void cmCTestCoverageHandler::EndCoverageLogFile(cmGeneratedFileStream& ostr,
- int logFileCount)
+ int logFileCount)
{
char covLogFilename[1024];
sprintf(covLogFilename, "CoverageLog-%d.xml", logFileCount);
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Close file: "
- << covLogFilename << std::endl, this->Quiet);
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Close file: " << covLogFilename << std::endl,
+ this->Quiet);
ostr.Close();
}
@@ -198,7 +183,7 @@ void cmCTestCoverageHandler::StartCoverageLogXML(cmXMLWriter& xml)
xml.StartElement("CoverageLog");
xml.Element("StartDateTime", this->CTest->CurrentTime());
xml.Element("StartTime",
- static_cast<unsigned int>(cmSystemTools::GetTime()));
+ static_cast<unsigned int>(cmSystemTools::GetTime()));
}
void cmCTestCoverageHandler::EndCoverageLogXML(cmXMLWriter& xml)
@@ -210,138 +195,117 @@ void cmCTestCoverageHandler::EndCoverageLogXML(cmXMLWriter& xml)
}
bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file,
- const char* srcDir,
- const char* binDir)
+ const char* srcDir,
+ const char* binDir)
{
- if(this->IsFilteredOut(file))
- {
+ if (this->IsFilteredOut(file)) {
return false;
- }
+ }
std::vector<cmsys::RegularExpression>::iterator sit;
- for ( sit = this->CustomCoverageExcludeRegex.begin();
- sit != this->CustomCoverageExcludeRegex.end(); ++ sit )
- {
- if ( sit->find(file) )
- {
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " File " << file
- << " is excluded in CTestCustom.ctest" << std::endl;, this->Quiet);
+ for (sit = this->CustomCoverageExcludeRegex.begin();
+ sit != this->CustomCoverageExcludeRegex.end(); ++sit) {
+ if (sit->find(file)) {
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " File "
+ << file << " is excluded in CTestCustom.ctest"
+ << std::endl;
+ , this->Quiet);
return false;
- }
}
+ }
std::string fSrcDir = cmSystemTools::CollapseFullPath(srcDir);
std::string fBinDir = cmSystemTools::CollapseFullPath(binDir);
std::string fFile = cmSystemTools::CollapseFullPath(file);
- bool sourceSubDir = cmSystemTools::IsSubDirectory(fFile,
- fSrcDir);
- bool buildSubDir = cmSystemTools::IsSubDirectory(fFile,
- fBinDir);
+ bool sourceSubDir = cmSystemTools::IsSubDirectory(fFile, fSrcDir);
+ bool buildSubDir = cmSystemTools::IsSubDirectory(fFile, fBinDir);
// Always check parent directory of the file.
std::string fileDir = cmSystemTools::GetFilenamePath(fFile);
std::string checkDir;
// We also need to check the binary/source directory pair.
- if ( sourceSubDir && buildSubDir )
- {
- if ( fSrcDir.size() > fBinDir.size() )
- {
+ if (sourceSubDir && buildSubDir) {
+ if (fSrcDir.size() > fBinDir.size()) {
checkDir = fSrcDir;
- }
- else
- {
+ } else {
checkDir = fBinDir;
- }
}
- else if ( sourceSubDir )
- {
+ } else if (sourceSubDir) {
checkDir = fSrcDir;
- }
- else if ( buildSubDir )
- {
+ } else if (buildSubDir) {
checkDir = fBinDir;
- }
- std::string ndc
- = cmSystemTools::FileExistsInParentDirectories(".NoDartCoverage",
- fFile.c_str(), checkDir.c_str());
- if (!ndc.empty())
- {
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found: " << ndc
- << " so skip coverage of " << file << std::endl, this->Quiet);
+ }
+ std::string ndc = cmSystemTools::FileExistsInParentDirectories(
+ ".NoDartCoverage", fFile.c_str(), checkDir.c_str());
+ if (!ndc.empty()) {
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Found: " << ndc << " so skip coverage of " << file
+ << std::endl,
+ this->Quiet);
return false;
- }
+ }
// By now checkDir should be set to parent directory of the file.
// Get the relative path to the file an apply it to the opposite directory.
// If it is the same as fileDir, then ignore, otherwise check.
std::string relPath;
- if(!checkDir.empty())
- {
- relPath = cmSystemTools::RelativePath(checkDir.c_str(),
- fFile.c_str());
- }
- else
- {
+ if (!checkDir.empty()) {
+ relPath = cmSystemTools::RelativePath(checkDir.c_str(), fFile.c_str());
+ } else {
relPath = fFile;
- }
- if ( checkDir == fSrcDir )
- {
+ }
+ if (checkDir == fSrcDir) {
checkDir = fBinDir;
- }
- else
- {
+ } else {
checkDir = fSrcDir;
- }
+ }
fFile = checkDir + "/" + relPath;
fFile = cmSystemTools::GetFilenamePath(fFile);
- if ( fileDir == fFile )
- {
+ if (fileDir == fFile) {
// This is in-source build, so we trust the previous check.
return true;
- }
+ }
- ndc = cmSystemTools::FileExistsInParentDirectories(".NoDartCoverage",
- fFile.c_str(), checkDir.c_str());
- if (!ndc.empty())
- {
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found: " << ndc
- << " so skip coverage of: " << file << std::endl, this->Quiet);
+ ndc = cmSystemTools::FileExistsInParentDirectories(
+ ".NoDartCoverage", fFile.c_str(), checkDir.c_str());
+ if (!ndc.empty()) {
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Found: " << ndc << " so skip coverage of: " << file
+ << std::endl,
+ this->Quiet);
return false;
- }
+ }
// Ok, nothing in source tree, nothing in binary tree
return true;
}
-//clearly it would be nice if this were broken up into a few smaller
-//functions and commented...
+// clearly it would be nice if this were broken up into a few smaller
+// functions and commented...
int cmCTestCoverageHandler::ProcessHandler()
{
this->CTest->ClearSubmitFiles(cmCTest::PartCoverage);
int error = 0;
// do we have time for this
- if (this->CTest->GetRemainingTimeAllowed() < 120)
- {
+ if (this->CTest->GetRemainingTimeAllowed() < 120) {
return error;
- }
+ }
std::string coverage_start_time = this->CTest->CurrentTime();
- unsigned int coverage_start_time_time = static_cast<unsigned int>(
- cmSystemTools::GetTime());
- std::string sourceDir
- = this->CTest->GetCTestConfiguration("SourceDirectory");
- std::string binaryDir
- = this->CTest->GetCTestConfiguration("BuildDirectory");
+ unsigned int coverage_start_time_time =
+ static_cast<unsigned int>(cmSystemTools::GetTime());
+ std::string sourceDir =
+ this->CTest->GetCTestConfiguration("SourceDirectory");
+ std::string binaryDir = this->CTest->GetCTestConfiguration("BuildDirectory");
this->LoadLabels();
cmGeneratedFileStream ofs;
double elapsed_time_start = cmSystemTools::GetTime();
- if ( !this->StartLogFile("Coverage", ofs) )
- {
+ if (!this->StartLogFile("Coverage", ofs)) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Cannot create LastCoverage.log file" << std::endl);
- }
+ "Cannot create LastCoverage.log file" << std::endl);
+ }
ofs << "Performing coverage: " << elapsed_time_start << std::endl;
this->CleanCoverageLogFiles(ofs);
@@ -350,7 +314,7 @@ int cmCTestCoverageHandler::ProcessHandler()
cmSystemTools::ConvertToUnixSlashes(binaryDir);
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- "Performing coverage" << std::endl, this->Quiet);
+ "Performing coverage" << std::endl, this->Quiet);
cmCTestCoverageHandlerContainer cont;
cont.Error = error;
@@ -362,97 +326,86 @@ int cmCTestCoverageHandler::ProcessHandler()
// setup the regex exclude stuff
this->CustomCoverageExcludeRegex.clear();
std::vector<std::string>::iterator rexIt;
- for ( rexIt = this->CustomCoverageExclude.begin();
- rexIt != this->CustomCoverageExclude.end();
- ++ rexIt )
- {
+ for (rexIt = this->CustomCoverageExclude.begin();
+ rexIt != this->CustomCoverageExclude.end(); ++rexIt) {
this->CustomCoverageExcludeRegex.push_back(
cmsys::RegularExpression(rexIt->c_str()));
- }
+ }
- if(this->HandleBullseyeCoverage(&cont))
- {
+ if (this->HandleBullseyeCoverage(&cont)) {
return cont.Error;
- }
+ }
int file_count = 0;
file_count += this->HandleGCovCoverage(&cont);
error = cont.Error;
- if ( file_count < 0 )
- {
+ if (file_count < 0) {
return error;
- }
+ }
file_count += this->HandleLCovCoverage(&cont);
error = cont.Error;
- if ( file_count < 0 )
- {
+ if (file_count < 0) {
return error;
- }
+ }
file_count += this->HandleTracePyCoverage(&cont);
error = cont.Error;
- if ( file_count < 0 )
- {
+ if (file_count < 0) {
return error;
- }
+ }
file_count += this->HandlePHPCoverage(&cont);
error = cont.Error;
- if ( file_count < 0 )
- {
+ if (file_count < 0) {
return error;
- }
+ }
file_count += this->HandleCoberturaCoverage(&cont);
error = cont.Error;
- if ( file_count < 0 )
- {
+ if (file_count < 0) {
return error;
- }
+ }
file_count += this->HandleMumpsCoverage(&cont);
error = cont.Error;
- if ( file_count < 0 )
- {
+ if (file_count < 0) {
return error;
- }
+ }
file_count += this->HandleJacocoCoverage(&cont);
error = cont.Error;
- if ( file_count < 0 )
- {
+ if (file_count < 0) {
return error;
- }
+ }
file_count += this->HandleBlanketJSCoverage(&cont);
error = cont.Error;
- if ( file_count < 0 )
- {
+ if (file_count < 0) {
return error;
- }
+ }
- file_count += this->HandleDelphiCoverage(&cont);
+ file_count += this->HandleDelphiCoverage(&cont);
error = cont.Error;
- if ( file_count < 0 )
- {
+ if (file_count < 0) {
return error;
- }
+ }
std::set<std::string> uncovered = this->FindUncoveredFiles(&cont);
- if (file_count == 0 && this->ExtraCoverageGlobs.empty())
- {
- cmCTestOptionalLog(this->CTest, WARNING,
+ if (file_count == 0 && this->ExtraCoverageGlobs.empty()) {
+ cmCTestOptionalLog(
+ this->CTest, WARNING,
" Cannot find any coverage files. Ignoring Coverage request."
- << std::endl, this->Quiet);
+ << std::endl,
+ this->Quiet);
return error;
- }
+ }
cmGeneratedFileStream covSumFile;
cmGeneratedFileStream covLogFile;
cmXMLWriter covSumXML(covSumFile);
cmXMLWriter covLogXML(covLogFile);
- if(!this->StartResultingXML(cmCTest::PartCoverage, "Coverage", covSumFile))
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Cannot open coverage summary file." << std::endl);
+ if (!this->StartResultingXML(cmCTest::PartCoverage, "Coverage",
+ covSumFile)) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open coverage summary file."
+ << std::endl);
return -1;
- }
+ }
covSumFile.setf(std::ios::fixed, std::ios::floatfield);
covSumFile.precision(2);
@@ -463,19 +416,19 @@ int cmCTestCoverageHandler::ProcessHandler()
covSumXML.Element("StartDateTime", coverage_start_time);
covSumXML.Element("StartTime", coverage_start_time_time);
int logFileCount = 0;
- if ( !this->StartCoverageLogFile(covLogFile, logFileCount) )
- {
+ if (!this->StartCoverageLogFile(covLogFile, logFileCount)) {
return -1;
- }
+ }
this->StartCoverageLogXML(covLogXML);
cmCTestCoverageHandlerContainer::TotalCoverageMap::iterator fileIterator;
int cnt = 0;
long total_tested = 0;
long total_untested = 0;
- //std::string fullSourceDir = sourceDir + "/";
- //std::string fullBinaryDir = binaryDir + "/";
+ // std::string fullSourceDir = sourceDir + "/";
+ // std::string fullBinaryDir = binaryDir + "/";
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, std::endl, this->Quiet);
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+ cmCTestOptionalLog(
+ this->CTest, HANDLER_OUTPUT,
" Accumulating results (each . represents one file):" << std::endl,
this->Quiet);
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " ", this->Quiet);
@@ -483,77 +436,68 @@ int cmCTestCoverageHandler::ProcessHandler()
std::vector<std::string> errorsWhileAccumulating;
file_count = 0;
- for ( fileIterator = cont.TotalCoverage.begin();
- fileIterator != cont.TotalCoverage.end();
- ++fileIterator )
- {
+ for (fileIterator = cont.TotalCoverage.begin();
+ fileIterator != cont.TotalCoverage.end(); ++fileIterator) {
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "." << std::flush,
- this->Quiet);
- file_count ++;
- if ( file_count % 50 == 0 )
- {
+ this->Quiet);
+ file_count++;
+ if (file_count % 50 == 0) {
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " processed: "
- << file_count
- << " out of "
- << cont.TotalCoverage.size() << std::endl, this->Quiet);
+ << file_count << " out of "
+ << cont.TotalCoverage.size() << std::endl,
+ this->Quiet);
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " ", this->Quiet);
- }
+ }
const std::string fullFileName = fileIterator->first;
- bool shouldIDoCoverage
- = this->ShouldIDoCoverage(fullFileName.c_str(),
- sourceDir.c_str(), binaryDir.c_str());
- if ( !shouldIDoCoverage )
- {
+ bool shouldIDoCoverage = this->ShouldIDoCoverage(
+ fullFileName.c_str(), sourceDir.c_str(), binaryDir.c_str());
+ if (!shouldIDoCoverage) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- ".NoDartCoverage found, so skip coverage check for: "
- << fullFileName
- << std::endl, this->Quiet);
+ ".NoDartCoverage found, so skip coverage check for: "
+ << fullFileName << std::endl,
+ this->Quiet);
continue;
- }
+ }
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Process file: " << fullFileName << std::endl, this->Quiet);
+ "Process file: " << fullFileName << std::endl,
+ this->Quiet);
- if ( !cmSystemTools::FileExists(fullFileName.c_str()) )
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot find file: "
- << fullFileName << std::endl);
+ if (!cmSystemTools::FileExists(fullFileName.c_str())) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Cannot find file: " << fullFileName << std::endl);
continue;
- }
+ }
- if ( ++cnt % 100 == 0 )
- {
+ if (++cnt % 100 == 0) {
this->EndCoverageLogXML(covLogXML);
this->EndCoverageLogFile(covLogFile, logFileCount);
- logFileCount ++;
- if ( !this->StartCoverageLogFile(covLogFile, logFileCount) )
- {
+ logFileCount++;
+ if (!this->StartCoverageLogFile(covLogFile, logFileCount)) {
return -1;
- }
- this->StartCoverageLogXML(covLogXML);
}
+ this->StartCoverageLogXML(covLogXML);
+ }
- const std::string fileName
- = cmSystemTools::GetFilenameName(fullFileName);
+ const std::string fileName = cmSystemTools::GetFilenameName(fullFileName);
std::string shortFileName =
this->CTest->GetShortPathToFile(fullFileName.c_str());
- const cmCTestCoverageHandlerContainer::SingleFileCoverageVector& fcov
- = fileIterator->second;
+ const cmCTestCoverageHandlerContainer::SingleFileCoverageVector& fcov =
+ fileIterator->second;
covLogXML.StartElement("File");
covLogXML.Attribute("Name", fileName);
covLogXML.Attribute("FullPath", shortFileName);
covLogXML.StartElement("Report");
cmsys::ifstream ifs(fullFileName.c_str());
- if ( !ifs)
- {
+ if (!ifs) {
std::ostringstream ostr;
- ostr << "Cannot open source file: " << fullFileName;
+ ostr << "Cannot open source file: " << fullFileName;
errorsWhileAccumulating.push_back(ostr.str());
- error ++;
+ error++;
continue;
- }
+ }
int tested = 0;
int untested = 0;
@@ -561,49 +505,43 @@ int cmCTestCoverageHandler::ProcessHandler()
cmCTestCoverageHandlerContainer::SingleFileCoverageVector::size_type cc;
std::string line;
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Actually performing coverage for: " << fullFileName << std::endl,
- this->Quiet);
- for ( cc= 0; cc < fcov.size(); cc ++ )
- {
- if ( !cmSystemTools::GetLineFromStream(ifs, line) &&
- cc != fcov.size() -1 )
- {
+ "Actually performing coverage for: " << fullFileName
+ << std::endl,
+ this->Quiet);
+ for (cc = 0; cc < fcov.size(); cc++) {
+ if (!cmSystemTools::GetLineFromStream(ifs, line) &&
+ cc != fcov.size() - 1) {
std::ostringstream ostr;
ostr << "Problem reading source file: " << fullFileName
- << " line:" << cc << " out total: " << fcov.size()-1;
+ << " line:" << cc << " out total: " << fcov.size() - 1;
errorsWhileAccumulating.push_back(ostr.str());
- error ++;
+ error++;
break;
- }
+ }
covLogXML.StartElement("Line");
covLogXML.Attribute("Number", cc);
covLogXML.Attribute("Count", fcov[cc]);
covLogXML.Content(line);
covLogXML.EndElement(); // Line
- if ( fcov[cc] == 0 )
- {
- untested ++;
- }
- else if ( fcov[cc] > 0 )
- {
- tested ++;
- }
+ if (fcov[cc] == 0) {
+ untested++;
+ } else if (fcov[cc] > 0) {
+ tested++;
}
- if ( cmSystemTools::GetLineFromStream(ifs, line) )
- {
+ }
+ if (cmSystemTools::GetLineFromStream(ifs, line)) {
std::ostringstream ostr;
- ostr << "Looks like there are more lines in the file: " << fullFileName;
+ ostr << "Looks like there are more lines in the file: " << fullFileName;
errorsWhileAccumulating.push_back(ostr.str());
- }
+ }
float cper = 0;
float cmet = 0;
- if ( tested + untested > 0 )
- {
+ if (tested + untested > 0) {
cper = (100 * SAFEDIV(static_cast<float>(tested),
- static_cast<float>(tested + untested)));
- cmet = ( SAFEDIV(static_cast<float>(tested + 10),
- static_cast<float>(tested + untested + 10)));
- }
+ static_cast<float>(tested + untested)));
+ cmet = (SAFEDIV(static_cast<float>(tested + 10),
+ static_cast<float>(tested + untested + 10)));
+ }
total_tested += tested;
total_untested += untested;
covLogXML.EndElement(); // Report
@@ -611,7 +549,7 @@ int cmCTestCoverageHandler::ProcessHandler()
covSumXML.StartElement("File");
covSumXML.Attribute("Name", fileName);
covSumXML.Attribute("FullPath",
- this->CTest->GetShortPathToFile(fullFileName.c_str()));
+ this->CTest->GetShortPathToFile(fullFileName.c_str()));
covSumXML.Attribute("Covered", tested + untested > 0 ? "true" : "false");
covSumXML.Element("LOCTested", tested);
covSumXML.Element("LOCUnTested", untested);
@@ -619,12 +557,11 @@ int cmCTestCoverageHandler::ProcessHandler()
covSumXML.Element("CoverageMetric", cmet);
this->WriteXMLLabels(covSumXML, shortFileName);
covSumXML.EndElement(); // File
- }
+ }
- //Handle all the files in the extra coverage globs that have no cov data
- for(std::set<std::string>::iterator i = uncovered.begin();
- i != uncovered.end(); ++i)
- {
+ // Handle all the files in the extra coverage globs that have no cov data
+ for (std::set<std::string>::iterator i = uncovered.begin();
+ i != uncovered.end(); ++i) {
std::string fileName = cmSystemTools::GetFilenameName(*i);
std::string fullPath = cont.SourceDir + "/" + *i;
@@ -634,27 +571,26 @@ int cmCTestCoverageHandler::ProcessHandler()
covLogXML.StartElement("Report");
cmsys::ifstream ifs(fullPath.c_str());
- if (!ifs)
- {
+ if (!ifs) {
std::ostringstream ostr;
- ostr << "Cannot open source file: " << fullPath;
+ ostr << "Cannot open source file: " << fullPath;
errorsWhileAccumulating.push_back(ostr.str());
- error ++;
+ error++;
continue;
- }
+ }
int untested = 0;
std::string line;
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Actually performing coverage for: " << *i << std::endl, this->Quiet);
- while (cmSystemTools::GetLineFromStream(ifs, line))
- {
+ "Actually performing coverage for: " << *i << std::endl,
+ this->Quiet);
+ while (cmSystemTools::GetLineFromStream(ifs, line)) {
covLogXML.StartElement("Line");
covLogXML.Attribute("Number", untested);
covLogXML.Attribute("Count", 0);
covLogXML.Content(line);
covLogXML.EndElement(); // Line
- untested ++;
- }
+ untested++;
+ }
covLogXML.EndElement(); // Report
covLogXML.EndElement(); // File
@@ -669,33 +605,28 @@ int cmCTestCoverageHandler::ProcessHandler()
covSumXML.Element("CoverageMetric", 0);
this->WriteXMLLabels(covSumXML, *i);
covSumXML.EndElement(); // File
- }
+ }
this->EndCoverageLogXML(covLogXML);
this->EndCoverageLogFile(covLogFile, logFileCount);
- if (!errorsWhileAccumulating.empty())
- {
+ if (!errorsWhileAccumulating.empty()) {
cmCTestLog(this->CTest, ERROR_MESSAGE, std::endl);
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Error(s) while accumulating results:" << std::endl);
+ "Error(s) while accumulating results:" << std::endl);
std::vector<std::string>::iterator erIt;
- for ( erIt = errorsWhileAccumulating.begin();
- erIt != errorsWhileAccumulating.end();
- ++ erIt )
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- " " << *erIt << std::endl);
- }
+ for (erIt = errorsWhileAccumulating.begin();
+ erIt != errorsWhileAccumulating.end(); ++erIt) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, " " << *erIt << std::endl);
}
+ }
long total_lines = total_tested + total_untested;
- float percent_coverage = 100 * SAFEDIV(static_cast<float>(total_tested),
- static_cast<float>(total_lines));
- if ( total_lines == 0 )
- {
+ float percent_coverage = 100 *
+ SAFEDIV(static_cast<float>(total_tested), static_cast<float>(total_lines));
+ if (total_lines == 0) {
percent_coverage = 0;
- }
+ }
std::string end_time = this->CTest->CurrentTime();
@@ -705,60 +636,57 @@ int cmCTestCoverageHandler::ProcessHandler()
covSumXML.Element("PercentCoverage", percent_coverage);
covSumXML.Element("EndDateTime", end_time);
covSumXML.Element("EndTime",
- static_cast<unsigned int>(cmSystemTools::GetTime()));
- covSumXML.Element("ElapsedMinutes",
- static_cast<int>((cmSystemTools::GetTime() - elapsed_time_start)/6)/10.0);
+ static_cast<unsigned int>(cmSystemTools::GetTime()));
+ covSumXML.Element(
+ "ElapsedMinutes",
+ static_cast<int>((cmSystemTools::GetTime() - elapsed_time_start) / 6) /
+ 10.0);
covSumXML.EndElement(); // Coverage
this->CTest->EndXML(covSumXML);
- cmCTestLog(this->CTest, HANDLER_OUTPUT, "" << std::endl
- << "\tCovered LOC: "
- << total_tested << std::endl
- << "\tNot covered LOC: " << total_untested << std::endl
- << "\tTotal LOC: " << total_lines << std::endl
- << "\tPercentage Coverage: "
- << std::setiosflags(std::ios::fixed)
- << std::setprecision(2)
- << (percent_coverage) << "%" << std::endl);
+ cmCTestLog(this->CTest, HANDLER_OUTPUT, ""
+ << std::endl
+ << "\tCovered LOC: " << total_tested << std::endl
+ << "\tNot covered LOC: " << total_untested << std::endl
+ << "\tTotal LOC: " << total_lines << std::endl
+ << "\tPercentage Coverage: "
+ << std::setiosflags(std::ios::fixed) << std::setprecision(2)
+ << (percent_coverage) << "%" << std::endl);
ofs << "\tCovered LOC: " << total_tested << std::endl
- << "\tNot covered LOC: " << total_untested << std::endl
- << "\tTotal LOC: " << total_lines << std::endl
- << "\tPercentage Coverage: "
- << std::setiosflags(std::ios::fixed)
- << std::setprecision(2)
- << (percent_coverage) << "%" << std::endl;
-
+ << "\tNot covered LOC: " << total_untested << std::endl
+ << "\tTotal LOC: " << total_lines << std::endl
+ << "\tPercentage Coverage: " << std::setiosflags(std::ios::fixed)
+ << std::setprecision(2) << (percent_coverage) << "%" << std::endl;
- if ( error )
- {
+ if (error) {
return -1;
- }
+ }
return 0;
}
-void cmCTestCoverageHandler::PopulateCustomVectors(cmMakefile *mf)
+void cmCTestCoverageHandler::PopulateCustomVectors(cmMakefile* mf)
{
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " Add coverage exclude regular expressions." << std::endl, this->Quiet);
+ " Add coverage exclude regular expressions." << std::endl,
+ this->Quiet);
this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_COVERAGE_EXCLUDE",
- this->CustomCoverageExclude);
+ this->CustomCoverageExclude);
this->CTest->PopulateCustomVector(mf, "CTEST_EXTRA_COVERAGE_GLOB",
- this->ExtraCoverageGlobs);
+ this->ExtraCoverageGlobs);
std::vector<std::string>::iterator it;
- for ( it = this->CustomCoverageExclude.begin();
- it != this->CustomCoverageExclude.end();
- ++ it )
- {
+ for (it = this->CustomCoverageExclude.begin();
+ it != this->CustomCoverageExclude.end(); ++it) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " Add coverage exclude: " << *it << std::endl, this->Quiet);
- }
- for ( it = this->ExtraCoverageGlobs.begin();
- it != this->ExtraCoverageGlobs.end(); ++it)
- {
+ " Add coverage exclude: " << *it << std::endl,
+ this->Quiet);
+ }
+ for (it = this->ExtraCoverageGlobs.begin();
+ it != this->ExtraCoverageGlobs.end(); ++it) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " Add coverage glob: " << *it << std::endl, this->Quiet);
- }
+ " Add coverage glob: " << *it << std::endl,
+ this->Quiet);
+ }
}
// Fix for issue #4971 where the case of the drive letter component of
@@ -772,19 +700,16 @@ void cmCTestCoverageHandler::PopulateCustomVectors(cmMakefile *mf)
#define fnc(s) s
#endif
-bool IsFileInDir(const std::string &infile, const std::string &indir)
+bool IsFileInDir(const std::string& infile, const std::string& indir)
{
std::string file = cmSystemTools::CollapseFullPath(infile);
std::string dir = cmSystemTools::CollapseFullPath(indir);
- if (
- file.size() > dir.size() &&
- (fnc(file.substr(0, dir.size())) == fnc(dir)) &&
- file[dir.size()] == '/'
- )
- {
+ if (file.size() > dir.size() &&
+ (fnc(file.substr(0, dir.size())) == fnc(dir)) &&
+ file[dir.size()] == '/') {
return true;
- }
+ }
return false;
}
@@ -794,10 +719,9 @@ int cmCTestCoverageHandler::HandlePHPCoverage(
{
cmParsePHPCoverage cov(*cont, this->CTest);
std::string coverageDir = this->CTest->GetBinaryDir() + "/xdebugCoverage";
- if(cmSystemTools::FileIsDirectory(coverageDir))
- {
+ if (cmSystemTools::FileIsDirectory(coverageDir)) {
cov.ReadPHPCoverageDirectory(coverageDir.c_str());
- }
+ }
return static_cast<int>(cont->TotalCoverage.size());
}
@@ -812,31 +736,27 @@ int cmCTestCoverageHandler::HandleCoberturaCoverage(
// binary directory is used.
std::string coverageXMLFile;
const char* covDir = cmSystemTools::GetEnv("COBERTURADIR");
- if(covDir && strlen(covDir) != 0)
- {
- coverageXMLFile = std::string(covDir);
- }
- else
- {
- coverageXMLFile = this->CTest->GetBinaryDir();
- }
+ if (covDir && strlen(covDir) != 0) {
+ coverageXMLFile = std::string(covDir);
+ } else {
+ coverageXMLFile = this->CTest->GetBinaryDir();
+ }
// build the find file string with the directory from above
coverageXMLFile += "/coverage.xml";
- if(cmSystemTools::FileExists(coverageXMLFile.c_str()))
- {
+ if (cmSystemTools::FileExists(coverageXMLFile.c_str())) {
// If file exists, parse it
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Parsing Cobertura XML file: " << coverageXMLFile
- << std::endl, this->Quiet);
+ "Parsing Cobertura XML file: " << coverageXMLFile
+ << std::endl,
+ this->Quiet);
cov.ReadCoverageXML(coverageXMLFile.c_str());
- }
- else
- {
+ } else {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " Cannot find Cobertura XML file: " << coverageXMLFile
- << std::endl, this->Quiet);
- }
+ " Cannot find Cobertura XML file: " << coverageXMLFile
+ << std::endl,
+ this->Quiet);
+ }
return static_cast<int>(cont->TotalCoverage.size());
}
@@ -845,82 +765,71 @@ int cmCTestCoverageHandler::HandleMumpsCoverage(
{
// try gtm coverage
cmParseGTMCoverage cov(*cont, this->CTest);
- std::string coverageFile = this->CTest->GetBinaryDir() +
- "/gtm_coverage.mcov";
- if(cmSystemTools::FileExists(coverageFile.c_str()))
- {
+ std::string coverageFile =
+ this->CTest->GetBinaryDir() + "/gtm_coverage.mcov";
+ if (cmSystemTools::FileExists(coverageFile.c_str())) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Parsing Cache Coverage: " << coverageFile
- << std::endl, this->Quiet);
+ "Parsing Cache Coverage: " << coverageFile << std::endl,
+ this->Quiet);
cov.ReadCoverageFile(coverageFile.c_str());
return static_cast<int>(cont->TotalCoverage.size());
- }
- else
- {
+ } else {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " Cannot find GTM coverage file: " << coverageFile
- << std::endl, this->Quiet);
- }
+ " Cannot find GTM coverage file: " << coverageFile
+ << std::endl,
+ this->Quiet);
+ }
cmParseCacheCoverage ccov(*cont, this->CTest);
- coverageFile = this->CTest->GetBinaryDir() +
- "/cache_coverage.cmcov";
- if(cmSystemTools::FileExists(coverageFile.c_str()))
- {
+ coverageFile = this->CTest->GetBinaryDir() + "/cache_coverage.cmcov";
+ if (cmSystemTools::FileExists(coverageFile.c_str())) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Parsing Cache Coverage: " << coverageFile
- << std::endl, this->Quiet);
+ "Parsing Cache Coverage: " << coverageFile << std::endl,
+ this->Quiet);
ccov.ReadCoverageFile(coverageFile.c_str());
- }
- else
- {
+ } else {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " Cannot find Cache coverage file: " << coverageFile
- << std::endl, this->Quiet);
- }
+ " Cannot find Cache coverage file: " << coverageFile
+ << std::endl,
+ this->Quiet);
+ }
return static_cast<int>(cont->TotalCoverage.size());
}
struct cmCTestCoverageHandlerLocale
{
cmCTestCoverageHandlerLocale()
- {
- if(const char* l = cmSystemTools::GetEnv("LC_ALL"))
- {
+ {
+ if (const char* l = cmSystemTools::GetEnv("LC_ALL")) {
lc_all = l;
- }
- if(lc_all != "C")
- {
+ }
+ if (lc_all != "C") {
cmSystemTools::PutEnv("LC_ALL=C");
- }
}
+ }
~cmCTestCoverageHandlerLocale()
- {
- if(!lc_all.empty())
- {
+ {
+ if (!lc_all.empty()) {
cmSystemTools::PutEnv("LC_ALL=" + lc_all);
- }
- else
- {
+ } else {
cmSystemTools::UnsetEnv("LC_ALL");
- }
}
+ }
std::string lc_all;
};
int cmCTestCoverageHandler::HandleJacocoCoverage(
cmCTestCoverageHandlerContainer* cont)
{
- cmParseJacocoCoverage cov =
- cmParseJacocoCoverage(*cont, this->CTest);
+ cmParseJacocoCoverage cov = cmParseJacocoCoverage(*cont, this->CTest);
// Search in the source directory.
cmsys::Glob g1;
std::vector<std::string> files;
g1.SetRecurse(true);
- std::string SourceDir
- = this->CTest->GetCTestConfiguration("SourceDirectory");
- std::string coverageFile = SourceDir+ "/*jacoco.xml";
+ std::string SourceDir =
+ this->CTest->GetCTestConfiguration("SourceDirectory");
+ std::string coverageFile = SourceDir + "/*jacoco.xml";
g1.FindFiles(coverageFile);
files = g1.GetFiles();
@@ -929,147 +838,132 @@ int cmCTestCoverageHandler::HandleJacocoCoverage(
cmsys::Glob g2;
std::vector<std::string> binFiles;
g2.SetRecurse(true);
- std::string binaryDir
- = this->CTest->GetCTestConfiguration("BuildDirectory");
- std::string binCoverageFile = binaryDir+ "/*jacoco.xml";
+ std::string binaryDir = this->CTest->GetCTestConfiguration("BuildDirectory");
+ std::string binCoverageFile = binaryDir + "/*jacoco.xml";
g2.FindFiles(binCoverageFile);
binFiles = g2.GetFiles();
- if (!binFiles.empty())
- {
+ if (!binFiles.empty()) {
files.insert(files.end(), binFiles.begin(), binFiles.end());
- }
+ }
- if (!files.empty())
- {
+ if (!files.empty()) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Found Jacoco Files, Performing Coverage" << std::endl, this->Quiet);
+ "Found Jacoco Files, Performing Coverage" << std::endl,
+ this->Quiet);
cov.LoadCoverageData(files);
- }
- else
- {
+ } else {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " Cannot find Jacoco coverage files: " << coverageFile
- << std::endl, this->Quiet);
- }
+ " Cannot find Jacoco coverage files: " << coverageFile
+ << std::endl,
+ this->Quiet);
+ }
return static_cast<int>(cont->TotalCoverage.size());
}
int cmCTestCoverageHandler::HandleDelphiCoverage(
cmCTestCoverageHandlerContainer* cont)
{
- cmParseDelphiCoverage cov =
- cmParseDelphiCoverage(*cont, this->CTest);
+ cmParseDelphiCoverage cov = cmParseDelphiCoverage(*cont, this->CTest);
cmsys::Glob g;
std::vector<std::string> files;
g.SetRecurse(true);
-
- std::string BinDir
- = this->CTest->GetBinaryDir();
- std::string coverageFile = BinDir+ "/*(*.pas).html";
-
+ std::string BinDir = this->CTest->GetBinaryDir();
+ std::string coverageFile = BinDir + "/*(*.pas).html";
g.FindFiles(coverageFile);
- files=g.GetFiles();
- if (!files.empty())
- {
+ files = g.GetFiles();
+ if (!files.empty()) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Found Delphi HTML Files, Performing Coverage" << std::endl,
- this->Quiet);
+ "Found Delphi HTML Files, Performing Coverage"
+ << std::endl,
+ this->Quiet);
cov.LoadCoverageData(files);
- }
- else
- {
+ } else {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " Cannot find Delphi coverage files: " << coverageFile
- << std::endl, this->Quiet);
- }
+ " Cannot find Delphi coverage files: " << coverageFile
+ << std::endl,
+ this->Quiet);
+ }
return static_cast<int>(cont->TotalCoverage.size());
}
int cmCTestCoverageHandler::HandleBlanketJSCoverage(
cmCTestCoverageHandlerContainer* cont)
- {
- cmParseBlanketJSCoverage cov =
- cmParseBlanketJSCoverage(*cont, this->CTest);
- std::string SourceDir
- = this->CTest->GetCTestConfiguration("SourceDirectory");
+{
+ cmParseBlanketJSCoverage cov = cmParseBlanketJSCoverage(*cont, this->CTest);
+ std::string SourceDir =
+ this->CTest->GetCTestConfiguration("SourceDirectory");
- //Look for something other than output.json, still JSON extension.
- std::string coverageFile = SourceDir+ "/*.json";
+ // Look for something other than output.json, still JSON extension.
+ std::string coverageFile = SourceDir + "/*.json";
cmsys::Glob g;
std::vector<std::string> files;
std::vector<std::string> blanketFiles;
g.FindFiles(coverageFile);
- files=g.GetFiles();
+ files = g.GetFiles();
// Ensure that the JSON files found are the result of the
// Blanket.js output. Check for the "node-jscoverage"
// string on the second line
std::string line;
- for(unsigned int fileEntry=0;fileEntry<files.size();fileEntry++)
- {
+ for (unsigned int fileEntry = 0; fileEntry < files.size(); fileEntry++) {
cmsys::ifstream in(files[fileEntry].c_str());
cmSystemTools::GetLineFromStream(in, line);
cmSystemTools::GetLineFromStream(in, line);
- if (line.find("node-jscoverage") != line.npos)
- {
+ if (line.find("node-jscoverage") != line.npos) {
blanketFiles.push_back(files[fileEntry]);
- }
}
+ }
// Take all files with the node-jscoverage string and parse those
- if (!blanketFiles.empty())
- {
+ if (!blanketFiles.empty()) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Found BlanketJS output JSON, Performing Coverage" << std::endl,
- this->Quiet);
+ "Found BlanketJS output JSON, Performing Coverage"
+ << std::endl,
+ this->Quiet);
cov.LoadCoverageData(files);
- }
- else
- {
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " Cannot find BlanketJS coverage files: " << coverageFile
- << std::endl, this->Quiet);
- }
- return static_cast<int>(cont->TotalCoverage.size());
+ } else {
+ cmCTestOptionalLog(
+ this->CTest, HANDLER_VERBOSE_OUTPUT,
+ " Cannot find BlanketJS coverage files: " << coverageFile << std::endl,
+ this->Quiet);
}
+ return static_cast<int>(cont->TotalCoverage.size());
+}
int cmCTestCoverageHandler::HandleGCovCoverage(
cmCTestCoverageHandlerContainer* cont)
{
- std::string gcovCommand
- = this->CTest->GetCTestConfiguration("CoverageCommand");
- if (gcovCommand.empty())
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Could not find gcov." << std::endl);
+ std::string gcovCommand =
+ this->CTest->GetCTestConfiguration("CoverageCommand");
+ if (gcovCommand.empty()) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "Could not find gcov."
+ << std::endl);
return 0;
- }
- std::string gcovExtraFlags
- = this->CTest->GetCTestConfiguration("CoverageExtraFlags");
+ }
+ std::string gcovExtraFlags =
+ this->CTest->GetCTestConfiguration("CoverageExtraFlags");
// Immediately skip to next coverage option since codecov is only for Intel
// compiler
- if ( gcovCommand == "codecov" )
- {
+ if (gcovCommand == "codecov") {
return 0;
- }
+ }
// Style 1
- std::string st1gcovOutputRex1
- = "[0-9]+\\.[0-9]+% of [0-9]+ (source |)lines executed in file (.*)$";
+ std::string st1gcovOutputRex1 =
+ "[0-9]+\\.[0-9]+% of [0-9]+ (source |)lines executed in file (.*)$";
std::string st1gcovOutputRex2 = "^Creating (.*\\.gcov)\\.";
cmsys::RegularExpression st1re1(st1gcovOutputRex1.c_str());
cmsys::RegularExpression st1re2(st1gcovOutputRex2.c_str());
-
// Style 2
std::string st2gcovOutputRex1 = "^File *[`'](.*)'$";
- std::string st2gcovOutputRex2
- = "Lines executed: *[0-9]+\\.[0-9]+% of [0-9]+$";
+ std::string st2gcovOutputRex2 =
+ "Lines executed: *[0-9]+\\.[0-9]+% of [0-9]+$";
std::string st2gcovOutputRex3 = "^(.*)reating [`'](.*\\.gcov)'";
std::string st2gcovOutputRex4 = "^(.*):unexpected EOF *$";
std::string st2gcovOutputRex5 = "^(.*):cannot open source file*$";
- std::string st2gcovOutputRex6
- = "^(.*):source file is newer than graph file `(.*)'$";
+ std::string st2gcovOutputRex6 =
+ "^(.*):source file is newer than graph file `(.*)'$";
cmsys::RegularExpression st2re1(st2gcovOutputRex1.c_str());
cmsys::RegularExpression st2re2(st2gcovOutputRex2.c_str());
cmsys::RegularExpression st2re3(st2gcovOutputRex3.c_str());
@@ -1081,14 +975,13 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
this->FindGCovFiles(files);
std::vector<std::string>::iterator it;
- if (files.empty())
- {
+ if (files.empty()) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " Cannot find any GCov coverage files."
- << std::endl, this->Quiet);
+ " Cannot find any GCov coverage files." << std::endl,
+ this->Quiet);
// No coverage files is a valid thing, so the exit code is 0
return 0;
- }
+ }
std::string testingDir = this->CTest->GetBinaryDir() + "/Testing";
std::string tempDir = testingDir + "/CoverageInfo";
@@ -1101,7 +994,8 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
std::set<std::string> missingFiles;
std::string actualSourceFile = "";
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+ cmCTestOptionalLog(
+ this->CTest, HANDLER_OUTPUT,
" Processing coverage (each . represents one file):" << std::endl,
this->Quiet);
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " ", this->Quiet);
@@ -1115,259 +1009,216 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
// These are binary files that you give as input to gcov so that it will
// give us text output we can analyze to summarize coverage.
//
- for ( it = files.begin(); it != files.end(); ++ it )
- {
+ for (it = files.begin(); it != files.end(); ++it) {
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "." << std::flush,
- this->Quiet);
+ this->Quiet);
// Call gcov to get coverage data for this *.gcda file:
//
std::string fileDir = cmSystemTools::GetFilenamePath(*it);
- std::string command = "\"" + gcovCommand + "\" " +
- gcovExtraFlags + " " +
- "-o \"" + fileDir + "\" " +
- "\"" + *it + "\"";
+ std::string command = "\"" + gcovCommand + "\" " + gcovExtraFlags + " " +
+ "-o \"" + fileDir + "\" " + "\"" + *it + "\"";
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, command.c_str()
- << std::endl, this->Quiet);
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ command.c_str() << std::endl, this->Quiet);
std::string output = "";
std::string errors = "";
int retVal = 0;
*cont->OFS << "* Run coverage for: " << fileDir << std::endl;
*cont->OFS << " Command: " << command << std::endl;
- int res = this->CTest->RunCommand(command.c_str(), &output, &errors,
- &retVal, tempDir.c_str(), 0 /*this->TimeOut*/);
+ int res =
+ this->CTest->RunCommand(command.c_str(), &output, &errors, &retVal,
+ tempDir.c_str(), 0 /*this->TimeOut*/);
*cont->OFS << " Output: " << output << std::endl;
*cont->OFS << " Errors: " << errors << std::endl;
- if ( ! res )
- {
+ if (!res) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Problem running coverage on file: " << *it << std::endl);
+ "Problem running coverage on file: " << *it << std::endl);
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Command produced error: " << errors << std::endl);
- cont->Error ++;
+ "Command produced error: " << errors << std::endl);
+ cont->Error++;
continue;
- }
- if ( retVal != 0 )
- {
+ }
+ if (retVal != 0) {
cmCTestLog(this->CTest, ERROR_MESSAGE, "Coverage command returned: "
- << retVal << " while processing: " << *it << std::endl);
+ << retVal << " while processing: " << *it << std::endl);
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Command produced error: " << cont->Error << std::endl);
- }
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Command produced error: " << cont->Error << std::endl);
+ }
+ cmCTestOptionalLog(
+ this->CTest, HANDLER_VERBOSE_OUTPUT,
"--------------------------------------------------------------"
- << std::endl
- << output << std::endl
- << "--------------------------------------------------------------"
- << std::endl, this->Quiet);
+ << std::endl
+ << output << std::endl
+ << "--------------------------------------------------------------"
+ << std::endl,
+ this->Quiet);
std::vector<std::string> lines;
std::vector<std::string>::iterator line;
cmSystemTools::Split(output.c_str(), lines);
- for ( line = lines.begin(); line != lines.end(); ++line)
- {
+ for (line = lines.begin(); line != lines.end(); ++line) {
std::string sourceFile;
std::string gcovFile;
- cmCTestOptionalLog(this->CTest, DEBUG, "Line: [" << *line << "]"
- << std::endl, this->Quiet);
+ cmCTestOptionalLog(this->CTest, DEBUG,
+ "Line: [" << *line << "]" << std::endl, this->Quiet);
- if (line->empty())
- {
+ if (line->empty()) {
// Ignore empty line; probably style 2
- }
- else if ( st1re1.find(line->c_str()) )
- {
- if ( gcovStyle == 0 )
- {
+ } else if (st1re1.find(line->c_str())) {
+ if (gcovStyle == 0) {
gcovStyle = 1;
- }
- if ( gcovStyle != 1 )
- {
+ }
+ if (gcovStyle != 1) {
cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style e1"
- << std::endl);
- cont->Error ++;
+ << std::endl);
+ cont->Error++;
break;
- }
+ }
actualSourceFile = "";
sourceFile = st1re1.match(2);
- }
- else if ( st1re2.find(line->c_str() ) )
- {
- if ( gcovStyle == 0 )
- {
+ } else if (st1re2.find(line->c_str())) {
+ if (gcovStyle == 0) {
gcovStyle = 1;
- }
- if ( gcovStyle != 1 )
- {
+ }
+ if (gcovStyle != 1) {
cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style e2"
- << std::endl);
- cont->Error ++;
+ << std::endl);
+ cont->Error++;
break;
- }
+ }
gcovFile = st1re2.match(1);
- }
- else if ( st2re1.find(line->c_str() ) )
- {
- if ( gcovStyle == 0 )
- {
+ } else if (st2re1.find(line->c_str())) {
+ if (gcovStyle == 0) {
gcovStyle = 2;
- }
- if ( gcovStyle != 2 )
- {
+ }
+ if (gcovStyle != 2) {
cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style e3"
- << std::endl);
- cont->Error ++;
+ << std::endl);
+ cont->Error++;
break;
- }
+ }
actualSourceFile = "";
sourceFile = st2re1.match(1);
- }
- else if ( st2re2.find(line->c_str() ) )
- {
- if ( gcovStyle == 0 )
- {
+ } else if (st2re2.find(line->c_str())) {
+ if (gcovStyle == 0) {
gcovStyle = 2;
- }
- if ( gcovStyle != 2 )
- {
+ }
+ if (gcovStyle != 2) {
cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style e4"
- << std::endl);
- cont->Error ++;
+ << std::endl);
+ cont->Error++;
break;
- }
}
- else if ( st2re3.find(line->c_str() ) )
- {
- if ( gcovStyle == 0 )
- {
+ } else if (st2re3.find(line->c_str())) {
+ if (gcovStyle == 0) {
gcovStyle = 2;
- }
- if ( gcovStyle != 2 )
- {
+ }
+ if (gcovStyle != 2) {
cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style e5"
- << std::endl);
- cont->Error ++;
+ << std::endl);
+ cont->Error++;
break;
- }
+ }
gcovFile = st2re3.match(2);
- }
- else if ( st2re4.find(line->c_str() ) )
- {
- if ( gcovStyle == 0 )
- {
+ } else if (st2re4.find(line->c_str())) {
+ if (gcovStyle == 0) {
gcovStyle = 2;
- }
- if ( gcovStyle != 2 )
- {
+ }
+ if (gcovStyle != 2) {
cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style e6"
- << std::endl);
- cont->Error ++;
+ << std::endl);
+ cont->Error++;
break;
- }
-
- cmCTestOptionalLog(this->CTest, WARNING, "Warning: " << st2re4.match(1)
- << " had unexpected EOF" << std::endl, this->Quiet);
}
- else if ( st2re5.find(line->c_str() ) )
- {
- if ( gcovStyle == 0 )
- {
+
+ cmCTestOptionalLog(this->CTest, WARNING,
+ "Warning: " << st2re4.match(1)
+ << " had unexpected EOF" << std::endl,
+ this->Quiet);
+ } else if (st2re5.find(line->c_str())) {
+ if (gcovStyle == 0) {
gcovStyle = 2;
- }
- if ( gcovStyle != 2 )
- {
+ }
+ if (gcovStyle != 2) {
cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style e7"
- << std::endl);
- cont->Error ++;
+ << std::endl);
+ cont->Error++;
break;
- }
+ }
cmCTestOptionalLog(this->CTest, WARNING, "Warning: Cannot open file: "
- << st2re5.match(1) << std::endl, this->Quiet);
- }
- else if ( st2re6.find(line->c_str() ) )
- {
- if ( gcovStyle == 0 )
- {
+ << st2re5.match(1) << std::endl,
+ this->Quiet);
+ } else if (st2re6.find(line->c_str())) {
+ if (gcovStyle == 0) {
gcovStyle = 2;
- }
- if ( gcovStyle != 2 )
- {
+ }
+ if (gcovStyle != 2) {
cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style e8"
- << std::endl);
- cont->Error ++;
+ << std::endl);
+ cont->Error++;
break;
- }
+ }
cmCTestOptionalLog(this->CTest, WARNING, "Warning: File: "
- << st2re6.match(1)
- << " is newer than " << st2re6.match(2) << std::endl, this->Quiet);
- }
- else
- {
+ << st2re6.match(1) << " is newer than "
+ << st2re6.match(2) << std::endl,
+ this->Quiet);
+ } else {
// gcov 4.7 can have output lines saying "No executable lines" and
// "Removing 'filename.gcov'"... Don't log those as "errors."
- if(*line != "No executable lines" &&
- !cmSystemTools::StringStartsWith(line->c_str(), "Removing "))
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Unknown gcov output line: [" << *line << "]"
- << std::endl);
- cont->Error ++;
- //abort();
- }
+ if (*line != "No executable lines" &&
+ !cmSystemTools::StringStartsWith(line->c_str(), "Removing ")) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output line: ["
+ << *line << "]" << std::endl);
+ cont->Error++;
+ // abort();
}
-
+ }
// If the last line of gcov output gave us a valid value for gcovFile,
// and we have an actualSourceFile, then insert a (or add to existing)
// SingleFileCoverageVector for actualSourceFile:
//
- if ( !gcovFile.empty() && !actualSourceFile.empty() )
- {
- cmCTestCoverageHandlerContainer::SingleFileCoverageVector& vec
- = cont->TotalCoverage[actualSourceFile];
+ if (!gcovFile.empty() && !actualSourceFile.empty()) {
+ cmCTestCoverageHandlerContainer::SingleFileCoverageVector& vec =
+ cont->TotalCoverage[actualSourceFile];
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " in gcovFile: " << gcovFile << std::endl, this->Quiet);
+ " in gcovFile: " << gcovFile << std::endl,
+ this->Quiet);
cmsys::ifstream ifile(gcovFile.c_str());
- if ( ! ifile )
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open file: "
- << gcovFile << std::endl);
- }
- else
- {
+ if (!ifile) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Cannot open file: " << gcovFile << std::endl);
+ } else {
long cnt = -1;
std::string nl;
- while ( cmSystemTools::GetLineFromStream(ifile, nl) )
- {
- cnt ++;
+ while (cmSystemTools::GetLineFromStream(ifile, nl)) {
+ cnt++;
- //TODO: Handle gcov 3.0 non-coverage lines
+ // TODO: Handle gcov 3.0 non-coverage lines
// Skip empty lines
- if (nl.empty())
- {
+ if (nl.empty()) {
continue;
- }
+ }
// Skip unused lines
- if ( nl.size() < 12 )
- {
+ if (nl.size() < 12) {
continue;
- }
+ }
// Read the coverage count from the beginning of the gcov output
// line
@@ -1378,96 +1229,86 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
// output line
std::string lineNumber = nl.substr(10, 5);
- int lineIdx = atoi(lineNumber.c_str())-1;
- if ( lineIdx >= 0 )
- {
- while ( vec.size() <= static_cast<size_t>(lineIdx) )
- {
+ int lineIdx = atoi(lineNumber.c_str()) - 1;
+ if (lineIdx >= 0) {
+ while (vec.size() <= static_cast<size_t>(lineIdx)) {
vec.push_back(-1);
- }
+ }
// Initially all entries are -1 (not used). If we get coverage
// information, increment it to 0 first.
- if ( vec[lineIdx] < 0 )
- {
- if ( cov > 0 || prefix.find("#") != prefix.npos )
- {
+ if (vec[lineIdx] < 0) {
+ if (cov > 0 || prefix.find("#") != prefix.npos) {
vec[lineIdx] = 0;
- }
}
+ }
vec[lineIdx] += cov;
- }
}
}
-
- actualSourceFile = "";
}
+ actualSourceFile = "";
+ }
- if ( !sourceFile.empty() && actualSourceFile.empty() )
- {
+ if (!sourceFile.empty() && actualSourceFile.empty()) {
gcovFile = "";
// Is it in the source dir or the binary dir?
//
- if ( IsFileInDir(sourceFile, cont->SourceDir) )
- {
+ if (IsFileInDir(sourceFile, cont->SourceDir)) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " produced s: " << sourceFile << std::endl, this->Quiet);
+ " produced s: " << sourceFile << std::endl,
+ this->Quiet);
*cont->OFS << " produced in source dir: " << sourceFile
- << std::endl;
- actualSourceFile
- = cmSystemTools::CollapseFullPath(sourceFile);
- }
- else if ( IsFileInDir(sourceFile, cont->BinaryDir) )
- {
+ << std::endl;
+ actualSourceFile = cmSystemTools::CollapseFullPath(sourceFile);
+ } else if (IsFileInDir(sourceFile, cont->BinaryDir)) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " produced b: " << sourceFile << std::endl, this->Quiet);
+ " produced b: " << sourceFile << std::endl,
+ this->Quiet);
*cont->OFS << " produced in binary dir: " << sourceFile
- << std::endl;
- actualSourceFile
- = cmSystemTools::CollapseFullPath(sourceFile);
- }
+ << std::endl;
+ actualSourceFile = cmSystemTools::CollapseFullPath(sourceFile);
+ }
- if ( actualSourceFile.empty() )
- {
- if ( missingFiles.find(sourceFile) == missingFiles.end() )
- {
+ if (actualSourceFile.empty()) {
+ if (missingFiles.find(sourceFile) == missingFiles.end()) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Something went wrong" << std::endl, this->Quiet);
+ "Something went wrong" << std::endl,
+ this->Quiet);
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Cannot find file: ["
- << sourceFile << "]" << std::endl, this->Quiet);
+ "Cannot find file: [" << sourceFile << "]"
+ << std::endl,
+ this->Quiet);
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " in source dir: ["
- << cont->SourceDir << "]"
- << std::endl, this->Quiet);
+ " in source dir: [" << cont->SourceDir << "]"
+ << std::endl,
+ this->Quiet);
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " or binary dir: ["
- << cont->BinaryDir.size() << "]"
- << std::endl, this->Quiet);
+ " or binary dir: [" << cont->BinaryDir.size()
+ << "]" << std::endl,
+ this->Quiet);
*cont->OFS << " Something went wrong. Cannot find file: "
- << sourceFile
- << " in source dir: " << cont->SourceDir
- << " or binary dir: " << cont->BinaryDir << std::endl;
+ << sourceFile << " in source dir: " << cont->SourceDir
+ << " or binary dir: " << cont->BinaryDir << std::endl;
missingFiles.insert(sourceFile);
- }
}
}
}
+ }
file_count++;
- if ( file_count % 50 == 0 )
- {
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " processed: "
- << file_count
- << " out of " << files.size() << std::endl, this->Quiet);
+ if (file_count % 50 == 0) {
+ cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+ " processed: " << file_count << " out of "
+ << files.size() << std::endl,
+ this->Quiet);
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " ", this->Quiet);
- }
}
+ }
cmSystemTools::ChangeDirectory(currentDirectory);
return file_count;
@@ -1476,46 +1317,44 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
int cmCTestCoverageHandler::HandleLCovCoverage(
cmCTestCoverageHandlerContainer* cont)
{
- std::string lcovCommand
- = this->CTest->GetCTestConfiguration("CoverageCommand");
- std::string lcovExtraFlags
- = this->CTest->GetCTestConfiguration("CoverageExtraFlags");
- if ( lcovCommand != "codecov" )
- {
+ std::string lcovCommand =
+ this->CTest->GetCTestConfiguration("CoverageCommand");
+ std::string lcovExtraFlags =
+ this->CTest->GetCTestConfiguration("CoverageExtraFlags");
+ if (lcovCommand != "codecov") {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " Not a valid Intel Coverage command."
- << std::endl, this->Quiet);
+ " Not a valid Intel Coverage command." << std::endl,
+ this->Quiet);
return 0;
- }
+ }
// There is only percentage completed output from LCOV
std::string st2lcovOutputRex3 = "[0-9]+%";
cmsys::RegularExpression st2re3(st2lcovOutputRex3.c_str());
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " This is coverage command: " << lcovCommand
- << std::endl, this->Quiet);
+ " This is coverage command: " << lcovCommand << std::endl,
+ this->Quiet);
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " These are coverage command flags: " << lcovExtraFlags
- << std::endl, this->Quiet);
+ " These are coverage command flags: " << lcovExtraFlags
+ << std::endl,
+ this->Quiet);
std::vector<std::string> files;
- if (!this->FindLCovFiles(files))
- {
+ if (!this->FindLCovFiles(files)) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Error while finding LCov files.\n");
return 0;
- }
+ }
std::vector<std::string>::iterator it;
- if (files.empty())
- {
+ if (files.empty()) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " Cannot find any LCov coverage files."
- << std::endl, this->Quiet);
+ " Cannot find any LCov coverage files." << std::endl,
+ this->Quiet);
// No coverage files is a valid thing, so the exit code is 0
return 0;
- }
+ }
std::string testingDir = this->CTest->GetBinaryDir();
std::string tempDir = testingDir;
std::string currentDirectory = cmSystemTools::GetCurrentWorkingDirectory();
@@ -1523,7 +1362,8 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
std::set<std::string> missingFiles;
std::string actualSourceFile = "";
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+ cmCTestOptionalLog(
+ this->CTest, HANDLER_OUTPUT,
" Processing coverage (each . represents one file):" << std::endl,
this->Quiet);
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " ", this->Quiet);
@@ -1535,67 +1375,65 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
// In intel compiler we have to call codecov only once in each executable
// directory. It collects all *.dyn files to generate .dpi file.
- for ( it = files.begin(); it != files.end(); ++ it )
- {
+ for (it = files.begin(); it != files.end(); ++it) {
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "." << std::flush,
- this->Quiet);
+ this->Quiet);
std::string fileDir = cmSystemTools::GetFilenamePath(*it);
cmSystemTools::ChangeDirectory(fileDir);
- std::string command = "\"" + lcovCommand + "\" " +
- lcovExtraFlags + " ";
+ std::string command = "\"" + lcovCommand + "\" " + lcovExtraFlags + " ";
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Current coverage dir: " << fileDir << std::endl, this->Quiet);
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, command.c_str()
- << std::endl, this->Quiet);
+ "Current coverage dir: " << fileDir << std::endl,
+ this->Quiet);
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ command.c_str() << std::endl, this->Quiet);
std::string output = "";
std::string errors = "";
int retVal = 0;
*cont->OFS << "* Run coverage for: " << fileDir << std::endl;
*cont->OFS << " Command: " << command << std::endl;
- int res = this->CTest->RunCommand(command.c_str(), &output, &errors,
- &retVal, fileDir.c_str(), 0 /*this->TimeOut*/);
+ int res =
+ this->CTest->RunCommand(command.c_str(), &output, &errors, &retVal,
+ fileDir.c_str(), 0 /*this->TimeOut*/);
*cont->OFS << " Output: " << output << std::endl;
*cont->OFS << " Errors: " << errors << std::endl;
- if ( ! res )
- {
+ if (!res) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Problem running coverage on file: " << *it << std::endl);
+ "Problem running coverage on file: " << *it << std::endl);
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Command produced error: " << errors << std::endl);
- cont->Error ++;
+ "Command produced error: " << errors << std::endl);
+ cont->Error++;
continue;
- }
- if ( retVal != 0 )
- {
+ }
+ if (retVal != 0) {
cmCTestLog(this->CTest, ERROR_MESSAGE, "Coverage command returned: "
- << retVal << " while processing: " << *it << std::endl);
+ << retVal << " while processing: " << *it << std::endl);
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Command produced error: " << cont->Error << std::endl);
- }
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Command produced error: " << cont->Error << std::endl);
+ }
+ cmCTestOptionalLog(
+ this->CTest, HANDLER_VERBOSE_OUTPUT,
"--------------------------------------------------------------"
- << std::endl
- << output << std::endl
- << "--------------------------------------------------------------"
- << std::endl, this->Quiet);
+ << std::endl
+ << output << std::endl
+ << "--------------------------------------------------------------"
+ << std::endl,
+ this->Quiet);
std::vector<std::string> lines;
std::vector<std::string>::iterator line;
cmSystemTools::Split(output.c_str(), lines);
- for ( line = lines.begin(); line != lines.end(); ++line)
- {
+ for (line = lines.begin(); line != lines.end(); ++line) {
std::string sourceFile;
std::string lcovFile;
- if (line->empty())
- {
+ if (line->empty()) {
// Ignore empty line
- }
+ }
// Look for LCOV files in binary directory
// Intel Compiler creates a CodeCoverage dir for each subfolder and
// each subfolder has LCOV files
@@ -1608,89 +1446,84 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
std::string daGlob;
daGlob = dir;
daGlob += "/*.LCOV";
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ cmCTestOptionalLog(
+ this->CTest, HANDLER_VERBOSE_OUTPUT,
" looking for LCOV files in: " << daGlob << std::endl, this->Quiet);
gl.FindFiles(daGlob);
// Keep a list of all LCOV files
lcovFiles.insert(lcovFiles.end(), gl.GetFiles().begin(),
gl.GetFiles().end());
- for(std::vector<std::string>::iterator a = lcovFiles.begin();
- a != lcovFiles.end(); ++a)
- {
+ for (std::vector<std::string>::iterator a = lcovFiles.begin();
+ a != lcovFiles.end(); ++a) {
lcovFile = *a;
cmsys::ifstream srcead(lcovFile.c_str());
- if ( ! srcead )
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open file: "
- << lcovFile << std::endl);
- }
+ if (!srcead) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Cannot open file: " << lcovFile << std::endl);
+ }
std::string srcname;
int success = cmSystemTools::GetLineFromStream(srcead, srcname);
- if ( !success )
- {
+ if (!success) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Error while parsing lcov file '" << lcovFile << "':"
- << " No source file name found!" << std::endl);
+ "Error while parsing lcov file '"
+ << lcovFile << "':"
+ << " No source file name found!" << std::endl);
return 0;
- }
+ }
srcname = srcname.substr(18);
// We can directly read found LCOV files to determine the source
// files
sourceFile = srcname;
actualSourceFile = srcname;
- for(std::vector<std::string>::iterator t = lcovFiles.begin();
- t != lcovFiles.end(); ++t)
- {
+ for (std::vector<std::string>::iterator t = lcovFiles.begin();
+ t != lcovFiles.end(); ++t) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Found LCOV File: " << *t << std::endl, this->Quiet);
- }
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "SourceFile: "
- << sourceFile << std::endl, this->Quiet);
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "lCovFile: "
- << lcovFile << std::endl, this->Quiet);
+ "Found LCOV File: " << *t << std::endl,
+ this->Quiet);
+ }
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "SourceFile: " << sourceFile << std::endl,
+ this->Quiet);
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "lCovFile: " << lcovFile << std::endl, this->Quiet);
// If we have some LCOV files to process
- if ( !lcovFile.empty() && !actualSourceFile.empty() )
- {
- cmCTestCoverageHandlerContainer::SingleFileCoverageVector& vec
- = cont->TotalCoverage[actualSourceFile];
+ if (!lcovFile.empty() && !actualSourceFile.empty()) {
+ cmCTestCoverageHandlerContainer::SingleFileCoverageVector& vec =
+ cont->TotalCoverage[actualSourceFile];
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " in lcovFile: " << lcovFile << std::endl, this->Quiet);
+ " in lcovFile: " << lcovFile << std::endl,
+ this->Quiet);
cmsys::ifstream ifile(lcovFile.c_str());
- if ( ! ifile )
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open file: "
- << lcovFile << std::endl);
- }
- else
- {
+ if (!ifile) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Cannot open file: " << lcovFile << std::endl);
+ } else {
long cnt = -1;
std::string nl;
// Skip the first line
cmSystemTools::GetLineFromStream(ifile, nl);
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "File is ready, start reading." << std::endl, this->Quiet);
- while ( cmSystemTools::GetLineFromStream(ifile, nl) )
- {
- cnt ++;
+ "File is ready, start reading." << std::endl,
+ this->Quiet);
+ while (cmSystemTools::GetLineFromStream(ifile, nl)) {
+ cnt++;
// Skip empty lines
- if (nl.empty())
- {
+ if (nl.empty()) {
continue;
- }
+ }
// Skip unused lines
- if ( nl.size() < 12 )
- {
+ if (nl.size() < 12) {
continue;
- }
+ }
// Read the coverage count from the beginning of the lcov
// output line
@@ -1701,44 +1534,40 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
// lcov output line
std::string lineNumber = nl.substr(17, 7);
- int lineIdx = atoi(lineNumber.c_str())-1;
- if ( lineIdx >= 0 )
- {
- while ( vec.size() <= static_cast<size_t>(lineIdx) )
- {
+ int lineIdx = atoi(lineNumber.c_str()) - 1;
+ if (lineIdx >= 0) {
+ while (vec.size() <= static_cast<size_t>(lineIdx)) {
vec.push_back(-1);
- }
+ }
// Initially all entries are -1 (not used). If we get coverage
// information, increment it to 0 first.
- if ( vec[lineIdx] < 0 )
- {
- if ( cov > 0 || prefix.find("#") != prefix.npos )
- {
+ if (vec[lineIdx] < 0) {
+ if (cov > 0 || prefix.find("#") != prefix.npos) {
vec[lineIdx] = 0;
- }
}
+ }
vec[lineIdx] += cov;
- }
}
}
+ }
actualSourceFile = "";
- }
}
}
+ }
file_count++;
- if ( file_count % 50 == 0 )
- {
+ if (file_count % 50 == 0) {
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " processed: " << file_count << " out of " << files.size()
- << std::endl, this->Quiet);
+ " processed: " << file_count << " out of "
+ << files.size() << std::endl,
+ this->Quiet);
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " ", this->Quiet);
- }
}
+ }
cmSystemTools::ChangeDirectory(currentDirectory);
return file_count;
@@ -1750,18 +1579,17 @@ void cmCTestCoverageHandler::FindGCovFiles(std::vector<std::string>& files)
gl.RecurseOn();
gl.RecurseThroughSymlinksOff();
- for(LabelMapType::const_iterator lmi = this->TargetDirs.begin();
- lmi != this->TargetDirs.end(); ++lmi)
- {
+ for (LabelMapType::const_iterator lmi = this->TargetDirs.begin();
+ lmi != this->TargetDirs.end(); ++lmi) {
// Skip targets containing no interesting labels.
- if(!this->IntersectsFilter(lmi->second))
- {
+ if (!this->IntersectsFilter(lmi->second)) {
continue;
- }
+ }
// Coverage files appear next to their object files in the target
// support directory.
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ cmCTestOptionalLog(
+ this->CTest, HANDLER_VERBOSE_OUTPUT,
" globbing for coverage in: " << lmi->first << std::endl, this->Quiet);
std::string daGlob = lmi->first;
daGlob += "/*.da";
@@ -1771,7 +1599,7 @@ void cmCTestCoverageHandler::FindGCovFiles(std::vector<std::string>& files)
daGlob += "/*.gcda";
gl.FindFiles(daGlob);
files.insert(files.end(), gl.GetFiles().begin(), gl.GetFiles().end());
- }
+ }
}
bool cmCTestCoverageHandler::FindLCovFiles(std::vector<std::string>& files)
@@ -1782,20 +1610,17 @@ bool cmCTestCoverageHandler::FindLCovFiles(std::vector<std::string>& files)
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);
+ if (cmSystemTools::ChangeDirectory(buildDir)) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "Error changing directory to "
+ << buildDir << std::endl);
return false;
- }
+ }
// Run profmerge to merge all *.dyn files into dpi files
- if (!cmSystemTools::RunSingleCommand("profmerge"))
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Error while running profmerge.\n");
+ if (!cmSystemTools::RunSingleCommand("profmerge")) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "Error while running profmerge.\n");
return false;
- }
+ }
prevBinaryDir = cmSystemTools::GetCurrentWorkingDirectory().c_str();
@@ -1804,16 +1629,16 @@ bool cmCTestCoverageHandler::FindLCovFiles(std::vector<std::string>& files)
daGlob = prevBinaryDir;
daGlob += "/*.dpi";
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " looking for dpi files in: " << daGlob << std::endl, this->Quiet);
- if (!gl.FindFiles(daGlob))
- {
+ " looking for dpi files in: " << daGlob << std::endl,
+ this->Quiet);
+ if (!gl.FindFiles(daGlob)) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Error while finding files matching " << daGlob << std::endl);
return false;
- }
+ }
files.insert(files.end(), gl.GetFiles().begin(), gl.GetFiles().end());
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Now searching in: " << daGlob << std::endl, this->Quiet);
+ "Now searching in: " << daGlob << std::endl, this->Quiet);
return true;
}
@@ -1827,14 +1652,14 @@ int cmCTestCoverageHandler::HandleTracePyCoverage(
gl.FindFiles(daGlob);
std::vector<std::string> files = gl.GetFiles();
- if (files.empty())
- {
+ if (files.empty()) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " Cannot find any Python Trace.py coverage files."
- << std::endl, this->Quiet);
+ " Cannot find any Python Trace.py coverage files."
+ << std::endl,
+ this->Quiet);
// No coverage files is a valid thing, so the exit code is 0
return 0;
- }
+ }
std::string testingDir = this->CTest->GetBinaryDir() + "/Testing";
std::string tempDir = testingDir + "/CoverageInfo";
@@ -1846,319 +1671,276 @@ int cmCTestCoverageHandler::HandleTracePyCoverage(
std::vector<std::string>::iterator fileIt;
int file_count = 0;
- for ( fileIt = files.begin(); fileIt != files.end(); ++ fileIt )
- {
+ for (fileIt = files.begin(); fileIt != files.end(); ++fileIt) {
std::string fileName = this->FindFile(cont, *fileIt);
- if ( fileName.empty() )
- {
+ if (fileName.empty()) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Cannot find source Python file corresponding to: "
- << *fileIt << std::endl);
+ "Cannot find source Python file corresponding to: "
+ << *fileIt << std::endl);
continue;
- }
+ }
- std::string actualSourceFile
- = cmSystemTools::CollapseFullPath(fileName);
+ std::string actualSourceFile = cmSystemTools::CollapseFullPath(fileName);
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " Check coverage for file: " << actualSourceFile
- << std::endl, this->Quiet);
- cmCTestCoverageHandlerContainer::SingleFileCoverageVector* vec
- = &cont->TotalCoverage[actualSourceFile];
+ " Check coverage for file: " << actualSourceFile
+ << std::endl,
+ this->Quiet);
+ cmCTestCoverageHandlerContainer::SingleFileCoverageVector* vec =
+ &cont->TotalCoverage[actualSourceFile];
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " in file: " << *fileIt << std::endl, this->Quiet);
+ " in file: " << *fileIt << std::endl, this->Quiet);
cmsys::ifstream ifile(fileIt->c_str());
- if ( ! ifile )
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open file: "
- << *fileIt << std::endl);
- }
- else
- {
+ if (!ifile) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Cannot open file: " << *fileIt << std::endl);
+ } else {
long cnt = -1;
std::string nl;
- while ( cmSystemTools::GetLineFromStream(ifile, nl) )
- {
- cnt ++;
+ while (cmSystemTools::GetLineFromStream(ifile, nl)) {
+ cnt++;
// Skip empty lines
- if (nl.empty())
- {
+ if (nl.empty()) {
continue;
- }
+ }
// Skip unused lines
- if ( nl.size() < 12 )
- {
+ if (nl.size() < 12) {
continue;
- }
+ }
// Read the coverage count from the beginning of the Trace.py output
// line
std::string prefix = nl.substr(0, 6);
- if ( prefix[5] != ' ' && prefix[5] != ':' )
- {
+ if (prefix[5] != ' ' && prefix[5] != ':') {
// This is a hack. We should really do something more elaborate
prefix = nl.substr(0, 7);
- if ( prefix[6] != ' ' && prefix[6] != ':' )
- {
+ if (prefix[6] != ' ' && prefix[6] != ':') {
prefix = nl.substr(0, 8);
- if ( prefix[7] != ' ' && prefix[7] != ':' )
- {
+ if (prefix[7] != ' ' && prefix[7] != ':') {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Currently the limit is maximum coverage of 999999"
- << std::endl);
- }
+ "Currently the limit is maximum coverage of 999999"
+ << std::endl);
}
}
+ }
int cov = atoi(prefix.c_str());
- if ( prefix[prefix.size()-1] != ':' )
- {
+ if (prefix[prefix.size() - 1] != ':') {
// This line does not have ':' so no coverage here. That said,
// Trace.py does not handle not covered lines versus comments etc.
// So, this will be set to 0.
cov = 0;
- }
- cmCTestOptionalLog(this->CTest, DEBUG, "Prefix: " << prefix
- << " cov: " << cov
- << std::endl, this->Quiet);
+ }
+ cmCTestOptionalLog(
+ this->CTest, DEBUG,
+ "Prefix: " << prefix << " cov: " << cov << std::endl, this->Quiet);
// Read the line number starting at the 10th character of the gcov
// output line
long lineIdx = cnt;
- if ( lineIdx >= 0 )
- {
- while ( vec->size() <=
- static_cast<size_t>(lineIdx) )
- {
+ if (lineIdx >= 0) {
+ while (vec->size() <= static_cast<size_t>(lineIdx)) {
vec->push_back(-1);
- }
+ }
// Initially all entries are -1 (not used). If we get coverage
// information, increment it to 0 first.
- if ( (*vec)[lineIdx] < 0 )
- {
- if ( cov >= 0 )
- {
+ if ((*vec)[lineIdx] < 0) {
+ if (cov >= 0) {
(*vec)[lineIdx] = 0;
- }
}
- (*vec)[lineIdx] += cov;
}
+ (*vec)[lineIdx] += cov;
}
}
- ++ file_count;
}
+ ++file_count;
+ }
cmSystemTools::ChangeDirectory(currentDirectory);
return file_count;
}
std::string cmCTestCoverageHandler::FindFile(
- cmCTestCoverageHandlerContainer* cont,
- std::string fileName)
+ cmCTestCoverageHandlerContainer* cont, std::string fileName)
{
- std::string fileNameNoE
- = cmSystemTools::GetFilenameWithoutLastExtension(fileName);
+ std::string fileNameNoE =
+ cmSystemTools::GetFilenameWithoutLastExtension(fileName);
// First check in source and binary directory
std::string fullName = cont->SourceDir + "/" + fileNameNoE + ".py";
- if ( cmSystemTools::FileExists(fullName.c_str()) )
- {
+ if (cmSystemTools::FileExists(fullName.c_str())) {
return fullName;
- }
+ }
fullName = cont->BinaryDir + "/" + fileNameNoE + ".py";
- if ( cmSystemTools::FileExists(fullName.c_str()) )
- {
+ if (cmSystemTools::FileExists(fullName.c_str())) {
return fullName;
- }
+ }
return "";
}
// This is a header put on each marked up source file
-namespace
-{
- const char* bullseyeHelp[] =
- {" Coverage produced by bullseye covbr tool: ",
- " www.bullseye.com/help/ref_covbr.html",
- " * An arrow --> indicates incomplete coverage.",
- " * An X indicates a function that was invoked, a switch label that ",
- " was exercised, a try-block that finished, or an exception handler ",
- " that was invoked.",
- " * A T or F indicates a boolean decision that evaluated true or false,",
- " respectively.",
- " * A t or f indicates a boolean condition within a decision if the ",
- " condition evaluated true or false, respectively.",
- " * A k indicates a constant decision or condition.",
- " * The slash / means this probe is excluded from summary results. ",
- 0};
+namespace {
+const char* bullseyeHelp[] = {
+ " Coverage produced by bullseye covbr tool: ",
+ " www.bullseye.com/help/ref_covbr.html",
+ " * An arrow --> indicates incomplete coverage.",
+ " * An X indicates a function that was invoked, a switch label that ",
+ " was exercised, a try-block that finished, or an exception handler ",
+ " that was invoked.",
+ " * A T or F indicates a boolean decision that evaluated true or false,",
+ " respectively.",
+ " * A t or f indicates a boolean condition within a decision if the ",
+ " condition evaluated true or false, respectively.",
+ " * A k indicates a constant decision or condition.",
+ " * The slash / means this probe is excluded from summary results. ",
+ 0
+};
}
int cmCTestCoverageHandler::RunBullseyeCoverageBranch(
cmCTestCoverageHandlerContainer* cont,
- std::set<std::string>& coveredFileNames,
- std::vector<std::string>& files,
+ std::set<std::string>& coveredFileNames, std::vector<std::string>& files,
std::vector<std::string>& filesFullPath)
{
- if(files.size() != filesFullPath.size())
- {
+ if (files.size() != filesFullPath.size()) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Files and full path files not the same size?:\n");
return 0;
- }
+ }
// create the output stream for the CoverageLog-N.xml file
cmGeneratedFileStream covLogFile;
cmXMLWriter covLogXML(covLogFile);
int logFileCount = 0;
- if ( !this->StartCoverageLogFile(covLogFile, logFileCount) )
- {
+ if (!this->StartCoverageLogFile(covLogFile, logFileCount)) {
return -1;
- }
+ }
this->StartCoverageLogXML(covLogXML);
// for each file run covbr on that file to get the coverage
// information for that file
std::string outputFile;
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "run covbr: " << std::endl, this->Quiet);
+ "run covbr: " << std::endl, this->Quiet);
- if(!this->RunBullseyeCommand(cont, "covbr", 0, outputFile))
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "error running covbr for." << "\n");
+ if (!this->RunBullseyeCommand(cont, "covbr", 0, outputFile)) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "error running covbr for."
+ << "\n");
return -1;
- }
+ }
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "covbr output in " << outputFile << std::endl, this->Quiet);
+ "covbr output in " << outputFile << std::endl,
+ this->Quiet);
// open the output file
cmsys::ifstream fin(outputFile.c_str());
- if(!fin)
- {
+ if (!fin) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Cannot open coverage file: " <<
- outputFile << std::endl);
+ "Cannot open coverage file: " << outputFile << std::endl);
return 0;
- }
+ }
std::map<std::string, std::string> fileMap;
std::vector<std::string>::iterator fp = filesFullPath.begin();
- for(std::vector<std::string>::iterator f = files.begin();
- f != files.end(); ++f, ++fp)
- {
+ for (std::vector<std::string>::iterator f = files.begin(); f != files.end();
+ ++f, ++fp) {
fileMap[*f] = *fp;
- }
+ }
- int count =0; // keep count of the number of files
+ int count = 0; // keep count of the number of files
// Now parse each line from the bullseye cov log file
std::string lineIn;
bool valid = false; // are we in a valid output file
- int line = 0; // line of the current file
+ int line = 0; // line of the current file
std::string file;
- while(cmSystemTools::GetLineFromStream(fin, lineIn))
- {
+ while (cmSystemTools::GetLineFromStream(fin, lineIn)) {
bool startFile = false;
- if(lineIn.size() > 1 && lineIn[lineIn.size()-1] == ':')
- {
- file = lineIn.substr(0, lineIn.size()-1);
- if(coveredFileNames.find(file) != coveredFileNames.end())
- {
+ if (lineIn.size() > 1 && lineIn[lineIn.size() - 1] == ':') {
+ file = lineIn.substr(0, lineIn.size() - 1);
+ if (coveredFileNames.find(file) != coveredFileNames.end()) {
startFile = true;
- }
}
- if(startFile)
- {
+ }
+ if (startFile) {
// if we are in a valid file close it because a new one started
- if(valid)
- {
+ if (valid) {
covLogXML.EndElement(); // Report
covLogXML.EndElement(); // File
- }
+ }
// only allow 100 files in each log file
- if ( count != 0 && count % 100 == 0 )
- {
+ if (count != 0 && count % 100 == 0) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "start a new log file: " << count << std::endl, this->Quiet);
+ "start a new log file: " << count << std::endl,
+ this->Quiet);
this->EndCoverageLogXML(covLogXML);
this->EndCoverageLogFile(covLogFile, logFileCount);
- logFileCount ++;
- if ( !this->StartCoverageLogFile(covLogFile, logFileCount) )
- {
+ logFileCount++;
+ if (!this->StartCoverageLogFile(covLogFile, logFileCount)) {
return -1;
- }
+ }
this->StartCoverageLogXML(covLogXML);
count++; // move on one
- }
- std::map<std::string, std::string>::iterator
- i = fileMap.find(file);
+ }
+ std::map<std::string, std::string>::iterator i = fileMap.find(file);
// if the file should be covered write out the header for that file
- if(i != fileMap.end())
- {
+ if (i != fileMap.end()) {
// we have a new file so count it in the output
count++;
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Produce coverage for file: " << file << " " << count
- << std::endl, this->Quiet);
+ "Produce coverage for file: " << file << " "
+ << count << std::endl,
+ this->Quiet);
// start the file output
covLogXML.StartElement("File");
covLogXML.Attribute("Name", i->first);
- covLogXML.Attribute("FullPath",
- this->CTest->GetShortPathToFile(i->second.c_str()));
+ covLogXML.Attribute(
+ "FullPath", this->CTest->GetShortPathToFile(i->second.c_str()));
covLogXML.StartElement("Report");
// write the bullseye header
- line =0;
- for(int k =0; bullseyeHelp[k] != 0; ++k)
- {
+ line = 0;
+ for (int k = 0; bullseyeHelp[k] != 0; ++k) {
covLogXML.StartElement("Line");
covLogXML.Attribute("Number", line);
covLogXML.Attribute("Count", -1);
covLogXML.Content(bullseyeHelp[k]);
covLogXML.EndElement(); // Line
line++;
- }
- valid = true; // we are in a valid file section
}
- else
- {
+ valid = true; // we are in a valid file section
+ } else {
// this is not a file that we want coverage for
valid = false;
- }
}
+ }
// we are not at a start file, and we are in a valid file output the line
- else if(valid)
- {
+ else if (valid) {
covLogXML.StartElement("Line");
covLogXML.Attribute("Number", line);
covLogXML.Attribute("Count", -1);
covLogXML.Content(lineIn);
covLogXML.EndElement(); // Line
line++;
- }
}
+ }
// if we ran out of lines a valid file then close that file
- if(valid)
- {
+ if (valid) {
covLogXML.EndElement(); // Report
covLogXML.EndElement(); // File
- }
+ }
this->EndCoverageLogXML(covLogXML);
this->EndCoverageLogFile(covLogFile, logFileCount);
return 1;
}
int cmCTestCoverageHandler::RunBullseyeCommand(
- cmCTestCoverageHandlerContainer* cont,
- const char* cmd,
- const char* arg,
+ cmCTestCoverageHandlerContainer* cont, const char* cmd, const char* arg,
std::string& outputFile)
{
std::string program = cmSystemTools::FindProgram(cmd);
- if(program.empty())
- {
+ if (program.empty()) {
cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot find :" << cmd << "\n");
return 0;
- }
- if(arg)
- {
+ }
+ if (arg) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Run : " << program << " " << arg << "\n", this->Quiet);
- }
- else
- {
+ "Run : " << program << " " << arg << "\n", this->Quiet);
+ } else {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Run : " << program << "\n", this->Quiet);
- }
+ "Run : " << program << "\n", this->Quiet);
+ }
// create a process object and start it
cmCTestRunProcess runCoverageSrc;
runCoverageSrc.SetCommand(program.c_str());
@@ -2172,14 +1954,13 @@ int cmCTestCoverageHandler::RunBullseyeCommand(
stderrFile += ".stderr";
runCoverageSrc.SetStdoutFile(stdoutFile.c_str());
runCoverageSrc.SetStderrFile(stderrFile.c_str());
- if(!runCoverageSrc.StartProcess())
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Could not run : "
- << program << " " << arg << "\n"
- << "kwsys process state : "
- << runCoverageSrc.GetProcessState());
+ if (!runCoverageSrc.StartProcess()) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Could not run : " << program << " " << arg << "\n"
+ << "kwsys process state : "
+ << runCoverageSrc.GetProcessState());
return 0;
- }
+ }
// since we set the output file names wait for it to end
runCoverageSrc.WaitForExit();
outputFile = stdoutFile;
@@ -2191,29 +1972,28 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary(
{
// Run the covsrc command and create a temp outputfile
std::string outputFile;
- if(!this->RunBullseyeCommand(cont, "covsrc", "-c", outputFile))
- {
+ if (!this->RunBullseyeCommand(cont, "covsrc", "-c", outputFile)) {
cmCTestLog(this->CTest, ERROR_MESSAGE, "error running covsrc:\n");
return 0;
- }
+ }
std::ostream& tmpLog = *cont->OFS;
// copen the Coverage.xml file in the Testing directory
cmGeneratedFileStream covSumFile;
cmXMLWriter xml(covSumFile);
- if(!this->StartResultingXML(cmCTest::PartCoverage, "Coverage", covSumFile))
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Cannot open coverage summary file." << std::endl);
+ if (!this->StartResultingXML(cmCTest::PartCoverage, "Coverage",
+ covSumFile)) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open coverage summary file."
+ << std::endl);
return 0;
- }
+ }
this->CTest->StartXML(xml, this->AppendXML);
double elapsed_time_start = cmSystemTools::GetTime();
std::string coverage_start_time = this->CTest->CurrentTime();
xml.StartElement("Coverage");
xml.Element("StartDateTime", coverage_start_time);
xml.Element("StartTime",
- static_cast<unsigned int>(cmSystemTools::GetTime()));
+ static_cast<unsigned int>(cmSystemTools::GetTime()));
std::string stdline;
std::string errline;
// expected output:
@@ -2230,66 +2010,53 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary(
double total_tested = 0;
double total_untested = 0;
double total_functions = 0;
- double percent_coverage =0;
- double number_files = 0;
+ double percent_coverage = 0;
+ double number_files = 0;
std::vector<std::string> coveredFiles;
std::vector<std::string> coveredFilesFullPath;
// Read and parse the summary output file
cmsys::ifstream fin(outputFile.c_str());
- if(!fin)
- {
+ if (!fin) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Cannot open coverage summary file: " <<
- outputFile << std::endl);
+ "Cannot open coverage summary file: " << outputFile
+ << std::endl);
return 0;
- }
+ }
std::set<std::string> coveredFileNames;
- while(cmSystemTools::GetLineFromStream(fin, stdline))
- {
+ while (cmSystemTools::GetLineFromStream(fin, stdline)) {
// if we have a line of output from stdout
- if(!stdline.empty())
- {
+ if (!stdline.empty()) {
// parse the comma separated output
- this->ParseBullsEyeCovsrcLine(stdline,
- sourceFile,
- functionsCalled,
- totalFunctions,
- percentFunction,
- branchCovered,
- totalBranches,
- percentBranch);
+ this->ParseBullsEyeCovsrcLine(
+ stdline, sourceFile, functionsCalled, totalFunctions, percentFunction,
+ branchCovered, totalBranches, percentBranch);
// The first line is the header
- if(sourceFile == "Source" || sourceFile == "Total")
- {
+ if (sourceFile == "Source" || sourceFile == "Total") {
continue;
- }
+ }
std::string file = sourceFile;
coveredFileNames.insert(file);
- if(!cmSystemTools::FileIsFullPath(sourceFile.c_str()))
- {
+ if (!cmSystemTools::FileIsFullPath(sourceFile.c_str())) {
// file will be relative to the binary dir
file = cont->BinaryDir;
file += "/";
file += sourceFile;
- }
+ }
file = cmSystemTools::CollapseFullPath(file);
- bool shouldIDoCoverage
- = this->ShouldIDoCoverage(file.c_str(),
- cont->SourceDir.c_str(),
- cont->BinaryDir.c_str());
- if ( !shouldIDoCoverage )
- {
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- ".NoDartCoverage found, so skip coverage check for: "
- << file
- << std::endl, this->Quiet);
+ bool shouldIDoCoverage = this->ShouldIDoCoverage(
+ file.c_str(), cont->SourceDir.c_str(), cont->BinaryDir.c_str());
+ if (!shouldIDoCoverage) {
+ cmCTestOptionalLog(
+ this->CTest, HANDLER_VERBOSE_OUTPUT,
+ ".NoDartCoverage found, so skip coverage check for: " << file
+ << std::endl,
+ this->Quiet);
continue;
- }
+ }
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Doing coverage for: "
- << file
- << std::endl, this->Quiet);
+ "Doing coverage for: " << file << std::endl,
+ this->Quiet);
coveredFiles.push_back(sourceFile);
coveredFilesFullPath.push_back(file);
@@ -2304,21 +2071,19 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary(
this->CTest->GetShortPathToFile(file.c_str());
float cper = static_cast<float>(percentBranch + percentFunction);
- if(totalBranches > 0)
- {
+ if (totalBranches > 0) {
cper /= 2.0f;
- }
+ }
percent_coverage += static_cast<double>(cper);
float cmet = static_cast<float>(percentFunction + percentBranch);
- if(totalBranches > 0)
- {
+ if (totalBranches > 0) {
cmet /= 2.0f;
- }
+ }
cmet /= 100.0f;
tmpLog << stdline << "\n";
tmpLog << fileName << "\n";
- tmpLog << "functionsCalled: " << functionsCalled/100 << "\n";
- tmpLog << "totalFunctions: " << totalFunctions/100 << "\n";
+ tmpLog << "functionsCalled: " << functionsCalled / 100 << "\n";
+ tmpLog << "totalFunctions: " << totalFunctions / 100 << "\n";
tmpLog << "percentFunction: " << percentFunction << "\n";
tmpLog << "branchCovered: " << branchCovered << "\n";
tmpLog << "totalBranches: " << totalBranches << "\n";
@@ -2341,8 +2106,8 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary(
xml.Element("CoverageMetric", cmet);
this->WriteXMLLabels(xml, shortFileName);
xml.EndElement(); // File
- }
}
+ }
std::string end_time = this->CTest->CurrentTime();
xml.Element("LOCTested", total_tested);
xml.Element("LOCUntested", total_untested);
@@ -2350,15 +2115,15 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary(
xml.Element("PercentCoverage", SAFEDIV(percent_coverage, number_files));
xml.Element("EndDateTime", end_time);
xml.Element("EndTime", static_cast<unsigned int>(cmSystemTools::GetTime()));
- xml.Element("ElapsedMinutes",
- static_cast<int>((cmSystemTools::GetTime() - elapsed_time_start)/6)/10.0);
+ xml.Element(
+ "ElapsedMinutes",
+ static_cast<int>((cmSystemTools::GetTime() - elapsed_time_start) / 6) /
+ 10.0);
xml.EndElement(); // Coverage
this->CTest->EndXML(xml);
// Now create the coverage information for each file
- return this->RunBullseyeCoverageBranch(cont,
- coveredFileNames,
- coveredFiles,
+ return this->RunBullseyeCoverageBranch(cont, coveredFileNames, coveredFiles,
coveredFilesFullPath);
}
@@ -2366,25 +2131,24 @@ int cmCTestCoverageHandler::HandleBullseyeCoverage(
cmCTestCoverageHandlerContainer* cont)
{
const char* covfile = cmSystemTools::GetEnv("COVFILE");
- if(!covfile || strlen(covfile) == 0)
- {
+ if (!covfile || strlen(covfile) == 0) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " COVFILE environment variable not found, not running "
- " bullseye\n", this->Quiet);
+ " COVFILE environment variable not found, not running "
+ " bullseye\n",
+ this->Quiet);
return 0;
- }
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " run covsrc with COVFILE=["
- << covfile
- << "]" << std::endl, this->Quiet);
- if(!this->RunBullseyeSourceSummary(cont))
- {
+ }
+ cmCTestOptionalLog(
+ this->CTest, HANDLER_VERBOSE_OUTPUT,
+ " run covsrc with COVFILE=[" << covfile << "]" << std::endl, this->Quiet);
+ if (!this->RunBullseyeSourceSummary(cont)) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Error running bullseye summary.\n");
return 0;
- }
- cmCTestOptionalLog(this->CTest, DEBUG, "HandleBullseyeCoverage return 1 "
- << std::endl, this->Quiet);
+ }
+ cmCTestOptionalLog(this->CTest, DEBUG,
+ "HandleBullseyeCoverage return 1 " << std::endl,
+ this->Quiet);
return 1;
}
@@ -2395,79 +2159,63 @@ bool cmCTestCoverageHandler::GetNextInt(std::string const& inputLine,
std::string::size_type start = pos;
pos = inputLine.find(',', start);
value = atoi(inputLine.substr(start, pos).c_str());
- if(pos == inputLine.npos)
- {
+ if (pos == inputLine.npos) {
return true;
- }
+ }
pos++;
return true;
}
bool cmCTestCoverageHandler::ParseBullsEyeCovsrcLine(
- std::string const& inputLine,
- std::string& sourceFile,
- int& functionsCalled,
- int& totalFunctions,
- int& percentFunction,
- int& branchCovered,
- int& totalBranches,
- int& percentBranch)
+ std::string const& inputLine, std::string& sourceFile, int& functionsCalled,
+ int& totalFunctions, int& percentFunction, int& branchCovered,
+ int& totalBranches, int& percentBranch)
{
// find the first comma
std::string::size_type pos = inputLine.find(',');
- if(pos == inputLine.npos)
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Error parsing string : "
- << inputLine << "\n");
+ if (pos == inputLine.npos) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Error parsing string : " << inputLine << "\n");
return false;
- }
+ }
// the source file has "" around it so extract out the file name
- sourceFile = inputLine.substr(1,pos-2);
+ sourceFile = inputLine.substr(1, pos - 2);
pos++;
- if(!this->GetNextInt(inputLine, pos, functionsCalled))
- {
+ if (!this->GetNextInt(inputLine, pos, functionsCalled)) {
return false;
- }
- if(!this->GetNextInt(inputLine, pos, totalFunctions))
- {
+ }
+ if (!this->GetNextInt(inputLine, pos, totalFunctions)) {
return false;
- }
- if(!this->GetNextInt(inputLine, pos, percentFunction))
- {
+ }
+ if (!this->GetNextInt(inputLine, pos, percentFunction)) {
return false;
- }
- if(!this->GetNextInt(inputLine, pos, branchCovered))
- {
+ }
+ if (!this->GetNextInt(inputLine, pos, branchCovered)) {
return false;
- }
- if(!this->GetNextInt(inputLine, pos, totalBranches))
- {
+ }
+ if (!this->GetNextInt(inputLine, pos, totalBranches)) {
return false;
- }
- if(!this->GetNextInt(inputLine, pos, percentBranch))
- {
+ }
+ if (!this->GetNextInt(inputLine, pos, percentBranch)) {
return false;
- }
+ }
// should be at the end now
- if(pos != inputLine.npos)
- {
+ if (pos != inputLine.npos) {
cmCTestLog(this->CTest, ERROR_MESSAGE, "Error parsing input : "
- << inputLine << " last pos not npos = " << pos <<
- "\n");
- }
+ << inputLine << " last pos not npos = " << pos << "\n");
+ }
return true;
}
int cmCTestCoverageHandler::GetLabelId(std::string const& label)
{
LabelIdMapType::iterator i = this->LabelIdMap.find(label);
- if(i == this->LabelIdMap.end())
- {
+ if (i == this->LabelIdMap.end()) {
int n = int(this->Labels.size());
this->Labels.push_back(label);
LabelIdMapType::value_type entry(label, n);
i = this->LabelIdMap.insert(entry).first;
- }
+ }
return i->second;
}
@@ -2477,13 +2225,13 @@ void cmCTestCoverageHandler::LoadLabels()
fileList += cmake::GetCMakeFilesDirectory();
fileList += "/TargetDirectories.txt";
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " target directory list [" << fileList << "]\n", this->Quiet);
+ " target directory list [" << fileList << "]\n",
+ this->Quiet);
cmsys::ifstream finList(fileList.c_str());
std::string line;
- while(cmSystemTools::GetLineFromStream(finList, line))
- {
+ while (cmSystemTools::GetLineFromStream(finList, line)) {
this->LoadLabels(line.c_str());
- }
+ }
}
void cmCTestCoverageHandler::LoadLabels(const char* dir)
@@ -2492,41 +2240,31 @@ void cmCTestCoverageHandler::LoadLabels(const char* dir)
std::string fname = dir;
fname += "/Labels.txt";
cmsys::ifstream fin(fname.c_str());
- if(!fin)
- {
+ if (!fin) {
return;
- }
+ }
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " loading labels from [" << fname << "]\n", this->Quiet);
+ " loading labels from [" << fname << "]\n", this->Quiet);
bool inTarget = true;
std::string source;
std::string line;
std::vector<int> targetLabels;
- while(cmSystemTools::GetLineFromStream(fin, line))
- {
- if(line.empty() || line[0] == '#')
- {
+ while (cmSystemTools::GetLineFromStream(fin, line)) {
+ if (line.empty() || line[0] == '#') {
// Ignore blank and comment lines.
continue;
- }
- else if(line[0] == ' ')
- {
+ } else if (line[0] == ' ') {
// Label lines appear indented by one space.
std::string label = line.substr(1);
int id = this->GetLabelId(label);
dirLabels.insert(id);
- if(inTarget)
- {
+ if (inTarget) {
targetLabels.push_back(id);
- }
- else
- {
+ } else {
this->SourceLabels[source].insert(id);
- }
}
- else
- {
+ } else {
// Non-indented lines specify a source file name. The first one
// is the end of the target-wide labels.
inTarget = false;
@@ -2536,69 +2274,62 @@ void cmCTestCoverageHandler::LoadLabels(const char* dir)
// Label the source with the target labels.
LabelSet& labelSet = this->SourceLabels[source];
labelSet.insert(targetLabels.begin(), targetLabels.end());
- }
}
+ }
}
void cmCTestCoverageHandler::WriteXMLLabels(cmXMLWriter& xml,
std::string const& source)
{
LabelMapType::const_iterator li = this->SourceLabels.find(source);
- if(li != this->SourceLabels.end() && !li->second.empty())
- {
+ if (li != this->SourceLabels.end() && !li->second.empty()) {
xml.StartElement("Labels");
- for(LabelSet::const_iterator lsi = li->second.begin();
- lsi != li->second.end(); ++lsi)
- {
+ for (LabelSet::const_iterator lsi = li->second.begin();
+ lsi != li->second.end(); ++lsi) {
xml.Element("Label", this->Labels[*lsi]);
- }
- xml.EndElement(); // Labels
}
+ xml.EndElement(); // Labels
+ }
}
-void
-cmCTestCoverageHandler::SetLabelFilter(std::set<std::string> const& labels)
+void cmCTestCoverageHandler::SetLabelFilter(
+ std::set<std::string> const& labels)
{
this->LabelFilter.clear();
- for(std::set<std::string>::const_iterator li = labels.begin();
- li != labels.end(); ++li)
- {
+ for (std::set<std::string>::const_iterator li = labels.begin();
+ li != labels.end(); ++li) {
this->LabelFilter.insert(this->GetLabelId(*li));
- }
+ }
}
bool cmCTestCoverageHandler::IntersectsFilter(LabelSet const& labels)
{
// If there is no label filter then nothing is filtered out.
- if(this->LabelFilter.empty())
- {
+ if (this->LabelFilter.empty()) {
return true;
- }
+ }
std::vector<int> ids;
- std::set_intersection
- (labels.begin(), labels.end(),
- this->LabelFilter.begin(), this->LabelFilter.end(),
- std::back_inserter(ids));
+ std::set_intersection(labels.begin(), labels.end(),
+ this->LabelFilter.begin(), this->LabelFilter.end(),
+ std::back_inserter(ids));
return !ids.empty();
}
bool cmCTestCoverageHandler::IsFilteredOut(std::string const& source)
{
// If there is no label filter then nothing is filtered out.
- if(this->LabelFilter.empty())
- {
+ if (this->LabelFilter.empty()) {
return false;
- }
+ }
// The source is filtered out if it does not have any labels in
// common with the filter set.
std::string shortSrc = this->CTest->GetShortPathToFile(source.c_str());
LabelMapType::const_iterator li = this->SourceLabels.find(shortSrc);
- if(li != this->SourceLabels.end())
- {
+ if (li != this->SourceLabels.end()) {
return !this->IntersectsFilter(li->second);
- }
+ }
return true;
}
@@ -2607,36 +2338,31 @@ std::set<std::string> cmCTestCoverageHandler::FindUncoveredFiles(
{
std::set<std::string> extraMatches;
- for(std::vector<std::string>::iterator i = this->ExtraCoverageGlobs.begin();
- i != this->ExtraCoverageGlobs.end(); ++i)
- {
+ for (std::vector<std::string>::iterator i = this->ExtraCoverageGlobs.begin();
+ i != this->ExtraCoverageGlobs.end(); ++i) {
cmsys::Glob gl;
gl.RecurseOn();
gl.RecurseThroughSymlinksOff();
std::string glob = cont->SourceDir + "/" + *i;
gl.FindFiles(glob);
std::vector<std::string> files = gl.GetFiles();
- for(std::vector<std::string>::iterator f = files.begin();
- f != files.end(); ++f)
- {
- if(this->ShouldIDoCoverage(f->c_str(),
- cont->SourceDir.c_str(), cont->BinaryDir.c_str()))
- {
- extraMatches.insert(this->CTest->GetShortPathToFile(
- f->c_str()));
- }
+ for (std::vector<std::string>::iterator f = files.begin();
+ f != files.end(); ++f) {
+ if (this->ShouldIDoCoverage(f->c_str(), cont->SourceDir.c_str(),
+ cont->BinaryDir.c_str())) {
+ extraMatches.insert(this->CTest->GetShortPathToFile(f->c_str()));
}
}
+ }
- if(!extraMatches.empty())
- {
- for(cmCTestCoverageHandlerContainer::TotalCoverageMap::iterator i =
- cont->TotalCoverage.begin(); i != cont->TotalCoverage.end(); ++i)
- {
- std::string shortPath = this->CTest->GetShortPathToFile(
- i->first.c_str());
+ if (!extraMatches.empty()) {
+ for (cmCTestCoverageHandlerContainer::TotalCoverageMap::iterator i =
+ cont->TotalCoverage.begin();
+ i != cont->TotalCoverage.end(); ++i) {
+ std::string shortPath =
+ this->CTest->GetShortPathToFile(i->first.c_str());
extraMatches.erase(shortPath);
- }
}
+ }
return extraMatches;
}
diff --git a/Source/CTest/cmCTestCoverageHandler.h b/Source/CTest/cmCTestCoverageHandler.h
index c91a2d7..4a2a602 100644
--- a/Source/CTest/cmCTestCoverageHandler.h
+++ b/Source/CTest/cmCTestCoverageHandler.h
@@ -54,14 +54,14 @@ public:
/**
* This method is called when reading CTest custom file
*/
- void PopulateCustomVectors(cmMakefile *mf);
+ void PopulateCustomVectors(cmMakefile* mf);
/** Report coverage only for sources with these labels. */
void SetLabelFilter(std::set<std::string> const& labels);
private:
bool ShouldIDoCoverage(const char* file, const char* srcDir,
- const char* binDir);
+ const char* binDir);
void CleanCoverageLogFiles(std::ostream& log);
bool StartCoverageLogFile(cmGeneratedFileStream& ostr, int logFileCount);
void EndCoverageLogFile(cmGeneratedFileStream& ostr, int logFileCount);
@@ -95,7 +95,7 @@ private:
//! Handle coverage for Jacoco
int HandleBlanketJSCoverage(cmCTestCoverageHandlerContainer* cont);
-//! Handle coverage using Bullseye
+ //! Handle coverage using Bullseye
int HandleBullseyeCoverage(cmCTestCoverageHandlerContainer* cont);
int RunBullseyeSourceSummary(cmCTestCoverageHandlerContainer* cont);
int RunBullseyeCoverageBranch(cmCTestCoverageHandlerContainer* cont,
@@ -103,22 +103,15 @@ private:
std::vector<std::string>& files,
std::vector<std::string>& filesFullPath);
- int RunBullseyeCommand(
- cmCTestCoverageHandlerContainer* cont,
- const char* cmd,
- const char* arg,
- std::string& outputFile);
- bool ParseBullsEyeCovsrcLine(
- std::string const& inputLine,
- std::string& sourceFile,
- int& functionsCalled,
- int& totalFunctions,
- int& percentFunction,
- int& branchCovered,
- int& totalBranches,
- int& percentBranch);
- bool GetNextInt(std::string const& inputLine,
- std::string::size_type& pos,
+ int RunBullseyeCommand(cmCTestCoverageHandlerContainer* cont,
+ const char* cmd, const char* arg,
+ std::string& outputFile);
+ bool ParseBullsEyeCovsrcLine(std::string const& inputLine,
+ std::string& sourceFile, int& functionsCalled,
+ int& totalFunctions, int& percentFunction,
+ int& branchCovered, int& totalBranches,
+ int& percentBranch);
+ bool GetNextInt(std::string const& inputLine, std::string::size_type& pos,
int& value);
//! Handle Python coverage using Python's Trace.py
int HandleTracePyCoverage(cmCTestCoverageHandlerContainer* cont);
@@ -126,7 +119,7 @@ private:
// Find the source file based on the source and build tree. This is used for
// Trace.py mode, since that one does not tell us where the source file is.
std::string FindFile(cmCTestCoverageHandlerContainer* cont,
- std::string fileName);
+ std::string fileName);
std::set<std::string> FindUncoveredFiles(
cmCTestCoverageHandlerContainer* cont);
@@ -134,9 +127,10 @@ private:
std::vector<cmsys::RegularExpression> CustomCoverageExcludeRegex;
std::vector<std::string> ExtraCoverageGlobs;
-
// Map from source file to label ids.
- class LabelSet: public std::set<int> {};
+ class LabelSet : public std::set<int>
+ {
+ };
typedef std::map<std::string, LabelSet> LabelMapType;
LabelMapType SourceLabels;
LabelMapType TargetDirs;
diff --git a/Source/CTest/cmCTestCurl.cxx b/Source/CTest/cmCTestCurl.cxx
index 0367d7d..59675dd 100644
--- a/Source/CTest/cmCTestCurl.cxx
+++ b/Source/CTest/cmCTestCurl.cxx
@@ -42,115 +42,95 @@ std::string cmCTestCurl::Escape(std::string const& source)
return ret;
}
-namespace
-{
-static size_t
-curlWriteMemoryCallback(void *ptr, size_t size, size_t nmemb,
- void *data)
+namespace {
+static size_t curlWriteMemoryCallback(void* ptr, size_t size, size_t nmemb,
+ void* data)
{
int realsize = (int)(size * nmemb);
- std::vector<char> *vec
- = static_cast<std::vector<char>* >(data);
+ std::vector<char>* vec = static_cast<std::vector<char>*>(data);
const char* chPtr = static_cast<char*>(ptr);
vec->insert(vec->end(), chPtr, chPtr + realsize);
return realsize;
}
-static size_t
-curlDebugCallback(CURL *, curl_infotype, char *chPtr,
- size_t size, void *data)
+static size_t curlDebugCallback(CURL*, curl_infotype, char* chPtr, size_t size,
+ void* data)
{
- std::vector<char> *vec
- = static_cast<std::vector<char>* >(data);
+ std::vector<char>* vec = static_cast<std::vector<char>*>(data);
vec->insert(vec->end(), chPtr, chPtr + size);
return size;
}
-
}
void cmCTestCurl::SetCurlOptions(std::vector<std::string> const& args)
{
- for( std::vector<std::string>::const_iterator i = args.begin();
- i != args.end(); ++i)
- {
- if(*i == "CURLOPT_SSL_VERIFYPEER_OFF")
- {
+ for (std::vector<std::string>::const_iterator i = args.begin();
+ i != args.end(); ++i) {
+ if (*i == "CURLOPT_SSL_VERIFYPEER_OFF") {
this->VerifyPeerOff = true;
- }
- if(*i == "CURLOPT_SSL_VERIFYHOST_OFF")
- {
+ }
+ if (*i == "CURLOPT_SSL_VERIFYHOST_OFF") {
this->VerifyHostOff = true;
- }
}
+ }
}
bool cmCTestCurl::InitCurl()
{
- if(!this->Curl)
- {
+ if (!this->Curl) {
return false;
- }
- if(this->VerifyPeerOff)
- {
+ }
+ if (this->VerifyPeerOff) {
curl_easy_setopt(this->Curl, CURLOPT_SSL_VERIFYPEER, 0);
- }
- if(this->VerifyHostOff)
- {
+ }
+ if (this->VerifyHostOff) {
curl_easy_setopt(this->Curl, CURLOPT_SSL_VERIFYHOST, 0);
- }
- if(this->HTTPProxy.size())
- {
+ }
+ if (this->HTTPProxy.size()) {
curl_easy_setopt(this->Curl, CURLOPT_PROXY, this->HTTPProxy.c_str());
curl_easy_setopt(this->Curl, CURLOPT_PROXYTYPE, this->HTTPProxyType);
- if (this->HTTPProxyAuth.size() > 0)
- {
+ if (this->HTTPProxyAuth.size() > 0) {
curl_easy_setopt(this->Curl, CURLOPT_PROXYUSERPWD,
this->HTTPProxyAuth.c_str());
- }
}
- if(this->UseHttp10)
- {
+ }
+ if (this->UseHttp10) {
curl_easy_setopt(this->Curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
- }
+ }
// enable HTTP ERROR parsing
curl_easy_setopt(this->Curl, CURLOPT_FAILONERROR, 1);
return true;
}
-
bool cmCTestCurl::UploadFile(std::string const& local_file,
- std::string const& url,
- std::string const& fields,
+ std::string const& url, std::string const& fields,
std::string& response)
{
response = "";
- if(!this->InitCurl())
- {
+ if (!this->InitCurl()) {
cmCTestLog(this->CTest, ERROR_MESSAGE, "Initialization of curl failed");
return false;
- }
+ }
/* enable uploading */
curl_easy_setopt(this->Curl, CURLOPT_UPLOAD, 1);
// if there is little to no activity for too long stop submitting
- if(this->TimeOutSeconds)
- {
+ if (this->TimeOutSeconds) {
::curl_easy_setopt(this->Curl, CURLOPT_LOW_SPEED_LIMIT, 1);
::curl_easy_setopt(this->Curl, CURLOPT_LOW_SPEED_TIME,
this->TimeOutSeconds);
- }
+ }
/* HTTP PUT please */
::curl_easy_setopt(this->Curl, CURLOPT_PUT, 1);
::curl_easy_setopt(this->Curl, CURLOPT_VERBOSE, 1);
FILE* ftpfile = cmsys::SystemTools::Fopen(local_file, "rb");
- if(!ftpfile)
- {
+ if (!ftpfile) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Could not open file for upload: " << local_file << "\n");
return false;
- }
+ }
// set the url
std::string upload_url = url;
upload_url += "?";
@@ -164,16 +144,15 @@ bool cmCTestCurl::UploadFile(std::string const& local_file,
static_cast<long>(filelen));
::curl_easy_setopt(this->Curl, CURLOPT_WRITEFUNCTION,
curlWriteMemoryCallback);
- ::curl_easy_setopt(this->Curl, CURLOPT_DEBUGFUNCTION,
- curlDebugCallback);
+ ::curl_easy_setopt(this->Curl, CURLOPT_DEBUGFUNCTION, curlDebugCallback);
// Be sure to set Content-Type to satisfy fussy modsecurity rules
- struct curl_slist *headers = ::curl_slist_append(NULL,
- "Content-Type: text/xml");
+ struct curl_slist* headers =
+ ::curl_slist_append(NULL, "Content-Type: text/xml");
::curl_easy_setopt(this->Curl, CURLOPT_HTTPHEADER, headers);
std::vector<char> responseData;
std::vector<char> debugData;
- ::curl_easy_setopt(this->Curl, CURLOPT_FILE, (void *)&responseData);
- ::curl_easy_setopt(this->Curl, CURLOPT_DEBUGDATA, (void *)&debugData);
+ ::curl_easy_setopt(this->Curl, CURLOPT_FILE, (void*)&responseData);
+ ::curl_easy_setopt(this->Curl, CURLOPT_DEBUGDATA, (void*)&debugData);
::curl_easy_setopt(this->Curl, CURLOPT_FAILONERROR, 1);
// Now run off and do what you've been told!
::curl_easy_perform(this->Curl);
@@ -181,108 +160,90 @@ bool cmCTestCurl::UploadFile(std::string const& local_file,
::curl_easy_setopt(this->Curl, CURLOPT_HTTPHEADER, NULL);
::curl_slist_free_all(headers);
- if ( responseData.size() > 0 )
- {
+ if (responseData.size() > 0) {
response = std::string(responseData.begin(), responseData.end());
- cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Curl response: [" << response << "]\n");
- }
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Curl response: ["
+ << response << "]\n");
+ }
std::string curlDebug;
- if ( debugData.size() > 0 )
- {
+ if (debugData.size() > 0) {
curlDebug = std::string(debugData.begin(), debugData.end());
cmCTestLog(this->CTest, DEBUG, "Curl debug: [" << curlDebug << "]\n");
- }
- if(response.size() == 0)
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "No response from server.\n" <<
- curlDebug);
+ }
+ if (response.size() == 0) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "No response from server.\n"
+ << curlDebug);
return false;
- }
+ }
return true;
}
bool cmCTestCurl::HttpRequest(std::string const& url,
- std::string const& fields,
- std::string& response)
+ std::string const& fields, std::string& response)
{
response = "";
cmCTestLog(this->CTest, DEBUG, "HttpRequest\n"
- << "url: " << url << "\n"
- << "fields " << fields << "\n");
- if(!this->InitCurl())
- {
+ << "url: " << url << "\n"
+ << "fields " << fields << "\n");
+ if (!this->InitCurl()) {
cmCTestLog(this->CTest, ERROR_MESSAGE, "Initialization of curl failed");
return false;
- }
+ }
curl_easy_setopt(this->Curl, CURLOPT_POST, 1);
curl_easy_setopt(this->Curl, CURLOPT_POSTFIELDS, fields.c_str());
::curl_easy_setopt(this->Curl, CURLOPT_URL, url.c_str());
::curl_easy_setopt(this->Curl, CURLOPT_FOLLOWLOCATION, 1);
- //set response options
+ // set response options
::curl_easy_setopt(this->Curl, CURLOPT_WRITEFUNCTION,
curlWriteMemoryCallback);
- ::curl_easy_setopt(this->Curl, CURLOPT_DEBUGFUNCTION,
- curlDebugCallback);
+ ::curl_easy_setopt(this->Curl, CURLOPT_DEBUGFUNCTION, curlDebugCallback);
std::vector<char> responseData;
std::vector<char> debugData;
- ::curl_easy_setopt(this->Curl, CURLOPT_FILE, (void *)&responseData);
- ::curl_easy_setopt(this->Curl, CURLOPT_DEBUGDATA, (void *)&debugData);
+ ::curl_easy_setopt(this->Curl, CURLOPT_FILE, (void*)&responseData);
+ ::curl_easy_setopt(this->Curl, CURLOPT_DEBUGDATA, (void*)&debugData);
::curl_easy_setopt(this->Curl, CURLOPT_FAILONERROR, 1);
CURLcode res = ::curl_easy_perform(this->Curl);
- if ( responseData.size() > 0 )
- {
+ if (responseData.size() > 0) {
response = std::string(responseData.begin(), responseData.end());
cmCTestLog(this->CTest, DEBUG, "Curl response: [" << response << "]\n");
- }
- if ( debugData.size() > 0 )
- {
+ }
+ if (debugData.size() > 0) {
std::string curlDebug = std::string(debugData.begin(), debugData.end());
cmCTestLog(this->CTest, DEBUG, "Curl debug: [" << curlDebug << "]\n");
- }
+ }
cmCTestLog(this->CTest, DEBUG, "Curl res: " << res << "\n");
return (res == 0);
}
void cmCTestCurl::SetProxyType()
{
- if ( cmSystemTools::GetEnv("HTTP_PROXY") )
- {
+ if (cmSystemTools::GetEnv("HTTP_PROXY")) {
this->HTTPProxy = cmSystemTools::GetEnv("HTTP_PROXY");
- if ( cmSystemTools::GetEnv("HTTP_PROXY_PORT") )
- {
+ if (cmSystemTools::GetEnv("HTTP_PROXY_PORT")) {
this->HTTPProxy += ":";
this->HTTPProxy += cmSystemTools::GetEnv("HTTP_PROXY_PORT");
- }
- if ( cmSystemTools::GetEnv("HTTP_PROXY_TYPE") )
- {
+ }
+ if (cmSystemTools::GetEnv("HTTP_PROXY_TYPE")) {
// this is the default
this->HTTPProxyType = CURLPROXY_HTTP;
std::string type = cmSystemTools::GetEnv("HTTP_PROXY_TYPE");
// HTTP/SOCKS4/SOCKS5
- if ( type == "HTTP" )
- {
+ if (type == "HTTP") {
this->HTTPProxyType = CURLPROXY_HTTP;
- }
- else if ( type == "SOCKS4" )
- {
+ } else if (type == "SOCKS4") {
this->HTTPProxyType = CURLPROXY_SOCKS4;
- }
- else if ( type == "SOCKS5" )
- {
+ } else if (type == "SOCKS5") {
this->HTTPProxyType = CURLPROXY_SOCKS5;
- }
}
- if ( cmSystemTools::GetEnv("HTTP_PROXY_USER") )
- {
+ }
+ if (cmSystemTools::GetEnv("HTTP_PROXY_USER")) {
this->HTTPProxyAuth = cmSystemTools::GetEnv("HTTP_PROXY_USER");
- }
- if ( cmSystemTools::GetEnv("HTTP_PROXY_PASSWD") )
- {
+ }
+ if (cmSystemTools::GetEnv("HTTP_PROXY_PASSWD")) {
this->HTTPProxyAuth += ":";
this->HTTPProxyAuth += cmSystemTools::GetEnv("HTTP_PROXY_PASSWD");
- }
}
+ }
}
diff --git a/Source/CTest/cmCTestCurl.h b/Source/CTest/cmCTestCurl.h
index 0737bb6..82601e3 100644
--- a/Source/CTest/cmCTestCurl.h
+++ b/Source/CTest/cmCTestCurl.h
@@ -23,22 +23,21 @@ class cmCTestCurl
public:
cmCTestCurl(cmCTest*);
~cmCTestCurl();
- bool UploadFile(std::string const& url,
- std::string const& file,
- std::string const& fields,
- std::string& response);
- bool HttpRequest(std::string const& url,
- std::string const& fields,
+ bool UploadFile(std::string const& url, std::string const& file,
+ std::string const& fields, std::string& response);
+ bool HttpRequest(std::string const& url, std::string const& fields,
std::string& response);
// currently only supports CURLOPT_SSL_VERIFYPEER_OFF
// and CURLOPT_SSL_VERIFYHOST_OFF
void SetCurlOptions(std::vector<std::string> const& args);
- void SetUseHttp10On() { this->UseHttp10 = true;}
- void SetTimeOutSeconds(int s) { this->TimeOutSeconds = s;}
+ void SetUseHttp10On() { this->UseHttp10 = true; }
+ void SetTimeOutSeconds(int s) { this->TimeOutSeconds = s; }
std::string Escape(std::string const& source);
+
protected:
void SetProxyType();
bool InitCurl();
+
private:
cmCTest* CTest;
CURL* Curl;
diff --git a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx
index e175592..1bda9be 100644
--- a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx
+++ b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx
@@ -13,24 +13,20 @@
#include "cmCTestScriptHandler.h"
-bool cmCTestEmptyBinaryDirectoryCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmCTestEmptyBinaryDirectoryCommand::InitialPass(
+ std::vector<std::string> const& args, cmExecutionStatus&)
{
- if(args.size() != 1 )
- {
+ if (args.size() != 1) {
this->SetError("called with incorrect number of arguments");
return false;
- }
+ }
- if ( !cmCTestScriptHandler::EmptyBinaryDirectory(args[0].c_str()) )
- {
+ if (!cmCTestScriptHandler::EmptyBinaryDirectory(args[0].c_str())) {
std::ostringstream ostr;
ostr << "problem removing the binary directory: " << args[0];
this->SetError(ostr.str());
return false;
- }
+ }
return true;
}
-
-
diff --git a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h
index d182d17..e904d19 100644
--- a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h
+++ b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h
@@ -23,36 +23,36 @@
class cmCTestEmptyBinaryDirectoryCommand : public cmCTestCommand
{
public:
-
cmCTestEmptyBinaryDirectoryCommand() {}
/**
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
- {
- cmCTestEmptyBinaryDirectoryCommand* ni
- = new cmCTestEmptyBinaryDirectoryCommand;
+ {
+ cmCTestEmptyBinaryDirectoryCommand* ni =
+ new cmCTestEmptyBinaryDirectoryCommand;
ni->CTest = this->CTest;
ni->CTestScriptHandler = this->CTestScriptHandler;
return ni;
- }
+ }
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus &status);
+ cmExecutionStatus& status);
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const { return "ctest_empty_binary_directory";}
+ virtual std::string GetName() const
+ {
+ return "ctest_empty_binary_directory";
+ }
cmTypeMacro(cmCTestEmptyBinaryDirectoryCommand, cmCTestCommand);
-
};
-
#endif
diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx
index 6d70be9..8b392f2 100644
--- a/Source/CTest/cmCTestGIT.cxx
+++ b/Source/CTest/cmCTestGIT.cxx
@@ -27,11 +27,11 @@ static unsigned int cmCTestGITVersion(unsigned int epic, unsigned int major,
unsigned int minor, unsigned int fix)
{
// 1.6.5.0 maps to 10605000
- return fix + minor*1000 + major*100000 + epic*10000000;
+ return fix + minor * 1000 + major * 100000 + epic * 10000000;
}
-cmCTestGIT::cmCTestGIT(cmCTest* ct, std::ostream& log):
- cmCTestGlobalVC(ct, log)
+cmCTestGIT::cmCTestGIT(cmCTest* ct, std::ostream& log)
+ : cmCTestGlobalVC(ct, log)
{
this->PriorRev = this->Unknown;
this->CurrentGitVersion = 0;
@@ -41,29 +41,30 @@ cmCTestGIT::~cmCTestGIT()
{
}
-class cmCTestGIT::OneLineParser: public cmCTestVC::LineParser
+class cmCTestGIT::OneLineParser : public cmCTestVC::LineParser
{
public:
- OneLineParser(cmCTestGIT* git, const char* prefix,
- std::string& l): Line1(l)
- {
+ OneLineParser(cmCTestGIT* git, const char* prefix, std::string& l)
+ : Line1(l)
+ {
this->SetLog(&git->Log, prefix);
- }
+ }
+
private:
std::string& Line1;
virtual bool ProcessLine()
- {
+ {
// Only the first line is of interest.
this->Line1 = this->Line;
return false;
- }
+ }
};
std::string cmCTestGIT::GetWorkingRevision()
{
// Run plumbing "git rev-list" to get work tree revision.
const char* git = this->CommandLineTool.c_str();
- const char* git_rev_list[] = {git, "rev-list", "-n", "1", "HEAD", "--", 0};
+ const char* git_rev_list[] = { git, "rev-list", "-n", "1", "HEAD", "--", 0 };
std::string rev;
OneLineParser out(this, "rl-out> ", rev);
OutputLogger err(this->Log, "rl-err> ");
@@ -75,7 +76,7 @@ void cmCTestGIT::NoteOldRevision()
{
this->OldRevision = this->GetWorkingRevision();
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Old revision of repository is: "
- << this->OldRevision << "\n");
+ << this->OldRevision << "\n");
this->PriorRev.Rev = this->OldRevision;
}
@@ -83,7 +84,7 @@ void cmCTestGIT::NoteNewRevision()
{
this->NewRevision = this->GetWorkingRevision();
cmCTestLog(this->CTest, HANDLER_OUTPUT, " New revision of repository is: "
- << this->NewRevision << "\n");
+ << this->NewRevision << "\n");
}
std::string cmCTestGIT::FindGitDir()
@@ -92,43 +93,38 @@ std::string cmCTestGIT::FindGitDir()
// Run "git rev-parse --git-dir" to locate the real .git directory.
const char* git = this->CommandLineTool.c_str();
- char const* git_rev_parse[] = {git, "rev-parse", "--git-dir", 0};
+ char const* git_rev_parse[] = { git, "rev-parse", "--git-dir", 0 };
std::string git_dir_line;
OneLineParser rev_parse_out(this, "rev-parse-out> ", git_dir_line);
OutputLogger rev_parse_err(this->Log, "rev-parse-err> ");
- if(this->RunChild(git_rev_parse, &rev_parse_out, &rev_parse_err))
- {
+ if (this->RunChild(git_rev_parse, &rev_parse_out, &rev_parse_err)) {
git_dir = git_dir_line;
- }
- if(git_dir.empty())
- {
+ }
+ if (git_dir.empty()) {
git_dir = ".git";
- }
+ }
// Git reports a relative path only when the .git directory is in
// the current directory.
- if(git_dir[0] == '.')
- {
+ if (git_dir[0] == '.') {
git_dir = this->SourceDirectory + "/" + git_dir;
- }
+ }
#if defined(_WIN32) && !defined(__CYGWIN__)
- else if(git_dir[0] == '/')
- {
+ else if (git_dir[0] == '/') {
// Cygwin Git reports a full path that Cygwin understands, but we
// are a Windows application. Run "cygpath" to get Windows path.
std::string cygpath_exe = cmSystemTools::GetFilenamePath(git);
cygpath_exe += "/cygpath.exe";
- if(cmSystemTools::FileExists(cygpath_exe.c_str()))
- {
- char const* cygpath[] = {cygpath_exe.c_str(), "-w", git_dir.c_str(), 0};
+ if (cmSystemTools::FileExists(cygpath_exe.c_str())) {
+ char const* cygpath[] = { cygpath_exe.c_str(), "-w", git_dir.c_str(),
+ 0 };
OneLineParser cygpath_out(this, "cygpath-out> ", git_dir_line);
OutputLogger cygpath_err(this->Log, "cygpath-err> ");
- if(this->RunChild(cygpath, &cygpath_out, &cygpath_err))
- {
+ if (this->RunChild(cygpath, &cygpath_out, &cygpath_err)) {
git_dir = git_dir_line;
- }
}
}
+ }
#endif
return git_dir;
}
@@ -139,17 +135,16 @@ std::string cmCTestGIT::FindTopDir()
// Run "git rev-parse --show-cdup" to locate the top of the tree.
const char* git = this->CommandLineTool.c_str();
- char const* git_rev_parse[] = {git, "rev-parse", "--show-cdup", 0};
+ char const* git_rev_parse[] = { git, "rev-parse", "--show-cdup", 0 };
std::string cdup;
OneLineParser rev_parse_out(this, "rev-parse-out> ", cdup);
OutputLogger rev_parse_err(this->Log, "rev-parse-err> ");
- if(this->RunChild(git_rev_parse, &rev_parse_out, &rev_parse_err) &&
- !cdup.empty())
- {
+ if (this->RunChild(git_rev_parse, &rev_parse_out, &rev_parse_err) &&
+ !cdup.empty()) {
top_dir += "/";
top_dir += cdup;
top_dir = cmSystemTools::CollapseFullPath(top_dir);
- }
+ }
return top_dir;
}
@@ -164,16 +159,14 @@ bool cmCTestGIT::UpdateByFetchAndReset()
// Add user-specified update options.
std::string opts = this->CTest->GetCTestConfiguration("UpdateOptions");
- if(opts.empty())
- {
+ if (opts.empty()) {
opts = this->CTest->GetCTestConfiguration("GITUpdateOptions");
- }
+ }
std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
- for(std::vector<std::string>::const_iterator ai = args.begin();
- ai != args.end(); ++ai)
- {
+ for (std::vector<std::string>::const_iterator ai = args.begin();
+ ai != args.end(); ++ai) {
git_fetch.push_back(ai->c_str());
- }
+ }
// Sentinel argument.
git_fetch.push_back(0);
@@ -181,43 +174,37 @@ bool cmCTestGIT::UpdateByFetchAndReset()
// Fetch upstream refs.
OutputLogger fetch_out(this->Log, "fetch-out> ");
OutputLogger fetch_err(this->Log, "fetch-err> ");
- if(!this->RunUpdateCommand(&git_fetch[0], &fetch_out, &fetch_err))
- {
+ if (!this->RunUpdateCommand(&git_fetch[0], &fetch_out, &fetch_err)) {
return false;
- }
+ }
// Identify the merge head that would be used by "git pull".
std::string sha1;
{
- std::string fetch_head = this->FindGitDir() + "/FETCH_HEAD";
- cmsys::ifstream fin(fetch_head.c_str(), std::ios::in | std::ios::binary);
- if(!fin)
- {
- this->Log << "Unable to open " << fetch_head << "\n";
- return false;
+ std::string fetch_head = this->FindGitDir() + "/FETCH_HEAD";
+ cmsys::ifstream fin(fetch_head.c_str(), std::ios::in | std::ios::binary);
+ if (!fin) {
+ this->Log << "Unable to open " << fetch_head << "\n";
+ return false;
}
- std::string line;
- while(sha1.empty() && cmSystemTools::GetLineFromStream(fin, line))
- {
- this->Log << "FETCH_HEAD> " << line << "\n";
- if(line.find("\tnot-for-merge\t") == line.npos)
- {
- std::string::size_type pos = line.find('\t');
- if(pos != line.npos)
- {
- sha1 = line.substr(0, pos);
+ std::string line;
+ while (sha1.empty() && cmSystemTools::GetLineFromStream(fin, line)) {
+ this->Log << "FETCH_HEAD> " << line << "\n";
+ if (line.find("\tnot-for-merge\t") == line.npos) {
+ std::string::size_type pos = line.find('\t');
+ if (pos != line.npos) {
+ sha1 = line.substr(0, pos);
}
}
}
- if(sha1.empty())
- {
- this->Log << "FETCH_HEAD has no upstream branch candidate!\n";
- return false;
+ if (sha1.empty()) {
+ this->Log << "FETCH_HEAD has no upstream branch candidate!\n";
+ return false;
}
}
// Reset the local branch to point at that tracked from upstream.
- char const* git_reset[] = {git, "reset", "--hard", sha1.c_str(), 0};
+ char const* git_reset[] = { git, "reset", "--hard", sha1.c_str(), 0 };
OutputLogger reset_out(this->Log, "reset-out> ");
OutputLogger reset_err(this->Log, "reset-err> ");
return this->RunChild(&git_reset[0], &reset_out, &reset_err);
@@ -228,11 +215,10 @@ bool cmCTestGIT::UpdateByCustom(std::string const& custom)
std::vector<std::string> git_custom_command;
cmSystemTools::ExpandListArgument(custom, git_custom_command, true);
std::vector<char const*> git_custom;
- for(std::vector<std::string>::const_iterator
- i = git_custom_command.begin(); i != git_custom_command.end(); ++i)
- {
+ for (std::vector<std::string>::const_iterator i = git_custom_command.begin();
+ i != git_custom_command.end(); ++i) {
git_custom.push_back(i->c_str());
- }
+ }
git_custom.push_back(0);
OutputLogger custom_out(this->Log, "custom-out> ");
@@ -243,19 +229,17 @@ bool cmCTestGIT::UpdateByCustom(std::string const& custom)
bool cmCTestGIT::UpdateInternal()
{
std::string custom = this->CTest->GetCTestConfiguration("GITUpdateCustom");
- if(!custom.empty())
- {
+ if (!custom.empty()) {
return this->UpdateByCustom(custom);
- }
+ }
return this->UpdateByFetchAndReset();
}
bool cmCTestGIT::UpdateImpl()
{
- if(!this->UpdateInternal())
- {
+ if (!this->UpdateInternal()) {
return false;
- }
+ }
std::string top_dir = this->FindTopDir();
const char* git = this->CommandLineTool.c_str();
@@ -263,26 +247,22 @@ bool cmCTestGIT::UpdateImpl()
const char* sync_recursive = "--recursive";
// Git < 1.6.5 did not support submodule --recursive
- if(this->GetGitVersion() < cmCTestGITVersion(1,6,5,0))
- {
+ if (this->GetGitVersion() < cmCTestGITVersion(1, 6, 5, 0)) {
recursive = 0;
// No need to require >= 1.6.5 if there are no submodules.
- if(cmSystemTools::FileExists((top_dir + "/.gitmodules").c_str()))
- {
+ if (cmSystemTools::FileExists((top_dir + "/.gitmodules").c_str())) {
this->Log << "Git < 1.6.5 cannot update submodules recursively\n";
- }
}
+ }
// Git < 1.8.1 did not support sync --recursive
- if(this->GetGitVersion() < cmCTestGITVersion(1,8,1,0))
- {
+ if (this->GetGitVersion() < cmCTestGITVersion(1, 8, 1, 0)) {
sync_recursive = 0;
// No need to require >= 1.8.1 if there are no submodules.
- if(cmSystemTools::FileExists((top_dir + "/.gitmodules").c_str()))
- {
+ if (cmSystemTools::FileExists((top_dir + "/.gitmodules").c_str())) {
this->Log << "Git < 1.8.1 cannot synchronize submodules recursively\n";
- }
}
+ }
OutputLogger submodule_out(this->Log, "submodule-out> ");
OutputLogger submodule_err(this->Log, "submodule-err> ");
@@ -291,50 +271,45 @@ bool cmCTestGIT::UpdateImpl()
std::string init_submodules =
this->CTest->GetCTestConfiguration("GITInitSubmodules");
- if (cmSystemTools::IsOn(init_submodules.c_str()))
- {
- char const* git_submodule_init[] = {git, "submodule", "init", 0};
+ if (cmSystemTools::IsOn(init_submodules.c_str())) {
+ char const* git_submodule_init[] = { git, "submodule", "init", 0 };
ret = this->RunChild(git_submodule_init, &submodule_out, &submodule_err,
top_dir.c_str());
- if (!ret)
- {
+ if (!ret) {
return false;
- }
}
+ }
- char const* git_submodule_sync[] = {git, "submodule", "sync",
- sync_recursive, 0};
+ char const* git_submodule_sync[] = { git, "submodule", "sync",
+ sync_recursive, 0 };
ret = this->RunChild(git_submodule_sync, &submodule_out, &submodule_err,
top_dir.c_str());
- if (!ret)
- {
+ if (!ret) {
return false;
- }
+ }
- char const* git_submodule[] = {git, "submodule", "update", recursive, 0};
+ char const* git_submodule[] = { git, "submodule", "update", recursive, 0 };
return this->RunChild(git_submodule, &submodule_out, &submodule_err,
top_dir.c_str());
}
unsigned int cmCTestGIT::GetGitVersion()
{
- if(!this->CurrentGitVersion)
- {
+ if (!this->CurrentGitVersion) {
const char* git = this->CommandLineTool.c_str();
- char const* git_version[] = {git, "--version", 0};
+ char const* git_version[] = { git, "--version", 0 };
std::string version;
OneLineParser version_out(this, "version-out> ", version);
OutputLogger version_err(this->Log, "version-err> ");
- unsigned int v[4] = {0,0,0,0};
- if(this->RunChild(git_version, &version_out, &version_err) &&
- sscanf(version.c_str(), "git version %u.%u.%u.%u",
- &v[0], &v[1], &v[2], &v[3]) >= 3)
- {
+ unsigned int v[4] = { 0, 0, 0, 0 };
+ if (this->RunChild(git_version, &version_out, &version_err) &&
+ sscanf(version.c_str(), "git version %u.%u.%u.%u", &v[0], &v[1], &v[2],
+ &v[3]) >= 3) {
this->CurrentGitVersion = cmCTestGITVersion(v[0], v[1], v[2], v[3]);
- }
}
+ }
return this->CurrentGitVersion;
}
@@ -348,76 +323,73 @@ unsigned int cmCTestGIT::GetGitVersion()
line appears only for lines with status 'C' or 'R'. See 'git help
diff-tree' for details.
*/
-class cmCTestGIT::DiffParser: public cmCTestVC::LineParser
+class cmCTestGIT::DiffParser : public cmCTestVC::LineParser
{
public:
- DiffParser(cmCTestGIT* git, const char* prefix):
- LineParser('\0', false), GIT(git), DiffField(DiffFieldNone)
- {
+ DiffParser(cmCTestGIT* git, const char* prefix)
+ : LineParser('\0', false)
+ , GIT(git)
+ , DiffField(DiffFieldNone)
+ {
this->SetLog(&git->Log, prefix);
- }
+ }
typedef cmCTestGIT::Change Change;
std::vector<Change> Changes;
+
protected:
cmCTestGIT* GIT;
- enum DiffFieldType { DiffFieldNone, DiffFieldChange,
- DiffFieldSrc, DiffFieldDst };
+ enum DiffFieldType
+ {
+ DiffFieldNone,
+ DiffFieldChange,
+ DiffFieldSrc,
+ DiffFieldDst
+ };
DiffFieldType DiffField;
Change CurChange;
void DiffReset()
- {
+ {
this->DiffField = DiffFieldNone;
this->Changes.clear();
- }
+ }
virtual bool ProcessLine()
- {
- if(this->Line[0] == ':')
- {
+ {
+ if (this->Line[0] == ':') {
this->DiffField = DiffFieldChange;
this->CurChange = Change();
- }
- if(this->DiffField == DiffFieldChange)
- {
+ }
+ if (this->DiffField == DiffFieldChange) {
// :src-mode dst-mode src-sha1 dst-sha1 status
- if(this->Line[0] != ':')
- {
+ if (this->Line[0] != ':') {
this->DiffField = DiffFieldNone;
return true;
- }
- const char* src_mode_first = this->Line.c_str()+1;
- const char* src_mode_last = this->ConsumeField(src_mode_first);
+ }
+ const char* src_mode_first = this->Line.c_str() + 1;
+ const char* src_mode_last = this->ConsumeField(src_mode_first);
const char* dst_mode_first = this->ConsumeSpace(src_mode_last);
- const char* dst_mode_last = this->ConsumeField(dst_mode_first);
+ const char* dst_mode_last = this->ConsumeField(dst_mode_first);
const char* src_sha1_first = this->ConsumeSpace(dst_mode_last);
- const char* src_sha1_last = this->ConsumeField(src_sha1_first);
+ const char* src_sha1_last = this->ConsumeField(src_sha1_first);
const char* dst_sha1_first = this->ConsumeSpace(src_sha1_last);
- const char* dst_sha1_last = this->ConsumeField(dst_sha1_first);
- const char* status_first = this->ConsumeSpace(dst_sha1_last);
- const char* status_last = this->ConsumeField(status_first);
- if(status_first != status_last)
- {
+ const char* dst_sha1_last = this->ConsumeField(dst_sha1_first);
+ const char* status_first = this->ConsumeSpace(dst_sha1_last);
+ const char* status_last = this->ConsumeField(status_first);
+ if (status_first != status_last) {
this->CurChange.Action = *status_first;
this->DiffField = DiffFieldSrc;
- }
- else
- {
+ } else {
this->DiffField = DiffFieldNone;
- }
}
- else if(this->DiffField == DiffFieldSrc)
- {
+ } else if (this->DiffField == DiffFieldSrc) {
// src-path
- if(this->CurChange.Action == 'C')
- {
+ if (this->CurChange.Action == 'C') {
// Convert copy to addition of destination.
this->CurChange.Action = 'A';
this->DiffField = DiffFieldDst;
- }
- else if(this->CurChange.Action == 'R')
- {
+ } else if (this->CurChange.Action == 'R') {
// Convert rename to deletion of source and addition of destination.
this->CurChange.Action = 'D';
this->CurChange.Path = this->Line;
@@ -425,34 +397,34 @@ protected:
this->CurChange = Change('A');
this->DiffField = DiffFieldDst;
- }
- else
- {
+ } else {
this->CurChange.Path = this->Line;
this->Changes.push_back(this->CurChange);
this->DiffField = this->DiffFieldNone;
- }
}
- else if(this->DiffField == DiffFieldDst)
- {
+ } else if (this->DiffField == DiffFieldDst) {
// dst-path
this->CurChange.Path = this->Line;
this->Changes.push_back(this->CurChange);
this->DiffField = this->DiffFieldNone;
- }
- return true;
}
+ return true;
+ }
const char* ConsumeSpace(const char* c)
- {
- while(*c && isspace(*c)) { ++c; }
- return c;
+ {
+ while (*c && isspace(*c)) {
+ ++c;
}
- const char* ConsumeField(const char* c)
- {
- while(*c && !isspace(*c)) { ++c; }
return c;
+ }
+ const char* ConsumeField(const char* c)
+ {
+ while (*c && !isspace(*c)) {
+ ++c;
}
+ return c;
+ }
};
/* Commit format:
@@ -474,18 +446,25 @@ protected:
The header may have more fields. See 'git help diff-tree'.
*/
-class cmCTestGIT::CommitParser: public cmCTestGIT::DiffParser
+class cmCTestGIT::CommitParser : public cmCTestGIT::DiffParser
{
public:
- CommitParser(cmCTestGIT* git, const char* prefix):
- DiffParser(git, prefix), Section(SectionHeader)
- {
+ CommitParser(cmCTestGIT* git, const char* prefix)
+ : DiffParser(git, prefix)
+ , Section(SectionHeader)
+ {
this->Separator = SectionSep[this->Section];
- }
+ }
private:
typedef cmCTestGIT::Revision Revision;
- enum SectionType { SectionHeader, SectionBody, SectionDiff, SectionCount };
+ enum SectionType
+ {
+ SectionHeader,
+ SectionBody,
+ SectionDiff,
+ SectionCount
+ };
static char const SectionSep[SectionCount];
SectionType Section;
Revision Rev;
@@ -496,141 +475,147 @@ private:
std::string EMail;
unsigned long Time;
long TimeZone;
- Person(): Name(), EMail(), Time(0), TimeZone(0) {}
+ Person()
+ : Name()
+ , EMail()
+ , Time(0)
+ , TimeZone(0)
+ {
+ }
};
void ParsePerson(const char* str, Person& person)
- {
+ {
// Person Name <person@domain.com> 1234567890 +0000
const char* c = str;
- while(*c && isspace(*c)) { ++c; }
+ while (*c && isspace(*c)) {
+ ++c;
+ }
const char* name_first = c;
- while(*c && *c != '<') { ++c; }
+ while (*c && *c != '<') {
+ ++c;
+ }
const char* name_last = c;
- while(name_last != name_first && isspace(*(name_last-1))) { --name_last; }
- person.Name.assign(name_first, name_last-name_first);
+ while (name_last != name_first && isspace(*(name_last - 1))) {
+ --name_last;
+ }
+ person.Name.assign(name_first, name_last - name_first);
- const char* email_first = *c? ++c : c;
- while(*c && *c != '>') { ++c; }
- const char* email_last = *c? c++ : c;
- person.EMail.assign(email_first, email_last-email_first);
+ const char* email_first = *c ? ++c : c;
+ while (*c && *c != '>') {
+ ++c;
+ }
+ const char* email_last = *c ? c++ : c;
+ person.EMail.assign(email_first, email_last - email_first);
person.Time = strtoul(c, (char**)&c, 10);
person.TimeZone = strtol(c, (char**)&c, 10);
- }
+ }
virtual bool ProcessLine()
- {
- if(this->Line.empty())
- {
- if(this->Section == SectionBody && this->LineEnd == '\0')
- {
+ {
+ if (this->Line.empty()) {
+ if (this->Section == SectionBody && this->LineEnd == '\0') {
// Skip SectionDiff
this->NextSection();
- }
- this->NextSection();
}
- else
- {
- switch(this->Section)
- {
- case SectionHeader: this->DoHeaderLine(); break;
- case SectionBody: this->DoBodyLine(); break;
- case SectionDiff: this->DiffParser::ProcessLine(); break;
- case SectionCount: break; // never happens
- }
+ this->NextSection();
+ } else {
+ switch (this->Section) {
+ case SectionHeader:
+ this->DoHeaderLine();
+ break;
+ case SectionBody:
+ this->DoBodyLine();
+ break;
+ case SectionDiff:
+ this->DiffParser::ProcessLine();
+ break;
+ case SectionCount:
+ break; // never happens
}
- return true;
}
+ return true;
+ }
void NextSection()
- {
- this->Section = SectionType((this->Section+1) % SectionCount);
+ {
+ this->Section = SectionType((this->Section + 1) % SectionCount);
this->Separator = SectionSep[this->Section];
- if(this->Section == SectionHeader)
- {
+ if (this->Section == SectionHeader) {
this->GIT->DoRevision(this->Rev, this->Changes);
this->Rev = Revision();
this->DiffReset();
- }
}
+ }
void DoHeaderLine()
- {
+ {
// Look for header fields that we need.
- if(cmHasLiteralPrefix(this->Line.c_str(), "commit "))
- {
- this->Rev.Rev = this->Line.c_str()+7;
- }
- else if(cmHasLiteralPrefix(this->Line.c_str(), "author "))
- {
+ if (cmHasLiteralPrefix(this->Line.c_str(), "commit ")) {
+ this->Rev.Rev = this->Line.c_str() + 7;
+ } else if (cmHasLiteralPrefix(this->Line.c_str(), "author ")) {
Person author;
- this->ParsePerson(this->Line.c_str()+7, author);
+ this->ParsePerson(this->Line.c_str() + 7, author);
this->Rev.Author = author.Name;
this->Rev.EMail = author.EMail;
this->Rev.Date = this->FormatDateTime(author);
- }
- else if(cmHasLiteralPrefix(this->Line.c_str(), "committer "))
- {
+ } else if (cmHasLiteralPrefix(this->Line.c_str(), "committer ")) {
Person committer;
- this->ParsePerson(this->Line.c_str()+10, committer);
+ this->ParsePerson(this->Line.c_str() + 10, committer);
this->Rev.Committer = committer.Name;
this->Rev.CommitterEMail = committer.EMail;
this->Rev.CommitDate = this->FormatDateTime(committer);
- }
}
+ }
void DoBodyLine()
- {
+ {
// Commit log lines are indented by 4 spaces.
- if(this->Line.size() >= 4)
- {
+ if (this->Line.size() >= 4) {
this->Rev.Log += this->Line.substr(4);
- }
- this->Rev.Log += "\n";
}
+ this->Rev.Log += "\n";
+ }
std::string FormatDateTime(Person const& person)
- {
+ {
// Convert the time to a human-readable format that is also easy
// to machine-parse: "CCYY-MM-DD hh:mm:ss".
time_t seconds = static_cast<time_t>(person.Time);
struct tm* t = gmtime(&seconds);
char dt[1024];
- sprintf(dt, "%04d-%02d-%02d %02d:%02d:%02d",
- t->tm_year+1900, t->tm_mon+1, t->tm_mday,
- t->tm_hour, t->tm_min, t->tm_sec);
+ sprintf(dt, "%04d-%02d-%02d %02d:%02d:%02d", t->tm_year + 1900,
+ t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
std::string out = dt;
// Add the time-zone field "+zone" or "-zone".
char tz[32];
- if(person.TimeZone >= 0)
- {
+ if (person.TimeZone >= 0) {
sprintf(tz, " +%04ld", person.TimeZone);
- }
- else
- {
+ } else {
sprintf(tz, " -%04ld", -person.TimeZone);
- }
+ }
out += tz;
return out;
- }
+ }
};
-char const cmCTestGIT::CommitParser::SectionSep[SectionCount] =
-{'\n', '\n', '\0'};
+char const cmCTestGIT::CommitParser::SectionSep[SectionCount] = { '\n', '\n',
+ '\0' };
void cmCTestGIT::LoadRevisions()
{
// Use 'git rev-list ... | git diff-tree ...' to get revisions.
std::string range = this->OldRevision + ".." + this->NewRevision;
const char* git = this->CommandLineTool.c_str();
- const char* git_rev_list[] =
- {git, "rev-list", "--reverse", range.c_str(), "--", 0};
- const char* git_diff_tree[] =
- {git, "diff-tree", "--stdin", "--always", "-z", "-r", "--pretty=raw",
- "--encoding=utf-8", 0};
+ const char* git_rev_list[] = { git, "rev-list", "--reverse",
+ range.c_str(), "--", 0 };
+ const char* git_diff_tree[] = {
+ git, "diff-tree", "--stdin", "--always", "-z",
+ "-r", "--pretty=raw", "--encoding=utf-8", 0
+ };
this->Log << this->ComputeCommandLine(git_rev_list) << " | "
<< this->ComputeCommandLine(git_diff_tree) << "\n";
@@ -654,20 +639,19 @@ void cmCTestGIT::LoadModifications()
const char* git = this->CommandLineTool.c_str();
// Use 'git update-index' to refresh the index w.r.t. the work tree.
- const char* git_update_index[] = {git, "update-index", "--refresh", 0};
+ const char* git_update_index[] = { git, "update-index", "--refresh", 0 };
OutputLogger ui_out(this->Log, "ui-out> ");
OutputLogger ui_err(this->Log, "ui-err> ");
this->RunChild(git_update_index, &ui_out, &ui_err);
// Use 'git diff-index' to get modified files.
- const char* git_diff_index[] = {git, "diff-index", "-z", "HEAD", "--", 0};
+ const char* git_diff_index[] = { git, "diff-index", "-z", "HEAD", "--", 0 };
DiffParser out(this, "di-out> ");
OutputLogger err(this->Log, "di-err> ");
this->RunChild(git_diff_index, &out, &err);
- for(std::vector<Change>::const_iterator ci = out.Changes.begin();
- ci != out.Changes.end(); ++ci)
- {
+ for (std::vector<Change>::const_iterator ci = out.Changes.begin();
+ ci != out.Changes.end(); ++ci) {
this->DoModification(PathModified, ci->Path);
- }
+ }
}
diff --git a/Source/CTest/cmCTestGIT.h b/Source/CTest/cmCTestGIT.h
index 3d45da8..685cc31 100644
--- a/Source/CTest/cmCTestGIT.h
+++ b/Source/CTest/cmCTestGIT.h
@@ -18,7 +18,7 @@
* \brief Interaction with git command-line tool
*
*/
-class cmCTestGIT: public cmCTestGlobalVC
+class cmCTestGIT : public cmCTestGlobalVC
{
public:
/** Construct with a CTest instance and update log stream. */
@@ -46,7 +46,6 @@ private:
// "public" needed by older Sun compilers
public:
-
// Parsing helper classes.
class OneLineParser;
class DiffParser;
diff --git a/Source/CTest/cmCTestGenericHandler.cxx b/Source/CTest/cmCTestGenericHandler.cxx
index 2e9dd1f..1c80acd 100644
--- a/Source/CTest/cmCTestGenericHandler.cxx
+++ b/Source/CTest/cmCTestGenericHandler.cxx
@@ -32,16 +32,14 @@ cmCTestGenericHandler::~cmCTestGenericHandler()
void cmCTestGenericHandler::SetOption(const std::string& op, const char* value)
{
- if ( !value )
- {
- cmCTestGenericHandler::t_StringToString::iterator remit
- = this->Options.find(op);
- if ( remit != this->Options.end() )
- {
+ if (!value) {
+ cmCTestGenericHandler::t_StringToString::iterator remit =
+ this->Options.find(op);
+ if (remit != this->Options.end()) {
this->Options.erase(remit);
- }
- return;
}
+ return;
+ }
this->Options[op] = value;
}
@@ -50,16 +48,14 @@ void cmCTestGenericHandler::SetPersistentOption(const std::string& op,
const char* value)
{
this->SetOption(op, value);
- if ( !value )
- {
- cmCTestGenericHandler::t_StringToString::iterator remit
- = this->PersistentOptions.find(op);
- if ( remit != this->PersistentOptions.end() )
- {
+ if (!value) {
+ cmCTestGenericHandler::t_StringToString::iterator remit =
+ this->PersistentOptions.find(op);
+ if (remit != this->PersistentOptions.end()) {
this->PersistentOptions.erase(remit);
- }
- return;
}
+ return;
+ }
this->PersistentOptions[op] = value;
}
@@ -70,22 +66,19 @@ void cmCTestGenericHandler::Initialize()
this->TestLoad = 0;
this->Options.clear();
t_StringToString::iterator it;
- for ( it = this->PersistentOptions.begin();
- it != this->PersistentOptions.end();
- ++ it )
- {
+ for (it = this->PersistentOptions.begin();
+ it != this->PersistentOptions.end(); ++it) {
this->Options[it->first] = it->second.c_str();
- }
+ }
}
const char* cmCTestGenericHandler::GetOption(const std::string& op)
{
- cmCTestGenericHandler::t_StringToString::iterator remit
- = this->Options.find(op);
- if ( remit == this->Options.end() )
- {
+ cmCTestGenericHandler::t_StringToString::iterator remit =
+ this->Options.find(op);
+ if (remit == this->Options.end()) {
return 0;
- }
+ }
return remit->second.c_str();
}
@@ -93,67 +86,60 @@ bool cmCTestGenericHandler::StartResultingXML(cmCTest::Part part,
const char* name,
cmGeneratedFileStream& xofs)
{
- if ( !name )
- {
+ if (!name) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Cannot create resulting XML file without providing the name"
- << std::endl;);
+ "Cannot create resulting XML file without providing the name"
+ << std::endl;);
return false;
- }
+ }
std::ostringstream ostr;
ostr << name;
- if ( this->SubmitIndex > 0 )
- {
+ if (this->SubmitIndex > 0) {
ostr << "_" << this->SubmitIndex;
- }
+ }
ostr << ".xml";
- if(this->CTest->GetCurrentTag().empty())
- {
+ if (this->CTest->GetCurrentTag().empty()) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Current Tag empty, this may mean NightlyStartTime / "
"CTEST_NIGHTLY_START_TIME was not set correctly. Or "
"maybe you forgot to call ctest_start() before calling "
- "ctest_configure()." << std::endl);
+ "ctest_configure()."
+ << std::endl);
cmSystemTools::SetFatalErrorOccured();
return false;
- }
- if( !this->CTest->OpenOutputFile(this->CTest->GetCurrentTag(),
- ostr.str(), xofs, true) )
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Cannot create resulting XML file: " << ostr.str()
- << std::endl);
+ }
+ if (!this->CTest->OpenOutputFile(this->CTest->GetCurrentTag(), ostr.str(),
+ xofs, true)) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot create resulting XML file: "
+ << ostr.str() << std::endl);
return false;
- }
+ }
this->CTest->AddSubmitFile(part, ostr.str().c_str());
return true;
}
bool cmCTestGenericHandler::StartLogFile(const char* name,
- cmGeneratedFileStream& xofs)
+ cmGeneratedFileStream& xofs)
{
- if ( !name )
- {
+ if (!name) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Cannot create log file without providing the name" << std::endl;);
+ "Cannot create log file without providing the name"
+ << std::endl;);
return false;
- }
+ }
std::ostringstream ostr;
ostr << "Last" << name;
- if ( this->SubmitIndex > 0 )
- {
+ if (this->SubmitIndex > 0) {
ostr << "_" << this->SubmitIndex;
- }
- if ( !this->CTest->GetCurrentTag().empty() )
- {
+ }
+ if (!this->CTest->GetCurrentTag().empty()) {
ostr << "_" << this->CTest->GetCurrentTag();
- }
+ }
ostr << ".log";
- if( !this->CTest->OpenOutputFile("Temporary", ostr.str(), xofs) )
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot create log file: "
- << ostr.str() << std::endl);
+ if (!this->CTest->OpenOutputFile("Temporary", ostr.str(), xofs)) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Cannot create log file: " << ostr.str() << std::endl);
return false;
- }
+ }
return true;
}
diff --git a/Source/CTest/cmCTestGenericHandler.h b/Source/CTest/cmCTestGenericHandler.h
index 7a7e034..ad349ac 100644
--- a/Source/CTest/cmCTestGenericHandler.h
+++ b/Source/CTest/cmCTestGenericHandler.h
@@ -33,13 +33,15 @@ public:
* If verbose then more informaiton is printed out
*/
void SetVerbose(bool val)
- { this->HandlerVerbose = val ?
- cmSystemTools::OUTPUT_MERGE : cmSystemTools::OUTPUT_NONE; }
+ {
+ this->HandlerVerbose =
+ val ? cmSystemTools::OUTPUT_MERGE : cmSystemTools::OUTPUT_NONE;
+ }
/**
* Populate internals from CTest custom scripts
*/
- virtual void PopulateCustomVectors(cmMakefile *) {}
+ virtual void PopulateCustomVectors(cmMakefile*) {}
/**
* Do the actual processing. Subclass has to override it.
@@ -52,7 +54,10 @@ public:
*/
virtual int ProcessCommandLineArguments(
const std::string& /*currentArg*/, size_t& /*idx*/,
- const std::vector<std::string>& /*allArgs*/) { return 1; }
+ const std::vector<std::string>& /*allArgs*/)
+ {
+ return 1;
+ }
/**
* Initialize handler
@@ -71,17 +76,13 @@ public:
cmCTestGenericHandler();
virtual ~cmCTestGenericHandler();
- typedef std::map<std::string,std::string> t_StringToString;
-
+ typedef std::map<std::string, std::string> t_StringToString;
void SetPersistentOption(const std::string& op, const char* value);
void SetOption(const std::string& op, const char* value);
const char* GetOption(const std::string& op);
- void SetCommand(cmCTestCommand* command)
- {
- this->Command = command;
- }
+ void SetCommand(cmCTestCommand* command) { this->Command = command; }
void SetSubmitIndex(int idx) { this->SubmitIndex = idx; }
int GetSubmitIndex() { return this->SubmitIndex; }
@@ -90,18 +91,18 @@ public:
void SetQuiet(bool b) { this->Quiet = b; }
bool GetQuiet() { return this->Quiet; }
void SetTestLoad(unsigned long load) { this->TestLoad = load; }
- unsigned long GetTestLoad() const { return this->TestLoad; }
+ unsigned long GetTestLoad() const { return this->TestLoad; }
protected:
- bool StartResultingXML(cmCTest::Part part,
- const char* name, cmGeneratedFileStream& xofs);
+ bool StartResultingXML(cmCTest::Part part, const char* name,
+ cmGeneratedFileStream& xofs);
bool StartLogFile(const char* name, cmGeneratedFileStream& xofs);
bool AppendXML;
bool Quiet;
unsigned long TestLoad;
cmSystemTools::OutputOption HandlerVerbose;
- cmCTest *CTest;
+ cmCTest* CTest;
t_StringToString Options;
t_StringToString PersistentOptions;
@@ -110,4 +111,3 @@ protected:
};
#endif
-
diff --git a/Source/CTest/cmCTestGlobalVC.cxx b/Source/CTest/cmCTestGlobalVC.cxx
index 7c565fb..0c7ca4d 100644
--- a/Source/CTest/cmCTestGlobalVC.cxx
+++ b/Source/CTest/cmCTestGlobalVC.cxx
@@ -17,8 +17,8 @@
#include <cmsys/RegularExpression.hxx>
-cmCTestGlobalVC::cmCTestGlobalVC(cmCTest* ct, std::ostream& log):
- cmCTestVC(ct, log)
+cmCTestGlobalVC::cmCTestGlobalVC(cmCTest* ct, std::ostream& log)
+ : cmCTestVC(ct, log)
{
this->PriorRev = this->Unknown;
}
@@ -36,11 +36,10 @@ void cmCTestGlobalVC::DoRevision(Revision const& revision,
std::vector<Change> const& changes)
{
// Ignore changes in the old revision.
- if(revision.Rev == this->OldRevision)
- {
+ if (revision.Rev == this->OldRevision) {
this->PriorRev = revision;
return;
- }
+ }
// Indicate we found a revision.
cmCTestLog(this->CTest, HANDLER_OUTPUT, "." << std::flush);
@@ -57,19 +56,18 @@ void cmCTestGlobalVC::DoRevision(Revision const& revision,
/* clang-format on */
// Update information about revisions of the changed files.
- for(std::vector<Change>::const_iterator ci = changes.begin();
- ci != changes.end(); ++ci)
- {
- if(const char* local = this->LocalPath(ci->Path))
- {
+ for (std::vector<Change>::const_iterator ci = changes.begin();
+ ci != changes.end(); ++ci) {
+ if (const char* local = this->LocalPath(ci->Path)) {
std::string dir = cmSystemTools::GetFilenamePath(local);
std::string name = cmSystemTools::GetFilenameName(local);
File& file = this->Dirs[dir][name];
- file.PriorRev = file.Rev? file.Rev : &this->PriorRev;
+ file.PriorRev = file.Rev ? file.Rev : &this->PriorRev;
file.Rev = &rev;
- this->Log << " " << ci->Action << " " << local << " " << "\n";
- }
+ this->Log << " " << ci->Action << " " << local << " "
+ << "\n";
}
+ }
}
void cmCTestGlobalVC::DoModification(PathStatus status,
@@ -81,44 +79,41 @@ void cmCTestGlobalVC::DoModification(PathStatus status,
file.Status = status;
// For local modifications the current rev is unknown and the
// prior rev is the latest from svn.
- if(!file.Rev && !file.PriorRev)
- {
+ if (!file.Rev && !file.PriorRev) {
file.PriorRev = &this->PriorRev;
- }
+ }
}
void cmCTestGlobalVC::WriteXMLDirectory(cmXMLWriter& xml,
std::string const& path,
Directory const& dir)
{
- const char* slash = path.empty()? "":"/";
+ const char* slash = path.empty() ? "" : "/";
xml.StartElement("Directory");
xml.Element("Name", path);
- for(Directory::const_iterator fi = dir.begin(); fi != dir.end(); ++fi)
- {
+ for (Directory::const_iterator fi = dir.begin(); fi != dir.end(); ++fi) {
std::string full = path + slash + fi->first;
this->WriteXMLEntry(xml, path, fi->first, full, fi->second);
- }
+ }
xml.EndElement(); // Directory
}
void cmCTestGlobalVC::WriteXMLGlobal(cmXMLWriter& xml)
{
- if(!this->NewRevision.empty())
- {
+ if (!this->NewRevision.empty()) {
xml.Element("Revision", this->NewRevision);
- }
- if(!this->OldRevision.empty() && this->OldRevision != this->NewRevision)
- {
+ }
+ if (!this->OldRevision.empty() && this->OldRevision != this->NewRevision) {
xml.Element("PriorRevision", this->OldRevision);
- }
+ }
}
bool cmCTestGlobalVC::WriteXMLUpdates(cmXMLWriter& xml)
{
cmCTestLog(this->CTest, HANDLER_OUTPUT,
" Gathering version information (one . per revision):\n"
- " " << std::flush);
+ " "
+ << std::flush);
this->LoadRevisions();
cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl);
@@ -126,11 +121,11 @@ bool cmCTestGlobalVC::WriteXMLUpdates(cmXMLWriter& xml)
this->WriteXMLGlobal(xml);
- for(std::map<std::string, Directory>::const_iterator
- di = this->Dirs.begin(); di != this->Dirs.end(); ++di)
- {
+ for (std::map<std::string, Directory>::const_iterator di =
+ this->Dirs.begin();
+ di != this->Dirs.end(); ++di) {
this->WriteXMLDirectory(xml, di->first, di->second);
- }
+ }
return true;
}
diff --git a/Source/CTest/cmCTestGlobalVC.h b/Source/CTest/cmCTestGlobalVC.h
index d0e9410..9a5357f 100644
--- a/Source/CTest/cmCTestGlobalVC.h
+++ b/Source/CTest/cmCTestGlobalVC.h
@@ -20,7 +20,7 @@
* \brief Base class for handling globally-versioned trees
*
*/
-class cmCTestGlobalVC: public cmCTestVC
+class cmCTestGlobalVC : public cmCTestVC
{
public:
/** Construct with a CTest instance and update log stream. */
@@ -37,11 +37,16 @@ protected:
{
char Action;
std::string Path;
- Change(char a = '?'): Action(a) {}
+ Change(char a = '?')
+ : Action(a)
+ {
+ }
};
// Update status for files in each directory.
- class Directory: public std::map<std::string, File> {};
+ class Directory : public std::map<std::string, File>
+ {
+ };
std::map<std::string, Directory> Dirs;
// Old and new repository revisions.
diff --git a/Source/CTest/cmCTestHG.cxx b/Source/CTest/cmCTestHG.cxx
index 4dcd805..c6cfa44 100644
--- a/Source/CTest/cmCTestHG.cxx
+++ b/Source/CTest/cmCTestHG.cxx
@@ -17,8 +17,8 @@
#include <cmsys/RegularExpression.hxx>
-cmCTestHG::cmCTestHG(cmCTest* ct, std::ostream& log):
- cmCTestGlobalVC(ct, log)
+cmCTestHG::cmCTestHG(cmCTest* ct, std::ostream& log)
+ : cmCTestGlobalVC(ct, log)
{
this->PriorRev = this->Unknown;
}
@@ -27,74 +27,80 @@ cmCTestHG::~cmCTestHG()
{
}
-class cmCTestHG::IdentifyParser: public cmCTestVC::LineParser
+class cmCTestHG::IdentifyParser : public cmCTestVC::LineParser
{
public:
- IdentifyParser(cmCTestHG* hg, const char* prefix,
- std::string& rev): Rev(rev)
- {
+ IdentifyParser(cmCTestHG* hg, const char* prefix, std::string& rev)
+ : Rev(rev)
+ {
this->SetLog(&hg->Log, prefix);
this->RegexIdentify.compile("^([0-9a-f]+)");
- }
+ }
+
private:
std::string& Rev;
cmsys::RegularExpression RegexIdentify;
bool ProcessLine()
- {
- if(this->RegexIdentify.find(this->Line))
- {
+ {
+ if (this->RegexIdentify.find(this->Line)) {
this->Rev = this->RegexIdentify.match(1);
return false;
- }
- return true;
}
+ return true;
+ }
};
-class cmCTestHG::StatusParser: public cmCTestVC::LineParser
+class cmCTestHG::StatusParser : public cmCTestVC::LineParser
{
public:
- StatusParser(cmCTestHG* hg, const char* prefix): HG(hg)
- {
+ StatusParser(cmCTestHG* hg, const char* prefix)
+ : HG(hg)
+ {
this->SetLog(&hg->Log, prefix);
this->RegexStatus.compile("([MARC!?I]) (.*)");
- }
+ }
private:
cmCTestHG* HG;
cmsys::RegularExpression RegexStatus;
bool ProcessLine()
- {
- if(this->RegexStatus.find(this->Line))
- {
- this->DoPath(this->RegexStatus.match(1)[0],
- this->RegexStatus.match(2));
- }
- return true;
+ {
+ if (this->RegexStatus.find(this->Line)) {
+ this->DoPath(this->RegexStatus.match(1)[0], this->RegexStatus.match(2));
}
+ return true;
+ }
void DoPath(char status, std::string const& path)
- {
- if(path.empty()) return;
+ {
+ if (path.empty())
+ return;
// See "hg help status". Note that there is no 'conflict' status.
- switch(status)
- {
- case 'M': case 'A': case '!': case 'R':
+ switch (status) {
+ case 'M':
+ case 'A':
+ case '!':
+ case 'R':
this->HG->DoModification(PathModified, path);
break;
- case 'I': case '?': case 'C': case ' ': default:
+ case 'I':
+ case '?':
+ case 'C':
+ case ' ':
+ default:
break;
- }
}
+ }
};
std::string cmCTestHG::GetWorkingRevision()
{
// Run plumbing "hg identify" to get work tree revision.
const char* hg = this->CommandLineTool.c_str();
- const char* hg_identify[] = {hg, "identify","-i", 0};
+ const char* hg_identify[] = { hg, "identify", "-i", 0 };
std::string rev;
IdentifyParser out(this, "rev-out> ", rev);
OutputLogger err(this->Log, "rev-err> ");
@@ -106,7 +112,7 @@ void cmCTestHG::NoteOldRevision()
{
this->OldRevision = this->GetWorkingRevision();
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Old revision of repository is: "
- << this->OldRevision << "\n");
+ << this->OldRevision << "\n");
this->PriorRev.Rev = this->OldRevision;
}
@@ -114,18 +120,18 @@ void cmCTestHG::NoteNewRevision()
{
this->NewRevision = this->GetWorkingRevision();
cmCTestLog(this->CTest, HANDLER_OUTPUT, " New revision of repository is: "
- << this->NewRevision << "\n");
+ << this->NewRevision << "\n");
}
bool cmCTestHG::UpdateImpl()
{
// Use "hg pull" followed by "hg update" to update the working tree.
{
- const char* hg = this->CommandLineTool.c_str();
- const char* hg_pull[] = {hg, "pull","-v", 0};
- OutputLogger out(this->Log, "pull-out> ");
- OutputLogger err(this->Log, "pull-err> ");
- this->RunChild(&hg_pull[0], &out, &err);
+ const char* hg = this->CommandLineTool.c_str();
+ const char* hg_pull[] = { hg, "pull", "-v", 0 };
+ OutputLogger out(this->Log, "pull-out> ");
+ OutputLogger err(this->Log, "pull-err> ");
+ this->RunChild(&hg_pull[0], &out, &err);
}
// TODO: if(this->CTest->GetTestModel() == cmCTest::NIGHTLY)
@@ -137,16 +143,14 @@ bool cmCTestHG::UpdateImpl()
// Add user-specified update options.
std::string opts = this->CTest->GetCTestConfiguration("UpdateOptions");
- if(opts.empty())
- {
+ if (opts.empty()) {
opts = this->CTest->GetCTestConfiguration("HGUpdateOptions");
- }
+ }
std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
- for(std::vector<std::string>::const_iterator ai = args.begin();
- ai != args.end(); ++ai)
- {
+ for (std::vector<std::string>::const_iterator ai = args.begin();
+ ai != args.end(); ++ai) {
hg_update.push_back(ai->c_str());
- }
+ }
// Sentinel argument.
hg_update.push_back(0);
@@ -156,12 +160,16 @@ bool cmCTestHG::UpdateImpl()
return this->RunUpdateCommand(&hg_update[0], &out, &err);
}
-class cmCTestHG::LogParser: public cmCTestVC::OutputLogger,
- private cmXMLParser
+class cmCTestHG::LogParser : public cmCTestVC::OutputLogger,
+ private cmXMLParser
{
public:
- LogParser(cmCTestHG* hg, const char* prefix):
- OutputLogger(hg->Log, prefix), HG(hg) { this->InitializeParser(); }
+ LogParser(cmCTestHG* hg, const char* prefix)
+ : OutputLogger(hg->Log, prefix)
+ , HG(hg)
+ {
+ this->InitializeParser();
+ }
~LogParser() { this->CleanupParser(); }
private:
cmCTestHG* HG;
@@ -174,114 +182,88 @@ private:
std::vector<char> CData;
virtual bool ProcessChunk(const char* data, int length)
- {
+ {
this->OutputLogger::ProcessChunk(data, length);
this->ParseChunk(data, length);
return true;
- }
+ }
virtual void StartElement(const std::string& name, const char** atts)
- {
+ {
this->CData.clear();
- if(name == "logentry")
- {
+ if (name == "logentry") {
this->Rev = Revision();
- if(const char* rev = this->FindAttribute(atts, "revision"))
- {
+ if (const char* rev = this->FindAttribute(atts, "revision")) {
this->Rev.Rev = rev;
- }
- this->Changes.clear();
}
+ this->Changes.clear();
}
+ }
virtual void CharacterDataHandler(const char* data, int length)
- {
- this->CData.insert(this->CData.end(), data, data+length);
- }
+ {
+ this->CData.insert(this->CData.end(), data, data + length);
+ }
virtual void EndElement(const std::string& name)
- {
- if(name == "logentry")
- {
+ {
+ if (name == "logentry") {
this->HG->DoRevision(this->Rev, this->Changes);
- }
- else if(!this->CData.empty() && name == "author")
- {
+ } else if (!this->CData.empty() && name == "author") {
this->Rev.Author.assign(&this->CData[0], this->CData.size());
- }
- else if(!this->CData.empty() && name == "email")
- {
+ } else if (!this->CData.empty() && name == "email") {
this->Rev.EMail.assign(&this->CData[0], this->CData.size());
- }
- else if(!this->CData.empty() && name == "date")
- {
+ } else if (!this->CData.empty() && name == "date") {
this->Rev.Date.assign(&this->CData[0], this->CData.size());
- }
- else if(!this->CData.empty() && name == "msg")
- {
+ } else if (!this->CData.empty() && name == "msg") {
this->Rev.Log.assign(&this->CData[0], this->CData.size());
- }
- else if(!this->CData.empty() && name == "files")
- {
+ } else if (!this->CData.empty() && name == "files") {
std::vector<std::string> paths = this->SplitCData();
- for(unsigned int i = 0; i < paths.size(); ++i)
- {
+ for (unsigned int i = 0; i < paths.size(); ++i) {
// Updated by default, will be modified using file_adds and
// file_dels.
this->CurChange = Change('U');
this->CurChange.Path = paths[i];
this->Changes.push_back(this->CurChange);
- }
}
- else if(!this->CData.empty() && name == "file_adds")
- {
+ } else if (!this->CData.empty() && name == "file_adds") {
std::string added_paths(this->CData.begin(), this->CData.end());
- for(unsigned int i = 0; i < this->Changes.size(); ++i)
- {
- if(added_paths.find(this->Changes[i].Path) != std::string::npos)
- {
+ for (unsigned int i = 0; i < this->Changes.size(); ++i) {
+ if (added_paths.find(this->Changes[i].Path) != std::string::npos) {
this->Changes[i].Action = 'A';
- }
}
}
- else if(!this->CData.empty() && name == "file_dels")
- {
+ } else if (!this->CData.empty() && name == "file_dels") {
std::string added_paths(this->CData.begin(), this->CData.end());
- for(unsigned int i = 0; i < this->Changes.size(); ++i)
- {
- if(added_paths.find(this->Changes[i].Path) != std::string::npos)
- {
+ for (unsigned int i = 0; i < this->Changes.size(); ++i) {
+ if (added_paths.find(this->Changes[i].Path) != std::string::npos) {
this->Changes[i].Action = 'D';
- }
}
}
- this->CData.clear();
}
+ this->CData.clear();
+ }
std::vector<std::string> SplitCData()
- {
+ {
std::vector<std::string> output;
std::string currPath;
- for(unsigned int i=0; i < this->CData.size(); ++i)
- {
- if(this->CData[i] != ' ')
- {
+ for (unsigned int i = 0; i < this->CData.size(); ++i) {
+ if (this->CData[i] != ' ') {
currPath += this->CData[i];
- }
- else
- {
+ } else {
output.push_back(currPath);
currPath = "";
- }
}
+ }
output.push_back(currPath);
return output;
- }
+ }
virtual void ReportError(int, int, const char* msg)
- {
+ {
this->HG->Log << "Error parsing hg log xml: " << msg << "\n";
- }
+ }
};
void cmCTestHG::LoadRevisions()
@@ -294,19 +276,19 @@ void cmCTestHG::LoadRevisions()
// proper XML escapes.
std::string range = this->OldRevision + ":" + this->NewRevision;
const char* hg = this->CommandLineTool.c_str();
- const char* hgXMLTemplate =
- "<logentry\n"
- " revision=\"{node|short}\">\n"
- " <author>{author|person}</author>\n"
- " <email>{author|email}</email>\n"
- " <date>{date|isodate}</date>\n"
- " <msg>{desc}</msg>\n"
- " <files>{files}</files>\n"
- " <file_adds>{file_adds}</file_adds>\n"
- " <file_dels>{file_dels}</file_dels>\n"
- "</logentry>\n";
- const char* hg_log[] = {hg, "log","--removed", "-r", range.c_str(),
- "--template", hgXMLTemplate, 0};
+ const char* hgXMLTemplate = "<logentry\n"
+ " revision=\"{node|short}\">\n"
+ " <author>{author|person}</author>\n"
+ " <email>{author|email}</email>\n"
+ " <date>{date|isodate}</date>\n"
+ " <msg>{desc}</msg>\n"
+ " <files>{files}</files>\n"
+ " <file_adds>{file_adds}</file_adds>\n"
+ " <file_dels>{file_dels}</file_dels>\n"
+ "</logentry>\n";
+ const char* hg_log[] = {
+ hg, "log", "--removed", "-r", range.c_str(), "--template", hgXMLTemplate, 0
+ };
LogParser out(this, "log-out> ");
out.Process("<?xml version=\"1.0\"?>\n"
@@ -320,7 +302,7 @@ void cmCTestHG::LoadModifications()
{
// Use 'hg status' to get modified files.
const char* hg = this->CommandLineTool.c_str();
- const char* hg_status[] = {hg, "status", 0};
+ const char* hg_status[] = { hg, "status", 0 };
StatusParser out(this, "status-out> ");
OutputLogger err(this->Log, "status-err> ");
this->RunChild(hg_status, &out, &err);
diff --git a/Source/CTest/cmCTestHG.h b/Source/CTest/cmCTestHG.h
index 1eaf933..8cc8c7a 100644
--- a/Source/CTest/cmCTestHG.h
+++ b/Source/CTest/cmCTestHG.h
@@ -18,7 +18,7 @@
* \brief Interaction with Mercurial command-line tool
*
*/
-class cmCTestHG: public cmCTestGlobalVC
+class cmCTestHG : public cmCTestGlobalVC
{
public:
/** Construct with a CTest instance and update log stream. */
diff --git a/Source/CTest/cmCTestHandlerCommand.cxx b/Source/CTest/cmCTestHandlerCommand.cxx
index 4b24a199..76f971d 100644
--- a/Source/CTest/cmCTestHandlerCommand.cxx
+++ b/Source/CTest/cmCTestHandlerCommand.cxx
@@ -19,10 +19,9 @@ cmCTestHandlerCommand::cmCTestHandlerCommand()
const size_t INIT_SIZE = 100;
size_t cc;
this->Arguments.reserve(INIT_SIZE);
- for ( cc = 0; cc < INIT_SIZE; ++ cc )
- {
+ for (cc = 0; cc < INIT_SIZE; ++cc) {
this->Arguments.push_back(0);
- }
+ }
this->Arguments[ct_RETURN_VALUE] = "RETURN_VALUE";
this->Arguments[ct_SOURCE] = "SOURCE";
this->Arguments[ct_BUILD] = "BUILD";
@@ -32,8 +31,8 @@ cmCTestHandlerCommand::cmCTestHandlerCommand()
this->Quiet = false;
}
-bool cmCTestHandlerCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus&)
{
// Allocate space for argument values.
this->Values.clear();
@@ -41,24 +40,21 @@ bool cmCTestHandlerCommand
// Process input arguments.
this->ArgumentDoing = ArgumentDoingNone;
- for(unsigned int i=0; i < args.size(); ++i)
- {
+ for (unsigned int i = 0; i < args.size(); ++i) {
// Check this argument.
- if(!this->CheckArgumentKeyword(args[i]) &&
- !this->CheckArgumentValue(args[i]))
- {
+ if (!this->CheckArgumentKeyword(args[i]) &&
+ !this->CheckArgumentValue(args[i])) {
std::ostringstream e;
e << "called with unknown argument \"" << args[i] << "\".";
this->SetError(e.str());
return false;
- }
+ }
// Quit if an argument is invalid.
- if(this->ArgumentDoing == ArgumentDoingError)
- {
+ if (this->ArgumentDoing == ArgumentDoingError) {
return false;
- }
}
+ }
// Set the config type of this ctest to the current value of the
// CTEST_CONFIGURATION_TYPE script variable if it is defined.
@@ -66,94 +62,83 @@ bool cmCTestHandlerCommand
// line.
const char* ctestConfigType =
this->Makefile->GetDefinition("CTEST_CONFIGURATION_TYPE");
- if (ctestConfigType)
- {
+ if (ctestConfigType) {
this->CTest->SetConfigType(ctestConfigType);
- }
+ }
- if ( this->Values[ct_BUILD] )
- {
- this->CTest->SetCTestConfiguration("BuildDirectory",
- cmSystemTools::CollapseFullPath(
- this->Values[ct_BUILD]).c_str(), this->Quiet);
- }
- else
- {
+ if (this->Values[ct_BUILD]) {
+ this->CTest->SetCTestConfiguration(
+ "BuildDirectory",
+ cmSystemTools::CollapseFullPath(this->Values[ct_BUILD]).c_str(),
+ this->Quiet);
+ } else {
const char* bdir =
this->Makefile->GetSafeDefinition("CTEST_BINARY_DIRECTORY");
- if(bdir)
- {
- this->
- CTest->SetCTestConfiguration("BuildDirectory",
- cmSystemTools::CollapseFullPath(bdir).c_str(), this->Quiet);
- }
- else
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "CTEST_BINARY_DIRECTORY not set" << std::endl;);
- }
- }
- if ( this->Values[ct_SOURCE] )
- {
- cmCTestLog(this->CTest, DEBUG,
- "Set source directory to: " << this->Values[ct_SOURCE] << std::endl);
- this->CTest->SetCTestConfiguration("SourceDirectory",
- cmSystemTools::CollapseFullPath(
- this->Values[ct_SOURCE]).c_str(), this->Quiet);
+ if (bdir) {
+ this->CTest->SetCTestConfiguration(
+ "BuildDirectory", cmSystemTools::CollapseFullPath(bdir).c_str(),
+ this->Quiet);
+ } else {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "CTEST_BINARY_DIRECTORY not set"
+ << std::endl;);
}
- else
- {
- this->CTest->SetCTestConfiguration("SourceDirectory",
+ }
+ if (this->Values[ct_SOURCE]) {
+ cmCTestLog(this->CTest, DEBUG, "Set source directory to: "
+ << this->Values[ct_SOURCE] << std::endl);
+ this->CTest->SetCTestConfiguration(
+ "SourceDirectory",
+ cmSystemTools::CollapseFullPath(this->Values[ct_SOURCE]).c_str(),
+ this->Quiet);
+ } else {
+ this->CTest->SetCTestConfiguration(
+ "SourceDirectory",
cmSystemTools::CollapseFullPath(
- this->Makefile->GetSafeDefinition("CTEST_SOURCE_DIRECTORY")).c_str(),
+ this->Makefile->GetSafeDefinition("CTEST_SOURCE_DIRECTORY"))
+ .c_str(),
this->Quiet);
- }
+ }
- if(const char* changeId =
- this->Makefile->GetDefinition("CTEST_CHANGE_ID"))
- {
+ if (const char* changeId =
+ this->Makefile->GetDefinition("CTEST_CHANGE_ID")) {
this->CTest->SetCTestConfiguration("ChangeId", changeId, this->Quiet);
- }
+ }
cmCTestLog(this->CTest, DEBUG, "Initialize handler" << std::endl;);
cmCTestGenericHandler* handler = this->InitializeHandler();
- if ( !handler )
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Cannot instantiate test handler " << this->GetName()
- << std::endl);
+ if (!handler) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot instantiate test handler "
+ << this->GetName() << std::endl);
return false;
- }
+ }
handler->SetAppendXML(this->AppendXML);
handler->PopulateCustomVectors(this->Makefile);
- if ( this->Values[ct_SUBMIT_INDEX] )
- {
- if(!this->CTest->GetDropSiteCDash() && this->CTest->GetDartVersion() <= 1)
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
+ if (this->Values[ct_SUBMIT_INDEX]) {
+ if (!this->CTest->GetDropSiteCDash() &&
+ this->CTest->GetDartVersion() <= 1) {
+ cmCTestLog(
+ this->CTest, ERROR_MESSAGE,
"Dart before version 2.0 does not support collecting submissions."
- << std::endl
- << "Please upgrade the server to Dart 2 or higher, or do not use "
- "SUBMIT_INDEX." << std::endl);
- }
- else
- {
+ << std::endl
+ << "Please upgrade the server to Dart 2 or higher, or do not use "
+ "SUBMIT_INDEX."
+ << std::endl);
+ } else {
handler->SetSubmitIndex(atoi(this->Values[ct_SUBMIT_INDEX]));
- }
}
+ }
std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory();
cmSystemTools::ChangeDirectory(
this->CTest->GetCTestConfiguration("BuildDirectory"));
int res = handler->ProcessHandler();
- if ( this->Values[ct_RETURN_VALUE] && *this->Values[ct_RETURN_VALUE])
- {
+ if (this->Values[ct_RETURN_VALUE] && *this->Values[ct_RETURN_VALUE]) {
std::ostringstream str;
str << res;
- this->Makefile->AddDefinition(
- this->Values[ct_RETURN_VALUE], str.str().c_str());
- }
+ this->Makefile->AddDefinition(this->Values[ct_RETURN_VALUE],
+ str.str().c_str());
+ }
cmSystemTools::ChangeDirectory(current_dir);
return true;
}
@@ -161,50 +146,44 @@ bool cmCTestHandlerCommand
bool cmCTestHandlerCommand::CheckArgumentKeyword(std::string const& arg)
{
// Look for non-value arguments common to all commands.
- if(arg == "APPEND")
- {
+ if (arg == "APPEND") {
this->ArgumentDoing = ArgumentDoingNone;
this->AppendXML = true;
return true;
- }
- if(arg == "QUIET")
- {
+ }
+ if (arg == "QUIET") {
this->ArgumentDoing = ArgumentDoingNone;
this->Quiet = true;
return true;
- }
+ }
// Check for a keyword in our argument/value table.
- for(unsigned int k=0; k < this->Arguments.size(); ++k)
- {
- if(this->Arguments[k] && arg == this->Arguments[k])
- {
+ for (unsigned int k = 0; k < this->Arguments.size(); ++k) {
+ if (this->Arguments[k] && arg == this->Arguments[k]) {
this->ArgumentDoing = ArgumentDoingKeyword;
this->ArgumentIndex = k;
return true;
- }
}
+ }
return false;
}
bool cmCTestHandlerCommand::CheckArgumentValue(std::string const& arg)
{
- if(this->ArgumentDoing == ArgumentDoingKeyword)
- {
+ if (this->ArgumentDoing == ArgumentDoingKeyword) {
this->ArgumentDoing = ArgumentDoingNone;
unsigned int k = this->ArgumentIndex;
- if(this->Values[k])
- {
+ if (this->Values[k]) {
std::ostringstream e;
e << "Called with more than one value for " << this->Arguments[k];
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
this->ArgumentDoing = ArgumentDoingError;
return true;
- }
+ }
this->Values[k] = arg.c_str();
- cmCTestLog(this->CTest, DEBUG, "Set " << this->Arguments[k]
- << " to " << arg << "\n");
+ cmCTestLog(this->CTest, DEBUG, "Set " << this->Arguments[k] << " to "
+ << arg << "\n");
return true;
- }
+ }
return false;
}
diff --git a/Source/CTest/cmCTestHandlerCommand.h b/Source/CTest/cmCTestHandlerCommand.h
index 87b2cd8..7248832 100644
--- a/Source/CTest/cmCTestHandlerCommand.h
+++ b/Source/CTest/cmCTestHandlerCommand.h
@@ -31,19 +31,19 @@ public:
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus &status);
+ cmExecutionStatus& status);
cmTypeMacro(cmCTestHandlerCommand, cmCTestCommand);
enum
- {
+ {
ct_NONE,
ct_RETURN_VALUE,
ct_BUILD,
ct_SOURCE,
ct_SUBMIT_INDEX,
ct_LAST
- };
+ };
protected:
virtual cmCTestGenericHandler* InitializeHandler() = 0;
@@ -70,9 +70,9 @@ protected:
size_t Last;
};
-#define CTEST_COMMAND_APPEND_OPTION_DOCS \
- "The APPEND option marks results for append to those previously " \
- "submitted to a dashboard server since the last ctest_start. " \
+#define CTEST_COMMAND_APPEND_OPTION_DOCS \
+ "The APPEND option marks results for append to those previously " \
+ "submitted to a dashboard server since the last ctest_start. " \
"Append semantics are defined by the dashboard server in use."
#endif
diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx
index 7da81ec..4a408a2 100644
--- a/Source/CTest/cmCTestLaunch.cxx
+++ b/Source/CTest/cmCTestLaunch.cxx
@@ -34,10 +34,9 @@ cmCTestLaunch::cmCTestLaunch(int argc, const char* const* argv)
this->ExitCode = 1;
this->CWD = cmSystemTools::GetCurrentWorkingDirectory();
- if(!this->ParseArguments(argc, argv))
- {
+ if (!this->ParseArguments(argc, argv)) {
return;
- }
+ }
this->ComputeFileNames();
@@ -50,138 +49,103 @@ cmCTestLaunch::cmCTestLaunch(int argc, const char* const* argv)
cmCTestLaunch::~cmCTestLaunch()
{
cmsysProcess_Delete(this->Process);
- if(!this->Passthru)
- {
+ if (!this->Passthru) {
cmSystemTools::RemoveFile(this->LogOut);
cmSystemTools::RemoveFile(this->LogErr);
- }
+ }
}
bool cmCTestLaunch::ParseArguments(int argc, const char* const* argv)
{
// Launcher options occur first and are separated from the real
// command line by a '--' option.
- enum Doing { DoingNone,
- DoingOutput,
- DoingSource,
- DoingLanguage,
- DoingTargetName,
- DoingTargetType,
- DoingBuildDir,
- DoingCount,
- DoingFilterPrefix };
+ enum Doing
+ {
+ DoingNone,
+ DoingOutput,
+ DoingSource,
+ DoingLanguage,
+ DoingTargetName,
+ DoingTargetType,
+ DoingBuildDir,
+ DoingCount,
+ DoingFilterPrefix
+ };
Doing doing = DoingNone;
int arg0 = 0;
- for(int i=1; !arg0 && i < argc; ++i)
- {
+ for (int i = 1; !arg0 && i < argc; ++i) {
const char* arg = argv[i];
- if(strcmp(arg, "--") == 0)
- {
- arg0 = i+1;
- }
- else if(strcmp(arg, "--output") == 0)
- {
+ if (strcmp(arg, "--") == 0) {
+ arg0 = i + 1;
+ } else if (strcmp(arg, "--output") == 0) {
doing = DoingOutput;
- }
- else if(strcmp(arg, "--source") == 0)
- {
+ } else if (strcmp(arg, "--source") == 0) {
doing = DoingSource;
- }
- else if(strcmp(arg, "--language") == 0)
- {
+ } else if (strcmp(arg, "--language") == 0) {
doing = DoingLanguage;
- }
- else if(strcmp(arg, "--target-name") == 0)
- {
+ } else if (strcmp(arg, "--target-name") == 0) {
doing = DoingTargetName;
- }
- else if(strcmp(arg, "--target-type") == 0)
- {
+ } else if (strcmp(arg, "--target-type") == 0) {
doing = DoingTargetType;
- }
- else if(strcmp(arg, "--build-dir") == 0)
- {
+ } else if (strcmp(arg, "--build-dir") == 0) {
doing = DoingBuildDir;
- }
- else if(strcmp(arg, "--filter-prefix") == 0)
- {
+ } else if (strcmp(arg, "--filter-prefix") == 0) {
doing = DoingFilterPrefix;
- }
- else if(doing == DoingOutput)
- {
+ } else if (doing == DoingOutput) {
this->OptionOutput = arg;
doing = DoingNone;
- }
- else if(doing == DoingSource)
- {
+ } else if (doing == DoingSource) {
this->OptionSource = arg;
doing = DoingNone;
- }
- else if(doing == DoingLanguage)
- {
+ } else if (doing == DoingLanguage) {
this->OptionLanguage = arg;
- if(this->OptionLanguage == "CXX")
- {
+ if (this->OptionLanguage == "CXX") {
this->OptionLanguage = "C++";
- }
- doing = DoingNone;
}
- else if(doing == DoingTargetName)
- {
+ doing = DoingNone;
+ } else if (doing == DoingTargetName) {
this->OptionTargetName = arg;
doing = DoingNone;
- }
- else if(doing == DoingTargetType)
- {
+ } else if (doing == DoingTargetType) {
this->OptionTargetType = arg;
doing = DoingNone;
- }
- else if(doing == DoingBuildDir)
- {
+ } else if (doing == DoingBuildDir) {
this->OptionBuildDir = arg;
doing = DoingNone;
- }
- else if(doing == DoingFilterPrefix)
- {
+ } else if (doing == DoingFilterPrefix) {
this->OptionFilterPrefix = arg;
doing = DoingNone;
- }
}
+ }
// Extract the real command line.
- if(arg0)
- {
+ if (arg0) {
this->RealArgC = argc - arg0;
this->RealArgV = argv + arg0;
- for(int i=0; i < this->RealArgC; ++i)
- {
+ for (int i = 0; i < this->RealArgC; ++i) {
this->HandleRealArg(this->RealArgV[i]);
- }
- return true;
}
- else
- {
+ return true;
+ } else {
this->RealArgC = 0;
this->RealArgV = 0;
std::cerr << "No launch/command separator ('--') found!\n";
return false;
- }
+ }
}
void cmCTestLaunch::HandleRealArg(const char* arg)
{
#ifdef _WIN32
// Expand response file arguments.
- if(arg[0] == '@' && cmSystemTools::FileExists(arg+1))
- {
- cmsys::ifstream fin(arg+1);
+ if (arg[0] == '@' && cmSystemTools::FileExists(arg + 1)) {
+ cmsys::ifstream fin(arg + 1);
std::string line;
- while(cmSystemTools::GetLineFromStream(fin, line))
- {
+ while (cmSystemTools::GetLineFromStream(fin, line)) {
cmSystemTools::ParseWindowsCommandLine(line.c_str(), this->RealArgs);
- }
- return;
}
+ return;
+ }
#endif
this->RealArgs.push_back(arg);
}
@@ -191,10 +155,9 @@ void cmCTestLaunch::ComputeFileNames()
// We just passthru the behavior of the real command unless the
// CTEST_LAUNCH_LOGS environment variable is set.
const char* d = getenv("CTEST_LAUNCH_LOGS");
- if(!(d && *d))
- {
+ if (!(d && *d)) {
return;
- }
+ }
this->Passthru = false;
// The environment variable specifies the directory into which we
@@ -209,11 +172,10 @@ void cmCTestLaunch::ComputeFileNames()
cmsysMD5* md5 = cmsysMD5_New();
cmsysMD5_Initialize(md5);
cmsysMD5_Append(md5, (unsigned char const*)(this->CWD.c_str()), -1);
- for(std::vector<std::string>::const_iterator ai = this->RealArgs.begin();
- ai != this->RealArgs.end(); ++ai)
- {
+ for (std::vector<std::string>::const_iterator ai = this->RealArgs.begin();
+ ai != this->RealArgs.end(); ++ai) {
cmsysMD5_Append(md5, (unsigned char const*)ai->c_str(), -1);
- }
+ }
cmsysMD5_FinalizeHex(md5, hash);
cmsysMD5_Delete(md5);
this->LogHash.assign(hash, 32);
@@ -232,11 +194,10 @@ void cmCTestLaunch::ComputeFileNames()
void cmCTestLaunch::RunChild()
{
// Ignore noopt make rules
- if(this->RealArgs.empty() || this->RealArgs[0] == ":")
- {
+ if (this->RealArgs.empty() || this->RealArgs[0] == ":") {
this->ExitCode = 0;
return;
- }
+ }
// Prepare to run the real command.
cmsysProcess* cp = this->Process;
@@ -244,20 +205,15 @@ void cmCTestLaunch::RunChild()
cmsys::ofstream fout;
cmsys::ofstream ferr;
- if(this->Passthru)
- {
+ if (this->Passthru) {
// In passthru mode we just share the output pipes.
cmsysProcess_SetPipeShared(cp, cmsysProcess_Pipe_STDOUT, 1);
cmsysProcess_SetPipeShared(cp, cmsysProcess_Pipe_STDERR, 1);
- }
- else
- {
+ } else {
// In full mode we record the child output pipes to log files.
- fout.open(this->LogOut.c_str(),
- std::ios::out | std::ios::binary);
- ferr.open(this->LogErr.c_str(),
- std::ios::out | std::ios::binary);
- }
+ fout.open(this->LogOut.c_str(), std::ios::out | std::ios::binary);
+ ferr.open(this->LogErr.c_str(), std::ios::out | std::ios::binary);
+ }
#ifdef _WIN32
// Do this so that newline transformation is not done when writing to cout
@@ -270,26 +226,21 @@ void cmCTestLaunch::RunChild()
cmsysProcess_Execute(cp);
// Record child stdout and stderr if necessary.
- if(!this->Passthru)
- {
+ if (!this->Passthru) {
char* data = 0;
int length = 0;
- while(int p = cmsysProcess_WaitForData(cp, &data, &length, 0))
- {
- if(p == cmsysProcess_Pipe_STDOUT)
- {
+ while (int p = cmsysProcess_WaitForData(cp, &data, &length, 0)) {
+ if (p == cmsysProcess_Pipe_STDOUT) {
fout.write(data, length);
std::cout.write(data, length);
this->HaveOut = true;
- }
- else if(p == cmsysProcess_Pipe_STDERR)
- {
+ } else if (p == cmsysProcess_Pipe_STDERR) {
ferr.write(data, length);
std::cerr.write(data, length);
this->HaveErr = true;
- }
}
}
+ }
// Wait for the real command to finish.
cmsysProcess_WaitForExit(cp, 0);
@@ -298,18 +249,16 @@ void cmCTestLaunch::RunChild()
int cmCTestLaunch::Run()
{
- if(!this->Process)
- {
+ if (!this->Process) {
std::cerr << "Could not allocate cmsysProcess instance!\n";
return -1;
- }
+ }
this->RunChild();
- if(this->CheckResults())
- {
+ if (this->CheckResults()) {
return this->ExitCode;
- }
+ }
this->LoadConfig();
this->WriteXML();
@@ -319,10 +268,9 @@ int cmCTestLaunch::Run()
void cmCTestLaunch::LoadLabels()
{
- if(this->OptionBuildDir.empty() || this->OptionTargetName.empty())
- {
+ if (this->OptionBuildDir.empty() || this->OptionTargetName.empty()) {
return;
- }
+ }
// Labels are listed in per-target files.
std::string fname = this->OptionBuildDir;
@@ -337,38 +285,31 @@ void cmCTestLaunch::LoadLabels()
// Load the labels file.
cmsys::ifstream fin(fname.c_str(), std::ios::in | std::ios::binary);
- if(!fin) { return; }
+ if (!fin) {
+ return;
+ }
bool inTarget = true;
bool inSource = false;
std::string line;
- while(cmSystemTools::GetLineFromStream(fin, line))
- {
- if(line.empty() || line[0] == '#')
- {
+ while (cmSystemTools::GetLineFromStream(fin, line)) {
+ if (line.empty() || line[0] == '#') {
// Ignore blank and comment lines.
continue;
- }
- else if(line[0] == ' ')
- {
+ } else if (line[0] == ' ') {
// Label lines appear indented by one space.
- if(inTarget || inSource)
- {
- this->Labels.insert(line.c_str()+1);
- }
+ if (inTarget || inSource) {
+ this->Labels.insert(line.c_str() + 1);
}
- else if(!this->OptionSource.empty() && !inSource)
- {
+ } else if (!this->OptionSource.empty() && !inSource) {
// Non-indented lines specify a source file name. The first one
// is the end of the target-wide labels. Use labels following a
// matching source.
inTarget = false;
inSource = this->SourceMatches(line, source);
- }
- else
- {
+ } else {
return;
- }
}
+ }
}
bool cmCTestLaunch::SourceMatches(std::string const& lhs,
@@ -390,7 +331,7 @@ void cmCTestLaunch::WriteXML()
{
// Name the xml file.
std::string logXML = this->LogDir;
- logXML += this->IsError()? "error-" : "warning-";
+ logXML += this->IsError() ? "error-" : "warning-";
logXML += this->LogHash;
logXML += ".xml";
@@ -412,71 +353,54 @@ void cmCTestLaunch::WriteXMLAction(cmXMLWriter& xml)
xml.StartElement("Action");
// TargetName
- if(!this->OptionTargetName.empty())
- {
+ if (!this->OptionTargetName.empty()) {
xml.Element("TargetName", this->OptionTargetName);
- }
+ }
// Language
- if(!this->OptionLanguage.empty())
- {
+ if (!this->OptionLanguage.empty()) {
xml.Element("Language", this->OptionLanguage);
- }
+ }
// SourceFile
- if(!this->OptionSource.empty())
- {
+ if (!this->OptionSource.empty()) {
std::string source = this->OptionSource;
cmSystemTools::ConvertToUnixSlashes(source);
// If file is in source tree use its relative location.
- if(cmSystemTools::FileIsFullPath(this->SourceDir.c_str()) &&
- cmSystemTools::FileIsFullPath(source.c_str()) &&
- cmSystemTools::IsSubDirectory(source,
- this->SourceDir))
- {
- source = cmSystemTools::RelativePath(this->SourceDir.c_str(),
- source.c_str());
- }
+ if (cmSystemTools::FileIsFullPath(this->SourceDir.c_str()) &&
+ cmSystemTools::FileIsFullPath(source.c_str()) &&
+ cmSystemTools::IsSubDirectory(source, this->SourceDir)) {
+ source =
+ cmSystemTools::RelativePath(this->SourceDir.c_str(), source.c_str());
+ }
xml.Element("SourceFile", source);
- }
+ }
// OutputFile
- if(!this->OptionOutput.empty())
- {
+ if (!this->OptionOutput.empty()) {
xml.Element("OutputFile", this->OptionOutput);
- }
+ }
// OutputType
const char* outputType = 0;
- if(!this->OptionTargetType.empty())
- {
- if(this->OptionTargetType == "EXECUTABLE")
- {
+ if (!this->OptionTargetType.empty()) {
+ if (this->OptionTargetType == "EXECUTABLE") {
outputType = "executable";
- }
- else if(this->OptionTargetType == "SHARED_LIBRARY")
- {
+ } else if (this->OptionTargetType == "SHARED_LIBRARY") {
outputType = "shared library";
- }
- else if(this->OptionTargetType == "MODULE_LIBRARY")
- {
+ } else if (this->OptionTargetType == "MODULE_LIBRARY") {
outputType = "module library";
- }
- else if(this->OptionTargetType == "STATIC_LIBRARY")
- {
+ } else if (this->OptionTargetType == "STATIC_LIBRARY") {
outputType = "static library";
- }
}
- else if(!this->OptionSource.empty())
- {
+ } else if (!this->OptionSource.empty()) {
outputType = "object file";
- }
- if(outputType)
- {
+ }
+ if (outputType) {
xml.Element("OutputType", outputType);
- }
+ }
xml.EndElement(); // Action
}
@@ -485,15 +409,13 @@ void cmCTestLaunch::WriteXMLCommand(cmXMLWriter& xml)
{
xml.Comment("Details of command");
xml.StartElement("Command");
- if(!this->CWD.empty())
- {
+ if (!this->CWD.empty()) {
xml.Element("WorkingDirectory", this->CWD);
- }
- for(std::vector<std::string>::const_iterator ai = this->RealArgs.begin();
- ai != this->RealArgs.end(); ++ai)
- {
+ }
+ for (std::vector<std::string>::const_iterator ai = this->RealArgs.begin();
+ ai != this->RealArgs.end(); ++ai) {
xml.Element("Argument", *ai);
- }
+ }
xml.EndElement(); // Command
}
@@ -515,28 +437,35 @@ void cmCTestLaunch::WriteXMLResult(cmXMLWriter& xml)
// ExitCondition
xml.StartElement("ExitCondition");
cmsysProcess* cp = this->Process;
- switch (cmsysProcess_GetState(cp))
- {
+ switch (cmsysProcess_GetState(cp)) {
case cmsysProcess_State_Starting:
- xml.Content("No process has been executed"); break;
+ xml.Content("No process has been executed");
+ break;
case cmsysProcess_State_Executing:
- xml.Content("The process is still executing"); break;
+ xml.Content("The process is still executing");
+ break;
case cmsysProcess_State_Disowned:
- xml.Content("Disowned"); break;
+ xml.Content("Disowned");
+ break;
case cmsysProcess_State_Killed:
- xml.Content("Killed by parent"); break;
+ xml.Content("Killed by parent");
+ break;
case cmsysProcess_State_Expired:
- xml.Content("Killed when timeout expired"); break;
+ xml.Content("Killed when timeout expired");
+ break;
case cmsysProcess_State_Exited:
- xml.Content(this->ExitCode); break;
+ xml.Content(this->ExitCode);
+ break;
case cmsysProcess_State_Exception:
xml.Content("Terminated abnormally: ");
- xml.Content(cmsysProcess_GetExceptionString(cp)); break;
+ xml.Content(cmsysProcess_GetExceptionString(cp));
+ break;
case cmsysProcess_State_Error:
xml.Content("Error administrating child process: ");
- xml.Content(cmsysProcess_GetErrorString(cp)); break;
- };
+ xml.Content(cmsysProcess_GetErrorString(cp));
+ break;
+ };
xml.EndElement(); // ExitCondition
xml.EndElement(); // Result
@@ -545,69 +474,60 @@ void cmCTestLaunch::WriteXMLResult(cmXMLWriter& xml)
void cmCTestLaunch::WriteXMLLabels(cmXMLWriter& xml)
{
this->LoadLabels();
- if(!this->Labels.empty())
- {
+ if (!this->Labels.empty()) {
xml.Comment("Interested parties");
xml.StartElement("Labels");
- for(std::set<std::string>::const_iterator li = this->Labels.begin();
- li != this->Labels.end(); ++li)
- {
+ for (std::set<std::string>::const_iterator li = this->Labels.begin();
+ li != this->Labels.end(); ++li) {
xml.Element("Label", *li);
- }
- xml.EndElement(); // Labels
}
+ xml.EndElement(); // Labels
+ }
}
-void cmCTestLaunch::DumpFileToXML(cmXMLWriter& xml,
- std::string const& fname)
+void cmCTestLaunch::DumpFileToXML(cmXMLWriter& xml, std::string const& fname)
{
cmsys::ifstream fin(fname.c_str(), std::ios::in | std::ios::binary);
std::string line;
const char* sep = "";
- while(cmSystemTools::GetLineFromStream(fin, line))
- {
- if(MatchesFilterPrefix(line))
- {
+ while (cmSystemTools::GetLineFromStream(fin, line)) {
+ if (MatchesFilterPrefix(line)) {
continue;
- }
+ }
xml.Content(sep);
xml.Content(line);
sep = "\n";
- }
+ }
}
bool cmCTestLaunch::CheckResults()
{
// Skip XML in passthru mode.
- if(this->Passthru)
- {
+ if (this->Passthru) {
return true;
- }
+ }
// We always report failure for error conditions.
- if(this->IsError())
- {
+ if (this->IsError()) {
return false;
- }
+ }
// Scrape the output logs to look for warnings.
- if((this->HaveErr && this->ScrapeLog(this->LogErr)) ||
- (this->HaveOut && this->ScrapeLog(this->LogOut)))
- {
+ if ((this->HaveErr && this->ScrapeLog(this->LogErr)) ||
+ (this->HaveOut && this->ScrapeLog(this->LogOut))) {
return false;
- }
+ }
return true;
}
void cmCTestLaunch::LoadScrapeRules()
{
- if(this->ScrapeRulesLoaded)
- {
+ if (this->ScrapeRulesLoaded) {
return;
- }
+ }
this->ScrapeRulesLoaded = true;
// Common compiler warning formats. These are much simpler than the
@@ -622,10 +542,8 @@ void cmCTestLaunch::LoadScrapeRules()
this->LoadScrapeRules("WarningSuppress", this->RegexWarningSuppress);
}
-void
-cmCTestLaunch
-::LoadScrapeRules(const char* purpose,
- std::vector<cmsys::RegularExpression>& regexps)
+void cmCTestLaunch::LoadScrapeRules(
+ const char* purpose, std::vector<cmsys::RegularExpression>& regexps)
{
std::string fname = this->LogDir;
fname += "Custom";
@@ -634,13 +552,11 @@ cmCTestLaunch
cmsys::ifstream fin(fname.c_str(), std::ios::in | std::ios::binary);
std::string line;
cmsys::RegularExpression rex;
- while(cmSystemTools::GetLineFromStream(fin, line))
- {
- if(rex.compile(line.c_str()))
- {
+ while (cmSystemTools::GetLineFromStream(fin, line)) {
+ if (rex.compile(line.c_str())) {
regexps.push_back(rex);
- }
}
+ }
}
bool cmCTestLaunch::ScrapeLog(std::string const& fname)
@@ -651,54 +567,48 @@ bool cmCTestLaunch::ScrapeLog(std::string const& fname)
// suppression expressions.
cmsys::ifstream fin(fname.c_str(), std::ios::in | std::ios::binary);
std::string line;
- while(cmSystemTools::GetLineFromStream(fin, line))
- {
- if(MatchesFilterPrefix(line))
- {
+ while (cmSystemTools::GetLineFromStream(fin, line)) {
+ if (MatchesFilterPrefix(line)) {
continue;
- }
+ }
- if(this->Match(line, this->RegexWarning) &&
- !this->Match(line, this->RegexWarningSuppress))
- {
+ if (this->Match(line, this->RegexWarning) &&
+ !this->Match(line, this->RegexWarningSuppress)) {
return true;
- }
}
+ }
return false;
}
bool cmCTestLaunch::Match(std::string const& line,
std::vector<cmsys::RegularExpression>& regexps)
{
- for(std::vector<cmsys::RegularExpression>::iterator ri = regexps.begin();
- ri != regexps.end(); ++ri)
- {
- if(ri->find(line.c_str()))
- {
+ for (std::vector<cmsys::RegularExpression>::iterator ri = regexps.begin();
+ ri != regexps.end(); ++ri) {
+ if (ri->find(line.c_str())) {
return true;
- }
}
+ }
return false;
}
bool cmCTestLaunch::MatchesFilterPrefix(std::string const& line) const
{
- if(!this->OptionFilterPrefix.empty() && cmSystemTools::StringStartsWith(
- line.c_str(), this->OptionFilterPrefix.c_str()))
- {
+ if (!this->OptionFilterPrefix.empty() &&
+ cmSystemTools::StringStartsWith(line.c_str(),
+ this->OptionFilterPrefix.c_str())) {
return true;
- }
+ }
return false;
}
int cmCTestLaunch::Main(int argc, const char* const argv[])
{
- if(argc == 2)
- {
+ if (argc == 2) {
std::cerr << "ctest --launch: this mode is for internal CTest use only"
<< std::endl;
return 1;
- }
+ }
cmCTestLaunch self(argc, argv);
return self.Run();
}
@@ -717,10 +627,9 @@ void cmCTestLaunch::LoadConfig()
cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(&gg, cm.GetCurrentSnapshot()));
std::string fname = this->LogDir;
fname += "CTestLaunchConfig.cmake";
- if(cmSystemTools::FileExists(fname.c_str()) &&
- mf->ReadListFile(fname.c_str()))
- {
+ if (cmSystemTools::FileExists(fname.c_str()) &&
+ mf->ReadListFile(fname.c_str())) {
this->SourceDir = mf->GetSafeDefinition("CTEST_SOURCE_DIRECTORY");
cmSystemTools::ConvertToUnixSlashes(this->SourceDir);
- }
+ }
}
diff --git a/Source/CTest/cmCTestLaunch.h b/Source/CTest/cmCTestLaunch.h
index 1a908a3..cbcc9ec 100644
--- a/Source/CTest/cmCTestLaunch.h
+++ b/Source/CTest/cmCTestLaunch.h
@@ -28,6 +28,7 @@ class cmCTestLaunch
public:
/** Entry point from ctest executable main(). */
static int Main(int argc, const char* const argv[]);
+
private:
// Initialize the launcher from its command line.
cmCTestLaunch(int argc, const char* const* argv);
@@ -78,8 +79,7 @@ private:
// Labels associated with the build rule.
std::set<std::string> Labels;
void LoadLabels();
- bool SourceMatches(std::string const& lhs,
- std::string const& rhs);
+ bool SourceMatches(std::string const& lhs, std::string const& rhs);
// Regular expressions to match warnings and their exceptions.
bool ScrapeRulesLoaded;
diff --git a/Source/CTest/cmCTestMemCheckCommand.cxx b/Source/CTest/cmCTestMemCheckCommand.cxx
index b379d32..d53dcd0 100644
--- a/Source/CTest/cmCTestMemCheckCommand.cxx
+++ b/Source/CTest/cmCTestMemCheckCommand.cxx
@@ -14,27 +14,26 @@
#include "cmCTest.h"
#include "cmCTestGenericHandler.h"
-
cmCTestGenericHandler* cmCTestMemCheckCommand::InitializeActualHandler()
{
- cmCTestGenericHandler* handler
- = this->CTest->GetInitializedHandler("memcheck");
-
- this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
- "MemoryCheckType", "CTEST_MEMORYCHECK_TYPE", this->Quiet);
- this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
- "MemoryCheckSanitizerOptions", "CTEST_MEMORYCHECK_SANITIZER_OPTIONS",
- this->Quiet);
- this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
- "MemoryCheckCommand", "CTEST_MEMORYCHECK_COMMAND", this->Quiet);
- this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
- "MemoryCheckCommandOptions", "CTEST_MEMORYCHECK_COMMAND_OPTIONS",
- this->Quiet);
- this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
- "MemoryCheckSuppressionFile", "CTEST_MEMORYCHECK_SUPPRESSIONS_FILE",
+ cmCTestGenericHandler* handler =
+ this->CTest->GetInitializedHandler("memcheck");
+
+ this->CTest->SetCTestConfigurationFromCMakeVariable(
+ this->Makefile, "MemoryCheckType", "CTEST_MEMORYCHECK_TYPE", this->Quiet);
+ this->CTest->SetCTestConfigurationFromCMakeVariable(
+ this->Makefile, "MemoryCheckSanitizerOptions",
+ "CTEST_MEMORYCHECK_SANITIZER_OPTIONS", this->Quiet);
+ this->CTest->SetCTestConfigurationFromCMakeVariable(
+ this->Makefile, "MemoryCheckCommand", "CTEST_MEMORYCHECK_COMMAND",
this->Quiet);
+ this->CTest->SetCTestConfigurationFromCMakeVariable(
+ this->Makefile, "MemoryCheckCommandOptions",
+ "CTEST_MEMORYCHECK_COMMAND_OPTIONS", this->Quiet);
+ this->CTest->SetCTestConfigurationFromCMakeVariable(
+ this->Makefile, "MemoryCheckSuppressionFile",
+ "CTEST_MEMORYCHECK_SUPPRESSIONS_FILE", this->Quiet);
handler->SetQuiet(this->Quiet);
return handler;
}
-
diff --git a/Source/CTest/cmCTestMemCheckCommand.h b/Source/CTest/cmCTestMemCheckCommand.h
index e239d46..245892c 100644
--- a/Source/CTest/cmCTestMemCheckCommand.h
+++ b/Source/CTest/cmCTestMemCheckCommand.h
@@ -24,24 +24,23 @@ class cmCTestGenericHandler;
class cmCTestMemCheckCommand : public cmCTestTestCommand
{
public:
-
cmCTestMemCheckCommand() {}
/**
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
- {
+ {
cmCTestMemCheckCommand* ni = new cmCTestMemCheckCommand;
ni->CTest = this->CTest;
ni->CTestScriptHandler = this->CTestScriptHandler;
return ni;
- }
+ }
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const { return "ctest_memcheck";}
+ virtual std::string GetName() const { return "ctest_memcheck"; }
cmTypeMacro(cmCTestMemCheckCommand, cmCTestTestCommand);
@@ -49,6 +48,4 @@ protected:
cmCTestGenericHandler* InitializeActualHandler();
};
-
#endif
-
diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx
index dd2a5b8..2cbd64d 100644
--- a/Source/CTest/cmCTestMemCheckHandler.cxx
+++ b/Source/CTest/cmCTestMemCheckHandler.cxx
@@ -34,24 +34,22 @@ struct CatToErrorType
int ErrorCode;
};
-
static CatToErrorType cmCTestMemCheckBoundsChecker[] = {
// Error tags
- {"Write Overrun", cmCTestMemCheckHandler::ABW},
- {"Read Overrun", cmCTestMemCheckHandler::ABR},
- {"Memory Overrun", cmCTestMemCheckHandler::ABW},
- {"Allocation Conflict", cmCTestMemCheckHandler::FMM},
- {"Bad Pointer Use", cmCTestMemCheckHandler::FMW},
- {"Dangling Pointer", cmCTestMemCheckHandler::FMR},
- {0,0}
+ { "Write Overrun", cmCTestMemCheckHandler::ABW },
+ { "Read Overrun", cmCTestMemCheckHandler::ABR },
+ { "Memory Overrun", cmCTestMemCheckHandler::ABW },
+ { "Allocation Conflict", cmCTestMemCheckHandler::FMM },
+ { "Bad Pointer Use", cmCTestMemCheckHandler::FMW },
+ { "Dangling Pointer", cmCTestMemCheckHandler::FMR },
+ { 0, 0 }
};
static void xmlReportError(int line, const char* msg, void* data)
{
cmCTest* ctest = (cmCTest*)data;
- cmCTestLog(ctest, ERROR_MESSAGE,
- "Error parsing XML in stream at line "
- << line << ": " << msg << std::endl);
+ cmCTestLog(ctest, ERROR_MESSAGE, "Error parsing XML in stream at line "
+ << line << ": " << msg << std::endl);
}
// parse the xml file containing the results of last BoundsChecker run
@@ -59,87 +57,70 @@ class cmBoundsCheckerParser : public cmXMLParser
{
public:
cmBoundsCheckerParser(cmCTest* c)
- {
- this->CTest = c;
- this->SetErrorCallback(xmlReportError, (void*)c);
- }
+ {
+ this->CTest = c;
+ this->SetErrorCallback(xmlReportError, (void*)c);
+ }
void StartElement(const std::string& name, const char** atts)
- {
- if(name == "MemoryLeak" ||
- name == "ResourceLeak")
- {
- this->Errors.push_back(cmCTestMemCheckHandler::MLK);
- }
- else if(name == "Error" ||
- name == "Dangling Pointer")
- {
- this->ParseError(atts);
- }
- // Create the log
- std::ostringstream ostr;
- ostr << name << ":\n";
- int i = 0;
- for(; atts[i] != 0; i+=2)
- {
- ostr << " " << atts[i]
- << " - " << atts[i+1] << "\n";
- }
- ostr << "\n";
- this->Log += ostr.str();
+ {
+ if (name == "MemoryLeak" || name == "ResourceLeak") {
+ this->Errors.push_back(cmCTestMemCheckHandler::MLK);
+ } else if (name == "Error" || name == "Dangling Pointer") {
+ this->ParseError(atts);
}
- void EndElement(const std::string& )
- {
+ // Create the log
+ std::ostringstream ostr;
+ ostr << name << ":\n";
+ int i = 0;
+ for (; atts[i] != 0; i += 2) {
+ ostr << " " << atts[i] << " - " << atts[i + 1] << "\n";
}
+ ostr << "\n";
+ this->Log += ostr.str();
+ }
+ void EndElement(const std::string&) {}
const char* GetAttribute(const char* name, const char** atts)
- {
- int i = 0;
- for(; atts[i] != 0; ++i)
- {
- if(strcmp(name, atts[i]) == 0)
- {
- return atts[i+1];
- }
- }
- return 0;
+ {
+ int i = 0;
+ for (; atts[i] != 0; ++i) {
+ if (strcmp(name, atts[i]) == 0) {
+ return atts[i + 1];
+ }
}
+ return 0;
+ }
void ParseError(const char** atts)
- {
- CatToErrorType* ptr = cmCTestMemCheckBoundsChecker;
- const char* cat = this->GetAttribute("ErrorCategory", atts);
- if(!cat)
- {
- this->Errors.push_back(cmCTestMemCheckHandler::ABW); // do not know
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "No Category found in Bounds checker XML\n" );
- return;
- }
- while(ptr->ErrorCategory && cat)
- {
- if(strcmp(ptr->ErrorCategory, cat) == 0)
- {
- this->Errors.push_back(ptr->ErrorCode);
- return; // found it we are done
- }
- ptr++;
- }
- if(ptr->ErrorCategory)
- {
- this->Errors.push_back(cmCTestMemCheckHandler::ABW); // do not know
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Found unknown Bounds Checker error "
- << ptr->ErrorCategory << std::endl);
- }
+ {
+ CatToErrorType* ptr = cmCTestMemCheckBoundsChecker;
+ const char* cat = this->GetAttribute("ErrorCategory", atts);
+ if (!cat) {
+ this->Errors.push_back(cmCTestMemCheckHandler::ABW); // do not know
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "No Category found in Bounds checker XML\n");
+ return;
+ }
+ while (ptr->ErrorCategory && cat) {
+ if (strcmp(ptr->ErrorCategory, cat) == 0) {
+ this->Errors.push_back(ptr->ErrorCode);
+ return; // found it we are done
+ }
+ ptr++;
}
+ if (ptr->ErrorCategory) {
+ this->Errors.push_back(cmCTestMemCheckHandler::ABW); // do not know
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Found unknown Bounds Checker error " << ptr->ErrorCategory
+ << std::endl);
+ }
+ }
cmCTest* CTest;
std::vector<int> Errors;
std::string Log;
};
-#define BOUNDS_CHECKER_MARKER \
-"******######*****Begin BOUNDS CHECKER XML******######******"
-
-
+#define BOUNDS_CHECKER_MARKER \
+ "******######*****Begin BOUNDS CHECKER XML******######******"
cmCTestMemCheckHandler::cmCTestMemCheckHandler()
{
@@ -164,28 +145,25 @@ void cmCTestMemCheckHandler::Initialize()
int cmCTestMemCheckHandler::PreProcessHandler()
{
- if ( !this->InitializeMemoryChecking() )
- {
+ if (!this->InitializeMemoryChecking()) {
return 0;
- }
+ }
- if ( !this->ExecuteCommands(this->CustomPreMemCheck) )
- {
+ if (!this->ExecuteCommands(this->CustomPreMemCheck)) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Problem executing pre-memcheck command(s)." << std::endl);
+ "Problem executing pre-memcheck command(s)." << std::endl);
return 0;
- }
+ }
return 1;
}
int cmCTestMemCheckHandler::PostProcessHandler()
{
- if ( !this->ExecuteCommands(this->CustomPostMemCheck) )
- {
+ if (!this->ExecuteCommands(this->CustomPostMemCheck)) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Problem executing post-memcheck command(s)." << std::endl);
+ "Problem executing post-memcheck command(s)." << std::endl);
return 0;
- }
+ }
return 1;
}
@@ -195,104 +173,77 @@ void cmCTestMemCheckHandler::GenerateTestCommand(
std::vector<std::string>::size_type pp;
std::string index;
std::ostringstream stream;
- std::string memcheckcommand
- = cmSystemTools::ConvertToOutputPath(this->MemoryTester.c_str());
+ std::string memcheckcommand =
+ cmSystemTools::ConvertToOutputPath(this->MemoryTester.c_str());
stream << test;
index = stream.str();
- for ( pp = 0; pp < this->MemoryTesterDynamicOptions.size(); pp ++ )
- {
+ for (pp = 0; pp < this->MemoryTesterDynamicOptions.size(); pp++) {
std::string arg = this->MemoryTesterDynamicOptions[pp];
std::string::size_type pos = arg.find("??");
- if (pos != std::string::npos)
- {
+ if (pos != std::string::npos) {
arg.replace(pos, 2, index);
- }
+ }
args.push_back(arg);
memcheckcommand += " \"";
memcheckcommand += arg;
memcheckcommand += "\"";
- }
+ }
// Create a copy of the memory tester environment variable.
// This is used for memory testing programs that pass options
// via environment varaibles.
std::string memTesterEnvironmentVariable =
this->MemoryTesterEnvironmentVariable;
- for ( pp = 0; pp < this->MemoryTesterOptions.size(); pp ++ )
- {
- if(!memTesterEnvironmentVariable.empty())
- {
+ for (pp = 0; pp < this->MemoryTesterOptions.size(); pp++) {
+ if (!memTesterEnvironmentVariable.empty()) {
// If we are using env to pass options, append all the options to
// this string with space separation.
memTesterEnvironmentVariable += " " + this->MemoryTesterOptions[pp];
- }
+ }
// for regular options just add them to args and memcheckcommand
// which is just used for display
- else
- {
+ else {
args.push_back(this->MemoryTesterOptions[pp]);
memcheckcommand += " \"";
memcheckcommand += this->MemoryTesterOptions[pp];
memcheckcommand += "\"";
- }
}
+ }
// if this is an env option type, then add the env string as a single
// argument.
- if(!memTesterEnvironmentVariable.empty())
- {
+ if (!memTesterEnvironmentVariable.empty()) {
std::string::size_type pos = memTesterEnvironmentVariable.find("??");
- if (pos != std::string::npos)
- {
+ if (pos != std::string::npos) {
memTesterEnvironmentVariable.replace(pos, 2, index);
- }
+ }
memcheckcommand += " " + memTesterEnvironmentVariable;
args.push_back(memTesterEnvironmentVariable);
- }
+ }
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Memory check command: " << memcheckcommand << std::endl, this->Quiet);
+ "Memory check command: " << memcheckcommand << std::endl,
+ this->Quiet);
}
void cmCTestMemCheckHandler::InitializeResultsVectors()
{
// fill these members
-// cmsys::vector<std::string> ResultStrings;
-// cmsys::vector<std::string> ResultStringsLong;
-// cmsys::vector<int> GlobalResults;
+ // cmsys::vector<std::string> ResultStrings;
+ // cmsys::vector<std::string> ResultStringsLong;
+ // cmsys::vector<int> GlobalResults;
this->ResultStringsLong.clear();
this->ResultStrings.clear();
this->GlobalResults.clear();
// If we are working with style checkers that dynamically fill
// the results strings then return.
- if(this->MemoryTesterStyle > cmCTestMemCheckHandler::BOUNDS_CHECKER)
- {
+ if (this->MemoryTesterStyle > cmCTestMemCheckHandler::BOUNDS_CHECKER) {
return;
- }
+ }
// define the standard set of errors
//----------------------------------------------------------------------
static const char* cmCTestMemCheckResultStrings[] = {
- "ABR",
- "ABW",
- "ABWL",
- "COR",
- "EXU",
- "FFM",
- "FIM",
- "FMM",
- "FMR",
- "FMW",
- "FUM",
- "IPR",
- "IPW",
- "MAF",
- "MLK",
- "MPK",
- "NPR",
- "ODS",
- "PAR",
- "PLK",
- "UMC",
- "UMR",
- 0
+ "ABR", "ABW", "ABWL", "COR", "EXU", "FFM", "FIM", "FMM",
+ "FMR", "FMW", "FUM", "IPR", "IPW", "MAF", "MLK", "MPK",
+ "NPR", "ODS", "PAR", "PLK", "UMC", "UMR", 0
};
static const char* cmCTestMemCheckResultLongStrings[] = {
"Threading Problem",
@@ -320,40 +271,36 @@ void cmCTestMemCheckHandler::InitializeResultsVectors()
0
};
this->GlobalResults.clear();
- for(int i =0; cmCTestMemCheckResultStrings[i] != 0; ++i)
- {
+ for (int i = 0; cmCTestMemCheckResultStrings[i] != 0; ++i) {
this->ResultStrings.push_back(cmCTestMemCheckResultStrings[i]);
this->ResultStringsLong.push_back(cmCTestMemCheckResultLongStrings[i]);
this->GlobalResults.push_back(0);
- }
+ }
}
-void cmCTestMemCheckHandler::PopulateCustomVectors(cmMakefile *mf)
+void cmCTestMemCheckHandler::PopulateCustomVectors(cmMakefile* mf)
{
this->cmCTestTestHandler::PopulateCustomVectors(mf);
this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_PRE_MEMCHECK",
- this->CustomPreMemCheck);
+ this->CustomPreMemCheck);
this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_POST_MEMCHECK",
- this->CustomPostMemCheck);
+ this->CustomPostMemCheck);
- this->CTest->PopulateCustomVector(mf,
- "CTEST_CUSTOM_MEMCHECK_IGNORE",
- this->CustomTestsIgnore);
+ this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_MEMCHECK_IGNORE",
+ this->CustomTestsIgnore);
std::string cmake = cmSystemTools::GetCMakeCommand();
this->CTest->SetCTestConfiguration("CMakeCommand", cmake.c_str(),
- this->Quiet);
+ this->Quiet);
}
void cmCTestMemCheckHandler::GenerateDartOutput(cmXMLWriter& xml)
{
- if ( !this->CTest->GetProduceXML() )
- {
+ if (!this->CTest->GetProduceXML()) {
return;
- }
+ }
this->CTest->StartXML(xml, this->AppendXML);
xml.StartElement("DynamicAnalysis");
- switch ( this->MemoryTesterStyle )
- {
+ switch (this->MemoryTesterStyle) {
case cmCTestMemCheckHandler::VALGRIND:
xml.Attribute("Checker", "Valgrind");
break;
@@ -377,98 +324,91 @@ void cmCTestMemCheckHandler::GenerateDartOutput(cmXMLWriter& xml)
break;
default:
xml.Attribute("Checker", "Unknown");
- }
+ }
xml.Element("StartDateTime", this->StartTest);
xml.Element("StartTestTime", this->StartTestTime);
xml.StartElement("TestList");
cmCTestMemCheckHandler::TestResultsVector::size_type cc;
- for ( cc = 0; cc < this->TestResults.size(); cc ++ )
- {
- cmCTestTestResult *result = &this->TestResults[cc];
+ for (cc = 0; cc < this->TestResults.size(); cc++) {
+ cmCTestTestResult* result = &this->TestResults[cc];
std::string testPath = result->Path + "/" + result->Name;
xml.Element("Test", this->CTest->GetShortPathToFile(testPath.c_str()));
- }
+ }
xml.EndElement(); // TestList
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- "-- Processing memory checking output: ", this->Quiet);
+ "-- Processing memory checking output: ", this->Quiet);
size_t total = this->TestResults.size();
size_t step = total / 10;
size_t current = 0;
- for ( cc = 0; cc < this->TestResults.size(); cc ++ )
- {
- cmCTestTestResult *result = &this->TestResults[cc];
+ for (cc = 0; cc < this->TestResults.size(); cc++) {
+ cmCTestTestResult* result = &this->TestResults[cc];
std::string memcheckstr;
std::vector<int> memcheckresults(this->ResultStrings.size(), 0);
bool res = this->ProcessMemCheckOutput(result->Output, memcheckstr,
- memcheckresults);
- if ( res && result->Status == cmCTestMemCheckHandler::COMPLETED )
- {
+ memcheckresults);
+ if (res && result->Status == cmCTestMemCheckHandler::COMPLETED) {
continue;
- }
- this->CleanTestOutput(memcheckstr,
+ }
+ this->CleanTestOutput(
+ memcheckstr,
static_cast<size_t>(this->CustomMaximumFailedTestOutputSize));
this->WriteTestResultHeader(xml, result);
xml.StartElement("Results");
- for(std::vector<int>::size_type kk = 0;
- kk < memcheckresults.size(); ++kk)
- {
- if ( memcheckresults[kk] )
- {
+ for (std::vector<int>::size_type kk = 0; kk < memcheckresults.size();
+ ++kk) {
+ if (memcheckresults[kk]) {
xml.StartElement("Defect");
xml.Attribute("type", this->ResultStringsLong[kk]);
xml.Content(memcheckresults[kk]);
xml.EndElement(); // Defect
- }
- this->GlobalResults[kk] += memcheckresults[kk];
}
+ this->GlobalResults[kk] += memcheckresults[kk];
+ }
xml.EndElement(); // Results
xml.StartElement("Log");
- if(this->CTest->ShouldCompressMemCheckOutput())
- {
+ if (this->CTest->ShouldCompressMemCheckOutput()) {
this->CTest->CompressString(memcheckstr);
xml.Attribute("compression", "gzip");
xml.Attribute("encoding", "base64");
- }
+ }
xml.Content(memcheckstr);
xml.EndElement(); // Log
this->WriteTestResultFooter(xml, result);
- if ( current < cc )
- {
+ if (current < cc) {
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "#" << std::flush,
- this->Quiet);
+ this->Quiet);
current += step;
- }
}
+ }
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, std::endl, this->Quiet);
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "Memory checking results:"
- << std::endl, this->Quiet);
+ cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+ "Memory checking results:" << std::endl, this->Quiet);
xml.StartElement("DefectList");
- for ( cc = 0; cc < this->GlobalResults.size(); cc ++ )
- {
- if ( this->GlobalResults[cc] )
- {
+ for (cc = 0; cc < this->GlobalResults.size(); cc++) {
+ if (this->GlobalResults[cc]) {
#ifdef cerr
-# undef cerr
+#undef cerr
#endif
std::cerr.width(35);
#define cerr no_cerr
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- this->ResultStringsLong[cc] << " - "
- << this->GlobalResults[cc] << std::endl, this->Quiet);
+ this->ResultStringsLong[cc]
+ << " - " << this->GlobalResults[cc] << std::endl,
+ this->Quiet);
xml.StartElement("Defect");
xml.Attribute("Type", this->ResultStringsLong[cc]);
xml.EndElement();
- }
}
+ }
xml.EndElement(); // DefectList
xml.Element("EndDateTime", this->EndTest);
xml.Element("EndTestTime", this->EndTestTime);
xml.Element("ElapsedMinutes",
- static_cast<int>(this->ElapsedTestingTime/6)/10.0);
+ static_cast<int>(this->ElapsedTestingTime / 6) / 10.0);
xml.EndElement(); // DynamicAnalysis
this->CTest->EndXML(xml);
@@ -479,187 +419,156 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
this->MemoryTesterEnvironmentVariable = "";
this->MemoryTester = "";
// Setup the command
- if ( cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
- "MemoryCheckCommand").c_str()) )
- {
- this->MemoryTester
- = this->CTest->GetCTestConfiguration("MemoryCheckCommand").c_str();
+ if (cmSystemTools::FileExists(
+ this->CTest->GetCTestConfiguration("MemoryCheckCommand").c_str())) {
+ this->MemoryTester =
+ this->CTest->GetCTestConfiguration("MemoryCheckCommand").c_str();
std::string testerName =
cmSystemTools::GetFilenameName(this->MemoryTester);
// determine the checker type
- if ( testerName.find("valgrind") != std::string::npos ||
- this->CTest->GetCTestConfiguration("MemoryCheckType")
- == "Valgrind")
- {
- this->MemoryTesterStyle = cmCTestMemCheckHandler::VALGRIND;
- }
- else if ( testerName.find("purify") != std::string::npos )
- {
+ if (testerName.find("valgrind") != std::string::npos ||
+ this->CTest->GetCTestConfiguration("MemoryCheckType") == "Valgrind") {
+ this->MemoryTesterStyle = cmCTestMemCheckHandler::VALGRIND;
+ } else if (testerName.find("purify") != std::string::npos) {
this->MemoryTesterStyle = cmCTestMemCheckHandler::PURIFY;
- }
- else if ( testerName.find("BC") != std::string::npos )
- {
+ } else if (testerName.find("BC") != std::string::npos) {
this->MemoryTesterStyle = cmCTestMemCheckHandler::BOUNDS_CHECKER;
- }
- else
- {
+ } else {
this->MemoryTesterStyle = cmCTestMemCheckHandler::UNKNOWN;
- }
}
- else if ( cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
- "PurifyCommand").c_str()) )
- {
- this->MemoryTester
- = this->CTest->GetCTestConfiguration("PurifyCommand").c_str();
+ } else if (cmSystemTools::FileExists(
+ this->CTest->GetCTestConfiguration("PurifyCommand").c_str())) {
+ this->MemoryTester =
+ this->CTest->GetCTestConfiguration("PurifyCommand").c_str();
this->MemoryTesterStyle = cmCTestMemCheckHandler::PURIFY;
- }
- else if ( cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
- "ValgrindCommand").c_str()) )
- {
- this->MemoryTester
- = this->CTest->GetCTestConfiguration("ValgrindCommand").c_str();
+ } else if (cmSystemTools::FileExists(
+ this->CTest->GetCTestConfiguration("ValgrindCommand")
+ .c_str())) {
+ this->MemoryTester =
+ this->CTest->GetCTestConfiguration("ValgrindCommand").c_str();
this->MemoryTesterStyle = cmCTestMemCheckHandler::VALGRIND;
- }
- else if ( cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
- "BoundsCheckerCommand").c_str()) )
- {
- this->MemoryTester
- = this->CTest->GetCTestConfiguration("BoundsCheckerCommand").c_str();
+ } else if (cmSystemTools::FileExists(
+ this->CTest->GetCTestConfiguration("BoundsCheckerCommand")
+ .c_str())) {
+ this->MemoryTester =
+ this->CTest->GetCTestConfiguration("BoundsCheckerCommand").c_str();
this->MemoryTesterStyle = cmCTestMemCheckHandler::BOUNDS_CHECKER;
- }
- if ( this->CTest->GetCTestConfiguration("MemoryCheckType")
- == "AddressSanitizer")
- {
- this->MemoryTester
- = this->CTest->GetCTestConfiguration("CMakeCommand").c_str();
+ }
+ if (this->CTest->GetCTestConfiguration("MemoryCheckType") ==
+ "AddressSanitizer") {
+ this->MemoryTester =
+ this->CTest->GetCTestConfiguration("CMakeCommand").c_str();
this->MemoryTesterStyle = cmCTestMemCheckHandler::ADDRESS_SANITIZER;
this->LogWithPID = true; // even if we give the log file the pid is added
- }
- if ( this->CTest->GetCTestConfiguration("MemoryCheckType")
- == "ThreadSanitizer")
- {
- this->MemoryTester
- = this->CTest->GetCTestConfiguration("CMakeCommand").c_str();
+ }
+ if (this->CTest->GetCTestConfiguration("MemoryCheckType") ==
+ "ThreadSanitizer") {
+ this->MemoryTester =
+ this->CTest->GetCTestConfiguration("CMakeCommand").c_str();
this->MemoryTesterStyle = cmCTestMemCheckHandler::THREAD_SANITIZER;
this->LogWithPID = true; // even if we give the log file the pid is added
- }
- if ( this->CTest->GetCTestConfiguration("MemoryCheckType")
- == "MemorySanitizer")
- {
- this->MemoryTester
- = this->CTest->GetCTestConfiguration("CMakeCommand").c_str();
+ }
+ if (this->CTest->GetCTestConfiguration("MemoryCheckType") ==
+ "MemorySanitizer") {
+ this->MemoryTester =
+ this->CTest->GetCTestConfiguration("CMakeCommand").c_str();
this->MemoryTesterStyle = cmCTestMemCheckHandler::MEMORY_SANITIZER;
this->LogWithPID = true; // even if we give the log file the pid is added
- }
- if ( this->CTest->GetCTestConfiguration("MemoryCheckType")
- == "UndefinedBehaviorSanitizer")
- {
- this->MemoryTester
- = this->CTest->GetCTestConfiguration("CMakeCommand").c_str();
+ }
+ if (this->CTest->GetCTestConfiguration("MemoryCheckType") ==
+ "UndefinedBehaviorSanitizer") {
+ this->MemoryTester =
+ this->CTest->GetCTestConfiguration("CMakeCommand").c_str();
this->MemoryTesterStyle = cmCTestMemCheckHandler::UB_SANITIZER;
this->LogWithPID = true; // even if we give the log file the pid is added
- }
+ }
// Check the MemoryCheckType
- if(this->MemoryTesterStyle == cmCTestMemCheckHandler::UNKNOWN)
- {
+ if (this->MemoryTesterStyle == cmCTestMemCheckHandler::UNKNOWN) {
std::string checkType =
this->CTest->GetCTestConfiguration("MemoryCheckType");
- if(checkType == "Purify")
- {
+ if (checkType == "Purify") {
this->MemoryTesterStyle = cmCTestMemCheckHandler::PURIFY;
- }
- else if(checkType == "BoundsChecker")
- {
+ } else if (checkType == "BoundsChecker") {
this->MemoryTesterStyle = cmCTestMemCheckHandler::BOUNDS_CHECKER;
- }
- else if(checkType == "Valgrind")
- {
+ } else if (checkType == "Valgrind") {
this->MemoryTesterStyle = cmCTestMemCheckHandler::VALGRIND;
- }
}
- if(this->MemoryTester.empty())
- {
+ }
+ if (this->MemoryTester.empty()) {
cmCTestOptionalLog(this->CTest, WARNING,
- "Memory checker (MemoryCheckCommand) "
- "not set, or cannot find the specified program."
- << std::endl, this->Quiet);
+ "Memory checker (MemoryCheckCommand) "
+ "not set, or cannot find the specified program."
+ << std::endl,
+ this->Quiet);
return false;
- }
+ }
// Setup the options
std::string memoryTesterOptions;
- if ( this->CTest->GetCTestConfiguration(
- "MemoryCheckCommandOptions").size() )
- {
- memoryTesterOptions = this->CTest->GetCTestConfiguration(
- "MemoryCheckCommandOptions");
- }
- else if ( this->CTest->GetCTestConfiguration(
- "ValgrindCommandOptions").size() )
- {
- memoryTesterOptions = this->CTest->GetCTestConfiguration(
- "ValgrindCommandOptions");
- }
- this->MemoryTesterOptions
- = cmSystemTools::ParseArguments(memoryTesterOptions.c_str());
+ if (this->CTest->GetCTestConfiguration("MemoryCheckCommandOptions").size()) {
+ memoryTesterOptions =
+ this->CTest->GetCTestConfiguration("MemoryCheckCommandOptions");
+ } else if (this->CTest->GetCTestConfiguration("ValgrindCommandOptions")
+ .size()) {
+ memoryTesterOptions =
+ this->CTest->GetCTestConfiguration("ValgrindCommandOptions");
+ }
+ this->MemoryTesterOptions =
+ cmSystemTools::ParseArguments(memoryTesterOptions.c_str());
- this->MemoryTesterOutputFile
- = this->CTest->GetBinaryDir()
- + "/Testing/Temporary/MemoryChecker.??.log";
+ this->MemoryTesterOutputFile =
+ this->CTest->GetBinaryDir() + "/Testing/Temporary/MemoryChecker.??.log";
- switch ( this->MemoryTesterStyle )
- {
- case cmCTestMemCheckHandler::VALGRIND:
- {
- if ( this->MemoryTesterOptions.empty() )
- {
+ switch (this->MemoryTesterStyle) {
+ case cmCTestMemCheckHandler::VALGRIND: {
+ if (this->MemoryTesterOptions.empty()) {
this->MemoryTesterOptions.push_back("-q");
this->MemoryTesterOptions.push_back("--tool=memcheck");
this->MemoryTesterOptions.push_back("--leak-check=yes");
this->MemoryTesterOptions.push_back("--show-reachable=yes");
this->MemoryTesterOptions.push_back("--num-callers=50");
- }
- if ( this->CTest->GetCTestConfiguration(
- "MemoryCheckSuppressionFile").size() )
- {
- if ( !cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
- "MemoryCheckSuppressionFile").c_str()) )
- {
+ }
+ if (this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile")
+ .size()) {
+ if (!cmSystemTools::FileExists(
+ this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile")
+ .c_str())) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Cannot find memory checker suppression file: "
- << this->CTest->GetCTestConfiguration(
- "MemoryCheckSuppressionFile") << std::endl);
+ "Cannot find memory checker suppression file: "
+ << this->CTest->GetCTestConfiguration(
+ "MemoryCheckSuppressionFile")
+ << std::endl);
return false;
- }
- std::string suppressions = "--suppressions="
- + this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile");
- this->MemoryTesterOptions.push_back(suppressions);
}
- std::string outputFile = "--log-file="
- + this->MemoryTesterOutputFile;
+ std::string suppressions = "--suppressions=" +
+ this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile");
+ this->MemoryTesterOptions.push_back(suppressions);
+ }
+ std::string outputFile = "--log-file=" + this->MemoryTesterOutputFile;
this->MemoryTesterDynamicOptions.push_back(outputFile);
break;
- }
- case cmCTestMemCheckHandler::PURIFY:
- {
+ }
+ case cmCTestMemCheckHandler::PURIFY: {
std::string outputFile;
#ifdef _WIN32
- if( this->CTest->GetCTestConfiguration(
- "MemoryCheckSuppressionFile").size() )
- {
- if( !cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
- "MemoryCheckSuppressionFile").c_str()) )
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Cannot find memory checker suppression file: "
- << this->CTest->GetCTestConfiguration(
- "MemoryCheckSuppressionFile").c_str() << std::endl);
+ if (this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile")
+ .size()) {
+ if (!cmSystemTools::FileExists(
+ this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile")
+ .c_str())) {
+ cmCTestLog(
+ this->CTest, ERROR_MESSAGE,
+ "Cannot find memory checker suppression file: "
+ << this->CTest
+ ->GetCTestConfiguration("MemoryCheckSuppressionFile")
+ .c_str()
+ << std::endl);
return false;
- }
- std::string filterFiles = "/FilterFiles="
- + this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile");
- this->MemoryTesterOptions.push_back(filterFiles);
}
+ std::string filterFiles = "/FilterFiles=" +
+ this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile");
+ this->MemoryTesterOptions.push_back(filterFiles);
+ }
outputFile = "/SAVETEXTDATA=";
#else
outputFile = "-log-file=";
@@ -667,12 +576,11 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
outputFile += this->MemoryTesterOutputFile;
this->MemoryTesterDynamicOptions.push_back(outputFile);
break;
- }
- case cmCTestMemCheckHandler::BOUNDS_CHECKER:
- {
+ }
+ case cmCTestMemCheckHandler::BOUNDS_CHECKER: {
this->BoundsCheckerXMLFile = this->MemoryTesterOutputFile;
- std::string dpbdFile = this->CTest->GetBinaryDir()
- + "/Testing/Temporary/MemoryChecker.??.DPbd";
+ std::string dpbdFile = this->CTest->GetBinaryDir() +
+ "/Testing/Temporary/MemoryChecker.??.DPbd";
this->BoundsCheckerDPBDFile = dpbdFile;
this->MemoryTesterDynamicOptions.push_back("/B");
this->MemoryTesterDynamicOptions.push_back(dpbdFile);
@@ -680,13 +588,12 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
this->MemoryTesterDynamicOptions.push_back(this->MemoryTesterOutputFile);
this->MemoryTesterOptions.push_back("/M");
break;
- }
- // these are almost the same but the env var used is different
+ }
+ // these are almost the same but the env var used is different
case cmCTestMemCheckHandler::ADDRESS_SANITIZER:
case cmCTestMemCheckHandler::THREAD_SANITIZER:
case cmCTestMemCheckHandler::MEMORY_SANITIZER:
- case cmCTestMemCheckHandler::UB_SANITIZER:
- {
+ case cmCTestMemCheckHandler::UB_SANITIZER: {
// To pass arguments to ThreadSanitizer the environment variable
// TSAN_OPTIONS is used. This is done with the cmake -E env command.
// The MemoryTesterDynamicOptions is setup with the -E env
@@ -697,36 +604,31 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
std::string envVar;
std::string extraOptions =
this->CTest->GetCTestConfiguration("MemoryCheckSanitizerOptions");
- if(this->MemoryTesterStyle == cmCTestMemCheckHandler::ADDRESS_SANITIZER)
- {
+ if (this->MemoryTesterStyle ==
+ cmCTestMemCheckHandler::ADDRESS_SANITIZER) {
envVar = "ASAN_OPTIONS";
extraOptions += " detect_leaks=1";
- }
- else if(this->MemoryTesterStyle ==
- cmCTestMemCheckHandler::THREAD_SANITIZER)
- {
+ } else if (this->MemoryTesterStyle ==
+ cmCTestMemCheckHandler::THREAD_SANITIZER) {
envVar = "TSAN_OPTIONS";
- }
- else if(this->MemoryTesterStyle ==
- cmCTestMemCheckHandler::MEMORY_SANITIZER)
- {
+ } else if (this->MemoryTesterStyle ==
+ cmCTestMemCheckHandler::MEMORY_SANITIZER) {
envVar = "MSAN_OPTIONS";
- }
- else if(this->MemoryTesterStyle == cmCTestMemCheckHandler::UB_SANITIZER)
- {
+ } else if (this->MemoryTesterStyle ==
+ cmCTestMemCheckHandler::UB_SANITIZER) {
envVar = "UBSAN_OPTIONS";
- }
- std::string outputFile = envVar + "=log_path=\""
- + this->MemoryTesterOutputFile + "\" ";
+ }
+ std::string outputFile =
+ envVar + "=log_path=\"" + this->MemoryTesterOutputFile + "\" ";
this->MemoryTesterEnvironmentVariable = outputFile + extraOptions;
break;
- }
+ }
default:
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Do not understand memory checker: " << this->MemoryTester
- << std::endl);
+ "Do not understand memory checker: " << this->MemoryTester
+ << std::endl);
return false;
- }
+ }
this->InitializeResultsVectors();
// std::vector<std::string>::size_type cc;
@@ -737,66 +639,52 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
return true;
}
-bool cmCTestMemCheckHandler::
-ProcessMemCheckOutput(const std::string& str,
- std::string& log, std::vector<int>& results)
+bool cmCTestMemCheckHandler::ProcessMemCheckOutput(const std::string& str,
+ std::string& log,
+ std::vector<int>& results)
{
- if ( this->MemoryTesterStyle == cmCTestMemCheckHandler::VALGRIND )
- {
+ if (this->MemoryTesterStyle == cmCTestMemCheckHandler::VALGRIND) {
return this->ProcessMemCheckValgrindOutput(str, log, results);
- }
- else if ( this->MemoryTesterStyle == cmCTestMemCheckHandler::PURIFY )
- {
+ } else if (this->MemoryTesterStyle == cmCTestMemCheckHandler::PURIFY) {
return this->ProcessMemCheckPurifyOutput(str, log, results);
- }
- else if ( this->MemoryTesterStyle ==
- cmCTestMemCheckHandler::ADDRESS_SANITIZER ||
- this->MemoryTesterStyle ==
- cmCTestMemCheckHandler::THREAD_SANITIZER ||
- this->MemoryTesterStyle ==
- cmCTestMemCheckHandler::MEMORY_SANITIZER ||
- this->MemoryTesterStyle ==
- cmCTestMemCheckHandler::UB_SANITIZER)
- {
+ } else if (this->MemoryTesterStyle ==
+ cmCTestMemCheckHandler::ADDRESS_SANITIZER ||
+ this->MemoryTesterStyle ==
+ cmCTestMemCheckHandler::THREAD_SANITIZER ||
+ this->MemoryTesterStyle ==
+ cmCTestMemCheckHandler::MEMORY_SANITIZER ||
+ this->MemoryTesterStyle == cmCTestMemCheckHandler::UB_SANITIZER) {
return this->ProcessMemCheckSanitizerOutput(str, log, results);
- }
- else if ( this->MemoryTesterStyle ==
- cmCTestMemCheckHandler::BOUNDS_CHECKER )
- {
+ } else if (this->MemoryTesterStyle ==
+ cmCTestMemCheckHandler::BOUNDS_CHECKER) {
return this->ProcessMemCheckBoundsCheckerOutput(str, log, results);
- }
- else
- {
+ } else {
log.append("\nMemory checking style used was: ");
log.append("None that I know");
log = str;
- }
+ }
return true;
}
std::vector<int>::size_type cmCTestMemCheckHandler::FindOrAddWarning(
const std::string& warning)
{
- for(std::vector<std::string>::size_type i =0;
- i < this->ResultStrings.size(); ++i)
- {
- if(this->ResultStrings[i] == warning)
- {
+ for (std::vector<std::string>::size_type i = 0;
+ i < this->ResultStrings.size(); ++i) {
+ if (this->ResultStrings[i] == warning) {
return i;
- }
}
+ }
this->GlobalResults.push_back(0); // this must stay the same size
this->ResultStrings.push_back(warning);
this->ResultStringsLong.push_back(warning);
- return this->ResultStrings.size()-1;
+ return this->ResultStrings.size() - 1;
}
bool cmCTestMemCheckHandler::ProcessMemCheckSanitizerOutput(
- const std::string& str, std::string& log,
- std::vector<int>& result)
+ const std::string& str, std::string& log, std::vector<int>& result)
{
std::string regex;
- switch ( this->MemoryTesterStyle )
- {
+ switch (this->MemoryTesterStyle) {
case cmCTestMemCheckHandler::ADDRESS_SANITIZER:
regex = "ERROR: AddressSanitizer: (.*) on.*";
break;
@@ -811,7 +699,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckSanitizerOutput(
break;
default:
break;
- }
+ }
cmsys::RegularExpression sanitizerWarning(regex);
cmsys::RegularExpression leakWarning("(Direct|Indirect) leak of .*");
int defects = 0;
@@ -819,44 +707,34 @@ bool cmCTestMemCheckHandler::ProcessMemCheckSanitizerOutput(
cmSystemTools::Split(str.c_str(), lines);
std::ostringstream ostr;
log = "";
- for( std::vector<std::string>::iterator i = lines.begin();
- i != lines.end(); ++i)
- {
+ for (std::vector<std::string>::iterator i = lines.begin(); i != lines.end();
+ ++i) {
std::string resultFound;
- if(leakWarning.find(*i))
- {
- resultFound = leakWarning.match(1)+" leak";
- }
- else if (sanitizerWarning.find(*i))
- {
+ if (leakWarning.find(*i)) {
+ resultFound = leakWarning.match(1) + " leak";
+ } else if (sanitizerWarning.find(*i)) {
resultFound = sanitizerWarning.match(1);
- }
- if(!resultFound.empty())
- {
+ }
+ if (!resultFound.empty()) {
std::vector<int>::size_type idx = this->FindOrAddWarning(resultFound);
- if(result.empty() || idx > result.size()-1)
- {
+ if (result.empty() || idx > result.size() - 1) {
result.push_back(1);
- }
- else
- {
+ } else {
result[idx]++;
- }
- defects++;
- ostr << "<b>" << this->ResultStrings[idx] << "</b> ";
}
- ostr << *i << std::endl;
+ defects++;
+ ostr << "<b>" << this->ResultStrings[idx] << "</b> ";
}
+ ostr << *i << std::endl;
+ }
log = ostr.str();
- if(defects)
- {
+ if (defects) {
return false;
- }
+ }
return true;
}
bool cmCTestMemCheckHandler::ProcessMemCheckPurifyOutput(
- const std::string& str, std::string& log,
- std::vector<int>& results)
+ const std::string& str, std::string& log, std::vector<int>& results)
{
std::vector<std::string> lines;
cmSystemTools::Split(str.c_str(), lines);
@@ -867,58 +745,49 @@ bool cmCTestMemCheckHandler::ProcessMemCheckPurifyOutput(
int defects = 0;
- for( std::vector<std::string>::iterator i = lines.begin();
- i != lines.end(); ++i)
- {
+ for (std::vector<std::string>::iterator i = lines.begin(); i != lines.end();
+ ++i) {
std::vector<int>::size_type failure = this->ResultStrings.size();
- if ( pfW.find(*i) )
- {
+ if (pfW.find(*i)) {
std::vector<int>::size_type cc;
- for ( cc = 0; cc < this->ResultStrings.size(); cc ++ )
- {
- if ( pfW.match(1) == this->ResultStrings[cc] )
- {
+ for (cc = 0; cc < this->ResultStrings.size(); cc++) {
+ if (pfW.match(1) == this->ResultStrings[cc]) {
failure = cc;
break;
- }
}
- if ( cc == this->ResultStrings.size() )
- {
+ }
+ if (cc == this->ResultStrings.size()) {
cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown Purify memory fault: "
- << pfW.match(1) << std::endl);
+ << pfW.match(1) << std::endl);
ostr << "*** Unknown Purify memory fault: " << pfW.match(1)
- << std::endl;
- }
- }
- if ( failure != this->ResultStrings.size() )
- {
- ostr << "<b>" << this->ResultStrings[failure] << "</b> ";
- results[failure] ++;
- defects ++;
+ << std::endl;
}
- ostr << *i << std::endl;
}
+ if (failure != this->ResultStrings.size()) {
+ ostr << "<b>" << this->ResultStrings[failure] << "</b> ";
+ results[failure]++;
+ defects++;
+ }
+ ostr << *i << std::endl;
+ }
log = ostr.str();
- if ( defects )
- {
+ if (defects) {
return false;
- }
+ }
return true;
}
bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput(
- const std::string& str, std::string& log,
- std::vector<int>& results)
+ const std::string& str, std::string& log, std::vector<int>& results)
{
std::vector<std::string> lines;
cmSystemTools::Split(str.c_str(), lines);
bool unlimitedOutput = false;
- if(str.find("CTEST_FULL_OUTPUT") != str.npos ||
- this->CustomMaximumFailedTestOutputSize == 0)
- {
+ if (str.find("CTEST_FULL_OUTPUT") != str.npos ||
+ this->CustomMaximumFailedTestOutputSize == 0) {
unlimitedOutput = true;
- }
+ }
std::string::size_type cc;
@@ -935,7 +804,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput(
"== .*Mismatched free\\(\\) / delete / delete \\[\\]");
cmsys::RegularExpression vgMLK1(
"== .*[0-9,]+ bytes in [0-9,]+ blocks are definitely lost"
- " in loss record [0-9,]+ of [0-9,]+");
+ " in loss record [0-9,]+ of [0-9,]+");
cmsys::RegularExpression vgMLK2(
"== .*[0-9,]+ \\([0-9,]+ direct, [0-9,]+ indirect\\)"
" bytes in [0-9,]+ blocks are definitely lost"
@@ -954,298 +823,239 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput(
"== .*Use of uninitialised value of size [0-9,]+");
cmsys::RegularExpression vgUMR2("== .*Invalid read of size [0-9,]+");
cmsys::RegularExpression vgUMR3("== .*Jump to the invalid address ");
- cmsys::RegularExpression vgUMR4("== .*Syscall param .* contains "
+ cmsys::RegularExpression vgUMR4(
+ "== .*Syscall param .* contains "
"uninitialised or unaddressable byte\\(s\\)");
cmsys::RegularExpression vgUMR5("== .*Syscall param .* uninitialised");
cmsys::RegularExpression vgIPW("== .*Invalid write of size [0-9,]+");
cmsys::RegularExpression vgABR("== .*pthread_mutex_unlock: mutex is "
- "locked by a different thread");
+ "locked by a different thread");
std::vector<std::string::size_type> nonValGrindOutput;
double sttime = cmSystemTools::GetTime();
cmCTestOptionalLog(this->CTest, DEBUG,
- "Start test: " << lines.size() << std::endl, this->Quiet);
+ "Start test: " << lines.size() << std::endl, this->Quiet);
std::string::size_type totalOutputSize = 0;
- for ( cc = 0; cc < lines.size(); cc ++ )
- {
- cmCTestOptionalLog(this->CTest, DEBUG, "test line "
- << lines[cc] << std::endl, this->Quiet);
+ for (cc = 0; cc < lines.size(); cc++) {
+ cmCTestOptionalLog(this->CTest, DEBUG,
+ "test line " << lines[cc] << std::endl, this->Quiet);
- if ( valgrindLine.find(lines[cc]) )
- {
- cmCTestOptionalLog(this->CTest, DEBUG, "valgrind line "
- << lines[cc] << std::endl, this->Quiet);
+ if (valgrindLine.find(lines[cc])) {
+ cmCTestOptionalLog(this->CTest, DEBUG,
+ "valgrind line " << lines[cc] << std::endl,
+ this->Quiet);
int failure = cmCTestMemCheckHandler::NO_MEMORY_FAULT;
- if ( vgFIM.find(lines[cc]) )
- {
+ if (vgFIM.find(lines[cc])) {
failure = cmCTestMemCheckHandler::FIM;
- }
- else if ( vgFMM.find(lines[cc]) )
- {
+ } else if (vgFMM.find(lines[cc])) {
failure = cmCTestMemCheckHandler::FMM;
- }
- else if ( vgMLK1.find(lines[cc]) )
- {
+ } else if (vgMLK1.find(lines[cc])) {
failure = cmCTestMemCheckHandler::MLK;
- }
- else if ( vgMLK2.find(lines[cc]) )
- {
+ } else if (vgMLK2.find(lines[cc])) {
failure = cmCTestMemCheckHandler::MLK;
- }
- else if ( vgPAR.find(lines[cc]) )
- {
+ } else if (vgPAR.find(lines[cc])) {
failure = cmCTestMemCheckHandler::PAR;
- }
- else if ( vgMPK1.find(lines[cc]) )
- {
+ } else if (vgMPK1.find(lines[cc])) {
failure = cmCTestMemCheckHandler::MPK;
- }
- else if ( vgMPK2.find(lines[cc]) )
- {
+ } else if (vgMPK2.find(lines[cc])) {
failure = cmCTestMemCheckHandler::MPK;
- }
- else if ( vgUMC.find(lines[cc]) )
- {
+ } else if (vgUMC.find(lines[cc])) {
failure = cmCTestMemCheckHandler::UMC;
- }
- else if ( vgUMR1.find(lines[cc]) )
- {
+ } else if (vgUMR1.find(lines[cc])) {
failure = cmCTestMemCheckHandler::UMR;
- }
- else if ( vgUMR2.find(lines[cc]) )
- {
+ } else if (vgUMR2.find(lines[cc])) {
failure = cmCTestMemCheckHandler::UMR;
- }
- else if ( vgUMR3.find(lines[cc]) )
- {
+ } else if (vgUMR3.find(lines[cc])) {
failure = cmCTestMemCheckHandler::UMR;
- }
- else if ( vgUMR4.find(lines[cc]) )
- {
+ } else if (vgUMR4.find(lines[cc])) {
failure = cmCTestMemCheckHandler::UMR;
- }
- else if ( vgUMR5.find(lines[cc]) )
- {
+ } else if (vgUMR5.find(lines[cc])) {
failure = cmCTestMemCheckHandler::UMR;
- }
- else if ( vgIPW.find(lines[cc]) )
- {
+ } else if (vgIPW.find(lines[cc])) {
failure = cmCTestMemCheckHandler::IPW;
- }
- else if ( vgABR.find(lines[cc]) )
- {
+ } else if (vgABR.find(lines[cc])) {
failure = cmCTestMemCheckHandler::ABR;
- }
+ }
- if ( failure != cmCTestMemCheckHandler::NO_MEMORY_FAULT )
- {
+ if (failure != cmCTestMemCheckHandler::NO_MEMORY_FAULT) {
ostr << "<b>" << this->ResultStrings[failure] << "</b> ";
- results[failure] ++;
- defects ++;
- }
+ results[failure]++;
+ defects++;
+ }
totalOutputSize += lines[cc].size();
ostr << lines[cc] << std::endl;
- }
- else
- {
+ } else {
nonValGrindOutput.push_back(cc);
- }
}
+ }
// Now put all all the non valgrind output into the test output
// This should be last in case it gets truncated by the output
// limiting code
- for(std::vector<std::string::size_type>::iterator i =
- nonValGrindOutput.begin(); i != nonValGrindOutput.end(); ++i)
- {
+ for (std::vector<std::string::size_type>::iterator i =
+ nonValGrindOutput.begin();
+ i != nonValGrindOutput.end(); ++i) {
totalOutputSize += lines[*i].size();
ostr << lines[*i] << std::endl;
- if(!unlimitedOutput && totalOutputSize >
- static_cast<size_t>(this->CustomMaximumFailedTestOutputSize))
- {
+ if (!unlimitedOutput &&
+ totalOutputSize >
+ static_cast<size_t>(this->CustomMaximumFailedTestOutputSize)) {
ostr << "....\n";
ostr << "Test Output for this test has been truncated see testing"
- " machine logs for full output,\n";
+ " machine logs for full output,\n";
ostr << "or put CTEST_FULL_OUTPUT in the output of "
- "this test program.\n";
- break; // stop the copy of output if we are full
- }
+ "this test program.\n";
+ break; // stop the copy of output if we are full
}
+ }
cmCTestOptionalLog(this->CTest, DEBUG, "End test (elapsed: "
- << (cmSystemTools::GetTime() - sttime) << std::endl, this->Quiet);
+ << (cmSystemTools::GetTime() - sttime) << std::endl,
+ this->Quiet);
log = ostr.str();
- if ( defects )
- {
+ if (defects) {
return false;
- }
+ }
return true;
}
-
-
bool cmCTestMemCheckHandler::ProcessMemCheckBoundsCheckerOutput(
- const std::string& str, std::string& log,
- std::vector<int>& results)
+ const std::string& str, std::string& log, std::vector<int>& results)
{
log = "";
double sttime = cmSystemTools::GetTime();
std::vector<std::string> lines;
cmSystemTools::Split(str.c_str(), lines);
cmCTestOptionalLog(this->CTest, DEBUG,
- "Start test: " << lines.size() << std::endl, this->Quiet);
+ "Start test: " << lines.size() << std::endl, this->Quiet);
std::vector<std::string>::size_type cc;
- for ( cc = 0; cc < lines.size(); cc ++ )
- {
- if(lines[cc] == BOUNDS_CHECKER_MARKER)
- {
+ for (cc = 0; cc < lines.size(); cc++) {
+ if (lines[cc] == BOUNDS_CHECKER_MARKER) {
break;
- }
}
+ }
cmBoundsCheckerParser parser(this->CTest);
parser.InitializeParser();
- if(cc < lines.size())
- {
- for(cc++; cc < lines.size(); ++cc)
- {
+ if (cc < lines.size()) {
+ for (cc++; cc < lines.size(); ++cc) {
std::string& theLine = lines[cc];
// check for command line arguments that are not escaped
// correctly by BC
- if(theLine.find("TargetArgs=") != theLine.npos)
- {
+ if (theLine.find("TargetArgs=") != theLine.npos) {
// skip this because BC gets it wrong and we can't parse it
- }
- else if(!parser.ParseChunk(theLine.c_str(), theLine.size()))
- {
+ } else if (!parser.ParseChunk(theLine.c_str(), theLine.size())) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Error in ParseChunk: " << theLine
- << std::endl);
- }
+ "Error in ParseChunk: " << theLine << std::endl);
}
}
+ }
int defects = 0;
- for(cc =0; cc < parser.Errors.size(); ++cc)
- {
+ for (cc = 0; cc < parser.Errors.size(); ++cc) {
results[parser.Errors[cc]]++;
defects++;
- }
+ }
cmCTestOptionalLog(this->CTest, DEBUG, "End test (elapsed: "
- << (cmSystemTools::GetTime() - sttime) << std::endl, this->Quiet);
- if(defects)
- {
+ << (cmSystemTools::GetTime() - sttime) << std::endl,
+ this->Quiet);
+ if (defects) {
// only put the output of Bounds Checker if there were
// errors or leaks detected
log = parser.Log;
return false;
- }
+ }
return true;
}
// PostProcessTest memcheck results
-void
-cmCTestMemCheckHandler::PostProcessTest(cmCTestTestResult& res,
- int test)
+void cmCTestMemCheckHandler::PostProcessTest(cmCTestTestResult& res, int test)
{
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "PostProcessTest memcheck results for : "
- << res.Name << std::endl, this->Quiet);
- if(this->MemoryTesterStyle
- == cmCTestMemCheckHandler::BOUNDS_CHECKER)
- {
+ "PostProcessTest memcheck results for : " << res.Name
+ << std::endl,
+ this->Quiet);
+ if (this->MemoryTesterStyle == cmCTestMemCheckHandler::BOUNDS_CHECKER) {
this->PostProcessBoundsCheckerTest(res, test);
- }
- else
- {
+ } else {
std::vector<std::string> files;
this->TestOutputFileNames(test, files);
- for(std::vector<std::string>::iterator i = files.begin();
- i != files.end(); ++i)
- {
+ for (std::vector<std::string>::iterator i = files.begin();
+ i != files.end(); ++i) {
this->AppendMemTesterOutput(res, *i);
- }
}
+ }
}
-
// This method puts the bounds checker output file into the output
// for the test
-void
-cmCTestMemCheckHandler::PostProcessBoundsCheckerTest(cmCTestTestResult& res,
- int test)
+void cmCTestMemCheckHandler::PostProcessBoundsCheckerTest(
+ cmCTestTestResult& res, int test)
{
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "PostProcessBoundsCheckerTest for : "
- << res.Name << std::endl, this->Quiet);
+ "PostProcessBoundsCheckerTest for : " << res.Name
+ << std::endl,
+ this->Quiet);
std::vector<std::string> files;
this->TestOutputFileNames(test, files);
- if (files.empty())
- {
+ if (files.empty()) {
return;
- }
+ }
std::string ofile = files[0];
- if ( ofile.empty() )
- {
+ if (ofile.empty()) {
return;
- }
+ }
// put a scope around this to close ifs so the file can be removed
{
- cmsys::ifstream ifs(ofile.c_str());
- if ( !ifs )
- {
- std::string log = "Cannot read memory tester output file: " + ofile;
- cmCTestLog(this->CTest, ERROR_MESSAGE, log.c_str() << std::endl);
- return;
+ cmsys::ifstream ifs(ofile.c_str());
+ if (!ifs) {
+ std::string log = "Cannot read memory tester output file: " + ofile;
+ cmCTestLog(this->CTest, ERROR_MESSAGE, log.c_str() << std::endl);
+ return;
}
- res.Output += BOUNDS_CHECKER_MARKER;
- res.Output += "\n";
- std::string line;
- while ( cmSystemTools::GetLineFromStream(ifs, line) )
- {
- res.Output += line;
+ res.Output += BOUNDS_CHECKER_MARKER;
res.Output += "\n";
+ std::string line;
+ while (cmSystemTools::GetLineFromStream(ifs, line)) {
+ res.Output += line;
+ res.Output += "\n";
}
}
cmSystemTools::Delay(1000);
cmSystemTools::RemoveFile(this->BoundsCheckerDPBDFile);
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Remove: "
- << this->BoundsCheckerDPBDFile << std::endl, this->Quiet);
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Remove: " << this->BoundsCheckerDPBDFile << std::endl,
+ this->Quiet);
cmSystemTools::RemoveFile(this->BoundsCheckerXMLFile);
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Remove: "
- << this->BoundsCheckerXMLFile << std::endl, this->Quiet);
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Remove: " << this->BoundsCheckerXMLFile << std::endl,
+ this->Quiet);
}
-void
-cmCTestMemCheckHandler::AppendMemTesterOutput(cmCTestTestResult& res,
- std::string const& ofile)
+void cmCTestMemCheckHandler::AppendMemTesterOutput(cmCTestTestResult& res,
+ std::string const& ofile)
{
- if ( ofile.empty() )
- {
+ if (ofile.empty()) {
return;
- }
+ }
// put ifs in scope so file can be deleted if needed
{
- cmsys::ifstream ifs(ofile.c_str());
- if ( !ifs )
- {
- std::string log = "Cannot read memory tester output file: " + ofile;
- cmCTestLog(this->CTest, ERROR_MESSAGE, log.c_str() << std::endl);
- return;
+ cmsys::ifstream ifs(ofile.c_str());
+ if (!ifs) {
+ std::string log = "Cannot read memory tester output file: " + ofile;
+ cmCTestLog(this->CTest, ERROR_MESSAGE, log.c_str() << std::endl);
+ return;
}
- std::string line;
- while ( cmSystemTools::GetLineFromStream(ifs, line) )
- {
- res.Output += line;
- res.Output += "\n";
+ std::string line;
+ while (cmSystemTools::GetLineFromStream(ifs, line)) {
+ res.Output += line;
+ res.Output += "\n";
}
}
- if(this->LogWithPID)
- {
+ if (this->LogWithPID) {
cmSystemTools::RemoveFile(ofile);
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Remove: "<< ofile <<"\n", this->Quiet);
- }
+ "Remove: " << ofile << "\n", this->Quiet);
+ }
}
-void cmCTestMemCheckHandler::TestOutputFileNames(int test,
- std::vector<std::string>&
- files)
+void cmCTestMemCheckHandler::TestOutputFileNames(
+ int test, std::vector<std::string>& files)
{
std::string index;
std::ostringstream stream;
@@ -1254,30 +1064,22 @@ void cmCTestMemCheckHandler::TestOutputFileNames(int test,
std::string ofile = this->MemoryTesterOutputFile;
std::string::size_type pos = ofile.find("??");
ofile.replace(pos, 2, index);
- if(this->LogWithPID)
- {
+ if (this->LogWithPID) {
ofile += ".*";
cmsys::Glob g;
g.FindFiles(ofile);
- if(g.GetFiles().empty())
- {
- std::string log = "Cannot find memory tester output file: "
- + ofile;
+ if (g.GetFiles().empty()) {
+ std::string log = "Cannot find memory tester output file: " + ofile;
cmCTestLog(this->CTest, ERROR_MESSAGE, log.c_str() << std::endl);
ofile = "";
- }
- else
- {
+ } else {
files = g.GetFiles();
return;
- }
}
- else if ( !cmSystemTools::FileExists(ofile.c_str()) )
- {
- std::string log = "Cannot find memory tester output file: "
- + ofile;
+ } else if (!cmSystemTools::FileExists(ofile.c_str())) {
+ std::string log = "Cannot find memory tester output file: " + ofile;
cmCTestLog(this->CTest, ERROR_MESSAGE, log.c_str() << std::endl);
ofile = "";
- }
+ }
files.push_back(ofile);
}
diff --git a/Source/CTest/cmCTestMemCheckHandler.h b/Source/CTest/cmCTestMemCheckHandler.h
index 6232924..8f0cc47 100644
--- a/Source/CTest/cmCTestMemCheckHandler.h
+++ b/Source/CTest/cmCTestMemCheckHandler.h
@@ -29,22 +29,24 @@ class cmXMLWriter;
class cmCTestMemCheckHandler : public cmCTestTestHandler
{
friend class cmCTestRunTest;
+
public:
cmTypeMacro(cmCTestMemCheckHandler, cmCTestTestHandler);
- void PopulateCustomVectors(cmMakefile *mf);
+ void PopulateCustomVectors(cmMakefile* mf);
cmCTestMemCheckHandler();
void Initialize();
+
protected:
virtual int PreProcessHandler();
virtual int PostProcessHandler();
virtual void GenerateTestCommand(std::vector<std::string>& args, int test);
private:
-
- enum { // Memory checkers
+ enum
+ { // Memory checkers
UNKNOWN = 0,
VALGRIND,
PURIFY,
@@ -55,8 +57,10 @@ private:
MEMORY_SANITIZER,
UB_SANITIZER
};
+
public:
- enum { // Memory faults
+ enum
+ { // Memory faults
ABR = 0,
ABW,
ABWL,
@@ -81,8 +85,10 @@ public:
UMR,
NO_MEMORY_FAULT
};
+
private:
- enum { // Program statuses
+ enum
+ { // Program statuses
NOT_RUN = 0,
TIMEOUT,
SEGFAULT,
@@ -94,19 +100,19 @@ private:
BAD_COMMAND,
COMPLETED
};
- std::string BoundsCheckerDPBDFile;
- std::string BoundsCheckerXMLFile;
- std::string MemoryTester;
+ std::string BoundsCheckerDPBDFile;
+ std::string BoundsCheckerXMLFile;
+ std::string MemoryTester;
std::vector<std::string> MemoryTesterDynamicOptions;
std::vector<std::string> MemoryTesterOptions;
- int MemoryTesterStyle;
- std::string MemoryTesterOutputFile;
- std::string MemoryTesterEnvironmentVariable;
+ int MemoryTesterStyle;
+ std::string MemoryTesterOutputFile;
+ std::string MemoryTesterEnvironmentVariable;
// these are used to store the types of errors that can show up
std::vector<std::string> ResultStrings;
std::vector<std::string> ResultStringsLong;
- std::vector<int> GlobalResults;
- bool LogWithPID; // does log file add pid
+ std::vector<int> GlobalResults;
+ bool LogWithPID; // does log file add pid
std::vector<int>::size_type FindOrAddWarning(const std::string& warning);
// initialize the ResultStrings and ResultStringsLong for
@@ -125,18 +131,15 @@ private:
std::vector<std::string> CustomPostMemCheck;
//! Parse Valgrind/Purify/Bounds Checker result out of the output
- //string. After running, log holds the output and results hold the
- //different memmory errors.
- bool ProcessMemCheckOutput(const std::string& str,
- std::string& log, std::vector<int>& results);
- bool ProcessMemCheckValgrindOutput(const std::string& str,
- std::string& log,
+ // string. After running, log holds the output and results hold the
+ // different memmory errors.
+ bool ProcessMemCheckOutput(const std::string& str, std::string& log,
+ std::vector<int>& results);
+ bool ProcessMemCheckValgrindOutput(const std::string& str, std::string& log,
std::vector<int>& results);
- bool ProcessMemCheckPurifyOutput(const std::string& str,
- std::string& log,
+ bool ProcessMemCheckPurifyOutput(const std::string& str, std::string& log,
std::vector<int>& results);
- bool ProcessMemCheckSanitizerOutput(const std::string& str,
- std::string& log,
+ bool ProcessMemCheckSanitizerOutput(const std::string& str, std::string& log,
std::vector<int>& results);
bool ProcessMemCheckBoundsCheckerOutput(const std::string& str,
std::string& log,
@@ -154,4 +157,3 @@ private:
};
#endif
-
diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx
index d92ac77..d155023 100644
--- a/Source/CTest/cmCTestMultiProcessHandler.cxx
+++ b/Source/CTest/cmCTestMultiProcessHandler.cxx
@@ -27,15 +27,18 @@
class TestComparator
{
public:
- TestComparator(cmCTestMultiProcessHandler* handler) : Handler(handler) {}
+ TestComparator(cmCTestMultiProcessHandler* handler)
+ : Handler(handler)
+ {
+ }
~TestComparator() {}
// Sorts tests in descending order of cost
- bool operator() (int index1, int index2) const
- {
+ bool operator()(int index1, int index2) const
+ {
return Handler->Properties[index1]->Cost >
Handler->Properties[index2]->Cost;
- }
+ }
private:
cmCTestMultiProcessHandler* Handler;
@@ -56,34 +59,30 @@ cmCTestMultiProcessHandler::~cmCTestMultiProcessHandler()
{
}
- // Set the tests
-void
-cmCTestMultiProcessHandler::SetTests(TestMap& tests,
- PropertiesMap& properties)
+// Set the tests
+void cmCTestMultiProcessHandler::SetTests(TestMap& tests,
+ PropertiesMap& properties)
{
this->Tests = tests;
this->Properties = properties;
this->Total = this->Tests.size();
// set test run map to false for all
- for(TestMap::iterator i = this->Tests.begin();
- i != this->Tests.end(); ++i)
- {
+ for (TestMap::iterator i = this->Tests.begin(); i != this->Tests.end();
+ ++i) {
this->TestRunningMap[i->first] = false;
this->TestFinishMap[i->first] = false;
- }
- if(!this->CTest->GetShowOnly())
- {
+ }
+ if (!this->CTest->GetShowOnly()) {
this->ReadCostData();
this->HasCycles = !this->CheckCycles();
- if(this->HasCycles)
- {
+ if (this->HasCycles) {
return;
- }
- this->CreateTestCostList();
}
+ this->CreateTestCostList();
+ }
}
- // Set the max number of tests that can be run at the same time.
+// Set the max number of tests that can be run at the same time.
void cmCTestMultiProcessHandler::SetParallelLevel(size_t level)
{
this->ParallelLevel = level < 1 ? 1 : level;
@@ -97,25 +96,21 @@ void cmCTestMultiProcessHandler::SetTestLoad(unsigned long load)
void cmCTestMultiProcessHandler::RunTests()
{
this->CheckResume();
- if(this->HasCycles)
- {
+ if (this->HasCycles) {
return;
- }
+ }
this->TestHandler->SetMaxIndex(this->FindMaxIndex());
this->StartNextTests();
- while(!this->Tests.empty())
- {
- if(this->StopTimePassed)
- {
+ while (!this->Tests.empty()) {
+ if (this->StopTimePassed) {
return;
- }
+ }
this->CheckOutput();
this->StartNextTests();
- }
+ }
// let all running tests finish
- while(this->CheckOutput())
- {
- }
+ while (this->CheckOutput()) {
+ }
this->MarkFinished();
this->UpdateCostData();
}
@@ -123,18 +118,17 @@ void cmCTestMultiProcessHandler::RunTests()
void cmCTestMultiProcessHandler::StartTestProcess(int test)
{
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "test " << test << "\n", this->Quiet);
+ "test " << test << "\n", this->Quiet);
this->TestRunningMap[test] = true; // mark the test as running
// now remove the test itself
this->EraseTest(test);
this->RunningCount += GetProcessorsUsed(test);
cmCTestRunTest* testRun = new cmCTestRunTest(this->TestHandler);
- if(this->CTest->GetRepeatUntilFail())
- {
+ if (this->CTest->GetRepeatUntilFail()) {
testRun->SetRunUntilFailOn();
testRun->SetNumberOfRuns(this->CTest->GetTestRepeat());
- }
+ }
testRun->SetIndex(test);
testRun->SetTestProperties(this->Properties[test]);
@@ -144,24 +138,18 @@ void cmCTestMultiProcessHandler::StartTestProcess(int test)
// Lock the resources we'll be using
this->LockResources(test);
- if(testRun->StartTest(this->Total))
- {
+ if (testRun->StartTest(this->Total)) {
this->RunningTests.insert(testRun);
- }
- else if(testRun->IsStopTimePassed())
- {
+ } else if (testRun->IsStopTimePassed()) {
this->StopTimePassed = true;
delete testRun;
return;
- }
- else
- {
+ } else {
- for(TestMap::iterator j = this->Tests.begin();
- j != this->Tests.end(); ++j)
- {
+ for (TestMap::iterator j = this->Tests.begin(); j != this->Tests.end();
+ ++j) {
j->second.erase(test);
- }
+ }
this->UnlockResources(test);
this->Completed++;
@@ -171,34 +159,31 @@ void cmCTestMultiProcessHandler::StartTestProcess(int test)
testRun->EndTest(this->Completed, this->Total, false);
this->Failed->push_back(this->Properties[test]->Name);
delete testRun;
- }
+ }
cmSystemTools::ChangeDirectory(current_dir);
}
void cmCTestMultiProcessHandler::LockResources(int index)
{
this->LockedResources.insert(
- this->Properties[index]->LockedResources.begin(),
- this->Properties[index]->LockedResources.end());
+ this->Properties[index]->LockedResources.begin(),
+ this->Properties[index]->LockedResources.end());
- if (this->Properties[index]->RunSerial)
- {
+ if (this->Properties[index]->RunSerial) {
this->SerialTestRunning = true;
- }
+ }
}
void cmCTestMultiProcessHandler::UnlockResources(int index)
{
- for(std::set<std::string>::iterator i =
- this->Properties[index]->LockedResources.begin();
- i != this->Properties[index]->LockedResources.end(); ++i)
- {
+ for (std::set<std::string>::iterator i =
+ this->Properties[index]->LockedResources.begin();
+ i != this->Properties[index]->LockedResources.end(); ++i) {
this->LockedResources.erase(*i);
- }
- if (this->Properties[index]->RunSerial)
- {
+ }
+ if (this->Properties[index]->RunSerial) {
this->SerialTestRunning = false;
- }
+ }
}
void cmCTestMultiProcessHandler::EraseTest(int test)
@@ -210,14 +195,12 @@ void cmCTestMultiProcessHandler::EraseTest(int test)
inline size_t cmCTestMultiProcessHandler::GetProcessorsUsed(int test)
{
- size_t processors =
- static_cast<int>(this->Properties[test]->Processors);
- //If processors setting is set higher than the -j
- //setting, we default to using all of the process slots.
- if (processors > this->ParallelLevel)
- {
+ size_t processors = static_cast<int>(this->Properties[test]->Processors);
+ // If processors setting is set higher than the -j
+ // setting, we default to using all of the process slots.
+ if (processors > this->ParallelLevel) {
processors = this->ParallelLevel;
- }
+ }
return processors;
}
@@ -228,23 +211,20 @@ std::string cmCTestMultiProcessHandler::GetName(int test)
bool cmCTestMultiProcessHandler::StartTest(int test)
{
- //Check for locked resources
- for(std::set<std::string>::iterator i =
- this->Properties[test]->LockedResources.begin();
- i != this->Properties[test]->LockedResources.end(); ++i)
- {
- if(this->LockedResources.find(*i) != this->LockedResources.end())
- {
+ // Check for locked resources
+ for (std::set<std::string>::iterator i =
+ this->Properties[test]->LockedResources.begin();
+ i != this->Properties[test]->LockedResources.end(); ++i) {
+ if (this->LockedResources.find(*i) != this->LockedResources.end()) {
return false;
- }
}
+ }
// if there are no depends left then run this test
- if(this->Tests[test].empty())
- {
+ if (this->Tests[test].empty()) {
this->StartTestProcess(test);
return true;
- }
+ }
// This test was not able to start because it is waiting
// on depends to run
return false;
@@ -253,22 +233,19 @@ bool cmCTestMultiProcessHandler::StartTest(int test)
void cmCTestMultiProcessHandler::StartNextTests()
{
size_t numToStart = 0;
- if(this->RunningCount < this->ParallelLevel)
- {
+ if (this->RunningCount < this->ParallelLevel) {
numToStart = this->ParallelLevel - this->RunningCount;
- }
+ }
- if(numToStart == 0)
- {
+ if (numToStart == 0) {
return;
- }
+ }
// Don't start any new tests if one with the RUN_SERIAL property
// is already running.
- if (this->SerialTestRunning)
- {
+ if (this->SerialTestRunning) {
return;
- }
+ }
bool allTestsFailedTestLoadCheck = false;
bool usedFakeLoadForTesting = false;
@@ -279,101 +256,79 @@ void cmCTestMultiProcessHandler::StartNextTests()
unsigned long systemLoad = 0;
size_t spareLoad = 0;
- if (this->TestLoad > 0)
- {
+ if (this->TestLoad > 0) {
// Activate possible wait.
allTestsFailedTestLoadCheck = true;
// Check for a fake load average value used in testing.
if (const char* fake_load_value =
- cmSystemTools::GetEnv("__CTEST_FAKE_LOAD_AVERAGE_FOR_TESTING"))
- {
+ cmSystemTools::GetEnv("__CTEST_FAKE_LOAD_AVERAGE_FOR_TESTING")) {
usedFakeLoadForTesting = true;
- if (!cmSystemTools::StringToULong(fake_load_value, &systemLoad))
- {
+ if (!cmSystemTools::StringToULong(fake_load_value, &systemLoad)) {
cmSystemTools::Error("Failed to parse fake load value: ",
fake_load_value);
- }
}
+ }
// If it's not set, look up the true load average.
- else
- {
+ else {
systemLoad = static_cast<unsigned long>(ceil(info.GetLoadAverage()));
- }
- spareLoad = (this->TestLoad > systemLoad ?
- this->TestLoad - systemLoad : 0);
+ }
+ spareLoad =
+ (this->TestLoad > systemLoad ? this->TestLoad - systemLoad : 0);
// Don't start more tests than the spare load can support.
- if (numToStart > spareLoad)
- {
+ if (numToStart > spareLoad) {
numToStart = spareLoad;
- }
}
+ }
TestList copy = this->SortedTests;
- for(TestList::iterator test = copy.begin(); test != copy.end(); ++test)
- {
+ for (TestList::iterator test = copy.begin(); test != copy.end(); ++test) {
// Take a nap if we're currently performing a RUN_SERIAL test.
- if (this->SerialTestRunning)
- {
+ if (this->SerialTestRunning) {
break;
- }
+ }
// We can only start a RUN_SERIAL test if no other tests are also running.
- if (this->Properties[*test]->RunSerial && this->RunningCount > 0)
- {
+ if (this->Properties[*test]->RunSerial && this->RunningCount > 0) {
continue;
- }
+ }
size_t processors = GetProcessorsUsed(*test);
bool testLoadOk = true;
- if (this->TestLoad > 0)
- {
- if (processors <= spareLoad)
- {
- cmCTestLog(this->CTest, DEBUG,
- "OK to run " << GetName(*test) <<
- ", it requires " << processors <<
- " procs & system load is: " <<
- systemLoad << std::endl);
+ if (this->TestLoad > 0) {
+ if (processors <= spareLoad) {
+ cmCTestLog(this->CTest, DEBUG, "OK to run "
+ << GetName(*test) << ", it requires " << processors
+ << " procs & system load is: " << systemLoad
+ << std::endl);
allTestsFailedTestLoadCheck = false;
- }
- else
- {
+ } else {
testLoadOk = false;
- }
}
+ }
- if (processors <= minProcessorsRequired)
- {
+ if (processors <= minProcessorsRequired) {
minProcessorsRequired = processors;
testWithMinProcessors = GetName(*test);
- }
+ }
- if(testLoadOk && processors <= numToStart && this->StartTest(*test))
- {
- if(this->StopTimePassed)
- {
+ if (testLoadOk && processors <= numToStart && this->StartTest(*test)) {
+ if (this->StopTimePassed) {
return;
- }
+ }
numToStart -= processors;
- }
- else if(numToStart == 0)
- {
+ } else if (numToStart == 0) {
break;
- }
}
+ }
- if (allTestsFailedTestLoadCheck)
- {
+ if (allTestsFailedTestLoadCheck) {
cmCTestLog(this->CTest, HANDLER_OUTPUT, "***** WAITING, ");
- if (this->SerialTestRunning)
- {
+ if (this->SerialTestRunning) {
cmCTestLog(this->CTest, HANDLER_OUTPUT,
"Waiting for RUN_SERIAL test to finish.");
- }
- else
- {
+ } else {
/* clang-format off */
cmCTestLog(this->CTest, HANDLER_OUTPUT,
"System Load: " << systemLoad << ", "
@@ -381,68 +336,57 @@ void cmCTestMultiProcessHandler::StartNextTests()
"Smallest test " << testWithMinProcessors <<
" requires " << minProcessorsRequired);
/* clang-format on */
- }
+ }
cmCTestLog(this->CTest, HANDLER_OUTPUT, "*****" << std::endl);
- if (usedFakeLoadForTesting)
- {
+ if (usedFakeLoadForTesting) {
// Break out of the infinite loop of waiting for our fake load
// to come down.
this->StopTimePassed = true;
- }
- else
- {
+ } else {
// Wait between 1 and 5 seconds before trying again.
- cmCTestScriptHandler::SleepInSeconds(
- cmSystemTools::RandomSeed() % 5 + 1);
- }
+ cmCTestScriptHandler::SleepInSeconds(cmSystemTools::RandomSeed() % 5 +
+ 1);
}
+ }
}
bool cmCTestMultiProcessHandler::CheckOutput()
{
// no more output we are done
- if(this->RunningTests.empty())
- {
+ if (this->RunningTests.empty()) {
return false;
- }
+ }
std::vector<cmCTestRunTest*> finished;
std::string out, err;
- for(std::set<cmCTestRunTest*>::const_iterator i = this->RunningTests.begin();
- i != this->RunningTests.end(); ++i)
- {
+ for (std::set<cmCTestRunTest*>::const_iterator i =
+ this->RunningTests.begin();
+ i != this->RunningTests.end(); ++i) {
cmCTestRunTest* p = *i;
- if(!p->CheckOutput())
- {
+ if (!p->CheckOutput()) {
finished.push_back(p);
- }
}
- for( std::vector<cmCTestRunTest*>::iterator i = finished.begin();
- i != finished.end(); ++i)
- {
+ }
+ for (std::vector<cmCTestRunTest*>::iterator i = finished.begin();
+ i != finished.end(); ++i) {
this->Completed++;
cmCTestRunTest* p = *i;
int test = p->GetIndex();
bool testResult = p->EndTest(this->Completed, this->Total, true);
- if(p->StartAgain())
- {
+ if (p->StartAgain()) {
this->Completed--; // remove the completed test because run again
continue;
- }
- if(testResult)
- {
+ }
+ if (testResult) {
this->Passed->push_back(p->GetTestProperties()->Name);
- }
- else
- {
+ } else {
this->Failed->push_back(p->GetTestProperties()->Name);
- }
- for(TestMap::iterator j = this->Tests.begin();
- j != this->Tests.end(); ++j)
- {
+ }
+ for (TestMap::iterator j = this->Tests.begin(); j != this->Tests.end();
+ ++j) {
j->second.erase(test);
- }
+ }
this->TestFinishMap[test] = true;
this->TestRunningMap[test] = false;
this->RunningTests.erase(p);
@@ -450,7 +394,7 @@ bool cmCTestMultiProcessHandler::CheckOutput()
this->UnlockResources(test);
this->RunningCount -= GetProcessorsUsed(test);
delete p;
- }
+ }
return true;
}
@@ -463,56 +407,50 @@ void cmCTestMultiProcessHandler::UpdateCostData()
PropertiesMap temp = this->Properties;
- if(cmSystemTools::FileExists(fname.c_str()))
- {
+ if (cmSystemTools::FileExists(fname.c_str())) {
cmsys::ifstream fin;
fin.open(fname.c_str());
std::string line;
- while(std::getline(fin, line))
- {
- if(line == "---") break;
- std::vector<cmsys::String> parts =
- cmSystemTools::SplitString(line, ' ');
- //Format: <name> <previous_runs> <avg_cost>
- if(parts.size() < 3) break;
+ while (std::getline(fin, line)) {
+ if (line == "---")
+ break;
+ std::vector<cmsys::String> parts = cmSystemTools::SplitString(line, ' ');
+ // Format: <name> <previous_runs> <avg_cost>
+ if (parts.size() < 3)
+ break;
std::string name = parts[0];
int prev = atoi(parts[1].c_str());
float cost = static_cast<float>(atof(parts[2].c_str()));
int index = this->SearchByName(name);
- if(index == -1)
- {
+ if (index == -1) {
// This test is not in memory. We just rewrite the entry
fout << name << " " << prev << " " << cost << "\n";
- }
- else
- {
+ } else {
// Update with our new average cost
fout << name << " " << this->Properties[index]->PreviousRuns << " "
- << this->Properties[index]->Cost << "\n";
+ << this->Properties[index]->Cost << "\n";
temp.erase(index);
- }
}
+ }
fin.close();
cmSystemTools::RemoveFile(fname);
- }
+ }
// Add all tests not previously listed in the file
- for(PropertiesMap::iterator i = temp.begin(); i != temp.end(); ++i)
- {
+ for (PropertiesMap::iterator i = temp.begin(); i != temp.end(); ++i) {
fout << i->second->Name << " " << i->second->PreviousRuns << " "
- << i->second->Cost << "\n";
- }
+ << i->second->Cost << "\n";
+ }
// Write list of failed tests
fout << "---\n";
- for(std::vector<std::string>::iterator i = this->Failed->begin();
- i != this->Failed->end(); ++i)
- {
+ for (std::vector<std::string>::iterator i = this->Failed->begin();
+ i != this->Failed->end(); ++i) {
fout << i->c_str() << "\n";
- }
+ }
fout.close();
cmSystemTools::RenameFile(tmpout.c_str(), fname.c_str());
}
@@ -521,78 +459,67 @@ void cmCTestMultiProcessHandler::ReadCostData()
{
std::string fname = this->CTest->GetCostDataFile();
- if(cmSystemTools::FileExists(fname.c_str(), true))
- {
+ if (cmSystemTools::FileExists(fname.c_str(), true)) {
cmsys::ifstream fin;
fin.open(fname.c_str());
std::string line;
- while(std::getline(fin, line))
- {
- if(line == "---") break;
+ while (std::getline(fin, line)) {
+ if (line == "---")
+ break;
- std::vector<cmsys::String> parts =
- cmSystemTools::SplitString(line, ' ');
+ std::vector<cmsys::String> parts = cmSystemTools::SplitString(line, ' ');
// Probably an older version of the file, will be fixed next run
- if(parts.size() < 3)
- {
+ if (parts.size() < 3) {
fin.close();
return;
- }
+ }
std::string name = parts[0];
int prev = atoi(parts[1].c_str());
float cost = static_cast<float>(atof(parts[2].c_str()));
int index = this->SearchByName(name);
- if(index == -1) continue;
+ if (index == -1)
+ continue;
this->Properties[index]->PreviousRuns = prev;
// When not running in parallel mode, don't use cost data
- if(this->ParallelLevel > 1 &&
- this->Properties[index] &&
- this->Properties[index]->Cost == 0)
- {
+ if (this->ParallelLevel > 1 && this->Properties[index] &&
+ this->Properties[index]->Cost == 0) {
this->Properties[index]->Cost = cost;
- }
}
+ }
// Next part of the file is the failed tests
- while(std::getline(fin, line))
- {
- if(line != "")
- {
+ while (std::getline(fin, line)) {
+ if (line != "") {
this->LastTestsFailed.push_back(line);
- }
}
- fin.close();
}
+ fin.close();
+ }
}
int cmCTestMultiProcessHandler::SearchByName(std::string name)
{
int index = -1;
- for(PropertiesMap::iterator i = this->Properties.begin();
- i != this->Properties.end(); ++i)
- {
- if(i->second->Name == name)
- {
+ for (PropertiesMap::iterator i = this->Properties.begin();
+ i != this->Properties.end(); ++i) {
+ if (i->second->Name == name) {
index = i->first;
- }
}
+ }
return index;
}
void cmCTestMultiProcessHandler::CreateTestCostList()
{
- if(this->ParallelLevel > 1)
- {
+ if (this->ParallelLevel > 1) {
CreateParallelTestCostList();
- }
- else
- {
+ } else {
CreateSerialTestCostList();
- }
+ }
}
void cmCTestMultiProcessHandler::CreateParallelTestCostList()
@@ -601,140 +528,125 @@ void cmCTestMultiProcessHandler::CreateParallelTestCostList()
std::list<TestSet> priorityStack;
priorityStack.push_back(TestSet());
- TestSet &topLevel = priorityStack.back();
+ TestSet& topLevel = priorityStack.back();
// In parallel test runs add previously failed tests to the front
// of the cost list and queue other tests for further sorting
- for(TestMap::const_iterator i = this->Tests.begin();
- i != this->Tests.end(); ++i)
- {
- if(std::find(this->LastTestsFailed.begin(), this->LastTestsFailed.end(),
- this->Properties[i->first]->Name) != this->LastTestsFailed.end())
- {
- //If the test failed last time, it should be run first.
+ for (TestMap::const_iterator i = this->Tests.begin(); i != this->Tests.end();
+ ++i) {
+ if (std::find(this->LastTestsFailed.begin(), this->LastTestsFailed.end(),
+ this->Properties[i->first]->Name) !=
+ this->LastTestsFailed.end()) {
+ // If the test failed last time, it should be run first.
this->SortedTests.push_back(i->first);
alreadySortedTests.insert(i->first);
- }
- else
- {
+ } else {
topLevel.insert(i->first);
- }
}
+ }
// 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())
- {
- TestSet &previousSet = priorityStack.back();
+ while (priorityStack.back().size()) {
+ TestSet& previousSet = priorityStack.back();
priorityStack.push_back(TestSet());
- TestSet &currentSet = priorityStack.back();
+ TestSet& currentSet = priorityStack.back();
- for(TestSet::const_iterator i = previousSet.begin();
- i != previousSet.end(); ++i)
- {
+ for (TestSet::const_iterator i = previousSet.begin();
+ i != previousSet.end(); ++i) {
TestSet const& dependencies = this->Tests[*i];
currentSet.insert(dependencies.begin(), dependencies.end());
- }
+ }
- for(TestSet::const_iterator i = currentSet.begin();
- i != currentSet.end(); ++i)
- {
+ for (TestSet::const_iterator i = currentSet.begin(); i != currentSet.end();
+ ++i) {
previousSet.erase(*i);
- }
}
+ }
// Remove the empty dependency level
priorityStack.pop_back();
// Reverse iterate over the different dependency levels (deepest first).
// Sort tests within each level by COST and append them to the cost list.
- for(std::list<TestSet>::reverse_iterator i = priorityStack.rbegin();
- i != priorityStack.rend(); ++i)
- {
+ for (std::list<TestSet>::reverse_iterator i = priorityStack.rbegin();
+ i != priorityStack.rend(); ++i) {
TestSet const& currentSet = *i;
TestComparator comp(this);
TestList sortedCopy;
- sortedCopy.insert(sortedCopy.end(),
- currentSet.begin(), currentSet.end());
+ sortedCopy.insert(sortedCopy.end(), currentSet.begin(), currentSet.end());
std::stable_sort(sortedCopy.begin(), sortedCopy.end(), comp);
- for(TestList::const_iterator j = sortedCopy.begin();
- j != sortedCopy.end(); ++j)
- {
- if(alreadySortedTests.find(*j) == alreadySortedTests.end())
- {
+ for (TestList::const_iterator j = sortedCopy.begin();
+ j != sortedCopy.end(); ++j) {
+ if (alreadySortedTests.find(*j) == alreadySortedTests.end()) {
this->SortedTests.push_back(*j);
alreadySortedTests.insert(*j);
- }
}
}
+ }
}
-void cmCTestMultiProcessHandler::GetAllTestDependencies(
- int test, TestList& dependencies)
+void cmCTestMultiProcessHandler::GetAllTestDependencies(int test,
+ TestList& dependencies)
{
TestSet const& dependencySet = this->Tests[test];
- for(TestSet::const_iterator i = dependencySet.begin();
- i != dependencySet.end(); ++i)
- {
+ for (TestSet::const_iterator i = dependencySet.begin();
+ i != dependencySet.end(); ++i) {
GetAllTestDependencies(*i, dependencies);
dependencies.push_back(*i);
- }
+ }
}
void cmCTestMultiProcessHandler::CreateSerialTestCostList()
{
TestList presortedList;
- for(TestMap::iterator i = this->Tests.begin();
- i != this->Tests.end(); ++i)
- {
+ for (TestMap::iterator i = this->Tests.begin(); i != this->Tests.end();
+ ++i) {
presortedList.push_back(i->first);
- }
+ }
TestComparator comp(this);
std::stable_sort(presortedList.begin(), presortedList.end(), comp);
TestSet alreadySortedTests;
- for(TestList::const_iterator i = presortedList.begin();
- i != presortedList.end(); ++i)
- {
- int test = *i;
+ for (TestList::const_iterator i = presortedList.begin();
+ i != presortedList.end(); ++i) {
+ int test = *i;
- if(alreadySortedTests.find(test) != alreadySortedTests.end())
- {
- continue;
- }
-
- TestList dependencies;
- GetAllTestDependencies(test, dependencies);
+ if (alreadySortedTests.find(test) != alreadySortedTests.end()) {
+ continue;
+ }
- for(TestList::const_iterator j = dependencies.begin();
- j != dependencies.end(); ++j)
- {
- int testDependency = *j;
+ TestList dependencies;
+ GetAllTestDependencies(test, dependencies);
- if(alreadySortedTests.find(testDependency) == alreadySortedTests.end())
- {
- alreadySortedTests.insert(testDependency);
- this->SortedTests.push_back(testDependency);
- }
- }
+ for (TestList::const_iterator j = dependencies.begin();
+ j != dependencies.end(); ++j) {
+ int testDependency = *j;
- alreadySortedTests.insert(test);
- this->SortedTests.push_back(test);
+ if (alreadySortedTests.find(testDependency) ==
+ alreadySortedTests.end()) {
+ alreadySortedTests.insert(testDependency);
+ this->SortedTests.push_back(testDependency);
+ }
}
+
+ alreadySortedTests.insert(test);
+ this->SortedTests.push_back(test);
+ }
}
void cmCTestMultiProcessHandler::WriteCheckpoint(int index)
{
- std::string fname = this->CTest->GetBinaryDir()
- + "/Testing/Temporary/CTestCheckpoint.txt";
+ std::string fname =
+ this->CTest->GetBinaryDir() + "/Testing/Temporary/CTestCheckpoint.txt";
cmsys::ofstream fout;
fout.open(fname.c_str(), std::ios::app);
fout << index << "\n";
@@ -743,130 +655,118 @@ void cmCTestMultiProcessHandler::WriteCheckpoint(int index)
void cmCTestMultiProcessHandler::MarkFinished()
{
- std::string fname = this->CTest->GetBinaryDir()
- + "/Testing/Temporary/CTestCheckpoint.txt";
+ std::string fname =
+ this->CTest->GetBinaryDir() + "/Testing/Temporary/CTestCheckpoint.txt";
cmSystemTools::RemoveFile(fname);
}
-//For ShowOnly mode
+// For ShowOnly mode
void cmCTestMultiProcessHandler::PrintTestList()
{
this->TestHandler->SetMaxIndex(this->FindMaxIndex());
int count = 0;
for (PropertiesMap::iterator it = this->Properties.begin();
- it != this->Properties.end(); ++it)
- {
+ it != this->Properties.end(); ++it) {
count++;
cmCTestTestHandler::cmCTestTestProperties& p = *it->second;
- //push working dir
+ // push working dir
std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory();
cmSystemTools::ChangeDirectory(p.Directory);
cmCTestRunTest testRun(this->TestHandler);
testRun.SetIndex(p.Index);
testRun.SetTestProperties(&p);
- testRun.ComputeArguments(); //logs the command in verbose mode
+ testRun.ComputeArguments(); // logs the command in verbose mode
- if(!p.Labels.empty()) //print the labels
- {
+ if (!p.Labels.empty()) // print the labels
+ {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Labels:",
- this->Quiet);
- }
- for(std::vector<std::string>::iterator label = p.Labels.begin();
- label != p.Labels.end(); ++label)
- {
+ this->Quiet);
+ }
+ for (std::vector<std::string>::iterator label = p.Labels.begin();
+ label != p.Labels.end(); ++label) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " " << *label,
- this->Quiet);
- }
- if(!p.Labels.empty()) //print the labels
- {
+ this->Quiet);
+ }
+ if (!p.Labels.empty()) // print the labels
+ {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl,
- this->Quiet);
- }
+ this->Quiet);
+ }
- if (this->TestHandler->MemCheck)
- {
+ if (this->TestHandler->MemCheck) {
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " Memory Check",
- this->Quiet);
- }
- else
- {
+ this->Quiet);
+ } else {
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " Test", this->Quiet);
- }
+ }
std::ostringstream indexStr;
indexStr << " #" << p.Index << ":";
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+ cmCTestOptionalLog(
+ this->CTest, HANDLER_OUTPUT,
std::setw(3 + getNumWidth(this->TestHandler->GetMaxIndex()))
- << indexStr.str(), this->Quiet);
+ << indexStr.str(),
+ this->Quiet);
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " ", this->Quiet);
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- p.Name.c_str() << std::endl, this->Quiet);
- //pop working dir
+ p.Name.c_str() << std::endl, this->Quiet);
+ // pop working dir
cmSystemTools::ChangeDirectory(current_dir);
- }
+ }
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, std::endl << "Total Tests: "
- << this->Total << std::endl, this->Quiet);
+ cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, std::endl
+ << "Total Tests: " << this->Total << std::endl,
+ this->Quiet);
}
void cmCTestMultiProcessHandler::PrintLabels()
{
std::set<std::string> allLabels;
for (PropertiesMap::iterator it = this->Properties.begin();
- it != this->Properties.end(); ++it)
- {
+ it != this->Properties.end(); ++it) {
cmCTestTestHandler::cmCTestTestProperties& p = *it->second;
allLabels.insert(p.Labels.begin(), p.Labels.end());
- }
+ }
- if(!allLabels.empty())
- {
+ if (!allLabels.empty()) {
+ cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "All Labels:" << std::endl,
+ this->Quiet);
+ } else {
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- "All Labels:" << std::endl, this->Quiet);
- }
- else
- {
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- "No Labels Exist" << std::endl, this->Quiet);
- }
- for(std::set<std::string>::iterator label = allLabels.begin();
- label != allLabels.end(); ++label)
- {
+ "No Labels Exist" << std::endl, this->Quiet);
+ }
+ for (std::set<std::string>::iterator label = allLabels.begin();
+ label != allLabels.end(); ++label) {
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " " << *label << std::endl, this->Quiet);
- }
+ " " << *label << std::endl, this->Quiet);
+ }
}
void cmCTestMultiProcessHandler::CheckResume()
{
- std::string fname = this->CTest->GetBinaryDir()
- + "/Testing/Temporary/CTestCheckpoint.txt";
- if(this->CTest->GetFailover())
- {
- if(cmSystemTools::FileExists(fname.c_str(), true))
- {
- *this->TestHandler->LogFile << "Resuming previously interrupted test set"
- << std::endl
+ std::string fname =
+ this->CTest->GetBinaryDir() + "/Testing/Temporary/CTestCheckpoint.txt";
+ if (this->CTest->GetFailover()) {
+ if (cmSystemTools::FileExists(fname.c_str(), true)) {
+ *this->TestHandler->LogFile
+ << "Resuming previously interrupted test set" << std::endl
<< "----------------------------------------------------------"
<< std::endl;
cmsys::ifstream fin;
fin.open(fname.c_str());
std::string line;
- while(std::getline(fin, line))
- {
+ while (std::getline(fin, line)) {
int index = atoi(line.c_str());
this->RemoveTest(index);
- }
- fin.close();
}
+ fin.close();
}
- else if(cmSystemTools::FileExists(fname.c_str(), true))
- {
+ } else if (cmSystemTools::FileExists(fname.c_str(), true)) {
cmSystemTools::RemoveFile(fname);
- }
+ }
}
void cmCTestMultiProcessHandler::RemoveTest(int index)
@@ -882,56 +782,51 @@ int cmCTestMultiProcessHandler::FindMaxIndex()
{
int max = 0;
cmCTestMultiProcessHandler::TestMap::iterator i = this->Tests.begin();
- for(; i != this->Tests.end(); ++i)
- {
- if(i->first > max)
- {
+ for (; i != this->Tests.end(); ++i) {
+ if (i->first > max) {
max = i->first;
- }
}
+ }
return max;
}
-//Returns true if no cycles exist in the dependency graph
+// Returns true if no cycles exist in the dependency graph
bool cmCTestMultiProcessHandler::CheckCycles()
{
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Checking test dependency graph..." << std::endl, this->Quiet);
- for(TestMap::iterator it = this->Tests.begin();
- it != this->Tests.end(); ++it)
- {
- //DFS from each element to itself
+ "Checking test dependency graph..." << std::endl,
+ this->Quiet);
+ for (TestMap::iterator it = this->Tests.begin(); it != this->Tests.end();
+ ++it) {
+ // DFS from each element to itself
int root = it->first;
std::set<int> visited;
std::stack<int> s;
s.push(root);
- while(!s.empty())
- {
+ while (!s.empty()) {
int test = s.top();
s.pop();
- if(visited.insert(test).second)
- {
- for(TestSet::iterator d = this->Tests[test].begin();
- d != this->Tests[test].end(); ++d)
- {
- if(*d == root)
- {
- //cycle exists
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Error: a cycle exists in the test dependency graph "
- "for the test \"" << this->Properties[root]->Name <<
- "\".\nPlease fix the cycle and run ctest again.\n");
+ if (visited.insert(test).second) {
+ for (TestSet::iterator d = this->Tests[test].begin();
+ d != this->Tests[test].end(); ++d) {
+ if (*d == root) {
+ // cycle exists
+ cmCTestLog(
+ this->CTest, ERROR_MESSAGE,
+ "Error: a cycle exists in the test dependency graph "
+ "for the test \""
+ << this->Properties[root]->Name
+ << "\".\nPlease fix the cycle and run ctest again.\n");
return false;
- }
- else
- {
+ } else {
s.push(*d);
- }
}
}
}
}
+ }
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Checking test dependency graph end" << std::endl, this->Quiet);
+ "Checking test dependency graph end" << std::endl,
+ this->Quiet);
return true;
}
diff --git a/Source/CTest/cmCTestMultiProcessHandler.h b/Source/CTest/cmCTestMultiProcessHandler.h
index 64e56e6..cb709cc 100644
--- a/Source/CTest/cmCTestMultiProcessHandler.h
+++ b/Source/CTest/cmCTestMultiProcessHandler.h
@@ -24,12 +24,21 @@
class cmCTestMultiProcessHandler
{
friend class TestComparator;
+
public:
- struct TestSet : public std::set<int> {};
- struct TestMap : public std::map<int, TestSet> {};
- struct TestList : public std::vector<int> {};
- struct PropertiesMap : public
- std::map<int, cmCTestTestHandler::cmCTestTestProperties*> {};
+ struct TestSet : public std::set<int>
+ {
+ };
+ struct TestMap : public std::map<int, TestSet>
+ {
+ };
+ struct TestList : public std::vector<int>
+ {
+ };
+ struct PropertiesMap
+ : public std::map<int, cmCTestTestHandler::cmCTestTestProperties*>
+ {
+ };
cmCTestMultiProcessHandler();
virtual ~cmCTestMultiProcessHandler();
@@ -44,20 +53,23 @@ public:
void SetPassFailVectors(std::vector<std::string>* passed,
std::vector<std::string>* failed)
- {
+ {
this->Passed = passed;
this->Failed = failed;
- }
+ }
void SetTestResults(std::vector<cmCTestTestHandler::cmCTestTestResult>* r)
- { this->TestResults = r; }
+ {
+ this->TestResults = r;
+ }
- void SetCTest(cmCTest* ctest) { this->CTest = ctest;}
+ void SetCTest(cmCTest* ctest) { this->CTest = ctest; }
- void SetTestHandler(cmCTestTestHandler * handler)
- { this->TestHandler = handler; }
+ void SetTestHandler(cmCTestTestHandler* handler)
+ {
+ this->TestHandler = handler;
+ }
- cmCTestTestHandler * GetTestHandler()
- { return this->TestHandler; }
+ cmCTestTestHandler* GetTestHandler() { return this->TestHandler; }
void SetQuiet(bool b) { this->Quiet = b; }
protected:
@@ -88,9 +100,9 @@ protected:
// check all running processes for output and exit case
bool CheckOutput();
void RemoveTest(int index);
- //Check if we need to resume an interrupted test set
+ // Check if we need to resume an interrupted test set
void CheckResume();
- //Check if there are any circular dependencies
+ // Check if there are any circular dependencies
bool CheckCycles();
int FindMaxIndex();
inline size_t GetProcessorsUsed(int index);
@@ -101,13 +113,13 @@ protected:
// map from test number to set of depend tests
TestMap Tests;
TestList SortedTests;
- //Total number of tests we'll be running
+ // Total number of tests we'll be running
size_t Total;
- //Number of tests that are complete
+ // Number of tests that are complete
size_t Completed;
size_t RunningCount;
bool StopTimePassed;
- //list of test properties (indices concurrent to the test map)
+ // list of test properties (indices concurrent to the test map)
PropertiesMap Properties;
std::map<int, bool> TestRunningMap;
std::map<int, bool> TestFinishMap;
@@ -119,8 +131,8 @@ protected:
std::vector<cmCTestTestHandler::cmCTestTestResult>* TestResults;
size_t ParallelLevel; // max number of process that can be run at once
unsigned long TestLoad;
- std::set<cmCTestRunTest*> RunningTests; // current running tests
- cmCTestTestHandler * TestHandler;
+ std::set<cmCTestRunTest*> RunningTests; // current running tests
+ cmCTestTestHandler* TestHandler;
cmCTest* CTest;
bool HasCycles;
bool Quiet;
diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx
index e05b77a..07f9dad 100644
--- a/Source/CTest/cmCTestP4.cxx
+++ b/Source/CTest/cmCTestP4.cxx
@@ -21,8 +21,8 @@
#include <sys/types.h>
#include <time.h>
-cmCTestP4::cmCTestP4(cmCTest* ct, std::ostream& log):
- cmCTestGlobalVC(ct, log)
+cmCTestP4::cmCTestP4(cmCTest* ct, std::ostream& log)
+ : cmCTestGlobalVC(ct, log)
{
this->PriorRev = this->Unknown;
}
@@ -31,68 +31,70 @@ cmCTestP4::~cmCTestP4()
{
}
-class cmCTestP4::IdentifyParser: public cmCTestVC::LineParser
+class cmCTestP4::IdentifyParser : public cmCTestVC::LineParser
{
public:
- IdentifyParser(cmCTestP4* p4, const char* prefix,
- std::string& rev): Rev(rev)
- {
+ IdentifyParser(cmCTestP4* p4, const char* prefix, std::string& rev)
+ : Rev(rev)
+ {
this->SetLog(&p4->Log, prefix);
this->RegexIdentify.compile("^Change ([0-9]+) on");
- }
+ }
+
private:
std::string& Rev;
cmsys::RegularExpression RegexIdentify;
bool ProcessLine()
- {
- if(this->RegexIdentify.find(this->Line))
- {
+ {
+ if (this->RegexIdentify.find(this->Line)) {
this->Rev = this->RegexIdentify.match(1);
return false;
- }
- return true;
}
+ return true;
+ }
};
-class cmCTestP4::ChangesParser: public cmCTestVC::LineParser
+class cmCTestP4::ChangesParser : public cmCTestVC::LineParser
{
public:
- ChangesParser(cmCTestP4* p4, const char* prefix) : P4(p4)
- {
+ ChangesParser(cmCTestP4* p4, const char* prefix)
+ : P4(p4)
+ {
this->SetLog(&P4->Log, prefix);
this->RegexIdentify.compile("^Change ([0-9]+) on");
- }
+ }
+
private:
cmsys::RegularExpression RegexIdentify;
cmCTestP4* P4;
bool ProcessLine()
- {
- if(this->RegexIdentify.find(this->Line))
- {
+ {
+ if (this->RegexIdentify.find(this->Line)) {
P4->ChangeLists.push_back(this->RegexIdentify.match(1));
- }
- return true;
}
+ return true;
+ }
};
-class cmCTestP4::UserParser: public cmCTestVC::LineParser
+class cmCTestP4::UserParser : public cmCTestVC::LineParser
{
public:
- UserParser(cmCTestP4* p4, const char* prefix) : P4(p4)
- {
+ UserParser(cmCTestP4* p4, const char* prefix)
+ : P4(p4)
+ {
this->SetLog(&P4->Log, prefix);
this->RegexUser.compile("^(.+) <(.*)> \\((.*)\\) accessed (.*)$");
- }
+ }
+
private:
cmsys::RegularExpression RegexUser;
cmCTestP4* P4;
bool ProcessLine()
- {
- if(this->RegexUser.find(this->Line))
- {
+ {
+ if (this->RegexUser.find(this->Line)) {
User NewUser;
NewUser.UserName = this->RegexUser.match(1);
@@ -102,9 +104,9 @@ private:
P4->Users[this->RegexUser.match(1)] = NewUser;
return false;
- }
- return true;
}
+ return true;
+ }
};
/* Diff format:
@@ -116,15 +118,17 @@ private:
==== //depot/file4#rev - /absolute/path/to/file4 ====
(diff data)
*/
-class cmCTestP4::DiffParser: public cmCTestVC::LineParser
+class cmCTestP4::DiffParser : public cmCTestVC::LineParser
{
public:
DiffParser(cmCTestP4* p4, const char* prefix)
- : P4(p4), AlreadyNotified(false)
- {
+ : P4(p4)
+ , AlreadyNotified(false)
+ {
this->SetLog(&P4->Log, prefix);
this->RegexDiff.compile("^==== (.*)#[0-9]+ - (.*)");
- }
+ }
+
private:
cmCTestP4* P4;
bool AlreadyNotified;
@@ -132,32 +136,27 @@ private:
cmsys::RegularExpression RegexDiff;
bool ProcessLine()
- {
- if(!this->Line.empty() && this->Line[0] == '='
- && this->RegexDiff.find(this->Line))
- {
- CurrentPath = this->RegexDiff.match(1);
- AlreadyNotified = false;
- }
- else
- {
- if(!AlreadyNotified)
- {
+ {
+ if (!this->Line.empty() && this->Line[0] == '=' &&
+ this->RegexDiff.find(this->Line)) {
+ CurrentPath = this->RegexDiff.match(1);
+ AlreadyNotified = false;
+ } else {
+ if (!AlreadyNotified) {
P4->DoModification(PathModified, CurrentPath);
AlreadyNotified = true;
- }
}
- return true;
}
+ return true;
+ }
};
cmCTestP4::User cmCTestP4::GetUserData(const std::string& username)
{
std::map<std::string, cmCTestP4::User>::const_iterator it =
- Users.find(username);
+ Users.find(username);
- if(it == Users.end())
- {
+ if (it == Users.end()) {
std::vector<char const*> p4_users;
SetP4Options(p4_users);
p4_users.push_back("users");
@@ -172,11 +171,10 @@ cmCTestP4::User cmCTestP4::GetUserData(const std::string& username)
// The user should now be added to the map. Search again.
it = Users.find(username);
- if(it == Users.end())
- {
+ if (it == Users.end()) {
return cmCTestP4::User();
- }
}
+ }
return it->second;
}
@@ -195,16 +193,19 @@ Affected files ...
... //path/to/file#rev delete
... //path/to/file#rev integrate
*/
-class cmCTestP4::DescribeParser: public cmCTestVC::LineParser
+class cmCTestP4::DescribeParser : public cmCTestVC::LineParser
{
public:
- DescribeParser(cmCTestP4* p4, const char* prefix):
- LineParser('\n', false), P4(p4), Section(SectionHeader)
- {
+ DescribeParser(cmCTestP4* p4, const char* prefix)
+ : LineParser('\n', false)
+ , P4(p4)
+ , Section(SectionHeader)
+ {
this->SetLog(&P4->Log, prefix);
this->RegexHeader.compile("^Change ([0-9]+) by (.+)@(.+) on (.*)$");
this->RegexDiff.compile("^\\.\\.\\. (.*)#[0-9]+ ([^ ]+)$");
- }
+ }
+
private:
cmsys::RegularExpression RegexHeader;
cmsys::RegularExpression RegexDiff;
@@ -213,46 +214,54 @@ private:
typedef cmCTestP4::Revision Revision;
typedef cmCTestP4::Change Change;
std::vector<Change> Changes;
- enum SectionType { SectionHeader, SectionBody, SectionDiffHeader,
- SectionDiff, SectionCount };
+ enum SectionType
+ {
+ SectionHeader,
+ SectionBody,
+ SectionDiffHeader,
+ SectionDiff,
+ SectionCount
+ };
SectionType Section;
Revision Rev;
virtual bool ProcessLine()
- {
- if(this->Line.empty())
- {
+ {
+ if (this->Line.empty()) {
this->NextSection();
+ } else {
+ switch (this->Section) {
+ case SectionHeader:
+ this->DoHeaderLine();
+ break;
+ case SectionBody:
+ this->DoBodyLine();
+ break;
+ case SectionDiffHeader:
+ break; // nothing to do
+ case SectionDiff:
+ this->DoDiffLine();
+ break;
+ case SectionCount:
+ break; // never happens
}
- else
- {
- switch(this->Section)
- {
- case SectionHeader: this->DoHeaderLine(); break;
- case SectionBody: this->DoBodyLine(); break;
- case SectionDiffHeader: break; // nothing to do
- case SectionDiff: this->DoDiffLine(); break;
- case SectionCount: break; // never happens
- }
- }
- return true;
- }
+ }
+ return true;
+ }
void NextSection()
- {
- if(this->Section == SectionDiff)
- {
+ {
+ if (this->Section == SectionDiff) {
this->P4->DoRevision(this->Rev, this->Changes);
this->Rev = Revision();
}
- this->Section = SectionType((this->Section+1) % SectionCount);
- }
+ this->Section = SectionType((this->Section + 1) % SectionCount);
+ }
void DoHeaderLine()
- {
- if(this->RegexHeader.find(this->Line))
- {
+ {
+ if (this->RegexHeader.find(this->Line)) {
this->Rev.Rev = this->RegexHeader.match(1);
this->Rev.Date = this->RegexHeader.match(4);
@@ -263,90 +272,78 @@ private:
this->Rev.Committer = this->Rev.Author;
this->Rev.CommitterEMail = this->Rev.EMail;
this->Rev.CommitDate = this->Rev.Date;
- }
}
+ }
void DoBodyLine()
- {
- if(this->Line[0] == '\t')
- {
+ {
+ if (this->Line[0] == '\t') {
this->Rev.Log += this->Line.substr(1);
- }
- this->Rev.Log += "\n";
}
+ this->Rev.Log += "\n";
+ }
void DoDiffLine()
- {
- if(this->RegexDiff.find(this->Line))
- {
- Change change;
- std::string Path = this->RegexDiff.match(1);
- if(Path.length() > 2 && Path[0] == '/' && Path[1] == '/')
- {
- size_t found = Path.find('/', 2);
- if(found != std::string::npos)
- {
- Path = Path.substr(found + 1);
+ {
+ if (this->RegexDiff.find(this->Line)) {
+ Change change;
+ std::string Path = this->RegexDiff.match(1);
+ if (Path.length() > 2 && Path[0] == '/' && Path[1] == '/') {
+ size_t found = Path.find('/', 2);
+ if (found != std::string::npos) {
+ Path = Path.substr(found + 1);
}
}
- change.Path = Path;
- std::string action = this->RegexDiff.match(2);
+ change.Path = Path;
+ std::string action = this->RegexDiff.match(2);
- if(action == "add")
- {
- change.Action = 'A';
- }
- else if(action == "delete")
- {
- change.Action = 'D';
- }
- else if(action == "edit" || action == "integrate")
- {
- change.Action = 'M';
+ if (action == "add") {
+ change.Action = 'A';
+ } else if (action == "delete") {
+ change.Action = 'D';
+ } else if (action == "edit" || action == "integrate") {
+ change.Action = 'M';
}
- Changes.push_back(change);
+ Changes.push_back(change);
}
}
};
-void cmCTestP4::SetP4Options(std::vector<char const*> &CommandOptions)
+void cmCTestP4::SetP4Options(std::vector<char const*>& CommandOptions)
{
- if(P4Options.empty())
- {
+ if (P4Options.empty()) {
const char* p4 = this->CommandLineTool.c_str();
P4Options.push_back(p4);
- //The CTEST_P4_CLIENT variable sets the P4 client used when issuing
- //Perforce commands, if it's different from the default one.
+ // The CTEST_P4_CLIENT variable sets the P4 client used when issuing
+ // Perforce commands, if it's different from the default one.
std::string client = this->CTest->GetCTestConfiguration("P4Client");
- if(!client.empty())
- {
+ if (!client.empty()) {
P4Options.push_back("-c");
P4Options.push_back(client);
- }
+ }
- //Set the message language to be English, in case the P4 admin
- //has localized them
+ // Set the message language to be English, in case the P4 admin
+ // has localized them
P4Options.push_back("-L");
P4Options.push_back("en");
- //The CTEST_P4_OPTIONS variable adds additional Perforce command line
- //options before the main command
+ // The CTEST_P4_OPTIONS variable adds additional Perforce command line
+ // options before the main command
std::string opts = this->CTest->GetCTestConfiguration("P4Options");
std::vector<std::string> args =
- cmSystemTools::ParseArguments(opts.c_str());
+ cmSystemTools::ParseArguments(opts.c_str());
P4Options.insert(P4Options.end(), args.begin(), args.end());
- }
+ }
CommandOptions.clear();
- for(std::vector<std::string>::iterator i = P4Options.begin();
- i != P4Options.end(); ++i)
- {
+ for (std::vector<std::string>::iterator i = P4Options.begin();
+ i != P4Options.end(); ++i) {
CommandOptions.push_back(i->c_str());
- }
+ }
}
std::string cmCTestP4::GetWorkingRevision()
@@ -370,19 +367,15 @@ std::string cmCTestP4::GetWorkingRevision()
bool result = RunChild(&p4_identify[0], &out, &err);
// If there was a problem contacting the server return "<unknown>"
- if(!result)
- {
+ if (!result) {
return "<unknown>";
- }
+ }
- if(rev.empty())
- {
+ if (rev.empty()) {
return "0";
- }
- else
- {
+ } else {
return rev;
- }
+ }
}
void cmCTestP4::NoteOldRevision()
@@ -390,7 +383,7 @@ void cmCTestP4::NoteOldRevision()
this->OldRevision = this->GetWorkingRevision();
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Old revision of repository is: "
- << this->OldRevision << "\n");
+ << this->OldRevision << "\n");
this->PriorRev.Rev = this->OldRevision;
}
@@ -399,7 +392,7 @@ void cmCTestP4::NoteNewRevision()
this->NewRevision = this->GetWorkingRevision();
cmCTestLog(this->CTest, HANDLER_OUTPUT, " New revision of repository is: "
- << this->NewRevision << "\n");
+ << this->NewRevision << "\n");
}
void cmCTestP4::LoadRevisions()
@@ -412,15 +405,16 @@ void cmCTestP4::LoadRevisions()
// If any revision is unknown it means we couldn't contact the server.
// Do not process updates
- if(this->OldRevision == "<unknown>" || this->NewRevision == "<unknown>")
- {
+ 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");
+ << "is unknown. No repository changes will be reported.\n");
return;
- }
+ }
- range.append("@").append(this->OldRevision)
- .append(",").append(this->NewRevision);
+ range.append("@")
+ .append(this->OldRevision)
+ .append(",")
+ .append(this->NewRevision);
p4_changes.push_back("changes");
p4_changes.push_back(range.c_str());
@@ -432,14 +426,13 @@ void cmCTestP4::LoadRevisions()
ChangeLists.clear();
this->RunChild(&p4_changes[0], &out, &err);
- if(ChangeLists.empty())
- return;
+ if (ChangeLists.empty())
+ return;
- //p4 describe -s ...@1111111,2222222
+ // p4 describe -s ...@1111111,2222222
std::vector<char const*> p4_describe;
- for(std::vector<std::string>::reverse_iterator i = ChangeLists.rbegin();
- i != ChangeLists.rend(); ++i)
- {
+ for (std::vector<std::string>::reverse_iterator i = ChangeLists.rbegin();
+ i != ChangeLists.rend(); ++i) {
SetP4Options(p4_describe);
p4_describe.push_back("describe");
p4_describe.push_back("-s");
@@ -449,7 +442,7 @@ void cmCTestP4::LoadRevisions()
DescribeParser outDescribe(this, "p4_describe-out> ");
OutputLogger errDescribe(this->Log, "p4_describe-err> ");
this->RunChild(&p4_describe[0], &outDescribe, &errDescribe);
- }
+ }
}
void cmCTestP4::LoadModifications()
@@ -459,7 +452,7 @@ void cmCTestP4::LoadModifications()
p4_diff.push_back("diff");
- //Ideally we would use -Od but not all clients support it
+ // Ideally we would use -Od but not all clients support it
p4_diff.push_back("-dn");
std::string source = this->SourceDirectory + "/...";
p4_diff.push_back(source.c_str());
@@ -476,11 +469,10 @@ bool cmCTestP4::UpdateCustom(const std::string& custom)
cmSystemTools::ExpandListArgument(custom, p4_custom_command, true);
std::vector<char const*> p4_custom;
- for(std::vector<std::string>::const_iterator
- i = p4_custom_command.begin(); i != p4_custom_command.end(); ++i)
- {
+ for (std::vector<std::string>::const_iterator i = p4_custom_command.begin();
+ i != p4_custom_command.end(); ++i) {
p4_custom.push_back(i->c_str());
- }
+ }
p4_custom.push_back(0);
OutputLogger custom_out(this->Log, "p4_customsync-out> ");
@@ -492,18 +484,16 @@ bool cmCTestP4::UpdateCustom(const std::string& custom)
bool cmCTestP4::UpdateImpl()
{
std::string custom = this->CTest->GetCTestConfiguration("P4UpdateCustom");
- if(!custom.empty())
- {
+ if (!custom.empty()) {
return this->UpdateCustom(custom);
- }
+ }
// If we couldn't get a revision number before updating, abort.
- if(this->OldRevision == "<unknown>")
- {
+ if (this->OldRevision == "<unknown>") {
this->UpdateCommandLine = "Unknown current revision";
cmCTestLog(this->CTest, ERROR_MESSAGE, " Unknown current revision\n");
return false;
- }
+ }
std::vector<char const*> p4_sync;
SetP4Options(p4_sync);
@@ -512,29 +502,26 @@ bool cmCTestP4::UpdateImpl()
// Get user-specified update options.
std::string opts = this->CTest->GetCTestConfiguration("UpdateOptions");
- if(opts.empty())
- {
+ if (opts.empty()) {
opts = this->CTest->GetCTestConfiguration("P4UpdateOptions");
- }
+ }
std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
- for(std::vector<std::string>::const_iterator ai = args.begin();
- ai != args.end(); ++ai)
- {
+ for (std::vector<std::string>::const_iterator ai = args.begin();
+ ai != args.end(); ++ai) {
p4_sync.push_back(ai->c_str());
- }
+ }
std::string source = this->SourceDirectory + "/...";
// Specify the start time for nightly testing.
- if(this->CTest->GetTestModel() == cmCTest::NIGHTLY)
- {
+ if (this->CTest->GetTestModel() == cmCTest::NIGHTLY) {
std::string date = this->GetNightlyTime();
- //CTest reports the date as YYYY-MM-DD, Perforce needs it as YYYY/MM/DD
+ // CTest reports the date as YYYY-MM-DD, Perforce needs it as YYYY/MM/DD
std::replace(date.begin(), date.end(), '-', '/');
- //Revision specification: /...@"YYYY/MM/DD HH:MM:SS"
+ // Revision specification: /...@"YYYY/MM/DD HH:MM:SS"
source.append("@\"").append(date).append("\"");
- }
+ }
p4_sync.push_back(source.c_str());
p4_sync.push_back(0);
diff --git a/Source/CTest/cmCTestP4.h b/Source/CTest/cmCTestP4.h
index d666bd8..917751e 100644
--- a/Source/CTest/cmCTestP4.h
+++ b/Source/CTest/cmCTestP4.h
@@ -21,7 +21,7 @@
* \brief Interaction with the Perforce command-line tool
*
*/
-class cmCTestP4: public cmCTestGlobalVC
+class cmCTestP4 : public cmCTestGlobalVC
{
public:
/** Construct with a CTest instance and update log stream. */
@@ -33,19 +33,25 @@ private:
std::vector<std::string> ChangeLists;
struct User
- {
+ {
std::string UserName;
std::string Name;
std::string EMail;
std::string AccessTime;
- User(): UserName(), Name(), EMail(), AccessTime() {}
- };
+ User()
+ : UserName()
+ , Name()
+ , EMail()
+ , AccessTime()
+ {
+ }
+ };
std::map<std::string, User> Users;
std::vector<std::string> P4Options;
User GetUserData(const std::string& username);
- void SetP4Options(std::vector<char const*> &options);
+ void SetP4Options(std::vector<char const*>& options);
std::string GetWorkingRevision();
virtual void NoteOldRevision();
diff --git a/Source/CTest/cmCTestReadCustomFilesCommand.cxx b/Source/CTest/cmCTestReadCustomFilesCommand.cxx
index 5db01f9..2613c1c 100644
--- a/Source/CTest/cmCTestReadCustomFilesCommand.cxx
+++ b/Source/CTest/cmCTestReadCustomFilesCommand.cxx
@@ -13,23 +13,18 @@
#include "cmCTest.h"
-bool cmCTestReadCustomFilesCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmCTestReadCustomFilesCommand::InitialPass(
+ std::vector<std::string> const& args, cmExecutionStatus&)
{
- if (args.size() < 1)
- {
+ if (args.size() < 1) {
this->SetError("called with incorrect number of arguments");
return false;
- }
+ }
std::vector<std::string>::const_iterator dit;
- for ( dit = args.begin(); dit != args.end(); ++ dit )
- {
- this->CTest->ReadCustomConfigurationFileTree(dit->c_str(),
- this->Makefile);
- }
+ for (dit = args.begin(); dit != args.end(); ++dit) {
+ this->CTest->ReadCustomConfigurationFileTree(dit->c_str(), this->Makefile);
+ }
return true;
}
-
-
diff --git a/Source/CTest/cmCTestReadCustomFilesCommand.h b/Source/CTest/cmCTestReadCustomFilesCommand.h
index c95694a..713fc66 100644
--- a/Source/CTest/cmCTestReadCustomFilesCommand.h
+++ b/Source/CTest/cmCTestReadCustomFilesCommand.h
@@ -23,34 +23,31 @@
class cmCTestReadCustomFilesCommand : public cmCTestCommand
{
public:
-
cmCTestReadCustomFilesCommand() {}
/**
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
- {
+ {
cmCTestReadCustomFilesCommand* ni = new cmCTestReadCustomFilesCommand;
ni->CTest = this->CTest;
return ni;
- }
+ }
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus &status);
+ cmExecutionStatus& status);
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const { return "ctest_read_custom_files";}
+ virtual std::string GetName() const { return "ctest_read_custom_files"; }
cmTypeMacro(cmCTestReadCustomFilesCommand, cmCTestCommand);
-
};
-
#endif
diff --git a/Source/CTest/cmCTestRunScriptCommand.cxx b/Source/CTest/cmCTestRunScriptCommand.cxx
index 7afbe04..e143d50 100644
--- a/Source/CTest/cmCTestRunScriptCommand.cxx
+++ b/Source/CTest/cmCTestRunScriptCommand.cxx
@@ -13,53 +13,41 @@
#include "cmCTestScriptHandler.h"
-bool cmCTestRunScriptCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmCTestRunScriptCommand::InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus&)
{
- if(args.size() < 1 )
- {
+ if (args.size() < 1) {
this->CTestScriptHandler->RunCurrentScript();
return true;
- }
+ }
bool np = false;
unsigned int i = 0;
- if (args[i] == "NEW_PROCESS")
- {
+ if (args[i] == "NEW_PROCESS") {
np = true;
i++;
- }
+ }
int start = i;
// run each script
std::string returnVariable;
- for (i = start; i < args.size(); ++i)
- {
- if(args[i] == "RETURN_VALUE")
- {
+ for (i = start; i < args.size(); ++i) {
+ if (args[i] == "RETURN_VALUE") {
++i;
- if(i < args.size())
- {
+ if (i < args.size()) {
returnVariable = args[i];
- }
}
}
- for (i = start; i < args.size(); ++i)
- {
- if(args[i] == "RETURN_VALUE")
- {
+ }
+ for (i = start; i < args.size(); ++i) {
+ if (args[i] == "RETURN_VALUE") {
++i;
- }
- else
- {
+ } else {
int ret;
- cmCTestScriptHandler::RunScript(this->CTest, args[i].c_str(), !np,
- &ret);
+ cmCTestScriptHandler::RunScript(this->CTest, args[i].c_str(), !np, &ret);
std::ostringstream str;
str << ret;
this->Makefile->AddDefinition(returnVariable, str.str().c_str());
- }
}
+ }
return true;
}
-
-
diff --git a/Source/CTest/cmCTestRunScriptCommand.h b/Source/CTest/cmCTestRunScriptCommand.h
index 0998e5c..c503516 100644
--- a/Source/CTest/cmCTestRunScriptCommand.h
+++ b/Source/CTest/cmCTestRunScriptCommand.h
@@ -23,34 +23,32 @@
class cmCTestRunScriptCommand : public cmCTestCommand
{
public:
-
cmCTestRunScriptCommand() {}
/**
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
- {
+ {
cmCTestRunScriptCommand* ni = new cmCTestRunScriptCommand;
ni->CTest = this->CTest;
ni->CTestScriptHandler = this->CTestScriptHandler;
return ni;
- }
+ }
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus &status);
+ cmExecutionStatus& status);
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const { return "ctest_run_script";}
+ virtual std::string GetName() const { return "ctest_run_script"; }
cmTypeMacro(cmCTestRunScriptCommand, cmCTestCommand);
};
-
#endif
diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx
index 1fa008d..59383af 100644
--- a/Source/CTest/cmCTestRunTest.cxx
+++ b/Source/CTest/cmCTestRunTest.cxx
@@ -25,7 +25,7 @@ cmCTestRunTest::cmCTestRunTest(cmCTestTestHandler* handler)
this->CTest = handler->CTest;
this->TestHandler = handler;
this->TestProcess = 0;
- this->TestResult.ExecutionTime =0;
+ this->TestResult.ExecutionTime = 0;
this->TestResult.ReturnValue = 0;
this->TestResult.Status = cmCTestTestHandler::NOT_RUN;
this->TestResult.TestCount = 0;
@@ -36,7 +36,7 @@ cmCTestRunTest::cmCTestRunTest(cmCTestTestHandler* handler)
this->StopTimePassed = false;
this->NumberOfRunsLeft = 1; // default to 1 run of the test
this->RunUntilFail = false; // default to run the test once
- this->RunAgain = false; // default to not having to run again
+ this->RunAgain = false; // default to not having to run again
}
cmCTestRunTest::~cmCTestRunTest()
@@ -49,51 +49,44 @@ bool cmCTestRunTest::CheckOutput()
double timeout = 0.1;
double timeEnd = cmSystemTools::GetTime() + timeout;
std::string line;
- while((timeout = timeEnd - cmSystemTools::GetTime(), timeout > 0))
- {
+ while ((timeout = timeEnd - cmSystemTools::GetTime(), timeout > 0)) {
int p = this->TestProcess->GetNextOutputLine(line, timeout);
- if(p == cmsysProcess_Pipe_None)
- {
+ if (p == cmsysProcess_Pipe_None) {
// Process has terminated and all output read.
return false;
- }
- else if(p == cmsysProcess_Pipe_STDOUT)
- {
+ } else if (p == cmsysProcess_Pipe_STDOUT) {
// Store this line of output.
- cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- this->GetIndex() << ": " << line << std::endl);
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->GetIndex()
+ << ": " << line << std::endl);
this->ProcessOutput += line;
this->ProcessOutput += "\n";
// Check for TIMEOUT_AFTER_MATCH property.
- if (!this->TestProperties->TimeoutRegularExpressions.empty())
- {
- std::vector<std::pair<cmsys::RegularExpression,
- std::string> >::iterator regIt;
- for ( regIt = this->TestProperties->TimeoutRegularExpressions.begin();
- regIt != this->TestProperties->TimeoutRegularExpressions.end();
- ++ regIt )
- {
- if ( regIt->first.find(this->ProcessOutput.c_str()) )
- {
- cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- this->GetIndex() << ": " <<
- "Test timeout changed to " <<
- this->TestProperties->AlternateTimeout << std::endl);
+ if (!this->TestProperties->TimeoutRegularExpressions.empty()) {
+ std::vector<
+ std::pair<cmsys::RegularExpression, std::string> >::iterator regIt;
+ for (regIt = this->TestProperties->TimeoutRegularExpressions.begin();
+ regIt != this->TestProperties->TimeoutRegularExpressions.end();
+ ++regIt) {
+ if (regIt->first.find(this->ProcessOutput.c_str())) {
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->GetIndex()
+ << ": "
+ << "Test timeout changed to "
+ << this->TestProperties->AlternateTimeout
+ << std::endl);
this->TestProcess->ResetStartTime();
this->TestProcess->ChangeTimeout(
this->TestProperties->AlternateTimeout);
this->TestProperties->TimeoutRegularExpressions.clear();
break;
- }
}
}
}
- else // if(p == cmsysProcess_Pipe_Timeout)
- {
+ } else // if(p == cmsysProcess_Pipe_Timeout)
+ {
break;
- }
}
+ }
return true;
}
@@ -104,10 +97,9 @@ void cmCTestRunTest::CompressOutput()
int ret;
z_stream strm;
- unsigned char* in =
- reinterpret_cast<unsigned char*>(
+ unsigned char* in = reinterpret_cast<unsigned char*>(
const_cast<char*>(this->ProcessOutput.c_str()));
- //zlib makes the guarantee that this is the maximum output size
+ // zlib makes the guarantee that this is the maximum output size
int outSize = static_cast<int>(
static_cast<double>(this->ProcessOutput.size()) * 1.001 + 13.0);
unsigned char* out = new unsigned char[outSize];
@@ -115,12 +107,11 @@ void cmCTestRunTest::CompressOutput()
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
- ret = deflateInit(&strm, -1); //default compression level
- if (ret != Z_OK)
- {
+ ret = deflateInit(&strm, -1); // default compression level
+ if (ret != Z_OK) {
delete[] out;
return;
- }
+ }
strm.avail_in = static_cast<uInt>(this->ProcessOutput.size());
strm.next_in = in;
@@ -128,139 +119,116 @@ void cmCTestRunTest::CompressOutput()
strm.next_out = out;
ret = deflate(&strm, Z_FINISH);
- if(ret == Z_STREAM_ERROR || ret != Z_STREAM_END)
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Error during output "
- "compression. Sending uncompressed output." << std::endl);
+ if (ret == Z_STREAM_ERROR || ret != Z_STREAM_END) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Error during output "
+ "compression. Sending uncompressed output."
+ << std::endl);
delete[] out;
return;
- }
+ }
(void)deflateEnd(&strm);
- unsigned char *encoded_buffer
- = new unsigned char[static_cast<int>(outSize * 1.5)];
+ unsigned char* encoded_buffer =
+ new unsigned char[static_cast<int>(outSize * 1.5)];
- size_t rlen
- = cmsysBase64_Encode(out, strm.total_out, encoded_buffer, 1);
+ size_t rlen = cmsysBase64_Encode(out, strm.total_out, encoded_buffer, 1);
- for(size_t i = 0; i < rlen; i++)
- {
+ for (size_t i = 0; i < rlen; i++) {
this->CompressedOutput += encoded_buffer[i];
- }
+ }
- if(strm.total_in)
- {
- this->CompressionRatio = static_cast<double>(strm.total_out) /
- static_cast<double>(strm.total_in);
- }
+ if (strm.total_in) {
+ this->CompressionRatio =
+ static_cast<double>(strm.total_out) / static_cast<double>(strm.total_in);
+ }
- delete [] encoded_buffer;
- delete [] out;
+ delete[] encoded_buffer;
+ delete[] out;
}
bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
{
if ((!this->TestHandler->MemCheck &&
- this->CTest->ShouldCompressTestOutput()) ||
+ this->CTest->ShouldCompressTestOutput()) ||
(this->TestHandler->MemCheck &&
- this->CTest->ShouldCompressMemCheckOutput()))
- {
+ this->CTest->ShouldCompressMemCheckOutput())) {
this->CompressOutput();
- }
+ }
this->WriteLogOutputTop(completed, total);
std::string reason;
bool passed = true;
- int res = started ? this->TestProcess->GetProcessStatus()
- : cmsysProcess_State_Error;
+ int res =
+ started ? this->TestProcess->GetProcessStatus() : cmsysProcess_State_Error;
int retVal = this->TestProcess->GetExitValue();
- std::vector<std::pair<cmsys::RegularExpression,
- std::string> >::iterator passIt;
+ std::vector<std::pair<cmsys::RegularExpression, std::string> >::iterator
+ passIt;
bool forceFail = false;
bool outputTestErrorsToConsole = false;
- if (!this->TestProperties->RequiredRegularExpressions.empty())
- {
+ if (!this->TestProperties->RequiredRegularExpressions.empty()) {
bool found = false;
- for ( passIt = this->TestProperties->RequiredRegularExpressions.begin();
- passIt != this->TestProperties->RequiredRegularExpressions.end();
- ++ passIt )
- {
- if ( passIt->first.find(this->ProcessOutput.c_str()) )
- {
+ for (passIt = this->TestProperties->RequiredRegularExpressions.begin();
+ passIt != this->TestProperties->RequiredRegularExpressions.end();
+ ++passIt) {
+ if (passIt->first.find(this->ProcessOutput.c_str())) {
found = true;
reason = "Required regular expression found.";
break;
- }
}
- if ( !found )
- {
+ }
+ if (!found) {
reason = "Required regular expression not found.";
forceFail = true;
- }
- reason += "Regex=[";
- for ( passIt = this->TestProperties->RequiredRegularExpressions.begin();
- passIt != this->TestProperties->RequiredRegularExpressions.end();
- ++ passIt )
- {
+ }
+ reason += "Regex=[";
+ for (passIt = this->TestProperties->RequiredRegularExpressions.begin();
+ passIt != this->TestProperties->RequiredRegularExpressions.end();
+ ++passIt) {
reason += passIt->second;
reason += "\n";
- }
- reason += "]";
}
- if (!this->TestProperties->ErrorRegularExpressions.empty())
- {
- for ( passIt = this->TestProperties->ErrorRegularExpressions.begin();
- passIt != this->TestProperties->ErrorRegularExpressions.end();
- ++ passIt )
- {
- if ( passIt->first.find(this->ProcessOutput.c_str()) )
- {
+ reason += "]";
+ }
+ if (!this->TestProperties->ErrorRegularExpressions.empty()) {
+ for (passIt = this->TestProperties->ErrorRegularExpressions.begin();
+ passIt != this->TestProperties->ErrorRegularExpressions.end();
+ ++passIt) {
+ if (passIt->first.find(this->ProcessOutput.c_str())) {
reason = "Error regular expression found in output.";
reason += " Regex=[";
reason += passIt->second;
reason += "]";
forceFail = true;
break;
- }
}
}
- if (res == cmsysProcess_State_Exited)
- {
- bool success =
- !forceFail && (retVal == 0 ||
- this->TestProperties->RequiredRegularExpressions.size());
- if(this->TestProperties->SkipReturnCode >= 0
- && this->TestProperties->SkipReturnCode == retVal)
- {
+ }
+ if (res == cmsysProcess_State_Exited) {
+ bool success = !forceFail &&
+ (retVal == 0 || this->TestProperties->RequiredRegularExpressions.size());
+ if (this->TestProperties->SkipReturnCode >= 0 &&
+ this->TestProperties->SkipReturnCode == retVal) {
this->TestResult.Status = cmCTestTestHandler::NOT_RUN;
cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Skipped ");
- }
- else if((success && !this->TestProperties->WillFail)
- || (!success && this->TestProperties->WillFail))
- {
+ } else if ((success && !this->TestProperties->WillFail) ||
+ (!success && this->TestProperties->WillFail)) {
this->TestResult.Status = cmCTestTestHandler::COMPLETED;
- cmCTestLog(this->CTest, HANDLER_OUTPUT, " Passed " );
- }
- else
- {
+ cmCTestLog(this->CTest, HANDLER_OUTPUT, " Passed ");
+ } else {
this->TestResult.Status = cmCTestTestHandler::FAILED;
- cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Failed " << reason );
+ cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Failed " << reason);
outputTestErrorsToConsole = this->CTest->OutputTestOutputOnTestFailure;
- }
}
- else if ( res == cmsysProcess_State_Expired )
- {
+ } else if (res == cmsysProcess_State_Expired) {
cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Timeout ");
this->TestResult.Status = cmCTestTestHandler::TIMEOUT;
outputTestErrorsToConsole = this->CTest->OutputTestOutputOnTestFailure;
- }
- else if ( res == cmsysProcess_State_Exception )
- {
+ } else if (res == cmsysProcess_State_Exception) {
outputTestErrorsToConsole = this->CTest->OutputTestOutputOnTestFailure;
cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Exception: ");
- switch(this->TestProcess->GetExitException())
- {
+ switch (this->TestProcess->GetExitException()) {
case cmsysProcess_Exception_Fault:
cmCTestLog(this->CTest, HANDLER_OUTPUT, "SegFault");
this->TestResult.Status = cmCTestTestHandler::SEGFAULT;
@@ -280,27 +248,24 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
default:
cmCTestLog(this->CTest, HANDLER_OUTPUT, "Other");
this->TestResult.Status = cmCTestTestHandler::OTHER_FAULT;
- }
}
- else //cmsysProcess_State_Error
- {
+ } else // cmsysProcess_State_Error
+ {
cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Not Run ");
- }
+ }
passed = this->TestResult.Status == cmCTestTestHandler::COMPLETED;
char buf[1024];
sprintf(buf, "%6.2f sec", this->TestProcess->GetTotalTime());
- cmCTestLog(this->CTest, HANDLER_OUTPUT, buf << "\n" );
+ cmCTestLog(this->CTest, HANDLER_OUTPUT, buf << "\n");
- if ( outputTestErrorsToConsole )
- {
- cmCTestLog(this->CTest, HANDLER_OUTPUT, this->ProcessOutput << std::endl );
- }
+ if (outputTestErrorsToConsole) {
+ cmCTestLog(this->CTest, HANDLER_OUTPUT, this->ProcessOutput << std::endl);
+ }
- if ( this->TestHandler->LogFile )
- {
+ if (this->TestHandler->LogFile) {
*this->TestHandler->LogFile << "Test time = " << buf << std::endl;
- }
+ }
// Set the working directory to the tests directory
std::string oldpath = cmSystemTools::GetCurrentWorkingDirectory();
@@ -311,28 +276,25 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
// restore working directory
cmSystemTools::ChangeDirectory(oldpath);
-
// if this is doing MemCheck then all the output needs to be put into
// Output since that is what is parsed by cmCTestMemCheckHandler
- if(!this->TestHandler->MemCheck && started)
- {
- this->TestHandler->CleanTestOutput(this->ProcessOutput,
- static_cast<size_t>
- (this->TestResult.Status == cmCTestTestHandler::COMPLETED ?
- this->TestHandler->CustomMaximumPassedTestOutputSize :
- this->TestHandler->CustomMaximumFailedTestOutputSize));
- }
+ if (!this->TestHandler->MemCheck && started) {
+ this->TestHandler->CleanTestOutput(
+ this->ProcessOutput,
+ static_cast<size_t>(
+ this->TestResult.Status == cmCTestTestHandler::COMPLETED
+ ? this->TestHandler->CustomMaximumPassedTestOutputSize
+ : this->TestHandler->CustomMaximumFailedTestOutputSize));
+ }
this->TestResult.Reason = reason;
- if (this->TestHandler->LogFile)
- {
+ if (this->TestHandler->LogFile) {
bool pass = true;
const char* reasonType = "Test Pass Reason";
- if(this->TestResult.Status != cmCTestTestHandler::COMPLETED &&
- this->TestResult.Status != cmCTestTestHandler::NOT_RUN)
- {
+ if (this->TestResult.Status != cmCTestTestHandler::COMPLETED &&
+ this->TestResult.Status != cmCTestTestHandler::NOT_RUN) {
reasonType = "Test Fail Reason";
pass = false;
- }
+ }
double ttime = this->TestProcess->GetTotalTime();
int hours = static_cast<int>(ttime / (60 * 60));
int minutes = static_cast<int>(ttime / 60) % 60;
@@ -342,61 +304,53 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
*this->TestHandler->LogFile
<< "----------------------------------------------------------"
<< std::endl;
- if(!this->TestResult.Reason.empty())
- {
+ if (!this->TestResult.Reason.empty()) {
*this->TestHandler->LogFile << reasonType << ":\n"
- << this->TestResult.Reason << "\n";
- }
- else
- {
- if(pass)
- {
+ << this->TestResult.Reason << "\n";
+ } else {
+ if (pass) {
*this->TestHandler->LogFile << "Test Passed.\n";
- }
- else
- {
+ } else {
*this->TestHandler->LogFile << "Test Failed.\n";
- }
}
- *this->TestHandler->LogFile << "\"" << this->TestProperties->Name
+ }
+ *this->TestHandler->LogFile
+ << "\"" << this->TestProperties->Name
<< "\" end time: " << this->CTest->CurrentTime() << std::endl
- << "\"" << this->TestProperties->Name << "\" time elapsed: "
- << buffer << std::endl
+ << "\"" << this->TestProperties->Name << "\" time elapsed: " << buffer
+ << std::endl
<< "----------------------------------------------------------"
- << std::endl << std::endl;
- }
+ << std::endl
+ << std::endl;
+ }
// if the test actually started and ran
// record the results in TestResult
- if(started)
- {
+ if (started) {
bool compress = !this->TestHandler->MemCheck &&
- this->CompressionRatio < 1 &&
- this->CTest->ShouldCompressTestOutput();
- this->TestResult.Output = compress ? this->CompressedOutput
- : this->ProcessOutput;
+ this->CompressionRatio < 1 && this->CTest->ShouldCompressTestOutput();
+ this->TestResult.Output =
+ compress ? this->CompressedOutput : this->ProcessOutput;
this->TestResult.CompressOutput = compress;
this->TestResult.ReturnValue = this->TestProcess->GetExitValue();
this->TestResult.CompletionStatus = "Completed";
this->TestResult.ExecutionTime = this->TestProcess->GetTotalTime();
this->MemCheckPostProcess();
this->ComputeWeightedCost();
- }
+ }
// If the test does not need to rerun push the current TestResult onto the
// TestHandler vector
- if(!this->NeedsToRerun())
- {
+ if (!this->NeedsToRerun()) {
this->TestHandler->TestResults.push_back(this->TestResult);
- }
+ }
delete this->TestProcess;
return passed;
}
bool cmCTestRunTest::StartAgain()
{
- if(!this->RunAgain)
- {
+ if (!this->RunAgain) {
return false;
- }
+ }
this->RunAgain = false; // reset
// change to tests directory
std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory();
@@ -410,19 +364,17 @@ bool cmCTestRunTest::StartAgain()
bool cmCTestRunTest::NeedsToRerun()
{
this->NumberOfRunsLeft--;
- if(this->NumberOfRunsLeft == 0)
- {
+ if (this->NumberOfRunsLeft == 0) {
return false;
- }
+ }
// if number of runs left is not 0, and we are running until
// we find a failed test, then return true so the test can be
// restarted
- if(this->RunUntilFail
- && this->TestResult.Status == cmCTestTestHandler::COMPLETED)
- {
+ if (this->RunUntilFail &&
+ this->TestResult.Status == cmCTestTestHandler::COMPLETED) {
this->RunAgain = true;
return true;
- }
+ }
return false;
}
void cmCTestRunTest::ComputeWeightedCost()
@@ -431,27 +383,25 @@ void cmCTestRunTest::ComputeWeightedCost()
double avgcost = static_cast<double>(this->TestProperties->Cost);
double current = this->TestResult.ExecutionTime;
- if(this->TestResult.Status == cmCTestTestHandler::COMPLETED)
- {
+ if (this->TestResult.Status == cmCTestTestHandler::COMPLETED) {
this->TestProperties->Cost =
static_cast<float>(((prev * avgcost) + current) / (prev + 1.0));
this->TestProperties->PreviousRuns++;
- }
+ }
}
void cmCTestRunTest::MemCheckPostProcess()
{
- if(!this->TestHandler->MemCheck)
- {
+ if (!this->TestHandler->MemCheck) {
return;
- }
+ }
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->Index
- << ": process test output now: "
- << this->TestProperties->Name << " "
- << this->TestResult.Name << std::endl,
- this->TestHandler->GetQuiet());
- cmCTestMemCheckHandler * handler = static_cast<cmCTestMemCheckHandler*>
- (this->TestHandler);
+ << ": process test output now: "
+ << this->TestProperties->Name << " "
+ << this->TestResult.Name << std::endl,
+ this->TestHandler->GetQuiet());
+ cmCTestMemCheckHandler* handler =
+ static_cast<cmCTestMemCheckHandler*>(this->TestHandler);
handler->PostProcessTest(this->TestResult, this->Index);
}
@@ -459,11 +409,11 @@ void cmCTestRunTest::MemCheckPostProcess()
bool cmCTestRunTest::StartTest(size_t total)
{
this->TotalNumberOfTests = total; // save for rerun case
- cmCTestLog(this->CTest, HANDLER_OUTPUT, std::setw(2*getNumWidth(total) + 8)
- << "Start "
- << std::setw(getNumWidth(this->TestHandler->GetMaxIndex()))
- << this->TestProperties->Index << ": "
- << this->TestProperties->Name << std::endl);
+ cmCTestLog(this->CTest, HANDLER_OUTPUT, std::setw(2 * getNumWidth(total) + 8)
+ << "Start "
+ << std::setw(getNumWidth(this->TestHandler->GetMaxIndex()))
+ << this->TestProperties->Index << ": "
+ << this->TestProperties->Name << std::endl);
this->ComputeArguments();
std::vector<std::string>& args = this->TestProperties->Args;
this->TestResult.Properties = this->TestProperties;
@@ -476,21 +426,17 @@ bool cmCTestRunTest::StartTest(size_t total)
this->TestResult.Name = this->TestProperties->Name;
this->TestResult.Path = this->TestProperties->Directory.c_str();
- if(args.size() >= 2 && args[1] == "NOT_AVAILABLE")
- {
+ if (args.size() >= 2 && args[1] == "NOT_AVAILABLE") {
this->TestProcess = new cmProcess;
std::string msg;
- if(this->CTest->GetConfigType().empty())
- {
+ if (this->CTest->GetConfigType().empty()) {
msg = "Test not available without configuration.";
msg += " (Missing \"-C <config>\"?)";
- }
- else
- {
+ } else {
msg = "Test not available in configuration \"";
msg += this->CTest->GetConfigType();
msg += "\".";
- }
+ }
*this->TestHandler->LogFile << msg << std::endl;
cmCTestLog(this->CTest, ERROR_MESSAGE, msg << std::endl);
this->TestResult.Output = msg;
@@ -498,54 +444,50 @@ bool cmCTestRunTest::StartTest(size_t total)
this->TestResult.CompletionStatus = "Not Run";
this->TestResult.Status = cmCTestTestHandler::NOT_RUN;
return false;
- }
+ }
// Check if all required files exist
- for(std::vector<std::string>::iterator i =
- this->TestProperties->RequiredFiles.begin();
- i != this->TestProperties->RequiredFiles.end(); ++i)
- {
+ for (std::vector<std::string>::iterator i =
+ this->TestProperties->RequiredFiles.begin();
+ i != this->TestProperties->RequiredFiles.end(); ++i) {
std::string file = *i;
- if(!cmSystemTools::FileExists(file.c_str()))
- {
- //Required file was not found
+ if (!cmSystemTools::FileExists(file.c_str())) {
+ // Required file was not found
this->TestProcess = new cmProcess;
- *this->TestHandler->LogFile << "Unable to find required file: "
- << file << std::endl;
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Unable to find required file: "
- << file << std::endl);
+ *this->TestHandler->LogFile << "Unable to find required file: " << file
+ << std::endl;
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "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.Status = cmCTestTestHandler::NOT_RUN;
return false;
- }
}
+ }
// log and return if we did not find the executable
- if (this->ActualCommand == "")
- {
+ if (this->ActualCommand == "") {
// if the command was not found create a TestResult object
// that has that information
this->TestProcess = new cmProcess;
- *this->TestHandler->LogFile << "Unable to find executable: "
- << args[1] << std::endl;
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Unable to find executable: "
- << args[1] << std::endl);
+ *this->TestHandler->LogFile << "Unable to find executable: " << args[1]
+ << std::endl;
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "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.Status = cmCTestTestHandler::NOT_RUN;
return false;
- }
+ }
this->StartTime = this->CTest->CurrentTime();
double timeout = this->ResolveTimeout();
- if(this->StopTimePassed)
- {
+ if (this->StopTimePassed) {
return false;
- }
+ }
return this->ForkProcess(timeout, this->TestProperties->ExplicitTimeout,
&this->TestProperties->Environment);
}
@@ -557,92 +499,82 @@ void cmCTestRunTest::ComputeArguments()
this->TestProperties->Args.begin();
++j; // skip test name
// find the test executable
- if(this->TestHandler->MemCheck)
- {
- cmCTestMemCheckHandler * handler = static_cast<cmCTestMemCheckHandler*>
- (this->TestHandler);
+ if (this->TestHandler->MemCheck) {
+ cmCTestMemCheckHandler* handler =
+ static_cast<cmCTestMemCheckHandler*>(this->TestHandler);
this->ActualCommand = handler->MemoryTester.c_str();
this->TestProperties->Args[1] = this->TestHandler->FindTheExecutable(
this->TestProperties->Args[1].c_str());
- }
- else
- {
- this->ActualCommand =
- this->TestHandler->FindTheExecutable(
+ } else {
+ this->ActualCommand = this->TestHandler->FindTheExecutable(
this->TestProperties->Args[1].c_str());
- ++j; //skip the executable (it will be actualCommand)
- }
- std::string testCommand
- = cmSystemTools::ConvertToOutputPath(this->ActualCommand.c_str());
+ ++j; // skip the executable (it will be actualCommand)
+ }
+ std::string testCommand =
+ cmSystemTools::ConvertToOutputPath(this->ActualCommand.c_str());
- //Prepends memcheck args to our command string
+ // Prepends memcheck args to our command string
this->TestHandler->GenerateTestCommand(this->Arguments, this->Index);
- for(std::vector<std::string>::iterator i = this->Arguments.begin();
- i != this->Arguments.end(); ++i)
- {
+ for (std::vector<std::string>::iterator i = this->Arguments.begin();
+ i != this->Arguments.end(); ++i) {
testCommand += " \"";
testCommand += *i;
testCommand += "\"";
- }
+ }
- for(;j != this->TestProperties->Args.end(); ++j)
- {
+ for (; j != this->TestProperties->Args.end(); ++j) {
testCommand += " \"";
testCommand += *j;
testCommand += "\"";
this->Arguments.push_back(*j);
- }
+ }
this->TestResult.FullCommandLine = testCommand;
// Print the test command in verbose mode
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl
- << this->Index << ": "
- << (this->TestHandler->MemCheck?"MemCheck":"Test")
- << " command: " << testCommand
- << std::endl);
+ << this->Index << ": "
+ << (this->TestHandler->MemCheck ? "MemCheck" : "Test")
+ << " command: " << testCommand << std::endl);
// Print any test-specific env vars in verbose mode
- if (this->TestProperties->Environment.size())
- {
- cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->Index << ": "
- << "Environment variables: " << std::endl);
- }
- for(std::vector<std::string>::const_iterator e =
- this->TestProperties->Environment.begin();
- e != this->TestProperties->Environment.end(); ++e)
- {
+ if (this->TestProperties->Environment.size()) {
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->Index
+ << ": "
+ << "Environment variables: " << std::endl);
+ }
+ for (std::vector<std::string>::const_iterator e =
+ this->TestProperties->Environment.begin();
+ e != this->TestProperties->Environment.end(); ++e) {
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->Index << ": " << *e
- << std::endl);
- }
+ << std::endl);
+ }
}
void cmCTestRunTest::DartProcessing()
{
if (!this->ProcessOutput.empty() &&
- this->ProcessOutput.find("<DartMeasurement") != this->ProcessOutput.npos)
- {
- if (this->TestHandler->DartStuff.find(this->ProcessOutput.c_str()))
- {
+ this->ProcessOutput.find("<DartMeasurement") !=
+ this->ProcessOutput.npos) {
+ if (this->TestHandler->DartStuff.find(this->ProcessOutput.c_str())) {
this->TestResult.DartString = this->TestHandler->DartStuff.match(1);
// keep searching and replacing until none are left
- while (this->TestHandler->DartStuff1.find(this->ProcessOutput.c_str()))
- {
+ while (this->TestHandler->DartStuff1.find(this->ProcessOutput.c_str())) {
// replace the exact match for the string
- cmSystemTools::ReplaceString(this->ProcessOutput,
- this->TestHandler->DartStuff1.match(1).c_str(), "");
- }
+ cmSystemTools::ReplaceString(
+ this->ProcessOutput, this->TestHandler->DartStuff1.match(1).c_str(),
+ "");
}
}
+ }
}
double cmCTestRunTest::ResolveTimeout()
{
double timeout = this->TestProperties->Timeout;
- if(this->CTest->GetStopTime() == "")
- {
+ if (this->CTest->GetStopTime() == "") {
return timeout;
- }
+ }
struct tm* lctime;
time_t current_time = time(0);
lctime = gmtime(&current_time);
@@ -652,87 +584,77 @@ double cmCTestRunTest::ResolveTimeout()
int local_hour = lctime->tm_hour;
int tzone_offset = local_hour - gm_hour;
- if(gm_time > current_time && gm_hour < local_hour)
- {
+ if (gm_time > current_time && gm_hour < local_hour) {
// this means gm_time is on the next day
tzone_offset -= 24;
- }
- else if(gm_time < current_time && gm_hour > local_hour)
- {
+ } else if (gm_time < current_time && gm_hour > local_hour) {
// this means gm_time is on the previous day
tzone_offset += 24;
- }
+ }
tzone_offset *= 100;
char buf[1024];
// add todays year day and month to the time in str because
// curl_getdate no longer assumes the day is today
- sprintf(buf, "%d%02d%02d %s %+05i",
- lctime->tm_year + 1900,
- lctime->tm_mon + 1,
- lctime->tm_mday,
- this->CTest->GetStopTime().c_str(),
- tzone_offset);
+ sprintf(buf, "%d%02d%02d %s %+05i", lctime->tm_year + 1900,
+ lctime->tm_mon + 1, lctime->tm_mday,
+ this->CTest->GetStopTime().c_str(), tzone_offset);
time_t stop_time = curl_getdate(buf, &current_time);
- if(stop_time == -1)
- {
+ if (stop_time == -1) {
return timeout;
- }
-
- //the stop time refers to the next day
- if(this->CTest->NextDayStopTime)
- {
- stop_time += 24*60*60;
- }
- int stop_timeout = static_cast<int>(stop_time - current_time) % (24*60*60);
+ }
+
+ // the stop time refers to the next day
+ if (this->CTest->NextDayStopTime) {
+ stop_time += 24 * 60 * 60;
+ }
+ int stop_timeout =
+ static_cast<int>(stop_time - current_time) % (24 * 60 * 60);
this->CTest->LastStopTimeout = stop_timeout;
- if(stop_timeout <= 0 || stop_timeout > this->CTest->LastStopTimeout)
- {
+ if (stop_timeout <= 0 || stop_timeout > this->CTest->LastStopTimeout) {
cmCTestLog(this->CTest, ERROR_MESSAGE, "The stop time has been passed. "
- "Stopping all tests." << std::endl);
+ "Stopping all tests."
+ << std::endl);
this->StopTimePassed = true;
return 0;
- }
- return timeout == 0 ? stop_timeout :
- (timeout < stop_timeout ? timeout : stop_timeout);
+ }
+ return timeout == 0 ? stop_timeout
+ : (timeout < stop_timeout ? timeout : stop_timeout);
}
bool cmCTestRunTest::ForkProcess(double testTimeOut, bool explicitTimeout,
- std::vector<std::string>* environment)
+ std::vector<std::string>* environment)
{
this->TestProcess = new cmProcess;
this->TestProcess->SetId(this->Index);
this->TestProcess->SetWorkingDirectory(
- this->TestProperties->Directory.c_str());
+ this->TestProperties->Directory.c_str());
this->TestProcess->SetCommand(this->ActualCommand.c_str());
this->TestProcess->SetCommandArguments(this->Arguments);
// determine how much time we have
double timeout = this->CTest->GetRemainingTimeAllowed() - 120;
- if (this->CTest->GetTimeOut() > 0 && this->CTest->GetTimeOut() < timeout)
- {
+ if (this->CTest->GetTimeOut() > 0 && this->CTest->GetTimeOut() < timeout) {
timeout = this->CTest->GetTimeOut();
- }
- if (testTimeOut > 0
- && testTimeOut < this->CTest->GetRemainingTimeAllowed())
- {
+ }
+ if (testTimeOut > 0 &&
+ testTimeOut < this->CTest->GetRemainingTimeAllowed()) {
timeout = testTimeOut;
- }
+ }
// always have at least 1 second if we got to here
- if (timeout <= 0)
- {
+ if (timeout <= 0) {
timeout = 1;
- }
+ }
// handle timeout explicitly set to 0
- if (testTimeOut == 0 && explicitTimeout)
- {
+ if (testTimeOut == 0 && explicitTimeout) {
timeout = 0;
- }
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->Index << ": "
- << "Test timeout computed to be: " << timeout << "\n",
- this->TestHandler->GetQuiet());
+ }
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->Index
+ << ": "
+ << "Test timeout computed to be: " << timeout << "\n",
+ this->TestHandler->GetQuiet());
this->TestProcess->SetTimeout(timeout);
@@ -740,10 +662,9 @@ bool cmCTestRunTest::ForkProcess(double testTimeOut, bool explicitTimeout,
cmSystemTools::SaveRestoreEnvironment sre;
#endif
- if (environment && !environment->empty())
- {
+ if (environment && !environment->empty()) {
cmSystemTools::AppendEnv(*environment);
- }
+ }
return this->TestProcess->StartProcess();
}
@@ -756,69 +677,67 @@ void cmCTestRunTest::WriteLogOutputTop(size_t completed, size_t total)
// then it will never print out the completed / total, same would
// got for run until pass. Trick is when this is called we don't
// yet know if we are passing or failing.
- if(this->NumberOfRunsLeft == 1)
- {
+ if (this->NumberOfRunsLeft == 1) {
cmCTestLog(this->CTest, HANDLER_OUTPUT, std::setw(getNumWidth(total))
- << completed << "/");
+ << completed << "/");
cmCTestLog(this->CTest, HANDLER_OUTPUT, std::setw(getNumWidth(total))
- << total << " ");
- }
+ << total << " ");
+ }
// if this is one of several runs of a test just print blank space
// to keep things neat
- else
- {
+ else {
cmCTestLog(this->CTest, HANDLER_OUTPUT, std::setw(getNumWidth(total))
- << " " << " ");
+ << " "
+ << " ");
cmCTestLog(this->CTest, HANDLER_OUTPUT, std::setw(getNumWidth(total))
- << " " << " ");
- }
+ << " "
+ << " ");
+ }
- if ( this->TestHandler->MemCheck )
- {
+ if (this->TestHandler->MemCheck) {
cmCTestLog(this->CTest, HANDLER_OUTPUT, "MemCheck");
- }
- else
- {
+ } else {
cmCTestLog(this->CTest, HANDLER_OUTPUT, "Test");
- }
+ }
std::ostringstream indexStr;
indexStr << " #" << this->Index << ":";
cmCTestLog(this->CTest, HANDLER_OUTPUT,
std::setw(3 + getNumWidth(this->TestHandler->GetMaxIndex()))
- << indexStr.str());
+ << indexStr.str());
cmCTestLog(this->CTest, HANDLER_OUTPUT, " ");
const int maxTestNameWidth = this->CTest->GetMaxTestNameWidth();
std::string outname = this->TestProperties->Name + " ";
outname.resize(maxTestNameWidth + 4, '.');
*this->TestHandler->LogFile << this->TestProperties->Index << "/"
- << this->TestHandler->TotalNumberOfTests << " Testing: "
- << this->TestProperties->Name << std::endl;
+ << this->TestHandler->TotalNumberOfTests
+ << " Testing: " << this->TestProperties->Name
+ << std::endl;
*this->TestHandler->LogFile << this->TestProperties->Index << "/"
- << this->TestHandler->TotalNumberOfTests
- << " Test: " << this->TestProperties->Name << std::endl;
+ << this->TestHandler->TotalNumberOfTests
+ << " Test: " << this->TestProperties->Name
+ << std::endl;
*this->TestHandler->LogFile << "Command: \"" << this->ActualCommand << "\"";
for (std::vector<std::string>::iterator i = this->Arguments.begin();
- i != this->Arguments.end(); ++i)
- {
- *this->TestHandler->LogFile
- << " \"" << *i << "\"";
- }
- *this->TestHandler->LogFile << std::endl
+ i != this->Arguments.end(); ++i) {
+ *this->TestHandler->LogFile << " \"" << *i << "\"";
+ }
+ *this->TestHandler->LogFile
+ << std::endl
<< "Directory: " << this->TestProperties->Directory << std::endl
- << "\"" << this->TestProperties->Name << "\" start time: "
- << this->StartTime << std::endl;
+ << "\"" << this->TestProperties->Name
+ << "\" start time: " << this->StartTime << std::endl;
*this->TestHandler->LogFile
<< "Output:" << std::endl
<< "----------------------------------------------------------"
<< std::endl;
- *this->TestHandler->LogFile
- << this->ProcessOutput << "<end of output>" << std::endl;
+ *this->TestHandler->LogFile << this->ProcessOutput << "<end of output>"
+ << std::endl;
cmCTestLog(this->CTest, HANDLER_OUTPUT, outname.c_str());
- cmCTestLog(this->CTest, DEBUG, "Testing "
- << this->TestProperties->Name << " ... ");
+ cmCTestLog(this->CTest, DEBUG, "Testing " << this->TestProperties->Name
+ << " ... ");
}
diff --git a/Source/CTest/cmCTestRunTest.h b/Source/CTest/cmCTestRunTest.h
index 5f3467a..3dcc026 100644
--- a/Source/CTest/cmCTestRunTest.h
+++ b/Source/CTest/cmCTestRunTest.h
@@ -27,13 +27,17 @@ public:
cmCTestRunTest(cmCTestTestHandler* handler);
~cmCTestRunTest();
- void SetNumberOfRuns(int n) {this->NumberOfRunsLeft = n;}
- void SetRunUntilFailOn() { this->RunUntilFail = true;}
- void SetTestProperties(cmCTestTestHandler::cmCTestTestProperties * prop)
- { this->TestProperties = prop; }
-
- cmCTestTestHandler::cmCTestTestProperties * GetTestProperties()
- { return this->TestProperties; }
+ void SetNumberOfRuns(int n) { this->NumberOfRunsLeft = n; }
+ void SetRunUntilFailOn() { this->RunUntilFail = true; }
+ void SetTestProperties(cmCTestTestHandler::cmCTestTestProperties* prop)
+ {
+ this->TestProperties = prop;
+ }
+
+ cmCTestTestHandler::cmCTestTestProperties* GetTestProperties()
+ {
+ return this->TestProperties;
+ }
void SetIndex(int i) { this->Index = i; }
@@ -44,7 +48,9 @@ public:
bool IsStopTimePassed() { return this->StopTimePassed; }
cmCTestTestHandler::cmCTestTestResult GetTestResults()
- { return this->TestResult; }
+ {
+ return this->TestResult;
+ }
// Read and store output. Returns true if it must be called again.
bool CheckOutput();
@@ -52,16 +58,17 @@ public:
// Compresses the output, writing to CompressedOutput
void CompressOutput();
- //launch the test process, return whether it started correctly
+ // launch the test process, return whether it started correctly
bool StartTest(size_t total);
- //capture and report the test results
+ // capture and report the test results
bool EndTest(size_t completed, size_t total, bool started);
- //Called by ctest -N to log the command string
+ // Called by ctest -N to log the command string
void ComputeArguments();
void ComputeWeightedCost();
bool StartAgain();
+
private:
bool NeedsToRerun();
void DartProcessing();
@@ -71,18 +78,18 @@ private:
bool ForkProcess(double testTimeOut, bool explicitTimeout,
std::vector<std::string>* environment);
void WriteLogOutputTop(size_t completed, size_t total);
- //Run post processing of the process output for MemCheck
+ // Run post processing of the process output for MemCheck
void MemCheckPostProcess();
- cmCTestTestHandler::cmCTestTestProperties * TestProperties;
- //Pointer back to the "parent"; the handler that invoked this test run
- cmCTestTestHandler * TestHandler;
- cmCTest * CTest;
- cmProcess * TestProcess;
- //If the executable to run is ctest, don't create a new process;
- //just instantiate a new cmTest. (Can be disabled for a single test
- //if this option is set to false.)
- //bool OptimizeForCTest;
+ cmCTestTestHandler::cmCTestTestProperties* TestProperties;
+ // Pointer back to the "parent"; the handler that invoked this test run
+ cmCTestTestHandler* TestHandler;
+ cmCTest* CTest;
+ cmProcess* TestProcess;
+ // If the executable to run is ctest, don't create a new process;
+ // just instantiate a new cmTest. (Can be disabled for a single test
+ // if this option is set to false.)
+ // bool OptimizeForCTest;
bool UsePrefixCommand;
std::string PrefixCommand;
@@ -90,7 +97,7 @@ private:
std::string ProcessOutput;
std::string CompressedOutput;
double CompressionRatio;
- //The test results
+ // The test results
cmCTestTestHandler::cmCTestTestResult TestResult;
int Index;
std::string StartTime;
@@ -106,16 +113,13 @@ private:
inline int getNumWidth(size_t n)
{
int numWidth = 1;
- if(n >= 10)
- {
+ if (n >= 10) {
numWidth = 2;
- }
- if(n >= 100)
- {
+ }
+ if (n >= 100) {
numWidth = 3;
- }
+ }
return numWidth;
}
#endif
-
diff --git a/Source/CTest/cmCTestSVN.cxx b/Source/CTest/cmCTestSVN.cxx
index 507ec29..a6885aa 100644
--- a/Source/CTest/cmCTestSVN.cxx
+++ b/Source/CTest/cmCTestSVN.cxx
@@ -18,13 +18,13 @@
#include <cmsys/RegularExpression.hxx>
-struct cmCTestSVN::Revision: public cmCTestVC::Revision
+struct cmCTestSVN::Revision : public cmCTestVC::Revision
{
cmCTestSVN::SVNInfo* SVNInfo;
};
-cmCTestSVN::cmCTestSVN(cmCTest* ct, std::ostream& log):
- cmCTestGlobalVC(ct, log)
+cmCTestSVN::cmCTestSVN(cmCTest* ct, std::ostream& log)
+ : cmCTestGlobalVC(ct, log)
{
this->PriorRev = this->Unknown;
}
@@ -42,20 +42,20 @@ void cmCTestSVN::CleanupImpl()
this->RunSVNCommand(svn_cleanup, &out, &err);
}
-class cmCTestSVN::InfoParser: public cmCTestVC::LineParser
+class cmCTestSVN::InfoParser : public cmCTestVC::LineParser
{
public:
- InfoParser(cmCTestSVN* svn,
- const char* prefix,
- std::string& rev,
- SVNInfo& svninfo):
- Rev(rev), SVNRepo(svninfo)
- {
+ InfoParser(cmCTestSVN* svn, const char* prefix, std::string& rev,
+ SVNInfo& svninfo)
+ : Rev(rev)
+ , SVNRepo(svninfo)
+ {
this->SetLog(&svn->Log, prefix);
this->RegexRev.compile("^Revision: ([0-9]+)");
this->RegexURL.compile("^URL: +([^ ]+) *$");
this->RegexRoot.compile("^Repository Root: +([^ ]+) *$");
- }
+ }
+
private:
std::string& Rev;
cmCTestSVN::SVNInfo& SVNRepo;
@@ -63,38 +63,28 @@ private:
cmsys::RegularExpression RegexURL;
cmsys::RegularExpression RegexRoot;
virtual bool ProcessLine()
- {
- if(this->RegexRev.find(this->Line))
- {
+ {
+ if (this->RegexRev.find(this->Line)) {
this->Rev = this->RegexRev.match(1);
- }
- else if(this->RegexURL.find(this->Line))
- {
+ } else if (this->RegexURL.find(this->Line)) {
this->SVNRepo.URL = this->RegexURL.match(1);
- }
- else if(this->RegexRoot.find(this->Line))
- {
+ } else if (this->RegexRoot.find(this->Line)) {
this->SVNRepo.Root = this->RegexRoot.match(1);
- }
- return true;
}
+ return true;
+ }
};
static bool cmCTestSVNPathStarts(std::string const& p1, std::string const& p2)
{
// Does path p1 start with path p2?
- if(p1.size() == p2.size())
- {
+ if (p1.size() == p2.size()) {
return p1 == p2;
- }
- else if(p1.size() > p2.size() && p1[p2.size()] == '/')
- {
+ } else if (p1.size() > p2.size() && p1[p2.size()] == '/') {
return strncmp(p1.c_str(), p2.c_str(), p2.size()) == 0;
- }
- else
- {
+ } else {
return false;
- }
+ }
}
std::string cmCTestSVN::LoadInfo(SVNInfo& svninfo)
@@ -113,7 +103,7 @@ std::string cmCTestSVN::LoadInfo(SVNInfo& svninfo)
void cmCTestSVN::NoteOldRevision()
{
// Info for root repository
- this->Repositories.push_back( SVNInfo("") );
+ this->Repositories.push_back(SVNInfo(""));
this->RootInfo = &(this->Repositories.back());
// Info for the external repositories
this->LoadExternals();
@@ -121,17 +111,15 @@ void cmCTestSVN::NoteOldRevision()
// Get info for all the repositories
std::list<SVNInfo>::iterator itbeg = this->Repositories.begin();
std::list<SVNInfo>::iterator itend = this->Repositories.end();
- for( ; itbeg != itend ; itbeg++)
- {
+ for (; itbeg != itend; itbeg++) {
SVNInfo& svninfo = *itbeg;
svninfo.OldRevision = this->LoadInfo(svninfo);
this->Log << "Revision for repository '" << svninfo.LocalPath
<< "' before update: " << svninfo.OldRevision << "\n";
- cmCTestLog(this->CTest, HANDLER_OUTPUT,
- " Old revision of external repository '"
- << svninfo.LocalPath << "' is: "
- << svninfo.OldRevision << "\n");
- }
+ cmCTestLog(
+ this->CTest, HANDLER_OUTPUT, " Old revision of external repository '"
+ << svninfo.LocalPath << "' is: " << svninfo.OldRevision << "\n");
+ }
// Set the global old revision to the one of the root
this->OldRevision = this->RootInfo->OldRevision;
@@ -143,16 +131,14 @@ void cmCTestSVN::NoteNewRevision()
// Get info for the external repositories
std::list<SVNInfo>::iterator itbeg = this->Repositories.begin();
std::list<SVNInfo>::iterator itend = this->Repositories.end();
- for( ; itbeg != itend ; itbeg++)
- {
+ for (; itbeg != itend; itbeg++) {
SVNInfo& svninfo = *itbeg;
svninfo.NewRevision = this->LoadInfo(svninfo);
this->Log << "Revision for repository '" << svninfo.LocalPath
<< "' after update: " << svninfo.NewRevision << "\n";
- cmCTestLog(this->CTest, HANDLER_OUTPUT,
- " New revision of external repository '"
- << svninfo.LocalPath << "' is: "
- << svninfo.NewRevision << "\n");
+ cmCTestLog(
+ this->CTest, HANDLER_OUTPUT, " New revision of external repository '"
+ << svninfo.LocalPath << "' is: " << svninfo.NewRevision << "\n");
// svninfo.Root = ""; // uncomment to test GuessBase
this->Log << "Repository '" << svninfo.LocalPath
@@ -162,16 +148,14 @@ void cmCTestSVN::NoteNewRevision()
// Compute the base path the working tree has checked out under
// the repository root.
- if(!svninfo.Root.empty()
- && cmCTestSVNPathStarts(svninfo.URL, svninfo.Root))
- {
- svninfo.Base = cmCTest::DecodeURL(
- svninfo.URL.substr(svninfo.Root.size()));
+ if (!svninfo.Root.empty() &&
+ cmCTestSVNPathStarts(svninfo.URL, svninfo.Root)) {
+ svninfo.Base =
+ cmCTest::DecodeURL(svninfo.URL.substr(svninfo.Root.size()));
svninfo.Base += "/";
- }
+ }
this->Log << "Repository '" << svninfo.LocalPath
<< "' Base = " << svninfo.Base << "\n";
-
}
// Set the global new revision to the one of the root
@@ -186,21 +170,18 @@ void cmCTestSVN::GuessBase(SVNInfo& svninfo,
// changes under it.
// Consider each possible URL suffix from longest to shortest.
- for(std::string::size_type slash = svninfo.URL.find('/');
- svninfo.Base.empty() && slash != std::string::npos;
- slash = svninfo.URL.find('/', slash+1))
- {
+ for (std::string::size_type slash = svninfo.URL.find('/');
+ svninfo.Base.empty() && slash != std::string::npos;
+ slash = svninfo.URL.find('/', slash + 1)) {
// If the URL suffix is a prefix of at least one path then it is the base.
std::string base = cmCTest::DecodeURL(svninfo.URL.substr(slash));
- for(std::vector<Change>::const_iterator ci = changes.begin();
- svninfo.Base.empty() && ci != changes.end(); ++ci)
- {
- if(cmCTestSVNPathStarts(ci->Path, base))
- {
+ for (std::vector<Change>::const_iterator ci = changes.begin();
+ svninfo.Base.empty() && ci != changes.end(); ++ci) {
+ if (cmCTestSVNPathStarts(ci->Path, base)) {
svninfo.Base = base;
- }
}
}
+ }
// We always append a slash so that we know paths beginning in the
// base lie under its path. If no base was found then the working
@@ -211,76 +192,76 @@ void cmCTestSVN::GuessBase(SVNInfo& svninfo,
this->Log << "Guessed Base = " << svninfo.Base << "\n";
}
-class cmCTestSVN::UpdateParser: public cmCTestVC::LineParser
+class cmCTestSVN::UpdateParser : public cmCTestVC::LineParser
{
public:
- UpdateParser(cmCTestSVN* svn, const char* prefix): SVN(svn)
- {
+ UpdateParser(cmCTestSVN* svn, const char* prefix)
+ : SVN(svn)
+ {
this->SetLog(&svn->Log, prefix);
this->RegexUpdate.compile("^([ADUCGE ])([ADUCGE ])[B ] +(.+)$");
- }
+ }
+
private:
cmCTestSVN* SVN;
cmsys::RegularExpression RegexUpdate;
bool ProcessLine()
- {
- if(this->RegexUpdate.find(this->Line))
- {
+ {
+ if (this->RegexUpdate.find(this->Line)) {
this->DoPath(this->RegexUpdate.match(1)[0],
- this->RegexUpdate.match(2)[0],
- this->RegexUpdate.match(3));
- }
- return true;
+ this->RegexUpdate.match(2)[0], this->RegexUpdate.match(3));
}
+ return true;
+ }
void DoPath(char path_status, char prop_status, std::string const& path)
- {
- char status = (path_status != ' ')? path_status : prop_status;
+ {
+ char status = (path_status != ' ') ? path_status : prop_status;
std::string dir = cmSystemTools::GetFilenamePath(path);
std::string name = cmSystemTools::GetFilenameName(path);
// See "svn help update".
- switch(status)
- {
+ switch (status) {
case 'G':
this->SVN->Dirs[dir][name].Status = PathModified;
break;
case 'C':
this->SVN->Dirs[dir][name].Status = PathConflicting;
break;
- case 'A': case 'D': case 'U':
+ case 'A':
+ case 'D':
+ case 'U':
this->SVN->Dirs[dir][name].Status = PathUpdated;
break;
case 'E': // TODO?
- case '?': case ' ': default:
+ case '?':
+ case ' ':
+ default:
break;
- }
}
+ }
};
bool cmCTestSVN::UpdateImpl()
{
// Get user-specified update options.
std::string opts = this->CTest->GetCTestConfiguration("UpdateOptions");
- if(opts.empty())
- {
+ if (opts.empty()) {
opts = this->CTest->GetCTestConfiguration("SVNUpdateOptions");
- }
+ }
std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
// Specify the start time for nightly testing.
- if(this->CTest->GetTestModel() == cmCTest::NIGHTLY)
- {
+ if (this->CTest->GetTestModel() == cmCTest::NIGHTLY) {
args.push_back("-r{" + this->GetNightlyTime() + " +0000}");
- }
+ }
std::vector<char const*> svn_update;
svn_update.push_back("update");
- for(std::vector<std::string>::const_iterator ai = args.begin();
- ai != args.end(); ++ai)
- {
+ for (std::vector<std::string>::const_iterator ai = args.begin();
+ ai != args.end(); ++ai) {
svn_update.push_back(ai->c_str());
- }
+ }
UpdateParser out(this, "up-out> ");
OutputLogger err(this->Log, "up-err> ");
@@ -288,9 +269,10 @@ bool cmCTestSVN::UpdateImpl()
}
bool cmCTestSVN::RunSVNCommand(std::vector<char const*> const& parameters,
- OutputParser* out, OutputParser* err)
+ OutputParser* out, OutputParser* err)
{
- if(parameters.empty()) return false;
+ if (parameters.empty())
+ return false;
std::vector<char const*> args;
args.push_back(this->CommandLineTool.c_str());
@@ -299,36 +281,35 @@ bool cmCTestSVN::RunSVNCommand(std::vector<char const*> const& parameters,
args.push_back("--non-interactive");
- std::string userOptions =
- this->CTest->GetCTestConfiguration("SVNOptions");
+ std::string userOptions = this->CTest->GetCTestConfiguration("SVNOptions");
std::vector<std::string> parsedUserOptions =
cmSystemTools::ParseArguments(userOptions.c_str());
- for(std::vector<std::string>::iterator i = parsedUserOptions.begin();
- i != parsedUserOptions.end(); ++i)
- {
+ for (std::vector<std::string>::iterator i = parsedUserOptions.begin();
+ i != parsedUserOptions.end(); ++i) {
args.push_back(i->c_str());
- }
+ }
args.push_back(0);
- if(strcmp(parameters[0], "update") == 0)
- {
+ if (strcmp(parameters[0], "update") == 0) {
return RunUpdateCommand(&args[0], out, err);
- }
- else
- {
+ } else {
return RunChild(&args[0], out, err);
- }
+ }
}
-class cmCTestSVN::LogParser: public cmCTestVC::OutputLogger,
- private cmXMLParser
+class cmCTestSVN::LogParser : public cmCTestVC::OutputLogger,
+ private cmXMLParser
{
public:
- LogParser(cmCTestSVN* svn, const char* prefix, SVNInfo& svninfo):
- OutputLogger(svn->Log, prefix), SVN(svn), SVNRepo(svninfo)
- { this->InitializeParser(); }
+ LogParser(cmCTestSVN* svn, const char* prefix, SVNInfo& svninfo)
+ : OutputLogger(svn->Log, prefix)
+ , SVN(svn)
+ , SVNRepo(svninfo)
+ {
+ this->InitializeParser();
+ }
~LogParser() { this->CleanupParser(); }
private:
cmCTestSVN* SVN;
@@ -342,72 +323,58 @@ private:
std::vector<char> CData;
virtual bool ProcessChunk(const char* data, int length)
- {
+ {
this->OutputLogger::ProcessChunk(data, length);
this->ParseChunk(data, length);
return true;
- }
+ }
virtual void StartElement(const std::string& name, const char** atts)
- {
+ {
this->CData.clear();
- if(name == "logentry")
- {
+ if (name == "logentry") {
this->Rev = Revision();
this->Rev.SVNInfo = &SVNRepo;
- if(const char* rev = this->FindAttribute(atts, "revision"))
- {
+ if (const char* rev = this->FindAttribute(atts, "revision")) {
this->Rev.Rev = rev;
- }
- this->Changes.clear();
}
- else if(name == "path")
- {
+ this->Changes.clear();
+ } else if (name == "path") {
this->CurChange = Change();
- if(const char* action = this->FindAttribute(atts, "action"))
- {
+ if (const char* action = this->FindAttribute(atts, "action")) {
this->CurChange.Action = action[0];
- }
}
}
+ }
virtual void CharacterDataHandler(const char* data, int length)
- {
- this->CData.insert(this->CData.end(), data, data+length);
- }
+ {
+ this->CData.insert(this->CData.end(), data, data + length);
+ }
virtual void EndElement(const std::string& name)
- {
- if(name == "logentry")
- {
+ {
+ if (name == "logentry") {
this->SVN->DoRevisionSVN(this->Rev, this->Changes);
- }
- else if(!this->CData.empty() && name == "path")
- {
+ } else if (!this->CData.empty() && name == "path") {
std::string orig_path(&this->CData[0], this->CData.size());
- std::string new_path = SVNRepo.BuildLocalPath( orig_path );
+ std::string new_path = SVNRepo.BuildLocalPath(orig_path);
this->CurChange.Path.assign(new_path);
this->Changes.push_back(this->CurChange);
- }
- else if(!this->CData.empty() && name == "author")
- {
+ } else if (!this->CData.empty() && name == "author") {
this->Rev.Author.assign(&this->CData[0], this->CData.size());
- }
- else if(!this->CData.empty() && name == "date")
- {
+ } else if (!this->CData.empty() && name == "date") {
this->Rev.Date.assign(&this->CData[0], this->CData.size());
- }
- else if(!this->CData.empty() && name == "msg")
- {
+ } else if (!this->CData.empty() && name == "msg") {
this->Rev.Log.assign(&this->CData[0], this->CData.size());
- }
- this->CData.clear();
}
+ this->CData.clear();
+ }
virtual void ReportError(int, int, const char* msg)
- {
+ {
this->SVN->Log << "Error parsing svn log xml: " << msg << "\n";
- }
+ }
};
void cmCTestSVN::LoadRevisions()
@@ -415,25 +382,21 @@ void cmCTestSVN::LoadRevisions()
// 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++)
- {
+ for (; itbeg != itend; itbeg++) {
SVNInfo& svninfo = *itbeg;
LoadRevisions(svninfo);
- }
+ }
}
-void cmCTestSVN::LoadRevisions(SVNInfo &svninfo)
+void cmCTestSVN::LoadRevisions(SVNInfo& svninfo)
{
// We are interested in every revision included in the update.
std::string revs;
- if(atoi(svninfo.OldRevision.c_str()) < atoi(svninfo.NewRevision.c_str()))
- {
+ if (atoi(svninfo.OldRevision.c_str()) < atoi(svninfo.NewRevision.c_str())) {
revs = "-r" + svninfo.OldRevision + ":" + svninfo.NewRevision;
- }
- else
- {
+ } else {
revs = "-r" + svninfo.NewRevision;
- }
+ }
// Run "svn log" to get all global revisions of interest.
std::vector<const char*> svn_log;
@@ -451,59 +414,65 @@ void cmCTestSVN::DoRevisionSVN(Revision const& revision,
std::vector<Change> const& changes)
{
// Guess the base checkout path from the changes if necessary.
- if(this->RootInfo->Base.empty() && !changes.empty())
- {
+ if (this->RootInfo->Base.empty() && !changes.empty()) {
this->GuessBase(*this->RootInfo, changes);
- }
+ }
// Ignore changes in the old revision for external repositories
- if(revision.Rev == revision.SVNInfo->OldRevision
- && revision.SVNInfo->LocalPath != "")
- {
+ if (revision.Rev == revision.SVNInfo->OldRevision &&
+ revision.SVNInfo->LocalPath != "") {
return;
- }
+ }
this->cmCTestGlobalVC::DoRevision(revision, changes);
}
-class cmCTestSVN::StatusParser: public cmCTestVC::LineParser
+class cmCTestSVN::StatusParser : public cmCTestVC::LineParser
{
public:
- StatusParser(cmCTestSVN* svn, const char* prefix): SVN(svn)
- {
+ StatusParser(cmCTestSVN* svn, const char* prefix)
+ : SVN(svn)
+ {
this->SetLog(&svn->Log, prefix);
this->RegexStatus.compile("^([ACDIMRX?!~ ])([CM ])[ L]... +(.+)$");
- }
+ }
+
private:
cmCTestSVN* SVN;
cmsys::RegularExpression RegexStatus;
bool ProcessLine()
- {
- if(this->RegexStatus.find(this->Line))
- {
+ {
+ if (this->RegexStatus.find(this->Line)) {
this->DoPath(this->RegexStatus.match(1)[0],
- this->RegexStatus.match(2)[0],
- this->RegexStatus.match(3));
- }
- return true;
+ this->RegexStatus.match(2)[0], this->RegexStatus.match(3));
}
+ return true;
+ }
void DoPath(char path_status, char prop_status, std::string const& path)
- {
- char status = (path_status != ' ')? path_status : prop_status;
+ {
+ char status = (path_status != ' ') ? path_status : prop_status;
// See "svn help status".
- switch(status)
- {
- case 'M': case '!': case 'A': case 'D': case 'R':
+ switch (status) {
+ case 'M':
+ case '!':
+ case 'A':
+ case 'D':
+ case 'R':
this->SVN->DoModification(PathModified, path);
break;
- case 'C': case '~':
+ case 'C':
+ case '~':
this->SVN->DoModification(PathConflicting, path);
break;
- case 'X': case 'I': case '?': case ' ': default:
+ case 'X':
+ case 'I':
+ case '?':
+ case ' ':
+ default:
break;
- }
}
+ }
};
void cmCTestSVN::LoadModifications()
@@ -523,42 +492,40 @@ void cmCTestSVN::WriteXMLGlobal(cmXMLWriter& xml)
xml.Element("SVNPath", this->RootInfo->Base);
}
-class cmCTestSVN::ExternalParser: public cmCTestVC::LineParser
+class cmCTestSVN::ExternalParser : public cmCTestVC::LineParser
{
public:
- ExternalParser(cmCTestSVN* svn, const char* prefix): SVN(svn)
- {
+ ExternalParser(cmCTestSVN* svn, const char* prefix)
+ : SVN(svn)
+ {
this->SetLog(&svn->Log, prefix);
this->RegexExternal.compile("^X..... +(.+)$");
- }
+ }
+
private:
cmCTestSVN* SVN;
cmsys::RegularExpression RegexExternal;
bool ProcessLine()
- {
- if(this->RegexExternal.find(this->Line))
- {
+ {
+ if (this->RegexExternal.find(this->Line)) {
this->DoPath(this->RegexExternal.match(1));
- }
- return true;
}
+ return true;
+ }
void DoPath(std::string const& path)
- {
+ {
// Get local path relative to the source directory
std::string local_path;
- if(path.size() > this->SVN->SourceDirectory.size() &&
- strncmp(path.c_str(), this->SVN->SourceDirectory.c_str(),
- this->SVN->SourceDirectory.size()) == 0)
- {
+ if (path.size() > this->SVN->SourceDirectory.size() &&
+ strncmp(path.c_str(), this->SVN->SourceDirectory.c_str(),
+ this->SVN->SourceDirectory.size()) == 0) {
local_path = path.c_str() + this->SVN->SourceDirectory.size() + 1;
- }
- else
- {
+ } else {
local_path = path;
- }
- this->SVN->Repositories.push_back( SVNInfo(local_path.c_str()) );
}
+ this->SVN->Repositories.push_back(SVNInfo(local_path.c_str()));
+ }
};
void cmCTestSVN::LoadExternals()
@@ -576,20 +543,16 @@ std::string cmCTestSVN::SVNInfo::BuildLocalPath(std::string const& path) const
std::string local_path;
// Add local path prefix if not empty
- if (!this->LocalPath.empty())
- {
+ if (!this->LocalPath.empty()) {
local_path += this->LocalPath;
local_path += "/";
- }
+ }
// Add path with base prefix removed
- if(path.size() > this->Base.size() &&
- strncmp(path.c_str(), this->Base.c_str(), this->Base.size()) == 0)
- {
+ if (path.size() > this->Base.size() &&
+ strncmp(path.c_str(), this->Base.c_str(), this->Base.size()) == 0) {
local_path += (path.c_str() + this->Base.size());
- }
- else
- {
+ } else {
local_path += path;
}
diff --git a/Source/CTest/cmCTestSVN.h b/Source/CTest/cmCTestSVN.h
index f9febc5..e596bdc 100644
--- a/Source/CTest/cmCTestSVN.h
+++ b/Source/CTest/cmCTestSVN.h
@@ -20,7 +20,7 @@
* \brief Interaction with subversion command-line tool
*
*/
-class cmCTestSVN: public cmCTestGlobalVC
+class cmCTestSVN : public cmCTestGlobalVC
{
public:
/** Construct with a CTest instance and update log stream. */
@@ -36,12 +36,16 @@ private:
virtual bool UpdateImpl();
bool RunSVNCommand(std::vector<char const*> const& parameters,
- OutputParser* out, OutputParser* err);
+ OutputParser* out, OutputParser* err);
// Information about an SVN repository (root repository or external)
- struct SVNInfo {
+ struct SVNInfo
+ {
- SVNInfo(const char* path) : LocalPath(path) {}
+ SVNInfo(const char* path)
+ : LocalPath(path)
+ {
+ }
// Remove base from the filename
std::string BuildLocalPath(std::string const& path) const;
@@ -60,7 +64,6 @@ private:
// Old and new repository revisions.
std::string OldRevision;
std::string NewRevision;
-
};
// Extended revision structure to include info about external it refers to.
@@ -79,7 +82,7 @@ private:
void LoadRevisions();
void LoadRevisions(SVNInfo& svninfo);
- void GuessBase(SVNInfo &svninfo, std::vector<Change> const& changes);
+ void GuessBase(SVNInfo& svninfo, std::vector<Change> const& changes);
void DoRevisionSVN(Revision const& revision,
std::vector<Change> const& changes);
diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx
index bde7a6d..0c09cc7 100644
--- a/Source/CTest/cmCTestScriptHandler.cxx
+++ b/Source/CTest/cmCTestScriptHandler.cxx
@@ -35,7 +35,7 @@
// needed for sleep
#if !defined(_WIN32)
-# include <unistd.h>
+#include <unistd.h>
#endif
#include "cmCTestBuildCommand.h"
@@ -60,19 +60,18 @@ class cmCTestScriptFunctionBlocker : public cmFunctionBlocker
public:
cmCTestScriptFunctionBlocker() {}
virtual ~cmCTestScriptFunctionBlocker() {}
- virtual bool IsFunctionBlocked(const cmListFileFunction& lff,
- cmMakefile &mf,
- cmExecutionStatus &);
- //virtual bool ShouldRemove(const cmListFileFunction& lff, cmMakefile &mf);
- //virtual void ScopeEnded(cmMakefile &mf);
+ virtual bool IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile& mf,
+ cmExecutionStatus&);
+ // virtual bool ShouldRemove(const cmListFileFunction& lff, cmMakefile &mf);
+ // virtual void ScopeEnded(cmMakefile &mf);
cmCTestScriptHandler* CTestScriptHandler;
};
// simply update the time and don't block anything
-bool cmCTestScriptFunctionBlocker::
-IsFunctionBlocked(const cmListFileFunction& , cmMakefile &,
- cmExecutionStatus &)
+bool cmCTestScriptFunctionBlocker::IsFunctionBlocked(const cmListFileFunction&,
+ cmMakefile&,
+ cmExecutionStatus&)
{
this->CTestScriptHandler->UpdateElapsedTime();
return false;
@@ -90,7 +89,7 @@ cmCTestScriptHandler::cmCTestScriptHandler()
this->ScriptStartTime = 0;
// the *60 is becuase the settings are in minutes but GetTime is seconds
- this->MinimumInterval = 30*60;
+ this->MinimumInterval = 30 * 60;
this->ContinuousDuration = -1;
}
@@ -115,7 +114,7 @@ void cmCTestScriptHandler::Initialize()
this->CMOutFile = "";
this->ExtraUpdates.clear();
- this->MinimumInterval = 20*60;
+ this->MinimumInterval = 20 * 60;
this->ContinuousDuration = -1;
// what time in seconds did this script start running
@@ -137,46 +136,41 @@ cmCTestScriptHandler::~cmCTestScriptHandler()
delete this->CMake;
}
-
// just adds an argument to the vector
-void cmCTestScriptHandler::AddConfigurationScript(const char *script,
+void cmCTestScriptHandler::AddConfigurationScript(const char* script,
bool pscope)
{
this->ConfigurationScripts.push_back(script);
this->ScriptProcessScope.push_back(pscope);
}
-
// the generic entry point for handling scripts, this routine will run all
// the scripts provides a -S arguments
int cmCTestScriptHandler::ProcessHandler()
{
int res = 0;
- for (size_t i=0; i < this->ConfigurationScripts.size(); ++i)
- {
+ for (size_t i = 0; i < this->ConfigurationScripts.size(); ++i) {
// for each script run it
- res |= this->RunConfigurationScript
- (cmSystemTools::CollapseFullPath(this->ConfigurationScripts[i]),
- this->ScriptProcessScope[i]);
- }
- if ( res )
- {
+ res |= this->RunConfigurationScript(
+ cmSystemTools::CollapseFullPath(this->ConfigurationScripts[i]),
+ this->ScriptProcessScope[i]);
+ }
+ if (res) {
return -1;
- }
+ }
return 0;
}
void cmCTestScriptHandler::UpdateElapsedTime()
{
- if (this->Makefile)
- {
+ if (this->Makefile) {
// set the current elapsed time
char timeString[20];
- int itime = static_cast<unsigned int>(cmSystemTools::GetTime()
- - this->ScriptStartTime);
- sprintf(timeString,"%i",itime);
+ int itime = static_cast<unsigned int>(cmSystemTools::GetTime() -
+ this->ScriptStartTime);
+ sprintf(timeString, "%i", itime);
this->Makefile->AddDefinition("CTEST_ELAPSED_TIME", timeString);
- }
+ }
}
void cmCTestScriptHandler::AddCTestCommand(cmCTestCommand* command)
@@ -196,115 +190,97 @@ int cmCTestScriptHandler::ExecuteScript(const std::string& total_script_arg)
argv.push_back("-SR");
argv.push_back(total_script_arg.c_str());
- cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Executable for CTest is: " <<
- cmSystemTools::GetCTestCommand() << "\n");
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Executable for CTest is: "
+ << cmSystemTools::GetCTestCommand() << "\n");
// now pass through all the other arguments
- std::vector<std::string> &initArgs =
+ std::vector<std::string>& initArgs =
this->CTest->GetInitialCommandLineArguments();
//*** need to make sure this does not have the current script ***
- for(size_t i=1; i < initArgs.size(); ++i)
- {
+ for (size_t i = 1; i < initArgs.size(); ++i) {
argv.push_back(initArgs[i].c_str());
- }
+ }
argv.push_back(0);
// Now create process object
cmsysProcess* cp = cmsysProcess_New();
cmsysProcess_SetCommand(cp, &*argv.begin());
- //cmsysProcess_SetWorkingDirectory(cp, dir);
+ // cmsysProcess_SetWorkingDirectory(cp, dir);
cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
- //cmsysProcess_SetTimeout(cp, timeout);
+ // cmsysProcess_SetTimeout(cp, timeout);
cmsysProcess_Execute(cp);
std::vector<char> out;
std::vector<char> err;
std::string line;
int pipe = cmSystemTools::WaitForLine(cp, line, 100.0, out, err);
- while(pipe != cmsysProcess_Pipe_None)
- {
- cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Output: "
- << line << "\n");
- if(pipe == cmsysProcess_Pipe_STDERR)
- {
+ while (pipe != cmsysProcess_Pipe_None) {
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Output: " << line
+ << "\n");
+ if (pipe == cmsysProcess_Pipe_STDERR) {
cmCTestLog(this->CTest, ERROR_MESSAGE, line << "\n");
- }
- else if(pipe == cmsysProcess_Pipe_STDOUT)
- {
+ } else if (pipe == cmsysProcess_Pipe_STDOUT) {
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, line << "\n");
- }
- pipe = cmSystemTools::WaitForLine(cp, line, 100, out, err);
}
+ pipe = cmSystemTools::WaitForLine(cp, line, 100, out, err);
+ }
// Properly handle output of the build command
cmsysProcess_WaitForExit(cp, 0);
int result = cmsysProcess_GetState(cp);
int retVal = 0;
bool failed = false;
- if(result == cmsysProcess_State_Exited)
- {
+ if (result == cmsysProcess_State_Exited) {
retVal = cmsysProcess_GetExitValue(cp);
- }
- else if(result == cmsysProcess_State_Exception)
- {
+ } else if (result == cmsysProcess_State_Exception) {
retVal = cmsysProcess_GetExitException(cp);
cmCTestLog(this->CTest, ERROR_MESSAGE, "\tThere was an exception: "
- << cmsysProcess_GetExceptionString(cp) << " " <<
- retVal << std::endl);
+ << cmsysProcess_GetExceptionString(cp) << " " << retVal
+ << std::endl);
failed = true;
- }
- else if(result == cmsysProcess_State_Expired)
- {
+ } else if (result == cmsysProcess_State_Expired) {
cmCTestLog(this->CTest, ERROR_MESSAGE, "\tThere was a timeout"
- << std::endl);
+ << std::endl);
failed = true;
- }
- else if(result == cmsysProcess_State_Error)
- {
+ } else if (result == cmsysProcess_State_Error) {
cmCTestLog(this->CTest, ERROR_MESSAGE, "\tError executing ctest: "
- << cmsysProcess_GetErrorString(cp) << std::endl);
+ << cmsysProcess_GetErrorString(cp) << std::endl);
failed = true;
- }
+ }
cmsysProcess_Delete(cp);
- if(failed)
- {
+ if (failed) {
std::ostringstream message;
message << "Error running command: [";
message << result << "] ";
- for(std::vector<const char*>::iterator i = argv.begin();
- i != argv.end(); ++i)
- {
- if(*i)
- {
- message << *i << " ";
- }
+ for (std::vector<const char*>::iterator i = argv.begin(); i != argv.end();
+ ++i) {
+ if (*i) {
+ message << *i << " ";
}
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- message.str() << argv[0] << std::endl);
- return -1;
}
+ cmCTestLog(this->CTest, ERROR_MESSAGE, message.str() << argv[0]
+ << std::endl);
+ return -1;
+ }
return retVal;
}
-static void ctestScriptProgressCallback(const char *m, float, void* cd)
+static void ctestScriptProgressCallback(const char* m, float, void* cd)
{
cmCTest* ctest = static_cast<cmCTest*>(cd);
- if(m && *m)
- {
+ if (m && *m) {
cmCTestLog(ctest, HANDLER_OUTPUT, "-- " << m << std::endl);
- }
+ }
}
void cmCTestScriptHandler::CreateCMake()
{
// create a cmake instance to read the configuration script
- if (this->CMake)
- {
+ if (this->CMake) {
delete this->CMake;
delete this->GlobalGenerator;
delete this->Makefile;
- }
+ }
this->CMake = new cmake;
this->CMake->SetHomeDirectory("");
this->CMake->SetHomeOutputDirectory("");
@@ -354,27 +330,25 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg)
// passed into the scripts as S_ARG
std::string script = total_script_arg;
std::string script_arg;
- if (total_script_arg.find(",") != std::string::npos)
- {
- script = total_script_arg.substr(0,total_script_arg.find(","));
- script_arg = total_script_arg.substr(total_script_arg.find(",")+1);
- }
+ if (total_script_arg.find(",") != std::string::npos) {
+ script = total_script_arg.substr(0, total_script_arg.find(","));
+ script_arg = total_script_arg.substr(total_script_arg.find(",") + 1);
+ }
// make sure the file exists
- if (!cmSystemTools::FileExists(script.c_str()))
- {
+ if (!cmSystemTools::FileExists(script.c_str())) {
cmSystemTools::Error("Cannot find file: ", script.c_str());
return 1;
- }
+ }
// read in the list file to fill the cache
// create a cmake instance to read the configuration script
this->CreateCMake();
// set a variable with the path to the current script
- this->Makefile->AddDefinition("CTEST_SCRIPT_DIRECTORY",
- cmSystemTools::GetFilenamePath(script).c_str());
- this->Makefile->AddDefinition("CTEST_SCRIPT_NAME",
- cmSystemTools::GetFilenameName(script).c_str());
+ this->Makefile->AddDefinition(
+ "CTEST_SCRIPT_DIRECTORY", cmSystemTools::GetFilenamePath(script).c_str());
+ this->Makefile->AddDefinition(
+ "CTEST_SCRIPT_NAME", cmSystemTools::GetFilenameName(script).c_str());
this->Makefile->AddDefinition("CTEST_EXECUTABLE_NAME",
cmSystemTools::GetCTestCommand().c_str());
this->Makefile->AddDefinition("CMAKE_EXECUTABLE_NAME",
@@ -383,59 +357,53 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg)
this->UpdateElapsedTime();
// add the script arg if defined
- if (!script_arg.empty())
- {
+ if (!script_arg.empty()) {
this->Makefile->AddDefinition("CTEST_SCRIPT_ARG", script_arg.c_str());
- }
+ }
#if defined(__CYGWIN__)
this->Makefile->AddDefinition("CMAKE_LEGACY_CYGWIN_WIN32", "0");
#endif
// always add a function blocker to update the elapsed time
- cmCTestScriptFunctionBlocker *f = new cmCTestScriptFunctionBlocker();
+ cmCTestScriptFunctionBlocker* f = new cmCTestScriptFunctionBlocker();
f->CTestScriptHandler = this;
this->Makefile->AddFunctionBlocker(f);
-
/* Execute CTestScriptMode.cmake, which loads CMakeDetermineSystem and
CMakeSystemSpecificInformation, so
that variables like CMAKE_SYSTEM and also the search paths for libraries,
header and executables are set correctly and can be used. Makes new-style
ctest scripting easier. */
std::string systemFile =
- this->Makefile->GetModulesFile("CTestScriptMode.cmake");
+ this->Makefile->GetModulesFile("CTestScriptMode.cmake");
if (!this->Makefile->ReadListFile(systemFile.c_str()) ||
- cmSystemTools::GetErrorOccuredFlag())
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Error in read:"
- << systemFile << "\n");
+ cmSystemTools::GetErrorOccuredFlag()) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "Error in read:" << systemFile
+ << "\n");
return 2;
- }
+ }
// Add definitions of variables passed in on the command line:
- const std::map<std::string, std::string> &defs =
+ const std::map<std::string, std::string>& defs =
this->CTest->GetDefinitions();
for (std::map<std::string, std::string>::const_iterator it = defs.begin();
- it != defs.end(); ++it)
- {
+ it != defs.end(); ++it) {
this->Makefile->AddDefinition(it->first, it->second.c_str());
- }
+ }
// finally read in the script
if (!this->Makefile->ReadListFile(script.c_str()) ||
- cmSystemTools::GetErrorOccuredFlag())
- {
+ cmSystemTools::GetErrorOccuredFlag()) {
// Reset the error flag so that it can run more than
// one script with an error when you use ctest_run_script.
cmSystemTools::ResetErrorOccuredFlag();
return 2;
- }
+ }
return 0;
}
-
// extract variabels from the script to set ivars
int cmCTestScriptHandler::ExtractVariables()
{
@@ -443,80 +411,64 @@ int cmCTestScriptHandler::ExtractVariables()
const char* minInterval;
const char* contDuration;
- this->SourceDir
- = this->Makefile->GetSafeDefinition("CTEST_SOURCE_DIRECTORY");
- this->BinaryDir
- = this->Makefile->GetSafeDefinition("CTEST_BINARY_DIRECTORY");
+ this->SourceDir =
+ this->Makefile->GetSafeDefinition("CTEST_SOURCE_DIRECTORY");
+ this->BinaryDir =
+ this->Makefile->GetSafeDefinition("CTEST_BINARY_DIRECTORY");
// add in translations for src and bin
cmSystemTools::AddKeepPath(this->SourceDir);
cmSystemTools::AddKeepPath(this->BinaryDir);
- this->CTestCmd
- = this->Makefile->GetSafeDefinition("CTEST_COMMAND");
- this->CVSCheckOut
- = this->Makefile->GetSafeDefinition("CTEST_CVS_CHECKOUT");
- this->CTestRoot
- = this->Makefile->GetSafeDefinition("CTEST_DASHBOARD_ROOT");
- this->UpdateCmd
- = this->Makefile->GetSafeDefinition("CTEST_UPDATE_COMMAND");
- if ( this->UpdateCmd.empty() )
- {
- this->UpdateCmd
- = this->Makefile->GetSafeDefinition("CTEST_CVS_COMMAND");
- }
- this->CTestEnv
- = this->Makefile->GetSafeDefinition("CTEST_ENVIRONMENT");
- this->InitialCache
- = this->Makefile->GetSafeDefinition("CTEST_INITIAL_CACHE");
- this->CMakeCmd
- = this->Makefile->GetSafeDefinition("CTEST_CMAKE_COMMAND");
- this->CMOutFile
- = this->Makefile->GetSafeDefinition("CTEST_CMAKE_OUTPUT_FILE_NAME");
-
- this->Backup
- = this->Makefile->IsOn("CTEST_BACKUP_AND_RESTORE");
- this->EmptyBinDir
- = this->Makefile->IsOn("CTEST_START_WITH_EMPTY_BINARY_DIRECTORY");
- this->EmptyBinDirOnce
- = this->Makefile->IsOn("CTEST_START_WITH_EMPTY_BINARY_DIRECTORY_ONCE");
-
- minInterval
- = this->Makefile->GetDefinition("CTEST_CONTINUOUS_MINIMUM_INTERVAL");
- contDuration
- = this->Makefile->GetDefinition("CTEST_CONTINUOUS_DURATION");
+ this->CTestCmd = this->Makefile->GetSafeDefinition("CTEST_COMMAND");
+ this->CVSCheckOut = this->Makefile->GetSafeDefinition("CTEST_CVS_CHECKOUT");
+ this->CTestRoot = this->Makefile->GetSafeDefinition("CTEST_DASHBOARD_ROOT");
+ this->UpdateCmd = this->Makefile->GetSafeDefinition("CTEST_UPDATE_COMMAND");
+ if (this->UpdateCmd.empty()) {
+ this->UpdateCmd = this->Makefile->GetSafeDefinition("CTEST_CVS_COMMAND");
+ }
+ this->CTestEnv = this->Makefile->GetSafeDefinition("CTEST_ENVIRONMENT");
+ this->InitialCache =
+ this->Makefile->GetSafeDefinition("CTEST_INITIAL_CACHE");
+ this->CMakeCmd = this->Makefile->GetSafeDefinition("CTEST_CMAKE_COMMAND");
+ this->CMOutFile =
+ this->Makefile->GetSafeDefinition("CTEST_CMAKE_OUTPUT_FILE_NAME");
+
+ this->Backup = this->Makefile->IsOn("CTEST_BACKUP_AND_RESTORE");
+ this->EmptyBinDir =
+ this->Makefile->IsOn("CTEST_START_WITH_EMPTY_BINARY_DIRECTORY");
+ this->EmptyBinDirOnce =
+ this->Makefile->IsOn("CTEST_START_WITH_EMPTY_BINARY_DIRECTORY_ONCE");
+
+ minInterval =
+ this->Makefile->GetDefinition("CTEST_CONTINUOUS_MINIMUM_INTERVAL");
+ contDuration = this->Makefile->GetDefinition("CTEST_CONTINUOUS_DURATION");
char updateVar[40];
int i;
- for (i = 1; i < 10; ++i)
- {
- sprintf(updateVar,"CTEST_EXTRA_UPDATES_%i",i);
- const char *updateVal = this->Makefile->GetDefinition(updateVar);
- if ( updateVal )
- {
- if ( this->UpdateCmd.empty() )
- {
- cmSystemTools::Error(updateVar,
- " specified without specifying CTEST_CVS_COMMAND.");
+ for (i = 1; i < 10; ++i) {
+ sprintf(updateVar, "CTEST_EXTRA_UPDATES_%i", i);
+ const char* updateVal = this->Makefile->GetDefinition(updateVar);
+ if (updateVal) {
+ if (this->UpdateCmd.empty()) {
+ cmSystemTools::Error(
+ updateVar, " specified without specifying CTEST_CVS_COMMAND.");
return 12;
- }
- this->ExtraUpdates.push_back(updateVal);
}
+ this->ExtraUpdates.push_back(updateVal);
}
+ }
// in order to backup and restore we also must have the cvs root
- if (this->Backup && this->CVSCheckOut.empty())
- {
+ if (this->Backup && this->CVSCheckOut.empty()) {
cmSystemTools::Error(
"Backup was requested without specifying CTEST_CVS_CHECKOUT.");
return 3;
- }
+ }
// make sure the required info is here
- if (this->SourceDir.empty() ||
- this->BinaryDir.empty() ||
- this->CTestCmd.empty())
- {
+ if (this->SourceDir.empty() || this->BinaryDir.empty() ||
+ this->CTestCmd.empty()) {
std::string msg = "CTEST_SOURCE_DIRECTORY = ";
msg += (!this->SourceDir.empty()) ? this->SourceDir.c_str() : "(Null)";
msg += "\nCTEST_BINARY_DIRECTORY = ";
@@ -527,25 +479,21 @@ int cmCTestScriptHandler::ExtractVariables()
"Some required settings in the configuration file were missing:\n",
msg.c_str());
return 4;
- }
+ }
// if the dashboard root isn't specified then we can compute it from the
// this->SourceDir
- if (this->CTestRoot.empty() )
- {
+ if (this->CTestRoot.empty()) {
this->CTestRoot = cmSystemTools::GetFilenamePath(this->SourceDir).c_str();
- }
+ }
// the script may override the minimum continuous interval
- if (minInterval)
- {
+ if (minInterval) {
this->MinimumInterval = 60 * atof(minInterval);
- }
- if (contDuration)
- {
+ }
+ if (contDuration) {
this->ContinuousDuration = 60.0 * atof(contDuration);
- }
-
+ }
this->UpdateElapsedTime();
@@ -555,15 +503,15 @@ int cmCTestScriptHandler::ExtractVariables()
void cmCTestScriptHandler::SleepInSeconds(unsigned int secondsToWait)
{
#if defined(_WIN32)
- Sleep(1000*secondsToWait);
+ Sleep(1000 * secondsToWait);
#else
- sleep(secondsToWait);
+ sleep(secondsToWait);
#endif
}
// run a specific script
-int cmCTestScriptHandler::RunConfigurationScript
-(const std::string& total_script_arg, bool pscope)
+int cmCTestScriptHandler::RunConfigurationScript(
+ const std::string& total_script_arg, bool pscope)
{
#ifdef CMAKE_BUILD_WITH_CMAKE
cmSystemTools::SaveRestoreEnvironment sre;
@@ -571,32 +519,26 @@ int cmCTestScriptHandler::RunConfigurationScript
int result;
- this->ScriptStartTime =
- cmSystemTools::GetTime();
+ this->ScriptStartTime = cmSystemTools::GetTime();
// read in the script
- if (pscope)
- {
+ if (pscope) {
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Reading Script: " << total_script_arg << std::endl);
+ "Reading Script: " << total_script_arg << std::endl);
result = this->ReadInScript(total_script_arg);
- }
- else
- {
+ } else {
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Executing Script: " << total_script_arg << std::endl);
+ "Executing Script: " << total_script_arg << std::endl);
result = this->ExecuteScript(total_script_arg);
- }
- if (result)
- {
+ }
+ if (result) {
return result;
- }
+ }
// only run the curent script if we should
- if (this->Makefile && this->Makefile->IsOn("CTEST_RUN_CURRENT_SCRIPT"))
- {
+ if (this->Makefile && this->Makefile->IsOn("CTEST_RUN_CURRENT_SCRIPT")) {
return this->RunCurrentScript();
- }
+ }
return result;
}
@@ -612,52 +554,43 @@ int cmCTestScriptHandler::RunCurrentScript()
// extract the vars from the cache and store in ivars
result = this->ExtractVariables();
- if (result)
- {
+ if (result) {
return result;
- }
+ }
// set any environment variables
- if (!this->CTestEnv.empty())
- {
+ if (!this->CTestEnv.empty()) {
std::vector<std::string> envArgs;
- cmSystemTools::ExpandListArgument(this->CTestEnv,envArgs);
+ cmSystemTools::ExpandListArgument(this->CTestEnv, envArgs);
cmSystemTools::AppendEnv(envArgs);
- }
+ }
// now that we have done most of the error checking finally run the
// dashboard, we may be asked to repeatedly run this dashboard, such as
// for a continuous, do we ned to run it more than once?
- if ( this->ContinuousDuration >= 0 )
- {
+ if (this->ContinuousDuration >= 0) {
this->UpdateElapsedTime();
- double ending_time = cmSystemTools::GetTime() + this->ContinuousDuration;
- if (this->EmptyBinDirOnce)
- {
+ double ending_time = cmSystemTools::GetTime() + this->ContinuousDuration;
+ if (this->EmptyBinDirOnce) {
this->EmptyBinDir = true;
- }
- do
- {
+ }
+ do {
double interval = cmSystemTools::GetTime();
result = this->RunConfigurationDashboard();
interval = cmSystemTools::GetTime() - interval;
- if (interval < this->MinimumInterval)
- {
+ if (interval < this->MinimumInterval) {
this->SleepInSeconds(
static_cast<unsigned int>(this->MinimumInterval - interval));
- }
- if (this->EmptyBinDirOnce)
- {
+ }
+ if (this->EmptyBinDirOnce) {
this->EmptyBinDir = false;
- }
}
- while (cmSystemTools::GetTime() < ending_time);
- }
+ } while (cmSystemTools::GetTime() < ending_time);
+ }
// otherwise just run it once
- else
- {
+ else {
result = this->RunConfigurationDashboard();
- }
+ }
return result;
}
@@ -670,23 +603,20 @@ int cmCTestScriptHandler::CheckOutSourceDir()
bool res;
if (!cmSystemTools::FileExists(this->SourceDir.c_str()) &&
- !this->CVSCheckOut.empty())
- {
+ !this->CVSCheckOut.empty()) {
// we must now checkout the src dir
output = "";
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Run cvs: " << this->CVSCheckOut << std::endl);
+ "Run cvs: " << this->CVSCheckOut << std::endl);
res = cmSystemTools::RunSingleCommand(
- this->CVSCheckOut.c_str(), &output, &output,
- &retVal, this->CTestRoot.c_str(), this->HandlerVerbose,
- 0 /*this->TimeOut*/);
- if (!res || retVal != 0)
- {
+ this->CVSCheckOut.c_str(), &output, &output, &retVal,
+ this->CTestRoot.c_str(), this->HandlerVerbose, 0 /*this->TimeOut*/);
+ if (!res || retVal != 0) {
cmSystemTools::Error("Unable to perform cvs checkout:\n",
output.c_str());
return 6;
- }
}
+ }
return 0;
}
@@ -701,17 +631,14 @@ int cmCTestScriptHandler::BackupDirectories()
this->BackupBinaryDir += "_CMakeBackup";
// backup the binary and src directories if requested
- if (this->Backup)
- {
+ if (this->Backup) {
// if for some reason those directories exist then first delete them
- if (cmSystemTools::FileExists(this->BackupSourceDir.c_str()))
- {
+ if (cmSystemTools::FileExists(this->BackupSourceDir.c_str())) {
cmSystemTools::RemoveADirectory(this->BackupSourceDir);
- }
- if (cmSystemTools::FileExists(this->BackupBinaryDir.c_str()))
- {
+ }
+ if (cmSystemTools::FileExists(this->BackupBinaryDir.c_str())) {
cmSystemTools::RemoveADirectory(this->BackupBinaryDir);
- }
+ }
// first rename the src and binary directories
rename(this->SourceDir.c_str(), this->BackupSourceDir.c_str());
@@ -719,17 +646,15 @@ int cmCTestScriptHandler::BackupDirectories()
// we must now checkout the src dir
retVal = this->CheckOutSourceDir();
- if (retVal)
- {
+ if (retVal) {
this->RestoreBackupDirectories();
return retVal;
- }
}
+ }
return 0;
}
-
int cmCTestScriptHandler::PerformExtraUpdates()
{
std::string command;
@@ -740,38 +665,30 @@ int cmCTestScriptHandler::PerformExtraUpdates()
// do an initial cvs update as required
command = this->UpdateCmd;
std::vector<std::string>::iterator it;
- for (it = this->ExtraUpdates.begin();
- it != this->ExtraUpdates.end();
- ++ it )
- {
+ for (it = this->ExtraUpdates.begin(); it != this->ExtraUpdates.end(); ++it) {
std::vector<std::string> cvsArgs;
- cmSystemTools::ExpandListArgument(*it,cvsArgs);
- if (cvsArgs.size() == 2)
- {
+ cmSystemTools::ExpandListArgument(*it, cvsArgs);
+ if (cvsArgs.size() == 2) {
std::string fullCommand = command;
fullCommand += " update ";
fullCommand += cvsArgs[1];
output = "";
retVal = 0;
- cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run Update: "
- << fullCommand << std::endl);
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Run Update: " << fullCommand << std::endl);
res = cmSystemTools::RunSingleCommand(
- fullCommand.c_str(), &output, &output,
- &retVal, cvsArgs[0].c_str(),
+ fullCommand.c_str(), &output, &output, &retVal, cvsArgs[0].c_str(),
this->HandlerVerbose, 0 /*this->TimeOut*/);
- if (!res || retVal != 0)
- {
- cmSystemTools::Error("Unable to perform extra updates:\n",
- it->c_str(), "\nWith output:\n",
- output.c_str());
+ if (!res || retVal != 0) {
+ cmSystemTools::Error("Unable to perform extra updates:\n", it->c_str(),
+ "\nWith output:\n", output.c_str());
return 0;
- }
}
}
+ }
return 0;
}
-
// run a single dashboard entry
int cmCTestScriptHandler::RunConfigurationDashboard()
{
@@ -784,180 +701,153 @@ int cmCTestScriptHandler::RunConfigurationDashboard()
// make sure the src directory is there, if it isn't then we might be able
// to check it out from cvs
retVal = this->CheckOutSourceDir();
- if (retVal)
- {
+ if (retVal) {
return retVal;
- }
+ }
// backup the dirs if requested
retVal = this->BackupDirectories();
- if (retVal)
- {
+ if (retVal) {
return retVal;
- }
+ }
// clear the binary directory?
- if (this->EmptyBinDir)
- {
- if ( !cmCTestScriptHandler::EmptyBinaryDirectory(
- this->BinaryDir.c_str()) )
- {
+ if (this->EmptyBinDir) {
+ if (!cmCTestScriptHandler::EmptyBinaryDirectory(this->BinaryDir.c_str())) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Problem removing the binary directory" << std::endl);
- }
+ "Problem removing the binary directory" << std::endl);
}
+ }
// make sure the binary directory exists if it isn't the srcdir
if (!cmSystemTools::FileExists(this->BinaryDir.c_str()) &&
- this->SourceDir != this->BinaryDir)
- {
- if (!cmSystemTools::MakeDirectory(this->BinaryDir.c_str()))
- {
+ this->SourceDir != this->BinaryDir) {
+ if (!cmSystemTools::MakeDirectory(this->BinaryDir.c_str())) {
cmSystemTools::Error("Unable to create the binary directory:\n",
this->BinaryDir.c_str());
this->RestoreBackupDirectories();
return 7;
- }
}
+ }
// if the binary directory and the source directory are the same,
// and we are starting with an empty binary directory, then that means
// we must check out the source tree
- if (this->EmptyBinDir && this->SourceDir == this->BinaryDir)
- {
+ if (this->EmptyBinDir && this->SourceDir == this->BinaryDir) {
// make sure we have the required info
- if (this->CVSCheckOut.empty())
- {
- cmSystemTools::Error("You have specified the source and binary "
+ if (this->CVSCheckOut.empty()) {
+ cmSystemTools::Error(
+ "You have specified the source and binary "
"directories to be the same (an in source build). You have also "
"specified that the binary directory is to be erased. This means "
"that the source will have to be checked out from CVS. But you have "
"not specified CTEST_CVS_CHECKOUT");
return 8;
- }
+ }
// we must now checkout the src dir
retVal = this->CheckOutSourceDir();
- if (retVal)
- {
+ if (retVal) {
this->RestoreBackupDirectories();
return retVal;
- }
}
+ }
// backup the dirs if requested
retVal = this->PerformExtraUpdates();
- if (retVal)
- {
+ if (retVal) {
return retVal;
- }
+ }
// put the initial cache into the bin dir
- if (!this->InitialCache.empty())
- {
+ if (!this->InitialCache.empty()) {
if (!this->WriteInitialCache(this->BinaryDir.c_str(),
- this->InitialCache.c_str()))
- {
+ this->InitialCache.c_str())) {
this->RestoreBackupDirectories();
return 9;
- }
}
+ }
// do an initial cmake to setup the DartConfig file
int cmakeFailed = 0;
std::string cmakeFailedOuput;
- if (!this->CMakeCmd.empty())
- {
+ if (!this->CMakeCmd.empty()) {
command = this->CMakeCmd;
command += " \"";
command += this->SourceDir;
output = "";
command += "\"";
retVal = 0;
- cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run cmake command: "
- << command << std::endl);
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Run cmake command: " << command << std::endl);
res = cmSystemTools::RunSingleCommand(
- command.c_str(), &output, &output,
- &retVal, this->BinaryDir.c_str(),
+ command.c_str(), &output, &output, &retVal, this->BinaryDir.c_str(),
this->HandlerVerbose, 0 /*this->TimeOut*/);
- if ( !this->CMOutFile.empty() )
- {
+ if (!this->CMOutFile.empty()) {
std::string cmakeOutputFile = this->CMOutFile;
- if ( !cmSystemTools::FileIsFullPath(cmakeOutputFile.c_str()) )
- {
+ if (!cmSystemTools::FileIsFullPath(cmakeOutputFile.c_str())) {
cmakeOutputFile = this->BinaryDir + "/" + cmakeOutputFile;
- }
+ }
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Write CMake output to file: " << cmakeOutputFile
- << std::endl);
+ "Write CMake output to file: " << cmakeOutputFile
+ << std::endl);
cmGeneratedFileStream fout(cmakeOutputFile.c_str());
- if ( fout )
- {
+ if (fout) {
fout << output.c_str();
- }
- else
- {
+ } else {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Cannot open CMake output file: "
- << cmakeOutputFile << " for writing" << std::endl);
- }
+ "Cannot open CMake output file: "
+ << cmakeOutputFile << " for writing" << std::endl);
}
- if (!res || retVal != 0)
- {
+ }
+ if (!res || retVal != 0) {
// even if this fails continue to the next step
cmakeFailed = 1;
cmakeFailedOuput = output;
- }
}
+ }
// run ctest, it may be more than one command in here
std::vector<std::string> ctestCommands;
- cmSystemTools::ExpandListArgument(this->CTestCmd,ctestCommands);
+ cmSystemTools::ExpandListArgument(this->CTestCmd, ctestCommands);
// for each variable/argument do a putenv
- for (unsigned i = 0; i < ctestCommands.size(); ++i)
- {
+ for (unsigned i = 0; i < ctestCommands.size(); ++i) {
command = ctestCommands[i];
output = "";
retVal = 0;
- cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run ctest command: "
- << command << std::endl);
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Run ctest command: " << command << std::endl);
res = cmSystemTools::RunSingleCommand(
- command.c_str(), &output, &output,
- &retVal, this->BinaryDir.c_str(), this->HandlerVerbose,
- 0 /*this->TimeOut*/);
+ command.c_str(), &output, &output, &retVal, this->BinaryDir.c_str(),
+ this->HandlerVerbose, 0 /*this->TimeOut*/);
// did something critical fail in ctest
- if (!res || cmakeFailed ||
- retVal & cmCTest::BUILD_ERRORS)
- {
+ if (!res || cmakeFailed || retVal & cmCTest::BUILD_ERRORS) {
this->RestoreBackupDirectories();
- if (cmakeFailed)
- {
+ if (cmakeFailed) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Unable to run cmake:" << std::endl
- << cmakeFailedOuput << std::endl);
+ "Unable to run cmake:" << std::endl
+ << cmakeFailedOuput << std::endl);
return 10;
- }
+ }
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Unable to run ctest:" << std::endl
- << "command: " << command << std::endl
- << "output: " << output << std::endl);
- if (!res)
- {
+ "Unable to run ctest:" << std::endl
+ << "command: " << command << std::endl
+ << "output: " << output << std::endl);
+ if (!res) {
return 11;
- }
- return retVal * 100;
}
+ return retVal * 100;
}
+ }
// if all was succesful, delete the backup dirs to free up disk space
- if (this->Backup)
- {
+ if (this->Backup) {
cmSystemTools::RemoveADirectory(this->BackupSourceDir);
cmSystemTools::RemoveADirectory(this->BackupBinaryDir);
- }
+ }
return 0;
}
@@ -968,15 +858,13 @@ bool cmCTestScriptHandler::WriteInitialCache(const char* directory,
std::string cacheFile = directory;
cacheFile += "/CMakeCache.txt";
cmGeneratedFileStream fout(cacheFile.c_str());
- if(!fout)
- {
+ if (!fout) {
return false;
- }
+ }
- if (text!=0)
- {
+ if (text != 0) {
fout.write(text, strlen(text));
- }
+ }
// Make sure the operating system has finished writing the file
// before closing it. This will ensure the file is finished before
@@ -990,69 +878,60 @@ void cmCTestScriptHandler::RestoreBackupDirectories()
{
// if we backed up the dirs and the build failed, then restore
// the backed up dirs
- if (this->Backup)
- {
+ if (this->Backup) {
// if for some reason those directories exist then first delete them
- if (cmSystemTools::FileExists(this->SourceDir.c_str()))
- {
+ if (cmSystemTools::FileExists(this->SourceDir.c_str())) {
cmSystemTools::RemoveADirectory(this->SourceDir);
- }
- if (cmSystemTools::FileExists(this->BinaryDir.c_str()))
- {
+ }
+ if (cmSystemTools::FileExists(this->BinaryDir.c_str())) {
cmSystemTools::RemoveADirectory(this->BinaryDir);
- }
+ }
// rename the src and binary directories
rename(this->BackupSourceDir.c_str(), this->SourceDir.c_str());
rename(this->BackupBinaryDir.c_str(), this->BinaryDir.c_str());
- }
+ }
}
-bool cmCTestScriptHandler::RunScript(cmCTest* ctest, const char *sname,
+bool cmCTestScriptHandler::RunScript(cmCTest* ctest, const char* sname,
bool InProcess, int* returnValue)
{
cmCTestScriptHandler* sh = new cmCTestScriptHandler();
sh->SetCTestInstance(ctest);
- sh->AddConfigurationScript(sname,InProcess);
+ sh->AddConfigurationScript(sname, InProcess);
int res = sh->ProcessHandler();
- if(returnValue)
- {
+ if (returnValue) {
*returnValue = res;
- }
+ }
delete sh;
return true;
}
-bool cmCTestScriptHandler::EmptyBinaryDirectory(const char *sname)
+bool cmCTestScriptHandler::EmptyBinaryDirectory(const char* sname)
{
// try to avoid deleting root
- if (!sname || strlen(sname) < 2)
- {
+ if (!sname || strlen(sname) < 2) {
return false;
- }
+ }
// consider non existing target directory a success
- if(!cmSystemTools::FileExists(sname))
- {
+ if (!cmSystemTools::FileExists(sname)) {
return true;
- }
+ }
// try to avoid deleting directories that we shouldn't
std::string check = sname;
check += "/CMakeCache.txt";
- if(!cmSystemTools::FileExists(check.c_str()))
- {
+ if (!cmSystemTools::FileExists(check.c_str())) {
return false;
- }
+ }
- for(int i = 0; i < 5; ++i)
- {
- if(TryToRemoveBinaryDirectoryOnce(sname))
- {
+ for (int i = 0; i < 5; ++i) {
+ if (TryToRemoveBinaryDirectoryOnce(sname)) {
return true;
- }
- cmSystemTools::Delay(100);
}
+ cmSystemTools::Delay(100);
+ }
return false;
}
@@ -1063,34 +942,27 @@ bool cmCTestScriptHandler::TryToRemoveBinaryDirectoryOnce(
cmsys::Directory directory;
directory.Load(directoryPath);
- for(unsigned long i = 0; i < directory.GetNumberOfFiles(); ++i)
- {
+ for (unsigned long i = 0; i < directory.GetNumberOfFiles(); ++i) {
std::string path = directory.GetFile(i);
- if(path == "." || path == ".." || path == "CMakeCache.txt")
- {
+ if (path == "." || path == ".." || path == "CMakeCache.txt") {
continue;
- }
+ }
std::string fullPath = directoryPath + std::string("/") + path;
bool isDirectory = cmSystemTools::FileIsDirectory(fullPath) &&
!cmSystemTools::FileIsSymlink(fullPath);
- if(isDirectory)
- {
- if(!cmSystemTools::RemoveADirectory(fullPath))
- {
+ if (isDirectory) {
+ if (!cmSystemTools::RemoveADirectory(fullPath)) {
return false;
- }
}
- else
- {
- if(!cmSystemTools::RemoveFile(fullPath))
- {
+ } else {
+ if (!cmSystemTools::RemoveFile(fullPath)) {
return false;
- }
}
+ }
}
return cmSystemTools::RemoveADirectory(directoryPath);
@@ -1098,18 +970,15 @@ bool cmCTestScriptHandler::TryToRemoveBinaryDirectoryOnce(
double cmCTestScriptHandler::GetRemainingTimeAllowed()
{
- if (!this->Makefile)
- {
+ if (!this->Makefile) {
return 1.0e7;
- }
+ }
- const char *timelimitS
- = this->Makefile->GetDefinition("CTEST_TIME_LIMIT");
+ const char* timelimitS = this->Makefile->GetDefinition("CTEST_TIME_LIMIT");
- if (!timelimitS)
- {
+ if (!timelimitS) {
return 1.0e7;
- }
+ }
double timelimit = atof(timelimitS);
diff --git a/Source/CTest/cmCTestScriptHandler.h b/Source/CTest/cmCTestScriptHandler.h
index 2b66f70..e09e040 100644
--- a/Source/CTest/cmCTestScriptHandler.h
+++ b/Source/CTest/cmCTestScriptHandler.h
@@ -66,7 +66,7 @@ public:
/**
* Add a script to run, and if is should run in the current process
*/
- void AddConfigurationScript(const char *, bool pscope);
+ void AddConfigurationScript(const char*, bool pscope);
/**
* Run a dashboard using a specified confiuration script
@@ -76,14 +76,14 @@ public:
/*
* Run a script
*/
- static bool RunScript(cmCTest* ctest, const char *script, bool InProcess,
- int* returnValue);
+ static bool RunScript(cmCTest* ctest, const char* script, bool InProcess,
+ int* returnValue);
int RunCurrentScript();
/*
* Empty Binary Directory
*/
- static bool EmptyBinaryDirectory(const char *dir);
+ static bool EmptyBinaryDirectory(const char* dir);
/*
* Write an initial CMakeCache.txt from the given contents.
@@ -109,7 +109,7 @@ public:
void Initialize();
void CreateCMake();
- cmake* GetCMake() { return this->CMake;}
+ cmake* GetCMake() { return this->CMake; }
private:
// reads in a script
int ReadInScript(const std::string& total_script_arg);
@@ -164,9 +164,9 @@ private:
// what time in seconds did this script start running
double ScriptStartTime;
- cmMakefile *Makefile;
- cmGlobalGenerator *GlobalGenerator;
- cmake *CMake;
+ cmMakefile* Makefile;
+ cmGlobalGenerator* GlobalGenerator;
+ cmake* CMake;
};
#endif
diff --git a/Source/CTest/cmCTestSleepCommand.cxx b/Source/CTest/cmCTestSleepCommand.cxx
index 7e87550..102a303 100644
--- a/Source/CTest/cmCTestSleepCommand.cxx
+++ b/Source/CTest/cmCTestSleepCommand.cxx
@@ -14,42 +14,36 @@
#include "cmCTestScriptHandler.h"
#include <stdlib.h> // required for atoi
-bool cmCTestSleepCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmCTestSleepCommand::InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus&)
{
- if (args.size() < 1)
- {
+ if (args.size() < 1) {
this->SetError("called with incorrect number of arguments");
return false;
- }
+ }
// sleep for specified seconds
unsigned int time1 = atoi(args[0].c_str());
- if(args.size() == 1 )
- {
+ if (args.size() == 1) {
cmCTestScriptHandler::SleepInSeconds(time1);
// update the elapsed time since it could have slept for a while
this->CTestScriptHandler->UpdateElapsedTime();
return true;
- }
+ }
// sleep up to a duration
- if(args.size() == 3 )
- {
+ if (args.size() == 3) {
unsigned int duration = atoi(args[1].c_str());
unsigned int time2 = atoi(args[2].c_str());
- if (time1 + duration > time2)
- {
+ if (time1 + duration > time2) {
duration = (time1 + duration - time2);
cmCTestScriptHandler::SleepInSeconds(duration);
// update the elapsed time since it could have slept for a while
this->CTestScriptHandler->UpdateElapsedTime();
- }
- return true;
}
+ return true;
+ }
this->SetError("called with incorrect number of arguments");
return false;
}
-
-
diff --git a/Source/CTest/cmCTestSleepCommand.h b/Source/CTest/cmCTestSleepCommand.h
index 740a7e1..ff7f146 100644
--- a/Source/CTest/cmCTestSleepCommand.h
+++ b/Source/CTest/cmCTestSleepCommand.h
@@ -23,35 +23,32 @@
class cmCTestSleepCommand : public cmCTestCommand
{
public:
-
cmCTestSleepCommand() {}
/**
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
- {
+ {
cmCTestSleepCommand* ni = new cmCTestSleepCommand;
ni->CTest = this->CTest;
ni->CTestScriptHandler = this->CTestScriptHandler;
return ni;
- }
+ }
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus &status);
+ cmExecutionStatus& status);
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const { return "ctest_sleep";}
+ virtual std::string GetName() const { return "ctest_sleep"; }
cmTypeMacro(cmCTestSleepCommand, cmCTestCommand);
-
};
-
#endif
diff --git a/Source/CTest/cmCTestStartCommand.cxx b/Source/CTest/cmCTestStartCommand.cxx
index fef5637..d561393 100644
--- a/Source/CTest/cmCTestStartCommand.cxx
+++ b/Source/CTest/cmCTestStartCommand.cxx
@@ -22,14 +22,13 @@ cmCTestStartCommand::cmCTestStartCommand()
this->Quiet = false;
}
-bool cmCTestStartCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmCTestStartCommand::InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus&)
{
- if (args.size() < 1)
- {
+ if (args.size() < 1) {
this->SetError("called with incorrect number of arguments");
return false;
- }
+ }
size_t cnt = 0;
const char* smodel = args[cnt].c_str();
@@ -39,62 +38,50 @@ bool cmCTestStartCommand
cnt++;
this->CTest->SetSpecificTrack(0);
- if ( cnt < args.size() -1 )
- {
- if ( args[cnt] == "TRACK" )
- {
- cnt ++;
+ if (cnt < args.size() - 1) {
+ if (args[cnt] == "TRACK") {
+ cnt++;
this->CTest->SetSpecificTrack(args[cnt].c_str());
- cnt ++;
- }
+ cnt++;
}
+ }
- if (cnt < args.size())
- {
- if (args[cnt] == "APPEND")
- {
- cnt ++;
+ if (cnt < args.size()) {
+ if (args[cnt] == "APPEND") {
+ cnt++;
this->CreateNewTag = false;
- }
}
- if (cnt < args.size())
- {
- if (args[cnt] == "QUIET")
- {
- cnt ++;
+ }
+ if (cnt < args.size()) {
+ if (args[cnt] == "QUIET") {
+ cnt++;
this->Quiet = true;
- }
}
+ }
- if ( cnt < args.size() )
- {
+ if (cnt < args.size()) {
src_dir = args[cnt].c_str();
- cnt ++;
- if ( cnt < args.size() )
- {
+ cnt++;
+ if (cnt < args.size()) {
bld_dir = args[cnt].c_str();
- }
}
- if ( !src_dir )
- {
+ }
+ if (!src_dir) {
src_dir = this->Makefile->GetDefinition("CTEST_SOURCE_DIRECTORY");
- }
- if ( !bld_dir)
- {
+ }
+ if (!bld_dir) {
bld_dir = this->Makefile->GetDefinition("CTEST_BINARY_DIRECTORY");
- }
- if ( !src_dir )
- {
+ }
+ if (!src_dir) {
this->SetError("source directory not specified. Specify source directory "
- "as an argument or set CTEST_SOURCE_DIRECTORY");
+ "as an argument or set CTEST_SOURCE_DIRECTORY");
return false;
- }
- if ( !bld_dir)
- {
+ }
+ if (!bld_dir) {
this->SetError("binary directory not specified. Specify binary directory "
- "as an argument or set CTEST_BINARY_DIRECTORY");
+ "as an argument or set CTEST_BINARY_DIRECTORY");
return false;
- }
+ }
cmSystemTools::AddKeepPath(src_dir);
cmSystemTools::AddKeepPath(bld_dir);
@@ -104,38 +91,35 @@ bool cmCTestStartCommand
std::string sourceDir = cmSystemTools::CollapseFullPath(src_dir);
std::string binaryDir = cmSystemTools::CollapseFullPath(bld_dir);
this->CTest->SetCTestConfiguration("SourceDirectory", sourceDir.c_str(),
- this->Quiet);
+ this->Quiet);
this->CTest->SetCTestConfiguration("BuildDirectory", binaryDir.c_str(),
- this->Quiet);
+ this->Quiet);
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "Run dashboard with model "
- << smodel << std::endl
- << " Source directory: " << src_dir << std::endl
- << " Build directory: " << bld_dir << std::endl, this->Quiet);
+ << smodel << std::endl
+ << " Source directory: " << src_dir << std::endl
+ << " Build directory: " << bld_dir << std::endl,
+ this->Quiet);
const char* track = this->CTest->GetSpecificTrack();
- if ( track )
- {
+ if (track) {
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " Track: " << track << std::endl, this->Quiet);
- }
+ " Track: " << track << std::endl, this->Quiet);
+ }
// Log startup actions.
std::string startLogFile = binaryDir + "/Testing/Temporary/LastStart.log";
cmGeneratedFileStream ofs(startLogFile.c_str());
- if(!ofs)
- {
+ if (!ofs) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Cannot create log file: LastStart.log" << std::endl);
return false;
- }
+ }
// Make sure the source directory exists.
- if(!this->InitialCheckout(ofs, sourceDir))
- {
+ if (!this->InitialCheckout(ofs, sourceDir)) {
return false;
- }
- if(!cmSystemTools::FileIsDirectory(sourceDir))
- {
+ }
+ if (!cmSystemTools::FileIsDirectory(sourceDir)) {
std::ostringstream e;
e << "given source path\n"
<< " " << sourceDir << "\n"
@@ -143,7 +127,7 @@ bool cmCTestStartCommand
<< "Set CTEST_CHECKOUT_COMMAND to a command line to create it.";
this->SetError(e.str());
return false;
- }
+ }
this->Makefile->AddDefinition("CTEST_RUN_CURRENT_SCRIPT", "OFF");
this->CTest->SetSuppressUpdatingCTestConfiguration(true);
@@ -154,26 +138,23 @@ bool cmCTestStartCommand
return this->CTest->InitializeFromCommand(this);
}
-bool cmCTestStartCommand::InitialCheckout(
- std::ostream& ofs, std::string const& sourceDir)
+bool cmCTestStartCommand::InitialCheckout(std::ostream& ofs,
+ std::string const& sourceDir)
{
// Use the user-provided command to create the source tree.
- const char* initialCheckoutCommand
- = this->Makefile->GetDefinition("CTEST_CHECKOUT_COMMAND");
- if(!initialCheckoutCommand)
- {
+ const char* initialCheckoutCommand =
+ this->Makefile->GetDefinition("CTEST_CHECKOUT_COMMAND");
+ if (!initialCheckoutCommand) {
initialCheckoutCommand =
this->Makefile->GetDefinition("CTEST_CVS_CHECKOUT");
- }
- if(initialCheckoutCommand)
- {
+ }
+ if (initialCheckoutCommand) {
// Use a generic VC object to run and log the command.
cmCTestVC vc(this->CTest, ofs);
vc.SetSourceDirectory(sourceDir);
- if(!vc.InitialCheckout(initialCheckoutCommand))
- {
+ if (!vc.InitialCheckout(initialCheckoutCommand)) {
return false;
- }
}
+ }
return true;
}
diff --git a/Source/CTest/cmCTestStartCommand.h b/Source/CTest/cmCTestStartCommand.h
index eed1962..2aa6281 100644
--- a/Source/CTest/cmCTestStartCommand.h
+++ b/Source/CTest/cmCTestStartCommand.h
@@ -22,49 +22,42 @@
class cmCTestStartCommand : public cmCTestCommand
{
public:
-
cmCTestStartCommand();
/**
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
- {
+ {
cmCTestStartCommand* ni = new cmCTestStartCommand;
ni->CTest = this->CTest;
ni->CTestScriptHandler = this->CTestScriptHandler;
ni->CreateNewTag = this->CreateNewTag;
ni->Quiet = this->Quiet;
return ni;
- }
+ }
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus &status);
+ cmExecutionStatus& status);
/**
* Will this invocation of ctest_start create a new TAG file?
*/
- bool ShouldCreateNewTag()
- {
- return this->CreateNewTag;
- }
+ bool ShouldCreateNewTag() { return this->CreateNewTag; }
/**
* Should this invocation of ctest_start output non-error messages?
*/
- bool ShouldBeQuiet()
- {
- return this->Quiet;
- }
+ bool ShouldBeQuiet() { return this->Quiet; }
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const { return "ctest_start";}
+ virtual std::string GetName() const { return "ctest_start"; }
cmTypeMacro(cmCTestStartCommand, cmCTestCommand);
@@ -74,5 +67,4 @@ private:
bool Quiet;
};
-
#endif
diff --git a/Source/CTest/cmCTestSubmitCommand.cxx b/Source/CTest/cmCTestSubmitCommand.cxx
index 6174624..fa9bd2c 100644
--- a/Source/CTest/cmCTestSubmitCommand.cxx
+++ b/Source/CTest/cmCTestSubmitCommand.cxx
@@ -17,96 +17,87 @@
cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler()
{
- const char* ctestDropMethod
- = this->Makefile->GetDefinition("CTEST_DROP_METHOD");
- const char* ctestDropSite
- = this->Makefile->GetDefinition("CTEST_DROP_SITE");
- const char* ctestDropLocation
- = this->Makefile->GetDefinition("CTEST_DROP_LOCATION");
- const char* ctestTriggerSite
- = this->Makefile->GetDefinition("CTEST_TRIGGER_SITE");
- bool ctestDropSiteCDash
- = this->Makefile->IsOn("CTEST_DROP_SITE_CDASH");
- const char* ctestProjectName
- = this->Makefile->GetDefinition("CTEST_PROJECT_NAME");
- if ( !ctestDropMethod )
- {
+ const char* ctestDropMethod =
+ this->Makefile->GetDefinition("CTEST_DROP_METHOD");
+ const char* ctestDropSite = this->Makefile->GetDefinition("CTEST_DROP_SITE");
+ const char* ctestDropLocation =
+ this->Makefile->GetDefinition("CTEST_DROP_LOCATION");
+ const char* ctestTriggerSite =
+ this->Makefile->GetDefinition("CTEST_TRIGGER_SITE");
+ bool ctestDropSiteCDash = this->Makefile->IsOn("CTEST_DROP_SITE_CDASH");
+ const char* ctestProjectName =
+ this->Makefile->GetDefinition("CTEST_PROJECT_NAME");
+ if (!ctestDropMethod) {
ctestDropMethod = "http";
- }
+ }
- if ( !ctestDropSite )
- {
+ if (!ctestDropSite) {
// error: CDash requires CTEST_DROP_SITE definition
// in CTestConfig.cmake
- }
- if ( !ctestDropLocation )
- {
+ }
+ if (!ctestDropLocation) {
// error: CDash requires CTEST_DROP_LOCATION definition
// in CTestConfig.cmake
- }
+ }
this->CTest->SetCTestConfiguration("ProjectName", ctestProjectName,
- this->Quiet);
+ this->Quiet);
this->CTest->SetCTestConfiguration("DropMethod", ctestDropMethod,
- this->Quiet);
+ this->Quiet);
this->CTest->SetCTestConfiguration("DropSite", ctestDropSite, this->Quiet);
this->CTest->SetCTestConfiguration("DropLocation", ctestDropLocation,
- this->Quiet);
+ this->Quiet);
- this->CTest->SetCTestConfiguration("IsCDash",
- ctestDropSiteCDash ? "TRUE" : "FALSE", this->Quiet);
+ this->CTest->SetCTestConfiguration(
+ "IsCDash", ctestDropSiteCDash ? "TRUE" : "FALSE", this->Quiet);
// Only propagate TriggerSite for non-CDash projects:
//
- if ( !ctestDropSiteCDash )
- {
- this->CTest->SetCTestConfiguration("TriggerSite", ctestTriggerSite,
- this->Quiet);
- }
+ if (!ctestDropSiteCDash) {
+ this->CTest->SetCTestConfiguration("TriggerSite", ctestTriggerSite,
+ this->Quiet);
+ }
+
+ this->CTest->SetCTestConfigurationFromCMakeVariable(
+ this->Makefile, "CurlOptions", "CTEST_CURL_OPTIONS", this->Quiet);
+ this->CTest->SetCTestConfigurationFromCMakeVariable(
+ this->Makefile, "DropSiteUser", "CTEST_DROP_SITE_USER", this->Quiet);
+ this->CTest->SetCTestConfigurationFromCMakeVariable(
+ this->Makefile, "DropSitePassword", "CTEST_DROP_SITE_PASSWORD",
+ this->Quiet);
+ this->CTest->SetCTestConfigurationFromCMakeVariable(
+ this->Makefile, "ScpCommand", "CTEST_SCP_COMMAND", this->Quiet);
- this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
- "CurlOptions", "CTEST_CURL_OPTIONS", this->Quiet);
- this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
- "DropSiteUser", "CTEST_DROP_SITE_USER", this->Quiet);
- this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
- "DropSitePassword", "CTEST_DROP_SITE_PASSWORD", this->Quiet);
- this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
- "ScpCommand", "CTEST_SCP_COMMAND", this->Quiet);
-
- const char* notesFilesVariable
- = this->Makefile->GetDefinition("CTEST_NOTES_FILES");
- if (notesFilesVariable)
- {
+ const char* notesFilesVariable =
+ this->Makefile->GetDefinition("CTEST_NOTES_FILES");
+ if (notesFilesVariable) {
std::vector<std::string> notesFiles;
cmCTest::VectorOfStrings newNotesFiles;
- cmSystemTools::ExpandListArgument(notesFilesVariable,notesFiles);
- newNotesFiles.insert(newNotesFiles.end(),
- notesFiles.begin(), notesFiles.end());
+ cmSystemTools::ExpandListArgument(notesFilesVariable, notesFiles);
+ newNotesFiles.insert(newNotesFiles.end(), notesFiles.begin(),
+ notesFiles.end());
this->CTest->GenerateNotesFile(newNotesFiles);
- }
+ }
- const char* extraFilesVariable
- = this->Makefile->GetDefinition("CTEST_EXTRA_SUBMIT_FILES");
- if (extraFilesVariable)
- {
+ const char* extraFilesVariable =
+ this->Makefile->GetDefinition("CTEST_EXTRA_SUBMIT_FILES");
+ if (extraFilesVariable) {
std::vector<std::string> extraFiles;
cmCTest::VectorOfStrings newExtraFiles;
- cmSystemTools::ExpandListArgument(extraFilesVariable,extraFiles);
- newExtraFiles.insert(newExtraFiles.end(),
- extraFiles.begin(), extraFiles.end());
- if ( !this->CTest->SubmitExtraFiles(newExtraFiles))
- {
+ cmSystemTools::ExpandListArgument(extraFilesVariable, extraFiles);
+ newExtraFiles.insert(newExtraFiles.end(), extraFiles.begin(),
+ extraFiles.end());
+ if (!this->CTest->SubmitExtraFiles(newExtraFiles)) {
this->SetError("problem submitting extra files.");
return 0;
- }
}
+ }
- cmCTestGenericHandler* handler
- = this->CTest->GetInitializedHandler("submit");
- if ( !handler )
- {
+ cmCTestGenericHandler* handler =
+ this->CTest->GetInitializedHandler("submit");
+ if (!handler) {
this->SetError("internal CTest error. Cannot instantiate submit handler");
return 0;
- }
+ }
// If no FILES or PARTS given, *all* PARTS are submitted by default.
//
@@ -122,8 +113,7 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler()
// If given explicit FILES to submit, pass them to the handler.
//
- if(this->FilesMentioned)
- {
+ if (this->FilesMentioned) {
// Intentionally select *no* PARTS. (Pass an empty set.) If PARTS
// were also explicitly mentioned, they will be selected below...
// But FILES with no PARTS mentioned should just submit the FILES
@@ -133,31 +123,29 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler()
static_cast<cmCTestSubmitHandler*>(handler)->SelectParts(noParts);
static_cast<cmCTestSubmitHandler*>(handler)->SelectFiles(this->Files);
- }
+ }
// If a PARTS option was given, select only the named parts for submission.
//
- if(this->PartsMentioned)
- {
+ if (this->PartsMentioned) {
static_cast<cmCTestSubmitHandler*>(handler)->SelectParts(this->Parts);
- }
+ }
- static_cast<cmCTestSubmitHandler*>(handler)->SetOption("RetryDelay",
- this->RetryDelay.c_str());
- static_cast<cmCTestSubmitHandler*>(handler)->SetOption("RetryCount",
- this->RetryCount.c_str());
- static_cast<cmCTestSubmitHandler*>(handler)->SetOption("InternalTest",
- this->InternalTest ? "ON" : "OFF");
+ static_cast<cmCTestSubmitHandler*>(handler)->SetOption(
+ "RetryDelay", this->RetryDelay.c_str());
+ static_cast<cmCTestSubmitHandler*>(handler)->SetOption(
+ "RetryCount", this->RetryCount.c_str());
+ static_cast<cmCTestSubmitHandler*>(handler)->SetOption(
+ "InternalTest", this->InternalTest ? "ON" : "OFF");
handler->SetQuiet(this->Quiet);
- if (this->CDashUpload)
- {
- static_cast<cmCTestSubmitHandler*>(handler)->
- SetOption("CDashUploadFile", this->CDashUploadFile.c_str());
- static_cast<cmCTestSubmitHandler*>(handler)->
- SetOption("CDashUploadType", this->CDashUploadType.c_str());
- }
+ if (this->CDashUpload) {
+ static_cast<cmCTestSubmitHandler*>(handler)->SetOption(
+ "CDashUploadFile", this->CDashUploadFile.c_str());
+ static_cast<cmCTestSubmitHandler*>(handler)->SetOption(
+ "CDashUploadType", this->CDashUploadType.c_str());
+ }
return handler;
}
@@ -170,124 +158,101 @@ bool cmCTestSubmitCommand::InitialPass(std::vector<std::string> const& args,
bool cmCTestSubmitCommand::CheckArgumentKeyword(std::string const& arg)
{
- if (this->CDashUpload)
- {
- if(arg == "CDASH_UPLOAD")
- {
+ if (this->CDashUpload) {
+ if (arg == "CDASH_UPLOAD") {
this->ArgumentDoing = ArgumentDoingCDashUpload;
return true;
- }
+ }
- if(arg == "CDASH_UPLOAD_TYPE")
- {
+ if (arg == "CDASH_UPLOAD_TYPE") {
this->ArgumentDoing = ArgumentDoingCDashUploadType;
return true;
- }
}
- else
- {
+ } else {
// Look for arguments specific to this command.
- if(arg == "PARTS")
- {
+ if (arg == "PARTS") {
this->ArgumentDoing = ArgumentDoingParts;
this->PartsMentioned = true;
return true;
- }
+ }
- if(arg == "FILES")
- {
+ if (arg == "FILES") {
this->ArgumentDoing = ArgumentDoingFiles;
this->FilesMentioned = true;
return true;
- }
+ }
- if(arg == "RETRY_COUNT")
- {
+ if (arg == "RETRY_COUNT") {
this->ArgumentDoing = ArgumentDoingRetryCount;
return true;
- }
+ }
- if(arg == "RETRY_DELAY")
- {
+ if (arg == "RETRY_DELAY") {
this->ArgumentDoing = ArgumentDoingRetryDelay;
return true;
- }
+ }
- if(arg == "INTERNAL_TEST_CHECKSUM")
- {
+ if (arg == "INTERNAL_TEST_CHECKSUM") {
this->InternalTest = true;
return true;
- }
}
+ }
// Look for other arguments.
return this->Superclass::CheckArgumentKeyword(arg);
}
-
bool cmCTestSubmitCommand::CheckArgumentValue(std::string const& arg)
{
// Handle states specific to this command.
- if(this->ArgumentDoing == ArgumentDoingParts)
- {
+ if (this->ArgumentDoing == ArgumentDoingParts) {
cmCTest::Part p = this->CTest->GetPartFromName(arg.c_str());
- if(p != cmCTest::PartCount)
- {
+ if (p != cmCTest::PartCount) {
this->Parts.insert(p);
- }
- else
- {
+ } else {
std::ostringstream e;
e << "Part name \"" << arg << "\" is invalid.";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
this->ArgumentDoing = ArgumentDoingError;
- }
- return true;
}
+ return true;
+ }
- if(this->ArgumentDoing == ArgumentDoingFiles)
- {
+ if (this->ArgumentDoing == ArgumentDoingFiles) {
std::string filename(arg);
- if(cmSystemTools::FileExists(filename.c_str()))
- {
+ if (cmSystemTools::FileExists(filename.c_str())) {
this->Files.insert(filename);
- }
- else
- {
+ } else {
std::ostringstream e;
e << "File \"" << filename << "\" does not exist. Cannot submit "
- << "a non-existent file.";
+ << "a non-existent file.";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
this->ArgumentDoing = ArgumentDoingError;
- }
- return true;
}
+ return true;
+ }
- if(this->ArgumentDoing == ArgumentDoingRetryCount)
- {
+ if (this->ArgumentDoing == ArgumentDoingRetryCount) {
this->RetryCount = arg;
return true;
- }
+ }
- if(this->ArgumentDoing == ArgumentDoingRetryDelay)
- {
+ if (this->ArgumentDoing == ArgumentDoingRetryDelay) {
this->RetryDelay = arg;
return true;
- }
+ }
- if(this->ArgumentDoing == ArgumentDoingCDashUpload)
- {
+ if (this->ArgumentDoing == ArgumentDoingCDashUpload) {
this->ArgumentDoing = ArgumentDoingNone;
this->CDashUploadFile = arg;
return true;
- }
+ }
- if(this->ArgumentDoing == ArgumentDoingCDashUploadType)
- {
+ if (this->ArgumentDoing == ArgumentDoingCDashUploadType) {
this->ArgumentDoing = ArgumentDoingNone;
this->CDashUploadType = arg;
return true;
- }
+ }
// Look for other arguments.
return this->Superclass::CheckArgumentValue(arg);
diff --git a/Source/CTest/cmCTestSubmitCommand.h b/Source/CTest/cmCTestSubmitCommand.h
index ebc8c36..6323d8c 100644
--- a/Source/CTest/cmCTestSubmitCommand.h
+++ b/Source/CTest/cmCTestSubmitCommand.h
@@ -25,35 +25,34 @@
class cmCTestSubmitCommand : public cmCTestHandlerCommand
{
public:
-
cmCTestSubmitCommand()
- {
+ {
this->PartsMentioned = false;
this->FilesMentioned = false;
this->InternalTest = false;
this->RetryCount = "";
this->RetryDelay = "";
this->CDashUpload = false;
- }
+ }
/**
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
- {
+ {
cmCTestSubmitCommand* ni = new cmCTestSubmitCommand;
ni->CTest = this->CTest;
ni->CTestScriptHandler = this->CTestScriptHandler;
return ni;
- }
+ }
virtual bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus &status);
+ cmExecutionStatus& status);
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const { return "ctest_submit";}
+ virtual std::string GetName() const { return "ctest_submit"; }
cmTypeMacro(cmCTestSubmitCommand, cmCTestHandlerCommand);
@@ -86,5 +85,4 @@ protected:
std::string CDashUploadType;
};
-
#endif
diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx
index 2153b8f..bbc6b37 100644
--- a/Source/CTest/cmCTestSubmitHandler.cxx
+++ b/Source/CTest/cmCTestSubmitHandler.cxx
@@ -37,20 +37,19 @@
typedef std::vector<char> cmCTestSubmitHandlerVectorOfChar;
-class cmCTestSubmitHandler::ResponseParser: public cmXMLParser
+class cmCTestSubmitHandler::ResponseParser : public cmXMLParser
{
public:
ResponseParser() { this->Status = STATUS_OK; }
~ResponseParser() {}
public:
-
enum StatusType
- {
+ {
STATUS_OK,
STATUS_WARNING,
STATUS_ERROR
- };
+ };
StatusType Status;
std::string CDashVersion;
@@ -59,93 +58,78 @@ public:
std::string Message;
private:
-
std::vector<char> CurrentValue;
std::string GetCurrentValue()
- {
+ {
std::string val;
- if(!this->CurrentValue.empty())
- {
+ if (!this->CurrentValue.empty()) {
val.assign(&this->CurrentValue[0], this->CurrentValue.size());
- }
- return val;
}
+ return val;
+ }
virtual void StartElement(const std::string& name, const char** atts)
- {
+ {
this->CurrentValue.clear();
- if(name == "cdash")
- {
+ if (name == "cdash") {
this->CDashVersion = this->FindAttribute(atts, "version");
- }
}
+ }
virtual void CharacterDataHandler(const char* data, int length)
- {
- this->CurrentValue.insert(this->CurrentValue.end(), data, data+length);
- }
+ {
+ this->CurrentValue.insert(this->CurrentValue.end(), data, data + length);
+ }
virtual void EndElement(const std::string& name)
- {
- if(name == "status")
- {
+ {
+ if (name == "status") {
std::string status = cmSystemTools::UpperCase(this->GetCurrentValue());
- if(status == "OK" || status == "SUCCESS")
- {
+ if (status == "OK" || status == "SUCCESS") {
this->Status = STATUS_OK;
- }
- else if(status == "WARNING")
- {
+ } else if (status == "WARNING") {
this->Status = STATUS_WARNING;
- }
- else
- {
+ } else {
this->Status = STATUS_ERROR;
- }
}
- else if(name == "filename")
- {
+ } else if (name == "filename") {
this->Filename = this->GetCurrentValue();
- }
- else if(name == "md5")
- {
+ } else if (name == "md5") {
this->MD5 = this->GetCurrentValue();
- }
- else if(name == "message")
- {
+ } else if (name == "message") {
this->Message = this->GetCurrentValue();
- }
}
+ }
};
-
-static size_t
-cmCTestSubmitHandlerWriteMemoryCallback(void *ptr, size_t size, size_t nmemb,
- void *data)
+static size_t cmCTestSubmitHandlerWriteMemoryCallback(void* ptr, size_t size,
+ size_t nmemb, void* data)
{
int realsize = (int)(size * nmemb);
- cmCTestSubmitHandlerVectorOfChar *vec
- = static_cast<cmCTestSubmitHandlerVectorOfChar*>(data);
+ cmCTestSubmitHandlerVectorOfChar* vec =
+ static_cast<cmCTestSubmitHandlerVectorOfChar*>(data);
const char* chPtr = static_cast<char*>(ptr);
vec->insert(vec->end(), chPtr, chPtr + realsize);
return realsize;
}
-static size_t
-cmCTestSubmitHandlerCurlDebugCallback(CURL *, curl_infotype, char *chPtr,
- size_t size, void *data)
+static size_t cmCTestSubmitHandlerCurlDebugCallback(CURL*, curl_infotype,
+ char* chPtr, size_t size,
+ void* data)
{
- cmCTestSubmitHandlerVectorOfChar *vec
- = static_cast<cmCTestSubmitHandlerVectorOfChar*>(data);
+ cmCTestSubmitHandlerVectorOfChar* vec =
+ static_cast<cmCTestSubmitHandlerVectorOfChar*>(data);
vec->insert(vec->end(), chPtr, chPtr + size);
return size;
}
-cmCTestSubmitHandler::cmCTestSubmitHandler() : HTTPProxy(), FTPProxy()
+cmCTestSubmitHandler::cmCTestSubmitHandler()
+ : HTTPProxy()
+ , FTPProxy()
{
this->Initialize();
}
@@ -153,11 +137,10 @@ cmCTestSubmitHandler::cmCTestSubmitHandler() : HTTPProxy(), FTPProxy()
void cmCTestSubmitHandler::Initialize()
{
// We submit all available parts by default.
- for(cmCTest::Part p = cmCTest::PartStart;
- p != cmCTest::PartCount; p = cmCTest::Part(p+1))
- {
+ for (cmCTest::Part p = cmCTest::PartStart; p != cmCTest::PartCount;
+ p = cmCTest::Part(p + 1)) {
this->SubmitPart[p] = true;
- }
+ }
this->CDash = false;
this->HasWarnings = false;
this->HasErrors = false;
@@ -172,11 +155,11 @@ void cmCTestSubmitHandler::Initialize()
}
bool cmCTestSubmitHandler::SubmitUsingFTP(const std::string& localprefix,
- const std::set<std::string>& files,
- const std::string& remoteprefix,
- const std::string& url)
+ const std::set<std::string>& files,
+ const std::string& remoteprefix,
+ const std::string& url)
{
- CURL *curl;
+ CURL* curl;
CURLcode res;
FILE* ftpfile;
char error_buffer[1024];
@@ -185,28 +168,24 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const std::string& localprefix,
::curl_global_init(CURL_GLOBAL_ALL);
cmCTest::SetOfStrings::const_iterator file;
- for ( file = files.begin(); file != files.end(); ++file )
- {
+ for (file = files.begin(); file != files.end(); ++file) {
/* get a curl handle */
curl = curl_easy_init();
- if(curl)
- {
+ if (curl) {
// Using proxy
- if ( this->FTPProxyType > 0 )
- {
+ if (this->FTPProxyType > 0) {
curl_easy_setopt(curl, CURLOPT_PROXY, this->FTPProxy.c_str());
- switch (this->FTPProxyType)
- {
- case 2:
- curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
- break;
- case 3:
- curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
- break;
- default:
- curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
- }
+ switch (this->FTPProxyType) {
+ case 2:
+ curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
+ break;
+ case 3:
+ curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
+ break;
+ default:
+ curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
}
+ }
// enable uploading
::curl_easy_setopt(curl, CURLOPT_UPLOAD, 1);
@@ -214,128 +193,122 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const std::string& localprefix,
// if there is little to no activity for too long stop submitting
::curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1);
::curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME,
- SUBMIT_TIMEOUT_IN_SECONDS_DEFAULT);
+ SUBMIT_TIMEOUT_IN_SECONDS_DEFAULT);
::curl_easy_setopt(curl, CURLOPT_UPLOAD, 1);
std::string local_file = *file;
- if ( !cmSystemTools::FileExists(local_file.c_str()) )
- {
+ if (!cmSystemTools::FileExists(local_file.c_str())) {
local_file = localprefix + "/" + *file;
- }
- std::string upload_as
- = url + "/" + remoteprefix + cmSystemTools::GetFilenameName(*file);
-
+ }
+ std::string upload_as =
+ url + "/" + remoteprefix + cmSystemTools::GetFilenameName(*file);
- if ( !cmSystemTools::FileExists(local_file.c_str()) )
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE, " Cannot find file: "
- << local_file << std::endl);
+ if (!cmSystemTools::FileExists(local_file.c_str())) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ " Cannot find file: " << local_file << std::endl);
::curl_easy_cleanup(curl);
::curl_global_cleanup();
return false;
- }
+ }
unsigned long filelen = cmSystemTools::FileLength(local_file);
ftpfile = cmsys::SystemTools::Fopen(local_file, "rb");
- *this->LogFile << "\tUpload file: " << local_file << " to "
- << upload_as << std::endl;
+ *this->LogFile << "\tUpload file: " << local_file << " to " << upload_as
+ << std::endl;
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " Upload file: " << local_file << " to " << upload_as << std::endl,
- this->Quiet);
+ " Upload file: " << local_file << " to "
+ << upload_as << std::endl,
+ this->Quiet);
::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
// specify target
- ::curl_easy_setopt(curl,CURLOPT_URL, upload_as.c_str());
+ ::curl_easy_setopt(curl, CURLOPT_URL, upload_as.c_str());
// now specify which file to upload
::curl_easy_setopt(curl, CURLOPT_INFILE, ftpfile);
// and give the size of the upload (optional)
- ::curl_easy_setopt(curl, CURLOPT_INFILESIZE,
- static_cast<long>(filelen));
+ ::curl_easy_setopt(curl, CURLOPT_INFILESIZE, static_cast<long>(filelen));
// and give curl the buffer for errors
::curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &error_buffer);
// specify handler for output
::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
- cmCTestSubmitHandlerWriteMemoryCallback);
+ cmCTestSubmitHandlerWriteMemoryCallback);
::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION,
- cmCTestSubmitHandlerCurlDebugCallback);
+ cmCTestSubmitHandlerCurlDebugCallback);
/* we pass our 'chunk' struct to the callback function */
cmCTestSubmitHandlerVectorOfChar chunk;
cmCTestSubmitHandlerVectorOfChar chunkDebug;
- ::curl_easy_setopt(curl, CURLOPT_FILE, (void *)&chunk);
- ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void *)&chunkDebug);
+ ::curl_easy_setopt(curl, CURLOPT_FILE, (void*)&chunk);
+ ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void*)&chunkDebug);
// Now run off and do what you've been told!
res = ::curl_easy_perform(curl);
- if (!chunk.empty())
- {
+ if (!chunk.empty()) {
cmCTestOptionalLog(this->CTest, DEBUG, "CURL output: ["
- << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
- << std::endl, this->Quiet);
- }
- if (!chunkDebug.empty())
- {
- cmCTestOptionalLog(this->CTest, DEBUG, "CURL debug output: ["
- << cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]"
- << std::endl, this->Quiet);
- }
+ << cmCTestLogWrite(&*chunk.begin(), chunk.size())
+ << "]" << std::endl,
+ this->Quiet);
+ }
+ if (!chunkDebug.empty()) {
+ cmCTestOptionalLog(
+ this->CTest, DEBUG, "CURL debug output: ["
+ << cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]"
+ << std::endl,
+ this->Quiet);
+ }
fclose(ftpfile);
- if ( res )
- {
+ if (res) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, " Error when uploading file: "
+ << local_file << std::endl);
cmCTestLog(this->CTest, ERROR_MESSAGE,
- " Error when uploading file: "
- << local_file << std::endl);
- cmCTestLog(this->CTest, ERROR_MESSAGE, " Error message was: "
- << error_buffer << std::endl);
- *this->LogFile << " Error when uploading file: "
- << local_file
+ " Error message was: " << error_buffer << std::endl);
+ *this->LogFile << " Error when uploading file: " << local_file
<< std::endl
- << " Error message was: "
- << error_buffer << std::endl
+ << " Error message was: " << error_buffer << std::endl
<< " Curl output was: ";
// avoid dereference of empty vector
- if(!chunk.empty())
- {
+ if (!chunk.empty()) {
*this->LogFile << cmCTestLogWrite(&*chunk.begin(), chunk.size());
cmCTestLog(this->CTest, ERROR_MESSAGE, "CURL output: ["
- << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
- << std::endl);
- }
+ << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
+ << std::endl);
+ }
*this->LogFile << std::endl;
::curl_easy_cleanup(curl);
::curl_global_cleanup();
return false;
- }
+ }
// always cleanup
::curl_easy_cleanup(curl);
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " Uploaded: " + local_file << std::endl, this->Quiet);
- }
+ " Uploaded: " + local_file << std::endl,
+ this->Quiet);
}
+ }
::curl_global_cleanup();
return true;
}
// Uploading files is simpler
bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
- const std::set<std::string>& files,
- const std::string& remoteprefix,
- const std::string& url)
+ const std::set<std::string>& files,
+ const std::string& remoteprefix,
+ const std::string& url)
{
- CURL *curl;
+ CURL* curl;
CURLcode res;
FILE* ftpfile;
char error_buffer[1024];
- struct curl_slist *headers = ::curl_slist_append(NULL,
- "Content-Type: text/xml");
+ struct curl_slist* headers =
+ ::curl_slist_append(NULL, "Content-Type: text/xml");
/* In windows, this will init the winsock stuff */
::curl_global_init(CURL_GLOBAL_ALL);
@@ -345,65 +318,56 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
cmSystemTools::ExpandListArgument(curlopt, args);
bool verifyPeerOff = false;
bool verifyHostOff = false;
- for( std::vector<std::string>::iterator i = args.begin();
- i != args.end(); ++i)
- {
- if(*i == "CURLOPT_SSL_VERIFYPEER_OFF")
- {
+ for (std::vector<std::string>::iterator i = args.begin(); i != args.end();
+ ++i) {
+ if (*i == "CURLOPT_SSL_VERIFYPEER_OFF") {
verifyPeerOff = true;
- }
- if(*i == "CURLOPT_SSL_VERIFYHOST_OFF")
- {
+ }
+ if (*i == "CURLOPT_SSL_VERIFYHOST_OFF") {
verifyHostOff = true;
- }
}
+ }
std::string::size_type kk;
cmCTest::SetOfStrings::const_iterator file;
- for ( file = files.begin(); file != files.end(); ++file )
- {
+ for (file = files.begin(); file != files.end(); ++file) {
/* get a curl handle */
curl = curl_easy_init();
- if(curl)
- {
+ if (curl) {
cmCurlSetCAInfo(curl);
- if(verifyPeerOff)
- {
+ if (verifyPeerOff) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " Set CURLOPT_SSL_VERIFYPEER to off\n", this->Quiet);
+ " Set CURLOPT_SSL_VERIFYPEER to off\n",
+ this->Quiet);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
- }
- if(verifyHostOff)
- {
+ }
+ if (verifyHostOff) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " Set CURLOPT_SSL_VERIFYHOST to off\n", this->Quiet);
+ " Set CURLOPT_SSL_VERIFYHOST to off\n",
+ this->Quiet);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);
- }
+ }
// Using proxy
- if ( this->HTTPProxyType > 0 )
- {
+ if (this->HTTPProxyType > 0) {
curl_easy_setopt(curl, CURLOPT_PROXY, this->HTTPProxy.c_str());
- switch (this->HTTPProxyType)
- {
- case 2:
- curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
- break;
- case 3:
- curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
- break;
- default:
- curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
- if (!this->HTTPProxyAuth.empty())
- {
- curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD,
- this->HTTPProxyAuth.c_str());
+ switch (this->HTTPProxyType) {
+ case 2:
+ curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
+ break;
+ case 3:
+ curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
+ break;
+ default:
+ curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
+ if (!this->HTTPProxyAuth.empty()) {
+ curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD,
+ this->HTTPProxyAuth.c_str());
}
- }
}
- if(this->CTest->ShouldUseHTTP10())
- {
+ }
+ if (this->CTest->ShouldUseHTTP10()) {
curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
- }
+ }
// enable HTTP ERROR parsing
curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
/* enable uploading */
@@ -412,7 +376,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
// if there is little to no activity for too long stop submitting
::curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1);
::curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME,
- SUBMIT_TIMEOUT_IN_SECONDS_DEFAULT);
+ SUBMIT_TIMEOUT_IN_SECONDS_DEFAULT);
/* HTTP PUT please */
::curl_easy_setopt(curl, CURLOPT_PUT, 1);
@@ -422,157 +386,158 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
::curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
std::string local_file = *file;
- if ( !cmSystemTools::FileExists(local_file.c_str()) )
- {
+ if (!cmSystemTools::FileExists(local_file.c_str())) {
local_file = localprefix + "/" + *file;
- }
- std::string remote_file
- = remoteprefix + cmSystemTools::GetFilenameName(*file);
+ }
+ std::string remote_file =
+ remoteprefix + cmSystemTools::GetFilenameName(*file);
*this->LogFile << "\tUpload file: " << local_file << " to "
- << remote_file << std::endl;
+ << remote_file << std::endl;
std::string ofile = "";
- for ( kk = 0; kk < remote_file.size(); kk ++ )
- {
+ for (kk = 0; kk < remote_file.size(); kk++) {
char c = remote_file[kk];
char hexCh[4] = { 0, 0, 0, 0 };
hexCh[0] = c;
- switch ( c )
- {
- case '+':
- case '?':
- case '/':
- case '\\':
- case '&':
- case ' ':
- case '=':
- case '%':
- sprintf(hexCh, "%%%02X", (int)c);
- ofile.append(hexCh);
- break;
- default:
- ofile.append(hexCh);
- }
+ switch (c) {
+ case '+':
+ case '?':
+ case '/':
+ case '\\':
+ case '&':
+ case ' ':
+ case '=':
+ case '%':
+ sprintf(hexCh, "%%%02X", (int)c);
+ ofile.append(hexCh);
+ break;
+ default:
+ ofile.append(hexCh);
}
- std::string upload_as
- = url + ((url.find("?",0) == std::string::npos) ? "?" : "&")
- + "FileName=" + ofile;
+ }
+ std::string upload_as = url +
+ ((url.find("?", 0) == std::string::npos) ? "?" : "&") + "FileName=" +
+ ofile;
upload_as += "&MD5=";
- if(cmSystemTools::IsOn(this->GetOption("InternalTest")))
- {
+ if (cmSystemTools::IsOn(this->GetOption("InternalTest"))) {
upload_as += "bad_md5sum";
- }
- else
- {
+ } else {
char md5[33];
cmSystemTools::ComputeFileMD5(local_file, md5);
md5[32] = 0;
upload_as += md5;
- }
+ }
- if( !cmSystemTools::FileExists(local_file.c_str()) )
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE, " Cannot find file: "
- << local_file << std::endl);
+ if (!cmSystemTools::FileExists(local_file.c_str())) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ " Cannot find file: " << local_file << std::endl);
::curl_easy_cleanup(curl);
::curl_slist_free_all(headers);
::curl_global_cleanup();
return false;
- }
+ }
unsigned long filelen = cmSystemTools::FileLength(local_file);
ftpfile = cmsys::SystemTools::Fopen(local_file, "rb");
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " Upload file: " << local_file << " to "
- << upload_as << " Size: " << filelen << std::endl, this->Quiet);
+ " Upload file: " << local_file << " to "
+ << upload_as << " Size: "
+ << filelen << std::endl,
+ this->Quiet);
// specify target
- ::curl_easy_setopt(curl,CURLOPT_URL, upload_as.c_str());
+ ::curl_easy_setopt(curl, CURLOPT_URL, upload_as.c_str());
// now specify which file to upload
::curl_easy_setopt(curl, CURLOPT_INFILE, ftpfile);
// and give the size of the upload (optional)
- ::curl_easy_setopt(curl, CURLOPT_INFILESIZE,
- static_cast<long>(filelen));
+ ::curl_easy_setopt(curl, CURLOPT_INFILESIZE, static_cast<long>(filelen));
// and give curl the buffer for errors
::curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &error_buffer);
// specify handler for output
::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
- cmCTestSubmitHandlerWriteMemoryCallback);
+ cmCTestSubmitHandlerWriteMemoryCallback);
::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION,
- cmCTestSubmitHandlerCurlDebugCallback);
+ cmCTestSubmitHandlerCurlDebugCallback);
/* we pass our 'chunk' struct to the callback function */
cmCTestSubmitHandlerVectorOfChar chunk;
cmCTestSubmitHandlerVectorOfChar chunkDebug;
- ::curl_easy_setopt(curl, CURLOPT_FILE, (void *)&chunk);
- ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void *)&chunkDebug);
+ ::curl_easy_setopt(curl, CURLOPT_FILE, (void*)&chunk);
+ ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void*)&chunkDebug);
// Now run off and do what you've been told!
res = ::curl_easy_perform(curl);
- if(cmSystemTools::IsOn(this->GetOption("InternalTest")) &&
- cmSystemTools::VersionCompare(cmSystemTools::OP_LESS,
- this->CTest->GetCDashVersion().c_str(), "1.7"))
- {
+ if (cmSystemTools::IsOn(this->GetOption("InternalTest")) &&
+ cmSystemTools::VersionCompare(cmSystemTools::OP_LESS,
+ this->CTest->GetCDashVersion().c_str(),
+ "1.7")) {
// mock failure output for internal test case
- std::string mock_output = "<cdash version=\"1.7.0\">\n"
+ std::string mock_output =
+ "<cdash version=\"1.7.0\">\n"
" <status>ERROR</status>\n"
" <message>Checksum failed for file.</message>\n"
"</cdash>\n";
chunk.clear();
chunk.assign(mock_output.begin(), mock_output.end());
- }
+ }
- if (!chunk.empty())
- {
+ if (!chunk.empty()) {
cmCTestOptionalLog(this->CTest, DEBUG, "CURL output: ["
- << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
- << std::endl, this->Quiet);
+ << cmCTestLogWrite(&*chunk.begin(), chunk.size())
+ << "]" << std::endl,
+ this->Quiet);
this->ParseResponse(chunk);
- }
- if (!chunkDebug.empty())
- {
- cmCTestOptionalLog(this->CTest, DEBUG, "CURL debug output: ["
- << cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]"
- << std::endl, this->Quiet);
- }
+ }
+ if (!chunkDebug.empty()) {
+ cmCTestOptionalLog(
+ this->CTest, DEBUG, "CURL debug output: ["
+ << cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]"
+ << std::endl,
+ this->Quiet);
+ }
// If curl failed for any reason, or checksum fails, wait and retry
//
- if(res != CURLE_OK || this->HasErrors)
- {
- std::string retryDelay = this->GetOption("RetryDelay") == NULL ?
- "" : this->GetOption("RetryDelay");
- std::string retryCount = this->GetOption("RetryCount") == NULL ?
- "" : this->GetOption("RetryCount");
-
- int delay = retryDelay == "" ? atoi(this->CTest->GetCTestConfiguration(
- "CTestSubmitRetryDelay").c_str()) : atoi(retryDelay.c_str());
- int count = retryCount == "" ? atoi(this->CTest->GetCTestConfiguration(
- "CTestSubmitRetryCount").c_str()) : atoi(retryCount.c_str());
-
- for(int i = 0; i < count; i++)
- {
+ if (res != CURLE_OK || this->HasErrors) {
+ std::string retryDelay = this->GetOption("RetryDelay") == NULL
+ ? ""
+ : this->GetOption("RetryDelay");
+ std::string retryCount = this->GetOption("RetryCount") == NULL
+ ? ""
+ : this->GetOption("RetryCount");
+
+ int delay = retryDelay == ""
+ ? atoi(this->CTest->GetCTestConfiguration("CTestSubmitRetryDelay")
+ .c_str())
+ : atoi(retryDelay.c_str());
+ int count = retryCount == ""
+ ? atoi(this->CTest->GetCTestConfiguration("CTestSubmitRetryCount")
+ .c_str())
+ : atoi(retryCount.c_str());
+
+ for (int i = 0; i < count; i++) {
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " Submit failed, waiting " << delay << " seconds...\n",
- this->Quiet);
+ " Submit failed, waiting " << delay
+ << " seconds...\n",
+ this->Quiet);
double stop = cmSystemTools::GetTime() + delay;
- while(cmSystemTools::GetTime() < stop)
- {
+ while (cmSystemTools::GetTime() < stop) {
cmSystemTools::Delay(100);
- }
+ }
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " Retry submission: Attempt " << (i + 1) << " of "
- << count << std::endl, this->Quiet);
+ " Retry submission: Attempt "
+ << (i + 1) << " of " << count << std::endl,
+ this->Quiet);
::fclose(ftpfile);
ftpfile = cmsys::SystemTools::Fopen(local_file, "rb");
@@ -584,135 +549,121 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
res = ::curl_easy_perform(curl);
- if (!chunk.empty())
- {
- cmCTestOptionalLog(this->CTest, DEBUG, "CURL output: ["
- << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
- << std::endl, this->Quiet);
+ if (!chunk.empty()) {
+ cmCTestOptionalLog(
+ this->CTest, DEBUG, "CURL output: ["
+ << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
+ << std::endl,
+ this->Quiet);
this->ParseResponse(chunk);
- }
+ }
- if(res == CURLE_OK && !this->HasErrors)
- {
+ if (res == CURLE_OK && !this->HasErrors) {
break;
- }
}
}
+ }
fclose(ftpfile);
- if ( res )
- {
+ if (res) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, " Error when uploading file: "
+ << local_file << std::endl);
cmCTestLog(this->CTest, ERROR_MESSAGE,
- " Error when uploading file: "
- << local_file << std::endl);
- cmCTestLog(this->CTest, ERROR_MESSAGE, " Error message was: "
- << error_buffer << std::endl);
- *this->LogFile << " Error when uploading file: "
- << local_file
+ " Error message was: " << error_buffer << std::endl);
+ *this->LogFile << " Error when uploading file: " << local_file
<< std::endl
<< " Error message was: " << error_buffer
<< std::endl;
// avoid deref of begin for zero size array
- if(!chunk.empty())
- {
+ if (!chunk.empty()) {
*this->LogFile << " Curl output was: "
<< cmCTestLogWrite(&*chunk.begin(), chunk.size())
<< std::endl;
cmCTestLog(this->CTest, ERROR_MESSAGE, "CURL output: ["
- << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
- << std::endl);
- }
+ << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
+ << std::endl);
+ }
::curl_easy_cleanup(curl);
::curl_slist_free_all(headers);
::curl_global_cleanup();
return false;
- }
+ }
// always cleanup
::curl_easy_cleanup(curl);
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " Uploaded: " + local_file << std::endl, this->Quiet);
- }
+ " Uploaded: " + local_file << std::endl,
+ this->Quiet);
}
+ }
::curl_slist_free_all(headers);
::curl_global_cleanup();
return true;
}
-void cmCTestSubmitHandler
-::ParseResponse(cmCTestSubmitHandlerVectorOfChar chunk)
+void cmCTestSubmitHandler::ParseResponse(
+ cmCTestSubmitHandlerVectorOfChar chunk)
{
std::string output = "";
output.append(chunk.begin(), chunk.end());
- if(output.find("<cdash") != output.npos)
- {
+ if (output.find("<cdash") != output.npos) {
ResponseParser parser;
parser.Parse(output.c_str());
- if(parser.Status != ResponseParser::STATUS_OK)
- {
+ if (parser.Status != ResponseParser::STATUS_OK) {
this->HasErrors = true;
- cmCTestLog(this->CTest, HANDLER_OUTPUT, " Submission failed: " <<
- parser.Message << std::endl);
+ cmCTestLog(this->CTest, HANDLER_OUTPUT,
+ " Submission failed: " << parser.Message << std::endl);
return;
- }
}
+ }
output = cmSystemTools::UpperCase(output);
- if(output.find("WARNING") != std::string::npos)
- {
+ if (output.find("WARNING") != std::string::npos) {
this->HasWarnings = true;
- }
- if(output.find("ERROR") != std::string::npos)
- {
+ }
+ if (output.find("ERROR") != std::string::npos) {
this->HasErrors = true;
- }
+ }
- if(this->HasWarnings || this->HasErrors)
- {
- cmCTestLog(this->CTest, HANDLER_OUTPUT, " Server Response:\n" <<
- cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "\n");
- }
+ if (this->HasWarnings || this->HasErrors) {
+ cmCTestLog(this->CTest, HANDLER_OUTPUT, " Server Response:\n"
+ << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "\n");
+ }
}
-bool cmCTestSubmitHandler::TriggerUsingHTTP(
- const std::set<std::string>& files,
- const std::string& remoteprefix,
- const std::string& url)
+bool cmCTestSubmitHandler::TriggerUsingHTTP(const std::set<std::string>& files,
+ const std::string& remoteprefix,
+ const std::string& url)
{
- CURL *curl;
+ CURL* curl;
char error_buffer[1024];
/* In windows, this will init the winsock stuff */
::curl_global_init(CURL_GLOBAL_ALL);
cmCTest::SetOfStrings::const_iterator file;
- for ( file = files.begin(); file != files.end(); ++file )
- {
+ for (file = files.begin(); file != files.end(); ++file) {
/* get a curl handle */
curl = curl_easy_init();
- if(curl)
- {
+ if (curl) {
// Using proxy
- if ( this->HTTPProxyType > 0 )
- {
+ if (this->HTTPProxyType > 0) {
curl_easy_setopt(curl, CURLOPT_PROXY, this->HTTPProxy.c_str());
- switch (this->HTTPProxyType)
- {
- case 2:
- curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
- break;
- case 3:
- curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
- break;
- default:
- curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
- if (!this->HTTPProxyAuth.empty())
- {
- curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD,
- this->HTTPProxyAuth.c_str());
+ switch (this->HTTPProxyType) {
+ case 2:
+ curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
+ break;
+ case 3:
+ curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
+ break;
+ default:
+ curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
+ if (!this->HTTPProxyAuth.empty()) {
+ curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD,
+ this->HTTPProxyAuth.c_str());
}
- }
}
+ }
::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
@@ -721,111 +672,105 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP(
// specify handler for output
::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
- cmCTestSubmitHandlerWriteMemoryCallback);
+ cmCTestSubmitHandlerWriteMemoryCallback);
::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION,
- cmCTestSubmitHandlerCurlDebugCallback);
+ cmCTestSubmitHandlerCurlDebugCallback);
/* we pass our 'chunk' struct to the callback function */
cmCTestSubmitHandlerVectorOfChar chunk;
cmCTestSubmitHandlerVectorOfChar chunkDebug;
- ::curl_easy_setopt(curl, CURLOPT_FILE, (void *)&chunk);
- ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void *)&chunkDebug);
+ ::curl_easy_setopt(curl, CURLOPT_FILE, (void*)&chunk);
+ ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void*)&chunkDebug);
- std::string rfile
- = remoteprefix + cmSystemTools::GetFilenameName(*file);
+ std::string rfile = remoteprefix + cmSystemTools::GetFilenameName(*file);
std::string ofile = "";
std::string::iterator kk;
- for ( kk = rfile.begin(); kk < rfile.end(); ++ kk)
- {
+ for (kk = rfile.begin(); kk < rfile.end(); ++kk) {
char c = *kk;
char hexCh[4] = { 0, 0, 0, 0 };
hexCh[0] = c;
- switch ( c )
- {
- case '+':
- case '?':
- case '/':
- case '\\':
- case '&':
- case ' ':
- case '=':
- case '%':
- sprintf(hexCh, "%%%02X", (int)c);
- ofile.append(hexCh);
- break;
- default:
- ofile.append(hexCh);
- }
+ switch (c) {
+ case '+':
+ case '?':
+ case '/':
+ case '\\':
+ case '&':
+ case ' ':
+ case '=':
+ case '%':
+ sprintf(hexCh, "%%%02X", (int)c);
+ ofile.append(hexCh);
+ break;
+ default:
+ ofile.append(hexCh);
}
- std::string turl
- = url + ((url.find("?",0) == std::string::npos) ? "?" : "&")
- + "xmlfile=" + ofile;
+ }
+ std::string turl = url +
+ ((url.find("?", 0) == std::string::npos) ? "?" : "&") + "xmlfile=" +
+ ofile;
*this->LogFile << "Trigger url: " << turl << std::endl;
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " Trigger url: " << turl << std::endl, this->Quiet);
+ " Trigger url: " << turl << std::endl, this->Quiet);
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_easy_setopt(curl, CURLOPT_URL, turl.c_str());
- if ( curl_easy_perform(curl) )
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE, " Error when triggering: "
- << turl << std::endl);
- cmCTestLog(this->CTest, ERROR_MESSAGE, " Error message was: "
- << error_buffer << std::endl);
+ if (curl_easy_perform(curl)) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ " Error when triggering: " << turl << std::endl);
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ " Error message was: " << error_buffer << std::endl);
*this->LogFile << "\tTriggering failed with error: " << error_buffer
<< std::endl
<< " Error message was: " << error_buffer
<< std::endl;
- if(!chunk.empty())
- {
- *this->LogFile
- << " Curl output was: "
- << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << std::endl;
+ if (!chunk.empty()) {
+ *this->LogFile << " Curl output was: "
+ << cmCTestLogWrite(&*chunk.begin(), chunk.size())
+ << std::endl;
cmCTestLog(this->CTest, ERROR_MESSAGE, "CURL output: ["
- << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
- << std::endl);
- }
+ << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
+ << std::endl);
+ }
::curl_easy_cleanup(curl);
::curl_global_cleanup();
return false;
- }
+ }
- if (!chunk.empty())
- {
+ if (!chunk.empty()) {
cmCTestOptionalLog(this->CTest, DEBUG, "CURL output: ["
- << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
- << std::endl, this->Quiet);
- }
- if (!chunkDebug.empty())
- {
- cmCTestOptionalLog(this->CTest, DEBUG, "CURL debug output: ["
- << cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size())
- << "]" << std::endl, this->Quiet);
- }
+ << cmCTestLogWrite(&*chunk.begin(), chunk.size())
+ << "]" << std::endl,
+ this->Quiet);
+ }
+ if (!chunkDebug.empty()) {
+ cmCTestOptionalLog(
+ this->CTest, DEBUG, "CURL debug output: ["
+ << cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]"
+ << std::endl,
+ this->Quiet);
+ }
// always cleanup
::curl_easy_cleanup(curl);
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl,
- this->Quiet);
- }
+ this->Quiet);
}
+ }
::curl_global_cleanup();
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " Dart server triggered..."
- << std::endl, this->Quiet);
+ cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+ " Dart server triggered..." << std::endl, this->Quiet);
return true;
}
-bool cmCTestSubmitHandler::SubmitUsingSCP(
- const std::string& scp_command,
- const std::string& localprefix,
- const std::set<std::string>& files,
- const std::string& remoteprefix,
- const std::string& url)
+bool cmCTestSubmitHandler::SubmitUsingSCP(const std::string& scp_command,
+ const std::string& localprefix,
+ const std::set<std::string>& files,
+ const std::string& remoteprefix,
+ const std::string& url)
{
- if ( scp_command.empty() || localprefix.empty() ||
- files.empty() || remoteprefix.empty() || url.empty() )
- {
+ if (scp_command.empty() || localprefix.empty() || files.empty() ||
+ remoteprefix.empty() || url.empty()) {
return 0;
- }
+ }
std::vector<const char*> argv;
argv.push_back(scp_command.c_str()); // Scp command
@@ -835,13 +780,12 @@ bool cmCTestSubmitHandler::SubmitUsingSCP(
cmsysProcess* cp = cmsysProcess_New();
cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
- //cmsysProcess_SetTimeout(cp, timeout);
+ // cmsysProcess_SetTimeout(cp, timeout);
int problems = 0;
cmCTest::SetOfStrings::const_iterator file;
- for ( file = files.begin(); file != files.end(); ++file )
- {
+ for (file = files.begin(); file != files.end(); ++file) {
int retVal;
std::string lfname = localprefix;
@@ -851,79 +795,69 @@ bool cmCTestSubmitHandler::SubmitUsingSCP(
argv[1] = lfname.c_str();
std::string rfname = url + "/" + remoteprefix + *file;
argv[2] = rfname.c_str();
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Execute \"" << argv[0] << "\" \"" << argv[1] << "\" \""
- << argv[2] << "\"" << std::endl, this->Quiet);
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Execute \""
+ << argv[0] << "\" \"" << argv[1] << "\" \"" << argv[2]
+ << "\"" << std::endl,
+ this->Quiet);
*this->LogFile << "Execute \"" << argv[0] << "\" \"" << argv[1] << "\" \""
- << argv[2] << "\"" << std::endl;
+ << argv[2] << "\"" << std::endl;
cmsysProcess_SetCommand(cp, &*argv.begin());
cmsysProcess_Execute(cp);
char* data;
int length;
- while(cmsysProcess_WaitForData(cp, &data, &length, 0))
- {
+ while (cmsysProcess_WaitForData(cp, &data, &length, 0)) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- cmCTestLogWrite(data, length), this->Quiet);
- }
+ cmCTestLogWrite(data, length), this->Quiet);
+ }
cmsysProcess_WaitForExit(cp, 0);
int result = cmsysProcess_GetState(cp);
- if(result == cmsysProcess_State_Exited)
- {
+ if (result == cmsysProcess_State_Exited) {
retVal = cmsysProcess_GetExitValue(cp);
- if ( retVal != 0 )
- {
+ if (retVal != 0) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "\tSCP returned: " << retVal << std::endl, this->Quiet);
+ "\tSCP returned: " << retVal << std::endl,
+ this->Quiet);
*this->LogFile << "\tSCP returned: " << retVal << std::endl;
- problems ++;
- }
+ problems++;
}
- else if(result == cmsysProcess_State_Exception)
- {
+ } else if (result == cmsysProcess_State_Exception) {
retVal = cmsysProcess_GetExitException(cp);
- cmCTestLog(this->CTest, ERROR_MESSAGE, "\tThere was an exception: "
- << retVal << std::endl);
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "\tThere was an exception: " << retVal << std::endl);
*this->LogFile << "\tThere was an exception: " << retVal << std::endl;
- problems ++;
- }
- else if(result == cmsysProcess_State_Expired)
- {
+ problems++;
+ } else if (result == cmsysProcess_State_Expired) {
cmCTestLog(this->CTest, ERROR_MESSAGE, "\tThere was a timeout"
- << std::endl);
+ << std::endl);
*this->LogFile << "\tThere was a timeout" << std::endl;
- problems ++;
- }
- else if(result == cmsysProcess_State_Error)
- {
+ problems++;
+ } else if (result == cmsysProcess_State_Error) {
cmCTestLog(this->CTest, ERROR_MESSAGE, "\tError executing SCP: "
- << cmsysProcess_GetErrorString(cp) << std::endl);
+ << cmsysProcess_GetErrorString(cp) << std::endl);
*this->LogFile << "\tError executing SCP: "
- << cmsysProcess_GetErrorString(cp) << std::endl;
- problems ++;
- }
+ << cmsysProcess_GetErrorString(cp) << std::endl;
+ problems++;
}
+ }
cmsysProcess_Delete(cp);
- if ( problems )
- {
+ if (problems) {
return false;
- }
+ }
return true;
}
-bool cmCTestSubmitHandler::SubmitUsingCP(
- const std::string& localprefix,
- const std::set<std::string>& files,
- const std::string& remoteprefix,
- const std::string& destination)
+bool cmCTestSubmitHandler::SubmitUsingCP(const std::string& localprefix,
+ const std::set<std::string>& files,
+ const std::string& remoteprefix,
+ const std::string& destination)
{
- if ( localprefix.empty() ||
- files.empty() || remoteprefix.empty() || destination.empty() )
- {
+ if (localprefix.empty() || files.empty() || remoteprefix.empty() ||
+ destination.empty()) {
/* clang-format off */
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Missing arguments for submit via cp:\n"
@@ -933,36 +867,32 @@ bool cmCTestSubmitHandler::SubmitUsingCP(
<< "\tdestination: " << destination << std::endl);
/* clang-format on */
return 0;
- }
+ }
cmCTest::SetOfStrings::const_iterator file;
bool problems = false;
- for ( file = files.begin(); file != files.end(); ++file )
- {
+ for (file = files.begin(); file != files.end(); ++file) {
std::string lfname = localprefix;
cmSystemTools::ConvertToUnixSlashes(lfname);
lfname += "/" + *file;
std::string rfname = destination + "/" + remoteprefix + *file;
cmSystemTools::CopyFileAlways(lfname, rfname);
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Copy file: "
- << lfname << " to "
- << rfname << std::endl, this->Quiet);
- }
+ << lfname << " to " << rfname << std::endl,
+ this->Quiet);
+ }
std::string tagDoneFile = destination + "/" + remoteprefix + "DONE";
cmSystemTools::Touch(tagDoneFile, true);
- if ( problems )
- {
+ if (problems) {
return false;
- }
+ }
return true;
}
-
#if defined(CTEST_USE_XMLRPC)
-bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const std::string& localprefix,
- const std::set<std::string>& files,
- const std::string& remoteprefix,
- const std::string& url)
+bool cmCTestSubmitHandler::SubmitUsingXMLRPC(
+ const std::string& localprefix, const std::set<std::string>& files,
+ const std::string& remoteprefix, const std::string& url)
{
xmlrpc_env env;
char ctestString[] = "CTest";
@@ -979,76 +909,72 @@ bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const std::string& localprefix,
/* Call the famous server at UserLand. */
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " Submitting to: "
- << realURL.c_str() << " (" << remoteprefix.c_str() << ")" << std::endl,
- this->Quiet);
+ << realURL.c_str() << " (" << remoteprefix.c_str()
+ << ")" << std::endl,
+ this->Quiet);
cmCTest::SetOfStrings::const_iterator file;
- for ( file = files.begin(); file != files.end(); ++file )
- {
- xmlrpc_value *result;
+ for (file = files.begin(); file != files.end(); ++file) {
+ xmlrpc_value* result;
std::string local_file = *file;
- if ( !cmSystemTools::FileExists(local_file.c_str()) )
- {
+ if (!cmSystemTools::FileExists(local_file.c_str())) {
local_file = localprefix + "/" + *file;
- }
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " Submit file: "
- << local_file.c_str() << std::endl, this->Quiet);
+ }
+ cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+ " Submit file: " << local_file.c_str() << std::endl,
+ this->Quiet);
struct stat st;
- if ( ::stat(local_file.c_str(), &st) )
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE, " Cannot find file: "
- << local_file.c_str() << std::endl);
+ if (::stat(local_file.c_str(), &st)) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ " Cannot find file: " << local_file.c_str() << std::endl);
return false;
- }
+ }
// off_t can be bigger than size_t. fread takes size_t.
// make sure the file is not too big.
- if(static_cast<off_t>(static_cast<size_t>(st.st_size)) !=
- static_cast<off_t>(st.st_size))
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE, " File too big: "
- << local_file.c_str() << std::endl);
+ if (static_cast<off_t>(static_cast<size_t>(st.st_size)) !=
+ static_cast<off_t>(st.st_size)) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ " File too big: " << local_file.c_str() << std::endl);
return false;
- }
+ }
size_t fileSize = static_cast<size_t>(st.st_size);
FILE* fp = cmsys::SystemTools::Fopen(local_file.c_str(), "rb");
- if ( !fp )
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE, " Cannot open file: "
- << local_file.c_str() << std::endl);
+ if (!fp) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ " Cannot open file: " << local_file.c_str() << std::endl);
return false;
- }
+ }
- unsigned char *fileBuffer = new unsigned char[fileSize];
- if ( fread(fileBuffer, 1, fileSize, fp) != fileSize )
- {
- delete [] fileBuffer;
+ unsigned char* fileBuffer = new unsigned char[fileSize];
+ if (fread(fileBuffer, 1, fileSize, fp) != fileSize) {
+ delete[] fileBuffer;
fclose(fp);
- cmCTestLog(this->CTest, ERROR_MESSAGE, " Cannot read file: "
- << local_file.c_str() << std::endl);
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ " Cannot read file: " << local_file.c_str() << std::endl);
return false;
- }
+ }
fclose(fp);
char remoteCommand[] = "Submit.put";
char* pRealURL = const_cast<char*>(realURL.c_str());
- result = xmlrpc_client_call(&env, pRealURL, remoteCommand,
- "(6)", fileBuffer, (xmlrpc_int32)fileSize );
+ result = xmlrpc_client_call(&env, pRealURL, remoteCommand, "(6)",
+ fileBuffer, (xmlrpc_int32)fileSize);
- delete [] fileBuffer;
+ delete[] fileBuffer;
- if ( env.fault_occurred )
- {
+ if (env.fault_occurred) {
cmCTestLog(this->CTest, ERROR_MESSAGE, " Submission problem: "
- << env.fault_string << " (" << env.fault_code << ")" << std::endl);
+ << env.fault_string << " (" << env.fault_code << ")"
+ << std::endl);
xmlrpc_env_clean(&env);
xmlrpc_client_cleanup();
return false;
- }
+ }
/* Dispose of our result value. */
xmlrpc_DECREF(result);
- }
+ }
/* Clean up our error-handling environment. */
xmlrpc_env_clean(&env);
@@ -1073,40 +999,33 @@ void cmCTestSubmitHandler::ConstructCDashURL(std::string& dropMethod,
dropMethod = this->CTest->GetCTestConfiguration("DropMethod");
url = dropMethod;
url += "://";
- if ( this->CTest->GetCTestConfiguration("DropSiteUser").size() > 0 )
- {
+ if (this->CTest->GetCTestConfiguration("DropSiteUser").size() > 0) {
url += this->CTest->GetCTestConfiguration("DropSiteUser");
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- this->CTest->GetCTestConfiguration("DropSiteUser").c_str(),
- this->Quiet);
- if ( this->CTest->GetCTestConfiguration("DropSitePassword").size() > 0 )
- {
+ cmCTestOptionalLog(
+ this->CTest, HANDLER_OUTPUT,
+ this->CTest->GetCTestConfiguration("DropSiteUser").c_str(), this->Quiet);
+ if (this->CTest->GetCTestConfiguration("DropSitePassword").size() > 0) {
url += ":" + this->CTest->GetCTestConfiguration("DropSitePassword");
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, ":******",
- this->Quiet);
- }
- url += "@";
+ cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, ":******", this->Quiet);
}
+ url += "@";
+ }
url += this->CTest->GetCTestConfiguration("DropSite") +
this->CTest->GetCTestConfiguration("DropLocation");
}
-
int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file,
std::string const& typeString)
{
- if (file.empty())
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Upload file not specified\n");
+ if (file.empty()) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "Upload file not specified\n");
return -1;
- }
- if (!cmSystemTools::FileExists(file))
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Upload file not found: '" << file << "'\n");
+ }
+ if (!cmSystemTools::FileExists(file)) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "Upload file not found: '"
+ << file << "'\n");
return -1;
- }
+ }
cmCTestCurl curl(this->CTest);
std::string curlopt(this->CTest->GetCTestConfiguration("CurlOptions"));
std::vector<std::string> args;
@@ -1117,13 +1036,12 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file,
std::string url;
this->ConstructCDashURL(dropMethod, url);
std::string::size_type pos = url.find("submit.php?");
- url = url.substr(0, pos+10);
- if ( ! (dropMethod == "http" || dropMethod == "https" ) )
- {
+ url = url.substr(0, pos + 10);
+ if (!(dropMethod == "http" || dropMethod == "https")) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Only http and https are supported for CDASH_UPLOAD\n");
return -1;
- }
+ }
char md5sum[33];
md5sum[32] = 0;
cmSystemTools::ComputeFileMD5(file, md5sum);
@@ -1133,75 +1051,68 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file,
// a "&subproject=subprojectname" to the first POST.
cmCTestScriptHandler* ch =
static_cast<cmCTestScriptHandler*>(this->CTest->GetHandler("script"));
- cmake* cm = ch->GetCMake();
+ cmake* cm = ch->GetCMake();
const char* subproject = cm->GetState()->GetGlobalProperty("SubProject");
// TODO: Encode values for a URL instead of trusting caller.
std::ostringstream str;
str << "project="
<< curl.Escape(this->CTest->GetCTestConfiguration("ProjectName")) << "&";
- if(subproject)
- {
+ if (subproject) {
str << "subproject=" << curl.Escape(subproject) << "&";
- }
+ }
str << "stamp=" << curl.Escape(this->CTest->GetCurrentTag()) << "-"
<< curl.Escape(this->CTest->GetTestModelString()) << "&"
<< "model=" << curl.Escape(this->CTest->GetTestModelString()) << "&"
<< "build="
<< curl.Escape(this->CTest->GetCTestConfiguration("BuildName")) << "&"
- << "site="
- << curl.Escape(this->CTest->GetCTestConfiguration("Site")) << "&"
- << "track="
- << curl.Escape(this->CTest->GetTestModelString()) << "&"
+ << "site=" << curl.Escape(this->CTest->GetCTestConfiguration("Site"))
+ << "&"
+ << "track=" << curl.Escape(this->CTest->GetTestModelString()) << "&"
<< "starttime=" << (int)cmSystemTools::GetTime() << "&"
<< "endtime=" << (int)cmSystemTools::GetTime() << "&"
<< "datafilesmd5[0]=" << md5sum << "&"
<< "type=" << curl.Escape(typeString);
std::string fields = str.str();
- cmCTestOptionalLog(this->CTest, DEBUG, "fields: " << fields << "\nurl:"
- << url << "\nfile: " << file << "\n", this->Quiet);
+ cmCTestOptionalLog(this->CTest, DEBUG,
+ "fields: " << fields << "\nurl:" << url
+ << "\nfile: " << file << "\n",
+ this->Quiet);
std::string response;
- if(!curl.HttpRequest(url, fields, response))
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Error in HttpRequest\n" << response);
+ if (!curl.HttpRequest(url, fields, response)) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "Error in HttpRequest\n"
+ << response);
return -1;
- }
+ }
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Request upload response: [" << response << "]\n", this->Quiet);
+ "Request upload response: [" << response << "]\n",
+ this->Quiet);
Json::Value json;
Json::Reader reader;
- if(!reader.parse(response, json))
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "error parsing json string [" << response << "]\n"
- << reader.getFormattedErrorMessages() << "\n");
+ if (!reader.parse(response, json)) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "error parsing json string ["
+ << response << "]\n"
+ << reader.getFormattedErrorMessages() << "\n");
return -1;
- }
- if(json["status"].asInt() != 0)
- {
+ }
+ if (json["status"].asInt() != 0) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Bad status returned from CDash: "
- << json["status"].asInt());
+ "Bad status returned from CDash: " << json["status"].asInt());
return -1;
- }
- if(json["datafilesmd5"].isArray())
- {
+ }
+ if (json["datafilesmd5"].isArray()) {
int datares = json["datafilesmd5"][0].asInt();
- if(datares == 1)
- {
+ if (datares == 1) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "File already exists on CDash, skip upload " << file << "\n",
- this->Quiet);
+ "File already exists on CDash, skip upload " << file
+ << "\n",
+ this->Quiet);
return 0;
- }
}
- else
- {
+ } else {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "bad datafilesmd5 value in response "
- << response << "\n");
+ "bad datafilesmd5 value in response " << response << "\n");
return -1;
- }
+ }
std::string upload_as = cmSystemTools::GetFilenameName(file);
std::ostringstream fstr;
@@ -1209,22 +1120,20 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file,
<< "md5=" << md5sum << "&"
<< "filename=" << curl.Escape(upload_as) << "&"
<< "buildid=" << json["buildid"].asString();
- if(!curl.UploadFile(file, url, fstr.str(), response))
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "error uploading to CDash. "
- << file << " " << url << " " << fstr.str());
+ if (!curl.UploadFile(file, url, fstr.str(), response)) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "error uploading to CDash. "
+ << file << " " << url << " " << fstr.str());
return -1;
- }
- if(!reader.parse(response, json))
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "error parsing json string [" << response << "]\n"
- << reader.getFormattedErrorMessages() << "\n");
+ }
+ if (!reader.parse(response, json)) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "error parsing json string ["
+ << response << "]\n"
+ << reader.getFormattedErrorMessages() << "\n");
return -1;
- }
+ }
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Upload file response: [" << response << "]\n", this->Quiet );
+ "Upload file response: [" << response << "]\n",
+ this->Quiet);
return 0;
}
@@ -1232,114 +1141,92 @@ int cmCTestSubmitHandler::ProcessHandler()
{
const char* cdashUploadFile = this->GetOption("CDashUploadFile");
const char* cdashUploadType = this->GetOption("CDashUploadType");
- if(cdashUploadFile && cdashUploadType)
- {
+ if (cdashUploadFile && cdashUploadType) {
return this->HandleCDashUploadFile(cdashUploadFile, cdashUploadType);
- }
+ }
std::string iscdash = this->CTest->GetCTestConfiguration("IsCDash");
// cdash does not need to trigger so just return true
- if(!iscdash.empty())
- {
+ if (!iscdash.empty()) {
this->CDash = true;
- }
+ }
- const std::string &buildDirectory
- = this->CTest->GetCTestConfiguration("BuildDirectory");
- if (buildDirectory.empty())
- {
+ const std::string& buildDirectory =
+ this->CTest->GetCTestConfiguration("BuildDirectory");
+ if (buildDirectory.empty()) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Cannot find BuildDirectory key in the DartConfiguration.tcl"
- << std::endl);
+ "Cannot find BuildDirectory key in the DartConfiguration.tcl"
+ << std::endl);
return -1;
- }
+ }
- if ( getenv("HTTP_PROXY") )
- {
+ if (getenv("HTTP_PROXY")) {
this->HTTPProxyType = 1;
this->HTTPProxy = getenv("HTTP_PROXY");
- if ( getenv("HTTP_PROXY_PORT") )
- {
+ if (getenv("HTTP_PROXY_PORT")) {
this->HTTPProxy += ":";
this->HTTPProxy += getenv("HTTP_PROXY_PORT");
- }
- if ( getenv("HTTP_PROXY_TYPE") )
- {
+ }
+ if (getenv("HTTP_PROXY_TYPE")) {
std::string type = getenv("HTTP_PROXY_TYPE");
// HTTP/SOCKS4/SOCKS5
- if ( type == "HTTP" )
- {
+ if (type == "HTTP") {
this->HTTPProxyType = 1;
- }
- else if ( type == "SOCKS4" )
- {
+ } else if (type == "SOCKS4") {
this->HTTPProxyType = 2;
- }
- else if ( type == "SOCKS5" )
- {
+ } else if (type == "SOCKS5") {
this->HTTPProxyType = 3;
- }
}
- if ( getenv("HTTP_PROXY_USER") )
- {
+ }
+ if (getenv("HTTP_PROXY_USER")) {
this->HTTPProxyAuth = getenv("HTTP_PROXY_USER");
- }
- if ( getenv("HTTP_PROXY_PASSWD") )
- {
+ }
+ if (getenv("HTTP_PROXY_PASSWD")) {
this->HTTPProxyAuth += ":";
this->HTTPProxyAuth += getenv("HTTP_PROXY_PASSWD");
- }
}
+ }
- if ( getenv("FTP_PROXY") )
- {
+ if (getenv("FTP_PROXY")) {
this->FTPProxyType = 1;
this->FTPProxy = getenv("FTP_PROXY");
- if ( getenv("FTP_PROXY_PORT") )
- {
+ if (getenv("FTP_PROXY_PORT")) {
this->FTPProxy += ":";
this->FTPProxy += getenv("FTP_PROXY_PORT");
- }
- if ( getenv("FTP_PROXY_TYPE") )
- {
+ }
+ if (getenv("FTP_PROXY_TYPE")) {
std::string type = getenv("FTP_PROXY_TYPE");
// HTTP/SOCKS4/SOCKS5
- if ( type == "HTTP" )
- {
+ if (type == "HTTP") {
this->FTPProxyType = 1;
- }
- else if ( type == "SOCKS4" )
- {
+ } else if (type == "SOCKS4") {
this->FTPProxyType = 2;
- }
- else if ( type == "SOCKS5" )
- {
+ } else if (type == "SOCKS5") {
this->FTPProxyType = 3;
- }
}
}
+ }
- if (!this->HTTPProxy.empty())
- {
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " Use HTTP Proxy: "
- << this->HTTPProxy << std::endl, this->Quiet);
- }
- if (!this->FTPProxy.empty())
- {
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " Use FTP Proxy: "
- << this->FTPProxy << std::endl, this->Quiet);
- }
+ if (!this->HTTPProxy.empty()) {
+ cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+ " Use HTTP Proxy: " << this->HTTPProxy << std::endl,
+ this->Quiet);
+ }
+ if (!this->FTPProxy.empty()) {
+ cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+ " Use FTP Proxy: " << this->FTPProxy << std::endl,
+ this->Quiet);
+ }
cmGeneratedFileStream ofs;
this->StartLogFile("Submit", ofs);
cmCTest::SetOfStrings files;
std::string prefix = this->GetSubmitResultsPrefix();
- if (!this->Files.empty())
- {
+ if (!this->Files.empty()) {
// Submit the explicitly selected files:
//
files.insert(this->Files.begin(), this->Files.end());
- }
+ }
// Add to the list of files to submit from any selected, existing parts:
//
@@ -1351,244 +1238,225 @@ int cmCTestSubmitHandler::ProcessHandler()
this->CTest->AddIfExists(cmCTest::PartConfigure, "Configure.xml");
this->CTest->AddIfExists(cmCTest::PartBuild, "Build.xml");
this->CTest->AddIfExists(cmCTest::PartTest, "Test.xml");
- if(this->CTest->AddIfExists(cmCTest::PartCoverage, "Coverage.xml"))
- {
+ if (this->CTest->AddIfExists(cmCTest::PartCoverage, "Coverage.xml")) {
std::vector<std::string> gfiles;
- std::string gpath
- = buildDirectory + "/Testing/" + this->CTest->GetCurrentTag();
+ std::string gpath =
+ buildDirectory + "/Testing/" + this->CTest->GetCurrentTag();
std::string::size_type glen = gpath.size() + 1;
gpath = gpath + "/CoverageLog*";
- cmCTestOptionalLog(this->CTest, DEBUG, "Globbing for: " << gpath
- << std::endl, this->Quiet);
- if ( cmSystemTools::SimpleGlob(gpath, gfiles, 1) )
- {
+ cmCTestOptionalLog(this->CTest, DEBUG,
+ "Globbing for: " << gpath << std::endl, this->Quiet);
+ if (cmSystemTools::SimpleGlob(gpath, gfiles, 1)) {
size_t cc;
- for ( cc = 0; cc < gfiles.size(); cc ++ )
- {
+ for (cc = 0; cc < gfiles.size(); cc++) {
gfiles[cc] = gfiles[cc].substr(glen);
- cmCTestOptionalLog(this->CTest, DEBUG, "Glob file: " << gfiles[cc]
- << std::endl, this->Quiet);
+ cmCTestOptionalLog(this->CTest, DEBUG,
+ "Glob file: " << gfiles[cc] << std::endl,
+ this->Quiet);
this->CTest->AddSubmitFile(cmCTest::PartCoverage, gfiles[cc].c_str());
- }
}
- else
- {
+ } else {
cmCTestLog(this->CTest, ERROR_MESSAGE, "Problem globbing" << std::endl);
- }
}
+ }
this->CTest->AddIfExists(cmCTest::PartMemCheck, "DynamicAnalysis.xml");
this->CTest->AddIfExists(cmCTest::PartMemCheck, "Purify.xml");
this->CTest->AddIfExists(cmCTest::PartNotes, "Notes.xml");
this->CTest->AddIfExists(cmCTest::PartUpload, "Upload.xml");
// Query parts for files to submit.
- for(cmCTest::Part p = cmCTest::PartStart;
- p != cmCTest::PartCount; p = cmCTest::Part(p+1))
- {
+ for (cmCTest::Part p = cmCTest::PartStart; p != cmCTest::PartCount;
+ p = cmCTest::Part(p + 1)) {
// Skip parts we are not submitting.
- if(!this->SubmitPart[p])
- {
+ if (!this->SubmitPart[p]) {
continue;
- }
+ }
// Submit files from this part.
std::vector<std::string> const& pfiles = this->CTest->GetSubmitFiles(p);
files.insert(pfiles.begin(), pfiles.end());
- }
+ }
- if ( ofs )
- {
+ if (ofs) {
ofs << "Upload files:" << std::endl;
int cnt = 0;
cmCTest::SetOfStrings::iterator it;
- for ( it = files.begin(); it != files.end(); ++ it )
- {
+ for (it = files.begin(); it != files.end(); ++it) {
ofs << cnt << "\t" << *it << std::endl;
- cnt ++;
- }
+ cnt++;
}
+ }
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "Submit files (using "
- << this->CTest->GetCTestConfiguration("DropMethod") << ")"
- << std::endl, this->Quiet);
+ << this->CTest->GetCTestConfiguration("DropMethod")
+ << ")" << std::endl,
+ this->Quiet);
const char* specificTrack = this->CTest->GetSpecificTrack();
- if ( specificTrack )
- {
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " Send to track: "
- << specificTrack << std::endl, this->Quiet);
- }
+ if (specificTrack) {
+ cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+ " Send to track: " << specificTrack << std::endl,
+ this->Quiet);
+ }
this->SetLogFile(&ofs);
std::string dropMethod(this->CTest->GetCTestConfiguration("DropMethod"));
- if ( dropMethod == "" || dropMethod == "ftp" )
- {
+ if (dropMethod == "" || dropMethod == "ftp") {
ofs << "Using drop method: FTP" << std::endl;
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " Using FTP submit method" << std::endl << " Drop site: ftp://",
- this->Quiet);
+ " Using FTP submit method" << std::endl
+ << " Drop site: ftp://",
+ this->Quiet);
std::string url = "ftp://";
url += cmCTest::MakeURLSafe(
- this->CTest->GetCTestConfiguration("DropSiteUser")) + ":" +
- cmCTest::MakeURLSafe(this->CTest->GetCTestConfiguration(
- "DropSitePassword")) + "@" +
- this->CTest->GetCTestConfiguration("DropSite") +
- cmCTest::MakeURLSafe(
- this->CTest->GetCTestConfiguration("DropLocation"));
- if (!this->CTest->GetCTestConfiguration("DropSiteUser").empty())
- {
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- this->CTest->GetCTestConfiguration(
- "DropSiteUser").c_str(), this->Quiet);
- if (!this->CTest->GetCTestConfiguration("DropSitePassword").empty())
- {
+ this->CTest->GetCTestConfiguration("DropSiteUser")) +
+ ":" + cmCTest::MakeURLSafe(
+ this->CTest->GetCTestConfiguration("DropSitePassword")) +
+ "@" + this->CTest->GetCTestConfiguration("DropSite") +
+ cmCTest::MakeURLSafe(this->CTest->GetCTestConfiguration("DropLocation"));
+ if (!this->CTest->GetCTestConfiguration("DropSiteUser").empty()) {
+ cmCTestOptionalLog(
+ this->CTest, HANDLER_OUTPUT,
+ this->CTest->GetCTestConfiguration("DropSiteUser").c_str(),
+ this->Quiet);
+ if (!this->CTest->GetCTestConfiguration("DropSitePassword").empty()) {
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, ":******",
- this->Quiet);
- }
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "@", this->Quiet);
+ this->Quiet);
}
+ cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "@", this->Quiet);
+ }
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- this->CTest->GetCTestConfiguration("DropSite")
- << this->CTest->GetCTestConfiguration("DropLocation") << std::endl,
- this->Quiet);
- if ( !this->SubmitUsingFTP(buildDirectory + "/Testing/"
- + this->CTest->GetCurrentTag(),
- files, prefix, url) )
- {
+ this->CTest->GetCTestConfiguration("DropSite")
+ << this->CTest->GetCTestConfiguration("DropLocation")
+ << std::endl,
+ this->Quiet);
+ if (!this->SubmitUsingFTP(buildDirectory + "/Testing/" +
+ this->CTest->GetCurrentTag(),
+ files, prefix, url)) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- " Problems when submitting via FTP"
- << std::endl);
+ " Problems when submitting via FTP" << std::endl);
ofs << " Problems when submitting via FTP" << std::endl;
return -1;
- }
- if(!this->CDash)
- {
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " Using HTTP trigger method"
- << std::endl
- << " Trigger site: "
- << this->CTest->GetCTestConfiguration("TriggerSite")
- << std::endl, this->Quiet);
- if ( !this->
- TriggerUsingHTTP(files, prefix,
- this->CTest->GetCTestConfiguration("TriggerSite")))
- {
+ }
+ if (!this->CDash) {
+ cmCTestOptionalLog(
+ this->CTest, HANDLER_OUTPUT, " Using HTTP trigger method"
+ << std::endl
+ << " Trigger site: "
+ << this->CTest->GetCTestConfiguration("TriggerSite") << std::endl,
+ this->Quiet);
+ if (!this->TriggerUsingHTTP(
+ files, prefix,
+ this->CTest->GetCTestConfiguration("TriggerSite"))) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
" Problems when triggering via HTTP" << std::endl);
ofs << " Problems when triggering via HTTP" << std::endl;
return -1;
- }
+ }
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " Submission successful" << std::endl, this->Quiet);
+ " Submission successful" << std::endl, this->Quiet);
ofs << " Submission successful" << std::endl;
return 0;
- }
}
- else if ( dropMethod == "http" || dropMethod == "https" )
- {
+ } else if (dropMethod == "http" || dropMethod == "https") {
std::string url = dropMethod;
url += "://";
ofs << "Using drop method: " << dropMethod << std::endl;
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " Using HTTP submit method" << std::endl << " Drop site:" << url,
- this->Quiet);
- if (!this->CTest->GetCTestConfiguration("DropSiteUser").empty())
- {
+ " Using HTTP submit method" << std::endl
+ << " Drop site:" << url,
+ this->Quiet);
+ if (!this->CTest->GetCTestConfiguration("DropSiteUser").empty()) {
url += this->CTest->GetCTestConfiguration("DropSiteUser");
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+ cmCTestOptionalLog(
+ this->CTest, HANDLER_OUTPUT,
this->CTest->GetCTestConfiguration("DropSiteUser").c_str(),
this->Quiet);
- if (!this->CTest->GetCTestConfiguration("DropSitePassword").empty())
- {
+ if (!this->CTest->GetCTestConfiguration("DropSitePassword").empty()) {
url += ":" + this->CTest->GetCTestConfiguration("DropSitePassword");
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, ":******",
- this->Quiet);
- }
+ this->Quiet);
+ }
url += "@";
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "@", this->Quiet);
- }
+ }
url += this->CTest->GetCTestConfiguration("DropSite") +
this->CTest->GetCTestConfiguration("DropLocation");
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- this->CTest->GetCTestConfiguration("DropSite")
- << this->CTest->GetCTestConfiguration("DropLocation") << std::endl,
- this->Quiet);
- if ( !this->SubmitUsingHTTP(buildDirectory + "/Testing/" +
- this->CTest->GetCurrentTag(), files, prefix, url) )
- {
+ this->CTest->GetCTestConfiguration("DropSite")
+ << this->CTest->GetCTestConfiguration("DropLocation")
+ << std::endl,
+ this->Quiet);
+ if (!this->SubmitUsingHTTP(buildDirectory + "/Testing/" +
+ this->CTest->GetCurrentTag(),
+ files, prefix, url)) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- " Problems when submitting via HTTP" << std::endl);
+ " Problems when submitting via HTTP" << std::endl);
ofs << " Problems when submitting via HTTP" << std::endl;
return -1;
- }
- if(!this->CDash)
- {
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " Using HTTP trigger method" << std::endl << " Trigger site: "
- << this->CTest->GetCTestConfiguration("TriggerSite")
- << std::endl, this->Quiet);
- if ( !this->
- TriggerUsingHTTP(files, prefix,
- this->CTest->GetCTestConfiguration("TriggerSite")))
- {
+ }
+ if (!this->CDash) {
+ cmCTestOptionalLog(
+ this->CTest, HANDLER_OUTPUT, " Using HTTP trigger method"
+ << std::endl
+ << " Trigger site: "
+ << this->CTest->GetCTestConfiguration("TriggerSite") << std::endl,
+ this->Quiet);
+ if (!this->TriggerUsingHTTP(
+ files, prefix,
+ this->CTest->GetCTestConfiguration("TriggerSite"))) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
" Problems when triggering via HTTP" << std::endl);
ofs << " Problems when triggering via HTTP" << std::endl;
return -1;
- }
}
- if(this->HasErrors)
- {
+ }
+ if (this->HasErrors) {
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Errors occurred during "
- "submission." << std::endl);
+ "submission."
+ << std::endl);
ofs << " Errors occurred during submission. " << std::endl;
- }
- else
- {
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " Submission successful" <<
- (this->HasWarnings ? ", with warnings." : "") << std::endl,
+ } else {
+ cmCTestOptionalLog(
+ this->CTest, HANDLER_OUTPUT, " Submission successful"
+ << (this->HasWarnings ? ", with warnings." : "") << std::endl,
this->Quiet);
- ofs << " Submission successful" <<
- (this->HasWarnings ? ", with warnings." : "") << std::endl;
- }
+ ofs << " Submission successful"
+ << (this->HasWarnings ? ", with warnings." : "") << std::endl;
+ }
return 0;
- }
- else if ( dropMethod == "xmlrpc" )
- {
+ } else if (dropMethod == "xmlrpc") {
#if defined(CTEST_USE_XMLRPC)
ofs << "Using drop method: XML-RPC" << std::endl;
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " Using XML-RPC submit method" << std::endl, this->Quiet);
+ " Using XML-RPC submit method" << std::endl,
+ this->Quiet);
std::string url = this->CTest->GetCTestConfiguration("DropSite");
prefix = this->CTest->GetCTestConfiguration("DropLocation");
- if ( !this->SubmitUsingXMLRPC(buildDirectory + "/Testing/" +
- this->CTest->GetCurrentTag(), files, prefix, url) )
- {
+ if (!this->SubmitUsingXMLRPC(buildDirectory + "/Testing/" +
+ this->CTest->GetCurrentTag(),
+ files, prefix, url)) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- " Problems when submitting via XML-RPC" << std::endl);
+ " Problems when submitting via XML-RPC" << std::endl);
ofs << " Problems when submitting via XML-RPC" << std::endl;
return -1;
- }
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " Submission successful"
- << std::endl, this->Quiet);
+ }
+ cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+ " Submission successful" << std::endl, this->Quiet);
ofs << " Submission successful" << std::endl;
return 0;
#else
cmCTestLog(this->CTest, ERROR_MESSAGE,
" Submission method \"xmlrpc\" not compiled into CTest!"
- << std::endl);
+ << std::endl);
return -1;
#endif
- }
- else if ( dropMethod == "scp" )
- {
+ } else if (dropMethod == "scp") {
std::string url;
std::string oldWorkingDirectory;
- if (!this->CTest->GetCTestConfiguration("DropSiteUser").empty())
- {
+ if (!this->CTest->GetCTestConfiguration("DropSiteUser").empty()) {
url += this->CTest->GetCTestConfiguration("DropSiteUser") + "@";
- }
+ }
url += this->CTest->GetCTestConfiguration("DropSite") + ":" +
this->CTest->GetCTestConfiguration("DropLocation");
@@ -1597,69 +1465,58 @@ int cmCTestSubmitHandler::ProcessHandler()
oldWorkingDirectory = cmSystemTools::GetCurrentWorkingDirectory();
cmSystemTools::ChangeDirectory(buildDirectory);
- if ( !this->SubmitUsingSCP(
- this->CTest->GetCTestConfiguration("ScpCommand"),
- "Testing/"+this->CTest->GetCurrentTag(), files, prefix, url) )
- {
+ 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);
+ " 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);
+ cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+ " Submission successful" << std::endl, this->Quiet);
ofs << " Submission successful" << std::endl;
return 0;
- }
- else if ( dropMethod == "cp" )
- {
- std::string location
- = this->CTest->GetCTestConfiguration("DropLocation");
-
+ } else if (dropMethod == "cp") {
+ std::string location = this->CTest->GetCTestConfiguration("DropLocation");
// 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();
+ std::string oldWorkingDirectory =
+ cmSystemTools::GetCurrentWorkingDirectory();
cmSystemTools::ChangeDirectory(buildDirectory);
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " Change directory: " << buildDirectory << std::endl, this->Quiet);
-
- if ( !this->SubmitUsingCP(
- "Testing/"+this->CTest->GetCurrentTag(),
- files,
- prefix,
- location) )
- {
+ " 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);
+ " 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);
+ cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+ " Submission successful" << std::endl, this->Quiet);
ofs << " Submission successful" << std::endl;
return 0;
- }
+ }
cmCTestLog(this->CTest, ERROR_MESSAGE, " Unknown submission method: \""
- << dropMethod << "\"" << std::endl);
+ << dropMethod << "\"" << std::endl);
return -1;
}
std::string cmCTestSubmitHandler::GetSubmitResultsPrefix()
{
- std::string buildname = cmCTest::SafeBuildIdField(
- this->CTest->GetCTestConfiguration("BuildName"));
- std::string name = this->CTest->GetCTestConfiguration("Site") +
- "___" + buildname +
- "___" + this->CTest->GetCurrentTag() + "-" +
+ std::string buildname =
+ cmCTest::SafeBuildIdField(this->CTest->GetCTestConfiguration("BuildName"));
+ std::string name = this->CTest->GetCTestConfiguration("Site") + "___" +
+ buildname + "___" + this->CTest->GetCurrentTag() + "-" +
this->CTest->GetTestModelString() + "___XML___";
return name;
}
@@ -1667,12 +1524,11 @@ std::string cmCTestSubmitHandler::GetSubmitResultsPrefix()
void cmCTestSubmitHandler::SelectParts(std::set<cmCTest::Part> const& parts)
{
// Check whether each part is selected.
- for(cmCTest::Part p = cmCTest::PartStart;
- p != cmCTest::PartCount; p = cmCTest::Part(p+1))
- {
+ for (cmCTest::Part p = cmCTest::PartStart; p != cmCTest::PartCount;
+ p = cmCTest::Part(p + 1)) {
this->SubmitPart[p] =
(std::set<cmCTest::Part>::const_iterator(parts.find(p)) != parts.end());
- }
+ }
}
void cmCTestSubmitHandler::SelectFiles(cmCTest::SetOfStrings const& files)
diff --git a/Source/CTest/cmCTestSubmitHandler.h b/Source/CTest/cmCTestSubmitHandler.h
index f9cd894..87fa142 100644
--- a/Source/CTest/cmCTestSubmitHandler.h
+++ b/Source/CTest/cmCTestSubmitHandler.h
@@ -54,8 +54,7 @@ private:
*/
bool SubmitUsingFTP(const std::string& localprefix,
const std::set<std::string>& files,
- const std::string& remoteprefix,
- const std::string& url);
+ const std::string& remoteprefix, const std::string& url);
bool SubmitUsingHTTP(const std::string& localprefix,
const std::set<std::string>& files,
const std::string& remoteprefix,
@@ -63,22 +62,20 @@ private:
bool SubmitUsingSCP(const std::string& scp_command,
const std::string& localprefix,
const std::set<std::string>& files,
- const std::string& remoteprefix,
- const std::string& url);
+ const std::string& remoteprefix, const std::string& url);
- bool SubmitUsingCP( const std::string& localprefix,
- const std::set<std::string>& files,
- const std::string& remoteprefix,
- const std::string& url);
+ bool SubmitUsingCP(const std::string& localprefix,
+ const std::set<std::string>& files,
+ const std::string& remoteprefix, const std::string& url);
bool TriggerUsingHTTP(const std::set<std::string>& files,
const std::string& remoteprefix,
const std::string& url);
bool SubmitUsingXMLRPC(const std::string& localprefix,
- const std::set<std::string>& files,
- const std::string& remoteprefix,
- const std::string& url);
+ const std::set<std::string>& files,
+ const std::string& remoteprefix,
+ const std::string& url);
typedef std::vector<char> cmCTestSubmitHandlerVectorOfChar;
@@ -86,12 +83,12 @@ private:
std::string GetSubmitResultsPrefix();
- class ResponseParser;
- std::string HTTPProxy;
- int HTTPProxyType;
- std::string HTTPProxyAuth;
- std::string FTPProxy;
- int FTPProxyType;
+ class ResponseParser;
+ std::string HTTPProxy;
+ int HTTPProxyType;
+ std::string HTTPProxyAuth;
+ std::string FTPProxy;
+ int FTPProxyType;
std::ostream* LogFile;
bool SubmitPart[cmCTest::PartCount];
bool CDash;
diff --git a/Source/CTest/cmCTestTestCommand.cxx b/Source/CTest/cmCTestTestCommand.cxx
index b7d8318..7b437c6 100644
--- a/Source/CTest/cmCTestTestCommand.cxx
+++ b/Source/CTest/cmCTestTestCommand.cxx
@@ -37,103 +37,78 @@ cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler()
this->Makefile->GetDefinition("CTEST_TEST_TIMEOUT");
double timeout = this->CTest->GetTimeOut();
- if ( ctestTimeout )
- {
+ if (ctestTimeout) {
timeout = atof(ctestTimeout);
- }
- else
- {
- if ( timeout <= 0 )
- {
+ } else {
+ if (timeout <= 0) {
// By default use timeout of 10 minutes
timeout = 600;
- }
}
+ }
this->CTest->SetTimeOut(timeout);
cmCTestGenericHandler* handler = this->InitializeActualHandler();
- if ( this->Values[ctt_START] || this->Values[ctt_END] ||
- this->Values[ctt_STRIDE] )
- {
+ if (this->Values[ctt_START] || this->Values[ctt_END] ||
+ this->Values[ctt_STRIDE]) {
std::ostringstream testsToRunString;
- if ( this->Values[ctt_START] )
- {
+ if (this->Values[ctt_START]) {
testsToRunString << this->Values[ctt_START];
- }
+ }
testsToRunString << ",";
- if ( this->Values[ctt_END] )
- {
+ if (this->Values[ctt_END]) {
testsToRunString << this->Values[ctt_END];
- }
+ }
testsToRunString << ",";
- if ( this->Values[ctt_STRIDE] )
- {
+ if (this->Values[ctt_STRIDE]) {
testsToRunString << this->Values[ctt_STRIDE];
- }
- handler->SetOption("TestsToRunInformation",
- testsToRunString.str().c_str());
}
- if(this->Values[ctt_EXCLUDE])
- {
+ handler->SetOption("TestsToRunInformation",
+ testsToRunString.str().c_str());
+ }
+ if (this->Values[ctt_EXCLUDE]) {
handler->SetOption("ExcludeRegularExpression", this->Values[ctt_EXCLUDE]);
- }
- if(this->Values[ctt_INCLUDE])
- {
+ }
+ if (this->Values[ctt_INCLUDE]) {
handler->SetOption("IncludeRegularExpression", this->Values[ctt_INCLUDE]);
- }
- if(this->Values[ctt_EXCLUDE_LABEL])
- {
+ }
+ if (this->Values[ctt_EXCLUDE_LABEL]) {
handler->SetOption("ExcludeLabelRegularExpression",
this->Values[ctt_EXCLUDE_LABEL]);
- }
- if(this->Values[ctt_INCLUDE_LABEL])
- {
+ }
+ if (this->Values[ctt_INCLUDE_LABEL]) {
handler->SetOption("LabelRegularExpression",
this->Values[ctt_INCLUDE_LABEL]);
- }
- if(this->Values[ctt_PARALLEL_LEVEL])
- {
- handler->SetOption("ParallelLevel",
- this->Values[ctt_PARALLEL_LEVEL]);
- }
- if(this->Values[ctt_SCHEDULE_RANDOM])
- {
- handler->SetOption("ScheduleRandom",
- this->Values[ctt_SCHEDULE_RANDOM]);
- }
- if(this->Values[ctt_STOP_TIME])
- {
+ }
+ if (this->Values[ctt_PARALLEL_LEVEL]) {
+ handler->SetOption("ParallelLevel", this->Values[ctt_PARALLEL_LEVEL]);
+ }
+ if (this->Values[ctt_SCHEDULE_RANDOM]) {
+ handler->SetOption("ScheduleRandom", this->Values[ctt_SCHEDULE_RANDOM]);
+ }
+ if (this->Values[ctt_STOP_TIME]) {
this->CTest->SetStopTime(this->Values[ctt_STOP_TIME]);
- }
+ }
// Test load is determined by: TEST_LOAD argument,
// or CTEST_TEST_LOAD script variable, or ctest --test-load
// command line argument... in that order.
unsigned long testLoad;
- const char* ctestTestLoad
- = this->Makefile->GetDefinition("CTEST_TEST_LOAD");
- if(this->Values[ctt_TEST_LOAD] && *this->Values[ctt_TEST_LOAD])
- {
- if (!cmSystemTools::StringToULong(this->Values[ctt_TEST_LOAD], &testLoad))
- {
+ const char* ctestTestLoad = this->Makefile->GetDefinition("CTEST_TEST_LOAD");
+ if (this->Values[ctt_TEST_LOAD] && *this->Values[ctt_TEST_LOAD]) {
+ if (!cmSystemTools::StringToULong(this->Values[ctt_TEST_LOAD],
+ &testLoad)) {
testLoad = 0;
cmCTestLog(this->CTest, WARNING, "Invalid value for 'TEST_LOAD' : "
- << this->Values[ctt_TEST_LOAD] << std::endl);
- }
+ << this->Values[ctt_TEST_LOAD] << std::endl);
}
- else if(ctestTestLoad && *ctestTestLoad)
- {
- if (!cmSystemTools::StringToULong(ctestTestLoad, &testLoad))
- {
+ } else if (ctestTestLoad && *ctestTestLoad) {
+ if (!cmSystemTools::StringToULong(ctestTestLoad, &testLoad)) {
testLoad = 0;
- cmCTestLog(this->CTest, WARNING,
- "Invalid value for 'CTEST_TEST_LOAD' : " <<
- ctestTestLoad << std::endl);
- }
+ cmCTestLog(this->CTest, WARNING, "Invalid value for 'CTEST_TEST_LOAD' : "
+ << ctestTestLoad << std::endl);
}
- else
- {
+ } else {
testLoad = this->CTest->GetTestLoad();
- }
+ }
handler->SetTestLoad(testLoad);
handler->SetQuiet(this->Quiet);
diff --git a/Source/CTest/cmCTestTestCommand.h b/Source/CTest/cmCTestTestCommand.h
index 0dfca97..212213e 100644
--- a/Source/CTest/cmCTestTestCommand.h
+++ b/Source/CTest/cmCTestTestCommand.h
@@ -22,24 +22,23 @@
class cmCTestTestCommand : public cmCTestHandlerCommand
{
public:
-
cmCTestTestCommand();
/**
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
- {
+ {
cmCTestTestCommand* ni = new cmCTestTestCommand;
ni->CTest = this->CTest;
ni->CTestScriptHandler = this->CTestScriptHandler;
return ni;
- }
+ }
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const { return "ctest_test";}
+ virtual std::string GetName() const { return "ctest_test"; }
cmTypeMacro(cmCTestTestCommand, cmCTestHandlerCommand);
@@ -47,7 +46,8 @@ protected:
virtual cmCTestGenericHandler* InitializeActualHandler();
cmCTestGenericHandler* InitializeHandler();
- enum {
+ enum
+ {
ctt_BUILD = ct_LAST,
ctt_RETURN_VALUE,
ctt_START,
@@ -65,5 +65,4 @@ protected:
};
};
-
#endif
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index b477f5f..4935f11 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -43,88 +43,76 @@ public:
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
- {
+ {
cmCTestSubdirCommand* c = new cmCTestSubdirCommand;
c->TestHandler = this->TestHandler;
return c;
- }
+ }
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus &);
+ cmExecutionStatus&);
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const { return "subdirs";}
+ virtual std::string GetName() const { return "subdirs"; }
cmTypeMacro(cmCTestSubdirCommand, cmCommand);
cmCTestTestHandler* TestHandler;
};
-bool cmCTestSubdirCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmCTestSubdirCommand::InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus&)
{
- if(args.size() < 1 )
- {
+ if (args.size() < 1) {
this->SetError("called with incorrect number of arguments");
return false;
- }
+ }
std::vector<std::string>::const_iterator it;
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
- for ( it = args.begin(); it != args.end(); ++ it )
- {
+ for (it = args.begin(); it != args.end(); ++it) {
std::string fname;
- if(cmSystemTools::FileIsFullPath(it->c_str()))
- {
+ if (cmSystemTools::FileIsFullPath(it->c_str())) {
fname = *it;
- }
- else
- {
+ } else {
fname = cwd;
fname += "/";
fname += *it;
- }
+ }
- if ( !cmSystemTools::FileIsDirectory(fname) )
- {
+ if (!cmSystemTools::FileIsDirectory(fname)) {
// No subdirectory? So what...
continue;
- }
+ }
cmSystemTools::ChangeDirectory(fname);
const char* testFilename;
- if( cmSystemTools::FileExists("CTestTestfile.cmake") )
- {
+ if (cmSystemTools::FileExists("CTestTestfile.cmake")) {
// does the CTestTestfile.cmake exist ?
testFilename = "CTestTestfile.cmake";
- }
- else if( cmSystemTools::FileExists("DartTestfile.txt") )
- {
+ } else if (cmSystemTools::FileExists("DartTestfile.txt")) {
// does the DartTestfile.txt exist ?
testFilename = "DartTestfile.txt";
- }
- else
- {
+ } else {
// No CTestTestfile? Who cares...
continue;
- }
+ }
fname += "/";
fname += testFilename;
bool readit = this->Makefile->ReadDependentFile(fname.c_str());
cmSystemTools::ChangeDirectory(cwd);
- if(!readit)
- {
+ if (!readit) {
std::string m = "Could not find include file: ";
m += fname;
this->SetError(m);
return false;
- }
}
+ }
cmSystemTools::ChangeDirectory(cwd);
return true;
}
@@ -136,37 +124,36 @@ public:
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
- {
+ {
cmCTestAddSubdirectoryCommand* c = new cmCTestAddSubdirectoryCommand;
c->TestHandler = this->TestHandler;
return c;
- }
+ }
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus &);
+ cmExecutionStatus&);
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const { return "add_subdirectory";}
+ virtual std::string GetName() const { return "add_subdirectory"; }
cmTypeMacro(cmCTestAddSubdirectoryCommand, cmCommand);
cmCTestTestHandler* TestHandler;
};
-bool cmCTestAddSubdirectoryCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmCTestAddSubdirectoryCommand::InitialPass(
+ std::vector<std::string> const& args, cmExecutionStatus&)
{
- if(args.size() < 1 )
- {
+ if (args.size() < 1) {
this->SetError("called with incorrect number of arguments");
return false;
- }
+ }
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
cmSystemTools::ChangeDirectory(cwd);
@@ -174,40 +161,33 @@ bool cmCTestAddSubdirectoryCommand
fname += "/";
fname += args[0];
- if ( !cmSystemTools::FileExists(fname.c_str()) )
- {
+ if (!cmSystemTools::FileExists(fname.c_str())) {
// No subdirectory? So what...
return true;
- }
+ }
cmSystemTools::ChangeDirectory(fname);
const char* testFilename;
- if( cmSystemTools::FileExists("CTestTestfile.cmake") )
- {
+ if (cmSystemTools::FileExists("CTestTestfile.cmake")) {
// does the CTestTestfile.cmake exist ?
testFilename = "CTestTestfile.cmake";
- }
- else if( cmSystemTools::FileExists("DartTestfile.txt") )
- {
+ } else if (cmSystemTools::FileExists("DartTestfile.txt")) {
// does the DartTestfile.txt exist ?
testFilename = "DartTestfile.txt";
- }
- else
- {
+ } else {
// No CTestTestfile? Who cares...
cmSystemTools::ChangeDirectory(cwd);
return true;
- }
+ }
fname += "/";
fname += testFilename;
bool readit = this->Makefile->ReadDependentFile(fname.c_str());
cmSystemTools::ChangeDirectory(cwd);
- if(!readit)
- {
+ if (!readit) {
std::string m = "Could not find include file: ";
m += fname;
this->SetError(m);
return false;
- }
+ }
return true;
}
@@ -218,37 +198,36 @@ public:
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
- {
+ {
cmCTestAddTestCommand* c = new cmCTestAddTestCommand;
c->TestHandler = this->TestHandler;
return c;
- }
+ }
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const&,
- cmExecutionStatus &);
+ cmExecutionStatus&);
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const { return "add_test";}
+ virtual std::string GetName() const { return "add_test"; }
cmTypeMacro(cmCTestAddTestCommand, cmCommand);
cmCTestTestHandler* TestHandler;
};
-bool cmCTestAddTestCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmCTestAddTestCommand::InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus&)
{
- if ( args.size() < 2 )
- {
+ if (args.size() < 2) {
this->SetError("called with incorrect number of arguments");
return false;
- }
+ }
return this->TestHandler->AddTest(args);
}
@@ -259,32 +238,31 @@ public:
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
- {
- cmCTestSetTestsPropertiesCommand* c
- = new cmCTestSetTestsPropertiesCommand;
+ {
+ cmCTestSetTestsPropertiesCommand* c = new cmCTestSetTestsPropertiesCommand;
c->TestHandler = this->TestHandler;
return c;
- }
+ }
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const&,
- cmExecutionStatus &);
+ cmExecutionStatus&);
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const { return "set_tests_properties";}
+ virtual std::string GetName() const { return "set_tests_properties"; }
cmTypeMacro(cmCTestSetTestsPropertiesCommand, cmCommand);
cmCTestTestHandler* TestHandler;
};
-bool cmCTestSetTestsPropertiesCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmCTestSetTestsPropertiesCommand::InitialPass(
+ std::vector<std::string> const& args, cmExecutionStatus&)
{
return this->TestHandler->SetTestsProperties(args);
}
@@ -293,86 +271,65 @@ bool cmCTestSetTestsPropertiesCommand
// pos is the start of the search and pos2 is the end of the search
// pos becomes pos2 after a call to GetNextNumber.
// -1 is returned at the end of the list.
-inline int GetNextNumber(std::string const& in,
- int& val,
+inline int GetNextNumber(std::string const& in, int& val,
std::string::size_type& pos,
std::string::size_type& pos2)
{
pos2 = in.find(',', pos);
- if(pos2 != in.npos)
- {
- if(pos2-pos == 0)
- {
+ if (pos2 != in.npos) {
+ if (pos2 - pos == 0) {
val = -1;
- }
- else
- {
- val = atoi(in.substr(pos, pos2-pos).c_str());
- }
- pos = pos2+1;
+ } else {
+ val = atoi(in.substr(pos, pos2 - pos).c_str());
+ }
+ pos = pos2 + 1;
return 1;
+ } else {
+ if (in.size() - pos == 0) {
+ val = -1;
+ } else {
+ val = atoi(in.substr(pos, in.size() - pos).c_str());
}
- else
- {
- if(in.size()-pos == 0)
- {
- val = -1;
- }
- else
- {
- val = atoi(in.substr(pos, in.size()-pos).c_str());
- }
return 0;
- }
+ }
}
// get the next number in a string with numbers separated by ,
// pos is the start of the search and pos2 is the end of the search
// pos becomes pos2 after a call to GetNextNumber.
// -1 is returned at the end of the list.
-inline int GetNextRealNumber(std::string const& in,
- double& val,
+inline int GetNextRealNumber(std::string const& in, double& val,
std::string::size_type& pos,
std::string::size_type& pos2)
{
pos2 = in.find(',', pos);
- if(pos2 != in.npos)
- {
- if(pos2-pos == 0)
- {
+ if (pos2 != in.npos) {
+ if (pos2 - pos == 0) {
val = -1;
- }
- else
- {
- val = atof(in.substr(pos, pos2-pos).c_str());
- }
- pos = pos2+1;
+ } else {
+ val = atof(in.substr(pos, pos2 - pos).c_str());
+ }
+ pos = pos2 + 1;
return 1;
+ } else {
+ if (in.size() - pos == 0) {
+ val = -1;
+ } else {
+ val = atof(in.substr(pos, in.size() - pos).c_str());
}
- else
- {
- if(in.size()-pos == 0)
- {
- val = -1;
- }
- else
- {
- val = atof(in.substr(pos, in.size()-pos).c_str());
- }
return 0;
- }
+ }
}
-
cmCTestTestHandler::cmCTestTestHandler()
{
this->UseUnion = false;
- this->UseIncludeLabelRegExpFlag = false;
- this->UseExcludeLabelRegExpFlag = false;
- this->UseIncludeRegExpFlag = false;
- this->UseExcludeRegExpFlag = false;
- this->UseExcludeRegExpFirst = false;
+ this->UseIncludeLabelRegExpFlag = false;
+ this->UseExcludeLabelRegExpFlag = false;
+ this->UseIncludeRegExpFlag = false;
+ this->UseExcludeRegExpFlag = false;
+ this->UseExcludeRegExpFirst = false;
this->CustomMaximumPassedTestOutputSize = 1 * 1024;
this->CustomMaximumFailedTestOutputSize = 300 * 1024;
@@ -382,8 +339,7 @@ cmCTestTestHandler::cmCTestTestHandler()
this->LogFile = 0;
// regex to detect <DartMeasurement>...</DartMeasurement>
- this->DartStuff.compile(
- "(<DartMeasurement.*/DartMeasurement[a-zA-Z]*>)");
+ this->DartStuff.compile("(<DartMeasurement.*/DartMeasurement[a-zA-Z]*>)");
// regex to detect each individual <DartMeasurement>...</DartMeasurement>
this->DartStuff1.compile(
"(<DartMeasurement[^<]*</DartMeasurement[a-zA-Z]*>)");
@@ -423,98 +379,89 @@ void cmCTestTestHandler::Initialize()
this->TestList.clear();
}
-void cmCTestTestHandler::PopulateCustomVectors(cmMakefile *mf)
+void cmCTestTestHandler::PopulateCustomVectors(cmMakefile* mf)
{
this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_PRE_TEST",
- this->CustomPreTest);
+ this->CustomPreTest);
this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_POST_TEST",
- this->CustomPostTest);
- this->CTest->PopulateCustomVector(mf,
- "CTEST_CUSTOM_TESTS_IGNORE",
- this->CustomTestsIgnore);
- this->CTest->PopulateCustomInteger(mf,
- "CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE",
- this->CustomMaximumPassedTestOutputSize);
- this->CTest->PopulateCustomInteger(mf,
- "CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE",
- this->CustomMaximumFailedTestOutputSize);
+ this->CustomPostTest);
+ this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_TESTS_IGNORE",
+ this->CustomTestsIgnore);
+ this->CTest->PopulateCustomInteger(
+ mf, "CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE",
+ this->CustomMaximumPassedTestOutputSize);
+ this->CTest->PopulateCustomInteger(
+ mf, "CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE",
+ this->CustomMaximumFailedTestOutputSize);
}
int cmCTestTestHandler::PreProcessHandler()
{
- if ( !this->ExecuteCommands(this->CustomPreTest) )
- {
+ if (!this->ExecuteCommands(this->CustomPreTest)) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Problem executing pre-test command(s)." << std::endl);
+ "Problem executing pre-test command(s)." << std::endl);
return 0;
- }
+ }
return 1;
}
int cmCTestTestHandler::PostProcessHandler()
{
- if ( !this->ExecuteCommands(this->CustomPostTest) )
- {
+ if (!this->ExecuteCommands(this->CustomPostTest)) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Problem executing post-test command(s)." << std::endl);
+ "Problem executing post-test command(s)." << std::endl);
return 0;
- }
+ }
return 1;
}
-//clearly it would be nice if this were broken up into a few smaller
-//functions and commented...
+// clearly it would be nice if this were broken up into a few smaller
+// functions and commented...
int cmCTestTestHandler::ProcessHandler()
{
// Update internal data structure from generic one
this->SetTestsToRunInformation(this->GetOption("TestsToRunInformation"));
this->SetUseUnion(cmSystemTools::IsOn(this->GetOption("UseUnion")));
- if(cmSystemTools::IsOn(this->GetOption("ScheduleRandom")))
- {
+ if (cmSystemTools::IsOn(this->GetOption("ScheduleRandom"))) {
this->CTest->SetScheduleType("Random");
- }
- if(this->GetOption("ParallelLevel"))
- {
+ }
+ if (this->GetOption("ParallelLevel")) {
this->CTest->SetParallelLevel(atoi(this->GetOption("ParallelLevel")));
- }
+ }
const char* val;
val = this->GetOption("LabelRegularExpression");
- if ( val )
- {
+ if (val) {
this->UseIncludeLabelRegExpFlag = true;
this->IncludeLabelRegExp = val;
- }
+ }
val = this->GetOption("ExcludeLabelRegularExpression");
- if ( val )
- {
+ if (val) {
this->UseExcludeLabelRegExpFlag = true;
this->ExcludeLabelRegExp = val;
- }
+ }
val = this->GetOption("IncludeRegularExpression");
- if ( val )
- {
+ if (val) {
this->UseIncludeRegExp();
this->SetIncludeRegExp(val);
- }
+ }
val = this->GetOption("ExcludeRegularExpression");
- if ( val )
- {
+ if (val) {
this->UseExcludeRegExp();
this->SetExcludeRegExp(val);
- }
+ }
this->SetRerunFailed(cmSystemTools::IsOn(this->GetOption("RerunFailed")));
this->TestResults.clear();
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- (this->MemCheck ? "Memory check" : "Test")
- << " project " << cmSystemTools::GetCurrentWorkingDirectory()
- << std::endl, this->Quiet);
- if ( ! this->PreProcessHandler() )
- {
+ cmCTestOptionalLog(
+ this->CTest, HANDLER_OUTPUT, (this->MemCheck ? "Memory check" : "Test")
+ << " project " << cmSystemTools::GetCurrentWorkingDirectory()
+ << std::endl,
+ this->Quiet);
+ if (!this->PreProcessHandler()) {
return -1;
- }
+ }
cmGeneratedFileStream mLogFile;
this->StartLogFile((this->MemCheck ? "DynamicAnalysis" : "Test"), mLogFile);
@@ -524,7 +471,7 @@ int cmCTestTestHandler::ProcessHandler()
std::vector<std::string> failed;
int total;
- //start the real time clock
+ // start the real time clock
double clock_start, clock_finish;
clock_start = cmSystemTools::GetTime();
@@ -534,104 +481,91 @@ int cmCTestTestHandler::ProcessHandler()
total = int(passed.size()) + int(failed.size());
- if (total == 0)
- {
- if ( !this->CTest->GetShowOnly() && !this->CTest->ShouldPrintLabels() )
- {
+ if (total == 0) {
+ if (!this->CTest->GetShowOnly() && !this->CTest->ShouldPrintLabels()) {
cmCTestLog(this->CTest, ERROR_MESSAGE, "No tests were found!!!"
- << std::endl);
- }
+ << std::endl);
}
- else
- {
+ } else {
if (this->HandlerVerbose && !passed.empty() &&
- (this->UseIncludeRegExpFlag || this->UseExcludeRegExpFlag))
- {
+ (this->UseIncludeRegExpFlag || this->UseExcludeRegExpFlag)) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl
- << "The following tests passed:" << std::endl, this->Quiet);
- for(std::vector<std::string>::iterator j = passed.begin();
- j != passed.end(); ++j)
- {
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "\t" << *j
- << std::endl, this->Quiet);
- }
+ << "The following tests passed:" << std::endl,
+ this->Quiet);
+ for (std::vector<std::string>::iterator j = passed.begin();
+ j != passed.end(); ++j) {
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "\t" << *j << std::endl, this->Quiet);
}
+ }
float percent = float(passed.size()) * 100.0f / float(total);
- if (!failed.empty() && percent > 99)
- {
+ if (!failed.empty() && percent > 99) {
percent = 99;
- }
+ }
cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl
- << static_cast<int>(percent + .5f) << "% tests passed, "
- << failed.size() << " tests failed out of "
- << total << std::endl);
- if(this->CTest->GetLabelSummary())
- {
+ << static_cast<int>(percent + .5f) << "% tests passed, "
+ << failed.size() << " tests failed out of " << total
+ << std::endl);
+ if (this->CTest->GetLabelSummary()) {
this->PrintLabelSummary();
- }
+ }
char realBuf[1024];
sprintf(realBuf, "%6.2f sec", (double)(clock_finish - clock_start));
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- "\nTotal Test time (real) = " << realBuf << "\n", this->Quiet );
+ "\nTotal Test time (real) = " << realBuf << "\n",
+ this->Quiet);
- if (!failed.empty())
- {
+ if (!failed.empty()) {
cmGeneratedFileStream ofs;
cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl
- << "The following tests FAILED:" << std::endl);
+ << "The following tests FAILED:" << std::endl);
this->StartLogFile("TestsFailed", ofs);
typedef std::set<cmCTestTestHandler::cmCTestTestResult,
- cmCTestTestResultLess> SetOfTests;
+ 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 )
- {
+ for (SetOfTests::iterator ftit = resultsSet.begin();
+ ftit != resultsSet.end(); ++ftit) {
+ if (ftit->Status != cmCTestTestHandler::COMPLETED) {
ofs << ftit->TestCount << ":" << ftit->Name << std::endl;
- cmCTestLog(this->CTest, HANDLER_OUTPUT, "\t" << std::setw(3)
- << ftit->TestCount << " - "
- << ftit->Name << " ("
- << this->GetTestStatus(ftit->Status) << ")"
- << std::endl);
- }
+ cmCTestLog(
+ this->CTest, HANDLER_OUTPUT, "\t"
+ << std::setw(3) << ftit->TestCount << " - " << ftit->Name << " ("
+ << this->GetTestStatus(ftit->Status) << ")" << std::endl);
}
}
}
+ }
- if ( this->CTest->GetProduceXML() )
- {
+ if (this->CTest->GetProduceXML()) {
cmGeneratedFileStream xmlfile;
- if( !this->StartResultingXML(
+ if (!this->StartResultingXML(
(this->MemCheck ? cmCTest::PartMemCheck : cmCTest::PartTest),
- (this->MemCheck ? "DynamicAnalysis" : "Test"), xmlfile) )
- {
+ (this->MemCheck ? "DynamicAnalysis" : "Test"), xmlfile)) {
cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot create "
- << (this->MemCheck ? "memory check" : "testing")
- << " XML file" << std::endl);
+ << (this->MemCheck ? "memory check" : "testing")
+ << " XML file" << std::endl);
this->LogFile = 0;
return 1;
- }
+ }
cmXMLWriter xml(xmlfile);
this->GenerateDartOutput(xml);
- }
+ }
- if ( ! this->PostProcessHandler() )
- {
+ if (!this->PostProcessHandler()) {
this->LogFile = 0;
return -1;
- }
+ }
- if ( !failed.empty() )
- {
+ if (!failed.empty()) {
this->LogFile = 0;
return -1;
- }
+ }
this->LogFile = 0;
return 0;
}
@@ -644,146 +578,121 @@ void cmCTestTestHandler::PrintLabelSummary()
std::set<std::string> labels;
// initialize maps
std::string::size_type maxlen = 0;
- for(; it != this->TestList.end(); ++it)
- {
+ for (; it != this->TestList.end(); ++it) {
cmCTestTestProperties& p = *it;
- if(!p.Labels.empty())
- {
- for(std::vector<std::string>::iterator l = p.Labels.begin();
- l != p.Labels.end(); ++l)
- {
- if((*l).size() > maxlen)
- {
+ if (!p.Labels.empty()) {
+ for (std::vector<std::string>::iterator l = p.Labels.begin();
+ l != p.Labels.end(); ++l) {
+ if ((*l).size() > maxlen) {
maxlen = (*l).size();
- }
+ }
labels.insert(*l);
labelTimes[*l] = 0;
labelCounts[*l] = 0;
- }
}
}
+ }
cmCTestTestHandler::TestResultsVector::iterator ri =
- this->TestResults.begin();
+ this->TestResults.begin();
// fill maps
- for(; ri != this->TestResults.end(); ++ri)
- {
- cmCTestTestResult &result = *ri;
+ for (; ri != this->TestResults.end(); ++ri) {
+ cmCTestTestResult& result = *ri;
cmCTestTestProperties& p = *result.Properties;
- if(!p.Labels.empty())
- {
- for(std::vector<std::string>::iterator l = p.Labels.begin();
- l != p.Labels.end(); ++l)
- {
+ if (!p.Labels.empty()) {
+ for (std::vector<std::string>::iterator l = p.Labels.begin();
+ l != p.Labels.end(); ++l) {
labelTimes[*l] += result.ExecutionTime;
++labelCounts[*l];
- }
}
}
+ }
// now print times
- if(!labels.empty())
- {
+ if (!labels.empty()) {
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "\nLabel Time Summary:",
- this->Quiet);
- }
- for(std::set<std::string>::const_iterator i = labels.begin();
- i != labels.end(); ++i)
- {
+ this->Quiet);
+ }
+ for (std::set<std::string>::const_iterator i = labels.begin();
+ i != labels.end(); ++i) {
std::string label = *i;
- label.resize(maxlen +3, ' ');
+ label.resize(maxlen + 3, ' ');
char buf[1024];
sprintf(buf, "%6.2f sec", labelTimes[*i]);
std::ostringstream labelCountStr;
labelCountStr << "(" << labelCounts[*i] << " test";
- if (labelCounts[*i] > 1)
- {
+ if (labelCounts[*i] > 1) {
labelCountStr << "s";
- }
+ }
labelCountStr << ")";
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "\n"
- << label << " = " << buf << " " << labelCountStr.str(),
- this->Quiet );
- if ( this->LogFile )
- {
- *this->LogFile << "\n" << *i << " = "
- << buf << "\n";
- }
- }
- if(!labels.empty())
- {
- if(this->LogFile)
- {
+ << label << " = " << buf << " "
+ << labelCountStr.str(),
+ this->Quiet);
+ if (this->LogFile) {
+ *this->LogFile << "\n" << *i << " = " << buf << "\n";
+ }
+ }
+ if (!labels.empty()) {
+ if (this->LogFile) {
*this->LogFile << "\n";
- }
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "\n", this->Quiet);
}
-
+ cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "\n", this->Quiet);
+ }
}
void cmCTestTestHandler::CheckLabelFilterInclude(cmCTestTestProperties& it)
{
// if not using Labels to filter then return
- if (!this->UseIncludeLabelRegExpFlag )
- {
+ if (!this->UseIncludeLabelRegExpFlag) {
return;
- }
+ }
// if there are no labels and we are filtering by labels
// then exclude the test as it does not have the label
- if(it.Labels.empty())
- {
+ if (it.Labels.empty()) {
it.IsInBasedOnREOptions = false;
return;
- }
+ }
// check to see if the label regular expression matches
- bool found = false; // assume it does not match
+ bool found = false; // assume it does not match
// loop over all labels and look for match
- for(std::vector<std::string>::iterator l = it.Labels.begin();
- l != it.Labels.end(); ++l)
- {
- if(this->IncludeLabelRegularExpression.find(*l))
- {
+ for (std::vector<std::string>::iterator l = it.Labels.begin();
+ l != it.Labels.end(); ++l) {
+ if (this->IncludeLabelRegularExpression.find(*l)) {
found = true;
- }
}
+ }
// if no match was found, exclude the test
- if(!found)
- {
+ if (!found) {
it.IsInBasedOnREOptions = false;
- }
+ }
}
-
void cmCTestTestHandler::CheckLabelFilterExclude(cmCTestTestProperties& it)
{
// if not using Labels to filter then return
- if (!this->UseExcludeLabelRegExpFlag )
- {
+ if (!this->UseExcludeLabelRegExpFlag) {
return;
- }
+ }
// if there are no labels and we are excluding by labels
// then do nothing as a no label can not be a match
- if(it.Labels.empty())
- {
+ if (it.Labels.empty()) {
return;
- }
+ }
// check to see if the label regular expression matches
- bool found = false; // assume it does not match
+ bool found = false; // assume it does not match
// loop over all labels and look for match
- for(std::vector<std::string>::iterator l = it.Labels.begin();
- l != it.Labels.end(); ++l)
- {
- if(this->ExcludeLabelRegularExpression.find(*l))
- {
+ for (std::vector<std::string>::iterator l = it.Labels.begin();
+ l != it.Labels.end(); ++l) {
+ if (this->ExcludeLabelRegularExpression.find(*l)) {
found = true;
- }
}
+ }
// if match was found, exclude the test
- if(found)
- {
+ if (found) {
it.IsInBasedOnREOptions = false;
- }
+ }
}
void cmCTestTestHandler::CheckLabelFilter(cmCTestTestProperties& it)
@@ -797,70 +706,58 @@ void cmCTestTestHandler::ComputeTestList()
this->TestList.clear(); // clear list of test
this->GetListOfTests();
- if (this->RerunFailed)
- {
+ if (this->RerunFailed) {
this->ComputeTestListForRerunFailed();
return;
- }
+ }
cmCTestTestHandler::ListOfTests::size_type tmsize = this->TestList.size();
// how many tests are in based on RegExp?
int inREcnt = 0;
cmCTestTestHandler::ListOfTests::iterator it;
- for ( it = this->TestList.begin(); it != this->TestList.end(); it ++ )
- {
+ for (it = this->TestList.begin(); it != this->TestList.end(); it++) {
this->CheckLabelFilter(*it);
- if (it->IsInBasedOnREOptions)
- {
- inREcnt ++;
- }
+ if (it->IsInBasedOnREOptions) {
+ inREcnt++;
}
+ }
// expand the test list based on the union flag
- if (this->UseUnion)
- {
+ if (this->UseUnion) {
this->ExpandTestsToRunInformation((int)tmsize);
- }
- else
- {
+ } else {
this->ExpandTestsToRunInformation(inREcnt);
- }
+ }
// Now create a final list of tests to run
int cnt = 0;
inREcnt = 0;
std::string last_directory = "";
ListOfTests finalList;
- for ( it = this->TestList.begin(); it != this->TestList.end(); it ++ )
- {
- cnt ++;
- if (it->IsInBasedOnREOptions)
- {
+ for (it = this->TestList.begin(); it != this->TestList.end(); it++) {
+ cnt++;
+ if (it->IsInBasedOnREOptions) {
inREcnt++;
- }
+ }
- if (this->UseUnion)
- {
+ if (this->UseUnion) {
// if it is not in the list and not in the regexp then skip
if ((!this->TestsToRun.empty() &&
- std::find(this->TestsToRun.begin(), this->TestsToRun.end(), cnt)
- == this->TestsToRun.end()) && !it->IsInBasedOnREOptions)
- {
+ std::find(this->TestsToRun.begin(), this->TestsToRun.end(), cnt) ==
+ this->TestsToRun.end()) &&
+ !it->IsInBasedOnREOptions) {
continue;
- }
}
- else
- {
+ } else {
// is this test in the list of tests to run? If not then skip it
if ((!this->TestsToRun.empty() &&
- std::find(this->TestsToRun.begin(),
- this->TestsToRun.end(), inREcnt)
- == this->TestsToRun.end()) || !it->IsInBasedOnREOptions)
- {
+ std::find(this->TestsToRun.begin(), this->TestsToRun.end(),
+ inREcnt) == this->TestsToRun.end()) ||
+ !it->IsInBasedOnREOptions) {
continue;
- }
}
- it->Index = cnt; // save the index into the test list for this test
- finalList.push_back(*it);
}
+ it->Index = cnt; // save the index into the test list for this test
+ finalList.push_back(*it);
+ }
// Save the total number of tests before exclusions
this->TotalNumberOfTests = this->TestList.size();
// Set the TestList to the final list of all test
@@ -876,21 +773,19 @@ void cmCTestTestHandler::ComputeTestListForRerunFailed()
cmCTestTestHandler::ListOfTests::iterator it;
ListOfTests finalList;
int cnt = 0;
- for ( it = this->TestList.begin(); it != this->TestList.end(); it ++ )
- {
- cnt ++;
+ for (it = this->TestList.begin(); it != this->TestList.end(); it++) {
+ cnt++;
// if this test is not in our list of tests to run, then skip it.
if ((!this->TestsToRun.empty() &&
- std::find(this->TestsToRun.begin(), this->TestsToRun.end(), cnt)
- == this->TestsToRun.end()))
- {
+ std::find(this->TestsToRun.begin(), this->TestsToRun.end(), cnt) ==
+ this->TestsToRun.end())) {
continue;
- }
+ }
it->Index = cnt;
finalList.push_back(*it);
- }
+ }
// Save the total number of tests before exclusions
this->TotalNumberOfTests = this->TestList.size();
@@ -904,166 +799,135 @@ void cmCTestTestHandler::ComputeTestListForRerunFailed()
void cmCTestTestHandler::UpdateMaxTestNameWidth()
{
std::string::size_type max = this->CTest->GetMaxTestNameWidth();
- for ( cmCTestTestHandler::ListOfTests::iterator it = this->TestList.begin();
- it != this->TestList.end(); it ++ )
- {
+ for (cmCTestTestHandler::ListOfTests::iterator it = this->TestList.begin();
+ it != this->TestList.end(); it++) {
cmCTestTestProperties& p = *it;
- if(max < p.Name.size())
- {
+ if (max < p.Name.size()) {
max = p.Name.size();
- }
}
- if(static_cast<std::string::size_type>(this->CTest->GetMaxTestNameWidth())
- != max)
- {
+ }
+ if (static_cast<std::string::size_type>(
+ this->CTest->GetMaxTestNameWidth()) != max) {
this->CTest->SetMaxTestNameWidth(static_cast<int>(max));
- }
+ }
}
-bool cmCTestTestHandler::GetValue(const char* tag,
- int& value,
+bool cmCTestTestHandler::GetValue(const char* tag, int& value,
std::istream& fin)
{
std::string line;
bool ret = true;
cmSystemTools::GetLineFromStream(fin, line);
- if(line == tag)
- {
+ if (line == tag) {
fin >> value;
ret = cmSystemTools::GetLineFromStream(fin, line); // read blank line
- }
- else
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "parse error: missing tag: "
- << tag << " found [" << line << "]" << std::endl);
+ } else {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "parse error: missing tag: "
+ << tag << " found [" << line << "]" << std::endl);
ret = false;
- }
+ }
return ret;
}
-bool cmCTestTestHandler::GetValue(const char* tag,
- double& value,
+bool cmCTestTestHandler::GetValue(const char* tag, double& value,
std::istream& fin)
{
std::string line;
cmSystemTools::GetLineFromStream(fin, line);
bool ret = true;
- if(line == tag)
- {
+ if (line == tag) {
fin >> value;
ret = cmSystemTools::GetLineFromStream(fin, line); // read blank line
- }
- else
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "parse error: missing tag: "
- << tag << " found [" << line << "]" << std::endl);
+ } else {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "parse error: missing tag: "
+ << tag << " found [" << line << "]" << std::endl);
ret = false;
- }
+ }
return ret;
}
-bool cmCTestTestHandler::GetValue(const char* tag,
- bool& value,
+bool cmCTestTestHandler::GetValue(const char* tag, bool& value,
std::istream& fin)
{
std::string line;
cmSystemTools::GetLineFromStream(fin, line);
bool ret = true;
- if(line == tag)
- {
+ if (line == tag) {
#ifdef __HAIKU__
int tmp = 0;
fin >> tmp;
value = false;
- if(tmp)
- {
+ if (tmp) {
value = true;
- }
+ }
#else
fin >> value;
#endif
ret = cmSystemTools::GetLineFromStream(fin, line); // read blank line
- }
- else
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "parse error: missing tag: "
- << tag << " found [" << line << "]" << std::endl);
+ } else {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "parse error: missing tag: "
+ << tag << " found [" << line << "]" << std::endl);
ret = false;
- }
+ }
return ret;
}
-bool cmCTestTestHandler::GetValue(const char* tag,
- size_t& value,
+bool cmCTestTestHandler::GetValue(const char* tag, size_t& value,
std::istream& fin)
{
std::string line;
cmSystemTools::GetLineFromStream(fin, line);
bool ret = true;
- if(line == tag)
- {
+ if (line == tag) {
fin >> value;
ret = cmSystemTools::GetLineFromStream(fin, line); // read blank line
- }
- else
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "parse error: missing tag: "
- << tag << " found [" << line << "]" << std::endl);
+ } else {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "parse error: missing tag: "
+ << tag << " found [" << line << "]" << std::endl);
ret = false;
- }
+ }
return ret;
}
-bool cmCTestTestHandler::GetValue(const char* tag,
- std::string& value,
+bool cmCTestTestHandler::GetValue(const char* tag, std::string& value,
std::istream& fin)
{
std::string line;
cmSystemTools::GetLineFromStream(fin, line);
bool ret = true;
- if(line == tag)
- {
- ret = cmSystemTools::GetLineFromStream(fin, value);
- }
- else
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "parse error: missing tag: "
- << tag << " found [" << line << "]" << std::endl);
+ if (line == tag) {
+ ret = cmSystemTools::GetLineFromStream(fin, value);
+ } else {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "parse error: missing tag: "
+ << tag << " found [" << line << "]" << std::endl);
ret = false;
- }
+ }
return ret;
}
-void cmCTestTestHandler::ProcessDirectory(std::vector<std::string> &passed,
- std::vector<std::string> &failed)
+void cmCTestTestHandler::ProcessDirectory(std::vector<std::string>& passed,
+ std::vector<std::string>& failed)
{
this->ComputeTestList();
this->StartTest = this->CTest->CurrentTime();
this->StartTestTime = static_cast<unsigned int>(cmSystemTools::GetTime());
double elapsed_time_start = cmSystemTools::GetTime();
- cmCTestMultiProcessHandler* parallel = this->CTest->GetBatchJobs() ?
- new cmCTestBatchTestHandler : new cmCTestMultiProcessHandler;
+ cmCTestMultiProcessHandler* parallel = this->CTest->GetBatchJobs()
+ ? new cmCTestBatchTestHandler
+ : new cmCTestMultiProcessHandler;
parallel->SetCTest(this->CTest);
parallel->SetParallelLevel(this->CTest->GetParallelLevel());
parallel->SetTestHandler(this);
parallel->SetQuiet(this->Quiet);
- if(this->TestLoad > 0)
- {
+ if (this->TestLoad > 0) {
parallel->SetTestLoad(this->TestLoad);
- }
- else
- {
+ } else {
parallel->SetTestLoad(this->CTest->GetTestLoad());
- }
+ }
- *this->LogFile << "Start testing: "
- << this->CTest->CurrentTime() << std::endl
+ *this->LogFile
+ << "Start testing: " << this->CTest->CurrentTime() << std::endl
<< "----------------------------------------------------------"
<< std::endl;
@@ -1071,69 +935,55 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<std::string> &passed,
cmCTestMultiProcessHandler::PropertiesMap properties;
bool randomSchedule = this->CTest->GetScheduleType() == "Random";
- if(randomSchedule)
- {
+ if (randomSchedule) {
srand((unsigned)time(0));
- }
+ }
for (ListOfTests::iterator it = this->TestList.begin();
- it != this->TestList.end(); ++it)
- {
+ it != this->TestList.end(); ++it) {
cmCTestTestProperties& p = *it;
cmCTestMultiProcessHandler::TestSet depends;
- if(randomSchedule)
- {
+ if (randomSchedule) {
p.Cost = static_cast<float>(rand());
- }
+ }
- if(p.Timeout == 0 && this->CTest->GetGlobalTimeout() != 0)
- {
+ if (p.Timeout == 0 && this->CTest->GetGlobalTimeout() != 0) {
p.Timeout = this->CTest->GetGlobalTimeout();
- }
+ }
- if(!p.Depends.empty())
- {
- for(std::vector<std::string>::iterator i = p.Depends.begin();
- i != p.Depends.end(); ++i)
- {
- for(ListOfTests::iterator it2 = this->TestList.begin();
- it2 != this->TestList.end(); ++it2)
- {
- if(it2->Name == *i)
- {
+ if (!p.Depends.empty()) {
+ for (std::vector<std::string>::iterator i = p.Depends.begin();
+ i != p.Depends.end(); ++i) {
+ for (ListOfTests::iterator it2 = this->TestList.begin();
+ it2 != this->TestList.end(); ++it2) {
+ if (it2->Name == *i) {
depends.insert(it2->Index);
break; // break out of test loop as name can only match 1
- }
}
}
}
+ }
tests[it->Index] = depends;
properties[it->Index] = &*it;
- }
+ }
parallel->SetTests(tests, properties);
parallel->SetPassFailVectors(&passed, &failed);
this->TestResults.clear();
parallel->SetTestResults(&this->TestResults);
- if(this->CTest->ShouldPrintLabels())
- {
+ if (this->CTest->ShouldPrintLabels()) {
parallel->PrintLabels();
- }
- else if(this->CTest->GetShowOnly())
- {
+ } else if (this->CTest->GetShowOnly()) {
parallel->PrintTestList();
- }
- else
- {
+ } else {
parallel->RunTests();
- }
+ }
delete parallel;
this->EndTest = this->CTest->CurrentTime();
this->EndTestTime = static_cast<unsigned int>(cmSystemTools::GetTime());
this->ElapsedTestingTime = cmSystemTools::GetTime() - elapsed_time_start;
- *this->LogFile << "End testing: "
- << this->CTest->CurrentTime() << std::endl;
+ *this->LogFile << "End testing: " << this->CTest->CurrentTime() << std::endl;
}
void cmCTestTestHandler::GenerateTestCommand(std::vector<std::string>&, int)
@@ -1142,10 +992,9 @@ void cmCTestTestHandler::GenerateTestCommand(std::vector<std::string>&, int)
void cmCTestTestHandler::GenerateDartOutput(cmXMLWriter& xml)
{
- if ( !this->CTest->GetProduceXML() )
- {
+ if (!this->CTest->GetProduceXML()) {
return;
- }
+ }
this->CTest->StartXML(xml, this->AppendXML);
xml.StartElement("Testing");
@@ -1153,23 +1002,19 @@ void cmCTestTestHandler::GenerateDartOutput(cmXMLWriter& xml)
xml.Element("StartTestTime", this->StartTestTime);
xml.StartElement("TestList");
cmCTestTestHandler::TestResultsVector::size_type cc;
- for ( cc = 0; cc < this->TestResults.size(); cc ++ )
- {
- cmCTestTestResult *result = &this->TestResults[cc];
+ for (cc = 0; cc < this->TestResults.size(); cc++) {
+ cmCTestTestResult* result = &this->TestResults[cc];
std::string testPath = result->Path + "/" + result->Name;
xml.Element("Test", this->CTest->GetShortPathToFile(testPath.c_str()));
- }
+ }
xml.EndElement(); // TestList
- for ( cc = 0; cc < this->TestResults.size(); cc ++ )
- {
- cmCTestTestResult *result = &this->TestResults[cc];
+ for (cc = 0; cc < this->TestResults.size(); cc++) {
+ 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 )
- {
+ if (result->Status != cmCTestTestHandler::NOT_RUN) {
+ if (result->Status != cmCTestTestHandler::COMPLETED ||
+ result->ReturnValue) {
xml.StartElement("NamedMeasurement");
xml.Attribute("type", "text/string");
xml.Attribute("name", "Exit Code");
@@ -1180,56 +1025,51 @@ void cmCTestTestHandler::GenerateDartOutput(cmXMLWriter& xml)
xml.Attribute("name", "Exit Value");
xml.Element("Value", result->ReturnValue);
xml.EndElement(); // NamedMeasurement
- }
+ }
this->GenerateRegressionImages(xml, result->DartString);
xml.StartElement("NamedMeasurement");
xml.Attribute("type", "numeric/double");
xml.Attribute("name", "Execution Time");
xml.Element("Value", result->ExecutionTime);
xml.EndElement(); // NamedMeasurement
- if(!result->Reason.empty())
- {
+ if (!result->Reason.empty()) {
const char* reasonType = "Pass Reason";
- if(result->Status != cmCTestTestHandler::COMPLETED &&
- result->Status != cmCTestTestHandler::NOT_RUN)
- {
+ if (result->Status != cmCTestTestHandler::COMPLETED &&
+ result->Status != cmCTestTestHandler::NOT_RUN) {
reasonType = "Fail Reason";
- }
+ }
xml.StartElement("NamedMeasurement");
xml.Attribute("type", "text/string");
xml.Attribute("name", reasonType);
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", "Command Line");
xml.Element("Value", result->FullCommandLine);
xml.EndElement(); // NamedMeasurement
- std::map<std::string,std::string>::iterator measureIt;
- for ( measureIt = result->Properties->Measurements.begin();
- measureIt != result->Properties->Measurements.end();
- ++ measureIt )
- {
+ std::map<std::string, std::string>::iterator measureIt;
+ for (measureIt = result->Properties->Measurements.begin();
+ measureIt != result->Properties->Measurements.end(); ++measureIt) {
xml.StartElement("NamedMeasurement");
xml.Attribute("type", "text/string");
xml.Attribute("name", measureIt->first);
xml.Element("Value", measureIt->second);
xml.EndElement(); // NamedMeasurement
- }
+ }
xml.StartElement("Measurement");
xml.StartElement("Value");
- if (result->CompressOutput)
- {
+ if (result->CompressOutput) {
xml.Attribute("encoding", "base64");
xml.Attribute("compression", "gzip");
- }
+ }
xml.Content(result->Output);
xml.EndElement(); // Value
xml.EndElement(); // Measurement
@@ -1237,12 +1077,12 @@ void cmCTestTestHandler::GenerateDartOutput(cmXMLWriter& xml)
this->AttachFiles(xml, result);
this->WriteTestResultFooter(xml, result);
- }
+ }
xml.Element("EndDateTime", this->EndTest);
xml.Element("EndTestTime", this->EndTestTime);
xml.Element("ElapsedMinutes",
- static_cast<int>(this->ElapsedTestingTime/6)/10.0);
+ static_cast<int>(this->ElapsedTestingTime / 6) / 10.0);
xml.EndElement(); // Testing
this->CTest->EndXML(xml);
}
@@ -1251,18 +1091,13 @@ void cmCTestTestHandler::WriteTestResultHeader(cmXMLWriter& xml,
cmCTestTestResult* result)
{
xml.StartElement("Test");
- if ( result->Status == cmCTestTestHandler::COMPLETED )
- {
+ if (result->Status == cmCTestTestHandler::COMPLETED) {
xml.Attribute("Status", "passed");
- }
- else if ( result->Status == cmCTestTestHandler::NOT_RUN )
- {
+ } else if (result->Status == cmCTestTestHandler::NOT_RUN) {
xml.Attribute("Status", "notrun");
- }
- else
- {
+ } else {
xml.Attribute("Status", "failed");
- }
+ }
std::string testPath = result->Path + "/" + result->Name;
xml.Element("Name", result->Name);
xml.Element("Path", this->CTest->GetShortPathToFile(result->Path.c_str()));
@@ -1273,17 +1108,15 @@ void cmCTestTestHandler::WriteTestResultHeader(cmXMLWriter& xml,
void cmCTestTestHandler::WriteTestResultFooter(cmXMLWriter& xml,
cmCTestTestResult* result)
{
- if(!result->Properties->Labels.empty())
- {
+ if (!result->Properties->Labels.empty()) {
xml.StartElement("Labels");
std::vector<std::string> const& labels = result->Properties->Labels;
- for(std::vector<std::string>::const_iterator li = labels.begin();
- li != labels.end(); ++li)
- {
+ for (std::vector<std::string>::const_iterator li = labels.begin();
+ li != labels.end(); ++li) {
xml.Element("Label", *li);
- }
- xml.EndElement(); // Labels
}
+ xml.EndElement(); // Labels
+ }
xml.EndElement(); // Test
}
@@ -1291,19 +1124,17 @@ void cmCTestTestHandler::WriteTestResultFooter(cmXMLWriter& xml,
void cmCTestTestHandler::AttachFiles(cmXMLWriter& xml,
cmCTestTestResult* result)
{
- if(result->Status != cmCTestTestHandler::COMPLETED
- && result->Properties->AttachOnFail.size())
- {
+ if (result->Status != cmCTestTestHandler::COMPLETED &&
+ result->Properties->AttachOnFail.size()) {
result->Properties->AttachedFiles.insert(
result->Properties->AttachedFiles.end(),
result->Properties->AttachOnFail.begin(),
result->Properties->AttachOnFail.end());
- }
- for(std::vector<std::string>::const_iterator file =
- result->Properties->AttachedFiles.begin();
- file != result->Properties->AttachedFiles.end(); ++file)
- {
- const std::string &base64 = this->CTest->Base64GzipEncodeFile(*file);
+ }
+ for (std::vector<std::string>::const_iterator file =
+ result->Properties->AttachedFiles.begin();
+ file != result->Properties->AttachedFiles.end(); ++file) {
+ const std::string& base64 = this->CTest->Base64GzipEncodeFile(*file);
std::string fname = cmSystemTools::GetFilenameName(*file);
xml.StartElement("NamedMeasurement");
xml.Attribute("name", "Attached File");
@@ -1313,67 +1144,57 @@ void cmCTestTestHandler::AttachFiles(cmXMLWriter& xml,
xml.Attribute("type", "file");
xml.Element("Value", base64);
xml.EndElement(); // NamedMeasurement
- }
+ }
}
int cmCTestTestHandler::ExecuteCommands(std::vector<std::string>& vec)
{
std::vector<std::string>::iterator it;
- for ( it = vec.begin(); it != vec.end(); ++it )
- {
+ for (it = vec.begin(); it != vec.end(); ++it) {
int retVal = 0;
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run command: " <<
- *it << std::endl, this->Quiet);
- if ( !cmSystemTools::RunSingleCommand(it->c_str(), 0, 0, &retVal, 0,
- cmSystemTools::OUTPUT_MERGE
- /*this->Verbose*/) || retVal != 0 )
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Problem running command: "
- << *it << std::endl);
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Run command: " << *it << std::endl, this->Quiet);
+ if (!cmSystemTools::RunSingleCommand(it->c_str(), 0, 0, &retVal, 0,
+ cmSystemTools::OUTPUT_MERGE
+ /*this->Verbose*/) ||
+ retVal != 0) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Problem running command: " << *it << std::endl);
return 0;
- }
}
+ }
return 1;
}
-
// Find the appropriate executable to run for a test
-std::string cmCTestTestHandler::FindTheExecutable(const char *exe)
+std::string cmCTestTestHandler::FindTheExecutable(const char* exe)
{
std::string resConfig;
std::vector<std::string> extraPaths;
std::vector<std::string> failedPaths;
- if(strcmp(exe, "NOT_AVAILABLE") == 0)
- {
+ if (strcmp(exe, "NOT_AVAILABLE") == 0) {
return exe;
- }
- return cmCTestTestHandler::FindExecutable(this->CTest,
- exe, resConfig,
- extraPaths,
- failedPaths);
+ }
+ return cmCTestTestHandler::FindExecutable(this->CTest, exe, resConfig,
+ extraPaths, failedPaths);
}
// add additional configurations to the search path
-void cmCTestTestHandler
-::AddConfigurations(cmCTest *ctest,
- std::vector<std::string> &attempted,
- std::vector<std::string> &attemptedConfigs,
- std::string filepath,
- std::string &filename)
+void cmCTestTestHandler::AddConfigurations(
+ cmCTest* ctest, std::vector<std::string>& attempted,
+ std::vector<std::string>& attemptedConfigs, std::string filepath,
+ std::string& filename)
{
std::string tempPath;
- if (!filepath.empty() &&
- filepath[filepath.size()-1] != '/')
- {
+ if (!filepath.empty() && filepath[filepath.size() - 1] != '/') {
filepath += "/";
- }
+ }
tempPath = filepath + filename;
attempted.push_back(tempPath);
attemptedConfigs.push_back("");
- if(!ctest->GetConfigType().empty())
- {
+ if (!ctest->GetConfigType().empty()) {
tempPath = filepath;
tempPath += ctest->GetConfigType();
tempPath += "/";
@@ -1388,9 +1209,7 @@ void cmCTestTestHandler
tempPath += filename;
attempted.push_back(tempPath);
attemptedConfigs.push_back(ctest->GetConfigType());
- }
- else
- {
+ } else {
// no config specified - try some options...
tempPath = filepath;
tempPath += "Release/";
@@ -1422,141 +1241,111 @@ void cmCTestTestHandler
tempPath += filename;
attempted.push_back(tempPath);
attemptedConfigs.push_back("Deployment");
- }
+ }
}
-
// Find the appropriate executable to run for a test
-std::string cmCTestTestHandler
-::FindExecutable(cmCTest *ctest,
- const char *testCommand,
- std::string &resultingConfig,
- std::vector<std::string> &extraPaths,
- std::vector<std::string> &failed)
+std::string cmCTestTestHandler::FindExecutable(
+ cmCTest* ctest, const char* testCommand, std::string& resultingConfig,
+ std::vector<std::string>& extraPaths, std::vector<std::string>& failed)
{
// now run the compiled test if we can find it
std::vector<std::string> attempted;
std::vector<std::string> attemptedConfigs;
std::string tempPath;
- std::string filepath =
- cmSystemTools::GetFilenamePath(testCommand);
- std::string filename =
- cmSystemTools::GetFilenameName(testCommand);
+ std::string filepath = cmSystemTools::GetFilenamePath(testCommand);
+ std::string filename = cmSystemTools::GetFilenameName(testCommand);
- cmCTestTestHandler::AddConfigurations(ctest, attempted,
- attemptedConfigs,
- filepath,filename);
+ cmCTestTestHandler::AddConfigurations(ctest, attempted, attemptedConfigs,
+ filepath, filename);
// even if a fullpath was specified also try it relative to the current
// directory
- if (!filepath.empty() && filepath[0] == '/')
- {
- std::string localfilepath = filepath.substr(1,filepath.size()-1);
- cmCTestTestHandler::AddConfigurations(ctest, attempted,
- attemptedConfigs,
- localfilepath,filename);
- }
-
+ if (!filepath.empty() && filepath[0] == '/') {
+ std::string localfilepath = filepath.substr(1, filepath.size() - 1);
+ cmCTestTestHandler::AddConfigurations(ctest, attempted, attemptedConfigs,
+ localfilepath, filename);
+ }
// if extraPaths are provided and we were not passed a full path, try them,
// try any extra paths
- if (filepath.empty())
- {
- for (unsigned int i = 0; i < extraPaths.size(); ++i)
- {
+ if (filepath.empty()) {
+ for (unsigned int i = 0; i < extraPaths.size(); ++i) {
std::string filepathExtra =
cmSystemTools::GetFilenamePath(extraPaths[i]);
std::string filenameExtra =
cmSystemTools::GetFilenameName(extraPaths[i]);
- cmCTestTestHandler::AddConfigurations(ctest,attempted,
- attemptedConfigs,
- filepathExtra,
- filenameExtra);
- }
+ cmCTestTestHandler::AddConfigurations(ctest, attempted, attemptedConfigs,
+ filepathExtra, filenameExtra);
}
+ }
// store the final location in fullPath
std::string fullPath;
// now look in the paths we specified above
- for(unsigned int ai=0;
- ai < attempted.size() && fullPath.empty(); ++ai)
- {
+ for (unsigned int ai = 0; ai < attempted.size() && fullPath.empty(); ++ai) {
// first check without exe extension
- if(cmSystemTools::FileExists(attempted[ai].c_str())
- && !cmSystemTools::FileIsDirectory(attempted[ai]))
- {
+ if (cmSystemTools::FileExists(attempted[ai].c_str()) &&
+ !cmSystemTools::FileIsDirectory(attempted[ai])) {
fullPath = cmSystemTools::CollapseFullPath(attempted[ai]);
resultingConfig = attemptedConfigs[ai];
- }
+ }
// then try with the exe extension
- else
- {
+ else {
failed.push_back(attempted[ai]);
tempPath = attempted[ai];
tempPath += cmSystemTools::GetExecutableExtension();
- if(cmSystemTools::FileExists(tempPath.c_str())
- && !cmSystemTools::FileIsDirectory(tempPath))
- {
+ if (cmSystemTools::FileExists(tempPath.c_str()) &&
+ !cmSystemTools::FileIsDirectory(tempPath)) {
fullPath = cmSystemTools::CollapseFullPath(tempPath);
resultingConfig = attemptedConfigs[ai];
- }
- else
- {
+ } else {
failed.push_back(tempPath);
- }
}
}
+ }
// if everything else failed, check the users path, but only if a full path
// wasn't specified
- if (fullPath.empty() && filepath.empty())
- {
+ if (fullPath.empty() && filepath.empty()) {
std::string path = cmSystemTools::FindProgram(filename.c_str());
- if (path != "")
- {
+ if (path != "") {
resultingConfig = "";
return path;
- }
}
- if(fullPath.empty())
- {
- cmCTestLog(ctest, HANDLER_OUTPUT,
- "Could not find executable " << testCommand << "\n"
- << "Looked in the following places:\n");
- for(std::vector<std::string>::iterator i = failed.begin();
- i != failed.end(); ++i)
- {
+ }
+ if (fullPath.empty()) {
+ cmCTestLog(ctest, HANDLER_OUTPUT, "Could not find executable "
+ << testCommand << "\n"
+ << "Looked in the following places:\n");
+ for (std::vector<std::string>::iterator i = failed.begin();
+ i != failed.end(); ++i) {
cmCTestLog(ctest, HANDLER_OUTPUT, i->c_str() << "\n");
- }
}
+ }
return fullPath;
}
-
void cmCTestTestHandler::GetListOfTests()
{
- if ( !this->IncludeLabelRegExp.empty() )
- {
- this->IncludeLabelRegularExpression.
- compile(this->IncludeLabelRegExp.c_str());
- }
- if ( !this->ExcludeLabelRegExp.empty() )
- {
- this->ExcludeLabelRegularExpression.
- compile(this->ExcludeLabelRegExp.c_str());
- }
- if ( !this->IncludeRegExp.empty() )
- {
+ if (!this->IncludeLabelRegExp.empty()) {
+ this->IncludeLabelRegularExpression.compile(
+ this->IncludeLabelRegExp.c_str());
+ }
+ if (!this->ExcludeLabelRegExp.empty()) {
+ this->ExcludeLabelRegularExpression.compile(
+ this->ExcludeLabelRegExp.c_str());
+ }
+ if (!this->IncludeRegExp.empty()) {
this->IncludeTestsRegularExpression.compile(this->IncludeRegExp.c_str());
- }
- if ( !this->ExcludeRegExp.empty() )
- {
+ }
+ if (!this->ExcludeRegExp.empty()) {
this->ExcludeTestsRegularExpression.compile(this->ExcludeRegExp.c_str());
- }
+ }
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Constructing a list of tests" << std::endl, this->Quiet);
+ "Constructing a list of tests" << std::endl, this->Quiet);
cmake cm;
cm.SetHomeDirectory("");
cm.SetHomeOutputDirectory("");
@@ -1564,7 +1353,7 @@ void cmCTestTestHandler::GetListOfTests()
cmGlobalGenerator gg(&cm);
cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(&gg, cm.GetCurrentSnapshot()));
mf->AddDefinition("CTEST_CONFIGURATION_TYPE",
- this->CTest->GetConfigType().c_str());
+ this->CTest->GetConfigType().c_str());
// Add handler for ADD_TEST
cmCTestAddTestCommand* newCom1 = new cmCTestAddTestCommand;
@@ -1572,49 +1361,41 @@ void cmCTestTestHandler::GetListOfTests()
cm.GetState()->AddCommand(newCom1);
// Add handler for SUBDIRS
- cmCTestSubdirCommand* newCom2 =
- new cmCTestSubdirCommand;
+ cmCTestSubdirCommand* newCom2 = new cmCTestSubdirCommand;
newCom2->TestHandler = this;
cm.GetState()->AddCommand(newCom2);
// Add handler for ADD_SUBDIRECTORY
- cmCTestAddSubdirectoryCommand* newCom3 =
- new cmCTestAddSubdirectoryCommand;
+ cmCTestAddSubdirectoryCommand* newCom3 = new cmCTestAddSubdirectoryCommand;
newCom3->TestHandler = this;
cm.GetState()->AddCommand(newCom3);
// Add handler for SET_SOURCE_FILES_PROPERTIES
- cmCTestSetTestsPropertiesCommand* newCom4
- = new cmCTestSetTestsPropertiesCommand;
+ cmCTestSetTestsPropertiesCommand* newCom4 =
+ new cmCTestSetTestsPropertiesCommand;
newCom4->TestHandler = this;
cm.GetState()->AddCommand(newCom4);
const char* testFilename;
- if( cmSystemTools::FileExists("CTestTestfile.cmake") )
- {
+ if (cmSystemTools::FileExists("CTestTestfile.cmake")) {
// does the CTestTestfile.cmake exist ?
testFilename = "CTestTestfile.cmake";
- }
- else if( cmSystemTools::FileExists("DartTestfile.txt") )
- {
+ } else if (cmSystemTools::FileExists("DartTestfile.txt")) {
// does the DartTestfile.txt exist ?
testFilename = "DartTestfile.txt";
- }
- else
- {
+ } else {
return;
- }
+ }
- if ( !mf->ReadListFile(testFilename) )
- {
+ if (!mf->ReadListFile(testFilename)) {
return;
- }
- if ( cmSystemTools::GetErrorOccuredFlag() )
- {
+ }
+ if (cmSystemTools::GetErrorOccuredFlag()) {
return;
- }
+ }
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Done constructing a list of tests" << std::endl, this->Quiet);
+ "Done constructing a list of tests" << std::endl,
+ this->Quiet);
}
void cmCTestTestHandler::UseIncludeRegExp()
@@ -1631,32 +1412,22 @@ 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"
+ "Not Run", "Timeout", "SEGFAULT", "ILLEGAL", "INTERRUPT",
+ "NUMERICAL", "OTHER_FAULT", "Failed", "BAD_COMMAND", "Completed"
};
- if ( status < cmCTestTestHandler::NOT_RUN ||
- status > cmCTestTestHandler::COMPLETED )
- {
+ if (status < cmCTestTestHandler::NOT_RUN ||
+ status > cmCTestTestHandler::COMPLETED) {
return "No Status";
- }
+ }
return statuses[status];
}
void cmCTestTestHandler::ExpandTestsToRunInformation(size_t numTests)
{
- if (this->TestsToRunString.empty())
- {
+ if (this->TestsToRunString.empty()) {
return;
- }
+ }
int start;
int end = -1;
@@ -1664,57 +1435,48 @@ void cmCTestTestHandler::ExpandTestsToRunInformation(size_t numTests)
std::string::size_type pos = 0;
std::string::size_type pos2;
// read start
- if(GetNextNumber(this->TestsToRunString, start, pos, pos2))
- {
+ if (GetNextNumber(this->TestsToRunString, start, pos, pos2)) {
// read end
- if(GetNextNumber(this->TestsToRunString, end, pos, pos2))
- {
+ if (GetNextNumber(this->TestsToRunString, end, pos, pos2)) {
// read stride
- if(GetNextRealNumber(this->TestsToRunString, stride, pos, pos2))
- {
- int val =0;
+ if (GetNextRealNumber(this->TestsToRunString, stride, pos, pos2)) {
+ int val = 0;
// now read specific numbers
- while(GetNextNumber(this->TestsToRunString, val, pos, pos2))
- {
+ while (GetNextNumber(this->TestsToRunString, val, pos, pos2)) {
this->TestsToRun.push_back(val);
- }
- this->TestsToRun.push_back(val);
}
+ this->TestsToRun.push_back(val);
}
}
+ }
// if start is not specified then we assume we start at 1
- if(start == -1)
- {
+ if (start == -1) {
start = 1;
- }
+ }
// if end isnot specified then we assume we end with the last test
- if(end == -1)
- {
+ if (end == -1) {
end = static_cast<int>(numTests);
- }
+ }
// if the stride wasn't specified then it defaults to 1
- if(stride == -1)
- {
+ if (stride == -1) {
stride = 1;
- }
+ }
// if we have a range then add it
- if(end != -1 && start != -1 && stride > 0)
- {
+ if (end != -1 && start != -1 && stride > 0) {
int i = 0;
- while (i*stride + start <= end)
- {
- this->TestsToRun.push_back(static_cast<int>(i*stride+start));
+ while (i * stride + start <= end) {
+ this->TestsToRun.push_back(static_cast<int>(i * stride + start));
++i;
- }
}
+ }
// sort the array
std::sort(this->TestsToRun.begin(), this->TestsToRun.end(),
- std::less<int>());
+ std::less<int>());
// remove duplicates
std::vector<int>::iterator new_end =
std::unique(this->TestsToRun.begin(), this->TestsToRun.end());
@@ -1727,141 +1489,120 @@ void cmCTestTestHandler::ExpandTestsToRunInformationForRerunFailed()
std::string dirName = this->CTest->GetBinaryDir() + "/Testing/Temporary";
cmsys::Directory directory;
- if (directory.Load(dirName) == 0)
- {
+ if (directory.Load(dirName) == 0) {
cmCTestLog(this->CTest, ERROR_MESSAGE, "Unable to read the contents of "
- << dirName << std::endl);
+ << dirName << std::endl);
return;
- }
+ }
- int numFiles = static_cast<int>
- (cmsys::Directory::GetNumberOfFilesInDirectory(dirName));
+ int numFiles =
+ static_cast<int>(cmsys::Directory::GetNumberOfFilesInDirectory(dirName));
std::string pattern = "LastTestsFailed";
std::string logName = "";
- for (int i = 0; i < numFiles; ++i)
- {
+ for (int i = 0; i < numFiles; ++i) {
std::string fileName = directory.GetFile(i);
// bcc crashes if we attempt a normal substring comparison,
// hence the following workaround
std::string fileNameSubstring = fileName.substr(0, pattern.length());
- if (fileNameSubstring.compare(pattern) != 0)
- {
+ if (fileNameSubstring.compare(pattern) != 0) {
continue;
- }
- if (logName == "")
- {
+ }
+ if (logName == "") {
logName = fileName;
- }
- else
- {
+ } else {
// if multiple matching logs were found we use the most recently
// modified one.
int res;
cmSystemTools::FileTimeCompare(logName, fileName, &res);
- if (res == -1)
- {
+ if (res == -1) {
logName = fileName;
- }
}
}
+ }
- std::string lastTestsFailedLog = this->CTest->GetBinaryDir()
- + "/Testing/Temporary/" + logName;
+ std::string lastTestsFailedLog =
+ this->CTest->GetBinaryDir() + "/Testing/Temporary/" + logName;
- if ( !cmSystemTools::FileExists(lastTestsFailedLog.c_str()) )
- {
- if ( !this->CTest->GetShowOnly() && !this->CTest->ShouldPrintLabels() )
- {
+ if (!cmSystemTools::FileExists(lastTestsFailedLog.c_str())) {
+ if (!this->CTest->GetShowOnly() && !this->CTest->ShouldPrintLabels()) {
cmCTestLog(this->CTest, ERROR_MESSAGE, lastTestsFailedLog
- << " does not exist!" << std::endl);
- }
- return;
+ << " does not exist!" << std::endl);
}
+ return;
+ }
// parse the list of tests to rerun from LastTestsFailed.log
cmsys::ifstream ifs(lastTestsFailedLog.c_str());
- if ( ifs )
- {
+ if (ifs) {
std::string line;
std::string::size_type pos;
- while ( cmSystemTools::GetLineFromStream(ifs, line) )
- {
+ while (cmSystemTools::GetLineFromStream(ifs, line)) {
pos = line.find(':', 0);
- if (pos == line.npos)
- {
+ if (pos == line.npos) {
continue;
- }
+ }
int val = atoi(line.substr(0, pos).c_str());
this->TestsToRun.push_back(val);
- }
- ifs.close();
}
- else if ( !this->CTest->GetShowOnly() && !this->CTest->ShouldPrintLabels() )
- {
+ ifs.close();
+ } else if (!this->CTest->GetShowOnly() &&
+ !this->CTest->ShouldPrintLabels()) {
cmCTestLog(this->CTest, ERROR_MESSAGE, "Problem reading file: "
- << lastTestsFailedLog <<
- " while generating list of previously failed tests." << std::endl);
- }
+ << lastTestsFailedLog
+ << " while generating list of previously failed tests."
+ << std::endl);
+ }
}
// Just for convenience
#define SPACE_REGEX "[ \t\r\n]"
-void cmCTestTestHandler::GenerateRegressionImages(
- cmXMLWriter& xml, const std::string& dart)
+void cmCTestTestHandler::GenerateRegressionImages(cmXMLWriter& xml,
+ const std::string& dart)
{
cmsys::RegularExpression twoattributes(
- "<DartMeasurement"
- SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\""
- SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\""
- SPACE_REGEX "*>([^<]*)</DartMeasurement>");
+ "<DartMeasurement" SPACE_REGEX
+ "*(name|type|encoding|compression)=\"([^\"]*)\"" SPACE_REGEX
+ "*(name|type|encoding|compression)=\"([^\"]*)\"" SPACE_REGEX
+ "*>([^<]*)</DartMeasurement>");
cmsys::RegularExpression threeattributes(
- "<DartMeasurement"
- SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\""
- SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\""
- SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\""
- SPACE_REGEX "*>([^<]*)</DartMeasurement>");
+ "<DartMeasurement" SPACE_REGEX
+ "*(name|type|encoding|compression)=\"([^\"]*)\"" SPACE_REGEX
+ "*(name|type|encoding|compression)=\"([^\"]*)\"" SPACE_REGEX
+ "*(name|type|encoding|compression)=\"([^\"]*)\"" SPACE_REGEX
+ "*>([^<]*)</DartMeasurement>");
cmsys::RegularExpression fourattributes(
- "<DartMeasurement"
- SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\""
- SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\""
- SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\""
- SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\""
- SPACE_REGEX "*>([^<]*)</DartMeasurement>");
+ "<DartMeasurement" SPACE_REGEX
+ "*(name|type|encoding|compression)=\"([^\"]*)\"" SPACE_REGEX
+ "*(name|type|encoding|compression)=\"([^\"]*)\"" SPACE_REGEX
+ "*(name|type|encoding|compression)=\"([^\"]*)\"" SPACE_REGEX
+ "*(name|type|encoding|compression)=\"([^\"]*)\"" SPACE_REGEX
+ "*>([^<]*)</DartMeasurement>");
cmsys::RegularExpression cdatastart(
- "<DartMeasurement"
- SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\""
- SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\""
- SPACE_REGEX "*>"
- SPACE_REGEX "*<!\\[CDATA\\[");
- cmsys::RegularExpression cdataend(
- "]]>"
- SPACE_REGEX "*</DartMeasurement>");
+ "<DartMeasurement" SPACE_REGEX
+ "*(name|type|encoding|compression)=\"([^\"]*)\"" SPACE_REGEX
+ "*(name|type|encoding|compression)=\"([^\"]*)\"" SPACE_REGEX
+ "*>" SPACE_REGEX "*<!\\[CDATA\\[");
+ cmsys::RegularExpression cdataend("]]>" SPACE_REGEX "*</DartMeasurement>");
cmsys::RegularExpression measurementfile(
- "<DartMeasurementFile"
- SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\""
- SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\""
- SPACE_REGEX "*>([^<]*)</DartMeasurementFile>");
+ "<DartMeasurementFile" SPACE_REGEX
+ "*(name|type|encoding|compression)=\"([^\"]*)\"" SPACE_REGEX
+ "*(name|type|encoding|compression)=\"([^\"]*)\"" SPACE_REGEX
+ "*>([^<]*)</DartMeasurementFile>");
bool done = false;
std::string cxml = dart;
- while ( ! done )
- {
- if ( twoattributes.find(cxml) )
- {
+ while (!done) {
+ if (twoattributes.find(cxml)) {
xml.StartElement("NamedMeasurement");
- xml.Attribute(twoattributes.match(1).c_str(),
- twoattributes.match(2));
- xml.Attribute(twoattributes.match(3).c_str(),
- twoattributes.match(4));
+ xml.Attribute(twoattributes.match(1).c_str(), twoattributes.match(2));
+ xml.Attribute(twoattributes.match(3).c_str(), twoattributes.match(4));
xml.Element("Value", twoattributes.match(5));
xml.EndElement();
cxml.erase(twoattributes.start(),
- twoattributes.end() - twoattributes.start());
- }
- else if ( threeattributes.find(cxml) )
- {
+ twoattributes.end() - twoattributes.start());
+ } else if (threeattributes.find(cxml)) {
xml.StartElement("NamedMeasurement");
xml.Attribute(threeattributes.match(1).c_str(),
threeattributes.match(2));
@@ -1872,58 +1613,43 @@ void cmCTestTestHandler::GenerateRegressionImages(
xml.Element("Value", twoattributes.match(7));
xml.EndElement();
cxml.erase(threeattributes.start(),
- threeattributes.end() - threeattributes.start());
- }
- else if ( fourattributes.find(cxml) )
- {
+ threeattributes.end() - threeattributes.start());
+ } else if (fourattributes.find(cxml)) {
xml.StartElement("NamedMeasurement");
- xml.Attribute(fourattributes.match(1).c_str(),
- fourattributes.match(2));
- xml.Attribute(fourattributes.match(3).c_str(),
- fourattributes.match(4));
- xml.Attribute(fourattributes.match(5).c_str(),
- fourattributes.match(6));
- xml.Attribute(fourattributes.match(7).c_str(),
- fourattributes.match(8));
+ xml.Attribute(fourattributes.match(1).c_str(), fourattributes.match(2));
+ xml.Attribute(fourattributes.match(3).c_str(), fourattributes.match(4));
+ xml.Attribute(fourattributes.match(5).c_str(), fourattributes.match(6));
+ xml.Attribute(fourattributes.match(7).c_str(), fourattributes.match(8));
xml.Element("Value", twoattributes.match(9));
xml.EndElement();
cxml.erase(fourattributes.start(),
- fourattributes.end() - fourattributes.start());
- }
- else if ( cdatastart.find(cxml) && cdataend.find(cxml) )
- {
+ fourattributes.end() - fourattributes.start());
+ } else if (cdatastart.find(cxml) && cdataend.find(cxml)) {
xml.StartElement("NamedMeasurement");
xml.Attribute(cdatastart.match(1).c_str(), cdatastart.match(2));
xml.Attribute(cdatastart.match(3).c_str(), cdatastart.match(4));
xml.StartElement("Value");
xml.CData(
- cxml.substr(cdatastart.end(), cdataend.start() - cdatastart.end()));
+ cxml.substr(cdatastart.end(), cdataend.start() - cdatastart.end()));
xml.EndElement(); // Value
xml.EndElement(); // NamedMeasurement
- cxml.erase(cdatastart.start(),
- cdataend.end() - cdatastart.start());
- }
- else if ( measurementfile.find(cxml) )
- {
+ cxml.erase(cdatastart.start(), cdataend.end() - cdatastart.start());
+ } else if (measurementfile.find(cxml)) {
const std::string& filename =
cmCTest::CleanString(measurementfile.match(5));
- if ( cmSystemTools::FileExists(filename.c_str()) )
- {
+ if (cmSystemTools::FileExists(filename.c_str())) {
long len = cmSystemTools::FileLength(filename);
- if ( len == 0 )
- {
+ if (len == 0) {
std::string k1 = measurementfile.match(1);
std::string v1 = measurementfile.match(2);
std::string k2 = measurementfile.match(3);
std::string v2 = measurementfile.match(4);
- if ( cmSystemTools::LowerCase(k1) == "type" )
- {
+ if (cmSystemTools::LowerCase(k1) == "type") {
v1 = "text/string";
- }
- if ( cmSystemTools::LowerCase(k2) == "type" )
- {
+ }
+ if (cmSystemTools::LowerCase(k2) == "type") {
v2 = "text/string";
- }
+ }
xml.StartElement("NamedMeasurement");
xml.Attribute(k1.c_str(), v1);
@@ -1931,22 +1657,19 @@ void cmCTestTestHandler::GenerateRegressionImages(
xml.Attribute("encoding", "none");
xml.Element("Value", "Image " + filename + " is empty");
xml.EndElement();
- }
- else
- {
+ } else {
cmsys::ifstream ifs(filename.c_str(), std::ios::in
#ifdef _WIN32
- | std::ios::binary
+ | std::ios::binary
#endif
- );
- unsigned char *file_buffer = new unsigned char [ len + 1 ];
+ );
+ unsigned char* file_buffer = new unsigned char[len + 1];
ifs.read(reinterpret_cast<char*>(file_buffer), len);
- unsigned char *encoded_buffer
- = new unsigned char [ static_cast<int>(
- static_cast<double>(len) * 1.5 + 5.0) ];
+ unsigned char* encoded_buffer = new unsigned char[static_cast<int>(
+ static_cast<double>(len) * 1.5 + 5.0)];
- size_t rlen
- = cmsysBase64_Encode(file_buffer, len, encoded_buffer, 1);
+ size_t rlen =
+ cmsysBase64_Encode(file_buffer, len, encoded_buffer, 1);
xml.StartElement("NamedMeasurement");
xml.Attribute(measurementfile.match(1).c_str(),
@@ -1955,83 +1678,74 @@ void cmCTestTestHandler::GenerateRegressionImages(
measurementfile.match(4));
xml.Attribute("encoding", "base64");
std::stringstream ostr;
- for (size_t cc = 0; cc < rlen; cc ++ )
- {
+ for (size_t cc = 0; cc < rlen; cc++) {
ostr << encoded_buffer[cc];
- if ( cc % 60 == 0 && cc )
- {
+ if (cc % 60 == 0 && cc) {
ostr << std::endl;
- }
}
+ }
xml.Element("Value", ostr.str());
xml.EndElement(); // NamedMeasurement
- delete [] file_buffer;
- delete [] encoded_buffer;
- }
+ delete[] file_buffer;
+ delete[] encoded_buffer;
}
- else
- {
+ } else {
int idx = 4;
- if ( measurementfile.match(1) == "name" )
- {
+ if (measurementfile.match(1) == "name") {
idx = 2;
- }
+ }
xml.StartElement("NamedMeasurement");
xml.Attribute("name", measurementfile.match(idx));
xml.Attribute("text", "text/string");
xml.Element("Value", "File " + filename + " not found");
xml.EndElement();
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "File \"" << filename
- << "\" not found." << std::endl, this->Quiet);
- }
- cxml.erase(measurementfile.start(),
- measurementfile.end() - measurementfile.start());
+ cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "File \""
+ << filename << "\" not found." << std::endl,
+ this->Quiet);
}
- else
- {
+ cxml.erase(measurementfile.start(),
+ measurementfile.end() - measurementfile.start());
+ } else {
done = true;
- }
}
+ }
}
-void cmCTestTestHandler::SetIncludeRegExp(const char *arg)
+void cmCTestTestHandler::SetIncludeRegExp(const char* arg)
{
this->IncludeRegExp = arg;
}
-void cmCTestTestHandler::SetExcludeRegExp(const char *arg)
+void cmCTestTestHandler::SetExcludeRegExp(const char* arg)
{
this->ExcludeRegExp = arg;
}
void cmCTestTestHandler::SetTestsToRunInformation(const char* in)
{
- if ( !in )
- {
+ if (!in) {
return;
- }
+ }
this->TestsToRunString = in;
// if the argument is a file, then read it and use the contents as the
// string
- if(cmSystemTools::FileExists(in))
- {
+ if (cmSystemTools::FileExists(in)) {
cmsys::ifstream fin(in);
unsigned long filelen = cmSystemTools::FileLength(in);
- char* buff = new char[filelen+1];
+ char* buff = new char[filelen + 1];
fin.getline(buff, filelen);
buff[fin.gcount()] = 0;
this->TestsToRunString = buff;
- delete [] buff;
- }
+ delete[] buff;
+ }
}
bool cmCTestTestHandler::CleanTestOutput(std::string& output, size_t length)
{
- if(!length || length >= output.size() ||
- output.find("CTEST_FULL_OUTPUT") != output.npos)
- {
+ if (!length || length >= output.size() ||
+ output.find("CTEST_FULL_OUTPUT") != output.npos) {
return true;
- }
+ }
// Truncate at given length but do not break in the middle of a multi-byte
// UTF-8 encoding.
@@ -2039,29 +1753,27 @@ bool cmCTestTestHandler::CleanTestOutput(std::string& output, size_t length)
char const* const end = begin + output.size();
char const* const truncate = begin + length;
char const* current = begin;
- while(current < truncate)
- {
+ while (current < truncate) {
unsigned int ch;
- if(const char* next = cm_utf8_decode_character(current, end, &ch))
- {
- if(next > truncate)
- {
+ if (const char* next = cm_utf8_decode_character(current, end, &ch)) {
+ if (next > truncate) {
break;
- }
- current = next;
}
- else // Bad byte will be handled by cmXMLWriter.
- {
+ current = next;
+ } else // Bad byte will be handled by cmXMLWriter.
+ {
++current;
- }
}
+ }
output = output.substr(0, current - begin);
// Append truncation message.
std::ostringstream msg;
msg << "...\n"
- "The rest of the test output was removed since it exceeds the threshold "
- "of " << length << " bytes.\n";
+ "The rest of the test output was removed since it exceeds the "
+ "threshold "
+ "of "
+ << length << " bytes.\n";
output += msg.str();
return true;
}
@@ -2072,176 +1784,138 @@ bool cmCTestTestHandler::SetTestsProperties(
std::vector<std::string>::const_iterator it;
std::vector<std::string> tests;
bool found = false;
- for ( it = args.begin(); it != args.end(); ++ it )
- {
- if ( *it == "PROPERTIES" )
- {
+ for (it = args.begin(); it != args.end(); ++it) {
+ if (*it == "PROPERTIES") {
found = true;
break;
- }
- tests.push_back(*it);
}
- if ( !found )
- {
+ tests.push_back(*it);
+ }
+ if (!found) {
return false;
- }
- ++ it; // skip PROPERTIES
- for ( ; it != args.end(); ++ it )
- {
+ }
+ ++it; // skip PROPERTIES
+ for (; it != args.end(); ++it) {
std::string key = *it;
- ++ it;
- if ( it == args.end() )
- {
+ ++it;
+ if (it == args.end()) {
break;
- }
+ }
std::string val = *it;
std::vector<std::string>::const_iterator tit;
- for ( tit = tests.begin(); tit != tests.end(); ++ tit )
- {
+ for (tit = tests.begin(); tit != tests.end(); ++tit) {
cmCTestTestHandler::ListOfTests::iterator rtit;
- for ( rtit = this->TestList.begin();
- rtit != this->TestList.end();
- ++ rtit )
- {
- if ( *tit == rtit->Name )
- {
- if ( key == "WILL_FAIL" )
- {
+ for (rtit = this->TestList.begin(); rtit != this->TestList.end();
+ ++rtit) {
+ if (*tit == rtit->Name) {
+ if (key == "WILL_FAIL") {
rtit->WillFail = cmSystemTools::IsOn(val.c_str());
- }
- if ( key == "ATTACHED_FILES" )
- {
+ }
+ if (key == "ATTACHED_FILES") {
cmSystemTools::ExpandListArgument(val, rtit->AttachedFiles);
- }
- if ( key == "ATTACHED_FILES_ON_FAIL" )
- {
+ }
+ if (key == "ATTACHED_FILES_ON_FAIL") {
cmSystemTools::ExpandListArgument(val, rtit->AttachOnFail);
- }
- if ( key == "RESOURCE_LOCK" )
- {
+ }
+ if (key == "RESOURCE_LOCK") {
std::vector<std::string> lval;
cmSystemTools::ExpandListArgument(val, lval);
rtit->LockedResources.insert(lval.begin(), lval.end());
- }
- if ( key == "TIMEOUT" )
- {
+ }
+ if (key == "TIMEOUT") {
rtit->Timeout = atof(val.c_str());
rtit->ExplicitTimeout = true;
- }
- if ( key == "COST" )
- {
+ }
+ if (key == "COST") {
rtit->Cost = static_cast<float>(atof(val.c_str()));
- }
- if ( key == "REQUIRED_FILES" )
- {
+ }
+ if (key == "REQUIRED_FILES") {
cmSystemTools::ExpandListArgument(val, rtit->RequiredFiles);
- }
- if ( key == "RUN_SERIAL" )
- {
+ }
+ if (key == "RUN_SERIAL") {
rtit->RunSerial = cmSystemTools::IsOn(val.c_str());
- }
- if ( key == "FAIL_REGULAR_EXPRESSION" )
- {
+ }
+ if (key == "FAIL_REGULAR_EXPRESSION") {
std::vector<std::string> lval;
cmSystemTools::ExpandListArgument(val, lval);
std::vector<std::string>::iterator crit;
- for ( crit = lval.begin(); crit != lval.end(); ++ crit )
- {
+ for (crit = lval.begin(); crit != lval.end(); ++crit) {
rtit->ErrorRegularExpressions.push_back(
std::pair<cmsys::RegularExpression, std::string>(
cmsys::RegularExpression(crit->c_str()),
std::string(*crit)));
- }
}
- if ( key == "PROCESSORS" )
- {
+ }
+ if (key == "PROCESSORS") {
rtit->Processors = atoi(val.c_str());
- if(rtit->Processors < 1)
- {
+ if (rtit->Processors < 1) {
rtit->Processors = 1;
- }
}
- if ( key == "SKIP_RETURN_CODE" )
- {
+ }
+ if (key == "SKIP_RETURN_CODE") {
rtit->SkipReturnCode = atoi(val.c_str());
- if(rtit->SkipReturnCode < 0 || rtit->SkipReturnCode > 255)
- {
+ if (rtit->SkipReturnCode < 0 || rtit->SkipReturnCode > 255) {
rtit->SkipReturnCode = -1;
- }
}
- if ( key == "DEPENDS" )
- {
+ }
+ if (key == "DEPENDS") {
cmSystemTools::ExpandListArgument(val, rtit->Depends);
- }
- if ( key == "ENVIRONMENT" )
- {
+ }
+ if (key == "ENVIRONMENT") {
cmSystemTools::ExpandListArgument(val, rtit->Environment);
- }
- if ( key == "LABELS" )
- {
+ }
+ if (key == "LABELS") {
cmSystemTools::ExpandListArgument(val, rtit->Labels);
- }
- if ( key == "MEASUREMENT" )
- {
+ }
+ if (key == "MEASUREMENT") {
size_t pos = val.find_first_of("=");
- if ( pos != val.npos )
- {
+ if (pos != val.npos) {
std::string mKey = val.substr(0, pos);
const char* mVal = val.c_str() + pos + 1;
rtit->Measurements[mKey] = mVal;
- }
- else
- {
+ } else {
rtit->Measurements[val] = "1";
- }
}
- if ( key == "PASS_REGULAR_EXPRESSION" )
- {
+ }
+ if (key == "PASS_REGULAR_EXPRESSION") {
std::vector<std::string> lval;
cmSystemTools::ExpandListArgument(val, lval);
std::vector<std::string>::iterator crit;
- for ( crit = lval.begin(); crit != lval.end(); ++ crit )
- {
+ for (crit = lval.begin(); crit != lval.end(); ++crit) {
rtit->RequiredRegularExpressions.push_back(
std::pair<cmsys::RegularExpression, std::string>(
cmsys::RegularExpression(crit->c_str()),
std::string(*crit)));
- }
}
- if ( key == "WORKING_DIRECTORY" )
- {
+ }
+ if (key == "WORKING_DIRECTORY") {
rtit->Directory = val;
- }
- if ( key == "TIMEOUT_AFTER_MATCH" )
- {
+ }
+ if (key == "TIMEOUT_AFTER_MATCH") {
std::vector<std::string> propArgs;
cmSystemTools::ExpandListArgument(val, propArgs);
- if (propArgs.size() != 2)
- {
+ if (propArgs.size() != 2) {
cmCTestLog(this->CTest, WARNING,
- "TIMEOUT_AFTER_MATCH expects two arguments, found " <<
- propArgs.size() << std::endl);
- }
- else
- {
+ "TIMEOUT_AFTER_MATCH expects two arguments, found "
+ << propArgs.size() << std::endl);
+ } else {
rtit->AlternateTimeout = atof(propArgs[0].c_str());
std::vector<std::string> lval;
cmSystemTools::ExpandListArgument(propArgs[1], lval);
std::vector<std::string>::iterator crit;
- for ( crit = lval.begin(); crit != lval.end(); ++ crit )
- {
+ for (crit = lval.begin(); crit != lval.end(); ++crit) {
rtit->TimeoutRegularExpressions.push_back(
std::pair<cmsys::RegularExpression, std::string>(
cmsys::RegularExpression(crit->c_str()),
std::string(*crit)));
- }
}
}
}
}
}
}
+ }
return true;
}
@@ -2249,61 +1923,51 @@ bool cmCTestTestHandler::AddTest(const std::vector<std::string>& args)
{
const std::string& testname = args[0];
cmCTestOptionalLog(this->CTest, DEBUG, "Add test: " << args[0] << std::endl,
- this->Quiet);
+ this->Quiet);
- if (this->UseExcludeRegExpFlag &&
- this->UseExcludeRegExpFirst &&
- this->ExcludeTestsRegularExpression.find(testname.c_str()))
- {
+ if (this->UseExcludeRegExpFlag && this->UseExcludeRegExpFirst &&
+ this->ExcludeTestsRegularExpression.find(testname.c_str())) {
return true;
- }
- if ( this->MemCheck )
- {
+ }
+ if (this->MemCheck) {
std::vector<std::string>::iterator it;
bool found = false;
- for ( it = this->CustomTestsIgnore.begin();
- it != this->CustomTestsIgnore.end(); ++ it )
- {
- if ( *it == testname )
- {
+ for (it = this->CustomTestsIgnore.begin();
+ it != this->CustomTestsIgnore.end(); ++it) {
+ if (*it == testname) {
found = true;
break;
- }
}
- if ( found )
- {
+ }
+ if (found) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Ignore memcheck: " << *it << std::endl, this->Quiet);
+ "Ignore memcheck: " << *it << std::endl, this->Quiet);
return true;
- }
}
- else
- {
+ } else {
std::vector<std::string>::iterator it;
bool found = false;
- for ( it = this->CustomTestsIgnore.begin();
- it != this->CustomTestsIgnore.end(); ++ it )
- {
- if ( *it == testname )
- {
+ for (it = this->CustomTestsIgnore.begin();
+ it != this->CustomTestsIgnore.end(); ++it) {
+ if (*it == testname) {
found = true;
break;
- }
}
- if ( found )
- {
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Ignore test: "
- << *it << std::endl, this->Quiet);
+ }
+ if (found) {
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Ignore test: " << *it << std::endl, this->Quiet);
return true;
- }
}
+ }
cmCTestTestProperties test;
test.Name = testname;
test.Args = args;
test.Directory = cmSystemTools::GetCurrentWorkingDirectory();
- cmCTestOptionalLog(this->CTest, DEBUG, "Set test directory: "
- << test.Directory << std::endl, this->Quiet);
+ cmCTestOptionalLog(this->CTest, DEBUG,
+ "Set test directory: " << test.Directory << std::endl,
+ this->Quiet);
test.IsInBasedOnREOptions = true;
test.WillFail = false;
@@ -2315,17 +1979,12 @@ bool cmCTestTestHandler::AddTest(const std::vector<std::string>& args)
test.SkipReturnCode = -1;
test.PreviousRuns = 0;
if (this->UseIncludeRegExpFlag &&
- !this->IncludeTestsRegularExpression.find(testname.c_str()))
- {
+ !this->IncludeTestsRegularExpression.find(testname.c_str())) {
test.IsInBasedOnREOptions = false;
- }
- else if (this->UseExcludeRegExpFlag &&
- !this->UseExcludeRegExpFirst &&
- this->ExcludeTestsRegularExpression.find(testname.c_str()))
- {
+ } else if (this->UseExcludeRegExpFlag && !this->UseExcludeRegExpFirst &&
+ this->ExcludeTestsRegularExpression.find(testname.c_str())) {
test.IsInBasedOnREOptions = false;
- }
+ }
this->TestList.push_back(test);
return true;
}
-
diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h
index 28338dd..4b74ce0 100644
--- a/Source/CTest/cmCTestTestHandler.h
+++ b/Source/CTest/cmCTestTestHandler.h
@@ -29,6 +29,7 @@ class cmCTestTestHandler : public cmCTestGenericHandler
friend class cmCTestRunTest;
friend class cmCTestMultiProcessHandler;
friend class cmCTestBatchTestHandler;
+
public:
cmTypeMacro(cmCTestTestHandler, cmCTestGenericHandler);
@@ -53,22 +54,26 @@ public:
/**
* This method is called when reading CTest custom file
*/
- void PopulateCustomVectors(cmMakefile *mf);
+ void PopulateCustomVectors(cmMakefile* mf);
///! Control the use of the regular expresisons, call these methods to turn
- ///them on
+ /// them on
void UseIncludeRegExp();
void UseExcludeRegExp();
- void SetIncludeRegExp(const char *);
- void SetExcludeRegExp(const char *);
+ void SetIncludeRegExp(const char*);
+ void SetExcludeRegExp(const char*);
- void SetMaxIndex(int n) {this->MaxIndex = n;}
- int GetMaxIndex() {return this->MaxIndex;}
+ void SetMaxIndex(int n) { this->MaxIndex = n; }
+ int GetMaxIndex() { return this->MaxIndex; }
void SetTestOutputSizePassed(int n)
- { this->CustomMaximumPassedTestOutputSize = n; }
+ {
+ this->CustomMaximumPassedTestOutputSize = n;
+ }
void SetTestOutputSizeFailed(int n)
- { this->CustomMaximumFailedTestOutputSize = n; }
+ {
+ this->CustomMaximumFailedTestOutputSize = n;
+ }
///! pass the -I argument down
void SetTestsToRunInformation(const char*);
@@ -100,12 +105,12 @@ public:
std::vector<std::string> Depends;
std::vector<std::string> AttachedFiles;
std::vector<std::string> AttachOnFail;
- std::vector<std::pair<cmsys::RegularExpression,
- std::string> > ErrorRegularExpressions;
- std::vector<std::pair<cmsys::RegularExpression,
- std::string> > RequiredRegularExpressions;
- std::vector<std::pair<cmsys::RegularExpression,
- std::string> > TimeoutRegularExpressions;
+ std::vector<std::pair<cmsys::RegularExpression, std::string> >
+ ErrorRegularExpressions;
+ std::vector<std::pair<cmsys::RegularExpression, std::string> >
+ RequiredRegularExpressions;
+ std::vector<std::pair<cmsys::RegularExpression, std::string> >
+ TimeoutRegularExpressions;
std::map<std::string, std::string> Measurements;
bool IsInBasedOnREOptions;
bool WillFail;
@@ -116,7 +121,7 @@ public:
bool ExplicitTimeout;
double AlternateTimeout;
int Index;
- //Requested number of process slots
+ // Requested number of process slots
int Processors;
// return code of test which will mark test as "not run"
int SkipReturnCode;
@@ -131,41 +136,40 @@ public:
std::string Path;
std::string Reason;
std::string FullCommandLine;
- double ExecutionTime;
- int ReturnValue;
- int Status;
- bool CompressOutput;
+ double ExecutionTime;
+ int ReturnValue;
+ int Status;
+ bool CompressOutput;
std::string CompletionStatus;
std::string Output;
std::string DartString;
- int TestCount;
+ int TestCount;
cmCTestTestProperties* Properties;
};
struct cmCTestTestResultLess
{
- bool operator() (const cmCTestTestResult &lhs,
- const cmCTestTestResult &rhs) const
+ bool operator()(const cmCTestTestResult& lhs,
+ const cmCTestTestResult& rhs) const
{
- return lhs.TestCount < rhs.TestCount;
+ return lhs.TestCount < rhs.TestCount;
}
};
// add configurations to a search path for an executable
- static void AddConfigurations(cmCTest *ctest,
- std::vector<std::string> &attempted,
- std::vector<std::string> &attemptedConfigs,
- std::string filepath,
- std::string &filename);
+ static void AddConfigurations(cmCTest* ctest,
+ std::vector<std::string>& attempted,
+ std::vector<std::string>& attemptedConfigs,
+ std::string filepath, std::string& filename);
// full signature static method to find an executable
- static std::string FindExecutable(cmCTest *ctest,
- const char *testCommand,
- std::string &resultingConfig,
- std::vector<std::string> &extraPaths,
- std::vector<std::string> &failed);
+ static std::string FindExecutable(cmCTest* ctest, const char* testCommand,
+ std::string& resultingConfig,
+ std::vector<std::string>& extraPaths,
+ std::vector<std::string>& failed);
typedef std::vector<cmCTestTestProperties> ListOfTests;
+
protected:
// compute a final test list
virtual int PreProcessHandler();
@@ -181,22 +185,24 @@ protected:
//! Clean test output to specified length
bool CleanTestOutput(std::string& output, size_t length);
- double ElapsedTestingTime;
+ double ElapsedTestingTime;
typedef std::vector<cmCTestTestResult> TestResultsVector;
- TestResultsVector TestResults;
+ TestResultsVector TestResults;
std::vector<std::string> CustomTestsIgnore;
- std::string StartTest;
- std::string EndTest;
- unsigned int StartTestTime;
- unsigned int EndTestTime;
+ std::string StartTest;
+ std::string EndTest;
+ unsigned int StartTestTime;
+ unsigned int EndTestTime;
bool MemCheck;
int CustomMaximumPassedTestOutputSize;
int CustomMaximumFailedTestOutputSize;
int MaxIndex;
+
public:
- enum { // Program statuses
+ enum
+ { // Program statuses
NOT_RUN = 0,
TIMEOUT,
SEGFAULT,
@@ -219,8 +225,8 @@ private:
/**
* Run the tests for a directory and any subdirectories
*/
- void ProcessDirectory(std::vector<std::string> &passed,
- std::vector<std::string> &failed);
+ void ProcessDirectory(std::vector<std::string>& passed,
+ std::vector<std::string>& failed);
/**
* Get the list of tests in directory and subdirectories.
@@ -236,25 +242,15 @@ private:
void UpdateMaxTestNameWidth();
- bool GetValue(const char* tag,
- std::string& value,
- std::istream& fin);
- bool GetValue(const char* tag,
- int& value,
- std::istream& fin);
- bool GetValue(const char* tag,
- size_t& value,
- std::istream& fin);
- bool GetValue(const char* tag,
- bool& value,
- std::istream& fin);
- bool GetValue(const char* tag,
- double& value,
- std::istream& fin);
+ bool GetValue(const char* tag, std::string& value, std::istream& fin);
+ bool GetValue(const char* tag, int& value, std::istream& fin);
+ bool GetValue(const char* tag, size_t& value, std::istream& fin);
+ bool GetValue(const char* tag, bool& value, std::istream& fin);
+ bool GetValue(const char* tag, double& value, std::istream& fin);
/**
* Find the executable for a test
*/
- std::string FindTheExecutable(const char *exe);
+ std::string FindTheExecutable(const char* exe);
const char* GetTestStatus(int status);
void ExpandTestsToRunInformation(size_t numPossibleTests);
@@ -263,7 +259,7 @@ private:
std::vector<std::string> CustomPreTest;
std::vector<std::string> CustomPostTest;
- std::vector<int> TestsToRun;
+ std::vector<int> TestsToRun;
bool UseIncludeLabelRegExpFlag;
bool UseExcludeLabelRegExpFlag;
diff --git a/Source/CTest/cmCTestUpdateCommand.cxx b/Source/CTest/cmCTestUpdateCommand.cxx
index 1bf60fc..f1bae5d 100644
--- a/Source/CTest/cmCTestUpdateCommand.cxx
+++ b/Source/CTest/cmCTestUpdateCommand.cxx
@@ -16,79 +16,81 @@
cmCTestGenericHandler* cmCTestUpdateCommand::InitializeHandler()
{
- if ( this->Values[ct_SOURCE] )
- {
- this->CTest->SetCTestConfiguration("SourceDirectory",
- cmSystemTools::CollapseFullPath(
- this->Values[ct_SOURCE]).c_str(), this->Quiet);
- }
- else
- {
- this->CTest->SetCTestConfiguration("SourceDirectory",
+ if (this->Values[ct_SOURCE]) {
+ this->CTest->SetCTestConfiguration(
+ "SourceDirectory",
+ cmSystemTools::CollapseFullPath(this->Values[ct_SOURCE]).c_str(),
+ this->Quiet);
+ } else {
+ this->CTest->SetCTestConfiguration(
+ "SourceDirectory",
cmSystemTools::CollapseFullPath(
- this->Makefile->GetDefinition("CTEST_SOURCE_DIRECTORY")).c_str(),
+ this->Makefile->GetDefinition("CTEST_SOURCE_DIRECTORY"))
+ .c_str(),
this->Quiet);
- }
- std::string source_dir
- = this->CTest->GetCTestConfiguration("SourceDirectory");
+ }
+ std::string source_dir =
+ this->CTest->GetCTestConfiguration("SourceDirectory");
- this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
- "UpdateCommand", "CTEST_UPDATE_COMMAND", this->Quiet);
- this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
- "UpdateOptions", "CTEST_UPDATE_OPTIONS", this->Quiet);
- this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
- "CVSCommand", "CTEST_CVS_COMMAND", this->Quiet);
- this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
- "CVSUpdateOptions", "CTEST_CVS_UPDATE_OPTIONS", this->Quiet);
- this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
- "SVNCommand", "CTEST_SVN_COMMAND", this->Quiet);
- this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
- "SVNUpdateOptions", "CTEST_SVN_UPDATE_OPTIONS", this->Quiet);
- this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
- "SVNOptions", "CTEST_SVN_OPTIONS", this->Quiet);
- this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
- "BZRCommand", "CTEST_BZR_COMMAND", this->Quiet);
- this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
- "BZRUpdateOptions", "CTEST_BZR_UPDATE_OPTIONS", this->Quiet);
- this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
- "GITCommand", "CTEST_GIT_COMMAND", this->Quiet);
- this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
- "GITUpdateOptions", "CTEST_GIT_UPDATE_OPTIONS", this->Quiet);
- this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
- "GITInitSubmodules", "CTEST_GIT_INIT_SUBMODULES", this->Quiet);
- this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
- "GITUpdateCustom", "CTEST_GIT_UPDATE_CUSTOM", this->Quiet);
- this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
- "UpdateVersionOnly", "CTEST_UPDATE_VERSION_ONLY", this->Quiet);
- this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
- "HGCommand", "CTEST_HG_COMMAND", this->Quiet);
- this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
- "HGUpdateOptions", "CTEST_HG_UPDATE_OPTIONS", this->Quiet);
- this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
- "P4Command", "CTEST_P4_COMMAND", this->Quiet);
- this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
- "P4UpdateOptions", "CTEST_P4_UPDATE_OPTIONS", this->Quiet);
- this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
- "P4Client", "CTEST_P4_CLIENT", this->Quiet);
- this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
- "P4Options", "CTEST_P4_OPTIONS", this->Quiet);
+ this->CTest->SetCTestConfigurationFromCMakeVariable(
+ this->Makefile, "UpdateCommand", "CTEST_UPDATE_COMMAND", this->Quiet);
+ this->CTest->SetCTestConfigurationFromCMakeVariable(
+ this->Makefile, "UpdateOptions", "CTEST_UPDATE_OPTIONS", this->Quiet);
+ this->CTest->SetCTestConfigurationFromCMakeVariable(
+ this->Makefile, "CVSCommand", "CTEST_CVS_COMMAND", this->Quiet);
+ this->CTest->SetCTestConfigurationFromCMakeVariable(
+ this->Makefile, "CVSUpdateOptions", "CTEST_CVS_UPDATE_OPTIONS",
+ this->Quiet);
+ this->CTest->SetCTestConfigurationFromCMakeVariable(
+ this->Makefile, "SVNCommand", "CTEST_SVN_COMMAND", this->Quiet);
+ this->CTest->SetCTestConfigurationFromCMakeVariable(
+ this->Makefile, "SVNUpdateOptions", "CTEST_SVN_UPDATE_OPTIONS",
+ this->Quiet);
+ this->CTest->SetCTestConfigurationFromCMakeVariable(
+ this->Makefile, "SVNOptions", "CTEST_SVN_OPTIONS", this->Quiet);
+ this->CTest->SetCTestConfigurationFromCMakeVariable(
+ this->Makefile, "BZRCommand", "CTEST_BZR_COMMAND", this->Quiet);
+ this->CTest->SetCTestConfigurationFromCMakeVariable(
+ this->Makefile, "BZRUpdateOptions", "CTEST_BZR_UPDATE_OPTIONS",
+ this->Quiet);
+ this->CTest->SetCTestConfigurationFromCMakeVariable(
+ this->Makefile, "GITCommand", "CTEST_GIT_COMMAND", this->Quiet);
+ this->CTest->SetCTestConfigurationFromCMakeVariable(
+ this->Makefile, "GITUpdateOptions", "CTEST_GIT_UPDATE_OPTIONS",
+ this->Quiet);
+ this->CTest->SetCTestConfigurationFromCMakeVariable(
+ this->Makefile, "GITInitSubmodules", "CTEST_GIT_INIT_SUBMODULES",
+ this->Quiet);
+ this->CTest->SetCTestConfigurationFromCMakeVariable(
+ this->Makefile, "GITUpdateCustom", "CTEST_GIT_UPDATE_CUSTOM", this->Quiet);
+ this->CTest->SetCTestConfigurationFromCMakeVariable(
+ this->Makefile, "UpdateVersionOnly", "CTEST_UPDATE_VERSION_ONLY",
+ this->Quiet);
+ this->CTest->SetCTestConfigurationFromCMakeVariable(
+ this->Makefile, "HGCommand", "CTEST_HG_COMMAND", this->Quiet);
+ this->CTest->SetCTestConfigurationFromCMakeVariable(
+ this->Makefile, "HGUpdateOptions", "CTEST_HG_UPDATE_OPTIONS", this->Quiet);
+ this->CTest->SetCTestConfigurationFromCMakeVariable(
+ this->Makefile, "P4Command", "CTEST_P4_COMMAND", this->Quiet);
+ this->CTest->SetCTestConfigurationFromCMakeVariable(
+ this->Makefile, "P4UpdateOptions", "CTEST_P4_UPDATE_OPTIONS", this->Quiet);
+ this->CTest->SetCTestConfigurationFromCMakeVariable(
+ this->Makefile, "P4Client", "CTEST_P4_CLIENT", this->Quiet);
+ this->CTest->SetCTestConfigurationFromCMakeVariable(
+ this->Makefile, "P4Options", "CTEST_P4_OPTIONS", this->Quiet);
- cmCTestGenericHandler* handler
- = this->CTest->GetInitializedHandler("update");
- if ( !handler )
- {
+ cmCTestGenericHandler* handler =
+ this->CTest->GetInitializedHandler("update");
+ if (!handler) {
this->SetError("internal CTest error. Cannot instantiate update handler");
return 0;
- }
+ }
handler->SetCommand(this);
- if ( source_dir.empty() )
- {
+ if (source_dir.empty()) {
this->SetError("source directory not specified. Please use SOURCE tag");
return 0;
- }
+ }
handler->SetOption("SourceDirectory", source_dir.c_str());
handler->SetQuiet(this->Quiet);
return handler;
}
-
-
diff --git a/Source/CTest/cmCTestUpdateCommand.h b/Source/CTest/cmCTestUpdateCommand.h
index fb80333..e807193 100644
--- a/Source/CTest/cmCTestUpdateCommand.h
+++ b/Source/CTest/cmCTestUpdateCommand.h
@@ -22,24 +22,23 @@
class cmCTestUpdateCommand : public cmCTestHandlerCommand
{
public:
-
cmCTestUpdateCommand() {}
/**
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
- {
+ {
cmCTestUpdateCommand* ni = new cmCTestUpdateCommand;
ni->CTest = this->CTest;
ni->CTestScriptHandler = this->CTestScriptHandler;
return ni;
- }
+ }
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const { return "ctest_update";}
+ virtual std::string GetName() const { return "ctest_update"; }
cmTypeMacro(cmCTestUpdateCommand, cmCTestHandlerCommand);
@@ -47,5 +46,4 @@ protected:
cmCTestGenericHandler* InitializeHandler();
};
-
#endif
diff --git a/Source/CTest/cmCTestUpdateHandler.cxx b/Source/CTest/cmCTestUpdateHandler.cxx
index 85624e0..4eaa16b 100644
--- a/Source/CTest/cmCTestUpdateHandler.cxx
+++ b/Source/CTest/cmCTestUpdateHandler.cxx
@@ -44,24 +44,16 @@
#include <math.h>
#include <stdlib.h>
-static const char* cmCTestUpdateHandlerUpdateStrings[] =
-{
- "Unknown",
- "CVS",
- "SVN",
- "BZR",
- "GIT",
- "HG",
- "P4"
+static const char* cmCTestUpdateHandlerUpdateStrings[] = {
+ "Unknown", "CVS", "SVN", "BZR", "GIT", "HG", "P4"
};
static const char* cmCTestUpdateHandlerUpdateToString(int type)
{
- if ( type < cmCTestUpdateHandler::e_UNKNOWN ||
- type >= cmCTestUpdateHandler::e_LAST )
- {
+ if (type < cmCTestUpdateHandler::e_UNKNOWN ||
+ type >= cmCTestUpdateHandler::e_LAST) {
return cmCTestUpdateHandlerUpdateStrings[cmCTestUpdateHandler::e_UNKNOWN];
- }
+ }
return cmCTestUpdateHandlerUpdateStrings[type];
}
@@ -78,74 +70,60 @@ void cmCTestUpdateHandler::Initialize()
int cmCTestUpdateHandler::DetermineType(const char* cmd, const char* type)
{
- cmCTestOptionalLog(this->CTest, DEBUG,
- "Determine update type from command: " << cmd << " and type: " << type <<
- std::endl, this->Quiet);
- if ( type && *type )
- {
- cmCTestOptionalLog(this->CTest, DEBUG, "Type specified: " << type <<
- std::endl, this->Quiet);
+ cmCTestOptionalLog(this->CTest, DEBUG, "Determine update type from command: "
+ << cmd << " and type: " << type << std::endl,
+ this->Quiet);
+ if (type && *type) {
+ cmCTestOptionalLog(this->CTest, DEBUG,
+ "Type specified: " << type << std::endl, this->Quiet);
std::string stype = cmSystemTools::LowerCase(type);
- if ( stype.find("cvs") != std::string::npos )
- {
+ if (stype.find("cvs") != std::string::npos) {
return cmCTestUpdateHandler::e_CVS;
- }
- if ( stype.find("svn") != std::string::npos )
- {
+ }
+ if (stype.find("svn") != std::string::npos) {
return cmCTestUpdateHandler::e_SVN;
- }
- if ( stype.find("bzr") != std::string::npos )
- {
+ }
+ if (stype.find("bzr") != std::string::npos) {
return cmCTestUpdateHandler::e_BZR;
- }
- if ( stype.find("git") != std::string::npos )
- {
+ }
+ if (stype.find("git") != std::string::npos) {
return cmCTestUpdateHandler::e_GIT;
- }
- if ( stype.find("hg") != std::string::npos )
- {
+ }
+ if (stype.find("hg") != std::string::npos) {
return cmCTestUpdateHandler::e_HG;
- }
- if ( stype.find("p4") != std::string::npos )
- {
+ }
+ if (stype.find("p4") != std::string::npos) {
return cmCTestUpdateHandler::e_P4;
- }
}
- else
- {
- cmCTestOptionalLog(this->CTest, DEBUG,
+ } else {
+ cmCTestOptionalLog(
+ this->CTest, DEBUG,
"Type not specified, check command: " << cmd << std::endl, this->Quiet);
std::string stype = cmSystemTools::LowerCase(cmd);
- if ( stype.find("cvs") != std::string::npos )
- {
+ if (stype.find("cvs") != std::string::npos) {
return cmCTestUpdateHandler::e_CVS;
- }
- if ( stype.find("svn") != std::string::npos )
- {
+ }
+ if (stype.find("svn") != std::string::npos) {
return cmCTestUpdateHandler::e_SVN;
- }
- if ( stype.find("bzr") != std::string::npos )
- {
+ }
+ if (stype.find("bzr") != std::string::npos) {
return cmCTestUpdateHandler::e_BZR;
- }
- if ( stype.find("git") != std::string::npos )
- {
+ }
+ if (stype.find("git") != std::string::npos) {
return cmCTestUpdateHandler::e_GIT;
- }
- if ( stype.find("hg") != std::string::npos )
- {
+ }
+ if (stype.find("hg") != std::string::npos) {
return cmCTestUpdateHandler::e_HG;
- }
- if ( stype.find("p4") != std::string::npos )
- {
+ }
+ if (stype.find("p4") != std::string::npos) {
return cmCTestUpdateHandler::e_P4;
- }
}
+ }
return cmCTestUpdateHandler::e_UNKNOWN;
}
-//clearly it would be nice if this were broken up into a few smaller
-//functions and commented...
+// clearly it would be nice if this were broken up into a few smaller
+// functions and commented...
int cmCTestUpdateHandler::ProcessHandler()
{
// Make sure VCS tool messages are in English so we can parse them.
@@ -154,46 +132,57 @@ int cmCTestUpdateHandler::ProcessHandler()
// Get source dir
const char* sourceDirectory = this->GetOption("SourceDirectory");
- if ( !sourceDirectory )
- {
+ if (!sourceDirectory) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Cannot find SourceDirectory key in the DartConfiguration.tcl"
- << std::endl);
+ "Cannot find SourceDirectory key in the DartConfiguration.tcl"
+ << std::endl);
return -1;
- }
+ }
cmGeneratedFileStream ofs;
- if ( !this->CTest->GetShowOnly() )
- {
+ if (!this->CTest->GetShowOnly()) {
this->StartLogFile("Update", ofs);
- }
+ }
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " Updating the repository: " << sourceDirectory << std::endl,
- this->Quiet);
+ " Updating the repository: " << sourceDirectory
+ << std::endl,
+ this->Quiet);
- if(!this->SelectVCS())
- {
+ if (!this->SelectVCS()) {
return -1;
- }
+ }
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " Use "
- << cmCTestUpdateHandlerUpdateToString(this->UpdateType)
- << " repository type"
- << std::endl;, this->Quiet);
+ << cmCTestUpdateHandlerUpdateToString(this->UpdateType)
+ << " repository type" << std::endl;
+ , this->Quiet);
// Create an object to interact with the VCS tool.
cmsys::auto_ptr<cmCTestVC> vc;
- switch (this->UpdateType)
- {
- case e_CVS: vc.reset(new cmCTestCVS(this->CTest, ofs)); break;
- case e_SVN: vc.reset(new cmCTestSVN(this->CTest, ofs)); break;
- case e_BZR: vc.reset(new cmCTestBZR(this->CTest, ofs)); break;
- case e_GIT: vc.reset(new cmCTestGIT(this->CTest, ofs)); break;
- case e_HG: vc.reset(new cmCTestHG(this->CTest, ofs)); break;
- case e_P4: vc.reset(new cmCTestP4(this->CTest, ofs)); break;
- default: vc.reset(new cmCTestVC(this->CTest, ofs)); break;
- }
+ switch (this->UpdateType) {
+ case e_CVS:
+ vc.reset(new cmCTestCVS(this->CTest, ofs));
+ break;
+ case e_SVN:
+ vc.reset(new cmCTestSVN(this->CTest, ofs));
+ break;
+ case e_BZR:
+ vc.reset(new cmCTestBZR(this->CTest, ofs));
+ break;
+ case e_GIT:
+ vc.reset(new cmCTestGIT(this->CTest, ofs));
+ break;
+ case e_HG:
+ vc.reset(new cmCTestHG(this->CTest, ofs));
+ break;
+ case e_P4:
+ vc.reset(new cmCTestP4(this->CTest, ofs));
+ break;
+ default:
+ vc.reset(new cmCTestVC(this->CTest, ofs));
+ break;
+ }
vc->SetCommandLineTool(this->UpdateCommand);
vc->SetSourceDirectory(sourceDirectory);
@@ -204,134 +193,127 @@ int cmCTestUpdateHandler::ProcessHandler()
// Now update repository and remember what files were updated
//
cmGeneratedFileStream os;
- if(!this->StartResultingXML(cmCTest::PartUpdate, "Update", os))
- {
+ if (!this->StartResultingXML(cmCTest::PartUpdate, "Update", os)) {
cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open log file"
- << std::endl);
+ << std::endl);
return -1;
- }
+ }
std::string start_time = this->CTest->CurrentTime();
unsigned int start_time_time =
static_cast<unsigned int>(cmSystemTools::GetTime());
double elapsed_time_start = cmSystemTools::GetTime();
bool updated = vc->Update();
- std::string buildname = cmCTest::SafeBuildIdField(
- this->CTest->GetCTestConfiguration("BuildName"));
+ std::string buildname =
+ cmCTest::SafeBuildIdField(this->CTest->GetCTestConfiguration("BuildName"));
cmXMLWriter xml(os);
xml.StartDocument();
xml.StartElement("Update");
xml.Attribute("mode", "Client");
xml.Attribute("Generator",
- std::string("ctest-") + cmVersion::GetCMakeVersion());
+ std::string("ctest-") + cmVersion::GetCMakeVersion());
xml.Element("Site", this->CTest->GetCTestConfiguration("Site"));
xml.Element("BuildName", buildname);
xml.Element("BuildStamp", this->CTest->GetCurrentTag() + "-" +
- this->CTest->GetTestModelString());
+ this->CTest->GetTestModelString());
xml.Element("StartDateTime", start_time);
xml.Element("StartTime", start_time_time);
xml.Element("UpdateCommand", vc->GetUpdateCommandLine());
xml.Element("UpdateType",
- cmCTestUpdateHandlerUpdateToString(this->UpdateType));
+ cmCTestUpdateHandlerUpdateToString(this->UpdateType));
vc->WriteXML(xml);
int localModifications = 0;
int numUpdated = vc->GetPathCount(cmCTestVC::PathUpdated);
- if(numUpdated)
- {
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " Found " << numUpdated << " updated files\n", this->Quiet);
- }
- if(int numModified = vc->GetPathCount(cmCTestVC::PathModified))
- {
+ if (numUpdated) {
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " Found " << numModified << " locally modified files\n", this->Quiet);
+ " Found " << numUpdated << " updated files\n",
+ this->Quiet);
+ }
+ if (int numModified = vc->GetPathCount(cmCTestVC::PathModified)) {
+ cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " Found "
+ << numModified << " locally modified files\n",
+ this->Quiet);
localModifications += numModified;
- }
- if(int numConflicting = vc->GetPathCount(cmCTestVC::PathConflicting))
- {
+ }
+ if (int numConflicting = vc->GetPathCount(cmCTestVC::PathConflicting)) {
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " Found " << numConflicting << " conflicting files\n", this->Quiet);
+ " Found " << numConflicting << " conflicting files\n",
+ this->Quiet);
localModifications += numConflicting;
- }
+ }
cmCTestOptionalLog(this->CTest, DEBUG, "End" << std::endl, this->Quiet);
std::string end_time = this->CTest->CurrentTime();
xml.Element("EndDateTime", end_time);
xml.Element("EndTime", static_cast<unsigned int>(cmSystemTools::GetTime()));
- xml.Element("ElapsedMinutes",
- static_cast<int>((cmSystemTools::GetTime() - elapsed_time_start)/6)/10.0);
+ xml.Element(
+ "ElapsedMinutes",
+ static_cast<int>((cmSystemTools::GetTime() - elapsed_time_start) / 6) /
+ 10.0);
xml.StartElement("UpdateReturnStatus");
- if(localModifications)
- {
+ if (localModifications) {
xml.Content("Update error: "
- "There are modified or conflicting files in the repository");
+ "There are modified or conflicting files in the repository");
cmCTestLog(this->CTest, ERROR_MESSAGE,
- " There are modified or conflicting files in the repository"
- << std::endl);
- }
- if(!updated)
- {
+ " There are modified or conflicting files in the repository"
+ << std::endl);
+ }
+ if (!updated) {
xml.Content("Update command failed:\n");
xml.Content(vc->GetUpdateCommandLine());
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Update command failed: "
- << vc->GetUpdateCommandLine() << "\n");
- }
+ << vc->GetUpdateCommandLine() << "\n");
+ }
xml.EndElement(); // UpdateReturnStatus
xml.EndElement(); // Update
xml.EndDocument();
- return updated? numUpdated : -1;
+ return updated ? numUpdated : -1;
}
int cmCTestUpdateHandler::DetectVCS(const char* dir)
{
std::string sourceDirectory = dir;
- cmCTestOptionalLog(this->CTest, DEBUG, "Check directory: "
- << sourceDirectory << std::endl, this->Quiet);
+ cmCTestOptionalLog(this->CTest, DEBUG,
+ "Check directory: " << sourceDirectory << std::endl,
+ this->Quiet);
sourceDirectory += "/.svn";
- if ( cmSystemTools::FileExists(sourceDirectory.c_str()) )
- {
+ if (cmSystemTools::FileExists(sourceDirectory.c_str())) {
return cmCTestUpdateHandler::e_SVN;
- }
+ }
sourceDirectory = dir;
sourceDirectory += "/CVS";
- if ( cmSystemTools::FileExists(sourceDirectory.c_str()) )
- {
+ if (cmSystemTools::FileExists(sourceDirectory.c_str())) {
return cmCTestUpdateHandler::e_CVS;
- }
+ }
sourceDirectory = dir;
sourceDirectory += "/.bzr";
- if ( cmSystemTools::FileExists(sourceDirectory.c_str()) )
- {
+ if (cmSystemTools::FileExists(sourceDirectory.c_str())) {
return cmCTestUpdateHandler::e_BZR;
- }
+ }
sourceDirectory = dir;
sourceDirectory += "/.git";
- if ( cmSystemTools::FileExists(sourceDirectory.c_str()) )
- {
+ if (cmSystemTools::FileExists(sourceDirectory.c_str())) {
return cmCTestUpdateHandler::e_GIT;
- }
+ }
sourceDirectory = dir;
sourceDirectory += "/.hg";
- if ( cmSystemTools::FileExists(sourceDirectory.c_str()) )
- {
+ if (cmSystemTools::FileExists(sourceDirectory.c_str())) {
return cmCTestUpdateHandler::e_HG;
- }
+ }
sourceDirectory = dir;
sourceDirectory += "/.p4";
- if ( cmSystemTools::FileExists(sourceDirectory.c_str()) )
- {
+ if (cmSystemTools::FileExists(sourceDirectory.c_str())) {
return cmCTestUpdateHandler::e_P4;
- }
+ }
sourceDirectory = dir;
sourceDirectory += "/.p4config";
- if ( cmSystemTools::FileExists(sourceDirectory.c_str()) )
- {
+ if (cmSystemTools::FileExists(sourceDirectory.c_str())) {
return cmCTestUpdateHandler::e_P4;
- }
+ }
return cmCTestUpdateHandler::e_UNKNOWN;
}
@@ -342,45 +324,53 @@ bool cmCTestUpdateHandler::SelectVCS()
// Detect the VCS managing the source tree.
this->UpdateType = this->DetectVCS(this->GetOption("SourceDirectory"));
- if (this->UpdateType == e_UNKNOWN)
- {
+ if (this->UpdateType == e_UNKNOWN) {
// The source tree does not have a recognized VCS. Check the
// configuration value or command name.
- this->UpdateType = this->DetermineType(this->UpdateCommand.c_str(),
+ this->UpdateType = this->DetermineType(
+ this->UpdateCommand.c_str(),
this->CTest->GetCTestConfiguration("UpdateType").c_str());
- }
+ }
// If no update command was specified, lookup one for this VCS tool.
- if (this->UpdateCommand.empty())
- {
+ if (this->UpdateCommand.empty()) {
const char* key = 0;
- switch (this->UpdateType)
- {
- case e_CVS: key = "CVSCommand"; break;
- case e_SVN: key = "SVNCommand"; break;
- case e_BZR: key = "BZRCommand"; break;
- case e_GIT: key = "GITCommand"; break;
- case e_HG: key = "HGCommand"; break;
- case e_P4: key = "P4Command"; break;
- default: break;
- }
- if (key)
- {
+ switch (this->UpdateType) {
+ case e_CVS:
+ key = "CVSCommand";
+ break;
+ case e_SVN:
+ key = "SVNCommand";
+ break;
+ case e_BZR:
+ key = "BZRCommand";
+ break;
+ case e_GIT:
+ key = "GITCommand";
+ break;
+ case e_HG:
+ key = "HGCommand";
+ break;
+ case e_P4:
+ key = "P4Command";
+ break;
+ default:
+ break;
+ }
+ if (key) {
this->UpdateCommand = this->CTest->GetCTestConfiguration(key);
- }
- if (this->UpdateCommand.empty())
- {
+ }
+ if (this->UpdateCommand.empty()) {
std::ostringstream e;
e << "Cannot find UpdateCommand ";
- if (key)
- {
+ if (key) {
e << "or " << key;
- }
+ }
e << " configuration key.";
cmCTestLog(this->CTest, ERROR_MESSAGE, e.str() << std::endl);
return false;
- }
}
+ }
return true;
}
diff --git a/Source/CTest/cmCTestUpdateHandler.h b/Source/CTest/cmCTestUpdateHandler.h
index 463703c..d44e619 100644
--- a/Source/CTest/cmCTestUpdateHandler.h
+++ b/Source/CTest/cmCTestUpdateHandler.h
@@ -33,7 +33,8 @@ public:
cmCTestUpdateHandler();
- enum {
+ enum
+ {
e_UNKNOWN = 0,
e_CVS,
e_SVN,
@@ -51,9 +52,12 @@ public:
private:
// Some structures needed for update
- struct StringPair :
- public std::pair<std::string, std::string>{};
- struct UpdateFiles : public std::vector<StringPair>{};
+ struct StringPair : public std::pair<std::string, std::string>
+ {
+ };
+ struct UpdateFiles : public std::vector<StringPair>
+ {
+ };
// Determine the type of version control
int DetermineType(const char* cmd, const char* type);
diff --git a/Source/CTest/cmCTestUploadCommand.cxx b/Source/CTest/cmCTestUploadCommand.cxx
index 7c24e62..6813cbc 100644
--- a/Source/CTest/cmCTestUploadCommand.cxx
+++ b/Source/CTest/cmCTestUploadCommand.cxx
@@ -17,57 +17,48 @@
cmCTestGenericHandler* cmCTestUploadCommand::InitializeHandler()
{
- cmCTestGenericHandler* handler
- = this->CTest->GetInitializedHandler("upload");
- if ( !handler )
- {
+ cmCTestGenericHandler* handler =
+ this->CTest->GetInitializedHandler("upload");
+ if (!handler) {
this->SetError("internal CTest error. Cannot instantiate upload handler");
return 0;
- }
+ }
static_cast<cmCTestUploadHandler*>(handler)->SetFiles(this->Files);
handler->SetQuiet(this->Quiet);
return handler;
}
-
bool cmCTestUploadCommand::CheckArgumentKeyword(std::string const& arg)
{
- if(arg == "FILES")
- {
+ if (arg == "FILES") {
this->ArgumentDoing = ArgumentDoingFiles;
return true;
- }
- if(arg == "QUIET")
- {
+ }
+ if (arg == "QUIET") {
this->ArgumentDoing = ArgumentDoingNone;
this->Quiet = true;
return true;
- }
+ }
return false;
}
-
bool cmCTestUploadCommand::CheckArgumentValue(std::string const& arg)
{
- if(this->ArgumentDoing == ArgumentDoingFiles)
- {
+ if (this->ArgumentDoing == ArgumentDoingFiles) {
std::string filename(arg);
- if(cmSystemTools::FileExists(filename.c_str()))
- {
+ if (cmSystemTools::FileExists(filename.c_str())) {
this->Files.insert(filename);
return true;
- }
- else
- {
+ } else {
std::ostringstream e;
e << "File \"" << filename << "\" does not exist. Cannot submit "
- << "a non-existent file.";
+ << "a non-existent file.";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
this->ArgumentDoing = ArgumentDoingError;
return false;
- }
}
+ }
// Look for other arguments.
return this->Superclass::CheckArgumentValue(arg);
diff --git a/Source/CTest/cmCTestUploadCommand.h b/Source/CTest/cmCTestUploadCommand.h
index 1802254..551be2b 100644
--- a/Source/CTest/cmCTestUploadCommand.h
+++ b/Source/CTest/cmCTestUploadCommand.h
@@ -25,26 +25,23 @@
class cmCTestUploadCommand : public cmCTestHandlerCommand
{
public:
-
- cmCTestUploadCommand()
- {
- }
+ cmCTestUploadCommand() {}
/**
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
- {
+ {
cmCTestUploadCommand* ni = new cmCTestUploadCommand;
ni->CTest = this->CTest;
ni->CTestScriptHandler = this->CTestScriptHandler;
return ni;
- }
+ }
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const { return "ctest_upload";}
+ virtual std::string GetName() const { return "ctest_upload"; }
cmTypeMacro(cmCTestUploadCommand, cmCTestHandlerCommand);
@@ -63,5 +60,4 @@ protected:
cmCTest::SetOfStrings Files;
};
-
#endif
diff --git a/Source/CTest/cmCTestUploadHandler.cxx b/Source/CTest/cmCTestUploadHandler.cxx
index 6f0a024..6a3b830 100644
--- a/Source/CTest/cmCTestUploadHandler.cxx
+++ b/Source/CTest/cmCTestUploadHandler.cxx
@@ -34,36 +34,35 @@ void cmCTestUploadHandler::SetFiles(const cmCTest::SetOfStrings& files)
int cmCTestUploadHandler::ProcessHandler()
{
cmGeneratedFileStream ofs;
- if ( !this->CTest->OpenOutputFile(this->CTest->GetCurrentTag(),
- "Upload.xml", ofs))
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Cannot open Upload.xml file" << std::endl);
+ if (!this->CTest->OpenOutputFile(this->CTest->GetCurrentTag(), "Upload.xml",
+ ofs)) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open Upload.xml file"
+ << std::endl);
return -1;
- }
- std::string buildname = cmCTest::SafeBuildIdField(
- this->CTest->GetCTestConfiguration("BuildName"));
+ }
+ std::string buildname =
+ cmCTest::SafeBuildIdField(this->CTest->GetCTestConfiguration("BuildName"));
cmCTest::SetOfStrings::const_iterator it;
cmXMLWriter xml(ofs);
xml.StartDocument();
- xml.ProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" "
- "href=\"Dart/Source/Server/XSL/Build.xsl "
- "<file:///Dart/Source/Server/XSL/Build.xsl> \"");
+ xml.ProcessingInstruction("xml-stylesheet",
+ "type=\"text/xsl\" "
+ "href=\"Dart/Source/Server/XSL/Build.xsl "
+ "<file:///Dart/Source/Server/XSL/Build.xsl> \"");
xml.StartElement("Site");
xml.Attribute("BuildName", buildname);
- xml.Attribute("BuildStamp",
- this->CTest->GetCurrentTag() + "-" + this->CTest->GetTestModelString());
+ xml.Attribute("BuildStamp", this->CTest->GetCurrentTag() + "-" +
+ this->CTest->GetTestModelString());
xml.Attribute("Name", this->CTest->GetCTestConfiguration("Site"));
xml.Attribute("Generator",
- std::string("ctest") + cmVersion::GetCMakeVersion());
+ std::string("ctest") + cmVersion::GetCMakeVersion());
this->CTest->AddSiteProperties(xml);
xml.StartElement("Upload");
- for ( it = this->Files.begin(); it != this->Files.end(); it ++ )
- {
+ for (it = this->Files.begin(); it != this->Files.end(); it++) {
cmCTestOptionalLog(this->CTest, OUTPUT,
- "\tUpload file: " << *it << std::endl, this->Quiet);
+ "\tUpload file: " << *it << std::endl, this->Quiet);
xml.StartElement("File");
xml.Attribute("filename", *it);
xml.StartElement("Content");
@@ -71,7 +70,7 @@ int cmCTestUploadHandler::ProcessHandler()
xml.Content(this->CTest->Base64EncodeFile(*it));
xml.EndElement(); // Content
xml.EndElement(); // File
- }
+ }
xml.EndElement(); // Upload
xml.EndElement(); // Site
xml.EndDocument();
diff --git a/Source/CTest/cmCTestVC.cxx b/Source/CTest/cmCTestVC.cxx
index f3d699b..e9934e5 100644
--- a/Source/CTest/cmCTestVC.cxx
+++ b/Source/CTest/cmCTestVC.cxx
@@ -17,7 +17,9 @@
#include <cmsys/Process.h>
-cmCTestVC::cmCTestVC(cmCTest* ct, std::ostream& log): CTest(ct), Log(log)
+cmCTestVC::cmCTestVC(cmCTest* ct, std::ostream& log)
+ : CTest(ct)
+ , Log(log)
{
this->PathCount[PathUpdated] = 0;
this->PathCount[PathModified] = 0;
@@ -50,21 +52,19 @@ bool cmCTestVC::InitialCheckout(const char* command)
std::string parent = cmSystemTools::GetFilenamePath(this->SourceDirectory);
cmCTestLog(this->CTest, HANDLER_OUTPUT,
" Perform checkout in directory: " << parent << "\n");
- if(!cmSystemTools::MakeDirectory(parent.c_str()))
- {
+ if (!cmSystemTools::MakeDirectory(parent.c_str())) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Cannot create directory: " << parent << std::endl);
return false;
- }
+ }
// Construct the initial checkout command line.
std::vector<std::string> args = cmSystemTools::ParseArguments(command);
std::vector<char const*> vc_co;
- for(std::vector<std::string>::const_iterator ai = args.begin();
- ai != args.end(); ++ai)
- {
+ for (std::vector<std::string>::const_iterator ai = args.begin();
+ ai != args.end(); ++ai) {
vc_co.push_back(ai->c_str());
- }
+ }
vc_co.push_back(0);
// Run the initial checkout command and log its output.
@@ -73,11 +73,10 @@ bool cmCTestVC::InitialCheckout(const char* command)
OutputLogger err(this->Log, "co-err> ");
bool result = this->RunChild(&vc_co[0], &out, &err, parent.c_str());
this->Log << "--- End Initial Checkout ---\n";
- if(!result)
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Initial checkout failed!" << std::endl);
- }
+ if (!result) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "Initial checkout failed!"
+ << std::endl);
+ }
return result;
}
@@ -88,7 +87,7 @@ bool cmCTestVC::RunChild(char const* const* cmd, OutputParser* out,
cmsysProcess* cp = cmsysProcess_New();
cmsysProcess_SetCommand(cp, cmd);
- workDir = workDir? workDir : this->SourceDirectory.c_str();
+ workDir = workDir ? workDir : this->SourceDirectory.c_str();
cmsysProcess_SetWorkingDirectory(cp, workDir);
this->RunProcess(cp, out, err);
int result = cmsysProcess_GetExitValue(cp);
@@ -100,24 +99,22 @@ std::string cmCTestVC::ComputeCommandLine(char const* const* cmd)
{
std::ostringstream line;
const char* sep = "";
- for(const char* const* arg = cmd; *arg; ++arg)
- {
+ for (const char* const* arg = cmd; *arg; ++arg) {
line << sep << "\"" << *arg << "\"";
sep = " ";
- }
+ }
return line.str();
}
-bool cmCTestVC::RunUpdateCommand(char const* const* cmd,
- OutputParser* out, OutputParser* err)
+bool cmCTestVC::RunUpdateCommand(char const* const* cmd, OutputParser* out,
+ OutputParser* err)
{
// Report the command line.
this->UpdateCommandLine = this->ComputeCommandLine(cmd);
- if(this->CTest->GetShowOnly())
- {
+ if (this->CTest->GetShowOnly()) {
this->Log << this->UpdateCommandLine << "\n";
return true;
- }
+ }
// Run the command.
return this->RunChild(cmd, out, err);
@@ -130,13 +127,8 @@ std::string cmCTestVC::GetNightlyTime()
this->CTest->GetCTestConfiguration("NightlyStartTime"),
this->CTest->GetTomorrowTag());
char current_time[1024];
- sprintf(current_time, "%04d-%02d-%02d %02d:%02d:%02d",
- t->tm_year + 1900,
- t->tm_mon + 1,
- t->tm_mday,
- t->tm_hour,
- t->tm_min,
- t->tm_sec);
+ sprintf(current_time, "%04d-%02d-%02d %02d:%02d:%02d", t->tm_year + 1900,
+ t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
return std::string(current_time);
}
@@ -157,14 +149,13 @@ bool cmCTestVC::Update()
bool result = true;
// if update version only is on then do not actually update,
// just note the current version and finish
- if(!cmSystemTools::IsOn(
- this->CTest->GetCTestConfiguration("UpdateVersionOnly").c_str()))
- {
+ if (!cmSystemTools::IsOn(
+ this->CTest->GetCTestConfiguration("UpdateVersionOnly").c_str())) {
this->NoteOldRevision();
this->Log << "--- Begin Update ---\n";
result = this->UpdateImpl();
this->Log << "--- End Update ---\n";
- }
+ }
this->NoteNewRevision();
return result;
}
@@ -201,15 +192,13 @@ bool cmCTestVC::WriteXMLUpdates(cmXMLWriter&)
return true;
}
-void cmCTestVC::WriteXMLEntry(cmXMLWriter& xml,
- std::string const& path,
- std::string const& name,
- std::string const& full,
+void cmCTestVC::WriteXMLEntry(cmXMLWriter& xml, std::string const& path,
+ std::string const& name, std::string const& full,
File const& f)
{
- static const char* desc[3] = { "Updated", "Modified", "Conflicting"};
- Revision const& rev = f.Rev? *f.Rev : this->Unknown;
- std::string prior = f.PriorRev? f.PriorRev->Rev : std::string("Unknown");
+ static const char* desc[3] = { "Updated", "Modified", "Conflicting" };
+ Revision const& rev = f.Rev ? *f.Rev : this->Unknown;
+ std::string prior = f.PriorRev ? f.PriorRev->Rev : std::string("Unknown");
xml.StartElement(desc[f.Status]);
xml.Element("File", name);
xml.Element("Directory", path);
diff --git a/Source/CTest/cmCTestVC.h b/Source/CTest/cmCTestVC.h
index 1caa850..4ae38eb 100644
--- a/Source/CTest/cmCTestVC.h
+++ b/Source/CTest/cmCTestVC.h
@@ -21,7 +21,7 @@ class cmXMLWriter;
* \brief Base class for version control system handlers
*
*/
-class cmCTestVC: public cmProcessTools
+class cmCTestVC : public cmProcessTools
{
public:
/** Construct with a CTest instance and update log stream. */
@@ -49,13 +49,20 @@ public:
/** Get the command line used by the Update method. */
std::string const& GetUpdateCommandLine() const
- { return this->UpdateCommandLine; }
+ {
+ return this->UpdateCommandLine;
+ }
/** Write Update.xml entries for the updates found. */
bool WriteXML(cmXMLWriter& xml);
/** Enumerate non-trivial working tree states during update. */
- enum PathStatus { PathUpdated, PathModified, PathConflicting };
+ enum PathStatus
+ {
+ PathUpdated,
+ PathModified,
+ PathConflicting
+ };
/** Get the number of working tree paths in each state after update. */
int GetPathCount(PathStatus s) const { return this->PathCount[s]; }
@@ -95,21 +102,30 @@ protected:
PathStatus Status;
Revision const* Rev;
Revision const* PriorRev;
- File(): Status(PathUpdated), Rev(0), PriorRev(0) {}
- File(PathStatus status, Revision const* rev, Revision const* priorRev):
- Status(status), Rev(rev), PriorRev(priorRev) {}
+ File()
+ : Status(PathUpdated)
+ , Rev(0)
+ , PriorRev(0)
+ {
+ }
+ File(PathStatus status, Revision const* rev, Revision const* priorRev)
+ : Status(status)
+ , Rev(rev)
+ , PriorRev(priorRev)
+ {
+ }
};
/** Convert a list of arguments to a human-readable command line. */
static std::string ComputeCommandLine(char const* const* cmd);
/** Run a command line and send output to given parsers. */
- bool RunChild(char const* const* cmd, OutputParser* out,
- OutputParser* err, const char* workDir = 0);
+ bool RunChild(char const* const* cmd, OutputParser* out, OutputParser* err,
+ const char* workDir = 0);
/** Run VC update command line and send output to given parsers. */
- bool RunUpdateCommand(char const* const* cmd,
- OutputParser* out, OutputParser* err = 0);
+ bool RunUpdateCommand(char const* const* cmd, OutputParser* out,
+ OutputParser* err = 0);
/** Write xml element for one file. */
void WriteXMLEntry(cmXMLWriter& xml, std::string const& path,
diff --git a/Source/CTest/cmParseBlanketJSCoverage.cxx b/Source/CTest/cmParseBlanketJSCoverage.cxx
index 1f1db3e..1e42847 100644
--- a/Source/CTest/cmParseBlanketJSCoverage.cxx
+++ b/Source/CTest/cmParseBlanketJSCoverage.cxx
@@ -18,76 +18,65 @@
#include <stdio.h>
#include <stdlib.h>
-
class cmParseBlanketJSCoverage::JSONParser
- {
+{
public:
- typedef cmCTestCoverageHandlerContainer::
- SingleFileCoverageVector FileLinesType;
+ typedef cmCTestCoverageHandlerContainer::SingleFileCoverageVector
+ FileLinesType;
JSONParser(cmCTestCoverageHandlerContainer& cont)
- : Coverage(cont)
- {
- }
+ : Coverage(cont)
+ {
+ }
- virtual ~JSONParser()
- {
- }
+ virtual ~JSONParser() {}
std::string getValue(std::string line, int type)
- {
+ {
size_t begIndex;
size_t endIndex;
endIndex = line.rfind(',');
begIndex = line.find_first_of(':');
- if(type == 0)
- {
+ if (type == 0) {
// A unique substring to remove the extra characters
// around the files name in the JSON (extra " and ,)
std::string foundFileName =
- line.substr(begIndex+3,endIndex-(begIndex+4));
+ line.substr(begIndex + 3, endIndex - (begIndex + 4));
return foundFileName;
- }
- else
- {
- return line.substr(begIndex,line.npos);
- }
+ } else {
+ return line.substr(begIndex, line.npos);
}
+ }
bool ParseFile(std::string file)
- {
+ {
FileLinesType localCoverageVector;
std::string filename;
bool foundFile = false;
- bool inSource = false;
+ bool inSource = false;
std::string covResult;
std::string line;
cmsys::ifstream in(file.c_str());
- if(!in)
- {
+ if (!in) {
return false;
- }
- while( cmSystemTools::GetLineFromStream(in, line))
- {
- if(line.find("filename") != line.npos)
- {
- if(foundFile)
- {
+ }
+ while (cmSystemTools::GetLineFromStream(in, line)) {
+ if (line.find("filename") != line.npos) {
+ if (foundFile) {
/*
* Upon finding a second file name, generate a
* vector within the total coverage to capture the
* information in the local vector
*/
FileLinesType& CoverageVector =
- this->Coverage.TotalCoverage[filename];
+ this->Coverage.TotalCoverage[filename];
CoverageVector = localCoverageVector;
localCoverageVector.clear();
- }
- foundFile= true;
- inSource = false;
- filename = getValue(line,0).c_str();
}
- else if((line.find("coverage") != line.npos) && foundFile && inSource )
- {
+ foundFile = true;
+ inSource = false;
+ filename = getValue(line, 0).c_str();
+ } else if ((line.find("coverage") != line.npos) && foundFile &&
+ inSource) {
/*
* two types of "coverage" in the JSON structure
*
@@ -97,68 +86,63 @@ public:
* FoundFile and foundSource ensure that
* only the value of the line coverage is captured
*/
- std::string result = getValue(line,1);
- result = result.substr(2,result.npos);
- if(result == "\"\"")
- {
+ std::string result = getValue(line, 1);
+ result = result.substr(2, result.npos);
+ if (result == "\"\"") {
// Empty quotation marks indicate that the
// line is not executable
localCoverageVector.push_back(-1);
- }
- else
- {
+ } else {
// Else, it contains the number of time executed
localCoverageVector.push_back(atoi(result.c_str()));
- }
- }
- else if(line.find("source") != line.npos)
- {
- inSource=true;
}
+ } else if (line.find("source") != line.npos) {
+ inSource = true;
}
+ }
// On exit, capture end of last file covered.
- FileLinesType& CoverageVector =
- this->Coverage.TotalCoverage[filename];
+ FileLinesType& CoverageVector = this->Coverage.TotalCoverage[filename];
CoverageVector = localCoverageVector;
localCoverageVector.clear();
return true;
- }
+ }
+
private:
cmCTestCoverageHandlerContainer& Coverage;
};
cmParseBlanketJSCoverage::cmParseBlanketJSCoverage(
- cmCTestCoverageHandlerContainer& cont, cmCTest* ctest)
- :Coverage(cont), CTest(ctest)
- {
- }
+ cmCTestCoverageHandlerContainer& cont, cmCTest* ctest)
+ : Coverage(cont)
+ , CTest(ctest)
+{
+}
bool cmParseBlanketJSCoverage::LoadCoverageData(std::vector<std::string> files)
- {
- size_t i=0;
+{
+ size_t i = 0;
std::string path;
- cmCTestOptionalLog(this->CTest,HANDLER_VERBOSE_OUTPUT,
- "Found " << files.size() <<" Files" << std::endl, this->Coverage.Quiet);
- for(i=0;i<files.size();i++)
- {
- cmCTestOptionalLog(this->CTest,HANDLER_VERBOSE_OUTPUT,
- "Reading JSON File " << files[i] << std::endl, this->Coverage.Quiet);
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Found " << files.size() << " Files" << std::endl,
+ this->Coverage.Quiet);
+ for (i = 0; i < files.size(); i++) {
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Reading JSON File " << files[i] << std::endl,
+ this->Coverage.Quiet);
- if(!this->ReadJSONFile(files[i]))
- {
+ if (!this->ReadJSONFile(files[i])) {
return false;
- }
}
- return true;
}
+ return true;
+}
bool cmParseBlanketJSCoverage::ReadJSONFile(std::string file)
- {
- cmParseBlanketJSCoverage::JSONParser parser
- (this->Coverage);
- cmCTestOptionalLog(this->CTest,HANDLER_VERBOSE_OUTPUT,
- "Parsing " << file << std::endl, this->Coverage.Quiet);
+{
+ cmParseBlanketJSCoverage::JSONParser parser(this->Coverage);
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Parsing " << file << std::endl, this->Coverage.Quiet);
parser.ParseFile(file);
return true;
- }
+}
diff --git a/Source/CTest/cmParseBlanketJSCoverage.h b/Source/CTest/cmParseBlanketJSCoverage.h
index d34492d..4fc64e7 100644
--- a/Source/CTest/cmParseBlanketJSCoverage.h
+++ b/Source/CTest/cmParseBlanketJSCoverage.h
@@ -15,7 +15,6 @@
#include "cmCTestCoverageHandler.h"
-
/** \class cmParseBlanketJSCoverage
* \brief Parse BlanketJS coverage information
*
@@ -33,13 +32,12 @@ class cmParseBlanketJSCoverage
{
public:
cmParseBlanketJSCoverage(cmCTestCoverageHandlerContainer& cont,
- cmCTest* ctest);
+ cmCTest* ctest);
bool LoadCoverageData(std::vector<std::string> files);
// Read the JSON output
bool ReadJSONFile(std::string file);
protected:
-
class JSONParser;
cmCTestCoverageHandlerContainer& Coverage;
cmCTest* CTest;
diff --git a/Source/CTest/cmParseCacheCoverage.cxx b/Source/CTest/cmParseCacheCoverage.cxx
index f838087..0916da2 100644
--- a/Source/CTest/cmParseCacheCoverage.cxx
+++ b/Source/CTest/cmParseCacheCoverage.cxx
@@ -7,44 +7,35 @@
#include <stdio.h>
#include <stdlib.h>
-
cmParseCacheCoverage::cmParseCacheCoverage(
- cmCTestCoverageHandlerContainer& cont,
- cmCTest* ctest)
- :cmParseMumpsCoverage(cont, ctest)
+ cmCTestCoverageHandlerContainer& cont, cmCTest* ctest)
+ : cmParseMumpsCoverage(cont, ctest)
{
}
-
bool cmParseCacheCoverage::LoadCoverageData(const char* d)
{
// load all the .mcov files in the specified directory
cmsys::Directory dir;
- if(!dir.Load(d))
- {
+ if (!dir.Load(d)) {
return false;
- }
+ }
size_t numf;
unsigned int i;
numf = dir.GetNumberOfFiles();
- for (i = 0; i < numf; i++)
- {
+ for (i = 0; i < numf; i++) {
std::string file = dir.GetFile(i);
- if(file != "." && file != ".."
- && !cmSystemTools::FileIsDirectory(file))
- {
+ if (file != "." && file != ".." && !cmSystemTools::FileIsDirectory(file)) {
std::string path = d;
path += "/";
path += file;
- if(cmSystemTools::GetFilenameLastExtension(path) == ".cmcov")
- {
- if(!this->ReadCMCovFile(path.c_str()))
- {
+ if (cmSystemTools::GetFilenameLastExtension(path) == ".cmcov") {
+ if (!this->ReadCMCovFile(path.c_str())) {
return false;
- }
}
}
}
+ }
return true;
}
@@ -55,32 +46,26 @@ void cmParseCacheCoverage::RemoveUnCoveredFiles()
// that only have -1 or 0 for the lines.
cmCTestCoverageHandlerContainer::TotalCoverageMap::iterator ci =
this->Coverage.TotalCoverage.begin();
- while(ci != this->Coverage.TotalCoverage.end())
- {
- cmCTestCoverageHandlerContainer::SingleFileCoverageVector& v =
- ci->second;
+ while (ci != this->Coverage.TotalCoverage.end()) {
+ cmCTestCoverageHandlerContainer::SingleFileCoverageVector& v = ci->second;
bool nothing = true;
- for(cmCTestCoverageHandlerContainer::SingleFileCoverageVector::iterator i=
- v.begin(); i != v.end(); ++i)
- {
- if(*i > 0)
- {
+ for (cmCTestCoverageHandlerContainer::SingleFileCoverageVector::iterator
+ i = v.begin();
+ i != v.end(); ++i) {
+ if (*i > 0) {
nothing = false;
break;
- }
}
- if(nothing)
- {
+ }
+ if (nothing) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "No coverage found in: " << ci->first
- << std::endl, this->Coverage.Quiet);
+ "No coverage found in: " << ci->first << std::endl,
+ this->Coverage.Quiet);
this->Coverage.TotalCoverage.erase(ci++);
- }
- else
- {
+ } else {
++ci;
- }
}
+ }
}
bool cmParseCacheCoverage::SplitString(std::vector<std::string>& args,
@@ -88,18 +73,16 @@ bool cmParseCacheCoverage::SplitString(std::vector<std::string>& args,
{
std::string::size_type pos1 = 0;
std::string::size_type pos2 = line.find(',', 0);
- if(pos2 == std::string::npos)
- {
+ if (pos2 == std::string::npos) {
return false;
- }
+ }
std::string arg;
- while(pos2 != std::string::npos)
- {
- arg = line.substr(pos1, pos2-pos1);
+ while (pos2 != std::string::npos) {
+ arg = line.substr(pos1, pos2 - pos1);
args.push_back(arg);
- pos1 = pos2+1;
- pos2 = line.find(',',pos1);
- }
+ pos1 = pos2 + 1;
+ pos2 = line.find(',', pos1);
+ }
arg = line.substr(pos1);
args.push_back(arg);
return true;
@@ -108,126 +91,106 @@ bool cmParseCacheCoverage::SplitString(std::vector<std::string>& args,
bool cmParseCacheCoverage::ReadCMCovFile(const char* file)
{
cmsys::ifstream in(file);
- if(!in)
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Can not open : "
- << file << "\n");
+ if (!in) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "Can not open : " << file << "\n");
return false;
- }
+ }
std::string line;
std::vector<std::string> separateLine;
- if(!cmSystemTools::GetLineFromStream(in, line))
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Empty file : "
- << file << " referenced in this line of cmcov data:\n"
- "[" << line << "]\n");
+ if (!cmSystemTools::GetLineFromStream(in, line)) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "Empty file : "
+ << file << " referenced in this line of cmcov data:\n"
+ "["
+ << line << "]\n");
return false;
- }
+ }
separateLine.clear();
this->SplitString(separateLine, line);
- if(separateLine.size() !=4 || separateLine[0] != "Routine"
- || separateLine[1] != "Line" || separateLine[2] != "RtnLine"
- || separateLine[3] != "Code")
- {
+ if (separateLine.size() != 4 || separateLine[0] != "Routine" ||
+ separateLine[1] != "Line" || separateLine[2] != "RtnLine" ||
+ separateLine[3] != "Code") {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Bad first line of cmcov file : "
- << file << " line:\n"
- "[" << line << "]\n");
- }
+ "Bad first line of cmcov file : " << file << " line:\n"
+ "["
+ << line << "]\n");
+ }
std::string routine;
std::string filepath;
- while(cmSystemTools::GetLineFromStream(in, line))
- {
+ while (cmSystemTools::GetLineFromStream(in, line)) {
// clear out line argument vector
separateLine.clear();
// parse the comma separated line
this->SplitString(separateLine, line);
// might have more because code could have a quoted , in it
// but we only care about the first 3 args anyway
- if(separateLine.size() < 4)
- {
+ if (separateLine.size() < 4) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Bad line of cmcov file expected at least 4 found: "
- << separateLine.size() << " "
- << file << " line:\n"
- "[" << line << "]\n");
- for(std::string::size_type i = 0; i < separateLine.size(); ++i)
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE,""
- << separateLine[1] << " ");
- }
+ << separateLine.size() << " " << file << " line:\n"
+ "["
+ << line << "]\n");
+ for (std::string::size_type i = 0; i < separateLine.size(); ++i) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "" << separateLine[1] << " ");
+ }
cmCTestLog(this->CTest, ERROR_MESSAGE, "\n");
return false;
- }
+ }
// if we do not have a routine yet, then it should be
// the first argument in the vector
- if(routine.empty())
- {
+ if (routine.empty()) {
routine = separateLine[0];
// Find the full path to the file
- if(!this->FindMumpsFile(routine, filepath))
- {
+ if (!this->FindMumpsFile(routine, filepath)) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Could not find mumps file for routine: "
- << routine << "\n");
+ "Could not find mumps file for routine: " << routine
+ << "\n");
filepath = "";
continue; // move to next line
- }
}
+ }
// if we have a routine name, check for end of routine
- else
- {
+ else {
// Totals in arg 0 marks the end of a routine
- if(separateLine[0].substr(0, 6) == "Totals")
- {
+ if (separateLine[0].substr(0, 6) == "Totals") {
routine = ""; // at the end of this routine
filepath = "";
continue; // move to next line
- }
}
+ }
// if the file path was not found for the routine
// move to next line. We should have already warned
// after the call to FindMumpsFile that we did not find
// it, so don't report again to cut down on output
- if(filepath.empty())
- {
+ if (filepath.empty()) {
continue;
- }
+ }
// now we are ready to set the coverage from the line of data
- cmCTestCoverageHandlerContainer::SingleFileCoverageVector&
- coverageVector = this->Coverage.TotalCoverage[filepath];
- std::string::size_type linenumber = atoi(separateLine[1].c_str()) -1;
+ cmCTestCoverageHandlerContainer::SingleFileCoverageVector& coverageVector =
+ this->Coverage.TotalCoverage[filepath];
+ std::string::size_type linenumber = atoi(separateLine[1].c_str()) - 1;
int count = atoi(separateLine[2].c_str());
- if(linenumber > coverageVector.size())
- {
+ if (linenumber > coverageVector.size()) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Parse error line is greater than number of lines in file: "
- << linenumber << " " << filepath << "\n");
+ << linenumber << " " << filepath << "\n");
continue; // skip setting count to avoid crash
- }
+ }
// now add to count for linenumber
// for some reason the cache coverage adds extra lines to the
// end of the file in some cases. Since they do not exist, we will
// mark them as non executable
- while(linenumber >= coverageVector.size())
- {
+ while (linenumber >= coverageVector.size()) {
coverageVector.push_back(-1);
- }
+ }
// Accounts for lines that were previously marked
// as non-executable code (-1). if the parser comes back with
// a non-zero count, increase the count by 1 to push the line
// into the executable code set in addition to the count found.
- if(coverageVector[linenumber] == -1 &&
- count > 0)
- {
- coverageVector[linenumber] += count+1;
- }
- else
- {
- coverageVector[linenumber] += count;
- }
+ if (coverageVector[linenumber] == -1 && count > 0) {
+ coverageVector[linenumber] += count + 1;
+ } else {
+ coverageVector[linenumber] += count;
}
+ }
return true;
}
diff --git a/Source/CTest/cmParseCacheCoverage.h b/Source/CTest/cmParseCacheCoverage.h
index 114eb92..bd331d0 100644
--- a/Source/CTest/cmParseCacheCoverage.h
+++ b/Source/CTest/cmParseCacheCoverage.h
@@ -24,8 +24,8 @@
class cmParseCacheCoverage : public cmParseMumpsCoverage
{
public:
- cmParseCacheCoverage(cmCTestCoverageHandlerContainer& cont,
- cmCTest* ctest);
+ cmParseCacheCoverage(cmCTestCoverageHandlerContainer& cont, cmCTest* ctest);
+
protected:
// implement virtual from parent
bool LoadCoverageData(const char* dir);
@@ -34,9 +34,7 @@ protected:
// Read a single mcov file
bool ReadCMCovFile(const char* f);
// split a string based on ,
- bool SplitString(std::vector<std::string>& args,
- std::string const& line);
+ bool SplitString(std::vector<std::string>& args, std::string const& line);
};
-
#endif
diff --git a/Source/CTest/cmParseCoberturaCoverage.cxx b/Source/CTest/cmParseCoberturaCoverage.cxx
index d3b99fb..3bdae17 100644
--- a/Source/CTest/cmParseCoberturaCoverage.cxx
+++ b/Source/CTest/cmParseCoberturaCoverage.cxx
@@ -5,117 +5,97 @@
#include <cmsys/Directory.hxx>
#include <cmsys/FStream.hxx>
-class cmParseCoberturaCoverage::XMLParser: public cmXMLParser
+class cmParseCoberturaCoverage::XMLParser : public cmXMLParser
{
public:
XMLParser(cmCTest* ctest, cmCTestCoverageHandlerContainer& cont)
- : CTest(ctest), Coverage(cont)
+ : CTest(ctest)
+ , Coverage(cont)
{
- this->InSources = false;
- this->InSource = false;
- this->SkipThisClass = false;
- this->FilePaths.push_back(this->Coverage.SourceDir);
- this->FilePaths.push_back(this->Coverage.BinaryDir);
- this->CurFileName = "";
+ this->InSources = false;
+ this->InSource = false;
+ this->SkipThisClass = false;
+ this->FilePaths.push_back(this->Coverage.SourceDir);
+ this->FilePaths.push_back(this->Coverage.BinaryDir);
+ this->CurFileName = "";
}
- virtual ~XMLParser()
- {
- }
+ virtual ~XMLParser() {}
protected:
-
-
virtual void EndElement(const std::string& name)
{
- if(name == "source")
- {
- this->InSource=false;
- }
- else if (name == "sources")
- {
- this->InSources=false;
- }
- else if(name == "class")
- {
+ if (name == "source") {
+ this->InSource = false;
+ } else if (name == "sources") {
+ this->InSources = false;
+ } else if (name == "class") {
this->SkipThisClass = false;
- }
+ }
}
virtual void CharacterDataHandler(const char* data, int length)
{
- std::string tmp;
- tmp.insert(0,data,length);
- if (this->InSources && this->InSource)
- {
- this->FilePaths.push_back(tmp);
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Adding Source: " << tmp << std::endl, this->Coverage.Quiet);
- }
+ std::string tmp;
+ tmp.insert(0, data, length);
+ if (this->InSources && this->InSource) {
+ this->FilePaths.push_back(tmp);
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Adding Source: " << tmp << std::endl,
+ this->Coverage.Quiet);
+ }
}
virtual void StartElement(const std::string& name, const char** atts)
{
std::string FoundSource;
std::string finalpath = "";
- if(name == "source")
- {
+ if (name == "source") {
this->InSource = true;
- }
- else if(name == "sources")
- {
+ } else if (name == "sources") {
this->InSources = true;
- }
- else if(name == "class")
- {
+ } else if (name == "class") {
int tagCount = 0;
- while(true)
- {
- if(strcmp(atts[tagCount], "filename") == 0)
- {
+ while (true) {
+ if (strcmp(atts[tagCount], "filename") == 0) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Reading file: " << atts[tagCount+1]<< std::endl,
- this->Coverage.Quiet);
- std::string filename = atts[tagCount+1];
+ "Reading file: " << atts[tagCount + 1]
+ << std::endl,
+ this->Coverage.Quiet);
+ std::string filename = atts[tagCount + 1];
this->CurFileName = "";
// Check if this is an absolute path that falls within our
// source or binary directories.
- for(size_t i=0;i < FilePaths.size();i++)
- {
- if (filename.find(FilePaths[i]) == 0)
- {
+ for (size_t i = 0; i < FilePaths.size(); i++) {
+ if (filename.find(FilePaths[i]) == 0) {
this->CurFileName = filename;
break;
- }
}
+ }
- if (this->CurFileName == "")
- {
+ if (this->CurFileName == "") {
// Check if this is a path that is relative to our source or
// binary directories.
- for(size_t i=0;i < FilePaths.size();i++)
- {
+ for (size_t i = 0; i < FilePaths.size(); i++) {
finalpath = FilePaths[i] + "/" + filename;
- if(cmSystemTools::FileExists(finalpath.c_str()))
- {
+ if (cmSystemTools::FileExists(finalpath.c_str())) {
this->CurFileName = finalpath;
break;
- }
}
}
+ }
cmsys::ifstream fin(this->CurFileName.c_str());
- if(this->CurFileName == "" || !fin )
- {
- this->CurFileName = this->Coverage.BinaryDir + "/" +
- atts[tagCount+1];
+ if (this->CurFileName == "" || !fin) {
+ this->CurFileName =
+ this->Coverage.BinaryDir + "/" + atts[tagCount + 1];
fin.open(this->CurFileName.c_str());
- if (!fin)
- {
+ if (!fin) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Skipping system file " << filename << std::endl,
- this->Coverage.Quiet);
+ "Skipping system file " << filename
+ << std::endl,
+ this->Coverage.Quiet);
this->SkipThisClass = true;
break;
@@ -124,8 +104,7 @@ protected:
std::string line;
FileLinesType& curFileLines =
this->Coverage.TotalCoverage[this->CurFileName];
- while(cmSystemTools::GetLineFromStream(fin, line))
- {
+ while (cmSystemTools::GetLineFromStream(fin, line)) {
curFileLines.push_back(-1);
}
@@ -133,34 +112,26 @@ protected:
}
++tagCount;
}
- }
- else if(name == "line")
- {
+ } else if (name == "line") {
int tagCount = 0;
int curNumber = -1;
int curHits = -1;
- while(true)
- {
- if(this->SkipThisClass)
- {
+ while (true) {
+ if (this->SkipThisClass) {
break;
- }
- if(strcmp(atts[tagCount], "hits") == 0)
- {
- curHits = atoi(atts[tagCount+1]);
}
- else if(strcmp(atts[tagCount], "number") == 0)
- {
- curNumber = atoi(atts[tagCount+1]);
+ if (strcmp(atts[tagCount], "hits") == 0) {
+ curHits = atoi(atts[tagCount + 1]);
+ } else if (strcmp(atts[tagCount], "number") == 0) {
+ curNumber = atoi(atts[tagCount + 1]);
}
- if(curHits > -1 && curNumber > 0)
- {
+ if (curHits > -1 && curNumber > 0) {
FileLinesType& curFileLines =
this->Coverage.TotalCoverage[this->CurFileName];
- {
- curFileLines[curNumber-1] = curHits;
- }
+ {
+ curFileLines[curNumber - 1] = curHits;
+ }
break;
}
++tagCount;
@@ -169,24 +140,21 @@ protected:
}
private:
-
bool InSources;
bool InSource;
bool SkipThisClass;
std::vector<std::string> FilePaths;
typedef cmCTestCoverageHandlerContainer::SingleFileCoverageVector
- FileLinesType;
+ FileLinesType;
cmCTest* CTest;
cmCTestCoverageHandlerContainer& Coverage;
std::string CurFileName;
-
};
-
cmParseCoberturaCoverage::cmParseCoberturaCoverage(
- cmCTestCoverageHandlerContainer& cont,
- cmCTest* ctest)
- :Coverage(cont), CTest(ctest)
+ cmCTestCoverageHandlerContainer& cont, cmCTest* ctest)
+ : Coverage(cont)
+ , CTest(ctest)
{
}
diff --git a/Source/CTest/cmParseCoberturaCoverage.h b/Source/CTest/cmParseCoberturaCoverage.h
index c3e3ec9..4fa6d10 100644
--- a/Source/CTest/cmParseCoberturaCoverage.h
+++ b/Source/CTest/cmParseCoberturaCoverage.h
@@ -27,11 +27,10 @@
class cmParseCoberturaCoverage
{
public:
-
//! Create the coverage parser by passing in the coverage handler
//! container and the cmCTest object
cmParseCoberturaCoverage(cmCTestCoverageHandlerContainer& cont,
- cmCTest* ctest);
+ cmCTest* ctest);
bool inSources;
bool inSource;
@@ -40,7 +39,6 @@ public:
bool ReadCoverageXML(const char* xmlFile);
private:
-
class XMLParser;
cmCTestCoverageHandlerContainer& Coverage;
cmCTest* CTest;
diff --git a/Source/CTest/cmParseDelphiCoverage.cxx b/Source/CTest/cmParseDelphiCoverage.cxx
index 09c4f02..d20b16a 100644
--- a/Source/CTest/cmParseDelphiCoverage.cxx
+++ b/Source/CTest/cmParseDelphiCoverage.cxx
@@ -8,93 +8,76 @@
#include <stdio.h>
#include <stdlib.h>
-
class cmParseDelphiCoverage::HTMLParser
{
public:
typedef cmCTestCoverageHandlerContainer::SingleFileCoverageVector
- FileLinesType;
+ FileLinesType;
HTMLParser(cmCTest* ctest, cmCTestCoverageHandlerContainer& cont)
- : CTest(ctest), Coverage(cont)
- {
- }
+ : CTest(ctest)
+ , Coverage(cont)
+ {
+ }
- virtual ~HTMLParser()
- {
- }
+ virtual ~HTMLParser() {}
- bool initializeDelphiFile(const std::string filename,
- cmParseDelphiCoverage::HTMLParser::FileLinesType &coverageVector)
- {
+ bool initializeDelphiFile(
+ const std::string filename,
+ cmParseDelphiCoverage::HTMLParser::FileLinesType& coverageVector)
+ {
std::string line;
size_t comPos;
size_t semiPos;
- bool blockComFlag= false;
- bool lineComFlag= false;
+ bool blockComFlag = false;
+ bool lineComFlag = false;
std::vector<std::string> beginSet;
cmsys::ifstream in(filename.c_str());
- if(!in)
- {
+ if (!in) {
return false;
- }
- while(cmSystemTools::GetLineFromStream(in, line))
- {
- lineComFlag=false;
+ }
+ while (cmSystemTools::GetLineFromStream(in, line)) {
+ lineComFlag = false;
// Unique cases found in lines.
size_t beginPos = line.find("begin");
- //Check that the begin is the first non-space string on the line
- if( (beginPos == line.find_first_not_of(' ')) && beginPos != line.npos )
- {
+ // Check that the begin is the first non-space string on the line
+ if ((beginPos == line.find_first_not_of(' ')) && beginPos != line.npos) {
beginSet.push_back("begin");
coverageVector.push_back(-1);
continue;
- }
- else if(line.find('{') != line.npos)
- {
- blockComFlag=true;
- }
- else if(line.find('}') != line.npos)
- {
- blockComFlag=false;
+ } else if (line.find('{') != line.npos) {
+ blockComFlag = true;
+ } else if (line.find('}') != line.npos) {
+ blockComFlag = false;
coverageVector.push_back(-1);
continue;
- }
- else if((line.find("end;") != line.npos)
- && !beginSet.empty())
- {
+ } else if ((line.find("end;") != line.npos) && !beginSet.empty()) {
beginSet.pop_back();
coverageVector.push_back(-1);
continue;
- }
+ }
// This checks for comments after lines of code, finding the
// comment symbol after the ending semicolon.
comPos = line.find("//");
- if(comPos != line.npos)
- {
- semiPos= line.find(';');
- if(comPos < semiPos)
- {
- lineComFlag=true;
- }
+ if (comPos != line.npos) {
+ semiPos = line.find(';');
+ if (comPos < semiPos) {
+ lineComFlag = true;
}
- //Based up what was found, add a line to the coverageVector
- if(!beginSet.empty() && line != "" && !blockComFlag
- && !lineComFlag)
- {
+ }
+ // Based up what was found, add a line to the coverageVector
+ if (!beginSet.empty() && line != "" && !blockComFlag && !lineComFlag) {
coverageVector.push_back(0);
- }
- else
- {
+ } else {
coverageVector.push_back(-1);
- }
}
- return true;
}
+ return true;
+ }
bool ParseFile(const char* file)
- {
- std::string line=file;
+ {
+ std::string line = file;
std::string lineresult;
std::string lastroutine;
std::string filename;
@@ -117,28 +100,25 @@ public:
* to see if it ends in '.pas'. If it can't be found,
* exit the function.
*/
- while(true)
- {
- lastoffset = line.find('(',pos);
- if(lastoffset==line.npos)
- {
- cmCTestOptionalLog(this->CTest,HANDLER_VERBOSE_OUTPUT,
- endnamepos << "File not found " << lastoffset << std::endl,
- this->Coverage.Quiet);
+ while (true) {
+ lastoffset = line.find('(', pos);
+ if (lastoffset == line.npos) {
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, endnamepos
+ << "File not found " << lastoffset << std::endl,
+ this->Coverage.Quiet);
return false;
- }
- endnamepos = line.find(')',lastoffset);
- filename = line.substr(lastoffset+1,
- (endnamepos-1)-lastoffset);
- if(filename.find(".pas") != filename.npos)
- {
- cmCTestOptionalLog(this->CTest,HANDLER_VERBOSE_OUTPUT,
- "Coverage found for file: " << filename << std::endl,
- this->Coverage.Quiet);
+ }
+ endnamepos = line.find(')', lastoffset);
+ filename = line.substr(lastoffset + 1, (endnamepos - 1) - lastoffset);
+ if (filename.find(".pas") != filename.npos) {
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Coverage found for file: " << filename
+ << std::endl,
+ this->Coverage.Quiet);
break;
- }
- pos = lastoffset+1;
}
+ pos = lastoffset + 1;
+ }
/*
* Glob through the source directory for the
* file found above
@@ -149,32 +129,29 @@ public:
std::string glob = Coverage.SourceDir + "*/" + filename;
gl.FindFiles(glob);
std::vector<std::string> const& files = gl.GetFiles();
- if(files.empty())
- {
+ if (files.empty()) {
/*
* If that doesn't find any matching files
* return a failure.
*/
- cmCTestOptionalLog(this->CTest,HANDLER_VERBOSE_OUTPUT,
- "Unable to find file matching" << glob << std::endl,
- this->Coverage.Quiet);
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Unable to find file matching" << glob << std::endl,
+ this->Coverage.Quiet);
return false;
- }
- FileLinesType& coverageVector =
- this->Coverage.TotalCoverage[files[0]];
+ }
+ FileLinesType& coverageVector = this->Coverage.TotalCoverage[files[0]];
/*
* Initialize the file to have all code between 'begin' and
* 'end' tags marked as executable
*/
- this->initializeDelphiFile(files[0],coverageVector);
+ this->initializeDelphiFile(files[0], coverageVector);
cmsys::ifstream in(file);
- if(!in)
- {
+ if (!in) {
return false;
- }
+ }
/*
* Now read the HTML file, looking for the lines that have an
@@ -188,67 +165,61 @@ public:
*
*/
- while( cmSystemTools::GetLineFromStream(in, line))
- {
- if(line.find("inline") == line.npos)
- {
+ while (cmSystemTools::GetLineFromStream(in, line)) {
+ if (line.find("inline") == line.npos) {
continue;
- }
+ }
lastoffset = line.find("class=");
- endcovpos = line.find(">",lastoffset);
- lineresult = line.substr(lastoffset+7,(endcovpos-8)-lastoffset);
-
- if(lineresult == "covered")
- {
- afterLineNum = line.find('<',endcovpos+5);
- filelineoffset= line.substr(endcovpos+5,
- afterLineNum-(endcovpos+5));
- coverageVector[atoi(filelineoffset.c_str())-1] = 1;
- }
+ endcovpos = line.find(">", lastoffset);
+ lineresult = line.substr(lastoffset + 7, (endcovpos - 8) - lastoffset);
+
+ if (lineresult == "covered") {
+ afterLineNum = line.find('<', endcovpos + 5);
+ filelineoffset =
+ line.substr(endcovpos + 5, afterLineNum - (endcovpos + 5));
+ coverageVector[atoi(filelineoffset.c_str()) - 1] = 1;
}
- return true;
}
+ return true;
+ }
-
- private:
- cmCTest* CTest;
- cmCTestCoverageHandlerContainer& Coverage;
+private:
+ cmCTest* CTest;
+ cmCTestCoverageHandlerContainer& Coverage;
};
cmParseDelphiCoverage::cmParseDelphiCoverage(
- cmCTestCoverageHandlerContainer& cont, cmCTest* ctest)
- :Coverage(cont), CTest(ctest)
- {
- }
+ cmCTestCoverageHandlerContainer& cont, cmCTest* ctest)
+ : Coverage(cont)
+ , CTest(ctest)
+{
+}
bool cmParseDelphiCoverage::LoadCoverageData(
const std::vector<std::string> files)
- {
+{
size_t i;
std::string path;
size_t numf = files.size();
- for (i = 0; i < numf; i++)
- {
+ for (i = 0; i < numf; i++) {
path = files[i];
- cmCTestOptionalLog(this->CTest,HANDLER_VERBOSE_OUTPUT,
- "Reading HTML File " << path << std::endl, this->Coverage.Quiet);
- if(cmSystemTools::GetFilenameLastExtension(path) == ".html")
- {
- if(!this->ReadDelphiHTML(path.c_str()))
- {
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Reading HTML File " << path << std::endl,
+ this->Coverage.Quiet);
+ if (cmSystemTools::GetFilenameLastExtension(path) == ".html") {
+ if (!this->ReadDelphiHTML(path.c_str())) {
return false;
- }
}
}
- return true;
}
+ return true;
+}
bool cmParseDelphiCoverage::ReadDelphiHTML(const char* file)
- {
- cmParseDelphiCoverage::HTMLParser
- parser(this->CTest, this->Coverage);
+{
+ cmParseDelphiCoverage::HTMLParser parser(this->CTest, this->Coverage);
parser.ParseFile(file);
return true;
- }
+}
diff --git a/Source/CTest/cmParseDelphiCoverage.h b/Source/CTest/cmParseDelphiCoverage.h
index 2c3f3b3..06dea2b 100644
--- a/Source/CTest/cmParseDelphiCoverage.h
+++ b/Source/CTest/cmParseDelphiCoverage.h
@@ -15,7 +15,6 @@
#include "cmCTestCoverageHandler.h"
-
/** \class cmParseDelphiCoverage
* \brief Parse Delphi coverage information
*
@@ -26,20 +25,17 @@
*/
class cmParseDelphiCoverage
- {
- public:
- cmParseDelphiCoverage(cmCTestCoverageHandlerContainer& cont,
- cmCTest* ctest);
- bool LoadCoverageData(const std::vector<std::string> files);
- bool ReadDelphiHTML(const char* file);
- // Read a single HTML file from output
- bool ReadHTMLFile(const char* f);
-
-
- protected:
-
- class HTMLParser;
- cmCTestCoverageHandlerContainer& Coverage;
- cmCTest* CTest;
- };
+{
+public:
+ cmParseDelphiCoverage(cmCTestCoverageHandlerContainer& cont, cmCTest* ctest);
+ bool LoadCoverageData(const std::vector<std::string> files);
+ bool ReadDelphiHTML(const char* file);
+ // Read a single HTML file from output
+ bool ReadHTMLFile(const char* f);
+
+protected:
+ class HTMLParser;
+ cmCTestCoverageHandlerContainer& Coverage;
+ cmCTest* CTest;
+};
#endif
diff --git a/Source/CTest/cmParseGTMCoverage.cxx b/Source/CTest/cmParseGTMCoverage.cxx
index ae7dedb..a065903 100644
--- a/Source/CTest/cmParseGTMCoverage.cxx
+++ b/Source/CTest/cmParseGTMCoverage.cxx
@@ -7,65 +7,54 @@
#include <stdio.h>
#include <stdlib.h>
-
cmParseGTMCoverage::cmParseGTMCoverage(cmCTestCoverageHandlerContainer& cont,
cmCTest* ctest)
- :cmParseMumpsCoverage(cont, ctest)
+ : cmParseMumpsCoverage(cont, ctest)
{
}
-
bool cmParseGTMCoverage::LoadCoverageData(const char* d)
{
// load all the .mcov files in the specified directory
cmsys::Directory dir;
- if(!dir.Load(d))
- {
+ if (!dir.Load(d)) {
return false;
- }
+ }
size_t numf;
unsigned int i;
numf = dir.GetNumberOfFiles();
- for (i = 0; i < numf; i++)
- {
+ for (i = 0; i < numf; i++) {
std::string file = dir.GetFile(i);
- if(file != "." && file != ".."
- && !cmSystemTools::FileIsDirectory(file))
- {
+ if (file != "." && file != ".." && !cmSystemTools::FileIsDirectory(file)) {
std::string path = d;
path += "/";
path += file;
- if(cmSystemTools::GetFilenameLastExtension(path) == ".mcov")
- {
- if(!this->ReadMCovFile(path.c_str()))
- {
+ if (cmSystemTools::GetFilenameLastExtension(path) == ".mcov") {
+ if (!this->ReadMCovFile(path.c_str())) {
return false;
- }
}
}
}
+ }
return true;
}
bool cmParseGTMCoverage::ReadMCovFile(const char* file)
{
cmsys::ifstream in(file);
- if(!in)
- {
+ if (!in) {
return false;
- }
+ }
std::string line;
std::string lastfunction;
std::string lastroutine;
std::string lastpath;
int lastoffset = 0;
- while( cmSystemTools::GetLineFromStream(in, line))
- {
+ while (cmSystemTools::GetLineFromStream(in, line)) {
// only look at lines that have coverage data
- if(line.find("^ZZCOVERAGE") == line.npos)
- {
+ if (line.find("^ZZCOVERAGE") == line.npos) {
continue;
- }
+ }
std::string filepath;
std::string function;
std::string routine;
@@ -73,66 +62,51 @@ bool cmParseGTMCoverage::ReadMCovFile(const char* file)
int count = 0;
this->ParseMCOVLine(line, routine, function, linenumber, count);
// skip this one
- if(routine == "RSEL")
- {
+ if (routine == "RSEL") {
continue;
- }
+ }
// no need to search the file if we just did it
- if(function == lastfunction && lastroutine == routine)
- {
- if(!lastpath.empty())
- {
- this->Coverage.TotalCoverage[lastpath][lastoffset + linenumber]
- += count;
- }
- else
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Can not find mumps file : "
- << lastroutine <<
- " referenced in this line of mcov data:\n"
- "[" << line << "]\n");
- }
- continue;
+ if (function == lastfunction && lastroutine == routine) {
+ if (!lastpath.empty()) {
+ this->Coverage.TotalCoverage[lastpath][lastoffset + linenumber] +=
+ count;
+ } else {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "Can not find mumps file : "
+ << lastroutine
+ << " referenced in this line of mcov data:\n"
+ "["
+ << line << "]\n");
}
+ continue;
+ }
// Find the full path to the file
bool found = this->FindMumpsFile(routine, filepath);
- if(found)
- {
+ if (found) {
int lineoffset = 0;
- if(this->FindFunctionInMumpsFile(filepath,
- function,
- lineoffset))
- {
+ if (this->FindFunctionInMumpsFile(filepath, function, lineoffset)) {
cmCTestCoverageHandlerContainer::SingleFileCoverageVector&
coverageVector = this->Coverage.TotalCoverage[filepath];
// This section accounts for lines that were previously marked
// as non-executable code (-1), if the parser comes back with
// a non-zero count, increase the count by 1 to push the line
// into the executable code set in addtion to the count found.
- if(coverageVector[lineoffset + linenumber] == -1 &&
- count > 0)
- {
- coverageVector[lineoffset + linenumber] += count+1;
- }
- else
- {
+ if (coverageVector[lineoffset + linenumber] == -1 && count > 0) {
+ coverageVector[lineoffset + linenumber] += count + 1;
+ } else {
coverageVector[lineoffset + linenumber] += count;
- }
- lastoffset = lineoffset;
}
+ lastoffset = lineoffset;
}
- else
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Can not find mumps file : "
- << routine << " referenced in this line of mcov data:\n"
- "[" << line << "]\n");
- }
+ } else {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "Can not find mumps file : "
+ << routine << " referenced in this line of mcov data:\n"
+ "["
+ << line << "]\n");
+ }
lastfunction = function;
lastroutine = routine;
lastpath = filepath;
- }
+ }
return true;
}
@@ -141,47 +115,39 @@ bool cmParseGTMCoverage::FindFunctionInMumpsFile(std::string const& filepath,
int& lineoffset)
{
cmsys::ifstream in(filepath.c_str());
- if(!in)
- {
+ if (!in) {
return false;
- }
+ }
std::string line;
int linenum = 0;
- while( cmSystemTools::GetLineFromStream(in, line))
- {
+ while (cmSystemTools::GetLineFromStream(in, line)) {
std::string::size_type pos = line.find(function.c_str());
- if(pos == 0)
- {
+ if (pos == 0) {
char nextchar = line[function.size()];
- if(nextchar == ' ' || nextchar == '('|| nextchar == '\t')
- {
+ if (nextchar == ' ' || nextchar == '(' || nextchar == '\t') {
lineoffset = linenum;
return true;
- }
}
- if(pos == 1)
- {
+ }
+ if (pos == 1) {
char prevchar = line[0];
- char nextchar = line[function.size()+1];
- if(prevchar == '%' && (nextchar == ' ' || nextchar == '('))
- {
+ char nextchar = line[function.size() + 1];
+ if (prevchar == '%' && (nextchar == ' ' || nextchar == '(')) {
lineoffset = linenum;
return true;
- }
}
- linenum++; // move to next line count
}
+ linenum++; // move to next line count
+ }
lineoffset = 0;
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Could not find entry point : "
- << function << " in " << filepath << "\n");
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "Could not find entry point : "
+ << function << " in " << filepath << "\n");
return false;
}
bool cmParseGTMCoverage::ParseMCOVLine(std::string const& line,
std::string& routine,
- std::string& function,
- int& linenumber,
+ std::string& function, int& linenumber,
int& count)
{
// this method parses lines from the .mcov file
@@ -197,60 +163,49 @@ bool cmParseGTMCoverage::ParseMCOVLine(std::string const& line,
std::vector<std::string> args;
std::string::size_type pos = line.find('(', 0);
// if no ( is found, then return line has no coverage
- if(pos == std::string::npos)
- {
+ if (pos == std::string::npos) {
return false;
- }
+ }
std::string arg;
bool done = false;
// separate out all of the comma separated arguments found
// in the COVERAGE(...) line
- while(line[pos] && !done)
- {
+ while (line[pos] && !done) {
// save the char we are looking at
char cur = line[pos];
// , or ) means end of argument
- if(cur == ',' || cur == ')')
- {
+ if (cur == ',' || cur == ')') {
// save the argument into the argument vector
args.push_back(arg);
// start on a new argument
arg = "";
// if we are at the end of the ), then finish while loop
- if(cur == ')')
- {
+ if (cur == ')') {
done = true;
- }
}
- else
- {
+ } else {
// all chars except ", (, and % get stored in the arg string
- if(cur != '\"' && cur != '(' && cur != '%')
- {
+ if (cur != '\"' && cur != '(' && cur != '%') {
arg.append(1, line[pos]);
- }
}
+ }
// move to next char
pos++;
- }
+ }
// now parse the right hand side of the =
pos = line.find('=');
// no = found, this is an error
- if(pos == line.npos)
- {
+ if (pos == line.npos) {
return false;
- }
+ }
pos++; // move past =
// if the next positing is not a ", then this is a
// COVERAGE(..)=count line and turn the rest of the string
// past the = into an integer and set it to count
- if(line[pos] != '\"')
- {
+ if (line[pos] != '\"') {
count = atoi(line.substr(pos).c_str());
- }
- else
- {
+ } else {
// this means line[pos] is a ", and we have a
// COVERAGE(...)="1:0:0:0" type of line
pos++; // move past "
@@ -258,32 +213,28 @@ bool cmParseGTMCoverage::ParseMCOVLine(std::string const& line,
std::string::size_type pos2 = line.find(':', pos);
// turn the string between the " and the first : into an integer
// and set it to count
- count = atoi(line.substr(pos, pos2-pos).c_str());
- }
+ count = atoi(line.substr(pos, pos2 - pos).c_str());
+ }
// less then two arguments is an error
- if(args.size() < 2)
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Error parsing mcov line: [" << line << "]\n");
+ if (args.size() < 2) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "Error parsing mcov line: ["
+ << line << "]\n");
return false;
- }
- routine = args[0]; // the routine is the first argument
+ }
+ routine = args[0]; // the routine is the first argument
function = args[1]; // the function in the routine is the second
// in the two argument only format
// ^COVERAGE("%RSEL","SRC"), the line offset is 0
- if(args.size() == 2)
- {
+ if (args.size() == 2) {
// To avoid double counting of line 0 of each entry point,
// Don't count the lines that do not give an explicit line
// number.
- routine="";
- function="";
- }
- else
- {
+ routine = "";
+ function = "";
+ } else {
// this is the format for this line
// ^COVERAGE("%RSEL","SRC",count)
linenumber = atoi(args[2].c_str());
- }
+ }
return true;
}
diff --git a/Source/CTest/cmParseGTMCoverage.h b/Source/CTest/cmParseGTMCoverage.h
index c6d7ef9..bc2f2ec 100644
--- a/Source/CTest/cmParseGTMCoverage.h
+++ b/Source/CTest/cmParseGTMCoverage.h
@@ -24,8 +24,8 @@
class cmParseGTMCoverage : public cmParseMumpsCoverage
{
public:
- cmParseGTMCoverage(cmCTestCoverageHandlerContainer& cont,
- cmCTest* ctest);
+ cmParseGTMCoverage(cmCTestCoverageHandlerContainer& cont, cmCTest* ctest);
+
protected:
// implement virtual from parent
bool LoadCoverageData(const char* dir);
@@ -34,16 +34,11 @@ protected:
// find out what line in a mumps file (filepath) the given entry point
// or function is. lineoffset is set by this method.
bool FindFunctionInMumpsFile(std::string const& filepath,
- std::string const& function,
- int& lineoffset);
+ std::string const& function, int& lineoffset);
// parse a line from a .mcov file, and fill in the
// routine, function, linenumber and coverage count
- bool ParseMCOVLine(std::string const& line,
- std::string& routine,
- std::string& function,
- int& linenumber,
- int& count);
+ bool ParseMCOVLine(std::string const& line, std::string& routine,
+ std::string& function, int& linenumber, int& count);
};
-
#endif
diff --git a/Source/CTest/cmParseJacocoCoverage.cxx b/Source/CTest/cmParseJacocoCoverage.cxx
index d9c4ffb..6afaca6 100644
--- a/Source/CTest/cmParseJacocoCoverage.cxx
+++ b/Source/CTest/cmParseJacocoCoverage.cxx
@@ -8,172 +8,145 @@
#include <stdio.h>
#include <stdlib.h>
-
-class cmParseJacocoCoverage::XMLParser: public cmXMLParser
+class cmParseJacocoCoverage::XMLParser : public cmXMLParser
{
- public:
- XMLParser(cmCTest* ctest, cmCTestCoverageHandlerContainer& cont)
- : CTest(ctest), Coverage(cont)
- {
- this->FilePath = "";
- this->PackagePath = "";
- this->PackageName = "";
- }
+public:
+ XMLParser(cmCTest* ctest, cmCTestCoverageHandlerContainer& cont)
+ : CTest(ctest)
+ , Coverage(cont)
+ {
+ this->FilePath = "";
+ this->PackagePath = "";
+ this->PackageName = "";
+ }
- virtual ~XMLParser()
- {
- }
+ virtual ~XMLParser() {}
- protected:
+protected:
+ virtual void EndElement(const std::string&) {}
- virtual void EndElement(const std::string&)
- {
+ virtual void StartElement(const std::string& name, const char** atts)
+ {
+ if (name == "package") {
+ this->PackageName = atts[1];
+ this->PackagePath = "";
+ } else if (name == "sourcefile") {
+ std::string fileName = atts[1];
+
+ if (this->PackagePath == "") {
+ if (!this->FindPackagePath(fileName)) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot find file: "
+ << this->PackageName << "/" << fileName << std::endl);
+ this->Coverage.Error++;
+ return;
+ }
}
- virtual void StartElement(const std::string& name,
- const char** atts)
- {
- if(name == "package")
- {
- this->PackageName = atts[1];
- this->PackagePath = "";
- }
- else if(name == "sourcefile")
- {
- std::string fileName = atts[1];
-
- if (this->PackagePath == "")
- {
- if(!this->FindPackagePath(fileName))
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot find file: "
- << this->PackageName << "/" << fileName << std::endl);
- this->Coverage.Error++;
- return;
- }
- }
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Reading file: " << fileName << std::endl,
+ this->Coverage.Quiet);
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Reading file: " << fileName << std::endl,
- this->Coverage.Quiet);
-
- this->FilePath = this->PackagePath + "/" + fileName;
- cmsys::ifstream fin(this->FilePath.c_str());
- if (!fin)
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Jacoco Coverage: Error opening " << this->FilePath
- << std::endl);
- }
- std::string line;
- FileLinesType& curFileLines =
- this->Coverage.TotalCoverage[this->FilePath];
- if(fin)
- {
- curFileLines.push_back(-1);
- }
- while(cmSystemTools::GetLineFromStream(fin, line))
- {
- curFileLines.push_back(-1);
- }
+ this->FilePath = this->PackagePath + "/" + fileName;
+ cmsys::ifstream fin(this->FilePath.c_str());
+ if (!fin) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Jacoco Coverage: Error opening " << this->FilePath
+ << std::endl);
+ }
+ std::string line;
+ FileLinesType& curFileLines =
+ this->Coverage.TotalCoverage[this->FilePath];
+ if (fin) {
+ curFileLines.push_back(-1);
+ }
+ while (cmSystemTools::GetLineFromStream(fin, line)) {
+ curFileLines.push_back(-1);
+ }
+ } else if (name == "line") {
+ int tagCount = 0;
+ int nr = -1;
+ int ci = -1;
+ while (true) {
+ if (strcmp(atts[tagCount], "ci") == 0) {
+ ci = atoi(atts[tagCount + 1]);
+ } else if (strcmp(atts[tagCount], "nr") == 0) {
+ nr = atoi(atts[tagCount + 1]);
}
- else if(name == "line")
- {
- int tagCount = 0;
- int nr = -1;
- int ci = -1;
- while(true)
- {
- if(strcmp(atts[tagCount],"ci") == 0)
- {
- ci = atoi(atts[tagCount+1]);
- }
- else if (strcmp(atts[tagCount],"nr") == 0)
- {
- nr = atoi(atts[tagCount+1]);
- }
- if (ci > -1 && nr > 0)
- {
- FileLinesType& curFileLines=
- this->Coverage.TotalCoverage[this->FilePath];
- if(!curFileLines.empty())
- {
- curFileLines[nr-1] = ci;
- }
- break;
- }
- ++tagCount;
+ if (ci > -1 && nr > 0) {
+ FileLinesType& curFileLines =
+ this->Coverage.TotalCoverage[this->FilePath];
+ if (!curFileLines.empty()) {
+ curFileLines[nr - 1] = ci;
}
+ break;
}
+ ++tagCount;
}
+ }
+ }
- virtual bool FindPackagePath(const std::string fileName)
- {
- // Search for the source file in the source directory.
- if (this->PackagePathFound(fileName, this->Coverage.SourceDir))
- {
- return true;
- }
-
- // If not found there, check the binary directory.
- if (this->PackagePathFound(fileName, this->Coverage.BinaryDir))
- {
- return true;
- }
- return false;
- }
+ virtual bool FindPackagePath(const std::string fileName)
+ {
+ // Search for the source file in the source directory.
+ if (this->PackagePathFound(fileName, this->Coverage.SourceDir)) {
+ return true;
+ }
- virtual bool PackagePathFound(const std::string fileName,
- const std::string baseDir)
- {
- // Search for the file in the baseDir and its subdirectories.
- std::string packageGlob = baseDir;
- packageGlob += "/";
- packageGlob += fileName;
- cmsys::Glob gl;
- gl.RecurseOn();
- gl.RecurseThroughSymlinksOn();
- gl.FindFiles(packageGlob);
- std::vector<std::string> const& files = gl.GetFiles();
- if (files.size() == 0)
- {
- return false;
- }
+ // If not found there, check the binary directory.
+ if (this->PackagePathFound(fileName, this->Coverage.BinaryDir)) {
+ return true;
+ }
+ return false;
+ }
- // Check if any of the locations found match our package.
- for(std::vector<std::string>::const_iterator fi = files.begin();
- fi != files.end(); ++fi)
- {
- std::string dir = cmsys::SystemTools::GetParentDirectory(*fi);
- if (cmsys::SystemTools::StringEndsWith(dir, this->PackageName.c_str()))
- {
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Found package directory for " << fileName <<
- ": " << dir << std::endl,
- this->Coverage.Quiet);
- this->PackagePath = dir;
- return true;
- }
- }
+ virtual bool PackagePathFound(const std::string fileName,
+ const std::string baseDir)
+ {
+ // Search for the file in the baseDir and its subdirectories.
+ std::string packageGlob = baseDir;
+ packageGlob += "/";
+ packageGlob += fileName;
+ cmsys::Glob gl;
+ gl.RecurseOn();
+ gl.RecurseThroughSymlinksOn();
+ gl.FindFiles(packageGlob);
+ std::vector<std::string> const& files = gl.GetFiles();
+ if (files.size() == 0) {
return false;
+ }
+
+ // Check if any of the locations found match our package.
+ for (std::vector<std::string>::const_iterator fi = files.begin();
+ fi != files.end(); ++fi) {
+ std::string dir = cmsys::SystemTools::GetParentDirectory(*fi);
+ if (cmsys::SystemTools::StringEndsWith(dir, this->PackageName.c_str())) {
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Found package directory for " << fileName << ": "
+ << dir << std::endl,
+ this->Coverage.Quiet);
+ this->PackagePath = dir;
+ return true;
}
+ }
+ return false;
+ }
- private:
- std::string FilePath;
- std::string PackagePath;
- std::string PackageName;
- typedef cmCTestCoverageHandlerContainer::SingleFileCoverageVector
- FileLinesType;
- cmCTest* CTest;
- cmCTestCoverageHandlerContainer& Coverage;
+private:
+ std::string FilePath;
+ std::string PackagePath;
+ std::string PackageName;
+ typedef cmCTestCoverageHandlerContainer::SingleFileCoverageVector
+ FileLinesType;
+ cmCTest* CTest;
+ cmCTestCoverageHandlerContainer& Coverage;
};
cmParseJacocoCoverage::cmParseJacocoCoverage(
- cmCTestCoverageHandlerContainer& cont,
- cmCTest* ctest)
- :Coverage(cont), CTest(ctest)
- {
- }
+ cmCTestCoverageHandlerContainer& cont, cmCTest* ctest)
+ : Coverage(cont)
+ , CTest(ctest)
+{
+}
bool cmParseJacocoCoverage::LoadCoverageData(
const std::vector<std::string> files)
@@ -183,27 +156,24 @@ bool cmParseJacocoCoverage::LoadCoverageData(
size_t i;
std::string path;
size_t numf = files.size();
- for (i = 0; i < numf; i++)
- {
+ for (i = 0; i < numf; i++) {
path = files[i];
- cmCTestOptionalLog(this->CTest,HANDLER_VERBOSE_OUTPUT,
- "Reading XML File " << path << std::endl, this->Coverage.Quiet);
- if(cmSystemTools::GetFilenameLastExtension(path) == ".xml")
- {
- if(!this->ReadJacocoXML(path.c_str()))
- {
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Reading XML File " << path << std::endl,
+ this->Coverage.Quiet);
+ if (cmSystemTools::GetFilenameLastExtension(path) == ".xml") {
+ if (!this->ReadJacocoXML(path.c_str())) {
return false;
- }
}
}
+ }
return true;
}
bool cmParseJacocoCoverage::ReadJacocoXML(const char* file)
{
- cmParseJacocoCoverage::XMLParser
- parser(this->CTest, this->Coverage);
+ cmParseJacocoCoverage::XMLParser parser(this->CTest, this->Coverage);
parser.ParseFile(file);
return true;
}
diff --git a/Source/CTest/cmParseJacocoCoverage.h b/Source/CTest/cmParseJacocoCoverage.h
index cf86508..fa31d47 100644
--- a/Source/CTest/cmParseJacocoCoverage.h
+++ b/Source/CTest/cmParseJacocoCoverage.h
@@ -15,7 +15,6 @@
#include "cmCTestCoverageHandler.h"
-
/** \class cmParseJacocoCoverage
* \brief Parse JaCoCO coverage information
*
@@ -27,14 +26,14 @@
class cmParseJacocoCoverage
{
public:
- cmParseJacocoCoverage(cmCTestCoverageHandlerContainer& cont,
- cmCTest* ctest);
+ cmParseJacocoCoverage(cmCTestCoverageHandlerContainer& cont, cmCTest* ctest);
bool LoadCoverageData(const std::vector<std::string> files);
std::string PackageName;
std::string FileName;
std::string ModuleName;
std::string CurFileName;
+
private:
// implement virtual from parent
// remove files with no coverage
@@ -42,10 +41,8 @@ private:
// Read a single mcov file
bool ReadJacocoXML(const char* f);
// split a string based on ,
- bool SplitString(std::vector<std::string>& args,
- std::string const& line);
- bool FindJavaFile(std::string const& routine,
- std::string& filepath);
+ bool SplitString(std::vector<std::string>& args, std::string const& line);
+ bool FindJavaFile(std::string const& routine, std::string& filepath);
void InitializeJavaFile(std::string& file);
bool LoadSource(std::string d);
diff --git a/Source/CTest/cmParseMumpsCoverage.cxx b/Source/CTest/cmParseMumpsCoverage.cxx
index d0c7599..e5dd74a 100644
--- a/Source/CTest/cmParseMumpsCoverage.cxx
+++ b/Source/CTest/cmParseMumpsCoverage.cxx
@@ -7,11 +7,10 @@
#include <stdio.h>
#include <stdlib.h>
-
cmParseMumpsCoverage::cmParseMumpsCoverage(
- cmCTestCoverageHandlerContainer& cont,
- cmCTest* ctest)
- :Coverage(cont), CTest(ctest)
+ cmCTestCoverageHandlerContainer& cont, cmCTest* ctest)
+ : Coverage(cont)
+ , CTest(ctest)
{
}
@@ -25,37 +24,30 @@ bool cmParseMumpsCoverage::ReadCoverageFile(const char* file)
// packages:/full/path/to/Vista/Packages
// coverage_dir:/full/path/to/dir/with/*.mcov
cmsys::ifstream in(file);
- if(!in)
- {
+ if (!in) {
return false;
- }
+ }
std::string line;
- while(cmSystemTools::GetLineFromStream(in, line))
- {
+ while (cmSystemTools::GetLineFromStream(in, line)) {
std::string::size_type pos = line.find(':', 0);
std::string packages;
- if(pos != std::string::npos)
- {
+ if (pos != std::string::npos) {
std::string type = line.substr(0, pos);
- std::string path = line.substr(pos+1);
- if(type == "packages")
- {
+ std::string path = line.substr(pos + 1);
+ if (type == "packages") {
this->LoadPackages(path.c_str());
- }
- else if(type == "coverage_dir")
- {
+ } else if (type == "coverage_dir") {
this->LoadCoverageData(path.c_str());
- }
- else
- {
+ } else {
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Parse Error in Mumps coverage file :\n"
- << file <<
- "\ntype: [" << type << "]\npath:[" << path << "]\n"
- "input line: [" << line << "]\n");
- }
+ << file << "\ntype: [" << type << "]\npath:[" << path
+ << "]\n"
+ "input line: ["
+ << line << "]\n");
}
}
+ }
return true;
}
@@ -63,59 +55,50 @@ void cmParseMumpsCoverage::InitializeMumpsFile(std::string& file)
{
// initialize the coverage information for a given mumps file
cmsys::ifstream in(file.c_str());
- if(!in)
- {
+ if (!in) {
return;
- }
+ }
std::string line;
- cmCTestCoverageHandlerContainer::SingleFileCoverageVector&
- coverageVector = this->Coverage.TotalCoverage[file];
- if(!cmSystemTools::GetLineFromStream(in, line))
- {
+ cmCTestCoverageHandlerContainer::SingleFileCoverageVector& coverageVector =
+ this->Coverage.TotalCoverage[file];
+ if (!cmSystemTools::GetLineFromStream(in, line)) {
return;
- }
+ }
// first line of a .m file can never be run
coverageVector.push_back(-1);
- while( cmSystemTools::GetLineFromStream(in, line) )
- {
+ while (cmSystemTools::GetLineFromStream(in, line)) {
// putting in a 0 for a line means it is executable code
// putting in a -1 for a line means it is not executable code
int val = -1; // assume line is not executable
bool found = false;
std::string::size_type i = 0;
// (1) Search for the first whitespace or semicolon character on a line.
- //This will skip over labels if the line starts with one, or will simply
- //be the first character on the line for non-label lines.
- for(; i < line.size(); ++i)
- {
- if(line[i] == ' ' || line[i] == '\t' || line[i] == ';')
- {
+ // This will skip over labels if the line starts with one, or will simply
+ // be the first character on the line for non-label lines.
+ for (; i < line.size(); ++i) {
+ if (line[i] == ' ' || line[i] == '\t' || line[i] == ';') {
found = true;
break;
- }
}
- if(found)
- {
+ }
+ if (found) {
// (2) If the first character found above is whitespace or a period
// then continue the search for the first following non-whitespace
// character.
- if(line[i] == ' ' || line[i] == '\t')
- {
- while(i < line.size() && (line[i] == ' ' || line[i] == '\t'
- || line[i] == '.'))
- {
+ if (line[i] == ' ' || line[i] == '\t') {
+ while (i < line.size() &&
+ (line[i] == ' ' || line[i] == '\t' || line[i] == '.')) {
i++;
- }
}
+ }
// (3) If the character found is not a semicolon then the line counts for
// coverage.
- if(i < line.size() && line[i] != ';')
- {
+ if (i < line.size() && line[i] != ';') {
val = 0;
- }
}
- coverageVector.push_back(val);
}
+ coverageVector.push_back(val);
+ }
}
bool cmParseMumpsCoverage::LoadPackages(const char* d)
@@ -127,15 +110,13 @@ bool cmParseMumpsCoverage::LoadPackages(const char* d)
glob.FindFiles(pat);
std::vector<std::string>& files = glob.GetFiles();
std::vector<std::string>::iterator fileIt;
- for ( fileIt = files.begin(); fileIt != files.end();
- ++ fileIt )
- {
+ for (fileIt = files.begin(); fileIt != files.end(); ++fileIt) {
std::string name = cmSystemTools::GetFilenameName(*fileIt);
- this->RoutineToDirectory[name.substr(0, name.size()-2)] = *fileIt;
+ this->RoutineToDirectory[name.substr(0, name.size() - 2)] = *fileIt;
// initialze each file, this is left out until CDash is fixed
// to handle large numbers of files
this->InitializeMumpsFile(*fileIt);
- }
+ }
return true;
}
@@ -144,25 +125,20 @@ bool cmParseMumpsCoverage::FindMumpsFile(std::string const& routine,
{
std::map<std::string, std::string>::iterator i =
this->RoutineToDirectory.find(routine);
- if(i != this->RoutineToDirectory.end())
- {
+ if (i != this->RoutineToDirectory.end()) {
filepath = i->second;
return true;
- }
- else
- {
+ } else {
// try some alternate names
- const char* tryname[] = {"GUX", "GTM", "ONT", 0};
- for(int k=0; tryname[k] != 0; k++)
- {
+ const char* tryname[] = { "GUX", "GTM", "ONT", 0 };
+ for (int k = 0; tryname[k] != 0; k++) {
std::string routine2 = routine + tryname[k];
i = this->RoutineToDirectory.find(routine2);
- if(i != this->RoutineToDirectory.end())
- {
+ if (i != this->RoutineToDirectory.end()) {
filepath = i->second;
return true;
- }
}
}
+ }
return false;
}
diff --git a/Source/CTest/cmParseMumpsCoverage.h b/Source/CTest/cmParseMumpsCoverage.h
index ab957b8..3761ba6 100644
--- a/Source/CTest/cmParseMumpsCoverage.h
+++ b/Source/CTest/cmParseMumpsCoverage.h
@@ -24,12 +24,12 @@
class cmParseMumpsCoverage
{
public:
- cmParseMumpsCoverage(cmCTestCoverageHandlerContainer& cont,
- cmCTest* ctest);
+ cmParseMumpsCoverage(cmCTestCoverageHandlerContainer& cont, cmCTest* ctest);
virtual ~cmParseMumpsCoverage();
// This is the toplevel coverage file locating the coverage files
// and the mumps source code package tree.
bool ReadCoverageFile(const char* file);
+
protected:
// sub classes will use this to
// load all coverage files found in the given directory
@@ -40,8 +40,8 @@ protected:
// initialize the coverage information for a single mumps file
void InitializeMumpsFile(std::string& file);
// Find mumps file for routine
- bool FindMumpsFile(std::string const& routine,
- std::string& filepath);
+ bool FindMumpsFile(std::string const& routine, std::string& filepath);
+
protected:
std::map<std::string, std::string> RoutineToDirectory;
cmCTestCoverageHandlerContainer& Coverage;
diff --git a/Source/CTest/cmParsePHPCoverage.cxx b/Source/CTest/cmParsePHPCoverage.cxx
index 7c2901e..eb0d962 100644
--- a/Source/CTest/cmParsePHPCoverage.cxx
+++ b/Source/CTest/cmParsePHPCoverage.cxx
@@ -16,55 +16,48 @@
*/
cmParsePHPCoverage::cmParsePHPCoverage(cmCTestCoverageHandlerContainer& cont,
- cmCTest* ctest)
- :Coverage(cont), CTest(ctest)
+ cmCTest* ctest)
+ : Coverage(cont)
+ , CTest(ctest)
{
}
bool cmParsePHPCoverage::ReadUntil(std::istream& in, char until)
{
char c = 0;
- while(in.get(c) && c != until)
- {
- }
- if(c != until)
- {
+ while (in.get(c) && c != until) {
+ }
+ if (c != until) {
return false;
- }
+ }
return true;
}
bool cmParsePHPCoverage::ReadCoverageArray(std::istream& in,
std::string const& fileName)
{
- cmCTestCoverageHandlerContainer::SingleFileCoverageVector& coverageVector
- = this->Coverage.TotalCoverage[fileName];
+ cmCTestCoverageHandlerContainer::SingleFileCoverageVector& coverageVector =
+ this->Coverage.TotalCoverage[fileName];
char c;
char buf[4];
in.read(buf, 3);
buf[3] = 0;
- if(strcmp(buf, ";a:") != 0)
- {
+ if (strcmp(buf, ";a:") != 0) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "failed to read start of coverage array, found : "
- << buf << "\n");
+ "failed to read start of coverage array, found : " << buf
+ << "\n");
return false;
- }
+ }
int size = 0;
- if(!this->ReadInt(in, size))
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "failed to read size ");
+ if (!this->ReadInt(in, size)) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "failed to read size ");
return false;
- }
- if(!in.get(c) && c == '{')
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "failed to read open {\n");
+ }
+ if (!in.get(c) && c == '{') {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "failed to read open {\n");
return false;
- }
- for(int i =0; i < size; i++)
- {
+ }
+ for (int i = 0; i < size; i++) {
this->ReadUntil(in, ':');
int line = 0;
this->ReadInt(in, line);
@@ -72,19 +65,17 @@ bool cmParsePHPCoverage::ReadCoverageArray(std::istream& in,
// it seems to be 1 based but often times
// seems to have a 0'th line.
line--;
- if(line < 0)
- {
+ if (line < 0) {
line = 0;
- }
+ }
this->ReadUntil(in, ':');
int value = 0;
this->ReadInt(in, value);
// make sure the vector is the right size and is
// initialized with -1 for each line
- while(coverageVector.size() <= static_cast<size_t>(line) )
- {
+ while (coverageVector.size() <= static_cast<size_t>(line)) {
coverageVector.push_back(-1);
- }
+ }
// if value is less than 0, set it to zero
// TODO figure out the difference between
// -1 and -2 in xdebug coverage?? For now
@@ -92,21 +83,18 @@ bool cmParsePHPCoverage::ReadCoverageArray(std::istream& in,
// CDash expects -1 for non executable code (like comments)
// and 0 for uncovered code, and a positive value
// for number of times a line was executed
- if(value < 0)
- {
+ if (value < 0) {
value = 0;
- }
+ }
// if unset then set it to value
- if(coverageVector[line] == -1)
- {
+ if (coverageVector[line] == -1) {
coverageVector[line] = value;
- }
+ }
// otherwise increment by value
- else
- {
+ else {
coverageVector[line] += value;
- }
}
+ }
return true;
}
@@ -114,10 +102,9 @@ bool cmParsePHPCoverage::ReadInt(std::istream& in, int& v)
{
std::string s;
char c = 0;
- while(in.get(c) && c != ':' && c != ';')
- {
+ while (in.get(c) && c != ':' && c != ';') {
s += c;
- }
+ }
v = atoi(s.c_str());
return true;
}
@@ -126,17 +113,14 @@ bool cmParsePHPCoverage::ReadArraySize(std::istream& in, int& size)
{
char c = 0;
in.get(c);
- if(c != 'a')
- {
+ if (c != 'a') {
return false;
- }
- if(in.get(c) && c == ':')
- {
- if(this->ReadInt(in, size))
- {
+ }
+ if (in.get(c) && c == ':') {
+ if (this->ReadInt(in, size)) {
return true;
- }
}
+ }
return false;
}
@@ -145,110 +129,91 @@ bool cmParsePHPCoverage::ReadFileInformation(std::istream& in)
char buf[4];
in.read(buf, 2);
buf[2] = 0;
- if(strcmp(buf, "s:") != 0)
- {
+ if (strcmp(buf, "s:") != 0) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
"failed to read start of file info found: [" << buf << "]\n");
return false;
- }
+ }
char c;
int size = 0;
- if(this->ReadInt(in, size))
- {
+ if (this->ReadInt(in, size)) {
size++; // add one for null termination
- char* s = new char[size+1];
+ char* s = new char[size + 1];
// read open quote
- if(in.get(c) && c != '"')
- {
+ if (in.get(c) && c != '"') {
delete[] s;
return false;
- }
+ }
// read the string data
- in.read(s, size-1);
- s[size-1] = 0;
+ in.read(s, size - 1);
+ s[size - 1] = 0;
std::string fileName = s;
- delete [] s;
+ delete[] s;
// read close quote
- if(in.get(c) && c != '"')
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "failed to read close quote\n"
- << "read [" << c << "]\n");
+ if (in.get(c) && c != '"') {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "failed to read close quote\n"
+ << "read [" << c << "]\n");
return false;
- }
- if(!this->ReadCoverageArray(in, fileName) )
- {
+ }
+ if (!this->ReadCoverageArray(in, fileName)) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "failed to read coverage array for file: "
- << fileName << "\n");
+ "failed to read coverage array for file: " << fileName
+ << "\n");
return false;
- }
- return true;
}
+ return true;
+ }
return false;
}
-
bool cmParsePHPCoverage::ReadPHPData(const char* file)
{
cmsys::ifstream in(file);
- if(!in)
- {
+ if (!in) {
return false;
- }
+ }
int size = 0;
this->ReadArraySize(in, size);
char c = 0;
in.get(c);
- if(c != '{')
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "failed to read open array\n");
+ if (c != '{') {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "failed to read open array\n");
return false;
- }
- for(int i =0; i < size; i++)
- {
- if(!this->ReadFileInformation(in))
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Failed to read file #" << i << "\n");
+ }
+ for (int i = 0; i < size; i++) {
+ if (!this->ReadFileInformation(in)) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "Failed to read file #" << i
+ << "\n");
return false;
- }
+ }
in.get(c);
- if(c != '}')
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "failed to read close array\n");
+ if (c != '}') {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "failed to read close array\n");
return false;
- }
}
+ }
return true;
}
bool cmParsePHPCoverage::ReadPHPCoverageDirectory(const char* d)
{
cmsys::Directory dir;
- if(!dir.Load(d))
- {
+ if (!dir.Load(d)) {
return false;
- }
+ }
size_t numf;
unsigned int i;
numf = dir.GetNumberOfFiles();
- for (i = 0; i < numf; i++)
- {
+ for (i = 0; i < numf; i++) {
std::string file = dir.GetFile(i);
- if(file != "." && file != ".."
- && !cmSystemTools::FileIsDirectory(file))
- {
+ if (file != "." && file != ".." && !cmSystemTools::FileIsDirectory(file)) {
std::string path = d;
path += "/";
path += file;
- if(!this->ReadPHPData(path.c_str()))
- {
+ if (!this->ReadPHPData(path.c_str())) {
return false;
- }
}
}
+ }
return true;
}
diff --git a/Source/CTest/cmParsePHPCoverage.h b/Source/CTest/cmParsePHPCoverage.h
index 706d036..72f9129 100644
--- a/Source/CTest/cmParsePHPCoverage.h
+++ b/Source/CTest/cmParsePHPCoverage.h
@@ -25,10 +25,10 @@
class cmParsePHPCoverage
{
public:
- cmParsePHPCoverage(cmCTestCoverageHandlerContainer& cont,
- cmCTest* ctest);
+ cmParsePHPCoverage(cmCTestCoverageHandlerContainer& cont, cmCTest* ctest);
bool ReadPHPCoverageDirectory(const char* dir);
void PrintCoverage();
+
private:
bool ReadPHPData(const char* file);
bool ReadArraySize(std::istream& in, int& size);
@@ -40,5 +40,4 @@ private:
cmCTest* CTest;
};
-
#endif
diff --git a/Source/CTest/cmProcess.cxx b/Source/CTest/cmProcess.cxx
index d385677..db5151c 100644
--- a/Source/CTest/cmProcess.cxx
+++ b/Source/CTest/cmProcess.cxx
@@ -40,49 +40,43 @@ void cmProcess::SetCommandArguments(std::vector<std::string> const& args)
bool cmProcess::StartProcess()
{
- if(this->Command.empty())
- {
+ if (this->Command.empty()) {
return false;
- }
+ }
this->StartTime = cmSystemTools::GetTime();
this->ProcessArgs.clear();
// put the command as arg0
this->ProcessArgs.push_back(this->Command.c_str());
// now put the command arguments in
- for(std::vector<std::string>::iterator i = this->Arguments.begin();
- i != this->Arguments.end(); ++i)
- {
+ for (std::vector<std::string>::iterator i = this->Arguments.begin();
+ i != this->Arguments.end(); ++i) {
this->ProcessArgs.push_back(i->c_str());
- }
+ }
this->ProcessArgs.push_back(0); // null terminate the list
this->Process = cmsysProcess_New();
cmsysProcess_SetCommand(this->Process, &*this->ProcessArgs.begin());
- if(!this->WorkingDirectory.empty())
- {
+ if (!this->WorkingDirectory.empty()) {
cmsysProcess_SetWorkingDirectory(this->Process,
this->WorkingDirectory.c_str());
- }
+ }
cmsysProcess_SetTimeout(this->Process, this->Timeout);
cmsysProcess_SetOption(this->Process, cmsysProcess_Option_MergeOutput, 1);
cmsysProcess_Execute(this->Process);
- return (cmsysProcess_GetState(this->Process)
- == cmsysProcess_State_Executing);
+ return (cmsysProcess_GetState(this->Process) ==
+ cmsysProcess_State_Executing);
}
bool cmProcess::Buffer::GetLine(std::string& line)
{
// Scan for the next newline.
- for(size_type sz = this->size(); this->Last != sz; ++this->Last)
- {
- if((*this)[this->Last] == '\n' || (*this)[this->Last] == '\0')
- {
+ for (size_type sz = this->size(); this->Last != sz; ++this->Last) {
+ if ((*this)[this->Last] == '\n' || (*this)[this->Last] == '\0') {
// Extract the range first..last as a line.
const char* text = &*this->begin() + this->First;
size_type length = this->Last - this->First;
- while(length && text[length-1] == '\r')
- {
- length --;
- }
+ while (length && text[length - 1] == '\r') {
+ length--;
+ }
line.assign(text, length);
// Start a new range for the next line.
@@ -91,73 +85,63 @@ bool cmProcess::Buffer::GetLine(std::string& line)
// Return the line extracted.
return true;
- }
}
+ }
// Available data have been exhausted without a newline.
- if(this->First != 0)
- {
+ if (this->First != 0) {
// Move the partial line to the beginning of the buffer.
this->erase(this->begin(), this->begin() + this->First);
this->First = 0;
this->Last = this->size();
- }
+ }
return false;
}
bool cmProcess::Buffer::GetLast(std::string& line)
{
// Return the partial last line, if any.
- if(!this->empty())
- {
+ if (!this->empty()) {
line.assign(&*this->begin(), this->size());
this->First = this->Last = 0;
this->clear();
return true;
- }
+ }
return false;
}
int cmProcess::GetNextOutputLine(std::string& line, double timeout)
{
- for(;;)
- {
+ for (;;) {
// Look for lines already buffered.
- if(this->Output.GetLine(line))
- {
+ if (this->Output.GetLine(line)) {
return cmsysProcess_Pipe_STDOUT;
- }
+ }
// Check for more data from the process.
char* data;
int length;
int p = cmsysProcess_WaitForData(this->Process, &data, &length, &timeout);
- if(p == cmsysProcess_Pipe_Timeout)
- {
+ if (p == cmsysProcess_Pipe_Timeout) {
return cmsysProcess_Pipe_Timeout;
- }
- else if(p == cmsysProcess_Pipe_STDOUT)
- {
- this->Output.insert(this->Output.end(), data, data+length);
- }
- else // p == cmsysProcess_Pipe_None
- {
+ } else if (p == cmsysProcess_Pipe_STDOUT) {
+ this->Output.insert(this->Output.end(), data, data + length);
+ } else // p == cmsysProcess_Pipe_None
+ {
// The process will provide no more data.
break;
- }
}
+ }
// Look for partial last lines.
- if(this->Output.GetLast(line))
- {
+ if (this->Output.GetLast(line)) {
return cmsysProcess_Pipe_STDOUT;
- }
+ }
// No more data. Wait for process exit.
- if(!cmsysProcess_WaitForExit(this->Process, &timeout))
- {
+ if (!cmsysProcess_WaitForExit(this->Process, &timeout)) {
return cmsysProcess_Pipe_Timeout;
- }
+ }
// Record exit information.
this->ExitValue = cmsysProcess_GetExitValue(this->Process);
@@ -166,10 +150,9 @@ int cmProcess::GetNextOutputLine(std::string& line, double timeout)
// negative. If someone changed the system clock while the process was
// running this may be even more. Make sure not to report a negative
// duration here.
- if (this->TotalTime <= 0.0)
- {
+ if (this->TotalTime <= 0.0) {
this->TotalTime = 0.0;
- }
+ }
// std::cerr << "Time to run: " << this->TotalTime << "\n";
return cmsysProcess_Pipe_None;
}
@@ -177,87 +160,68 @@ int cmProcess::GetNextOutputLine(std::string& line, double timeout)
// return the process status
int cmProcess::GetProcessStatus()
{
- if(!this->Process)
- {
+ if (!this->Process) {
return cmsysProcess_State_Exited;
- }
+ }
return cmsysProcess_GetState(this->Process);
}
int cmProcess::ReportStatus()
{
int result = 1;
- switch(cmsysProcess_GetState(this->Process))
- {
- case cmsysProcess_State_Starting:
- {
- std::cerr << "cmProcess: Never started "
- << this->Command << " process.\n";
- } break;
- case cmsysProcess_State_Error:
- {
+ switch (cmsysProcess_GetState(this->Process)) {
+ case cmsysProcess_State_Starting: {
+ std::cerr << "cmProcess: Never started " << this->Command
+ << " process.\n";
+ } break;
+ case cmsysProcess_State_Error: {
std::cerr << "cmProcess: Error executing " << this->Command
- << " process: "
- << cmsysProcess_GetErrorString(this->Process)
+ << " process: " << cmsysProcess_GetErrorString(this->Process)
<< "\n";
- } break;
- case cmsysProcess_State_Exception:
- {
+ } break;
+ case cmsysProcess_State_Exception: {
std::cerr << "cmProcess: " << this->Command
- << " process exited with an exception: ";
- switch(cmsysProcess_GetExitException(this->Process))
- {
- case cmsysProcess_Exception_None:
- {
+ << " process exited with an exception: ";
+ switch (cmsysProcess_GetExitException(this->Process)) {
+ case cmsysProcess_Exception_None: {
std::cerr << "None";
- } break;
- case cmsysProcess_Exception_Fault:
- {
+ } break;
+ case cmsysProcess_Exception_Fault: {
std::cerr << "Segmentation fault";
- } break;
- case cmsysProcess_Exception_Illegal:
- {
+ } break;
+ case cmsysProcess_Exception_Illegal: {
std::cerr << "Illegal instruction";
- } break;
- case cmsysProcess_Exception_Interrupt:
- {
+ } break;
+ case cmsysProcess_Exception_Interrupt: {
std::cerr << "Interrupted by user";
- } break;
- case cmsysProcess_Exception_Numerical:
- {
+ } break;
+ case cmsysProcess_Exception_Numerical: {
std::cerr << "Numerical exception";
- } break;
- case cmsysProcess_Exception_Other:
- {
+ } break;
+ case cmsysProcess_Exception_Other: {
std::cerr << "Unknown";
- } break;
- }
+ } break;
+ }
std::cerr << "\n";
- } break;
- case cmsysProcess_State_Executing:
- {
- std::cerr << "cmProcess: Never terminated " <<
- this->Command << " process.\n";
- } break;
- case cmsysProcess_State_Exited:
- {
+ } break;
+ case cmsysProcess_State_Executing: {
+ std::cerr << "cmProcess: Never terminated " << this->Command
+ << " process.\n";
+ } break;
+ case cmsysProcess_State_Exited: {
result = cmsysProcess_GetExitValue(this->Process);
std::cerr << "cmProcess: " << this->Command
- << " process exited with code "
- << result << "\n";
- } break;
- case cmsysProcess_State_Expired:
- {
+ << " process exited with code " << result << "\n";
+ } break;
+ case cmsysProcess_State_Expired: {
std::cerr << "cmProcess: killed " << this->Command
<< " process due to timeout.\n";
- } break;
- case cmsysProcess_State_Killed:
- {
+ } break;
+ case cmsysProcess_State_Killed: {
std::cerr << "cmProcess: killed " << this->Command << " process.\n";
- } break;
- }
+ } break;
+ }
return result;
-
}
void cmProcess::ChangeTimeout(double t)
diff --git a/Source/CTest/cmProcess.h b/Source/CTest/cmProcess.h
index 326456e..d5e2721 100644
--- a/Source/CTest/cmProcess.h
+++ b/Source/CTest/cmProcess.h
@@ -16,7 +16,6 @@
#include <cmsys/Process.h>
-
/** \class cmProcess
* \brief run a process with c++
*
@@ -27,11 +26,11 @@ class cmProcess
public:
cmProcess();
~cmProcess();
- const char* GetCommand() { return this->Command.c_str();}
+ const char* GetCommand() { return this->Command.c_str(); }
void SetCommand(const char* command);
void SetCommandArguments(std::vector<std::string> const& arg);
- void SetWorkingDirectory(const char* dir) { this->WorkingDirectory = dir;}
- void SetTimeout(double t) { this->Timeout = t;}
+ void SetWorkingDirectory(const char* dir) { this->WorkingDirectory = dir; }
+ void SetTimeout(double t) { this->Timeout = t; }
void ChangeTimeout(double t);
void ResetStartTime();
// Return true if the process starts
@@ -42,9 +41,9 @@ public:
// Report the status of the program
int ReportStatus();
int GetId() { return this->Id; }
- void SetId(int id) { this->Id = id;}
- int GetExitValue() { return this->ExitValue;}
- double GetTotalTime() { return this->TotalTime;}
+ void SetId(int id) { this->Id = id; }
+ int GetExitValue() { return this->ExitValue; }
+ double GetTotalTime() { return this->TotalTime; }
int GetExitException();
/**
* Read one line of output but block for no more than timeout.
@@ -54,18 +53,24 @@ public:
* cmsysProcess_Pipe_Timeout = Timeout expired while waiting
*/
int GetNextOutputLine(std::string& line, double timeout);
+
private:
double Timeout;
double StartTime;
double TotalTime;
cmsysProcess* Process;
- class Buffer: public std::vector<char>
+ class Buffer : public std::vector<char>
{
// Half-open index range of partial line already scanned.
size_type First;
size_type Last;
+
public:
- Buffer(): First(0), Last(0) {}
+ Buffer()
+ : First(0)
+ , Last(0)
+ {
+ }
bool GetLine(std::string& line);
bool GetLast(std::string& line);
};
diff --git a/Source/Checks/cm_c11_thread_local.c b/Source/Checks/cm_c11_thread_local.c
index ab780f2..bdf91aa 100644
--- a/Source/Checks/cm_c11_thread_local.c
+++ b/Source/Checks/cm_c11_thread_local.c
@@ -1,2 +1,5 @@
_Thread_local int i = 42;
-int main(void) { return 0; }
+int main(void)
+{
+ return 0;
+}
diff --git a/Source/Checks/cm_cxx11_unordered_map.cpp b/Source/Checks/cm_cxx11_unordered_map.cpp
index beeb31b..be3de25 100644
--- a/Source/Checks/cm_cxx11_unordered_map.cpp
+++ b/Source/Checks/cm_cxx11_unordered_map.cpp
@@ -1,5 +1,6 @@
#include <unordered_map>
-int main() {
+int main()
+{
std::unordered_map<int, int> map;
map[0] = 0;
return 0;
diff --git a/Source/Checks/cm_cxx14_cstdio.cpp b/Source/Checks/cm_cxx14_cstdio.cpp
index 3a6a699..f5806a9 100644
--- a/Source/Checks/cm_cxx14_cstdio.cpp
+++ b/Source/Checks/cm_cxx14_cstdio.cpp
@@ -1,2 +1,5 @@
#include <cstdio>
-int main() { return 0; }
+int main()
+{
+ return 0;
+}
diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx
index 6eccf54..be8751c 100644
--- a/Source/CursesDialog/ccmake.cxx
+++ b/Source/CursesDialog/ccmake.cxx
@@ -23,68 +23,56 @@
#include <form.h>
-static const char * cmDocumentationName[][2] =
-{
- {0,
- " ccmake - Curses Interface for CMake."},
- {0,0}
+static const char* cmDocumentationName[][2] = {
+ { 0, " ccmake - Curses Interface for CMake." },
+ { 0, 0 }
};
-static const char * cmDocumentationUsage[][2] =
-{
- {0,
- " ccmake <path-to-source>\n"
- " ccmake <path-to-existing-build>"},
- {0,
- "Specify a source directory to (re-)generate a build system for "
- "it in the current working directory. Specify an existing build "
- "directory to re-generate its build system."},
- {0,0}
+static const char* cmDocumentationUsage[][2] = {
+ { 0, " ccmake <path-to-source>\n"
+ " ccmake <path-to-existing-build>" },
+ { 0, "Specify a source directory to (re-)generate a build system for "
+ "it in the current working directory. Specify an existing build "
+ "directory to re-generate its build system." },
+ { 0, 0 }
};
-static const char * cmDocumentationUsageNote[][2] =
-{
- {0,
- "Run 'ccmake --help' for more information."},
- {0,0}
+static const char* cmDocumentationUsageNote[][2] = {
+ { 0, "Run 'ccmake --help' for more information." },
+ { 0, 0 }
};
-static const char * cmDocumentationOptions[][2] =
-{
- CMAKE_STANDARD_OPTIONS_TABLE,
- {0,0}
-};
+static const char* cmDocumentationOptions[]
+ [2] = { CMAKE_STANDARD_OPTIONS_TABLE,
+ { 0, 0 } };
-cmCursesForm* cmCursesForm::CurrentForm=0;
+cmCursesForm* cmCursesForm::CurrentForm = 0;
-extern "C"
-{
+extern "C" {
void onsig(int)
{
- if (cmCursesForm::CurrentForm)
- {
+ if (cmCursesForm::CurrentForm) {
endwin();
- initscr(); /* Initialization */
- noecho(); /* Echo off */
- cbreak(); /* nl- or cr not needed */
- keypad(stdscr,TRUE); /* Use key symbols as
- KEY_DOWN*/
+ initscr(); /* Initialization */
+ noecho(); /* Echo off */
+ cbreak(); /* nl- or cr not needed */
+ keypad(stdscr, TRUE); /* Use key symbols as
+ KEY_DOWN*/
refresh();
- int x,y;
+ int x, y;
getmaxyx(stdscr, y, x);
- cmCursesForm::CurrentForm->Render(1,1,x,y);
+ cmCursesForm::CurrentForm->Render(1, 1, x, y);
cmCursesForm::CurrentForm->UpdateStatusBar();
- }
+ }
signal(SIGWINCH, onsig);
}
-
}
void CMakeMessageHandler(const char* message, const char* title, bool&,
void* clientData)
{
- cmCursesForm* self = static_cast<cmCursesForm*>( clientData );
+ cmCursesForm* self = static_cast<cmCursesForm*>(clientData);
self->AddError(message, title);
}
@@ -98,8 +86,7 @@ int main(int argc, char const* const* argv)
cmSystemTools::FindCMakeResources(argv[0]);
cmDocumentation doc;
doc.addCMakeStandardDocSections();
- if(doc.CheckOptions(argc, argv))
- {
+ if (doc.CheckOptions(argc, argv)) {
cmake hcm;
hcm.SetHomeDirectory("");
hcm.SetHomeOutputDirectory("");
@@ -107,95 +94,82 @@ int main(int argc, char const* const* argv)
std::vector<cmDocumentationEntry> generators;
hcm.GetGeneratorDocumentation(generators);
doc.SetName("ccmake");
- doc.SetSection("Name",cmDocumentationName);
- doc.SetSection("Usage",cmDocumentationUsage);
- if ( argc == 1 )
- {
- doc.AppendSection("Usage",cmDocumentationUsageNote);
- }
- doc.SetSection("Generators",generators);
- doc.PrependSection("Options",cmDocumentationOptions);
- return doc.PrintRequestedDocumentation(std::cout)? 0:1;
+ doc.SetSection("Name", cmDocumentationName);
+ doc.SetSection("Usage", cmDocumentationUsage);
+ if (argc == 1) {
+ doc.AppendSection("Usage", cmDocumentationUsageNote);
}
+ doc.SetSection("Generators", generators);
+ doc.PrependSection("Options", cmDocumentationOptions);
+ return doc.PrintRequestedDocumentation(std::cout) ? 0 : 1;
+ }
bool debug = false;
unsigned int i;
int j;
std::vector<std::string> args;
- for(j =0; j < argc; ++j)
- {
- if(strcmp(argv[j], "-debug") == 0)
- {
+ for (j = 0; j < argc; ++j) {
+ if (strcmp(argv[j], "-debug") == 0) {
debug = true;
- }
- else
- {
+ } else {
args.push_back(argv[j]);
- }
}
+ }
std::string cacheDir = cmSystemTools::GetCurrentWorkingDirectory();
- for(i=1; i < args.size(); ++i)
- {
+ for (i = 1; i < args.size(); ++i) {
std::string arg = args[i];
- if(arg.find("-B",0) == 0)
- {
+ if (arg.find("-B", 0) == 0) {
cacheDir = arg.substr(2);
- }
}
+ }
cmSystemTools::DisableRunCommandOutput();
- if (debug)
- {
+ if (debug) {
cmCursesForm::DebugStart();
- }
+ }
- initscr(); /* Initialization */
- noecho(); /* Echo off */
- cbreak(); /* nl- or cr not needed */
- keypad(stdscr,TRUE); /* Use key symbols as
- KEY_DOWN*/
+ initscr(); /* Initialization */
+ noecho(); /* Echo off */
+ cbreak(); /* nl- or cr not needed */
+ keypad(stdscr, TRUE); /* Use key symbols as
+ KEY_DOWN*/
signal(SIGWINCH, onsig);
- int x,y;
+ int x, y;
getmaxyx(stdscr, y, x);
- if ( x < cmCursesMainForm::MIN_WIDTH ||
- y < cmCursesMainForm::MIN_HEIGHT )
- {
+ if (x < cmCursesMainForm::MIN_WIDTH || y < cmCursesMainForm::MIN_HEIGHT) {
endwin();
std::cerr << "Window is too small. A size of at least "
<< cmCursesMainForm::MIN_WIDTH << " x "
- << cmCursesMainForm::MIN_HEIGHT
- << " is required to run ccmake." << std::endl;
+ << cmCursesMainForm::MIN_HEIGHT << " is required to run ccmake."
+ << std::endl;
return 1;
- }
-
+ }
cmCursesMainForm* myform;
myform = new cmCursesMainForm(args, x);
- if(myform->LoadCache(cacheDir.c_str()))
- {
+ if (myform->LoadCache(cacheDir.c_str())) {
curses_clear();
touchwin(stdscr);
endwin();
delete myform;
std::cerr << "Error running cmake::LoadCache(). Aborting.\n";
return 1;
- }
+ }
cmSystemTools::SetMessageCallback(CMakeMessageHandler, myform);
cmCursesForm::CurrentForm = myform;
myform->InitializeUI();
- if ( myform->Configure(1) == 0 )
- {
+ if (myform->Configure(1) == 0) {
myform->Render(1, 1, x, y);
myform->HandleInput();
- }
+ }
// Need to clean-up better
curses_clear();
@@ -207,5 +181,4 @@ int main(int argc, char const* const* argv)
std::cout << std::endl << std::endl;
return 0;
-
}
diff --git a/Source/CursesDialog/cmCursesBoolWidget.cxx b/Source/CursesDialog/cmCursesBoolWidget.cxx
index 0529b78..0055e88 100644
--- a/Source/CursesDialog/cmCursesBoolWidget.cxx
+++ b/Source/CursesDialog/cmCursesBoolWidget.cxx
@@ -13,14 +13,14 @@
#include "cmCursesMainForm.h"
-cmCursesBoolWidget::cmCursesBoolWidget(int width, int height,
- int left, int top) :
- cmCursesWidget(width, height, left, top)
+cmCursesBoolWidget::cmCursesBoolWidget(int width, int height, int left,
+ int top)
+ : cmCursesWidget(width, height, left, top)
{
this->Type = cmState::BOOL;
- set_field_fore(this->Field, A_NORMAL);
- set_field_back(this->Field, A_STANDOUT);
- field_opts_off(this->Field, O_STATIC);
+ set_field_fore(this->Field, A_NORMAL);
+ set_field_back(this->Field, A_STANDOUT);
+ field_opts_off(this->Field, O_STATIC);
this->SetValueAsBool(false);
}
@@ -28,48 +28,35 @@ bool cmCursesBoolWidget::HandleInput(int& key, cmCursesMainForm*, WINDOW* w)
{
// 10 == enter
- if (key == 10 || key == KEY_ENTER)
- {
- if (this->GetValueAsBool())
- {
+ if (key == 10 || key == KEY_ENTER) {
+ if (this->GetValueAsBool()) {
this->SetValueAsBool(false);
- }
- else
- {
+ } else {
this->SetValueAsBool(true);
- }
+ }
touchwin(w);
wrefresh(w);
return true;
- }
- else
- {
+ } else {
return false;
- }
-
+ }
}
void cmCursesBoolWidget::SetValueAsBool(bool value)
{
- if (value)
- {
+ if (value) {
this->SetValue("ON");
- }
- else
- {
+ } else {
this->SetValue("OFF");
- }
+ }
}
bool cmCursesBoolWidget::GetValueAsBool()
{
- if (this->Value == "ON")
- {
+ if (this->Value == "ON") {
return true;
- }
- else
- {
+ } else {
return false;
- }
+ }
}
diff --git a/Source/CursesDialog/cmCursesBoolWidget.h b/Source/CursesDialog/cmCursesBoolWidget.h
index 65a8ddb..49be45a 100644
--- a/Source/CursesDialog/cmCursesBoolWidget.h
+++ b/Source/CursesDialog/cmCursesBoolWidget.h
@@ -35,7 +35,6 @@ public:
protected:
cmCursesBoolWidget(const cmCursesBoolWidget& from);
void operator=(const cmCursesBoolWidget&);
-
};
#endif // cmCursesBoolWidget_h
diff --git a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx
index 40c0eb6..bdfc8e9 100644
--- a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx
+++ b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx
@@ -25,10 +25,10 @@
#include <assert.h>
cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
- const std::string& key,
- int labelwidth,
- int entrywidth) :
- Key(key), LabelWidth(labelwidth), EntryWidth(entrywidth)
+ const std::string& key, int labelwidth, int entrywidth)
+ : Key(key)
+ , LabelWidth(labelwidth)
+ , EntryWidth(entrywidth)
{
this->Label = new cmCursesLabelWidget(this->LabelWidth, 1, 1, 1, key);
this->IsNewLabel = new cmCursesLabelWidget(1, 1, 1, 1, " ");
@@ -37,35 +37,30 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
}
cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
- const std::string& key, cmake *cm, bool isNew,
- int labelwidth, int entrywidth)
- : Key(key), LabelWidth(labelwidth), EntryWidth(entrywidth)
+ const std::string& key, cmake* cm, bool isNew, int labelwidth,
+ int entrywidth)
+ : Key(key)
+ , LabelWidth(labelwidth)
+ , EntryWidth(entrywidth)
{
this->Label = new cmCursesLabelWidget(this->LabelWidth, 1, 1, 1, key);
- if (isNew)
- {
+ if (isNew) {
this->IsNewLabel = new cmCursesLabelWidget(1, 1, 1, 1, "*");
- }
- else
- {
+ } else {
this->IsNewLabel = new cmCursesLabelWidget(1, 1, 1, 1, " ");
- }
+ }
this->Entry = 0;
const char* value = cm->GetState()->GetCacheEntryValue(key);
assert(value);
- switch (cm->GetState()->GetCacheEntryType(key))
- {
+ switch (cm->GetState()->GetCacheEntryType(key)) {
case cmState::BOOL:
this->Entry = new cmCursesBoolWidget(this->EntryWidth, 1, 1, 1);
- if (cmSystemTools::IsOn(value))
- {
+ if (cmSystemTools::IsOn(value)) {
static_cast<cmCursesBoolWidget*>(this->Entry)->SetValueAsBool(true);
- }
- else
- {
+ } else {
static_cast<cmCursesBoolWidget*>(this->Entry)->SetValueAsBool(false);
- }
+ }
break;
case cmState::PATH:
this->Entry = new cmCursesPathWidget(this->EntryWidth, 1, 1, 1);
@@ -75,40 +70,33 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
this->Entry = new cmCursesFilePathWidget(this->EntryWidth, 1, 1, 1);
static_cast<cmCursesFilePathWidget*>(this->Entry)->SetString(value);
break;
- case cmState::STRING:
- {
- const char* stringsProp = cm->GetState()
- ->GetCacheEntryProperty(key, "STRINGS");
- if(stringsProp)
- {
+ case cmState::STRING: {
+ const char* stringsProp =
+ cm->GetState()->GetCacheEntryProperty(key, "STRINGS");
+ if (stringsProp) {
cmCursesOptionsWidget* ow =
new cmCursesOptionsWidget(this->EntryWidth, 1, 1, 1);
this->Entry = ow;
std::vector<std::string> options;
cmSystemTools::ExpandListArgument(stringsProp, options);
- for(std::vector<std::string>::iterator
- si = options.begin(); si != options.end(); ++si)
- {
+ for (std::vector<std::string>::iterator si = options.begin();
+ si != options.end(); ++si) {
ow->AddOption(*si);
- }
- ow->SetOption(value);
}
- else
- {
+ ow->SetOption(value);
+ } else {
this->Entry = new cmCursesStringWidget(this->EntryWidth, 1, 1, 1);
static_cast<cmCursesStringWidget*>(this->Entry)->SetString(value);
- }
- break;
}
+ break;
+ }
case cmState::UNINITIALIZED:
- cmSystemTools::Error("Found an undefined variable: ",
- key.c_str());
+ cmSystemTools::Error("Found an undefined variable: ", key.c_str());
break;
default:
// TODO : put warning message here
break;
- }
-
+ }
}
cmCursesCacheEntryComposite::~cmCursesCacheEntryComposite()
@@ -120,12 +108,9 @@ cmCursesCacheEntryComposite::~cmCursesCacheEntryComposite()
const char* cmCursesCacheEntryComposite::GetValue()
{
- if (this->Label)
- {
+ if (this->Label) {
return this->Label->GetValue();
- }
- else
- {
+ } else {
return 0;
- }
+ }
}
diff --git a/Source/CursesDialog/cmCursesCacheEntryComposite.h b/Source/CursesDialog/cmCursesCacheEntryComposite.h
index f280897..8ed3902 100644
--- a/Source/CursesDialog/cmCursesCacheEntryComposite.h
+++ b/Source/CursesDialog/cmCursesCacheEntryComposite.h
@@ -19,9 +19,8 @@ class cmCursesCacheEntryComposite
public:
cmCursesCacheEntryComposite(const std::string& key, int labelwidth,
int entrywidth);
- cmCursesCacheEntryComposite(const std::string& key,
- cmake *cm,
- bool isNew, int labelwidth, int entrywidth);
+ cmCursesCacheEntryComposite(const std::string& key, cmake* cm, bool isNew,
+ int labelwidth, int entrywidth);
~cmCursesCacheEntryComposite();
const char* GetValue();
diff --git a/Source/CursesDialog/cmCursesDummyWidget.cxx b/Source/CursesDialog/cmCursesDummyWidget.cxx
index 9801e4d..3cd36af 100644
--- a/Source/CursesDialog/cmCursesDummyWidget.cxx
+++ b/Source/CursesDialog/cmCursesDummyWidget.cxx
@@ -11,16 +11,14 @@
============================================================================*/
#include "cmCursesDummyWidget.h"
-cmCursesDummyWidget::cmCursesDummyWidget(int width, int height,
- int left, int top) :
- cmCursesWidget(width, height, left, top)
+cmCursesDummyWidget::cmCursesDummyWidget(int width, int height, int left,
+ int top)
+ : cmCursesWidget(width, height, left, top)
{
this->Type = cmState::INTERNAL;
}
-
-bool cmCursesDummyWidget::HandleInput(int&, cmCursesMainForm*, WINDOW* )
+bool cmCursesDummyWidget::HandleInput(int&, cmCursesMainForm*, WINDOW*)
{
return false;
}
-
diff --git a/Source/CursesDialog/cmCursesDummyWidget.h b/Source/CursesDialog/cmCursesDummyWidget.h
index 2b3b9b5..9a3df29 100644
--- a/Source/CursesDialog/cmCursesDummyWidget.h
+++ b/Source/CursesDialog/cmCursesDummyWidget.h
@@ -30,7 +30,6 @@ public:
protected:
cmCursesDummyWidget(const cmCursesDummyWidget& from);
void operator=(const cmCursesDummyWidget&);
-
};
#endif // cmCursesDummyWidget_h
diff --git a/Source/CursesDialog/cmCursesFilePathWidget.cxx b/Source/CursesDialog/cmCursesFilePathWidget.cxx
index 51ed670..28a74a9 100644
--- a/Source/CursesDialog/cmCursesFilePathWidget.cxx
+++ b/Source/CursesDialog/cmCursesFilePathWidget.cxx
@@ -11,10 +11,9 @@
============================================================================*/
#include "cmCursesFilePathWidget.h"
-cmCursesFilePathWidget::cmCursesFilePathWidget(int width, int height,
- int left, int top) :
- cmCursesPathWidget(width, height, left, top)
+cmCursesFilePathWidget::cmCursesFilePathWidget(int width, int height, int left,
+ int top)
+ : cmCursesPathWidget(width, height, left, top)
{
this->Type = cmState::FILEPATH;
}
-
diff --git a/Source/CursesDialog/cmCursesFilePathWidget.h b/Source/CursesDialog/cmCursesFilePathWidget.h
index 6c50dd4..72adc77 100644
--- a/Source/CursesDialog/cmCursesFilePathWidget.h
+++ b/Source/CursesDialog/cmCursesFilePathWidget.h
@@ -22,7 +22,6 @@ public:
protected:
cmCursesFilePathWidget(const cmCursesFilePathWidget& from);
void operator=(const cmCursesFilePathWidget&);
-
};
#endif // cmCursesFilePathWidget_h
diff --git a/Source/CursesDialog/cmCursesForm.cxx b/Source/CursesDialog/cmCursesForm.cxx
index d1b470c..aa4710f 100644
--- a/Source/CursesDialog/cmCursesForm.cxx
+++ b/Source/CursesDialog/cmCursesForm.cxx
@@ -21,12 +21,11 @@ cmCursesForm::cmCursesForm()
cmCursesForm::~cmCursesForm()
{
- if (this->Form)
- {
+ if (this->Form) {
unpost_form(this->Form);
free_form(this->Form);
this->Form = 0;
- }
+ }
}
void cmCursesForm::DebugStart()
@@ -37,10 +36,9 @@ void cmCursesForm::DebugStart()
void cmCursesForm::DebugEnd()
{
- if (!cmCursesForm::Debug)
- {
+ if (!cmCursesForm::Debug) {
return;
- }
+ }
cmCursesForm::Debug = false;
cmCursesForm::DebugFile.close();
@@ -48,10 +46,9 @@ void cmCursesForm::DebugEnd()
void cmCursesForm::LogMessage(const char* msg)
{
- if (!cmCursesForm::Debug)
- {
+ if (!cmCursesForm::Debug) {
return;
- }
+ }
cmCursesForm::DebugFile << msg << std::endl;
}
diff --git a/Source/CursesDialog/cmCursesForm.h b/Source/CursesDialog/cmCursesForm.h
index 2c45494..c0192fc 100644
--- a/Source/CursesDialog/cmCursesForm.h
+++ b/Source/CursesDialog/cmCursesForm.h
@@ -54,16 +54,11 @@ public:
// Description:
// Return the FORM. Should be only used by low-level methods.
- FORM* GetForm()
- {
- return this->Form;
- }
+ FORM* GetForm() { return this->Form; }
static cmCursesForm* CurrentForm;
-
protected:
-
static cmsys::ofstream DebugFile;
static bool Debug;
diff --git a/Source/CursesDialog/cmCursesLabelWidget.cxx b/Source/CursesDialog/cmCursesLabelWidget.cxx
index b50eb64..e9da71e 100644
--- a/Source/CursesDialog/cmCursesLabelWidget.cxx
+++ b/Source/CursesDialog/cmCursesLabelWidget.cxx
@@ -11,14 +11,13 @@
============================================================================*/
#include "cmCursesLabelWidget.h"
-cmCursesLabelWidget::cmCursesLabelWidget(int width, int height,
- int left, int top,
- const std::string& name) :
- cmCursesWidget(width, height, left, top)
+cmCursesLabelWidget::cmCursesLabelWidget(int width, int height, int left,
+ int top, const std::string& name)
+ : cmCursesWidget(width, height, left, top)
{
- field_opts_off(this->Field, O_EDIT);
- field_opts_off(this->Field, O_ACTIVE);
- field_opts_off(this->Field, O_STATIC);
+ field_opts_off(this->Field, O_EDIT);
+ field_opts_off(this->Field, O_ACTIVE);
+ field_opts_off(this->Field, O_STATIC);
this->SetValue(name);
}
@@ -26,7 +25,7 @@ cmCursesLabelWidget::~cmCursesLabelWidget()
{
}
-bool cmCursesLabelWidget::HandleInput(int&, cmCursesMainForm*, WINDOW* )
+bool cmCursesLabelWidget::HandleInput(int&, cmCursesMainForm*, WINDOW*)
{
// Static text. No input is handled here.
return false;
diff --git a/Source/CursesDialog/cmCursesLongMessageForm.cxx b/Source/CursesDialog/cmCursesLongMessageForm.cxx
index 776d828..84672ae 100644
--- a/Source/CursesDialog/cmCursesLongMessageForm.cxx
+++ b/Source/CursesDialog/cmCursesLongMessageForm.cxx
@@ -18,21 +18,19 @@
inline int ctrl(int z)
{
- return (z&037);
+ return (z & 037);
}
-cmCursesLongMessageForm::cmCursesLongMessageForm(std::vector<std::string>
- const& messages, const char*
- title)
+cmCursesLongMessageForm::cmCursesLongMessageForm(
+ std::vector<std::string> const& messages, const char* title)
{
// Append all messages into on big string
std::vector<std::string>::const_iterator it;
- for(it=messages.begin(); it != messages.end(); it++)
- {
+ for (it = messages.begin(); it != messages.end(); it++) {
this->Messages += (*it);
// Add one blank line after each message
this->Messages += "\n\n";
- }
+ }
this->Title = title;
this->Fields[0] = 0;
this->Fields[1] = 0;
@@ -40,170 +38,145 @@ cmCursesLongMessageForm::cmCursesLongMessageForm(std::vector<std::string>
cmCursesLongMessageForm::~cmCursesLongMessageForm()
{
- if (this->Fields[0])
- {
+ if (this->Fields[0]) {
free_field(this->Fields[0]);
- }
+ }
}
-
void cmCursesLongMessageForm::UpdateStatusBar()
{
- int x,y;
+ int x, y;
getmaxyx(stdscr, y, x);
char bar[cmCursesMainForm::MAX_WIDTH];
size_t size = strlen(this->Title.c_str());
- if ( size >= cmCursesMainForm::MAX_WIDTH )
- {
- size = cmCursesMainForm::MAX_WIDTH-1;
- }
+ if (size >= cmCursesMainForm::MAX_WIDTH) {
+ size = cmCursesMainForm::MAX_WIDTH - 1;
+ }
strncpy(bar, this->Title.c_str(), size);
- for(size_t i=size-1; i<cmCursesMainForm::MAX_WIDTH; i++) bar[i] = ' ';
+ for (size_t i = size - 1; i < cmCursesMainForm::MAX_WIDTH; i++)
+ bar[i] = ' ';
int width;
- if (x < cmCursesMainForm::MAX_WIDTH )
- {
+ if (x < cmCursesMainForm::MAX_WIDTH) {
width = x;
- }
- else
- {
- width = cmCursesMainForm::MAX_WIDTH-1;
- }
+ } else {
+ width = cmCursesMainForm::MAX_WIDTH - 1;
+ }
bar[width] = '\0';
char version[cmCursesMainForm::MAX_WIDTH];
char vertmp[128];
- sprintf(vertmp,"CMake Version %s", cmVersion::GetCMakeVersion());
- size_t sideSpace = (width-strlen(vertmp));
- for(size_t i=0; i<sideSpace; i++) { version[i] = ' '; }
- sprintf(version+sideSpace, "%s", vertmp);
+ sprintf(vertmp, "CMake Version %s", cmVersion::GetCMakeVersion());
+ size_t sideSpace = (width - strlen(vertmp));
+ for (size_t i = 0; i < sideSpace; i++) {
+ version[i] = ' ';
+ }
+ sprintf(version + sideSpace, "%s", vertmp);
version[width] = '\0';
char fmt_s[] = "%s";
- curses_move(y-4,0);
+ curses_move(y - 4, 0);
attron(A_STANDOUT);
printw(fmt_s, bar);
attroff(A_STANDOUT);
- curses_move(y-3,0);
+ curses_move(y - 3, 0);
printw(fmt_s, version);
pos_form_cursor(this->Form);
}
void cmCursesLongMessageForm::PrintKeys()
{
- int x,y;
+ int x, y;
getmaxyx(stdscr, y, x);
- if ( x < cmCursesMainForm::MIN_WIDTH ||
- y < cmCursesMainForm::MIN_HEIGHT )
- {
+ if (x < cmCursesMainForm::MIN_WIDTH || y < cmCursesMainForm::MIN_HEIGHT) {
return;
- }
+ }
char firstLine[512];
- sprintf(firstLine, "Press [e] to exit help");
+ sprintf(firstLine, "Press [e] to exit help");
char fmt_s[] = "%s";
- curses_move(y-2,0);
+ curses_move(y - 2, 0);
printw(fmt_s, firstLine);
pos_form_cursor(this->Form);
-
}
void cmCursesLongMessageForm::Render(int, int, int, int)
{
- int x,y;
+ int x, y;
getmaxyx(stdscr, y, x);
- if (this->Form)
- {
+ if (this->Form) {
unpost_form(this->Form);
free_form(this->Form);
this->Form = 0;
- }
+ }
const char* msg = this->Messages.c_str();
curses_clear();
- if (this->Fields[0])
- {
+ if (this->Fields[0]) {
free_field(this->Fields[0]);
this->Fields[0] = 0;
- }
+ }
- this->Fields[0] = new_field(y-6, x-2, 1, 1, 0, 0);
+ this->Fields[0] = new_field(y - 6, x - 2, 1, 1, 0, 0);
- field_opts_off(this->Fields[0], O_STATIC);
+ field_opts_off(this->Fields[0], O_STATIC);
this->Form = new_form(this->Fields);
post_form(this->Form);
- int i=0;
+ int i = 0;
form_driver(this->Form, REQ_BEG_FIELD);
- while(msg[i] != '\0' && i < 60000)
- {
- if (msg[i] == '\n' && msg[i+1] != '\0')
- {
+ while (msg[i] != '\0' && i < 60000) {
+ if (msg[i] == '\n' && msg[i + 1] != '\0') {
form_driver(this->Form, REQ_NEW_LINE);
- }
- else
- {
+ } else {
form_driver(this->Form, msg[i]);
- }
- i++;
}
+ i++;
+ }
form_driver(this->Form, REQ_BEG_FIELD);
this->UpdateStatusBar();
this->PrintKeys();
touchwin(stdscr);
refresh();
-
}
void cmCursesLongMessageForm::HandleInput()
{
- if (!this->Form)
- {
+ if (!this->Form) {
return;
- }
+ }
char debugMessage[128];
- for(;;)
- {
+ for (;;) {
int key = getch();
sprintf(debugMessage, "Message widget handling input, key: %d", key);
cmCursesForm::LogMessage(debugMessage);
// quit
- if ( key == 'o' || key == 'e' )
- {
+ if (key == 'o' || key == 'e') {
break;
- }
- else if ( key == KEY_DOWN || key == ctrl('n') )
- {
+ } else if (key == KEY_DOWN || key == ctrl('n')) {
form_driver(this->Form, REQ_SCR_FLINE);
- }
- else if ( key == KEY_UP || key == ctrl('p') )
- {
+ } else if (key == KEY_UP || key == ctrl('p')) {
form_driver(this->Form, REQ_SCR_BLINE);
- }
- else if ( key == KEY_NPAGE || key == ctrl('d') )
- {
+ } else if (key == KEY_NPAGE || key == ctrl('d')) {
form_driver(this->Form, REQ_SCR_FPAGE);
- }
- else if ( key == KEY_PPAGE || key == ctrl('u') )
- {
+ } else if (key == KEY_PPAGE || key == ctrl('u')) {
form_driver(this->Form, REQ_SCR_BPAGE);
- }
+ }
this->UpdateStatusBar();
this->PrintKeys();
touchwin(stdscr);
wrefresh(stdscr);
- }
-
+ }
}
diff --git a/Source/CursesDialog/cmCursesLongMessageForm.h b/Source/CursesDialog/cmCursesLongMessageForm.h
index e9bd542..73ccfc4 100644
--- a/Source/CursesDialog/cmCursesLongMessageForm.h
+++ b/Source/CursesDialog/cmCursesLongMessageForm.h
@@ -52,7 +52,6 @@ protected:
std::string Title;
FIELD* Fields[2];
-
};
#endif // cmCursesLongMessageForm_h
diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx
index 2aafc8b..7368560 100644
--- a/Source/CursesDialog/cmCursesMainForm.cxx
+++ b/Source/CursesDialog/cmCursesMainForm.cxx
@@ -25,15 +25,15 @@
#include "cmCursesStringWidget.h"
#include "cmState.h"
-
inline int ctrl(int z)
{
- return (z&037);
+ return (z & 037);
}
cmCursesMainForm::cmCursesMainForm(std::vector<std::string> const& args,
- int initWidth) :
- Args(args), InitialWidth(initWidth)
+ int initWidth)
+ : Args(args)
+ , InitialWidth(initWidth)
{
this->NumberOfPages = 0;
this->Fields = 0;
@@ -41,7 +41,8 @@ cmCursesMainForm::cmCursesMainForm(std::vector<std::string> const& args,
this->AdvancedMode = false;
this->NumberOfVisibleEntries = 0;
this->OkToGenerate = false;
- this->HelpMessage.push_back("Welcome to ccmake, curses based user interface for CMake.");
+ this->HelpMessage.push_back(
+ "Welcome to ccmake, curses based user interface for CMake.");
this->HelpMessage.push_back("");
this->HelpMessage.push_back(s_ConstHelpMessage);
this->CMakeInstance = new cmake;
@@ -60,43 +61,37 @@ cmCursesMainForm::cmCursesMainForm(std::vector<std::string> const& args,
cmCursesMainForm::~cmCursesMainForm()
{
- if (this->Form)
- {
+ if (this->Form) {
unpost_form(this->Form);
free_form(this->Form);
this->Form = 0;
- }
+ }
delete[] this->Fields;
// Clean-up composites
- if (this->Entries)
- {
+ if (this->Entries) {
cmDeleteAll(*this->Entries);
- }
+ }
delete this->Entries;
- if (this->CMakeInstance)
- {
+ if (this->CMakeInstance) {
delete this->CMakeInstance;
this->CMakeInstance = 0;
- }
+ }
}
// See if a cache entry is in the list of entries in the ui.
bool cmCursesMainForm::LookForCacheEntry(const std::string& key)
{
- if (!this->Entries)
- {
+ if (!this->Entries) {
return false;
- }
+ }
std::vector<cmCursesCacheEntryComposite*>::iterator it;
- for (it = this->Entries->begin(); it != this->Entries->end(); ++it)
- {
- if (key == (*it)->Key)
- {
+ for (it = this->Entries->begin(); it != this->Entries->end(); ++it) {
+ if (key == (*it)->Key) {
return true;
- }
}
+ }
return false;
}
@@ -109,93 +104,74 @@ void cmCursesMainForm::InitializeUI()
std::vector<cmCursesCacheEntryComposite*>* newEntries =
new std::vector<cmCursesCacheEntryComposite*>;
std::vector<std::string> cacheKeys =
- this->CMakeInstance->GetState()->GetCacheEntryKeys();
+ this->CMakeInstance->GetState()->GetCacheEntryKeys();
newEntries->reserve(cacheKeys.size());
// Count non-internal and non-static entries
- int count=0;
-
- for(std::vector<std::string>::const_iterator it = cacheKeys.begin();
- it != cacheKeys.end(); ++it)
- {
- cmState::CacheEntryType t = this->CMakeInstance->GetState()
- ->GetCacheEntryType(*it);
- if (t != cmState::INTERNAL &&
- t != cmState::STATIC &&
- t != cmState::UNINITIALIZED)
- {
+ int count = 0;
+
+ for (std::vector<std::string>::const_iterator it = cacheKeys.begin();
+ it != cacheKeys.end(); ++it) {
+ cmState::CacheEntryType t =
+ this->CMakeInstance->GetState()->GetCacheEntryType(*it);
+ if (t != cmState::INTERNAL && t != cmState::STATIC &&
+ t != cmState::UNINITIALIZED) {
++count;
- }
}
+ }
int entrywidth = this->InitialWidth - 35;
cmCursesCacheEntryComposite* comp;
- if ( count == 0 )
- {
+ if (count == 0) {
// If cache is empty, display a label saying so and a
// dummy entry widget (does not respond to input)
comp = new cmCursesCacheEntryComposite("EMPTY CACHE", 30, 30);
comp->Entry = new cmCursesDummyWidget(1, 1, 1, 1);
newEntries->push_back(comp);
- }
- else
- {
+ } else {
// Create the composites.
// First add entries which are new
- for(std::vector<std::string>::const_iterator it = cacheKeys.begin();
- it != cacheKeys.end(); ++it)
- {
+ for (std::vector<std::string>::const_iterator it = cacheKeys.begin();
+ it != cacheKeys.end(); ++it) {
std::string key = *it;
- cmState::CacheEntryType t = this->CMakeInstance->GetState()
- ->GetCacheEntryType(*it);
- if (t == cmState::INTERNAL ||
- t == cmState::STATIC ||
- t == cmState::UNINITIALIZED )
- {
+ cmState::CacheEntryType t =
+ this->CMakeInstance->GetState()->GetCacheEntryType(*it);
+ if (t == cmState::INTERNAL || t == cmState::STATIC ||
+ t == cmState::UNINITIALIZED) {
continue;
- }
+ }
- if (!this->LookForCacheEntry(key))
- {
- newEntries->push_back(new cmCursesCacheEntryComposite(key,
- this->CMakeInstance,
- true, 30,
- entrywidth));
+ if (!this->LookForCacheEntry(key)) {
+ newEntries->push_back(new cmCursesCacheEntryComposite(
+ key, this->CMakeInstance, true, 30, entrywidth));
this->OkToGenerate = false;
- }
}
+ }
// then add entries which are old
- for(std::vector<std::string>::const_iterator it = cacheKeys.begin();
- it != cacheKeys.end(); ++it)
- {
+ for (std::vector<std::string>::const_iterator it = cacheKeys.begin();
+ it != cacheKeys.end(); ++it) {
std::string key = *it;
- cmState::CacheEntryType t = this->CMakeInstance->GetState()
- ->GetCacheEntryType(*it);
- if (t == cmState::INTERNAL ||
- t == cmState::STATIC ||
- t == cmState::UNINITIALIZED )
- {
+ cmState::CacheEntryType t =
+ this->CMakeInstance->GetState()->GetCacheEntryType(*it);
+ if (t == cmState::INTERNAL || t == cmState::STATIC ||
+ t == cmState::UNINITIALIZED) {
continue;
- }
+ }
- if (this->LookForCacheEntry(key))
- {
- newEntries->push_back(new cmCursesCacheEntryComposite(key,
- this->CMakeInstance,
- false, 30,
- entrywidth));
- }
+ if (this->LookForCacheEntry(key)) {
+ newEntries->push_back(new cmCursesCacheEntryComposite(
+ key, this->CMakeInstance, false, 30, entrywidth));
}
}
+ }
// Clean old entries
- if (this->Entries)
- {
+ if (this->Entries) {
cmDeleteAll(*this->Entries);
- }
+ }
delete this->Entries;
this->Entries = newEntries;
@@ -203,180 +179,150 @@ void cmCursesMainForm::InitializeUI()
this->RePost();
}
-
void cmCursesMainForm::RePost()
{
// Create the fields to be passed to the form.
- if (this->Form)
- {
+ if (this->Form) {
unpost_form(this->Form);
free_form(this->Form);
this->Form = 0;
- }
+ }
delete[] this->Fields;
- if (this->AdvancedMode)
- {
+ if (this->AdvancedMode) {
this->NumberOfVisibleEntries = this->Entries->size();
- }
- else
- {
+ } else {
// If normal mode, count only non-advanced entries
this->NumberOfVisibleEntries = 0;
std::vector<cmCursesCacheEntryComposite*>::iterator it;
- for (it = this->Entries->begin(); it != this->Entries->end(); ++it)
- {
+ for (it = this->Entries->begin(); it != this->Entries->end(); ++it) {
const char* existingValue =
- this->CMakeInstance->GetState()
- ->GetCacheEntryValue((*it)->GetValue());
+ this->CMakeInstance->GetState()->GetCacheEntryValue((*it)->GetValue());
bool advanced =
- this->CMakeInstance->GetState()
- ->GetCacheEntryPropertyAsBool((*it)->GetValue(), "ADVANCED");
- if (!existingValue || (!this->AdvancedMode && advanced))
- {
+ this->CMakeInstance->GetState()->GetCacheEntryPropertyAsBool(
+ (*it)->GetValue(), "ADVANCED");
+ if (!existingValue || (!this->AdvancedMode && advanced)) {
continue;
- }
- this->NumberOfVisibleEntries++;
}
+ this->NumberOfVisibleEntries++;
}
+ }
// there is always one even if it is the dummy one
- if(this->NumberOfVisibleEntries == 0)
- {
+ if (this->NumberOfVisibleEntries == 0) {
this->NumberOfVisibleEntries = 1;
- }
+ }
// Assign the fields: 3 for each entry: label, new entry marker
// ('*' or ' ') and entry widget
- this->Fields = new FIELD*[3*this->NumberOfVisibleEntries+1];
+ this->Fields = new FIELD*[3 * this->NumberOfVisibleEntries + 1];
size_t cc;
- for ( cc = 0; cc < 3 * this->NumberOfVisibleEntries+1; cc ++ )
- {
+ for (cc = 0; cc < 3 * this->NumberOfVisibleEntries + 1; cc++) {
this->Fields[cc] = 0;
- }
+ }
// Assign fields
- int j=0;
+ int j = 0;
std::vector<cmCursesCacheEntryComposite*>::iterator it;
- for (it = this->Entries->begin(); it != this->Entries->end(); ++it)
- {
+ for (it = this->Entries->begin(); it != this->Entries->end(); ++it) {
const char* existingValue =
- this->CMakeInstance->GetState()
- ->GetCacheEntryValue((*it)->GetValue());
+ this->CMakeInstance->GetState()->GetCacheEntryValue((*it)->GetValue());
bool advanced =
- this->CMakeInstance->GetState()
- ->GetCacheEntryPropertyAsBool((*it)->GetValue(), "ADVANCED");
- if (!existingValue || (!this->AdvancedMode && advanced))
- {
+ this->CMakeInstance->GetState()->GetCacheEntryPropertyAsBool(
+ (*it)->GetValue(), "ADVANCED");
+ if (!existingValue || (!this->AdvancedMode && advanced)) {
continue;
- }
- this->Fields[3*j] = (*it)->Label->Field;
- this->Fields[3*j+1] = (*it)->IsNewLabel->Field;
- this->Fields[3*j+2] = (*it)->Entry->Field;
- j++;
}
+ this->Fields[3 * j] = (*it)->Label->Field;
+ this->Fields[3 * j + 1] = (*it)->IsNewLabel->Field;
+ this->Fields[3 * j + 2] = (*it)->Entry->Field;
+ j++;
+ }
// if no cache entries there should still be one dummy field
- if(j == 0)
- {
+ if (j == 0) {
it = this->Entries->begin();
- this->Fields[0] = (*it)->Label->Field;
- this->Fields[1] = (*it)->IsNewLabel->Field;
- this->Fields[2] = (*it)->Entry->Field;
+ this->Fields[0] = (*it)->Label->Field;
+ this->Fields[1] = (*it)->IsNewLabel->Field;
+ this->Fields[2] = (*it)->Entry->Field;
this->NumberOfVisibleEntries = 1;
- }
+ }
// Has to be null terminated.
- this->Fields[3*this->NumberOfVisibleEntries] = 0;
+ this->Fields[3 * this->NumberOfVisibleEntries] = 0;
}
void cmCursesMainForm::Render(int left, int top, int width, int height)
{
- if (this->Form)
- {
+ if (this->Form) {
FIELD* currentField = current_field(this->Form);
- cmCursesWidget* cw = reinterpret_cast<cmCursesWidget*>
- (field_userptr(currentField));
+ cmCursesWidget* cw =
+ reinterpret_cast<cmCursesWidget*>(field_userptr(currentField));
// If in edit mode, get out of it
- if ( cw->GetType() == cmState::STRING ||
- cw->GetType() == cmState::PATH ||
- cw->GetType() == cmState::FILEPATH )
- {
+ if (cw->GetType() == cmState::STRING || cw->GetType() == cmState::PATH ||
+ cw->GetType() == cmState::FILEPATH) {
cmCursesStringWidget* sw = static_cast<cmCursesStringWidget*>(cw);
sw->SetInEdit(false);
- }
+ }
// Delete the previous form
unpost_form(this->Form);
free_form(this->Form);
this->Form = 0;
- }
+ }
// Wrong window size
- if ( width < cmCursesMainForm::MIN_WIDTH ||
- width < this->InitialWidth ||
- height < cmCursesMainForm::MIN_HEIGHT )
- {
+ if (width < cmCursesMainForm::MIN_WIDTH || width < this->InitialWidth ||
+ height < cmCursesMainForm::MIN_HEIGHT) {
return;
- }
+ }
// Leave room for toolbar
height -= 7;
- if (this->AdvancedMode)
- {
+ if (this->AdvancedMode) {
this->NumberOfVisibleEntries = this->Entries->size();
- }
- else
- {
+ } else {
// If normal, display only non-advanced entries
this->NumberOfVisibleEntries = 0;
std::vector<cmCursesCacheEntryComposite*>::iterator it;
- for (it = this->Entries->begin(); it != this->Entries->end(); ++it)
- {
+ for (it = this->Entries->begin(); it != this->Entries->end(); ++it) {
const char* existingValue =
- this->CMakeInstance->GetState()
- ->GetCacheEntryValue((*it)->GetValue());
+ this->CMakeInstance->GetState()->GetCacheEntryValue((*it)->GetValue());
bool advanced =
- this->CMakeInstance->GetState()
- ->GetCacheEntryPropertyAsBool((*it)->GetValue(), "ADVANCED");
- if (!existingValue || (!this->AdvancedMode && advanced))
- {
+ this->CMakeInstance->GetState()->GetCacheEntryPropertyAsBool(
+ (*it)->GetValue(), "ADVANCED");
+ if (!existingValue || (!this->AdvancedMode && advanced)) {
continue;
- }
- this->NumberOfVisibleEntries++;
}
+ this->NumberOfVisibleEntries++;
}
+ }
// Re-adjust the fields according to their place
this->NumberOfPages = 1;
- if (height > 0)
- {
+ if (height > 0) {
bool isNewPage;
- int i=0;
+ int i = 0;
std::vector<cmCursesCacheEntryComposite*>::iterator it;
- for (it = this->Entries->begin(); it != this->Entries->end(); ++it)
- {
+ for (it = this->Entries->begin(); it != this->Entries->end(); ++it) {
const char* existingValue =
- this->CMakeInstance->GetState()
- ->GetCacheEntryValue((*it)->GetValue());
+ this->CMakeInstance->GetState()->GetCacheEntryValue((*it)->GetValue());
bool advanced =
- this->CMakeInstance->GetState()
- ->GetCacheEntryPropertyAsBool((*it)->GetValue(), "ADVANCED");
- if (!existingValue || (!this->AdvancedMode && advanced))
- {
+ this->CMakeInstance->GetState()->GetCacheEntryPropertyAsBool(
+ (*it)->GetValue(), "ADVANCED");
+ if (!existingValue || (!this->AdvancedMode && advanced)) {
continue;
- }
+ }
int row = (i % height) + 1;
int page = (i / height) + 1;
- isNewPage = ( page > 1 ) && ( row == 1 );
+ isNewPage = (page > 1) && (row == 1);
- if (isNewPage)
- {
+ if (isNewPage) {
this->NumberOfPages++;
- }
- (*it)->Label->Move(left, top+row-1, isNewPage);
- (*it)->IsNewLabel->Move(left+32, top+row-1, false);
- (*it)->Entry->Move(left+33, top+row-1, false);
+ }
+ (*it)->Label->Move(left, top + row - 1, isNewPage);
+ (*it)->IsNewLabel->Move(left + 32, top + row - 1, false);
+ (*it)->Entry->Move(left + 33, top + row - 1, false);
(*it)->Entry->SetPage(this->NumberOfPages);
i++;
- }
}
+ }
// Post the form
this->Form = new_form(this->Fields);
@@ -391,153 +337,130 @@ void cmCursesMainForm::Render(int left, int top, int width, int height)
void cmCursesMainForm::PrintKeys(int process /* = 0 */)
{
- int x,y;
+ int x, y;
getmaxyx(stdscr, y, x);
- if ( x < cmCursesMainForm::MIN_WIDTH ||
- x < this->InitialWidth ||
- y < cmCursesMainForm::MIN_HEIGHT )
- {
+ if (x < cmCursesMainForm::MIN_WIDTH || x < this->InitialWidth ||
+ y < cmCursesMainForm::MIN_HEIGHT) {
return;
- }
+ }
// Give the current widget (if it exists), a chance to print keys
cmCursesWidget* cw = 0;
- if (this->Form)
- {
+ if (this->Form) {
FIELD* currentField = current_field(this->Form);
cw = reinterpret_cast<cmCursesWidget*>(field_userptr(currentField));
- }
+ }
- if (cw)
- {
+ if (cw) {
cw->PrintKeys();
- }
-
-// {
-// }
-// else
-// {
- char firstLine[512]="";
- char secondLine[512]="";
- char thirdLine[512]="";
- if (process)
- {
+ }
+
+ // {
+ // }
+ // else
+ // {
+ char firstLine[512] = "";
+ char secondLine[512] = "";
+ char thirdLine[512] = "";
+ if (process) {
const char* clearLine =
" ";
strcpy(firstLine, clearLine);
strcpy(secondLine, clearLine);
strcpy(thirdLine, clearLine);
- }
- else
- {
- if (this->OkToGenerate)
- {
+ } else {
+ if (this->OkToGenerate) {
sprintf(firstLine,
"Press [c] to configure Press [g] to generate and exit");
- }
- else
- {
- sprintf(firstLine, "Press [c] to configure ");
- }
+ } else {
+ sprintf(firstLine,
+ "Press [c] to configure ");
+ }
{
const char* toggleKeyInstruction =
"Press [t] to toggle advanced mode (Currently %s)";
- sprintf(thirdLine,
- toggleKeyInstruction,
+ sprintf(thirdLine, toggleKeyInstruction,
this->AdvancedMode ? "On" : "Off");
}
- sprintf(secondLine,
- "Press [h] for help "
- "Press [q] to quit without generating");
- }
+ sprintf(secondLine, "Press [h] for help "
+ "Press [q] to quit without generating");
+ }
- curses_move(y-4,0);
+ curses_move(y - 4, 0);
char fmt_s[] = "%s";
char fmt[512] = "Press [enter] to edit option";
- if ( process )
- {
+ if (process) {
strcpy(fmt, " ");
- }
+ }
printw(fmt_s, fmt);
- curses_move(y-3,0);
+ curses_move(y - 3, 0);
printw(fmt_s, firstLine);
- curses_move(y-2,0);
+ curses_move(y - 2, 0);
printw(fmt_s, secondLine);
- curses_move(y-1,0);
+ curses_move(y - 1, 0);
printw(fmt_s, thirdLine);
- if (cw)
- {
+ if (cw) {
sprintf(firstLine, "Page %d of %d", cw->GetPage(), this->NumberOfPages);
- curses_move(0,65-static_cast<unsigned int>(strlen(firstLine))-1);
+ curses_move(0, 65 - static_cast<unsigned int>(strlen(firstLine)) - 1);
printw(fmt_s, firstLine);
- }
-// }
+ }
+ // }
pos_form_cursor(this->Form);
-
}
// Print the key of the current entry and the CMake version
// on the status bar. Designed for a width of 80 chars.
void cmCursesMainForm::UpdateStatusBar(const char* message)
{
- int x,y;
+ int x, y;
getmaxyx(stdscr, y, x);
// If window size is too small, display error and return
- if ( x < cmCursesMainForm::MIN_WIDTH ||
- x < this->InitialWidth ||
- y < cmCursesMainForm::MIN_HEIGHT )
- {
+ if (x < cmCursesMainForm::MIN_WIDTH || x < this->InitialWidth ||
+ y < cmCursesMainForm::MIN_HEIGHT) {
curses_clear();
- curses_move(0,0);
+ curses_move(0, 0);
char fmt[] = "Window is too small. A size of at least %dx%d is required.";
- printw(fmt,
- (cmCursesMainForm::MIN_WIDTH < this->InitialWidth ?
- this->InitialWidth : cmCursesMainForm::MIN_WIDTH),
+ printw(fmt, (cmCursesMainForm::MIN_WIDTH < this->InitialWidth
+ ? this->InitialWidth
+ : cmCursesMainForm::MIN_WIDTH),
cmCursesMainForm::MIN_HEIGHT);
touchwin(stdscr);
wrefresh(stdscr);
return;
- }
+ }
// Get the key of the current entry
FIELD* cur = current_field(this->Form);
int findex = field_index(cur);
cmCursesWidget* lbl = 0;
- if ( findex >= 0 )
- {
- lbl = reinterpret_cast<cmCursesWidget*>(field_userptr(this->Fields[findex-2]));
- }
+ if (findex >= 0) {
+ lbl = reinterpret_cast<cmCursesWidget*>(
+ field_userptr(this->Fields[findex - 2]));
+ }
char help[128] = "";
const char* curField = "";
- if ( lbl )
- {
+ if (lbl) {
curField = lbl->GetValue();
// Get the help string of the current entry
// and add it to the help string
const char* existingValue =
- this->CMakeInstance->GetState()->GetCacheEntryValue(curField);
- if (existingValue)
- {
- const char* hs = this->CMakeInstance->GetState()
- ->GetCacheEntryProperty(curField, "HELPSTRING");
- if ( hs )
- {
+ this->CMakeInstance->GetState()->GetCacheEntryValue(curField);
+ if (existingValue) {
+ const char* hs = this->CMakeInstance->GetState()->GetCacheEntryProperty(
+ curField, "HELPSTRING");
+ if (hs) {
strncpy(help, hs, 127);
help[127] = '\0';
- }
- else
- {
+ } else {
help[0] = 0;
- }
- }
- else
- {
- sprintf(help," ");
}
+ } else {
+ sprintf(help, " ");
}
+ }
// Join the key, help string and pad with spaces
// (or truncate) as necessary
@@ -546,119 +469,98 @@ void cmCursesMainForm::UpdateStatusBar(const char* message)
size_t helpLen = strlen(help);
size_t width;
- if (x < cmCursesMainForm::MAX_WIDTH )
- {
+ if (x < cmCursesMainForm::MAX_WIDTH) {
width = x;
- }
- else
- {
+ } else {
width = cmCursesMainForm::MAX_WIDTH;
- }
+ }
- if ( message )
- {
+ if (message) {
curField = message;
curFieldLen = strlen(message);
- if ( curFieldLen < width )
- {
+ if (curFieldLen < width) {
strcpy(bar, curField);
- for(i=curFieldLen; i < width; ++i)
- {
+ for (i = curFieldLen; i < width; ++i) {
bar[i] = ' ';
- }
}
- else
- {
+ } else {
strncpy(bar, curField, width);
- }
- }
- else
- {
- if (curFieldLen >= width)
- {
+ }
+ } else {
+ if (curFieldLen >= width) {
strncpy(bar, curField, width);
- }
- else
- {
+ } else {
strcpy(bar, curField);
bar[curFieldLen] = ':';
- bar[curFieldLen+1] = ' ';
- if (curFieldLen + helpLen + 2 >= width)
- {
- strncpy(bar+curFieldLen+2, help, width
- - curFieldLen - 2);
- }
- else
- {
- strcpy(bar+curFieldLen+2, help);
- for(i=curFieldLen+helpLen+2; i < width; ++i)
- {
+ bar[curFieldLen + 1] = ' ';
+ if (curFieldLen + helpLen + 2 >= width) {
+ strncpy(bar + curFieldLen + 2, help, width - curFieldLen - 2);
+ } else {
+ strcpy(bar + curFieldLen + 2, help);
+ for (i = curFieldLen + helpLen + 2; i < width; ++i) {
bar[i] = ' ';
- }
}
}
}
-
+ }
bar[width] = '\0';
-
// Display CMake version info on the next line
// We want to display this on the right
char version[cmCursesMainForm::MAX_WIDTH];
char vertmp[128];
- sprintf(vertmp,"CMake Version %s", cmVersion::GetCMakeVersion());
- size_t sideSpace = (width-strlen(vertmp));
- for(i=0; i<sideSpace; i++) { version[i] = ' '; }
- sprintf(version+sideSpace, "%s", vertmp);
+ sprintf(vertmp, "CMake Version %s", cmVersion::GetCMakeVersion());
+ size_t sideSpace = (width - strlen(vertmp));
+ for (i = 0; i < sideSpace; i++) {
+ version[i] = ' ';
+ }
+ sprintf(version + sideSpace, "%s", vertmp);
version[width] = '\0';
// Now print both lines
char fmt_s[] = "%s";
- curses_move(y-5,0);
+ curses_move(y - 5, 0);
attron(A_STANDOUT);
printw(fmt_s, bar);
attroff(A_STANDOUT);
- curses_move(y-4,0);
+ curses_move(y - 4, 0);
printw(fmt_s, version);
pos_form_cursor(this->Form);
}
-void cmCursesMainForm::UpdateProgress(const char *msg, float prog, void* vp)
+void cmCursesMainForm::UpdateProgress(const char* msg, float prog, void* vp)
{
cmCursesMainForm* cm = static_cast<cmCursesMainForm*>(vp);
- if ( !cm )
- {
+ if (!cm) {
return;
- }
+ }
char tmp[1024];
- const char *cmsg = tmp;
- if ( prog >= 0 )
- {
- sprintf(tmp, "%s %i%%",msg,(int)(100*prog));
- }
- else
- {
+ const char* cmsg = tmp;
+ if (prog >= 0) {
+ sprintf(tmp, "%s %i%%", msg, (int)(100 * prog));
+ } else {
cmsg = msg;
- }
+ }
cm->UpdateStatusBar(cmsg);
cm->PrintKeys(1);
- curses_move(1,1);
+ curses_move(1, 1);
touchwin(stdscr);
refresh();
}
int cmCursesMainForm::Configure(int noconfigure)
{
- int xi,yi;
+ int xi, yi;
getmaxyx(stdscr, yi, xi);
- curses_move(1,1);
+ curses_move(1, 1);
this->UpdateStatusBar("Configuring, please wait...");
this->PrintKeys(1);
touchwin(stdscr);
refresh();
- this->CMakeInstance->SetProgressCallback(cmCursesMainForm::UpdateProgress, this);
+ this->CMakeInstance->SetProgressCallback(cmCursesMainForm::UpdateProgress,
+ this);
// always save the current gui values to disk
this->FillCacheManagerFromUI();
@@ -672,52 +574,44 @@ int cmCursesMainForm::Configure(int noconfigure)
// run the generate process
this->OkToGenerate = true;
int retVal;
- if ( noconfigure )
- {
+ if (noconfigure) {
retVal = this->CMakeInstance->DoPreConfigureChecks();
this->OkToGenerate = false;
- if ( retVal > 0 )
- {
+ if (retVal > 0) {
retVal = 0;
- }
}
- else
- {
+ } else {
retVal = this->CMakeInstance->Configure();
- }
+ }
this->CMakeInstance->SetProgressCallback(0, 0);
- keypad(stdscr,TRUE); /* Use key symbols as
- KEY_DOWN*/
+ keypad(stdscr, TRUE); /* Use key symbols as
+ KEY_DOWN*/
- if( retVal != 0 || !this->Errors.empty())
- {
+ if (retVal != 0 || !this->Errors.empty()) {
// see if there was an error
- if(cmSystemTools::GetErrorOccuredFlag())
- {
+ if (cmSystemTools::GetErrorOccuredFlag()) {
this->OkToGenerate = false;
- }
- int xx,yy;
+ }
+ int xx, yy;
getmaxyx(stdscr, yy, xx);
cmCursesLongMessageForm* msgs = new cmCursesLongMessageForm(
- this->Errors,
- cmSystemTools::GetErrorOccuredFlag()
- ? "Errors occurred during the last pass." :
- "CMake produced the following output.");
+ this->Errors, cmSystemTools::GetErrorOccuredFlag()
+ ? "Errors occurred during the last pass."
+ : "CMake produced the following output.");
// reset error condition
cmSystemTools::ResetErrorOccuredFlag();
CurrentForm = msgs;
- msgs->Render(1,1,xx,yy);
+ msgs->Render(1, 1, xx, yy);
msgs->HandleInput();
// If they typed the wrong source directory, we report
// an error and exit
- if ( retVal == -2 )
- {
+ if (retVal == -2) {
return retVal;
- }
- CurrentForm = this;
- this->Render(1,1,xx,yy);
}
+ CurrentForm = this;
+ this->Render(1, 1, xx, yy);
+ }
this->InitializeUI();
this->Render(1, 1, xi, yi);
@@ -727,15 +621,16 @@ int cmCursesMainForm::Configure(int noconfigure)
int cmCursesMainForm::Generate()
{
- int xi,yi;
+ int xi, yi;
getmaxyx(stdscr, yi, xi);
- curses_move(1,1);
+ curses_move(1, 1);
this->UpdateStatusBar("Generating, please wait...");
this->PrintKeys(1);
touchwin(stdscr);
refresh();
- this->CMakeInstance->SetProgressCallback(cmCursesMainForm::UpdateProgress, this);
+ this->CMakeInstance->SetProgressCallback(cmCursesMainForm::UpdateProgress,
+ this);
// Get rid of previous errors
this->Errors = std::vector<std::string>();
@@ -744,39 +639,35 @@ int cmCursesMainForm::Generate()
int retVal = this->CMakeInstance->Generate();
this->CMakeInstance->SetProgressCallback(0, 0);
- keypad(stdscr,TRUE); /* Use key symbols as
- KEY_DOWN*/
+ keypad(stdscr, TRUE); /* Use key symbols as
+ KEY_DOWN*/
- if( retVal != 0 || !this->Errors.empty())
- {
+ if (retVal != 0 || !this->Errors.empty()) {
// see if there was an error
- if(cmSystemTools::GetErrorOccuredFlag())
- {
+ if (cmSystemTools::GetErrorOccuredFlag()) {
this->OkToGenerate = false;
- }
+ }
// reset error condition
cmSystemTools::ResetErrorOccuredFlag();
- int xx,yy;
+ int xx, yy;
getmaxyx(stdscr, yy, xx);
const char* title = "Messages during last pass.";
- if(cmSystemTools::GetErrorOccuredFlag())
- {
+ if (cmSystemTools::GetErrorOccuredFlag()) {
title = "Errors occurred during the last pass.";
- }
- cmCursesLongMessageForm* msgs = new cmCursesLongMessageForm(this->Errors,
- title);
+ }
+ cmCursesLongMessageForm* msgs =
+ new cmCursesLongMessageForm(this->Errors, title);
CurrentForm = msgs;
- msgs->Render(1,1,xx,yy);
+ msgs->Render(1, 1, xx, yy);
msgs->HandleInput();
// If they typed the wrong source directory, we report
// an error and exit
- if ( retVal == -2 )
- {
+ if (retVal == -2) {
return retVal;
- }
- CurrentForm = this;
- this->Render(1,1,xx,yy);
}
+ CurrentForm = this;
+ this->Render(1, 1, xx, yy);
+ }
this->InitializeUI();
this->Render(1, 1, xi, yi);
@@ -791,346 +682,286 @@ void cmCursesMainForm::AddError(const char* message, const char*)
void cmCursesMainForm::RemoveEntry(const char* value)
{
- if (!value)
- {
+ if (!value) {
return;
- }
+ }
std::vector<cmCursesCacheEntryComposite*>::iterator it;
- for (it = this->Entries->begin(); it != this->Entries->end(); ++it)
- {
+ for (it = this->Entries->begin(); it != this->Entries->end(); ++it) {
const char* val = (*it)->GetValue();
- if ( val && !strcmp(value, val) )
- {
+ if (val && !strcmp(value, val)) {
this->CMakeInstance->UnwatchUnusedCli(value);
this->Entries->erase(it);
break;
- }
}
+ }
}
// copy from the list box to the cache manager
void cmCursesMainForm::FillCacheManagerFromUI()
{
size_t size = this->Entries->size();
- for(size_t i=0; i < size; i++)
- {
+ for (size_t i = 0; i < size; i++) {
std::string cacheKey = (*this->Entries)[i]->Key;
- const char* existingValue = this->CMakeInstance->GetState()
- ->GetCacheEntryValue(cacheKey);
- if (existingValue)
- {
+ const char* existingValue =
+ this->CMakeInstance->GetState()->GetCacheEntryValue(cacheKey);
+ if (existingValue) {
std::string oldValue = existingValue;
std::string newValue = (*this->Entries)[i]->Entry->GetValue();
std::string fixedOldValue;
std::string fixedNewValue;
cmState::CacheEntryType t =
- this->CMakeInstance->GetState()
- ->GetCacheEntryType(cacheKey);
+ this->CMakeInstance->GetState()->GetCacheEntryType(cacheKey);
this->FixValue(t, oldValue, fixedOldValue);
this->FixValue(t, newValue, fixedNewValue);
- if(!(fixedOldValue == fixedNewValue))
- {
+ if (!(fixedOldValue == fixedNewValue)) {
// The user has changed the value. Mark it as modified.
- this->CMakeInstance->GetState()
- ->SetCacheEntryBoolProperty(cacheKey, "MODIFIED", true);
- this->CMakeInstance->GetState()
- ->SetCacheEntryValue(cacheKey, fixedNewValue);
- }
+ this->CMakeInstance->GetState()->SetCacheEntryBoolProperty(
+ cacheKey, "MODIFIED", true);
+ this->CMakeInstance->GetState()->SetCacheEntryValue(cacheKey,
+ fixedNewValue);
}
}
+ }
}
void cmCursesMainForm::FixValue(cmState::CacheEntryType type,
const std::string& in, std::string& out) const
{
- out = in.substr(0,in.find_last_not_of(" ")+1);
- if(type == cmState::PATH || type == cmState::FILEPATH)
- {
+ out = in.substr(0, in.find_last_not_of(" ") + 1);
+ if (type == cmState::PATH || type == cmState::FILEPATH) {
cmSystemTools::ConvertToUnixSlashes(out);
- }
- if(type == cmState::BOOL)
- {
- if(cmSystemTools::IsOff(out.c_str()))
- {
+ }
+ if (type == cmState::BOOL) {
+ if (cmSystemTools::IsOff(out.c_str())) {
out = "OFF";
- }
- else
- {
+ } else {
out = "ON";
- }
}
+ }
}
#include <unistd.h>
void cmCursesMainForm::HandleInput()
{
- int x=0,y=0;
+ int x = 0, y = 0;
- if (!this->Form)
- {
+ if (!this->Form) {
return;
- }
+ }
FIELD* currentField;
cmCursesWidget* currentWidget;
char debugMessage[128];
- for(;;)
- {
+ for (;;) {
this->UpdateStatusBar();
this->PrintKeys();
- if ( this->SearchMode )
- {
+ if (this->SearchMode) {
std::string searchstr = "Search: " + this->SearchString;
- this->UpdateStatusBar( searchstr.c_str() );
+ this->UpdateStatusBar(searchstr.c_str());
this->PrintKeys(1);
- curses_move(y-5,static_cast<unsigned int>(searchstr.size()));
- //curses_move(1,1);
+ curses_move(y - 5, static_cast<unsigned int>(searchstr.size()));
+ // curses_move(1,1);
touchwin(stdscr);
refresh();
- }
+ }
int key = getch();
getmaxyx(stdscr, y, x);
// If window too small, handle 'q' only
- if ( x < cmCursesMainForm::MIN_WIDTH ||
- y < cmCursesMainForm::MIN_HEIGHT )
- {
+ if (x < cmCursesMainForm::MIN_WIDTH || y < cmCursesMainForm::MIN_HEIGHT) {
// quit
- if ( key == 'q' )
- {
+ if (key == 'q') {
break;
- }
- else
- {
+ } else {
continue;
- }
}
+ }
currentField = current_field(this->Form);
- currentWidget = reinterpret_cast<cmCursesWidget*>(field_userptr(
- currentField));
+ currentWidget =
+ reinterpret_cast<cmCursesWidget*>(field_userptr(currentField));
- bool widgetHandled=false;
+ bool widgetHandled = false;
- if ( this->SearchMode )
- {
- if ( key == 10 || key == KEY_ENTER )
- {
+ if (this->SearchMode) {
+ if (key == 10 || key == KEY_ENTER) {
this->SearchMode = false;
- if (!this->SearchString.empty())
- {
+ if (!this->SearchString.empty()) {
this->JumpToCacheEntry(this->SearchString.c_str());
this->OldSearchString = this->SearchString;
- }
- this->SearchString = "";
}
+ this->SearchString = "";
+ }
/*
else if ( key == KEY_ESCAPE )
{
this->SearchMode = false;
}
*/
- else if ((key >= 'a' && key <= 'z') ||
- (key >= 'A' && key <= 'Z') ||
- (key >= '0' && key <= '9') ||
- (key == '_' ))
- {
- if ( this->SearchString.size() < static_cast<std::string::size_type>(x-10) )
- {
+ else if ((key >= 'a' && key <= 'z') || (key >= 'A' && key <= 'Z') ||
+ (key >= '0' && key <= '9') || (key == '_')) {
+ if (this->SearchString.size() <
+ static_cast<std::string::size_type>(x - 10)) {
this->SearchString += static_cast<char>(key);
- }
}
- else if ( key == ctrl('h') || key == KEY_BACKSPACE || key == KEY_DC )
- {
- if (!this->SearchString.empty())
- {
- this->SearchString.resize(this->SearchString.size()-1);
- }
+ } else if (key == ctrl('h') || key == KEY_BACKSPACE || key == KEY_DC) {
+ if (!this->SearchString.empty()) {
+ this->SearchString.resize(this->SearchString.size() - 1);
}
}
- else if (currentWidget && !this->SearchMode)
- {
+ } else if (currentWidget && !this->SearchMode) {
// Ask the current widget if it wants to handle input
widgetHandled = currentWidget->HandleInput(key, this, stdscr);
- if (widgetHandled)
- {
+ if (widgetHandled) {
this->OkToGenerate = false;
this->UpdateStatusBar();
this->PrintKeys();
- }
}
- if ((!currentWidget || !widgetHandled) && !this->SearchMode)
- {
+ }
+ if ((!currentWidget || !widgetHandled) && !this->SearchMode) {
// If the current widget does not want to handle input,
// we handle it.
sprintf(debugMessage, "Main form handling input, key: %d", key);
cmCursesForm::LogMessage(debugMessage);
// quit
- if ( key == 'q' )
- {
+ if (key == 'q') {
break;
- }
+ }
// if not end of page, next field otherwise next page
// each entry consists of fields: label, isnew, value
// therefore, the label field for the prev. entry is index-5
// and the label field for the next entry is index+1
// (index always corresponds to the value field)
- else if ( key == KEY_DOWN || key == ctrl('n') )
- {
+ else if (key == KEY_DOWN || key == ctrl('n')) {
FIELD* cur = current_field(this->Form);
size_t findex = field_index(cur);
- if ( findex == 3*this->NumberOfVisibleEntries-1 )
- {
+ if (findex == 3 * this->NumberOfVisibleEntries - 1) {
continue;
- }
- if (new_page(this->Fields[findex+1]))
- {
+ }
+ if (new_page(this->Fields[findex + 1])) {
form_driver(this->Form, REQ_NEXT_PAGE);
- }
- else
- {
+ } else {
form_driver(this->Form, REQ_NEXT_FIELD);
- }
}
+ }
// if not beginning of page, previous field, otherwise previous page
// each entry consists of fields: label, isnew, value
// therefore, the label field for the prev. entry is index-5
// and the label field for the next entry is index+1
// (index always corresponds to the value field)
- else if ( key == KEY_UP || key == ctrl('p') )
- {
+ else if (key == KEY_UP || key == ctrl('p')) {
FIELD* cur = current_field(this->Form);
int findex = field_index(cur);
- if ( findex == 2 )
- {
+ if (findex == 2) {
continue;
- }
- if ( new_page(this->Fields[findex-2]) )
- {
+ }
+ if (new_page(this->Fields[findex - 2])) {
form_driver(this->Form, REQ_PREV_PAGE);
- set_current_field(this->Form, this->Fields[findex-3]);
- }
- else
- {
+ set_current_field(this->Form, this->Fields[findex - 3]);
+ } else {
form_driver(this->Form, REQ_PREV_FIELD);
- }
}
+ }
// pg down
- else if ( key == KEY_NPAGE || key == ctrl('d') )
- {
+ else if (key == KEY_NPAGE || key == ctrl('d')) {
form_driver(this->Form, REQ_NEXT_PAGE);
- }
+ }
// pg up
- else if ( key == KEY_PPAGE || key == ctrl('u') )
- {
+ else if (key == KEY_PPAGE || key == ctrl('u')) {
form_driver(this->Form, REQ_PREV_PAGE);
- }
+ }
// configure
- else if ( key == 'c' )
- {
+ else if (key == 'c') {
this->Configure();
- }
+ }
// display help
- else if ( key == 'h' )
- {
+ else if (key == 'h') {
getmaxyx(stdscr, y, x);
FIELD* cur = current_field(this->Form);
int findex = field_index(cur);
- cmCursesWidget* lbl = reinterpret_cast<cmCursesWidget*>(field_userptr(
- this->Fields[findex-2]));
+ cmCursesWidget* lbl = reinterpret_cast<cmCursesWidget*>(
+ field_userptr(this->Fields[findex - 2]));
const char* curField = lbl->GetValue();
const char* helpString = 0;
const char* existingValue =
- this->CMakeInstance->GetState()
- ->GetCacheEntryValue(curField);
- if (existingValue)
- {
- helpString = this->CMakeInstance->GetState()
- ->GetCacheEntryProperty(curField, "HELPSTRING");
- }
- if (helpString)
- {
- char* message = new char[strlen(curField)+strlen(helpString)
- +strlen("Current option is: \n Help string for this option is: \n")+10];
- sprintf(message,"Current option is: %s\nHelp string for this option is: %s\n", curField, helpString);
+ this->CMakeInstance->GetState()->GetCacheEntryValue(curField);
+ if (existingValue) {
+ helpString = this->CMakeInstance->GetState()->GetCacheEntryProperty(
+ curField, "HELPSTRING");
+ }
+ if (helpString) {
+ char* message = new char
+ [strlen(curField) + strlen(helpString) +
+ strlen(
+ "Current option is: \n Help string for this option is: \n") +
+ 10];
+ sprintf(
+ message,
+ "Current option is: %s\nHelp string for this option is: %s\n",
+ curField, helpString);
this->HelpMessage[1] = message;
delete[] message;
- }
- else
- {
+ } else {
this->HelpMessage[1] = "";
- }
+ }
- cmCursesLongMessageForm* msgs = new cmCursesLongMessageForm(this->HelpMessage,
- "Help.");
+ cmCursesLongMessageForm* msgs =
+ new cmCursesLongMessageForm(this->HelpMessage, "Help.");
CurrentForm = msgs;
- msgs->Render(1,1,x,y);
+ msgs->Render(1, 1, x, y);
msgs->HandleInput();
CurrentForm = this;
- this->Render(1,1,x,y);
+ this->Render(1, 1, x, y);
set_current_field(this->Form, cur);
- }
+ }
// display last errors
- else if ( key == 'l' )
- {
+ else if (key == 'l') {
getmaxyx(stdscr, y, x);
- cmCursesLongMessageForm* msgs = new cmCursesLongMessageForm(this->Errors,
- "Errors occurred during the last pass.");
+ cmCursesLongMessageForm* msgs = new cmCursesLongMessageForm(
+ this->Errors, "Errors occurred during the last pass.");
CurrentForm = msgs;
- msgs->Render(1,1,x,y);
+ msgs->Render(1, 1, x, y);
msgs->HandleInput();
CurrentForm = this;
- this->Render(1,1,x,y);
- }
- else if ( key == '/' )
- {
+ this->Render(1, 1, x, y);
+ } else if (key == '/') {
this->SearchMode = true;
this->UpdateStatusBar("Search");
this->PrintKeys(1);
touchwin(stdscr);
refresh();
- }
- else if ( key == 'n' )
- {
- if (!this->OldSearchString.empty())
- {
+ } else if (key == 'n') {
+ if (!this->OldSearchString.empty()) {
this->JumpToCacheEntry(this->OldSearchString.c_str());
- }
}
+ }
// switch advanced on/off
- else if ( key == 't' )
- {
- if (this->AdvancedMode)
- {
+ else if (key == 't') {
+ if (this->AdvancedMode) {
this->AdvancedMode = false;
- }
- else
- {
+ } else {
this->AdvancedMode = true;
- }
+ }
getmaxyx(stdscr, y, x);
this->RePost();
this->Render(1, 1, x, y);
- }
+ }
// generate and exit
- else if ( key == 'g' )
- {
- if ( this->OkToGenerate )
- {
+ else if (key == 'g') {
+ if (this->OkToGenerate) {
this->Generate();
break;
- }
}
+ }
// delete cache entry
- else if ( key == 'd' && this->NumberOfVisibleEntries )
- {
+ else if (key == 'd' && this->NumberOfVisibleEntries) {
this->OkToGenerate = false;
FIELD* cur = current_field(this->Form);
size_t findex = field_index(cur);
@@ -1141,76 +972,66 @@ void cmCursesMainForm::HandleInput()
// and the label field for the next entry is findex+1
// (findex always corresponds to the value field)
FIELD* nextCur;
- if ( findex == 2 )
- {
- nextCur=0;
- }
- else if ( findex == 3*this->NumberOfVisibleEntries-1 )
- {
- nextCur = this->Fields[findex-5];
- }
- else
- {
- nextCur = this->Fields[findex+1];
- }
+ if (findex == 2) {
+ nextCur = 0;
+ } else if (findex == 3 * this->NumberOfVisibleEntries - 1) {
+ nextCur = this->Fields[findex - 5];
+ } else {
+ nextCur = this->Fields[findex + 1];
+ }
// Get the label widget
// each entry consists of fields: label, isnew, value
// therefore, the label field for the is findex-2
// (findex always corresponds to the value field)
- cmCursesWidget* lbl
- = reinterpret_cast<cmCursesWidget*>(
- field_userptr(this->Fields[findex-2]));
- if ( lbl )
- {
+ cmCursesWidget* lbl = reinterpret_cast<cmCursesWidget*>(
+ field_userptr(this->Fields[findex - 2]));
+ if (lbl) {
this->CMakeInstance->GetState()->RemoveCacheEntry(lbl->GetValue());
std::string nextVal;
- if (nextCur)
- {
- nextVal = (reinterpret_cast<cmCursesWidget*>(field_userptr(nextCur))->GetValue());
- }
+ if (nextCur) {
+ nextVal =
+ (reinterpret_cast<cmCursesWidget*>(field_userptr(nextCur))
+ ->GetValue());
+ }
getmaxyx(stdscr, y, x);
this->RemoveEntry(lbl->GetValue());
this->RePost();
this->Render(1, 1, x, y);
- if (nextCur)
- {
+ if (nextCur) {
// make the next or prev. current field after deletion
nextCur = 0;
std::vector<cmCursesCacheEntryComposite*>::iterator it;
- for (it = this->Entries->begin(); it != this->Entries->end(); ++it)
- {
- if (nextVal == (*it)->Key)
- {
+ for (it = this->Entries->begin(); it != this->Entries->end();
+ ++it) {
+ if (nextVal == (*it)->Key) {
nextCur = (*it)->Entry->Field;
- }
}
+ }
- if (nextCur)
- {
+ if (nextCur) {
set_current_field(this->Form, nextCur);
- }
}
}
}
}
+ }
touchwin(stdscr);
wrefresh(stdscr);
- }
+ }
}
-int cmCursesMainForm::LoadCache(const char *)
+int cmCursesMainForm::LoadCache(const char*)
{
int r = this->CMakeInstance->LoadCache();
- if(r < 0)
- {
+ if (r < 0) {
return r;
- }
+ }
this->CMakeInstance->SetCacheArgs(this->Args);
this->CMakeInstance->PreLoadCMakeFiles();
return r;
@@ -1219,55 +1040,44 @@ int cmCursesMainForm::LoadCache(const char *)
void cmCursesMainForm::JumpToCacheEntry(const char* astr)
{
std::string str;
- if ( astr )
- {
+ if (astr) {
str = cmSystemTools::LowerCase(astr);
- }
+ }
- if(str.empty())
- {
+ if (str.empty()) {
return;
- }
+ }
FIELD* cur = current_field(this->Form);
int start_index = field_index(cur);
int findex = start_index;
- for(;;)
- {
- if (!str.empty())
- {
+ for (;;) {
+ if (!str.empty()) {
cmCursesWidget* lbl = 0;
- if ( findex >= 0 )
- {
- lbl = reinterpret_cast<cmCursesWidget*>(field_userptr(this->Fields[findex-2]));
- }
- if ( lbl )
- {
+ if (findex >= 0) {
+ lbl = reinterpret_cast<cmCursesWidget*>(
+ field_userptr(this->Fields[findex - 2]));
+ }
+ if (lbl) {
const char* curField = lbl->GetValue();
- if ( curField )
- {
+ if (curField) {
std::string cfld = cmSystemTools::LowerCase(curField);
- if ( cfld.find(str) != cfld.npos && findex != start_index )
- {
+ if (cfld.find(str) != cfld.npos && findex != start_index) {
break;
- }
}
}
}
- if ( size_t(findex) >= 3* this->NumberOfVisibleEntries-1 )
- {
+ }
+ if (size_t(findex) >= 3 * this->NumberOfVisibleEntries - 1) {
set_current_field(this->Form, this->Fields[2]);
- }
- else if (new_page(this->Fields[findex+1]))
- {
+ } else if (new_page(this->Fields[findex + 1])) {
form_driver(this->Form, REQ_NEXT_PAGE);
- }
- else
- {
+ } else {
form_driver(this->Form, REQ_NEXT_FIELD);
- }
+ }
/*
char buffer[1024];
- sprintf(buffer, "Line: %d != %d / %d\n", findex, idx, this->NumberOfVisibleEntries);
+ sprintf(buffer, "Line: %d != %d / %d\n", findex, idx,
+ this->NumberOfVisibleEntries);
touchwin(stdscr);
refresh();
this->UpdateStatusBar( buffer );
@@ -1275,52 +1085,70 @@ void cmCursesMainForm::JumpToCacheEntry(const char* astr)
*/
cur = current_field(this->Form);
findex = field_index(cur);
- if ( findex == start_index )
- {
+ if (findex == start_index) {
break;
- }
}
+ }
}
-
const char* cmCursesMainForm::s_ConstHelpMessage =
-"CMake is used to configure and generate build files for software projects. "
-"The basic steps for configuring a project with ccmake are as follows:\n\n"
-"1. Run ccmake in the directory where you want the object and executable files to be placed (build directory). If the source directory is not the same as this build directory, you have to specify it as an argument on the command line.\n\n"
-"2. When ccmake is run, it will read the configuration files and display the current build options. "
-"If you have run CMake before and have updated the configuration files since then, any new entries will be displayed on top and will be marked with a *. "
-"On the other hand, the first time you run ccmake, all build options will be new and will be marked as such. "
-"At this point, you can modify any options (see keys below) you want to change. "
-"When you are satisfied with your changes, press 'c' to have CMake process the configuration files. "
-"Please note that changing some options may cause new ones to appear. These will be shown on top and will be marked with *. "
-"Repeat this procedure until you are satisfied with all the options and there are no new entries. "
-"At this point, a new command will appear: G)enerate and Exit. You can now hit 'g' to have CMake generate all the build files (i.e. makefiles or project files) and exit. "
-"At any point during the process, you can exit ccmake with 'q'. However, this will not generate/change any build files.\n\n"
-"ccmake KEYS:\n\n"
-"Navigation: "
-"You can use the arrow keys and page up, down to navigate the options. Alternatively, you can use the following keys: \n"
-" C-n : next option\n"
-" C-p : previous options\n"
-" C-d : down one page\n"
-" C-u : up one page\n\n"
-"Editing options: "
-"To change an option press enter or return. If the current options is a boolean, this will toggle it's value. "
-"Otherwise, ccmake will enter edit mode. In this mode you can edit an option using arrow keys and backspace. Alternatively, you can use the following keys:\n"
-" C-b : back one character\n"
-" C-f : forward one character\n"
-" C-a : go to the beginning of the field\n"
-" C-e : go to the end of the field\n"
-" C-d : delete previous character\n"
-" C-k : kill the rest of the field\n"
-" Esc : Restore field (discard last changes)\n"
-" Enter : Leave edit mode\n"
-"You can also delete an option by pressing 'd'\n\n"
-"Commands:\n"
-" q : quit ccmake without generating build files\n"
-" h : help, shows this screen\n"
-" c : process the configuration files with the current options\n"
-" g : generate build files and exit, only available when there are no "
-"new options and no errors have been detected during last configuration.\n"
-" l : shows last errors\n"
-" t : toggles advanced mode. In normal mode, only the most important options are shown. In advanced mode, all options are shown. We recommend using normal mode unless you are an expert.\n"
-" / : search for a variable name.\n";
+ "CMake is used to configure and generate build files for software projects. "
+ "The basic steps for configuring a project with ccmake are as follows:\n\n"
+ "1. Run ccmake in the directory where you want the object and executable "
+ "files to be placed (build directory). If the source directory is not the "
+ "same as this build directory, you have to specify it as an argument on the "
+ "command line.\n\n"
+ "2. When ccmake is run, it will read the configuration files and display "
+ "the current build options. "
+ "If you have run CMake before and have updated the configuration files "
+ "since then, any new entries will be displayed on top and will be marked "
+ "with a *. "
+ "On the other hand, the first time you run ccmake, all build options will "
+ "be new and will be marked as such. "
+ "At this point, you can modify any options (see keys below) you want to "
+ "change. "
+ "When you are satisfied with your changes, press 'c' to have CMake process "
+ "the configuration files. "
+ "Please note that changing some options may cause new ones to appear. These "
+ "will be shown on top and will be marked with *. "
+ "Repeat this procedure until you are satisfied with all the options and "
+ "there are no new entries. "
+ "At this point, a new command will appear: G)enerate and Exit. You can now "
+ "hit 'g' to have CMake generate all the build files (i.e. makefiles or "
+ "project files) and exit. "
+ "At any point during the process, you can exit ccmake with 'q'. However, "
+ "this will not generate/change any build files.\n\n"
+ "ccmake KEYS:\n\n"
+ "Navigation: "
+ "You can use the arrow keys and page up, down to navigate the options. "
+ "Alternatively, you can use the following keys: \n"
+ " C-n : next option\n"
+ " C-p : previous options\n"
+ " C-d : down one page\n"
+ " C-u : up one page\n\n"
+ "Editing options: "
+ "To change an option press enter or return. If the current options is a "
+ "boolean, this will toggle it's value. "
+ "Otherwise, ccmake will enter edit mode. In this mode you can edit an "
+ "option using arrow keys and backspace. Alternatively, you can use the "
+ "following keys:\n"
+ " C-b : back one character\n"
+ " C-f : forward one character\n"
+ " C-a : go to the beginning of the field\n"
+ " C-e : go to the end of the field\n"
+ " C-d : delete previous character\n"
+ " C-k : kill the rest of the field\n"
+ " Esc : Restore field (discard last changes)\n"
+ " Enter : Leave edit mode\n"
+ "You can also delete an option by pressing 'd'\n\n"
+ "Commands:\n"
+ " q : quit ccmake without generating build files\n"
+ " h : help, shows this screen\n"
+ " c : process the configuration files with the current options\n"
+ " g : generate build files and exit, only available when there are no "
+ "new options and no errors have been detected during last configuration.\n"
+ " l : shows last errors\n"
+ " t : toggles advanced mode. In normal mode, only the most important "
+ "options are shown. In advanced mode, all options are shown. We recommend "
+ "using normal mode unless you are an expert.\n"
+ " / : search for a variable name.\n";
diff --git a/Source/CursesDialog/cmCursesMainForm.h b/Source/CursesDialog/cmCursesMainForm.h
index 9a80ba2..9aa0f67 100644
--- a/Source/CursesDialog/cmCursesMainForm.h
+++ b/Source/CursesDialog/cmCursesMainForm.h
@@ -54,7 +54,8 @@ public:
*/
bool LookForCacheEntry(const std::string& key);
- enum {
+ enum
+ {
MIN_WIDTH = 65,
MIN_HEIGHT = 6,
IDEAL_WIDTH = 80,
@@ -88,7 +89,7 @@ public:
* Used to do a configure. If argument is specified, it does only the check
* and not configure.
*/
- int Configure(int noconfigure=0);
+ int Configure(int noconfigure = 0);
/**
* Used to generate
@@ -98,13 +99,13 @@ public:
/**
* Used by main program
*/
- int LoadCache(const char *dir);
+ int LoadCache(const char* dir);
/**
* Progress callback
*/
- static void UpdateProgressOld(const char *msg, float prog, void*);
- static void UpdateProgress(const char *msg, float prog, void*);
+ static void UpdateProgressOld(const char* msg, float prog, void*);
+ static void UpdateProgress(const char* msg, float prog, void*);
protected:
cmCursesMainForm(const cmCursesMainForm& from);
@@ -114,8 +115,8 @@ protected:
// cache.
void FillCacheManagerFromUI();
// Fix formatting of values to a consistent form.
- void FixValue(cmState::CacheEntryType type,
- const std::string& in, std::string& out) const;
+ void FixValue(cmState::CacheEntryType type, const std::string& in,
+ std::string& out) const;
// Re-post the existing fields. Used to toggle between
// normal and advanced modes. Render() should be called
// afterwards.
@@ -155,7 +156,7 @@ protected:
int NumberOfPages;
int InitialWidth;
- cmake *CMakeInstance;
+ cmake* CMakeInstance;
std::string SearchString;
std::string OldSearchString;
diff --git a/Source/CursesDialog/cmCursesOptionsWidget.cxx b/Source/CursesDialog/cmCursesOptionsWidget.cxx
index 05aeab1..1a3a8c2 100644
--- a/Source/CursesDialog/cmCursesOptionsWidget.cxx
+++ b/Source/CursesDialog/cmCursesOptionsWidget.cxx
@@ -15,54 +15,47 @@
inline int ctrl(int z)
{
- return (z&037);
+ return (z & 037);
}
-cmCursesOptionsWidget::cmCursesOptionsWidget(int width, int height,
- int left, int top) :
- cmCursesWidget(width, height, left, top)
+cmCursesOptionsWidget::cmCursesOptionsWidget(int width, int height, int left,
+ int top)
+ : cmCursesWidget(width, height, left, top)
{
this->Type = cmState::BOOL; // this is a bit of a hack
// there is no option type, and string type causes ccmake to cast
// the widget into a string widget at some point. BOOL is safe for
// now.
- set_field_fore(this->Field, A_NORMAL);
- set_field_back(this->Field, A_STANDOUT);
- field_opts_off(this->Field, O_STATIC);
+ set_field_fore(this->Field, A_NORMAL);
+ set_field_back(this->Field, A_STANDOUT);
+ field_opts_off(this->Field, O_STATIC);
}
bool cmCursesOptionsWidget::HandleInput(int& key, cmCursesMainForm*, WINDOW* w)
{
// 10 == enter
- if (key == 10 || key == KEY_ENTER)
- {
+ if (key == 10 || key == KEY_ENTER) {
this->NextOption();
touchwin(w);
wrefresh(w);
return true;
- }
- else if (key == KEY_LEFT || key == ctrl('b'))
- {
+ } else if (key == KEY_LEFT || key == ctrl('b')) {
touchwin(w);
wrefresh(w);
this->PreviousOption();
return true;
- }
- else if (key == KEY_RIGHT || key == ctrl('f'))
- {
+ } else if (key == KEY_RIGHT || key == ctrl('f')) {
this->NextOption();
touchwin(w);
wrefresh(w);
return true;
- }
- else
- {
+ } else {
return false;
- }
+ }
}
-void cmCursesOptionsWidget::AddOption(std::string const & option )
+void cmCursesOptionsWidget::AddOption(std::string const& option)
{
this->Options.push_back(option);
}
@@ -70,22 +63,18 @@ void cmCursesOptionsWidget::AddOption(std::string const & option )
void cmCursesOptionsWidget::NextOption()
{
this->CurrentOption++;
- if(this->CurrentOption > this->Options.size()-1)
- {
+ if (this->CurrentOption > this->Options.size() - 1) {
this->CurrentOption = 0;
- }
+ }
this->SetValue(this->Options[this->CurrentOption]);
}
void cmCursesOptionsWidget::PreviousOption()
{
- if(this->CurrentOption == 0)
- {
- this->CurrentOption = this->Options.size()-1;
- }
- else
- {
+ if (this->CurrentOption == 0) {
+ this->CurrentOption = this->Options.size() - 1;
+ } else {
this->CurrentOption--;
- }
+ }
this->SetValue(this->Options[this->CurrentOption]);
}
@@ -94,13 +83,11 @@ void cmCursesOptionsWidget::SetOption(const std::string& value)
this->CurrentOption = 0; // default to 0 index
this->SetValue(value);
int index = 0;
- for(std::vector<std::string>::iterator i = this->Options.begin();
- i != this->Options.end(); ++i)
- {
- if(*i == value)
- {
+ for (std::vector<std::string>::iterator i = this->Options.begin();
+ i != this->Options.end(); ++i) {
+ if (*i == value) {
this->CurrentOption = index;
- }
- index++;
}
+ index++;
+ }
}
diff --git a/Source/CursesDialog/cmCursesOptionsWidget.h b/Source/CursesDialog/cmCursesOptionsWidget.h
index ba359d3..a17f2d5 100644
--- a/Source/CursesDialog/cmCursesOptionsWidget.h
+++ b/Source/CursesDialog/cmCursesOptionsWidget.h
@@ -27,9 +27,10 @@ public:
// handled.
virtual bool HandleInput(int& key, cmCursesMainForm* fm, WINDOW* w);
void SetOption(const std::string&);
- void AddOption(std::string const &);
+ void AddOption(std::string const&);
void NextOption();
void PreviousOption();
+
protected:
cmCursesOptionsWidget(const cmCursesOptionsWidget& from);
void operator=(const cmCursesOptionsWidget&);
diff --git a/Source/CursesDialog/cmCursesPathWidget.cxx b/Source/CursesDialog/cmCursesPathWidget.cxx
index 6116823..33fffd1 100644
--- a/Source/CursesDialog/cmCursesPathWidget.cxx
+++ b/Source/CursesDialog/cmCursesPathWidget.cxx
@@ -14,9 +14,9 @@
#include "cmCursesMainForm.h"
#include "cmSystemTools.h"
-cmCursesPathWidget::cmCursesPathWidget(int width, int height,
- int left, int top) :
- cmCursesStringWidget(width, height, left, top)
+cmCursesPathWidget::cmCursesPathWidget(int width, int height, int left,
+ int top)
+ : cmCursesStringWidget(width, height, left, top)
{
this->Type = cmState::PATH;
this->Cycle = false;
@@ -33,46 +33,39 @@ void cmCursesPathWidget::OnType(int& key, cmCursesMainForm* fm, WINDOW* w)
void cmCursesPathWidget::OnTab(cmCursesMainForm* fm, WINDOW* w)
{
- if ( !this->GetString() )
- {
+ if (!this->GetString()) {
return;
- }
+ }
FORM* form = fm->GetForm();
form_driver(form, REQ_NEXT_FIELD);
form_driver(form, REQ_PREV_FIELD);
std::string cstr = this->GetString();
- cstr = cstr.substr(0, cstr.find_last_not_of(" \t\n\r")+1);
- if ( this->LastString != cstr )
- {
+ cstr = cstr.substr(0, cstr.find_last_not_of(" \t\n\r") + 1);
+ if (this->LastString != cstr) {
this->Cycle = false;
this->CurrentIndex = 0;
this->LastGlob = "";
- }
+ }
std::string glob;
- if ( this->Cycle )
- {
+ if (this->Cycle) {
glob = this->LastGlob;
- }
- else
- {
+ } else {
glob = cstr + "*";
- }
+ }
std::vector<std::string> dirs;
- cmSystemTools::SimpleGlob(glob, dirs, (this->Type == cmState::PATH?-1:0));
- if ( this->CurrentIndex < dirs.size() )
- {
+ cmSystemTools::SimpleGlob(glob, dirs,
+ (this->Type == cmState::PATH ? -1 : 0));
+ if (this->CurrentIndex < dirs.size()) {
cstr = dirs[this->CurrentIndex];
- }
- if ( cstr[cstr.size()-1] == '*' )
- {
- cstr = cstr.substr(0, cstr.size()-1);
- }
+ }
+ if (cstr[cstr.size() - 1] == '*') {
+ cstr = cstr.substr(0, cstr.size() - 1);
+ }
- if ( cmSystemTools::FileIsDirectory(cstr) )
- {
+ if (cmSystemTools::FileIsDirectory(cstr)) {
cstr += "/";
- }
+ }
this->SetString(cstr);
touchwin(w);
@@ -81,11 +74,10 @@ void cmCursesPathWidget::OnTab(cmCursesMainForm* fm, WINDOW* w)
this->LastGlob = glob;
this->LastString = cstr;
this->Cycle = true;
- this->CurrentIndex ++;
- if ( this->CurrentIndex >= dirs.size() )
- {
+ this->CurrentIndex++;
+ if (this->CurrentIndex >= dirs.size()) {
this->CurrentIndex = 0;
- }
+ }
}
void cmCursesPathWidget::OnReturn(cmCursesMainForm* fm, WINDOW* w)
diff --git a/Source/CursesDialog/cmCursesStandardIncludes.h b/Source/CursesDialog/cmCursesStandardIncludes.h
index 69a05b2..7b44df9 100644
--- a/Source/CursesDialog/cmCursesStandardIncludes.h
+++ b/Source/CursesDialog/cmCursesStandardIncludes.h
@@ -15,12 +15,12 @@
#include "../cmStandardIncludes.h"
#if defined(__sun__) && defined(__GNUC__)
- #define _MSE_INT_H
+#define _MSE_INT_H
#endif
#if defined(__hpux)
-# define _BOOL_DEFINED
-# include <sys/time.h>
+#define _BOOL_DEFINED
+#include <sys/time.h>
#endif
#include <form.h>
@@ -29,7 +29,7 @@
// so remove them from the namespace
inline void curses_move(unsigned int x, unsigned int y)
{
- move(x,y);
+ move(x, y);
}
inline void curses_clear()
@@ -42,5 +42,4 @@ inline void curses_clear()
#undef erase
#undef clear
-
#endif // cmCursesStandardIncludes_h
diff --git a/Source/CursesDialog/cmCursesStringWidget.cxx b/Source/CursesDialog/cmCursesStringWidget.cxx
index 6bd7b45..3707d0d 100644
--- a/Source/CursesDialog/cmCursesStringWidget.cxx
+++ b/Source/CursesDialog/cmCursesStringWidget.cxx
@@ -15,30 +15,29 @@
inline int ctrl(int z)
{
- return (z&037);
+ return (z & 037);
}
-cmCursesStringWidget::cmCursesStringWidget(int width, int height,
- int left, int top) :
- cmCursesWidget(width, height, left, top)
+cmCursesStringWidget::cmCursesStringWidget(int width, int height, int left,
+ int top)
+ : cmCursesWidget(width, height, left, top)
{
this->InEdit = false;
this->Type = cmState::STRING;
- set_field_fore(this->Field, A_NORMAL);
- set_field_back(this->Field, A_STANDOUT);
- field_opts_off(this->Field, O_STATIC);
+ set_field_fore(this->Field, A_NORMAL);
+ set_field_back(this->Field, A_STANDOUT);
+ field_opts_off(this->Field, O_STATIC);
}
void cmCursesStringWidget::OnTab(cmCursesMainForm*, WINDOW*)
{
- //FORM* form = fm->GetForm();
+ // FORM* form = fm->GetForm();
}
void cmCursesStringWidget::OnReturn(cmCursesMainForm* fm, WINDOW*)
{
FORM* form = fm->GetForm();
- if (this->InEdit)
- {
+ if (this->InEdit) {
cmCursesForm::LogMessage("String widget leaving edit.");
this->InEdit = false;
fm->PrintKeys();
@@ -47,16 +46,14 @@ void cmCursesStringWidget::OnReturn(cmCursesMainForm* fm, WINDOW*)
form_driver(form, REQ_NEXT_FIELD);
form_driver(form, REQ_PREV_FIELD);
this->Done = true;
- }
- else
- {
+ } else {
cmCursesForm::LogMessage("String widget entering edit.");
this->InEdit = true;
fm->PrintKeys();
char* buf = field_buffer(this->Field, 0);
- this->OriginalString = new char[strlen(buf)+1];
+ this->OriginalString = new char[strlen(buf) + 1];
strcpy(this->OriginalString, buf);
- }
+ }
}
void cmCursesStringWidget::OnType(int& key, cmCursesMainForm* fm, WINDOW*)
@@ -67,23 +64,21 @@ void cmCursesStringWidget::OnType(int& key, cmCursesMainForm* fm, WINDOW*)
bool cmCursesStringWidget::HandleInput(int& key, cmCursesMainForm* fm,
WINDOW* w)
{
- int x,y;
+ int x, y;
FORM* form = fm->GetForm();
// 10 == enter
- if (!this->InEdit && ( key != 10 && key != KEY_ENTER ) )
- {
+ if (!this->InEdit && (key != 10 && key != KEY_ENTER)) {
return false;
- }
+ }
- this->OriginalString=0;
+ this->OriginalString = 0;
this->Done = false;
char debugMessage[128];
// <Enter> is used to change edit mode (like <Esc> in vi).
- while(!this->Done)
- {
+ while (!this->Done) {
sprintf(debugMessage, "String widget handling input, key: %d", key);
cmCursesForm::LogMessage(debugMessage);
@@ -91,48 +86,36 @@ bool cmCursesStringWidget::HandleInput(int& key, cmCursesMainForm* fm,
getmaxyx(stdscr, y, x);
// If window too small, handle 'q' only
- if ( x < cmCursesMainForm::MIN_WIDTH ||
- y < cmCursesMainForm::MIN_HEIGHT )
- {
+ if (x < cmCursesMainForm::MIN_WIDTH || y < cmCursesMainForm::MIN_HEIGHT) {
// quit
- if ( key == 'q' )
- {
+ if (key == 'q') {
return false;
- }
- else
- {
- key=getch();
+ } else {
+ key = getch();
continue;
- }
}
+ }
// If resize occurred during edit, move out of edit mode
- if (!this->InEdit && ( key != 10 && key != KEY_ENTER ) )
- {
+ if (!this->InEdit && (key != 10 && key != KEY_ENTER)) {
return false;
- }
+ }
// 10 == enter
- if (key == 10 || key == KEY_ENTER)
- {
+ if (key == 10 || key == KEY_ENTER) {
this->OnReturn(fm, w);
- }
- else if ( key == KEY_DOWN || key == ctrl('n') ||
- key == KEY_UP || key == ctrl('p') ||
- key == KEY_NPAGE || key == ctrl('d') ||
- key == KEY_PPAGE || key == ctrl('u'))
- {
+ } else if (key == KEY_DOWN || key == ctrl('n') || key == KEY_UP ||
+ key == ctrl('p') || key == KEY_NPAGE || key == ctrl('d') ||
+ key == KEY_PPAGE || key == ctrl('u')) {
this->InEdit = false;
delete[] this->OriginalString;
// trick to force forms to update the field buffer
form_driver(form, REQ_NEXT_FIELD);
form_driver(form, REQ_PREV_FIELD);
return false;
- }
+ }
// esc
- else if (key == 27)
- {
- if (this->InEdit)
- {
+ else if (key == 27) {
+ if (this->InEdit) {
this->InEdit = false;
fm->PrintKeys();
this->SetString(this->OriginalString);
@@ -140,58 +123,37 @@ bool cmCursesStringWidget::HandleInput(int& key, cmCursesMainForm* fm,
touchwin(w);
wrefresh(w);
return true;
- }
}
- else if ( key == 9 )
- {
+ } else if (key == 9) {
this->OnTab(fm, w);
- }
- else if ( key == KEY_LEFT || key == ctrl('b') )
- {
+ } else if (key == KEY_LEFT || key == ctrl('b')) {
form_driver(form, REQ_PREV_CHAR);
- }
- else if ( key == KEY_RIGHT || key == ctrl('f') )
- {
+ } else if (key == KEY_RIGHT || key == ctrl('f')) {
form_driver(form, REQ_NEXT_CHAR);
- }
- else if ( key == ctrl('k') )
- {
+ } else if (key == ctrl('k')) {
form_driver(form, REQ_CLR_EOL);
- }
- else if ( key == ctrl('a') || key == KEY_HOME )
- {
+ } else if (key == ctrl('a') || key == KEY_HOME) {
form_driver(form, REQ_BEG_FIELD);
- }
- else if ( key == ctrl('e') || key == KEY_END )
- {
+ } else if (key == ctrl('e') || key == KEY_END) {
form_driver(form, REQ_END_FIELD);
+ } else if (key == 127 || key == KEY_BACKSPACE) {
+ FIELD* cur = current_field(form);
+ form_driver(form, REQ_DEL_PREV);
+ if (current_field(form) != cur) {
+ set_current_field(form, cur);
}
- else if ( key == 127 ||
- key == KEY_BACKSPACE )
- {
- FIELD *cur = current_field(form);
- form_driver(form, REQ_DEL_PREV);
- if (current_field(form) != cur)
- {
- set_current_field(form, cur);
- }
- }
- else if ( key == ctrl('d') ||key == KEY_DC )
- {
+ } else if (key == ctrl('d') || key == KEY_DC) {
form_driver(form, REQ_DEL_CHAR);
- }
- else
- {
+ } else {
this->OnType(key, fm, w);
- }
- if ( !this->Done )
- {
+ }
+ if (!this->Done) {
touchwin(w);
wrefresh(w);
- key=getch();
- }
+ key = getch();
}
+ }
return true;
}
@@ -212,38 +174,32 @@ const char* cmCursesStringWidget::GetValue()
bool cmCursesStringWidget::PrintKeys()
{
- int x,y;
+ int x, y;
getmaxyx(stdscr, y, x);
- if ( x < cmCursesMainForm::MIN_WIDTH ||
- y < cmCursesMainForm::MIN_HEIGHT )
- {
+ if (x < cmCursesMainForm::MIN_WIDTH || y < cmCursesMainForm::MIN_HEIGHT) {
return false;
- }
- if (this->InEdit)
- {
+ }
+ if (this->InEdit) {
char fmt_s[] = "%s";
char firstLine[512];
// Clean the toolbar
- for(int i=0; i<512; i++)
- {
+ for (int i = 0; i < 512; i++) {
firstLine[i] = ' ';
- }
+ }
firstLine[511] = '\0';
- curses_move(y-4,0);
+ curses_move(y - 4, 0);
printw(fmt_s, firstLine);
- curses_move(y-3,0);
+ curses_move(y - 3, 0);
printw(fmt_s, firstLine);
- curses_move(y-2,0);
+ curses_move(y - 2, 0);
printw(fmt_s, firstLine);
- curses_move(y-1,0);
+ curses_move(y - 1, 0);
printw(fmt_s, firstLine);
- curses_move(y-3,0);
+ curses_move(y - 3, 0);
printw(fmt_s, "Editing option, press [enter] to leave edit.");
return true;
- }
- else
- {
+ } else {
return false;
- }
+ }
}
diff --git a/Source/CursesDialog/cmCursesWidget.cxx b/Source/CursesDialog/cmCursesWidget.cxx
index a12e4c2..100ed1d 100644
--- a/Source/CursesDialog/cmCursesWidget.cxx
+++ b/Source/CursesDialog/cmCursesWidget.cxx
@@ -15,41 +15,36 @@ cmCursesWidget::cmCursesWidget(int width, int height, int left, int top)
{
this->Field = new_field(height, width, top, left, 0, 0);
set_field_userptr(this->Field, reinterpret_cast<char*>(this));
- field_opts_off(this->Field, O_AUTOSKIP);
+ field_opts_off(this->Field, O_AUTOSKIP);
this->Page = 0;
}
cmCursesWidget::~cmCursesWidget()
{
- if (this->Field)
- {
+ if (this->Field) {
free_field(this->Field);
this->Field = 0;
- }
+ }
}
void cmCursesWidget::Move(int x, int y, bool isNewPage)
{
- if (!this->Field)
- {
+ if (!this->Field) {
return;
- }
+ }
move_field(this->Field, y, x);
- if (isNewPage)
- {
+ if (isNewPage) {
set_new_page(this->Field, TRUE);
- }
- else
- {
+ } else {
set_new_page(this->Field, FALSE);
- }
+ }
}
void cmCursesWidget::SetValue(const std::string& value)
{
this->Value = value;
- set_field_buffer(this->Field, 0, const_cast<char *>(value.c_str()));
+ set_field_buffer(this->Field, 0, const_cast<char*>(value.c_str()));
}
const char* cmCursesWidget::GetValue()
diff --git a/Source/CursesDialog/cmCursesWidget.h b/Source/CursesDialog/cmCursesWidget.h
index 1f53786..2ac5bb8 100644
--- a/Source/CursesDialog/cmCursesWidget.h
+++ b/Source/CursesDialog/cmCursesWidget.h
@@ -47,30 +47,20 @@ public:
/**
* Get the type of the widget (STRING, PATH etc...)
*/
- cmState::CacheEntryType GetType()
- { return this->Type; }
+ cmState::CacheEntryType GetType() { return this->Type; }
/**
* If there are any, print the widget specific commands
* in the toolbar and return true. Otherwise, return false
* and the parent widget will print.
*/
- virtual bool PrintKeys()
- {
- return false;
- }
+ virtual bool PrintKeys() { return false; }
/**
* Set/Get the page this widget is in.
*/
- void SetPage(int page)
- {
- this->Page = page;
- }
- int GetPage()
- {
- return this->Page;
- }
+ void SetPage(int page) { this->Page = page; }
+ int GetPage() { return this->Page; }
friend class cmCursesMainForm;
diff --git a/Source/QtDialog/AddCacheEntry.cxx b/Source/QtDialog/AddCacheEntry.cxx
index efb2b65..dc7a4b0 100644
--- a/Source/QtDialog/AddCacheEntry.cxx
+++ b/Source/QtDialog/AddCacheEntry.cxx
@@ -17,21 +17,23 @@
static const int NumTypes = 4;
static const int DefaultTypeIndex = 0;
-static const QByteArray TypeStrings[NumTypes] =
- { "BOOL", "PATH", "FILEPATH", "STRING" };
-static const QCMakeProperty::PropertyType Types[NumTypes] =
- { QCMakeProperty::BOOL, QCMakeProperty::PATH,
- QCMakeProperty::FILEPATH, QCMakeProperty::STRING};
+static const QByteArray TypeStrings[NumTypes] = { "BOOL", "PATH", "FILEPATH",
+ "STRING" };
+static const QCMakeProperty::PropertyType Types[NumTypes] = {
+ QCMakeProperty::BOOL, QCMakeProperty::PATH, QCMakeProperty::FILEPATH,
+ QCMakeProperty::STRING
+};
AddCacheEntry::AddCacheEntry(QWidget* p, const QStringList& varNames,
- const QStringList& varTypes)
- : QWidget(p), VarNames(varNames), VarTypes(varTypes)
+ const QStringList& varTypes)
+ : QWidget(p)
+ , VarNames(varNames)
+ , VarTypes(varTypes)
{
this->setupUi(this);
- for(int i=0; i<NumTypes; i++)
- {
+ for (int i = 0; i < NumTypes; i++) {
this->Type->addItem(TypeStrings[i]);
- }
+ }
QWidget* cb = new QCheckBox();
QWidget* path = new QCMakePathEditor();
QWidget* filepath = new QCMakeFilePathEditor();
@@ -46,10 +48,10 @@ AddCacheEntry::AddCacheEntry(QWidget* p, const QStringList& varNames,
this->setTabOrder(path, filepath);
this->setTabOrder(filepath, string);
this->setTabOrder(string, this->Description);
- QCompleter *completer = new QCompleter(this->VarNames, this);
+ QCompleter* completer = new QCompleter(this->VarNames, this);
this->Name->setCompleter(completer);
- connect(completer, SIGNAL(activated(const QString&)),
- this, SLOT(onCompletionActivated(const QString&)));
+ connect(completer, SIGNAL(activated(const QString&)), this,
+ SLOT(onCompletionActivated(const QString&)));
}
QString AddCacheEntry::name() const
@@ -60,14 +62,11 @@ QString AddCacheEntry::name() const
QVariant AddCacheEntry::value() const
{
QWidget* w = this->StackedWidget->currentWidget();
- if(qobject_cast<QLineEdit*>(w))
- {
+ if (qobject_cast<QLineEdit*>(w)) {
return static_cast<QLineEdit*>(w)->text();
- }
- else if(qobject_cast<QCheckBox*>(w))
- {
+ } else if (qobject_cast<QCheckBox*>(w)) {
return static_cast<QCheckBox*>(w)->isChecked();
- }
+ }
return QVariant();
}
@@ -79,36 +78,31 @@ QString AddCacheEntry::description() const
QCMakeProperty::PropertyType AddCacheEntry::type() const
{
int idx = this->Type->currentIndex();
- if(idx >= 0 && idx < NumTypes)
- {
+ if (idx >= 0 && idx < NumTypes) {
return Types[idx];
- }
+ }
return Types[DefaultTypeIndex];
}
QString AddCacheEntry::typeString() const
{
int idx = this->Type->currentIndex();
- if(idx >= 0 && idx < NumTypes)
- {
+ if (idx >= 0 && idx < NumTypes) {
return TypeStrings[idx];
- }
+ }
return TypeStrings[DefaultTypeIndex];
}
-void AddCacheEntry::onCompletionActivated(const QString &text)
+void AddCacheEntry::onCompletionActivated(const QString& text)
{
int idx = this->VarNames.indexOf(text);
- if (idx != -1)
- {
+ if (idx != -1) {
QString vartype = this->VarTypes[idx];
- for (int i = 0; i < NumTypes; i++)
- {
- if (TypeStrings[i] == vartype)
- {
- this->Type->setCurrentIndex(i);
- break;
- }
+ for (int i = 0; i < NumTypes; i++) {
+ if (TypeStrings[i] == vartype) {
+ this->Type->setCurrentIndex(i);
+ break;
}
}
+ }
}
diff --git a/Source/QtDialog/AddCacheEntry.h b/Source/QtDialog/AddCacheEntry.h
index 7c08af6..05469af 100644
--- a/Source/QtDialog/AddCacheEntry.h
+++ b/Source/QtDialog/AddCacheEntry.h
@@ -26,7 +26,7 @@ class AddCacheEntry : public QWidget, public Ui::AddCacheEntry
Q_OBJECT
public:
AddCacheEntry(QWidget* p, const QStringList& varNames,
- const QStringList& varTypes);
+ const QStringList& varTypes);
QString name() const;
QVariant value() const;
@@ -35,7 +35,7 @@ public:
QString typeString() const;
private slots:
- void onCompletionActivated(const QString &text);
+ void onCompletionActivated(const QString& text);
private:
const QStringList& VarNames;
@@ -43,4 +43,3 @@ private:
};
#endif
-
diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx
index 1e1f040..c3c1468 100644
--- a/Source/QtDialog/CMakeSetup.cxx
+++ b/Source/QtDialog/CMakeSetup.cxx
@@ -9,7 +9,7 @@
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
-#include "QCMake.h" // include to disable MS warnings
+#include "QCMake.h" // include to disable MS warnings
#include "CMakeSetupDialog.h"
#include "cmAlgorithms.h"
@@ -25,26 +25,18 @@
#include <cmsys/Encoding.hxx>
#include <cmsys/SystemTools.hxx>
-static const char * cmDocumentationName[][2] =
-{
- {0,
- " cmake-gui - CMake GUI."},
- {0,0}
-};
+static const char* cmDocumentationName[][2] = { { 0,
+ " cmake-gui - CMake GUI." },
+ { 0, 0 } };
-static const char * cmDocumentationUsage[][2] =
-{
- {0,
- " cmake-gui [options]\n"
- " cmake-gui [options] <path-to-source>\n"
- " cmake-gui [options] <path-to-existing-build>"},
- {0,0}
+static const char* cmDocumentationUsage[][2] = {
+ { 0, " cmake-gui [options]\n"
+ " cmake-gui [options] <path-to-source>\n"
+ " cmake-gui [options] <path-to-existing-build>" },
+ { 0, 0 }
};
-static const char * cmDocumentationOptions[][2] =
-{
- {0,0}
-};
+static const char* cmDocumentationOptions[][2] = { { 0, 0 } };
#if defined(Q_OS_MAC)
static int cmOSXInstall(std::string dir);
@@ -62,8 +54,7 @@ int main(int argc, char** argv)
// do docs, if args were given
cmDocumentation doc;
doc.addCMakeStandardDocSections();
- if(argc2 >1 && doc.CheckOptions(argc2, argv2))
- {
+ if (argc2 > 1 && doc.CheckOptions(argc2, argv2)) {
// Construct and print requested documentation.
cmake hcm;
hcm.SetHomeDirectory("");
@@ -73,23 +64,21 @@ int main(int argc, char** argv)
std::vector<cmDocumentationEntry> generators;
hcm.GetGeneratorDocumentation(generators);
doc.SetName("cmake");
- doc.SetSection("Name",cmDocumentationName);
- doc.SetSection("Usage",cmDocumentationUsage);
- doc.AppendSection("Generators",generators);
- doc.PrependSection("Options",cmDocumentationOptions);
+ doc.SetSection("Name", cmDocumentationName);
+ doc.SetSection("Usage", cmDocumentationUsage);
+ doc.AppendSection("Generators", generators);
+ doc.PrependSection("Options", cmDocumentationOptions);
- return (doc.PrintRequestedDocumentation(std::cout)? 0:1);
- }
+ return (doc.PrintRequestedDocumentation(std::cout) ? 0 : 1);
+ }
#if defined(Q_OS_MAC)
- if (argc2 == 2 && strcmp(argv2[1], "--install") == 0)
- {
+ if (argc2 == 2 && strcmp(argv2[1], "--install") == 0) {
return cmOSXInstall("/usr/local/bin");
- }
- if (argc2 == 2 && cmHasLiteralPrefix(argv2[1], "--install="))
- {
- return cmOSXInstall(argv2[1]+10);
- }
+ }
+ if (argc2 == 2 && cmHasLiteralPrefix(argv2[1], "--install=")) {
+ return cmOSXInstall(argv2[1] + 10);
+ }
#endif
QApplication app(argc, argv);
@@ -103,10 +92,9 @@ int main(int argc, char** argv)
// clean out standard Qt paths for plugins, which we don't use anyway
// when creating Mac bundles, it potentially causes problems
- foreach(QString p, QApplication::libraryPaths())
- {
+ foreach (QString p, QApplication::libraryPaths()) {
QApplication::removeLibraryPath(p);
- }
+ }
// tell the cmake library where cmake is
QDir cmExecDir(QApplication::applicationDirPath());
@@ -139,110 +127,92 @@ int main(int argc, char** argv)
std::string binaryDirectory;
std::string sourceDirectory;
typedef cmsys::CommandLineArguments argT;
- arg.AddArgument("-B", argT::CONCAT_ARGUMENT,
- &binaryDirectory, "Binary Directory");
- arg.AddArgument("-H", argT::CONCAT_ARGUMENT,
- &sourceDirectory, "Source Directory");
+ arg.AddArgument("-B", argT::CONCAT_ARGUMENT, &binaryDirectory,
+ "Binary Directory");
+ arg.AddArgument("-H", argT::CONCAT_ARGUMENT, &sourceDirectory,
+ "Source Directory");
// do not complain about unknown options
arg.StoreUnusedArguments(true);
arg.Parse();
- if(!sourceDirectory.empty() && !binaryDirectory.empty())
- {
+ if (!sourceDirectory.empty() && !binaryDirectory.empty()) {
dialog.setSourceDirectory(QString::fromLocal8Bit(sourceDirectory.c_str()));
dialog.setBinaryDirectory(QString::fromLocal8Bit(binaryDirectory.c_str()));
- }
- else
- {
+ } else {
QStringList args = app.arguments();
- if(args.count() == 2)
- {
- std::string filePath = cmSystemTools::CollapseFullPath(args[1].toLocal8Bit().data());
+ if (args.count() == 2) {
+ std::string filePath =
+ cmSystemTools::CollapseFullPath(args[1].toLocal8Bit().data());
// check if argument is a directory containing CMakeCache.txt
std::string buildFilePath =
cmSystemTools::CollapseFullPath("CMakeCache.txt", filePath.c_str());
// check if argument is a CMakeCache.txt file
- if(cmSystemTools::GetFilenameName(filePath) == "CMakeCache.txt" &&
- cmSystemTools::FileExists(filePath.c_str()))
- {
+ if (cmSystemTools::GetFilenameName(filePath) == "CMakeCache.txt" &&
+ cmSystemTools::FileExists(filePath.c_str())) {
buildFilePath = filePath;
- }
+ }
// check if argument is a directory containing CMakeLists.txt
std::string srcFilePath =
cmSystemTools::CollapseFullPath("CMakeLists.txt", filePath.c_str());
- if(cmSystemTools::FileExists(buildFilePath.c_str()))
- {
- dialog.setBinaryDirectory(
- QString::fromLocal8Bit(
- cmSystemTools::GetFilenamePath(buildFilePath).c_str()
- )
- );
- }
- else if(cmSystemTools::FileExists(srcFilePath.c_str()))
- {
+ if (cmSystemTools::FileExists(buildFilePath.c_str())) {
+ dialog.setBinaryDirectory(QString::fromLocal8Bit(
+ cmSystemTools::GetFilenamePath(buildFilePath).c_str()));
+ } else if (cmSystemTools::FileExists(srcFilePath.c_str())) {
dialog.setSourceDirectory(QString::fromLocal8Bit(filePath.c_str()));
- dialog.setBinaryDirectory(
- QString::fromLocal8Bit(cmSystemTools::CollapseFullPath(".").c_str())
- );
- }
+ dialog.setBinaryDirectory(QString::fromLocal8Bit(
+ cmSystemTools::CollapseFullPath(".").c_str()));
}
}
+ }
return app.exec();
}
#if defined(Q_OS_MAC)
-# include <errno.h>
-# include <string.h>
-# include <sys/stat.h>
-# include <unistd.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)
{
- if (tool.empty())
- {
+ if (tool.empty()) {
return true;
- }
+ }
std::string link = dir + cmSystemTools::GetFilenameName(tool);
struct stat st;
- if (lstat(link.c_str(), &st) == 0 && S_ISLNK(st.st_mode))
- {
+ if (lstat(link.c_str(), &st) == 0 && S_ISLNK(st.st_mode)) {
char buf[4096];
- ssize_t s = readlink(link.c_str(), buf, sizeof(buf)-1);
- if (s >= 0 && std::string(buf, s) == tool)
- {
+ ssize_t s = readlink(link.c_str(), buf, sizeof(buf) - 1);
+ if (s >= 0 && std::string(buf, s) == tool) {
std::cerr << "Exists: '" << link << "' -> '" << tool << "'\n";
return true;
- }
}
+ }
cmSystemTools::MakeDirectory(dir);
- if (symlink(tool.c_str(), link.c_str()) == 0)
- {
+ if (symlink(tool.c_str(), link.c_str()) == 0) {
std::cerr << "Linked: '" << link << "' -> '" << tool << "'\n";
return true;
- }
- else
- {
+ } else {
int err = errno;
- std::cerr << "Failed: '" << link << "' -> '" << tool << "': "
- << strerror(err) << "\n";
+ std::cerr << "Failed: '" << link << "' -> '" << tool
+ << "': " << strerror(err) << "\n";
return false;
- }
+ }
}
static int cmOSXInstall(std::string dir)
{
- if (!cmHasLiteralSuffix(dir, "/"))
- {
+ if (!cmHasLiteralSuffix(dir, "/")) {
dir += "/";
- }
- return (
- cmOSXInstall(dir, cmSystemTools::GetCMakeCommand()) &&
- cmOSXInstall(dir, cmSystemTools::GetCTestCommand()) &&
- cmOSXInstall(dir, cmSystemTools::GetCPackCommand()) &&
- cmOSXInstall(dir, cmSystemTools::GetCMakeGUICommand()) &&
- cmOSXInstall(dir, cmSystemTools::GetCMakeCursesCommand())
- ) ? 0 : 1;
+ }
+ return (cmOSXInstall(dir, cmSystemTools::GetCMakeCommand()) &&
+ cmOSXInstall(dir, cmSystemTools::GetCTestCommand()) &&
+ cmOSXInstall(dir, cmSystemTools::GetCPackCommand()) &&
+ cmOSXInstall(dir, cmSystemTools::GetCMakeGUICommand()) &&
+ cmOSXInstall(dir, cmSystemTools::GetCMakeCursesCommand()))
+ ? 0
+ : 1;
}
#endif
diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx
index 945739d..712611d 100644
--- a/Source/QtDialog/CMakeSetupDialog.cxx
+++ b/Source/QtDialog/CMakeSetupDialog.cxx
@@ -40,7 +40,8 @@
#include "cmVersion.h"
QCMakeThread::QCMakeThread(QObject* p)
- : QThread(p), CMakeInstance(NULL)
+ : QThread(p)
+ , CMakeInstance(NULL)
{
}
@@ -60,7 +61,10 @@ void QCMakeThread::run()
}
CMakeSetupDialog::CMakeSetupDialog()
- : ExitAfterGenerate(true), CacheModified(false), ConfigureNeeded(true), CurrentState(Interrupting)
+ : ExitAfterGenerate(true)
+ , CacheModified(false)
+ , ConfigureNeeded(true)
+ , CurrentState(Interrupting)
{
QString title = QString(tr("CMake %1"));
title = title.arg(cmVersion::GetCMakeVersion());
@@ -72,10 +76,11 @@ CMakeSetupDialog::CMakeSetupDialog()
restoreGeometry(settings.value("geometry").toByteArray());
restoreState(settings.value("windowState").toByteArray());
- this->AddVariableNames = settings.value("AddVariableNames",
- QStringList("CMAKE_INSTALL_PREFIX")).toStringList();
- this->AddVariableTypes = settings.value("AddVariableTypes",
- QStringList("PATH")).toStringList();
+ this->AddVariableNames =
+ settings.value("AddVariableNames", QStringList("CMAKE_INSTALL_PREFIX"))
+ .toStringList();
+ this->AddVariableTypes =
+ settings.value("AddVariableTypes", QStringList("PATH")).toStringList();
QWidget* cont = new QWidget(this);
this->setupUi(cont);
@@ -95,60 +100,57 @@ CMakeSetupDialog::CMakeSetupDialog()
bool advancedView = settings.value("AdvancedView", false).toBool();
this->setAdvancedView(advancedView);
- this->advancedCheck->setCheckState(advancedView?Qt::Checked : Qt::Unchecked);
+ this->advancedCheck->setCheckState(advancedView ? Qt::Checked
+ : Qt::Unchecked);
QMenu* FileMenu = this->menuBar()->addMenu(tr("&File"));
this->ReloadCacheAction = FileMenu->addAction(tr("&Reload Cache"));
- QObject::connect(this->ReloadCacheAction, SIGNAL(triggered(bool)),
- this, SLOT(doReloadCache()));
+ QObject::connect(this->ReloadCacheAction, SIGNAL(triggered(bool)), this,
+ SLOT(doReloadCache()));
this->DeleteCacheAction = FileMenu->addAction(tr("&Delete Cache"));
- QObject::connect(this->DeleteCacheAction, SIGNAL(triggered(bool)),
- this, SLOT(doDeleteCache()));
+ QObject::connect(this->DeleteCacheAction, SIGNAL(triggered(bool)), this,
+ SLOT(doDeleteCache()));
this->ExitAction = FileMenu->addAction(tr("E&xit"));
this->ExitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
- QObject::connect(this->ExitAction, SIGNAL(triggered(bool)),
- this, SLOT(close()));
+ QObject::connect(this->ExitAction, SIGNAL(triggered(bool)), this,
+ SLOT(close()));
QMenu* ToolsMenu = this->menuBar()->addMenu(tr("&Tools"));
this->ConfigureAction = ToolsMenu->addAction(tr("&Configure"));
// prevent merging with Preferences menu item on Mac OS X
this->ConfigureAction->setMenuRole(QAction::NoRole);
- QObject::connect(this->ConfigureAction, SIGNAL(triggered(bool)),
- this, SLOT(doConfigure()));
+ QObject::connect(this->ConfigureAction, SIGNAL(triggered(bool)), this,
+ SLOT(doConfigure()));
this->GenerateAction = ToolsMenu->addAction(tr("&Generate"));
- QObject::connect(this->GenerateAction, SIGNAL(triggered(bool)),
- this, SLOT(doGenerate()));
+ QObject::connect(this->GenerateAction, SIGNAL(triggered(bool)), this,
+ SLOT(doGenerate()));
QAction* showChangesAction = ToolsMenu->addAction(tr("&Show My Changes"));
- QObject::connect(showChangesAction, SIGNAL(triggered(bool)),
- this, SLOT(showUserChanges()));
+ QObject::connect(showChangesAction, SIGNAL(triggered(bool)), this,
+ SLOT(showUserChanges()));
#if defined(Q_WS_MAC) || defined(Q_OS_MAC)
- this->InstallForCommandLineAction
- = ToolsMenu->addAction(tr("&How to Install For Command Line Use"));
+ this->InstallForCommandLineAction =
+ ToolsMenu->addAction(tr("&How to Install For Command Line Use"));
QObject::connect(this->InstallForCommandLineAction, SIGNAL(triggered(bool)),
this, SLOT(doInstallForCommandLine()));
#endif
ToolsMenu->addSeparator();
- ToolsMenu->addAction(tr("Regular Expression Explorer..."),
- this, SLOT(doRegexExplorerDialog()));
+ ToolsMenu->addAction(tr("Regular Expression Explorer..."), this,
+ SLOT(doRegexExplorerDialog()));
ToolsMenu->addSeparator();
- ToolsMenu->addAction(tr("&Find in Output..."),
- this, SLOT(doOutputFindDialog()),
- QKeySequence::Find);
- ToolsMenu->addAction(tr("Find Next"),
- this, SLOT(doOutputFindNext()),
+ ToolsMenu->addAction(tr("&Find in Output..."), this,
+ SLOT(doOutputFindDialog()), QKeySequence::Find);
+ ToolsMenu->addAction(tr("Find Next"), this, SLOT(doOutputFindNext()),
QKeySequence::FindNext);
- ToolsMenu->addAction(tr("Find Previous"),
- this, SLOT(doOutputFindPrev()),
+ ToolsMenu->addAction(tr("Find Previous"), this, SLOT(doOutputFindPrev()),
QKeySequence::FindPrevious);
- ToolsMenu->addAction(tr("Goto Next Error"),
- this, SLOT(doOutputErrorNext()),
- QKeySequence(Qt::Key_F8)); // in Visual Studio
- new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Period),
- this, SLOT(doOutputErrorNext())); // in Eclipse
+ ToolsMenu->addAction(tr("Goto Next Error"), this, SLOT(doOutputErrorNext()),
+ QKeySequence(Qt::Key_F8)); // in Visual Studio
+ new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Period), this,
+ SLOT(doOutputErrorNext())); // in Eclipse
QMenu* OptionsMenu = this->menuBar()->addMenu(tr("&Options"));
- OptionsMenu->addAction(tr("Warning Messages..."),
- this, SLOT(doWarningMessagesDialog()));
+ OptionsMenu->addAction(tr("Warning Messages..."), this,
+ SLOT(doWarningMessagesDialog()));
this->WarnUninitializedAction =
OptionsMenu->addAction(tr("&Warn Uninitialized (--warn-uninitialized)"));
this->WarnUninitializedAction->setCheckable(true);
@@ -158,24 +160,24 @@ CMakeSetupDialog::CMakeSetupDialog()
QAction* debugAction = OptionsMenu->addAction(tr("&Debug Output"));
debugAction->setCheckable(true);
- QObject::connect(debugAction, SIGNAL(toggled(bool)),
- this, SLOT(setDebugOutput(bool)));
+ QObject::connect(debugAction, SIGNAL(toggled(bool)), this,
+ SLOT(setDebugOutput(bool)));
OptionsMenu->addSeparator();
- QAction* expandAction = OptionsMenu->addAction(tr("&Expand Grouped Entries"));
- QObject::connect(expandAction, SIGNAL(triggered(bool)),
- this->CacheValues, SLOT(expandAll()));
- QAction* collapseAction = OptionsMenu->addAction(tr("&Collapse Grouped Entries"));
- QObject::connect(collapseAction, SIGNAL(triggered(bool)),
- this->CacheValues, SLOT(collapseAll()));
+ QAction* expandAction =
+ OptionsMenu->addAction(tr("&Expand Grouped Entries"));
+ QObject::connect(expandAction, SIGNAL(triggered(bool)), this->CacheValues,
+ SLOT(expandAll()));
+ QAction* collapseAction =
+ OptionsMenu->addAction(tr("&Collapse Grouped Entries"));
+ QObject::connect(collapseAction, SIGNAL(triggered(bool)), this->CacheValues,
+ SLOT(collapseAll()));
QMenu* HelpMenu = this->menuBar()->addMenu(tr("&Help"));
QAction* a = HelpMenu->addAction(tr("About"));
- QObject::connect(a, SIGNAL(triggered(bool)),
- this, SLOT(doAbout()));
+ QObject::connect(a, SIGNAL(triggered(bool)), this, SLOT(doAbout()));
a = HelpMenu->addAction(tr("Help"));
- QObject::connect(a, SIGNAL(triggered(bool)),
- this, SLOT(doHelp()));
+ QObject::connect(a, SIGNAL(triggered(bool)), this, SLOT(doHelp()));
this->setAcceptDrops(true);
@@ -193,12 +195,12 @@ CMakeSetupDialog::CMakeSetupDialog()
this->Output->setContextMenuPolicy(Qt::CustomContextMenu);
connect(this->Output, SIGNAL(customContextMenuRequested(const QPoint&)),
- this, SLOT(doOutputContextMenu(const QPoint &)));
+ this, SLOT(doOutputContextMenu(const QPoint&)));
// start the cmake worker thread
this->CMakeThread = new QCMakeThread(this);
- QObject::connect(this->CMakeThread, SIGNAL(cmakeInitialized()),
- this, SLOT(initialize()), Qt::QueuedConnection);
+ QObject::connect(this->CMakeThread, SIGNAL(cmakeInitialized()), this,
+ SLOT(initialize()), Qt::QueuedConnection);
this->CMakeThread->start();
this->enterState(ReadyConfigure);
@@ -211,20 +213,20 @@ void CMakeSetupDialog::initialize()
{
// now the cmake worker thread is running, lets make our connections to it
QObject::connect(this->CMakeThread->cmakeInstance(),
- SIGNAL(propertiesChanged(const QCMakePropertyList&)),
- this->CacheValues->cacheModel(),
- SLOT(setProperties(const QCMakePropertyList&)));
+ SIGNAL(propertiesChanged(const QCMakePropertyList&)),
+ this->CacheValues->cacheModel(),
+ SLOT(setProperties(const QCMakePropertyList&)));
- QObject::connect(this->ConfigureButton, SIGNAL(clicked(bool)),
- this, SLOT(doConfigure()));
+ QObject::connect(this->ConfigureButton, SIGNAL(clicked(bool)), this,
+ SLOT(doConfigure()));
- QObject::connect(this->CMakeThread->cmakeInstance(), SIGNAL(configureDone(int)),
- this, SLOT(exitLoop(int)));
- QObject::connect(this->CMakeThread->cmakeInstance(), SIGNAL(generateDone(int)),
- this, SLOT(exitLoop(int)));
+ QObject::connect(this->CMakeThread->cmakeInstance(),
+ SIGNAL(configureDone(int)), this, SLOT(exitLoop(int)));
+ QObject::connect(this->CMakeThread->cmakeInstance(),
+ SIGNAL(generateDone(int)), this, SLOT(exitLoop(int)));
- QObject::connect(this->GenerateButton, SIGNAL(clicked(bool)),
- this, SLOT(doGenerate()));
+ QObject::connect(this->GenerateButton, SIGNAL(clicked(bool)), this,
+ SLOT(doGenerate()));
QObject::connect(this->BrowseSourceDirectoryButton, SIGNAL(clicked(bool)),
this, SLOT(doSourceBrowse()));
@@ -233,51 +235,50 @@ void CMakeSetupDialog::initialize()
QObject::connect(this->BinaryDirectory, SIGNAL(editTextChanged(QString)),
this, SLOT(onBinaryDirectoryChanged(QString)));
- QObject::connect(this->SourceDirectory, SIGNAL(textChanged(QString)),
- this, SLOT(onSourceDirectoryChanged(QString)));
+ QObject::connect(this->SourceDirectory, SIGNAL(textChanged(QString)), this,
+ SLOT(onSourceDirectoryChanged(QString)));
QObject::connect(this->CMakeThread->cmakeInstance(),
- SIGNAL(sourceDirChanged(QString)),
- this, SLOT(updateSourceDirectory(QString)));
+ SIGNAL(sourceDirChanged(QString)), this,
+ SLOT(updateSourceDirectory(QString)));
QObject::connect(this->CMakeThread->cmakeInstance(),
- SIGNAL(binaryDirChanged(QString)),
- this, SLOT(updateBinaryDirectory(QString)));
+ SIGNAL(binaryDirChanged(QString)), this,
+ SLOT(updateBinaryDirectory(QString)));
QObject::connect(this->CMakeThread->cmakeInstance(),
- SIGNAL(progressChanged(QString, float)),
- this, SLOT(showProgress(QString,float)));
+ SIGNAL(progressChanged(QString, float)), this,
+ SLOT(showProgress(QString, float)));
QObject::connect(this->CMakeThread->cmakeInstance(),
- SIGNAL(errorMessage(QString)),
- this, SLOT(error(QString)));
+ SIGNAL(errorMessage(QString)), this, SLOT(error(QString)));
QObject::connect(this->CMakeThread->cmakeInstance(),
- SIGNAL(outputMessage(QString)),
- this, SLOT(message(QString)));
+ SIGNAL(outputMessage(QString)), this,
+ SLOT(message(QString)));
- QObject::connect(this->groupedCheck, SIGNAL(toggled(bool)),
- this, SLOT(setGroupedView(bool)));
- QObject::connect(this->advancedCheck, SIGNAL(toggled(bool)),
- this, SLOT(setAdvancedView(bool)));
- QObject::connect(this->Search, SIGNAL(textChanged(QString)),
- this, SLOT(setSearchFilter(QString)));
+ QObject::connect(this->groupedCheck, SIGNAL(toggled(bool)), this,
+ SLOT(setGroupedView(bool)));
+ QObject::connect(this->advancedCheck, SIGNAL(toggled(bool)), this,
+ SLOT(setAdvancedView(bool)));
+ QObject::connect(this->Search, SIGNAL(textChanged(QString)), this,
+ SLOT(setSearchFilter(QString)));
QObject::connect(this->CMakeThread->cmakeInstance(),
- SIGNAL(generatorChanged(QString)),
- this, SLOT(updateGeneratorLabel(QString)));
+ SIGNAL(generatorChanged(QString)), this,
+ SLOT(updateGeneratorLabel(QString)));
this->updateGeneratorLabel(QString());
QObject::connect(this->CacheValues->cacheModel(),
- SIGNAL(dataChanged(QModelIndex,QModelIndex)),
- this, SLOT(setCacheModified()));
+ SIGNAL(dataChanged(QModelIndex, QModelIndex)), this,
+ SLOT(setCacheModified()));
QObject::connect(this->CacheValues->selectionModel(),
- SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
+ SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
this, SLOT(selectionChanged()));
- QObject::connect(this->RemoveEntry, SIGNAL(clicked(bool)),
- this, SLOT(removeSelectedCacheEntries()));
- QObject::connect(this->AddEntry, SIGNAL(clicked(bool)),
- this, SLOT(addCacheEntry()));
+ QObject::connect(this->RemoveEntry, SIGNAL(clicked(bool)), this,
+ SLOT(removeSelectedCacheEntries()));
+ QObject::connect(this->AddEntry, SIGNAL(clicked(bool)), this,
+ SLOT(addCacheEntry()));
QObject::connect(this->WarnUninitializedAction, SIGNAL(triggered(bool)),
this->CMakeThread->cmakeInstance(),
@@ -286,16 +287,13 @@ void CMakeSetupDialog::initialize()
this->CMakeThread->cmakeInstance(),
SLOT(setWarnUnusedMode(bool)));
- if(!this->SourceDirectory->text().isEmpty() ||
- !this->BinaryDirectory->lineEdit()->text().isEmpty())
- {
+ if (!this->SourceDirectory->text().isEmpty() ||
+ !this->BinaryDirectory->lineEdit()->text().isEmpty()) {
this->onSourceDirectoryChanged(this->SourceDirectory->text());
this->onBinaryDirectoryChanged(this->BinaryDirectory->lineEdit()->text());
- }
- else
- {
+ } else {
this->onBinaryDirectoryChanged(this->BinaryDirectory->lineEdit()->text());
- }
+ }
}
CMakeSetupDialog::~CMakeSetupDialog()
@@ -316,38 +314,34 @@ bool CMakeSetupDialog::prepareConfigure()
// make sure build directory exists
QString bindir = this->CMakeThread->cmakeInstance()->binaryDirectory();
QDir dir(bindir);
- if(!dir.exists())
- {
+ if (!dir.exists()) {
QString msg = tr("Build directory does not exist, "
- "should I create it?\n\n"
- "Directory: ");
+ "should I create it?\n\n"
+ "Directory: ");
msg += bindir;
QString title = tr("Create Directory");
QMessageBox::StandardButton btn;
btn = QMessageBox::information(this, title, msg,
QMessageBox::Yes | QMessageBox::No);
- if(btn == QMessageBox::No)
- {
+ if (btn == QMessageBox::No) {
return false;
- }
- if(!dir.mkpath("."))
- {
- QMessageBox::information(this, tr("Create Directory Failed"),
+ }
+ if (!dir.mkpath(".")) {
+ QMessageBox::information(
+ this, tr("Create Directory Failed"),
QString(tr("Failed to create directory %1")).arg(dir.path()),
QMessageBox::Ok);
return false;
- }
}
+ }
// if no generator, prompt for it and other setup stuff
- if(this->CMakeThread->cmakeInstance()->generator().isEmpty())
- {
- if(!this->setupFirstConfigure())
- {
+ if (this->CMakeThread->cmakeInstance()->generator().isEmpty()) {
+ if (!this->setupFirstConfigure()) {
return false;
- }
}
+ }
// remember path
this->addBinaryPath(dir.absolutePath());
@@ -362,36 +356,30 @@ void CMakeSetupDialog::exitLoop(int err)
void CMakeSetupDialog::doConfigure()
{
- if(this->CurrentState == Configuring)
- {
+ if (this->CurrentState == Configuring) {
// stop configure
doInterrupt();
return;
- }
+ }
- if(!prepareConfigure())
- {
+ if (!prepareConfigure()) {
return;
- }
+ }
this->enterState(Configuring);
bool ret = doConfigureInternal();
- if(ret)
- {
+ if (ret) {
this->ConfigureNeeded = false;
- }
+ }
- if(ret && !this->CacheValues->cacheModel()->newPropertyCount())
- {
+ if (ret && !this->CacheValues->cacheModel()->newPropertyCount()) {
this->enterState(ReadyGenerate);
- }
- else
- {
+ } else {
this->enterState(ReadyConfigure);
this->CacheValues->scrollToTop();
- }
+ }
this->ProgressBar->reset();
}
@@ -400,21 +388,20 @@ bool CMakeSetupDialog::doConfigureInternal()
this->Output->clear();
this->CacheValues->selectionModel()->clear();
- QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(),
- "setProperties", Qt::QueuedConnection,
- Q_ARG(QCMakePropertyList,
- this->CacheValues->cacheModel()->properties()));
- QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(),
- "configure", Qt::QueuedConnection);
+ QMetaObject::invokeMethod(
+ this->CMakeThread->cmakeInstance(), "setProperties", Qt::QueuedConnection,
+ Q_ARG(QCMakePropertyList, this->CacheValues->cacheModel()->properties()));
+ QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(), "configure",
+ Qt::QueuedConnection);
int err = this->LocalLoop.exec();
- if(err != 0)
- {
- QMessageBox::critical(this, tr("Error"),
+ if (err != 0) {
+ QMessageBox::critical(
+ this, tr("Error"),
tr("Error in configuration process, project files may be invalid"),
QMessageBox::Ok);
- }
+ }
return 0 == err;
}
@@ -422,21 +409,19 @@ bool CMakeSetupDialog::doConfigureInternal()
void CMakeSetupDialog::doInstallForCommandLine()
{
QString title = tr("How to Install For Command Line Use");
- QString msg = tr(
- "One may add CMake to the PATH:\n"
- "\n"
- " PATH=\"%1\":\"$PATH\"\n"
- "\n"
- "Or, to install symlinks to '/usr/local/bin', run:\n"
- "\n"
- " sudo \"%2\" --install\n"
- "\n"
- "Or, to install symlinks to another directory, run:\n"
- "\n"
- " sudo \"%3\" --install=/path/to/bin\n"
- );
- msg = msg.arg(cmSystemTools::GetFilenamePath(
- cmSystemTools::GetCMakeCommand()).c_str());
+ QString msg = tr("One may add CMake to the PATH:\n"
+ "\n"
+ " PATH=\"%1\":\"$PATH\"\n"
+ "\n"
+ "Or, to install symlinks to '/usr/local/bin', run:\n"
+ "\n"
+ " sudo \"%2\" --install\n"
+ "\n"
+ "Or, to install symlinks to another directory, run:\n"
+ "\n"
+ " sudo \"%3\" --install=/path/to/bin\n");
+ msg = msg.arg(
+ cmSystemTools::GetFilenamePath(cmSystemTools::GetCMakeCommand()).c_str());
msg = msg.arg(cmSystemTools::GetCMakeGUICommand().c_str());
msg = msg.arg(cmSystemTools::GetCMakeGUICommand().c_str());
@@ -448,8 +433,8 @@ void CMakeSetupDialog::doInstallForCommandLine()
lab->setText(msg);
lab->setWordWrap(false);
lab->setTextInteractionFlags(Qt::TextSelectableByMouse);
- QDialogButtonBox* btns = new QDialogButtonBox(QDialogButtonBox::Ok,
- Qt::Horizontal, &dialog);
+ QDialogButtonBox* btns =
+ new QDialogButtonBox(QDialogButtonBox::Ok, Qt::Horizontal, &dialog);
QObject::connect(btns, SIGNAL(accepted()), &dialog, SLOT(accept()));
l->addWidget(btns);
dialog.exec();
@@ -457,57 +442,52 @@ void CMakeSetupDialog::doInstallForCommandLine()
bool CMakeSetupDialog::doGenerateInternal()
{
- QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(),
- "generate", Qt::QueuedConnection);
+ QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(), "generate",
+ Qt::QueuedConnection);
int err = this->LocalLoop.exec();
- if(err != 0)
- {
- QMessageBox::critical(this, tr("Error"),
+ if (err != 0) {
+ QMessageBox::critical(
+ this, tr("Error"),
tr("Error in generation process, project files may be invalid"),
QMessageBox::Ok);
- }
+ }
return 0 == err;
}
void CMakeSetupDialog::doGenerate()
{
- if(this->CurrentState == Generating)
- {
+ if (this->CurrentState == Generating) {
// stop generate
doInterrupt();
return;
- }
+ }
// see if we need to configure
// we'll need to configure if:
// the configure step hasn't been done yet
// generate was the last step done
- if(this->ConfigureNeeded)
- {
- if(!prepareConfigure())
- {
+ if (this->ConfigureNeeded) {
+ if (!prepareConfigure()) {
return;
- }
}
+ }
this->enterState(Generating);
bool config_passed = true;
- if(this->ConfigureNeeded)
- {
+ if (this->ConfigureNeeded) {
this->CacheValues->cacheModel()->setShowNewProperties(false);
this->ProgressFactor = 0.5;
config_passed = doConfigureInternal();
this->ProgressOffset = 0.5;
- }
+ }
- if(config_passed)
- {
+ if (config_passed) {
doGenerateInternal();
- }
+ }
this->ProgressOffset = 0.0;
this->ProgressFactor = 1.0;
@@ -522,78 +502,83 @@ void CMakeSetupDialog::doGenerate()
void CMakeSetupDialog::closeEvent(QCloseEvent* e)
{
// prompt for close if there are unsaved changes, and we're not busy
- if(this->CacheModified)
- {
+ if (this->CacheModified) {
QString msg = tr("You have changed options but not rebuilt, "
- "are you sure you want to exit?");
+ "are you sure you want to exit?");
QString title = tr("Confirm Exit");
QMessageBox::StandardButton btn;
btn = QMessageBox::critical(this, title, msg,
QMessageBox::Yes | QMessageBox::No);
- if(btn == QMessageBox::No)
- {
+ if (btn == QMessageBox::No) {
e->ignore();
- }
}
+ }
// don't close if we're busy, unless the user really wants to
- if(this->CurrentState == Configuring)
- {
- QString msg = tr("You are in the middle of a Configure.\n"
- "If you Exit now the configure information will be lost.\n"
- "Are you sure you want to Exit?");
+ if (this->CurrentState == Configuring) {
+ QString msg =
+ tr("You are in the middle of a Configure.\n"
+ "If you Exit now the configure information will be lost.\n"
+ "Are you sure you want to Exit?");
QString title = tr("Confirm Exit");
QMessageBox::StandardButton btn;
btn = QMessageBox::critical(this, title, msg,
QMessageBox::Yes | QMessageBox::No);
- if(btn == QMessageBox::No)
- {
+ if (btn == QMessageBox::No) {
e->ignore();
- }
- else
- {
+ } else {
this->doInterrupt();
- }
}
+ }
// let the generate finish
- if(this->CurrentState == Generating)
- {
+ if (this->CurrentState == Generating) {
e->ignore();
- }
+ }
}
void CMakeSetupDialog::doHelp()
{
- QString msg = tr("CMake is used to configure and generate build files for "
+ QString msg = tr(
+ "CMake is used to configure and generate build files for "
"software projects. The basic steps for configuring a project are as "
- "follows:\r\n\r\n1. Select the source directory for the project. This should "
- "contain the CMakeLists.txt files for the project.\r\n\r\n2. Select the build "
- "directory for the project. This is the directory where the project will be "
+ "follows:\r\n\r\n1. Select the source directory for the project. This "
+ "should "
+ "contain the CMakeLists.txt files for the project.\r\n\r\n2. Select the "
+ "build "
+ "directory for the project. This is the directory where the project "
+ "will be "
"built. It can be the same or a different directory than the source "
- "directory. For easy clean up, a separate build directory is recommended. "
+ "directory. For easy clean up, a separate build directory is "
+ "recommended. "
"CMake will create the directory if it does not exist.\r\n\r\n3. Once the "
"source and binary directories are selected, it is time to press the "
- "Configure button. This will cause CMake to read all of the input files and "
- "discover all the variables used by the project. The first time a variable "
- "is displayed it will be in Red. Users should inspect red variables making "
- "sure the values are correct. For some projects the Configure process can "
- "be iterative, so continue to press the Configure button until there are no "
+ "Configure button. This will cause CMake to read all of the input files "
+ "and "
+ "discover all the variables used by the project. The first time a "
+ "variable "
+ "is displayed it will be in Red. Users should inspect red variables "
+ "making "
+ "sure the values are correct. For some projects the Configure process "
+ "can "
+ "be iterative, so continue to press the Configure button until there are "
+ "no "
"longer red entries.\r\n\r\n4. Once there are no longer red entries, you "
- "should click the Generate button. This will write the build files to the build "
+ "should click the Generate button. This will write the build files to "
+ "the build "
"directory.");
QDialog dialog;
QFontMetrics met(this->font());
int msgWidth = met.width(msg);
- dialog.setMinimumSize(msgWidth/15,20);
+ dialog.setMinimumSize(msgWidth / 15, 20);
dialog.setWindowTitle(tr("Help"));
QVBoxLayout* l = new QVBoxLayout(&dialog);
QLabel* lab = new QLabel(&dialog);
lab->setText(msg);
lab->setWordWrap(true);
- QDialogButtonBox* btns = new QDialogButtonBox(QDialogButtonBox::Ok,
- Qt::Horizontal, &dialog);
+ QDialogButtonBox* btns =
+ new QDialogButtonBox(QDialogButtonBox::Ok, Qt::Horizontal, &dialog);
QObject::connect(btns, SIGNAL(accepted()), &dialog, SLOT(accept()));
l->addWidget(lab);
l->addWidget(btns);
@@ -608,44 +593,40 @@ void CMakeSetupDialog::doInterrupt()
void CMakeSetupDialog::doSourceBrowse()
{
- QString dir = QFileDialog::getExistingDirectory(this,
- tr("Enter Path to Source"), this->SourceDirectory->text(),
+ QString dir = QFileDialog::getExistingDirectory(
+ this, tr("Enter Path to Source"), this->SourceDirectory->text(),
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
- if(!dir.isEmpty())
- {
+ if (!dir.isEmpty()) {
this->setSourceDirectory(dir);
- }
+ }
}
void CMakeSetupDialog::updateSourceDirectory(const QString& dir)
{
- if(this->SourceDirectory->text() != dir)
- {
+ if (this->SourceDirectory->text() != dir) {
this->SourceDirectory->blockSignals(true);
this->SourceDirectory->setText(dir);
this->SourceDirectory->blockSignals(false);
- }
+ }
}
void CMakeSetupDialog::updateBinaryDirectory(const QString& dir)
{
- if(this->BinaryDirectory->currentText() != dir)
- {
+ if (this->BinaryDirectory->currentText() != dir) {
this->BinaryDirectory->blockSignals(true);
this->BinaryDirectory->setEditText(dir);
this->BinaryDirectory->blockSignals(false);
- }
+ }
}
void CMakeSetupDialog::doBinaryBrowse()
{
- QString dir = QFileDialog::getExistingDirectory(this,
- tr("Enter Path to Build"), this->BinaryDirectory->currentText(),
+ QString dir = QFileDialog::getExistingDirectory(
+ this, tr("Enter Path to Build"), this->BinaryDirectory->currentText(),
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
- if(!dir.isEmpty() && dir != this->BinaryDirectory->currentText())
- {
+ if (!dir.isEmpty() && dir != this->BinaryDirectory->currentText()) {
this->setBinaryDirectory(dir);
- }
+ }
}
void CMakeSetupDialog::setBinaryDirectory(const QString& dir)
@@ -657,7 +638,8 @@ void CMakeSetupDialog::onSourceDirectoryChanged(const QString& dir)
{
this->Output->clear();
QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(),
- "setSourceDirectory", Qt::QueuedConnection, Q_ARG(QString, dir));
+ "setSourceDirectory", Qt::QueuedConnection,
+ Q_ARG(QString, dir));
}
void CMakeSetupDialog::onBinaryDirectoryChanged(const QString& dir)
@@ -669,10 +651,12 @@ void CMakeSetupDialog::onBinaryDirectoryChanged(const QString& dir)
this->CacheModified = false;
this->CacheValues->cacheModel()->clear();
- qobject_cast<QCMakeCacheModelDelegate*>(this->CacheValues->itemDelegate())->clearChanges();
+ qobject_cast<QCMakeCacheModelDelegate*>(this->CacheValues->itemDelegate())
+ ->clearChanges();
this->Output->clear();
QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(),
- "setBinaryDirectory", Qt::QueuedConnection, Q_ARG(QString, dir));
+ "setBinaryDirectory", Qt::QueuedConnection,
+ Q_ARG(QString, dir));
}
void CMakeSetupDialog::setSourceDirectory(const QString& dir)
@@ -689,13 +673,14 @@ void CMakeSetupDialog::showProgress(const QString& /*msg*/, float percent)
void CMakeSetupDialog::error(const QString& msg)
{
this->Output->setCurrentCharFormat(this->ErrorFormat);
- //QTextEdit will terminate the msg with a ParagraphSeparator, but it also replaces
- //all newlines with ParagraphSeparators. By replacing the newlines by ourself, one
- //error msg will be one paragraph.
+ // QTextEdit will terminate the msg with a ParagraphSeparator, but it also
+ // replaces
+ // all newlines with ParagraphSeparators. By replacing the newlines by
+ // ourself, one
+ // error msg will be one paragraph.
QString paragraph(msg);
paragraph.replace(QLatin1Char('\n'), QChar::LineSeparator);
this->Output->append(paragraph);
-
}
void CMakeSetupDialog::message(const QString& msg)
@@ -717,7 +702,7 @@ void CMakeSetupDialog::setEnabledState(bool enabled)
this->ExitAction->setEnabled(enabled);
this->ConfigureAction->setEnabled(enabled);
this->AddEntry->setEnabled(enabled);
- this->RemoveEntry->setEnabled(false); // let selection re-enable it
+ this->RemoveEntry->setEnabled(false); // let selection re-enable it
}
bool CMakeSetupDialog::setupFirstConfigure()
@@ -727,58 +712,54 @@ bool CMakeSetupDialog::setupFirstConfigure()
// initialize dialog and restore saved settings
// add generators
- dialog.setGenerators(this->CMakeThread->cmakeInstance()->availableGenerators());
+ dialog.setGenerators(
+ this->CMakeThread->cmakeInstance()->availableGenerators());
// restore from settings
dialog.loadFromSettings();
- if(dialog.exec() == QDialog::Accepted)
- {
+ if (dialog.exec() == QDialog::Accepted) {
dialog.saveToSettings();
this->CMakeThread->cmakeInstance()->setGenerator(dialog.getGenerator());
this->CMakeThread->cmakeInstance()->setToolset(dialog.getToolset());
QCMakeCacheModel* m = this->CacheValues->cacheModel();
- if(dialog.compilerSetup())
- {
+ if (dialog.compilerSetup()) {
QString fortranCompiler = dialog.getFortranCompiler();
- if(!fortranCompiler.isEmpty())
- {
+ if (!fortranCompiler.isEmpty()) {
m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_Fortran_COMPILER",
"Fortran compiler.", fortranCompiler, false);
- }
+ }
QString cxxCompiler = dialog.getCXXCompiler();
- if(!cxxCompiler.isEmpty())
- {
+ if (!cxxCompiler.isEmpty()) {
m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_CXX_COMPILER",
"CXX compiler.", cxxCompiler, false);
- }
+ }
QString cCompiler = dialog.getCCompiler();
- if(!cCompiler.isEmpty())
- {
+ if (!cCompiler.isEmpty()) {
m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_C_COMPILER",
"C compiler.", cCompiler, false);
- }
}
- else if(dialog.crossCompilerSetup())
- {
+ } else if (dialog.crossCompilerSetup()) {
QString fortranCompiler = dialog.getFortranCompiler();
- if(!fortranCompiler.isEmpty())
- {
+ if (!fortranCompiler.isEmpty()) {
m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_Fortran_COMPILER",
"Fortran compiler.", fortranCompiler, false);
- }
+ }
QString mode = dialog.getCrossIncludeMode();
- m->insertProperty(QCMakeProperty::STRING, "CMAKE_FIND_ROOT_PATH_MODE_INCLUDE",
+ m->insertProperty(QCMakeProperty::STRING,
+ "CMAKE_FIND_ROOT_PATH_MODE_INCLUDE",
tr("CMake Find Include Mode"), mode, false);
mode = dialog.getCrossLibraryMode();
- m->insertProperty(QCMakeProperty::STRING, "CMAKE_FIND_ROOT_PATH_MODE_LIBRARY",
+ m->insertProperty(QCMakeProperty::STRING,
+ "CMAKE_FIND_ROOT_PATH_MODE_LIBRARY",
tr("CMake Find Library Mode"), mode, false);
mode = dialog.getCrossProgramMode();
- m->insertProperty(QCMakeProperty::STRING, "CMAKE_FIND_ROOT_PATH_MODE_PROGRAM",
+ m->insertProperty(QCMakeProperty::STRING,
+ "CMAKE_FIND_ROOT_PATH_MODE_PROGRAM",
tr("CMake Find Program Mode"), mode, false);
QString rootPath = dialog.getCrossRoot();
@@ -797,15 +778,14 @@ bool CMakeSetupDialog::setupFirstConfigure()
QString cCompiler = dialog.getCCompiler();
m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_C_COMPILER",
tr("C compiler."), cCompiler, false);
- }
- else if(dialog.crossCompilerToolChainFile())
- {
+ } else if (dialog.crossCompilerToolChainFile()) {
QString toolchainFile = dialog.getCrossCompilerToolChainFile();
m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_TOOLCHAIN_FILE",
- tr("Cross Compile ToolChain File"), toolchainFile, false);
- }
- return true;
+ tr("Cross Compile ToolChain File"), toolchainFile,
+ false);
}
+ return true;
+ }
return false;
}
@@ -813,21 +793,18 @@ bool CMakeSetupDialog::setupFirstConfigure()
void CMakeSetupDialog::updateGeneratorLabel(const QString& gen)
{
QString str = tr("Current Generator: ");
- if(gen.isEmpty())
- {
+ if (gen.isEmpty()) {
str += tr("None");
- }
- else
- {
+ } else {
str += gen;
- }
+ }
this->Generator->setText(str);
}
void CMakeSetupDialog::doReloadCache()
{
- QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(),
- "reloadCache", Qt::QueuedConnection);
+ QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(), "reloadCache",
+ Qt::QueuedConnection);
}
void CMakeSetupDialog::doDeleteCache()
@@ -837,12 +814,11 @@ void CMakeSetupDialog::doDeleteCache()
QMessageBox::StandardButton btn;
btn = QMessageBox::information(this, title, msg,
QMessageBox::Yes | QMessageBox::No);
- if(btn == QMessageBox::No)
- {
+ if (btn == QMessageBox::No) {
return;
- }
- QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(),
- "deleteCache", Qt::QueuedConnection);
+ }
+ QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(), "deleteCache",
+ Qt::QueuedConnection);
}
void CMakeSetupDialog::doAbout()
@@ -864,7 +840,7 @@ void CMakeSetupDialog::doAbout()
msg = msg.arg(cmVersion::GetCMakeVersion());
msg = msg.arg(qVersion());
#ifdef CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL
- std::string lgpl = cmSystemTools::GetCMakeRoot()+"/Licenses/LGPLv2.1.txt";
+ std::string lgpl = cmSystemTools::GetCMakeRoot() + "/Licenses/LGPLv2.1.txt";
msg = msg.arg(lgpl.c_str());
#endif
@@ -875,8 +851,8 @@ void CMakeSetupDialog::doAbout()
l->addWidget(lab);
lab->setText(msg);
lab->setWordWrap(true);
- QDialogButtonBox* btns = new QDialogButtonBox(QDialogButtonBox::Ok,
- Qt::Horizontal, &dialog);
+ QDialogButtonBox* btns =
+ new QDialogButtonBox(QDialogButtonBox::Ok, Qt::Horizontal, &dialog);
QObject::connect(btns, SIGNAL(accepted()), &dialog, SLOT(accept()));
l->addWidget(btns);
dialog.exec();
@@ -894,10 +870,9 @@ void CMakeSetupDialog::addBinaryPath(const QString& path)
// update UI
this->BinaryDirectory->blockSignals(true);
int idx = this->BinaryDirectory->findText(cleanpath);
- if(idx != -1)
- {
+ if (idx != -1) {
this->BinaryDirectory->removeItem(idx);
- }
+ }
this->BinaryDirectory->insertItem(0, cleanpath);
this->BinaryDirectory->setCurrentIndex(0);
this->BinaryDirectory->blockSignals(false);
@@ -911,56 +886,48 @@ void CMakeSetupDialog::addBinaryPath(const QString& path)
void CMakeSetupDialog::dragEnterEvent(QDragEnterEvent* e)
{
- if(!(this->CurrentState == ReadyConfigure ||
- this->CurrentState == ReadyGenerate))
- {
+ if (!(this->CurrentState == ReadyConfigure ||
+ this->CurrentState == ReadyGenerate)) {
e->ignore();
return;
- }
+ }
const QMimeData* dat = e->mimeData();
QList<QUrl> urls = dat->urls();
QString file = urls.count() ? urls[0].toLocalFile() : QString();
- if(!file.isEmpty() &&
- (file.endsWith("CMakeCache.txt", Qt::CaseInsensitive) ||
- file.endsWith("CMakeLists.txt", Qt::CaseInsensitive) ) )
- {
+ if (!file.isEmpty() &&
+ (file.endsWith("CMakeCache.txt", Qt::CaseInsensitive) ||
+ file.endsWith("CMakeLists.txt", Qt::CaseInsensitive))) {
e->accept();
- }
- else
- {
+ } else {
e->ignore();
- }
+ }
}
void CMakeSetupDialog::dropEvent(QDropEvent* e)
{
- if(!(this->CurrentState == ReadyConfigure ||
- this->CurrentState == ReadyGenerate))
- {
+ if (!(this->CurrentState == ReadyConfigure ||
+ this->CurrentState == ReadyGenerate)) {
return;
- }
+ }
const QMimeData* dat = e->mimeData();
QList<QUrl> urls = dat->urls();
QString file = urls.count() ? urls[0].toLocalFile() : QString();
- if(file.endsWith("CMakeCache.txt", Qt::CaseInsensitive))
- {
+ if (file.endsWith("CMakeCache.txt", Qt::CaseInsensitive)) {
QFileInfo info(file);
- if(this->CMakeThread->cmakeInstance()->binaryDirectory() != info.absolutePath())
- {
+ if (this->CMakeThread->cmakeInstance()->binaryDirectory() !=
+ info.absolutePath()) {
this->setBinaryDirectory(info.absolutePath());
- }
}
- else if(file.endsWith("CMakeLists.txt", Qt::CaseInsensitive))
- {
+ } else if (file.endsWith("CMakeLists.txt", Qt::CaseInsensitive)) {
QFileInfo info(file);
- if(this->CMakeThread->cmakeInstance()->binaryDirectory() != info.absolutePath())
- {
+ if (this->CMakeThread->cmakeInstance()->binaryDirectory() !=
+ info.absolutePath()) {
this->setSourceDirectory(info.absolutePath());
this->setBinaryDirectory(info.absolutePath());
- }
}
+ }
}
QStringList CMakeSetupDialog::loadBuildPaths()
@@ -969,14 +936,12 @@ QStringList CMakeSetupDialog::loadBuildPaths()
settings.beginGroup("Settings/StartPath");
QStringList buildPaths;
- for(int i=0; i<10; i++)
- {
- QString p = settings.value(QString("WhereBuild%1").arg(i)).toString();
- if(!p.isEmpty())
- {
- buildPaths.append(p);
- }
+ for (int i = 0; i < 10; i++) {
+ QString p = settings.value(QString("WhereBuild%1").arg(i)).toString();
+ if (!p.isEmpty()) {
+ buildPaths.append(p);
}
+ }
return buildPaths;
}
@@ -986,15 +951,13 @@ void CMakeSetupDialog::saveBuildPaths(const QStringList& paths)
settings.beginGroup("Settings/StartPath");
int num = paths.count();
- if(num > 10)
- {
+ if (num > 10) {
num = 10;
- }
+ }
- for(int i=0; i<num; i++)
- {
+ for (int i = 0; i < num; i++) {
settings.setValue(QString("WhereBuild%1").arg(i), paths[i]);
- }
+ }
}
void CMakeSetupDialog::setCacheModified()
@@ -1008,78 +971,62 @@ void CMakeSetupDialog::removeSelectedCacheEntries()
{
QModelIndexList idxs = this->CacheValues->selectionModel()->selectedRows();
QList<QPersistentModelIndex> pidxs;
- foreach(QModelIndex i, idxs)
- {
+ foreach (QModelIndex i, idxs) {
pidxs.append(i);
- }
- foreach(QPersistentModelIndex pi, pidxs)
- {
+ }
+ foreach (QPersistentModelIndex pi, pidxs) {
this->CacheValues->model()->removeRow(pi.row(), pi.parent());
- }
+ }
}
void CMakeSetupDialog::selectionChanged()
{
QModelIndexList idxs = this->CacheValues->selectionModel()->selectedRows();
- if(idxs.count() &&
- (this->CurrentState == ReadyConfigure ||
- this->CurrentState == ReadyGenerate) )
- {
+ if (idxs.count() && (this->CurrentState == ReadyConfigure ||
+ this->CurrentState == ReadyGenerate)) {
this->RemoveEntry->setEnabled(true);
- }
- else
- {
+ } else {
this->RemoveEntry->setEnabled(false);
- }
+ }
}
void CMakeSetupDialog::enterState(CMakeSetupDialog::State s)
{
- if(s == this->CurrentState)
- {
+ if (s == this->CurrentState) {
return;
- }
+ }
this->CurrentState = s;
- if(s == Interrupting)
- {
+ if (s == Interrupting) {
this->ConfigureButton->setEnabled(false);
this->GenerateButton->setEnabled(false);
- }
- else if(s == Configuring)
- {
+ } else if (s == Configuring) {
this->setEnabledState(false);
this->GenerateButton->setEnabled(false);
this->GenerateAction->setEnabled(false);
this->ConfigureButton->setText(tr("&Stop"));
- }
- else if(s == Generating)
- {
+ } else if (s == Generating) {
this->CacheModified = false;
this->setEnabledState(false);
this->ConfigureButton->setEnabled(false);
this->GenerateAction->setEnabled(false);
this->GenerateButton->setText(tr("&Stop"));
- }
- else if(s == ReadyConfigure)
- {
+ } else if (s == ReadyConfigure) {
this->setEnabledState(true);
this->GenerateButton->setEnabled(true);
this->GenerateAction->setEnabled(true);
this->ConfigureButton->setEnabled(true);
this->ConfigureButton->setText(tr("&Configure"));
this->GenerateButton->setText(tr("&Generate"));
- }
- else if(s == ReadyGenerate)
- {
+ } else if (s == ReadyGenerate) {
this->setEnabledState(true);
this->GenerateButton->setEnabled(true);
this->GenerateAction->setEnabled(true);
this->ConfigureButton->setEnabled(true);
this->ConfigureButton->setText(tr("&Configure"));
this->GenerateButton->setText(tr("&Generate"));
- }
+ }
}
void CMakeSetupDialog::addCacheEntry()
@@ -1088,44 +1035,40 @@ void CMakeSetupDialog::addCacheEntry()
dialog.resize(400, 200);
dialog.setWindowTitle(tr("Add Cache Entry"));
QVBoxLayout* l = new QVBoxLayout(&dialog);
- AddCacheEntry* w = new AddCacheEntry(&dialog, this->AddVariableNames,
- this->AddVariableTypes);
+ AddCacheEntry* w =
+ new AddCacheEntry(&dialog, this->AddVariableNames, this->AddVariableTypes);
QDialogButtonBox* btns = new QDialogButtonBox(
- QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
- Qt::Horizontal, &dialog);
+ QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, &dialog);
QObject::connect(btns, SIGNAL(accepted()), &dialog, SLOT(accept()));
QObject::connect(btns, SIGNAL(rejected()), &dialog, SLOT(reject()));
l->addWidget(w);
l->addStretch();
l->addWidget(btns);
- if(QDialog::Accepted == dialog.exec())
- {
+ if (QDialog::Accepted == dialog.exec()) {
QCMakeCacheModel* m = this->CacheValues->cacheModel();
- m->insertProperty(w->type(), w->name(), w->description(), w->value(), false);
+ m->insertProperty(w->type(), w->name(), w->description(), w->value(),
+ false);
// only add variable names to the completion which are new
- if (!this->AddVariableNames.contains(w->name()))
- {
+ if (!this->AddVariableNames.contains(w->name())) {
this->AddVariableNames << w->name();
this->AddVariableTypes << w->typeString();
// limit to at most 100 completion items
- if (this->AddVariableNames.size() > 100)
- {
+ if (this->AddVariableNames.size() > 100) {
this->AddVariableNames.removeFirst();
this->AddVariableTypes.removeFirst();
- }
+ }
// make sure CMAKE_INSTALL_PREFIX is always there
- if (!this->AddVariableNames.contains("CMAKE_INSTALL_PREFIX"))
- {
+ if (!this->AddVariableNames.contains("CMAKE_INSTALL_PREFIX")) {
this->AddVariableNames << "CMAKE_INSTALL_PREFIX";
this->AddVariableTypes << "PATH";
- }
+ }
QSettings settings;
settings.beginGroup("Settings/StartPath");
settings.setValue("AddVariableNames", this->AddVariableNames);
settings.setValue("AddVariableTypes", this->AddVariableTypes);
- }
}
+ }
}
void CMakeSetupDialog::startSearch()
@@ -1137,18 +1080,19 @@ void CMakeSetupDialog::startSearch()
void CMakeSetupDialog::setDebugOutput(bool flag)
{
QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(),
- "setDebugOutput", Qt::QueuedConnection, Q_ARG(bool, flag));
+ "setDebugOutput", Qt::QueuedConnection,
+ Q_ARG(bool, flag));
}
void CMakeSetupDialog::setGroupedView(bool v)
{
- this->CacheValues->cacheModel()->setViewType(v ? QCMakeCacheModel::GroupView : QCMakeCacheModel::FlatView);
+ this->CacheValues->cacheModel()->setViewType(v ? QCMakeCacheModel::GroupView
+ : QCMakeCacheModel::FlatView);
this->CacheValues->setRootIsDecorated(v);
QSettings settings;
settings.beginGroup("Settings/StartPath");
settings.setValue("GroupView", v);
-
}
void CMakeSetupDialog::setAdvancedView(bool v)
@@ -1162,7 +1106,8 @@ void CMakeSetupDialog::setAdvancedView(bool v)
void CMakeSetupDialog::showUserChanges()
{
QSet<QCMakeProperty> changes =
- qobject_cast<QCMakeCacheModelDelegate*>(this->CacheValues->itemDelegate())->changes();
+ qobject_cast<QCMakeCacheModelDelegate*>(this->CacheValues->itemDelegate())
+ ->changes();
QDialog dialog(this);
dialog.setWindowTitle(tr("My Changes"));
@@ -1171,19 +1116,17 @@ void CMakeSetupDialog::showUserChanges()
QTextEdit* textedit = new QTextEdit(&dialog);
textedit->setReadOnly(true);
l->addWidget(textedit);
- QDialogButtonBox* btns = new QDialogButtonBox(QDialogButtonBox::Close,
- Qt::Horizontal, &dialog);
+ QDialogButtonBox* btns =
+ new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, &dialog);
QObject::connect(btns, SIGNAL(rejected()), &dialog, SLOT(accept()));
l->addWidget(btns);
QString command;
QString cache;
- foreach(QCMakeProperty prop, changes)
- {
+ foreach (QCMakeProperty prop, changes) {
QString type;
- switch(prop.Type)
- {
+ switch (prop.Type) {
case QCMakeProperty::BOOL:
type = "BOOL";
break;
@@ -1196,16 +1139,13 @@ void CMakeSetupDialog::showUserChanges()
case QCMakeProperty::STRING:
type = "STRING";
break;
- }
+ }
QString value;
- if(prop.Type == QCMakeProperty::BOOL)
- {
+ if (prop.Type == QCMakeProperty::BOOL) {
value = prop.Value.toBool() ? "1" : "0";
- }
- else
- {
+ } else {
value = prop.Value.toString();
- }
+ }
QString line("%1:%2=");
line = line.arg(prop.Key);
@@ -1213,7 +1153,7 @@ void CMakeSetupDialog::showUserChanges()
command += QString("-D%1\"%2\" ").arg(line).arg(value);
cache += QString("%1%2\n").arg(line).arg(value);
- }
+ }
textedit->append(tr("Commandline options:"));
textedit->append(command);
@@ -1230,20 +1170,20 @@ void CMakeSetupDialog::setSearchFilter(const QString& str)
this->CacheValues->setSearchFilter(str);
}
-void CMakeSetupDialog::doOutputContextMenu(const QPoint &pt)
+void CMakeSetupDialog::doOutputContextMenu(const QPoint& pt)
{
- QMenu *menu = this->Output->createStandardContextMenu();
+ QMenu* menu = this->Output->createStandardContextMenu();
menu->addSeparator();
- menu->addAction(tr("Find..."),
- this, SLOT(doOutputFindDialog()), QKeySequence::Find);
- menu->addAction(tr("Find Next"),
- this, SLOT(doOutputFindNext()), QKeySequence::FindNext);
- menu->addAction(tr("Find Previous"),
- this, SLOT(doOutputFindPrev()), QKeySequence::FindPrevious);
+ menu->addAction(tr("Find..."), this, SLOT(doOutputFindDialog()),
+ QKeySequence::Find);
+ menu->addAction(tr("Find Next"), this, SLOT(doOutputFindNext()),
+ QKeySequence::FindNext);
+ menu->addAction(tr("Find Previous"), this, SLOT(doOutputFindPrev()),
+ QKeySequence::FindPrevious);
menu->addSeparator();
- menu->addAction(tr("Goto Next Error"),
- this, SLOT(doOutputErrorNext()), QKeySequence(Qt::Key_F8));
+ menu->addAction(tr("Goto Next Error"), this, SLOT(doOutputErrorNext()),
+ QKeySequence(Qt::Key_F8));
menu->exec(this->Output->mapToGlobal(pt));
delete menu;
@@ -1254,24 +1194,20 @@ void CMakeSetupDialog::doOutputFindDialog()
QStringList strings(this->FindHistory);
QString selection = this->Output->textCursor().selectedText();
- if (!selection.isEmpty() &&
- !selection.contains(QChar::ParagraphSeparator) &&
- !selection.contains(QChar::LineSeparator))
- {
+ if (!selection.isEmpty() && !selection.contains(QChar::ParagraphSeparator) &&
+ !selection.contains(QChar::LineSeparator)) {
strings.push_front(selection);
- }
+ }
bool ok;
QString search = QInputDialog::getItem(this, tr("Find in Output"),
tr("Find:"), strings, 0, true, &ok);
- if (ok && !search.isEmpty())
- {
- if (!this->FindHistory.contains(search))
- {
+ if (ok && !search.isEmpty()) {
+ if (!this->FindHistory.contains(search)) {
this->FindHistory.push_front(search);
- }
- doOutputFindNext();
}
+ doOutputFindNext();
+ }
}
void CMakeSetupDialog::doRegexExplorerDialog()
@@ -1287,37 +1223,33 @@ void CMakeSetupDialog::doOutputFindPrev()
void CMakeSetupDialog::doOutputFindNext(bool directionForward)
{
- if (this->FindHistory.isEmpty())
- {
- doOutputFindDialog(); //will re-call this function again
+ if (this->FindHistory.isEmpty()) {
+ doOutputFindDialog(); // will re-call this function again
return;
- }
+ }
QString search = this->FindHistory.front();
QTextCursor textCursor = this->Output->textCursor();
QTextDocument* document = this->Output->document();
QTextDocument::FindFlags flags;
- if (!directionForward)
- {
+ if (!directionForward) {
flags |= QTextDocument::FindBackward;
- }
+ }
textCursor = document->find(search, textCursor, flags);
- if (textCursor.isNull())
- {
+ if (textCursor.isNull()) {
// first search found nothing, wrap around and search again
textCursor = this->Output->textCursor();
textCursor.movePosition(directionForward ? QTextCursor::Start
: QTextCursor::End);
textCursor = document->find(search, textCursor, flags);
- }
+ }
- if (textCursor.hasSelection())
- {
+ if (textCursor.hasSelection()) {
this->Output->setTextCursor(textCursor);
- }
+ }
}
void CMakeSetupDialog::doOutputErrorNext()
@@ -1326,36 +1258,31 @@ void CMakeSetupDialog::doOutputErrorNext()
bool atEnd = false;
// move cursor out of current error-block
- if (textCursor.blockCharFormat() == this->ErrorFormat)
- {
+ if (textCursor.blockCharFormat() == this->ErrorFormat) {
atEnd = !textCursor.movePosition(QTextCursor::NextBlock);
- }
+ }
// move cursor to next error-block
- while (textCursor.blockCharFormat() != this->ErrorFormat && !atEnd)
- {
+ while (textCursor.blockCharFormat() != this->ErrorFormat && !atEnd) {
atEnd = !textCursor.movePosition(QTextCursor::NextBlock);
- }
+ }
- if (atEnd)
- {
+ if (atEnd) {
// first search found nothing, wrap around and search again
atEnd = !textCursor.movePosition(QTextCursor::Start);
// move cursor to next error-block
- while (textCursor.blockCharFormat() != this->ErrorFormat && !atEnd)
- {
+ while (textCursor.blockCharFormat() != this->ErrorFormat && !atEnd) {
atEnd = !textCursor.movePosition(QTextCursor::NextBlock);
- }
}
+ }
- if (!atEnd)
- {
+ if (!atEnd) {
textCursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
QTextCharFormat selectionFormat;
selectionFormat.setBackground(Qt::yellow);
- QTextEdit::ExtraSelection extraSelection = {textCursor, selectionFormat};
+ QTextEdit::ExtraSelection extraSelection = { textCursor, selectionFormat };
this->Output->setExtraSelections(QList<QTextEdit::ExtraSelection>()
<< extraSelection);
@@ -1365,7 +1292,7 @@ void CMakeSetupDialog::doOutputErrorNext()
// remove the selection to see the extraSelection
textCursor.setPosition(textCursor.anchor());
this->Output->setTextCursor(textCursor);
- }
+ }
}
void CMakeSetupDialog::doWarningMessagesDialog()
diff --git a/Source/QtDialog/CMakeSetupDialog.h b/Source/QtDialog/CMakeSetupDialog.h
index f9624d1..2a4ea7a 100644
--- a/Source/QtDialog/CMakeSetupDialog.h
+++ b/Source/QtDialog/CMakeSetupDialog.h
@@ -78,7 +78,7 @@ protected slots:
bool doConfigureInternal();
bool doGenerateInternal();
void exitLoop(int);
- void doOutputContextMenu(const QPoint &);
+ void doOutputContextMenu(const QPoint&);
void doOutputFindDialog();
void doOutputFindNext(bool directionForward = true);
void doOutputFindPrev();
@@ -88,8 +88,14 @@ protected slots:
void doWarningMessagesDialog();
protected:
-
- enum State { Interrupting, ReadyConfigure, ReadyGenerate, Configuring, Generating };
+ enum State
+ {
+ Interrupting,
+ ReadyConfigure,
+ ReadyGenerate,
+ Configuring,
+ Generating
+ };
void enterState(State s);
void closeEvent(QCloseEvent*);
diff --git a/Source/QtDialog/Compilers.h b/Source/QtDialog/Compilers.h
index ee89886..bdb1962 100644
--- a/Source/QtDialog/Compilers.h
+++ b/Source/QtDialog/Compilers.h
@@ -11,12 +11,11 @@ class Compilers : public QWidget, public Ui::Compilers
{
Q_OBJECT
public:
- Compilers(QWidget* p=NULL) :
- QWidget(p)
+ Compilers(QWidget* p = NULL)
+ : QWidget(p)
{
this->setupUi(this);
}
};
#endif
-
diff --git a/Source/QtDialog/FirstConfigure.cxx b/Source/QtDialog/FirstConfigure.cxx
index 5c0af2b..ca5e3b5 100644
--- a/Source/QtDialog/FirstConfigure.cxx
+++ b/Source/QtDialog/FirstConfigure.cxx
@@ -8,7 +8,6 @@
#include <QSettings>
#include <QVBoxLayout>
-
StartCompilerSetup::StartCompilerSetup(QWidget* p)
: QWizardPage(p)
{
@@ -23,10 +22,14 @@ StartCompilerSetup::StartCompilerSetup(QWidget* p)
l->addSpacing(6);
- this->CompilerSetupOptions[0] = new QRadioButton(tr("Use default native compilers"), this);
- this->CompilerSetupOptions[1] = new QRadioButton(tr("Specify native compilers"), this);
- this->CompilerSetupOptions[2] = new QRadioButton(tr("Specify toolchain file for cross-compiling"), this);
- this->CompilerSetupOptions[3] = new QRadioButton(tr("Specify options for cross-compiling"), this);
+ this->CompilerSetupOptions[0] =
+ new QRadioButton(tr("Use default native compilers"), this);
+ this->CompilerSetupOptions[1] =
+ new QRadioButton(tr("Specify native compilers"), this);
+ this->CompilerSetupOptions[2] =
+ new QRadioButton(tr("Specify toolchain file for cross-compiling"), this);
+ this->CompilerSetupOptions[3] =
+ new QRadioButton(tr("Specify options for cross-compiling"), this);
l->addWidget(this->CompilerSetupOptions[0]);
l->addWidget(this->CompilerSetupOptions[1]);
l->addWidget(this->CompilerSetupOptions[2]);
@@ -34,17 +37,17 @@ StartCompilerSetup::StartCompilerSetup(QWidget* p)
this->CompilerSetupOptions[0]->setChecked(true);
- QObject::connect(this->CompilerSetupOptions[0], SIGNAL(toggled(bool)),
- this, SLOT(onSelectionChanged(bool)));
- QObject::connect(this->CompilerSetupOptions[1], SIGNAL(toggled(bool)),
- this, SLOT(onSelectionChanged(bool)));
- QObject::connect(this->CompilerSetupOptions[2], SIGNAL(toggled(bool)),
- this, SLOT(onSelectionChanged(bool)));
- QObject::connect(this->CompilerSetupOptions[3], SIGNAL(toggled(bool)),
- this, SLOT(onSelectionChanged(bool)));
+ QObject::connect(this->CompilerSetupOptions[0], SIGNAL(toggled(bool)), this,
+ SLOT(onSelectionChanged(bool)));
+ QObject::connect(this->CompilerSetupOptions[1], SIGNAL(toggled(bool)), this,
+ SLOT(onSelectionChanged(bool)));
+ QObject::connect(this->CompilerSetupOptions[2], SIGNAL(toggled(bool)), this,
+ SLOT(onSelectionChanged(bool)));
+ QObject::connect(this->CompilerSetupOptions[3], SIGNAL(toggled(bool)), this,
+ SLOT(onSelectionChanged(bool)));
QObject::connect(GeneratorOptions,
- SIGNAL(currentIndexChanged(QString const&)),
- this, SLOT(onGeneratorChanged(QString const&)));
+ SIGNAL(currentIndexChanged(QString const&)), this,
+ SLOT(onGeneratorChanged(QString const&)));
}
QFrame* StartCompilerSetup::CreateToolsetWidgets()
@@ -74,16 +77,14 @@ void StartCompilerSetup::setGenerators(
QStringList generator_list;
std::vector<cmake::GeneratorInfo>::const_iterator it;
- for (it = gens.begin(); it != gens.end(); ++it)
- {
+ for (it = gens.begin(); it != gens.end(); ++it) {
generator_list.append(QString::fromLocal8Bit(it->name.c_str()));
- if (it->supportsToolset)
- {
+ if (it->supportsToolset) {
this->GeneratorsSupportingToolset.append(
QString::fromLocal8Bit(it->name.c_str()));
- }
}
+ }
this->GeneratorOptions->addItems(generator_list);
}
@@ -91,8 +92,7 @@ void StartCompilerSetup::setGenerators(
void StartCompilerSetup::setCurrentGenerator(const QString& gen)
{
int idx = this->GeneratorOptions->findText(gen);
- if(idx != -1)
- {
+ if (idx != -1) {
this->GeneratorOptions->setCurrentIndex(idx);
}
}
@@ -129,29 +129,26 @@ bool StartCompilerSetup::crossCompilerSetup() const
void StartCompilerSetup::onSelectionChanged(bool on)
{
- if(on)
+ if (on)
selectionChanged();
}
void StartCompilerSetup::onGeneratorChanged(QString const& name)
{
- if (GeneratorsSupportingToolset.contains(name))
- {
+ if (GeneratorsSupportingToolset.contains(name)) {
ToolsetFrame->show();
- }
- else
- {
+ } else {
ToolsetFrame->hide();
- }
+ }
}
int StartCompilerSetup::nextId() const
{
- if(compilerSetup())
+ if (compilerSetup())
return NativeSetup;
- if(crossCompilerSetup())
+ if (crossCompilerSetup())
return CrossSetup;
- if(crossCompilerToolChainFile())
+ if (crossCompilerToolChainFile())
return ToolchainSetup;
return -1;
}
@@ -199,7 +196,6 @@ void NativeCompilerSetup::setFortranCompiler(const QString& s)
this->FortranCompiler->setText(s);
}
-
CrossCompilerSetup::CrossCompilerSetup(QWidget* p)
: QWizardPage(p)
{
@@ -208,7 +204,8 @@ CrossCompilerSetup::CrossCompilerSetup(QWidget* p)
QWidget::setTabOrder(systemVersion, systemProcessor);
QWidget::setTabOrder(systemProcessor, CrossCompilers->CCompiler);
QWidget::setTabOrder(CrossCompilers->CCompiler, CrossCompilers->CXXCompiler);
- QWidget::setTabOrder(CrossCompilers->CXXCompiler, CrossCompilers->FortranCompiler);
+ QWidget::setTabOrder(CrossCompilers->CXXCompiler,
+ CrossCompilers->FortranCompiler);
QWidget::setTabOrder(CrossCompilers->FortranCompiler, crossFindRoot);
QWidget::setTabOrder(crossFindRoot, crossProgramMode);
QWidget::setTabOrder(crossProgramMode, crossLibraryMode);
@@ -273,7 +270,6 @@ void CrossCompilerSetup::setSystem(const QString& t)
this->systemName->setText(t);
}
-
QString CrossCompilerSetup::getVersion() const
{
return this->systemVersion->text();
@@ -284,7 +280,6 @@ void CrossCompilerSetup::setVersion(const QString& t)
this->systemVersion->setText(t);
}
-
QString CrossCompilerSetup::getProcessor() const
{
return this->systemProcessor->text();
@@ -358,11 +353,9 @@ void ToolchainCompilerSetup::setToolchainFile(const QString& t)
this->ToolchainFile->setText(t);
}
-
-
FirstConfigure::FirstConfigure()
{
- //this->setOption(QWizard::HaveFinishButtonOnEarlyPages, true);
+ // this->setOption(QWizard::HaveFinishButtonOnEarlyPages, true);
this->mStartCompilerSetupPage = new StartCompilerSetup(this);
this->setPage(Start, this->mStartCompilerSetupPage);
QObject::connect(this->mStartCompilerSetupPage, SIGNAL(selectionChanged()),
@@ -409,24 +402,38 @@ void FirstConfigure::loadFromSettings()
// restore compiler setup
settings.beginGroup("Settings/Compiler");
- this->mNativeCompilerSetupPage->setCCompiler(settings.value("CCompiler").toString());
- this->mNativeCompilerSetupPage->setCXXCompiler(settings.value("CXXCompiler").toString());
- this->mNativeCompilerSetupPage->setFortranCompiler(settings.value("FortranCompiler").toString());
+ this->mNativeCompilerSetupPage->setCCompiler(
+ settings.value("CCompiler").toString());
+ this->mNativeCompilerSetupPage->setCXXCompiler(
+ settings.value("CXXCompiler").toString());
+ this->mNativeCompilerSetupPage->setFortranCompiler(
+ settings.value("FortranCompiler").toString());
settings.endGroup();
// restore cross compiler setup
settings.beginGroup("Settings/CrossCompiler");
- this->mCrossCompilerSetupPage->setCCompiler(settings.value("CCompiler").toString());
- this->mCrossCompilerSetupPage->setCXXCompiler(settings.value("CXXCompiler").toString());
- this->mCrossCompilerSetupPage->setFortranCompiler(settings.value("FortranCompiler").toString());
- this->mToolchainCompilerSetupPage->setToolchainFile(settings.value("ToolChainFile").toString());
- this->mCrossCompilerSetupPage->setSystem(settings.value("SystemName").toString());
- this->mCrossCompilerSetupPage->setVersion(settings.value("SystemVersion").toString());
- this->mCrossCompilerSetupPage->setProcessor(settings.value("SystemProcessor").toString());
- this->mCrossCompilerSetupPage->setFindRoot(settings.value("FindRoot").toString());
- this->mCrossCompilerSetupPage->setProgramMode(settings.value("ProgramMode", 0).toInt());
- this->mCrossCompilerSetupPage->setLibraryMode(settings.value("LibraryMode", 0).toInt());
- this->mCrossCompilerSetupPage->setIncludeMode(settings.value("IncludeMode", 0).toInt());
+ this->mCrossCompilerSetupPage->setCCompiler(
+ settings.value("CCompiler").toString());
+ this->mCrossCompilerSetupPage->setCXXCompiler(
+ settings.value("CXXCompiler").toString());
+ this->mCrossCompilerSetupPage->setFortranCompiler(
+ settings.value("FortranCompiler").toString());
+ this->mToolchainCompilerSetupPage->setToolchainFile(
+ settings.value("ToolChainFile").toString());
+ this->mCrossCompilerSetupPage->setSystem(
+ settings.value("SystemName").toString());
+ this->mCrossCompilerSetupPage->setVersion(
+ settings.value("SystemVersion").toString());
+ this->mCrossCompilerSetupPage->setProcessor(
+ settings.value("SystemProcessor").toString());
+ this->mCrossCompilerSetupPage->setFindRoot(
+ settings.value("FindRoot").toString());
+ this->mCrossCompilerSetupPage->setProgramMode(
+ settings.value("ProgramMode", 0).toInt());
+ this->mCrossCompilerSetupPage->setLibraryMode(
+ settings.value("LibraryMode", 0).toInt());
+ this->mCrossCompilerSetupPage->setIncludeMode(
+ settings.value("IncludeMode", 0).toInt());
settings.endGroup();
}
@@ -442,24 +449,35 @@ void FirstConfigure::saveToSettings()
// save compiler setup
settings.beginGroup("Settings/Compiler");
- settings.setValue("CCompiler", this->mNativeCompilerSetupPage->getCCompiler());
- settings.setValue("CXXCompiler", this->mNativeCompilerSetupPage->getCXXCompiler());
- settings.setValue("FortranCompiler", this->mNativeCompilerSetupPage->getFortranCompiler());
+ settings.setValue("CCompiler",
+ this->mNativeCompilerSetupPage->getCCompiler());
+ settings.setValue("CXXCompiler",
+ this->mNativeCompilerSetupPage->getCXXCompiler());
+ settings.setValue("FortranCompiler",
+ this->mNativeCompilerSetupPage->getFortranCompiler());
settings.endGroup();
// save cross compiler setup
settings.beginGroup("Settings/CrossCompiler");
- settings.setValue("CCompiler", this->mCrossCompilerSetupPage->getCCompiler());
- settings.setValue("CXXCompiler", this->mCrossCompilerSetupPage->getCXXCompiler());
- settings.setValue("FortranCompiler", this->mCrossCompilerSetupPage->getFortranCompiler());
+ settings.setValue("CCompiler",
+ this->mCrossCompilerSetupPage->getCCompiler());
+ settings.setValue("CXXCompiler",
+ this->mCrossCompilerSetupPage->getCXXCompiler());
+ settings.setValue("FortranCompiler",
+ this->mCrossCompilerSetupPage->getFortranCompiler());
settings.setValue("ToolChainFile", this->getCrossCompilerToolChainFile());
settings.setValue("SystemName", this->mCrossCompilerSetupPage->getSystem());
- settings.setValue("SystemVersion", this->mCrossCompilerSetupPage->getVersion());
- settings.setValue("SystemProcessor", this->mCrossCompilerSetupPage->getProcessor());
+ settings.setValue("SystemVersion",
+ this->mCrossCompilerSetupPage->getVersion());
+ settings.setValue("SystemProcessor",
+ this->mCrossCompilerSetupPage->getProcessor());
settings.setValue("FindRoot", this->mCrossCompilerSetupPage->getFindRoot());
- settings.setValue("ProgramMode", this->mCrossCompilerSetupPage->getProgramMode());
- settings.setValue("LibraryMode", this->mCrossCompilerSetupPage->getLibraryMode());
- settings.setValue("IncludeMode", this->mCrossCompilerSetupPage->getIncludeMode());
+ settings.setValue("ProgramMode",
+ this->mCrossCompilerSetupPage->getProgramMode());
+ settings.setValue("LibraryMode",
+ this->mCrossCompilerSetupPage->getLibraryMode());
+ settings.setValue("IncludeMode",
+ this->mCrossCompilerSetupPage->getIncludeMode());
settings.endGroup();
}
@@ -495,44 +513,34 @@ QString FirstConfigure::getSystemName() const
QString FirstConfigure::getCCompiler() const
{
- if(this->compilerSetup())
- {
+ if (this->compilerSetup()) {
return this->mNativeCompilerSetupPage->getCCompiler();
- }
- else if(this->crossCompilerSetup())
- {
+ } else if (this->crossCompilerSetup()) {
return this->mCrossCompilerSetupPage->getCCompiler();
- }
+ }
return QString();
}
QString FirstConfigure::getCXXCompiler() const
{
- if(this->compilerSetup())
- {
+ if (this->compilerSetup()) {
return this->mNativeCompilerSetupPage->getCXXCompiler();
- }
- else if(this->crossCompilerSetup())
- {
+ } else if (this->crossCompilerSetup()) {
return this->mCrossCompilerSetupPage->getCXXCompiler();
- }
+ }
return QString();
}
QString FirstConfigure::getFortranCompiler() const
{
- if(this->compilerSetup())
- {
+ if (this->compilerSetup()) {
return this->mNativeCompilerSetupPage->getFortranCompiler();
- }
- else if(this->crossCompilerSetup())
- {
+ } else if (this->crossCompilerSetup()) {
return this->mCrossCompilerSetupPage->getFortranCompiler();
- }
+ }
return QString();
}
-
QString FirstConfigure::getSystemVersion() const
{
return this->mCrossCompilerSetupPage->getVersion();
@@ -548,12 +556,7 @@ QString FirstConfigure::getCrossRoot() const
return this->mCrossCompilerSetupPage->getFindRoot();
}
-const QString CrossModes[] =
-{
- "BOTH",
- "ONLY",
- "NEVER"
-};
+const QString CrossModes[] = { "BOTH", "ONLY", "NEVER" };
QString FirstConfigure::getCrossProgramMode() const
{
@@ -569,4 +572,3 @@ QString FirstConfigure::getCrossIncludeMode() const
{
return CrossModes[this->mCrossCompilerSetupPage->getIncludeMode()];
}
-
diff --git a/Source/QtDialog/FirstConfigure.h b/Source/QtDialog/FirstConfigure.h
index 3c574d4..c467ddb 100644
--- a/Source/QtDialog/FirstConfigure.h
+++ b/Source/QtDialog/FirstConfigure.h
@@ -23,125 +23,126 @@ enum FirstConfigurePages
Done
};
-//! the first page that gives basic options for what compilers setup to choose from
+//! the first page that gives basic options for what compilers setup to choose
+//! from
class StartCompilerSetup : public QWizardPage
{
Q_OBJECT
- public:
- StartCompilerSetup(QWidget* p);
- ~StartCompilerSetup();
- void setGenerators(std::vector<cmake::GeneratorInfo> const& gens);
- void setCurrentGenerator(const QString& gen);
- QString getGenerator() const;
- QString getToolset() const;
-
- bool defaultSetup() const;
- bool compilerSetup() const;
- bool crossCompilerSetup() const;
- bool crossCompilerToolChainFile() const;
-
- int nextId() const;
-
- signals:
- void selectionChanged();
-
- protected slots:
- void onSelectionChanged(bool);
- void onGeneratorChanged(QString const& name);
-
- protected:
- QComboBox* GeneratorOptions;
- QRadioButton* CompilerSetupOptions[4];
- QFrame* ToolsetFrame;
- QLineEdit* Toolset;
- QLabel* ToolsetLabel;
- QStringList GeneratorsSupportingToolset;
-
- private:
- QFrame* CreateToolsetWidgets();
+public:
+ StartCompilerSetup(QWidget* p);
+ ~StartCompilerSetup();
+ void setGenerators(std::vector<cmake::GeneratorInfo> const& gens);
+ void setCurrentGenerator(const QString& gen);
+ QString getGenerator() const;
+ QString getToolset() const;
+
+ bool defaultSetup() const;
+ bool compilerSetup() const;
+ bool crossCompilerSetup() const;
+ bool crossCompilerToolChainFile() const;
+
+ int nextId() const;
+
+signals:
+ void selectionChanged();
+
+protected slots:
+ void onSelectionChanged(bool);
+ void onGeneratorChanged(QString const& name);
+
+protected:
+ QComboBox* GeneratorOptions;
+ QRadioButton* CompilerSetupOptions[4];
+ QFrame* ToolsetFrame;
+ QLineEdit* Toolset;
+ QLabel* ToolsetLabel;
+ QStringList GeneratorsSupportingToolset;
+
+private:
+ QFrame* CreateToolsetWidgets();
};
//! the page that gives basic options for native compilers
class NativeCompilerSetup : public QWizardPage, protected Ui::Compilers
{
Q_OBJECT
- public:
- NativeCompilerSetup(QWidget* p);
- ~NativeCompilerSetup();
+public:
+ NativeCompilerSetup(QWidget* p);
+ ~NativeCompilerSetup();
- QString getCCompiler() const;
- void setCCompiler(const QString&);
+ QString getCCompiler() const;
+ void setCCompiler(const QString&);
- QString getCXXCompiler() const;
- void setCXXCompiler(const QString&);
+ QString getCXXCompiler() const;
+ void setCXXCompiler(const QString&);
- QString getFortranCompiler() const;
- void setFortranCompiler(const QString&);
+ QString getFortranCompiler() const;
+ void setFortranCompiler(const QString&);
- int nextId() const { return -1; }
+ int nextId() const { return -1; }
};
//! the page that gives options for cross compilers
class CrossCompilerSetup : public QWizardPage, protected Ui::CrossCompiler
{
Q_OBJECT
- public:
- CrossCompilerSetup(QWidget* p);
- ~CrossCompilerSetup();
-
- QString getSystem() const;
- void setSystem(const QString&);
-
- QString getVersion() const;
- void setVersion(const QString&);
-
- QString getProcessor() const;
- void setProcessor(const QString&);
-
- QString getCCompiler() const;
- void setCCompiler(const QString&);
+public:
+ CrossCompilerSetup(QWidget* p);
+ ~CrossCompilerSetup();
- QString getCXXCompiler() const;
- void setCXXCompiler(const QString&);
+ QString getSystem() const;
+ void setSystem(const QString&);
- QString getFortranCompiler() const;
- void setFortranCompiler(const QString&);
+ QString getVersion() const;
+ void setVersion(const QString&);
- QString getFindRoot() const;
- void setFindRoot(const QString&);
+ QString getProcessor() const;
+ void setProcessor(const QString&);
- enum CrossMode
- {
- BOTH,
- ONLY,
- NEVER
- };
+ QString getCCompiler() const;
+ void setCCompiler(const QString&);
- int getProgramMode() const;
- void setProgramMode(int);
- int getLibraryMode() const;
- void setLibraryMode(int);
- int getIncludeMode() const;
- void setIncludeMode(int);
+ QString getCXXCompiler() const;
+ void setCXXCompiler(const QString&);
- int nextId() const { return -1; }
+ QString getFortranCompiler() const;
+ void setFortranCompiler(const QString&);
+
+ QString getFindRoot() const;
+ void setFindRoot(const QString&);
+
+ enum CrossMode
+ {
+ BOTH,
+ ONLY,
+ NEVER
+ };
+
+ int getProgramMode() const;
+ void setProgramMode(int);
+ int getLibraryMode() const;
+ void setLibraryMode(int);
+ int getIncludeMode() const;
+ void setIncludeMode(int);
+
+ int nextId() const { return -1; }
};
//! the page that gives options for a toolchain file
class ToolchainCompilerSetup : public QWizardPage
{
Q_OBJECT
- public:
- ToolchainCompilerSetup(QWidget* p);
- ~ToolchainCompilerSetup();
+public:
+ ToolchainCompilerSetup(QWidget* p);
+ ~ToolchainCompilerSetup();
- QString toolchainFile() const;
- void setToolchainFile(const QString&);
+ QString toolchainFile() const;
+ void setToolchainFile(const QString&);
- int nextId() const { return -1; }
+ int nextId() const { return -1; }
- protected:
- QCMakeFilePathEditor* ToolchainFile;
+protected:
+ QCMakeFilePathEditor* ToolchainFile;
};
//! the wizard with the pages
@@ -183,8 +184,6 @@ protected:
NativeCompilerSetup* mNativeCompilerSetupPage;
CrossCompilerSetup* mCrossCompilerSetupPage;
ToolchainCompilerSetup* mToolchainCompilerSetupPage;
-
};
#endif // FirstConfigure_h
-
diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx
index 28be341..c84e153 100644
--- a/Source/QtDialog/QCMake.cxx
+++ b/Source/QtDialog/QCMake.cxx
@@ -20,7 +20,7 @@
#include "cmSystemTools.h"
#ifdef Q_OS_WIN
-#include "qt_windows.h" // For SetErrorMode
+#include "qt_windows.h" // For SetErrorMode
#endif
QCMake::QCMake(QObject* p)
@@ -48,26 +48,24 @@ QCMake::QCMake(QObject* p)
this->CMakeInstance->GetRegisteredGenerators(generators);
std::vector<cmake::GeneratorInfo>::const_iterator it;
- for(it = generators.begin(); it != generators.end(); ++it)
- {
+ for (it = generators.begin(); it != generators.end(); ++it) {
// Skip the generator "KDevelop3", since there is also
// "KDevelop3 - Unix Makefiles", which is the full and official name.
// The short name is actually only still there since this was the name
// in CMake 2.4, to keep "command line argument compatibility", but
// this is not necessary in the GUI.
- if (it->name == "KDevelop3")
- {
+ if (it->name == "KDevelop3") {
continue;
- }
+ }
this->AvailableGenerators.push_back(*it);
- }
+ }
}
QCMake::~QCMake()
{
delete this->CMakeInstance;
- //cmDynamicLoader::FlushCache();
+ // cmDynamicLoader::FlushCache();
}
void QCMake::loadCache(const QString& dir)
@@ -77,80 +75,73 @@ void QCMake::loadCache(const QString& dir)
void QCMake::setSourceDirectory(const QString& _dir)
{
- QString dir =
- QString::fromLocal8Bit(cmSystemTools::GetActualCaseForPath(_dir.toLocal8Bit().data()).c_str());
- if(this->SourceDirectory != dir)
- {
+ QString dir = QString::fromLocal8Bit(
+ cmSystemTools::GetActualCaseForPath(_dir.toLocal8Bit().data()).c_str());
+ if (this->SourceDirectory != dir) {
this->SourceDirectory = QDir::fromNativeSeparators(dir);
emit this->sourceDirChanged(this->SourceDirectory);
- }
+ }
}
void QCMake::setBinaryDirectory(const QString& _dir)
{
- QString dir =
- QString::fromLocal8Bit(cmSystemTools::GetActualCaseForPath(_dir.toLocal8Bit().data()).c_str());
- if(this->BinaryDirectory != dir)
- {
+ QString dir = QString::fromLocal8Bit(
+ cmSystemTools::GetActualCaseForPath(_dir.toLocal8Bit().data()).c_str());
+ if (this->BinaryDirectory != dir) {
this->BinaryDirectory = QDir::fromNativeSeparators(dir);
emit this->binaryDirChanged(this->BinaryDirectory);
cmState* state = this->CMakeInstance->GetState();
this->setGenerator(QString());
this->setToolset(QString());
- if(!this->CMakeInstance->LoadCache(
- this->BinaryDirectory.toLocal8Bit().data()))
- {
+ if (!this->CMakeInstance->LoadCache(
+ this->BinaryDirectory.toLocal8Bit().data())) {
QDir testDir(this->BinaryDirectory);
- if(testDir.exists("CMakeCache.txt"))
- {
- cmSystemTools::Error("There is a CMakeCache.txt file for the current binary "
- "tree but cmake does not have permission to read it. "
- "Please check the permissions of the directory you are trying to run CMake on.");
- }
+ if (testDir.exists("CMakeCache.txt")) {
+ cmSystemTools::Error(
+ "There is a CMakeCache.txt file for the current binary "
+ "tree but cmake does not have permission to read it. "
+ "Please check the permissions of the directory you are trying to "
+ "run CMake on.");
}
+ }
QCMakePropertyList props = this->properties();
emit this->propertiesChanged(props);
const char* homeDir = state->GetCacheEntryValue("CMAKE_HOME_DIRECTORY");
- if (homeDir)
- {
+ if (homeDir) {
setSourceDirectory(QString::fromLocal8Bit(homeDir));
- }
+ }
const char* gen = state->GetCacheEntryValue("CMAKE_GENERATOR");
- if (gen)
- {
- const char* extraGen = state
- ->GetInitializedCacheValue("CMAKE_EXTRA_GENERATOR");
- std::string curGen = cmExternalMakefileProjectGenerator::
- CreateFullGeneratorName(gen, extraGen? extraGen : "");
+ if (gen) {
+ const char* extraGen =
+ state->GetInitializedCacheValue("CMAKE_EXTRA_GENERATOR");
+ std::string curGen =
+ cmExternalMakefileProjectGenerator::CreateFullGeneratorName(
+ gen, extraGen ? extraGen : "");
this->setGenerator(QString::fromLocal8Bit(curGen.c_str()));
- }
+ }
const char* toolset = state->GetCacheEntryValue("CMAKE_GENERATOR_TOOLSET");
- if (toolset)
- {
+ if (toolset) {
this->setToolset(QString::fromLocal8Bit(toolset));
- }
}
+ }
}
-
void QCMake::setGenerator(const QString& gen)
{
- if(this->Generator != gen)
- {
+ if (this->Generator != gen) {
this->Generator = gen;
emit this->generatorChanged(this->Generator);
- }
+ }
}
void QCMake::setToolset(const QString& toolset)
{
- if(this->Toolset != toolset)
- {
+ if (this->Toolset != toolset) {
this->Toolset = toolset;
emit this->toolsetChanged(this->Toolset);
- }
+ }
}
void QCMake::configure()
@@ -159,10 +150,13 @@ void QCMake::configure()
UINT lastErrorMode = SetErrorMode(0);
#endif
- this->CMakeInstance->SetHomeDirectory(this->SourceDirectory.toLocal8Bit().data());
- this->CMakeInstance->SetHomeOutputDirectory(this->BinaryDirectory.toLocal8Bit().data());
+ this->CMakeInstance->SetHomeDirectory(
+ this->SourceDirectory.toLocal8Bit().data());
+ this->CMakeInstance->SetHomeOutputDirectory(
+ this->BinaryDirectory.toLocal8Bit().data());
this->CMakeInstance->SetGlobalGenerator(
- this->CMakeInstance->CreateGlobalGenerator(this->Generator.toLocal8Bit().data()));
+ this->CMakeInstance->CreateGlobalGenerator(
+ this->Generator.toLocal8Bit().data()));
this->CMakeInstance->SetGeneratorPlatform("");
this->CMakeInstance->SetGeneratorToolset(this->Toolset.toLocal8Bit().data());
this->CMakeInstance->LoadCache();
@@ -210,82 +204,59 @@ void QCMake::setProperties(const QCMakePropertyList& newProps)
// set the value of properties
cmState* state = this->CMakeInstance->GetState();
std::vector<std::string> cacheKeys = state->GetCacheEntryKeys();
- for(std::vector<std::string>::const_iterator it = cacheKeys.begin();
- it != cacheKeys.end(); ++it)
- {
+ for (std::vector<std::string>::const_iterator it = cacheKeys.begin();
+ it != cacheKeys.end(); ++it) {
cmState::CacheEntryType t = state->GetCacheEntryType(*it);
- if(t == cmState::INTERNAL ||
- t == cmState::STATIC)
- {
+ if (t == cmState::INTERNAL || t == cmState::STATIC) {
continue;
- }
+ }
QCMakeProperty prop;
prop.Key = QString::fromLocal8Bit(it->c_str());
int idx = props.indexOf(prop);
- if(idx == -1)
- {
+ if (idx == -1) {
toremove.append(QString::fromLocal8Bit(it->c_str()));
- }
- else
- {
+ } else {
prop = props[idx];
- if(prop.Value.type() == QVariant::Bool)
- {
+ if (prop.Value.type() == QVariant::Bool) {
state->SetCacheEntryValue(*it, prop.Value.toBool() ? "ON" : "OFF");
- }
- else
- {
+ } else {
state->SetCacheEntryValue(*it,
- prop.Value.toString().toLocal8Bit().data());
- }
- props.removeAt(idx);
+ prop.Value.toString().toLocal8Bit().data());
}
-
+ props.removeAt(idx);
}
+ }
// remove some properites
- foreach(QString s, toremove)
- {
+ foreach (QString s, toremove) {
this->CMakeInstance->UnwatchUnusedCli(s.toLocal8Bit().data());
state->RemoveCacheEntry(s.toLocal8Bit().data());
- }
+ }
// add some new properites
- foreach(QCMakeProperty s, props)
- {
+ foreach (QCMakeProperty s, props) {
this->CMakeInstance->WatchUnusedCli(s.Key.toLocal8Bit().data());
- if(s.Type == QCMakeProperty::BOOL)
- {
- this->CMakeInstance->AddCacheEntry(s.Key.toLocal8Bit().data(),
- s.Value.toBool() ? "ON" : "OFF",
- s.Help.toLocal8Bit().data(),
- cmState::BOOL);
- }
- else if(s.Type == QCMakeProperty::STRING)
- {
- this->CMakeInstance->AddCacheEntry(s.Key.toLocal8Bit().data(),
- s.Value.toString().toLocal8Bit().data(),
- s.Help.toLocal8Bit().data(),
- cmState::STRING);
- }
- else if(s.Type == QCMakeProperty::PATH)
- {
- this->CMakeInstance->AddCacheEntry(s.Key.toLocal8Bit().data(),
- s.Value.toString().toLocal8Bit().data(),
- s.Help.toLocal8Bit().data(),
- cmState::PATH);
- }
- else if(s.Type == QCMakeProperty::FILEPATH)
- {
- this->CMakeInstance->AddCacheEntry(s.Key.toLocal8Bit().data(),
- s.Value.toString().toLocal8Bit().data(),
- s.Help.toLocal8Bit().data(),
- cmState::FILEPATH);
- }
+ if (s.Type == QCMakeProperty::BOOL) {
+ this->CMakeInstance->AddCacheEntry(
+ s.Key.toLocal8Bit().data(), s.Value.toBool() ? "ON" : "OFF",
+ s.Help.toLocal8Bit().data(), cmState::BOOL);
+ } else if (s.Type == QCMakeProperty::STRING) {
+ this->CMakeInstance->AddCacheEntry(
+ s.Key.toLocal8Bit().data(), s.Value.toString().toLocal8Bit().data(),
+ s.Help.toLocal8Bit().data(), cmState::STRING);
+ } else if (s.Type == QCMakeProperty::PATH) {
+ this->CMakeInstance->AddCacheEntry(
+ s.Key.toLocal8Bit().data(), s.Value.toString().toLocal8Bit().data(),
+ s.Help.toLocal8Bit().data(), cmState::PATH);
+ } else if (s.Type == QCMakeProperty::FILEPATH) {
+ this->CMakeInstance->AddCacheEntry(
+ s.Key.toLocal8Bit().data(), s.Value.toString().toLocal8Bit().data(),
+ s.Help.toLocal8Bit().data(), cmState::FILEPATH);
}
+ }
this->CMakeInstance->SaveCache(this->BinaryDirectory.toLocal8Bit().data());
}
@@ -297,50 +268,39 @@ QCMakePropertyList QCMake::properties() const
cmState* state = this->CMakeInstance->GetState();
std::vector<std::string> cacheKeys = state->GetCacheEntryKeys();
for (std::vector<std::string>::const_iterator i = cacheKeys.begin();
- i != cacheKeys.end(); ++i)
- {
+ i != cacheKeys.end(); ++i) {
cmState::CacheEntryType t = state->GetCacheEntryType(*i);
- if(t == cmState::INTERNAL ||
- t == cmState::STATIC ||
- t == cmState::UNINITIALIZED)
- {
+ if (t == cmState::INTERNAL || t == cmState::STATIC ||
+ t == cmState::UNINITIALIZED) {
continue;
- }
+ }
const char* cachedValue = state->GetCacheEntryValue(*i);
QCMakeProperty prop;
prop.Key = QString::fromLocal8Bit(i->c_str());
- prop.Help = QString::fromLocal8Bit(
- state->GetCacheEntryProperty(*i, "HELPSTRING"));
+ prop.Help =
+ QString::fromLocal8Bit(state->GetCacheEntryProperty(*i, "HELPSTRING"));
prop.Value = QString::fromLocal8Bit(cachedValue);
prop.Advanced = state->GetCacheEntryPropertyAsBool(*i, "ADVANCED");
- if(t == cmState::BOOL)
- {
+ if (t == cmState::BOOL) {
prop.Type = QCMakeProperty::BOOL;
prop.Value = cmSystemTools::IsOn(cachedValue);
- }
- else if(t == cmState::PATH)
- {
+ } else if (t == cmState::PATH) {
prop.Type = QCMakeProperty::PATH;
- }
- else if(t == cmState::FILEPATH)
- {
+ } else if (t == cmState::FILEPATH) {
prop.Type = QCMakeProperty::FILEPATH;
- }
- else if(t == cmState::STRING)
- {
+ } else if (t == cmState::STRING) {
prop.Type = QCMakeProperty::STRING;
const char* stringsProperty =
- state->GetCacheEntryProperty(*i, "STRINGS");
- if (stringsProperty)
- {
+ state->GetCacheEntryProperty(*i, "STRINGS");
+ if (stringsProperty) {
prop.Strings = QString::fromLocal8Bit(stringsProperty).split(";");
- }
}
+ }
ret.append(prop);
- }
+ }
return ret;
}
@@ -363,14 +323,11 @@ bool QCMake::interruptCallback(void* cd)
void QCMake::progressCallback(const char* msg, float percent, void* cd)
{
QCMake* self = reinterpret_cast<QCMake*>(cd);
- if(percent >= 0)
- {
+ if (percent >= 0) {
emit self->progressChanged(QString::fromLocal8Bit(msg), percent);
- }
- else
- {
+ } else {
emit self->outputMessage(QString::fromLocal8Bit(msg));
- }
+ }
QCoreApplication::processEvents();
}
@@ -385,14 +342,14 @@ void QCMake::messageCallback(const char* msg, const char* /*title*/,
void QCMake::stdoutCallback(const char* msg, size_t len, void* cd)
{
QCMake* self = reinterpret_cast<QCMake*>(cd);
- emit self->outputMessage(QString::fromLocal8Bit(msg,int(len)));
+ emit self->outputMessage(QString::fromLocal8Bit(msg, int(len)));
QCoreApplication::processEvents();
}
void QCMake::stderrCallback(const char* msg, size_t len, void* cd)
{
QCMake* self = reinterpret_cast<QCMake*>(cd);
- emit self->outputMessage(QString::fromLocal8Bit(msg,int(len)));
+ emit self->outputMessage(QString::fromLocal8Bit(msg, int(len)));
QCoreApplication::processEvents();
}
@@ -443,11 +400,10 @@ void QCMake::reloadCache()
void QCMake::setDebugOutput(bool flag)
{
- if(flag != this->CMakeInstance->GetDebugOutput())
- {
+ if (flag != this->CMakeInstance->GetDebugOutput()) {
this->CMakeInstance->SetDebugOutputOn(flag);
emit this->debugOutputChanged(flag);
- }
+ }
}
bool QCMake::getDebugOutput() const
diff --git a/Source/QtDialog/QCMake.h b/Source/QtDialog/QCMake.h
index 5cae06d..a818c6b 100644
--- a/Source/QtDialog/QCMake.h
+++ b/Source/QtDialog/QCMake.h
@@ -16,8 +16,8 @@
#include "cmake.h"
#ifdef _MSC_VER
-#pragma warning ( disable : 4127 )
-#pragma warning ( disable : 4512 )
+#pragma warning(disable : 4127)
+#pragma warning(disable : 4512)
#endif
#include <vector>
@@ -34,7 +34,13 @@
/// Value is of type String or Bool
struct QCMakeProperty
{
- enum PropertyType { BOOL, PATH, FILEPATH, STRING };
+ enum PropertyType
+ {
+ BOOL,
+ PATH,
+ FILEPATH,
+ STRING
+ };
QString Key;
QVariant Value;
QStringList Strings;
@@ -42,13 +48,13 @@ struct QCMakeProperty
PropertyType Type;
bool Advanced;
bool operator==(const QCMakeProperty& other) const
- {
+ {
return this->Key == other.Key;
- }
+ }
bool operator<(const QCMakeProperty& other) const
- {
+ {
return this->Key < other.Key;
- }
+ }
};
// list of properties
@@ -65,7 +71,7 @@ class QCMake : public QObject
{
Q_OBJECT
public:
- QCMake(QObject* p=0);
+ QCMake(QObject* p = 0);
~QCMake();
public slots:
/// load the cache file in a directory
@@ -84,7 +90,8 @@ public slots:
void generate();
/// set the property values
void setProperties(const QCMakePropertyList&);
- /// interrupt the configure or generate process (if connecting, make a direct connection)
+ /// interrupt the configure or generate process (if connecting, make a direct
+ /// connection)
void interrupt();
/// delete the cache in binary directory
void deleteCache();
@@ -128,7 +135,8 @@ public:
bool getDebugOutput() const;
signals:
- /// signal when properties change (during read from disk or configure process)
+ /// signal when properties change (during read from disk or configure
+ /// process)
void propertiesChanged(const QCMakePropertyList& vars);
/// signal when the generator changes
void generatorChanged(const QString& gen);
@@ -157,8 +165,8 @@ protected:
static bool interruptCallback(void*);
static void progressCallback(const char* msg, float percent, void* cd);
- static void messageCallback(const char* msg, const char* title,
- bool&, void* cd);
+ static void messageCallback(const char* msg, const char* title, bool&,
+ void* cd);
static void stdoutCallback(const char* msg, size_t len, void* cd);
static void stderrCallback(const char* msg, size_t len, void* cd);
bool WarnUninitializedMode;
@@ -174,4 +182,3 @@ protected:
};
#endif // QCMake_h
-
diff --git a/Source/QtDialog/QCMakeCacheView.cxx b/Source/QtDialog/QCMakeCacheView.cxx
index f64a78a..cc1f4aa 100644
--- a/Source/QtDialog/QCMakeCacheView.cxx
+++ b/Source/QtDialog/QCMakeCacheView.cxx
@@ -27,46 +27,44 @@
class QCMakeSearchFilter : public QSortFilterProxyModel
{
public:
- QCMakeSearchFilter(QObject* o) : QSortFilterProxyModel(o) {}
+ QCMakeSearchFilter(QObject* o)
+ : QSortFilterProxyModel(o)
+ {
+ }
+
protected:
bool filterAcceptsRow(int row, const QModelIndex& p) const
- {
+ {
QStringList strs;
const QAbstractItemModel* m = this->sourceModel();
QModelIndex idx = m->index(row, 0, p);
// if there are no children, get strings for column 0 and 1
- if(!m->hasChildren(idx))
- {
+ if (!m->hasChildren(idx)) {
strs.append(m->data(idx).toString());
idx = m->index(row, 1, p);
strs.append(m->data(idx).toString());
- }
- else
- {
+ } else {
// get strings for children entries to compare with
// instead of comparing with the parent
int num = m->rowCount(idx);
- for(int i=0; i<num; i++)
- {
+ for (int i = 0; i < num; i++) {
QModelIndex tmpidx = m->index(i, 0, idx);
strs.append(m->data(tmpidx).toString());
tmpidx = m->index(i, 1, idx);
strs.append(m->data(tmpidx).toString());
- }
}
+ }
// check all strings for a match
- foreach(QString str, strs)
- {
- if(str.contains(this->filterRegExp()))
- {
+ foreach (QString str, strs) {
+ if (str.contains(this->filterRegExp())) {
return true;
- }
}
+ }
return false;
- }
+ }
};
// filter for searches
@@ -74,7 +72,10 @@ class QCMakeAdvancedFilter : public QSortFilterProxyModel
{
public:
QCMakeAdvancedFilter(QObject* o)
- : QSortFilterProxyModel(o), ShowAdvanced(false) {}
+ : QSortFilterProxyModel(o)
+ , ShowAdvanced(false)
+ {
+ }
void setShowAdvanced(bool f)
{
@@ -84,37 +85,32 @@ public:
bool showAdvanced() const { return this->ShowAdvanced; }
protected:
-
bool ShowAdvanced;
bool filterAcceptsRow(int row, const QModelIndex& p) const
- {
+ {
const QAbstractItemModel* m = this->sourceModel();
QModelIndex idx = m->index(row, 0, p);
// if there are no children
- if(!m->hasChildren(idx))
- {
+ if (!m->hasChildren(idx)) {
bool adv = m->data(idx, QCMakeCacheModel::AdvancedRole).toBool();
- if(!adv || (adv && this->ShowAdvanced))
- {
+ if (!adv || (adv && this->ShowAdvanced)) {
return true;
- }
- return false;
}
+ return false;
+ }
// check children
int num = m->rowCount(idx);
- for(int i=0; i<num; i++)
- {
+ for (int i = 0; i < num; i++) {
bool accept = this->filterAcceptsRow(i, idx);
- if(accept)
- {
+ if (accept) {
return true;
- }
}
- return false;
}
+ return false;
+ }
};
QCMakeCacheView::QCMakeCacheView(QWidget* p)
@@ -147,10 +143,9 @@ QCMakeCacheView::QCMakeCacheView(QWidget* p)
bool QCMakeCacheView::event(QEvent* e)
{
- if(e->type() == QEvent::Show)
- {
- this->header()->setDefaultSectionSize(this->viewport()->width()/2);
- }
+ if (e->type() == QEvent::Show) {
+ this->header()->setDefaultSectionSize(this->viewport()->width() / 2);
+ }
return QTreeView::event(e);
}
@@ -160,17 +155,14 @@ QCMakeCacheModel* QCMakeCacheView::cacheModel() const
}
QModelIndex QCMakeCacheView::moveCursor(CursorAction act,
- Qt::KeyboardModifiers mod)
+ Qt::KeyboardModifiers mod)
{
// want home/end to go to begin/end of rows, not columns
- if(act == MoveHome)
- {
+ if (act == MoveHome) {
return this->model()->index(0, 1);
- }
- else if(act == MoveEnd)
- {
- return this->model()->index(this->model()->rowCount()-1, 1);
- }
+ } else if (act == MoveEnd) {
+ return this->model()->index(this->model()->rowCount() - 1, 1);
+ }
return QTreeView::moveCursor(act, mod);
}
@@ -195,10 +187,10 @@ void QCMakeCacheView::setSearchFilter(const QString& s)
}
QCMakeCacheModel::QCMakeCacheModel(QObject* p)
- : QStandardItemModel(p),
- EditEnabled(true),
- NewPropertyCount(0),
- View(FlatView)
+ : QStandardItemModel(p)
+ , EditEnabled(true)
+ , NewPropertyCount(0)
+ , View(FlatView)
{
this->ShowNewProperties = true;
QStringList labels;
@@ -234,47 +226,39 @@ void QCMakeCacheModel::setProperties(const QCMakePropertyList& props)
{
QSet<QCMakeProperty> newProps, newProps2;
- if(this->ShowNewProperties)
- {
+ if (this->ShowNewProperties) {
newProps = props.toSet();
newProps2 = newProps;
QSet<QCMakeProperty> oldProps = this->properties().toSet();
oldProps.intersect(newProps);
newProps.subtract(oldProps);
newProps2.subtract(newProps);
- }
- else
- {
+ } else {
newProps2 = props.toSet();
- }
+ }
bool b = this->blockSignals(true);
this->clear();
this->NewPropertyCount = newProps.size();
- if(View == FlatView)
- {
+ if (View == FlatView) {
QCMakePropertyList newP = newProps.toList();
QCMakePropertyList newP2 = newProps2.toList();
qSort(newP);
qSort(newP2);
int row_count = 0;
- foreach(QCMakeProperty p, newP)
- {
+ foreach (QCMakeProperty p, newP) {
this->insertRow(row_count);
this->setPropertyData(this->index(row_count, 0), p, true);
row_count++;
}
- foreach(QCMakeProperty p, newP2)
- {
+ foreach (QCMakeProperty p, newP2) {
this->insertRow(row_count);
this->setPropertyData(this->index(row_count, 0), p, false);
row_count++;
}
- }
- else if(this->View == GroupView)
- {
+ } else if (this->View == GroupView) {
QMap<QString, QCMakePropertyList> newPropsTree;
this->breakProperties(newProps, newPropsTree);
QMap<QString, QCMakePropertyList> newPropsTree2;
@@ -282,35 +266,33 @@ void QCMakeCacheModel::setProperties(const QCMakePropertyList& props)
QStandardItem* root = this->invisibleRootItem();
- foreach(QString key, newPropsTree.keys())
- {
+ foreach (QString key, newPropsTree.keys()) {
QCMakePropertyList props2 = newPropsTree[key];
QList<QStandardItem*> parentItems;
parentItems.append(
- new QStandardItem(key.isEmpty() ? tr("Ungrouped Entries") : key)
- );
+ new QStandardItem(key.isEmpty() ? tr("Ungrouped Entries") : key));
parentItems.append(new QStandardItem());
- parentItems[0]->setData(QBrush(QColor(255,100,100)), Qt::BackgroundColorRole);
- parentItems[1]->setData(QBrush(QColor(255,100,100)), Qt::BackgroundColorRole);
+ parentItems[0]->setData(QBrush(QColor(255, 100, 100)),
+ Qt::BackgroundColorRole);
+ parentItems[1]->setData(QBrush(QColor(255, 100, 100)),
+ Qt::BackgroundColorRole);
parentItems[0]->setData(1, GroupRole);
parentItems[1]->setData(1, GroupRole);
root->appendRow(parentItems);
int num = props2.size();
- for(int i=0; i<num; i++)
- {
+ for (int i = 0; i < num; i++) {
QCMakeProperty prop = props2[i];
QList<QStandardItem*> items;
items.append(new QStandardItem());
items.append(new QStandardItem());
parentItems[0]->appendRow(items);
this->setPropertyData(this->indexFromItem(items[0]), prop, true);
- }
}
+ }
- foreach(QString key, newPropsTree2.keys())
- {
+ foreach (QString key, newPropsTree2.keys()) {
QCMakePropertyList props2 = newPropsTree2[key];
QStandardItem* parentItem =
@@ -319,16 +301,15 @@ void QCMakeCacheModel::setProperties(const QCMakePropertyList& props)
parentItem->setData(1, GroupRole);
int num = props2.size();
- for(int i=0; i<num; i++)
- {
+ for (int i = 0; i < num; i++) {
QCMakeProperty prop = props2[i];
QList<QStandardItem*> items;
items.append(new QStandardItem());
items.append(new QStandardItem());
parentItem->appendRow(items);
this->setPropertyData(this->indexFromItem(items[0]), prop, false);
- }
}
+ }
}
this->blockSignals(b);
@@ -348,8 +329,7 @@ void QCMakeCacheModel::setViewType(QCMakeCacheModel::ViewType t)
QCMakePropertyList oldProps;
int numNew = this->NewPropertyCount;
int numTotal = props.count();
- for(int i=numNew; i<numTotal; i++)
- {
+ for (int i = numNew; i < numTotal; i++) {
oldProps.append(props[i]);
}
@@ -362,7 +342,7 @@ void QCMakeCacheModel::setViewType(QCMakeCacheModel::ViewType t)
}
void QCMakeCacheModel::setPropertyData(const QModelIndex& idx1,
- const QCMakeProperty& prop, bool isNew)
+ const QCMakeProperty& prop, bool isNew)
{
QModelIndex idx2 = idx1.sibling(idx1.row(), 1);
@@ -371,46 +351,42 @@ void QCMakeCacheModel::setPropertyData(const QModelIndex& idx1,
this->setData(idx1, prop.Type, QCMakeCacheModel::TypeRole);
this->setData(idx1, prop.Advanced, QCMakeCacheModel::AdvancedRole);
- if(prop.Type == QCMakeProperty::BOOL)
- {
+ if (prop.Type == QCMakeProperty::BOOL) {
int check = prop.Value.toBool() ? Qt::Checked : Qt::Unchecked;
this->setData(idx2, check, Qt::CheckStateRole);
- }
- else
- {
+ } else {
this->setData(idx2, prop.Value, Qt::DisplayRole);
}
this->setData(idx2, prop.Help, QCMakeCacheModel::HelpRole);
- if (!prop.Strings.isEmpty())
- {
+ if (!prop.Strings.isEmpty()) {
this->setData(idx1, prop.Strings, QCMakeCacheModel::StringsRole);
}
- if(isNew)
- {
- this->setData(idx1, QBrush(QColor(255,100,100)), Qt::BackgroundColorRole);
- this->setData(idx2, QBrush(QColor(255,100,100)), Qt::BackgroundColorRole);
+ if (isNew) {
+ this->setData(idx1, QBrush(QColor(255, 100, 100)),
+ Qt::BackgroundColorRole);
+ this->setData(idx2, QBrush(QColor(255, 100, 100)),
+ Qt::BackgroundColorRole);
}
}
void QCMakeCacheModel::getPropertyData(const QModelIndex& idx1,
- QCMakeProperty& prop) const
+ QCMakeProperty& prop) const
{
QModelIndex idx2 = idx1.sibling(idx1.row(), 1);
prop.Key = this->data(idx1, Qt::DisplayRole).toString();
prop.Help = this->data(idx1, HelpRole).toString();
- prop.Type = static_cast<QCMakeProperty::PropertyType>(this->data(idx1, TypeRole).toInt());
+ prop.Type = static_cast<QCMakeProperty::PropertyType>(
+ this->data(idx1, TypeRole).toInt());
prop.Advanced = this->data(idx1, AdvancedRole).toBool();
- prop.Strings = this->data(idx1, QCMakeCacheModel::StringsRole).toStringList();
- if(prop.Type == QCMakeProperty::BOOL)
- {
+ prop.Strings =
+ this->data(idx1, QCMakeCacheModel::StringsRole).toStringList();
+ if (prop.Type == QCMakeProperty::BOOL) {
int check = this->data(idx2, Qt::CheckStateRole).toInt();
prop.Value = check == Qt::Checked;
- }
- else
- {
+ } else {
prop.Value = this->data(idx2, Qt::DisplayRole).toString();
}
}
@@ -418,43 +394,36 @@ void QCMakeCacheModel::getPropertyData(const QModelIndex& idx1,
QString QCMakeCacheModel::prefix(const QString& s)
{
QString prefix = s.section('_', 0, 0);
- if(prefix == s)
- {
+ if (prefix == s) {
prefix = QString();
- }
+ }
return prefix;
}
-void QCMakeCacheModel::breakProperties(const QSet<QCMakeProperty>& props,
- QMap<QString, QCMakePropertyList>& result)
+void QCMakeCacheModel::breakProperties(
+ const QSet<QCMakeProperty>& props, QMap<QString, QCMakePropertyList>& result)
{
QMap<QString, QCMakePropertyList> tmp;
// return a map of properties grouped by prefixes, and sorted
- foreach(QCMakeProperty p, props)
- {
+ foreach (QCMakeProperty p, props) {
QString prefix = QCMakeCacheModel::prefix(p.Key);
tmp[prefix].append(p);
- }
+ }
// sort it and re-org any properties with only one sub item
QCMakePropertyList reorgProps;
QMap<QString, QCMakePropertyList>::iterator iter;
- for(iter = tmp.begin(); iter != tmp.end();)
- {
- if(iter->count() == 1)
- {
+ for (iter = tmp.begin(); iter != tmp.end();) {
+ if (iter->count() == 1) {
reorgProps.append((*iter)[0]);
iter = tmp.erase(iter);
- }
- else
- {
+ } else {
qSort(*iter);
++iter;
- }
}
- if(reorgProps.count())
- {
+ }
+ if (reorgProps.count()) {
tmp[QString()] += reorgProps;
- }
+ }
result = tmp;
}
@@ -462,27 +431,21 @@ QCMakePropertyList QCMakeCacheModel::properties() const
{
QCMakePropertyList props;
- if(!this->rowCount())
- {
+ if (!this->rowCount()) {
return props;
- }
+ }
QList<QModelIndex> idxs;
- idxs.append(this->index(0,0));
+ idxs.append(this->index(0, 0));
// walk the entire model for property entries
// this works regardless of a flat view or a tree view
- while(!idxs.isEmpty())
- {
+ while (!idxs.isEmpty()) {
QModelIndex idx = idxs.last();
- if(this->hasChildren(idx) && this->rowCount(idx))
- {
- idxs.append(this->index(0,0, idx));
- }
- else
- {
- if(!data(idx, GroupRole).toInt())
- {
+ if (this->hasChildren(idx) && this->rowCount(idx)) {
+ idxs.append(this->index(0, 0, idx));
+ } else {
+ if (!data(idx, GroupRole).toInt()) {
// get data
QCMakeProperty prop;
this->getPropertyData(idx, prop);
@@ -490,17 +453,17 @@ QCMakePropertyList QCMakeCacheModel::properties() const
}
// go to the next in the tree
- while(!idxs.isEmpty() && (
-#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) && QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
- (idxs.last().row()+1) >= rowCount(idxs.last().parent()) ||
+ while (!idxs.isEmpty() &&
+ (
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) && \
+ QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
+ (idxs.last().row() + 1) >= rowCount(idxs.last().parent()) ||
#endif
- !idxs.last().sibling(idxs.last().row()+1, 0).isValid()))
- {
+ !idxs.last().sibling(idxs.last().row() + 1, 0).isValid())) {
idxs.removeLast();
}
- if(!idxs.isEmpty())
- {
- idxs.last() = idxs.last().sibling(idxs.last().row()+1, 0);
+ if (!idxs.isEmpty()) {
+ idxs.last() = idxs.last().sibling(idxs.last().row() + 1, 0);
}
}
}
@@ -509,8 +472,9 @@ QCMakePropertyList QCMakeCacheModel::properties() const
}
bool QCMakeCacheModel::insertProperty(QCMakeProperty::PropertyType t,
- const QString& name, const QString& description,
- const QVariant& value, bool advanced)
+ const QString& name,
+ const QString& description,
+ const QVariant& value, bool advanced)
{
QCMakeProperty prop;
prop.Key = name;
@@ -519,9 +483,9 @@ bool QCMakeCacheModel::insertProperty(QCMakeProperty::PropertyType t,
prop.Type = t;
prop.Advanced = advanced;
- //insert at beginning
+ // insert at beginning
this->insertRow(0);
- this->setPropertyData(this->index(0,0), prop, true);
+ this->setPropertyData(this->index(0, 0), prop, true);
this->NewPropertyCount++;
return true;
}
@@ -541,33 +505,31 @@ int QCMakeCacheModel::newPropertyCount() const
return this->NewPropertyCount;
}
-Qt::ItemFlags QCMakeCacheModel::flags (const QModelIndex& idx) const
+Qt::ItemFlags QCMakeCacheModel::flags(const QModelIndex& idx) const
{
Qt::ItemFlags f = QStandardItemModel::flags(idx);
- if(!this->EditEnabled)
- {
+ if (!this->EditEnabled) {
f &= ~Qt::ItemIsEditable;
return f;
- }
- if(QCMakeProperty::BOOL == this->data(idx, TypeRole).toInt())
- {
+ }
+ if (QCMakeProperty::BOOL == this->data(idx, TypeRole).toInt()) {
f |= Qt::ItemIsUserCheckable;
- }
+ }
return f;
}
QModelIndex QCMakeCacheModel::buddy(const QModelIndex& idx) const
{
- if(!this->hasChildren(idx) &&
- this->data(idx, TypeRole).toInt() != QCMakeProperty::BOOL)
- {
+ if (!this->hasChildren(idx) &&
+ this->data(idx, TypeRole).toInt() != QCMakeProperty::BOOL) {
return this->index(idx.row(), 1, idx.parent());
}
return idx;
}
QCMakeCacheModelDelegate::QCMakeCacheModelDelegate(QObject* p)
- : QItemDelegate(p), FileDialogFlag(false)
+ : QItemDelegate(p)
+ , FileDialogFlag(false)
{
}
@@ -577,91 +539,77 @@ void QCMakeCacheModelDelegate::setFileDialogFlag(bool f)
}
QWidget* QCMakeCacheModelDelegate::createEditor(QWidget* p,
- const QStyleOptionViewItem&, const QModelIndex& idx) const
+ const QStyleOptionViewItem&,
+ const QModelIndex& idx) const
{
QModelIndex var = idx.sibling(idx.row(), 0);
int type = var.data(QCMakeCacheModel::TypeRole).toInt();
- if(type == QCMakeProperty::BOOL)
- {
+ if (type == QCMakeProperty::BOOL) {
return NULL;
- }
- else if(type == QCMakeProperty::PATH)
- {
+ } else if (type == QCMakeProperty::PATH) {
QCMakePathEditor* editor =
- new QCMakePathEditor(p,
- var.data(Qt::DisplayRole).toString());
+ new QCMakePathEditor(p, var.data(Qt::DisplayRole).toString());
QObject::connect(editor, SIGNAL(fileDialogExists(bool)), this,
- SLOT(setFileDialogFlag(bool)));
+ SLOT(setFileDialogFlag(bool)));
return editor;
- }
- else if(type == QCMakeProperty::FILEPATH)
- {
+ } else if (type == QCMakeProperty::FILEPATH) {
QCMakeFilePathEditor* editor =
- new QCMakeFilePathEditor(p,
- var.data(Qt::DisplayRole).toString());
+ new QCMakeFilePathEditor(p, var.data(Qt::DisplayRole).toString());
QObject::connect(editor, SIGNAL(fileDialogExists(bool)), this,
- SLOT(setFileDialogFlag(bool)));
+ SLOT(setFileDialogFlag(bool)));
return editor;
- }
- else if(type == QCMakeProperty::STRING &&
- var.data(QCMakeCacheModel::StringsRole).isValid())
- {
- QCMakeComboBox* editor =
- new QCMakeComboBox(p, var.data(QCMakeCacheModel::StringsRole).toStringList());
+ } else if (type == QCMakeProperty::STRING &&
+ var.data(QCMakeCacheModel::StringsRole).isValid()) {
+ QCMakeComboBox* editor = new QCMakeComboBox(
+ p, var.data(QCMakeCacheModel::StringsRole).toStringList());
editor->setFrame(false);
return editor;
- }
+ }
QLineEdit* editor = new QLineEdit(p);
editor->setFrame(false);
return editor;
}
-bool QCMakeCacheModelDelegate::editorEvent(QEvent* e, QAbstractItemModel* model,
- const QStyleOptionViewItem& option, const QModelIndex& index)
+bool QCMakeCacheModelDelegate::editorEvent(QEvent* e,
+ QAbstractItemModel* model,
+ const QStyleOptionViewItem& option,
+ const QModelIndex& index)
{
Qt::ItemFlags flags = model->flags(index);
- if (!(flags & Qt::ItemIsUserCheckable) || !(option.state & QStyle::State_Enabled)
- || !(flags & Qt::ItemIsEnabled))
- {
+ if (!(flags & Qt::ItemIsUserCheckable) ||
+ !(option.state & QStyle::State_Enabled) ||
+ !(flags & Qt::ItemIsEnabled)) {
return false;
- }
+ }
QVariant value = index.data(Qt::CheckStateRole);
- if (!value.isValid())
- {
+ if (!value.isValid()) {
return false;
- }
+ }
- if ((e->type() == QEvent::MouseButtonRelease)
- || (e->type() == QEvent::MouseButtonDblClick))
- {
+ if ((e->type() == QEvent::MouseButtonRelease) ||
+ (e->type() == QEvent::MouseButtonDblClick)) {
// eat the double click events inside the check rect
- if (e->type() == QEvent::MouseButtonDblClick)
- {
+ if (e->type() == QEvent::MouseButtonDblClick) {
return true;
- }
}
- else if (e->type() == QEvent::KeyPress)
- {
- if(static_cast<QKeyEvent*>(e)->key() != Qt::Key_Space &&
- static_cast<QKeyEvent*>(e)->key() != Qt::Key_Select)
- {
+ } else if (e->type() == QEvent::KeyPress) {
+ if (static_cast<QKeyEvent*>(e)->key() != Qt::Key_Space &&
+ static_cast<QKeyEvent*>(e)->key() != Qt::Key_Select) {
return false;
- }
}
- else
- {
+ } else {
return false;
- }
+ }
- Qt::CheckState state = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked
- ? Qt::Unchecked : Qt::Checked);
+ Qt::CheckState state =
+ (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked ? Qt::Unchecked
+ : Qt::Checked);
bool success = model->setData(index, state, Qt::CheckStateRole);
- if(success)
- {
+ if (success) {
this->recordChange(model, index);
- }
+ }
return success;
}
@@ -673,29 +621,32 @@ bool QCMakeCacheModelDelegate::eventFilter(QObject* object, QEvent* evt)
// where it doesn't create a QWidget wrapper for the native file dialog
// so the Qt library ends up assuming the focus was lost to something else
- if(evt->type() == QEvent::FocusOut && this->FileDialogFlag)
- {
+ if (evt->type() == QEvent::FocusOut && this->FileDialogFlag) {
return false;
- }
+ }
return QItemDelegate::eventFilter(object, evt);
}
void QCMakeCacheModelDelegate::setModelData(QWidget* editor,
- QAbstractItemModel* model, const QModelIndex& index ) const
+ QAbstractItemModel* model,
+ const QModelIndex& index) const
{
QItemDelegate::setModelData(editor, model, index);
const_cast<QCMakeCacheModelDelegate*>(this)->recordChange(model, index);
}
-QSize QCMakeCacheModelDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const
+QSize QCMakeCacheModelDelegate::sizeHint(const QStyleOptionViewItem& option,
+ const QModelIndex& index) const
{
QSize sz = QItemDelegate::sizeHint(option, index);
- QStyle *style = QApplication::style();
+ QStyle* style = QApplication::style();
// increase to checkbox size
QStyleOptionButton opt;
opt.QStyleOption::operator=(option);
- sz = sz.expandedTo(style->subElementRect(QStyle::SE_ViewItemCheckIndicator, &opt, NULL).size());
+ sz = sz.expandedTo(
+ style->subElementRect(QStyle::SE_ViewItemCheckIndicator, &opt, NULL)
+ .size());
return sz;
}
@@ -710,30 +661,27 @@ void QCMakeCacheModelDelegate::clearChanges()
mChanges.clear();
}
-void QCMakeCacheModelDelegate::recordChange(QAbstractItemModel* model, const QModelIndex& index)
+void QCMakeCacheModelDelegate::recordChange(QAbstractItemModel* model,
+ const QModelIndex& index)
{
QModelIndex idx = index;
QAbstractItemModel* mymodel = model;
- while(qobject_cast<QAbstractProxyModel*>(mymodel))
- {
+ while (qobject_cast<QAbstractProxyModel*>(mymodel)) {
idx = static_cast<QAbstractProxyModel*>(mymodel)->mapToSource(idx);
mymodel = static_cast<QAbstractProxyModel*>(mymodel)->sourceModel();
- }
+ }
QCMakeCacheModel* cache_model = qobject_cast<QCMakeCacheModel*>(mymodel);
- if(cache_model && idx.isValid())
- {
+ if (cache_model && idx.isValid()) {
QCMakeProperty prop;
idx = idx.sibling(idx.row(), 0);
cache_model->getPropertyData(idx, prop);
// clean out an old one
QSet<QCMakeProperty>::iterator iter = mChanges.find(prop);
- if(iter != mChanges.end())
- {
+ if (iter != mChanges.end()) {
mChanges.erase(iter);
- }
+ }
// now add the new item
mChanges.insert(prop);
- }
+ }
}
-
diff --git a/Source/QtDialog/QCMakeCacheView.h b/Source/QtDialog/QCMakeCacheView.h
index 5631b86..6ad56fb 100644
--- a/Source/QtDialog/QCMakeCacheView.h
+++ b/Source/QtDialog/QCMakeCacheView.h
@@ -38,7 +38,7 @@ public:
// get whether to show advanced entries
bool showAdvanced() const;
- QSize sizeHint() const { return QSize(200,200); }
+ QSize sizeHint() const { return QSize(200, 200); }
public slots:
// set whether to show advanced entries
@@ -65,14 +65,20 @@ public:
// roles used to retrieve extra data such has help strings, types of
// properties, and the advanced flag
- enum { HelpRole = Qt::ToolTipRole,
- TypeRole = Qt::UserRole,
- AdvancedRole,
- StringsRole,
- GroupRole
- };
-
- enum ViewType { FlatView, GroupView };
+ enum
+ {
+ HelpRole = Qt::ToolTipRole,
+ TypeRole = Qt::UserRole,
+ AdvancedRole,
+ StringsRole,
+ GroupRole
+ };
+
+ enum ViewType
+ {
+ FlatView,
+ GroupView
+ };
public slots:
// set a list of properties. This list will be sorted and grouped according
@@ -92,9 +98,9 @@ public slots:
// insert a new property at a row specifying all the information about the
// property
- bool insertProperty(QCMakeProperty::PropertyType t,
- const QString& name, const QString& description,
- const QVariant& value, bool advanced);
+ bool insertProperty(QCMakeProperty::PropertyType t, const QString& name,
+ const QString& description, const QVariant& value,
+ bool advanced);
// set the view type
void setViewType(ViewType t);
@@ -111,12 +117,11 @@ public:
int newPropertyCount() const;
// return flags (overloaded to modify flag based on EditEnabled flag)
- Qt::ItemFlags flags (const QModelIndex& index) const;
+ Qt::ItemFlags flags(const QModelIndex& index) const;
QModelIndex buddy(const QModelIndex& idx) const;
// get the data in the model for this property
- void getPropertyData(const QModelIndex& idx1,
- QCMakeProperty& prop) const;
+ void getPropertyData(const QModelIndex& idx1, QCMakeProperty& prop) const;
protected:
bool EditEnabled;
@@ -125,17 +130,16 @@ protected:
ViewType View;
// set the data in the model for this property
- void setPropertyData(const QModelIndex& idx1,
- const QCMakeProperty& p, bool isNew);
+ void setPropertyData(const QModelIndex& idx1, const QCMakeProperty& p,
+ bool isNew);
// breaks up he property list into groups
// where each group has the same prefix up to the first underscore
static void breakProperties(const QSet<QCMakeProperty>& props,
- QMap<QString, QCMakePropertyList>& result);
+ QMap<QString, QCMakePropertyList>& result);
// gets the prefix of a string up to the first _
static QString prefix(const QString& s);
-
};
/// Qt delegate class for interaction (or other customization)
@@ -147,18 +151,22 @@ public:
QCMakeCacheModelDelegate(QObject* p);
/// create our own editors for cache properties
QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option,
- const QModelIndex& index ) const;
- bool editorEvent (QEvent* event, QAbstractItemModel* model,
- const QStyleOptionViewItem& option, const QModelIndex& index);
+ const QModelIndex& index) const;
+ bool editorEvent(QEvent* event, QAbstractItemModel* model,
+ const QStyleOptionViewItem& option,
+ const QModelIndex& index);
bool eventFilter(QObject* object, QEvent* event);
- void setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index ) const;
- QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const;
+ void setModelData(QWidget* editor, QAbstractItemModel* model,
+ const QModelIndex& index) const;
+ QSize sizeHint(const QStyleOptionViewItem& option,
+ const QModelIndex& index) const;
QSet<QCMakeProperty> changes() const;
void clearChanges();
protected slots:
void setFileDialogFlag(bool);
+
protected:
bool FileDialogFlag;
// record a change to an item in the model.
@@ -170,4 +178,3 @@ protected:
};
#endif
-
diff --git a/Source/QtDialog/QCMakeWidgets.cxx b/Source/QtDialog/QCMakeWidgets.cxx
index 7803ef3..4b3eb34 100644
--- a/Source/QtDialog/QCMakeWidgets.cxx
+++ b/Source/QtDialog/QCMakeWidgets.cxx
@@ -19,23 +19,24 @@
#include <QToolButton>
QCMakeFileEditor::QCMakeFileEditor(QWidget* p, const QString& var)
- : QLineEdit(p), Variable(var)
+ : QLineEdit(p)
+ , Variable(var)
{
this->ToolButton = new QToolButton(this);
this->ToolButton->setText("...");
this->ToolButton->setCursor(QCursor(Qt::ArrowCursor));
- QObject::connect(this->ToolButton, SIGNAL(clicked(bool)),
- this, SLOT(chooseFile()));
+ QObject::connect(this->ToolButton, SIGNAL(clicked(bool)), this,
+ SLOT(chooseFile()));
}
QCMakeFilePathEditor::QCMakeFilePathEditor(QWidget* p, const QString& var)
- : QCMakeFileEditor(p, var)
+ : QCMakeFileEditor(p, var)
{
this->setCompleter(new QCMakeFileCompleter(this, false));
}
QCMakePathEditor::QCMakePathEditor(QWidget* p, const QString& var)
- : QCMakeFileEditor(p, var)
+ : QCMakeFileEditor(p, var)
{
this->setCompleter(new QCMakeFileCompleter(this, true));
}
@@ -57,24 +58,21 @@ void QCMakeFilePathEditor::chooseFile()
QString path;
QFileInfo info(this->text());
QString title;
- if(this->Variable.isEmpty())
- {
+ if (this->Variable.isEmpty()) {
title = tr("Select File");
- }
- else
- {
+ } else {
title = tr("Select File for %1");
title = title.arg(this->Variable);
- }
+ }
this->fileDialogExists(true);
- path = QFileDialog::getOpenFileName(this, title, info.absolutePath(),
- QString(), NULL, QFileDialog::DontResolveSymlinks);
+ path =
+ QFileDialog::getOpenFileName(this, title, info.absolutePath(), QString(),
+ NULL, QFileDialog::DontResolveSymlinks);
this->fileDialogExists(false);
- if(!path.isEmpty())
- {
+ if (!path.isEmpty()) {
this->setText(QDir::fromNativeSeparators(path));
- }
+ }
}
void QCMakePathEditor::chooseFile()
@@ -82,43 +80,38 @@ void QCMakePathEditor::chooseFile()
// choose a file and set it
QString path;
QString title;
- if(this->Variable.isEmpty())
- {
+ if (this->Variable.isEmpty()) {
title = tr("Select Path");
- }
- else
- {
+ } else {
title = tr("Select Path for %1");
title = title.arg(this->Variable);
- }
+ }
this->fileDialogExists(true);
path = QFileDialog::getExistingDirectory(this, title, this->text(),
- QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
+ QFileDialog::ShowDirsOnly |
+ QFileDialog::DontResolveSymlinks);
this->fileDialogExists(false);
- if(!path.isEmpty())
- {
+ if (!path.isEmpty()) {
this->setText(QDir::fromNativeSeparators(path));
- }
+ }
}
// use same QDirModel for all completers
static QDirModel* fileDirModel()
{
static QDirModel* m = NULL;
- if(!m)
- {
+ if (!m) {
m = new QDirModel();
- }
+ }
return m;
}
static QDirModel* pathDirModel()
{
static QDirModel* m = NULL;
- if(!m)
- {
+ if (!m) {
m = new QDirModel();
m->setFilter(QDir::AllDirs | QDir::Drives | QDir::NoDotAndDotDot);
- }
+ }
return m;
}
@@ -133,4 +126,3 @@ QString QCMakeFileCompleter::pathFromIndex(const QModelIndex& idx) const
{
return QDir::fromNativeSeparators(QCompleter::pathFromIndex(idx));
}
-
diff --git a/Source/QtDialog/QCMakeWidgets.h b/Source/QtDialog/QCMakeWidgets.h
index 759b635..f1e87ce 100644
--- a/Source/QtDialog/QCMakeWidgets.h
+++ b/Source/QtDialog/QCMakeWidgets.h
@@ -31,6 +31,7 @@ protected slots:
virtual void chooseFile() = 0;
signals:
void fileDialogExists(bool);
+
protected:
void resizeEvent(QResizeEvent* e);
QToolButton* ToolButton;
@@ -69,20 +70,20 @@ class QCMakeComboBox : public QComboBox
{
Q_OBJECT
Q_PROPERTY(QString value READ currentText WRITE setValue USER true);
+
public:
- QCMakeComboBox(QWidget* p, QStringList strings) : QComboBox(p)
+ QCMakeComboBox(QWidget* p, QStringList strings)
+ : QComboBox(p)
{
this->addItems(strings);
}
void setValue(const QString& v)
{
int i = this->findText(v);
- if(i != -1)
- {
+ if (i != -1) {
this->setCurrentIndex(i);
}
}
};
#endif
-
diff --git a/Source/QtDialog/RegexExplorer.cxx b/Source/QtDialog/RegexExplorer.cxx
index dfcf048..d23a08c 100644
--- a/Source/QtDialog/RegexExplorer.cxx
+++ b/Source/QtDialog/RegexExplorer.cxx
@@ -12,16 +12,16 @@
#include "RegexExplorer.h"
-RegexExplorer::RegexExplorer(QWidget* p) : QDialog(p), m_matched(false)
+RegexExplorer::RegexExplorer(QWidget* p)
+ : QDialog(p)
+ , m_matched(false)
{
this->setupUi(this);
- for(int i = 1; i < cmsys::RegularExpression::NSUBEXP; ++i)
- {
- matchNumber->addItem(
- QString("Match %1").arg(QString::number(i)),
- QVariant(i));
- }
+ for (int i = 1; i < cmsys::RegularExpression::NSUBEXP; ++i) {
+ matchNumber->addItem(QString("Match %1").arg(QString::number(i)),
+ QVariant(i));
+ }
matchNumber->setCurrentIndex(0);
}
@@ -44,10 +44,9 @@ void RegexExplorer::on_regularExpression_textChanged(const QString& text)
bool validExpression =
stripEscapes(m_regex) && m_regexParser.compile(m_regex);
- if(!validExpression)
- {
+ if (!validExpression) {
m_regexParser.set_invalid();
- }
+ }
setStatusColor(labelRegexValid, validExpression);
@@ -56,8 +55,7 @@ void RegexExplorer::on_regularExpression_textChanged(const QString& text)
void RegexExplorer::on_inputText_textChanged()
{
- if(m_regexParser.is_valid())
- {
+ if (m_regexParser.is_valid()) {
QString plainText = inputText->toPlainText();
#ifdef QT_NO_STL
m_text = plainText.toAscii().constData();
@@ -65,19 +63,16 @@ void RegexExplorer::on_inputText_textChanged()
m_text = plainText.toStdString();
#endif
m_matched = m_regexParser.find(m_text);
- }
- else
- {
+ } else {
m_matched = false;
- }
+ }
setStatusColor(labelRegexMatch, m_matched);
- if(!m_matched)
- {
+ if (!m_matched) {
clearMatch();
return;
- }
+ }
#ifdef QT_NO_STL
QString matchText = m_regexParser.match(0).c_str();
@@ -91,18 +86,16 @@ void RegexExplorer::on_inputText_textChanged()
void RegexExplorer::on_matchNumber_currentIndexChanged(int index)
{
- if(!m_matched)
- {
+ if (!m_matched) {
return;
- }
+ }
QVariant itemData = matchNumber->itemData(index);
int idx = itemData.toInt();
- if(idx < 1 || idx >= cmsys::RegularExpression::NSUBEXP)
- {
+ if (idx < 1 || idx >= cmsys::RegularExpression::NSUBEXP) {
return;
- }
+ }
#ifdef QT_NO_STL
QString match = m_regexParser.match(idx).c_str();
@@ -125,42 +118,29 @@ bool RegexExplorer::stripEscapes(std::string& source)
std::string result;
result.reserve(source.size());
- for(char inc = *in; inc != '\0'; inc = *++in)
- {
- if(inc == '\\')
- {
+ for (char inc = *in; inc != '\0'; inc = *++in) {
+ if (inc == '\\') {
char nextc = in[1];
- if(nextc == 't')
- {
+ if (nextc == 't') {
result.append(1, '\t');
in++;
- }
- else if(nextc == 'n')
- {
+ } else if (nextc == 'n') {
result.append(1, '\n');
in++;
- }
- else if(nextc == 't')
- {
+ } else if (nextc == 't') {
result.append(1, '\t');
in++;
- }
- else if(isalnum(nextc) || nextc == '\0')
- {
+ } else if (isalnum(nextc) || nextc == '\0') {
return false;
- }
- else
- {
+ } else {
result.append(1, nextc);
in++;
- }
- }
- else
- {
- result.append(1, inc);
}
+ } else {
+ result.append(1, inc);
}
+ }
- source = result;
- return true;
+ source = result;
+ return true;
}
diff --git a/Source/QtDialog/WarningMessagesDialog.cxx b/Source/QtDialog/WarningMessagesDialog.cxx
index 4bd541f..3be6798 100644
--- a/Source/QtDialog/WarningMessagesDialog.cxx
+++ b/Source/QtDialog/WarningMessagesDialog.cxx
@@ -13,7 +13,8 @@
#include "WarningMessagesDialog.h"
WarningMessagesDialog::WarningMessagesDialog(QWidget* prnt, QCMake* instance)
- : QDialog(prnt), cmakeInstance(instance)
+ : QDialog(prnt)
+ , cmakeInstance(instance)
{
this->setupUi(this);
this->setInitialValues();
@@ -35,8 +36,8 @@ void WarningMessagesDialog::setInitialValues()
void WarningMessagesDialog::setupSignals()
{
- QObject::connect(this->buttonBox, SIGNAL(accepted()),
- this, SLOT(doAccept()));
+ QObject::connect(this->buttonBox, SIGNAL(accepted()), this,
+ SLOT(doAccept()));
QObject::connect(this->suppressDeveloperWarnings, SIGNAL(stateChanged(int)),
this, SLOT(doSuppressDeveloperWarningsChanged(int)));
@@ -65,35 +66,31 @@ void WarningMessagesDialog::doAccept()
void WarningMessagesDialog::doSuppressDeveloperWarningsChanged(int state)
{
// no warnings implies no errors either
- if (state)
- {
+ if (state) {
this->developerWarningsAsErrors->setChecked(false);
- }
+ }
}
void WarningMessagesDialog::doSuppressDeprecatedWarningsChanged(int state)
{
// no warnings implies no errors either
- if (state)
- {
+ if (state) {
this->deprecatedWarningsAsErrors->setChecked(false);
- }
+ }
}
void WarningMessagesDialog::doDeveloperWarningsAsErrorsChanged(int state)
{
// warnings as errors implies warnings are not suppressed
- if (state)
- {
+ if (state) {
this->suppressDeveloperWarnings->setChecked(false);
- }
+ }
}
void WarningMessagesDialog::doDeprecatedWarningsAsErrorsChanged(int state)
{
// warnings as errors implies warnings are not suppressed
- if (state)
- {
+ if (state) {
this->suppressDeprecatedWarnings->setChecked(false);
- }
+ }
}
diff --git a/Source/cmAddCompileOptionsCommand.cxx b/Source/cmAddCompileOptionsCommand.cxx
index a6c3c00..2223cf4 100644
--- a/Source/cmAddCompileOptionsCommand.cxx
+++ b/Source/cmAddCompileOptionsCommand.cxx
@@ -11,18 +11,16 @@
============================================================================*/
#include "cmAddCompileOptionsCommand.h"
-bool cmAddCompileOptionsCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmAddCompileOptionsCommand::InitialPass(
+ std::vector<std::string> const& args, cmExecutionStatus&)
{
- if(args.size() < 1 )
- {
+ if (args.size() < 1) {
return true;
- }
+ }
- for(std::vector<std::string>::const_iterator i = args.begin();
- i != args.end(); ++i)
- {
+ for (std::vector<std::string>::const_iterator i = args.begin();
+ i != args.end(); ++i) {
this->Makefile->AddCompileOption(i->c_str());
- }
+ }
return true;
}
diff --git a/Source/cmAddCompileOptionsCommand.h b/Source/cmAddCompileOptionsCommand.h
index f147ec0..5c073c8 100644
--- a/Source/cmAddCompileOptionsCommand.h
+++ b/Source/cmAddCompileOptionsCommand.h
@@ -20,22 +20,19 @@ public:
/**
* This is a virtual constructor for the command.
*/
- virtual cmCommand* Clone()
- {
- return new cmAddCompileOptionsCommand;
- }
+ virtual cmCommand* Clone() { return new cmAddCompileOptionsCommand; }
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus &status);
+ cmExecutionStatus& status);
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const {return "add_compile_options";}
+ virtual std::string GetName() const { return "add_compile_options"; }
cmTypeMacro(cmAddCompileOptionsCommand, cmCommand);
};
diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx
index 30f431c..d8fd1d8 100644
--- a/Source/cmAddCustomCommandCommand.cxx
+++ b/Source/cmAddCustomCommandCommand.cxx
@@ -16,18 +16,17 @@
#include "cmSourceFile.h"
// cmAddCustomCommandCommand
-bool cmAddCustomCommandCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmAddCustomCommandCommand::InitialPass(
+ std::vector<std::string> const& args, cmExecutionStatus&)
{
/* Let's complain at the end of this function about the lack of a particular
arg. For the moment, let's say that COMMAND, and either TARGET or SOURCE
are required.
*/
- if (args.size() < 4)
- {
- this->SetError("called with wrong number of arguments.");
- return false;
- }
+ if (args.size() < 4) {
+ this->SetError("called with wrong number of arguments.");
+ return false;
+ }
std::string source, target, main_dependency, working;
std::string comment_buffer;
@@ -47,7 +46,8 @@ bool cmAddCustomCommandCommand
cmTarget::CustomCommandType cctype = cmTarget::POST_BUILD;
- enum tdoing {
+ enum tdoing
+ {
doing_source,
doing_command,
doing_target,
@@ -65,99 +65,58 @@ bool cmAddCustomCommandCommand
tdoing doing = doing_nothing;
- for (unsigned int j = 0; j < args.size(); ++j)
- {
+ for (unsigned int j = 0; j < args.size(); ++j) {
std::string const& copy = args[j];
- if(copy == "SOURCE")
- {
+ if (copy == "SOURCE") {
doing = doing_source;
- }
- else if(copy == "COMMAND")
- {
+ } else if (copy == "COMMAND") {
doing = doing_command;
// Save the current command before starting the next command.
- if(!currentLine.empty())
- {
+ if (!currentLine.empty()) {
commandLines.push_back(currentLine);
currentLine.clear();
- }
}
- else if(copy == "PRE_BUILD")
- {
+ } else if (copy == "PRE_BUILD") {
cctype = cmTarget::PRE_BUILD;
- }
- else if(copy == "PRE_LINK")
- {
+ } else if (copy == "PRE_LINK") {
cctype = cmTarget::PRE_LINK;
- }
- else if(copy == "POST_BUILD")
- {
+ } else if (copy == "POST_BUILD") {
cctype = cmTarget::POST_BUILD;
- }
- else if(copy == "VERBATIM")
- {
+ } else if (copy == "VERBATIM") {
verbatim = true;
- }
- else if(copy == "APPEND")
- {
+ } else if (copy == "APPEND") {
append = true;
- }
- else if(copy == "USES_TERMINAL")
- {
+ } else if (copy == "USES_TERMINAL") {
uses_terminal = true;
- }
- else if(copy == "TARGET")
- {
+ } else if (copy == "TARGET") {
doing = doing_target;
- }
- else if(copy == "ARGS")
- {
+ } else if (copy == "ARGS") {
// Ignore this old keyword.
- }
- else if (copy == "DEPENDS")
- {
+ } else if (copy == "DEPENDS") {
doing = doing_depends;
- }
- else if (copy == "OUTPUTS")
- {
+ } else if (copy == "OUTPUTS") {
doing = doing_outputs;
- }
- else if (copy == "OUTPUT")
- {
+ } else if (copy == "OUTPUT") {
doing = doing_output;
- }
- else if (copy == "BYPRODUCTS")
- {
+ } else if (copy == "BYPRODUCTS") {
doing = doing_byproducts;
- }
- else if (copy == "WORKING_DIRECTORY")
- {
+ } else if (copy == "WORKING_DIRECTORY") {
doing = doing_working_directory;
- }
- else if (copy == "MAIN_DEPENDENCY")
- {
+ } else if (copy == "MAIN_DEPENDENCY") {
doing = doing_main_dependency;
- }
- else if (copy == "IMPLICIT_DEPENDS")
- {
+ } else if (copy == "IMPLICIT_DEPENDS") {
doing = doing_implicit_depends_lang;
- }
- else if (copy == "COMMENT")
- {
+ } else if (copy == "COMMENT") {
doing = doing_comment;
- }
- else
- {
+ } else {
std::string filename;
- switch (doing)
- {
+ switch (doing) {
case doing_output:
case doing_outputs:
case doing_byproducts:
- if (!cmSystemTools::FileIsFullPath(copy.c_str()))
- {
+ if (!cmSystemTools::FileIsFullPath(copy.c_str())) {
// This is an output to be generated, so it should be
// under the build tree. CMake 2.4 placed this under the
// source tree. However the only case that this change
@@ -170,139 +129,124 @@ bool cmAddCustomCommandCommand
// complain.
filename = this->Makefile->GetCurrentBinaryDirectory();
filename += "/";
- }
+ }
filename += copy;
cmSystemTools::ConvertToUnixSlashes(filename);
break;
case doing_source:
- // We do not want to convert the argument to SOURCE because
- // that option is only available for backward compatibility.
- // Old-style use of this command may use the SOURCE==TARGET
- // trick which we must preserve. If we convert the source
- // to a full path then it will no longer equal the target.
+ // We do not want to convert the argument to SOURCE because
+ // that option is only available for backward compatibility.
+ // Old-style use of this command may use the SOURCE==TARGET
+ // trick which we must preserve. If we convert the source
+ // to a full path then it will no longer equal the target.
default:
break;
- }
+ }
- if (cmSystemTools::FileIsFullPath(filename.c_str()))
- {
+ if (cmSystemTools::FileIsFullPath(filename.c_str())) {
filename = cmSystemTools::CollapseFullPath(filename);
- }
- switch (doing)
- {
- case doing_working_directory:
- working = copy;
- break;
- case doing_source:
- source = copy;
- break;
- case doing_output:
- output.push_back(filename);
- break;
- case doing_main_dependency:
- main_dependency = copy;
- break;
- case doing_implicit_depends_lang:
- implicit_depends_lang = copy;
- doing = doing_implicit_depends_file;
- break;
- case doing_implicit_depends_file:
- {
- // An implicit dependency starting point is also an
- // explicit dependency.
- std::string dep = copy;
- cmSystemTools::ConvertToUnixSlashes(dep);
- depends.push_back(dep);
+ }
+ switch (doing) {
+ case doing_working_directory:
+ working = copy;
+ break;
+ case doing_source:
+ source = copy;
+ break;
+ case doing_output:
+ output.push_back(filename);
+ break;
+ case doing_main_dependency:
+ main_dependency = copy;
+ break;
+ case doing_implicit_depends_lang:
+ implicit_depends_lang = copy;
+ doing = doing_implicit_depends_file;
+ break;
+ case doing_implicit_depends_file: {
+ // An implicit dependency starting point is also an
+ // explicit dependency.
+ std::string dep = copy;
+ cmSystemTools::ConvertToUnixSlashes(dep);
+ depends.push_back(dep);
- // Add the implicit dependency language and file.
- cmCustomCommand::ImplicitDependsPair
- entry(implicit_depends_lang, dep);
- implicit_depends.push_back(entry);
+ // Add the implicit dependency language and file.
+ cmCustomCommand::ImplicitDependsPair entry(implicit_depends_lang,
+ dep);
+ implicit_depends.push_back(entry);
- // Switch back to looking for a language.
- doing = doing_implicit_depends_lang;
- }
- break;
- case doing_command:
- currentLine.push_back(copy);
- break;
- case doing_target:
- target = copy;
- break;
- case doing_depends:
- {
- std::string dep = copy;
- cmSystemTools::ConvertToUnixSlashes(dep);
- depends.push_back(dep);
- }
- break;
- case doing_outputs:
- outputs.push_back(filename);
- break;
- case doing_byproducts:
- byproducts.push_back(filename);
- break;
- case doing_comment:
- comment_buffer = copy;
- comment = comment_buffer.c_str();
- break;
- default:
- this->SetError("Wrong syntax. Unknown type of argument.");
- return false;
- }
+ // Switch back to looking for a language.
+ doing = doing_implicit_depends_lang;
+ } break;
+ case doing_command:
+ currentLine.push_back(copy);
+ break;
+ case doing_target:
+ target = copy;
+ break;
+ case doing_depends: {
+ std::string dep = copy;
+ cmSystemTools::ConvertToUnixSlashes(dep);
+ depends.push_back(dep);
+ } break;
+ case doing_outputs:
+ outputs.push_back(filename);
+ break;
+ case doing_byproducts:
+ byproducts.push_back(filename);
+ break;
+ case doing_comment:
+ comment_buffer = copy;
+ comment = comment_buffer.c_str();
+ break;
+ default:
+ this->SetError("Wrong syntax. Unknown type of argument.");
+ return false;
}
}
+ }
// Store the last command line finished.
- if(!currentLine.empty())
- {
+ if (!currentLine.empty()) {
commandLines.push_back(currentLine);
currentLine.clear();
- }
+ }
// At this point we could complain about the lack of arguments. For
// the moment, let's say that COMMAND, TARGET are always required.
- if(output.empty() && target.empty())
- {
+ if (output.empty() && target.empty()) {
this->SetError("Wrong syntax. A TARGET or OUTPUT must be specified.");
return false;
- }
+ }
- if(source.empty() && !target.empty() && !output.empty())
- {
+ if (source.empty() && !target.empty() && !output.empty()) {
this->SetError(
"Wrong syntax. A TARGET and OUTPUT can not both be specified.");
return false;
- }
- if(append && output.empty())
- {
+ }
+ if (append && output.empty()) {
this->SetError("given APPEND option with no OUTPUT.");
return false;
- }
+ }
// Make sure the output names and locations are safe.
- if(!this->CheckOutputs(output) ||
- !this->CheckOutputs(outputs) ||
- !this->CheckOutputs(byproducts))
- {
+ if (!this->CheckOutputs(output) || !this->CheckOutputs(outputs) ||
+ !this->CheckOutputs(byproducts)) {
return false;
- }
+ }
// Check for an append request.
- if(append)
- {
+ if (append) {
// Lookup an existing command.
- if(cmSourceFile* sf =
- this->Makefile->GetSourceFileWithOutput(output[0]))
- {
- if(cmCustomCommand* cc = sf->GetCustomCommand())
- {
+ if (cmSourceFile* sf =
+ this->Makefile->GetSourceFileWithOutput(output[0])) {
+ if (cmCustomCommand* cc = sf->GetCustomCommand()) {
cc->AppendCommands(commandLines);
cc->AppendDepends(depends);
cc->AppendImplicitDepends(implicit_depends);
return true;
- }
}
+ }
// No command for this output exists.
std::ostringstream e;
@@ -310,136 +254,111 @@ bool cmAddCustomCommandCommand
<< "\" which is not already a custom command output.";
this->SetError(e.str());
return false;
- }
+ }
// Convert working directory to a full path.
- if(!working.empty())
- {
+ if (!working.empty()) {
const char* build_dir = this->Makefile->GetCurrentBinaryDirectory();
working = cmSystemTools::CollapseFullPath(working, build_dir);
- }
+ }
// Choose which mode of the command to use.
bool escapeOldStyle = !verbatim;
- if(source.empty() && output.empty())
- {
+ if (source.empty() && output.empty()) {
// Source is empty, use the target.
std::vector<std::string> no_depends;
- this->Makefile->AddCustomCommandToTarget(target, byproducts, no_depends,
- commandLines, cctype,
- comment, working.c_str(),
- escapeOldStyle, uses_terminal);
- }
- else if(target.empty())
- {
+ this->Makefile->AddCustomCommandToTarget(
+ target, byproducts, no_depends, commandLines, cctype, comment,
+ working.c_str(), escapeOldStyle, uses_terminal);
+ } else if (target.empty()) {
// Target is empty, use the output.
- this->Makefile->AddCustomCommandToOutput(output, byproducts,
- depends, main_dependency,
- commandLines, comment,
- working.c_str(), false,
- escapeOldStyle, uses_terminal);
+ this->Makefile->AddCustomCommandToOutput(
+ output, byproducts, depends, main_dependency, commandLines, comment,
+ working.c_str(), false, escapeOldStyle, uses_terminal);
// Add implicit dependency scanning requests if any were given.
- if(!implicit_depends.empty())
- {
+ if (!implicit_depends.empty()) {
bool okay = false;
- if(cmSourceFile* sf =
- this->Makefile->GetSourceFileWithOutput(output[0]))
- {
- if(cmCustomCommand* cc = sf->GetCustomCommand())
- {
+ if (cmSourceFile* sf =
+ this->Makefile->GetSourceFileWithOutput(output[0])) {
+ if (cmCustomCommand* cc = sf->GetCustomCommand()) {
okay = true;
cc->SetImplicitDepends(implicit_depends);
- }
}
- if(!okay)
- {
+ }
+ if (!okay) {
std::ostringstream e;
e << "could not locate source file with a custom command producing \""
<< output[0] << "\" even though this command tried to create it!";
this->SetError(e.str());
return false;
- }
}
}
- else if (!byproducts.empty())
- {
+ } else if (!byproducts.empty()) {
this->SetError("BYPRODUCTS may not be specified with SOURCE signatures");
return false;
- }
- else if (uses_terminal)
- {
+ } else if (uses_terminal) {
this->SetError("USES_TERMINAL may not be used with SOURCE signatures");
return false;
- }
- else
- {
+ } else {
bool issueMessage = true;
std::ostringstream e;
cmake::MessageType messageType = cmake::AUTHOR_WARNING;
- switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0050))
- {
- case cmPolicies::WARN:
- e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0050) << "\n";
- break;
- case cmPolicies::OLD:
- issueMessage = false;
- break;
- case cmPolicies::REQUIRED_ALWAYS:
- case cmPolicies::REQUIRED_IF_USED:
- case cmPolicies::NEW:
- messageType = cmake::FATAL_ERROR;
- break;
+ switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0050)) {
+ case cmPolicies::WARN:
+ e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0050) << "\n";
+ break;
+ case cmPolicies::OLD:
+ issueMessage = false;
+ break;
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::NEW:
+ messageType = cmake::FATAL_ERROR;
+ break;
}
- if (issueMessage)
- {
+ if (issueMessage) {
e << "The SOURCE signatures of add_custom_command are no longer "
"supported.";
this->Makefile->IssueMessage(messageType, e.str());
- if (messageType == cmake::FATAL_ERROR)
- {
+ if (messageType == cmake::FATAL_ERROR) {
return false;
- }
}
+ }
// Use the old-style mode for backward compatibility.
- this->Makefile->AddCustomCommandOldStyle(target, outputs, depends,
- source, commandLines,
- comment);
- }
+ this->Makefile->AddCustomCommandOldStyle(target, outputs, depends, source,
+ commandLines, comment);
+ }
return true;
}
-bool
-cmAddCustomCommandCommand
-::CheckOutputs(const std::vector<std::string>& outputs)
+bool cmAddCustomCommandCommand::CheckOutputs(
+ const std::vector<std::string>& outputs)
{
- for(std::vector<std::string>::const_iterator o = outputs.begin();
- o != outputs.end(); ++o)
- {
+ for (std::vector<std::string>::const_iterator o = outputs.begin();
+ o != outputs.end(); ++o) {
// Make sure the file will not be generated into the source
// directory during an out of source build.
- if(!this->Makefile->CanIWriteThisFile(o->c_str()))
- {
+ if (!this->Makefile->CanIWriteThisFile(o->c_str())) {
std::string e = "attempted to have a file \"" + *o +
"\" in a source directory as an output of custom command.";
this->SetError(e);
cmSystemTools::SetFatalErrorOccured();
return false;
- }
+ }
// Make sure the output file name has no invalid characters.
std::string::size_type pos = o->find_first_of("#<>");
- if(pos != o->npos)
- {
+ if (pos != o->npos) {
std::ostringstream msg;
msg << "called with OUTPUT containing a \"" << (*o)[pos]
<< "\". This character is not allowed.";
this->SetError(msg.str());
return false;
- }
}
+ }
return true;
}
diff --git a/Source/cmAddCustomCommandCommand.h b/Source/cmAddCustomCommandCommand.h
index 1d6ddb2..ccbd50c 100644
--- a/Source/cmAddCustomCommandCommand.h
+++ b/Source/cmAddCustomCommandCommand.h
@@ -26,27 +26,24 @@ public:
/**
* This is a virtual constructor for the command.
*/
- virtual cmCommand* Clone()
- {
- return new cmAddCustomCommandCommand;
- }
+ virtual cmCommand* Clone() { return new cmAddCustomCommandCommand; }
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus &status);
+ cmExecutionStatus& status);
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const {return "add_custom_command";}
+ virtual std::string GetName() const { return "add_custom_command"; }
cmTypeMacro(cmAddCustomCommandCommand, cmCommand);
+
protected:
bool CheckOutputs(const std::vector<std::string>& outputs);
};
-
#endif
diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx
index 5bf752a..ac08cb2 100644
--- a/Source/cmAddCustomTargetCommand.cxx
+++ b/Source/cmAddCustomTargetCommand.cxx
@@ -15,28 +15,25 @@
#include "cmGlobalGenerator.h"
// cmAddCustomTargetCommand
-bool cmAddCustomTargetCommand
-::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmAddCustomTargetCommand::InitialPass(
+ std::vector<std::string> const& args, cmExecutionStatus&)
{
- if(args.size() < 1 )
- {
+ if (args.size() < 1) {
this->SetError("called with incorrect number of arguments");
return false;
- }
+ }
std::string targetName = args[0];
// Check the target name.
- if(targetName.find_first_of("/\\") != targetName.npos)
- {
+ if (targetName.find_first_of("/\\") != targetName.npos) {
std::ostringstream e;
e << "called with invalid target name \"" << targetName
<< "\". Target names may not contain a slash. "
<< "Use ADD_CUSTOM_COMMAND to generate files.";
this->SetError(e.str());
return false;
- }
+ }
// Accumulate one command line at a time.
cmCustomCommandLine currentLine;
@@ -54,7 +51,8 @@ bool cmAddCustomTargetCommand
std::vector<std::string> sources;
// Keep track of parser state.
- enum tdoing {
+ enum tdoing
+ {
doing_command,
doing_depends,
doing_byproducts,
@@ -68,131 +66,100 @@ bool cmAddCustomTargetCommand
// Look for the ALL option.
bool excludeFromAll = true;
unsigned int start = 1;
- if(args.size() > 1)
- {
- if(args[1] == "ALL")
- {
+ if (args.size() > 1) {
+ if (args[1] == "ALL") {
excludeFromAll = false;
start = 2;
- }
}
+ }
// Parse the rest of the arguments.
- for(unsigned int j = start; j < args.size(); ++j)
- {
+ for (unsigned int j = start; j < args.size(); ++j) {
std::string const& copy = args[j];
- if(copy == "DEPENDS")
- {
+ if (copy == "DEPENDS") {
doing = doing_depends;
- }
- else if(copy == "BYPRODUCTS")
- {
+ } else if (copy == "BYPRODUCTS") {
doing = doing_byproducts;
- }
- else if(copy == "WORKING_DIRECTORY")
- {
+ } else if (copy == "WORKING_DIRECTORY") {
doing = doing_working_directory;
- }
- else if(copy == "VERBATIM")
- {
+ } else if (copy == "VERBATIM") {
doing = doing_nothing;
verbatim = true;
- }
- else if(copy == "USES_TERMINAL")
- {
+ } else if (copy == "USES_TERMINAL") {
doing = doing_nothing;
uses_terminal = true;
- }
- else if (copy == "COMMENT")
- {
+ } else if (copy == "COMMENT") {
doing = doing_comment;
- }
- else if(copy == "COMMAND")
- {
+ } else if (copy == "COMMAND") {
doing = doing_command;
// Save the current command before starting the next command.
- if(!currentLine.empty())
- {
+ if (!currentLine.empty()) {
commandLines.push_back(currentLine);
currentLine.clear();
- }
}
- else if(copy == "SOURCES")
- {
+ } else if (copy == "SOURCES") {
doing = doing_source;
- }
- else
- {
- switch (doing)
- {
+ } else {
+ switch (doing) {
case doing_working_directory:
working_directory = copy;
break;
case doing_command:
currentLine.push_back(copy);
break;
- case doing_byproducts:
- {
+ case doing_byproducts: {
std::string filename;
- if (!cmSystemTools::FileIsFullPath(copy.c_str()))
- {
+ if (!cmSystemTools::FileIsFullPath(copy.c_str())) {
filename = this->Makefile->GetCurrentBinaryDirectory();
filename += "/";
- }
+ }
filename += copy;
cmSystemTools::ConvertToUnixSlashes(filename);
byproducts.push_back(filename);
- }
- break;
- case doing_depends:
- {
+ } break;
+ case doing_depends: {
std::string dep = copy;
cmSystemTools::ConvertToUnixSlashes(dep);
depends.push_back(dep);
- }
+ } break;
+ case doing_comment:
+ comment_buffer = copy;
+ comment = comment_buffer.c_str();
break;
- case doing_comment:
- comment_buffer = copy;
- comment = comment_buffer.c_str();
- break;
case doing_source:
sources.push_back(copy);
break;
default:
this->SetError("Wrong syntax. Unknown type of argument.");
return false;
- }
}
}
+ }
std::string::size_type pos = targetName.find_first_of("#<>");
- if(pos != targetName.npos)
- {
+ if (pos != targetName.npos) {
std::ostringstream msg;
msg << "called with target name containing a \"" << targetName[pos]
<< "\". This character is not allowed.";
this->SetError(msg.str());
return false;
- }
+ }
// Some requirements on custom target names already exist
// and have been checked at this point.
// The following restrictions overlap but depend on policy CMP0037.
bool nameOk = cmGeneratorExpression::IsValidTargetName(targetName) &&
!cmGlobalGenerator::IsReservedTarget(targetName);
- if (nameOk)
- {
+ if (nameOk) {
nameOk = targetName.find(":") == std::string::npos;
- }
- if (!nameOk)
- {
+ }
+ if (!nameOk) {
cmake::MessageType messageType = cmake::AUTHOR_WARNING;
std::ostringstream e;
bool issueMessage = false;
- switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0037))
- {
+ switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0037)) {
case cmPolicies::WARN:
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0037) << "\n";
issueMessage = true;
@@ -203,9 +170,8 @@ bool cmAddCustomTargetCommand
case cmPolicies::REQUIRED_ALWAYS:
issueMessage = true;
messageType = cmake::FATAL_ERROR;
- }
- if (issueMessage)
- {
+ }
+ if (issueMessage) {
/* clang-format off */
e << "The target name \"" << targetName <<
"\" is reserved or not valid for certain "
@@ -214,59 +180,52 @@ bool cmAddCustomTargetCommand
/* clang-format on */
this->Makefile->IssueMessage(messageType, e.str());
- if (messageType == cmake::FATAL_ERROR)
- {
+ if (messageType == cmake::FATAL_ERROR) {
return false;
- }
}
}
+ }
// Store the last command line finished.
- if(!currentLine.empty())
- {
+ if (!currentLine.empty()) {
commandLines.push_back(currentLine);
currentLine.clear();
- }
+ }
// Enforce name uniqueness.
{
- std::string msg;
- if(!this->Makefile->EnforceUniqueName(targetName, msg, true))
- {
- this->SetError(msg);
- return false;
+ std::string msg;
+ if (!this->Makefile->EnforceUniqueName(targetName, msg, true)) {
+ this->SetError(msg);
+ return false;
}
}
// Convert working directory to a full path.
- if(!working_directory.empty())
- {
+ if (!working_directory.empty()) {
const char* build_dir = this->Makefile->GetCurrentBinaryDirectory();
working_directory =
cmSystemTools::CollapseFullPath(working_directory, build_dir);
- }
+ }
- if (commandLines.empty() && !byproducts.empty())
- {
- this->Makefile->IssueMessage(cmake::FATAL_ERROR,
+ if (commandLines.empty() && !byproducts.empty()) {
+ this->Makefile->IssueMessage(
+ cmake::FATAL_ERROR,
"BYPRODUCTS may not be specified without any COMMAND");
return true;
- }
- if (commandLines.empty() && uses_terminal)
- {
- this->Makefile->IssueMessage(cmake::FATAL_ERROR,
+ }
+ if (commandLines.empty() && uses_terminal) {
+ this->Makefile->IssueMessage(
+ cmake::FATAL_ERROR,
"USES_TERMINAL may not be specified without any COMMAND");
return true;
- }
+ }
// Add the utility target to the makefile.
bool escapeOldStyle = !verbatim;
- cmTarget* target =
- this->Makefile->AddUtilityCommand(targetName, excludeFromAll,
- working_directory.c_str(),
- byproducts, depends,
- commandLines, escapeOldStyle, comment,
- uses_terminal);
+ cmTarget* target = this->Makefile->AddUtilityCommand(
+ targetName, excludeFromAll, working_directory.c_str(), byproducts, depends,
+ commandLines, escapeOldStyle, comment, uses_terminal);
// Add additional user-specified source files to the target.
target->AddSources(sources);
diff --git a/Source/cmAddCustomTargetCommand.h b/Source/cmAddCustomTargetCommand.h
index d2b00ad..9c376c0 100644
--- a/Source/cmAddCustomTargetCommand.h
+++ b/Source/cmAddCustomTargetCommand.h
@@ -27,23 +27,19 @@ public:
/**
* This is a virtual constructor for the command.
*/
- virtual cmCommand* Clone()
- {
- return new cmAddCustomTargetCommand;
- }
+ virtual cmCommand* Clone() { return new cmAddCustomTargetCommand; }
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus &status);
+ cmExecutionStatus& status);
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const
- {return "add_custom_target";}
+ virtual std::string GetName() const { return "add_custom_target"; }
cmTypeMacro(cmAddCustomTargetCommand, cmCommand);
};
diff --git a/Source/cmAddDefinitionsCommand.cxx b/Source/cmAddDefinitionsCommand.cxx
index b813e3e..2d0d026 100644
--- a/Source/cmAddDefinitionsCommand.cxx
+++ b/Source/cmAddDefinitionsCommand.cxx
@@ -12,20 +12,17 @@
#include "cmAddDefinitionsCommand.h"
// cmAddDefinitionsCommand
-bool cmAddDefinitionsCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmAddDefinitionsCommand::InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus&)
{
// it is OK to have no arguments
- if(args.size() < 1 )
- {
+ if (args.size() < 1) {
return true;
- }
+ }
- for(std::vector<std::string>::const_iterator i = args.begin();
- i != args.end(); ++i)
- {
+ for (std::vector<std::string>::const_iterator i = args.begin();
+ i != args.end(); ++i) {
this->Makefile->AddDefineFlag(i->c_str());
- }
+ }
return true;
}
-
diff --git a/Source/cmAddDefinitionsCommand.h b/Source/cmAddDefinitionsCommand.h
index 9800fd2..959ed64 100644
--- a/Source/cmAddDefinitionsCommand.h
+++ b/Source/cmAddDefinitionsCommand.h
@@ -26,26 +26,21 @@ public:
/**
* This is a virtual constructor for the command.
*/
- virtual cmCommand* Clone()
- {
- return new cmAddDefinitionsCommand;
- }
+ virtual cmCommand* Clone() { return new cmAddDefinitionsCommand; }
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus &status);
+ cmExecutionStatus& status);
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const {return "add_definitions";}
+ virtual std::string GetName() const { return "add_definitions"; }
cmTypeMacro(cmAddDefinitionsCommand, cmCommand);
};
-
-
#endif
diff --git a/Source/cmAddDependenciesCommand.cxx b/Source/cmAddDependenciesCommand.cxx
index 3b28359..5cf9d3b 100644
--- a/Source/cmAddDependenciesCommand.cxx
+++ b/Source/cmAddDependenciesCommand.cxx
@@ -14,34 +14,28 @@
#include "cmGlobalGenerator.h"
// cmDependenciesCommand
-bool cmAddDependenciesCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmAddDependenciesCommand::InitialPass(
+ std::vector<std::string> const& args, cmExecutionStatus&)
{
- if(args.size() < 2 )
- {
+ if (args.size() < 2) {
this->SetError("called with incorrect number of arguments");
return false;
- }
+ }
std::string target_name = args[0];
- if(this->Makefile->IsAlias(target_name))
- {
+ if (this->Makefile->IsAlias(target_name)) {
std::ostringstream e;
e << "Cannot add target-level dependencies to alias target \""
<< target_name << "\".\n";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
- }
- if(cmTarget* target = this->Makefile->FindTargetToUse(target_name))
- {
+ }
+ if (cmTarget* target = this->Makefile->FindTargetToUse(target_name)) {
std::vector<std::string>::const_iterator s = args.begin();
++s; // skip over target_name
- for (; s != args.end(); ++s)
- {
+ for (; s != args.end(); ++s) {
target->AddUtility(*s, this->Makefile);
- }
}
- else
- {
+ } else {
std::ostringstream e;
e << "Cannot add target-level dependencies to non-existent target \""
<< target_name << "\".\n"
@@ -50,8 +44,7 @@ bool cmAddDependenciesCommand
<< "If you want to add file-level dependencies see the DEPENDS option "
<< "of the add_custom_target and add_custom_command commands.";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
- }
+ }
return true;
}
-
diff --git a/Source/cmAddDependenciesCommand.h b/Source/cmAddDependenciesCommand.h
index db3712a..202d072 100644
--- a/Source/cmAddDependenciesCommand.h
+++ b/Source/cmAddDependenciesCommand.h
@@ -25,25 +25,21 @@ public:
/**
* This is a virtual constructor for the command.
*/
- virtual cmCommand* Clone()
- {
- return new cmAddDependenciesCommand;
- }
+ virtual cmCommand* Clone() { return new cmAddDependenciesCommand; }
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus &status);
+ cmExecutionStatus& status);
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const { return "add_dependencies";}
+ virtual std::string GetName() const { return "add_dependencies"; }
cmTypeMacro(cmAddDependenciesCommand, cmCommand);
};
-
#endif
diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx
index dccf9d9..fec5eb8 100644
--- a/Source/cmAddExecutableCommand.cxx
+++ b/Source/cmAddExecutableCommand.cxx
@@ -12,14 +12,13 @@
#include "cmAddExecutableCommand.h"
// cmExecutableCommand
-bool cmAddExecutableCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmAddExecutableCommand::InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus&)
{
- if(args.size() < 2 )
- {
+ if (args.size() < 2) {
this->SetError("called with incorrect number of arguments");
return false;
- }
+ }
std::vector<std::string>::const_iterator s = args.begin();
std::string exename = *s;
@@ -31,58 +30,41 @@ bool cmAddExecutableCommand
bool importTarget = false;
bool importGlobal = false;
bool isAlias = false;
- while ( s != args.end() )
- {
- if (*s == "WIN32")
- {
+ while (s != args.end()) {
+ if (*s == "WIN32") {
++s;
use_win32 = true;
- }
- else if ( *s == "MACOSX_BUNDLE" )
- {
+ } else if (*s == "MACOSX_BUNDLE") {
++s;
use_macbundle = true;
- }
- else if(*s == "EXCLUDE_FROM_ALL")
- {
+ } else if (*s == "EXCLUDE_FROM_ALL") {
++s;
excludeFromAll = true;
- }
- else if(*s == "IMPORTED")
- {
- ++s;
- importTarget = true;
- }
- else if(importTarget && *s == "GLOBAL")
- {
+ } else if (*s == "IMPORTED") {
+ ++s;
+ importTarget = true;
+ } else if (importTarget && *s == "GLOBAL") {
++s;
importGlobal = true;
- }
- else if(*s == "ALIAS")
- {
+ } else if (*s == "ALIAS") {
++s;
isAlias = true;
- }
- else
- {
+ } else {
break;
- }
}
+ }
bool nameOk = cmGeneratorExpression::IsValidTargetName(exename) &&
!cmGlobalGenerator::IsReservedTarget(exename);
- if (nameOk && !importTarget && !isAlias)
- {
+ if (nameOk && !importTarget && !isAlias) {
nameOk = exename.find(":") == std::string::npos;
- }
- if (!nameOk)
- {
+ }
+ if (!nameOk) {
cmake::MessageType messageType = cmake::AUTHOR_WARNING;
std::ostringstream e;
bool issueMessage = false;
- switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0037))
- {
+ switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0037)) {
case cmPolicies::WARN:
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0037) << "\n";
issueMessage = true;
@@ -93,9 +75,8 @@ bool cmAddExecutableCommand
case cmPolicies::REQUIRED_ALWAYS:
issueMessage = true;
messageType = cmake::FATAL_ERROR;
- }
- if (issueMessage)
- {
+ }
+ if (issueMessage) {
/* clang-format off */
e << "The target name \"" << exename <<
"\" is reserved or not valid for certain "
@@ -104,147 +85,124 @@ bool cmAddExecutableCommand
/* clang-format on */
this->Makefile->IssueMessage(messageType, e.str());
- if (messageType == cmake::FATAL_ERROR)
- {
+ if (messageType == cmake::FATAL_ERROR) {
return false;
- }
}
}
+ }
// Special modifiers are not allowed with IMPORTED signature.
- if(importTarget
- && (use_win32 || use_macbundle || excludeFromAll))
- {
- if(use_win32)
- {
+ if (importTarget && (use_win32 || use_macbundle || excludeFromAll)) {
+ if (use_win32) {
this->SetError("may not be given WIN32 for an IMPORTED target.");
- }
- else if(use_macbundle)
- {
- this->SetError(
- "may not be given MACOSX_BUNDLE for an IMPORTED target.");
- }
- else // if(excludeFromAll)
- {
+ } else if (use_macbundle) {
+ this->SetError("may not be given MACOSX_BUNDLE for an IMPORTED target.");
+ } else // if(excludeFromAll)
+ {
this->SetError(
"may not be given EXCLUDE_FROM_ALL for an IMPORTED target.");
- }
- return false;
}
- if (isAlias)
- {
- if(!cmGeneratorExpression::IsValidTargetName(exename))
- {
+ return false;
+ }
+ if (isAlias) {
+ if (!cmGeneratorExpression::IsValidTargetName(exename)) {
this->SetError("Invalid name for ALIAS: " + exename);
return false;
- }
- if(excludeFromAll)
- {
+ }
+ if (excludeFromAll) {
this->SetError("EXCLUDE_FROM_ALL with ALIAS makes no sense.");
return false;
- }
- if(importTarget || importGlobal)
- {
+ }
+ if (importTarget || importGlobal) {
this->SetError("IMPORTED with ALIAS is not allowed.");
return false;
- }
- if(args.size() != 3)
- {
+ }
+ if (args.size() != 3) {
std::ostringstream e;
e << "ALIAS requires exactly one target argument.";
this->SetError(e.str());
return false;
- }
+ }
- const char *aliasedName = s->c_str();
- if(this->Makefile->IsAlias(aliasedName))
- {
+ const char* aliasedName = s->c_str();
+ if (this->Makefile->IsAlias(aliasedName)) {
std::ostringstream e;
- e << "cannot create ALIAS target \"" << exename
- << "\" because target \"" << aliasedName << "\" is itself an ALIAS.";
+ e << "cannot create ALIAS target \"" << exename << "\" because target \""
+ << aliasedName << "\" is itself an ALIAS.";
this->SetError(e.str());
return false;
- }
- cmTarget *aliasedTarget =
- this->Makefile->FindTargetToUse(aliasedName, true);
- if(!aliasedTarget)
- {
+ }
+ cmTarget* aliasedTarget =
+ this->Makefile->FindTargetToUse(aliasedName, true);
+ if (!aliasedTarget) {
std::ostringstream e;
- e << "cannot create ALIAS target \"" << exename
- << "\" because target \"" << aliasedName << "\" does not already "
- "exist.";
+ e << "cannot create ALIAS target \"" << exename << "\" because target \""
+ << aliasedName << "\" does not already "
+ "exist.";
this->SetError(e.str());
return false;
- }
+ }
cmState::TargetType type = aliasedTarget->GetType();
- if(type != cmState::EXECUTABLE)
- {
+ if (type != cmState::EXECUTABLE) {
std::ostringstream e;
- e << "cannot create ALIAS target \"" << exename
- << "\" because target \"" << aliasedName << "\" is not an "
- "executable.";
+ e << "cannot create ALIAS target \"" << exename << "\" because target \""
+ << aliasedName << "\" is not an "
+ "executable.";
this->SetError(e.str());
return false;
- }
- if(aliasedTarget->IsImported())
- {
+ }
+ if (aliasedTarget->IsImported()) {
std::ostringstream e;
- e << "cannot create ALIAS target \"" << exename
- << "\" because target \"" << aliasedName << "\" is IMPORTED.";
+ e << "cannot create ALIAS target \"" << exename << "\" because target \""
+ << aliasedName << "\" is IMPORTED.";
this->SetError(e.str());
return false;
- }
+ }
this->Makefile->AddAlias(exename, aliasedName);
return true;
- }
+ }
// Handle imported target creation.
- if(importTarget)
- {
+ if (importTarget) {
// Make sure the target does not already exist.
- if(this->Makefile->FindTargetToUse(exename))
- {
+ if (this->Makefile->FindTargetToUse(exename)) {
std::ostringstream e;
e << "cannot create imported target \"" << exename
<< "\" because another target with the same name already exists.";
this->SetError(e.str());
return false;
- }
+ }
// Create the imported target.
this->Makefile->AddImportedTarget(exename, cmState::EXECUTABLE,
importGlobal);
return true;
- }
+ }
// Enforce name uniqueness.
{
- std::string msg;
- if(!this->Makefile->EnforceUniqueName(exename, msg))
- {
- this->SetError(msg);
- return false;
+ std::string msg;
+ if (!this->Makefile->EnforceUniqueName(exename, msg)) {
+ this->SetError(msg);
+ return false;
}
}
- if (s == args.end())
- {
- this->SetError
- ("called with incorrect number of arguments, no sources provided");
+ if (s == args.end()) {
+ this->SetError(
+ "called with incorrect number of arguments, no sources provided");
return false;
- }
+ }
std::vector<std::string> srclists(s, args.end());
- cmTarget* tgt = this->Makefile->AddExecutable(exename.c_str(), srclists,
- excludeFromAll);
- if ( use_win32 )
- {
+ cmTarget* tgt =
+ this->Makefile->AddExecutable(exename.c_str(), srclists, excludeFromAll);
+ if (use_win32) {
tgt->SetProperty("WIN32_EXECUTABLE", "ON");
- }
- if ( use_macbundle)
- {
+ }
+ if (use_macbundle) {
tgt->SetProperty("MACOSX_BUNDLE", "ON");
- }
+ }
return true;
}
diff --git a/Source/cmAddExecutableCommand.h b/Source/cmAddExecutableCommand.h
index e134077..1e3181f 100644
--- a/Source/cmAddExecutableCommand.h
+++ b/Source/cmAddExecutableCommand.h
@@ -26,25 +26,21 @@ public:
/**
* This is a virtual constructor for the command.
*/
- virtual cmCommand* Clone()
- {
- return new cmAddExecutableCommand;
- }
+ virtual cmCommand* Clone() { return new cmAddExecutableCommand; }
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus &status);
+ cmExecutionStatus& status);
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const { return "add_executable";}
+ virtual std::string GetName() const { return "add_executable"; }
cmTypeMacro(cmAddExecutableCommand, cmCommand);
};
-
#endif
diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx
index e40ecf4..4516ed2 100644
--- a/Source/cmAddLibraryCommand.cxx
+++ b/Source/cmAddLibraryCommand.cxx
@@ -15,21 +15,20 @@
#include "cmake.h"
// cmLibraryCommand
-bool cmAddLibraryCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus&)
{
- if(args.size() < 1 )
- {
+ if (args.size() < 1) {
this->SetError("called with incorrect number of arguments");
return false;
- }
+ }
// Library type defaults to value of BUILD_SHARED_LIBS, if it exists,
// otherwise it defaults to static library.
cmState::TargetType type = cmState::SHARED_LIBRARY;
- if (cmSystemTools::IsOff(this->Makefile->GetDefinition("BUILD_SHARED_LIBS")))
- {
+ if (cmSystemTools::IsOff(
+ this->Makefile->GetDefinition("BUILD_SHARED_LIBS"))) {
type = cmState::STATIC_LIBRARY;
- }
+ }
bool excludeFromAll = false;
bool importTarget = false;
bool importGlobal = false;
@@ -45,186 +44,145 @@ bool cmAddLibraryCommand
// source list name. There may be two keyword arguments, check for them
bool haveSpecifiedType = false;
bool isAlias = false;
- while ( s != args.end() )
- {
+ while (s != args.end()) {
std::string libType = *s;
- if(libType == "STATIC")
- {
- if (type == cmState::INTERFACE_LIBRARY)
- {
+ if (libType == "STATIC") {
+ if (type == cmState::INTERFACE_LIBRARY) {
std::ostringstream e;
e << "INTERFACE library specified with conflicting STATIC type.";
this->SetError(e.str());
return false;
- }
+ }
++s;
type = cmState::STATIC_LIBRARY;
haveSpecifiedType = true;
- }
- else if(libType == "SHARED")
- {
- if (type == cmState::INTERFACE_LIBRARY)
- {
+ } else if (libType == "SHARED") {
+ if (type == cmState::INTERFACE_LIBRARY) {
std::ostringstream e;
e << "INTERFACE library specified with conflicting SHARED type.";
this->SetError(e.str());
return false;
- }
+ }
++s;
type = cmState::SHARED_LIBRARY;
haveSpecifiedType = true;
- }
- else if(libType == "MODULE")
- {
- if (type == cmState::INTERFACE_LIBRARY)
- {
+ } else if (libType == "MODULE") {
+ if (type == cmState::INTERFACE_LIBRARY) {
std::ostringstream e;
e << "INTERFACE library specified with conflicting MODULE type.";
this->SetError(e.str());
return false;
- }
+ }
++s;
type = cmState::MODULE_LIBRARY;
haveSpecifiedType = true;
- }
- else if(libType == "OBJECT")
- {
- if (type == cmState::INTERFACE_LIBRARY)
- {
+ } else if (libType == "OBJECT") {
+ if (type == cmState::INTERFACE_LIBRARY) {
std::ostringstream e;
e << "INTERFACE library specified with conflicting OBJECT type.";
this->SetError(e.str());
return false;
- }
+ }
++s;
type = cmState::OBJECT_LIBRARY;
haveSpecifiedType = true;
- }
- else if(libType == "UNKNOWN")
- {
- if (type == cmState::INTERFACE_LIBRARY)
- {
+ } else if (libType == "UNKNOWN") {
+ if (type == cmState::INTERFACE_LIBRARY) {
std::ostringstream e;
e << "INTERFACE library specified with conflicting UNKNOWN type.";
this->SetError(e.str());
return false;
- }
+ }
++s;
type = cmState::UNKNOWN_LIBRARY;
haveSpecifiedType = true;
- }
- else if(libType == "ALIAS")
- {
- if (type == cmState::INTERFACE_LIBRARY)
- {
+ } else if (libType == "ALIAS") {
+ if (type == cmState::INTERFACE_LIBRARY) {
std::ostringstream e;
e << "INTERFACE library specified with conflicting ALIAS type.";
this->SetError(e.str());
return false;
- }
+ }
++s;
isAlias = true;
- }
- else if(libType == "INTERFACE")
- {
- if (haveSpecifiedType)
- {
+ } else if (libType == "INTERFACE") {
+ if (haveSpecifiedType) {
std::ostringstream e;
e << "INTERFACE library specified with conflicting/multiple types.";
this->SetError(e.str());
return false;
- }
- if (isAlias)
- {
+ }
+ if (isAlias) {
std::ostringstream e;
e << "INTERFACE library specified with conflicting ALIAS type.";
this->SetError(e.str());
return false;
- }
- if (excludeFromAll)
- {
+ }
+ if (excludeFromAll) {
std::ostringstream e;
e << "INTERFACE library may not be used with EXCLUDE_FROM_ALL.";
this->SetError(e.str());
return false;
- }
+ }
++s;
type = cmState::INTERFACE_LIBRARY;
haveSpecifiedType = true;
- }
- else if(*s == "EXCLUDE_FROM_ALL")
- {
- if (type == cmState::INTERFACE_LIBRARY)
- {
+ } else if (*s == "EXCLUDE_FROM_ALL") {
+ if (type == cmState::INTERFACE_LIBRARY) {
std::ostringstream e;
e << "INTERFACE library may not be used with EXCLUDE_FROM_ALL.";
this->SetError(e.str());
return false;
- }
+ }
++s;
excludeFromAll = true;
- }
- else if(*s == "IMPORTED")
- {
+ } else if (*s == "IMPORTED") {
++s;
importTarget = true;
- }
- else if(importTarget && *s == "GLOBAL")
- {
+ } else if (importTarget && *s == "GLOBAL") {
++s;
importGlobal = true;
- }
- else if(type == cmState::INTERFACE_LIBRARY && *s == "GLOBAL")
- {
+ } else if (type == cmState::INTERFACE_LIBRARY && *s == "GLOBAL") {
std::ostringstream e;
e << "GLOBAL option may only be used with IMPORTED libraries.";
this->SetError(e.str());
return false;
- }
- else
- {
+ } else {
break;
- }
}
+ }
- if (type == cmState::INTERFACE_LIBRARY)
- {
- if (s != args.end())
- {
+ if (type == cmState::INTERFACE_LIBRARY) {
+ if (s != args.end()) {
std::ostringstream e;
e << "INTERFACE library requires no source arguments.";
this->SetError(e.str());
return false;
- }
- if (importGlobal && !importTarget)
- {
+ }
+ if (importGlobal && !importTarget) {
std::ostringstream e;
e << "INTERFACE library specified as GLOBAL, but not as IMPORTED.";
this->SetError(e.str());
return false;
- }
}
+ }
bool nameOk = cmGeneratorExpression::IsValidTargetName(libName) &&
!cmGlobalGenerator::IsReservedTarget(libName);
- if (nameOk && !importTarget && !isAlias)
- {
+ if (nameOk && !importTarget && !isAlias) {
nameOk = libName.find(":") == std::string::npos;
- }
- if (!nameOk)
- {
+ }
+ if (!nameOk) {
cmake::MessageType messageType = cmake::AUTHOR_WARNING;
std::ostringstream e;
bool issueMessage = false;
- switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0037))
- {
+ switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0037)) {
case cmPolicies::WARN:
- if(type != cmState::INTERFACE_LIBRARY)
- {
+ if (type != cmState::INTERFACE_LIBRARY) {
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0037) << "\n";
issueMessage = true;
- }
+ }
case cmPolicies::OLD:
break;
case cmPolicies::NEW:
@@ -232,208 +190,177 @@ bool cmAddLibraryCommand
case cmPolicies::REQUIRED_ALWAYS:
issueMessage = true;
messageType = cmake::FATAL_ERROR;
- }
- if (issueMessage)
- {
- e << "The target name \"" << libName <<
- "\" is reserved or not valid for certain "
- "CMake features, such as generator expressions, and may result "
- "in undefined behavior.";
+ }
+ if (issueMessage) {
+ e << "The target name \"" << libName
+ << "\" is reserved or not valid for certain "
+ "CMake features, such as generator expressions, and may result "
+ "in undefined behavior.";
this->Makefile->IssueMessage(messageType, e.str());
- if (messageType == cmake::FATAL_ERROR)
- {
+ if (messageType == cmake::FATAL_ERROR) {
return false;
- }
}
}
+ }
- if (isAlias)
- {
- if(!cmGeneratorExpression::IsValidTargetName(libName))
- {
+ if (isAlias) {
+ if (!cmGeneratorExpression::IsValidTargetName(libName)) {
this->SetError("Invalid name for ALIAS: " + libName);
return false;
- }
- if(excludeFromAll)
- {
+ }
+ if (excludeFromAll) {
this->SetError("EXCLUDE_FROM_ALL with ALIAS makes no sense.");
return false;
- }
- if(importTarget || importGlobal)
- {
+ }
+ if (importTarget || importGlobal) {
this->SetError("IMPORTED with ALIAS is not allowed.");
return false;
- }
- if(args.size() != 3)
- {
+ }
+ if (args.size() != 3) {
std::ostringstream e;
e << "ALIAS requires exactly one target argument.";
this->SetError(e.str());
return false;
- }
+ }
- const char *aliasedName = s->c_str();
- if(this->Makefile->IsAlias(aliasedName))
- {
+ const char* aliasedName = s->c_str();
+ if (this->Makefile->IsAlias(aliasedName)) {
std::ostringstream e;
- e << "cannot create ALIAS target \"" << libName
- << "\" because target \"" << aliasedName << "\" is itself an ALIAS.";
+ e << "cannot create ALIAS target \"" << libName << "\" because target \""
+ << aliasedName << "\" is itself an ALIAS.";
this->SetError(e.str());
return false;
- }
- cmTarget *aliasedTarget =
- this->Makefile->FindTargetToUse(aliasedName, true);
- if(!aliasedTarget)
- {
+ }
+ cmTarget* aliasedTarget =
+ this->Makefile->FindTargetToUse(aliasedName, true);
+ if (!aliasedTarget) {
std::ostringstream e;
- e << "cannot create ALIAS target \"" << libName
- << "\" because target \"" << aliasedName << "\" does not already "
- "exist.";
+ e << "cannot create ALIAS target \"" << libName << "\" because target \""
+ << aliasedName << "\" does not already "
+ "exist.";
this->SetError(e.str());
return false;
- }
+ }
cmState::TargetType aliasedType = aliasedTarget->GetType();
- if(aliasedType != cmState::SHARED_LIBRARY
- && aliasedType != cmState::STATIC_LIBRARY
- && aliasedType != cmState::MODULE_LIBRARY
- && aliasedType != cmState::OBJECT_LIBRARY
- && aliasedType != cmState::INTERFACE_LIBRARY)
- {
+ if (aliasedType != cmState::SHARED_LIBRARY &&
+ aliasedType != cmState::STATIC_LIBRARY &&
+ aliasedType != cmState::MODULE_LIBRARY &&
+ aliasedType != cmState::OBJECT_LIBRARY &&
+ aliasedType != cmState::INTERFACE_LIBRARY) {
std::ostringstream e;
- e << "cannot create ALIAS target \"" << libName
- << "\" because target \"" << aliasedName << "\" is not a library.";
+ e << "cannot create ALIAS target \"" << libName << "\" because target \""
+ << aliasedName << "\" is not a library.";
this->SetError(e.str());
return false;
- }
- if(aliasedTarget->IsImported())
- {
+ }
+ if (aliasedTarget->IsImported()) {
std::ostringstream e;
- e << "cannot create ALIAS target \"" << libName
- << "\" because target \"" << aliasedName << "\" is IMPORTED.";
+ e << "cannot create ALIAS target \"" << libName << "\" because target \""
+ << aliasedName << "\" is IMPORTED.";
this->SetError(e.str());
return false;
- }
+ }
this->Makefile->AddAlias(libName, aliasedName);
return true;
- }
+ }
- if(importTarget && excludeFromAll)
- {
+ if (importTarget && excludeFromAll) {
this->SetError("excludeFromAll with IMPORTED target makes no sense.");
return false;
- }
+ }
/* ideally we should check whether for the linker language of the target
CMAKE_${LANG}_CREATE_SHARED_LIBRARY is defined and if not default to
STATIC. But at this point we know only the name of the target, but not
yet its linker language. */
- if ((type == cmState::SHARED_LIBRARY ||
- type == cmState::MODULE_LIBRARY) &&
- (this->Makefile->GetState()->GetGlobalPropertyAsBool(
- "TARGET_SUPPORTS_SHARED_LIBS") == false))
- {
+ if ((type == cmState::SHARED_LIBRARY || type == cmState::MODULE_LIBRARY) &&
+ (this->Makefile->GetState()->GetGlobalPropertyAsBool(
+ "TARGET_SUPPORTS_SHARED_LIBS") == false)) {
std::ostringstream w;
- w <<
- "ADD_LIBRARY called with " <<
- (type==cmState::SHARED_LIBRARY ? "SHARED" : "MODULE") <<
- " option but the target platform does not support dynamic linking. "
- "Building a STATIC library instead. This may lead to problems.";
+ w << "ADD_LIBRARY called with "
+ << (type == cmState::SHARED_LIBRARY ? "SHARED" : "MODULE")
+ << " option but the target platform does not support dynamic linking. "
+ "Building a STATIC library instead. This may lead to problems.";
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str());
type = cmState::STATIC_LIBRARY;
- }
+ }
// Handle imported target creation.
- if(importTarget)
- {
+ if (importTarget) {
// The IMPORTED signature requires a type to be specified explicitly.
- if (!haveSpecifiedType)
- {
+ if (!haveSpecifiedType) {
this->SetError("called with IMPORTED argument but no library type.");
return false;
- }
- if(type == cmState::OBJECT_LIBRARY)
- {
+ }
+ if (type == cmState::OBJECT_LIBRARY) {
this->Makefile->IssueMessage(
cmake::FATAL_ERROR,
- "The OBJECT library type may not be used for IMPORTED libraries."
- );
+ "The OBJECT library type may not be used for IMPORTED libraries.");
return true;
- }
- if(type == cmState::INTERFACE_LIBRARY)
- {
- if (!cmGeneratorExpression::IsValidTargetName(libName))
- {
+ }
+ if (type == cmState::INTERFACE_LIBRARY) {
+ if (!cmGeneratorExpression::IsValidTargetName(libName)) {
std::ostringstream e;
e << "Invalid name for IMPORTED INTERFACE library target: " << libName;
this->SetError(e.str());
return false;
- }
}
+ }
// Make sure the target does not already exist.
- if(this->Makefile->FindTargetToUse(libName))
- {
+ if (this->Makefile->FindTargetToUse(libName)) {
std::ostringstream e;
e << "cannot create imported target \"" << libName
<< "\" because another target with the same name already exists.";
this->SetError(e.str());
return false;
- }
+ }
// Create the imported target.
this->Makefile->AddImportedTarget(libName, type, importGlobal);
return true;
- }
+ }
// A non-imported target may not have UNKNOWN type.
- if(type == cmState::UNKNOWN_LIBRARY)
- {
+ if (type == cmState::UNKNOWN_LIBRARY) {
this->Makefile->IssueMessage(
cmake::FATAL_ERROR,
- "The UNKNOWN library type may be used only for IMPORTED libraries."
- );
+ "The UNKNOWN library type may be used only for IMPORTED libraries.");
return true;
- }
+ }
// Enforce name uniqueness.
{
- std::string msg;
- if(!this->Makefile->EnforceUniqueName(libName, msg))
- {
- this->SetError(msg);
- return false;
+ std::string msg;
+ if (!this->Makefile->EnforceUniqueName(libName, msg)) {
+ this->SetError(msg);
+ return false;
}
}
std::vector<std::string> srclists;
- if(type == cmState::INTERFACE_LIBRARY)
- {
- if (!cmGeneratorExpression::IsValidTargetName(libName)
- || libName.find("::") != std::string::npos)
- {
+ if (type == cmState::INTERFACE_LIBRARY) {
+ if (!cmGeneratorExpression::IsValidTargetName(libName) ||
+ libName.find("::") != std::string::npos) {
std::ostringstream e;
e << "Invalid name for INTERFACE library target: " << libName;
this->SetError(e.str());
return false;
- }
+ }
- this->Makefile->AddLibrary(libName,
- type,
- srclists,
- excludeFromAll);
+ this->Makefile->AddLibrary(libName, type, srclists, excludeFromAll);
return true;
- }
+ }
- if (s == args.end())
- {
+ if (s == args.end()) {
std::string msg = "You have called ADD_LIBRARY for library ";
msg += args[0];
msg += " without any source files. This typically indicates a problem ";
msg += "with your CMakeLists.txt file";
- cmSystemTools::Message(msg.c_str() ,"Warning");
- }
+ cmSystemTools::Message(msg.c_str(), "Warning");
+ }
srclists.insert(srclists.end(), s, args.end());
@@ -441,5 +368,3 @@ bool cmAddLibraryCommand
return true;
}
-
-
diff --git a/Source/cmAddLibraryCommand.h b/Source/cmAddLibraryCommand.h
index 350708b..0f0f768 100644
--- a/Source/cmAddLibraryCommand.h
+++ b/Source/cmAddLibraryCommand.h
@@ -26,25 +26,21 @@ public:
/**
* This is a virtual constructor for the command.
*/
- virtual cmCommand* Clone()
- {
- return new cmAddLibraryCommand;
- }
+ virtual cmCommand* Clone() { return new cmAddLibraryCommand; }
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus &status);
+ cmExecutionStatus& status);
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const { return "add_library";}
+ virtual std::string GetName() const { return "add_library"; }
cmTypeMacro(cmAddLibraryCommand, cmCommand);
};
-
#endif
diff --git a/Source/cmAddSubDirectoryCommand.cxx b/Source/cmAddSubDirectoryCommand.cxx
index 69c6a14..63a9051 100644
--- a/Source/cmAddSubDirectoryCommand.cxx
+++ b/Source/cmAddSubDirectoryCommand.cxx
@@ -12,14 +12,13 @@
#include "cmAddSubDirectoryCommand.h"
// cmAddSubDirectoryCommand
-bool cmAddSubDirectoryCommand::InitialPass
-(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmAddSubDirectoryCommand::InitialPass(
+ std::vector<std::string> const& args, cmExecutionStatus&)
{
- if(args.size() < 1 )
- {
+ if (args.size() < 1) {
this->SetError("called with incorrect number of arguments");
return false;
- }
+ }
// store the binpath
std::string srcArg = args[0];
@@ -30,57 +29,45 @@ bool cmAddSubDirectoryCommand::InitialPass
// process the rest of the arguments looking for optional args
std::vector<std::string>::const_iterator i = args.begin();
++i;
- for(;i != args.end(); ++i)
- {
- if(*i == "EXCLUDE_FROM_ALL")
- {
+ for (; i != args.end(); ++i) {
+ if (*i == "EXCLUDE_FROM_ALL") {
excludeFromAll = true;
continue;
- }
- else if (binArg.empty())
- {
+ } else if (binArg.empty()) {
binArg = *i;
- }
- else
- {
+ } else {
this->SetError("called with incorrect number of arguments");
return false;
- }
}
+ }
// Compute the full path to the specified source directory.
// Interpret a relative path with respect to the current source directory.
std::string srcPath;
- if(cmSystemTools::FileIsFullPath(srcArg.c_str()))
- {
+ if (cmSystemTools::FileIsFullPath(srcArg.c_str())) {
srcPath = srcArg;
- }
- else
- {
+ } else {
srcPath = this->Makefile->GetCurrentSourceDirectory();
srcPath += "/";
srcPath += srcArg;
- }
- if(!cmSystemTools::FileIsDirectory(srcPath))
- {
+ }
+ if (!cmSystemTools::FileIsDirectory(srcPath)) {
std::string error = "given source \"";
error += srcArg;
error += "\" which is not an existing directory.";
this->SetError(error);
return false;
- }
+ }
srcPath = cmSystemTools::CollapseFullPath(srcPath);
// Compute the full path to the binary directory.
std::string binPath;
- if(binArg.empty())
- {
+ if (binArg.empty()) {
// No binary directory was specified. If the source directory is
// not a subdirectory of the current directory then it is an
// error.
- if(!cmSystemTools::IsSubDirectory(srcPath,
- this->Makefile->GetCurrentSourceDirectory()))
- {
+ if (!cmSystemTools::IsSubDirectory(
+ srcPath, this->Makefile->GetCurrentSourceDirectory())) {
std::ostringstream e;
e << "not given a binary directory but the given source directory "
<< "\"" << srcPath << "\" is not a subdirectory of \""
@@ -89,7 +76,7 @@ bool cmAddSubDirectoryCommand::InitialPass
<< "must be explicitly specified.";
this->SetError(e.str());
return false;
- }
+ }
// Remove the CurrentDirectory from the srcPath and replace it
// with the CurrentOutputDirectory.
@@ -97,32 +84,28 @@ bool cmAddSubDirectoryCommand::InitialPass
const char* bin = this->Makefile->GetCurrentBinaryDirectory();
size_t srcLen = strlen(src);
size_t binLen = strlen(bin);
- if(srcLen > 0 && src[srcLen-1] == '/')
- { --srcLen; }
- if(binLen > 0 && bin[binLen-1] == '/')
- { --binLen; }
- binPath = std::string(bin, binLen) + srcPath.substr(srcLen);
+ if (srcLen > 0 && src[srcLen - 1] == '/') {
+ --srcLen;
}
- else
- {
+ if (binLen > 0 && bin[binLen - 1] == '/') {
+ --binLen;
+ }
+ binPath = std::string(bin, binLen) + srcPath.substr(srcLen);
+ } else {
// Use the binary directory specified.
// Interpret a relative path with respect to the current binary directory.
- if(cmSystemTools::FileIsFullPath(binArg.c_str()))
- {
+ if (cmSystemTools::FileIsFullPath(binArg.c_str())) {
binPath = binArg;
- }
- else
- {
+ } else {
binPath = this->Makefile->GetCurrentBinaryDirectory();
binPath += "/";
binPath += binArg;
- }
}
+ }
binPath = cmSystemTools::CollapseFullPath(binPath);
// Add the subdirectory using the computed full paths.
- this->Makefile->AddSubDirectory(srcPath, binPath,
- excludeFromAll, true);
+ this->Makefile->AddSubDirectory(srcPath, binPath, excludeFromAll, true);
return true;
}
diff --git a/Source/cmAddSubDirectoryCommand.h b/Source/cmAddSubDirectoryCommand.h
index abf3efc..786c8b0 100644
--- a/Source/cmAddSubDirectoryCommand.h
+++ b/Source/cmAddSubDirectoryCommand.h
@@ -27,26 +27,21 @@ public:
/**
* This is a virtual constructor for the command.
*/
- virtual cmCommand* Clone()
- {
- return new cmAddSubDirectoryCommand;
- }
+ virtual cmCommand* Clone() { return new cmAddSubDirectoryCommand; }
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus &status);
+ cmExecutionStatus& status);
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const { return "add_subdirectory";}
+ virtual std::string GetName() const { return "add_subdirectory"; }
cmTypeMacro(cmAddSubDirectoryCommand, cmCommand);
};
-
-
#endif
diff --git a/Source/cmAddTestCommand.cxx b/Source/cmAddTestCommand.cxx
index e813415..204dd97 100644
--- a/Source/cmAddTestCommand.cxx
+++ b/Source/cmAddTestCommand.cxx
@@ -15,24 +15,21 @@
#include "cmTest.h"
-
// cmExecutableCommand
-bool cmAddTestCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmAddTestCommand::InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus&)
{
- if(!args.empty() && args[0] == "NAME")
- {
+ if (!args.empty() && args[0] == "NAME") {
return this->HandleNameMode(args);
- }
+ }
// First argument is the name of the test Second argument is the name of
// the executable to run (a target or external program) Remaining arguments
// are the arguments to pass to the executable
- if(args.size() < 2 )
- {
+ if (args.size() < 2) {
this->SetError("called with incorrect number of arguments");
return false;
- }
+ }
// Collect the command with arguments.
std::vector<std::string> command;
@@ -41,25 +38,21 @@ bool cmAddTestCommand
// Create the test but add a generator only the first time it is
// seen. This preserves behavior from before test generators.
cmTest* test = this->Makefile->GetTest(args[0]);
- if(test)
- {
+ if (test) {
// If the test was already added by a new-style signature do not
// allow it to be duplicated.
- if(!test->GetOldStyle())
- {
+ if (!test->GetOldStyle()) {
std::ostringstream e;
e << " given test name \"" << args[0]
<< "\" which already exists in this directory.";
this->SetError(e.str());
return false;
- }
}
- else
- {
+ } else {
test = this->Makefile->CreateTest(args[0]);
test->SetOldStyle(true);
this->Makefile->AddTestGenerator(new cmTestGenerator(test));
- }
+ }
test->SetCommand(command);
return true;
@@ -73,7 +66,8 @@ bool cmAddTestCommand::HandleNameMode(std::vector<std::string> const& args)
std::vector<std::string> command;
// Read the arguments.
- enum Doing {
+ enum Doing
+ {
DoingName,
DoingCommand,
DoingConfigs,
@@ -81,94 +75,71 @@ bool cmAddTestCommand::HandleNameMode(std::vector<std::string> const& args)
DoingNone
};
Doing doing = DoingName;
- for(unsigned int i=1; i < args.size(); ++i)
- {
- if(args[i] == "COMMAND")
- {
- if(!command.empty())
- {
+ for (unsigned int i = 1; i < args.size(); ++i) {
+ if (args[i] == "COMMAND") {
+ if (!command.empty()) {
this->SetError(" may be given at most one COMMAND.");
return false;
- }
- doing = DoingCommand;
}
- else if(args[i] == "CONFIGURATIONS")
- {
- if(!configurations.empty())
- {
+ doing = DoingCommand;
+ } else if (args[i] == "CONFIGURATIONS") {
+ if (!configurations.empty()) {
this->SetError(" may be given at most one set of CONFIGURATIONS.");
return false;
- }
- doing = DoingConfigs;
}
- else if(args[i] == "WORKING_DIRECTORY")
- {
- if(!working_directory.empty())
- {
+ doing = DoingConfigs;
+ } else if (args[i] == "WORKING_DIRECTORY") {
+ if (!working_directory.empty()) {
this->SetError(" may be given at most one WORKING_DIRECTORY.");
return false;
- }
- doing = DoingWorkingDirectory;
}
- else if(doing == DoingName)
- {
+ doing = DoingWorkingDirectory;
+ } else if (doing == DoingName) {
name = args[i];
doing = DoingNone;
- }
- else if(doing == DoingCommand)
- {
+ } else if (doing == DoingCommand) {
command.push_back(args[i]);
- }
- else if(doing == DoingConfigs)
- {
+ } else if (doing == DoingConfigs) {
configurations.push_back(args[i]);
- }
- else if(doing == DoingWorkingDirectory)
- {
+ } else if (doing == DoingWorkingDirectory) {
working_directory = args[i];
doing = DoingNone;
- }
- else
- {
+ } else {
std::ostringstream e;
e << " given unknown argument:\n " << args[i] << "\n";
this->SetError(e.str());
return false;
- }
}
+ }
// Require a test name.
- if(name.empty())
- {
+ if (name.empty()) {
this->SetError(" must be given non-empty NAME.");
return false;
- }
+ }
// Require a command.
- if(command.empty())
- {
+ if (command.empty()) {
this->SetError(" must be given non-empty COMMAND.");
return false;
- }
+ }
// Require a unique test name within the directory.
- if(this->Makefile->GetTest(name))
- {
+ if (this->Makefile->GetTest(name)) {
std::ostringstream e;
e << " given test NAME \"" << name
<< "\" which already exists in this directory.";
this->SetError(e.str());
return false;
- }
+ }
// Add the test.
cmTest* test = this->Makefile->CreateTest(name);
test->SetOldStyle(false);
test->SetCommand(command);
- if(!working_directory.empty())
- {
+ if (!working_directory.empty()) {
test->SetProperty("WORKING_DIRECTORY", working_directory.c_str());
- }
+ }
this->Makefile->AddTestGenerator(new cmTestGenerator(test, configurations));
return true;
diff --git a/Source/cmAddTestCommand.h b/Source/cmAddTestCommand.h
index 624288f..295fb78 100644
--- a/Source/cmAddTestCommand.h
+++ b/Source/cmAddTestCommand.h
@@ -25,27 +25,24 @@ public:
/**
* This is a virtual constructor for the command.
*/
- virtual cmCommand* Clone()
- {
- return new cmAddTestCommand;
- }
+ virtual cmCommand* Clone() { return new cmAddTestCommand; }
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus &status);
+ cmExecutionStatus& status);
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const { return "add_test";}
+ virtual std::string GetName() const { return "add_test"; }
cmTypeMacro(cmAddTestCommand, cmCommand);
+
private:
bool HandleNameMode(std::vector<std::string> const& args);
};
-
#endif
diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h
index bb65ea5..76acaca 100644
--- a/Source/cmAlgorithms.h
+++ b/Source/cmAlgorithms.h
@@ -14,65 +14,74 @@
#include "cmStandardIncludes.h"
-inline bool cmHasLiteralPrefixImpl(const std::string &str1,
- const char *str2,
- size_t N)
+inline bool cmHasLiteralPrefixImpl(const std::string& str1, const char* str2,
+ size_t N)
{
return strncmp(str1.c_str(), str2, N) == 0;
}
-inline bool cmHasLiteralPrefixImpl(const char* str1,
- const char *str2,
- size_t N)
+inline bool cmHasLiteralPrefixImpl(const char* str1, const char* str2,
+ size_t N)
{
return strncmp(str1, str2, N) == 0;
}
-inline bool cmHasLiteralSuffixImpl(const std::string &str1,
- const char *str2,
+inline bool cmHasLiteralSuffixImpl(const std::string& str1, const char* str2,
size_t N)
{
size_t len = str1.size();
return len >= N && strcmp(str1.c_str() + len - N, str2) == 0;
}
-inline bool cmHasLiteralSuffixImpl(const char* str1,
- const char* str2,
+inline bool cmHasLiteralSuffixImpl(const char* str1, const char* str2,
size_t N)
{
size_t len = strlen(str1);
return len >= N && strcmp(str1 + len - N, str2) == 0;
}
-template<typename T, size_t N>
-const T* cmArrayBegin(const T (&a)[N]) { return a; }
-template<typename T, size_t N>
-const T* cmArrayEnd(const T (&a)[N]) { return a + N; }
-template<typename T, size_t N>
-size_t cmArraySize(const T (&)[N]) { return N; }
+template <typename T, size_t N>
+const T* cmArrayBegin(const T (&a)[N])
+{
+ return a;
+}
+template <typename T, size_t N>
+const T* cmArrayEnd(const T (&a)[N])
+{
+ return a + N;
+}
+template <typename T, size_t N>
+size_t cmArraySize(const T (&)[N])
+{
+ return N;
+}
-template<typename T, size_t N>
+template <typename T, size_t N>
bool cmHasLiteralPrefix(const T& str1, const char (&str2)[N])
{
return cmHasLiteralPrefixImpl(str1, str2, N - 1);
}
-template<typename T, size_t N>
+template <typename T, size_t N>
bool cmHasLiteralSuffix(const T& str1, const char (&str2)[N])
{
return cmHasLiteralSuffixImpl(str1, str2, N - 1);
}
-struct cmStrCmp {
- cmStrCmp(const char *test) : m_test(test) {}
- cmStrCmp(const std::string &test) : m_test(test) {}
-
- bool operator()(const std::string& input) const
+struct cmStrCmp
+{
+ cmStrCmp(const char* test)
+ : m_test(test)
{
- return m_test == input;
}
+ cmStrCmp(const std::string& test)
+ : m_test(test)
+ {
+ }
+
+ bool operator()(const std::string& input) const { return m_test == input; }
- bool operator()(const char * input) const
+ bool operator()(const char* input) const
{
return strcmp(input, m_test.c_str()) == 0;
}
@@ -81,11 +90,11 @@ private:
const std::string m_test;
};
-template<typename FwdIt>
+template <typename FwdIt>
FwdIt cmRotate(FwdIt first, FwdIt middle, FwdIt last)
{
const typename std::iterator_traits<FwdIt>::difference_type dist =
- std::distance(middle, last);
+ std::distance(middle, last);
std::rotate(first, middle, last);
std::advance(first, dist);
return first;
@@ -93,36 +102,41 @@ FwdIt cmRotate(FwdIt first, FwdIt middle, FwdIt last)
namespace ContainerAlgorithms {
-template<typename T>
+template <typename T>
struct cmIsPair
{
- enum { value = false };
+ enum
+ {
+ value = false
+ };
};
-template<typename K, typename V>
+template <typename K, typename V>
struct cmIsPair<std::pair<K, V> >
{
- enum { value = true };
+ enum
+ {
+ value = true
+ };
};
-template<typename Range,
- bool valueTypeIsPair = cmIsPair<typename Range::value_type>::value>
+template <typename Range,
+ bool valueTypeIsPair = cmIsPair<typename Range::value_type>::value>
struct DefaultDeleter
{
- void operator()(typename Range::value_type value) const {
- delete value;
- }
+ void operator()(typename Range::value_type value) const { delete value; }
};
-template<typename Range>
+template <typename Range>
struct DefaultDeleter<Range, /* valueTypeIsPair = */ true>
{
- void operator()(typename Range::value_type value) const {
+ void operator()(typename Range::value_type value) const
+ {
delete value.second;
}
};
-template<typename FwdIt>
+template <typename FwdIt>
FwdIt RemoveN(FwdIt i1, FwdIt i2, size_t n)
{
FwdIt m = i1;
@@ -130,7 +144,7 @@ FwdIt RemoveN(FwdIt i1, FwdIt i2, size_t n)
return cmRotate(i1, m, i2);
}
-template<typename Range>
+template <typename Range>
struct BinarySearcher
{
typedef typename Range::value_type argument_type;
@@ -143,13 +157,13 @@ struct BinarySearcher
{
return std::binary_search(m_range.begin(), m_range.end(), item);
}
+
private:
Range const& m_range;
};
-
}
-template<typename const_iterator_>
+template <typename const_iterator_>
struct cmRange
{
typedef const_iterator_ const_iterator;
@@ -157,7 +171,10 @@ struct cmRange
typedef typename std::iterator_traits<const_iterator>::difference_type
difference_type;
cmRange(const_iterator begin_, const_iterator end_)
- : Begin(begin_), End(end_) {}
+ : Begin(begin_)
+ , End(end_)
+ {
+ }
const_iterator begin() const { return Begin; }
const_iterator end() const { return End; }
bool empty() const { return std::distance(Begin, End) == 0; }
@@ -173,6 +190,7 @@ struct cmRange
std::advance(End, -amount);
return *this;
}
+
private:
const_iterator Begin;
const_iterator End;
@@ -181,73 +199,68 @@ private:
typedef cmRange<std::vector<std::string>::const_iterator> cmStringRange;
class cmListFileBacktrace;
-typedef
-cmRange<std::vector<cmListFileBacktrace>::const_iterator> cmBacktraceRange;
+typedef cmRange<std::vector<cmListFileBacktrace>::const_iterator>
+ cmBacktraceRange;
-template<typename Iter1, typename Iter2>
+template <typename Iter1, typename Iter2>
cmRange<Iter1> cmMakeRange(Iter1 begin, Iter2 end)
{
return cmRange<Iter1>(begin, end);
}
-template<typename Range>
-cmRange<typename Range::const_iterator>
-cmMakeRange(Range const& range)
+template <typename Range>
+cmRange<typename Range::const_iterator> cmMakeRange(Range const& range)
{
- return cmRange<typename Range::const_iterator>(
- range.begin(), range.end());
+ return cmRange<typename Range::const_iterator>(range.begin(), range.end());
}
-template<typename Range>
+template <typename Range>
void cmDeleteAll(Range const& r)
{
std::for_each(r.begin(), r.end(),
ContainerAlgorithms::DefaultDeleter<Range>());
}
-template<typename Range>
+template <typename Range>
std::string cmJoin(Range const& r, const char* delimiter)
{
- if (r.empty())
- {
+ if (r.empty()) {
return std::string();
- }
+ }
std::ostringstream os;
typedef typename Range::value_type ValueType;
typedef typename Range::const_iterator InputIt;
const InputIt first = r.begin();
InputIt last = r.end();
--last;
- std::copy(first, last,
- std::ostream_iterator<ValueType>(os, delimiter));
+ std::copy(first, last, std::ostream_iterator<ValueType>(os, delimiter));
os << *last;
return os.str();
}
-template<typename Range>
+template <typename Range>
std::string cmJoin(Range const& r, std::string delimiter)
{
return cmJoin(r, delimiter.c_str());
}
-template<typename Range>
+template <typename Range>
typename Range::const_iterator cmRemoveN(Range& r, size_t n)
{
return ContainerAlgorithms::RemoveN(r.begin(), r.end(), n);
}
-template<typename Range, typename InputRange>
+template <typename Range, typename InputRange>
typename Range::const_iterator cmRemoveIndices(Range& r, InputRange const& rem)
{
typename InputRange::const_iterator remIt = rem.begin();
typename InputRange::const_iterator remEnd = rem.end();
const typename Range::iterator rangeEnd = r.end();
- if (remIt == remEnd)
- {
+ if (remIt == remEnd) {
return rangeEnd;
- }
+ }
typename Range::iterator writer = r.begin();
std::advance(writer, *remIt);
@@ -255,17 +268,16 @@ typename Range::const_iterator cmRemoveIndices(Range& r, InputRange const& rem)
typename InputRange::value_type prevRem = *remIt;
++remIt;
size_t count = 1;
- for ( ; writer != rangeEnd && remIt != remEnd; ++count, ++remIt)
- {
+ for (; writer != rangeEnd && remIt != remEnd; ++count, ++remIt) {
std::advance(pivot, *remIt - prevRem);
prevRem = *remIt;
writer = ContainerAlgorithms::RemoveN(writer, pivot, count);
- }
+ }
return ContainerAlgorithms::RemoveN(writer, rangeEnd, count);
}
-template<typename Range, typename MatchRange>
-typename Range::const_iterator cmRemoveMatching(Range &r, MatchRange const& m)
+template <typename Range, typename MatchRange>
+typename Range::const_iterator cmRemoveMatching(Range& r, MatchRange const& m)
{
return std::remove_if(r.begin(), r.end(),
ContainerAlgorithms::BinarySearcher<MatchRange>(m));
@@ -273,7 +285,7 @@ typename Range::const_iterator cmRemoveMatching(Range &r, MatchRange const& m)
namespace ContainerAlgorithms {
-template<typename Range, typename T = typename Range::value_type>
+template <typename Range, typename T = typename Range::value_type>
struct RemoveDuplicatesAPI
{
typedef typename Range::const_iterator const_iterator;
@@ -281,11 +293,14 @@ struct RemoveDuplicatesAPI
static bool lessThan(value_type a, value_type b) { return *a < *b; }
static value_type uniqueValue(const_iterator a) { return a; }
- template<typename It>
- static bool valueCompare(It it, const_iterator it2) { return **it != *it2; }
+ template <typename It>
+ static bool valueCompare(It it, const_iterator it2)
+ {
+ return **it != *it2;
+ }
};
-template<typename Range, typename T>
+template <typename Range, typename T>
struct RemoveDuplicatesAPI<Range, T*>
{
typedef typename Range::const_iterator const_iterator;
@@ -293,13 +308,15 @@ struct RemoveDuplicatesAPI<Range, T*>
static bool lessThan(value_type a, value_type b) { return a < b; }
static value_type uniqueValue(const_iterator a) { return *a; }
- template<typename It>
- static bool valueCompare(It it, const_iterator it2) { return *it != *it2; }
+ template <typename It>
+ static bool valueCompare(It it, const_iterator it2)
+ {
+ return *it != *it2;
+ }
};
-
}
-template<typename Range>
+template <typename Range>
typename Range::const_iterator cmRemoveDuplicates(Range& r)
{
typedef typename ContainerAlgorithms::RemoveDuplicatesAPI<Range> API;
@@ -309,58 +326,51 @@ typename Range::const_iterator cmRemoveDuplicates(Range& r)
std::vector<size_t> indices;
size_t count = 0;
const typename Range::const_iterator end = r.end();
- for(typename Range::const_iterator it = r.begin();
- it != end; ++it, ++count)
- {
- const typename std::vector<T>::iterator low =
- std::lower_bound(unique.begin(), unique.end(),
- API::uniqueValue(it), API::lessThan);
- if (low == unique.end() || API::valueCompare(low, it))
- {
+ for (typename Range::const_iterator it = r.begin(); it != end;
+ ++it, ++count) {
+ const typename std::vector<T>::iterator low = std::lower_bound(
+ unique.begin(), unique.end(), API::uniqueValue(it), API::lessThan);
+ if (low == unique.end() || API::valueCompare(low, it)) {
unique.insert(low, API::uniqueValue(it));
- }
- else
- {
+ } else {
indices.push_back(count);
- }
}
- if (indices.empty())
- {
+ }
+ if (indices.empty()) {
return end;
- }
+ }
return cmRemoveIndices(r, indices);
}
-template<typename Range>
+template <typename Range>
std::string cmWrap(std::string prefix, Range const& r, std::string suffix,
std::string sep)
{
- if (r.empty())
- {
+ if (r.empty()) {
return std::string();
- }
+ }
return prefix + cmJoin(r, (suffix + sep + prefix).c_str()) + suffix;
}
-template<typename Range>
+template <typename Range>
std::string cmWrap(char prefix, Range const& r, char suffix, std::string sep)
{
return cmWrap(std::string(1, prefix), r, std::string(1, suffix), sep);
}
-template<typename Range, typename T>
+template <typename Range, typename T>
typename Range::const_iterator cmFindNot(Range const& r, T const& t)
{
return std::find_if(r.begin(), r.end(),
std::bind1st(std::not_equal_to<T>(), t));
}
-template<typename Range>
-cmRange<typename Range::const_reverse_iterator>
-cmReverseRange(Range const& range)
+template <typename Range>
+cmRange<typename Range::const_reverse_iterator> cmReverseRange(
+ Range const& range)
{
- return cmRange<typename Range::const_reverse_iterator>(
- range.rbegin(), range.rend());
+ return cmRange<typename Range::const_reverse_iterator>(range.rbegin(),
+ range.rend());
}
template <class Iter>
diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx
index 399c513..a0150ec 100644
--- a/Source/cmArchiveWrite.cxx
+++ b/Source/cmArchiveWrite.cxx
@@ -19,17 +19,17 @@
#include <cmsys/FStream.hxx>
#ifndef __LA_SSIZE_T
-# define __LA_SSIZE_T la_ssize_t
+#define __LA_SSIZE_T la_ssize_t
#endif
static std::string cm_archive_error_string(struct archive* a)
{
const char* e = archive_error_string(a);
- return e? e : "unknown error";
+ return e ? e : "unknown error";
}
static void cm_archive_entry_copy_pathname(struct archive_entry* e,
- const std::string& dest)
+ const std::string& dest)
{
#if cmsys_STL_HAS_WSTRING
archive_entry_copy_pathname_w(e, cmsys::Encoding::ToWide(dest).c_str());
@@ -39,7 +39,7 @@ static void cm_archive_entry_copy_pathname(struct archive_entry* e,
}
static void cm_archive_entry_copy_sourcepath(struct archive_entry* e,
- const std::string& file)
+ const std::string& file)
{
#if cmsys_STL_HAS_WSTRING
archive_entry_copy_sourcepath_w(e, cmsys::Encoding::ToWide(file).c_str());
@@ -51,8 +51,12 @@ static void cm_archive_entry_copy_sourcepath(struct archive_entry* e,
class cmArchiveWrite::Entry
{
struct archive_entry* Object;
+
public:
- Entry(): Object(archive_entry_new()) {}
+ Entry()
+ : Object(archive_entry_new())
+ {
+ }
~Entry() { archive_entry_free(this->Object); }
operator struct archive_entry*() { return this->Object; }
};
@@ -60,115 +64,100 @@ public:
struct cmArchiveWrite::Callback
{
// archive_write_callback
- static __LA_SSIZE_T Write(struct archive*, void *cd,
- const void *b, size_t n)
- {
+ static __LA_SSIZE_T Write(struct archive*, void* cd, const void* b, size_t n)
+ {
cmArchiveWrite* self = static_cast<cmArchiveWrite*>(cd);
- if(self->Stream.write(static_cast<const char*>(b),
- static_cast<std::streamsize>(n)))
- {
+ if (self->Stream.write(static_cast<const char*>(b),
+ static_cast<std::streamsize>(n))) {
return static_cast<__LA_SSIZE_T>(n);
- }
- else
- {
+ } else {
return static_cast<__LA_SSIZE_T>(-1);
- }
}
+ }
};
-cmArchiveWrite::cmArchiveWrite(
- std::ostream& os, Compress c, std::string const& format):
- Stream(os),
- Archive(archive_write_new()),
- Disk(archive_read_disk_new()),
- Verbose(false),
- Format(format)
+cmArchiveWrite::cmArchiveWrite(std::ostream& os, Compress c,
+ std::string const& format)
+ : Stream(os)
+ , Archive(archive_write_new())
+ , Disk(archive_read_disk_new())
+ , Verbose(false)
+ , Format(format)
{
- switch (c)
- {
+ switch (c) {
case CompressNone:
- if(archive_write_add_filter_none(this->Archive) != ARCHIVE_OK)
- {
+ if (archive_write_add_filter_none(this->Archive) != ARCHIVE_OK) {
this->Error = "archive_write_add_filter_none: ";
this->Error += cm_archive_error_string(this->Archive);
return;
- }
+ }
break;
case CompressCompress:
- if(archive_write_add_filter_compress(this->Archive) != ARCHIVE_OK)
- {
+ if (archive_write_add_filter_compress(this->Archive) != ARCHIVE_OK) {
this->Error = "archive_write_add_filter_compress: ";
this->Error += cm_archive_error_string(this->Archive);
return;
- }
+ }
break;
case CompressGZip:
- if(archive_write_add_filter_gzip(this->Archive) != ARCHIVE_OK)
- {
+ if (archive_write_add_filter_gzip(this->Archive) != ARCHIVE_OK) {
this->Error = "archive_write_add_filter_gzip: ";
this->Error += cm_archive_error_string(this->Archive);
return;
- }
+ }
break;
case CompressBZip2:
- if(archive_write_add_filter_bzip2(this->Archive) != ARCHIVE_OK)
- {
+ if (archive_write_add_filter_bzip2(this->Archive) != ARCHIVE_OK) {
this->Error = "archive_write_add_filter_bzip2: ";
this->Error += cm_archive_error_string(this->Archive);
return;
- }
+ }
break;
case CompressLZMA:
- if(archive_write_add_filter_lzma(this->Archive) != ARCHIVE_OK)
- {
+ if (archive_write_add_filter_lzma(this->Archive) != ARCHIVE_OK) {
this->Error = "archive_write_add_filter_lzma: ";
this->Error += cm_archive_error_string(this->Archive);
return;
- }
+ }
break;
case CompressXZ:
- if(archive_write_add_filter_xz(this->Archive) != ARCHIVE_OK)
- {
+ if (archive_write_add_filter_xz(this->Archive) != ARCHIVE_OK) {
this->Error = "archive_write_add_filter_xz: ";
this->Error += cm_archive_error_string(this->Archive);
return;
- }
+ }
break;
- };
+ };
#if !defined(_WIN32) || defined(__CYGWIN__)
- if (archive_read_disk_set_standard_lookup(this->Disk) != ARCHIVE_OK)
- {
+ if (archive_read_disk_set_standard_lookup(this->Disk) != ARCHIVE_OK) {
this->Error = "archive_read_disk_set_standard_lookup: ";
this->Error += cm_archive_error_string(this->Archive);
return;
- }
+ }
#endif
- if(archive_write_set_format_by_name(this->Archive, format.c_str())
- != ARCHIVE_OK)
- {
+ if (archive_write_set_format_by_name(this->Archive, format.c_str()) !=
+ ARCHIVE_OK) {
this->Error = "archive_write_set_format_by_name: ";
this->Error += cm_archive_error_string(this->Archive);
return;
- }
+ }
// do not pad the last block!!
- if (archive_write_set_bytes_in_last_block(this->Archive, 1))
- {
+ if (archive_write_set_bytes_in_last_block(this->Archive, 1)) {
this->Error = "archive_write_set_bytes_in_last_block: ";
this->Error += cm_archive_error_string(this->Archive);
return;
- }
+ }
- if(archive_write_open(
- this->Archive, this, 0,
- reinterpret_cast<archive_write_callback*>(&Callback::Write),
- 0) != ARCHIVE_OK)
- {
+ if (archive_write_open(
+ this->Archive, this, 0,
+ reinterpret_cast<archive_write_callback*>(&Callback::Write),
+ 0) != ARCHIVE_OK) {
this->Error = "archive_write_open: ";
this->Error += cm_archive_error_string(this->Archive);
return;
- }
+ }
}
cmArchiveWrite::~cmArchiveWrite()
@@ -177,205 +166,174 @@ cmArchiveWrite::~cmArchiveWrite()
archive_write_free(this->Archive);
}
-bool cmArchiveWrite::Add(std::string path,
- size_t skip,
- const char* prefix,
+bool cmArchiveWrite::Add(std::string path, size_t skip, const char* prefix,
bool recursive)
{
- if(this->Okay())
- {
- if(!path.empty() && path[path.size()-1] == '/')
- {
- path.erase(path.size()-1);
- }
- this->AddPath(path.c_str(), skip, prefix, recursive);
+ if (this->Okay()) {
+ if (!path.empty() && path[path.size() - 1] == '/') {
+ path.erase(path.size() - 1);
}
+ this->AddPath(path.c_str(), skip, prefix, recursive);
+ }
return this->Okay();
}
-bool cmArchiveWrite::AddPath(const char* path,
- size_t skip, const char* prefix,
+bool cmArchiveWrite::AddPath(const char* path, size_t skip, const char* prefix,
bool recursive)
{
- if(!this->AddFile(path, skip, prefix))
- {
+ if (!this->AddFile(path, skip, prefix)) {
return false;
- }
- if((!cmSystemTools::FileIsDirectory(path) || !recursive) ||
- cmSystemTools::FileIsSymlink(path))
- {
+ }
+ if ((!cmSystemTools::FileIsDirectory(path) || !recursive) ||
+ cmSystemTools::FileIsSymlink(path)) {
return true;
- }
+ }
cmsys::Directory d;
- if(d.Load(path))
- {
+ if (d.Load(path)) {
std::string next = path;
next += "/";
std::string::size_type end = next.size();
unsigned long n = d.GetNumberOfFiles();
- for(unsigned long i = 0; i < n; ++i)
- {
+ for (unsigned long i = 0; i < n; ++i) {
const char* file = d.GetFile(i);
- if(strcmp(file, ".") != 0 && strcmp(file, "..") != 0)
- {
+ if (strcmp(file, ".") != 0 && strcmp(file, "..") != 0) {
next.erase(end);
next += file;
- if(!this->AddPath(next.c_str(), skip, prefix))
- {
+ if (!this->AddPath(next.c_str(), skip, prefix)) {
return false;
- }
}
}
}
+ }
return true;
}
-bool cmArchiveWrite::AddFile(const char* file,
- size_t skip, const char* prefix)
+bool cmArchiveWrite::AddFile(const char* file, size_t skip, const char* prefix)
{
// Skip the file if we have no name for it. This may happen on a
// top-level directory, which does not need to be included anyway.
- if(skip >= strlen(file))
- {
+ if (skip >= strlen(file)) {
return true;
- }
+ }
const char* out = file + skip;
cmLocaleRAII localeRAII;
static_cast<void>(localeRAII);
// Meta-data.
- std::string dest = prefix? prefix : "";
+ std::string dest = prefix ? prefix : "";
dest += out;
- if(this->Verbose)
- {
+ if (this->Verbose) {
std::cout << dest << "\n";
- }
+ }
Entry e;
cm_archive_entry_copy_sourcepath(e, file);
cm_archive_entry_copy_pathname(e, dest);
- if(archive_read_disk_entry_from_file(this->Disk, e, -1, 0) != ARCHIVE_OK)
- {
+ if (archive_read_disk_entry_from_file(this->Disk, e, -1, 0) != ARCHIVE_OK) {
this->Error = "archive_read_disk_entry_from_file '";
this->Error += file;
this->Error += "': ";
this->Error += cm_archive_error_string(this->Disk);
return false;
- }
- if (!this->MTime.empty())
- {
+ }
+ if (!this->MTime.empty()) {
time_t now;
time(&now);
time_t t = cm_get_date(now, this->MTime.c_str());
- if (t == -1)
- {
+ if (t == -1) {
this->Error = "unable to parse mtime '";
this->Error += this->MTime;
this->Error += "'";
return false;
- }
- archive_entry_set_mtime(e, t, 0);
}
+ archive_entry_set_mtime(e, t, 0);
+ }
// manages the uid/guid of the entry (if any)
- if (this->Uid.IsSet() && this->Gid.IsSet())
- {
+ if (this->Uid.IsSet() && this->Gid.IsSet()) {
archive_entry_set_uid(e, this->Uid.Get());
archive_entry_set_gid(e, this->Gid.Get());
- }
+ }
- if (this->Uname.size() && this->Gname.size())
- {
+ if (this->Uname.size() && this->Gname.size()) {
archive_entry_set_uname(e, this->Uname.c_str());
archive_entry_set_gname(e, this->Gname.c_str());
- }
-
+ }
// manages the permissions
- if (this->Permissions.IsSet())
- {
+ if (this->Permissions.IsSet()) {
archive_entry_set_perm(e, this->Permissions.Get());
- }
+ }
- if (this->PermissionsMask.IsSet())
- {
+ if (this->PermissionsMask.IsSet()) {
mode_t perm = archive_entry_perm(e);
archive_entry_set_perm(e, perm & this->PermissionsMask.Get());
- }
+ }
// Clear acl and xattr fields not useful for distribution.
archive_entry_acl_clear(e);
archive_entry_xattr_clear(e);
archive_entry_set_fflags(e, 0, 0);
- if (this->Format == "pax" || this->Format == "paxr")
- {
+ if (this->Format == "pax" || this->Format == "paxr") {
// Sparse files are a GNU tar extension.
// Do not use them in standard tar files.
archive_entry_sparse_clear(e);
- }
+ }
- if(archive_write_header(this->Archive, e) != ARCHIVE_OK)
- {
+ if (archive_write_header(this->Archive, e) != ARCHIVE_OK) {
this->Error = "archive_write_header: ";
this->Error += cm_archive_error_string(this->Archive);
return false;
- }
+ }
// do not copy content of symlink
- if (!archive_entry_symlink(e))
- {
+ if (!archive_entry_symlink(e)) {
// Content.
- if(size_t size = static_cast<size_t>(archive_entry_size(e)))
- {
+ if (size_t size = static_cast<size_t>(archive_entry_size(e))) {
return this->AddData(file, size);
- }
}
+ }
return true;
}
bool cmArchiveWrite::AddData(const char* file, size_t size)
{
cmsys::ifstream fin(file, std::ios::in | std::ios::binary);
- if(!fin)
- {
+ if (!fin) {
this->Error = "Error opening \"";
this->Error += file;
this->Error += "\": ";
this->Error += cmSystemTools::GetLastSystemError();
return false;
- }
+ }
char buffer[16384];
size_t nleft = size;
- while(nleft > 0)
- {
+ while (nleft > 0) {
typedef std::streamsize ssize_type;
- size_t const nnext = nleft > sizeof(buffer)? sizeof(buffer) : nleft;
+ size_t const nnext = nleft > sizeof(buffer) ? sizeof(buffer) : nleft;
ssize_type const nnext_s = static_cast<ssize_type>(nnext);
fin.read(buffer, nnext_s);
// Some stream libraries (older HPUX) return failure at end of
// file on the last read even if some data were read. Check
// gcount instead of trusting the stream error status.
- if(static_cast<size_t>(fin.gcount()) != nnext)
- {
+ if (static_cast<size_t>(fin.gcount()) != nnext) {
break;
- }
- if(archive_write_data(this->Archive, buffer, nnext) != nnext_s)
- {
+ }
+ if (archive_write_data(this->Archive, buffer, nnext) != nnext_s) {
this->Error = "archive_write_data: ";
this->Error += cm_archive_error_string(this->Archive);
return false;
- }
- nleft -= nnext;
}
- if(nleft > 0)
- {
+ nleft -= nnext;
+ }
+ if (nleft > 0) {
this->Error = "Error reading \"";
this->Error += file;
this->Error += "\": ";
this->Error += cmSystemTools::GetLastSystemError();
return false;
- }
+ }
return true;
}
diff --git a/Source/cmArchiveWrite.h b/Source/cmArchiveWrite.h
index 8dbbb83..72d8f3a 100644
--- a/Source/cmArchiveWrite.h
+++ b/Source/cmArchiveWrite.h
@@ -15,20 +15,24 @@
#include "cmStandardIncludes.h"
#if !defined(CMAKE_BUILD_WITH_CMAKE)
-# error "cmArchiveWrite not allowed during bootstrap build!"
+#error "cmArchiveWrite not allowed during bootstrap build!"
#endif
-template<typename T>
+template <typename T>
class cmArchiveWriteOptional
{
public:
- cmArchiveWriteOptional() {this->Clear();}
- explicit cmArchiveWriteOptional(T val) {this->Set(val);}
+ cmArchiveWriteOptional() { this->Clear(); }
+ explicit cmArchiveWriteOptional(T val) { this->Set(val); }
- void Set(T val) {this->IsValueSet = true; this->Value=val;}
- void Clear() {this->IsValueSet = false;}
- bool IsSet() const {return this->IsValueSet;}
- T Get() const {return Value;}
+ void Set(T val)
+ {
+ this->IsValueSet = true;
+ this->Value = val;
+ }
+ void Clear() { this->IsValueSet = false; }
+ bool IsSet() const { return this->IsValueSet; }
+ T Get() const { return Value; }
private:
T Value;
bool IsValueSet;
@@ -40,7 +44,7 @@ private:
*/
class cmArchiveWrite
{
- typedef void (cmArchiveWrite::* safe_bool)();
+ typedef void (cmArchiveWrite::*safe_bool)();
void safe_bool_true() {}
public:
/** Compression type. */
@@ -56,7 +60,7 @@ public:
/** Construct with output stream to which to write archive. */
cmArchiveWrite(std::ostream& os, Compress c = CompressNone,
- std::string const& format = "paxr");
+ std::string const& format = "paxr");
~cmArchiveWrite();
@@ -68,14 +72,14 @@ public:
* skip. The remaining part of the input path is appended to the
* "prefix" value to construct the final name in the archive.
*/
- bool Add(std::string path,
- size_t skip = 0,
- const char* prefix = 0,
- bool recursive = true);
+ bool Add(std::string path, size_t skip = 0, const char* prefix = 0,
+ bool recursive = true);
/** Returns true if there has been no error. */
operator safe_bool() const
- { return this->Okay()? &cmArchiveWrite::safe_bool_true : 0; }
+ {
+ return this->Okay() ? &cmArchiveWrite::safe_bool_true : 0;
+ }
/** Returns true if there has been an error. */
bool operator!() const { return !this->Okay(); }
@@ -91,9 +95,9 @@ public:
//! Sets the permissions of the added files/folders
void SetPermissions(mode_t permissions_)
- {
+ {
this->Permissions.Set(permissions_);
- }
+ }
//! Clears permissions - default is used instead
void ClearPermissions() { this->Permissions.Clear(); }
@@ -104,44 +108,41 @@ public:
//! or folder. The mask will then be applied to unset
//! some of them
void SetPermissionsMask(mode_t permissionsMask_)
- {
+ {
this->PermissionsMask.Set(permissionsMask_);
- }
+ }
//! Clears permissions mask - default is used instead
- void ClearPermissionsMask()
- {
- this->PermissionsMask.Clear();
- }
+ void ClearPermissionsMask() { this->PermissionsMask.Clear(); }
//! Sets UID and GID to be used in the tar file
void SetUIDAndGID(int uid_, int gid_)
- {
+ {
this->Uid.Set(uid_);
this->Gid.Set(gid_);
- }
+ }
//! Clears UID and GID to be used in the tar file - default is used instead
void ClearUIDAndGID()
- {
+ {
this->Uid.Clear();
this->Gid.Clear();
- }
+ }
//! Sets UNAME and GNAME to be used in the tar file
void SetUNAMEAndGNAME(const std::string& uname_, const std::string& gname_)
- {
+ {
this->Uname = uname_;
this->Gname = gname_;
- }
+ }
//! Clears UNAME and GNAME to be used in the tar file
//! default is used instead
void ClearUNAMEAndGNAME()
- {
+ {
this->Uname = "";
this->Gname = "";
- }
+ }
private:
bool Okay() const { return this->Error.empty(); }
diff --git a/Source/cmAuxSourceDirectoryCommand.cxx b/Source/cmAuxSourceDirectoryCommand.cxx
index 07cb295..78f67a4 100644
--- a/Source/cmAuxSourceDirectoryCommand.cxx
+++ b/Source/cmAuxSourceDirectoryCommand.cxx
@@ -16,74 +16,62 @@
#include <cmsys/Directory.hxx>
// cmAuxSourceDirectoryCommand
-bool cmAuxSourceDirectoryCommand::InitialPass
-(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmAuxSourceDirectoryCommand::InitialPass(
+ std::vector<std::string> const& args, cmExecutionStatus&)
{
- if(args.size() < 2 || args.size() > 2)
- {
+ if (args.size() < 2 || args.size() > 2) {
this->SetError("called with incorrect number of arguments");
return false;
- }
+ }
std::string sourceListValue;
std::string templateDirectory = args[0];
std::string tdir;
- if(!cmSystemTools::FileIsFullPath(templateDirectory.c_str()))
- {
+ if (!cmSystemTools::FileIsFullPath(templateDirectory.c_str())) {
tdir = this->Makefile->GetCurrentSourceDirectory();
tdir += "/";
tdir += templateDirectory;
- }
- else
- {
+ } else {
tdir = templateDirectory;
- }
+ }
// was the list already populated
- const char *def = this->Makefile->GetDefinition(args[1]);
- if (def)
- {
+ const char* def = this->Makefile->GetDefinition(args[1]);
+ if (def) {
sourceListValue = def;
- }
+ }
// Load all the files in the directory
cmsys::Directory dir;
- if(dir.Load(tdir.c_str()))
- {
+ if (dir.Load(tdir.c_str())) {
size_t numfiles = dir.GetNumberOfFiles();
- for(size_t i =0; i < numfiles; ++i)
- {
+ for (size_t i = 0; i < numfiles; ++i) {
std::string file = dir.GetFile(static_cast<unsigned long>(i));
// Split the filename into base and extension
std::string::size_type dotpos = file.rfind(".");
- if( dotpos != std::string::npos )
- {
- std::string ext = file.substr(dotpos+1);
+ if (dotpos != std::string::npos) {
+ std::string ext = file.substr(dotpos + 1);
std::string base = file.substr(0, dotpos);
// Process only source files
std::vector<std::string> srcExts =
- this->Makefile->GetCMakeInstance()->GetSourceExtensions();
- if(!base.empty() &&
- std::find(srcExts.begin(), srcExts.end(), ext) != srcExts.end())
- {
+ this->Makefile->GetCMakeInstance()->GetSourceExtensions();
+ if (!base.empty() &&
+ std::find(srcExts.begin(), srcExts.end(), ext) != srcExts.end()) {
std::string fullname = templateDirectory;
fullname += "/";
fullname += file;
// add the file as a class file so
// depends can be done
- cmSourceFile* sf =
- this->Makefile->GetOrCreateSource(fullname);
- sf->SetProperty("ABSTRACT","0");
- if(!sourceListValue.empty())
- {
+ cmSourceFile* sf = this->Makefile->GetOrCreateSource(fullname);
+ sf->SetProperty("ABSTRACT", "0");
+ if (!sourceListValue.empty()) {
sourceListValue += ";";
- }
- sourceListValue += fullname;
}
+ sourceListValue += fullname;
}
}
}
+ }
this->Makefile->AddDefinition(args[1], sourceListValue.c_str());
return true;
}
-
diff --git a/Source/cmAuxSourceDirectoryCommand.h b/Source/cmAuxSourceDirectoryCommand.h
index 6615273..b5943f5 100644
--- a/Source/cmAuxSourceDirectoryCommand.h
+++ b/Source/cmAuxSourceDirectoryCommand.h
@@ -29,26 +29,21 @@ public:
/**
* This is a virtual constructor for the command.
*/
- virtual cmCommand* Clone()
- {
- return new cmAuxSourceDirectoryCommand;
- }
+ virtual cmCommand* Clone() { return new cmAuxSourceDirectoryCommand; }
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus &status);
+ cmExecutionStatus& status);
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const { return "aux_source_directory";}
+ virtual std::string GetName() const { return "aux_source_directory"; }
cmTypeMacro(cmAuxSourceDirectoryCommand, cmCommand);
};
-
-
#endif
diff --git a/Source/cmBreakCommand.cxx b/Source/cmBreakCommand.cxx
index fc0c3f5..fd57705 100644
--- a/Source/cmBreakCommand.cxx
+++ b/Source/cmBreakCommand.cxx
@@ -12,16 +12,14 @@
#include "cmBreakCommand.h"
// cmBreakCommand
-bool cmBreakCommand::InitialPass(std::vector<std::string> const &args,
- cmExecutionStatus &status)
+bool cmBreakCommand::InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
- if(!this->Makefile->IsLoopBlock())
- {
+ if (!this->Makefile->IsLoopBlock()) {
bool issueMessage = true;
std::ostringstream e;
cmake::MessageType messageType = cmake::AUTHOR_WARNING;
- switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0055))
- {
+ switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0055)) {
case cmPolicies::WARN:
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0055) << "\n";
break;
@@ -33,29 +31,25 @@ bool cmBreakCommand::InitialPass(std::vector<std::string> const &args,
case cmPolicies::NEW:
messageType = cmake::FATAL_ERROR;
break;
- }
+ }
- if(issueMessage)
- {
+ if (issueMessage) {
e << "A BREAK command was found outside of a proper "
"FOREACH or WHILE loop scope.";
this->Makefile->IssueMessage(messageType, e.str());
- if(messageType == cmake::FATAL_ERROR)
- {
+ if (messageType == cmake::FATAL_ERROR) {
return false;
- }
}
}
+ }
status.SetBreakInvoked(true);
- if(!args.empty())
- {
+ if (!args.empty()) {
bool issueMessage = true;
std::ostringstream e;
cmake::MessageType messageType = cmake::AUTHOR_WARNING;
- switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0055))
- {
+ switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0055)) {
case cmPolicies::WARN:
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0055) << "\n";
break;
@@ -67,19 +61,16 @@ bool cmBreakCommand::InitialPass(std::vector<std::string> const &args,
case cmPolicies::NEW:
messageType = cmake::FATAL_ERROR;
break;
- }
+ }
- if(issueMessage)
- {
+ if (issueMessage) {
e << "The BREAK command does not accept any arguments.";
this->Makefile->IssueMessage(messageType, e.str());
- if(messageType == cmake::FATAL_ERROR)
- {
+ if (messageType == cmake::FATAL_ERROR) {
return false;
- }
}
}
+ }
return true;
}
-
diff --git a/Source/cmBreakCommand.h b/Source/cmBreakCommand.h
index 1fcae50..270d3e6 100644
--- a/Source/cmBreakCommand.h
+++ b/Source/cmBreakCommand.h
@@ -25,17 +25,14 @@ public:
/**
* This is a virtual constructor for the command.
*/
- virtual cmCommand* Clone()
- {
- return new cmBreakCommand;
- }
+ virtual cmCommand* Clone() { return new cmBreakCommand; }
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus &status);
+ cmExecutionStatus& status);
/**
* This determines if the command is invoked when in script mode.
@@ -45,11 +42,9 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const {return "break";}
+ virtual std::string GetName() const { return "break"; }
cmTypeMacro(cmBreakCommand, cmCommand);
};
-
-
#endif
diff --git a/Source/cmBuildCommand.cxx b/Source/cmBuildCommand.cxx
index b9183ed..586e8a8 100644
--- a/Source/cmBuildCommand.cxx
+++ b/Source/cmBuildCommand.cxx
@@ -13,27 +13,24 @@
#include "cmGlobalGenerator.h"
-bool cmBuildCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmBuildCommand::InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus&)
{
// Support the legacy signature of the command:
//
- if(2 == args.size())
- {
+ if (2 == args.size()) {
return this->TwoArgsSignature(args);
- }
+ }
return this->MainSignature(args);
}
-bool cmBuildCommand
-::MainSignature(std::vector<std::string> const& args)
+bool cmBuildCommand::MainSignature(std::vector<std::string> const& args)
{
- if(args.size() < 1)
- {
+ if (args.size() < 1) {
this->SetError("requires at least one argument naming a CMake variable");
return false;
- }
+ }
// The cmake variable in which to store the result.
const char* variable = args[0].c_str();
@@ -42,107 +39,91 @@ bool cmBuildCommand
const char* configuration = 0;
const char* project_name = 0;
std::string target;
- enum Doing { DoingNone, DoingConfiguration, DoingProjectName, DoingTarget };
+ enum Doing
+ {
+ DoingNone,
+ DoingConfiguration,
+ DoingProjectName,
+ DoingTarget
+ };
Doing doing = DoingNone;
- for(unsigned int i=1; i < args.size(); ++i)
- {
- if(args[i] == "CONFIGURATION")
- {
+ for (unsigned int i = 1; i < args.size(); ++i) {
+ if (args[i] == "CONFIGURATION") {
doing = DoingConfiguration;
- }
- else if(args[i] == "PROJECT_NAME")
- {
+ } else if (args[i] == "PROJECT_NAME") {
doing = DoingProjectName;
- }
- else if(args[i] == "TARGET")
- {
+ } else if (args[i] == "TARGET") {
doing = DoingTarget;
- }
- else if(doing == DoingConfiguration)
- {
+ } else if (doing == DoingConfiguration) {
doing = DoingNone;
configuration = args[i].c_str();
- }
- else if(doing == DoingProjectName)
- {
+ } else if (doing == DoingProjectName) {
doing = DoingNone;
project_name = args[i].c_str();
- }
- else if(doing == DoingTarget)
- {
+ } else if (doing == DoingTarget) {
doing = DoingNone;
target = args[i];
- }
- else
- {
+ } else {
std::ostringstream e;
e << "unknown argument \"" << args[i] << "\"";
this->SetError(e.str());
return false;
- }
}
+ }
// If null/empty CONFIGURATION argument, cmake --build uses 'Debug'
// in the currently implemented multi-configuration global generators...
// so we put this code here to end up with the same default configuration
// as the original 2-arg build_command signature:
//
- if(!configuration || !*configuration)
- {
+ if (!configuration || !*configuration) {
configuration = getenv("CMAKE_CONFIG_TYPE");
- }
- if(!configuration || !*configuration)
- {
+ }
+ if (!configuration || !*configuration) {
configuration = "Release";
- }
+ }
- if(project_name && *project_name)
- {
- this->Makefile->IssueMessage(cmake::AUTHOR_WARNING,
+ if (project_name && *project_name) {
+ this->Makefile->IssueMessage(
+ cmake::AUTHOR_WARNING,
"Ignoring PROJECT_NAME option because it has no effect.");
- }
+ }
- std::string makecommand = this->Makefile->GetGlobalGenerator()
- ->GenerateCMakeBuildCommand(target, configuration, "",
- this->Makefile->IgnoreErrorsCMP0061());
+ std::string makecommand =
+ this->Makefile->GetGlobalGenerator()->GenerateCMakeBuildCommand(
+ target, configuration, "", this->Makefile->IgnoreErrorsCMP0061());
this->Makefile->AddDefinition(variable, makecommand.c_str());
return true;
}
-bool cmBuildCommand
-::TwoArgsSignature(std::vector<std::string> const& args)
+bool cmBuildCommand::TwoArgsSignature(std::vector<std::string> const& args)
{
- if(args.size() < 2 )
- {
+ if (args.size() < 2) {
this->SetError("called with less than two arguments");
return false;
- }
+ }
const char* define = args[0].c_str();
- const char* cacheValue
- = this->Makefile->GetDefinition(define);
+ const char* cacheValue = this->Makefile->GetDefinition(define);
std::string configType = "Release";
const char* cfg = getenv("CMAKE_CONFIG_TYPE");
- if ( cfg && *cfg )
- {
+ if (cfg && *cfg) {
configType = cfg;
- }
+ }
- std::string makecommand = this->Makefile->GetGlobalGenerator()
- ->GenerateCMakeBuildCommand("", configType, "",
- this->Makefile->IgnoreErrorsCMP0061());
+ std::string makecommand =
+ this->Makefile->GetGlobalGenerator()->GenerateCMakeBuildCommand(
+ "", configType, "", this->Makefile->IgnoreErrorsCMP0061());
- if(cacheValue)
- {
+ if (cacheValue) {
return true;
- }
- this->Makefile->AddCacheDefinition(define,
- makecommand.c_str(),
- "Command used to build entire project "
- "from the command line.",
- cmState::STRING);
+ }
+ this->Makefile->AddCacheDefinition(define, makecommand.c_str(),
+ "Command used to build entire project "
+ "from the command line.",
+ cmState::STRING);
return true;
}
diff --git a/Source/cmBuildCommand.h b/Source/cmBuildCommand.h
index 979abc0..6cbf3ca 100644
--- a/Source/cmBuildCommand.h
+++ b/Source/cmBuildCommand.h
@@ -25,17 +25,14 @@ public:
/**
* This is a virtual constructor for the command.
*/
- virtual cmCommand* Clone()
- {
- return new cmBuildCommand;
- }
+ virtual cmCommand* Clone() { return new cmBuildCommand; }
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus &status);
+ cmExecutionStatus& status);
/**
* The primary command signature with optional, KEYWORD-based args.
@@ -50,9 +47,10 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const {return "build_command";}
+ virtual std::string GetName() const { return "build_command"; }
cmTypeMacro(cmBuildCommand, cmCommand);
+
private:
bool IgnoreErrors() const;
};
diff --git a/Source/cmBuildNameCommand.cxx b/Source/cmBuildNameCommand.cxx
index 2733d76..7ed96ab 100644
--- a/Source/cmBuildNameCommand.cxx
+++ b/Source/cmBuildNameCommand.cxx
@@ -14,67 +14,54 @@
#include <cmsys/RegularExpression.hxx>
// cmBuildNameCommand
-bool cmBuildNameCommand
-::InitialPass(std::vector<std::string> const& args, 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.size() < 1 )
- {
+ if (this->Disallowed(
+ cmPolicies::CMP0036,
+ "The build_name command should not be called; see CMP0036.")) {
+ return true;
+ }
+ if (args.size() < 1) {
this->SetError("called with incorrect number of arguments");
return false;
- }
+ }
const char* cacheValue = this->Makefile->GetDefinition(args[0]);
- if(cacheValue)
- {
+ if (cacheValue) {
// do we need to correct the value?
cmsys::RegularExpression reg("[()/]");
- if (reg.find(cacheValue))
- {
+ if (reg.find(cacheValue)) {
std::string cv = cacheValue;
- cmSystemTools::ReplaceString(cv,"/", "_");
- cmSystemTools::ReplaceString(cv,"(", "_");
- cmSystemTools::ReplaceString(cv,")", "_");
- this->Makefile->AddCacheDefinition(args[0],
- cv.c_str(),
- "Name of build.",
- cmState::STRING);
- }
- return true;
+ cmSystemTools::ReplaceString(cv, "/", "_");
+ cmSystemTools::ReplaceString(cv, "(", "_");
+ cmSystemTools::ReplaceString(cv, ")", "_");
+ this->Makefile->AddCacheDefinition(args[0], cv.c_str(), "Name of build.",
+ cmState::STRING);
}
-
+ return true;
+ }
std::string buildname = "WinNT";
- if(this->Makefile->GetDefinition("UNIX"))
- {
+ if (this->Makefile->GetDefinition("UNIX")) {
buildname = "";
cmSystemTools::RunSingleCommand("uname -a", &buildname, &buildname);
- if(!buildname.empty())
- {
+ if (!buildname.empty()) {
std::string RegExp = "([^ ]*) [^ ]* ([^ ]*) ";
- cmsys::RegularExpression reg( RegExp.c_str() );
- if(reg.find(buildname.c_str()))
- {
+ cmsys::RegularExpression reg(RegExp.c_str());
+ if (reg.find(buildname.c_str())) {
buildname = reg.match(1) + "-" + reg.match(2);
- }
}
}
+ }
std::string compiler = "${CMAKE_CXX_COMPILER}";
- this->Makefile->ExpandVariablesInString ( compiler );
+ this->Makefile->ExpandVariablesInString(compiler);
buildname += "-";
buildname += cmSystemTools::GetFilenameName(compiler);
- cmSystemTools::ReplaceString(buildname,
- "/", "_");
- cmSystemTools::ReplaceString(buildname,
- "(", "_");
- cmSystemTools::ReplaceString(buildname,
- ")", "_");
+ cmSystemTools::ReplaceString(buildname, "/", "_");
+ cmSystemTools::ReplaceString(buildname, "(", "_");
+ cmSystemTools::ReplaceString(buildname, ")", "_");
- this->Makefile->AddCacheDefinition(args[0],
- buildname.c_str(),
- "Name of build.",
- cmState::STRING);
+ this->Makefile->AddCacheDefinition(args[0], buildname.c_str(),
+ "Name of build.", cmState::STRING);
return true;
}
-
diff --git a/Source/cmBuildNameCommand.h b/Source/cmBuildNameCommand.h
index 47455f8..43c24b0 100644
--- a/Source/cmBuildNameCommand.h
+++ b/Source/cmBuildNameCommand.h
@@ -20,11 +20,9 @@ public:
cmTypeMacro(cmBuildNameCommand, cmCommand);
virtual cmCommand* Clone() { return new cmBuildNameCommand; }
virtual bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus &status);
- virtual std::string GetName() const {return "build_name";}
+ cmExecutionStatus& status);
+ virtual std::string GetName() const { return "build_name"; }
virtual bool IsScriptable() const { return true; }
};
-
-
#endif
diff --git a/Source/cmCLocaleEnvironmentScope.cxx b/Source/cmCLocaleEnvironmentScope.cxx
index 5792302..ee9acde 100644
--- a/Source/cmCLocaleEnvironmentScope.cxx
+++ b/Source/cmCLocaleEnvironmentScope.cxx
@@ -23,11 +23,10 @@ cmCLocaleEnvironmentScope::cmCLocaleEnvironmentScope()
std::string lcAll = this->GetEnv("LC_ALL");
- if(!lcAll.empty())
- {
+ if (!lcAll.empty()) {
this->SetEnv("LC_ALL", "");
this->SetEnv("LC_CTYPE", lcAll);
- }
+ }
}
std::string cmCLocaleEnvironmentScope::GetEnv(std::string const& key)
@@ -36,32 +35,28 @@ std::string cmCLocaleEnvironmentScope::GetEnv(std::string const& key)
return value ? value : std::string();
}
-void cmCLocaleEnvironmentScope::SetEnv(
- std::string const& key, std::string const& value)
+void cmCLocaleEnvironmentScope::SetEnv(std::string const& key,
+ std::string const& value)
{
std::string oldValue = this->GetEnv(key);
this->EnvironmentBackup.insert(std::make_pair(key, oldValue));
- if(value.empty())
- {
+ if (value.empty()) {
cmSystemTools::UnsetEnv(key.c_str());
- }
- else
- {
+ } else {
std::stringstream tmp;
tmp << key << "=" << value;
cmSystemTools::PutEnv(tmp.str());
- }
+ }
}
cmCLocaleEnvironmentScope::~cmCLocaleEnvironmentScope()
{
- for(backup_map_t::const_iterator i = this->EnvironmentBackup.begin();
- i != this->EnvironmentBackup.end(); ++i)
- {
+ for (backup_map_t::const_iterator i = this->EnvironmentBackup.begin();
+ i != this->EnvironmentBackup.end(); ++i) {
std::stringstream tmp;
tmp << i->first << "=" << i->second;
cmSystemTools::PutEnv(tmp.str());
- }
+ }
}
diff --git a/Source/cmCMakeHostSystemInformationCommand.cxx b/Source/cmCMakeHostSystemInformationCommand.cxx
index 6ff7c0d..fbec6fd 100644
--- a/Source/cmCMakeHostSystemInformationCommand.cxx
+++ b/Source/cmCMakeHostSystemInformationCommand.cxx
@@ -12,25 +12,23 @@
#include "cmCMakeHostSystemInformationCommand.h"
// cmCMakeHostSystemInformation
-bool cmCMakeHostSystemInformationCommand
-::InitialPass(std::vector<std::string> const &args, cmExecutionStatus &)
+bool cmCMakeHostSystemInformationCommand::InitialPass(
+ std::vector<std::string> const& args, cmExecutionStatus&)
{
size_t current_index = 0;
- if(args.size() < (current_index + 2) || args[current_index] != "RESULT")
- {
+ if (args.size() < (current_index + 2) || args[current_index] != "RESULT") {
this->SetError("missing RESULT specification.");
return false;
- }
+ }
std::string variable = args[current_index + 1];
current_index += 2;
- if(args.size() < (current_index + 2) || args[current_index] != "QUERY")
- {
+ if (args.size() < (current_index + 2) || args[current_index] != "QUERY") {
this->SetError("missing QUERY specification");
return false;
- }
+ }
cmsys::SystemInformation info;
info.RunCPUCheck();
@@ -38,87 +36,68 @@ bool cmCMakeHostSystemInformationCommand
info.RunMemoryCheck();
std::string result_list;
- for(size_t i = current_index + 1; i < args.size(); ++i)
- {
+ for (size_t i = current_index + 1; i < args.size(); ++i) {
std::string key = args[i];
- if(i != current_index + 1)
- {
+ if (i != current_index + 1) {
result_list += ";";
- }
+ }
std::string value;
- if(!this->GetValue(info, key, value)) return false;
+ if (!this->GetValue(info, key, value))
+ return false;
result_list += value;
- }
+ }
this->Makefile->AddDefinition(variable, result_list.c_str());
return true;
}
-bool cmCMakeHostSystemInformationCommand
-::GetValue(cmsys::SystemInformation &info,
- std::string const& key, std::string &value)
+bool cmCMakeHostSystemInformationCommand::GetValue(
+ cmsys::SystemInformation& info, std::string const& key, std::string& value)
{
- if(key == "NUMBER_OF_LOGICAL_CORES")
- {
+ if (key == "NUMBER_OF_LOGICAL_CORES") {
value = this->ValueToString(info.GetNumberOfLogicalCPU());
- }
- else if(key == "NUMBER_OF_PHYSICAL_CORES")
- {
+ } else if (key == "NUMBER_OF_PHYSICAL_CORES") {
value = this->ValueToString(info.GetNumberOfPhysicalCPU());
- }
- else if(key == "HOSTNAME")
- {
+ } else if (key == "HOSTNAME") {
value = this->ValueToString(info.GetHostname());
- }
- else if(key == "FQDN")
- {
+ } else if (key == "FQDN") {
value = this->ValueToString(info.GetFullyQualifiedDomainName());
- }
- else if(key == "TOTAL_VIRTUAL_MEMORY")
- {
+ } else if (key == "TOTAL_VIRTUAL_MEMORY") {
value = this->ValueToString(info.GetTotalVirtualMemory());
- }
- else if(key == "AVAILABLE_VIRTUAL_MEMORY")
- {
+ } else if (key == "AVAILABLE_VIRTUAL_MEMORY") {
value = this->ValueToString(info.GetAvailableVirtualMemory());
- }
- else if(key == "TOTAL_PHYSICAL_MEMORY")
- {
+ } else if (key == "TOTAL_PHYSICAL_MEMORY") {
value = this->ValueToString(info.GetTotalPhysicalMemory());
- }
- else if(key == "AVAILABLE_PHYSICAL_MEMORY")
- {
+ } else if (key == "AVAILABLE_PHYSICAL_MEMORY") {
value = this->ValueToString(info.GetAvailablePhysicalMemory());
- }
- else
- {
+ } else {
std::string e = "does not recognize <key> " + key;
this->SetError(e);
return false;
- }
+ }
return true;
}
-std::string cmCMakeHostSystemInformationCommand
-::ValueToString(size_t value) const
+std::string cmCMakeHostSystemInformationCommand::ValueToString(
+ size_t value) const
{
std::stringstream tmp;
tmp << value;
return tmp.str();
}
-std::string cmCMakeHostSystemInformationCommand
-::ValueToString(const char *value) const
+std::string cmCMakeHostSystemInformationCommand::ValueToString(
+ const char* value) const
{
std::string safe_string = value ? value : "";
return safe_string;
}
-std::string cmCMakeHostSystemInformationCommand
-::ValueToString(std::string const& value) const
+std::string cmCMakeHostSystemInformationCommand::ValueToString(
+ std::string const& value) const
{
return value;
}
diff --git a/Source/cmCMakeHostSystemInformationCommand.h b/Source/cmCMakeHostSystemInformationCommand.h
index 463b180..6981ea9 100644
--- a/Source/cmCMakeHostSystemInformationCommand.h
+++ b/Source/cmCMakeHostSystemInformationCommand.h
@@ -29,38 +29,38 @@ public:
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
- {
+ {
return new cmCMakeHostSystemInformationCommand;
- }
+ }
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus &status);
+ cmExecutionStatus& status);
- /**
- * This determines if the command is invoked when in script mode.
- */
+ /**
+ * This determines if the command is invoked when in script mode.
+ */
virtual bool IsScriptable() const { return true; }
- /**
- * The name of the command as specified in CMakeList.txt.
- */
+ /**
+ * The name of the command as specified in CMakeList.txt.
+ */
virtual std::string GetName() const
- {
+ {
return "cmake_host_system_information";
- }
+ }
cmTypeMacro(cmCMakeHostSystemInformationCommand, cmCommand);
private:
- bool GetValue(cmsys::SystemInformation &info,
- std::string const& key, std::string &value);
+ bool GetValue(cmsys::SystemInformation& info, std::string const& key,
+ std::string& value);
std::string ValueToString(size_t value) const;
- std::string ValueToString(const char *value) const;
+ std::string ValueToString(const char* value) const;
std::string ValueToString(std::string const& value) const;
};
diff --git a/Source/cmCMakeMinimumRequired.cxx b/Source/cmCMakeMinimumRequired.cxx
index eac5965..1376845 100644
--- a/Source/cmCMakeMinimumRequired.cxx
+++ b/Source/cmCMakeMinimumRequired.cxx
@@ -14,54 +14,42 @@
#include "cmVersion.h"
// cmCMakeMinimumRequired
-bool cmCMakeMinimumRequired
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmCMakeMinimumRequired::InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus&)
{
// Process arguments.
std::string version_string;
bool doing_version = false;
- for(unsigned int i=0; i < args.size(); ++i)
- {
- if(args[i] == "VERSION")
- {
+ for (unsigned int i = 0; i < args.size(); ++i) {
+ if (args[i] == "VERSION") {
doing_version = true;
- }
- else if(args[i] == "FATAL_ERROR")
- {
- if(doing_version)
- {
+ } else if (args[i] == "FATAL_ERROR") {
+ if (doing_version) {
this->SetError("called with no value for VERSION.");
return false;
- }
- doing_version = false;
}
- else if(doing_version)
- {
+ doing_version = false;
+ } else if (doing_version) {
doing_version = false;
version_string = args[i];
- }
- else
- {
+ } else {
this->UnknownArguments.push_back(args[i]);
- }
}
- if(doing_version)
- {
+ }
+ if (doing_version) {
this->SetError("called with no value for VERSION.");
return false;
- }
+ }
// Make sure there was a version to check.
- if(version_string.empty())
- {
+ if (version_string.empty()) {
return this->EnforceUnknownArguments();
- }
+ }
// Save the required version string.
this->Makefile->AddDefinition("CMAKE_MINIMUM_REQUIRED_VERSION",
version_string.c_str());
-
// Get the current version number.
unsigned int current_major = cmVersion::GetMajorVersion();
unsigned int current_minor = cmVersion::GetMinorVersion();
@@ -74,28 +62,21 @@ bool cmCMakeMinimumRequired
unsigned int required_minor = 0;
unsigned int required_patch = 0;
unsigned int required_tweak = 0;
- if(sscanf(version_string.c_str(), "%u.%u.%u.%u",
- &required_major, &required_minor,
- &required_patch, &required_tweak) < 2)
- {
+ if (sscanf(version_string.c_str(), "%u.%u.%u.%u", &required_major,
+ &required_minor, &required_patch, &required_tweak) < 2) {
std::ostringstream e;
e << "could not parse VERSION \"" << version_string << "\".";
this->SetError(e.str());
return false;
- }
+ }
// Compare the version numbers.
- if((current_major < required_major) ||
- (current_major == required_major &&
- current_minor < required_minor) ||
- (current_major == required_major &&
- current_minor == required_minor &&
- current_patch < required_patch) ||
- (current_major == required_major &&
- current_minor == required_minor &&
- current_patch == required_patch &&
- current_tweak < required_tweak))
- {
+ if ((current_major < required_major) ||
+ (current_major == required_major && current_minor < required_minor) ||
+ (current_major == required_major && current_minor == required_minor &&
+ current_patch < required_patch) ||
+ (current_major == required_major && current_minor == required_minor &&
+ current_patch == required_patch && current_tweak < required_tweak)) {
// The current version is too low.
std::ostringstream e;
e << "CMake " << version_string
@@ -104,23 +85,19 @@ bool cmCMakeMinimumRequired
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
cmSystemTools::SetFatalErrorOccured();
return true;
- }
+ }
// The version is not from the future, so enforce unknown arguments.
- if(!this->EnforceUnknownArguments())
- {
+ if (!this->EnforceUnknownArguments()) {
return false;
- }
+ }
- if (required_major < 2 || (required_major == 2 && required_minor < 4))
- {
+ if (required_major < 2 || (required_major == 2 && required_minor < 4)) {
this->Makefile->IssueMessage(
cmake::AUTHOR_WARNING,
"Compatibility with CMake < 2.4 is not supported by CMake >= 3.0.");
this->Makefile->SetPolicyVersion("2.4");
- }
- else
- {
+ } else {
this->Makefile->SetPolicyVersion(version_string.c_str());
}
@@ -129,13 +106,12 @@ bool cmCMakeMinimumRequired
bool cmCMakeMinimumRequired::EnforceUnknownArguments()
{
- if(!this->UnknownArguments.empty())
- {
+ if (!this->UnknownArguments.empty()) {
std::ostringstream e;
- e << "called with unknown argument \""
- << this->UnknownArguments[0] << "\".";
+ e << "called with unknown argument \"" << this->UnknownArguments[0]
+ << "\".";
this->SetError(e.str());
return false;
- }
+ }
return true;
}
diff --git a/Source/cmCMakeMinimumRequired.h b/Source/cmCMakeMinimumRequired.h
index 31b7271..fc73e87 100644
--- a/Source/cmCMakeMinimumRequired.h
+++ b/Source/cmCMakeMinimumRequired.h
@@ -25,17 +25,14 @@ public:
/**
* This is a virtual constructor for the command.
*/
- virtual cmCommand* Clone()
- {
- return new cmCMakeMinimumRequired;
- }
+ virtual cmCommand* Clone() { return new cmCMakeMinimumRequired; }
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus &status);
+ cmExecutionStatus& status);
/**
* This determines if the command is invoked when in script mode.
@@ -45,7 +42,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const {return "cmake_minimum_required";}
+ virtual std::string GetName() const { return "cmake_minimum_required"; }
cmTypeMacro(cmCMakeMinimumRequired, cmCommand);
@@ -54,6 +51,4 @@ private:
bool EnforceUnknownArguments();
};
-
-
#endif
diff --git a/Source/cmCMakePolicyCommand.cxx b/Source/cmCMakePolicyCommand.cxx
index 9132aec..07e0885 100644
--- a/Source/cmCMakePolicyCommand.cxx
+++ b/Source/cmCMakePolicyCommand.cxx
@@ -14,47 +14,35 @@
#include "cmVersion.h"
// cmCMakePolicyCommand
-bool cmCMakePolicyCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmCMakePolicyCommand::InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus&)
{
- if(args.size() < 1)
- {
+ if (args.size() < 1) {
this->SetError("requires at least one argument.");
return false;
- }
+ }
- if(args[0] == "SET")
- {
+ if (args[0] == "SET") {
return this->HandleSetMode(args);
- }
- else if(args[0] == "GET")
- {
+ } else if (args[0] == "GET") {
return this->HandleGetMode(args);
- }
- else if(args[0] == "PUSH")
- {
- if(args.size() > 1)
- {
+ } else if (args[0] == "PUSH") {
+ if (args.size() > 1) {
this->SetError("PUSH may not be given additional arguments.");
return false;
- }
+ }
this->Makefile->PushPolicy();
return true;
- }
- else if(args[0] == "POP")
- {
- if(args.size() > 1)
- {
+ } else if (args[0] == "POP") {
+ if (args.size() > 1) {
this->SetError("POP may not be given additional arguments.");
return false;
- }
+ }
this->Makefile->PopPolicy();
return true;
- }
- else if(args[0] == "VERSION")
- {
+ } else if (args[0] == "VERSION") {
return this->HandleVersionMode(args);
- }
+ }
std::ostringstream e;
e << "given unknown first argument \"" << args[0] << "\"";
@@ -64,60 +52,50 @@ bool cmCMakePolicyCommand
bool cmCMakePolicyCommand::HandleSetMode(std::vector<std::string> const& args)
{
- if(args.size() != 3)
- {
+ if (args.size() != 3) {
this->SetError("SET must be given exactly 2 additional arguments.");
return false;
- }
+ }
cmPolicies::PolicyStatus status;
- if(args[2] == "OLD")
- {
+ if (args[2] == "OLD") {
status = cmPolicies::OLD;
- }
- else if(args[2] == "NEW")
- {
+ } else if (args[2] == "NEW") {
status = cmPolicies::NEW;
- }
- else
- {
+ } else {
std::ostringstream e;
e << "SET given unrecognized policy status \"" << args[2] << "\"";
this->SetError(e.str());
return false;
- }
+ }
- if(!this->Makefile->SetPolicy(args[1].c_str(), status))
- {
+ if (!this->Makefile->SetPolicy(args[1].c_str(), status)) {
this->SetError("SET failed to set policy.");
return false;
- }
- if(args[1] == "CMP0001" &&
- (status == cmPolicies::WARN || status == cmPolicies::OLD))
- {
- if(!(this->Makefile->GetState()
- ->GetInitializedCacheValue("CMAKE_BACKWARDS_COMPATIBILITY")))
- {
+ }
+ if (args[1] == "CMP0001" &&
+ (status == cmPolicies::WARN || status == cmPolicies::OLD)) {
+ if (!(this->Makefile->GetState()->GetInitializedCacheValue(
+ "CMAKE_BACKWARDS_COMPATIBILITY"))) {
// Set it to 2.4 because that is the last version where the
// variable had meaning.
- this->Makefile->AddCacheDefinition
- ("CMAKE_BACKWARDS_COMPATIBILITY", "2.4",
- "For backwards compatibility, what version of CMake "
- "commands and "
- "syntax should this version of CMake try to support.",
- cmState::STRING);
- }
- }
+ this->Makefile->AddCacheDefinition(
+ "CMAKE_BACKWARDS_COMPATIBILITY", "2.4",
+ "For backwards compatibility, what version of CMake "
+ "commands and "
+ "syntax should this version of CMake try to support.",
+ cmState::STRING);
+ }
+ }
return true;
}
bool cmCMakePolicyCommand::HandleGetMode(std::vector<std::string> const& args)
{
- if(args.size() != 3)
- {
+ if (args.size() != 3) {
this->SetError("GET must be given exactly 2 additional arguments.");
return false;
- }
+ }
// Get arguments.
std::string const& id = args[1];
@@ -125,19 +103,17 @@ bool cmCMakePolicyCommand::HandleGetMode(std::vector<std::string> const& args)
// Lookup the policy number.
cmPolicies::PolicyID pid;
- if(!cmPolicies::GetPolicyID(id.c_str(), pid))
- {
+ if (!cmPolicies::GetPolicyID(id.c_str(), pid)) {
std::ostringstream e;
e << "GET given policy \"" << id << "\" which is not known to this "
<< "version of CMake.";
this->SetError(e.str());
return false;
- }
+ }
// Lookup the policy setting.
cmPolicies::PolicyStatus status = this->Makefile->GetPolicyStatus(pid);
- switch (status)
- {
+ switch (status) {
case cmPolicies::OLD:
// Report that the policy is set to OLD.
this->Makefile->AddDefinition(var, "OLD");
@@ -154,32 +130,28 @@ bool cmCMakePolicyCommand::HandleGetMode(std::vector<std::string> const& args)
case cmPolicies::REQUIRED_ALWAYS:
// The policy is required to be set before anything needs it.
{
- std::ostringstream e;
- e << cmPolicies::GetRequiredPolicyError(pid)
- << "\n"
- << "The call to cmake_policy(GET " << id << " ...) at which this "
- << "error appears requests the policy, and this version of CMake "
- << "requires that the policy be set to NEW before it is checked.";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ std::ostringstream e;
+ e << cmPolicies::GetRequiredPolicyError(pid) << "\n"
+ << "The call to cmake_policy(GET " << id << " ...) at which this "
+ << "error appears requests the policy, and this version of CMake "
+ << "requires that the policy be set to NEW before it is checked.";
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
}
- }
+ }
return true;
}
-bool
-cmCMakePolicyCommand::HandleVersionMode(std::vector<std::string> const& args)
+bool cmCMakePolicyCommand::HandleVersionMode(
+ std::vector<std::string> const& args)
{
- if(args.size() <= 1)
- {
+ if (args.size() <= 1) {
this->SetError("VERSION not given an argument");
return false;
- }
- else if(args.size() >= 3)
- {
+ } else if (args.size() >= 3) {
this->SetError("VERSION given too many arguments");
return false;
- }
+ }
this->Makefile->SetPolicyVersion(args[1].c_str());
return true;
}
diff --git a/Source/cmCMakePolicyCommand.h b/Source/cmCMakePolicyCommand.h
index 8dc8fbe..dbb91d5 100644
--- a/Source/cmCMakePolicyCommand.h
+++ b/Source/cmCMakePolicyCommand.h
@@ -26,35 +26,31 @@ public:
/**
* This is a virtual constructor for the command.
*/
- virtual cmCommand* Clone()
- {
- return new cmCMakePolicyCommand;
- }
+ virtual cmCommand* Clone() { return new cmCMakePolicyCommand; }
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus &status);
+ cmExecutionStatus& status);
- /**
- * This determines if the command is invoked when in script mode.
- */
+ /**
+ * This determines if the command is invoked when in script mode.
+ */
virtual bool IsScriptable() const { return true; }
- /**
- * The name of the command as specified in CMakeList.txt.
- */
- virtual std::string GetName() const {return "cmake_policy";}
+ /**
+ * The name of the command as specified in CMakeList.txt.
+ */
+ virtual std::string GetName() const { return "cmake_policy"; }
cmTypeMacro(cmCMakePolicyCommand, cmCommand);
+
private:
bool HandleSetMode(std::vector<std::string> const& args);
bool HandleGetMode(std::vector<std::string> const& args);
bool HandleVersionMode(std::vector<std::string> const& args);
};
-
-
#endif
diff --git a/Source/cmCPackPropertiesGenerator.cxx b/Source/cmCPackPropertiesGenerator.cxx
index 3eef55a..af01c7d 100644
--- a/Source/cmCPackPropertiesGenerator.cxx
+++ b/Source/cmCPackPropertiesGenerator.cxx
@@ -4,44 +4,40 @@
#include "cmOutputConverter.h"
cmCPackPropertiesGenerator::cmCPackPropertiesGenerator(
- cmLocalGenerator* lg,
- cmInstalledFile const& installedFile,
- std::vector<std::string> const& configurations):
- cmScriptGenerator("CPACK_BUILD_CONFIG", configurations),
- LG(lg),
- InstalledFile(installedFile)
+ cmLocalGenerator* lg, cmInstalledFile const& installedFile,
+ std::vector<std::string> const& configurations)
+ : cmScriptGenerator("CPACK_BUILD_CONFIG", configurations)
+ , LG(lg)
+ , InstalledFile(installedFile)
{
this->ActionsPerConfig = true;
}
-void cmCPackPropertiesGenerator::GenerateScriptForConfig(std::ostream& os,
- const std::string& config, Indent const& indent)
+void cmCPackPropertiesGenerator::GenerateScriptForConfig(
+ std::ostream& os, const std::string& config, Indent const& indent)
{
std::string const& expandedFileName =
- this->InstalledFile.GetNameExpression().Evaluate(this->LG,
- config);
+ this->InstalledFile.GetNameExpression().Evaluate(this->LG, config);
cmInstalledFile::PropertyMapType const& properties =
this->InstalledFile.GetProperties();
- for(cmInstalledFile::PropertyMapType::const_iterator i = properties.begin();
- i != properties.end(); ++i)
- {
+ for (cmInstalledFile::PropertyMapType::const_iterator i = properties.begin();
+ i != properties.end(); ++i) {
std::string const& name = i->first;
cmInstalledFile::Property const& property = i->second;
- os << indent << "set_property(INSTALL " <<
- cmOutputConverter::EscapeForCMake(expandedFileName) << " PROPERTY " <<
- cmOutputConverter::EscapeForCMake(name);
+ os << indent << "set_property(INSTALL "
+ << cmOutputConverter::EscapeForCMake(expandedFileName) << " PROPERTY "
+ << cmOutputConverter::EscapeForCMake(name);
- for(cmInstalledFile::ExpressionVectorType::const_iterator
- j = property.ValueExpressions.begin();
- j != property.ValueExpressions.end(); ++j)
- {
+ for (cmInstalledFile::ExpressionVectorType::const_iterator j =
+ property.ValueExpressions.begin();
+ j != property.ValueExpressions.end(); ++j) {
std::string value = (*j)->Evaluate(this->LG, config);
os << " " << cmOutputConverter::EscapeForCMake(value);
- }
+ }
os << ")\n";
- }
+ }
}
diff --git a/Source/cmCPackPropertiesGenerator.h b/Source/cmCPackPropertiesGenerator.h
index e54bcab..4372b87 100644
--- a/Source/cmCPackPropertiesGenerator.h
+++ b/Source/cmCPackPropertiesGenerator.h
@@ -21,17 +21,17 @@ class cmLocalGenerator;
* \brief Support class for generating CPackProperties.cmake.
*
*/
-class cmCPackPropertiesGenerator: public cmScriptGenerator
+class cmCPackPropertiesGenerator : public cmScriptGenerator
{
public:
- cmCPackPropertiesGenerator(
- cmLocalGenerator* lg,
- cmInstalledFile const& installedFile,
- std::vector<std::string> const& configurations);
+ cmCPackPropertiesGenerator(cmLocalGenerator* lg,
+ cmInstalledFile const& installedFile,
+ std::vector<std::string> const& configurations);
protected:
virtual void GenerateScriptForConfig(std::ostream& os,
- const std::string& config, Indent const& indent);
+ const std::string& config,
+ Indent const& indent);
cmLocalGenerator* LG;
cmInstalledFile const& InstalledFile;
diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx
index b203a22..a78300c 100644
--- a/Source/cmCPluginAPI.cxx
+++ b/Source/cmCPluginAPI.cxx
@@ -24,191 +24,175 @@
#include <stdlib.h>
#ifdef __QNX__
-# include <malloc.h> /* for malloc/free on QNX */
+#include <malloc.h> /* for malloc/free on QNX */
#endif
-extern "C"
-{
+extern "C" {
-void CCONV *cmGetClientData(void *info)
+void CCONV* cmGetClientData(void* info)
{
- return ((cmLoadedCommandInfo *)info)->ClientData;
+ return ((cmLoadedCommandInfo*)info)->ClientData;
}
-void CCONV cmSetClientData(void *info, void *cd)
+void CCONV cmSetClientData(void* info, void* cd)
{
- ((cmLoadedCommandInfo *)info)->ClientData = cd;
+ ((cmLoadedCommandInfo*)info)->ClientData = cd;
}
-void CCONV cmSetError(void *info, const char *err)
+void CCONV cmSetError(void* info, const char* err)
{
- if (((cmLoadedCommandInfo *)info)->Error)
- {
- free(((cmLoadedCommandInfo *)info)->Error);
- }
- ((cmLoadedCommandInfo *)info)->Error = strdup(err);
+ if (((cmLoadedCommandInfo*)info)->Error) {
+ free(((cmLoadedCommandInfo*)info)->Error);
+ }
+ ((cmLoadedCommandInfo*)info)->Error = strdup(err);
}
-unsigned int CCONV cmGetCacheMajorVersion(void *arg)
+unsigned int CCONV cmGetCacheMajorVersion(void* arg)
{
- cmMakefile *mf = static_cast<cmMakefile *>(arg);
- cmState *state = mf->GetState();
+ cmMakefile* mf = static_cast<cmMakefile*>(arg);
+ cmState* state = mf->GetState();
return state->GetCacheMajorVersion();
}
-unsigned int CCONV cmGetCacheMinorVersion(void *arg)
+unsigned int CCONV cmGetCacheMinorVersion(void* arg)
{
- cmMakefile *mf = static_cast<cmMakefile *>(arg);
- cmState *state = mf->GetState();
+ cmMakefile* mf = static_cast<cmMakefile*>(arg);
+ cmState* state = mf->GetState();
return state->GetCacheMinorVersion();
}
-unsigned int CCONV cmGetMajorVersion(void *)
+unsigned int CCONV cmGetMajorVersion(void*)
{
return cmVersion::GetMajorVersion();
}
-unsigned int CCONV cmGetMinorVersion(void *)
+unsigned int CCONV cmGetMinorVersion(void*)
{
return cmVersion::GetMinorVersion();
}
-void CCONV cmAddDefinition(void *arg, const char* name, const char* value)
+void CCONV cmAddDefinition(void* arg, const char* name, const char* value)
{
- cmMakefile *mf = static_cast<cmMakefile *>(arg);
- mf->AddDefinition(name,value);
+ cmMakefile* mf = static_cast<cmMakefile*>(arg);
+ mf->AddDefinition(name, value);
}
/* Add a definition to this makefile and the global cmake cache. */
-void CCONV cmAddCacheDefinition(void *arg, const char* name,
- const char* value, const char* doc, int type)
+void CCONV cmAddCacheDefinition(void* arg, const char* name, const char* value,
+ const char* doc, int type)
{
- cmMakefile *mf = static_cast<cmMakefile *>(arg);
+ cmMakefile* mf = static_cast<cmMakefile*>(arg);
- switch (type)
- {
+ switch (type) {
case CM_CACHE_BOOL:
- mf->AddCacheDefinition(name,value,doc,
- cmState::BOOL);
+ mf->AddCacheDefinition(name, value, doc, cmState::BOOL);
break;
case CM_CACHE_PATH:
- mf->AddCacheDefinition(name,value,doc,
- cmState::PATH);
+ mf->AddCacheDefinition(name, value, doc, cmState::PATH);
break;
case CM_CACHE_FILEPATH:
- mf->AddCacheDefinition(name,value,doc,
- cmState::FILEPATH);
+ mf->AddCacheDefinition(name, value, doc, cmState::FILEPATH);
break;
case CM_CACHE_STRING:
- mf->AddCacheDefinition(name,value,doc,
- cmState::STRING);
+ mf->AddCacheDefinition(name, value, doc, cmState::STRING);
break;
case CM_CACHE_INTERNAL:
- mf->AddCacheDefinition(name,value,doc,
- cmState::INTERNAL);
+ mf->AddCacheDefinition(name, value, doc, cmState::INTERNAL);
break;
case CM_CACHE_STATIC:
- mf->AddCacheDefinition(name,value,doc,
- cmState::STATIC);
+ mf->AddCacheDefinition(name, value, doc, cmState::STATIC);
break;
- }
+ }
}
-const char* CCONV cmGetProjectName(void *arg)
+const char* CCONV cmGetProjectName(void* arg)
{
- cmMakefile *mf = static_cast<cmMakefile *>(arg);
+ cmMakefile* mf = static_cast<cmMakefile*>(arg);
static std::string name;
name = mf->GetStateSnapshot().GetProjectName();
return name.c_str();
}
-const char* CCONV cmGetHomeDirectory(void *arg)
+const char* CCONV cmGetHomeDirectory(void* arg)
{
- cmMakefile *mf = static_cast<cmMakefile *>(arg);
+ cmMakefile* mf = static_cast<cmMakefile*>(arg);
return mf->GetHomeDirectory();
}
-const char* CCONV cmGetHomeOutputDirectory(void *arg)
+const char* CCONV cmGetHomeOutputDirectory(void* arg)
{
- cmMakefile *mf = static_cast<cmMakefile *>(arg);
+ cmMakefile* mf = static_cast<cmMakefile*>(arg);
return mf->GetHomeOutputDirectory();
}
-const char* CCONV cmGetStartDirectory(void *arg)
+const char* CCONV cmGetStartDirectory(void* arg)
{
- cmMakefile *mf = static_cast<cmMakefile *>(arg);
+ cmMakefile* mf = static_cast<cmMakefile*>(arg);
return mf->GetCurrentSourceDirectory();
}
-const char* CCONV cmGetStartOutputDirectory(void *arg)
+const char* CCONV cmGetStartOutputDirectory(void* arg)
{
- cmMakefile *mf = static_cast<cmMakefile *>(arg);
+ cmMakefile* mf = static_cast<cmMakefile*>(arg);
return mf->GetCurrentBinaryDirectory();
}
-const char* CCONV cmGetCurrentDirectory(void *arg)
+const char* CCONV cmGetCurrentDirectory(void* arg)
{
- cmMakefile *mf = static_cast<cmMakefile *>(arg);
+ cmMakefile* mf = static_cast<cmMakefile*>(arg);
return mf->GetCurrentSourceDirectory();
}
-const char* CCONV cmGetCurrentOutputDirectory(void *arg)
+const char* CCONV cmGetCurrentOutputDirectory(void* arg)
{
- cmMakefile *mf = static_cast<cmMakefile *>(arg);
+ cmMakefile* mf = static_cast<cmMakefile*>(arg);
return mf->GetCurrentBinaryDirectory();
}
-const char* CCONV cmGetDefinition(void *arg,const char*def)
+const char* CCONV cmGetDefinition(void* arg, const char* def)
{
- cmMakefile *mf = static_cast<cmMakefile *>(arg);
+ cmMakefile* mf = static_cast<cmMakefile*>(arg);
return mf->GetDefinition(def);
}
-int CCONV cmIsOn(void *arg, const char* name)
+int CCONV cmIsOn(void* arg, const char* name)
{
- cmMakefile *mf = static_cast<cmMakefile *>(arg);
+ cmMakefile* mf = static_cast<cmMakefile*>(arg);
return static_cast<int>(mf->IsOn(name));
}
/** Check if a command exists. */
-int CCONV cmCommandExists(void *arg, const char* name)
+int CCONV cmCommandExists(void* arg, const char* name)
{
- cmMakefile *mf = static_cast<cmMakefile *>(arg);
+ cmMakefile* mf = static_cast<cmMakefile*>(arg);
return static_cast<int>(mf->GetState()->GetCommand(name) ? 1 : 0);
}
-void CCONV cmAddDefineFlag(void *arg, const char* definition)
+void CCONV cmAddDefineFlag(void* arg, const char* definition)
{
- cmMakefile *mf = static_cast<cmMakefile *>(arg);
+ cmMakefile* mf = static_cast<cmMakefile*>(arg);
mf->AddDefineFlag(definition);
}
-void CCONV cmAddLinkDirectoryForTarget(void *arg, const char *tgt,
- const char* d)
+void CCONV cmAddLinkDirectoryForTarget(void* arg, const char* tgt,
+ const char* d)
{
- cmMakefile *mf = static_cast<cmMakefile *>(arg);
- mf->AddLinkDirectoryForTarget(tgt,d);
+ cmMakefile* mf = static_cast<cmMakefile*>(arg);
+ mf->AddLinkDirectoryForTarget(tgt, d);
}
-
-void CCONV cmAddExecutable(void *arg, const char *exename,
- int numSrcs, const char **srcs, int win32)
+void CCONV cmAddExecutable(void* arg, const char* exename, int numSrcs,
+ const char** srcs, int win32)
{
- cmMakefile *mf = static_cast<cmMakefile *>(arg);
+ cmMakefile* mf = static_cast<cmMakefile*>(arg);
std::vector<std::string> srcs2;
int i;
- for (i = 0; i < numSrcs; ++i)
- {
+ for (i = 0; i < numSrcs; ++i) {
srcs2.push_back(srcs[i]);
- }
- cmTarget* tg = mf->AddExecutable(exename, srcs2);
- if ( win32 )
- {
- tg->SetProperty("WIN32_EXECUTABLE", "ON");
- }
-}
-
-void CCONV cmAddUtilityCommand(void *arg, const char* utilityName,
- const char* command,
- const char* arguments,
- int all,
- int numDepends,
- const char **depends,
- int,
- const char **)
+ }
+ cmTarget* tg = mf->AddExecutable(exename, srcs2);
+ if (win32) {
+ tg->SetProperty("WIN32_EXECUTABLE", "ON");
+ }
+}
+
+void CCONV cmAddUtilityCommand(void* arg, const char* utilityName,
+ const char* command, const char* arguments,
+ int all, int numDepends, const char** depends,
+ int, const char**)
{
// Get the makefile instance. Perform an extra variable expansion
// now because the API caller expects it.
@@ -218,33 +202,30 @@ void CCONV cmAddUtilityCommand(void *arg, const char* utilityName,
cmCustomCommandLine commandLine;
std::string expand = command;
commandLine.push_back(mf->ExpandVariablesInString(expand));
- if(arguments && arguments[0])
- {
+ if (arguments && arguments[0]) {
// TODO: Parse arguments!
expand = arguments;
commandLine.push_back(mf->ExpandVariablesInString(expand));
- }
+ }
cmCustomCommandLines commandLines;
commandLines.push_back(commandLine);
// Accumulate the list of dependencies.
std::vector<std::string> depends2;
- for(int i = 0; i < numDepends; ++i)
- {
+ for (int i = 0; i < numDepends; ++i) {
expand = depends[i];
depends2.push_back(mf->ExpandVariablesInString(expand));
- }
+ }
// Pass the call to the makefile instance.
- mf->AddUtilityCommand(utilityName, (all ? false : true),
- 0, depends2, commandLines);
+ mf->AddUtilityCommand(utilityName, (all ? false : true), 0, depends2,
+ commandLines);
}
-void CCONV cmAddCustomCommand(void *arg, const char* source,
- const char* command,
- int numArgs, const char **args,
- int numDepends, const char **depends,
- int numOutputs, const char **outputs,
- const char *target)
+void CCONV cmAddCustomCommand(void* arg, const char* source,
+ const char* command, int numArgs,
+ const char** args, int numDepends,
+ const char** depends, int numOutputs,
+ const char** outputs, const char* target)
{
// Get the makefile instance. Perform an extra variable expansion
// now because the API caller expects it.
@@ -254,29 +235,26 @@ void CCONV cmAddCustomCommand(void *arg, const char* source,
cmCustomCommandLine commandLine;
std::string expand = command;
commandLine.push_back(mf->ExpandVariablesInString(expand));
- for(int i=0; i < numArgs; ++i)
- {
+ for (int i = 0; i < numArgs; ++i) {
expand = args[i];
commandLine.push_back(mf->ExpandVariablesInString(expand));
- }
+ }
cmCustomCommandLines commandLines;
commandLines.push_back(commandLine);
// Accumulate the list of dependencies.
std::vector<std::string> depends2;
- for(int i = 0; i < numDepends; ++i)
- {
+ for (int i = 0; i < numDepends; ++i) {
expand = depends[i];
depends2.push_back(mf->ExpandVariablesInString(expand));
- }
+ }
// Accumulate the list of outputs.
std::vector<std::string> outputs2;
- for(int i = 0; i < numOutputs; ++i)
- {
+ for (int i = 0; i < numOutputs; ++i) {
expand = outputs[i];
outputs2.push_back(mf->ExpandVariablesInString(expand));
- }
+ }
// Pass the call to the makefile instance.
const char* no_comment = 0;
@@ -284,11 +262,11 @@ void CCONV cmAddCustomCommand(void *arg, const char* source,
commandLines, no_comment);
}
-void CCONV cmAddCustomCommandToOutput(void *arg, const char* output,
- const char* command,
- int numArgs, const char **args,
- const char* main_dependency,
- int numDepends, const char **depends)
+void CCONV cmAddCustomCommandToOutput(void* arg, const char* output,
+ const char* command, int numArgs,
+ const char** args,
+ const char* main_dependency,
+ int numDepends, const char** depends)
{
// Get the makefile instance. Perform an extra variable expansion
// now because the API caller expects it.
@@ -298,33 +276,30 @@ void CCONV cmAddCustomCommandToOutput(void *arg, const char* output,
cmCustomCommandLine commandLine;
std::string expand = command;
commandLine.push_back(mf->ExpandVariablesInString(expand));
- for(int i=0; i < numArgs; ++i)
- {
+ for (int i = 0; i < numArgs; ++i) {
expand = args[i];
commandLine.push_back(mf->ExpandVariablesInString(expand));
- }
+ }
cmCustomCommandLines commandLines;
commandLines.push_back(commandLine);
// Accumulate the list of dependencies.
std::vector<std::string> depends2;
- for(int i = 0; i < numDepends; ++i)
- {
+ for (int i = 0; i < numDepends; ++i) {
expand = depends[i];
depends2.push_back(mf->ExpandVariablesInString(expand));
- }
+ }
// Pass the call to the makefile instance.
const char* no_comment = 0;
const char* no_working_dir = 0;
- mf->AddCustomCommandToOutput(output, depends2, main_dependency,
- commandLines, no_comment, no_working_dir);
+ mf->AddCustomCommandToOutput(output, depends2, main_dependency, commandLines,
+ no_comment, no_working_dir);
}
-void CCONV cmAddCustomCommandToTarget(void *arg, const char* target,
- const char* command,
- int numArgs, const char **args,
- int commandType)
+void CCONV cmAddCustomCommandToTarget(void* arg, const char* target,
+ const char* command, int numArgs,
+ const char** args, int commandType)
{
// Get the makefile instance.
cmMakefile* mf = static_cast<cmMakefile*>(arg);
@@ -334,18 +309,16 @@ void CCONV cmAddCustomCommandToTarget(void *arg, const char* target,
cmCustomCommandLine commandLine;
std::string expand = command;
commandLine.push_back(mf->ExpandVariablesInString(expand));
- for(int i=0; i < numArgs; ++i)
- {
+ for (int i = 0; i < numArgs; ++i) {
expand = args[i];
commandLine.push_back(mf->ExpandVariablesInString(expand));
- }
+ }
cmCustomCommandLines commandLines;
commandLines.push_back(commandLine);
// Select the command type.
cmTarget::CustomCommandType cctype = cmTarget::POST_BUILD;
- switch (commandType)
- {
+ switch (commandType) {
case CM_PRE_BUILD:
cctype = cmTarget::PRE_BUILD;
break;
@@ -355,7 +328,7 @@ void CCONV cmAddCustomCommandToTarget(void *arg, const char* target,
case CM_POST_BUILD:
cctype = cmTarget::POST_BUILD;
break;
- }
+ }
// Pass the call to the makefile instance.
std::vector<std::string> no_byproducts;
@@ -366,128 +339,112 @@ void CCONV cmAddCustomCommandToTarget(void *arg, const char* target,
cctype, no_comment, no_working_dir);
}
-void CCONV cmAddLinkLibraryForTarget(void *arg, const char *tgt,
- const char*value, int libtype)
+void CCONV cmAddLinkLibraryForTarget(void* arg, const char* tgt,
+ const char* value, int libtype)
{
- cmMakefile *mf = static_cast<cmMakefile *>(arg);
+ cmMakefile* mf = static_cast<cmMakefile*>(arg);
- switch (libtype)
- {
+ switch (libtype) {
case CM_LIBRARY_GENERAL:
- mf->AddLinkLibraryForTarget(tgt,value, GENERAL_LibraryType);
+ mf->AddLinkLibraryForTarget(tgt, value, GENERAL_LibraryType);
break;
case CM_LIBRARY_DEBUG:
- mf->AddLinkLibraryForTarget(tgt,value, DEBUG_LibraryType);
+ mf->AddLinkLibraryForTarget(tgt, value, DEBUG_LibraryType);
break;
case CM_LIBRARY_OPTIMIZED:
- mf->AddLinkLibraryForTarget(tgt,value, OPTIMIZED_LibraryType);
+ mf->AddLinkLibraryForTarget(tgt, value, OPTIMIZED_LibraryType);
break;
- }
+ }
}
-void CCONV cmAddLibrary(void *arg, const char *libname, int shared,
- int numSrcs, const char **srcs)
+void CCONV cmAddLibrary(void* arg, const char* libname, int shared,
+ int numSrcs, const char** srcs)
{
- cmMakefile *mf = static_cast<cmMakefile *>(arg);
+ cmMakefile* mf = static_cast<cmMakefile*>(arg);
std::vector<std::string> srcs2;
int i;
- for (i = 0; i < numSrcs; ++i)
- {
+ for (i = 0; i < numSrcs; ++i) {
srcs2.push_back(srcs[i]);
- }
+ }
mf->AddLibrary(libname,
- (shared? cmState::SHARED_LIBRARY : cmState::STATIC_LIBRARY),
- srcs2);
+ (shared ? cmState::SHARED_LIBRARY : cmState::STATIC_LIBRARY),
+ srcs2);
}
-char CCONV *cmExpandVariablesInString(void *arg, const char *source,
- int escapeQuotes, int atOnly)
+char CCONV* cmExpandVariablesInString(void* arg, const char* source,
+ int escapeQuotes, int atOnly)
{
- cmMakefile *mf = static_cast<cmMakefile *>(arg);
+ cmMakefile* mf = static_cast<cmMakefile*>(arg);
std::string barf = source;
- std::string result =
- mf->ExpandVariablesInString(barf,
- (escapeQuotes ? true : false),
- (atOnly ? true : false));
- char *res = static_cast<char *>(malloc(result.size() + 1));
- if (result.size())
- {
- strcpy(res,result.c_str());
- }
+ std::string result = mf->ExpandVariablesInString(
+ barf, (escapeQuotes ? true : false), (atOnly ? true : false));
+ char* res = static_cast<char*>(malloc(result.size() + 1));
+ if (result.size()) {
+ strcpy(res, result.c_str());
+ }
res[result.size()] = '\0';
return res;
}
-
-int CCONV cmExecuteCommand(void *arg, const char *name,
- int numArgs, const char **args)
+int CCONV cmExecuteCommand(void* arg, const char* name, int numArgs,
+ const char** args)
{
- cmMakefile *mf = static_cast<cmMakefile *>(arg);
+ cmMakefile* mf = static_cast<cmMakefile*>(arg);
cmListFileFunction lff;
lff.Name = name;
- for(int i = 0; i < numArgs; ++i)
- {
+ for (int i = 0; i < numArgs; ++i) {
// Assume all arguments are quoted.
lff.Arguments.push_back(
cmListFileArgument(args[i], cmListFileArgument::Quoted, 0));
- }
+ }
cmExecutionStatus status;
- return mf->ExecuteCommand(lff,status);
+ return mf->ExecuteCommand(lff, status);
}
-void CCONV cmExpandSourceListArguments(void *arg,
- int numArgs,
- const char **args,
- int *resArgc,
- char ***resArgv,
- unsigned int startArgumentIndex)
+void CCONV cmExpandSourceListArguments(void* arg, int numArgs,
+ const char** args, int* resArgc,
+ char*** resArgv,
+ unsigned int startArgumentIndex)
{
(void)arg;
(void)startArgumentIndex;
std::vector<std::string> result;
int i;
- for (i = 0; i < numArgs; ++i)
- {
+ for (i = 0; i < numArgs; ++i) {
result.push_back(args[i]);
- }
+ }
int resargc = static_cast<int>(result.size());
- char **resargv = 0;
- if (resargc)
- {
- resargv = (char **)malloc(resargc*sizeof(char *));
- }
- for (i = 0; i < resargc; ++i)
- {
+ char** resargv = 0;
+ if (resargc) {
+ resargv = (char**)malloc(resargc * sizeof(char*));
+ }
+ for (i = 0; i < resargc; ++i) {
resargv[i] = strdup(result[i].c_str());
- }
+ }
*resArgc = resargc;
*resArgv = resargv;
}
-void CCONV cmFreeArguments(int argc, char **argv)
+void CCONV cmFreeArguments(int argc, char** argv)
{
int i;
- for (i = 0; i < argc; ++i)
- {
+ for (i = 0; i < argc; ++i) {
free(argv[i]);
- }
- if (argv)
- {
+ }
+ if (argv) {
free(argv);
- }
+ }
}
-int CCONV cmGetTotalArgumentSize(int argc, char **argv)
+int CCONV cmGetTotalArgumentSize(int argc, char** argv)
{
int i;
int result = 0;
- for (i = 0; i < argc; ++i)
- {
- if (argv[i])
- {
+ for (i = 0; i < argc; ++i) {
+ if (argv[i]) {
result = result + static_cast<int>(strlen(argv[i]));
- }
}
+ }
return result;
}
@@ -495,7 +452,10 @@ int CCONV cmGetTotalArgumentSize(int argc, char **argv)
// API for source files.
struct cmCPluginAPISourceFile
{
- cmCPluginAPISourceFile(): RealSourceFile(0) {}
+ cmCPluginAPISourceFile()
+ : RealSourceFile(0)
+ {
+ }
cmSourceFile* RealSourceFile;
std::string SourceName;
std::string SourceExtension;
@@ -506,54 +466,50 @@ struct cmCPluginAPISourceFile
// Keep a map from real cmSourceFile instances stored in a makefile to
// the CPluginAPI proxy source file.
-class cmCPluginAPISourceFileMap:
- public std::map<cmSourceFile*, cmCPluginAPISourceFile*>
+class cmCPluginAPISourceFileMap
+ : public std::map<cmSourceFile*, cmCPluginAPISourceFile*>
{
public:
typedef std::map<cmSourceFile*, cmCPluginAPISourceFile*> derived;
typedef derived::iterator iterator;
typedef derived::value_type value_type;
~cmCPluginAPISourceFileMap()
- {
- for(iterator i=this->begin(); i != this->end(); ++i)
- {
+ {
+ for (iterator i = this->begin(); i != this->end(); ++i) {
delete i->second;
- }
}
+ }
};
cmCPluginAPISourceFileMap cmCPluginAPISourceFiles;
-void * CCONV cmCreateSourceFile(void)
+void* CCONV cmCreateSourceFile(void)
{
return (void*)new cmCPluginAPISourceFile;
}
-void * CCONV cmCreateNewSourceFile(void *)
+void* CCONV cmCreateNewSourceFile(void*)
{
- cmCPluginAPISourceFile *sf = new cmCPluginAPISourceFile;
+ cmCPluginAPISourceFile* sf = new cmCPluginAPISourceFile;
return (void*)sf;
}
-void CCONV cmDestroySourceFile(void *arg)
+void CCONV cmDestroySourceFile(void* arg)
{
cmCPluginAPISourceFile* sf = static_cast<cmCPluginAPISourceFile*>(arg);
// Only delete if it was created by cmCreateSourceFile or
// cmCreateNewSourceFile and is therefore not in the map.
- if(!sf->RealSourceFile)
- {
+ if (!sf->RealSourceFile) {
delete sf;
- }
+ }
}
-void CCONV *cmGetSource(void *arg, const char *name)
+void CCONV* cmGetSource(void* arg, const char* name)
{
- cmMakefile *mf = static_cast<cmMakefile *>(arg);
- if(cmSourceFile* rsf = mf->GetSource(name))
- {
+ cmMakefile* mf = static_cast<cmMakefile*>(arg);
+ if (cmSourceFile* rsf = mf->GetSource(name)) {
// Lookup the proxy source file object for this source.
cmCPluginAPISourceFileMap::iterator i = cmCPluginAPISourceFiles.find(rsf);
- if(i == cmCPluginAPISourceFiles.end())
- {
+ if (i == cmCPluginAPISourceFiles.end()) {
// Create a proxy source file object for this source.
cmCPluginAPISourceFile* sf = new cmCPluginAPISourceFile;
sf->RealSourceFile = rsf;
@@ -566,32 +522,28 @@ void CCONV *cmGetSource(void *arg, const char *name)
// Store the proxy in the map so it can be re-used and deleted later.
cmCPluginAPISourceFileMap::value_type entry(rsf, sf);
i = cmCPluginAPISourceFiles.insert(entry).first;
- }
- return (void *)i->second;
}
- else
- {
+ return (void*)i->second;
+ } else {
return 0;
- }
+ }
}
-void * CCONV cmAddSource(void *arg, void *arg2)
+void* CCONV cmAddSource(void* arg, void* arg2)
{
- cmMakefile *mf = static_cast<cmMakefile *>(arg);
+ cmMakefile* mf = static_cast<cmMakefile*>(arg);
cmCPluginAPISourceFile* osf = static_cast<cmCPluginAPISourceFile*>(arg2);
- if(osf->FullPath.empty())
- {
+ if (osf->FullPath.empty()) {
return 0;
- }
+ }
// Create the real cmSourceFile instance and copy over saved information.
cmSourceFile* rsf = mf->GetOrCreateSource(osf->FullPath);
rsf->GetProperties() = osf->Properties;
- for(std::vector<std::string>::iterator i = osf->Depends.begin();
- i != osf->Depends.end(); ++i)
- {
+ for (std::vector<std::string>::iterator i = osf->Depends.begin();
+ i != osf->Depends.end(); ++i) {
rsf->AddDepend(i->c_str());
- }
+ }
// Create the proxy for the real source file.
cmCPluginAPISourceFile* sf = new cmCPluginAPISourceFile;
@@ -602,103 +554,89 @@ void * CCONV cmAddSource(void *arg, void *arg2)
// Store the proxy in the map so it can be re-used and deleted later.
cmCPluginAPISourceFiles[rsf] = sf;
- return (void *)sf;
+ return (void*)sf;
}
-const char * CCONV cmSourceFileGetSourceName(void *arg)
+const char* CCONV cmSourceFileGetSourceName(void* arg)
{
cmCPluginAPISourceFile* sf = static_cast<cmCPluginAPISourceFile*>(arg);
return sf->SourceName.c_str();
}
-const char * CCONV cmSourceFileGetFullPath(void *arg)
+const char* CCONV cmSourceFileGetFullPath(void* arg)
{
cmCPluginAPISourceFile* sf = static_cast<cmCPluginAPISourceFile*>(arg);
return sf->FullPath.c_str();
}
-const char * CCONV cmSourceFileGetProperty(void *arg,const char *prop)
+const char* CCONV cmSourceFileGetProperty(void* arg, const char* prop)
{
cmCPluginAPISourceFile* sf = static_cast<cmCPluginAPISourceFile*>(arg);
- if(cmSourceFile* rsf = sf->RealSourceFile)
- {
+ if (cmSourceFile* rsf = sf->RealSourceFile) {
return rsf->GetProperty(prop);
- }
- else
- {
- if(!strcmp(prop,"LOCATION"))
- {
+ } else {
+ if (!strcmp(prop, "LOCATION")) {
return sf->FullPath.c_str();
- }
- return sf->Properties.GetPropertyValue(prop);
}
+ return sf->Properties.GetPropertyValue(prop);
+ }
}
-int CCONV cmSourceFileGetPropertyAsBool(void *arg,const char *prop)
+int CCONV cmSourceFileGetPropertyAsBool(void* arg, const char* prop)
{
cmCPluginAPISourceFile* sf = static_cast<cmCPluginAPISourceFile*>(arg);
- if(cmSourceFile* rsf = sf->RealSourceFile)
- {
- return rsf->GetPropertyAsBool(prop) ? 1:0;
- }
- else
- {
- return cmSystemTools::IsOn(cmSourceFileGetProperty(arg, prop))? 1:0;
- }
+ if (cmSourceFile* rsf = sf->RealSourceFile) {
+ return rsf->GetPropertyAsBool(prop) ? 1 : 0;
+ } else {
+ return cmSystemTools::IsOn(cmSourceFileGetProperty(arg, prop)) ? 1 : 0;
+ }
}
-void CCONV cmSourceFileSetProperty(void *arg,const char *prop,
- const char *value)
+void CCONV cmSourceFileSetProperty(void* arg, const char* prop,
+ const char* value)
{
cmCPluginAPISourceFile* sf = static_cast<cmCPluginAPISourceFile*>(arg);
- if(cmSourceFile* rsf = sf->RealSourceFile)
- {
+ if (cmSourceFile* rsf = sf->RealSourceFile) {
rsf->SetProperty(prop, value);
+ } else if (prop) {
+ if (!value) {
+ value = "NOTFOUND";
}
- else if(prop)
- {
- if(!value) { value = "NOTFOUND"; }
sf->Properties.SetProperty(prop, value);
- }
+ }
}
-void CCONV cmSourceFileAddDepend(void *arg, const char *depend)
+void CCONV cmSourceFileAddDepend(void* arg, const char* depend)
{
cmCPluginAPISourceFile* sf = static_cast<cmCPluginAPISourceFile*>(arg);
- if(cmSourceFile* rsf = sf->RealSourceFile)
- {
+ if (cmSourceFile* rsf = sf->RealSourceFile) {
rsf->AddDepend(depend);
- }
- else
- {
+ } else {
sf->Depends.push_back(depend);
- }
+ }
}
-void CCONV cmSourceFileSetName(void *arg, const char* name, const char* dir,
+void CCONV cmSourceFileSetName(void* arg, const char* name, const char* dir,
int numSourceExtensions,
- const char **sourceExtensions,
+ const char** sourceExtensions,
int numHeaderExtensions,
- const char **headerExtensions)
+ const char** headerExtensions)
{
cmCPluginAPISourceFile* sf = static_cast<cmCPluginAPISourceFile*>(arg);
- if(sf->RealSourceFile)
- {
+ if (sf->RealSourceFile) {
// SetName is allowed only on temporary source files created by
// the command for building and passing to AddSource.
return;
- }
+ }
std::vector<std::string> sourceExts;
std::vector<std::string> headerExts;
int i;
- for (i = 0; i < numSourceExtensions; ++i)
- {
+ for (i = 0; i < numSourceExtensions; ++i) {
sourceExts.push_back(sourceExtensions[i]);
- }
- for (i = 0; i < numHeaderExtensions; ++i)
- {
+ }
+ for (i = 0; i < numHeaderExtensions; ++i) {
headerExts.push_back(headerExtensions[i]);
- }
+ }
// Save the original name given.
sf->SourceName = name;
@@ -710,167 +648,150 @@ void CCONV cmSourceFileSetName(void *arg, const char* name, const char* dir,
// First try and see whether the listed file can be found
// as is without extensions added on.
std::string hname = pathname;
- if(cmSystemTools::FileExists(hname.c_str()))
- {
+ if (cmSystemTools::FileExists(hname.c_str())) {
sf->SourceName = cmSystemTools::GetFilenamePath(name);
- if ( sf->SourceName.size() > 0 )
- {
+ if (sf->SourceName.size() > 0) {
sf->SourceName += "/";
- }
+ }
sf->SourceName += cmSystemTools::GetFilenameWithoutLastExtension(name);
std::string::size_type pos = hname.rfind('.');
- if(pos != std::string::npos)
- {
- sf->SourceExtension = hname.substr(pos+1, hname.size()-pos);
- if ( cmSystemTools::FileIsFullPath(name) )
- {
+ if (pos != std::string::npos) {
+ sf->SourceExtension = hname.substr(pos + 1, hname.size() - pos);
+ if (cmSystemTools::FileIsFullPath(name)) {
std::string::size_type pos2 = hname.rfind('/');
- if(pos2 != std::string::npos)
- {
- sf->SourceName = hname.substr(pos2+1, pos - pos2-1);
- }
+ if (pos2 != std::string::npos) {
+ sf->SourceName = hname.substr(pos2 + 1, pos - pos2 - 1);
}
}
+ }
sf->FullPath = hname;
return;
- }
+ }
// Next, try the various source extensions
- for( std::vector<std::string>::const_iterator ext = sourceExts.begin();
- ext != sourceExts.end(); ++ext )
- {
+ for (std::vector<std::string>::const_iterator ext = sourceExts.begin();
+ ext != sourceExts.end(); ++ext) {
hname = pathname;
hname += ".";
hname += *ext;
- if(cmSystemTools::FileExists(hname.c_str()))
- {
+ if (cmSystemTools::FileExists(hname.c_str())) {
sf->SourceExtension = *ext;
sf->FullPath = hname;
return;
- }
}
+ }
// Finally, try the various header extensions
- for( std::vector<std::string>::const_iterator ext = headerExts.begin();
- ext != headerExts.end(); ++ext )
- {
+ for (std::vector<std::string>::const_iterator ext = headerExts.begin();
+ ext != headerExts.end(); ++ext) {
hname = pathname;
hname += ".";
hname += *ext;
- if(cmSystemTools::FileExists(hname.c_str()))
- {
+ if (cmSystemTools::FileExists(hname.c_str())) {
sf->SourceExtension = *ext;
sf->FullPath = hname;
return;
- }
}
+ }
std::ostringstream e;
e << "Cannot find source file \"" << pathname << "\"";
e << "\n\nTried extensions";
- for( std::vector<std::string>::const_iterator ext = sourceExts.begin();
- ext != sourceExts.end(); ++ext )
- {
+ for (std::vector<std::string>::const_iterator ext = sourceExts.begin();
+ ext != sourceExts.end(); ++ext) {
e << " ." << *ext;
- }
- for( std::vector<std::string>::const_iterator ext = headerExts.begin();
- ext != headerExts.end(); ++ext )
- {
+ }
+ for (std::vector<std::string>::const_iterator ext = headerExts.begin();
+ ext != headerExts.end(); ++ext) {
e << " ." << *ext;
- }
+ }
cmSystemTools::Error(e.str().c_str());
return;
}
-void CCONV cmSourceFileSetName2(void *arg, const char* name, const char* dir,
- const char *ext, int headerFileOnly)
+void CCONV cmSourceFileSetName2(void* arg, const char* name, const char* dir,
+ const char* ext, int headerFileOnly)
{
cmCPluginAPISourceFile* sf = static_cast<cmCPluginAPISourceFile*>(arg);
- if(sf->RealSourceFile)
- {
+ if (sf->RealSourceFile) {
// SetName is allowed only on temporary source files created by
// the command for building and passing to AddSource.
return;
- }
+ }
// Implement the old SetName method code here.
- if(headerFileOnly)
- {
+ if (headerFileOnly) {
sf->Properties.SetProperty("HEADER_FILE_ONLY", "1");
- }
+ }
sf->SourceName = name;
std::string fname = sf->SourceName;
- if(ext && strlen(ext))
- {
+ if (ext && strlen(ext)) {
fname += ".";
fname += ext;
- }
+ }
sf->FullPath = cmSystemTools::CollapseFullPath(fname.c_str(), dir);
cmSystemTools::ConvertToUnixSlashes(sf->FullPath);
sf->SourceExtension = ext;
}
-char * CCONV cmGetFilenameWithoutExtension(const char *name)
+char* CCONV cmGetFilenameWithoutExtension(const char* name)
{
std::string sres = cmSystemTools::GetFilenameWithoutExtension(name);
- char *result = (char *)malloc(sres.size()+1);
- strcpy(result,sres.c_str());
+ char* result = (char*)malloc(sres.size() + 1);
+ strcpy(result, sres.c_str());
return result;
}
-char * CCONV cmGetFilenamePath(const char *name)
+char* CCONV cmGetFilenamePath(const char* name)
{
std::string sres = cmSystemTools::GetFilenamePath(name);
- char *result = (char *)malloc(sres.size()+1);
- strcpy(result,sres.c_str());
+ char* result = (char*)malloc(sres.size() + 1);
+ strcpy(result, sres.c_str());
return result;
}
-char * CCONV cmCapitalized(const char *name)
+char* CCONV cmCapitalized(const char* name)
{
std::string sres = cmSystemTools::Capitalized(name);
- char *result = (char *)malloc(sres.size()+1);
- strcpy(result,sres.c_str());
+ char* result = (char*)malloc(sres.size() + 1);
+ strcpy(result, sres.c_str());
return result;
}
-void CCONV cmCopyFileIfDifferent(const char *name1, const char *name2)
+void CCONV cmCopyFileIfDifferent(const char* name1, const char* name2)
{
- cmSystemTools::CopyFileIfDifferent(name1,name2);
+ cmSystemTools::CopyFileIfDifferent(name1, name2);
}
-void CCONV cmRemoveFile(const char *name)
+void CCONV cmRemoveFile(const char* name)
{
cmSystemTools::RemoveFile(name);
}
-void CCONV cmDisplayStatus(void *arg, const char* message)
+void CCONV cmDisplayStatus(void* arg, const char* message)
{
- cmMakefile *mf = static_cast<cmMakefile *>(arg);
+ cmMakefile* mf = static_cast<cmMakefile*>(arg);
mf->DisplayStatus(message, -1);
}
-void CCONV cmFree(void *data)
+void CCONV cmFree(void* data)
{
free(data);
}
-void CCONV DefineSourceFileProperty (void *arg, const char *name,
- const char *briefDocs,
- const char *longDocs,
- int chained)
+void CCONV DefineSourceFileProperty(void* arg, const char* name,
+ const char* briefDocs,
+ const char* longDocs, int chained)
{
- cmMakefile *mf = static_cast<cmMakefile *>(arg);
- mf->GetState()->DefineProperty(name,cmProperty::SOURCE_FILE,
- briefDocs, longDocs,
- chained != 0);
+ cmMakefile* mf = static_cast<cmMakefile*>(arg);
+ mf->GetState()->DefineProperty(name, cmProperty::SOURCE_FILE, briefDocs,
+ longDocs, chained != 0);
}
} // close the extern "C" scope
-cmCAPI cmStaticCAPI =
-{
+cmCAPI cmStaticCAPI = {
cmGetClientData,
cmGetTotalArgumentSize,
cmFreeArguments,
@@ -929,4 +850,3 @@ cmCAPI cmStaticCAPI =
cmCreateNewSourceFile,
DefineSourceFileProperty,
};
-
diff --git a/Source/cmCPluginAPI.h b/Source/cmCPluginAPI.h
index 5c832c3..4d9a9a7 100644
--- a/Source/cmCPluginAPI.h
+++ b/Source/cmCPluginAPI.h
@@ -23,7 +23,7 @@
#define CMAKE_VERSION_MAJOR 2
#define CMAKE_VERSION_MINOR 5
-#ifdef __cplusplus
+#ifdef __cplusplus
extern "C" {
#endif
@@ -46,141 +46,131 @@ typedef struct
/* set/Get the ClientData in the cmLoadedCommandInfo structure, this is how
information is passed from the InitialPass to FInalPass for commands
that need a FinalPass and need information from the InitialPass */
- void *(CCONV *GetClientData) (void *info);
+ void*(CCONV* GetClientData)(void* info);
/* return the summed size in characters of all the arguments */
- int (CCONV *GetTotalArgumentSize) (int argc, char **argv);
+ int(CCONV* GetTotalArgumentSize)(int argc, char** argv);
/* free all the memory associated with an argc, argv pair */
- void (CCONV *FreeArguments) (int argc, char **argv);
+ void(CCONV* FreeArguments)(int argc, char** argv);
/* set/Get the ClientData in the cmLoadedCommandInfo structure, this is how
information is passed from the InitialPass to FInalPass for commands
that need a FinalPass and need information from the InitialPass */
- void (CCONV *SetClientData) (void *info, void *cd);
+ void(CCONV* SetClientData)(void* info, void* cd);
/* when an error occurs, call this function to set the error string */
- void (CCONV *SetError) (void *info, const char *err);
+ void(CCONV* SetError)(void* info, const char* err);
/*=========================================================================
The following functions all directly map to methods in the cmMakefile
class. See cmMakefile.h for descriptions of what each method does. All of
these methods take the void * makefile pointer as their first argument.
=========================================================================*/
- void (CCONV *AddCacheDefinition) (void *mf, const char* name,
- const char* value,
- const char* doc, int cachetype);
- void (CCONV *AddCustomCommand) (void *mf, const char* source,
- const char* command,
- int numArgs, const char **args,
- int numDepends, const char **depends,
- int numOutputs, const char **outputs,
- const char *target);
- void (CCONV *AddDefineFlag) (void *mf, const char* definition);
- void (CCONV *AddDefinition) (void *mf, const char* name,
- const char* value);
- void (CCONV *AddExecutable) (void *mf, const char *exename,
- int numSrcs, const char **srcs, int win32);
- void (CCONV *AddLibrary) (void *mf, const char *libname,
- int shared, int numSrcs, const char **srcs);
- void (CCONV *AddLinkDirectoryForTarget) (void *mf, const char *tgt,
- const char* d);
- void (CCONV *AddLinkLibraryForTarget) (void *mf, const char *tgt,
- const char *libname, int libtype);
- void (CCONV *AddUtilityCommand) (void *mf, const char* utilityName,
- const char *command, const char *arguments,
- int all, int numDepends, const char **depends,
- int numOutputs, const char **outputs);
- int (CCONV *CommandExists) (void *mf, const char* name);
- int (CCONV *ExecuteCommand) (void *mf, const char *name,
- int numArgs, const char **args);
- void (CCONV *ExpandSourceListArguments) (void *mf,int argc,
- const char **argv,
- int *resArgc, char ***resArgv,
- unsigned int startArgumentIndex);
- char *(CCONV *ExpandVariablesInString) (void *mf, const char *source,
- int escapeQuotes, int atOnly);
- unsigned int (CCONV *GetCacheMajorVersion) (void *mf);
- unsigned int (CCONV *GetCacheMinorVersion) (void *mf);
- const char* (CCONV *GetCurrentDirectory) (void *mf);
- const char* (CCONV *GetCurrentOutputDirectory) (void *mf);
- const char* (CCONV *GetDefinition) (void *mf, const char *def);
- const char* (CCONV *GetHomeDirectory) (void *mf);
- const char* (CCONV *GetHomeOutputDirectory) (void *mf);
- unsigned int (CCONV *GetMajorVersion) (void *mf);
- unsigned int (CCONV *GetMinorVersion) (void *mf);
- const char* (CCONV *GetProjectName) (void *mf);
- const char* (CCONV *GetStartDirectory) (void *mf);
- const char* (CCONV *GetStartOutputDirectory) (void *mf);
- int (CCONV *IsOn) (void *mf, const char* name);
-
+ void(CCONV* AddCacheDefinition)(void* mf, const char* name,
+ const char* value, const char* doc,
+ int cachetype);
+ void(CCONV* AddCustomCommand)(void* mf, const char* source,
+ const char* command, int numArgs,
+ const char** args, int numDepends,
+ const char** depends, int numOutputs,
+ const char** outputs, const char* target);
+ void(CCONV* AddDefineFlag)(void* mf, const char* definition);
+ void(CCONV* AddDefinition)(void* mf, const char* name, const char* value);
+ void(CCONV* AddExecutable)(void* mf, const char* exename, int numSrcs,
+ const char** srcs, int win32);
+ void(CCONV* AddLibrary)(void* mf, const char* libname, int shared,
+ int numSrcs, const char** srcs);
+ void(CCONV* AddLinkDirectoryForTarget)(void* mf, const char* tgt,
+ const char* d);
+ void(CCONV* AddLinkLibraryForTarget)(void* mf, const char* tgt,
+ const char* libname, int libtype);
+ void(CCONV* AddUtilityCommand)(void* mf, const char* utilityName,
+ const char* command, const char* arguments,
+ int all, int numDepends, const char** depends,
+ int numOutputs, const char** outputs);
+ int(CCONV* CommandExists)(void* mf, const char* name);
+ int(CCONV* ExecuteCommand)(void* mf, const char* name, int numArgs,
+ const char** args);
+ void(CCONV* ExpandSourceListArguments)(void* mf, int argc, const char** argv,
+ int* resArgc, char*** resArgv,
+ unsigned int startArgumentIndex);
+ char*(CCONV* ExpandVariablesInString)(void* mf, const char* source,
+ int escapeQuotes, int atOnly);
+ unsigned int(CCONV* GetCacheMajorVersion)(void* mf);
+ unsigned int(CCONV* GetCacheMinorVersion)(void* mf);
+ const char*(CCONV* GetCurrentDirectory)(void* mf);
+ const char*(CCONV* GetCurrentOutputDirectory)(void* mf);
+ const char*(CCONV* GetDefinition)(void* mf, const char* def);
+ const char*(CCONV* GetHomeDirectory)(void* mf);
+ const char*(CCONV* GetHomeOutputDirectory)(void* mf);
+ unsigned int(CCONV* GetMajorVersion)(void* mf);
+ unsigned int(CCONV* GetMinorVersion)(void* mf);
+ const char*(CCONV* GetProjectName)(void* mf);
+ const char*(CCONV* GetStartDirectory)(void* mf);
+ const char*(CCONV* GetStartOutputDirectory)(void* mf);
+ int(CCONV* IsOn)(void* mf, const char* name);
/*=========================================================================
The following functions are designed to operate or manipulate
cmSourceFiles. Please see cmSourceFile.h for additional information on many
of these methods. Some of these methods are in cmMakefile.h.
=========================================================================*/
- void *(CCONV *AddSource) (void *mf, void *sf);
- void *(CCONV *CreateSourceFile) ();
- void (CCONV *DestroySourceFile) (void *sf);
- void *(CCONV *GetSource) (void *mf, const char* sourceName);
- void (CCONV *SourceFileAddDepend) (void *sf, const char *depend);
- const char *(CCONV *SourceFileGetProperty) (void *sf, const char *prop);
- int (CCONV *SourceFileGetPropertyAsBool) (void *sf, const char *prop);
- const char *(CCONV *SourceFileGetSourceName) (void *sf);
- const char *(CCONV *SourceFileGetFullPath) (void *sf);
- void (CCONV *SourceFileSetName) (void *sf, const char* name,
- const char* dir,
- int numSourceExtensions,
- const char **sourceExtensions,
- int numHeaderExtensions,
- const char **headerExtensions);
- void (CCONV *SourceFileSetName2) (void *sf, const char* name,
- const char* dir,
- const char *ext, int headerFileOnly);
- void (CCONV *SourceFileSetProperty) (void *sf, const char *prop,
- const char *value);
-
+ void*(CCONV* AddSource)(void* mf, void* sf);
+ void*(CCONV* CreateSourceFile)();
+ void(CCONV* DestroySourceFile)(void* sf);
+ void*(CCONV* GetSource)(void* mf, const char* sourceName);
+ void(CCONV* SourceFileAddDepend)(void* sf, const char* depend);
+ const char*(CCONV* SourceFileGetProperty)(void* sf, const char* prop);
+ int(CCONV* SourceFileGetPropertyAsBool)(void* sf, const char* prop);
+ const char*(CCONV* SourceFileGetSourceName)(void* sf);
+ const char*(CCONV* SourceFileGetFullPath)(void* sf);
+ void(CCONV* SourceFileSetName)(void* sf, const char* name, const char* dir,
+ int numSourceExtensions,
+ const char** sourceExtensions,
+ int numHeaderExtensions,
+ const char** headerExtensions);
+ void(CCONV* SourceFileSetName2)(void* sf, const char* name, const char* dir,
+ const char* ext, int headerFileOnly);
+ void(CCONV* SourceFileSetProperty)(void* sf, const char* prop,
+ const char* value);
/*=========================================================================
The following methods are from cmSystemTools.h see that file for specific
documentation on each method.
=========================================================================*/
- char *(CCONV *Capitalized)(const char *);
- void (CCONV *CopyFileIfDifferent)(const char *f1, const char *f2);
- char *(CCONV *GetFilenameWithoutExtension)(const char *);
- char *(CCONV *GetFilenamePath)(const char *);
- void (CCONV *RemoveFile)(const char *f1);
- void (CCONV *Free)(void *);
+ char*(CCONV* Capitalized)(const char*);
+ void(CCONV* CopyFileIfDifferent)(const char* f1, const char* f2);
+ char*(CCONV* GetFilenameWithoutExtension)(const char*);
+ char*(CCONV* GetFilenamePath)(const char*);
+ void(CCONV* RemoveFile)(const char* f1);
+ void(CCONV* Free)(void*);
/*=========================================================================
The following are new functions added after 1.6
=========================================================================*/
- void (CCONV *AddCustomCommandToOutput) (void *mf, const char* output,
- const char* command,
- int numArgs, const char **args,
- const char* main_dependency,
- int numDepends, const char **depends);
- void (CCONV *AddCustomCommandToTarget) (void *mf, const char* target,
- const char* command,
- int numArgs, const char **args,
- int commandType);
+ void(CCONV* AddCustomCommandToOutput)(void* mf, const char* output,
+ const char* command, int numArgs,
+ const char** args,
+ const char* main_dependency,
+ int numDepends, const char** depends);
+ void(CCONV* AddCustomCommandToTarget)(void* mf, const char* target,
+ const char* command, int numArgs,
+ const char** args, int commandType);
/* display status information */
- void (CCONV *DisplaySatus) (void *info, const char *message);
+ void(CCONV* DisplaySatus)(void* info, const char* message);
/* new functions added after 2.4 */
- void *(CCONV *CreateNewSourceFile) (void *mf);
- void (CCONV *DefineSourceFileProperty) (void *mf, const char *name,
- const char *briefDocs,
- const char *longDocs,
- int chained);
+ void*(CCONV* CreateNewSourceFile)(void* mf);
+ void(CCONV* DefineSourceFileProperty)(void* mf, const char* name,
+ const char* briefDocs,
+ const char* longDocs, int chained);
/* this is the end of the C function stub API structure */
} cmCAPI;
-
/*=========================================================================
CM_PLUGIN_EXPORT should be used by plugins
=========================================================================*/
#ifdef _WIN32
-#define CM_PLUGIN_EXPORT __declspec( dllexport )
+#define CM_PLUGIN_EXPORT __declspec(dllexport)
#else
#define CM_PLUGIN_EXPORT
#endif
@@ -206,37 +196,38 @@ define the different types of compiles a library may be
/*=========================================================================
define the different types of custom commands for a target
=========================================================================*/
-#define CM_PRE_BUILD 0
-#define CM_PRE_LINK 1
+#define CM_PRE_BUILD 0
+#define CM_PRE_LINK 1
#define CM_POST_BUILD 2
/*=========================================================================
Finally we define the key data structures and function prototypes
=========================================================================*/
- typedef const char* (CCONV *CM_DOC_FUNCTION)();
- typedef int (CCONV *CM_INITIAL_PASS_FUNCTION)(void *info, void *mf,
- int argc, char *[]);
- typedef void (CCONV *CM_FINAL_PASS_FUNCTION)(void *info, void *mf);
- typedef void (CCONV *CM_DESTRUCTOR_FUNCTION)(void *info);
-
- typedef struct {
- unsigned long reserved1; /* Reserved for future use. DO NOT USE. */
- unsigned long reserved2; /* Reserved for future use. DO NOT USE. */
- cmCAPI *CAPI;
- int m_Inherited; /* this ivar is no longer used in CMake 2.2 or later */
- CM_INITIAL_PASS_FUNCTION InitialPass;
- CM_FINAL_PASS_FUNCTION FinalPass;
- CM_DESTRUCTOR_FUNCTION Destructor;
- CM_DOC_FUNCTION GetTerseDocumentation;
- CM_DOC_FUNCTION GetFullDocumentation;
- const char *Name;
- char *Error;
- void *ClientData;
- } cmLoadedCommandInfo;
-
- typedef void (CCONV *CM_INIT_FUNCTION)(cmLoadedCommandInfo *);
-
-#ifdef __cplusplus
+typedef const char*(CCONV* CM_DOC_FUNCTION)();
+typedef int(CCONV* CM_INITIAL_PASS_FUNCTION)(void* info, void* mf, int argc,
+ char* []);
+typedef void(CCONV* CM_FINAL_PASS_FUNCTION)(void* info, void* mf);
+typedef void(CCONV* CM_DESTRUCTOR_FUNCTION)(void* info);
+
+typedef struct
+{
+ unsigned long reserved1; /* Reserved for future use. DO NOT USE. */
+ unsigned long reserved2; /* Reserved for future use. DO NOT USE. */
+ cmCAPI* CAPI;
+ int m_Inherited; /* this ivar is no longer used in CMake 2.2 or later */
+ CM_INITIAL_PASS_FUNCTION InitialPass;
+ CM_FINAL_PASS_FUNCTION FinalPass;
+ CM_DESTRUCTOR_FUNCTION Destructor;
+ CM_DOC_FUNCTION GetTerseDocumentation;
+ CM_DOC_FUNCTION GetFullDocumentation;
+ const char* Name;
+ char* Error;
+ void* ClientData;
+} cmLoadedCommandInfo;
+
+typedef void(CCONV* CM_INIT_FUNCTION)(cmLoadedCommandInfo*);
+
+#ifdef __cplusplus
}
#endif
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index a189430..7e5d966 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -57,15 +57,17 @@
#include <cmsys/Base64.h>
#if defined(__BEOS__) || defined(__HAIKU__)
-#include <be/kernel/OS.h> /* disable_debugger() API. */
+#include <be/kernel/OS.h> /* disable_debugger() API. */
#endif
+#define DEBUGOUT \
+ std::cout << __LINE__ << " "; \
+ std::cout
+#define DEBUGERR \
+ std::cerr << __LINE__ << " "; \
+ std::cerr
-#define DEBUGOUT std::cout << __LINE__ << " "; std::cout
-#define DEBUGERR std::cerr << __LINE__ << " "; std::cerr
-
-struct tm* cmCTest::GetNightlyTime(std::string str,
- bool tomorrowtag)
+struct tm* cmCTest::GetNightlyTime(std::string str, bool tomorrowtag)
{
struct tm* lctime;
time_t tctime = time(0);
@@ -73,19 +75,17 @@ struct tm* cmCTest::GetNightlyTime(std::string str,
char buf[1024];
// add todays year day and month to the time in str because
// curl_getdate no longer assumes the day is today
- sprintf(buf, "%d%02d%02d %s",
- lctime->tm_year+1900,
- lctime->tm_mon +1,
- lctime->tm_mday,
- str.c_str());
- cmCTestLog(this, OUTPUT, "Determine Nightly Start Time" << std::endl
- << " Specified time: " << str << std::endl);
- //Convert the nightly start time to seconds. Since we are
- //providing only a time and a timezone, the current date of
- //the local machine is assumed. Consequently, nightlySeconds
- //is the time at which the nightly dashboard was opened or
- //will be opened on the date of the current client machine.
- //As such, this time may be in the past or in the future.
+ sprintf(buf, "%d%02d%02d %s", lctime->tm_year + 1900, lctime->tm_mon + 1,
+ lctime->tm_mday, str.c_str());
+ cmCTestLog(this, OUTPUT, "Determine Nightly Start Time"
+ << std::endl
+ << " Specified time: " << str << std::endl);
+ // Convert the nightly start time to seconds. Since we are
+ // providing only a time and a timezone, the current date of
+ // the local machine is assumed. Consequently, nightlySeconds
+ // is the time at which the nightly dashboard was opened or
+ // will be opened on the date of the current client machine.
+ // As such, this time may be in the past or in the future.
time_t ntime = curl_getdate(buf, &tctime);
cmCTestLog(this, DEBUG, " Get curl time: " << ntime << std::endl);
tctime = time(0);
@@ -93,8 +93,7 @@ struct tm* cmCTest::GetNightlyTime(std::string str,
const int dayLength = 24 * 60 * 60;
cmCTestLog(this, DEBUG, "Seconds: " << tctime << std::endl);
- while ( ntime > tctime )
- {
+ while (ntime > tctime) {
// If nightlySeconds is in the past, this is the current
// open dashboard, then return nightlySeconds. If
// nightlySeconds is in the future, this is the next
@@ -103,21 +102,19 @@ struct tm* cmCTest::GetNightlyTime(std::string str,
ntime -= dayLength;
cmCTestLog(this, DEBUG, "Pick yesterday" << std::endl);
cmCTestLog(this, DEBUG, " Future time, subtract day: " << ntime
- << std::endl);
- }
- while ( tctime > (ntime + dayLength) )
- {
+ << std::endl);
+ }
+ while (tctime > (ntime + dayLength)) {
ntime += dayLength;
cmCTestLog(this, DEBUG, " Past time, add day: " << ntime << std::endl);
- }
+ }
cmCTestLog(this, DEBUG, "nightlySeconds: " << ntime << std::endl);
- cmCTestLog(this, DEBUG, " Current time: " << tctime
- << " Nightly time: " << ntime << std::endl);
- if ( tomorrowtag )
- {
+ cmCTestLog(this, DEBUG, " Current time: " << tctime << " Nightly time: "
+ << ntime << std::endl);
+ if (tomorrowtag) {
cmCTestLog(this, OUTPUT, " Use future tag, Add a day" << std::endl);
ntime += dayLength;
- }
+ }
lctime = gmtime(&ntime);
return lctime;
}
@@ -126,14 +123,12 @@ std::string cmCTest::CleanString(const std::string& str)
{
std::string::size_type spos = str.find_first_not_of(" \n\t\r\f\v");
std::string::size_type epos = str.find_last_not_of(" \n\t\r\f\v");
- if ( spos == str.npos )
- {
+ if (spos == str.npos) {
return std::string();
- }
- if ( epos != str.npos )
- {
+ }
+ if (epos != str.npos) {
epos = epos - spos + 1;
- }
+ }
return str.substr(spos, epos);
}
@@ -141,16 +136,13 @@ std::string cmCTest::CurrentTime()
{
time_t currenttime = time(0);
struct tm* t = localtime(&currenttime);
- //return ::CleanString(ctime(&currenttime));
+ // return ::CleanString(ctime(&currenttime));
char current_time[1024];
- if ( this->ShortDateFormat )
- {
+ if (this->ShortDateFormat) {
strftime(current_time, 1000, "%b %d %H:%M %Z", t);
- }
- else
- {
+ } else {
strftime(current_time, 1000, "%a %b %d %H:%M:%S %Z %Y", t);
- }
+ }
cmCTestLog(this, DEBUG, " Current_Time: " << current_time << std::endl);
return cmCTest::CleanString(current_time);
}
@@ -158,21 +150,19 @@ std::string cmCTest::CurrentTime()
std::string cmCTest::GetCostDataFile()
{
std::string fname = this->GetCTestConfiguration("CostDataFile");
- if(fname == "")
- {
- fname= this->GetBinaryDir() + "/Testing/Temporary/CTestCostData.txt";
- }
+ if (fname == "") {
+ fname = this->GetBinaryDir() + "/Testing/Temporary/CTestCostData.txt";
+ }
return fname;
}
#ifdef CMAKE_BUILD_WITH_CMAKE
-static size_t
-HTTPResponseCallback(void *ptr, size_t size, size_t nmemb, void *data)
+static size_t HTTPResponseCallback(void* ptr, size_t size, size_t nmemb,
+ void* data)
{
int realsize = (int)(size * nmemb);
- std::string *response
- = static_cast<std::string*>(data);
+ std::string* response = static_cast<std::string*>(data);
const char* chPtr = static_cast<char*>(ptr);
*response += chPtr;
@@ -180,9 +170,8 @@ HTTPResponseCallback(void *ptr, size_t size, size_t nmemb, void *data)
}
int cmCTest::HTTPRequest(std::string url, HTTPMethod method,
- std::string& response,
- std::string fields,
- std::string putFile, int timeout)
+ std::string& response, std::string fields,
+ std::string putFile, int timeout)
{
CURL* curl;
FILE* file;
@@ -190,39 +179,36 @@ int cmCTest::HTTPRequest(std::string url, HTTPMethod method,
curl = ::curl_easy_init();
cmCurlSetCAInfo(curl);
- //set request options based on method
- switch(method)
- {
+ // set request options based on method
+ switch (method) {
case cmCTest::HTTP_POST:
::curl_easy_setopt(curl, CURLOPT_POST, 1);
::curl_easy_setopt(curl, CURLOPT_POSTFIELDS, fields.c_str());
break;
case cmCTest::HTTP_PUT:
- if(!cmSystemTools::FileExists(putFile.c_str()))
- {
+ if (!cmSystemTools::FileExists(putFile.c_str())) {
response = "Error: File ";
response += putFile + " does not exist.\n";
return -1;
- }
+ }
::curl_easy_setopt(curl, CURLOPT_PUT, 1);
file = cmsys::SystemTools::Fopen(putFile, "rb");
::curl_easy_setopt(curl, CURLOPT_INFILE, file);
- //fall through to append GET fields
+ // fall through to append GET fields
case cmCTest::HTTP_GET:
- if(!fields.empty())
- {
+ if (!fields.empty()) {
url += "?" + fields;
- }
+ }
break;
- }
+ }
::curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
::curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout);
::curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
- //set response options
+ // set response options
::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, HTTPResponseCallback);
- ::curl_easy_setopt(curl, CURLOPT_FILE, (void *)&response);
+ ::curl_easy_setopt(curl, CURLOPT_FILE, (void*)&response);
::curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
CURLcode res = ::curl_easy_perform(curl);
@@ -238,96 +224,84 @@ std::string cmCTest::MakeURLSafe(const std::string& str)
{
std::ostringstream ost;
char buffer[10];
- for ( std::string::size_type pos = 0; pos < str.size(); pos ++ )
- {
+ for (std::string::size_type pos = 0; pos < str.size(); pos++) {
unsigned char ch = str[pos];
- if ( ( ch > 126 || ch < 32 ||
- ch == '&' ||
- ch == '%' ||
- ch == '+' ||
- ch == '=' ||
- ch == '@'
- ) && ch != 9 )
- {
+ if ((ch > 126 || ch < 32 || ch == '&' || ch == '%' || ch == '+' ||
+ ch == '=' || ch == '@') &&
+ ch != 9) {
sprintf(buffer, "%02x;", (unsigned int)ch);
ost << buffer;
- }
- else
- {
+ } else {
ost << ch;
- }
}
+ }
return ost.str();
}
std::string cmCTest::DecodeURL(const std::string& in)
{
std::string out;
- for(const char* c = in.c_str(); *c; ++c)
- {
- if(*c == '%' && isxdigit(*(c+1)) && isxdigit(*(c+2)))
- {
- char buf[3] = {*(c+1), *(c+2), 0};
+ for (const char* c = in.c_str(); *c; ++c) {
+ if (*c == '%' && isxdigit(*(c + 1)) && isxdigit(*(c + 2))) {
+ char buf[3] = { *(c + 1), *(c + 2), 0 };
out.append(1, char(strtoul(buf, 0, 16)));
c += 2;
- }
- else
- {
+ } else {
out.append(1, *c);
- }
}
+ }
return out;
}
cmCTest::cmCTest()
{
- this->LabelSummary = true;
- this->ParallelLevel = 1;
- this->ParallelLevelSetInCli = false;
- this->TestLoad = 0;
- this->SubmitIndex = 0;
- this->Failover = false;
- this->BatchJobs = false;
- this->ForceNewCTestProcess = false;
- this->TomorrowTag = false;
- this->Verbose = false;
-
- this->Debug = false;
- this->ShowLineNumbers = false;
- this->Quiet = false;
- this->ExtraVerbose = false;
- this->ProduceXML = false;
- this->ShowOnly = false;
+ this->LabelSummary = true;
+ this->ParallelLevel = 1;
+ this->ParallelLevelSetInCli = false;
+ this->TestLoad = 0;
+ this->SubmitIndex = 0;
+ this->Failover = false;
+ this->BatchJobs = false;
+ this->ForceNewCTestProcess = false;
+ this->TomorrowTag = false;
+ this->Verbose = false;
+
+ this->Debug = false;
+ this->ShowLineNumbers = false;
+ this->Quiet = false;
+ this->ExtraVerbose = false;
+ this->ProduceXML = false;
+ this->ShowOnly = false;
this->RunConfigurationScript = false;
- this->UseHTTP10 = false;
- this->PrintLabels = false;
- this->CompressTestOutput = true;
+ this->UseHTTP10 = false;
+ this->PrintLabels = false;
+ this->CompressTestOutput = true;
this->CompressMemCheckOutput = true;
- this->TestModel = cmCTest::EXPERIMENTAL;
- this->MaxTestNameWidth = 30;
- this->InteractiveDebugMode = true;
- this->TimeOut = 0;
- this->GlobalTimeout = 0;
- this->LastStopTimeout = 24 * 60 * 60;
- this->CompressXMLFiles = false;
- this->CTestConfigFile = "";
- this->ScheduleType = "";
- this->StopTime = "";
- this->NextDayStopTime = false;
- this->OutputLogFile = 0;
- this->OutputLogFileLastTag = -1;
+ this->TestModel = cmCTest::EXPERIMENTAL;
+ this->MaxTestNameWidth = 30;
+ this->InteractiveDebugMode = true;
+ this->TimeOut = 0;
+ this->GlobalTimeout = 0;
+ this->LastStopTimeout = 24 * 60 * 60;
+ this->CompressXMLFiles = false;
+ this->CTestConfigFile = "";
+ this->ScheduleType = "";
+ this->StopTime = "";
+ this->NextDayStopTime = false;
+ this->OutputLogFile = 0;
+ this->OutputLogFileLastTag = -1;
this->SuppressUpdatingCTestConfiguration = false;
- this->DartVersion = 1;
- this->DropSiteCDash = false;
+ this->DartVersion = 1;
+ this->DropSiteCDash = false;
this->OutputTestOutputOnTestFailure = false;
this->ComputedCompressTestOutput = false;
this->ComputedCompressMemCheckOutput = false;
this->RepeatTests = 1; // default to run each test once
this->RepeatUntilFail = false;
- if(const char* outOnFail = cmSystemTools::GetEnv("CTEST_OUTPUT_ON_FAILURE"))
- {
+ if (const char* outOnFail =
+ cmSystemTools::GetEnv("CTEST_OUTPUT_ON_FAILURE")) {
this->OutputTestOutputOnTestFailure = !cmSystemTools::IsOff(outOnFail);
- }
+ }
this->InitStreams();
this->Parts[PartStart].SetName("Start");
@@ -343,30 +317,28 @@ cmCTest::cmCTest()
this->Parts[PartUpload].SetName("Upload");
// Fill the part name-to-id map.
- for(Part p = PartStart; p != PartCount; p = Part(p+1))
- {
+ for (Part p = PartStart; p != PartCount; p = Part(p + 1)) {
this->PartMap[cmSystemTools::LowerCase(this->Parts[p].GetName())] = p;
- }
+ }
- this->ShortDateFormat = true;
+ this->ShortDateFormat = true;
- this->TestingHandlers["build"] = new cmCTestBuildHandler;
+ this->TestingHandlers["build"] = new cmCTestBuildHandler;
this->TestingHandlers["buildtest"] = new cmCTestBuildAndTestHandler;
- this->TestingHandlers["coverage"] = new cmCTestCoverageHandler;
- this->TestingHandlers["script"] = new cmCTestScriptHandler;
- this->TestingHandlers["test"] = new cmCTestTestHandler;
- this->TestingHandlers["update"] = new cmCTestUpdateHandler;
+ this->TestingHandlers["coverage"] = new cmCTestCoverageHandler;
+ this->TestingHandlers["script"] = new cmCTestScriptHandler;
+ this->TestingHandlers["test"] = new cmCTestTestHandler;
+ this->TestingHandlers["update"] = new cmCTestUpdateHandler;
this->TestingHandlers["configure"] = new cmCTestConfigureHandler;
- this->TestingHandlers["memcheck"] = new cmCTestMemCheckHandler;
- this->TestingHandlers["submit"] = new cmCTestSubmitHandler;
- this->TestingHandlers["upload"] = new cmCTestUploadHandler;
+ this->TestingHandlers["memcheck"] = new cmCTestMemCheckHandler;
+ this->TestingHandlers["submit"] = new cmCTestSubmitHandler;
+ this->TestingHandlers["upload"] = new cmCTestUploadHandler;
cmCTest::t_TestingHandlers::iterator it;
- for ( it = this->TestingHandlers.begin();
- it != this->TestingHandlers.end(); ++ it )
- {
+ for (it = this->TestingHandlers.begin(); it != this->TestingHandlers.end();
+ ++it) {
it->second->SetCTestInstance(this);
- }
+ }
// Make sure we can capture the build tool output.
cmSystemTools::EnableVSConsoleOutput();
@@ -390,38 +362,37 @@ void cmCTest::SetTestLoad(unsigned long load)
bool cmCTest::ShouldCompressTestOutput()
{
- if(!this->ComputedCompressTestOutput)
- {
+ if (!this->ComputedCompressTestOutput) {
std::string cdashVersion = this->GetCDashVersion();
- //version >= 1.6?
- bool cdashSupportsGzip = cmSystemTools::VersionCompare(
- cmSystemTools::OP_GREATER, cdashVersion.c_str(), "1.6") ||
+ // version >= 1.6?
+ bool cdashSupportsGzip =
+ cmSystemTools::VersionCompare(cmSystemTools::OP_GREATER,
+ cdashVersion.c_str(), "1.6") ||
cmSystemTools::VersionCompare(cmSystemTools::OP_EQUAL,
- cdashVersion.c_str(), "1.6");
+ cdashVersion.c_str(), "1.6");
this->CompressTestOutput &= cdashSupportsGzip;
this->ComputedCompressTestOutput = true;
- }
+ }
return this->CompressTestOutput;
}
bool cmCTest::ShouldCompressMemCheckOutput()
{
- if(!this->ComputedCompressMemCheckOutput)
- {
+ if (!this->ComputedCompressMemCheckOutput) {
std::string cdashVersion = this->GetCDashVersion();
bool compressionSupported = cmSystemTools::VersionCompare(
cmSystemTools::OP_GREATER, cdashVersion.c_str(), "1.9.0");
this->CompressMemCheckOutput &= compressionSupported;
this->ComputedCompressMemCheckOutput = true;
- }
+ }
return this->CompressMemCheckOutput;
}
std::string cmCTest::GetCDashVersion()
{
#ifdef CMAKE_BUILD_WITH_CMAKE
- //First query the server. If that fails, fall back to the local setting
+ // First query the server. If that fails, fall back to the local setting
std::string response;
std::string url = "http://";
url += this->GetCTestConfiguration("DropSite");
@@ -430,8 +401,7 @@ std::string cmCTest::GetCDashVersion()
cdashUri = cdashUri.substr(0, cdashUri.find("/submit.php"));
int res = 1;
- if ( ! cdashUri.empty() )
- {
+ if (!cdashUri.empty()) {
url += cdashUri + "/api/getversion.php";
res = cmCTest::HTTPRequest(url, cmCTest::HTTP_GET, response, "", "", 3);
}
@@ -447,10 +417,9 @@ cmCTest::Part cmCTest::GetPartFromName(const char* name)
// Look up by lower-case to make names case-insensitive.
std::string lower_name = cmSystemTools::LowerCase(name);
PartMapType::const_iterator i = this->PartMap.find(lower_name);
- if(i != this->PartMap.end())
- {
+ if (i != this->PartMap.end()) {
return i->second;
- }
+ }
// The string does not name a valid part.
return PartCount;
@@ -459,20 +428,16 @@ cmCTest::Part cmCTest::GetPartFromName(const char* name)
int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command)
{
bool quiet = false;
- if (command && command->ShouldBeQuiet())
- {
+ if (command && command->ShouldBeQuiet()) {
quiet = true;
- }
+ }
cmCTestOptionalLog(this, DEBUG, "Here: " << __LINE__ << std::endl, quiet);
- if(!this->InteractiveDebugMode)
- {
+ if (!this->InteractiveDebugMode) {
this->BlockTestErrorDiagnostics();
- }
- else
- {
+ } else {
cmSystemTools::PutEnv("CTEST_INTERACTIVE_DEBUG_MODE=1");
- }
+ }
this->BinaryDir = binary_dir;
cmSystemTools::ConvertToUnixSlashes(this->BinaryDir);
@@ -480,25 +445,29 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command)
this->UpdateCTestConfiguration();
cmCTestOptionalLog(this, DEBUG, "Here: " << __LINE__ << std::endl, quiet);
- if ( this->ProduceXML )
- {
+ if (this->ProduceXML) {
cmCTestOptionalLog(this, DEBUG, "Here: " << __LINE__ << std::endl, quiet);
- cmCTestOptionalLog(this, OUTPUT,
- " Site: " << this->GetCTestConfiguration("Site") << std::endl <<
- " Build name: " << cmCTest::SafeBuildIdField(
- this->GetCTestConfiguration("BuildName")) << std::endl, quiet);
+ cmCTestOptionalLog(
+ this, OUTPUT, " Site: "
+ << this->GetCTestConfiguration("Site") << std::endl
+ << " Build name: "
+ << cmCTest::SafeBuildIdField(this->GetCTestConfiguration("BuildName"))
+ << std::endl,
+ quiet);
cmCTestOptionalLog(this, DEBUG, "Produce XML is on" << std::endl, quiet);
- if ( this->TestModel == cmCTest::NIGHTLY &&
- this->GetCTestConfiguration("NightlyStartTime").empty() )
- {
- cmCTestOptionalLog(this, WARNING,
+ if (this->TestModel == cmCTest::NIGHTLY &&
+ this->GetCTestConfiguration("NightlyStartTime").empty()) {
+ cmCTestOptionalLog(
+ this, WARNING,
"WARNING: No nightly start time found please set in CTestConfig.cmake"
- " or DartConfig.cmake" << std::endl, quiet);
- cmCTestOptionalLog(this, DEBUG, "Here: " << __LINE__ << std::endl,
+ " or DartConfig.cmake"
+ << std::endl,
quiet);
+ cmCTestOptionalLog(this, DEBUG, "Here: " << __LINE__ << std::endl,
+ quiet);
return 0;
- }
}
+ }
cmake cm;
cm.SetHomeDirectory("");
@@ -506,154 +475,133 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command)
cm.GetCurrentSnapshot().SetDefaultDefinitions();
cmGlobalGenerator gg(&cm);
cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(&gg, cm.GetCurrentSnapshot()));
- if ( !this->ReadCustomConfigurationFileTree(this->BinaryDir.c_str(),
- mf.get()) )
- {
- cmCTestOptionalLog(this, DEBUG,
- "Cannot find custom configuration file tree" << std::endl, quiet);
+ if (!this->ReadCustomConfigurationFileTree(this->BinaryDir.c_str(),
+ mf.get())) {
+ cmCTestOptionalLog(
+ this, DEBUG, "Cannot find custom configuration file tree" << std::endl,
+ quiet);
return 0;
- }
+ }
- if ( this->ProduceXML )
- {
+ if (this->ProduceXML) {
// Verify "Testing" directory exists:
//
std::string testingDir = this->BinaryDir + "/Testing";
- if ( cmSystemTools::FileExists(testingDir.c_str()) )
- {
- if ( !cmSystemTools::FileIsDirectory(testingDir) )
- {
- cmCTestLog(this, ERROR_MESSAGE, "File " << testingDir
- << " is in the place of the testing directory" << std::endl);
+ if (cmSystemTools::FileExists(testingDir.c_str())) {
+ if (!cmSystemTools::FileIsDirectory(testingDir)) {
+ cmCTestLog(this, ERROR_MESSAGE, "File "
+ << testingDir
+ << " is in the place of the testing directory"
+ << std::endl);
return 0;
- }
}
- else
- {
- if ( !cmSystemTools::MakeDirectory(testingDir.c_str()) )
- {
+ } else {
+ if (!cmSystemTools::MakeDirectory(testingDir.c_str())) {
cmCTestLog(this, ERROR_MESSAGE, "Cannot create directory "
- << testingDir << std::endl);
+ << testingDir << std::endl);
return 0;
- }
}
+ }
// Create new "TAG" file or read existing one:
//
bool createNewTag = true;
- if (command)
- {
+ if (command) {
createNewTag = command->ShouldCreateNewTag();
- }
+ }
std::string tagfile = testingDir + "/TAG";
cmsys::ifstream tfin(tagfile.c_str());
std::string tag;
- if (createNewTag)
- {
+ if (createNewTag) {
time_t tctime = time(0);
- if ( this->TomorrowTag )
- {
- tctime += ( 24 * 60 * 60 );
- }
- struct tm *lctime = gmtime(&tctime);
- if ( tfin && cmSystemTools::GetLineFromStream(tfin, tag) )
- {
+ if (this->TomorrowTag) {
+ tctime += (24 * 60 * 60);
+ }
+ struct tm* lctime = gmtime(&tctime);
+ if (tfin && cmSystemTools::GetLineFromStream(tfin, tag)) {
int year = 0;
int mon = 0;
int day = 0;
int hour = 0;
int min = 0;
- sscanf(tag.c_str(), "%04d%02d%02d-%02d%02d",
- &year, &mon, &day, &hour, &min);
- if ( year != lctime->tm_year + 1900 ||
- mon != lctime->tm_mon+1 ||
- day != lctime->tm_mday )
- {
+ sscanf(tag.c_str(), "%04d%02d%02d-%02d%02d", &year, &mon, &day, &hour,
+ &min);
+ if (year != lctime->tm_year + 1900 || mon != lctime->tm_mon + 1 ||
+ day != lctime->tm_mday) {
tag = "";
- }
+ }
std::string tagmode;
- if ( cmSystemTools::GetLineFromStream(tfin, tagmode) )
- {
- if (tagmode.size() > 4 && !this->Parts[PartStart])
- {
+ if (cmSystemTools::GetLineFromStream(tfin, tagmode)) {
+ if (tagmode.size() > 4 && !this->Parts[PartStart]) {
this->TestModel = cmCTest::GetTestModelFromString(tagmode.c_str());
- }
}
- tfin.close();
}
- if (tag.empty() || (0 != command) || this->Parts[PartStart])
- {
- cmCTestOptionalLog(this, DEBUG, "TestModel: " <<
- this->GetTestModelString() << std::endl, quiet);
- cmCTestOptionalLog(this, DEBUG, "TestModel: " <<
- this->TestModel << std::endl, quiet);
- if ( this->TestModel == cmCTest::NIGHTLY )
- {
+ tfin.close();
+ }
+ if (tag.empty() || (0 != command) || this->Parts[PartStart]) {
+ cmCTestOptionalLog(
+ this, DEBUG,
+ "TestModel: " << this->GetTestModelString() << std::endl, quiet);
+ cmCTestOptionalLog(
+ this, DEBUG, "TestModel: " << this->TestModel << std::endl, quiet);
+ if (this->TestModel == cmCTest::NIGHTLY) {
lctime = this->GetNightlyTime(
this->GetCTestConfiguration("NightlyStartTime"),
this->TomorrowTag);
- }
+ }
char datestring[100];
- sprintf(datestring, "%04d%02d%02d-%02d%02d",
- lctime->tm_year + 1900,
- lctime->tm_mon+1,
- lctime->tm_mday,
- lctime->tm_hour,
+ sprintf(datestring, "%04d%02d%02d-%02d%02d", lctime->tm_year + 1900,
+ lctime->tm_mon + 1, lctime->tm_mday, lctime->tm_hour,
lctime->tm_min);
tag = datestring;
cmsys::ofstream ofs(tagfile.c_str());
- if ( ofs )
- {
+ if (ofs) {
ofs << tag << std::endl;
ofs << this->GetTestModelString() << std::endl;
- }
+ }
ofs.close();
- if ( 0 == command )
- {
- cmCTestOptionalLog(this, OUTPUT, "Create new tag: " << tag << " - "
- << this->GetTestModelString() << std::endl, quiet);
- }
+ if (0 == command) {
+ cmCTestOptionalLog(this, OUTPUT, "Create new tag: "
+ << tag << " - " << this->GetTestModelString()
+ << std::endl,
+ quiet);
}
}
- else
- {
- if ( tfin )
- {
+ } else {
+ if (tfin) {
cmSystemTools::GetLineFromStream(tfin, tag);
tfin.close();
- }
+ }
- if ( tag.empty() )
- {
- cmCTestLog(this, ERROR_MESSAGE,
- "Cannot read existing TAG file in " << testingDir
- << std::endl);
+ if (tag.empty()) {
+ cmCTestLog(this, ERROR_MESSAGE, "Cannot read existing TAG file in "
+ << testingDir << std::endl);
return 0;
- }
-
- cmCTestOptionalLog(this, OUTPUT, " Use existing tag: " << tag << " - "
- << this->GetTestModelString() << std::endl, quiet);
}
- this->CurrentTag = tag;
+ cmCTestOptionalLog(this, OUTPUT, " Use existing tag: "
+ << tag << " - " << this->GetTestModelString()
+ << std::endl,
+ quiet);
}
+ this->CurrentTag = tag;
+ }
+
return 1;
}
bool cmCTest::InitializeFromCommand(cmCTestStartCommand* command)
{
- std::string src_dir
- = this->GetCTestConfiguration("SourceDirectory");
+ std::string src_dir = this->GetCTestConfiguration("SourceDirectory");
std::string bld_dir = this->GetCTestConfiguration("BuildDirectory");
this->DartVersion = 1;
this->DropSiteCDash = false;
- for(Part p = PartStart; p != PartCount; p = Part(p+1))
- {
+ for (Part p = PartStart; p != PartCount; p = Part(p + 1)) {
this->Parts[p].SubmitFiles.clear();
- }
+ }
cmMakefile* mf = command->GetMakefile();
std::string fname;
@@ -666,168 +614,143 @@ bool cmCTest::InitializeFromCommand(cmCTestStartCommand* command)
bld_dir_fname += "/CTestConfig.cmake";
cmSystemTools::ConvertToUnixSlashes(bld_dir_fname);
- if ( cmSystemTools::FileExists(bld_dir_fname.c_str()) )
- {
+ if (cmSystemTools::FileExists(bld_dir_fname.c_str())) {
fname = bld_dir_fname;
- }
- else if ( cmSystemTools::FileExists(src_dir_fname.c_str()) )
- {
+ } else if (cmSystemTools::FileExists(src_dir_fname.c_str())) {
fname = src_dir_fname;
- }
+ }
- if ( !fname.empty() )
- {
+ if (!fname.empty()) {
cmCTestOptionalLog(this, OUTPUT, " Reading ctest configuration file: "
- << fname << std::endl, command->ShouldBeQuiet());
+ << fname << std::endl,
+ command->ShouldBeQuiet());
bool readit = mf->ReadDependentFile(fname.c_str());
- if(!readit)
- {
+ if (!readit) {
std::string m = "Could not find include file: ";
m += fname;
command->SetError(m);
return false;
- }
}
- else
- {
- cmCTestOptionalLog(this, WARNING,
- "Cannot locate CTest configuration: in BuildDirectory: "
- << bld_dir_fname << std::endl, command->ShouldBeQuiet());
+ } else {
cmCTestOptionalLog(this, WARNING,
- "Cannot locate CTest configuration: in SourceDirectory: "
- << src_dir_fname << std::endl, command->ShouldBeQuiet());
- }
+ "Cannot locate CTest configuration: in BuildDirectory: "
+ << bld_dir_fname << std::endl,
+ command->ShouldBeQuiet());
+ cmCTestOptionalLog(
+ this, WARNING, "Cannot locate CTest configuration: in SourceDirectory: "
+ << src_dir_fname << std::endl,
+ command->ShouldBeQuiet());
+ }
this->SetCTestConfigurationFromCMakeVariable(mf, "NightlyStartTime",
- "CTEST_NIGHTLY_START_TIME", command->ShouldBeQuiet());
+ "CTEST_NIGHTLY_START_TIME",
+ command->ShouldBeQuiet());
this->SetCTestConfigurationFromCMakeVariable(mf, "Site", "CTEST_SITE",
- command->ShouldBeQuiet());
- this->SetCTestConfigurationFromCMakeVariable(mf, "BuildName",
- "CTEST_BUILD_NAME", command->ShouldBeQuiet());
+ command->ShouldBeQuiet());
+ this->SetCTestConfigurationFromCMakeVariable(
+ mf, "BuildName", "CTEST_BUILD_NAME", command->ShouldBeQuiet());
const char* dartVersion = mf->GetDefinition("CTEST_DART_SERVER_VERSION");
- if ( dartVersion )
- {
+ if (dartVersion) {
this->DartVersion = atoi(dartVersion);
- if ( this->DartVersion < 0 )
- {
+ if (this->DartVersion < 0) {
cmCTestLog(this, ERROR_MESSAGE, "Invalid Dart server version: "
- << dartVersion << ". Please specify the version number."
- << std::endl);
+ << dartVersion << ". Please specify the version number."
+ << std::endl);
return false;
- }
}
+ }
this->DropSiteCDash = mf->IsOn("CTEST_DROP_SITE_CDASH");
- if ( !this->Initialize(bld_dir.c_str(), command) )
- {
+ if (!this->Initialize(bld_dir.c_str(), command)) {
return false;
- }
- cmCTestOptionalLog(this, OUTPUT, " Use " << this->GetTestModelString()
- << " tag: " << this->GetCurrentTag() << std::endl,
- command->ShouldBeQuiet());
+ }
+ cmCTestOptionalLog(this, OUTPUT, " Use "
+ << this->GetTestModelString()
+ << " tag: " << this->GetCurrentTag() << std::endl,
+ command->ShouldBeQuiet());
return true;
}
-
bool cmCTest::UpdateCTestConfiguration()
{
- if ( this->SuppressUpdatingCTestConfiguration )
- {
+ if (this->SuppressUpdatingCTestConfiguration) {
return true;
- }
+ }
std::string fileName = this->CTestConfigFile;
- if ( fileName.empty() )
- {
+ if (fileName.empty()) {
fileName = this->BinaryDir + "/CTestConfiguration.ini";
- if ( !cmSystemTools::FileExists(fileName.c_str()) )
- {
+ if (!cmSystemTools::FileExists(fileName.c_str())) {
fileName = this->BinaryDir + "/DartConfiguration.tcl";
- }
}
- cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "UpdateCTestConfiguration from :"
- << fileName << "\n");
- if ( !cmSystemTools::FileExists(fileName.c_str()) )
- {
+ }
+ cmCTestLog(this, HANDLER_VERBOSE_OUTPUT,
+ "UpdateCTestConfiguration from :" << fileName << "\n");
+ if (!cmSystemTools::FileExists(fileName.c_str())) {
// No need to exit if we are not producing XML
- if ( this->ProduceXML )
- {
+ if (this->ProduceXML) {
cmCTestLog(this, ERROR_MESSAGE, "Cannot find file: " << fileName
- << std::endl);
+ << std::endl);
return false;
- }
}
- else
- {
- cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "Parse Config file:"
- << fileName << "\n");
+ } else {
+ cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "Parse Config file:" << fileName
+ << "\n");
// parse the dart test file
cmsys::ifstream fin(fileName.c_str());
- if(!fin)
- {
+ if (!fin) {
return false;
- }
+ }
char buffer[1024];
- while ( fin )
- {
+ while (fin) {
buffer[0] = 0;
fin.getline(buffer, 1023);
buffer[1023] = 0;
std::string line = cmCTest::CleanString(buffer);
- if(line.empty())
- {
+ if (line.empty()) {
continue;
- }
- while ( fin && (line[line.size()-1] == '\\') )
- {
- line = line.substr(0, line.size()-1);
+ }
+ while (fin && (line[line.size() - 1] == '\\')) {
+ line = line.substr(0, line.size() - 1);
buffer[0] = 0;
fin.getline(buffer, 1023);
buffer[1023] = 0;
line += cmCTest::CleanString(buffer);
- }
- if ( line[0] == '#' )
- {
+ }
+ if (line[0] == '#') {
continue;
- }
+ }
std::string::size_type cpos = line.find_first_of(":");
- if ( cpos == line.npos )
- {
+ if (cpos == line.npos) {
continue;
- }
+ }
std::string key = line.substr(0, cpos);
- std::string value
- = cmCTest::CleanString(line.substr(cpos+1, line.npos));
+ std::string value =
+ cmCTest::CleanString(line.substr(cpos + 1, line.npos));
this->CTestConfiguration[key] = value;
- }
- fin.close();
}
- if ( !this->GetCTestConfiguration("BuildDirectory").empty() )
- {
+ fin.close();
+ }
+ if (!this->GetCTestConfiguration("BuildDirectory").empty()) {
this->BinaryDir = this->GetCTestConfiguration("BuildDirectory");
cmSystemTools::ChangeDirectory(this->BinaryDir);
- }
+ }
this->TimeOut = atoi(this->GetCTestConfiguration("TimeOut").c_str());
std::string const& testLoad = this->GetCTestConfiguration("TestLoad");
- if (!testLoad.empty())
- {
+ if (!testLoad.empty()) {
unsigned long load;
- if (cmSystemTools::StringToULong(testLoad.c_str(), &load))
- {
+ if (cmSystemTools::StringToULong(testLoad.c_str(), &load)) {
this->SetTestLoad(load);
- }
- else
- {
- cmCTestLog(this, WARNING, "Invalid value for 'Test Load' : "
- << testLoad << std::endl);
- }
+ } else {
+ cmCTestLog(this, WARNING,
+ "Invalid value for 'Test Load' : " << testLoad << std::endl);
}
- if ( this->ProduceXML )
- {
+ }
+ if (this->ProduceXML) {
this->CompressXMLFiles = cmSystemTools::IsOn(
this->GetCTestConfiguration("CompressSubmission").c_str());
- }
+ }
return true;
}
@@ -850,107 +773,85 @@ void cmCTest::SetTestModel(int mode)
bool cmCTest::SetTest(const char* ttype, bool report)
{
- if ( cmSystemTools::LowerCase(ttype) == "all" )
- {
- for(Part p = PartStart; p != PartCount; p = Part(p+1))
- {
+ if (cmSystemTools::LowerCase(ttype) == "all") {
+ for (Part p = PartStart; p != PartCount; p = Part(p + 1)) {
this->Parts[p].Enable();
- }
- return true;
}
+ return true;
+ }
Part p = this->GetPartFromName(ttype);
- if(p != PartCount)
- {
+ if (p != PartCount) {
this->Parts[p].Enable();
return true;
+ } else {
+ if (report) {
+ cmCTestLog(this, ERROR_MESSAGE, "Don't know about test \""
+ << ttype << "\" yet..." << std::endl);
}
- else
- {
- if ( report )
- {
- cmCTestLog(this, ERROR_MESSAGE, "Don't know about test \"" << ttype
- << "\" yet..." << std::endl);
- }
return false;
- }
+ }
}
void cmCTest::Finalize()
{
}
-bool cmCTest::OpenOutputFile(const std::string& path,
- const std::string& name, cmGeneratedFileStream& stream,
- bool compress)
+bool cmCTest::OpenOutputFile(const std::string& path, const std::string& name,
+ cmGeneratedFileStream& stream, bool compress)
{
std::string testingDir = this->BinaryDir + "/Testing";
- if (!path.empty())
- {
+ if (!path.empty()) {
testingDir += "/" + path;
- }
- if ( cmSystemTools::FileExists(testingDir.c_str()) )
- {
- if ( !cmSystemTools::FileIsDirectory(testingDir) )
- {
- cmCTestLog(this, ERROR_MESSAGE, "File " << testingDir
- << " is in the place of the testing directory"
- << std::endl);
+ }
+ if (cmSystemTools::FileExists(testingDir.c_str())) {
+ if (!cmSystemTools::FileIsDirectory(testingDir)) {
+ cmCTestLog(this, ERROR_MESSAGE, "File "
+ << testingDir << " is in the place of the testing directory"
+ << std::endl);
return false;
- }
}
- else
- {
- if ( !cmSystemTools::MakeDirectory(testingDir.c_str()) )
- {
+ } else {
+ if (!cmSystemTools::MakeDirectory(testingDir.c_str())) {
cmCTestLog(this, ERROR_MESSAGE, "Cannot create directory " << testingDir
- << std::endl);
+ << std::endl);
return false;
- }
}
+ }
std::string filename = testingDir + "/" + name;
stream.Open(filename.c_str());
- if( !stream )
- {
+ if (!stream) {
cmCTestLog(this, ERROR_MESSAGE, "Problem opening file: " << filename
- << std::endl);
+ << std::endl);
return false;
- }
- if ( compress )
- {
- if ( this->CompressXMLFiles )
- {
+ }
+ if (compress) {
+ if (this->CompressXMLFiles) {
stream.SetCompression(true);
- }
}
+ }
return true;
}
bool cmCTest::AddIfExists(Part part, const char* file)
{
- if ( this->CTestFileExists(file) )
- {
+ if (this->CTestFileExists(file)) {
this->AddSubmitFile(part, file);
- }
- else
- {
+ } else {
std::string name = file;
name += ".gz";
- if ( this->CTestFileExists(name) )
- {
+ if (this->CTestFileExists(name)) {
this->AddSubmitFile(part, file);
- }
- else
- {
+ } else {
return false;
- }
}
+ }
return true;
}
bool cmCTest::CTestFileExists(const std::string& filename)
{
- std::string testingDir = this->BinaryDir + "/Testing/" +
- this->CurrentTag + "/" + filename;
+ std::string testingDir =
+ this->BinaryDir + "/Testing/" + this->CurrentTag + "/" + filename;
return cmSystemTools::FileExists(testingDir.c_str());
}
@@ -958,10 +859,9 @@ cmCTestGenericHandler* cmCTest::GetInitializedHandler(const char* handler)
{
cmCTest::t_TestingHandlers::iterator it =
this->TestingHandlers.find(handler);
- if ( it == this->TestingHandlers.end() )
- {
+ if (it == this->TestingHandlers.end()) {
return 0;
- }
+ }
it->second->Initialize();
return it->second;
}
@@ -970,20 +870,18 @@ cmCTestGenericHandler* cmCTest::GetHandler(const char* handler)
{
cmCTest::t_TestingHandlers::iterator it =
this->TestingHandlers.find(handler);
- if ( it == this->TestingHandlers.end() )
- {
+ if (it == this->TestingHandlers.end()) {
return 0;
- }
+ }
return it->second;
}
int cmCTest::ExecuteHandler(const char* shandler)
{
cmCTestGenericHandler* handler = this->GetHandler(shandler);
- if ( !handler )
- {
+ if (!handler) {
return -1;
- }
+ }
handler->Initialize();
return handler->ProcessHandler();
}
@@ -994,150 +892,119 @@ int cmCTest::ProcessTests()
bool notest = true;
int update_count = 0;
- for(Part p = PartStart; notest && p != PartCount; p = Part(p+1))
- {
+ for (Part p = PartStart; notest && p != PartCount; p = Part(p + 1)) {
notest = !this->Parts[p];
- }
- if (this->Parts[PartUpdate] &&
- (this->GetRemainingTimeAllowed() - 120 > 0))
- {
+ }
+ if (this->Parts[PartUpdate] && (this->GetRemainingTimeAllowed() - 120 > 0)) {
cmCTestGenericHandler* uphandler = this->GetHandler("update");
- uphandler->SetPersistentOption("SourceDirectory",
+ uphandler->SetPersistentOption(
+ "SourceDirectory",
this->GetCTestConfiguration("SourceDirectory").c_str());
update_count = uphandler->ProcessHandler();
- if ( update_count < 0 )
- {
+ if (update_count < 0) {
res |= cmCTest::UPDATE_ERRORS;
- }
}
- if ( this->TestModel == cmCTest::CONTINUOUS && !update_count )
- {
+ }
+ if (this->TestModel == cmCTest::CONTINUOUS && !update_count) {
return 0;
- }
+ }
if (this->Parts[PartConfigure] &&
- (this->GetRemainingTimeAllowed() - 120 > 0))
- {
- if (this->GetHandler("configure")->ProcessHandler() < 0)
- {
+ (this->GetRemainingTimeAllowed() - 120 > 0)) {
+ if (this->GetHandler("configure")->ProcessHandler() < 0) {
res |= cmCTest::CONFIGURE_ERRORS;
- }
}
- if (this->Parts[PartBuild] &&
- (this->GetRemainingTimeAllowed() - 120 > 0))
- {
+ }
+ if (this->Parts[PartBuild] && (this->GetRemainingTimeAllowed() - 120 > 0)) {
this->UpdateCTestConfiguration();
- if (this->GetHandler("build")->ProcessHandler() < 0)
- {
+ if (this->GetHandler("build")->ProcessHandler() < 0) {
res |= cmCTest::BUILD_ERRORS;
- }
}
+ }
if ((this->Parts[PartTest] || notest) &&
- (this->GetRemainingTimeAllowed() - 120 > 0))
- {
+ (this->GetRemainingTimeAllowed() - 120 > 0)) {
this->UpdateCTestConfiguration();
- if (this->GetHandler("test")->ProcessHandler() < 0)
- {
+ if (this->GetHandler("test")->ProcessHandler() < 0) {
res |= cmCTest::TEST_ERRORS;
- }
}
+ }
if (this->Parts[PartCoverage] &&
- (this->GetRemainingTimeAllowed() - 120 > 0))
- {
+ (this->GetRemainingTimeAllowed() - 120 > 0)) {
this->UpdateCTestConfiguration();
- if (this->GetHandler("coverage")->ProcessHandler() < 0)
- {
+ if (this->GetHandler("coverage")->ProcessHandler() < 0) {
res |= cmCTest::COVERAGE_ERRORS;
- }
}
+ }
if (this->Parts[PartMemCheck] &&
- (this->GetRemainingTimeAllowed() - 120 > 0))
- {
+ (this->GetRemainingTimeAllowed() - 120 > 0)) {
this->UpdateCTestConfiguration();
- if (this->GetHandler("memcheck")->ProcessHandler() < 0)
- {
+ if (this->GetHandler("memcheck")->ProcessHandler() < 0) {
res |= cmCTest::MEMORY_ERRORS;
- }
}
- if ( !notest )
- {
+ }
+ if (!notest) {
std::string notes_dir = this->BinaryDir + "/Testing/Notes";
- if ( cmSystemTools::FileIsDirectory(notes_dir) )
- {
+ if (cmSystemTools::FileIsDirectory(notes_dir)) {
cmsys::Directory d;
d.Load(notes_dir);
unsigned long kk;
- for ( kk = 0; kk < d.GetNumberOfFiles(); kk ++ )
- {
+ for (kk = 0; kk < d.GetNumberOfFiles(); kk++) {
const char* file = d.GetFile(kk);
std::string fullname = notes_dir + "/" + file;
- if ( cmSystemTools::FileExists(fullname.c_str()) &&
- !cmSystemTools::FileIsDirectory(fullname) )
- {
- if (!this->NotesFiles.empty())
- {
+ if (cmSystemTools::FileExists(fullname.c_str()) &&
+ !cmSystemTools::FileIsDirectory(fullname)) {
+ if (!this->NotesFiles.empty()) {
this->NotesFiles += ";";
- }
+ }
this->NotesFiles += fullname;
this->Parts[PartNotes].Enable();
- }
}
}
}
- if (this->Parts[PartNotes])
- {
+ }
+ if (this->Parts[PartNotes]) {
this->UpdateCTestConfiguration();
- if (!this->NotesFiles.empty())
- {
+ if (!this->NotesFiles.empty()) {
this->GenerateNotesFile(this->NotesFiles.c_str());
- }
}
- if (this->Parts[PartSubmit])
- {
+ }
+ if (this->Parts[PartSubmit]) {
this->UpdateCTestConfiguration();
- if (this->GetHandler("submit")->ProcessHandler() < 0)
- {
+ if (this->GetHandler("submit")->ProcessHandler() < 0) {
res |= cmCTest::SUBMIT_ERRORS;
- }
- }
- if ( res != 0 )
- {
- cmCTestLog(this, ERROR_MESSAGE, "Errors while running CTest"
- << std::endl);
}
+ }
+ if (res != 0) {
+ cmCTestLog(this, ERROR_MESSAGE, "Errors while running CTest" << std::endl);
+ }
return res;
}
std::string cmCTest::GetTestModelString()
{
- if ( !this->SpecificTrack.empty() )
- {
+ if (!this->SpecificTrack.empty()) {
return this->SpecificTrack;
- }
- switch ( this->TestModel )
- {
- case cmCTest::NIGHTLY:
- return "Nightly";
- case cmCTest::CONTINUOUS:
- return "Continuous";
- }
+ }
+ switch (this->TestModel) {
+ case cmCTest::NIGHTLY:
+ return "Nightly";
+ case cmCTest::CONTINUOUS:
+ return "Continuous";
+ }
return "Experimental";
}
int cmCTest::GetTestModelFromString(const char* str)
{
- if ( !str )
- {
+ if (!str) {
return cmCTest::EXPERIMENTAL;
- }
+ }
std::string rstr = cmSystemTools::LowerCase(str);
- if ( cmHasLiteralPrefix(rstr.c_str(), "cont") )
- {
+ if (cmHasLiteralPrefix(rstr.c_str(), "cont")) {
return cmCTest::CONTINUOUS;
- }
- if ( cmHasLiteralPrefix(rstr.c_str(), "nigh") )
- {
+ }
+ if (cmHasLiteralPrefix(rstr.c_str(), "nigh")) {
return cmCTest::NIGHTLY;
- }
+ }
return cmCTest::EXPERIMENTAL;
}
@@ -1147,31 +1014,29 @@ int cmCTest::GetTestModelFromString(const char* str)
//######################################################################
int cmCTest::RunMakeCommand(const char* command, std::string& output,
- int* retVal, const char* dir, int timeout, std::ostream& ofs)
+ int* retVal, const char* dir, int timeout,
+ std::ostream& ofs)
{
// First generate the command and arguments
std::vector<std::string> args = cmSystemTools::ParseArguments(command);
- if(args.size() < 1)
- {
+ if (args.size() < 1) {
return false;
- }
+ }
std::vector<const char*> argv;
- for(std::vector<std::string>::const_iterator a = args.begin();
- a != args.end(); ++a)
- {
+ for (std::vector<std::string>::const_iterator a = args.begin();
+ a != args.end(); ++a) {
argv.push_back(a->c_str());
- }
+ }
argv.push_back(0);
output = "";
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "Run command:");
std::vector<const char*>::iterator ait;
- for ( ait = argv.begin(); ait != argv.end() && *ait; ++ ait )
- {
+ for (ait = argv.begin(); ait != argv.end() && *ait; ++ait) {
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, " \"" << *ait << "\"");
- }
+ }
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, std::endl);
// Now create process object
@@ -1189,69 +1054,55 @@ int cmCTest::RunMakeCommand(const char* command, std::string& output,
char* data;
int length;
- cmCTestLog(this, HANDLER_PROGRESS_OUTPUT,
- " Each . represents " << tick_len << " bytes of output" << std::endl
- << " " << std::flush);
- while(cmsysProcess_WaitForData(cp, &data, &length, 0))
- {
- for(int cc =0; cc < length; ++cc)
- {
- if(data[cc] == 0)
- {
+ cmCTestLog(this, HANDLER_PROGRESS_OUTPUT, " Each . represents "
+ << tick_len << " bytes of output" << std::endl
+ << " " << std::flush);
+ while (cmsysProcess_WaitForData(cp, &data, &length, 0)) {
+ for (int cc = 0; cc < length; ++cc) {
+ if (data[cc] == 0) {
data[cc] = '\n';
- }
}
+ }
output.append(data, length);
- while ( output.size() > (tick * tick_len) )
- {
- tick ++;
+ while (output.size() > (tick * tick_len)) {
+ tick++;
cmCTestLog(this, HANDLER_PROGRESS_OUTPUT, "." << std::flush);
- if ( tick % tick_line_len == 0 && tick > 0 )
- {
+ if (tick % tick_line_len == 0 && tick > 0) {
cmCTestLog(this, HANDLER_PROGRESS_OUTPUT,
- " Size: "
- << int((double(output.size()) / 1024.0) + 1)
- << "K" << std::endl
- << " " << std::flush);
- }
+ " Size: " << int((double(output.size()) / 1024.0) + 1)
+ << "K" << std::endl
+ << " " << std::flush);
}
+ }
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, cmCTestLogWrite(data, length));
- if ( ofs )
- {
+ if (ofs) {
ofs << cmCTestLogWrite(data, length);
- }
}
+ }
cmCTestLog(this, HANDLER_PROGRESS_OUTPUT, " Size of output: "
- << int(double(output.size()) / 1024.0) << "K" << std::endl);
+ << int(double(output.size()) / 1024.0) << "K" << std::endl);
cmsysProcess_WaitForExit(cp, 0);
int result = cmsysProcess_GetState(cp);
- if(result == cmsysProcess_State_Exited)
- {
+ if (result == cmsysProcess_State_Exited) {
*retVal = cmsysProcess_GetExitValue(cp);
- cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "Command exited with the value: "
- << *retVal << std::endl);
- }
- else if(result == cmsysProcess_State_Exception)
- {
+ cmCTestLog(this, HANDLER_VERBOSE_OUTPUT,
+ "Command exited with the value: " << *retVal << std::endl);
+ } else if (result == cmsysProcess_State_Exception) {
*retVal = cmsysProcess_GetExitException(cp);
cmCTestLog(this, WARNING, "There was an exception: " << *retVal
- << std::endl);
- }
- else if(result == cmsysProcess_State_Expired)
- {
+ << std::endl);
+ } else if (result == cmsysProcess_State_Expired) {
cmCTestLog(this, WARNING, "There was a timeout" << std::endl);
- }
- else if(result == cmsysProcess_State_Error)
- {
+ } else if (result == cmsysProcess_State_Error) {
output += "\n*** ERROR executing: ";
output += cmsysProcess_GetErrorString(cp);
output += "\n***The build process failed.";
cmCTestLog(this, ERROR_MESSAGE, "There was an error: "
- << cmsysProcess_GetErrorString(cp) << std::endl);
- }
+ << cmsysProcess_GetErrorString(cp) << std::endl);
+ }
cmsysProcess_Delete(cp);
@@ -1263,36 +1114,29 @@ int cmCTest::RunMakeCommand(const char* command, std::string& output,
//######################################################################
//######################################################################
-int cmCTest::RunTest(std::vector<const char*> argv,
- std::string* output, int *retVal,
- std::ostream* log, double testTimeOut,
+int cmCTest::RunTest(std::vector<const char*> argv, std::string* output,
+ int* retVal, std::ostream* log, double testTimeOut,
std::vector<std::string>* environment)
{
bool modifyEnv = (environment && !environment->empty());
// determine how much time we have
double timeout = this->GetRemainingTimeAllowed() - 120;
- if (this->TimeOut > 0 && this->TimeOut < timeout)
- {
+ if (this->TimeOut > 0 && this->TimeOut < timeout) {
timeout = this->TimeOut;
- }
- if (testTimeOut > 0
- && testTimeOut < this->GetRemainingTimeAllowed())
- {
+ }
+ if (testTimeOut > 0 && testTimeOut < this->GetRemainingTimeAllowed()) {
timeout = testTimeOut;
- }
+ }
// always have at least 1 second if we got to here
- if (timeout <= 0)
- {
+ if (timeout <= 0) {
timeout = 1;
- }
+ }
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT,
"Test timeout computed to be: " << timeout << "\n");
- if(cmSystemTools::SameFile(
- argv[0], cmSystemTools::GetCTestCommand()) &&
- !this->ForceNewCTestProcess)
- {
+ if (cmSystemTools::SameFile(argv[0], cmSystemTools::GetCTestCommand()) &&
+ !this->ForceNewCTestProcess) {
cmCTest inst;
inst.ConfigType = this->ConfigType;
inst.TimeOut = timeout;
@@ -1302,139 +1146,116 @@ int cmCTest::RunTest(std::vector<const char*> argv,
inst.SetStreams(&oss, &oss);
std::vector<std::string> args;
- for(unsigned int i =0; i < argv.size(); ++i)
- {
- if(argv[i])
- {
+ for (unsigned int i = 0; i < argv.size(); ++i) {
+ if (argv[i]) {
// make sure we pass the timeout in for any build and test
// invocations. Since --build-generator is required this is a
// good place to check for it, and to add the arguments in
- if (strcmp(argv[i],"--build-generator") == 0 && timeout > 0)
- {
+ if (strcmp(argv[i], "--build-generator") == 0 && timeout > 0) {
args.push_back("--test-timeout");
std::ostringstream msg;
msg << timeout;
args.push_back(msg.str());
- }
- args.push_back(argv[i]);
}
+ args.push_back(argv[i]);
}
- if ( log )
- {
+ }
+ if (log) {
*log << "* Run internal CTest" << std::endl;
- }
+ }
std::string oldpath = cmSystemTools::GetCurrentWorkingDirectory();
cmsys::auto_ptr<cmSystemTools::SaveRestoreEnvironment> saveEnv;
- if (modifyEnv)
- {
+ if (modifyEnv) {
saveEnv.reset(new cmSystemTools::SaveRestoreEnvironment);
cmSystemTools::AppendEnv(*environment);
- }
+ }
*retVal = inst.Run(args, output);
- if(output)
- {
+ if (output) {
*output += oss.str();
- }
- if ( log && output)
- {
+ }
+ if (log && output) {
*log << *output;
- }
+ }
cmSystemTools::ChangeDirectory(oldpath);
- if(output)
- {
+ if (output) {
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT,
"Internal cmCTest object used to run test." << std::endl
- << *output << std::endl);
- }
+ << *output
+ << std::endl);
+ }
return cmsysProcess_State_Exited;
- }
+ }
std::vector<char> tempOutput;
- if ( output )
- {
+ if (output) {
*output = "";
- }
+ }
cmsys::auto_ptr<cmSystemTools::SaveRestoreEnvironment> saveEnv;
- if (modifyEnv)
- {
+ if (modifyEnv) {
saveEnv.reset(new cmSystemTools::SaveRestoreEnvironment);
cmSystemTools::AppendEnv(*environment);
- }
+ }
cmsysProcess* cp = cmsysProcess_New();
cmsysProcess_SetCommand(cp, &*argv.begin());
cmCTestLog(this, DEBUG, "Command is: " << argv[0] << std::endl);
- if(cmSystemTools::GetRunCommandHideConsole())
- {
+ if (cmSystemTools::GetRunCommandHideConsole()) {
cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
- }
+ }
cmsysProcess_SetTimeout(cp, timeout);
cmsysProcess_Execute(cp);
char* data;
int length;
- while(cmsysProcess_WaitForData(cp, &data, &length, 0))
- {
- if ( output )
- {
- tempOutput.insert(tempOutput.end(), data, data+length);
- }
+ while (cmsysProcess_WaitForData(cp, &data, &length, 0)) {
+ if (output) {
+ tempOutput.insert(tempOutput.end(), data, data + length);
+ }
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, cmCTestLogWrite(data, length));
- if ( log )
- {
+ if (log) {
log->write(data, length);
- }
}
+ }
cmsysProcess_WaitForExit(cp, 0);
- if(output && tempOutput.begin() != tempOutput.end())
- {
+ if (output && tempOutput.begin() != tempOutput.end()) {
output->append(&*tempOutput.begin(), tempOutput.size());
- }
+ }
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "-- Process completed"
- << std::endl);
+ << std::endl);
int result = cmsysProcess_GetState(cp);
- if(result == cmsysProcess_State_Exited)
- {
+ if (result == cmsysProcess_State_Exited) {
*retVal = cmsysProcess_GetExitValue(cp);
- if(*retVal != 0 && this->OutputTestOutputOnTestFailure)
- {
- OutputTestErrors(tempOutput);
- }
+ if (*retVal != 0 && this->OutputTestOutputOnTestFailure) {
+ OutputTestErrors(tempOutput);
+ }
+ } else if (result == cmsysProcess_State_Exception) {
+ if (this->OutputTestOutputOnTestFailure) {
+ OutputTestErrors(tempOutput);
}
- else if(result == cmsysProcess_State_Exception)
- {
- if(this->OutputTestOutputOnTestFailure)
- {
- OutputTestErrors(tempOutput);
- }
*retVal = cmsysProcess_GetExitException(cp);
std::string outerr = "\n*** Exception executing: ";
outerr += cmsysProcess_GetExceptionString(cp);
- if(output)
- {
+ if (output) {
*output += outerr;
- }
- cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, outerr.c_str() << std::endl
- << std::flush);
}
- else if(result == cmsysProcess_State_Error)
- {
+ cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, outerr.c_str() << std::endl
+ << std::flush);
+ } else if (result == cmsysProcess_State_Error) {
std::string outerr = "\n*** ERROR executing: ";
outerr += cmsysProcess_GetErrorString(cp);
- if(output)
- {
+ if (output) {
*output += outerr;
- }
- cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, outerr.c_str() << std::endl
- << std::flush);
}
+ cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, outerr.c_str() << std::endl
+ << std::flush);
+ }
cmsysProcess_Delete(cp);
return result;
@@ -1444,45 +1265,40 @@ std::string cmCTest::SafeBuildIdField(const std::string& value)
{
std::string safevalue(value);
- if (safevalue != "")
- {
+ if (safevalue != "") {
// Disallow non-filename and non-space whitespace characters.
// If they occur, replace them with ""
//
- const char *disallowed = "\\:*?\"<>|\n\r\t\f\v";
+ const char* disallowed = "\\:*?\"<>|\n\r\t\f\v";
- if (safevalue.find_first_of(disallowed) != value.npos)
- {
+ if (safevalue.find_first_of(disallowed) != value.npos) {
std::string::size_type i = 0;
std::string::size_type n = strlen(disallowed);
char replace[2];
replace[1] = 0;
- for (i= 0; i<n; ++i)
- {
+ for (i = 0; i < n; ++i) {
replace[0] = disallowed[i];
cmSystemTools::ReplaceString(safevalue, replace, "");
- }
}
}
+ }
- if (safevalue == "")
- {
+ if (safevalue == "") {
safevalue = "(empty)";
- }
+ }
return safevalue;
}
void cmCTest::StartXML(cmXMLWriter& xml, bool append)
{
- if(this->CurrentTag.empty())
- {
- cmCTestLog(this, ERROR_MESSAGE,
- "Current Tag empty, this may mean"
- " NightlStartTime was not set correctly." << std::endl);
+ if (this->CurrentTag.empty()) {
+ cmCTestLog(this, ERROR_MESSAGE, "Current Tag empty, this may mean"
+ " NightlStartTime was not set correctly."
+ << std::endl);
cmSystemTools::SetFatalErrorOccured();
- }
+ }
// find out about the system
cmsys::SystemInformation info;
@@ -1490,12 +1306,12 @@ void cmCTest::StartXML(cmXMLWriter& xml, bool append)
info.RunOSCheck();
info.RunMemoryCheck();
- std::string buildname = cmCTest::SafeBuildIdField(
- this->GetCTestConfiguration("BuildName"));
- std::string stamp = cmCTest::SafeBuildIdField(
- this->CurrentTag + "-" + this->GetTestModelString());
- std::string site = cmCTest::SafeBuildIdField(
- this->GetCTestConfiguration("Site"));
+ std::string buildname =
+ cmCTest::SafeBuildIdField(this->GetCTestConfiguration("BuildName"));
+ std::string stamp = cmCTest::SafeBuildIdField(this->CurrentTag + "-" +
+ this->GetTestModelString());
+ std::string site =
+ cmCTest::SafeBuildIdField(this->GetCTestConfiguration("Site"));
xml.StartDocument();
xml.StartElement("Site");
@@ -1504,14 +1320,13 @@ void cmCTest::StartXML(cmXMLWriter& xml, bool append)
xml.Attribute("BuildStamp", stamp);
xml.Attribute("Name", site);
xml.Attribute("Generator",
- std::string("ctest-") + cmVersion::GetCMakeVersion());
- if(append)
- {
+ std::string("ctest-") + cmVersion::GetCMakeVersion());
+ if (append) {
xml.Attribute("Append", "true");
- }
+ }
xml.Attribute("CompilerName", this->GetCTestConfiguration("Compiler"));
xml.Attribute("CompilerVersion",
- this->GetCTestConfiguration("CompilerVersion"));
+ this->GetCTestConfiguration("CompilerVersion"));
xml.Attribute("OSName", info.GetOSName());
xml.Attribute("Hostname", info.GetHostname());
xml.Attribute("OSRelease", info.GetOSRelease());
@@ -1528,14 +1343,13 @@ void cmCTest::StartXML(cmXMLWriter& xml, bool append)
xml.Attribute("TotalVirtualMemory", info.GetTotalVirtualMemory());
xml.Attribute("TotalPhysicalMemory", info.GetTotalPhysicalMemory());
xml.Attribute("LogicalProcessorsPerPhysical",
- info.GetLogicalProcessorsPerPhysical());
+ info.GetLogicalProcessorsPerPhysical());
xml.Attribute("ProcessorClockFrequency", info.GetProcessorClockFrequency());
std::string changeId = this->GetCTestConfiguration("ChangeId");
- if(!changeId.empty())
- {
+ if (!changeId.empty()) {
xml.Attribute("ChangeId", changeId);
- }
+ }
this->AddSiteProperties(xml);
}
@@ -1544,47 +1358,40 @@ void cmCTest::AddSiteProperties(cmXMLWriter& xml)
{
cmCTestScriptHandler* ch =
static_cast<cmCTestScriptHandler*>(this->GetHandler("script"));
- cmake* cm = ch->GetCMake();
+ cmake* cm = ch->GetCMake();
// if no CMake then this is the old style script and props like
// this will not work anyway.
- if(!cm)
- {
+ if (!cm) {
return;
- }
+ }
// This code should go when cdash is changed to use labels only
- const char* subproject = cm->GetState()
- ->GetGlobalProperty("SubProject");
- if(subproject)
- {
+ const char* subproject = cm->GetState()->GetGlobalProperty("SubProject");
+ if (subproject) {
xml.StartElement("Subproject");
xml.Attribute("name", subproject);
const char* labels =
- ch->GetCMake()->GetState()
- ->GetGlobalProperty("SubProjectLabels");
- if(labels)
- {
+ ch->GetCMake()->GetState()->GetGlobalProperty("SubProjectLabels");
+ if (labels) {
xml.StartElement("Labels");
std::string l = labels;
std::vector<std::string> args;
cmSystemTools::ExpandListArgument(l, args);
- for(std::vector<std::string>::iterator i = args.begin();
- i != args.end(); ++i)
- {
+ for (std::vector<std::string>::iterator i = args.begin();
+ i != args.end(); ++i) {
xml.Element("Label", *i);
- }
- xml.EndElement();
}
- xml.EndElement();
+ xml.EndElement();
}
+ xml.EndElement();
+ }
// This code should stay when cdash only does label based sub-projects
const char* label = cm->GetState()->GetGlobalProperty("Label");
- if(label)
- {
+ if (label) {
xml.StartElement("Labels");
xml.Element("Label", label);
xml.EndElement();
- }
+ }
}
void cmCTest::EndXML(cmXMLWriter& xml)
@@ -1594,25 +1401,27 @@ void cmCTest::EndXML(cmXMLWriter& xml)
}
int cmCTest::GenerateCTestNotesOutput(cmXMLWriter& xml,
- const cmCTest::VectorOfStrings& files)
+ const cmCTest::VectorOfStrings& files)
{
- std::string buildname = cmCTest::SafeBuildIdField(
- this->GetCTestConfiguration("BuildName"));
+ std::string buildname =
+ cmCTest::SafeBuildIdField(this->GetCTestConfiguration("BuildName"));
cmCTest::VectorOfStrings::const_iterator it;
xml.StartDocument();
- xml.ProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" "
- "href=\"Dart/Source/Server/XSL/Build.xsl "
- "<file:///Dart/Source/Server/XSL/Build.xsl> \"");
+ xml.ProcessingInstruction("xml-stylesheet",
+ "type=\"text/xsl\" "
+ "href=\"Dart/Source/Server/XSL/Build.xsl "
+ "<file:///Dart/Source/Server/XSL/Build.xsl> \"");
xml.StartElement("Site");
xml.Attribute("BuildName", buildname);
- xml.Attribute("BuildStamp", this->CurrentTag+"-"+this->GetTestModelString());
+ xml.Attribute("BuildStamp",
+ this->CurrentTag + "-" + this->GetTestModelString());
xml.Attribute("Name", this->GetCTestConfiguration("Site"));
- xml.Attribute("Generator",std::string("ctest")+cmVersion::GetCMakeVersion());
+ xml.Attribute("Generator",
+ std::string("ctest") + cmVersion::GetCMakeVersion());
this->AddSiteProperties(xml);
xml.StartElement("Notes");
- for ( it = files.begin(); it != files.end(); it ++ )
- {
+ for (it = files.begin(); it != files.end(); it++) {
cmCTestLog(this, OUTPUT, "\tAdd file: " << *it << std::endl);
std::string note_time = this->CurrentTime();
xml.StartElement("Note");
@@ -1621,39 +1430,34 @@ int cmCTest::GenerateCTestNotesOutput(cmXMLWriter& xml,
xml.Element("DateTime", note_time);
xml.StartElement("Text");
cmsys::ifstream ifs(it->c_str());
- if ( ifs )
- {
+ if (ifs) {
std::string line;
- while ( cmSystemTools::GetLineFromStream(ifs, line) )
- {
+ while (cmSystemTools::GetLineFromStream(ifs, line)) {
xml.Content(line);
xml.Content("\n");
- }
- ifs.close();
}
- else
- {
+ ifs.close();
+ } else {
xml.Content("Problem reading file: " + *it + "\n");
- cmCTestLog(this, ERROR_MESSAGE, "Problem reading file: " << *it
- << " while creating notes" << std::endl);
- }
+ cmCTestLog(this, ERROR_MESSAGE, "Problem reading file: "
+ << *it << " while creating notes" << std::endl);
+ }
xml.EndElement(); // Text
xml.EndElement(); // Note
- }
+ }
xml.EndElement(); // Notes
xml.EndElement(); // Site
xml.EndDocument();
return 1;
}
-int cmCTest::GenerateNotesFile(const VectorOfStrings &files)
+int cmCTest::GenerateNotesFile(const VectorOfStrings& files)
{
cmGeneratedFileStream ofs;
- if ( !this->OpenOutputFile(this->CurrentTag, "Notes.xml", ofs) )
- {
+ if (!this->OpenOutputFile(this->CurrentTag, "Notes.xml", ofs)) {
cmCTestLog(this, ERROR_MESSAGE, "Cannot open notes file" << std::endl);
return 1;
- }
+ }
cmXMLWriter xml(ofs);
this->GenerateCTestNotesOutput(xml, files);
return 0;
@@ -1661,20 +1465,18 @@ int cmCTest::GenerateNotesFile(const VectorOfStrings &files)
int cmCTest::GenerateNotesFile(const char* cfiles)
{
- if ( !cfiles )
- {
+ if (!cfiles) {
return 1;
- }
+ }
VectorOfStrings files;
cmCTestLog(this, OUTPUT, "Create notes file" << std::endl);
files = cmSystemTools::SplitString(cfiles, ';');
- if (files.empty())
- {
+ if (files.empty()) {
return 1;
- }
+ }
return this->GenerateNotesFile(files);
}
@@ -1685,13 +1487,13 @@ std::string cmCTest::Base64GzipEncodeFile(std::string file)
std::vector<std::string> files;
files.push_back(file);
- if(!cmSystemTools::CreateTar(tarFile.c_str(), files,
- cmSystemTools::TarCompressGZip, false))
- {
+ if (!cmSystemTools::CreateTar(tarFile.c_str(), files,
+ cmSystemTools::TarCompressGZip, false)) {
cmCTestLog(this, ERROR_MESSAGE, "Error creating tar while "
- "encoding file: " << file << std::endl);
+ "encoding file: "
+ << file << std::endl);
return "";
- }
+ }
std::string base64 = this->Base64EncodeFile(tarFile);
cmSystemTools::RemoveFile(tarFile);
return base64;
@@ -1702,77 +1504,64 @@ std::string cmCTest::Base64EncodeFile(std::string file)
size_t const len = cmSystemTools::FileLength(file);
cmsys::ifstream ifs(file.c_str(), std::ios::in
#ifdef _WIN32
- | std::ios::binary
+ | std::ios::binary
#endif
- );
- unsigned char *file_buffer = new unsigned char [ len + 1 ];
+ );
+ unsigned char* file_buffer = new unsigned char[len + 1];
ifs.read(reinterpret_cast<char*>(file_buffer), len);
ifs.close();
- unsigned char *encoded_buffer
- = new unsigned char [ (len * 3) / 2 + 5 ];
+ unsigned char* encoded_buffer = new unsigned char[(len * 3) / 2 + 5];
- size_t const rlen
- = cmsysBase64_Encode(file_buffer, len, encoded_buffer, 1);
+ size_t const rlen = cmsysBase64_Encode(file_buffer, len, encoded_buffer, 1);
std::string base64 = "";
- for(size_t i = 0; i < rlen; i++)
- {
+ for (size_t i = 0; i < rlen; i++) {
base64 += encoded_buffer[i];
- }
- delete [] file_buffer;
- delete [] encoded_buffer;
+ }
+ delete[] file_buffer;
+ delete[] encoded_buffer;
return base64;
}
-
-bool cmCTest::SubmitExtraFiles(const VectorOfStrings &files)
+bool cmCTest::SubmitExtraFiles(const VectorOfStrings& files)
{
VectorOfStrings::const_iterator it;
- for ( it = files.begin();
- it != files.end();
- ++ it )
- {
- if ( !cmSystemTools::FileExists(it->c_str()) )
- {
+ for (it = files.begin(); it != files.end(); ++it) {
+ if (!cmSystemTools::FileExists(it->c_str())) {
cmCTestLog(this, ERROR_MESSAGE, "Cannot find extra file: "
- << *it << " to submit."
- << std::endl;);
+ << *it << " to submit." << std::endl;);
return false;
- }
- this->AddSubmitFile(PartExtraFiles, it->c_str());
}
+ this->AddSubmitFile(PartExtraFiles, it->c_str());
+ }
return true;
}
bool cmCTest::SubmitExtraFiles(const char* cfiles)
{
- if ( !cfiles )
- {
+ if (!cfiles) {
return 1;
- }
+ }
VectorOfStrings files;
cmCTestLog(this, OUTPUT, "Submit extra files" << std::endl);
files = cmSystemTools::SplitString(cfiles, ';');
- if (files.empty())
- {
+ if (files.empty()) {
return 1;
- }
+ }
return this->SubmitExtraFiles(files);
}
-
// for a -D argument convert the next argument into
// the proper list of dashboard steps via SetTest
-bool cmCTest::AddTestsForDashboardType(std::string &targ)
+bool cmCTest::AddTestsForDashboardType(std::string& targ)
{
- if ( targ == "Experimental" )
- {
+ if (targ == "Experimental") {
this->SetTestModel(cmCTest::EXPERIMENTAL);
this->SetTest("Start");
this->SetTest("Configure");
@@ -1780,50 +1569,31 @@ bool cmCTest::AddTestsForDashboardType(std::string &targ)
this->SetTest("Test");
this->SetTest("Coverage");
this->SetTest("Submit");
- }
- else if ( targ == "ExperimentalStart" )
- {
+ } else if (targ == "ExperimentalStart") {
this->SetTestModel(cmCTest::EXPERIMENTAL);
this->SetTest("Start");
- }
- else if ( targ == "ExperimentalUpdate" )
- {
+ } else if (targ == "ExperimentalUpdate") {
this->SetTestModel(cmCTest::EXPERIMENTAL);
this->SetTest("Update");
- }
- else if ( targ == "ExperimentalConfigure" )
- {
+ } else if (targ == "ExperimentalConfigure") {
this->SetTestModel(cmCTest::EXPERIMENTAL);
this->SetTest("Configure");
- }
- else if ( targ == "ExperimentalBuild" )
- {
+ } else if (targ == "ExperimentalBuild") {
this->SetTestModel(cmCTest::EXPERIMENTAL);
this->SetTest("Build");
- }
- else if ( targ == "ExperimentalTest" )
- {
+ } else if (targ == "ExperimentalTest") {
this->SetTestModel(cmCTest::EXPERIMENTAL);
this->SetTest("Test");
- }
- else if ( targ == "ExperimentalMemCheck"
- || targ == "ExperimentalPurify" )
- {
+ } else if (targ == "ExperimentalMemCheck" || targ == "ExperimentalPurify") {
this->SetTestModel(cmCTest::EXPERIMENTAL);
this->SetTest("MemCheck");
- }
- else if ( targ == "ExperimentalCoverage" )
- {
+ } else if (targ == "ExperimentalCoverage") {
this->SetTestModel(cmCTest::EXPERIMENTAL);
this->SetTest("Coverage");
- }
- else if ( targ == "ExperimentalSubmit" )
- {
+ } else if (targ == "ExperimentalSubmit") {
this->SetTestModel(cmCTest::EXPERIMENTAL);
this->SetTest("Submit");
- }
- else if ( targ == "Continuous" )
- {
+ } else if (targ == "Continuous") {
this->SetTestModel(cmCTest::CONTINUOUS);
this->SetTest("Start");
this->SetTest("Update");
@@ -1832,50 +1602,31 @@ bool cmCTest::AddTestsForDashboardType(std::string &targ)
this->SetTest("Test");
this->SetTest("Coverage");
this->SetTest("Submit");
- }
- else if ( targ == "ContinuousStart" )
- {
+ } else if (targ == "ContinuousStart") {
this->SetTestModel(cmCTest::CONTINUOUS);
this->SetTest("Start");
- }
- else if ( targ == "ContinuousUpdate" )
- {
+ } else if (targ == "ContinuousUpdate") {
this->SetTestModel(cmCTest::CONTINUOUS);
this->SetTest("Update");
- }
- else if ( targ == "ContinuousConfigure" )
- {
+ } else if (targ == "ContinuousConfigure") {
this->SetTestModel(cmCTest::CONTINUOUS);
this->SetTest("Configure");
- }
- else if ( targ == "ContinuousBuild" )
- {
+ } else if (targ == "ContinuousBuild") {
this->SetTestModel(cmCTest::CONTINUOUS);
this->SetTest("Build");
- }
- else if ( targ == "ContinuousTest" )
- {
+ } else if (targ == "ContinuousTest") {
this->SetTestModel(cmCTest::CONTINUOUS);
this->SetTest("Test");
- }
- else if ( targ == "ContinuousMemCheck"
- || targ == "ContinuousPurify" )
- {
+ } else if (targ == "ContinuousMemCheck" || targ == "ContinuousPurify") {
this->SetTestModel(cmCTest::CONTINUOUS);
this->SetTest("MemCheck");
- }
- else if ( targ == "ContinuousCoverage" )
- {
+ } else if (targ == "ContinuousCoverage") {
this->SetTestModel(cmCTest::CONTINUOUS);
this->SetTest("Coverage");
- }
- else if ( targ == "ContinuousSubmit" )
- {
+ } else if (targ == "ContinuousSubmit") {
this->SetTestModel(cmCTest::CONTINUOUS);
this->SetTest("Submit");
- }
- else if ( targ == "Nightly" )
- {
+ } else if (targ == "Nightly") {
this->SetTestModel(cmCTest::NIGHTLY);
this->SetTest("Start");
this->SetTest("Update");
@@ -1884,50 +1635,31 @@ bool cmCTest::AddTestsForDashboardType(std::string &targ)
this->SetTest("Test");
this->SetTest("Coverage");
this->SetTest("Submit");
- }
- else if ( targ == "NightlyStart" )
- {
+ } else if (targ == "NightlyStart") {
this->SetTestModel(cmCTest::NIGHTLY);
this->SetTest("Start");
- }
- else if ( targ == "NightlyUpdate" )
- {
+ } else if (targ == "NightlyUpdate") {
this->SetTestModel(cmCTest::NIGHTLY);
this->SetTest("Update");
- }
- else if ( targ == "NightlyConfigure" )
- {
+ } else if (targ == "NightlyConfigure") {
this->SetTestModel(cmCTest::NIGHTLY);
this->SetTest("Configure");
- }
- else if ( targ == "NightlyBuild" )
- {
+ } else if (targ == "NightlyBuild") {
this->SetTestModel(cmCTest::NIGHTLY);
this->SetTest("Build");
- }
- else if ( targ == "NightlyTest" )
- {
+ } else if (targ == "NightlyTest") {
this->SetTestModel(cmCTest::NIGHTLY);
this->SetTest("Test");
- }
- else if ( targ == "NightlyMemCheck"
- || targ == "NightlyPurify" )
- {
+ } else if (targ == "NightlyMemCheck" || targ == "NightlyPurify") {
this->SetTestModel(cmCTest::NIGHTLY);
this->SetTest("MemCheck");
- }
- else if ( targ == "NightlyCoverage" )
- {
+ } else if (targ == "NightlyCoverage") {
this->SetTestModel(cmCTest::NIGHTLY);
this->SetTest("Coverage");
- }
- else if ( targ == "NightlySubmit" )
- {
+ } else if (targ == "NightlySubmit") {
this->SetTestModel(cmCTest::NIGHTLY);
this->SetTest("Submit");
- }
- else if ( targ == "MemoryCheck" )
- {
+ } else if (targ == "MemoryCheck") {
this->SetTestModel(cmCTest::EXPERIMENTAL);
this->SetTest("Start");
this->SetTest("Configure");
@@ -1935,9 +1667,7 @@ bool cmCTest::AddTestsForDashboardType(std::string &targ)
this->SetTest("MemCheck");
this->SetTest("Coverage");
this->SetTest("Submit");
- }
- else if ( targ == "NightlyMemoryCheck" )
- {
+ } else if (targ == "NightlyMemoryCheck") {
this->SetTestModel(cmCTest::NIGHTLY);
this->SetTest("Start");
this->SetTest("Update");
@@ -1946,391 +1676,326 @@ bool cmCTest::AddTestsForDashboardType(std::string &targ)
this->SetTest("MemCheck");
this->SetTest("Coverage");
this->SetTest("Submit");
- }
- else
- {
+ } else {
return false;
- }
+ }
return true;
}
-
-void cmCTest::ErrorMessageUnknownDashDValue(std::string &val)
+void cmCTest::ErrorMessageUnknownDashDValue(std::string& val)
{
cmCTestLog(this, ERROR_MESSAGE,
- "CTest -D called with incorrect option: " << val << std::endl);
+ "CTest -D called with incorrect option: " << val << std::endl);
- cmCTestLog(this, ERROR_MESSAGE,
- "Available options are:" << std::endl
- << " ctest -D Continuous" << std::endl
- << " ctest -D Continuous(Start|Update|Configure|Build)" << std::endl
- << " ctest -D Continuous(Test|Coverage|MemCheck|Submit)" << std::endl
- << " ctest -D Experimental" << std::endl
- << " ctest -D Experimental(Start|Update|Configure|Build)" << std::endl
- << " ctest -D Experimental(Test|Coverage|MemCheck|Submit)" << std::endl
- << " ctest -D Nightly" << std::endl
- << " ctest -D Nightly(Start|Update|Configure|Build)" << std::endl
- << " ctest -D Nightly(Test|Coverage|MemCheck|Submit)" << std::endl
- << " ctest -D NightlyMemoryCheck" << std::endl);
+ cmCTestLog(
+ this, ERROR_MESSAGE, "Available options are:"
+ << std::endl
+ << " ctest -D Continuous" << std::endl
+ << " ctest -D Continuous(Start|Update|Configure|Build)" << std::endl
+ << " ctest -D Continuous(Test|Coverage|MemCheck|Submit)" << std::endl
+ << " ctest -D Experimental" << std::endl
+ << " ctest -D Experimental(Start|Update|Configure|Build)" << std::endl
+ << " ctest -D Experimental(Test|Coverage|MemCheck|Submit)" << std::endl
+ << " ctest -D Nightly" << std::endl
+ << " ctest -D Nightly(Start|Update|Configure|Build)" << std::endl
+ << " ctest -D Nightly(Test|Coverage|MemCheck|Submit)" << std::endl
+ << " ctest -D NightlyMemoryCheck" << std::endl);
}
-
bool cmCTest::CheckArgument(const std::string& arg, const char* varg1,
- const char* varg2)
+ const char* varg2)
{
return (varg1 && arg == varg1) || (varg2 && arg == varg2);
}
-
// Processes one command line argument (and its arguments if any)
// for many simple options and then returns
-bool cmCTest::HandleCommandLineArguments(size_t &i,
- std::vector<std::string> &args,
+bool cmCTest::HandleCommandLineArguments(size_t& i,
+ std::vector<std::string>& args,
std::string& errormsg)
{
std::string arg = args[i];
- if(this->CheckArgument(arg, "-F"))
- {
+ if (this->CheckArgument(arg, "-F")) {
this->Failover = true;
- }
- if(this->CheckArgument(arg, "-j", "--parallel") && i < args.size() - 1)
- {
+ }
+ if (this->CheckArgument(arg, "-j", "--parallel") && i < args.size() - 1) {
i++;
int plevel = atoi(args[i].c_str());
this->SetParallelLevel(plevel);
this->ParallelLevelSetInCli = true;
- }
- else if(arg.find("-j") == 0)
- {
+ } else if (arg.find("-j") == 0) {
int plevel = atoi(arg.substr(2).c_str());
this->SetParallelLevel(plevel);
this->ParallelLevelSetInCli = true;
- }
- if(this->CheckArgument(arg, "--repeat-until-fail"))
- {
- if( i >= args.size() - 1)
- {
+ }
+ if (this->CheckArgument(arg, "--repeat-until-fail")) {
+ if (i >= args.size() - 1) {
errormsg = "'--repeat-until-fail' requires an argument";
return false;
- }
+ }
i++;
long repeat = 1;
- if(!cmSystemTools::StringToLong(args[i].c_str(), &repeat))
- {
- errormsg = "'--repeat-until-fail' given non-integer value '"
- + args[i] + "'";
+ if (!cmSystemTools::StringToLong(args[i].c_str(), &repeat)) {
+ errormsg =
+ "'--repeat-until-fail' given non-integer value '" + args[i] + "'";
return false;
- }
+ }
this->RepeatTests = static_cast<int>(repeat);
- if(repeat > 1)
- {
+ if (repeat > 1) {
this->RepeatUntilFail = true;
- }
}
+ }
- if(this->CheckArgument(arg, "--test-load") && i < args.size() - 1)
- {
+ if (this->CheckArgument(arg, "--test-load") && i < args.size() - 1) {
i++;
unsigned long load;
- if (cmSystemTools::StringToULong(args[i].c_str(), &load))
- {
+ if (cmSystemTools::StringToULong(args[i].c_str(), &load)) {
this->SetTestLoad(load);
- }
- else
- {
+ } else {
cmCTestLog(this, WARNING,
"Invalid value for 'Test Load' : " << args[i] << std::endl);
- }
}
+ }
- if(this->CheckArgument(arg, "--no-compress-output"))
- {
+ if (this->CheckArgument(arg, "--no-compress-output")) {
this->CompressTestOutput = false;
this->CompressMemCheckOutput = false;
- }
+ }
- if(this->CheckArgument(arg, "--print-labels"))
- {
+ if (this->CheckArgument(arg, "--print-labels")) {
this->PrintLabels = true;
- }
+ }
- if(this->CheckArgument(arg, "--http1.0"))
- {
+ if (this->CheckArgument(arg, "--http1.0")) {
this->UseHTTP10 = true;
- }
+ }
- if(this->CheckArgument(arg, "--timeout") && i < args.size() - 1)
- {
+ if (this->CheckArgument(arg, "--timeout") && i < args.size() - 1) {
i++;
double timeout = (double)atof(args[i].c_str());
this->GlobalTimeout = timeout;
- }
+ }
- if(this->CheckArgument(arg, "--stop-time") && i < args.size() - 1)
- {
+ if (this->CheckArgument(arg, "--stop-time") && i < args.size() - 1) {
i++;
this->SetStopTime(args[i]);
- }
+ }
- if(this->CheckArgument(arg, "-C", "--build-config") &&
- i < args.size() - 1)
- {
+ if (this->CheckArgument(arg, "-C", "--build-config") &&
+ i < args.size() - 1) {
i++;
this->SetConfigType(args[i].c_str());
- }
+ }
- if(this->CheckArgument(arg, "--debug"))
- {
+ if (this->CheckArgument(arg, "--debug")) {
this->Debug = true;
this->ShowLineNumbers = true;
- }
- if(this->CheckArgument(arg, "--track") && i < args.size() - 1)
- {
+ }
+ if (this->CheckArgument(arg, "--track") && i < args.size() - 1) {
i++;
this->SpecificTrack = args[i];
- }
- if(this->CheckArgument(arg, "--show-line-numbers"))
- {
+ }
+ if (this->CheckArgument(arg, "--show-line-numbers")) {
this->ShowLineNumbers = true;
- }
- if(this->CheckArgument(arg, "--no-label-summary"))
- {
+ }
+ if (this->CheckArgument(arg, "--no-label-summary")) {
this->LabelSummary = false;
- }
- if(this->CheckArgument(arg, "-Q", "--quiet"))
- {
+ }
+ if (this->CheckArgument(arg, "-Q", "--quiet")) {
this->Quiet = true;
- }
- if(this->CheckArgument(arg, "-V", "--verbose"))
- {
+ }
+ if (this->CheckArgument(arg, "-V", "--verbose")) {
this->Verbose = true;
- }
- if(this->CheckArgument(arg, "-B"))
- {
+ }
+ if (this->CheckArgument(arg, "-B")) {
this->BatchJobs = true;
- }
- if(this->CheckArgument(arg, "-VV", "--extra-verbose"))
- {
+ }
+ if (this->CheckArgument(arg, "-VV", "--extra-verbose")) {
this->ExtraVerbose = true;
this->Verbose = true;
- }
- if(this->CheckArgument(arg, "--output-on-failure"))
- {
+ }
+ if (this->CheckArgument(arg, "--output-on-failure")) {
this->OutputTestOutputOnTestFailure = true;
- }
+ }
if (this->CheckArgument(arg, "--test-output-size-passed") &&
- i < args.size() - 1)
- {
+ i < args.size() - 1) {
i++;
long outputSize;
- if (cmSystemTools::StringToLong(args[i].c_str(), &outputSize))
- {
- if (cmCTestTestHandler *pCTestTestHandler =
- static_cast<cmCTestTestHandler*>(this->TestingHandlers["test"]))
- {
+ if (cmSystemTools::StringToLong(args[i].c_str(), &outputSize)) {
+ if (cmCTestTestHandler* pCTestTestHandler =
+ static_cast<cmCTestTestHandler*>(this->TestingHandlers["test"])) {
pCTestTestHandler->SetTestOutputSizePassed(int(outputSize));
- }
}
- else
- {
+ } else {
cmCTestLog(this, WARNING,
- "Invalid value for '--test-output-size-passed': " <<
- args[i] << "\n");
- }
+ "Invalid value for '--test-output-size-passed': " << args[i]
+ << "\n");
}
+ }
if (this->CheckArgument(arg, "--test-output-size-failed") &&
- i < args.size() - 1)
- {
+ i < args.size() - 1) {
i++;
long outputSize;
- if (cmSystemTools::StringToLong(args[i].c_str(), &outputSize))
- {
- if (cmCTestTestHandler *pCTestTestHandler =
- static_cast<cmCTestTestHandler*>(this->TestingHandlers["test"]))
- {
+ if (cmSystemTools::StringToLong(args[i].c_str(), &outputSize)) {
+ if (cmCTestTestHandler* pCTestTestHandler =
+ static_cast<cmCTestTestHandler*>(this->TestingHandlers["test"])) {
pCTestTestHandler->SetTestOutputSizeFailed(int(outputSize));
- }
}
- else
- {
+ } else {
cmCTestLog(this, WARNING,
- "Invalid value for '--test-output-size-failed': " <<
- args[i] << "\n");
- }
+ "Invalid value for '--test-output-size-failed': " << args[i]
+ << "\n");
}
- if(this->CheckArgument(arg, "-N", "--show-only"))
- {
+ }
+ if (this->CheckArgument(arg, "-N", "--show-only")) {
this->ShowOnly = true;
- }
+ }
- if(this->CheckArgument(arg, "-O", "--output-log") && i < args.size() - 1 )
- {
+ if (this->CheckArgument(arg, "-O", "--output-log") && i < args.size() - 1) {
i++;
this->SetOutputLogFileName(args[i].c_str());
- }
+ }
- if(this->CheckArgument(arg, "--tomorrow-tag"))
- {
+ if (this->CheckArgument(arg, "--tomorrow-tag")) {
this->TomorrowTag = true;
- }
- if(this->CheckArgument(arg, "--force-new-ctest-process"))
- {
+ }
+ if (this->CheckArgument(arg, "--force-new-ctest-process")) {
this->ForceNewCTestProcess = true;
- }
- if(this->CheckArgument(arg, "-W", "--max-width") && i < args.size() - 1)
- {
+ }
+ if (this->CheckArgument(arg, "-W", "--max-width") && i < args.size() - 1) {
i++;
this->MaxTestNameWidth = atoi(args[i].c_str());
- }
- if(this->CheckArgument(arg, "--interactive-debug-mode") &&
- i < args.size() - 1 )
- {
+ }
+ if (this->CheckArgument(arg, "--interactive-debug-mode") &&
+ i < args.size() - 1) {
i++;
this->InteractiveDebugMode = cmSystemTools::IsOn(args[i].c_str());
- }
- if(this->CheckArgument(arg, "--submit-index") && i < args.size() - 1 )
- {
+ }
+ if (this->CheckArgument(arg, "--submit-index") && i < args.size() - 1) {
i++;
this->SubmitIndex = atoi(args[i].c_str());
- if ( this->SubmitIndex < 0 )
- {
+ if (this->SubmitIndex < 0) {
this->SubmitIndex = 0;
- }
}
+ }
- if(this->CheckArgument(arg, "--overwrite") && i < args.size() - 1)
- {
+ if (this->CheckArgument(arg, "--overwrite") && i < args.size() - 1) {
i++;
this->AddCTestConfigurationOverwrite(args[i]);
- }
- if(this->CheckArgument(arg, "-A", "--add-notes") && i < args.size() - 1)
- {
+ }
+ if (this->CheckArgument(arg, "-A", "--add-notes") && i < args.size() - 1) {
this->ProduceXML = true;
this->SetTest("Notes");
i++;
this->SetNotesFiles(args[i].c_str());
- }
+ }
// options that control what tests are run
- if(this->CheckArgument(arg, "-I", "--tests-information") &&
- i < args.size() - 1)
- {
+ if (this->CheckArgument(arg, "-I", "--tests-information") &&
+ i < args.size() - 1) {
i++;
this->GetHandler("test")->SetPersistentOption("TestsToRunInformation",
args[i].c_str());
- this->GetHandler("memcheck")->
- SetPersistentOption("TestsToRunInformation",args[i].c_str());
- }
- if(this->CheckArgument(arg, "-U", "--union"))
- {
+ this->GetHandler("memcheck")
+ ->SetPersistentOption("TestsToRunInformation", args[i].c_str());
+ }
+ if (this->CheckArgument(arg, "-U", "--union")) {
this->GetHandler("test")->SetPersistentOption("UseUnion", "true");
this->GetHandler("memcheck")->SetPersistentOption("UseUnion", "true");
- }
- if(this->CheckArgument(arg, "-R", "--tests-regex") && i < args.size() - 1)
- {
+ }
+ if (this->CheckArgument(arg, "-R", "--tests-regex") && i < args.size() - 1) {
i++;
- this->GetHandler("test")->
- SetPersistentOption("IncludeRegularExpression", args[i].c_str());
- this->GetHandler("memcheck")->
- SetPersistentOption("IncludeRegularExpression", args[i].c_str());
- }
- if(this->CheckArgument(arg, "-L", "--label-regex") && i < args.size() - 1)
- {
+ this->GetHandler("test")->SetPersistentOption("IncludeRegularExpression",
+ args[i].c_str());
+ this->GetHandler("memcheck")
+ ->SetPersistentOption("IncludeRegularExpression", args[i].c_str());
+ }
+ if (this->CheckArgument(arg, "-L", "--label-regex") && i < args.size() - 1) {
i++;
- this->GetHandler("test")->
- SetPersistentOption("LabelRegularExpression", args[i].c_str());
- this->GetHandler("memcheck")->
- SetPersistentOption("LabelRegularExpression", args[i].c_str());
- }
- if(this->CheckArgument(arg, "-LE", "--label-exclude") && i < args.size() - 1)
- {
+ this->GetHandler("test")->SetPersistentOption("LabelRegularExpression",
+ args[i].c_str());
+ this->GetHandler("memcheck")
+ ->SetPersistentOption("LabelRegularExpression", args[i].c_str());
+ }
+ if (this->CheckArgument(arg, "-LE", "--label-exclude") &&
+ i < args.size() - 1) {
i++;
- this->GetHandler("test")->
- SetPersistentOption("ExcludeLabelRegularExpression", args[i].c_str());
- this->GetHandler("memcheck")->
- SetPersistentOption("ExcludeLabelRegularExpression", args[i].c_str());
- }
+ this->GetHandler("test")->SetPersistentOption(
+ "ExcludeLabelRegularExpression", args[i].c_str());
+ this->GetHandler("memcheck")
+ ->SetPersistentOption("ExcludeLabelRegularExpression", args[i].c_str());
+ }
- if(this->CheckArgument(arg, "-E", "--exclude-regex") &&
- i < args.size() - 1)
- {
+ if (this->CheckArgument(arg, "-E", "--exclude-regex") &&
+ i < args.size() - 1) {
i++;
- this->GetHandler("test")->
- SetPersistentOption("ExcludeRegularExpression", args[i].c_str());
- this->GetHandler("memcheck")->
- SetPersistentOption("ExcludeRegularExpression", args[i].c_str());
- }
+ this->GetHandler("test")->SetPersistentOption("ExcludeRegularExpression",
+ args[i].c_str());
+ this->GetHandler("memcheck")
+ ->SetPersistentOption("ExcludeRegularExpression", args[i].c_str());
+ }
- if(this->CheckArgument(arg, "--rerun-failed"))
- {
+ if (this->CheckArgument(arg, "--rerun-failed")) {
this->GetHandler("test")->SetPersistentOption("RerunFailed", "true");
this->GetHandler("memcheck")->SetPersistentOption("RerunFailed", "true");
- }
+ }
return true;
}
// handle the -S -SR and -SP arguments
-void cmCTest::HandleScriptArguments(size_t &i,
- std::vector<std::string> &args,
- bool &SRArgumentSpecified)
+void cmCTest::HandleScriptArguments(size_t& i, std::vector<std::string>& args,
+ bool& SRArgumentSpecified)
{
std::string arg = args[i];
- if(this->CheckArgument(arg, "-SP", "--script-new-process") &&
- i < args.size() - 1 )
- {
+ if (this->CheckArgument(arg, "-SP", "--script-new-process") &&
+ i < args.size() - 1) {
this->RunConfigurationScript = true;
i++;
- cmCTestScriptHandler* ch
- = static_cast<cmCTestScriptHandler*>(this->GetHandler("script"));
+ cmCTestScriptHandler* ch =
+ static_cast<cmCTestScriptHandler*>(this->GetHandler("script"));
// -SR is an internal argument, -SP should be ignored when it is passed
- if (!SRArgumentSpecified)
- {
- ch->AddConfigurationScript(args[i].c_str(),false);
- }
+ if (!SRArgumentSpecified) {
+ ch->AddConfigurationScript(args[i].c_str(), false);
}
+ }
- if(this->CheckArgument(arg, "-SR", "--script-run") &&
- i < args.size() - 1 )
- {
+ if (this->CheckArgument(arg, "-SR", "--script-run") && i < args.size() - 1) {
SRArgumentSpecified = true;
this->RunConfigurationScript = true;
i++;
- cmCTestScriptHandler* ch
- = static_cast<cmCTestScriptHandler*>(this->GetHandler("script"));
- ch->AddConfigurationScript(args[i].c_str(),true);
- }
+ cmCTestScriptHandler* ch =
+ static_cast<cmCTestScriptHandler*>(this->GetHandler("script"));
+ ch->AddConfigurationScript(args[i].c_str(), true);
+ }
- if(this->CheckArgument(arg, "-S", "--script") && i < args.size() - 1 )
- {
+ if (this->CheckArgument(arg, "-S", "--script") && i < args.size() - 1) {
this->RunConfigurationScript = true;
i++;
- cmCTestScriptHandler* ch
- = static_cast<cmCTestScriptHandler*>(this->GetHandler("script"));
+ cmCTestScriptHandler* ch =
+ static_cast<cmCTestScriptHandler*>(this->GetHandler("script"));
// -SR is an internal argument, -S should be ignored when it is passed
- if (!SRArgumentSpecified)
- {
- ch->AddConfigurationScript(args[i].c_str(),true);
- }
+ if (!SRArgumentSpecified) {
+ ch->AddConfigurationScript(args[i].c_str(), true);
}
+ }
}
-bool cmCTest::AddVariableDefinition(const std::string &arg)
+bool cmCTest::AddVariableDefinition(const std::string& arg)
{
std::string name;
std::string value;
cmState::CacheEntryType type = cmState::UNINITIALIZED;
- if (cmake::ParseCacheEntry(arg, name, value, type))
- {
+ if (cmake::ParseCacheEntry(arg, name, value, type)) {
this->Definitions[name] = value;
return true;
- }
+ }
return false;
}
// the main entry point of ctest, called from main
-int cmCTest::Run(std::vector<std::string> &args, std::string* output)
+int cmCTest::Run(std::vector<std::string>& args, std::string* output)
{
const char* ctestExec = "ctest";
bool cmakeAndTest = false;
@@ -2339,161 +2004,136 @@ int cmCTest::Run(std::vector<std::string> &args, std::string* output)
// copy the command line
this->InitialCommandLineArguments.insert(
- this->InitialCommandLineArguments.end(),
- args.begin(), args.end());
+ this->InitialCommandLineArguments.end(), args.begin(), args.end());
// process the command line arguments
- for(size_t i=1; i < args.size(); ++i)
- {
+ for (size_t i = 1; i < args.size(); ++i) {
// handle the simple commandline arguments
std::string errormsg;
- if(!this->HandleCommandLineArguments(i,args, errormsg))
- {
+ if (!this->HandleCommandLineArguments(i, args, errormsg)) {
cmSystemTools::Error(errormsg.c_str());
return 1;
- }
+ }
// handle the script arguments -S -SR -SP
- this->HandleScriptArguments(i,args,SRArgumentSpecified);
+ this->HandleScriptArguments(i, args, SRArgumentSpecified);
// handle a request for a dashboard
std::string arg = args[i];
- if(this->CheckArgument(arg, "-D", "--dashboard") && i < args.size() - 1 )
- {
+ if (this->CheckArgument(arg, "-D", "--dashboard") && i < args.size() - 1) {
this->ProduceXML = true;
i++;
std::string targ = args[i];
// AddTestsForDashboard parses the dashboard type and converts it
// into the separate stages
- if (!this->AddTestsForDashboardType(targ))
- {
- if (!this->AddVariableDefinition(targ))
- {
+ if (!this->AddTestsForDashboardType(targ)) {
+ if (!this->AddVariableDefinition(targ)) {
this->ErrorMessageUnknownDashDValue(targ);
executeTests = false;
- }
}
}
+ }
// If it's not exactly -D, but it starts with -D, then try to parse out
// a variable definition from it, same as CMake does. Unsuccessful
// attempts are simply ignored since previous ctest versions ignore
// this too. (As well as many other unknown command line args.)
//
- if(arg != "-D" && cmSystemTools::StringStartsWith(arg.c_str(), "-D"))
- {
+ if (arg != "-D" && cmSystemTools::StringStartsWith(arg.c_str(), "-D")) {
std::string input = arg.substr(2);
this->AddVariableDefinition(input);
- }
+ }
- if(this->CheckArgument(arg, "-T", "--test-action") &&
- (i < args.size() -1) )
- {
+ if (this->CheckArgument(arg, "-T", "--test-action") &&
+ (i < args.size() - 1)) {
this->ProduceXML = true;
i++;
- if ( !this->SetTest(args[i].c_str(), false) )
- {
+ if (!this->SetTest(args[i].c_str(), false)) {
executeTests = false;
cmCTestLog(this, ERROR_MESSAGE,
- "CTest -T called with incorrect option: "
- << args[i] << std::endl);
- cmCTestLog(this, ERROR_MESSAGE, "Available options are:" << std::endl
- << " " << ctestExec << " -T all" << std::endl
- << " " << ctestExec << " -T start" << std::endl
- << " " << ctestExec << " -T update" << std::endl
- << " " << ctestExec << " -T configure" << std::endl
- << " " << ctestExec << " -T build" << std::endl
- << " " << ctestExec << " -T test" << std::endl
- << " " << ctestExec << " -T coverage" << std::endl
- << " " << ctestExec << " -T memcheck" << std::endl
- << " " << ctestExec << " -T notes" << std::endl
- << " " << ctestExec << " -T submit" << std::endl);
- }
+ "CTest -T called with incorrect option: " << args[i]
+ << std::endl);
+ cmCTestLog(this, ERROR_MESSAGE, "Available options are:"
+ << std::endl
+ << " " << ctestExec << " -T all" << std::endl
+ << " " << ctestExec << " -T start" << std::endl
+ << " " << ctestExec << " -T update" << std::endl
+ << " " << ctestExec << " -T configure" << std::endl
+ << " " << ctestExec << " -T build" << std::endl
+ << " " << ctestExec << " -T test" << std::endl
+ << " " << ctestExec << " -T coverage" << std::endl
+ << " " << ctestExec << " -T memcheck" << std::endl
+ << " " << ctestExec << " -T notes" << std::endl
+ << " " << ctestExec << " -T submit" << std::endl);
}
+ }
// what type of test model
- if(this->CheckArgument(arg, "-M", "--test-model") &&
- (i < args.size() -1) )
- {
+ if (this->CheckArgument(arg, "-M", "--test-model") &&
+ (i < args.size() - 1)) {
i++;
std::string const& str = args[i];
- if ( cmSystemTools::LowerCase(str) == "nightly" )
- {
+ if (cmSystemTools::LowerCase(str) == "nightly") {
this->SetTestModel(cmCTest::NIGHTLY);
- }
- else if ( cmSystemTools::LowerCase(str) == "continuous" )
- {
+ } else if (cmSystemTools::LowerCase(str) == "continuous") {
this->SetTestModel(cmCTest::CONTINUOUS);
- }
- else if ( cmSystemTools::LowerCase(str) == "experimental" )
- {
+ } else if (cmSystemTools::LowerCase(str) == "experimental") {
this->SetTestModel(cmCTest::EXPERIMENTAL);
- }
- else
- {
+ } else {
executeTests = false;
cmCTestLog(this, ERROR_MESSAGE,
- "CTest -M called with incorrect option: " << str
- << std::endl);
- cmCTestLog(this, ERROR_MESSAGE, "Available options are:" << std::endl
- << " " << ctestExec << " -M Continuous" << std::endl
- << " " << ctestExec << " -M Experimental" << std::endl
- << " " << ctestExec << " -M Nightly" << std::endl);
- }
+ "CTest -M called with incorrect option: " << str
+ << std::endl);
+ cmCTestLog(this, ERROR_MESSAGE, "Available options are:"
+ << std::endl
+ << " " << ctestExec << " -M Continuous" << std::endl
+ << " " << ctestExec << " -M Experimental" << std::endl
+ << " " << ctestExec << " -M Nightly" << std::endl);
}
+ }
- if(this->CheckArgument(arg, "--extra-submit") && i < args.size() - 1)
- {
+ if (this->CheckArgument(arg, "--extra-submit") && i < args.size() - 1) {
this->ProduceXML = true;
this->SetTest("Submit");
i++;
- if ( !this->SubmitExtraFiles(args[i].c_str()) )
- {
+ if (!this->SubmitExtraFiles(args[i].c_str())) {
return 0;
- }
}
+ }
// --build-and-test options
- if(this->CheckArgument(arg, "--build-and-test") && i < args.size() - 1)
- {
+ if (this->CheckArgument(arg, "--build-and-test") && i < args.size() - 1) {
cmakeAndTest = true;
- }
+ }
- if(this->CheckArgument(arg, "--schedule-random"))
- {
+ if (this->CheckArgument(arg, "--schedule-random")) {
this->ScheduleType = "Random";
- }
+ }
// pass the argument to all the handlers as well, but i may no longer be
// set to what it was originally so I'm not sure this is working as
// intended
cmCTest::t_TestingHandlers::iterator it;
- for ( it = this->TestingHandlers.begin();
- it != this->TestingHandlers.end();
- ++ it )
- {
- if ( !it->second->ProcessCommandLineArguments(arg, i, args) )
- {
+ for (it = this->TestingHandlers.begin(); it != this->TestingHandlers.end();
+ ++it) {
+ if (!it->second->ProcessCommandLineArguments(arg, i, args)) {
cmCTestLog(this, ERROR_MESSAGE,
- "Problem parsing command line arguments within a handler");
+ "Problem parsing command line arguments within a handler");
return 0;
- }
}
- } // the close of the for argument loop
+ }
+ } // the close of the for argument loop
- if (!this->ParallelLevelSetInCli)
- {
- if (const char *parallel = cmSystemTools::GetEnv("CTEST_PARALLEL_LEVEL"))
- {
+ if (!this->ParallelLevelSetInCli) {
+ if (const char* parallel = cmSystemTools::GetEnv("CTEST_PARALLEL_LEVEL")) {
int plevel = atoi(parallel);
this->SetParallelLevel(plevel);
- }
}
+ }
// now what sould cmake do? if --build-and-test was specified then
// we run the build and test handler and return
- if(cmakeAndTest)
- {
+ if (cmakeAndTest) {
this->Verbose = true;
cmCTestBuildAndTestHandler* handler =
static_cast<cmCTestBuildAndTestHandler*>(this->GetHandler("buildtest"));
@@ -2502,85 +2142,69 @@ int cmCTest::Run(std::vector<std::string> &args, std::string* output)
#ifdef CMAKE_BUILD_WITH_CMAKE
cmDynamicLoader::FlushCache();
#endif
- if(retv != 0)
- {
- cmCTestLog(this, DEBUG, "build and test failing returning: " << retv
- << std::endl);
- }
- return retv;
+ if (retv != 0) {
+ cmCTestLog(this, DEBUG,
+ "build and test failing returning: " << retv << std::endl);
}
+ return retv;
+ }
- if(executeTests)
- {
+ if (executeTests) {
int res;
// call process directory
- if (this->RunConfigurationScript)
- {
- if ( this->ExtraVerbose )
- {
+ if (this->RunConfigurationScript) {
+ if (this->ExtraVerbose) {
cmCTestLog(this, OUTPUT, "* Extra verbosity turned on" << std::endl);
- }
+ }
cmCTest::t_TestingHandlers::iterator it;
- for ( it = this->TestingHandlers.begin();
- it != this->TestingHandlers.end();
- ++ it )
- {
+ for (it = this->TestingHandlers.begin();
+ it != this->TestingHandlers.end(); ++it) {
it->second->SetVerbose(this->ExtraVerbose);
it->second->SetSubmitIndex(this->SubmitIndex);
- }
+ }
this->GetHandler("script")->SetVerbose(this->Verbose);
res = this->GetHandler("script")->ProcessHandler();
- if(res != 0)
- {
- cmCTestLog(this, DEBUG, "running script failing returning: " << res
- << std::endl);
- }
-
+ if (res != 0) {
+ cmCTestLog(this, DEBUG,
+ "running script failing returning: " << res << std::endl);
}
- else
- {
+
+ } else {
// What is this? -V seems to be the same as -VV,
// and Verbose is always on in this case
this->ExtraVerbose = this->Verbose;
this->Verbose = true;
cmCTest::t_TestingHandlers::iterator it;
- for ( it = this->TestingHandlers.begin();
- it != this->TestingHandlers.end();
- ++ it )
- {
+ for (it = this->TestingHandlers.begin();
+ it != this->TestingHandlers.end(); ++it) {
it->second->SetVerbose(this->Verbose);
it->second->SetSubmitIndex(this->SubmitIndex);
- }
+ }
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
- if(!this->Initialize(cwd.c_str(), 0))
- {
+ if (!this->Initialize(cwd.c_str(), 0)) {
res = 12;
cmCTestLog(this, ERROR_MESSAGE, "Problem initializing the dashboard."
- << std::endl);
- }
- else
- {
+ << std::endl);
+ } else {
res = this->ProcessTests();
- }
- this->Finalize();
}
- if(res != 0)
- {
- cmCTestLog(this, DEBUG, "Running a test(s) failed returning : " << res
- << std::endl);
- }
- return res;
+ this->Finalize();
+ }
+ if (res != 0) {
+ cmCTestLog(this, DEBUG,
+ "Running a test(s) failed returning : " << res << std::endl);
}
+ return res;
+ }
return 1;
}
void cmCTest::SetNotesFiles(const char* notes)
{
- if ( !notes )
- {
+ if (!notes) {
return;
- }
+ }
this->NotesFiles = notes;
}
@@ -2596,122 +2220,105 @@ int cmCTest::ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf)
VectorOfStrings dirs;
VectorOfStrings ndirs;
cmCTestLog(this, DEBUG, "* Read custom CTest configuration directory: "
- << dir << std::endl);
+ << dir << std::endl);
std::string fname = dir;
fname += "/CTestCustom.cmake";
- cmCTestLog(this, DEBUG, "* Check for file: "
- << fname << std::endl);
- if ( cmSystemTools::FileExists(fname.c_str()) )
- {
+ cmCTestLog(this, DEBUG, "* Check for file: " << fname << std::endl);
+ if (cmSystemTools::FileExists(fname.c_str())) {
cmCTestLog(this, DEBUG, "* Read custom CTest configuration file: "
- << fname << std::endl);
+ << fname << std::endl);
bool erroroc = cmSystemTools::GetErrorOccuredFlag();
cmSystemTools::ResetErrorOccuredFlag();
- if ( !mf->ReadListFile(fname.c_str()) ||
- cmSystemTools::GetErrorOccuredFlag() )
- {
- cmCTestLog(this, ERROR_MESSAGE,
- "Problem reading custom configuration: "
- << fname << std::endl);
- }
+ if (!mf->ReadListFile(fname.c_str()) ||
+ cmSystemTools::GetErrorOccuredFlag()) {
+ cmCTestLog(this, ERROR_MESSAGE, "Problem reading custom configuration: "
+ << fname << std::endl);
+ }
found = true;
- if ( erroroc )
- {
+ if (erroroc) {
cmSystemTools::SetErrorOccured();
- }
}
+ }
std::string rexpr = dir;
rexpr += "/CTestCustom.ctest";
- cmCTestLog(this, DEBUG, "* Check for file: "
- << rexpr << std::endl);
- if ( !found && cmSystemTools::FileExists(rexpr.c_str()) )
- {
+ cmCTestLog(this, DEBUG, "* Check for file: " << rexpr << std::endl);
+ if (!found && cmSystemTools::FileExists(rexpr.c_str())) {
cmsys::Glob gl;
gl.RecurseOn();
gl.FindFiles(rexpr);
std::vector<std::string>& files = gl.GetFiles();
std::vector<std::string>::iterator fileIt;
- for ( fileIt = files.begin(); fileIt != files.end();
- ++ fileIt )
- {
+ for (fileIt = files.begin(); fileIt != files.end(); ++fileIt) {
cmCTestLog(this, DEBUG, "* Read custom CTest configuration file: "
- << *fileIt << std::endl);
- if ( !mf->ReadListFile(fileIt->c_str()) ||
- cmSystemTools::GetErrorOccuredFlag() )
- {
+ << *fileIt << std::endl);
+ if (!mf->ReadListFile(fileIt->c_str()) ||
+ cmSystemTools::GetErrorOccuredFlag()) {
cmCTestLog(this, ERROR_MESSAGE,
- "Problem reading custom configuration: "
- << *fileIt << std::endl);
- }
+ "Problem reading custom configuration: " << *fileIt
+ << std::endl);
}
- found = true;
}
+ found = true;
+ }
- if ( found )
- {
+ if (found) {
cmCTest::t_TestingHandlers::iterator it;
- for ( it = this->TestingHandlers.begin();
- it != this->TestingHandlers.end(); ++ it )
- {
+ for (it = this->TestingHandlers.begin(); it != this->TestingHandlers.end();
+ ++it) {
cmCTestLog(this, DEBUG,
- "* Read custom CTest configuration vectors for handler: "
- << it->first << " (" << it->second << ")" << std::endl);
+ "* Read custom CTest configuration vectors for handler: "
+ << it->first << " (" << it->second << ")" << std::endl);
it->second->PopulateCustomVectors(mf);
- }
}
+ }
return 1;
}
void cmCTest::PopulateCustomVector(cmMakefile* mf, const std::string& def,
- std::vector<std::string>& vec)
+ std::vector<std::string>& vec)
{
const char* dval = mf->GetDefinition(def);
- if ( !dval )
- {
+ if (!dval) {
return;
- }
+ }
cmCTestLog(this, DEBUG, "PopulateCustomVector: " << def << std::endl);
vec.clear();
cmSystemTools::ExpandListArgument(dval, vec);
for (std::vector<std::string>::const_iterator it = vec.begin();
- it != vec.end(); ++it )
- {
+ it != vec.end(); ++it) {
cmCTestLog(this, DEBUG, " -- " << *it << std::endl);
- }
+ }
}
void cmCTest::PopulateCustomInteger(cmMakefile* mf, const std::string& def,
- int& val)
+ int& val)
{
const char* dval = mf->GetDefinition(def);
- if ( !dval )
- {
+ if (!dval) {
return;
- }
+ }
val = atoi(dval);
}
std::string cmCTest::GetShortPathToFile(const char* cfname)
{
- const std::string& sourceDir
- = cmSystemTools::CollapseFullPath(
- this->GetCTestConfiguration("SourceDirectory"));
- const std::string& buildDir
- = cmSystemTools::CollapseFullPath(
- this->GetCTestConfiguration("BuildDirectory"));
+ const std::string& sourceDir = cmSystemTools::CollapseFullPath(
+ this->GetCTestConfiguration("SourceDirectory"));
+ const std::string& buildDir = cmSystemTools::CollapseFullPath(
+ this->GetCTestConfiguration("BuildDirectory"));
std::string fname = cmSystemTools::CollapseFullPath(cfname);
// Find relative paths to both directories
- std::string srcRelpath
- = cmSystemTools::RelativePath(sourceDir.c_str(), fname.c_str());
- std::string bldRelpath
- = cmSystemTools::RelativePath(buildDir.c_str(), fname.c_str());
+ std::string srcRelpath =
+ cmSystemTools::RelativePath(sourceDir.c_str(), fname.c_str());
+ std::string bldRelpath =
+ cmSystemTools::RelativePath(buildDir.c_str(), fname.c_str());
// If any contains "." it is not parent directory
bool inSrc = srcRelpath.find("..") == srcRelpath.npos;
@@ -2720,43 +2327,31 @@ std::string cmCTest::GetShortPathToFile(const char* cfname)
std::string* res = 0;
- if ( inSrc && inBld )
- {
+ if (inSrc && inBld) {
// If both have relative path with no dots, pick the shorter one
- if ( srcRelpath.size() < bldRelpath.size() )
- {
+ if (srcRelpath.size() < bldRelpath.size()) {
res = &srcRelpath;
- }
- else
- {
+ } else {
res = &bldRelpath;
- }
}
- else if ( inSrc )
- {
+ } else if (inSrc) {
res = &srcRelpath;
- }
- else if ( inBld )
- {
+ } else if (inBld) {
res = &bldRelpath;
- }
+ }
std::string path;
- if ( !res )
- {
+ if (!res) {
path = fname;
- }
- else
- {
+ } else {
cmSystemTools::ConvertToUnixSlashes(*res);
path = "./" + *res;
- if ( path[path.size()-1] == '/' )
- {
- path = path.substr(0, path.size()-1);
- }
+ if (path[path.size() - 1] == '/') {
+ path = path.substr(0, path.size() - 1);
}
+ }
cmsys::SystemTools::ReplaceString(path, ":", "_");
cmsys::SystemTools::ReplaceString(path, " ", "_");
@@ -2765,11 +2360,10 @@ std::string cmCTest::GetShortPathToFile(const char* cfname)
std::string cmCTest::GetCTestConfiguration(const std::string& name)
{
- if ( this->CTestConfigurationOverwrites.find(name) !=
- this->CTestConfigurationOverwrites.end() )
- {
+ if (this->CTestConfigurationOverwrites.find(name) !=
+ this->CTestConfigurationOverwrites.end()) {
return this->CTestConfigurationOverwrites[name];
- }
+ }
return this->CTestConfiguration[name];
}
@@ -2789,53 +2383,44 @@ void cmCTest::DetermineNextDayStop()
int local_hour = lctime->tm_hour;
int tzone_offset = local_hour - gm_hour;
- if(gm_time > current_time && gm_hour < local_hour)
- {
+ if (gm_time > current_time && gm_hour < local_hour) {
// this means gm_time is on the next day
tzone_offset -= 24;
- }
- else if(gm_time < current_time && gm_hour > local_hour)
- {
+ } else if (gm_time < current_time && gm_hour > local_hour) {
// this means gm_time is on the previous day
tzone_offset += 24;
- }
+ }
tzone_offset *= 100;
char buf[1024];
- sprintf(buf, "%d%02d%02d %s %+05i",
- lctime->tm_year + 1900,
- lctime->tm_mon + 1,
- lctime->tm_mday,
- this->StopTime.c_str(),
+ sprintf(buf, "%d%02d%02d %s %+05i", lctime->tm_year + 1900,
+ lctime->tm_mon + 1, lctime->tm_mday, this->StopTime.c_str(),
tzone_offset);
time_t stop_time = curl_getdate(buf, &current_time);
- if(stop_time < current_time)
- {
+ if (stop_time < current_time) {
this->NextDayStopTime = true;
- }
+ }
}
-void cmCTest::SetCTestConfiguration(const char *name, const char* value,
+void cmCTest::SetCTestConfiguration(const char* name, const char* value,
bool suppress)
{
cmCTestOptionalLog(this, HANDLER_VERBOSE_OUTPUT, "SetCTestConfiguration:"
- << name << ":" << (value ? value : "(null)") << "\n", suppress);
+ << name << ":" << (value ? value : "(null)") << "\n",
+ suppress);
- if ( !name )
- {
+ if (!name) {
return;
- }
- if ( !value )
- {
+ }
+ if (!value) {
this->CTestConfiguration.erase(name);
return;
- }
+ }
this->CTestConfiguration[name] = value;
}
-
std::string cmCTest::GetCurrentTag()
{
return this->CurrentTag;
@@ -2873,20 +2458,18 @@ bool cmCTest::GetProduceXML()
const char* cmCTest::GetSpecificTrack()
{
- if ( this->SpecificTrack.empty() )
- {
+ if (this->SpecificTrack.empty()) {
return 0;
- }
+ }
return this->SpecificTrack.c_str();
}
void cmCTest::SetSpecificTrack(const char* track)
{
- if ( !track )
- {
+ if (!track) {
this->SpecificTrack = "";
return;
- }
+ }
this->SpecificTrack = track;
}
@@ -2898,66 +2481,59 @@ void cmCTest::AddSubmitFile(Part part, const char* name)
void cmCTest::AddCTestConfigurationOverwrite(const std::string& overStr)
{
size_t epos = overStr.find("=");
- if ( epos == overStr.npos )
- {
+ if (epos == overStr.npos) {
cmCTestLog(this, ERROR_MESSAGE,
- "CTest configuration overwrite specified in the wrong format."
- << std::endl
- << "Valid format is: --overwrite key=value" << std::endl
- << "The specified was: --overwrite " << overStr << std::endl);
+ "CTest configuration overwrite specified in the wrong format."
+ << std::endl
+ << "Valid format is: --overwrite key=value" << std::endl
+ << "The specified was: --overwrite " << overStr << std::endl);
return;
- }
+ }
std::string key = overStr.substr(0, epos);
- std::string value = overStr.substr(epos+1, overStr.npos);
+ std::string value = overStr.substr(epos + 1, overStr.npos);
this->CTestConfigurationOverwrites[key] = value;
}
void cmCTest::SetConfigType(const char* ct)
{
- this->ConfigType = ct?ct:"";
+ this->ConfigType = ct ? ct : "";
cmSystemTools::ReplaceString(this->ConfigType, ".\\", "");
- std::string confTypeEnv
- = "CMAKE_CONFIG_TYPE=" + this->ConfigType;
+ std::string confTypeEnv = "CMAKE_CONFIG_TYPE=" + this->ConfigType;
cmSystemTools::PutEnv(confTypeEnv);
}
-bool cmCTest::SetCTestConfigurationFromCMakeVariable(cmMakefile* mf,
- const char* dconfig, const std::string& cmake_var, bool suppress)
+bool cmCTest::SetCTestConfigurationFromCMakeVariable(
+ cmMakefile* mf, const char* dconfig, const std::string& cmake_var,
+ bool suppress)
{
const char* ctvar;
ctvar = mf->GetDefinition(cmake_var);
- if ( !ctvar )
- {
+ if (!ctvar) {
return false;
- }
+ }
cmCTestOptionalLog(this, HANDLER_VERBOSE_OUTPUT,
- "SetCTestConfigurationFromCMakeVariable:" << dconfig << ":" <<
- cmake_var << std::endl, suppress);
+ "SetCTestConfigurationFromCMakeVariable:"
+ << dconfig << ":" << cmake_var << std::endl,
+ suppress);
this->SetCTestConfiguration(dconfig, ctvar, suppress);
return true;
}
-bool cmCTest::RunCommand(
- const char* command,
- std::string* stdOut,
- std::string* stdErr,
- int *retVal,
- const char* dir,
- double timeout)
+bool cmCTest::RunCommand(const char* command, std::string* stdOut,
+ std::string* stdErr, int* retVal, const char* dir,
+ double timeout)
{
std::vector<std::string> args = cmSystemTools::ParseArguments(command);
- if(args.size() < 1)
- {
+ if (args.size() < 1) {
return false;
- }
+ }
std::vector<const char*> argv;
- for(std::vector<std::string>::const_iterator a = args.begin();
- a != args.end(); ++a)
- {
+ for (std::vector<std::string>::const_iterator a = args.begin();
+ a != args.end(); ++a) {
argv.push_back(a->c_str());
- }
+ }
argv.push_back(0);
*stdOut = "";
@@ -2966,10 +2542,9 @@ bool cmCTest::RunCommand(
cmsysProcess* cp = cmsysProcess_New();
cmsysProcess_SetCommand(cp, &*argv.begin());
cmsysProcess_SetWorkingDirectory(cp, dir);
- if(cmSystemTools::GetRunCommandHideConsole())
- {
+ if (cmSystemTools::GetRunCommandHideConsole()) {
cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
- }
+ }
cmsysProcess_SetTimeout(cp, timeout);
cmsysProcess_Execute(cp);
@@ -2979,73 +2554,57 @@ bool cmCTest::RunCommand(
int length;
int res;
bool done = false;
- while(!done)
- {
+ while (!done) {
res = cmsysProcess_WaitForData(cp, &data, &length, 0);
- switch ( res )
- {
- case cmsysProcess_Pipe_STDOUT:
- tempOutput.insert(tempOutput.end(), data, data+length);
- break;
- case cmsysProcess_Pipe_STDERR:
- tempError.insert(tempError.end(), data, data+length);
- break;
- default:
- done = true;
- }
- if ( (res == cmsysProcess_Pipe_STDOUT ||
- res == cmsysProcess_Pipe_STDERR) && this->ExtraVerbose )
- {
+ switch (res) {
+ case cmsysProcess_Pipe_STDOUT:
+ tempOutput.insert(tempOutput.end(), data, data + length);
+ break;
+ case cmsysProcess_Pipe_STDERR:
+ tempError.insert(tempError.end(), data, data + length);
+ break;
+ default:
+ done = true;
+ }
+ if ((res == cmsysProcess_Pipe_STDOUT || res == cmsysProcess_Pipe_STDERR) &&
+ this->ExtraVerbose) {
cmSystemTools::Stdout(data, length);
- }
}
+ }
cmsysProcess_WaitForExit(cp, 0);
- if (!tempOutput.empty())
- {
+ if (!tempOutput.empty()) {
stdOut->append(&*tempOutput.begin(), tempOutput.size());
- }
- if (!tempError.empty())
- {
+ }
+ if (!tempError.empty()) {
stdErr->append(&*tempError.begin(), tempError.size());
- }
+ }
bool result = true;
- if(cmsysProcess_GetState(cp) == cmsysProcess_State_Exited)
- {
- if ( retVal )
- {
+ if (cmsysProcess_GetState(cp) == cmsysProcess_State_Exited) {
+ if (retVal) {
*retVal = cmsysProcess_GetExitValue(cp);
- }
- else
- {
- if ( cmsysProcess_GetExitValue(cp) != 0 )
- {
+ } else {
+ if (cmsysProcess_GetExitValue(cp) != 0) {
result = false;
- }
}
}
- else if(cmsysProcess_GetState(cp) == cmsysProcess_State_Exception)
- {
+ } else if (cmsysProcess_GetState(cp) == cmsysProcess_State_Exception) {
const char* exception_str = cmsysProcess_GetExceptionString(cp);
cmCTestLog(this, ERROR_MESSAGE, exception_str << std::endl);
stdErr->append(exception_str, strlen(exception_str));
result = false;
- }
- else if(cmsysProcess_GetState(cp) == cmsysProcess_State_Error)
- {
+ } else if (cmsysProcess_GetState(cp) == cmsysProcess_State_Error) {
const char* error_str = cmsysProcess_GetErrorString(cp);
cmCTestLog(this, ERROR_MESSAGE, error_str << std::endl);
stdErr->append(error_str, strlen(error_str));
result = false;
- }
- else if(cmsysProcess_GetState(cp) == cmsysProcess_State_Expired)
- {
+ } else if (cmsysProcess_GetState(cp) == cmsysProcess_State_Expired) {
const char* error_str = "Process terminated due to timeout\n";
cmCTestLog(this, ERROR_MESSAGE, error_str << std::endl);
stdErr->append(error_str, strlen(error_str));
result = false;
- }
+ }
cmsysProcess_Delete(cp);
return result;
@@ -3053,41 +2612,35 @@ bool cmCTest::RunCommand(
void cmCTest::SetOutputLogFileName(const char* name)
{
- if ( this->OutputLogFile)
- {
+ if (this->OutputLogFile) {
delete this->OutputLogFile;
- this->OutputLogFile= 0;
- }
- if ( name )
- {
+ this->OutputLogFile = 0;
+ }
+ if (name) {
this->OutputLogFile = new cmGeneratedFileStream(name);
- }
+ }
}
-static const char* cmCTestStringLogType[] =
-{
- "DEBUG",
- "OUTPUT",
- "HANDLER_OUTPUT",
- "HANDLER_PROGRESS_OUTPUT",
- "HANDLER_VERBOSE_OUTPUT",
- "WARNING",
- "ERROR_MESSAGE",
- 0
-};
+static const char* cmCTestStringLogType[] = { "DEBUG",
+ "OUTPUT",
+ "HANDLER_OUTPUT",
+ "HANDLER_PROGRESS_OUTPUT",
+ "HANDLER_VERBOSE_OUTPUT",
+ "WARNING",
+ "ERROR_MESSAGE",
+ 0 };
#ifdef cerr
-# undef cerr
+#undef cerr
#endif
#ifdef cout
-# undef cout
+#undef cout
#endif
-#define cmCTestLogOutputFileLine(stream) \
- if ( this->ShowLineNumbers ) \
- { \
- (stream) << std::endl << file << ":" << line << " "; \
- }
+#define cmCTestLogOutputFileLine(stream) \
+ if (this->ShowLineNumbers) { \
+ (stream) << std::endl << file << ":" << line << " "; \
+ }
void cmCTest::InitStreams()
{
@@ -3099,118 +2652,106 @@ void cmCTest::InitStreams()
void cmCTest::Log(int logType, const char* file, int line, const char* msg,
bool suppress)
{
- if ( !msg || !*msg )
- {
+ if (!msg || !*msg) {
return;
- }
- if ( suppress && logType != cmCTest::ERROR_MESSAGE )
- {
+ }
+ if (suppress && logType != cmCTest::ERROR_MESSAGE) {
return;
- }
- if ( logType == cmCTest::HANDLER_PROGRESS_OUTPUT &&
- ( this->Debug || this->ExtraVerbose ) )
- {
+ }
+ if (logType == cmCTest::HANDLER_PROGRESS_OUTPUT &&
+ (this->Debug || this->ExtraVerbose)) {
return;
- }
- if ( this->OutputLogFile )
- {
+ }
+ if (this->OutputLogFile) {
bool display = true;
- if ( logType == cmCTest::DEBUG && !this->Debug ) { display = false; }
- if ( logType == cmCTest::HANDLER_VERBOSE_OUTPUT && !this->Debug &&
- !this->ExtraVerbose ) { display = false; }
- if ( display )
- {
+ if (logType == cmCTest::DEBUG && !this->Debug) {
+ display = false;
+ }
+ if (logType == cmCTest::HANDLER_VERBOSE_OUTPUT && !this->Debug &&
+ !this->ExtraVerbose) {
+ display = false;
+ }
+ if (display) {
cmCTestLogOutputFileLine(*this->OutputLogFile);
- if ( logType != this->OutputLogFileLastTag )
- {
+ if (logType != this->OutputLogFileLastTag) {
*this->OutputLogFile << "[";
- if ( logType >= OTHER || logType < 0 )
- {
+ if (logType >= OTHER || logType < 0) {
*this->OutputLogFile << "OTHER";
- }
- else
- {
+ } else {
*this->OutputLogFile << cmCTestStringLogType[logType];
- }
- *this->OutputLogFile << "] " << std::endl << std::flush;
}
+ *this->OutputLogFile << "] " << std::endl << std::flush;
+ }
*this->OutputLogFile << msg << std::flush;
- if ( logType != this->OutputLogFileLastTag )
- {
+ if (logType != this->OutputLogFileLastTag) {
*this->OutputLogFile << std::endl << std::flush;
this->OutputLogFileLastTag = logType;
- }
}
}
- if ( !this->Quiet )
- {
+ }
+ if (!this->Quiet) {
std::ostream& out = *this->StreamOut;
std::ostream& err = *this->StreamErr;
- switch ( logType )
- {
- case DEBUG:
- if ( this->Debug )
- {
- cmCTestLogOutputFileLine(out);
- out << msg;
- out.flush();
+ switch (logType) {
+ case DEBUG:
+ if (this->Debug) {
+ cmCTestLogOutputFileLine(out);
+ out << msg;
+ out.flush();
}
- break;
- case OUTPUT: case HANDLER_OUTPUT:
- if ( this->Debug || this->Verbose )
- {
- cmCTestLogOutputFileLine(out);
- out << msg;
- out.flush();
+ break;
+ case OUTPUT:
+ case HANDLER_OUTPUT:
+ if (this->Debug || this->Verbose) {
+ cmCTestLogOutputFileLine(out);
+ out << msg;
+ out.flush();
}
- break;
- case HANDLER_VERBOSE_OUTPUT:
- if ( this->Debug || this->ExtraVerbose )
- {
+ break;
+ case HANDLER_VERBOSE_OUTPUT:
+ if (this->Debug || this->ExtraVerbose) {
+ cmCTestLogOutputFileLine(out);
+ out << msg;
+ out.flush();
+ }
+ break;
+ case WARNING:
+ cmCTestLogOutputFileLine(err);
+ err << msg;
+ err.flush();
+ break;
+ case ERROR_MESSAGE:
+ cmCTestLogOutputFileLine(err);
+ err << msg;
+ err.flush();
+ cmSystemTools::SetErrorOccured();
+ break;
+ default:
cmCTestLogOutputFileLine(out);
out << msg;
out.flush();
- }
- break;
- case WARNING:
- cmCTestLogOutputFileLine(err);
- err << msg;
- err.flush();
- break;
- case ERROR_MESSAGE:
- cmCTestLogOutputFileLine(err);
- err << msg;
- err.flush();
- cmSystemTools::SetErrorOccured();
- break;
- default:
- cmCTestLogOutputFileLine(out);
- out << msg;
- out.flush();
- }
}
+ }
}
double cmCTest::GetRemainingTimeAllowed()
{
- if (!this->GetHandler("script"))
- {
+ if (!this->GetHandler("script")) {
return 1.0e7;
- }
+ }
- cmCTestScriptHandler* ch
- = static_cast<cmCTestScriptHandler*>(this->GetHandler("script"));
+ cmCTestScriptHandler* ch =
+ static_cast<cmCTestScriptHandler*>(this->GetHandler("script"));
return ch->GetRemainingTimeAllowed();
}
-void cmCTest::OutputTestErrors(std::vector<char> const &process_output)
+void cmCTest::OutputTestErrors(std::vector<char> const& process_output)
{
std::string test_outputs("\n*** Test Failed:\n");
- if(!process_output.empty())
- {
+ if (!process_output.empty()) {
test_outputs.append(&*process_output.begin(), process_output.size());
- }
+ }
cmCTestLog(this, HANDLER_OUTPUT, test_outputs << std::endl << std::flush);
}
@@ -3219,22 +2760,21 @@ bool cmCTest::CompressString(std::string& str)
int ret;
z_stream strm;
- unsigned char* in = reinterpret_cast<unsigned char*>(
- const_cast<char*>(str.c_str()));
- //zlib makes the guarantee that this is the maximum output size
- int outSize = static_cast<int>(
- static_cast<double>(str.size()) * 1.001 + 13.0);
+ unsigned char* in =
+ reinterpret_cast<unsigned char*>(const_cast<char*>(str.c_str()));
+ // zlib makes the guarantee that this is the maximum output size
+ int outSize =
+ static_cast<int>(static_cast<double>(str.size()) * 1.001 + 13.0);
unsigned char* out = new unsigned char[outSize];
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
- ret = deflateInit(&strm, -1); //default compression level
- if (ret != Z_OK)
- {
+ ret = deflateInit(&strm, -1); // default compression level
+ if (ret != Z_OK) {
delete[] out;
return false;
- }
+ }
strm.avail_in = static_cast<uInt>(str.size());
strm.next_in = in;
@@ -3242,28 +2782,26 @@ bool cmCTest::CompressString(std::string& str)
strm.next_out = out;
ret = deflate(&strm, Z_FINISH);
- if(ret == Z_STREAM_ERROR || ret != Z_STREAM_END)
- {
+ if (ret == Z_STREAM_ERROR || ret != Z_STREAM_END) {
cmCTestLog(this, ERROR_MESSAGE, "Error during gzip compression."
- << std::endl);
+ << std::endl);
delete[] out;
return false;
- }
+ }
(void)deflateEnd(&strm);
// Now base64 encode the resulting binary string
- unsigned char* base64EncodedBuffer
- = new unsigned char[(outSize * 3) / 2];
+ unsigned char* base64EncodedBuffer = new unsigned char[(outSize * 3) / 2];
- size_t rlen
- = cmsysBase64_Encode(out, strm.total_out, base64EncodedBuffer, 1);
+ size_t rlen =
+ cmsysBase64_Encode(out, strm.total_out, base64EncodedBuffer, 1);
str = "";
str.append(reinterpret_cast<char*>(base64EncodedBuffer), rlen);
- delete [] base64EncodedBuffer;
- delete [] out;
+ delete[] base64EncodedBuffer;
+ delete[] out;
return true;
}
diff --git a/Source/cmCTest.h b/Source/cmCTest.h
index 07081fc..1c3490e 100644
--- a/Source/cmCTest.h
+++ b/Source/cmCTest.h
@@ -27,29 +27,29 @@ class cmCTestScriptHandler;
class cmCTestStartCommand;
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 ( 0 )
-
-#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 ( 0 )
+#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 (0)
+
+#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 (0)
#ifdef cerr
-# undef cerr
+#undef cerr
#endif
#define cerr no_cerr_use_cmCTestLog
#ifdef cout
-# undef cout
+#undef cout
#endif
#define cout no_cout_use_cmCTestLog
@@ -57,6 +57,7 @@ class cmCTest
{
friend class cmCTestRunTest;
friend class cmCTestMultiProcessHandler;
+
public:
/** Enumerate parts of the testing and submission process. */
enum Part
@@ -78,7 +79,10 @@ public:
/** Representation of one part. */
struct PartInfo
{
- PartInfo(): Enabled(false) {}
+ PartInfo()
+ : Enabled(false)
+ {
+ }
void SetName(const std::string& name) { this->Name = name; }
const std::string& GetName() const { return this->Name; }
@@ -87,12 +91,14 @@ public:
operator bool() const { return this->Enabled; }
std::vector<std::string> SubmitFiles;
+
private:
bool Enabled;
std::string Name;
};
#ifdef CMAKE_BUILD_WITH_CMAKE
- enum HTTPMethod {
+ enum HTTPMethod
+ {
HTTP_GET,
HTTP_POST,
HTTP_PUT
@@ -102,9 +108,8 @@ public:
* Perform an HTTP request.
*/
static int HTTPRequest(std::string url, HTTPMethod method,
- std::string& response,
- std::string fields = "",
- std::string putFile = "", int timeout = 0);
+ std::string& response, std::string fields = "",
+ std::string putFile = "", int timeout = 0);
#endif
/** Get a testing part id from its string name. Returns PartCount
@@ -115,7 +120,7 @@ public:
typedef std::set<std::string> SetOfStrings;
///! Process Command line arguments
- int Run(std::vector<std::string> &, std::string* output = 0);
+ int Run(std::vector<std::string>&, std::string* output = 0);
/**
* Initialize and finalize testing
@@ -138,8 +143,7 @@ public:
/*
* A utility function that returns the nightly time
*/
- struct tm* GetNightlyTime(std::string str,
- bool tomorrowtag);
+ struct tm* GetNightlyTime(std::string str, bool tomorrowtag);
/*
* Is the tomorrow tag set?
@@ -186,8 +190,8 @@ public:
static int GetTestModelFromString(const char* str);
static std::string CleanString(const std::string& str);
std::string GetCTestConfiguration(const std::string& name);
- void SetCTestConfiguration(const char *name, const char* value,
- bool suppress=false);
+ void SetCTestConfiguration(const char* name, const char* value,
+ bool suppress = false);
void EmptyCTestConfiguration();
/**
@@ -200,9 +204,8 @@ public:
void SetNotesFiles(const char* notes);
void PopulateCustomVector(cmMakefile* mf, const std::string& definition,
- std::vector<std::string>& vec);
- void PopulateCustomInteger(cmMakefile* mf, const std::string& def,
- int& val);
+ std::vector<std::string>& vec);
+ void PopulateCustomInteger(cmMakefile* mf, const std::string& def, int& val);
///! Get the current time as string
std::string CurrentTime();
@@ -220,10 +223,8 @@ public:
double GetRemainingTimeAllowed();
///! Open file in the output directory and set the stream
- bool OpenOutputFile(const std::string& path,
- const std::string& name,
- cmGeneratedFileStream& stream,
- bool compress = false);
+ bool OpenOutputFile(const std::string& path, const std::string& name,
+ cmGeneratedFileStream& stream, bool compress = false);
///! Should we only show what we would do?
bool GetShowOnly();
@@ -241,13 +242,13 @@ public:
std::string GetStopTime() { return this->StopTime; }
void SetStopTime(std::string time);
- //Used for parallel ctest job scheduling
+ // Used for parallel ctest job scheduling
std::string GetScheduleType() { return this->ScheduleType; }
void SetScheduleType(std::string type) { this->ScheduleType = type; }
///! The max output width
int GetMaxTestNameWidth() const;
- void SetMaxTestNameWidth(int w) { this->MaxTestNameWidth = w;}
+ void SetMaxTestNameWidth(int w) { this->MaxTestNameWidth = w; }
/**
* Run a single executable command and put the stdout and stderr
@@ -269,9 +270,9 @@ public:
* it into this function or it will not work. The command must be correctly
* escaped for this to with spaces.
*/
- bool RunCommand(const char* command,
- std::string* stdOut, std::string* stdErr,
- int* retVal = 0, const char* dir = 0, double timeout = 0.0);
+ bool RunCommand(const char* command, std::string* stdOut,
+ std::string* stdErr, int* retVal = 0, const char* dir = 0,
+ double timeout = 0.0);
//! Clean/make safe for xml the given value such that it may be used as
// one of the key fields by CDash when computing the buildid.
@@ -285,9 +286,8 @@ public:
//! Run command specialized for make and configure. Returns process status
// and retVal is return value or exception.
- int RunMakeCommand(const char* command, std::string& output,
- int* retVal, const char* dir, int timeout,
- std::ostream& ofs);
+ int RunMakeCommand(const char* command, std::string& output, int* retVal,
+ const char* dir, int timeout, std::ostream& ofs);
/*
* return the current tag
@@ -298,24 +298,26 @@ public:
std::string GetBinaryDir();
//! Get the short path to the file. This means if the file is in binary or
- //source directory, it will become /.../relative/path/to/file
+ // source directory, it will become /.../relative/path/to/file
std::string GetShortPathToFile(const char* fname);
- enum {
+ enum
+ {
EXPERIMENTAL,
NIGHTLY,
CONTINUOUS
};
// provide some more detailed info on the return code for ctest
- enum {
- UPDATE_ERRORS = 0x01,
+ enum
+ {
+ UPDATE_ERRORS = 0x01,
CONFIGURE_ERRORS = 0x02,
- BUILD_ERRORS = 0x04,
- TEST_ERRORS = 0x08,
- MEMORY_ERRORS = 0x10,
- COVERAGE_ERRORS = 0x20,
- SUBMIT_ERRORS = 0x40
+ BUILD_ERRORS = 0x04,
+ TEST_ERRORS = 0x08,
+ MEMORY_ERRORS = 0x10,
+ COVERAGE_ERRORS = 0x20,
+ SUBMIT_ERRORS = 0x40
};
///! Are we producing XML
@@ -326,9 +328,9 @@ public:
// return value or exception. If environment is non-null, it is used to set
// environment variables prior to running the test. After running the test,
// environment variables are restored to their previous values.
- int RunTest(std::vector<const char*> args, std::string* output, int *retVal,
- std::ostream* logfile, double testTimeOut,
- std::vector<std::string>* environment);
+ int RunTest(std::vector<const char*> args, std::string* output, int* retVal,
+ std::ostream* logfile, double testTimeOut,
+ std::vector<std::string>* environment);
/**
* Execute handler and return its result. If the handler fails, it returns
@@ -346,7 +348,9 @@ public:
* Set the CTest variable from CMake variable
*/
bool SetCTestConfigurationFromCMakeVariable(cmMakefile* mf,
- const char* dconfig, const std::string& cmake_var, bool suppress=false);
+ const char* dconfig,
+ const std::string& cmake_var,
+ bool suppress = false);
//! Make string safe to be send as an URL
static std::string MakeURLSafe(const std::string&);
@@ -357,20 +361,20 @@ public:
//! Should ctect configuration be updated. When using new style ctest
// script, this should be true.
void SetSuppressUpdatingCTestConfiguration(bool val)
- {
+ {
this->SuppressUpdatingCTestConfiguration = val;
- }
+ }
//! Add overwrite to ctest configuration.
// The format is key=value
void AddCTestConfigurationOverwrite(const std::string& encstr);
//! Create XML file that contains all the notes specified
- int GenerateNotesFile(const VectorOfStrings &files);
+ int GenerateNotesFile(const VectorOfStrings& files);
//! Submit extra files to the server
bool SubmitExtraFiles(const char* files);
- bool SubmitExtraFiles(const VectorOfStrings &files);
+ bool SubmitExtraFiles(const VectorOfStrings& files);
//! Set the output log file name
void SetOutputLogFileName(const char* name);
@@ -379,7 +383,8 @@ public:
void SetConfigType(const char* ct);
//! Various log types
- enum {
+ enum
+ {
DEBUG = 0,
OUTPUT,
HANDLER_OUTPUT,
@@ -392,7 +397,7 @@ public:
//! Add log to the output
void Log(int logType, const char* file, int line, const char* msg,
- bool suppress=false);
+ bool suppress = false);
//! Get the version of dart server
int GetDartVersion() { return this->DartVersion; }
@@ -401,14 +406,18 @@ public:
//! Add file to be submitted
void AddSubmitFile(Part part, const char* name);
std::vector<std::string> const& GetSubmitFiles(Part part)
- { return this->Parts[part].SubmitFiles; }
+ {
+ return this->Parts[part].SubmitFiles;
+ }
void ClearSubmitFiles(Part part) { this->Parts[part].SubmitFiles.clear(); }
//! Read the custom configuration files and apply them to the current ctest
int ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf);
- std::vector<std::string> &GetInitialCommandLineArguments()
- { return this->InitialCommandLineArguments; }
+ std::vector<std::string>& GetInitialCommandLineArguments()
+ {
+ return this->InitialCommandLineArguments;
+ }
//! Set the track to submit to
void SetSpecificTrack(const char* track);
@@ -420,25 +429,28 @@ public:
void SetBatchJobs(bool batch = true) { this->BatchJobs = batch; }
bool GetBatchJobs() { return this->BatchJobs; }
- bool GetVerbose() { return this->Verbose;}
- bool GetExtraVerbose() { return this->ExtraVerbose;}
+ bool GetVerbose() { return this->Verbose; }
+ bool GetExtraVerbose() { return this->ExtraVerbose; }
/** Direct process output to given streams. */
void SetStreams(std::ostream* out, std::ostream* err)
- { this->StreamOut = out; this->StreamErr = err; }
+ {
+ this->StreamOut = out;
+ this->StreamErr = err;
+ }
void AddSiteProperties(cmXMLWriter& xml);
- bool GetLabelSummary() { return this->LabelSummary;}
+ bool GetLabelSummary() { return this->LabelSummary; }
std::string GetCostDataFile();
- const std::map<std::string, std::string> &GetDefinitions()
- {
+ const std::map<std::string, std::string>& GetDefinitions()
+ {
return this->Definitions;
- }
+ }
// return the number of times a test should be run
- int GetTestRepeat() { return this->RepeatTests;}
+ int GetTestRepeat() { return this->RepeatTests; }
// return true if test should run until fail
- bool GetRepeatUntilFail() { return this->RepeatUntilFail;}
+ bool GetRepeatUntilFail() { return this->RepeatUntilFail; }
private:
int RepeatTests;
bool RepeatUntilFail;
@@ -459,7 +471,7 @@ private:
bool RunConfigurationScript;
- //flag for lazy getter (optimization)
+ // flag for lazy getter (optimization)
bool ComputedCompressTestOutput;
bool ComputedCompressMemCheckOutput;
@@ -468,7 +480,7 @@ private:
void DetermineNextDayStop();
// these are helper classes
- typedef std::map<std::string,cmCTestGenericHandler*> t_TestingHandlers;
+ typedef std::map<std::string, cmCTestGenericHandler*> t_TestingHandlers;
t_TestingHandlers TestingHandlers;
bool ShowOnly;
@@ -476,51 +488,50 @@ private:
//! Map of configuration properties
typedef std::map<std::string, std::string> CTestConfigurationMap;
- std::string CTestConfigFile;
+ std::string CTestConfigFile;
// TODO: The ctest configuration should be a hierarchy of
// configuration option sources: command-line, script, ini file.
// Then the ini file can get re-loaded whenever it changes without
// affecting any higher-precedence settings.
CTestConfigurationMap CTestConfiguration;
CTestConfigurationMap CTestConfigurationOverwrites;
- PartInfo Parts[PartCount];
+ PartInfo Parts[PartCount];
typedef std::map<std::string, Part> PartMapType;
- PartMapType PartMap;
+ PartMapType PartMap;
- std::string CurrentTag;
- bool TomorrowTag;
+ std::string CurrentTag;
+ bool TomorrowTag;
- int TestModel;
- std::string SpecificTrack;
+ int TestModel;
+ std::string SpecificTrack;
- double TimeOut;
+ double TimeOut;
- double GlobalTimeout;
+ double GlobalTimeout;
- int LastStopTimeout;
+ int LastStopTimeout;
- int MaxTestNameWidth;
+ int MaxTestNameWidth;
- int ParallelLevel;
- bool ParallelLevelSetInCli;
+ int ParallelLevel;
+ bool ParallelLevelSetInCli;
- unsigned long TestLoad;
+ unsigned long TestLoad;
- int CompatibilityMode;
+ int CompatibilityMode;
// information for the --build-and-test options
- std::string BinaryDir;
-
- std::string NotesFiles;
+ std::string BinaryDir;
+ std::string NotesFiles;
- bool InteractiveDebugMode;
+ bool InteractiveDebugMode;
- bool ShortDateFormat;
+ bool ShortDateFormat;
- bool CompressXMLFiles;
- bool CompressTestOutput;
- bool CompressMemCheckOutput;
+ bool CompressXMLFiles;
+ bool CompressTestOutput;
+ bool CompressMemCheckOutput;
void InitStreams();
std::ostream* StreamOut;
@@ -539,45 +550,42 @@ private:
int Initialize(const char* binary_dir, cmCTestStartCommand* command);
//! parse the option after -D and convert it into the appropriate steps
- bool AddTestsForDashboardType(std::string &targ);
+ bool AddTestsForDashboardType(std::string& targ);
//! read as "emit an error message for an unknown -D value"
- void ErrorMessageUnknownDashDValue(std::string &val);
+ void ErrorMessageUnknownDashDValue(std::string& val);
//! add a variable definition from a command line -D value
- bool AddVariableDefinition(const std::string &arg);
+ bool AddVariableDefinition(const std::string& arg);
//! parse and process most common command line arguments
- bool HandleCommandLineArguments(size_t &i,
- std::vector<std::string> &args,
+ bool HandleCommandLineArguments(size_t& i, std::vector<std::string>& args,
std::string& errormsg);
//! hande the -S -SP and -SR arguments
- void HandleScriptArguments(size_t &i,
- std::vector<std::string> &args,
- bool &SRArgumentSpecified);
+ void HandleScriptArguments(size_t& i, std::vector<std::string>& args,
+ bool& SRArgumentSpecified);
//! Reread the configuration file
bool UpdateCTestConfiguration();
//! Create note from files.
- int GenerateCTestNotesOutput(cmXMLWriter& xml,
- const VectorOfStrings& files);
+ int GenerateCTestNotesOutput(cmXMLWriter& xml, const VectorOfStrings& files);
//! Check if the argument is the one specified
bool CheckArgument(const std::string& arg, const char* varg1,
- const char* varg2 = 0);
+ const char* varg2 = 0);
//! Output errors from a test
- void OutputTestErrors(std::vector<char> const &process_output);
+ void OutputTestErrors(std::vector<char> const& process_output);
- bool SuppressUpdatingCTestConfiguration;
+ bool SuppressUpdatingCTestConfiguration;
bool Debug;
bool ShowLineNumbers;
bool Quiet;
- int DartVersion;
+ int DartVersion;
bool DropSiteCDash;
std::vector<std::string> InitialCommandLineArguments;
@@ -596,18 +604,20 @@ class cmCTestLogWrite
{
public:
cmCTestLogWrite(const char* data, size_t length)
- : Data(data), Length(length) {}
+ : Data(data)
+ , Length(length)
+ {
+ }
const char* Data;
size_t Length;
};
-inline std::ostream& operator<< (std::ostream& os, const cmCTestLogWrite& c)
+inline std::ostream& operator<<(std::ostream& os, const cmCTestLogWrite& c)
{
- if (!c.Length)
- {
+ if (!c.Length) {
return os;
- }
+ }
os.write(c.Data, c.Length);
os.flush();
return os;
diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx
index 30caa32..d143193 100644
--- a/Source/cmCacheManager.cxx
+++ b/Source/cmCacheManager.cxx
@@ -38,223 +38,183 @@ void cmCacheManager::CleanCMakeFiles(const std::string& path)
std::for_each(files.begin(), files.end(), cmSystemTools::RemoveFile);
}
-bool cmCacheManager::LoadCache(const std::string& path,
- bool internal,
+bool cmCacheManager::LoadCache(const std::string& path, bool internal,
std::set<std::string>& excludes,
std::set<std::string>& includes)
{
std::string cacheFile = path;
cacheFile += "/CMakeCache.txt";
// clear the old cache, if we are reading in internal values
- if ( internal )
- {
+ if (internal) {
this->Cache.clear();
- }
- if(!cmSystemTools::FileExists(cacheFile.c_str()))
- {
+ }
+ if (!cmSystemTools::FileExists(cacheFile.c_str())) {
this->CleanCMakeFiles(path);
return false;
- }
+ }
cmsys::ifstream fin(cacheFile.c_str());
- if(!fin)
- {
+ if (!fin) {
return false;
- }
- const char *realbuffer;
+ }
+ const char* realbuffer;
std::string buffer;
std::string entryKey;
unsigned int lineno = 0;
- while(fin)
- {
+ while (fin) {
// Format is key:type=value
std::string helpString;
CacheEntry e;
cmSystemTools::GetLineFromStream(fin, buffer);
lineno++;
realbuffer = buffer.c_str();
- while(*realbuffer != '0' &&
- (*realbuffer == ' ' ||
- *realbuffer == '\t' ||
- *realbuffer == '\r' ||
- *realbuffer == '\n'))
- {
- if (*realbuffer == '\n') lineno++;
+ while (*realbuffer != '0' &&
+ (*realbuffer == ' ' || *realbuffer == '\t' || *realbuffer == '\r' ||
+ *realbuffer == '\n')) {
+ if (*realbuffer == '\n')
+ lineno++;
realbuffer++;
- }
+ }
// skip blank lines and comment lines
- if(realbuffer[0] == '#' || realbuffer[0] == 0)
- {
+ if (realbuffer[0] == '#' || realbuffer[0] == 0) {
continue;
- }
- while(realbuffer[0] == '/' && realbuffer[1] == '/')
- {
- if ((realbuffer[2] == '\\') && (realbuffer[3]=='n'))
- {
+ }
+ while (realbuffer[0] == '/' && realbuffer[1] == '/') {
+ if ((realbuffer[2] == '\\') && (realbuffer[3] == 'n')) {
helpString += "\n";
helpString += &realbuffer[4];
- }
- else
- {
+ } else {
helpString += &realbuffer[2];
- }
+ }
cmSystemTools::GetLineFromStream(fin, buffer);
lineno++;
realbuffer = buffer.c_str();
- if(!fin)
- {
+ if (!fin) {
continue;
- }
}
+ }
e.SetProperty("HELPSTRING", helpString.c_str());
- if(cmState::ParseCacheEntry(realbuffer, entryKey, e.Value, e.Type))
- {
- if ( excludes.find(entryKey) == excludes.end() )
- {
+ if (cmState::ParseCacheEntry(realbuffer, entryKey, e.Value, e.Type)) {
+ if (excludes.find(entryKey) == excludes.end()) {
// Load internal values if internal is set.
// If the entry is not internal to the cache being loaded
// or if it is in the list of internal entries to be
// imported, load it.
- if ( internal || (e.Type != cmState::INTERNAL) ||
- (includes.find(entryKey) != includes.end()) )
- {
+ if (internal || (e.Type != cmState::INTERNAL) ||
+ (includes.find(entryKey) != includes.end())) {
// If we are loading the cache from another project,
// make all loaded entries internal so that it is
// not visible in the gui
- if (!internal)
- {
+ if (!internal) {
e.Type = cmState::INTERNAL;
helpString = "DO NOT EDIT, ";
helpString += entryKey;
helpString += " loaded from external file. "
- "To change this value edit this file: ";
+ "To change this value edit this file: ";
helpString += path;
- helpString += "/CMakeCache.txt" ;
+ helpString += "/CMakeCache.txt";
e.SetProperty("HELPSTRING", helpString.c_str());
- }
- if(!this->ReadPropertyEntry(entryKey, e))
- {
+ }
+ if (!this->ReadPropertyEntry(entryKey, e)) {
e.Initialized = true;
this->Cache[entryKey] = e;
- }
}
}
}
- else
- {
+ } else {
std::ostringstream error;
error << "Parse error in cache file " << cacheFile;
error << " on line " << lineno << ". Offending entry: " << realbuffer;
cmSystemTools::Error(error.str().c_str());
- }
}
+ }
this->CacheMajorVersion = 0;
this->CacheMinorVersion = 0;
- if(const char* cmajor =
- this->GetInitializedCacheValue("CMAKE_CACHE_MAJOR_VERSION"))
- {
- unsigned int v=0;
- if(sscanf(cmajor, "%u", &v) == 1)
- {
+ if (const char* cmajor =
+ this->GetInitializedCacheValue("CMAKE_CACHE_MAJOR_VERSION")) {
+ unsigned int v = 0;
+ if (sscanf(cmajor, "%u", &v) == 1) {
this->CacheMajorVersion = v;
- }
- if(const char* cminor =
- this->GetInitializedCacheValue("CMAKE_CACHE_MINOR_VERSION"))
- {
- if(sscanf(cminor, "%u", &v) == 1)
- {
+ }
+ if (const char* cminor =
+ this->GetInitializedCacheValue("CMAKE_CACHE_MINOR_VERSION")) {
+ if (sscanf(cminor, "%u", &v) == 1) {
this->CacheMinorVersion = v;
- }
}
}
- else
- {
+ } else {
// CMake version not found in the list file.
// Set as version 0.0
this->AddCacheEntry("CMAKE_CACHE_MINOR_VERSION", "0",
"Minor version of cmake used to create the "
- "current loaded cache", cmState::INTERNAL);
+ "current loaded cache",
+ cmState::INTERNAL);
this->AddCacheEntry("CMAKE_CACHE_MAJOR_VERSION", "0",
"Major version of cmake used to create the "
- "current loaded cache", cmState::INTERNAL);
-
- }
+ "current loaded cache",
+ cmState::INTERNAL);
+ }
// check to make sure the cache directory has not
// been moved
const char* oldDir = this->GetInitializedCacheValue("CMAKE_CACHEFILE_DIR");
- if (internal && oldDir)
- {
+ if (internal && oldDir) {
std::string currentcwd = path;
std::string oldcwd = oldDir;
cmSystemTools::ConvertToUnixSlashes(currentcwd);
currentcwd += "/CMakeCache.txt";
oldcwd += "/CMakeCache.txt";
- if(!cmSystemTools::SameFile(oldcwd, currentcwd))
- {
+ if (!cmSystemTools::SameFile(oldcwd, currentcwd)) {
std::string message =
- std::string("The current CMakeCache.txt directory ") +
- currentcwd + std::string(" is different than the directory ") +
+ std::string("The current CMakeCache.txt directory ") + currentcwd +
+ std::string(" is different than the directory ") +
std::string(this->GetInitializedCacheValue("CMAKE_CACHEFILE_DIR")) +
std::string(" where CMakeCache.txt was created. This may result "
"in binaries being created in the wrong place. If you "
"are not sure, reedit the CMakeCache.txt");
cmSystemTools::Error(message.c_str());
- }
}
+ }
return true;
}
-const char* cmCacheManager::PersistentProperties[] =
-{
- "ADVANCED",
- "MODIFIED",
- "STRINGS",
- 0
-};
+const char* cmCacheManager::PersistentProperties[] = { "ADVANCED", "MODIFIED",
+ "STRINGS", 0 };
bool cmCacheManager::ReadPropertyEntry(std::string const& entryKey,
CacheEntry& e)
{
// All property entries are internal.
- if(e.Type != cmState::INTERNAL)
- {
+ if (e.Type != cmState::INTERNAL) {
return false;
- }
+ }
const char* end = entryKey.c_str() + entryKey.size();
- for(const char** p = this->PersistentProperties; *p; ++p)
- {
+ for (const char** p = this->PersistentProperties; *p; ++p) {
std::string::size_type plen = strlen(*p) + 1;
- if(entryKey.size() > plen && *(end-plen) == '-' &&
- strcmp(end-plen+1, *p) == 0)
- {
+ if (entryKey.size() > plen && *(end - plen) == '-' &&
+ strcmp(end - plen + 1, *p) == 0) {
std::string key = entryKey.substr(0, entryKey.size() - plen);
cmCacheManager::CacheIterator it = this->GetCacheIterator(key.c_str());
- if(it.IsAtEnd())
- {
+ if (it.IsAtEnd()) {
// Create an entry and store the property.
CacheEntry& ne = this->Cache[key];
ne.Type = cmState::UNINITIALIZED;
ne.SetProperty(*p, e.Value.c_str());
- }
- else
- {
+ } else {
// Store this property on its entry.
it.SetProperty(*p, e.Value.c_str());
- }
- return true;
}
+ return true;
}
+ }
return false;
}
void cmCacheManager::WritePropertyEntries(std::ostream& os,
CacheIterator const& i)
{
- for(const char** p = this->PersistentProperties; *p; ++p)
- {
- if(const char* value = i.GetProperty(*p))
- {
+ for (const char** p = this->PersistentProperties; *p; ++p) {
+ if (const char* value = i.GetProperty(*p)) {
std::string helpstring = *p;
helpstring += " property for variable: ";
helpstring += i.GetName();
@@ -267,8 +227,8 @@ void cmCacheManager::WritePropertyEntries(std::ostream& os,
os << ":INTERNAL=";
this->OutputValue(os, value);
os << "\n";
- }
}
+ }
}
bool cmCacheManager::SaveCache(const std::string& path)
@@ -277,43 +237,44 @@ bool cmCacheManager::SaveCache(const std::string& path)
cacheFile += "/CMakeCache.txt";
cmGeneratedFileStream fout(cacheFile.c_str());
fout.SetCopyIfDifferent(true);
- if(!fout)
- {
+ if (!fout) {
cmSystemTools::Error("Unable to open cache file for save. ",
cacheFile.c_str());
cmSystemTools::ReportLastSystemError("");
return false;
- }
+ }
// before writing the cache, update the version numbers
// to the
char temp[1024];
sprintf(temp, "%d", cmVersion::GetMinorVersion());
this->AddCacheEntry("CMAKE_CACHE_MINOR_VERSION", temp,
"Minor version of cmake used to create the "
- "current loaded cache", cmState::INTERNAL);
+ "current loaded cache",
+ cmState::INTERNAL);
sprintf(temp, "%d", cmVersion::GetMajorVersion());
this->AddCacheEntry("CMAKE_CACHE_MAJOR_VERSION", temp,
"Major version of cmake used to create the "
- "current loaded cache", cmState::INTERNAL);
+ "current loaded cache",
+ cmState::INTERNAL);
sprintf(temp, "%d", cmVersion::GetPatchVersion());
this->AddCacheEntry("CMAKE_CACHE_PATCH_VERSION", temp,
"Patch version of cmake used to create the "
- "current loaded cache", cmState::INTERNAL);
+ "current loaded cache",
+ cmState::INTERNAL);
// Let us store the current working directory so that if somebody
// Copies it, he will not be surprised
std::string currentcwd = path;
- if ( currentcwd[0] >= 'A' && currentcwd[0] <= 'Z' &&
- currentcwd[1] == ':' )
- {
+ if (currentcwd[0] >= 'A' && currentcwd[0] <= 'Z' && currentcwd[1] == ':') {
// Cast added to avoid compiler warning. Cast is ok because
// value is guaranteed to fit in char by the above if...
currentcwd[0] = static_cast<char>(currentcwd[0] - 'A' + 'a');
- }
+ }
cmSystemTools::ConvertToUnixSlashes(currentcwd);
this->AddCacheEntry("CMAKE_CACHEFILE_DIR", currentcwd.c_str(),
"This is the directory where this CMakeCache.txt"
- " was created", cmState::INTERNAL);
+ " was created",
+ cmState::INTERNAL);
/* clang-format off */
fout << "# This is the CMakeCache file.\n"
@@ -342,36 +303,30 @@ bool cmCacheManager::SaveCache(const std::string& path)
fout << "########################\n";
fout << "\n";
- for( std::map<std::string, CacheEntry>::const_iterator i =
- this->Cache.begin(); i != this->Cache.end(); ++i)
- {
+ for (std::map<std::string, CacheEntry>::const_iterator i =
+ this->Cache.begin();
+ i != this->Cache.end(); ++i) {
const CacheEntry& ce = (*i).second;
cmState::CacheEntryType t = ce.Type;
- if(!ce.Initialized)
- {
+ if (!ce.Initialized) {
/*
// This should be added in, but is not for now.
cmSystemTools::Error("Cache entry \"", (*i).first.c_str(),
"\" is uninitialized");
*/
- }
- else if(t != cmState::INTERNAL)
- {
+ } else if (t != cmState::INTERNAL) {
// Format is key:type=value
- if(const char* help = ce.GetProperty("HELPSTRING"))
- {
+ if (const char* help = ce.GetProperty("HELPSTRING")) {
cmCacheManager::OutputHelpString(fout, help);
- }
- else
- {
+ } else {
cmCacheManager::OutputHelpString(fout, "Missing description");
- }
+ }
this->OutputKey(fout, i->first);
fout << ":" << cmState::CacheEntryTypeToString(t) << "=";
this->OutputValue(fout, ce.Value);
fout << "\n\n";
- }
}
+ }
fout << "\n";
fout << "########################\n";
@@ -379,29 +334,25 @@ bool cmCacheManager::SaveCache(const std::string& path)
fout << "########################\n";
fout << "\n";
- for( cmCacheManager::CacheIterator i = this->NewIterator();
- !i.IsAtEnd(); i.Next())
- {
- if ( !i.Initialized() )
- {
+ for (cmCacheManager::CacheIterator i = this->NewIterator(); !i.IsAtEnd();
+ i.Next()) {
+ if (!i.Initialized()) {
continue;
- }
+ }
cmState::CacheEntryType t = i.GetType();
this->WritePropertyEntries(fout, i);
- if(t == cmState::INTERNAL)
- {
+ if (t == cmState::INTERNAL) {
// Format is key:type=value
- if(const char* help = i.GetProperty("HELPSTRING"))
- {
+ if (const char* help = i.GetProperty("HELPSTRING")) {
this->OutputHelpString(fout, help);
- }
+ }
this->OutputKey(fout, i.GetName());
fout << ":" << cmState::CacheEntryTypeToString(t) << "=";
this->OutputValue(fout, i.GetValue());
fout << "\n";
- }
}
+ }
fout << "\n";
fout.Close();
std::string checkCacheFile = path;
@@ -409,14 +360,13 @@ bool cmCacheManager::SaveCache(const std::string& path)
cmSystemTools::MakeDirectory(checkCacheFile.c_str());
checkCacheFile += "/cmake.check_cache";
cmsys::ofstream checkCache(checkCacheFile.c_str());
- if(!checkCache)
- {
+ if (!checkCache) {
cmSystemTools::Error("Unable to open check cache file for write. ",
checkCacheFile.c_str());
return false;
- }
+ }
checkCache << "# This file is generated by cmake for dependency checking "
- "of the CMakeCache.txt file\n";
+ "of the CMakeCache.txt file\n";
return true;
}
@@ -426,25 +376,23 @@ bool cmCacheManager::DeleteCache(const std::string& path)
cmSystemTools::ConvertToUnixSlashes(cacheFile);
std::string cmakeFiles = cacheFile;
cacheFile += "/CMakeCache.txt";
- if(cmSystemTools::FileExists(cacheFile.c_str()))
- {
+ if (cmSystemTools::FileExists(cacheFile.c_str())) {
cmSystemTools::RemoveFile(cacheFile);
// now remove the files in the CMakeFiles directory
// this cleans up language cache files
cmakeFiles += cmake::GetCMakeFilesDirectory();
- if(cmSystemTools::FileIsDirectory(cmakeFiles))
- {
+ if (cmSystemTools::FileIsDirectory(cmakeFiles)) {
cmSystemTools::RemoveADirectory(cmakeFiles);
- }
}
+ }
return true;
}
void cmCacheManager::OutputKey(std::ostream& fout, std::string const& key)
{
// support : in key name by double quoting
- const char* q = (key.find(':') != key.npos ||
- key.find("//") == 0)? "\"" : "";
+ const char* q =
+ (key.find(':') != key.npos || key.find("//") == 0) ? "\"" : "";
fout << q << key << q;
}
@@ -452,147 +400,120 @@ void cmCacheManager::OutputValue(std::ostream& fout, std::string const& value)
{
// if value has trailing space or tab, enclose it in single quotes
if (!value.empty() &&
- (value[value.size() - 1] == ' ' ||
- value[value.size() - 1] == '\t'))
- {
+ (value[value.size() - 1] == ' ' || value[value.size() - 1] == '\t')) {
fout << '\'' << value << '\'';
- }
- else
- {
+ } else {
fout << value;
- }
+ }
}
void cmCacheManager::OutputHelpString(std::ostream& fout,
const std::string& helpString)
{
std::string::size_type end = helpString.size();
- if(end == 0)
- {
+ if (end == 0) {
return;
- }
+ }
std::string oneLine;
std::string::size_type pos = 0;
- for (std::string::size_type i=0; i<=end; i++)
- {
- if ((i==end)
- || (helpString[i]=='\n')
- || ((i-pos >= 60) && (helpString[i]==' ')))
- {
+ for (std::string::size_type i = 0; i <= end; i++) {
+ if ((i == end) || (helpString[i] == '\n') ||
+ ((i - pos >= 60) && (helpString[i] == ' '))) {
fout << "//";
- if (helpString[pos] == '\n')
- {
+ if (helpString[pos] == '\n') {
pos++;
fout << "\\n";
- }
+ }
oneLine = helpString.substr(pos, i - pos);
fout << oneLine << "\n";
pos = i;
- }
}
+ }
}
void cmCacheManager::RemoveCacheEntry(const std::string& key)
{
CacheEntryMap::iterator i = this->Cache.find(key);
- if(i != this->Cache.end())
- {
+ if (i != this->Cache.end()) {
this->Cache.erase(i);
- }
+ }
}
-
-cmCacheManager::CacheEntry *cmCacheManager::GetCacheEntry(
- const std::string& key)
+cmCacheManager::CacheEntry* cmCacheManager::GetCacheEntry(
+ const std::string& key)
{
CacheEntryMap::iterator i = this->Cache.find(key);
- if(i != this->Cache.end())
- {
+ if (i != this->Cache.end()) {
return &i->second;
- }
+ }
return 0;
}
-cmCacheManager::CacheIterator cmCacheManager::GetCacheIterator(
- const char *key)
+cmCacheManager::CacheIterator cmCacheManager::GetCacheIterator(const char* key)
{
return CacheIterator(*this, key);
}
-const char*
-cmCacheManager::GetInitializedCacheValue(const std::string& key) const
+const char* cmCacheManager::GetInitializedCacheValue(
+ const std::string& key) const
{
CacheEntryMap::const_iterator i = this->Cache.find(key);
- if(i != this->Cache.end() &&
- i->second.Initialized)
- {
+ if (i != this->Cache.end() && i->second.Initialized) {
return i->second.Value.c_str();
- }
+ }
return 0;
}
-
void cmCacheManager::PrintCache(std::ostream& out) const
{
out << "=================================================" << std::endl;
out << "CMakeCache Contents:" << std::endl;
- for(std::map<std::string, CacheEntry>::const_iterator i =
- this->Cache.begin(); i != this->Cache.end(); ++i)
- {
- if((*i).second.Type != cmState::INTERNAL)
- {
- out << (*i).first << " = " << (*i).second.Value
- << std::endl;
- }
+ for (std::map<std::string, CacheEntry>::const_iterator i =
+ this->Cache.begin();
+ i != this->Cache.end(); ++i) {
+ if ((*i).second.Type != cmState::INTERNAL) {
+ out << (*i).first << " = " << (*i).second.Value << std::endl;
}
+ }
out << "\n\n";
- out << "To change values in the CMakeCache, "
- << std::endl << "edit CMakeCache.txt in your output directory.\n";
+ out << "To change values in the CMakeCache, " << std::endl
+ << "edit CMakeCache.txt in your output directory.\n";
out << "=================================================" << std::endl;
}
-
-void cmCacheManager::AddCacheEntry(const std::string& key,
- const char* value,
+void cmCacheManager::AddCacheEntry(const std::string& key, const char* value,
const char* helpString,
cmState::CacheEntryType type)
{
CacheEntry& e = this->Cache[key];
- if ( value )
- {
+ if (value) {
e.Value = value;
e.Initialized = true;
- }
- else
- {
+ } else {
e.Value = "";
- }
+ }
e.Type = type;
// make sure we only use unix style paths
- if(type == cmState::FILEPATH || type == cmState::PATH)
- {
- if(e.Value.find(';') != e.Value.npos)
- {
+ if (type == cmState::FILEPATH || type == cmState::PATH) {
+ if (e.Value.find(';') != e.Value.npos) {
std::vector<std::string> paths;
cmSystemTools::ExpandListArgument(e.Value, paths);
const char* sep = "";
e.Value = "";
- for(std::vector<std::string>::iterator i = paths.begin();
- i != paths.end(); ++i)
- {
+ for (std::vector<std::string>::iterator i = paths.begin();
+ i != paths.end(); ++i) {
cmSystemTools::ConvertToUnixSlashes(*i);
e.Value += sep;
e.Value += *i;
sep = ";";
- }
}
- else
- {
+ } else {
cmSystemTools::ConvertToUnixSlashes(e.Value);
- }
}
- e.SetProperty("HELPSTRING", helpString? helpString :
- "(This variable does not exist and should not be used)");
+ }
+ e.SetProperty("HELPSTRING", helpString
+ ? helpString
+ : "(This variable does not exist and should not be used)");
}
bool cmCacheManager::CacheIterator::IsAtEnd() const
@@ -613,28 +534,23 @@ bool cmCacheManager::CacheIterator::Find(const std::string& key)
void cmCacheManager::CacheIterator::Next()
{
- if (!this->IsAtEnd())
- {
+ if (!this->IsAtEnd()) {
++this->Position;
- }
+ }
}
void cmCacheManager::CacheIterator::SetValue(const char* value)
{
- if (this->IsAtEnd())
- {
+ if (this->IsAtEnd()) {
return;
- }
+ }
CacheEntry* entry = &this->GetEntry();
- if ( value )
- {
+ if (value) {
entry->Value = value;
entry->Initialized = true;
- }
- else
- {
+ } else {
entry->Value = "";
- }
+ }
}
bool cmCacheManager::CacheIterator::GetValueAsBool() const
@@ -642,98 +558,79 @@ bool cmCacheManager::CacheIterator::GetValueAsBool() const
return cmSystemTools::IsOn(this->GetEntry().Value.c_str());
}
-const char*
-cmCacheManager::CacheEntry::GetProperty(const std::string& prop) const
+const char* cmCacheManager::CacheEntry::GetProperty(
+ const std::string& prop) const
{
- if(prop == "TYPE")
- {
+ if (prop == "TYPE") {
return cmState::CacheEntryTypeToString(this->Type);
- }
- else if(prop == "VALUE")
- {
+ } else if (prop == "VALUE") {
return this->Value.c_str();
- }
+ }
return this->Properties.GetPropertyValue(prop);
}
void cmCacheManager::CacheEntry::SetProperty(const std::string& prop,
const char* value)
{
- if(prop == "TYPE")
- {
- this->Type = cmState::StringToCacheEntryType(value? value : "STRING");
- }
- else if(prop == "VALUE")
- {
- this->Value = value? value : "";
- }
- else
- {
+ if (prop == "TYPE") {
+ this->Type = cmState::StringToCacheEntryType(value ? value : "STRING");
+ } else if (prop == "VALUE") {
+ this->Value = value ? value : "";
+ } else {
this->Properties.SetProperty(prop, value);
- }
+ }
}
void cmCacheManager::CacheEntry::AppendProperty(const std::string& prop,
const char* value,
bool asString)
{
- if(prop == "TYPE")
- {
- this->Type = cmState::StringToCacheEntryType(value? value : "STRING");
- }
- else if(prop == "VALUE")
- {
- if(value)
- {
- if(!this->Value.empty() && *value && !asString)
- {
+ if (prop == "TYPE") {
+ this->Type = cmState::StringToCacheEntryType(value ? value : "STRING");
+ } else if (prop == "VALUE") {
+ if (value) {
+ if (!this->Value.empty() && *value && !asString) {
this->Value += ";";
- }
- this->Value += value;
}
+ this->Value += value;
}
- else
- {
+ } else {
this->Properties.AppendProperty(prop, value, asString);
- }
+ }
}
const char* cmCacheManager::CacheIterator::GetProperty(
- const std::string& prop) const
+ const std::string& prop) const
{
- if(!this->IsAtEnd())
- {
+ if (!this->IsAtEnd()) {
return this->GetEntry().GetProperty(prop);
- }
+ }
return 0;
}
void cmCacheManager::CacheIterator::SetProperty(const std::string& p,
const char* v)
{
- if(!this->IsAtEnd())
- {
+ if (!this->IsAtEnd()) {
this->GetEntry().SetProperty(p, v);
- }
+ }
}
void cmCacheManager::CacheIterator::AppendProperty(const std::string& p,
const char* v,
bool asString)
{
- if(!this->IsAtEnd())
- {
+ if (!this->IsAtEnd()) {
this->GetEntry().AppendProperty(p, v, asString);
- }
+ }
}
bool cmCacheManager::CacheIterator::GetPropertyAsBool(
- const std::string& prop) const
+ const std::string& prop) const
{
- if(const char* value = this->GetProperty(prop))
- {
+ if (const char* value = this->GetProperty(prop)) {
return cmSystemTools::IsOn(value);
- }
+ }
return false;
}
@@ -743,7 +640,7 @@ void cmCacheManager::CacheIterator::SetProperty(const std::string& p, bool v)
}
bool cmCacheManager::CacheIterator::PropertyExists(
- const std::string& prop) const
+ const std::string& prop) const
{
- return this->GetProperty(prop)? true:false;
+ return this->GetProperty(prop) ? true : false;
}
diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h
index 614ff69..e9b80cb 100644
--- a/Source/cmCacheManager.h
+++ b/Source/cmCacheManager.h
@@ -41,13 +41,14 @@ private:
const char* GetProperty(const std::string&) const;
void SetProperty(const std::string& property, const char* value);
void AppendProperty(const std::string& property, const char* value,
- bool asString=false);
+ bool asString = false);
bool Initialized;
CacheEntry()
- : Value(""),
- Type(cmState::UNINITIALIZED),
- Initialized(false)
- {}
+ : Value("")
+ , Type(cmState::UNINITIALIZED)
+ , Initialized(false)
+ {
+ }
};
public:
@@ -58,45 +59,42 @@ public:
bool Find(const std::string&);
bool IsAtEnd() const;
void Next();
- std::string GetName() const {
- return this->Position->first; }
- const char* GetProperty(const std::string&) const ;
- bool GetPropertyAsBool(const std::string&) const ;
+ std::string GetName() const { return this->Position->first; }
+ const char* GetProperty(const std::string&) const;
+ bool GetPropertyAsBool(const std::string&) const;
bool PropertyExists(const std::string&) const;
void SetProperty(const std::string& property, const char* value);
void AppendProperty(const std::string& property, const char* value,
- bool asString=false);
+ bool asString = false);
void SetProperty(const std::string& property, bool value);
const char* GetValue() const { return this->GetEntry().Value.c_str(); }
bool GetValueAsBool() const;
void SetValue(const char*);
- cmState::CacheEntryType GetType() const
- { return this->GetEntry().Type; }
- void SetType(cmState::CacheEntryType ty)
- { this->GetEntry().Type = ty; }
+ cmState::CacheEntryType GetType() const { return this->GetEntry().Type; }
+ void SetType(cmState::CacheEntryType ty) { this->GetEntry().Type = ty; }
bool Initialized() { return this->GetEntry().Initialized; }
- cmCacheManager &Container;
+ cmCacheManager& Container;
std::map<std::string, CacheEntry>::iterator Position;
- CacheIterator(cmCacheManager &cm) : Container(cm) {
+ CacheIterator(cmCacheManager& cm)
+ : Container(cm)
+ {
this->Begin();
}
- CacheIterator(cmCacheManager &cm, const char* key) : Container(cm)
- {
- if ( key )
- {
+ CacheIterator(cmCacheManager& cm, const char* key)
+ : Container(cm)
+ {
+ if (key) {
this->Find(key);
- }
}
+ }
+
private:
CacheEntry const& GetEntry() const { return this->Position->second; }
CacheEntry& GetEntry() { return this->Position->second; }
};
///! return an iterator to iterate through the cache map
- cmCacheManager::CacheIterator NewIterator()
- {
- return CacheIterator(*this);
- }
+ cmCacheManager::CacheIterator NewIterator() { return CacheIterator(*this); }
///! Load a cache for given makefile. Loads from path/CMakeCache.txt.
bool LoadCache(const std::string& path, bool internal,
@@ -104,7 +102,7 @@ public:
std::set<std::string>& includes);
///! Save cache for given makefile. Saves to ouput path/CMakeCache.txt
- bool SaveCache(const std::string& path) ;
+ bool SaveCache(const std::string& path);
///! Delete the cache given
bool DeleteCache(const std::string& path);
@@ -113,14 +111,13 @@ public:
void PrintCache(std::ostream&) const;
///! Get the iterator for an entry with a given key.
- cmCacheManager::CacheIterator GetCacheIterator(const char *key=0);
+ cmCacheManager::CacheIterator GetCacheIterator(const char* key = 0);
///! Remove an entry from the cache
void RemoveCacheEntry(const std::string& key);
///! Get the number of entries in the cache
- int GetSize() {
- return static_cast<int>(this->Cache.size()); }
+ int GetSize() { return static_cast<int>(this->Cache.size()); }
///! Get a value from the cache given a key
const char* GetInitializedCacheValue(const std::string& key) const;
@@ -128,10 +125,9 @@ public:
const char* GetCacheEntryValue(const std::string& key)
{
cmCacheManager::CacheIterator it = this->GetCacheIterator(key.c_str());
- if (it.IsAtEnd())
- {
+ if (it.IsAtEnd()) {
return 0;
- }
+ }
return it.GetValue();
}
@@ -160,14 +156,12 @@ public:
}
void SetCacheEntryBoolProperty(std::string const& key,
- std::string const& propName,
- bool value)
+ std::string const& propName, bool value)
{
this->GetCacheIterator(key.c_str()).SetProperty(propName, value);
}
- void SetCacheEntryValue(std::string const& key,
- std::string const& value)
+ void SetCacheEntryValue(std::string const& key, std::string const& value)
{
this->GetCacheIterator(key.c_str()).SetValue(value.c_str());
}
@@ -183,9 +177,8 @@ public:
std::string const& value,
bool asString = false)
{
- this->GetCacheIterator(key.c_str()).AppendProperty(propName,
- value.c_str(),
- asString);
+ this->GetCacheIterator(key.c_str())
+ .AppendProperty(propName, value.c_str(), asString);
}
std::vector<std::string> GetCacheEntryKeys()
@@ -193,36 +186,33 @@ public:
std::vector<std::string> definitions;
definitions.reserve(this->GetSize());
cmCacheManager::CacheIterator cit = this->GetCacheIterator();
- for ( cit.Begin(); !cit.IsAtEnd(); cit.Next() )
- {
+ for (cit.Begin(); !cit.IsAtEnd(); cit.Next()) {
definitions.push_back(cit.GetName());
- }
+ }
return definitions;
}
/** Get the version of CMake that wrote the cache. */
- unsigned int GetCacheMajorVersion() const
- { return this->CacheMajorVersion; }
- unsigned int GetCacheMinorVersion() const
- { return this->CacheMinorVersion; }
+ unsigned int GetCacheMajorVersion() const { return this->CacheMajorVersion; }
+ unsigned int GetCacheMinorVersion() const { return this->CacheMinorVersion; }
protected:
///! Add an entry into the cache
void AddCacheEntry(const std::string& key, const char* value,
- const char* helpString,
- cmState::CacheEntryType type);
+ const char* helpString, cmState::CacheEntryType type);
///! Get a cache entry object for a key
- CacheEntry *GetCacheEntry(const std::string& key);
+ CacheEntry* GetCacheEntry(const std::string& key);
///! Clean out the CMakeFiles directory if no CMakeCache.txt
void CleanCMakeFiles(const std::string& path);
// Cache version info
unsigned int CacheMajorVersion;
unsigned int CacheMinorVersion;
+
private:
cmake* CMakeInstance;
- typedef std::map<std::string, CacheEntry> CacheEntryMap;
+ typedef std::map<std::string, CacheEntry> CacheEntryMap;
static void OutputHelpString(std::ostream& fout,
const std::string& helpString);
static void OutputKey(std::ostream& fout, std::string const& key);
@@ -236,7 +226,7 @@ private:
// Only cmake and cmState should be able to add cache values
// the commands should never use the cmCacheManager directly
friend class cmState; // allow access to add cache values
- friend class cmake; // allow access to add cache values
+ friend class cmake; // allow access to add cache values
};
#endif
diff --git a/Source/cmCallVisualStudioMacro.cxx b/Source/cmCallVisualStudioMacro.cxx
index 9cc5a69..e608d6b 100644
--- a/Source/cmCallVisualStudioMacro.cxx
+++ b/Source/cmCallVisualStudioMacro.cxx
@@ -13,86 +13,73 @@
#include "cmSystemTools.h"
-
#if defined(_MSC_VER)
#define HAVE_COMDEF_H
#endif
-
// Just for this file:
//
static bool LogErrorsAsMessages;
-
#if defined(HAVE_COMDEF_H)
-
#include <comdef.h>
-
// Copied from a correct comdef.h to avoid problems with deficient versions
// of comdef.h that exist in the wild... Fixes issue #7533.
//
#ifdef _NATIVE_WCHAR_T_DEFINED
-# ifdef _DEBUG
-# pragma comment(lib, "comsuppwd.lib")
-# else
-# pragma comment(lib, "comsuppw.lib")
-# endif
+#ifdef _DEBUG
+#pragma comment(lib, "comsuppwd.lib")
#else
-# ifdef _DEBUG
-# pragma comment(lib, "comsuppd.lib")
-# else
-# pragma comment(lib, "comsupp.lib")
-# endif
+#pragma comment(lib, "comsuppw.lib")
+#endif
+#else
+#ifdef _DEBUG
+#pragma comment(lib, "comsuppd.lib")
+#else
+#pragma comment(lib, "comsupp.lib")
+#endif
#endif
-
///! Use ReportHRESULT to make a cmSystemTools::Message after calling
///! a COM method that may have failed.
-#define ReportHRESULT(hr, context) \
- if (FAILED(hr)) \
- { \
- if (LogErrorsAsMessages) \
- { \
- std::ostringstream _hresult_oss; \
- _hresult_oss.flags(std::ios::hex); \
- _hresult_oss << context << " failed HRESULT, hr = 0x" \
- << hr << std::endl; \
- _hresult_oss.flags(std::ios::dec); \
- _hresult_oss << __FILE__ << "(" << __LINE__ << ")"; \
- cmSystemTools::Message(_hresult_oss.str().c_str()); \
- } \
- }
-
+#define ReportHRESULT(hr, context) \
+ if (FAILED(hr)) { \
+ if (LogErrorsAsMessages) { \
+ std::ostringstream _hresult_oss; \
+ _hresult_oss.flags(std::ios::hex); \
+ _hresult_oss << context << " failed HRESULT, hr = 0x" << hr \
+ << std::endl; \
+ _hresult_oss.flags(std::ios::dec); \
+ _hresult_oss << __FILE__ << "(" << __LINE__ << ")"; \
+ cmSystemTools::Message(_hresult_oss.str().c_str()); \
+ } \
+ }
///! Using the given instance of Visual Studio, call the named macro
-HRESULT InstanceCallMacro(
- IDispatch* vsIDE,
- const std::string& macro,
- const std::string& args)
+HRESULT InstanceCallMacro(IDispatch* vsIDE, const std::string& macro,
+ const std::string& args)
{
HRESULT hr = E_POINTER;
_bstr_t macroName(macro.c_str());
_bstr_t macroArgs(args.c_str());
- if (0 != vsIDE)
- {
- DISPID dispid = (DISPID) -1;
- OLECHAR *name = L"ExecuteCommand";
+ if (0 != vsIDE) {
+ DISPID dispid = (DISPID)-1;
+ OLECHAR* name = L"ExecuteCommand";
- hr = vsIDE->GetIDsOfNames(IID_NULL, &name, 1,
- LOCALE_USER_DEFAULT, &dispid);
+ hr =
+ vsIDE->GetIDsOfNames(IID_NULL, &name, 1, LOCALE_USER_DEFAULT, &dispid);
ReportHRESULT(hr, "GetIDsOfNames(ExecuteCommand)");
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
VARIANTARG vargs[2];
DISPPARAMS params;
VARIANT result;
EXCEPINFO excep;
- UINT arg = (UINT) -1;
+ UINT arg = (UINT)-1;
// No VariantInit or VariantClear calls are necessary for
// these two vargs. They are both local _bstr_t variables
@@ -105,7 +92,7 @@ HRESULT InstanceCallMacro(
params.rgvarg = &vargs[0];
params.rgdispidNamedArgs = 0;
- params.cArgs = sizeof(vargs)/sizeof(vargs[0]);
+ params.cArgs = sizeof(vargs) / sizeof(vargs[0]);
params.cNamedArgs = 0;
VariantInit(&result);
@@ -113,7 +100,7 @@ HRESULT InstanceCallMacro(
memset(&excep, 0, sizeof(excep));
hr = vsIDE->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT,
- DISPATCH_METHOD, &params, &result, &excep, &arg);
+ DISPATCH_METHOD, &params, &result, &excep, &arg);
std::ostringstream oss;
oss << std::endl;
@@ -121,65 +108,56 @@ HRESULT InstanceCallMacro(
oss << " Macro: " << macro.c_str() << std::endl;
oss << " Args: " << args.c_str() << std::endl;
- if (DISP_E_EXCEPTION == hr)
- {
+ if (DISP_E_EXCEPTION == hr) {
oss << "DISP_E_EXCEPTION EXCEPINFO:" << excep.wCode << std::endl;
oss << " wCode: " << excep.wCode << std::endl;
oss << " wReserved: " << excep.wReserved << std::endl;
- if (excep.bstrSource)
- {
- oss << " bstrSource: " <<
- (const char*)(_bstr_t)excep.bstrSource << std::endl;
- }
- if (excep.bstrDescription)
- {
- oss << " bstrDescription: " <<
- (const char*)(_bstr_t)excep.bstrDescription << std::endl;
- }
- if (excep.bstrHelpFile)
- {
- oss << " bstrHelpFile: " <<
- (const char*)(_bstr_t)excep.bstrHelpFile << std::endl;
- }
+ if (excep.bstrSource) {
+ oss << " bstrSource: " << (const char*)(_bstr_t)excep.bstrSource
+ << std::endl;
+ }
+ if (excep.bstrDescription) {
+ oss << " bstrDescription: "
+ << (const char*)(_bstr_t)excep.bstrDescription << std::endl;
+ }
+ if (excep.bstrHelpFile) {
+ oss << " bstrHelpFile: " << (const char*)(_bstr_t)excep.bstrHelpFile
+ << std::endl;
+ }
oss << " dwHelpContext: " << excep.dwHelpContext << std::endl;
oss << " pvReserved: " << excep.pvReserved << std::endl;
oss << " pfnDeferredFillIn: " << excep.pfnDeferredFillIn << std::endl;
oss << " scode: " << excep.scode << std::endl;
- }
+ }
std::string exstr(oss.str());
ReportHRESULT(hr, exstr.c_str());
VariantClear(&result);
- }
}
+ }
return hr;
}
-
///! Get the Solution object from the IDE object
-HRESULT GetSolutionObject(
- IDispatch* vsIDE,
- IDispatchPtr& vsSolution)
+HRESULT GetSolutionObject(IDispatch* vsIDE, IDispatchPtr& vsSolution)
{
HRESULT hr = E_POINTER;
- if (0 != vsIDE)
- {
- DISPID dispid = (DISPID) -1;
- OLECHAR *name = L"Solution";
+ if (0 != vsIDE) {
+ DISPID dispid = (DISPID)-1;
+ OLECHAR* name = L"Solution";
- hr = vsIDE->GetIDsOfNames(IID_NULL, &name, 1,
- LOCALE_USER_DEFAULT, &dispid);
+ hr =
+ vsIDE->GetIDsOfNames(IID_NULL, &name, 1, LOCALE_USER_DEFAULT, &dispid);
ReportHRESULT(hr, "GetIDsOfNames(Solution)");
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
DISPPARAMS params;
VARIANT result;
EXCEPINFO excep;
- UINT arg = (UINT) -1;
+ UINT arg = (UINT)-1;
params.rgvarg = 0;
params.rgdispidNamedArgs = 0;
@@ -191,44 +169,38 @@ HRESULT GetSolutionObject(
memset(&excep, 0, sizeof(excep));
hr = vsIDE->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT,
- DISPATCH_PROPERTYGET, &params, &result, &excep, &arg);
+ DISPATCH_PROPERTYGET, &params, &result, &excep, &arg);
ReportHRESULT(hr, "Invoke(Solution)");
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
vsSolution = V_DISPATCH(&result);
- }
+ }
VariantClear(&result);
- }
}
+ }
return hr;
}
-
///! Get the FullName property from the Solution object
-HRESULT GetSolutionFullName(
- IDispatch* vsSolution,
- std::string& fullName)
+HRESULT GetSolutionFullName(IDispatch* vsSolution, std::string& fullName)
{
HRESULT hr = E_POINTER;
- if (0 != vsSolution)
- {
- DISPID dispid = (DISPID) -1;
- OLECHAR *name = L"FullName";
+ if (0 != vsSolution) {
+ DISPID dispid = (DISPID)-1;
+ OLECHAR* name = L"FullName";
- hr = vsSolution->GetIDsOfNames(IID_NULL, &name, 1,
- LOCALE_USER_DEFAULT, &dispid);
+ hr = vsSolution->GetIDsOfNames(IID_NULL, &name, 1, LOCALE_USER_DEFAULT,
+ &dispid);
ReportHRESULT(hr, "GetIDsOfNames(FullName)");
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
DISPPARAMS params;
VARIANT result;
EXCEPINFO excep;
- UINT arg = (UINT) -1;
+ UINT arg = (UINT)-1;
params.rgvarg = 0;
params.rgdispidNamedArgs = 0;
@@ -240,41 +212,36 @@ HRESULT GetSolutionFullName(
memset(&excep, 0, sizeof(excep));
hr = vsSolution->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT,
- DISPATCH_PROPERTYGET, &params, &result, &excep, &arg);
+ DISPATCH_PROPERTYGET, &params, &result, &excep,
+ &arg);
ReportHRESULT(hr, "Invoke(FullName)");
- if (SUCCEEDED(hr))
- {
- fullName = (std::string) (_bstr_t) V_BSTR(&result);
- }
+ if (SUCCEEDED(hr)) {
+ fullName = (std::string)(_bstr_t)V_BSTR(&result);
+ }
VariantClear(&result);
- }
}
+ }
return hr;
}
-
///! Get the FullName property from the Solution object, given the IDE object
-HRESULT GetIDESolutionFullName(
- IDispatch* vsIDE,
- std::string& fullName)
+HRESULT GetIDESolutionFullName(IDispatch* vsIDE, std::string& fullName)
{
IDispatchPtr vsSolution;
HRESULT hr = GetSolutionObject(vsIDE, vsSolution);
ReportHRESULT(hr, "GetSolutionObject");
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
GetSolutionFullName(vsSolution, fullName);
ReportHRESULT(hr, "GetSolutionFullName");
- }
+ }
return hr;
}
-
///! Get all running objects from the Windows running object table.
///! Save them in a map by their display names.
HRESULT GetRunningInstances(std::map<std::string, IUnknownPtr>& mrot)
@@ -289,22 +256,18 @@ HRESULT GetRunningInstances(std::map<std::string, IUnknownPtr>& mrot)
HRESULT hr = GetRunningObjectTable(0, &runningObjectTable);
ReportHRESULT(hr, "GetRunningObjectTable");
- if(SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
hr = runningObjectTable->EnumRunning(&monikerEnumerator);
ReportHRESULT(hr, "EnumRunning");
- }
+ }
- if(SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
hr = monikerEnumerator->Reset();
ReportHRESULT(hr, "Reset");
- }
+ }
- if(SUCCEEDED(hr))
- {
- while (S_OK == monikerEnumerator->Next(1, &moniker, &numFetched))
- {
+ if (SUCCEEDED(hr)) {
+ while (S_OK == monikerEnumerator->Next(1, &moniker, &numFetched)) {
std::string runningObjectName;
IUnknownPtr runningObjectVal;
IBindCtxPtr ctx;
@@ -312,44 +275,37 @@ HRESULT GetRunningInstances(std::map<std::string, IUnknownPtr>& mrot)
hr = CreateBindCtx(0, &ctx);
ReportHRESULT(hr, "CreateBindCtx");
- if(SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
LPOLESTR displayName = 0;
hr = moniker->GetDisplayName(ctx, 0, &displayName);
ReportHRESULT(hr, "GetDisplayName");
- if (displayName)
- {
- runningObjectName = (std::string) (_bstr_t) displayName;
+ if (displayName) {
+ runningObjectName = (std::string)(_bstr_t)displayName;
CoTaskMemFree(displayName);
- }
+ }
hr = runningObjectTable->GetObject(moniker, &runningObjectVal);
ReportHRESULT(hr, "GetObject");
- if(SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
mrot.insert(std::make_pair(runningObjectName, runningObjectVal));
- }
}
+ }
numFetched = 0;
moniker = 0;
- }
}
+ }
return hr;
}
-
///! Do the two file names refer to the same Visual Studio solution? Or are
///! we perhaps looking for any and all solutions?
-bool FilesSameSolution(
- const std::string& slnFile,
- const std::string& slnName)
+bool FilesSameSolution(const std::string& slnFile, const std::string& slnName)
{
- if (slnFile == "ALL" || slnName == "ALL")
- {
+ if (slnFile == "ALL" || slnName == "ALL") {
return true;
- }
+ }
// Otherwise, make lowercase local copies, convert to Unix slashes, and
// see if the resulting strings are the same:
@@ -361,56 +317,47 @@ bool FilesSameSolution(
return s1 == s2;
}
-
///! Find instances of Visual Studio with the given solution file
///! open. Pass "ALL" for slnFile to gather all running instances
///! of Visual Studio.
-HRESULT FindVisualStudioInstances(
- const std::string& slnFile,
- std::vector<IDispatchPtr>& instances)
+HRESULT FindVisualStudioInstances(const std::string& slnFile,
+ std::vector<IDispatchPtr>& instances)
{
std::map<std::string, IUnknownPtr> mrot;
HRESULT hr = GetRunningInstances(mrot);
ReportHRESULT(hr, "GetRunningInstances");
- if(SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
std::map<std::string, IUnknownPtr>::iterator it;
- for(it = mrot.begin(); it != mrot.end(); ++it)
- {
+ for (it = mrot.begin(); it != mrot.end(); ++it) {
if (cmSystemTools::StringStartsWith(it->first.c_str(),
- "!VisualStudio.DTE."))
- {
+ "!VisualStudio.DTE.")) {
IDispatchPtr disp(it->second);
- if (disp != (IDispatch*) 0)
- {
+ if (disp != (IDispatch*)0) {
std::string slnName;
hr = GetIDESolutionFullName(disp, slnName);
ReportHRESULT(hr, "GetIDESolutionFullName");
- if (FilesSameSolution(slnFile, slnName))
- {
+ if (FilesSameSolution(slnFile, slnName)) {
instances.push_back(disp);
- //std::cout << "Found Visual Studio instance." << std::endl;
- //std::cout << " ROT entry name: " << it->first << std::endl;
- //std::cout << " ROT entry object: "
+ // std::cout << "Found Visual Studio instance." << std::endl;
+ // std::cout << " ROT entry name: " << it->first << std::endl;
+ // std::cout << " ROT entry object: "
// << (IUnknown*) it->second << std::endl;
- //std::cout << " slnFile: " << slnFile << std::endl;
- //std::cout << " slnName: " << slnName << std::endl;
- }
+ // std::cout << " slnFile: " << slnFile << std::endl;
+ // std::cout << " slnName: " << slnName << std::endl;
}
}
}
}
+ }
return hr;
}
-
-#endif //defined(HAVE_COMDEF_H)
-
+#endif // defined(HAVE_COMDEF_H)
int cmCallVisualStudioMacro::GetNumberOfRunningVisualStudioInstances(
const std::string& slnFile)
@@ -423,22 +370,20 @@ int cmCallVisualStudioMacro::GetNumberOfRunningVisualStudioInstances(
HRESULT hr = CoInitialize(0);
ReportHRESULT(hr, "CoInitialize");
- if(SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
std::vector<IDispatchPtr> instances;
hr = FindVisualStudioInstances(slnFile, instances);
ReportHRESULT(hr, "FindVisualStudioInstances");
- if(SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
count = static_cast<int>(instances.size());
- }
+ }
// Force release all COM pointers before CoUninitialize:
instances.clear();
CoUninitialize();
- }
+ }
#else
(void)slnFile;
#endif
@@ -446,14 +391,12 @@ int cmCallVisualStudioMacro::GetNumberOfRunningVisualStudioInstances(
return count;
}
-
///! Get all running objects from the Windows running object table.
///! Save them in a map by their display names.
-int cmCallVisualStudioMacro::CallMacro(
- const std::string& slnFile,
- const std::string& macro,
- const std::string& args,
- const bool logErrorsAsMessages)
+int cmCallVisualStudioMacro::CallMacro(const std::string& slnFile,
+ const std::string& macro,
+ const std::string& args,
+ const bool logErrorsAsMessages)
{
int err = 1; // no comdef.h
@@ -465,60 +408,53 @@ int cmCallVisualStudioMacro::CallMacro(
HRESULT hr = CoInitialize(0);
ReportHRESULT(hr, "CoInitialize");
- if(SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
std::vector<IDispatchPtr> instances;
hr = FindVisualStudioInstances(slnFile, instances);
ReportHRESULT(hr, "FindVisualStudioInstances");
- if(SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
err = 0; // no error
std::vector<IDispatchPtr>::iterator it;
- for(it = instances.begin(); it != instances.end(); ++it)
- {
+ for (it = instances.begin(); it != instances.end(); ++it) {
hr = InstanceCallMacro(*it, macro, args);
ReportHRESULT(hr, "InstanceCallMacro");
- if (FAILED(hr))
- {
+ if (FAILED(hr)) {
err = 3; // error attempting to call the macro
- }
}
+ }
- if(instances.empty())
- {
+ if (instances.empty()) {
// no instances to call
- //cmSystemTools::Message(
+ // cmSystemTools::Message(
// "cmCallVisualStudioMacro::CallMacro no instances found to call",
// "Warning");
- }
}
+ }
// Force release all COM pointers before CoUninitialize:
instances.clear();
CoUninitialize();
- }
+ }
#else
(void)slnFile;
(void)macro;
(void)args;
- if (LogErrorsAsMessages)
- {
+ if (LogErrorsAsMessages) {
cmSystemTools::Message("cmCallVisualStudioMacro::CallMacro is not "
- "supported on this platform");
- }
+ "supported on this platform");
+ }
#endif
- if (err && LogErrorsAsMessages)
- {
+ if (err && LogErrorsAsMessages) {
std::ostringstream oss;
oss << "cmCallVisualStudioMacro::CallMacro failed, err = " << err;
cmSystemTools::Message(oss.str().c_str());
- }
+ }
return 0;
}
diff --git a/Source/cmCallVisualStudioMacro.h b/Source/cmCallVisualStudioMacro.h
index 09bddfa..e516fe2 100644
--- a/Source/cmCallVisualStudioMacro.h
+++ b/Source/cmCallVisualStudioMacro.h
@@ -26,8 +26,7 @@ public:
///! Call the named macro in instances of Visual Studio with the
///! given solution file open. Pass "ALL" for slnFile to call the
///! macro in each Visual Studio instance.
- static int CallMacro(const std::string& slnFile,
- const std::string& macro,
+ static int CallMacro(const std::string& slnFile, const std::string& macro,
const std::string& args,
const bool logErrorsAsMessages);
@@ -38,7 +37,6 @@ public:
const std::string& slnFile);
protected:
-
private:
};
diff --git a/Source/cmCommand.h b/Source/cmCommand.h
index d5e394d..0157293 100644
--- a/Source/cmCommand.h
+++ b/Source/cmCommand.h
@@ -37,7 +37,10 @@ public:
* Construct the command. By default it is enabled with no makefile.
*/
cmCommand()
- {this->Makefile = 0; this->Enabled = true;}
+ {
+ this->Makefile = 0;
+ this->Enabled = true;
+ }
/**
* Need virtual destructor to destroy real command type.
@@ -47,8 +50,7 @@ public:
/**
* Specify the makefile.
*/
- void SetMakefile(cmMakefile*m)
- {this->Makefile = m; }
+ void SetMakefile(cmMakefile* m) { this->Makefile = m; }
cmMakefile* GetMakefile() { return this->Makefile; }
/**
@@ -57,24 +59,23 @@ public:
* arguments and then invokes the InitialPass.
*/
virtual bool InvokeInitialPass(const std::vector<cmListFileArgument>& args,
- cmExecutionStatus &status)
- {
+ cmExecutionStatus& status)
+ {
std::vector<std::string> expandedArguments;
- if(!this->Makefile->ExpandArguments(args, expandedArguments))
- {
+ if (!this->Makefile->ExpandArguments(args, expandedArguments)) {
// There was an error expanding arguments. It was already
// reported, so we can skip this command without error.
return true;
- }
- return this->InitialPass(expandedArguments,status);
}
+ return this->InitialPass(expandedArguments, status);
+ }
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus &) = 0;
+ cmExecutionStatus&) = 0;
/**
* This is called at the end after all the information
@@ -97,10 +98,7 @@ public:
/**
* This determines if the command is invoked when in script mode.
*/
- virtual bool IsScriptable() const
- {
- return false;
- }
+ virtual bool IsScriptable() const { return false; }
/**
* This is used to avoid including this command
@@ -108,10 +106,7 @@ public:
* cmMacroHelperCommand and cmFunctionHelperCommand
* which cannot provide appropriate documentation.
*/
- virtual bool ShouldAppearInDocumentation() const
- {
- return true;
- }
+ virtual bool ShouldAppearInDocumentation() const { return true; }
/**
* The name of the command as specified in CMakeList.txt.
@@ -121,58 +116,52 @@ public:
/**
* Enable the command.
*/
- void EnabledOn()
- {this->Enabled = true;}
+ void EnabledOn() { this->Enabled = true; }
/**
* Disable the command.
*/
- void EnabledOff()
- {this->Enabled = false;}
+ void EnabledOff() { this->Enabled = false; }
/**
* Query whether the command is enabled.
*/
- bool GetEnabled() const
- {return this->Enabled;}
+ bool GetEnabled() const { return this->Enabled; }
/**
* Disable or enable the command.
*/
- void SetEnabled(bool enabled)
- {this->Enabled = enabled;}
+ void SetEnabled(bool enabled) { this->Enabled = enabled; }
/**
* Return the last error string.
*/
const char* GetError()
- {
- if(this->Error.empty())
- {
- this->Error = this->GetName();
- this->Error += " unknown error.";
- }
- return this->Error.c_str();
+ {
+ if (this->Error.empty()) {
+ this->Error = this->GetName();
+ this->Error += " unknown error.";
}
+ return this->Error.c_str();
+ }
/**
* Set the error message
*/
void SetError(const std::string& e)
- {
+ {
this->Error = this->GetName();
this->Error += " ";
this->Error += e;
- }
+ }
/** Check if the command is disallowed by a policy. */
bool Disallowed(cmPolicies::PolicyID pol, const char* e)
- {
- switch(this->Makefile->GetPolicyStatus(pol))
- {
+ {
+ switch (this->Makefile->GetPolicyStatus(pol)) {
case cmPolicies::WARN:
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING,
- cmPolicies::GetPolicyWarning(pol));
+ cmPolicies::GetPolicyWarning(pol));
case cmPolicies::OLD:
return false;
case cmPolicies::REQUIRED_IF_USED:
@@ -180,9 +169,9 @@ public:
case cmPolicies::NEW:
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e);
break;
- }
- return true;
}
+ return true;
+ }
protected:
cmMakefile* Makefile;
diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx
index 0b2fd81..a4f3c7d 100644
--- a/Source/cmCommandArgumentParserHelper.cxx
+++ b/Source/cmCommandArgumentParserHelper.cxx
@@ -18,7 +18,7 @@
#include "cmCommandArgumentLexer.h"
-int cmCommandArgument_yyparse( yyscan_t yyscanner );
+int cmCommandArgument_yyparse(yyscan_t yyscanner);
//
cmCommandArgumentParserHelper::cmCommandArgumentParserHelper()
{
@@ -30,7 +30,7 @@ cmCommandArgumentParserHelper::cmCommandArgumentParserHelper()
this->EmptyVariable[0] = 0;
strcpy(this->DCURLYVariable, "${");
strcpy(this->RCURLYVariable, "}");
- strcpy(this->ATVariable, "@");
+ strcpy(this->ATVariable, "@");
strcpy(this->DOLLARVariable, "$");
strcpy(this->LCURLYVariable, "{");
strcpy(this->BSLASHVariable, "\\");
@@ -39,7 +39,6 @@ cmCommandArgumentParserHelper::cmCommandArgumentParserHelper()
this->ReplaceAtSyntax = false;
}
-
cmCommandArgumentParserHelper::~cmCommandArgumentParserHelper()
{
this->CleanupParser();
@@ -53,11 +52,10 @@ void cmCommandArgumentParserHelper::SetLineFile(long line, const char* file)
char* cmCommandArgumentParserHelper::AddString(const std::string& str)
{
- if ( str.empty() )
- {
+ if (str.empty()) {
return this->EmptyVariable;
- }
- char* stVal = new char[str.size()+1];
+ }
+ char* stVal = new char[str.size() + 1];
strcpy(stVal, str.c_str());
this->Variables.push_back(stVal);
return stVal;
@@ -66,46 +64,34 @@ char* cmCommandArgumentParserHelper::AddString(const std::string& str)
char* cmCommandArgumentParserHelper::ExpandSpecialVariable(const char* key,
const char* var)
{
- if ( !key )
- {
+ if (!key) {
return this->ExpandVariable(var);
- }
- if(!var)
- {
+ }
+ if (!var) {
return this->EmptyVariable;
- }
- if ( strcmp(key, "ENV") == 0 )
- {
- char *ptr = getenv(var);
- if (ptr)
- {
- if (this->EscapeQuotes)
- {
+ }
+ if (strcmp(key, "ENV") == 0) {
+ char* ptr = getenv(var);
+ if (ptr) {
+ if (this->EscapeQuotes) {
return this->AddString(cmSystemTools::EscapeQuotes(ptr));
- }
- else
- {
+ } else {
return ptr;
- }
}
- return this->EmptyVariable;
}
- if ( strcmp(key, "CACHE") == 0 )
- {
- if(const char* c = this->Makefile->GetState()
- ->GetInitializedCacheValue(var))
- {
- if(this->EscapeQuotes)
- {
+ return this->EmptyVariable;
+ }
+ if (strcmp(key, "CACHE") == 0) {
+ if (const char* c =
+ this->Makefile->GetState()->GetInitializedCacheValue(var)) {
+ if (this->EscapeQuotes) {
return this->AddString(cmSystemTools::EscapeQuotes(c));
- }
- else
- {
+ } else {
return this->AddString(c);
- }
}
- return this->EmptyVariable;
}
+ return this->EmptyVariable;
+ }
std::ostringstream e;
e << "Syntax $" << key << "{} is not supported. "
<< "Only ${}, $ENV{}, and $CACHE{} are allowed.";
@@ -115,62 +101,53 @@ char* cmCommandArgumentParserHelper::ExpandSpecialVariable(const char* key,
char* cmCommandArgumentParserHelper::ExpandVariable(const char* var)
{
- if(!var)
- {
+ if (!var) {
return 0;
- }
- if(this->FileLine >= 0 && strcmp(var, "CMAKE_CURRENT_LIST_LINE") == 0)
- {
+ }
+ if (this->FileLine >= 0 && strcmp(var, "CMAKE_CURRENT_LIST_LINE") == 0) {
std::ostringstream ostr;
ostr << this->FileLine;
return this->AddString(ostr.str());
- }
+ }
const char* value = this->Makefile->GetDefinition(var);
- if(!value && !this->RemoveEmpty)
- {
+ if (!value && !this->RemoveEmpty) {
// check to see if we need to print a warning
// if strict mode is on and the variable has
// not been "cleared"/initialized with a set(foo ) call
- if(this->WarnUninitialized && !this->Makefile->VariableInitialized(var))
- {
+ if (this->WarnUninitialized && !this->Makefile->VariableInitialized(var)) {
if (this->CheckSystemVars ||
cmSystemTools::IsSubDirectory(this->FileName,
this->Makefile->GetHomeDirectory()) ||
- cmSystemTools::IsSubDirectory(this->FileName,
- this->Makefile->GetHomeOutputDirectory()))
- {
+ cmSystemTools::IsSubDirectory(
+ this->FileName, this->Makefile->GetHomeOutputDirectory())) {
std::ostringstream msg;
msg << "uninitialized variable \'" << var << "\'";
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, msg.str());
- }
}
- return 0;
}
- if (this->EscapeQuotes && value)
- {
+ return 0;
+ }
+ if (this->EscapeQuotes && value) {
return this->AddString(cmSystemTools::EscapeQuotes(value));
- }
+ }
return this->AddString(value ? value : "");
}
char* cmCommandArgumentParserHelper::ExpandVariableForAt(const char* var)
{
- if(this->ReplaceAtSyntax)
- {
+ if (this->ReplaceAtSyntax) {
// try to expand the variable
char* ret = this->ExpandVariable(var);
// if the return was 0 and we want to replace empty strings
// then return an empty string
- if(!ret && this->RemoveEmpty)
- {
+ if (!ret && this->RemoveEmpty) {
return this->AddString("");
- }
+ }
// if the ret was not 0, then return it
- if(ret)
- {
+ if (ret) {
return ret;
- }
}
+ }
// at this point we want to put it back because of one of these cases:
// - this->ReplaceAtSyntax is false
// - this->ReplaceAtSyntax is true, but this->RemoveEmpty is false,
@@ -183,79 +160,72 @@ char* cmCommandArgumentParserHelper::ExpandVariableForAt(const char* var)
char* cmCommandArgumentParserHelper::CombineUnions(char* in1, char* in2)
{
- if ( !in1 )
- {
+ if (!in1) {
return in2;
- }
- else if ( !in2 )
- {
+ } else if (!in2) {
return in1;
- }
+ }
size_t len = strlen(in1) + strlen(in2) + 1;
- char* out = new char [ len ];
+ char* out = new char[len];
strcpy(out, in1);
strcat(out, in2);
this->Variables.push_back(out);
return out;
}
-void cmCommandArgumentParserHelper::AllocateParserType
-(cmCommandArgumentParserHelper::ParserType* pt,const char* str, int len)
+void cmCommandArgumentParserHelper::AllocateParserType(
+ cmCommandArgumentParserHelper::ParserType* pt, const char* str, int len)
{
pt->str = 0;
- if ( len == 0 )
- {
+ if (len == 0) {
len = static_cast<int>(strlen(str));
- }
- if ( len == 0 )
- {
+ }
+ if (len == 0) {
return;
- }
- pt->str = new char[ len + 1 ];
+ }
+ pt->str = new char[len + 1];
strncpy(pt->str, str, len);
pt->str[len] = 0;
this->Variables.push_back(pt->str);
}
-bool cmCommandArgumentParserHelper::HandleEscapeSymbol
-(cmCommandArgumentParserHelper::ParserType* pt, char symbol)
+bool cmCommandArgumentParserHelper::HandleEscapeSymbol(
+ cmCommandArgumentParserHelper::ParserType* pt, char symbol)
{
- switch ( symbol )
- {
- case '\\':
- case '"':
- case ' ':
- case '#':
- case '(':
- case ')':
- case '$':
- case '@':
- case '^':
- this->AllocateParserType(pt, &symbol, 1);
- break;
- case ';':
- this->AllocateParserType(pt, "\\;", 2);
- break;
- case 't':
- this->AllocateParserType(pt, "\t", 1);
- break;
- case 'n':
- this->AllocateParserType(pt, "\n", 1);
- break;
- case 'r':
- this->AllocateParserType(pt, "\r", 1);
- break;
- case '0':
- this->AllocateParserType(pt, "\0", 1);
- break;
- default:
- {
- std::ostringstream e;
- e << "Invalid escape sequence \\" << symbol;
- this->SetError(e.str());
- }
- return false;
+ switch (symbol) {
+ case '\\':
+ case '"':
+ case ' ':
+ case '#':
+ case '(':
+ case ')':
+ case '$':
+ case '@':
+ case '^':
+ this->AllocateParserType(pt, &symbol, 1);
+ break;
+ case ';':
+ this->AllocateParserType(pt, "\\;", 2);
+ break;
+ case 't':
+ this->AllocateParserType(pt, "\t", 1);
+ break;
+ case 'n':
+ this->AllocateParserType(pt, "\n", 1);
+ break;
+ case 'r':
+ this->AllocateParserType(pt, "\r", 1);
+ break;
+ case '0':
+ this->AllocateParserType(pt, "\0", 1);
+ break;
+ default: {
+ std::ostringstream e;
+ e << "Invalid escape sequence \\" << symbol;
+ this->SetError(e.str());
}
+ return false;
+ }
return true;
}
@@ -263,10 +233,9 @@ void cmCommandArgument_SetupEscapes(yyscan_t yyscanner, bool noEscapes);
int cmCommandArgumentParserHelper::ParseString(const char* str, int verb)
{
- if ( !str)
- {
+ if (!str) {
return 0;
- }
+ }
this->Verbose = verb;
this->InputBuffer = str;
this->InputBufferPos = 0;
@@ -280,53 +249,43 @@ int cmCommandArgumentParserHelper::ParseString(const char* str, int verb)
cmCommandArgument_SetupEscapes(yyscanner, this->NoEscapeMode);
int res = cmCommandArgument_yyparse(yyscanner);
cmCommandArgument_yylex_destroy(yyscanner);
- if ( res != 0 )
- {
+ if (res != 0) {
return 0;
- }
+ }
this->CleanupParser();
- if ( Verbose )
- {
- std::cerr << "Expanding [" << str << "] produced: ["
- << this->Result << "]" << std::endl;
- }
+ if (Verbose) {
+ std::cerr << "Expanding [" << str << "] produced: [" << this->Result << "]"
+ << std::endl;
+ }
return 1;
}
void cmCommandArgumentParserHelper::CleanupParser()
{
std::vector<char*>::iterator sit;
- for ( sit = this->Variables.begin();
- sit != this->Variables.end();
- ++ sit )
- {
- delete [] *sit;
- }
+ for (sit = this->Variables.begin(); sit != this->Variables.end(); ++sit) {
+ delete[] * sit;
+ }
this->Variables.erase(this->Variables.begin(), this->Variables.end());
}
int cmCommandArgumentParserHelper::LexInput(char* buf, int maxlen)
{
- if ( maxlen < 1 )
- {
+ if (maxlen < 1) {
return 0;
+ }
+ if (this->InputBufferPos < this->InputBuffer.size()) {
+ buf[0] = this->InputBuffer[this->InputBufferPos++];
+ if (buf[0] == '\n') {
+ this->CurrentLine++;
}
- if ( this->InputBufferPos < this->InputBuffer.size() )
- {
- buf[0] = this->InputBuffer[ this->InputBufferPos++ ];
- if ( buf[0] == '\n' )
- {
- this->CurrentLine ++;
- }
- return(1);
- }
- else
- {
+ return (1);
+ } else {
buf[0] = '\n';
- return( 0 );
- }
+ return (0);
+ }
}
void cmCommandArgumentParserHelper::Error(const char* str)
@@ -346,19 +305,17 @@ void cmCommandArgumentParserHelper::SetMakefile(const cmMakefile* mf)
void cmCommandArgumentParserHelper::SetResult(const char* value)
{
- if ( !value )
- {
+ if (!value) {
this->Result = "";
return;
- }
+ }
this->Result = value;
}
void cmCommandArgumentParserHelper::SetError(std::string const& msg)
{
// Keep only the first error.
- if(this->ErrorString.empty())
- {
+ if (this->ErrorString.empty()) {
this->ErrorString = msg;
- }
+ }
}
diff --git a/Source/cmCommandArgumentParserHelper.h b/Source/cmCommandArgumentParserHelper.h
index 387afc6..97b706c 100644
--- a/Source/cmCommandArgumentParserHelper.h
+++ b/Source/cmCommandArgumentParserHelper.h
@@ -17,8 +17,8 @@
#define YYSTYPE cmCommandArgumentParserHelper::ParserType
#define YYSTYPE_IS_DECLARED
#define YY_EXTRA_TYPE cmCommandArgumentParserHelper*
-#define YY_DECL int cmCommandArgument_yylex(YYSTYPE* yylvalp,\
- yyscan_t yyscanner)
+#define YY_DECL \
+ int cmCommandArgument_yylex(YYSTYPE* yylvalp, yyscan_t yyscanner)
/** \class cmCommandArgumentParserHelper
* \brief Helper class for parsing java source files
@@ -31,7 +31,8 @@ class cmMakefile;
class cmCommandArgumentParserHelper
{
public:
- typedef struct {
+ typedef struct
+ {
char* str;
} ParserType;
@@ -42,9 +43,9 @@ public:
// For the lexer:
void AllocateParserType(cmCommandArgumentParserHelper::ParserType* pt,
- const char* str, int len = 0);
+ const char* str, int len = 0);
bool HandleEscapeSymbol(cmCommandArgumentParserHelper::ParserType* pt,
- char symbol);
+ char symbol);
int LexInput(char* buf, int maxlen);
void Error(const char* str);
@@ -106,5 +107,3 @@ private:
};
#endif
-
-
diff --git a/Source/cmCommandArgumentsHelper.cxx b/Source/cmCommandArgumentsHelper.cxx
index 1a2efc6..c336bc5 100644
--- a/Source/cmCommandArgumentsHelper.cxx
+++ b/Source/cmCommandArgumentsHelper.cxx
@@ -15,26 +15,24 @@
cmCommandArgument::cmCommandArgument(cmCommandArgumentsHelper* args,
const char* key,
cmCommandArgumentGroup* group)
-:Key(key)
-,Group(group)
-,WasActive(false)
-,ArgumentsBeforeEmpty(true)
-,CurrentIndex(0)
+ : Key(key)
+ , Group(group)
+ , WasActive(false)
+ , ArgumentsBeforeEmpty(true)
+ , CurrentIndex(0)
{
- if (args!=0)
- {
+ if (args != 0) {
args->AddArgument(this);
- }
+ }
- if (this->Group!=0)
- {
+ if (this->Group != 0) {
this->Group->ContainedArguments.push_back(this);
- }
+ }
}
void cmCommandArgument::Reset()
{
- this->WasActive =false;
+ this->WasActive = false;
this->CurrentIndex = 0;
this->DoReset();
}
@@ -47,55 +45,47 @@ void cmCommandArgument::Follows(const cmCommandArgument* arg)
void cmCommandArgument::FollowsGroup(const cmCommandArgumentGroup* group)
{
- if (group!=0)
- {
+ if (group != 0) {
this->ArgumentsBeforeEmpty = false;
this->ArgumentsBefore.insert(group->ContainedArguments.begin(),
group->ContainedArguments.end());
- }
+ }
}
bool cmCommandArgument::MayFollow(const cmCommandArgument* current) const
{
- if (this->ArgumentsBeforeEmpty)
- {
+ if (this->ArgumentsBeforeEmpty) {
return true;
- }
+ }
- std::set<const cmCommandArgument*>::const_iterator argIt
- = this->ArgumentsBefore.find(current);
- if (argIt != this->ArgumentsBefore.end())
- {
+ std::set<const cmCommandArgument*>::const_iterator argIt =
+ this->ArgumentsBefore.find(current);
+ if (argIt != this->ArgumentsBefore.end()) {
return true;
- }
+ }
return false;
}
bool cmCommandArgument::KeyMatches(const std::string& key) const
{
- if ((this->Key==0) || (this->Key[0]=='\0'))
- {
+ if ((this->Key == 0) || (this->Key[0] == '\0')) {
return true;
- }
- return (key==this->Key);
+ }
+ return (key == this->Key);
}
void cmCommandArgument::ApplyOwnGroup()
{
- if (this->Group!=0)
- {
- for (std::vector<cmCommandArgument*>::const_iterator
- it = this->Group->ContainedArguments.begin();
- it != this->Group->ContainedArguments.end();
- ++it)
- {
- if(*it != this)
- {
+ if (this->Group != 0) {
+ for (std::vector<cmCommandArgument*>::const_iterator it =
+ this->Group->ContainedArguments.begin();
+ it != this->Group->ContainedArguments.end(); ++it) {
+ if (*it != this) {
this->ArgumentsBefore.insert(*it);
- }
}
}
+ }
}
void cmCommandArgument::Activate()
@@ -106,37 +96,31 @@ void cmCommandArgument::Activate()
bool cmCommandArgument::Consume(const std::string& arg)
{
- bool res=this->DoConsume(arg, this->CurrentIndex);
+ bool res = this->DoConsume(arg, this->CurrentIndex);
this->CurrentIndex++;
return res;
}
-
cmCAStringVector::cmCAStringVector(cmCommandArgumentsHelper* args,
const char* key,
cmCommandArgumentGroup* group)
-:cmCommandArgument(args, key, group)
-,Ignore(0)
+ : cmCommandArgument(args, key, group)
+ , Ignore(0)
{
- if ((key==0) || (*key==0))
- {
+ if ((key == 0) || (*key == 0)) {
this->DataStart = 0;
- }
- else
- {
+ } else {
this->DataStart = 1;
- }
+ }
}
-bool cmCAStringVector::DoConsume(const std::string& arg,unsigned int index)
+bool cmCAStringVector::DoConsume(const std::string& arg, unsigned int index)
{
- if (index >= this->DataStart)
- {
- if ((this->Ignore==0) || (arg != this->Ignore))
- {
+ if (index >= this->DataStart) {
+ if ((this->Ignore == 0) || (arg != this->Ignore)) {
this->Vector.push_back(arg);
- }
}
+ }
return false;
}
@@ -146,27 +130,22 @@ void cmCAStringVector::DoReset()
this->Vector.clear();
}
-cmCAString::cmCAString(cmCommandArgumentsHelper* args,
- const char* key,
+cmCAString::cmCAString(cmCommandArgumentsHelper* args, const char* key,
cmCommandArgumentGroup* group)
-:cmCommandArgument(args, key, group)
+ : cmCommandArgument(args, key, group)
{
- if ((key==0) || (*key==0))
- {
+ if ((key == 0) || (*key == 0)) {
this->DataStart = 0;
- }
- else
- {
+ } else {
this->DataStart = 1;
- }
+ }
}
bool cmCAString::DoConsume(const std::string& arg, unsigned int index)
{
- if (index == this->DataStart)
- {
+ if (index == this->DataStart) {
this->String = arg;
- }
+ }
return index >= this->DataStart;
}
@@ -176,19 +155,18 @@ void cmCAString::DoReset()
this->String = "";
}
-cmCAEnabler::cmCAEnabler(cmCommandArgumentsHelper* args,
- const char* key,
+cmCAEnabler::cmCAEnabler(cmCommandArgumentsHelper* args, const char* key,
cmCommandArgumentGroup* group)
-:cmCommandArgument(args, key, group)
-,Enabled(false)
-{}
+ : cmCommandArgument(args, key, group)
+ , Enabled(false)
+{
+}
bool cmCAEnabler::DoConsume(const std::string&, unsigned int index)
{
- if (index==0)
- {
+ if (index == 0) {
this->Enabled = true;
- }
+ }
return true;
}
@@ -197,19 +175,18 @@ void cmCAEnabler::DoReset()
this->Enabled = false;
}
-cmCADisabler::cmCADisabler(cmCommandArgumentsHelper* args,
- const char* key,
+cmCADisabler::cmCADisabler(cmCommandArgumentsHelper* args, const char* key,
cmCommandArgumentGroup* group)
-:cmCommandArgument(args, key, group)
-,Enabled(true)
-{}
+ : cmCommandArgument(args, key, group)
+ , Enabled(true)
+{
+}
bool cmCADisabler::DoConsume(const std::string&, unsigned int index)
{
- if (index==0)
- {
+ if (index == 0) {
this->Enabled = false;
- }
+ }
return true;
}
@@ -220,83 +197,66 @@ void cmCADisabler::DoReset()
void cmCommandArgumentGroup::Follows(const cmCommandArgument* arg)
{
- for(std::vector<cmCommandArgument*>::iterator
- it = this->ContainedArguments.begin();
- it != this->ContainedArguments.end();
- ++it)
- {
+ for (std::vector<cmCommandArgument*>::iterator it =
+ this->ContainedArguments.begin();
+ it != this->ContainedArguments.end(); ++it) {
(*it)->Follows(arg);
- }
+ }
}
void cmCommandArgumentGroup::FollowsGroup(const cmCommandArgumentGroup* group)
{
- for(std::vector<cmCommandArgument*>::iterator
- it = this->ContainedArguments.begin();
- it != this->ContainedArguments.end();
- ++it)
- {
+ for (std::vector<cmCommandArgument*>::iterator it =
+ this->ContainedArguments.begin();
+ it != this->ContainedArguments.end(); ++it) {
(*it)->FollowsGroup(group);
- }
+ }
}
void cmCommandArgumentsHelper::Parse(const std::vector<std::string>* args,
std::vector<std::string>* unconsumedArgs)
{
- if(args==0)
- {
+ if (args == 0) {
return;
- }
+ }
- for(std::vector<cmCommandArgument*>::iterator
- argIt = this->Arguments.begin();
- argIt != this->Arguments.end();
- ++argIt)
- {
+ for (std::vector<cmCommandArgument*>::iterator argIt =
+ this->Arguments.begin();
+ argIt != this->Arguments.end(); ++argIt) {
(*argIt)->ApplyOwnGroup();
(*argIt)->Reset();
- }
+ }
cmCommandArgument* activeArgument = 0;
const cmCommandArgument* previousArgument = 0;
- for(std::vector<std::string>::const_iterator it = args->begin();
- it != args->end();
- ++it)
- {
- for(std::vector<cmCommandArgument*>::iterator
- argIt = this->Arguments.begin();
- argIt != this->Arguments.end();
- ++argIt)
- {
- if ((*argIt)->KeyMatches(*it) && ((*argIt)->MayFollow(previousArgument)))
- {
+ for (std::vector<std::string>::const_iterator it = args->begin();
+ it != args->end(); ++it) {
+ for (std::vector<cmCommandArgument*>::iterator argIt =
+ this->Arguments.begin();
+ argIt != this->Arguments.end(); ++argIt) {
+ if ((*argIt)->KeyMatches(*it) &&
+ ((*argIt)->MayFollow(previousArgument))) {
activeArgument = *argIt;
activeArgument->Activate();
break;
- }
}
+ }
- if (activeArgument)
- {
+ if (activeArgument) {
bool argDone = activeArgument->Consume(*it);
previousArgument = activeArgument;
- if (argDone)
- {
+ if (argDone) {
activeArgument = 0;
- }
}
- else
- {
- if (unconsumedArgs!=0)
- {
+ } else {
+ if (unconsumedArgs != 0) {
unconsumedArgs->push_back(*it);
- }
}
}
+ }
}
void cmCommandArgumentsHelper::AddArgument(cmCommandArgument* arg)
{
this->Arguments.push_back(arg);
}
-
diff --git a/Source/cmCommandArgumentsHelper.h b/Source/cmCommandArgumentsHelper.h
index f732f8f..c2a6f92 100644
--- a/Source/cmCommandArgumentsHelper.h
+++ b/Source/cmCommandArgumentsHelper.h
@@ -41,164 +41,161 @@ For an example see cmExportCommand.cxx.
*/
class cmCommandArgument
{
- public:
- cmCommandArgument(cmCommandArgumentsHelper* args,
- const char* key,
- cmCommandArgumentGroup* group=0);
- virtual ~cmCommandArgument() {}
-
- /// this argument may follow after arg. 0 means it comes first.
- void Follows(const cmCommandArgument* arg);
-
- /// this argument may follow after any of the arguments in the given group
- void FollowsGroup(const cmCommandArgumentGroup* group);
-
- /// Returns true if the argument was found in the argument list
- bool WasFound() const {return this->WasActive;}
-
- // The following methods are only called from
- // cmCommandArgumentsHelper::Parse(), but making this a friend would
- // give it access to everything
-
- /// Make the current argument the currently active argument
- void Activate();
- /// Consume the current string
- bool Consume(const std::string& arg);
-
- /// Return true if this argument may follow after the given argument.
- bool MayFollow(const cmCommandArgument* current) const;
-
- /** Returns true if the given key matches the key for this argument.
- If this argument has an empty key everything matches. */
- bool KeyMatches(const std::string& key) const;
-
- /// Make this argument follow all members of the own group
- void ApplyOwnGroup();
-
- /// Reset argument, so it's back to its initial state
- void Reset();
- private:
- const char* Key;
- std::set<const cmCommandArgument*> ArgumentsBefore;
- cmCommandArgumentGroup* Group;
- bool WasActive;
- bool ArgumentsBeforeEmpty;
- unsigned int CurrentIndex;
-
- virtual bool DoConsume(const std::string& arg, unsigned int index) = 0;
- virtual void DoReset() = 0;
+public:
+ cmCommandArgument(cmCommandArgumentsHelper* args, const char* key,
+ cmCommandArgumentGroup* group = 0);
+ virtual ~cmCommandArgument() {}
+
+ /// this argument may follow after arg. 0 means it comes first.
+ void Follows(const cmCommandArgument* arg);
+
+ /// this argument may follow after any of the arguments in the given group
+ void FollowsGroup(const cmCommandArgumentGroup* group);
+
+ /// Returns true if the argument was found in the argument list
+ bool WasFound() const { return this->WasActive; }
+
+ // The following methods are only called from
+ // cmCommandArgumentsHelper::Parse(), but making this a friend would
+ // give it access to everything
+
+ /// Make the current argument the currently active argument
+ void Activate();
+ /// Consume the current string
+ bool Consume(const std::string& arg);
+
+ /// Return true if this argument may follow after the given argument.
+ bool MayFollow(const cmCommandArgument* current) const;
+
+ /** Returns true if the given key matches the key for this argument.
+ If this argument has an empty key everything matches. */
+ bool KeyMatches(const std::string& key) const;
+
+ /// Make this argument follow all members of the own group
+ void ApplyOwnGroup();
+
+ /// Reset argument, so it's back to its initial state
+ void Reset();
+
+private:
+ const char* Key;
+ std::set<const cmCommandArgument*> ArgumentsBefore;
+ cmCommandArgumentGroup* Group;
+ bool WasActive;
+ bool ArgumentsBeforeEmpty;
+ unsigned int CurrentIndex;
+
+ virtual bool DoConsume(const std::string& arg, unsigned int index) = 0;
+ virtual void DoReset() = 0;
};
/** cmCAStringVector is to be used for arguments which can consist of more
than one string, e.g. the FILES argument in INSTALL(FILES f1 f2 f3 ...). */
class cmCAStringVector : public cmCommandArgument
{
- public:
- cmCAStringVector(cmCommandArgumentsHelper* args,
- const char* key,
- cmCommandArgumentGroup* group=0);
-
- /// Return the vector of strings
- const std::vector<std::string>& GetVector() const {return this->Vector;}
-
- /** Is there a keyword which should be skipped in
- the arguments (e.g. ARGS for ADD_CUSTOM_COMMAND) ? */
- void SetIgnore(const char* ignore) {this->Ignore=ignore;}
- private:
- std::vector<std::string> Vector;
- unsigned int DataStart;
- const char* Ignore;
- cmCAStringVector();
- virtual bool DoConsume(const std::string& arg, unsigned int index);
- virtual void DoReset();
+public:
+ cmCAStringVector(cmCommandArgumentsHelper* args, const char* key,
+ cmCommandArgumentGroup* group = 0);
+
+ /// Return the vector of strings
+ const std::vector<std::string>& GetVector() const { return this->Vector; }
+
+ /** Is there a keyword which should be skipped in
+ the arguments (e.g. ARGS for ADD_CUSTOM_COMMAND) ? */
+ void SetIgnore(const char* ignore) { this->Ignore = ignore; }
+private:
+ std::vector<std::string> Vector;
+ unsigned int DataStart;
+ const char* Ignore;
+ cmCAStringVector();
+ virtual bool DoConsume(const std::string& arg, unsigned int index);
+ virtual void DoReset();
};
/** cmCAString is to be used for arguments which consist of one value,
e.g. the executable name in ADD_EXECUTABLE(). */
class cmCAString : public cmCommandArgument
{
- public:
- cmCAString(cmCommandArgumentsHelper* args,
- const char* key,
- cmCommandArgumentGroup* group=0);
-
- /// Return the string
- const std::string& GetString() const {return this->String;}
- const char* GetCString() const {return this->String.c_str();}
- private:
- std::string String;
- unsigned int DataStart;
- virtual bool DoConsume(const std::string& arg, unsigned int index);
- virtual void DoReset();
- cmCAString();
+public:
+ cmCAString(cmCommandArgumentsHelper* args, const char* key,
+ cmCommandArgumentGroup* group = 0);
+
+ /// Return the string
+ const std::string& GetString() const { return this->String; }
+ const char* GetCString() const { return this->String.c_str(); }
+private:
+ std::string String;
+ unsigned int DataStart;
+ virtual bool DoConsume(const std::string& arg, unsigned int index);
+ virtual void DoReset();
+ cmCAString();
};
/** cmCAEnabler is to be used for options which are off by default and can be
enabled using a special argument, e.g. EXCLUDE_FROM_ALL in ADD_EXECUTABLE(). */
class cmCAEnabler : public cmCommandArgument
{
- public:
- cmCAEnabler(cmCommandArgumentsHelper* args,
- const char* key,
- cmCommandArgumentGroup* group=0);
-
- /// Has it been enabled ?
- bool IsEnabled() const {return this->Enabled;}
- private:
- bool Enabled;
- virtual bool DoConsume(const std::string& arg, unsigned int index);
- virtual void DoReset();
- cmCAEnabler();
+public:
+ cmCAEnabler(cmCommandArgumentsHelper* args, const char* key,
+ cmCommandArgumentGroup* group = 0);
+
+ /// Has it been enabled ?
+ bool IsEnabled() const { return this->Enabled; }
+private:
+ bool Enabled;
+ virtual bool DoConsume(const std::string& arg, unsigned int index);
+ virtual void DoReset();
+ cmCAEnabler();
};
/** cmCADisable is to be used for options which are on by default and can be
disabled using a special argument.*/
class cmCADisabler : public cmCommandArgument
{
- public:
- cmCADisabler(cmCommandArgumentsHelper* args,
- const char* key,
- cmCommandArgumentGroup* group=0);
-
- /// Is it still enabled ?
- bool IsEnabled() const {return this->Enabled;}
- private:
- bool Enabled;
- virtual bool DoConsume(const std::string& arg, unsigned int index);
- virtual void DoReset();
- cmCADisabler();
+public:
+ cmCADisabler(cmCommandArgumentsHelper* args, const char* key,
+ cmCommandArgumentGroup* group = 0);
+
+ /// Is it still enabled ?
+ bool IsEnabled() const { return this->Enabled; }
+private:
+ bool Enabled;
+ virtual bool DoConsume(const std::string& arg, unsigned int index);
+ virtual void DoReset();
+ cmCADisabler();
};
-
/** Group of arguments, needed for ordering. E.g. WIN32, EXCLUDE_FROM_ALL and
MACSOX_BUNDLE from ADD_EXECUTABLE() are a group.
*/
class cmCommandArgumentGroup
{
friend class cmCommandArgument;
- public:
- cmCommandArgumentGroup() {}
- /// All members of this group may follow the given argument
- void Follows(const cmCommandArgument* arg);
+public:
+ cmCommandArgumentGroup() {}
- /// All members of this group may follow all members of the given group
- void FollowsGroup(const cmCommandArgumentGroup* group);
- private:
- std::vector<cmCommandArgument*> ContainedArguments;
+ /// All members of this group may follow the given argument
+ void Follows(const cmCommandArgument* arg);
+
+ /// All members of this group may follow all members of the given group
+ void FollowsGroup(const cmCommandArgumentGroup* group);
+
+private:
+ std::vector<cmCommandArgument*> ContainedArguments;
};
class cmCommandArgumentsHelper
{
- public:
- /// Parse the argument list
- void Parse(const std::vector<std::string>* args,
- std::vector<std::string>* unconsumedArgs);
- /// Add an argument.
- void AddArgument(cmCommandArgument* arg);
- private:
- std::vector<cmCommandArgument*> Arguments;
+public:
+ /// Parse the argument list
+ void Parse(const std::vector<std::string>* args,
+ std::vector<std::string>* unconsumedArgs);
+ /// Add an argument.
+ void AddArgument(cmCommandArgument* arg);
+
+private:
+ std::vector<cmCommandArgument*> Arguments;
};
-
#endif
diff --git a/Source/cmCommands.h b/Source/cmCommands.h
index 0786a64..d0f1ab7 100644
--- a/Source/cmCommands.h
+++ b/Source/cmCommands.h
@@ -28,5 +28,4 @@ void GetBootstrapCommands1(std::vector<cmCommand*>& commands);
void GetBootstrapCommands2(std::vector<cmCommand*>& commands);
void GetPredefinedCommands(std::vector<cmCommand*>& commands);
-
#endif
diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx
index d00a416..6b2d1e3 100644
--- a/Source/cmCommonTargetGenerator.cxx
+++ b/Source/cmCommonTargetGenerator.cxx
@@ -20,15 +20,13 @@
#include "cmSystemTools.h"
cmCommonTargetGenerator::cmCommonTargetGenerator(
- cmOutputConverter::RelativeRoot wd,
- cmGeneratorTarget* gt
- )
+ cmOutputConverter::RelativeRoot wd, cmGeneratorTarget* gt)
: WorkingDirectory(wd)
, GeneratorTarget(gt)
, Makefile(gt->Makefile)
, LocalGenerator(static_cast<cmLocalCommonGenerator*>(gt->LocalGenerator))
, GlobalGenerator(static_cast<cmGlobalCommonGenerator*>(
- gt->LocalGenerator->GetGlobalGenerator()))
+ gt->LocalGenerator->GetGlobalGenerator()))
, ConfigName(LocalGenerator->GetConfigName())
, ModuleDefinitionFile(GeneratorTarget->GetModuleDefinitionFile(ConfigName))
, FortranModuleDirectoryComputed(false)
@@ -45,8 +43,7 @@ std::string const& cmCommonTargetGenerator::GetConfigName() const
}
std::string cmCommonTargetGenerator::Convert(
- std::string const& source,
- cmLocalGenerator::RelativeRoot relative,
+ std::string const& source, cmLocalGenerator::RelativeRoot relative,
cmLocalGenerator::OutputFormat output)
{
return this->LocalGenerator->Convert(source, relative, output);
@@ -62,39 +59,35 @@ bool cmCommonTargetGenerator::GetFeatureAsBool(const std::string& feature)
return this->GeneratorTarget->GetFeatureAsBool(feature, this->ConfigName);
}
-void cmCommonTargetGenerator::AddFeatureFlags(
- std::string& flags, const std::string& lang
- )
+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->GetFeatureAsBool("INTERPROCEDURAL_OPTIMIZATION")) {
this->LocalGenerator->AppendFeatureOptions(flags, lang, "IPO");
- }
+ }
}
void cmCommonTargetGenerator::AddModuleDefinitionFlag(std::string& flags)
{
- if(!this->ModuleDefinitionFile)
- {
+ if (!this->ModuleDefinitionFile) {
return;
- }
+ }
// TODO: Create a per-language flag variable.
const char* defFileFlag =
this->Makefile->GetDefinition("CMAKE_LINK_DEF_FILE_FLAG");
- if(!defFileFlag)
- {
+ if (!defFileFlag) {
return;
- }
+ }
// Append the flag and value. Use ConvertToLinkReference to help
// vs6's "cl -link" pass it to the linker.
std::string flag = defFileFlag;
flag += (this->LocalGenerator->ConvertToLinkReference(
- this->ModuleDefinitionFile->GetFullPath()));
+ this->ModuleDefinitionFile->GetFullPath()));
this->LocalGenerator->AppendFlags(flags, flag);
}
@@ -105,36 +98,31 @@ std::string cmCommonTargetGenerator::ComputeFortranModuleDirectory() const
this->GeneratorTarget->GetProperty("Fortran_MODULE_DIRECTORY");
const char* moddir_flag =
this->Makefile->GetDefinition("CMAKE_Fortran_MODDIR_FLAG");
- if(target_mod_dir && moddir_flag)
- {
+ if (target_mod_dir && moddir_flag) {
// Compute the full path to the module directory.
- if(cmSystemTools::FileIsFullPath(target_mod_dir))
- {
+ if (cmSystemTools::FileIsFullPath(target_mod_dir)) {
// Already a full path.
mod_dir = target_mod_dir;
- }
- else
- {
+ } else {
// Interpret relative to the current output directory.
mod_dir = this->LocalGenerator->GetCurrentBinaryDirectory();
mod_dir += "/";
mod_dir += target_mod_dir;
- }
+ }
// Make sure the module output directory exists.
cmSystemTools::MakeDirectory(mod_dir);
- }
+ }
return mod_dir;
}
std::string cmCommonTargetGenerator::GetFortranModuleDirectory()
{
// Compute the module directory.
- if(!this->FortranModuleDirectoryComputed)
- {
+ if (!this->FortranModuleDirectoryComputed) {
this->FortranModuleDirectoryComputed = true;
this->FortranModuleDirectory = this->ComputeFortranModuleDirectory();
- }
+ }
// Return the computed directory.
return this->FortranModuleDirectory;
@@ -143,154 +131,133 @@ std::string cmCommonTargetGenerator::GetFortranModuleDirectory()
void cmCommonTargetGenerator::AddFortranFlags(std::string& flags)
{
// Enable module output if necessary.
- if(const char* modout_flag =
- this->Makefile->GetDefinition("CMAKE_Fortran_MODOUT_FLAG"))
- {
+ if (const char* modout_flag =
+ this->Makefile->GetDefinition("CMAKE_Fortran_MODOUT_FLAG")) {
this->LocalGenerator->AppendFlags(flags, modout_flag);
- }
+ }
// Add a module output directory flag if necessary.
std::string mod_dir = this->GetFortranModuleDirectory();
- if (!mod_dir.empty())
- {
- mod_dir = this->Convert(mod_dir,
- this->WorkingDirectory,
- cmLocalGenerator::SHELL);
- }
- else
- {
+ if (!mod_dir.empty()) {
+ mod_dir =
+ this->Convert(mod_dir, this->WorkingDirectory, cmLocalGenerator::SHELL);
+ } else {
mod_dir =
this->Makefile->GetSafeDefinition("CMAKE_Fortran_MODDIR_DEFAULT");
- }
- if (!mod_dir.empty())
- {
+ }
+ if (!mod_dir.empty()) {
const char* moddir_flag =
this->Makefile->GetRequiredDefinition("CMAKE_Fortran_MODDIR_FLAG");
std::string modflag = moddir_flag;
modflag += mod_dir;
this->LocalGenerator->AppendFlags(flags, modflag);
- }
+ }
// If there is a separate module path flag then duplicate the
// include path with it. This compiler does not search the include
// path for modules.
- if(const char* modpath_flag =
- this->Makefile->GetDefinition("CMAKE_Fortran_MODPATH_FLAG"))
- {
+ if (const char* modpath_flag =
+ this->Makefile->GetDefinition("CMAKE_Fortran_MODPATH_FLAG")) {
std::vector<std::string> includes;
const std::string& config =
this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
- this->LocalGenerator->GetIncludeDirectories(includes,
- this->GeneratorTarget,
- "C", config);
- for(std::vector<std::string>::const_iterator idi = includes.begin();
- idi != includes.end(); ++idi)
- {
+ this->LocalGenerator->GetIncludeDirectories(
+ includes, this->GeneratorTarget, "C", config);
+ for (std::vector<std::string>::const_iterator idi = includes.begin();
+ idi != includes.end(); ++idi) {
std::string flg = modpath_flag;
- flg += this->Convert(*idi,
- cmLocalGenerator::NONE,
- cmLocalGenerator::SHELL);
+ flg +=
+ this->Convert(*idi, cmLocalGenerator::NONE, cmLocalGenerator::SHELL);
this->LocalGenerator->AppendFlags(flags, flg);
- }
}
+ }
}
-void
-cmCommonTargetGenerator
-::AppendFortranFormatFlags(std::string& flags, cmSourceFile const& source)
+void cmCommonTargetGenerator::AppendFortranFormatFlags(
+ std::string& flags, cmSourceFile const& source)
{
const char* srcfmt = source.GetProperty("Fortran_FORMAT");
cmLocalGenerator::FortranFormat format =
this->LocalGenerator->GetFortranFormat(srcfmt);
- if(format == cmLocalGenerator::FortranFormatNone)
- {
+ if (format == cmLocalGenerator::FortranFormatNone) {
const char* tgtfmt = this->GeneratorTarget->GetProperty("Fortran_FORMAT");
format = this->LocalGenerator->GetFortranFormat(tgtfmt);
- }
+ }
const char* var = 0;
- switch (format)
- {
+ switch (format) {
case cmLocalGenerator::FortranFormatFixed:
- var = "CMAKE_Fortran_FORMAT_FIXED_FLAG"; break;
+ var = "CMAKE_Fortran_FORMAT_FIXED_FLAG";
+ break;
case cmLocalGenerator::FortranFormatFree:
- var = "CMAKE_Fortran_FORMAT_FREE_FLAG"; break;
- default: break;
- }
- if(var)
- {
- this->LocalGenerator->AppendFlags(
- flags, this->Makefile->GetDefinition(var));
- }
+ var = "CMAKE_Fortran_FORMAT_FREE_FLAG";
+ break;
+ default:
+ break;
+ }
+ if (var) {
+ this->LocalGenerator->AppendFlags(flags,
+ this->Makefile->GetDefinition(var));
+ }
}
std::string cmCommonTargetGenerator::GetFrameworkFlags(std::string const& l)
{
- if(!this->Makefile->IsOn("APPLE"))
- {
- return std::string();
- }
+ if (!this->Makefile->IsOn("APPLE")) {
+ return std::string();
+ }
std::string fwSearchFlagVar = "CMAKE_" + l + "_FRAMEWORK_SEARCH_FLAG";
- const char* fwSearchFlag =
- this->Makefile->GetDefinition(fwSearchFlagVar);
- if(!(fwSearchFlag && *fwSearchFlag))
- {
+ const char* fwSearchFlag = this->Makefile->GetDefinition(fwSearchFlagVar);
+ if (!(fwSearchFlag && *fwSearchFlag)) {
return std::string();
- }
+ }
- std::set<std::string> emitted;
-#ifdef __APPLE__ /* don't insert this when crosscompiling e.g. to iphone */
+ std::set<std::string> emitted;
+#ifdef __APPLE__ /* don't insert this when crosscompiling e.g. to iphone */
emitted.insert("/System/Library/Frameworks");
#endif
std::vector<std::string> includes;
const std::string& config =
this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
- this->LocalGenerator->GetIncludeDirectories(includes,
- this->GeneratorTarget,
+ this->LocalGenerator->GetIncludeDirectories(includes, this->GeneratorTarget,
"C", config);
// check all include directories for frameworks as this
// will already have added a -F for the framework
- for(std::vector<std::string>::iterator i = includes.begin();
- i != includes.end(); ++i)
- {
- if(this->GlobalGenerator->NameResolvesToFramework(*i))
- {
+ for (std::vector<std::string>::iterator i = includes.begin();
+ i != includes.end(); ++i) {
+ if (this->GlobalGenerator->NameResolvesToFramework(*i)) {
std::string frameworkDir = *i;
frameworkDir += "/../";
frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir);
emitted.insert(frameworkDir);
- }
}
+ }
std::string flags;
const char* cfg = this->LocalGenerator->GetConfigName().c_str();
- if(cmComputeLinkInformation* cli =
- this->GeneratorTarget->GetLinkInformation(cfg))
- {
+ if (cmComputeLinkInformation* cli =
+ this->GeneratorTarget->GetLinkInformation(cfg)) {
std::vector<std::string> const& frameworks = cli->GetFrameworkPaths();
- for(std::vector<std::string>::const_iterator i = frameworks.begin();
- i != frameworks.end(); ++i)
- {
- if(emitted.insert(*i).second)
- {
+ for (std::vector<std::string>::const_iterator i = frameworks.begin();
+ i != frameworks.end(); ++i) {
+ if (emitted.insert(*i).second) {
flags += fwSearchFlag;
- flags += this->LocalGenerator
- ->ConvertToOutputFormat(*i, cmLocalGenerator::SHELL);
+ flags += this->LocalGenerator->ConvertToOutputFormat(
+ *i, cmLocalGenerator::SHELL);
flags += " ";
- }
}
}
+ }
return flags;
}
-std::string cmCommonTargetGenerator::GetFlags(const std::string &l)
+std::string cmCommonTargetGenerator::GetFlags(const std::string& l)
{
ByLanguageMap::iterator i = this->FlagsByLanguage.find(l);
- if (i == this->FlagsByLanguage.end())
- {
+ if (i == this->FlagsByLanguage.end()) {
std::string flags;
- const char *lang = l.c_str();
+ const char* lang = l.c_str();
// Add language feature flags.
this->AddFeatureFlags(flags, lang);
@@ -299,104 +266,95 @@ std::string cmCommonTargetGenerator::GetFlags(const std::string &l)
lang, this->ConfigName);
// Fortran-specific flags computed for this target.
- if(l == "Fortran")
- {
+ if (l == "Fortran") {
this->AddFortranFlags(flags);
- }
+ }
- this->LocalGenerator->AddCMP0018Flags(flags, this->GeneratorTarget,
- lang, this->ConfigName);
+ this->LocalGenerator->AddCMP0018Flags(flags, this->GeneratorTarget, lang,
+ this->ConfigName);
- this->LocalGenerator->AddVisibilityPresetFlags(flags,
- this->GeneratorTarget,
- lang);
+ this->LocalGenerator->AddVisibilityPresetFlags(
+ flags, this->GeneratorTarget, lang);
// Append old-style preprocessor definition flags.
- this->LocalGenerator->
- AppendFlags(flags, this->Makefile->GetDefineFlags());
+ this->LocalGenerator->AppendFlags(flags, this->Makefile->GetDefineFlags());
// Add framework directory flags.
- this->LocalGenerator->
- AppendFlags(flags,this->GetFrameworkFlags(l));
+ this->LocalGenerator->AppendFlags(flags, this->GetFrameworkFlags(l));
// Add target-specific flags.
- this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget,
- lang, this->ConfigName);
+ this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget, lang,
+ this->ConfigName);
ByLanguageMap::value_type entry(l, flags);
i = this->FlagsByLanguage.insert(entry).first;
- }
+ }
return i->second;
}
-std::string cmCommonTargetGenerator::GetDefines(const std::string &l)
+std::string cmCommonTargetGenerator::GetDefines(const std::string& l)
{
ByLanguageMap::iterator i = this->DefinesByLanguage.find(l);
- if (i == this->DefinesByLanguage.end())
- {
+ if (i == this->DefinesByLanguage.end()) {
std::set<std::string> defines;
- const char *lang = l.c_str();
+ const char* lang = l.c_str();
// Add the export symbol definition for shared library objects.
- if(const char* exportMacro =
- this->GeneratorTarget->GetExportMacro())
- {
+ if (const char* exportMacro = this->GeneratorTarget->GetExportMacro()) {
this->LocalGenerator->AppendDefines(defines, exportMacro);
- }
+ }
// Add preprocessor definitions for this target and configuration.
- this->LocalGenerator->AddCompileDefinitions(defines, this->GeneratorTarget,
- this->LocalGenerator->GetConfigName(), l);
+ this->LocalGenerator->AddCompileDefinitions(
+ defines, this->GeneratorTarget, this->LocalGenerator->GetConfigName(),
+ l);
std::string definesString;
this->LocalGenerator->JoinDefines(defines, definesString, lang);
ByLanguageMap::value_type entry(l, definesString);
i = this->DefinesByLanguage.insert(entry).first;
- }
+ }
return i->second;
}
std::string cmCommonTargetGenerator::GetIncludes(std::string const& l)
{
ByLanguageMap::iterator i = this->IncludesByLanguage.find(l);
- if (i == this->IncludesByLanguage.end())
- {
+ if (i == this->IncludesByLanguage.end()) {
std::string includes;
this->AddIncludeFlags(includes, l);
ByLanguageMap::value_type entry(l, includes);
i = this->IncludesByLanguage.insert(entry).first;
- }
+ }
return i->second;
}
-std::vector<std::string>
-cmCommonTargetGenerator::GetLinkedTargetDirectories() const
+std::vector<std::string> cmCommonTargetGenerator::GetLinkedTargetDirectories()
+ const
{
std::vector<std::string> dirs;
std::set<cmGeneratorTarget const*> emitted;
if (cmComputeLinkInformation* cli =
- this->GeneratorTarget->GetLinkInformation(this->ConfigName))
- {
+ this->GeneratorTarget->GetLinkInformation(this->ConfigName)) {
cmComputeLinkInformation::ItemVector const& items = cli->GetItems();
- for(cmComputeLinkInformation::ItemVector::const_iterator
- i = items.begin(); i != items.end(); ++i)
- {
+ for (cmComputeLinkInformation::ItemVector::const_iterator i =
+ items.begin();
+ i != items.end(); ++i) {
cmGeneratorTarget const* linkee = i->Target;
- if(linkee && !linkee->IsImported()
- // We can ignore the INTERFACE_LIBRARY items because
- // Target->GetLinkInformation already processed their
- // link interface and they don't have any output themselves.
- && linkee->GetType() != cmState::INTERFACE_LIBRARY
- && emitted.insert(linkee).second)
- {
+ if (linkee && !linkee->IsImported()
+ // We can ignore the INTERFACE_LIBRARY items because
+ // Target->GetLinkInformation already processed their
+ // link interface and they don't have any output themselves.
+ && linkee->GetType() != cmState::INTERFACE_LIBRARY &&
+ emitted.insert(linkee).second) {
cmLocalGenerator* lg = linkee->GetLocalGenerator();
std::string di = lg->GetCurrentBinaryDirectory();
di += "/";
di += lg->GetTargetDirectory(linkee);
dirs.push_back(di);
- }
}
}
+ }
return dirs;
}
@@ -407,19 +365,17 @@ std::string cmCommonTargetGenerator::GetManifests()
std::vector<std::string> manifests;
for (std::vector<cmSourceFile const*>::iterator mi = manifest_srcs.begin();
- mi != manifest_srcs.end(); ++mi)
- {
- manifests.push_back(this->Convert((*mi)->GetFullPath(),
- this->WorkingDirectory,
- cmOutputConverter::SHELL));
- }
+ mi != manifest_srcs.end(); ++mi) {
+ manifests.push_back(this->Convert(
+ (*mi)->GetFullPath(), this->WorkingDirectory, cmOutputConverter::SHELL));
+ }
return cmJoin(manifests, " ");
}
-void cmCommonTargetGenerator
-::AppendOSXVerFlag(std::string& flags, const std::string& lang,
- const char* name, bool so)
+void cmCommonTargetGenerator::AppendOSXVerFlag(std::string& flags,
+ const std::string& lang,
+ const char* name, bool so)
{
// Lookup the flag to specify the version.
std::string fvar = "CMAKE_";
@@ -430,21 +386,19 @@ void cmCommonTargetGenerator
const char* flag = this->Makefile->GetDefinition(fvar);
// Skip if no such flag.
- if(!flag)
- {
+ if (!flag) {
return;
- }
+ }
// Lookup the target version information.
int major;
int minor;
int patch;
this->GeneratorTarget->GetTargetVersion(so, major, minor, patch);
- if(major > 0 || minor > 0 || patch > 0)
- {
+ if (major > 0 || minor > 0 || patch > 0) {
// Append the flag since a non-zero version is specified.
std::ostringstream vflag;
vflag << flag << major << "." << minor << "." << patch;
this->LocalGenerator->AppendFlags(flags, vflag.str());
- }
+ }
}
diff --git a/Source/cmCommonTargetGenerator.h b/Source/cmCommonTargetGenerator.h
index bfb6b79..c5d324f 100644
--- a/Source/cmCommonTargetGenerator.h
+++ b/Source/cmCommonTargetGenerator.h
@@ -35,7 +35,6 @@ public:
std::string const& GetConfigName() const;
protected:
-
// Add language feature flags.
void AddFeatureFlags(std::string& flags, const std::string& lang);
@@ -65,10 +64,9 @@ protected:
// Compute target-specific Fortran language flags.
void AddFortranFlags(std::string& flags);
- std::string Convert(std::string const& source,
- cmLocalGenerator::RelativeRoot relative,
- cmLocalGenerator::OutputFormat output =
- cmLocalGenerator::UNCHANGED);
+ std::string Convert(
+ std::string const& source, cmLocalGenerator::RelativeRoot relative,
+ cmLocalGenerator::OutputFormat output = cmLocalGenerator::UNCHANGED);
void AppendFortranFormatFlags(std::string& flags,
cmSourceFile const& source);
@@ -83,9 +81,9 @@ protected:
const char* name, bool so);
typedef std::map<std::string, std::string> ByLanguageMap;
- std::string GetFlags(const std::string &l);
+ std::string GetFlags(const std::string& l);
ByLanguageMap FlagsByLanguage;
- std::string GetDefines(const std::string &l);
+ std::string GetDefines(const std::string& l);
ByLanguageMap DefinesByLanguage;
std::string GetIncludes(std::string const& l);
ByLanguageMap IncludesByLanguage;
diff --git a/Source/cmComputeComponentGraph.cxx b/Source/cmComputeComponentGraph.cxx
index 9cd780d..4f21c3a 100644
--- a/Source/cmComputeComponentGraph.cxx
+++ b/Source/cmComputeComponentGraph.cxx
@@ -15,8 +15,8 @@
#include <assert.h>
-cmComputeComponentGraph::cmComputeComponentGraph(Graph const& input):
- InputGraph(input)
+cmComputeComponentGraph::cmComputeComponentGraph(Graph const& input)
+ : InputGraph(input)
{
// Identify components.
this->Tarjan();
@@ -34,7 +34,7 @@ cmComputeComponentGraph::~cmComputeComponentGraph()
void cmComputeComponentGraph::Tarjan()
{
int n = static_cast<int>(this->InputGraph.size());
- TarjanEntry entry = {0,0};
+ TarjanEntry entry = { 0, 0 };
this->TarjanEntries.resize(0);
this->TarjanEntries.resize(n, entry);
this->TarjanComponents.resize(0);
@@ -42,17 +42,15 @@ void cmComputeComponentGraph::Tarjan()
this->TarjanWalkId = 0;
this->TarjanVisited.resize(0);
this->TarjanVisited.resize(n, 0);
- for(int i = 0; i < n; ++i)
- {
+ for (int i = 0; i < n; ++i) {
// Start a new DFS from this node if it has never been visited.
- if(!this->TarjanVisited[i])
- {
+ if (!this->TarjanVisited[i]) {
assert(this->TarjanStack.empty());
++this->TarjanWalkId;
this->TarjanIndex = 0;
this->TarjanVisit(i);
- }
}
+ }
}
void cmComputeComponentGraph::TarjanVisit(int i)
@@ -68,41 +66,35 @@ void cmComputeComponentGraph::TarjanVisit(int i)
// Follow outgoing edges.
EdgeList const& nl = this->InputGraph[i];
- for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni)
- {
+ for (EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) {
int j = *ni;
// Ignore edges to nodes that have been reached by a previous DFS
// walk. Since we did not reach the current node from that walk
// it must not belong to the same component and it has already
// been assigned to a component.
- if(this->TarjanVisited[j] > 0 &&
- this->TarjanVisited[j] < this->TarjanWalkId)
- {
+ if (this->TarjanVisited[j] > 0 &&
+ this->TarjanVisited[j] < this->TarjanWalkId) {
continue;
- }
+ }
// Visit the destination if it has not yet been visited.
- if(!this->TarjanVisited[j])
- {
+ if (!this->TarjanVisited[j]) {
this->TarjanVisit(j);
- }
+ }
// If the destination has not yet been assigned to a component,
// check if it has a better root for the current object.
- if(this->TarjanComponents[j] < 0)
- {
- if(this->TarjanEntries[this->TarjanEntries[j].Root].VisitIndex <
- this->TarjanEntries[this->TarjanEntries[i].Root].VisitIndex)
- {
+ if (this->TarjanComponents[j] < 0) {
+ if (this->TarjanEntries[this->TarjanEntries[j].Root].VisitIndex <
+ this->TarjanEntries[this->TarjanEntries[i].Root].VisitIndex) {
this->TarjanEntries[i].Root = this->TarjanEntries[j].Root;
- }
}
}
+ }
// Check if we have found a component.
- if(this->TarjanEntries[i].Root == i)
- {
+ if (this->TarjanEntries[i].Root == i) {
// Yes. Create it.
int c = static_cast<int>(this->Components.size());
this->Components.push_back(NodeList());
@@ -110,8 +102,7 @@ void cmComputeComponentGraph::TarjanVisit(int i)
// Populate the component list.
int j;
- do
- {
+ do {
// Get the next member of the component.
j = this->TarjanStack.top();
this->TarjanStack.pop();
@@ -122,11 +113,11 @@ void cmComputeComponentGraph::TarjanVisit(int i)
// Store the node in its component.
component.push_back(j);
- } while(j != i);
+ } while (j != i);
// Sort the component members for clarity.
std::sort(component.begin(), component.end());
- }
+ }
}
void cmComputeComponentGraph::TransferEdges()
@@ -134,21 +125,18 @@ void cmComputeComponentGraph::TransferEdges()
// Map inter-component edges in the original graph to edges in the
// component graph.
int n = static_cast<int>(this->InputGraph.size());
- for(int i=0; i < n; ++i)
- {
+ for (int i = 0; i < n; ++i) {
int i_component = this->TarjanComponents[i];
EdgeList const& nl = this->InputGraph[i];
- for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni)
- {
+ for (EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) {
int j = *ni;
int j_component = this->TarjanComponents[j];
- if(i_component != j_component)
- {
+ if (i_component != j_component) {
// We do not attempt to combine duplicate edges, but instead
// store the inter-component edges with suitable multiplicity.
this->ComponentGraph[i_component].push_back(
cmGraphEdge(j_component, ni->IsStrong()));
- }
}
}
+ }
}
diff --git a/Source/cmComputeComponentGraph.h b/Source/cmComputeComponentGraph.h
index 4dbac4a..fb95f9a 100644
--- a/Source/cmComputeComponentGraph.h
+++ b/Source/cmComputeComponentGraph.h
@@ -40,20 +40,24 @@ public:
~cmComputeComponentGraph();
/** Get the adjacency list of the component graph. */
- Graph const& GetComponentGraph() const
- { return this->ComponentGraph; }
+ Graph const& GetComponentGraph() const { return this->ComponentGraph; }
EdgeList const& GetComponentGraphEdges(int c) const
- { return this->ComponentGraph[c]; }
+ {
+ return this->ComponentGraph[c];
+ }
/** Get map from component index to original node indices. */
std::vector<NodeList> const& GetComponents() const
- { return this->Components; }
- NodeList const& GetComponent(int c) const
- { return this->Components[c]; }
+ {
+ return this->Components;
+ }
+ NodeList const& GetComponent(int c) const { return this->Components[c]; }
/** Get map from original node index to component index. */
std::vector<int> const& GetComponentMap() const
- { return this->TarjanComponents; }
+ {
+ return this->TarjanComponents;
+ }
private:
void TransferEdges();
diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx
index 23ea371..2129394 100644
--- a/Source/cmComputeLinkDepends.cxx
+++ b/Source/cmComputeLinkDepends.cxx
@@ -170,20 +170,19 @@ items that we know the linker will re-use automatically (shared libs).
*/
-cmComputeLinkDepends
-::cmComputeLinkDepends(const cmGeneratorTarget* target,
- const std::string& config)
+cmComputeLinkDepends::cmComputeLinkDepends(const cmGeneratorTarget* target,
+ const std::string& config)
{
// Store context information.
this->Target = target;
this->Makefile = this->Target->Target->GetMakefile();
this->GlobalGenerator =
- this->Target->GetLocalGenerator()->GetGlobalGenerator();
+ this->Target->GetLocalGenerator()->GetGlobalGenerator();
this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance();
// The configuration being linked.
this->HasConfig = !config.empty();
- this->Config = (this->HasConfig)? config : std::string();
+ this->Config = (this->HasConfig) ? config : std::string();
std::vector<std::string> debugConfigs =
this->Makefile->GetCMakeInstance()->GetDebugConfigs();
this->LinkType = CMP0003_ComputeLinkType(this->Config, debugConfigs);
@@ -216,23 +215,21 @@ cmComputeLinkDepends::Compute()
this->AddDirectLinkEntries();
// Complete the breadth-first search of dependencies.
- while(!this->BFSQueue.empty())
- {
+ while (!this->BFSQueue.empty()) {
// Get the next entry.
BFSEntry qe = this->BFSQueue.front();
this->BFSQueue.pop();
// Follow the entry's dependencies.
this->FollowLinkEntry(qe);
- }
+ }
// Complete the search of shared library dependencies.
- while(!this->SharedDepQueue.empty())
- {
+ while (!this->SharedDepQueue.empty()) {
// Handle the next entry.
this->HandleSharedDependency(this->SharedDepQueue.front());
this->SharedDepQueue.pop();
- }
+ }
// Infer dependencies of targets for which they were not known.
this->InferDependencies();
@@ -241,16 +238,14 @@ cmComputeLinkDepends::Compute()
this->CleanConstraintGraph();
// Display the constraint graph.
- if(this->DebugMode)
- {
- fprintf(stderr,
- "---------------------------------------"
- "---------------------------------------\n");
+ if (this->DebugMode) {
+ fprintf(stderr, "---------------------------------------"
+ "---------------------------------------\n");
fprintf(stderr, "Link dependency analysis for target %s, config %s\n",
this->Target->GetName().c_str(),
- this->HasConfig?this->Config.c_str():"noconfig");
+ this->HasConfig ? this->Config.c_str() : "noconfig");
this->DisplayConstraintGraph();
- }
+ }
// Compute the final ordering.
this->OrderLinkEntires();
@@ -259,40 +254,37 @@ cmComputeLinkDepends::Compute()
// Iterate in reverse order so we can keep only the last occurrence
// of a shared library.
std::set<int> emmitted;
- for(std::vector<int>::const_reverse_iterator
- li = this->FinalLinkOrder.rbegin(),
- le = this->FinalLinkOrder.rend();
- li != le; ++li)
- {
+ for (std::vector<int>::const_reverse_iterator
+ li = this->FinalLinkOrder.rbegin(),
+ le = this->FinalLinkOrder.rend();
+ li != le; ++li) {
int i = *li;
LinkEntry const& e = this->EntryList[i];
cmGeneratorTarget const* t = e.Target;
// Entries that we know the linker will re-use do not need to be repeated.
bool uniquify = t && t->GetType() == cmState::SHARED_LIBRARY;
- if(!uniquify || emmitted.insert(i).second)
- {
+ if (!uniquify || emmitted.insert(i).second) {
this->FinalLinkEntries.push_back(e);
- }
}
+ }
// Reverse the resulting order since we iterated in reverse.
std::reverse(this->FinalLinkEntries.begin(), this->FinalLinkEntries.end());
// Display the final set.
- if(this->DebugMode)
- {
+ if (this->DebugMode) {
this->DisplayFinalEntries();
- }
+ }
return this->FinalLinkEntries;
}
-std::map<std::string, int>::iterator
-cmComputeLinkDepends::AllocateLinkEntry(std::string const& item)
+std::map<std::string, int>::iterator cmComputeLinkDepends::AllocateLinkEntry(
+ std::string const& item)
{
- std::map<std::string, int>::value_type
- index_entry(item, static_cast<int>(this->EntryList.size()));
- std::map<std::string, int>::iterator
- lei = this->LinkEntryIndex.insert(index_entry).first;
+ std::map<std::string, int>::value_type index_entry(
+ item, static_cast<int>(this->EntryList.size()));
+ std::map<std::string, int>::iterator lei =
+ this->LinkEntryIndex.insert(index_entry).first;
this->EntryList.push_back(LinkEntry());
this->InferredDependSets.push_back(0);
this->EntryConstraintGraph.push_back(EdgeList());
@@ -303,11 +295,10 @@ int cmComputeLinkDepends::AddLinkEntry(cmLinkItem const& item)
{
// Check if the item entry has already been added.
std::map<std::string, int>::iterator lei = this->LinkEntryIndex.find(item);
- if(lei != this->LinkEntryIndex.end())
- {
+ if (lei != this->LinkEntryIndex.end()) {
// Yes. We do not need to follow the item's dependencies again.
return lei->second;
- }
+ }
// Allocate a spot for the item entry.
lei = this->AllocateLinkEntry(item);
@@ -321,29 +312,23 @@ int cmComputeLinkDepends::AddLinkEntry(cmLinkItem const& item)
item.substr(0, 10) != "-framework");
// If the item has dependencies queue it to follow them.
- if(entry.Target)
- {
+ if (entry.Target) {
// Target dependencies are always known. Follow them.
- BFSEntry qe = {index, 0};
+ BFSEntry qe = { index, 0 };
this->BFSQueue.push(qe);
- }
- else
- {
+ } else {
// Look for an old-style <item>_LIB_DEPENDS variable.
std::string var = entry.Item;
var += "_LIB_DEPENDS";
- if(const char* val = this->Makefile->GetDefinition(var))
- {
+ if (const char* val = this->Makefile->GetDefinition(var)) {
// The item dependencies are known. Follow them.
- BFSEntry qe = {index, val};
+ BFSEntry qe = { index, val };
this->BFSQueue.push(qe);
- }
- else if(!entry.IsFlag)
- {
+ } else if (!entry.IsFlag) {
// The item dependencies are not known. We need to infer them.
this->InferredDependSets[index] = new DependSetList;
- }
}
+ }
return index;
}
@@ -355,70 +340,58 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe)
LinkEntry const& entry = this->EntryList[depender_index];
// Follow the item's dependencies.
- if(entry.Target)
- {
+ if (entry.Target) {
// Follow the target dependencies.
- if(cmLinkInterface const* iface =
- entry.Target->GetLinkInterface(this->Config, this->Target))
- {
+ if (cmLinkInterface const* iface =
+ entry.Target->GetLinkInterface(this->Config, this->Target)) {
const bool isIface =
- entry.Target->GetType() == cmState::INTERFACE_LIBRARY;
+ entry.Target->GetType() == cmState::INTERFACE_LIBRARY;
// This target provides its own link interface information.
this->AddLinkEntries(depender_index, iface->Libraries);
- if (isIface)
- {
+ if (isIface) {
return;
- }
+ }
// Handle dependent shared libraries.
this->FollowSharedDeps(depender_index, iface);
// Support for CMP0003.
- for(std::vector<cmLinkItem>::const_iterator
- oi = iface->WrongConfigLibraries.begin();
- oi != iface->WrongConfigLibraries.end(); ++oi)
- {
+ for (std::vector<cmLinkItem>::const_iterator oi =
+ iface->WrongConfigLibraries.begin();
+ oi != iface->WrongConfigLibraries.end(); ++oi) {
this->CheckWrongConfigItem(*oi);
- }
}
}
- else
- {
+ } else {
// Follow the old-style dependency list.
this->AddVarLinkEntries(depender_index, qe.LibDepends);
- }
+ }
}
-void
-cmComputeLinkDepends
-::FollowSharedDeps(int depender_index, cmLinkInterface const* iface,
- bool follow_interface)
+void cmComputeLinkDepends::FollowSharedDeps(int depender_index,
+ cmLinkInterface const* iface,
+ bool follow_interface)
{
// Follow dependencies if we have not followed them already.
- if(this->SharedDepFollowed.insert(depender_index).second)
- {
- if(follow_interface)
- {
+ if (this->SharedDepFollowed.insert(depender_index).second) {
+ if (follow_interface) {
this->QueueSharedDependencies(depender_index, iface->Libraries);
- }
- this->QueueSharedDependencies(depender_index, iface->SharedDeps);
}
+ this->QueueSharedDependencies(depender_index, iface->SharedDeps);
+ }
}
-void
-cmComputeLinkDepends
-::QueueSharedDependencies(int depender_index,
- std::vector<cmLinkItem> const& deps)
+void cmComputeLinkDepends::QueueSharedDependencies(
+ int depender_index, std::vector<cmLinkItem> const& deps)
{
- for(std::vector<cmLinkItem>::const_iterator li = deps.begin();
- li != deps.end(); ++li)
- {
+ for (std::vector<cmLinkItem>::const_iterator li = deps.begin();
+ li != deps.end(); ++li) {
SharedDepEntry qe;
qe.Item = *li;
qe.DependerIndex = depender_index;
this->SharedDepQueue.push(qe);
- }
+ }
}
void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep)
@@ -426,8 +399,7 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep)
// Check if the target already has an entry.
std::map<std::string, int>::iterator lei =
this->LinkEntryIndex.find(dep.Item);
- if(lei == this->LinkEntryIndex.end())
- {
+ if (lei == this->LinkEntryIndex.end()) {
// Allocate a spot for the item entry.
lei = this->AllocateLinkEntry(dep.Item);
@@ -440,7 +412,7 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep)
// shared library. It may get special treatment
// in cmComputeLinkInformation.
entry.IsSharedDep = true;
- }
+ }
// Get the link entry for this target.
int index = lei->second;
@@ -451,15 +423,13 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep)
this->EntryConstraintGraph[dep.DependerIndex].push_back(index);
// Target items may have their own dependencies.
- if(entry.Target)
- {
- if(cmLinkInterface const* iface =
- entry.Target->GetLinkInterface(this->Config, this->Target))
- {
+ if (entry.Target) {
+ if (cmLinkInterface const* iface =
+ entry.Target->GetLinkInterface(this->Config, this->Target)) {
// Follow public and private dependencies transitively.
this->FollowSharedDeps(index, iface, true);
- }
}
+ }
}
void cmComputeLinkDepends::AddVarLinkEntries(int depender_index,
@@ -475,65 +445,49 @@ void cmComputeLinkDepends::AddVarLinkEntries(int depender_index,
std::vector<cmLinkItem> actual_libs;
cmTargetLinkLibraryType llt = GENERAL_LibraryType;
bool haveLLT = false;
- for(std::vector<std::string>::const_iterator di = deplist.begin();
- di != deplist.end(); ++di)
- {
- if(*di == "debug")
- {
+ for (std::vector<std::string>::const_iterator di = deplist.begin();
+ di != deplist.end(); ++di) {
+ if (*di == "debug") {
llt = DEBUG_LibraryType;
haveLLT = true;
- }
- else if(*di == "optimized")
- {
+ } else if (*di == "optimized") {
llt = OPTIMIZED_LibraryType;
haveLLT = true;
- }
- else if(*di == "general")
- {
+ } else if (*di == "general") {
llt = GENERAL_LibraryType;
haveLLT = true;
- }
- else if(!di->empty())
- {
+ } else if (!di->empty()) {
// If no explicit link type was given prior to this entry then
// check if the entry has its own link type variable. This is
// needed for compatibility with dependency files generated by
// the export_library_dependencies command from CMake 2.4 and
// lower.
- if(!haveLLT)
- {
+ if (!haveLLT) {
std::string var = *di;
var += "_LINK_TYPE";
- if(const char* val = this->Makefile->GetDefinition(var))
- {
- if(strcmp(val, "debug") == 0)
- {
+ if (const char* val = this->Makefile->GetDefinition(var)) {
+ if (strcmp(val, "debug") == 0) {
llt = DEBUG_LibraryType;
- }
- else if(strcmp(val, "optimized") == 0)
- {
+ } else if (strcmp(val, "optimized") == 0) {
llt = OPTIMIZED_LibraryType;
- }
}
}
+ }
// If the library is meant for this link type then use it.
- if(llt == GENERAL_LibraryType || llt == this->LinkType)
- {
+ if (llt == GENERAL_LibraryType || llt == this->LinkType) {
cmLinkItem item(*di, this->FindTargetToLink(depender_index, *di));
actual_libs.push_back(item);
- }
- else if(this->OldLinkDirMode)
- {
+ } else if (this->OldLinkDirMode) {
cmLinkItem item(*di, this->FindTargetToLink(depender_index, *di));
this->CheckWrongConfigItem(item);
- }
+ }
// Reset the link type until another explicit type is given.
llt = GENERAL_LibraryType;
haveLLT = false;
- }
}
+ }
// Add the entries from this list.
this->AddLinkEntries(depender_index, actual_libs);
@@ -545,94 +499,80 @@ void cmComputeLinkDepends::AddDirectLinkEntries()
cmLinkImplementation const* impl =
this->Target->GetLinkImplementation(this->Config);
this->AddLinkEntries(-1, impl->Libraries);
- for(std::vector<cmLinkItem>::const_iterator
- wi = impl->WrongConfigLibraries.begin();
- wi != impl->WrongConfigLibraries.end(); ++wi)
- {
+ for (std::vector<cmLinkItem>::const_iterator wi =
+ impl->WrongConfigLibraries.begin();
+ wi != impl->WrongConfigLibraries.end(); ++wi) {
this->CheckWrongConfigItem(*wi);
- }
+ }
}
template <typename T>
-void
-cmComputeLinkDepends::AddLinkEntries(
- int depender_index, std::vector<T> const& libs)
+void cmComputeLinkDepends::AddLinkEntries(int depender_index,
+ std::vector<T> const& libs)
{
// Track inferred dependency sets implied by this list.
std::map<int, DependSet> dependSets;
// Loop over the libraries linked directly by the depender.
- for(typename std::vector<T>::const_iterator li = libs.begin();
- li != libs.end(); ++li)
- {
+ for (typename std::vector<T>::const_iterator li = libs.begin();
+ li != libs.end(); ++li) {
// Skip entries that will resolve to the target getting linked or
// are empty.
cmLinkItem const& item = *li;
- if(item == this->Target->GetName() || item.empty())
- {
+ if (item == this->Target->GetName() || item.empty()) {
continue;
- }
+ }
// Add a link entry for this item.
int dependee_index = this->AddLinkEntry(*li);
// The dependee must come after the depender.
- if(depender_index >= 0)
- {
+ if (depender_index >= 0) {
this->EntryConstraintGraph[depender_index].push_back(dependee_index);
- }
- else
- {
+ } else {
// This is a direct dependency of the target being linked.
this->OriginalEntries.push_back(dependee_index);
- }
+ }
// Update the inferred dependencies for earlier items.
- for(std::map<int, DependSet>::iterator dsi = dependSets.begin();
- dsi != dependSets.end(); ++dsi)
- {
+ for (std::map<int, DependSet>::iterator dsi = dependSets.begin();
+ dsi != dependSets.end(); ++dsi) {
// Add this item to the inferred dependencies of other items.
// Target items are never inferred dependees because unknown
// items are outside libraries that should not be depending on
// targets.
- if(!this->EntryList[dependee_index].Target &&
- !this->EntryList[dependee_index].IsFlag &&
- dependee_index != dsi->first)
- {
+ if (!this->EntryList[dependee_index].Target &&
+ !this->EntryList[dependee_index].IsFlag &&
+ dependee_index != dsi->first) {
dsi->second.insert(dependee_index);
- }
}
+ }
// If this item needs to have dependencies inferred, do so.
- if(this->InferredDependSets[dependee_index])
- {
+ if (this->InferredDependSets[dependee_index]) {
// Make sure an entry exists to hold the set for the item.
dependSets[dependee_index];
- }
}
+ }
// Store the inferred dependency sets discovered for this list.
- for(std::map<int, DependSet>::iterator dsi = dependSets.begin();
- dsi != dependSets.end(); ++dsi)
- {
+ for (std::map<int, DependSet>::iterator dsi = dependSets.begin();
+ dsi != dependSets.end(); ++dsi) {
this->InferredDependSets[dsi->first]->push_back(dsi->second);
- }
+ }
}
-cmGeneratorTarget const*
-cmComputeLinkDepends::FindTargetToLink(int depender_index,
- const std::string& name)
+cmGeneratorTarget const* cmComputeLinkDepends::FindTargetToLink(
+ int depender_index, const std::string& name)
{
// Look for a target in the scope of the depender.
cmGeneratorTarget const* from = this->Target;
- if(depender_index >= 0)
- {
- if(cmGeneratorTarget const* depender =
- this->EntryList[depender_index].Target)
- {
+ if (depender_index >= 0) {
+ if (cmGeneratorTarget const* depender =
+ this->EntryList[depender_index].Target) {
from = depender;
- }
}
+ }
return from->FindTargetToLink(name);
}
@@ -641,59 +581,53 @@ void cmComputeLinkDepends::InferDependencies()
// The inferred dependency sets for each item list the possible
// dependencies. The intersection of the sets for one item form its
// inferred dependencies.
- for(unsigned int depender_index=0;
- depender_index < this->InferredDependSets.size(); ++depender_index)
- {
+ for (unsigned int depender_index = 0;
+ depender_index < this->InferredDependSets.size(); ++depender_index) {
// Skip items for which dependencies do not need to be inferred or
// for which the inferred dependency sets are empty.
DependSetList* sets = this->InferredDependSets[depender_index];
- if(!sets || sets->empty())
- {
+ if (!sets || sets->empty()) {
continue;
- }
+ }
// Intersect the sets for this item.
DependSetList::const_iterator i = sets->begin();
DependSet common = *i;
- for(++i; i != sets->end(); ++i)
- {
+ for (++i; i != sets->end(); ++i) {
DependSet intersection;
- std::set_intersection
- (common.begin(), common.end(), i->begin(), i->end(),
- std::inserter(intersection, intersection.begin()));
+ std::set_intersection(common.begin(), common.end(), i->begin(), i->end(),
+ std::inserter(intersection, intersection.begin()));
common = intersection;
- }
+ }
// Add the inferred dependencies to the graph.
cmGraphEdgeList& edges = this->EntryConstraintGraph[depender_index];
edges.insert(edges.end(), common.begin(), common.end());
- }
+ }
}
void cmComputeLinkDepends::CleanConstraintGraph()
{
- for(Graph::iterator i = this->EntryConstraintGraph.begin();
- i != this->EntryConstraintGraph.end(); ++i)
- {
+ for (Graph::iterator i = this->EntryConstraintGraph.begin();
+ i != this->EntryConstraintGraph.end(); ++i) {
// Sort the outgoing edges for each graph node so that the
// original order will be preserved as much as possible.
std::sort(i->begin(), i->end());
// Make the edge list unique.
i->erase(std::unique(i->begin(), i->end()), i->end());
- }
+ }
}
void cmComputeLinkDepends::DisplayConstraintGraph()
{
// Display the graph nodes and their edges.
std::ostringstream e;
- for(unsigned int i=0; i < this->EntryConstraintGraph.size(); ++i)
- {
+ for (unsigned int i = 0; i < this->EntryConstraintGraph.size(); ++i) {
EdgeList const& nl = this->EntryConstraintGraph[i];
e << "item " << i << " is [" << this->EntryList[i].Item << "]\n";
e << cmWrap(" item ", nl, " must follow it", "\n") << "\n";
- }
+ }
fprintf(stderr, "%s\n", e.str().c_str());
}
@@ -716,71 +650,60 @@ void cmComputeLinkDepends::OrderLinkEntires()
this->ComponentOrderId = n;
// Run in reverse order so the topological order will preserve the
// original order where there are no constraints.
- for(int c = n-1; c >= 0; --c)
- {
+ for (int c = n - 1; c >= 0; --c) {
this->VisitComponent(c);
- }
+ }
// Display the component graph.
- if(this->DebugMode)
- {
+ if (this->DebugMode) {
this->DisplayComponents();
- }
+ }
// Start with the original link line.
- for(std::vector<int>::const_iterator i = this->OriginalEntries.begin();
- i != this->OriginalEntries.end(); ++i)
- {
+ for (std::vector<int>::const_iterator i = this->OriginalEntries.begin();
+ i != this->OriginalEntries.end(); ++i) {
this->VisitEntry(*i);
- }
+ }
// Now explore anything left pending. Since the component graph is
// guaranteed to be acyclic we know this will terminate.
- while(!this->PendingComponents.empty())
- {
+ while (!this->PendingComponents.empty()) {
// Visit one entry from the first pending component. The visit
// logic will update the pending components accordingly. Since
// the pending components are kept in topological order this will
// not repeat one.
int e = *this->PendingComponents.begin()->second.Entries.begin();
this->VisitEntry(e);
- }
+ }
}
-void
-cmComputeLinkDepends::DisplayComponents()
+void cmComputeLinkDepends::DisplayComponents()
{
fprintf(stderr, "The strongly connected components are:\n");
std::vector<NodeList> const& components = this->CCG->GetComponents();
- for(unsigned int c=0; c < components.size(); ++c)
- {
+ for (unsigned int c = 0; c < components.size(); ++c) {
fprintf(stderr, "Component (%u):\n", c);
NodeList const& nl = components[c];
- for(NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni)
- {
+ for (NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) {
int i = *ni;
- fprintf(stderr, " item %d [%s]\n", i,
- this->EntryList[i].Item.c_str());
- }
+ fprintf(stderr, " item %d [%s]\n", i, this->EntryList[i].Item.c_str());
+ }
EdgeList const& ol = this->CCG->GetComponentGraphEdges(c);
- for(EdgeList::const_iterator oi = ol.begin(); oi != ol.end(); ++oi)
- {
+ for (EdgeList::const_iterator oi = ol.begin(); oi != ol.end(); ++oi) {
int i = *oi;
fprintf(stderr, " followed by Component (%d)\n", i);
- }
- fprintf(stderr, " topo order index %d\n",
- this->ComponentOrder[c]);
}
+ fprintf(stderr, " topo order index %d\n", this->ComponentOrder[c]);
+ }
fprintf(stderr, "\n");
}
void cmComputeLinkDepends::VisitComponent(unsigned int c)
{
// Check if the node has already been visited.
- if(this->ComponentVisited[c])
- {
+ if (this->ComponentVisited[c]) {
return;
- }
+ }
// We are now visiting this component so mark it.
this->ComponentVisited[c] = 1;
@@ -789,11 +712,10 @@ void cmComputeLinkDepends::VisitComponent(unsigned int c)
// Run in reverse order so the topological order will preserve the
// original order where there are no constraints.
EdgeList const& nl = this->CCG->GetComponentGraphEdges(c);
- for(EdgeList::const_reverse_iterator ni = nl.rbegin();
- ni != nl.rend(); ++ni)
- {
+ for (EdgeList::const_reverse_iterator ni = nl.rbegin(); ni != nl.rend();
+ ++ni) {
this->VisitComponent(*ni);
- }
+ }
// Assign an ordering id to this component.
this->ComponentOrder[c] = --this->ComponentOrderId;
@@ -809,64 +731,52 @@ void cmComputeLinkDepends::VisitEntry(int index)
int component = this->CCG->GetComponentMap()[index];
std::map<int, PendingComponent>::iterator mi =
this->PendingComponents.find(this->ComponentOrder[component]);
- if(mi != this->PendingComponents.end())
- {
+ if (mi != this->PendingComponents.end()) {
// The entry is in an already pending component.
PendingComponent& pc = mi->second;
// Remove the entry from those pending in its component.
pc.Entries.erase(index);
- if(pc.Entries.empty())
- {
+ if (pc.Entries.empty()) {
// The complete component has been seen since it was last needed.
--pc.Count;
- if(pc.Count == 0)
- {
+ if (pc.Count == 0) {
// The component has been completed.
this->PendingComponents.erase(mi);
completed = true;
- }
- else
- {
+ } else {
// The whole component needs to be seen again.
NodeList const& nl = this->CCG->GetComponent(component);
assert(nl.size() > 1);
pc.Entries.insert(nl.begin(), nl.end());
- }
}
}
- else
- {
+ } else {
// The entry is not in an already pending component.
NodeList const& nl = this->CCG->GetComponent(component);
- if(nl.size() > 1)
- {
+ if (nl.size() > 1) {
// This is a non-trivial component. It is now pending.
PendingComponent& pc = this->MakePendingComponent(component);
// The starting entry has already been seen.
pc.Entries.erase(index);
- }
- else
- {
+ } else {
// This is a trivial component, so it is already complete.
completed = true;
- }
}
+ }
// If the entry completed a component, the component's dependencies
// are now pending.
- if(completed)
- {
+ if (completed) {
EdgeList const& ol = this->CCG->GetComponentGraphEdges(component);
- for(EdgeList::const_iterator oi = ol.begin(); oi != ol.end(); ++oi)
- {
+ for (EdgeList::const_iterator oi = ol.begin(); oi != ol.end(); ++oi) {
// This entire component is now pending no matter whether it has
// been partially seen already.
this->MakePendingComponent(*oi);
- }
}
+ }
}
cmComputeLinkDepends::PendingComponent&
@@ -878,13 +788,10 @@ cmComputeLinkDepends::MakePendingComponent(unsigned int component)
pc.Id = component;
NodeList const& nl = this->CCG->GetComponent(component);
- if(nl.size() == 1)
- {
+ if (nl.size() == 1) {
// Trivial components need be seen only once.
pc.Count = 1;
- }
- else
- {
+ } else {
// This is a non-trivial strongly connected component of the
// original graph. It consists of two or more libraries
// (archives) that mutually require objects from one another. In
@@ -898,7 +805,7 @@ cmComputeLinkDepends::MakePendingComponent(unsigned int component)
// this component will come first which minimizes the number of
// repeats needed.
pc.Count = this->ComputeComponentCount(nl);
- }
+ }
// Store the entries to be seen.
pc.Entries.insert(nl.begin(), nl.end());
@@ -909,54 +816,44 @@ cmComputeLinkDepends::MakePendingComponent(unsigned int component)
int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl)
{
unsigned int count = 2;
- for(NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni)
- {
- if(cmGeneratorTarget const* target = this->EntryList[*ni].Target)
- {
- if(cmLinkInterface const* iface =
- target->GetLinkInterface(this->Config, this->Target))
- {
- if(iface->Multiplicity > count)
- {
+ for (NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) {
+ if (cmGeneratorTarget const* target = this->EntryList[*ni].Target) {
+ if (cmLinkInterface const* iface =
+ target->GetLinkInterface(this->Config, this->Target)) {
+ if (iface->Multiplicity > count) {
count = iface->Multiplicity;
- }
}
}
}
+ }
return count;
}
void cmComputeLinkDepends::DisplayFinalEntries()
{
fprintf(stderr, "target [%s] links to:\n", this->Target->GetName().c_str());
- for(std::vector<LinkEntry>::const_iterator lei =
- this->FinalLinkEntries.begin();
- lei != this->FinalLinkEntries.end(); ++lei)
- {
- if(lei->Target)
- {
+ for (std::vector<LinkEntry>::const_iterator lei =
+ this->FinalLinkEntries.begin();
+ lei != this->FinalLinkEntries.end(); ++lei) {
+ if (lei->Target) {
fprintf(stderr, " target [%s]\n", lei->Target->GetName().c_str());
- }
- else
- {
+ } else {
fprintf(stderr, " item [%s]\n", lei->Item.c_str());
- }
}
+ }
fprintf(stderr, "\n");
}
void cmComputeLinkDepends::CheckWrongConfigItem(cmLinkItem const& item)
{
- if(!this->OldLinkDirMode)
- {
+ if (!this->OldLinkDirMode) {
return;
- }
+ }
// For CMake 2.4 bug-compatibility we need to consider the output
// directories of targets linked in another configuration as link
// directories.
- if(item.Target && !item.Target->IsImported())
- {
+ if (item.Target && !item.Target->IsImported()) {
this->OldWrongConfigItems.insert(item.Target);
- }
+ }
}
diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h
index ea23308..6aa40c3 100644
--- a/Source/cmComputeLinkDepends.h
+++ b/Source/cmComputeLinkDepends.h
@@ -42,10 +42,20 @@ public:
cmGeneratorTarget const* Target;
bool IsSharedDep;
bool IsFlag;
- LinkEntry(): Item(), Target(0), IsSharedDep(false), IsFlag(false) {}
- LinkEntry(LinkEntry const& r):
- Item(r.Item), Target(r.Target), IsSharedDep(r.IsSharedDep),
- IsFlag(r.IsFlag) {}
+ LinkEntry()
+ : Item()
+ , Target(0)
+ , IsSharedDep(false)
+ , IsFlag(false)
+ {
+ }
+ LinkEntry(LinkEntry const& r)
+ : Item(r.Item)
+ , Target(r.Target)
+ , IsSharedDep(r.IsSharedDep)
+ , IsFlag(r.IsFlag)
+ {
+ }
};
typedef std::vector<LinkEntry> EntryVector;
@@ -53,10 +63,11 @@ public:
void SetOldLinkDirMode(bool b);
std::set<cmGeneratorTarget const*> const& GetOldWrongConfigItems() const
- { return this->OldWrongConfigItems; }
+ {
+ return this->OldWrongConfigItems;
+ }
private:
-
// Context information.
cmGeneratorTarget const* Target;
cmMakefile* Makefile;
@@ -65,13 +76,13 @@ private:
std::string Config;
EntryVector FinalLinkEntries;
- std::map<std::string, int>::iterator
- AllocateLinkEntry(std::string const& item);
+ std::map<std::string, int>::iterator AllocateLinkEntry(
+ std::string const& item);
int AddLinkEntry(cmLinkItem const& item);
void AddVarLinkEntries(int depender_index, const char* value);
void AddDirectLinkEntries();
template <typename T>
- void AddLinkEntries(int depender_index, std::vector<T> const& libs);
+ void AddLinkEntries(int depender_index, std::vector<T> const& libs);
cmGeneratorTarget const* FindTargetToLink(int depender_index,
const std::string& name);
@@ -98,16 +109,19 @@ private:
};
std::queue<SharedDepEntry> SharedDepQueue;
std::set<int> SharedDepFollowed;
- void FollowSharedDeps(int depender_index,
- cmLinkInterface const* iface,
+ void FollowSharedDeps(int depender_index, cmLinkInterface const* iface,
bool follow_interface = false);
void QueueSharedDependencies(int depender_index,
std::vector<cmLinkItem> const& deps);
void HandleSharedDependency(SharedDepEntry const& dep);
// Dependency inferral for each link item.
- struct DependSet: public std::set<int> {};
- struct DependSetList: public std::vector<DependSet> {};
+ struct DependSet : public std::set<int>
+ {
+ };
+ struct DependSetList : public std::vector<DependSet>
+ {
+ };
std::vector<DependSetList*> InferredDependSets;
void InferDependencies();
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx
index 5b42b1a..e1a7bee 100644
--- a/Source/cmComputeLinkInformation.cxx
+++ b/Source/cmComputeLinkInformation.cxx
@@ -240,45 +240,42 @@ because this need be done only for shared libraries without soname-s.
*/
-cmComputeLinkInformation
-::cmComputeLinkInformation(const cmGeneratorTarget* target,
- const std::string& config)
+cmComputeLinkInformation::cmComputeLinkInformation(
+ const cmGeneratorTarget* target, const std::string& config)
{
// Store context information.
this->Target = target;
this->Makefile = this->Target->Target->GetMakefile();
this->GlobalGenerator =
- this->Target->GetLocalGenerator()->GetGlobalGenerator();
+ this->Target->GetLocalGenerator()->GetGlobalGenerator();
this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance();
// Check whether to recognize OpenBSD-style library versioned names.
- this->OpenBSD = this->Makefile->GetState()
- ->GetGlobalPropertyAsBool("FIND_LIBRARY_USE_OPENBSD_VERSIONING");
+ this->OpenBSD = this->Makefile->GetState()->GetGlobalPropertyAsBool(
+ "FIND_LIBRARY_USE_OPENBSD_VERSIONING");
// The configuration being linked.
this->Config = config;
// Allocate internals.
- this->OrderLinkerSearchPath =
- new cmOrderDirectories(this->GlobalGenerator, target,
- "linker search path");
- this->OrderRuntimeSearchPath =
- new cmOrderDirectories(this->GlobalGenerator, target,
- "runtime search path");
+ this->OrderLinkerSearchPath = new cmOrderDirectories(
+ this->GlobalGenerator, target, "linker search path");
+ this->OrderRuntimeSearchPath = new cmOrderDirectories(
+ this->GlobalGenerator, target, "runtime search path");
this->OrderDependentRPath = 0;
// Get the language used for linking this target.
this->LinkLanguage = this->Target->GetLinkerLanguage(config);
- if(this->LinkLanguage.empty())
- {
+ if (this->LinkLanguage.empty()) {
// The Compute method will do nothing, so skip the rest of the
// initialization.
return;
- }
+ }
// Check whether we should use an import library for linking a target.
this->UseImportLibrary =
- this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")?true:false;
+ this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX") ? true
+ : false;
// Check whether we should skip dependencies on shared library files.
this->LinkDependsNoShared =
@@ -288,14 +285,13 @@ cmComputeLinkInformation
// to use when creating a plugin (module) that obtains symbols from
// the program that will load it.
this->LoaderFlag = 0;
- if(!this->UseImportLibrary &&
- this->Target->GetType() == cmState::MODULE_LIBRARY)
- {
+ if (!this->UseImportLibrary &&
+ this->Target->GetType() == cmState::MODULE_LIBRARY) {
std::string loader_flag_var = "CMAKE_SHARED_MODULE_LOADER_";
loader_flag_var += this->LinkLanguage;
loader_flag_var += "_FLAG";
this->LoaderFlag = this->Makefile->GetDefinition(loader_flag_var);
- }
+ }
// Get options needed to link libraries.
this->LibLinkFlag =
@@ -307,11 +303,10 @@ cmComputeLinkInformation
// Get options needed to specify RPATHs.
this->RuntimeUseChrpath = false;
- if(this->Target->GetType() != cmState::STATIC_LIBRARY)
- {
+ if (this->Target->GetType() != cmState::STATIC_LIBRARY) {
const char* tType =
- ((this->Target->GetType() == cmState::EXECUTABLE)?
- "EXECUTABLE" : "SHARED_LIBRARY");
+ ((this->Target->GetType() == cmState::EXECUTABLE) ? "EXECUTABLE"
+ : "SHARED_LIBRARY");
std::string rtVar = "CMAKE_";
rtVar += tType;
rtVar += "_RUNTIME_";
@@ -320,9 +315,8 @@ cmComputeLinkInformation
std::string rtSepVar = rtVar + "_SEP";
this->RuntimeFlag = this->Makefile->GetSafeDefinition(rtVar);
this->RuntimeSep = this->Makefile->GetSafeDefinition(rtSepVar);
- this->RuntimeAlways =
- (this->Makefile->
- GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH"));
+ this->RuntimeAlways = (this->Makefile->GetSafeDefinition(
+ "CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH"));
this->RuntimeUseChrpath = this->Target->IsChrpathUsed(config);
@@ -333,14 +327,14 @@ cmComputeLinkInformation
rlVar += this->LinkLanguage;
rlVar += "_FLAG";
this->RPathLinkFlag = this->Makefile->GetSafeDefinition(rlVar);
- }
+ }
// Check if we need to include the runtime search path at link time.
{
- std::string var = "CMAKE_SHARED_LIBRARY_LINK_";
- var += this->LinkLanguage;
- var += "_WITH_RUNTIME_PATH";
- this->LinkWithRuntimePath = this->Makefile->IsOn(var);
+ std::string var = "CMAKE_SHARED_LIBRARY_LINK_";
+ var += this->LinkLanguage;
+ var += "_WITH_RUNTIME_PATH";
+ this->LinkWithRuntimePath = this->Makefile->IsOn(var);
}
// Check the platform policy for missing soname case.
@@ -358,41 +352,30 @@ cmComputeLinkInformation
// Choose a mode for dealing with shared library dependencies.
this->SharedDependencyMode = SharedDepModeNone;
- if(this->Makefile->IsOn("CMAKE_LINK_DEPENDENT_LIBRARY_FILES"))
- {
+ if (this->Makefile->IsOn("CMAKE_LINK_DEPENDENT_LIBRARY_FILES")) {
this->SharedDependencyMode = SharedDepModeLink;
- }
- else if(this->Makefile->IsOn("CMAKE_LINK_DEPENDENT_LIBRARY_DIRS"))
- {
+ } else if (this->Makefile->IsOn("CMAKE_LINK_DEPENDENT_LIBRARY_DIRS")) {
this->SharedDependencyMode = SharedDepModeLibDir;
- }
- else if(!this->RPathLinkFlag.empty())
- {
+ } else if (!this->RPathLinkFlag.empty()) {
this->SharedDependencyMode = SharedDepModeDir;
- this->OrderDependentRPath =
- new cmOrderDirectories(this->GlobalGenerator, target,
- "dependent library path");
- }
+ this->OrderDependentRPath = new cmOrderDirectories(
+ this->GlobalGenerator, target, "dependent library path");
+ }
// Add the search path entries requested by the user to path ordering.
- this->OrderLinkerSearchPath
- ->AddUserDirectories(this->Target->GetLinkDirectories());
- this->OrderRuntimeSearchPath
- ->AddUserDirectories(this->Target->GetLinkDirectories());
+ this->OrderLinkerSearchPath->AddUserDirectories(
+ this->Target->GetLinkDirectories());
+ this->OrderRuntimeSearchPath->AddUserDirectories(
+ this->Target->GetLinkDirectories());
// Set up the implicit link directories.
this->LoadImplicitLinkInfo();
- this->OrderLinkerSearchPath
- ->SetImplicitDirectories(this->ImplicitLinkDirs);
- this->OrderRuntimeSearchPath
- ->SetImplicitDirectories(this->ImplicitLinkDirs);
- if(this->OrderDependentRPath)
- {
- this->OrderDependentRPath
- ->SetImplicitDirectories(this->ImplicitLinkDirs);
- this->OrderDependentRPath
- ->AddLanguageDirectories(this->RuntimeLinkDirs);
- }
+ this->OrderLinkerSearchPath->SetImplicitDirectories(this->ImplicitLinkDirs);
+ this->OrderRuntimeSearchPath->SetImplicitDirectories(this->ImplicitLinkDirs);
+ if (this->OrderDependentRPath) {
+ this->OrderDependentRPath->SetImplicitDirectories(this->ImplicitLinkDirs);
+ this->OrderDependentRPath->AddLanguageDirectories(this->RuntimeLinkDirs);
+ }
// Decide whether to enable compatible library search path mode.
// There exists code that effectively does
@@ -407,18 +390,15 @@ cmComputeLinkInformation
// containing libraries linked with a full path to the -L path.
this->OldLinkDirMode =
this->Target->GetPolicyStatusCMP0003() != cmPolicies::NEW;
- if(this->OldLinkDirMode)
- {
+ if (this->OldLinkDirMode) {
// Construct a mask to not bother with this behavior for link
// directories already specified by the user.
- std::vector<std::string> const& dirs =
- this->Target->GetLinkDirectories();
+ std::vector<std::string> const& dirs = this->Target->GetLinkDirectories();
this->OldLinkDirMask.insert(dirs.begin(), dirs.end());
- }
+ }
- this->CMP0060Warn =
- this->Makefile->PolicyOptionalWarningEnabled(
- "CMAKE_POLICY_WARNING_CMP0060");
+ this->CMP0060Warn = this->Makefile->PolicyOptionalWarningEnabled(
+ "CMAKE_POLICY_WARNING_CMP0060");
}
cmComputeLinkInformation::~cmComputeLinkInformation()
@@ -443,10 +423,9 @@ std::string cmComputeLinkInformation::GetRPathLinkString()
{
// If there is no separate linker runtime search flag (-rpath-link)
// there is no reason to compute a string.
- if(!this->OrderDependentRPath)
- {
+ if (!this->OrderDependentRPath) {
return "";
- }
+ }
// Construct the linker runtime search path.
return cmJoin(this->OrderDependentRPath->GetOrderedDirectories(), ":");
@@ -471,22 +450,20 @@ cmComputeLinkInformation::GetSharedLibrariesLinked()
bool cmComputeLinkInformation::Compute()
{
// Skip targets that do not link.
- if(!(this->Target->GetType() == cmState::EXECUTABLE ||
- this->Target->GetType() == cmState::SHARED_LIBRARY ||
- this->Target->GetType() == cmState::MODULE_LIBRARY ||
- this->Target->GetType() == cmState::STATIC_LIBRARY))
- {
+ if (!(this->Target->GetType() == cmState::EXECUTABLE ||
+ this->Target->GetType() == cmState::SHARED_LIBRARY ||
+ this->Target->GetType() == cmState::MODULE_LIBRARY ||
+ this->Target->GetType() == cmState::STATIC_LIBRARY)) {
return false;
- }
+ }
// We require a link language for the target.
- if(this->LinkLanguage.empty())
- {
- cmSystemTools::
- Error("CMake can not determine linker language for target: ",
- this->Target->GetName().c_str());
+ if (this->LinkLanguage.empty()) {
+ cmSystemTools::Error(
+ "CMake can not determine linker language for target: ",
+ this->Target->GetName().c_str());
return false;
- }
+ }
// Compute the ordered link line items.
cmComputeLinkDepends cld(this->Target, this->Config);
@@ -494,64 +471,52 @@ bool cmComputeLinkInformation::Compute()
cmComputeLinkDepends::EntryVector const& linkEntries = cld.Compute();
// Add the link line items.
- for(cmComputeLinkDepends::EntryVector::const_iterator
- lei = linkEntries.begin();
- lei != linkEntries.end(); ++lei)
- {
- if(lei->IsSharedDep)
- {
+ for (cmComputeLinkDepends::EntryVector::const_iterator lei =
+ linkEntries.begin();
+ lei != linkEntries.end(); ++lei) {
+ if (lei->IsSharedDep) {
this->AddSharedDepItem(lei->Item, lei->Target);
- }
- else
- {
+ } else {
this->AddItem(lei->Item, lei->Target);
- }
}
+ }
// Restore the target link type so the correct system runtime
// libraries are found.
- const char* lss =
- this->Target->GetProperty("LINK_SEARCH_END_STATIC");
- if(cmSystemTools::IsOn(lss))
- {
+ const char* lss = this->Target->GetProperty("LINK_SEARCH_END_STATIC");
+ if (cmSystemTools::IsOn(lss)) {
this->SetCurrentLinkType(LinkStatic);
- }
- else
- {
+ } else {
this->SetCurrentLinkType(this->StartLinkType);
- }
+ }
// Finish listing compatibility paths.
- if(this->OldLinkDirMode)
- {
+ if (this->OldLinkDirMode) {
// For CMake 2.4 bug-compatibility we need to consider the output
// directories of targets linked in another configuration as link
// directories.
std::set<cmGeneratorTarget const*> const& wrongItems =
- cld.GetOldWrongConfigItems();
- for(std::set<cmGeneratorTarget const*>::const_iterator i =
- wrongItems.begin(); i != wrongItems.end(); ++i)
- {
+ cld.GetOldWrongConfigItems();
+ for (std::set<cmGeneratorTarget const*>::const_iterator i =
+ wrongItems.begin();
+ i != wrongItems.end(); ++i) {
cmGeneratorTarget const* tgt = *i;
- bool implib =
- (this->UseImportLibrary &&
- (tgt->GetType() == cmState::SHARED_LIBRARY));
- std::string lib = tgt->GetFullPath(this->Config , implib, true);
+ bool implib = (this->UseImportLibrary &&
+ (tgt->GetType() == cmState::SHARED_LIBRARY));
+ std::string lib = tgt->GetFullPath(this->Config, implib, true);
this->OldLinkDirItems.push_back(lib);
- }
}
+ }
// Finish setting up linker search directories.
- if(!this->FinishLinkerSearchDirectories())
- {
+ if (!this->FinishLinkerSearchDirectories()) {
return false;
- }
+ }
// Add implicit language runtime libraries and directories.
this->AddImplicitLinkInfo();
- if (!this->CMP0060WarnItems.empty())
- {
+ if (!this->CMP0060WarnItems.empty()) {
std::ostringstream w;
/* clang-format off */
w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0060) << "\n"
@@ -565,7 +530,7 @@ bool cmComputeLinkInformation::Compute()
/* clang-format on */
this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(),
this->Target->GetBacktrace());
- }
+ }
return true;
}
@@ -574,16 +539,14 @@ void cmComputeLinkInformation::AddImplicitLinkInfo()
{
// The link closure lists all languages whose implicit info is needed.
cmGeneratorTarget::LinkClosure const* lc =
- this->Target->GetLinkClosure(this->Config);
- for(std::vector<std::string>::const_iterator li = lc->Languages.begin();
- li != lc->Languages.end(); ++li)
- {
+ this->Target->GetLinkClosure(this->Config);
+ for (std::vector<std::string>::const_iterator li = lc->Languages.begin();
+ li != lc->Languages.end(); ++li) {
// Skip those of the linker language. They are implicit.
- if(*li != this->LinkLanguage)
- {
+ if (*li != this->LinkLanguage) {
this->AddImplicitLinkInfo(*li);
- }
}
+ }
}
void cmComputeLinkInformation::AddImplicitLinkInfo(std::string const& lang)
@@ -593,31 +556,27 @@ void cmComputeLinkInformation::AddImplicitLinkInfo(std::string const& lang)
std::string libVar = "CMAKE_";
libVar += lang;
libVar += "_IMPLICIT_LINK_LIBRARIES";
- if(const char* libs = this->Makefile->GetDefinition(libVar))
- {
+ if (const char* libs = this->Makefile->GetDefinition(libVar)) {
std::vector<std::string> libsVec;
cmSystemTools::ExpandListArgument(libs, libsVec);
- for(std::vector<std::string>::const_iterator i = libsVec.begin();
- i != libsVec.end(); ++i)
- {
- if(this->ImplicitLinkLibs.find(*i) == this->ImplicitLinkLibs.end())
- {
+ for (std::vector<std::string>::const_iterator i = libsVec.begin();
+ i != libsVec.end(); ++i) {
+ if (this->ImplicitLinkLibs.find(*i) == this->ImplicitLinkLibs.end()) {
this->AddItem(*i, 0);
- }
}
}
+ }
// Add linker search paths for this language that are not
// implied by the linker language.
std::string dirVar = "CMAKE_";
dirVar += lang;
dirVar += "_IMPLICIT_LINK_DIRECTORIES";
- if(const char* dirs = this->Makefile->GetDefinition(dirVar))
- {
+ if (const char* dirs = this->Makefile->GetDefinition(dirVar)) {
std::vector<std::string> dirsVec;
cmSystemTools::ExpandListArgument(dirs, dirsVec);
this->OrderLinkerSearchPath->AddLanguageDirectories(dirsVec);
- }
+ }
}
void cmComputeLinkInformation::AddItem(std::string const& item,
@@ -626,176 +585,141 @@ void cmComputeLinkInformation::AddItem(std::string const& item,
// Compute the proper name to use to link this library.
const std::string& config = this->Config;
bool impexe = (tgt && tgt->IsExecutableWithExports());
- if(impexe && !this->UseImportLibrary && !this->LoaderFlag)
- {
+ if (impexe && !this->UseImportLibrary && !this->LoaderFlag) {
// Skip linking to executables on platforms with no import
// libraries or loader flags.
return;
- }
+ }
- if(tgt && tgt->IsLinkable())
- {
+ if (tgt && tgt->IsLinkable()) {
// This is a CMake target. Ask the target for its real name.
- if(impexe && this->LoaderFlag)
- {
+ if (impexe && this->LoaderFlag) {
// This link item is an executable that may provide symbols
// used by this target. A special flag is needed on this
// platform. Add it now.
std::string linkItem;
linkItem = this->LoaderFlag;
- std::string exe = tgt->GetFullPath(config, this->UseImportLibrary,
- true);
+ std::string exe = tgt->GetFullPath(config, this->UseImportLibrary, true);
linkItem += exe;
this->Items.push_back(Item(linkItem, true, tgt));
this->Depends.push_back(exe);
- }
- else if(tgt->GetType() == cmState::INTERFACE_LIBRARY)
- {
+ } else if (tgt->GetType() == cmState::INTERFACE_LIBRARY) {
// Add the interface library as an item so it can be considered as part
// of COMPATIBLE_INTERFACE_ enforcement. The generators will ignore
// this for the actual link line.
this->Items.push_back(Item(std::string(), false, tgt));
- }
- else
- {
+ } else {
// Decide whether to use an import library.
- bool implib =
- (this->UseImportLibrary &&
- (impexe || tgt->GetType() == cmState::SHARED_LIBRARY));
+ bool implib = (this->UseImportLibrary &&
+ (impexe || tgt->GetType() == cmState::SHARED_LIBRARY));
// Pass the full path to the target file.
std::string lib = tgt->GetFullPath(config, implib, true);
- if(!this->LinkDependsNoShared ||
- tgt->GetType() != cmState::SHARED_LIBRARY)
- {
+ if (!this->LinkDependsNoShared ||
+ tgt->GetType() != cmState::SHARED_LIBRARY) {
this->Depends.push_back(lib);
- }
+ }
this->AddTargetItem(lib, tgt);
this->AddLibraryRuntimeInfo(lib, tgt);
- }
}
- else
- {
+ } else {
// This is not a CMake target. Use the name given.
- if(cmSystemTools::FileIsFullPath(item.c_str()))
- {
- if(cmSystemTools::FileIsDirectory(item))
- {
+ if (cmSystemTools::FileIsFullPath(item.c_str())) {
+ if (cmSystemTools::FileIsDirectory(item)) {
// This is a directory.
this->AddDirectoryItem(item);
- }
- else
- {
+ } else {
// Use the full path given to the library file.
this->Depends.push_back(item);
this->AddFullItem(item);
this->AddLibraryRuntimeInfo(item);
- }
}
- else
- {
+ } else {
// This is a library or option specified by the user.
this->AddUserItem(item, true);
- }
}
+ }
}
void cmComputeLinkInformation::AddSharedDepItem(std::string const& item,
const cmGeneratorTarget* tgt)
{
// If dropping shared library dependencies, ignore them.
- if(this->SharedDependencyMode == SharedDepModeNone)
- {
+ if (this->SharedDependencyMode == SharedDepModeNone) {
return;
- }
+ }
// The user may have incorrectly named an item. Skip items that are
// not full paths to shared libraries.
- if(tgt)
- {
+ if (tgt) {
// The target will provide a full path. Make sure it is a shared
// library.
- if(tgt->GetType() != cmState::SHARED_LIBRARY)
- {
+ if (tgt->GetType() != cmState::SHARED_LIBRARY) {
return;
- }
}
- else
- {
+ } else {
// Skip items that are not full paths. We will not be able to
// reliably specify them.
- if(!cmSystemTools::FileIsFullPath(item.c_str()))
- {
+ if (!cmSystemTools::FileIsFullPath(item.c_str())) {
return;
- }
+ }
// Get the name of the library from the file name.
std::string file = cmSystemTools::GetFilenameName(item);
- if(!this->ExtractSharedLibraryName.find(file.c_str()))
- {
+ if (!this->ExtractSharedLibraryName.find(file.c_str())) {
// This is not the name of a shared library.
return;
- }
}
+ }
// If in linking mode, just link to the shared library.
- if(this->SharedDependencyMode == SharedDepModeLink)
- {
+ if (this->SharedDependencyMode == SharedDepModeLink) {
this->AddItem(item, tgt);
return;
- }
+ }
// Get a full path to the dependent shared library.
// Add it to the runtime path computation so that the target being
// linked will be able to find it.
std::string lib;
- if(tgt)
- {
+ if (tgt) {
lib = tgt->GetFullPath(this->Config, this->UseImportLibrary);
this->AddLibraryRuntimeInfo(lib, tgt);
- }
- else
- {
+ } else {
lib = item;
this->AddLibraryRuntimeInfo(lib);
- }
+ }
// Check if we need to include the dependent shared library in other
// path ordering.
cmOrderDirectories* order = 0;
- if(this->SharedDependencyMode == SharedDepModeLibDir &&
- !this->LinkWithRuntimePath /* AddLibraryRuntimeInfo adds it */)
- {
+ if (this->SharedDependencyMode == SharedDepModeLibDir &&
+ !this->LinkWithRuntimePath /* AddLibraryRuntimeInfo adds it */) {
// Add the item to the linker search path.
order = this->OrderLinkerSearchPath;
- }
- else if(this->SharedDependencyMode == SharedDepModeDir)
- {
+ } else if (this->SharedDependencyMode == SharedDepModeDir) {
// Add the item to the separate dependent library search path.
order = this->OrderDependentRPath;
- }
- if(order)
- {
- if(tgt)
- {
+ }
+ if (order) {
+ if (tgt) {
std::string soName = tgt->GetSOName(this->Config);
- const char* soname = soName.empty()? 0 : soName.c_str();
+ const char* soname = soName.empty() ? 0 : soName.c_str();
order->AddRuntimeLibrary(lib, soname);
- }
- else
- {
+ } else {
order->AddRuntimeLibrary(lib);
- }
}
+ }
}
void cmComputeLinkInformation::ComputeLinkTypeInfo()
{
// Check whether archives may actually be shared libraries.
- this->ArchivesMayBeShared = this->CMakeInstance->GetState()
- ->GetGlobalPropertyAsBool("TARGET_ARCHIVES_MAY_BE_SHARED_LIBS");
+ this->ArchivesMayBeShared =
+ this->CMakeInstance->GetState()->GetGlobalPropertyAsBool(
+ "TARGET_ARCHIVES_MAY_BE_SHARED_LIBS");
// First assume we cannot do link type stuff.
this->LinkTypeEnabled = false;
@@ -804,15 +728,20 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo()
const char* static_link_type_flag = 0;
const char* shared_link_type_flag = 0;
const char* target_type_str = 0;
- switch(this->Target->GetType())
- {
- case cmState::EXECUTABLE: target_type_str = "EXE"; break;
- case cmState::SHARED_LIBRARY: target_type_str = "SHARED_LIBRARY"; break;
- case cmState::MODULE_LIBRARY: target_type_str = "SHARED_MODULE"; break;
- default: break;
- }
- if(target_type_str)
- {
+ switch (this->Target->GetType()) {
+ case cmState::EXECUTABLE:
+ target_type_str = "EXE";
+ break;
+ case cmState::SHARED_LIBRARY:
+ target_type_str = "SHARED_LIBRARY";
+ break;
+ case cmState::MODULE_LIBRARY:
+ target_type_str = "SHARED_MODULE";
+ break;
+ default:
+ break;
+ }
+ if (target_type_str) {
std::string static_link_type_flag_var = "CMAKE_";
static_link_type_flag_var += target_type_str;
static_link_type_flag_var += "_LINK_STATIC_";
@@ -828,22 +757,20 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo()
shared_link_type_flag_var += "_FLAGS";
shared_link_type_flag =
this->Makefile->GetDefinition(shared_link_type_flag_var);
- }
+ }
// We can support link type switching only if all needed flags are
// known.
- if(static_link_type_flag && *static_link_type_flag &&
- shared_link_type_flag && *shared_link_type_flag)
- {
+ if (static_link_type_flag && *static_link_type_flag &&
+ shared_link_type_flag && *shared_link_type_flag) {
this->LinkTypeEnabled = true;
this->StaticLinkTypeFlag = static_link_type_flag;
this->SharedLinkTypeFlag = shared_link_type_flag;
- }
+ }
// Lookup the starting link type from the target (linked statically?).
- const char* lss =
- this->Target->GetProperty("LINK_SEARCH_START_STATIC");
- this->StartLinkType = cmSystemTools::IsOn(lss)? LinkStatic : LinkShared;
+ const char* lss = this->Target->GetProperty("LINK_SEARCH_START_STATIC");
+ this->StartLinkType = cmSystemTools::IsOn(lss) ? LinkStatic : LinkShared;
this->CurrentLinkType = this->StartLinkType;
}
@@ -864,50 +791,44 @@ void cmComputeLinkInformation::ComputeItemParserInfo()
LinkShared);
this->AddLinkExtension(mf->GetDefinition("CMAKE_LINK_LIBRARY_SUFFIX"),
LinkUnknown);
- if(const char* linkSuffixes =
- mf->GetDefinition("CMAKE_EXTRA_LINK_EXTENSIONS"))
- {
+ if (const char* linkSuffixes =
+ mf->GetDefinition("CMAKE_EXTRA_LINK_EXTENSIONS")) {
std::vector<std::string> linkSuffixVec;
cmSystemTools::ExpandListArgument(linkSuffixes, linkSuffixVec);
- for(std::vector<std::string>::iterator i = linkSuffixVec.begin();
- i != linkSuffixVec.end(); ++i)
- {
+ for (std::vector<std::string>::iterator i = linkSuffixVec.begin();
+ i != linkSuffixVec.end(); ++i) {
this->AddLinkExtension(i->c_str(), LinkUnknown);
- }
}
- if(const char* sharedSuffixes =
- mf->GetDefinition("CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES"))
- {
+ }
+ if (const char* sharedSuffixes =
+ mf->GetDefinition("CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES")) {
std::vector<std::string> sharedSuffixVec;
cmSystemTools::ExpandListArgument(sharedSuffixes, sharedSuffixVec);
- for(std::vector<std::string>::iterator i = sharedSuffixVec.begin();
- i != sharedSuffixVec.end(); ++i)
- {
+ for (std::vector<std::string>::iterator i = sharedSuffixVec.begin();
+ i != sharedSuffixVec.end(); ++i) {
this->AddLinkExtension(i->c_str(), LinkShared);
- }
}
+ }
// Compute a regex to match link extensions.
- std::string libext = this->CreateExtensionRegex(this->LinkExtensions,
- LinkUnknown);
+ std::string libext =
+ this->CreateExtensionRegex(this->LinkExtensions, LinkUnknown);
// Create regex to remove any library extension.
std::string reg("(.*)");
reg += libext;
- this->OrderLinkerSearchPath->SetLinkExtensionInfo(this->LinkExtensions,
- reg);
+ this->OrderLinkerSearchPath->SetLinkExtensionInfo(this->LinkExtensions, reg);
// Create a regex to match a library name. Match index 1 will be
// the prefix if it exists and empty otherwise. Match index 2 will
// be the library name. Match index 3 will be the library
// extension.
reg = "^(";
- for(std::set<std::string>::iterator p = this->LinkPrefixes.begin();
- p != this->LinkPrefixes.end(); ++p)
- {
+ for (std::set<std::string>::iterator p = this->LinkPrefixes.begin();
+ p != this->LinkPrefixes.end(); ++p) {
reg += *p;
reg += "|";
- }
+ }
reg += ")";
reg += "([^/:]*)";
@@ -920,65 +841,57 @@ void cmComputeLinkInformation::ComputeItemParserInfo()
this->ExtractAnyLibraryName.compile(reg_any.c_str());
// Create a regex to match static library names.
- if(!this->StaticLinkExtensions.empty())
- {
+ if (!this->StaticLinkExtensions.empty()) {
std::string reg_static = reg;
- reg_static += this->CreateExtensionRegex(this->StaticLinkExtensions,
- LinkStatic);
+ reg_static +=
+ this->CreateExtensionRegex(this->StaticLinkExtensions, LinkStatic);
#ifdef CM_COMPUTE_LINK_INFO_DEBUG
- fprintf(stderr, "static regex [%s]\n", reg_static.c_str());
+ fprintf(stderr, "static regex [%s]\n", reg_static.c_str());
#endif
this->ExtractStaticLibraryName.compile(reg_static.c_str());
- }
+ }
// Create a regex to match shared library names.
- if(!this->SharedLinkExtensions.empty())
- {
+ if (!this->SharedLinkExtensions.empty()) {
std::string reg_shared = reg;
this->SharedRegexString =
this->CreateExtensionRegex(this->SharedLinkExtensions, LinkShared);
reg_shared += this->SharedRegexString;
#ifdef CM_COMPUTE_LINK_INFO_DEBUG
- fprintf(stderr, "shared regex [%s]\n", reg_shared.c_str());
+ fprintf(stderr, "shared regex [%s]\n", reg_shared.c_str());
#endif
this->ExtractSharedLibraryName.compile(reg_shared.c_str());
- }
+ }
}
void cmComputeLinkInformation::AddLinkPrefix(const char* p)
{
- if(p && *p)
- {
+ if (p && *p) {
this->LinkPrefixes.insert(p);
- }
+ }
}
void cmComputeLinkInformation::AddLinkExtension(const char* e, LinkType type)
{
- if(e && *e)
- {
- if(type == LinkStatic)
- {
+ if (e && *e) {
+ if (type == LinkStatic) {
this->StaticLinkExtensions.push_back(e);
- }
- if(type == LinkShared)
- {
+ }
+ if (type == LinkShared) {
this->SharedLinkExtensions.push_back(e);
- }
- this->LinkExtensions.push_back(e);
}
+ this->LinkExtensions.push_back(e);
+ }
}
-std::string
-cmComputeLinkInformation
-::CreateExtensionRegex(std::vector<std::string> const& exts, LinkType type)
+std::string cmComputeLinkInformation::CreateExtensionRegex(
+ std::vector<std::string> const& exts, LinkType type)
{
// Build a list of extension choices.
std::string libext = "(";
const char* sep = "";
- for(std::vector<std::string>::const_iterator i = exts.begin();
- i != exts.end(); ++i)
- {
+ for (std::vector<std::string>::const_iterator i = exts.begin();
+ i != exts.end(); ++i) {
// Separate this choice from the previous one.
libext += sep;
sep = "|";
@@ -990,20 +903,17 @@ cmComputeLinkInformation
#else
libext += *i;
#endif
- }
+ }
// Finish the list.
libext += ")";
// Add an optional OpenBSD version component.
- if(this->OpenBSD)
- {
+ if (this->OpenBSD) {
libext += "(\\.[0-9]+\\.[0-9]+)?";
- }
- else if(type == LinkShared)
- {
+ } else if (type == LinkShared) {
libext += "(\\.[0-9]+)?";
- }
+ }
libext += "$";
return libext;
@@ -1013,21 +923,17 @@ std::string cmComputeLinkInformation::NoCaseExpression(const char* str)
{
std::string ret;
const char* s = str;
- while(*s)
- {
- if(*s == '.')
- {
+ while (*s) {
+ if (*s == '.') {
ret += *s;
- }
- else
- {
+ } else {
ret += "[";
ret += static_cast<char>(tolower(*s));
ret += static_cast<char>(toupper(*s));
ret += "]";
- }
- s++;
}
+ s++;
+ }
return ret;
}
@@ -1035,14 +941,11 @@ void cmComputeLinkInformation::SetCurrentLinkType(LinkType lt)
{
// If we are changing the current link type add the flag to tell the
// linker about it.
- if(this->CurrentLinkType != lt)
- {
+ if (this->CurrentLinkType != lt) {
this->CurrentLinkType = lt;
- if(this->LinkTypeEnabled)
- {
- switch(this->CurrentLinkType)
- {
+ if (this->LinkTypeEnabled) {
+ switch (this->CurrentLinkType) {
case LinkStatic:
this->Items.push_back(Item(this->StaticLinkTypeFlag, false));
break;
@@ -1051,9 +954,9 @@ void cmComputeLinkInformation::SetCurrentLinkType(LinkType lt)
break;
default:
break;
- }
}
}
+ }
}
void cmComputeLinkInformation::AddTargetItem(std::string const& item,
@@ -1065,39 +968,34 @@ void cmComputeLinkInformation::AddTargetItem(std::string const& item,
// shared and static libraries but static-mode can handle only
// static libraries. If a previous user item changed the link type
// to static we need to make sure it is back to shared.
- if(target->GetType() != cmState::STATIC_LIBRARY)
- {
+ if (target->GetType() != cmState::STATIC_LIBRARY) {
this->SetCurrentLinkType(LinkShared);
- }
+ }
// Keep track of shared library targets linked.
- if(target->GetType() == cmState::SHARED_LIBRARY)
- {
+ if (target->GetType() == cmState::SHARED_LIBRARY) {
this->SharedLibrariesLinked.insert(target);
- }
+ }
// Handle case of an imported shared library with no soname.
- if(this->NoSONameUsesPath &&
- target->IsImportedSharedLibWithoutSOName(this->Config))
- {
+ if (this->NoSONameUsesPath &&
+ target->IsImportedSharedLibWithoutSOName(this->Config)) {
this->AddSharedLibNoSOName(item);
return;
- }
+ }
// If this platform wants a flag before the full path, add it.
- if(!this->LibLinkFileFlag.empty())
- {
+ if (!this->LibLinkFileFlag.empty()) {
this->Items.push_back(Item(this->LibLinkFileFlag, false));
- }
+ }
// For compatibility with CMake 2.4 include the item's directory in
// the linker search path.
- if(this->OldLinkDirMode && !target->IsFrameworkOnApple() &&
- this->OldLinkDirMask.find(cmSystemTools::GetFilenamePath(item)) ==
- this->OldLinkDirMask.end())
- {
+ if (this->OldLinkDirMode && !target->IsFrameworkOnApple() &&
+ this->OldLinkDirMask.find(cmSystemTools::GetFilenamePath(item)) ==
+ this->OldLinkDirMask.end()) {
this->OldLinkDirItems.push_back(item);
- }
+ }
// Now add the full path to the library.
this->Items.push_back(Item(item, true, target));
@@ -1106,31 +1004,27 @@ void cmComputeLinkInformation::AddTargetItem(std::string const& item,
void cmComputeLinkInformation::AddFullItem(std::string const& item)
{
// Check for the implicit link directory special case.
- if(this->CheckImplicitDirItem(item))
- {
+ if (this->CheckImplicitDirItem(item)) {
return;
- }
+ }
// Check for case of shared library with no builtin soname.
- if(this->NoSONameUsesPath && this->CheckSharedLibNoSOName(item))
- {
+ if (this->NoSONameUsesPath && this->CheckSharedLibNoSOName(item)) {
return;
- }
+ }
// Full path libraries should specify a valid library file name.
// See documentation of CMP0008.
std::string generator = this->GlobalGenerator->GetName();
- if(this->Target->GetPolicyStatusCMP0008() != cmPolicies::NEW &&
- (generator.find("Visual Studio") != generator.npos ||
- generator.find("Xcode") != generator.npos))
- {
+ if (this->Target->GetPolicyStatusCMP0008() != cmPolicies::NEW &&
+ (generator.find("Visual Studio") != generator.npos ||
+ generator.find("Xcode") != generator.npos)) {
std::string file = cmSystemTools::GetFilenameName(item);
- if(!this->ExtractAnyLibraryName.find(file.c_str()))
- {
+ if (!this->ExtractAnyLibraryName.find(file.c_str())) {
this->HandleBadFullItem(item, file);
return;
- }
}
+ }
// This is called to handle a link item that is a full path.
// If the target is not a static library make sure the link type is
@@ -1138,35 +1032,29 @@ void cmComputeLinkInformation::AddFullItem(std::string const& item)
// shared and static libraries but static-mode can handle only
// static libraries. If a previous user item changed the link type
// to static we need to make sure it is back to shared.
- if(this->LinkTypeEnabled)
- {
+ if (this->LinkTypeEnabled) {
std::string name = cmSystemTools::GetFilenameName(item);
- if(this->ExtractSharedLibraryName.find(name))
- {
+ if (this->ExtractSharedLibraryName.find(name)) {
this->SetCurrentLinkType(LinkShared);
- }
- else if(!this->ExtractStaticLibraryName.find(item))
- {
+ } else if (!this->ExtractStaticLibraryName.find(item)) {
// We cannot determine the type. Assume it is the target's
// default type.
this->SetCurrentLinkType(this->StartLinkType);
- }
}
+ }
// For compatibility with CMake 2.4 include the item's directory in
// the linker search path.
- if(this->OldLinkDirMode &&
- this->OldLinkDirMask.find(cmSystemTools::GetFilenamePath(item)) ==
- this->OldLinkDirMask.end())
- {
+ if (this->OldLinkDirMode &&
+ this->OldLinkDirMask.find(cmSystemTools::GetFilenamePath(item)) ==
+ this->OldLinkDirMask.end()) {
this->OldLinkDirItems.push_back(item);
- }
+ }
// If this platform wants a flag before the full path, add it.
- if(!this->LibLinkFileFlag.empty())
- {
+ if (!this->LibLinkFileFlag.empty()) {
this->Items.push_back(Item(this->LibLinkFileFlag, false));
- }
+ }
// Now add the full path to the library.
this->Items.push_back(Item(item, true));
@@ -1177,49 +1065,43 @@ bool cmComputeLinkInformation::CheckImplicitDirItem(std::string const& item)
// We only switch to a pathless item if the link type may be
// enforced. Fortunately only platforms that support link types
// seem to have magic per-architecture implicit link directories.
- if(!this->LinkTypeEnabled)
- {
+ if (!this->LinkTypeEnabled) {
return false;
- }
+ }
// Check if this item is in an implicit link directory.
std::string dir = cmSystemTools::GetFilenamePath(item);
- if(this->ImplicitLinkDirs.find(dir) == this->ImplicitLinkDirs.end())
- {
+ if (this->ImplicitLinkDirs.find(dir) == this->ImplicitLinkDirs.end()) {
// Only libraries in implicit link directories are converted to
// pathless items.
return false;
- }
+ }
// Only apply the policy below if the library file is one that can
// be found by the linker.
std::string file = cmSystemTools::GetFilenameName(item);
- if(!this->ExtractAnyLibraryName.find(file))
- {
+ if (!this->ExtractAnyLibraryName.find(file)) {
return false;
- }
+ }
// Check the policy for whether we should use the approach below.
- switch (this->Target->GetPolicyStatusCMP0060())
- {
+ switch (this->Target->GetPolicyStatusCMP0060()) {
case cmPolicies::WARN:
- if (this->CMP0060Warn)
- {
+ if (this->CMP0060Warn) {
// Print the warning at most once for this item.
std::string const& wid = "CMP0060-WARNING-GIVEN-" + item;
- if (!this->CMakeInstance->GetPropertyAsBool(wid))
- {
+ if (!this->CMakeInstance->GetPropertyAsBool(wid)) {
this->CMakeInstance->SetProperty(wid, "1");
this->CMP0060WarnItems.insert(item);
- }
}
+ }
case cmPolicies::OLD:
break;
case cmPolicies::REQUIRED_ALWAYS:
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::NEW:
return false;
- }
+ }
// Many system linkers support multiple architectures by
// automatically selecting the implicit linker search path for the
@@ -1247,17 +1129,15 @@ void cmComputeLinkInformation::AddUserItem(std::string const& item,
// libfoo.a ==> -Wl,-Bstatic -lfoo
// Pass flags through untouched.
- if(item[0] == '-' || item[0] == '$' || item[0] == '`')
- {
+ if (item[0] == '-' || item[0] == '$' || item[0] == '`') {
// if this is a -l option then we might need to warn about
// CMP0003 so put it in OldUserFlagItems, if it is not a -l
// or -Wl,-l (-framework -pthread), then allow it without a
// CMP0003 as -L will not affect those other linker flags
- if(item.find("-l") == 0 || item.find("-Wl,-l") == 0)
- {
+ if (item.find("-l") == 0 || item.find("-Wl,-l") == 0) {
// This is a linker option provided by the user.
this->OldUserFlagItems.push_back(item);
- }
+ }
// Restore the target link type since this item does not specify
// one.
@@ -1266,7 +1146,7 @@ void cmComputeLinkInformation::AddUserItem(std::string const& item,
// Use the item verbatim.
this->Items.push_back(Item(item, false));
return;
- }
+ }
// Parse out the prefix, base, and suffix components of the
// library name. If the name matches that of a shared or static
@@ -1279,9 +1159,8 @@ void cmComputeLinkInformation::AddUserItem(std::string const& item,
// libraries. On AIX a library with the name libfoo.a can be
// shared!
std::string lib;
- if(this->ExtractSharedLibraryName.find(item))
- {
- // This matches a shared library file name.
+ if (this->ExtractSharedLibraryName.find(item)) {
+// This matches a shared library file name.
#ifdef CM_COMPUTE_LINK_INFO_DEBUG
fprintf(stderr, "shared regex matched [%s] [%s] [%s]\n",
this->ExtractSharedLibraryName.match(1).c_str(),
@@ -1293,10 +1172,8 @@ void cmComputeLinkInformation::AddUserItem(std::string const& item,
// Use just the library name so the linker will search.
lib = this->ExtractSharedLibraryName.match(2);
- }
- else if(this->ExtractStaticLibraryName.find(item))
- {
- // This matches a static library file name.
+ } else if (this->ExtractStaticLibraryName.find(item)) {
+// This matches a static library file name.
#ifdef CM_COMPUTE_LINK_INFO_DEBUG
fprintf(stderr, "static regex matched [%s] [%s] [%s]\n",
this->ExtractStaticLibraryName.match(1).c_str(),
@@ -1308,10 +1185,8 @@ void cmComputeLinkInformation::AddUserItem(std::string const& item,
// Use just the library name so the linker will search.
lib = this->ExtractStaticLibraryName.match(2);
- }
- else if(this->ExtractAnyLibraryName.find(item))
- {
- // This matches a library file name.
+ } else if (this->ExtractAnyLibraryName.find(item)) {
+// This matches a library file name.
#ifdef CM_COMPUTE_LINK_INFO_DEBUG
fprintf(stderr, "any regex matched [%s] [%s] [%s]\n",
this->ExtractAnyLibraryName.match(1).c_str(),
@@ -1324,21 +1199,18 @@ void cmComputeLinkInformation::AddUserItem(std::string const& item,
// Use just the library name so the linker will search.
lib = this->ExtractAnyLibraryName.match(2);
- }
- else
- {
+ } else {
// This is a name specified by the user.
- if(pathNotKnown)
- {
+ if (pathNotKnown) {
this->OldUserFlagItems.push_back(item);
- }
+ }
// We must ask the linker to search for a library with this name.
// Restore the target link type since this item does not specify
// one.
this->SetCurrentLinkType(this->StartLinkType);
lib = item;
- }
+ }
// Create an option to ask the linker to search for the library.
std::string out = this->LibLinkFlag;
@@ -1355,14 +1227,13 @@ void cmComputeLinkInformation::AddUserItem(std::string const& item,
void cmComputeLinkInformation::AddFrameworkItem(std::string const& item)
{
// Try to separate the framework name and path.
- if(!this->SplitFramework.find(item.c_str()))
- {
+ if (!this->SplitFramework.find(item.c_str())) {
std::ostringstream e;
e << "Could not parse framework path \"" << item << "\" "
<< "linked by target " << this->Target->GetName() << ".";
cmSystemTools::Error(e.str().c_str());
return;
- }
+ }
std::string fw_path = this->SplitFramework.match(1);
std::string fw = this->SplitFramework.match(2);
@@ -1388,15 +1259,12 @@ void cmComputeLinkInformation::AddFrameworkItem(std::string const& item)
void cmComputeLinkInformation::AddDirectoryItem(std::string const& item)
{
- if(this->Makefile->IsOn("APPLE")
- && cmSystemTools::IsPathToFramework(item.c_str()))
- {
+ if (this->Makefile->IsOn("APPLE") &&
+ cmSystemTools::IsPathToFramework(item.c_str())) {
this->AddFrameworkItem(item);
- }
- else
- {
+ } else {
this->DropDirectoryItem(item);
- }
+ }
}
void cmComputeLinkInformation::DropDirectoryItem(std::string const& item)
@@ -1417,21 +1285,19 @@ void cmComputeLinkInformation::ComputeFrameworkInfo()
std::vector<std::string> implicitDirVec;
// Get platform-wide implicit directories.
- if(const char* implicitLinks = this->Makefile->GetDefinition
- ("CMAKE_PLATFORM_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES"))
- {
+ if (const char* implicitLinks = this->Makefile->GetDefinition(
+ "CMAKE_PLATFORM_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES")) {
cmSystemTools::ExpandListArgument(implicitLinks, implicitDirVec);
- }
+ }
// Get language-specific implicit directories.
std::string implicitDirVar = "CMAKE_";
implicitDirVar += this->LinkLanguage;
implicitDirVar += "_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES";
- if(const char* implicitDirs =
- this->Makefile->GetDefinition(implicitDirVar))
- {
+ if (const char* implicitDirs =
+ this->Makefile->GetDefinition(implicitDirVar)) {
cmSystemTools::ExpandListArgument(implicitDirs, implicitDirVec);
- }
+ }
this->FrameworkPathsEmmitted.insert(implicitDirVec.begin(),
implicitDirVec.end());
@@ -1442,10 +1308,9 @@ void cmComputeLinkInformation::ComputeFrameworkInfo()
void cmComputeLinkInformation::AddFrameworkPath(std::string const& p)
{
- if(this->FrameworkPathsEmmitted.insert(p).second)
- {
+ if (this->FrameworkPathsEmmitted.insert(p).second) {
this->FrameworkPaths.push_back(p);
- }
+ }
}
bool cmComputeLinkInformation::CheckSharedLibNoSOName(std::string const& item)
@@ -1454,18 +1319,16 @@ bool cmComputeLinkInformation::CheckSharedLibNoSOName(std::string const& item)
// library is given via path and was not built with an soname. If
// this is a shared library that might be the case.
std::string file = cmSystemTools::GetFilenameName(item);
- if(this->ExtractSharedLibraryName.find(file))
- {
+ if (this->ExtractSharedLibraryName.find(file)) {
// If we can guess the soname fairly reliably then assume the
// library has one. Otherwise assume the library has no builtin
// soname.
std::string soname;
- if(!cmSystemTools::GuessLibrarySOName(item, soname))
- {
+ if (!cmSystemTools::GuessLibrarySOName(item, soname)) {
this->AddSharedLibNoSOName(item);
return true;
- }
}
+ }
return false;
}
@@ -1489,10 +1352,9 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item,
// Do not depend on things that do not exist.
std::vector<std::string>::iterator i =
std::find(this->Depends.begin(), this->Depends.end(), item);
- if(i != this->Depends.end())
- {
+ if (i != this->Depends.end()) {
this->Depends.erase(i);
- }
+ }
// Tell the linker to search for the item and provide the proper
// path for it. Do not contribute to any CMP0003 warning (do not
@@ -1501,16 +1363,12 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item,
this->OrderLinkerSearchPath->AddLinkLibrary(item);
// Produce any needed message.
- switch(this->Target->GetPolicyStatusCMP0008())
- {
- case cmPolicies::WARN:
- {
+ switch (this->Target->GetPolicyStatusCMP0008()) {
+ case cmPolicies::WARN: {
// Print the warning at most once for this item.
std::string wid = "CMP0008-WARNING-GIVEN-";
wid += item;
- if(!this->CMakeInstance->GetState()
- ->GetGlobalPropertyAsBool(wid))
- {
+ if (!this->CMakeInstance->GetState()->GetGlobalPropertyAsBool(wid)) {
this->CMakeInstance->GetState()->SetGlobalProperty(wid, "1");
std::ostringstream w;
/* clang-format off */
@@ -1520,9 +1378,9 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item,
<< "which is a full-path but not a valid library file name.";
/* clang-format on */
this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(),
- this->Target->GetBacktrace());
- }
+ this->Target->GetBacktrace());
}
+ }
case cmPolicies::OLD:
// OLD behavior does not warn.
break;
@@ -1530,8 +1388,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item,
// NEW behavior will not get here.
break;
case cmPolicies::REQUIRED_IF_USED:
- case cmPolicies::REQUIRED_ALWAYS:
- {
+ case cmPolicies::REQUIRED_ALWAYS: {
std::ostringstream e;
/* clang-format off */
e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0008) << "\n"
@@ -1541,34 +1398,30 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item,
/* clang-format on */
this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(),
this->Target->GetBacktrace());
- }
- break;
- }
+ } break;
+ }
}
bool cmComputeLinkInformation::FinishLinkerSearchDirectories()
{
// Support broken projects if necessary.
- if(this->OldLinkDirItems.empty() || this->OldUserFlagItems.empty() ||
- !this->OldLinkDirMode)
- {
+ if (this->OldLinkDirItems.empty() || this->OldUserFlagItems.empty() ||
+ !this->OldLinkDirMode) {
return true;
- }
+ }
// Enforce policy constraints.
- switch(this->Target->GetPolicyStatusCMP0003())
- {
+ switch (this->Target->GetPolicyStatusCMP0003()) {
case cmPolicies::WARN:
- if(!this->CMakeInstance->GetState()
- ->GetGlobalPropertyAsBool("CMP0003-WARNING-GIVEN"))
- {
- this->CMakeInstance->GetState()
- ->SetGlobalProperty("CMP0003-WARNING-GIVEN", "1");
+ if (!this->CMakeInstance->GetState()->GetGlobalPropertyAsBool(
+ "CMP0003-WARNING-GIVEN")) {
+ this->CMakeInstance->GetState()->SetGlobalProperty(
+ "CMP0003-WARNING-GIVEN", "1");
std::ostringstream w;
this->PrintLinkPolicyDiagnosis(w);
this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(),
- this->Target->GetBacktrace());
- }
+ this->Target->GetBacktrace());
+ }
case cmPolicies::OLD:
// OLD behavior is to add the paths containing libraries with
// known full paths as link directories.
@@ -1577,24 +1430,22 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories()
// Should never happen due to assignment of OldLinkDirMode
return true;
case cmPolicies::REQUIRED_IF_USED:
- case cmPolicies::REQUIRED_ALWAYS:
- {
+ case cmPolicies::REQUIRED_ALWAYS: {
std::ostringstream e;
e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0003) << "\n";
this->PrintLinkPolicyDiagnosis(e);
this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(),
this->Target->GetBacktrace());
return false;
- }
}
+ }
// Add the link directories for full path items.
- for(std::vector<std::string>::const_iterator
- i = this->OldLinkDirItems.begin();
- i != this->OldLinkDirItems.end(); ++i)
- {
+ for (std::vector<std::string>::const_iterator i =
+ this->OldLinkDirItems.begin();
+ i != this->OldLinkDirItems.end(); ++i) {
this->OrderLinkerSearchPath->AddLinkLibrary(*i);
- }
+ }
return true;
}
@@ -1612,52 +1463,47 @@ void cmComputeLinkInformation::PrintLinkPolicyDiagnosis(std::ostream& os)
/* clang-format on */
// List the items that might need the old-style paths.
- os << "This warning appears because target \""
- << this->Target->GetName() << "\" "
+ os << "This warning appears because target \"" << this->Target->GetName()
+ << "\" "
<< "links to some libraries for which the linker must search:\n";
{
- // Format the list of unknown items to be as short as possible while
- // still fitting in the allowed width (a true solution would be the
- // bin packing problem if we were allowed to change the order).
- std::string::size_type max_size = 76;
- std::string line;
- const char* sep = " ";
- for(std::vector<std::string>::const_iterator
- i = this->OldUserFlagItems.begin();
- i != this->OldUserFlagItems.end(); ++i)
- {
- // If the addition of another item will exceed the limit then
- // output the current line and reset it. Note that the separator
- // is either " " or ", " which is always 2 characters.
- if(!line.empty() && (line.size() + i->size() + 2) > max_size)
- {
- os << line << "\n";
- sep = " ";
- line = "";
+ // Format the list of unknown items to be as short as possible while
+ // still fitting in the allowed width (a true solution would be the
+ // bin packing problem if we were allowed to change the order).
+ std::string::size_type max_size = 76;
+ std::string line;
+ const char* sep = " ";
+ for (std::vector<std::string>::const_iterator i =
+ this->OldUserFlagItems.begin();
+ i != this->OldUserFlagItems.end(); ++i) {
+ // If the addition of another item will exceed the limit then
+ // output the current line and reset it. Note that the separator
+ // is either " " or ", " which is always 2 characters.
+ if (!line.empty() && (line.size() + i->size() + 2) > max_size) {
+ os << line << "\n";
+ sep = " ";
+ line = "";
}
- line += sep;
- line += *i;
- // Convert to the other separator.
- sep = ", ";
+ line += sep;
+ line += *i;
+ // Convert to the other separator.
+ sep = ", ";
}
- if(!line.empty())
- {
- os << line << "\n";
+ if (!line.empty()) {
+ os << line << "\n";
}
}
// List the paths old behavior is adding.
os << "and other libraries with known full path:\n";
std::set<std::string> emitted;
- for(std::vector<std::string>::const_iterator
- i = this->OldLinkDirItems.begin();
- i != this->OldLinkDirItems.end(); ++i)
- {
- if(emitted.insert(cmSystemTools::GetFilenamePath(*i)).second)
- {
+ for (std::vector<std::string>::const_iterator i =
+ this->OldLinkDirItems.begin();
+ i != this->OldLinkDirItems.end(); ++i) {
+ if (emitted.insert(cmSystemTools::GetFilenamePath(*i)).second) {
os << " " << *i << "\n";
- }
}
+ }
// Explain.
os << "CMake is adding directories in the second list to the linker "
@@ -1673,34 +1519,29 @@ void cmComputeLinkInformation::LoadImplicitLinkInfo()
std::vector<std::string> implicitDirVec;
// Get platform-wide implicit directories.
- if(const char* implicitLinks =
- (this->Makefile->GetDefinition
- ("CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES")))
- {
+ if (const char* implicitLinks = (this->Makefile->GetDefinition(
+ "CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES"))) {
cmSystemTools::ExpandListArgument(implicitLinks, implicitDirVec);
- }
+ }
// Append library architecture to all implicit platform directories
// and add them to the set
- if(const char* libraryArch =
- this->Makefile->GetDefinition("CMAKE_LIBRARY_ARCHITECTURE"))
- {
+ if (const char* libraryArch =
+ this->Makefile->GetDefinition("CMAKE_LIBRARY_ARCHITECTURE")) {
for (std::vector<std::string>::const_iterator i = implicitDirVec.begin();
- i != implicitDirVec.end(); ++i)
- {
+ i != implicitDirVec.end(); ++i) {
this->ImplicitLinkDirs.insert(*i + "/" + libraryArch);
- }
}
+ }
// Get language-specific implicit directories.
std::string implicitDirVar = "CMAKE_";
implicitDirVar += this->LinkLanguage;
implicitDirVar += "_IMPLICIT_LINK_DIRECTORIES";
- if(const char* implicitDirs =
- this->Makefile->GetDefinition(implicitDirVar))
- {
+ if (const char* implicitDirs =
+ this->Makefile->GetDefinition(implicitDirVar)) {
cmSystemTools::ExpandListArgument(implicitDirs, implicitDirVec);
- }
+ }
// Store implicit link directories.
this->ImplicitLinkDirs.insert(implicitDirVec.begin(), implicitDirVec.end());
@@ -1710,32 +1551,27 @@ void cmComputeLinkInformation::LoadImplicitLinkInfo()
std::string implicitLibVar = "CMAKE_";
implicitLibVar += this->LinkLanguage;
implicitLibVar += "_IMPLICIT_LINK_LIBRARIES";
- if(const char* implicitLibs =
- this->Makefile->GetDefinition(implicitLibVar))
- {
+ if (const char* implicitLibs =
+ this->Makefile->GetDefinition(implicitLibVar)) {
cmSystemTools::ExpandListArgument(implicitLibs, implicitLibVec);
- }
+ }
// Store implicit link libraries.
- for(std::vector<std::string>::const_iterator i = implicitLibVec.begin();
- i != implicitLibVec.end(); ++i)
- {
+ for (std::vector<std::string>::const_iterator i = implicitLibVec.begin();
+ i != implicitLibVec.end(); ++i) {
// Items starting in '-' but not '-l' are flags, not libraries,
// and should not be filtered by this implicit list.
std::string const& item = *i;
- if(item[0] != '-' || item[1] == 'l')
- {
+ if (item[0] != '-' || item[1] == 'l') {
this->ImplicitLinkLibs.insert(item);
- }
}
+ }
// Get platform specific rpath link directories
- if(const char *rpathDirs =
- (this->Makefile->GetDefinition
- ("CMAKE_PLATFORM_RUNTIME_PATH")))
- {
+ if (const char* rpathDirs =
+ (this->Makefile->GetDefinition("CMAKE_PLATFORM_RUNTIME_PATH"))) {
cmSystemTools::ExpandListArgument(rpathDirs, this->RuntimeLinkDirs);
- }
+ }
}
std::vector<std::string> const&
@@ -1744,113 +1580,96 @@ cmComputeLinkInformation::GetRuntimeSearchPath()
return this->OrderRuntimeSearchPath->GetOrderedDirectories();
}
-void
-cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath,
- cmGeneratorTarget const* target)
+void cmComputeLinkInformation::AddLibraryRuntimeInfo(
+ std::string const& fullPath, cmGeneratorTarget const* target)
{
// Ignore targets on Apple where install_name is not @rpath.
// The dependenty library can be found with other means such as
// @loader_path or full paths.
- if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
- {
- if(!target->HasMacOSXRpathInstallNameDir(this->Config))
- {
+ if (this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) {
+ if (!target->HasMacOSXRpathInstallNameDir(this->Config)) {
return;
- }
}
+ }
// Libraries with unknown type must be handled using just the file
// on disk.
- if(target->GetType() == cmState::UNKNOWN_LIBRARY)
- {
+ if (target->GetType() == cmState::UNKNOWN_LIBRARY) {
this->AddLibraryRuntimeInfo(fullPath);
return;
- }
+ }
// Skip targets that are not shared libraries (modules cannot be linked).
- if(target->GetType() != cmState::SHARED_LIBRARY)
- {
+ if (target->GetType() != cmState::SHARED_LIBRARY) {
return;
- }
+ }
// Try to get the soname of the library. Only files with this name
// could possibly conflict.
std::string soName = target->GetSOName(this->Config);
- const char* soname = soName.empty()? 0 : soName.c_str();
+ const char* soname = soName.empty() ? 0 : soName.c_str();
// Include this library in the runtime path ordering.
this->OrderRuntimeSearchPath->AddRuntimeLibrary(fullPath, soname);
- if(this->LinkWithRuntimePath)
- {
+ if (this->LinkWithRuntimePath) {
this->OrderLinkerSearchPath->AddRuntimeLibrary(fullPath, soname);
- }
+ }
}
-void
-cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath)
+void cmComputeLinkInformation::AddLibraryRuntimeInfo(
+ std::string const& fullPath)
{
// Get the name of the library from the file name.
bool is_shared_library = false;
std::string file = cmSystemTools::GetFilenameName(fullPath);
- if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
- {
+ if (this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) {
// Check that @rpath is part of the install name.
// If it isn't, return.
std::string soname;
- if(!cmSystemTools::GuessLibraryInstallName(fullPath, soname))
- {
+ if (!cmSystemTools::GuessLibraryInstallName(fullPath, soname)) {
return;
- }
+ }
- if(soname.find("@rpath") == std::string::npos)
- {
+ if (soname.find("@rpath") == std::string::npos) {
return;
- }
}
+ }
is_shared_library = this->ExtractSharedLibraryName.find(file);
- if(!is_shared_library)
- {
+ if (!is_shared_library) {
// On some platforms (AIX) a shared library may look static.
- if(this->ArchivesMayBeShared)
- {
- if(this->ExtractStaticLibraryName.find(file.c_str()))
- {
+ if (this->ArchivesMayBeShared) {
+ if (this->ExtractStaticLibraryName.find(file.c_str())) {
// This is the name of a shared library or archive.
is_shared_library = true;
- }
}
}
+ }
// It could be an Apple framework
- if(!is_shared_library)
- {
- if(fullPath.find(".framework") != std::string::npos)
- {
- static cmsys::RegularExpression
- splitFramework("^(.*)/(.*).framework/(.*)$");
- if(splitFramework.find(fullPath) &&
- (std::string::npos !=
- splitFramework.match(3).find(splitFramework.match(2))))
- {
+ if (!is_shared_library) {
+ if (fullPath.find(".framework") != std::string::npos) {
+ static cmsys::RegularExpression splitFramework(
+ "^(.*)/(.*).framework/(.*)$");
+ if (splitFramework.find(fullPath) &&
+ (std::string::npos !=
+ splitFramework.match(3).find(splitFramework.match(2)))) {
is_shared_library = true;
- }
}
}
+ }
- if(!is_shared_library)
- {
+ if (!is_shared_library) {
return;
- }
+ }
// Include this library in the runtime path ordering.
this->OrderRuntimeSearchPath->AddRuntimeLibrary(fullPath);
- if(this->LinkWithRuntimePath)
- {
+ if (this->LinkWithRuntimePath) {
this->OrderLinkerSearchPath->AddRuntimeLibrary(fullPath);
- }
+ }
}
static void cmCLI_ExpandListUnique(const char* str,
@@ -1859,13 +1678,12 @@ static void cmCLI_ExpandListUnique(const char* str,
{
std::vector<std::string> tmp;
cmSystemTools::ExpandListArgument(str, tmp);
- for(std::vector<std::string>::iterator i = tmp.begin(); i != tmp.end(); ++i)
- {
- if(emitted.insert(*i).second)
- {
+ for (std::vector<std::string>::iterator i = tmp.begin(); i != tmp.end();
+ ++i) {
+ if (emitted.insert(*i).second) {
out.push_back(*i);
- }
}
+ }
}
void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs,
@@ -1886,103 +1704,82 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs,
bool use_build_rpath =
(outputRuntime && this->Target->HaveBuildTreeRPATH(this->Config) &&
!linking_for_install);
- bool use_link_rpath =
- outputRuntime && linking_for_install &&
+ bool use_link_rpath = outputRuntime && linking_for_install &&
!this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH") &&
this->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH");
// Construct the RPATH.
std::set<std::string> emitted;
- if(use_install_rpath)
- {
- const char* install_rpath =
- this->Target->GetProperty("INSTALL_RPATH");
+ if (use_install_rpath) {
+ const char* install_rpath = this->Target->GetProperty("INSTALL_RPATH");
cmCLI_ExpandListUnique(install_rpath, runtimeDirs, emitted);
- }
- if(use_build_rpath || use_link_rpath)
- {
+ }
+ if (use_build_rpath || use_link_rpath) {
std::string rootPath = this->Makefile->GetSafeDefinition("CMAKE_SYSROOT");
- const char *stagePath
- = this->Makefile->GetDefinition("CMAKE_STAGING_PREFIX");
- const char *installPrefix
- = this->Makefile->GetSafeDefinition("CMAKE_INSTALL_PREFIX");
+ const char* stagePath =
+ this->Makefile->GetDefinition("CMAKE_STAGING_PREFIX");
+ const char* installPrefix =
+ this->Makefile->GetSafeDefinition("CMAKE_INSTALL_PREFIX");
cmSystemTools::ConvertToUnixSlashes(rootPath);
std::vector<std::string> const& rdirs = this->GetRuntimeSearchPath();
- for(std::vector<std::string>::const_iterator ri = rdirs.begin();
- ri != rdirs.end(); ++ri)
- {
+ for (std::vector<std::string>::const_iterator ri = rdirs.begin();
+ ri != rdirs.end(); ++ri) {
// Put this directory in the rpath if using build-tree rpath
// support or if using the link path as an rpath.
- if(use_build_rpath)
- {
+ if (use_build_rpath) {
std::string d = *ri;
- if (!rootPath.empty() && d.find(rootPath) == 0)
- {
+ if (!rootPath.empty() && d.find(rootPath) == 0) {
d = d.substr(rootPath.size());
- }
- else if (stagePath && *stagePath && d.find(stagePath) == 0)
- {
+ } else if (stagePath && *stagePath && d.find(stagePath) == 0) {
std::string suffix = d.substr(strlen(stagePath));
d = installPrefix;
d += "/";
d += suffix;
cmSystemTools::ConvertToUnixSlashes(d);
- }
- if(emitted.insert(d).second)
- {
+ }
+ if (emitted.insert(d).second) {
runtimeDirs.push_back(d);
- }
}
- else if(use_link_rpath)
- {
+ } else if (use_link_rpath) {
// Do not add any path inside the source or build tree.
const char* topSourceDir = this->CMakeInstance->GetHomeDirectory();
const char* topBinaryDir =
- this->CMakeInstance->GetHomeOutputDirectory();
- if(!cmSystemTools::ComparePath(*ri, topSourceDir) &&
- !cmSystemTools::ComparePath(*ri, topBinaryDir) &&
- !cmSystemTools::IsSubDirectory(*ri, topSourceDir) &&
- !cmSystemTools::IsSubDirectory(*ri, topBinaryDir))
- {
+ this->CMakeInstance->GetHomeOutputDirectory();
+ if (!cmSystemTools::ComparePath(*ri, topSourceDir) &&
+ !cmSystemTools::ComparePath(*ri, topBinaryDir) &&
+ !cmSystemTools::IsSubDirectory(*ri, topSourceDir) &&
+ !cmSystemTools::IsSubDirectory(*ri, topBinaryDir)) {
std::string d = *ri;
- if (!rootPath.empty() && d.find(rootPath) == 0)
- {
+ if (!rootPath.empty() && d.find(rootPath) == 0) {
d = d.substr(rootPath.size());
- }
- else if (stagePath && *stagePath && d.find(stagePath) == 0)
- {
+ } else if (stagePath && *stagePath && d.find(stagePath) == 0) {
std::string suffix = d.substr(strlen(stagePath));
d = installPrefix;
d += "/";
d += suffix;
cmSystemTools::ConvertToUnixSlashes(d);
- }
- if(emitted.insert(d).second)
- {
+ }
+ if (emitted.insert(d).second) {
runtimeDirs.push_back(d);
- }
}
}
}
}
+ }
// Add runtime paths required by the languages to always be
// present. This is done even when skipping rpath support.
{
- cmGeneratorTarget::LinkClosure const* lc =
- this->Target->GetLinkClosure(this->Config);
- for(std::vector<std::string>::const_iterator li = lc->Languages.begin();
- li != lc->Languages.end(); ++li)
- {
- std::string useVar = "CMAKE_" + *li +
- "_USE_IMPLICIT_LINK_DIRECTORIES_IN_RUNTIME_PATH";
- if(this->Makefile->IsOn(useVar))
- {
- std::string dirVar = "CMAKE_" + *li +
- "_IMPLICIT_LINK_DIRECTORIES";
- if(const char* dirs = this->Makefile->GetDefinition(dirVar))
- {
- cmCLI_ExpandListUnique(dirs, runtimeDirs, emitted);
+ cmGeneratorTarget::LinkClosure const* lc =
+ this->Target->GetLinkClosure(this->Config);
+ for (std::vector<std::string>::const_iterator li = lc->Languages.begin();
+ li != lc->Languages.end(); ++li) {
+ std::string useVar =
+ "CMAKE_" + *li + "_USE_IMPLICIT_LINK_DIRECTORIES_IN_RUNTIME_PATH";
+ if (this->Makefile->IsOn(useVar)) {
+ std::string dirVar = "CMAKE_" + *li + "_IMPLICIT_LINK_DIRECTORIES";
+ if (const char* dirs = this->Makefile->GetDefinition(dirVar)) {
+ cmCLI_ExpandListUnique(dirs, runtimeDirs, emitted);
}
}
}
@@ -2003,33 +1800,29 @@ std::string cmComputeLinkInformation::GetRPathString(bool for_install)
std::string rpath = cmJoin(runtimeDirs, this->GetRuntimeSep());
// If the rpath will be replaced at install time, prepare space.
- if(!for_install && this->RuntimeUseChrpath)
- {
- if(!rpath.empty())
- {
+ if (!for_install && this->RuntimeUseChrpath) {
+ if (!rpath.empty()) {
// Add one trailing separator so the linker does not re-use the
// rpath .dynstr entry for a symbol name that happens to match
// the end of the rpath string.
rpath += this->GetRuntimeSep();
- }
+ }
// Make sure it is long enough to hold the replacement value.
std::string::size_type minLength = this->GetChrpathString().length();
- while(rpath.length() < minLength)
- {
+ while (rpath.length() < minLength) {
rpath += this->GetRuntimeSep();
- }
}
+ }
return rpath;
}
std::string cmComputeLinkInformation::GetChrpathString()
{
- if(!this->RuntimeUseChrpath)
- {
+ if (!this->RuntimeUseChrpath) {
return "";
- }
+ }
return this->GetRPathString(true);
}
diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h
index 5eecf7d..c0ddc53 100644
--- a/Source/cmComputeLinkInformation.h
+++ b/Source/cmComputeLinkInformation.h
@@ -35,11 +35,24 @@ public:
struct Item
{
- Item(): Value(), IsPath(true), Target(0) {}
- Item(Item const& item):
- Value(item.Value), IsPath(item.IsPath), Target(item.Target) {}
- Item(std::string const& v, bool p, cmGeneratorTarget const* target = 0):
- Value(v), IsPath(p), Target(target) {}
+ Item()
+ : Value()
+ , IsPath(true)
+ , Target(0)
+ {
+ }
+ Item(Item const& item)
+ : Value(item.Value)
+ , IsPath(item.IsPath)
+ , Target(item.Target)
+ {
+ }
+ Item(std::string const& v, bool p, cmGeneratorTarget const* target = 0)
+ : Value(v)
+ , IsPath(p)
+ , Target(target)
+ {
+ }
std::string Value;
bool IsPath;
cmGeneratorTarget const* Target;
@@ -60,6 +73,7 @@ public:
std::string const& GetRPathLinkFlag() const { return this->RPathLinkFlag; }
std::string GetRPathLinkString();
+
private:
void AddItem(std::string const& item, const cmGeneratorTarget* tgt);
void AddSharedDepItem(std::string const& item, cmGeneratorTarget const* tgt);
@@ -101,7 +115,12 @@ private:
std::string RPathLinkFlag;
SharedDepMode SharedDependencyMode;
- enum LinkType { LinkUnknown, LinkStatic, LinkShared };
+ enum LinkType
+ {
+ LinkUnknown,
+ LinkStatic,
+ LinkShared
+ };
void SetCurrentLinkType(LinkType lt);
// Link type adjustment.
@@ -184,7 +203,6 @@ private:
void AddLibraryRuntimeInfo(std::string const& fullPath,
const cmGeneratorTarget* target);
void AddLibraryRuntimeInfo(std::string const& fullPath);
-
};
#endif
diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx
index 1b5297f..570405a 100644
--- a/Source/cmComputeTargetDepends.cxx
+++ b/Source/cmComputeTargetDepends.cxx
@@ -98,10 +98,10 @@ cmComputeTargetDepends::cmComputeTargetDepends(cmGlobalGenerator* gg)
{
this->GlobalGenerator = gg;
cmake* cm = this->GlobalGenerator->GetCMakeInstance();
- this->DebugMode = cm->GetState()
- ->GetGlobalPropertyAsBool("GLOBAL_DEPENDS_DEBUG_MODE");
- this->NoCycles = cm->GetState()
- ->GetGlobalPropertyAsBool("GLOBAL_DEPENDS_NO_CYCLES");
+ this->DebugMode =
+ cm->GetState()->GetGlobalPropertyAsBool("GLOBAL_DEPENDS_DEBUG_MODE");
+ this->NoCycles =
+ cm->GetState()->GetGlobalPropertyAsBool("GLOBAL_DEPENDS_NO_CYCLES");
}
cmComputeTargetDepends::~cmComputeTargetDepends()
@@ -113,54 +113,47 @@ bool cmComputeTargetDepends::Compute()
// Build the original graph.
this->CollectTargets();
this->CollectDepends();
- if(this->DebugMode)
- {
+ if (this->DebugMode) {
this->DisplayGraph(this->InitialGraph, "initial");
- }
+ }
// Identify components.
cmComputeComponentGraph ccg(this->InitialGraph);
- if(this->DebugMode)
- {
+ if (this->DebugMode) {
this->DisplayComponents(ccg);
- }
- if(!this->CheckComponents(ccg))
- {
+ }
+ if (!this->CheckComponents(ccg)) {
return false;
- }
+ }
// Compute the final dependency graph.
- if(!this->ComputeFinalDepends(ccg))
- {
+ if (!this->ComputeFinalDepends(ccg)) {
return false;
- }
- if(this->DebugMode)
- {
+ }
+ if (this->DebugMode) {
this->DisplayGraph(this->FinalGraph, "final");
- }
+ }
return true;
}
-void
-cmComputeTargetDepends::GetTargetDirectDepends(cmGeneratorTarget const* t,
- cmTargetDependSet& deps)
+void cmComputeTargetDepends::GetTargetDirectDepends(cmGeneratorTarget const* t,
+ cmTargetDependSet& deps)
{
// Lookup the index for this target. All targets should be known by
// this point.
- std::map<cmGeneratorTarget const*, int>::const_iterator tii
- = this->TargetIndex.find(t);
+ std::map<cmGeneratorTarget const*, int>::const_iterator tii =
+ this->TargetIndex.find(t);
assert(tii != this->TargetIndex.end());
int i = tii->second;
// Get its final dependencies.
EdgeList const& nl = this->FinalGraph[i];
- for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni)
- {
+ for (EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) {
cmGeneratorTarget const* dep = this->Targets[*ni];
cmTargetDependSet::iterator di = deps.insert(dep).first;
di->SetType(ni->IsStrong());
- }
+ }
}
void cmComputeTargetDepends::CollectTargets()
@@ -168,19 +161,17 @@ void cmComputeTargetDepends::CollectTargets()
// Collect all targets from all generators.
std::vector<cmLocalGenerator*> const& lgens =
this->GlobalGenerator->GetLocalGenerators();
- for(unsigned int i = 0; i < lgens.size(); ++i)
- {
+ for (unsigned int i = 0; i < lgens.size(); ++i) {
const std::vector<cmGeneratorTarget*> targets =
- lgens[i]->GetGeneratorTargets();
- for(std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin();
- ti != targets.end(); ++ti)
- {
+ lgens[i]->GetGeneratorTargets();
+ for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin();
+ ti != targets.end(); ++ti) {
cmGeneratorTarget* gt = *ti;
int index = static_cast<int>(this->Targets.size());
this->TargetIndex[gt] = index;
this->Targets.push_back(gt);
- }
}
+ }
}
void cmComputeTargetDepends::CollectDepends()
@@ -189,74 +180,66 @@ void cmComputeTargetDepends::CollectDepends()
this->InitialGraph.resize(this->Targets.size());
// Compute each dependency list.
- for(unsigned int i=0; i < this->Targets.size(); ++i)
- {
+ for (unsigned int i = 0; i < this->Targets.size(); ++i) {
this->CollectTargetDepends(i);
- }
+ }
}
void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
{
// Get the depender.
cmGeneratorTarget const* depender = this->Targets[depender_index];
- if (depender->GetType() == cmState::INTERFACE_LIBRARY)
- {
+ if (depender->GetType() == cmState::INTERFACE_LIBRARY) {
return;
- }
+ }
// Loop over all targets linked directly in all configs.
// We need to make targets depend on the union of all config-specific
// dependencies in all targets, because the generated build-systems can't
// deal with config-specific dependencies.
{
- std::set<std::string> emitted;
+ std::set<std::string> emitted;
- std::vector<std::string> configs;
- depender->Makefile->GetConfigurations(configs);
- if (configs.empty())
- {
- configs.push_back("");
+ std::vector<std::string> configs;
+ depender->Makefile->GetConfigurations(configs);
+ if (configs.empty()) {
+ configs.push_back("");
}
- for (std::vector<std::string>::const_iterator it = configs.begin();
- it != configs.end(); ++it)
- {
- std::vector<cmSourceFile const*> objectFiles;
- depender->GetExternalObjects(objectFiles, *it);
- for(std::vector<cmSourceFile const*>::const_iterator
- oi = objectFiles.begin(); oi != objectFiles.end(); ++oi)
- {
- std::string objLib = (*oi)->GetObjectLibrary();
- if (!objLib.empty() && emitted.insert(objLib).second)
- {
- if(depender->GetType() != cmState::EXECUTABLE &&
- depender->GetType() != cmState::STATIC_LIBRARY &&
- depender->GetType() != cmState::SHARED_LIBRARY &&
- depender->GetType() != cmState::MODULE_LIBRARY)
- {
- this->GlobalGenerator->GetCMakeInstance()
- ->IssueMessage(cmake::FATAL_ERROR,
- "Only executables and non-OBJECT libraries may "
- "reference target objects.",
- depender->GetBacktrace());
- return;
+ for (std::vector<std::string>::const_iterator it = configs.begin();
+ it != configs.end(); ++it) {
+ std::vector<cmSourceFile const*> objectFiles;
+ depender->GetExternalObjects(objectFiles, *it);
+ for (std::vector<cmSourceFile const*>::const_iterator oi =
+ objectFiles.begin();
+ oi != objectFiles.end(); ++oi) {
+ std::string objLib = (*oi)->GetObjectLibrary();
+ if (!objLib.empty() && emitted.insert(objLib).second) {
+ if (depender->GetType() != cmState::EXECUTABLE &&
+ depender->GetType() != cmState::STATIC_LIBRARY &&
+ depender->GetType() != cmState::SHARED_LIBRARY &&
+ depender->GetType() != cmState::MODULE_LIBRARY) {
+ this->GlobalGenerator->GetCMakeInstance()->IssueMessage(
+ cmake::FATAL_ERROR,
+ "Only executables and non-OBJECT libraries may "
+ "reference target objects.",
+ depender->GetBacktrace());
+ return;
}
- const_cast<cmGeneratorTarget*>(depender)->Target->AddUtility(objLib);
+ const_cast<cmGeneratorTarget*>(depender)->Target->AddUtility(objLib);
}
}
- cmLinkImplementation const* impl = depender->GetLinkImplementation(*it);
+ cmLinkImplementation const* impl = depender->GetLinkImplementation(*it);
- // A target should not depend on itself.
- emitted.insert(depender->GetName());
- for(std::vector<cmLinkImplItem>::const_iterator
- lib = impl->Libraries.begin();
- lib != impl->Libraries.end(); ++lib)
- {
- // Don't emit the same library twice for this target.
- if(emitted.insert(*lib).second)
- {
- this->AddTargetDepend(depender_index, *lib, true);
- this->AddInterfaceDepends(depender_index, *lib, emitted);
+ // A target should not depend on itself.
+ emitted.insert(depender->GetName());
+ for (std::vector<cmLinkImplItem>::const_iterator lib =
+ impl->Libraries.begin();
+ lib != impl->Libraries.end(); ++lib) {
+ // Don't emit the same library twice for this target.
+ if (emitted.insert(*lib).second) {
+ this->AddTargetDepend(depender_index, *lib, true);
+ this->AddInterfaceDepends(depender_index, *lib, emitted);
}
}
}
@@ -264,80 +247,69 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
// Loop over all utility dependencies.
{
- std::set<cmLinkItem> const& tutils = depender->GetUtilityItems();
- std::set<std::string> emitted;
- // A target should not depend on itself.
- emitted.insert(depender->GetName());
- for(std::set<cmLinkItem>::const_iterator util = tutils.begin();
- util != tutils.end(); ++util)
- {
- // Don't emit the same utility twice for this target.
- if(emitted.insert(*util).second)
- {
- this->AddTargetDepend(depender_index, *util, false);
+ std::set<cmLinkItem> const& tutils = depender->GetUtilityItems();
+ std::set<std::string> emitted;
+ // A target should not depend on itself.
+ emitted.insert(depender->GetName());
+ for (std::set<cmLinkItem>::const_iterator util = tutils.begin();
+ util != tutils.end(); ++util) {
+ // Don't emit the same utility twice for this target.
+ if (emitted.insert(*util).second) {
+ this->AddTargetDepend(depender_index, *util, false);
}
}
}
}
-void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
- const cmGeneratorTarget* dependee,
- const std::string& config,
- std::set<std::string> &emitted)
+void cmComputeTargetDepends::AddInterfaceDepends(
+ int depender_index, const cmGeneratorTarget* dependee,
+ const std::string& config, std::set<std::string>& emitted)
{
cmGeneratorTarget const* depender = this->Targets[depender_index];
- if(cmLinkInterface const* iface =
- dependee->GetLinkInterface(config,
- depender))
- {
- for(std::vector<cmLinkItem>::const_iterator
- lib = iface->Libraries.begin();
- lib != iface->Libraries.end(); ++lib)
- {
+ if (cmLinkInterface const* iface =
+ dependee->GetLinkInterface(config, depender)) {
+ for (std::vector<cmLinkItem>::const_iterator lib =
+ iface->Libraries.begin();
+ lib != iface->Libraries.end(); ++lib) {
// Don't emit the same library twice for this target.
- if(emitted.insert(*lib).second)
- {
+ if (emitted.insert(*lib).second) {
this->AddTargetDepend(depender_index, *lib, true);
this->AddInterfaceDepends(depender_index, *lib, emitted);
- }
}
}
+ }
}
-void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
- cmLinkItem const& dependee_name,
- std::set<std::string> &emitted)
+void cmComputeTargetDepends::AddInterfaceDepends(
+ int depender_index, cmLinkItem const& dependee_name,
+ std::set<std::string>& emitted)
{
cmGeneratorTarget const* depender = this->Targets[depender_index];
cmGeneratorTarget const* dependee = dependee_name.Target;
// Skip targets that will not really be linked. This is probably a
// name conflict between an external library and an executable
// within the project.
- if(dependee &&
- dependee->GetType() == cmState::EXECUTABLE &&
- !dependee->IsExecutableWithExports())
- {
+ if (dependee && dependee->GetType() == cmState::EXECUTABLE &&
+ !dependee->IsExecutableWithExports()) {
dependee = 0;
- }
+ }
- if(dependee)
- {
+ if (dependee) {
this->AddInterfaceDepends(depender_index, dependee, "", emitted);
std::vector<std::string> configs;
depender->Makefile->GetConfigurations(configs);
for (std::vector<std::string>::const_iterator it = configs.begin();
- it != configs.end(); ++it)
- {
+ it != configs.end(); ++it) {
// A target should not depend on itself.
emitted.insert(depender->GetName());
this->AddInterfaceDepends(depender_index, dependee, *it, emitted);
- }
}
+ }
}
-void cmComputeTargetDepends::AddTargetDepend(
- int depender_index, cmLinkItem const& dependee_name,
- bool linking)
+void cmComputeTargetDepends::AddTargetDepend(int depender_index,
+ cmLinkItem const& dependee_name,
+ bool linking)
{
// Get the depender.
cmGeneratorTarget const* depender = this->Targets[depender_index];
@@ -345,14 +317,12 @@ void cmComputeTargetDepends::AddTargetDepend(
// Check the target's makefile first.
cmGeneratorTarget const* dependee = dependee_name.Target;
- if(!dependee && !linking &&
- (depender->GetType() != cmState::GLOBAL_TARGET))
- {
+ if (!dependee && !linking &&
+ (depender->GetType() != cmState::GLOBAL_TARGET)) {
cmake::MessageType messageType = cmake::AUTHOR_WARNING;
bool issueMessage = false;
std::ostringstream e;
- switch(depender->GetPolicyStatusCMP0046())
- {
+ switch (depender->GetPolicyStatusCMP0046()) {
case cmPolicies::WARN:
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0046) << "\n";
issueMessage = true;
@@ -363,65 +333,52 @@ void cmComputeTargetDepends::AddTargetDepend(
case cmPolicies::REQUIRED_ALWAYS:
issueMessage = true;
messageType = cmake::FATAL_ERROR;
- }
- if(issueMessage)
- {
+ }
+ if (issueMessage) {
cmake* cm = this->GlobalGenerator->GetCMakeInstance();
- e << "The dependency target \"" << dependee_name
- << "\" of target \"" << depender->GetName() << "\" does not exist.";
+ e << "The dependency target \"" << dependee_name << "\" of target \""
+ << depender->GetName() << "\" does not exist.";
cmListFileBacktrace const* backtrace =
depender->GetUtilityBacktrace(dependee_name);
- if(backtrace)
- {
+ if (backtrace) {
cm->IssueMessage(messageType, e.str(), *backtrace);
- }
- else
- {
+ } else {
cm->IssueMessage(messageType, e.str());
- }
-
}
}
+ }
// Skip targets that will not really be linked. This is probably a
// name conflict between an external library and an executable
// within the project.
- if(linking && dependee &&
- dependee->GetType() == cmState::EXECUTABLE &&
- !dependee->IsExecutableWithExports())
- {
+ if (linking && dependee && dependee->GetType() == cmState::EXECUTABLE &&
+ !dependee->IsExecutableWithExports()) {
dependee = 0;
- }
+ }
- if(dependee)
- {
+ if (dependee) {
this->AddTargetDepend(depender_index, dependee, linking);
- }
+ }
}
void cmComputeTargetDepends::AddTargetDepend(int depender_index,
const cmGeneratorTarget* dependee,
bool linking)
{
- if(dependee->IsImported() ||
- dependee->GetType() == cmState::INTERFACE_LIBRARY)
- {
+ if (dependee->IsImported() ||
+ dependee->GetType() == cmState::INTERFACE_LIBRARY) {
// Skip IMPORTED and INTERFACE targets but follow their utility
// dependencies.
std::set<cmLinkItem> const& utils = dependee->GetUtilityItems();
- for(std::set<cmLinkItem>::const_iterator i = utils.begin();
- i != utils.end(); ++i)
- {
- if(cmGeneratorTarget const* transitive_dependee = i->Target)
- {
+ for (std::set<cmLinkItem>::const_iterator i = utils.begin();
+ i != utils.end(); ++i) {
+ if (cmGeneratorTarget const* transitive_dependee = i->Target) {
this->AddTargetDepend(depender_index, transitive_dependee, false);
- }
}
}
- else
- {
+ } else {
// Lookup the index for this target. All targets should be known by
// this point.
std::map<cmGeneratorTarget const*, int>::const_iterator tii =
@@ -432,96 +389,82 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index,
// Add this entry to the dependency graph.
this->InitialGraph[depender_index].push_back(
cmGraphEdge(dependee_index, !linking));
- }
+ }
}
-void
-cmComputeTargetDepends::DisplayGraph(Graph const& graph,
- const std::string& name)
+void cmComputeTargetDepends::DisplayGraph(Graph const& graph,
+ const std::string& name)
{
fprintf(stderr, "The %s target dependency graph is:\n", name.c_str());
int n = static_cast<int>(graph.size());
- for(int depender_index = 0; depender_index < n; ++depender_index)
- {
+ for (int depender_index = 0; depender_index < n; ++depender_index) {
EdgeList const& nl = graph[depender_index];
cmGeneratorTarget const* depender = this->Targets[depender_index];
- fprintf(stderr, "target %d is [%s]\n",
- depender_index, depender->GetName().c_str());
- for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni)
- {
+ fprintf(stderr, "target %d is [%s]\n", depender_index,
+ depender->GetName().c_str());
+ for (EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) {
int dependee_index = *ni;
cmGeneratorTarget const* dependee = this->Targets[dependee_index];
fprintf(stderr, " depends on target %d [%s] (%s)\n", dependee_index,
- dependee->GetName().c_str(), ni->IsStrong()? "strong" : "weak");
- }
+ dependee->GetName().c_str(), ni->IsStrong() ? "strong" : "weak");
}
+ }
fprintf(stderr, "\n");
}
-void
-cmComputeTargetDepends
-::DisplayComponents(cmComputeComponentGraph const& ccg)
+void cmComputeTargetDepends::DisplayComponents(
+ cmComputeComponentGraph const& ccg)
{
fprintf(stderr, "The strongly connected components are:\n");
std::vector<NodeList> const& components = ccg.GetComponents();
int n = static_cast<int>(components.size());
- for(int c = 0; c < n; ++c)
- {
+ for (int c = 0; c < n; ++c) {
NodeList const& nl = components[c];
fprintf(stderr, "Component (%d):\n", c);
- for(NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni)
- {
+ for (NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) {
int i = *ni;
- fprintf(stderr, " contains target %d [%s]\n",
- i, this->Targets[i]->GetName().c_str());
- }
+ fprintf(stderr, " contains target %d [%s]\n", i,
+ this->Targets[i]->GetName().c_str());
}
+ }
fprintf(stderr, "\n");
}
-bool
-cmComputeTargetDepends
-::CheckComponents(cmComputeComponentGraph const& ccg)
+bool cmComputeTargetDepends::CheckComponents(
+ cmComputeComponentGraph const& ccg)
{
// All non-trivial components should consist only of static
// libraries.
std::vector<NodeList> const& components = ccg.GetComponents();
int nc = static_cast<int>(components.size());
- for(int c=0; c < nc; ++c)
- {
+ for (int c = 0; c < nc; ++c) {
// Get the current component.
NodeList const& nl = components[c];
// Skip trivial components.
- if(nl.size() < 2)
- {
+ if (nl.size() < 2) {
continue;
- }
+ }
// Immediately complain if no cycles are allowed at all.
- if(this->NoCycles)
- {
+ if (this->NoCycles) {
this->ComplainAboutBadComponent(ccg, c);
return false;
- }
+ }
// Make sure the component is all STATIC_LIBRARY targets.
- for(NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni)
- {
- if(this->Targets[*ni]->GetType() != cmState::STATIC_LIBRARY)
- {
+ for (NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) {
+ if (this->Targets[*ni]->GetType() != cmState::STATIC_LIBRARY) {
this->ComplainAboutBadComponent(ccg, c);
return false;
- }
}
}
+ }
return true;
}
-void
-cmComputeTargetDepends
-::ComplainAboutBadComponent(cmComputeComponentGraph const& ccg, int c,
- bool strong)
+void cmComputeTargetDepends::ComplainAboutBadComponent(
+ cmComputeComponentGraph const& ccg, int c, bool strong)
{
// Construct the error message.
std::ostringstream e;
@@ -530,8 +473,7 @@ cmComputeTargetDepends
std::vector<NodeList> const& components = ccg.GetComponents();
std::vector<int> const& cmap = ccg.GetComponentMap();
NodeList const& cl = components[c];
- for(NodeList::const_iterator ci = cl.begin(); ci != cl.end(); ++ci)
- {
+ for (NodeList::const_iterator ci = cl.begin(); ci != cl.end(); ++ci) {
// Get the depender.
int i = *ci;
cmGeneratorTarget const* depender = this->Targets[i];
@@ -542,82 +484,66 @@ cmComputeTargetDepends
// List its dependencies that are inside the component.
EdgeList const& nl = this->InitialGraph[i];
- for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni)
- {
+ for (EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) {
int j = *ni;
- if(cmap[j] == c)
- {
+ if (cmap[j] == c) {
cmGeneratorTarget const* dependee = this->Targets[j];
e << " depends on \"" << dependee->GetName() << "\""
- << " (" << (ni->IsStrong()? "strong" : "weak") << ")\n";
- }
+ << " (" << (ni->IsStrong() ? "strong" : "weak") << ")\n";
}
}
- if(strong)
- {
+ }
+ if (strong) {
// Custom command executable dependencies cannot occur within a
// component of static libraries. The cycle must appear in calls
// to add_dependencies.
e << "The component contains at least one cycle consisting of strong "
<< "dependencies (created by add_dependencies) that cannot be broken.";
- }
- else if(this->NoCycles)
- {
+ } else if (this->NoCycles) {
e << "The GLOBAL_DEPENDS_NO_CYCLES global property is enabled, so "
<< "cyclic dependencies are not allowed even among static libraries.";
- }
- else
- {
+ } else {
e << "At least one of these targets is not a STATIC_LIBRARY. "
<< "Cyclic dependencies are allowed only among static libraries.";
- }
+ }
cmSystemTools::Error(e.str().c_str());
}
-bool
-cmComputeTargetDepends
-::IntraComponent(std::vector<int> const& cmap, int c, int i, int* head,
- std::set<int>& emitted, std::set<int>& visited)
+bool cmComputeTargetDepends::IntraComponent(std::vector<int> const& cmap,
+ int c, int i, int* head,
+ std::set<int>& emitted,
+ std::set<int>& visited)
{
- if(!visited.insert(i).second)
- {
+ if (!visited.insert(i).second) {
// Cycle in utility depends!
return false;
- }
- if(emitted.insert(i).second)
- {
+ }
+ if (emitted.insert(i).second) {
// Honor strong intra-component edges in the final order.
EdgeList const& el = this->InitialGraph[i];
- for(EdgeList::const_iterator ei = el.begin(); ei != el.end(); ++ei)
- {
+ for (EdgeList::const_iterator ei = el.begin(); ei != el.end(); ++ei) {
int j = *ei;
- if(cmap[j] == c && ei->IsStrong())
- {
+ if (cmap[j] == c && ei->IsStrong()) {
this->FinalGraph[i].push_back(cmGraphEdge(j, true));
- if(!this->IntraComponent(cmap, c, j, head, emitted, visited))
- {
+ if (!this->IntraComponent(cmap, c, j, head, emitted, visited)) {
return false;
- }
}
}
+ }
// Prepend to a linear linked-list of intra-component edges.
- if(*head >= 0)
- {
+ if (*head >= 0) {
this->FinalGraph[i].push_back(cmGraphEdge(*head, false));
- }
- else
- {
+ } else {
this->ComponentTail[c] = i;
- }
- *head = i;
}
+ *head = i;
+ }
return true;
}
-bool
-cmComputeTargetDepends
-::ComputeFinalDepends(cmComputeComponentGraph const& ccg)
+bool cmComputeTargetDepends::ComputeFinalDepends(
+ cmComputeComponentGraph const& ccg)
{
// Get the component graph information.
std::vector<NodeList> const& components = ccg.GetComponents();
@@ -632,38 +558,34 @@ cmComputeTargetDepends
this->ComponentHead.resize(components.size());
this->ComponentTail.resize(components.size());
int nc = static_cast<int>(components.size());
- for(int c=0; c < nc; ++c)
- {
+ for (int c = 0; c < nc; ++c) {
int head = -1;
std::set<int> emitted;
NodeList const& nl = components[c];
- for(NodeList::const_reverse_iterator ni = nl.rbegin();
- ni != nl.rend(); ++ni)
- {
+ for (NodeList::const_reverse_iterator ni = nl.rbegin(); ni != nl.rend();
+ ++ni) {
std::set<int> visited;
- if(!this->IntraComponent(cmap, c, *ni, &head, emitted, visited))
- {
+ if (!this->IntraComponent(cmap, c, *ni, &head, emitted, visited)) {
// Cycle in add_dependencies within component!
this->ComplainAboutBadComponent(ccg, c, true);
return false;
- }
}
- this->ComponentHead[c] = head;
}
+ this->ComponentHead[c] = head;
+ }
// Convert inter-component edges to connect component tails to heads.
int n = static_cast<int>(cgraph.size());
- for(int depender_component=0; depender_component < n; ++depender_component)
- {
+ for (int depender_component = 0; depender_component < n;
+ ++depender_component) {
int depender_component_tail = this->ComponentTail[depender_component];
EdgeList const& nl = cgraph[depender_component];
- for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni)
- {
+ for (EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) {
int dependee_component = *ni;
int dependee_component_head = this->ComponentHead[dependee_component];
- this->FinalGraph[depender_component_tail]
- .push_back(cmGraphEdge(dependee_component_head, ni->IsStrong()));
- }
+ this->FinalGraph[depender_component_tail].push_back(
+ cmGraphEdge(dependee_component_head, ni->IsStrong()));
}
+ }
return true;
}
diff --git a/Source/cmComputeTargetDepends.h b/Source/cmComputeTargetDepends.h
index 6100d97..9e51d4d 100644
--- a/Source/cmComputeTargetDepends.h
+++ b/Source/cmComputeTargetDepends.h
@@ -39,27 +39,28 @@ public:
bool Compute();
- std::vector<cmGeneratorTarget const*> const&
- GetTargets() const { return this->Targets; }
+ std::vector<cmGeneratorTarget const*> const& GetTargets() const
+ {
+ return this->Targets;
+ }
void GetTargetDirectDepends(cmGeneratorTarget const* t,
cmTargetDependSet& deps);
+
private:
void CollectTargets();
void CollectDepends();
void CollectTargetDepends(int depender_index);
- void AddTargetDepend(int depender_index,
- cmLinkItem const& dependee_name,
+ void AddTargetDepend(int depender_index, cmLinkItem const& dependee_name,
bool linking);
void AddTargetDepend(int depender_index, cmGeneratorTarget const* dependee,
bool linking);
bool ComputeFinalDepends(cmComputeComponentGraph const& ccg);
- void AddInterfaceDepends(int depender_index,
- cmLinkItem const& dependee_name,
- std::set<std::string> &emitted);
+ void AddInterfaceDepends(int depender_index, cmLinkItem const& dependee_name,
+ std::set<std::string>& emitted);
void AddInterfaceDepends(int depender_index,
cmGeneratorTarget const* dependee,
const std::string& config,
- std::set<std::string> &emitted);
+ std::set<std::string>& emitted);
cmGlobalGenerator* GlobalGenerator;
bool DebugMode;
bool NoCycles;
diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx
index 3711b9b..7006b62 100644
--- a/Source/cmConditionEvaluator.cxx
+++ b/Source/cmConditionEvaluator.cxx
@@ -43,17 +43,16 @@ static std::string const keyVERSION_GREATER = "VERSION_GREATER";
static std::string const keyVERSION_LESS = "VERSION_LESS";
cmConditionEvaluator::cmConditionEvaluator(cmMakefile& makefile,
- const cmListFileContext &context,
- const cmListFileBacktrace& bt):
- Makefile(makefile),
- ExecutionContext(context),
- Backtrace(bt),
- Policy12Status(makefile.GetPolicyStatus(cmPolicies::CMP0012)),
- Policy54Status(makefile.GetPolicyStatus(cmPolicies::CMP0054)),
- Policy57Status(makefile.GetPolicyStatus(cmPolicies::CMP0057)),
- Policy64Status(makefile.GetPolicyStatus(cmPolicies::CMP0064))
+ const cmListFileContext& context,
+ const cmListFileBacktrace& bt)
+ : Makefile(makefile)
+ , ExecutionContext(context)
+ , Backtrace(bt)
+ , Policy12Status(makefile.GetPolicyStatus(cmPolicies::CMP0012))
+ , Policy54Status(makefile.GetPolicyStatus(cmPolicies::CMP0054))
+ , Policy57Status(makefile.GetPolicyStatus(cmPolicies::CMP0057))
+ , Policy64Status(makefile.GetPolicyStatus(cmPolicies::CMP0064))
{
-
}
//=========================================================================
@@ -73,17 +72,15 @@ cmConditionEvaluator::cmConditionEvaluator(cmMakefile& makefile,
// directly. AND OR take variables or the values 0 or 1.
bool cmConditionEvaluator::IsTrue(
- const std::vector<cmExpandedCommandArgument> &args,
- std::string &errorString,
- cmake::MessageType &status)
+ const std::vector<cmExpandedCommandArgument>& args, std::string& errorString,
+ cmake::MessageType& status)
{
errorString = "";
// handle empty invocation
- if (args.size() < 1)
- {
+ if (args.size() < 1) {
return false;
- }
+ }
// store the reduced args in this vector
cmArgumentList newArgs;
@@ -94,123 +91,109 @@ bool cmConditionEvaluator::IsTrue(
// now loop through the arguments and see if we can reduce any of them
// we do this multiple times. Once for each level of precedence
// parens
- if (!this->HandleLevel0(newArgs, errorString, status))
- {
+ if (!this->HandleLevel0(newArgs, errorString, status)) {
return false;
- }
- //predicates
- if (!this->HandleLevel1(newArgs, errorString, status))
- {
+ }
+ // predicates
+ if (!this->HandleLevel1(newArgs, errorString, status)) {
return false;
- }
+ }
// binary ops
- if (!this->HandleLevel2(newArgs, errorString, status))
- {
+ if (!this->HandleLevel2(newArgs, errorString, status)) {
return false;
- }
+ }
// NOT
- if (!this->HandleLevel3(newArgs, errorString, status))
- {
+ if (!this->HandleLevel3(newArgs, errorString, status)) {
return false;
- }
+ }
// AND OR
- if (!this->HandleLevel4(newArgs, errorString, status))
- {
+ if (!this->HandleLevel4(newArgs, errorString, status)) {
return false;
- }
+ }
// now at the end there should only be one argument left
- if (newArgs.size() != 1)
- {
+ if (newArgs.size() != 1) {
errorString = "Unknown arguments specified";
status = cmake::FATAL_ERROR;
return false;
- }
+ }
return this->GetBooleanValueWithAutoDereference(*(newArgs.begin()),
- errorString, status, true);
+ errorString, status, true);
}
//=========================================================================
const char* cmConditionEvaluator::GetDefinitionIfUnquoted(
cmExpandedCommandArgument const& argument) const
{
- if((this->Policy54Status != cmPolicies::WARN &&
- this->Policy54Status != cmPolicies::OLD) &&
- argument.WasQuoted())
- {
+ if ((this->Policy54Status != cmPolicies::WARN &&
+ this->Policy54Status != cmPolicies::OLD) &&
+ argument.WasQuoted()) {
return 0;
- }
+ }
const char* def = this->Makefile.GetDefinition(argument.GetValue());
- if(def && argument.WasQuoted() && this->Policy54Status == cmPolicies::WARN)
- {
- if(!this->Makefile.HasCMP0054AlreadyBeenReported(
- this->ExecutionContext))
- {
+ if (def && argument.WasQuoted() &&
+ this->Policy54Status == cmPolicies::WARN) {
+ if (!this->Makefile.HasCMP0054AlreadyBeenReported(
+ this->ExecutionContext)) {
std::ostringstream e;
e << (cmPolicies::GetPolicyWarning(cmPolicies::CMP0054)) << "\n";
- e << "Quoted variables like \"" << argument.GetValue() <<
- "\" will no longer be dereferenced "
- "when the policy is set to NEW. "
- "Since the policy is not set the OLD behavior will be used.";
-
- this->Makefile.GetCMakeInstance()
- ->IssueMessage(cmake::AUTHOR_WARNING, e.str(),
- this->Backtrace);
- }
+ e << "Quoted variables like \"" << argument.GetValue()
+ << "\" will no longer be dereferenced "
+ "when the policy is set to NEW. "
+ "Since the policy is not set the OLD behavior will be used.";
+
+ this->Makefile.GetCMakeInstance()->IssueMessage(
+ cmake::AUTHOR_WARNING, e.str(), this->Backtrace);
}
+ }
return def;
}
//=========================================================================
const char* cmConditionEvaluator::GetVariableOrString(
- const cmExpandedCommandArgument& argument) const
+ const cmExpandedCommandArgument& argument) const
{
const char* def = this->GetDefinitionIfUnquoted(argument);
- if(!def)
- {
+ if (!def) {
def = argument.c_str();
- }
+ }
return def;
}
//=========================================================================
bool cmConditionEvaluator::IsKeyword(std::string const& keyword,
- cmExpandedCommandArgument& argument) const
+ cmExpandedCommandArgument& argument) const
{
- if((this->Policy54Status != cmPolicies::WARN &&
- this->Policy54Status != cmPolicies::OLD) &&
- argument.WasQuoted())
- {
+ if ((this->Policy54Status != cmPolicies::WARN &&
+ this->Policy54Status != cmPolicies::OLD) &&
+ argument.WasQuoted()) {
return false;
- }
+ }
bool isKeyword = argument.GetValue() == keyword;
- if(isKeyword && argument.WasQuoted() &&
- this->Policy54Status == cmPolicies::WARN)
- {
- if(!this->Makefile.HasCMP0054AlreadyBeenReported(
- this->ExecutionContext))
- {
+ if (isKeyword && argument.WasQuoted() &&
+ this->Policy54Status == cmPolicies::WARN) {
+ if (!this->Makefile.HasCMP0054AlreadyBeenReported(
+ this->ExecutionContext)) {
std::ostringstream e;
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0054) << "\n";
- e << "Quoted keywords like \"" << argument.GetValue() <<
- "\" will no longer be interpreted as keywords "
- "when the policy is set to NEW. "
- "Since the policy is not set the OLD behavior will be used.";
-
- this->Makefile.GetCMakeInstance()
- ->IssueMessage(cmake::AUTHOR_WARNING, e.str(),
- this->Backtrace);
- }
+ e << "Quoted keywords like \"" << argument.GetValue()
+ << "\" will no longer be interpreted as keywords "
+ "when the policy is set to NEW. "
+ "Since the policy is not set the OLD behavior will be used.";
+
+ this->Makefile.GetCMakeInstance()->IssueMessage(
+ cmake::AUTHOR_WARNING, e.str(), this->Backtrace);
}
+ }
return isKeyword;
}
@@ -220,36 +203,30 @@ bool cmConditionEvaluator::GetBooleanValue(
cmExpandedCommandArgument& arg) const
{
// Check basic constants.
- if (arg == "0")
- {
+ if (arg == "0") {
return false;
- }
- if (arg == "1")
- {
+ }
+ if (arg == "1") {
return true;
- }
+ }
// Check named constants.
- if (cmSystemTools::IsOn(arg.c_str()))
- {
+ if (cmSystemTools::IsOn(arg.c_str())) {
return true;
- }
- if (cmSystemTools::IsOff(arg.c_str()))
- {
+ }
+ if (cmSystemTools::IsOff(arg.c_str())) {
return false;
- }
+ }
// Check for numbers.
- if(!arg.empty())
- {
+ if (!arg.empty()) {
char* end;
double d = strtod(arg.c_str(), &end);
- if(*end == '\0')
- {
+ if (*end == '\0') {
// The whole string is a number. Use C conversion to bool.
- return d? true:false;
- }
+ return d ? true : false;
}
+ }
// Check definition.
const char* def = this->GetDefinitionIfUnquoted(arg);
@@ -261,179 +238,149 @@ bool cmConditionEvaluator::GetBooleanValue(
bool cmConditionEvaluator::GetBooleanValueOld(
cmExpandedCommandArgument const& arg, bool one) const
{
- if(one)
- {
+ if (one) {
// Old IsTrue behavior for single argument.
- if(arg == "0")
- { return false; }
- else if(arg == "1")
- { return true; }
- else
- {
+ if (arg == "0") {
+ return false;
+ } else if (arg == "1") {
+ return true;
+ } else {
const char* def = this->GetDefinitionIfUnquoted(arg);
return !cmSystemTools::IsOff(def);
- }
}
- else
- {
+ } else {
// Old GetVariableOrNumber behavior.
const char* def = this->GetDefinitionIfUnquoted(arg);
- if(!def && atoi(arg.c_str()))
- {
+ if (!def && atoi(arg.c_str())) {
def = arg.c_str();
- }
- return !cmSystemTools::IsOff(def);
}
+ return !cmSystemTools::IsOff(def);
+ }
}
//=========================================================================
// returns the resulting boolean value
bool cmConditionEvaluator::GetBooleanValueWithAutoDereference(
- cmExpandedCommandArgument &newArg,
- std::string &errorString,
- cmake::MessageType &status,
- bool oneArg) const
+ cmExpandedCommandArgument& newArg, std::string& errorString,
+ cmake::MessageType& status, bool oneArg) const
{
// Use the policy if it is set.
- if (this->Policy12Status == cmPolicies::NEW)
- {
+ if (this->Policy12Status == cmPolicies::NEW) {
return GetBooleanValue(newArg);
- }
- else if (this->Policy12Status == cmPolicies::OLD)
- {
+ } else if (this->Policy12Status == cmPolicies::OLD) {
return GetBooleanValueOld(newArg, oneArg);
- }
+ }
// Check policy only if old and new results differ.
bool newResult = this->GetBooleanValue(newArg);
bool oldResult = this->GetBooleanValueOld(newArg, oneArg);
- if(newResult != oldResult)
- {
- switch(this->Policy12Status)
- {
- case cmPolicies::WARN:
- {
- errorString = "An argument named \"" + newArg.GetValue()
- + "\" appears in a conditional statement. "
- + cmPolicies::GetPolicyWarning(cmPolicies::CMP0012);
+ if (newResult != oldResult) {
+ switch (this->Policy12Status) {
+ case cmPolicies::WARN: {
+ errorString = "An argument named \"" + newArg.GetValue() +
+ "\" appears in a conditional statement. " +
+ cmPolicies::GetPolicyWarning(cmPolicies::CMP0012);
status = cmake::AUTHOR_WARNING;
- }
+ }
case cmPolicies::OLD:
return oldResult;
case cmPolicies::REQUIRED_IF_USED:
- case cmPolicies::REQUIRED_ALWAYS:
- {
- errorString = "An argument named \"" + newArg.GetValue()
- + "\" appears in a conditional statement. "
- + cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0012);
+ case cmPolicies::REQUIRED_ALWAYS: {
+ errorString = "An argument named \"" + newArg.GetValue() +
+ "\" appears in a conditional statement. " +
+ cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0012);
status = cmake::FATAL_ERROR;
- }
+ }
case cmPolicies::NEW:
break;
- }
}
+ }
return newResult;
}
//=========================================================================
-void cmConditionEvaluator::IncrementArguments(cmArgumentList &newArgs,
- cmArgumentList::iterator &argP1,
- cmArgumentList::iterator &argP2) const
+void cmConditionEvaluator::IncrementArguments(
+ cmArgumentList& newArgs, cmArgumentList::iterator& argP1,
+ cmArgumentList::iterator& argP2) const
{
- if (argP1 != newArgs.end())
- {
+ if (argP1 != newArgs.end()) {
argP1++;
argP2 = argP1;
- if (argP1 != newArgs.end())
- {
+ if (argP1 != newArgs.end()) {
argP2++;
- }
}
+ }
}
//=========================================================================
// helper function to reduce code duplication
-void cmConditionEvaluator::HandlePredicate(bool value, int &reducible,
- cmArgumentList::iterator &arg,
- cmArgumentList &newArgs,
- cmArgumentList::iterator &argP1,
- cmArgumentList::iterator &argP2) const
+void cmConditionEvaluator::HandlePredicate(
+ bool value, int& reducible, cmArgumentList::iterator& arg,
+ cmArgumentList& newArgs, cmArgumentList::iterator& argP1,
+ cmArgumentList::iterator& argP2) const
{
- if(value)
- {
+ if (value) {
*arg = cmExpandedCommandArgument("1", true);
- }
- else
- {
+ } else {
*arg = cmExpandedCommandArgument("0", true);
- }
+ }
newArgs.erase(argP1);
argP1 = arg;
- this->IncrementArguments(newArgs,argP1,argP2);
+ this->IncrementArguments(newArgs, argP1, argP2);
reducible = 1;
}
//=========================================================================
// helper function to reduce code duplication
-void cmConditionEvaluator::HandleBinaryOp(bool value, int &reducible,
- cmArgumentList::iterator &arg,
- cmArgumentList &newArgs,
- cmArgumentList::iterator &argP1,
- cmArgumentList::iterator &argP2)
+void cmConditionEvaluator::HandleBinaryOp(bool value, int& reducible,
+ cmArgumentList::iterator& arg,
+ cmArgumentList& newArgs,
+ cmArgumentList::iterator& argP1,
+ cmArgumentList::iterator& argP2)
{
- if(value)
- {
+ if (value) {
*arg = cmExpandedCommandArgument("1", true);
- }
- else
- {
+ } else {
*arg = cmExpandedCommandArgument("0", true);
- }
+ }
newArgs.erase(argP2);
newArgs.erase(argP1);
argP1 = arg;
- this->IncrementArguments(newArgs,argP1,argP2);
+ this->IncrementArguments(newArgs, argP1, argP2);
reducible = 1;
}
//=========================================================================
// level 0 processes parenthetical expressions
-bool cmConditionEvaluator::HandleLevel0(cmArgumentList &newArgs,
- std::string &errorString,
- cmake::MessageType &status)
+bool cmConditionEvaluator::HandleLevel0(cmArgumentList& newArgs,
+ std::string& errorString,
+ cmake::MessageType& status)
{
int reducible;
- do
- {
+ do {
reducible = 0;
cmArgumentList::iterator arg = newArgs.begin();
- while (arg != newArgs.end())
- {
- if (IsKeyword(keyParenL, *arg))
- {
+ while (arg != newArgs.end()) {
+ if (IsKeyword(keyParenL, *arg)) {
// search for the closing paren for this opening one
cmArgumentList::iterator argClose;
argClose = arg;
argClose++;
unsigned int depth = 1;
- while (argClose != newArgs.end() && depth)
- {
- if (this->IsKeyword(keyParenL, *argClose))
- {
- depth++;
- }
- if (this->IsKeyword(keyParenR, *argClose))
- {
- depth--;
- }
- argClose++;
+ while (argClose != newArgs.end() && depth) {
+ if (this->IsKeyword(keyParenL, *argClose)) {
+ depth++;
+ }
+ if (this->IsKeyword(keyParenR, *argClose)) {
+ depth--;
}
- if (depth)
- {
+ argClose++;
+ }
+ if (depth) {
errorString = "mismatched parenthesis in condition";
status = cmake::FATAL_ERROR;
return false;
- }
+ }
// store the reduced args in this vector
std::vector<cmExpandedCommandArgument> newArgs2;
@@ -444,420 +391,337 @@ bool cmConditionEvaluator::HandleLevel0(cmArgumentList &newArgs,
newArgs2.pop_back();
// now recursively invoke IsTrue to handle the values inside the
// parenthetical expression
- bool value =
- this->IsTrue(newArgs2, errorString, status);
- if(value)
- {
+ bool value = this->IsTrue(newArgs2, errorString, status);
+ if (value) {
*arg = cmExpandedCommandArgument("1", true);
- }
- else
- {
+ } else {
*arg = cmExpandedCommandArgument("0", true);
- }
+ }
argP1 = arg;
argP1++;
// remove the now evaluated parenthetical expression
- newArgs.erase(argP1,argClose);
- }
- ++arg;
+ newArgs.erase(argP1, argClose);
}
+ ++arg;
}
- while (reducible);
+ } while (reducible);
return true;
}
//=========================================================================
// level one handles most predicates except for NOT
-bool cmConditionEvaluator::HandleLevel1(cmArgumentList &newArgs,
- std::string &, cmake::MessageType &)
+bool cmConditionEvaluator::HandleLevel1(cmArgumentList& newArgs, std::string&,
+ cmake::MessageType&)
{
int reducible;
- do
- {
+ do {
reducible = 0;
cmArgumentList::iterator arg = newArgs.begin();
cmArgumentList::iterator argP1;
cmArgumentList::iterator argP2;
- while (arg != newArgs.end())
- {
+ while (arg != newArgs.end()) {
argP1 = arg;
- this->IncrementArguments(newArgs,argP1,argP2);
+ this->IncrementArguments(newArgs, argP1, argP2);
// does a file exist
- if (this->IsKeyword(keyEXISTS, *arg) && argP1 != newArgs.end())
- {
- this->HandlePredicate(
- cmSystemTools::FileExists(argP1->c_str()),
- reducible, arg, newArgs, argP1, argP2);
- }
+ if (this->IsKeyword(keyEXISTS, *arg) && argP1 != newArgs.end()) {
+ this->HandlePredicate(cmSystemTools::FileExists(argP1->c_str()),
+ reducible, arg, newArgs, argP1, argP2);
+ }
// does a directory with this name exist
- if (this->IsKeyword(keyIS_DIRECTORY, *arg) && argP1 != newArgs.end())
- {
- this->HandlePredicate(
- cmSystemTools::FileIsDirectory(argP1->c_str()),
- reducible, arg, newArgs, argP1, argP2);
- }
+ if (this->IsKeyword(keyIS_DIRECTORY, *arg) && argP1 != newArgs.end()) {
+ this->HandlePredicate(cmSystemTools::FileIsDirectory(argP1->c_str()),
+ reducible, arg, newArgs, argP1, argP2);
+ }
// does a symlink with this name exist
- if (this->IsKeyword(keyIS_SYMLINK, *arg) && argP1 != newArgs.end())
- {
- this->HandlePredicate(
- cmSystemTools::FileIsSymlink(argP1->c_str()),
- reducible, arg, newArgs, argP1, argP2);
- }
+ if (this->IsKeyword(keyIS_SYMLINK, *arg) && argP1 != newArgs.end()) {
+ this->HandlePredicate(cmSystemTools::FileIsSymlink(argP1->c_str()),
+ reducible, arg, newArgs, argP1, argP2);
+ }
// is the given path an absolute path ?
- if (this->IsKeyword(keyIS_ABSOLUTE, *arg) && argP1 != newArgs.end())
- {
- this->HandlePredicate(
- cmSystemTools::FileIsFullPath(argP1->c_str()),
- reducible, arg, newArgs, argP1, argP2);
- }
+ if (this->IsKeyword(keyIS_ABSOLUTE, *arg) && argP1 != newArgs.end()) {
+ this->HandlePredicate(cmSystemTools::FileIsFullPath(argP1->c_str()),
+ reducible, arg, newArgs, argP1, argP2);
+ }
// does a command exist
- if (this->IsKeyword(keyCOMMAND, *arg) && argP1 != newArgs.end())
- {
+ if (this->IsKeyword(keyCOMMAND, *arg) && argP1 != newArgs.end()) {
cmCommand* command =
- this->Makefile.GetState()->GetCommand(argP1->c_str());
- this->HandlePredicate(
- command ? true : false,
- reducible, arg, newArgs, argP1, argP2);
- }
+ this->Makefile.GetState()->GetCommand(argP1->c_str());
+ this->HandlePredicate(command ? true : false, reducible, arg, newArgs,
+ argP1, argP2);
+ }
// does a policy exist
- if (this->IsKeyword(keyPOLICY, *arg) && argP1 != newArgs.end())
- {
+ if (this->IsKeyword(keyPOLICY, *arg) && argP1 != newArgs.end()) {
cmPolicies::PolicyID pid;
- this->HandlePredicate(
- cmPolicies::GetPolicyID(argP1->c_str(), pid),
- reducible, arg, newArgs, argP1, argP2);
- }
+ this->HandlePredicate(cmPolicies::GetPolicyID(argP1->c_str(), pid),
+ reducible, arg, newArgs, argP1, argP2);
+ }
// does a target exist
- if (this->IsKeyword(keyTARGET, *arg) && argP1 != newArgs.end())
- {
+ if (this->IsKeyword(keyTARGET, *arg) && argP1 != newArgs.end()) {
this->HandlePredicate(
- this->Makefile.FindTargetToUse(argP1->GetValue())?true:false,
+ this->Makefile.FindTargetToUse(argP1->GetValue()) ? true : false,
reducible, arg, newArgs, argP1, argP2);
- }
+ }
// does a test exist
- if(this->Policy64Status != cmPolicies::OLD &&
- this->Policy64Status != cmPolicies::WARN)
- {
- if (this->IsKeyword(keyTEST, *arg) && argP1 != newArgs.end())
- {
+ if (this->Policy64Status != cmPolicies::OLD &&
+ this->Policy64Status != cmPolicies::WARN) {
+ if (this->IsKeyword(keyTEST, *arg) && argP1 != newArgs.end()) {
const cmTest* haveTest = this->Makefile.GetTest(argP1->c_str());
- this->HandlePredicate(
- haveTest?true:false,
- reducible, arg, newArgs, argP1, argP2);
- }
+ this->HandlePredicate(haveTest ? true : false, reducible, arg,
+ newArgs, argP1, argP2);
}
- else if(this->Policy64Status == cmPolicies::WARN &&
- this->IsKeyword(keyTEST, *arg))
- {
+ } else if (this->Policy64Status == cmPolicies::WARN &&
+ this->IsKeyword(keyTEST, *arg)) {
std::ostringstream e;
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0064) << "\n";
e << "TEST will be interpreted as an operator "
- "when the policy is set to NEW. "
- "Since the policy is not set the OLD behavior will be used.";
+ "when the policy is set to NEW. "
+ "Since the policy is not set the OLD behavior will be used.";
this->Makefile.IssueMessage(cmake::AUTHOR_WARNING, e.str());
- }
+ }
// is a variable defined
- if (this->IsKeyword(keyDEFINED, *arg) && argP1 != newArgs.end())
- {
+ if (this->IsKeyword(keyDEFINED, *arg) && argP1 != newArgs.end()) {
size_t argP1len = argP1->GetValue().size();
bool bdef = false;
- if(argP1len > 4 && argP1->GetValue().substr(0, 4) == "ENV{" &&
- argP1->GetValue().operator[](argP1len-1) == '}')
- {
- std::string env = argP1->GetValue().substr(4, argP1len-5);
- bdef = cmSystemTools::GetEnv(env.c_str())?true:false;
- }
- else
- {
+ if (argP1len > 4 && argP1->GetValue().substr(0, 4) == "ENV{" &&
+ argP1->GetValue().operator[](argP1len - 1) == '}') {
+ std::string env = argP1->GetValue().substr(4, argP1len - 5);
+ bdef = cmSystemTools::GetEnv(env.c_str()) ? true : false;
+ } else {
bdef = this->Makefile.IsDefinitionSet(argP1->GetValue());
- }
- this->HandlePredicate(bdef, reducible, arg, newArgs, argP1, argP2);
}
- ++arg;
+ this->HandlePredicate(bdef, reducible, arg, newArgs, argP1, argP2);
}
+ ++arg;
}
- while (reducible);
+ } while (reducible);
return true;
}
//=========================================================================
// level two handles most binary operations except for AND OR
-bool cmConditionEvaluator::HandleLevel2(cmArgumentList &newArgs,
- std::string &errorString,
- cmake::MessageType &status)
+bool cmConditionEvaluator::HandleLevel2(cmArgumentList& newArgs,
+ std::string& errorString,
+ cmake::MessageType& status)
{
int reducible;
std::string def_buf;
- const char *def;
- const char *def2;
- do
- {
+ const char* def;
+ const char* def2;
+ do {
reducible = 0;
cmArgumentList::iterator arg = newArgs.begin();
cmArgumentList::iterator argP1;
cmArgumentList::iterator argP2;
- while (arg != newArgs.end())
- {
+ while (arg != newArgs.end()) {
argP1 = arg;
- this->IncrementArguments(newArgs,argP1,argP2);
+ this->IncrementArguments(newArgs, argP1, argP2);
if (argP1 != newArgs.end() && argP2 != newArgs.end() &&
- IsKeyword(keyMATCHES, *argP1))
- {
+ IsKeyword(keyMATCHES, *argP1)) {
def = this->GetVariableOrString(*arg);
if (def != arg->c_str() // yes, we compare the pointer value
- && cmHasLiteralPrefix(arg->GetValue(), "CMAKE_MATCH_"))
- {
+ && cmHasLiteralPrefix(arg->GetValue(), "CMAKE_MATCH_")) {
// The string to match is owned by our match result variables.
// Move it to our own buffer before clearing them.
def_buf = def;
def = def_buf.c_str();
- }
+ }
const char* rex = argP2->c_str();
this->Makefile.ClearMatches();
cmsys::RegularExpression regEntry;
- if ( !regEntry.compile(rex) )
- {
+ if (!regEntry.compile(rex)) {
std::ostringstream error;
error << "Regular expression \"" << rex << "\" cannot compile";
errorString = error.str();
status = cmake::FATAL_ERROR;
return false;
- }
- if (regEntry.find(def))
- {
+ }
+ if (regEntry.find(def)) {
this->Makefile.StoreMatches(regEntry);
*arg = cmExpandedCommandArgument("1", true);
- }
- else
- {
+ } else {
*arg = cmExpandedCommandArgument("0", true);
- }
+ }
newArgs.erase(argP2);
newArgs.erase(argP1);
argP1 = arg;
- this->IncrementArguments(newArgs,argP1,argP2);
+ this->IncrementArguments(newArgs, argP1, argP2);
reducible = 1;
- }
+ }
- if (argP1 != newArgs.end() && this->IsKeyword(keyMATCHES, *arg))
- {
+ if (argP1 != newArgs.end() && this->IsKeyword(keyMATCHES, *arg)) {
*arg = cmExpandedCommandArgument("0", true);
newArgs.erase(argP1);
argP1 = arg;
- this->IncrementArguments(newArgs,argP1,argP2);
+ this->IncrementArguments(newArgs, argP1, argP2);
reducible = 1;
- }
+ }
if (argP1 != newArgs.end() && argP2 != newArgs.end() &&
- (this->IsKeyword(keyLESS, *argP1) ||
- this->IsKeyword(keyGREATER, *argP1) ||
- this->IsKeyword(keyEQUAL, *argP1)))
- {
+ (this->IsKeyword(keyLESS, *argP1) ||
+ this->IsKeyword(keyGREATER, *argP1) ||
+ this->IsKeyword(keyEQUAL, *argP1))) {
def = this->GetVariableOrString(*arg);
def2 = this->GetVariableOrString(*argP2);
double lhs;
double rhs;
bool result;
- if(sscanf(def, "%lg", &lhs) != 1 ||
- sscanf(def2, "%lg", &rhs) != 1)
- {
+ if (sscanf(def, "%lg", &lhs) != 1 || sscanf(def2, "%lg", &rhs) != 1) {
result = false;
- }
- else if (*(argP1) == keyLESS)
- {
+ } else if (*(argP1) == keyLESS) {
result = (lhs < rhs);
- }
- else if (*(argP1) == keyGREATER)
- {
+ } else if (*(argP1) == keyGREATER) {
result = (lhs > rhs);
- }
- else
- {
+ } else {
result = (lhs == rhs);
- }
- this->HandleBinaryOp(result,
- reducible, arg, newArgs, argP1, argP2);
}
+ this->HandleBinaryOp(result, reducible, arg, newArgs, argP1, argP2);
+ }
if (argP1 != newArgs.end() && argP2 != newArgs.end() &&
- (this->IsKeyword(keySTRLESS, *argP1) ||
- this->IsKeyword(keySTREQUAL, *argP1) ||
- this->IsKeyword(keySTRGREATER, *argP1)))
- {
+ (this->IsKeyword(keySTRLESS, *argP1) ||
+ this->IsKeyword(keySTREQUAL, *argP1) ||
+ this->IsKeyword(keySTRGREATER, *argP1))) {
def = this->GetVariableOrString(*arg);
def2 = this->GetVariableOrString(*argP2);
- int val = strcmp(def,def2);
+ int val = strcmp(def, def2);
bool result;
- if (*(argP1) == keySTRLESS)
- {
+ if (*(argP1) == keySTRLESS) {
result = (val < 0);
- }
- else if (*(argP1) == keySTRGREATER)
- {
+ } else if (*(argP1) == keySTRGREATER) {
result = (val > 0);
- }
- else // strequal
- {
+ } else // strequal
+ {
result = (val == 0);
- }
- this->HandleBinaryOp(result,
- reducible, arg, newArgs, argP1, argP2);
}
+ this->HandleBinaryOp(result, reducible, arg, newArgs, argP1, argP2);
+ }
if (argP1 != newArgs.end() && argP2 != newArgs.end() &&
- (this->IsKeyword(keyVERSION_LESS, *argP1) ||
- this->IsKeyword(keyVERSION_GREATER, *argP1) ||
- this->IsKeyword(keyVERSION_EQUAL, *argP1)))
- {
+ (this->IsKeyword(keyVERSION_LESS, *argP1) ||
+ this->IsKeyword(keyVERSION_GREATER, *argP1) ||
+ this->IsKeyword(keyVERSION_EQUAL, *argP1))) {
def = this->GetVariableOrString(*arg);
def2 = this->GetVariableOrString(*argP2);
cmSystemTools::CompareOp op = cmSystemTools::OP_EQUAL;
- if(*argP1 == keyVERSION_LESS)
- {
+ if (*argP1 == keyVERSION_LESS) {
op = cmSystemTools::OP_LESS;
- }
- else if(*argP1 == keyVERSION_GREATER)
- {
+ } else if (*argP1 == keyVERSION_GREATER) {
op = cmSystemTools::OP_GREATER;
- }
- bool result = cmSystemTools::VersionCompare(op, def, def2);
- this->HandleBinaryOp(result,
- reducible, arg, newArgs, argP1, argP2);
}
+ bool result = cmSystemTools::VersionCompare(op, def, def2);
+ this->HandleBinaryOp(result, reducible, arg, newArgs, argP1, argP2);
+ }
// is file A newer than file B
if (argP1 != newArgs.end() && argP2 != newArgs.end() &&
- this->IsKeyword(keyIS_NEWER_THAN, *argP1))
- {
- int fileIsNewer=0;
- bool success=cmSystemTools::FileTimeCompare(arg->GetValue(),
- (argP2)->GetValue(),
- &fileIsNewer);
+ this->IsKeyword(keyIS_NEWER_THAN, *argP1)) {
+ int fileIsNewer = 0;
+ bool success = cmSystemTools::FileTimeCompare(
+ arg->GetValue(), (argP2)->GetValue(), &fileIsNewer);
this->HandleBinaryOp(
- (success==false || fileIsNewer==1 || fileIsNewer==0),
+ (success == false || fileIsNewer == 1 || fileIsNewer == 0),
reducible, arg, newArgs, argP1, argP2);
- }
+ }
if (argP1 != newArgs.end() && argP2 != newArgs.end() &&
- this->IsKeyword(keyIN_LIST, *argP1))
- {
- if(this->Policy57Status != cmPolicies::OLD &&
- this->Policy57Status != cmPolicies::WARN)
- {
+ this->IsKeyword(keyIN_LIST, *argP1)) {
+ if (this->Policy57Status != cmPolicies::OLD &&
+ this->Policy57Status != cmPolicies::WARN) {
bool result = false;
def = this->GetVariableOrString(*arg);
def2 = this->Makefile.GetDefinition(argP2->GetValue());
- if(def2)
- {
+ if (def2) {
std::vector<std::string> list;
cmSystemTools::ExpandListArgument(def2, list, true);
result = std::find(list.begin(), list.end(), def) != list.end();
- }
-
- this->HandleBinaryOp(result,
- reducible, arg, newArgs, argP1, argP2);
}
- else if(this->Policy57Status == cmPolicies::WARN)
- {
- std::ostringstream e;
- e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0057) << "\n";
- e << "IN_LIST will be interpreted as an operator "
- "when the policy is set to NEW. "
- "Since the policy is not set the OLD behavior will be used.";
-
- this->Makefile.IssueMessage(cmake::AUTHOR_WARNING, e.str());
- }
+
+ this->HandleBinaryOp(result, reducible, arg, newArgs, argP1, argP2);
+ } else if (this->Policy57Status == cmPolicies::WARN) {
+ std::ostringstream e;
+ e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0057) << "\n";
+ e << "IN_LIST will be interpreted as an operator "
+ "when the policy is set to NEW. "
+ "Since the policy is not set the OLD behavior will be used.";
+
+ this->Makefile.IssueMessage(cmake::AUTHOR_WARNING, e.str());
}
+ }
++arg;
- }
}
- while (reducible);
+ } while (reducible);
return true;
}
//=========================================================================
// level 3 handles NOT
-bool cmConditionEvaluator::HandleLevel3(cmArgumentList &newArgs,
- std::string &errorString,
- cmake::MessageType &status)
+bool cmConditionEvaluator::HandleLevel3(cmArgumentList& newArgs,
+ std::string& errorString,
+ cmake::MessageType& status)
{
int reducible;
- do
- {
+ do {
reducible = 0;
cmArgumentList::iterator arg = newArgs.begin();
cmArgumentList::iterator argP1;
cmArgumentList::iterator argP2;
- while (arg != newArgs.end())
- {
+ while (arg != newArgs.end()) {
argP1 = arg;
- IncrementArguments(newArgs,argP1,argP2);
- if (argP1 != newArgs.end() && IsKeyword(keyNOT, *arg))
- {
- bool rhs = this->GetBooleanValueWithAutoDereference(*argP1,
- errorString,
- status);
+ IncrementArguments(newArgs, argP1, argP2);
+ if (argP1 != newArgs.end() && IsKeyword(keyNOT, *arg)) {
+ bool rhs = this->GetBooleanValueWithAutoDereference(
+ *argP1, errorString, status);
this->HandlePredicate(!rhs, reducible, arg, newArgs, argP1, argP2);
- }
- ++arg;
}
+ ++arg;
}
- while (reducible);
+ } while (reducible);
return true;
}
//=========================================================================
// level 4 handles AND OR
-bool cmConditionEvaluator::HandleLevel4(cmArgumentList &newArgs,
- std::string &errorString,
- cmake::MessageType &status)
+bool cmConditionEvaluator::HandleLevel4(cmArgumentList& newArgs,
+ std::string& errorString,
+ cmake::MessageType& status)
{
int reducible;
bool lhs;
bool rhs;
- do
- {
+ do {
reducible = 0;
cmArgumentList::iterator arg = newArgs.begin();
cmArgumentList::iterator argP1;
cmArgumentList::iterator argP2;
- while (arg != newArgs.end())
- {
+ while (arg != newArgs.end()) {
argP1 = arg;
- IncrementArguments(newArgs,argP1,argP2);
+ IncrementArguments(newArgs, argP1, argP2);
if (argP1 != newArgs.end() && IsKeyword(keyAND, *argP1) &&
- argP2 != newArgs.end())
- {
- lhs = this->GetBooleanValueWithAutoDereference(*arg,
- errorString,
- status);
- rhs = this->GetBooleanValueWithAutoDereference(*argP2,
- errorString,
- status);
- this->HandleBinaryOp((lhs && rhs),
- reducible, arg, newArgs, argP1, argP2);
- }
+ argP2 != newArgs.end()) {
+ lhs =
+ this->GetBooleanValueWithAutoDereference(*arg, errorString, status);
+ rhs = this->GetBooleanValueWithAutoDereference(*argP2, errorString,
+ status);
+ this->HandleBinaryOp((lhs && rhs), reducible, arg, newArgs, argP1,
+ argP2);
+ }
if (argP1 != newArgs.end() && this->IsKeyword(keyOR, *argP1) &&
- argP2 != newArgs.end())
- {
- lhs = this->GetBooleanValueWithAutoDereference(*arg,
- errorString,
- status);
- rhs = this->GetBooleanValueWithAutoDereference(*argP2,
- errorString,
- status);
- this->HandleBinaryOp((lhs || rhs),
- reducible, arg, newArgs, argP1, argP2);
- }
- ++arg;
+ argP2 != newArgs.end()) {
+ lhs =
+ this->GetBooleanValueWithAutoDereference(*arg, errorString, status);
+ rhs = this->GetBooleanValueWithAutoDereference(*argP2, errorString,
+ status);
+ this->HandleBinaryOp((lhs || rhs), reducible, arg, newArgs, argP1,
+ argP2);
}
+ ++arg;
}
- while (reducible);
+ } while (reducible);
return true;
}
diff --git a/Source/cmConditionEvaluator.h b/Source/cmConditionEvaluator.h
index 3ed512d..3f8c984 100644
--- a/Source/cmConditionEvaluator.h
+++ b/Source/cmConditionEvaluator.h
@@ -22,75 +22,64 @@ class cmConditionEvaluator
public:
typedef std::list<cmExpandedCommandArgument> cmArgumentList;
- cmConditionEvaluator(cmMakefile& makefile,
- cmListFileContext const& context,
+ cmConditionEvaluator(cmMakefile& makefile, cmListFileContext const& context,
cmListFileBacktrace const& bt);
// this is a shared function for both If and Else to determine if the
// arguments were valid, and if so, was the response true. If there is
// an error, the errorString will be set.
- bool IsTrue(const std::vector<cmExpandedCommandArgument> &args,
- std::string &errorString,
- cmake::MessageType &status);
+ bool IsTrue(const std::vector<cmExpandedCommandArgument>& args,
+ std::string& errorString, cmake::MessageType& status);
private:
// Filter the given variable definition based on policy CMP0054.
const char* GetDefinitionIfUnquoted(
- const cmExpandedCommandArgument& argument) const;
+ const cmExpandedCommandArgument& argument) const;
const char* GetVariableOrString(
- const cmExpandedCommandArgument& argument) const;
+ const cmExpandedCommandArgument& argument) const;
bool IsKeyword(std::string const& keyword,
- cmExpandedCommandArgument& argument) const;
-
- bool GetBooleanValue(
- cmExpandedCommandArgument& arg) const;
-
- bool GetBooleanValueOld(
- cmExpandedCommandArgument const& arg, bool one) const;
-
- bool GetBooleanValueWithAutoDereference(
- cmExpandedCommandArgument &newArg,
- std::string &errorString,
- cmake::MessageType &status,
- bool oneArg = false) const;
-
- void IncrementArguments(
- cmArgumentList &newArgs,
- cmArgumentList::iterator &argP1,
- cmArgumentList::iterator &argP2) const;
-
- void HandlePredicate(bool value, int &reducible,
- cmArgumentList::iterator &arg,
- cmArgumentList &newArgs,
- cmArgumentList::iterator &argP1,
- cmArgumentList::iterator &argP2) const;
-
- void HandleBinaryOp(bool value, int &reducible,
- cmArgumentList::iterator &arg,
- cmArgumentList &newArgs,
- cmArgumentList::iterator &argP1,
- cmArgumentList::iterator &argP2);
-
- bool HandleLevel0(cmArgumentList &newArgs,
- std::string &errorString,
- cmake::MessageType &status);
-
- bool HandleLevel1(cmArgumentList &newArgs,
- std::string &, cmake::MessageType &);
-
- bool HandleLevel2(cmArgumentList &newArgs,
- std::string &errorString,
- cmake::MessageType &status);
-
- bool HandleLevel3(cmArgumentList &newArgs,
- std::string &errorString,
- cmake::MessageType &status);
-
- bool HandleLevel4(cmArgumentList &newArgs,
- std::string &errorString,
- cmake::MessageType &status);
+ cmExpandedCommandArgument& argument) const;
+
+ bool GetBooleanValue(cmExpandedCommandArgument& arg) const;
+
+ bool GetBooleanValueOld(cmExpandedCommandArgument const& arg,
+ bool one) const;
+
+ bool GetBooleanValueWithAutoDereference(cmExpandedCommandArgument& newArg,
+ std::string& errorString,
+ cmake::MessageType& status,
+ bool oneArg = false) const;
+
+ void IncrementArguments(cmArgumentList& newArgs,
+ cmArgumentList::iterator& argP1,
+ cmArgumentList::iterator& argP2) const;
+
+ void HandlePredicate(bool value, int& reducible,
+ cmArgumentList::iterator& arg, cmArgumentList& newArgs,
+ cmArgumentList::iterator& argP1,
+ cmArgumentList::iterator& argP2) const;
+
+ void HandleBinaryOp(bool value, int& reducible,
+ cmArgumentList::iterator& arg, cmArgumentList& newArgs,
+ cmArgumentList::iterator& argP1,
+ cmArgumentList::iterator& argP2);
+
+ bool HandleLevel0(cmArgumentList& newArgs, std::string& errorString,
+ cmake::MessageType& status);
+
+ bool HandleLevel1(cmArgumentList& newArgs, std::string&,
+ cmake::MessageType&);
+
+ bool HandleLevel2(cmArgumentList& newArgs, std::string& errorString,
+ cmake::MessageType& status);
+
+ bool HandleLevel3(cmArgumentList& newArgs, std::string& errorString,
+ cmake::MessageType& status);
+
+ bool HandleLevel4(cmArgumentList& newArgs, std::string& errorString,
+ cmake::MessageType& status);
cmMakefile& Makefile;
cmListFileContext ExecutionContext;
diff --git a/Source/cmConfigureFileCommand.cxx b/Source/cmConfigureFileCommand.cxx
index 94c778b..899a674 100644
--- a/Source/cmConfigureFileCommand.cxx
+++ b/Source/cmConfigureFileCommand.cxx
@@ -14,26 +14,23 @@
#include <cmsys/RegularExpression.hxx>
// cmConfigureFileCommand
-bool cmConfigureFileCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmConfigureFileCommand::InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus&)
{
- if(args.size() < 2 )
- {
+ if (args.size() < 2) {
this->SetError("called with incorrect number of arguments, expected 2");
return false;
- }
+ }
const char* inFile = args[0].c_str();
- if(!cmSystemTools::FileIsFullPath(inFile))
- {
+ if (!cmSystemTools::FileIsFullPath(inFile)) {
this->InputFile = this->Makefile->GetCurrentSourceDirectory();
this->InputFile += "/";
- }
+ }
this->InputFile += inFile;
// If the input location is a directory, error out.
- if(cmSystemTools::FileIsDirectory(this->InputFile))
- {
+ if (cmSystemTools::FileIsDirectory(this->InputFile)) {
std::ostringstream e;
/* clang-format off */
e << "input location\n"
@@ -42,92 +39,72 @@ bool cmConfigureFileCommand
/* clang-format on */
this->SetError(e.str());
return false;
- }
+ }
const char* outFile = args[1].c_str();
- if(!cmSystemTools::FileIsFullPath(outFile))
- {
+ if (!cmSystemTools::FileIsFullPath(outFile)) {
this->OutputFile = this->Makefile->GetCurrentBinaryDirectory();
this->OutputFile += "/";
- }
+ }
this->OutputFile += outFile;
// If the output location is already a directory put the file in it.
- if(cmSystemTools::FileIsDirectory(this->OutputFile))
- {
+ if (cmSystemTools::FileIsDirectory(this->OutputFile)) {
this->OutputFile += "/";
this->OutputFile += cmSystemTools::GetFilenameName(inFile);
- }
+ }
- if ( !this->Makefile->CanIWriteThisFile(this->OutputFile.c_str()) )
- {
- std::string e = "attempted to configure a file: " + this->OutputFile
- + " into a source directory.";
+ if (!this->Makefile->CanIWriteThisFile(this->OutputFile.c_str())) {
+ std::string e = "attempted to configure a file: " + this->OutputFile +
+ " into a source directory.";
this->SetError(e);
cmSystemTools::SetFatalErrorOccured();
return false;
- }
+ }
std::string errorMessage;
- if (!this->NewLineStyle.ReadFromArguments(args, errorMessage))
- {
+ if (!this->NewLineStyle.ReadFromArguments(args, errorMessage)) {
this->SetError(errorMessage);
return false;
- }
+ }
this->CopyOnly = false;
this->EscapeQuotes = false;
std::string unknown_args;
this->AtOnly = false;
- for(unsigned int i=2;i < args.size();++i)
- {
- if(args[i] == "COPYONLY")
- {
+ for (unsigned int i = 2; i < args.size(); ++i) {
+ if (args[i] == "COPYONLY") {
this->CopyOnly = true;
- if (this->NewLineStyle.IsValid())
- {
+ if (this->NewLineStyle.IsValid()) {
this->SetError("COPYONLY could not be used in combination "
"with NEWLINE_STYLE");
return false;
- }
}
- else if(args[i] == "ESCAPE_QUOTES")
- {
+ } else if (args[i] == "ESCAPE_QUOTES") {
this->EscapeQuotes = true;
- }
- else if(args[i] == "@ONLY")
- {
+ } else if (args[i] == "@ONLY") {
this->AtOnly = true;
- }
- else if(args[i] == "IMMEDIATE")
- {
+ } else if (args[i] == "IMMEDIATE") {
/* Ignore legacy option. */
- }
- else if(args[i] == "NEWLINE_STYLE" ||
- args[i] == "LF" || args[i] == "UNIX" ||
- args[i] == "CRLF" || args[i] == "WIN32" ||
- args[i] == "DOS")
- {
+ } else if (args[i] == "NEWLINE_STYLE" || args[i] == "LF" ||
+ args[i] == "UNIX" || args[i] == "CRLF" || args[i] == "WIN32" ||
+ args[i] == "DOS") {
/* Options handled by NewLineStyle member above. */
- }
- else
- {
+ } else {
unknown_args += " ";
unknown_args += args[i];
unknown_args += "\n";
- }
}
- if (!unknown_args.empty())
- {
+ }
+ if (!unknown_args.empty()) {
std::string msg = "configure_file called with unknown argument(s):\n";
msg += unknown_args;
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, msg);
- }
+ }
- if ( !this->ConfigureFile() )
- {
+ if (!this->ConfigureFile()) {
this->SetError("Problem configuring file");
return false;
- }
+ }
return true;
}
@@ -135,12 +112,6 @@ bool cmConfigureFileCommand
int cmConfigureFileCommand::ConfigureFile()
{
return this->Makefile->ConfigureFile(
- this->InputFile.c_str(),
- this->OutputFile.c_str(),
- this->CopyOnly,
- this->AtOnly,
- this->EscapeQuotes,
- this->NewLineStyle);
+ this->InputFile.c_str(), this->OutputFile.c_str(), this->CopyOnly,
+ this->AtOnly, this->EscapeQuotes, this->NewLineStyle);
}
-
-
diff --git a/Source/cmConfigureFileCommand.h b/Source/cmConfigureFileCommand.h
index 8155ef7..79f00bc 100644
--- a/Source/cmConfigureFileCommand.h
+++ b/Source/cmConfigureFileCommand.h
@@ -19,22 +19,19 @@ class cmConfigureFileCommand : public cmCommand
public:
cmTypeMacro(cmConfigureFileCommand, cmCommand);
- virtual cmCommand* Clone()
- {
- return new cmConfigureFileCommand;
- }
+ virtual cmCommand* Clone() { return new cmConfigureFileCommand; }
/**
* This is called when the command is first encountered in
* the input file.
*/
virtual bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus &status);
+ cmExecutionStatus& status);
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const { return "configure_file";}
+ virtual std::string GetName() const { return "configure_file"; }
/**
* This determines if the command is invoked when in script mode.
@@ -53,6 +50,4 @@ private:
bool AtOnly;
};
-
-
#endif
diff --git a/Source/cmContinueCommand.cxx b/Source/cmContinueCommand.cxx
index 4a03caa..c8c1b7d 100644
--- a/Source/cmContinueCommand.cxx
+++ b/Source/cmContinueCommand.cxx
@@ -12,28 +12,26 @@
#include "cmContinueCommand.h"
// cmContinueCommand
-bool cmContinueCommand::InitialPass(std::vector<std::string> const &args,
- cmExecutionStatus &status)
+bool cmContinueCommand::InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
- if(!this->Makefile->IsLoopBlock())
- {
+ if (!this->Makefile->IsLoopBlock()) {
this->Makefile->IssueMessage(cmake::FATAL_ERROR,
"A CONTINUE command was found outside of a "
"proper FOREACH or WHILE loop scope.");
cmSystemTools::SetFatalErrorOccured();
return true;
- }
+ }
status.SetContinueInvoked(true);
- if(!args.empty())
- {
+ if (!args.empty()) {
this->Makefile->IssueMessage(cmake::FATAL_ERROR,
"The CONTINUE command does not accept any "
"arguments.");
cmSystemTools::SetFatalErrorOccured();
return true;
- }
+ }
return true;
}
diff --git a/Source/cmContinueCommand.h b/Source/cmContinueCommand.h
index 093b14f..63ae59d 100644
--- a/Source/cmContinueCommand.h
+++ b/Source/cmContinueCommand.h
@@ -25,17 +25,14 @@ public:
/**
* This is a virtual constructor for the command.
*/
- virtual cmCommand* Clone()
- {
- return new cmContinueCommand;
- }
+ virtual cmCommand* Clone() { return new cmContinueCommand; }
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus &status);
+ cmExecutionStatus& status);
/**
* This determines if the command is invoked when in script mode.
@@ -50,6 +47,4 @@ public:
cmTypeMacro(cmContinueCommand, cmCommand);
};
-
-
#endif
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx
index 18dca91..9d83624 100644
--- a/Source/cmCoreTryCompile.cxx
+++ b/Source/cmCoreTryCompile.cxx
@@ -31,30 +31,26 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
cmState::TargetType targetType = cmState::EXECUTABLE;
const char* tt =
this->Makefile->GetDefinition("CMAKE_TRY_COMPILE_TARGET_TYPE");
- if (!isTryRun && tt && *tt)
- {
- if (strcmp(tt, cmState::GetTargetTypeName(cmState::EXECUTABLE)) == 0)
- {
+ if (!isTryRun && tt && *tt) {
+ if (strcmp(tt, cmState::GetTargetTypeName(cmState::EXECUTABLE)) == 0) {
targetType = cmState::EXECUTABLE;
- }
- else if (strcmp(tt,
- cmState::GetTargetTypeName(cmState::STATIC_LIBRARY)) == 0)
- {
+ } else if (strcmp(tt, cmState::GetTargetTypeName(
+ cmState::STATIC_LIBRARY)) == 0) {
targetType = cmState::STATIC_LIBRARY;
- }
- else
- {
+ } else {
this->Makefile->IssueMessage(
- cmake::FATAL_ERROR,
- std::string("Invalid value '") + tt + "' for "
- "CMAKE_TRY_COMPILE_TARGET_TYPE. Only "
- "'" + cmState::GetTargetTypeName(cmState::EXECUTABLE) + "' and "
- "'" + cmState::GetTargetTypeName(cmState::STATIC_LIBRARY) + "' "
- "are allowed."
- );
+ cmake::FATAL_ERROR, std::string("Invalid value '") + tt +
+ "' for "
+ "CMAKE_TRY_COMPILE_TARGET_TYPE. Only "
+ "'" +
+ cmState::GetTargetTypeName(cmState::EXECUTABLE) + "' and "
+ "'" +
+ cmState::GetTargetTypeName(cmState::STATIC_LIBRARY) +
+ "' "
+ "are allowed.");
return -1;
- }
}
+ }
const char* sourceDirectory = argv[2].c_str();
const char* projectName = 0;
@@ -74,213 +70,176 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
bool useSources = argv[2] == "SOURCES";
std::vector<std::string> sources;
- enum Doing { DoingNone, DoingCMakeFlags, DoingCompileDefinitions,
- DoingLinkLibraries, DoingOutputVariable, DoingCopyFile,
- DoingCopyFileError, DoingSources };
- Doing doing = useSources? DoingSources : DoingNone;
- for(size_t i=3; i < argv.size(); ++i)
- {
- if(argv[i] == "CMAKE_FLAGS")
- {
+ enum Doing
+ {
+ DoingNone,
+ DoingCMakeFlags,
+ DoingCompileDefinitions,
+ DoingLinkLibraries,
+ DoingOutputVariable,
+ DoingCopyFile,
+ DoingCopyFileError,
+ DoingSources
+ };
+ Doing doing = useSources ? DoingSources : DoingNone;
+ for (size_t i = 3; i < argv.size(); ++i) {
+ if (argv[i] == "CMAKE_FLAGS") {
doing = DoingCMakeFlags;
- }
- else if(argv[i] == "COMPILE_DEFINITIONS")
- {
+ } else if (argv[i] == "COMPILE_DEFINITIONS") {
doing = DoingCompileDefinitions;
- }
- else if(argv[i] == "LINK_LIBRARIES")
- {
+ } else if (argv[i] == "LINK_LIBRARIES") {
doing = DoingLinkLibraries;
useOldLinkLibs = false;
- }
- else if(argv[i] == "OUTPUT_VARIABLE")
- {
+ } else if (argv[i] == "OUTPUT_VARIABLE") {
doing = DoingOutputVariable;
didOutputVariable = true;
- }
- else if(argv[i] == "COPY_FILE")
- {
+ } else if (argv[i] == "COPY_FILE") {
doing = DoingCopyFile;
didCopyFile = true;
- }
- else if(argv[i] == "COPY_FILE_ERROR")
- {
+ } else if (argv[i] == "COPY_FILE_ERROR") {
doing = DoingCopyFileError;
didCopyFileError = true;
- }
- else if(doing == DoingCMakeFlags)
- {
+ } else if (doing == DoingCMakeFlags) {
cmakeFlags.push_back(argv[i]);
- }
- else if(doing == DoingCompileDefinitions)
- {
+ } else if (doing == DoingCompileDefinitions) {
compileDefs.push_back(argv[i]);
- }
- else if(doing == DoingLinkLibraries)
- {
+ } else if (doing == DoingLinkLibraries) {
libsToLink += "\"" + cmSystemTools::TrimWhitespace(argv[i]) + "\" ";
- if(cmTarget *tgt = this->Makefile->FindTargetToUse(argv[i]))
- {
- switch(tgt->GetType())
- {
+ if (cmTarget* tgt = this->Makefile->FindTargetToUse(argv[i])) {
+ switch (tgt->GetType()) {
case cmState::SHARED_LIBRARY:
case cmState::STATIC_LIBRARY:
case cmState::INTERFACE_LIBRARY:
case cmState::UNKNOWN_LIBRARY:
break;
case cmState::EXECUTABLE:
- if (tgt->IsExecutableWithExports())
- {
+ if (tgt->IsExecutableWithExports()) {
break;
- }
+ }
default:
- this->Makefile->IssueMessage(cmake::FATAL_ERROR,
+ this->Makefile->IssueMessage(
+ cmake::FATAL_ERROR,
"Only libraries may be used as try_compile or try_run IMPORTED "
- "LINK_LIBRARIES. Got " + std::string(tgt->GetName()) + " of "
- "type " + cmState::GetTargetTypeName(tgt->GetType()) + ".");
+ "LINK_LIBRARIES. Got " +
+ std::string(tgt->GetName()) + " of "
+ "type " +
+ cmState::GetTargetTypeName(tgt->GetType()) + ".");
return -1;
- }
- if (tgt->IsImported())
- {
+ }
+ if (tgt->IsImported()) {
targets.push_back(argv[i]);
- }
}
}
- else if(doing == DoingOutputVariable)
- {
+ } else if (doing == DoingOutputVariable) {
outputVariable = argv[i].c_str();
doing = DoingNone;
- }
- else if(doing == DoingCopyFile)
- {
+ } else if (doing == DoingCopyFile) {
copyFile = argv[i].c_str();
doing = DoingNone;
- }
- else if(doing == DoingCopyFileError)
- {
+ } else if (doing == DoingCopyFileError) {
copyFileError = argv[i].c_str();
doing = DoingNone;
- }
- else if(doing == DoingSources)
- {
+ } else if (doing == DoingSources) {
sources.push_back(argv[i]);
- }
- else if(i == 3)
- {
+ } else if (i == 3) {
this->SrcFileSignature = false;
projectName = argv[i].c_str();
- }
- else if(i == 4 && !this->SrcFileSignature)
- {
+ } else if (i == 4 && !this->SrcFileSignature) {
targetName = argv[i].c_str();
- }
- else
- {
+ } else {
std::ostringstream m;
m << "try_compile given unknown argument \"" << argv[i] << "\".";
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, m.str());
- }
}
+ }
- if(didCopyFile && copyFile.empty())
- {
+ if (didCopyFile && copyFile.empty()) {
this->Makefile->IssueMessage(cmake::FATAL_ERROR,
- "COPY_FILE must be followed by a file path");
+ "COPY_FILE must be followed by a file path");
return -1;
- }
+ }
- if(didCopyFileError && copyFileError.empty())
- {
- this->Makefile->IssueMessage(cmake::FATAL_ERROR,
+ if (didCopyFileError && copyFileError.empty()) {
+ this->Makefile->IssueMessage(
+ cmake::FATAL_ERROR,
"COPY_FILE_ERROR must be followed by a variable name");
return -1;
- }
+ }
- if(didCopyFileError && !didCopyFile)
- {
- this->Makefile->IssueMessage(cmake::FATAL_ERROR,
- "COPY_FILE_ERROR may be used only with COPY_FILE");
+ if (didCopyFileError && !didCopyFile) {
+ this->Makefile->IssueMessage(
+ cmake::FATAL_ERROR, "COPY_FILE_ERROR may be used only with COPY_FILE");
return -1;
- }
+ }
- if(didOutputVariable && outputVariable.empty())
- {
- this->Makefile->IssueMessage(cmake::FATAL_ERROR,
+ if (didOutputVariable && outputVariable.empty()) {
+ this->Makefile->IssueMessage(
+ cmake::FATAL_ERROR,
"OUTPUT_VARIABLE must be followed by a variable name");
return -1;
- }
+ }
- if(useSources && sources.empty())
- {
- this->Makefile->IssueMessage(cmake::FATAL_ERROR,
+ if (useSources && sources.empty()) {
+ this->Makefile->IssueMessage(
+ cmake::FATAL_ERROR,
"SOURCES must be followed by at least one source file");
return -1;
- }
+ }
// compute the binary dir when TRY_COMPILE is called with a src file
// signature
- if (this->SrcFileSignature)
- {
+ if (this->SrcFileSignature) {
this->BinaryDirectory += cmake::GetCMakeFilesDirectory();
this->BinaryDirectory += "/CMakeTmp";
- }
- else
- {
+ } else {
// only valid for srcfile signatures
- if (!compileDefs.empty())
- {
- this->Makefile->IssueMessage(cmake::FATAL_ERROR,
+ if (!compileDefs.empty()) {
+ this->Makefile->IssueMessage(
+ cmake::FATAL_ERROR,
"COMPILE_DEFINITIONS specified on a srcdir type TRY_COMPILE");
return -1;
- }
- if (!copyFile.empty())
- {
- this->Makefile->IssueMessage(cmake::FATAL_ERROR,
+ }
+ if (!copyFile.empty()) {
+ this->Makefile->IssueMessage(
+ cmake::FATAL_ERROR,
"COPY_FILE specified on a srcdir type TRY_COMPILE");
return -1;
- }
}
+ }
// make sure the binary directory exists
cmSystemTools::MakeDirectory(this->BinaryDirectory.c_str());
// do not allow recursive try Compiles
- if (this->BinaryDirectory == this->Makefile->GetHomeOutputDirectory())
- {
+ if (this->BinaryDirectory == this->Makefile->GetHomeOutputDirectory()) {
std::ostringstream e;
e << "Attempt at a recursive or nested TRY_COMPILE in directory\n"
<< " " << this->BinaryDirectory << "\n";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
return -1;
- }
+ }
std::string outFileName = this->BinaryDirectory + "/CMakeLists.txt";
// which signature are we using? If we are using var srcfile bindir
- if (this->SrcFileSignature)
- {
+ if (this->SrcFileSignature) {
// remove any CMakeCache.txt files so we will have a clean test
std::string ccFile = this->BinaryDirectory + "/CMakeCache.txt";
cmSystemTools::RemoveFile(ccFile);
// Choose sources.
- if(!useSources)
- {
+ if (!useSources) {
sources.push_back(argv[2]);
- }
+ }
// Detect languages to enable.
cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator();
std::set<std::string> testLangs;
- for(std::vector<std::string>::iterator si = sources.begin();
- si != sources.end(); ++si)
- {
+ for (std::vector<std::string>::iterator si = sources.begin();
+ si != sources.end(); ++si) {
std::string ext = cmSystemTools::GetFilenameLastExtension(*si);
std::string lang = gg->GetLanguageFromExtension(ext.c_str());
- if(!lang.empty())
- {
+ if (!lang.empty()) {
testLangs.insert(lang);
- }
- else
- {
+ } else {
std::ostringstream err;
err << "Unknown extension \"" << ext << "\" for file\n"
<< " " << *si << "\n"
@@ -292,8 +251,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
err << "\nSee project() command to enable other languages.";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, err.str());
return -1;
- }
}
+ }
std::string const tcConfig =
this->Makefile->GetSafeDefinition("CMAKE_TRY_COMPILE_CONFIGURATION");
@@ -303,9 +262,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
sourceDirectory = this->BinaryDirectory.c_str();
// now create a CMakeLists.txt file in that directory
- FILE *fout = cmsys::SystemTools::Fopen(outFileName,"w");
- if (!fout)
- {
+ FILE* fout = cmsys::SystemTools::Fopen(outFileName, "w");
+ if (!fout) {
std::ostringstream e;
/* clang-format off */
e << "Failed to open\n"
@@ -314,62 +272,56 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
/* clang-format on */
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
return -1;
- }
+ }
const char* def = this->Makefile->GetDefinition("CMAKE_MODULE_PATH");
fprintf(fout, "cmake_minimum_required(VERSION %u.%u.%u.%u)\n",
cmVersion::GetMajorVersion(), cmVersion::GetMinorVersion(),
cmVersion::GetPatchVersion(), cmVersion::GetTweakVersion());
- if(def)
- {
+ if (def) {
fprintf(fout, "set(CMAKE_MODULE_PATH \"%s\")\n", def);
- }
+ }
std::string projectLangs;
- for(std::set<std::string>::iterator li = testLangs.begin();
- li != testLangs.end(); ++li)
- {
+ for (std::set<std::string>::iterator li = testLangs.begin();
+ li != testLangs.end(); ++li) {
projectLangs += " " + *li;
std::string rulesOverrideBase = "CMAKE_USER_MAKE_RULES_OVERRIDE";
std::string rulesOverrideLang = rulesOverrideBase + "_" + *li;
- if(const char* rulesOverridePath =
- this->Makefile->GetDefinition(rulesOverrideLang))
- {
- fprintf(fout, "set(%s \"%s\")\n",
- rulesOverrideLang.c_str(), rulesOverridePath);
- }
- else if(const char* rulesOverridePath2 =
- this->Makefile->GetDefinition(rulesOverrideBase))
- {
- fprintf(fout, "set(%s \"%s\")\n",
- rulesOverrideBase.c_str(), rulesOverridePath2);
- }
+ if (const char* rulesOverridePath =
+ this->Makefile->GetDefinition(rulesOverrideLang)) {
+ fprintf(fout, "set(%s \"%s\")\n", rulesOverrideLang.c_str(),
+ rulesOverridePath);
+ } else if (const char* rulesOverridePath2 =
+ this->Makefile->GetDefinition(rulesOverrideBase)) {
+ fprintf(fout, "set(%s \"%s\")\n", rulesOverrideBase.c_str(),
+ rulesOverridePath2);
}
+ }
fprintf(fout, "project(CMAKE_TRY_COMPILE%s)\n", projectLangs.c_str());
fprintf(fout, "set(CMAKE_VERBOSE_MAKEFILE 1)\n");
- for(std::set<std::string>::iterator li = testLangs.begin();
- li != testLangs.end(); ++li)
- {
+ for (std::set<std::string>::iterator li = testLangs.begin();
+ li != testLangs.end(); ++li) {
std::string langFlags = "CMAKE_" + *li + "_FLAGS";
const char* flags = this->Makefile->GetDefinition(langFlags);
fprintf(fout, "set(CMAKE_%s_FLAGS %s)\n", li->c_str(),
- cmOutputConverter::EscapeForCMake(flags?flags:"").c_str());
+ cmOutputConverter::EscapeForCMake(flags ? flags : "").c_str());
fprintf(fout, "set(CMAKE_%s_FLAGS \"${CMAKE_%s_FLAGS}"
- " ${COMPILE_DEFINITIONS}\")\n", li->c_str(), li->c_str());
+ " ${COMPILE_DEFINITIONS}\")\n",
+ li->c_str(), li->c_str());
static std::string const cfgDefault = "DEBUG";
- std::string const cfg = !tcConfig.empty()?
- cmSystemTools::UpperCase(tcConfig) : cfgDefault;
+ std::string const cfg =
+ !tcConfig.empty() ? cmSystemTools::UpperCase(tcConfig) : cfgDefault;
std::string const langFlagsCfg = "CMAKE_" + *li + "_FLAGS_" + cfg;
const char* flagsCfg = this->Makefile->GetDefinition(langFlagsCfg);
- fprintf(fout, "set(%s %s)\n", langFlagsCfg.c_str(),
- cmOutputConverter::EscapeForCMake(flagsCfg?flagsCfg:"").c_str());
- }
- switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0056))
- {
+ fprintf(
+ fout, "set(%s %s)\n", langFlagsCfg.c_str(),
+ cmOutputConverter::EscapeForCMake(flagsCfg ? flagsCfg : "").c_str());
+ }
+ switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0056)) {
case cmPolicies::WARN:
- if(this->Makefile->PolicyOptionalWarningEnabled(
- "CMAKE_POLICY_WARNING_CMP0056"))
- {
+ if (this->Makefile->PolicyOptionalWarningEnabled(
+ "CMAKE_POLICY_WARNING_CMP0056")) {
std::ostringstream w;
/* clang-format off */
w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0056) << "\n"
@@ -379,7 +331,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
;
/* clang-format on */
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str());
- }
+ }
case cmPolicies::OLD:
// OLD behavior is to do nothing.
break;
@@ -387,53 +339,49 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
case cmPolicies::REQUIRED_ALWAYS:
this->Makefile->IssueMessage(
cmake::FATAL_ERROR,
- cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0056)
- );
+ cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0056));
case cmPolicies::NEW:
// NEW behavior is to pass linker flags.
{
- const char* exeLinkFlags =
- this->Makefile->GetDefinition("CMAKE_EXE_LINKER_FLAGS");
- fprintf(fout, "set(CMAKE_EXE_LINKER_FLAGS %s)\n",
- cmOutputConverter::EscapeForCMake(
- exeLinkFlags ? exeLinkFlags : "").c_str());
- } break;
- }
+ const char* exeLinkFlags =
+ this->Makefile->GetDefinition("CMAKE_EXE_LINKER_FLAGS");
+ fprintf(
+ fout, "set(CMAKE_EXE_LINKER_FLAGS %s)\n",
+ cmOutputConverter::EscapeForCMake(exeLinkFlags ? exeLinkFlags : "")
+ .c_str());
+ }
+ break;
+ }
fprintf(fout, "set(CMAKE_EXE_LINKER_FLAGS \"${CMAKE_EXE_LINKER_FLAGS}"
- " ${EXE_LINKER_FLAGS}\")\n");
+ " ${EXE_LINKER_FLAGS}\")\n");
fprintf(fout, "include_directories(${INCLUDE_DIRECTORIES})\n");
fprintf(fout, "set(CMAKE_SUPPRESS_REGENERATION 1)\n");
fprintf(fout, "link_directories(${LINK_DIRECTORIES})\n");
// handle any compile flags we need to pass on
- if (!compileDefs.empty())
- {
+ if (!compileDefs.empty()) {
fprintf(fout, "add_definitions(%s)\n", cmJoin(compileDefs, " ").c_str());
- }
+ }
/* Use a random file name to avoid rapid creation and deletion
of the same executable name (some filesystems fail on that). */
- sprintf(targetNameBuf, "cmTC_%05x",
- cmSystemTools::RandomSeed() & 0xFFFFF);
+ sprintf(targetNameBuf, "cmTC_%05x", cmSystemTools::RandomSeed() & 0xFFFFF);
targetName = targetNameBuf;
- if (!targets.empty())
- {
+ if (!targets.empty()) {
std::string fname = "/" + std::string(targetName) + "Targets.cmake";
cmExportTryCompileFileGenerator tcfg(gg, targets, this->Makefile);
tcfg.SetExportFile((this->BinaryDirectory + fname).c_str());
tcfg.SetConfig(tcConfig);
- if(!tcfg.GenerateImportFile())
- {
+ if (!tcfg.GenerateImportFile()) {
this->Makefile->IssueMessage(cmake::FATAL_ERROR,
"could not write export file.");
fclose(fout);
return -1;
- }
- fprintf(fout,
- "\ninclude(\"${CMAKE_CURRENT_LIST_DIR}/%s\")\n\n",
- fname.c_str());
}
+ fprintf(fout, "\ninclude(\"${CMAKE_CURRENT_LIST_DIR}/%s\")\n\n",
+ fname.c_str());
+ }
/* for the TRY_COMPILEs we want to be able to specify the architecture.
So the user can set CMAKE_OSX_ARCHITECTURES to i386;ppc and then set
@@ -442,175 +390,144 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
cmLocalGenerator doesn't allow building for "the other"
architecture only via CMAKE_OSX_ARCHITECTURES.
*/
- if(this->Makefile->GetDefinition("CMAKE_TRY_COMPILE_OSX_ARCHITECTURES")!=0)
- {
- std::string flag="-DCMAKE_OSX_ARCHITECTURES=";
+ if (this->Makefile->GetDefinition("CMAKE_TRY_COMPILE_OSX_ARCHITECTURES") !=
+ 0) {
+ std::string flag = "-DCMAKE_OSX_ARCHITECTURES=";
flag += this->Makefile->GetSafeDefinition(
- "CMAKE_TRY_COMPILE_OSX_ARCHITECTURES");
+ "CMAKE_TRY_COMPILE_OSX_ARCHITECTURES");
cmakeFlags.push_back(flag);
- }
- else if (this->Makefile->GetDefinition("CMAKE_OSX_ARCHITECTURES")!=0)
- {
- std::string flag="-DCMAKE_OSX_ARCHITECTURES=";
+ } else if (this->Makefile->GetDefinition("CMAKE_OSX_ARCHITECTURES") != 0) {
+ std::string flag = "-DCMAKE_OSX_ARCHITECTURES=";
flag += this->Makefile->GetSafeDefinition("CMAKE_OSX_ARCHITECTURES");
cmakeFlags.push_back(flag);
- }
+ }
/* on APPLE also pass CMAKE_OSX_SYSROOT to the try_compile */
- if(this->Makefile->GetDefinition("CMAKE_OSX_SYSROOT")!=0)
- {
- std::string flag="-DCMAKE_OSX_SYSROOT=";
+ if (this->Makefile->GetDefinition("CMAKE_OSX_SYSROOT") != 0) {
+ std::string flag = "-DCMAKE_OSX_SYSROOT=";
flag += this->Makefile->GetSafeDefinition("CMAKE_OSX_SYSROOT");
cmakeFlags.push_back(flag);
- }
+ }
/* on APPLE also pass CMAKE_OSX_DEPLOYMENT_TARGET to the try_compile */
- if(this->Makefile->GetDefinition("CMAKE_OSX_DEPLOYMENT_TARGET")!=0)
- {
- std::string flag="-DCMAKE_OSX_DEPLOYMENT_TARGET=";
+ if (this->Makefile->GetDefinition("CMAKE_OSX_DEPLOYMENT_TARGET") != 0) {
+ std::string flag = "-DCMAKE_OSX_DEPLOYMENT_TARGET=";
flag += this->Makefile->GetSafeDefinition("CMAKE_OSX_DEPLOYMENT_TARGET");
cmakeFlags.push_back(flag);
- }
- if (const char *cxxDef
- = this->Makefile->GetDefinition("CMAKE_CXX_COMPILER_TARGET"))
- {
- std::string flag="-DCMAKE_CXX_COMPILER_TARGET=";
+ }
+ if (const char* cxxDef =
+ this->Makefile->GetDefinition("CMAKE_CXX_COMPILER_TARGET")) {
+ std::string flag = "-DCMAKE_CXX_COMPILER_TARGET=";
flag += cxxDef;
cmakeFlags.push_back(flag);
- }
- if (const char *cDef
- = this->Makefile->GetDefinition("CMAKE_C_COMPILER_TARGET"))
- {
- std::string flag="-DCMAKE_C_COMPILER_TARGET=";
+ }
+ if (const char* cDef =
+ this->Makefile->GetDefinition("CMAKE_C_COMPILER_TARGET")) {
+ std::string flag = "-DCMAKE_C_COMPILER_TARGET=";
flag += cDef;
cmakeFlags.push_back(flag);
- }
- if (const char *tcxxDef = this->Makefile->GetDefinition(
- "CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN"))
- {
- std::string flag="-DCMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN=";
+ }
+ if (const char* tcxxDef = this->Makefile->GetDefinition(
+ "CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN")) {
+ std::string flag = "-DCMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN=";
flag += tcxxDef;
cmakeFlags.push_back(flag);
- }
- if (const char *tcDef = this->Makefile->GetDefinition(
- "CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN"))
- {
- std::string flag="-DCMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN=";
+ }
+ if (const char* tcDef = this->Makefile->GetDefinition(
+ "CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN")) {
+ std::string flag = "-DCMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN=";
flag += tcDef;
cmakeFlags.push_back(flag);
- }
- if (const char *rootDef
- = this->Makefile->GetDefinition("CMAKE_SYSROOT"))
- {
- std::string flag="-DCMAKE_SYSROOT=";
+ }
+ if (const char* rootDef = this->Makefile->GetDefinition("CMAKE_SYSROOT")) {
+ std::string flag = "-DCMAKE_SYSROOT=";
flag += rootDef;
cmakeFlags.push_back(flag);
- }
- if(this->Makefile->GetDefinition("CMAKE_POSITION_INDEPENDENT_CODE")!=0)
- {
+ }
+ if (this->Makefile->GetDefinition("CMAKE_POSITION_INDEPENDENT_CODE") !=
+ 0) {
fprintf(fout, "set(CMAKE_POSITION_INDEPENDENT_CODE \"ON\")\n");
- }
- if (const char *lssDef = this->Makefile->GetDefinition(
- "CMAKE_LINK_SEARCH_START_STATIC"))
- {
+ }
+ if (const char* lssDef =
+ this->Makefile->GetDefinition("CMAKE_LINK_SEARCH_START_STATIC")) {
fprintf(fout, "set(CMAKE_LINK_SEARCH_START_STATIC \"%s\")\n", lssDef);
- }
- if (const char *lssDef = this->Makefile->GetDefinition(
- "CMAKE_LINK_SEARCH_END_STATIC"))
- {
+ }
+ if (const char* lssDef =
+ this->Makefile->GetDefinition("CMAKE_LINK_SEARCH_END_STATIC")) {
fprintf(fout, "set(CMAKE_LINK_SEARCH_END_STATIC \"%s\")\n", lssDef);
- }
+ }
/* Set the appropriate policy information for ENABLE_EXPORTS */
fprintf(fout, "cmake_policy(SET CMP0065 %s)\n",
- this->Makefile->GetPolicyStatus(cmPolicies::CMP0065) ==
- cmPolicies::NEW ? "NEW" : "OLD");
- if(const char *ee = this->Makefile->GetDefinition(
- "CMAKE_ENABLE_EXPORTS"))
- {
+ this->Makefile->GetPolicyStatus(cmPolicies::CMP0065) ==
+ cmPolicies::NEW
+ ? "NEW"
+ : "OLD");
+ if (const char* ee =
+ this->Makefile->GetDefinition("CMAKE_ENABLE_EXPORTS")) {
fprintf(fout, "set(CMAKE_ENABLE_EXPORTS %s)\n", ee);
- }
+ }
- if (targetType == cmState::EXECUTABLE)
- {
+ if (targetType == cmState::EXECUTABLE) {
/* Put the executable at a known location (for COPY_FILE). */
fprintf(fout, "set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"%s\")\n",
this->BinaryDirectory.c_str());
/* Create the actual executable. */
fprintf(fout, "add_executable(%s", targetName.c_str());
- }
- else // if (targetType == cmState::STATIC_LIBRARY)
- {
+ } else // if (targetType == cmState::STATIC_LIBRARY)
+ {
/* Put the static library at a known location (for COPY_FILE). */
fprintf(fout, "set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY \"%s\")\n",
this->BinaryDirectory.c_str());
/* Create the actual static library. */
fprintf(fout, "add_library(%s STATIC", targetName.c_str());
- }
- for(std::vector<std::string>::iterator si = sources.begin();
- si != sources.end(); ++si)
- {
+ }
+ for (std::vector<std::string>::iterator si = sources.begin();
+ si != sources.end(); ++si) {
fprintf(fout, " \"%s\"", si->c_str());
// Add dependencies on any non-temporary sources.
- if(si->find("CMakeTmp") == si->npos)
- {
+ if (si->find("CMakeTmp") == si->npos) {
this->Makefile->AddCMakeDependFile(*si);
- }
}
+ }
fprintf(fout, ")\n");
- if (useOldLinkLibs)
- {
- fprintf(fout,
- "target_link_libraries(%s ${LINK_LIBRARIES})\n",
+ if (useOldLinkLibs) {
+ fprintf(fout, "target_link_libraries(%s ${LINK_LIBRARIES})\n",
targetName.c_str());
- }
- else
- {
- fprintf(fout, "target_link_libraries(%s %s)\n",
- targetName.c_str(),
+ } else {
+ fprintf(fout, "target_link_libraries(%s %s)\n", targetName.c_str(),
libsToLink.c_str());
- }
+ }
fclose(fout);
projectName = "CMAKE_TRY_COMPILE";
- }
+ }
bool erroroc = cmSystemTools::GetErrorOccuredFlag();
cmSystemTools::ResetErrorOccuredFlag();
std::string output;
// actually do the try compile now that everything is setup
- int res = this->Makefile->TryCompile(sourceDirectory,
- this->BinaryDirectory,
- projectName,
- targetName,
- this->SrcFileSignature,
- &cmakeFlags,
- output);
- if ( erroroc )
- {
+ int res = this->Makefile->TryCompile(
+ sourceDirectory, this->BinaryDirectory, projectName, targetName,
+ this->SrcFileSignature, &cmakeFlags, output);
+ if (erroroc) {
cmSystemTools::SetErrorOccured();
- }
+ }
// set the result var to the return value to indicate success or failure
- this->Makefile->AddCacheDefinition(argv[0],
- (res == 0 ? "TRUE" : "FALSE"),
+ this->Makefile->AddCacheDefinition(argv[0], (res == 0 ? "TRUE" : "FALSE"),
"Result of TRY_COMPILE",
cmState::INTERNAL);
- if (!outputVariable.empty())
- {
+ if (!outputVariable.empty()) {
this->Makefile->AddDefinition(outputVariable, output.c_str());
- }
+ }
- if (this->SrcFileSignature)
- {
+ if (this->SrcFileSignature) {
std::string copyFileErrorMessage;
this->FindOutputFile(targetName, targetType);
- if ((res==0) && !copyFile.empty())
- {
- if(this->OutputFile.empty() ||
- !cmSystemTools::CopyFileAlways(this->OutputFile,
- copyFile))
- {
+ if ((res == 0) && !copyFile.empty()) {
+ if (this->OutputFile.empty() ||
+ !cmSystemTools::CopyFileAlways(this->OutputFile, copyFile)) {
std::ostringstream emsg;
/* clang-format off */
emsg << "Cannot copy output executable\n"
@@ -618,93 +535,81 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
<< "to destination specified by COPY_FILE:\n"
<< " '" << copyFile << "'\n";
/* clang-format on */
- if(!this->FindErrorMessage.empty())
- {
+ if (!this->FindErrorMessage.empty()) {
emsg << this->FindErrorMessage.c_str();
- }
- if(copyFileError.empty())
- {
+ }
+ if (copyFileError.empty()) {
this->Makefile->IssueMessage(cmake::FATAL_ERROR, emsg.str());
return -1;
- }
- else
- {
+ } else {
copyFileErrorMessage = emsg.str();
- }
}
}
+ }
- if(!copyFileError.empty())
- {
+ if (!copyFileError.empty()) {
this->Makefile->AddDefinition(copyFileError,
copyFileErrorMessage.c_str());
- }
}
+ }
return res;
}
void cmCoreTryCompile::CleanupFiles(const char* binDir)
{
- if ( !binDir )
- {
+ if (!binDir) {
return;
- }
+ }
std::string bdir = binDir;
- if(bdir.find("CMakeTmp") == std::string::npos)
- {
+ if (bdir.find("CMakeTmp") == std::string::npos) {
cmSystemTools::Error(
"TRY_COMPILE attempt to remove -rf directory that does not contain "
- "CMakeTmp:", binDir);
+ "CMakeTmp:",
+ binDir);
return;
- }
+ }
cmsys::Directory dir;
dir.Load(binDir);
size_t fileNum;
std::set<std::string> deletedFiles;
- for (fileNum = 0; fileNum < dir.GetNumberOfFiles(); ++fileNum)
- {
- if (strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)),".") &&
- strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)),".."))
- {
+ for (fileNum = 0; fileNum < dir.GetNumberOfFiles(); ++fileNum) {
+ if (strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), ".") &&
+ strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), "..")) {
- if(deletedFiles.find( dir.GetFile(static_cast<unsigned long>(fileNum)))
- == deletedFiles.end())
- {
+ if (deletedFiles.find(dir.GetFile(
+ static_cast<unsigned long>(fileNum))) == deletedFiles.end()) {
deletedFiles.insert(dir.GetFile(static_cast<unsigned long>(fileNum)));
std::string fullPath = binDir;
fullPath += "/";
fullPath += dir.GetFile(static_cast<unsigned long>(fileNum));
- if(cmSystemTools::FileIsDirectory(fullPath))
- {
+ if (cmSystemTools::FileIsDirectory(fullPath)) {
this->CleanupFiles(fullPath.c_str());
cmSystemTools::RemoveADirectory(fullPath);
- }
- else
- {
+ } else {
#ifdef _WIN32
// Sometimes anti-virus software hangs on to new files so we
// cannot delete them immediately. Try a few times.
cmSystemTools::WindowsFileRetry retry =
cmSystemTools::GetWindowsFileRetry();
- while(!cmSystemTools::RemoveFile(fullPath.c_str()) &&
- --retry.Count && cmSystemTools::FileExists(fullPath.c_str()))
- {
+ while (!cmSystemTools::RemoveFile(fullPath.c_str()) &&
+ --retry.Count &&
+ cmSystemTools::FileExists(fullPath.c_str())) {
cmSystemTools::Delay(retry.Delay);
- }
- if(retry.Count == 0)
+ }
+ if (retry.Count == 0)
#else
- if(!cmSystemTools::RemoveFile(fullPath))
+ if (!cmSystemTools::RemoveFile(fullPath))
#endif
- {
+ {
std::string m = "Remove failed on file: " + fullPath;
cmSystemTools::ReportLastSystemError(m.c_str());
- }
}
}
}
}
+ }
}
void cmCoreTryCompile::FindOutputFile(const std::string& targetName,
@@ -713,35 +618,32 @@ void cmCoreTryCompile::FindOutputFile(const std::string& targetName,
this->FindErrorMessage = "";
this->OutputFile = "";
std::string tmpOutputFile = "/";
- if (targetType == cmState::EXECUTABLE)
- {
+ if (targetType == cmState::EXECUTABLE) {
tmpOutputFile += targetName;
tmpOutputFile +=
this->Makefile->GetSafeDefinition("CMAKE_EXECUTABLE_SUFFIX");
- }
- else // if (targetType == cmState::STATIC_LIBRARY)
- {
+ } else // if (targetType == cmState::STATIC_LIBRARY)
+ {
tmpOutputFile +=
this->Makefile->GetSafeDefinition("CMAKE_STATIC_LIBRARY_PREFIX");
tmpOutputFile += targetName;
tmpOutputFile +=
this->Makefile->GetSafeDefinition("CMAKE_STATIC_LIBRARY_SUFFIX");
- }
+ }
// a list of directories where to search for the compilation result
// at first directly in the binary dir
std::vector<std::string> searchDirs;
searchDirs.push_back("");
- const char* config = this->Makefile->GetDefinition(
- "CMAKE_TRY_COMPILE_CONFIGURATION");
+ const char* config =
+ this->Makefile->GetDefinition("CMAKE_TRY_COMPILE_CONFIGURATION");
// if a config was specified try that first
- if (config && config[0])
- {
+ if (config && config[0]) {
std::string tmp = "/";
tmp += config;
searchDirs.push_back(tmp);
- }
+ }
searchDirs.push_back("/Debug");
#if defined(__APPLE__)
std::string app = "/Debug/" + targetName + ".app";
@@ -749,25 +651,21 @@ void cmCoreTryCompile::FindOutputFile(const std::string& targetName,
#endif
searchDirs.push_back("/Development");
- for(std::vector<std::string>::const_iterator it = searchDirs.begin();
- it != searchDirs.end();
- ++it)
- {
+ for (std::vector<std::string>::const_iterator it = searchDirs.begin();
+ it != searchDirs.end(); ++it) {
std::string command = this->BinaryDirectory;
command += *it;
command += tmpOutputFile;
- if(cmSystemTools::FileExists(command.c_str()))
- {
+ if (cmSystemTools::FileExists(command.c_str())) {
this->OutputFile = cmSystemTools::CollapseFullPath(command);
return;
- }
}
+ }
std::ostringstream emsg;
emsg << "Unable to find the executable at any of:\n";
- emsg << cmWrap(" " + this->BinaryDirectory,
- searchDirs,
- tmpOutputFile, "\n") << "\n";
+ emsg << cmWrap(" " + this->BinaryDirectory, searchDirs, tmpOutputFile, "\n")
+ << "\n";
this->FindErrorMessage = emsg.str();
return;
}
diff --git a/Source/cmCoreTryCompile.h b/Source/cmCoreTryCompile.h
index c2beea8..6a3b049 100644
--- a/Source/cmCoreTryCompile.h
+++ b/Source/cmCoreTryCompile.h
@@ -23,8 +23,7 @@
class cmCoreTryCompile : public cmCommand
{
public:
-
- protected:
+protected:
/**
* This is the core code for try compile. It is here so that other
* commands, such as TryRun can access the same logic without
@@ -53,8 +52,6 @@ public:
std::string OutputFile;
std::string FindErrorMessage;
bool SrcFileSignature;
-
};
-
#endif
diff --git a/Source/cmCreateTestSourceList.cxx b/Source/cmCreateTestSourceList.cxx
index 65eee34..6f7cfbe 100644
--- a/Source/cmCreateTestSourceList.cxx
+++ b/Source/cmCreateTestSourceList.cxx
@@ -14,51 +14,41 @@
#include "cmSourceFile.h"
// cmCreateTestSourceList
-bool cmCreateTestSourceList
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus&)
{
- if (args.size() < 3)
- {
+ if (args.size() < 3) {
this->SetError("called with wrong number of arguments.");
return false;
- }
-
+ }
std::vector<std::string>::const_iterator i = args.begin();
std::string extraInclude;
std::string function;
std::vector<std::string> tests;
// extract extra include and function ot
- for(; i != args.end(); i++)
- {
- if(*i == "EXTRA_INCLUDE")
- {
+ for (; i != args.end(); i++) {
+ if (*i == "EXTRA_INCLUDE") {
++i;
- if(i == args.end())
- {
+ if (i == args.end()) {
this->SetError("incorrect arguments to EXTRA_INCLUDE");
return false;
- }
+ }
extraInclude = "#include \"";
extraInclude += *i;
extraInclude += "\"\n";
- }
- else if(*i == "FUNCTION")
- {
+ } else if (*i == "FUNCTION") {
++i;
- if(i == args.end())
- {
+ if (i == args.end()) {
this->SetError("incorrect arguments to FUNCTION");
return false;
- }
+ }
function = *i;
function += "(&ac, &av);\n";
- }
- else
- {
+ } else {
tests.push_back(*i);
- }
}
+ }
i = tests.begin();
// Name of the source list
@@ -68,12 +58,11 @@ bool cmCreateTestSourceList
// Name of the test driver
// make sure they specified an extension
- if (cmSystemTools::GetFilenameExtension(*i).size() < 2)
- {
+ if (cmSystemTools::GetFilenameExtension(*i).size() < 2) {
this->SetError(
"You must specify a file extension for the test driver file.");
return false;
- }
+ }
std::string driver = this->Makefile->GetCurrentBinaryDirectory();
driver += "/";
driver += *i;
@@ -94,22 +83,17 @@ bool cmCreateTestSourceList
// For the moment:
// - replace spaces ' ', ':' and '/' with underscores '_'
std::string forwardDeclareCode;
- for(i = testsBegin; i != tests.end(); ++i)
- {
- if(*i == "EXTRA_INCLUDE")
- {
+ for (i = testsBegin; i != tests.end(); ++i) {
+ if (*i == "EXTRA_INCLUDE") {
break;
- }
+ }
std::string func_name;
- if (!cmSystemTools::GetFilenamePath(*i).empty())
- {
+ if (!cmSystemTools::GetFilenamePath(*i).empty()) {
func_name = cmSystemTools::GetFilenamePath(*i) + "/" +
cmSystemTools::GetFilenameWithoutLastExtension(*i);
- }
- else
- {
+ } else {
func_name = cmSystemTools::GetFilenameWithoutLastExtension(*i);
- }
+ }
cmSystemTools::ConvertToUnixSlashes(func_name);
cmSystemTools::ReplaceString(func_name, " ", "_");
cmSystemTools::ReplaceString(func_name, "/", "_");
@@ -118,72 +102,62 @@ bool cmCreateTestSourceList
forwardDeclareCode += "int ";
forwardDeclareCode += func_name;
forwardDeclareCode += "(int, char*[]);\n";
- }
+ }
std::string functionMapCode;
int numTests = 0;
std::vector<std::string>::iterator j;
- for(i = testsBegin, j = tests_func_name.begin(); i != tests.end(); ++i, ++j)
- {
+ for (i = testsBegin, j = tests_func_name.begin(); i != tests.end();
+ ++i, ++j) {
std::string func_name;
- if (!cmSystemTools::GetFilenamePath(*i).empty())
- {
+ if (!cmSystemTools::GetFilenamePath(*i).empty()) {
func_name = cmSystemTools::GetFilenamePath(*i) + "/" +
cmSystemTools::GetFilenameWithoutLastExtension(*i);
- }
- else
- {
+ } else {
func_name = cmSystemTools::GetFilenameWithoutLastExtension(*i);
- }
+ }
functionMapCode += " {\n"
- " \"";
+ " \"";
functionMapCode += func_name;
functionMapCode += "\",\n"
- " ";
- functionMapCode += *j;
+ " ";
+ functionMapCode += *j;
functionMapCode += "\n"
- " },\n";
+ " },\n";
numTests++;
- }
- if(!extraInclude.empty())
- {
+ }
+ if (!extraInclude.empty()) {
this->Makefile->AddDefinition("CMAKE_TESTDRIVER_EXTRA_INCLUDES",
extraInclude.c_str());
- }
- if(!function.empty())
- {
+ }
+ if (!function.empty()) {
this->Makefile->AddDefinition("CMAKE_TESTDRIVER_ARGVC_FUNCTION",
function.c_str());
- }
+ }
this->Makefile->AddDefinition("CMAKE_FORWARD_DECLARE_TESTS",
- forwardDeclareCode.c_str());
+ forwardDeclareCode.c_str());
this->Makefile->AddDefinition("CMAKE_FUNCTION_TABLE_ENTIRES",
- functionMapCode.c_str());
+ functionMapCode.c_str());
bool res = true;
- if ( !this->Makefile->ConfigureFile(configFile.c_str(), driver.c_str(),
- false, true, false) )
- {
+ if (!this->Makefile->ConfigureFile(configFile.c_str(), driver.c_str(), false,
+ true, false)) {
res = false;
- }
+ }
// Construct the source list.
std::string sourceListValue;
{
- cmSourceFile* sf = this->Makefile->GetOrCreateSource(driver);
- sf->SetProperty("ABSTRACT","0");
- sourceListValue = args[1];
+ cmSourceFile* sf = this->Makefile->GetOrCreateSource(driver);
+ sf->SetProperty("ABSTRACT", "0");
+ sourceListValue = args[1];
}
- for(i = testsBegin; i != tests.end(); ++i)
- {
+ for (i = testsBegin; i != tests.end(); ++i) {
cmSourceFile* sf = this->Makefile->GetOrCreateSource(*i);
- sf->SetProperty("ABSTRACT","0");
+ sf->SetProperty("ABSTRACT", "0");
sourceListValue += ";";
sourceListValue += *i;
- }
+ }
this->Makefile->AddDefinition(sourceList, sourceListValue.c_str());
return res;
}
-
-
-
diff --git a/Source/cmCreateTestSourceList.h b/Source/cmCreateTestSourceList.h
index 2f6b541..cfaca2e 100644
--- a/Source/cmCreateTestSourceList.h
+++ b/Source/cmCreateTestSourceList.h
@@ -25,26 +25,21 @@ public:
/**
* This is a virtual constructor for the command.
*/
- virtual cmCommand* Clone()
- {
- return new cmCreateTestSourceList;
- }
+ virtual cmCommand* Clone() { return new cmCreateTestSourceList; }
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus &status);
+ cmExecutionStatus& status);
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const {return "create_test_sourcelist";}
+ virtual std::string GetName() const { return "create_test_sourcelist"; }
cmTypeMacro(cmCreateTestSourceList, cmCommand);
};
-
-
#endif
diff --git a/Source/cmCryptoHash.cxx b/Source/cmCryptoHash.cxx
index 5eb0239..85049ca 100644
--- a/Source/cmCryptoHash.cxx
+++ b/Source/cmCryptoHash.cxx
@@ -17,20 +17,21 @@
cmsys::auto_ptr<cmCryptoHash> cmCryptoHash::New(const char* algo)
{
- if(strcmp(algo,"MD5") == 0)
- { return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashMD5); }
- else if(strcmp(algo,"SHA1") == 0)
- { return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashSHA1); }
- else if(strcmp(algo,"SHA224") == 0)
- { return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashSHA224); }
- else if(strcmp(algo,"SHA256") == 0)
- { return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashSHA256); }
- else if(strcmp(algo,"SHA384") == 0)
- { return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashSHA384); }
- else if(strcmp(algo,"SHA512") == 0)
- { return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashSHA512); }
- else
- { return cmsys::auto_ptr<cmCryptoHash>(0); }
+ if (strcmp(algo, "MD5") == 0) {
+ return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashMD5);
+ } else if (strcmp(algo, "SHA1") == 0) {
+ return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashSHA1);
+ } else if (strcmp(algo, "SHA224") == 0) {
+ return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashSHA224);
+ } else if (strcmp(algo, "SHA256") == 0) {
+ return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashSHA256);
+ } else if (strcmp(algo, "SHA384") == 0) {
+ return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashSHA384);
+ } else if (strcmp(algo, "SHA512") == 0) {
+ return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashSHA512);
+ } else {
+ return cmsys::auto_ptr<cmCryptoHash>(0);
+ }
}
std::string cmCryptoHash::HashString(const std::string& input)
@@ -44,10 +45,9 @@ std::string cmCryptoHash::HashString(const std::string& input)
std::string cmCryptoHash::HashFile(const std::string& file)
{
cmsys::ifstream fin(file.c_str(), std::ios::in | std::ios::binary);
- if(!fin)
- {
+ if (!fin) {
return "";
- }
+ }
this->Initialize();
@@ -61,22 +61,20 @@ std::string cmCryptoHash::HashFile(const std::string& file)
// incorrect to not check the error condition on the fin.read()
// before using the data, but the fin.gcount() will be zero if an
// error occurred. Therefore, the loop should be safe everywhere.
- while(fin)
- {
+ while (fin) {
fin.read(buffer_c, sizeof(buffer));
- if(int gcount = static_cast<int>(fin.gcount()))
- {
+ if (int gcount = static_cast<int>(fin.gcount())) {
this->Append(buffer_uc, gcount);
- }
}
- if(fin.eof())
- {
+ }
+ if (fin.eof()) {
return this->Finalize();
- }
+ }
return "";
}
-cmCryptoHashMD5::cmCryptoHashMD5(): MD5(cmsysMD5_New())
+cmCryptoHashMD5::cmCryptoHashMD5()
+ : MD5(cmsysMD5_New())
{
}
@@ -102,22 +100,24 @@ std::string cmCryptoHashMD5::Finalize()
return std::string(md5out, 32);
}
-
-#define cmCryptoHash_SHA_CLASS_IMPL(SHA) \
-cmCryptoHash##SHA::cmCryptoHash##SHA(): SHA(new SHA_CTX) {} \
-cmCryptoHash##SHA::~cmCryptoHash##SHA() { delete this->SHA; } \
-void cmCryptoHash##SHA::Initialize() { SHA##_Init(this->SHA); } \
-void cmCryptoHash##SHA::Append(unsigned char const* buf, int sz) \
-{ SHA##_Update(this->SHA, buf, sz); } \
-std::string cmCryptoHash##SHA::Finalize() \
-{ \
- char out[SHA##_DIGEST_STRING_LENGTH]; \
- SHA##_End(this->SHA, out); \
- return std::string(out, SHA##_DIGEST_STRING_LENGTH-1); \
-}
-
-cmCryptoHash_SHA_CLASS_IMPL(SHA1)
-cmCryptoHash_SHA_CLASS_IMPL(SHA224)
-cmCryptoHash_SHA_CLASS_IMPL(SHA256)
-cmCryptoHash_SHA_CLASS_IMPL(SHA384)
-cmCryptoHash_SHA_CLASS_IMPL(SHA512)
+#define cmCryptoHash_SHA_CLASS_IMPL(SHA) \
+ cmCryptoHash##SHA::cmCryptoHash##SHA() \
+ : SHA(new SHA_CTX) \
+ { \
+ } \
+ cmCryptoHash##SHA::~cmCryptoHash##SHA() { delete this->SHA; } \
+ void cmCryptoHash##SHA::Initialize() { SHA##_Init(this->SHA); } \
+ void cmCryptoHash##SHA::Append(unsigned char const* buf, int sz) \
+ { \
+ SHA##_Update(this->SHA, buf, sz); \
+ } \
+ std::string cmCryptoHash##SHA::Finalize() \
+ { \
+ char out[SHA##_DIGEST_STRING_LENGTH]; \
+ SHA##_End(this->SHA, out); \
+ return std::string(out, SHA##_DIGEST_STRING_LENGTH - 1); \
+ }
+
+cmCryptoHash_SHA_CLASS_IMPL(SHA1) cmCryptoHash_SHA_CLASS_IMPL(SHA224)
+ cmCryptoHash_SHA_CLASS_IMPL(SHA256) cmCryptoHash_SHA_CLASS_IMPL(SHA384)
+ cmCryptoHash_SHA_CLASS_IMPL(SHA512)
diff --git a/Source/cmCryptoHash.h b/Source/cmCryptoHash.h
index 88cd240..a0c5eab 100644
--- a/Source/cmCryptoHash.h
+++ b/Source/cmCryptoHash.h
@@ -23,35 +23,40 @@ public:
static cmsys::auto_ptr<cmCryptoHash> New(const char* algo);
std::string HashString(const std::string& input);
std::string HashFile(const std::string& file);
+
protected:
- virtual void Initialize()=0;
- virtual void Append(unsigned char const*, int)=0;
- virtual std::string Finalize()=0;
+ virtual void Initialize() = 0;
+ virtual void Append(unsigned char const*, int) = 0;
+ virtual std::string Finalize() = 0;
};
-class cmCryptoHashMD5: public cmCryptoHash
+class cmCryptoHashMD5 : public cmCryptoHash
{
struct cmsysMD5_s* MD5;
+
public:
cmCryptoHashMD5();
~cmCryptoHashMD5();
+
protected:
virtual void Initialize();
virtual void Append(unsigned char const* buf, int sz);
virtual std::string Finalize();
};
-#define cmCryptoHash_SHA_CLASS_DECL(SHA) \
- class cmCryptoHash##SHA: public cmCryptoHash \
- { \
- union _SHA_CTX* SHA; \
- public: \
- cmCryptoHash##SHA(); \
- ~cmCryptoHash##SHA(); \
- protected: \
- virtual void Initialize(); \
- virtual void Append(unsigned char const* buf, int sz); \
- virtual std::string Finalize(); \
+#define cmCryptoHash_SHA_CLASS_DECL(SHA) \
+ class cmCryptoHash##SHA : public cmCryptoHash \
+ { \
+ union _SHA_CTX* SHA; \
+ \
+ public: \
+ cmCryptoHash##SHA(); \
+ ~cmCryptoHash##SHA(); \
+ \
+ protected: \
+ virtual void Initialize(); \
+ virtual void Append(unsigned char const* buf, int sz); \
+ virtual std::string Finalize(); \
}
cmCryptoHash_SHA_CLASS_DECL(SHA1);
diff --git a/Source/cmCurl.cxx b/Source/cmCurl.cxx
index c135f27..5bc4f91 100644
--- a/Source/cmCurl.cxx
+++ b/Source/cmCurl.cxx
@@ -15,55 +15,48 @@
// curl versions before 7.21.5 did not provide this error code
#if defined(LIBCURL_VERSION_NUM) && LIBCURL_VERSION_NUM < 0x071505
-# define CURLE_NOT_BUILT_IN 4
+#define CURLE_NOT_BUILT_IN 4
#endif
-#define check_curl_result(result, errstr) \
- if (result != CURLE_OK && result != CURLE_NOT_BUILT_IN) \
- { \
- e += e.empty()? "" : "\n"; \
- e += errstr; \
- e += ::curl_easy_strerror(result); \
- }
+#define check_curl_result(result, errstr) \
+ if (result != CURLE_OK && result != CURLE_NOT_BUILT_IN) { \
+ e += e.empty() ? "" : "\n"; \
+ e += errstr; \
+ e += ::curl_easy_strerror(result); \
+ }
-std::string cmCurlSetCAInfo(::CURL *curl, const char* cafile)
+std::string cmCurlSetCAInfo(::CURL* curl, const char* cafile)
{
std::string e;
- if(cafile && *cafile)
- {
+ if (cafile && *cafile) {
::CURLcode res = ::curl_easy_setopt(curl, CURLOPT_CAINFO, cafile);
check_curl_result(res, "Unable to set TLS/SSL Verify CAINFO: ");
- }
-#if !defined(CMAKE_USE_SYSTEM_CURL) && \
- !defined(_WIN32) && !defined(__APPLE__) && \
- !defined(CURL_CA_BUNDLE) && !defined(CURL_CA_PATH)
-# define CMAKE_CAFILE_FEDORA "/etc/pki/tls/certs/ca-bundle.crt"
- else if(cmSystemTools::FileExists(CMAKE_CAFILE_FEDORA, true))
- {
+ }
+#if !defined(CMAKE_USE_SYSTEM_CURL) && !defined(_WIN32) && \
+ !defined(__APPLE__) && !defined(CURL_CA_BUNDLE) && !defined(CURL_CA_PATH)
+#define CMAKE_CAFILE_FEDORA "/etc/pki/tls/certs/ca-bundle.crt"
+ else if (cmSystemTools::FileExists(CMAKE_CAFILE_FEDORA, true)) {
::CURLcode res =
::curl_easy_setopt(curl, CURLOPT_CAINFO, CMAKE_CAFILE_FEDORA);
check_curl_result(res, "Unable to set TLS/SSL Verify CAINFO: ");
- }
-# undef CMAKE_CAFILE_FEDORA
- else
- {
-# define CMAKE_CAFILE_COMMON "/etc/ssl/certs/ca-certificates.crt"
- if(cmSystemTools::FileExists(CMAKE_CAFILE_COMMON, true))
- {
+ }
+#undef CMAKE_CAFILE_FEDORA
+ else {
+#define CMAKE_CAFILE_COMMON "/etc/ssl/certs/ca-certificates.crt"
+ if (cmSystemTools::FileExists(CMAKE_CAFILE_COMMON, true)) {
::CURLcode res =
::curl_easy_setopt(curl, CURLOPT_CAINFO, CMAKE_CAFILE_COMMON);
check_curl_result(res, "Unable to set TLS/SSL Verify CAINFO: ");
- }
-# undef CMAKE_CAFILE_COMMON
-# define CMAKE_CAPATH_COMMON "/etc/ssl/certs"
- if(cmSystemTools::FileIsDirectory(CMAKE_CAPATH_COMMON))
- {
+ }
+#undef CMAKE_CAFILE_COMMON
+#define CMAKE_CAPATH_COMMON "/etc/ssl/certs"
+ if (cmSystemTools::FileIsDirectory(CMAKE_CAPATH_COMMON)) {
::CURLcode res =
::curl_easy_setopt(curl, CURLOPT_CAPATH, CMAKE_CAPATH_COMMON);
check_curl_result(res, "Unable to set TLS/SSL Verify CAPATH: ");
- }
-# undef CMAKE_CAPATH_COMMON
}
+#undef CMAKE_CAPATH_COMMON
+ }
#endif
return e;
}
diff --git a/Source/cmCurl.h b/Source/cmCurl.h
index 2bc54cd..eac7f13 100644
--- a/Source/cmCurl.h
+++ b/Source/cmCurl.h
@@ -16,6 +16,6 @@
#include "cm_curl.h"
-std::string cmCurlSetCAInfo(::CURL *curl, const char* cafile = 0);
+std::string cmCurlSetCAInfo(::CURL* curl, const char* cafile = 0);
#endif
diff --git a/Source/cmCustomCommand.cxx b/Source/cmCustomCommand.cxx
index e2bd8b1..7c00c80 100644
--- a/Source/cmCustomCommand.cxx
+++ b/Source/cmCustomCommand.cxx
@@ -30,22 +30,21 @@ cmCustomCommand::cmCustomCommand(cmMakefile const* mf,
const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines,
const char* comment,
- const char* workingDirectory):
- Outputs(outputs),
- Byproducts(byproducts),
- Depends(depends),
- CommandLines(commandLines),
- Backtrace(),
- Comment(comment?comment:""),
- WorkingDirectory(workingDirectory?workingDirectory:""),
- HaveComment(comment?true:false),
- EscapeAllowMakeVars(false),
- EscapeOldStyle(true)
-{
- if(mf)
- {
+ const char* workingDirectory)
+ : Outputs(outputs)
+ , Byproducts(byproducts)
+ , Depends(depends)
+ , CommandLines(commandLines)
+ , Backtrace()
+ , Comment(comment ? comment : "")
+ , WorkingDirectory(workingDirectory ? workingDirectory : "")
+ , HaveComment(comment ? true : false)
+ , EscapeAllowMakeVars(false)
+ , EscapeOldStyle(true)
+{
+ if (mf) {
this->Backtrace = mf->GetBacktrace();
- }
+ }
}
const std::vector<std::string>& cmCustomCommand::GetOutputs() const
@@ -71,13 +70,13 @@ const cmCustomCommandLines& cmCustomCommand::GetCommandLines() const
const char* cmCustomCommand::GetComment() const
{
const char* no_comment = 0;
- return this->HaveComment? this->Comment.c_str() : no_comment;
+ return this->HaveComment ? this->Comment.c_str() : no_comment;
}
void cmCustomCommand::AppendCommands(const cmCustomCommandLines& commandLines)
{
- this->CommandLines.insert(this->CommandLines.end(),
- commandLines.begin(), commandLines.end());
+ this->CommandLines.insert(this->CommandLines.end(), commandLines.begin(),
+ commandLines.end());
}
void cmCustomCommand::AppendDepends(const std::vector<std::string>& depends)
@@ -123,8 +122,8 @@ void cmCustomCommand::SetImplicitDepends(ImplicitDependsList const& l)
void cmCustomCommand::AppendImplicitDepends(ImplicitDependsList const& l)
{
- this->ImplicitDepends.insert(this->ImplicitDepends.end(),
- l.begin(), l.end());
+ this->ImplicitDepends.insert(this->ImplicitDepends.end(), l.begin(),
+ l.end());
}
bool cmCustomCommand::GetUsesTerminal() const
diff --git a/Source/cmCustomCommand.h b/Source/cmCustomCommand.h
index 0370497..c2b9738 100644
--- a/Source/cmCustomCommand.h
+++ b/Source/cmCustomCommand.h
@@ -34,8 +34,7 @@ public:
const std::vector<std::string>& byproducts,
const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines,
- const char* comment,
- const char* workingDirectory);
+ const char* comment, const char* workingDirectory);
/** Get the output file produced by the command. */
const std::vector<std::string>& GetOutputs() const;
@@ -48,7 +47,9 @@ public:
/** Get the working directory. */
std::string const& GetWorkingDirectory() const
- { return this->WorkingDirectory; }
+ {
+ return this->WorkingDirectory;
+ }
/** Get the list of command lines. */
const cmCustomCommandLines& GetCommandLines() const;
@@ -75,7 +76,9 @@ public:
cmListFileBacktrace const& GetBacktrace() const;
typedef std::pair<std::string, std::string> ImplicitDependsPair;
- class ImplicitDependsList: public std::vector<ImplicitDependsPair> {};
+ class ImplicitDependsList : public std::vector<ImplicitDependsPair>
+ {
+ };
void SetImplicitDepends(ImplicitDependsList const&);
void AppendImplicitDepends(ImplicitDependsList const&);
ImplicitDependsList const& GetImplicitDepends() const;
diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx
index 4a19160..99bb601 100644
--- a/Source/cmCustomCommandGenerator.cxx
+++ b/Source/cmCustomCommandGenerator.cxx
@@ -17,11 +17,16 @@
#include "cmMakefile.h"
#include "cmOutputConverter.h"
-cmCustomCommandGenerator::cmCustomCommandGenerator(
- cmCustomCommand const& cc, const std::string& config, cmLocalGenerator* lg):
- CC(cc), Config(config), LG(lg),
- OldStyle(cc.GetEscapeOldStyle()), MakeVars(cc.GetEscapeAllowMakeVars()),
- GE(new cmGeneratorExpression(cc.GetBacktrace())), DependsDone(false)
+cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc,
+ const std::string& config,
+ cmLocalGenerator* lg)
+ : CC(cc)
+ , Config(config)
+ , LG(lg)
+ , OldStyle(cc.GetEscapeOldStyle())
+ , MakeVars(cc.GetEscapeAllowMakeVars())
+ , GE(new cmGeneratorExpression(cc.GetBacktrace()))
+ , DependsDone(false)
{
}
@@ -38,34 +43,28 @@ unsigned int cmCustomCommandGenerator::GetNumberOfCommands() const
bool cmCustomCommandGenerator::UseCrossCompilingEmulator(unsigned int c) const
{
std::string const& argv0 = this->CC.GetCommandLines()[c][0];
- cmGeneratorTarget* target =
- this->LG->FindGeneratorTargetToUse(argv0);
- if(target && target->GetType() == cmState::EXECUTABLE)
- {
+ cmGeneratorTarget* target = this->LG->FindGeneratorTargetToUse(argv0);
+ if (target && target->GetType() == cmState::EXECUTABLE) {
return target->GetProperty("CROSSCOMPILING_EMULATOR") != 0;
- }
+ }
return false;
}
std::string cmCustomCommandGenerator::GetCommand(unsigned int c) const
{
std::string const& argv0 = this->CC.GetCommandLines()[c][0];
- cmGeneratorTarget* target =
- this->LG->FindGeneratorTargetToUse(argv0);
- if(target && target->GetType() == cmState::EXECUTABLE &&
- (target->IsImported()
- || !this->LG->GetMakefile()->IsOn("CMAKE_CROSSCOMPILING")))
- {
+ cmGeneratorTarget* target = this->LG->FindGeneratorTargetToUse(argv0);
+ if (target && target->GetType() == cmState::EXECUTABLE &&
+ (target->IsImported() ||
+ !this->LG->GetMakefile()->IsOn("CMAKE_CROSSCOMPILING"))) {
return target->GetLocation(this->Config);
- }
- if (target && target->GetType() == cmState::EXECUTABLE)
- {
+ }
+ if (target && target->GetType() == cmState::EXECUTABLE) {
const char* emulator = target->GetProperty("CROSSCOMPILING_EMULATOR");
- if (emulator)
- {
- return std::string(emulator);
- }
+ if (emulator) {
+ return std::string(emulator);
}
+ }
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = this->GE->Parse(argv0);
std::string exe = cge->Evaluate(this->LG, this->Config);
@@ -80,53 +79,43 @@ std::string escapeForShellOldStyle(const std::string& str)
// if there are spaces
std::string temp = str;
if (temp.find(" ") != std::string::npos &&
- temp.find("\"")==std::string::npos)
- {
+ temp.find("\"") == std::string::npos) {
result = "\"";
result += str;
result += "\"";
return result;
- }
+ }
return str;
#else
- for(const char* ch = str.c_str(); *ch != '\0'; ++ch)
- {
- if(*ch == ' ')
- {
+ for (const char* ch = str.c_str(); *ch != '\0'; ++ch) {
+ if (*ch == ' ') {
result += '\\';
- }
- result += *ch;
}
+ result += *ch;
+ }
return result;
#endif
}
-void
-cmCustomCommandGenerator
-::AppendArguments(unsigned int c, std::string& cmd) const
+void cmCustomCommandGenerator::AppendArguments(unsigned int c,
+ std::string& cmd) const
{
unsigned int offset = 1;
- if (this->UseCrossCompilingEmulator(c))
- {
+ if (this->UseCrossCompilingEmulator(c)) {
offset = 0;
- }
+ }
cmCustomCommandLine const& commandLine = this->CC.GetCommandLines()[c];
- for(unsigned int j=offset;j < commandLine.size(); ++j)
- {
+ for (unsigned int j = offset; j < commandLine.size(); ++j) {
std::string arg =
- this->GE->Parse(commandLine[j])->Evaluate(this->LG,
- this->Config);
+ this->GE->Parse(commandLine[j])->Evaluate(this->LG, this->Config);
cmd += " ";
- if(this->OldStyle)
- {
+ if (this->OldStyle) {
cmd += escapeForShellOldStyle(arg);
- }
- else
- {
+ } else {
cmOutputConverter converter(this->LG->GetStateSnapshot());
cmd += converter.EscapeForShell(arg, this->MakeVars);
- }
}
+ }
}
const char* cmCustomCommandGenerator::GetComment() const
@@ -151,29 +140,23 @@ std::vector<std::string> const& cmCustomCommandGenerator::GetByproducts() const
std::vector<std::string> const& cmCustomCommandGenerator::GetDepends() const
{
- if (!this->DependsDone)
- {
+ if (!this->DependsDone) {
this->DependsDone = true;
std::vector<std::string> depends = this->CC.GetDepends();
- for(std::vector<std::string>::const_iterator
- i = depends.begin();
- i != depends.end(); ++i)
- {
- cmsys::auto_ptr<cmCompiledGeneratorExpression> cge
- = this->GE->Parse(*i);
+ for (std::vector<std::string>::const_iterator i = depends.begin();
+ i != depends.end(); ++i) {
+ cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = this->GE->Parse(*i);
std::vector<std::string> result;
- cmSystemTools::ExpandListArgument(
- cge->Evaluate(this->LG, this->Config), result);
+ cmSystemTools::ExpandListArgument(cge->Evaluate(this->LG, this->Config),
+ result);
for (std::vector<std::string>::iterator it = result.begin();
- it != result.end(); ++it)
- {
- if (cmSystemTools::FileIsFullPath(it->c_str()))
- {
+ it != result.end(); ++it) {
+ if (cmSystemTools::FileIsFullPath(it->c_str())) {
*it = cmSystemTools::CollapseFullPath(*it);
- }
}
- this->Depends.insert(this->Depends.end(), result.begin(), result.end());
}
+ this->Depends.insert(this->Depends.end(), result.begin(), result.end());
}
+ }
return this->Depends;
}
diff --git a/Source/cmCustomCommandGenerator.h b/Source/cmCustomCommandGenerator.h
index 65ce031..a361153 100644
--- a/Source/cmCustomCommandGenerator.h
+++ b/Source/cmCustomCommandGenerator.h
@@ -28,10 +28,10 @@ class cmCustomCommandGenerator
cmGeneratorExpression* GE;
mutable bool DependsDone;
mutable std::vector<std::string> Depends;
+
public:
cmCustomCommandGenerator(cmCustomCommand const& cc,
- const std::string& config,
- cmLocalGenerator* lg);
+ const std::string& config, cmLocalGenerator* lg);
~cmCustomCommandGenerator();
cmCustomCommand const& GetCC() const { return this->CC; }
unsigned int GetNumberOfCommands() const;
diff --git a/Source/cmDefinePropertyCommand.cxx b/Source/cmDefinePropertyCommand.cxx
index 47fc22e..484a970 100644
--- a/Source/cmDefinePropertyCommand.cxx
+++ b/Source/cmDefinePropertyCommand.cxx
@@ -14,47 +14,31 @@
#include "cmState.h"
#include "cmake.h"
-bool cmDefinePropertyCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmDefinePropertyCommand::InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus&)
{
- if(args.size() < 1)
- {
+ if (args.size() < 1) {
this->SetError("called with incorrect number of arguments");
return false;
- }
+ }
// Get the scope in which to define the property.
cmProperty::ScopeType scope;
- if(args[0] == "GLOBAL")
- {
+ if (args[0] == "GLOBAL") {
scope = cmProperty::GLOBAL;
- }
- else if(args[0] == "DIRECTORY")
- {
+ } else if (args[0] == "DIRECTORY") {
scope = cmProperty::DIRECTORY;
- }
- else if(args[0] == "TARGET")
- {
+ } else if (args[0] == "TARGET") {
scope = cmProperty::TARGET;
- }
- else if(args[0] == "SOURCE")
- {
+ } else if (args[0] == "SOURCE") {
scope = cmProperty::SOURCE_FILE;
- }
- else if(args[0] == "TEST")
- {
+ } else if (args[0] == "TEST") {
scope = cmProperty::TEST;
- }
- else if(args[0] == "VARIABLE")
- {
+ } else if (args[0] == "VARIABLE") {
scope = cmProperty::VARIABLE;
- }
- else if (args[0] == "CACHED_VARIABLE")
- {
+ } else if (args[0] == "CACHED_VARIABLE") {
scope = cmProperty::CACHED_VARIABLE;
- }
- else
- {
+ } else {
std::ostringstream e;
e << "given invalid scope " << args[0] << ". "
<< "Valid scopes are "
@@ -62,77 +46,63 @@ bool cmDefinePropertyCommand
<< "TEST, VARIABLE, CACHED_VARIABLE.";
this->SetError(e.str());
return false;
- }
+ }
// Parse remaining arguments.
bool inherited = false;
- enum Doing { DoingNone, DoingProperty, DoingBrief, DoingFull };
+ enum Doing
+ {
+ DoingNone,
+ DoingProperty,
+ DoingBrief,
+ DoingFull
+ };
Doing doing = DoingNone;
- for(unsigned int i=1; i < args.size(); ++i)
- {
- if(args[i] == "PROPERTY")
- {
+ for (unsigned int i = 1; i < args.size(); ++i) {
+ if (args[i] == "PROPERTY") {
doing = DoingProperty;
- }
- else if(args[i] == "BRIEF_DOCS")
- {
+ } else if (args[i] == "BRIEF_DOCS") {
doing = DoingBrief;
- }
- else if(args[i] == "FULL_DOCS")
- {
+ } else if (args[i] == "FULL_DOCS") {
doing = DoingFull;
- }
- else if(args[i] == "INHERITED")
- {
+ } else if (args[i] == "INHERITED") {
doing = DoingNone;
inherited = true;
- }
- else if(doing == DoingProperty)
- {
+ } else if (doing == DoingProperty) {
doing = DoingNone;
this->PropertyName = args[i];
- }
- else if(doing == DoingBrief)
- {
+ } else if (doing == DoingBrief) {
this->BriefDocs += args[i];
- }
- else if(doing == DoingFull)
- {
+ } else if (doing == DoingFull) {
this->FullDocs += args[i];
- }
- else
- {
+ } else {
std::ostringstream e;
e << "given invalid argument \"" << args[i] << "\".";
this->SetError(e.str());
return false;
- }
}
+ }
// Make sure a property name was found.
- if(this->PropertyName.empty())
- {
+ if (this->PropertyName.empty()) {
this->SetError("not given a PROPERTY <name> argument.");
return false;
- }
+ }
// Make sure documentation was given.
- if(this->BriefDocs.empty())
- {
+ if (this->BriefDocs.empty()) {
this->SetError("not given a BRIEF_DOCS <brief-doc> argument.");
return false;
- }
- if(this->FullDocs.empty())
- {
+ }
+ if (this->FullDocs.empty()) {
this->SetError("not given a FULL_DOCS <full-doc> argument.");
return false;
- }
+ }
// Actually define the property.
- this->Makefile->GetState()->DefineProperty
- (this->PropertyName, scope,
- this->BriefDocs.c_str(), this->FullDocs.c_str(), inherited);
+ this->Makefile->GetState()->DefineProperty(
+ this->PropertyName, scope, this->BriefDocs.c_str(), this->FullDocs.c_str(),
+ inherited);
return true;
}
-
diff --git a/Source/cmDefinePropertyCommand.h b/Source/cmDefinePropertyCommand.h
index bc5c8a4..4248bbe 100644
--- a/Source/cmDefinePropertyCommand.h
+++ b/Source/cmDefinePropertyCommand.h
@@ -17,30 +17,26 @@
class cmDefinePropertyCommand : public cmCommand
{
public:
- virtual cmCommand* Clone()
- {
- return new cmDefinePropertyCommand;
- }
+ virtual cmCommand* Clone() { return new cmDefinePropertyCommand; }
/**
* This is called when the command is first encountered in
* the input file.
*/
virtual bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus &status);
+ cmExecutionStatus& status);
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const { return "define_property";}
+ virtual std::string GetName() const { return "define_property"; }
cmTypeMacro(cmDefinePropertyCommand, cmCommand);
+
private:
std::string PropertyName;
std::string BriefDocs;
std::string FullDocs;
};
-
-
#endif
diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index e8b898d..28b6677 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -15,54 +15,50 @@
cmDefinitions::Def cmDefinitions::NoDef;
-cmDefinitions::Def const& cmDefinitions::GetInternal(
- const std::string& key, StackIter begin, StackIter end, bool raise)
+cmDefinitions::Def const& cmDefinitions::GetInternal(const std::string& key,
+ StackIter begin,
+ StackIter end, bool raise)
{
assert(begin != end);
MapType::iterator i = begin->Map.find(key);
- if (i != begin->Map.end())
- {
+ if (i != begin->Map.end()) {
i->second.Used = true;
return i->second;
- }
+ }
StackIter it = begin;
++it;
- if (it == end)
- {
+ if (it == end) {
return cmDefinitions::NoDef;
- }
+ }
Def const& def = cmDefinitions::GetInternal(key, it, end, raise);
- if (!raise)
- {
+ if (!raise) {
return def;
- }
+ }
return begin->Map.insert(MapType::value_type(key, def)).first->second;
}
-const char* cmDefinitions::Get(const std::string& key,
- StackIter begin, StackIter end)
+const char* cmDefinitions::Get(const std::string& key, StackIter begin,
+ StackIter end)
{
Def const& def = cmDefinitions::GetInternal(key, begin, end, false);
- return def.Exists? def.c_str() : 0;
+ return def.Exists ? def.c_str() : 0;
}
-void cmDefinitions::Raise(const std::string& key,
- StackIter begin, StackIter end)
+void cmDefinitions::Raise(const std::string& key, StackIter begin,
+ StackIter end)
{
cmDefinitions::GetInternal(key, begin, end, true);
}
-bool cmDefinitions::HasKey(const std::string& key,
- StackIter begin, StackIter end)
+bool cmDefinitions::HasKey(const std::string& key, StackIter begin,
+ StackIter end)
{
- for (StackIter it = begin; it != end; ++it)
- {
+ for (StackIter it = begin; it != end; ++it) {
MapType::const_iterator i = it->Map.find(key);
- if (i != it->Map.end())
- {
+ if (i != it->Map.end()) {
return true;
- }
}
+ }
return false;
}
@@ -77,65 +73,53 @@ std::vector<std::string> cmDefinitions::UnusedKeys() const
std::vector<std::string> keys;
keys.reserve(this->Map.size());
// Consider local definitions.
- for(MapType::const_iterator mi = this->Map.begin();
- mi != this->Map.end(); ++mi)
- {
- if (!mi->second.Used)
- {
+ for (MapType::const_iterator mi = this->Map.begin(); mi != this->Map.end();
+ ++mi) {
+ if (!mi->second.Used) {
keys.push_back(mi->first);
- }
}
+ }
return keys;
}
-cmDefinitions cmDefinitions::MakeClosure(StackIter begin,
- StackIter end)
+cmDefinitions cmDefinitions::MakeClosure(StackIter begin, StackIter end)
{
cmDefinitions closure;
std::set<std::string> undefined;
- for (StackIter it = begin; it != end; ++it)
- {
+ for (StackIter it = begin; it != end; ++it) {
// Consider local definitions.
- for(MapType::const_iterator mi = it->Map.begin();
- mi != it->Map.end(); ++mi)
- {
+ for (MapType::const_iterator mi = it->Map.begin(); mi != it->Map.end();
+ ++mi) {
// Use this key if it is not already set or unset.
- if(closure.Map.find(mi->first) == closure.Map.end() &&
- undefined.find(mi->first) == undefined.end())
- {
- if(mi->second.Exists)
- {
+ if (closure.Map.find(mi->first) == closure.Map.end() &&
+ undefined.find(mi->first) == undefined.end()) {
+ if (mi->second.Exists) {
closure.Map.insert(*mi);
- }
- else
- {
+ } else {
undefined.insert(mi->first);
- }
}
}
}
+ }
return closure;
}
-std::vector<std::string>
-cmDefinitions::ClosureKeys(StackIter begin, StackIter end)
+std::vector<std::string> cmDefinitions::ClosureKeys(StackIter begin,
+ StackIter end)
{
std::set<std::string> bound;
std::vector<std::string> defined;
- for (StackIter it = begin; it != end; ++it)
- {
+ for (StackIter it = begin; it != end; ++it) {
defined.reserve(defined.size() + it->Map.size());
- for(MapType::const_iterator mi = it->Map.begin();
- mi != it->Map.end(); ++mi)
- {
+ for (MapType::const_iterator mi = it->Map.begin(); mi != it->Map.end();
+ ++mi) {
// Use this key if it is not already set or unset.
- if(bound.insert(mi->first).second && mi->second.Exists)
- {
+ if (bound.insert(mi->first).second && mi->second.Exists) {
defined.push_back(mi->first);
- }
}
}
+ }
return defined;
}
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index 411867c..7be0098 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -36,41 +36,56 @@
class cmDefinitions
{
typedef cmLinkedTree<cmDefinitions>::iterator StackIter;
+
public:
- static const char* Get(const std::string& key,
- StackIter begin, StackIter end);
+ static const char* Get(const std::string& key, StackIter begin,
+ StackIter end);
- static void Raise(const std::string& key,
- StackIter begin, StackIter end);
+ static void Raise(const std::string& key, StackIter begin, StackIter end);
- static bool HasKey(const std::string& key,
- StackIter begin, StackIter end);
+ static bool HasKey(const std::string& key, StackIter begin, StackIter end);
/** Set (or unset if null) a value associated with a key. */
void Set(const std::string& key, const char* value);
std::vector<std::string> UnusedKeys() const;
- static std::vector<std::string> ClosureKeys(StackIter begin,
- StackIter end);
+ static std::vector<std::string> ClosureKeys(StackIter begin, StackIter end);
static cmDefinitions MakeClosure(StackIter begin, StackIter end);
private:
// String with existence boolean.
- struct Def: public std::string
+ struct Def : public std::string
{
private:
typedef std::string std_string;
+
public:
- Def(): std_string(), Exists(false), Used(false) {}
+ Def()
+ : std_string()
+ , Exists(false)
+ , Used(false)
+ {
+ }
Def(const char* v)
- : std_string(v ? v : ""),
- Exists(v ? true : false),
- Used(false)
- {}
- Def(const std_string& v): std_string(v), Exists(true), Used(false) {}
- Def(Def const& d): std_string(d), Exists(d.Exists), Used(d.Used) {}
+ : std_string(v ? v : "")
+ , Exists(v ? true : false)
+ , Used(false)
+ {
+ }
+ Def(const std_string& v)
+ : std_string(v)
+ , Exists(true)
+ , Used(false)
+ {
+ }
+ Def(Def const& d)
+ : std_string(d)
+ , Exists(d.Exists)
+ , Used(d.Used)
+ {
+ }
bool Exists;
bool Used;
};
@@ -87,8 +102,8 @@ private:
#endif
MapType Map;
- static Def const& GetInternal(const std::string& key,
- StackIter begin, StackIter end, bool raise);
+ static Def const& GetInternal(const std::string& key, StackIter begin,
+ StackIter end, bool raise);
};
#endif
diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx
index 8686bcd..5df3cc1 100644
--- a/Source/cmDepends.cxx
+++ b/Source/cmDepends.cxx
@@ -19,26 +19,25 @@
#include <cmsys/FStream.hxx>
#include <string.h>
-cmDepends::cmDepends(cmLocalGenerator* lg, const char* targetDir):
- CompileDirectory(),
- LocalGenerator(lg),
- Verbose(false),
- FileComparison(0),
- TargetDirectory(targetDir),
- MaxPath(16384),
- Dependee(new char[MaxPath]),
- Depender(new char[MaxPath])
+cmDepends::cmDepends(cmLocalGenerator* lg, const char* targetDir)
+ : CompileDirectory()
+ , LocalGenerator(lg)
+ , Verbose(false)
+ , FileComparison(0)
+ , TargetDirectory(targetDir)
+ , MaxPath(16384)
+ , Dependee(new char[MaxPath])
+ , Depender(new char[MaxPath])
{
}
cmDepends::~cmDepends()
{
- delete [] this->Dependee;
- delete [] this->Depender;
+ delete[] this->Dependee;
+ delete[] this->Depender;
}
-bool cmDepends::Write(std::ostream &makeDepends,
- std::ostream &internalDepends)
+bool cmDepends::Write(std::ostream& makeDepends, std::ostream& internalDepends)
{
// Lookup the set of sources to scan.
std::string srcLang = "CMAKE_DEPENDS_CHECK_";
@@ -49,97 +48,92 @@ bool cmDepends::Write(std::ostream &makeDepends,
cmSystemTools::ExpandListArgument(srcStr, pairs);
std::map<std::string, std::set<std::string> > dependencies;
- for(std::vector<std::string>::iterator si = pairs.begin();
- si != pairs.end();)
- {
+ for (std::vector<std::string>::iterator si = pairs.begin();
+ si != pairs.end();) {
// Get the source and object file.
std::string const& src = *si++;
- if(si == pairs.end()) { break; }
+ if (si == pairs.end()) {
+ break;
+ }
std::string const& obj = *si++;
dependencies[obj].insert(src);
- }
- for(std::map<std::string, std::set<std::string> >::const_iterator
- it = dependencies.begin(); it != dependencies.end(); ++it)
- {
+ }
+ for (std::map<std::string, std::set<std::string> >::const_iterator it =
+ dependencies.begin();
+ it != dependencies.end(); ++it) {
// Write the dependencies for this pair.
- if(!this->WriteDependencies(it->second, it->first,
- makeDepends, internalDepends))
- {
+ if (!this->WriteDependencies(it->second, it->first, makeDepends,
+ internalDepends)) {
return false;
- }
}
+ }
return this->Finalize(makeDepends, internalDepends);
}
-bool cmDepends::Finalize(std::ostream&,
- std::ostream&)
+bool cmDepends::Finalize(std::ostream&, std::ostream&)
{
return true;
}
-bool cmDepends::Check(const char *makeFile, const char *internalFile,
+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 != ".")
- {
+ 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);
- }
+ }
// Check whether dependencies must be regenerated.
bool okay = true;
cmsys::ifstream fin(internalFile);
- if(!(fin && this->CheckDependencies(fin, internalFile, validDeps)))
- {
+ if (!(fin && this->CheckDependencies(fin, internalFile, validDeps))) {
// Clear all dependencies so they will be regenerated.
this->Clear(makeFile);
cmSystemTools::RemoveFile(internalFile);
okay = false;
- }
+ }
// Restore working directory.
- if(oldcwd != ".")
- {
+ if (oldcwd != ".") {
cmSystemTools::ChangeDirectory(oldcwd);
- }
+ }
return okay;
}
-void cmDepends::Clear(const char *file)
+void cmDepends::Clear(const char* file)
{
// Print verbose output.
- if(this->Verbose)
- {
+ if (this->Verbose) {
std::ostringstream msg;
msg << "Clearing dependencies in \"" << file << "\"." << std::endl;
cmSystemTools::Stdout(msg.str().c_str());
- }
+ }
// Write an empty dependency file.
cmGeneratedFileStream depFileStream(file);
- depFileStream
- << "# Empty dependencies file\n"
- << "# This may be replaced when dependencies are built." << std::endl;
+ depFileStream << "# Empty dependencies file\n"
+ << "# This may be replaced when dependencies are built."
+ << std::endl;
}
-bool cmDepends::WriteDependencies(
- const std::set<std::string>&, const std::string&,
- std::ostream&, std::ostream&)
+bool cmDepends::WriteDependencies(const std::set<std::string>&,
+ const std::string&, std::ostream&,
+ std::ostream&)
{
// This should be implemented by the subclass.
return false;
}
-bool cmDepends::CheckDependencies(std::istream& internalDepends,
- const char* internalDependsFileName,
- std::map<std::string, DependencyVector>& validDeps)
+bool cmDepends::CheckDependencies(
+ std::istream& internalDepends, const char* internalDependsFileName,
+ std::map<std::string, DependencyVector>& validDeps)
{
// Parse dependencies from the stream. If any dependee is missing
// or newer than the depender then dependencies should be
@@ -148,22 +142,18 @@ bool cmDepends::CheckDependencies(std::istream& internalDepends,
bool dependerExists = false;
DependencyVector* currentDependencies = 0;
- while(internalDepends.getline(this->Dependee, this->MaxPath))
- {
- if ( this->Dependee[0] == 0 || this->Dependee[0] == '#' ||
- this->Dependee[0] == '\r' )
- {
+ while (internalDepends.getline(this->Dependee, this->MaxPath)) {
+ if (this->Dependee[0] == 0 || this->Dependee[0] == '#' ||
+ this->Dependee[0] == '\r') {
continue;
- }
- size_t len = internalDepends.gcount()-1;
- if ( this->Dependee[len-1] == '\r' )
- {
- len --;
+ }
+ size_t len = internalDepends.gcount() - 1;
+ if (this->Dependee[len - 1] == '\r') {
+ len--;
this->Dependee[len] = 0;
- }
- if ( this->Dependee[0] != ' ' )
- {
- memcpy(this->Depender, this->Dependee, len+1);
+ }
+ if (this->Dependee[0] != ' ') {
+ memcpy(this->Depender, this->Dependee, len + 1);
// Calling FileExists() for the depender here saves in many cases 50%
// of the calls to FileExists() further down in the loop. E.g. for
// kdelibs/khtml this reduces the number of calls from 184k down to 92k,
@@ -175,7 +165,7 @@ bool cmDepends::CheckDependencies(std::istream& internalDepends,
// access.
currentDependencies = &validDeps[this->Depender];
continue;
- }
+ }
/*
// Parse the dependency line.
if(!this->ParseDependency(line.c_str()))
@@ -190,95 +180,80 @@ bool cmDepends::CheckDependencies(std::istream& internalDepends,
// * if the depender does not exist, but the dependee is newer than the
// depends file
bool regenerate = false;
- const char* dependee = this->Dependee+1;
+ const char* dependee = this->Dependee + 1;
const char* depender = this->Depender;
- if (currentDependencies != 0)
- {
+ if (currentDependencies != 0) {
currentDependencies->push_back(dependee);
- }
+ }
- if(!cmSystemTools::FileExists(dependee))
- {
+ if (!cmSystemTools::FileExists(dependee)) {
// The dependee does not exist.
regenerate = true;
// Print verbose output.
- if(this->Verbose)
- {
+ if (this->Verbose) {
std::ostringstream msg;
- msg << "Dependee \"" << dependee
- << "\" does not exist for depender \""
+ msg << "Dependee \"" << dependee << "\" does not exist for depender \""
<< depender << "\"." << std::endl;
cmSystemTools::Stdout(msg.str().c_str());
- }
}
- else
- {
- if(dependerExists)
- {
+ } else {
+ if (dependerExists) {
// The dependee and depender both exist. Compare file times.
int result = 0;
- if((!this->FileComparison->FileTimeCompare(depender, dependee,
- &result) || result < 0))
- {
+ if ((!this->FileComparison->FileTimeCompare(depender, dependee,
+ &result) ||
+ result < 0)) {
// The depender is older than the dependee.
regenerate = true;
// Print verbose output.
- if(this->Verbose)
- {
+ if (this->Verbose) {
std::ostringstream msg;
- msg << "Dependee \"" << dependee
- << "\" is newer than depender \""
+ msg << "Dependee \"" << dependee << "\" is newer than depender \""
<< depender << "\"." << std::endl;
cmSystemTools::Stdout(msg.str().c_str());
- }
}
}
- else
- {
+ } else {
// The dependee exists, but the depender doesn't. Regenerate if the
// internalDepends file is older than the dependee.
int result = 0;
- if((!this->FileComparison->FileTimeCompare(internalDependsFileName,
- dependee, &result) || result < 0))
- {
+ if ((!this->FileComparison->FileTimeCompare(internalDependsFileName,
+ dependee, &result) ||
+ result < 0)) {
// The depends-file is older than the dependee.
regenerate = true;
// Print verbose output.
- if(this->Verbose)
- {
+ if (this->Verbose) {
std::ostringstream msg;
msg << "Dependee \"" << dependee
<< "\" is newer than depends file \""
<< internalDependsFileName << "\"." << std::endl;
cmSystemTools::Stdout(msg.str().c_str());
- }
}
}
}
- if(regenerate)
- {
+ }
+ if (regenerate) {
// Dependencies must be regenerated.
okay = false;
// Remove the information of this depender from the map, it needs
// to be rescanned
- if (currentDependencies != 0)
- {
+ if (currentDependencies != 0) {
validDeps.erase(this->Depender);
currentDependencies = 0;
- }
+ }
// Remove the depender to be sure it is rebuilt.
- if (dependerExists)
- {
+ if (dependerExists) {
cmSystemTools::RemoveFile(depender);
dependerExists = false;
- }
}
}
+ }
return okay;
}
@@ -286,26 +261,22 @@ bool cmDepends::CheckDependencies(std::istream& internalDepends,
void cmDepends::SetIncludePathFromLanguage(const std::string& lang)
{
// Look for the new per "TARGET_" variant first:
- const char * includePath = 0;
+ const char* includePath = 0;
std::string includePathVar = "CMAKE_";
includePathVar += lang;
includePathVar += "_TARGET_INCLUDE_PATH";
cmMakefile* mf = this->LocalGenerator->GetMakefile();
includePath = mf->GetDefinition(includePathVar);
- if(includePath)
- {
+ if (includePath) {
cmSystemTools::ExpandListArgument(includePath, this->IncludePath);
- }
- else
- {
+ } else {
// Fallback to the old directory level variable if no per-target var:
includePathVar = "CMAKE_";
includePathVar += lang;
includePathVar += "_INCLUDE_PATH";
includePath = mf->GetDefinition(includePathVar);
- if(includePath)
- {
+ if (includePath) {
cmSystemTools::ExpandListArgument(includePath, this->IncludePath);
- }
}
+ }
}
diff --git a/Source/cmDepends.h b/Source/cmDepends.h
index 4f6517e..a62f8c2 100644
--- a/Source/cmDepends.h
+++ b/Source/cmDepends.h
@@ -29,10 +29,10 @@ class cmDepends
public:
/** Instances need to know the build directory name and the relative
path from the build directory to the target file. */
- cmDepends(cmLocalGenerator* lg=0, const char* targetDir="");
+ cmDepends(cmLocalGenerator* lg = 0, const char* targetDir = "");
/** at what level will the compile be done from */
- void SetCompileDirectory(const char *dir) {this->CompileDirectory = dir;}
+ void SetCompileDirectory(const char* dir) { this->CompileDirectory = dir; }
/** Set the local generator for the directory in which we are
scanning dependencies. This is not a full local generator; it
@@ -53,27 +53,30 @@ public:
virtual ~cmDepends();
/** Write dependencies for the target file. */
- bool Write(std::ostream &makeDepends, std::ostream &internalDepends);
+ bool Write(std::ostream& makeDepends, std::ostream& internalDepends);
- class DependencyVector: public std::vector<std::string> {};
+ class DependencyVector : public std::vector<std::string>
+ {
+ };
/** Check dependencies for the target file. Returns true if
dependencies are okay and false if they must be generated. If
they must be generated Clear has already been called to wipe out
the old dependencies.
Dependencies which are still valid will be stored in validDeps. */
- bool Check(const char *makeFile, const char* internalFile,
+ bool Check(const char* makeFile, const char* internalFile,
std::map<std::string, DependencyVector>& validDeps);
/** Clear dependencies for the target file so they will be regenerated. */
- void Clear(const char *file);
+ void Clear(const char* file);
/** Set the file comparison object */
- void SetFileComparison(cmFileTimeComparison* fc) {
- this->FileComparison = fc; }
+ void SetFileComparison(cmFileTimeComparison* fc)
+ {
+ this->FileComparison = fc;
+ }
protected:
-
// Write dependencies for the target file to the given stream.
// Return true for success and false for failure.
virtual bool WriteDependencies(const std::set<std::string>& sources,
@@ -84,9 +87,9 @@ protected:
// Check dependencies for the target file in the given stream.
// Return false if dependencies must be regenerated and true
// otherwise.
- virtual bool CheckDependencies(std::istream& internalDepends,
- const char* internalDependsFileName,
- std::map<std::string, DependencyVector>& validDeps);
+ virtual bool CheckDependencies(
+ std::istream& internalDepends, const char* internalDependsFileName,
+ std::map<std::string, DependencyVector>& validDeps);
// Finalize the dependency information for the target.
virtual bool Finalize(std::ostream& makeDepends,
@@ -117,7 +120,7 @@ protected:
void SetIncludePathFromLanguage(const std::string& lang);
private:
- cmDepends(cmDepends const&); // Purposely not implemented.
+ cmDepends(cmDepends const&); // Purposely not implemented.
void operator=(cmDepends const&); // Purposely not implemented.
};
diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx
index 2fab890..0a5c7fa 100644
--- a/Source/cmDependsC.cxx
+++ b/Source/cmDependsC.cxx
@@ -20,8 +20,7 @@
#include <ctype.h> // isspace
-
-#define INCLUDE_REGEX_LINE \
+#define INCLUDE_REGEX_LINE \
"^[ \t]*#[ \t]*(include|import)[ \t]*[<\"]([^\">]+)([\">])"
#define INCLUDE_REGEX_LINE_MARKER "#IncludeRegexLine: "
@@ -30,16 +29,15 @@
#define INCLUDE_REGEX_TRANSFORM_MARKER "#IncludeRegexTransform: "
cmDependsC::cmDependsC()
-: ValidDeps(0)
+ : ValidDeps(0)
{
}
-cmDependsC::cmDependsC(cmLocalGenerator* lg,
- const char* targetDir,
- const std::string& lang,
- const std::map<std::string, DependencyVector>* validDeps)
-: cmDepends(lg, targetDir)
-, ValidDeps(validDeps)
+cmDependsC::cmDependsC(
+ cmLocalGenerator* lg, const char* targetDir, const std::string& lang,
+ const std::map<std::string, DependencyVector>* validDeps)
+ : cmDepends(lg, targetDir)
+ , ValidDeps(validDeps)
{
cmMakefile* mf = lg->GetMakefile();
@@ -50,19 +48,17 @@ cmDependsC::cmDependsC(cmLocalGenerator* lg,
std::string scanRegex = "^.*$";
std::string complainRegex = "^$";
{
- std::string scanRegexVar = "CMAKE_";
- scanRegexVar += lang;
- scanRegexVar += "_INCLUDE_REGEX_SCAN";
- if(const char* sr = mf->GetDefinition(scanRegexVar))
- {
- scanRegex = sr;
+ std::string scanRegexVar = "CMAKE_";
+ scanRegexVar += lang;
+ scanRegexVar += "_INCLUDE_REGEX_SCAN";
+ if (const char* sr = mf->GetDefinition(scanRegexVar)) {
+ scanRegex = sr;
}
- std::string complainRegexVar = "CMAKE_";
- complainRegexVar += lang;
- complainRegexVar += "_INCLUDE_REGEX_COMPLAIN";
- if(const char* cr = mf->GetDefinition(complainRegexVar))
- {
- complainRegex = cr;
+ std::string complainRegexVar = "CMAKE_";
+ complainRegexVar += lang;
+ complainRegexVar += "_INCLUDE_REGEX_COMPLAIN";
+ if (const char* cr = mf->GetDefinition(complainRegexVar)) {
+ complainRegex = cr;
}
}
@@ -97,151 +93,128 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
std::ostream& internalDepends)
{
// Make sure this is a scanning instance.
- if(sources.empty() || sources.begin()->empty())
- {
+ if (sources.empty() || sources.begin()->empty()) {
cmSystemTools::Error("Cannot scan dependencies without a source file.");
return false;
- }
- if(obj.empty())
- {
+ }
+ if (obj.empty()) {
cmSystemTools::Error("Cannot scan dependencies without an object file.");
return false;
- }
+ }
std::set<std::string> dependencies;
bool haveDeps = false;
- if (this->ValidDeps != 0)
- {
+ if (this->ValidDeps != 0) {
std::map<std::string, DependencyVector>::const_iterator tmpIt =
- this->ValidDeps->find(obj);
- if (tmpIt!= this->ValidDeps->end())
- {
+ this->ValidDeps->find(obj);
+ if (tmpIt != this->ValidDeps->end()) {
dependencies.insert(tmpIt->second.begin(), tmpIt->second.end());
haveDeps = true;
- }
}
+ }
- if (!haveDeps)
- {
+ if (!haveDeps) {
// Walk the dependency graph starting with the source file.
int srcFiles = (int)sources.size();
this->Encountered.clear();
- for(std::set<std::string>::const_iterator srcIt = sources.begin();
- srcIt != sources.end(); ++srcIt)
- {
+ for (std::set<std::string>::const_iterator srcIt = sources.begin();
+ srcIt != sources.end(); ++srcIt) {
UnscannedEntry root;
root.FileName = *srcIt;
this->Unscanned.push(root);
this->Encountered.insert(*srcIt);
- }
+ }
std::set<std::string> scanned;
// Use reserve to allocate enough memory for tempPathStr
// so that during the loops no memory is allocated or freed
std::string tempPathStr;
- tempPathStr.reserve(4*1024);
+ tempPathStr.reserve(4 * 1024);
- while(!this->Unscanned.empty())
- {
+ while (!this->Unscanned.empty()) {
// Get the next file to scan.
UnscannedEntry current = this->Unscanned.front();
this->Unscanned.pop();
// If not a full path, find the file in the include path.
std::string fullName;
- if((srcFiles>0)
- || cmSystemTools::FileIsFullPath(current.FileName.c_str()))
- {
- if(cmSystemTools::FileExists(current.FileName.c_str(), true))
- {
+ if ((srcFiles > 0) ||
+ cmSystemTools::FileIsFullPath(current.FileName.c_str())) {
+ if (cmSystemTools::FileExists(current.FileName.c_str(), true)) {
fullName = current.FileName;
- }
}
- else if(!current.QuotedLocation.empty() &&
- cmSystemTools::FileExists(current.QuotedLocation.c_str(), true))
- {
+ } else if (!current.QuotedLocation.empty() &&
+ cmSystemTools::FileExists(current.QuotedLocation.c_str(),
+ true)) {
// The include statement producing this entry was a double-quote
// include and the included file is present in the directory of
// the source containing the include statement.
fullName = current.QuotedLocation;
- }
- else
- {
- std::map<std::string, std::string>::iterator
- headerLocationIt=this->HeaderLocationCache.find(current.FileName);
- if (headerLocationIt!=this->HeaderLocationCache.end())
- {
- fullName=headerLocationIt->second;
- }
- else for(std::vector<std::string>::const_iterator i =
- this->IncludePath.begin(); i != this->IncludePath.end(); ++i)
- {
- // Construct the name of the file as if it were in the current
- // include directory. Avoid using a leading "./".
-
- tempPathStr =
- cmSystemTools::CollapseCombinedPath(*i, current.FileName);
-
- // Look for the file in this location.
- if(cmSystemTools::FileExists(tempPathStr.c_str(), true))
- {
- fullName = tempPathStr;
- HeaderLocationCache[current.FileName]=fullName;
- break;
+ } else {
+ std::map<std::string, std::string>::iterator headerLocationIt =
+ this->HeaderLocationCache.find(current.FileName);
+ if (headerLocationIt != this->HeaderLocationCache.end()) {
+ fullName = headerLocationIt->second;
+ } else
+ for (std::vector<std::string>::const_iterator i =
+ this->IncludePath.begin();
+ i != this->IncludePath.end(); ++i) {
+ // Construct the name of the file as if it were in the current
+ // include directory. Avoid using a leading "./".
+
+ tempPathStr =
+ cmSystemTools::CollapseCombinedPath(*i, current.FileName);
+
+ // Look for the file in this location.
+ if (cmSystemTools::FileExists(tempPathStr.c_str(), true)) {
+ fullName = tempPathStr;
+ HeaderLocationCache[current.FileName] = fullName;
+ break;
}
}
- }
+ }
// Complain if the file cannot be found and matches the complain
// regex.
- if(fullName.empty() &&
- this->IncludeRegexComplain.find(current.FileName.c_str()))
- {
- cmSystemTools::Error("Cannot find file \"",
- current.FileName.c_str(), "\".");
+ if (fullName.empty() &&
+ this->IncludeRegexComplain.find(current.FileName.c_str())) {
+ cmSystemTools::Error("Cannot find file \"", current.FileName.c_str(),
+ "\".");
return false;
- }
+ }
// Scan the file if it was found and has not been scanned already.
- if(!fullName.empty() && (scanned.find(fullName) == scanned.end()))
- {
+ if (!fullName.empty() && (scanned.find(fullName) == scanned.end())) {
// Record scanned files.
scanned.insert(fullName);
// Check whether this file is already in the cache
- std::map<std::string, cmIncludeLines*>::iterator fileIt=
+ std::map<std::string, cmIncludeLines*>::iterator fileIt =
this->FileCache.find(fullName);
- if (fileIt!=this->FileCache.end())
- {
- fileIt->second->Used=true;
+ if (fileIt != this->FileCache.end()) {
+ fileIt->second->Used = true;
dependencies.insert(fullName);
- for (std::vector<UnscannedEntry>::const_iterator incIt=
- fileIt->second->UnscannedEntries.begin();
- incIt!=fileIt->second->UnscannedEntries.end(); ++incIt)
- {
+ for (std::vector<UnscannedEntry>::const_iterator incIt =
+ fileIt->second->UnscannedEntries.begin();
+ incIt != fileIt->second->UnscannedEntries.end(); ++incIt) {
if (this->Encountered.find(incIt->FileName) ==
- this->Encountered.end())
- {
+ this->Encountered.end()) {
this->Encountered.insert(incIt->FileName);
this->Unscanned.push(*incIt);
- }
}
}
- else
- {
+ } else {
// Try to scan the file. Just leave it out if we cannot find
// it.
cmsys::ifstream fin(fullName.c_str());
- if(fin)
- {
+ if (fin) {
cmsys::FStream::BOM bom = cmsys::FStream::ReadBOM(fin);
- if(bom == cmsys::FStream::BOM_None ||
- bom == cmsys::FStream::BOM_UTF8)
- {
+ if (bom == cmsys::FStream::BOM_None ||
+ bom == cmsys::FStream::BOM_UTF8) {
// Add this file as a dependency.
dependencies.insert(fullName);
@@ -249,18 +222,16 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
// containing the file to handle double-quote includes.
std::string dir = cmSystemTools::GetFilenamePath(fullName);
this->Scan(fin, dir.c_str(), fullName);
- }
- else
- {
+ } else {
// Skip file with encoding we do not implement.
- }
}
}
}
+ }
srcFiles--;
- }
}
+ }
// Write the dependencies to the output stream. Makefile rules
// written by the original local generator for this directory
@@ -268,21 +239,19 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
// directory. We must do the same here.
std::string obj_i =
this->LocalGenerator->Convert(obj, cmLocalGenerator::HOME_OUTPUT);
- std::string obj_m =
- this->LocalGenerator->ConvertToOutputFormat(obj_i,
- cmLocalGenerator::MAKERULE);
+ std::string obj_m = this->LocalGenerator->ConvertToOutputFormat(
+ obj_i, cmLocalGenerator::MAKERULE);
internalDepends << obj_i << std::endl;
- for(std::set<std::string>::const_iterator i=dependencies.begin();
- i != dependencies.end(); ++i)
- {
- makeDepends << obj_m << ": " <<
- this->LocalGenerator->Convert(*i,
- cmLocalGenerator::HOME_OUTPUT,
- cmLocalGenerator::MAKERULE)
+ for (std::set<std::string>::const_iterator i = dependencies.begin();
+ i != dependencies.end(); ++i) {
+ makeDepends << obj_m << ": "
+ << this->LocalGenerator->Convert(*i,
+ cmLocalGenerator::HOME_OUTPUT,
+ cmLocalGenerator::MAKERULE)
<< std::endl;
internalDepends << " " << *i << std::endl;
- }
+ }
makeDepends << std::endl;
return true;
@@ -290,169 +259,136 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
void cmDependsC::ReadCacheFile()
{
- if(this->CacheFileName.empty())
- {
+ if (this->CacheFileName.empty()) {
return;
- }
+ }
cmsys::ifstream fin(this->CacheFileName.c_str());
- if(!fin)
- {
+ if (!fin) {
return;
- }
+ }
std::string line;
- cmIncludeLines* cacheEntry=0;
- bool haveFileName=false;
+ cmIncludeLines* cacheEntry = 0;
+ bool haveFileName = false;
- while(cmSystemTools::GetLineFromStream(fin, line))
- {
- if (line.empty())
- {
- cacheEntry=0;
- haveFileName=false;
+ while (cmSystemTools::GetLineFromStream(fin, line)) {
+ if (line.empty()) {
+ cacheEntry = 0;
+ haveFileName = false;
continue;
- }
- //the first line after an empty line is the name of the parsed file
- if (haveFileName==false)
- {
- haveFileName=true;
- int newer=0;
+ }
+ // the first line after an empty line is the name of the parsed file
+ if (haveFileName == false) {
+ haveFileName = true;
+ int newer = 0;
cmFileTimeComparison comp;
- bool res=comp.FileTimeCompare(this->CacheFileName.c_str(),
- line.c_str(), &newer);
+ bool res = comp.FileTimeCompare(this->CacheFileName.c_str(),
+ line.c_str(), &newer);
- if ((res==true) && (newer==1)) //cache is newer than the parsed file
- {
- cacheEntry=new cmIncludeLines;
- this->FileCache[line]=cacheEntry;
- }
+ if ((res == true) && (newer == 1)) // cache is newer than the parsed file
+ {
+ cacheEntry = new cmIncludeLines;
+ this->FileCache[line] = cacheEntry;
+ }
// file doesn't exist, check that the regular expressions
// haven't changed
- else if (res==false)
- {
- if (line.find(INCLUDE_REGEX_LINE_MARKER) == 0)
- {
- if (line != this->IncludeRegexLineString)
- {
+ else if (res == false) {
+ if (line.find(INCLUDE_REGEX_LINE_MARKER) == 0) {
+ if (line != this->IncludeRegexLineString) {
return;
- }
}
- else if (line.find(INCLUDE_REGEX_SCAN_MARKER) == 0)
- {
- if (line != this->IncludeRegexScanString)
- {
+ } else if (line.find(INCLUDE_REGEX_SCAN_MARKER) == 0) {
+ if (line != this->IncludeRegexScanString) {
return;
- }
}
- else if (line.find(INCLUDE_REGEX_COMPLAIN_MARKER) == 0)
- {
- if (line != this->IncludeRegexComplainString)
- {
+ } else if (line.find(INCLUDE_REGEX_COMPLAIN_MARKER) == 0) {
+ if (line != this->IncludeRegexComplainString) {
return;
- }
}
- else if (line.find(INCLUDE_REGEX_TRANSFORM_MARKER) == 0)
- {
- if (line != this->IncludeRegexTransformString)
- {
+ } else if (line.find(INCLUDE_REGEX_TRANSFORM_MARKER) == 0) {
+ if (line != this->IncludeRegexTransformString) {
return;
- }
}
}
}
- else if (cacheEntry!=0)
- {
+ } else if (cacheEntry != 0) {
UnscannedEntry entry;
entry.FileName = line;
- if (cmSystemTools::GetLineFromStream(fin, line))
- {
- if (line!="-")
- {
- entry.QuotedLocation=line;
- }
- cacheEntry->UnscannedEntries.push_back(entry);
+ if (cmSystemTools::GetLineFromStream(fin, line)) {
+ if (line != "-") {
+ entry.QuotedLocation = line;
}
+ cacheEntry->UnscannedEntries.push_back(entry);
}
}
+ }
}
void cmDependsC::WriteCacheFile() const
{
- if(this->CacheFileName.empty())
- {
+ if (this->CacheFileName.empty()) {
return;
- }
+ }
cmsys::ofstream cacheOut(this->CacheFileName.c_str());
- if(!cacheOut)
- {
+ if (!cacheOut) {
return;
- }
+ }
cacheOut << this->IncludeRegexLineString << "\n\n";
cacheOut << this->IncludeRegexScanString << "\n\n";
cacheOut << this->IncludeRegexComplainString << "\n\n";
cacheOut << this->IncludeRegexTransformString << "\n\n";
- for (std::map<std::string, cmIncludeLines*>::const_iterator fileIt=
+ for (std::map<std::string, cmIncludeLines*>::const_iterator fileIt =
this->FileCache.begin();
- fileIt!=this->FileCache.end(); ++fileIt)
- {
- if (fileIt->second->Used)
- {
- cacheOut<<fileIt->first.c_str()<<std::endl;
-
- for (std::vector<UnscannedEntry>::const_iterator
- incIt=fileIt->second->UnscannedEntries.begin();
- incIt!=fileIt->second->UnscannedEntries.end(); ++incIt)
- {
- cacheOut<<incIt->FileName.c_str()<<std::endl;
- if (incIt->QuotedLocation.empty())
- {
- cacheOut<<"-"<<std::endl;
- }
- else
- {
- cacheOut<<incIt->QuotedLocation.c_str()<<std::endl;
- }
+ fileIt != this->FileCache.end(); ++fileIt) {
+ if (fileIt->second->Used) {
+ cacheOut << fileIt->first.c_str() << std::endl;
+
+ for (std::vector<UnscannedEntry>::const_iterator incIt =
+ fileIt->second->UnscannedEntries.begin();
+ incIt != fileIt->second->UnscannedEntries.end(); ++incIt) {
+ cacheOut << incIt->FileName.c_str() << std::endl;
+ if (incIt->QuotedLocation.empty()) {
+ cacheOut << "-" << std::endl;
+ } else {
+ cacheOut << incIt->QuotedLocation.c_str() << std::endl;
}
- cacheOut<<std::endl;
}
- }
+ cacheOut << std::endl;
+ }
+ }
}
void cmDependsC::Scan(std::istream& is, const char* directory,
- const std::string& fullName)
+ const std::string& fullName)
{
- cmIncludeLines* newCacheEntry=new cmIncludeLines;
- newCacheEntry->Used=true;
- this->FileCache[fullName]=newCacheEntry;
+ cmIncludeLines* newCacheEntry = new cmIncludeLines;
+ newCacheEntry->Used = true;
+ this->FileCache[fullName] = newCacheEntry;
// Read one line at a time.
std::string line;
- while(cmSystemTools::GetLineFromStream(is, line))
- {
+ while (cmSystemTools::GetLineFromStream(is, line)) {
// Transform the line content first.
- if(!this->TransformRules.empty())
- {
+ if (!this->TransformRules.empty()) {
this->TransformLine(line);
- }
+ }
// Match include directives.
- if(this->IncludeRegexLine.find(line.c_str()))
- {
+ if (this->IncludeRegexLine.find(line.c_str())) {
// Get the file being included.
UnscannedEntry entry;
entry.FileName = this->IncludeRegexLine.match(2);
cmSystemTools::ConvertToUnixSlashes(entry.FileName);
- if(this->IncludeRegexLine.match(3) == "\"" &&
- !cmSystemTools::FileIsFullPath(entry.FileName.c_str()))
- {
+ if (this->IncludeRegexLine.match(3) == "\"" &&
+ !cmSystemTools::FileIsFullPath(entry.FileName.c_str())) {
// This was a double-quoted include with a relative path. We
// must check for the file in the directory containing the
// file we are scanning.
entry.QuotedLocation =
cmSystemTools::CollapseCombinedPath(directory, entry.FileName);
- }
+ }
// Queue the file if it has not yet been encountered and it
// matches the regular expression for recursive scanning. Note
@@ -464,17 +400,16 @@ void cmDependsC::Scan(std::istream& is, const char* directory,
// file their own directory by simply using "filename.h" (#12619)
// This kind of problem will be fixed when a more
// preprocessor-like implementation of this scanner is created.
- if (this->IncludeRegexScan.find(entry.FileName.c_str()))
- {
+ if (this->IncludeRegexScan.find(entry.FileName.c_str())) {
newCacheEntry->UnscannedEntries.push_back(entry);
- if(this->Encountered.find(entry.FileName) == this->Encountered.end())
- {
+ if (this->Encountered.find(entry.FileName) ==
+ this->Encountered.end()) {
this->Encountered.insert(entry.FileName);
this->Unscanned.push(entry);
- }
}
}
}
+ }
}
void cmDependsC::SetupTransforms()
@@ -482,46 +417,40 @@ void cmDependsC::SetupTransforms()
// Get the transformation rules.
std::vector<std::string> transformRules;
cmMakefile* mf = this->LocalGenerator->GetMakefile();
- if(const char* xform =
- mf->GetDefinition("CMAKE_INCLUDE_TRANSFORMS"))
- {
+ if (const char* xform = mf->GetDefinition("CMAKE_INCLUDE_TRANSFORMS")) {
cmSystemTools::ExpandListArgument(xform, transformRules, true);
- }
- for(std::vector<std::string>::const_iterator tri = transformRules.begin();
- tri != transformRules.end(); ++tri)
- {
+ }
+ for (std::vector<std::string>::const_iterator tri = transformRules.begin();
+ tri != transformRules.end(); ++tri) {
this->ParseTransform(*tri);
- }
+ }
this->IncludeRegexTransformString = INCLUDE_REGEX_TRANSFORM_MARKER;
- if(!this->TransformRules.empty())
- {
+ if (!this->TransformRules.empty()) {
// Construct the regular expression to match lines to be
// transformed.
std::string xform = "^([ \t]*#[ \t]*(include|import)[ \t]*)(";
const char* sep = "";
- for(TransformRulesType::const_iterator tri = this->TransformRules.begin();
- tri != this->TransformRules.end(); ++tri)
- {
+ for (TransformRulesType::const_iterator tri = this->TransformRules.begin();
+ tri != this->TransformRules.end(); ++tri) {
xform += sep;
xform += tri->first;
sep = "|";
- }
+ }
xform += ")[ \t]*\\(([^),]*)\\)";
this->IncludeRegexTransform.compile(xform.c_str());
// Build a string that encodes all transformation rules and will
// change when rules are changed.
this->IncludeRegexTransformString += xform;
- for(TransformRulesType::const_iterator tri = this->TransformRules.begin();
- tri != this->TransformRules.end(); ++tri)
- {
+ for (TransformRulesType::const_iterator tri = this->TransformRules.begin();
+ tri != this->TransformRules.end(); ++tri) {
this->IncludeRegexTransformString += " ";
this->IncludeRegexTransformString += tri->first;
this->IncludeRegexTransformString += "(%)=";
this->IncludeRegexTransformString += tri->second;
- }
}
+ }
}
void cmDependsC::ParseTransform(std::string const& xform)
@@ -529,43 +458,36 @@ void cmDependsC::ParseTransform(std::string const& xform)
// A transform rule is of the form SOME_MACRO(%)=value-with-%
// We can simply separate with "(%)=".
std::string::size_type pos = xform.find("(%)=");
- if(pos == xform.npos || pos == 0)
- {
+ if (pos == xform.npos || pos == 0) {
return;
- }
+ }
std::string name = xform.substr(0, pos);
- std::string value = xform.substr(pos+4, xform.npos);
+ std::string value = xform.substr(pos + 4, xform.npos);
this->TransformRules[name] = value;
}
void cmDependsC::TransformLine(std::string& line)
{
// Check for a transform rule match. Return if none.
- if(!this->IncludeRegexTransform.find(line.c_str()))
- {
+ if (!this->IncludeRegexTransform.find(line.c_str())) {
return;
- }
+ }
TransformRulesType::const_iterator tri =
this->TransformRules.find(this->IncludeRegexTransform.match(3));
- if(tri == this->TransformRules.end())
- {
+ if (tri == this->TransformRules.end()) {
return;
- }
+ }
// Construct the transformed line.
std::string newline = this->IncludeRegexTransform.match(1);
std::string arg = this->IncludeRegexTransform.match(4);
- for(const char* c = tri->second.c_str(); *c; ++c)
- {
- if(*c == '%')
- {
+ for (const char* c = tri->second.c_str(); *c; ++c) {
+ if (*c == '%') {
newline += arg;
- }
- else
- {
+ } else {
newline += *c;
- }
}
+ }
// Return the transformed line.
line = newline;
diff --git a/Source/cmDependsC.h b/Source/cmDependsC.h
index cf0a423..e830aa8 100644
--- a/Source/cmDependsC.h
+++ b/Source/cmDependsC.h
@@ -20,7 +20,7 @@
/** \class cmDependsC
* \brief Dependency scanner for C and C++ object files.
*/
-class cmDependsC: public cmDepends
+class cmDependsC : public cmDepends
{
public:
/** Checking instances need to know the build directory name and the
@@ -36,13 +36,13 @@ public:
protected:
// Implement writing/checking methods required by superclass.
virtual bool WriteDependencies(const std::set<std::string>& sources,
- const std::string& obj,
+ const std::string& obj,
std::ostream& makeDepends,
std::ostream& internalDepends);
// Method to scan a single file.
void Scan(std::istream& is, const char* directory,
- const std::string& fullName);
+ const std::string& fullName);
// Regular expression to identify C preprocessor include directives.
cmsys::RegularExpression IncludeRegexLine;
@@ -74,24 +74,29 @@ public:
struct cmIncludeLines
{
- cmIncludeLines(): Used(false) {}
+ cmIncludeLines()
+ : Used(false)
+ {
+ }
std::vector<UnscannedEntry> UnscannedEntries;
bool Used;
};
+
protected:
const std::map<std::string, DependencyVector>* ValidDeps;
std::set<std::string> Encountered;
std::queue<UnscannedEntry> Unscanned;
- std::map<std::string, cmIncludeLines *> FileCache;
+ std::map<std::string, cmIncludeLines*> FileCache;
std::map<std::string, std::string> HeaderLocationCache;
std::string CacheFileName;
void WriteCacheFile() const;
void ReadCacheFile();
+
private:
- cmDependsC(cmDependsC const&); // Purposely not implemented.
+ cmDependsC(cmDependsC const&); // Purposely not implemented.
void operator=(cmDependsC const&); // Purposely not implemented.
};
diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx
index 2e4a276..b8af178 100644
--- a/Source/cmDependsFortran.cxx
+++ b/Source/cmDependsFortran.cxx
@@ -38,31 +38,28 @@ public:
typedef std::map<std::string, cmFortranSourceInfo> ObjectInfoMap;
ObjectInfoMap ObjectInfo;
- cmFortranSourceInfo& CreateObjectInfo(const char* obj,
- const char* src)
- {
+ cmFortranSourceInfo& CreateObjectInfo(const char* obj, const char* src)
+ {
std::map<std::string, cmFortranSourceInfo>::iterator i =
this->ObjectInfo.find(obj);
- if(i == this->ObjectInfo.end())
- {
- std::map<std::string, cmFortranSourceInfo>::value_type
- entry(obj, cmFortranSourceInfo());
+ if (i == this->ObjectInfo.end()) {
+ std::map<std::string, cmFortranSourceInfo>::value_type entry(
+ obj, cmFortranSourceInfo());
i = this->ObjectInfo.insert(entry).first;
i->second.Source = src;
- }
- return i->second;
}
+ return i->second;
+ }
};
-cmDependsFortran::cmDependsFortran():
- Internal(0)
+cmDependsFortran::cmDependsFortran()
+ : Internal(0)
{
}
-cmDependsFortran
-::cmDependsFortran(cmLocalGenerator* lg):
- cmDepends(lg),
- Internal(new cmDependsFortranInternals)
+cmDependsFortran::cmDependsFortran(cmLocalGenerator* lg)
+ : cmDepends(lg)
+ , Internal(new cmDependsFortranInternals)
{
// Configure the include file search path.
this->SetIncludePathFromLanguage("Fortran");
@@ -70,25 +67,22 @@ cmDependsFortran
// Get the list of definitions.
std::vector<std::string> definitions;
cmMakefile* mf = this->LocalGenerator->GetMakefile();
- if(const char* c_defines =
- mf->GetDefinition("CMAKE_TARGET_DEFINITIONS_Fortran"))
- {
+ if (const char* c_defines =
+ mf->GetDefinition("CMAKE_TARGET_DEFINITIONS_Fortran")) {
cmSystemTools::ExpandListArgument(c_defines, definitions);
- }
+ }
// translate i.e. FOO=BAR to FOO and add it to the list of defined
// preprocessor symbols
- for(std::vector<std::string>::const_iterator
- it = definitions.begin(); it != definitions.end(); ++it)
- {
+ for (std::vector<std::string>::const_iterator it = definitions.begin();
+ it != definitions.end(); ++it) {
std::string def = *it;
std::string::size_type assignment = def.find("=");
- if(assignment != std::string::npos)
- {
+ if (assignment != std::string::npos) {
def = it->substr(0, assignment);
- }
- this->PPDefinitions.insert(def);
}
+ this->PPDefinitions.insert(def);
+ }
}
cmDependsFortran::~cmDependsFortran()
@@ -96,26 +90,23 @@ cmDependsFortran::~cmDependsFortran()
delete this->Internal;
}
-bool cmDependsFortran::WriteDependencies(
- const std::set<std::string>& sources, const std::string& obj,
- std::ostream&, std::ostream&)
+bool cmDependsFortran::WriteDependencies(const std::set<std::string>& sources,
+ const std::string& obj, std::ostream&,
+ std::ostream&)
{
// Make sure this is a scanning instance.
- if(sources.empty() || sources.begin()->empty())
- {
+ if (sources.empty() || sources.begin()->empty()) {
cmSystemTools::Error("Cannot scan dependencies without a source file.");
return false;
- }
- if(obj.empty())
- {
+ }
+ if (obj.empty()) {
cmSystemTools::Error("Cannot scan dependencies without an object file.");
return false;
- }
+ }
bool okay = true;
- for(std::set<std::string>::const_iterator it = sources.begin();
- it != sources.end(); ++it)
- {
+ for (std::set<std::string>::const_iterator it = sources.begin();
+ it != sources.end(); ++it) {
const std::string& src = *it;
// Get the information object for this source.
cmFortranSourceInfo& info =
@@ -129,12 +120,11 @@ bool cmDependsFortran::WriteDependencies(
cmFortranParser_FilePush(&parser, src.c_str());
// Parse the translation unit.
- if(cmFortran_yyparse(parser.Scanner) != 0)
- {
+ if (cmFortran_yyparse(parser.Scanner) != 0) {
// Failed to parse the file. Report failure to write dependencies.
okay = false;
- }
}
+ }
return okay;
}
@@ -151,25 +141,21 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends,
cmMakefile* mf = this->LocalGenerator->GetMakefile();
std::string mod_dir =
mf->GetSafeDefinition("CMAKE_Fortran_TARGET_MODULE_DIR");
- if (mod_dir.empty())
- {
- mod_dir =
- this->LocalGenerator->GetCurrentBinaryDirectory();
- }
+ if (mod_dir.empty()) {
+ mod_dir = this->LocalGenerator->GetCurrentBinaryDirectory();
+ }
// Actually write dependencies to the streams.
typedef cmDependsFortranInternals::ObjectInfoMap ObjectInfoMap;
ObjectInfoMap const& objInfo = this->Internal->ObjectInfo;
- for(ObjectInfoMap::const_iterator i = objInfo.begin();
- i != objInfo.end(); ++i)
- {
- if(!this->WriteDependenciesReal(i->first.c_str(), i->second,
- mod_dir, stamp_dir,
- makeDepends, internalDepends))
- {
+ for (ObjectInfoMap::const_iterator i = objInfo.begin(); i != objInfo.end();
+ ++i) {
+ if (!this->WriteDependenciesReal(i->first.c_str(), i->second, mod_dir,
+ stamp_dir, makeDepends,
+ internalDepends)) {
return false;
- }
}
+ }
// Store the list of modules provided by this target.
std::string fiName = this->TargetDirectory;
@@ -178,23 +164,20 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends,
fiStream << "# The fortran modules provided by this target.\n";
fiStream << "provides\n";
std::set<std::string> const& provides = this->Internal->TargetProvides;
- for(std::set<std::string>::const_iterator i = provides.begin();
- i != provides.end(); ++i)
- {
+ for (std::set<std::string>::const_iterator i = provides.begin();
+ i != provides.end(); ++i) {
fiStream << " " << *i << "\n";
- }
+ }
// Create a script to clean the modules.
- if(!provides.empty())
- {
+ if (!provides.empty()) {
std::string fcName = this->TargetDirectory;
fcName += "/cmake_clean_Fortran.cmake";
cmGeneratedFileStream fcStream(fcName.c_str());
fcStream << "# Remove fortran modules provided by this target.\n";
fcStream << "FILE(REMOVE";
- for(std::set<std::string>::const_iterator i = provides.begin();
- i != provides.end(); ++i)
- {
+ for (std::set<std::string>::const_iterator i = provides.begin();
+ i != provides.end(); ++i) {
std::string mod_upper = mod_dir;
mod_upper += "/";
mod_upper += cmSystemTools::UpperCase(*i);
@@ -208,21 +191,21 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends,
stamp += *i;
stamp += ".mod.stamp";
fcStream << "\n";
- fcStream << " \"" <<
- this->LocalGenerator->Convert(mod_lower,
- cmLocalGenerator::START_OUTPUT)
+ fcStream << " \""
+ << this->LocalGenerator->Convert(mod_lower,
+ cmLocalGenerator::START_OUTPUT)
<< "\"\n";
- fcStream << " \"" <<
- this->LocalGenerator->Convert(mod_upper,
- cmLocalGenerator::START_OUTPUT)
+ fcStream << " \""
+ << this->LocalGenerator->Convert(mod_upper,
+ cmLocalGenerator::START_OUTPUT)
<< "\"\n";
- fcStream << " \"" <<
- this->LocalGenerator->Convert(stamp,
- cmLocalGenerator::START_OUTPUT)
+ fcStream << " \""
+ << this->LocalGenerator->Convert(stamp,
+ cmLocalGenerator::START_OUTPUT)
<< "\"\n";
- }
- fcStream << " )\n";
}
+ fcStream << " )\n";
+ }
return true;
}
@@ -231,26 +214,23 @@ void cmDependsFortran::LocateModules()
// Collect the set of modules provided and required by all sources.
typedef cmDependsFortranInternals::ObjectInfoMap ObjectInfoMap;
ObjectInfoMap const& objInfo = this->Internal->ObjectInfo;
- for(ObjectInfoMap::const_iterator infoI = objInfo.begin();
- infoI != objInfo.end(); ++infoI)
- {
+ for (ObjectInfoMap::const_iterator infoI = objInfo.begin();
+ infoI != objInfo.end(); ++infoI) {
cmFortranSourceInfo const& info = infoI->second;
// Include this module in the set provided by this target.
this->Internal->TargetProvides.insert(info.Provides.begin(),
info.Provides.end());
- for(std::set<std::string>::const_iterator i = info.Requires.begin();
- i != info.Requires.end(); ++i)
- {
+ for (std::set<std::string>::const_iterator i = info.Requires.begin();
+ i != info.Requires.end(); ++i) {
this->Internal->TargetRequires[*i] = "";
- }
}
+ }
// Short-circuit for simple targets.
- if(this->Internal->TargetRequires.empty())
- {
+ if (this->Internal->TargetRequires.empty()) {
return;
- }
+ }
// Match modules provided by this target to those it requires.
this->MatchLocalModules();
@@ -258,33 +238,29 @@ void cmDependsFortran::LocateModules()
// Load information about other targets.
cmMakefile* mf = this->LocalGenerator->GetMakefile();
std::vector<std::string> infoFiles;
- if(const char* infoFilesValue =
- mf->GetDefinition("CMAKE_TARGET_LINKED_INFO_FILES"))
- {
+ if (const char* infoFilesValue =
+ mf->GetDefinition("CMAKE_TARGET_LINKED_INFO_FILES")) {
cmSystemTools::ExpandListArgument(infoFilesValue, infoFiles);
- }
- for(std::vector<std::string>::const_iterator i = infoFiles.begin();
- i != infoFiles.end(); ++i)
- {
+ }
+ for (std::vector<std::string>::const_iterator i = infoFiles.begin();
+ i != infoFiles.end(); ++i) {
std::string targetDir = cmSystemTools::GetFilenamePath(*i);
std::string fname = targetDir + "/fortran.internal";
cmsys::ifstream fin(fname.c_str());
- if(fin)
- {
+ if (fin) {
this->MatchRemoteModules(fin, targetDir.c_str());
- }
}
+ }
}
void cmDependsFortran::MatchLocalModules()
{
const char* stampDir = this->TargetDirectory.c_str();
std::set<std::string> const& provides = this->Internal->TargetProvides;
- for(std::set<std::string>::const_iterator i = provides.begin();
- i != provides.end(); ++i)
- {
+ for (std::set<std::string>::const_iterator i = provides.begin();
+ i != provides.end(); ++i) {
this->ConsiderModule(i->c_str(), stampDir);
- }
+ }
}
void cmDependsFortran::MatchRemoteModules(std::istream& fin,
@@ -292,59 +268,47 @@ void cmDependsFortran::MatchRemoteModules(std::istream& fin,
{
std::string line;
bool doing_provides = false;
- while(cmSystemTools::GetLineFromStream(fin, line))
- {
+ while (cmSystemTools::GetLineFromStream(fin, line)) {
// Ignore comments and empty lines.
- if(line.empty() || line[0] == '#' || line[0] == '\r')
- {
+ if (line.empty() || line[0] == '#' || line[0] == '\r') {
continue;
- }
+ }
- if(line[0] == ' ')
- {
- if(doing_provides)
- {
- this->ConsiderModule(line.c_str()+1, stampDir);
- }
+ if (line[0] == ' ') {
+ if (doing_provides) {
+ this->ConsiderModule(line.c_str() + 1, stampDir);
}
- else if(line == "provides")
- {
+ } else if (line == "provides") {
doing_provides = true;
- }
- else
- {
+ } else {
doing_provides = false;
- }
}
+ }
}
-void cmDependsFortran::ConsiderModule(const char* name,
- const char* stampDir)
+void cmDependsFortran::ConsiderModule(const char* name, const char* stampDir)
{
// Locate each required module.
typedef cmDependsFortranInternals::TargetRequiresMap TargetRequiresMap;
TargetRequiresMap::iterator required =
this->Internal->TargetRequires.find(name);
- if(required != this->Internal->TargetRequires.end() &&
- required->second.empty())
- {
+ if (required != this->Internal->TargetRequires.end() &&
+ required->second.empty()) {
// The module is provided by a CMake target. It will have a stamp file.
std::string stampFile = stampDir;
stampFile += "/";
stampFile += name;
stampFile += ".mod.stamp";
required->second = stampFile;
- }
+ }
}
-bool
-cmDependsFortran
-::WriteDependenciesReal(const char *obj,
- cmFortranSourceInfo const& info,
- std::string const& mod_dir,
- const char* stamp_dir,
- std::ostream& makeDepends,
- std::ostream& internalDepends)
+bool cmDependsFortran::WriteDependenciesReal(const char* obj,
+ cmFortranSourceInfo const& info,
+ std::string const& mod_dir,
+ const char* stamp_dir,
+ std::ostream& makeDepends,
+ std::ostream& internalDepends)
{
typedef cmDependsFortranInternals::TargetRequiresMap TargetRequiresMap;
@@ -354,39 +318,34 @@ cmDependsFortran
// Write the include dependencies to the output stream.
std::string obj_i =
this->LocalGenerator->Convert(obj, cmLocalGenerator::HOME_OUTPUT);
- std::string obj_m =
- this->LocalGenerator->ConvertToOutputFormat(obj_i,
- cmLocalGenerator::MAKERULE);
+ std::string obj_m = this->LocalGenerator->ConvertToOutputFormat(
+ obj_i, cmLocalGenerator::MAKERULE);
internalDepends << obj_i << std::endl;
internalDepends << " " << src << std::endl;
- for(std::set<std::string>::const_iterator i = info.Includes.begin();
- i != info.Includes.end(); ++i)
- {
- makeDepends << obj_m << ": " <<
- this->LocalGenerator->Convert(*i,
- cmLocalGenerator::HOME_OUTPUT,
- cmLocalGenerator::MAKERULE)
+ for (std::set<std::string>::const_iterator i = info.Includes.begin();
+ i != info.Includes.end(); ++i) {
+ makeDepends << obj_m << ": "
+ << this->LocalGenerator->Convert(*i,
+ cmLocalGenerator::HOME_OUTPUT,
+ cmLocalGenerator::MAKERULE)
<< std::endl;
internalDepends << " " << *i << std::endl;
- }
+ }
makeDepends << std::endl;
// Write module requirements to the output stream.
- for(std::set<std::string>::const_iterator i = info.Requires.begin();
- i != info.Requires.end(); ++i)
- {
+ for (std::set<std::string>::const_iterator i = info.Requires.begin();
+ i != info.Requires.end(); ++i) {
// Require only modules not provided in the same source.
- if(std::set<std::string>::const_iterator(info.Provides.find(*i)) !=
- info.Provides.end())
- {
+ if (std::set<std::string>::const_iterator(info.Provides.find(*i)) !=
+ info.Provides.end()) {
continue;
- }
+ }
// If the module is provided in this target special handling is
// needed.
- if(this->Internal->TargetProvides.find(*i) !=
- this->Internal->TargetProvides.end())
- {
+ if (this->Internal->TargetProvides.find(*i) !=
+ this->Internal->TargetProvides.end()) {
// The module is provided by a different source in the same
// target. Add the proxy dependency to make sure the other
// source builds first.
@@ -394,67 +353,57 @@ cmDependsFortran
proxy += "/";
proxy += *i;
proxy += ".mod.proxy";
- proxy = this->LocalGenerator->Convert(proxy,
- cmLocalGenerator::HOME_OUTPUT,
- cmLocalGenerator::MAKERULE);
+ proxy = this->LocalGenerator->Convert(
+ proxy, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKERULE);
// since we require some things add them to our list of requirements
makeDepends << obj_m << ".requires: " << proxy << std::endl;
- }
+ }
// The object file should depend on timestamped files for the
// modules it uses.
TargetRequiresMap::const_iterator required =
this->Internal->TargetRequires.find(*i);
- if(required == this->Internal->TargetRequires.end()) { abort(); }
- if(!required->second.empty())
- {
+ if (required == this->Internal->TargetRequires.end()) {
+ abort();
+ }
+ if (!required->second.empty()) {
// This module is known. Depend on its timestamp file.
- std::string stampFile =
- this->LocalGenerator->Convert(required->second,
- cmLocalGenerator::HOME_OUTPUT,
- cmLocalGenerator::MAKERULE);
+ std::string stampFile = this->LocalGenerator->Convert(
+ required->second, cmLocalGenerator::HOME_OUTPUT,
+ cmLocalGenerator::MAKERULE);
makeDepends << obj_m << ": " << stampFile << "\n";
- }
- else
- {
+ } else {
// This module is not known to CMake. Try to locate it where
// the compiler will and depend on that.
std::string module;
- if(this->FindModule(*i, module))
- {
- module =
- this->LocalGenerator->Convert(module,
- cmLocalGenerator::HOME_OUTPUT,
- cmLocalGenerator::MAKERULE);
+ if (this->FindModule(*i, module)) {
+ module = this->LocalGenerator->Convert(
+ module, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKERULE);
makeDepends << obj_m << ": " << module << "\n";
- }
}
}
+ }
// Write provided modules to the output stream.
- for(std::set<std::string>::const_iterator i = info.Provides.begin();
- i != info.Provides.end(); ++i)
- {
+ for (std::set<std::string>::const_iterator i = info.Provides.begin();
+ i != info.Provides.end(); ++i) {
std::string proxy = stamp_dir;
proxy += "/";
proxy += *i;
proxy += ".mod.proxy";
- proxy = this->LocalGenerator->Convert(proxy,
- cmLocalGenerator::HOME_OUTPUT,
+ proxy = this->LocalGenerator->Convert(proxy, cmLocalGenerator::HOME_OUTPUT,
cmLocalGenerator::MAKERULE);
makeDepends << proxy << ": " << obj_m << ".provides" << std::endl;
- }
+ }
// If any modules are provided then they must be converted to stamp files.
- if(!info.Provides.empty())
- {
+ if (!info.Provides.empty()) {
// Create a target to copy the module after the object file
// changes.
makeDepends << obj_m << ".provides.build:\n";
- for(std::set<std::string>::const_iterator i = info.Provides.begin();
- i != info.Provides.end(); ++i)
- {
+ for (std::set<std::string>::const_iterator i = info.Provides.begin();
+ i != info.Provides.end(); ++i) {
// Include this module in the set provided by this target.
this->Internal->TargetProvides.insert(*i);
@@ -465,28 +414,23 @@ cmDependsFortran
std::string modFile = mod_dir;
modFile += "/";
modFile += *i;
- modFile =
- this->LocalGenerator->Convert(modFile,
- cmLocalGenerator::HOME_OUTPUT,
- cmLocalGenerator::SHELL);
+ modFile = this->LocalGenerator->Convert(
+ modFile, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::SHELL);
std::string stampFile = stamp_dir;
stampFile += "/";
stampFile += m;
stampFile += ".mod.stamp";
- stampFile =
- this->LocalGenerator->Convert(stampFile,
- cmLocalGenerator::HOME_OUTPUT,
- cmLocalGenerator::SHELL);
- makeDepends << "\t$(CMAKE_COMMAND) -E cmake_copy_f90_mod "
- << modFile << " " << stampFile;
+ stampFile = this->LocalGenerator->Convert(
+ stampFile, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::SHELL);
+ makeDepends << "\t$(CMAKE_COMMAND) -E cmake_copy_f90_mod " << modFile
+ << " " << stampFile;
cmMakefile* mf = this->LocalGenerator->GetMakefile();
const char* cid = mf->GetDefinition("CMAKE_Fortran_COMPILER_ID");
- if(cid && *cid)
- {
+ if (cid && *cid) {
makeDepends << " " << cid;
- }
- makeDepends << "\n";
}
+ makeDepends << "\n";
+ }
// After copying the modules update the timestamp file so that
// copying will not be done again until the source rebuilds.
makeDepends << "\t$(CMAKE_COMMAND) -E touch " << obj_m
@@ -496,17 +440,15 @@ cmDependsFortran
// the target finishes building.
std::string driver = this->TargetDirectory;
driver += "/build";
- driver = this->LocalGenerator->Convert(driver,
- cmLocalGenerator::HOME_OUTPUT,
- cmLocalGenerator::MAKERULE);
+ driver = this->LocalGenerator->Convert(
+ driver, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKERULE);
makeDepends << driver << ": " << obj_m << ".provides.build\n";
- }
+ }
return true;
}
-bool cmDependsFortran::FindModule(std::string const& name,
- std::string& module)
+bool cmDependsFortran::FindModule(std::string const& name, std::string& module)
{
// Construct possible names for the module file.
std::string mod_upper = cmSystemTools::UpperCase(name);
@@ -516,29 +458,26 @@ bool cmDependsFortran::FindModule(std::string const& name,
// Search the include path for the module.
std::string fullName;
- for(std::vector<std::string>::const_iterator i =
- this->IncludePath.begin(); i != this->IncludePath.end(); ++i)
- {
+ for (std::vector<std::string>::const_iterator i = this->IncludePath.begin();
+ i != this->IncludePath.end(); ++i) {
// Try the lower-case name.
fullName = *i;
fullName += "/";
fullName += mod_lower;
- if(cmSystemTools::FileExists(fullName.c_str(), true))
- {
+ if (cmSystemTools::FileExists(fullName.c_str(), true)) {
module = fullName;
return true;
- }
+ }
// Try the upper-case name.
fullName = *i;
fullName += "/";
fullName += mod_upper;
- if(cmSystemTools::FileExists(fullName.c_str(), true))
- {
+ if (cmSystemTools::FileExists(fullName.c_str(), true)) {
module = fullName;
return true;
- }
}
+ }
return false;
}
@@ -557,12 +496,13 @@ bool cmDependsFortran::CopyModule(const std::vector<std::string>& args)
std::string mod = args[2];
std::string stamp = args[3];
std::string compilerId;
- if(args.size() >= 5)
- {
+ if (args.size() >= 5) {
compilerId = args[4];
- }
+ }
std::string mod_dir = cmSystemTools::GetFilenamePath(mod);
- if(!mod_dir.empty()) { mod_dir += "/"; }
+ if (!mod_dir.empty()) {
+ mod_dir += "/";
+ }
std::string mod_upper = mod_dir;
mod_upper += cmSystemTools::UpperCase(cmSystemTools::GetFilenameName(mod));
std::string mod_lower = mod_dir;
@@ -570,101 +510,81 @@ bool cmDependsFortran::CopyModule(const std::vector<std::string>& args)
mod += ".mod";
mod_upper += ".mod";
mod_lower += ".mod";
- if(cmSystemTools::FileExists(mod_upper.c_str(), true))
- {
- if(cmDependsFortran::ModulesDiffer(mod_upper.c_str(), stamp.c_str(),
- compilerId.c_str()))
- {
- if(!cmSystemTools::CopyFileAlways(mod_upper, stamp))
- {
- std::cerr << "Error copying Fortran module from \""
- << mod_upper << "\" to \"" << stamp
- << "\".\n";
+ if (cmSystemTools::FileExists(mod_upper.c_str(), true)) {
+ if (cmDependsFortran::ModulesDiffer(mod_upper.c_str(), stamp.c_str(),
+ compilerId.c_str())) {
+ if (!cmSystemTools::CopyFileAlways(mod_upper, stamp)) {
+ std::cerr << "Error copying Fortran module from \"" << mod_upper
+ << "\" to \"" << stamp << "\".\n";
return false;
- }
}
- return true;
}
- else if(cmSystemTools::FileExists(mod_lower.c_str(), true))
- {
- if(cmDependsFortran::ModulesDiffer(mod_lower.c_str(), stamp.c_str(),
- compilerId.c_str()))
- {
- if(!cmSystemTools::CopyFileAlways(mod_lower, stamp))
- {
- std::cerr << "Error copying Fortran module from \""
- << mod_lower << "\" to \"" << stamp
- << "\".\n";
+ return true;
+ } else if (cmSystemTools::FileExists(mod_lower.c_str(), true)) {
+ if (cmDependsFortran::ModulesDiffer(mod_lower.c_str(), stamp.c_str(),
+ compilerId.c_str())) {
+ if (!cmSystemTools::CopyFileAlways(mod_lower, stamp)) {
+ std::cerr << "Error copying Fortran module from \"" << mod_lower
+ << "\" to \"" << stamp << "\".\n";
return false;
- }
}
- return true;
}
+ return true;
+ }
- std::cerr << "Error copying Fortran module \"" << args[2]
- << "\". Tried \"" << mod_upper
- << "\" and \"" << mod_lower << "\".\n";
+ std::cerr << "Error copying Fortran module \"" << args[2] << "\". Tried \""
+ << mod_upper << "\" and \"" << mod_lower << "\".\n";
return false;
}
// Helper function to look for a short sequence in a stream. If this
// is later used for longer sequences it should be re-written using an
// efficient string search algorithm such as Boyer-Moore.
-static
-bool cmFortranStreamContainsSequence(std::istream& ifs,
- const char* seq, int len)
+static bool cmFortranStreamContainsSequence(std::istream& ifs, const char* seq,
+ int len)
{
assert(len > 0);
int cur = 0;
- while(cur < len)
- {
+ while (cur < len) {
// Get the next character.
int token = ifs.get();
- if(!ifs)
- {
+ if (!ifs) {
return false;
- }
+ }
// Check the character.
- if(token == static_cast<int>(seq[cur]))
- {
+ if (token == static_cast<int>(seq[cur])) {
++cur;
- }
- else
- {
+ } else {
// Assume the sequence has no repeating subsequence.
cur = 0;
- }
}
+ }
// The entire sequence was matched.
return true;
}
// Helper function to compare the remaining content in two streams.
-static bool cmFortranStreamsDiffer(std::istream& ifs1,
- std::istream& ifs2)
+static bool cmFortranStreamsDiffer(std::istream& ifs1, std::istream& ifs2)
{
// Compare the remaining content.
- for(;;)
- {
+ for (;;) {
int ifs1_c = ifs1.get();
int ifs2_c = ifs2.get();
- if(!ifs1 && !ifs2)
- {
+ if (!ifs1 && !ifs2) {
// We have reached the end of both streams simultaneously.
// The streams are identical.
return false;
- }
+ }
- if(!ifs1 || !ifs2 || ifs1_c != ifs2_c)
- {
+ if (!ifs1 || !ifs2 || ifs1_c != ifs2_c) {
// We have reached the end of one stream before the other or
// found differing content. The streams are different.
break;
- }
}
+ }
return true;
}
@@ -701,15 +621,13 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile,
TODO ...
*/
-
/* Compilers which do _not_ produce different mod content when the same
* source is compiled twice
* -SunPro
*/
- if(strcmp(compilerId, "SunPro") == 0)
- {
+ if (strcmp(compilerId, "SunPro") == 0) {
return cmSystemTools::FilesDiffer(modFile, stampFile);
- }
+ }
#if defined(_WIN32) || defined(__CYGWIN__)
cmsys::ifstream finModFile(modFile, std::ios::in | std::ios::binary);
@@ -718,11 +636,10 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile,
cmsys::ifstream finModFile(modFile, std::ios::in);
cmsys::ifstream finStampFile(stampFile, std::ios::in);
#endif
- if(!finModFile || !finStampFile)
- {
+ if (!finModFile || !finStampFile) {
// At least one of the files does not exist. The modules differ.
return true;
- }
+ }
/* Compilers which _do_ produce different mod content when the same
* source is compiled twice
@@ -732,62 +649,54 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile,
* Eat the stream content until all recompile only related changes
* are left behind.
*/
- if (strcmp(compilerId, "GNU") == 0 )
- {
+ if (strcmp(compilerId, "GNU") == 0) {
// GNU Fortran 4.9 and later compress .mod files with gzip
// but also do not include a date so we can fall through to
// compare them without skipping any prefix.
unsigned char hdr[2];
- bool okay = finModFile.read(reinterpret_cast<char*>(hdr), 2)? true:false;
+ bool okay =
+ finModFile.read(reinterpret_cast<char*>(hdr), 2) ? true : false;
finModFile.seekg(0);
- if(!(okay && hdr[0] == 0x1f && hdr[1] == 0x8b))
- {
- const char seq[1] = {'\n'};
+ if (!(okay && hdr[0] == 0x1f && hdr[1] == 0x8b)) {
+ const char seq[1] = { '\n' };
const int seqlen = 1;
- if(!cmFortranStreamContainsSequence(finModFile, seq, seqlen))
- {
+ if (!cmFortranStreamContainsSequence(finModFile, seq, seqlen)) {
// The module is of unexpected format. Assume it is different.
std::cerr << compilerId << " fortran module " << modFile
<< " has unexpected format." << std::endl;
return true;
- }
+ }
- if(!cmFortranStreamContainsSequence(finStampFile, seq, seqlen))
- {
+ if (!cmFortranStreamContainsSequence(finStampFile, seq, seqlen)) {
// The stamp must differ if the sequence is not contained.
return true;
- }
}
}
- else if(strcmp(compilerId, "Intel") == 0)
- {
- const char seq[2] = {'\n', '\0'};
+ } else if (strcmp(compilerId, "Intel") == 0) {
+ const char seq[2] = { '\n', '\0' };
const int seqlen = 2;
- if(!cmFortranStreamContainsSequence(finModFile, seq, seqlen))
- {
+ if (!cmFortranStreamContainsSequence(finModFile, seq, seqlen)) {
// The module is of unexpected format. Assume it is different.
std::cerr << compilerId << " fortran module " << modFile
<< " has unexpected format." << std::endl;
return true;
- }
+ }
- if(!cmFortranStreamContainsSequence(finStampFile, seq, seqlen))
- {
+ if (!cmFortranStreamContainsSequence(finStampFile, seq, seqlen)) {
// The stamp must differ if the sequence is not contained.
return true;
- }
}
+ }
// Compare the remaining content. If no compiler id matched above,
// including the case none was given, this will compare the whole
// content.
- if(!cmFortranStreamsDiffer(finModFile, finStampFile))
- {
+ if (!cmFortranStreamsDiffer(finModFile, finStampFile)) {
return false;
- }
+ }
- // The modules are different.
- return true;
+ // The modules are different.
+ return true;
}
diff --git a/Source/cmDependsFortran.h b/Source/cmDependsFortran.h
index a8a4013..5ff0b6c 100644
--- a/Source/cmDependsFortran.h
+++ b/Source/cmDependsFortran.h
@@ -20,7 +20,7 @@ class cmFortranSourceInfo;
/** \class cmDependsFortran
* \brief Dependency scanner for Fortran object files.
*/
-class cmDependsFortran: public cmDepends
+class cmDependsFortran : public cmDepends
{
public:
/** Checking instances need to know the build directory name and the
@@ -43,8 +43,8 @@ public:
/** Determine if a mod file and the corresponding mod.stamp file
are representing different module information. */
- static bool ModulesDiffer(const char* modFile, const char* stampFile,
- const char* compilerId);
+ static bool ModulesDiffer(const char* modFile, const char* stampFile,
+ const char* compilerId);
protected:
// Finalize the dependency information for the target.
@@ -59,15 +59,14 @@ protected:
bool FindModule(std::string const& name, std::string& module);
// Implement writing/checking methods required by superclass.
- virtual bool WriteDependencies(
- const std::set<std::string>& sources, const std::string& file,
- std::ostream& makeDepends, std::ostream& internalDepends);
+ virtual bool WriteDependencies(const std::set<std::string>& sources,
+ const std::string& file,
+ std::ostream& makeDepends,
+ std::ostream& internalDepends);
// Actually write the depenencies to the streams.
- bool WriteDependenciesReal(const char *obj,
- cmFortranSourceInfo const& info,
- std::string const& mod_dir,
- const char* stamp_dir,
+ bool WriteDependenciesReal(const char* obj, cmFortranSourceInfo const& info,
+ std::string const& mod_dir, const char* stamp_dir,
std::ostream& makeDepends,
std::ostream& internalDepends);
@@ -81,7 +80,7 @@ protected:
private:
cmDependsFortran(cmDependsFortran const&); // Purposely not implemented.
- void operator=(cmDependsFortran const&); // Purposely not implemented.
+ void operator=(cmDependsFortran const&); // Purposely not implemented.
};
#endif
diff --git a/Source/cmDependsJava.cxx b/Source/cmDependsJava.cxx
index 96f98dc..4f5e2ae 100644
--- a/Source/cmDependsJava.cxx
+++ b/Source/cmDependsJava.cxx
@@ -23,20 +23,20 @@ cmDependsJava::~cmDependsJava()
}
bool cmDependsJava::WriteDependencies(const std::set<std::string>& sources,
- const std::string&, std::ostream&, std::ostream&)
+ const std::string&, std::ostream&,
+ std::ostream&)
{
// Make sure this is a scanning instance.
- if(sources.empty() || sources.begin()->empty())
- {
+ if (sources.empty() || sources.begin()->empty()) {
cmSystemTools::Error("Cannot scan dependencies without an source file.");
return false;
- }
+ }
return true;
}
bool cmDependsJava::CheckDependencies(std::istream&, const char*,
- std::map<std::string, DependencyVector >&)
+ std::map<std::string, DependencyVector>&)
{
return true;
}
diff --git a/Source/cmDependsJava.h b/Source/cmDependsJava.h
index 22af53f..44723fa 100644
--- a/Source/cmDependsJava.h
+++ b/Source/cmDependsJava.h
@@ -17,7 +17,7 @@
/** \class cmDependsJava
* \brief Dependency scanner for Java class files.
*/
-class cmDependsJava: public cmDepends
+class cmDependsJava : public cmDepends
{
public:
/** Checking instances need to know the build directory name and the
@@ -29,15 +29,16 @@ public:
protected:
// Implement writing/checking methods required by superclass.
- virtual bool WriteDependencies(
- const std::set<std::string>& sources, const std::string& file,
- std::ostream& makeDepends, std::ostream& internalDepends);
- virtual bool CheckDependencies(std::istream& internalDepends,
- const char* internalDependsFileName,
- std::map<std::string, DependencyVector>& validDeps);
+ virtual bool WriteDependencies(const std::set<std::string>& sources,
+ const std::string& file,
+ std::ostream& makeDepends,
+ std::ostream& internalDepends);
+ virtual bool CheckDependencies(
+ std::istream& internalDepends, const char* internalDependsFileName,
+ std::map<std::string, DependencyVector>& validDeps);
private:
- cmDependsJava(cmDependsJava const&); // Purposely not implemented.
+ cmDependsJava(cmDependsJava const&); // Purposely not implemented.
void operator=(cmDependsJava const&); // Purposely not implemented.
};
diff --git a/Source/cmDependsJavaParserHelper.cxx b/Source/cmDependsJavaParserHelper.cxx
index 51a1cb4..bd3ee4d 100644
--- a/Source/cmDependsJavaParserHelper.cxx
+++ b/Source/cmDependsJavaParserHelper.cxx
@@ -15,7 +15,7 @@
#include "cmSystemTools.h"
#include <cmsys/FStream.hxx>
-int cmDependsJava_yyparse( yyscan_t yyscanner );
+int cmDependsJava_yyparse(yyscan_t yyscanner);
cmDependsJavaParserHelper::cmDependsJavaParserHelper()
{
@@ -29,185 +29,152 @@ cmDependsJavaParserHelper::cmDependsJavaParserHelper()
this->ClassStack.push_back(tl);
}
-
cmDependsJavaParserHelper::~cmDependsJavaParserHelper()
{
this->CleanupParser();
}
-void cmDependsJavaParserHelper::CurrentClass
-::AddFileNamesForPrinting(std::vector<std::string> *files,
- const char* prefix, const char* sep)
+void cmDependsJavaParserHelper::CurrentClass::AddFileNamesForPrinting(
+ std::vector<std::string>* files, const char* prefix, const char* sep)
{
std::string rname = "";
- if ( prefix )
- {
+ if (prefix) {
rname += prefix;
rname += sep;
- }
+ }
rname += this->Name;
files->push_back(rname);
std::vector<CurrentClass>::iterator it;
- for ( it = this->NestedClasses->begin();
- it != this->NestedClasses->end();
- ++ it )
- {
+ for (it = this->NestedClasses->begin(); it != this->NestedClasses->end();
+ ++it) {
it->AddFileNamesForPrinting(files, rname.c_str(), sep);
- }
+ }
}
void cmDependsJavaParserHelper::DeallocateParserType(char** pt)
{
- if (!pt)
- {
+ if (!pt) {
return;
- }
- if (!*pt)
- {
+ }
+ if (!*pt) {
return;
- }
+ }
*pt = 0;
- this->UnionsAvailable --;
+ this->UnionsAvailable--;
}
void cmDependsJavaParserHelper::AddClassFound(const char* sclass)
{
- if( ! sclass )
- {
+ if (!sclass) {
return;
- }
+ }
std::vector<std::string>::iterator it;
- for ( it = this->ClassesFound.begin();
- it != this->ClassesFound.end();
- it ++ )
- {
- if ( *it == sclass )
- {
+ for (it = this->ClassesFound.begin(); it != this->ClassesFound.end(); it++) {
+ if (*it == sclass) {
return;
- }
}
+ }
this->ClassesFound.push_back(sclass);
}
void cmDependsJavaParserHelper::AddPackagesImport(const char* sclass)
{
std::vector<std::string>::iterator it;
- for ( it = this->PackagesImport.begin();
- it != this->PackagesImport.end();
- it ++ )
- {
- if ( *it == sclass )
- {
+ for (it = this->PackagesImport.begin(); it != this->PackagesImport.end();
+ it++) {
+ if (*it == sclass) {
return;
- }
}
+ }
this->PackagesImport.push_back(sclass);
}
-void cmDependsJavaParserHelper::SafePrintMissing(const char* str,
- int line, int cnt)
+void cmDependsJavaParserHelper::SafePrintMissing(const char* str, int line,
+ int cnt)
{
- if ( str )
- {
+ if (str) {
std::cout << line << " String " << cnt << " exists: ";
unsigned int cc;
- for ( cc = 0; cc < strlen(str); cc ++ )
- {
+ for (cc = 0; cc < strlen(str); cc++) {
unsigned char ch = str[cc];
- if ( ch >= 32 && ch <= 126 )
- {
+ if (ch >= 32 && ch <= 126) {
std::cout << (char)ch;
- }
- else
- {
+ } else {
std::cout << "<" << (int)ch << ">";
break;
- }
}
- std::cout << "- " << strlen(str) << std::endl;
}
+ std::cout << "- " << strlen(str) << std::endl;
+ }
}
void cmDependsJavaParserHelper::Print(const char* place, const char* str)
{
- if ( this->Verbose )
- {
+ if (this->Verbose) {
std::cout << "[" << place << "=" << str << "]" << std::endl;
- }
+ }
}
-void cmDependsJavaParserHelper::CombineUnions(char** out,
- const char* in1, char** in2,
- const char* sep)
+void cmDependsJavaParserHelper::CombineUnions(char** out, const char* in1,
+ char** in2, const char* sep)
{
size_t len = 1;
- if ( in1 )
- {
+ if (in1) {
len += strlen(in1);
- }
- if ( *in2 )
- {
+ }
+ if (*in2) {
len += strlen(*in2);
- }
- if ( sep )
- {
+ }
+ if (sep) {
len += strlen(sep);
- }
- *out = new char [ len ];
+ }
+ *out = new char[len];
*out[0] = 0;
- if ( in1 )
- {
+ if (in1) {
strcat(*out, in1);
- }
- if ( sep )
- {
+ }
+ if (sep) {
strcat(*out, sep);
- }
- if ( *in2 )
- {
+ }
+ if (*in2) {
strcat(*out, *in2);
- }
- if ( *in2 )
- {
+ }
+ if (*in2) {
this->DeallocateParserType(in2);
- }
- this->UnionsAvailable ++;
+ }
+ this->UnionsAvailable++;
}
-void cmDependsJavaParserHelper
-::CheckEmpty(int line, int cnt, cmDependsJavaParserHelper::ParserType* pt)
+void cmDependsJavaParserHelper::CheckEmpty(
+ int line, int cnt, cmDependsJavaParserHelper::ParserType* pt)
{
int cc;
int kk = -cnt + 1;
- for ( cc = 1; cc <= cnt; cc ++)
- {
+ for (cc = 1; cc <= cnt; cc++) {
cmDependsJavaParserHelper::ParserType* cpt = pt + kk;
this->SafePrintMissing(cpt->str, line, cc);
- kk ++;
- }
+ kk++;
+ }
}
-void cmDependsJavaParserHelper
-::PrepareElement(cmDependsJavaParserHelper::ParserType* me)
+void cmDependsJavaParserHelper::PrepareElement(
+ cmDependsJavaParserHelper::ParserType* me)
{
// Inititalize self
me->str = 0;
}
-void cmDependsJavaParserHelper
-::AllocateParserType(cmDependsJavaParserHelper::ParserType* pt,
- const char* str, int len)
+void cmDependsJavaParserHelper::AllocateParserType(
+ cmDependsJavaParserHelper::ParserType* pt, const char* str, int len)
{
pt->str = 0;
- if ( len == 0 )
- {
+ if (len == 0) {
len = (int)strlen(str);
- }
- if ( len == 0 )
- {
+ }
+ if (len == 0) {
return;
- }
- this->UnionsAvailable ++;
- pt->str = new char[ len + 1 ];
+ }
+ this->UnionsAvailable++;
+ pt->str = new char[len + 1];
strncpy(pt->str, str, len);
pt->str[len] = 0;
this->Allocates.push_back(pt->str);
@@ -219,51 +186,43 @@ void cmDependsJavaParserHelper::StartClass(const char* cls)
cl.Name = cls;
this->ClassStack.push_back(cl);
- this->CurrentDepth ++;
+ this->CurrentDepth++;
}
void cmDependsJavaParserHelper::EndClass()
{
CurrentClass* parent = 0;
CurrentClass* current = 0;
- if (!this->ClassStack.empty())
- {
+ if (!this->ClassStack.empty()) {
current = &(*(this->ClassStack.end() - 1));
- if ( this->ClassStack.size() > 1 )
- {
+ if (this->ClassStack.size() > 1) {
parent = &(*(this->ClassStack.end() - 2));
- }
}
- if ( current == 0 )
- {
+ }
+ if (current == 0) {
std::cerr << "Error when parsing. Current class is null" << std::endl;
abort();
- }
- if ( parent == 0 )
- {
+ }
+ if (parent == 0) {
std::cerr << "Error when parsing. Parent class is null" << std::endl;
abort();
- }
- this->CurrentDepth --;
+ }
+ this->CurrentDepth--;
parent->NestedClasses->push_back(*current);
- this->ClassStack.erase(this->ClassStack.end()-1, this->ClassStack.end());
+ this->ClassStack.erase(this->ClassStack.end() - 1, this->ClassStack.end());
}
void cmDependsJavaParserHelper::PrintClasses()
{
- if (this->ClassStack.empty())
- {
+ if (this->ClassStack.empty()) {
std::cerr << "Error when parsing. No classes on class stack" << std::endl;
abort();
- }
+ }
std::vector<std::string> files = this->GetFilesProduced();
std::vector<std::string>::iterator sit;
- for ( sit = files.begin();
- sit != files.end();
- ++ sit )
- {
+ for (sit = files.begin(); sit != files.end(); ++sit) {
std::cout << " " << *sit << ".class" << std::endl;
- }
+ }
}
std::vector<std::string> cmDependsJavaParserHelper::GetFilesProduced()
@@ -271,77 +230,62 @@ std::vector<std::string> cmDependsJavaParserHelper::GetFilesProduced()
std::vector<std::string> files;
CurrentClass* toplevel = &(*(this->ClassStack.begin()));
std::vector<CurrentClass>::iterator it;
- for ( it = toplevel->NestedClasses->begin();
- it != toplevel->NestedClasses->end();
- ++ it )
- {
+ for (it = toplevel->NestedClasses->begin();
+ it != toplevel->NestedClasses->end(); ++it) {
it->AddFileNamesForPrinting(&files, 0, "$");
- }
+ }
return files;
}
int cmDependsJavaParserHelper::ParseString(const char* str, int verb)
{
- if ( !str)
- {
+ if (!str) {
return 0;
- }
+ }
this->Verbose = verb;
this->InputBuffer = str;
this->InputBufferPos = 0;
this->CurrentLine = 0;
-
yyscan_t yyscanner;
cmDependsJava_yylex_init(&yyscanner);
cmDependsJava_yyset_extra(this, yyscanner);
int res = cmDependsJava_yyparse(yyscanner);
cmDependsJava_yylex_destroy(yyscanner);
- if ( res != 0 )
- {
+ if (res != 0) {
std::cout << "JP_Parse returned: " << res << std::endl;
return 0;
- }
+ }
- if ( verb )
- {
- if (!this->CurrentPackage.empty())
- {
- std::cout << "Current package is: " <<
- this->CurrentPackage << std::endl;
- }
+ if (verb) {
+ if (!this->CurrentPackage.empty()) {
+ std::cout << "Current package is: " << this->CurrentPackage << std::endl;
+ }
std::cout << "Imports packages:";
- if (!this->PackagesImport.empty())
- {
+ if (!this->PackagesImport.empty()) {
std::vector<std::string>::iterator it;
- for ( it = this->PackagesImport.begin();
- it != this->PackagesImport.end();
- ++ it )
- {
+ for (it = this->PackagesImport.begin(); it != this->PackagesImport.end();
+ ++it) {
std::cout << " " << *it;
- }
}
+ }
std::cout << std::endl;
std::cout << "Depends on:";
- if (!this->ClassesFound.empty())
- {
+ if (!this->ClassesFound.empty()) {
std::vector<std::string>::iterator it;
- for ( it = this->ClassesFound.begin();
- it != this->ClassesFound.end();
- ++ it )
- {
+ for (it = this->ClassesFound.begin(); it != this->ClassesFound.end();
+ ++it) {
std::cout << " " << *it;
- }
}
+ }
std::cout << std::endl;
std::cout << "Generated files:" << std::endl;
this->PrintClasses();
- if ( this->UnionsAvailable != 0 )
- {
- std::cout << "There are still " <<
- this->UnionsAvailable << " unions available" << std::endl;
- }
+ if (this->UnionsAvailable != 0) {
+ std::cout << "There are still " << this->UnionsAvailable
+ << " unions available" << std::endl;
}
+ }
this->CleanupParser();
return 1;
}
@@ -349,82 +293,67 @@ int cmDependsJavaParserHelper::ParseString(const char* str, int verb)
void cmDependsJavaParserHelper::CleanupParser()
{
std::vector<char*>::iterator it;
- for ( it = this->Allocates.begin();
- it != this->Allocates.end();
- ++ it )
- {
- delete [] *it;
- }
- this->Allocates.erase(this->Allocates.begin(),
- this->Allocates.end());
+ for (it = this->Allocates.begin(); it != this->Allocates.end(); ++it) {
+ delete[] * it;
+ }
+ this->Allocates.erase(this->Allocates.begin(), this->Allocates.end());
}
int cmDependsJavaParserHelper::LexInput(char* buf, int maxlen)
{
- if ( maxlen < 1 )
- {
+ if (maxlen < 1) {
return 0;
- }
- if ( this->InputBufferPos < this->InputBuffer.size() )
- {
- buf[0] = this->InputBuffer[ this->InputBufferPos++ ];
- if ( buf[0] == '\n' )
- {
- this->CurrentLine ++;
- }
- return(1);
- }
- else
- {
+ }
+ if (this->InputBufferPos < this->InputBuffer.size()) {
+ buf[0] = this->InputBuffer[this->InputBufferPos++];
+ if (buf[0] == '\n') {
+ this->CurrentLine++;
+ }
+ return (1);
+ } else {
buf[0] = '\n';
- return( 0 );
- }
+ return (0);
+ }
}
void cmDependsJavaParserHelper::Error(const char* str)
{
unsigned long pos = static_cast<unsigned long>(this->InputBufferPos);
- fprintf(stderr, "JPError: %s (%lu / Line: %d)\n",
- str, pos, this->CurrentLine);
+ fprintf(stderr, "JPError: %s (%lu / Line: %d)\n", str, pos,
+ this->CurrentLine);
int cc;
std::cerr << "String: [";
- for ( cc = 0;
- cc < 30 && *(this->InputBuffer.c_str() + this->InputBufferPos + cc);
- cc ++ )
- {
+ for (cc = 0;
+ cc < 30 && *(this->InputBuffer.c_str() + this->InputBufferPos + cc);
+ cc++) {
std::cerr << *(this->InputBuffer.c_str() + this->InputBufferPos + cc);
- }
+ }
std::cerr << "]" << std::endl;
}
void cmDependsJavaParserHelper::UpdateCombine(const char* str1,
const char* str2)
{
- if ( this->CurrentCombine == "" && str1 != 0)
- {
+ if (this->CurrentCombine == "" && str1 != 0) {
this->CurrentCombine = str1;
- }
+ }
this->CurrentCombine += ".";
this->CurrentCombine += str2;
}
int cmDependsJavaParserHelper::ParseFile(const char* file)
{
- if ( !cmSystemTools::FileExists(file))
- {
+ if (!cmSystemTools::FileExists(file)) {
return 0;
- }
+ }
cmsys::ifstream ifs(file);
- if ( !ifs )
- {
+ if (!ifs) {
return 0;
- }
+ }
std::string fullfile = "";
std::string line;
- while ( cmSystemTools::GetLineFromStream(ifs, line) )
- {
+ while (cmSystemTools::GetLineFromStream(ifs, line)) {
fullfile += line + "\n";
- }
+ }
return this->ParseString(fullfile.c_str(), 0);
}
-
diff --git a/Source/cmDependsJavaParserHelper.h b/Source/cmDependsJavaParserHelper.h
index 5542018..a13d023 100644
--- a/Source/cmDependsJavaParserHelper.h
+++ b/Source/cmDependsJavaParserHelper.h
@@ -28,7 +28,8 @@
class cmDependsJavaParserHelper
{
public:
- typedef struct {
+ typedef struct
+ {
char* str;
} ParserType;
@@ -40,7 +41,7 @@ public:
// For the lexer:
void AllocateParserType(cmDependsJavaParserHelper::ParserType* pt,
- const char* str, int len = 0);
+ const char* str, int len = 0);
int LexInput(char* buf, int maxlen);
void Error(const char* str);
@@ -69,31 +70,18 @@ private:
public:
std::string Name;
std::vector<CurrentClass>* NestedClasses;
- CurrentClass()
- {
- this->NestedClasses = new std::vector<CurrentClass>;
- }
- ~CurrentClass()
- {
- delete this->NestedClasses;
- }
+ CurrentClass() { this->NestedClasses = new std::vector<CurrentClass>; }
+ ~CurrentClass() { delete this->NestedClasses; }
CurrentClass& operator=(CurrentClass const& c)
- {
- this->NestedClasses->clear();
- this->Name = c.Name;
- std::copy(
- c.NestedClasses->begin(),
- c.NestedClasses->end(),
- std::back_inserter(
- *this->NestedClasses)
- );
- return *this;
- }
- CurrentClass(CurrentClass const& c)
- {
- (*this) = c;
- }
- void AddFileNamesForPrinting(std::vector<std::string> *files,
+ {
+ this->NestedClasses->clear();
+ this->Name = c.Name;
+ std::copy(c.NestedClasses->begin(), c.NestedClasses->end(),
+ std::back_inserter(*this->NestedClasses));
+ return *this;
+ }
+ CurrentClass(CurrentClass const& c) { (*this) = c; }
+ void AddFileNamesForPrinting(std::vector<std::string>* files,
const char* prefix, const char* sep);
};
std::string CurrentPackage;
@@ -117,12 +105,10 @@ private:
void PrintClasses();
void Print(const char* place, const char* str);
- void CombineUnions(char** out, const char* in1, char** in2,
- const char* sep);
+ void CombineUnions(char** out, const char* in1, char** in2, const char* sep);
void SafePrintMissing(const char* str, int line, int cnt);
void CleanupParser();
};
#endif
-
diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx
index d3793c2..68a8488 100644
--- a/Source/cmDocumentation.cxx
+++ b/Source/cmDocumentation.cxx
@@ -24,56 +24,37 @@
#include <algorithm>
-static const char *cmDocumentationStandardOptions[][2] =
-{
- {"--help,-help,-usage,-h,-H,/?",
- "Print usage information and exit."},
- {"--version,-version,/V [<f>]",
- "Print version number and exit."},
- {"--help-full [<f>]",
- "Print all help manuals and exit."},
- {"--help-manual <man> [<f>]",
- "Print one help manual and exit."},
- {"--help-manual-list [<f>]",
- "List help manuals available and exit."},
- {"--help-command <cmd> [<f>]",
- "Print help for one command and exit."},
- {"--help-command-list [<f>]",
- "List commands with help available and exit."},
- {"--help-commands [<f>]",
- "Print cmake-commands manual and exit."},
- {"--help-module <mod> [<f>]",
- "Print help for one module and exit."},
- {"--help-module-list [<f>]",
- "List modules with help available and exit."},
- {"--help-modules [<f>]",
- "Print cmake-modules manual and exit."},
- {"--help-policy <cmp> [<f>]",
- "Print help for one policy and exit."},
- {"--help-policy-list [<f>]",
- "List policies with help available and exit."},
- {"--help-policies [<f>]",
- "Print cmake-policies manual and exit."},
- {"--help-property <prop> [<f>]",
- "Print help for one property and exit."},
- {"--help-property-list [<f>]",
- "List properties with help available and exit."},
- {"--help-properties [<f>]",
- "Print cmake-properties manual and exit."},
- {"--help-variable var [<f>]",
- "Print help for one variable and exit."},
- {"--help-variable-list [<f>]",
- "List variables with help available and exit."},
- {"--help-variables [<f>]",
- "Print cmake-variables manual and exit."},
- {0,0}
+static const char* cmDocumentationStandardOptions[][2] = {
+ { "--help,-help,-usage,-h,-H,/?", "Print usage information and exit." },
+ { "--version,-version,/V [<f>]", "Print version number and exit." },
+ { "--help-full [<f>]", "Print all help manuals and exit." },
+ { "--help-manual <man> [<f>]", "Print one help manual and exit." },
+ { "--help-manual-list [<f>]", "List help manuals available and exit." },
+ { "--help-command <cmd> [<f>]", "Print help for one command and exit." },
+ { "--help-command-list [<f>]",
+ "List commands with help available and exit." },
+ { "--help-commands [<f>]", "Print cmake-commands manual and exit." },
+ { "--help-module <mod> [<f>]", "Print help for one module and exit." },
+ { "--help-module-list [<f>]", "List modules with help available and exit." },
+ { "--help-modules [<f>]", "Print cmake-modules manual and exit." },
+ { "--help-policy <cmp> [<f>]", "Print help for one policy and exit." },
+ { "--help-policy-list [<f>]",
+ "List policies with help available and exit." },
+ { "--help-policies [<f>]", "Print cmake-policies manual and exit." },
+ { "--help-property <prop> [<f>]", "Print help for one property and exit." },
+ { "--help-property-list [<f>]",
+ "List properties with help available and exit." },
+ { "--help-properties [<f>]", "Print cmake-properties manual and exit." },
+ { "--help-variable var [<f>]", "Print help for one variable and exit." },
+ { "--help-variable-list [<f>]",
+ "List variables with help available and exit." },
+ { "--help-variables [<f>]", "Print cmake-variables manual and exit." },
+ { 0, 0 }
};
-static const char *cmDocumentationGeneratorsHeader[][2] =
-{
- {0,
- "The following generators are available on this platform:"},
- {0,0}
+static const char* cmDocumentationGeneratorsHeader[][2] = {
+ { 0, "The following generators are available on this platform:" },
+ { 0, 0 }
};
cmDocumentation::cmDocumentation()
@@ -102,8 +83,7 @@ bool cmDocumentation::PrintVersion(std::ostream& os)
bool cmDocumentation::PrintDocumentation(Type ht, std::ostream& os)
{
- switch (ht)
- {
+ switch (ht) {
case cmDocumentation::Usage:
return this->PrintUsage(os);
case cmDocumentation::Help:
@@ -140,8 +120,9 @@ bool cmDocumentation::PrintDocumentation(Type ht, std::ostream& os)
return this->PrintVersion(os);
case cmDocumentation::OldCustomModules:
return this->PrintOldCustomModules(os);
- default: return false;
- }
+ default:
+ return false;
+ }
}
bool cmDocumentation::PrintRequestedDocumentation(std::ostream& os)
@@ -150,323 +131,249 @@ bool cmDocumentation::PrintRequestedDocumentation(std::ostream& os)
bool result = true;
// Loop over requested documentation types.
- for(std::vector<RequestedHelpItem>::const_iterator
- i = this->RequestedHelpItems.begin();
- i != this->RequestedHelpItems.end();
- ++i)
- {
+ for (std::vector<RequestedHelpItem>::const_iterator i =
+ this->RequestedHelpItems.begin();
+ i != this->RequestedHelpItems.end(); ++i) {
this->CurrentArgument = i->Argument;
// If a file name was given, use it. Otherwise, default to the
// given stream.
cmsys::ofstream* fout = 0;
std::ostream* s = &os;
- if(!i->Filename.empty())
- {
+ if (!i->Filename.empty()) {
fout = new cmsys::ofstream(i->Filename.c_str(), std::ios::out);
- if(fout)
- {
+ if (fout) {
s = fout;
- }
- else
- {
+ } else {
result = false;
- }
}
- else if(++count > 1)
- {
+ } else if (++count > 1) {
os << "\n\n";
- }
+ }
// Print this documentation type to the stream.
- if(!this->PrintDocumentation(i->HelpType, *s) || !*s)
- {
+ if (!this->PrintDocumentation(i->HelpType, *s) || !*s) {
result = false;
- }
+ }
// Close the file if we wrote one.
- if(fout)
- {
+ if (fout) {
delete fout;
- }
}
+ }
return result;
}
-#define GET_OPT_ARGUMENT(target) \
- if((i+1 < argc) && !this->IsOption(argv[i+1])) \
- { \
- target = argv[i+1]; \
- i = i+1; \
- };
-
+#define GET_OPT_ARGUMENT(target) \
+ if ((i + 1 < argc) && !this->IsOption(argv[i + 1])) { \
+ target = argv[i + 1]; \
+ i = i + 1; \
+ };
void cmDocumentation::WarnFormFromFilename(
cmDocumentation::RequestedHelpItem& request, bool& result)
{
std::string ext = cmSystemTools::GetFilenameLastExtension(request.Filename);
ext = cmSystemTools::UpperCase(ext);
- if ((ext == ".HTM") || (ext == ".HTML"))
- {
+ if ((ext == ".HTM") || (ext == ".HTML")) {
request.HelpType = cmDocumentation::None;
result = true;
cmSystemTools::Message("Warning: HTML help format no longer supported");
- }
- else if (ext == ".DOCBOOK")
- {
+ } else if (ext == ".DOCBOOK") {
request.HelpType = cmDocumentation::None;
result = true;
cmSystemTools::Message("Warning: Docbook help format no longer supported");
- }
+ }
// ".1" to ".9" should be manpages
- else if ((ext.length()==2) && (ext[1] >='1') && (ext[1]<='9'))
- {
+ else if ((ext.length() == 2) && (ext[1] >= '1') && (ext[1] <= '9')) {
request.HelpType = cmDocumentation::None;
result = true;
cmSystemTools::Message("Warning: Man help format no longer supported");
- }
+ }
}
void cmDocumentation::addCommonStandardDocSections()
{
- cmDocumentationSection *sec;
+ cmDocumentationSection* sec;
- sec = new cmDocumentationSection("Options","OPTIONS");
- sec->Append(cmDocumentationStandardOptions);
- this->AllSections["Options"] = sec;
+ sec = new cmDocumentationSection("Options", "OPTIONS");
+ sec->Append(cmDocumentationStandardOptions);
+ this->AllSections["Options"] = sec;
}
void cmDocumentation::addCMakeStandardDocSections()
{
- cmDocumentationSection *sec;
+ cmDocumentationSection* sec;
- sec = new cmDocumentationSection("Generators","GENERATORS");
- sec->Append(cmDocumentationGeneratorsHeader);
- this->AllSections["Generators"] = sec;
+ sec = new cmDocumentationSection("Generators", "GENERATORS");
+ sec->Append(cmDocumentationGeneratorsHeader);
+ this->AllSections["Generators"] = sec;
}
void cmDocumentation::addCTestStandardDocSections()
{
- // This is currently done for backward compatibility reason
- // We may suppress some of these.
- addCMakeStandardDocSections();
+ // This is currently done for backward compatibility reason
+ // We may suppress some of these.
+ addCMakeStandardDocSections();
}
void cmDocumentation::addCPackStandardDocSections()
{
- cmDocumentationSection *sec;
+ cmDocumentationSection* sec;
- sec = new cmDocumentationSection("Generators","GENERATORS");
- sec->Append(cmDocumentationGeneratorsHeader);
- this->AllSections["Generators"] = sec;
+ sec = new cmDocumentationSection("Generators", "GENERATORS");
+ sec->Append(cmDocumentationGeneratorsHeader);
+ this->AllSections["Generators"] = sec;
}
bool cmDocumentation::CheckOptions(int argc, const char* const* argv,
const char* exitOpt)
{
// Providing zero arguments gives usage information.
- if(argc == 1)
- {
+ if (argc == 1) {
RequestedHelpItem help;
help.HelpType = cmDocumentation::Usage;
this->RequestedHelpItems.push_back(help);
return true;
- }
+ }
// Search for supported help options.
bool result = false;
- for(int i=1; i < argc; ++i)
- {
- if(exitOpt && strcmp(argv[i], exitOpt) == 0)
- {
+ for (int i = 1; i < argc; ++i) {
+ if (exitOpt && strcmp(argv[i], exitOpt) == 0) {
return result;
- }
+ }
RequestedHelpItem help;
// Check if this is a supported help option.
- if((strcmp(argv[i], "-help") == 0) ||
- (strcmp(argv[i], "--help") == 0) ||
- (strcmp(argv[i], "/?") == 0) ||
- (strcmp(argv[i], "-usage") == 0) ||
- (strcmp(argv[i], "-h") == 0) ||
- (strcmp(argv[i], "-H") == 0))
- {
+ if ((strcmp(argv[i], "-help") == 0) || (strcmp(argv[i], "--help") == 0) ||
+ (strcmp(argv[i], "/?") == 0) || (strcmp(argv[i], "-usage") == 0) ||
+ (strcmp(argv[i], "-h") == 0) || (strcmp(argv[i], "-H") == 0)) {
help.HelpType = cmDocumentation::Help;
GET_OPT_ARGUMENT(help.Argument);
help.Argument = cmSystemTools::LowerCase(help.Argument);
// special case for single command
- if (!help.Argument.empty())
- {
+ if (!help.Argument.empty()) {
help.HelpType = cmDocumentation::OneCommand;
- }
}
- else if(strcmp(argv[i], "--help-properties") == 0)
- {
+ } else if (strcmp(argv[i], "--help-properties") == 0) {
help.HelpType = cmDocumentation::OneManual;
help.Argument = "cmake-properties.7";
GET_OPT_ARGUMENT(help.Filename);
this->WarnFormFromFilename(help, result);
- }
- else if(strcmp(argv[i], "--help-policies") == 0)
- {
+ } else if (strcmp(argv[i], "--help-policies") == 0) {
help.HelpType = cmDocumentation::OneManual;
help.Argument = "cmake-policies.7";
GET_OPT_ARGUMENT(help.Filename);
this->WarnFormFromFilename(help, result);
- }
- else if(strcmp(argv[i], "--help-variables") == 0)
- {
+ } else if (strcmp(argv[i], "--help-variables") == 0) {
help.HelpType = cmDocumentation::OneManual;
help.Argument = "cmake-variables.7";
GET_OPT_ARGUMENT(help.Filename);
this->WarnFormFromFilename(help, result);
- }
- else if(strcmp(argv[i], "--help-modules") == 0)
- {
+ } else if (strcmp(argv[i], "--help-modules") == 0) {
help.HelpType = cmDocumentation::OneManual;
help.Argument = "cmake-modules.7";
GET_OPT_ARGUMENT(help.Filename);
this->WarnFormFromFilename(help, result);
- }
- else if(strcmp(argv[i], "--help-custom-modules") == 0)
- {
+ } else if (strcmp(argv[i], "--help-custom-modules") == 0) {
GET_OPT_ARGUMENT(help.Filename);
cmSystemTools::Message(
"Warning: --help-custom-modules no longer supported");
- if(help.Filename.empty())
- {
+ if (help.Filename.empty()) {
return true;
- }
+ }
// Avoid breaking old project builds completely by at least generating
// the output file. Abuse help.Argument to give the file name to
// PrintOldCustomModules without disrupting our internal API.
help.HelpType = cmDocumentation::OldCustomModules;
help.Argument = cmSystemTools::GetFilenameName(help.Filename);
- }
- else if(strcmp(argv[i], "--help-commands") == 0)
- {
+ } else if (strcmp(argv[i], "--help-commands") == 0) {
help.HelpType = cmDocumentation::OneManual;
help.Argument = "cmake-commands.7";
GET_OPT_ARGUMENT(help.Filename);
this->WarnFormFromFilename(help, result);
- }
- else if(strcmp(argv[i], "--help-compatcommands") == 0)
- {
+ } else if (strcmp(argv[i], "--help-compatcommands") == 0) {
GET_OPT_ARGUMENT(help.Filename);
cmSystemTools::Message(
"Warning: --help-compatcommands no longer supported");
return true;
- }
- else if(strcmp(argv[i], "--help-full") == 0)
- {
+ } else if (strcmp(argv[i], "--help-full") == 0) {
help.HelpType = cmDocumentation::Full;
GET_OPT_ARGUMENT(help.Filename);
this->WarnFormFromFilename(help, result);
- }
- else if(strcmp(argv[i], "--help-html") == 0)
- {
+ } else if (strcmp(argv[i], "--help-html") == 0) {
GET_OPT_ARGUMENT(help.Filename);
cmSystemTools::Message("Warning: --help-html no longer supported");
return true;
- }
- else if(strcmp(argv[i], "--help-man") == 0)
- {
+ } else if (strcmp(argv[i], "--help-man") == 0) {
GET_OPT_ARGUMENT(help.Filename);
cmSystemTools::Message("Warning: --help-man no longer supported");
return true;
- }
- else if(strcmp(argv[i], "--help-command") == 0)
- {
+ } else if (strcmp(argv[i], "--help-command") == 0) {
help.HelpType = cmDocumentation::OneCommand;
GET_OPT_ARGUMENT(help.Argument);
GET_OPT_ARGUMENT(help.Filename);
help.Argument = cmSystemTools::LowerCase(help.Argument);
this->WarnFormFromFilename(help, result);
- }
- else if(strcmp(argv[i], "--help-module") == 0)
- {
+ } else if (strcmp(argv[i], "--help-module") == 0) {
help.HelpType = cmDocumentation::OneModule;
GET_OPT_ARGUMENT(help.Argument);
GET_OPT_ARGUMENT(help.Filename);
this->WarnFormFromFilename(help, result);
- }
- else if(strcmp(argv[i], "--help-property") == 0)
- {
+ } else if (strcmp(argv[i], "--help-property") == 0) {
help.HelpType = cmDocumentation::OneProperty;
GET_OPT_ARGUMENT(help.Argument);
GET_OPT_ARGUMENT(help.Filename);
this->WarnFormFromFilename(help, result);
- }
- else if(strcmp(argv[i], "--help-policy") == 0)
- {
+ } else if (strcmp(argv[i], "--help-policy") == 0) {
help.HelpType = cmDocumentation::OnePolicy;
GET_OPT_ARGUMENT(help.Argument);
GET_OPT_ARGUMENT(help.Filename);
this->WarnFormFromFilename(help, result);
- }
- else if(strcmp(argv[i], "--help-variable") == 0)
- {
+ } else if (strcmp(argv[i], "--help-variable") == 0) {
help.HelpType = cmDocumentation::OneVariable;
GET_OPT_ARGUMENT(help.Argument);
GET_OPT_ARGUMENT(help.Filename);
this->WarnFormFromFilename(help, result);
- }
- else if(strcmp(argv[i], "--help-manual") == 0)
- {
+ } else if (strcmp(argv[i], "--help-manual") == 0) {
help.HelpType = cmDocumentation::OneManual;
GET_OPT_ARGUMENT(help.Argument);
GET_OPT_ARGUMENT(help.Filename);
this->WarnFormFromFilename(help, result);
- }
- else if(strcmp(argv[i], "--help-command-list") == 0)
- {
+ } else if (strcmp(argv[i], "--help-command-list") == 0) {
help.HelpType = cmDocumentation::ListCommands;
GET_OPT_ARGUMENT(help.Filename);
- }
- else if(strcmp(argv[i], "--help-module-list") == 0)
- {
+ } else if (strcmp(argv[i], "--help-module-list") == 0) {
help.HelpType = cmDocumentation::ListModules;
GET_OPT_ARGUMENT(help.Filename);
- }
- else if(strcmp(argv[i], "--help-property-list") == 0)
- {
+ } else if (strcmp(argv[i], "--help-property-list") == 0) {
help.HelpType = cmDocumentation::ListProperties;
GET_OPT_ARGUMENT(help.Filename);
- }
- else if(strcmp(argv[i], "--help-variable-list") == 0)
- {
+ } else if (strcmp(argv[i], "--help-variable-list") == 0) {
help.HelpType = cmDocumentation::ListVariables;
GET_OPT_ARGUMENT(help.Filename);
- }
- else if(strcmp(argv[i], "--help-policy-list") == 0)
- {
+ } else if (strcmp(argv[i], "--help-policy-list") == 0) {
help.HelpType = cmDocumentation::ListPolicies;
GET_OPT_ARGUMENT(help.Filename);
- }
- else if(strcmp(argv[i], "--help-manual-list") == 0)
- {
+ } else if (strcmp(argv[i], "--help-manual-list") == 0) {
help.HelpType = cmDocumentation::ListManuals;
GET_OPT_ARGUMENT(help.Filename);
- }
- else if(strcmp(argv[i], "--copyright") == 0)
- {
+ } else if (strcmp(argv[i], "--copyright") == 0) {
GET_OPT_ARGUMENT(help.Filename);
cmSystemTools::Message("Warning: --copyright no longer supported");
return true;
- }
- else if((strcmp(argv[i], "--version") == 0) ||
- (strcmp(argv[i], "-version") == 0) ||
- (strcmp(argv[i], "/V") == 0))
- {
+ } else if ((strcmp(argv[i], "--version") == 0) ||
+ (strcmp(argv[i], "-version") == 0) ||
+ (strcmp(argv[i], "/V") == 0)) {
help.HelpType = cmDocumentation::Version;
GET_OPT_ARGUMENT(help.Filename);
- }
- if(help.HelpType != None)
- {
+ }
+ if (help.HelpType != None) {
// This is a help option. See if there is a file name given.
result = true;
this->RequestedHelpItems.push_back(help);
- }
}
+ }
return result;
}
@@ -475,130 +382,112 @@ void cmDocumentation::SetName(const std::string& name)
this->NameString = name;
}
-void cmDocumentation::SetSection(const char *name,
- cmDocumentationSection *section)
+void cmDocumentation::SetSection(const char* name,
+ cmDocumentationSection* section)
{
- if (this->AllSections.find(name) != this->AllSections.end())
- {
+ if (this->AllSections.find(name) != this->AllSections.end()) {
delete this->AllSections[name];
- }
+ }
this->AllSections[name] = section;
}
-void cmDocumentation::SetSection(const char *name,
- std::vector<cmDocumentationEntry> &docs)
+void cmDocumentation::SetSection(const char* name,
+ std::vector<cmDocumentationEntry>& docs)
{
- cmDocumentationSection *sec =
- new cmDocumentationSection(name,
- cmSystemTools::UpperCase(name).c_str());
+ cmDocumentationSection* sec =
+ new cmDocumentationSection(name, cmSystemTools::UpperCase(name).c_str());
sec->Append(docs);
- this->SetSection(name,sec);
+ this->SetSection(name, sec);
}
-void cmDocumentation::SetSection(const char *name,
- const char *docs[][2])
+void cmDocumentation::SetSection(const char* name, const char* docs[][2])
{
- cmDocumentationSection *sec =
- new cmDocumentationSection(name,
- cmSystemTools::UpperCase(name).c_str());
+ cmDocumentationSection* sec =
+ new cmDocumentationSection(name, cmSystemTools::UpperCase(name).c_str());
sec->Append(docs);
- this->SetSection(name,sec);
+ this->SetSection(name, sec);
}
-void cmDocumentation
-::SetSections(std::map<std::string,cmDocumentationSection *> &sections)
+void cmDocumentation::SetSections(
+ std::map<std::string, cmDocumentationSection*>& sections)
{
- for (std::map<std::string,cmDocumentationSection *>::const_iterator
- it = sections.begin(); it != sections.end(); ++it)
- {
- this->SetSection(it->first.c_str(),it->second);
- }
+ for (std::map<std::string, cmDocumentationSection*>::const_iterator it =
+ sections.begin();
+ it != sections.end(); ++it) {
+ this->SetSection(it->first.c_str(), it->second);
+ }
}
-void cmDocumentation::PrependSection(const char *name,
- const char *docs[][2])
+void cmDocumentation::PrependSection(const char* name, const char* docs[][2])
{
- cmDocumentationSection *sec = 0;
- if (this->AllSections.find(name) == this->AllSections.end())
- {
- sec = new cmDocumentationSection
- (name, cmSystemTools::UpperCase(name).c_str());
- this->SetSection(name,sec);
- }
- else
- {
+ cmDocumentationSection* sec = 0;
+ if (this->AllSections.find(name) == this->AllSections.end()) {
+ sec =
+ new cmDocumentationSection(name, cmSystemTools::UpperCase(name).c_str());
+ this->SetSection(name, sec);
+ } else {
sec = this->AllSections[name];
- }
+ }
sec->Prepend(docs);
}
-void cmDocumentation::PrependSection(const char *name,
- std::vector<cmDocumentationEntry> &docs)
+void cmDocumentation::PrependSection(const char* name,
+ std::vector<cmDocumentationEntry>& docs)
{
- cmDocumentationSection *sec = 0;
- if (this->AllSections.find(name) == this->AllSections.end())
- {
- sec = new cmDocumentationSection
- (name, cmSystemTools::UpperCase(name).c_str());
- this->SetSection(name,sec);
- }
- else
- {
+ cmDocumentationSection* sec = 0;
+ if (this->AllSections.find(name) == this->AllSections.end()) {
+ sec =
+ new cmDocumentationSection(name, cmSystemTools::UpperCase(name).c_str());
+ this->SetSection(name, sec);
+ } else {
sec = this->AllSections[name];
- }
+ }
sec->Prepend(docs);
}
-void cmDocumentation::AppendSection(const char *name,
- const char *docs[][2])
+void cmDocumentation::AppendSection(const char* name, const char* docs[][2])
{
- cmDocumentationSection *sec = 0;
- if (this->AllSections.find(name) == this->AllSections.end())
- {
- sec = new cmDocumentationSection
- (name, cmSystemTools::UpperCase(name).c_str());
- this->SetSection(name,sec);
- }
- else
- {
+ cmDocumentationSection* sec = 0;
+ if (this->AllSections.find(name) == this->AllSections.end()) {
+ sec =
+ new cmDocumentationSection(name, cmSystemTools::UpperCase(name).c_str());
+ this->SetSection(name, sec);
+ } else {
sec = this->AllSections[name];
- }
+ }
sec->Append(docs);
}
-void cmDocumentation::AppendSection(const char *name,
- std::vector<cmDocumentationEntry> &docs)
+void cmDocumentation::AppendSection(const char* name,
+ std::vector<cmDocumentationEntry>& docs)
{
- cmDocumentationSection *sec = 0;
- if (this->AllSections.find(name) == this->AllSections.end())
- {
- sec = new cmDocumentationSection
- (name, cmSystemTools::UpperCase(name).c_str());
- this->SetSection(name,sec);
- }
- else
- {
+ cmDocumentationSection* sec = 0;
+ if (this->AllSections.find(name) == this->AllSections.end()) {
+ sec =
+ new cmDocumentationSection(name, cmSystemTools::UpperCase(name).c_str());
+ this->SetSection(name, sec);
+ } else {
sec = this->AllSections[name];
- }
+ }
sec->Append(docs);
}
-void cmDocumentation::AppendSection(const char *name,
- cmDocumentationEntry &docs)
+void cmDocumentation::AppendSection(const char* name,
+ cmDocumentationEntry& docs)
{
std::vector<cmDocumentationEntry> docsVec;
docsVec.push_back(docs);
- this->AppendSection(name,docsVec);
+ this->AppendSection(name, docsVec);
}
-void cmDocumentation::PrependSection(const char *name,
- cmDocumentationEntry &docs)
+void cmDocumentation::PrependSection(const char* name,
+ cmDocumentationEntry& docs)
{
std::vector<cmDocumentationEntry> docsVec;
docsVec.push_back(docs);
- this->PrependSection(name,docsVec);
+ this->PrependSection(name, docsVec);
}
void cmDocumentation::GlobHelp(std::vector<std::string>& files,
@@ -607,42 +496,35 @@ void cmDocumentation::GlobHelp(std::vector<std::string>& files,
cmsys::Glob gl;
std::string findExpr =
cmSystemTools::GetCMakeRoot() + "/Help/" + pattern + ".rst";
- if(gl.FindFiles(findExpr))
- {
+ if (gl.FindFiles(findExpr)) {
files = gl.GetFiles();
- }
+ }
}
-void cmDocumentation::PrintNames(std::ostream& os,
- std::string const& pattern)
+void cmDocumentation::PrintNames(std::ostream& os, std::string const& pattern)
{
std::vector<std::string> files;
this->GlobHelp(files, pattern);
std::vector<std::string> names;
for (std::vector<std::string>::const_iterator i = files.begin();
- i != files.end(); ++i)
- {
+ i != files.end(); ++i) {
std::string line;
cmsys::ifstream fin(i->c_str());
- while(fin && cmSystemTools::GetLineFromStream(fin, line))
- {
- if(!line.empty() && (isalnum(line[0]) || line[0] == '<'))
- {
+ while (fin && cmSystemTools::GetLineFromStream(fin, line)) {
+ if (!line.empty() && (isalnum(line[0]) || line[0] == '<')) {
names.push_back(line);
break;
- }
}
}
+ }
std::sort(names.begin(), names.end());
- for (std::vector<std::string>::iterator i = names.begin();
- i != names.end(); ++i)
- {
+ for (std::vector<std::string>::iterator i = names.begin(); i != names.end();
+ ++i) {
os << *i << "\n";
- }
+ }
}
-bool cmDocumentation::PrintFiles(std::ostream& os,
- std::string const& pattern)
+bool cmDocumentation::PrintFiles(std::ostream& os, std::string const& pattern)
{
bool found = false;
std::vector<std::string> files;
@@ -650,10 +532,9 @@ bool cmDocumentation::PrintFiles(std::ostream& os,
std::sort(files.begin(), files.end());
cmRST r(os, cmSystemTools::GetCMakeRoot() + "/Help");
for (std::vector<std::string>::const_iterator i = files.begin();
- i != files.end(); ++i)
- {
+ i != files.end(); ++i) {
found = r.ProcessFile(*i) || found;
- }
+ }
return found;
}
@@ -666,16 +547,13 @@ bool cmDocumentation::PrintHelpOneManual(std::ostream& os)
{
std::string mname = this->CurrentArgument;
std::string::size_type mlen = mname.length();
- if(mlen > 3 && mname[mlen-3] == '(' &&
- mname[mlen-1] == ')')
- {
- mname = mname.substr(0, mlen-3) + "." + mname[mlen-2];
- }
- if(this->PrintFiles(os, "manual/" + mname) ||
- this->PrintFiles(os, "manual/" + mname + ".[0-9]"))
- {
+ if (mlen > 3 && mname[mlen - 3] == '(' && mname[mlen - 1] == ')') {
+ mname = mname.substr(0, mlen - 3) + "." + mname[mlen - 2];
+ }
+ if (this->PrintFiles(os, "manual/" + mname) ||
+ this->PrintFiles(os, "manual/" + mname + ".[0-9]")) {
return true;
- }
+ }
// Argument was not a manual. Complain.
os << "Argument \"" << this->CurrentArgument
<< "\" to --help-manual is not an available manual. "
@@ -692,10 +570,9 @@ bool cmDocumentation::PrintHelpListManuals(std::ostream& os)
bool cmDocumentation::PrintHelpOneCommand(std::ostream& os)
{
std::string cname = cmSystemTools::LowerCase(this->CurrentArgument);
- if(this->PrintFiles(os, "command/" + cname))
- {
+ if (this->PrintFiles(os, "command/" + cname)) {
return true;
- }
+ }
// Argument was not a command. Complain.
os << "Argument \"" << this->CurrentArgument
<< "\" to --help-command is not a CMake command. "
@@ -712,10 +589,9 @@ bool cmDocumentation::PrintHelpListCommands(std::ostream& os)
bool cmDocumentation::PrintHelpOneModule(std::ostream& os)
{
std::string mname = this->CurrentArgument;
- if(this->PrintFiles(os, "module/" + mname))
- {
+ if (this->PrintFiles(os, "module/" + mname)) {
return true;
- }
+ }
// Argument was not a module. Complain.
os << "Argument \"" << this->CurrentArgument
<< "\" to --help-module is not a CMake module.\n";
@@ -728,27 +604,24 @@ bool cmDocumentation::PrintHelpListModules(std::ostream& os)
this->GlobHelp(files, "module/*");
std::vector<std::string> modules;
for (std::vector<std::string>::iterator fi = files.begin();
- fi != files.end(); ++fi)
- {
+ fi != files.end(); ++fi) {
std::string module = cmSystemTools::GetFilenameName(*fi);
- modules.push_back(module.substr(0, module.size()-4));
- }
+ modules.push_back(module.substr(0, module.size() - 4));
+ }
std::sort(modules.begin(), modules.end());
for (std::vector<std::string>::iterator i = modules.begin();
- i != modules.end(); ++i)
- {
+ i != modules.end(); ++i) {
os << *i << "\n";
- }
+ }
return true;
}
bool cmDocumentation::PrintHelpOneProperty(std::ostream& os)
{
std::string pname = cmSystemTools::HelpFileName(this->CurrentArgument);
- if(this->PrintFiles(os, "prop_*/" + pname))
- {
+ if (this->PrintFiles(os, "prop_*/" + pname)) {
return true;
- }
+ }
// Argument was not a property. Complain.
os << "Argument \"" << this->CurrentArgument
<< "\" to --help-property is not a CMake property. "
@@ -766,10 +639,9 @@ bool cmDocumentation::PrintHelpOnePolicy(std::ostream& os)
{
std::string pname = this->CurrentArgument;
std::vector<std::string> files;
- if(this->PrintFiles(os, "policy/" + pname))
- {
+ if (this->PrintFiles(os, "policy/" + pname)) {
return true;
- }
+ }
// Argument was not a policy. Complain.
os << "Argument \"" << this->CurrentArgument
@@ -785,23 +657,21 @@ bool cmDocumentation::PrintHelpListPolicies(std::ostream& os)
bool cmDocumentation::PrintHelpListGenerators(std::ostream& os)
{
- std::map<std::string,cmDocumentationSection*>::iterator si;
+ std::map<std::string, cmDocumentationSection*>::iterator si;
si = this->AllSections.find("Generators");
- if(si != this->AllSections.end())
- {
+ if (si != this->AllSections.end()) {
this->Formatter.SetIndent(" ");
this->Formatter.PrintSection(os, *si->second);
- }
+ }
return true;
}
bool cmDocumentation::PrintHelpOneVariable(std::ostream& os)
{
std::string vname = cmSystemTools::HelpFileName(this->CurrentArgument);
- if(this->PrintFiles(os, "variable/" + vname))
- {
+ if (this->PrintFiles(os, "variable/" + vname)) {
return true;
- }
+ }
// Argument was not a variable. Complain.
os << "Argument \"" << this->CurrentArgument
<< "\" to --help-variable is not a defined variable. "
@@ -817,49 +687,41 @@ bool cmDocumentation::PrintHelpListVariables(std::ostream& os)
bool cmDocumentation::PrintUsage(std::ostream& os)
{
- std::map<std::string,cmDocumentationSection*>::iterator si;
+ std::map<std::string, cmDocumentationSection*>::iterator si;
si = this->AllSections.find("Usage");
- if(si != this->AllSections.end())
- {
+ if (si != this->AllSections.end()) {
this->Formatter.PrintSection(os, *si->second);
- }
+ }
return true;
}
bool cmDocumentation::PrintHelp(std::ostream& os)
{
- std::map<std::string,cmDocumentationSection*>::iterator si;
+ std::map<std::string, cmDocumentationSection*>::iterator si;
si = this->AllSections.find("Usage");
- if(si != this->AllSections.end())
- {
+ if (si != this->AllSections.end()) {
this->Formatter.PrintSection(os, *si->second);
- }
+ }
si = this->AllSections.find("Options");
- if(si != this->AllSections.end())
- {
+ if (si != this->AllSections.end()) {
this->Formatter.PrintSection(os, *si->second);
- }
- if(this->ShowGenerators)
- {
+ }
+ if (this->ShowGenerators) {
si = this->AllSections.find("Generators");
- if(si != this->AllSections.end())
- {
+ if (si != this->AllSections.end()) {
this->Formatter.PrintSection(os, *si->second);
- }
}
+ }
return true;
}
const char* cmDocumentation::GetNameString() const
{
- if(!this->NameString.empty())
- {
+ if (!this->NameString.empty()) {
return this->NameString.c_str();
- }
- else
- {
+ } else {
return "CMake";
- }
+ }
}
bool cmDocumentation::IsOption(const char* arg) const
@@ -883,15 +745,12 @@ bool cmDocumentation::PrintOldCustomModules(std::ostream& os)
"CMake versions 3.0 and above use other means to generate their module\n"
"help pages so this functionality is no longer available to be exposed.\n"
"\n"
- "This file was generated as a placeholder to provide this information.\n"
- ;
- if((ext == ".HTM") || (ext == ".HTML"))
- {
+ "This file was generated as a placeholder to provide this information.\n";
+ if ((ext == ".HTM") || (ext == ".HTML")) {
os << "<html><title>" << name << "</title><body>\n"
- << summary << "<p/>\n" << detail << "</body></html>\n";
- }
- else if((ext.length()==2) && (ext[1] >='1') && (ext[1]<='9'))
- {
+ << summary << "<p/>\n"
+ << detail << "</body></html>\n";
+ } else if ((ext.length() == 2) && (ext[1] >= '1') && (ext[1] <= '9')) {
/* clang-format off */
os <<
".TH " << name << " " << ext[1] << " \"" <<
@@ -906,10 +765,8 @@ bool cmDocumentation::PrintOldCustomModules(std::ostream& os)
detail
;
/* clang-format on */
- }
- else
- {
+ } else {
os << name << "\n\n" << summary << "\n" << detail;
- }
+ }
return true;
}
diff --git a/Source/cmDocumentation.h b/Source/cmDocumentation.h
index a1d73f5..dd99ca8 100644
--- a/Source/cmDocumentation.h
+++ b/Source/cmDocumentation.h
@@ -18,13 +18,12 @@
#include "cmDocumentationSection.h"
#include "cmake.h"
-namespace cmsys
-{
- class Directory;
+namespace cmsys {
+class Directory;
}
/** Class to generate documentation. */
-class cmDocumentation: public cmDocumentationEnums
+class cmDocumentation : public cmDocumentationEnums
{
public:
cmDocumentation();
@@ -40,7 +39,7 @@ public:
* help arguments.
*/
bool CheckOptions(int argc, const char* const* argv,
- const char* exitOpt =0);
+ const char* exitOpt = 0);
/**
* Print help requested on the command line. Call after
@@ -60,28 +59,21 @@ public:
/** Set a section of the documentation. Typical sections include Name,
Usage, Description, Options */
- void SetSection(const char *sectionName,
- cmDocumentationSection *section);
- void SetSection(const char *sectionName,
- std::vector<cmDocumentationEntry> &docs);
- void SetSection(const char *sectionName,
- const char *docs[][2]);
- void SetSections(std::map<std::string,cmDocumentationSection *>
- &sections);
+ void SetSection(const char* sectionName, cmDocumentationSection* section);
+ void SetSection(const char* sectionName,
+ std::vector<cmDocumentationEntry>& docs);
+ void SetSection(const char* sectionName, const char* docs[][2]);
+ void SetSections(std::map<std::string, cmDocumentationSection*>& sections);
/** Add the documentation to the beginning/end of the section */
- void PrependSection(const char *sectionName,
- const char *docs[][2]);
- void PrependSection(const char *sectionName,
- std::vector<cmDocumentationEntry> &docs);
- void PrependSection(const char *sectionName,
- cmDocumentationEntry &docs);
- void AppendSection(const char *sectionName,
- const char *docs[][2]);
- void AppendSection(const char *sectionName,
- std::vector<cmDocumentationEntry> &docs);
- void AppendSection(const char *sectionName,
- cmDocumentationEntry &docs);
+ void PrependSection(const char* sectionName, const char* docs[][2]);
+ void PrependSection(const char* sectionName,
+ std::vector<cmDocumentationEntry>& docs);
+ void PrependSection(const char* sectionName, cmDocumentationEntry& docs);
+ void AppendSection(const char* sectionName, const char* docs[][2]);
+ void AppendSection(const char* sectionName,
+ std::vector<cmDocumentationEntry>& docs);
+ void AppendSection(const char* sectionName, cmDocumentationEntry& docs);
/** Add common (to all tools) documentation section(s) */
void addCommonStandardDocSections();
@@ -96,7 +88,6 @@ public:
void addCPackStandardDocSections();
private:
-
void GlobHelp(std::vector<std::string>& files, std::string const& pattern);
void PrintNames(std::ostream& os, std::string const& pattern);
bool PrintFiles(std::ostream& os, std::string const& pattern);
@@ -126,13 +117,16 @@ private:
bool ShowGenerators;
std::string NameString;
- std::map<std::string,cmDocumentationSection*> AllSections;
+ std::map<std::string, cmDocumentationSection*> AllSections;
std::string CurrentArgument;
struct RequestedHelpItem
{
- RequestedHelpItem(): HelpType(None) {}
+ RequestedHelpItem()
+ : HelpType(None)
+ {
+ }
cmDocumentationEnums::Type HelpType;
std::string Filename;
std::string Argument;
diff --git a/Source/cmDocumentationFormatter.cxx b/Source/cmDocumentationFormatter.cxx
index 6869e2f..4816bb9 100644
--- a/Source/cmDocumentationFormatter.cxx
+++ b/Source/cmDocumentationFormatter.cxx
@@ -13,8 +13,9 @@
#include "cmDocumentationSection.h"
-cmDocumentationFormatter::cmDocumentationFormatter():
- TextWidth(77), TextIndent("")
+cmDocumentationFormatter::cmDocumentationFormatter()
+ : TextWidth(77)
+ , TextIndent("")
{
}
@@ -25,67 +26,55 @@ cmDocumentationFormatter::~cmDocumentationFormatter()
void cmDocumentationFormatter::PrintFormatted(std::ostream& os,
const char* text)
{
- if(!text)
- {
+ if (!text) {
return;
- }
+ }
const char* ptr = text;
- while(*ptr)
- {
+ while (*ptr) {
// Any ptrs starting in a space are treated as preformatted text.
std::string preformatted;
- while(*ptr == ' ')
- {
- for(char ch = *ptr; ch && ch != '\n'; ++ptr, ch = *ptr)
- {
+ while (*ptr == ' ') {
+ for (char ch = *ptr; ch && ch != '\n'; ++ptr, ch = *ptr) {
preformatted.append(1, ch);
- }
- if(*ptr)
- {
+ }
+ if (*ptr) {
++ptr;
preformatted.append(1, '\n');
- }
}
- if(!preformatted.empty())
- {
+ }
+ if (!preformatted.empty()) {
this->PrintPreformatted(os, preformatted.c_str());
- }
+ }
// Other ptrs are treated as paragraphs.
std::string paragraph;
- for(char ch = *ptr; ch && ch != '\n'; ++ptr, ch = *ptr)
- {
+ for (char ch = *ptr; ch && ch != '\n'; ++ptr, ch = *ptr) {
paragraph.append(1, ch);
- }
- if(*ptr)
- {
+ }
+ if (*ptr) {
++ptr;
paragraph.append(1, '\n');
- }
- if(!paragraph.empty())
- {
+ }
+ if (!paragraph.empty()) {
this->PrintParagraph(os, paragraph.c_str());
- }
}
+ }
}
void cmDocumentationFormatter::PrintPreformatted(std::ostream& os,
- const char* text)
+ const char* text)
{
bool newline = true;
- for(const char* ptr = text; *ptr; ++ptr)
- {
- if(newline && *ptr != '\n')
- {
+ for (const char* ptr = text; *ptr; ++ptr) {
+ if (newline && *ptr != '\n') {
os << this->TextIndent;
newline = false;
- }
+ }
os << *ptr;
- if(*ptr == '\n')
- {
+ if (*ptr == '\n') {
newline = true;
- }
}
+ }
os << "\n";
}
@@ -102,8 +91,7 @@ void cmDocumentationFormatter::SetIndent(const char* indent)
this->TextIndent = indent;
}
-void cmDocumentationFormatter::PrintColumn(std::ostream& os,
- const char* text)
+void cmDocumentationFormatter::PrintColumn(std::ostream& os, const char* text)
{
// Print text arranged in an indented column of fixed witdh.
const char* l = text;
@@ -113,118 +101,97 @@ void cmDocumentationFormatter::PrintColumn(std::ostream& os,
int width = this->TextWidth - static_cast<int>(strlen(this->TextIndent));
// Loop until the end of the text.
- while(*l)
- {
+ while (*l) {
// Parse the next word.
const char* r = l;
- while(*r && (*r != '\n') && (*r != ' ')) { ++r; }
+ while (*r && (*r != '\n') && (*r != ' ')) {
+ ++r;
+ }
// Does it fit on this line?
- if(r-l < (width-column-(newSentence?1:0)))
- {
+ if (r - l < (width - column - (newSentence ? 1 : 0))) {
// Word fits on this line.
- if(r > l)
- {
- if(column)
- {
+ if (r > l) {
+ if (column) {
// Not first word on line. Separate from the previous word
// by a space, or two if this is a new sentence.
- if(newSentence)
- {
+ if (newSentence) {
os << " ";
column += 2;
- }
- else
- {
+ } else {
os << " ";
column += 1;
- }
}
- else
- {
+ } else {
// First word on line. Print indentation unless this is the
// first line.
- os << (firstLine?"":this->TextIndent);
- }
+ os << (firstLine ? "" : this->TextIndent);
+ }
// Print the word.
- os.write(l, static_cast<long>(r-l));
- newSentence = (*(r-1) == '.');
- }
+ os.write(l, static_cast<long>(r - l));
+ newSentence = (*(r - 1) == '.');
+ }
- if(*r == '\n')
- {
+ if (*r == '\n') {
// Text provided a newline. Start a new line.
os << "\n";
++r;
column = 0;
firstLine = false;
- }
- else
- {
+ } else {
// No provided newline. Continue this line.
- column += static_cast<long>(r-l);
- }
+ column += static_cast<long>(r - l);
}
- else
- {
+ } else {
// Word does not fit on this line. Start a new line.
os << "\n";
firstLine = false;
- if(r > l)
- {
+ if (r > l) {
os << this->TextIndent;
- os.write(l, static_cast<long>(r-l));
- column = static_cast<long>(r-l);
- newSentence = (*(r-1) == '.');
- }
- else
- {
+ os.write(l, static_cast<long>(r - l));
+ column = static_cast<long>(r - l);
+ newSentence = (*(r - 1) == '.');
+ } else {
column = 0;
- }
}
+ }
// Move to beginning of next word. Skip over whitespace.
l = r;
- while(*l && (*l == ' ')) { ++l; }
+ while (*l && (*l == ' ')) {
+ ++l;
}
+ }
}
-void cmDocumentationFormatter
-::PrintSection(std::ostream& os,
- cmDocumentationSection const& section)
+void cmDocumentationFormatter::PrintSection(
+ std::ostream& os, cmDocumentationSection const& section)
{
os << section.GetName() << "\n";
- const std::vector<cmDocumentationEntry> &entries =
- section.GetEntries();
- for(std::vector<cmDocumentationEntry>::const_iterator op = entries.begin();
- op != entries.end(); ++op)
- {
- if(!op->Name.empty())
- {
+ const std::vector<cmDocumentationEntry>& entries = section.GetEntries();
+ for (std::vector<cmDocumentationEntry>::const_iterator op = entries.begin();
+ op != entries.end(); ++op) {
+ if (!op->Name.empty()) {
os << " " << op->Name;
this->TextIndent = " ";
- int align = static_cast<int>(strlen(this->TextIndent))-4;
- for(int i = static_cast<int>(op->Name.size()); i < align; ++i)
- {
+ int align = static_cast<int>(strlen(this->TextIndent)) - 4;
+ for (int i = static_cast<int>(op->Name.size()); i < align; ++i) {
os << " ";
- }
- if (op->Name.size() > strlen(this->TextIndent)-4 )
- {
+ }
+ if (op->Name.size() > strlen(this->TextIndent) - 4) {
os << "\n";
- os.write(this->TextIndent, strlen(this->TextIndent)-2);
- }
+ os.write(this->TextIndent, strlen(this->TextIndent) - 2);
+ }
os << "= ";
this->PrintColumn(os, op->Brief.c_str());
os << "\n";
- }
- else
- {
+ } else {
os << "\n";
this->TextIndent = "";
this->PrintFormatted(os, op->Brief.c_str());
- }
}
+ }
os << "\n";
}
diff --git a/Source/cmDocumentationFormatter.h b/Source/cmDocumentationFormatter.h
index 6e19b7d..7c4c35b 100644
--- a/Source/cmDocumentationFormatter.h
+++ b/Source/cmDocumentationFormatter.h
@@ -26,9 +26,24 @@ public:
/** Types of help provided. */
enum Type
{
- None, Version, Usage, Help, Full, ListManuals, ListCommands,
- ListModules, ListProperties, ListVariables, ListPolicies, ListGenerators,
- OneManual, OneCommand, OneModule, OneProperty, OneVariable, OnePolicy,
+ None,
+ Version,
+ Usage,
+ Help,
+ Full,
+ ListManuals,
+ ListCommands,
+ ListModules,
+ ListProperties,
+ ListVariables,
+ ListPolicies,
+ ListGenerators,
+ OneManual,
+ OneCommand,
+ OneModule,
+ OneProperty,
+ OneVariable,
+ OnePolicy,
OldCustomModules
};
};
@@ -49,6 +64,7 @@ public:
virtual void PrintParagraph(std::ostream& os, const char* text);
void PrintColumn(std::ostream& os, const char* text);
void SetIndent(const char* indent);
+
private:
int TextWidth;
const char* TextIndent;
diff --git a/Source/cmDocumentationSection.cxx b/Source/cmDocumentationSection.cxx
index 2fbc50e..c6c87f4 100644
--- a/Source/cmDocumentationSection.cxx
+++ b/Source/cmDocumentationSection.cxx
@@ -11,32 +11,27 @@
============================================================================*/
#include "cmDocumentationSection.h"
-
-void cmDocumentationSection::Append(const char *data[][2])
+void cmDocumentationSection::Append(const char* data[][2])
{
int i = 0;
- while(data[i][1])
- {
- this->Entries.push_back(cmDocumentationEntry(data[i][0],
- data[i][1]));
+ while (data[i][1]) {
+ this->Entries.push_back(cmDocumentationEntry(data[i][0], data[i][1]));
data += 1;
- }
+ }
}
-void cmDocumentationSection::Prepend(const char *data[][2])
+void cmDocumentationSection::Prepend(const char* data[][2])
{
std::vector<cmDocumentationEntry> tmp;
int i = 0;
- while(data[i][1])
- {
- tmp.push_back(cmDocumentationEntry(data[i][0],
- data[i][1]));
+ while (data[i][1]) {
+ tmp.push_back(cmDocumentationEntry(data[i][0], data[i][1]));
data += 1;
- }
- this->Entries.insert(this->Entries.begin(),tmp.begin(),tmp.end());
+ }
+ this->Entries.insert(this->Entries.begin(), tmp.begin(), tmp.end());
}
-void cmDocumentationSection::Append(const char *n, const char *b)
+void cmDocumentationSection::Append(const char* n, const char* b)
{
- this->Entries.push_back(cmDocumentationEntry(n,b));
+ this->Entries.push_back(cmDocumentationEntry(n, b));
}
diff --git a/Source/cmDocumentationSection.h b/Source/cmDocumentationSection.h
index 66b94c2..161a731 100644
--- a/Source/cmDocumentationSection.h
+++ b/Source/cmDocumentationSection.h
@@ -24,7 +24,9 @@ class cmDocumentationSection
public:
/** Create a cmSection, with a special name for man-output mode. */
cmDocumentationSection(const char* name, const char*)
- :Name(name) {}
+ : Name(name)
+ {
+ }
/** Has any content been added to this section or is it empty ? */
bool IsEmpty() const { return this->Entries.empty(); }
@@ -33,29 +35,35 @@ public:
void Clear() { this->Entries.clear(); }
/** Return the name of this section. */
- std::string GetName() const
- { return this->Name; }
+ std::string GetName() const { return this->Name; }
/** Return a pointer to the first entry of this section. */
- const std::vector<cmDocumentationEntry> &GetEntries() const
- { return this->Entries; }
+ const std::vector<cmDocumentationEntry>& GetEntries() const
+ {
+ return this->Entries;
+ }
/** Append an entry to this section. */
void Append(const cmDocumentationEntry& entry)
- { this->Entries.push_back(entry); }
- void Append(const std::vector<cmDocumentationEntry> &entries)
- { this->Entries.insert(this->Entries.end(),entries.begin(),entries.end()); }
+ {
+ this->Entries.push_back(entry);
+ }
+ void Append(const std::vector<cmDocumentationEntry>& entries)
+ {
+ this->Entries.insert(this->Entries.end(), entries.begin(), entries.end());
+ }
/** Append an entry to this section using NULL terminated chars */
- void Append(const char *[][2]);
- void Append(const char *n, const char *b);
+ void Append(const char* [][2]);
+ void Append(const char* n, const char* b);
/** prepend some documentation to this section */
- void Prepend(const char *[][2]);
- void Prepend(const std::vector<cmDocumentationEntry> &entries)
- { this->Entries.insert(this->Entries.begin(),
- entries.begin(),entries.end()); }
-
+ void Prepend(const char* [][2]);
+ void Prepend(const std::vector<cmDocumentationEntry>& entries)
+ {
+ this->Entries.insert(this->Entries.begin(), entries.begin(),
+ entries.end());
+ }
private:
std::string Name;
diff --git a/Source/cmDynamicLoader.cxx b/Source/cmDynamicLoader.cxx
index 944a000..7d0bbdc 100644
--- a/Source/cmDynamicLoader.cxx
+++ b/Source/cmDynamicLoader.cxx
@@ -15,8 +15,7 @@ class cmDynamicLoaderCache
{
public:
~cmDynamicLoaderCache();
- void CacheFile(const char* path,
- const cmsys::DynamicLoader::LibraryHandle&);
+ void CacheFile(const char* path, const cmsys::DynamicLoader::LibraryHandle&);
bool GetCacheFile(const char* path, cmsys::DynamicLoader::LibraryHandle&);
bool FlushCache(const char* path);
void FlushCache();
@@ -33,74 +32,67 @@ cmDynamicLoaderCache::~cmDynamicLoaderCache()
{
}
-void cmDynamicLoaderCache::CacheFile(const char* path,
- const cmsys::DynamicLoader::LibraryHandle& p)
+void cmDynamicLoaderCache::CacheFile(
+ const char* path, const cmsys::DynamicLoader::LibraryHandle& p)
{
cmsys::DynamicLoader::LibraryHandle h;
- if ( this->GetCacheFile(path, h) )
- {
+ if (this->GetCacheFile(path, h)) {
this->FlushCache(path);
- }
+ }
this->CacheMap[path] = p;
}
bool cmDynamicLoaderCache::GetCacheFile(const char* path,
- cmsys::DynamicLoader::LibraryHandle& p)
+ cmsys::DynamicLoader::LibraryHandle& p)
{
- std::map<std::string, cmsys::DynamicLoader::LibraryHandle>::iterator it
- = this->CacheMap.find(path);
- if ( it != this->CacheMap.end() )
- {
+ std::map<std::string, cmsys::DynamicLoader::LibraryHandle>::iterator it =
+ this->CacheMap.find(path);
+ if (it != this->CacheMap.end()) {
p = it->second;
return true;
- }
+ }
return false;
}
bool cmDynamicLoaderCache::FlushCache(const char* path)
{
- std::map<std::string, cmsys::DynamicLoader::LibraryHandle>::iterator it
- = this->CacheMap.find(path);
+ std::map<std::string, cmsys::DynamicLoader::LibraryHandle>::iterator it =
+ this->CacheMap.find(path);
bool ret = false;
- if ( it != this->CacheMap.end() )
- {
+ if (it != this->CacheMap.end()) {
cmsys::DynamicLoader::CloseLibrary(it->second);
this->CacheMap.erase(it);
ret = true;
- }
+ }
return ret;
}
void cmDynamicLoaderCache::FlushCache()
{
- for ( std::map<std::string,
- cmsys::DynamicLoader::LibraryHandle>::iterator it
- = this->CacheMap.begin();
- it != this->CacheMap.end(); it++ )
- {
+ for (std::map<std::string, cmsys::DynamicLoader::LibraryHandle>::iterator
+ it = this->CacheMap.begin();
+ it != this->CacheMap.end(); it++) {
cmsys::DynamicLoader::CloseLibrary(it->second);
- }
+ }
delete cmDynamicLoaderCache::Instance;
cmDynamicLoaderCache::Instance = 0;
}
cmDynamicLoaderCache* cmDynamicLoaderCache::GetInstance()
{
- if ( !cmDynamicLoaderCache::Instance )
- {
+ if (!cmDynamicLoaderCache::Instance) {
cmDynamicLoaderCache::Instance = new cmDynamicLoaderCache;
- }
+ }
return cmDynamicLoaderCache::Instance;
}
cmsys::DynamicLoader::LibraryHandle cmDynamicLoader::OpenLibrary(
- const char* libname )
+ const char* libname)
{
cmsys::DynamicLoader::LibraryHandle lh;
- if ( cmDynamicLoaderCache::GetInstance()->GetCacheFile(libname, lh) )
- {
+ if (cmDynamicLoaderCache::GetInstance()->GetCacheFile(libname, lh)) {
return lh;
- }
+ }
lh = cmsys::DynamicLoader::OpenLibrary(libname);
cmDynamicLoaderCache::GetInstance()->CacheFile(libname, lh);
return lh;
diff --git a/Source/cmDynamicLoader.h b/Source/cmDynamicLoader.h
index 84bc9bc..58d9ae9 100644
--- a/Source/cmDynamicLoader.h
+++ b/Source/cmDynamicLoader.h
@@ -14,7 +14,6 @@
// cmDynamicLoader provides a portable interface to loading dynamic
// libraries into a process.
-
#ifndef cmDynamicLoader_h
#define cmDynamicLoader_h
@@ -40,7 +39,7 @@ protected:
~cmDynamicLoader() {}
private:
- cmDynamicLoader(const cmDynamicLoader&); // Not implemented.
+ cmDynamicLoader(const cmDynamicLoader&); // Not implemented.
void operator=(const cmDynamicLoader&); // Not implemented.
};
diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx
index c6ae205..26f1a44 100644
--- a/Source/cmELF.cxx
+++ b/Source/cmELF.cxx
@@ -18,58 +18,75 @@
// Include the ELF format information system header.
#if defined(__OpenBSD__)
-# include <elf_abi.h>
-# include <stdint.h>
+#include <elf_abi.h>
+#include <stdint.h>
#elif defined(__HAIKU__)
-# include <elf32.h>
-# include <elf64.h>
- typedef struct Elf32_Ehdr Elf32_Ehdr;
- typedef struct Elf32_Shdr Elf32_Shdr;
- typedef struct Elf32_Sym Elf32_Sym;
- typedef struct Elf32_Rel Elf32_Rel;
- typedef struct Elf32_Rela Elf32_Rela;
-# define ELFMAG0 0x7F
-# define ELFMAG1 'E'
-# define ELFMAG2 'L'
-# define ELFMAG3 'F'
-# define ET_NONE 0
-# define ET_REL 1
-# define ET_EXEC 2
-# define ET_DYN 3
-# define ET_CORE 4
-# define EM_386 3
-# define EM_SPARC 2
-# define EM_PPC 20
+#include <elf32.h>
+#include <elf64.h>
+typedef struct Elf32_Ehdr Elf32_Ehdr;
+typedef struct Elf32_Shdr Elf32_Shdr;
+typedef struct Elf32_Sym Elf32_Sym;
+typedef struct Elf32_Rel Elf32_Rel;
+typedef struct Elf32_Rela Elf32_Rela;
+#define ELFMAG0 0x7F
+#define ELFMAG1 'E'
+#define ELFMAG2 'L'
+#define ELFMAG3 'F'
+#define ET_NONE 0
+#define ET_REL 1
+#define ET_EXEC 2
+#define ET_DYN 3
+#define ET_CORE 4
+#define EM_386 3
+#define EM_SPARC 2
+#define EM_PPC 20
#else
-# include <elf.h>
+#include <elf.h>
#endif
#if defined(__sun)
-# include <sys/link.h> // For dynamic section information
+#include <sys/link.h> // For dynamic section information
#endif
// Low-level byte swapping implementation.
-template <size_t s> struct cmELFByteSwapSize {};
+template <size_t s>
+struct cmELFByteSwapSize
+{
+};
void cmELFByteSwap(char*, cmELFByteSwapSize<1> const&)
{
}
void cmELFByteSwap(char* data, cmELFByteSwapSize<2> const&)
{
char one_byte;
- one_byte = data[0]; data[0] = data[1]; data[1] = one_byte;
+ one_byte = data[0];
+ data[0] = data[1];
+ data[1] = one_byte;
}
void cmELFByteSwap(char* data, cmELFByteSwapSize<4> const&)
{
char one_byte;
- one_byte = data[0]; data[0] = data[3]; data[3] = one_byte;
- one_byte = data[1]; data[1] = data[2]; data[2] = one_byte;
+ one_byte = data[0];
+ data[0] = data[3];
+ data[3] = one_byte;
+ one_byte = data[1];
+ data[1] = data[2];
+ data[2] = one_byte;
}
void cmELFByteSwap(char* data, cmELFByteSwapSize<8> const&)
{
char one_byte;
- one_byte = data[0]; data[0] = data[7]; data[7] = one_byte;
- one_byte = data[1]; data[1] = data[6]; data[6] = one_byte;
- one_byte = data[2]; data[2] = data[5]; data[5] = one_byte;
- one_byte = data[3]; data[3] = data[4]; data[4] = one_byte;
+ one_byte = data[0];
+ data[0] = data[7];
+ data[7] = one_byte;
+ one_byte = data[1];
+ data[1] = data[6];
+ data[6] = one_byte;
+ one_byte = data[2];
+ data[2] = data[5];
+ data[5] = one_byte;
+ one_byte = data[3];
+ data[3] = data[4];
+ data[4] = one_byte;
}
// Low-level byte swapping interface.
@@ -83,20 +100,23 @@ class cmELFInternal
{
public:
typedef cmELF::StringEntry StringEntry;
- enum ByteOrderType { ByteOrderMSB, ByteOrderLSB };
+ enum ByteOrderType
+ {
+ ByteOrderMSB,
+ ByteOrderLSB
+ };
// Construct and take ownership of the file stream object.
- cmELFInternal(cmELF* external,
- cmsys::auto_ptr<cmsys::ifstream>& fin,
- ByteOrderType order):
- External(external),
- Stream(*fin.release()),
- ByteOrder(order),
- ELFType(cmELF::FileTypeInvalid)
- {
- // In most cases the processor-specific byte order will match that
- // of the target execution environment. If we choose wrong here
- // it is fixed when the header is read.
+ cmELFInternal(cmELF* external, cmsys::auto_ptr<cmsys::ifstream>& fin,
+ ByteOrderType order)
+ : External(external)
+ , Stream(*fin.release())
+ , ByteOrder(order)
+ , ELFType(cmELF::FileTypeInvalid)
+ {
+// In most cases the processor-specific byte order will match that
+// of the target execution environment. If we choose wrong here
+// it is fixed when the header is read.
#if KWIML_ABI_ENDIAN_ID == KWIML_ABI_ENDIAN_ID_LITTLE
this->NeedSwap = (this->ByteOrder == ByteOrderMSB);
#elif KWIML_ABI_ENDIAN_ID == KWIML_ABI_ENDIAN_ID_BIG
@@ -107,13 +127,10 @@ public:
// We have not yet loaded the section info.
this->DynamicSectionIndex = -1;
- }
+ }
// Destruct and delete the file stream object.
- virtual ~cmELFInternal()
- {
- delete &this->Stream;
- }
+ virtual ~cmELFInternal() { delete &this->Stream; }
// Forward to the per-class implementation.
virtual unsigned int GetNumberOfSections() const = 0;
@@ -123,33 +140,33 @@ public:
virtual void PrintInfo(std::ostream& os) const = 0;
bool ReadBytes(unsigned long pos, unsigned long size, char* buf)
- {
+ {
this->Stream.seekg(pos);
this->Stream.read(buf, size);
- return this->Stream?true:false;
- }
+ return this->Stream ? true : false;
+ }
// Lookup the SONAME in the DYNAMIC section.
StringEntry const* GetSOName()
- {
+ {
return this->GetDynamicSectionString(DT_SONAME);
- }
+ }
// Lookup the RPATH in the DYNAMIC section.
StringEntry const* GetRPath()
- {
+ {
return this->GetDynamicSectionString(DT_RPATH);
- }
+ }
// Lookup the RUNPATH in the DYNAMIC section.
StringEntry const* GetRunPath()
- {
+ {
#if defined(DT_RUNPATH)
return this->GetDynamicSectionString(DT_RUNPATH);
#else
return 0;
#endif
- }
+ }
// Return the recorded ELF type.
cmELF::FileType GetFileType() const { return this->ELFType; }
@@ -176,10 +193,10 @@ protected:
// Helper methods for subclasses.
void SetErrorMessage(const char* msg)
- {
+ {
this->External->ErrorMessage = msg;
this->ELFType = cmELF::FileTypeInvalid;
- }
+ }
// Store string table entry states.
std::map<unsigned int, StringEntry> DynamicSectionStrings;
@@ -190,7 +207,7 @@ struct cmELFTypes32
{
typedef Elf32_Ehdr ELF_Ehdr;
typedef Elf32_Shdr ELF_Shdr;
- typedef Elf32_Dyn ELF_Dyn;
+ typedef Elf32_Dyn ELF_Dyn;
typedef Elf32_Half ELF_Half;
typedef KWIML_INT_uint32_t tagtype;
static const char* GetName() { return "32-bit"; }
@@ -201,7 +218,7 @@ struct cmELFTypes64
{
typedef Elf64_Ehdr ELF_Ehdr;
typedef Elf64_Shdr ELF_Shdr;
- typedef Elf64_Dyn ELF_Dyn;
+ typedef Elf64_Dyn ELF_Dyn;
typedef Elf64_Half ELF_Half;
typedef KWIML_INT_uint64_t tagtype;
static const char* GetName() { return "64-bit"; }
@@ -209,26 +226,25 @@ struct cmELFTypes64
// Parser implementation template.
template <class Types>
-class cmELFInternalImpl: public cmELFInternal
+class cmELFInternalImpl : public cmELFInternal
{
public:
// Copy the ELF file format types from our configuration parameter.
typedef typename Types::ELF_Ehdr ELF_Ehdr;
typedef typename Types::ELF_Shdr ELF_Shdr;
- typedef typename Types::ELF_Dyn ELF_Dyn;
+ typedef typename Types::ELF_Dyn ELF_Dyn;
typedef typename Types::ELF_Half ELF_Half;
typedef typename Types::tagtype tagtype;
// Construct with a stream and byte swap indicator.
- cmELFInternalImpl(cmELF* external,
- cmsys::auto_ptr<cmsys::ifstream>& fin,
+ cmELFInternalImpl(cmELF* external, cmsys::auto_ptr<cmsys::ifstream>& fin,
ByteOrderType order);
// Return the number of sections as specified by the ELF header.
virtual unsigned int GetNumberOfSections() const
- {
+ {
return static_cast<unsigned int>(this->ELFHeader.e_shnum);
- }
+ }
// Get the file position and size of a dynamic section entry.
virtual unsigned int GetDynamicEntryCount();
@@ -239,18 +255,14 @@ public:
// Print information about the ELF file.
virtual void PrintInfo(std::ostream& os) const
- {
+ {
os << "ELF " << Types::GetName();
- if(this->ByteOrder == ByteOrderMSB)
- {
+ if (this->ByteOrder == ByteOrderMSB) {
os << " MSB";
- }
- else if(this->ByteOrder == ByteOrderLSB)
- {
+ } else if (this->ByteOrder == ByteOrderLSB) {
os << " LSB";
- }
- switch(this->ELFType)
- {
+ }
+ switch (this->ELFType) {
case cmELF::FileTypeInvalid:
os << " invalid file";
break;
@@ -272,13 +284,13 @@ public:
case cmELF::FileTypeSpecificProc:
os << " processor-specific type";
break;
- }
- os << "\n";
}
+ os << "\n";
+ }
private:
void ByteSwap(ELF_Ehdr& elf_header)
- {
+ {
cmELFByteSwap(elf_header.e_type);
cmELFByteSwap(elf_header.e_machine);
cmELFByteSwap(elf_header.e_version);
@@ -292,10 +304,10 @@ private:
cmELFByteSwap(elf_header.e_shentsize);
cmELFByteSwap(elf_header.e_shnum);
cmELFByteSwap(elf_header.e_shstrndx);
- }
+ }
void ByteSwap(ELF_Shdr& sec_header)
- {
+ {
cmELFByteSwap(sec_header.sh_name);
cmELFByteSwap(sec_header.sh_type);
cmELFByteSwap(sec_header.sh_flags);
@@ -306,97 +318,154 @@ private:
cmELFByteSwap(sec_header.sh_info);
cmELFByteSwap(sec_header.sh_addralign);
cmELFByteSwap(sec_header.sh_entsize);
- }
+ }
void ByteSwap(ELF_Dyn& dyn)
- {
+ {
cmELFByteSwap(dyn.d_tag);
- switch (dyn.d_tag)
- {
- case DT_NULL: /* dyn.d_un ignored */ break;
- case DT_NEEDED: cmELFByteSwap(dyn.d_un.d_val); break;
- case DT_PLTRELSZ: cmELFByteSwap(dyn.d_un.d_val); break;
- case DT_PLTGOT: cmELFByteSwap(dyn.d_un.d_ptr); break;
- case DT_HASH: cmELFByteSwap(dyn.d_un.d_ptr); break;
- case DT_STRTAB: cmELFByteSwap(dyn.d_un.d_ptr); break;
- case DT_SYMTAB: cmELFByteSwap(dyn.d_un.d_ptr); break;
- case DT_RELA: cmELFByteSwap(dyn.d_un.d_ptr); break;
- case DT_RELASZ: cmELFByteSwap(dyn.d_un.d_val); break;
- case DT_RELAENT: cmELFByteSwap(dyn.d_un.d_val); break;
- case DT_STRSZ: cmELFByteSwap(dyn.d_un.d_val); break;
- case DT_SYMENT: cmELFByteSwap(dyn.d_un.d_val); break;
- case DT_INIT: cmELFByteSwap(dyn.d_un.d_ptr); break;
- case DT_FINI: cmELFByteSwap(dyn.d_un.d_ptr); break;
- case DT_SONAME: cmELFByteSwap(dyn.d_un.d_val); break;
- case DT_RPATH: cmELFByteSwap(dyn.d_un.d_val); break;
- case DT_SYMBOLIC: /* dyn.d_un ignored */ break;
- case DT_REL: cmELFByteSwap(dyn.d_un.d_ptr); break;
- case DT_RELSZ: cmELFByteSwap(dyn.d_un.d_val); break;
- case DT_RELENT: cmELFByteSwap(dyn.d_un.d_val); break;
- case DT_PLTREL: cmELFByteSwap(dyn.d_un.d_val); break;
- case DT_DEBUG: cmELFByteSwap(dyn.d_un.d_ptr); break;
- case DT_TEXTREL: /* dyn.d_un ignored */ break;
- case DT_JMPREL: cmELFByteSwap(dyn.d_un.d_ptr); break;
+ switch (dyn.d_tag) {
+ case DT_NULL: /* dyn.d_un ignored */
+ break;
+ case DT_NEEDED:
+ cmELFByteSwap(dyn.d_un.d_val);
+ break;
+ case DT_PLTRELSZ:
+ cmELFByteSwap(dyn.d_un.d_val);
+ break;
+ case DT_PLTGOT:
+ cmELFByteSwap(dyn.d_un.d_ptr);
+ break;
+ case DT_HASH:
+ cmELFByteSwap(dyn.d_un.d_ptr);
+ break;
+ case DT_STRTAB:
+ cmELFByteSwap(dyn.d_un.d_ptr);
+ break;
+ case DT_SYMTAB:
+ cmELFByteSwap(dyn.d_un.d_ptr);
+ break;
+ case DT_RELA:
+ cmELFByteSwap(dyn.d_un.d_ptr);
+ break;
+ case DT_RELASZ:
+ cmELFByteSwap(dyn.d_un.d_val);
+ break;
+ case DT_RELAENT:
+ cmELFByteSwap(dyn.d_un.d_val);
+ break;
+ case DT_STRSZ:
+ cmELFByteSwap(dyn.d_un.d_val);
+ break;
+ case DT_SYMENT:
+ cmELFByteSwap(dyn.d_un.d_val);
+ break;
+ case DT_INIT:
+ cmELFByteSwap(dyn.d_un.d_ptr);
+ break;
+ case DT_FINI:
+ cmELFByteSwap(dyn.d_un.d_ptr);
+ break;
+ case DT_SONAME:
+ cmELFByteSwap(dyn.d_un.d_val);
+ break;
+ case DT_RPATH:
+ cmELFByteSwap(dyn.d_un.d_val);
+ break;
+ case DT_SYMBOLIC: /* dyn.d_un ignored */
+ break;
+ case DT_REL:
+ cmELFByteSwap(dyn.d_un.d_ptr);
+ break;
+ case DT_RELSZ:
+ cmELFByteSwap(dyn.d_un.d_val);
+ break;
+ case DT_RELENT:
+ cmELFByteSwap(dyn.d_un.d_val);
+ break;
+ case DT_PLTREL:
+ cmELFByteSwap(dyn.d_un.d_val);
+ break;
+ case DT_DEBUG:
+ cmELFByteSwap(dyn.d_un.d_ptr);
+ break;
+ case DT_TEXTREL: /* dyn.d_un ignored */
+ break;
+ case DT_JMPREL:
+ cmELFByteSwap(dyn.d_un.d_ptr);
+ break;
#ifdef T_BIND_NOW
- case T_BIND_NOW: /* dyn.d_un ignored */ break;
+ case T_BIND_NOW: /* dyn.d_un ignored */
+ break;
#endif
#ifdef DT_INIT_ARRAY
- case DT_INIT_ARRAY: cmELFByteSwap(dyn.d_un.d_ptr); break;
+ case DT_INIT_ARRAY:
+ cmELFByteSwap(dyn.d_un.d_ptr);
+ break;
#endif
#ifdef DT_FINI_ARRAY
- case DT_FINI_ARRAY: cmELFByteSwap(dyn.d_un.d_ptr); break;
+ case DT_FINI_ARRAY:
+ cmELFByteSwap(dyn.d_un.d_ptr);
+ break;
#endif
#ifdef DT_INIT_ARRAYSZ
- case DT_INIT_ARRAYSZ: cmELFByteSwap(dyn.d_un.d_val); break;
+ case DT_INIT_ARRAYSZ:
+ cmELFByteSwap(dyn.d_un.d_val);
+ break;
#endif
#ifdef DT_FINI_ARRAYSZ
- case DT_FINI_ARRAYSZ: cmELFByteSwap(dyn.d_un.d_val); break;
+ case DT_FINI_ARRAYSZ:
+ cmELFByteSwap(dyn.d_un.d_val);
+ break;
#endif
#ifdef DT_RUNPATH
- case DT_RUNPATH: cmELFByteSwap(dyn.d_un.d_val); break;
+ case DT_RUNPATH:
+ cmELFByteSwap(dyn.d_un.d_val);
+ break;
#endif
#ifdef DT_FLAGS
- case DT_FLAGS: cmELFByteSwap(dyn.d_un.d_val); break;
+ case DT_FLAGS:
+ cmELFByteSwap(dyn.d_un.d_val);
+ break;
#endif
#ifdef DT_PREINIT_ARRAY
- case DT_PREINIT_ARRAY: cmELFByteSwap(dyn.d_un.d_ptr); break;
+ case DT_PREINIT_ARRAY:
+ cmELFByteSwap(dyn.d_un.d_ptr);
+ break;
#endif
#ifdef DT_PREINIT_ARRAYSZ
- case DT_PREINIT_ARRAYSZ: cmELFByteSwap(dyn.d_un.d_val); break;
+ case DT_PREINIT_ARRAYSZ:
+ cmELFByteSwap(dyn.d_un.d_val);
+ break;
#endif
- }
}
+ }
bool FileTypeValid(ELF_Half et)
- {
+ {
unsigned int eti = static_cast<unsigned int>(et);
- if(eti == ET_NONE || eti == ET_REL || eti == ET_EXEC ||
- eti == ET_DYN || eti == ET_CORE)
- {
+ if (eti == ET_NONE || eti == ET_REL || eti == ET_EXEC || eti == ET_DYN ||
+ eti == ET_CORE) {
return true;
- }
+ }
#if defined(ET_LOOS) && defined(ET_HIOS)
- if(eti >= ET_LOOS && eti <= ET_HIOS)
- {
+ if (eti >= ET_LOOS && eti <= ET_HIOS) {
return true;
- }
+ }
#endif
#if defined(ET_LOPROC) && defined(ET_HIPROC)
- if(eti >= ET_LOPROC && eti <= ET_HIPROC)
- {
+ if (eti >= ET_LOPROC && eti <= ET_HIPROC) {
return true;
- }
+ }
#endif
return false;
- }
+ }
bool Read(ELF_Ehdr& x)
- {
+ {
// Read the header from the file.
- if(!this->Stream.read(reinterpret_cast<char*>(&x), sizeof(x)))
- {
+ if (!this->Stream.read(reinterpret_cast<char*>(&x), sizeof(x))) {
return false;
- }
+ }
// The byte order of ELF header fields may not match that of the
// processor-specific data. The header fields are ordered to
@@ -405,63 +474,55 @@ private:
// value. As a heuristic, if the type is invalid but its
// swapped value is okay then flip our swap mode.
ELF_Half et = x.e_type;
- if(this->NeedSwap)
- {
+ if (this->NeedSwap) {
cmELFByteSwap(et);
- }
- if(!this->FileTypeValid(et))
- {
+ }
+ if (!this->FileTypeValid(et)) {
cmELFByteSwap(et);
- if(this->FileTypeValid(et))
- {
+ if (this->FileTypeValid(et)) {
// The previous byte order guess was wrong. Flip it.
this->NeedSwap = !this->NeedSwap;
- }
}
+ }
// Fix the byte order of the header.
- if(this->NeedSwap)
- {
+ if (this->NeedSwap) {
ByteSwap(x);
- }
- return true;
}
+ return true;
+ }
bool Read(ELF_Shdr& x)
- {
- if(this->Stream.read(reinterpret_cast<char*>(&x), sizeof(x)) &&
- this->NeedSwap)
- {
+ {
+ if (this->Stream.read(reinterpret_cast<char*>(&x), sizeof(x)) &&
+ this->NeedSwap) {
ByteSwap(x);
- }
- return this->Stream? true:false;
}
+ return this->Stream ? true : false;
+ }
bool Read(ELF_Dyn& x)
- {
- if(this->Stream.read(reinterpret_cast<char*>(&x), sizeof(x)) &&
- this->NeedSwap)
- {
+ {
+ if (this->Stream.read(reinterpret_cast<char*>(&x), sizeof(x)) &&
+ this->NeedSwap) {
ByteSwap(x);
- }
- return this->Stream? true:false;
}
+ return this->Stream ? true : false;
+ }
bool LoadSectionHeader(ELF_Half i)
- {
+ {
// Read the section header from the file.
this->Stream.seekg(this->ELFHeader.e_shoff +
this->ELFHeader.e_shentsize * i);
- if(!this->Read(this->SectionHeaders[i]))
- {
+ if (!this->Read(this->SectionHeaders[i])) {
return false;
- }
+ }
// Identify some important sections.
- if(this->SectionHeaders[i].sh_type == SHT_DYNAMIC)
- {
+ if (this->SectionHeaders[i].sh_type == SHT_DYNAMIC) {
this->DynamicSectionIndex = i;
- }
- return true;
}
+ return true;
+ }
bool LoadDynamicSection();
@@ -476,22 +537,18 @@ private:
};
template <class Types>
-cmELFInternalImpl<Types>
-::cmELFInternalImpl(cmELF* external,
- cmsys::auto_ptr<cmsys::ifstream>& fin,
- ByteOrderType order):
- cmELFInternal(external, fin, order)
+cmELFInternalImpl<Types>::cmELFInternalImpl(
+ cmELF* external, cmsys::auto_ptr<cmsys::ifstream>& fin, ByteOrderType order)
+ : cmELFInternal(external, fin, order)
{
// Read the main header.
- if(!this->Read(this->ELFHeader))
- {
+ if (!this->Read(this->ELFHeader)) {
this->SetErrorMessage("Failed to read main ELF header.");
return;
- }
+ }
// Determine the ELF file type.
- switch(this->ELFHeader.e_type)
- {
+ switch (this->ELFHeader.e_type) {
case ET_NONE:
this->SetErrorMessage("ELF file type is NONE.");
return;
@@ -507,133 +564,116 @@ cmELFInternalImpl<Types>
case ET_CORE:
this->ELFType = cmELF::FileTypeCore;
break;
- default:
- {
+ default: {
unsigned int eti = static_cast<unsigned int>(this->ELFHeader.e_type);
#if defined(ET_LOOS) && defined(ET_HIOS)
- if(eti >= ET_LOOS && eti <= ET_HIOS)
- {
+ if (eti >= ET_LOOS && eti <= ET_HIOS) {
this->ELFType = cmELF::FileTypeSpecificOS;
break;
- }
+ }
#endif
#if defined(ET_LOPROC) && defined(ET_HIPROC)
- if(eti >= ET_LOPROC && eti <= ET_HIPROC)
- {
+ if (eti >= ET_LOPROC && eti <= ET_HIPROC) {
this->ELFType = cmELF::FileTypeSpecificProc;
break;
- }
+ }
#endif
std::ostringstream e;
e << "Unknown ELF file type " << eti;
this->SetErrorMessage(e.str().c_str());
return;
- }
}
+ }
// Load the section headers.
this->SectionHeaders.resize(this->ELFHeader.e_shnum);
- for(ELF_Half i=0; i < this->ELFHeader.e_shnum; ++i)
- {
- if(!this->LoadSectionHeader(i))
- {
+ for (ELF_Half i = 0; i < this->ELFHeader.e_shnum; ++i) {
+ if (!this->LoadSectionHeader(i)) {
this->SetErrorMessage("Failed to load section headers.");
return;
- }
}
+ }
}
template <class Types>
bool cmELFInternalImpl<Types>::LoadDynamicSection()
{
// If there is no dynamic section we are done.
- if(this->DynamicSectionIndex < 0)
- {
+ if (this->DynamicSectionIndex < 0) {
return false;
- }
+ }
// If the section was already loaded we are done.
- if(!this->DynamicSectionEntries.empty())
- {
+ if (!this->DynamicSectionEntries.empty()) {
return true;
- }
+ }
// If there are no entries we are done.
ELF_Shdr const& sec = this->SectionHeaders[this->DynamicSectionIndex];
- if(sec.sh_entsize == 0)
- {
+ if (sec.sh_entsize == 0) {
return false;
- }
+ }
// Allocate the dynamic section entries.
int n = static_cast<int>(sec.sh_size / sec.sh_entsize);
this->DynamicSectionEntries.resize(n);
// Read each entry.
- for(int j=0; j < n; ++j)
- {
+ for (int j = 0; j < n; ++j) {
// Seek to the beginning of the section entry.
- this->Stream.seekg(sec.sh_offset + sec.sh_entsize*j);
+ this->Stream.seekg(sec.sh_offset + sec.sh_entsize * j);
ELF_Dyn& dyn = this->DynamicSectionEntries[j];
// Try reading the entry.
- if(!this->Read(dyn))
- {
+ if (!this->Read(dyn)) {
this->SetErrorMessage("Error reading entry from DYNAMIC section.");
this->DynamicSectionIndex = -1;
return false;
- }
}
+ }
return true;
}
template <class Types>
unsigned int cmELFInternalImpl<Types>::GetDynamicEntryCount()
{
- if(!this->LoadDynamicSection())
- {
+ if (!this->LoadDynamicSection()) {
return 0;
- }
- for(unsigned int i = 0; i < this->DynamicSectionEntries.size(); ++i)
- {
- if(this->DynamicSectionEntries[i].d_tag == DT_NULL)
- {
+ }
+ for (unsigned int i = 0; i < this->DynamicSectionEntries.size(); ++i) {
+ if (this->DynamicSectionEntries[i].d_tag == DT_NULL) {
return i;
- }
}
+ }
return static_cast<unsigned int>(this->DynamicSectionEntries.size());
}
template <class Types>
unsigned long cmELFInternalImpl<Types>::GetDynamicEntryPosition(int j)
{
- if(!this->LoadDynamicSection())
- {
+ if (!this->LoadDynamicSection()) {
return 0;
- }
- if(j < 0 || j >= static_cast<int>(this->DynamicSectionEntries.size()))
- {
+ }
+ if (j < 0 || j >= static_cast<int>(this->DynamicSectionEntries.size())) {
return 0;
- }
+ }
ELF_Shdr const& sec = this->SectionHeaders[this->DynamicSectionIndex];
- return static_cast<unsigned long>(sec.sh_offset + sec.sh_entsize*j);
+ return static_cast<unsigned long>(sec.sh_offset + sec.sh_entsize * j);
}
template <class Types>
-cmELF::StringEntry const*
-cmELFInternalImpl<Types>::GetDynamicSectionString(unsigned int tag)
+cmELF::StringEntry const* cmELFInternalImpl<Types>::GetDynamicSectionString(
+ unsigned int tag)
{
// Short-circuit if already checked.
std::map<unsigned int, StringEntry>::iterator dssi =
this->DynamicSectionStrings.find(tag);
- if(dssi != this->DynamicSectionStrings.end())
- {
- if(dssi->second.Position > 0)
- {
+ if (dssi != this->DynamicSectionStrings.end()) {
+ if (dssi->second.Position > 0) {
return &dssi->second;
- }
- return 0;
}
+ return 0;
+ }
// Create an entry for this tag. Assume it is missing until found.
StringEntry& se = this->DynamicSectionStrings[tag];
@@ -642,36 +682,31 @@ cmELFInternalImpl<Types>::GetDynamicSectionString(unsigned int tag)
se.IndexInSection = -1;
// Try reading the dynamic section.
- if(!this->LoadDynamicSection())
- {
+ if (!this->LoadDynamicSection()) {
return 0;
- }
+ }
// Get the string table referenced by the DYNAMIC section.
ELF_Shdr const& sec = this->SectionHeaders[this->DynamicSectionIndex];
- if(sec.sh_link >= this->SectionHeaders.size())
- {
+ if (sec.sh_link >= this->SectionHeaders.size()) {
this->SetErrorMessage("Section DYNAMIC has invalid string table index.");
return 0;
- }
+ }
ELF_Shdr const& strtab = this->SectionHeaders[sec.sh_link];
// Look for the requested entry.
- for(typename std::vector<ELF_Dyn>::iterator
- di = this->DynamicSectionEntries.begin();
- di != this->DynamicSectionEntries.end(); ++di)
- {
+ for (typename std::vector<ELF_Dyn>::iterator di =
+ this->DynamicSectionEntries.begin();
+ di != this->DynamicSectionEntries.end(); ++di) {
ELF_Dyn& dyn = *di;
- if(static_cast<tagtype>(dyn.d_tag) == static_cast<tagtype>(tag))
- {
+ if (static_cast<tagtype>(dyn.d_tag) == static_cast<tagtype>(tag)) {
// We found the tag requested.
// Make sure the position given is within the string section.
- if(dyn.d_un.d_val >= strtab.sh_size)
- {
+ if (dyn.d_un.d_val >= strtab.sh_size) {
this->SetErrorMessage("Section DYNAMIC references string beyond "
"the end of its string section.");
return 0;
- }
+ }
// Seek to the position reported by the entry.
unsigned long first = static_cast<unsigned long>(dyn.d_un.d_val);
@@ -686,26 +721,21 @@ cmELFInternalImpl<Types>::GetDynamicSectionString(unsigned int tag)
// assumption.
bool terminated = false;
char c;
- while(last != end && this->Stream.get(c) && !(terminated && c))
- {
+ while (last != end && this->Stream.get(c) && !(terminated && c)) {
++last;
- if(c)
- {
+ if (c) {
se.Value += c;
- }
- else
- {
+ } else {
terminated = true;
- }
}
+ }
// Make sure the whole value was read.
- if(!this->Stream)
- {
+ if (!this->Stream) {
this->SetErrorMessage("Dynamic section specifies unreadable RPATH.");
se.Value = "";
return 0;
- }
+ }
// The value has been read successfully. Report it.
se.Position = static_cast<unsigned long>(strtab.sh_offset + first);
@@ -713,84 +743,69 @@ cmELFInternalImpl<Types>::GetDynamicSectionString(unsigned int tag)
se.IndexInSection =
static_cast<int>(di - this->DynamicSectionEntries.begin());
return &se;
- }
}
+ }
return 0;
}
//============================================================================
// External class implementation.
-cmELF::cmELF(const char* fname): Internal(0)
+cmELF::cmELF(const char* fname)
+ : Internal(0)
{
// Try to open the file.
cmsys::auto_ptr<cmsys::ifstream> fin(new cmsys::ifstream(fname));
// Quit now if the file could not be opened.
- if(!fin.get() || !*fin)
- {
+ if (!fin.get() || !*fin) {
this->ErrorMessage = "Error opening input file.";
return;
- }
+ }
// Read the ELF identification block.
char ident[EI_NIDENT];
- if(!fin->read(ident, EI_NIDENT))
- {
+ if (!fin->read(ident, EI_NIDENT)) {
this->ErrorMessage = "Error reading ELF identification.";
return;
- }
- if(!fin->seekg(0))
- {
+ }
+ if (!fin->seekg(0)) {
this->ErrorMessage = "Error seeking to beginning of file.";
return;
- }
+ }
// Verify the ELF identification.
- if(!(ident[EI_MAG0] == ELFMAG0 &&
- ident[EI_MAG1] == ELFMAG1 &&
- ident[EI_MAG2] == ELFMAG2 &&
- ident[EI_MAG3] == ELFMAG3))
- {
+ if (!(ident[EI_MAG0] == ELFMAG0 && ident[EI_MAG1] == ELFMAG1 &&
+ ident[EI_MAG2] == ELFMAG2 && ident[EI_MAG3] == ELFMAG3)) {
this->ErrorMessage = "File does not have a valid ELF identification.";
return;
- }
+ }
// Check the byte order in which the rest of the file is encoded.
cmELFInternal::ByteOrderType order;
- if(ident[EI_DATA] == ELFDATA2LSB)
- {
+ if (ident[EI_DATA] == ELFDATA2LSB) {
// File is LSB.
- order = cmELFInternal::ByteOrderLSB;
- }
- else if(ident[EI_DATA] == ELFDATA2MSB)
- {
+ order = cmELFInternal::ByteOrderLSB;
+ } else if (ident[EI_DATA] == ELFDATA2MSB) {
// File is MSB.
- order = cmELFInternal::ByteOrderMSB;
- }
- else
- {
+ order = cmELFInternal::ByteOrderMSB;
+ } else {
this->ErrorMessage = "ELF file is not LSB or MSB encoded.";
return;
- }
+ }
// Check the class of the file and construct the corresponding
// parser implementation.
- if(ident[EI_CLASS] == ELFCLASS32)
- {
+ if (ident[EI_CLASS] == ELFCLASS32) {
// 32-bit ELF
this->Internal = new cmELFInternalImpl<cmELFTypes32>(this, fin, order);
- }
- else if(ident[EI_CLASS] == ELFCLASS64)
- {
+ } else if (ident[EI_CLASS] == ELFCLASS64) {
// 64-bit ELF
this->Internal = new cmELFInternalImpl<cmELFTypes64>(this, fin, order);
- }
- else
- {
+ } else {
this->ErrorMessage = "ELF file class is not 32-bit or 64-bit.";
return;
- }
+ }
}
cmELF::~cmELF()
@@ -805,126 +820,96 @@ bool cmELF::Valid() const
cmELF::FileType cmELF::GetFileType() const
{
- if(this->Valid())
- {
+ if (this->Valid()) {
return this->Internal->GetFileType();
- }
- else
- {
+ } else {
return FileTypeInvalid;
- }
+ }
}
unsigned int cmELF::GetNumberOfSections() const
{
- if(this->Valid())
- {
+ if (this->Valid()) {
return this->Internal->GetNumberOfSections();
- }
- else
- {
+ } else {
return 0;
- }
+ }
}
unsigned int cmELF::GetDynamicEntryCount() const
{
- if(this->Valid())
- {
+ if (this->Valid()) {
return this->Internal->GetDynamicEntryCount();
- }
- else
- {
+ } else {
return 0;
- }
+ }
}
unsigned long cmELF::GetDynamicEntryPosition(int index) const
{
- if(this->Valid())
- {
+ if (this->Valid()) {
return this->Internal->GetDynamicEntryPosition(index);
- }
- else
- {
+ } else {
return 0;
- }
+ }
}
bool cmELF::ReadBytes(unsigned long pos, unsigned long size, char* buf) const
{
- if(this->Valid())
- {
+ if (this->Valid()) {
return this->Internal->ReadBytes(pos, size, buf);
- }
- else
- {
+ } else {
return false;
- }
+ }
}
bool cmELF::GetSOName(std::string& soname)
{
- if(StringEntry const* se = this->GetSOName())
- {
+ if (StringEntry const* se = this->GetSOName()) {
soname = se->Value;
return true;
- }
- else
- {
+ } else {
return false;
- }
+ }
}
cmELF::StringEntry const* cmELF::GetSOName()
{
- if(this->Valid() &&
- this->Internal->GetFileType() == cmELF::FileTypeSharedLibrary)
- {
+ if (this->Valid() &&
+ this->Internal->GetFileType() == cmELF::FileTypeSharedLibrary) {
return this->Internal->GetSOName();
- }
- else
- {
+ } else {
return 0;
- }
+ }
}
cmELF::StringEntry const* cmELF::GetRPath()
{
- if(this->Valid() &&
- (this->Internal->GetFileType() == cmELF::FileTypeExecutable ||
- this->Internal->GetFileType() == cmELF::FileTypeSharedLibrary))
- {
+ if (this->Valid() &&
+ (this->Internal->GetFileType() == cmELF::FileTypeExecutable ||
+ this->Internal->GetFileType() == cmELF::FileTypeSharedLibrary)) {
return this->Internal->GetRPath();
- }
- else
- {
+ } else {
return 0;
- }
+ }
}
cmELF::StringEntry const* cmELF::GetRunPath()
{
- if(this->Valid() &&
- (this->Internal->GetFileType() == cmELF::FileTypeExecutable ||
- this->Internal->GetFileType() == cmELF::FileTypeSharedLibrary))
- {
+ if (this->Valid() &&
+ (this->Internal->GetFileType() == cmELF::FileTypeExecutable ||
+ this->Internal->GetFileType() == cmELF::FileTypeSharedLibrary)) {
return this->Internal->GetRunPath();
- }
- else
- {
+ } else {
return 0;
- }
+ }
}
void cmELF::PrintInfo(std::ostream& os) const
{
- if(this->Valid())
- {
+ if (this->Valid()) {
this->Internal->PrintInfo(os);
- }
- else
- {
+ } else {
os << "Not a valid ELF file.\n";
- }
+ }
}
diff --git a/Source/cmELF.h b/Source/cmELF.h
index ab9be42..80832ad 100644
--- a/Source/cmELF.h
+++ b/Source/cmELF.h
@@ -13,7 +13,7 @@
#define cmELF_h
#if !defined(CMAKE_USE_ELF_PARSER)
-# error "This file may be included only if CMAKE_USE_ELF_PARSER is enabled."
+#error "This file may be included only if CMAKE_USE_ELF_PARSER is enabled."
#endif
class cmELFInternal;
@@ -31,10 +31,7 @@ public:
~cmELF();
/** Get the error message if any. */
- std::string const& GetErrorMessage() const
- {
- return this->ErrorMessage;
- }
+ std::string const& GetErrorMessage() const { return this->ErrorMessage; }
/** Boolean conversion. True if the ELF file is valid. */
operator bool() const { return this->Valid(); }
diff --git a/Source/cmElseCommand.cxx b/Source/cmElseCommand.cxx
index 163d006..6db6f8d 100644
--- a/Source/cmElseCommand.cxx
+++ b/Source/cmElseCommand.cxx
@@ -12,7 +12,7 @@
#include "cmElseCommand.h"
bool cmElseCommand::InitialPass(std::vector<std::string> const&,
- cmExecutionStatus &)
+ cmExecutionStatus&)
{
this->SetError("An ELSE command was found outside of a proper "
"IF ENDIF structure. Or its arguments did not match "
diff --git a/Source/cmElseCommand.h b/Source/cmElseCommand.h
index dde5fcc..815825e 100644
--- a/Source/cmElseCommand.h
+++ b/Source/cmElseCommand.h
@@ -25,17 +25,14 @@ public:
/**
* This is a virtual constructor for the command.
*/
- virtual cmCommand* Clone()
- {
- return new cmElseCommand;
- }
+ virtual cmCommand* Clone() { return new cmElseCommand; }
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus &status);
+ cmExecutionStatus& status);
/**
* This determines if the command is invoked when in script mode.
@@ -45,10 +42,9 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const { return "else";}
+ virtual std::string GetName() const { return "else"; }
cmTypeMacro(cmElseCommand, cmCommand);
};
-
#endif
diff --git a/Source/cmElseIfCommand.cxx b/Source/cmElseIfCommand.cxx
index cd9742b..dc89e24 100644
--- a/Source/cmElseIfCommand.cxx
+++ b/Source/cmElseIfCommand.cxx
@@ -12,7 +12,7 @@
#include "cmElseIfCommand.h"
bool cmElseIfCommand::InitialPass(std::vector<std::string> const&,
- cmExecutionStatus &)
+ cmExecutionStatus&)
{
this->SetError("An ELSEIF command was found outside of a proper "
"IF ENDIF structure.");
diff --git a/Source/cmElseIfCommand.h b/Source/cmElseIfCommand.h
index c627cbe..d0ffa5d 100644
--- a/Source/cmElseIfCommand.h
+++ b/Source/cmElseIfCommand.h
@@ -25,17 +25,14 @@ public:
/**
* This is a virtual constructor for the command.
*/
- virtual cmCommand* Clone()
- {
- return new cmElseIfCommand;
- }
+ virtual cmCommand* Clone() { return new cmElseIfCommand; }
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus &status);
+ cmExecutionStatus& status);
/**
* This determines if the command is invoked when in script mode.
@@ -45,10 +42,9 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const { return "elseif";}
+ virtual std::string GetName() const { return "elseif"; }
cmTypeMacro(cmElseIfCommand, cmCommand);
};
-
#endif
diff --git a/Source/cmEnableLanguageCommand.cxx b/Source/cmEnableLanguageCommand.cxx
index dcabf6a..0ebe778 100644
--- a/Source/cmEnableLanguageCommand.cxx
+++ b/Source/cmEnableLanguageCommand.cxx
@@ -12,32 +12,24 @@
#include "cmEnableLanguageCommand.h"
// cmEnableLanguageCommand
-bool cmEnableLanguageCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmEnableLanguageCommand::InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus&)
{
bool optional = false;
std::vector<std::string> languages;
- if(args.size() < 1 )
- {
- this->SetError
- ("called with incorrect number of arguments");
+ if (args.size() < 1) {
+ this->SetError("called with incorrect number of arguments");
return false;
- }
+ }
for (std::vector<std::string>::const_iterator it = args.begin();
- it != args.end();
- ++it)
- {
- if ((*it) == "OPTIONAL")
- {
+ it != args.end(); ++it) {
+ if ((*it) == "OPTIONAL") {
optional = true;
- }
- else
- {
+ } else {
languages.push_back(*it);
- }
}
+ }
this->Makefile->EnableLanguage(languages, optional);
return true;
}
-
diff --git a/Source/cmEnableLanguageCommand.h b/Source/cmEnableLanguageCommand.h
index 2b09e11..657e4e5 100644
--- a/Source/cmEnableLanguageCommand.h
+++ b/Source/cmEnableLanguageCommand.h
@@ -28,26 +28,21 @@ public:
/**
* This is a virtual constructor for the command.
*/
- virtual cmCommand* Clone()
- {
- return new cmEnableLanguageCommand;
- }
+ virtual cmCommand* Clone() { return new cmEnableLanguageCommand; }
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus &status);
+ cmExecutionStatus& status);
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const {return "enable_language";}
+ virtual std::string GetName() const { return "enable_language"; }
cmTypeMacro(cmEnableLanguageCommand, cmCommand);
};
-
-
#endif
diff --git a/Source/cmEnableTestingCommand.cxx b/Source/cmEnableTestingCommand.cxx
index 6a7fd46..a9c60a8 100644
--- a/Source/cmEnableTestingCommand.cxx
+++ b/Source/cmEnableTestingCommand.cxx
@@ -14,8 +14,8 @@
// we do this in the final pass so that we now the subdirs have all
// been defined
bool cmEnableTestingCommand::InitialPass(std::vector<std::string> const&,
- cmExecutionStatus &)
+ cmExecutionStatus&)
{
- this->Makefile->AddDefinition("CMAKE_TESTING_ENABLED","1");
+ this->Makefile->AddDefinition("CMAKE_TESTING_ENABLED", "1");
return true;
}
diff --git a/Source/cmEnableTestingCommand.h b/Source/cmEnableTestingCommand.h
index d028c59..a518f18 100644
--- a/Source/cmEnableTestingCommand.h
+++ b/Source/cmEnableTestingCommand.h
@@ -33,26 +33,21 @@ public:
/**
* This is a virtual constructor for the command.
*/
- virtual cmCommand* Clone()
- {
- return new cmEnableTestingCommand;
- }
+ virtual cmCommand* Clone() { return new cmEnableTestingCommand; }
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const&,
- cmExecutionStatus &);
+ cmExecutionStatus&);
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const { return "enable_testing";}
+ virtual std::string GetName() const { return "enable_testing"; }
cmTypeMacro(cmEnableTestingCommand, cmCommand);
-
};
-
#endif
diff --git a/Source/cmEndForEachCommand.cxx b/Source/cmEndForEachCommand.cxx
index 7f11ae5..104b39a 100644
--- a/Source/cmEndForEachCommand.cxx
+++ b/Source/cmEndForEachCommand.cxx
@@ -11,13 +11,11 @@
============================================================================*/
#include "cmEndForEachCommand.h"
-bool cmEndForEachCommand
-::InvokeInitialPass(std::vector<cmListFileArgument> const&,
- cmExecutionStatus &)
+bool cmEndForEachCommand::InvokeInitialPass(
+ std::vector<cmListFileArgument> const&, cmExecutionStatus&)
{
this->SetError("An ENDFOREACH command was found outside of a proper "
"FOREACH ENDFOREACH structure. Or its arguments did "
"not match the opening FOREACH command.");
return false;
}
-
diff --git a/Source/cmEndForEachCommand.h b/Source/cmEndForEachCommand.h
index c3be387..ebc794f 100644
--- a/Source/cmEndForEachCommand.h
+++ b/Source/cmEndForEachCommand.h
@@ -25,24 +25,23 @@ public:
/**
* This is a virtual constructor for the command.
*/
- virtual cmCommand* Clone()
- {
- return new cmEndForEachCommand;
- }
+ virtual cmCommand* Clone() { return new cmEndForEachCommand; }
/**
* Override cmCommand::InvokeInitialPass to get arguments before
* expansion.
*/
virtual bool InvokeInitialPass(std::vector<cmListFileArgument> const&,
- cmExecutionStatus &);
+ cmExecutionStatus&);
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
- virtual bool InitialPass(std::vector<std::string> const&,
- cmExecutionStatus &) {return false;}
+ virtual bool InitialPass(std::vector<std::string> const&, cmExecutionStatus&)
+ {
+ return false;
+ }
/**
* This determines if the command is invoked when in script mode.
@@ -52,10 +51,9 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const { return "endforeach";}
+ virtual std::string GetName() const { return "endforeach"; }
cmTypeMacro(cmEndForEachCommand, cmCommand);
};
-
#endif
diff --git a/Source/cmEndFunctionCommand.cxx b/Source/cmEndFunctionCommand.cxx
index 04b242d..b4bfa2d 100644
--- a/Source/cmEndFunctionCommand.cxx
+++ b/Source/cmEndFunctionCommand.cxx
@@ -11,13 +11,11 @@
============================================================================*/
#include "cmEndFunctionCommand.h"
-bool cmEndFunctionCommand
-::InvokeInitialPass(std::vector<cmListFileArgument> const&,
- cmExecutionStatus &)
+bool cmEndFunctionCommand::InvokeInitialPass(
+ std::vector<cmListFileArgument> const&, cmExecutionStatus&)
{
this->SetError("An ENDFUNCTION command was found outside of a proper "
"FUNCTION ENDFUNCTION structure. Or its arguments did not "
"match the opening FUNCTION command.");
return false;
}
-
diff --git a/Source/cmEndFunctionCommand.h b/Source/cmEndFunctionCommand.h
index 3a42c17..b69dec0 100644
--- a/Source/cmEndFunctionCommand.h
+++ b/Source/cmEndFunctionCommand.h
@@ -25,24 +25,23 @@ public:
/**
* This is a virtual constructor for the command.
*/
- virtual cmCommand* Clone()
- {
- return new cmEndFunctionCommand;
- }
+ virtual cmCommand* Clone() { return new cmEndFunctionCommand; }
/**
* Override cmCommand::InvokeInitialPass to get arguments before
* expansion.
*/
virtual bool InvokeInitialPass(std::vector<cmListFileArgument> const&,
- cmExecutionStatus &);
+ cmExecutionStatus&);
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
- virtual bool InitialPass(std::vector<std::string> const&,
- cmExecutionStatus &) {return false;}
+ virtual bool InitialPass(std::vector<std::string> const&, cmExecutionStatus&)
+ {
+ return false;
+ }
/**
* This determines if the command is invoked when in script mode.
@@ -52,10 +51,9 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const { return "endfunction";}
+ virtual std::string GetName() const { return "endfunction"; }
cmTypeMacro(cmEndFunctionCommand, cmCommand);
};
-
#endif
diff --git a/Source/cmEndIfCommand.cxx b/Source/cmEndIfCommand.cxx
index 05f23c4..1ae3a78 100644
--- a/Source/cmEndIfCommand.cxx
+++ b/Source/cmEndIfCommand.cxx
@@ -13,18 +13,16 @@
#include <stdlib.h> // required for atof
bool cmEndIfCommand::InitialPass(std::vector<std::string> const&,
- cmExecutionStatus &)
+ cmExecutionStatus&)
{
- const char* versionValue
- = this->Makefile->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION");
- if (!versionValue || (atof(versionValue) <= 1.4))
- {
+ const char* versionValue =
+ this->Makefile->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION");
+ if (!versionValue || (atof(versionValue) <= 1.4)) {
return true;
- }
+ }
this->SetError("An ENDIF command was found outside of a proper "
"IF ENDIF structure. Or its arguments did not match "
"the opening IF command.");
return false;
}
-
diff --git a/Source/cmEndIfCommand.h b/Source/cmEndIfCommand.h
index a8248c8..457dfd3 100644
--- a/Source/cmEndIfCommand.h
+++ b/Source/cmEndIfCommand.h
@@ -25,17 +25,14 @@ public:
/**
* This is a virtual constructor for the command.
*/
- virtual cmCommand* Clone()
- {
- return new cmEndIfCommand;
- }
+ virtual cmCommand* Clone() { return new cmEndIfCommand; }
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus &status);
+ cmExecutionStatus& status);
/**
* This determines if the command is invoked when in script mode.
@@ -45,10 +42,9 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const { return "endif";}
+ virtual std::string GetName() const { return "endif"; }
cmTypeMacro(cmEndIfCommand, cmCommand);
};
-
#endif
diff --git a/Source/cmEndMacroCommand.cxx b/Source/cmEndMacroCommand.cxx
index 86d907b..435c05f 100644
--- a/Source/cmEndMacroCommand.cxx
+++ b/Source/cmEndMacroCommand.cxx
@@ -11,13 +11,11 @@
============================================================================*/
#include "cmEndMacroCommand.h"
-bool cmEndMacroCommand
-::InvokeInitialPass(std::vector<cmListFileArgument> const&,
- cmExecutionStatus &)
+bool cmEndMacroCommand::InvokeInitialPass(
+ std::vector<cmListFileArgument> const&, cmExecutionStatus&)
{
this->SetError("An ENDMACRO command was found outside of a proper "
"MACRO ENDMACRO structure. Or its arguments did not "
"match the opening MACRO command.");
return false;
}
-
diff --git a/Source/cmEndMacroCommand.h b/Source/cmEndMacroCommand.h
index fdc04ee..615e8dc 100644
--- a/Source/cmEndMacroCommand.h
+++ b/Source/cmEndMacroCommand.h
@@ -25,24 +25,23 @@ public:
/**
* This is a virtual constructor for the command.
*/
- virtual cmCommand* Clone()
- {
- return new cmEndMacroCommand;
- }
+ virtual cmCommand* Clone() { return new cmEndMacroCommand; }
/**
* Override cmCommand::InvokeInitialPass to get arguments before
* expansion.
*/
virtual bool InvokeInitialPass(std::vector<cmListFileArgument> const&,
- cmExecutionStatus &);
+ cmExecutionStatus&);
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
- virtual bool InitialPass(std::vector<std::string> const&,
- cmExecutionStatus &) {return false;}
+ virtual bool InitialPass(std::vector<std::string> const&, cmExecutionStatus&)
+ {
+ return false;
+ }
/**
* This determines if the command is invoked when in script mode.
@@ -52,10 +51,9 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const { return "endmacro";}
+ virtual std::string GetName() const { return "endmacro"; }
cmTypeMacro(cmEndMacroCommand, cmCommand);
};
-
#endif
diff --git a/Source/cmEndWhileCommand.cxx b/Source/cmEndWhileCommand.cxx
index abb9e5e..33507de 100644
--- a/Source/cmEndWhileCommand.cxx
+++ b/Source/cmEndWhileCommand.cxx
@@ -11,22 +11,17 @@
============================================================================*/
#include "cmEndWhileCommand.h"
-bool cmEndWhileCommand
-::InvokeInitialPass(std::vector<cmListFileArgument> const& args,
- cmExecutionStatus &)
+bool cmEndWhileCommand::InvokeInitialPass(
+ std::vector<cmListFileArgument> const& args, cmExecutionStatus&)
{
- if (args.empty())
- {
+ if (args.empty()) {
this->SetError("An ENDWHILE command was found outside of a proper "
"WHILE ENDWHILE structure.");
- }
- else
- {
+ } else {
this->SetError("An ENDWHILE command was found outside of a proper "
"WHILE ENDWHILE structure. Or its arguments did not "
"match the opening WHILE command.");
- }
+ }
return false;
}
-
diff --git a/Source/cmEndWhileCommand.h b/Source/cmEndWhileCommand.h
index ec1cb65..5eda7af 100644
--- a/Source/cmEndWhileCommand.h
+++ b/Source/cmEndWhileCommand.h
@@ -25,24 +25,23 @@ public:
/**
* This is a virtual constructor for the command.
*/
- virtual cmCommand* Clone()
- {
- return new cmEndWhileCommand;
- }
+ virtual cmCommand* Clone() { return new cmEndWhileCommand; }
/**
* Override cmCommand::InvokeInitialPass to get arguments before
* expansion.
*/
virtual bool InvokeInitialPass(std::vector<cmListFileArgument> const& args,
- cmExecutionStatus &status);
+ cmExecutionStatus& status);
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
- virtual bool InitialPass(std::vector<std::string> const&,
- cmExecutionStatus &) {return false;}
+ virtual bool InitialPass(std::vector<std::string> const&, cmExecutionStatus&)
+ {
+ return false;
+ }
/**
* This determines if the command is invoked when in script mode.
@@ -52,10 +51,9 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const { return "endwhile";}
+ virtual std::string GetName() const { return "endwhile"; }
cmTypeMacro(cmEndWhileCommand, cmCommand);
};
-
#endif
diff --git a/Source/cmExecProgramCommand.cxx b/Source/cmExecProgramCommand.cxx
index 1109737..f3f8c2f 100644
--- a/Source/cmExecProgramCommand.cxx
+++ b/Source/cmExecProgramCommand.cxx
@@ -16,14 +16,13 @@
#include <cmsys/Process.h>
// cmExecProgramCommand
-bool cmExecProgramCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmExecProgramCommand::InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus&)
{
- if(args.size() < 1 )
- {
+ if (args.size() < 1) {
this->SetError("called with incorrect number of arguments");
return false;
- }
+ }
std::string arguments;
bool doingargs = false;
int count = 0;
@@ -31,131 +30,102 @@ bool cmExecProgramCommand
bool haveoutput_variable = false;
std::string return_variable;
bool havereturn_variable = false;
- for(size_t i=0; i < args.size(); ++i)
- {
- if(args[i] == "OUTPUT_VARIABLE")
- {
+ for (size_t i = 0; i < args.size(); ++i) {
+ if (args[i] == "OUTPUT_VARIABLE") {
count++;
doingargs = false;
havereturn_variable = false;
haveoutput_variable = true;
- }
- else if ( haveoutput_variable )
- {
- if (!output_variable.empty())
- {
+ } else if (haveoutput_variable) {
+ if (!output_variable.empty()) {
this->SetError("called with incorrect number of arguments");
return false;
- }
+ }
output_variable = args[i];
haveoutput_variable = false;
- count ++;
- }
- else if(args[i] == "RETURN_VALUE")
- {
+ count++;
+ } else if (args[i] == "RETURN_VALUE") {
count++;
doingargs = false;
haveoutput_variable = false;
havereturn_variable = true;
- }
- else if ( havereturn_variable )
- {
- if (!return_variable.empty())
- {
+ } else if (havereturn_variable) {
+ if (!return_variable.empty()) {
this->SetError("called with incorrect number of arguments");
return false;
- }
+ }
return_variable = args[i];
havereturn_variable = false;
- count ++;
- }
- else if(args[i] == "ARGS")
- {
+ count++;
+ } else if (args[i] == "ARGS") {
count++;
havereturn_variable = false;
haveoutput_variable = false;
doingargs = true;
- }
- else if(doingargs)
- {
+ } else if (doingargs) {
arguments += args[i];
arguments += " ";
count++;
- }
}
+ }
std::string command;
- if(!arguments.empty())
- {
+ if (!arguments.empty()) {
command = cmSystemTools::ConvertToRunCommandPath(args[0].c_str());
command += " ";
command += arguments;
- }
- else
- {
+ } else {
command = args[0];
- }
+ }
bool verbose = true;
- if(!output_variable.empty())
- {
+ if (!output_variable.empty()) {
verbose = false;
- }
+ }
int retVal = 0;
std::string output;
bool result = true;
- if(args.size() - count == 2)
- {
+ if (args.size() - count == 2) {
cmSystemTools::MakeDirectory(args[1].c_str());
result = cmExecProgramCommand::RunCommand(command.c_str(), output, retVal,
args[1].c_str(), verbose);
- }
- else
- {
- result = cmExecProgramCommand::RunCommand(command.c_str(), output,
- retVal, 0, verbose);
- }
- if(!result)
- {
+ } else {
+ result = cmExecProgramCommand::RunCommand(command.c_str(), output, retVal,
+ 0, verbose);
+ }
+ if (!result) {
retVal = -1;
- }
+ }
- if (!output_variable.empty())
- {
+ if (!output_variable.empty()) {
std::string::size_type first = output.find_first_not_of(" \n\t\r");
std::string::size_type last = output.find_last_not_of(" \n\t\r");
- if(first == std::string::npos)
- {
+ if (first == std::string::npos) {
first = 0;
- }
- if(last == std::string::npos)
- {
- last = output.size()-1;
- }
+ }
+ if (last == std::string::npos) {
+ last = output.size() - 1;
+ }
- std::string coutput = std::string(output, first, last-first+1);
+ std::string coutput = std::string(output, first, last - first + 1);
this->Makefile->AddDefinition(output_variable, coutput.c_str());
- }
+ }
- if (!return_variable.empty())
- {
+ if (!return_variable.empty()) {
char buffer[100];
sprintf(buffer, "%d", retVal);
this->Makefile->AddDefinition(return_variable, buffer);
- }
+ }
return true;
}
-bool cmExecProgramCommand::RunCommand(const char* command,
- std::string& output,
- int &retVal,
- const char* dir,
+bool cmExecProgramCommand::RunCommand(const char* command, std::string& output,
+ int& retVal, const char* dir,
bool verbose)
{
- if(cmSystemTools::GetRunCommandOutput())
- {
+ if (cmSystemTools::GetRunCommandOutput()) {
verbose = false;
- }
+ }
#if defined(_WIN32) && !defined(__CYGWIN__)
// if the command does not start with a quote, then
@@ -164,100 +134,82 @@ bool cmExecProgramCommand::RunCommand(const char* command,
// shell command like echo or dir
int count = 0;
std::string shortCmd;
- if(command[0] == '\"')
- {
+ if (command[0] == '\"') {
// count the number of quotes
- for(const char* s = command; *s != 0; ++s)
- {
- if(*s == '\"')
- {
+ for (const char* s = command; *s != 0; ++s) {
+ if (*s == '\"') {
count++;
- if(count > 2)
- {
+ if (count > 2) {
break;
- }
}
}
+ }
// if there are more than two double quotes use
// GetShortPathName, the cmd.exe program in windows which
// is used by system fails to execute if there are more than
// one set of quotes in the arguments
- if(count > 2)
- {
+ if (count > 2) {
cmsys::RegularExpression quoted("^\"([^\"]*)\"[ \t](.*)");
- if(quoted.find(command))
- {
+ if (quoted.find(command)) {
std::string cmd = quoted.match(1);
std::string args = quoted.match(2);
- if(! cmSystemTools::FileExists(cmd.c_str()) )
- {
+ if (!cmSystemTools::FileExists(cmd.c_str())) {
shortCmd = cmd;
- }
- else if(!cmSystemTools::GetShortPath(cmd.c_str(), shortCmd))
- {
- cmSystemTools::Error("GetShortPath failed for " , cmd.c_str());
+ } else if (!cmSystemTools::GetShortPath(cmd.c_str(), shortCmd)) {
+ cmSystemTools::Error("GetShortPath failed for ", cmd.c_str());
return false;
- }
+ }
shortCmd += " ";
shortCmd += args;
command = shortCmd.c_str();
- }
- else
- {
+ } else {
cmSystemTools::Error("Could not parse command line with quotes ",
command);
- }
}
}
+ }
#endif
// Allocate a process instance.
cmsysProcess* cp = cmsysProcess_New();
- if(!cp)
- {
+ if (!cp) {
cmSystemTools::Error("Error allocating process instance.");
return false;
- }
+ }
#if defined(_WIN32) && !defined(__CYGWIN__)
- if(dir)
- {
+ if (dir) {
cmsysProcess_SetWorkingDirectory(cp, dir);
- }
- if(cmSystemTools::GetRunCommandHideConsole())
- {
+ }
+ if (cmSystemTools::GetRunCommandHideConsole()) {
cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
- }
+ }
cmsysProcess_SetOption(cp, cmsysProcess_Option_Verbatim, 1);
- const char* cmd[] = {command, 0};
+ const char* cmd[] = { command, 0 };
cmsysProcess_SetCommand(cp, cmd);
#else
std::string commandInDir;
- if(dir)
- {
+ if (dir) {
commandInDir = "cd \"";
commandInDir += dir;
commandInDir += "\" && ";
commandInDir += command;
- }
- else
- {
+ } else {
commandInDir = command;
- }
+ }
#ifndef __VMS
commandInDir += " 2>&1";
#endif
command = commandInDir.c_str();
- if(verbose)
- {
+ if (verbose) {
cmSystemTools::Stdout("running ");
cmSystemTools::Stdout(command);
cmSystemTools::Stdout("\n");
- }
+ }
fflush(stdout);
fflush(stderr);
- const char* cmd[] = {"/bin/sh", "-c", command, 0};
+ const char* cmd[] = { "/bin/sh", "-c", command, 0 };
cmsysProcess_SetCommand(cp, cmd);
#endif
@@ -267,25 +219,21 @@ bool cmExecProgramCommand::RunCommand(const char* command,
int length;
char* data;
int p;
- while((p = cmsysProcess_WaitForData(cp, &data, &length, 0), p))
- {
- if(p == cmsysProcess_Pipe_STDOUT || p == cmsysProcess_Pipe_STDERR)
- {
- if(verbose)
- {
+ while ((p = cmsysProcess_WaitForData(cp, &data, &length, 0), p)) {
+ if (p == cmsysProcess_Pipe_STDOUT || p == cmsysProcess_Pipe_STDERR) {
+ if (verbose) {
cmSystemTools::Stdout(data, length);
- }
- output.append(data, length);
}
+ output.append(data, length);
}
+ }
// All output has been read. Wait for the process to exit.
cmsysProcess_WaitForExit(cp, 0);
// Check the result of running the process.
std::string msg;
- switch(cmsysProcess_GetState(cp))
- {
+ switch (cmsysProcess_GetState(cp)) {
case cmsysProcess_State_Exited:
retVal = cmsysProcess_GetExitValue(cp);
break;
@@ -303,29 +251,26 @@ bool cmExecProgramCommand::RunCommand(const char* command,
retVal = -1;
msg += "\nProcess terminated due to timeout.";
break;
- }
- if(!msg.empty())
- {
+ }
+ if (!msg.empty()) {
#if defined(_WIN32) && !defined(__CYGWIN__)
// Old Windows process execution printed this info.
msg += "\n\nfor command: ";
msg += command;
- if(dir)
- {
+ if (dir) {
msg += "\nin dir: ";
msg += dir;
- }
+ }
msg += "\n";
- if(verbose)
- {
+ if (verbose) {
cmSystemTools::Stdout(msg.c_str());
- }
+ }
output += msg;
#else
// Old UNIX process execution only put message in output.
output += msg;
#endif
- }
+ }
// Delete the process instance.
cmsysProcess_Delete(cp);
diff --git a/Source/cmExecProgramCommand.h b/Source/cmExecProgramCommand.h
index adefdf9..e6e76d2 100644
--- a/Source/cmExecProgramCommand.h
+++ b/Source/cmExecProgramCommand.h
@@ -27,23 +27,19 @@ public:
/**
* This is a virtual constructor for the command.
*/
- virtual cmCommand* Clone()
- {
- return new cmExecProgramCommand;
- }
+ virtual cmCommand* Clone() { return new cmExecProgramCommand; }
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus &status);
+ cmExecutionStatus& status);
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const
- {return "exec_program";}
+ virtual std::string GetName() const { return "exec_program"; }
/**
* This determines if the command is invoked when in script mode.
@@ -51,10 +47,10 @@ public:
virtual bool IsScriptable() const { return true; }
cmTypeMacro(cmExecProgramCommand, cmCommand);
+
private:
- static bool RunCommand(const char* command, std::string& output,
- int &retVal, const char* directory = 0,
- bool verbose = true);
+ static bool RunCommand(const char* command, std::string& output, int& retVal,
+ const char* directory = 0, bool verbose = true);
};
#endif
diff --git a/Source/cmExecuteProcessCommand.cxx b/Source/cmExecuteProcessCommand.cxx
index a1e5010..575cdc3 100644
--- a/Source/cmExecuteProcessCommand.cxx
+++ b/Source/cmExecuteProcessCommand.cxx
@@ -24,19 +24,18 @@ static bool cmExecuteProcessCommandIsWhitespace(char c)
void cmExecuteProcessCommandFixText(std::vector<char>& output,
bool strip_trailing_whitespace);
-void cmExecuteProcessCommandAppend(std::vector<char>& output,
- const char* data, int length);
+void cmExecuteProcessCommandAppend(std::vector<char>& output, const char* data,
+ int length);
// cmExecuteProcessCommand
-bool cmExecuteProcessCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmExecuteProcessCommand::InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus&)
{
- if(args.size() < 1 )
- {
+ if (args.size() < 1) {
this->SetError("called with incorrect number of arguments");
return false;
- }
- std::vector< std::vector<const char*> > cmds;
+ }
+ std::vector<std::vector<const char*> > cmds;
std::string arguments;
bool doing_command = false;
size_t command_index = 0;
@@ -52,246 +51,173 @@ bool cmExecuteProcessCommand
std::string error_variable;
std::string result_variable;
std::string working_directory;
- for(size_t i=0; i < args.size(); ++i)
- {
- if(args[i] == "COMMAND")
- {
+ for (size_t i = 0; i < args.size(); ++i) {
+ if (args[i] == "COMMAND") {
doing_command = true;
command_index = cmds.size();
cmds.push_back(std::vector<const char*>());
- }
- else if(args[i] == "OUTPUT_VARIABLE")
- {
+ } else if (args[i] == "OUTPUT_VARIABLE") {
doing_command = false;
- if(++i < args.size())
- {
+ if (++i < args.size()) {
output_variable = args[i];
- }
- else
- {
+ } else {
this->SetError(" called with no value for OUTPUT_VARIABLE.");
return false;
- }
}
- else if(args[i] == "ERROR_VARIABLE")
- {
+ } else if (args[i] == "ERROR_VARIABLE") {
doing_command = false;
- if(++i < args.size())
- {
+ if (++i < args.size()) {
error_variable = args[i];
- }
- else
- {
+ } else {
this->SetError(" called with no value for ERROR_VARIABLE.");
return false;
- }
}
- else if(args[i] == "RESULT_VARIABLE")
- {
+ } else if (args[i] == "RESULT_VARIABLE") {
doing_command = false;
- if(++i < args.size())
- {
+ if (++i < args.size()) {
result_variable = args[i];
- }
- else
- {
+ } else {
this->SetError(" called with no value for RESULT_VARIABLE.");
return false;
- }
}
- else if(args[i] == "WORKING_DIRECTORY")
- {
+ } else if (args[i] == "WORKING_DIRECTORY") {
doing_command = false;
- if(++i < args.size())
- {
+ if (++i < args.size()) {
working_directory = args[i];
- }
- else
- {
+ } else {
this->SetError(" called with no value for WORKING_DIRECTORY.");
return false;
- }
}
- else if(args[i] == "INPUT_FILE")
- {
+ } else if (args[i] == "INPUT_FILE") {
doing_command = false;
- if(++i < args.size())
- {
+ if (++i < args.size()) {
input_file = args[i];
- }
- else
- {
+ } else {
this->SetError(" called with no value for INPUT_FILE.");
return false;
- }
}
- else if(args[i] == "OUTPUT_FILE")
- {
+ } else if (args[i] == "OUTPUT_FILE") {
doing_command = false;
- if(++i < args.size())
- {
+ if (++i < args.size()) {
output_file = args[i];
- }
- else
- {
+ } else {
this->SetError(" called with no value for OUTPUT_FILE.");
return false;
- }
}
- else if(args[i] == "ERROR_FILE")
- {
+ } else if (args[i] == "ERROR_FILE") {
doing_command = false;
- if(++i < args.size())
- {
+ if (++i < args.size()) {
error_file = args[i];
- }
- else
- {
+ } else {
this->SetError(" called with no value for ERROR_FILE.");
return false;
- }
}
- else if(args[i] == "TIMEOUT")
- {
+ } else if (args[i] == "TIMEOUT") {
doing_command = false;
- if(++i < args.size())
- {
+ if (++i < args.size()) {
timeout_string = args[i];
- }
- else
- {
+ } else {
this->SetError(" called with no value for TIMEOUT.");
return false;
- }
}
- else if(args[i] == "OUTPUT_QUIET")
- {
+ } else if (args[i] == "OUTPUT_QUIET") {
doing_command = false;
output_quiet = true;
- }
- else if(args[i] == "ERROR_QUIET")
- {
+ } else if (args[i] == "ERROR_QUIET") {
doing_command = false;
error_quiet = true;
- }
- else if(args[i] == "OUTPUT_STRIP_TRAILING_WHITESPACE")
- {
+ } else if (args[i] == "OUTPUT_STRIP_TRAILING_WHITESPACE") {
doing_command = false;
output_strip_trailing_whitespace = true;
- }
- else if(args[i] == "ERROR_STRIP_TRAILING_WHITESPACE")
- {
+ } else if (args[i] == "ERROR_STRIP_TRAILING_WHITESPACE") {
doing_command = false;
error_strip_trailing_whitespace = true;
- }
- else if(doing_command)
- {
+ } else if (doing_command) {
cmds[command_index].push_back(args[i].c_str());
- }
- else
- {
+ } else {
std::ostringstream e;
e << " given unknown argument \"" << args[i] << "\".";
this->SetError(e.str());
return false;
- }
}
+ }
- if ( !this->Makefile->CanIWriteThisFile(output_file.c_str()) )
- {
- std::string e = "attempted to output into a file: " + output_file
- + " into a source directory.";
+ if (!this->Makefile->CanIWriteThisFile(output_file.c_str())) {
+ std::string e = "attempted to output into a file: " + output_file +
+ " into a source directory.";
this->SetError(e);
cmSystemTools::SetFatalErrorOccured();
return false;
- }
+ }
// Check for commands given.
- if(cmds.empty())
- {
+ if (cmds.empty()) {
this->SetError(" called with no COMMAND argument.");
return false;
- }
- for(unsigned int i=0; i < cmds.size(); ++i)
- {
- if(cmds[i].empty())
- {
+ }
+ for (unsigned int i = 0; i < cmds.size(); ++i) {
+ if (cmds[i].empty()) {
this->SetError(" given COMMAND argument with no value.");
return false;
- }
- else
- {
+ } else {
// Add the null terminating pointer to the command argument list.
cmds[i].push_back(0);
- }
}
+ }
// Parse the timeout string.
double timeout = -1;
- if(!timeout_string.empty())
- {
- if(sscanf(timeout_string.c_str(), "%lg", &timeout) != 1)
- {
+ if (!timeout_string.empty()) {
+ if (sscanf(timeout_string.c_str(), "%lg", &timeout) != 1) {
this->SetError(" called with TIMEOUT value that could not be parsed.");
return false;
- }
}
+ }
// Create a process instance.
cmsysProcess* cp = cmsysProcess_New();
// Set the command sequence.
- for(unsigned int i=0; i < cmds.size(); ++i)
- {
+ for (unsigned int i = 0; i < cmds.size(); ++i) {
cmsysProcess_AddCommand(cp, &*cmds[i].begin());
- }
+ }
// Set the process working directory.
- if(!working_directory.empty())
- {
+ if (!working_directory.empty()) {
cmsysProcess_SetWorkingDirectory(cp, working_directory.c_str());
- }
+ }
// Always hide the process window.
cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
// Check the output variables.
bool merge_output = false;
- if(!input_file.empty())
- {
+ if (!input_file.empty()) {
cmsysProcess_SetPipeFile(cp, cmsysProcess_Pipe_STDIN, input_file.c_str());
- }
- if(!output_file.empty())
- {
+ }
+ if (!output_file.empty()) {
cmsysProcess_SetPipeFile(cp, cmsysProcess_Pipe_STDOUT,
output_file.c_str());
- }
- if(!error_file.empty())
- {
- if (error_file == output_file)
- {
+ }
+ if (!error_file.empty()) {
+ if (error_file == output_file) {
merge_output = true;
- }
- else
- {
+ } else {
cmsysProcess_SetPipeFile(cp, cmsysProcess_Pipe_STDERR,
error_file.c_str());
- }
}
- if (!output_variable.empty() && output_variable == error_variable)
- {
+ }
+ if (!output_variable.empty() && output_variable == error_variable) {
merge_output = true;
- }
- if (merge_output)
- {
+ }
+ if (merge_output) {
cmsysProcess_SetOption(cp, cmsysProcess_Option_MergeOutput, 1);
- }
+ }
// Set the timeout if any.
- if(timeout >= 0)
- {
+ if (timeout >= 0) {
cmsysProcess_SetTimeout(cp, timeout);
- }
+ }
// Start the process.
cmsysProcess_Execute(cp);
@@ -302,81 +228,61 @@ bool cmExecuteProcessCommand
int length;
char* data;
int p;
- while((p = cmsysProcess_WaitForData(cp, &data, &length, 0), p))
- {
+ while ((p = cmsysProcess_WaitForData(cp, &data, &length, 0), p)) {
// Put the output in the right place.
- if (p == cmsysProcess_Pipe_STDOUT && !output_quiet)
- {
- if(output_variable.empty())
- {
+ if (p == cmsysProcess_Pipe_STDOUT && !output_quiet) {
+ if (output_variable.empty()) {
cmSystemTools::Stdout(data, length);
- }
- else
- {
+ } else {
cmExecuteProcessCommandAppend(tempOutput, data, length);
- }
}
- else if(p == cmsysProcess_Pipe_STDERR && !error_quiet)
- {
- if(error_variable.empty())
- {
+ } else if (p == cmsysProcess_Pipe_STDERR && !error_quiet) {
+ if (error_variable.empty()) {
cmSystemTools::Stderr(data, length);
- }
- else
- {
+ } else {
cmExecuteProcessCommandAppend(tempError, data, length);
- }
}
}
+ }
// All output has been read. Wait for the process to exit.
cmsysProcess_WaitForExit(cp, 0);
// Fix the text in the output strings.
- cmExecuteProcessCommandFixText(tempOutput,
- output_strip_trailing_whitespace);
- cmExecuteProcessCommandFixText(tempError,
- error_strip_trailing_whitespace);
+ cmExecuteProcessCommandFixText(tempOutput, output_strip_trailing_whitespace);
+ cmExecuteProcessCommandFixText(tempError, error_strip_trailing_whitespace);
// Store the output obtained.
- if(!output_variable.empty() && !tempOutput.empty())
- {
- this->Makefile->AddDefinition(output_variable,
- &*tempOutput.begin());
- }
- if(!merge_output && !error_variable.empty() && !tempError.empty())
- {
- this->Makefile->AddDefinition(error_variable,
- &*tempError.begin());
- }
+ if (!output_variable.empty() && !tempOutput.empty()) {
+ this->Makefile->AddDefinition(output_variable, &*tempOutput.begin());
+ }
+ if (!merge_output && !error_variable.empty() && !tempError.empty()) {
+ this->Makefile->AddDefinition(error_variable, &*tempError.begin());
+ }
// Store the result of running the process.
- if(!result_variable.empty())
- {
- switch(cmsysProcess_GetState(cp))
- {
- case cmsysProcess_State_Exited:
- {
+ if (!result_variable.empty()) {
+ switch (cmsysProcess_GetState(cp)) {
+ case cmsysProcess_State_Exited: {
int v = cmsysProcess_GetExitValue(cp);
char buf[100];
sprintf(buf, "%d", v);
this->Makefile->AddDefinition(result_variable, buf);
- }
- break;
+ } break;
case cmsysProcess_State_Exception:
this->Makefile->AddDefinition(result_variable,
- cmsysProcess_GetExceptionString(cp));
+ cmsysProcess_GetExceptionString(cp));
break;
case cmsysProcess_State_Error:
this->Makefile->AddDefinition(result_variable,
- cmsysProcess_GetErrorString(cp));
+ cmsysProcess_GetErrorString(cp));
break;
case cmsysProcess_State_Expired:
this->Makefile->AddDefinition(result_variable,
- "Process terminated due to timeout");
+ "Process terminated due to timeout");
break;
- }
}
+ }
// Delete the process instance.
cmsysProcess_Delete(cp);
@@ -390,25 +296,22 @@ void cmExecuteProcessCommandFixText(std::vector<char>& output,
// Remove \0 characters and the \r part of \r\n pairs.
unsigned int in_index = 0;
unsigned int out_index = 0;
- while(in_index < output.size())
- {
+ while (in_index < output.size()) {
char c = output[in_index++];
- if((c != '\r' || !(in_index < output.size() && output[in_index] == '\n'))
- && c != '\0')
- {
+ if ((c != '\r' ||
+ !(in_index < output.size() && output[in_index] == '\n')) &&
+ c != '\0') {
output[out_index++] = c;
- }
}
+ }
// Remove trailing whitespace if requested.
- if(strip_trailing_whitespace)
- {
- while(out_index > 0 &&
- cmExecuteProcessCommandIsWhitespace(output[out_index-1]))
- {
+ if (strip_trailing_whitespace) {
+ while (out_index > 0 &&
+ cmExecuteProcessCommandIsWhitespace(output[out_index - 1])) {
--out_index;
- }
}
+ }
// Shrink the vector to the size needed.
output.resize(out_index);
@@ -417,19 +320,18 @@ void cmExecuteProcessCommandFixText(std::vector<char>& output,
output.push_back('\0');
}
-void cmExecuteProcessCommandAppend(std::vector<char>& output,
- const char* data, int length)
+void cmExecuteProcessCommandAppend(std::vector<char>& output, const char* data,
+ int length)
{
#if defined(__APPLE__)
// HACK on Apple to work around bug with inserting at the
// end of an empty vector. This resulted in random failures
// that were hard to reproduce.
- if(output.empty() && length > 0)
- {
+ if (output.empty() && length > 0) {
output.push_back(data[0]);
++data;
--length;
- }
+ }
#endif
- output.insert(output.end(), data, data+length);
+ output.insert(output.end(), data, data + length);
}
diff --git a/Source/cmExecuteProcessCommand.h b/Source/cmExecuteProcessCommand.h
index 6906a08..a89e705 100644
--- a/Source/cmExecuteProcessCommand.h
+++ b/Source/cmExecuteProcessCommand.h
@@ -26,23 +26,19 @@ public:
/**
* This is a virtual constructor for the command.
*/
- virtual cmCommand* Clone()
- {
- return new cmExecuteProcessCommand;
- }
+ virtual cmCommand* Clone() { return new cmExecuteProcessCommand; }
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus &status);
+ cmExecutionStatus& status);
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const
- {return "execute_process";}
+ virtual std::string GetName() const { return "execute_process"; }
/**
* This determines if the command is invoked when in script mode.
diff --git a/Source/cmExecutionStatus.h b/Source/cmExecutionStatus.h
index 201465d..508c6bd 100644
--- a/Source/cmExecutionStatus.h
+++ b/Source/cmExecutionStatus.h
@@ -24,28 +24,22 @@ class cmExecutionStatus
public:
cmExecutionStatus() { this->Clear(); }
- void SetReturnInvoked(bool val)
- { this->ReturnInvoked = val; }
- bool GetReturnInvoked()
- { return this->ReturnInvoked; }
+ void SetReturnInvoked(bool val) { this->ReturnInvoked = val; }
+ bool GetReturnInvoked() { return this->ReturnInvoked; }
- void SetBreakInvoked(bool val)
- { this->BreakInvoked = val; }
- bool GetBreakInvoked()
- { return this->BreakInvoked; }
+ void SetBreakInvoked(bool val) { this->BreakInvoked = val; }
+ bool GetBreakInvoked() { return this->BreakInvoked; }
- void SetContinueInvoked(bool val)
- { this->ContinueInvoked = val; }
- bool GetContinueInvoked()
- { return this->ContinueInvoked; }
+ void SetContinueInvoked(bool val) { this->ContinueInvoked = val; }
+ bool GetContinueInvoked() { return this->ContinueInvoked; }
void Clear()
- {
+ {
this->ReturnInvoked = false;
this->BreakInvoked = false;
this->ContinueInvoked = false;
this->NestedError = false;
- }
+ }
void SetNestedError(bool val) { this->NestedError = val; }
bool GetNestedError() { return this->NestedError; }
diff --git a/Source/cmExpandedCommandArgument.cxx b/Source/cmExpandedCommandArgument.cxx
index 4477cf5..df7fba1 100644
--- a/Source/cmExpandedCommandArgument.cxx
+++ b/Source/cmExpandedCommandArgument.cxx
@@ -12,17 +12,16 @@
#include "cmExpandedCommandArgument.h"
-cmExpandedCommandArgument::cmExpandedCommandArgument():
- Quoted(false)
+cmExpandedCommandArgument::cmExpandedCommandArgument()
+ : Quoted(false)
{
-
}
-cmExpandedCommandArgument::cmExpandedCommandArgument(
- std::string const& value, bool quoted):
- Value(value), Quoted(quoted)
+cmExpandedCommandArgument::cmExpandedCommandArgument(std::string const& value,
+ bool quoted)
+ : Value(value)
+ , Quoted(quoted)
{
-
}
std::string const& cmExpandedCommandArgument::GetValue() const
@@ -35,7 +34,7 @@ bool cmExpandedCommandArgument::WasQuoted() const
return this->Quoted;
}
-bool cmExpandedCommandArgument::operator== (std::string const& value) const
+bool cmExpandedCommandArgument::operator==(std::string const& value) const
{
return this->Value == value;
}
diff --git a/Source/cmExpandedCommandArgument.h b/Source/cmExpandedCommandArgument.h
index f4e1517..1f8e405 100644
--- a/Source/cmExpandedCommandArgument.h
+++ b/Source/cmExpandedCommandArgument.h
@@ -31,7 +31,7 @@ public:
bool WasQuoted() const;
- bool operator== (std::string const& value) const;
+ bool operator==(std::string const& value) const;
bool empty() const;
diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx
index c1fa54b..8ca7a11 100644
--- a/Source/cmExportBuildFileGenerator.cxx
+++ b/Source/cmExportBuildFileGenerator.cxx
@@ -25,56 +25,47 @@ cmExportBuildFileGenerator::cmExportBuildFileGenerator()
void cmExportBuildFileGenerator::Compute(cmLocalGenerator* lg)
{
this->LG = lg;
- if (this->ExportSet)
- {
+ if (this->ExportSet) {
this->ExportSet->Compute(lg);
- }
+ }
}
bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os)
{
{
- std::string expectedTargets;
- std::string sep;
- std::vector<std::string> targets;
- this->GetTargets(targets);
- for(std::vector<std::string>::const_iterator
- tei = targets.begin();
- tei != targets.end(); ++tei)
- {
- cmGeneratorTarget *te = this->LG
- ->FindGeneratorTargetToUse(*tei);
- expectedTargets += sep + this->Namespace + te->GetExportName();
- sep = " ";
- if(this->ExportedTargets.insert(te).second)
- {
- this->Exports.push_back(te);
- }
- else
- {
- std::ostringstream e;
- e << "given target \"" << te->GetName() << "\" more than once.";
- this->LG->GetGlobalGenerator()->GetCMakeInstance()
- ->IssueMessage(cmake::FATAL_ERROR, e.str(),
- this->LG->GetMakefile()->GetBacktrace());
- return false;
+ std::string expectedTargets;
+ std::string sep;
+ std::vector<std::string> targets;
+ this->GetTargets(targets);
+ for (std::vector<std::string>::const_iterator tei = targets.begin();
+ tei != targets.end(); ++tei) {
+ cmGeneratorTarget* te = this->LG->FindGeneratorTargetToUse(*tei);
+ expectedTargets += sep + this->Namespace + te->GetExportName();
+ sep = " ";
+ if (this->ExportedTargets.insert(te).second) {
+ this->Exports.push_back(te);
+ } else {
+ std::ostringstream e;
+ e << "given target \"" << te->GetName() << "\" more than once.";
+ this->LG->GetGlobalGenerator()->GetCMakeInstance()->IssueMessage(
+ cmake::FATAL_ERROR, e.str(),
+ this->LG->GetMakefile()->GetBacktrace());
+ return false;
}
- if (te->GetType() == cmState::INTERFACE_LIBRARY)
- {
- this->GenerateRequiredCMakeVersion(os, "3.0.0");
+ if (te->GetType() == cmState::INTERFACE_LIBRARY) {
+ this->GenerateRequiredCMakeVersion(os, "3.0.0");
}
}
- this->GenerateExpectedTargetsCode(os, expectedTargets);
+ this->GenerateExpectedTargetsCode(os, expectedTargets);
}
std::vector<std::string> missingTargets;
// Create all the imported targets.
- for(std::vector<cmGeneratorTarget*>::const_iterator
- tei = this->Exports.begin();
- tei != this->Exports.end(); ++tei)
- {
+ for (std::vector<cmGeneratorTarget*>::const_iterator tei =
+ this->Exports.begin();
+ tei != this->Exports.end(); ++tei) {
cmGeneratorTarget* gte = *tei;
this->GenerateImportTargetCode(os, gte);
@@ -100,67 +91,56 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os)
this->PopulateInterfaceProperty("INTERFACE_COMPILE_FEATURES", gte,
cmGeneratorExpression::BuildInterface,
properties, missingTargets);
- this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE",
- gte, properties);
+ this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", gte,
+ properties);
const bool newCMP0022Behavior =
- gte->GetPolicyStatusCMP0022() != cmPolicies::WARN
- && gte->GetPolicyStatusCMP0022() != cmPolicies::OLD;
- if (newCMP0022Behavior)
- {
- this->PopulateInterfaceLinkLibrariesProperty(gte,
- cmGeneratorExpression::BuildInterface,
- properties, missingTargets);
- }
+ gte->GetPolicyStatusCMP0022() != cmPolicies::WARN &&
+ gte->GetPolicyStatusCMP0022() != cmPolicies::OLD;
+ if (newCMP0022Behavior) {
+ this->PopulateInterfaceLinkLibrariesProperty(
+ gte, cmGeneratorExpression::BuildInterface, properties,
+ missingTargets);
+ }
this->PopulateCompatibleInterfaceProperties(gte, properties);
this->GenerateInterfaceProperties(gte, os, properties);
- }
+ }
// Generate import file content for each configuration.
- for(std::vector<std::string>::const_iterator
- ci = this->Configurations.begin();
- ci != this->Configurations.end(); ++ci)
- {
+ for (std::vector<std::string>::const_iterator ci =
+ this->Configurations.begin();
+ ci != this->Configurations.end(); ++ci) {
this->GenerateImportConfig(os, *ci, missingTargets);
- }
+ }
this->GenerateMissingTargetsCheckCode(os, missingTargets);
return true;
}
-void
-cmExportBuildFileGenerator
-::GenerateImportTargetsConfig(std::ostream& os,
- const std::string& config,
- std::string const& suffix,
- std::vector<std::string> &missingTargets)
+void cmExportBuildFileGenerator::GenerateImportTargetsConfig(
+ std::ostream& os, const std::string& config, std::string const& suffix,
+ std::vector<std::string>& missingTargets)
{
- for(std::vector<cmGeneratorTarget*>::const_iterator
- tei = this->Exports.begin();
- tei != this->Exports.end(); ++tei)
- {
+ for (std::vector<cmGeneratorTarget*>::const_iterator tei =
+ this->Exports.begin();
+ tei != this->Exports.end(); ++tei) {
// Collect import properties for this target.
cmGeneratorTarget* target = *tei;
ImportPropertyMap properties;
- if (target->GetType() != cmState::INTERFACE_LIBRARY)
- {
+ if (target->GetType() != cmState::INTERFACE_LIBRARY) {
this->SetImportLocationProperty(config, suffix, target, properties);
- }
- if(!properties.empty())
- {
+ }
+ if (!properties.empty()) {
// Get the rest of the target details.
- if (target->GetType() != cmState::INTERFACE_LIBRARY)
- {
- this->SetImportDetailProperties(config, suffix,
- target,
- properties, missingTargets);
+ if (target->GetType() != cmState::INTERFACE_LIBRARY) {
+ this->SetImportDetailProperties(config, suffix, target, properties,
+ missingTargets);
this->SetImportLinkInterface(config, suffix,
cmGeneratorExpression::BuildInterface,
- target,
- properties, missingTargets);
- }
+ target, properties, missingTargets);
+ }
// TOOD: PUBLIC_HEADER_LOCATION
// This should wait until the build feature propagation stuff
@@ -169,179 +149,148 @@ cmExportBuildFileGenerator
// properties);
// Generate code in the export file.
- this->GenerateImportPropertyCode(os, config, target,
- properties);
- }
+ this->GenerateImportPropertyCode(os, config, target, properties);
}
+ }
}
-void cmExportBuildFileGenerator::SetExportSet(cmExportSet *exportSet)
+void cmExportBuildFileGenerator::SetExportSet(cmExportSet* exportSet)
{
this->ExportSet = exportSet;
}
-void
-cmExportBuildFileGenerator
-::SetImportLocationProperty(const std::string& config,
- std::string const& suffix,
- cmGeneratorTarget* target,
- ImportPropertyMap& properties)
+void cmExportBuildFileGenerator::SetImportLocationProperty(
+ const std::string& config, std::string const& suffix,
+ cmGeneratorTarget* target, ImportPropertyMap& properties)
{
// Get the makefile in which to lookup target information.
cmMakefile* mf = target->Makefile;
// Add the main target file.
{
- std::string prop = "IMPORTED_LOCATION";
- prop += suffix;
- std::string value;
- if(target->IsAppBundleOnApple())
- {
- value = target->GetFullPath(config, false);
- }
- else
- {
- value = target->GetFullPath(config, false, true);
+ std::string prop = "IMPORTED_LOCATION";
+ prop += suffix;
+ std::string value;
+ if (target->IsAppBundleOnApple()) {
+ value = target->GetFullPath(config, false);
+ } else {
+ value = target->GetFullPath(config, false, true);
}
- properties[prop] = value;
+ properties[prop] = value;
}
// Add the import library for windows DLLs.
- if(target->IsDLLPlatform() &&
- (target->GetType() == cmState::SHARED_LIBRARY ||
- target->IsExecutableWithExports()) &&
- mf->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX"))
- {
+ if (target->IsDLLPlatform() &&
+ (target->GetType() == cmState::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}");
+ target->GetImplibGNUtoMS(value, value, "${CMAKE_IMPORT_LIBRARY_SUFFIX}");
properties[prop] = value;
- }
+ }
}
-void
-cmExportBuildFileGenerator::HandleMissingTarget(
- std::string& link_libs,
- std::vector<std::string>& missingTargets,
- cmGeneratorTarget* depender,
- cmGeneratorTarget* dependee)
+void cmExportBuildFileGenerator::HandleMissingTarget(
+ std::string& link_libs, std::vector<std::string>& missingTargets,
+ cmGeneratorTarget* depender, cmGeneratorTarget* dependee)
{
// The target is not in the export.
- if(!this->AppendMode)
- {
+ if (!this->AppendMode) {
const std::string name = dependee->GetName();
cmGlobalGenerator* gg =
- dependee->GetLocalGenerator()->GetGlobalGenerator();
+ dependee->GetLocalGenerator()->GetGlobalGenerator();
std::vector<std::string> namespaces = this->FindNamespaces(gg, name);
int targetOccurrences = (int)namespaces.size();
- if (targetOccurrences == 1)
- {
+ if (targetOccurrences == 1) {
std::string missingTarget = namespaces[0];
missingTarget += dependee->GetExportName();
link_libs += missingTarget;
missingTargets.push_back(missingTarget);
return;
- }
- else
- {
+ } else {
// We are not appending, so all exported targets should be
// known here. This is probably user-error.
this->ComplainAboutMissingTarget(depender, dependee, targetOccurrences);
- }
}
+ }
// Assume the target will be exported by another command.
// Append it with the export namespace.
link_libs += this->Namespace;
link_libs += dependee->GetExportName();
}
-void cmExportBuildFileGenerator
-::GetTargets(std::vector<std::string> &targets) const
+void cmExportBuildFileGenerator::GetTargets(
+ std::vector<std::string>& targets) const
{
- if (this->ExportSet)
- {
- for(std::vector<cmTargetExport*>::const_iterator
- tei = this->ExportSet->GetTargetExports()->begin();
- tei != this->ExportSet->GetTargetExports()->end(); ++tei)
- {
+ if (this->ExportSet) {
+ for (std::vector<cmTargetExport*>::const_iterator tei =
+ this->ExportSet->GetTargetExports()->begin();
+ tei != this->ExportSet->GetTargetExports()->end(); ++tei) {
targets.push_back((*tei)->TargetName);
- }
- return;
}
+ return;
+ }
targets = this->Targets;
}
-std::vector<std::string>
-cmExportBuildFileGenerator
-::FindNamespaces(cmGlobalGenerator* gg, const std::string& name)
+std::vector<std::string> cmExportBuildFileGenerator::FindNamespaces(
+ cmGlobalGenerator* gg, const std::string& name)
{
std::vector<std::string> namespaces;
- std::map<std::string, cmExportBuildFileGenerator*>& exportSets
- = gg->GetBuildExportSets();
+ std::map<std::string, cmExportBuildFileGenerator*>& exportSets =
+ gg->GetBuildExportSets();
- for(std::map<std::string, cmExportBuildFileGenerator*>::const_iterator
- expIt = exportSets.begin(); expIt != exportSets.end(); ++expIt)
- {
+ for (std::map<std::string, cmExportBuildFileGenerator*>::const_iterator
+ expIt = exportSets.begin();
+ expIt != exportSets.end(); ++expIt) {
const cmExportBuildFileGenerator* exportSet = expIt->second;
std::vector<std::string> targets;
exportSet->GetTargets(targets);
- if (std::find(targets.begin(), targets.end(), name) != targets.end())
- {
+ if (std::find(targets.begin(), targets.end(), name) != targets.end()) {
namespaces.push_back(exportSet->GetNamespace());
- }
}
+ }
return namespaces;
}
-void
-cmExportBuildFileGenerator
-::ComplainAboutMissingTarget(cmGeneratorTarget* depender,
- cmGeneratorTarget* dependee,
- int occurrences)
+void cmExportBuildFileGenerator::ComplainAboutMissingTarget(
+ cmGeneratorTarget* depender, cmGeneratorTarget* dependee, int occurrences)
{
- if(cmSystemTools::GetErrorOccuredFlag())
- {
+ if (cmSystemTools::GetErrorOccuredFlag()) {
return;
- }
+ }
std::ostringstream e;
e << "export called with target \"" << depender->GetName()
<< "\" which requires target \"" << dependee->GetName() << "\" ";
- if (occurrences == 0)
- {
+ if (occurrences == 0) {
e << "that is not in the export set.\n";
- }
- else
- {
+ } else {
e << "that is not in this export set, but " << occurrences
- << " times in others.\n";
- }
+ << " times in others.\n";
+ }
e << "If the required target is not easy to reference in this call, "
<< "consider using the APPEND option with multiple separate calls.";
- this->LG->GetGlobalGenerator()->GetCMakeInstance()
- ->IssueMessage(cmake::FATAL_ERROR, e.str(),
- this->LG->GetMakefile()->GetBacktrace());
+ this->LG->GetGlobalGenerator()->GetCMakeInstance()->IssueMessage(
+ cmake::FATAL_ERROR, e.str(), this->LG->GetMakefile()->GetBacktrace());
}
-std::string
-cmExportBuildFileGenerator::InstallNameDir(cmGeneratorTarget* target,
- const std::string& config)
+std::string cmExportBuildFileGenerator::InstallNameDir(
+ cmGeneratorTarget* target, const std::string& config)
{
std::string install_name_dir;
cmMakefile* mf = target->Target->GetMakefile();
- if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
- {
- install_name_dir =
- target->GetInstallNameDirForBuildTree(config);
- }
+ if (mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) {
+ install_name_dir = target->GetInstallNameDirForBuildTree(config);
+ }
return install_name_dir;
}
diff --git a/Source/cmExportBuildFileGenerator.h b/Source/cmExportBuildFileGenerator.h
index 85aae2f..be3c70a 100644
--- a/Source/cmExportBuildFileGenerator.h
+++ b/Source/cmExportBuildFileGenerator.h
@@ -26,18 +26,21 @@ class cmExportSet;
*
* This is used to implement the EXPORT() command.
*/
-class cmExportBuildFileGenerator: public cmExportFileGenerator
+class cmExportBuildFileGenerator : public cmExportFileGenerator
{
public:
cmExportBuildFileGenerator();
/** Set the list of targets to export. */
void SetTargets(std::vector<std::string> const& targets)
- { this->Targets = targets; }
- void GetTargets(std::vector<std::string> &targets) const;
+ {
+ this->Targets = targets;
+ }
+ void GetTargets(std::vector<std::string>& targets) const;
void AppendTargets(std::vector<std::string> const& targets)
- { this->Targets.insert(this->Targets.end(),
- targets.begin(), targets.end()); }
+ {
+ this->Targets.insert(this->Targets.end(), targets.begin(), targets.end());
+ }
void SetExportSet(cmExportSet*);
/** Set whether to append generated code to the output file. */
@@ -48,10 +51,9 @@ public:
protected:
// Implement virtual methods from the superclass.
virtual bool GenerateMainFile(std::ostream& os);
- virtual void GenerateImportTargetsConfig(std::ostream& os,
- const std::string& config,
- std::string const& suffix,
- std::vector<std::string> &missingTargets);
+ virtual void GenerateImportTargetsConfig(
+ std::ostream& os, const std::string& config, std::string const& suffix,
+ std::vector<std::string>& missingTargets);
virtual void HandleMissingTarget(std::string& link_libs,
std::vector<std::string>& missingTargets,
cmGeneratorTarget* depender,
@@ -70,11 +72,11 @@ protected:
std::string InstallNameDir(cmGeneratorTarget* target,
const std::string& config);
- std::vector<std::string>
- FindNamespaces(cmGlobalGenerator* gg, const std::string& name);
+ std::vector<std::string> FindNamespaces(cmGlobalGenerator* gg,
+ const std::string& name);
std::vector<std::string> Targets;
- cmExportSet *ExportSet;
+ cmExportSet* ExportSet;
std::vector<cmGeneratorTarget*> Exports;
cmLocalGenerator* LG;
};
diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx
index ee8865e..a0e7e45 100644
--- a/Source/cmExportCommand.cxx
+++ b/Source/cmExportCommand.cxx
@@ -26,226 +26,184 @@
#endif
cmExportCommand::cmExportCommand()
-:cmCommand()
-,ArgumentGroup()
-,Targets(&Helper, "TARGETS")
-,Append(&Helper, "APPEND", &ArgumentGroup)
-,ExportSetName(&Helper, "EXPORT", &ArgumentGroup)
-,Namespace(&Helper, "NAMESPACE", &ArgumentGroup)
-,Filename(&Helper, "FILE", &ArgumentGroup)
-,ExportOld(&Helper, "EXPORT_LINK_INTERFACE_LIBRARIES", &ArgumentGroup)
+ : cmCommand()
+ , ArgumentGroup()
+ , Targets(&Helper, "TARGETS")
+ , Append(&Helper, "APPEND", &ArgumentGroup)
+ , ExportSetName(&Helper, "EXPORT", &ArgumentGroup)
+ , Namespace(&Helper, "NAMESPACE", &ArgumentGroup)
+ , Filename(&Helper, "FILE", &ArgumentGroup)
+ , ExportOld(&Helper, "EXPORT_LINK_INTERFACE_LIBRARIES", &ArgumentGroup)
{
this->ExportSet = 0;
}
-
// cmExportCommand
-bool cmExportCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmExportCommand::InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus&)
{
- if(args.size() < 2 )
- {
+ if (args.size() < 2) {
this->SetError("called with too few arguments");
return false;
- }
+ }
- if(args[0] == "PACKAGE")
- {
+ if (args[0] == "PACKAGE") {
return this->HandlePackage(args);
- }
- else if (args[0] == "EXPORT")
- {
+ } else if (args[0] == "EXPORT") {
this->ExportSetName.Follows(0);
this->ArgumentGroup.Follows(&this->ExportSetName);
- }
- else
- {
+ } else {
this->Targets.Follows(0);
this->ArgumentGroup.Follows(&this->Targets);
- }
+ }
std::vector<std::string> unknownArgs;
this->Helper.Parse(&args, &unknownArgs);
- if (!unknownArgs.empty())
- {
+ if (!unknownArgs.empty()) {
this->SetError("Unknown arguments.");
return false;
- }
+ }
std::string fname;
- if(!this->Filename.WasFound())
- {
- if (args[0] != "EXPORT")
- {
+ if (!this->Filename.WasFound()) {
+ if (args[0] != "EXPORT") {
this->SetError("FILE <filename> option missing.");
return false;
- }
- fname = this->ExportSetName.GetString() + ".cmake";
}
- else
- {
+ fname = this->ExportSetName.GetString() + ".cmake";
+ } else {
// Make sure the file has a .cmake extension.
- if(cmSystemTools::GetFilenameLastExtension(this->Filename.GetCString())
- != ".cmake")
- {
+ if (cmSystemTools::GetFilenameLastExtension(this->Filename.GetCString()) !=
+ ".cmake") {
std::ostringstream e;
e << "FILE option given filename \"" << this->Filename.GetString()
<< "\" which does not have an extension of \".cmake\".\n";
this->SetError(e.str());
return false;
- }
- fname = this->Filename.GetString();
}
+ fname = this->Filename.GetString();
+ }
// Get the file to write.
- if(cmSystemTools::FileIsFullPath(fname.c_str()))
- {
- if(!this->Makefile->CanIWriteThisFile(fname.c_str()))
- {
+ if (cmSystemTools::FileIsFullPath(fname.c_str())) {
+ if (!this->Makefile->CanIWriteThisFile(fname.c_str())) {
std::ostringstream e;
e << "FILE option given filename \"" << fname
<< "\" which is in the source tree.\n";
this->SetError(e.str());
return false;
- }
}
- else
- {
+ } else {
// Interpret relative paths with respect to the current build dir.
std::string dir = this->Makefile->GetCurrentBinaryDirectory();
fname = dir + "/" + fname;
- }
+ }
std::vector<std::string> targets;
- cmGlobalGenerator *gg = this->Makefile->GetGlobalGenerator();
+ cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator();
- if(args[0] == "EXPORT")
- {
- if (this->Append.IsEnabled())
- {
+ if (args[0] == "EXPORT") {
+ if (this->Append.IsEnabled()) {
std::ostringstream e;
e << "EXPORT signature does not recognise the APPEND option.";
this->SetError(e.str());
return false;
- }
+ }
- if (this->ExportOld.IsEnabled())
- {
+ if (this->ExportOld.IsEnabled()) {
std::ostringstream e;
e << "EXPORT signature does not recognise the "
- "EXPORT_LINK_INTERFACE_LIBRARIES option.";
+ "EXPORT_LINK_INTERFACE_LIBRARIES option.";
this->SetError(e.str());
return false;
- }
+ }
- cmExportSetMap &setMap = gg->GetExportSets();
+ cmExportSetMap& setMap = gg->GetExportSets();
std::string setName = this->ExportSetName.GetString();
- if (setMap.find(setName) == setMap.end())
- {
+ if (setMap.find(setName) == setMap.end()) {
std::ostringstream e;
e << "Export set \"" << setName << "\" not found.";
this->SetError(e.str());
return false;
- }
- this->ExportSet = setMap[setName];
}
- else if (this->Targets.WasFound())
- {
- for(std::vector<std::string>::const_iterator
- currentTarget = this->Targets.GetVector().begin();
- currentTarget != this->Targets.GetVector().end();
- ++currentTarget)
- {
- if (this->Makefile->IsAlias(*currentTarget))
- {
+ this->ExportSet = setMap[setName];
+ } else if (this->Targets.WasFound()) {
+ for (std::vector<std::string>::const_iterator currentTarget =
+ this->Targets.GetVector().begin();
+ currentTarget != this->Targets.GetVector().end(); ++currentTarget) {
+ if (this->Makefile->IsAlias(*currentTarget)) {
std::ostringstream e;
e << "given ALIAS target \"" << *currentTarget
<< "\" which may not be exported.";
this->SetError(e.str());
return false;
- }
+ }
- if(cmTarget* target = gg->FindTarget(*currentTarget))
- {
- if(target->GetType() == cmState::OBJECT_LIBRARY)
- {
+ if (cmTarget* target = gg->FindTarget(*currentTarget)) {
+ if (target->GetType() == cmState::OBJECT_LIBRARY) {
std::ostringstream e;
e << "given OBJECT library \"" << *currentTarget
<< "\" which may not be exported.";
this->SetError(e.str());
return false;
- }
- if (target->GetType() == cmState::UTILITY)
- {
- this->SetError("given custom target \"" + *currentTarget
- + "\" which may not be exported.");
+ }
+ if (target->GetType() == cmState::UTILITY) {
+ this->SetError("given custom target \"" + *currentTarget +
+ "\" which may not be exported.");
return false;
- }
}
- else
- {
+ } else {
std::ostringstream e;
e << "given target \"" << *currentTarget
<< "\" which is not built by this project.";
this->SetError(e.str());
return false;
- }
- targets.push_back(*currentTarget);
}
- if (this->Append.IsEnabled())
- {
- if (cmExportBuildFileGenerator *ebfg = gg->GetExportedTargetsFile(fname))
- {
+ targets.push_back(*currentTarget);
+ }
+ if (this->Append.IsEnabled()) {
+ if (cmExportBuildFileGenerator* ebfg =
+ gg->GetExportedTargetsFile(fname)) {
ebfg->AppendTargets(targets);
return true;
- }
}
}
- else
- {
+ } else {
this->SetError("EXPORT or TARGETS specifier missing.");
return false;
- }
+ }
// Setup export file generation.
- cmExportBuildFileGenerator *ebfg = new cmExportBuildFileGenerator;
+ cmExportBuildFileGenerator* ebfg = new cmExportBuildFileGenerator;
ebfg->SetExportFile(fname.c_str());
ebfg->SetNamespace(this->Namespace.GetCString());
ebfg->SetAppendMode(this->Append.IsEnabled());
- if (this->ExportSet)
- {
+ if (this->ExportSet) {
ebfg->SetExportSet(this->ExportSet);
- }
- else
- {
+ } else {
ebfg->SetTargets(targets);
- }
+ }
this->Makefile->AddExportBuildFileGenerator(ebfg);
ebfg->SetExportOld(this->ExportOld.IsEnabled());
// Compute the set of configurations exported.
std::vector<std::string> configurationTypes;
this->Makefile->GetConfigurations(configurationTypes);
- if(configurationTypes.empty())
- {
+ if (configurationTypes.empty()) {
configurationTypes.push_back("");
- }
- for(std::vector<std::string>::const_iterator
- ci = configurationTypes.begin();
- ci != configurationTypes.end(); ++ci)
- {
+ }
+ for (std::vector<std::string>::const_iterator ci =
+ configurationTypes.begin();
+ ci != configurationTypes.end(); ++ci) {
ebfg->AddConfiguration(*ci);
- }
- if (this->ExportSet)
- {
+ }
+ if (this->ExportSet) {
gg->AddBuildExportExportSet(ebfg);
- }
- else
- {
+ } else {
gg->AddBuildExportSet(ebfg);
- }
+ }
return true;
}
@@ -253,48 +211,45 @@ bool cmExportCommand
bool cmExportCommand::HandlePackage(std::vector<std::string> const& args)
{
// Parse PACKAGE mode arguments.
- enum Doing { DoingNone, DoingPackage };
+ enum Doing
+ {
+ DoingNone,
+ DoingPackage
+ };
Doing doing = DoingPackage;
std::string package;
- for(unsigned int i=1; i < args.size(); ++i)
- {
- if(doing == DoingPackage)
- {
+ for (unsigned int i = 1; i < args.size(); ++i) {
+ if (doing == DoingPackage) {
package = args[i];
doing = DoingNone;
- }
- else
- {
+ } else {
std::ostringstream e;
e << "PACKAGE given unknown argument: " << args[i];
this->SetError(e.str());
return false;
- }
}
+ }
// Verify the package name.
- if(package.empty())
- {
+ if (package.empty()) {
this->SetError("PACKAGE must be given a package name.");
return false;
- }
+ }
const char* packageExpr = "^[A-Za-z0-9_.-]+$";
cmsys::RegularExpression packageRegex(packageExpr);
- if(!packageRegex.find(package.c_str()))
- {
+ if (!packageRegex.find(package.c_str())) {
std::ostringstream e;
e << "PACKAGE given invalid package name \"" << package << "\". "
<< "Package names must match \"" << packageExpr << "\".";
this->SetError(e.str());
return false;
- }
+ }
// If the CMAKE_EXPORT_NO_PACKAGE_REGISTRY variable is set the command
// export(PACKAGE) does nothing.
- if(this->Makefile->IsOn("CMAKE_EXPORT_NO_PACKAGE_REGISTRY"))
- {
+ if (this->Makefile->IsOn("CMAKE_EXPORT_NO_PACKAGE_REGISTRY")) {
return true;
- }
+ }
// We store the current build directory in the registry as a value
// named by a hash of its own content. This is deterministic and is
@@ -311,24 +266,21 @@ bool cmExportCommand::HandlePackage(std::vector<std::string> const& args)
}
#if defined(_WIN32) && !defined(__CYGWIN__)
-# include <windows.h>
-# undef GetCurrentDirectory
+#include <windows.h>
+#undef GetCurrentDirectory
void cmExportCommand::ReportRegistryError(std::string const& msg,
- std::string const& key,
- long err)
+ std::string const& key, long err)
{
std::ostringstream e;
e << msg << "\n"
<< " HKEY_CURRENT_USER\\" << key << "\n";
wchar_t winmsg[1024];
- if(FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS, 0, err,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- winmsg, 1024, 0) > 0)
- {
+ if (FormatMessageW(
+ FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 0, err,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), winmsg, 1024, 0) > 0) {
e << "Windows reported:\n"
<< " " << cmsys::Encoding::ToNarrow(winmsg);
- }
+ }
this->Makefile->IssueMessage(cmake::WARNING, e.str());
}
@@ -339,29 +291,26 @@ void cmExportCommand::StorePackageRegistryWin(std::string const& package,
std::string key = "Software\\Kitware\\CMake\\Packages\\";
key += package;
HKEY hKey;
- LONG err = RegCreateKeyExW(HKEY_CURRENT_USER,
- cmsys::Encoding::ToWide(key).c_str(),
- 0, 0, REG_OPTION_NON_VOLATILE,
- KEY_SET_VALUE, 0, &hKey, 0);
- if(err != ERROR_SUCCESS)
- {
- this->ReportRegistryError(
- "Cannot create/open registry key", key, err);
+ LONG err =
+ RegCreateKeyExW(HKEY_CURRENT_USER, cmsys::Encoding::ToWide(key).c_str(), 0,
+ 0, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, 0, &hKey, 0);
+ if (err != ERROR_SUCCESS) {
+ this->ReportRegistryError("Cannot create/open registry key", key, err);
return;
- }
+ }
std::wstring wcontent = cmsys::Encoding::ToWide(content);
- err = RegSetValueExW(hKey, cmsys::Encoding::ToWide(hash).c_str(),
- 0, REG_SZ, (BYTE const*)wcontent.c_str(),
- static_cast<DWORD>(wcontent.size()+1)*sizeof(wchar_t));
+ err =
+ RegSetValueExW(hKey, cmsys::Encoding::ToWide(hash).c_str(), 0, REG_SZ,
+ (BYTE const*)wcontent.c_str(),
+ static_cast<DWORD>(wcontent.size() + 1) * sizeof(wchar_t));
RegCloseKey(hKey);
- if(err != ERROR_SUCCESS)
- {
+ if (err != ERROR_SUCCESS) {
std::ostringstream msg;
msg << "Cannot set registry value \"" << hash << "\" under key";
this->ReportRegistryError(msg.str(), key, err);
return;
- }
+ }
}
#else
void cmExportCommand::StorePackageRegistryDir(std::string const& package,
@@ -371,19 +320,17 @@ void cmExportCommand::StorePackageRegistryDir(std::string const& package,
#if defined(__HAIKU__)
char dir[B_PATH_NAME_LENGTH];
if (find_directory(B_USER_SETTINGS_DIRECTORY, -1, false, dir, sizeof(dir)) !=
- B_OK)
- {
+ B_OK) {
return;
- }
+ }
std::string fname = dir;
fname += "/cmake/packages/";
fname += package;
#else
const char* home = cmSystemTools::GetEnv("HOME");
- if(!home)
- {
+ if (!home) {
return;
- }
+ }
std::string fname = home;
cmSystemTools::ConvertToUnixSlashes(fname);
fname += "/.cmake/packages/";
@@ -392,15 +339,11 @@ void cmExportCommand::StorePackageRegistryDir(std::string const& package,
cmSystemTools::MakeDirectory(fname.c_str());
fname += "/";
fname += hash;
- if(!cmSystemTools::FileExists(fname.c_str()))
- {
+ if (!cmSystemTools::FileExists(fname.c_str())) {
cmGeneratedFileStream entry(fname.c_str(), true);
- if(entry)
- {
+ if (entry) {
entry << content << "\n";
- }
- else
- {
+ } else {
std::ostringstream e;
/* clang-format off */
e << "Cannot create package registry file:\n"
@@ -408,7 +351,7 @@ void cmExportCommand::StorePackageRegistryDir(std::string const& package,
<< cmSystemTools::GetLastSystemError() << "\n";
/* clang-format on */
this->Makefile->IssueMessage(cmake::WARNING, e.str());
- }
}
+ }
}
#endif
diff --git a/Source/cmExportCommand.h b/Source/cmExportCommand.h
index f9506bb..a71393a 100644
--- a/Source/cmExportCommand.h
+++ b/Source/cmExportCommand.h
@@ -30,22 +30,19 @@ public:
/**
* This is a virtual constructor for the command.
*/
- virtual cmCommand* Clone()
- {
- return new cmExportCommand;
- }
+ virtual cmCommand* Clone() { return new cmExportCommand; }
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus &status);
+ cmExecutionStatus& status);
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual std::string GetName() const { return "export";}
+ virtual std::string GetName() const { return "export"; }
cmTypeMacro(cmExportCommand, cmCommand);
@@ -58,19 +55,18 @@ private:
cmCAString Filename;
cmCAEnabler ExportOld;
- cmExportSet *ExportSet;
+ cmExportSet* ExportSet;
friend class cmExportBuildFileGenerator;
std::string ErrorMessage;
bool HandlePackage(std::vector<std::string> const& args);
- void StorePackageRegistryWin(std::string const& package,
- const char* content, const char* hash);
- void StorePackageRegistryDir(std::string const& package,
- const char* content, const char* hash);
+ void StorePackageRegistryWin(std::string const& package, const char* content,
+ const char* hash);
+ void StorePackageRegistryDir(std::string const& package, const char* content,
+ const char* hash);
void ReportRegistryError(std::string const& msg, std::string const& key,
long err);
};
-
#endif
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index 5aa466d..2d645da 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -33,11 +33,9 @@ static std::string cmExportFileGeneratorEscape(std::string const& str)
// Escape a property value for writing into a .cmake file.
std::string result = cmOutputConverter::EscapeForCMake(str);
// Un-escape variable references generated by our own export code.
- cmSystemTools::ReplaceString(result,
- "\\${_IMPORT_PREFIX}",
+ cmSystemTools::ReplaceString(result, "\\${_IMPORT_PREFIX}",
"${_IMPORT_PREFIX}");
- cmSystemTools::ReplaceString(result,
- "\\${CMAKE_IMPORT_LIBRARY_SUFFIX}",
+ cmSystemTools::ReplaceString(result, "\\${CMAKE_IMPORT_LIBRARY_SUFFIX}",
"${CMAKE_IMPORT_LIBRARY_SUFFIX}");
return result;
}
@@ -56,8 +54,7 @@ void cmExportFileGenerator::AddConfiguration(const std::string& config)
void cmExportFileGenerator::SetExportFile(const char* mainFile)
{
this->MainImportFile = mainFile;
- this->FileDir =
- cmSystemTools::GetFilenamePath(this->MainImportFile);
+ this->FileDir = cmSystemTools::GetFilenamePath(this->MainImportFile);
this->FileBase =
cmSystemTools::GetFilenameWithoutLastExtension(this->MainImportFile);
this->FileExt =
@@ -73,30 +70,25 @@ bool cmExportFileGenerator::GenerateImportFile()
{
// Open the output file to generate it.
cmsys::auto_ptr<cmsys::ofstream> foutPtr;
- if(this->AppendMode)
- {
+ if (this->AppendMode) {
// Open for append.
- cmsys::auto_ptr<cmsys::ofstream>
- ap(new cmsys::ofstream(this->MainImportFile.c_str(), std::ios::app));
+ cmsys::auto_ptr<cmsys::ofstream> ap(
+ new cmsys::ofstream(this->MainImportFile.c_str(), std::ios::app));
foutPtr = ap;
- }
- else
- {
+ } else {
// Generate atomically and with copy-if-different.
- cmsys::auto_ptr<cmGeneratedFileStream>
- ap(new cmGeneratedFileStream(this->MainImportFile.c_str(), true));
+ cmsys::auto_ptr<cmGeneratedFileStream> ap(
+ new cmGeneratedFileStream(this->MainImportFile.c_str(), true));
ap->SetCopyIfDifferent(true);
foutPtr = ap;
- }
- if(!foutPtr.get() || !*foutPtr)
- {
+ }
+ if (!foutPtr.get() || !*foutPtr) {
std::string se = cmSystemTools::GetLastSystemError();
std::ostringstream e;
- e << "cannot write to file \"" << this->MainImportFile
- << "\": " << se;
+ e << "cannot write to file \"" << this->MainImportFile << "\": " << se;
cmSystemTools::Error(e.str().c_str());
return false;
- }
+ }
std::ostream& os = *foutPtr;
// Protect that file against use with older CMake versions.
@@ -129,68 +121,58 @@ bool cmExportFileGenerator::GenerateImportFile()
return result;
}
-void cmExportFileGenerator::GenerateImportConfig(std::ostream& os,
- const std::string& config,
- std::vector<std::string> &missingTargets)
+void cmExportFileGenerator::GenerateImportConfig(
+ std::ostream& os, const std::string& config,
+ std::vector<std::string>& missingTargets)
{
// Construct the property configuration suffix.
std::string suffix = "_";
- if(!config.empty())
- {
+ if (!config.empty()) {
suffix += cmSystemTools::UpperCase(config);
- }
- else
- {
+ } else {
suffix += "NOCONFIG";
- }
+ }
// Generate the per-config target information.
this->GenerateImportTargetsConfig(os, config, suffix, missingTargets);
}
void cmExportFileGenerator::PopulateInterfaceProperty(
- const std::string& propName,
- cmGeneratorTarget *target,
- ImportPropertyMap &properties)
+ const std::string& propName, cmGeneratorTarget* target,
+ ImportPropertyMap& properties)
{
- const char *input = target->GetProperty(propName);
- if (input)
- {
+ const char* input = target->GetProperty(propName);
+ if (input) {
properties[propName] = input;
- }
+ }
}
void cmExportFileGenerator::PopulateInterfaceProperty(
- const std::string& propName,
- const std::string& outputName,
- cmGeneratorTarget *target,
- cmGeneratorExpression::PreprocessContext preprocessRule,
- ImportPropertyMap &properties,
- std::vector<std::string> &missingTargets)
+ const std::string& propName, const std::string& outputName,
+ cmGeneratorTarget* target,
+ cmGeneratorExpression::PreprocessContext preprocessRule,
+ ImportPropertyMap& properties, std::vector<std::string>& missingTargets)
{
- const char *input = target->GetProperty(propName);
- if (input)
- {
- if (!*input)
- {
+ const char* input = target->GetProperty(propName);
+ if (input) {
+ if (!*input) {
// Set to empty
properties[outputName] = "";
return;
- }
+ }
- std::string prepro = cmGeneratorExpression::Preprocess(input,
- preprocessRule);
- if (!prepro.empty())
- {
+ std::string prepro =
+ cmGeneratorExpression::Preprocess(input, preprocessRule);
+ if (!prepro.empty()) {
this->ResolveTargetsInGeneratorExpressions(prepro, target,
missingTargets);
properties[outputName] = prepro;
- }
}
+ }
}
-void cmExportFileGenerator::GenerateRequiredCMakeVersion(std::ostream& os,
- const char *versionString)
+void cmExportFileGenerator::GenerateRequiredCMakeVersion(
+ std::ostream& os, const char* versionString)
{
/* clang-format off */
os << "if(CMAKE_VERSION VERSION_LESS " << versionString << ")\n"
@@ -201,29 +183,24 @@ void cmExportFileGenerator::GenerateRequiredCMakeVersion(std::ostream& os,
}
bool cmExportFileGenerator::PopulateInterfaceLinkLibrariesProperty(
- cmGeneratorTarget *target,
- cmGeneratorExpression::PreprocessContext preprocessRule,
- ImportPropertyMap &properties,
- std::vector<std::string> &missingTargets)
+ cmGeneratorTarget* target,
+ cmGeneratorExpression::PreprocessContext preprocessRule,
+ ImportPropertyMap& properties, std::vector<std::string>& missingTargets)
{
- if(!target->IsLinkable())
- {
+ if (!target->IsLinkable()) {
return false;
- }
- const char *input = target->GetProperty("INTERFACE_LINK_LIBRARIES");
- if (input)
- {
- std::string prepro = cmGeneratorExpression::Preprocess(input,
- preprocessRule);
- if (!prepro.empty())
- {
- this->ResolveTargetsInGeneratorExpressions(prepro, target,
- missingTargets,
- ReplaceFreeTargets);
+ }
+ const char* input = target->GetProperty("INTERFACE_LINK_LIBRARIES");
+ if (input) {
+ std::string prepro =
+ cmGeneratorExpression::Preprocess(input, preprocessRule);
+ if (!prepro.empty()) {
+ this->ResolveTargetsInGeneratorExpressions(
+ prepro, target, missingTargets, ReplaceFreeTargets);
properties["INTERFACE_LINK_LIBRARIES"] = prepro;
return true;
- }
}
+ }
return false;
}
@@ -233,15 +210,14 @@ static bool isSubDirectory(const char* a, const char* b)
cmSystemTools::IsSubDirectory(a, b));
}
-static bool checkInterfaceDirs(const std::string &prepro,
- cmGeneratorTarget *target, const std::string& prop)
+static bool checkInterfaceDirs(const std::string& prepro,
+ cmGeneratorTarget* target,
+ const std::string& prop)
{
const char* installDir =
- target->Makefile->GetSafeDefinition("CMAKE_INSTALL_PREFIX");
- const char* topSourceDir =
- target->GetLocalGenerator()->GetSourceDirectory();
- const char* topBinaryDir =
- target->GetLocalGenerator()->GetBinaryDirectory();
+ target->Makefile->GetSafeDefinition("CMAKE_INSTALL_PREFIX");
+ const char* topSourceDir = target->GetLocalGenerator()->GetSourceDirectory();
+ const char* topBinaryDir = target->GetLocalGenerator()->GetBinaryDirectory();
std::vector<std::string> parts;
cmGeneratorExpression::Split(prepro, parts);
@@ -250,22 +226,17 @@ static bool checkInterfaceDirs(const std::string &prepro,
bool hadFatalError = false;
- for(std::vector<std::string>::iterator li = parts.begin();
- li != parts.end(); ++li)
- {
+ for (std::vector<std::string>::iterator li = parts.begin();
+ li != parts.end(); ++li) {
size_t genexPos = cmGeneratorExpression::Find(*li);
- if (genexPos == 0)
- {
+ if (genexPos == 0) {
continue;
- }
+ }
cmake::MessageType messageType = cmake::FATAL_ERROR;
std::ostringstream e;
- if (genexPos != std::string::npos)
- {
- if (prop == "INTERFACE_INCLUDE_DIRECTORIES")
- {
- switch (target->GetPolicyStatusCMP0041())
- {
+ if (genexPos != std::string::npos) {
+ if (prop == "INTERFACE_INCLUDE_DIRECTORIES") {
+ switch (target->GetPolicyStatusCMP0041()) {
case cmPolicies::WARN:
messageType = cmake::WARNING;
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0041) << "\n";
@@ -277,30 +248,25 @@ static bool checkInterfaceDirs(const std::string &prepro,
case cmPolicies::NEW:
hadFatalError = true;
break; // Issue fatal message.
- }
}
- else
- {
+ } else {
hadFatalError = true;
- }
}
- if (cmHasLiteralPrefix(li->c_str(), "${_IMPORT_PREFIX}"))
- {
+ }
+ if (cmHasLiteralPrefix(li->c_str(), "${_IMPORT_PREFIX}")) {
continue;
- }
- if (!cmSystemTools::FileIsFullPath(li->c_str()))
- {
+ }
+ if (!cmSystemTools::FileIsFullPath(li->c_str())) {
/* clang-format off */
e << "Target \"" << target->GetName() << "\" " << prop <<
" property contains relative path:\n"
" \"" << *li << "\"";
/* clang-format on */
target->GetLocalGenerator()->IssueMessage(messageType, e.str());
- }
+ }
bool inBinary = isSubDirectory(li->c_str(), topBinaryDir);
bool inSource = isSubDirectory(li->c_str(), topSourceDir);
- if (isSubDirectory(li->c_str(), installDir))
- {
+ if (isSubDirectory(li->c_str(), installDir)) {
// The include directory is inside the install tree. If the
// install tree is not inside the source tree or build tree then
// fall through to the checks below that the include directory is not
@@ -309,26 +275,25 @@ static bool checkInterfaceDirs(const std::string &prepro,
(!inBinary || isSubDirectory(installDir, topBinaryDir)) &&
(!inSource || isSubDirectory(installDir, topSourceDir));
- if (prop == "INTERFACE_INCLUDE_DIRECTORIES")
- {
- if (!shouldContinue)
- {
- switch(target->GetPolicyStatusCMP0052())
- {
- case cmPolicies::WARN:
- {
+ if (prop == "INTERFACE_INCLUDE_DIRECTORIES") {
+ if (!shouldContinue) {
+ switch (target->GetPolicyStatusCMP0052()) {
+ case cmPolicies::WARN: {
std::ostringstream s;
s << cmPolicies::GetPolicyWarning(cmPolicies::CMP0052) << "\n";
- s << "Directory:\n \"" << *li << "\"\nin "
- "INTERFACE_INCLUDE_DIRECTORIES of target \""
+ s << "Directory:\n \"" << *li
+ << "\"\nin "
+ "INTERFACE_INCLUDE_DIRECTORIES of target \""
<< target->GetName() << "\" is a subdirectory of the install "
- "directory:\n \"" << installDir << "\"\nhowever it is also "
- "a subdirectory of the " << (inBinary ? "build" : "source")
- << " tree:\n \"" << (inBinary ? topBinaryDir : topSourceDir)
- << "\"" << std::endl;
+ "directory:\n \""
+ << installDir << "\"\nhowever it is also "
+ "a subdirectory of the "
+ << (inBinary ? "build" : "source") << " tree:\n \""
+ << (inBinary ? topBinaryDir : topSourceDir) << "\""
+ << std::endl;
target->GetLocalGenerator()->IssueMessage(cmake::AUTHOR_WARNING,
- s.str());
- }
+ s.str());
+ }
case cmPolicies::OLD:
shouldContinue = true;
break;
@@ -336,242 +301,207 @@ static bool checkInterfaceDirs(const std::string &prepro,
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::NEW:
break;
- }
}
}
- if (shouldContinue)
- {
+ }
+ if (shouldContinue) {
continue;
- }
}
- if (inBinary)
- {
+ }
+ if (inBinary) {
/* clang-format off */
e << "Target \"" << target->GetName() << "\" " << prop <<
" property contains path:\n"
" \"" << *li << "\"\nwhich is prefixed in the build directory.";
/* clang-format on */
target->GetLocalGenerator()->IssueMessage(messageType, e.str());
- }
- if (!inSourceBuild)
- {
- if (inSource)
- {
- e << "Target \"" << target->GetName() << "\" " << prop <<
- " property contains path:\n"
- " \"" << *li << "\"\nwhich is prefixed in the source directory.";
+ }
+ if (!inSourceBuild) {
+ if (inSource) {
+ e << "Target \"" << target->GetName() << "\" " << prop
+ << " property contains path:\n"
+ " \""
+ << *li << "\"\nwhich is prefixed in the source directory.";
target->GetLocalGenerator()->IssueMessage(messageType, e.str());
- }
}
}
+ }
return !hadFatalError;
}
-static void prefixItems(std::string &exportDirs)
+static void prefixItems(std::string& exportDirs)
{
std::vector<std::string> entries;
cmGeneratorExpression::Split(exportDirs, entries);
exportDirs = "";
- const char *sep = "";
- for(std::vector<std::string>::const_iterator ei = entries.begin();
- ei != entries.end(); ++ei)
- {
+ const char* sep = "";
+ for (std::vector<std::string>::const_iterator ei = entries.begin();
+ ei != entries.end(); ++ei) {
exportDirs += sep;
sep = ";";
- if (!cmSystemTools::FileIsFullPath(ei->c_str())
- && ei->find("${_IMPORT_PREFIX}") == std::string::npos)
- {
+ if (!cmSystemTools::FileIsFullPath(ei->c_str()) &&
+ ei->find("${_IMPORT_PREFIX}") == std::string::npos) {
exportDirs += "${_IMPORT_PREFIX}/";
- }
- exportDirs += *ei;
}
+ exportDirs += *ei;
+ }
}
void cmExportFileGenerator::PopulateSourcesInterface(
- cmTargetExport *tei,
- cmGeneratorExpression::PreprocessContext preprocessRule,
- ImportPropertyMap &properties,
- std::vector<std::string> &missingTargets)
+ cmTargetExport* tei, cmGeneratorExpression::PreprocessContext preprocessRule,
+ ImportPropertyMap& properties, std::vector<std::string>& missingTargets)
{
cmGeneratorTarget* gt = tei->Target;
assert(preprocessRule == cmGeneratorExpression::InstallInterface);
- const char *propName = "INTERFACE_SOURCES";
- const char *input = gt->GetProperty(propName);
+ const char* propName = "INTERFACE_SOURCES";
+ const char* input = gt->GetProperty(propName);
- if (!input)
- {
+ if (!input) {
return;
- }
+ }
- if (!*input)
- {
+ if (!*input) {
properties[propName] = "";
return;
- }
+ }
- std::string prepro = cmGeneratorExpression::Preprocess(input,
- preprocessRule,
- true);
- if (!prepro.empty())
- {
- this->ResolveTargetsInGeneratorExpressions(prepro, gt,
- missingTargets);
+ std::string prepro =
+ cmGeneratorExpression::Preprocess(input, preprocessRule, true);
+ if (!prepro.empty()) {
+ this->ResolveTargetsInGeneratorExpressions(prepro, gt, missingTargets);
- if (!checkInterfaceDirs(prepro, gt, propName))
- {
+ if (!checkInterfaceDirs(prepro, gt, propName)) {
return;
- }
- properties[propName] = prepro;
}
+ properties[propName] = prepro;
+ }
}
void cmExportFileGenerator::PopulateIncludeDirectoriesInterface(
- cmTargetExport *tei,
- cmGeneratorExpression::PreprocessContext preprocessRule,
- ImportPropertyMap &properties,
- std::vector<std::string> &missingTargets)
+ cmTargetExport* tei, cmGeneratorExpression::PreprocessContext preprocessRule,
+ ImportPropertyMap& properties, std::vector<std::string>& missingTargets)
{
- cmGeneratorTarget *target = tei->Target;
+ cmGeneratorTarget* target = tei->Target;
assert(preprocessRule == cmGeneratorExpression::InstallInterface);
- const char *propName = "INTERFACE_INCLUDE_DIRECTORIES";
- const char *input = target->GetProperty(propName);
+ const char* propName = "INTERFACE_INCLUDE_DIRECTORIES";
+ const char* input = target->GetProperty(propName);
cmGeneratorExpression ge;
std::string dirs = cmGeneratorExpression::Preprocess(
- tei->InterfaceIncludeDirectories,
- preprocessRule,
- true);
+ tei->InterfaceIncludeDirectories, preprocessRule, true);
this->ReplaceInstallPrefix(dirs);
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(dirs);
- std::string exportDirs = cge->Evaluate(target->GetLocalGenerator(), "",
- false, target);
+ std::string exportDirs =
+ cge->Evaluate(target->GetLocalGenerator(), "", false, target);
- if (cge->GetHadContextSensitiveCondition())
- {
+ if (cge->GetHadContextSensitiveCondition()) {
cmLocalGenerator* lg = target->GetLocalGenerator();
std::ostringstream e;
- e << "Target \"" << target->GetName() << "\" is installed with "
- "INCLUDES DESTINATION set to a context sensitive path. Paths which "
- "depend on the configuration, policy values or the link interface are "
- "not supported. Consider using target_include_directories instead.";
+ e << "Target \"" << target->GetName()
+ << "\" is installed with "
+ "INCLUDES DESTINATION set to a context sensitive path. Paths which "
+ "depend on the configuration, policy values or the link interface "
+ "are "
+ "not supported. Consider using target_include_directories instead.";
lg->IssueMessage(cmake::FATAL_ERROR, e.str());
return;
- }
+ }
- if (!input && exportDirs.empty())
- {
+ if (!input && exportDirs.empty()) {
return;
- }
- if ((input && !*input) && exportDirs.empty())
- {
+ }
+ if ((input && !*input) && exportDirs.empty()) {
// Set to empty
properties[propName] = "";
return;
- }
+ }
prefixItems(exportDirs);
- std::string includes = (input?input:"");
+ std::string includes = (input ? input : "");
const char* sep = input ? ";" : "";
includes += sep + exportDirs;
- std::string prepro = cmGeneratorExpression::Preprocess(includes,
- preprocessRule,
- true);
- if (!prepro.empty())
- {
- this->ResolveTargetsInGeneratorExpressions(prepro, target,
- missingTargets);
+ std::string prepro =
+ cmGeneratorExpression::Preprocess(includes, preprocessRule, true);
+ if (!prepro.empty()) {
+ this->ResolveTargetsInGeneratorExpressions(prepro, target, missingTargets);
- if (!checkInterfaceDirs(prepro, target, propName))
- {
+ if (!checkInterfaceDirs(prepro, target, propName)) {
return;
- }
- properties[propName] = prepro;
}
+ properties[propName] = prepro;
+ }
}
void cmExportFileGenerator::PopulateInterfaceProperty(
- const std::string& propName,
- cmGeneratorTarget* target,
- cmGeneratorExpression::PreprocessContext preprocessRule,
- ImportPropertyMap &properties,
- std::vector<std::string> &missingTargets)
+ const std::string& propName, cmGeneratorTarget* target,
+ cmGeneratorExpression::PreprocessContext preprocessRule,
+ ImportPropertyMap& properties, std::vector<std::string>& missingTargets)
{
this->PopulateInterfaceProperty(propName, propName, target, preprocessRule,
- properties, missingTargets);
+ properties, missingTargets);
}
-
-void getPropertyContents(cmGeneratorTarget const* tgt,
- const std::string& prop,
- std::set<std::string> &ifaceProperties)
+void getPropertyContents(cmGeneratorTarget const* tgt, const std::string& prop,
+ std::set<std::string>& ifaceProperties)
{
- const char *p = tgt->GetProperty(prop);
- if (!p)
- {
+ const char* p = tgt->GetProperty(prop);
+ if (!p) {
return;
- }
+ }
std::vector<std::string> content;
cmSystemTools::ExpandListArgument(p, content);
ifaceProperties.insert(content.begin(), content.end());
}
-void getCompatibleInterfaceProperties(cmGeneratorTarget *target,
- std::set<std::string> &ifaceProperties,
+void getCompatibleInterfaceProperties(cmGeneratorTarget* target,
+ std::set<std::string>& ifaceProperties,
const std::string& config)
{
- cmComputeLinkInformation *info = target->GetLinkInformation(config);
+ cmComputeLinkInformation* info = target->GetLinkInformation(config);
- if (!info)
- {
+ if (!info) {
cmLocalGenerator* lg = target->GetLocalGenerator();
std::ostringstream e;
- e << "Exporting the target \"" << target->GetName() << "\" is not "
- "allowed since its linker language cannot be determined";
+ e << "Exporting the target \"" << target->GetName()
+ << "\" is not "
+ "allowed since its linker language cannot be determined";
lg->IssueMessage(cmake::FATAL_ERROR, e.str());
return;
- }
+ }
- const cmComputeLinkInformation::ItemVector &deps = info->GetItems();
+ const cmComputeLinkInformation::ItemVector& deps = info->GetItems();
- for(cmComputeLinkInformation::ItemVector::const_iterator li =
- deps.begin();
- li != deps.end(); ++li)
- {
- if (!li->Target)
- {
+ for (cmComputeLinkInformation::ItemVector::const_iterator li = deps.begin();
+ li != deps.end(); ++li) {
+ if (!li->Target) {
continue;
- }
- getPropertyContents(li->Target,
- "COMPATIBLE_INTERFACE_BOOL",
+ }
+ getPropertyContents(li->Target, "COMPATIBLE_INTERFACE_BOOL",
ifaceProperties);
- getPropertyContents(li->Target,
- "COMPATIBLE_INTERFACE_STRING",
+ getPropertyContents(li->Target, "COMPATIBLE_INTERFACE_STRING",
ifaceProperties);
- getPropertyContents(li->Target,
- "COMPATIBLE_INTERFACE_NUMBER_MIN",
+ getPropertyContents(li->Target, "COMPATIBLE_INTERFACE_NUMBER_MIN",
ifaceProperties);
- getPropertyContents(li->Target,
- "COMPATIBLE_INTERFACE_NUMBER_MAX",
+ getPropertyContents(li->Target, "COMPATIBLE_INTERFACE_NUMBER_MAX",
ifaceProperties);
- }
+ }
}
void cmExportFileGenerator::PopulateCompatibleInterfaceProperties(
- cmGeneratorTarget *gtarget,
- ImportPropertyMap &properties)
+ cmGeneratorTarget* gtarget, ImportPropertyMap& properties)
{
- this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_BOOL",
- gtarget, properties);
- this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_STRING",
- gtarget, properties);
- this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_NUMBER_MIN",
- gtarget, properties);
- this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_NUMBER_MAX",
- gtarget, properties);
+ this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_BOOL", gtarget,
+ properties);
+ this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_STRING", gtarget,
+ properties);
+ this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_NUMBER_MIN", gtarget,
+ properties);
+ this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_NUMBER_MAX", gtarget,
+ properties);
std::set<std::string> ifaceProperties;
@@ -582,335 +512,272 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties(
getPropertyContents(gtarget, "COMPATIBLE_INTERFACE_NUMBER_MAX",
ifaceProperties);
- if (gtarget->GetType() != cmState::INTERFACE_LIBRARY)
- {
+ if (gtarget->GetType() != cmState::INTERFACE_LIBRARY) {
getCompatibleInterfaceProperties(gtarget, ifaceProperties, "");
std::vector<std::string> configNames;
gtarget->Target->GetMakefile()->GetConfigurations(configNames);
for (std::vector<std::string>::const_iterator ci = configNames.begin();
- ci != configNames.end(); ++ci)
- {
+ ci != configNames.end(); ++ci) {
getCompatibleInterfaceProperties(gtarget, ifaceProperties, *ci);
- }
}
+ }
for (std::set<std::string>::const_iterator it = ifaceProperties.begin();
- it != ifaceProperties.end(); ++it)
- {
- this->PopulateInterfaceProperty("INTERFACE_" + *it,
- gtarget, properties);
- }
+ it != ifaceProperties.end(); ++it) {
+ this->PopulateInterfaceProperty("INTERFACE_" + *it, gtarget, properties);
+ }
}
void cmExportFileGenerator::GenerateInterfaceProperties(
- const cmGeneratorTarget* target,
- std::ostream& os,
- const ImportPropertyMap &properties)
+ const cmGeneratorTarget* target, std::ostream& os,
+ const ImportPropertyMap& properties)
{
- if (!properties.empty())
- {
+ if (!properties.empty()) {
std::string targetName = this->Namespace;
targetName += target->GetExportName();
os << "set_target_properties(" << targetName << " PROPERTIES\n";
- for(ImportPropertyMap::const_iterator pi = properties.begin();
- pi != properties.end(); ++pi)
- {
- os << " " << pi->first << " "
- << cmExportFileGeneratorEscape(pi->second) << "\n";
- }
- os << ")\n\n";
+ for (ImportPropertyMap::const_iterator pi = properties.begin();
+ pi != properties.end(); ++pi) {
+ os << " " << pi->first << " " << cmExportFileGeneratorEscape(pi->second)
+ << "\n";
}
+ os << ")\n\n";
+ }
}
-bool
-cmExportFileGenerator::AddTargetNamespace(std::string &input,
- cmGeneratorTarget* target,
- std::vector<std::string> &missingTargets)
+bool cmExportFileGenerator::AddTargetNamespace(
+ std::string& input, cmGeneratorTarget* target,
+ std::vector<std::string>& missingTargets)
{
- cmLocalGenerator *lg = target->GetLocalGenerator();
+ cmLocalGenerator* lg = target->GetLocalGenerator();
- cmGeneratorTarget *tgt = lg->FindGeneratorTargetToUse(input);
- if (!tgt)
- {
+ cmGeneratorTarget* tgt = lg->FindGeneratorTargetToUse(input);
+ if (!tgt) {
return false;
- }
+ }
- if(tgt->IsImported())
- {
+ if (tgt->IsImported()) {
return true;
- }
- if(this->ExportedTargets.find(tgt) != this->ExportedTargets.end())
- {
+ }
+ if (this->ExportedTargets.find(tgt) != this->ExportedTargets.end()) {
input = this->Namespace + tgt->GetExportName();
- }
- else
- {
+ } else {
std::string namespacedTarget;
- this->HandleMissingTarget(namespacedTarget, missingTargets,
- target, tgt);
- if (!namespacedTarget.empty())
- {
+ this->HandleMissingTarget(namespacedTarget, missingTargets, target, tgt);
+ if (!namespacedTarget.empty()) {
input = namespacedTarget;
- }
}
+ }
return true;
}
-void
-cmExportFileGenerator::ResolveTargetsInGeneratorExpressions(
- std::string &input,
- cmGeneratorTarget* target,
- std::vector<std::string> &missingTargets,
- FreeTargetsReplace replace)
+void cmExportFileGenerator::ResolveTargetsInGeneratorExpressions(
+ std::string& input, cmGeneratorTarget* target,
+ std::vector<std::string>& missingTargets, FreeTargetsReplace replace)
{
- if (replace == NoReplaceFreeTargets)
- {
+ if (replace == NoReplaceFreeTargets) {
this->ResolveTargetsInGeneratorExpression(input, target, missingTargets);
return;
- }
+ }
std::vector<std::string> parts;
cmGeneratorExpression::Split(input, parts);
std::string sep;
input = "";
- for(std::vector<std::string>::iterator li = parts.begin();
- li != parts.end(); ++li)
- {
- if (cmGeneratorExpression::Find(*li) == std::string::npos)
- {
+ for (std::vector<std::string>::iterator li = parts.begin();
+ li != parts.end(); ++li) {
+ if (cmGeneratorExpression::Find(*li) == std::string::npos) {
this->AddTargetNamespace(*li, target, missingTargets);
- }
- else
- {
- this->ResolveTargetsInGeneratorExpression(
- *li,
- target,
- missingTargets);
- }
+ } else {
+ this->ResolveTargetsInGeneratorExpression(*li, target, missingTargets);
+ }
input += sep + *li;
sep = ";";
- }
+ }
}
-void
-cmExportFileGenerator::ResolveTargetsInGeneratorExpression(
- std::string &input,
- cmGeneratorTarget* target,
- std::vector<std::string> &missingTargets)
+void cmExportFileGenerator::ResolveTargetsInGeneratorExpression(
+ std::string& input, cmGeneratorTarget* target,
+ std::vector<std::string>& missingTargets)
{
std::string::size_type pos = 0;
std::string::size_type lastPos = pos;
- while((pos = input.find("$<TARGET_PROPERTY:", lastPos)) != input.npos)
- {
- std::string::size_type nameStartPos = pos +
- sizeof("$<TARGET_PROPERTY:") - 1;
+ while ((pos = input.find("$<TARGET_PROPERTY:", lastPos)) != input.npos) {
+ std::string::size_type nameStartPos =
+ pos + sizeof("$<TARGET_PROPERTY:") - 1;
std::string::size_type closePos = input.find(">", nameStartPos);
std::string::size_type commaPos = input.find(",", nameStartPos);
std::string::size_type nextOpenPos = input.find("$<", nameStartPos);
- if (commaPos == input.npos // Implied 'this' target
- || closePos == input.npos // Imcomplete expression.
- || closePos < commaPos // Implied 'this' target
+ if (commaPos == input.npos // Implied 'this' target
+ || closePos == input.npos // Imcomplete expression.
+ || closePos < commaPos // Implied 'this' target
|| nextOpenPos < commaPos) // Non-literal
- {
+ {
lastPos = nameStartPos;
continue;
- }
+ }
- std::string targetName = input.substr(nameStartPos,
- commaPos - nameStartPos);
+ std::string targetName =
+ input.substr(nameStartPos, commaPos - nameStartPos);
- if (this->AddTargetNamespace(targetName, target, missingTargets))
- {
+ if (this->AddTargetNamespace(targetName, target, missingTargets)) {
input.replace(nameStartPos, commaPos - nameStartPos, targetName);
- }
- lastPos = nameStartPos + targetName.size() + 1;
}
+ lastPos = nameStartPos + targetName.size() + 1;
+ }
std::string errorString;
pos = 0;
lastPos = pos;
- while((pos = input.find("$<TARGET_NAME:", lastPos)) != input.npos)
- {
+ while ((pos = input.find("$<TARGET_NAME:", lastPos)) != input.npos) {
std::string::size_type nameStartPos = pos + sizeof("$<TARGET_NAME:") - 1;
std::string::size_type endPos = input.find(">", nameStartPos);
- if (endPos == input.npos)
- {
+ if (endPos == input.npos) {
errorString = "$<TARGET_NAME:...> expression incomplete";
break;
- }
- std::string targetName = input.substr(nameStartPos,
- endPos - nameStartPos);
- if(targetName.find("$<") != input.npos)
- {
+ }
+ std::string targetName = input.substr(nameStartPos, endPos - nameStartPos);
+ if (targetName.find("$<") != input.npos) {
errorString = "$<TARGET_NAME:...> requires its parameter to be a "
"literal.";
break;
- }
- if (!this->AddTargetNamespace(targetName, target, missingTargets))
- {
+ }
+ if (!this->AddTargetNamespace(targetName, target, missingTargets)) {
errorString = "$<TARGET_NAME:...> requires its parameter to be a "
"reachable target.";
break;
- }
+ }
input.replace(pos, endPos - pos + 1, targetName);
lastPos = endPos;
- }
+ }
pos = 0;
lastPos = pos;
while (errorString.empty() &&
- (pos = input.find("$<LINK_ONLY:", lastPos)) != input.npos)
- {
+ (pos = input.find("$<LINK_ONLY:", lastPos)) != input.npos) {
std::string::size_type nameStartPos = pos + sizeof("$<LINK_ONLY:") - 1;
std::string::size_type endPos = input.find(">", nameStartPos);
- if (endPos == input.npos)
- {
+ if (endPos == input.npos) {
errorString = "$<LINK_ONLY:...> expression incomplete";
break;
- }
+ }
std::string libName = input.substr(nameStartPos, endPos - nameStartPos);
if (cmGeneratorExpression::IsValidTargetName(libName) &&
- this->AddTargetNamespace(libName, target, missingTargets))
- {
+ this->AddTargetNamespace(libName, target, missingTargets)) {
input.replace(nameStartPos, endPos - nameStartPos, libName);
- }
- lastPos = nameStartPos + libName.size() + 1;
}
+ lastPos = nameStartPos + libName.size() + 1;
+ }
this->ReplaceInstallPrefix(input);
- if (!errorString.empty())
- {
+ if (!errorString.empty()) {
target->GetLocalGenerator()->IssueMessage(cmake::FATAL_ERROR, errorString);
- }
+ }
}
-void
-cmExportFileGenerator::ReplaceInstallPrefix(std::string &)
+void cmExportFileGenerator::ReplaceInstallPrefix(std::string&)
{
// Do nothing
}
-void
-cmExportFileGenerator
-::SetImportLinkInterface(const std::string& config, std::string const& suffix,
- cmGeneratorExpression::PreprocessContext preprocessRule,
- cmGeneratorTarget* target, ImportPropertyMap& properties,
- std::vector<std::string>& missingTargets)
+void cmExportFileGenerator::SetImportLinkInterface(
+ const std::string& config, std::string const& suffix,
+ cmGeneratorExpression::PreprocessContext preprocessRule,
+ cmGeneratorTarget* target, ImportPropertyMap& properties,
+ std::vector<std::string>& missingTargets)
{
// Add the transitive link dependencies for this configuration.
- cmLinkInterface const* iface = target->GetLinkInterface(config,
- target);
- if (!iface)
- {
+ cmLinkInterface const* iface = target->GetLinkInterface(config, target);
+ if (!iface) {
return;
- }
+ }
- if (iface->ImplementationIsInterface)
- {
+ if (iface->ImplementationIsInterface) {
// Policy CMP0022 must not be NEW.
this->SetImportLinkProperty(suffix, target,
"IMPORTED_LINK_INTERFACE_LIBRARIES",
iface->Libraries, properties, missingTargets);
return;
- }
+ }
- const char *propContent;
+ const char* propContent;
- if (const char *prop_suffixed = target->GetProperty(
- "LINK_INTERFACE_LIBRARIES" + suffix))
- {
+ if (const char* prop_suffixed =
+ target->GetProperty("LINK_INTERFACE_LIBRARIES" + suffix)) {
propContent = prop_suffixed;
- }
- else if (const char *prop = target->GetProperty(
- "LINK_INTERFACE_LIBRARIES"))
- {
+ } else if (const char* prop =
+ target->GetProperty("LINK_INTERFACE_LIBRARIES")) {
propContent = prop;
- }
- else
- {
+ } else {
return;
- }
+ }
const bool newCMP0022Behavior =
- target->GetPolicyStatusCMP0022() != cmPolicies::WARN
- && target->GetPolicyStatusCMP0022() != cmPolicies::OLD;
+ target->GetPolicyStatusCMP0022() != cmPolicies::WARN &&
+ target->GetPolicyStatusCMP0022() != cmPolicies::OLD;
- if(newCMP0022Behavior && !this->ExportOld)
- {
- cmLocalGenerator *lg = target->GetLocalGenerator();
+ if (newCMP0022Behavior && !this->ExportOld) {
+ cmLocalGenerator* lg = target->GetLocalGenerator();
std::ostringstream e;
- e << "Target \"" << target->GetName() << "\" has policy CMP0022 enabled, "
+ e << "Target \"" << target->GetName()
+ << "\" has policy CMP0022 enabled, "
"but also has old-style LINK_INTERFACE_LIBRARIES properties "
"populated, but it was exported without the "
"EXPORT_LINK_INTERFACE_LIBRARIES to export the old-style properties";
lg->IssueMessage(cmake::FATAL_ERROR, e.str());
return;
- }
+ }
- if (!*propContent)
- {
+ if (!*propContent) {
properties["IMPORTED_LINK_INTERFACE_LIBRARIES" + suffix] = "";
return;
- }
+ }
- std::string prepro = cmGeneratorExpression::Preprocess(propContent,
- preprocessRule);
- if (!prepro.empty())
- {
- this->ResolveTargetsInGeneratorExpressions(prepro, target,
- missingTargets,
+ std::string prepro =
+ cmGeneratorExpression::Preprocess(propContent, preprocessRule);
+ if (!prepro.empty()) {
+ this->ResolveTargetsInGeneratorExpressions(prepro, target, missingTargets,
ReplaceFreeTargets);
properties["IMPORTED_LINK_INTERFACE_LIBRARIES" + suffix] = prepro;
- }
+ }
}
-void
-cmExportFileGenerator
-::SetImportDetailProperties(const std::string& config,
- std::string const& suffix,
- cmGeneratorTarget* target,
- ImportPropertyMap& properties,
- std::vector<std::string>& missingTargets
- )
+void cmExportFileGenerator::SetImportDetailProperties(
+ const std::string& config, std::string const& suffix,
+ cmGeneratorTarget* target, ImportPropertyMap& properties,
+ std::vector<std::string>& missingTargets)
{
// Get the makefile in which to lookup target information.
cmMakefile* mf = target->Makefile;
// Add the soname for unix shared libraries.
- if(target->GetType() == cmState::SHARED_LIBRARY ||
- target->GetType() == cmState::MODULE_LIBRARY)
- {
- if(!target->IsDLLPlatform())
- {
+ if (target->GetType() == cmState::SHARED_LIBRARY ||
+ target->GetType() == cmState::MODULE_LIBRARY) {
+ if (!target->IsDLLPlatform()) {
std::string prop;
std::string value;
- if(target->HasSOName(config))
- {
- if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
- {
+ if (target->HasSOName(config)) {
+ if (mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) {
value = this->InstallNameDir(target, config);
- }
+ }
prop = "IMPORTED_SONAME";
value += target->GetSOName(config);
- }
- else
- {
+ } else {
prop = "IMPORTED_NO_SONAME";
value = "TRUE";
- }
+ }
prop += suffix;
properties[prop] = value;
- }
}
+ }
// Add the transitive link dependencies for this configuration.
- if(cmLinkInterface const* iface =
- target->GetLinkInterface(config, target))
- {
+ if (cmLinkInterface const* iface =
+ target->GetLinkInterface(config, target)) {
this->SetImportLinkProperty(suffix, target,
"IMPORTED_LINK_INTERFACE_LANGUAGES",
iface->Languages, properties, missingTargets);
@@ -919,40 +786,32 @@ cmExportFileGenerator
this->SetImportLinkProperty(suffix, target,
"IMPORTED_LINK_DEPENDENT_LIBRARIES",
iface->SharedDeps, properties, dummy);
- if(iface->Multiplicity > 0)
- {
+ if (iface->Multiplicity > 0) {
std::string prop = "IMPORTED_LINK_INTERFACE_MULTIPLICITY";
prop += suffix;
std::ostringstream m;
m << iface->Multiplicity;
properties[prop] = m.str();
- }
}
+ }
}
template <typename T>
-void
-cmExportFileGenerator
-::SetImportLinkProperty(std::string const& suffix,
- cmGeneratorTarget* target,
- const std::string& propName,
- std::vector<T> const& entries,
- ImportPropertyMap& properties,
- std::vector<std::string>& missingTargets
- )
+void cmExportFileGenerator::SetImportLinkProperty(
+ std::string const& suffix, cmGeneratorTarget* target,
+ const std::string& propName, std::vector<T> const& entries,
+ ImportPropertyMap& properties, std::vector<std::string>& missingTargets)
{
// Skip the property if there are no entries.
- if(entries.empty())
- {
+ if (entries.empty()) {
return;
- }
+ }
// Construct the property value.
std::string link_entries;
const char* sep = "";
- for(typename std::vector<T>::const_iterator li = entries.begin();
- li != entries.end(); ++li)
- {
+ for (typename std::vector<T>::const_iterator li = entries.begin();
+ li != entries.end(); ++li) {
// Separate this from the previous entry.
link_entries += sep;
sep = ";";
@@ -960,7 +819,7 @@ cmExportFileGenerator
std::string temp = *li;
this->AddTargetNamespace(temp, target, missingTargets);
link_entries += temp;
- }
+ }
// Store the property.
std::string prop = propName;
@@ -969,18 +828,15 @@ cmExportFileGenerator
}
void cmExportFileGenerator::GenerateImportHeaderCode(std::ostream& os,
- const std::string& config)
+ const std::string& config)
{
os << "#----------------------------------------------------------------\n"
<< "# Generated CMake target import file";
- if(!config.empty())
- {
+ if (!config.empty()) {
os << " for configuration \"" << config << "\".\n";
- }
- else
- {
+ } else {
os << ".\n";
- }
+ }
os << "#----------------------------------------------------------------\n"
<< "\n";
this->GenerateImportVersionCode(os);
@@ -1003,8 +859,8 @@ void cmExportFileGenerator::GenerateImportVersionCode(std::ostream& os)
/* clang-format on */
}
-void cmExportFileGenerator::GenerateExpectedTargetsCode(std::ostream& os,
- const std::string &expectedTargets)
+void cmExportFileGenerator::GenerateExpectedTargetsCode(
+ std::ostream& os, const std::string& expectedTargets)
{
/* clang-format off */
os << "# Protect against multiple inclusion, which would fail when already "
@@ -1040,9 +896,8 @@ void cmExportFileGenerator::GenerateExpectedTargetsCode(std::ostream& os,
"\n\n";
/* clang-format on */
}
-void
-cmExportFileGenerator
-::GenerateImportTargetCode(std::ostream& os, const cmGeneratorTarget* target)
+void cmExportFileGenerator::GenerateImportTargetCode(
+ std::ostream& os, const cmGeneratorTarget* target)
{
// Construct the imported target name.
std::string targetName = this->Namespace;
@@ -1051,8 +906,7 @@ cmExportFileGenerator
// Create the imported target.
os << "# Create imported target " << targetName << "\n";
- switch(target->GetType())
- {
+ switch (target->GetType()) {
case cmState::EXECUTABLE:
os << "add_executable(" << targetName << " IMPORTED)\n";
break;
@@ -1071,44 +925,36 @@ cmExportFileGenerator
case cmState::INTERFACE_LIBRARY:
os << "add_library(" << targetName << " INTERFACE IMPORTED)\n";
break;
- default: // should never happen
+ default: // should never happen
break;
- }
+ }
// Mark the imported executable if it has exports.
- if(target->IsExecutableWithExports())
- {
+ if (target->IsExecutableWithExports()) {
os << "set_property(TARGET " << targetName
<< " PROPERTY ENABLE_EXPORTS 1)\n";
- }
+ }
// Mark the imported library if it is a framework.
- if(target->IsFrameworkOnApple())
- {
- os << "set_property(TARGET " << targetName
- << " PROPERTY FRAMEWORK 1)\n";
- }
+ if (target->IsFrameworkOnApple()) {
+ os << "set_property(TARGET " << targetName << " PROPERTY FRAMEWORK 1)\n";
+ }
// Mark the imported executable if it is an application bundle.
- if(target->IsAppBundleOnApple())
- {
+ if (target->IsAppBundleOnApple()) {
os << "set_property(TARGET " << targetName
<< " PROPERTY MACOSX_BUNDLE 1)\n";
- }
+ }
- if (target->IsCFBundleOnApple())
- {
- os << "set_property(TARGET " << targetName
- << " PROPERTY BUNDLE 1)\n";
- }
+ if (target->IsCFBundleOnApple()) {
+ os << "set_property(TARGET " << targetName << " PROPERTY BUNDLE 1)\n";
+ }
os << "\n";
}
-void
-cmExportFileGenerator
-::GenerateImportPropertyCode(std::ostream& os, const std::string& config,
- cmGeneratorTarget const* target,
- ImportPropertyMap const& properties)
+void cmExportFileGenerator::GenerateImportPropertyCode(
+ std::ostream& os, const std::string& config, cmGeneratorTarget const* target,
+ ImportPropertyMap const& properties)
{
// Construct the imported target name.
std::string targetName = this->Namespace;
@@ -1120,39 +966,33 @@ cmExportFileGenerator
<< config << "\"\n";
os << "set_property(TARGET " << targetName
<< " APPEND PROPERTY IMPORTED_CONFIGURATIONS ";
- if(!config.empty())
- {
+ if (!config.empty()) {
os << cmSystemTools::UpperCase(config);
- }
- else
- {
+ } else {
os << "NOCONFIG";
- }
+ }
os << ")\n";
os << "set_target_properties(" << targetName << " PROPERTIES\n";
- for(ImportPropertyMap::const_iterator pi = properties.begin();
- pi != properties.end(); ++pi)
- {
- os << " " << pi->first << " "
- << cmExportFileGeneratorEscape(pi->second) << "\n";
- }
+ for (ImportPropertyMap::const_iterator pi = properties.begin();
+ pi != properties.end(); ++pi) {
+ os << " " << pi->first << " " << cmExportFileGeneratorEscape(pi->second)
+ << "\n";
+ }
os << " )\n"
<< "\n";
}
-
-void cmExportFileGenerator::GenerateMissingTargetsCheckCode(std::ostream& os,
- const std::vector<std::string>& missingTargets)
+void cmExportFileGenerator::GenerateMissingTargetsCheckCode(
+ std::ostream& os, const std::vector<std::string>& missingTargets)
{
- if (missingTargets.empty())
- {
+ if (missingTargets.empty()) {
/* clang-format off */
os << "# This file does not depend on other imported targets which have\n"
"# been exported from the same project but in a separate "
"export set.\n\n";
/* clang-format on */
return;
- }
+ }
/* clang-format off */
os << "# Make sure the targets which have been exported in some other \n"
"# export set exist.\n"
@@ -1160,13 +1000,11 @@ void cmExportFileGenerator::GenerateMissingTargetsCheckCode(std::ostream& os,
"foreach(_target ";
/* clang-format on */
std::set<std::string> emitted;
- for(unsigned int i=0; i<missingTargets.size(); ++i)
- {
- if (emitted.insert(missingTargets[i]).second)
- {
- os << "\"" << missingTargets[i] << "\" ";
- }
+ for (unsigned int i = 0; i < missingTargets.size(); ++i) {
+ if (emitted.insert(missingTargets[i]).second) {
+ os << "\"" << missingTargets[i] << "\" ";
}
+ }
/* clang-format off */
os << ")\n"
" if(NOT TARGET \"${_target}\" )\n"
@@ -1194,9 +1032,7 @@ void cmExportFileGenerator::GenerateMissingTargetsCheckCode(std::ostream& os,
/* clang-format on */
}
-
-void
-cmExportFileGenerator::GenerateImportedFileCheckLoop(std::ostream& os)
+void cmExportFileGenerator::GenerateImportedFileCheckLoop(std::ostream& os)
{
// Add code which verifies at cmake time that the file which is being
// imported actually exists on disk. This should in theory always be theory
@@ -1229,30 +1065,27 @@ cmExportFileGenerator::GenerateImportedFileCheckLoop(std::ostream& os)
/* clang-format on */
}
-
-void
-cmExportFileGenerator
-::GenerateImportedFileChecksCode(std::ostream& os, cmGeneratorTarget* target,
- ImportPropertyMap const& properties,
- const std::set<std::string>& importedLocations)
+void cmExportFileGenerator::GenerateImportedFileChecksCode(
+ std::ostream& os, cmGeneratorTarget* target,
+ ImportPropertyMap const& properties,
+ const std::set<std::string>& importedLocations)
{
// Construct the imported target name.
std::string targetName = this->Namespace;
targetName += target->GetExportName();
- os << "list(APPEND _IMPORT_CHECK_TARGETS " << targetName << " )\n"
- "list(APPEND _IMPORT_CHECK_FILES_FOR_" << targetName << " ";
+ os << "list(APPEND _IMPORT_CHECK_TARGETS " << targetName
+ << " )\n"
+ "list(APPEND _IMPORT_CHECK_FILES_FOR_"
+ << targetName << " ";
- for(std::set<std::string>::const_iterator li = importedLocations.begin();
- li != importedLocations.end();
- ++li)
- {
+ for (std::set<std::string>::const_iterator li = importedLocations.begin();
+ li != importedLocations.end(); ++li) {
ImportPropertyMap::const_iterator pi = properties.find(*li);
- if (pi != properties.end())
- {
+ if (pi != properties.end()) {
os << cmExportFileGeneratorEscape(pi->second) << " ";
- }
}
+ }
os << ")\n\n";
}
diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h
index 9fc02a4..9c96015 100644
--- a/Source/cmExportFileGenerator.h
+++ b/Source/cmExportFileGenerator.h
@@ -21,13 +21,12 @@
#define STRINGIFY_HELPER(X) #X
#define STRINGIFY(X) STRINGIFY_HELPER(X)
-#define DEVEL_CMAKE_VERSION(major, minor) ( \
- CMake_VERSION_ENCODE(major, minor, 0) > \
- CMake_VERSION_ENCODE(CMake_VERSION_MAJOR, CMake_VERSION_MINOR, 0) ? \
- STRINGIFY(CMake_VERSION_MAJOR) "." STRINGIFY(CMake_VERSION_MINOR) "." \
- STRINGIFY(CMake_VERSION_PATCH) \
- : #major "." #minor ".0" \
- )
+#define DEVEL_CMAKE_VERSION(major, minor) \
+ (CMake_VERSION_ENCODE(major, minor, 0) > \
+ CMake_VERSION_ENCODE(CMake_VERSION_MAJOR, CMake_VERSION_MINOR, 0) \
+ ? STRINGIFY(CMake_VERSION_MAJOR) "." STRINGIFY( \
+ CMake_VERSION_MINOR) "." STRINGIFY(CMake_VERSION_PATCH) \
+ : #major "." #minor ".0")
class cmTargetExport;
@@ -47,7 +46,7 @@ public:
/** Set the full path to the export file to generate. */
void SetExportFile(const char* mainFile);
- const char *GetMainExportFileName() const;
+ const char* GetMainExportFileName() const;
/** Set the namespace in which to place exported target names. */
void SetNamespace(const std::string& ns) { this->Namespace = ns; }
@@ -61,14 +60,14 @@ public:
/** Actually generate the export file. Returns whether there was an
error. */
bool GenerateImportFile();
-protected:
+protected:
typedef std::map<std::string, std::string> ImportPropertyMap;
// Generate per-configuration target information to the given output
// stream.
void GenerateImportConfig(std::ostream& os, const std::string& config,
- std::vector<std::string> &missingTargets);
+ std::vector<std::string>& missingTargets);
// Methods to implement export file code generation.
void GenerateImportHeaderCode(std::ostream& os,
@@ -80,16 +79,16 @@ protected:
void GenerateImportPropertyCode(std::ostream& os, const std::string& config,
cmGeneratorTarget const* target,
ImportPropertyMap const& properties);
- void GenerateImportedFileChecksCode(std::ostream& os,
- cmGeneratorTarget* target,
- ImportPropertyMap const& properties,
- const std::set<std::string>& importedLocations);
+ void GenerateImportedFileChecksCode(
+ std::ostream& os, cmGeneratorTarget* target,
+ ImportPropertyMap const& properties,
+ const std::set<std::string>& importedLocations);
void GenerateImportedFileCheckLoop(std::ostream& os);
- void GenerateMissingTargetsCheckCode(std::ostream& os,
- const std::vector<std::string>& missingTargets);
+ void GenerateMissingTargetsCheckCode(
+ std::ostream& os, const std::vector<std::string>& missingTargets);
void GenerateExpectedTargetsCode(std::ostream& os,
- const std::string &expectedTargets);
+ const std::string& expectedTargets);
// Collect properties with detailed information about targets beyond
// their location on disk.
@@ -111,10 +110,9 @@ protected:
virtual bool GenerateMainFile(std::ostream& os) = 0;
/** Each subclass knows where the target files are located. */
- virtual void GenerateImportTargetsConfig(std::ostream& os,
- const std::string& config,
- std::string const& suffix,
- std::vector<std::string> &missingTargets) = 0;
+ virtual void GenerateImportTargetsConfig(
+ std::ostream& os, const std::string& config, std::string const& suffix,
+ std::vector<std::string>& missingTargets) = 0;
/** Each subclass knows how to deal with a target that is missing from an
* export set. */
@@ -122,52 +120,49 @@ protected:
std::vector<std::string>& missingTargets,
cmGeneratorTarget* depender,
cmGeneratorTarget* dependee) = 0;
- void PopulateInterfaceProperty(const std::string&,
- cmGeneratorTarget *target,
+ void PopulateInterfaceProperty(const std::string&, cmGeneratorTarget* target,
cmGeneratorExpression::PreprocessContext,
- ImportPropertyMap &properties,
- std::vector<std::string> &missingTargets);
- bool PopulateInterfaceLinkLibrariesProperty(cmGeneratorTarget* target,
- cmGeneratorExpression::PreprocessContext,
- ImportPropertyMap &properties,
- std::vector<std::string> &missingTargets);
+ ImportPropertyMap& properties,
+ std::vector<std::string>& missingTargets);
+ bool PopulateInterfaceLinkLibrariesProperty(
+ cmGeneratorTarget* target, cmGeneratorExpression::PreprocessContext,
+ ImportPropertyMap& properties, std::vector<std::string>& missingTargets);
void PopulateInterfaceProperty(const std::string& propName,
cmGeneratorTarget* target,
- ImportPropertyMap &properties);
- void PopulateCompatibleInterfaceProperties(cmGeneratorTarget *target,
- ImportPropertyMap &properties);
+ ImportPropertyMap& properties);
+ void PopulateCompatibleInterfaceProperties(cmGeneratorTarget* target,
+ ImportPropertyMap& properties);
void GenerateInterfaceProperties(cmGeneratorTarget const* target,
std::ostream& os,
- const ImportPropertyMap &properties);
+ const ImportPropertyMap& properties);
void PopulateIncludeDirectoriesInterface(
- cmTargetExport *target,
- cmGeneratorExpression::PreprocessContext preprocessRule,
- ImportPropertyMap &properties,
- std::vector<std::string> &missingTargets);
+ cmTargetExport* target,
+ cmGeneratorExpression::PreprocessContext preprocessRule,
+ ImportPropertyMap& properties, std::vector<std::string>& missingTargets);
void PopulateSourcesInterface(
- cmTargetExport *target,
- cmGeneratorExpression::PreprocessContext preprocessRule,
- ImportPropertyMap &properties,
- std::vector<std::string> &missingTargets);
-
- void SetImportLinkInterface(const std::string& config,
- std::string const& suffix,
- cmGeneratorExpression::PreprocessContext preprocessRule,
- cmGeneratorTarget* target, ImportPropertyMap& properties,
- std::vector<std::string>& missingTargets);
-
- enum FreeTargetsReplace {
+ cmTargetExport* target,
+ cmGeneratorExpression::PreprocessContext preprocessRule,
+ ImportPropertyMap& properties, std::vector<std::string>& missingTargets);
+
+ void SetImportLinkInterface(
+ const std::string& config, std::string const& suffix,
+ cmGeneratorExpression::PreprocessContext preprocessRule,
+ cmGeneratorTarget* target, ImportPropertyMap& properties,
+ std::vector<std::string>& missingTargets);
+
+ enum FreeTargetsReplace
+ {
ReplaceFreeTargets,
NoReplaceFreeTargets
};
- void ResolveTargetsInGeneratorExpressions(std::string &input,
- cmGeneratorTarget* target,
- std::vector<std::string> &missingTargets,
- FreeTargetsReplace replace = NoReplaceFreeTargets);
+ void ResolveTargetsInGeneratorExpressions(
+ std::string& input, cmGeneratorTarget* target,
+ std::vector<std::string>& missingTargets,
+ FreeTargetsReplace replace = NoReplaceFreeTargets);
void GenerateRequiredCMakeVersion(std::ostream& os,
- const char *versionString);
+ const char* versionString);
// The namespace in which the exports are placed in the generated file.
std::string Namespace;
@@ -191,17 +186,17 @@ private:
void PopulateInterfaceProperty(const std::string&, const std::string&,
cmGeneratorTarget* target,
cmGeneratorExpression::PreprocessContext,
- ImportPropertyMap &properties,
- std::vector<std::string> &missingTargets);
+ ImportPropertyMap& properties,
+ std::vector<std::string>& missingTargets);
- bool AddTargetNamespace(std::string &input, cmGeneratorTarget* target,
- std::vector<std::string> &missingTargets);
+ bool AddTargetNamespace(std::string& input, cmGeneratorTarget* target,
+ std::vector<std::string>& missingTargets);
- void ResolveTargetsInGeneratorExpression(std::string &input,
- cmGeneratorTarget* target,
- std::vector<std::string> &missingTargets);
+ void ResolveTargetsInGeneratorExpression(
+ std::string& input, cmGeneratorTarget* target,
+ std::vector<std::string>& missingTargets);
- virtual void ReplaceInstallPrefix(std::string &input);
+ virtual void ReplaceInstallPrefix(std::string& input);
virtual std::string InstallNameDir(cmGeneratorTarget* target,
const std::string& config) = 0;
diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx
index 2d454b9..38b08f0 100644
--- a/Source/cmExportInstallFileGenerator.cxx
+++ b/Source/cmExportInstallFileGenerator.cxx
@@ -21,9 +21,9 @@
#include "cmLocalGenerator.h"
#include "cmTargetExport.h"
-cmExportInstallFileGenerator
-::cmExportInstallFileGenerator(cmInstallExportGenerator* iegen):
- IEGen(iegen)
+cmExportInstallFileGenerator::cmExportInstallFileGenerator(
+ cmInstallExportGenerator* iegen)
+ : IEGen(iegen)
{
}
@@ -39,42 +39,39 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
{
std::vector<cmTargetExport*> allTargets;
{
- std::string expectedTargets;
- std::string sep;
- for(std::vector<cmTargetExport*>::const_iterator
- tei = this->IEGen->GetExportSet()->GetTargetExports()->begin();
- tei != this->IEGen->GetExportSet()->GetTargetExports()->end(); ++tei)
- {
- expectedTargets +=
+ std::string expectedTargets;
+ std::string sep;
+ for (std::vector<cmTargetExport*>::const_iterator tei =
+ this->IEGen->GetExportSet()->GetTargetExports()->begin();
+ tei != this->IEGen->GetExportSet()->GetTargetExports()->end();
+ ++tei) {
+ expectedTargets +=
sep + this->Namespace + (*tei)->Target->GetExportName();
- sep = " ";
- cmTargetExport * te = *tei;
- if(this->ExportedTargets.insert(te->Target).second)
- {
- allTargets.push_back(te);
- }
- else
- {
- std::ostringstream e;
- e << "install(EXPORT \""
- << this->IEGen->GetExportSet()->GetName()
- << "\" ...) " << "includes target \"" << te->Target->GetName()
- << "\" more than once in the export set.";
- cmSystemTools::Error(e.str().c_str());
- return false;
+ sep = " ";
+ cmTargetExport* te = *tei;
+ if (this->ExportedTargets.insert(te->Target).second) {
+ allTargets.push_back(te);
+ } else {
+ std::ostringstream e;
+ e << "install(EXPORT \"" << this->IEGen->GetExportSet()->GetName()
+ << "\" ...) "
+ << "includes target \"" << te->Target->GetName()
+ << "\" more than once in the export set.";
+ cmSystemTools::Error(e.str().c_str());
+ return false;
}
}
- this->GenerateExpectedTargetsCode(os, expectedTargets);
+ this->GenerateExpectedTargetsCode(os, expectedTargets);
}
// Set an _IMPORT_PREFIX variable for import location properties
// to reference if they are relative to the install prefix.
- std::string installPrefix = this->IEGen->GetLocalGenerator()
- ->GetMakefile()->GetSafeDefinition("CMAKE_INSTALL_PREFIX");
+ std::string installPrefix =
+ this->IEGen->GetLocalGenerator()->GetMakefile()->GetSafeDefinition(
+ "CMAKE_INSTALL_PREFIX");
std::string const& expDest = this->IEGen->GetDestination();
- if(cmSystemTools::FileIsFullPath(expDest))
- {
+ if (cmSystemTools::FileIsFullPath(expDest)) {
// The export file is being installed to an absolute path so the
// package is not relocatable. Use the configured install prefix.
/* clang-format off */
@@ -83,9 +80,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
"set(_IMPORT_PREFIX \"" << installPrefix << "\")\n"
"\n";
/* clang-format on */
- }
- else
- {
+ } else {
// Add code to compute the installation prefix relative to the
// import file location.
std::string absDest = installPrefix + "/" + expDest;
@@ -93,11 +88,10 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
os << "# Compute the installation prefix relative to this file.\n"
<< "get_filename_component(_IMPORT_PREFIX"
<< " \"${CMAKE_CURRENT_LIST_FILE}\" PATH)\n";
- if(cmHasLiteralPrefix(absDestS.c_str(), "/lib/") ||
- cmHasLiteralPrefix(absDestS.c_str(), "/lib64/") ||
- cmHasLiteralPrefix(absDestS.c_str(), "/usr/lib/") ||
- cmHasLiteralPrefix(absDestS.c_str(), "/usr/lib64/"))
- {
+ if (cmHasLiteralPrefix(absDestS.c_str(), "/lib/") ||
+ cmHasLiteralPrefix(absDestS.c_str(), "/lib64/") ||
+ cmHasLiteralPrefix(absDestS.c_str(), "/usr/lib/") ||
+ cmHasLiteralPrefix(absDestS.c_str(), "/usr/lib64/")) {
// Handle "/usr move" symlinks created by some Linux distros.
/* clang-format off */
os <<
@@ -111,16 +105,15 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
"unset(_realOrig)\n"
"unset(_realCurr)\n";
/* clang-format on */
- }
+ }
std::string dest = expDest;
- while(!dest.empty())
- {
- os <<
- "get_filename_component(_IMPORT_PREFIX \"${_IMPORT_PREFIX}\" PATH)\n";
+ while (!dest.empty()) {
+ os << "get_filename_component(_IMPORT_PREFIX \"${_IMPORT_PREFIX}\" "
+ "PATH)\n";
dest = cmSystemTools::GetFilenamePath(dest);
- }
- os << "\n";
}
+ os << "\n";
+ }
std::vector<std::string> missingTargets;
@@ -129,90 +122,74 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
bool require3_1_0 = false;
bool requiresConfigFiles = false;
// Create all the imported targets.
- for(std::vector<cmTargetExport*>::const_iterator
- tei = allTargets.begin();
- tei != allTargets.end(); ++tei)
- {
+ for (std::vector<cmTargetExport*>::const_iterator tei = allTargets.begin();
+ tei != allTargets.end(); ++tei) {
cmGeneratorTarget* gt = (*tei)->Target;
- requiresConfigFiles = requiresConfigFiles
- || gt->GetType() != cmState::INTERFACE_LIBRARY;
+ requiresConfigFiles =
+ requiresConfigFiles || gt->GetType() != cmState::INTERFACE_LIBRARY;
this->GenerateImportTargetCode(os, gt);
ImportPropertyMap properties;
- this->PopulateIncludeDirectoriesInterface(*tei,
- cmGeneratorExpression::InstallInterface,
- properties, missingTargets);
+ this->PopulateIncludeDirectoriesInterface(
+ *tei, cmGeneratorExpression::InstallInterface, properties,
+ missingTargets);
this->PopulateSourcesInterface(*tei,
- cmGeneratorExpression::InstallInterface,
- properties, missingTargets);
- this->PopulateInterfaceProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES",
- gt,
- cmGeneratorExpression::InstallInterface,
- properties, missingTargets);
- this->PopulateInterfaceProperty("INTERFACE_COMPILE_DEFINITIONS",
- gt,
- cmGeneratorExpression::InstallInterface,
- properties, missingTargets);
- this->PopulateInterfaceProperty("INTERFACE_COMPILE_OPTIONS",
- gt,
- cmGeneratorExpression::InstallInterface,
- properties, missingTargets);
- this->PopulateInterfaceProperty("INTERFACE_AUTOUIC_OPTIONS",
- gt,
- cmGeneratorExpression::InstallInterface,
- properties, missingTargets);
- this->PopulateInterfaceProperty("INTERFACE_COMPILE_FEATURES",
- gt,
- cmGeneratorExpression::InstallInterface,
- properties, missingTargets);
+ cmGeneratorExpression::InstallInterface,
+ properties, missingTargets);
+ this->PopulateInterfaceProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES", gt,
+ cmGeneratorExpression::InstallInterface,
+ properties, missingTargets);
+ this->PopulateInterfaceProperty("INTERFACE_COMPILE_DEFINITIONS", gt,
+ cmGeneratorExpression::InstallInterface,
+ properties, missingTargets);
+ this->PopulateInterfaceProperty("INTERFACE_COMPILE_OPTIONS", gt,
+ cmGeneratorExpression::InstallInterface,
+ properties, missingTargets);
+ this->PopulateInterfaceProperty("INTERFACE_AUTOUIC_OPTIONS", gt,
+ cmGeneratorExpression::InstallInterface,
+ properties, missingTargets);
+ this->PopulateInterfaceProperty("INTERFACE_COMPILE_FEATURES", gt,
+ cmGeneratorExpression::InstallInterface,
+ properties, missingTargets);
const bool newCMP0022Behavior =
- gt->GetPolicyStatusCMP0022() != cmPolicies::WARN
- && gt->GetPolicyStatusCMP0022() != cmPolicies::OLD;
- if (newCMP0022Behavior)
- {
- if (this->PopulateInterfaceLinkLibrariesProperty(gt,
- cmGeneratorExpression::InstallInterface,
- properties, missingTargets)
- && !this->ExportOld)
- {
+ gt->GetPolicyStatusCMP0022() != cmPolicies::WARN &&
+ gt->GetPolicyStatusCMP0022() != cmPolicies::OLD;
+ if (newCMP0022Behavior) {
+ if (this->PopulateInterfaceLinkLibrariesProperty(
+ gt, cmGeneratorExpression::InstallInterface, properties,
+ missingTargets) &&
+ !this->ExportOld) {
require2_8_12 = true;
- }
}
- if (gt->GetType() == cmState::INTERFACE_LIBRARY)
- {
+ }
+ if (gt->GetType() == cmState::INTERFACE_LIBRARY) {
require3_0_0 = true;
- }
- if(gt->GetProperty("INTERFACE_SOURCES"))
- {
+ }
+ if (gt->GetProperty("INTERFACE_SOURCES")) {
// We can only generate INTERFACE_SOURCES in CMake 3.3, but CMake 3.1
// can consume them.
require3_1_0 = true;
- }
+ }
- this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE",
- gt, properties);
+ this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", gt,
+ properties);
this->PopulateCompatibleInterfaceProperties(gt, properties);
this->GenerateInterfaceProperties(gt, os, properties);
- }
+ }
- if (require3_1_0)
- {
+ if (require3_1_0) {
this->GenerateRequiredCMakeVersion(os, "3.1.0");
- }
- else if (require3_0_0)
- {
+ } else if (require3_0_0) {
this->GenerateRequiredCMakeVersion(os, "3.0.0");
- }
- else if (require2_8_12)
- {
+ } else if (require2_8_12) {
this->GenerateRequiredCMakeVersion(os, "2.8.12");
- }
+ }
// Now load per-configuration properties for them.
/* clang-format off */
@@ -237,75 +214,62 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
bool result = true;
// Generate an import file for each configuration.
// Don't do this if we only export INTERFACE_LIBRARY targets.
- if (requiresConfigFiles)
- {
- for(std::vector<std::string>::const_iterator
- ci = this->Configurations.begin();
- ci != this->Configurations.end(); ++ci)
- {
- if(!this->GenerateImportFileConfig(*ci, missingTargets))
- {
+ if (requiresConfigFiles) {
+ for (std::vector<std::string>::const_iterator ci =
+ this->Configurations.begin();
+ ci != this->Configurations.end(); ++ci) {
+ if (!this->GenerateImportFileConfig(*ci, missingTargets)) {
result = false;
- }
}
}
+ }
this->GenerateMissingTargetsCheckCode(os, missingTargets);
return result;
}
-void
-cmExportInstallFileGenerator::ReplaceInstallPrefix(std::string &input)
+void cmExportInstallFileGenerator::ReplaceInstallPrefix(std::string& input)
{
std::string::size_type pos = 0;
std::string::size_type lastPos = pos;
- while((pos = input.find("$<INSTALL_PREFIX>", lastPos)) != input.npos)
- {
+ while ((pos = input.find("$<INSTALL_PREFIX>", lastPos)) != input.npos) {
std::string::size_type endPos = pos + sizeof("$<INSTALL_PREFIX>") - 1;
input.replace(pos, endPos - pos, "${_IMPORT_PREFIX}");
lastPos = endPos;
- }
+ }
}
-bool
-cmExportInstallFileGenerator::GenerateImportFileConfig(
- const std::string& config,
- std::vector<std::string> &missingTargets)
+bool cmExportInstallFileGenerator::GenerateImportFileConfig(
+ const std::string& config, std::vector<std::string>& missingTargets)
{
// Skip configurations not enabled for this export.
- if(!this->IEGen->InstallsForConfig(config))
- {
+ if (!this->IEGen->InstallsForConfig(config)) {
return true;
- }
+ }
// Construct the name of the file to generate.
std::string fileName = this->FileDir;
fileName += "/";
fileName += this->FileBase;
fileName += "-";
- if(!config.empty())
- {
+ if (!config.empty()) {
fileName += cmSystemTools::LowerCase(config);
- }
- else
- {
+ } else {
fileName += "noconfig";
- }
+ }
fileName += this->FileExt;
// Open the output file to generate it.
cmGeneratedFileStream exportFileStream(fileName.c_str(), true);
- if(!exportFileStream)
- {
+ if (!exportFileStream) {
std::string se = cmSystemTools::GetLastSystemError();
std::ostringstream e;
- e << "cannot write to file \"" << fileName
- << "\": " << se;
+ e << "cannot write to file \"" << fileName << "\": " << se;
cmSystemTools::Error(e.str().c_str());
return false;
- }
+ }
std::ostream& os = exportFileStream;
// Start with the import file header.
@@ -323,24 +287,19 @@ cmExportInstallFileGenerator::GenerateImportFileConfig(
return true;
}
-void
-cmExportInstallFileGenerator
-::GenerateImportTargetsConfig(std::ostream& os,
- const std::string& config,
- std::string const& suffix,
- std::vector<std::string> &missingTargets)
+void cmExportInstallFileGenerator::GenerateImportTargetsConfig(
+ std::ostream& os, const std::string& config, std::string const& suffix,
+ std::vector<std::string>& missingTargets)
{
// Add each target in the set to the export.
- for(std::vector<cmTargetExport*>::const_iterator
- tei = this->IEGen->GetExportSet()->GetTargetExports()->begin();
- tei != this->IEGen->GetExportSet()->GetTargetExports()->end(); ++tei)
- {
+ for (std::vector<cmTargetExport*>::const_iterator tei =
+ this->IEGen->GetExportSet()->GetTargetExports()->begin();
+ tei != this->IEGen->GetExportSet()->GetTargetExports()->end(); ++tei) {
// Collect import properties for this target.
cmTargetExport const* te = *tei;
- if (te->Target->GetType() == cmState::INTERFACE_LIBRARY)
- {
+ if (te->Target->GetType() == cmState::INTERFACE_LIBRARY) {
continue;
- }
+ }
ImportPropertyMap properties;
std::set<std::string> importedLocations;
@@ -349,9 +308,8 @@ cmExportInstallFileGenerator
properties, importedLocations);
this->SetImportLocationProperty(config, suffix, te->LibraryGenerator,
properties, importedLocations);
- this->SetImportLocationProperty(config, suffix,
- te->RuntimeGenerator, properties,
- importedLocations);
+ this->SetImportLocationProperty(config, suffix, te->RuntimeGenerator,
+ properties, importedLocations);
this->SetImportLocationProperty(config, suffix, te->FrameworkGenerator,
properties, importedLocations);
this->SetImportLocationProperty(config, suffix, te->BundleGenerator,
@@ -359,12 +317,11 @@ cmExportInstallFileGenerator
// If any file location was set for the target add it to the
// import file.
- if(!properties.empty())
- {
+ if (!properties.empty()) {
// Get the rest of the target details.
- cmGeneratorTarget *gtgt = te->Target;
- this->SetImportDetailProperties(config, suffix,
- gtgt, properties, missingTargets);
+ cmGeneratorTarget* gtgt = te->Target;
+ this->SetImportDetailProperties(config, suffix, gtgt, properties,
+ missingTargets);
this->SetImportLinkInterface(config, suffix,
cmGeneratorExpression::InstallInterface,
@@ -380,24 +337,19 @@ cmExportInstallFileGenerator
this->GenerateImportPropertyCode(os, config, gtgt, properties);
this->GenerateImportedFileChecksCode(os, gtgt, properties,
importedLocations);
- }
}
+ }
}
-void
-cmExportInstallFileGenerator
-::SetImportLocationProperty(const std::string& config,
- std::string const& suffix,
- cmInstallTargetGenerator* itgen,
- ImportPropertyMap& properties,
- std::set<std::string>& importedLocations
- )
+void cmExportInstallFileGenerator::SetImportLocationProperty(
+ const std::string& config, std::string const& suffix,
+ cmInstallTargetGenerator* itgen, ImportPropertyMap& properties,
+ std::set<std::string>& importedLocations)
{
// Skip rules that do not match this configuration.
- if(!(itgen && itgen->InstallsForConfig(config)))
- {
+ if (!(itgen && itgen->InstallsForConfig(config))) {
return;
- }
+ }
// Get the target to be installed.
cmGeneratorTarget* target = itgen->GetTarget();
@@ -405,16 +357,14 @@ cmExportInstallFileGenerator
// Construct the installed location of the target.
std::string dest = itgen->GetDestination(config);
std::string value;
- if(!cmSystemTools::FileIsFullPath(dest.c_str()))
- {
+ if (!cmSystemTools::FileIsFullPath(dest.c_str())) {
// The target is installed relative to the installation prefix.
value = "${_IMPORT_PREFIX}/";
- }
+ }
value += dest;
value += "/";
- if(itgen->IsImportLibrary())
- {
+ if (itgen->IsImportLibrary()) {
// Construct the property name.
std::string prop = "IMPORTED_IMPLIB";
prop += suffix;
@@ -426,132 +376,106 @@ cmExportInstallFileGenerator
// Store the property.
properties[prop] = value;
importedLocations.insert(prop);
- }
- else
- {
+ } else {
// Construct the property name.
std::string prop = "IMPORTED_LOCATION";
prop += suffix;
// Append the installed file name.
- if(target->IsAppBundleOnApple())
- {
+ if (target->IsAppBundleOnApple()) {
value += itgen->GetInstallFilename(target, config);
value += ".app/Contents/MacOS/";
value += itgen->GetInstallFilename(target, config);
- }
- else
- {
+ } else {
value += itgen->GetInstallFilename(target, config,
cmInstallTargetGenerator::NameReal);
- }
+ }
// Store the property.
properties[prop] = value;
importedLocations.insert(prop);
- }
+ }
}
-void
-cmExportInstallFileGenerator::HandleMissingTarget(std::string& link_libs,
- std::vector<std::string>& missingTargets,
+void cmExportInstallFileGenerator::HandleMissingTarget(
+ std::string& link_libs, std::vector<std::string>& missingTargets,
cmGeneratorTarget* depender, cmGeneratorTarget* dependee)
{
const std::string name = dependee->GetName();
cmGlobalGenerator* gg = dependee->GetLocalGenerator()->GetGlobalGenerator();
std::vector<std::string> namespaces = this->FindNamespaces(gg, name);
int targetOccurrences = (int)namespaces.size();
- if (targetOccurrences == 1)
- {
+ if (targetOccurrences == 1) {
std::string missingTarget = namespaces[0];
missingTarget += dependee->GetExportName();
link_libs += missingTarget;
missingTargets.push_back(missingTarget);
- }
- else
- {
+ } else {
// All exported targets should be known here and should be unique.
// This is probably user-error.
this->ComplainAboutMissingTarget(depender, dependee, targetOccurrences);
- }
+ }
}
-std::vector<std::string>
-cmExportInstallFileGenerator
-::FindNamespaces(cmGlobalGenerator* gg, const std::string& name)
+std::vector<std::string> cmExportInstallFileGenerator::FindNamespaces(
+ cmGlobalGenerator* gg, const std::string& name)
{
std::vector<std::string> namespaces;
const cmExportSetMap& exportSets = gg->GetExportSets();
- for(cmExportSetMap::const_iterator expIt = exportSets.begin();
- expIt != exportSets.end();
- ++expIt)
- {
+ for (cmExportSetMap::const_iterator expIt = exportSets.begin();
+ expIt != exportSets.end(); ++expIt) {
const cmExportSet* exportSet = expIt->second;
std::vector<cmTargetExport*> const* targets =
- exportSet->GetTargetExports();
+ exportSet->GetTargetExports();
bool containsTarget = false;
- for(unsigned int i=0; i<targets->size(); i++)
- {
- if (name == (*targets)[i]->TargetName)
- {
+ for (unsigned int i = 0; i < targets->size(); i++) {
+ if (name == (*targets)[i]->TargetName) {
containsTarget = true;
break;
- }
}
+ }
- if (containsTarget)
- {
+ if (containsTarget) {
std::vector<cmInstallExportGenerator const*> const* installs =
- exportSet->GetInstallations();
- for(unsigned int i=0; i<installs->size(); i++)
- {
+ exportSet->GetInstallations();
+ for (unsigned int i = 0; i < installs->size(); i++) {
namespaces.push_back((*installs)[i]->GetNamespace());
- }
}
}
+ }
return namespaces;
}
-void
-cmExportInstallFileGenerator
-::ComplainAboutMissingTarget(cmGeneratorTarget* depender,
- cmGeneratorTarget* dependee,
- int occurrences)
+void cmExportInstallFileGenerator::ComplainAboutMissingTarget(
+ cmGeneratorTarget* depender, cmGeneratorTarget* dependee, int occurrences)
{
std::ostringstream e;
- e << "install(EXPORT \""
- << this->IEGen->GetExportSet()->GetName()
+ e << "install(EXPORT \"" << this->IEGen->GetExportSet()->GetName()
<< "\" ...) "
<< "includes target \"" << depender->GetName()
<< "\" which requires target \"" << dependee->GetName() << "\" ";
- if (occurrences == 0)
- {
+ if (occurrences == 0) {
e << "that is not in the export set.";
- }
- else
- {
+ } else {
e << "that is not in this export set, but " << occurrences
- << " times in others.";
- }
+ << " times in others.";
+ }
cmSystemTools::Error(e.str().c_str());
}
-std::string
-cmExportInstallFileGenerator::InstallNameDir(cmGeneratorTarget* target,
- const std::string&)
+std::string cmExportInstallFileGenerator::InstallNameDir(
+ cmGeneratorTarget* target, const std::string&)
{
std::string install_name_dir;
cmMakefile* mf = target->Target->GetMakefile();
- if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
- {
- install_name_dir =
- target->GetInstallNameDirForInstallTree();
- }
+ if (mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) {
+ install_name_dir = target->GetInstallNameDirForInstallTree();
+ }
return install_name_dir;
}
diff --git a/Source/cmExportInstallFileGenerator.h b/Source/cmExportInstallFileGenerator.h
index 13dae89..723b6e5 100644
--- a/Source/cmExportInstallFileGenerator.h
+++ b/Source/cmExportInstallFileGenerator.h
@@ -31,7 +31,7 @@ class cmInstallTargetGenerator;
*
* This is used to implement the INSTALL(EXPORT) command.
*/
-class cmExportInstallFileGenerator: public cmExportFileGenerator
+class cmExportInstallFileGenerator : public cmExportFileGenerator
{
public:
/** Construct with the export installer that will install the
@@ -42,25 +42,26 @@ public:
maps from the configuration name to the file temporary location
for installation. */
std::map<std::string, std::string> const& GetConfigImportFiles()
- { return this->ConfigImportFiles; }
+ {
+ return this->ConfigImportFiles;
+ }
/** Compute the globbing expression used to load per-config import
files from the main file. */
std::string GetConfigImportFileGlob();
-protected:
+protected:
// Implement virtual methods from the superclass.
virtual bool GenerateMainFile(std::ostream& os);
- virtual void GenerateImportTargetsConfig(std::ostream& os,
- const std::string& config,
- std::string const& suffix,
- std::vector<std::string> &missingTargets);
+ virtual void GenerateImportTargetsConfig(
+ std::ostream& os, const std::string& config, std::string const& suffix,
+ std::vector<std::string>& missingTargets);
virtual void HandleMissingTarget(std::string& link_libs,
std::vector<std::string>& missingTargets,
cmGeneratorTarget* depender,
cmGeneratorTarget* dependee);
- virtual void ReplaceInstallPrefix(std::string &input);
+ virtual void ReplaceInstallPrefix(std::string& input);
void ComplainAboutMissingTarget(cmGeneratorTarget* depender,
cmGeneratorTarget* dependee,
@@ -69,18 +70,16 @@ protected:
std::vector<std::string> FindNamespaces(cmGlobalGenerator* gg,
const std::string& name);
-
/** Generate a per-configuration file for the targets. */
bool GenerateImportFileConfig(const std::string& config,
- std::vector<std::string> &missingTargets);
+ std::vector<std::string>& missingTargets);
/** Fill in properties indicating installed file locations. */
void SetImportLocationProperty(const std::string& config,
std::string const& suffix,
cmInstallTargetGenerator* itgen,
ImportPropertyMap& properties,
- std::set<std::string>& importedLocations
- );
+ std::set<std::string>& importedLocations);
std::string InstallNameDir(cmGeneratorTarget* target,
const std::string& config);
diff --git a/Source/cmExportLibraryDependenciesCommand.cxx b/Source/cmExportLibraryDependenciesCommand.cxx
index a715070..ab43aa8 100644
--- a/Source/cmExportLibraryDependenciesCommand.cxx
+++ b/Source/cmExportLibraryDependenciesCommand.cxx
@@ -18,33 +18,31 @@
#include <cmsys/auto_ptr.hxx>
-bool cmExportLibraryDependenciesCommand
-::InitialPass(std::vector<std::string> const& args, 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.size() < 1 )
- {
+ if (this->Disallowed(
+ cmPolicies::CMP0033,
+ "The export_library_dependencies command should not be called; "
+ "see CMP0033.")) {
+ return true;
+ }
+ if (args.size() < 1) {
this->SetError("called with incorrect number of arguments");
return false;
- }
+ }
// store the arguments for the final pass
this->Filename = args[0];
this->Append = false;
- if(args.size() > 1)
- {
- if(args[1] == "APPEND")
- {
+ if (args.size() > 1) {
+ if (args[1] == "APPEND") {
this->Append = true;
- }
}
+ }
return true;
}
-
void cmExportLibraryDependenciesCommand::FinalPass()
{
// export_library_dependencies() shouldn't modify anything
@@ -56,27 +54,23 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const
{
// Use copy-if-different if not appending.
cmsys::auto_ptr<cmsys::ofstream> foutPtr;
- if(this->Append)
- {
+ if (this->Append) {
cmsys::auto_ptr<cmsys::ofstream> ap(
new cmsys::ofstream(this->Filename.c_str(), std::ios::app));
foutPtr = ap;
- }
- else
- {
+ } else {
cmsys::auto_ptr<cmGeneratedFileStream> ap(
new cmGeneratedFileStream(this->Filename.c_str(), true));
ap->SetCopyIfDifferent(true);
foutPtr = ap;
- }
+ }
std::ostream& fout = *foutPtr.get();
- if (!fout)
- {
+ if (!fout) {
cmSystemTools::Error("Error Writing ", this->Filename.c_str());
cmSystemTools::ReportLastSystemError("");
return;
- }
+ }
// Collect dependency information about all library targets built in
// the project.
@@ -86,22 +80,18 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const
std::map<std::string, std::string> libDepsOld;
std::map<std::string, std::string> libDepsNew;
std::map<std::string, std::string> libTypes;
- for(std::vector<cmMakefile*>::const_iterator i = locals.begin();
- i != locals.end(); ++i)
- {
- const cmTargets &tgts = (*i)->GetTargets();
- for(cmTargets::const_iterator l = tgts.begin();
- l != tgts.end(); ++l)
- {
+ for (std::vector<cmMakefile*>::const_iterator i = locals.begin();
+ i != locals.end(); ++i) {
+ const cmTargets& tgts = (*i)->GetTargets();
+ for (cmTargets::const_iterator l = tgts.begin(); l != tgts.end(); ++l) {
// Get the current target.
cmTarget const& target = l->second;
// Skip non-library targets.
- if(target.GetType() < cmState::STATIC_LIBRARY
- || target.GetType() > cmState::MODULE_LIBRARY)
- {
+ if (target.GetType() < cmState::STATIC_LIBRARY ||
+ target.GetType() > cmState::MODULE_LIBRARY) {
continue;
- }
+ }
// Construct the dependency variable name.
std::string targetEntry = target.GetName();
@@ -113,14 +103,12 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const
std::string valueNew;
cmTarget::LinkLibraryVectorType const& libs =
target.GetOriginalLinkLibraries();
- for(cmTarget::LinkLibraryVectorType::const_iterator li = libs.begin();
- li != libs.end(); ++li)
- {
+ for (cmTarget::LinkLibraryVectorType::const_iterator li = libs.begin();
+ li != libs.end(); ++li) {
std::string ltVar = li->first;
ltVar += "_LINK_TYPE";
std::string ltValue;
- switch(li->second)
- {
+ switch (li->second) {
case GENERAL_LibraryType:
valueNew += "general;";
ltValue = "general";
@@ -133,73 +121,62 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const
valueNew += "optimized;";
ltValue = "optimized";
break;
- }
+ }
std::string lib = li->first;
- if(cmTarget* libtgt = global->FindTarget(lib))
- {
+ if (cmTarget* libtgt = global->FindTarget(lib)) {
// Handle simple output name changes. This command is
// deprecated so we do not support full target name
// translation (which requires per-configuration info).
- if(const char* outname = libtgt->GetProperty("OUTPUT_NAME"))
- {
+ if (const char* outname = libtgt->GetProperty("OUTPUT_NAME")) {
lib = outname;
- }
}
+ }
valueOld += lib;
valueOld += ";";
valueNew += lib;
valueNew += ";";
std::string& ltEntry = libTypes[ltVar];
- if(ltEntry.empty())
- {
+ if (ltEntry.empty()) {
ltEntry = ltValue;
- }
- else if(ltEntry != ltValue)
- {
+ } else if (ltEntry != ltValue) {
ltEntry = "general";
- }
}
+ }
libDepsNew[targetEntry] = valueNew;
libDepsOld[targetEntry] = valueOld;
- }
}
+ }
// Generate dependency information for both old and new style CMake
// versions.
const char* vertest =
"\"${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}\" GREATER 2.4";
- fout << "# Generated by CMake " << cmVersion::GetCMakeVersion() << "\n\n";
+ fout << "# Generated by CMake " << cmVersion::GetCMakeVersion() << "\n\n";
fout << "if(" << vertest << ")\n";
fout << " # Information for CMake 2.6 and above.\n";
- for(std::map<std::string, std::string>::const_iterator
- i = libDepsNew.begin();
- i != libDepsNew.end(); ++i)
- {
- if(!i->second.empty())
- {
+ for (std::map<std::string, std::string>::const_iterator i =
+ libDepsNew.begin();
+ i != libDepsNew.end(); ++i) {
+ if (!i->second.empty()) {
fout << " set(\"" << i->first << "\" \"" << i->second << "\")\n";
- }
}
+ }
fout << "else()\n";
fout << " # Information for CMake 2.4 and lower.\n";
- for(std::map<std::string, std::string>::const_iterator
- i = libDepsOld.begin();
- i != libDepsOld.end(); ++i)
- {
- if(!i->second.empty())
- {
+ for (std::map<std::string, std::string>::const_iterator i =
+ libDepsOld.begin();
+ i != libDepsOld.end(); ++i) {
+ if (!i->second.empty()) {
fout << " set(\"" << i->first << "\" \"" << i->second << "\")\n";
- }
}
- for(std::map<std::string, std::string>::const_iterator i = libTypes.begin();
- i != libTypes.end(); ++i)
- {
- if(i->second != "general")
- {
+ }
+ for (std::map<std::string, std::string>::const_iterator i = libTypes.begin();
+ i != libTypes.end(); ++i) {
+ if (i->second != "general") {
fout << " set(\"" << i->first << "\" \"" << i->second << "\")\n";
- }
}
+ }
fout << "endif()\n";
return;
}
diff --git a/Source/cmExportLibraryDependenciesCommand.h b/Source/cmExportLibraryDependenciesCommand.h
index 81aa21a..3fb3565 100644
--- a/Source/cmExportLibraryDependenciesCommand.h
+++ b/Source/cmExportLibraryDependenciesCommand.h
@@ -20,8 +20,8 @@ public:
cmTypeMacro(cmExportLibraryDependenciesCommand, cmCommand);
virtual cmCommand* Clone() { return new cmExportLibraryDependenciesCommand; }
virtual bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus &status);
- virtual std::string GetName() const { return "export_library_dependencies";}
+ cmExecutionStatus& status);
+ virtual std::string GetName() const { return "export_library_dependencies"; }
virtual void FinalPass();
virtual bool HasFinalPass() const { return true; }
@@ -32,5 +32,4 @@ private:
void ConstFinalPass() const;
};
-
#endif
diff --git a/Source/cmExportSet.cxx b/Source/cmExportSet.cxx
index 83c4fdc..c468e3e 100644
--- a/Source/cmExportSet.cxx
+++ b/Source/cmExportSet.cxx
@@ -24,10 +24,9 @@ cmExportSet::~cmExportSet()
void cmExportSet::Compute(cmLocalGenerator* lg)
{
for (std::vector<cmTargetExport*>::iterator it = this->TargetExports.begin();
- it != this->TargetExports.end(); ++it)
- {
+ it != this->TargetExports.end(); ++it) {
(*it)->Target = lg->FindGeneratorTargetToUse((*it)->TargetName);
- }
+ }
}
void cmExportSet::AddTargetExport(cmTargetExport* te)
diff --git a/Source/cmExportSet.h b/Source/cmExportSet.h
index a3359ac..49f2cac 100644
--- a/Source/cmExportSet.h
+++ b/Source/cmExportSet.h
@@ -23,7 +23,10 @@ class cmExportSet
{
public:
/// Construct an empty export set named \a name
- cmExportSet(const std::string &name) : Name(name) {}
+ cmExportSet(const std::string& name)
+ : Name(name)
+ {
+ }
/// Destructor
~cmExportSet();
@@ -36,10 +39,14 @@ public:
std::string const& GetName() const { return this->Name; }
std::vector<cmTargetExport*> const* GetTargetExports() const
- { return &this->TargetExports; }
+ {
+ return &this->TargetExports;
+ }
std::vector<cmInstallExportGenerator const*> const* GetInstallations() const
- { return &this->Installations; }
+ {
+ return &this->Installations;
+ }
private:
std::vector<cmTargetExport*> TargetExports;
diff --git a/Source/cmExportSetMap.cxx b/Source/cmExportSetMap.cxx
index d267cd3..ac1c66e 100644
--- a/Source/cmExportSetMap.cxx
+++ b/Source/cmExportSetMap.cxx
@@ -15,13 +15,13 @@
#include "cmAlgorithms.h"
#include "cmExportSet.h"
-cmExportSet* cmExportSetMap::operator[](const std::string &name)
+cmExportSet* cmExportSetMap::operator[](const std::string& name)
{
std::map<std::string, cmExportSet*>::iterator it = this->find(name);
if (it == this->end()) // Export set not found
- {
+ {
it = this->insert(std::make_pair(name, new cmExportSet(name))).first;
- }
+ }
return it->second;
}
diff --git a/Source/cmExportSetMap.h b/Source/cmExportSetMap.h
index 87f2060..d2954e3 100644
--- a/Source/cmExportSetMap.h
+++ b/Source/cmExportSetMap.h
@@ -20,13 +20,14 @@ class cmExportSet;
class cmExportSetMap : public std::map<std::string, cmExportSet*>
{
typedef std::map<std::string, cmExportSet*> derived;
+
public:
/** \brief Overloaded operator[].
*
* The operator is overloaded because cmExportSet has no default constructor:
* we do not want unnamed export sets.
*/
- cmExportSet* operator[](const std::string &name);
+ cmExportSet* operator[](const std::string& name);
void clear();
diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx
index 891af84..5a826f2 100644
--- a/Source/cmExportTryCompileFileGenerator.cxx
+++ b/Source/cmExportTryCompileFileGenerator.cxx
@@ -18,9 +18,8 @@
#include "cmLocalGenerator.h"
cmExportTryCompileFileGenerator::cmExportTryCompileFileGenerator(
- cmGlobalGenerator* gg,
- const std::vector<std::string>& targets,
- cmMakefile* mf)
+ cmGlobalGenerator* gg, const std::vector<std::string>& targets,
+ cmMakefile* mf)
{
gg->CreateImportedGenerationObjects(mf, targets, this->Exports);
}
@@ -29,19 +28,17 @@ bool cmExportTryCompileFileGenerator::GenerateMainFile(std::ostream& os)
{
std::set<cmGeneratorTarget const*> emitted;
std::set<cmGeneratorTarget const*> emittedDeps;
- while(!this->Exports.empty())
- {
+ while (!this->Exports.empty()) {
cmGeneratorTarget const* te = this->Exports.back();
this->Exports.pop_back();
- if (emitted.insert(te).second)
- {
+ if (emitted.insert(te).second) {
emittedDeps.insert(te);
this->GenerateImportTargetCode(os, te);
ImportPropertyMap properties;
-#define FIND_TARGETS(PROPERTY) \
- this->FindTargets("INTERFACE_" #PROPERTY, te, emittedDeps);
+#define FIND_TARGETS(PROPERTY) \
+ this->FindTargets("INTERFACE_" #PROPERTY, te, emittedDeps);
CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(FIND_TARGETS)
@@ -50,27 +47,23 @@ bool cmExportTryCompileFileGenerator::GenerateMainFile(std::ostream& os)
this->PopulateProperties(te, properties, emittedDeps);
this->GenerateInterfaceProperties(te, os, properties);
- }
}
+ }
return true;
}
std::string cmExportTryCompileFileGenerator::FindTargets(
- const std::string& propName,
- cmGeneratorTarget const* tgt,
- std::set<cmGeneratorTarget const*> &emitted)
+ const std::string& propName, cmGeneratorTarget const* tgt,
+ std::set<cmGeneratorTarget const*>& emitted)
{
- const char *prop = tgt->GetProperty(propName);
- if(!prop)
- {
+ const char* prop = tgt->GetProperty(propName);
+ if (!prop) {
return std::string();
- }
+ }
cmGeneratorExpression ge;
- cmGeneratorExpressionDAGChecker dagChecker(
- tgt->GetName(),
- propName, 0, 0);
+ cmGeneratorExpressionDAGChecker dagChecker(tgt->GetName(), propName, 0, 0);
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(prop);
@@ -81,70 +74,58 @@ std::string cmExportTryCompileFileGenerator::FindTargets(
cmGeneratorTarget gDummyHead(&dummyHead, tgt->GetLocalGenerator());
std::string result = cge->Evaluate(tgt->GetLocalGenerator(), this->Config,
- false, &gDummyHead,
- tgt, &dagChecker);
-
- const std::set<cmGeneratorTarget const*> &allTargets =
- cge->GetAllTargetsSeen();
- for(std::set<cmGeneratorTarget const*>::const_iterator li =
- allTargets.begin(); li != allTargets.end(); ++li)
- {
- if(emitted.insert(*li).second)
- {
+ false, &gDummyHead, tgt, &dagChecker);
+
+ const std::set<cmGeneratorTarget const*>& allTargets =
+ cge->GetAllTargetsSeen();
+ for (std::set<cmGeneratorTarget const*>::const_iterator li =
+ allTargets.begin();
+ li != allTargets.end(); ++li) {
+ if (emitted.insert(*li).second) {
this->Exports.push_back(*li);
- }
}
+ }
return result;
}
-void
-cmExportTryCompileFileGenerator::PopulateProperties(
- const cmGeneratorTarget* target,
- ImportPropertyMap& properties,
- std::set<cmGeneratorTarget const*> &emitted)
+void cmExportTryCompileFileGenerator::PopulateProperties(
+ const cmGeneratorTarget* target, ImportPropertyMap& properties,
+ std::set<cmGeneratorTarget const*>& emitted)
{
std::vector<std::string> props = target->GetPropertyKeys();
- for(std::vector<std::string>::const_iterator i = props.begin();
- i != props.end(); ++i)
- {
+ for (std::vector<std::string>::const_iterator i = props.begin();
+ i != props.end(); ++i) {
properties[*i] = target->GetProperty(*i);
- if(i->find("IMPORTED_LINK_INTERFACE_LIBRARIES") == 0
- || i->find("IMPORTED_LINK_DEPENDENT_LIBRARIES") == 0
- || i->find("INTERFACE_LINK_LIBRARIES") == 0)
- {
- std::string evalResult = this->FindTargets(*i,
- target, emitted);
+ if (i->find("IMPORTED_LINK_INTERFACE_LIBRARIES") == 0 ||
+ i->find("IMPORTED_LINK_DEPENDENT_LIBRARIES") == 0 ||
+ i->find("INTERFACE_LINK_LIBRARIES") == 0) {
+ std::string evalResult = this->FindTargets(*i, target, emitted);
std::vector<std::string> depends;
cmSystemTools::ExpandListArgument(evalResult, depends);
- for(std::vector<std::string>::const_iterator li = depends.begin();
- li != depends.end(); ++li)
- {
- cmGeneratorTarget *tgt =
- target->GetLocalGenerator()->FindGeneratorTargetToUse(*li);
- if(tgt && emitted.insert(tgt).second)
- {
+ for (std::vector<std::string>::const_iterator li = depends.begin();
+ li != depends.end(); ++li) {
+ cmGeneratorTarget* tgt =
+ target->GetLocalGenerator()->FindGeneratorTargetToUse(*li);
+ if (tgt && emitted.insert(tgt).second) {
this->Exports.push_back(tgt);
- }
}
}
}
+ }
}
-std::string
-cmExportTryCompileFileGenerator::InstallNameDir(cmGeneratorTarget* target,
- const std::string& config)
+std::string cmExportTryCompileFileGenerator::InstallNameDir(
+ cmGeneratorTarget* target, const std::string& config)
{
std::string install_name_dir;
cmMakefile* mf = target->Target->GetMakefile();
- if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
- {
- install_name_dir =
- target->GetInstallNameDirForBuildTree(config);
- }
+ if (mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) {
+ install_name_dir = target->GetInstallNameDirForBuildTree(config);
+ }
return install_name_dir;
}
diff --git a/Source/cmExportTryCompileFileGenerator.h b/Source/cmExportTryCompileFileGenerator.h
index fc135a4..26f4db1 100644
--- a/Source/cmExportTryCompileFileGenerator.h
+++ b/Source/cmExportTryCompileFileGenerator.h
@@ -17,7 +17,7 @@
class cmInstallExportGenerator;
class cmInstallTargetGenerator;
-class cmExportTryCompileFileGenerator: public cmExportFileGenerator
+class cmExportTryCompileFileGenerator : public cmExportFileGenerator
{
public:
cmExportTryCompileFileGenerator(cmGlobalGenerator* gg,
@@ -27,18 +27,18 @@ public:
/** Set the list of targets to export. */
void SetConfig(const std::string& config) { this->Config = config; }
protected:
-
// Implement virtual methods from the superclass.
virtual bool GenerateMainFile(std::ostream& os);
- virtual void GenerateImportTargetsConfig(std::ostream&,
- const std::string&,
+ virtual void GenerateImportTargetsConfig(std::ostream&, const std::string&,
std::string const&,
- std::vector<std::string>&) {}
- virtual void HandleMissingTarget(std::string&,
- std::vector<std::string>&,
- cmGeneratorTarget*,
- cmGeneratorTarget*) {}
+ std::vector<std::string>&)
+ {
+ }
+ virtual void HandleMissingTarget(std::string&, std::vector<std::string>&,
+ cmGeneratorTarget*, cmGeneratorTarget*)
+ {
+ }
void PopulateProperties(cmGeneratorTarget const* target,
ImportPropertyMap& properties,
@@ -46,12 +46,12 @@ protected:
std::string InstallNameDir(cmGeneratorTarget* target,
const std::string& config);
+
private:
std::string FindTargets(const std::string& prop,
const cmGeneratorTarget* tgt,
std::set<const cmGeneratorTarget*>& emitted);
-
std::vector<cmGeneratorTarget const*> Exports;
std::string Config;
};
diff --git a/Source/cmExprParserHelper.cxx b/Source/cmExprParserHelper.cxx
index c5ecde4..2ba9b8d 100644
--- a/Source/cmExprParserHelper.cxx
+++ b/Source/cmExprParserHelper.cxx
@@ -16,7 +16,7 @@
#include "cmExprLexer.h"
-int cmExpr_yyparse( yyscan_t yyscanner );
+int cmExpr_yyparse(yyscan_t yyscanner);
//
cmExprParserHelper::cmExprParserHelper()
{
@@ -24,7 +24,6 @@ cmExprParserHelper::cmExprParserHelper()
this->FileName = 0;
}
-
cmExprParserHelper::~cmExprParserHelper()
{
this->CleanupParser();
@@ -32,11 +31,10 @@ cmExprParserHelper::~cmExprParserHelper()
int cmExprParserHelper::ParseString(const char* str, int verb)
{
- if ( !str)
- {
+ if (!str) {
return 0;
- }
- //printf("Do some parsing: %s\n", str);
+ }
+ // printf("Do some parsing: %s\n", str);
this->Verbose = verb;
this->InputBuffer = str;
@@ -50,20 +48,18 @@ int cmExprParserHelper::ParseString(const char* str, int verb)
cmExpr_yyset_extra(this, yyscanner);
int res = cmExpr_yyparse(yyscanner);
cmExpr_yylex_destroy(yyscanner);
- if ( res != 0 )
- {
- //str << "CAL_Parser returned: " << res << std::endl;
- //std::cerr << "When parsing: [" << str << "]" << std::endl;
+ if (res != 0) {
+ // str << "CAL_Parser returned: " << res << std::endl;
+ // std::cerr << "When parsing: [" << str << "]" << std::endl;
return 0;
- }
+ }
this->CleanupParser();
- if ( Verbose )
- {
- std::cerr << "Expanding [" << str << "] produced: ["
- << this->Result << "]" << std::endl;
- }
+ if (Verbose) {
+ std::cerr << "Expanding [" << str << "] produced: [" << this->Result << "]"
+ << std::endl;
+ }
return 1;
}
@@ -73,27 +69,22 @@ void cmExprParserHelper::CleanupParser()
int cmExprParserHelper::LexInput(char* buf, int maxlen)
{
- //std::cout << "JPLexInput ";
- //std::cout.write(buf, maxlen);
- //std::cout << std::endl;
- if ( maxlen < 1 )
- {
+ // std::cout << "JPLexInput ";
+ // std::cout.write(buf, maxlen);
+ // std::cout << std::endl;
+ if (maxlen < 1) {
return 0;
+ }
+ if (this->InputBufferPos < this->InputBuffer.size()) {
+ buf[0] = this->InputBuffer[this->InputBufferPos++];
+ if (buf[0] == '\n') {
+ this->CurrentLine++;
}
- if ( this->InputBufferPos < this->InputBuffer.size() )
- {
- buf[0] = this->InputBuffer[ this->InputBufferPos++ ];
- if ( buf[0] == '\n' )
- {
- this->CurrentLine ++;
- }
- return(1);
- }
- else
- {
+ return (1);
+ } else {
buf[0] = '\n';
- return( 0 );
- }
+ return (0);
+ }
}
void cmExprParserHelper::Error(const char* str)
@@ -108,5 +99,3 @@ void cmExprParserHelper::SetResult(int value)
{
this->Result = value;
}
-
-
diff --git a/Source/cmExprParserHelper.h b/Source/cmExprParserHelper.h
index 8d6b2cd..af0b916 100644
--- a/Source/cmExprParserHelper.h
+++ b/Source/cmExprParserHelper.h
@@ -30,7 +30,8 @@ class cmMakefile;
class cmExprParserHelper
{
public:
- typedef struct {
+ typedef struct
+ {
int Number;
} ParserType;
@@ -66,6 +67,3 @@ private:
};
#endif
-
-
-
diff --git a/Source/cmExternalMakefileProjectGenerator.cxx b/Source/cmExternalMakefileProjectGenerator.cxx