5 #include "../../rbuild.h"
7 #include "modulehandler.h"
13 map
<ModuleType
,MingwModuleHandler
*>*
14 MingwModuleHandler::handler_map
= NULL
;
16 MingwModuleHandler::ref
= 0;
19 MingwModuleHandler::fMakefile
= NULL
;
21 MingwModuleHandler::MingwModuleHandler ( ModuleType moduletype
)
24 handler_map
= new map
<ModuleType
,MingwModuleHandler
*>;
25 (*handler_map
)[moduletype
] = this;
28 MingwModuleHandler::~MingwModuleHandler()
38 MingwModuleHandler::SetMakefile ( FILE* f
)
44 MingwModuleHandler::LookupHandler ( const string
& location
,
45 ModuleType moduletype
)
48 throw Exception ( "internal tool error: no registered module handlers" );
49 MingwModuleHandler
* h
= (*handler_map
)[moduletype
];
52 throw UnknownModuleTypeException ( location
, moduletype
);
59 MingwModuleHandler::GetWorkingDirectory () const
65 MingwModuleHandler::GetExtension ( const string
& filename
) const
67 size_t index
= filename
.find_last_of ( '.' );
68 if (index
!= string::npos
)
69 return filename
.substr ( index
);
74 MingwModuleHandler::ReplaceExtension ( const string
& filename
,
75 const string
& newExtension
) const
77 size_t index
= filename
.find_last_of ( '.' );
78 if (index
!= string::npos
)
79 return filename
.substr ( 0, index
) + newExtension
;
84 MingwModuleHandler::GetModuleArchiveFilename ( const Module
& module
) const
86 return ReplaceExtension ( FixupTargetFilename ( module
.GetPath () ),
91 MingwModuleHandler::GetImportLibraryDependencies ( const Module
& module
) const
93 if ( module
.libraries
.size () == 0 )
96 string
dependencies ( "" );
97 for ( size_t i
= 0; i
< module
.libraries
.size (); i
++ )
99 if ( dependencies
.size () > 0 )
101 const Module
* importedModule
= module
.project
.LocateModule ( module
.libraries
[i
]->name
);
102 assert ( importedModule
!= NULL
);
103 dependencies
+= FixupTargetFilename ( importedModule
->GetDependencyPath () ).c_str ();
109 MingwModuleHandler::GetModuleDependencies ( const Module
& module
) const
111 if ( module
.dependencies
.size () == 0 )
114 string
dependencies ( "" );
115 for ( size_t i
= 0; i
< module
.dependencies
.size (); i
++ )
117 if ( dependencies
.size () > 0 )
119 const Dependency
* dependency
= module
.dependencies
[i
];
120 const Module
* dependencyModule
= dependency
->dependencyModule
;
121 dependencies
+= dependencyModule
->GetTargets ();
127 MingwModuleHandler::GetAllDependencies ( const Module
& module
) const
129 string dependencies
= GetImportLibraryDependencies ( module
);
130 string s
= GetModuleDependencies ( module
);
140 MingwModuleHandler::GetSourceFilenames ( const Module
& module
) const
144 string
sourceFilenames ( "" );
145 for ( i
= 0; i
< module
.files
.size (); i
++ )
146 sourceFilenames
+= " " + module
.files
[i
]->name
;
147 vector
<If
*> ifs
= module
.ifs
;
148 for ( i
= 0; i
< ifs
.size(); i
++ )
152 for ( j
= 0; j
< rIf
.ifs
.size(); j
++ )
153 ifs
.push_back ( rIf
.ifs
[j
] );
154 for ( j
= 0; j
< rIf
.files
.size(); j
++ )
155 sourceFilenames
+= " " + rIf
.files
[j
]->name
;
157 return sourceFilenames
;
161 MingwModuleHandler::GetObjectFilename ( const string
& sourceFilename
) const
164 string extension
= GetExtension ( sourceFilename
);
165 if ( extension
== ".rc" || extension
== ".RC" )
166 newExtension
= ".coff";
169 return FixupTargetFilename ( ReplaceExtension ( sourceFilename
,
174 MingwModuleHandler::GetObjectFilenames ( const Module
& module
) const
176 if ( module
.files
.size () == 0 )
179 string
objectFilenames ( "" );
180 for ( size_t i
= 0; i
< module
.files
.size (); i
++ )
182 if ( objectFilenames
.size () > 0 )
183 objectFilenames
+= " ";
184 objectFilenames
+= GetObjectFilename ( module
.files
[i
]->name
);
186 return objectFilenames
;
190 MingwModuleHandler::GenerateGccDefineParametersFromVector ( const vector
<Define
*>& defines
) const
193 for (size_t i
= 0; i
< defines
.size (); i
++)
195 Define
& define
= *defines
[i
];
196 if (parameters
.length () > 0)
199 parameters
+= define
.name
;
200 if (define
.value
.length () > 0)
203 parameters
+= define
.value
;
210 MingwModuleHandler::GenerateGccDefineParameters ( const Module
& module
) const
212 string parameters
= GenerateGccDefineParametersFromVector ( module
.project
.defines
);
213 string s
= GenerateGccDefineParametersFromVector ( module
.defines
);
223 MingwModuleHandler::ConcatenatePaths ( const string
& path1
,
224 const string
& path2
) const
226 if ( ( path1
.length () == 0 ) || ( path1
== "." ) || ( path1
== "./" ) )
228 if ( path1
[path1
.length ()] == CSEP
)
229 return path1
+ path2
;
231 return path1
+ CSEP
+ path2
;
235 MingwModuleHandler::GenerateGccIncludeParametersFromVector ( const vector
<Include
*>& includes
) const
238 for ( size_t i
= 0; i
< includes
.size (); i
++ )
240 Include
& include
= *includes
[i
];
241 if (parameters
.length () > 0)
243 parameters
+= "-I" + include
.directory
;
249 MingwModuleHandler::GenerateGccIncludeParameters ( const Module
& module
) const
251 string parameters
= GenerateGccIncludeParametersFromVector ( module
.includes
);
252 string s
= GenerateGccIncludeParametersFromVector ( module
.project
.includes
);
253 if ( s
.length () > 0 )
263 MingwModuleHandler::GenerateLinkerParametersFromVector ( const vector
<LinkerFlag
*>& linkerFlags
) const
266 for ( size_t i
= 0; i
< linkerFlags
.size (); i
++ )
268 LinkerFlag
& linkerFlag
= *linkerFlags
[i
];
269 if ( parameters
.length () > 0 )
271 parameters
+= linkerFlag
.flag
;
277 MingwModuleHandler::GenerateLinkerParameters ( const Module
& module
) const
279 return GenerateLinkerParametersFromVector ( module
.linkerFlags
);
283 MingwModuleHandler::GenerateMacro ( const char* assignmentOperation
,
285 const vector
<Include
*>& includes
,
286 const vector
<Define
*>& defines
) const
294 assignmentOperation
);
295 for ( i
= 0; i
< includes
.size(); i
++ )
300 includes
[i
]->directory
.c_str() );
302 for ( i
= 0; i
< defines
.size(); i
++ )
304 Define
& d
= *defines
[i
];
309 if ( d
.value
.size() )
315 fprintf ( fMakefile
, "\n" );
319 MingwModuleHandler::GenerateMacros (
320 const char* assignmentOperation
,
321 const vector
<File
*>& files
,
322 const vector
<Include
*>& includes
,
323 const vector
<Define
*>& defines
,
324 const vector
<LinkerFlag
*>* linkerFlags
,
325 const vector
<If
*>& ifs
,
326 const string
& cflags_macro
,
327 const string
& nasmflags_macro
,
328 const string
& windresflags_macro
,
329 const string
& linkerflags_macro
,
330 const string
& objs_macro
) const
334 if ( includes
.size() || defines
.size() )
336 GenerateMacro ( assignmentOperation
,
340 GenerateMacro ( assignmentOperation
,
346 if ( linkerFlags
!= NULL
)
348 string linkerParameters
= GenerateLinkerParametersFromVector ( *linkerFlags
);
349 if ( linkerParameters
.size () > 0 )
354 linkerflags_macro
.c_str (),
356 linkerParameters
.c_str() );
366 assignmentOperation
);
367 for ( i
= 0; i
< files
.size(); i
++ )
372 ( i
%10 == 9 ? "\\\n\t" : " " ),
373 GetObjectFilename(files
[i
]->name
).c_str() );
375 fprintf ( fMakefile
, "\n" );
378 for ( i
= 0; i
< ifs
.size(); i
++ )
381 if ( rIf
.defines
.size() || rIf
.includes
.size() || rIf
.files
.size() || rIf
.ifs
.size() )
385 "ifeq (\"$(%s)\",\"%s\")\n",
386 rIf
.property
.c_str(),
408 MingwModuleHandler::GenerateMacros (
409 const Module
& module
,
410 const string
& cflags_macro
,
411 const string
& nasmflags_macro
,
412 const string
& windresflags_macro
,
413 const string
& linkerflags_macro
,
414 const string
& objs_macro
) const
428 fprintf ( fMakefile
, "\n" );
432 "%s += $(PROJECT_CFLAGS)\n\n",
433 cflags_macro
.c_str () );
437 "%s += $(PROJECT_RCFLAGS)\n\n",
438 windresflags_macro
.c_str () );
442 "%s_LFLAGS += $(PROJECT_LFLAGS)\n\n",
443 module
.name
.c_str () );
447 MingwModuleHandler::GenerateGccCommand ( const Module
& module
,
448 const string
& sourceFilename
,
450 const string
& cflagsMacro
) const
452 string objectFilename
= GetObjectFilename ( sourceFilename
);
453 return ssprintf ( "%s -c %s -o %s %s\n",
455 sourceFilename
.c_str (),
456 objectFilename
.c_str (),
457 cflagsMacro
.c_str () );
461 MingwModuleHandler::GenerateGccAssemblerCommand ( const Module
& module
,
462 const string
& sourceFilename
,
464 const string
& cflagsMacro
) const
466 string objectFilename
= GetObjectFilename ( sourceFilename
);
467 return ssprintf ( "%s -x assembler-with-cpp -c %s -o %s -D__ASM__ %s\n",
469 sourceFilename
.c_str (),
470 objectFilename
.c_str (),
471 cflagsMacro
.c_str () );
475 MingwModuleHandler::GenerateNasmCommand ( const Module
& module
,
476 const string
& sourceFilename
,
477 const string
& nasmflagsMacro
) const
479 string objectFilename
= GetObjectFilename ( sourceFilename
);
480 return ssprintf ( "%s -f win32 %s -o %s %s\n",
482 sourceFilename
.c_str (),
483 objectFilename
.c_str (),
484 nasmflagsMacro
.c_str () );
488 MingwModuleHandler::GenerateWindresCommand ( const Module
& module
,
489 const string
& sourceFilename
,
490 const string
& windresflagsMacro
) const
492 string objectFilename
= GetObjectFilename ( sourceFilename
);
493 return ssprintf ( "%s %s -o %s ${%s}\n",
495 sourceFilename
.c_str (),
496 objectFilename
.c_str (),
497 windresflagsMacro
.c_str () );
501 MingwModuleHandler::GenerateCommand ( const Module
& module
,
502 const string
& sourceFilename
,
504 const string
& cflagsMacro
,
505 const string
& nasmflagsMacro
,
506 const string
& windresflagsMacro
) const
508 string extension
= GetExtension ( sourceFilename
);
509 if ( extension
== ".c" || extension
== ".C" )
510 return GenerateGccCommand ( module
,
514 else if ( extension
== ".s" || extension
== ".S" )
515 return GenerateGccAssemblerCommand ( module
,
519 else if ( extension
== ".asm" || extension
== ".ASM" )
520 return GenerateNasmCommand ( module
,
523 else if ( extension
== ".rc" || extension
== ".RC" )
524 return GenerateWindresCommand ( module
,
528 throw InvalidOperationException ( __FILE__
,
530 "Unsupported filename extension '%s' in file '%s'",
532 sourceFilename
.c_str () );
536 MingwModuleHandler::GenerateLinkerCommand ( const Module
& module
,
537 const string
& linker
,
538 const string
& linkerParameters
,
539 const string
& objectFilenames
) const
541 string
target ( FixupTargetFilename ( module
.GetPath () ) );
542 string importLibraryDependencies
= GetImportLibraryDependencies ( module
);
543 return ssprintf ( "%s %s -o %s %s %s %s\n",
545 linkerParameters
.c_str (),
547 objectFilenames
.c_str (),
548 importLibraryDependencies
.c_str (),
549 GetLinkerMacro ( module
).c_str () );
553 MingwModuleHandler::GenerateObjectFileTargets ( const Module
& module
,
554 const vector
<File
*>& files
,
555 const vector
<If
*>& ifs
,
557 const string
& cflagsMacro
,
558 const string
& nasmflagsMacro
,
559 const string
& windresflagsMacro
) const
563 for ( i
= 0; i
< files
.size (); i
++ )
565 string sourceFilename
= files
[i
]->name
;
566 string objectFilename
= GetObjectFilename ( sourceFilename
);
569 objectFilename
.c_str (),
570 sourceFilename
.c_str () );
573 GenerateCommand ( module
,
578 windresflagsMacro
).c_str () );
581 for ( i
= 0; i
< ifs
.size(); i
++ )
582 GenerateObjectFileTargets ( module
,
592 MingwModuleHandler::GenerateObjectFileTargets ( const Module
& module
,
594 const string
& cflagsMacro
,
595 const string
& nasmflagsMacro
,
596 const string
& windresflagsMacro
) const
598 GenerateObjectFileTargets ( module
,
605 fprintf ( fMakefile
, "\n" );
609 MingwModuleHandler::GetCleanTargets ( vector
<string
>& out
,
610 const vector
<File
*>& files
,
611 const vector
<If
*>& ifs
) const
615 for ( i
= 0; i
< files
.size(); i
++ )
616 out
.push_back ( GetObjectFilename(files
[i
]->name
) );
618 for ( i
= 0; i
< ifs
.size(); i
++ )
619 GetCleanTargets ( out
, ifs
[i
]->files
, ifs
[i
]->ifs
);
623 MingwModuleHandler::GenerateArchiveTarget ( const Module
& module
,
625 const string
& objs_macro
) const
627 string archiveFilename
= GetModuleArchiveFilename ( module
);
631 archiveFilename
.c_str (),
632 objs_macro
.c_str ());
635 "\t%s -rc %s %s\n\n",
637 archiveFilename
.c_str (),
638 objs_macro
.c_str ());
640 return archiveFilename
;
644 MingwModuleHandler::GetObjectsMacro ( const Module
& module
) const
646 return ssprintf ( "$(%s_OBJS)",
647 module
.name
.c_str () );
651 MingwModuleHandler::GetLinkerMacro ( const Module
& module
) const
653 return ssprintf ( "$(%s_LFLAGS)",
654 module
.name
.c_str () );
658 MingwModuleHandler::GenerateMacrosAndTargets (
659 const Module
& module
,
661 const string
& ar
) const
663 string cflagsMacro
= ssprintf ("%s_CFLAGS", module
.name
.c_str ());
664 string nasmflagsMacro
= ssprintf ("%s_NASMFLAGS", module
.name
.c_str ());
665 string windresflagsMacro
= ssprintf ("%s_RCFLAGS", module
.name
.c_str ());
666 string linkerFlagsMacro
= ssprintf ("%s_LFLAGS", module
.name
.c_str ());
667 string objectsMacro
= ssprintf ("%s_OBJS", module
.name
.c_str ());
669 GenerateMacros ( module
,
676 // generate phony target for module name
677 fprintf ( fMakefile
, ".PHONY: %s\n",
678 module
.name
.c_str() );
679 fprintf ( fMakefile
, "%s: %s\n\n",
681 module
.GetPath().c_str() );
683 // future references to the macros will be to get their values
684 cflagsMacro
= ssprintf ("$(%s)", cflagsMacro
.c_str ());
685 nasmflagsMacro
= ssprintf ("$(%s)", nasmflagsMacro
.c_str ());
686 objectsMacro
= ssprintf ("$(%s)", objectsMacro
.c_str ());
688 string ar_target
= GenerateArchiveTarget ( module
, ar
, objectsMacro
);
689 GenerateObjectFileTargets ( module
,
695 vector
<string
> clean_files
;
696 clean_files
.push_back ( FixupTargetFilename(module
.GetPath()) );
697 clean_files
.push_back ( ar_target
);
698 GetCleanTargets ( clean_files
, module
.files
, module
.ifs
);
700 fprintf ( fMakefile
, "clean::\n\t-@$(rm)" );
701 for ( size_t i
= 0; i
< clean_files
.size(); i
++ )
704 fprintf ( fMakefile
, " 2>NUL\n\t-@$(rm)" );
705 fprintf ( fMakefile
, " %s", clean_files
[i
].c_str() );
707 fprintf ( fMakefile
, " 2>NUL\n\n" );
711 MingwModuleHandler::GenerateMacrosAndTargetsHost ( const Module
& module
) const
713 GenerateMacrosAndTargets ( module
, "${host_gcc}", "${host_ar}" );
717 MingwModuleHandler::GenerateMacrosAndTargetsTarget ( const Module
& module
) const
719 GenerateMacrosAndTargets ( module
, "${gcc}", "${ar}" );
723 MingwModuleHandler::GetInvocationDependencies ( const Module
& module
) const
726 for ( size_t i
= 0; i
< module
.invocations
.size (); i
++ )
728 Invoke
& invoke
= *module
.invocations
[i
];
729 if (invoke
.invokeModule
== &module
)
730 /* Protect against circular dependencies */
732 if ( dependencies
.length () > 0 )
734 dependencies
+= invoke
.GetTargets ();
740 MingwModuleHandler::GetInvocationParameters ( const Invoke
& invoke
) const
742 string
parameters ( "" );
744 for (i
= 0; i
< invoke
.output
.size (); i
++)
746 if (parameters
.length () > 0)
748 InvokeFile
& invokeFile
= *invoke
.output
[i
];
749 if (invokeFile
.switches
.length () > 0)
751 parameters
+= invokeFile
.switches
;
754 parameters
+= invokeFile
.name
;
757 for (i
= 0; i
< invoke
.input
.size (); i
++)
759 if (parameters
.length () > 0)
761 InvokeFile
& invokeFile
= *invoke
.input
[i
];
762 if (invokeFile
.switches
.length () > 0)
764 parameters
+= invokeFile
.switches
;
767 parameters
+= invokeFile
.name
;
774 MingwModuleHandler::GenerateInvocations ( const Module
& module
) const
776 if ( module
.invocations
.size () == 0 )
779 for ( size_t i
= 0; i
< module
.invocations
.size (); i
++ )
781 const Invoke
& invoke
= *module
.invocations
[i
];
783 if ( invoke
.invokeModule
->type
!= BuildTool
)
784 throw InvalidBuildFileException ( module
.node
.location
,
785 "Only modules of type buildtool can be invoked." );
787 string invokeTarget
= module
.GetInvocationTarget ( i
);
790 invoke
.GetTargets ().c_str (),
791 invokeTarget
.c_str () );
794 invokeTarget
.c_str (),
795 FixupTargetFilename ( invoke
.invokeModule
->GetPath () ).c_str () );
798 FixupTargetFilename ( invoke
.invokeModule
->GetPath () ).c_str (),
799 GetInvocationParameters ( invoke
).c_str () );
802 invokeTarget
.c_str () );
807 MingwModuleHandler::GetPreconditionDependenciesName ( const Module
& module
) const
809 return ssprintf ( "%s_precondition",
810 module
.name
.c_str () );
814 MingwModuleHandler::GeneratePreconditionDependencies ( const Module
& module
) const
816 string preconditionDependenciesName
= GetPreconditionDependenciesName ( module
);
817 string sourceFilenames
= GetSourceFilenames ( module
);
818 string dependencies
= GetModuleDependencies ( module
);
819 string s
= GetInvocationDependencies ( module
);
820 if ( s
.length () > 0 )
822 if ( dependencies
.length () > 0 )
829 preconditionDependenciesName
.c_str () );
832 preconditionDependenciesName
.c_str (),
833 dependencies
.c_str () );
834 const char* p
= sourceFilenames
.c_str();
835 const char* end
= p
+ strlen(p
);
838 const char* p2
= &p
[512];
841 while ( p2
> p
&& !isspace(*p2
) )
845 p2
= strpbrk ( p
, " \t" );
853 preconditionDependenciesName
.c_str ());
855 p
+= strspn ( p
, " \t" );
857 fprintf ( fMakefile
, "\n" );
861 static MingwBuildToolModuleHandler buildtool_handler
;
863 MingwBuildToolModuleHandler::MingwBuildToolModuleHandler()
864 : MingwModuleHandler ( BuildTool
)
869 MingwBuildToolModuleHandler::Process ( const Module
& module
)
871 GeneratePreconditionDependencies ( module
);
872 GenerateBuildToolModuleTarget ( module
);
873 GenerateInvocations ( module
);
877 MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ( const Module
& module
)
879 string
target ( FixupTargetFilename ( module
.GetPath () ) );
880 string archiveFilename
= GetModuleArchiveFilename ( module
);
882 GenerateMacrosAndTargetsHost ( module
);
884 fprintf ( fMakefile
, "%s: %s\n",
886 archiveFilename
.c_str () );
888 "\t${host_gcc} %s -o %s %s\n\n",
889 GetLinkerMacro ( module
).c_str (),
891 archiveFilename
.c_str () );
894 static MingwKernelModuleHandler kernelmodule_handler
;
896 MingwKernelModuleHandler::MingwKernelModuleHandler ()
897 : MingwModuleHandler ( Kernel
)
902 MingwKernelModuleHandler::Process ( const Module
& module
)
904 GeneratePreconditionDependencies ( module
);
905 GenerateKernelModuleTarget ( module
);
906 GenerateInvocations ( module
);
910 MingwKernelModuleHandler::GenerateKernelModuleTarget ( const Module
& module
)
912 static string
ros_junk ( "$(ROS_TEMPORARY)" );
913 string
target ( FixupTargetFilename (module
.GetPath ()) );
914 string workingDirectory
= GetWorkingDirectory ();
915 string objectsMacro
= GetObjectsMacro ( module
);
916 string importLibraryDependencies
= GetImportLibraryDependencies ( module
);
917 string base_tmp
= ros_junk
+ module
.name
+ ".base.tmp";
918 string junk_tmp
= ros_junk
+ module
.name
+ ".junk.tmp";
919 string temp_exp
= ros_junk
+ module
.name
+ ".temp.exp";
920 string gccOptions
= ssprintf ("-Wl,-T,%s" SSEP
"ntoskrnl.lnk -Wl,--subsystem,native -Wl,--entry,_NtProcessStartup -Wl,--image-base,0xC0000000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll",
921 module
.GetBasePath ().c_str () );
923 GenerateMacrosAndTargetsTarget ( module
);
925 fprintf ( fMakefile
, "%s: %s %s\n",
927 objectsMacro
.c_str (),
928 importLibraryDependencies
.c_str () );
930 "\t${gcc} %s %s -Wl,--base-file,%s -o %s %s %s\n",
931 GetLinkerMacro ( module
).c_str (),
935 objectsMacro
.c_str (),
936 importLibraryDependencies
.c_str () );
941 "\t${dlltool} --dllname %s --base-file %s --def ntoskrnl/ntoskrnl.def --output-exp %s --kill-at\n",
949 "\t${gcc} %s %s -Wl,%s -o %s %s %s\n",
950 GetLinkerMacro ( module
).c_str (),
954 objectsMacro
.c_str (),
955 importLibraryDependencies
.c_str () );
962 static MingwStaticLibraryModuleHandler staticlibrary_handler
;
964 MingwStaticLibraryModuleHandler::MingwStaticLibraryModuleHandler ()
965 : MingwModuleHandler ( StaticLibrary
)
970 MingwStaticLibraryModuleHandler::Process ( const Module
& module
)
972 GeneratePreconditionDependencies ( module
);
973 GenerateStaticLibraryModuleTarget ( module
);
974 GenerateInvocations ( module
);
978 MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget ( const Module
& module
)
980 GenerateMacrosAndTargetsTarget ( module
);
984 static MingwKernelModeDLLModuleHandler kernelmodedll_handler
;
986 MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler ()
987 : MingwModuleHandler ( KernelModeDLL
)
992 MingwKernelModeDLLModuleHandler::Process ( const Module
& module
)
994 GeneratePreconditionDependencies ( module
);
995 GenerateKernelModeDLLModuleTarget ( module
);
996 GenerateInvocations ( module
);
1000 MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ( const Module
& module
)
1002 static string
ros_junk ( "$(ROS_TEMPORARY)" );
1003 string
target ( FixupTargetFilename ( module
.GetPath () ) );
1004 string workingDirectory
= GetWorkingDirectory ( );
1005 string archiveFilename
= GetModuleArchiveFilename ( module
);
1006 string importLibraryDependencies
= GetImportLibraryDependencies ( module
);
1008 if (module
.importLibrary
!= NULL
)
1010 fprintf ( fMakefile
, "%s:\n",
1011 module
.GetDependencyPath ().c_str () );
1013 fprintf ( fMakefile
,
1014 "\t${dlltool} --dllname %s --def %s --output-lib %s --kill-at\n\n",
1015 module
.GetTargetName ().c_str (),
1016 FixupTargetFilename ( module
.GetBasePath () + SSEP
+ module
.importLibrary
->definition
).c_str (),
1017 FixupTargetFilename ( module
.GetDependencyPath () ).c_str () );
1020 if (module
.files
.size () > 0)
1022 GenerateMacrosAndTargetsTarget ( module
);
1024 fprintf ( fMakefile
, "%s: %s %s\n",
1026 archiveFilename
.c_str (),
1027 importLibraryDependencies
.c_str () );
1029 string
linkerParameters ( "-Wl,--subsystem,native -Wl,--entry,_DriverEntry@8 -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll" );
1030 string linkerCommand
= GenerateLinkerCommand ( module
,
1034 fprintf ( fMakefile
,
1036 linkerCommand
.c_str () );
1040 fprintf ( fMakefile
, "%s:\n",
1042 fprintf ( fMakefile
, ".PHONY: %s\n\n",
1048 static MingwNativeDLLModuleHandler nativedll_handler
;
1050 MingwNativeDLLModuleHandler::MingwNativeDLLModuleHandler ()
1051 : MingwModuleHandler ( NativeDLL
)
1056 MingwNativeDLLModuleHandler::Process ( const Module
& module
)
1058 GeneratePreconditionDependencies ( module
);
1059 GenerateNativeDLLModuleTarget ( module
);
1060 GenerateInvocations ( module
);
1064 MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ( const Module
& module
)
1066 static string
ros_junk ( "$(ROS_TEMPORARY)" );
1067 string
target ( FixupTargetFilename ( module
.GetPath () ) );
1068 string workingDirectory
= GetWorkingDirectory ( );
1069 string archiveFilename
= GetModuleArchiveFilename ( module
);
1070 string importLibraryDependencies
= GetImportLibraryDependencies ( module
);
1072 if (module
.importLibrary
!= NULL
)
1074 fprintf ( fMakefile
, "%s:\n",
1075 module
.GetDependencyPath ().c_str () );
1077 fprintf ( fMakefile
,
1078 "\t${dlltool} --dllname %s --def %s --output-lib %s --kill-at\n\n",
1079 module
.GetTargetName ().c_str (),
1080 FixupTargetFilename ( module
.GetBasePath () + SSEP
+ module
.importLibrary
->definition
).c_str (),
1081 FixupTargetFilename ( module
.GetDependencyPath () ).c_str () );
1084 if (module
.files
.size () > 0)
1086 GenerateMacrosAndTargetsTarget ( module
);
1088 fprintf ( fMakefile
, "%s: %s %s\n",
1090 archiveFilename
.c_str (),
1091 importLibraryDependencies
.c_str () );
1093 string
linkerParameters ( "-Wl,--subsystem,native -Wl,--entry,_DllMainCRTStartup@12 -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib -mdll" );
1094 string linkerCommand
= GenerateLinkerCommand ( module
,
1098 fprintf ( fMakefile
,
1100 linkerCommand
.c_str () );
1104 fprintf ( fMakefile
, "%s:\n\n",
1106 fprintf ( fMakefile
, ".PHONY: %s\n\n",
1112 static MingwWin32DLLModuleHandler win32dll_handler
;
1114 MingwWin32DLLModuleHandler::MingwWin32DLLModuleHandler ()
1115 : MingwModuleHandler ( Win32DLL
)
1120 MingwWin32DLLModuleHandler::Process ( const Module
& module
)
1122 GeneratePreconditionDependencies ( module
);
1123 GenerateWin32DLLModuleTarget ( module
);
1124 GenerateInvocations ( module
);
1128 MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ( const Module
& module
)
1130 static string
ros_junk ( "$(ROS_TEMPORARY)" );
1131 string
target ( FixupTargetFilename ( module
.GetPath () ) );
1132 string workingDirectory
= GetWorkingDirectory ( );
1133 string archiveFilename
= GetModuleArchiveFilename ( module
);
1134 string importLibraryDependencies
= GetImportLibraryDependencies ( module
);
1136 if (module
.importLibrary
!= NULL
)
1138 fprintf ( fMakefile
, "%s:\n",
1139 module
.GetDependencyPath ().c_str () );
1141 fprintf ( fMakefile
,
1142 "\t${dlltool} --dllname %s --def %s --output-lib %s --kill-at\n\n",
1143 module
.GetTargetName ().c_str (),
1144 FixupTargetFilename ( module
.GetBasePath () + SSEP
+ module
.importLibrary
->definition
).c_str (),
1145 FixupTargetFilename ( module
.GetDependencyPath () ).c_str () );
1148 if (module
.files
.size () > 0)
1150 GenerateMacrosAndTargetsTarget ( module
);
1152 fprintf ( fMakefile
, "%s: %s %s\n",
1154 archiveFilename
.c_str (),
1155 importLibraryDependencies
.c_str () );
1157 string
linkerParameters ( "-Wl,--subsystem,console -Wl,--entry,_DllMain@12 -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -mdll" );
1158 string linkerCommand
= GenerateLinkerCommand ( module
,
1162 fprintf ( fMakefile
,
1164 linkerCommand
.c_str () );
1168 fprintf ( fMakefile
, "%s:\n\n",
1170 fprintf ( fMakefile
, ".PHONY: %s\n\n",
1176 static MingwWin32GUIModuleHandler win32gui_handler
;
1178 MingwWin32GUIModuleHandler::MingwWin32GUIModuleHandler ()
1179 : MingwModuleHandler ( Win32GUI
)
1184 MingwWin32GUIModuleHandler::Process ( const Module
& module
)
1186 GeneratePreconditionDependencies ( module
);
1187 GenerateWin32GUIModuleTarget ( module
);
1188 GenerateInvocations ( module
);
1192 MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ( const Module
& module
)
1194 static string
ros_junk ( "$(ROS_TEMPORARY)" );
1195 string
target ( FixupTargetFilename ( module
.GetPath () ) );
1196 string workingDirectory
= GetWorkingDirectory ( );
1197 string objectFilenames
= GetObjectFilenames ( module
);
1198 string importLibraryDependencies
= GetImportLibraryDependencies ( module
);
1200 if (module
.files
.size () > 0)
1202 GenerateMacrosAndTargetsTarget ( module
);
1204 fprintf ( fMakefile
, "%s: %s %s\n",
1206 objectFilenames
.c_str (),
1207 importLibraryDependencies
.c_str () );
1209 string
linkerParameters ( "-Wl,--subsystem,windows -Wl,--entry,_WinMainCRTStartup -Wl,--image-base,0x00400000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000" );
1210 string linkerCommand
= GenerateLinkerCommand ( module
,
1214 fprintf ( fMakefile
,
1216 linkerCommand
.c_str () );
1220 fprintf ( fMakefile
, "%s:\n\n",
1222 fprintf ( fMakefile
, ".PHONY: %s\n\n",