CPack: accept --trace and --trace-expand

This commit is contained in:
Isaiah Norton 2017-12-09 11:46:58 -05:00 committed by Brad King
parent 9c52b587b6
commit 93bc5848e7
5 changed files with 44 additions and 0 deletions

View File

@ -62,6 +62,12 @@ Options
Run cpack with debug output (for CPack developers). Run cpack with debug output (for CPack developers).
``--trace``
Put underlying cmake scripts in trace mode.
``--trace-expand``
Put underlying cmake scripts in expanded trace mode.
``-P <package name>`` ``-P <package name>``
override/define CPACK_PACKAGE_NAME override/define CPACK_PACKAGE_NAME

View File

@ -0,0 +1,4 @@
cpack_trace
-----------
* :manual:`cpack(1)` gained ``--trace`` and ``--trace-expand`` options.

View File

@ -637,6 +637,8 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
cm.GetCurrentSnapshot().SetDefaultDefinitions(); cm.GetCurrentSnapshot().SetDefaultDefinitions();
cm.AddCMakePaths(); cm.AddCMakePaths();
cm.SetProgressCallback(cmCPackGeneratorProgress, this); cm.SetProgressCallback(cmCPackGeneratorProgress, this);
cm.SetTrace(this->Trace);
cm.SetTraceExpand(this->TraceExpand);
cmGlobalGenerator gg(&cm); cmGlobalGenerator gg(&cm);
cmMakefile mf(&gg, cm.GetCurrentSnapshot()); cmMakefile mf(&gg, cm.GetCurrentSnapshot());
if (!installSubDirectory.empty() && installSubDirectory != "/" && if (!installSubDirectory.empty() && installSubDirectory != "/" &&

View File

@ -35,6 +35,16 @@ public:
val ? cmSystemTools::OUTPUT_MERGE : cmSystemTools::OUTPUT_NONE; val ? cmSystemTools::OUTPUT_MERGE : cmSystemTools::OUTPUT_NONE;
} }
/**
* Put underlying cmake scripts in trace mode.
*/
void SetTrace(bool val) { this->Trace = val; }
/**
* Put underlying cmake scripts in expanded trace mode.
*/
void SetTraceExpand(bool val) { this->TraceExpand = val; }
/** /**
* Returns true if the generator may work on this system. * Returns true if the generator may work on this system.
* Rational: * Rational:
@ -295,6 +305,8 @@ protected:
ComponentPackageMethod componentPackageMethod; ComponentPackageMethod componentPackageMethod;
cmCPackLog* Logger; cmCPackLog* Logger;
bool Trace;
bool TraceExpand;
private: private:
cmMakefile* MakefileMap; cmMakefile* MakefileMap;

View File

@ -43,6 +43,8 @@ static const char* cmDocumentationOptions[][2] = {
{ "-D <var>=<value>", "Set a CPack variable." }, { "-D <var>=<value>", "Set a CPack variable." },
{ "--config <config file>", "Specify the config file." }, { "--config <config file>", "Specify the config file." },
{ "--verbose,-V", "enable verbose output" }, { "--verbose,-V", "enable verbose output" },
{ "--trace", "Put underlying cmake scripts in trace mode." },
{ "--trace-expand", "Put underlying cmake scripts in expanded trace mode." },
{ "--debug", "enable debug output (for CPack developers)" }, { "--debug", "enable debug output (for CPack developers)" },
{ "-P <package name>", "override/define CPACK_PACKAGE_NAME" }, { "-P <package name>", "override/define CPACK_PACKAGE_NAME" },
{ "-R <package version>", "override/define CPACK_PACKAGE_VERSION" }, { "-R <package version>", "override/define CPACK_PACKAGE_VERSION" },
@ -119,6 +121,8 @@ int main(int argc, char const* const* argv)
bool help = false; bool help = false;
bool helpVersion = false; bool helpVersion = false;
bool verbose = false; bool verbose = false;
bool trace = false;
bool traceExpand = false;
bool debug = false; bool debug = false;
std::string helpFull; std::string helpFull;
std::string helpMAN; std::string helpMAN;
@ -154,6 +158,10 @@ int main(int argc, char const* const* argv)
arg.AddArgument("--debug", argT::NO_ARGUMENT, &debug, "-V"); arg.AddArgument("--debug", argT::NO_ARGUMENT, &debug, "-V");
arg.AddArgument("--config", argT::SPACE_ARGUMENT, &cpackConfigFile, arg.AddArgument("--config", argT::SPACE_ARGUMENT, &cpackConfigFile,
"CPack configuration file"); "CPack configuration file");
arg.AddArgument("--trace", argT::NO_ARGUMENT, &trace,
"Put underlying cmake scripts in trace mode.");
arg.AddArgument("--trace-expand", argT::NO_ARGUMENT, &traceExpand,
"Put underlying cmake scripts in expanded trace mode.");
arg.AddArgument("-C", argT::SPACE_ARGUMENT, &cpackBuildConfig, arg.AddArgument("-C", argT::SPACE_ARGUMENT, &cpackBuildConfig,
"CPack build configuration"); "CPack build configuration");
arg.AddArgument("-G", argT::SPACE_ARGUMENT, &generator, "CPack generator"); arg.AddArgument("-G", argT::SPACE_ARGUMENT, &generator, "CPack generator");
@ -197,6 +205,14 @@ int main(int argc, char const* const* argv)
globalMF.AddDefinition("CMAKE_LEGACY_CYGWIN_WIN32", "0"); globalMF.AddDefinition("CMAKE_LEGACY_CYGWIN_WIN32", "0");
#endif #endif
if (trace) {
cminst.SetTrace(true);
}
if (traceExpand) {
cminst.SetTrace(true);
cminst.SetTraceExpand(true);
}
bool cpackConfigFileSpecified = true; bool cpackConfigFileSpecified = true;
if (cpackConfigFile.empty()) { if (cpackConfigFile.empty()) {
cpackConfigFile = cmSystemTools::GetCurrentWorkingDirectory(); cpackConfigFile = cmSystemTools::GetCurrentWorkingDirectory();
@ -340,6 +356,10 @@ int main(int argc, char const* const* argv)
<< std::endl); << std::endl);
parsed = 0; parsed = 0;
} }
cpackGenerator->SetTrace(trace);
cpackGenerator->SetTraceExpand(traceExpand);
if (parsed && !cpackGenerator->Initialize(gen, mf)) { if (parsed && !cpackGenerator->Initialize(gen, mf)) {
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"Cannot initialize the generator " << gen "Cannot initialize the generator " << gen