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 MingwModuleHandler::GenerateBuildNonSymbolStrippedCode ()
1152 fprintf ( fMakefile
,
1153 "ifeq ($(ROS_BUILDNOSTRIP),yes)\n" );
1155 string filename
= module
.GetPath ();
1156 string outputFilename
= PassThruCacheDirectory (
1158 backend
->outputDirectory
);
1159 string nostripFilename
= PassThruCacheDirectory (
1160 GetBasename ( filename
) + ".nostrip" + GetExtension ( filename
),
1161 backend
->outputDirectory
);
1162 CLEAN_FILE ( nostripFilename
);
1164 fprintf ( fMakefile
,
1166 fprintf ( fMakefile
,
1167 "\t${cp} %s %s 1>$(NUL)\n",
1168 outputFilename
.c_str (),
1169 nostripFilename
.c_str () );
1171 fprintf ( fMakefile
,
1176 MergeStringVector ( const vector
<string
>& input
,
1177 vector
<string
>& output
)
1181 int wrap_count
= -1;
1182 for ( size_t i
= 0; i
< input
.size (); i
++ )
1184 if ( input
[i
].size () == 0 )
1186 if ( wrap_count
++ == wrap_at
)
1188 output
.push_back ( s
);
1192 else if ( s
.size () > 0)
1196 if ( s
.length () > 0 )
1197 output
.push_back ( s
);
1201 MingwModuleHandler::GetObjectsVector ( const IfableData
& data
,
1202 vector
<string
>& objectFiles
) const
1204 for ( size_t i
= 0; i
< data
.files
.size (); i
++ )
1206 File
& file
= *data
.files
[i
];
1207 objectFiles
.push_back ( GetObjectFilename ( file
.name
, NULL
) );
1212 MingwModuleHandler::GenerateCleanObjectsAsYouGoCode () const
1214 if ( backend
->cleanAsYouGo
)
1216 vector
<string
> objectFiles
;
1217 GetObjectsVector ( module
.non_if_data
,
1219 vector
<string
> lines
;
1220 MergeStringVector ( objectFiles
,
1222 for ( size_t i
= 0; i
< lines
.size (); i
++ )
1224 fprintf ( fMakefile
,
1225 "\t-@${rm} %s 2>$(NUL)\n",
1226 lines
[i
].c_str () );
1232 MingwModuleHandler::GenerateLinkerCommand (
1233 const string
& dependencies
,
1234 const string
& linker
,
1235 const string
& linkerParameters
,
1236 const string
& objectsMacro
,
1237 const string
& libsMacro
)
1239 string
target ( GetTargetMacro ( module
) );
1240 string
target_folder ( GetDirectory ( GetTargetFilename ( module
, NULL
) ) );
1242 fprintf ( fMakefile
,
1243 "%s: %s $(RSYM_TARGET) | %s\n",
1245 dependencies
.c_str (),
1246 target_folder
.c_str () );
1247 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
1248 string
targetName ( module
.GetTargetName () );
1249 if ( module
.importLibrary
!= NULL
)
1251 string base_tmp
= ros_temp
+ module
.name
+ ".base.tmp";
1252 CLEAN_FILE ( base_tmp
);
1253 string junk_tmp
= ros_temp
+ module
.name
+ ".junk.tmp";
1254 CLEAN_FILE ( junk_tmp
);
1255 string temp_exp
= ros_temp
+ module
.name
+ ".temp.exp";
1256 CLEAN_FILE ( temp_exp
);
1257 string def_file
= GetDefinitionFilename ();
1259 fprintf ( fMakefile
,
1260 "\t%s %s -Wl,--base-file,%s -o %s %s %s %s\n",
1262 linkerParameters
.c_str (),
1265 objectsMacro
.c_str (),
1267 GetLinkerMacro ().c_str () );
1269 fprintf ( fMakefile
,
1270 "\t-@${rm} %s 2>$(NUL)\n",
1271 junk_tmp
.c_str () );
1273 string killAt
= module
.mangledSymbols
? "" : "--kill-at";
1274 fprintf ( fMakefile
,
1275 "\t${dlltool} --dllname %s --base-file %s --def %s --output-exp %s %s\n",
1276 targetName
.c_str (),
1282 fprintf ( fMakefile
,
1283 "\t-@${rm} %s 2>$(NUL)\n",
1284 base_tmp
.c_str () );
1286 fprintf ( fMakefile
,
1287 "\t%s %s %s -o %s %s %s %s\n",
1289 linkerParameters
.c_str (),
1292 objectsMacro
.c_str (),
1294 GetLinkerMacro ().c_str () );
1296 fprintf ( fMakefile
,
1297 "\t-@${rm} %s 2>$(NUL)\n",
1298 temp_exp
.c_str () );
1300 GenerateCleanObjectsAsYouGoCode ();
1304 fprintf ( fMakefile
,
1305 "\t%s %s -o %s %s %s %s\n",
1307 linkerParameters
.c_str (),
1309 objectsMacro
.c_str (),
1311 GetLinkerMacro ().c_str () );
1313 GenerateCleanObjectsAsYouGoCode ();
1316 GenerateBuildMapCode ();
1318 GenerateBuildNonSymbolStrippedCode ();
1320 fprintf ( fMakefile
,
1321 "\t$(ECHO_RSYM)\n" );
1322 fprintf ( fMakefile
,
1323 "\t$(Q)$(RSYM_TARGET) $@ $@\n\n" );
1327 MingwModuleHandler::GeneratePhonyTarget() const
1329 string
targetMacro ( GetTargetMacro(module
) );
1330 fprintf ( fMakefile
, ".PHONY: %s\n\n",
1331 targetMacro
.c_str ());
1332 fprintf ( fMakefile
, "%s: | %s\n",
1333 targetMacro
.c_str (),
1334 GetDirectory(GetTargetFilename(module
,NULL
)).c_str () );
1338 MingwModuleHandler::GenerateObjectFileTargets (
1339 const IfableData
& data
,
1342 const string
& cflagsMacro
,
1343 const string
& nasmflagsMacro
,
1344 const string
& windresflagsMacro
,
1345 const string
& widlflagsMacro
)
1349 const vector
<File
*>& files
= data
.files
;
1350 for ( i
= 0; i
< files
.size (); i
++ )
1352 string sourceFilename
= files
[i
]->name
;
1353 GenerateCommands ( sourceFilename
,
1360 fprintf ( fMakefile
,
1364 const vector
<If
*>& ifs
= data
.ifs
;
1365 for ( i
= 0; i
< ifs
.size(); i
++ )
1367 GenerateObjectFileTargets ( ifs
[i
]->data
,
1378 MingwModuleHandler::GenerateObjectFileTargets (
1381 const string
& cflagsMacro
,
1382 const string
& nasmflagsMacro
,
1383 const string
& windresflagsMacro
,
1384 const string
& widlflagsMacro
)
1388 const string
& pch_file
= module
.pch
->header
;
1389 string gch_file
= pch_file
+ ".gch";
1390 CLEAN_FILE(gch_file
);
1398 fprintf ( fMakefile
, "\t$(ECHO_PCH)\n" );
1401 "\t%s -o %s %s -g %s\n\n",
1402 ( module
.cplusplus
? cppc
.c_str() : cc
.c_str() ),
1404 cflagsMacro
.c_str(),
1409 GenerateObjectFileTargets ( module
.non_if_data
,
1416 fprintf ( fMakefile
, "\n" );
1420 MingwModuleHandler::GenerateArchiveTarget ( const string
& ar
,
1421 const string
& objs_macro
) const
1423 string
archiveFilename ( GetModuleArchiveFilename () );
1425 fprintf ( fMakefile
,
1427 archiveFilename
.c_str (),
1428 objs_macro
.c_str (),
1429 GetDirectory(archiveFilename
).c_str() );
1431 fprintf ( fMakefile
, "\t$(ECHO_AR)\n" );
1433 fprintf ( fMakefile
,
1436 objs_macro
.c_str ());
1438 GenerateCleanObjectsAsYouGoCode ();
1440 fprintf ( fMakefile
, "\n" );
1442 return archiveFilename
;
1446 MingwModuleHandler::GetCFlagsMacro () const
1448 return ssprintf ( "$(%s_CFLAGS)",
1449 module
.name
.c_str () );
1453 MingwModuleHandler::GetObjectsMacro ( const Module
& module
)
1455 return ssprintf ( "$(%s_OBJS)",
1456 module
.name
.c_str () );
1460 MingwModuleHandler::GetLinkingDependenciesMacro () const
1462 return ssprintf ( "$(%s_LINKDEPS)", module
.name
.c_str () );
1466 MingwModuleHandler::GetLibsMacro () const
1468 return ssprintf ( "$(%s_LIBS)", module
.name
.c_str () );
1472 MingwModuleHandler::GetLinkerMacro () const
1474 return ssprintf ( "$(%s_LFLAGS)",
1475 module
.name
.c_str () );
1479 MingwModuleHandler::GetModuleTargets ( const Module
& module
)
1481 if ( ReferenceObjects ( module
) )
1482 return GetObjectsMacro ( module
);
1484 return GetTargetFilename ( module
, NULL
);
1488 MingwModuleHandler::GenerateObjectMacro ()
1490 objectsMacro
= ssprintf ("%s_OBJS", module
.name
.c_str ());
1492 GenerateObjectMacros (
1495 &module
.compilerFlags
,
1496 &module
.linkerFlags
);
1498 // future references to the macro will be to get its values
1499 objectsMacro
= ssprintf ("$(%s)", objectsMacro
.c_str ());
1503 MingwModuleHandler::GenerateTargetMacro ()
1505 fprintf ( fMakefile
,
1507 GetTargetMacro ( module
, false ).c_str (),
1508 GetModuleTargets ( module
).c_str () );
1512 MingwModuleHandler::GenerateOtherMacros ()
1514 cflagsMacro
= ssprintf ("%s_CFLAGS", module
.name
.c_str ());
1515 nasmflagsMacro
= ssprintf ("%s_NASMFLAGS", module
.name
.c_str ());
1516 windresflagsMacro
= ssprintf ("%s_RCFLAGS", module
.name
.c_str ());
1517 widlflagsMacro
= ssprintf ("%s_WIDLFLAGS", module
.name
.c_str ());
1518 linkerflagsMacro
= ssprintf ("%s_LFLAGS", module
.name
.c_str ());
1519 libsMacro
= ssprintf("%s_LIBS", module
.name
.c_str ());
1520 linkDepsMacro
= ssprintf ("%s_LINKDEPS", module
.name
.c_str ());
1525 &module
.compilerFlags
,
1526 &module
.linkerFlags
);
1528 if ( module
.importLibrary
)
1531 const vector
<File
*>& files
= module
.non_if_data
.files
;
1532 for ( size_t i
= 0; i
< files
.size (); i
++ )
1534 File
& file
= *files
[i
];
1535 string extension
= GetExtension ( file
.name
);
1536 if ( extension
== ".spec" || extension
== ".SPEC" )
1537 GetSpecObjectDependencies ( s
, file
.name
);
1539 if ( s
.size () > 0 )
1544 linkDepsMacro
.c_str() );
1545 for ( size_t i
= 0; i
< s
.size(); i
++ )
1546 fprintf ( fMakefile
,
1549 fprintf ( fMakefile
, "\n" );
1553 string globalCflags
= "-g";
1554 if ( backend
->usePipe
)
1555 globalCflags
+= " -pipe";
1556 if ( !module
.enableWarnings
)
1557 globalCflags
+= " -Werror";
1561 "%s += $(PROJECT_CFLAGS) %s\n",
1562 cflagsMacro
.c_str (),
1563 globalCflags
.c_str () );
1567 "%s += $(PROJECT_RCFLAGS)\n",
1568 windresflagsMacro
.c_str () );
1572 "%s += $(PROJECT_WIDLFLAGS)\n",
1573 widlflagsMacro
.c_str () );
1577 "%s_LFLAGS += $(PROJECT_LFLAGS) -g\n",
1578 module
.name
.c_str () );
1583 linkDepsMacro
.c_str (),
1584 libsMacro
.c_str () );
1586 string cflags
= TypeSpecificCFlags();
1587 if ( cflags
.size() > 0 )
1589 fprintf ( fMakefile
,
1591 cflagsMacro
.c_str (),
1595 string nasmflags
= TypeSpecificNasmFlags();
1596 if ( nasmflags
.size () > 0 )
1598 fprintf ( fMakefile
,
1600 nasmflagsMacro
.c_str (),
1601 nasmflags
.c_str () );
1604 string linkerflags
= TypeSpecificLinkerFlags();
1605 if ( linkerflags
.size() > 0 )
1607 fprintf ( fMakefile
,
1609 linkerflagsMacro
.c_str (),
1610 linkerflags
.c_str () );
1613 fprintf ( fMakefile
, "\n\n" );
1615 // future references to the macros will be to get their values
1616 cflagsMacro
= ssprintf ("$(%s)", cflagsMacro
.c_str ());
1617 nasmflagsMacro
= ssprintf ("$(%s)", nasmflagsMacro
.c_str ());
1618 widlflagsMacro
= ssprintf ("$(%s)", widlflagsMacro
.c_str ());
1622 MingwModuleHandler::GenerateRules ()
1624 string cc
= ( module
.host
== HostTrue
? "${host_gcc}" : "${gcc}" );
1625 string cppc
= ( module
.host
== HostTrue
? "${host_gpp}" : "${gpp}" );
1626 string ar
= ( module
.host
== HostTrue
? "${host_ar}" : "${ar}" );
1628 string targetMacro
= GetTargetMacro ( module
);
1630 CLEAN_FILE ( targetMacro
);
1632 // generate phony target for module name
1633 fprintf ( fMakefile
, ".PHONY: %s\n",
1634 module
.name
.c_str () );
1635 fprintf ( fMakefile
, "%s: %s\n\n",
1636 module
.name
.c_str (),
1637 GetTargetMacro ( module
).c_str () );
1639 if ( !ReferenceObjects ( module
) )
1641 string
ar_target ( GenerateArchiveTarget ( ar
, objectsMacro
) );
1642 if ( targetMacro
!= ar_target
)
1644 CLEAN_FILE ( ar_target
);
1648 GenerateObjectFileTargets ( cc
,
1657 MingwModuleHandler::GetInvocationDependencies (
1658 const Module
& module
,
1659 string_list
& dependencies
)
1661 for ( size_t i
= 0; i
< module
.invocations
.size (); i
++ )
1663 Invoke
& invoke
= *module
.invocations
[i
];
1664 if ( invoke
.invokeModule
== &module
)
1665 /* Protect against circular dependencies */
1667 invoke
.GetTargets ( dependencies
);
1672 MingwModuleHandler::GenerateInvocations () const
1674 if ( module
.invocations
.size () == 0 )
1677 size_t iend
= module
.invocations
.size ();
1678 for ( size_t i
= 0; i
< iend
; i
++ )
1680 const Invoke
& invoke
= *module
.invocations
[i
];
1682 if ( invoke
.invokeModule
->type
!= BuildTool
)
1684 throw InvalidBuildFileException ( module
.node
.location
,
1685 "Only modules of type buildtool can be invoked." );
1688 string invokeTarget
= module
.GetInvocationTarget ( i
);
1689 string_list invoke_targets
;
1690 assert ( invoke_targets
.size() );
1691 invoke
.GetTargets ( invoke_targets
);
1692 fprintf ( fMakefile
,
1694 invokeTarget
.c_str () );
1695 fprintf ( fMakefile
,
1697 invokeTarget
.c_str () );
1698 size_t j
, jend
= invoke_targets
.size();
1699 for ( j
= 0; j
< jend
; j
++ )
1701 fprintf ( fMakefile
,
1703 invoke_targets
[i
].c_str () );
1705 fprintf ( fMakefile
, "\n\n%s", invoke_targets
[0].c_str () );
1706 for ( j
= 1; j
< jend
; j
++ )
1707 fprintf ( fMakefile
,
1709 invoke_targets
[i
].c_str () );
1710 fprintf ( fMakefile
,
1712 NormalizeFilename ( invoke
.invokeModule
->GetPath () ).c_str () );
1713 fprintf ( fMakefile
, "\t$(ECHO_INVOKE)\n" );
1714 fprintf ( fMakefile
,
1716 NormalizeFilename ( invoke
.invokeModule
->GetPath () ).c_str (),
1717 invoke
.GetParameters ().c_str () );
1722 MingwModuleHandler::GetPreconditionDependenciesName () const
1724 return module
.name
+ "_precondition";
1728 MingwModuleHandler::GetDefaultDependencies (
1729 string_list
& dependencies
) const
1731 /* Avoid circular dependency */
1732 if ( module
.type
!= BuildTool
1733 && module
.name
!= "zlib"
1734 && module
.name
!= "hostzlib" )
1736 dependencies
.push_back ( "$(INIT)" );
1740 MingwModuleHandler::GeneratePreconditionDependencies ()
1742 string preconditionDependenciesName
= GetPreconditionDependenciesName ();
1743 string_list sourceFilenames
;
1744 GetSourceFilenamesWithoutGeneratedFiles ( sourceFilenames
);
1745 string_list dependencies
;
1746 GetDefaultDependencies ( dependencies
);
1747 GetModuleDependencies ( dependencies
);
1749 GetInvocationDependencies ( module
, dependencies
);
1751 if ( dependencies
.size() )
1753 fprintf ( fMakefile
,
1755 preconditionDependenciesName
.c_str () );
1756 for ( size_t i
= 0; i
< dependencies
.size(); i
++ )
1757 fprintf ( fMakefile
,
1759 dependencies
[i
].c_str () );
1760 fprintf ( fMakefile
, "\n\n" );
1763 for ( size_t i
= 0; i
< sourceFilenames
.size(); i
++ )
1765 fprintf ( fMakefile
,
1767 sourceFilenames
[i
].c_str(),
1768 preconditionDependenciesName
.c_str ());
1770 fprintf ( fMakefile
, "\n" );
1774 MingwModuleHandler::IsWineModule () const
1776 if ( module
.importLibrary
== NULL
)
1779 size_t index
= module
.importLibrary
->definition
.rfind ( ".spec.def" );
1780 return ( index
!= string::npos
);
1784 MingwModuleHandler::GetDefinitionFilename () const
1786 string defFilename
= module
.GetBasePath () + SSEP
+ module
.importLibrary
->definition
;
1787 if ( IsWineModule () )
1788 return PassThruCacheDirectory ( NormalizeFilename ( defFilename
),
1789 backend
->intermediateDirectory
);
1795 MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ()
1797 if ( module
.importLibrary
!= NULL
)
1799 string
library_target (
1800 GetImportLibraryFilename ( module
, &clean_files
) );
1803 GetDefinitionDependencies ( deps
);
1805 fprintf ( fMakefile
, "# IMPORT LIBRARY RULE:\n" );
1807 fprintf ( fMakefile
, "%s:",
1808 library_target
.c_str () );
1810 size_t i
, iend
= deps
.size();
1811 for ( i
= 0; i
< iend
; i
++ )
1812 fprintf ( fMakefile
, " %s",
1815 fprintf ( fMakefile
, " | %s\n",
1816 GetDirectory ( GetTargetFilename ( module
, NULL
) ).c_str () );
1818 fprintf ( fMakefile
, "\t$(ECHO_DLLTOOL)\n" );
1820 string killAt
= module
.mangledSymbols
? "" : "--kill-at";
1821 fprintf ( fMakefile
,
1822 "\t${dlltool} --dllname %s --def %s --output-lib %s %s\n\n",
1823 module
.GetTargetName ().c_str (),
1824 GetDefinitionFilename ().c_str (),
1825 library_target
.c_str (),
1831 MingwModuleHandler::GetSpecObjectDependencies (
1832 string_list
& dependencies
,
1833 const string
& filename
) const
1835 string basename
= GetBasename ( filename
);
1836 string defDependency
= PassThruCacheDirectory (
1837 NormalizeFilename ( basename
+ ".spec.def" ),
1838 backend
->intermediateDirectory
);
1839 dependencies
.push_back ( defDependency
);
1840 string stubsDependency
= PassThruCacheDirectory (
1841 NormalizeFilename ( basename
+ ".stubs.c" ),
1842 backend
->intermediateDirectory
);
1843 dependencies
.push_back ( stubsDependency
);
1847 MingwModuleHandler::GetWidlObjectDependencies (
1848 string_list
& dependencies
,
1849 const string
& filename
) const
1851 string basename
= GetBasename ( filename
);
1852 string serverDependency
= PassThruCacheDirectory (
1853 NormalizeFilename ( basename
+ "_s.c" ),
1854 backend
->intermediateDirectory
);
1855 dependencies
.push_back ( serverDependency
);
1859 MingwModuleHandler::GetDefinitionDependencies (
1860 string_list
& dependencies
) const
1862 string dkNkmLibNoFixup
= "dk/nkm/lib";
1863 const vector
<File
*>& files
= module
.non_if_data
.files
;
1864 for ( size_t i
= 0; i
< files
.size (); i
++ )
1866 File
& file
= *files
[i
];
1867 string extension
= GetExtension ( file
.name
);
1868 if ( extension
== ".spec" || extension
== ".SPEC" )
1870 GetSpecObjectDependencies ( dependencies
, file
.name
);
1872 if ( extension
== ".idl" || extension
== ".IDL" )
1874 GetWidlObjectDependencies ( dependencies
, file
.name
);
1880 MingwBuildToolModuleHandler::MingwBuildToolModuleHandler ( const Module
& module_
)
1881 : MingwModuleHandler ( module_
)
1886 MingwBuildToolModuleHandler::Process ()
1888 GenerateBuildToolModuleTarget ();
1892 MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ()
1894 string
targetMacro ( GetTargetMacro (module
) );
1895 string objectsMacro
= GetObjectsMacro ( module
);
1896 string linkDepsMacro
= GetLinkingDependenciesMacro ();
1897 string libsMacro
= GetLibsMacro ();
1902 if ( module
.cplusplus
)
1903 linker
= "${host_gpp}";
1905 linker
= "${host_gcc}";
1907 fprintf ( fMakefile
, "%s: %s %s | %s\n",
1908 targetMacro
.c_str (),
1909 objectsMacro
.c_str (),
1910 linkDepsMacro
.c_str (),
1911 GetDirectory(GetTargetFilename(module
,NULL
)).c_str () );
1912 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
1913 fprintf ( fMakefile
,
1914 "\t%s %s -o $@ %s %s\n\n",
1916 GetLinkerMacro ().c_str (),
1917 objectsMacro
.c_str (),
1918 libsMacro
.c_str () );
1922 MingwKernelModuleHandler::MingwKernelModuleHandler (
1923 const Module
& module_
)
1925 : MingwModuleHandler ( module_
)
1930 MingwKernelModuleHandler::Process ()
1932 GenerateKernelModuleTarget ();
1936 MingwKernelModuleHandler::GenerateKernelModuleTarget ()
1938 string
targetName ( module
.GetTargetName () ); // i.e. "ntoskrnl.exe"
1939 string
targetMacro ( GetTargetMacro ( module
) ); // i.e. "$(NTOSKRNL_TARGET)"
1940 string workingDirectory
= GetWorkingDirectory ();
1941 string objectsMacro
= GetObjectsMacro ( module
);
1942 string linkDepsMacro
= GetLinkingDependenciesMacro ();
1943 string libsMacro
= GetLibsMacro ();
1944 string base_tmp
= ros_temp
+ module
.name
+ ".base.tmp";
1945 CLEAN_FILE ( base_tmp
);
1946 string junk_tmp
= ros_temp
+ module
.name
+ ".junk.tmp";
1947 CLEAN_FILE ( junk_tmp
);
1948 string temp_exp
= ros_temp
+ module
.name
+ ".temp.exp";
1949 CLEAN_FILE ( temp_exp
);
1950 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",
1951 module
.GetBasePath ().c_str (),
1952 module
.entrypoint
.c_str (),
1953 module
.baseaddress
.c_str () );
1957 GenerateImportLibraryTargetIfNeeded ();
1959 fprintf ( fMakefile
, "%s: %s %s $(RSYM_TARGET) | %s\n",
1960 targetMacro
.c_str (),
1961 objectsMacro
.c_str (),
1962 linkDepsMacro
.c_str (),
1963 GetDirectory(GetTargetFilename(module
,NULL
)).c_str () );
1964 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
1965 fprintf ( fMakefile
,
1966 "\t${gcc} %s %s -Wl,--base-file,%s -o %s %s %s\n",
1967 GetLinkerMacro ().c_str (),
1968 gccOptions
.c_str (),
1971 objectsMacro
.c_str (),
1972 linkDepsMacro
.c_str () );
1973 fprintf ( fMakefile
,
1974 "\t-@${rm} %s 2>$(NUL)\n",
1975 junk_tmp
.c_str () );
1976 string killAt
= module
.mangledSymbols
? "" : "--kill-at";
1977 fprintf ( fMakefile
,
1978 "\t${dlltool} --dllname %s --base-file %s --def ntoskrnl/ntoskrnl.def --output-exp %s %s\n",
1979 targetName
.c_str (),
1983 fprintf ( fMakefile
,
1984 "\t-@${rm} %s 2>$(NUL)\n",
1985 base_tmp
.c_str () );
1986 fprintf ( fMakefile
,
1987 "\t${gcc} %s %s -Wl,%s -o $@ %s %s\n",
1988 GetLinkerMacro ().c_str (),
1989 gccOptions
.c_str (),
1991 objectsMacro
.c_str (),
1992 linkDepsMacro
.c_str () );
1993 fprintf ( fMakefile
,
1994 "\t-@${rm} %s 2>$(NUL)\n",
1995 temp_exp
.c_str () );
1996 fprintf ( fMakefile
, "\t$(ECHO_RSYM)\n" );
1997 fprintf ( fMakefile
,
1998 "\t$(Q)$(RSYM_TARGET) $@ $@\n\n" );
2002 MingwStaticLibraryModuleHandler::MingwStaticLibraryModuleHandler (
2003 const Module
& module_
)
2005 : MingwModuleHandler ( module_
)
2010 MingwStaticLibraryModuleHandler::Process ()
2012 GenerateStaticLibraryModuleTarget ();
2016 MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget ()
2022 MingwObjectLibraryModuleHandler::MingwObjectLibraryModuleHandler (
2023 const Module
& module_
)
2025 : MingwModuleHandler ( module_
)
2030 MingwObjectLibraryModuleHandler::Process ()
2032 GenerateObjectLibraryModuleTarget ();
2036 MingwObjectLibraryModuleHandler::GenerateObjectLibraryModuleTarget ()
2042 MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler (
2043 const Module
& module_
)
2045 : MingwModuleHandler ( module_
)
2050 MingwKernelModeDLLModuleHandler::Process ()
2052 GenerateKernelModeDLLModuleTarget ();
2056 MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ()
2058 string
targetMacro ( GetTargetMacro ( module
) );
2059 string workingDirectory
= GetWorkingDirectory ( );
2060 string objectsMacro
= GetObjectsMacro ( module
);
2061 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2062 string libsMacro
= GetLibsMacro ();
2064 GenerateImportLibraryTargetIfNeeded ();
2066 if ( module
.non_if_data
.files
.size () > 0 )
2070 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2072 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll",
2073 module
.entrypoint
.c_str (),
2074 module
.baseaddress
.c_str () );
2075 GenerateLinkerCommand ( dependencies
,
2083 GeneratePhonyTarget();
2088 MingwKernelModeDriverModuleHandler::MingwKernelModeDriverModuleHandler (
2089 const Module
& module_
)
2091 : MingwModuleHandler ( module_
)
2096 MingwKernelModeDriverModuleHandler::Process ()
2098 GenerateKernelModeDriverModuleTarget ();
2103 MingwKernelModeDriverModuleHandler::GenerateKernelModeDriverModuleTarget ()
2105 string
targetMacro ( GetTargetMacro (module
) );
2106 string workingDirectory
= GetWorkingDirectory ();
2107 string objectsMacro
= GetObjectsMacro ( module
);
2108 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2109 string libsMacro
= GetLibsMacro ();
2111 GenerateImportLibraryTargetIfNeeded ();
2113 if ( module
.non_if_data
.files
.size () > 0 )
2117 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2119 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll",
2120 module
.entrypoint
.c_str (),
2121 module
.baseaddress
.c_str () );
2122 GenerateLinkerCommand ( dependencies
,
2130 GeneratePhonyTarget();
2135 MingwNativeDLLModuleHandler::MingwNativeDLLModuleHandler (
2136 const Module
& module_
)
2138 : MingwModuleHandler ( module_
)
2143 MingwNativeDLLModuleHandler::Process ()
2145 GenerateNativeDLLModuleTarget ();
2149 MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ()
2151 string
targetMacro ( GetTargetMacro (module
) );
2152 string workingDirectory
= GetWorkingDirectory ( );
2153 string objectsMacro
= GetObjectsMacro ( module
);
2154 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2155 string libsMacro
= GetLibsMacro ();
2157 GenerateImportLibraryTargetIfNeeded ();
2159 if ( module
.non_if_data
.files
.size () > 0 )
2163 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2165 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib -mdll",
2166 module
.entrypoint
.c_str (),
2167 module
.baseaddress
.c_str () );
2168 GenerateLinkerCommand ( dependencies
,
2176 GeneratePhonyTarget();
2181 MingwNativeCUIModuleHandler::MingwNativeCUIModuleHandler (
2182 const Module
& module_
)
2184 : MingwModuleHandler ( module_
)
2189 MingwNativeCUIModuleHandler::Process ()
2191 GenerateNativeCUIModuleTarget ();
2195 MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ()
2197 string
targetMacro ( GetTargetMacro (module
) );
2198 string workingDirectory
= GetWorkingDirectory ( );
2199 string objectsMacro
= GetObjectsMacro ( module
);
2200 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2201 string libsMacro
= GetLibsMacro ();
2203 GenerateImportLibraryTargetIfNeeded ();
2205 if ( module
.non_if_data
.files
.size () > 0 )
2209 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2211 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib",
2212 module
.entrypoint
.c_str (),
2213 module
.baseaddress
.c_str () );
2214 GenerateLinkerCommand ( dependencies
,
2222 GeneratePhonyTarget();
2227 MingwWin32DLLModuleHandler::MingwWin32DLLModuleHandler (
2228 const Module
& module_
)
2230 : MingwModuleHandler ( module_
)
2235 MingwWin32DLLModuleHandler::Process ()
2237 GenerateExtractWineDLLResourcesTarget ();
2238 GenerateWin32DLLModuleTarget ();
2242 MingwWin32DLLModuleHandler::GenerateExtractWineDLLResourcesTarget ()
2244 fprintf ( fMakefile
, ".PHONY: %s_extractresources\n\n",
2245 module
.name
.c_str () );
2246 fprintf ( fMakefile
, "%s_extractresources: $(BIN2RES_TARGET)\n",
2247 module
.name
.c_str () );
2248 const vector
<File
*>& files
= module
.non_if_data
.files
;
2249 for ( size_t i
= 0; i
< files
.size (); i
++ )
2251 File
& file
= *files
[i
];
2252 string extension
= GetExtension ( file
.name
);
2253 if ( extension
== ".rc" || extension
== ".RC" )
2255 string resource
= NormalizeFilename ( file
.name
);
2256 fprintf ( fMakefile
, "\t$(ECHO_BIN2RES)\n" );
2257 fprintf ( fMakefile
, "\t@:echo ${bin2res} -f -x %s\n",
2258 resource
.c_str () );
2261 fprintf ( fMakefile
, "\n");
2265 MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ()
2267 string
targetMacro ( GetTargetMacro (module
) );
2268 string workingDirectory
= GetWorkingDirectory ( );
2269 string objectsMacro
= GetObjectsMacro ( module
);
2270 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2271 string libsMacro
= GetLibsMacro ();
2273 GenerateImportLibraryTargetIfNeeded ();
2275 if ( module
.non_if_data
.files
.size () > 0 )
2279 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2282 if ( module
.cplusplus
)
2287 string linkerParameters
= ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -mdll",
2288 module
.entrypoint
.c_str (),
2289 module
.baseaddress
.c_str () );
2290 GenerateLinkerCommand ( dependencies
,
2298 GeneratePhonyTarget();
2303 MingwWin32CUIModuleHandler::MingwWin32CUIModuleHandler (
2304 const Module
& module_
)
2306 : MingwModuleHandler ( module_
)
2311 MingwWin32CUIModuleHandler::Process ()
2313 GenerateWin32CUIModuleTarget ();
2317 MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ()
2319 string
targetMacro ( GetTargetMacro (module
) );
2320 string workingDirectory
= GetWorkingDirectory ( );
2321 string objectsMacro
= GetObjectsMacro ( module
);
2322 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2323 string libsMacro
= GetLibsMacro ();
2325 GenerateImportLibraryTargetIfNeeded ();
2327 if ( module
.non_if_data
.files
.size () > 0 )
2331 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2334 if ( module
.cplusplus
)
2339 string linkerParameters
= ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
2340 module
.entrypoint
.c_str (),
2341 module
.baseaddress
.c_str () );
2342 GenerateLinkerCommand ( dependencies
,
2350 GeneratePhonyTarget();
2355 MingwWin32GUIModuleHandler::MingwWin32GUIModuleHandler (
2356 const Module
& module_
)
2358 : MingwModuleHandler ( module_
)
2363 MingwWin32GUIModuleHandler::Process ()
2365 GenerateWin32GUIModuleTarget ();
2369 MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ()
2371 string
targetMacro ( GetTargetMacro (module
) );
2372 string workingDirectory
= GetWorkingDirectory ( );
2373 string objectsMacro
= GetObjectsMacro ( module
);
2374 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2375 string libsMacro
= GetLibsMacro ();
2377 GenerateImportLibraryTargetIfNeeded ();
2379 if ( module
.non_if_data
.files
.size () > 0 )
2383 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2386 if ( module
.cplusplus
)
2391 string linkerParameters
= ssprintf ( "-Wl,--subsystem,windows -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
2392 module
.entrypoint
.c_str (),
2393 module
.baseaddress
.c_str () );
2394 GenerateLinkerCommand ( dependencies
,
2402 GeneratePhonyTarget();
2407 MingwBootLoaderModuleHandler::MingwBootLoaderModuleHandler (
2408 const Module
& module_
)
2410 : MingwModuleHandler ( module_
)
2415 MingwBootLoaderModuleHandler::Process ()
2417 GenerateBootLoaderModuleTarget ();
2421 MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ()
2423 string
targetName ( module
.GetTargetName () );
2424 string
targetMacro ( GetTargetMacro (module
) );
2425 string workingDirectory
= GetWorkingDirectory ();
2426 string junk_tmp
= ros_temp
+ module
.name
+ ".junk.tmp";
2427 CLEAN_FILE ( junk_tmp
);
2428 string objectsMacro
= GetObjectsMacro ( module
);
2429 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2430 string libsMacro
= GetLibsMacro ();
2434 fprintf ( fMakefile
, "%s: %s %s | %s\n",
2435 targetMacro
.c_str (),
2436 objectsMacro
.c_str (),
2437 linkDepsMacro
.c_str (),
2438 GetDirectory(GetTargetFilename(module
,NULL
)).c_str () );
2440 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
2442 fprintf ( fMakefile
,
2443 "\t${ld} %s -N -Ttext=0x8000 -o %s %s %s\n",
2444 GetLinkerMacro ().c_str (),
2446 objectsMacro
.c_str (),
2447 linkDepsMacro
.c_str () );
2448 fprintf ( fMakefile
,
2449 "\t${objcopy} -O binary %s $@\n",
2450 junk_tmp
.c_str () );
2451 fprintf ( fMakefile
,
2452 "\t-@${rm} %s 2>$(NUL)\n",
2453 junk_tmp
.c_str () );
2457 MingwBootSectorModuleHandler::MingwBootSectorModuleHandler (
2458 const Module
& module_
)
2460 : MingwModuleHandler ( module_
)
2465 MingwBootSectorModuleHandler::Process ()
2467 GenerateBootSectorModuleTarget ();
2471 MingwBootSectorModuleHandler::GenerateBootSectorModuleTarget ()
2473 string objectsMacro
= GetObjectsMacro ( module
);
2477 fprintf ( fMakefile
, ".PHONY: %s\n\n",
2478 module
.name
.c_str ());
2479 fprintf ( fMakefile
,
2481 module
.name
.c_str (),
2482 objectsMacro
.c_str () );
2486 MingwIsoModuleHandler::MingwIsoModuleHandler (
2487 const Module
& module_
)
2489 : MingwModuleHandler ( module_
)
2494 MingwIsoModuleHandler::Process ()
2496 GenerateIsoModuleTarget ();
2500 MingwIsoModuleHandler::OutputBootstrapfileCopyCommands (
2501 const string
& bootcdDirectory
)
2503 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
2505 const Module
& m
= *module
.project
.modules
[i
];
2506 if ( m
.bootstrap
!= NULL
)
2508 string sourceFilename
= PassThruCacheDirectory (
2509 NormalizeFilename ( m
.GetPath () ),
2510 backend
->outputDirectory
);
2511 string
targetFilenameNoFixup ( bootcdDirectory
+ SSEP
+ m
.bootstrap
->base
+ SSEP
+ m
.bootstrap
->nameoncd
);
2512 string targetFilename
= MingwModuleHandler::PassThruCacheDirectory (
2513 NormalizeFilename ( targetFilenameNoFixup
),
2514 backend
->outputDirectory
);
2515 fprintf ( fMakefile
,
2517 fprintf ( fMakefile
,
2518 "\t${cp} %s %s 1>$(NUL)\n",
2519 sourceFilename
.c_str (),
2520 targetFilename
.c_str () );
2526 MingwIsoModuleHandler::OutputCdfileCopyCommands (
2527 const string
& bootcdDirectory
)
2529 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
2531 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
2532 string targetFilenameNoFixup
= bootcdDirectory
+ SSEP
+ cdfile
.base
+ SSEP
+ cdfile
.nameoncd
;
2533 string targetFilename
= MingwModuleHandler::PassThruCacheDirectory (
2534 NormalizeFilename ( targetFilenameNoFixup
),
2535 backend
->outputDirectory
);
2536 fprintf ( fMakefile
,
2538 fprintf ( fMakefile
,
2539 "\t${cp} %s %s 1>$(NUL)\n",
2540 cdfile
.GetPath ().c_str (),
2541 targetFilename
.c_str () );
2546 MingwIsoModuleHandler::GetBootstrapCdDirectories ( const string
& bootcdDirectory
)
2549 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
2551 const Module
& m
= *module
.project
.modules
[i
];
2552 if ( m
.bootstrap
!= NULL
)
2554 string
targetDirectory ( bootcdDirectory
+ SSEP
+ m
.bootstrap
->base
);
2555 if ( directories
.size () > 0 )
2557 directories
+= PassThruCacheDirectory (
2558 NormalizeFilename ( targetDirectory
),
2559 backend
->outputDirectory
);
2566 MingwIsoModuleHandler::GetNonModuleCdDirectories ( const string
& bootcdDirectory
)
2569 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
2571 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
2572 string
targetDirectory ( bootcdDirectory
+ SSEP
+ cdfile
.base
);
2573 if ( directories
.size () > 0 )
2575 directories
+= PassThruCacheDirectory (
2576 NormalizeFilename ( targetDirectory
),
2577 backend
->outputDirectory
);
2583 MingwIsoModuleHandler::GetCdDirectories ( const string
& bootcdDirectory
)
2585 string directories
= GetBootstrapCdDirectories ( bootcdDirectory
);
2586 directories
+= " " + GetNonModuleCdDirectories ( bootcdDirectory
);
2591 MingwIsoModuleHandler::GetBootstrapCdFiles (
2592 vector
<string
>& out
) const
2594 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
2596 const Module
& m
= *module
.project
.modules
[i
];
2597 if ( m
.bootstrap
!= NULL
)
2599 string filename
= PassThruCacheDirectory (
2600 NormalizeFilename ( m
.GetPath () ),
2601 backend
->outputDirectory
);
2602 out
.push_back ( filename
);
2608 MingwIsoModuleHandler::GetNonModuleCdFiles (
2609 vector
<string
>& out
) const
2611 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
2613 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
2614 out
.push_back ( cdfile
.GetPath () );
2619 MingwIsoModuleHandler::GetCdFiles (
2620 vector
<string
>& out
) const
2622 GetBootstrapCdFiles ( out
);
2623 GetNonModuleCdFiles ( out
);
2627 MingwIsoModuleHandler::GenerateIsoModuleTarget ()
2629 string bootcdDirectory
= "cd";
2630 string bootcd
= PassThruCacheDirectory (
2631 NormalizeFilename ( bootcdDirectory
+ SSEP
),
2632 backend
->outputDirectory
);
2633 string isoboot
= PassThruCacheDirectory (
2634 NormalizeFilename ( "boot" SSEP
"freeldr" SSEP
"bootsect" SSEP
"isoboot.o" ),
2635 backend
->outputDirectory
);
2636 string bootcdReactosNoFixup
= bootcdDirectory
+ SSEP
"reactos";
2637 string bootcdReactos
= PassThruCacheDirectory (
2638 NormalizeFilename ( bootcdReactosNoFixup
+ SSEP
),
2639 backend
->outputDirectory
);
2640 CLEAN_FILE ( bootcdReactos
);
2641 string reactosInf
= PassThruCacheDirectory (
2642 NormalizeFilename ( bootcdReactosNoFixup
+ SSEP
"reactos.inf" ),
2643 backend
->outputDirectory
);
2644 string reactosDff
= NormalizeFilename ( "bootdata" SSEP
"packages" SSEP
"reactos.dff" );
2645 string cdDirectories
= GetCdDirectories ( bootcdDirectory
);
2646 vector
<string
> vCdFiles
;
2647 GetCdFiles ( vCdFiles
);
2648 string cdFiles
= v2s ( vCdFiles
, 5 );
2650 fprintf ( fMakefile
, ".PHONY: %s\n\n",
2651 module
.name
.c_str ());
2652 fprintf ( fMakefile
,
2653 "%s: all %s %s %s %s $(CABMAN_TARGET) $(CDMAKE_TARGET)\n",
2654 module
.name
.c_str (),
2656 bootcdReactos
.c_str (),
2657 cdDirectories
.c_str (),
2659 fprintf ( fMakefile
, "\t$(ECHO_CABMAN)\n" );
2660 fprintf ( fMakefile
,
2661 "\t$(Q)$(CABMAN_TARGET) -C %s -L %s -I -P $(OUTPUT)\n",
2662 reactosDff
.c_str (),
2663 bootcdReactos
.c_str () );
2664 fprintf ( fMakefile
,
2665 "\t$(Q)$(CABMAN_TARGET) -C %s -RC %s -L %s -N -P $(OUTPUT)\n",
2666 reactosDff
.c_str (),
2667 reactosInf
.c_str (),
2668 bootcdReactos
.c_str ());
2669 fprintf ( fMakefile
,
2670 "\t-@${rm} %s 2>$(NUL)\n",
2671 reactosInf
.c_str () );
2672 OutputBootstrapfileCopyCommands ( bootcdDirectory
);
2673 OutputCdfileCopyCommands ( bootcdDirectory
);
2674 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
2675 fprintf ( fMakefile
,
2676 "\t$(Q)$(CDMAKE_TARGET) -v -m -b %s %s REACTOS ReactOS.iso\n",
2679 fprintf ( fMakefile
,
2684 MingwLiveIsoModuleHandler::MingwLiveIsoModuleHandler (
2685 const Module
& module_
)
2687 : MingwModuleHandler ( module_
)
2692 MingwLiveIsoModuleHandler::Process ()
2694 GenerateLiveIsoModuleTarget ();
2698 MingwLiveIsoModuleHandler::CreateDirectory ( const string
& directory
)
2700 string normalizedDirectory
= MingwModuleHandler::PassThruCacheDirectory (
2701 NormalizeFilename ( directory
) + SSEP
,
2702 backend
->outputDirectory
);
2706 MingwLiveIsoModuleHandler::OutputCopyCommand ( const string
& sourceFilename
,
2707 const string
& targetFilename
,
2708 const string
& targetDirectory
)
2710 string normalizedTargetFilename
= MingwModuleHandler::PassThruCacheDirectory (
2711 NormalizeFilename ( targetDirectory
+ SSEP
+ targetFilename
),
2712 backend
->outputDirectory
);
2713 fprintf ( fMakefile
,
2715 fprintf ( fMakefile
,
2716 "\t${cp} %s %s 1>$(NUL)\n",
2717 sourceFilename
.c_str (),
2718 normalizedTargetFilename
.c_str () );
2722 MingwLiveIsoModuleHandler::OutputModuleCopyCommands ( string
& livecdDirectory
,
2723 string
& reactosDirectory
)
2725 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
2727 const Module
& m
= *module
.project
.modules
[i
];
2728 if ( m
.installName
.length () > 0 )
2730 string sourceFilename
= MingwModuleHandler::PassThruCacheDirectory (
2731 NormalizeFilename ( m
.GetPath () ),
2732 backend
->outputDirectory
);
2733 OutputCopyCommand ( sourceFilename
,
2735 livecdDirectory
+ SSEP
+ reactosDirectory
+ SSEP
+ m
.installBase
);
2741 MingwLiveIsoModuleHandler::OutputNonModuleCopyCommands ( string
& livecdDirectory
,
2742 string
& reactosDirectory
)
2744 for ( size_t i
= 0; i
< module
.project
.installfiles
.size (); i
++ )
2746 const InstallFile
& installfile
= *module
.project
.installfiles
[i
];
2747 OutputCopyCommand ( installfile
.GetPath (),
2748 installfile
.newname
,
2749 livecdDirectory
+ SSEP
+ reactosDirectory
+ SSEP
+ installfile
.base
);
2754 MingwLiveIsoModuleHandler::OutputProfilesDirectoryCommands ( string
& livecdDirectory
)
2756 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" );
2757 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" SSEP
"All Users") ;
2758 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" SSEP
"All Users" SSEP
"Desktop" );
2759 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" SSEP
"Default User" );
2760 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" SSEP
"Default User" SSEP
"Desktop" );
2761 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" SSEP
"Default User" SSEP
"My Documents" );
2763 string livecdIni
= "bootdata" SSEP
"livecd.ini";
2764 OutputCopyCommand ( livecdIni
,
2770 MingwLiveIsoModuleHandler::OutputLoaderCommands ( string
& livecdDirectory
)
2772 string freeldr
= PassThruCacheDirectory (
2773 NormalizeFilename ( "boot" SSEP
"freeldr" SSEP
"freeldr" SSEP
"freeldr.sys" ),
2774 backend
->outputDirectory
);
2775 CreateDirectory ( livecdDirectory
+ SSEP
"loader" );
2776 OutputCopyCommand ( freeldr
,
2778 livecdDirectory
+ SSEP
+ "loader" );
2782 MingwLiveIsoModuleHandler::OutputRegistryCommands ( string
& livecdDirectory
)
2784 string reactosSystem32ConfigDirectory
= NormalizeFilename (
2785 MingwModuleHandler::PassThruCacheDirectory (
2786 livecdDirectory
+ SSEP
"reactos" SSEP
"system32" SSEP
"config" SSEP
,
2787 backend
->outputDirectory
) );
2788 fprintf ( fMakefile
,
2789 "\t$(ECHO_MKHIVE)\n" );
2790 fprintf ( fMakefile
,
2791 "\t$(MKHIVE_TARGET) bootdata %s bootdata" SSEP
"livecd.inf bootdata" SSEP
"hiveinst.inf\n",
2792 reactosSystem32ConfigDirectory
.c_str () );
2796 MingwLiveIsoModuleHandler::GenerateLiveIsoModuleTarget ()
2798 string livecdDirectory
= "livecd";
2799 string livecd
= PassThruCacheDirectory (
2800 NormalizeFilename ( livecdDirectory
+ SSEP
),
2801 backend
->outputDirectory
);
2802 string isoboot
= PassThruCacheDirectory (
2803 NormalizeFilename ( "boot" SSEP
"freeldr" SSEP
"bootsect" SSEP
"isoboot.o" ),
2804 backend
->outputDirectory
);
2805 string reactosDirectory
= "reactos";
2806 string livecdReactosNoFixup
= livecdDirectory
+ SSEP
+ reactosDirectory
;
2807 string livecdReactos
= NormalizeFilename ( PassThruCacheDirectory (
2808 NormalizeFilename ( livecdReactosNoFixup
+ SSEP
),
2809 backend
->outputDirectory
) );
2810 CLEAN_FILE ( livecdReactos
);
2812 fprintf ( fMakefile
, ".PHONY: %s\n\n",
2813 module
.name
.c_str ());
2814 fprintf ( fMakefile
,
2815 "%s: all %s %s $(MKHIVE_TARGET) $(CDMAKE_TARGET)\n",
2816 module
.name
.c_str (),
2818 livecdReactos
.c_str () );
2819 OutputModuleCopyCommands ( livecdDirectory
,
2821 OutputNonModuleCopyCommands ( livecdDirectory
,
2823 OutputProfilesDirectoryCommands ( livecdDirectory
);
2824 OutputLoaderCommands ( livecdDirectory
);
2825 OutputRegistryCommands ( livecdDirectory
);
2826 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
2827 fprintf ( fMakefile
,
2828 "\t$(Q)$(CDMAKE_TARGET) -v -m -j -b %s %s REACTOS ReactOS-LiveCD.iso\n",
2831 fprintf ( fMakefile
,
2836 MingwTestModuleHandler::MingwTestModuleHandler (
2837 const Module
& module_
)
2839 : MingwModuleHandler ( module_
)
2844 MingwTestModuleHandler::Process ()
2846 GenerateTestModuleTarget ();
2850 MingwTestModuleHandler::GenerateTestModuleTarget ()
2852 string
targetMacro ( GetTargetMacro ( module
) );
2853 string workingDirectory
= GetWorkingDirectory ( );
2854 string objectsMacro
= GetObjectsMacro ( module
);
2855 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2856 string libsMacro
= GetLibsMacro ();
2858 GenerateImportLibraryTargetIfNeeded ();
2860 if ( module
.non_if_data
.files
.size () > 0 )
2864 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2867 if ( module
.cplusplus
)
2872 string linkerParameters
= ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
2873 module
.entrypoint
.c_str (),
2874 module
.baseaddress
.c_str () );
2875 GenerateLinkerCommand ( dependencies
,
2883 GeneratePhonyTarget();
2888 MingwRpcServerModuleHandler::MingwRpcServerModuleHandler (
2889 const Module
& module_
)
2891 : MingwModuleHandler ( module_
)
2896 MingwRpcServerModuleHandler::Process ()
2901 MingwRpcClientModuleHandler::MingwRpcClientModuleHandler (
2902 const Module
& module_
)
2904 : MingwModuleHandler ( module_
)
2909 MingwRpcClientModuleHandler::Process ()