ENH: Paths are now expanded for environment variables and made absolute.
The binary directory is created if it doesn't exist.
This commit is contained in:
parent
522ff0204a
commit
d0614d75ea
|
@ -126,8 +126,8 @@ void CMakeSetupGUI::BrowseForBinaryPath(void) {
|
|||
void CMakeSetupGUI::Show(void) {
|
||||
}
|
||||
|
||||
void CMakeSetupGUI::SetBinaryPath(const char *) {
|
||||
bool CMakeSetupGUI::SetBinaryPath(const char *) {
|
||||
}
|
||||
|
||||
void CMakeSetupGUI::SetSourcePath(const char *) {
|
||||
bool CMakeSetupGUI::SetSourcePath(const char *) {
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ class CMakeSetupGUI {open
|
|||
}
|
||||
Fl_Input binaryPathTextInput {
|
||||
label {Where do you want to build the binaries: }
|
||||
callback {SetBinaryPath( binaryPathTextInput->value() );}
|
||||
callback {SetBinaryPath( binaryPathTextInput->value() );} selected
|
||||
xywh {219 50 200 20} labelsize 11 when 8 textsize 11
|
||||
}
|
||||
Fl_Button {} {
|
||||
|
@ -50,7 +50,7 @@ class CMakeSetupGUI {open
|
|||
label {Cache Values} open
|
||||
xywh {40 98 485 190} type BOTH_ALWAYS box DOWN_FRAME labelsize 11 align 5 when 1 resizable
|
||||
} {
|
||||
Fl_Pack propertyListPack {selected
|
||||
Fl_Pack propertyListPack {
|
||||
xywh {40 99 485 185} resizable
|
||||
} {}
|
||||
}
|
||||
|
@ -72,8 +72,8 @@ class CMakeSetupGUI {open
|
|||
} {}
|
||||
Function {Show(void)} {return_type {virtual void}
|
||||
} {}
|
||||
Function {SetBinaryPath(const char *)} {return_type {virtual void}
|
||||
Function {SetBinaryPath(const char *)} {return_type {virtual bool}
|
||||
} {}
|
||||
Function {SetSourcePath(const char *)} {return_type {virtual void}
|
||||
Function {SetSourcePath(const char *)} {return_type {virtual bool}
|
||||
} {}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
virtual void BrowseForSourcePath(void);
|
||||
virtual void BrowseForBinaryPath(void);
|
||||
virtual void Show(void);
|
||||
virtual void SetBinaryPath(const char *);
|
||||
virtual void SetSourcePath(const char *);
|
||||
virtual bool SetBinaryPath(const char *);
|
||||
virtual bool SetSourcePath(const char *);
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -21,10 +21,9 @@ CMakeSetupGUIImplementation
|
|||
{
|
||||
m_BuildPathChanged = false;
|
||||
char fname[1024];
|
||||
//::GetModuleFileName(NULL,fname,1023);
|
||||
//::GetModuleFileName(NULL,fname,1023); // Didn't found this method. (?)
|
||||
m_PathToExecutable = cmSystemTools::GetProgramPath(fname).c_str();
|
||||
m_PathToExecutable += "/cmake.exe";
|
||||
std::cout << "Path to executable = " << m_PathToExecutable << std::endl;
|
||||
}
|
||||
|
||||
|
||||
|
@ -122,41 +121,88 @@ CMakeSetupGUIImplementation
|
|||
/**
|
||||
* Set the source path
|
||||
*/
|
||||
void
|
||||
bool
|
||||
CMakeSetupGUIImplementation
|
||||
::SetSourcePath( const char * path )
|
||||
{
|
||||
if( VerifySourcePath( path ) )
|
||||
|
||||
if( !path || strlen(path)==0 )
|
||||
{
|
||||
m_WhereSource = path;
|
||||
sourcePathTextInput->value( path );
|
||||
fl_alert("Please select the path to the sources");
|
||||
return false;
|
||||
}
|
||||
|
||||
string expandedAbsolutePath = ExpandPathAndMakeItAbsolute( path );
|
||||
|
||||
sourcePathTextInput->value( expandedAbsolutePath.c_str() );
|
||||
|
||||
if( VerifySourcePath( expandedAbsolutePath ) )
|
||||
{
|
||||
m_WhereSource = expandedAbsolutePath;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Expand environment variables in the path and make it absolute
|
||||
*/
|
||||
string
|
||||
CMakeSetupGUIImplementation
|
||||
::ExpandPathAndMakeItAbsolute( const string & inputPath ) const
|
||||
{
|
||||
|
||||
char expandedPath[3000];
|
||||
filename_expand( expandedPath, inputPath.c_str() );
|
||||
|
||||
char absolutePath[3000];
|
||||
filename_absolute( absolutePath, expandedPath );
|
||||
|
||||
string expandedAbsolutePath = absolutePath;
|
||||
|
||||
return expandedAbsolutePath;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the binary path
|
||||
*/
|
||||
void
|
||||
bool
|
||||
CMakeSetupGUIImplementation
|
||||
::SetBinaryPath( const char * path )
|
||||
{
|
||||
|
||||
if( VerifyBinaryPath( path ) )
|
||||
if( !path || strlen(path)==0 )
|
||||
{
|
||||
if( m_WhereBuild != path )
|
||||
{
|
||||
m_BuildPathChanged = true;
|
||||
m_WhereBuild = path;
|
||||
}
|
||||
binaryPathTextInput->value( path );
|
||||
fl_alert("Please select the path to the binaries");
|
||||
return false;
|
||||
}
|
||||
|
||||
string expandedAbsolutePath = ExpandPathAndMakeItAbsolute( path );
|
||||
|
||||
binaryPathTextInput->value( expandedAbsolutePath.c_str() );
|
||||
|
||||
if( !VerifyBinaryPath( expandedAbsolutePath.c_str() ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( m_WhereBuild != expandedAbsolutePath )
|
||||
{
|
||||
m_BuildPathChanged = true;
|
||||
m_WhereBuild = expandedAbsolutePath;
|
||||
}
|
||||
|
||||
LoadCacheFromDiskToGUI();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -166,23 +212,36 @@ CMakeSetupGUIImplementation
|
|||
*/
|
||||
bool
|
||||
CMakeSetupGUIImplementation
|
||||
::VerifyBinaryPath( const char * path )
|
||||
::VerifyBinaryPath( const string & path ) const
|
||||
{
|
||||
|
||||
if( !path || strlen(path)==0 )
|
||||
bool pathIsOK = false;
|
||||
|
||||
if( filename_isdir( path.c_str() ) )
|
||||
{
|
||||
fl_alert("Please select the path to the binaries");
|
||||
return false;
|
||||
pathIsOK = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
int userWantsToCreateDirectory =
|
||||
fl_ask("The directory \n %s \n Doesn't exist. Do you want to create it ?",
|
||||
path.c_str() );
|
||||
|
||||
if( userWantsToCreateDirectory )
|
||||
{
|
||||
string command = "mkdir ";
|
||||
command += path;
|
||||
system( command.c_str() );
|
||||
pathIsOK = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
pathIsOK = false;
|
||||
}
|
||||
}
|
||||
|
||||
return pathIsOK;
|
||||
|
||||
if( !filename_isdir( path ) )
|
||||
{
|
||||
fl_alert("%s \n Doesn't exist or is not a directory",path);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -192,19 +251,12 @@ CMakeSetupGUIImplementation
|
|||
*/
|
||||
bool
|
||||
CMakeSetupGUIImplementation
|
||||
::VerifySourcePath( const char * path )
|
||||
::VerifySourcePath( const string & path ) const
|
||||
{
|
||||
|
||||
if( !path || strlen(path)==0 )
|
||||
if( !filename_isdir( path.c_str() ) )
|
||||
{
|
||||
fl_alert("Please select the path to the sources");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if( !filename_isdir( path ) )
|
||||
{
|
||||
fl_alert("%s \n Doesn't exist or is not a directory",path);
|
||||
fl_alert("The Source directory \n %s \n Doesn't exist or is not a directory", path.c_str() );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -222,17 +274,18 @@ CMakeSetupGUIImplementation
|
|||
::BuildProjectFiles( void )
|
||||
{
|
||||
|
||||
// Verify that source path is a valid directory
|
||||
if( !VerifySourcePath( sourcePathTextInput->value() ) )
|
||||
// Take and verify the source path from the GUI
|
||||
if( !SetSourcePath( sourcePathTextInput->value() ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Verify that binary path is a valid directory
|
||||
if( !VerifyBinaryPath( binaryPathTextInput->value() ) )
|
||||
{
|
||||
|
||||
// Take and verify the binary path from the GUI
|
||||
if( !SetBinaryPath( binaryPathTextInput->value() ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
SaveCacheFromGUI();
|
||||
|
||||
|
|
|
@ -26,15 +26,18 @@ public:
|
|||
virtual void BuildProjectFiles( void );
|
||||
virtual void BrowseForBinaryPath( void );
|
||||
virtual void BrowseForSourcePath( void );
|
||||
virtual void SetBinaryPath( const char * path );
|
||||
virtual void SetSourcePath( const char * path );
|
||||
virtual bool VerifyBinaryPath( const char * path );
|
||||
virtual bool VerifySourcePath( const char * path );
|
||||
virtual bool SetBinaryPath( const char * path );
|
||||
virtual bool SetSourcePath( const char * path );
|
||||
virtual void SaveCacheFromGUI( void );
|
||||
virtual void LoadCacheFromDiskToGUI( void );
|
||||
virtual void FillCacheGUIFromCacheManager( void );
|
||||
virtual void FillCacheManagerFromCacheGUI( void );
|
||||
|
||||
private:
|
||||
virtual bool VerifyBinaryPath( const string & path ) const;
|
||||
virtual bool VerifySourcePath( const string & path ) const;
|
||||
virtual string ExpandPathAndMakeItAbsolute( const string & inputPath ) const;
|
||||
|
||||
private:
|
||||
fltk::PropertyList m_CacheEntriesList;
|
||||
std::string m_WhereBuild;
|
||||
|
|
|
@ -26,7 +26,8 @@ PropertyItemRow::PropertyItemRow( PropertyItem * pItem )
|
|||
|
||||
Fl_Tile * group = new Fl_Tile(0,0,nameWidth+textWidth,rowHeight,"");
|
||||
|
||||
group->parent()->size( nameWidth + textWidth , 100 );
|
||||
// Make the parent Fl_Pack widget at least a row wide.
|
||||
group->parent()->size( nameWidth + textWidth , rowHeight );
|
||||
|
||||
Fl_Button * name = new
|
||||
Fl_Button( firstColumn, 0, nameWidth, rowHeight,
|
||||
|
|
Loading…
Reference in New Issue