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
;
116 /*static*/ Directory
*
117 MingwModuleHandler::GetTargetDirectoryTree (
118 const Module
& module
)
120 if ( module
.type
== StaticLibrary
)
121 return backend
->intermediateDirectory
;
122 return backend
->outputDirectory
;
126 MingwModuleHandler::GetTargetFilename (
127 const Module
& module
,
128 string_list
* pclean_files
)
130 string target
= PassThruCacheDirectory (
131 NormalizeFilename ( module
.GetPath () ),
132 GetTargetDirectoryTree ( module
) );
135 string_list
& clean_files
= *pclean_files
;
136 CLEAN_FILE ( target
);
142 MingwModuleHandler::GetImportLibraryFilename (
143 const Module
& module
,
144 string_list
* pclean_files
)
146 string target
= PassThruCacheDirectory (
147 NormalizeFilename ( module
.GetDependencyPath () ),
148 backend
->intermediateDirectory
);
151 string_list
& clean_files
= *pclean_files
;
152 CLEAN_FILE ( target
);
157 /*static*/ MingwModuleHandler
*
158 MingwModuleHandler::InstanciateHandler (
159 const Module
& module
,
160 MingwBackend
* backend
)
162 MingwModuleHandler
* handler
;
163 switch ( module
.type
)
166 handler
= new MingwBuildToolModuleHandler ( module
);
169 handler
= new MingwStaticLibraryModuleHandler ( module
);
172 handler
= new MingwObjectLibraryModuleHandler ( module
);
175 handler
= new MingwKernelModuleHandler ( module
);
178 handler
= new MingwNativeCUIModuleHandler ( module
);
181 handler
= new MingwWin32CUIModuleHandler ( module
);
184 handler
= new MingwWin32GUIModuleHandler ( module
);
187 handler
= new MingwKernelModeDLLModuleHandler ( module
);
190 handler
= new MingwNativeDLLModuleHandler ( module
);
193 handler
= new MingwWin32DLLModuleHandler ( module
);
195 case KernelModeDriver
:
196 handler
= new MingwKernelModeDriverModuleHandler ( module
);
199 handler
= new MingwBootLoaderModuleHandler ( module
);
202 handler
= new MingwBootSectorModuleHandler ( module
);
205 handler
= new MingwIsoModuleHandler ( module
);
208 handler
= new MingwLiveIsoModuleHandler ( module
);
211 handler
= new MingwTestModuleHandler ( module
);
214 handler
= new MingwRpcServerModuleHandler ( module
);
217 handler
= new MingwRpcClientModuleHandler ( module
);
220 throw UnknownModuleTypeException (
221 module
.node
.location
,
229 MingwModuleHandler::GetWorkingDirectory () const
235 MingwModuleHandler::GetBasename ( const string
& filename
) const
237 size_t index
= filename
.find_last_of ( '.' );
238 if ( index
!= string::npos
)
239 return filename
.substr ( 0, index
);
244 MingwModuleHandler::GetActualSourceFilename (
245 const string
& filename
) const
247 string extension
= GetExtension ( filename
);
248 if ( extension
== ".spec" || extension
== ".SPEC" )
250 string basename
= GetBasename ( filename
);
251 return PassThruCacheDirectory ( NormalizeFilename ( basename
+ ".stubs.c" ),
252 backend
->intermediateDirectory
);
254 else if ( extension
== ".idl" || extension
== ".IDL" )
256 string basename
= GetBasename ( filename
);
258 if ( module
.type
== RpcServer
)
259 newname
= basename
+ "_s.c";
261 newname
= basename
+ "_c.c";
262 return PassThruCacheDirectory ( NormalizeFilename ( newname
),
263 backend
->intermediateDirectory
);
270 MingwModuleHandler::GetModuleArchiveFilename () const
272 if ( module
.type
== StaticLibrary
)
273 return GetTargetFilename ( module
, NULL
);
274 return PassThruCacheDirectory ( ReplaceExtension (
275 NormalizeFilename ( module
.GetPath () ),
277 backend
->intermediateDirectory
);
281 MingwModuleHandler::IsGeneratedFile ( const File
& file
) const
283 string extension
= GetExtension ( file
.name
);
284 return ( extension
== ".spec" || extension
== ".SPEC" );
288 MingwModuleHandler::ReferenceObjects (
289 const Module
& module
)
291 if ( module
.type
== ObjectLibrary
)
293 if ( module
.type
== RpcServer
)
295 if ( module
.type
== RpcClient
)
301 MingwModuleHandler::GetImportLibraryDependency (
302 const Module
& importedModule
)
305 if ( ReferenceObjects ( importedModule
) )
306 dep
= GetTargetMacro ( importedModule
);
308 dep
= GetImportLibraryFilename ( importedModule
, NULL
);
313 MingwModuleHandler::GetTargets ( const Module
& dependencyModule
,
314 string_list
& targets
)
316 if ( dependencyModule
.invocations
.size () > 0 )
318 for ( size_t i
= 0; i
< dependencyModule
.invocations
.size (); i
++ )
320 Invoke
& invoke
= *dependencyModule
.invocations
[i
];
321 invoke
.GetTargets ( targets
);
325 targets
.push_back ( GetImportLibraryDependency ( dependencyModule
) );
329 MingwModuleHandler::GetModuleDependencies (
330 string_list
& dependencies
)
332 size_t iend
= module
.dependencies
.size ();
337 for ( size_t i
= 0; i
< iend
; i
++ )
339 const Dependency
& dependency
= *module
.dependencies
[i
];
340 const Module
& dependencyModule
= *dependency
.dependencyModule
;
341 GetTargets ( dependencyModule
,
344 GetDefinitionDependencies ( dependencies
);
348 MingwModuleHandler::GetSourceFilenames (
350 bool includeGeneratedFiles
) const
354 const vector
<File
*>& files
= module
.non_if_data
.files
;
355 for ( i
= 0; i
< files
.size (); i
++ )
357 if ( includeGeneratedFiles
|| !IsGeneratedFile ( *files
[i
] ) )
360 GetActualSourceFilename ( files
[i
]->name
) );
363 // intentionally make a copy so that we can append more work in
364 // the middle of processing without having to go recursive
365 vector
<If
*> v
= module
.non_if_data
.ifs
;
366 for ( i
= 0; i
< v
.size (); i
++ )
370 // check for sub-ifs to add to list
371 const vector
<If
*>& ifs
= rIf
.data
.ifs
;
372 for ( j
= 0; j
< ifs
.size (); j
++ )
373 v
.push_back ( ifs
[j
] );
374 const vector
<File
*>& files
= rIf
.data
.files
;
375 for ( j
= 0; j
< files
.size (); j
++ )
377 File
& file
= *files
[j
];
378 if ( includeGeneratedFiles
|| !IsGeneratedFile ( file
) )
381 GetActualSourceFilename ( file
.name
) );
388 MingwModuleHandler::GetSourceFilenamesWithoutGeneratedFiles (
389 string_list
& list
) const
391 GetSourceFilenames ( list
, false );
395 MingwModuleHandler::GetObjectFilename (
396 const string
& sourceFilename
,
397 string_list
* pclean_files
) const
399 Directory
* directoryTree
;
402 string extension
= GetExtension ( sourceFilename
);
403 if ( extension
== ".rc" || extension
== ".RC" )
404 newExtension
= ".coff";
405 else if ( extension
== ".spec" || extension
== ".SPEC" )
406 newExtension
= ".stubs.o";
407 else if ( extension
== ".idl" || extension
== ".IDL" )
409 if ( module
.type
== RpcServer
)
410 newExtension
= "_s.o";
412 newExtension
= "_c.o";
417 if ( module
.type
== BootSector
)
418 directoryTree
= backend
->outputDirectory
;
420 directoryTree
= backend
->intermediateDirectory
;
422 string obj_file
= PassThruCacheDirectory (
423 NormalizeFilename ( ReplaceExtension (
424 RemoveVariables ( sourceFilename
),
429 string_list
& clean_files
= *pclean_files
;
430 CLEAN_FILE ( obj_file
);
436 MingwModuleHandler::GenerateCleanTarget () const
438 if ( 0 == clean_files
.size() )
440 fprintf ( fMakefile
, ".PHONY: %s_clean\n", module
.name
.c_str() );
441 fprintf ( fMakefile
, "%s_clean:\n\t-@${rm}", module
.name
.c_str() );
442 for ( size_t i
= 0; i
< clean_files
.size(); i
++ )
445 fprintf ( fMakefile
, " 2>$(NUL)\n\t-@${rm}" );
446 fprintf ( fMakefile
, " %s", clean_files
[i
].c_str() );
448 fprintf ( fMakefile
, " 2>$(NUL)\n" );
449 fprintf ( fMakefile
, "clean: %s_clean\n\n", module
.name
.c_str() );
453 MingwModuleHandler::GenerateInstallTarget () const
455 if ( module
.installName
.length () == 0 )
457 fprintf ( fMakefile
, ".PHONY: %s_install\n", module
.name
.c_str() );
458 fprintf ( fMakefile
, "%s_install:\n", module
.name
.c_str() );
459 string sourceFilename
= MingwModuleHandler::PassThruCacheDirectory (
460 NormalizeFilename ( module
.GetPath () ),
461 backend
->outputDirectory
);
462 string normalizedTargetFilename
= MingwModuleHandler::PassThruCacheDirectory (
463 NormalizeFilename ( module
.installBase
+ SSEP
+ module
.installName
),
464 backend
->installDirectory
);
468 "\t${cp} %s %s 1>$(NUL)\n",
469 sourceFilename
.c_str (),
470 normalizedTargetFilename
.c_str () );
474 MingwModuleHandler::GetObjectFilenames ()
476 const vector
<File
*>& files
= module
.non_if_data
.files
;
477 if ( files
.size () == 0 )
480 string
objectFilenames ( "" );
481 for ( size_t i
= 0; i
< files
.size (); i
++ )
483 if ( objectFilenames
.size () > 0 )
484 objectFilenames
+= " ";
486 GetObjectFilename ( files
[i
]->name
, NULL
);
488 return objectFilenames
;
492 MingwModuleHandler::GenerateGccDefineParametersFromVector (
493 const vector
<Define
*>& defines
) const
496 for ( size_t i
= 0; i
< defines
.size (); i
++ )
498 Define
& define
= *defines
[i
];
499 if (parameters
.length () > 0)
502 parameters
+= define
.name
;
503 if (define
.value
.length () > 0)
506 parameters
+= define
.value
;
513 MingwModuleHandler::GenerateGccDefineParameters () const
515 string parameters
= GenerateGccDefineParametersFromVector ( module
.project
.non_if_data
.defines
);
516 string s
= GenerateGccDefineParametersFromVector ( module
.non_if_data
.defines
);
517 if ( s
.length () > 0 )
526 MingwModuleHandler::ConcatenatePaths (
528 const string
& path2
) const
530 if ( ( path1
.length () == 0 ) || ( path1
== "." ) || ( path1
== "./" ) )
532 if ( path1
[path1
.length ()] == CSEP
)
533 return path1
+ path2
;
535 return path1
+ CSEP
+ path2
;
539 MingwModuleHandler::GenerateGccIncludeParametersFromVector ( const vector
<Include
*>& includes
) const
542 for ( size_t i
= 0; i
< includes
.size (); i
++ )
544 Include
& include
= *includes
[i
];
545 if ( parameters
.length () > 0 )
547 parameters
+= "-I" + include
.directory
;
553 MingwModuleHandler::GenerateGccIncludeParameters () const
555 string parameters
= GenerateGccIncludeParametersFromVector ( module
.non_if_data
.includes
);
556 string s
= GenerateGccIncludeParametersFromVector ( module
.project
.non_if_data
.includes
);
557 if ( s
.length () > 0 )
567 MingwModuleHandler::GenerateCompilerParametersFromVector ( const vector
<CompilerFlag
*>& compilerFlags
) const
570 for ( size_t i
= 0; i
< compilerFlags
.size (); i
++ )
572 CompilerFlag
& compilerFlag
= *compilerFlags
[i
];
573 if ( parameters
.length () > 0 )
575 parameters
+= compilerFlag
.flag
;
581 MingwModuleHandler::GenerateLinkerParametersFromVector ( const vector
<LinkerFlag
*>& linkerFlags
) const
584 for ( size_t i
= 0; i
< linkerFlags
.size (); i
++ )
586 LinkerFlag
& linkerFlag
= *linkerFlags
[i
];
587 if ( parameters
.length () > 0 )
589 parameters
+= linkerFlag
.flag
;
595 MingwModuleHandler::GenerateImportLibraryDependenciesFromVector (
596 const vector
<Library
*>& libraries
)
598 string
dependencies ( "" );
600 for ( size_t i
= 0; i
< libraries
.size (); i
++ )
602 if ( wrap_count
++ == 5 )
603 dependencies
+= " \\\n\t\t", wrap_count
= 0;
604 else if ( dependencies
.size () > 0 )
606 dependencies
+= GetImportLibraryDependency ( *libraries
[i
]->imported_module
);
612 MingwModuleHandler::GenerateLinkerParameters () const
614 return GenerateLinkerParametersFromVector ( module
.linkerFlags
);
618 MingwModuleHandler::GenerateMacro (
619 const char* assignmentOperation
,
621 const IfableData
& data
,
622 const vector
<CompilerFlag
*>* compilerFlags
)
630 assignmentOperation
);
632 if ( compilerFlags
!= NULL
)
634 string compilerParameters
= GenerateCompilerParametersFromVector ( *compilerFlags
);
635 if ( compilerParameters
.size () > 0 )
640 compilerParameters
.c_str () );
644 for ( i
= 0; i
< data
.includes
.size(); i
++ )
649 data
.includes
[i
]->directory
.c_str() );
651 for ( i
= 0; i
< data
.defines
.size(); i
++ )
653 Define
& d
= *data
.defines
[i
];
658 if ( d
.value
.size() )
664 fprintf ( fMakefile
, "\n" );
668 MingwModuleHandler::GenerateMacros (
669 const char* assignmentOperation
,
670 const IfableData
& data
,
671 const vector
<CompilerFlag
*>* compilerFlags
,
672 const vector
<LinkerFlag
*>* linkerFlags
)
676 if ( data
.includes
.size () > 0 || data
.defines
.size () > 0 )
678 GenerateMacro ( assignmentOperation
,
682 GenerateMacro ( assignmentOperation
,
688 if ( linkerFlags
!= NULL
)
690 string linkerParameters
= GenerateLinkerParametersFromVector ( *linkerFlags
);
691 if ( linkerParameters
.size () > 0 )
696 linkerflagsMacro
.c_str (),
698 linkerParameters
.c_str() );
702 if ( data
.libraries
.size () > 0 )
704 string deps
= GenerateImportLibraryDependenciesFromVector ( data
.libraries
);
705 if ( deps
.size () > 0 )
716 const vector
<If
*>& ifs
= data
.ifs
;
717 for ( i
= 0; i
< ifs
.size(); i
++ )
720 if ( rIf
.data
.defines
.size()
721 || rIf
.data
.includes
.size()
722 || rIf
.data
.libraries
.size()
723 || rIf
.data
.files
.size()
724 || rIf
.data
.ifs
.size() )
728 "ifeq (\"$(%s)\",\"%s\")\n",
729 rIf
.property
.c_str(),
744 MingwModuleHandler::GenerateObjectMacros (
745 const char* assignmentOperation
,
746 const IfableData
& data
,
747 const vector
<CompilerFlag
*>* compilerFlags
,
748 const vector
<LinkerFlag
*>* linkerFlags
)
752 const vector
<File
*>& files
= data
.files
;
753 if ( files
.size () > 0 )
755 for ( i
= 0; i
< files
.size (); i
++ )
757 File
& file
= *files
[i
];
762 objectsMacro
.c_str(),
764 file
.name
, NULL
).c_str (),
765 objectsMacro
.c_str() );
771 objectsMacro
.c_str (),
772 assignmentOperation
);
773 for ( i
= 0; i
< files
.size(); i
++ )
775 File
& file
= *files
[i
];
781 ( i
%10 == 9 ? " \\\n\t" : " " ),
783 file
.name
, NULL
).c_str () );
786 fprintf ( fMakefile
, "\n" );
789 const vector
<If
*>& ifs
= data
.ifs
;
790 for ( i
= 0; i
< ifs
.size(); i
++ )
793 if ( rIf
.data
.defines
.size()
794 || rIf
.data
.includes
.size()
795 || rIf
.data
.libraries
.size()
796 || rIf
.data
.files
.size()
797 || rIf
.data
.ifs
.size() )
801 "ifeq (\"$(%s)\",\"%s\")\n",
802 rIf
.property
.c_str(),
804 GenerateObjectMacros (
817 MingwModuleHandler::GenerateGccCommand (
818 const string
& sourceFilename
,
820 const string
& cflagsMacro
)
822 string dependencies
= sourceFilename
;
823 if ( module
.pch
&& use_pch
)
824 dependencies
+= " " + module
.pch
->header
+ ".gch";
826 /* WIDL generated headers may be used */
827 dependencies
+= " " + GetLinkingDependenciesMacro ();
828 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
830 string objectFilename
= GetObjectFilename (
831 sourceFilename
, &clean_files
);
834 objectFilename
.c_str (),
835 dependencies
.c_str (),
836 GetDirectory ( objectFilename
).c_str () );
837 fprintf ( fMakefile
, "\t$(ECHO_CC)\n" );
839 "\t%s -c $< -o $@ %s\n",
841 cflagsMacro
.c_str () );
845 MingwModuleHandler::GenerateGccAssemblerCommand (
846 const string
& sourceFilename
,
848 const string
& cflagsMacro
)
850 string dependencies
= sourceFilename
;
851 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
852 string objectFilename
= GetObjectFilename (
853 sourceFilename
, &clean_files
);
856 objectFilename
.c_str (),
857 dependencies
.c_str (),
858 GetDirectory ( objectFilename
).c_str () );
859 fprintf ( fMakefile
, "\t$(ECHO_GAS)\n" );
861 "\t%s -x assembler-with-cpp -c $< -o $@ -D__ASM__ %s\n",
863 cflagsMacro
.c_str () );
867 MingwModuleHandler::GenerateNasmCommand (
868 const string
& sourceFilename
,
869 const string
& nasmflagsMacro
)
871 string dependencies
= sourceFilename
;
872 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
873 string objectFilename
= GetObjectFilename (
874 sourceFilename
, &clean_files
);
877 objectFilename
.c_str (),
878 dependencies
.c_str (),
879 GetDirectory ( objectFilename
).c_str () );
880 fprintf ( fMakefile
, "\t$(ECHO_NASM)\n" );
882 "\t%s -f win32 $< -o $@ %s\n",
884 nasmflagsMacro
.c_str () );
888 MingwModuleHandler::GenerateWindresCommand (
889 const string
& sourceFilename
,
890 const string
& windresflagsMacro
)
892 string dependencies
= sourceFilename
;
893 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
894 string objectFilename
=
895 GetObjectFilename ( sourceFilename
, &clean_files
);
896 string rciFilename
= ros_temp
+ module
.name
+ ".rci.tmp";
897 string resFilename
= ros_temp
+ module
.name
+ ".res.tmp";
901 "%s: %s $(WRC_TARGET) | %s\n",
902 objectFilename
.c_str (),
903 dependencies
.c_str (),
904 GetDirectory ( objectFilename
).c_str () );
905 fprintf ( fMakefile
, "\t$(ECHO_WRC)\n" );
907 "\t${gcc} -xc -E -DRC_INVOKED ${%s} %s > %s\n",
908 windresflagsMacro
.c_str (),
909 sourceFilename
.c_str (),
910 rciFilename
.c_str () );
912 "\t$(Q)$(WRC_TARGET) ${%s} %s %s\n",
913 windresflagsMacro
.c_str (),
914 rciFilename
.c_str (),
915 resFilename
.c_str () );
917 "\t-@${rm} %s 2>$(NUL)\n",
918 rciFilename
.c_str () );
920 "\t${windres} %s -o $@\n",
921 resFilename
.c_str () );
923 "\t-@${rm} %s 2>$(NUL)\n",
924 resFilename
.c_str () );
929 "%s: %s $(WRC_TARGET) | %s\n",
930 objectFilename
.c_str (),
931 dependencies
.c_str (),
932 GetDirectory ( objectFilename
).c_str () );
933 fprintf ( fMakefile
, "\t$(ECHO_WRC)\n" );
935 "\t${windres} $(%s) %s -o $@\n",
936 windresflagsMacro
.c_str (),
937 sourceFilename
.c_str () );
942 MingwModuleHandler::GenerateWinebuildCommands (
943 const string
& sourceFilename
)
945 string dependencies
= sourceFilename
;
946 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
948 string basename
= GetBasename ( sourceFilename
);
949 string def_file
= PassThruCacheDirectory (
950 basename
+ ".spec.def",
951 backend
->intermediateDirectory
);
952 CLEAN_FILE(def_file
);
954 string stub_file
= PassThruCacheDirectory (
955 basename
+ ".stubs.c",
956 backend
->intermediateDirectory
);
957 CLEAN_FILE(stub_file
)
960 "%s: %s $(WINEBUILD_TARGET)\n",
962 dependencies
.c_str () );
963 fprintf ( fMakefile
, "\t$(ECHO_WINEBLD)\n" );
965 "\t%s --def=%s -o %s\n",
966 "$(Q)$(WINEBUILD_TARGET)",
967 sourceFilename
.c_str (),
971 "%s: %s $(WINEBUILD_TARGET)\n",
973 sourceFilename
.c_str () );
974 fprintf ( fMakefile
, "\t$(ECHO_WINEBLD)\n" );
976 "\t%s --pedll=%s -o %s\n",
977 "$(Q)$(WINEBUILD_TARGET)",
978 sourceFilename
.c_str (),
979 stub_file
.c_str () );
983 MingwModuleHandler::GetWidlFlags ( const File
& file
)
985 return file
.switches
;
989 MingwModuleHandler::GenerateWidlCommandsServer (
991 const string
& widlflagsMacro
)
993 string dependencies
= file
.name
;
994 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
996 string basename
= GetBasename ( file
.name
);
998 /*string generatedHeaderFilename = PassThruCacheDirectory (
1000 backend->intermediateDirectory );
1001 CLEAN_FILE(generatedHeaderFilename);
1003 string generatedHeaderFilename
= basename
+ "_s.h";
1004 CLEAN_FILE(generatedHeaderFilename
);
1006 string generatedServerFilename
= PassThruCacheDirectory (
1008 backend
->intermediateDirectory
);
1009 CLEAN_FILE(generatedServerFilename
);
1011 fprintf ( fMakefile
,
1012 "%s %s: %s $(WIDL_TARGET) | %s\n",
1013 generatedServerFilename
.c_str (),
1014 generatedHeaderFilename
.c_str (),
1015 dependencies
.c_str (),
1016 GetDirectory ( generatedServerFilename
).c_str () );
1017 fprintf ( fMakefile
, "\t$(ECHO_WIDL)\n" );
1018 fprintf ( fMakefile
,
1019 "\t%s %s %s -h -H %s -s -S %s %s\n",
1020 "$(Q)$(WIDL_TARGET)",
1021 GetWidlFlags ( file
).c_str (),
1022 widlflagsMacro
.c_str (),
1023 generatedHeaderFilename
.c_str (),
1024 generatedServerFilename
.c_str (),
1025 file
.name
.c_str () );
1029 MingwModuleHandler::GenerateWidlCommandsClient (
1031 const string
& widlflagsMacro
)
1033 string dependencies
= file
.name
;
1034 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
1036 string basename
= GetBasename ( file
.name
);
1038 /*string generatedHeaderFilename = PassThruCacheDirectory (
1040 backend->intermediateDirectory );
1041 CLEAN_FILE(generatedHeaderFilename);
1043 string generatedHeaderFilename
= basename
+ "_c.h";
1044 CLEAN_FILE(generatedHeaderFilename
);
1046 string generatedClientFilename
= PassThruCacheDirectory (
1048 backend
->intermediateDirectory
);
1049 CLEAN_FILE(generatedClientFilename
);
1051 fprintf ( fMakefile
,
1052 "%s %s: %s $(WIDL_TARGET) | %s\n",
1053 generatedClientFilename
.c_str (),
1054 generatedHeaderFilename
.c_str (),
1055 dependencies
.c_str (),
1056 GetDirectory ( generatedClientFilename
).c_str () );
1057 fprintf ( fMakefile
, "\t$(ECHO_WIDL)\n" );
1058 fprintf ( fMakefile
,
1059 "\t%s %s %s -h -H %s -c -C %s %s\n",
1060 "$(Q)$(WIDL_TARGET)",
1061 GetWidlFlags ( file
).c_str (),
1062 widlflagsMacro
.c_str (),
1063 generatedHeaderFilename
.c_str (),
1064 generatedClientFilename
.c_str (),
1065 file
.name
.c_str () );
1069 MingwModuleHandler::GenerateWidlCommands (
1071 const string
& widlflagsMacro
)
1073 if ( module
.type
== RpcServer
)
1074 GenerateWidlCommandsServer ( file
,
1077 GenerateWidlCommandsClient ( file
,
1082 MingwModuleHandler::GenerateCommands (
1086 const string
& cflagsMacro
,
1087 const string
& nasmflagsMacro
,
1088 const string
& windresflagsMacro
,
1089 const string
& widlflagsMacro
)
1091 string extension
= GetExtension ( file
.name
);
1092 if ( extension
== ".c" || extension
== ".C" )
1094 GenerateGccCommand ( file
.name
,
1099 else if ( extension
== ".cc" || extension
== ".CC" ||
1100 extension
== ".cpp" || extension
== ".CPP" ||
1101 extension
== ".cxx" || extension
== ".CXX" )
1103 GenerateGccCommand ( file
.name
,
1108 else if ( extension
== ".s" || extension
== ".S" )
1110 GenerateGccAssemblerCommand ( file
.name
,
1115 else if ( extension
== ".asm" || extension
== ".ASM" )
1117 GenerateNasmCommand ( file
.name
,
1121 else if ( extension
== ".rc" || extension
== ".RC" )
1123 GenerateWindresCommand ( file
.name
,
1124 windresflagsMacro
);
1127 else if ( extension
== ".spec" || extension
== ".SPEC" )
1129 GenerateWinebuildCommands ( file
.name
);
1130 GenerateGccCommand ( GetActualSourceFilename ( file
.name
),
1135 else if ( extension
== ".idl" || extension
== ".IDL" )
1137 GenerateWidlCommands ( file
,
1139 GenerateGccCommand ( GetActualSourceFilename ( file
.name
),
1145 throw InvalidOperationException ( __FILE__
,
1147 "Unsupported filename extension '%s' in file '%s'",
1149 file
.name
.c_str () );
1153 MingwModuleHandler::GenerateBuildMapCode ()
1155 fprintf ( fMakefile
,
1156 "ifeq ($(ROS_BUILDMAP),full)\n" );
1158 string mapFilename
= PassThruCacheDirectory (
1159 GetBasename ( module
.GetPath () ) + ".map",
1160 backend
->outputDirectory
);
1161 CLEAN_FILE ( mapFilename
);
1163 fprintf ( fMakefile
,
1164 "\t$(ECHO_OBJDUMP)\n" );
1165 fprintf ( fMakefile
,
1166 "\t$(Q)${objdump} -d -S $@ > %s\n",
1167 mapFilename
.c_str () );
1169 fprintf ( fMakefile
,
1171 fprintf ( fMakefile
,
1172 "ifeq ($(ROS_BUILDMAP),yes)\n" );
1174 fprintf ( fMakefile
,
1176 fprintf ( fMakefile
,
1177 "\t$(Q)${nm} --numeric-sort $@ > %s\n",
1178 mapFilename
.c_str () );
1180 fprintf ( fMakefile
,
1183 fprintf ( fMakefile
,
1188 MingwModuleHandler::GenerateBuildNonSymbolStrippedCode ()
1190 fprintf ( fMakefile
,
1191 "ifeq ($(ROS_BUILDNOSTRIP),yes)\n" );
1193 string filename
= module
.GetPath ();
1194 string outputFilename
= PassThruCacheDirectory (
1196 backend
->outputDirectory
);
1197 string nostripFilename
= PassThruCacheDirectory (
1198 GetBasename ( filename
) + ".nostrip" + GetExtension ( filename
),
1199 backend
->outputDirectory
);
1200 CLEAN_FILE ( nostripFilename
);
1202 fprintf ( fMakefile
,
1204 fprintf ( fMakefile
,
1205 "\t${cp} %s %s 1>$(NUL)\n",
1206 outputFilename
.c_str (),
1207 nostripFilename
.c_str () );
1209 fprintf ( fMakefile
,
1214 MergeStringVector ( const vector
<string
>& input
,
1215 vector
<string
>& output
)
1219 int wrap_count
= -1;
1220 for ( size_t i
= 0; i
< input
.size (); i
++ )
1222 if ( input
[i
].size () == 0 )
1224 if ( wrap_count
++ == wrap_at
)
1226 output
.push_back ( s
);
1230 else if ( s
.size () > 0)
1234 if ( s
.length () > 0 )
1235 output
.push_back ( s
);
1239 MingwModuleHandler::GetObjectsVector ( const IfableData
& data
,
1240 vector
<string
>& objectFiles
) const
1242 for ( size_t i
= 0; i
< data
.files
.size (); i
++ )
1244 File
& file
= *data
.files
[i
];
1245 objectFiles
.push_back ( GetObjectFilename ( file
.name
, NULL
) );
1250 MingwModuleHandler::GenerateCleanObjectsAsYouGoCode () const
1252 if ( backend
->cleanAsYouGo
)
1254 vector
<string
> objectFiles
;
1255 GetObjectsVector ( module
.non_if_data
,
1257 vector
<string
> lines
;
1258 MergeStringVector ( objectFiles
,
1260 for ( size_t i
= 0; i
< lines
.size (); i
++ )
1262 fprintf ( fMakefile
,
1263 "\t-@${rm} %s 2>$(NUL)\n",
1264 lines
[i
].c_str () );
1270 MingwModuleHandler::GenerateLinkerCommand (
1271 const string
& dependencies
,
1272 const string
& linker
,
1273 const string
& linkerParameters
,
1274 const string
& objectsMacro
,
1275 const string
& libsMacro
)
1277 string
target ( GetTargetMacro ( module
) );
1278 string
target_folder ( GetDirectory ( GetTargetFilename ( module
, NULL
) ) );
1279 string def_file
= GetDefinitionFilename ();
1281 fprintf ( fMakefile
,
1282 "%s: %s %s $(RSYM_TARGET) | %s\n",
1285 dependencies
.c_str (),
1286 target_folder
.c_str () );
1287 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
1288 string
targetName ( module
.GetTargetName () );
1290 if ( module
.IsDLL () )
1292 string base_tmp
= ros_temp
+ module
.name
+ ".base.tmp";
1293 CLEAN_FILE ( base_tmp
);
1294 string junk_tmp
= ros_temp
+ module
.name
+ ".junk.tmp";
1295 CLEAN_FILE ( junk_tmp
);
1296 string temp_exp
= ros_temp
+ module
.name
+ ".temp.exp";
1297 CLEAN_FILE ( temp_exp
);
1299 fprintf ( fMakefile
,
1300 "\t%s %s -Wl,--base-file,%s -o %s %s %s %s\n",
1302 linkerParameters
.c_str (),
1305 objectsMacro
.c_str (),
1307 GetLinkerMacro ().c_str () );
1309 fprintf ( fMakefile
,
1310 "\t-@${rm} %s 2>$(NUL)\n",
1311 junk_tmp
.c_str () );
1313 string killAt
= module
.mangledSymbols
? "" : "--kill-at";
1314 fprintf ( fMakefile
,
1315 "\t${dlltool} --dllname %s --base-file %s --def %s --output-exp %s %s\n",
1316 targetName
.c_str (),
1322 fprintf ( fMakefile
,
1323 "\t-@${rm} %s 2>$(NUL)\n",
1324 base_tmp
.c_str () );
1326 fprintf ( fMakefile
,
1327 "\t%s %s %s -o %s %s %s %s\n",
1329 linkerParameters
.c_str (),
1332 objectsMacro
.c_str (),
1334 GetLinkerMacro ().c_str () );
1336 fprintf ( fMakefile
,
1337 "\t-@${rm} %s 2>$(NUL)\n",
1338 temp_exp
.c_str () );
1340 GenerateCleanObjectsAsYouGoCode ();
1342 GenerateBuildMapCode ();
1344 GenerateBuildNonSymbolStrippedCode ();
1346 fprintf ( fMakefile
,
1347 "\t$(ECHO_RSYM)\n" );
1348 fprintf ( fMakefile
,
1349 "\t$(Q)$(RSYM_TARGET) $@ $@\n\n" );
1353 fprintf ( fMakefile
,
1354 "\t%s %s -o %s %s %s %s\n",
1356 linkerParameters
.c_str (),
1358 objectsMacro
.c_str (),
1360 GetLinkerMacro ().c_str () );
1362 GenerateCleanObjectsAsYouGoCode ();
1367 MingwModuleHandler::GeneratePhonyTarget() const
1369 string
targetMacro ( GetTargetMacro(module
) );
1370 fprintf ( fMakefile
, ".PHONY: %s\n\n",
1371 targetMacro
.c_str ());
1372 fprintf ( fMakefile
, "%s: | %s\n",
1373 targetMacro
.c_str (),
1374 GetDirectory(GetTargetFilename(module
,NULL
)).c_str () );
1378 MingwModuleHandler::GenerateObjectFileTargets (
1379 const IfableData
& data
,
1382 const string
& cflagsMacro
,
1383 const string
& nasmflagsMacro
,
1384 const string
& windresflagsMacro
,
1385 const string
& widlflagsMacro
)
1389 const vector
<File
*>& files
= data
.files
;
1390 for ( i
= 0; i
< files
.size (); i
++ )
1392 GenerateCommands ( *files
[i
],
1399 fprintf ( fMakefile
,
1403 const vector
<If
*>& ifs
= data
.ifs
;
1404 for ( i
= 0; i
< ifs
.size(); i
++ )
1406 GenerateObjectFileTargets ( ifs
[i
]->data
,
1417 MingwModuleHandler::GenerateObjectFileTargets (
1420 const string
& cflagsMacro
,
1421 const string
& nasmflagsMacro
,
1422 const string
& windresflagsMacro
,
1423 const string
& widlflagsMacro
)
1427 const string
& pch_file
= module
.pch
->header
;
1428 string gch_file
= pch_file
+ ".gch";
1429 CLEAN_FILE(gch_file
);
1437 fprintf ( fMakefile
, "\t$(ECHO_PCH)\n" );
1440 "\t%s -o %s %s -g %s\n\n",
1441 ( module
.cplusplus
? cppc
.c_str() : cc
.c_str() ),
1443 cflagsMacro
.c_str(),
1448 GenerateObjectFileTargets ( module
.non_if_data
,
1455 fprintf ( fMakefile
, "\n" );
1459 MingwModuleHandler::GenerateArchiveTarget ( const string
& ar
,
1460 const string
& objs_macro
) const
1462 string
archiveFilename ( GetModuleArchiveFilename () );
1464 fprintf ( fMakefile
,
1466 archiveFilename
.c_str (),
1467 objs_macro
.c_str (),
1468 GetDirectory(archiveFilename
).c_str() );
1470 fprintf ( fMakefile
, "\t$(ECHO_AR)\n" );
1472 fprintf ( fMakefile
,
1475 objs_macro
.c_str ());
1477 GenerateCleanObjectsAsYouGoCode ();
1479 fprintf ( fMakefile
, "\n" );
1481 return archiveFilename
;
1485 MingwModuleHandler::GetCFlagsMacro () const
1487 return ssprintf ( "$(%s_CFLAGS)",
1488 module
.name
.c_str () );
1492 MingwModuleHandler::GetObjectsMacro ( const Module
& module
)
1494 return ssprintf ( "$(%s_OBJS)",
1495 module
.name
.c_str () );
1499 MingwModuleHandler::GetLinkingDependenciesMacro () const
1501 return ssprintf ( "$(%s_LINKDEPS)", module
.name
.c_str () );
1505 MingwModuleHandler::GetLibsMacro () const
1507 return ssprintf ( "$(%s_LIBS)", module
.name
.c_str () );
1511 MingwModuleHandler::GetLinkerMacro () const
1513 return ssprintf ( "$(%s_LFLAGS)",
1514 module
.name
.c_str () );
1518 MingwModuleHandler::GetModuleTargets ( const Module
& module
)
1520 if ( ReferenceObjects ( module
) )
1521 return GetObjectsMacro ( module
);
1523 return GetTargetFilename ( module
, NULL
);
1527 MingwModuleHandler::GenerateObjectMacro ()
1529 objectsMacro
= ssprintf ("%s_OBJS", module
.name
.c_str ());
1531 GenerateObjectMacros (
1534 &module
.compilerFlags
,
1535 &module
.linkerFlags
);
1537 // future references to the macro will be to get its values
1538 objectsMacro
= ssprintf ("$(%s)", objectsMacro
.c_str ());
1542 MingwModuleHandler::GenerateTargetMacro ()
1544 fprintf ( fMakefile
,
1546 GetTargetMacro ( module
, false ).c_str (),
1547 GetModuleTargets ( module
).c_str () );
1551 MingwModuleHandler::GenerateOtherMacros ()
1553 cflagsMacro
= ssprintf ("%s_CFLAGS", module
.name
.c_str ());
1554 nasmflagsMacro
= ssprintf ("%s_NASMFLAGS", module
.name
.c_str ());
1555 windresflagsMacro
= ssprintf ("%s_RCFLAGS", module
.name
.c_str ());
1556 widlflagsMacro
= ssprintf ("%s_WIDLFLAGS", module
.name
.c_str ());
1557 linkerflagsMacro
= ssprintf ("%s_LFLAGS", module
.name
.c_str ());
1558 libsMacro
= ssprintf("%s_LIBS", module
.name
.c_str ());
1559 linkDepsMacro
= ssprintf ("%s_LINKDEPS", module
.name
.c_str ());
1564 &module
.compilerFlags
,
1565 &module
.linkerFlags
);
1567 if ( module
.importLibrary
)
1570 const vector
<File
*>& files
= module
.non_if_data
.files
;
1571 for ( size_t i
= 0; i
< files
.size (); i
++ )
1573 File
& file
= *files
[i
];
1574 string extension
= GetExtension ( file
.name
);
1575 if ( extension
== ".spec" || extension
== ".SPEC" )
1576 GetSpecObjectDependencies ( s
, file
.name
);
1578 if ( s
.size () > 0 )
1583 linkDepsMacro
.c_str() );
1584 for ( size_t i
= 0; i
< s
.size(); i
++ )
1585 fprintf ( fMakefile
,
1588 fprintf ( fMakefile
, "\n" );
1592 string globalCflags
= "-g";
1593 if ( backend
->usePipe
)
1594 globalCflags
+= " -pipe";
1595 if ( !module
.enableWarnings
)
1596 globalCflags
+= " -Werror";
1600 "%s += $(PROJECT_CFLAGS) %s\n",
1601 cflagsMacro
.c_str (),
1602 globalCflags
.c_str () );
1606 "%s += $(PROJECT_RCFLAGS)\n",
1607 windresflagsMacro
.c_str () );
1611 "%s += $(PROJECT_WIDLFLAGS)\n",
1612 widlflagsMacro
.c_str () );
1616 "%s_LFLAGS += $(PROJECT_LFLAGS) -g\n",
1617 module
.name
.c_str () );
1622 linkDepsMacro
.c_str (),
1623 libsMacro
.c_str () );
1625 string cflags
= TypeSpecificCFlags();
1626 if ( cflags
.size() > 0 )
1628 fprintf ( fMakefile
,
1630 cflagsMacro
.c_str (),
1634 string nasmflags
= TypeSpecificNasmFlags();
1635 if ( nasmflags
.size () > 0 )
1637 fprintf ( fMakefile
,
1639 nasmflagsMacro
.c_str (),
1640 nasmflags
.c_str () );
1643 string linkerflags
= TypeSpecificLinkerFlags();
1644 if ( linkerflags
.size() > 0 )
1646 fprintf ( fMakefile
,
1648 linkerflagsMacro
.c_str (),
1649 linkerflags
.c_str () );
1652 fprintf ( fMakefile
, "\n\n" );
1654 // future references to the macros will be to get their values
1655 cflagsMacro
= ssprintf ("$(%s)", cflagsMacro
.c_str ());
1656 nasmflagsMacro
= ssprintf ("$(%s)", nasmflagsMacro
.c_str ());
1657 widlflagsMacro
= ssprintf ("$(%s)", widlflagsMacro
.c_str ());
1661 MingwModuleHandler::GenerateRules ()
1663 string cc
= ( module
.host
== HostTrue
? "${host_gcc}" : "${gcc}" );
1664 string cppc
= ( module
.host
== HostTrue
? "${host_gpp}" : "${gpp}" );
1665 string ar
= ( module
.host
== HostTrue
? "${host_ar}" : "${ar}" );
1667 string targetMacro
= GetTargetMacro ( module
);
1669 CLEAN_FILE ( targetMacro
);
1671 // generate phony target for module name
1672 fprintf ( fMakefile
, ".PHONY: %s\n",
1673 module
.name
.c_str () );
1674 fprintf ( fMakefile
, "%s: %s\n\n",
1675 module
.name
.c_str (),
1676 GetTargetMacro ( module
).c_str () );
1678 if ( !ReferenceObjects ( module
) )
1680 string
ar_target ( GenerateArchiveTarget ( ar
, objectsMacro
) );
1681 if ( targetMacro
!= ar_target
)
1683 CLEAN_FILE ( ar_target
);
1687 GenerateObjectFileTargets ( cc
,
1696 MingwModuleHandler::GetInvocationDependencies (
1697 const Module
& module
,
1698 string_list
& dependencies
)
1700 for ( size_t i
= 0; i
< module
.invocations
.size (); i
++ )
1702 Invoke
& invoke
= *module
.invocations
[i
];
1703 if ( invoke
.invokeModule
== &module
)
1704 /* Protect against circular dependencies */
1706 invoke
.GetTargets ( dependencies
);
1711 MingwModuleHandler::GenerateInvocations () const
1713 if ( module
.invocations
.size () == 0 )
1716 size_t iend
= module
.invocations
.size ();
1717 for ( size_t i
= 0; i
< iend
; i
++ )
1719 const Invoke
& invoke
= *module
.invocations
[i
];
1721 if ( invoke
.invokeModule
->type
!= BuildTool
)
1723 throw InvalidBuildFileException ( module
.node
.location
,
1724 "Only modules of type buildtool can be invoked." );
1727 string invokeTarget
= module
.GetInvocationTarget ( i
);
1728 string_list invoke_targets
;
1729 assert ( invoke_targets
.size() );
1730 invoke
.GetTargets ( invoke_targets
);
1731 fprintf ( fMakefile
,
1733 invokeTarget
.c_str () );
1734 fprintf ( fMakefile
,
1736 invokeTarget
.c_str () );
1737 size_t j
, jend
= invoke_targets
.size();
1738 for ( j
= 0; j
< jend
; j
++ )
1740 fprintf ( fMakefile
,
1742 invoke_targets
[i
].c_str () );
1744 fprintf ( fMakefile
, "\n\n%s", invoke_targets
[0].c_str () );
1745 for ( j
= 1; j
< jend
; j
++ )
1746 fprintf ( fMakefile
,
1748 invoke_targets
[i
].c_str () );
1749 fprintf ( fMakefile
,
1751 NormalizeFilename ( invoke
.invokeModule
->GetPath () ).c_str () );
1752 fprintf ( fMakefile
, "\t$(ECHO_INVOKE)\n" );
1753 fprintf ( fMakefile
,
1755 NormalizeFilename ( invoke
.invokeModule
->GetPath () ).c_str (),
1756 invoke
.GetParameters ().c_str () );
1761 MingwModuleHandler::GetPreconditionDependenciesName () const
1763 return module
.name
+ "_precondition";
1767 MingwModuleHandler::GetDefaultDependencies (
1768 string_list
& dependencies
) const
1770 /* Avoid circular dependency */
1771 if ( module
.type
!= BuildTool
1772 && module
.name
!= "zlib"
1773 && module
.name
!= "hostzlib" )
1775 dependencies
.push_back ( "$(INIT)" );
1779 MingwModuleHandler::GeneratePreconditionDependencies ()
1781 string preconditionDependenciesName
= GetPreconditionDependenciesName ();
1782 string_list sourceFilenames
;
1783 GetSourceFilenamesWithoutGeneratedFiles ( sourceFilenames
);
1784 string_list dependencies
;
1785 GetDefaultDependencies ( dependencies
);
1786 GetModuleDependencies ( dependencies
);
1788 GetInvocationDependencies ( module
, dependencies
);
1790 if ( dependencies
.size() )
1792 fprintf ( fMakefile
,
1794 preconditionDependenciesName
.c_str () );
1795 for ( size_t i
= 0; i
< dependencies
.size(); i
++ )
1796 fprintf ( fMakefile
,
1798 dependencies
[i
].c_str () );
1799 fprintf ( fMakefile
, "\n\n" );
1802 for ( size_t i
= 0; i
< sourceFilenames
.size(); i
++ )
1804 fprintf ( fMakefile
,
1806 sourceFilenames
[i
].c_str(),
1807 preconditionDependenciesName
.c_str ());
1809 fprintf ( fMakefile
, "\n" );
1813 MingwModuleHandler::IsWineModule () const
1815 if ( module
.importLibrary
== NULL
)
1818 size_t index
= module
.importLibrary
->definition
.rfind ( ".spec.def" );
1819 return ( index
!= string::npos
);
1823 MingwModuleHandler::GetDefinitionFilename () const
1825 if ( module
.importLibrary
!= NULL
)
1827 string defFilename
= module
.GetBasePath () + SSEP
+ module
.importLibrary
->definition
;
1828 if ( IsWineModule () )
1829 return PassThruCacheDirectory ( NormalizeFilename ( defFilename
),
1830 backend
->intermediateDirectory
);
1835 return "tools" SSEP
"rbuild" SSEP
"empty.def";
1839 MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ()
1841 if ( module
.importLibrary
!= NULL
)
1843 string
library_target (
1844 GetImportLibraryFilename ( module
, &clean_files
) );
1845 string defFilename
= GetDefinitionFilename ();
1848 GetDefinitionDependencies ( deps
);
1850 fprintf ( fMakefile
, "# IMPORT LIBRARY RULE:\n" );
1852 fprintf ( fMakefile
, "%s: %s",
1853 library_target
.c_str (),
1854 defFilename
.c_str () );
1856 size_t i
, iend
= deps
.size();
1857 for ( i
= 0; i
< iend
; i
++ )
1858 fprintf ( fMakefile
, " %s",
1861 fprintf ( fMakefile
, " | %s\n",
1862 GetDirectory ( GetTargetFilename ( module
, NULL
) ).c_str () );
1864 fprintf ( fMakefile
, "\t$(ECHO_DLLTOOL)\n" );
1866 string killAt
= module
.mangledSymbols
? "" : "--kill-at";
1867 fprintf ( fMakefile
,
1868 "\t${dlltool} --dllname %s --def %s --output-lib %s %s\n\n",
1869 module
.GetTargetName ().c_str (),
1870 defFilename
.c_str (),
1871 library_target
.c_str (),
1877 MingwModuleHandler::GetSpecObjectDependencies (
1878 string_list
& dependencies
,
1879 const string
& filename
) const
1881 string basename
= GetBasename ( filename
);
1882 string defDependency
= PassThruCacheDirectory (
1883 NormalizeFilename ( basename
+ ".spec.def" ),
1884 backend
->intermediateDirectory
);
1885 dependencies
.push_back ( defDependency
);
1886 string stubsDependency
= PassThruCacheDirectory (
1887 NormalizeFilename ( basename
+ ".stubs.c" ),
1888 backend
->intermediateDirectory
);
1889 dependencies
.push_back ( stubsDependency
);
1893 MingwModuleHandler::GetWidlObjectDependencies (
1894 string_list
& dependencies
,
1895 const string
& filename
) const
1897 string basename
= GetBasename ( filename
);
1898 string serverDependency
= PassThruCacheDirectory (
1899 NormalizeFilename ( basename
+ "_s.c" ),
1900 backend
->intermediateDirectory
);
1901 dependencies
.push_back ( serverDependency
);
1905 MingwModuleHandler::GetDefinitionDependencies (
1906 string_list
& dependencies
) const
1908 string dkNkmLibNoFixup
= "dk/nkm/lib";
1909 const vector
<File
*>& files
= module
.non_if_data
.files
;
1910 for ( size_t i
= 0; i
< files
.size (); i
++ )
1912 File
& file
= *files
[i
];
1913 string extension
= GetExtension ( file
.name
);
1914 if ( extension
== ".spec" || extension
== ".SPEC" )
1916 GetSpecObjectDependencies ( dependencies
, file
.name
);
1918 if ( extension
== ".idl" || extension
== ".IDL" )
1920 GetWidlObjectDependencies ( dependencies
, file
.name
);
1926 MingwBuildToolModuleHandler::MingwBuildToolModuleHandler ( const Module
& module_
)
1927 : MingwModuleHandler ( module_
)
1932 MingwBuildToolModuleHandler::Process ()
1934 GenerateBuildToolModuleTarget ();
1938 MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ()
1940 string
targetMacro ( GetTargetMacro (module
) );
1941 string objectsMacro
= GetObjectsMacro ( module
);
1942 string linkDepsMacro
= GetLinkingDependenciesMacro ();
1943 string libsMacro
= GetLibsMacro ();
1948 if ( module
.cplusplus
)
1949 linker
= "${host_gpp}";
1951 linker
= "${host_gcc}";
1953 fprintf ( fMakefile
, "%s: %s %s | %s\n",
1954 targetMacro
.c_str (),
1955 objectsMacro
.c_str (),
1956 linkDepsMacro
.c_str (),
1957 GetDirectory(GetTargetFilename(module
,NULL
)).c_str () );
1958 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
1959 fprintf ( fMakefile
,
1960 "\t%s %s -o $@ %s %s\n\n",
1962 GetLinkerMacro ().c_str (),
1963 objectsMacro
.c_str (),
1964 libsMacro
.c_str () );
1968 MingwKernelModuleHandler::MingwKernelModuleHandler (
1969 const Module
& module_
)
1971 : MingwModuleHandler ( module_
)
1976 MingwKernelModuleHandler::Process ()
1978 GenerateKernelModuleTarget ();
1982 MingwKernelModuleHandler::GenerateKernelModuleTarget ()
1984 string
targetMacro ( GetTargetMacro ( module
) );
1985 string workingDirectory
= GetWorkingDirectory ( );
1986 string objectsMacro
= GetObjectsMacro ( module
);
1987 string linkDepsMacro
= GetLinkingDependenciesMacro ();
1988 string libsMacro
= GetLibsMacro ();
1990 GenerateImportLibraryTargetIfNeeded ();
1992 if ( module
.non_if_data
.files
.size () > 0 )
1996 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
1998 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",
1999 module
.GetBasePath ().c_str (),
2000 module
.entrypoint
.c_str (),
2001 module
.baseaddress
.c_str () );
2002 GenerateLinkerCommand ( dependencies
,
2010 GeneratePhonyTarget();
2015 MingwStaticLibraryModuleHandler::MingwStaticLibraryModuleHandler (
2016 const Module
& module_
)
2018 : MingwModuleHandler ( module_
)
2023 MingwStaticLibraryModuleHandler::Process ()
2025 GenerateStaticLibraryModuleTarget ();
2029 MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget ()
2035 MingwObjectLibraryModuleHandler::MingwObjectLibraryModuleHandler (
2036 const Module
& module_
)
2038 : MingwModuleHandler ( module_
)
2043 MingwObjectLibraryModuleHandler::Process ()
2045 GenerateObjectLibraryModuleTarget ();
2049 MingwObjectLibraryModuleHandler::GenerateObjectLibraryModuleTarget ()
2055 MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler (
2056 const Module
& module_
)
2058 : MingwModuleHandler ( module_
)
2063 MingwKernelModeDLLModuleHandler::Process ()
2065 GenerateKernelModeDLLModuleTarget ();
2069 MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ()
2071 string
targetMacro ( GetTargetMacro ( module
) );
2072 string workingDirectory
= GetWorkingDirectory ( );
2073 string objectsMacro
= GetObjectsMacro ( module
);
2074 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2075 string libsMacro
= GetLibsMacro ();
2077 GenerateImportLibraryTargetIfNeeded ();
2079 if ( module
.non_if_data
.files
.size () > 0 )
2083 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2085 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll --dll",
2086 module
.entrypoint
.c_str (),
2087 module
.baseaddress
.c_str () );
2088 GenerateLinkerCommand ( dependencies
,
2096 GeneratePhonyTarget();
2101 MingwKernelModeDriverModuleHandler::MingwKernelModeDriverModuleHandler (
2102 const Module
& module_
)
2104 : MingwModuleHandler ( module_
)
2109 MingwKernelModeDriverModuleHandler::Process ()
2111 GenerateKernelModeDriverModuleTarget ();
2116 MingwKernelModeDriverModuleHandler::GenerateKernelModeDriverModuleTarget ()
2118 string
targetMacro ( GetTargetMacro (module
) );
2119 string workingDirectory
= GetWorkingDirectory ();
2120 string objectsMacro
= GetObjectsMacro ( module
);
2121 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2122 string libsMacro
= GetLibsMacro ();
2124 GenerateImportLibraryTargetIfNeeded ();
2126 if ( module
.non_if_data
.files
.size () > 0 )
2130 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2132 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll --dll",
2133 module
.entrypoint
.c_str (),
2134 module
.baseaddress
.c_str () );
2135 GenerateLinkerCommand ( dependencies
,
2143 GeneratePhonyTarget();
2148 MingwNativeDLLModuleHandler::MingwNativeDLLModuleHandler (
2149 const Module
& module_
)
2151 : MingwModuleHandler ( module_
)
2156 MingwNativeDLLModuleHandler::Process ()
2158 GenerateNativeDLLModuleTarget ();
2162 MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ()
2164 string
targetMacro ( GetTargetMacro (module
) );
2165 string workingDirectory
= GetWorkingDirectory ( );
2166 string objectsMacro
= GetObjectsMacro ( module
);
2167 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2168 string libsMacro
= GetLibsMacro ();
2170 GenerateImportLibraryTargetIfNeeded ();
2172 if ( module
.non_if_data
.files
.size () > 0 )
2176 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2178 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",
2179 module
.entrypoint
.c_str (),
2180 module
.baseaddress
.c_str () );
2181 GenerateLinkerCommand ( dependencies
,
2189 GeneratePhonyTarget();
2194 MingwNativeCUIModuleHandler::MingwNativeCUIModuleHandler (
2195 const Module
& module_
)
2197 : MingwModuleHandler ( module_
)
2202 MingwNativeCUIModuleHandler::Process ()
2204 GenerateNativeCUIModuleTarget ();
2208 MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ()
2210 string
targetMacro ( GetTargetMacro (module
) );
2211 string workingDirectory
= GetWorkingDirectory ( );
2212 string objectsMacro
= GetObjectsMacro ( module
);
2213 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2214 string libsMacro
= GetLibsMacro ();
2216 GenerateImportLibraryTargetIfNeeded ();
2218 if ( module
.non_if_data
.files
.size () > 0 )
2222 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2224 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib",
2225 module
.entrypoint
.c_str (),
2226 module
.baseaddress
.c_str () );
2227 GenerateLinkerCommand ( dependencies
,
2235 GeneratePhonyTarget();
2240 MingwWin32DLLModuleHandler::MingwWin32DLLModuleHandler (
2241 const Module
& module_
)
2243 : MingwModuleHandler ( module_
)
2248 MingwWin32DLLModuleHandler::Process ()
2250 GenerateExtractWineDLLResourcesTarget ();
2251 GenerateWin32DLLModuleTarget ();
2255 MingwWin32DLLModuleHandler::GenerateExtractWineDLLResourcesTarget ()
2257 fprintf ( fMakefile
, ".PHONY: %s_extractresources\n\n",
2258 module
.name
.c_str () );
2259 fprintf ( fMakefile
, "%s_extractresources: $(BIN2RES_TARGET)\n",
2260 module
.name
.c_str () );
2261 const vector
<File
*>& files
= module
.non_if_data
.files
;
2262 for ( size_t i
= 0; i
< files
.size (); i
++ )
2264 File
& file
= *files
[i
];
2265 string extension
= GetExtension ( file
.name
);
2266 if ( extension
== ".rc" || extension
== ".RC" )
2268 string resource
= NormalizeFilename ( file
.name
);
2269 fprintf ( fMakefile
, "\t$(ECHO_BIN2RES)\n" );
2270 fprintf ( fMakefile
, "\t@:echo ${bin2res} -f -x %s\n",
2271 resource
.c_str () );
2274 fprintf ( fMakefile
, "\n");
2278 MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ()
2280 string
targetMacro ( GetTargetMacro (module
) );
2281 string workingDirectory
= GetWorkingDirectory ( );
2282 string objectsMacro
= GetObjectsMacro ( module
);
2283 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2284 string libsMacro
= GetLibsMacro ();
2286 GenerateImportLibraryTargetIfNeeded ();
2288 if ( module
.non_if_data
.files
.size () > 0 )
2292 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2295 if ( module
.cplusplus
)
2300 string linkerParameters
= ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -mdll --dll",
2301 module
.entrypoint
.c_str (),
2302 module
.baseaddress
.c_str () );
2303 GenerateLinkerCommand ( dependencies
,
2311 GeneratePhonyTarget();
2316 MingwWin32CUIModuleHandler::MingwWin32CUIModuleHandler (
2317 const Module
& module_
)
2319 : MingwModuleHandler ( module_
)
2324 MingwWin32CUIModuleHandler::Process ()
2326 GenerateWin32CUIModuleTarget ();
2330 MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ()
2332 string
targetMacro ( GetTargetMacro (module
) );
2333 string workingDirectory
= GetWorkingDirectory ( );
2334 string objectsMacro
= GetObjectsMacro ( module
);
2335 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2336 string libsMacro
= GetLibsMacro ();
2338 GenerateImportLibraryTargetIfNeeded ();
2340 if ( module
.non_if_data
.files
.size () > 0 )
2344 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2347 if ( module
.cplusplus
)
2352 string linkerParameters
= ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
2353 module
.entrypoint
.c_str (),
2354 module
.baseaddress
.c_str () );
2355 GenerateLinkerCommand ( dependencies
,
2363 GeneratePhonyTarget();
2368 MingwWin32GUIModuleHandler::MingwWin32GUIModuleHandler (
2369 const Module
& module_
)
2371 : MingwModuleHandler ( module_
)
2376 MingwWin32GUIModuleHandler::Process ()
2378 GenerateWin32GUIModuleTarget ();
2382 MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ()
2384 string
targetMacro ( GetTargetMacro (module
) );
2385 string workingDirectory
= GetWorkingDirectory ( );
2386 string objectsMacro
= GetObjectsMacro ( module
);
2387 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2388 string libsMacro
= GetLibsMacro ();
2390 GenerateImportLibraryTargetIfNeeded ();
2392 if ( module
.non_if_data
.files
.size () > 0 )
2396 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2399 if ( module
.cplusplus
)
2404 string linkerParameters
= ssprintf ( "-Wl,--subsystem,windows -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
2405 module
.entrypoint
.c_str (),
2406 module
.baseaddress
.c_str () );
2407 GenerateLinkerCommand ( dependencies
,
2415 GeneratePhonyTarget();
2420 MingwBootLoaderModuleHandler::MingwBootLoaderModuleHandler (
2421 const Module
& module_
)
2423 : MingwModuleHandler ( module_
)
2428 MingwBootLoaderModuleHandler::Process ()
2430 GenerateBootLoaderModuleTarget ();
2434 MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ()
2436 string
targetName ( module
.GetTargetName () );
2437 string
targetMacro ( GetTargetMacro (module
) );
2438 string workingDirectory
= GetWorkingDirectory ();
2439 string junk_tmp
= ros_temp
+ module
.name
+ ".junk.tmp";
2440 CLEAN_FILE ( junk_tmp
);
2441 string objectsMacro
= GetObjectsMacro ( module
);
2442 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2443 string libsMacro
= GetLibsMacro ();
2447 fprintf ( fMakefile
, "%s: %s %s | %s\n",
2448 targetMacro
.c_str (),
2449 objectsMacro
.c_str (),
2450 linkDepsMacro
.c_str (),
2451 GetDirectory(GetTargetFilename(module
,NULL
)).c_str () );
2453 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
2455 fprintf ( fMakefile
,
2456 "\t${ld} %s -N -Ttext=0x8000 -o %s %s %s\n",
2457 GetLinkerMacro ().c_str (),
2459 objectsMacro
.c_str (),
2460 linkDepsMacro
.c_str () );
2461 fprintf ( fMakefile
,
2462 "\t${objcopy} -O binary %s $@\n",
2463 junk_tmp
.c_str () );
2464 fprintf ( fMakefile
,
2465 "\t-@${rm} %s 2>$(NUL)\n",
2466 junk_tmp
.c_str () );
2470 MingwBootSectorModuleHandler::MingwBootSectorModuleHandler (
2471 const Module
& module_
)
2473 : MingwModuleHandler ( module_
)
2478 MingwBootSectorModuleHandler::Process ()
2480 GenerateBootSectorModuleTarget ();
2484 MingwBootSectorModuleHandler::GenerateBootSectorModuleTarget ()
2486 string objectsMacro
= GetObjectsMacro ( module
);
2490 fprintf ( fMakefile
, ".PHONY: %s\n\n",
2491 module
.name
.c_str ());
2492 fprintf ( fMakefile
,
2494 module
.name
.c_str (),
2495 objectsMacro
.c_str () );
2499 MingwIsoModuleHandler::MingwIsoModuleHandler (
2500 const Module
& module_
)
2502 : MingwModuleHandler ( module_
)
2507 MingwIsoModuleHandler::Process ()
2509 GenerateIsoModuleTarget ();
2513 MingwIsoModuleHandler::OutputBootstrapfileCopyCommands (
2514 const string
& bootcdDirectory
)
2516 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
2518 const Module
& m
= *module
.project
.modules
[i
];
2519 if ( m
.bootstrap
!= NULL
)
2521 string sourceFilename
= PassThruCacheDirectory (
2522 NormalizeFilename ( m
.GetPath () ),
2523 backend
->outputDirectory
);
2524 string
targetFilenameNoFixup ( bootcdDirectory
+ SSEP
+ m
.bootstrap
->base
+ SSEP
+ m
.bootstrap
->nameoncd
);
2525 string targetFilename
= MingwModuleHandler::PassThruCacheDirectory (
2526 NormalizeFilename ( targetFilenameNoFixup
),
2527 backend
->outputDirectory
);
2528 fprintf ( fMakefile
,
2530 fprintf ( fMakefile
,
2531 "\t${cp} %s %s 1>$(NUL)\n",
2532 sourceFilename
.c_str (),
2533 targetFilename
.c_str () );
2539 MingwIsoModuleHandler::OutputCdfileCopyCommands (
2540 const string
& bootcdDirectory
)
2542 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
2544 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
2545 string targetFilenameNoFixup
= bootcdDirectory
+ SSEP
+ cdfile
.base
+ SSEP
+ cdfile
.nameoncd
;
2546 string targetFilename
= MingwModuleHandler::PassThruCacheDirectory (
2547 NormalizeFilename ( targetFilenameNoFixup
),
2548 backend
->outputDirectory
);
2549 fprintf ( fMakefile
,
2551 fprintf ( fMakefile
,
2552 "\t${cp} %s %s 1>$(NUL)\n",
2553 cdfile
.GetPath ().c_str (),
2554 targetFilename
.c_str () );
2559 MingwIsoModuleHandler::GetBootstrapCdDirectories ( const string
& bootcdDirectory
)
2562 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
2564 const Module
& m
= *module
.project
.modules
[i
];
2565 if ( m
.bootstrap
!= NULL
)
2567 string
targetDirectory ( bootcdDirectory
+ SSEP
+ m
.bootstrap
->base
);
2568 if ( directories
.size () > 0 )
2570 directories
+= PassThruCacheDirectory (
2571 NormalizeFilename ( targetDirectory
),
2572 backend
->outputDirectory
);
2579 MingwIsoModuleHandler::GetNonModuleCdDirectories ( const string
& bootcdDirectory
)
2582 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
2584 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
2585 string
targetDirectory ( bootcdDirectory
+ SSEP
+ cdfile
.base
);
2586 if ( directories
.size () > 0 )
2588 directories
+= PassThruCacheDirectory (
2589 NormalizeFilename ( targetDirectory
),
2590 backend
->outputDirectory
);
2596 MingwIsoModuleHandler::GetCdDirectories ( const string
& bootcdDirectory
)
2598 string directories
= GetBootstrapCdDirectories ( bootcdDirectory
);
2599 directories
+= " " + GetNonModuleCdDirectories ( bootcdDirectory
);
2604 MingwIsoModuleHandler::GetBootstrapCdFiles (
2605 vector
<string
>& out
) const
2607 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
2609 const Module
& m
= *module
.project
.modules
[i
];
2610 if ( m
.bootstrap
!= NULL
)
2612 string filename
= PassThruCacheDirectory (
2613 NormalizeFilename ( m
.GetPath () ),
2614 backend
->outputDirectory
);
2615 out
.push_back ( filename
);
2621 MingwIsoModuleHandler::GetNonModuleCdFiles (
2622 vector
<string
>& out
) const
2624 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
2626 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
2627 out
.push_back ( cdfile
.GetPath () );
2632 MingwIsoModuleHandler::GetCdFiles (
2633 vector
<string
>& out
) const
2635 GetBootstrapCdFiles ( out
);
2636 GetNonModuleCdFiles ( out
);
2640 MingwIsoModuleHandler::GenerateIsoModuleTarget ()
2642 string bootcdDirectory
= "cd";
2643 string bootcd
= PassThruCacheDirectory (
2644 NormalizeFilename ( bootcdDirectory
+ SSEP
),
2645 backend
->outputDirectory
);
2646 string isoboot
= PassThruCacheDirectory (
2647 NormalizeFilename ( "boot" SSEP
"freeldr" SSEP
"bootsect" SSEP
"isoboot.o" ),
2648 backend
->outputDirectory
);
2649 string bootcdReactosNoFixup
= bootcdDirectory
+ SSEP
"reactos";
2650 string bootcdReactos
= PassThruCacheDirectory (
2651 NormalizeFilename ( bootcdReactosNoFixup
+ SSEP
),
2652 backend
->outputDirectory
);
2653 CLEAN_FILE ( bootcdReactos
);
2654 string reactosInf
= PassThruCacheDirectory (
2655 NormalizeFilename ( bootcdReactosNoFixup
+ SSEP
"reactos.inf" ),
2656 backend
->outputDirectory
);
2657 string reactosDff
= NormalizeFilename ( "bootdata" SSEP
"packages" SSEP
"reactos.dff" );
2658 string cdDirectories
= GetCdDirectories ( bootcdDirectory
);
2659 vector
<string
> vCdFiles
;
2660 GetCdFiles ( vCdFiles
);
2661 string cdFiles
= v2s ( vCdFiles
, 5 );
2663 fprintf ( fMakefile
, ".PHONY: %s\n\n",
2664 module
.name
.c_str ());
2665 fprintf ( fMakefile
,
2666 "%s: all %s %s %s %s $(CABMAN_TARGET) $(CDMAKE_TARGET)\n",
2667 module
.name
.c_str (),
2669 bootcdReactos
.c_str (),
2670 cdDirectories
.c_str (),
2672 fprintf ( fMakefile
, "\t$(ECHO_CABMAN)\n" );
2673 fprintf ( fMakefile
,
2674 "\t$(Q)$(CABMAN_TARGET) -C %s -L %s -I -P $(OUTPUT)\n",
2675 reactosDff
.c_str (),
2676 bootcdReactos
.c_str () );
2677 fprintf ( fMakefile
,
2678 "\t$(Q)$(CABMAN_TARGET) -C %s -RC %s -L %s -N -P $(OUTPUT)\n",
2679 reactosDff
.c_str (),
2680 reactosInf
.c_str (),
2681 bootcdReactos
.c_str ());
2682 fprintf ( fMakefile
,
2683 "\t-@${rm} %s 2>$(NUL)\n",
2684 reactosInf
.c_str () );
2685 OutputBootstrapfileCopyCommands ( bootcdDirectory
);
2686 OutputCdfileCopyCommands ( bootcdDirectory
);
2687 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
2688 fprintf ( fMakefile
,
2689 "\t$(Q)$(CDMAKE_TARGET) -v -m -b %s %s REACTOS ReactOS.iso\n",
2692 fprintf ( fMakefile
,
2697 MingwLiveIsoModuleHandler::MingwLiveIsoModuleHandler (
2698 const Module
& module_
)
2700 : MingwModuleHandler ( module_
)
2705 MingwLiveIsoModuleHandler::Process ()
2707 GenerateLiveIsoModuleTarget ();
2711 MingwLiveIsoModuleHandler::CreateDirectory ( const string
& directory
)
2713 string normalizedDirectory
= MingwModuleHandler::PassThruCacheDirectory (
2714 NormalizeFilename ( directory
) + SSEP
,
2715 backend
->outputDirectory
);
2719 MingwLiveIsoModuleHandler::OutputCopyCommand ( const string
& sourceFilename
,
2720 const string
& targetFilename
,
2721 const string
& targetDirectory
)
2723 string normalizedTargetFilename
= MingwModuleHandler::PassThruCacheDirectory (
2724 NormalizeFilename ( targetDirectory
+ SSEP
+ targetFilename
),
2725 backend
->outputDirectory
);
2726 fprintf ( fMakefile
,
2728 fprintf ( fMakefile
,
2729 "\t${cp} %s %s 1>$(NUL)\n",
2730 sourceFilename
.c_str (),
2731 normalizedTargetFilename
.c_str () );
2735 MingwLiveIsoModuleHandler::OutputModuleCopyCommands ( string
& livecdDirectory
,
2736 string
& reactosDirectory
)
2738 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
2740 const Module
& m
= *module
.project
.modules
[i
];
2741 if ( m
.installName
.length () > 0 )
2743 string sourceFilename
= MingwModuleHandler::PassThruCacheDirectory (
2744 NormalizeFilename ( m
.GetPath () ),
2745 backend
->outputDirectory
);
2746 OutputCopyCommand ( sourceFilename
,
2748 livecdDirectory
+ SSEP
+ reactosDirectory
+ SSEP
+ m
.installBase
);
2754 MingwLiveIsoModuleHandler::OutputNonModuleCopyCommands ( string
& livecdDirectory
,
2755 string
& reactosDirectory
)
2757 for ( size_t i
= 0; i
< module
.project
.installfiles
.size (); i
++ )
2759 const InstallFile
& installfile
= *module
.project
.installfiles
[i
];
2760 OutputCopyCommand ( installfile
.GetPath (),
2761 installfile
.newname
,
2762 livecdDirectory
+ SSEP
+ reactosDirectory
+ SSEP
+ installfile
.base
);
2767 MingwLiveIsoModuleHandler::OutputProfilesDirectoryCommands ( string
& livecdDirectory
)
2769 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" );
2770 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" SSEP
"All Users") ;
2771 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" SSEP
"All Users" SSEP
"Desktop" );
2772 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" SSEP
"Default User" );
2773 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" SSEP
"Default User" SSEP
"Desktop" );
2774 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" SSEP
"Default User" SSEP
"My Documents" );
2776 string livecdIni
= "bootdata" SSEP
"livecd.ini";
2777 OutputCopyCommand ( livecdIni
,
2783 MingwLiveIsoModuleHandler::OutputLoaderCommands ( string
& livecdDirectory
)
2785 string freeldr
= PassThruCacheDirectory (
2786 NormalizeFilename ( "boot" SSEP
"freeldr" SSEP
"freeldr" SSEP
"freeldr.sys" ),
2787 backend
->outputDirectory
);
2788 CreateDirectory ( livecdDirectory
+ SSEP
"loader" );
2789 OutputCopyCommand ( freeldr
,
2791 livecdDirectory
+ SSEP
+ "loader" );
2795 MingwLiveIsoModuleHandler::OutputRegistryCommands ( string
& livecdDirectory
)
2797 string reactosSystem32ConfigDirectory
= NormalizeFilename (
2798 MingwModuleHandler::PassThruCacheDirectory (
2799 livecdDirectory
+ SSEP
"reactos" SSEP
"system32" SSEP
"config" SSEP
,
2800 backend
->outputDirectory
) );
2801 fprintf ( fMakefile
,
2802 "\t$(ECHO_MKHIVE)\n" );
2803 fprintf ( fMakefile
,
2804 "\t$(MKHIVE_TARGET) bootdata %s bootdata" SSEP
"livecd.inf bootdata" SSEP
"hiveinst.inf\n",
2805 reactosSystem32ConfigDirectory
.c_str () );
2809 MingwLiveIsoModuleHandler::GenerateLiveIsoModuleTarget ()
2811 string livecdDirectory
= "livecd";
2812 string livecd
= PassThruCacheDirectory (
2813 NormalizeFilename ( livecdDirectory
+ SSEP
),
2814 backend
->outputDirectory
);
2815 string isoboot
= PassThruCacheDirectory (
2816 NormalizeFilename ( "boot" SSEP
"freeldr" SSEP
"bootsect" SSEP
"isoboot.o" ),
2817 backend
->outputDirectory
);
2818 string reactosDirectory
= "reactos";
2819 string livecdReactosNoFixup
= livecdDirectory
+ SSEP
+ reactosDirectory
;
2820 string livecdReactos
= NormalizeFilename ( PassThruCacheDirectory (
2821 NormalizeFilename ( livecdReactosNoFixup
+ SSEP
),
2822 backend
->outputDirectory
) );
2823 CLEAN_FILE ( livecdReactos
);
2825 fprintf ( fMakefile
, ".PHONY: %s\n\n",
2826 module
.name
.c_str ());
2827 fprintf ( fMakefile
,
2828 "%s: all %s %s $(MKHIVE_TARGET) $(CDMAKE_TARGET)\n",
2829 module
.name
.c_str (),
2831 livecdReactos
.c_str () );
2832 OutputModuleCopyCommands ( livecdDirectory
,
2834 OutputNonModuleCopyCommands ( livecdDirectory
,
2836 OutputProfilesDirectoryCommands ( livecdDirectory
);
2837 OutputLoaderCommands ( livecdDirectory
);
2838 OutputRegistryCommands ( livecdDirectory
);
2839 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
2840 fprintf ( fMakefile
,
2841 "\t$(Q)$(CDMAKE_TARGET) -v -m -j -b %s %s REACTOS ReactOS-LiveCD.iso\n",
2844 fprintf ( fMakefile
,
2849 MingwTestModuleHandler::MingwTestModuleHandler (
2850 const Module
& module_
)
2852 : MingwModuleHandler ( module_
)
2857 MingwTestModuleHandler::Process ()
2859 GenerateTestModuleTarget ();
2863 MingwTestModuleHandler::GenerateTestModuleTarget ()
2865 string
targetMacro ( GetTargetMacro ( module
) );
2866 string workingDirectory
= GetWorkingDirectory ( );
2867 string objectsMacro
= GetObjectsMacro ( module
);
2868 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2869 string libsMacro
= GetLibsMacro ();
2871 GenerateImportLibraryTargetIfNeeded ();
2873 if ( module
.non_if_data
.files
.size () > 0 )
2877 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2880 if ( module
.cplusplus
)
2885 string linkerParameters
= ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
2886 module
.entrypoint
.c_str (),
2887 module
.baseaddress
.c_str () );
2888 GenerateLinkerCommand ( dependencies
,
2896 GeneratePhonyTarget();
2901 MingwRpcServerModuleHandler::MingwRpcServerModuleHandler (
2902 const Module
& module_
)
2904 : MingwModuleHandler ( module_
)
2909 MingwRpcServerModuleHandler::Process ()
2914 MingwRpcClientModuleHandler::MingwRpcClientModuleHandler (
2915 const Module
& module_
)
2917 : MingwModuleHandler ( module_
)
2922 MingwRpcClientModuleHandler::Process ()