4 #include "../../rbuild.h"
6 #include "modulehandler.h"
11 #define CLEAN_FILE(f) clean_files.push_back ( f );
13 static string ros_temp
= "$(TEMPORARY)";
15 MingwModuleHandler::backend
= NULL
;
17 MingwModuleHandler::fMakefile
= NULL
;
19 MingwModuleHandler::use_pch
= false;
23 const string
& filename
,
24 const string
& prefix
)
26 if ( !prefix
.length() )
29 const char* pfilename
= filename
.c_str();
30 const char* p1
= strrchr ( pfilename
, '/' );
31 const char* p2
= strrchr ( pfilename
, '\\' );
36 out
+= string(pfilename
,p1
-pfilename
) + CSEP
;
39 out
+= prefix
+ pfilename
;
44 GetTargetMacro ( const Module
& module
, bool with_dollar
)
46 string
s ( module
.name
);
50 return ssprintf ( "$(%s)", s
.c_str() );
54 MingwModuleHandler::MingwModuleHandler (
55 const Module
& module_
)
61 MingwModuleHandler::~MingwModuleHandler()
66 MingwModuleHandler::SetBackend ( MingwBackend
* backend_
)
72 MingwModuleHandler::SetMakefile ( FILE* f
)
78 MingwModuleHandler::SetUsePch ( bool b
)
84 MingwModuleHandler::RemoveVariables ( string path
)
86 size_t i
= path
.find ( '$' );
87 if ( i
!= string::npos
)
89 size_t j
= path
.find ( ')', i
);
90 if ( j
!= string::npos
)
92 if ( j
+ 2 < path
.length () && path
[j
+ 1] == CSEP
)
93 return path
.substr ( j
+ 2);
95 return path
.substr ( j
+ 1);
102 MingwModuleHandler::PassThruCacheDirectory (
104 Directory
* directoryTree
)
106 string
directory ( GetDirectory ( RemoveVariables ( file
) ) );
107 string generatedFilesDirectory
= backend
->AddDirectoryTarget ( directory
,
109 if ( directory
.find ( generatedFilesDirectory
) != string::npos
)
110 /* This path already includes the generated files directory variable */
113 return generatedFilesDirectory
+ SSEP
+ file
;
117 MingwModuleHandler::GetTargetFilename (
118 const Module
& module
,
119 string_list
* pclean_files
)
121 string target
= PassThruCacheDirectory (
122 NormalizeFilename ( module
.GetPath () ),
123 backend
->outputDirectory
);
126 string_list
& clean_files
= *pclean_files
;
127 CLEAN_FILE ( target
);
133 MingwModuleHandler::GetImportLibraryFilename (
134 const Module
& module
,
135 string_list
* pclean_files
)
137 string target
= PassThruCacheDirectory (
138 NormalizeFilename ( module
.GetDependencyPath () ),
139 backend
->outputDirectory
);
142 string_list
& clean_files
= *pclean_files
;
143 CLEAN_FILE ( target
);
148 /*static*/ MingwModuleHandler
*
149 MingwModuleHandler::InstanciateHandler (
150 const Module
& module
,
151 MingwBackend
* backend
)
153 MingwModuleHandler
* handler
;
154 switch ( module
.type
)
157 handler
= new MingwBuildToolModuleHandler ( module
);
160 handler
= new MingwStaticLibraryModuleHandler ( module
);
163 handler
= new MingwObjectLibraryModuleHandler ( module
);
166 handler
= new MingwKernelModuleHandler ( module
);
169 handler
= new MingwNativeCUIModuleHandler ( module
);
172 handler
= new MingwWin32CUIModuleHandler ( module
);
175 handler
= new MingwWin32GUIModuleHandler ( module
);
178 handler
= new MingwKernelModeDLLModuleHandler ( module
);
181 handler
= new MingwNativeDLLModuleHandler ( module
);
184 handler
= new MingwWin32DLLModuleHandler ( module
);
186 case KernelModeDriver
:
187 handler
= new MingwKernelModeDriverModuleHandler ( module
);
190 handler
= new MingwBootLoaderModuleHandler ( module
);
193 handler
= new MingwBootSectorModuleHandler ( module
);
196 handler
= new MingwIsoModuleHandler ( module
);
199 handler
= new MingwLiveIsoModuleHandler ( module
);
202 handler
= new MingwTestModuleHandler ( module
);
205 handler
= new MingwRpcServerModuleHandler ( module
);
208 handler
= new MingwRpcClientModuleHandler ( module
);
211 throw UnknownModuleTypeException (
212 module
.node
.location
,
220 MingwModuleHandler::GetWorkingDirectory () const
226 MingwModuleHandler::GetBasename ( const string
& filename
) const
228 size_t index
= filename
.find_last_of ( '.' );
229 if ( index
!= string::npos
)
230 return filename
.substr ( 0, index
);
235 MingwModuleHandler::GetActualSourceFilename (
236 const string
& filename
) const
238 string extension
= GetExtension ( filename
);
239 if ( extension
== ".spec" || extension
== ".SPEC" )
241 string basename
= GetBasename ( filename
);
242 return PassThruCacheDirectory ( NormalizeFilename ( basename
+ ".stubs.c" ),
243 backend
->intermediateDirectory
);
245 else if ( extension
== ".idl" || extension
== ".IDL" )
247 string basename
= GetBasename ( filename
);
249 if ( module
.type
== RpcServer
)
250 newname
= basename
+ "_s.c";
252 newname
= basename
+ "_c.c";
253 return PassThruCacheDirectory ( NormalizeFilename ( newname
),
254 backend
->intermediateDirectory
);
261 MingwModuleHandler::GetModuleArchiveFilename () const
263 if ( module
.type
== StaticLibrary
)
264 return GetTargetFilename ( module
, NULL
);
265 return PassThruCacheDirectory ( ReplaceExtension (
266 NormalizeFilename ( module
.GetPath () ),
268 backend
->intermediateDirectory
);
272 MingwModuleHandler::IsGeneratedFile ( const File
& file
) const
274 string extension
= GetExtension ( file
.name
);
275 return ( extension
== ".spec" || extension
== ".SPEC" );
279 MingwModuleHandler::ReferenceObjects (
280 const Module
& module
)
282 if ( module
.type
== ObjectLibrary
)
284 if ( module
.type
== RpcServer
)
286 if ( module
.type
== RpcClient
)
292 MingwModuleHandler::GetImportLibraryDependency (
293 const Module
& importedModule
)
296 if ( ReferenceObjects ( importedModule
) )
297 dep
= GetTargetMacro ( importedModule
);
299 dep
= GetImportLibraryFilename ( importedModule
, NULL
);
304 MingwModuleHandler::GetTargets ( const Module
& dependencyModule
,
305 string_list
& targets
)
307 if ( dependencyModule
.invocations
.size () > 0 )
309 for ( size_t i
= 0; i
< dependencyModule
.invocations
.size (); i
++ )
311 Invoke
& invoke
= *dependencyModule
.invocations
[i
];
312 invoke
.GetTargets ( targets
);
316 targets
.push_back ( GetImportLibraryDependency ( dependencyModule
) );
320 MingwModuleHandler::GetModuleDependencies (
321 string_list
& dependencies
)
323 size_t iend
= module
.dependencies
.size ();
328 for ( size_t i
= 0; i
< iend
; i
++ )
330 const Dependency
& dependency
= *module
.dependencies
[i
];
331 const Module
& dependencyModule
= *dependency
.dependencyModule
;
332 GetTargets ( dependencyModule
,
335 GetDefinitionDependencies ( dependencies
);
339 MingwModuleHandler::GetSourceFilenames (
341 bool includeGeneratedFiles
) const
345 const vector
<File
*>& files
= module
.non_if_data
.files
;
346 for ( i
= 0; i
< files
.size (); i
++ )
348 if ( includeGeneratedFiles
|| !IsGeneratedFile ( *files
[i
] ) )
351 GetActualSourceFilename ( files
[i
]->name
) );
354 // intentionally make a copy so that we can append more work in
355 // the middle of processing without having to go recursive
356 vector
<If
*> v
= module
.non_if_data
.ifs
;
357 for ( i
= 0; i
< v
.size (); i
++ )
361 // check for sub-ifs to add to list
362 const vector
<If
*>& ifs
= rIf
.data
.ifs
;
363 for ( j
= 0; j
< ifs
.size (); j
++ )
364 v
.push_back ( ifs
[j
] );
365 const vector
<File
*>& files
= rIf
.data
.files
;
366 for ( j
= 0; j
< files
.size (); j
++ )
368 File
& file
= *files
[j
];
369 if ( includeGeneratedFiles
|| !IsGeneratedFile ( file
) )
372 GetActualSourceFilename ( file
.name
) );
379 MingwModuleHandler::GetSourceFilenamesWithoutGeneratedFiles (
380 string_list
& list
) const
382 GetSourceFilenames ( list
, false );
386 MingwModuleHandler::GetObjectFilename (
387 const string
& sourceFilename
,
388 string_list
* pclean_files
) const
390 Directory
* directoryTree
;
393 string extension
= GetExtension ( sourceFilename
);
394 if ( extension
== ".rc" || extension
== ".RC" )
395 newExtension
= ".coff";
396 else if ( extension
== ".spec" || extension
== ".SPEC" )
397 newExtension
= ".stubs.o";
398 else if ( extension
== ".idl" || extension
== ".IDL" )
400 if ( module
.type
== RpcServer
)
401 newExtension
= "_s.o";
403 newExtension
= "_c.o";
408 if ( module
.type
== BootSector
)
409 directoryTree
= backend
->outputDirectory
;
411 directoryTree
= backend
->intermediateDirectory
;
413 string obj_file
= PassThruCacheDirectory (
414 NormalizeFilename ( ReplaceExtension (
415 RemoveVariables ( sourceFilename
),
420 string_list
& clean_files
= *pclean_files
;
421 CLEAN_FILE ( obj_file
);
427 MingwModuleHandler::GenerateCleanTarget () const
429 if ( 0 == clean_files
.size() )
431 fprintf ( fMakefile
, ".PHONY: %s_clean\n", module
.name
.c_str() );
432 fprintf ( fMakefile
, "%s_clean:\n\t-@${rm}", module
.name
.c_str() );
433 for ( size_t i
= 0; i
< clean_files
.size(); i
++ )
436 fprintf ( fMakefile
, " 2>$(NUL)\n\t-@${rm}" );
437 fprintf ( fMakefile
, " %s", clean_files
[i
].c_str() );
439 fprintf ( fMakefile
, " 2>$(NUL)\n" );
440 fprintf ( fMakefile
, "clean: %s_clean\n\n", module
.name
.c_str() );
444 MingwModuleHandler::GenerateInstallTarget () const
446 if ( module
.installName
.length () == 0 )
448 fprintf ( fMakefile
, ".PHONY: %s_install\n", module
.name
.c_str() );
449 fprintf ( fMakefile
, "%s_install:\n", module
.name
.c_str() );
450 string sourceFilename
= MingwModuleHandler::PassThruCacheDirectory (
451 NormalizeFilename ( module
.GetPath () ),
452 backend
->outputDirectory
);
453 string normalizedTargetFilename
= MingwModuleHandler::PassThruCacheDirectory (
454 NormalizeFilename ( module
.installBase
+ SSEP
+ module
.installName
),
455 backend
->installDirectory
);
459 "\t${cp} %s %s 1>$(NUL)\n",
460 sourceFilename
.c_str (),
461 normalizedTargetFilename
.c_str () );
465 MingwModuleHandler::GetObjectFilenames ()
467 const vector
<File
*>& files
= module
.non_if_data
.files
;
468 if ( files
.size () == 0 )
471 string
objectFilenames ( "" );
472 for ( size_t i
= 0; i
< files
.size (); i
++ )
474 if ( objectFilenames
.size () > 0 )
475 objectFilenames
+= " ";
477 GetObjectFilename ( files
[i
]->name
, NULL
);
479 return objectFilenames
;
483 MingwModuleHandler::GenerateGccDefineParametersFromVector (
484 const vector
<Define
*>& defines
) const
487 for ( size_t i
= 0; i
< defines
.size (); i
++ )
489 Define
& define
= *defines
[i
];
490 if (parameters
.length () > 0)
493 parameters
+= define
.name
;
494 if (define
.value
.length () > 0)
497 parameters
+= define
.value
;
504 MingwModuleHandler::GenerateGccDefineParameters () const
506 string parameters
= GenerateGccDefineParametersFromVector ( module
.project
.non_if_data
.defines
);
507 string s
= GenerateGccDefineParametersFromVector ( module
.non_if_data
.defines
);
508 if ( s
.length () > 0 )
517 MingwModuleHandler::ConcatenatePaths (
519 const string
& path2
) const
521 if ( ( path1
.length () == 0 ) || ( path1
== "." ) || ( path1
== "./" ) )
523 if ( path1
[path1
.length ()] == CSEP
)
524 return path1
+ path2
;
526 return path1
+ CSEP
+ path2
;
530 MingwModuleHandler::GenerateGccIncludeParametersFromVector ( const vector
<Include
*>& includes
) const
533 for ( size_t i
= 0; i
< includes
.size (); i
++ )
535 Include
& include
= *includes
[i
];
536 if ( parameters
.length () > 0 )
538 parameters
+= "-I" + include
.directory
;
544 MingwModuleHandler::GenerateGccIncludeParameters () const
546 string parameters
= GenerateGccIncludeParametersFromVector ( module
.non_if_data
.includes
);
547 string s
= GenerateGccIncludeParametersFromVector ( module
.project
.non_if_data
.includes
);
548 if ( s
.length () > 0 )
558 MingwModuleHandler::GenerateCompilerParametersFromVector ( const vector
<CompilerFlag
*>& compilerFlags
) const
561 for ( size_t i
= 0; i
< compilerFlags
.size (); i
++ )
563 CompilerFlag
& compilerFlag
= *compilerFlags
[i
];
564 if ( parameters
.length () > 0 )
566 parameters
+= compilerFlag
.flag
;
572 MingwModuleHandler::GenerateLinkerParametersFromVector ( const vector
<LinkerFlag
*>& linkerFlags
) const
575 for ( size_t i
= 0; i
< linkerFlags
.size (); i
++ )
577 LinkerFlag
& linkerFlag
= *linkerFlags
[i
];
578 if ( parameters
.length () > 0 )
580 parameters
+= linkerFlag
.flag
;
586 MingwModuleHandler::GenerateImportLibraryDependenciesFromVector (
587 const vector
<Library
*>& libraries
)
589 string
dependencies ( "" );
591 for ( size_t i
= 0; i
< libraries
.size (); i
++ )
593 if ( wrap_count
++ == 5 )
594 dependencies
+= " \\\n\t\t", wrap_count
= 0;
595 else if ( dependencies
.size () > 0 )
597 dependencies
+= GetImportLibraryDependency ( *libraries
[i
]->imported_module
);
603 MingwModuleHandler::GenerateLinkerParameters () const
605 return GenerateLinkerParametersFromVector ( module
.linkerFlags
);
609 MingwModuleHandler::GenerateMacro (
610 const char* assignmentOperation
,
612 const IfableData
& data
,
613 const vector
<CompilerFlag
*>* compilerFlags
)
621 assignmentOperation
);
623 if ( compilerFlags
!= NULL
)
625 string compilerParameters
= GenerateCompilerParametersFromVector ( *compilerFlags
);
626 if ( compilerParameters
.size () > 0 )
631 compilerParameters
.c_str () );
635 for ( i
= 0; i
< data
.includes
.size(); i
++ )
640 data
.includes
[i
]->directory
.c_str() );
642 for ( i
= 0; i
< data
.defines
.size(); i
++ )
644 Define
& d
= *data
.defines
[i
];
649 if ( d
.value
.size() )
655 fprintf ( fMakefile
, "\n" );
659 MingwModuleHandler::GenerateMacros (
660 const char* assignmentOperation
,
661 const IfableData
& data
,
662 const vector
<CompilerFlag
*>* compilerFlags
,
663 const vector
<LinkerFlag
*>* linkerFlags
)
667 if ( data
.includes
.size () > 0 || data
.defines
.size () > 0 )
669 GenerateMacro ( assignmentOperation
,
673 GenerateMacro ( assignmentOperation
,
679 if ( linkerFlags
!= NULL
)
681 string linkerParameters
= GenerateLinkerParametersFromVector ( *linkerFlags
);
682 if ( linkerParameters
.size () > 0 )
687 linkerflagsMacro
.c_str (),
689 linkerParameters
.c_str() );
693 if ( data
.libraries
.size () > 0 )
695 string deps
= GenerateImportLibraryDependenciesFromVector ( data
.libraries
);
696 if ( deps
.size () > 0 )
707 const vector
<If
*>& ifs
= data
.ifs
;
708 for ( i
= 0; i
< ifs
.size(); i
++ )
711 if ( rIf
.data
.defines
.size()
712 || rIf
.data
.includes
.size()
713 || rIf
.data
.libraries
.size()
714 || rIf
.data
.files
.size()
715 || rIf
.data
.ifs
.size() )
719 "ifeq (\"$(%s)\",\"%s\")\n",
720 rIf
.property
.c_str(),
735 MingwModuleHandler::GenerateObjectMacros (
736 const char* assignmentOperation
,
737 const IfableData
& data
,
738 const vector
<CompilerFlag
*>* compilerFlags
,
739 const vector
<LinkerFlag
*>* linkerFlags
)
743 const vector
<File
*>& files
= data
.files
;
744 if ( files
.size () > 0 )
746 for ( i
= 0; i
< files
.size (); i
++ )
748 File
& file
= *files
[i
];
753 objectsMacro
.c_str(),
755 file
.name
, NULL
).c_str (),
756 objectsMacro
.c_str() );
762 objectsMacro
.c_str (),
763 assignmentOperation
);
764 for ( i
= 0; i
< files
.size(); i
++ )
766 File
& file
= *files
[i
];
772 ( i
%10 == 9 ? " \\\n\t" : " " ),
774 file
.name
, NULL
).c_str () );
777 fprintf ( fMakefile
, "\n" );
780 const vector
<If
*>& ifs
= data
.ifs
;
781 for ( i
= 0; i
< ifs
.size(); i
++ )
784 if ( rIf
.data
.defines
.size()
785 || rIf
.data
.includes
.size()
786 || rIf
.data
.libraries
.size()
787 || rIf
.data
.files
.size()
788 || rIf
.data
.ifs
.size() )
792 "ifeq (\"$(%s)\",\"%s\")\n",
793 rIf
.property
.c_str(),
795 GenerateObjectMacros (
808 MingwModuleHandler::GenerateGccCommand (
809 const string
& sourceFilename
,
811 const string
& cflagsMacro
)
813 string dependencies
= sourceFilename
;
814 if ( module
.pch
&& use_pch
)
815 dependencies
+= " " + module
.pch
->header
+ ".gch";
817 /* WIDL generated headers may be used */
818 dependencies
+= " " + GetLinkingDependenciesMacro ();
819 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
821 string objectFilename
= GetObjectFilename (
822 sourceFilename
, &clean_files
);
825 objectFilename
.c_str (),
826 dependencies
.c_str (),
827 GetDirectory ( objectFilename
).c_str () );
828 fprintf ( fMakefile
, "\t$(ECHO_CC)\n" );
830 "\t%s -c $< -o $@ %s\n",
832 cflagsMacro
.c_str () );
836 MingwModuleHandler::GenerateGccAssemblerCommand (
837 const string
& sourceFilename
,
839 const string
& cflagsMacro
)
841 string dependencies
= sourceFilename
;
842 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
843 string objectFilename
= GetObjectFilename (
844 sourceFilename
, &clean_files
);
847 objectFilename
.c_str (),
848 dependencies
.c_str (),
849 GetDirectory ( objectFilename
).c_str () );
850 fprintf ( fMakefile
, "\t$(ECHO_GAS)\n" );
852 "\t%s -x assembler-with-cpp -c $< -o $@ -D__ASM__ %s\n",
854 cflagsMacro
.c_str () );
858 MingwModuleHandler::GenerateNasmCommand (
859 const string
& sourceFilename
,
860 const string
& nasmflagsMacro
)
862 string dependencies
= sourceFilename
;
863 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
864 string objectFilename
= GetObjectFilename (
865 sourceFilename
, &clean_files
);
868 objectFilename
.c_str (),
869 dependencies
.c_str (),
870 GetDirectory ( objectFilename
).c_str () );
871 fprintf ( fMakefile
, "\t$(ECHO_NASM)\n" );
873 "\t%s -f win32 $< -o $@ %s\n",
875 nasmflagsMacro
.c_str () );
879 MingwModuleHandler::GenerateWindresCommand (
880 const string
& sourceFilename
,
881 const string
& windresflagsMacro
)
883 string dependencies
= sourceFilename
;
884 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
885 string objectFilename
=
886 GetObjectFilename ( sourceFilename
, &clean_files
);
887 string rciFilename
= ros_temp
+ module
.name
+ ".rci.tmp";
888 string resFilename
= ros_temp
+ module
.name
+ ".res.tmp";
892 "%s: %s $(WRC_TARGET) | %s\n",
893 objectFilename
.c_str (),
894 dependencies
.c_str (),
895 GetDirectory ( objectFilename
).c_str () );
896 fprintf ( fMakefile
, "\t$(ECHO_WRC)\n" );
898 "\t${gcc} -xc -E -DRC_INVOKED ${%s} %s > %s\n",
899 windresflagsMacro
.c_str (),
900 sourceFilename
.c_str (),
901 rciFilename
.c_str () );
903 "\t$(Q)$(WRC_TARGET) ${%s} %s %s\n",
904 windresflagsMacro
.c_str (),
905 rciFilename
.c_str (),
906 resFilename
.c_str () );
908 "\t-@${rm} %s 2>$(NUL)\n",
909 rciFilename
.c_str () );
911 "\t${windres} %s -o $@\n",
912 resFilename
.c_str () );
914 "\t-@${rm} %s 2>$(NUL)\n",
915 resFilename
.c_str () );
920 "%s: %s $(WRC_TARGET) | %s\n",
921 objectFilename
.c_str (),
922 dependencies
.c_str (),
923 GetDirectory ( objectFilename
).c_str () );
924 fprintf ( fMakefile
, "\t$(ECHO_WRC)\n" );
926 "\t${windres} $(%s) %s -o $@\n",
927 windresflagsMacro
.c_str (),
928 sourceFilename
.c_str () );
933 MingwModuleHandler::GenerateWinebuildCommands (
934 const string
& sourceFilename
)
936 string dependencies
= sourceFilename
;
937 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
939 string basename
= GetBasename ( sourceFilename
);
940 string def_file
= PassThruCacheDirectory (
941 basename
+ ".spec.def",
942 backend
->intermediateDirectory
);
943 CLEAN_FILE(def_file
);
945 string stub_file
= PassThruCacheDirectory (
946 basename
+ ".stubs.c",
947 backend
->intermediateDirectory
);
948 CLEAN_FILE(stub_file
)
951 "%s: %s $(WINEBUILD_TARGET)\n",
953 dependencies
.c_str () );
954 fprintf ( fMakefile
, "\t$(ECHO_WINEBLD)\n" );
956 "\t%s --def=%s -o %s\n",
957 "$(Q)$(WINEBUILD_TARGET)",
958 sourceFilename
.c_str (),
962 "%s: %s $(WINEBUILD_TARGET)\n",
964 sourceFilename
.c_str () );
965 fprintf ( fMakefile
, "\t$(ECHO_WINEBLD)\n" );
967 "\t%s --pedll=%s -o %s\n",
968 "$(Q)$(WINEBUILD_TARGET)",
969 sourceFilename
.c_str (),
970 stub_file
.c_str () );
974 MingwModuleHandler::GetWidlFlags ( const File
& file
)
976 return file
.switches
;
980 MingwModuleHandler::GenerateWidlCommandsServer (
982 const string
& widlflagsMacro
)
984 string dependencies
= file
.name
;
985 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
987 string basename
= GetBasename ( file
.name
);
989 /*string generatedHeaderFilename = PassThruCacheDirectory (
991 backend->intermediateDirectory );
992 CLEAN_FILE(generatedHeaderFilename);
994 string generatedHeaderFilename
= basename
+ "_s.h";
995 CLEAN_FILE(generatedHeaderFilename
);
997 string generatedServerFilename
= PassThruCacheDirectory (
999 backend
->intermediateDirectory
);
1000 CLEAN_FILE(generatedServerFilename
);
1002 fprintf ( fMakefile
,
1003 "%s %s: %s $(WIDL_TARGET) | %s\n",
1004 generatedServerFilename
.c_str (),
1005 generatedHeaderFilename
.c_str (),
1006 dependencies
.c_str (),
1007 GetDirectory ( generatedServerFilename
).c_str () );
1008 fprintf ( fMakefile
, "\t$(ECHO_WIDL)\n" );
1009 fprintf ( fMakefile
,
1010 "\t%s %s %s -h -H %s -s -S %s %s\n",
1011 "$(Q)$(WIDL_TARGET)",
1012 GetWidlFlags ( file
).c_str (),
1013 widlflagsMacro
.c_str (),
1014 generatedHeaderFilename
.c_str (),
1015 generatedServerFilename
.c_str (),
1016 file
.name
.c_str () );
1020 MingwModuleHandler::GenerateWidlCommandsClient (
1022 const string
& widlflagsMacro
)
1024 string dependencies
= file
.name
;
1025 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
1027 string basename
= GetBasename ( file
.name
);
1029 /*string generatedHeaderFilename = PassThruCacheDirectory (
1031 backend->intermediateDirectory );
1032 CLEAN_FILE(generatedHeaderFilename);
1034 string generatedHeaderFilename
= basename
+ "_c.h";
1035 CLEAN_FILE(generatedHeaderFilename
);
1037 string generatedClientFilename
= PassThruCacheDirectory (
1039 backend
->intermediateDirectory
);
1040 CLEAN_FILE(generatedClientFilename
);
1042 fprintf ( fMakefile
,
1043 "%s %s: %s $(WIDL_TARGET) | %s\n",
1044 generatedClientFilename
.c_str (),
1045 generatedHeaderFilename
.c_str (),
1046 dependencies
.c_str (),
1047 GetDirectory ( generatedClientFilename
).c_str () );
1048 fprintf ( fMakefile
, "\t$(ECHO_WIDL)\n" );
1049 fprintf ( fMakefile
,
1050 "\t%s %s %s -h -H %s -c -C %s %s\n",
1051 "$(Q)$(WIDL_TARGET)",
1052 GetWidlFlags ( file
).c_str (),
1053 widlflagsMacro
.c_str (),
1054 generatedHeaderFilename
.c_str (),
1055 generatedClientFilename
.c_str (),
1056 file
.name
.c_str () );
1060 MingwModuleHandler::GenerateWidlCommands (
1062 const string
& widlflagsMacro
)
1064 if ( module
.type
== RpcServer
)
1065 GenerateWidlCommandsServer ( file
,
1068 GenerateWidlCommandsClient ( file
,
1073 MingwModuleHandler::GenerateCommands (
1077 const string
& cflagsMacro
,
1078 const string
& nasmflagsMacro
,
1079 const string
& windresflagsMacro
,
1080 const string
& widlflagsMacro
)
1082 string extension
= GetExtension ( file
.name
);
1083 if ( extension
== ".c" || extension
== ".C" )
1085 GenerateGccCommand ( file
.name
,
1090 else if ( extension
== ".cc" || extension
== ".CC" ||
1091 extension
== ".cpp" || extension
== ".CPP" ||
1092 extension
== ".cxx" || extension
== ".CXX" )
1094 GenerateGccCommand ( file
.name
,
1099 else if ( extension
== ".s" || extension
== ".S" )
1101 GenerateGccAssemblerCommand ( file
.name
,
1106 else if ( extension
== ".asm" || extension
== ".ASM" )
1108 GenerateNasmCommand ( file
.name
,
1112 else if ( extension
== ".rc" || extension
== ".RC" )
1114 GenerateWindresCommand ( file
.name
,
1115 windresflagsMacro
);
1118 else if ( extension
== ".spec" || extension
== ".SPEC" )
1120 GenerateWinebuildCommands ( file
.name
);
1121 GenerateGccCommand ( GetActualSourceFilename ( file
.name
),
1126 else if ( extension
== ".idl" || extension
== ".IDL" )
1128 GenerateWidlCommands ( file
,
1130 GenerateGccCommand ( GetActualSourceFilename ( file
.name
),
1136 throw InvalidOperationException ( __FILE__
,
1138 "Unsupported filename extension '%s' in file '%s'",
1140 file
.name
.c_str () );
1144 MingwModuleHandler::GenerateBuildMapCode ()
1146 fprintf ( fMakefile
,
1147 "ifeq ($(ROS_BUILDMAP),full)\n" );
1149 string mapFilename
= PassThruCacheDirectory (
1150 GetBasename ( module
.GetPath () ) + ".map",
1151 backend
->outputDirectory
);
1152 CLEAN_FILE ( mapFilename
);
1154 fprintf ( fMakefile
,
1155 "\t$(ECHO_OBJDUMP)\n" );
1156 fprintf ( fMakefile
,
1157 "\t$(Q)${objdump} -d -S $@ > %s\n",
1158 mapFilename
.c_str () );
1160 fprintf ( fMakefile
,
1162 fprintf ( fMakefile
,
1163 "ifeq ($(ROS_BUILDMAP),yes)\n" );
1165 fprintf ( fMakefile
,
1167 fprintf ( fMakefile
,
1168 "\t$(Q)${nm} --numeric-sort $@ > %s\n",
1169 mapFilename
.c_str () );
1171 fprintf ( fMakefile
,
1174 fprintf ( fMakefile
,
1179 MingwModuleHandler::GenerateBuildNonSymbolStrippedCode ()
1181 fprintf ( fMakefile
,
1182 "ifeq ($(ROS_BUILDNOSTRIP),yes)\n" );
1184 string filename
= module
.GetPath ();
1185 string outputFilename
= PassThruCacheDirectory (
1187 backend
->outputDirectory
);
1188 string nostripFilename
= PassThruCacheDirectory (
1189 GetBasename ( filename
) + ".nostrip" + GetExtension ( filename
),
1190 backend
->outputDirectory
);
1191 CLEAN_FILE ( nostripFilename
);
1193 fprintf ( fMakefile
,
1195 fprintf ( fMakefile
,
1196 "\t${cp} %s %s 1>$(NUL)\n",
1197 outputFilename
.c_str (),
1198 nostripFilename
.c_str () );
1200 fprintf ( fMakefile
,
1205 MergeStringVector ( const vector
<string
>& input
,
1206 vector
<string
>& output
)
1210 int wrap_count
= -1;
1211 for ( size_t i
= 0; i
< input
.size (); i
++ )
1213 if ( input
[i
].size () == 0 )
1215 if ( wrap_count
++ == wrap_at
)
1217 output
.push_back ( s
);
1221 else if ( s
.size () > 0)
1225 if ( s
.length () > 0 )
1226 output
.push_back ( s
);
1230 MingwModuleHandler::GetObjectsVector ( const IfableData
& data
,
1231 vector
<string
>& objectFiles
) const
1233 for ( size_t i
= 0; i
< data
.files
.size (); i
++ )
1235 File
& file
= *data
.files
[i
];
1236 objectFiles
.push_back ( GetObjectFilename ( file
.name
, NULL
) );
1241 MingwModuleHandler::GenerateCleanObjectsAsYouGoCode () const
1243 if ( backend
->cleanAsYouGo
)
1245 vector
<string
> objectFiles
;
1246 GetObjectsVector ( module
.non_if_data
,
1248 vector
<string
> lines
;
1249 MergeStringVector ( objectFiles
,
1251 for ( size_t i
= 0; i
< lines
.size (); i
++ )
1253 fprintf ( fMakefile
,
1254 "\t-@${rm} %s 2>$(NUL)\n",
1255 lines
[i
].c_str () );
1261 MingwModuleHandler::GenerateLinkerCommand (
1262 const string
& dependencies
,
1263 const string
& linker
,
1264 const string
& linkerParameters
,
1265 const string
& objectsMacro
,
1266 const string
& libsMacro
)
1268 string
target ( GetTargetMacro ( module
) );
1269 string
target_folder ( GetDirectory ( GetTargetFilename ( module
, NULL
) ) );
1271 fprintf ( fMakefile
,
1272 "%s: %s $(RSYM_TARGET) | %s\n",
1274 dependencies
.c_str (),
1275 target_folder
.c_str () );
1276 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
1277 string
targetName ( module
.GetTargetName () );
1279 if ( module
.IsDLL () )
1281 string base_tmp
= ros_temp
+ module
.name
+ ".base.tmp";
1282 CLEAN_FILE ( base_tmp
);
1283 string junk_tmp
= ros_temp
+ module
.name
+ ".junk.tmp";
1284 CLEAN_FILE ( junk_tmp
);
1285 string temp_exp
= ros_temp
+ module
.name
+ ".temp.exp";
1286 CLEAN_FILE ( temp_exp
);
1287 string def_file
= GetDefinitionFilename ();
1289 fprintf ( fMakefile
,
1290 "\t%s %s -Wl,--base-file,%s -o %s %s %s %s\n",
1292 linkerParameters
.c_str (),
1295 objectsMacro
.c_str (),
1297 GetLinkerMacro ().c_str () );
1299 fprintf ( fMakefile
,
1300 "\t-@${rm} %s 2>$(NUL)\n",
1301 junk_tmp
.c_str () );
1303 string killAt
= module
.mangledSymbols
? "" : "--kill-at";
1304 fprintf ( fMakefile
,
1305 "\t${dlltool} --dllname %s --base-file %s --def %s --output-exp %s %s\n",
1306 targetName
.c_str (),
1312 fprintf ( fMakefile
,
1313 "\t-@${rm} %s 2>$(NUL)\n",
1314 base_tmp
.c_str () );
1316 fprintf ( fMakefile
,
1317 "\t%s %s %s -o %s %s %s %s\n",
1319 linkerParameters
.c_str (),
1322 objectsMacro
.c_str (),
1324 GetLinkerMacro ().c_str () );
1326 fprintf ( fMakefile
,
1327 "\t-@${rm} %s 2>$(NUL)\n",
1328 temp_exp
.c_str () );
1330 GenerateCleanObjectsAsYouGoCode ();
1332 GenerateBuildMapCode ();
1334 GenerateBuildNonSymbolStrippedCode ();
1336 fprintf ( fMakefile
,
1337 "\t$(ECHO_RSYM)\n" );
1338 fprintf ( fMakefile
,
1339 "\t$(Q)$(RSYM_TARGET) $@ $@\n\n" );
1343 fprintf ( fMakefile
,
1344 "\t%s %s -o %s %s %s %s\n",
1346 linkerParameters
.c_str (),
1348 objectsMacro
.c_str (),
1350 GetLinkerMacro ().c_str () );
1352 GenerateCleanObjectsAsYouGoCode ();
1357 MingwModuleHandler::GeneratePhonyTarget() const
1359 string
targetMacro ( GetTargetMacro(module
) );
1360 fprintf ( fMakefile
, ".PHONY: %s\n\n",
1361 targetMacro
.c_str ());
1362 fprintf ( fMakefile
, "%s: | %s\n",
1363 targetMacro
.c_str (),
1364 GetDirectory(GetTargetFilename(module
,NULL
)).c_str () );
1368 MingwModuleHandler::GenerateObjectFileTargets (
1369 const IfableData
& data
,
1372 const string
& cflagsMacro
,
1373 const string
& nasmflagsMacro
,
1374 const string
& windresflagsMacro
,
1375 const string
& widlflagsMacro
)
1379 const vector
<File
*>& files
= data
.files
;
1380 for ( i
= 0; i
< files
.size (); i
++ )
1382 GenerateCommands ( *files
[i
],
1389 fprintf ( fMakefile
,
1393 const vector
<If
*>& ifs
= data
.ifs
;
1394 for ( i
= 0; i
< ifs
.size(); i
++ )
1396 GenerateObjectFileTargets ( ifs
[i
]->data
,
1407 MingwModuleHandler::GenerateObjectFileTargets (
1410 const string
& cflagsMacro
,
1411 const string
& nasmflagsMacro
,
1412 const string
& windresflagsMacro
,
1413 const string
& widlflagsMacro
)
1417 const string
& pch_file
= module
.pch
->header
;
1418 string gch_file
= pch_file
+ ".gch";
1419 CLEAN_FILE(gch_file
);
1427 fprintf ( fMakefile
, "\t$(ECHO_PCH)\n" );
1430 "\t%s -o %s %s -g %s\n\n",
1431 ( module
.cplusplus
? cppc
.c_str() : cc
.c_str() ),
1433 cflagsMacro
.c_str(),
1438 GenerateObjectFileTargets ( module
.non_if_data
,
1445 fprintf ( fMakefile
, "\n" );
1449 MingwModuleHandler::GenerateArchiveTarget ( const string
& ar
,
1450 const string
& objs_macro
) const
1452 string
archiveFilename ( GetModuleArchiveFilename () );
1454 fprintf ( fMakefile
,
1456 archiveFilename
.c_str (),
1457 objs_macro
.c_str (),
1458 GetDirectory(archiveFilename
).c_str() );
1460 fprintf ( fMakefile
, "\t$(ECHO_AR)\n" );
1462 fprintf ( fMakefile
,
1465 objs_macro
.c_str ());
1467 GenerateCleanObjectsAsYouGoCode ();
1469 fprintf ( fMakefile
, "\n" );
1471 return archiveFilename
;
1475 MingwModuleHandler::GetCFlagsMacro () const
1477 return ssprintf ( "$(%s_CFLAGS)",
1478 module
.name
.c_str () );
1482 MingwModuleHandler::GetObjectsMacro ( const Module
& module
)
1484 return ssprintf ( "$(%s_OBJS)",
1485 module
.name
.c_str () );
1489 MingwModuleHandler::GetLinkingDependenciesMacro () const
1491 return ssprintf ( "$(%s_LINKDEPS)", module
.name
.c_str () );
1495 MingwModuleHandler::GetLibsMacro () const
1497 return ssprintf ( "$(%s_LIBS)", module
.name
.c_str () );
1501 MingwModuleHandler::GetLinkerMacro () const
1503 return ssprintf ( "$(%s_LFLAGS)",
1504 module
.name
.c_str () );
1508 MingwModuleHandler::GetModuleTargets ( const Module
& module
)
1510 if ( ReferenceObjects ( module
) )
1511 return GetObjectsMacro ( module
);
1513 return GetTargetFilename ( module
, NULL
);
1517 MingwModuleHandler::GenerateObjectMacro ()
1519 objectsMacro
= ssprintf ("%s_OBJS", module
.name
.c_str ());
1521 GenerateObjectMacros (
1524 &module
.compilerFlags
,
1525 &module
.linkerFlags
);
1527 // future references to the macro will be to get its values
1528 objectsMacro
= ssprintf ("$(%s)", objectsMacro
.c_str ());
1532 MingwModuleHandler::GenerateTargetMacro ()
1534 fprintf ( fMakefile
,
1536 GetTargetMacro ( module
, false ).c_str (),
1537 GetModuleTargets ( module
).c_str () );
1541 MingwModuleHandler::GenerateOtherMacros ()
1543 cflagsMacro
= ssprintf ("%s_CFLAGS", module
.name
.c_str ());
1544 nasmflagsMacro
= ssprintf ("%s_NASMFLAGS", module
.name
.c_str ());
1545 windresflagsMacro
= ssprintf ("%s_RCFLAGS", module
.name
.c_str ());
1546 widlflagsMacro
= ssprintf ("%s_WIDLFLAGS", module
.name
.c_str ());
1547 linkerflagsMacro
= ssprintf ("%s_LFLAGS", module
.name
.c_str ());
1548 libsMacro
= ssprintf("%s_LIBS", module
.name
.c_str ());
1549 linkDepsMacro
= ssprintf ("%s_LINKDEPS", module
.name
.c_str ());
1554 &module
.compilerFlags
,
1555 &module
.linkerFlags
);
1557 if ( module
.importLibrary
)
1560 const vector
<File
*>& files
= module
.non_if_data
.files
;
1561 for ( size_t i
= 0; i
< files
.size (); i
++ )
1563 File
& file
= *files
[i
];
1564 string extension
= GetExtension ( file
.name
);
1565 if ( extension
== ".spec" || extension
== ".SPEC" )
1566 GetSpecObjectDependencies ( s
, file
.name
);
1568 if ( s
.size () > 0 )
1573 linkDepsMacro
.c_str() );
1574 for ( size_t i
= 0; i
< s
.size(); i
++ )
1575 fprintf ( fMakefile
,
1578 fprintf ( fMakefile
, "\n" );
1582 string globalCflags
= "-g";
1583 if ( backend
->usePipe
)
1584 globalCflags
+= " -pipe";
1585 if ( !module
.enableWarnings
)
1586 globalCflags
+= " -Werror";
1590 "%s += $(PROJECT_CFLAGS) %s\n",
1591 cflagsMacro
.c_str (),
1592 globalCflags
.c_str () );
1596 "%s += $(PROJECT_RCFLAGS)\n",
1597 windresflagsMacro
.c_str () );
1601 "%s += $(PROJECT_WIDLFLAGS)\n",
1602 widlflagsMacro
.c_str () );
1606 "%s_LFLAGS += $(PROJECT_LFLAGS) -g\n",
1607 module
.name
.c_str () );
1612 linkDepsMacro
.c_str (),
1613 libsMacro
.c_str () );
1615 string cflags
= TypeSpecificCFlags();
1616 if ( cflags
.size() > 0 )
1618 fprintf ( fMakefile
,
1620 cflagsMacro
.c_str (),
1624 string nasmflags
= TypeSpecificNasmFlags();
1625 if ( nasmflags
.size () > 0 )
1627 fprintf ( fMakefile
,
1629 nasmflagsMacro
.c_str (),
1630 nasmflags
.c_str () );
1633 string linkerflags
= TypeSpecificLinkerFlags();
1634 if ( linkerflags
.size() > 0 )
1636 fprintf ( fMakefile
,
1638 linkerflagsMacro
.c_str (),
1639 linkerflags
.c_str () );
1642 fprintf ( fMakefile
, "\n\n" );
1644 // future references to the macros will be to get their values
1645 cflagsMacro
= ssprintf ("$(%s)", cflagsMacro
.c_str ());
1646 nasmflagsMacro
= ssprintf ("$(%s)", nasmflagsMacro
.c_str ());
1647 widlflagsMacro
= ssprintf ("$(%s)", widlflagsMacro
.c_str ());
1651 MingwModuleHandler::GenerateRules ()
1653 string cc
= ( module
.host
== HostTrue
? "${host_gcc}" : "${gcc}" );
1654 string cppc
= ( module
.host
== HostTrue
? "${host_gpp}" : "${gpp}" );
1655 string ar
= ( module
.host
== HostTrue
? "${host_ar}" : "${ar}" );
1657 string targetMacro
= GetTargetMacro ( module
);
1659 CLEAN_FILE ( targetMacro
);
1661 // generate phony target for module name
1662 fprintf ( fMakefile
, ".PHONY: %s\n",
1663 module
.name
.c_str () );
1664 fprintf ( fMakefile
, "%s: %s\n\n",
1665 module
.name
.c_str (),
1666 GetTargetMacro ( module
).c_str () );
1668 if ( !ReferenceObjects ( module
) )
1670 string
ar_target ( GenerateArchiveTarget ( ar
, objectsMacro
) );
1671 if ( targetMacro
!= ar_target
)
1673 CLEAN_FILE ( ar_target
);
1677 GenerateObjectFileTargets ( cc
,
1686 MingwModuleHandler::GetInvocationDependencies (
1687 const Module
& module
,
1688 string_list
& dependencies
)
1690 for ( size_t i
= 0; i
< module
.invocations
.size (); i
++ )
1692 Invoke
& invoke
= *module
.invocations
[i
];
1693 if ( invoke
.invokeModule
== &module
)
1694 /* Protect against circular dependencies */
1696 invoke
.GetTargets ( dependencies
);
1701 MingwModuleHandler::GenerateInvocations () const
1703 if ( module
.invocations
.size () == 0 )
1706 size_t iend
= module
.invocations
.size ();
1707 for ( size_t i
= 0; i
< iend
; i
++ )
1709 const Invoke
& invoke
= *module
.invocations
[i
];
1711 if ( invoke
.invokeModule
->type
!= BuildTool
)
1713 throw InvalidBuildFileException ( module
.node
.location
,
1714 "Only modules of type buildtool can be invoked." );
1717 string invokeTarget
= module
.GetInvocationTarget ( i
);
1718 string_list invoke_targets
;
1719 assert ( invoke_targets
.size() );
1720 invoke
.GetTargets ( invoke_targets
);
1721 fprintf ( fMakefile
,
1723 invokeTarget
.c_str () );
1724 fprintf ( fMakefile
,
1726 invokeTarget
.c_str () );
1727 size_t j
, jend
= invoke_targets
.size();
1728 for ( j
= 0; j
< jend
; j
++ )
1730 fprintf ( fMakefile
,
1732 invoke_targets
[i
].c_str () );
1734 fprintf ( fMakefile
, "\n\n%s", invoke_targets
[0].c_str () );
1735 for ( j
= 1; j
< jend
; j
++ )
1736 fprintf ( fMakefile
,
1738 invoke_targets
[i
].c_str () );
1739 fprintf ( fMakefile
,
1741 NormalizeFilename ( invoke
.invokeModule
->GetPath () ).c_str () );
1742 fprintf ( fMakefile
, "\t$(ECHO_INVOKE)\n" );
1743 fprintf ( fMakefile
,
1745 NormalizeFilename ( invoke
.invokeModule
->GetPath () ).c_str (),
1746 invoke
.GetParameters ().c_str () );
1751 MingwModuleHandler::GetPreconditionDependenciesName () const
1753 return module
.name
+ "_precondition";
1757 MingwModuleHandler::GetDefaultDependencies (
1758 string_list
& dependencies
) const
1760 /* Avoid circular dependency */
1761 if ( module
.type
!= BuildTool
1762 && module
.name
!= "zlib"
1763 && module
.name
!= "hostzlib" )
1765 dependencies
.push_back ( "$(INIT)" );
1769 MingwModuleHandler::GeneratePreconditionDependencies ()
1771 string preconditionDependenciesName
= GetPreconditionDependenciesName ();
1772 string_list sourceFilenames
;
1773 GetSourceFilenamesWithoutGeneratedFiles ( sourceFilenames
);
1774 string_list dependencies
;
1775 GetDefaultDependencies ( dependencies
);
1776 GetModuleDependencies ( dependencies
);
1778 GetInvocationDependencies ( module
, dependencies
);
1780 if ( dependencies
.size() )
1782 fprintf ( fMakefile
,
1784 preconditionDependenciesName
.c_str () );
1785 for ( size_t i
= 0; i
< dependencies
.size(); i
++ )
1786 fprintf ( fMakefile
,
1788 dependencies
[i
].c_str () );
1789 fprintf ( fMakefile
, "\n\n" );
1792 for ( size_t i
= 0; i
< sourceFilenames
.size(); i
++ )
1794 fprintf ( fMakefile
,
1796 sourceFilenames
[i
].c_str(),
1797 preconditionDependenciesName
.c_str ());
1799 fprintf ( fMakefile
, "\n" );
1803 MingwModuleHandler::IsWineModule () const
1805 if ( module
.importLibrary
== NULL
)
1808 size_t index
= module
.importLibrary
->definition
.rfind ( ".spec.def" );
1809 return ( index
!= string::npos
);
1813 MingwModuleHandler::GetDefinitionFilename () const
1815 if ( module
.importLibrary
!= NULL
)
1817 string defFilename
= module
.GetBasePath () + SSEP
+ module
.importLibrary
->definition
;
1818 if ( IsWineModule () )
1819 return PassThruCacheDirectory ( NormalizeFilename ( defFilename
),
1820 backend
->intermediateDirectory
);
1825 return "tools" SSEP
"rbuild" SSEP
"empty.def";
1829 MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ()
1831 if ( module
.importLibrary
!= NULL
)
1833 string
library_target (
1834 GetImportLibraryFilename ( module
, &clean_files
) );
1837 GetDefinitionDependencies ( deps
);
1839 fprintf ( fMakefile
, "# IMPORT LIBRARY RULE:\n" );
1841 fprintf ( fMakefile
, "%s:",
1842 library_target
.c_str () );
1844 size_t i
, iend
= deps
.size();
1845 for ( i
= 0; i
< iend
; i
++ )
1846 fprintf ( fMakefile
, " %s",
1849 fprintf ( fMakefile
, " | %s\n",
1850 GetDirectory ( GetTargetFilename ( module
, NULL
) ).c_str () );
1852 fprintf ( fMakefile
, "\t$(ECHO_DLLTOOL)\n" );
1854 string killAt
= module
.mangledSymbols
? "" : "--kill-at";
1855 fprintf ( fMakefile
,
1856 "\t${dlltool} --dllname %s --def %s --output-lib %s %s\n\n",
1857 module
.GetTargetName ().c_str (),
1858 GetDefinitionFilename ().c_str (),
1859 library_target
.c_str (),
1865 MingwModuleHandler::GetSpecObjectDependencies (
1866 string_list
& dependencies
,
1867 const string
& filename
) const
1869 string basename
= GetBasename ( filename
);
1870 string defDependency
= PassThruCacheDirectory (
1871 NormalizeFilename ( basename
+ ".spec.def" ),
1872 backend
->intermediateDirectory
);
1873 dependencies
.push_back ( defDependency
);
1874 string stubsDependency
= PassThruCacheDirectory (
1875 NormalizeFilename ( basename
+ ".stubs.c" ),
1876 backend
->intermediateDirectory
);
1877 dependencies
.push_back ( stubsDependency
);
1881 MingwModuleHandler::GetWidlObjectDependencies (
1882 string_list
& dependencies
,
1883 const string
& filename
) const
1885 string basename
= GetBasename ( filename
);
1886 string serverDependency
= PassThruCacheDirectory (
1887 NormalizeFilename ( basename
+ "_s.c" ),
1888 backend
->intermediateDirectory
);
1889 dependencies
.push_back ( serverDependency
);
1893 MingwModuleHandler::GetDefinitionDependencies (
1894 string_list
& dependencies
) const
1896 string dkNkmLibNoFixup
= "dk/nkm/lib";
1897 const vector
<File
*>& files
= module
.non_if_data
.files
;
1898 for ( size_t i
= 0; i
< files
.size (); i
++ )
1900 File
& file
= *files
[i
];
1901 string extension
= GetExtension ( file
.name
);
1902 if ( extension
== ".spec" || extension
== ".SPEC" )
1904 GetSpecObjectDependencies ( dependencies
, file
.name
);
1906 if ( extension
== ".idl" || extension
== ".IDL" )
1908 GetWidlObjectDependencies ( dependencies
, file
.name
);
1914 MingwBuildToolModuleHandler::MingwBuildToolModuleHandler ( const Module
& module_
)
1915 : MingwModuleHandler ( module_
)
1920 MingwBuildToolModuleHandler::Process ()
1922 GenerateBuildToolModuleTarget ();
1926 MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ()
1928 string
targetMacro ( GetTargetMacro (module
) );
1929 string objectsMacro
= GetObjectsMacro ( module
);
1930 string linkDepsMacro
= GetLinkingDependenciesMacro ();
1931 string libsMacro
= GetLibsMacro ();
1936 if ( module
.cplusplus
)
1937 linker
= "${host_gpp}";
1939 linker
= "${host_gcc}";
1941 fprintf ( fMakefile
, "%s: %s %s | %s\n",
1942 targetMacro
.c_str (),
1943 objectsMacro
.c_str (),
1944 linkDepsMacro
.c_str (),
1945 GetDirectory(GetTargetFilename(module
,NULL
)).c_str () );
1946 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
1947 fprintf ( fMakefile
,
1948 "\t%s %s -o $@ %s %s\n\n",
1950 GetLinkerMacro ().c_str (),
1951 objectsMacro
.c_str (),
1952 libsMacro
.c_str () );
1956 MingwKernelModuleHandler::MingwKernelModuleHandler (
1957 const Module
& module_
)
1959 : MingwModuleHandler ( module_
)
1964 MingwKernelModuleHandler::Process ()
1966 GenerateKernelModuleTarget ();
1970 MingwKernelModuleHandler::GenerateKernelModuleTarget ()
1972 string
targetMacro ( GetTargetMacro ( module
) );
1973 string workingDirectory
= GetWorkingDirectory ( );
1974 string objectsMacro
= GetObjectsMacro ( module
);
1975 string linkDepsMacro
= GetLinkingDependenciesMacro ();
1976 string libsMacro
= GetLibsMacro ();
1978 GenerateImportLibraryTargetIfNeeded ();
1980 if ( module
.non_if_data
.files
.size () > 0 )
1984 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
1986 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",
1987 module
.GetBasePath ().c_str (),
1988 module
.entrypoint
.c_str (),
1989 module
.baseaddress
.c_str () );
1990 GenerateLinkerCommand ( dependencies
,
1998 GeneratePhonyTarget();
2003 MingwStaticLibraryModuleHandler::MingwStaticLibraryModuleHandler (
2004 const Module
& module_
)
2006 : MingwModuleHandler ( module_
)
2011 MingwStaticLibraryModuleHandler::Process ()
2013 GenerateStaticLibraryModuleTarget ();
2017 MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget ()
2023 MingwObjectLibraryModuleHandler::MingwObjectLibraryModuleHandler (
2024 const Module
& module_
)
2026 : MingwModuleHandler ( module_
)
2031 MingwObjectLibraryModuleHandler::Process ()
2033 GenerateObjectLibraryModuleTarget ();
2037 MingwObjectLibraryModuleHandler::GenerateObjectLibraryModuleTarget ()
2043 MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler (
2044 const Module
& module_
)
2046 : MingwModuleHandler ( module_
)
2051 MingwKernelModeDLLModuleHandler::Process ()
2053 GenerateKernelModeDLLModuleTarget ();
2057 MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ()
2059 string
targetMacro ( GetTargetMacro ( module
) );
2060 string workingDirectory
= GetWorkingDirectory ( );
2061 string objectsMacro
= GetObjectsMacro ( module
);
2062 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2063 string libsMacro
= GetLibsMacro ();
2065 GenerateImportLibraryTargetIfNeeded ();
2067 if ( module
.non_if_data
.files
.size () > 0 )
2071 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2073 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll --dll",
2074 module
.entrypoint
.c_str (),
2075 module
.baseaddress
.c_str () );
2076 GenerateLinkerCommand ( dependencies
,
2084 GeneratePhonyTarget();
2089 MingwKernelModeDriverModuleHandler::MingwKernelModeDriverModuleHandler (
2090 const Module
& module_
)
2092 : MingwModuleHandler ( module_
)
2097 MingwKernelModeDriverModuleHandler::Process ()
2099 GenerateKernelModeDriverModuleTarget ();
2104 MingwKernelModeDriverModuleHandler::GenerateKernelModeDriverModuleTarget ()
2106 string
targetMacro ( GetTargetMacro (module
) );
2107 string workingDirectory
= GetWorkingDirectory ();
2108 string objectsMacro
= GetObjectsMacro ( module
);
2109 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2110 string libsMacro
= GetLibsMacro ();
2112 GenerateImportLibraryTargetIfNeeded ();
2114 if ( module
.non_if_data
.files
.size () > 0 )
2118 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2120 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll --dll",
2121 module
.entrypoint
.c_str (),
2122 module
.baseaddress
.c_str () );
2123 GenerateLinkerCommand ( dependencies
,
2131 GeneratePhonyTarget();
2136 MingwNativeDLLModuleHandler::MingwNativeDLLModuleHandler (
2137 const Module
& module_
)
2139 : MingwModuleHandler ( module_
)
2144 MingwNativeDLLModuleHandler::Process ()
2146 GenerateNativeDLLModuleTarget ();
2150 MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ()
2152 string
targetMacro ( GetTargetMacro (module
) );
2153 string workingDirectory
= GetWorkingDirectory ( );
2154 string objectsMacro
= GetObjectsMacro ( module
);
2155 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2156 string libsMacro
= GetLibsMacro ();
2158 GenerateImportLibraryTargetIfNeeded ();
2160 if ( module
.non_if_data
.files
.size () > 0 )
2164 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2166 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",
2167 module
.entrypoint
.c_str (),
2168 module
.baseaddress
.c_str () );
2169 GenerateLinkerCommand ( dependencies
,
2177 GeneratePhonyTarget();
2182 MingwNativeCUIModuleHandler::MingwNativeCUIModuleHandler (
2183 const Module
& module_
)
2185 : MingwModuleHandler ( module_
)
2190 MingwNativeCUIModuleHandler::Process ()
2192 GenerateNativeCUIModuleTarget ();
2196 MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ()
2198 string
targetMacro ( GetTargetMacro (module
) );
2199 string workingDirectory
= GetWorkingDirectory ( );
2200 string objectsMacro
= GetObjectsMacro ( module
);
2201 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2202 string libsMacro
= GetLibsMacro ();
2204 GenerateImportLibraryTargetIfNeeded ();
2206 if ( module
.non_if_data
.files
.size () > 0 )
2210 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2212 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib",
2213 module
.entrypoint
.c_str (),
2214 module
.baseaddress
.c_str () );
2215 GenerateLinkerCommand ( dependencies
,
2223 GeneratePhonyTarget();
2228 MingwWin32DLLModuleHandler::MingwWin32DLLModuleHandler (
2229 const Module
& module_
)
2231 : MingwModuleHandler ( module_
)
2236 MingwWin32DLLModuleHandler::Process ()
2238 GenerateExtractWineDLLResourcesTarget ();
2239 GenerateWin32DLLModuleTarget ();
2243 MingwWin32DLLModuleHandler::GenerateExtractWineDLLResourcesTarget ()
2245 fprintf ( fMakefile
, ".PHONY: %s_extractresources\n\n",
2246 module
.name
.c_str () );
2247 fprintf ( fMakefile
, "%s_extractresources: $(BIN2RES_TARGET)\n",
2248 module
.name
.c_str () );
2249 const vector
<File
*>& files
= module
.non_if_data
.files
;
2250 for ( size_t i
= 0; i
< files
.size (); i
++ )
2252 File
& file
= *files
[i
];
2253 string extension
= GetExtension ( file
.name
);
2254 if ( extension
== ".rc" || extension
== ".RC" )
2256 string resource
= NormalizeFilename ( file
.name
);
2257 fprintf ( fMakefile
, "\t$(ECHO_BIN2RES)\n" );
2258 fprintf ( fMakefile
, "\t@:echo ${bin2res} -f -x %s\n",
2259 resource
.c_str () );
2262 fprintf ( fMakefile
, "\n");
2266 MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ()
2268 string
targetMacro ( GetTargetMacro (module
) );
2269 string workingDirectory
= GetWorkingDirectory ( );
2270 string objectsMacro
= GetObjectsMacro ( module
);
2271 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2272 string libsMacro
= GetLibsMacro ();
2274 GenerateImportLibraryTargetIfNeeded ();
2276 if ( module
.non_if_data
.files
.size () > 0 )
2280 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2283 if ( module
.cplusplus
)
2288 string linkerParameters
= ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -mdll --dll",
2289 module
.entrypoint
.c_str (),
2290 module
.baseaddress
.c_str () );
2291 GenerateLinkerCommand ( dependencies
,
2299 GeneratePhonyTarget();
2304 MingwWin32CUIModuleHandler::MingwWin32CUIModuleHandler (
2305 const Module
& module_
)
2307 : MingwModuleHandler ( module_
)
2312 MingwWin32CUIModuleHandler::Process ()
2314 GenerateWin32CUIModuleTarget ();
2318 MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ()
2320 string
targetMacro ( GetTargetMacro (module
) );
2321 string workingDirectory
= GetWorkingDirectory ( );
2322 string objectsMacro
= GetObjectsMacro ( module
);
2323 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2324 string libsMacro
= GetLibsMacro ();
2326 GenerateImportLibraryTargetIfNeeded ();
2328 if ( module
.non_if_data
.files
.size () > 0 )
2332 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2335 if ( module
.cplusplus
)
2340 string linkerParameters
= ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
2341 module
.entrypoint
.c_str (),
2342 module
.baseaddress
.c_str () );
2343 GenerateLinkerCommand ( dependencies
,
2351 GeneratePhonyTarget();
2356 MingwWin32GUIModuleHandler::MingwWin32GUIModuleHandler (
2357 const Module
& module_
)
2359 : MingwModuleHandler ( module_
)
2364 MingwWin32GUIModuleHandler::Process ()
2366 GenerateWin32GUIModuleTarget ();
2370 MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ()
2372 string
targetMacro ( GetTargetMacro (module
) );
2373 string workingDirectory
= GetWorkingDirectory ( );
2374 string objectsMacro
= GetObjectsMacro ( module
);
2375 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2376 string libsMacro
= GetLibsMacro ();
2378 GenerateImportLibraryTargetIfNeeded ();
2380 if ( module
.non_if_data
.files
.size () > 0 )
2384 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2387 if ( module
.cplusplus
)
2392 string linkerParameters
= ssprintf ( "-Wl,--subsystem,windows -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
2393 module
.entrypoint
.c_str (),
2394 module
.baseaddress
.c_str () );
2395 GenerateLinkerCommand ( dependencies
,
2403 GeneratePhonyTarget();
2408 MingwBootLoaderModuleHandler::MingwBootLoaderModuleHandler (
2409 const Module
& module_
)
2411 : MingwModuleHandler ( module_
)
2416 MingwBootLoaderModuleHandler::Process ()
2418 GenerateBootLoaderModuleTarget ();
2422 MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ()
2424 string
targetName ( module
.GetTargetName () );
2425 string
targetMacro ( GetTargetMacro (module
) );
2426 string workingDirectory
= GetWorkingDirectory ();
2427 string junk_tmp
= ros_temp
+ module
.name
+ ".junk.tmp";
2428 CLEAN_FILE ( junk_tmp
);
2429 string objectsMacro
= GetObjectsMacro ( module
);
2430 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2431 string libsMacro
= GetLibsMacro ();
2435 fprintf ( fMakefile
, "%s: %s %s | %s\n",
2436 targetMacro
.c_str (),
2437 objectsMacro
.c_str (),
2438 linkDepsMacro
.c_str (),
2439 GetDirectory(GetTargetFilename(module
,NULL
)).c_str () );
2441 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
2443 fprintf ( fMakefile
,
2444 "\t${ld} %s -N -Ttext=0x8000 -o %s %s %s\n",
2445 GetLinkerMacro ().c_str (),
2447 objectsMacro
.c_str (),
2448 linkDepsMacro
.c_str () );
2449 fprintf ( fMakefile
,
2450 "\t${objcopy} -O binary %s $@\n",
2451 junk_tmp
.c_str () );
2452 fprintf ( fMakefile
,
2453 "\t-@${rm} %s 2>$(NUL)\n",
2454 junk_tmp
.c_str () );
2458 MingwBootSectorModuleHandler::MingwBootSectorModuleHandler (
2459 const Module
& module_
)
2461 : MingwModuleHandler ( module_
)
2466 MingwBootSectorModuleHandler::Process ()
2468 GenerateBootSectorModuleTarget ();
2472 MingwBootSectorModuleHandler::GenerateBootSectorModuleTarget ()
2474 string objectsMacro
= GetObjectsMacro ( module
);
2478 fprintf ( fMakefile
, ".PHONY: %s\n\n",
2479 module
.name
.c_str ());
2480 fprintf ( fMakefile
,
2482 module
.name
.c_str (),
2483 objectsMacro
.c_str () );
2487 MingwIsoModuleHandler::MingwIsoModuleHandler (
2488 const Module
& module_
)
2490 : MingwModuleHandler ( module_
)
2495 MingwIsoModuleHandler::Process ()
2497 GenerateIsoModuleTarget ();
2501 MingwIsoModuleHandler::OutputBootstrapfileCopyCommands (
2502 const string
& bootcdDirectory
)
2504 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
2506 const Module
& m
= *module
.project
.modules
[i
];
2507 if ( m
.bootstrap
!= NULL
)
2509 string sourceFilename
= PassThruCacheDirectory (
2510 NormalizeFilename ( m
.GetPath () ),
2511 backend
->outputDirectory
);
2512 string
targetFilenameNoFixup ( bootcdDirectory
+ SSEP
+ m
.bootstrap
->base
+ SSEP
+ m
.bootstrap
->nameoncd
);
2513 string targetFilename
= MingwModuleHandler::PassThruCacheDirectory (
2514 NormalizeFilename ( targetFilenameNoFixup
),
2515 backend
->outputDirectory
);
2516 fprintf ( fMakefile
,
2518 fprintf ( fMakefile
,
2519 "\t${cp} %s %s 1>$(NUL)\n",
2520 sourceFilename
.c_str (),
2521 targetFilename
.c_str () );
2527 MingwIsoModuleHandler::OutputCdfileCopyCommands (
2528 const string
& bootcdDirectory
)
2530 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
2532 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
2533 string targetFilenameNoFixup
= bootcdDirectory
+ SSEP
+ cdfile
.base
+ SSEP
+ cdfile
.nameoncd
;
2534 string targetFilename
= MingwModuleHandler::PassThruCacheDirectory (
2535 NormalizeFilename ( targetFilenameNoFixup
),
2536 backend
->outputDirectory
);
2537 fprintf ( fMakefile
,
2539 fprintf ( fMakefile
,
2540 "\t${cp} %s %s 1>$(NUL)\n",
2541 cdfile
.GetPath ().c_str (),
2542 targetFilename
.c_str () );
2547 MingwIsoModuleHandler::GetBootstrapCdDirectories ( const string
& bootcdDirectory
)
2550 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
2552 const Module
& m
= *module
.project
.modules
[i
];
2553 if ( m
.bootstrap
!= NULL
)
2555 string
targetDirectory ( bootcdDirectory
+ SSEP
+ m
.bootstrap
->base
);
2556 if ( directories
.size () > 0 )
2558 directories
+= PassThruCacheDirectory (
2559 NormalizeFilename ( targetDirectory
),
2560 backend
->outputDirectory
);
2567 MingwIsoModuleHandler::GetNonModuleCdDirectories ( const string
& bootcdDirectory
)
2570 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
2572 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
2573 string
targetDirectory ( bootcdDirectory
+ SSEP
+ cdfile
.base
);
2574 if ( directories
.size () > 0 )
2576 directories
+= PassThruCacheDirectory (
2577 NormalizeFilename ( targetDirectory
),
2578 backend
->outputDirectory
);
2584 MingwIsoModuleHandler::GetCdDirectories ( const string
& bootcdDirectory
)
2586 string directories
= GetBootstrapCdDirectories ( bootcdDirectory
);
2587 directories
+= " " + GetNonModuleCdDirectories ( bootcdDirectory
);
2592 MingwIsoModuleHandler::GetBootstrapCdFiles (
2593 vector
<string
>& out
) const
2595 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
2597 const Module
& m
= *module
.project
.modules
[i
];
2598 if ( m
.bootstrap
!= NULL
)
2600 string filename
= PassThruCacheDirectory (
2601 NormalizeFilename ( m
.GetPath () ),
2602 backend
->outputDirectory
);
2603 out
.push_back ( filename
);
2609 MingwIsoModuleHandler::GetNonModuleCdFiles (
2610 vector
<string
>& out
) const
2612 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
2614 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
2615 out
.push_back ( cdfile
.GetPath () );
2620 MingwIsoModuleHandler::GetCdFiles (
2621 vector
<string
>& out
) const
2623 GetBootstrapCdFiles ( out
);
2624 GetNonModuleCdFiles ( out
);
2628 MingwIsoModuleHandler::GenerateIsoModuleTarget ()
2630 string bootcdDirectory
= "cd";
2631 string bootcd
= PassThruCacheDirectory (
2632 NormalizeFilename ( bootcdDirectory
+ SSEP
),
2633 backend
->outputDirectory
);
2634 string isoboot
= PassThruCacheDirectory (
2635 NormalizeFilename ( "boot" SSEP
"freeldr" SSEP
"bootsect" SSEP
"isoboot.o" ),
2636 backend
->outputDirectory
);
2637 string bootcdReactosNoFixup
= bootcdDirectory
+ SSEP
"reactos";
2638 string bootcdReactos
= PassThruCacheDirectory (
2639 NormalizeFilename ( bootcdReactosNoFixup
+ SSEP
),
2640 backend
->outputDirectory
);
2641 CLEAN_FILE ( bootcdReactos
);
2642 string reactosInf
= PassThruCacheDirectory (
2643 NormalizeFilename ( bootcdReactosNoFixup
+ SSEP
"reactos.inf" ),
2644 backend
->outputDirectory
);
2645 string reactosDff
= NormalizeFilename ( "bootdata" SSEP
"packages" SSEP
"reactos.dff" );
2646 string cdDirectories
= GetCdDirectories ( bootcdDirectory
);
2647 vector
<string
> vCdFiles
;
2648 GetCdFiles ( vCdFiles
);
2649 string cdFiles
= v2s ( vCdFiles
, 5 );
2651 fprintf ( fMakefile
, ".PHONY: %s\n\n",
2652 module
.name
.c_str ());
2653 fprintf ( fMakefile
,
2654 "%s: all %s %s %s %s $(CABMAN_TARGET) $(CDMAKE_TARGET)\n",
2655 module
.name
.c_str (),
2657 bootcdReactos
.c_str (),
2658 cdDirectories
.c_str (),
2660 fprintf ( fMakefile
, "\t$(ECHO_CABMAN)\n" );
2661 fprintf ( fMakefile
,
2662 "\t$(Q)$(CABMAN_TARGET) -C %s -L %s -I -P $(OUTPUT)\n",
2663 reactosDff
.c_str (),
2664 bootcdReactos
.c_str () );
2665 fprintf ( fMakefile
,
2666 "\t$(Q)$(CABMAN_TARGET) -C %s -RC %s -L %s -N -P $(OUTPUT)\n",
2667 reactosDff
.c_str (),
2668 reactosInf
.c_str (),
2669 bootcdReactos
.c_str ());
2670 fprintf ( fMakefile
,
2671 "\t-@${rm} %s 2>$(NUL)\n",
2672 reactosInf
.c_str () );
2673 OutputBootstrapfileCopyCommands ( bootcdDirectory
);
2674 OutputCdfileCopyCommands ( bootcdDirectory
);
2675 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
2676 fprintf ( fMakefile
,
2677 "\t$(Q)$(CDMAKE_TARGET) -v -m -b %s %s REACTOS ReactOS.iso\n",
2680 fprintf ( fMakefile
,
2685 MingwLiveIsoModuleHandler::MingwLiveIsoModuleHandler (
2686 const Module
& module_
)
2688 : MingwModuleHandler ( module_
)
2693 MingwLiveIsoModuleHandler::Process ()
2695 GenerateLiveIsoModuleTarget ();
2699 MingwLiveIsoModuleHandler::CreateDirectory ( const string
& directory
)
2701 string normalizedDirectory
= MingwModuleHandler::PassThruCacheDirectory (
2702 NormalizeFilename ( directory
) + SSEP
,
2703 backend
->outputDirectory
);
2707 MingwLiveIsoModuleHandler::OutputCopyCommand ( const string
& sourceFilename
,
2708 const string
& targetFilename
,
2709 const string
& targetDirectory
)
2711 string normalizedTargetFilename
= MingwModuleHandler::PassThruCacheDirectory (
2712 NormalizeFilename ( targetDirectory
+ SSEP
+ targetFilename
),
2713 backend
->outputDirectory
);
2714 fprintf ( fMakefile
,
2716 fprintf ( fMakefile
,
2717 "\t${cp} %s %s 1>$(NUL)\n",
2718 sourceFilename
.c_str (),
2719 normalizedTargetFilename
.c_str () );
2723 MingwLiveIsoModuleHandler::OutputModuleCopyCommands ( string
& livecdDirectory
,
2724 string
& reactosDirectory
)
2726 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
2728 const Module
& m
= *module
.project
.modules
[i
];
2729 if ( m
.installName
.length () > 0 )
2731 string sourceFilename
= MingwModuleHandler::PassThruCacheDirectory (
2732 NormalizeFilename ( m
.GetPath () ),
2733 backend
->outputDirectory
);
2734 OutputCopyCommand ( sourceFilename
,
2736 livecdDirectory
+ SSEP
+ reactosDirectory
+ SSEP
+ m
.installBase
);
2742 MingwLiveIsoModuleHandler::OutputNonModuleCopyCommands ( string
& livecdDirectory
,
2743 string
& reactosDirectory
)
2745 for ( size_t i
= 0; i
< module
.project
.installfiles
.size (); i
++ )
2747 const InstallFile
& installfile
= *module
.project
.installfiles
[i
];
2748 OutputCopyCommand ( installfile
.GetPath (),
2749 installfile
.newname
,
2750 livecdDirectory
+ SSEP
+ reactosDirectory
+ SSEP
+ installfile
.base
);
2755 MingwLiveIsoModuleHandler::OutputProfilesDirectoryCommands ( string
& livecdDirectory
)
2757 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" );
2758 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" SSEP
"All Users") ;
2759 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" SSEP
"All Users" SSEP
"Desktop" );
2760 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" SSEP
"Default User" );
2761 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" SSEP
"Default User" SSEP
"Desktop" );
2762 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" SSEP
"Default User" SSEP
"My Documents" );
2764 string livecdIni
= "bootdata" SSEP
"livecd.ini";
2765 OutputCopyCommand ( livecdIni
,
2771 MingwLiveIsoModuleHandler::OutputLoaderCommands ( string
& livecdDirectory
)
2773 string freeldr
= PassThruCacheDirectory (
2774 NormalizeFilename ( "boot" SSEP
"freeldr" SSEP
"freeldr" SSEP
"freeldr.sys" ),
2775 backend
->outputDirectory
);
2776 CreateDirectory ( livecdDirectory
+ SSEP
"loader" );
2777 OutputCopyCommand ( freeldr
,
2779 livecdDirectory
+ SSEP
+ "loader" );
2783 MingwLiveIsoModuleHandler::OutputRegistryCommands ( string
& livecdDirectory
)
2785 string reactosSystem32ConfigDirectory
= NormalizeFilename (
2786 MingwModuleHandler::PassThruCacheDirectory (
2787 livecdDirectory
+ SSEP
"reactos" SSEP
"system32" SSEP
"config" SSEP
,
2788 backend
->outputDirectory
) );
2789 fprintf ( fMakefile
,
2790 "\t$(ECHO_MKHIVE)\n" );
2791 fprintf ( fMakefile
,
2792 "\t$(MKHIVE_TARGET) bootdata %s bootdata" SSEP
"livecd.inf bootdata" SSEP
"hiveinst.inf\n",
2793 reactosSystem32ConfigDirectory
.c_str () );
2797 MingwLiveIsoModuleHandler::GenerateLiveIsoModuleTarget ()
2799 string livecdDirectory
= "livecd";
2800 string livecd
= PassThruCacheDirectory (
2801 NormalizeFilename ( livecdDirectory
+ SSEP
),
2802 backend
->outputDirectory
);
2803 string isoboot
= PassThruCacheDirectory (
2804 NormalizeFilename ( "boot" SSEP
"freeldr" SSEP
"bootsect" SSEP
"isoboot.o" ),
2805 backend
->outputDirectory
);
2806 string reactosDirectory
= "reactos";
2807 string livecdReactosNoFixup
= livecdDirectory
+ SSEP
+ reactosDirectory
;
2808 string livecdReactos
= NormalizeFilename ( PassThruCacheDirectory (
2809 NormalizeFilename ( livecdReactosNoFixup
+ SSEP
),
2810 backend
->outputDirectory
) );
2811 CLEAN_FILE ( livecdReactos
);
2813 fprintf ( fMakefile
, ".PHONY: %s\n\n",
2814 module
.name
.c_str ());
2815 fprintf ( fMakefile
,
2816 "%s: all %s %s $(MKHIVE_TARGET) $(CDMAKE_TARGET)\n",
2817 module
.name
.c_str (),
2819 livecdReactos
.c_str () );
2820 OutputModuleCopyCommands ( livecdDirectory
,
2822 OutputNonModuleCopyCommands ( livecdDirectory
,
2824 OutputProfilesDirectoryCommands ( livecdDirectory
);
2825 OutputLoaderCommands ( livecdDirectory
);
2826 OutputRegistryCommands ( livecdDirectory
);
2827 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
2828 fprintf ( fMakefile
,
2829 "\t$(Q)$(CDMAKE_TARGET) -v -m -j -b %s %s REACTOS ReactOS-LiveCD.iso\n",
2832 fprintf ( fMakefile
,
2837 MingwTestModuleHandler::MingwTestModuleHandler (
2838 const Module
& module_
)
2840 : MingwModuleHandler ( module_
)
2845 MingwTestModuleHandler::Process ()
2847 GenerateTestModuleTarget ();
2851 MingwTestModuleHandler::GenerateTestModuleTarget ()
2853 string
targetMacro ( GetTargetMacro ( module
) );
2854 string workingDirectory
= GetWorkingDirectory ( );
2855 string objectsMacro
= GetObjectsMacro ( module
);
2856 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2857 string libsMacro
= GetLibsMacro ();
2859 GenerateImportLibraryTargetIfNeeded ();
2861 if ( module
.non_if_data
.files
.size () > 0 )
2865 string dependencies
= linkDepsMacro
+ " " + objectsMacro
;
2868 if ( module
.cplusplus
)
2873 string linkerParameters
= ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
2874 module
.entrypoint
.c_str (),
2875 module
.baseaddress
.c_str () );
2876 GenerateLinkerCommand ( dependencies
,
2884 GeneratePhonyTarget();
2889 MingwRpcServerModuleHandler::MingwRpcServerModuleHandler (
2890 const Module
& module_
)
2892 : MingwModuleHandler ( module_
)
2897 MingwRpcServerModuleHandler::Process ()
2902 MingwRpcClientModuleHandler::MingwRpcClientModuleHandler (
2903 const Module
& module_
)
2905 : MingwModuleHandler ( module_
)
2910 MingwRpcClientModuleHandler::Process ()