~ubuntu-branches/ubuntu/hardy/codeblocks/hardy-backports

« back to all changes in this revision

Viewing changes to src/plugins/compilergcc/compilerDMC.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michael Casadevall
  • Date: 2008-07-17 04:39:23 UTC
  • Revision ID: james.westby@ubuntu.com-20080717043923-gmsy5cwkdjswghkm
Tags: upstream-8.02
ImportĀ upstreamĀ versionĀ 8.02

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of the Code::Blocks IDE and licensed under the GNU General Public License, version 3
 
3
 * http://www.gnu.org/licenses/gpl-3.0.html
 
4
 *
 
5
 * $Revision: 4909 $
 
6
 * $Id: compilerDMC.cpp 4909 2008-02-27 13:15:26Z mortenmacfly $
 
7
 * $HeadURL: svn://svn.berlios.de/codeblocks/tags/8.02/src/plugins/compilergcc/compilerDMC.cpp $
 
8
 */
 
9
 
 
10
#ifdef __WXMSW__
 
11
// this compiler is valid only in windows
 
12
 
 
13
#include <sdk.h>
 
14
#include "compilerDMC.h"
 
15
#include <wx/intl.h>
 
16
#include <wx/regex.h>
 
17
#include <wx/config.h>
 
18
 
 
19
CompilerDMC::CompilerDMC()
 
20
    : Compiler(_("Digital Mars Compiler"), _T("dmc"))
 
21
{
 
22
    Reset();
 
23
}
 
24
 
 
25
CompilerDMC::~CompilerDMC()
 
26
{
 
27
        //dtor
 
28
}
 
29
 
 
30
Compiler * CompilerDMC::CreateCopy()
 
31
{
 
32
    Compiler* c = new CompilerDMC(*this);
 
33
    c->SetExtraPaths(m_ExtraPaths); // wxArrayString doesn't seem to be copied with the default copy ctor...
 
34
    return c;
 
35
}
 
36
 
 
37
void CompilerDMC::Reset()
 
38
{
 
39
        m_Programs.C = _T("dmc.exe");
 
40
        m_Programs.CPP = _T("dmc.exe");
 
41
        m_Programs.LD = _T("link.exe");
 
42
        m_Programs.LIB = _T("lib.exe");
 
43
        m_Programs.WINDRES = _T("rcc.exe");
 
44
        m_Programs.MAKE = _T("mingw32-make.exe");
 
45
 
 
46
        m_Switches.includeDirs = _T("-I");
 
47
        m_Switches.libDirs = _T("");
 
48
        m_Switches.linkLibs = _T("");
 
49
        m_Switches.libPrefix = _T("");
 
50
        m_Switches.libExtension = _T("lib");
 
51
        m_Switches.defines = _T("-D");
 
52
        m_Switches.genericSwitch = _T("-");
 
53
        m_Switches.objectExtension = _T("obj");
 
54
        m_Switches.needDependencies = false;
 
55
        m_Switches.forceCompilerUseQuotes = false;
 
56
        m_Switches.forceLinkerUseQuotes = true;
 
57
        m_Switches.logging = clogSimple;
 
58
        m_Switches.linkerNeedsLibPrefix = false;
 
59
        m_Switches.linkerNeedsLibExtension = true;
 
60
 
 
61
    m_Options.ClearOptions();
 
62
        m_Options.AddOption(_("Produce debugging symbols"),
 
63
                                _T("-g"),
 
64
                                _("Debugging"),
 
65
                                _T(""),
 
66
                                true,
 
67
                                _T("-o -o+space"),
 
68
                                _("You have optimizations enabled. This is Not A Good Thing(tm) when producing debugging symbols..."));
 
69
 
 
70
    //
 
71
    // TODO (hd#3#): should be simplified
 
72
    //
 
73
 
 
74
        //. m_Options.AddOption(_("Alignment of struct members"), "-a[1|2|4|8]", _("Architecture"));
 
75
        m_Options.AddOption(_("Enforce strict compliance with ANSI C/C++"), _T("-A"), _("C++ Features"));
 
76
        m_Options.AddOption(_("Enable new[] and delete[] overloading"), _T("-Aa"), _("C++ Features"));
 
77
        m_Options.AddOption(_("Enable bool"), _T("-Ab"), _("C++ Features"));
 
78
        m_Options.AddOption(_("Enable exception handling"), _T("-Ae"), _("C++ Features"));
 
79
        m_Options.AddOption(_("Enable RTTI"), _T("-Ar"), _("C++ Features"));
 
80
        //. m_Options.AddOption(_("Message language: English,French,German,Japanese"), _T("-B[e|f|g|j]"), _("Others"));
 
81
        //. m_Options.AddOption(_("Skip the link, do compile only"), _T("-c"), _("Others"));
 
82
        m_Options.AddOption(_("Compile all source files as C++"), _T("-cpp"), _("C++ Features"));
 
83
        m_Options.AddOption(_("Generate .cod (assemply) file"), _T("-cod"), _("Others"));
 
84
        m_Options.AddOption(_("No inline function expansion"), _T("-C"), _("Debugging"));
 
85
        m_Options.AddOption(_("Generate .dep (make dependency) file"), _T("-d"), _("Others"));
 
86
        m_Options.AddOption(_T("#define DEBUG 1"), _T("-D"), _("Debugging"));
 
87
        m_Options.AddOption(_("Show results of preprocessor"), _T("-e"), _("Others"));
 
88
        m_Options.AddOption(_("Do not elide comments"), _T("-EC"), _("Others"));
 
89
        m_Options.AddOption(_("#line directives not output"), _T("-EL"), _("Others"));
 
90
        m_Options.AddOption(_("IEEE 754 inline 8087 code"), _T("-f"), _("Others"));
 
91
        m_Options.AddOption(_("Work around FDIV problem"), _T("-fd"), _("Others"));
 
92
        m_Options.AddOption(_("Fast inline 8087 code"), _T("-ff"), _("Optimization"));
 
93
        m_Options.AddOption(_("Disable debug info optimization"), _T("-gf"), _("Optimization"));
 
94
        m_Options.AddOption(_("Make static functions global"), _T("-gg"), _("Optimization"));
 
95
        m_Options.AddOption(_("Symbol info for globals"), _T("-gh"), _("C++ Features"));
 
96
        m_Options.AddOption(_("Debug line numbers only"), _T("-gl"), _("Debugging"));
 
97
        m_Options.AddOption(_("Generate pointer validations"), _T("-gp"), _("Others"));
 
98
        m_Options.AddOption(_("Debug symbol info only"), _T("-gs"), _("Debugging"));
 
99
        m_Options.AddOption(_("Generate trace prolog/epilog"), _T("-gt"), _("Others"));
 
100
        //. m_Options.AddOption(_("Set data threshold to nnnn"), _T("-GTnnnn"), _("Others"));
 
101
        m_Options.AddOption(_("Use precompiled headers (ph)"), _T("-H"), _("Others"));
 
102
        //. m_Options.AddOption(_("Use ph from directory"), _T("-HDdirectory"), _("Others"));
 
103
        //. m_Options.AddOption(_("Generate ph to filename"), _T("-HF[filename]"), _("Others"));
 
104
        //. m_Options.AddOption(_("#include \"filename\""), _T("-HIfilename"), _("Others"));
 
105
        m_Options.AddOption(_("Include files only once"), _T("-HO"), _("Others"));
 
106
        m_Options.AddOption(_("Only search -I directories"), _T("-HS"), _("Others"));
 
107
        //. m_Options.AddOption(_("#include file search path"), _T("-Ipath"), _("Others"));
 
108
        //. m_Options.AddOption(_("Asian language characters (Japanese)"), _T("-j0"), _("Others"));
 
109
        //. m_Options.AddOption(_("Asian language characters (Taiwanese/Chinese)"), _T("-j1"), _("Others"));
 
110
        //. m_Options.AddOption(_("Asian language characters (Korean)"), _T("-j2"), _("Others"));
 
111
        m_Options.AddOption(_("Relaxed type checking"), _T("-Jm"), _("Others"));
 
112
        m_Options.AddOption(_T("char==unsigned"), _T("-Ju"), _("Others"));
 
113
        m_Options.AddOption(_("No empty base class optimization"), _T("-Jb"), _("Optimization"));
 
114
        m_Options.AddOption(_("chars are unsigned"), _T("-J"), _("Others"));
 
115
        //. m_Options.AddOption(_("Generate list file"), _T("-l[listfile]"), _("Others"));
 
116
        //. m_Options.AddOption(_("Using non-Digital Mars linker"), _T("-L"), _("Others"));
 
117
        //. m_Options.AddOption(_("Specify linker to use"), _T("-Llink"), _("Others"));
 
118
        //. m_Options.AddOption(_("Pass /switch to linker"), _T("-L/switch"), _("Others"));
 
119
        //. m_Options.AddOption(_("Specify assembler to use"), _T("-Masm"), _("Others"));
 
120
        //. m_Options.AddOption(_("Pass /switch to assembler"), _T("-M/switch"), _("Others"));
 
121
        //. m_Options.AddOption(_("Set memory model (-mn: Windows)"), _T("-m[tsmclvfnrpxz][do][w][u]"), _("Architecture"));
 
122
        m_Options.AddOption(_("Perform function level linking"), _T("-Nc"), _("Optimization"));
 
123
        m_Options.AddOption(_("No default library"), _T("-NL"), _("Optimization"));
 
124
        m_Options.AddOption(_("Place expr strings in code seg"), _T("-Ns"), _("Optimization"));
 
125
        m_Options.AddOption(_("New code seg for each function"), _T("-NS"), _("Optimization"));
 
126
        //. m_Options.AddOption(_("Set code segment name"), _T("-NTname"), _("Others"));
 
127
        m_Options.AddOption(_("vtables in far data"), _T("-NV"), _("Others"));
 
128
        //. m_Options.AddOption(_("Run optimizer with flag"), _T("-o[-+flag]"), _("Optimization"));
 
129
        m_Options.AddOption(_("Minimize space"), _T("-o+space"), _("Optimization"));
 
130
        m_Options.AddOption(_("Maximize speed"), _T("-o"), _("Optimization"));
 
131
        //. m_Options.AddOption(_("Output filename"), _T("-ooutput"), _("Others"));
 
132
        m_Options.AddOption(_("Turn off function auto-prototyping"), _T("-p"), _("Others"));
 
133
        m_Options.AddOption(_("Make Pascal linkage the default"), _T("-P"), _("Linkage"));
 
134
        m_Options.AddOption(_("Make stdcall linkage the default"), _T("-Pz"), _("Linkage"));
 
135
        m_Options.AddOption(_("Require strict function prototyping"), _T("-r"), _("Others"));
 
136
        m_Options.AddOption(_("Put switch tables in code seg"), _T("-R"), _("Others"));
 
137
        m_Options.AddOption(_("Stack overflow checking"), _T("-s"), _("Others"));
 
138
        m_Options.AddOption(_("Always generate stack frame"), _T("-S"), _("Others"));
 
139
        m_Options.AddOption(_("Suppress non-ANSI predefined macros"), _T("-u"), _("C++ Features"));
 
140
        //. m_Options.AddOption(_("Verbose compile"), _T("-v[0|1|2]"), _("Warnings"));
 
141
        m_Options.AddOption(_("Suppress all warning messages"), _T("-w"), _("Warnings"));
 
142
        m_Options.AddOption(_("Warn on C style casts"), _T("-wc"), _("Warnings"));
 
143
        //. m_Options.AddOption(_("Suppress warning number n"), _T("-wn"), _("Warnings"));
 
144
        m_Options.AddOption(_("Treat warnings as errors"), _T("-wx"), _("Warnings"));
 
145
        //. m_Options.AddOption(_("Windows prolog/epilog (-WA exe -WD dll)"), _T("-W{0123ADabdefmrstuvwx-+}"), _("Architecture"));
 
146
        m_Options.AddOption(_("Windows prolog/epilog : Win32 Exe"), _T("-WA"), _("Architecture"));
 
147
        m_Options.AddOption(_("Windows prolog/epilog : Win32 Dll"), _T("-WD"), _("Architecture"));
 
148
        m_Options.AddOption(_("Turn off error maximum"), _T("-x"), _("Warnings"));
 
149
        m_Options.AddOption(_("Instantiate templates"), _T("-XD"), _("C++ Features"));
 
150
        //. m_Options.AddOption(_("Instantiate template class temp<type>"), _T("-XItemp<type>"), _("C++ Features"));
 
151
        //. m_Options.AddOption(_("Instantiate template function func(type)"), _T("-XIfunc(type)"), _("C++ Features"));
 
152
        //. m_Options.AddOption(_("8088/286/386/486/Pentium/P6 code"), _T("-[0|2|3|4|5|6]"), _("Architecture"));
 
153
        m_Options.AddOption(_("Optimize for 80386"), _T("-3"), _("Architecture"));
 
154
        m_Options.AddOption(_("Optimize for 80486"), _T("-4"), _("Architecture"));
 
155
        m_Options.AddOption(_("Optimize for Pentium"), _T("-5"), _("Architecture"));
 
156
        m_Options.AddOption(_("Optimize for Pentium Pro, Pentium II, Pentium III"), _T("-6"), _("Architecture"));
 
157
 
 
158
    // FIXME (hd#1#): should be work on: we need $res_options
 
159
    m_Commands[(int)ctCompileObjectCmd].push_back( CompilerTool(_T("$compiler -mn -c $options $includes -o$object $file")) );
 
160
    m_Commands[(int)ctCompileResourceCmd].push_back( CompilerTool(_T("$rescomp -32 -I$res_includes -o$resource_output $file")) );
 
161
    m_Commands[(int)ctLinkExeCmd].push_back( CompilerTool(_T("$linker /NOLOGO /subsystem:windows $link_objects, $exe_output, , $libs $link_options, , $link_resobjects")) );
 
162
    m_Commands[(int)ctLinkConsoleExeCmd].push_back( CompilerTool(_T("$linker /NOLOGO $link_objects, $exe_output, , $libs $link_options")) );
 
163
    m_Commands[(int)ctLinkDynamicCmd].push_back( CompilerTool(_T("$linker /NOLOGO /subsystem:windows $link_objects, $exe_output, , $libs $link_options, , $link_resobjects")) );
 
164
    m_Commands[(int)ctLinkStaticCmd].push_back( CompilerTool(_T("$lib_linker -c $link_options $static_output $link_objects")) );
 
165
    m_Commands[(int)ctLinkNativeCmd] = m_Commands[(int)ctLinkConsoleExeCmd]; // unsupported currently
 
166
 
 
167
    LoadDefaultRegExArray();
 
168
 
 
169
    m_CompilerOptions.Clear();
 
170
    m_LinkerOptions.Clear();
 
171
    m_LinkLibs.Clear();
 
172
    m_CmdsBefore.Clear();
 
173
    m_CmdsAfter.Clear();
 
174
}
 
175
 
 
176
void CompilerDMC::LoadDefaultRegExArray()
 
177
{
 
178
    m_RegExes.Clear();
 
179
    m_RegExes.Add(RegExStruct(_("Linker error"), cltError, _T("(") + FilePathWithSpaces + _T(")[ \t]+:[ \t]+(.*error LNK[0-9]+.*)"), 2, 1));
 
180
    m_RegExes.Add(RegExStruct(_("Compiler warning"), cltWarning, _T("(") + FilePathWithSpaces + _T(")\\(([0-9]+)\\)[ \t]*:[ \t]*[Ww][Aa][Rr][Nn][Ii][Nn][Gg][ \t]*(.*)"), 3, 1, 2));
 
181
    m_RegExes.Add(RegExStruct(_("Compiler error"), cltError, _T("(") + FilePathWithSpaces + _T(")\\(([0-9]+)\\)[ \t]*:[ \t]*(.*)"), 3, 1, 2));
 
182
    m_RegExes.Add(RegExStruct(_("Fatal error"), cltError, _T("Fatal error:[ \t](.*)"), 1));
 
183
}
 
184
 
 
185
AutoDetectResult CompilerDMC::AutoDetectInstallationDir()
 
186
{
 
187
    // just a guess; the default installation dir
 
188
        m_MasterPath = _T("C:\\dm");
 
189
    wxString sep = wxFileName::GetPathSeparator();
 
190
 
 
191
    // NOTE (hd#1#): dmc uses sc.ini for compiler's master directories
 
192
    // NOTE (mandrav#1#): which doesn't seem to exist if you don't have the CD version ;)
 
193
    if (!m_MasterPath.IsEmpty())
 
194
    {
 
195
        AddIncludeDir(m_MasterPath + sep + _T("stlport") + sep + _T("stlport"));
 
196
        AddIncludeDir(m_MasterPath + sep + _T("include"));
 
197
        AddLibDir(m_MasterPath + sep + _T("lib"));
 
198
    }
 
199
 
 
200
    return wxFileExists(m_MasterPath + sep + _T("bin") + sep + m_Programs.C) ? adrDetected : adrGuessed;
 
201
}
 
202
 
 
203
#endif // __WXMSW__