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 GenerateInitTarget ();
34 for ( size_t i
= 0; i
< ProjectNode
.modules
.size (); i
++ )
36 Module
& module
= *ProjectNode
.modules
[i
];
37 ProcessModule ( module
);
39 CheckAutomaticDependencies ();
44 MingwBackend::CreateMakefile ()
46 fMakefile
= fopen ( ProjectNode
.makefile
.c_str (), "w" );
48 throw AccessDeniedException ( ProjectNode
.makefile
);
49 MingwModuleHandler::SetMakefile ( fMakefile
);
53 MingwBackend::CloseMakefile () const
60 MingwBackend::GenerateHeader () const
62 fprintf ( fMakefile
, "# THIS FILE IS AUTOMATICALLY GENERATED, EDIT 'ReactOS.xml' INSTEAD\n\n" );
66 MingwBackend::GenerateProjectCFlagsMacro ( const char* assignmentOperation
,
67 const vector
<Include
*>& includes
,
68 const vector
<Define
*>& defines
) const
75 assignmentOperation
);
76 for ( i
= 0; i
< includes
.size(); i
++ )
81 includes
[i
]->directory
.c_str() );
84 for ( i
= 0; i
< defines
.size(); i
++ )
86 Define
& d
= *defines
[i
];
97 fprintf ( fMakefile
, "\n" );
101 MingwBackend::GenerateGlobalCFlagsAndProperties (
102 const char* assignmentOperation
,
103 const vector
<Property
*>& properties
,
104 const vector
<Include
*>& includes
,
105 const vector
<Define
*>& defines
,
106 const vector
<If
*>& ifs
) const
110 for ( i
= 0; i
< properties
.size(); i
++ )
112 Property
& prop
= *properties
[i
];
113 fprintf ( fMakefile
, "%s := %s\n",
115 prop
.value
.c_str() );
118 if ( includes
.size() || defines
.size() )
120 GenerateProjectCFlagsMacro ( assignmentOperation
,
125 for ( i
= 0; i
< ifs
.size(); i
++ )
128 if ( rIf
.defines
.size() || rIf
.includes
.size() || rIf
.ifs
.size() )
132 "ifeq (\"$(%s)\",\"%s\")\n",
133 rIf
.property
.c_str(),
135 GenerateGlobalCFlagsAndProperties (
149 MingwBackend::GenerateProjectLFLAGS () const
152 for ( size_t i
= 0; i
< ProjectNode
.linkerFlags
.size (); i
++ )
154 LinkerFlag
& linkerFlag
= *ProjectNode
.linkerFlags
[i
];
155 if ( lflags
.length () > 0 )
157 lflags
+= linkerFlag
.flag
;
163 MingwBackend::GenerateGlobalVariables () const
165 fprintf ( fMakefile
, "mkdir = tools" SSEP
"rmkdir" EXEPOSTFIX
"\n" );
166 fprintf ( fMakefile
, "winebuild = tools" SSEP
"winebuild" SSEP
"winebuild" EXEPOSTFIX
"\n" );
167 fprintf ( fMakefile
, "bin2res = tools" SSEP
"bin2res" SSEP
"bin2res" EXEPOSTFIX
"\n" );
168 fprintf ( fMakefile
, "cabman = tools" SSEP
"cabman" SSEP
"cabman" EXEPOSTFIX
"\n" );
169 fprintf ( fMakefile
, "cdmake = tools" SSEP
"cdmake" SSEP
"cdmake" EXEPOSTFIX
"\n" );
170 fprintf ( fMakefile
, "\n" );
171 GenerateGlobalCFlagsAndProperties (
173 ProjectNode
.properties
,
174 ProjectNode
.includes
,
177 fprintf ( fMakefile
, "PROJECT_RCFLAGS = $(PROJECT_CFLAGS)\n" );
178 fprintf ( fMakefile
, "PROJECT_LFLAGS = %s\n",
179 GenerateProjectLFLAGS ().c_str () );
180 fprintf ( fMakefile
, "\n" );
184 MingwBackend::IncludeInAllTarget ( const Module
& module
) const
186 if ( module
.type
== ObjectLibrary
)
188 if ( module
.type
== BootSector
)
190 if ( module
.type
== Iso
)
196 MingwBackend::GenerateAllTarget () const
198 fprintf ( fMakefile
, "all:" );
199 for ( size_t i
= 0; i
< ProjectNode
.modules
.size (); i
++ )
201 Module
& module
= *ProjectNode
.modules
[i
];
202 if ( IncludeInAllTarget ( module
) )
206 FixupTargetFilename ( module
.GetPath () ).c_str () );
209 fprintf ( fMakefile
, "\n\t\n\n" );
213 MingwBackend::GetBuildToolDependencies () const
216 for ( size_t i
= 0; i
< ProjectNode
.modules
.size (); i
++ )
218 Module
& module
= *ProjectNode
.modules
[i
];
219 if ( module
.type
== BuildTool
)
221 if ( dependencies
.length () > 0 )
223 dependencies
+= module
.GetDependencyPath ();
230 MingwBackend::GenerateInitTarget () const
235 " $(ROS_INTERMEDIATE)." SSEP
"tools" );
238 GetBuildToolDependencies ().c_str () );
241 "include" SSEP
"reactos" SSEP
"buildno.h" );
246 "$(ROS_INTERMEDIATE)." SSEP
"tools:\n" );
248 "ifneq ($(ROS_INTERMEDIATE),)\n" );
250 "\t${nmkdir} $(ROS_INTERMEDIATE)\n" );
254 "\t${nmkdir} $(ROS_INTERMEDIATE)." SSEP
"tools\n" );
260 MingwBackend::CheckAutomaticDependencies ()
262 AutomaticDependency
automaticDependency ( ProjectNode
);
263 automaticDependency
.Process ();
264 automaticDependency
.CheckAutomaticDependencies ();
268 MingwBackend::ProcessModule ( Module
& module
) const
270 MingwModuleHandler
* h
= MingwModuleHandler::LookupHandler (
271 module
.node
.location
,
273 h
->Process ( module
);
274 h
->GenerateDirectoryTargets ();
278 FixupTargetFilename ( const string
& targetFilename
)
280 return string("$(ROS_INTERMEDIATE)") + NormalizeFilename ( targetFilename
);