00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012
00013
00014 #include "wx/wxprec.h"
00015
00016 #ifdef __BORLANDC__
00017 #pragma hdrstop
00018 #endif
00019
00020 #ifndef WX_PRECOMP
00021 #include "wx/wx.h"
00022 #endif
00023
00024 #include "guipm/compilerpanel.h"
00025 #include "guipm/opteditctrl.h"
00026 #include "wxp/package.h"
00027 #include "wxp/wxp.h"
00028 #include "wx/config.h"
00029 #include "wx/dir.h"
00030
00031 #ifdef __WXMSW__
00032 #include "shlobj.h"
00033 #endif
00034
00035
00036
00037 wxString wxPackageCompilerNotes[wxPCF_MAX] =
00038 {
00039
00040 _("The 'Autodetect' button will be able to autodetect the BCC 5.5 folders"),
00041
00042
00043 _("The Microsoft VisualC++ compiler requires a number of different folders which are different from version to version. The 'Autodetect' button should be able to locate all required folders for MSVC 6, 7.1 and 8.0"),
00044
00045
00046 _("Autodetect feature not tested yet (FIXME)"),
00047
00048
00049 _("All MinGW versions are supported by the Autodetect feature"),
00050
00051
00052 _("TOWRITE"),
00053
00054
00055 _("On a Unix system usually there's no need to add additional paths to those built-in in the compiler: the GNU make is usually already in PATH and should run out-of-the-box when you have installed the 'gcc' (or similar) package of your distribution."),
00056
00057
00058 _("On a Unix system usually there's no need to add additional paths to those built-in in the compiler: the GNU make is usually already in PATH and should run out-of-the-box when you have installed the 'gcc' (or similar) package of your distribution.")
00059 };
00060
00061
00062
00063
00064
00065
00066 IMPLEMENT_DYNAMIC_CLASS( wxCompilerSettingsPanel, wxPanel )
00067 BEGIN_EVENT_TABLE( wxCompilerSettingsPanel, wxPanel )
00068 EVT_CHOICE( ID_COMPILERSETTINGS_DEFAULTCOMPILER,
00069 wxCompilerSettingsPanel::OnCompilerChanged)
00070 EVT_BUTTON( ID_COMPILERSETTINGS_AUTODETECT,
00071 wxCompilerSettingsPanel::OnAutodetect)
00072 EVT_BUTTON( ID_COMPILERSETTINGS_ADDPATH,
00073 wxCompilerSettingsPanel::OnAddNewPath)
00074 EVT_BUTTON( ID_COMPILERSETTINGS_EDITPATH,
00075 wxCompilerSettingsPanel::OnEditPath)
00076 EVT_BUTTON( ID_COMPILERSETTINGS_OPENPATH,
00077 wxCompilerSettingsPanel::OnOpenPath)
00078 EVT_BUTTON( ID_COMPILERSETTINGS_DELETEPATH,
00079 wxCompilerSettingsPanel::OnRemovePath)
00080
00081 EVT_LISTBOX_DCLICK( ID_COMPILERSETTINGS_PATHS,
00082 wxCompilerSettingsPanel::OnEditPath )
00083 EVT_UPDATE_UI( wxID_ANY, wxCompilerSettingsPanel::OnUpdateUI )
00084 END_EVENT_TABLE()
00085
00086 wxCompilerSettingsPanel::wxCompilerSettingsPanel( )
00087 {
00088 }
00089
00090 wxCompilerSettingsPanel::wxCompilerSettingsPanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
00091 {
00092 Create(parent, id, pos, size, style);
00093 }
00094
00095 bool wxCompilerSettingsPanel::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
00096 {
00098 m_pCompilerChoice = NULL;
00099 m_pNotes = NULL;
00100 m_pPathList = NULL;
00102
00104 SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
00105 wxPanel::Create( parent, id, pos, size, style );
00106
00107 CreateControls();
00108 if (GetSizer())
00109 {
00110 GetSizer()->SetSizeHints(this);
00111 }
00112 Centre();
00114 return true;
00115 }
00116
00117 void wxCompilerSettingsPanel::CreateControls()
00118 {
00120 wxCompilerSettingsPanel* itemPanel1 = this;
00121
00122 wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
00123 itemPanel1->SetSizer(itemBoxSizer2);
00124
00125 wxStaticBox* itemStaticBoxSizer3Static = new wxStaticBox(itemPanel1, wxID_ANY, _("Compiler"));
00126 wxStaticBoxSizer* itemStaticBoxSizer3 = new wxStaticBoxSizer(itemStaticBoxSizer3Static, wxVERTICAL);
00127 itemBoxSizer2->Add(itemStaticBoxSizer3, 1, wxGROW|wxALL, 5);
00128
00129 wxFlexGridSizer* itemFlexGridSizer4 = new wxFlexGridSizer(2, 2, 0, 0);
00130 itemFlexGridSizer4->AddGrowableRow(0);
00131 itemFlexGridSizer4->AddGrowableRow(1);
00132 itemFlexGridSizer4->AddGrowableCol(1);
00133 itemStaticBoxSizer3->Add(itemFlexGridSizer4, 0, wxGROW, 5);
00134
00135 wxStaticText* itemStaticText5 = new wxStaticText( itemPanel1, wxID_STATIC, _("Currently selected compiler:"), wxDefaultPosition, wxDefaultSize, 0 );
00136 itemFlexGridSizer4->Add(itemStaticText5, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL|wxADJUST_MINSIZE, 5);
00137
00138 wxString* m_pCompilerChoiceStrings = NULL;
00139 m_pCompilerChoice = new wxChoice( itemPanel1, ID_COMPILERSETTINGS_DEFAULTCOMPILER, wxDefaultPosition, wxDefaultSize, 0, m_pCompilerChoiceStrings, 0 );
00140 itemFlexGridSizer4->Add(m_pCompilerChoice, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
00141
00142 wxStaticText* itemStaticText7 = new wxStaticText( itemPanel1, wxID_STATIC, _("Notes about selected compiler:"), wxDefaultPosition, wxDefaultSize, 0 );
00143 itemStaticBoxSizer3->Add(itemStaticText7, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
00144
00145 m_pNotes = new wxTextCtrl( itemPanel1, ID_COMPILERSETTINGS_NOTES, _T(""), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY );
00146 itemStaticBoxSizer3->Add(m_pNotes, 1, wxGROW|wxALL, 5);
00147
00148 wxStaticText* itemStaticText9 = new wxStaticText( itemPanel1, wxID_STATIC, _("Compiler/tools paths:"), wxDefaultPosition, wxDefaultSize, 0 );
00149 itemStaticBoxSizer3->Add(itemStaticText9, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
00150
00151 wxBoxSizer* itemBoxSizer10 = new wxBoxSizer(wxHORIZONTAL);
00152 itemStaticBoxSizer3->Add(itemBoxSizer10, 2, wxGROW, 5);
00153
00154 wxString* m_pPathListStrings = NULL;
00155 m_pPathList = new wxListBox( itemPanel1, ID_COMPILERSETTINGS_PATHS, wxDefaultPosition, wxSize(-1, 100), 0, m_pPathListStrings, wxLB_SINGLE|wxLB_HSCROLL );
00156 itemBoxSizer10->Add(m_pPathList, 1, wxGROW|wxALL|wxFIXED_MINSIZE, 5);
00157
00158 wxBoxSizer* itemBoxSizer12 = new wxBoxSizer(wxVERTICAL);
00159 itemBoxSizer10->Add(itemBoxSizer12, 0, wxALIGN_BOTTOM, 5);
00160
00161 wxButton* itemButton13 = new wxButton( itemPanel1, ID_COMPILERSETTINGS_ADDPATH, _("Add new..."), wxDefaultPosition, wxDefaultSize, 0 );
00162 itemBoxSizer12->Add(itemButton13, 0, wxGROW|wxALL, 5);
00163
00164 wxButton* itemButton14 = new wxButton( itemPanel1, ID_COMPILERSETTINGS_EDITPATH, _("Edit..."), wxDefaultPosition, wxDefaultSize, 0 );
00165 itemBoxSizer12->Add(itemButton14, 0, wxGROW|wxALL, 5);
00166
00167 wxButton* itemButton15 = new wxButton( itemPanel1, ID_COMPILERSETTINGS_OPENPATH, _("Open..."), wxDefaultPosition, wxDefaultSize, 0 );
00168 itemBoxSizer12->Add(itemButton15, 0, wxGROW|wxALL, 5);
00169
00170 wxButton* itemButton16 = new wxButton( itemPanel1, ID_COMPILERSETTINGS_DELETEPATH, _("Delete"), wxDefaultPosition, wxDefaultSize, 0 );
00171 itemBoxSizer12->Add(itemButton16, 0, wxGROW|wxALL, 5);
00172
00173 wxButton* itemButton17 = new wxButton( itemPanel1, ID_COMPILERSETTINGS_AUTODETECT, _("Autodetect..."), wxDefaultPosition, wxDefaultSize, 0 );
00174 itemBoxSizer12->Add(itemButton17, 0, wxGROW|wxALL, 5);
00175
00177 }
00178
00179 wxString wxCompilerSettingsPanel::GetCompilerUserFriendlyName(wxPackageCompilerFormat f)
00180 {
00181 wxString str = wxPackageCompilerFormat2String(f);
00182
00183
00184 str = wxString(str[0]).MakeUpper() + str.Mid(1);
00185
00186 if (f != wxPCF_AUTOCONF)
00187 return str + wxT(" makefile");
00188 return str;
00189 }
00190
00191 void wxCompilerSettingsPanel::InitAsGlobal()
00192 {
00193 wxPackageCompilerFormat def = wxCompilerSettings::GetDefaultFormat();
00194 wxASSERT(def != wxPCF_INVALID);
00195
00196
00197 for (size_t i=0; i < wxPCF_MAX; i++)
00198 {
00199 wxPackageCompilerFormat fmt = wxIdx2PackageCompilerFormat(i);
00200 wxString str = GetCompilerUserFriendlyName(fmt) + wxT(" [");
00201
00202
00203
00204 long buildsyslist = wxGetBuildSystemsSupportingCompilerFormat(fmt);
00205 str += wxPackageBuildSystemTypeList2String(buildsyslist) + wxT("]");
00206
00207
00208 int lastitem = m_pCompilerChoice->Append(str, (void*)fmt);
00209 if (fmt == def)
00210 m_pCompilerChoice->SetSelection(lastitem);
00211 }
00212
00213 UpdatePathList();
00214 UpdateNotes();
00215 }
00216
00217 void wxCompilerSettingsPanel::SetPackage(const wxPackage &p)
00218 {
00219
00220 m_pCompilerChoice->Clear();
00221 m_pPathList->Clear();
00222
00223 m_pkg = p;
00224 wxPackageCompilerFormat def = m_pkg.GetCompilerSettings().GetSelFormat();
00225 wxASSERT(def != wxPCF_INVALID);
00226
00227
00228 for (size_t i=0; i < wxPCF_MAX; i++)
00229 {
00230 wxPackageCompilerFormat fmt = wxIdx2PackageCompilerFormat(i);
00231 if (m_pkg.SupportsBuildSysFormat(fmt))
00232 {
00233
00234 int lastitem =
00235 m_pCompilerChoice->Append(GetCompilerUserFriendlyName(fmt), (void*)fmt);
00236
00237
00238
00239
00240
00241 if (fmt == def)
00242 m_pCompilerChoice->SetSelection(lastitem);
00243 }
00244 }
00245
00246 wxASSERT(m_pCompilerChoice->GetCount() > 0);
00247 if (m_pCompilerChoice->GetSelection() == wxNOT_FOUND)
00248 m_pCompilerChoice->SetSelection(0);
00249
00250 UpdatePathList();
00251 UpdateNotes();
00252 }
00253
00254 bool wxCompilerSettingsPanel::ShowToolTips()
00255 {
00256 return true;
00257 }
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269 wxPackageCompilerFormat wxCompilerSettingsPanel::GetSelCompilerFormat() const
00270 {
00271 int n = m_pCompilerChoice->GetSelection();
00272 wxASSERT(n != wxNOT_FOUND);
00273 return (wxPackageCompilerFormat)(int)
00274 m_pCompilerChoice->GetClientData(n);
00275 }
00276
00277 void wxCompilerSettingsPanel::UpdatePathList()
00278 {
00279 wxPackageCompilerFormat def = GetSelCompilerFormat();
00280 m_pPathList->Clear();
00281
00282 for (size_t j=0; j<wxPCPT_MAX; j++)
00283 {
00284 wxPackageCompilerPathType t = (wxPackageCompilerPathType)j;
00285 wxString prefix = wxT("[") + wxPackageCompilerPathType2String(t) + wxT("] ");
00286
00287 wxArrayString arr = wxCompilerSettings::GetCompilerPaths(def, t);
00288 for (size_t i=0; i<arr.GetCount(); i++)
00289 m_pPathList->Append(prefix + arr[i], (void *)t);
00290 }
00291 }
00292
00293 void wxCompilerSettingsPanel::UpdatePackageCompiler()
00294 {
00295
00296 m_pkg.GetCompilerSettings().SetSelFormat(GetSelCompilerFormat());
00297 }
00298
00299 void wxCompilerSettingsPanel::UpdateCompilerSettingsPaths()
00300 {
00301 wxPathList pl[wxPCPT_MAX];
00302
00303 for (size_t i=0; i < m_pPathList->GetCount(); i++)
00304 {
00305 wxPackageCompilerPathType t =
00306 (wxPackageCompilerPathType)(int)m_pPathList->GetClientData(i);
00307
00308 pl[t].Add(m_pPathList->GetString(i).AfterFirst(wxT(' ')));
00309 }
00310
00311
00312 for (size_t j=0; j < wxPCPT_MAX; j++)
00313 wxCompilerSettings::SetCompilerPaths(GetSelCompilerFormat(),
00314 (wxPackageCompilerPathType)j,
00315 pl[j]);
00316 }
00317
00318 void wxCompilerSettingsPanel::UpdateNotes()
00319 {
00320 size_t n = wxPackageCompilerFormat2Idx(GetSelCompilerFormat());
00321 m_pNotes->SetValue(wxPackageCompilerNotes[n]);
00322 }
00323
00324
00325
00326
00327
00328
00329 void wxCompilerSettingsPanel::OnCompilerChanged(wxCommandEvent &WXUNUSED(ev))
00330 {
00331
00332 UpdatePackageCompiler();
00333
00334
00335 UpdatePathList();
00336
00337
00338 UpdateNotes();
00339 }
00340
00341 void wxCompilerSettingsPanel::OnAutodetect(wxCommandEvent &)
00342 {
00343 wxPackageCompilerFormat selected = GetSelCompilerFormat();
00344
00345
00346 InteractiveAutodetectPathsFor(selected);
00347
00348
00349
00350 UpdatePathList();
00351 }
00352
00353 void wxCompilerSettingsPanel::OnAddNewPath(wxCommandEvent &)
00354 {
00355 wxPackageCompilerPathType idx =
00356 (wxPackageCompilerPathType)wxGetSingleChoiceIndex(
00357 _("Please choose the type of path you want to add:"),
00358 _("Choose path type"),
00359 wxPCPT_MAX, wxPackageCompilerPathTypeName,
00360 this);
00361 if (idx == wxPCPT_INVALID)
00362 return;
00363
00364 wxDirDialog dlg(this);
00365 if (dlg.ShowModal() == wxID_OK)
00366 {
00367 wxString prefix = wxT("[") + wxPackageCompilerPathType2String(idx) + wxT("] ");
00368 m_pPathList->Append(prefix + dlg.GetPath(), (void*)idx);
00369 UpdateCompilerSettingsPaths();
00370 }
00371 }
00372
00373 void wxCompilerSettingsPanel::OnEditPath(wxCommandEvent &)
00374 {
00375 wxString path = m_pPathList->GetStringSelection().AfterFirst(wxT(' '));
00376
00377 wxDirDialog dlg(this);
00378 dlg.SetPath(path);
00379
00380 int sel = m_pPathList->GetSelection();
00381 wxASSERT(sel != wxNOT_FOUND);
00382
00383 wxPackageCompilerPathType idx =
00384 (wxPackageCompilerPathType)(int)m_pPathList->GetClientData(sel);
00385 if (dlg.ShowModal() == wxID_OK)
00386 {
00387 wxString prefix = wxT("[") + wxPackageCompilerPathType2String(idx) + wxT("] ");
00388 m_pPathList->SetString(sel, prefix + dlg.GetPath());
00389 UpdateCompilerSettingsPaths();
00390 }
00391 }
00392
00393 void wxCompilerSettingsPanel::OnOpenPath(wxCommandEvent &)
00394 {
00395 wxString path = m_pPathList->GetStringSelection().AfterFirst(wxT(' '));
00396
00397 #ifdef __WXMSW__
00398 wxExecute(wxT("explorer.exe ") + path);
00399 #elif defined(__WXGTK__)
00400 wxExecute(wxT("gnome-open ") + path);
00401 #endif
00402 }
00403
00404 void wxCompilerSettingsPanel::OnRemovePath(wxCommandEvent &)
00405 {
00406 m_pPathList->Delete(m_pPathList->GetSelection());
00407 UpdateCompilerSettingsPaths();
00408 }
00409
00410 void wxCompilerSettingsPanel::OnUpdateUI(wxUpdateUIEvent &)
00411 {
00412 bool toenable = m_pPathList->GetSelection() != wxNOT_FOUND;
00413
00414 FindWindowById(ID_COMPILERSETTINGS_EDITPATH, this)->Enable(toenable);
00415 FindWindowById(ID_COMPILERSETTINGS_OPENPATH, this)->Enable(toenable);
00416 FindWindowById(ID_COMPILERSETTINGS_DELETEPATH, this)->Enable(toenable);
00417 }
00418
00419
00420
00421
00422
00423
00424
00425
00426 void wxCompilerSettingsPanel::InteractiveAutodetectPathsFor(wxPackageCompilerFormat f)
00427 {
00428 wxPathList pl;
00429
00430 wxArrayString tool = wxCompilerSettings::GetRequiredToolsList(f);
00431 wxString toolstr;
00432 for (size_t i=0; i<tool.GetCount(); i++)
00433 toolstr += tool[i] + wxT("\n");
00434
00435
00436 pl.AddEnvList(wxT("PATH"));
00437 if (wxCompilerSettings::IsValidPathList(f, pl))
00438 {
00439
00440 wxLogMessage(_("It looks like all the following tools:\n\n%s\nare already in the PATH environment variable... so you don't need any additional path!"),
00441 toolstr.c_str());
00442 return;
00443 }
00444
00445
00446 switch (f)
00447 {
00448 case wxPCF_BORLAND:
00449 if (AutodetectBCC())
00450 return;
00451 break;
00452
00453 case wxPCF_MSVC:
00454 if (AutodetectMSVC())
00455 return;
00456 break;
00457
00458 case wxPCF_MINGW:
00459 if (AutodetectMinGW())
00460 return;
00461 break;
00462
00463 case wxPCF_WATCOM:
00464 if (AutodetectWatcom())
00465 return;
00466 break;
00467
00468 default:
00469 break;
00470 }
00471
00472
00473 wxString path;
00474 #if defined( __WXMSW__ )
00475 wxChar pathbuf[MAX_PATH];
00476 if (!SHGetSpecialFolderPath(NULL, pathbuf, CSIDL_PROGRAM_FILES, false))
00477 return;
00478 path = pathbuf;
00479 #elif defined( __UNIX__ )
00480 path = wxT("/usr");
00481 #else
00482 #error Please add some logic for this platform!
00483 #endif
00484
00485 int reply = wxMessageBox(wxString::Format(
00486 _("The required compiler programs:\n\n%s\nare not in the PATH; should I search them in the '%s' folder?\nNote that this search could take few minutes..."),
00487 toolstr.c_str(), path.c_str()),
00488 wxT("Question"), wxYES_NO|wxICON_INFORMATION);
00489
00490 if (reply == wxYES)
00491 {
00492 wxBusyCursor wait;
00493
00494 for (size_t i=0; i<tool.GetCount(); i++)
00495 {
00496 wxFileName fn(wxDir::FindFirst(path, tool[i]));
00497 if (fn.IsOk())
00498 wxCompilerSettings::AddPath(f, wxPCPT_BIN, fn.GetPath());
00499 }
00500 }
00501 }
00502
00503
00504 void AddIfExists(wxPathList &pl, const wxString &path)
00505 {
00506 if (wxFileName::DirExists(path))
00507 pl.Add(path);
00508 }
00509
00510
00511 bool wxCompilerSettingsPanel::AutodetectMSVC()
00512 {
00513 wxPathList &binDirs = wxCompilerSettings::GetCompilerPaths(wxPCF_MSVC, wxPCPT_BIN);
00514 wxPathList &incDirs = wxCompilerSettings::GetCompilerPaths(wxPCF_MSVC, wxPCPT_INCLUDE);
00515 wxPathList &libDirs = wxCompilerSettings::GetCompilerPaths(wxPCF_MSVC, wxPCPT_LIB);
00516
00517
00518 wxString maindir;
00519 if (!wxGetEnv(wxT("VS71COMNTOOLS"), &maindir))
00520 return false;
00521
00522 wxFileName fn(maindir);
00523 if (!fn.IsOk() || !fn.DirExists())
00524 {
00525 wxDirDialog dlg(NULL, wxT("Choose MSVC main directory"),
00526 wxEmptyString, wxDD_DIR_MUST_EXIST|wxDD_DEFAULT_STYLE);
00527 if (dlg.ShowModal() == wxID_OK)
00528 {
00529 fn.AssignDir(dlg.GetPath());
00530 if (!fn.IsOk() || !fn.DirExists())
00531 return false;
00532 }
00533 else
00534 return false;
00535 }
00536 else
00537 {
00538
00539
00540 if (fn.GetDirs().Last() == wxT("Tools"))
00541 fn.RemoveLastDir();
00542 if (fn.GetDirs().Last() == wxT("Common7"))
00543 fn.RemoveLastDir();
00544 }
00545 maindir = fn.GetPath(wxPATH_GET_VOLUME|wxPATH_GET_SEPARATOR);
00546
00547
00548
00549
00550 AddIfExists(binDirs, maindir + wxT("vc98\\bin"));
00551 AddIfExists(binDirs, maindir + wxT("common\\msdev98\\bin"));
00552
00553 AddIfExists(incDirs, maindir + wxT("vc98\\include"));
00554
00555 AddIfExists(libDirs, maindir + wxT("vc98\\lib"));
00556
00557
00558 AddIfExists(binDirs, maindir + wxT("vc7\\bin"));
00559 AddIfExists(binDirs, maindir + wxT("common7\\ide"));
00560
00561 AddIfExists(incDirs, maindir + wxT("vc7\\include"));
00562 AddIfExists(incDirs, maindir + wxT("vc7\\PlatformSDK\\include"));
00563
00564 AddIfExists(libDirs, maindir + wxT("vc7\\lib"));
00565 AddIfExists(libDirs, maindir + wxT("vc7\\PlatformSDK\\lib"));
00566
00567
00568 AddIfExists(binDirs, maindir + wxT("vc\\bin"));
00569 AddIfExists(binDirs, maindir + wxT("vc\\vcpackages"));
00570 AddIfExists(incDirs, maindir + wxT("vc\\include"));
00571 AddIfExists(incDirs, maindir + wxT("vc\\PlatformSDK\\include"));
00572 AddIfExists(libDirs, maindir + wxT("vc\\lib"));
00573 AddIfExists(libDirs, maindir + wxT("vc\\PlatformSDK\\lib"));
00574
00575
00576 AddIfExists(binDirs, maindir + wxT("bin"));
00577 AddIfExists(binDirs, maindir + wxT("bin\\win64"));
00578 AddIfExists(incDirs, maindir + wxT("include"));
00579 AddIfExists(libDirs, maindir + wxT("lib"));
00580
00581 return true;
00582 }
00583
00584
00585 bool wxCompilerSettingsPanel::AutodetectBCC()
00586 {
00587 wxPathList &binDirs = wxCompilerSettings::GetCompilerPaths(wxPCF_BORLAND, wxPCPT_BIN);
00588 wxPathList &incDirs = wxCompilerSettings::GetCompilerPaths(wxPCF_BORLAND, wxPCPT_INCLUDE);
00589 wxPathList &libDirs = wxCompilerSettings::GetCompilerPaths(wxPCF_BORLAND, wxPCPT_LIB);
00590
00591 wxFileName fn;
00592 wxDirDialog dlg(NULL, wxT("Choose Borland main directory"),
00593 wxEmptyString, wxDD_DIR_MUST_EXIST|wxDD_DEFAULT_STYLE);
00594 if (dlg.ShowModal() == wxID_OK)
00595 {
00596 fn.AssignDir(dlg.GetPath());
00597 if (!fn.IsOk() || !fn.DirExists())
00598 return false;
00599 }
00600 else
00601 return false;
00602
00603 wxString maindir = fn.GetPath(wxPATH_GET_VOLUME|wxPATH_GET_SEPARATOR);
00604 if (!wxFileName::DirExists(maindir + wxT("Bin")))
00605 {
00606
00607 maindir += wxT("BCC55");
00608 maindir += wxFileName::GetPathSeparator();
00609 if (!wxFileName::DirExists(maindir + wxT("Bin")))
00610 return false;
00611 }
00612
00613
00614 AddIfExists(binDirs, maindir + wxT("Bin"));
00615 AddIfExists(incDirs, maindir + wxT("Include"));
00616 AddIfExists(libDirs, maindir + wxT("Lib"));
00617
00618 return true;
00619 }
00620
00621
00622 bool wxCompilerSettingsPanel::AutodetectMinGW()
00623 {
00624 wxPathList &binDirs = wxCompilerSettings::GetCompilerPaths(wxPCF_MINGW, wxPCPT_BIN);
00625 wxPathList &incDirs = wxCompilerSettings::GetCompilerPaths(wxPCF_MINGW, wxPCPT_INCLUDE);
00626 wxPathList &libDirs = wxCompilerSettings::GetCompilerPaths(wxPCF_MINGW, wxPCPT_LIB);
00627
00628 wxFileName fn;
00629 wxDirDialog dlg(NULL, wxT("Choose MinGW main directory"),
00630 wxEmptyString, wxDD_DIR_MUST_EXIST|wxDD_DEFAULT_STYLE);
00631 if (dlg.ShowModal() == wxID_OK)
00632 {
00633 fn.AssignDir(dlg.GetPath());
00634 if (!fn.IsOk() || !fn.DirExists())
00635 return false;
00636 }
00637 else
00638 return false;
00639
00640 wxString maindir = fn.GetPath(wxPATH_GET_VOLUME|wxPATH_GET_SEPARATOR);
00641 AddIfExists(binDirs, maindir + wxT("bin"));
00642 AddIfExists(incDirs, maindir + wxT("include"));
00643 AddIfExists(libDirs, maindir + wxT("lib"));
00644
00645 return true;
00646 }
00647
00648
00649 bool wxCompilerSettingsPanel::AutodetectWatcom()
00650 {
00651 wxPathList &binDirs = wxCompilerSettings::GetCompilerPaths(wxPCF_WATCOM, wxPCPT_BIN);
00652 wxPathList &incDirs = wxCompilerSettings::GetCompilerPaths(wxPCF_WATCOM, wxPCPT_INCLUDE);
00653 wxPathList &libDirs = wxCompilerSettings::GetCompilerPaths(wxPCF_WATCOM, wxPCPT_LIB);
00654
00655 wxFileName fn;
00656 wxDirDialog dlg(NULL, wxT("Choose Watcom main directory"),
00657 wxEmptyString, wxDD_DIR_MUST_EXIST|wxDD_DEFAULT_STYLE);
00658 if (dlg.ShowModal() == wxID_OK)
00659 {
00660 fn.AssignDir(dlg.GetPath());
00661 if (!fn.IsOk() || !fn.DirExists())
00662 return false;
00663 }
00664 else
00665 return false;
00666
00667 wxString maindir = fn.GetPath(wxPATH_GET_VOLUME|wxPATH_GET_SEPARATOR);
00668 AddIfExists(binDirs, maindir + wxT("binnt"));
00669 AddIfExists(incDirs, maindir + wxT("h"));
00670 AddIfExists(incDirs, maindir + wxT("h\\nt"));
00671 AddIfExists(incDirs, maindir + wxT("h\\sys"));
00672 AddIfExists(libDirs, maindir + wxT("lib386"));
00673 AddIfExists(libDirs, maindir + wxT("lib386\\nt"));
00674
00675 return true;
00676 }