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
->header
+ ".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 rciFilename
= ros_temp
+ module
.name
+ ".rci.tmp";
916 string resFilename
= ros_temp
+ module
.name
+ ".res.tmp";
920 "%s: %s $(WRC_TARGET) | %s\n",
921 objectFilename
.c_str (),
922 dependencies
.c_str (),
923 GetDirectory ( objectFilename
).c_str () );
924 fprintf ( fMakefile
, "\t$(ECHO_WRC)\n" );
926 "\t${gcc} -xc -E -DRC_INVOKED ${%s} %s > %s\n",
927 windresflagsMacro
.c_str (),
928 sourceFilename
.c_str (),
929 rciFilename
.c_str () );
931 "\t$(Q)$(WRC_TARGET) ${%s} %s %s\n",
932 windresflagsMacro
.c_str (),
933 rciFilename
.c_str (),
934 resFilename
.c_str () );
936 "\t-@${rm} %s 2>$(NUL)\n",
937 rciFilename
.c_str () );
939 "\t${windres} %s -o $@\n",
940 resFilename
.c_str () );
942 "\t-@${rm} %s 2>$(NUL)\n",
943 resFilename
.c_str () );
948 "%s: %s $(WRC_TARGET) | %s\n",
949 objectFilename
.c_str (),
950 dependencies
.c_str (),
951 GetDirectory ( objectFilename
).c_str () );
952 fprintf ( fMakefile
, "\t$(ECHO_WRC)\n" );
954 "\t${windres} $(%s) %s -o $@\n",
955 windresflagsMacro
.c_str (),
956 sourceFilename
.c_str () );
961 MingwModuleHandler::GenerateWinebuildCommands (
962 const string
& sourceFilename
)
964 string dependencies
= sourceFilename
;
965 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
967 string basename
= GetBasename ( sourceFilename
);
968 string def_file
= PassThruCacheDirectory (
969 basename
+ ".spec.def",
970 backend
->intermediateDirectory
);
971 CLEAN_FILE(def_file
);
973 string stub_file
= PassThruCacheDirectory (
974 basename
+ ".stubs.c",
975 backend
->intermediateDirectory
);
976 CLEAN_FILE(stub_file
)
979 "%s: %s $(WINEBUILD_TARGET)\n",
981 dependencies
.c_str () );
982 fprintf ( fMakefile
, "\t$(ECHO_WINEBLD)\n" );
984 "\t%s --def=%s -o %s\n",
985 "$(Q)$(WINEBUILD_TARGET)",
986 sourceFilename
.c_str (),
990 "%s: %s $(WINEBUILD_TARGET)\n",
992 sourceFilename
.c_str () );
993 fprintf ( fMakefile
, "\t$(ECHO_WINEBLD)\n" );
995 "\t%s --pedll=%s -o %s\n",
996 "$(Q)$(WINEBUILD_TARGET)",
997 sourceFilename
.c_str (),
998 stub_file
.c_str () );
1002 MingwModuleHandler::GetWidlFlags ( const File
& file
)
1004 return file
.switches
;
1008 MingwModuleHandler::GenerateWidlCommandsServer (
1010 const string
& widlflagsMacro
)
1012 string dependencies
= file
.name
;
1013 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
1015 string basename
= GetBasename ( file
.name
);
1017 /*string generatedHeaderFilename = PassThruCacheDirectory (
1019 backend->intermediateDirectory );
1020 CLEAN_FILE(generatedHeaderFilename);
1022 string generatedHeaderFilename
= basename
+ "_s.h";
1023 CLEAN_FILE(generatedHeaderFilename
);
1025 string generatedServerFilename
= PassThruCacheDirectory (
1027 backend
->intermediateDirectory
);
1028 CLEAN_FILE(generatedServerFilename
);
1030 fprintf ( fMakefile
,
1031 "%s %s: %s $(WIDL_TARGET) | %s\n",
1032 generatedServerFilename
.c_str (),
1033 generatedHeaderFilename
.c_str (),
1034 dependencies
.c_str (),
1035 GetDirectory ( generatedServerFilename
).c_str () );
1036 fprintf ( fMakefile
, "\t$(ECHO_WIDL)\n" );
1037 fprintf ( fMakefile
,
1038 "\t%s %s %s -h -H %s -s -S %s %s\n",
1039 "$(Q)$(WIDL_TARGET)",
1040 GetWidlFlags ( file
).c_str (),
1041 widlflagsMacro
.c_str (),
1042 generatedHeaderFilename
.c_str (),
1043 generatedServerFilename
.c_str (),
1044 file
.name
.c_str () );
1048 MingwModuleHandler::GenerateWidlCommandsClient (
1050 const string
& widlflagsMacro
)
1052 string dependencies
= file
.name
;
1053 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
1055 string basename
= GetBasename ( file
.name
);
1057 /*string generatedHeaderFilename = PassThruCacheDirectory (
1059 backend->intermediateDirectory );
1060 CLEAN_FILE(generatedHeaderFilename);
1062 string generatedHeaderFilename
= basename
+ "_c.h";
1063 CLEAN_FILE(generatedHeaderFilename
);
1065 string generatedClientFilename
= PassThruCacheDirectory (
1067 backend
->intermediateDirectory
);
1068 CLEAN_FILE(generatedClientFilename
);
1070 fprintf ( fMakefile
,
1071 "%s %s: %s $(WIDL_TARGET) | %s\n",
1072 generatedClientFilename
.c_str (),
1073 generatedHeaderFilename
.c_str (),
1074 dependencies
.c_str (),
1075 GetDirectory ( generatedClientFilename
).c_str () );
1076 fprintf ( fMakefile
, "\t$(ECHO_WIDL)\n" );
1077 fprintf ( fMakefile
,
1078 "\t%s %s %s -h -H %s -c -C %s %s\n",
1079 "$(Q)$(WIDL_TARGET)",
1080 GetWidlFlags ( file
).c_str (),
1081 widlflagsMacro
.c_str (),
1082 generatedHeaderFilename
.c_str (),
1083 generatedClientFilename
.c_str (),
1084 file
.name
.c_str () );
1088 MingwModuleHandler::GenerateWidlCommands (
1090 const string
& widlflagsMacro
)
1092 if ( module
.type
== RpcServer
)
1093 GenerateWidlCommandsServer ( file
,
1096 GenerateWidlCommandsClient ( file
,
1101 MingwModuleHandler::GenerateCommands (
1105 const string
& cflagsMacro
,
1106 const string
& nasmflagsMacro
,
1107 const string
& windresflagsMacro
,
1108 const string
& widlflagsMacro
)
1110 string extension
= GetExtension ( file
.name
);
1111 if ( extension
== ".c" || extension
== ".C" )
1113 GenerateGccCommand ( file
.name
,
1118 else if ( extension
== ".cc" || extension
== ".CC" ||
1119 extension
== ".cpp" || extension
== ".CPP" ||
1120 extension
== ".cxx" || extension
== ".CXX" )
1122 GenerateGccCommand ( file
.name
,
1127 else if ( extension
== ".s" || extension
== ".S" )
1129 GenerateGccAssemblerCommand ( file
.name
,
1134 else if ( extension
== ".asm" || extension
== ".ASM" )
1136 GenerateNasmCommand ( file
.name
,
1140 else if ( extension
== ".rc" || extension
== ".RC" )
1142 GenerateWindresCommand ( file
.name
,
1143 windresflagsMacro
);
1146 else if ( extension
== ".spec" || extension
== ".SPEC" )
1148 GenerateWinebuildCommands ( file
.name
);
1149 GenerateGccCommand ( GetActualSourceFilename ( file
.name
),
1154 else if ( extension
== ".idl" || extension
== ".IDL" )
1156 GenerateWidlCommands ( file
,
1158 GenerateGccCommand ( GetActualSourceFilename ( file
.name
),
1164 throw InvalidOperationException ( __FILE__
,
1166 "Unsupported filename extension '%s' in file '%s'",
1168 file
.name
.c_str () );
1172 MingwModuleHandler::GenerateBuildMapCode ()
1174 fprintf ( fMakefile
,
1175 "ifeq ($(ROS_BUILDMAP),full)\n" );
1177 string mapFilename
= PassThruCacheDirectory (
1178 GetBasename ( module
.GetPath () ) + ".map",
1179 backend
->outputDirectory
);
1180 CLEAN_FILE ( mapFilename
);
1182 fprintf ( fMakefile
,
1183 "\t$(ECHO_OBJDUMP)\n" );
1184 fprintf ( fMakefile
,
1185 "\t$(Q)${objdump} -d -S $@ > %s\n",
1186 mapFilename
.c_str () );
1188 fprintf ( fMakefile
,
1190 fprintf ( fMakefile
,
1191 "ifeq ($(ROS_BUILDMAP),yes)\n" );
1193 fprintf ( fMakefile
,
1195 fprintf ( fMakefile
,
1196 "\t$(Q)${nm} --numeric-sort $@ > %s\n",
1197 mapFilename
.c_str () );
1199 fprintf ( fMakefile
,
1202 fprintf ( fMakefile
,
1207 MingwModuleHandler::GenerateBuildNonSymbolStrippedCode ()
1209 fprintf ( fMakefile
,
1210 "ifeq ($(ROS_BUILDNOSTRIP),yes)\n" );
1212 string filename
= module
.GetPath ();
1213 string outputFilename
= PassThruCacheDirectory (
1215 backend
->outputDirectory
);
1216 string nostripFilename
= PassThruCacheDirectory (
1217 GetBasename ( filename
) + ".nostrip" + GetExtension ( filename
),
1218 backend
->outputDirectory
);
1219 CLEAN_FILE ( nostripFilename
);
1221 fprintf ( fMakefile
,
1223 fprintf ( fMakefile
,
1224 "\t${cp} %s %s 1>$(NUL)\n",
1225 outputFilename
.c_str (),
1226 nostripFilename
.c_str () );
1228 fprintf ( fMakefile
,
1233 MergeStringVector ( const vector
<string
>& input
,
1234 vector
<string
>& output
)
1238 int wrap_count
= -1;
1239 for ( size_t i
= 0; i
< input
.size (); i
++ )
1241 if ( input
[i
].size () == 0 )
1243 if ( wrap_count
++ == wrap_at
)
1245 output
.push_back ( s
);
1249 else if ( s
.size () > 0)
1253 if ( s
.length () > 0 )
1254 output
.push_back ( s
);
1258 MingwModuleHandler::GetObjectsVector ( const IfableData
& data
,
1259 vector
<string
>& objectFiles
) const
1261 for ( size_t i
= 0; i
< data
.files
.size (); i
++ )
1263 File
& file
= *data
.files
[i
];
1264 objectFiles
.push_back ( GetObjectFilename ( file
.name
, NULL
) );
1269 MingwModuleHandler::GenerateCleanObjectsAsYouGoCode () const
1271 if ( backend
->cleanAsYouGo
)
1273 vector
<string
> objectFiles
;
1274 GetObjectsVector ( module
.non_if_data
,
1276 vector
<string
> lines
;
1277 MergeStringVector ( objectFiles
,
1279 for ( size_t i
= 0; i
< lines
.size (); i
++ )
1281 fprintf ( fMakefile
,
1282 "\t-@${rm} %s 2>$(NUL)\n",
1283 lines
[i
].c_str () );
1289 MingwModuleHandler::GenerateRunRsymCode () const
1291 fprintf ( fMakefile
,
1292 "\t$(ECHO_RSYM)\n" );
1293 fprintf ( fMakefile
,
1294 "\t$(Q)$(RSYM_TARGET) $@ $@\n\n" );
1298 MingwModuleHandler::GenerateLinkerCommand (
1299 const string
& dependencies
,
1300 const string
& linker
,
1301 const string
& linkerParameters
,
1302 const string
& objectsMacro
,
1303 const string
& libsMacro
)
1305 string
target ( GetTargetMacro ( module
) );
1306 string
target_folder ( GetDirectory ( GetTargetFilename ( module
, NULL
) ) );
1307 string def_file
= GetDefinitionFilename ();
1309 fprintf ( fMakefile
,
1310 "%s: %s %s $(RSYM_TARGET) | %s\n",
1313 dependencies
.c_str (),
1314 target_folder
.c_str () );
1315 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
1316 string
targetName ( module
.GetTargetName () );
1318 if ( module
.IsDLL () )
1320 string base_tmp
= ros_temp
+ module
.name
+ ".base.tmp";
1321 CLEAN_FILE ( base_tmp
);
1322 string junk_tmp
= ros_temp
+ module
.name
+ ".junk.tmp";
1323 CLEAN_FILE ( junk_tmp
);
1324 string temp_exp
= ros_temp
+ module
.name
+ ".temp.exp";
1325 CLEAN_FILE ( temp_exp
);
1327 fprintf ( fMakefile
,
1328 "\t%s %s -Wl,--base-file,%s -o %s %s %s %s\n",
1330 linkerParameters
.c_str (),
1333 objectsMacro
.c_str (),
1335 GetLinkerMacro ().c_str () );
1337 fprintf ( fMakefile
,
1338 "\t-@${rm} %s 2>$(NUL)\n",
1339 junk_tmp
.c_str () );
1341 string killAt
= module
.mangledSymbols
? "" : "--kill-at";
1342 fprintf ( fMakefile
,
1343 "\t${dlltool} --dllname %s --base-file %s --def %s --output-exp %s %s\n",
1344 targetName
.c_str (),
1350 fprintf ( fMakefile
,
1351 "\t-@${rm} %s 2>$(NUL)\n",
1352 base_tmp
.c_str () );
1354 fprintf ( fMakefile
,
1355 "\t%s %s %s -o %s %s %s %s\n",
1357 linkerParameters
.c_str (),
1360 objectsMacro
.c_str (),
1362 GetLinkerMacro ().c_str () );
1364 fprintf ( fMakefile
,
1365 "\t-@${rm} %s 2>$(NUL)\n",
1366 temp_exp
.c_str () );
1370 fprintf ( fMakefile
,
1371 "\t%s %s -o %s %s %s %s\n",
1373 linkerParameters
.c_str (),
1375 objectsMacro
.c_str (),
1377 GetLinkerMacro ().c_str () );
1380 GenerateBuildMapCode ();
1381 GenerateBuildNonSymbolStrippedCode ();
1382 GenerateRunRsymCode ();
1383 GenerateCleanObjectsAsYouGoCode ();
1387 MingwModuleHandler::GeneratePhonyTarget() const
1389 string
targetMacro ( GetTargetMacro ( module
) );
1390 fprintf ( fMakefile
,
1392 targetMacro
.c_str ());
1393 fprintf ( fMakefile
, "%s: | %s\n",
1394 targetMacro
.c_str (),
1395 GetDirectory ( GetTargetFilename ( module
, NULL
) ).c_str () );
1399 MingwModuleHandler::GenerateObjectFileTargets (
1400 const IfableData
& data
,
1403 const string
& cflagsMacro
,
1404 const string
& nasmflagsMacro
,
1405 const string
& windresflagsMacro
,
1406 const string
& widlflagsMacro
)
1410 const vector
<File
*>& files
= data
.files
;
1411 for ( i
= 0; i
< files
.size (); i
++ )
1413 GenerateCommands ( *files
[i
],
1420 fprintf ( fMakefile
,
1424 const vector
<If
*>& ifs
= data
.ifs
;
1425 for ( i
= 0; i
< ifs
.size(); i
++ )
1427 GenerateObjectFileTargets ( ifs
[i
]->data
,
1436 vector
<File
*> sourceFiles
;
1437 GetModuleSpecificSourceFiles ( sourceFiles
);
1438 for ( i
= 0; i
< sourceFiles
.size (); i
++ )
1440 GenerateCommands ( *sourceFiles
[i
],
1448 CleanupFileVector ( sourceFiles
);
1452 MingwModuleHandler::GenerateObjectFileTargets (
1455 const string
& cflagsMacro
,
1456 const string
& nasmflagsMacro
,
1457 const string
& windresflagsMacro
,
1458 const string
& widlflagsMacro
)
1462 const string
& pch_file
= module
.pch
->header
;
1463 string gch_file
= pch_file
+ ".gch";
1464 CLEAN_FILE(gch_file
);
1472 fprintf ( fMakefile
, "\t$(ECHO_PCH)\n" );
1475 "\t%s -o %s %s -g %s\n\n",
1476 ( module
.cplusplus
? cppc
.c_str() : cc
.c_str() ),
1478 cflagsMacro
.c_str(),
1483 GenerateObjectFileTargets ( module
.non_if_data
,
1490 fprintf ( fMakefile
, "\n" );
1494 MingwModuleHandler::GenerateArchiveTarget ( const string
& ar
,
1495 const string
& objs_macro
) const
1497 string
archiveFilename ( GetModuleArchiveFilename () );
1499 fprintf ( fMakefile
,
1501 archiveFilename
.c_str (),
1502 objs_macro
.c_str (),
1503 GetDirectory(archiveFilename
).c_str() );
1505 fprintf ( fMakefile
, "\t$(ECHO_AR)\n" );
1507 fprintf ( fMakefile
,
1510 objs_macro
.c_str ());
1512 GenerateCleanObjectsAsYouGoCode ();
1514 fprintf ( fMakefile
, "\n" );
1516 return archiveFilename
;
1520 MingwModuleHandler::GetCFlagsMacro () const
1522 return ssprintf ( "$(%s_CFLAGS)",
1523 module
.name
.c_str () );
1527 MingwModuleHandler::GetObjectsMacro ( const Module
& module
)
1529 return ssprintf ( "$(%s_OBJS)",
1530 module
.name
.c_str () );
1534 MingwModuleHandler::GetLinkingDependenciesMacro () const
1536 return ssprintf ( "$(%s_LINKDEPS)", module
.name
.c_str () );
1540 MingwModuleHandler::GetLibsMacro () const
1542 return ssprintf ( "$(%s_LIBS)", module
.name
.c_str () );
1546 MingwModuleHandler::GetLinkerMacro () const
1548 return ssprintf ( "$(%s_LFLAGS)",
1549 module
.name
.c_str () );
1553 MingwModuleHandler::GetModuleTargets ( const Module
& module
)
1555 if ( ReferenceObjects ( module
) )
1556 return GetObjectsMacro ( module
);
1558 return GetTargetFilename ( module
, NULL
);
1562 MingwModuleHandler::GenerateObjectMacro ()
1564 objectsMacro
= ssprintf ("%s_OBJS", module
.name
.c_str ());
1566 GenerateObjectMacros (
1569 &module
.linkerFlags
);
1571 // future references to the macro will be to get its values
1572 objectsMacro
= ssprintf ("$(%s)", objectsMacro
.c_str ());
1576 MingwModuleHandler::GenerateTargetMacro ()
1578 fprintf ( fMakefile
,
1580 GetTargetMacro ( module
, false ).c_str (),
1581 GetModuleTargets ( module
).c_str () );
1585 MingwModuleHandler::GenerateOtherMacros ()
1587 cflagsMacro
= ssprintf ("%s_CFLAGS", module
.name
.c_str ());
1588 nasmflagsMacro
= ssprintf ("%s_NASMFLAGS", module
.name
.c_str ());
1589 windresflagsMacro
= ssprintf ("%s_RCFLAGS", module
.name
.c_str ());
1590 widlflagsMacro
= ssprintf ("%s_WIDLFLAGS", module
.name
.c_str ());
1591 linkerflagsMacro
= ssprintf ("%s_LFLAGS", module
.name
.c_str ());
1592 libsMacro
= ssprintf("%s_LIBS", module
.name
.c_str ());
1593 linkDepsMacro
= ssprintf ("%s_LINKDEPS", module
.name
.c_str ());
1598 &module
.linkerFlags
);
1600 if ( module
.importLibrary
)
1603 const vector
<File
*>& files
= module
.non_if_data
.files
;
1604 for ( size_t i
= 0; i
< files
.size (); i
++ )
1606 File
& file
= *files
[i
];
1607 string extension
= GetExtension ( file
.name
);
1608 if ( extension
== ".spec" || extension
== ".SPEC" )
1609 GetSpecObjectDependencies ( s
, file
.name
);
1611 if ( s
.size () > 0 )
1616 linkDepsMacro
.c_str() );
1617 for ( size_t i
= 0; i
< s
.size(); i
++ )
1618 fprintf ( fMakefile
,
1621 fprintf ( fMakefile
, "\n" );
1625 string globalCflags
= "-g";
1626 if ( backend
->usePipe
)
1627 globalCflags
+= " -pipe";
1628 if ( !module
.enableWarnings
)
1629 globalCflags
+= " -Werror";
1633 "%s += $(PROJECT_CFLAGS) %s\n",
1634 cflagsMacro
.c_str (),
1635 globalCflags
.c_str () );
1639 "%s += $(PROJECT_RCFLAGS)\n",
1640 windresflagsMacro
.c_str () );
1644 "%s += $(PROJECT_WIDLFLAGS)\n",
1645 widlflagsMacro
.c_str () );
1649 "%s_LFLAGS += $(PROJECT_LFLAGS) -g\n",
1650 module
.name
.c_str () );
1655 linkDepsMacro
.c_str (),
1656 libsMacro
.c_str () );
1658 string cflags
= TypeSpecificCFlags();
1659 if ( cflags
.size() > 0 )
1661 fprintf ( fMakefile
,
1663 cflagsMacro
.c_str (),
1667 string nasmflags
= TypeSpecificNasmFlags();
1668 if ( nasmflags
.size () > 0 )
1670 fprintf ( fMakefile
,
1672 nasmflagsMacro
.c_str (),
1673 nasmflags
.c_str () );
1676 string linkerflags
= TypeSpecificLinkerFlags();
1677 if ( linkerflags
.size() > 0 )
1679 fprintf ( fMakefile
,
1681 linkerflagsMacro
.c_str (),
1682 linkerflags
.c_str () );
1685 fprintf ( fMakefile
, "\n\n" );
1687 // future references to the macros will be to get their values
1688 cflagsMacro
= ssprintf ("$(%s)", cflagsMacro
.c_str ());
1689 nasmflagsMacro
= ssprintf ("$(%s)", nasmflagsMacro
.c_str ());
1690 widlflagsMacro
= ssprintf ("$(%s)", widlflagsMacro
.c_str ());
1694 MingwModuleHandler::GenerateRules ()
1696 string cc
= ( module
.host
== HostTrue
? "${host_gcc}" : "${gcc}" );
1697 string cppc
= ( module
.host
== HostTrue
? "${host_gpp}" : "${gpp}" );
1698 string ar
= ( module
.host
== HostTrue
? "${host_ar}" : "${ar}" );
1700 string targetMacro
= GetTargetMacro ( module
);
1702 CLEAN_FILE ( targetMacro
);
1704 // generate phony target for module name
1705 fprintf ( fMakefile
, ".PHONY: %s\n",
1706 module
.name
.c_str () );
1707 string dependencies
= GetTargetMacro ( module
);
1708 if ( module
.type
== Test
)
1709 dependencies
+= " $(REGTESTS_RUN_TARGET)";
1710 fprintf ( fMakefile
, "%s: %s\n\n",
1711 module
.name
.c_str (),
1712 dependencies
.c_str () );
1713 if ( module
.type
== Test
)
1715 fprintf ( fMakefile
,
1717 targetMacro
.c_str ());
1720 if ( !ReferenceObjects ( module
) )
1722 string
ar_target ( GenerateArchiveTarget ( ar
, objectsMacro
) );
1723 if ( targetMacro
!= ar_target
)
1724 CLEAN_FILE ( ar_target
);
1727 GenerateObjectFileTargets ( cc
,
1736 MingwModuleHandler::GetInvocationDependencies (
1737 const Module
& module
,
1738 string_list
& dependencies
)
1740 for ( size_t i
= 0; i
< module
.invocations
.size (); i
++ )
1742 Invoke
& invoke
= *module
.invocations
[i
];
1743 if ( invoke
.invokeModule
== &module
)
1744 /* Protect against circular dependencies */
1746 invoke
.GetTargets ( dependencies
);
1751 MingwModuleHandler::GenerateInvocations () const
1753 if ( module
.invocations
.size () == 0 )
1756 size_t iend
= module
.invocations
.size ();
1757 for ( size_t i
= 0; i
< iend
; i
++ )
1759 const Invoke
& invoke
= *module
.invocations
[i
];
1761 if ( invoke
.invokeModule
->type
!= BuildTool
)
1763 throw InvalidBuildFileException ( module
.node
.location
,
1764 "Only modules of type buildtool can be invoked." );
1767 string invokeTarget
= module
.GetInvocationTarget ( i
);
1768 string_list invoke_targets
;
1769 assert ( invoke_targets
.size() );
1770 invoke
.GetTargets ( invoke_targets
);
1771 fprintf ( fMakefile
,
1773 invokeTarget
.c_str () );
1774 fprintf ( fMakefile
,
1776 invokeTarget
.c_str () );
1777 size_t j
, jend
= invoke_targets
.size();
1778 for ( j
= 0; j
< jend
; j
++ )
1780 fprintf ( fMakefile
,
1782 invoke_targets
[i
].c_str () );
1784 fprintf ( fMakefile
, "\n\n%s", invoke_targets
[0].c_str () );
1785 for ( j
= 1; j
< jend
; j
++ )
1786 fprintf ( fMakefile
,
1788 invoke_targets
[i
].c_str () );
1789 fprintf ( fMakefile
,
1791 NormalizeFilename ( invoke
.invokeModule
->GetPath () ).c_str () );
1792 fprintf ( fMakefile
, "\t$(ECHO_INVOKE)\n" );
1793 fprintf ( fMakefile
,
1795 NormalizeFilename ( invoke
.invokeModule
->GetPath () ).c_str (),
1796 invoke
.GetParameters ().c_str () );
1801 MingwModuleHandler::GetPreconditionDependenciesName () const
1803 return module
.name
+ "_precondition";
1807 MingwModuleHandler::GetDefaultDependencies (
1808 string_list
& dependencies
) const
1810 /* Avoid circular dependency */
1811 if ( module
.type
!= BuildTool
1812 && module
.name
!= "zlib"
1813 && module
.name
!= "hostzlib" )
1815 dependencies
.push_back ( "$(INIT)" );
1819 MingwModuleHandler::GeneratePreconditionDependencies ()
1821 string preconditionDependenciesName
= GetPreconditionDependenciesName ();
1822 string_list sourceFilenames
;
1823 GetSourceFilenamesWithoutGeneratedFiles ( sourceFilenames
);
1824 string_list dependencies
;
1825 GetDefaultDependencies ( dependencies
);
1826 GetModuleDependencies ( dependencies
);
1828 GetInvocationDependencies ( module
, dependencies
);
1830 if ( dependencies
.size() )
1832 fprintf ( fMakefile
,
1834 preconditionDependenciesName
.c_str () );
1835 for ( size_t i
= 0; i
< dependencies
.size(); i
++ )
1836 fprintf ( fMakefile
,
1838 dependencies
[i
].c_str () );
1839 fprintf ( fMakefile
, "\n\n" );
1842 for ( size_t i
= 0; i
< sourceFilenames
.size(); i
++ )
1844 fprintf ( fMakefile
,
1846 sourceFilenames
[i
].c_str(),
1847 preconditionDependenciesName
.c_str ());
1849 fprintf ( fMakefile
, "\n" );
1853 MingwModuleHandler::IsWineModule () const
1855 if ( module
.importLibrary
== NULL
)
1858 size_t index
= module
.importLibrary
->definition
.rfind ( ".spec.def" );
1859 return ( index
!= string::npos
);
1863 MingwModuleHandler::GetDefinitionFilename () const
1865 if ( module
.importLibrary
!= NULL
)
1867 string defFilename
= module
.GetBasePath () + SSEP
+ module
.importLibrary
->definition
;
1868 if ( IsWineModule () )
1869 return PassThruCacheDirectory ( NormalizeFilename ( defFilename
),
1870 backend
->intermediateDirectory
);
1875 return "tools" SSEP
"rbuild" SSEP
"empty.def";
1879 MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ()
1881 if ( module
.importLibrary
!= NULL
)
1883 string
library_target (
1884 GetImportLibraryFilename ( module
, &clean_files
) );
1885 string defFilename
= GetDefinitionFilename ();
1888 GetDefinitionDependencies ( deps
);
1890 fprintf ( fMakefile
, "# IMPORT LIBRARY RULE:\n" );
1892 fprintf ( fMakefile
, "%s: %s",
1893 library_target
.c_str (),
1894 defFilename
.c_str () );
1896 size_t i
, iend
= deps
.size();
1897 for ( i
= 0; i
< iend
; i
++ )
1898 fprintf ( fMakefile
, " %s",
1901 fprintf ( fMakefile
, " | %s\n",
1902 GetDirectory ( GetImportLibraryFilename ( module
, NULL
) ).c_str () );
1904 fprintf ( fMakefile
, "\t$(ECHO_DLLTOOL)\n" );
1906 string killAt
= module
.mangledSymbols
? "" : "--kill-at";
1907 fprintf ( fMakefile
,
1908 "\t${dlltool} --dllname %s --def %s --output-lib %s %s\n\n",
1909 module
.GetTargetName ().c_str (),
1910 defFilename
.c_str (),
1911 library_target
.c_str (),
1917 MingwModuleHandler::GetSpecObjectDependencies (
1918 string_list
& dependencies
,
1919 const string
& filename
) const
1921 string basename
= GetBasename ( filename
);
1922 string defDependency
= PassThruCacheDirectory (
1923 NormalizeFilename ( basename
+ ".spec.def" ),
1924 backend
->intermediateDirectory
);
1925 dependencies
.push_back ( defDependency
);
1926 string stubsDependency
= PassThruCacheDirectory (
1927 NormalizeFilename ( basename
+ ".stubs.c" ),
1928 backend
->intermediateDirectory
);
1929 dependencies
.push_back ( stubsDependency
);
1933 MingwModuleHandler::GetWidlObjectDependencies (
1934 string_list
& dependencies
,
1935 const string
& filename
) const
1937 string basename
= GetBasename ( filename
);
1938 string serverDependency
= PassThruCacheDirectory (
1939 NormalizeFilename ( basename
+ "_s.c" ),
1940 backend
->intermediateDirectory
);
1941 dependencies
.push_back ( serverDependency
);
1945 MingwModuleHandler::GetDefinitionDependencies (
1946 string_list
& dependencies
) const
1948 string dkNkmLibNoFixup
= "dk/nkm/lib";
1949 const vector
<File
*>& files
= module
.non_if_data
.files
;
1950 for ( size_t i
= 0; i
< files
.size (); i
++ )
1952 File
& file
= *files
[i
];
1953 string extension
= GetExtension ( file
.name
);
1954 if ( extension
== ".spec" || extension
== ".SPEC" )
1956 GetSpecObjectDependencies ( dependencies
, file
.name
);
1958 if ( extension
== ".idl" || extension
== ".IDL" )
1960 GetWidlObjectDependencies ( dependencies
, file
.name
);
1966 MingwBuildToolModuleHandler::MingwBuildToolModuleHandler ( const Module
& module_
)
1967 : MingwModuleHandler ( module_
)
1972 MingwBuildToolModuleHandler::Process ()
1974 GenerateBuildToolModuleTarget ();
1978 MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ()
1980 string
targetMacro ( GetTargetMacro (module
) );
1981 string objectsMacro
= GetObjectsMacro ( module
);
1982 string linkDepsMacro
= GetLinkingDependenciesMacro ();
1983 string libsMacro
= GetLibsMacro ();
1988 if ( module
.cplusplus
)
1989 linker
= "${host_gpp}";
1991 linker
= "${host_gcc}";
1993 fprintf ( fMakefile
, "%s: %s %s | %s\n",
1994 targetMacro
.c_str (),
1995 objectsMacro
.c_str (),
1996 linkDepsMacro
.c_str (),
1997 GetDirectory(GetTargetFilename(module
,NULL
)).c_str () );
1998 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
1999 fprintf ( fMakefile
,
2000 "\t%s %s -o $@ %s %s\n\n",
2002 GetLinkerMacro ().c_str (),
2003 objectsMacro
.c_str (),
2004 libsMacro
.c_str () );
2008 MingwKernelModuleHandler::MingwKernelModuleHandler (
2009 const Module
& module_
)
2011 : MingwModuleHandler ( module_
)
2016 MingwKernelModuleHandler::Process ()
2018 GenerateKernelModuleTarget ();
2022 MingwKernelModuleHandler::GenerateKernelModuleTarget ()
2024 string
targetMacro ( GetTargetMacro ( module
) );
2025 string workingDirectory
= GetWorkingDirectory ( );
2026 string objectsMacro
= GetObjectsMacro ( module
);
2027 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2028 string libsMacro
= GetLibsMacro ();
2030 GenerateImportLibraryTargetIfNeeded ();
2032 if ( module
.non_if_data
.files
.size () > 0 )
2036 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2038 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",
2039 module
.GetBasePath ().c_str (),
2040 module
.entrypoint
.c_str (),
2041 module
.baseaddress
.c_str () );
2042 GenerateLinkerCommand ( dependencies
,
2050 GeneratePhonyTarget();
2055 MingwStaticLibraryModuleHandler::MingwStaticLibraryModuleHandler (
2056 const Module
& module_
)
2058 : MingwModuleHandler ( module_
)
2063 MingwStaticLibraryModuleHandler::Process ()
2065 GenerateStaticLibraryModuleTarget ();
2069 MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget ()
2075 MingwObjectLibraryModuleHandler::MingwObjectLibraryModuleHandler (
2076 const Module
& module_
)
2078 : MingwModuleHandler ( module_
)
2083 MingwObjectLibraryModuleHandler::Process ()
2085 GenerateObjectLibraryModuleTarget ();
2089 MingwObjectLibraryModuleHandler::GenerateObjectLibraryModuleTarget ()
2095 MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler (
2096 const Module
& module_
)
2098 : MingwModuleHandler ( module_
)
2103 MingwKernelModeDLLModuleHandler::Process ()
2105 GenerateKernelModeDLLModuleTarget ();
2109 MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ()
2111 string
targetMacro ( GetTargetMacro ( module
) );
2112 string workingDirectory
= GetWorkingDirectory ( );
2113 string objectsMacro
= GetObjectsMacro ( module
);
2114 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2115 string libsMacro
= GetLibsMacro ();
2117 GenerateImportLibraryTargetIfNeeded ();
2119 if ( module
.non_if_data
.files
.size () > 0 )
2123 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2125 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll --dll",
2126 module
.entrypoint
.c_str (),
2127 module
.baseaddress
.c_str () );
2128 GenerateLinkerCommand ( dependencies
,
2136 GeneratePhonyTarget();
2141 MingwKernelModeDriverModuleHandler::MingwKernelModeDriverModuleHandler (
2142 const Module
& module_
)
2144 : MingwModuleHandler ( module_
)
2149 MingwKernelModeDriverModuleHandler::Process ()
2151 GenerateKernelModeDriverModuleTarget ();
2156 MingwKernelModeDriverModuleHandler::GenerateKernelModeDriverModuleTarget ()
2158 string
targetMacro ( GetTargetMacro (module
) );
2159 string workingDirectory
= GetWorkingDirectory ();
2160 string objectsMacro
= GetObjectsMacro ( module
);
2161 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2162 string libsMacro
= GetLibsMacro ();
2164 GenerateImportLibraryTargetIfNeeded ();
2166 if ( module
.non_if_data
.files
.size () > 0 )
2170 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2172 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll --dll",
2173 module
.entrypoint
.c_str (),
2174 module
.baseaddress
.c_str () );
2175 GenerateLinkerCommand ( dependencies
,
2183 GeneratePhonyTarget();
2188 MingwNativeDLLModuleHandler::MingwNativeDLLModuleHandler (
2189 const Module
& module_
)
2191 : MingwModuleHandler ( module_
)
2196 MingwNativeDLLModuleHandler::Process ()
2198 GenerateNativeDLLModuleTarget ();
2202 MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ()
2204 string
targetMacro ( GetTargetMacro (module
) );
2205 string workingDirectory
= GetWorkingDirectory ( );
2206 string objectsMacro
= GetObjectsMacro ( module
);
2207 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2208 string libsMacro
= GetLibsMacro ();
2210 GenerateImportLibraryTargetIfNeeded ();
2212 if ( module
.non_if_data
.files
.size () > 0 )
2216 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2218 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",
2219 module
.entrypoint
.c_str (),
2220 module
.baseaddress
.c_str () );
2221 GenerateLinkerCommand ( dependencies
,
2229 GeneratePhonyTarget();
2234 MingwNativeCUIModuleHandler::MingwNativeCUIModuleHandler (
2235 const Module
& module_
)
2237 : MingwModuleHandler ( module_
)
2242 MingwNativeCUIModuleHandler::Process ()
2244 GenerateNativeCUIModuleTarget ();
2248 MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ()
2250 string
targetMacro ( GetTargetMacro (module
) );
2251 string workingDirectory
= GetWorkingDirectory ( );
2252 string objectsMacro
= GetObjectsMacro ( module
);
2253 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2254 string libsMacro
= GetLibsMacro ();
2256 GenerateImportLibraryTargetIfNeeded ();
2258 if ( module
.non_if_data
.files
.size () > 0 )
2262 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2264 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib",
2265 module
.entrypoint
.c_str (),
2266 module
.baseaddress
.c_str () );
2267 GenerateLinkerCommand ( dependencies
,
2275 GeneratePhonyTarget();
2280 MingwWin32DLLModuleHandler::MingwWin32DLLModuleHandler (
2281 const Module
& module_
)
2283 : MingwModuleHandler ( module_
)
2288 MingwWin32DLLModuleHandler::Process ()
2290 GenerateWin32DLLModuleTarget ();
2294 MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ()
2296 string
targetMacro ( GetTargetMacro (module
) );
2297 string workingDirectory
= GetWorkingDirectory ( );
2298 string objectsMacro
= GetObjectsMacro ( module
);
2299 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2300 string libsMacro
= GetLibsMacro ();
2302 GenerateImportLibraryTargetIfNeeded ();
2304 if ( module
.non_if_data
.files
.size () > 0 )
2308 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2311 if ( module
.cplusplus
)
2316 string linkerParameters
= ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -mdll --dll",
2317 module
.entrypoint
.c_str (),
2318 module
.baseaddress
.c_str () );
2319 GenerateLinkerCommand ( dependencies
,
2327 GeneratePhonyTarget();
2332 MingwWin32CUIModuleHandler::MingwWin32CUIModuleHandler (
2333 const Module
& module_
)
2335 : MingwModuleHandler ( module_
)
2340 MingwWin32CUIModuleHandler::Process ()
2342 GenerateWin32CUIModuleTarget ();
2346 MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ()
2348 string
targetMacro ( GetTargetMacro (module
) );
2349 string workingDirectory
= GetWorkingDirectory ( );
2350 string objectsMacro
= GetObjectsMacro ( module
);
2351 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2352 string libsMacro
= GetLibsMacro ();
2354 GenerateImportLibraryTargetIfNeeded ();
2356 if ( module
.non_if_data
.files
.size () > 0 )
2360 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2363 if ( module
.cplusplus
)
2368 string linkerParameters
= ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
2369 module
.entrypoint
.c_str (),
2370 module
.baseaddress
.c_str () );
2371 GenerateLinkerCommand ( dependencies
,
2379 GeneratePhonyTarget();
2384 MingwWin32GUIModuleHandler::MingwWin32GUIModuleHandler (
2385 const Module
& module_
)
2387 : MingwModuleHandler ( module_
)
2392 MingwWin32GUIModuleHandler::Process ()
2394 GenerateWin32GUIModuleTarget ();
2398 MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ()
2400 string
targetMacro ( GetTargetMacro (module
) );
2401 string workingDirectory
= GetWorkingDirectory ( );
2402 string objectsMacro
= GetObjectsMacro ( module
);
2403 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2404 string libsMacro
= GetLibsMacro ();
2406 GenerateImportLibraryTargetIfNeeded ();
2408 if ( module
.non_if_data
.files
.size () > 0 )
2412 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2415 if ( module
.cplusplus
)
2420 string linkerParameters
= ssprintf ( "-Wl,--subsystem,windows -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
2421 module
.entrypoint
.c_str (),
2422 module
.baseaddress
.c_str () );
2423 GenerateLinkerCommand ( dependencies
,
2431 GeneratePhonyTarget();
2436 MingwBootLoaderModuleHandler::MingwBootLoaderModuleHandler (
2437 const Module
& module_
)
2439 : MingwModuleHandler ( module_
)
2444 MingwBootLoaderModuleHandler::Process ()
2446 GenerateBootLoaderModuleTarget ();
2450 MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ()
2452 string
targetName ( module
.GetTargetName () );
2453 string
targetMacro ( GetTargetMacro (module
) );
2454 string workingDirectory
= GetWorkingDirectory ();
2455 string junk_tmp
= ros_temp
+ module
.name
+ ".junk.tmp";
2456 CLEAN_FILE ( junk_tmp
);
2457 string objectsMacro
= GetObjectsMacro ( module
);
2458 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2459 string libsMacro
= GetLibsMacro ();
2463 fprintf ( fMakefile
, "%s: %s %s | %s\n",
2464 targetMacro
.c_str (),
2465 objectsMacro
.c_str (),
2466 linkDepsMacro
.c_str (),
2467 GetDirectory(GetTargetFilename(module
,NULL
)).c_str () );
2469 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
2471 fprintf ( fMakefile
,
2472 "\t${ld} %s -N -Ttext=0x8000 -o %s %s %s\n",
2473 GetLinkerMacro ().c_str (),
2475 objectsMacro
.c_str (),
2476 linkDepsMacro
.c_str () );
2477 fprintf ( fMakefile
,
2478 "\t${objcopy} -O binary %s $@\n",
2479 junk_tmp
.c_str () );
2480 fprintf ( fMakefile
,
2481 "\t-@${rm} %s 2>$(NUL)\n",
2482 junk_tmp
.c_str () );
2486 MingwBootSectorModuleHandler::MingwBootSectorModuleHandler (
2487 const Module
& module_
)
2489 : MingwModuleHandler ( module_
)
2494 MingwBootSectorModuleHandler::Process ()
2496 GenerateBootSectorModuleTarget ();
2500 MingwBootSectorModuleHandler::GenerateBootSectorModuleTarget ()
2502 string objectsMacro
= GetObjectsMacro ( module
);
2506 fprintf ( fMakefile
, ".PHONY: %s\n\n",
2507 module
.name
.c_str ());
2508 fprintf ( fMakefile
,
2510 module
.name
.c_str (),
2511 objectsMacro
.c_str () );
2515 MingwIsoModuleHandler::MingwIsoModuleHandler (
2516 const Module
& module_
)
2518 : MingwModuleHandler ( module_
)
2523 MingwIsoModuleHandler::Process ()
2525 GenerateIsoModuleTarget ();
2529 MingwIsoModuleHandler::OutputBootstrapfileCopyCommands (
2530 const string
& bootcdDirectory
)
2532 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
2534 const Module
& m
= *module
.project
.modules
[i
];
2535 if ( m
.bootstrap
!= NULL
)
2537 string sourceFilename
= PassThruCacheDirectory (
2538 NormalizeFilename ( m
.GetPath () ),
2539 backend
->outputDirectory
);
2540 string
targetFilenameNoFixup ( bootcdDirectory
+ SSEP
+ m
.bootstrap
->base
+ SSEP
+ m
.bootstrap
->nameoncd
);
2541 string targetFilename
= MingwModuleHandler::PassThruCacheDirectory (
2542 NormalizeFilename ( targetFilenameNoFixup
),
2543 backend
->outputDirectory
);
2544 fprintf ( fMakefile
,
2546 fprintf ( fMakefile
,
2547 "\t${cp} %s %s 1>$(NUL)\n",
2548 sourceFilename
.c_str (),
2549 targetFilename
.c_str () );
2555 MingwIsoModuleHandler::OutputCdfileCopyCommands (
2556 const string
& bootcdDirectory
)
2558 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
2560 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
2561 string targetFilenameNoFixup
= bootcdDirectory
+ SSEP
+ cdfile
.base
+ SSEP
+ cdfile
.nameoncd
;
2562 string targetFilename
= MingwModuleHandler::PassThruCacheDirectory (
2563 NormalizeFilename ( targetFilenameNoFixup
),
2564 backend
->outputDirectory
);
2565 fprintf ( fMakefile
,
2567 fprintf ( fMakefile
,
2568 "\t${cp} %s %s 1>$(NUL)\n",
2569 cdfile
.GetPath ().c_str (),
2570 targetFilename
.c_str () );
2575 MingwIsoModuleHandler::GetBootstrapCdDirectories ( const string
& bootcdDirectory
)
2578 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
2580 const Module
& m
= *module
.project
.modules
[i
];
2581 if ( m
.bootstrap
!= NULL
)
2583 string
targetDirectory ( bootcdDirectory
+ SSEP
+ m
.bootstrap
->base
);
2584 if ( directories
.size () > 0 )
2586 directories
+= PassThruCacheDirectory (
2587 NormalizeFilename ( targetDirectory
),
2588 backend
->outputDirectory
);
2595 MingwIsoModuleHandler::GetNonModuleCdDirectories ( const string
& bootcdDirectory
)
2598 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
2600 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
2601 string
targetDirectory ( bootcdDirectory
+ SSEP
+ cdfile
.base
);
2602 if ( directories
.size () > 0 )
2604 directories
+= PassThruCacheDirectory (
2605 NormalizeFilename ( targetDirectory
),
2606 backend
->outputDirectory
);
2612 MingwIsoModuleHandler::GetCdDirectories ( const string
& bootcdDirectory
)
2614 string directories
= GetBootstrapCdDirectories ( bootcdDirectory
);
2615 directories
+= " " + GetNonModuleCdDirectories ( bootcdDirectory
);
2620 MingwIsoModuleHandler::GetBootstrapCdFiles (
2621 vector
<string
>& out
) const
2623 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
2625 const Module
& m
= *module
.project
.modules
[i
];
2626 if ( m
.bootstrap
!= NULL
)
2628 string filename
= PassThruCacheDirectory (
2629 NormalizeFilename ( m
.GetPath () ),
2630 backend
->outputDirectory
);
2631 out
.push_back ( filename
);
2637 MingwIsoModuleHandler::GetNonModuleCdFiles (
2638 vector
<string
>& out
) const
2640 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
2642 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
2643 out
.push_back ( cdfile
.GetPath () );
2648 MingwIsoModuleHandler::GetCdFiles (
2649 vector
<string
>& out
) const
2651 GetBootstrapCdFiles ( out
);
2652 GetNonModuleCdFiles ( out
);
2656 MingwIsoModuleHandler::GenerateIsoModuleTarget ()
2658 string bootcdDirectory
= "cd";
2659 string bootcd
= PassThruCacheDirectory (
2660 NormalizeFilename ( bootcdDirectory
+ SSEP
),
2661 backend
->outputDirectory
);
2662 string isoboot
= PassThruCacheDirectory (
2663 NormalizeFilename ( "boot" SSEP
"freeldr" SSEP
"bootsect" SSEP
"isoboot.o" ),
2664 backend
->outputDirectory
);
2665 string bootcdReactosNoFixup
= bootcdDirectory
+ SSEP
"reactos";
2666 string bootcdReactos
= PassThruCacheDirectory (
2667 NormalizeFilename ( bootcdReactosNoFixup
+ SSEP
),
2668 backend
->outputDirectory
);
2669 CLEAN_FILE ( bootcdReactos
);
2670 string reactosInf
= PassThruCacheDirectory (
2671 NormalizeFilename ( bootcdReactosNoFixup
+ SSEP
"reactos.inf" ),
2672 backend
->outputDirectory
);
2673 string reactosDff
= NormalizeFilename ( "bootdata" SSEP
"packages" SSEP
"reactos.dff" );
2674 string cdDirectories
= GetCdDirectories ( bootcdDirectory
);
2675 vector
<string
> vCdFiles
;
2676 GetCdFiles ( vCdFiles
);
2677 string cdFiles
= v2s ( vCdFiles
, 5 );
2679 fprintf ( fMakefile
, ".PHONY: %s\n\n",
2680 module
.name
.c_str ());
2681 fprintf ( fMakefile
,
2682 "%s: all %s %s %s %s $(CABMAN_TARGET) $(CDMAKE_TARGET)\n",
2683 module
.name
.c_str (),
2685 bootcdReactos
.c_str (),
2686 cdDirectories
.c_str (),
2688 fprintf ( fMakefile
, "\t$(ECHO_CABMAN)\n" );
2689 fprintf ( fMakefile
,
2690 "\t$(Q)$(CABMAN_TARGET) -C %s -L %s -I -P $(OUTPUT)\n",
2691 reactosDff
.c_str (),
2692 bootcdReactos
.c_str () );
2693 fprintf ( fMakefile
,
2694 "\t$(Q)$(CABMAN_TARGET) -C %s -RC %s -L %s -N -P $(OUTPUT)\n",
2695 reactosDff
.c_str (),
2696 reactosInf
.c_str (),
2697 bootcdReactos
.c_str ());
2698 fprintf ( fMakefile
,
2699 "\t-@${rm} %s 2>$(NUL)\n",
2700 reactosInf
.c_str () );
2701 OutputBootstrapfileCopyCommands ( bootcdDirectory
);
2702 OutputCdfileCopyCommands ( bootcdDirectory
);
2703 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
2704 fprintf ( fMakefile
,
2705 "\t$(Q)$(CDMAKE_TARGET) -v -m -b %s %s REACTOS ReactOS.iso\n",
2708 fprintf ( fMakefile
,
2713 MingwLiveIsoModuleHandler::MingwLiveIsoModuleHandler (
2714 const Module
& module_
)
2716 : MingwModuleHandler ( module_
)
2721 MingwLiveIsoModuleHandler::Process ()
2723 GenerateLiveIsoModuleTarget ();
2727 MingwLiveIsoModuleHandler::CreateDirectory ( const string
& directory
)
2729 string normalizedDirectory
= MingwModuleHandler::PassThruCacheDirectory (
2730 NormalizeFilename ( directory
) + SSEP
,
2731 backend
->outputDirectory
);
2735 MingwLiveIsoModuleHandler::OutputCopyCommand ( const string
& sourceFilename
,
2736 const string
& targetFilename
,
2737 const string
& targetDirectory
)
2739 string normalizedTargetFilename
= MingwModuleHandler::PassThruCacheDirectory (
2740 NormalizeFilename ( targetDirectory
+ SSEP
+ targetFilename
),
2741 backend
->outputDirectory
);
2742 fprintf ( fMakefile
,
2744 fprintf ( fMakefile
,
2745 "\t${cp} %s %s 1>$(NUL)\n",
2746 sourceFilename
.c_str (),
2747 normalizedTargetFilename
.c_str () );
2751 MingwLiveIsoModuleHandler::OutputModuleCopyCommands ( string
& livecdDirectory
,
2752 string
& reactosDirectory
)
2754 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
2756 const Module
& m
= *module
.project
.modules
[i
];
2757 if ( m
.installName
.length () > 0 )
2759 string sourceFilename
= MingwModuleHandler::PassThruCacheDirectory (
2760 NormalizeFilename ( m
.GetPath () ),
2761 backend
->outputDirectory
);
2762 OutputCopyCommand ( sourceFilename
,
2764 livecdDirectory
+ SSEP
+ reactosDirectory
+ SSEP
+ m
.installBase
);
2770 MingwLiveIsoModuleHandler::OutputNonModuleCopyCommands ( string
& livecdDirectory
,
2771 string
& reactosDirectory
)
2773 for ( size_t i
= 0; i
< module
.project
.installfiles
.size (); i
++ )
2775 const InstallFile
& installfile
= *module
.project
.installfiles
[i
];
2776 OutputCopyCommand ( installfile
.GetPath (),
2777 installfile
.newname
,
2778 livecdDirectory
+ SSEP
+ reactosDirectory
+ SSEP
+ installfile
.base
);
2783 MingwLiveIsoModuleHandler::OutputProfilesDirectoryCommands ( string
& livecdDirectory
)
2785 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" );
2786 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" SSEP
"All Users") ;
2787 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" SSEP
"All Users" SSEP
"Desktop" );
2788 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" SSEP
"Default User" );
2789 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" SSEP
"Default User" SSEP
"Desktop" );
2790 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" SSEP
"Default User" SSEP
"My Documents" );
2792 string livecdIni
= "bootdata" SSEP
"livecd.ini";
2793 OutputCopyCommand ( livecdIni
,
2799 MingwLiveIsoModuleHandler::OutputLoaderCommands ( string
& livecdDirectory
)
2801 string freeldr
= PassThruCacheDirectory (
2802 NormalizeFilename ( "boot" SSEP
"freeldr" SSEP
"freeldr" SSEP
"freeldr.sys" ),
2803 backend
->outputDirectory
);
2804 CreateDirectory ( livecdDirectory
+ SSEP
"loader" );
2805 OutputCopyCommand ( freeldr
,
2807 livecdDirectory
+ SSEP
+ "loader" );
2811 MingwLiveIsoModuleHandler::OutputRegistryCommands ( string
& livecdDirectory
)
2813 string reactosSystem32ConfigDirectory
= NormalizeFilename (
2814 MingwModuleHandler::PassThruCacheDirectory (
2815 livecdDirectory
+ SSEP
"reactos" SSEP
"system32" SSEP
"config" SSEP
,
2816 backend
->outputDirectory
) );
2817 fprintf ( fMakefile
,
2818 "\t$(ECHO_MKHIVE)\n" );
2819 fprintf ( fMakefile
,
2820 "\t$(MKHIVE_TARGET) bootdata %s bootdata" SSEP
"livecd.inf bootdata" SSEP
"hiveinst.inf\n",
2821 reactosSystem32ConfigDirectory
.c_str () );
2825 MingwLiveIsoModuleHandler::GenerateLiveIsoModuleTarget ()
2827 string livecdDirectory
= "livecd";
2828 string livecd
= PassThruCacheDirectory (
2829 NormalizeFilename ( livecdDirectory
+ SSEP
),
2830 backend
->outputDirectory
);
2831 string isoboot
= PassThruCacheDirectory (
2832 NormalizeFilename ( "boot" SSEP
"freeldr" SSEP
"bootsect" SSEP
"isoboot.o" ),
2833 backend
->outputDirectory
);
2834 string reactosDirectory
= "reactos";
2835 string livecdReactosNoFixup
= livecdDirectory
+ SSEP
+ reactosDirectory
;
2836 string livecdReactos
= NormalizeFilename ( PassThruCacheDirectory (
2837 NormalizeFilename ( livecdReactosNoFixup
+ SSEP
),
2838 backend
->outputDirectory
) );
2839 CLEAN_FILE ( livecdReactos
);
2841 fprintf ( fMakefile
, ".PHONY: %s\n\n",
2842 module
.name
.c_str ());
2843 fprintf ( fMakefile
,
2844 "%s: all %s %s $(MKHIVE_TARGET) $(CDMAKE_TARGET)\n",
2845 module
.name
.c_str (),
2847 livecdReactos
.c_str () );
2848 OutputModuleCopyCommands ( livecdDirectory
,
2850 OutputNonModuleCopyCommands ( livecdDirectory
,
2852 OutputProfilesDirectoryCommands ( livecdDirectory
);
2853 OutputLoaderCommands ( livecdDirectory
);
2854 OutputRegistryCommands ( livecdDirectory
);
2855 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
2856 fprintf ( fMakefile
,
2857 "\t$(Q)$(CDMAKE_TARGET) -v -m -j -b %s %s REACTOS ReactOS-LiveCD.iso\n",
2860 fprintf ( fMakefile
,
2865 MingwTestModuleHandler::MingwTestModuleHandler (
2866 const Module
& module_
)
2868 : MingwModuleHandler ( module_
)
2873 MingwTestModuleHandler::Process ()
2875 GenerateTestModuleTarget ();
2879 MingwTestModuleHandler::GetModuleSpecificSourceFiles ( vector
<File
*>& sourceFiles
)
2881 string basePath
= "$(INTERMEDIATE)" SSEP
+ module
.GetBasePath ();
2882 sourceFiles
.push_back ( new File ( basePath
+ SSEP
"_hooks.c", false, "" ) );
2883 sourceFiles
.push_back ( new File ( basePath
+ SSEP
"_stubs.S", false, "" ) );
2884 sourceFiles
.push_back ( new File ( basePath
+ SSEP
"_startup.c", false, "" ) );
2888 MingwTestModuleHandler::GenerateTestModuleTarget ()
2890 string
targetMacro ( GetTargetMacro ( module
) );
2891 string workingDirectory
= GetWorkingDirectory ( );
2892 string objectsMacro
= GetObjectsMacro ( module
);
2893 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2894 string libsMacro
= GetLibsMacro ();
2896 GenerateImportLibraryTargetIfNeeded ();
2898 if ( module
.non_if_data
.files
.size () > 0 )
2902 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2905 if ( module
.cplusplus
)
2910 string linkerParameters
= ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
2911 module
.entrypoint
.c_str (),
2912 module
.baseaddress
.c_str () );
2913 GenerateLinkerCommand ( dependencies
,
2921 GeneratePhonyTarget();
2926 MingwRpcServerModuleHandler::MingwRpcServerModuleHandler (
2927 const Module
& module_
)
2929 : MingwModuleHandler ( module_
)
2934 MingwRpcServerModuleHandler::Process ()
2939 MingwRpcClientModuleHandler::MingwRpcClientModuleHandler (
2940 const Module
& module_
)
2942 : MingwModuleHandler ( module_
)
2947 MingwRpcClientModuleHandler::Process ()