4 #include "../../rbuild.h"
6 #include "modulehandler.h"
11 #define CLEAN_FILE(f) clean_files.push_back ( f );
13 static string ros_temp
= "$(TEMPORARY)";
15 MingwModuleHandler::backend
= NULL
;
17 MingwModuleHandler::fMakefile
= NULL
;
19 MingwModuleHandler::use_pch
= false;
23 const string
& filename
,
24 const string
& prefix
)
26 if ( !prefix
.length() )
29 const char* pfilename
= filename
.c_str();
30 const char* p1
= strrchr ( pfilename
, '/' );
31 const char* p2
= strrchr ( pfilename
, '\\' );
36 out
+= string(pfilename
,p1
-pfilename
) + CSEP
;
39 out
+= prefix
+ pfilename
;
44 GetTargetMacro ( const Module
& module
, bool with_dollar
)
46 string
s ( module
.name
);
50 return ssprintf ( "$(%s)", s
.c_str() );
54 MingwModuleHandler::MingwModuleHandler (
55 const Module
& module_
)
61 MingwModuleHandler::~MingwModuleHandler()
66 MingwModuleHandler::SetBackend ( MingwBackend
* backend_
)
72 MingwModuleHandler::SetMakefile ( FILE* f
)
78 MingwModuleHandler::SetUsePch ( bool b
)
84 MingwModuleHandler::RemoveVariables ( string path
)
86 size_t i
= path
.find ( '$' );
87 if ( i
!= string::npos
)
89 size_t j
= path
.find ( ')', i
);
90 if ( j
!= string::npos
)
92 if ( j
+ 2 < path
.length () && path
[j
+ 1] == CSEP
)
93 return path
.substr ( j
+ 2);
95 return path
.substr ( j
+ 1);
102 MingwModuleHandler::PassThruCacheDirectory (
104 Directory
* directoryTree
)
106 string
directory ( GetDirectory ( RemoveVariables ( file
) ) );
107 string generatedFilesDirectory
= backend
->AddDirectoryTarget ( directory
,
109 if ( directory
.find ( generatedFilesDirectory
) != string::npos
)
110 /* This path already includes the generated files directory variable */
115 return generatedFilesDirectory
;
116 return generatedFilesDirectory
+ SSEP
+ file
;
120 /*static*/ Directory
*
121 MingwModuleHandler::GetTargetDirectoryTree (
122 const Module
& module
)
124 if ( module
.type
== StaticLibrary
)
125 return backend
->intermediateDirectory
;
126 return backend
->outputDirectory
;
130 MingwModuleHandler::GetTargetFilename (
131 const Module
& module
,
132 string_list
* pclean_files
)
134 string target
= PassThruCacheDirectory (
135 NormalizeFilename ( module
.GetPath () ),
136 GetTargetDirectoryTree ( module
) );
139 string_list
& clean_files
= *pclean_files
;
140 CLEAN_FILE ( target
);
146 MingwModuleHandler::GetImportLibraryFilename (
147 const Module
& module
,
148 string_list
* pclean_files
)
150 string target
= PassThruCacheDirectory (
151 NormalizeFilename ( module
.GetDependencyPath () ),
152 backend
->intermediateDirectory
);
155 string_list
& clean_files
= *pclean_files
;
156 CLEAN_FILE ( target
);
161 /*static*/ MingwModuleHandler
*
162 MingwModuleHandler::InstanciateHandler (
163 const Module
& module
,
164 MingwBackend
* backend
)
166 MingwModuleHandler
* handler
;
167 switch ( module
.type
)
170 handler
= new MingwBuildToolModuleHandler ( module
);
173 handler
= new MingwStaticLibraryModuleHandler ( module
);
176 handler
= new MingwObjectLibraryModuleHandler ( module
);
179 handler
= new MingwKernelModuleHandler ( module
);
182 handler
= new MingwNativeCUIModuleHandler ( module
);
185 handler
= new MingwWin32CUIModuleHandler ( module
);
188 handler
= new MingwWin32GUIModuleHandler ( module
);
191 handler
= new MingwKernelModeDLLModuleHandler ( module
);
194 handler
= new MingwNativeDLLModuleHandler ( module
);
197 handler
= new MingwWin32DLLModuleHandler ( module
);
199 case KernelModeDriver
:
200 handler
= new MingwKernelModeDriverModuleHandler ( module
);
203 handler
= new MingwBootLoaderModuleHandler ( module
);
206 handler
= new MingwBootSectorModuleHandler ( module
);
209 handler
= new MingwIsoModuleHandler ( module
);
212 handler
= new MingwLiveIsoModuleHandler ( module
);
215 handler
= new MingwTestModuleHandler ( module
);
218 handler
= new MingwRpcServerModuleHandler ( module
);
221 handler
= new MingwRpcClientModuleHandler ( module
);
224 throw UnknownModuleTypeException (
225 module
.node
.location
,
233 MingwModuleHandler::GetWorkingDirectory () const
239 MingwModuleHandler::GetBasename ( const string
& filename
) const
241 size_t index
= filename
.find_last_of ( '.' );
242 if ( index
!= string::npos
)
243 return filename
.substr ( 0, index
);
248 MingwModuleHandler::GetActualSourceFilename (
249 const string
& filename
) const
251 string extension
= GetExtension ( filename
);
252 if ( extension
== ".spec" || extension
== ".SPEC" )
254 string basename
= GetBasename ( filename
);
255 return PassThruCacheDirectory ( NormalizeFilename ( basename
+ ".stubs.c" ),
256 backend
->intermediateDirectory
);
258 else if ( extension
== ".idl" || extension
== ".IDL" )
260 string basename
= GetBasename ( filename
);
262 if ( module
.type
== RpcServer
)
263 newname
= basename
+ "_s.c";
265 newname
= basename
+ "_c.c";
266 return PassThruCacheDirectory ( NormalizeFilename ( newname
),
267 backend
->intermediateDirectory
);
274 MingwModuleHandler::GetModuleArchiveFilename () const
276 if ( module
.type
== StaticLibrary
)
277 return GetTargetFilename ( module
, NULL
);
278 return PassThruCacheDirectory ( ReplaceExtension (
279 NormalizeFilename ( module
.GetPath () ),
281 backend
->intermediateDirectory
);
285 MingwModuleHandler::IsGeneratedFile ( const File
& file
) const
287 string extension
= GetExtension ( file
.name
);
288 return ( extension
== ".spec" || extension
== ".SPEC" );
292 MingwModuleHandler::ReferenceObjects (
293 const Module
& module
)
295 if ( module
.type
== ObjectLibrary
)
297 if ( module
.type
== RpcServer
)
299 if ( module
.type
== RpcClient
)
305 MingwModuleHandler::GetImportLibraryDependency (
306 const Module
& importedModule
)
309 if ( ReferenceObjects ( importedModule
) )
310 dep
= GetTargetMacro ( importedModule
);
312 dep
= GetImportLibraryFilename ( importedModule
, NULL
);
317 MingwModuleHandler::GetTargets ( const Module
& dependencyModule
,
318 string_list
& targets
)
320 if ( dependencyModule
.invocations
.size () > 0 )
322 for ( size_t i
= 0; i
< dependencyModule
.invocations
.size (); i
++ )
324 Invoke
& invoke
= *dependencyModule
.invocations
[i
];
325 invoke
.GetTargets ( targets
);
329 targets
.push_back ( GetImportLibraryDependency ( dependencyModule
) );
333 MingwModuleHandler::GetModuleDependencies (
334 string_list
& dependencies
)
336 size_t iend
= module
.dependencies
.size ();
341 for ( size_t i
= 0; i
< iend
; i
++ )
343 const Dependency
& dependency
= *module
.dependencies
[i
];
344 const Module
& dependencyModule
= *dependency
.dependencyModule
;
345 GetTargets ( dependencyModule
,
348 GetDefinitionDependencies ( dependencies
);
352 MingwModuleHandler::GetSourceFilenames (
354 bool includeGeneratedFiles
) const
358 const vector
<File
*>& files
= module
.non_if_data
.files
;
359 for ( i
= 0; i
< files
.size (); i
++ )
361 if ( includeGeneratedFiles
|| !IsGeneratedFile ( *files
[i
] ) )
364 GetActualSourceFilename ( files
[i
]->name
) );
367 // intentionally make a copy so that we can append more work in
368 // the middle of processing without having to go recursive
369 vector
<If
*> v
= module
.non_if_data
.ifs
;
370 for ( i
= 0; i
< v
.size (); i
++ )
374 // check for sub-ifs to add to list
375 const vector
<If
*>& ifs
= rIf
.data
.ifs
;
376 for ( j
= 0; j
< ifs
.size (); j
++ )
377 v
.push_back ( ifs
[j
] );
378 const vector
<File
*>& files
= rIf
.data
.files
;
379 for ( j
= 0; j
< files
.size (); j
++ )
381 File
& file
= *files
[j
];
382 if ( includeGeneratedFiles
|| !IsGeneratedFile ( file
) )
385 GetActualSourceFilename ( file
.name
) );
392 MingwModuleHandler::GetSourceFilenamesWithoutGeneratedFiles (
393 string_list
& list
) const
395 GetSourceFilenames ( list
, false );
399 MingwModuleHandler::GetObjectFilename (
400 const string
& sourceFilename
,
401 string_list
* pclean_files
) const
403 Directory
* directoryTree
;
406 string extension
= GetExtension ( sourceFilename
);
407 if ( extension
== ".rc" || extension
== ".RC" )
408 newExtension
= ".coff";
409 else if ( extension
== ".spec" || extension
== ".SPEC" )
410 newExtension
= ".stubs.o";
411 else if ( extension
== ".idl" || extension
== ".IDL" )
413 if ( module
.type
== RpcServer
)
414 newExtension
= "_s.o";
416 newExtension
= "_c.o";
421 if ( module
.type
== BootSector
)
422 directoryTree
= backend
->outputDirectory
;
424 directoryTree
= backend
->intermediateDirectory
;
426 string obj_file
= PassThruCacheDirectory (
427 NormalizeFilename ( ReplaceExtension (
428 RemoveVariables ( sourceFilename
),
433 string_list
& clean_files
= *pclean_files
;
434 CLEAN_FILE ( obj_file
);
440 MingwModuleHandler::GenerateCleanTarget () const
442 if ( 0 == clean_files
.size() )
444 fprintf ( fMakefile
, ".PHONY: %s_clean\n", module
.name
.c_str() );
445 fprintf ( fMakefile
, "%s_clean:\n\t-@${rm}", module
.name
.c_str() );
446 for ( size_t i
= 0; i
< clean_files
.size(); i
++ )
449 fprintf ( fMakefile
, " 2>$(NUL)\n\t-@${rm}" );
450 fprintf ( fMakefile
, " %s", clean_files
[i
].c_str() );
452 fprintf ( fMakefile
, " 2>$(NUL)\n" );
453 fprintf ( fMakefile
, "clean: %s_clean\n\n", module
.name
.c_str() );
457 MingwModuleHandler::GenerateInstallTarget () const
459 if ( module
.installName
.length () == 0 )
461 fprintf ( fMakefile
, ".PHONY: %s_install\n", module
.name
.c_str() );
462 fprintf ( fMakefile
, "%s_install:\n", module
.name
.c_str() );
463 string sourceFilename
= MingwModuleHandler::PassThruCacheDirectory (
464 NormalizeFilename ( module
.GetPath () ),
465 backend
->outputDirectory
);
466 string normalizedTargetFilename
= MingwModuleHandler::PassThruCacheDirectory (
467 NormalizeFilename ( module
.installBase
+ SSEP
+ module
.installName
),
468 backend
->installDirectory
);
472 "\t${cp} %s %s 1>$(NUL)\n",
473 sourceFilename
.c_str (),
474 normalizedTargetFilename
.c_str () );
478 MingwModuleHandler::GetObjectFilenames ()
480 const vector
<File
*>& files
= module
.non_if_data
.files
;
481 if ( files
.size () == 0 )
484 string
objectFilenames ( "" );
485 for ( size_t i
= 0; i
< files
.size (); i
++ )
487 if ( objectFilenames
.size () > 0 )
488 objectFilenames
+= " ";
490 GetObjectFilename ( files
[i
]->name
, NULL
);
492 return objectFilenames
;
496 MingwModuleHandler::GenerateGccDefineParametersFromVector (
497 const vector
<Define
*>& defines
)
500 for ( size_t i
= 0; i
< defines
.size (); i
++ )
502 Define
& define
= *defines
[i
];
503 if (parameters
.length () > 0)
506 parameters
+= define
.name
;
507 if (define
.value
.length () > 0)
510 parameters
+= define
.value
;
517 MingwModuleHandler::GenerateGccDefineParameters () const
519 string parameters
= GenerateGccDefineParametersFromVector ( module
.project
.non_if_data
.defines
);
520 string s
= GenerateGccDefineParametersFromVector ( module
.non_if_data
.defines
);
521 if ( s
.length () > 0 )
530 MingwModuleHandler::ConcatenatePaths (
532 const string
& path2
) const
534 if ( ( path1
.length () == 0 ) || ( path1
== "." ) || ( path1
== "./" ) )
536 if ( path1
[path1
.length ()] == CSEP
)
537 return path1
+ path2
;
539 return path1
+ CSEP
+ path2
;
543 MingwModuleHandler::GenerateGccIncludeParametersFromVector ( const vector
<Include
*>& includes
)
546 for ( size_t i
= 0; i
< includes
.size (); i
++ )
548 Include
& include
= *includes
[i
];
549 if ( parameters
.length () > 0 )
551 parameters
+= "-I" + include
.directory
;
557 MingwModuleHandler::GenerateGccIncludeParameters () const
559 string parameters
= GenerateGccIncludeParametersFromVector ( module
.non_if_data
.includes
);
560 string s
= GenerateGccIncludeParametersFromVector ( module
.project
.non_if_data
.includes
);
561 if ( s
.length () > 0 )
570 MingwModuleHandler::GenerateCompilerParametersFromVector ( const vector
<CompilerFlag
*>& compilerFlags
) const
573 for ( size_t i
= 0; i
< compilerFlags
.size (); i
++ )
575 CompilerFlag
& compilerFlag
= *compilerFlags
[i
];
576 if ( parameters
.length () > 0 )
578 parameters
+= compilerFlag
.flag
;
584 MingwModuleHandler::GenerateLinkerParametersFromVector ( const vector
<LinkerFlag
*>& linkerFlags
) const
587 for ( size_t i
= 0; i
< linkerFlags
.size (); i
++ )
589 LinkerFlag
& linkerFlag
= *linkerFlags
[i
];
590 if ( parameters
.length () > 0 )
592 parameters
+= linkerFlag
.flag
;
598 MingwModuleHandler::GenerateImportLibraryDependenciesFromVector (
599 const vector
<Library
*>& libraries
)
601 string
dependencies ( "" );
603 for ( size_t i
= 0; i
< libraries
.size (); i
++ )
605 if ( wrap_count
++ == 5 )
606 dependencies
+= " \\\n\t\t", wrap_count
= 0;
607 else if ( dependencies
.size () > 0 )
609 dependencies
+= GetImportLibraryDependency ( *libraries
[i
]->imported_module
);
615 MingwModuleHandler::GenerateLinkerParameters () const
617 return GenerateLinkerParametersFromVector ( module
.linkerFlags
);
621 MingwModuleHandler::GenerateMacro (
622 const char* assignmentOperation
,
624 const IfableData
& data
)
632 assignmentOperation
);
634 string compilerParameters
= GenerateCompilerParametersFromVector ( data
.compilerFlags
);
635 if ( compilerParameters
.size () > 0 )
640 compilerParameters
.c_str () );
643 for ( i
= 0; i
< data
.includes
.size(); i
++ )
648 data
.includes
[i
]->directory
.c_str() );
650 for ( i
= 0; i
< data
.defines
.size(); i
++ )
652 Define
& d
= *data
.defines
[i
];
657 if ( d
.value
.size() )
663 fprintf ( fMakefile
, "\n" );
667 MingwModuleHandler::GenerateMacros (
668 const char* assignmentOperation
,
669 const IfableData
& data
,
670 const vector
<LinkerFlag
*>* linkerFlags
)
674 if ( data
.includes
.size () > 0 || data
.defines
.size () > 0 || data
.compilerFlags
.size () > 0 )
676 GenerateMacro ( assignmentOperation
,
679 GenerateMacro ( assignmentOperation
,
684 if ( linkerFlags
!= NULL
)
686 string linkerParameters
= GenerateLinkerParametersFromVector ( *linkerFlags
);
687 if ( linkerParameters
.size () > 0 )
692 linkerflagsMacro
.c_str (),
694 linkerParameters
.c_str() );
698 if ( data
.libraries
.size () > 0 )
700 string deps
= GenerateImportLibraryDependenciesFromVector ( data
.libraries
);
701 if ( deps
.size () > 0 )
712 const vector
<If
*>& ifs
= data
.ifs
;
713 for ( i
= 0; i
< ifs
.size(); i
++ )
716 if ( rIf
.data
.defines
.size()
717 || rIf
.data
.includes
.size()
718 || rIf
.data
.libraries
.size()
719 || rIf
.data
.files
.size()
720 || rIf
.data
.compilerFlags
.size()
721 || rIf
.data
.ifs
.size() )
725 "ifeq (\"$(%s)\",\"%s\")\n",
726 rIf
.property
.c_str(),
740 MingwModuleHandler::GenerateObjectMacros (
741 const char* assignmentOperation
,
742 const IfableData
& data
,
743 const vector
<LinkerFlag
*>* linkerFlags
)
747 const vector
<File
*>& files
= data
.files
;
748 if ( files
.size () > 0 )
750 for ( i
= 0; i
< files
.size (); i
++ )
752 File
& file
= *files
[i
];
757 objectsMacro
.c_str(),
759 file
.name
, NULL
).c_str (),
760 objectsMacro
.c_str() );
766 objectsMacro
.c_str (),
767 assignmentOperation
);
768 for ( i
= 0; i
< files
.size(); i
++ )
770 File
& file
= *files
[i
];
776 ( i
%10 == 9 ? " \\\n\t" : " " ),
778 file
.name
, NULL
).c_str () );
781 fprintf ( fMakefile
, "\n" );
784 const vector
<If
*>& ifs
= data
.ifs
;
785 for ( i
= 0; i
< ifs
.size(); i
++ )
788 if ( rIf
.data
.defines
.size()
789 || rIf
.data
.includes
.size()
790 || rIf
.data
.libraries
.size()
791 || rIf
.data
.files
.size()
792 || rIf
.data
.compilerFlags
.size()
793 || rIf
.data
.ifs
.size() )
797 "ifeq (\"$(%s)\",\"%s\")\n",
798 rIf
.property
.c_str(),
800 GenerateObjectMacros (
812 MingwModuleHandler::GenerateGccCommand (
813 const string
& sourceFilename
,
815 const string
& cflagsMacro
)
817 string dependencies
= sourceFilename
;
818 if ( module
.pch
&& use_pch
)
819 dependencies
+= " " + module
.pch
->header
+ ".gch";
821 /* WIDL generated headers may be used */
822 dependencies
+= " " + GetLinkingDependenciesMacro ();
823 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
825 string objectFilename
= GetObjectFilename (
826 sourceFilename
, &clean_files
);
829 objectFilename
.c_str (),
830 dependencies
.c_str (),
831 GetDirectory ( objectFilename
).c_str () );
832 fprintf ( fMakefile
, "\t$(ECHO_CC)\n" );
834 "\t%s -c $< -o $@ %s\n",
836 cflagsMacro
.c_str () );
840 MingwModuleHandler::GenerateGccAssemblerCommand (
841 const string
& sourceFilename
,
843 const string
& cflagsMacro
)
845 string dependencies
= sourceFilename
;
846 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
847 string objectFilename
= GetObjectFilename (
848 sourceFilename
, &clean_files
);
851 objectFilename
.c_str (),
852 dependencies
.c_str (),
853 GetDirectory ( objectFilename
).c_str () );
854 fprintf ( fMakefile
, "\t$(ECHO_GAS)\n" );
856 "\t%s -x assembler-with-cpp -c $< -o $@ -D__ASM__ %s\n",
858 cflagsMacro
.c_str () );
862 MingwModuleHandler::GenerateNasmCommand (
863 const string
& sourceFilename
,
864 const string
& nasmflagsMacro
)
866 string dependencies
= sourceFilename
;
867 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
868 string objectFilename
= GetObjectFilename (
869 sourceFilename
, &clean_files
);
872 objectFilename
.c_str (),
873 dependencies
.c_str (),
874 GetDirectory ( objectFilename
).c_str () );
875 fprintf ( fMakefile
, "\t$(ECHO_NASM)\n" );
877 "\t%s -f win32 $< -o $@ %s\n",
879 nasmflagsMacro
.c_str () );
883 MingwModuleHandler::GenerateWindresCommand (
884 const string
& sourceFilename
,
885 const string
& windresflagsMacro
)
887 string dependencies
= sourceFilename
;
888 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
889 string objectFilename
=
890 GetObjectFilename ( sourceFilename
, &clean_files
);
891 string rciFilename
= ros_temp
+ module
.name
+ ".rci.tmp";
892 string resFilename
= ros_temp
+ module
.name
+ ".res.tmp";
896 "%s: %s $(WRC_TARGET) | %s\n",
897 objectFilename
.c_str (),
898 dependencies
.c_str (),
899 GetDirectory ( objectFilename
).c_str () );
900 fprintf ( fMakefile
, "\t$(ECHO_WRC)\n" );
902 "\t${gcc} -xc -E -DRC_INVOKED ${%s} %s > %s\n",
903 windresflagsMacro
.c_str (),
904 sourceFilename
.c_str (),
905 rciFilename
.c_str () );
907 "\t$(Q)$(WRC_TARGET) ${%s} %s %s\n",
908 windresflagsMacro
.c_str (),
909 rciFilename
.c_str (),
910 resFilename
.c_str () );
912 "\t-@${rm} %s 2>$(NUL)\n",
913 rciFilename
.c_str () );
915 "\t${windres} %s -o $@\n",
916 resFilename
.c_str () );
918 "\t-@${rm} %s 2>$(NUL)\n",
919 resFilename
.c_str () );
924 "%s: %s $(WRC_TARGET) | %s\n",
925 objectFilename
.c_str (),
926 dependencies
.c_str (),
927 GetDirectory ( objectFilename
).c_str () );
928 fprintf ( fMakefile
, "\t$(ECHO_WRC)\n" );
930 "\t${windres} $(%s) %s -o $@\n",
931 windresflagsMacro
.c_str (),
932 sourceFilename
.c_str () );
937 MingwModuleHandler::GenerateWinebuildCommands (
938 const string
& sourceFilename
)
940 string dependencies
= sourceFilename
;
941 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
943 string basename
= GetBasename ( sourceFilename
);
944 string def_file
= PassThruCacheDirectory (
945 basename
+ ".spec.def",
946 backend
->intermediateDirectory
);
947 CLEAN_FILE(def_file
);
949 string stub_file
= PassThruCacheDirectory (
950 basename
+ ".stubs.c",
951 backend
->intermediateDirectory
);
952 CLEAN_FILE(stub_file
)
955 "%s: %s $(WINEBUILD_TARGET)\n",
957 dependencies
.c_str () );
958 fprintf ( fMakefile
, "\t$(ECHO_WINEBLD)\n" );
960 "\t%s --def=%s -o %s\n",
961 "$(Q)$(WINEBUILD_TARGET)",
962 sourceFilename
.c_str (),
966 "%s: %s $(WINEBUILD_TARGET)\n",
968 sourceFilename
.c_str () );
969 fprintf ( fMakefile
, "\t$(ECHO_WINEBLD)\n" );
971 "\t%s --pedll=%s -o %s\n",
972 "$(Q)$(WINEBUILD_TARGET)",
973 sourceFilename
.c_str (),
974 stub_file
.c_str () );
978 MingwModuleHandler::GetWidlFlags ( const File
& file
)
980 return file
.switches
;
984 MingwModuleHandler::GenerateWidlCommandsServer (
986 const string
& widlflagsMacro
)
988 string dependencies
= file
.name
;
989 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
991 string basename
= GetBasename ( file
.name
);
993 /*string generatedHeaderFilename = PassThruCacheDirectory (
995 backend->intermediateDirectory );
996 CLEAN_FILE(generatedHeaderFilename);
998 string generatedHeaderFilename
= basename
+ "_s.h";
999 CLEAN_FILE(generatedHeaderFilename
);
1001 string generatedServerFilename
= PassThruCacheDirectory (
1003 backend
->intermediateDirectory
);
1004 CLEAN_FILE(generatedServerFilename
);
1006 fprintf ( fMakefile
,
1007 "%s %s: %s $(WIDL_TARGET) | %s\n",
1008 generatedServerFilename
.c_str (),
1009 generatedHeaderFilename
.c_str (),
1010 dependencies
.c_str (),
1011 GetDirectory ( generatedServerFilename
).c_str () );
1012 fprintf ( fMakefile
, "\t$(ECHO_WIDL)\n" );
1013 fprintf ( fMakefile
,
1014 "\t%s %s %s -h -H %s -s -S %s %s\n",
1015 "$(Q)$(WIDL_TARGET)",
1016 GetWidlFlags ( file
).c_str (),
1017 widlflagsMacro
.c_str (),
1018 generatedHeaderFilename
.c_str (),
1019 generatedServerFilename
.c_str (),
1020 file
.name
.c_str () );
1024 MingwModuleHandler::GenerateWidlCommandsClient (
1026 const string
& widlflagsMacro
)
1028 string dependencies
= file
.name
;
1029 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
1031 string basename
= GetBasename ( file
.name
);
1033 /*string generatedHeaderFilename = PassThruCacheDirectory (
1035 backend->intermediateDirectory );
1036 CLEAN_FILE(generatedHeaderFilename);
1038 string generatedHeaderFilename
= basename
+ "_c.h";
1039 CLEAN_FILE(generatedHeaderFilename
);
1041 string generatedClientFilename
= PassThruCacheDirectory (
1043 backend
->intermediateDirectory
);
1044 CLEAN_FILE(generatedClientFilename
);
1046 fprintf ( fMakefile
,
1047 "%s %s: %s $(WIDL_TARGET) | %s\n",
1048 generatedClientFilename
.c_str (),
1049 generatedHeaderFilename
.c_str (),
1050 dependencies
.c_str (),
1051 GetDirectory ( generatedClientFilename
).c_str () );
1052 fprintf ( fMakefile
, "\t$(ECHO_WIDL)\n" );
1053 fprintf ( fMakefile
,
1054 "\t%s %s %s -h -H %s -c -C %s %s\n",
1055 "$(Q)$(WIDL_TARGET)",
1056 GetWidlFlags ( file
).c_str (),
1057 widlflagsMacro
.c_str (),
1058 generatedHeaderFilename
.c_str (),
1059 generatedClientFilename
.c_str (),
1060 file
.name
.c_str () );
1064 MingwModuleHandler::GenerateWidlCommands (
1066 const string
& widlflagsMacro
)
1068 if ( module
.type
== RpcServer
)
1069 GenerateWidlCommandsServer ( file
,
1072 GenerateWidlCommandsClient ( file
,
1077 MingwModuleHandler::GenerateCommands (
1081 const string
& cflagsMacro
,
1082 const string
& nasmflagsMacro
,
1083 const string
& windresflagsMacro
,
1084 const string
& widlflagsMacro
)
1086 string extension
= GetExtension ( file
.name
);
1087 if ( extension
== ".c" || extension
== ".C" )
1089 GenerateGccCommand ( file
.name
,
1094 else if ( extension
== ".cc" || extension
== ".CC" ||
1095 extension
== ".cpp" || extension
== ".CPP" ||
1096 extension
== ".cxx" || extension
== ".CXX" )
1098 GenerateGccCommand ( file
.name
,
1103 else if ( extension
== ".s" || extension
== ".S" )
1105 GenerateGccAssemblerCommand ( file
.name
,
1110 else if ( extension
== ".asm" || extension
== ".ASM" )
1112 GenerateNasmCommand ( file
.name
,
1116 else if ( extension
== ".rc" || extension
== ".RC" )
1118 GenerateWindresCommand ( file
.name
,
1119 windresflagsMacro
);
1122 else if ( extension
== ".spec" || extension
== ".SPEC" )
1124 GenerateWinebuildCommands ( file
.name
);
1125 GenerateGccCommand ( GetActualSourceFilename ( file
.name
),
1130 else if ( extension
== ".idl" || extension
== ".IDL" )
1132 GenerateWidlCommands ( file
,
1134 GenerateGccCommand ( GetActualSourceFilename ( file
.name
),
1140 throw InvalidOperationException ( __FILE__
,
1142 "Unsupported filename extension '%s' in file '%s'",
1144 file
.name
.c_str () );
1148 MingwModuleHandler::GenerateBuildMapCode ()
1150 fprintf ( fMakefile
,
1151 "ifeq ($(ROS_BUILDMAP),full)\n" );
1153 string mapFilename
= PassThruCacheDirectory (
1154 GetBasename ( module
.GetPath () ) + ".map",
1155 backend
->outputDirectory
);
1156 CLEAN_FILE ( mapFilename
);
1158 fprintf ( fMakefile
,
1159 "\t$(ECHO_OBJDUMP)\n" );
1160 fprintf ( fMakefile
,
1161 "\t$(Q)${objdump} -d -S $@ > %s\n",
1162 mapFilename
.c_str () );
1164 fprintf ( fMakefile
,
1166 fprintf ( fMakefile
,
1167 "ifeq ($(ROS_BUILDMAP),yes)\n" );
1169 fprintf ( fMakefile
,
1171 fprintf ( fMakefile
,
1172 "\t$(Q)${nm} --numeric-sort $@ > %s\n",
1173 mapFilename
.c_str () );
1175 fprintf ( fMakefile
,
1178 fprintf ( fMakefile
,
1183 MingwModuleHandler::GenerateBuildNonSymbolStrippedCode ()
1185 fprintf ( fMakefile
,
1186 "ifeq ($(ROS_BUILDNOSTRIP),yes)\n" );
1188 string filename
= module
.GetPath ();
1189 string outputFilename
= PassThruCacheDirectory (
1191 backend
->outputDirectory
);
1192 string nostripFilename
= PassThruCacheDirectory (
1193 GetBasename ( filename
) + ".nostrip" + GetExtension ( filename
),
1194 backend
->outputDirectory
);
1195 CLEAN_FILE ( nostripFilename
);
1197 fprintf ( fMakefile
,
1199 fprintf ( fMakefile
,
1200 "\t${cp} %s %s 1>$(NUL)\n",
1201 outputFilename
.c_str (),
1202 nostripFilename
.c_str () );
1204 fprintf ( fMakefile
,
1209 MergeStringVector ( const vector
<string
>& input
,
1210 vector
<string
>& output
)
1214 int wrap_count
= -1;
1215 for ( size_t i
= 0; i
< input
.size (); i
++ )
1217 if ( input
[i
].size () == 0 )
1219 if ( wrap_count
++ == wrap_at
)
1221 output
.push_back ( s
);
1225 else if ( s
.size () > 0)
1229 if ( s
.length () > 0 )
1230 output
.push_back ( s
);
1234 MingwModuleHandler::GetObjectsVector ( const IfableData
& data
,
1235 vector
<string
>& objectFiles
) const
1237 for ( size_t i
= 0; i
< data
.files
.size (); i
++ )
1239 File
& file
= *data
.files
[i
];
1240 objectFiles
.push_back ( GetObjectFilename ( file
.name
, NULL
) );
1245 MingwModuleHandler::GenerateCleanObjectsAsYouGoCode () const
1247 if ( backend
->cleanAsYouGo
)
1249 vector
<string
> objectFiles
;
1250 GetObjectsVector ( module
.non_if_data
,
1252 vector
<string
> lines
;
1253 MergeStringVector ( objectFiles
,
1255 for ( size_t i
= 0; i
< lines
.size (); i
++ )
1257 fprintf ( fMakefile
,
1258 "\t-@${rm} %s 2>$(NUL)\n",
1259 lines
[i
].c_str () );
1265 MingwModuleHandler::GenerateRunRsymCode () const
1267 fprintf ( fMakefile
,
1268 "\t$(ECHO_RSYM)\n" );
1269 fprintf ( fMakefile
,
1270 "\t$(Q)$(RSYM_TARGET) $@ $@\n\n" );
1274 MingwModuleHandler::GenerateLinkerCommand (
1275 const string
& dependencies
,
1276 const string
& linker
,
1277 const string
& linkerParameters
,
1278 const string
& objectsMacro
,
1279 const string
& libsMacro
)
1281 string
target ( GetTargetMacro ( module
) );
1282 string
target_folder ( GetDirectory ( GetTargetFilename ( module
, NULL
) ) );
1283 string def_file
= GetDefinitionFilename ();
1285 fprintf ( fMakefile
,
1286 "%s: %s %s $(RSYM_TARGET) | %s\n",
1289 dependencies
.c_str (),
1290 target_folder
.c_str () );
1291 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
1292 string
targetName ( module
.GetTargetName () );
1294 if ( module
.IsDLL () )
1296 string base_tmp
= ros_temp
+ module
.name
+ ".base.tmp";
1297 CLEAN_FILE ( base_tmp
);
1298 string junk_tmp
= ros_temp
+ module
.name
+ ".junk.tmp";
1299 CLEAN_FILE ( junk_tmp
);
1300 string temp_exp
= ros_temp
+ module
.name
+ ".temp.exp";
1301 CLEAN_FILE ( temp_exp
);
1303 fprintf ( fMakefile
,
1304 "\t%s %s -Wl,--base-file,%s -o %s %s %s %s\n",
1306 linkerParameters
.c_str (),
1309 objectsMacro
.c_str (),
1311 GetLinkerMacro ().c_str () );
1313 fprintf ( fMakefile
,
1314 "\t-@${rm} %s 2>$(NUL)\n",
1315 junk_tmp
.c_str () );
1317 string killAt
= module
.mangledSymbols
? "" : "--kill-at";
1318 fprintf ( fMakefile
,
1319 "\t${dlltool} --dllname %s --base-file %s --def %s --output-exp %s %s\n",
1320 targetName
.c_str (),
1326 fprintf ( fMakefile
,
1327 "\t-@${rm} %s 2>$(NUL)\n",
1328 base_tmp
.c_str () );
1330 fprintf ( fMakefile
,
1331 "\t%s %s %s -o %s %s %s %s\n",
1333 linkerParameters
.c_str (),
1336 objectsMacro
.c_str (),
1338 GetLinkerMacro ().c_str () );
1340 fprintf ( fMakefile
,
1341 "\t-@${rm} %s 2>$(NUL)\n",
1342 temp_exp
.c_str () );
1346 fprintf ( fMakefile
,
1347 "\t%s %s -o %s %s %s %s\n",
1349 linkerParameters
.c_str (),
1351 objectsMacro
.c_str (),
1353 GetLinkerMacro ().c_str () );
1356 GenerateBuildMapCode ();
1357 GenerateBuildNonSymbolStrippedCode ();
1358 GenerateRunRsymCode ();
1359 GenerateCleanObjectsAsYouGoCode ();
1363 MingwModuleHandler::GeneratePhonyTarget() const
1365 string
targetMacro ( GetTargetMacro(module
) );
1366 fprintf ( fMakefile
, ".PHONY: %s\n\n",
1367 targetMacro
.c_str ());
1368 fprintf ( fMakefile
, "%s: | %s\n",
1369 targetMacro
.c_str (),
1370 GetDirectory(GetTargetFilename(module
,NULL
)).c_str () );
1374 MingwModuleHandler::GenerateObjectFileTargets (
1375 const IfableData
& data
,
1378 const string
& cflagsMacro
,
1379 const string
& nasmflagsMacro
,
1380 const string
& windresflagsMacro
,
1381 const string
& widlflagsMacro
)
1385 const vector
<File
*>& files
= data
.files
;
1386 for ( i
= 0; i
< files
.size (); i
++ )
1388 GenerateCommands ( *files
[i
],
1395 fprintf ( fMakefile
,
1399 const vector
<If
*>& ifs
= data
.ifs
;
1400 for ( i
= 0; i
< ifs
.size(); i
++ )
1402 GenerateObjectFileTargets ( ifs
[i
]->data
,
1413 MingwModuleHandler::GenerateObjectFileTargets (
1416 const string
& cflagsMacro
,
1417 const string
& nasmflagsMacro
,
1418 const string
& windresflagsMacro
,
1419 const string
& widlflagsMacro
)
1423 const string
& pch_file
= module
.pch
->header
;
1424 string gch_file
= pch_file
+ ".gch";
1425 CLEAN_FILE(gch_file
);
1433 fprintf ( fMakefile
, "\t$(ECHO_PCH)\n" );
1436 "\t%s -o %s %s -g %s\n\n",
1437 ( module
.cplusplus
? cppc
.c_str() : cc
.c_str() ),
1439 cflagsMacro
.c_str(),
1444 GenerateObjectFileTargets ( module
.non_if_data
,
1451 fprintf ( fMakefile
, "\n" );
1455 MingwModuleHandler::GenerateArchiveTarget ( const string
& ar
,
1456 const string
& objs_macro
) const
1458 string
archiveFilename ( GetModuleArchiveFilename () );
1460 fprintf ( fMakefile
,
1462 archiveFilename
.c_str (),
1463 objs_macro
.c_str (),
1464 GetDirectory(archiveFilename
).c_str() );
1466 fprintf ( fMakefile
, "\t$(ECHO_AR)\n" );
1468 fprintf ( fMakefile
,
1471 objs_macro
.c_str ());
1473 GenerateCleanObjectsAsYouGoCode ();
1475 fprintf ( fMakefile
, "\n" );
1477 return archiveFilename
;
1481 MingwModuleHandler::GetCFlagsMacro () const
1483 return ssprintf ( "$(%s_CFLAGS)",
1484 module
.name
.c_str () );
1488 MingwModuleHandler::GetObjectsMacro ( const Module
& module
)
1490 return ssprintf ( "$(%s_OBJS)",
1491 module
.name
.c_str () );
1495 MingwModuleHandler::GetLinkingDependenciesMacro () const
1497 return ssprintf ( "$(%s_LINKDEPS)", module
.name
.c_str () );
1501 MingwModuleHandler::GetLibsMacro () const
1503 return ssprintf ( "$(%s_LIBS)", module
.name
.c_str () );
1507 MingwModuleHandler::GetLinkerMacro () const
1509 return ssprintf ( "$(%s_LFLAGS)",
1510 module
.name
.c_str () );
1514 MingwModuleHandler::GetModuleTargets ( const Module
& module
)
1516 if ( ReferenceObjects ( module
) )
1517 return GetObjectsMacro ( module
);
1519 return GetTargetFilename ( module
, NULL
);
1523 MingwModuleHandler::GenerateObjectMacro ()
1525 objectsMacro
= ssprintf ("%s_OBJS", module
.name
.c_str ());
1527 GenerateObjectMacros (
1530 &module
.linkerFlags
);
1532 // future references to the macro will be to get its values
1533 objectsMacro
= ssprintf ("$(%s)", objectsMacro
.c_str ());
1537 MingwModuleHandler::GenerateTargetMacro ()
1539 fprintf ( fMakefile
,
1541 GetTargetMacro ( module
, false ).c_str (),
1542 GetModuleTargets ( module
).c_str () );
1546 MingwModuleHandler::GenerateOtherMacros ()
1548 cflagsMacro
= ssprintf ("%s_CFLAGS", module
.name
.c_str ());
1549 nasmflagsMacro
= ssprintf ("%s_NASMFLAGS", module
.name
.c_str ());
1550 windresflagsMacro
= ssprintf ("%s_RCFLAGS", module
.name
.c_str ());
1551 widlflagsMacro
= ssprintf ("%s_WIDLFLAGS", module
.name
.c_str ());
1552 linkerflagsMacro
= ssprintf ("%s_LFLAGS", module
.name
.c_str ());
1553 libsMacro
= ssprintf("%s_LIBS", module
.name
.c_str ());
1554 linkDepsMacro
= ssprintf ("%s_LINKDEPS", module
.name
.c_str ());
1559 &module
.linkerFlags
);
1561 if ( module
.importLibrary
)
1564 const vector
<File
*>& files
= module
.non_if_data
.files
;
1565 for ( size_t i
= 0; i
< files
.size (); i
++ )
1567 File
& file
= *files
[i
];
1568 string extension
= GetExtension ( file
.name
);
1569 if ( extension
== ".spec" || extension
== ".SPEC" )
1570 GetSpecObjectDependencies ( s
, file
.name
);
1572 if ( s
.size () > 0 )
1577 linkDepsMacro
.c_str() );
1578 for ( size_t i
= 0; i
< s
.size(); i
++ )
1579 fprintf ( fMakefile
,
1582 fprintf ( fMakefile
, "\n" );
1586 string globalCflags
= "-g";
1587 if ( backend
->usePipe
)
1588 globalCflags
+= " -pipe";
1589 if ( !module
.enableWarnings
)
1590 globalCflags
+= " -Werror";
1594 "%s += $(PROJECT_CFLAGS) %s\n",
1595 cflagsMacro
.c_str (),
1596 globalCflags
.c_str () );
1600 "%s += $(PROJECT_RCFLAGS)\n",
1601 windresflagsMacro
.c_str () );
1605 "%s += $(PROJECT_WIDLFLAGS)\n",
1606 widlflagsMacro
.c_str () );
1610 "%s_LFLAGS += $(PROJECT_LFLAGS) -g\n",
1611 module
.name
.c_str () );
1616 linkDepsMacro
.c_str (),
1617 libsMacro
.c_str () );
1619 string cflags
= TypeSpecificCFlags();
1620 if ( cflags
.size() > 0 )
1622 fprintf ( fMakefile
,
1624 cflagsMacro
.c_str (),
1628 string nasmflags
= TypeSpecificNasmFlags();
1629 if ( nasmflags
.size () > 0 )
1631 fprintf ( fMakefile
,
1633 nasmflagsMacro
.c_str (),
1634 nasmflags
.c_str () );
1637 string linkerflags
= TypeSpecificLinkerFlags();
1638 if ( linkerflags
.size() > 0 )
1640 fprintf ( fMakefile
,
1642 linkerflagsMacro
.c_str (),
1643 linkerflags
.c_str () );
1646 fprintf ( fMakefile
, "\n\n" );
1648 // future references to the macros will be to get their values
1649 cflagsMacro
= ssprintf ("$(%s)", cflagsMacro
.c_str ());
1650 nasmflagsMacro
= ssprintf ("$(%s)", nasmflagsMacro
.c_str ());
1651 widlflagsMacro
= ssprintf ("$(%s)", widlflagsMacro
.c_str ());
1655 MingwModuleHandler::GenerateRules ()
1657 string cc
= ( module
.host
== HostTrue
? "${host_gcc}" : "${gcc}" );
1658 string cppc
= ( module
.host
== HostTrue
? "${host_gpp}" : "${gpp}" );
1659 string ar
= ( module
.host
== HostTrue
? "${host_ar}" : "${ar}" );
1661 string targetMacro
= GetTargetMacro ( module
);
1663 CLEAN_FILE ( targetMacro
);
1665 // generate phony target for module name
1666 fprintf ( fMakefile
, ".PHONY: %s\n",
1667 module
.name
.c_str () );
1668 fprintf ( fMakefile
, "%s: %s\n\n",
1669 module
.name
.c_str (),
1670 GetTargetMacro ( module
).c_str () );
1672 if ( !ReferenceObjects ( module
) )
1674 string
ar_target ( GenerateArchiveTarget ( ar
, objectsMacro
) );
1675 if ( targetMacro
!= ar_target
)
1677 CLEAN_FILE ( ar_target
);
1681 GenerateObjectFileTargets ( cc
,
1690 MingwModuleHandler::GetInvocationDependencies (
1691 const Module
& module
,
1692 string_list
& dependencies
)
1694 for ( size_t i
= 0; i
< module
.invocations
.size (); i
++ )
1696 Invoke
& invoke
= *module
.invocations
[i
];
1697 if ( invoke
.invokeModule
== &module
)
1698 /* Protect against circular dependencies */
1700 invoke
.GetTargets ( dependencies
);
1705 MingwModuleHandler::GenerateInvocations () const
1707 if ( module
.invocations
.size () == 0 )
1710 size_t iend
= module
.invocations
.size ();
1711 for ( size_t i
= 0; i
< iend
; i
++ )
1713 const Invoke
& invoke
= *module
.invocations
[i
];
1715 if ( invoke
.invokeModule
->type
!= BuildTool
)
1717 throw InvalidBuildFileException ( module
.node
.location
,
1718 "Only modules of type buildtool can be invoked." );
1721 string invokeTarget
= module
.GetInvocationTarget ( i
);
1722 string_list invoke_targets
;
1723 assert ( invoke_targets
.size() );
1724 invoke
.GetTargets ( invoke_targets
);
1725 fprintf ( fMakefile
,
1727 invokeTarget
.c_str () );
1728 fprintf ( fMakefile
,
1730 invokeTarget
.c_str () );
1731 size_t j
, jend
= invoke_targets
.size();
1732 for ( j
= 0; j
< jend
; j
++ )
1734 fprintf ( fMakefile
,
1736 invoke_targets
[i
].c_str () );
1738 fprintf ( fMakefile
, "\n\n%s", invoke_targets
[0].c_str () );
1739 for ( j
= 1; j
< jend
; j
++ )
1740 fprintf ( fMakefile
,
1742 invoke_targets
[i
].c_str () );
1743 fprintf ( fMakefile
,
1745 NormalizeFilename ( invoke
.invokeModule
->GetPath () ).c_str () );
1746 fprintf ( fMakefile
, "\t$(ECHO_INVOKE)\n" );
1747 fprintf ( fMakefile
,
1749 NormalizeFilename ( invoke
.invokeModule
->GetPath () ).c_str (),
1750 invoke
.GetParameters ().c_str () );
1755 MingwModuleHandler::GetPreconditionDependenciesName () const
1757 return module
.name
+ "_precondition";
1761 MingwModuleHandler::GetDefaultDependencies (
1762 string_list
& dependencies
) const
1764 /* Avoid circular dependency */
1765 if ( module
.type
!= BuildTool
1766 && module
.name
!= "zlib"
1767 && module
.name
!= "hostzlib" )
1769 dependencies
.push_back ( "$(INIT)" );
1773 MingwModuleHandler::GeneratePreconditionDependencies ()
1775 string preconditionDependenciesName
= GetPreconditionDependenciesName ();
1776 string_list sourceFilenames
;
1777 GetSourceFilenamesWithoutGeneratedFiles ( sourceFilenames
);
1778 string_list dependencies
;
1779 GetDefaultDependencies ( dependencies
);
1780 GetModuleDependencies ( dependencies
);
1782 GetInvocationDependencies ( module
, dependencies
);
1784 if ( dependencies
.size() )
1786 fprintf ( fMakefile
,
1788 preconditionDependenciesName
.c_str () );
1789 for ( size_t i
= 0; i
< dependencies
.size(); i
++ )
1790 fprintf ( fMakefile
,
1792 dependencies
[i
].c_str () );
1793 fprintf ( fMakefile
, "\n\n" );
1796 for ( size_t i
= 0; i
< sourceFilenames
.size(); i
++ )
1798 fprintf ( fMakefile
,
1800 sourceFilenames
[i
].c_str(),
1801 preconditionDependenciesName
.c_str ());
1803 fprintf ( fMakefile
, "\n" );
1807 MingwModuleHandler::IsWineModule () const
1809 if ( module
.importLibrary
== NULL
)
1812 size_t index
= module
.importLibrary
->definition
.rfind ( ".spec.def" );
1813 return ( index
!= string::npos
);
1817 MingwModuleHandler::GetDefinitionFilename () const
1819 if ( module
.importLibrary
!= NULL
)
1821 string defFilename
= module
.GetBasePath () + SSEP
+ module
.importLibrary
->definition
;
1822 if ( IsWineModule () )
1823 return PassThruCacheDirectory ( NormalizeFilename ( defFilename
),
1824 backend
->intermediateDirectory
);
1829 return "tools" SSEP
"rbuild" SSEP
"empty.def";
1833 MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ()
1835 if ( module
.importLibrary
!= NULL
)
1837 string
library_target (
1838 GetImportLibraryFilename ( module
, &clean_files
) );
1839 string defFilename
= GetDefinitionFilename ();
1842 GetDefinitionDependencies ( deps
);
1844 fprintf ( fMakefile
, "# IMPORT LIBRARY RULE:\n" );
1846 fprintf ( fMakefile
, "%s: %s",
1847 library_target
.c_str (),
1848 defFilename
.c_str () );
1850 size_t i
, iend
= deps
.size();
1851 for ( i
= 0; i
< iend
; i
++ )
1852 fprintf ( fMakefile
, " %s",
1855 fprintf ( fMakefile
, " | %s\n",
1856 GetDirectory ( GetImportLibraryFilename ( module
, NULL
) ).c_str () );
1858 fprintf ( fMakefile
, "\t$(ECHO_DLLTOOL)\n" );
1860 string killAt
= module
.mangledSymbols
? "" : "--kill-at";
1861 fprintf ( fMakefile
,
1862 "\t${dlltool} --dllname %s --def %s --output-lib %s %s\n\n",
1863 module
.GetTargetName ().c_str (),
1864 defFilename
.c_str (),
1865 library_target
.c_str (),
1871 MingwModuleHandler::GetSpecObjectDependencies (
1872 string_list
& dependencies
,
1873 const string
& filename
) const
1875 string basename
= GetBasename ( filename
);
1876 string defDependency
= PassThruCacheDirectory (
1877 NormalizeFilename ( basename
+ ".spec.def" ),
1878 backend
->intermediateDirectory
);
1879 dependencies
.push_back ( defDependency
);
1880 string stubsDependency
= PassThruCacheDirectory (
1881 NormalizeFilename ( basename
+ ".stubs.c" ),
1882 backend
->intermediateDirectory
);
1883 dependencies
.push_back ( stubsDependency
);
1887 MingwModuleHandler::GetWidlObjectDependencies (
1888 string_list
& dependencies
,
1889 const string
& filename
) const
1891 string basename
= GetBasename ( filename
);
1892 string serverDependency
= PassThruCacheDirectory (
1893 NormalizeFilename ( basename
+ "_s.c" ),
1894 backend
->intermediateDirectory
);
1895 dependencies
.push_back ( serverDependency
);
1899 MingwModuleHandler::GetDefinitionDependencies (
1900 string_list
& dependencies
) const
1902 string dkNkmLibNoFixup
= "dk/nkm/lib";
1903 const vector
<File
*>& files
= module
.non_if_data
.files
;
1904 for ( size_t i
= 0; i
< files
.size (); i
++ )
1906 File
& file
= *files
[i
];
1907 string extension
= GetExtension ( file
.name
);
1908 if ( extension
== ".spec" || extension
== ".SPEC" )
1910 GetSpecObjectDependencies ( dependencies
, file
.name
);
1912 if ( extension
== ".idl" || extension
== ".IDL" )
1914 GetWidlObjectDependencies ( dependencies
, file
.name
);
1920 MingwBuildToolModuleHandler::MingwBuildToolModuleHandler ( const Module
& module_
)
1921 : MingwModuleHandler ( module_
)
1926 MingwBuildToolModuleHandler::Process ()
1928 GenerateBuildToolModuleTarget ();
1932 MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ()
1934 string
targetMacro ( GetTargetMacro (module
) );
1935 string objectsMacro
= GetObjectsMacro ( module
);
1936 string linkDepsMacro
= GetLinkingDependenciesMacro ();
1937 string libsMacro
= GetLibsMacro ();
1942 if ( module
.cplusplus
)
1943 linker
= "${host_gpp}";
1945 linker
= "${host_gcc}";
1947 fprintf ( fMakefile
, "%s: %s %s | %s\n",
1948 targetMacro
.c_str (),
1949 objectsMacro
.c_str (),
1950 linkDepsMacro
.c_str (),
1951 GetDirectory(GetTargetFilename(module
,NULL
)).c_str () );
1952 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
1953 fprintf ( fMakefile
,
1954 "\t%s %s -o $@ %s %s\n\n",
1956 GetLinkerMacro ().c_str (),
1957 objectsMacro
.c_str (),
1958 libsMacro
.c_str () );
1962 MingwKernelModuleHandler::MingwKernelModuleHandler (
1963 const Module
& module_
)
1965 : MingwModuleHandler ( module_
)
1970 MingwKernelModuleHandler::Process ()
1972 GenerateKernelModuleTarget ();
1976 MingwKernelModuleHandler::GenerateKernelModuleTarget ()
1978 string
targetMacro ( GetTargetMacro ( module
) );
1979 string workingDirectory
= GetWorkingDirectory ( );
1980 string objectsMacro
= GetObjectsMacro ( module
);
1981 string linkDepsMacro
= GetLinkingDependenciesMacro ();
1982 string libsMacro
= GetLibsMacro ();
1984 GenerateImportLibraryTargetIfNeeded ();
1986 if ( module
.non_if_data
.files
.size () > 0 )
1990 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
1992 string linkerParameters
= ssprintf ( "-Wl,-T,%s" SSEP
"ntoskrnl.lnk -Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll --dll",
1993 module
.GetBasePath ().c_str (),
1994 module
.entrypoint
.c_str (),
1995 module
.baseaddress
.c_str () );
1996 GenerateLinkerCommand ( dependencies
,
2004 GeneratePhonyTarget();
2009 MingwStaticLibraryModuleHandler::MingwStaticLibraryModuleHandler (
2010 const Module
& module_
)
2012 : MingwModuleHandler ( module_
)
2017 MingwStaticLibraryModuleHandler::Process ()
2019 GenerateStaticLibraryModuleTarget ();
2023 MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget ()
2029 MingwObjectLibraryModuleHandler::MingwObjectLibraryModuleHandler (
2030 const Module
& module_
)
2032 : MingwModuleHandler ( module_
)
2037 MingwObjectLibraryModuleHandler::Process ()
2039 GenerateObjectLibraryModuleTarget ();
2043 MingwObjectLibraryModuleHandler::GenerateObjectLibraryModuleTarget ()
2049 MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler (
2050 const Module
& module_
)
2052 : MingwModuleHandler ( module_
)
2057 MingwKernelModeDLLModuleHandler::Process ()
2059 GenerateKernelModeDLLModuleTarget ();
2063 MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ()
2065 string
targetMacro ( GetTargetMacro ( module
) );
2066 string workingDirectory
= GetWorkingDirectory ( );
2067 string objectsMacro
= GetObjectsMacro ( module
);
2068 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2069 string libsMacro
= GetLibsMacro ();
2071 GenerateImportLibraryTargetIfNeeded ();
2073 if ( module
.non_if_data
.files
.size () > 0 )
2077 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2079 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll --dll",
2080 module
.entrypoint
.c_str (),
2081 module
.baseaddress
.c_str () );
2082 GenerateLinkerCommand ( dependencies
,
2090 GeneratePhonyTarget();
2095 MingwKernelModeDriverModuleHandler::MingwKernelModeDriverModuleHandler (
2096 const Module
& module_
)
2098 : MingwModuleHandler ( module_
)
2103 MingwKernelModeDriverModuleHandler::Process ()
2105 GenerateKernelModeDriverModuleTarget ();
2110 MingwKernelModeDriverModuleHandler::GenerateKernelModeDriverModuleTarget ()
2112 string
targetMacro ( GetTargetMacro (module
) );
2113 string workingDirectory
= GetWorkingDirectory ();
2114 string objectsMacro
= GetObjectsMacro ( module
);
2115 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2116 string libsMacro
= GetLibsMacro ();
2118 GenerateImportLibraryTargetIfNeeded ();
2120 if ( module
.non_if_data
.files
.size () > 0 )
2124 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2126 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll --dll",
2127 module
.entrypoint
.c_str (),
2128 module
.baseaddress
.c_str () );
2129 GenerateLinkerCommand ( dependencies
,
2137 GeneratePhonyTarget();
2142 MingwNativeDLLModuleHandler::MingwNativeDLLModuleHandler (
2143 const Module
& module_
)
2145 : MingwModuleHandler ( module_
)
2150 MingwNativeDLLModuleHandler::Process ()
2152 GenerateNativeDLLModuleTarget ();
2156 MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ()
2158 string
targetMacro ( GetTargetMacro (module
) );
2159 string workingDirectory
= GetWorkingDirectory ( );
2160 string objectsMacro
= GetObjectsMacro ( module
);
2161 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2162 string libsMacro
= GetLibsMacro ();
2164 GenerateImportLibraryTargetIfNeeded ();
2166 if ( module
.non_if_data
.files
.size () > 0 )
2170 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2172 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib -mdll --dll",
2173 module
.entrypoint
.c_str (),
2174 module
.baseaddress
.c_str () );
2175 GenerateLinkerCommand ( dependencies
,
2183 GeneratePhonyTarget();
2188 MingwNativeCUIModuleHandler::MingwNativeCUIModuleHandler (
2189 const Module
& module_
)
2191 : MingwModuleHandler ( module_
)
2196 MingwNativeCUIModuleHandler::Process ()
2198 GenerateNativeCUIModuleTarget ();
2202 MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ()
2204 string
targetMacro ( GetTargetMacro (module
) );
2205 string workingDirectory
= GetWorkingDirectory ( );
2206 string objectsMacro
= GetObjectsMacro ( module
);
2207 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2208 string libsMacro
= GetLibsMacro ();
2210 GenerateImportLibraryTargetIfNeeded ();
2212 if ( module
.non_if_data
.files
.size () > 0 )
2216 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2218 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib",
2219 module
.entrypoint
.c_str (),
2220 module
.baseaddress
.c_str () );
2221 GenerateLinkerCommand ( dependencies
,
2229 GeneratePhonyTarget();
2234 MingwWin32DLLModuleHandler::MingwWin32DLLModuleHandler (
2235 const Module
& module_
)
2237 : MingwModuleHandler ( module_
)
2242 MingwWin32DLLModuleHandler::Process ()
2244 GenerateWin32DLLModuleTarget ();
2248 MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ()
2250 string
targetMacro ( GetTargetMacro (module
) );
2251 string workingDirectory
= GetWorkingDirectory ( );
2252 string objectsMacro
= GetObjectsMacro ( module
);
2253 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2254 string libsMacro
= GetLibsMacro ();
2256 GenerateImportLibraryTargetIfNeeded ();
2258 if ( module
.non_if_data
.files
.size () > 0 )
2262 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2265 if ( module
.cplusplus
)
2270 string linkerParameters
= ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -mdll --dll",
2271 module
.entrypoint
.c_str (),
2272 module
.baseaddress
.c_str () );
2273 GenerateLinkerCommand ( dependencies
,
2281 GeneratePhonyTarget();
2286 MingwWin32CUIModuleHandler::MingwWin32CUIModuleHandler (
2287 const Module
& module_
)
2289 : MingwModuleHandler ( module_
)
2294 MingwWin32CUIModuleHandler::Process ()
2296 GenerateWin32CUIModuleTarget ();
2300 MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ()
2302 string
targetMacro ( GetTargetMacro (module
) );
2303 string workingDirectory
= GetWorkingDirectory ( );
2304 string objectsMacro
= GetObjectsMacro ( module
);
2305 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2306 string libsMacro
= GetLibsMacro ();
2308 GenerateImportLibraryTargetIfNeeded ();
2310 if ( module
.non_if_data
.files
.size () > 0 )
2314 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2317 if ( module
.cplusplus
)
2322 string linkerParameters
= ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
2323 module
.entrypoint
.c_str (),
2324 module
.baseaddress
.c_str () );
2325 GenerateLinkerCommand ( dependencies
,
2333 GeneratePhonyTarget();
2338 MingwWin32GUIModuleHandler::MingwWin32GUIModuleHandler (
2339 const Module
& module_
)
2341 : MingwModuleHandler ( module_
)
2346 MingwWin32GUIModuleHandler::Process ()
2348 GenerateWin32GUIModuleTarget ();
2352 MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ()
2354 string
targetMacro ( GetTargetMacro (module
) );
2355 string workingDirectory
= GetWorkingDirectory ( );
2356 string objectsMacro
= GetObjectsMacro ( module
);
2357 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2358 string libsMacro
= GetLibsMacro ();
2360 GenerateImportLibraryTargetIfNeeded ();
2362 if ( module
.non_if_data
.files
.size () > 0 )
2366 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2369 if ( module
.cplusplus
)
2374 string linkerParameters
= ssprintf ( "-Wl,--subsystem,windows -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
2375 module
.entrypoint
.c_str (),
2376 module
.baseaddress
.c_str () );
2377 GenerateLinkerCommand ( dependencies
,
2385 GeneratePhonyTarget();
2390 MingwBootLoaderModuleHandler::MingwBootLoaderModuleHandler (
2391 const Module
& module_
)
2393 : MingwModuleHandler ( module_
)
2398 MingwBootLoaderModuleHandler::Process ()
2400 GenerateBootLoaderModuleTarget ();
2404 MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ()
2406 string
targetName ( module
.GetTargetName () );
2407 string
targetMacro ( GetTargetMacro (module
) );
2408 string workingDirectory
= GetWorkingDirectory ();
2409 string junk_tmp
= ros_temp
+ module
.name
+ ".junk.tmp";
2410 CLEAN_FILE ( junk_tmp
);
2411 string objectsMacro
= GetObjectsMacro ( module
);
2412 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2413 string libsMacro
= GetLibsMacro ();
2417 fprintf ( fMakefile
, "%s: %s %s | %s\n",
2418 targetMacro
.c_str (),
2419 objectsMacro
.c_str (),
2420 linkDepsMacro
.c_str (),
2421 GetDirectory(GetTargetFilename(module
,NULL
)).c_str () );
2423 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
2425 fprintf ( fMakefile
,
2426 "\t${ld} %s -N -Ttext=0x8000 -o %s %s %s\n",
2427 GetLinkerMacro ().c_str (),
2429 objectsMacro
.c_str (),
2430 linkDepsMacro
.c_str () );
2431 fprintf ( fMakefile
,
2432 "\t${objcopy} -O binary %s $@\n",
2433 junk_tmp
.c_str () );
2434 fprintf ( fMakefile
,
2435 "\t-@${rm} %s 2>$(NUL)\n",
2436 junk_tmp
.c_str () );
2440 MingwBootSectorModuleHandler::MingwBootSectorModuleHandler (
2441 const Module
& module_
)
2443 : MingwModuleHandler ( module_
)
2448 MingwBootSectorModuleHandler::Process ()
2450 GenerateBootSectorModuleTarget ();
2454 MingwBootSectorModuleHandler::GenerateBootSectorModuleTarget ()
2456 string objectsMacro
= GetObjectsMacro ( module
);
2460 fprintf ( fMakefile
, ".PHONY: %s\n\n",
2461 module
.name
.c_str ());
2462 fprintf ( fMakefile
,
2464 module
.name
.c_str (),
2465 objectsMacro
.c_str () );
2469 MingwIsoModuleHandler::MingwIsoModuleHandler (
2470 const Module
& module_
)
2472 : MingwModuleHandler ( module_
)
2477 MingwIsoModuleHandler::Process ()
2479 GenerateIsoModuleTarget ();
2483 MingwIsoModuleHandler::OutputBootstrapfileCopyCommands (
2484 const string
& bootcdDirectory
)
2486 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
2488 const Module
& m
= *module
.project
.modules
[i
];
2489 if ( m
.bootstrap
!= NULL
)
2491 string sourceFilename
= PassThruCacheDirectory (
2492 NormalizeFilename ( m
.GetPath () ),
2493 backend
->outputDirectory
);
2494 string
targetFilenameNoFixup ( bootcdDirectory
+ SSEP
+ m
.bootstrap
->base
+ SSEP
+ m
.bootstrap
->nameoncd
);
2495 string targetFilename
= MingwModuleHandler::PassThruCacheDirectory (
2496 NormalizeFilename ( targetFilenameNoFixup
),
2497 backend
->outputDirectory
);
2498 fprintf ( fMakefile
,
2500 fprintf ( fMakefile
,
2501 "\t${cp} %s %s 1>$(NUL)\n",
2502 sourceFilename
.c_str (),
2503 targetFilename
.c_str () );
2509 MingwIsoModuleHandler::OutputCdfileCopyCommands (
2510 const string
& bootcdDirectory
)
2512 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
2514 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
2515 string targetFilenameNoFixup
= bootcdDirectory
+ SSEP
+ cdfile
.base
+ SSEP
+ cdfile
.nameoncd
;
2516 string targetFilename
= MingwModuleHandler::PassThruCacheDirectory (
2517 NormalizeFilename ( targetFilenameNoFixup
),
2518 backend
->outputDirectory
);
2519 fprintf ( fMakefile
,
2521 fprintf ( fMakefile
,
2522 "\t${cp} %s %s 1>$(NUL)\n",
2523 cdfile
.GetPath ().c_str (),
2524 targetFilename
.c_str () );
2529 MingwIsoModuleHandler::GetBootstrapCdDirectories ( const string
& bootcdDirectory
)
2532 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
2534 const Module
& m
= *module
.project
.modules
[i
];
2535 if ( m
.bootstrap
!= NULL
)
2537 string
targetDirectory ( bootcdDirectory
+ SSEP
+ m
.bootstrap
->base
);
2538 if ( directories
.size () > 0 )
2540 directories
+= PassThruCacheDirectory (
2541 NormalizeFilename ( targetDirectory
),
2542 backend
->outputDirectory
);
2549 MingwIsoModuleHandler::GetNonModuleCdDirectories ( const string
& bootcdDirectory
)
2552 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
2554 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
2555 string
targetDirectory ( bootcdDirectory
+ SSEP
+ cdfile
.base
);
2556 if ( directories
.size () > 0 )
2558 directories
+= PassThruCacheDirectory (
2559 NormalizeFilename ( targetDirectory
),
2560 backend
->outputDirectory
);
2566 MingwIsoModuleHandler::GetCdDirectories ( const string
& bootcdDirectory
)
2568 string directories
= GetBootstrapCdDirectories ( bootcdDirectory
);
2569 directories
+= " " + GetNonModuleCdDirectories ( bootcdDirectory
);
2574 MingwIsoModuleHandler::GetBootstrapCdFiles (
2575 vector
<string
>& out
) const
2577 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
2579 const Module
& m
= *module
.project
.modules
[i
];
2580 if ( m
.bootstrap
!= NULL
)
2582 string filename
= PassThruCacheDirectory (
2583 NormalizeFilename ( m
.GetPath () ),
2584 backend
->outputDirectory
);
2585 out
.push_back ( filename
);
2591 MingwIsoModuleHandler::GetNonModuleCdFiles (
2592 vector
<string
>& out
) const
2594 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
2596 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
2597 out
.push_back ( cdfile
.GetPath () );
2602 MingwIsoModuleHandler::GetCdFiles (
2603 vector
<string
>& out
) const
2605 GetBootstrapCdFiles ( out
);
2606 GetNonModuleCdFiles ( out
);
2610 MingwIsoModuleHandler::GenerateIsoModuleTarget ()
2612 string bootcdDirectory
= "cd";
2613 string bootcd
= PassThruCacheDirectory (
2614 NormalizeFilename ( bootcdDirectory
+ SSEP
),
2615 backend
->outputDirectory
);
2616 string isoboot
= PassThruCacheDirectory (
2617 NormalizeFilename ( "boot" SSEP
"freeldr" SSEP
"bootsect" SSEP
"isoboot.o" ),
2618 backend
->outputDirectory
);
2619 string bootcdReactosNoFixup
= bootcdDirectory
+ SSEP
"reactos";
2620 string bootcdReactos
= PassThruCacheDirectory (
2621 NormalizeFilename ( bootcdReactosNoFixup
+ SSEP
),
2622 backend
->outputDirectory
);
2623 CLEAN_FILE ( bootcdReactos
);
2624 string reactosInf
= PassThruCacheDirectory (
2625 NormalizeFilename ( bootcdReactosNoFixup
+ SSEP
"reactos.inf" ),
2626 backend
->outputDirectory
);
2627 string reactosDff
= NormalizeFilename ( "bootdata" SSEP
"packages" SSEP
"reactos.dff" );
2628 string cdDirectories
= GetCdDirectories ( bootcdDirectory
);
2629 vector
<string
> vCdFiles
;
2630 GetCdFiles ( vCdFiles
);
2631 string cdFiles
= v2s ( vCdFiles
, 5 );
2633 fprintf ( fMakefile
, ".PHONY: %s\n\n",
2634 module
.name
.c_str ());
2635 fprintf ( fMakefile
,
2636 "%s: all %s %s %s %s $(CABMAN_TARGET) $(CDMAKE_TARGET)\n",
2637 module
.name
.c_str (),
2639 bootcdReactos
.c_str (),
2640 cdDirectories
.c_str (),
2642 fprintf ( fMakefile
, "\t$(ECHO_CABMAN)\n" );
2643 fprintf ( fMakefile
,
2644 "\t$(Q)$(CABMAN_TARGET) -C %s -L %s -I -P $(OUTPUT)\n",
2645 reactosDff
.c_str (),
2646 bootcdReactos
.c_str () );
2647 fprintf ( fMakefile
,
2648 "\t$(Q)$(CABMAN_TARGET) -C %s -RC %s -L %s -N -P $(OUTPUT)\n",
2649 reactosDff
.c_str (),
2650 reactosInf
.c_str (),
2651 bootcdReactos
.c_str ());
2652 fprintf ( fMakefile
,
2653 "\t-@${rm} %s 2>$(NUL)\n",
2654 reactosInf
.c_str () );
2655 OutputBootstrapfileCopyCommands ( bootcdDirectory
);
2656 OutputCdfileCopyCommands ( bootcdDirectory
);
2657 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
2658 fprintf ( fMakefile
,
2659 "\t$(Q)$(CDMAKE_TARGET) -v -m -b %s %s REACTOS ReactOS.iso\n",
2662 fprintf ( fMakefile
,
2667 MingwLiveIsoModuleHandler::MingwLiveIsoModuleHandler (
2668 const Module
& module_
)
2670 : MingwModuleHandler ( module_
)
2675 MingwLiveIsoModuleHandler::Process ()
2677 GenerateLiveIsoModuleTarget ();
2681 MingwLiveIsoModuleHandler::CreateDirectory ( const string
& directory
)
2683 string normalizedDirectory
= MingwModuleHandler::PassThruCacheDirectory (
2684 NormalizeFilename ( directory
) + SSEP
,
2685 backend
->outputDirectory
);
2689 MingwLiveIsoModuleHandler::OutputCopyCommand ( const string
& sourceFilename
,
2690 const string
& targetFilename
,
2691 const string
& targetDirectory
)
2693 string normalizedTargetFilename
= MingwModuleHandler::PassThruCacheDirectory (
2694 NormalizeFilename ( targetDirectory
+ SSEP
+ targetFilename
),
2695 backend
->outputDirectory
);
2696 fprintf ( fMakefile
,
2698 fprintf ( fMakefile
,
2699 "\t${cp} %s %s 1>$(NUL)\n",
2700 sourceFilename
.c_str (),
2701 normalizedTargetFilename
.c_str () );
2705 MingwLiveIsoModuleHandler::OutputModuleCopyCommands ( string
& livecdDirectory
,
2706 string
& reactosDirectory
)
2708 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
2710 const Module
& m
= *module
.project
.modules
[i
];
2711 if ( m
.installName
.length () > 0 )
2713 string sourceFilename
= MingwModuleHandler::PassThruCacheDirectory (
2714 NormalizeFilename ( m
.GetPath () ),
2715 backend
->outputDirectory
);
2716 OutputCopyCommand ( sourceFilename
,
2718 livecdDirectory
+ SSEP
+ reactosDirectory
+ SSEP
+ m
.installBase
);
2724 MingwLiveIsoModuleHandler::OutputNonModuleCopyCommands ( string
& livecdDirectory
,
2725 string
& reactosDirectory
)
2727 for ( size_t i
= 0; i
< module
.project
.installfiles
.size (); i
++ )
2729 const InstallFile
& installfile
= *module
.project
.installfiles
[i
];
2730 OutputCopyCommand ( installfile
.GetPath (),
2731 installfile
.newname
,
2732 livecdDirectory
+ SSEP
+ reactosDirectory
+ SSEP
+ installfile
.base
);
2737 MingwLiveIsoModuleHandler::OutputProfilesDirectoryCommands ( string
& livecdDirectory
)
2739 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" );
2740 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" SSEP
"All Users") ;
2741 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" SSEP
"All Users" SSEP
"Desktop" );
2742 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" SSEP
"Default User" );
2743 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" SSEP
"Default User" SSEP
"Desktop" );
2744 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" SSEP
"Default User" SSEP
"My Documents" );
2746 string livecdIni
= "bootdata" SSEP
"livecd.ini";
2747 OutputCopyCommand ( livecdIni
,
2753 MingwLiveIsoModuleHandler::OutputLoaderCommands ( string
& livecdDirectory
)
2755 string freeldr
= PassThruCacheDirectory (
2756 NormalizeFilename ( "boot" SSEP
"freeldr" SSEP
"freeldr" SSEP
"freeldr.sys" ),
2757 backend
->outputDirectory
);
2758 CreateDirectory ( livecdDirectory
+ SSEP
"loader" );
2759 OutputCopyCommand ( freeldr
,
2761 livecdDirectory
+ SSEP
+ "loader" );
2765 MingwLiveIsoModuleHandler::OutputRegistryCommands ( string
& livecdDirectory
)
2767 string reactosSystem32ConfigDirectory
= NormalizeFilename (
2768 MingwModuleHandler::PassThruCacheDirectory (
2769 livecdDirectory
+ SSEP
"reactos" SSEP
"system32" SSEP
"config" SSEP
,
2770 backend
->outputDirectory
) );
2771 fprintf ( fMakefile
,
2772 "\t$(ECHO_MKHIVE)\n" );
2773 fprintf ( fMakefile
,
2774 "\t$(MKHIVE_TARGET) bootdata %s bootdata" SSEP
"livecd.inf bootdata" SSEP
"hiveinst.inf\n",
2775 reactosSystem32ConfigDirectory
.c_str () );
2779 MingwLiveIsoModuleHandler::GenerateLiveIsoModuleTarget ()
2781 string livecdDirectory
= "livecd";
2782 string livecd
= PassThruCacheDirectory (
2783 NormalizeFilename ( livecdDirectory
+ SSEP
),
2784 backend
->outputDirectory
);
2785 string isoboot
= PassThruCacheDirectory (
2786 NormalizeFilename ( "boot" SSEP
"freeldr" SSEP
"bootsect" SSEP
"isoboot.o" ),
2787 backend
->outputDirectory
);
2788 string reactosDirectory
= "reactos";
2789 string livecdReactosNoFixup
= livecdDirectory
+ SSEP
+ reactosDirectory
;
2790 string livecdReactos
= NormalizeFilename ( PassThruCacheDirectory (
2791 NormalizeFilename ( livecdReactosNoFixup
+ SSEP
),
2792 backend
->outputDirectory
) );
2793 CLEAN_FILE ( livecdReactos
);
2795 fprintf ( fMakefile
, ".PHONY: %s\n\n",
2796 module
.name
.c_str ());
2797 fprintf ( fMakefile
,
2798 "%s: all %s %s $(MKHIVE_TARGET) $(CDMAKE_TARGET)\n",
2799 module
.name
.c_str (),
2801 livecdReactos
.c_str () );
2802 OutputModuleCopyCommands ( livecdDirectory
,
2804 OutputNonModuleCopyCommands ( livecdDirectory
,
2806 OutputProfilesDirectoryCommands ( livecdDirectory
);
2807 OutputLoaderCommands ( livecdDirectory
);
2808 OutputRegistryCommands ( livecdDirectory
);
2809 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
2810 fprintf ( fMakefile
,
2811 "\t$(Q)$(CDMAKE_TARGET) -v -m -j -b %s %s REACTOS ReactOS-LiveCD.iso\n",
2814 fprintf ( fMakefile
,
2819 MingwTestModuleHandler::MingwTestModuleHandler (
2820 const Module
& module_
)
2822 : MingwModuleHandler ( module_
)
2827 MingwTestModuleHandler::Process ()
2829 GenerateTestModuleTarget ();
2833 MingwTestModuleHandler::GenerateTestModuleTarget ()
2835 string
targetMacro ( GetTargetMacro ( module
) );
2836 string workingDirectory
= GetWorkingDirectory ( );
2837 string objectsMacro
= GetObjectsMacro ( module
);
2838 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2839 string libsMacro
= GetLibsMacro ();
2841 GenerateImportLibraryTargetIfNeeded ();
2843 if ( module
.non_if_data
.files
.size () > 0 )
2847 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2850 if ( module
.cplusplus
)
2855 string linkerParameters
= ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
2856 module
.entrypoint
.c_str (),
2857 module
.baseaddress
.c_str () );
2858 GenerateLinkerCommand ( dependencies
,
2866 GeneratePhonyTarget();
2871 MingwRpcServerModuleHandler::MingwRpcServerModuleHandler (
2872 const Module
& module_
)
2874 : MingwModuleHandler ( module_
)
2879 MingwRpcServerModuleHandler::Process ()
2884 MingwRpcClientModuleHandler::MingwRpcClientModuleHandler (
2885 const Module
& module_
)
2887 : MingwModuleHandler ( module_
)
2892 MingwRpcClientModuleHandler::Process ()