4 #include "../../rbuild.h"
6 #include "modulehandler.h"
13 typedef set
<string
> set_string
;
15 map
<ModuleType
,MingwModuleHandler
*>*
16 MingwModuleHandler::handler_map
= NULL
;
18 MingwModuleHandler::directory_set
;
20 MingwModuleHandler::ref
= 0;
23 MingwModuleHandler::fMakefile
= NULL
;
26 ReplaceExtension ( const string
& filename
,
27 const string
& newExtension
)
29 size_t index
= filename
.find_last_of ( '/' );
30 if (index
== string::npos
) index
= 0;
31 string tmp
= filename
.substr( index
, filename
.size() - index
);
32 size_t ext_index
= tmp
.find_last_of( '.' );
33 if (ext_index
!= string::npos
)
34 return filename
.substr ( 0, index
+ ext_index
) + newExtension
;
35 return filename
+ newExtension
;
39 MingwModuleHandler::MingwModuleHandler ( ModuleType moduletype
)
42 handler_map
= new map
<ModuleType
,MingwModuleHandler
*>;
43 (*handler_map
)[moduletype
] = this;
46 MingwModuleHandler::~MingwModuleHandler()
56 MingwModuleHandler::PassThruCacheDirectory( const string
&file
) const
58 directory_set
.insert( ReplaceExtension( GetDirectory( file
), "" ) );
63 MingwModuleHandler::SetMakefile ( FILE* f
)
69 MingwModuleHandler::LookupHandler ( const string
& location
,
70 ModuleType moduletype
)
73 throw Exception ( "internal tool error: no registered module handlers" );
74 MingwModuleHandler
* h
= (*handler_map
)[moduletype
];
77 throw UnknownModuleTypeException ( location
, moduletype
);
84 MingwModuleHandler::GetWorkingDirectory () const
90 MingwModuleHandler::GetDirectory ( const string
& filename
)
92 size_t index
= filename
.find_last_of ( CSEP
);
93 if (index
== string::npos
)
96 return filename
.substr ( 0, index
);
100 MingwModuleHandler::GetBasename ( const string
& filename
) const
102 size_t index
= filename
.find_last_of ( '.' );
103 if (index
!= string::npos
)
104 return filename
.substr ( 0, index
);
109 MingwModuleHandler::GetActualSourceFilename ( const string
& filename
) const
111 string extension
= GetExtension ( filename
);
112 if ( extension
== ".spec" || extension
== "SPEC" )
114 string basename
= GetBasename( filename
);
115 return basename
+ ".stubs.c";
122 MingwModuleHandler::GetModuleArchiveFilename ( const Module
& module
) const
124 return ReplaceExtension ( FixupTargetFilename ( module
.GetPath () ),
129 MingwModuleHandler::IsGeneratedFile ( const File
& file
) const
131 string extension
= GetExtension ( file
.name
);
132 if ( extension
== ".spec" || extension
== "SPEC" )
139 MingwModuleHandler::GetImportLibraryDependency ( const Module
& importedModule
) const
141 if ( importedModule
.type
== ObjectLibrary
)
142 return GetObjectsMacro ( importedModule
);
144 return PassThruCacheDirectory ( FixupTargetFilename ( importedModule
.GetDependencyPath () ) );
148 MingwModuleHandler::GetImportLibraryDependencies ( const Module
& module
) const
150 string
dependencies ( "" );
151 for ( size_t i
= 0; i
< module
.libraries
.size (); i
++ )
153 if ( dependencies
.size () > 0 )
155 const Module
* importedModule
= module
.project
.LocateModule ( module
.libraries
[i
]->name
);
156 assert ( importedModule
!= NULL
);
157 dependencies
+= GetImportLibraryDependency ( *importedModule
);
163 MingwModuleHandler::GetModuleDependencies ( const Module
& module
) const
165 if ( module
.dependencies
.size () == 0 )
168 string
dependencies ( "" );
169 for ( size_t i
= 0; i
< module
.dependencies
.size (); i
++ )
171 if ( dependencies
.size () > 0 )
173 const Dependency
* dependency
= module
.dependencies
[i
];
174 const Module
* dependencyModule
= dependency
->dependencyModule
;
175 dependencies
+= dependencyModule
->GetTargets ();
177 string definitionDependencies
= GetDefinitionDependencies ( module
);
178 if ( dependencies
.length () > 0 && definitionDependencies
.length () > 0 )
179 dependencies
+= " " + definitionDependencies
;
180 else if ( definitionDependencies
.length () > 0 )
181 dependencies
= definitionDependencies
;
186 MingwModuleHandler::GetAllDependencies ( const Module
& module
) const
188 string dependencies
= GetImportLibraryDependencies ( module
);
189 string s
= GetModuleDependencies ( module
);
199 MingwModuleHandler::GetSourceFilenames ( const Module
& module
,
200 bool includeGeneratedFiles
) const
204 string
sourceFilenames ( "" );
205 for ( i
= 0; i
< module
.files
.size (); i
++ )
207 if ( includeGeneratedFiles
|| !IsGeneratedFile ( *module
.files
[i
] ) )
208 sourceFilenames
+= " " + GetActualSourceFilename ( module
.files
[i
]->name
);
210 vector
<If
*> ifs
= module
.ifs
;
211 for ( i
= 0; i
< ifs
.size(); i
++ )
215 for ( j
= 0; j
< rIf
.ifs
.size(); j
++ )
216 ifs
.push_back ( rIf
.ifs
[j
] );
217 for ( j
= 0; j
< rIf
.files
.size(); j
++ )
219 if ( includeGeneratedFiles
|| !IsGeneratedFile ( *rIf
.files
[j
] ) )
220 sourceFilenames
+= " " + GetActualSourceFilename ( rIf
.files
[j
]->name
);
223 return sourceFilenames
;
227 MingwModuleHandler::GetSourceFilenames ( const Module
& module
) const
229 return GetSourceFilenames ( module
,
234 MingwModuleHandler::GetSourceFilenamesWithoutGeneratedFiles ( const Module
& module
) const
236 return GetSourceFilenames ( module
,
241 MingwModuleHandler::GetObjectFilename ( const string
& sourceFilename
)
244 string extension
= GetExtension ( sourceFilename
);
245 if ( extension
== ".rc" || extension
== ".RC" )
246 newExtension
= ".coff";
247 else if ( extension
== ".spec" || extension
== ".SPEC" )
248 newExtension
= ".stubs.o";
251 return FixupTargetFilename (
252 ReplaceExtension ( sourceFilename
, newExtension
) );
256 MingwModuleHandler::GetObjectFilenames ( const Module
& module
) const
258 if ( module
.files
.size () == 0 )
261 string
objectFilenames ( "" );
262 for ( size_t i
= 0; i
< module
.files
.size (); i
++ )
264 if ( objectFilenames
.size () > 0 )
265 objectFilenames
+= " ";
266 objectFilenames
+= PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( module
.files
[i
]->name
) );
268 return objectFilenames
;
272 MingwModuleHandler::GenerateDirectoryTargets() const
274 set_string::iterator i
;
275 fprintf( fMakefile
, "ifneq ($(ROS_INTERMEDIATE),)\ndirectories::" );
277 for ( i
= directory_set
.begin();
278 i
!= directory_set
.end();
281 fprintf ( fMakefile
, " %s", i
->c_str() );
284 fprintf( fMakefile
, "\n\n" );
286 for ( i
= directory_set
.begin();
287 i
!= directory_set
.end();
290 fprintf ( fMakefile
, "%s ", i
->c_str() );
294 "::\n\t${mkdir} $@\n\n"
299 directory_set
.clear();
303 MingwModuleHandler::GenerateGccDefineParametersFromVector ( const vector
<Define
*>& defines
) const
306 for ( size_t i
= 0; i
< defines
.size (); i
++ )
308 Define
& define
= *defines
[i
];
309 if (parameters
.length () > 0)
312 parameters
+= define
.name
;
313 if (define
.value
.length () > 0)
316 parameters
+= define
.value
;
323 MingwModuleHandler::GenerateGccDefineParameters ( const Module
& module
) const
325 string parameters
= GenerateGccDefineParametersFromVector ( module
.project
.defines
);
326 string s
= GenerateGccDefineParametersFromVector ( module
.defines
);
327 if ( s
.length () > 0 )
336 MingwModuleHandler::ConcatenatePaths ( const string
& path1
,
337 const string
& path2
) const
339 if ( ( path1
.length () == 0 ) || ( path1
== "." ) || ( path1
== "./" ) )
341 if ( path1
[path1
.length ()] == CSEP
)
342 return path1
+ path2
;
344 return path1
+ CSEP
+ path2
;
348 MingwModuleHandler::GenerateGccIncludeParametersFromVector ( const vector
<Include
*>& includes
) const
351 for ( size_t i
= 0; i
< includes
.size (); i
++ )
353 Include
& include
= *includes
[i
];
354 if (parameters
.length () > 0)
356 parameters
+= "-I" + include
.directory
;
362 MingwModuleHandler::GenerateGccIncludeParameters ( const Module
& module
) const
364 string parameters
= GenerateGccIncludeParametersFromVector ( module
.includes
);
365 string s
= GenerateGccIncludeParametersFromVector ( module
.project
.includes
);
366 if ( s
.length () > 0 )
376 MingwModuleHandler::GenerateCompilerParametersFromVector ( const vector
<CompilerFlag
*>& compilerFlags
) const
379 for ( size_t i
= 0; i
< compilerFlags
.size (); i
++ )
381 CompilerFlag
& compilerFlag
= *compilerFlags
[i
];
382 if ( parameters
.length () > 0 )
384 parameters
+= compilerFlag
.flag
;
390 MingwModuleHandler::GenerateLinkerParametersFromVector ( const vector
<LinkerFlag
*>& linkerFlags
) const
393 for ( size_t i
= 0; i
< linkerFlags
.size (); i
++ )
395 LinkerFlag
& linkerFlag
= *linkerFlags
[i
];
396 if ( parameters
.length () > 0 )
398 parameters
+= linkerFlag
.flag
;
404 MingwModuleHandler::GenerateLinkerParameters ( const Module
& module
) const
406 return GenerateLinkerParametersFromVector ( module
.linkerFlags
);
410 MingwModuleHandler::GenerateMacro ( const char* assignmentOperation
,
412 const vector
<Include
*>& includes
,
413 const vector
<Define
*>& defines
,
414 const vector
<CompilerFlag
*>* compilerFlags
) const
422 assignmentOperation
);
424 if ( compilerFlags
!= NULL
)
426 string compilerParameters
= GenerateCompilerParametersFromVector ( *compilerFlags
);
427 if ( compilerParameters
.size () > 0 )
432 compilerParameters
.c_str () );
436 for ( i
= 0; i
< includes
.size(); i
++ )
441 includes
[i
]->directory
.c_str() );
443 for ( i
= 0; i
< defines
.size(); i
++ )
445 Define
& d
= *defines
[i
];
450 if ( d
.value
.size() )
456 fprintf ( fMakefile
, "\n" );
460 MingwModuleHandler::GenerateMacros (
461 const char* assignmentOperation
,
462 const vector
<File
*>& files
,
463 const vector
<Include
*>& includes
,
464 const vector
<Define
*>& defines
,
465 const vector
<CompilerFlag
*>* compilerFlags
,
466 const vector
<LinkerFlag
*>* linkerFlags
,
467 const vector
<If
*>& ifs
,
468 const string
& cflags_macro
,
469 const string
& nasmflags_macro
,
470 const string
& windresflags_macro
,
471 const string
& linkerflags_macro
,
472 const string
& objs_macro
) const
476 if ( includes
.size() || defines
.size() )
478 GenerateMacro ( assignmentOperation
,
483 GenerateMacro ( assignmentOperation
,
490 if ( linkerFlags
!= NULL
)
492 string linkerParameters
= GenerateLinkerParametersFromVector ( *linkerFlags
);
493 if ( linkerParameters
.size () > 0 )
498 linkerflags_macro
.c_str (),
500 linkerParameters
.c_str() );
506 for ( i
= 0; i
< files
.size(); i
++ )
508 if ( files
[i
]->first
)
513 PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( files
[i
]->name
) ).c_str (),
514 objs_macro
.c_str() );
521 assignmentOperation
);
522 for ( i
= 0; i
< files
.size(); i
++ )
524 string extension
= GetExtension ( files
[i
]->name
);
525 if ( extension
!= ".spec"
526 && extension
!= ".SPEC"
527 && !files
[i
]->first
)
532 ( i
%10 == 9 ? "\\\n\t" : " " ),
533 PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( files
[i
]->name
) ).c_str () );
536 fprintf ( fMakefile
, "\n" );
539 for ( i
= 0; i
< ifs
.size(); i
++ )
542 if ( rIf
.defines
.size() || rIf
.includes
.size() || rIf
.files
.size() || rIf
.ifs
.size() )
546 "ifeq (\"$(%s)\",\"%s\")\n",
547 rIf
.property
.c_str(),
570 MingwModuleHandler::GenerateMacros (
571 const Module
& module
,
572 const string
& cflags_macro
,
573 const string
& nasmflags_macro
,
574 const string
& windresflags_macro
,
575 const string
& linkerflags_macro
,
576 const string
& objs_macro
) const
583 &module
.compilerFlags
,
591 fprintf ( fMakefile
, "\n" );
595 "%s += $(PROJECT_CFLAGS)\n\n",
596 cflags_macro
.c_str () );
600 "%s += $(PROJECT_RCFLAGS)\n\n",
601 windresflags_macro
.c_str () );
605 "%s_LFLAGS += $(PROJECT_LFLAGS)\n\n",
606 module
.name
.c_str () );
610 MingwModuleHandler::GenerateGccCommand ( const Module
& module
,
611 const string
& sourceFilename
,
613 const string
& cflagsMacro
) const
615 string objectFilename
= PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( sourceFilename
) );
618 objectFilename
.c_str (),
619 sourceFilename
.c_str () );
621 "\t%s -c %s -o %s %s\n",
623 sourceFilename
.c_str (),
624 objectFilename
.c_str (),
625 cflagsMacro
.c_str () );
629 MingwModuleHandler::GenerateGccAssemblerCommand ( const Module
& module
,
630 const string
& sourceFilename
,
632 const string
& cflagsMacro
) const
634 string objectFilename
= PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( sourceFilename
) );
637 objectFilename
.c_str (),
638 sourceFilename
.c_str () );
640 "\t%s -x assembler-with-cpp -c %s -o %s -D__ASM__ %s\n",
642 sourceFilename
.c_str (),
643 objectFilename
.c_str (),
644 cflagsMacro
.c_str () );
648 MingwModuleHandler::GenerateNasmCommand ( const Module
& module
,
649 const string
& sourceFilename
,
650 const string
& nasmflagsMacro
) const
652 string objectFilename
= PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( sourceFilename
) );
655 objectFilename
.c_str (),
656 sourceFilename
.c_str () );
658 "\t%s -f win32 %s -o %s %s\n",
660 sourceFilename
.c_str (),
661 objectFilename
.c_str (),
662 nasmflagsMacro
.c_str () );
666 MingwModuleHandler::GenerateWindresCommand ( const Module
& module
,
667 const string
& sourceFilename
,
668 const string
& windresflagsMacro
) const
670 string objectFilename
= PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( sourceFilename
) );
673 objectFilename
.c_str (),
674 sourceFilename
.c_str () );
676 "\t%s %s -o %s ${%s}\n",
678 sourceFilename
.c_str (),
679 objectFilename
.c_str (),
680 windresflagsMacro
.c_str () );
684 MingwModuleHandler::GenerateWinebuildCommands ( const Module
& module
,
685 const string
& sourceFilename
) const
687 string basename
= GetBasename ( sourceFilename
);
691 sourceFilename
.c_str () );
693 "\t%s --def=%s -o %s.spec.def\n",
695 sourceFilename
.c_str (),
701 sourceFilename
.c_str () );
703 "\t%s --pedll=%s -o %s.stubs.c\n",
705 sourceFilename
.c_str (),
710 MingwModuleHandler::GenerateCommands ( const Module
& module
,
711 const string
& sourceFilename
,
714 const string
& cflagsMacro
,
715 const string
& nasmflagsMacro
,
716 const string
& windresflagsMacro
) const
718 string extension
= GetExtension ( sourceFilename
);
719 if ( extension
== ".c" || extension
== ".C" )
721 GenerateGccCommand ( module
,
727 else if ( extension
== ".cc" || extension
== ".CC" ||
728 extension
== ".cpp" || extension
== ".CPP" ||
729 extension
== ".cxx" || extension
== ".CXX" )
731 GenerateGccCommand ( module
,
737 else if ( extension
== ".s" || extension
== ".S" )
739 GenerateGccAssemblerCommand ( module
,
745 else if ( extension
== ".asm" || extension
== ".ASM" )
747 GenerateNasmCommand ( module
,
752 else if ( extension
== ".rc" || extension
== ".RC" )
754 GenerateWindresCommand ( module
,
759 else if ( extension
== ".spec" || extension
== ".SPEC" )
761 GenerateWinebuildCommands ( module
,
763 GenerateGccCommand ( module
,
764 GetActualSourceFilename ( sourceFilename
),
770 throw InvalidOperationException ( __FILE__
,
772 "Unsupported filename extension '%s' in file '%s'",
774 sourceFilename
.c_str () );
778 MingwModuleHandler::GenerateLinkerCommand ( const Module
& module
,
779 const string
& linker
,
780 const string
& linkerParameters
,
781 const string
& objectFilenames
) const
783 string
targetName ( module
.GetTargetName () );
784 string
target ( FixupTargetFilename ( module
.GetPath () ) );
785 string importLibraryDependencies
= GetImportLibraryDependencies ( module
);
786 if ( module
.importLibrary
!= NULL
)
788 static string
ros_junk ( "$(ROS_TEMPORARY)" );
789 string base_tmp
= ros_junk
+ module
.name
+ ".base.tmp";
790 string junk_tmp
= ros_junk
+ module
.name
+ ".junk.tmp";
791 string temp_exp
= ros_junk
+ module
.name
+ ".temp.exp";
794 "\t%s %s -Wl,--base-file,%s -o %s %s %s %s\n",
796 linkerParameters
.c_str (),
799 objectFilenames
.c_str (),
800 importLibraryDependencies
.c_str (),
801 GetLinkerMacro ( module
).c_str () );
807 string killAt
= module
.mangledSymbols
? "" : "--kill-at";
809 "\t${dlltool} --dllname %s --base-file %s --def %s --output-exp %s %s\n",
812 ( module
.GetBasePath () + SSEP
+ module
.importLibrary
->definition
).c_str (),
821 "\t%s %s %s -o %s %s %s %s\n\n",
823 linkerParameters
.c_str (),
826 objectFilenames
.c_str (),
827 importLibraryDependencies
.c_str (),
828 GetLinkerMacro ( module
).c_str () );
837 "\t%s %s -o %s %s %s %s\n\n",
839 linkerParameters
.c_str (),
841 objectFilenames
.c_str (),
842 importLibraryDependencies
.c_str (),
843 GetLinkerMacro ( module
).c_str () );
848 MingwModuleHandler::GenerateObjectFileTargets ( const Module
& module
,
849 const vector
<File
*>& files
,
850 const vector
<If
*>& ifs
,
853 const string
& cflagsMacro
,
854 const string
& nasmflagsMacro
,
855 const string
& windresflagsMacro
) const
859 for ( i
= 0; i
< files
.size (); i
++ )
861 string sourceFilename
= files
[i
]->name
;
862 GenerateCommands ( module
,
873 for ( i
= 0; i
< ifs
.size(); i
++ )
875 GenerateObjectFileTargets ( module
,
887 MingwModuleHandler::GenerateObjectFileTargets ( const Module
& module
,
890 const string
& cflagsMacro
,
891 const string
& nasmflagsMacro
,
892 const string
& windresflagsMacro
) const
894 GenerateObjectFileTargets ( module
,
902 fprintf ( fMakefile
, "\n" );
906 MingwModuleHandler::GetCleanTargets ( vector
<string
>& out
,
907 const vector
<File
*>& files
,
908 const vector
<If
*>& ifs
) const
912 for ( i
= 0; i
< files
.size(); i
++ )
913 out
.push_back ( PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( files
[i
]->name
) ) );
915 for ( i
= 0; i
< ifs
.size(); i
++ )
916 GetCleanTargets ( out
, ifs
[i
]->files
, ifs
[i
]->ifs
);
920 MingwModuleHandler::GenerateArchiveTarget ( const Module
& module
,
922 const string
& objs_macro
) const
924 string archiveFilename
= GetModuleArchiveFilename ( module
);
928 archiveFilename
.c_str (),
929 objs_macro
.c_str ());
932 "\t%s -rc %s %s\n\n",
934 archiveFilename
.c_str (),
935 objs_macro
.c_str ());
937 return archiveFilename
;
941 MingwModuleHandler::GetCFlagsMacro ( const Module
& module
) const
943 return ssprintf ( "$(%s_CFLAGS)",
944 module
.name
.c_str () );
948 MingwModuleHandler::GetObjectsMacro ( const Module
& module
) const
950 return ssprintf ( "$(%s_OBJS)",
951 module
.name
.c_str () );
955 MingwModuleHandler::GetLinkerMacro ( const Module
& module
) const
957 return ssprintf ( "$(%s_LFLAGS)",
958 module
.name
.c_str () );
962 MingwModuleHandler::GenerateMacrosAndTargets (
963 const Module
& module
,
967 const string
* cflags
,
968 const string
* nasmflags
) const
970 string cflagsMacro
= ssprintf ("%s_CFLAGS", module
.name
.c_str ());
971 string nasmflagsMacro
= ssprintf ("%s_NASMFLAGS", module
.name
.c_str ());
972 string windresflagsMacro
= ssprintf ("%s_RCFLAGS", module
.name
.c_str ());
973 string linkerFlagsMacro
= ssprintf ("%s_LFLAGS", module
.name
.c_str ());
974 string objectsMacro
= ssprintf ("%s_OBJS", module
.name
.c_str ());
976 GenerateMacros ( module
,
983 if ( cflags
!= NULL
)
987 cflagsMacro
.c_str (),
991 if ( nasmflags
!= NULL
)
995 nasmflagsMacro
.c_str (),
996 nasmflags
->c_str () );
999 // generate phony target for module name
1000 fprintf ( fMakefile
, ".PHONY: %s\n",
1001 module
.name
.c_str () );
1002 fprintf ( fMakefile
, "%s: %s\n\n",
1003 module
.name
.c_str (),
1004 FixupTargetFilename ( module
.GetPath () ).c_str () );
1006 // future references to the macros will be to get their values
1007 cflagsMacro
= ssprintf ("$(%s)", cflagsMacro
.c_str ());
1008 nasmflagsMacro
= ssprintf ("$(%s)", nasmflagsMacro
.c_str ());
1009 objectsMacro
= ssprintf ("$(%s)", objectsMacro
.c_str ());
1011 string ar_target
= GenerateArchiveTarget ( module
, ar
, objectsMacro
);
1012 GenerateObjectFileTargets ( module
,
1017 windresflagsMacro
);
1019 vector
<string
> clean_files
;
1020 clean_files
.push_back ( FixupTargetFilename(module
.GetPath()) );
1021 clean_files
.push_back ( ar_target
);
1022 GetCleanTargets ( clean_files
, module
.files
, module
.ifs
);
1024 fprintf ( fMakefile
, "clean::\n\t-@$(rm)" );
1025 for ( size_t i
= 0; i
< clean_files
.size(); i
++ )
1028 fprintf ( fMakefile
, " 2>$(NUL)\n\t-@$(rm)" );
1029 fprintf ( fMakefile
, " %s", clean_files
[i
].c_str() );
1031 fprintf ( fMakefile
, " 2>$(NUL)\n\n" );
1035 MingwModuleHandler::GenerateMacrosAndTargetsHost ( const Module
& module
) const
1037 GenerateMacrosAndTargets ( module
,
1046 MingwModuleHandler::GenerateMacrosAndTargetsTarget ( const Module
& module
) const
1048 GenerateMacrosAndTargetsTarget ( module
,
1054 MingwModuleHandler::GenerateMacrosAndTargetsTarget ( const Module
& module
,
1055 const string
* cflags
,
1056 const string
* nasmflags
) const
1058 GenerateMacrosAndTargets ( module
,
1067 MingwModuleHandler::GetInvocationDependencies ( const Module
& module
) const
1069 string dependencies
;
1070 for ( size_t i
= 0; i
< module
.invocations
.size (); i
++ )
1072 Invoke
& invoke
= *module
.invocations
[i
];
1073 if (invoke
.invokeModule
== &module
)
1074 /* Protect against circular dependencies */
1076 if ( dependencies
.length () > 0 )
1077 dependencies
+= " ";
1078 dependencies
+= invoke
.GetTargets ();
1080 return dependencies
;
1084 MingwModuleHandler::GetInvocationParameters ( const Invoke
& invoke
) const
1086 string
parameters ( "" );
1088 for (i
= 0; i
< invoke
.output
.size (); i
++)
1090 if (parameters
.length () > 0)
1092 InvokeFile
& invokeFile
= *invoke
.output
[i
];
1093 if (invokeFile
.switches
.length () > 0)
1095 parameters
+= invokeFile
.switches
;
1098 parameters
+= invokeFile
.name
;
1101 for (i
= 0; i
< invoke
.input
.size (); i
++)
1103 if (parameters
.length () > 0)
1105 InvokeFile
& invokeFile
= *invoke
.input
[i
];
1106 if (invokeFile
.switches
.length () > 0)
1108 parameters
+= invokeFile
.switches
;
1111 parameters
+= invokeFile
.name
;
1118 MingwModuleHandler::GenerateInvocations ( const Module
& module
) const
1120 if ( module
.invocations
.size () == 0 )
1123 for ( size_t i
= 0; i
< module
.invocations
.size (); i
++ )
1125 const Invoke
& invoke
= *module
.invocations
[i
];
1127 if ( invoke
.invokeModule
->type
!= BuildTool
)
1129 throw InvalidBuildFileException ( module
.node
.location
,
1130 "Only modules of type buildtool can be invoked." );
1133 string invokeTarget
= module
.GetInvocationTarget ( i
);
1134 fprintf ( fMakefile
,
1136 invokeTarget
.c_str () );
1137 fprintf ( fMakefile
,
1139 invokeTarget
.c_str (),
1140 invoke
.GetTargets ().c_str () );
1141 fprintf ( fMakefile
,
1143 invoke
.GetTargets ().c_str (),
1144 FixupTargetFilename ( invoke
.invokeModule
->GetPath () ).c_str () );
1145 fprintf ( fMakefile
,
1147 FixupTargetFilename ( invoke
.invokeModule
->GetPath () ).c_str (),
1148 GetInvocationParameters ( invoke
).c_str () );
1153 MingwModuleHandler::GetPreconditionDependenciesName ( const Module
& module
) const
1155 return ssprintf ( "%s_precondition",
1156 module
.name
.c_str () );
1160 MingwModuleHandler::GeneratePreconditionDependencies ( const Module
& module
) const
1162 string preconditionDependenciesName
= GetPreconditionDependenciesName ( module
);
1163 string sourceFilenames
= GetSourceFilenamesWithoutGeneratedFiles ( module
);
1164 string dependencies
= GetModuleDependencies ( module
);
1165 string s
= GetInvocationDependencies ( module
);
1166 if ( s
.length () > 0 )
1168 if ( dependencies
.length () > 0 )
1169 dependencies
+= " ";
1173 fprintf ( fMakefile
,
1175 preconditionDependenciesName
.c_str () );
1176 fprintf ( fMakefile
,
1178 preconditionDependenciesName
.c_str (),
1179 dependencies
.c_str () );
1180 const char* p
= sourceFilenames
.c_str();
1181 const char* end
= p
+ strlen(p
);
1184 const char* p2
= &p
[512];
1187 while ( p2
> p
&& !isspace(*p2
) )
1191 p2
= strpbrk ( p
, " \t" );
1195 fprintf ( fMakefile
,
1199 preconditionDependenciesName
.c_str ());
1201 p
+= strspn ( p
, " \t" );
1203 fprintf ( fMakefile
, "\n" );
1207 MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ( const Module
& module
) const
1209 if ( module
.importLibrary
!= NULL
)
1211 string definitionDependencies
= GetDefinitionDependencies ( module
);
1212 fprintf ( fMakefile
, "%s: %s\n",
1213 FixupTargetFilename( module
.GetDependencyPath () ).c_str (),
1214 definitionDependencies
.c_str () );
1216 string killAt
= module
.mangledSymbols
? "" : "--kill-at";
1217 fprintf ( fMakefile
,
1218 "\t${dlltool} --dllname %s --def %s --output-lib %s %s\n\n",
1219 module
.GetTargetName ().c_str (),
1220 ( module
.GetBasePath () + SSEP
+ module
.importLibrary
->definition
).c_str (),
1221 FixupTargetFilename ( module
.GetDependencyPath () ).c_str (),
1227 MingwModuleHandler::GetSpecObjectDependencies ( const string
& filename
) const
1229 string basename
= GetBasename ( filename
);
1230 return basename
+ ".spec.def" + " " + basename
+ ".stubs.c";
1234 MingwModuleHandler::GetDefinitionDependencies ( const Module
& module
) const
1236 string dependencies
;
1237 for ( size_t i
= 0; i
< module
.files
.size (); i
++ )
1239 File
& file
= *module
.files
[i
];
1240 string extension
= GetExtension ( file
.name
);
1241 if ( extension
== ".spec" || extension
== ".SPEC" )
1243 if ( dependencies
.length () > 0 )
1244 dependencies
+= " ";
1245 dependencies
+= GetSpecObjectDependencies ( file
.name
);
1248 return dependencies
;
1252 MingwModuleHandler::GetLinkingDependencies ( const Module
& module
) const
1254 string dependencies
= GetImportLibraryDependencies ( module
);
1255 string s
= GetDefinitionDependencies ( module
);
1256 if ( s
.length () > 0 )
1258 dependencies
+= " ";
1261 return dependencies
;
1265 MingwModuleHandler::IsCPlusPlusModule ( const Module
& module
) const
1267 if ( module
.HasFileWithExtensions ( ".cxx", ".CXX" ) )
1269 if ( module
.HasFileWithExtensions ( ".cpp", ".CPP" ) )
1275 static MingwBuildToolModuleHandler buildtool_handler
;
1277 MingwBuildToolModuleHandler::MingwBuildToolModuleHandler()
1278 : MingwModuleHandler ( BuildTool
)
1283 MingwBuildToolModuleHandler::Process ( const Module
& module
)
1285 GeneratePreconditionDependencies ( module
);
1286 GenerateBuildToolModuleTarget ( module
);
1287 GenerateInvocations ( module
);
1291 MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ( const Module
& module
)
1293 string
target ( FixupTargetFilename ( module
.GetPath () ) );
1294 string archiveFilename
= GetModuleArchiveFilename ( module
);
1295 string importLibraryDependencies
= GetImportLibraryDependencies ( module
);
1297 GenerateMacrosAndTargetsHost ( module
);
1300 if ( IsCPlusPlusModule ( module
) )
1301 linker
= "${host_gpp}";
1303 linker
= "${host_gcc}";
1305 fprintf ( fMakefile
, "%s: %s %s\n",
1307 archiveFilename
.c_str (),
1308 importLibraryDependencies
.c_str () );
1309 fprintf ( fMakefile
,
1310 "\t%s %s -o %s %s %s\n\n",
1312 GetLinkerMacro ( module
).c_str (),
1314 archiveFilename
.c_str (),
1315 importLibraryDependencies
.c_str () );
1319 static MingwKernelModuleHandler kernelmodule_handler
;
1321 MingwKernelModuleHandler::MingwKernelModuleHandler ()
1322 : MingwModuleHandler ( Kernel
)
1327 MingwKernelModuleHandler::Process ( const Module
& module
)
1329 GeneratePreconditionDependencies ( module
);
1330 GenerateKernelModuleTarget ( module
);
1331 GenerateInvocations ( module
);
1335 MingwKernelModuleHandler::GenerateKernelModuleTarget ( const Module
& module
)
1337 static string
ros_junk ( "$(ROS_TEMPORARY)" );
1338 string
targetName ( module
.GetTargetName () );
1339 string
target ( FixupTargetFilename (module
.GetPath ()) );
1340 string workingDirectory
= GetWorkingDirectory ();
1341 string objectsMacro
= GetObjectsMacro ( module
);
1342 string importLibraryDependencies
= GetImportLibraryDependencies ( module
);
1343 string base_tmp
= ros_junk
+ module
.name
+ ".base.tmp";
1344 string junk_tmp
= ros_junk
+ module
.name
+ ".junk.tmp";
1345 string temp_exp
= ros_junk
+ module
.name
+ ".temp.exp";
1346 string gccOptions
= ssprintf ("-Wl,-T,%s" SSEP
"ntoskrnl.lnk -Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,0xC0000000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll",
1347 module
.GetBasePath ().c_str (),
1348 module
.entrypoint
.c_str () );
1350 GenerateMacrosAndTargetsTarget ( module
);
1352 GenerateImportLibraryTargetIfNeeded ( module
);
1354 fprintf ( fMakefile
, "%s: %s %s\n",
1356 objectsMacro
.c_str (),
1357 importLibraryDependencies
.c_str () );
1358 fprintf ( fMakefile
,
1359 "\t${gcc} %s %s -Wl,--base-file,%s -o %s %s %s\n",
1360 GetLinkerMacro ( module
).c_str (),
1361 gccOptions
.c_str (),
1364 objectsMacro
.c_str (),
1365 importLibraryDependencies
.c_str () );
1366 fprintf ( fMakefile
,
1368 junk_tmp
.c_str () );
1369 string killAt
= module
.mangledSymbols
? "" : "--kill-at";
1370 fprintf ( fMakefile
,
1371 "\t${dlltool} --dllname %s --base-file %s --def ntoskrnl/ntoskrnl.def --output-exp %s %s\n",
1372 targetName
.c_str (),
1376 fprintf ( fMakefile
,
1378 base_tmp
.c_str () );
1379 fprintf ( fMakefile
,
1380 "\t${gcc} %s %s -Wl,%s -o %s %s %s\n",
1381 GetLinkerMacro ( module
).c_str (),
1382 gccOptions
.c_str (),
1385 objectsMacro
.c_str (),
1386 importLibraryDependencies
.c_str () );
1387 fprintf ( fMakefile
,
1389 temp_exp
.c_str () );
1393 static MingwStaticLibraryModuleHandler staticlibrary_handler
;
1395 MingwStaticLibraryModuleHandler::MingwStaticLibraryModuleHandler ()
1396 : MingwModuleHandler ( StaticLibrary
)
1401 MingwStaticLibraryModuleHandler::Process ( const Module
& module
)
1403 GeneratePreconditionDependencies ( module
);
1404 GenerateStaticLibraryModuleTarget ( module
);
1405 GenerateInvocations ( module
);
1409 MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget ( const Module
& module
)
1411 GenerateMacrosAndTargetsTarget ( module
);
1415 static MingwObjectLibraryModuleHandler objectlibrary_handler
;
1417 MingwObjectLibraryModuleHandler::MingwObjectLibraryModuleHandler ()
1418 : MingwModuleHandler ( ObjectLibrary
)
1423 MingwObjectLibraryModuleHandler::Process ( const Module
& module
)
1425 GeneratePreconditionDependencies ( module
);
1426 GenerateObjectLibraryModuleTarget ( module
);
1427 GenerateInvocations ( module
);
1431 MingwObjectLibraryModuleHandler::GenerateObjectLibraryModuleTarget ( const Module
& module
)
1433 GenerateMacrosAndTargetsTarget ( module
);
1437 static MingwKernelModeDLLModuleHandler kernelmodedll_handler
;
1439 MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler ()
1440 : MingwModuleHandler ( KernelModeDLL
)
1445 MingwKernelModeDLLModuleHandler::Process ( const Module
& module
)
1447 GeneratePreconditionDependencies ( module
);
1448 GenerateKernelModeDLLModuleTarget ( module
);
1449 GenerateInvocations ( module
);
1453 MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ( const Module
& module
)
1455 static string
ros_junk ( "$(ROS_TEMPORARY)" );
1456 string
target ( FixupTargetFilename ( module
.GetPath () ) );
1457 string workingDirectory
= GetWorkingDirectory ( );
1458 string archiveFilename
= GetModuleArchiveFilename ( module
);
1459 string importLibraryDependencies
= GetImportLibraryDependencies ( module
);
1461 GenerateImportLibraryTargetIfNeeded ( module
);
1463 if ( module
.files
.size () > 0 )
1465 GenerateMacrosAndTargetsTarget ( module
);
1467 fprintf ( fMakefile
, "%s: %s %s\n",
1469 archiveFilename
.c_str (),
1470 importLibraryDependencies
.c_str () );
1472 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll",
1473 module
.entrypoint
.c_str () );
1474 GenerateLinkerCommand ( module
,
1481 fprintf ( fMakefile
, ".PHONY: %s\n\n",
1483 fprintf ( fMakefile
, "%s:\n",
1489 static MingwKernelModeDriverModuleHandler kernelmodedriver_handler
;
1491 MingwKernelModeDriverModuleHandler::MingwKernelModeDriverModuleHandler ()
1492 : MingwModuleHandler ( KernelModeDriver
)
1497 MingwKernelModeDriverModuleHandler::Process ( const Module
& module
)
1499 GeneratePreconditionDependencies ( module
);
1500 GenerateKernelModeDriverModuleTarget ( module
);
1501 GenerateInvocations ( module
);
1506 MingwKernelModeDriverModuleHandler::GenerateKernelModeDriverModuleTarget ( const Module
& module
)
1508 static string
ros_junk ( "$(ROS_TEMPORARY)" );
1509 string
target ( PassThruCacheDirectory( FixupTargetFilename ( module
.GetPath () ) ) );
1510 string workingDirectory
= GetWorkingDirectory ( );
1511 string archiveFilename
= GetModuleArchiveFilename ( module
);
1512 string importLibraryDependencies
= GetImportLibraryDependencies ( module
);
1514 GenerateImportLibraryTargetIfNeeded ( module
);
1516 if ( module
.files
.size () > 0 )
1518 string
* cflags
= new string ( "-D__NTDRIVER__" );
1519 GenerateMacrosAndTargetsTarget ( module
,
1524 fprintf ( fMakefile
, "%s: %s %s\n",
1526 archiveFilename
.c_str (),
1527 importLibraryDependencies
.c_str () );
1529 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll",
1530 module
.entrypoint
.c_str () );
1531 GenerateLinkerCommand ( module
,
1538 fprintf ( fMakefile
, ".PHONY: %s\n\n",
1540 fprintf ( fMakefile
, "%s:\n",
1546 static MingwNativeDLLModuleHandler nativedll_handler
;
1548 MingwNativeDLLModuleHandler::MingwNativeDLLModuleHandler ()
1549 : MingwModuleHandler ( NativeDLL
)
1554 MingwNativeDLLModuleHandler::Process ( const Module
& module
)
1556 GeneratePreconditionDependencies ( module
);
1557 GenerateNativeDLLModuleTarget ( module
);
1558 GenerateInvocations ( module
);
1562 MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ( const Module
& module
)
1564 static string
ros_junk ( "$(ROS_TEMPORARY)" );
1565 string
target ( FixupTargetFilename ( module
.GetPath () ) );
1566 string workingDirectory
= GetWorkingDirectory ( );
1567 string objectFilenames
= GetObjectFilenames ( module
);
1568 string archiveFilename
= GetModuleArchiveFilename ( module
);
1569 string importLibraryDependencies
= GetImportLibraryDependencies ( module
);
1571 GenerateImportLibraryTargetIfNeeded ( module
);
1573 if ( module
.files
.size () > 0 )
1575 GenerateMacrosAndTargetsTarget ( module
);
1577 fprintf ( fMakefile
, "%s: %s %s\n",
1579 archiveFilename
.c_str (),
1580 importLibraryDependencies
.c_str () );
1582 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib -mdll",
1583 module
.entrypoint
.c_str () );
1584 GenerateLinkerCommand ( module
,
1591 fprintf ( fMakefile
, ".PHONY: %s\n\n",
1593 fprintf ( fMakefile
, "%s:\n\n",
1599 static MingwNativeCUIModuleHandler nativecui_handler
;
1601 MingwNativeCUIModuleHandler::MingwNativeCUIModuleHandler ()
1602 : MingwModuleHandler ( NativeCUI
)
1607 MingwNativeCUIModuleHandler::Process ( const Module
& module
)
1609 GeneratePreconditionDependencies ( module
);
1610 GenerateNativeCUIModuleTarget ( module
);
1611 GenerateInvocations ( module
);
1615 MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ( const Module
& module
)
1617 static string
ros_junk ( "$(ROS_TEMPORARY)" );
1618 string
target ( FixupTargetFilename ( module
.GetPath () ) );
1619 string workingDirectory
= GetWorkingDirectory ( );
1620 string objectFilenames
= GetObjectFilenames ( module
);
1621 string archiveFilename
= GetModuleArchiveFilename ( module
);
1622 string importLibraryDependencies
= GetImportLibraryDependencies ( module
);
1624 GenerateImportLibraryTargetIfNeeded ( module
);
1626 if ( module
.files
.size () > 0 )
1628 string
* cflags
= new string ( "-D__NTAPP__" );
1629 GenerateMacrosAndTargetsTarget ( module
,
1634 fprintf ( fMakefile
, "%s: %s %s\n",
1636 archiveFilename
.c_str (),
1637 importLibraryDependencies
.c_str () );
1639 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib",
1640 module
.entrypoint
.c_str () );
1641 GenerateLinkerCommand ( module
,
1648 fprintf ( fMakefile
, ".PHONY: %s\n\n",
1650 fprintf ( fMakefile
, "%s:\n\n",
1656 static MingwWin32DLLModuleHandler win32dll_handler
;
1658 MingwWin32DLLModuleHandler::MingwWin32DLLModuleHandler ()
1659 : MingwModuleHandler ( Win32DLL
)
1664 MingwWin32DLLModuleHandler::Process ( const Module
& module
)
1666 GenerateExtractWineDLLResourcesTarget ( module
);
1667 GeneratePreconditionDependencies ( module
);
1668 GenerateWin32DLLModuleTarget ( module
);
1669 GenerateInvocations ( module
);
1673 MingwWin32DLLModuleHandler::GenerateExtractWineDLLResourcesTarget ( const Module
& module
)
1675 fprintf ( fMakefile
, ".PHONY: %s_extractresources\n\n",
1676 module
.name
.c_str () );
1677 fprintf ( fMakefile
, "%s_extractresources: bin2res\n",
1678 module
.name
.c_str () );
1679 for ( size_t i
= 0; i
< module
.files
.size (); i
++ )
1681 File
& file
= *module
.files
[i
];
1682 string extension
= GetExtension ( file
.name
);
1683 if ( extension
== ".rc" || extension
== ".RC" )
1685 string resource
= FixupTargetFilename ( file
.name
);
1686 fprintf ( fMakefile
, "\t@echo ${bin2res} -f -x %s\n",
1687 resource
.c_str () );
1690 fprintf ( fMakefile
, "\n");
1694 MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ( const Module
& module
)
1696 static string
ros_junk ( "$(ROS_TEMPORARY)" );
1697 string
target ( FixupTargetFilename ( module
.GetPath () ) );
1698 string workingDirectory
= GetWorkingDirectory ( );
1699 string objectFilenames
= GetObjectFilenames ( module
);
1700 string linkingDependencies
= GetLinkingDependencies ( module
);
1702 GenerateImportLibraryTargetIfNeeded ( module
);
1703 if ( module
.files
.size () > 0 )
1705 GenerateMacrosAndTargetsTarget ( module
);
1707 fprintf ( fMakefile
, "%s: %s %s\n",
1709 objectFilenames
.c_str (),
1710 linkingDependencies
.c_str () );
1713 if ( IsCPlusPlusModule ( module
) )
1718 string linkerParameters
= ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -mdll",
1719 module
.entrypoint
.c_str () );
1720 GenerateLinkerCommand ( module
,
1727 fprintf ( fMakefile
, ".PHONY: %s\n\n",
1729 fprintf ( fMakefile
, "%s:\n\n",
1735 static MingwWin32CUIModuleHandler win32cui_handler
;
1737 MingwWin32CUIModuleHandler::MingwWin32CUIModuleHandler ()
1738 : MingwModuleHandler ( Win32CUI
)
1743 MingwWin32CUIModuleHandler::Process ( const Module
& module
)
1745 GeneratePreconditionDependencies ( module
);
1746 GenerateWin32CUIModuleTarget ( module
);
1747 GenerateInvocations ( module
);
1751 MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ( const Module
& module
)
1753 static string
ros_junk ( "$(ROS_TEMPORARY)" );
1754 string
target ( FixupTargetFilename ( module
.GetPath () ) );
1755 string workingDirectory
= GetWorkingDirectory ( );
1756 string objectFilenames
= GetObjectFilenames ( module
);
1757 string importLibraryDependencies
= GetImportLibraryDependencies ( module
);
1759 GenerateImportLibraryTargetIfNeeded ( module
);
1761 if ( module
.files
.size () > 0 )
1763 GenerateMacrosAndTargetsTarget ( module
);
1765 fprintf ( fMakefile
, "%s: %s %s\n",
1767 objectFilenames
.c_str (),
1768 importLibraryDependencies
.c_str () );
1771 if ( IsCPlusPlusModule ( module
) )
1776 string linkerParameters
= ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,0x00400000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
1777 module
.entrypoint
.c_str () );
1778 GenerateLinkerCommand ( module
,
1785 fprintf ( fMakefile
, ".PHONY: %s\n\n",
1787 fprintf ( fMakefile
, "%s:\n\n",
1793 static MingwWin32GUIModuleHandler win32gui_handler
;
1795 MingwWin32GUIModuleHandler::MingwWin32GUIModuleHandler ()
1796 : MingwModuleHandler ( Win32GUI
)
1801 MingwWin32GUIModuleHandler::Process ( const Module
& module
)
1803 GeneratePreconditionDependencies ( module
);
1804 GenerateWin32GUIModuleTarget ( module
);
1805 GenerateInvocations ( module
);
1809 MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ( const Module
& module
)
1811 static string
ros_junk ( "$(ROS_TEMPORARY)" );
1812 string
target ( FixupTargetFilename ( module
.GetPath () ) );
1813 string workingDirectory
= GetWorkingDirectory ( );
1814 string objectFilenames
= GetObjectFilenames ( module
);
1815 string importLibraryDependencies
= GetImportLibraryDependencies ( module
);
1817 GenerateImportLibraryTargetIfNeeded ( module
);
1819 if ( module
.files
.size () > 0 )
1821 GenerateMacrosAndTargetsTarget ( module
);
1823 fprintf ( fMakefile
, "%s: %s %s\n",
1825 objectFilenames
.c_str (),
1826 importLibraryDependencies
.c_str () );
1829 if ( IsCPlusPlusModule ( module
) )
1834 string linkerParameters
= ssprintf ( "-Wl,--subsystem,windows -Wl,--entry,%s -Wl,--image-base,0x00400000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
1835 module
.entrypoint
.c_str () );
1836 GenerateLinkerCommand ( module
,
1843 fprintf ( fMakefile
, ".PHONY: %s\n\n",
1845 fprintf ( fMakefile
, "%s:\n\n",
1851 static MingwBootLoaderModuleHandler bootloadermodule_handler
;
1853 MingwBootLoaderModuleHandler::MingwBootLoaderModuleHandler ()
1854 : MingwModuleHandler ( BootLoader
)
1859 MingwBootLoaderModuleHandler::Process ( const Module
& module
)
1861 GeneratePreconditionDependencies ( module
);
1862 GenerateBootLoaderModuleTarget ( module
);
1863 GenerateInvocations ( module
);
1867 MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ( const Module
& module
)
1869 static string
ros_junk ( "$(ROS_TEMPORARY)" );
1870 string
targetName ( module
.GetTargetName () );
1871 string
target ( FixupTargetFilename (module
.GetPath ()) );
1872 string workingDirectory
= GetWorkingDirectory ();
1873 string junk_tmp
= ros_junk
+ module
.name
+ ".junk.tmp";
1874 string objectsMacro
= GetObjectsMacro ( module
);
1875 string importLibraryDependencies
= GetImportLibraryDependencies ( module
);
1877 GenerateMacrosAndTargetsTarget ( module
);
1879 fprintf ( fMakefile
, "%s: %s %s\n",
1881 objectsMacro
.c_str (),
1882 importLibraryDependencies
.c_str () );
1884 fprintf ( fMakefile
,
1885 "\t${ld} %s -N -Ttext=0x8000 -o %s %s %s\n",
1886 GetLinkerMacro ( module
).c_str (),
1888 objectsMacro
.c_str (),
1889 importLibraryDependencies
.c_str () );
1890 fprintf ( fMakefile
,
1891 "\t${objcopy} -O binary %s %s\n",
1894 fprintf ( fMakefile
,
1896 junk_tmp
.c_str () );
1900 static MingwBootSectorModuleHandler bootsectormodule_handler
;
1902 MingwBootSectorModuleHandler::MingwBootSectorModuleHandler ()
1903 : MingwModuleHandler ( BootSector
)
1908 MingwBootSectorModuleHandler::Process ( const Module
& module
)
1910 GeneratePreconditionDependencies ( module
);
1911 GenerateBootSectorModuleTarget ( module
);
1912 GenerateInvocations ( module
);
1916 MingwBootSectorModuleHandler::GenerateBootSectorModuleTarget ( const Module
& module
)
1918 string objectsMacro
= GetObjectsMacro ( module
);
1920 string
* nasmflags
= new string ( "-f bin" );
1921 GenerateMacrosAndTargetsTarget ( module
,
1925 fprintf ( fMakefile
, ".PHONY: %s\n\n",
1926 module
.name
.c_str ());
1927 fprintf ( fMakefile
,
1929 module
.name
.c_str (),
1930 objectsMacro
.c_str () );
1934 static MingwIsoModuleHandler isomodule_handler
;
1936 MingwIsoModuleHandler::MingwIsoModuleHandler ()
1937 : MingwModuleHandler ( Iso
)
1942 MingwIsoModuleHandler::Process ( const Module
& module
)
1944 GeneratePreconditionDependencies ( module
);
1945 GenerateIsoModuleTarget ( module
);
1946 GenerateInvocations ( module
);
1950 MingwIsoModuleHandler::GenerateIsoModuleTarget ( const Module
& module
)
1952 string isoboot
= "$(ROS_INTERMEDIATE)" + FixupTargetFilename ( "boot/freeldr/bootsect/isoboot.o" );
1954 fprintf ( fMakefile
, ".PHONY: %s\n\n",
1955 module
.name
.c_str ());
1956 fprintf ( fMakefile
,
1958 module
.name
.c_str (),
1960 fprintf ( fMakefile
,
1961 "\t${cabman} /C %s /L $(ROS_INTERMEDIATE)%s /I\n",
1962 FixupTargetFilename ( "bootdata/packages/reactos.dff" ).c_str (),
1963 FixupTargetFilename ( "bootcd/reactos" ).c_str () );
1964 fprintf ( fMakefile
,
1965 "\t${cabman} /C %s /RC $(ROS_INTERMEDIATE)%s /L $(BOOTCD_DIR)reactos /N\n",
1966 FixupTargetFilename ( "bootdata/packages/reactos.dff" ).c_str (),
1967 FixupTargetFilename ( "bootcd/reactos/reactos.inf" ).c_str () );
1968 fprintf ( fMakefile
,
1969 "\t- ${rm} $(ROS_INTERMEDIATE)%s\n",
1970 FixupTargetFilename ( "bootcd/reactos/reactos.inf" ).c_str () );
1971 fprintf ( fMakefile
,
1972 "\t${cdmake} -v -m -b %s $(ROS_INTERMEDIATE)bootcd REACTOS ReactOS.iso\n",
1974 fprintf ( fMakefile
,