added progress

This commit is contained in:
Ken Martin 2002-09-26 15:14:20 -04:00
parent 85896b3460
commit c751d2ebff
7 changed files with 91 additions and 33 deletions

View File

@ -1,4 +1,4 @@
//Microsoft Developer Studio generated resource script. // Microsoft Visual C++ generated resource script.
// //
#include "resource.h" #include "resource.h"
@ -27,18 +27,18 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
// TEXTINCLUDE // TEXTINCLUDE
// //
1 TEXTINCLUDE DISCARDABLE 1 TEXTINCLUDE
BEGIN BEGIN
"resource.h\0" "resource.h\0"
END END
2 TEXTINCLUDE DISCARDABLE 2 TEXTINCLUDE
BEGIN BEGIN
"#include ""afxres.h""\r\n" "#include ""afxres.h""\r\n"
"\0" "\0"
END END
3 TEXTINCLUDE DISCARDABLE 3 TEXTINCLUDE
BEGIN BEGIN
"#define _AFX_NO_SPLITTER_RESOURCES\r\n" "#define _AFX_NO_SPLITTER_RESOURCES\r\n"
"#define _AFX_NO_OLE_RESOURCES\r\n" "#define _AFX_NO_OLE_RESOURCES\r\n"
@ -66,15 +66,15 @@ END
// Icon with lowest ID value placed first to ensure application icon // Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems. // remains consistent on all systems.
IDR_MAINFRAME ICON DISCARDABLE "res\\CMakeSetupDialog.ico" IDR_MAINFRAME ICON "res\\CMakeSetupDialog.ico"
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
// Dialog // Dialog
// //
IDD_ABOUTBOX DIALOG DISCARDABLE 0, 0, 235, 55 IDD_ABOUTBOX DIALOG 0, 0, 235, 55
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "About CMakeSetup" CAPTION "About CMakeSetup"
FONT 8, "MS Sans Serif" FONT 8, "MS Sans Serif"
BEGIN BEGIN
@ -86,11 +86,11 @@ BEGIN
END END
IDD_CMakeSetupDialog_DIALOG DIALOGEX 0, 0, 446, 241 IDD_CMakeSetupDialog_DIALOG DIALOGEX 0, 0, 446, 241
STYLE WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | STYLE DS_SETFONT | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_VISIBLE |
WS_SYSMENU | WS_THICKFRAME WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
EXSTYLE WS_EX_APPWINDOW EXSTYLE WS_EX_APPWINDOW
CAPTION "CMakeSetupDialog" CAPTION "CMakeSetupDialog"
FONT 8, "MS Sans Serif" FONT 8, "MS Sans Serif", 0, 0, 0x1
BEGIN BEGIN
COMBOBOX IDC_WhereSource,96,6,169,66,CBS_DROPDOWN | COMBOBOX IDC_WhereSource,96,6,169,66,CBS_DROPDOWN |
CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
@ -116,10 +116,11 @@ BEGIN
PUSHBUTTON "Help",IDC_HELP_BUTTON,278,223,51,15 PUSHBUTTON "Help",IDC_HELP_BUTTON,278,223,51,15
CONTROL "Show Advanced Values",IDC_AdvancedValues,"Button", CONTROL "Show Advanced Values",IDC_AdvancedValues,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,305,28,98,9 BS_AUTOCHECKBOX | WS_TABSTOP,305,28,98,9
RTEXT "Static",IDC_PROGRESS,341,226,100,12,SS_CENTERIMAGE
END END
IDD_CMAKE_HELP_DIALOG DIALOG DISCARDABLE 0, 0, 365, 183 IDD_CMAKE_HELP_DIALOG DIALOG 0, 0, 365, 183
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "CMake Help" CAPTION "CMake Help"
FONT 8, "MS Sans Serif" FONT 8, "MS Sans Serif"
BEGIN BEGIN
@ -129,7 +130,6 @@ BEGIN
END END
#ifndef _MAC
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
// Version // Version
@ -152,15 +152,13 @@ BEGIN
BEGIN BEGIN
BLOCK "040904B0" BLOCK "040904B0"
BEGIN BEGIN
VALUE "CompanyName", "\0" VALUE "FileDescription", "CMakeSetup MFC Application"
VALUE "FileDescription", "CMakeSetup MFC Application\0" VALUE "FileVersion", "1, 0, 0, 1"
VALUE "FileVersion", "1, 0, 0, 1\0" VALUE "InternalName", "CMakeSetup"
VALUE "InternalName", "CMakeSetup\0" VALUE "LegalCopyright", "Copyright (C) 2000"
VALUE "LegalCopyright", "Copyright (C) 2000\0" VALUE "OriginalFilename", "CMakeSetup.EXE"
VALUE "LegalTrademarks", "\0" VALUE "ProductName", "CMakeSetup Application"
VALUE "OriginalFilename", "CMakeSetup.EXE\0" VALUE "ProductVersion", "1, 0, 0, 1"
VALUE "ProductName", "CMakeSetup Application\0"
VALUE "ProductVersion", "1, 0, 0, 1\0"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"
@ -169,8 +167,6 @@ BEGIN
END END
END END
#endif // !_MAC
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
@ -178,7 +174,7 @@ END
// //
#ifdef APSTUDIO_INVOKED #ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE GUIDELINES DESIGNINFO
BEGIN BEGIN
IDD_ABOUTBOX, DIALOG IDD_ABOUTBOX, DIALOG
BEGIN BEGIN
@ -210,7 +206,7 @@ END
// String Table // String Table
// //
STRINGTABLE DISCARDABLE STRINGTABLE
BEGIN BEGIN
IDS_ABOUTBOX "&About CMakeSetup..." IDS_ABOUTBOX "&About CMakeSetup..."
IDS_CREATESHORTCUT "&Create shortcut" IDS_CREATESHORTCUT "&Create shortcut"

View File

@ -103,6 +103,20 @@ void MFCMessageCallback(const char* m, const char* title, bool& nomore, void*)
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// CMakeSetupDialog dialog // CMakeSetupDialog dialog
void updateProgress(const char *msg, float prog, void *cd)
{
char tmp[1024];
if (prog >= 0)
{
sprintf(tmp,"%s %i%%",msg,(int)(100*prog));
}
else
{
sprintf(tmp,"%s",msg);
}
CMakeSetupDialog *self = (CMakeSetupDialog *)cd;
self->SetDlgItemText(IDC_PROGRESS, tmp);
}
CMakeSetupDialog::CMakeSetupDialog(const CMakeCommandLineInfo& cmdInfo, CMakeSetupDialog::CMakeSetupDialog(const CMakeCommandLineInfo& cmdInfo,
CWnd* pParent /*=NULL*/) CWnd* pParent /*=NULL*/)
@ -147,6 +161,8 @@ CMakeSetupDialog::CMakeSetupDialog(const CMakeCommandLineInfo& cmdInfo,
m_oldCX = -1; m_oldCX = -1;
m_deltaXRemainder = 0; m_deltaXRemainder = 0;
m_CMakeInstance = new cmake; m_CMakeInstance = new cmake;
m_CMakeInstance->SetProgressCallback(updateProgress, (void *)this);
} }
void CMakeSetupDialog::DoDataExchange(CDataExchange* pDX) void CMakeSetupDialog::DoDataExchange(CDataExchange* pDX)
@ -268,6 +284,7 @@ BOOL CMakeSetupDialog::OnInitDialog()
sprintf(tmp,"Version %d.%d - %s", cmake::GetMajorVersion(), sprintf(tmp,"Version %d.%d - %s", cmake::GetMajorVersion(),
cmake::GetMinorVersion(), cmake::GetReleaseVersion()); cmake::GetMinorVersion(), cmake::GetReleaseVersion());
SetDlgItemText(IDC_CMAKE_VERSION, tmp); SetDlgItemText(IDC_CMAKE_VERSION, tmp);
SetDlgItemText(IDC_PROGRESS, "");
this->UpdateData(FALSE); this->UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control return TRUE; // return TRUE unless you set the focus to a control
} }

View File

@ -1,5 +1,5 @@
//{{NO_DEPENDENCIES}} //{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file. // Microsoft Visual C++ generated include file.
// Used by CMakeSetup.rc // Used by CMakeSetup.rc
// //
#define IDM_ABOUTBOX 0x0010 #define IDM_ABOUTBOX 0x0010
@ -26,6 +26,7 @@
#define IDC_HELP_BUTTON 1021 #define IDC_HELP_BUTTON 1021
#define IDC_EDIT1 1025 #define IDC_EDIT1 1025
#define IDC_AdvancedValues 1027 #define IDC_AdvancedValues 1027
#define IDC_PROGRESS 1028
// Next default values for new objects // Next default values for new objects
// //
@ -33,7 +34,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS #ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 134 #define _APS_NEXT_RESOURCE_VALUE 134
#define _APS_NEXT_COMMAND_VALUE 32771 #define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1028 #define _APS_NEXT_CONTROL_VALUE 1029
#define _APS_NEXT_SYMED_VALUE 102 #define _APS_NEXT_SYMED_VALUE 102
#endif #endif
#endif #endif

View File

@ -69,23 +69,31 @@ void cmGlobalGenerator::Configure()
lg->GetMakefile()->MakeStartDirectoriesCurrent(); lg->GetMakefile()->MakeStartDirectoriesCurrent();
// now do it // now do it
this->RecursiveConfigure(lg); this->RecursiveConfigure(lg,0.0f,0.9f);
// after it is all done do a ConfigureFinalPass // after it is all done do a ConfigureFinalPass
for (i = 0; i < m_LocalGenerators.size(); ++i) for (i = 0; i < m_LocalGenerators.size(); ++i)
{ {
m_LocalGenerators[i]->ConfigureFinalPass(); m_LocalGenerators[i]->ConfigureFinalPass();
m_CMakeInstance->UpdateProgress("Configuring",
0.9f+0.1f*(i+1.0f)/m_LocalGenerators.size());
} }
m_CMakeInstance->UpdateProgress("Configuring done", -1);
} }
// loop through the directories creating cmLocalGenerators and Configure() // loop through the directories creating cmLocalGenerators and Configure()
void cmGlobalGenerator::RecursiveConfigure(cmLocalGenerator *lg) void cmGlobalGenerator::RecursiveConfigure(cmLocalGenerator *lg,
float startProgress,
float endProgress)
{ {
// configure the current directory // configure the current directory
lg->Configure(); lg->Configure();
// get all the subdirectories // get all the subdirectories
std::vector<std::string> subdirs = lg->GetMakefile()->GetSubDirectories(); std::vector<std::string> subdirs = lg->GetMakefile()->GetSubDirectories();
float progressPiece = (endProgress - startProgress)/(1.0f+subdirs.size());
m_CMakeInstance->UpdateProgress("Configuring",
startProgress + progressPiece);
// for each subdir recurse // for each subdir recurse
unsigned int i; unsigned int i;
@ -107,7 +115,9 @@ void cmGlobalGenerator::RecursiveConfigure(cmLocalGenerator *lg)
lg2->GetMakefile()->SetStartDirectory(currentDir.c_str()); lg2->GetMakefile()->SetStartDirectory(currentDir.c_str());
lg2->GetMakefile()->MakeStartDirectoriesCurrent(); lg2->GetMakefile()->MakeStartDirectoriesCurrent();
this->RecursiveConfigure(lg2); this->RecursiveConfigure(lg2,
startProgress + (i+1.0f)*progressPiece,
startProgress + (i+2.0f)*progressPiece);
} }
} }
@ -118,6 +128,8 @@ void cmGlobalGenerator::Generate()
for (i = 0; i < m_LocalGenerators.size(); ++i) for (i = 0; i < m_LocalGenerators.size(); ++i)
{ {
m_LocalGenerators[i]->Generate(true); m_LocalGenerators[i]->Generate(true);
m_CMakeInstance->UpdateProgress("Generating",
(i+1.0f)/m_LocalGenerators.size());
} }
} }

View File

@ -103,7 +103,7 @@ protected:
std::vector<cmLocalGenerator *> m_LocalGenerators; std::vector<cmLocalGenerator *> m_LocalGenerators;
///! used by Configure() ///! used by Configure()
void RecursiveConfigure(cmLocalGenerator *lg); void RecursiveConfigure(cmLocalGenerator *lg, float start, float end);
private: private:
std::map<cmStdString, bool> m_LanguageEnabled; std::map<cmStdString, bool> m_LanguageEnabled;

View File

@ -41,6 +41,9 @@ cmake::cmake()
m_InTryCompile = false; m_InTryCompile = false;
m_CacheManager = new cmCacheManager; m_CacheManager = new cmCacheManager;
m_GlobalGenerator = 0; m_GlobalGenerator = 0;
m_ProgressCallback = 0;
m_ProgressCallbackClientData = 0;
this->AddDefaultCommands(); this->AddDefaultCommands();
} }
@ -907,3 +910,17 @@ int cmake::LoadCache()
return 0; return 0;
} }
void cmake::SetProgressCallback(ProgressCallback f, void *cd)
{
m_ProgressCallback = f;
m_ProgressCallbackClientData = cd;
}
void cmake::UpdateProgress(const char *msg, float prog)
{
if(m_ProgressCallback && !m_InTryCompile)
{
(*m_ProgressCallback)(msg, prog, m_ProgressCallbackClientData);
return;
}
}

View File

@ -211,6 +211,19 @@ class cmake
///! Parse command line arguments that might set cache values ///! Parse command line arguments that might set cache values
void SetCacheArgs(const std::vector<std::string>&); void SetCacheArgs(const std::vector<std::string>&);
typedef void (*ProgressCallback)(const char*msg, float progress, void *);
/**
* Set the function used by GUI's to receive progress updates
* Function gets passed: message as a const char*, a progress
* amount ranging from 0 to 1.0 and client data. The progress
* number provided may be negative in cases where a message is
* to be displayed without any progress percentage.
*/
void SetProgressCallback(ProgressCallback f, void* clientData=0);
///! this is called by generators to update the progress
void UpdateProgress(const char *msg, float prog);
protected: protected:
typedef std::map<cmStdString, cmCommand*> RegisteredCommandsMap; typedef std::map<cmStdString, cmCommand*> RegisteredCommandsMap;
RegisteredCommandsMap m_Commands; RegisteredCommandsMap m_Commands;
@ -235,6 +248,8 @@ protected:
int AddCMakePaths(const char *arg0); int AddCMakePaths(const char *arg0);
private: private:
ProgressCallback m_ProgressCallback;
void* m_ProgressCallbackClientData;
bool m_Verbose; bool m_Verbose;
bool m_Local; bool m_Local;
bool m_InTryCompile; bool m_InTryCompile;