9 static class MingwFactory
: public Backend::Factory
12 MingwFactory() : Factory ( "mingw" ) {}
13 Backend
* operator() ( Project
& project
)
15 return new MingwBackend ( project
);
20 MingwBackend::MingwBackend ( Project
& project
)
26 MingwBackend::Process ()
30 GenerateGlobalVariables ();
32 for ( size_t i
= 0; i
< ProjectNode
.modules
.size (); i
++ )
34 Module
& module
= *ProjectNode
.modules
[i
];
35 ProcessModule ( module
);
41 MingwBackend::CreateMakefile ()
43 fMakefile
= fopen ( ProjectNode
.makefile
.c_str (), "w" );
45 throw AccessDeniedException ( ProjectNode
.makefile
);
46 MingwModuleHandler::SetMakefile ( fMakefile
);
50 MingwBackend::CloseMakefile ()
57 MingwBackend::GenerateHeader ()
59 fprintf ( fMakefile
, "# THIS FILE IS AUTOMATICALLY GENERATED, EDIT 'ReactOS.xml' INSTEAD\n\n" );
63 MingwBackend::GenerateProjectCFLAGS ()
67 for ( i
= 0; i
< ProjectNode
.includes
.size (); i
++ )
69 Include
& include
= *ProjectNode
.includes
[i
];
70 if (clags
.length () > 0)
72 clags
+= "-I" + include
.directory
;
75 for ( i
= 0; i
< ProjectNode
.defines
.size (); i
++ )
77 Define
& define
= *ProjectNode
.defines
[i
];
78 if ( clags
.length () > 0 )
80 clags
+= "-D" + define
.name
;
81 if ( define
.value
.size() > 0 )
84 clags
+= define
.value
;
91 MingwBackend::GenerateGlobalVariables ()
95 fprintf ( fMakefile
, "host_gcc = gcc\n" );
96 fprintf ( fMakefile
, "host_ar = ar\n" );
97 fprintf ( fMakefile
, "host_ld = ld\n" );
98 fprintf ( fMakefile
, "rm = del /f /q\n" );
99 fprintf ( fMakefile
, "gcc = gcc\n" );
100 fprintf ( fMakefile
, "ld = ld\n" );
101 fprintf ( fMakefile
, "ar = ar\n" );
102 fprintf ( fMakefile
, "dlltool = dlltool\n" );
103 fprintf ( fMakefile
, "PROJECT_CFLAGS = %s\n", GenerateProjectCFLAGS ().c_str () );
104 for ( i
= 0; i
< ProjectNode
.properties
.size(); i
++ )
106 Property
& prop
= *ProjectNode
.properties
[i
];
107 fprintf ( fMakefile
, "%s := %s\n",
109 prop
.value
.c_str() );
111 fprintf ( fMakefile
, "\n" );
115 MingwBackend::GenerateAllTarget ()
117 fprintf ( fMakefile
, "all:" );
118 for ( size_t i
= 0; i
< ProjectNode
.modules
.size (); i
++ )
120 Module
& module
= *ProjectNode
.modules
[i
];
123 FixupTargetFilename ( module
.GetPath () ).c_str () );
125 fprintf ( fMakefile
, "\n\t\n\n" );
129 MingwBackend::ProcessModule ( Module
& module
)
131 MingwModuleHandler
* h
= MingwModuleHandler::LookupHandler (
132 module
.node
.location
,
134 h
->Process ( module
);
138 FixupTargetFilename ( const string
& targetFilename
)
140 return string("$(ROS_INTERMEDIATE)") + targetFilename
;