summaryrefslogtreecommitdiffstats
path: root/Source/CPack/cpack.cxx
diff options
context:
space:
mode:
authorEric NOULARD <eric.noulard@gmail.com>2012-01-02 23:54:08 (GMT)
committerEric NOULARD <eric.noulard@gmail.com>2012-01-22 12:31:24 (GMT)
commit1629615a10df10296ba6588f66a680eed424f9ba (patch)
tree4a59c67918578b94dbced9f0fde63f7af3005af2 /Source/CPack/cpack.cxx
parent83e34dd9e688b4721c70c56e66629bdc2768fa77 (diff)
downloadCMake-1629615a10df10296ba6588f66a680eed424f9ba.zip
CMake-1629615a10df10296ba6588f66a680eed424f9ba.tar.gz
CMake-1629615a10df10296ba6588f66a680eed424f9ba.tar.bz2
CPack Documentation extraction from CMake script begins to work
- Enhance extract doc parser. Seems robust now. The legacy module documentation parser works as before ignoring the new markup. - Proof of concept for CPack (generic), CPack RPM and CPack Deb generator for macro and variables. Try cpack --help-command and cpack --help-variables
Diffstat (limited to 'Source/CPack/cpack.cxx')
-rw-r--r--Source/CPack/cpack.cxx103
1 files changed, 54 insertions, 49 deletions
diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx
index 8e59fa0..4117971 100644
--- a/Source/CPack/cpack.cxx
+++ b/Source/CPack/cpack.cxx
@@ -303,29 +303,30 @@ int main (int argc, char *argv[])
help = false;
}
- 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
+ // This part is used for cpack documentation lookup as well.
+ cminst.AddCMakePaths();
+ std::string systemFile =
+ globalMF->GetModulesFile("CMakeDetermineSystem.cmake");
+ if (!globalMF->ReadListFile(0, systemFile.c_str()))
{
- // find out which system cpack is running on, so it can setup the search
- // paths, so FIND_XXX() commands can be used in scripts
- cminst.AddCMakePaths();
- std::string systemFile =
- globalMF->GetModulesFile("CMakeDetermineSystem.cmake");
- if (!globalMF->ReadListFile(0, systemFile.c_str()))
- {
- cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
- "Error reading CMakeDetermineSystem.cmake" << std::endl);
- return 1;
- }
+ cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
+ "Error reading CMakeDetermineSystem.cmake" << std::endl);
+ return 1;
+ }
- systemFile =
- globalMF->GetModulesFile("CMakeSystemSpecificInformation.cmake");
- if (!globalMF->ReadListFile(0, systemFile.c_str()))
- {
- cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
- "Error reading CMakeSystemSpecificInformation.cmake" << std::endl);
- return 1;
- }
+ systemFile =
+ globalMF->GetModulesFile("CMakeSystemSpecificInformation.cmake");
+ if (!globalMF->ReadListFile(0, systemFile.c_str()))
+ {
+ cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
+ "Error reading CMakeSystemSpecificInformation.cmake" << std::endl);
+ return 1;
+ }
+ if ( parsed && !help )
+ {
if ( cmSystemTools::FileExists(cpackConfigFile.c_str()) )
{
cpackConfigFile =
@@ -519,43 +520,47 @@ int main (int argc, char *argv[])
doc.SetSection("Description",cmDocumentationDescription);
doc.PrependSection("Options",cmDocumentationOptions);
+ // statically (in C++ code) defined variables
cmCPackDocumentVariables::DefineVariables(&cminst);
std::vector<cmDocumentationEntry> commands;
- cminst.AddCMakePaths();
- std::string systemFile =
- globalMF->GetModulesFile("CMakeDetermineSystem.cmake");
- if (!globalMF->ReadListFile(0, systemFile.c_str()))
- {
- cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
- "Error reading CMakeDetermineSystem.cmake" << std::endl);
- return 1;
- }
-
- systemFile =
- globalMF->GetModulesFile("CMakeSystemSpecificInformation.cmake");
- if (!globalMF->ReadListFile(0, systemFile.c_str()))
- {
- cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
- "Error reading CMakeSystemSpecificInformation.cmake"
- << std::endl);
- return 1;
- }
- std::string cpFile = globalMF->GetModulesFile("CPack.cmake");
- doc.getStructuredDocFromFile(cpFile.c_str(),
- commands,&cminst,"Variables common to all CPack generators");
- cpFile = globalMF->GetModulesFile("CPackComponent.cmake");
- doc.getStructuredDocFromFile(cpFile.c_str(),
- commands,&cminst,"Variables common to all CPack generators");
- cpFile = globalMF->GetModulesFile("CPackRPM.cmake");
- doc.getStructuredDocFromFile(cpFile.c_str(),
- commands,&cminst,"Variables specific to a CPack generator");
+ typedef std::pair<std::string,std::string> docModuleSectionPair_t;
+ typedef std::list<docModuleSectionPair_t> docedModulesList_t;
+ docedModulesList_t docedModList;
+ docModuleSectionPair_t docPair;
+ std::string docedFile;
+
+ // build the list of files to be parsed for documentation
+ // extraction
+ docPair.first = "CPack.cmake";
+ docPair.second = "Variables common to all CPack generators";
+ docedModList.push_back(docPair);
+ docPair.first = "CPackComponent.cmake";
+ docedModList.push_back(docPair);
+ docPair.first = "CPackRPM.cmake";
+ docPair.second = "Variables specific to a CPack generator";
+ docedModList.push_back(docPair);
+ docPair.first = "CPackDeb.cmake";
+ docedModList.push_back(docPair);
+
+ // parse the files for documentation.
+ for (docedModulesList_t::iterator it = docedModList.begin();
+ it!= docedModList.end(); ++it)
+ {
+ docedFile = globalMF->GetModulesFile((it->first).c_str());
+ if (docedFile.length()!=0)
+ {
+ doc.GetStructuredDocFromFile(docedFile.c_str(),
+ commands,&cminst,(it->second).c_str());
+ }
+ }
std::map<std::string,cmDocumentationSection *> propDocs;
cminst.GetPropertiesDocumentation(propDocs);
doc.SetSections(propDocs);
- cminst.GetCommandDocumentation(commands);
+ cminst.GetCommandDocumentation(commands,true,false);
+ // statically (in C++ code) defined macros/commands
cmCPackDocumentMacros::GetMacrosDocumentation(commands);
doc.SetSection("Commands",commands);