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 ( 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::GetBasename ( const string
& filename
) const
92 size_t index
= filename
.find_last_of ( '.' );
93 if ( index
!= string::npos
)
94 return filename
.substr ( 0, index
);
99 MingwModuleHandler::GetActualSourceFilename ( const string
& filename
) const
101 string extension
= GetExtension ( filename
);
102 if ( extension
== ".spec" || extension
== "SPEC" )
104 string basename
= GetBasename ( filename
);
105 return basename
+ ".stubs.c";
112 MingwModuleHandler::GetModuleArchiveFilename ( const Module
& module
) const
114 return ReplaceExtension ( FixupTargetFilename ( module
.GetPath () ),
119 MingwModuleHandler::IsGeneratedFile ( const File
& file
) const
121 string extension
= GetExtension ( file
.name
);
122 if ( extension
== ".spec" || extension
== "SPEC" )
129 MingwModuleHandler::GetImportLibraryDependency ( const Module
& importedModule
) const
131 if ( importedModule
.type
== ObjectLibrary
)
132 return GetObjectsMacro ( importedModule
);
134 return PassThruCacheDirectory ( FixupTargetFilename ( importedModule
.GetDependencyPath () ) );
138 MingwModuleHandler::GetImportLibraryDependencies ( const Module
& module
) const
140 string
dependencies ( "" );
141 for ( size_t i
= 0; i
< module
.libraries
.size (); i
++ )
143 if ( dependencies
.size () > 0 )
145 const Module
* importedModule
= module
.project
.LocateModule ( module
.libraries
[i
]->name
);
146 assert ( importedModule
!= NULL
);
147 dependencies
+= GetImportLibraryDependency ( *importedModule
);
153 MingwModuleHandler::GetModuleDependencies ( const Module
& module
) const
155 if ( module
.dependencies
.size () == 0 )
158 string
dependencies ( "" );
159 for ( size_t i
= 0; i
< module
.dependencies
.size (); i
++ )
161 if ( dependencies
.size () > 0 )
163 const Dependency
* dependency
= module
.dependencies
[i
];
164 const Module
* dependencyModule
= dependency
->dependencyModule
;
165 dependencies
+= dependencyModule
->GetTargets ();
167 string definitionDependencies
= GetDefinitionDependencies ( module
);
168 if ( dependencies
.length () > 0 && definitionDependencies
.length () > 0 )
169 dependencies
+= " " + definitionDependencies
;
170 else if ( definitionDependencies
.length () > 0 )
171 dependencies
= definitionDependencies
;
176 MingwModuleHandler::GetAllDependencies ( const Module
& module
) const
178 string dependencies
= GetImportLibraryDependencies ( module
);
179 string s
= GetModuleDependencies ( module
);
180 if ( s
.length () > 0 )
189 MingwModuleHandler::GetSourceFilenames ( const Module
& module
,
190 bool includeGeneratedFiles
) const
194 string
sourceFilenames ( "" );
195 for ( i
= 0; i
< module
.files
.size (); i
++ )
197 if ( includeGeneratedFiles
|| !IsGeneratedFile ( *module
.files
[i
] ) )
198 sourceFilenames
+= " " + GetActualSourceFilename ( module
.files
[i
]->name
);
200 vector
<If
*> ifs
= module
.ifs
;
201 for ( i
= 0; i
< ifs
.size (); i
++ )
205 for ( j
= 0; j
< rIf
.ifs
.size (); j
++ )
206 ifs
.push_back ( rIf
.ifs
[j
] );
207 for ( j
= 0; j
< rIf
.files
.size (); j
++ )
209 if ( includeGeneratedFiles
|| !IsGeneratedFile ( *rIf
.files
[j
] ) )
210 sourceFilenames
+= " " + GetActualSourceFilename ( rIf
.files
[j
]->name
);
213 return sourceFilenames
;
217 MingwModuleHandler::GetSourceFilenames ( const Module
& module
) const
219 return GetSourceFilenames ( module
,
224 MingwModuleHandler::GetSourceFilenamesWithoutGeneratedFiles ( const Module
& module
) const
226 return GetSourceFilenames ( module
,
231 MingwModuleHandler::GetObjectFilename ( const string
& sourceFilename
)
234 string extension
= GetExtension ( sourceFilename
);
235 if ( extension
== ".rc" || extension
== ".RC" )
236 newExtension
= ".coff";
237 else if ( extension
== ".spec" || extension
== ".SPEC" )
238 newExtension
= ".stubs.o";
241 return FixupTargetFilename ( ReplaceExtension ( sourceFilename
, newExtension
) );
245 MingwModuleHandler::GetObjectFilenames ( const Module
& module
) const
247 if ( module
.files
.size () == 0 )
250 string
objectFilenames ( "" );
251 for ( size_t i
= 0; i
< module
.files
.size (); i
++ )
253 if ( objectFilenames
.size () > 0 )
254 objectFilenames
+= " ";
255 objectFilenames
+= PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( module
.files
[i
]->name
) );
257 return objectFilenames
;
261 MingwModuleHandler::IncludeDirectoryTarget ( const string
& directory
) const
263 if ( directory
== "$(ROS_INTERMEDIATE)." SSEP
"tools")
270 MingwModuleHandler::GenerateDirectoryTargets () const
272 if ( directory_set
.size () == 0 )
275 set_string::iterator i
;
276 fprintf ( fMakefile
, "directories::" );
278 for ( i
= directory_set
.begin ();
279 i
!= directory_set
.end ();
282 if ( IncludeDirectoryTarget ( *i
) )
290 fprintf ( fMakefile
, "\n\n" );
292 for ( i
= directory_set
.begin ();
293 i
!= directory_set
.end ();
296 if ( IncludeDirectoryTarget ( *i
) )
305 "::\n\t${mkdir} $@\n\n" );
307 directory_set
.clear ();
311 MingwModuleHandler::GenerateGccDefineParametersFromVector ( const vector
<Define
*>& defines
) const
314 for ( size_t i
= 0; i
< defines
.size (); i
++ )
316 Define
& define
= *defines
[i
];
317 if (parameters
.length () > 0)
320 parameters
+= define
.name
;
321 if (define
.value
.length () > 0)
324 parameters
+= define
.value
;
331 MingwModuleHandler::GenerateGccDefineParameters ( const Module
& module
) const
333 string parameters
= GenerateGccDefineParametersFromVector ( module
.project
.defines
);
334 string s
= GenerateGccDefineParametersFromVector ( module
.defines
);
335 if ( s
.length () > 0 )
344 MingwModuleHandler::ConcatenatePaths ( const string
& path1
,
345 const string
& path2
) const
347 if ( ( path1
.length () == 0 ) || ( path1
== "." ) || ( path1
== "./" ) )
349 if ( path1
[path1
.length ()] == CSEP
)
350 return path1
+ path2
;
352 return path1
+ CSEP
+ path2
;
356 MingwModuleHandler::GenerateGccIncludeParametersFromVector ( const vector
<Include
*>& includes
) const
359 for ( size_t i
= 0; i
< includes
.size (); i
++ )
361 Include
& include
= *includes
[i
];
362 if ( parameters
.length () > 0 )
364 parameters
+= "-I" + include
.directory
;
370 MingwModuleHandler::GenerateGccIncludeParameters ( const Module
& module
) const
372 string parameters
= GenerateGccIncludeParametersFromVector ( module
.includes
);
373 string s
= GenerateGccIncludeParametersFromVector ( module
.project
.includes
);
374 if ( s
.length () > 0 )
384 MingwModuleHandler::GenerateCompilerParametersFromVector ( const vector
<CompilerFlag
*>& compilerFlags
) const
387 for ( size_t i
= 0; i
< compilerFlags
.size (); i
++ )
389 CompilerFlag
& compilerFlag
= *compilerFlags
[i
];
390 if ( parameters
.length () > 0 )
392 parameters
+= compilerFlag
.flag
;
398 MingwModuleHandler::GenerateLinkerParametersFromVector ( const vector
<LinkerFlag
*>& linkerFlags
) const
401 for ( size_t i
= 0; i
< linkerFlags
.size (); i
++ )
403 LinkerFlag
& linkerFlag
= *linkerFlags
[i
];
404 if ( parameters
.length () > 0 )
406 parameters
+= linkerFlag
.flag
;
412 MingwModuleHandler::GenerateLinkerParameters ( const Module
& module
) const
414 return GenerateLinkerParametersFromVector ( module
.linkerFlags
);
418 MingwModuleHandler::GenerateMacro ( const char* assignmentOperation
,
420 const vector
<Include
*>& includes
,
421 const vector
<Define
*>& defines
,
422 const vector
<CompilerFlag
*>* compilerFlags
) const
430 assignmentOperation
);
432 if ( compilerFlags
!= NULL
)
434 string compilerParameters
= GenerateCompilerParametersFromVector ( *compilerFlags
);
435 if ( compilerParameters
.size () > 0 )
440 compilerParameters
.c_str () );
444 for ( i
= 0; i
< includes
.size(); i
++ )
449 includes
[i
]->directory
.c_str() );
451 for ( i
= 0; i
< defines
.size(); i
++ )
453 Define
& d
= *defines
[i
];
458 if ( d
.value
.size() )
464 fprintf ( fMakefile
, "\n" );
468 MingwModuleHandler::GenerateMacros (
469 const char* assignmentOperation
,
470 const vector
<File
*>& files
,
471 const vector
<Include
*>& includes
,
472 const vector
<Define
*>& defines
,
473 const vector
<CompilerFlag
*>* compilerFlags
,
474 const vector
<LinkerFlag
*>* linkerFlags
,
475 const vector
<If
*>& ifs
,
476 const string
& cflags_macro
,
477 const string
& nasmflags_macro
,
478 const string
& windresflags_macro
,
479 const string
& linkerflags_macro
,
480 const string
& objs_macro
) const
484 if ( includes
.size() || defines
.size() )
486 GenerateMacro ( assignmentOperation
,
491 GenerateMacro ( assignmentOperation
,
498 if ( linkerFlags
!= NULL
)
500 string linkerParameters
= GenerateLinkerParametersFromVector ( *linkerFlags
);
501 if ( linkerParameters
.size () > 0 )
506 linkerflags_macro
.c_str (),
508 linkerParameters
.c_str() );
514 for ( i
= 0; i
< files
.size(); i
++ )
516 if ( files
[i
]->first
)
521 PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( files
[i
]->name
) ).c_str (),
522 objs_macro
.c_str() );
529 assignmentOperation
);
530 for ( i
= 0; i
< files
.size(); i
++ )
532 string extension
= GetExtension ( files
[i
]->name
);
533 if ( extension
!= ".spec"
534 && extension
!= ".SPEC"
535 && !files
[i
]->first
)
540 ( i
%10 == 9 ? "\\\n\t" : " " ),
541 PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( files
[i
]->name
) ).c_str () );
544 fprintf ( fMakefile
, "\n" );
547 for ( i
= 0; i
< ifs
.size(); i
++ )
550 if ( rIf
.defines
.size() || rIf
.includes
.size() || rIf
.files
.size() || rIf
.ifs
.size() )
554 "ifeq (\"$(%s)\",\"%s\")\n",
555 rIf
.property
.c_str(),
578 MingwModuleHandler::GenerateMacros (
579 const Module
& module
,
580 const string
& cflags_macro
,
581 const string
& nasmflags_macro
,
582 const string
& windresflags_macro
,
583 const string
& linkerflags_macro
,
584 const string
& objs_macro
) const
591 &module
.compilerFlags
,
599 fprintf ( fMakefile
, "\n" );
603 "%s += $(PROJECT_CFLAGS)\n\n",
604 cflags_macro
.c_str () );
608 "%s += $(PROJECT_RCFLAGS)\n\n",
609 windresflags_macro
.c_str () );
613 "%s_LFLAGS += $(PROJECT_LFLAGS)\n\n",
614 module
.name
.c_str () );
618 MingwModuleHandler::GenerateGccCommand ( const Module
& module
,
619 const string
& sourceFilename
,
621 const string
& cflagsMacro
) const
623 string objectFilename
= PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( sourceFilename
) );
626 objectFilename
.c_str (),
627 sourceFilename
.c_str () );
629 "\t%s -c %s -o %s %s\n",
631 sourceFilename
.c_str (),
632 objectFilename
.c_str (),
633 cflagsMacro
.c_str () );
637 MingwModuleHandler::GenerateGccAssemblerCommand ( const Module
& module
,
638 const string
& sourceFilename
,
640 const string
& cflagsMacro
) const
642 string objectFilename
= PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( sourceFilename
) );
645 objectFilename
.c_str (),
646 sourceFilename
.c_str () );
648 "\t%s -x assembler-with-cpp -c %s -o %s -D__ASM__ %s\n",
650 sourceFilename
.c_str (),
651 objectFilename
.c_str (),
652 cflagsMacro
.c_str () );
656 MingwModuleHandler::GenerateNasmCommand ( const Module
& module
,
657 const string
& sourceFilename
,
658 const string
& nasmflagsMacro
) const
660 string objectFilename
= PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( sourceFilename
) );
663 objectFilename
.c_str (),
664 sourceFilename
.c_str () );
666 "\t%s -f win32 %s -o %s %s\n",
668 sourceFilename
.c_str (),
669 objectFilename
.c_str (),
670 nasmflagsMacro
.c_str () );
674 MingwModuleHandler::GenerateWindresCommand ( const Module
& module
,
675 const string
& sourceFilename
,
676 const string
& windresflagsMacro
) const
678 string objectFilename
= PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( sourceFilename
) );
681 objectFilename
.c_str (),
682 sourceFilename
.c_str () );
684 "\t%s %s -o %s ${%s}\n",
686 sourceFilename
.c_str (),
687 objectFilename
.c_str (),
688 windresflagsMacro
.c_str () );
692 MingwModuleHandler::GenerateWinebuildCommands ( const Module
& module
,
693 const string
& sourceFilename
) const
695 string basename
= GetBasename ( sourceFilename
);
699 sourceFilename
.c_str () );
701 "\t%s --def=%s -o %s.spec.def\n",
703 sourceFilename
.c_str (),
709 sourceFilename
.c_str () );
711 "\t%s --pedll=%s -o %s.stubs.c\n",
713 sourceFilename
.c_str (),
718 MingwModuleHandler::GenerateCommands ( const Module
& module
,
719 const string
& sourceFilename
,
722 const string
& cflagsMacro
,
723 const string
& nasmflagsMacro
,
724 const string
& windresflagsMacro
) const
726 string extension
= GetExtension ( sourceFilename
);
727 if ( extension
== ".c" || extension
== ".C" )
729 GenerateGccCommand ( module
,
735 else if ( extension
== ".cc" || extension
== ".CC" ||
736 extension
== ".cpp" || extension
== ".CPP" ||
737 extension
== ".cxx" || extension
== ".CXX" )
739 GenerateGccCommand ( module
,
745 else if ( extension
== ".s" || extension
== ".S" )
747 GenerateGccAssemblerCommand ( module
,
753 else if ( extension
== ".asm" || extension
== ".ASM" )
755 GenerateNasmCommand ( module
,
760 else if ( extension
== ".rc" || extension
== ".RC" )
762 GenerateWindresCommand ( module
,
767 else if ( extension
== ".spec" || extension
== ".SPEC" )
769 GenerateWinebuildCommands ( module
,
771 GenerateGccCommand ( module
,
772 GetActualSourceFilename ( sourceFilename
),
778 throw InvalidOperationException ( __FILE__
,
780 "Unsupported filename extension '%s' in file '%s'",
782 sourceFilename
.c_str () );
786 MingwModuleHandler::GenerateLinkerCommand ( const Module
& module
,
787 const string
& linker
,
788 const string
& linkerParameters
,
789 const string
& objectFilenames
) const
791 string
targetName ( module
.GetTargetName () );
792 string
target ( FixupTargetFilename ( module
.GetPath () ) );
793 string importLibraryDependencies
= GetImportLibraryDependencies ( module
);
794 if ( module
.importLibrary
!= NULL
)
796 static string
ros_junk ( "$(ROS_TEMPORARY)" );
797 string base_tmp
= ros_junk
+ module
.name
+ ".base.tmp";
798 string junk_tmp
= ros_junk
+ module
.name
+ ".junk.tmp";
799 string temp_exp
= ros_junk
+ module
.name
+ ".temp.exp";
802 "\t%s %s -Wl,--base-file,%s -o %s %s %s %s\n",
804 linkerParameters
.c_str (),
807 objectFilenames
.c_str (),
808 importLibraryDependencies
.c_str (),
809 GetLinkerMacro ( module
).c_str () );
815 string killAt
= module
.mangledSymbols
? "" : "--kill-at";
817 "\t${dlltool} --dllname %s --base-file %s --def %s --output-exp %s %s\n",
820 ( module
.GetBasePath () + SSEP
+ module
.importLibrary
->definition
).c_str (),
829 "\t%s %s %s -o %s %s %s %s\n\n",
831 linkerParameters
.c_str (),
834 objectFilenames
.c_str (),
835 importLibraryDependencies
.c_str (),
836 GetLinkerMacro ( module
).c_str () );
845 "\t%s %s -o %s %s %s %s\n\n",
847 linkerParameters
.c_str (),
849 objectFilenames
.c_str (),
850 importLibraryDependencies
.c_str (),
851 GetLinkerMacro ( module
).c_str () );
856 MingwModuleHandler::GenerateObjectFileTargets ( const Module
& module
,
857 const vector
<File
*>& files
,
858 const vector
<If
*>& ifs
,
861 const string
& cflagsMacro
,
862 const string
& nasmflagsMacro
,
863 const string
& windresflagsMacro
) const
867 for ( i
= 0; i
< files
.size (); i
++ )
869 string sourceFilename
= files
[i
]->name
;
870 GenerateCommands ( module
,
881 for ( i
= 0; i
< ifs
.size(); i
++ )
883 GenerateObjectFileTargets ( module
,
895 MingwModuleHandler::GenerateObjectFileTargets ( const Module
& module
,
898 const string
& cflagsMacro
,
899 const string
& nasmflagsMacro
,
900 const string
& windresflagsMacro
) const
902 GenerateObjectFileTargets ( module
,
910 fprintf ( fMakefile
, "\n" );
914 MingwModuleHandler::GetCleanTargets ( vector
<string
>& out
,
915 const vector
<File
*>& files
,
916 const vector
<If
*>& ifs
) const
920 for ( i
= 0; i
< files
.size(); i
++ )
921 out
.push_back ( PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( files
[i
]->name
) ) );
923 for ( i
= 0; i
< ifs
.size(); i
++ )
924 GetCleanTargets ( out
, ifs
[i
]->files
, ifs
[i
]->ifs
);
928 MingwModuleHandler::GenerateArchiveTarget ( const Module
& module
,
930 const string
& objs_macro
) const
932 string archiveFilename
= GetModuleArchiveFilename ( module
);
936 archiveFilename
.c_str (),
937 objs_macro
.c_str ());
940 "\t%s -rc %s %s\n\n",
942 archiveFilename
.c_str (),
943 objs_macro
.c_str ());
945 return archiveFilename
;
949 MingwModuleHandler::GetCFlagsMacro ( const Module
& module
) const
951 return ssprintf ( "$(%s_CFLAGS)",
952 module
.name
.c_str () );
956 MingwModuleHandler::GetObjectsMacro ( const Module
& module
) const
958 return ssprintf ( "$(%s_OBJS)",
959 module
.name
.c_str () );
963 MingwModuleHandler::GetLinkerMacro ( const Module
& module
) const
965 return ssprintf ( "$(%s_LFLAGS)",
966 module
.name
.c_str () );
970 MingwModuleHandler::GenerateMacrosAndTargets (
971 const Module
& module
,
975 const string
* cflags
,
976 const string
* nasmflags
) const
978 string cflagsMacro
= ssprintf ("%s_CFLAGS", module
.name
.c_str ());
979 string nasmflagsMacro
= ssprintf ("%s_NASMFLAGS", module
.name
.c_str ());
980 string windresflagsMacro
= ssprintf ("%s_RCFLAGS", module
.name
.c_str ());
981 string linkerFlagsMacro
= ssprintf ("%s_LFLAGS", module
.name
.c_str ());
982 string objectsMacro
= ssprintf ("%s_OBJS", module
.name
.c_str ());
984 GenerateMacros ( module
,
991 if ( cflags
!= NULL
)
995 cflagsMacro
.c_str (),
999 if ( nasmflags
!= NULL
)
1001 fprintf ( fMakefile
,
1003 nasmflagsMacro
.c_str (),
1004 nasmflags
->c_str () );
1007 // generate phony target for module name
1008 fprintf ( fMakefile
, ".PHONY: %s\n",
1009 module
.name
.c_str () );
1010 fprintf ( fMakefile
, "%s: %s\n\n",
1011 module
.name
.c_str (),
1012 FixupTargetFilename ( module
.GetPath () ).c_str () );
1014 // future references to the macros will be to get their values
1015 cflagsMacro
= ssprintf ("$(%s)", cflagsMacro
.c_str ());
1016 nasmflagsMacro
= ssprintf ("$(%s)", nasmflagsMacro
.c_str ());
1017 objectsMacro
= ssprintf ("$(%s)", objectsMacro
.c_str ());
1019 string ar_target
= GenerateArchiveTarget ( module
, ar
, objectsMacro
);
1020 GenerateObjectFileTargets ( module
,
1025 windresflagsMacro
);
1027 vector
<string
> clean_files
;
1028 clean_files
.push_back ( FixupTargetFilename(module
.GetPath()) );
1029 clean_files
.push_back ( ar_target
);
1030 GetCleanTargets ( clean_files
, module
.files
, module
.ifs
);
1032 fprintf ( fMakefile
, "clean::\n\t-@$(rm)" );
1033 for ( size_t i
= 0; i
< clean_files
.size(); i
++ )
1036 fprintf ( fMakefile
, " 2>$(NUL)\n\t-@$(rm)" );
1037 fprintf ( fMakefile
, " %s", clean_files
[i
].c_str() );
1039 fprintf ( fMakefile
, " 2>$(NUL)\n\n" );
1043 MingwModuleHandler::GenerateMacrosAndTargetsHost ( const Module
& module
) const
1045 GenerateMacrosAndTargets ( module
,
1054 MingwModuleHandler::GenerateMacrosAndTargetsTarget ( const Module
& module
) const
1056 GenerateMacrosAndTargetsTarget ( module
,
1062 MingwModuleHandler::GenerateMacrosAndTargetsTarget ( const Module
& module
,
1063 const string
* cflags
,
1064 const string
* nasmflags
) const
1066 GenerateMacrosAndTargets ( module
,
1075 MingwModuleHandler::GetInvocationDependencies ( const Module
& module
) const
1077 string dependencies
;
1078 for ( size_t i
= 0; i
< module
.invocations
.size (); i
++ )
1080 Invoke
& invoke
= *module
.invocations
[i
];
1081 if (invoke
.invokeModule
== &module
)
1082 /* Protect against circular dependencies */
1084 if ( dependencies
.length () > 0 )
1085 dependencies
+= " ";
1086 dependencies
+= invoke
.GetTargets ();
1088 return dependencies
;
1092 MingwModuleHandler::GenerateInvocations ( const Module
& module
) const
1094 if ( module
.invocations
.size () == 0 )
1097 for ( size_t i
= 0; i
< module
.invocations
.size (); i
++ )
1099 const Invoke
& invoke
= *module
.invocations
[i
];
1101 if ( invoke
.invokeModule
->type
!= BuildTool
)
1103 throw InvalidBuildFileException ( module
.node
.location
,
1104 "Only modules of type buildtool can be invoked." );
1107 string invokeTarget
= module
.GetInvocationTarget ( i
);
1108 fprintf ( fMakefile
,
1110 invokeTarget
.c_str () );
1111 fprintf ( fMakefile
,
1113 invokeTarget
.c_str (),
1114 invoke
.GetTargets ().c_str () );
1115 fprintf ( fMakefile
,
1117 invoke
.GetTargets ().c_str (),
1118 FixupTargetFilename ( invoke
.invokeModule
->GetPath () ).c_str () );
1119 fprintf ( fMakefile
,
1121 FixupTargetFilename ( invoke
.invokeModule
->GetPath () ).c_str (),
1122 invoke
.GetParameters ().c_str () );
1127 MingwModuleHandler::GetPreconditionDependenciesName ( const Module
& module
) const
1129 return ssprintf ( "%s_precondition",
1130 module
.name
.c_str () );
1134 MingwModuleHandler::GetDefaultDependencies ( const Module
& module
) const
1136 /* Avoid circular dependency */
1137 if ( module
.type
== BuildTool
|| module
.name
== "zlib" )
1138 return "$(ROS_INTERMEDIATE)." SSEP
"tools $(ROS_INTERMEDIATE)." SSEP
"lib" SSEP
"zlib";
1144 MingwModuleHandler::GeneratePreconditionDependencies ( const Module
& module
) const
1146 string preconditionDependenciesName
= GetPreconditionDependenciesName ( module
);
1147 string sourceFilenames
= GetSourceFilenamesWithoutGeneratedFiles ( module
);
1148 string dependencies
= GetDefaultDependencies ( module
);
1149 string s
= GetModuleDependencies ( module
);
1150 if ( s
.length () > 0 )
1152 if ( dependencies
.length () > 0 )
1153 dependencies
+= " ";
1157 s
= GetInvocationDependencies ( module
);
1158 if ( s
.length () > 0 )
1160 if ( dependencies
.length () > 0 )
1161 dependencies
+= " ";
1165 fprintf ( fMakefile
,
1167 preconditionDependenciesName
.c_str () );
1168 fprintf ( fMakefile
,
1170 preconditionDependenciesName
.c_str (),
1171 dependencies
.c_str () );
1172 const char* p
= sourceFilenames
.c_str();
1173 const char* end
= p
+ strlen(p
);
1176 const char* p2
= &p
[512];
1179 while ( p2
> p
&& !isspace(*p2
) )
1183 p2
= strpbrk ( p
, " \t" );
1187 fprintf ( fMakefile
,
1191 preconditionDependenciesName
.c_str ());
1193 p
+= strspn ( p
, " \t" );
1195 fprintf ( fMakefile
, "\n" );
1199 MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ( const Module
& module
) const
1201 if ( module
.importLibrary
!= NULL
)
1203 string definitionDependencies
= GetDefinitionDependencies ( module
);
1204 fprintf ( fMakefile
, "%s: %s\n",
1205 FixupTargetFilename( module
.GetDependencyPath () ).c_str (),
1206 definitionDependencies
.c_str () );
1208 string killAt
= module
.mangledSymbols
? "" : "--kill-at";
1209 fprintf ( fMakefile
,
1210 "\t${dlltool} --dllname %s --def %s --output-lib %s %s\n\n",
1211 module
.GetTargetName ().c_str (),
1212 ( module
.GetBasePath () + SSEP
+ module
.importLibrary
->definition
).c_str (),
1213 FixupTargetFilename ( module
.GetDependencyPath () ).c_str (),
1219 MingwModuleHandler::GetSpecObjectDependencies ( const string
& filename
) const
1221 string basename
= GetBasename ( filename
);
1222 return basename
+ ".spec.def" + " " + basename
+ ".stubs.c";
1226 MingwModuleHandler::GetDefinitionDependencies ( const Module
& module
) const
1228 string dependencies
;
1229 string dkNkmLibNoFixup
= "dk/nkm/lib";
1230 dependencies
+= FixupTargetFilename ( dkNkmLibNoFixup
);
1231 PassThruCacheDirectory ( dkNkmLibNoFixup
+ SSEP
);
1232 for ( size_t i
= 0; i
< module
.files
.size (); i
++ )
1234 File
& file
= *module
.files
[i
];
1235 string extension
= GetExtension ( file
.name
);
1236 if ( extension
== ".spec" || extension
== ".SPEC" )
1238 if ( dependencies
.length () > 0 )
1239 dependencies
+= " ";
1240 dependencies
+= GetSpecObjectDependencies ( file
.name
);
1243 return dependencies
;
1247 MingwModuleHandler::GetLinkingDependencies ( const Module
& module
) const
1249 string dependencies
= GetImportLibraryDependencies ( module
);
1250 string s
= GetDefinitionDependencies ( module
);
1251 if ( s
.length () > 0 )
1253 dependencies
+= " ";
1256 return dependencies
;
1260 MingwModuleHandler::IsCPlusPlusModule ( const Module
& module
) const
1262 if ( module
.HasFileWithExtensions ( ".cc", ".CC" ) )
1264 if ( module
.HasFileWithExtensions ( ".cxx", ".CXX" ) )
1266 if ( module
.HasFileWithExtensions ( ".cpp", ".CPP" ) )
1272 static MingwBuildToolModuleHandler buildtool_handler
;
1274 MingwBuildToolModuleHandler::MingwBuildToolModuleHandler()
1275 : MingwModuleHandler ( BuildTool
)
1280 MingwBuildToolModuleHandler::Process ( const Module
& module
)
1282 GeneratePreconditionDependencies ( module
);
1283 GenerateBuildToolModuleTarget ( module
);
1284 GenerateInvocations ( module
);
1288 MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ( const Module
& module
)
1290 string
target ( FixupTargetFilename ( module
.GetPath () ) );
1291 string archiveFilename
= GetModuleArchiveFilename ( module
);
1292 string importLibraryDependencies
= GetImportLibraryDependencies ( module
);
1294 GenerateMacrosAndTargetsHost ( module
);
1297 if ( IsCPlusPlusModule ( module
) )
1298 linker
= "${host_gpp}";
1300 linker
= "${host_gcc}";
1302 fprintf ( fMakefile
, "%s: %s %s\n",
1304 archiveFilename
.c_str (),
1305 importLibraryDependencies
.c_str () );
1306 fprintf ( fMakefile
,
1307 "\t%s %s -o %s %s %s\n\n",
1309 GetLinkerMacro ( module
).c_str (),
1311 archiveFilename
.c_str (),
1312 importLibraryDependencies
.c_str () );
1316 static MingwKernelModuleHandler kernelmodule_handler
;
1318 MingwKernelModuleHandler::MingwKernelModuleHandler ()
1319 : MingwModuleHandler ( Kernel
)
1324 MingwKernelModuleHandler::Process ( const Module
& module
)
1326 GeneratePreconditionDependencies ( module
);
1327 GenerateKernelModuleTarget ( module
);
1328 GenerateInvocations ( module
);
1332 MingwKernelModuleHandler::GenerateKernelModuleTarget ( const Module
& module
)
1334 static string
ros_junk ( "$(ROS_TEMPORARY)" );
1335 string
targetName ( module
.GetTargetName () );
1336 string
target ( FixupTargetFilename (module
.GetPath ()) );
1337 string workingDirectory
= GetWorkingDirectory ();
1338 string objectsMacro
= GetObjectsMacro ( module
);
1339 string importLibraryDependencies
= GetImportLibraryDependencies ( module
);
1340 string base_tmp
= ros_junk
+ module
.name
+ ".base.tmp";
1341 string junk_tmp
= ros_junk
+ module
.name
+ ".junk.tmp";
1342 string temp_exp
= ros_junk
+ module
.name
+ ".temp.exp";
1343 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",
1344 module
.GetBasePath ().c_str (),
1345 module
.entrypoint
.c_str () );
1347 GenerateMacrosAndTargetsTarget ( module
);
1349 GenerateImportLibraryTargetIfNeeded ( module
);
1351 fprintf ( fMakefile
, "%s: %s %s\n",
1353 objectsMacro
.c_str (),
1354 importLibraryDependencies
.c_str () );
1355 fprintf ( fMakefile
,
1356 "\t${gcc} %s %s -Wl,--base-file,%s -o %s %s %s\n",
1357 GetLinkerMacro ( module
).c_str (),
1358 gccOptions
.c_str (),
1361 objectsMacro
.c_str (),
1362 importLibraryDependencies
.c_str () );
1363 fprintf ( fMakefile
,
1365 junk_tmp
.c_str () );
1366 string killAt
= module
.mangledSymbols
? "" : "--kill-at";
1367 fprintf ( fMakefile
,
1368 "\t${dlltool} --dllname %s --base-file %s --def ntoskrnl/ntoskrnl.def --output-exp %s %s\n",
1369 targetName
.c_str (),
1373 fprintf ( fMakefile
,
1375 base_tmp
.c_str () );
1376 fprintf ( fMakefile
,
1377 "\t${gcc} %s %s -Wl,%s -o %s %s %s\n",
1378 GetLinkerMacro ( module
).c_str (),
1379 gccOptions
.c_str (),
1382 objectsMacro
.c_str (),
1383 importLibraryDependencies
.c_str () );
1384 fprintf ( fMakefile
,
1386 temp_exp
.c_str () );
1390 static MingwStaticLibraryModuleHandler staticlibrary_handler
;
1392 MingwStaticLibraryModuleHandler::MingwStaticLibraryModuleHandler ()
1393 : MingwModuleHandler ( StaticLibrary
)
1398 MingwStaticLibraryModuleHandler::Process ( const Module
& module
)
1400 GeneratePreconditionDependencies ( module
);
1401 GenerateStaticLibraryModuleTarget ( module
);
1402 GenerateInvocations ( module
);
1406 MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget ( const Module
& module
)
1408 GenerateMacrosAndTargetsTarget ( module
);
1412 static MingwObjectLibraryModuleHandler objectlibrary_handler
;
1414 MingwObjectLibraryModuleHandler::MingwObjectLibraryModuleHandler ()
1415 : MingwModuleHandler ( ObjectLibrary
)
1420 MingwObjectLibraryModuleHandler::Process ( const Module
& module
)
1422 GeneratePreconditionDependencies ( module
);
1423 GenerateObjectLibraryModuleTarget ( module
);
1424 GenerateInvocations ( module
);
1428 MingwObjectLibraryModuleHandler::GenerateObjectLibraryModuleTarget ( const Module
& module
)
1430 GenerateMacrosAndTargetsTarget ( module
);
1434 static MingwKernelModeDLLModuleHandler kernelmodedll_handler
;
1436 MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler ()
1437 : MingwModuleHandler ( KernelModeDLL
)
1442 MingwKernelModeDLLModuleHandler::Process ( const Module
& module
)
1444 GeneratePreconditionDependencies ( module
);
1445 GenerateKernelModeDLLModuleTarget ( module
);
1446 GenerateInvocations ( module
);
1450 MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ( const Module
& module
)
1452 static string
ros_junk ( "$(ROS_TEMPORARY)" );
1453 string
target ( FixupTargetFilename ( module
.GetPath () ) );
1454 string workingDirectory
= GetWorkingDirectory ( );
1455 string archiveFilename
= GetModuleArchiveFilename ( module
);
1456 string importLibraryDependencies
= GetImportLibraryDependencies ( module
);
1458 GenerateImportLibraryTargetIfNeeded ( module
);
1460 if ( module
.files
.size () > 0 )
1462 GenerateMacrosAndTargetsTarget ( module
);
1464 fprintf ( fMakefile
, "%s: %s %s\n",
1466 archiveFilename
.c_str (),
1467 importLibraryDependencies
.c_str () );
1469 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll",
1470 module
.entrypoint
.c_str () );
1471 GenerateLinkerCommand ( module
,
1478 fprintf ( fMakefile
, ".PHONY: %s\n\n",
1480 fprintf ( fMakefile
, "%s:\n",
1486 static MingwKernelModeDriverModuleHandler kernelmodedriver_handler
;
1488 MingwKernelModeDriverModuleHandler::MingwKernelModeDriverModuleHandler ()
1489 : MingwModuleHandler ( KernelModeDriver
)
1494 MingwKernelModeDriverModuleHandler::Process ( const Module
& module
)
1496 GeneratePreconditionDependencies ( module
);
1497 GenerateKernelModeDriverModuleTarget ( module
);
1498 GenerateInvocations ( module
);
1503 MingwKernelModeDriverModuleHandler::GenerateKernelModeDriverModuleTarget ( const Module
& module
)
1505 static string
ros_junk ( "$(ROS_TEMPORARY)" );
1506 string
target ( PassThruCacheDirectory( FixupTargetFilename ( module
.GetPath () ) ) );
1507 string workingDirectory
= GetWorkingDirectory ( );
1508 string archiveFilename
= GetModuleArchiveFilename ( module
);
1509 string importLibraryDependencies
= GetImportLibraryDependencies ( module
);
1511 GenerateImportLibraryTargetIfNeeded ( module
);
1513 if ( module
.files
.size () > 0 )
1515 string
* cflags
= new string ( "-D__NTDRIVER__" );
1516 GenerateMacrosAndTargetsTarget ( module
,
1521 fprintf ( fMakefile
, "%s: %s %s\n",
1523 archiveFilename
.c_str (),
1524 importLibraryDependencies
.c_str () );
1526 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll",
1527 module
.entrypoint
.c_str () );
1528 GenerateLinkerCommand ( module
,
1535 fprintf ( fMakefile
, ".PHONY: %s\n\n",
1537 fprintf ( fMakefile
, "%s:\n",
1543 static MingwNativeDLLModuleHandler nativedll_handler
;
1545 MingwNativeDLLModuleHandler::MingwNativeDLLModuleHandler ()
1546 : MingwModuleHandler ( NativeDLL
)
1551 MingwNativeDLLModuleHandler::Process ( const Module
& module
)
1553 GeneratePreconditionDependencies ( module
);
1554 GenerateNativeDLLModuleTarget ( module
);
1555 GenerateInvocations ( module
);
1559 MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ( const Module
& module
)
1561 static string
ros_junk ( "$(ROS_TEMPORARY)" );
1562 string
target ( FixupTargetFilename ( module
.GetPath () ) );
1563 string workingDirectory
= GetWorkingDirectory ( );
1564 string objectFilenames
= GetObjectFilenames ( module
);
1565 string archiveFilename
= GetModuleArchiveFilename ( module
);
1566 string importLibraryDependencies
= GetImportLibraryDependencies ( module
);
1568 GenerateImportLibraryTargetIfNeeded ( module
);
1570 if ( module
.files
.size () > 0 )
1572 GenerateMacrosAndTargetsTarget ( module
);
1574 fprintf ( fMakefile
, "%s: %s %s\n",
1576 archiveFilename
.c_str (),
1577 importLibraryDependencies
.c_str () );
1579 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib -mdll",
1580 module
.entrypoint
.c_str () );
1581 GenerateLinkerCommand ( module
,
1588 fprintf ( fMakefile
, ".PHONY: %s\n\n",
1590 fprintf ( fMakefile
, "%s:\n\n",
1596 static MingwNativeCUIModuleHandler nativecui_handler
;
1598 MingwNativeCUIModuleHandler::MingwNativeCUIModuleHandler ()
1599 : MingwModuleHandler ( NativeCUI
)
1604 MingwNativeCUIModuleHandler::Process ( const Module
& module
)
1606 GeneratePreconditionDependencies ( module
);
1607 GenerateNativeCUIModuleTarget ( module
);
1608 GenerateInvocations ( module
);
1612 MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ( const Module
& module
)
1614 static string
ros_junk ( "$(ROS_TEMPORARY)" );
1615 string
target ( FixupTargetFilename ( module
.GetPath () ) );
1616 string workingDirectory
= GetWorkingDirectory ( );
1617 string objectFilenames
= GetObjectFilenames ( module
);
1618 string archiveFilename
= GetModuleArchiveFilename ( module
);
1619 string importLibraryDependencies
= GetImportLibraryDependencies ( module
);
1621 GenerateImportLibraryTargetIfNeeded ( module
);
1623 if ( module
.files
.size () > 0 )
1625 string
* cflags
= new string ( "-D__NTAPP__" );
1626 GenerateMacrosAndTargetsTarget ( module
,
1631 fprintf ( fMakefile
, "%s: %s %s\n",
1633 archiveFilename
.c_str (),
1634 importLibraryDependencies
.c_str () );
1636 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib",
1637 module
.entrypoint
.c_str () );
1638 GenerateLinkerCommand ( module
,
1645 fprintf ( fMakefile
, ".PHONY: %s\n\n",
1647 fprintf ( fMakefile
, "%s:\n\n",
1653 static MingwWin32DLLModuleHandler win32dll_handler
;
1655 MingwWin32DLLModuleHandler::MingwWin32DLLModuleHandler ()
1656 : MingwModuleHandler ( Win32DLL
)
1661 MingwWin32DLLModuleHandler::Process ( const Module
& module
)
1663 GenerateExtractWineDLLResourcesTarget ( module
);
1664 GeneratePreconditionDependencies ( module
);
1665 GenerateWin32DLLModuleTarget ( module
);
1666 GenerateInvocations ( module
);
1670 MingwWin32DLLModuleHandler::GenerateExtractWineDLLResourcesTarget ( const Module
& module
)
1672 fprintf ( fMakefile
, ".PHONY: %s_extractresources\n\n",
1673 module
.name
.c_str () );
1674 fprintf ( fMakefile
, "%s_extractresources: bin2res\n",
1675 module
.name
.c_str () );
1676 for ( size_t i
= 0; i
< module
.files
.size (); i
++ )
1678 File
& file
= *module
.files
[i
];
1679 string extension
= GetExtension ( file
.name
);
1680 if ( extension
== ".rc" || extension
== ".RC" )
1682 string resource
= FixupTargetFilename ( file
.name
);
1683 fprintf ( fMakefile
, "\t@echo ${bin2res} -f -x %s\n",
1684 resource
.c_str () );
1687 fprintf ( fMakefile
, "\n");
1691 MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ( const Module
& module
)
1693 static string
ros_junk ( "$(ROS_TEMPORARY)" );
1694 string
target ( FixupTargetFilename ( module
.GetPath () ) );
1695 string workingDirectory
= GetWorkingDirectory ( );
1696 string objectFilenames
= GetObjectFilenames ( module
);
1697 string linkingDependencies
= GetLinkingDependencies ( module
);
1699 GenerateImportLibraryTargetIfNeeded ( module
);
1700 if ( module
.files
.size () > 0 )
1702 GenerateMacrosAndTargetsTarget ( module
);
1704 fprintf ( fMakefile
, "%s: %s %s\n",
1706 objectFilenames
.c_str (),
1707 linkingDependencies
.c_str () );
1710 if ( IsCPlusPlusModule ( module
) )
1715 string linkerParameters
= ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -mdll",
1716 module
.entrypoint
.c_str () );
1717 GenerateLinkerCommand ( module
,
1724 fprintf ( fMakefile
, ".PHONY: %s\n\n",
1726 fprintf ( fMakefile
, "%s:\n\n",
1732 static MingwWin32CUIModuleHandler win32cui_handler
;
1734 MingwWin32CUIModuleHandler::MingwWin32CUIModuleHandler ()
1735 : MingwModuleHandler ( Win32CUI
)
1740 MingwWin32CUIModuleHandler::Process ( const Module
& module
)
1742 GeneratePreconditionDependencies ( module
);
1743 GenerateWin32CUIModuleTarget ( module
);
1744 GenerateInvocations ( module
);
1748 MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ( const Module
& module
)
1750 static string
ros_junk ( "$(ROS_TEMPORARY)" );
1751 string
target ( FixupTargetFilename ( module
.GetPath () ) );
1752 string workingDirectory
= GetWorkingDirectory ( );
1753 string objectFilenames
= GetObjectFilenames ( module
);
1754 string importLibraryDependencies
= GetImportLibraryDependencies ( module
);
1756 GenerateImportLibraryTargetIfNeeded ( module
);
1758 if ( module
.files
.size () > 0 )
1760 GenerateMacrosAndTargetsTarget ( module
);
1762 fprintf ( fMakefile
, "%s: %s %s\n",
1764 objectFilenames
.c_str (),
1765 importLibraryDependencies
.c_str () );
1768 if ( IsCPlusPlusModule ( module
) )
1773 string linkerParameters
= ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,0x00400000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
1774 module
.entrypoint
.c_str () );
1775 GenerateLinkerCommand ( module
,
1782 fprintf ( fMakefile
, ".PHONY: %s\n\n",
1784 fprintf ( fMakefile
, "%s:\n\n",
1790 static MingwWin32GUIModuleHandler win32gui_handler
;
1792 MingwWin32GUIModuleHandler::MingwWin32GUIModuleHandler ()
1793 : MingwModuleHandler ( Win32GUI
)
1798 MingwWin32GUIModuleHandler::Process ( const Module
& module
)
1800 GeneratePreconditionDependencies ( module
);
1801 GenerateWin32GUIModuleTarget ( module
);
1802 GenerateInvocations ( module
);
1806 MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ( const Module
& module
)
1808 static string
ros_junk ( "$(ROS_TEMPORARY)" );
1809 string
target ( FixupTargetFilename ( module
.GetPath () ) );
1810 string workingDirectory
= GetWorkingDirectory ( );
1811 string objectFilenames
= GetObjectFilenames ( module
);
1812 string importLibraryDependencies
= GetImportLibraryDependencies ( module
);
1814 GenerateImportLibraryTargetIfNeeded ( module
);
1816 if ( module
.files
.size () > 0 )
1818 GenerateMacrosAndTargetsTarget ( module
);
1820 fprintf ( fMakefile
, "%s: %s %s\n",
1822 objectFilenames
.c_str (),
1823 importLibraryDependencies
.c_str () );
1826 if ( IsCPlusPlusModule ( module
) )
1831 string linkerParameters
= ssprintf ( "-Wl,--subsystem,windows -Wl,--entry,%s -Wl,--image-base,0x00400000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
1832 module
.entrypoint
.c_str () );
1833 GenerateLinkerCommand ( module
,
1840 fprintf ( fMakefile
, ".PHONY: %s\n\n",
1842 fprintf ( fMakefile
, "%s:\n\n",
1848 static MingwBootLoaderModuleHandler bootloadermodule_handler
;
1850 MingwBootLoaderModuleHandler::MingwBootLoaderModuleHandler ()
1851 : MingwModuleHandler ( BootLoader
)
1856 MingwBootLoaderModuleHandler::Process ( const Module
& module
)
1858 GeneratePreconditionDependencies ( module
);
1859 GenerateBootLoaderModuleTarget ( module
);
1860 GenerateInvocations ( module
);
1864 MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ( const Module
& module
)
1866 static string
ros_junk ( "$(ROS_TEMPORARY)" );
1867 string
targetName ( module
.GetTargetName () );
1868 string
target ( FixupTargetFilename (module
.GetPath ()) );
1869 string workingDirectory
= GetWorkingDirectory ();
1870 string junk_tmp
= ros_junk
+ module
.name
+ ".junk.tmp";
1871 string objectsMacro
= GetObjectsMacro ( module
);
1872 string importLibraryDependencies
= GetImportLibraryDependencies ( module
);
1874 GenerateMacrosAndTargetsTarget ( module
);
1876 fprintf ( fMakefile
, "%s: %s %s\n",
1878 objectsMacro
.c_str (),
1879 importLibraryDependencies
.c_str () );
1881 fprintf ( fMakefile
,
1882 "\t${ld} %s -N -Ttext=0x8000 -o %s %s %s\n",
1883 GetLinkerMacro ( module
).c_str (),
1885 objectsMacro
.c_str (),
1886 importLibraryDependencies
.c_str () );
1887 fprintf ( fMakefile
,
1888 "\t${objcopy} -O binary %s %s\n",
1891 fprintf ( fMakefile
,
1893 junk_tmp
.c_str () );
1897 static MingwBootSectorModuleHandler bootsectormodule_handler
;
1899 MingwBootSectorModuleHandler::MingwBootSectorModuleHandler ()
1900 : MingwModuleHandler ( BootSector
)
1905 MingwBootSectorModuleHandler::Process ( const Module
& module
)
1907 GeneratePreconditionDependencies ( module
);
1908 GenerateBootSectorModuleTarget ( module
);
1909 GenerateInvocations ( module
);
1913 MingwBootSectorModuleHandler::GenerateBootSectorModuleTarget ( const Module
& module
)
1915 string objectsMacro
= GetObjectsMacro ( module
);
1917 string
* nasmflags
= new string ( "-f bin" );
1918 GenerateMacrosAndTargetsTarget ( module
,
1922 fprintf ( fMakefile
, ".PHONY: %s\n\n",
1923 module
.name
.c_str ());
1924 fprintf ( fMakefile
,
1926 module
.name
.c_str (),
1927 objectsMacro
.c_str () );
1931 static MingwIsoModuleHandler isomodule_handler
;
1933 MingwIsoModuleHandler::MingwIsoModuleHandler ()
1934 : MingwModuleHandler ( Iso
)
1939 MingwIsoModuleHandler::Process ( const Module
& module
)
1941 GeneratePreconditionDependencies ( module
);
1942 GenerateIsoModuleTarget ( module
);
1943 GenerateInvocations ( module
);
1947 MingwIsoModuleHandler::GenerateIsoModuleTarget ( const Module
& module
)
1949 string bootcdDirectory
= "cd";
1950 string isoboot
= FixupTargetFilename ( "boot/freeldr/bootsect/isoboot.o" );
1951 string bootcdReactosNoFixup
= bootcdDirectory
+ "/reactos";
1952 string bootcdReactos
= FixupTargetFilename ( bootcdReactosNoFixup
);
1953 PassThruCacheDirectory ( bootcdReactos
+ SSEP
);
1954 string reactosInf
= FixupTargetFilename ( bootcdReactosNoFixup
+ "/reactos.inf" );
1955 string reactosDff
= NormalizeFilename ( "bootdata/packages/reactos.dff" );
1957 fprintf ( fMakefile
, ".PHONY: %s\n\n",
1958 module
.name
.c_str ());
1959 fprintf ( fMakefile
,
1961 module
.name
.c_str (),
1963 bootcdReactos
.c_str () );
1964 fprintf ( fMakefile
,
1965 "\t${cabman} /C %s /L %s /I\n",
1966 reactosDff
.c_str (),
1967 bootcdReactos
.c_str () );
1968 fprintf ( fMakefile
,
1969 "\t${cabman} /C %s /RC %s /L %s /N\n",
1970 reactosDff
.c_str (),
1971 reactosInf
.c_str (),
1972 bootcdReactos
.c_str () );
1973 fprintf ( fMakefile
,
1975 reactosInf
.c_str () );
1976 fprintf ( fMakefile
,
1977 "\t${cdmake} -v -m -b %s %s REACTOS ReactOS.iso\n",
1979 bootcdDirectory
.c_str () );
1980 fprintf ( fMakefile
,