10 static class MingwFactory
: public Backend::Factory
13 MingwFactory() : Factory ( "mingw" ) {}
14 Backend
* operator() ( Project
& project
)
16 return new MingwBackend ( project
);
21 MingwBackend::MingwBackend ( Project
& project
)
27 MingwBackend::Process ()
31 GenerateGlobalVariables ();
33 for ( size_t i
= 0; i
< ProjectNode
.modules
.size (); i
++ )
35 Module
& module
= *ProjectNode
.modules
[i
];
36 ProcessModule ( module
);
42 MingwBackend::CreateMakefile ()
44 fMakefile
= fopen ( ProjectNode
.makefile
.c_str (), "w" );
46 throw AccessDeniedException ( ProjectNode
.makefile
);
47 MingwModuleHandler::SetMakefile ( fMakefile
);
51 MingwBackend::CloseMakefile () const
58 MingwBackend::GenerateHeader () const
60 fprintf ( fMakefile
, "# THIS FILE IS AUTOMATICALLY GENERATED, EDIT 'ReactOS.xml' INSTEAD\n\n" );
64 MingwBackend::GenerateProjectCFlagsMacro ( const char* assignmentOperation
,
65 const vector
<Include
*>& includes
,
66 const vector
<Define
*>& defines
) const
73 assignmentOperation
);
74 for ( i
= 0; i
< includes
.size(); i
++ )
79 includes
[i
]->directory
.c_str() );
82 for ( i
= 0; i
< defines
.size(); i
++ )
84 Define
& d
= *defines
[i
];
95 fprintf ( fMakefile
, "\n" );
99 MingwBackend::GenerateGlobalCFlagsAndProperties (
100 const char* assignmentOperation
,
101 const vector
<Property
*>& properties
,
102 const vector
<Include
*>& includes
,
103 const vector
<Define
*>& defines
,
104 const vector
<If
*>& ifs
) const
108 for ( i
= 0; i
< properties
.size(); i
++ )
110 Property
& prop
= *properties
[i
];
111 fprintf ( fMakefile
, "%s := %s\n",
113 prop
.value
.c_str() );
116 if ( includes
.size() || defines
.size() )
118 GenerateProjectCFlagsMacro ( assignmentOperation
,
123 for ( i
= 0; i
< ifs
.size(); i
++ )
126 if ( rIf
.defines
.size() || rIf
.includes
.size() || rIf
.ifs
.size() )
130 "ifeq (\"$(%s)\",\"%s\")\n",
131 rIf
.property
.c_str(),
133 GenerateGlobalCFlagsAndProperties (
147 MingwBackend::GenerateProjectLFLAGS () const
150 for ( size_t i
= 0; i
< ProjectNode
.linkerFlags
.size (); i
++ )
152 LinkerFlag
& linkerFlag
= *ProjectNode
.linkerFlags
[i
];
153 if ( lflags
.length () > 0 )
155 lflags
+= linkerFlag
.flag
;
161 MingwBackend::GenerateGlobalVariables () const
164 fprintf ( fMakefile
, "host_gcc = gcc\n" );
165 fprintf ( fMakefile
, "host_gpp = g++\n" );
166 fprintf ( fMakefile
, "host_ld = ld\n" );
167 fprintf ( fMakefile
, "host_ar = ar\n" );
168 fprintf ( fMakefile
, "host_objcopy = objcopy\n" );
169 fprintf ( fMakefile
, "rm = del /f /q\n" );
170 fprintf ( fMakefile
, "gcc = gcc\n" );
171 fprintf ( fMakefile
, "gpp = g++\n" );
172 fprintf ( fMakefile
, "ld = ld\n" );
173 fprintf ( fMakefile
, "ar = ar\n" );
174 fprintf ( fMakefile
, "objcopy = objcopy\n" );
175 fprintf ( fMakefile
, "dlltool = dlltool\n" );
176 fprintf ( fMakefile
, "windres = windres\n" );
178 fprintf ( fMakefile
, "host_gcc = gcc\n" );
179 fprintf ( fMakefile
, "host_gpp = g++\n" );
180 fprintf ( fMakefile
, "host_ld = ld\n" );
181 fprintf ( fMakefile
, "host_ar = ar\n" );
182 fprintf ( fMakefile
, "host_objcopy = objcopy\n" );
183 fprintf ( fMakefile
, "rm = rm -f\n" );
184 fprintf ( fMakefile
, "gcc = mingw32-gcc\n" );
185 fprintf ( fMakefile
, "gpp = mingw32-g++\n" );
186 fprintf ( fMakefile
, "ld = mingw32-ld\n" );
187 fprintf ( fMakefile
, "ar = mingw32-ar\n" );
188 fprintf ( fMakefile
, "objcopy = mingw32-objcopy\n" );
189 fprintf ( fMakefile
, "dlltool = mingw32-dlltool\n" );
190 fprintf ( fMakefile
, "windres = mingw32-windres\n" );
192 fprintf ( fMakefile
, "mkdir = tools%crmkdir\n", CSEP
);
193 fprintf ( fMakefile
, "NUL=NUL\n" );
194 fprintf ( fMakefile
, "winebuild = tools" SSEP
"winebuild" SSEP
"winebuild\n" );
195 fprintf ( fMakefile
, "bin2res = tools" SSEP
"bin2res" SSEP
"bin2res\n" );
196 fprintf ( fMakefile
, "cabman = tools" SSEP
"cabman" SSEP
"cabman\n" );
197 fprintf ( fMakefile
, "cdmake = tools" SSEP
"cdmake" SSEP
"cdmake\n" );
198 fprintf ( fMakefile
, "\n" );
199 GenerateGlobalCFlagsAndProperties (
201 ProjectNode
.properties
,
202 ProjectNode
.includes
,
205 fprintf ( fMakefile
, "PROJECT_RCFLAGS = $(PROJECT_CFLAGS)\n" );
206 fprintf ( fMakefile
, "PROJECT_LFLAGS = %s\n",
207 GenerateProjectLFLAGS ().c_str () );
208 fprintf ( fMakefile
, "\n" );
210 fprintf ( fMakefile
, ".PHONY: clean\n\n" );
214 MingwBackend::IncludeInAllTarget ( const Module
& module
) const
216 if ( module
.type
== ObjectLibrary
)
218 if ( module
.type
== BootSector
)
220 if ( module
.type
== Iso
)
226 MingwBackend::GenerateAllTarget () const
228 fprintf ( fMakefile
, "all:" );
229 for ( size_t i
= 0; i
< ProjectNode
.modules
.size (); i
++ )
231 Module
& module
= *ProjectNode
.modules
[i
];
232 if ( IncludeInAllTarget ( module
) )
236 FixupTargetFilename ( module
.GetPath () ).c_str () );
239 fprintf ( fMakefile
, "\n\t\n\n" );
243 MingwBackend::ProcessModule ( Module
& module
) const
245 MingwModuleHandler
* h
= MingwModuleHandler::LookupHandler (
246 module
.node
.location
,
248 h
->Process ( module
);
249 h
->GenerateDirectoryTargets ();
253 FixupTargetFilename ( const string
& targetFilename
)
255 return string("$(ROS_INTERMEDIATE)") + NormalizeFilename ( targetFilename
);