wxbuild.cpp

00001 
00002 // Name:        wxbuild.cpp
00003 // Purpose:     wxWidgetsBuild, wxWidgetsBuildArray
00004 // Author:      Francesco Montorsi
00005 // Modified by:
00006 // Created:     2006-06-29
00007 // RCS-ID:      $Id: wxbuild.cpp,v 1.1.1.1 2006/12/12 09:39:37 frm Exp $
00008 // Copyright:   (c) Francesco Montorsi
00009 // Licence:     wxWidgets licence
00011 
00012 
00013 // For compilers that support precompilation, includes "wx/wx.h".
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 // includes
00025 #include <wx/config.h>
00026 
00027 #include "wxp/packagedep.h"
00028 #include "wxp/packagecmd.h"
00029 #include "wxp/package.h"
00030 #include "wxp/version.h"
00031 
00032 
00033 // RTTI
00034 IMPLEMENT_DYNAMIC_CLASS(wxWidgetsBuild, wxObject)
00035 
00036 
00037 // wx array implementations
00038 #include <wx/arrimpl.cpp> // this is a magic incantation which must be done!
00039 WX_DEFINE_OBJARRAY(wxWidgetsBuildArrayHelper);
00040 
00041 // static
00042 wxWidgetsBuildArray wxWidgetsBuildArray::s_arrWxBuilds;
00043 
00044 
00045 
00046 // ----------------------------------------------------------------------------
00047 // wxWidgetsBuild
00048 // ----------------------------------------------------------------------------
00049 
00050 wxString wxWidgetsBuild::GetUserFriendlyName() const
00051 {
00052     return wxString::Format(wxT("%s %s [%s - %s %s %s]"),
00053             wxPlatformInfo::GetPortIdName(m_port, false).c_str(),
00054             m_version.GetAsString().c_str(),
00055             wxPackageCompilerFormat2String(m_format).c_str(),
00056             m_bUnicode ? wxT("Unicode") : wxT("ANSI"),
00057             m_bStatic ? wxT("static") : wxT("DLL"),
00058             m_bDebug ? wxT("debug") : wxT("release"));
00059 }
00060 
00061 bool wxWidgetsBuild::Load(wxConfigBase *p, const wxString &path)
00062 {
00063     m_strLocation = p->Read(path + wxT("/Location"), wxEmptyString);
00064     m_version = p->Read(path + wxT("/Version"), wxEmptyString);
00065 
00066     m_port = (wxPortId)p->Read(path + wxT("/PortId"), 0l);
00067     m_format = (wxPackageCompilerFormat)p->Read(path + wxT("/Compiler"), 0l);
00068 
00069     p->Read(path + wxT("/Static"), &m_bStatic);
00070     p->Read(path + wxT("/Debug"), &m_bDebug);
00071     p->Read(path + wxT("/Unicode"), &m_bUnicode);
00072 
00073     return IsOk();
00074 }
00075 
00076 void wxWidgetsBuild::Save(wxConfigBase *p, const wxString &path) const
00077 {
00078     p->Write(path + wxT("/Location"), m_strLocation);
00079     p->Write(path + wxT("/Version"), m_version);
00080     p->Write(path + wxT("/PortId"), (long)m_port);
00081     p->Write(path + wxT("/Compiler"), (long)m_format);
00082 
00083     p->Write(path + wxT("/Static"), m_bStatic);
00084     p->Write(path + wxT("/Debug"), m_bDebug);
00085     p->Write(path + wxT("/Unicode"), m_bUnicode);
00086 }
00087 
00088 // static
00089 wxArrayString wxWidgetsBuild::GetSpecialOptionNames()
00090 {
00091     // FIXME: maybe these vars and the way they are modified could
00092     //        be not-hardcoded somehow ?
00093     wxArrayString specialopt;
00094     specialopt.Add(wxT("WX_DIR"));
00095     specialopt.Add(wxT("WX_VERSION"));
00096     specialopt.Add(wxT("WX_SHARED"));
00097     specialopt.Add(wxT("WX_UNICODE"));
00098     specialopt.Add(wxT("WX_DEBUG"));
00099 
00100     return specialopt;
00101 }
00102 
00103 void wxWidgetsBuild::UpdateOptions(wxPackageCommandOptionArray &arr) const
00104 {
00105     wxString ver = 
00106         wxString::Format(wxT("%d%d"), GetVersion().GetMajor(), GetVersion().GetMinor());
00107 
00108     arr.ItemByName(wxT("WX_DIR")).SetValue(GetLocation());
00109     arr.ItemByName(wxT("WX_VERSION")).SetValue(ver);
00110     arr.ItemByName(wxT("WX_SHARED")).SetValue(IsStaticBuild() ? wxT("0") : wxT("1"));
00111     arr.ItemByName(wxT("WX_UNICODE")).SetValue(IsUnicodeBuild() ? wxT("1") : wxT("0"));
00112     arr.ItemByName(wxT("WX_DEBUG")).SetValue(IsDebugBuild() ? wxT("1") : wxT("0"));
00113 }
00114 
00115 
00116 
00117 // ----------------------------------------------------------------------------
00118 // wxWidgetsBuildArray
00119 // ----------------------------------------------------------------------------
00120 
00121 // static
00122 bool wxWidgetsBuildArray::LoadGlobals(wxConfigBase *p, const wxString &path)
00123 {
00124     wxWidgetsBuild temp;
00125     wxString str;
00126     long dummy;
00127 
00128     // try to load everything under path/WxBuilds
00129     p->SetPath(path + wxT("/WxBuilds/"));
00130     bool bCont = p->GetFirstGroup(str, dummy);
00131     while ( bCont )
00132     {
00133         if (temp.Load(p, str))
00134             s_arrWxBuilds.Add(temp);
00135 
00136         bCont = p->GetNextGroup(str, dummy);
00137     }
00138 
00139     return true;
00140 }
00141 
00142 void wxWidgetsBuildArray::SaveGlobals(wxConfigBase *p, const wxString &path)
00143 {
00144     p->DeleteGroup(path + wxT("/WxBuilds"));
00145     for (size_t i=0; i<s_arrWxBuilds.GetCount(); i++)
00146         s_arrWxBuilds[i].Save(p, path + wxString::Format(wxT("/WxBuilds/build%d"), i));
00147 }
00148 
00149 

Generated on Thu Feb 1 22:14:31 2007 for wxWidgets Package Manager by  doxygen 1.5.1-p1