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 */
113 return generatedFilesDirectory
+ SSEP
+ file
;
117 MingwModuleHandler::GetTargetFilename (
118 const Module
& module
,
119 string_list
* pclean_files
)
121 string target
= PassThruCacheDirectory (
122 NormalizeFilename ( module
.GetPath () ),
123 backend
->outputDirectory
);
126 string_list
& clean_files
= *pclean_files
;
127 CLEAN_FILE ( target
);
133 MingwModuleHandler::GetImportLibraryFilename (
134 const Module
& module
,
135 string_list
* pclean_files
)
137 string target
= PassThruCacheDirectory (
138 NormalizeFilename ( module
.GetDependencyPath () ),
139 backend
->outputDirectory
);
142 string_list
& clean_files
= *pclean_files
;
143 CLEAN_FILE ( target
);
148 /*static*/ MingwModuleHandler
*
149 MingwModuleHandler::InstanciateHandler (
150 const Module
& module
,
151 MingwBackend
* backend
)
153 MingwModuleHandler
* handler
;
154 switch ( module
.type
)
157 handler
= new MingwBuildToolModuleHandler ( module
);
160 handler
= new MingwStaticLibraryModuleHandler ( module
);
163 handler
= new MingwObjectLibraryModuleHandler ( module
);
166 handler
= new MingwKernelModuleHandler ( module
);
169 handler
= new MingwNativeCUIModuleHandler ( module
);
172 handler
= new MingwWin32CUIModuleHandler ( module
);
175 handler
= new MingwWin32GUIModuleHandler ( module
);
178 handler
= new MingwKernelModeDLLModuleHandler ( module
);
181 handler
= new MingwNativeDLLModuleHandler ( module
);
184 handler
= new MingwWin32DLLModuleHandler ( module
);
186 case KernelModeDriver
:
187 handler
= new MingwKernelModeDriverModuleHandler ( module
);
190 handler
= new MingwBootLoaderModuleHandler ( module
);
193 handler
= new MingwBootSectorModuleHandler ( module
);
196 handler
= new MingwIsoModuleHandler ( module
);
199 handler
= new MingwLiveIsoModuleHandler ( module
);
202 handler
= new MingwTestModuleHandler ( module
);
205 handler
= new MingwRpcServerModuleHandler ( module
);
208 handler
= new MingwRpcClientModuleHandler ( module
);
211 throw UnknownModuleTypeException (
212 module
.node
.location
,
220 MingwModuleHandler::GetWorkingDirectory () const
226 MingwModuleHandler::GetBasename ( const string
& filename
) const
228 size_t index
= filename
.find_last_of ( '.' );
229 if ( index
!= string::npos
)
230 return filename
.substr ( 0, index
);
235 MingwModuleHandler::GetActualSourceFilename (
236 const string
& filename
) const
238 string extension
= GetExtension ( filename
);
239 if ( extension
== ".spec" || extension
== ".SPEC" )
241 string basename
= GetBasename ( filename
);
242 return PassThruCacheDirectory ( NormalizeFilename ( basename
+ ".stubs.c" ),
243 backend
->intermediateDirectory
);
245 else if ( extension
== ".idl" || extension
== ".IDL" )
247 string basename
= GetBasename ( filename
);
249 if ( module
.type
== RpcServer
)
250 newname
= basename
+ "_s.c";
252 newname
= basename
+ "_c.c";
253 return PassThruCacheDirectory ( NormalizeFilename ( newname
),
254 backend
->intermediateDirectory
);
261 MingwModuleHandler::GetModuleArchiveFilename () const
263 if ( module
.type
== StaticLibrary
)
264 return GetTargetFilename ( module
, NULL
);
265 return PassThruCacheDirectory ( ReplaceExtension (
266 NormalizeFilename ( module
.GetPath () ),
268 backend
->intermediateDirectory
);
272 MingwModuleHandler::IsGeneratedFile ( const File
& file
) const
274 string extension
= GetExtension ( file
.name
);
275 return ( extension
== ".spec" || extension
== ".SPEC" );
279 MingwModuleHandler::ReferenceObjects (
280 const Module
& module
)
282 if ( module
.type
== ObjectLibrary
)
284 if ( module
.type
== RpcServer
)
286 if ( module
.type
== RpcClient
)
292 MingwModuleHandler::GetImportLibraryDependency (
293 const Module
& importedModule
)
296 if ( ReferenceObjects ( importedModule
) )
297 dep
= GetTargetMacro ( importedModule
);
299 dep
= GetImportLibraryFilename ( importedModule
, NULL
);
304 MingwModuleHandler::GetTargets ( const Module
& dependencyModule
,
305 string_list
& targets
)
307 if ( dependencyModule
.invocations
.size () > 0 )
309 for ( size_t i
= 0; i
< dependencyModule
.invocations
.size (); i
++ )
311 Invoke
& invoke
= *dependencyModule
.invocations
[i
];
312 invoke
.GetTargets ( targets
);
316 targets
.push_back ( GetImportLibraryDependency ( dependencyModule
) );
320 MingwModuleHandler::GetModuleDependencies (
321 string_list
& dependencies
)
323 size_t iend
= module
.dependencies
.size ();
328 for ( size_t i
= 0; i
< iend
; i
++ )
330 const Dependency
& dependency
= *module
.dependencies
[i
];
331 const Module
& dependencyModule
= *dependency
.dependencyModule
;
332 GetTargets ( dependencyModule
,
335 GetDefinitionDependencies ( dependencies
);
339 MingwModuleHandler::GetSourceFilenames (
341 bool includeGeneratedFiles
) const
345 const vector
<File
*>& files
= module
.non_if_data
.files
;
346 for ( i
= 0; i
< files
.size (); i
++ )
348 if ( includeGeneratedFiles
|| !IsGeneratedFile ( *files
[i
] ) )
351 GetActualSourceFilename ( files
[i
]->name
) );
354 // intentionally make a copy so that we can append more work in
355 // the middle of processing without having to go recursive
356 vector
<If
*> v
= module
.non_if_data
.ifs
;
357 for ( i
= 0; i
< v
.size (); i
++ )
361 // check for sub-ifs to add to list
362 const vector
<If
*>& ifs
= rIf
.data
.ifs
;
363 for ( j
= 0; j
< ifs
.size (); j
++ )
364 v
.push_back ( ifs
[j
] );
365 const vector
<File
*>& files
= rIf
.data
.files
;
366 for ( j
= 0; j
< files
.size (); j
++ )
368 File
& file
= *files
[j
];
369 if ( includeGeneratedFiles
|| !IsGeneratedFile ( file
) )
372 GetActualSourceFilename ( file
.name
) );
379 MingwModuleHandler::GetSourceFilenamesWithoutGeneratedFiles (
380 string_list
& list
) const
382 GetSourceFilenames ( list
, false );
386 MingwModuleHandler::GetObjectFilename (
387 const string
& sourceFilename
,
388 string_list
* pclean_files
) const
390 Directory
* directoryTree
;
393 string extension
= GetExtension ( sourceFilename
);
394 if ( extension
== ".rc" || extension
== ".RC" )
395 newExtension
= ".coff";
396 else if ( extension
== ".spec" || extension
== ".SPEC" )
397 newExtension
= ".stubs.o";
398 else if ( extension
== ".idl" || extension
== ".IDL" )
400 if ( module
.type
== RpcServer
)
401 newExtension
= "_s.o";
403 newExtension
= "_c.o";
408 if ( module
.type
== BootSector
)
409 directoryTree
= backend
->outputDirectory
;
411 directoryTree
= backend
->intermediateDirectory
;
413 string obj_file
= PassThruCacheDirectory (
414 NormalizeFilename ( ReplaceExtension (
415 RemoveVariables ( sourceFilename
),
420 string_list
& clean_files
= *pclean_files
;
421 CLEAN_FILE ( obj_file
);
427 MingwModuleHandler::GenerateCleanTarget () const
429 if ( 0 == clean_files
.size() )
431 fprintf ( fMakefile
, ".PHONY: %s_clean\n", module
.name
.c_str() );
432 fprintf ( fMakefile
, "%s_clean:\n\t-@${rm}", module
.name
.c_str() );
433 for ( size_t i
= 0; i
< clean_files
.size(); i
++ )
436 fprintf ( fMakefile
, " 2>$(NUL)\n\t-@${rm}" );
437 fprintf ( fMakefile
, " %s", clean_files
[i
].c_str() );
439 fprintf ( fMakefile
, " 2>$(NUL)\n" );
440 fprintf ( fMakefile
, "clean: %s_clean\n\n", module
.name
.c_str() );
444 MingwModuleHandler::GetObjectFilenames ()
446 const vector
<File
*>& files
= module
.non_if_data
.files
;
447 if ( files
.size () == 0 )
450 string
objectFilenames ( "" );
451 for ( size_t i
= 0; i
< files
.size (); i
++ )
453 if ( objectFilenames
.size () > 0 )
454 objectFilenames
+= " ";
456 GetObjectFilename ( files
[i
]->name
, NULL
);
458 return objectFilenames
;
462 MingwModuleHandler::GenerateGccDefineParametersFromVector (
463 const vector
<Define
*>& defines
) const
466 for ( size_t i
= 0; i
< defines
.size (); i
++ )
468 Define
& define
= *defines
[i
];
469 if (parameters
.length () > 0)
472 parameters
+= define
.name
;
473 if (define
.value
.length () > 0)
476 parameters
+= define
.value
;
483 MingwModuleHandler::GenerateGccDefineParameters () const
485 string parameters
= GenerateGccDefineParametersFromVector ( module
.project
.non_if_data
.defines
);
486 string s
= GenerateGccDefineParametersFromVector ( module
.non_if_data
.defines
);
487 if ( s
.length () > 0 )
496 MingwModuleHandler::ConcatenatePaths (
498 const string
& path2
) const
500 if ( ( path1
.length () == 0 ) || ( path1
== "." ) || ( path1
== "./" ) )
502 if ( path1
[path1
.length ()] == CSEP
)
503 return path1
+ path2
;
505 return path1
+ CSEP
+ path2
;
509 MingwModuleHandler::GenerateGccIncludeParametersFromVector ( const vector
<Include
*>& includes
) const
512 for ( size_t i
= 0; i
< includes
.size (); i
++ )
514 Include
& include
= *includes
[i
];
515 if ( parameters
.length () > 0 )
517 parameters
+= "-I" + include
.directory
;
523 MingwModuleHandler::GenerateGccIncludeParameters () const
525 string parameters
= GenerateGccIncludeParametersFromVector ( module
.non_if_data
.includes
);
526 string s
= GenerateGccIncludeParametersFromVector ( module
.project
.non_if_data
.includes
);
527 if ( s
.length () > 0 )
537 MingwModuleHandler::GenerateCompilerParametersFromVector ( const vector
<CompilerFlag
*>& compilerFlags
) const
540 for ( size_t i
= 0; i
< compilerFlags
.size (); i
++ )
542 CompilerFlag
& compilerFlag
= *compilerFlags
[i
];
543 if ( parameters
.length () > 0 )
545 parameters
+= compilerFlag
.flag
;
551 MingwModuleHandler::GenerateLinkerParametersFromVector ( const vector
<LinkerFlag
*>& linkerFlags
) const
554 for ( size_t i
= 0; i
< linkerFlags
.size (); i
++ )
556 LinkerFlag
& linkerFlag
= *linkerFlags
[i
];
557 if ( parameters
.length () > 0 )
559 parameters
+= linkerFlag
.flag
;
565 MingwModuleHandler::GenerateImportLibraryDependenciesFromVector (
566 const vector
<Library
*>& libraries
)
568 string
dependencies ( "" );
570 for ( size_t i
= 0; i
< libraries
.size (); i
++ )
572 if ( wrap_count
++ == 5 )
573 dependencies
+= " \\\n\t\t", wrap_count
= 0;
574 else if ( dependencies
.size () > 0 )
576 dependencies
+= GetImportLibraryDependency ( *libraries
[i
]->imported_module
);
582 MingwModuleHandler::GenerateLinkerParameters () const
584 return GenerateLinkerParametersFromVector ( module
.linkerFlags
);
588 MingwModuleHandler::GenerateMacro (
589 const char* assignmentOperation
,
591 const IfableData
& data
,
592 const vector
<CompilerFlag
*>* compilerFlags
)
600 assignmentOperation
);
602 if ( compilerFlags
!= NULL
)
604 string compilerParameters
= GenerateCompilerParametersFromVector ( *compilerFlags
);
605 if ( compilerParameters
.size () > 0 )
610 compilerParameters
.c_str () );
614 for ( i
= 0; i
< data
.includes
.size(); i
++ )
619 data
.includes
[i
]->directory
.c_str() );
621 for ( i
= 0; i
< data
.defines
.size(); i
++ )
623 Define
& d
= *data
.defines
[i
];
628 if ( d
.value
.size() )
634 fprintf ( fMakefile
, "\n" );
638 MingwModuleHandler::GenerateMacros (
639 const char* assignmentOperation
,
640 const IfableData
& data
,
641 const vector
<CompilerFlag
*>* compilerFlags
,
642 const vector
<LinkerFlag
*>* linkerFlags
)
646 if ( data
.includes
.size () > 0 || data
.defines
.size () > 0 )
648 GenerateMacro ( assignmentOperation
,
652 GenerateMacro ( assignmentOperation
,
658 if ( linkerFlags
!= NULL
)
660 string linkerParameters
= GenerateLinkerParametersFromVector ( *linkerFlags
);
661 if ( linkerParameters
.size () > 0 )
666 linkerflagsMacro
.c_str (),
668 linkerParameters
.c_str() );
672 if ( data
.libraries
.size () > 0 )
674 string deps
= GenerateImportLibraryDependenciesFromVector ( data
.libraries
);
675 if ( deps
.size () > 0 )
686 const vector
<If
*>& ifs
= data
.ifs
;
687 for ( i
= 0; i
< ifs
.size(); i
++ )
690 if ( rIf
.data
.defines
.size()
691 || rIf
.data
.includes
.size()
692 || rIf
.data
.libraries
.size()
693 || rIf
.data
.files
.size()
694 || rIf
.data
.ifs
.size() )
698 "ifeq (\"$(%s)\",\"%s\")\n",
699 rIf
.property
.c_str(),
714 MingwModuleHandler::GenerateObjectMacros (
715 const char* assignmentOperation
,
716 const IfableData
& data
,
717 const vector
<CompilerFlag
*>* compilerFlags
,
718 const vector
<LinkerFlag
*>* linkerFlags
)
722 const vector
<File
*>& files
= data
.files
;
723 if ( files
.size () > 0 )
725 for ( i
= 0; i
< files
.size (); i
++ )
727 File
& file
= *files
[i
];
732 objectsMacro
.c_str(),
734 file
.name
, NULL
).c_str (),
735 objectsMacro
.c_str() );
741 objectsMacro
.c_str (),
742 assignmentOperation
);
743 for ( i
= 0; i
< files
.size(); i
++ )
745 File
& file
= *files
[i
];
751 ( i
%10 == 9 ? " \\\n\t" : " " ),
753 file
.name
, NULL
).c_str () );
756 fprintf ( fMakefile
, "\n" );
759 const vector
<If
*>& ifs
= data
.ifs
;
760 for ( i
= 0; i
< ifs
.size(); i
++ )
763 if ( rIf
.data
.defines
.size()
764 || rIf
.data
.includes
.size()
765 || rIf
.data
.libraries
.size()
766 || rIf
.data
.files
.size()
767 || rIf
.data
.ifs
.size() )
771 "ifeq (\"$(%s)\",\"%s\")\n",
772 rIf
.property
.c_str(),
774 GenerateObjectMacros (
787 MingwModuleHandler::GenerateGccCommand (
788 const string
& sourceFilename
,
790 const string
& cflagsMacro
)
792 string dependencies
= sourceFilename
;
793 if ( module
.pch
&& use_pch
)
794 dependencies
+= " " + module
.pch
->header
+ ".gch";
796 /* WIDL generated headers may be used */
797 dependencies
+= " " + GetLinkingDependenciesMacro ();
798 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
800 string objectFilename
= GetObjectFilename (
801 sourceFilename
, &clean_files
);
804 objectFilename
.c_str (),
805 dependencies
.c_str (),
806 GetDirectory ( objectFilename
).c_str () );
807 fprintf ( fMakefile
, "\t$(ECHO_CC)\n" );
809 "\t%s -c $< -o $@ %s\n",
811 cflagsMacro
.c_str () );
815 MingwModuleHandler::GenerateGccAssemblerCommand (
816 const string
& sourceFilename
,
818 const string
& cflagsMacro
)
820 string dependencies
= sourceFilename
;
821 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
822 string objectFilename
= GetObjectFilename (
823 sourceFilename
, &clean_files
);
826 objectFilename
.c_str (),
827 dependencies
.c_str (),
828 GetDirectory ( objectFilename
).c_str () );
829 fprintf ( fMakefile
, "\t$(ECHO_GAS)\n" );
831 "\t%s -x assembler-with-cpp -c $< -o $@ -D__ASM__ %s\n",
833 cflagsMacro
.c_str () );
837 MingwModuleHandler::GenerateNasmCommand (
838 const string
& sourceFilename
,
839 const string
& nasmflagsMacro
)
841 string dependencies
= sourceFilename
;
842 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
843 string objectFilename
= GetObjectFilename (
844 sourceFilename
, &clean_files
);
847 objectFilename
.c_str (),
848 dependencies
.c_str (),
849 GetDirectory ( objectFilename
).c_str () );
850 fprintf ( fMakefile
, "\t$(ECHO_NASM)\n" );
852 "\t%s -f win32 $< -o $@ %s\n",
854 nasmflagsMacro
.c_str () );
858 MingwModuleHandler::GenerateWindresCommand (
859 const string
& sourceFilename
,
860 const string
& windresflagsMacro
)
862 string dependencies
= sourceFilename
;
863 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
864 string objectFilename
=
865 GetObjectFilename ( sourceFilename
, &clean_files
);
866 string rciFilename
= ros_temp
+ module
.name
+ ".rci.tmp";
867 string resFilename
= ros_temp
+ module
.name
+ ".res.tmp";
871 "%s: %s $(WRC_TARGET) | %s\n",
872 objectFilename
.c_str (),
873 dependencies
.c_str (),
874 GetDirectory ( objectFilename
).c_str () );
875 fprintf ( fMakefile
, "\t$(ECHO_WRC)\n" );
877 "\t${gcc} -xc -E -DRC_INVOKED ${%s} %s > %s\n",
878 windresflagsMacro
.c_str (),
879 sourceFilename
.c_str (),
880 rciFilename
.c_str () );
882 "\t$(Q)$(WRC_TARGET) ${%s} %s %s\n",
883 windresflagsMacro
.c_str (),
884 rciFilename
.c_str (),
885 resFilename
.c_str () );
887 "\t-@${rm} %s 2>$(NUL)\n",
888 rciFilename
.c_str () );
890 "\t${windres} %s -o $@\n",
891 resFilename
.c_str () );
893 "\t-@${rm} %s 2>$(NUL)\n",
894 resFilename
.c_str () );
899 "%s: %s $(WRC_TARGET) | %s\n",
900 objectFilename
.c_str (),
901 dependencies
.c_str (),
902 GetDirectory ( objectFilename
).c_str () );
903 fprintf ( fMakefile
, "\t$(ECHO_WRC)\n" );
905 "\t${windres} $(%s) %s -o $@\n",
906 windresflagsMacro
.c_str (),
907 sourceFilename
.c_str () );
912 MingwModuleHandler::GenerateWinebuildCommands (
913 const string
& sourceFilename
)
915 string dependencies
= sourceFilename
;
916 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
918 string basename
= GetBasename ( sourceFilename
);
919 string def_file
= PassThruCacheDirectory (
920 basename
+ ".spec.def",
921 backend
->intermediateDirectory
);
922 CLEAN_FILE(def_file
);
924 string stub_file
= PassThruCacheDirectory (
925 basename
+ ".stubs.c",
926 backend
->intermediateDirectory
);
927 CLEAN_FILE(stub_file
)
930 "%s: %s $(WINEBUILD_TARGET)\n",
932 dependencies
.c_str () );
933 fprintf ( fMakefile
, "\t$(ECHO_WINEBLD)\n" );
935 "\t%s --def=%s -o %s\n",
936 "$(Q)$(WINEBUILD_TARGET)",
937 sourceFilename
.c_str (),
941 "%s: %s $(WINEBUILD_TARGET)\n",
943 sourceFilename
.c_str () );
944 fprintf ( fMakefile
, "\t$(ECHO_WINEBLD)\n" );
946 "\t%s --pedll=%s -o %s\n",
947 "$(Q)$(WINEBUILD_TARGET)",
948 sourceFilename
.c_str (),
949 stub_file
.c_str () );
953 MingwModuleHandler::GenerateWidlCommandsServer (
954 const string
& sourceFilename
,
955 const string
& widlflagsMacro
)
957 string dependencies
= sourceFilename
;
958 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
960 string basename
= GetBasename ( sourceFilename
);
962 /*string generatedHeaderFilename = PassThruCacheDirectory (
964 backend->intermediateDirectory );
965 CLEAN_FILE(generatedHeaderFilename);
967 string generatedHeaderFilename
= basename
+ "_s.h";
968 CLEAN_FILE(generatedHeaderFilename
);
970 string generatedServerFilename
= PassThruCacheDirectory (
972 backend
->intermediateDirectory
);
973 CLEAN_FILE(generatedServerFilename
);
976 "%s %s: %s $(WIDL_TARGET) | %s\n",
977 generatedServerFilename
.c_str (),
978 generatedHeaderFilename
.c_str (),
979 dependencies
.c_str (),
980 GetDirectory ( generatedServerFilename
).c_str () );
981 fprintf ( fMakefile
, "\t$(ECHO_WIDL)\n" );
983 "\t%s %s -h -H %s -s -S %s %s\n",
984 "$(Q)$(WIDL_TARGET)",
985 widlflagsMacro
.c_str (),
986 generatedHeaderFilename
.c_str (),
987 generatedServerFilename
.c_str (),
988 sourceFilename
.c_str () );
992 MingwModuleHandler::GenerateWidlCommandsClient (
993 const string
& sourceFilename
,
994 const string
& widlflagsMacro
)
996 string dependencies
= sourceFilename
;
997 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
999 string basename
= GetBasename ( sourceFilename
);
1001 /*string generatedHeaderFilename = PassThruCacheDirectory (
1003 backend->intermediateDirectory );
1004 CLEAN_FILE(generatedHeaderFilename);
1006 string generatedHeaderFilename
= basename
+ "_c.h";
1007 CLEAN_FILE(generatedHeaderFilename
);
1009 string generatedClientFilename
= PassThruCacheDirectory (
1011 backend
->intermediateDirectory
);
1012 CLEAN_FILE(generatedClientFilename
);
1014 fprintf ( fMakefile
,
1015 "%s %s: %s $(WIDL_TARGET) | %s\n",
1016 generatedClientFilename
.c_str (),
1017 generatedHeaderFilename
.c_str (),
1018 dependencies
.c_str (),
1019 GetDirectory ( generatedClientFilename
).c_str () );
1020 fprintf ( fMakefile
, "\t$(ECHO_WIDL)\n" );
1021 fprintf ( fMakefile
,
1022 "\t%s %s -h -H %s -c -C %s %s\n",
1023 "$(Q)$(WIDL_TARGET)",
1024 widlflagsMacro
.c_str (),
1025 generatedHeaderFilename
.c_str (),
1026 generatedClientFilename
.c_str (),
1027 sourceFilename
.c_str () );
1031 MingwModuleHandler::GenerateWidlCommands (
1032 const string
& sourceFilename
,
1033 const string
& widlflagsMacro
)
1035 if ( module
.type
== RpcServer
)
1036 GenerateWidlCommandsServer ( sourceFilename
,
1039 GenerateWidlCommandsClient ( sourceFilename
,
1044 MingwModuleHandler::GenerateCommands (
1045 const string
& sourceFilename
,
1048 const string
& cflagsMacro
,
1049 const string
& nasmflagsMacro
,
1050 const string
& windresflagsMacro
,
1051 const string
& widlflagsMacro
)
1053 string extension
= GetExtension ( sourceFilename
);
1054 if ( extension
== ".c" || extension
== ".C" )
1056 GenerateGccCommand ( sourceFilename
,
1061 else if ( extension
== ".cc" || extension
== ".CC" ||
1062 extension
== ".cpp" || extension
== ".CPP" ||
1063 extension
== ".cxx" || extension
== ".CXX" )
1065 GenerateGccCommand ( sourceFilename
,
1070 else if ( extension
== ".s" || extension
== ".S" )
1072 GenerateGccAssemblerCommand ( sourceFilename
,
1077 else if ( extension
== ".asm" || extension
== ".ASM" )
1079 GenerateNasmCommand ( sourceFilename
,
1083 else if ( extension
== ".rc" || extension
== ".RC" )
1085 GenerateWindresCommand ( sourceFilename
,
1086 windresflagsMacro
);
1089 else if ( extension
== ".spec" || extension
== ".SPEC" )
1091 GenerateWinebuildCommands ( sourceFilename
);
1092 GenerateGccCommand ( GetActualSourceFilename ( sourceFilename
),
1097 else if ( extension
== ".idl" || extension
== ".IDL" )
1099 GenerateWidlCommands ( sourceFilename
,
1101 GenerateGccCommand ( GetActualSourceFilename ( sourceFilename
),
1107 throw InvalidOperationException ( __FILE__
,
1109 "Unsupported filename extension '%s' in file '%s'",
1111 sourceFilename
.c_str () );
1115 MingwModuleHandler::GenerateBuildMapCode ()
1117 fprintf ( fMakefile
,
1118 "ifeq ($(ROS_BUILDMAP),full)\n" );
1120 string mapFilename
= PassThruCacheDirectory (
1121 GetBasename ( module
.GetPath () ) + ".map",
1122 backend
->outputDirectory
);
1123 CLEAN_FILE ( mapFilename
);
1125 fprintf ( fMakefile
,
1126 "\t$(ECHO_OBJDUMP)\n" );
1127 fprintf ( fMakefile
,
1128 "\t$(Q)${objdump} -d -S $@ > %s\n",
1129 mapFilename
.c_str () );
1131 fprintf ( fMakefile
,
1133 fprintf ( fMakefile
,
1134 "ifeq ($(ROS_BUILDMAP),yes)\n" );
1136 fprintf ( fMakefile
,
1138 fprintf ( fMakefile
,
1139 "\t$(Q)${nm} --numeric-sort $@ > %s\n",
1140 mapFilename
.c_str () );
1142 fprintf ( fMakefile
,
1145 fprintf ( fMakefile
,
1150 MergeStringVector ( const vector
<string
>& input
,
1151 vector
<string
>& output
)
1155 int wrap_count
= -1;
1156 for ( size_t i
= 0; i
< input
.size (); i
++ )
1158 if ( input
[i
].size () == 0 )
1160 if ( wrap_count
++ == wrap_at
)
1162 output
.push_back ( s
);
1166 else if ( s
.size () > 0)
1170 if ( s
.length () > 0 )
1171 output
.push_back ( s
);
1175 MingwModuleHandler::GetObjectsVector ( const IfableData
& data
,
1176 vector
<string
>& objectFiles
) const
1178 for ( size_t i
= 0; i
< data
.files
.size (); i
++ )
1180 File
& file
= *data
.files
[i
];
1181 objectFiles
.push_back ( GetObjectFilename ( file
.name
, NULL
) );
1186 MingwModuleHandler::GenerateCleanObjectsAsYouGoCode () const
1188 if ( backend
->cleanAsYouGo
)
1190 vector
<string
> objectFiles
;
1191 GetObjectsVector ( module
.non_if_data
,
1193 vector
<string
> lines
;
1194 MergeStringVector ( objectFiles
,
1196 for ( size_t i
= 0; i
< lines
.size (); i
++ )
1198 fprintf ( fMakefile
,
1199 "\t-@${rm} %s 2>$(NUL)\n",
1200 lines
[i
].c_str () );
1206 MingwModuleHandler::GenerateLinkerCommand (
1207 const string
& dependencies
,
1208 const string
& linker
,
1209 const string
& linkerParameters
,
1210 const string
& objectsMacro
,
1211 const string
& libsMacro
)
1213 string
target ( GetTargetMacro ( module
) );
1214 string
target_folder ( GetDirectory ( GetTargetFilename ( module
, NULL
) ) );
1216 fprintf ( fMakefile
,
1217 "%s: %s $(RSYM_TARGET) | %s\n",
1219 dependencies
.c_str (),
1220 target_folder
.c_str () );
1221 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
1222 string
targetName ( module
.GetTargetName () );
1223 if ( module
.importLibrary
!= NULL
)
1225 string base_tmp
= ros_temp
+ module
.name
+ ".base.tmp";
1226 CLEAN_FILE ( base_tmp
);
1227 string junk_tmp
= ros_temp
+ module
.name
+ ".junk.tmp";
1228 CLEAN_FILE ( junk_tmp
);
1229 string temp_exp
= ros_temp
+ module
.name
+ ".temp.exp";
1230 CLEAN_FILE ( temp_exp
);
1231 string def_file
= GetDefinitionFilename ();
1233 fprintf ( fMakefile
,
1234 "\t%s %s -Wl,--base-file,%s -o %s %s %s %s\n",
1236 linkerParameters
.c_str (),
1239 objectsMacro
.c_str (),
1241 GetLinkerMacro ().c_str () );
1243 fprintf ( fMakefile
,
1244 "\t-@${rm} %s 2>$(NUL)\n",
1245 junk_tmp
.c_str () );
1247 string killAt
= module
.mangledSymbols
? "" : "--kill-at";
1248 fprintf ( fMakefile
,
1249 "\t${dlltool} --dllname %s --base-file %s --def %s --output-exp %s %s\n",
1250 targetName
.c_str (),
1256 fprintf ( fMakefile
,
1257 "\t-@${rm} %s 2>$(NUL)\n",
1258 base_tmp
.c_str () );
1260 fprintf ( fMakefile
,
1261 "\t%s %s %s -o %s %s %s %s\n",
1263 linkerParameters
.c_str (),
1266 objectsMacro
.c_str (),
1268 GetLinkerMacro ().c_str () );
1270 fprintf ( fMakefile
,
1271 "\t-@${rm} %s 2>$(NUL)\n",
1272 temp_exp
.c_str () );
1274 GenerateCleanObjectsAsYouGoCode ();
1278 fprintf ( fMakefile
,
1279 "\t%s %s -o %s %s %s %s\n",
1281 linkerParameters
.c_str (),
1283 objectsMacro
.c_str (),
1285 GetLinkerMacro ().c_str () );
1287 GenerateCleanObjectsAsYouGoCode ();
1290 GenerateBuildMapCode ();
1292 fprintf ( fMakefile
,
1293 "\t$(ECHO_RSYM)\n" );
1294 fprintf ( fMakefile
,
1295 "\t$(Q)$(RSYM_TARGET) $@ $@\n\n" );
1299 MingwModuleHandler::GeneratePhonyTarget() const
1301 string
targetMacro ( GetTargetMacro(module
) );
1302 fprintf ( fMakefile
, ".PHONY: %s\n\n",
1303 targetMacro
.c_str ());
1304 fprintf ( fMakefile
, "%s: | %s\n",
1305 targetMacro
.c_str (),
1306 GetDirectory(GetTargetFilename(module
,NULL
)).c_str () );
1310 MingwModuleHandler::GenerateObjectFileTargets (
1311 const IfableData
& data
,
1314 const string
& cflagsMacro
,
1315 const string
& nasmflagsMacro
,
1316 const string
& windresflagsMacro
,
1317 const string
& widlflagsMacro
)
1321 const vector
<File
*>& files
= data
.files
;
1322 for ( i
= 0; i
< files
.size (); i
++ )
1324 string sourceFilename
= files
[i
]->name
;
1325 GenerateCommands ( sourceFilename
,
1332 fprintf ( fMakefile
,
1336 const vector
<If
*>& ifs
= data
.ifs
;
1337 for ( i
= 0; i
< ifs
.size(); i
++ )
1339 GenerateObjectFileTargets ( ifs
[i
]->data
,
1350 MingwModuleHandler::GenerateObjectFileTargets (
1353 const string
& cflagsMacro
,
1354 const string
& nasmflagsMacro
,
1355 const string
& windresflagsMacro
,
1356 const string
& widlflagsMacro
)
1360 const string
& pch_file
= module
.pch
->header
;
1361 string gch_file
= pch_file
+ ".gch";
1362 CLEAN_FILE(gch_file
);
1370 fprintf ( fMakefile
, "\t$(ECHO_PCH)\n" );
1373 "\t%s -o %s %s -g %s\n\n",
1374 ( module
.cplusplus
? cppc
.c_str() : cc
.c_str() ),
1376 cflagsMacro
.c_str(),
1381 GenerateObjectFileTargets ( module
.non_if_data
,
1388 fprintf ( fMakefile
, "\n" );
1392 MingwModuleHandler::GenerateArchiveTarget ( const string
& ar
,
1393 const string
& objs_macro
) const
1395 string
archiveFilename ( GetModuleArchiveFilename () );
1397 fprintf ( fMakefile
,
1399 archiveFilename
.c_str (),
1400 objs_macro
.c_str (),
1401 GetDirectory(archiveFilename
).c_str() );
1403 fprintf ( fMakefile
, "\t$(ECHO_AR)\n" );
1405 fprintf ( fMakefile
,
1408 objs_macro
.c_str ());
1410 GenerateCleanObjectsAsYouGoCode ();
1412 fprintf ( fMakefile
, "\n" );
1414 return archiveFilename
;
1418 MingwModuleHandler::GetCFlagsMacro () const
1420 return ssprintf ( "$(%s_CFLAGS)",
1421 module
.name
.c_str () );
1425 MingwModuleHandler::GetObjectsMacro ( const Module
& module
)
1427 return ssprintf ( "$(%s_OBJS)",
1428 module
.name
.c_str () );
1432 MingwModuleHandler::GetLinkingDependenciesMacro () const
1434 return ssprintf ( "$(%s_LINKDEPS)", module
.name
.c_str () );
1438 MingwModuleHandler::GetLibsMacro () const
1440 return ssprintf ( "$(%s_LIBS)", module
.name
.c_str () );
1444 MingwModuleHandler::GetLinkerMacro () const
1446 return ssprintf ( "$(%s_LFLAGS)",
1447 module
.name
.c_str () );
1451 MingwModuleHandler::GetModuleTargets ( const Module
& module
)
1453 if ( ReferenceObjects ( module
) )
1454 return GetObjectsMacro ( module
);
1456 return GetTargetFilename ( module
, NULL
);
1460 MingwModuleHandler::GenerateObjectMacro ()
1462 objectsMacro
= ssprintf ("%s_OBJS", module
.name
.c_str ());
1464 GenerateObjectMacros (
1467 &module
.compilerFlags
,
1468 &module
.linkerFlags
);
1470 // future references to the macro will be to get its values
1471 objectsMacro
= ssprintf ("$(%s)", objectsMacro
.c_str ());
1475 MingwModuleHandler::GenerateTargetMacro ()
1477 fprintf ( fMakefile
,
1479 GetTargetMacro ( module
, false ).c_str (),
1480 GetModuleTargets ( module
).c_str () );
1484 MingwModuleHandler::GenerateOtherMacros ()
1486 cflagsMacro
= ssprintf ("%s_CFLAGS", module
.name
.c_str ());
1487 nasmflagsMacro
= ssprintf ("%s_NASMFLAGS", module
.name
.c_str ());
1488 windresflagsMacro
= ssprintf ("%s_RCFLAGS", module
.name
.c_str ());
1489 widlflagsMacro
= ssprintf ("%s_WIDLFLAGS", module
.name
.c_str ());
1490 linkerflagsMacro
= ssprintf ("%s_LFLAGS", module
.name
.c_str ());
1491 libsMacro
= ssprintf("%s_LIBS", module
.name
.c_str ());
1492 linkDepsMacro
= ssprintf ("%s_LINKDEPS", module
.name
.c_str ());
1497 &module
.compilerFlags
,
1498 &module
.linkerFlags
);
1500 if ( module
.importLibrary
)
1503 const vector
<File
*>& files
= module
.non_if_data
.files
;
1504 for ( size_t i
= 0; i
< files
.size (); i
++ )
1506 File
& file
= *files
[i
];
1507 string extension
= GetExtension ( file
.name
);
1508 if ( extension
== ".spec" || extension
== ".SPEC" )
1509 GetSpecObjectDependencies ( s
, file
.name
);
1511 if ( s
.size () > 0 )
1516 linkDepsMacro
.c_str() );
1517 for ( size_t i
= 0; i
< s
.size(); i
++ )
1518 fprintf ( fMakefile
,
1521 fprintf ( fMakefile
, "\n" );
1525 string globalCflags
= "-g";
1526 if ( backend
->usePipe
)
1527 globalCflags
+= " -pipe";
1528 if ( !module
.enableWarnings
)
1529 globalCflags
+= " -Werror";
1533 "%s += $(PROJECT_CFLAGS) %s\n",
1534 cflagsMacro
.c_str (),
1535 globalCflags
.c_str () );
1539 "%s += $(PROJECT_RCFLAGS)\n",
1540 windresflagsMacro
.c_str () );
1544 "%s += $(PROJECT_WIDLFLAGS)\n",
1545 widlflagsMacro
.c_str () );
1549 "%s_LFLAGS += $(PROJECT_LFLAGS) -g\n",
1550 module
.name
.c_str () );
1555 linkDepsMacro
.c_str (),
1556 libsMacro
.c_str () );
1558 string cflags
= TypeSpecificCFlags();
1559 if ( cflags
.size() > 0 )
1561 fprintf ( fMakefile
,
1563 cflagsMacro
.c_str (),
1567 string nasmflags
= TypeSpecificNasmFlags();
1568 if ( nasmflags
.size () > 0 )
1570 fprintf ( fMakefile
,
1572 nasmflagsMacro
.c_str (),
1573 nasmflags
.c_str () );
1576 string linkerflags
= TypeSpecificLinkerFlags();
1577 if ( linkerflags
.size() > 0 )
1579 fprintf ( fMakefile
,
1581 linkerflagsMacro
.c_str (),
1582 linkerflags
.c_str () );
1585 fprintf ( fMakefile
, "\n\n" );
1587 // future references to the macros will be to get their values
1588 cflagsMacro
= ssprintf ("$(%s)", cflagsMacro
.c_str ());
1589 nasmflagsMacro
= ssprintf ("$(%s)", nasmflagsMacro
.c_str ());
1590 widlflagsMacro
= ssprintf ("$(%s)", widlflagsMacro
.c_str ());
1594 MingwModuleHandler::GenerateRules ()
1596 string cc
= ( module
.host
== HostTrue
? "${host_gcc}" : "${gcc}" );
1597 string cppc
= ( module
.host
== HostTrue
? "${host_gpp}" : "${gpp}" );
1598 string ar
= ( module
.host
== HostTrue
? "${host_ar}" : "${ar}" );
1600 string targetMacro
= GetTargetMacro ( module
);
1602 CLEAN_FILE ( targetMacro
);
1604 // generate phony target for module name
1605 fprintf ( fMakefile
, ".PHONY: %s\n",
1606 module
.name
.c_str () );
1607 fprintf ( fMakefile
, "%s: %s\n\n",
1608 module
.name
.c_str (),
1609 GetTargetMacro ( module
).c_str () );
1611 if ( !ReferenceObjects ( module
) )
1613 string
ar_target ( GenerateArchiveTarget ( ar
, objectsMacro
) );
1614 if ( targetMacro
!= ar_target
)
1616 CLEAN_FILE ( ar_target
);
1620 GenerateObjectFileTargets ( cc
,
1629 MingwModuleHandler::GetInvocationDependencies (
1630 const Module
& module
,
1631 string_list
& dependencies
)
1633 for ( size_t i
= 0; i
< module
.invocations
.size (); i
++ )
1635 Invoke
& invoke
= *module
.invocations
[i
];
1636 if ( invoke
.invokeModule
== &module
)
1637 /* Protect against circular dependencies */
1639 invoke
.GetTargets ( dependencies
);
1644 MingwModuleHandler::GenerateInvocations () const
1646 if ( module
.invocations
.size () == 0 )
1649 size_t iend
= module
.invocations
.size ();
1650 for ( size_t i
= 0; i
< iend
; i
++ )
1652 const Invoke
& invoke
= *module
.invocations
[i
];
1654 if ( invoke
.invokeModule
->type
!= BuildTool
)
1656 throw InvalidBuildFileException ( module
.node
.location
,
1657 "Only modules of type buildtool can be invoked." );
1660 string invokeTarget
= module
.GetInvocationTarget ( i
);
1661 string_list invoke_targets
;
1662 assert ( invoke_targets
.size() );
1663 invoke
.GetTargets ( invoke_targets
);
1664 fprintf ( fMakefile
,
1666 invokeTarget
.c_str () );
1667 fprintf ( fMakefile
,
1669 invokeTarget
.c_str () );
1670 size_t j
, jend
= invoke_targets
.size();
1671 for ( j
= 0; j
< jend
; j
++ )
1673 fprintf ( fMakefile
,
1675 invoke_targets
[i
].c_str () );
1677 fprintf ( fMakefile
, "\n\n%s", invoke_targets
[0].c_str () );
1678 for ( j
= 1; j
< jend
; j
++ )
1679 fprintf ( fMakefile
,
1681 invoke_targets
[i
].c_str () );
1682 fprintf ( fMakefile
,
1684 NormalizeFilename ( invoke
.invokeModule
->GetPath () ).c_str () );
1685 fprintf ( fMakefile
, "\t$(ECHO_INVOKE)\n" );
1686 fprintf ( fMakefile
,
1688 NormalizeFilename ( invoke
.invokeModule
->GetPath () ).c_str (),
1689 invoke
.GetParameters ().c_str () );
1694 MingwModuleHandler::GetPreconditionDependenciesName () const
1696 return module
.name
+ "_precondition";
1700 MingwModuleHandler::GetDefaultDependencies (
1701 string_list
& dependencies
) const
1703 /* Avoid circular dependency */
1704 if ( module
.type
!= BuildTool
1705 && module
.name
!= "zlib"
1706 && module
.name
!= "hostzlib" )
1708 dependencies
.push_back ( "$(INIT)" );
1712 MingwModuleHandler::GeneratePreconditionDependencies ()
1714 string preconditionDependenciesName
= GetPreconditionDependenciesName ();
1715 string_list sourceFilenames
;
1716 GetSourceFilenamesWithoutGeneratedFiles ( sourceFilenames
);
1717 string_list dependencies
;
1718 GetDefaultDependencies ( dependencies
);
1719 GetModuleDependencies ( dependencies
);
1721 GetInvocationDependencies ( module
, dependencies
);
1723 if ( dependencies
.size() )
1725 fprintf ( fMakefile
,
1727 preconditionDependenciesName
.c_str () );
1728 for ( size_t i
= 0; i
< dependencies
.size(); i
++ )
1729 fprintf ( fMakefile
,
1731 dependencies
[i
].c_str () );
1732 fprintf ( fMakefile
, "\n\n" );
1735 for ( size_t i
= 0; i
< sourceFilenames
.size(); i
++ )
1737 fprintf ( fMakefile
,
1739 sourceFilenames
[i
].c_str(),
1740 preconditionDependenciesName
.c_str ());
1742 fprintf ( fMakefile
, "\n" );
1746 MingwModuleHandler::IsWineModule () const
1748 if ( module
.importLibrary
== NULL
)
1751 size_t index
= module
.importLibrary
->definition
.rfind ( ".spec.def" );
1752 return ( index
!= string::npos
);
1756 MingwModuleHandler::GetDefinitionFilename () const
1758 string defFilename
= module
.GetBasePath () + SSEP
+ module
.importLibrary
->definition
;
1759 if ( IsWineModule () )
1760 return PassThruCacheDirectory ( NormalizeFilename ( defFilename
),
1761 backend
->intermediateDirectory
);
1767 MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ()
1769 if ( module
.importLibrary
!= NULL
)
1771 string
library_target (
1772 GetImportLibraryFilename ( module
, &clean_files
) );
1775 GetDefinitionDependencies ( deps
);
1777 fprintf ( fMakefile
, "# IMPORT LIBRARY RULE:\n" );
1779 fprintf ( fMakefile
, "%s:",
1780 library_target
.c_str () );
1782 size_t i
, iend
= deps
.size();
1783 for ( i
= 0; i
< iend
; i
++ )
1784 fprintf ( fMakefile
, " %s",
1787 fprintf ( fMakefile
, " | %s\n",
1788 GetDirectory ( GetTargetFilename ( module
, NULL
) ).c_str () );
1790 fprintf ( fMakefile
, "\t$(ECHO_DLLTOOL)\n" );
1792 string killAt
= module
.mangledSymbols
? "" : "--kill-at";
1793 fprintf ( fMakefile
,
1794 "\t${dlltool} --dllname %s --def %s --output-lib %s %s\n\n",
1795 module
.GetTargetName ().c_str (),
1796 GetDefinitionFilename ().c_str (),
1797 library_target
.c_str (),
1803 MingwModuleHandler::GetSpecObjectDependencies (
1804 string_list
& dependencies
,
1805 const string
& filename
) const
1807 string basename
= GetBasename ( filename
);
1808 string defDependency
= PassThruCacheDirectory (
1809 NormalizeFilename ( basename
+ ".spec.def" ),
1810 backend
->intermediateDirectory
);
1811 dependencies
.push_back ( defDependency
);
1812 string stubsDependency
= PassThruCacheDirectory (
1813 NormalizeFilename ( basename
+ ".stubs.c" ),
1814 backend
->intermediateDirectory
);
1815 dependencies
.push_back ( stubsDependency
);
1819 MingwModuleHandler::GetWidlObjectDependencies (
1820 string_list
& dependencies
,
1821 const string
& filename
) const
1823 string basename
= GetBasename ( filename
);
1824 string serverDependency
= PassThruCacheDirectory (
1825 NormalizeFilename ( basename
+ "_s.c" ),
1826 backend
->intermediateDirectory
);
1827 dependencies
.push_back ( serverDependency
);
1831 MingwModuleHandler::GetDefinitionDependencies (
1832 string_list
& dependencies
) const
1834 string dkNkmLibNoFixup
= "dk/nkm/lib";
1835 const vector
<File
*>& files
= module
.non_if_data
.files
;
1836 for ( size_t i
= 0; i
< files
.size (); i
++ )
1838 File
& file
= *files
[i
];
1839 string extension
= GetExtension ( file
.name
);
1840 if ( extension
== ".spec" || extension
== ".SPEC" )
1842 GetSpecObjectDependencies ( dependencies
, file
.name
);
1844 if ( extension
== ".idl" || extension
== ".IDL" )
1846 GetWidlObjectDependencies ( dependencies
, file
.name
);
1852 MingwBuildToolModuleHandler::MingwBuildToolModuleHandler ( const Module
& module_
)
1853 : MingwModuleHandler ( module_
)
1858 MingwBuildToolModuleHandler::Process ()
1860 GenerateBuildToolModuleTarget ();
1864 MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ()
1866 string
targetMacro ( GetTargetMacro (module
) );
1867 string objectsMacro
= GetObjectsMacro ( module
);
1868 string linkDepsMacro
= GetLinkingDependenciesMacro ();
1869 string libsMacro
= GetLibsMacro ();
1874 if ( module
.cplusplus
)
1875 linker
= "${host_gpp}";
1877 linker
= "${host_gcc}";
1879 fprintf ( fMakefile
, "%s: %s %s | %s\n",
1880 targetMacro
.c_str (),
1881 objectsMacro
.c_str (),
1882 linkDepsMacro
.c_str (),
1883 GetDirectory(GetTargetFilename(module
,NULL
)).c_str () );
1884 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
1885 fprintf ( fMakefile
,
1886 "\t%s %s -o $@ %s %s\n\n",
1888 GetLinkerMacro ().c_str (),
1889 objectsMacro
.c_str (),
1890 libsMacro
.c_str () );
1894 MingwKernelModuleHandler::MingwKernelModuleHandler (
1895 const Module
& module_
)
1897 : MingwModuleHandler ( module_
)
1902 MingwKernelModuleHandler::Process ()
1904 GenerateKernelModuleTarget ();
1908 MingwKernelModuleHandler::GenerateKernelModuleTarget ()
1910 string
targetName ( module
.GetTargetName () ); // i.e. "ntoskrnl.exe"
1911 string
targetMacro ( GetTargetMacro ( module
) ); // i.e. "$(NTOSKRNL_TARGET)"
1912 string workingDirectory
= GetWorkingDirectory ();
1913 string objectsMacro
= GetObjectsMacro ( module
);
1914 string linkDepsMacro
= GetLinkingDependenciesMacro ();
1915 string libsMacro
= GetLibsMacro ();
1916 string base_tmp
= ros_temp
+ module
.name
+ ".base.tmp";
1917 CLEAN_FILE ( base_tmp
);
1918 string junk_tmp
= ros_temp
+ module
.name
+ ".junk.tmp";
1919 CLEAN_FILE ( junk_tmp
);
1920 string temp_exp
= ros_temp
+ module
.name
+ ".temp.exp";
1921 CLEAN_FILE ( temp_exp
);
1922 string gccOptions
= 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",
1923 module
.GetBasePath ().c_str (),
1924 module
.entrypoint
.c_str (),
1925 module
.baseaddress
.c_str () );
1929 GenerateImportLibraryTargetIfNeeded ();
1931 fprintf ( fMakefile
, "%s: %s %s $(RSYM_TARGET) | %s\n",
1932 targetMacro
.c_str (),
1933 objectsMacro
.c_str (),
1934 linkDepsMacro
.c_str (),
1935 GetDirectory(GetTargetFilename(module
,NULL
)).c_str () );
1936 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
1937 fprintf ( fMakefile
,
1938 "\t${gcc} %s %s -Wl,--base-file,%s -o %s %s %s\n",
1939 GetLinkerMacro ().c_str (),
1940 gccOptions
.c_str (),
1943 objectsMacro
.c_str (),
1944 linkDepsMacro
.c_str () );
1945 fprintf ( fMakefile
,
1946 "\t-@${rm} %s 2>$(NUL)\n",
1947 junk_tmp
.c_str () );
1948 string killAt
= module
.mangledSymbols
? "" : "--kill-at";
1949 fprintf ( fMakefile
,
1950 "\t${dlltool} --dllname %s --base-file %s --def ntoskrnl/ntoskrnl.def --output-exp %s %s\n",
1951 targetName
.c_str (),
1955 fprintf ( fMakefile
,
1956 "\t-@${rm} %s 2>$(NUL)\n",
1957 base_tmp
.c_str () );
1958 fprintf ( fMakefile
,
1959 "\t${gcc} %s %s -Wl,%s -o $@ %s %s\n",
1960 GetLinkerMacro ().c_str (),
1961 gccOptions
.c_str (),
1963 objectsMacro
.c_str (),
1964 linkDepsMacro
.c_str () );
1965 fprintf ( fMakefile
,
1966 "\t-@${rm} %s 2>$(NUL)\n",
1967 temp_exp
.c_str () );
1968 fprintf ( fMakefile
, "\t$(ECHO_RSYM)\n" );
1969 fprintf ( fMakefile
,
1970 "\t$(Q)$(RSYM_TARGET) $@ $@\n\n" );
1974 MingwStaticLibraryModuleHandler::MingwStaticLibraryModuleHandler (
1975 const Module
& module_
)
1977 : MingwModuleHandler ( module_
)
1982 MingwStaticLibraryModuleHandler::Process ()
1984 GenerateStaticLibraryModuleTarget ();
1988 MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget ()
1994 MingwObjectLibraryModuleHandler::MingwObjectLibraryModuleHandler (
1995 const Module
& module_
)
1997 : MingwModuleHandler ( module_
)
2002 MingwObjectLibraryModuleHandler::Process ()
2004 GenerateObjectLibraryModuleTarget ();
2008 MingwObjectLibraryModuleHandler::GenerateObjectLibraryModuleTarget ()
2014 MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler (
2015 const Module
& module_
)
2017 : MingwModuleHandler ( module_
)
2022 MingwKernelModeDLLModuleHandler::Process ()
2024 GenerateKernelModeDLLModuleTarget ();
2028 MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ()
2030 string
targetMacro ( GetTargetMacro ( module
) );
2031 string workingDirectory
= GetWorkingDirectory ( );
2032 string objectsMacro
= GetObjectsMacro ( module
);
2033 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2034 string libsMacro
= GetLibsMacro ();
2036 GenerateImportLibraryTargetIfNeeded ();
2038 if ( module
.non_if_data
.files
.size () > 0 )
2042 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2044 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll",
2045 module
.entrypoint
.c_str (),
2046 module
.baseaddress
.c_str () );
2047 GenerateLinkerCommand ( dependencies
,
2055 GeneratePhonyTarget();
2060 MingwKernelModeDriverModuleHandler::MingwKernelModeDriverModuleHandler (
2061 const Module
& module_
)
2063 : MingwModuleHandler ( module_
)
2068 MingwKernelModeDriverModuleHandler::Process ()
2070 GenerateKernelModeDriverModuleTarget ();
2075 MingwKernelModeDriverModuleHandler::GenerateKernelModeDriverModuleTarget ()
2077 string
targetMacro ( GetTargetMacro (module
) );
2078 string workingDirectory
= GetWorkingDirectory ();
2079 string objectsMacro
= GetObjectsMacro ( module
);
2080 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2081 string libsMacro
= GetLibsMacro ();
2083 GenerateImportLibraryTargetIfNeeded ();
2085 if ( module
.non_if_data
.files
.size () > 0 )
2089 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2091 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll",
2092 module
.entrypoint
.c_str (),
2093 module
.baseaddress
.c_str () );
2094 GenerateLinkerCommand ( dependencies
,
2102 GeneratePhonyTarget();
2107 MingwNativeDLLModuleHandler::MingwNativeDLLModuleHandler (
2108 const Module
& module_
)
2110 : MingwModuleHandler ( module_
)
2115 MingwNativeDLLModuleHandler::Process ()
2117 GenerateNativeDLLModuleTarget ();
2121 MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ()
2123 string
targetMacro ( GetTargetMacro (module
) );
2124 string workingDirectory
= GetWorkingDirectory ( );
2125 string objectsMacro
= GetObjectsMacro ( module
);
2126 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2127 string libsMacro
= GetLibsMacro ();
2129 GenerateImportLibraryTargetIfNeeded ();
2131 if ( module
.non_if_data
.files
.size () > 0 )
2135 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2137 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib -mdll",
2138 module
.entrypoint
.c_str (),
2139 module
.baseaddress
.c_str () );
2140 GenerateLinkerCommand ( dependencies
,
2148 GeneratePhonyTarget();
2153 MingwNativeCUIModuleHandler::MingwNativeCUIModuleHandler (
2154 const Module
& module_
)
2156 : MingwModuleHandler ( module_
)
2161 MingwNativeCUIModuleHandler::Process ()
2163 GenerateNativeCUIModuleTarget ();
2167 MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ()
2169 string
targetMacro ( GetTargetMacro (module
) );
2170 string workingDirectory
= GetWorkingDirectory ( );
2171 string objectsMacro
= GetObjectsMacro ( module
);
2172 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2173 string libsMacro
= GetLibsMacro ();
2175 GenerateImportLibraryTargetIfNeeded ();
2177 if ( module
.non_if_data
.files
.size () > 0 )
2181 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2183 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib",
2184 module
.entrypoint
.c_str (),
2185 module
.baseaddress
.c_str () );
2186 GenerateLinkerCommand ( dependencies
,
2194 GeneratePhonyTarget();
2199 MingwWin32DLLModuleHandler::MingwWin32DLLModuleHandler (
2200 const Module
& module_
)
2202 : MingwModuleHandler ( module_
)
2207 MingwWin32DLLModuleHandler::Process ()
2209 GenerateExtractWineDLLResourcesTarget ();
2210 GenerateWin32DLLModuleTarget ();
2214 MingwWin32DLLModuleHandler::GenerateExtractWineDLLResourcesTarget ()
2216 fprintf ( fMakefile
, ".PHONY: %s_extractresources\n\n",
2217 module
.name
.c_str () );
2218 fprintf ( fMakefile
, "%s_extractresources: $(BIN2RES_TARGET)\n",
2219 module
.name
.c_str () );
2220 const vector
<File
*>& files
= module
.non_if_data
.files
;
2221 for ( size_t i
= 0; i
< files
.size (); i
++ )
2223 File
& file
= *files
[i
];
2224 string extension
= GetExtension ( file
.name
);
2225 if ( extension
== ".rc" || extension
== ".RC" )
2227 string resource
= NormalizeFilename ( file
.name
);
2228 fprintf ( fMakefile
, "\t$(ECHO_BIN2RES)\n" );
2229 fprintf ( fMakefile
, "\t@:echo ${bin2res} -f -x %s\n",
2230 resource
.c_str () );
2233 fprintf ( fMakefile
, "\n");
2237 MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ()
2239 string
targetMacro ( GetTargetMacro (module
) );
2240 string workingDirectory
= GetWorkingDirectory ( );
2241 string objectsMacro
= GetObjectsMacro ( module
);
2242 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2243 string libsMacro
= GetLibsMacro ();
2245 GenerateImportLibraryTargetIfNeeded ();
2247 if ( module
.non_if_data
.files
.size () > 0 )
2251 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2254 if ( module
.cplusplus
)
2259 string linkerParameters
= ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -mdll",
2260 module
.entrypoint
.c_str (),
2261 module
.baseaddress
.c_str () );
2262 GenerateLinkerCommand ( dependencies
,
2270 GeneratePhonyTarget();
2275 MingwWin32CUIModuleHandler::MingwWin32CUIModuleHandler (
2276 const Module
& module_
)
2278 : MingwModuleHandler ( module_
)
2283 MingwWin32CUIModuleHandler::Process ()
2285 GenerateWin32CUIModuleTarget ();
2289 MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ()
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
;
2306 if ( module
.cplusplus
)
2311 string linkerParameters
= ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
2312 module
.entrypoint
.c_str (),
2313 module
.baseaddress
.c_str () );
2314 GenerateLinkerCommand ( dependencies
,
2322 GeneratePhonyTarget();
2327 MingwWin32GUIModuleHandler::MingwWin32GUIModuleHandler (
2328 const Module
& module_
)
2330 : MingwModuleHandler ( module_
)
2335 MingwWin32GUIModuleHandler::Process ()
2337 GenerateWin32GUIModuleTarget ();
2341 MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ()
2343 string
targetMacro ( GetTargetMacro (module
) );
2344 string workingDirectory
= GetWorkingDirectory ( );
2345 string objectsMacro
= GetObjectsMacro ( module
);
2346 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2347 string libsMacro
= GetLibsMacro ();
2349 GenerateImportLibraryTargetIfNeeded ();
2351 if ( module
.non_if_data
.files
.size () > 0 )
2355 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2358 if ( module
.cplusplus
)
2363 string linkerParameters
= ssprintf ( "-Wl,--subsystem,windows -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
2364 module
.entrypoint
.c_str (),
2365 module
.baseaddress
.c_str () );
2366 GenerateLinkerCommand ( dependencies
,
2374 GeneratePhonyTarget();
2379 MingwBootLoaderModuleHandler::MingwBootLoaderModuleHandler (
2380 const Module
& module_
)
2382 : MingwModuleHandler ( module_
)
2387 MingwBootLoaderModuleHandler::Process ()
2389 GenerateBootLoaderModuleTarget ();
2393 MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ()
2395 string
targetName ( module
.GetTargetName () );
2396 string
targetMacro ( GetTargetMacro (module
) );
2397 string workingDirectory
= GetWorkingDirectory ();
2398 string junk_tmp
= ros_temp
+ module
.name
+ ".junk.tmp";
2399 CLEAN_FILE ( junk_tmp
);
2400 string objectsMacro
= GetObjectsMacro ( module
);
2401 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2402 string libsMacro
= GetLibsMacro ();
2406 fprintf ( fMakefile
, "%s: %s %s | %s\n",
2407 targetMacro
.c_str (),
2408 objectsMacro
.c_str (),
2409 linkDepsMacro
.c_str (),
2410 GetDirectory(GetTargetFilename(module
,NULL
)).c_str () );
2412 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
2414 fprintf ( fMakefile
,
2415 "\t${ld} %s -N -Ttext=0x8000 -o %s %s %s\n",
2416 GetLinkerMacro ().c_str (),
2418 objectsMacro
.c_str (),
2419 linkDepsMacro
.c_str () );
2420 fprintf ( fMakefile
,
2421 "\t${objcopy} -O binary %s $@\n",
2422 junk_tmp
.c_str () );
2423 fprintf ( fMakefile
,
2424 "\t-@${rm} %s 2>$(NUL)\n",
2425 junk_tmp
.c_str () );
2429 MingwBootSectorModuleHandler::MingwBootSectorModuleHandler (
2430 const Module
& module_
)
2432 : MingwModuleHandler ( module_
)
2437 MingwBootSectorModuleHandler::Process ()
2439 GenerateBootSectorModuleTarget ();
2443 MingwBootSectorModuleHandler::GenerateBootSectorModuleTarget ()
2445 string objectsMacro
= GetObjectsMacro ( module
);
2449 fprintf ( fMakefile
, ".PHONY: %s\n\n",
2450 module
.name
.c_str ());
2451 fprintf ( fMakefile
,
2453 module
.name
.c_str (),
2454 objectsMacro
.c_str () );
2458 MingwIsoModuleHandler::MingwIsoModuleHandler (
2459 const Module
& module_
)
2461 : MingwModuleHandler ( module_
)
2466 MingwIsoModuleHandler::Process ()
2468 GenerateIsoModuleTarget ();
2472 MingwIsoModuleHandler::OutputBootstrapfileCopyCommands (
2473 const string
& bootcdDirectory
)
2475 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
2477 const Module
& m
= *module
.project
.modules
[i
];
2478 if ( m
.bootstrap
!= NULL
)
2480 string sourceFilename
= PassThruCacheDirectory (
2481 NormalizeFilename ( m
.GetPath () ),
2482 backend
->outputDirectory
);
2483 string
targetFilenameNoFixup ( bootcdDirectory
+ SSEP
+ m
.bootstrap
->base
+ SSEP
+ m
.bootstrap
->nameoncd
);
2484 string targetFilename
= MingwModuleHandler::PassThruCacheDirectory (
2485 NormalizeFilename ( targetFilenameNoFixup
),
2486 backend
->outputDirectory
);
2487 fprintf ( fMakefile
,
2489 fprintf ( fMakefile
,
2490 "\t${cp} %s %s 1>$(NUL)\n",
2491 sourceFilename
.c_str (),
2492 targetFilename
.c_str () );
2498 MingwIsoModuleHandler::OutputCdfileCopyCommands (
2499 const string
& bootcdDirectory
)
2501 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
2503 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
2504 string targetFilenameNoFixup
= bootcdDirectory
+ SSEP
+ cdfile
.base
+ SSEP
+ cdfile
.nameoncd
;
2505 string targetFilename
= MingwModuleHandler::PassThruCacheDirectory (
2506 NormalizeFilename ( targetFilenameNoFixup
),
2507 backend
->outputDirectory
);
2508 fprintf ( fMakefile
,
2510 fprintf ( fMakefile
,
2511 "\t${cp} %s %s 1>$(NUL)\n",
2512 cdfile
.GetPath ().c_str (),
2513 targetFilename
.c_str () );
2518 MingwIsoModuleHandler::GetBootstrapCdDirectories ( const string
& bootcdDirectory
)
2521 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
2523 const Module
& m
= *module
.project
.modules
[i
];
2524 if ( m
.bootstrap
!= NULL
)
2526 string
targetDirectory ( bootcdDirectory
+ SSEP
+ m
.bootstrap
->base
);
2527 if ( directories
.size () > 0 )
2529 directories
+= PassThruCacheDirectory (
2530 NormalizeFilename ( targetDirectory
),
2531 backend
->outputDirectory
);
2538 MingwIsoModuleHandler::GetNonModuleCdDirectories ( const string
& bootcdDirectory
)
2541 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
2543 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
2544 string
targetDirectory ( bootcdDirectory
+ SSEP
+ cdfile
.base
);
2545 if ( directories
.size () > 0 )
2547 directories
+= PassThruCacheDirectory (
2548 NormalizeFilename ( targetDirectory
),
2549 backend
->outputDirectory
);
2555 MingwIsoModuleHandler::GetCdDirectories ( const string
& bootcdDirectory
)
2557 string directories
= GetBootstrapCdDirectories ( bootcdDirectory
);
2558 directories
+= " " + GetNonModuleCdDirectories ( bootcdDirectory
);
2563 MingwIsoModuleHandler::GetBootstrapCdFiles (
2564 vector
<string
>& out
) const
2566 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
2568 const Module
& m
= *module
.project
.modules
[i
];
2569 if ( m
.bootstrap
!= NULL
)
2571 string filename
= PassThruCacheDirectory (
2572 NormalizeFilename ( m
.GetPath () ),
2573 backend
->outputDirectory
);
2574 out
.push_back ( filename
);
2580 MingwIsoModuleHandler::GetNonModuleCdFiles (
2581 vector
<string
>& out
) const
2583 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
2585 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
2586 out
.push_back ( cdfile
.GetPath () );
2591 MingwIsoModuleHandler::GetCdFiles (
2592 vector
<string
>& out
) const
2594 GetBootstrapCdFiles ( out
);
2595 GetNonModuleCdFiles ( out
);
2599 MingwIsoModuleHandler::GenerateIsoModuleTarget ()
2601 string bootcdDirectory
= "cd";
2602 string bootcd
= PassThruCacheDirectory (
2603 NormalizeFilename ( bootcdDirectory
+ SSEP
),
2604 backend
->outputDirectory
);
2605 string isoboot
= PassThruCacheDirectory (
2606 NormalizeFilename ( "boot" SSEP
"freeldr" SSEP
"bootsect" SSEP
"isoboot.o" ),
2607 backend
->outputDirectory
);
2608 string bootcdReactosNoFixup
= bootcdDirectory
+ SSEP
"reactos";
2609 string bootcdReactos
= PassThruCacheDirectory (
2610 NormalizeFilename ( bootcdReactosNoFixup
+ SSEP
),
2611 backend
->outputDirectory
);
2612 CLEAN_FILE ( bootcdReactos
);
2613 string reactosInf
= PassThruCacheDirectory (
2614 NormalizeFilename ( bootcdReactosNoFixup
+ SSEP
"reactos.inf" ),
2615 backend
->outputDirectory
);
2616 string reactosDff
= NormalizeFilename ( "bootdata" SSEP
"packages" SSEP
"reactos.dff" );
2617 string cdDirectories
= GetCdDirectories ( bootcdDirectory
);
2618 vector
<string
> vCdFiles
;
2619 GetCdFiles ( vCdFiles
);
2620 string cdFiles
= v2s ( vCdFiles
, 5 );
2622 fprintf ( fMakefile
, ".PHONY: %s\n\n",
2623 module
.name
.c_str ());
2624 fprintf ( fMakefile
,
2625 "%s: all %s %s %s %s $(CABMAN_TARGET) $(CDMAKE_TARGET)\n",
2626 module
.name
.c_str (),
2628 bootcdReactos
.c_str (),
2629 cdDirectories
.c_str (),
2631 fprintf ( fMakefile
, "\t$(ECHO_CABMAN)\n" );
2632 fprintf ( fMakefile
,
2633 "\t$(Q)$(CABMAN_TARGET) -C %s -L %s -I -P $(OUTPUT)\n",
2634 reactosDff
.c_str (),
2635 bootcdReactos
.c_str () );
2636 fprintf ( fMakefile
,
2637 "\t$(Q)$(CABMAN_TARGET) -C %s -RC %s -L %s -N -P $(OUTPUT)\n",
2638 reactosDff
.c_str (),
2639 reactosInf
.c_str (),
2640 bootcdReactos
.c_str ());
2641 fprintf ( fMakefile
,
2642 "\t-@${rm} %s 2>$(NUL)\n",
2643 reactosInf
.c_str () );
2644 OutputBootstrapfileCopyCommands ( bootcdDirectory
);
2645 OutputCdfileCopyCommands ( bootcdDirectory
);
2646 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
2647 fprintf ( fMakefile
,
2648 "\t$(Q)$(CDMAKE_TARGET) -v -m -b %s %s REACTOS ReactOS.iso\n",
2651 fprintf ( fMakefile
,
2656 MingwLiveIsoModuleHandler::MingwLiveIsoModuleHandler (
2657 const Module
& module_
)
2659 : MingwModuleHandler ( module_
)
2664 MingwLiveIsoModuleHandler::Process ()
2666 GenerateLiveIsoModuleTarget ();
2670 MingwLiveIsoModuleHandler::CreateDirectory ( const string
& directory
)
2672 string normalizedDirectory
= MingwModuleHandler::PassThruCacheDirectory (
2673 NormalizeFilename ( directory
) + SSEP
,
2674 backend
->outputDirectory
);
2678 MingwLiveIsoModuleHandler::OutputCopyCommand ( const string
& sourceFilename
,
2679 const string
& targetFilename
,
2680 const string
& targetDirectory
)
2682 string normalizedTargetFilename
= MingwModuleHandler::PassThruCacheDirectory (
2683 NormalizeFilename ( targetDirectory
+ SSEP
+ targetFilename
),
2684 backend
->outputDirectory
);
2685 fprintf ( fMakefile
,
2687 fprintf ( fMakefile
,
2688 "\t${cp} %s %s 1>$(NUL)\n",
2689 sourceFilename
.c_str (),
2690 normalizedTargetFilename
.c_str () );
2694 MingwLiveIsoModuleHandler::OutputModuleCopyCommands ( string
& livecdDirectory
,
2695 string
& reactosDirectory
)
2697 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
2699 const Module
& m
= *module
.project
.modules
[i
];
2700 if ( m
.installName
.length () > 0 )
2702 string sourceFilename
= MingwModuleHandler::PassThruCacheDirectory (
2703 NormalizeFilename ( m
.GetPath () ),
2704 backend
->outputDirectory
);
2705 OutputCopyCommand ( sourceFilename
,
2707 livecdDirectory
+ SSEP
+ reactosDirectory
+ SSEP
+ m
.installBase
);
2713 MingwLiveIsoModuleHandler::OutputNonModuleCopyCommands ( string
& livecdDirectory
,
2714 string
& reactosDirectory
)
2716 for ( size_t i
= 0; i
< module
.project
.installfiles
.size (); i
++ )
2718 const InstallFile
& installfile
= *module
.project
.installfiles
[i
];
2719 OutputCopyCommand ( installfile
.GetPath (),
2720 installfile
.newname
,
2721 livecdDirectory
+ SSEP
+ reactosDirectory
+ SSEP
+ installfile
.base
);
2726 MingwLiveIsoModuleHandler::OutputProfilesDirectoryCommands ( string
& livecdDirectory
)
2728 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" );
2729 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" SSEP
"All Users") ;
2730 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" SSEP
"All Users" SSEP
"Desktop" );
2731 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" SSEP
"Default User" );
2732 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" SSEP
"Default User" SSEP
"Desktop" );
2733 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" SSEP
"Default User" SSEP
"My Documents" );
2735 string livecdIni
= "bootdata" SSEP
"livecd.ini";
2736 OutputCopyCommand ( livecdIni
,
2742 MingwLiveIsoModuleHandler::OutputLoaderCommands ( string
& livecdDirectory
)
2744 string freeldr
= PassThruCacheDirectory (
2745 NormalizeFilename ( "boot" SSEP
"freeldr" SSEP
"freeldr" SSEP
"freeldr.sys" ),
2746 backend
->outputDirectory
);
2747 CreateDirectory ( livecdDirectory
+ SSEP
"loader" );
2748 OutputCopyCommand ( freeldr
,
2750 livecdDirectory
+ SSEP
+ "loader" );
2754 MingwLiveIsoModuleHandler::OutputRegistryCommands ( string
& livecdDirectory
)
2756 string reactosSystem32ConfigDirectory
= NormalizeFilename (
2757 MingwModuleHandler::PassThruCacheDirectory (
2758 livecdDirectory
+ SSEP
"reactos" SSEP
"system32" SSEP
"config" SSEP
,
2759 backend
->outputDirectory
) );
2760 fprintf ( fMakefile
,
2761 "\t$(ECHO_MKHIVE)\n" );
2762 fprintf ( fMakefile
,
2763 "\t$(MKHIVE_TARGET) bootdata %s bootdata" SSEP
"livecd.inf bootdata" SSEP
"hiveinst.inf\n",
2764 reactosSystem32ConfigDirectory
.c_str () );
2768 MingwLiveIsoModuleHandler::GenerateLiveIsoModuleTarget ()
2770 string livecdDirectory
= "livecd";
2771 string livecd
= PassThruCacheDirectory (
2772 NormalizeFilename ( livecdDirectory
+ SSEP
),
2773 backend
->outputDirectory
);
2774 string isoboot
= PassThruCacheDirectory (
2775 NormalizeFilename ( "boot" SSEP
"freeldr" SSEP
"bootsect" SSEP
"isoboot.o" ),
2776 backend
->outputDirectory
);
2777 string reactosDirectory
= "reactos";
2778 string livecdReactosNoFixup
= livecdDirectory
+ SSEP
+ reactosDirectory
;
2779 string livecdReactos
= NormalizeFilename ( PassThruCacheDirectory (
2780 NormalizeFilename ( livecdReactosNoFixup
+ SSEP
),
2781 backend
->outputDirectory
) );
2782 CLEAN_FILE ( livecdReactos
);
2784 fprintf ( fMakefile
, ".PHONY: %s\n\n",
2785 module
.name
.c_str ());
2786 fprintf ( fMakefile
,
2787 "%s: all %s %s $(MKHIVE_TARGET) $(CDMAKE_TARGET)\n",
2788 module
.name
.c_str (),
2790 livecdReactos
.c_str () );
2791 OutputModuleCopyCommands ( livecdDirectory
,
2793 OutputNonModuleCopyCommands ( livecdDirectory
,
2795 OutputProfilesDirectoryCommands ( livecdDirectory
);
2796 OutputLoaderCommands ( livecdDirectory
);
2797 OutputRegistryCommands ( livecdDirectory
);
2798 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
2799 fprintf ( fMakefile
,
2800 "\t$(Q)$(CDMAKE_TARGET) -v -m -j -b %s %s REACTOS ReactOS-LiveCD.iso\n",
2803 fprintf ( fMakefile
,
2808 MingwTestModuleHandler::MingwTestModuleHandler (
2809 const Module
& module_
)
2811 : MingwModuleHandler ( module_
)
2816 MingwTestModuleHandler::Process ()
2818 GenerateTestModuleTarget ();
2822 MingwTestModuleHandler::GenerateTestModuleTarget ()
2824 string
targetMacro ( GetTargetMacro ( module
) );
2825 string workingDirectory
= GetWorkingDirectory ( );
2826 string objectsMacro
= GetObjectsMacro ( module
);
2827 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2828 string libsMacro
= GetLibsMacro ();
2830 GenerateImportLibraryTargetIfNeeded ();
2832 if ( module
.non_if_data
.files
.size () > 0 )
2836 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2839 if ( module
.cplusplus
)
2844 string linkerParameters
= ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
2845 module
.entrypoint
.c_str (),
2846 module
.baseaddress
.c_str () );
2847 GenerateLinkerCommand ( dependencies
,
2855 GeneratePhonyTarget();
2860 MingwRpcServerModuleHandler::MingwRpcServerModuleHandler (
2861 const Module
& module_
)
2863 : MingwModuleHandler ( module_
)
2868 MingwRpcServerModuleHandler::Process ()
2873 MingwRpcClientModuleHandler::MingwRpcClientModuleHandler (
2874 const Module
& module_
)
2876 : MingwModuleHandler ( module_
)
2881 MingwRpcClientModuleHandler::Process ()