00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012 #ifndef _COMPILER_H_
00013 #define _COMPILER_H_
00014
00015
00016 #include "wx/tokenzr.h"
00017 #include "wxp/wxputils.h"
00018
00019
00020 class wxStringHashMap;
00021 class wxPackageCommandOptionArray;
00022 class wxConfigBase;
00023 class wxPackageInfo;
00024 class wxPackageArray;
00025
00026
00027
00028
00029
00030
00032 enum wxPackageBuildSystemStage
00033 {
00034 wxPBSS_INVALID = -1,
00035
00036 wxPBSS_BUILD = 1,
00037 wxPBSS_INSTALL = 2,
00038 wxPBSS_UNINSTALL = 4,
00039 wxPBSS_CLEAN = 8,
00040
00041 wxPBSS_MAX = 4
00042 };
00043
00046 enum wxPackageBuildSystemType
00047 {
00048 wxPBST_INVALID = -1,
00049
00050 wxPBST_BAKEFILE = 1,
00051 wxPBST_CMAKE = 2,
00052 wxPBST_SCONS = 4,
00053 wxPBST_MAKEFILE = 8,
00054
00055 wxPBST_MAX = 4
00056 };
00057
00072 enum wxPackageCompilerFormat
00073 {
00074 wxPCF_INVALID = -1,
00075
00076
00077 wxPCF_BORLAND = 1,
00078 wxPCF_MSVC = 2,
00079 wxPCF_WATCOM = 4,
00080 wxPCF_MINGW = 8,
00081 wxPCF_MSYS = 16,
00082
00083
00084 wxPCF_GNUMAKEFILE = 32,
00085 wxPCF_AUTOCONF = 64,
00086
00087 wxPCF_MAX = 7
00088 };
00089
00091 enum wxPackageCompilerPathType
00092 {
00093 wxPCPT_INVALID = -1,
00094
00095 wxPCPT_BIN,
00096 wxPCPT_INCLUDE,
00097 wxPCPT_LIB,
00098
00099 wxPCPT_MAX
00100 };
00101
00102 wxDEFINE_STRING2COMBINEABLE_ENUM(PackageBuildSystemStage)
00103 wxDEFINE_STRING2COMBINEABLE_ENUM(PackageBuildSystemType)
00104 wxDEFINE_STRING2COMBINEABLE_ENUM(PackageCompilerFormat)
00105 wxDEFINE_STRING2ENUM(PackageCompilerPathType)
00106
00107
00108
00109
00112 bool wxIsCompilerFormatSupportedBy(wxPackageCompilerFormat fmt,
00113 wxPackageBuildSystemType buildsys);
00114
00116 int wxGetBuildSystemsSupportingCompilerFormat(wxPackageCompilerFormat fmt);
00117
00119 bool wxIsCompilerFormatSupportedByThisPlatform(wxPackageCompilerFormat fmt);
00120
00121
00122
00123
00124
00125
00127 class wxCompilerSettings
00128 {
00129 protected:
00130
00132 static wxPathList s_paths[wxPCF_MAX][wxPCPT_MAX];
00133
00135 static wxPackageCompilerFormat s_defaultFormat;
00136
00137 protected:
00138
00139
00140
00141
00143 wxPackageCompilerFormat s_selFormat;
00144
00145 public:
00146
00147 wxCompilerSettings()
00148 { s_selFormat=s_defaultFormat; }
00149
00150
00151 public:
00152
00154 static wxPathList &GetCompilerPaths(wxPackageCompilerFormat n,
00155 wxPackageCompilerPathType t)
00156 { return s_paths[wxPackageCompilerFormat2Idx(n)][t]; }
00157
00159 static wxPackageCompilerFormat GetDefaultFormat()
00160 { return s_defaultFormat; }
00161
00162 public:
00163
00165 static void SetDefaultFormat(wxPackageCompilerFormat newfmt)
00166 { s_defaultFormat=newfmt; }
00167
00168
00169 public:
00170
00171 wxPathList GetCompilerPaths(wxPackageCompilerPathType t) const
00172 { return GetCompilerPaths(s_selFormat, t); }
00173
00175 wxPackageCompilerFormat GetSelFormat() const
00176 { return s_selFormat; }
00177
00179 void SetSelFormat(wxPackageCompilerFormat newfmt)
00180 { wxASSERT(newfmt!=wxPCF_INVALID); s_selFormat=newfmt; }
00181
00182 public:
00183
00188 wxStringHashMap GetOptionsWithDefaults(wxPackageBuildSystemType) const;
00189
00190 public:
00191
00194 static bool IsValidPathList(wxPackageCompilerFormat fmt, const wxPathList &);
00195
00199 static wxString GetToolPath(wxPackageCompilerFormat fmt, const wxString &program)
00200 { return s_paths[fmt][wxPCPT_BIN].FindAbsoluteValidPath(program); }
00201
00206 static wxArrayString GetRequiredToolsList(wxPackageCompilerFormat fmt);
00207
00209 static void SetCompilerPaths(wxPackageCompilerFormat n,
00210 wxPackageCompilerPathType t,
00211 const wxPathList &str)
00212 { s_paths[wxPackageCompilerFormat2Idx(n)][t] = str; }
00213
00215 static void AddPath(wxPackageCompilerFormat f,
00216 wxPackageCompilerPathType t,
00217 const wxString &str)
00218 { s_paths[wxPackageCompilerFormat2Idx(f)][t].Add(str); }
00219
00220 public:
00221
00222 bool IsValidPathList(const wxPathList &pl) const
00223 { return IsValidPathList(s_selFormat, pl); }
00224
00225 wxArrayString GetRequiredToolsList() const
00226 { return GetRequiredToolsList(s_selFormat); }
00227
00228 wxString GetToolPath(const wxString &program) const
00229 { return GetToolPath(s_selFormat, program); }
00230
00234 void UpdateEnvVars();
00235 void UpdateEnvVar(const wxString &name, wxPackageCompilerPathType t);
00236
00239 wxStringHashMap GetSubstitutionHashMap(wxPackageBuildSystemType t = wxPBST_INVALID) const;
00240
00241 public:
00242
00244 bool Load(wxConfigBase *, const wxString &path);
00245
00247 void Save(wxConfigBase *, const wxString &path) const;
00248
00250 static bool LoadGlobals(wxConfigBase *, const wxString &path);
00251
00253 static void SaveGlobals(wxConfigBase *, const wxString &path);
00254 };
00255
00256 #endif // _COMPILER_H_
00257