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
)
43 /*static*/ MingwModuleHandler
*
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 () ).c_str (),
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
163 return FixupTargetFilename ( ReplaceExtension ( sourceFilename
,
168 MingwModuleHandler::GetObjectFilenames ( const Module
& module
) const
170 if ( module
.files
.size () == 0 )
173 string
objectFilenames ( "" );
174 for ( size_t i
= 0; i
< module
.files
.size (); i
++ )
176 if ( objectFilenames
.size () > 0 )
177 objectFilenames
+= " ";
178 objectFilenames
+= GetObjectFilename ( module
.files
[i
]->name
);
180 return objectFilenames
;
184 MingwModuleHandler::GenerateGccDefineParametersFromVector ( const vector
<Define
*>& defines
) const
187 for (size_t i
= 0; i
< defines
.size (); i
++)
189 Define
& define
= *defines
[i
];
190 if (parameters
.length () > 0)
193 parameters
+= define
.name
;
194 if (define
.value
.length () > 0)
197 parameters
+= define
.value
;
204 MingwModuleHandler::GenerateGccDefineParameters ( const Module
& module
) const
206 string parameters
= GenerateGccDefineParametersFromVector ( module
.project
.defines
);
207 string s
= GenerateGccDefineParametersFromVector ( module
.defines
);
217 MingwModuleHandler::ConcatenatePaths ( const string
& path1
,
218 const string
& path2
) const
220 if ( ( path1
.length () == 0 ) || ( path1
== "." ) || ( path1
== "./" ) )
222 if ( path1
[path1
.length ()] == CSEP
)
223 return path1
+ path2
;
225 return path1
+ CSEP
+ path2
;
229 MingwModuleHandler::GenerateGccIncludeParametersFromVector ( const vector
<Include
*>& includes
) const
232 for ( size_t i
= 0; i
< includes
.size (); i
++ )
234 Include
& include
= *includes
[i
];
235 if (parameters
.length () > 0)
237 parameters
+= "-I" + include
.directory
;
243 MingwModuleHandler::GenerateGccModuleIncludeVariable ( const Module
& module
) const
246 string
name ( module
.name
+ "_CFLAGS" );
250 GenerateGccDefineParameters(module
).c_str(),
251 GenerateGccIncludeParameters(module
).c_str() );
256 MingwModuleHandler::GenerateGccIncludeParameters ( const Module
& module
) const
258 string parameters
= GenerateGccIncludeParametersFromVector ( module
.includes
);
259 string s
= GenerateGccIncludeParametersFromVector ( module
.project
.includes
);
260 if ( s
.length () > 0 )
269 MingwModuleHandler::GenerateMacros (
271 const vector
<File
*>& files
,
272 const vector
<Include
*>& includes
,
273 const vector
<Define
*>& defines
,
274 const vector
<If
*>& ifs
,
275 const string
& cflags_macro
,
276 const string
& nasmflags_macro
,
277 const string
& objs_macro
) const
281 if ( includes
.size() || defines
.size() )
286 cflags_macro
.c_str(),
288 for ( i
= 0; i
< includes
.size(); i
++ )
293 includes
[i
]->directory
.c_str() );
295 for ( i
= 0; i
< defines
.size(); i
++ )
297 Define
& d
= *defines
[i
];
302 if ( d
.value
.size() )
308 fprintf ( fMakefile
, "\n" );
318 for ( i
= 0; i
< files
.size(); i
++ )
323 ( i
%10 == 9 ? "\\\n\t" : " " ),
324 GetObjectFilename(files
[i
]->name
).c_str() );
326 fprintf ( fMakefile
, "\n" );
329 for ( i
= 0; i
< ifs
.size(); i
++ )
332 if ( rIf
.defines
.size() || rIf
.includes
.size() || rIf
.files
.size() || rIf
.ifs
.size() )
336 "ifeq (\"$(%s)\",\"%s\")\n",
337 rIf
.property
.c_str(),
356 MingwModuleHandler::GenerateMacros (
357 const Module
& module
,
358 const string
& cflags_macro
,
359 const string
& nasmflags_macro
,
360 const string
& objs_macro
) const
371 fprintf ( fMakefile
, "\n" );
375 "%s += $(PROJECT_CFLAGS)\n\n",
376 cflags_macro
.c_str () );
380 MingwModuleHandler::GenerateGccCommand ( const Module
& module
,
381 const string
& sourceFilename
,
383 const string
& cflagsMacro
) const
385 string objectFilename
= GetObjectFilename ( sourceFilename
);
386 return ssprintf ( "%s -c %s -o %s %s\n",
388 sourceFilename
.c_str (),
389 objectFilename
.c_str (),
390 cflagsMacro
.c_str () );
394 MingwModuleHandler::GenerateGccAssemblerCommand ( const Module
& module
,
395 const string
& sourceFilename
,
397 const string
& cflagsMacro
) const
399 string objectFilename
= GetObjectFilename ( sourceFilename
);
400 return ssprintf ( "%s -x assembler-with-cpp -c %s -o %s -D__ASM__ %s\n",
402 sourceFilename
.c_str (),
403 objectFilename
.c_str (),
404 cflagsMacro
.c_str () );
408 MingwModuleHandler::GenerateNasmCommand ( const Module
& module
,
409 const string
& sourceFilename
,
410 const string
& nasmflagsMacro
) const
412 string objectFilename
= GetObjectFilename ( sourceFilename
);
413 return ssprintf ( "%s -f win32 %s -o %s %s\n",
415 sourceFilename
.c_str (),
416 objectFilename
.c_str (),
417 nasmflagsMacro
.c_str () );
421 MingwModuleHandler::GenerateCommand ( const Module
& module
,
422 const string
& sourceFilename
,
424 const string
& cflagsMacro
,
425 const string
& nasmflagsMacro
) const
427 string extension
= GetExtension ( sourceFilename
);
428 if ( extension
== ".c" || extension
== ".C" )
429 return GenerateGccCommand ( module
,
433 else if ( extension
== ".s" || extension
== ".S" )
434 return GenerateGccAssemblerCommand ( module
,
438 else if ( extension
== ".asm" || extension
== ".ASM" )
439 return GenerateNasmCommand ( module
,
443 throw InvalidOperationException ( __FILE__
,
445 "Unsupported filename extension '%s' in file '%s'",
447 sourceFilename
.c_str () );
451 MingwModuleHandler::GenerateObjectFileTargets ( const Module
& module
,
452 const vector
<File
*>& files
,
453 const vector
<If
*>& ifs
,
455 const string
& cflagsMacro
,
456 const string
& nasmflagsMacro
) const
460 for ( i
= 0; i
< files
.size (); i
++ )
462 string sourceFilename
= files
[i
]->name
;
463 string objectFilename
= GetObjectFilename ( sourceFilename
);
466 objectFilename
.c_str (),
467 sourceFilename
.c_str () );
470 GenerateCommand ( module
,
474 nasmflagsMacro
).c_str () );
477 for ( i
= 0; i
< ifs
.size(); i
++ )
478 GenerateObjectFileTargets ( module
, ifs
[i
]->files
, ifs
[i
]->ifs
, cc
, cflagsMacro
, nasmflagsMacro
);
482 MingwModuleHandler::GenerateObjectFileTargets ( const Module
& module
,
484 const string
& cflagsMacro
,
485 const string
& nasmflagsMacro
) const
487 GenerateObjectFileTargets ( module
, module
.files
, module
.ifs
, cc
, cflagsMacro
, nasmflagsMacro
);
488 fprintf ( fMakefile
, "\n" );
492 MingwModuleHandler::GetCleanTargets ( vector
<string
>& out
,
493 const vector
<File
*>& files
,
494 const vector
<If
*>& ifs
) const
498 for ( i
= 0; i
< files
.size(); i
++ )
499 out
.push_back ( GetObjectFilename(files
[i
]->name
) );
501 for ( i
= 0; i
< ifs
.size(); i
++ )
502 GetCleanTargets ( out
, ifs
[i
]->files
, ifs
[i
]->ifs
);
506 MingwModuleHandler::GenerateArchiveTarget ( const Module
& module
,
508 const string
& objs_macro
) const
510 string archiveFilename
= GetModuleArchiveFilename ( module
);
514 archiveFilename
.c_str (),
515 objs_macro
.c_str ());
518 "\t%s -rc %s %s\n\n",
520 archiveFilename
.c_str (),
521 objs_macro
.c_str ());
523 return archiveFilename
;
527 MingwModuleHandler::GenerateMacrosAndTargets (
528 const Module
& module
,
530 const string
& ar
) const
532 string cflagsMacro
= ssprintf("%s_CFLAGS",module
.name
.c_str());
533 string nasmflagsMacro
= ssprintf("%s_NASMFLAGS",module
.name
.c_str());
534 string objectsMacro
= ssprintf("%s_OBJS",module
.name
.c_str());
536 GenerateMacros ( module
, cflagsMacro
, nasmflagsMacro
, objectsMacro
);
538 // generate phony target for module name
539 fprintf ( fMakefile
, ".PHONY: %s\n",
540 module
.name
.c_str() );
541 fprintf ( fMakefile
, "%s: %s\n\n",
543 module
.GetPath().c_str() );
545 // future references to the macros will be to get their values
546 cflagsMacro
= ssprintf("$(%s)",cflagsMacro
.c_str());
547 nasmflagsMacro
= ssprintf("$(%s)",nasmflagsMacro
.c_str());
548 objectsMacro
= ssprintf("$(%s)",objectsMacro
.c_str());
550 string ar_target
= GenerateArchiveTarget ( module
, ar
, objectsMacro
);
551 GenerateObjectFileTargets ( module
, cc
, cflagsMacro
, nasmflagsMacro
);
553 vector
<string
> clean_files
;
554 clean_files
.push_back ( FixupTargetFilename(module
.GetPath()) );
555 clean_files
.push_back ( ar_target
);
556 GetCleanTargets ( clean_files
, module
.files
, module
.ifs
);
558 fprintf ( fMakefile
, "clean::\n\t-@$(rm)" );
559 for ( size_t i
= 0; i
< clean_files
.size(); i
++ )
562 fprintf ( fMakefile
, " 2>NUL\n\t-@$(rm)" );
563 fprintf ( fMakefile
, " %s", clean_files
[i
].c_str() );
565 fprintf ( fMakefile
, " 2>NUL\n\n" );
569 MingwModuleHandler::GenerateMacrosAndTargetsHost ( const Module
& module
) const
571 GenerateMacrosAndTargets ( module
, "${host_gcc}", "${host_ar}" );
575 MingwModuleHandler::GenerateMacrosAndTargetsTarget ( const Module
& module
) const
577 GenerateMacrosAndTargets ( module
, "${gcc}", "${ar}" );
581 MingwModuleHandler::GetInvocationDependencies ( const Module
& module
) const
584 for ( size_t i
= 0; i
< module
.invocations
.size (); i
++ )
586 Invoke
& invoke
= *module
.invocations
[i
];
587 if (invoke
.invokeModule
== &module
)
588 /* Protect against circular dependencies */
590 if ( dependencies
.length () > 0 )
592 dependencies
+= invoke
.GetTargets ();
598 MingwModuleHandler::GetInvocationParameters ( const Invoke
& invoke
) const
600 string
parameters ( "" );
602 for (i
= 0; i
< invoke
.output
.size (); i
++)
604 if (parameters
.length () > 0)
606 InvokeFile
& invokeFile
= *invoke
.output
[i
];
607 if (invokeFile
.switches
.length () > 0)
609 parameters
+= invokeFile
.switches
;
612 parameters
+= invokeFile
.name
;
615 for (i
= 0; i
< invoke
.input
.size (); i
++)
617 if (parameters
.length () > 0)
619 InvokeFile
& invokeFile
= *invoke
.input
[i
];
620 if (invokeFile
.switches
.length () > 0)
622 parameters
+= invokeFile
.switches
;
625 parameters
+= invokeFile
.name
;
632 MingwModuleHandler::GenerateInvocations ( const Module
& module
) const
634 if ( module
.invocations
.size () == 0 )
637 for ( size_t i
= 0; i
< module
.invocations
.size (); i
++ )
639 const Invoke
& invoke
= *module
.invocations
[i
];
641 if ( invoke
.invokeModule
->type
!= BuildTool
)
642 throw InvalidBuildFileException ( module
.node
.location
,
643 "Only modules of type buildtool can be invoked." );
645 string invokeTarget
= module
.GetInvocationTarget ( i
);
648 invoke
.GetTargets ().c_str (),
649 invokeTarget
.c_str () );
652 invokeTarget
.c_str (),
653 FixupTargetFilename ( invoke
.invokeModule
->GetPath () ).c_str () );
656 FixupTargetFilename ( invoke
.invokeModule
->GetPath () ).c_str (),
657 GetInvocationParameters ( invoke
).c_str () );
660 invokeTarget
.c_str () );
665 MingwModuleHandler::GetPreconditionDependenciesName ( const Module
& module
) const
667 return ssprintf ( "%s_precondition",
668 module
.name
.c_str () );
672 MingwModuleHandler::GeneratePreconditionDependencies ( const Module
& module
) const
674 string preconditionDependenciesName
= GetPreconditionDependenciesName ( module
);
675 string sourceFilenames
= GetSourceFilenames ( module
);
676 string dependencies
= GetModuleDependencies ( module
);
677 string s
= GetInvocationDependencies ( module
);
678 if ( s
.length () > 0 )
680 if ( dependencies
.length () > 0 )
687 preconditionDependenciesName
.c_str () );
690 preconditionDependenciesName
.c_str (),
691 dependencies
.c_str () );
692 const char* p
= sourceFilenames
.c_str();
693 const char* end
= p
+ strlen(p
);
696 const char* p2
= &p
[512];
699 while ( p2
> p
&& !isspace(*p2
) )
703 p2
= strpbrk ( p
, " \t" );
711 preconditionDependenciesName
.c_str ());
713 p
+= strspn ( p
, " \t" );
715 fprintf ( fMakefile
, "\n" );
719 static MingwBuildToolModuleHandler buildtool_handler
;
721 MingwBuildToolModuleHandler::MingwBuildToolModuleHandler()
722 : MingwModuleHandler ( BuildTool
)
727 MingwBuildToolModuleHandler::Process ( const Module
& module
)
729 GeneratePreconditionDependencies ( module
);
730 GenerateBuildToolModuleTarget ( module
);
731 GenerateInvocations ( module
);
735 MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ( const Module
& module
)
737 string
target ( FixupTargetFilename ( module
.GetPath () ) );
738 string archiveFilename
= GetModuleArchiveFilename ( module
);
740 GenerateMacrosAndTargetsHost ( module
);
742 fprintf ( fMakefile
, "%s: %s\n",
744 archiveFilename
.c_str () );
746 "\t${host_gcc} -o %s %s\n\n",
748 archiveFilename
.c_str () );
751 static MingwKernelModuleHandler kernelmodule_handler
;
753 MingwKernelModuleHandler::MingwKernelModuleHandler ()
754 : MingwModuleHandler ( Kernel
)
759 MingwKernelModuleHandler::Process ( const Module
& module
)
761 GeneratePreconditionDependencies ( module
);
762 GenerateKernelModuleTarget ( module
);
763 GenerateInvocations ( module
);
767 MingwKernelModuleHandler::GenerateKernelModuleTarget ( const Module
& module
)
769 static string
ros_junk ( "$(ROS_TEMPORARY)" );
770 //static string ros_output ( "$(ROS_INTERMEDIATE)" );
771 string
target ( FixupTargetFilename(module
.GetPath()) );
772 string workingDirectory
= GetWorkingDirectory ( );
773 string archiveFilename
= GetModuleArchiveFilename ( module
);
774 string importLibraryDependencies
= GetImportLibraryDependencies ( module
);
775 string base_tmp
= ros_junk
+ module
.name
+ ".base.tmp";
776 string junk_tmp
= ros_junk
+ module
.name
+ ".junk.tmp";
777 string temp_exp
= ros_junk
+ module
.name
+ ".temp.exp";
778 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",
779 module
.GetBasePath ().c_str () );
781 GenerateMacrosAndTargetsTarget ( module
);
783 fprintf ( fMakefile
, "%s: %s %s\n",
785 archiveFilename
.c_str (),
786 importLibraryDependencies
.c_str () );
788 "\t${gcc} %s -Wl,--base-file,%s -o %s %s %s\n",
792 archiveFilename
.c_str (),
793 importLibraryDependencies
.c_str () );
798 "\t${dlltool} --dllname %s --base-file %s --def ntoskrnl/ntoskrnl.def --output-exp %s --kill-at\n",
801 //FixupTargetFilename ( module.GetBasePath () + SSEP + module.importLibrary->definition ).c_str (),
807 "\t${gcc} %s -Wl,%s -o %s %s %s\n",
811 archiveFilename
.c_str (),
812 importLibraryDependencies
.c_str () );
819 static MingwStaticLibraryModuleHandler staticlibrary_handler
;
821 MingwStaticLibraryModuleHandler::MingwStaticLibraryModuleHandler ()
822 : MingwModuleHandler ( StaticLibrary
)
827 MingwStaticLibraryModuleHandler::Process ( const Module
& module
)
829 GeneratePreconditionDependencies ( module
);
830 GenerateStaticLibraryModuleTarget ( module
);
831 GenerateInvocations ( module
);
835 MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget ( const Module
& module
)
837 GenerateMacrosAndTargetsTarget ( module
);
841 static MingwKernelModeDLLModuleHandler kernelmodedll_handler
;
843 MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler ()
844 : MingwModuleHandler ( KernelModeDLL
)
849 MingwKernelModeDLLModuleHandler::Process ( const Module
& module
)
851 GeneratePreconditionDependencies ( module
);
852 GenerateKernelModeDLLModuleTarget ( module
);
853 GenerateInvocations ( module
);
857 MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ( const Module
& module
)
859 static string
ros_junk ( "$(ROS_TEMPORARY)" );
860 string
target ( FixupTargetFilename ( module
.GetPath () ) );
861 string workingDirectory
= GetWorkingDirectory ( );
862 string archiveFilename
= GetModuleArchiveFilename ( module
);
863 string importLibraryDependencies
= GetImportLibraryDependencies ( module
);
865 if (module
.importLibrary
!= NULL
)
867 fprintf ( fMakefile
, "%s:\n",
868 module
.GetDependencyPath ().c_str () );
871 "\t${dlltool} --dllname %s --def %s --output-lib %s --kill-at\n\n",
872 module
.GetTargetName ().c_str (),
873 FixupTargetFilename ( module
.GetBasePath () + SSEP
+ module
.importLibrary
->definition
).c_str (),
874 FixupTargetFilename ( module
.GetDependencyPath () ).c_str () );
877 if (module
.files
.size () > 0)
879 GenerateMacrosAndTargetsTarget ( module
);
881 fprintf ( fMakefile
, "%s: %s %s\n",
883 archiveFilename
.c_str (),
884 importLibraryDependencies
.c_str () );
887 "\t${gcc} -Wl,--subsystem,native -Wl,--entry,_DriverEntry@8 -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll -o %s %s %s\n\n",
889 archiveFilename
.c_str (),
890 importLibraryDependencies
.c_str () );
894 fprintf ( fMakefile
, "%s:\n",
896 fprintf ( fMakefile
, ".PHONY: %s\n\n",
902 static MingwNativeDLLModuleHandler nativedll_handler
;
904 MingwNativeDLLModuleHandler::MingwNativeDLLModuleHandler ()
905 : MingwModuleHandler ( NativeDLL
)
910 MingwNativeDLLModuleHandler::Process ( const Module
& module
)
912 GeneratePreconditionDependencies ( module
);
913 GenerateNativeDLLModuleTarget ( module
);
914 GenerateInvocations ( module
);
918 MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ( const Module
& module
)
920 static string
ros_junk ( "$(ROS_TEMPORARY)" );
921 string
target ( FixupTargetFilename ( module
.GetPath () ) );
922 string workingDirectory
= GetWorkingDirectory ( );
923 string archiveFilename
= GetModuleArchiveFilename ( module
);
924 string importLibraryDependencies
= GetImportLibraryDependencies ( module
);
926 if (module
.importLibrary
!= NULL
)
928 fprintf ( fMakefile
, "%s:\n",
929 module
.GetDependencyPath ().c_str () );
932 "\t${dlltool} --dllname %s --def %s --output-lib %s --kill-at\n\n",
933 module
.GetTargetName ().c_str (),
934 FixupTargetFilename ( module
.GetBasePath () + SSEP
+ module
.importLibrary
->definition
).c_str (),
935 FixupTargetFilename ( module
.GetDependencyPath () ).c_str () );
938 if (module
.files
.size () > 0)
940 GenerateMacrosAndTargetsTarget ( module
);
942 fprintf ( fMakefile
, "%s: %s %s\n",
944 archiveFilename
.c_str (),
945 importLibraryDependencies
.c_str () );
948 "\t${gcc} -Wl,--subsystem,native -Wl,--entry,_DllMainCRTStartup@12 -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib -mdll -o %s %s %s\n\n",
950 archiveFilename
.c_str (),
951 importLibraryDependencies
.c_str () );
955 fprintf ( fMakefile
, "%s:\n\n",
957 fprintf ( fMakefile
, ".PHONY: %s\n\n",
963 static MingwWin32DLLModuleHandler win32dll_handler
;
965 MingwWin32DLLModuleHandler::MingwWin32DLLModuleHandler ()
966 : MingwModuleHandler ( Win32DLL
)
971 MingwWin32DLLModuleHandler::Process ( const Module
& module
)
973 GeneratePreconditionDependencies ( module
);
974 GenerateWin32DLLModuleTarget ( module
);
975 GenerateInvocations ( module
);
979 MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ( const Module
& module
)
981 static string
ros_junk ( "$(ROS_TEMPORARY)" );
982 string
target ( FixupTargetFilename ( module
.GetPath () ) );
983 string workingDirectory
= GetWorkingDirectory ( );
984 string archiveFilename
= GetModuleArchiveFilename ( module
);
985 string importLibraryDependencies
= GetImportLibraryDependencies ( module
);
987 if (module
.importLibrary
!= NULL
)
989 fprintf ( fMakefile
, "%s:\n",
990 module
.GetDependencyPath ().c_str () );
993 "\t${dlltool} --dllname %s --def %s --output-lib %s --kill-at\n\n",
994 module
.GetTargetName ().c_str (),
995 FixupTargetFilename ( module
.GetBasePath () + SSEP
+ module
.importLibrary
->definition
).c_str (),
996 FixupTargetFilename ( module
.GetDependencyPath () ).c_str () );
999 if (module
.files
.size () > 0)
1001 GenerateMacrosAndTargetsTarget ( module
);
1003 fprintf ( fMakefile
, "%s: %s %s\n",
1005 archiveFilename
.c_str (),
1006 importLibraryDependencies
.c_str () );
1008 fprintf ( fMakefile
,
1009 "\t${gcc} -Wl,--subsystem,console -Wl,--entry,_DllMain@12 -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib -mdll -o %s %s %s\n",
1011 archiveFilename
.c_str (),
1012 importLibraryDependencies
.c_str () );
1016 fprintf ( fMakefile
, "%s:\n\n",
1018 fprintf ( fMakefile
, ".PHONY: %s\n\n",