4 #include "../../rbuild.h"
6 #include "modulehandler.h"
11 #define CLEAN_FILE(f) clean_files.push_back ( f );
13 static string ros_temp
= "$(TEMPORARY)";
15 MingwModuleHandler::backend
= NULL
;
17 MingwModuleHandler::fMakefile
= NULL
;
19 MingwModuleHandler::use_pch
= false;
23 const string
& filename
,
24 const string
& prefix
)
26 if ( !prefix
.length() )
29 const char* pfilename
= filename
.c_str();
30 const char* p1
= strrchr ( pfilename
, '/' );
31 const char* p2
= strrchr ( pfilename
, '\\' );
36 out
+= string(pfilename
,p1
-pfilename
) + CSEP
;
39 out
+= prefix
+ pfilename
;
44 GetTargetMacro ( const Module
& module
, bool with_dollar
)
46 string
s ( module
.name
);
50 return ssprintf ( "$(%s)", s
.c_str() );
54 MingwModuleHandler::MingwModuleHandler (
55 const Module
& module_
)
61 MingwModuleHandler::~MingwModuleHandler()
66 MingwModuleHandler::SetBackend ( MingwBackend
* backend_
)
72 MingwModuleHandler::SetMakefile ( FILE* f
)
78 MingwModuleHandler::SetUsePch ( bool b
)
84 MingwModuleHandler::RemoveVariables ( string path
)
86 size_t i
= path
.find ( '$' );
87 if ( i
!= string::npos
)
89 size_t j
= path
.find ( ')', i
);
90 if ( j
!= string::npos
)
92 if ( j
+ 2 < path
.length () && path
[j
+ 1] == CSEP
)
93 return path
.substr ( j
+ 2);
95 return path
.substr ( j
+ 1);
102 MingwModuleHandler::PassThruCacheDirectory (
104 Directory
* directoryTree
)
106 string
directory ( GetDirectory ( RemoveVariables ( file
) ) );
107 string generatedFilesDirectory
= backend
->AddDirectoryTarget ( directory
,
109 if ( directory
.find ( generatedFilesDirectory
) != string::npos
)
110 /* This path already includes the generated files directory variable */
115 return generatedFilesDirectory
;
116 return generatedFilesDirectory
+ SSEP
+ file
;
120 /*static*/ Directory
*
121 MingwModuleHandler::GetTargetDirectoryTree (
122 const Module
& module
)
124 if ( module
.type
== StaticLibrary
)
125 return backend
->intermediateDirectory
;
126 return backend
->outputDirectory
;
130 MingwModuleHandler::GetTargetFilename (
131 const Module
& module
,
132 string_list
* pclean_files
)
134 string target
= PassThruCacheDirectory (
135 NormalizeFilename ( module
.GetPath () ),
136 GetTargetDirectoryTree ( module
) );
139 string_list
& clean_files
= *pclean_files
;
140 CLEAN_FILE ( target
);
146 MingwModuleHandler::GetImportLibraryFilename (
147 const Module
& module
,
148 string_list
* pclean_files
)
150 string target
= PassThruCacheDirectory (
151 NormalizeFilename ( module
.GetDependencyPath () ),
152 backend
->intermediateDirectory
);
155 string_list
& clean_files
= *pclean_files
;
156 CLEAN_FILE ( target
);
161 /*static*/ MingwModuleHandler
*
162 MingwModuleHandler::InstanciateHandler (
163 const Module
& module
,
164 MingwBackend
* backend
)
166 MingwModuleHandler
* handler
;
167 switch ( module
.type
)
170 handler
= new MingwBuildToolModuleHandler ( module
);
173 handler
= new MingwStaticLibraryModuleHandler ( module
);
176 handler
= new MingwObjectLibraryModuleHandler ( module
);
179 handler
= new MingwKernelModuleHandler ( module
);
182 handler
= new MingwNativeCUIModuleHandler ( module
);
185 handler
= new MingwWin32CUIModuleHandler ( module
);
188 handler
= new MingwWin32GUIModuleHandler ( module
);
191 handler
= new MingwKernelModeDLLModuleHandler ( module
);
194 handler
= new MingwNativeDLLModuleHandler ( module
);
197 handler
= new MingwWin32DLLModuleHandler ( module
);
199 case KernelModeDriver
:
200 handler
= new MingwKernelModeDriverModuleHandler ( module
);
203 handler
= new MingwBootLoaderModuleHandler ( module
);
206 handler
= new MingwBootSectorModuleHandler ( module
);
209 handler
= new MingwIsoModuleHandler ( module
);
212 handler
= new MingwLiveIsoModuleHandler ( module
);
215 handler
= new MingwTestModuleHandler ( module
);
218 handler
= new MingwRpcServerModuleHandler ( module
);
221 handler
= new MingwRpcClientModuleHandler ( module
);
224 throw UnknownModuleTypeException (
225 module
.node
.location
,
233 MingwModuleHandler::GetWorkingDirectory () const
239 MingwModuleHandler::GetBasename ( const string
& filename
) const
241 size_t index
= filename
.find_last_of ( '.' );
242 if ( index
!= string::npos
)
243 return filename
.substr ( 0, index
);
248 MingwModuleHandler::GetActualSourceFilename (
249 const string
& filename
) const
251 string extension
= GetExtension ( filename
);
252 if ( extension
== ".spec" || extension
== ".SPEC" )
254 string basename
= GetBasename ( filename
);
255 return PassThruCacheDirectory ( NormalizeFilename ( basename
+ ".stubs.c" ),
256 backend
->intermediateDirectory
);
258 else if ( extension
== ".idl" || extension
== ".IDL" )
260 string basename
= GetBasename ( filename
);
262 if ( module
.type
== RpcServer
)
263 newname
= basename
+ "_s.c";
265 newname
= basename
+ "_c.c";
266 return PassThruCacheDirectory ( NormalizeFilename ( newname
),
267 backend
->intermediateDirectory
);
274 MingwModuleHandler::GetModuleArchiveFilename () const
276 if ( module
.type
== StaticLibrary
)
277 return GetTargetFilename ( module
, NULL
);
278 return PassThruCacheDirectory ( ReplaceExtension (
279 NormalizeFilename ( module
.GetPath () ),
281 backend
->intermediateDirectory
);
285 MingwModuleHandler::IsGeneratedFile ( const File
& file
) const
287 string extension
= GetExtension ( file
.name
);
288 return ( extension
== ".spec" || extension
== ".SPEC" );
292 MingwModuleHandler::ReferenceObjects (
293 const Module
& module
)
295 if ( module
.type
== ObjectLibrary
)
297 if ( module
.type
== RpcServer
)
299 if ( module
.type
== RpcClient
)
305 MingwModuleHandler::GetImportLibraryDependency (
306 const Module
& importedModule
)
309 if ( ReferenceObjects ( importedModule
) )
310 dep
= GetTargetMacro ( importedModule
);
312 dep
= GetImportLibraryFilename ( importedModule
, NULL
);
317 MingwModuleHandler::GetTargets ( const Module
& dependencyModule
,
318 string_list
& targets
)
320 if ( dependencyModule
.invocations
.size () > 0 )
322 for ( size_t i
= 0; i
< dependencyModule
.invocations
.size (); i
++ )
324 Invoke
& invoke
= *dependencyModule
.invocations
[i
];
325 invoke
.GetTargets ( targets
);
329 targets
.push_back ( GetImportLibraryDependency ( dependencyModule
) );
333 MingwModuleHandler::GetModuleDependencies (
334 string_list
& dependencies
)
336 size_t iend
= module
.dependencies
.size ();
341 for ( size_t i
= 0; i
< iend
; i
++ )
343 const Dependency
& dependency
= *module
.dependencies
[i
];
344 const Module
& dependencyModule
= *dependency
.dependencyModule
;
345 GetTargets ( dependencyModule
,
348 GetDefinitionDependencies ( dependencies
);
352 MingwModuleHandler::GetSourceFilenames ( string_list
& list
,
353 bool includeGeneratedFiles
) const
357 const vector
<File
*>& files
= module
.non_if_data
.files
;
358 for ( i
= 0; i
< files
.size (); i
++ )
360 if ( includeGeneratedFiles
|| !files
[i
]->IsGeneratedFile () )
363 GetActualSourceFilename ( files
[i
]->name
) );
366 // intentionally make a copy so that we can append more work in
367 // the middle of processing without having to go recursive
368 vector
<If
*> v
= module
.non_if_data
.ifs
;
369 for ( i
= 0; i
< v
.size (); i
++ )
373 // check for sub-ifs to add to list
374 const vector
<If
*>& ifs
= rIf
.data
.ifs
;
375 for ( j
= 0; j
< ifs
.size (); j
++ )
376 v
.push_back ( ifs
[j
] );
377 const vector
<File
*>& files
= rIf
.data
.files
;
378 for ( j
= 0; j
< files
.size (); j
++ )
380 File
& file
= *files
[j
];
381 if ( includeGeneratedFiles
|| !file
.IsGeneratedFile () )
384 GetActualSourceFilename ( file
.name
) );
391 MingwModuleHandler::GetSourceFilenamesWithoutGeneratedFiles (
392 string_list
& list
) const
394 GetSourceFilenames ( list
, false );
398 MingwModuleHandler::GetObjectFilename (
399 const string
& sourceFilename
,
400 string_list
* pclean_files
) const
402 Directory
* directoryTree
;
405 string extension
= GetExtension ( sourceFilename
);
406 if ( extension
== ".rc" || extension
== ".RC" )
407 newExtension
= ".coff";
408 else if ( extension
== ".spec" || extension
== ".SPEC" )
409 newExtension
= ".stubs.o";
410 else if ( extension
== ".idl" || extension
== ".IDL" )
412 if ( module
.type
== RpcServer
)
413 newExtension
= "_s.o";
415 newExtension
= "_c.o";
420 if ( module
.type
== BootSector
)
421 directoryTree
= backend
->outputDirectory
;
423 directoryTree
= backend
->intermediateDirectory
;
425 string obj_file
= PassThruCacheDirectory (
426 NormalizeFilename ( ReplaceExtension (
427 RemoveVariables ( sourceFilename
),
432 string_list
& clean_files
= *pclean_files
;
433 CLEAN_FILE ( obj_file
);
439 MingwModuleHandler::GenerateCleanTarget () const
441 if ( 0 == clean_files
.size() )
443 fprintf ( fMakefile
, ".PHONY: %s_clean\n", module
.name
.c_str() );
444 fprintf ( fMakefile
, "%s_clean:\n\t-@${rm}", module
.name
.c_str() );
445 for ( size_t i
= 0; i
< clean_files
.size(); i
++ )
448 fprintf ( fMakefile
, " 2>$(NUL)\n\t-@${rm}" );
449 fprintf ( fMakefile
, " %s", clean_files
[i
].c_str() );
451 fprintf ( fMakefile
, " 2>$(NUL)\n" );
452 fprintf ( fMakefile
, "clean: %s_clean\n\n", module
.name
.c_str() );
456 MingwModuleHandler::GenerateInstallTarget () const
458 if ( module
.installName
.length () == 0 )
460 fprintf ( fMakefile
, ".PHONY: %s_install\n", module
.name
.c_str() );
461 fprintf ( fMakefile
, "%s_install:\n", module
.name
.c_str() );
462 string sourceFilename
= MingwModuleHandler::PassThruCacheDirectory (
463 NormalizeFilename ( module
.GetPath () ),
464 backend
->outputDirectory
);
465 string normalizedTargetFilename
= MingwModuleHandler::PassThruCacheDirectory (
466 NormalizeFilename ( module
.installBase
+ SSEP
+ module
.installName
),
467 backend
->installDirectory
);
471 "\t${cp} %s %s 1>$(NUL)\n",
472 sourceFilename
.c_str (),
473 normalizedTargetFilename
.c_str () );
477 MingwModuleHandler::GetObjectFilenames ()
479 const vector
<File
*>& files
= module
.non_if_data
.files
;
480 if ( files
.size () == 0 )
483 string
objectFilenames ( "" );
484 for ( size_t i
= 0; i
< files
.size (); i
++ )
486 if ( objectFilenames
.size () > 0 )
487 objectFilenames
+= " ";
489 GetObjectFilename ( files
[i
]->name
, NULL
);
491 return objectFilenames
;
495 MingwModuleHandler::GenerateGccDefineParametersFromVector (
496 const vector
<Define
*>& defines
)
499 for ( size_t i
= 0; i
< defines
.size (); i
++ )
501 Define
& define
= *defines
[i
];
502 if (parameters
.length () > 0)
505 parameters
+= define
.name
;
506 if (define
.value
.length () > 0)
509 parameters
+= define
.value
;
516 MingwModuleHandler::GenerateGccDefineParameters () const
518 string parameters
= GenerateGccDefineParametersFromVector ( module
.project
.non_if_data
.defines
);
519 string s
= GenerateGccDefineParametersFromVector ( module
.non_if_data
.defines
);
520 if ( s
.length () > 0 )
529 MingwModuleHandler::ConcatenatePaths (
531 const string
& path2
) const
533 if ( ( path1
.length () == 0 ) || ( path1
== "." ) || ( path1
== "./" ) )
535 if ( path1
[path1
.length ()] == CSEP
)
536 return path1
+ path2
;
538 return path1
+ CSEP
+ path2
;
542 MingwModuleHandler::GenerateGccIncludeParametersFromVector ( const vector
<Include
*>& includes
)
545 for ( size_t i
= 0; i
< includes
.size (); i
++ )
547 Include
& include
= *includes
[i
];
548 if ( parameters
.length () > 0 )
550 parameters
+= "-I" + include
.directory
;
556 MingwModuleHandler::GenerateGccIncludeParameters () const
558 string parameters
= GenerateGccIncludeParametersFromVector ( module
.non_if_data
.includes
);
559 string s
= GenerateGccIncludeParametersFromVector ( module
.project
.non_if_data
.includes
);
560 if ( s
.length () > 0 )
569 MingwModuleHandler::GenerateCompilerParametersFromVector ( const vector
<CompilerFlag
*>& compilerFlags
) const
572 for ( size_t i
= 0; i
< compilerFlags
.size (); i
++ )
574 CompilerFlag
& compilerFlag
= *compilerFlags
[i
];
575 if ( parameters
.length () > 0 )
577 parameters
+= compilerFlag
.flag
;
583 MingwModuleHandler::GenerateLinkerParametersFromVector ( const vector
<LinkerFlag
*>& linkerFlags
) const
586 for ( size_t i
= 0; i
< linkerFlags
.size (); i
++ )
588 LinkerFlag
& linkerFlag
= *linkerFlags
[i
];
589 if ( parameters
.length () > 0 )
591 parameters
+= linkerFlag
.flag
;
597 MingwModuleHandler::GenerateImportLibraryDependenciesFromVector (
598 const vector
<Library
*>& libraries
)
600 string
dependencies ( "" );
602 for ( size_t i
= 0; i
< libraries
.size (); i
++ )
604 if ( wrap_count
++ == 5 )
605 dependencies
+= " \\\n\t\t", wrap_count
= 0;
606 else if ( dependencies
.size () > 0 )
608 dependencies
+= GetImportLibraryDependency ( *libraries
[i
]->imported_module
);
614 MingwModuleHandler::GenerateLinkerParameters () const
616 return GenerateLinkerParametersFromVector ( module
.linkerFlags
);
620 MingwModuleHandler::GenerateMacro (
621 const char* assignmentOperation
,
623 const IfableData
& data
)
631 assignmentOperation
);
633 string compilerParameters
= GenerateCompilerParametersFromVector ( data
.compilerFlags
);
634 if ( compilerParameters
.size () > 0 )
639 compilerParameters
.c_str () );
642 for ( i
= 0; i
< data
.includes
.size(); i
++ )
647 data
.includes
[i
]->directory
.c_str() );
649 for ( i
= 0; i
< data
.defines
.size(); i
++ )
651 Define
& d
= *data
.defines
[i
];
656 if ( d
.value
.size() )
662 fprintf ( fMakefile
, "\n" );
666 MingwModuleHandler::GenerateMacros (
667 const char* assignmentOperation
,
668 const IfableData
& data
,
669 const vector
<LinkerFlag
*>* linkerFlags
)
673 if ( data
.includes
.size () > 0 || data
.defines
.size () > 0 || data
.compilerFlags
.size () > 0 )
675 GenerateMacro ( assignmentOperation
,
678 GenerateMacro ( assignmentOperation
,
683 if ( linkerFlags
!= NULL
)
685 string linkerParameters
= GenerateLinkerParametersFromVector ( *linkerFlags
);
686 if ( linkerParameters
.size () > 0 )
691 linkerflagsMacro
.c_str (),
693 linkerParameters
.c_str() );
697 if ( data
.libraries
.size () > 0 )
699 string deps
= GenerateImportLibraryDependenciesFromVector ( data
.libraries
);
700 if ( deps
.size () > 0 )
711 const vector
<If
*>& ifs
= data
.ifs
;
712 for ( i
= 0; i
< ifs
.size(); i
++ )
715 if ( rIf
.data
.defines
.size()
716 || rIf
.data
.includes
.size()
717 || rIf
.data
.libraries
.size()
718 || rIf
.data
.files
.size()
719 || rIf
.data
.compilerFlags
.size()
720 || rIf
.data
.ifs
.size() )
724 "ifeq (\"$(%s)\",\"%s\")\n",
725 rIf
.property
.c_str(),
739 MingwModuleHandler::CleanupFileVector ( vector
<File
*>& sourceFiles
)
741 for (size_t i
= 0; i
< sourceFiles
.size (); i
++)
742 delete sourceFiles
[i
];
746 MingwModuleHandler::GetModuleSpecificSourceFiles ( vector
<File
*>& sourceFiles
)
751 MingwModuleHandler::GenerateObjectMacros (
752 const char* assignmentOperation
,
753 const IfableData
& data
,
754 const vector
<LinkerFlag
*>* linkerFlags
)
758 const vector
<File
*>& files
= data
.files
;
759 if ( files
.size () > 0 )
761 for ( i
= 0; i
< files
.size (); i
++ )
763 File
& file
= *files
[i
];
768 objectsMacro
.c_str(),
770 file
.name
, NULL
).c_str (),
771 objectsMacro
.c_str() );
777 objectsMacro
.c_str (),
778 assignmentOperation
);
779 for ( i
= 0; i
< files
.size(); i
++ )
781 File
& file
= *files
[i
];
787 ( i
%10 == 9 ? " \\\n\t" : " " ),
789 file
.name
, NULL
).c_str () );
792 fprintf ( fMakefile
, "\n" );
795 const vector
<If
*>& ifs
= data
.ifs
;
796 for ( i
= 0; i
< ifs
.size(); i
++ )
799 if ( rIf
.data
.defines
.size()
800 || rIf
.data
.includes
.size()
801 || rIf
.data
.libraries
.size()
802 || rIf
.data
.files
.size()
803 || rIf
.data
.compilerFlags
.size()
804 || rIf
.data
.ifs
.size() )
808 "ifeq (\"$(%s)\",\"%s\")\n",
809 rIf
.property
.c_str(),
811 GenerateObjectMacros (
821 vector
<File
*> sourceFiles
;
822 GetModuleSpecificSourceFiles ( sourceFiles
);
823 for ( i
= 0; i
< sourceFiles
.size (); i
++ )
828 objectsMacro
.c_str(),
830 sourceFiles
[i
]->name
, NULL
).c_str () );
832 CleanupFileVector ( sourceFiles
);
836 MingwModuleHandler::GenerateGccCommand (
837 const string
& sourceFilename
,
839 const string
& cflagsMacro
)
841 string dependencies
= sourceFilename
;
842 if ( module
.pch
&& use_pch
)
843 dependencies
+= " " + module
.pch
->file
.name
+ ".gch";
845 /* WIDL generated headers may be used */
846 dependencies
+= " " + GetLinkingDependenciesMacro ();
847 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
849 string objectFilename
= GetObjectFilename (
850 sourceFilename
, &clean_files
);
853 objectFilename
.c_str (),
854 dependencies
.c_str (),
855 GetDirectory ( objectFilename
).c_str () );
856 fprintf ( fMakefile
, "\t$(ECHO_CC)\n" );
858 "\t%s -c $< -o $@ %s\n",
860 cflagsMacro
.c_str () );
864 MingwModuleHandler::GenerateGccAssemblerCommand (
865 const string
& sourceFilename
,
867 const string
& cflagsMacro
)
869 string dependencies
= sourceFilename
;
870 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
871 string objectFilename
= GetObjectFilename (
872 sourceFilename
, &clean_files
);
875 objectFilename
.c_str (),
876 dependencies
.c_str (),
877 GetDirectory ( objectFilename
).c_str () );
878 fprintf ( fMakefile
, "\t$(ECHO_GAS)\n" );
880 "\t%s -x assembler-with-cpp -c $< -o $@ -D__ASM__ %s\n",
882 cflagsMacro
.c_str () );
886 MingwModuleHandler::GenerateNasmCommand (
887 const string
& sourceFilename
,
888 const string
& nasmflagsMacro
)
890 string dependencies
= sourceFilename
;
891 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
892 string objectFilename
= GetObjectFilename (
893 sourceFilename
, &clean_files
);
896 objectFilename
.c_str (),
897 dependencies
.c_str (),
898 GetDirectory ( objectFilename
).c_str () );
899 fprintf ( fMakefile
, "\t$(ECHO_NASM)\n" );
901 "\t%s -f win32 $< -o $@ %s\n",
903 nasmflagsMacro
.c_str () );
907 MingwModuleHandler::GenerateWindresCommand (
908 const string
& sourceFilename
,
909 const string
& windresflagsMacro
)
911 string dependencies
= sourceFilename
;
912 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
913 string objectFilename
=
914 GetObjectFilename ( sourceFilename
, &clean_files
);
915 string sourceFilenamePart
= ReplaceExtension ( GetFilename ( sourceFilename
), "" );
916 string rciFilename
= ros_temp
+ module
.name
+ "." + sourceFilenamePart
+ ".rci.tmp";
917 string resFilename
= ros_temp
+ module
.name
+ "." + sourceFilenamePart
+ ".res.tmp";
921 "%s: %s $(WRC_TARGET) | %s\n",
922 objectFilename
.c_str (),
923 dependencies
.c_str (),
924 GetDirectory ( objectFilename
).c_str () );
925 fprintf ( fMakefile
, "\t$(ECHO_WRC)\n" );
927 "\t${gcc} -xc -E -DRC_INVOKED ${%s} %s > %s\n",
928 windresflagsMacro
.c_str (),
929 sourceFilename
.c_str (),
930 rciFilename
.c_str () );
932 "\t$(Q)$(WRC_TARGET) ${%s} %s %s\n",
933 windresflagsMacro
.c_str (),
934 rciFilename
.c_str (),
935 resFilename
.c_str () );
937 "\t-@${rm} %s 2>$(NUL)\n",
938 rciFilename
.c_str () );
940 "\t${windres} %s -o $@\n",
941 resFilename
.c_str () );
943 "\t-@${rm} %s 2>$(NUL)\n",
944 resFilename
.c_str () );
949 "%s: %s $(WRC_TARGET) | %s\n",
950 objectFilename
.c_str (),
951 dependencies
.c_str (),
952 GetDirectory ( objectFilename
).c_str () );
953 fprintf ( fMakefile
, "\t$(ECHO_WRC)\n" );
955 "\t${windres} $(%s) %s -o $@\n",
956 windresflagsMacro
.c_str (),
957 sourceFilename
.c_str () );
962 MingwModuleHandler::GenerateWinebuildCommands (
963 const string
& sourceFilename
)
965 string dependencies
= sourceFilename
;
966 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
968 string basename
= GetBasename ( sourceFilename
);
969 string def_file
= PassThruCacheDirectory (
970 basename
+ ".spec.def",
971 backend
->intermediateDirectory
);
972 CLEAN_FILE(def_file
);
974 string stub_file
= PassThruCacheDirectory (
975 basename
+ ".stubs.c",
976 backend
->intermediateDirectory
);
977 CLEAN_FILE(stub_file
)
980 "%s: %s $(WINEBUILD_TARGET)\n",
982 dependencies
.c_str () );
983 fprintf ( fMakefile
, "\t$(ECHO_WINEBLD)\n" );
985 "\t%s -o %s --def -E %s\n",
986 "$(Q)$(WINEBUILD_TARGET)",
988 sourceFilename
.c_str () );
990 "%s: %s $(WINEBUILD_TARGET)\n",
992 sourceFilename
.c_str () );
993 fprintf ( fMakefile
, "\t$(ECHO_WINEBLD)\n" );
995 "\t%s -o %s --pedll %s\n",
996 "$(Q)$(WINEBUILD_TARGET)",
998 sourceFilename
.c_str () );
1002 MingwModuleHandler::GetWidlFlags ( const File
& file
)
1004 return file
.switches
;
1008 MingwModuleHandler::GetRpcServerHeaderFilename ( string basename
) const
1010 return basename
+ "_s.h";
1014 MingwModuleHandler::GenerateWidlCommandsServer (
1016 const string
& widlflagsMacro
)
1018 string dependencies
= file
.name
;
1019 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
1021 string basename
= GetBasename ( file
.name
);
1023 /*string generatedHeaderFilename = PassThruCacheDirectory (
1025 backend->intermediateDirectory );
1026 CLEAN_FILE(generatedHeaderFilename);
1028 string generatedHeaderFilename
= GetRpcServerHeaderFilename ( basename
);
1029 CLEAN_FILE(generatedHeaderFilename
);
1031 string generatedServerFilename
= PassThruCacheDirectory (
1033 backend
->intermediateDirectory
);
1034 CLEAN_FILE(generatedServerFilename
);
1036 fprintf ( fMakefile
,
1037 "%s %s: %s $(WIDL_TARGET) | %s\n",
1038 generatedServerFilename
.c_str (),
1039 generatedHeaderFilename
.c_str (),
1040 dependencies
.c_str (),
1041 GetDirectory ( generatedServerFilename
).c_str () );
1042 fprintf ( fMakefile
, "\t$(ECHO_WIDL)\n" );
1043 fprintf ( fMakefile
,
1044 "\t%s %s %s -h -H %s -s -S %s %s\n",
1045 "$(Q)$(WIDL_TARGET)",
1046 GetWidlFlags ( file
).c_str (),
1047 widlflagsMacro
.c_str (),
1048 generatedHeaderFilename
.c_str (),
1049 generatedServerFilename
.c_str (),
1050 file
.name
.c_str () );
1054 MingwModuleHandler::GetRpcClientHeaderFilename ( string basename
) const
1056 return basename
+ "_c.h";
1060 MingwModuleHandler::GenerateWidlCommandsClient (
1062 const string
& widlflagsMacro
)
1064 string dependencies
= file
.name
;
1065 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
1067 string basename
= GetBasename ( file
.name
);
1069 /*string generatedHeaderFilename = PassThruCacheDirectory (
1071 backend->intermediateDirectory );
1072 CLEAN_FILE(generatedHeaderFilename);
1074 string generatedHeaderFilename
= GetRpcClientHeaderFilename ( basename
);
1075 CLEAN_FILE(generatedHeaderFilename
);
1077 string generatedClientFilename
= PassThruCacheDirectory (
1079 backend
->intermediateDirectory
);
1080 CLEAN_FILE(generatedClientFilename
);
1082 fprintf ( fMakefile
,
1083 "%s %s: %s $(WIDL_TARGET) | %s\n",
1084 generatedClientFilename
.c_str (),
1085 generatedHeaderFilename
.c_str (),
1086 dependencies
.c_str (),
1087 GetDirectory ( generatedClientFilename
).c_str () );
1088 fprintf ( fMakefile
, "\t$(ECHO_WIDL)\n" );
1089 fprintf ( fMakefile
,
1090 "\t%s %s %s -h -H %s -c -C %s %s\n",
1091 "$(Q)$(WIDL_TARGET)",
1092 GetWidlFlags ( file
).c_str (),
1093 widlflagsMacro
.c_str (),
1094 generatedHeaderFilename
.c_str (),
1095 generatedClientFilename
.c_str (),
1096 file
.name
.c_str () );
1100 MingwModuleHandler::GenerateWidlCommands (
1102 const string
& widlflagsMacro
)
1104 if ( module
.type
== RpcServer
)
1105 GenerateWidlCommandsServer ( file
,
1108 GenerateWidlCommandsClient ( file
,
1113 MingwModuleHandler::GenerateCommands (
1117 const string
& cflagsMacro
,
1118 const string
& nasmflagsMacro
,
1119 const string
& windresflagsMacro
,
1120 const string
& widlflagsMacro
)
1122 string extension
= GetExtension ( file
.name
);
1123 if ( extension
== ".c" || extension
== ".C" )
1125 GenerateGccCommand ( file
.name
,
1130 else if ( extension
== ".cc" || extension
== ".CC" ||
1131 extension
== ".cpp" || extension
== ".CPP" ||
1132 extension
== ".cxx" || extension
== ".CXX" )
1134 GenerateGccCommand ( file
.name
,
1139 else if ( extension
== ".s" || extension
== ".S" )
1141 GenerateGccAssemblerCommand ( file
.name
,
1146 else if ( extension
== ".asm" || extension
== ".ASM" )
1148 GenerateNasmCommand ( file
.name
,
1152 else if ( extension
== ".rc" || extension
== ".RC" )
1154 GenerateWindresCommand ( file
.name
,
1155 windresflagsMacro
);
1158 else if ( extension
== ".spec" || extension
== ".SPEC" )
1160 GenerateWinebuildCommands ( file
.name
);
1161 GenerateGccCommand ( GetActualSourceFilename ( file
.name
),
1166 else if ( extension
== ".idl" || extension
== ".IDL" )
1168 GenerateWidlCommands ( file
,
1170 GenerateGccCommand ( GetActualSourceFilename ( file
.name
),
1176 throw InvalidOperationException ( __FILE__
,
1178 "Unsupported filename extension '%s' in file '%s'",
1180 file
.name
.c_str () );
1184 MingwModuleHandler::GenerateBuildMapCode ()
1186 fprintf ( fMakefile
,
1187 "ifeq ($(ROS_BUILDMAP),full)\n" );
1189 string mapFilename
= PassThruCacheDirectory (
1190 GetBasename ( module
.GetPath () ) + ".map",
1191 backend
->outputDirectory
);
1192 CLEAN_FILE ( mapFilename
);
1194 fprintf ( fMakefile
,
1195 "\t$(ECHO_OBJDUMP)\n" );
1196 fprintf ( fMakefile
,
1197 "\t$(Q)${objdump} -d -S $@ > %s\n",
1198 mapFilename
.c_str () );
1200 fprintf ( fMakefile
,
1202 fprintf ( fMakefile
,
1203 "ifeq ($(ROS_BUILDMAP),yes)\n" );
1205 fprintf ( fMakefile
,
1207 fprintf ( fMakefile
,
1208 "\t$(Q)${nm} --numeric-sort $@ > %s\n",
1209 mapFilename
.c_str () );
1211 fprintf ( fMakefile
,
1214 fprintf ( fMakefile
,
1219 MingwModuleHandler::GenerateBuildNonSymbolStrippedCode ()
1221 fprintf ( fMakefile
,
1222 "ifeq ($(ROS_BUILDNOSTRIP),yes)\n" );
1224 string filename
= module
.GetPath ();
1225 string outputFilename
= PassThruCacheDirectory (
1227 backend
->outputDirectory
);
1228 string nostripFilename
= PassThruCacheDirectory (
1229 GetBasename ( filename
) + ".nostrip" + GetExtension ( filename
),
1230 backend
->outputDirectory
);
1231 CLEAN_FILE ( nostripFilename
);
1233 fprintf ( fMakefile
,
1235 fprintf ( fMakefile
,
1236 "\t${cp} %s %s 1>$(NUL)\n",
1237 outputFilename
.c_str (),
1238 nostripFilename
.c_str () );
1240 fprintf ( fMakefile
,
1245 MergeStringVector ( const vector
<string
>& input
,
1246 vector
<string
>& output
)
1250 int wrap_count
= -1;
1251 for ( size_t i
= 0; i
< input
.size (); i
++ )
1253 if ( input
[i
].size () == 0 )
1255 if ( wrap_count
++ == wrap_at
)
1257 output
.push_back ( s
);
1261 else if ( s
.size () > 0)
1265 if ( s
.length () > 0 )
1266 output
.push_back ( s
);
1270 MingwModuleHandler::GetObjectsVector ( const IfableData
& data
,
1271 vector
<string
>& objectFiles
) const
1273 for ( size_t i
= 0; i
< data
.files
.size (); i
++ )
1275 File
& file
= *data
.files
[i
];
1276 objectFiles
.push_back ( GetObjectFilename ( file
.name
, NULL
) );
1281 MingwModuleHandler::GenerateCleanObjectsAsYouGoCode () const
1283 if ( backend
->configuration
.CleanAsYouGo
)
1285 vector
<string
> objectFiles
;
1286 GetObjectsVector ( module
.non_if_data
,
1288 vector
<string
> lines
;
1289 MergeStringVector ( objectFiles
,
1291 for ( size_t i
= 0; i
< lines
.size (); i
++ )
1293 fprintf ( fMakefile
,
1294 "\t-@${rm} %s 2>$(NUL)\n",
1295 lines
[i
].c_str () );
1301 MingwModuleHandler::GenerateRunRsymCode () const
1303 fprintf ( fMakefile
,
1304 "\t$(ECHO_RSYM)\n" );
1305 fprintf ( fMakefile
,
1306 "\t$(Q)$(RSYM_TARGET) $@ $@\n\n" );
1310 MingwModuleHandler::GenerateLinkerCommand (
1311 const string
& dependencies
,
1312 const string
& linker
,
1313 const string
& linkerParameters
,
1314 const string
& objectsMacro
,
1315 const string
& libsMacro
)
1317 string
target ( GetTargetMacro ( module
) );
1318 string
target_folder ( GetDirectory ( GetTargetFilename ( module
, NULL
) ) );
1319 string def_file
= GetDefinitionFilename ();
1321 fprintf ( fMakefile
,
1322 "%s: %s %s $(RSYM_TARGET) | %s\n",
1325 dependencies
.c_str (),
1326 target_folder
.c_str () );
1327 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
1328 string
targetName ( module
.GetTargetName () );
1330 if ( module
.IsDLL () )
1332 string base_tmp
= ros_temp
+ module
.name
+ ".base.tmp";
1333 CLEAN_FILE ( base_tmp
);
1334 string junk_tmp
= ros_temp
+ module
.name
+ ".junk.tmp";
1335 CLEAN_FILE ( junk_tmp
);
1336 string temp_exp
= ros_temp
+ module
.name
+ ".temp.exp";
1337 CLEAN_FILE ( temp_exp
);
1339 fprintf ( fMakefile
,
1340 "\t%s %s -Wl,--base-file,%s -o %s %s %s %s\n",
1342 linkerParameters
.c_str (),
1345 objectsMacro
.c_str (),
1347 GetLinkerMacro ().c_str () );
1349 fprintf ( fMakefile
,
1350 "\t-@${rm} %s 2>$(NUL)\n",
1351 junk_tmp
.c_str () );
1353 string killAt
= module
.mangledSymbols
? "" : "--kill-at";
1354 fprintf ( fMakefile
,
1355 "\t${dlltool} --dllname %s --base-file %s --def %s --output-exp %s %s\n",
1356 targetName
.c_str (),
1362 fprintf ( fMakefile
,
1363 "\t-@${rm} %s 2>$(NUL)\n",
1364 base_tmp
.c_str () );
1366 fprintf ( fMakefile
,
1367 "\t%s %s %s -o %s %s %s %s\n",
1369 linkerParameters
.c_str (),
1372 objectsMacro
.c_str (),
1374 GetLinkerMacro ().c_str () );
1376 fprintf ( fMakefile
,
1377 "\t-@${rm} %s 2>$(NUL)\n",
1378 temp_exp
.c_str () );
1382 fprintf ( fMakefile
,
1383 "\t%s %s -o %s %s %s %s\n",
1385 linkerParameters
.c_str (),
1387 objectsMacro
.c_str (),
1389 GetLinkerMacro ().c_str () );
1392 GenerateBuildMapCode ();
1393 GenerateBuildNonSymbolStrippedCode ();
1394 GenerateRunRsymCode ();
1395 GenerateCleanObjectsAsYouGoCode ();
1399 MingwModuleHandler::GeneratePhonyTarget() const
1401 string
targetMacro ( GetTargetMacro ( module
) );
1402 fprintf ( fMakefile
,
1404 targetMacro
.c_str ());
1405 fprintf ( fMakefile
, "%s: | %s\n",
1406 targetMacro
.c_str (),
1407 GetDirectory ( GetTargetFilename ( module
, NULL
) ).c_str () );
1411 MingwModuleHandler::GenerateObjectFileTargets (
1412 const IfableData
& data
,
1415 const string
& cflagsMacro
,
1416 const string
& nasmflagsMacro
,
1417 const string
& windresflagsMacro
,
1418 const string
& widlflagsMacro
)
1422 const vector
<File
*>& files
= data
.files
;
1423 for ( i
= 0; i
< files
.size (); i
++ )
1425 GenerateCommands ( *files
[i
],
1432 fprintf ( fMakefile
,
1436 const vector
<If
*>& ifs
= data
.ifs
;
1437 for ( i
= 0; i
< ifs
.size(); i
++ )
1439 GenerateObjectFileTargets ( ifs
[i
]->data
,
1448 vector
<File
*> sourceFiles
;
1449 GetModuleSpecificSourceFiles ( sourceFiles
);
1450 for ( i
= 0; i
< sourceFiles
.size (); i
++ )
1452 GenerateCommands ( *sourceFiles
[i
],
1460 CleanupFileVector ( sourceFiles
);
1464 MingwModuleHandler::GenerateObjectFileTargets (
1467 const string
& cflagsMacro
,
1468 const string
& nasmflagsMacro
,
1469 const string
& windresflagsMacro
,
1470 const string
& widlflagsMacro
)
1474 const string
& pch_file
= module
.pch
->file
.name
;
1475 string gch_file
= pch_file
+ ".gch";
1476 CLEAN_FILE(gch_file
);
1484 fprintf ( fMakefile
, "\t$(ECHO_PCH)\n" );
1487 "\t%s -o %s %s -g %s\n\n",
1488 ( module
.cplusplus
? cppc
.c_str() : cc
.c_str() ),
1490 cflagsMacro
.c_str(),
1495 GenerateObjectFileTargets ( module
.non_if_data
,
1502 fprintf ( fMakefile
, "\n" );
1506 MingwModuleHandler::GenerateArchiveTarget ( const string
& ar
,
1507 const string
& objs_macro
) const
1509 string
archiveFilename ( GetModuleArchiveFilename () );
1511 fprintf ( fMakefile
,
1513 archiveFilename
.c_str (),
1514 objs_macro
.c_str (),
1515 GetDirectory(archiveFilename
).c_str() );
1517 fprintf ( fMakefile
, "\t$(ECHO_AR)\n" );
1519 fprintf ( fMakefile
,
1522 objs_macro
.c_str ());
1524 GenerateCleanObjectsAsYouGoCode ();
1526 fprintf ( fMakefile
, "\n" );
1528 return archiveFilename
;
1532 MingwModuleHandler::GetCFlagsMacro () const
1534 return ssprintf ( "$(%s_CFLAGS)",
1535 module
.name
.c_str () );
1539 MingwModuleHandler::GetObjectsMacro ( const Module
& module
)
1541 return ssprintf ( "$(%s_OBJS)",
1542 module
.name
.c_str () );
1546 MingwModuleHandler::GetLinkingDependenciesMacro () const
1548 return ssprintf ( "$(%s_LINKDEPS)", module
.name
.c_str () );
1552 MingwModuleHandler::GetLibsMacro () const
1554 return ssprintf ( "$(%s_LIBS)", module
.name
.c_str () );
1558 MingwModuleHandler::GetLinkerMacro () const
1560 return ssprintf ( "$(%s_LFLAGS)",
1561 module
.name
.c_str () );
1565 MingwModuleHandler::GetModuleTargets ( const Module
& module
)
1567 if ( ReferenceObjects ( module
) )
1568 return GetObjectsMacro ( module
);
1570 return GetTargetFilename ( module
, NULL
);
1574 MingwModuleHandler::GenerateObjectMacro ()
1576 objectsMacro
= ssprintf ("%s_OBJS", module
.name
.c_str ());
1578 GenerateObjectMacros (
1581 &module
.linkerFlags
);
1583 // future references to the macro will be to get its values
1584 objectsMacro
= ssprintf ("$(%s)", objectsMacro
.c_str ());
1588 MingwModuleHandler::GenerateTargetMacro ()
1590 fprintf ( fMakefile
,
1592 GetTargetMacro ( module
, false ).c_str (),
1593 GetModuleTargets ( module
).c_str () );
1597 MingwModuleHandler::GetRpcHeaderDependencies (
1598 string_list
& dependencies
) const
1600 for ( size_t i
= 0; i
< module
.non_if_data
.libraries
.size (); i
++ )
1602 Library
& library
= *module
.non_if_data
.libraries
[i
];
1603 if ( library
.imported_module
->type
== RpcServer
||
1604 library
.imported_module
->type
== RpcClient
)
1607 for ( size_t j
= 0; j
< library
.imported_module
->non_if_data
.files
.size (); j
++ )
1609 File
& file
= *library
.imported_module
->non_if_data
.files
[j
];
1610 string extension
= GetExtension ( file
.name
);
1611 if ( extension
== ".idl" || extension
== ".IDL" )
1613 string basename
= GetBasename ( file
.name
);
1614 if ( library
.imported_module
->type
== RpcServer
)
1615 dependencies
.push_back ( GetRpcServerHeaderFilename ( basename
) );
1616 if ( library
.imported_module
->type
== RpcClient
)
1617 dependencies
.push_back ( GetRpcClientHeaderFilename ( basename
) );
1625 MingwModuleHandler::GenerateOtherMacros ()
1627 cflagsMacro
= ssprintf ("%s_CFLAGS", module
.name
.c_str ());
1628 nasmflagsMacro
= ssprintf ("%s_NASMFLAGS", module
.name
.c_str ());
1629 windresflagsMacro
= ssprintf ("%s_RCFLAGS", module
.name
.c_str ());
1630 widlflagsMacro
= ssprintf ("%s_WIDLFLAGS", module
.name
.c_str ());
1631 linkerflagsMacro
= ssprintf ("%s_LFLAGS", module
.name
.c_str ());
1632 libsMacro
= ssprintf("%s_LIBS", module
.name
.c_str ());
1633 linkDepsMacro
= ssprintf ("%s_LINKDEPS", module
.name
.c_str ());
1638 &module
.linkerFlags
);
1641 if ( module
.importLibrary
)
1643 const vector
<File
*>& files
= module
.non_if_data
.files
;
1644 for ( size_t i
= 0; i
< files
.size (); i
++ )
1646 File
& file
= *files
[i
];
1647 string extension
= GetExtension ( file
.name
);
1648 if ( extension
== ".spec" || extension
== ".SPEC" )
1649 GetSpecObjectDependencies ( s
, file
.name
);
1652 GetRpcHeaderDependencies ( s
);
1653 if ( s
.size () > 0 )
1658 linkDepsMacro
.c_str() );
1659 for ( size_t i
= 0; i
< s
.size(); i
++ )
1660 fprintf ( fMakefile
,
1663 fprintf ( fMakefile
, "\n" );
1666 string globalCflags
= "-g";
1667 if ( backend
->usePipe
)
1668 globalCflags
+= " -pipe";
1669 if ( !module
.enableWarnings
)
1670 globalCflags
+= " -Werror";
1674 "%s += $(PROJECT_CFLAGS) %s\n",
1675 cflagsMacro
.c_str (),
1676 globalCflags
.c_str () );
1680 "%s += $(PROJECT_RCFLAGS)\n",
1681 windresflagsMacro
.c_str () );
1685 "%s += $(PROJECT_WIDLFLAGS)\n",
1686 widlflagsMacro
.c_str () );
1690 "%s_LFLAGS += $(PROJECT_LFLAGS) -g\n",
1691 module
.name
.c_str () );
1696 linkDepsMacro
.c_str (),
1697 libsMacro
.c_str () );
1699 string cflags
= TypeSpecificCFlags();
1700 if ( cflags
.size() > 0 )
1702 fprintf ( fMakefile
,
1704 cflagsMacro
.c_str (),
1708 string nasmflags
= TypeSpecificNasmFlags();
1709 if ( nasmflags
.size () > 0 )
1711 fprintf ( fMakefile
,
1713 nasmflagsMacro
.c_str (),
1714 nasmflags
.c_str () );
1717 string linkerflags
= TypeSpecificLinkerFlags();
1718 if ( linkerflags
.size() > 0 )
1720 fprintf ( fMakefile
,
1722 linkerflagsMacro
.c_str (),
1723 linkerflags
.c_str () );
1726 fprintf ( fMakefile
, "\n\n" );
1728 // future references to the macros will be to get their values
1729 cflagsMacro
= ssprintf ("$(%s)", cflagsMacro
.c_str ());
1730 nasmflagsMacro
= ssprintf ("$(%s)", nasmflagsMacro
.c_str ());
1731 widlflagsMacro
= ssprintf ("$(%s)", widlflagsMacro
.c_str ());
1735 MingwModuleHandler::GenerateRules ()
1737 string cc
= ( module
.host
== HostTrue
? "${host_gcc}" : "${gcc}" );
1738 string cppc
= ( module
.host
== HostTrue
? "${host_gpp}" : "${gpp}" );
1739 string ar
= ( module
.host
== HostTrue
? "${host_ar}" : "${ar}" );
1741 string targetMacro
= GetTargetMacro ( module
);
1743 CLEAN_FILE ( targetMacro
);
1745 // generate phony target for module name
1746 fprintf ( fMakefile
, ".PHONY: %s\n",
1747 module
.name
.c_str () );
1748 string dependencies
= GetTargetMacro ( module
);
1749 if ( module
.type
== Test
)
1750 dependencies
+= " $(REGTESTS_RUN_TARGET)";
1751 fprintf ( fMakefile
, "%s: %s\n\n",
1752 module
.name
.c_str (),
1753 dependencies
.c_str () );
1754 if ( module
.type
== Test
)
1756 fprintf ( fMakefile
,
1758 targetMacro
.c_str ());
1761 if ( !ReferenceObjects ( module
) )
1763 string
ar_target ( GenerateArchiveTarget ( ar
, objectsMacro
) );
1764 if ( targetMacro
!= ar_target
)
1765 CLEAN_FILE ( ar_target
);
1768 GenerateObjectFileTargets ( cc
,
1777 MingwModuleHandler::GetInvocationDependencies (
1778 const Module
& module
,
1779 string_list
& dependencies
)
1781 for ( size_t i
= 0; i
< module
.invocations
.size (); i
++ )
1783 Invoke
& invoke
= *module
.invocations
[i
];
1784 if ( invoke
.invokeModule
== &module
)
1785 /* Protect against circular dependencies */
1787 invoke
.GetTargets ( dependencies
);
1792 MingwModuleHandler::GenerateInvocations () const
1794 if ( module
.invocations
.size () == 0 )
1797 size_t iend
= module
.invocations
.size ();
1798 for ( size_t i
= 0; i
< iend
; i
++ )
1800 const Invoke
& invoke
= *module
.invocations
[i
];
1802 if ( invoke
.invokeModule
->type
!= BuildTool
)
1804 throw InvalidBuildFileException ( module
.node
.location
,
1805 "Only modules of type buildtool can be invoked." );
1808 string invokeTarget
= module
.GetInvocationTarget ( i
);
1809 string_list invoke_targets
;
1810 assert ( invoke_targets
.size() );
1811 invoke
.GetTargets ( invoke_targets
);
1812 fprintf ( fMakefile
,
1814 invokeTarget
.c_str () );
1815 fprintf ( fMakefile
,
1817 invokeTarget
.c_str () );
1818 size_t j
, jend
= invoke_targets
.size();
1819 for ( j
= 0; j
< jend
; j
++ )
1821 fprintf ( fMakefile
,
1823 invoke_targets
[i
].c_str () );
1825 fprintf ( fMakefile
, "\n\n%s", invoke_targets
[0].c_str () );
1826 for ( j
= 1; j
< jend
; j
++ )
1827 fprintf ( fMakefile
,
1829 invoke_targets
[i
].c_str () );
1830 fprintf ( fMakefile
,
1832 NormalizeFilename ( invoke
.invokeModule
->GetPath () ).c_str () );
1833 fprintf ( fMakefile
, "\t$(ECHO_INVOKE)\n" );
1834 fprintf ( fMakefile
,
1836 NormalizeFilename ( invoke
.invokeModule
->GetPath () ).c_str (),
1837 invoke
.GetParameters ().c_str () );
1842 MingwModuleHandler::GetPreconditionDependenciesName () const
1844 return module
.name
+ "_precondition";
1848 MingwModuleHandler::GetDefaultDependencies (
1849 string_list
& dependencies
) const
1851 /* Avoid circular dependency */
1852 if ( module
.type
!= BuildTool
1853 && module
.name
!= "zlib"
1854 && module
.name
!= "hostzlib" )
1856 dependencies
.push_back ( "$(INIT)" );
1860 MingwModuleHandler::GeneratePreconditionDependencies ()
1862 string preconditionDependenciesName
= GetPreconditionDependenciesName ();
1863 string_list sourceFilenames
;
1864 GetSourceFilenamesWithoutGeneratedFiles ( sourceFilenames
);
1865 string_list dependencies
;
1866 GetDefaultDependencies ( dependencies
);
1867 GetModuleDependencies ( dependencies
);
1869 GetInvocationDependencies ( module
, dependencies
);
1871 if ( dependencies
.size() )
1873 fprintf ( fMakefile
,
1875 preconditionDependenciesName
.c_str () );
1876 for ( size_t i
= 0; i
< dependencies
.size(); i
++ )
1877 fprintf ( fMakefile
,
1879 dependencies
[i
].c_str () );
1880 fprintf ( fMakefile
, "\n\n" );
1883 for ( size_t i
= 0; i
< sourceFilenames
.size(); i
++ )
1885 fprintf ( fMakefile
,
1887 sourceFilenames
[i
].c_str(),
1888 preconditionDependenciesName
.c_str ());
1890 fprintf ( fMakefile
, "\n" );
1894 MingwModuleHandler::IsWineModule () const
1896 if ( module
.importLibrary
== NULL
)
1899 size_t index
= module
.importLibrary
->definition
.rfind ( ".spec.def" );
1900 return ( index
!= string::npos
);
1904 MingwModuleHandler::GetDefinitionFilename () const
1906 if ( module
.importLibrary
!= NULL
)
1908 string defFilename
= module
.GetBasePath () + SSEP
+ module
.importLibrary
->definition
;
1909 if ( IsWineModule () )
1910 return PassThruCacheDirectory ( NormalizeFilename ( defFilename
),
1911 backend
->intermediateDirectory
);
1916 return "tools" SSEP
"rbuild" SSEP
"empty.def";
1920 MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ()
1922 if ( module
.importLibrary
!= NULL
)
1924 string
library_target (
1925 GetImportLibraryFilename ( module
, &clean_files
) );
1926 string defFilename
= GetDefinitionFilename ();
1929 GetDefinitionDependencies ( deps
);
1931 fprintf ( fMakefile
, "# IMPORT LIBRARY RULE:\n" );
1933 fprintf ( fMakefile
, "%s: %s",
1934 library_target
.c_str (),
1935 defFilename
.c_str () );
1937 size_t i
, iend
= deps
.size();
1938 for ( i
= 0; i
< iend
; i
++ )
1939 fprintf ( fMakefile
, " %s",
1942 fprintf ( fMakefile
, " | %s\n",
1943 GetDirectory ( GetImportLibraryFilename ( module
, NULL
) ).c_str () );
1945 fprintf ( fMakefile
, "\t$(ECHO_DLLTOOL)\n" );
1947 string killAt
= module
.mangledSymbols
? "" : "--kill-at";
1948 fprintf ( fMakefile
,
1949 "\t${dlltool} --dllname %s --def %s --output-lib %s %s\n\n",
1950 module
.GetTargetName ().c_str (),
1951 defFilename
.c_str (),
1952 library_target
.c_str (),
1958 MingwModuleHandler::GetSpecObjectDependencies (
1959 string_list
& dependencies
,
1960 const string
& filename
) const
1962 string basename
= GetBasename ( filename
);
1963 string defDependency
= PassThruCacheDirectory (
1964 NormalizeFilename ( basename
+ ".spec.def" ),
1965 backend
->intermediateDirectory
);
1966 dependencies
.push_back ( defDependency
);
1967 string stubsDependency
= PassThruCacheDirectory (
1968 NormalizeFilename ( basename
+ ".stubs.c" ),
1969 backend
->intermediateDirectory
);
1970 dependencies
.push_back ( stubsDependency
);
1974 MingwModuleHandler::GetWidlObjectDependencies (
1975 string_list
& dependencies
,
1976 const string
& filename
) const
1978 string basename
= GetBasename ( filename
);
1979 string serverDependency
= PassThruCacheDirectory (
1980 NormalizeFilename ( basename
+ "_s.c" ),
1981 backend
->intermediateDirectory
);
1982 dependencies
.push_back ( serverDependency
);
1986 MingwModuleHandler::GetDefinitionDependencies (
1987 string_list
& dependencies
) const
1989 string dkNkmLibNoFixup
= "dk/nkm/lib";
1990 const vector
<File
*>& files
= module
.non_if_data
.files
;
1991 for ( size_t i
= 0; i
< files
.size (); i
++ )
1993 File
& file
= *files
[i
];
1994 string extension
= GetExtension ( file
.name
);
1995 if ( extension
== ".spec" || extension
== ".SPEC" )
1997 GetSpecObjectDependencies ( dependencies
, file
.name
);
1999 if ( extension
== ".idl" || extension
== ".IDL" )
2001 GetWidlObjectDependencies ( dependencies
, file
.name
);
2007 MingwBuildToolModuleHandler::MingwBuildToolModuleHandler ( const Module
& module_
)
2008 : MingwModuleHandler ( module_
)
2013 MingwBuildToolModuleHandler::Process ()
2015 GenerateBuildToolModuleTarget ();
2019 MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ()
2021 string
targetMacro ( GetTargetMacro (module
) );
2022 string objectsMacro
= GetObjectsMacro ( module
);
2023 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2024 string libsMacro
= GetLibsMacro ();
2029 if ( module
.cplusplus
)
2030 linker
= "${host_gpp}";
2032 linker
= "${host_gcc}";
2034 fprintf ( fMakefile
, "%s: %s %s | %s\n",
2035 targetMacro
.c_str (),
2036 objectsMacro
.c_str (),
2037 linkDepsMacro
.c_str (),
2038 GetDirectory(GetTargetFilename(module
,NULL
)).c_str () );
2039 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
2040 fprintf ( fMakefile
,
2041 "\t%s %s -o $@ %s %s\n\n",
2043 GetLinkerMacro ().c_str (),
2044 objectsMacro
.c_str (),
2045 libsMacro
.c_str () );
2049 MingwKernelModuleHandler::MingwKernelModuleHandler (
2050 const Module
& module_
)
2052 : MingwModuleHandler ( module_
)
2057 MingwKernelModuleHandler::Process ()
2059 GenerateKernelModuleTarget ();
2063 MingwKernelModuleHandler::GenerateKernelModuleTarget ()
2065 string
targetMacro ( GetTargetMacro ( module
) );
2066 string workingDirectory
= GetWorkingDirectory ( );
2067 string objectsMacro
= GetObjectsMacro ( module
);
2068 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2069 string libsMacro
= GetLibsMacro ();
2071 GenerateImportLibraryTargetIfNeeded ();
2073 if ( module
.non_if_data
.files
.size () > 0 )
2077 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2079 string linkerParameters
= ssprintf ( "-Wl,-T,%s" SSEP
"ntoskrnl.lnk -Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll --dll",
2080 module
.GetBasePath ().c_str (),
2081 module
.entrypoint
.c_str (),
2082 module
.baseaddress
.c_str () );
2083 GenerateLinkerCommand ( dependencies
,
2091 GeneratePhonyTarget();
2096 MingwStaticLibraryModuleHandler::MingwStaticLibraryModuleHandler (
2097 const Module
& module_
)
2099 : MingwModuleHandler ( module_
)
2104 MingwStaticLibraryModuleHandler::Process ()
2106 GenerateStaticLibraryModuleTarget ();
2110 MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget ()
2116 MingwObjectLibraryModuleHandler::MingwObjectLibraryModuleHandler (
2117 const Module
& module_
)
2119 : MingwModuleHandler ( module_
)
2124 MingwObjectLibraryModuleHandler::Process ()
2126 GenerateObjectLibraryModuleTarget ();
2130 MingwObjectLibraryModuleHandler::GenerateObjectLibraryModuleTarget ()
2136 MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler (
2137 const Module
& module_
)
2139 : MingwModuleHandler ( module_
)
2144 MingwKernelModeDLLModuleHandler::Process ()
2146 GenerateKernelModeDLLModuleTarget ();
2150 MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ()
2152 string
targetMacro ( GetTargetMacro ( module
) );
2153 string workingDirectory
= GetWorkingDirectory ( );
2154 string objectsMacro
= GetObjectsMacro ( module
);
2155 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2156 string libsMacro
= GetLibsMacro ();
2158 GenerateImportLibraryTargetIfNeeded ();
2160 if ( module
.non_if_data
.files
.size () > 0 )
2164 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2166 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll --dll",
2167 module
.entrypoint
.c_str (),
2168 module
.baseaddress
.c_str () );
2169 GenerateLinkerCommand ( dependencies
,
2177 GeneratePhonyTarget();
2182 MingwKernelModeDriverModuleHandler::MingwKernelModeDriverModuleHandler (
2183 const Module
& module_
)
2185 : MingwModuleHandler ( module_
)
2190 MingwKernelModeDriverModuleHandler::Process ()
2192 GenerateKernelModeDriverModuleTarget ();
2197 MingwKernelModeDriverModuleHandler::GenerateKernelModeDriverModuleTarget ()
2199 string
targetMacro ( GetTargetMacro (module
) );
2200 string workingDirectory
= GetWorkingDirectory ();
2201 string objectsMacro
= GetObjectsMacro ( module
);
2202 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2203 string libsMacro
= GetLibsMacro ();
2205 GenerateImportLibraryTargetIfNeeded ();
2207 if ( module
.non_if_data
.files
.size () > 0 )
2211 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2213 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll --dll",
2214 module
.entrypoint
.c_str (),
2215 module
.baseaddress
.c_str () );
2216 GenerateLinkerCommand ( dependencies
,
2224 GeneratePhonyTarget();
2229 MingwNativeDLLModuleHandler::MingwNativeDLLModuleHandler (
2230 const Module
& module_
)
2232 : MingwModuleHandler ( module_
)
2237 MingwNativeDLLModuleHandler::Process ()
2239 GenerateNativeDLLModuleTarget ();
2243 MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ()
2245 string
targetMacro ( GetTargetMacro (module
) );
2246 string workingDirectory
= GetWorkingDirectory ( );
2247 string objectsMacro
= GetObjectsMacro ( module
);
2248 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2249 string libsMacro
= GetLibsMacro ();
2251 GenerateImportLibraryTargetIfNeeded ();
2253 if ( module
.non_if_data
.files
.size () > 0 )
2257 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2259 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib -mdll --dll",
2260 module
.entrypoint
.c_str (),
2261 module
.baseaddress
.c_str () );
2262 GenerateLinkerCommand ( dependencies
,
2270 GeneratePhonyTarget();
2275 MingwNativeCUIModuleHandler::MingwNativeCUIModuleHandler (
2276 const Module
& module_
)
2278 : MingwModuleHandler ( module_
)
2283 MingwNativeCUIModuleHandler::Process ()
2285 GenerateNativeCUIModuleTarget ();
2289 MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ()
2291 string
targetMacro ( GetTargetMacro (module
) );
2292 string workingDirectory
= GetWorkingDirectory ( );
2293 string objectsMacro
= GetObjectsMacro ( module
);
2294 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2295 string libsMacro
= GetLibsMacro ();
2297 GenerateImportLibraryTargetIfNeeded ();
2299 if ( module
.non_if_data
.files
.size () > 0 )
2303 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2305 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib",
2306 module
.entrypoint
.c_str (),
2307 module
.baseaddress
.c_str () );
2308 GenerateLinkerCommand ( dependencies
,
2316 GeneratePhonyTarget();
2321 MingwWin32DLLModuleHandler::MingwWin32DLLModuleHandler (
2322 const Module
& module_
)
2324 : MingwModuleHandler ( module_
)
2329 MingwWin32DLLModuleHandler::Process ()
2331 GenerateWin32DLLModuleTarget ();
2335 MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ()
2337 string
targetMacro ( GetTargetMacro (module
) );
2338 string workingDirectory
= GetWorkingDirectory ( );
2339 string objectsMacro
= GetObjectsMacro ( module
);
2340 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2341 string libsMacro
= GetLibsMacro ();
2343 GenerateImportLibraryTargetIfNeeded ();
2345 if ( module
.non_if_data
.files
.size () > 0 )
2349 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2352 if ( module
.cplusplus
)
2357 string linkerParameters
= ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -mdll --dll",
2358 module
.entrypoint
.c_str (),
2359 module
.baseaddress
.c_str () );
2360 GenerateLinkerCommand ( dependencies
,
2368 GeneratePhonyTarget();
2373 MingwWin32CUIModuleHandler::MingwWin32CUIModuleHandler (
2374 const Module
& module_
)
2376 : MingwModuleHandler ( module_
)
2381 MingwWin32CUIModuleHandler::Process ()
2383 GenerateWin32CUIModuleTarget ();
2387 MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ()
2389 string
targetMacro ( GetTargetMacro (module
) );
2390 string workingDirectory
= GetWorkingDirectory ( );
2391 string objectsMacro
= GetObjectsMacro ( module
);
2392 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2393 string libsMacro
= GetLibsMacro ();
2395 GenerateImportLibraryTargetIfNeeded ();
2397 if ( module
.non_if_data
.files
.size () > 0 )
2401 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2404 if ( module
.cplusplus
)
2409 string linkerParameters
= ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
2410 module
.entrypoint
.c_str (),
2411 module
.baseaddress
.c_str () );
2412 GenerateLinkerCommand ( dependencies
,
2420 GeneratePhonyTarget();
2425 MingwWin32GUIModuleHandler::MingwWin32GUIModuleHandler (
2426 const Module
& module_
)
2428 : MingwModuleHandler ( module_
)
2433 MingwWin32GUIModuleHandler::Process ()
2435 GenerateWin32GUIModuleTarget ();
2439 MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ()
2441 string
targetMacro ( GetTargetMacro (module
) );
2442 string workingDirectory
= GetWorkingDirectory ( );
2443 string objectsMacro
= GetObjectsMacro ( module
);
2444 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2445 string libsMacro
= GetLibsMacro ();
2447 GenerateImportLibraryTargetIfNeeded ();
2449 if ( module
.non_if_data
.files
.size () > 0 )
2453 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2456 if ( module
.cplusplus
)
2461 string linkerParameters
= ssprintf ( "-Wl,--subsystem,windows -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
2462 module
.entrypoint
.c_str (),
2463 module
.baseaddress
.c_str () );
2464 GenerateLinkerCommand ( dependencies
,
2472 GeneratePhonyTarget();
2477 MingwBootLoaderModuleHandler::MingwBootLoaderModuleHandler (
2478 const Module
& module_
)
2480 : MingwModuleHandler ( module_
)
2485 MingwBootLoaderModuleHandler::Process ()
2487 GenerateBootLoaderModuleTarget ();
2491 MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ()
2493 string
targetName ( module
.GetTargetName () );
2494 string
targetMacro ( GetTargetMacro (module
) );
2495 string workingDirectory
= GetWorkingDirectory ();
2496 string junk_tmp
= ros_temp
+ module
.name
+ ".junk.tmp";
2497 CLEAN_FILE ( junk_tmp
);
2498 string objectsMacro
= GetObjectsMacro ( module
);
2499 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2500 string libsMacro
= GetLibsMacro ();
2504 fprintf ( fMakefile
, "%s: %s %s | %s\n",
2505 targetMacro
.c_str (),
2506 objectsMacro
.c_str (),
2507 linkDepsMacro
.c_str (),
2508 GetDirectory(GetTargetFilename(module
,NULL
)).c_str () );
2510 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
2512 fprintf ( fMakefile
,
2513 "\t${ld} %s -N -Ttext=0x8000 -o %s %s %s\n",
2514 GetLinkerMacro ().c_str (),
2516 objectsMacro
.c_str (),
2517 linkDepsMacro
.c_str () );
2518 fprintf ( fMakefile
,
2519 "\t${objcopy} -O binary %s $@\n",
2520 junk_tmp
.c_str () );
2521 fprintf ( fMakefile
,
2522 "\t-@${rm} %s 2>$(NUL)\n",
2523 junk_tmp
.c_str () );
2527 MingwBootSectorModuleHandler::MingwBootSectorModuleHandler (
2528 const Module
& module_
)
2530 : MingwModuleHandler ( module_
)
2535 MingwBootSectorModuleHandler::Process ()
2537 GenerateBootSectorModuleTarget ();
2541 MingwBootSectorModuleHandler::GenerateBootSectorModuleTarget ()
2543 string objectsMacro
= GetObjectsMacro ( module
);
2547 fprintf ( fMakefile
, ".PHONY: %s\n\n",
2548 module
.name
.c_str ());
2549 fprintf ( fMakefile
,
2551 module
.name
.c_str (),
2552 objectsMacro
.c_str () );
2556 MingwIsoModuleHandler::MingwIsoModuleHandler (
2557 const Module
& module_
)
2559 : MingwModuleHandler ( module_
)
2564 MingwIsoModuleHandler::Process ()
2566 GenerateIsoModuleTarget ();
2570 MingwIsoModuleHandler::OutputBootstrapfileCopyCommands (
2571 const string
& bootcdDirectory
)
2573 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
2575 const Module
& m
= *module
.project
.modules
[i
];
2576 if ( m
.bootstrap
!= NULL
)
2578 string sourceFilename
= PassThruCacheDirectory (
2579 NormalizeFilename ( m
.GetPath () ),
2580 backend
->outputDirectory
);
2581 string
targetFilenameNoFixup ( bootcdDirectory
+ SSEP
+ m
.bootstrap
->base
+ SSEP
+ m
.bootstrap
->nameoncd
);
2582 string targetFilename
= MingwModuleHandler::PassThruCacheDirectory (
2583 NormalizeFilename ( targetFilenameNoFixup
),
2584 backend
->outputDirectory
);
2585 fprintf ( fMakefile
,
2587 fprintf ( fMakefile
,
2588 "\t${cp} %s %s 1>$(NUL)\n",
2589 sourceFilename
.c_str (),
2590 targetFilename
.c_str () );
2596 MingwIsoModuleHandler::OutputCdfileCopyCommands (
2597 const string
& bootcdDirectory
)
2599 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
2601 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
2602 string targetFilenameNoFixup
= bootcdDirectory
+ SSEP
+ cdfile
.base
+ SSEP
+ cdfile
.nameoncd
;
2603 string targetFilename
= MingwModuleHandler::PassThruCacheDirectory (
2604 NormalizeFilename ( targetFilenameNoFixup
),
2605 backend
->outputDirectory
);
2606 fprintf ( fMakefile
,
2608 fprintf ( fMakefile
,
2609 "\t${cp} %s %s 1>$(NUL)\n",
2610 cdfile
.GetPath ().c_str (),
2611 targetFilename
.c_str () );
2616 MingwIsoModuleHandler::GetBootstrapCdDirectories ( const string
& bootcdDirectory
)
2619 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
2621 const Module
& m
= *module
.project
.modules
[i
];
2622 if ( m
.bootstrap
!= NULL
)
2624 string
targetDirectory ( bootcdDirectory
+ SSEP
+ m
.bootstrap
->base
);
2625 if ( directories
.size () > 0 )
2627 directories
+= PassThruCacheDirectory (
2628 NormalizeFilename ( targetDirectory
),
2629 backend
->outputDirectory
);
2636 MingwIsoModuleHandler::GetNonModuleCdDirectories ( const string
& bootcdDirectory
)
2639 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
2641 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
2642 string
targetDirectory ( bootcdDirectory
+ SSEP
+ cdfile
.base
);
2643 if ( directories
.size () > 0 )
2645 directories
+= PassThruCacheDirectory (
2646 NormalizeFilename ( targetDirectory
),
2647 backend
->outputDirectory
);
2653 MingwIsoModuleHandler::GetCdDirectories ( const string
& bootcdDirectory
)
2655 string directories
= GetBootstrapCdDirectories ( bootcdDirectory
);
2656 directories
+= " " + GetNonModuleCdDirectories ( bootcdDirectory
);
2661 MingwIsoModuleHandler::GetBootstrapCdFiles (
2662 vector
<string
>& out
) const
2664 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
2666 const Module
& m
= *module
.project
.modules
[i
];
2667 if ( m
.bootstrap
!= NULL
)
2669 string filename
= PassThruCacheDirectory (
2670 NormalizeFilename ( m
.GetPath () ),
2671 backend
->outputDirectory
);
2672 out
.push_back ( filename
);
2678 MingwIsoModuleHandler::GetNonModuleCdFiles (
2679 vector
<string
>& out
) const
2681 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
2683 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
2684 out
.push_back ( cdfile
.GetPath () );
2689 MingwIsoModuleHandler::GetCdFiles (
2690 vector
<string
>& out
) const
2692 GetBootstrapCdFiles ( out
);
2693 GetNonModuleCdFiles ( out
);
2697 MingwIsoModuleHandler::GenerateIsoModuleTarget ()
2699 string bootcdDirectory
= "cd";
2700 string bootcd
= PassThruCacheDirectory (
2701 NormalizeFilename ( bootcdDirectory
+ SSEP
),
2702 backend
->outputDirectory
);
2703 string isoboot
= PassThruCacheDirectory (
2704 NormalizeFilename ( "boot" SSEP
"freeldr" SSEP
"bootsect" SSEP
"isoboot.o" ),
2705 backend
->outputDirectory
);
2706 string bootcdReactosNoFixup
= bootcdDirectory
+ SSEP
"reactos";
2707 string bootcdReactos
= PassThruCacheDirectory (
2708 NormalizeFilename ( bootcdReactosNoFixup
+ SSEP
),
2709 backend
->outputDirectory
);
2710 CLEAN_FILE ( bootcdReactos
);
2711 string reactosInf
= PassThruCacheDirectory (
2712 NormalizeFilename ( bootcdReactosNoFixup
+ SSEP
"reactos.inf" ),
2713 backend
->outputDirectory
);
2714 string reactosDff
= NormalizeFilename ( "bootdata" SSEP
"packages" SSEP
"reactos.dff" );
2715 string cdDirectories
= GetCdDirectories ( bootcdDirectory
);
2716 vector
<string
> vCdFiles
;
2717 GetCdFiles ( vCdFiles
);
2718 string cdFiles
= v2s ( vCdFiles
, 5 );
2720 fprintf ( fMakefile
, ".PHONY: %s\n\n",
2721 module
.name
.c_str ());
2722 fprintf ( fMakefile
,
2723 "%s: all %s %s %s %s $(CABMAN_TARGET) $(CDMAKE_TARGET)\n",
2724 module
.name
.c_str (),
2726 bootcdReactos
.c_str (),
2727 cdDirectories
.c_str (),
2729 fprintf ( fMakefile
, "\t$(ECHO_CABMAN)\n" );
2730 fprintf ( fMakefile
,
2731 "\t$(Q)$(CABMAN_TARGET) -C %s -L %s -I -P $(OUTPUT)\n",
2732 reactosDff
.c_str (),
2733 bootcdReactos
.c_str () );
2734 fprintf ( fMakefile
,
2735 "\t$(Q)$(CABMAN_TARGET) -C %s -RC %s -L %s -N -P $(OUTPUT)\n",
2736 reactosDff
.c_str (),
2737 reactosInf
.c_str (),
2738 bootcdReactos
.c_str ());
2739 fprintf ( fMakefile
,
2740 "\t-@${rm} %s 2>$(NUL)\n",
2741 reactosInf
.c_str () );
2742 OutputBootstrapfileCopyCommands ( bootcdDirectory
);
2743 OutputCdfileCopyCommands ( bootcdDirectory
);
2744 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
2745 fprintf ( fMakefile
,
2746 "\t$(Q)$(CDMAKE_TARGET) -v -m -b %s %s REACTOS ReactOS.iso\n",
2749 fprintf ( fMakefile
,
2754 MingwLiveIsoModuleHandler::MingwLiveIsoModuleHandler (
2755 const Module
& module_
)
2757 : MingwModuleHandler ( module_
)
2762 MingwLiveIsoModuleHandler::Process ()
2764 GenerateLiveIsoModuleTarget ();
2768 MingwLiveIsoModuleHandler::CreateDirectory ( const string
& directory
)
2770 string normalizedDirectory
= MingwModuleHandler::PassThruCacheDirectory (
2771 NormalizeFilename ( directory
) + SSEP
,
2772 backend
->outputDirectory
);
2776 MingwLiveIsoModuleHandler::OutputCopyCommand ( const string
& sourceFilename
,
2777 const string
& targetFilename
,
2778 const string
& targetDirectory
)
2780 string normalizedTargetFilename
= MingwModuleHandler::PassThruCacheDirectory (
2781 NormalizeFilename ( targetDirectory
+ SSEP
+ targetFilename
),
2782 backend
->outputDirectory
);
2783 fprintf ( fMakefile
,
2785 fprintf ( fMakefile
,
2786 "\t${cp} %s %s 1>$(NUL)\n",
2787 sourceFilename
.c_str (),
2788 normalizedTargetFilename
.c_str () );
2792 MingwLiveIsoModuleHandler::OutputModuleCopyCommands ( string
& livecdDirectory
,
2793 string
& reactosDirectory
)
2795 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
2797 const Module
& m
= *module
.project
.modules
[i
];
2798 if ( m
.installName
.length () > 0 )
2800 string sourceFilename
= MingwModuleHandler::PassThruCacheDirectory (
2801 NormalizeFilename ( m
.GetPath () ),
2802 backend
->outputDirectory
);
2803 OutputCopyCommand ( sourceFilename
,
2805 livecdDirectory
+ SSEP
+ reactosDirectory
+ SSEP
+ m
.installBase
);
2811 MingwLiveIsoModuleHandler::OutputNonModuleCopyCommands ( string
& livecdDirectory
,
2812 string
& reactosDirectory
)
2814 for ( size_t i
= 0; i
< module
.project
.installfiles
.size (); i
++ )
2816 const InstallFile
& installfile
= *module
.project
.installfiles
[i
];
2817 OutputCopyCommand ( installfile
.GetPath (),
2818 installfile
.newname
,
2819 livecdDirectory
+ SSEP
+ reactosDirectory
+ SSEP
+ installfile
.base
);
2824 MingwLiveIsoModuleHandler::OutputProfilesDirectoryCommands ( string
& livecdDirectory
)
2826 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" );
2827 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" SSEP
"All Users") ;
2828 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" SSEP
"All Users" SSEP
"Desktop" );
2829 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" SSEP
"Default User" );
2830 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" SSEP
"Default User" SSEP
"Desktop" );
2831 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" SSEP
"Default User" SSEP
"My Documents" );
2833 string livecdIni
= "bootdata" SSEP
"livecd.ini";
2834 OutputCopyCommand ( livecdIni
,
2840 MingwLiveIsoModuleHandler::OutputLoaderCommands ( string
& livecdDirectory
)
2842 string freeldr
= PassThruCacheDirectory (
2843 NormalizeFilename ( "boot" SSEP
"freeldr" SSEP
"freeldr" SSEP
"freeldr.sys" ),
2844 backend
->outputDirectory
);
2845 CreateDirectory ( livecdDirectory
+ SSEP
"loader" );
2846 OutputCopyCommand ( freeldr
,
2848 livecdDirectory
+ SSEP
+ "loader" );
2852 MingwLiveIsoModuleHandler::OutputRegistryCommands ( string
& livecdDirectory
)
2854 string reactosSystem32ConfigDirectory
= NormalizeFilename (
2855 MingwModuleHandler::PassThruCacheDirectory (
2856 livecdDirectory
+ SSEP
"reactos" SSEP
"system32" SSEP
"config" SSEP
,
2857 backend
->outputDirectory
) );
2858 fprintf ( fMakefile
,
2859 "\t$(ECHO_MKHIVE)\n" );
2860 fprintf ( fMakefile
,
2861 "\t$(MKHIVE_TARGET) bootdata %s bootdata" SSEP
"livecd.inf bootdata" SSEP
"hiveinst.inf\n",
2862 reactosSystem32ConfigDirectory
.c_str () );
2866 MingwLiveIsoModuleHandler::GenerateLiveIsoModuleTarget ()
2868 string livecdDirectory
= "livecd";
2869 string livecd
= PassThruCacheDirectory (
2870 NormalizeFilename ( livecdDirectory
+ SSEP
),
2871 backend
->outputDirectory
);
2872 string isoboot
= PassThruCacheDirectory (
2873 NormalizeFilename ( "boot" SSEP
"freeldr" SSEP
"bootsect" SSEP
"isoboot.o" ),
2874 backend
->outputDirectory
);
2875 string reactosDirectory
= "reactos";
2876 string livecdReactosNoFixup
= livecdDirectory
+ SSEP
+ reactosDirectory
;
2877 string livecdReactos
= NormalizeFilename ( PassThruCacheDirectory (
2878 NormalizeFilename ( livecdReactosNoFixup
+ SSEP
),
2879 backend
->outputDirectory
) );
2880 CLEAN_FILE ( livecdReactos
);
2882 fprintf ( fMakefile
, ".PHONY: %s\n\n",
2883 module
.name
.c_str ());
2884 fprintf ( fMakefile
,
2885 "%s: all %s %s $(MKHIVE_TARGET) $(CDMAKE_TARGET)\n",
2886 module
.name
.c_str (),
2888 livecdReactos
.c_str () );
2889 OutputModuleCopyCommands ( livecdDirectory
,
2891 OutputNonModuleCopyCommands ( livecdDirectory
,
2893 OutputProfilesDirectoryCommands ( livecdDirectory
);
2894 OutputLoaderCommands ( livecdDirectory
);
2895 OutputRegistryCommands ( livecdDirectory
);
2896 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
2897 fprintf ( fMakefile
,
2898 "\t$(Q)$(CDMAKE_TARGET) -v -m -j -b %s %s REACTOS ReactOS-LiveCD.iso\n",
2901 fprintf ( fMakefile
,
2906 MingwTestModuleHandler::MingwTestModuleHandler (
2907 const Module
& module_
)
2909 : MingwModuleHandler ( module_
)
2914 MingwTestModuleHandler::Process ()
2916 GenerateTestModuleTarget ();
2920 MingwTestModuleHandler::GetModuleSpecificSourceFiles ( vector
<File
*>& sourceFiles
)
2922 string basePath
= "$(INTERMEDIATE)" SSEP
+ module
.GetBasePath ();
2923 sourceFiles
.push_back ( new File ( basePath
+ SSEP
"_hooks.c", false, "", false ) );
2924 sourceFiles
.push_back ( new File ( basePath
+ SSEP
"_stubs.S", false, "", false ) );
2925 sourceFiles
.push_back ( new File ( basePath
+ SSEP
"_startup.c", false, "", false ) );
2929 MingwTestModuleHandler::GenerateTestModuleTarget ()
2931 string
targetMacro ( GetTargetMacro ( module
) );
2932 string workingDirectory
= GetWorkingDirectory ( );
2933 string objectsMacro
= GetObjectsMacro ( module
);
2934 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2935 string libsMacro
= GetLibsMacro ();
2937 GenerateImportLibraryTargetIfNeeded ();
2939 if ( module
.non_if_data
.files
.size () > 0 )
2943 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2946 if ( module
.cplusplus
)
2951 string linkerParameters
= ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
2952 module
.entrypoint
.c_str (),
2953 module
.baseaddress
.c_str () );
2954 GenerateLinkerCommand ( dependencies
,
2962 GeneratePhonyTarget();
2967 MingwRpcServerModuleHandler::MingwRpcServerModuleHandler (
2968 const Module
& module_
)
2970 : MingwModuleHandler ( module_
)
2975 MingwRpcServerModuleHandler::Process ()
2980 MingwRpcClientModuleHandler::MingwRpcClientModuleHandler (
2981 const Module
& module_
)
2983 : MingwModuleHandler ( module_
)
2988 MingwRpcClientModuleHandler::Process ()