4 #include "../../rbuild.h"
6 #include "modulehandler.h"
11 #define CLEAN_FILE(f) clean_files.push_back ( f ); /*if ( module.name == "crt" ) printf ( "%s(%i): clean: %s\n", __FILE__, __LINE__, f.c_str() )*/
13 static string ros_temp
= "$(TEMPORARY)";
15 MingwModuleHandler::backend
= NULL
;
17 MingwModuleHandler::fMakefile
= NULL
;
19 MingwModuleHandler::use_pch
= false;
23 const string
& filename
,
24 const string
& prefix
)
26 if ( !prefix
.length() )
29 const char* pfilename
= filename
.c_str();
30 const char* p1
= strrchr ( pfilename
, '/' );
31 const char* p2
= strrchr ( pfilename
, '\\' );
36 out
+= string(pfilename
,p1
-pfilename
) + CSEP
;
39 out
+= prefix
+ pfilename
;
44 GetTargetMacro ( const Module
& module
, bool with_dollar
)
46 string
s ( module
.name
);
50 return ssprintf ( "$(%s)", s
.c_str() );
54 MingwModuleHandler::MingwModuleHandler (
55 const Module
& module_
)
61 MingwModuleHandler::~MingwModuleHandler()
66 MingwModuleHandler::SetBackend ( MingwBackend
* backend_
)
72 MingwModuleHandler::SetMakefile ( FILE* f
)
78 MingwModuleHandler::SetUsePch ( bool b
)
84 MingwModuleHandler::RemoveVariables ( string path
)
86 size_t i
= path
.find ( '$' );
87 if ( i
!= string::npos
)
89 size_t j
= path
.find ( ')', i
);
90 if ( j
!= string::npos
)
92 if ( j
+ 2 < path
.length () && path
[j
+ 1] == CSEP
)
93 return path
.substr ( j
+ 2);
95 return path
.substr ( j
+ 1);
102 MingwModuleHandler::PassThruCacheDirectory (
104 Directory
* directoryTree
)
106 string
directory ( GetDirectory ( RemoveVariables ( file
) ) );
107 string generatedFilesDirectory
= backend
->AddDirectoryTarget ( directory
,
109 if ( directory
.find ( generatedFilesDirectory
) != string::npos
)
110 /* This path already includes the generated files directory variable */
113 return generatedFilesDirectory
+ SSEP
+ file
;
117 MingwModuleHandler::GetTargetFilename (
118 const Module
& module
,
119 string_list
* pclean_files
)
121 string target
= PassThruCacheDirectory (
122 NormalizeFilename ( module
.GetPath () ),
123 backend
->outputDirectory
);
126 string_list
& clean_files
= *pclean_files
;
127 CLEAN_FILE ( target
);
133 MingwModuleHandler::GetImportLibraryFilename (
134 const Module
& module
,
135 string_list
* pclean_files
)
137 string target
= PassThruCacheDirectory (
138 NormalizeFilename ( module
.GetDependencyPath () ),
139 backend
->outputDirectory
);
142 string_list
& clean_files
= *pclean_files
;
143 CLEAN_FILE ( target
);
148 /*static*/ MingwModuleHandler
*
149 MingwModuleHandler::InstanciateHandler (
150 const Module
& module
,
151 MingwBackend
* backend
)
153 MingwModuleHandler
* handler
;
154 switch ( module
.type
)
157 handler
= new MingwBuildToolModuleHandler ( module
);
160 handler
= new MingwStaticLibraryModuleHandler ( module
);
163 handler
= new MingwObjectLibraryModuleHandler ( module
);
166 handler
= new MingwKernelModuleHandler ( module
);
169 handler
= new MingwNativeCUIModuleHandler ( module
);
172 handler
= new MingwWin32CUIModuleHandler ( module
);
175 handler
= new MingwWin32GUIModuleHandler ( module
);
178 handler
= new MingwKernelModeDLLModuleHandler ( module
);
181 handler
= new MingwNativeDLLModuleHandler ( module
);
184 handler
= new MingwWin32DLLModuleHandler ( module
);
186 case KernelModeDriver
:
187 handler
= new MingwKernelModeDriverModuleHandler ( module
);
190 handler
= new MingwBootLoaderModuleHandler ( module
);
193 handler
= new MingwBootSectorModuleHandler ( module
);
196 handler
= new MingwIsoModuleHandler ( module
);
199 handler
= new MingwLiveIsoModuleHandler ( module
);
202 handler
= new MingwTestModuleHandler ( module
);
205 handler
= new MingwRpcServerModuleHandler ( module
);
208 handler
= new MingwRpcClientModuleHandler ( module
);
211 throw UnknownModuleTypeException (
212 module
.node
.location
,
220 MingwModuleHandler::GetWorkingDirectory () const
226 MingwModuleHandler::GetBasename ( const string
& filename
) const
228 size_t index
= filename
.find_last_of ( '.' );
229 if ( index
!= string::npos
)
230 return filename
.substr ( 0, index
);
235 MingwModuleHandler::GetActualSourceFilename (
236 const string
& filename
) const
238 string extension
= GetExtension ( filename
);
239 if ( extension
== ".spec" || extension
== ".SPEC" )
241 string basename
= GetBasename ( filename
);
242 return PassThruCacheDirectory ( NormalizeFilename ( basename
+ ".stubs.c" ),
243 backend
->intermediateDirectory
);
245 else if ( extension
== ".idl" || extension
== ".IDL" )
247 string basename
= GetBasename ( filename
);
249 if ( module
.type
== RpcServer
)
250 newname
= basename
+ "_s.c";
252 newname
= basename
+ "_c.c";
253 return PassThruCacheDirectory ( NormalizeFilename ( newname
),
254 backend
->intermediateDirectory
);
261 MingwModuleHandler::GetModuleArchiveFilename () const
263 if ( module
.type
== StaticLibrary
)
264 return GetTargetFilename ( module
, NULL
);
265 return PassThruCacheDirectory ( ReplaceExtension (
266 NormalizeFilename ( module
.GetPath () ),
268 backend
->intermediateDirectory
);
272 MingwModuleHandler::IsGeneratedFile ( const File
& file
) const
274 string extension
= GetExtension ( file
.name
);
275 return ( extension
== ".spec" || extension
== ".SPEC" );
279 MingwModuleHandler::ReferenceObjects (
280 const Module
& module
)
282 if ( module
.type
== ObjectLibrary
)
284 if ( module
.type
== RpcServer
)
286 if ( module
.type
== RpcClient
)
292 MingwModuleHandler::GetImportLibraryDependency (
293 const Module
& importedModule
)
296 if ( ReferenceObjects ( importedModule
) )
297 dep
= GetTargetMacro ( importedModule
);
299 dep
= GetImportLibraryFilename ( importedModule
, NULL
);
304 MingwModuleHandler::GetTargets ( const Module
& dependencyModule
,
305 string_list
& targets
)
307 if ( dependencyModule
.invocations
.size () > 0 )
309 for ( size_t i
= 0; i
< dependencyModule
.invocations
.size (); i
++ )
311 Invoke
& invoke
= *dependencyModule
.invocations
[i
];
312 invoke
.GetTargets ( targets
);
316 targets
.push_back ( GetImportLibraryDependency ( dependencyModule
) );
320 MingwModuleHandler::GetModuleDependencies (
321 string_list
& dependencies
)
323 size_t iend
= module
.dependencies
.size ();
328 for ( size_t i
= 0; i
< iend
; i
++ )
330 const Dependency
& dependency
= *module
.dependencies
[i
];
331 const Module
& dependencyModule
= *dependency
.dependencyModule
;
332 GetTargets ( dependencyModule
,
335 GetDefinitionDependencies ( dependencies
);
339 MingwModuleHandler::GetSourceFilenames (
341 bool includeGeneratedFiles
) const
345 const vector
<File
*>& files
= module
.non_if_data
.files
;
346 for ( i
= 0; i
< files
.size (); i
++ )
348 if ( includeGeneratedFiles
|| !IsGeneratedFile ( *files
[i
] ) )
351 GetActualSourceFilename ( files
[i
]->name
) );
354 // intentionally make a copy so that we can append more work in
355 // the middle of processing without having to go recursive
356 vector
<If
*> v
= module
.non_if_data
.ifs
;
357 for ( i
= 0; i
< v
.size (); i
++ )
361 // check for sub-ifs to add to list
362 const vector
<If
*>& ifs
= rIf
.data
.ifs
;
363 for ( j
= 0; j
< ifs
.size (); j
++ )
364 v
.push_back ( ifs
[j
] );
365 const vector
<File
*>& files
= rIf
.data
.files
;
366 for ( j
= 0; j
< files
.size (); j
++ )
368 File
& file
= *files
[j
];
369 if ( includeGeneratedFiles
|| !IsGeneratedFile ( file
) )
372 GetActualSourceFilename ( file
.name
) );
379 MingwModuleHandler::GetSourceFilenamesWithoutGeneratedFiles (
380 string_list
& list
) const
382 GetSourceFilenames ( list
, false );
386 MingwModuleHandler::GetObjectFilename (
387 const string
& sourceFilename
,
388 string_list
* pclean_files
) const
390 Directory
* directoryTree
;
393 string extension
= GetExtension ( sourceFilename
);
394 if ( extension
== ".rc" || extension
== ".RC" )
395 newExtension
= ".coff";
396 else if ( extension
== ".spec" || extension
== ".SPEC" )
397 newExtension
= ".stubs.o";
398 else if ( extension
== ".idl" || extension
== ".IDL" )
400 if ( module
.type
== RpcServer
)
401 newExtension
= "_s.o";
403 newExtension
= "_c.o";
408 if ( module
.type
== BootSector
)
409 directoryTree
= backend
->outputDirectory
;
411 directoryTree
= backend
->intermediateDirectory
;
413 string obj_file
= PassThruCacheDirectory (
414 NormalizeFilename ( ReplaceExtension (
415 RemoveVariables ( sourceFilename
),
420 string_list
& clean_files
= *pclean_files
;
421 CLEAN_FILE ( obj_file
);
427 MingwModuleHandler::GenerateCleanTarget () const
429 if ( 0 == clean_files
.size() )
431 fprintf ( fMakefile
, ".PHONY: %s_clean\n", module
.name
.c_str() );
432 fprintf ( fMakefile
, "%s_clean:\n\t-@$(rm)", module
.name
.c_str() );
433 for ( size_t i
= 0; i
< clean_files
.size(); i
++ )
436 fprintf ( fMakefile
, " 2>$(NUL)\n\t-@$(rm)" );
437 fprintf ( fMakefile
, " %s", clean_files
[i
].c_str() );
439 fprintf ( fMakefile
, " 2>$(NUL)\n" );
440 fprintf ( fMakefile
, "clean: %s_clean\n\n", module
.name
.c_str() );
444 MingwModuleHandler::GetObjectFilenames ()
446 const vector
<File
*>& files
= module
.non_if_data
.files
;
447 if ( files
.size () == 0 )
450 string
objectFilenames ( "" );
451 for ( size_t i
= 0; i
< files
.size (); i
++ )
453 if ( objectFilenames
.size () > 0 )
454 objectFilenames
+= " ";
456 GetObjectFilename ( files
[i
]->name
, NULL
);
458 return objectFilenames
;
462 MingwModuleHandler::GenerateGccDefineParametersFromVector (
463 const vector
<Define
*>& defines
) const
466 for ( size_t i
= 0; i
< defines
.size (); i
++ )
468 Define
& define
= *defines
[i
];
469 if (parameters
.length () > 0)
472 parameters
+= define
.name
;
473 if (define
.value
.length () > 0)
476 parameters
+= define
.value
;
483 MingwModuleHandler::GenerateGccDefineParameters () const
485 string parameters
= GenerateGccDefineParametersFromVector ( module
.project
.non_if_data
.defines
);
486 string s
= GenerateGccDefineParametersFromVector ( module
.non_if_data
.defines
);
487 if ( s
.length () > 0 )
496 MingwModuleHandler::ConcatenatePaths (
498 const string
& path2
) const
500 if ( ( path1
.length () == 0 ) || ( path1
== "." ) || ( path1
== "./" ) )
502 if ( path1
[path1
.length ()] == CSEP
)
503 return path1
+ path2
;
505 return path1
+ CSEP
+ path2
;
509 MingwModuleHandler::GenerateGccIncludeParametersFromVector ( const vector
<Include
*>& includes
) const
512 for ( size_t i
= 0; i
< includes
.size (); i
++ )
514 Include
& include
= *includes
[i
];
515 if ( parameters
.length () > 0 )
517 parameters
+= "-I" + include
.directory
;
523 MingwModuleHandler::GenerateGccIncludeParameters () const
525 string parameters
= GenerateGccIncludeParametersFromVector ( module
.non_if_data
.includes
);
526 string s
= GenerateGccIncludeParametersFromVector ( module
.project
.non_if_data
.includes
);
527 if ( s
.length () > 0 )
537 MingwModuleHandler::GenerateCompilerParametersFromVector ( const vector
<CompilerFlag
*>& compilerFlags
) const
540 for ( size_t i
= 0; i
< compilerFlags
.size (); i
++ )
542 CompilerFlag
& compilerFlag
= *compilerFlags
[i
];
543 if ( parameters
.length () > 0 )
545 parameters
+= compilerFlag
.flag
;
551 MingwModuleHandler::GenerateLinkerParametersFromVector ( const vector
<LinkerFlag
*>& linkerFlags
) const
554 for ( size_t i
= 0; i
< linkerFlags
.size (); i
++ )
556 LinkerFlag
& linkerFlag
= *linkerFlags
[i
];
557 if ( parameters
.length () > 0 )
559 parameters
+= linkerFlag
.flag
;
565 MingwModuleHandler::GenerateImportLibraryDependenciesFromVector (
566 const vector
<Library
*>& libraries
)
568 string
dependencies ( "" );
570 for ( size_t i
= 0; i
< libraries
.size (); i
++ )
572 if ( wrap_count
++ == 5 )
573 dependencies
+= " \\\n\t\t", wrap_count
= 0;
574 else if ( dependencies
.size () > 0 )
576 dependencies
+= GetImportLibraryDependency ( *libraries
[i
]->imported_module
);
582 MingwModuleHandler::GenerateLinkerParameters () const
584 return GenerateLinkerParametersFromVector ( module
.linkerFlags
);
588 MingwModuleHandler::GenerateMacro (
589 const char* assignmentOperation
,
591 const IfableData
& data
,
592 const vector
<CompilerFlag
*>* compilerFlags
)
600 assignmentOperation
);
602 if ( compilerFlags
!= NULL
)
604 string compilerParameters
= GenerateCompilerParametersFromVector ( *compilerFlags
);
605 if ( compilerParameters
.size () > 0 )
610 compilerParameters
.c_str () );
614 for ( i
= 0; i
< data
.includes
.size(); i
++ )
619 data
.includes
[i
]->directory
.c_str() );
621 for ( i
= 0; i
< data
.defines
.size(); i
++ )
623 Define
& d
= *data
.defines
[i
];
628 if ( d
.value
.size() )
634 fprintf ( fMakefile
, "\n" );
638 MingwModuleHandler::GenerateMacros (
639 const char* assignmentOperation
,
640 const IfableData
& data
,
641 const vector
<CompilerFlag
*>* compilerFlags
,
642 const vector
<LinkerFlag
*>* linkerFlags
)
646 if ( data
.includes
.size () > 0 || data
.defines
.size () > 0 )
648 GenerateMacro ( assignmentOperation
,
652 GenerateMacro ( assignmentOperation
,
658 if ( linkerFlags
!= NULL
)
660 string linkerParameters
= GenerateLinkerParametersFromVector ( *linkerFlags
);
661 if ( linkerParameters
.size () > 0 )
666 linkerflagsMacro
.c_str (),
668 linkerParameters
.c_str() );
672 if ( data
.libraries
.size () > 0 )
674 string deps
= GenerateImportLibraryDependenciesFromVector ( data
.libraries
);
675 if ( deps
.size () > 0 )
686 const vector
<If
*>& ifs
= data
.ifs
;
687 for ( i
= 0; i
< ifs
.size(); i
++ )
690 if ( rIf
.data
.defines
.size()
691 || rIf
.data
.includes
.size()
692 || rIf
.data
.libraries
.size()
693 || rIf
.data
.files
.size()
694 || rIf
.data
.ifs
.size() )
698 "ifeq (\"$(%s)\",\"%s\")\n",
699 rIf
.property
.c_str(),
714 MingwModuleHandler::GenerateObjectMacros (
715 const char* assignmentOperation
,
716 const IfableData
& data
,
717 const vector
<CompilerFlag
*>* compilerFlags
,
718 const vector
<LinkerFlag
*>* linkerFlags
)
722 const vector
<File
*>& files
= data
.files
;
723 if ( files
.size () > 0 )
725 for ( i
= 0; i
< files
.size (); i
++ )
727 File
& file
= *files
[i
];
732 objectsMacro
.c_str(),
734 file
.name
, NULL
).c_str (),
735 objectsMacro
.c_str() );
741 objectsMacro
.c_str (),
742 assignmentOperation
);
743 for ( i
= 0; i
< files
.size(); i
++ )
745 File
& file
= *files
[i
];
751 ( i
%10 == 9 ? " \\\n\t" : " " ),
753 file
.name
, NULL
).c_str () );
756 fprintf ( fMakefile
, "\n" );
759 const vector
<If
*>& ifs
= data
.ifs
;
760 for ( i
= 0; i
< ifs
.size(); i
++ )
763 if ( rIf
.data
.defines
.size()
764 || rIf
.data
.includes
.size()
765 || rIf
.data
.libraries
.size()
766 || rIf
.data
.files
.size()
767 || rIf
.data
.ifs
.size() )
771 "ifeq (\"$(%s)\",\"%s\")\n",
772 rIf
.property
.c_str(),
774 GenerateObjectMacros (
787 MingwModuleHandler::GenerateGccCommand (
788 const string
& sourceFilename
,
790 const string
& cflagsMacro
)
792 string dependencies
= sourceFilename
;
793 if ( module
.pch
&& use_pch
)
794 dependencies
+= " " + module
.pch
->header
+ ".gch";
796 /* WIDL generated headers may be used */
797 dependencies
+= " " + GetLinkingDependenciesMacro ();
798 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
800 string objectFilename
= GetObjectFilename (
801 sourceFilename
, &clean_files
);
804 objectFilename
.c_str (),
805 dependencies
.c_str (),
806 GetDirectory ( objectFilename
).c_str () );
807 fprintf ( fMakefile
, "\t$(ECHO_CC)\n" );
809 "\t%s -c $< -o $@ %s\n",
811 cflagsMacro
.c_str () );
815 MingwModuleHandler::GenerateGccAssemblerCommand (
816 const string
& sourceFilename
,
818 const string
& cflagsMacro
)
820 string dependencies
= sourceFilename
;
821 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
822 string objectFilename
= GetObjectFilename (
823 sourceFilename
, &clean_files
);
826 objectFilename
.c_str (),
827 dependencies
.c_str (),
828 GetDirectory ( objectFilename
).c_str () );
829 fprintf ( fMakefile
, "\t$(ECHO_GAS)\n" );
831 "\t%s -x assembler-with-cpp -c $< -o $@ -D__ASM__ %s\n",
833 cflagsMacro
.c_str () );
837 MingwModuleHandler::GenerateNasmCommand (
838 const string
& sourceFilename
,
839 const string
& nasmflagsMacro
)
841 string dependencies
= sourceFilename
;
842 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
843 string objectFilename
= GetObjectFilename (
844 sourceFilename
, &clean_files
);
847 objectFilename
.c_str (),
848 dependencies
.c_str (),
849 GetDirectory ( objectFilename
).c_str () );
850 fprintf ( fMakefile
, "\t$(ECHO_NASM)\n" );
852 "\t%s -f win32 $< -o $@ %s\n",
854 nasmflagsMacro
.c_str () );
858 MingwModuleHandler::GenerateWindresCommand (
859 const string
& sourceFilename
,
860 const string
& windresflagsMacro
)
862 string dependencies
= sourceFilename
;
863 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
864 string objectFilename
=
865 GetObjectFilename ( sourceFilename
, &clean_files
);
866 string rciFilename
= ros_temp
+
867 ReplaceExtension ( sourceFilename
, ".rci" );
868 string resFilename
= ros_temp
+
869 ReplaceExtension ( sourceFilename
, ".res" );
873 "%s: %s $(WRC_TARGET) | %s\n",
874 objectFilename
.c_str (),
875 dependencies
.c_str (),
876 GetDirectory ( objectFilename
).c_str () );
877 fprintf ( fMakefile
, "\t$(ECHO_WRC)\n" );
879 "\t${gcc} -xc -E -DRC_INVOKED ${%s} %s > %s\n",
880 windresflagsMacro
.c_str (),
881 sourceFilename
.c_str (),
882 rciFilename
.c_str () );
884 "\t$(Q)$(WRC_TARGET) ${%s} %s %s\n",
885 windresflagsMacro
.c_str (),
886 rciFilename
.c_str (),
887 resFilename
.c_str () );
889 "\t-@${rm} %s 2>$(NUL)\n",
890 rciFilename
.c_str () );
892 "\t${windres} %s -o $@\n",
893 resFilename
.c_str () );
895 "\t-@${rm} %s 2>$(NUL)\n",
896 resFilename
.c_str () );
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${windres} $(%s) %s -o $@\n",
908 windresflagsMacro
.c_str (),
909 sourceFilename
.c_str () );
914 MingwModuleHandler::GenerateWinebuildCommands (
915 const string
& sourceFilename
)
917 string dependencies
= sourceFilename
;
918 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
920 string basename
= GetBasename ( sourceFilename
);
921 string def_file
= PassThruCacheDirectory (
922 basename
+ ".spec.def",
923 backend
->intermediateDirectory
);
924 CLEAN_FILE(def_file
);
926 string stub_file
= PassThruCacheDirectory (
927 basename
+ ".stubs.c",
928 backend
->intermediateDirectory
);
929 CLEAN_FILE(stub_file
)
932 "%s: %s $(WINEBUILD_TARGET)\n",
934 dependencies
.c_str () );
935 fprintf ( fMakefile
, "\t$(ECHO_WINEBLD)\n" );
937 "\t%s --def=%s -o %s\n",
938 "$(Q)$(WINEBUILD_TARGET)",
939 sourceFilename
.c_str (),
943 "%s: %s $(WINEBUILD_TARGET)\n",
945 sourceFilename
.c_str () );
946 fprintf ( fMakefile
, "\t$(ECHO_WINEBLD)\n" );
948 "\t%s --pedll=%s -o %s\n",
949 "$(Q)$(WINEBUILD_TARGET)",
950 sourceFilename
.c_str (),
951 stub_file
.c_str () );
955 MingwModuleHandler::GenerateWidlCommandsServer (
956 const string
& sourceFilename
,
957 const string
& widlflagsMacro
)
959 string dependencies
= sourceFilename
;
960 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
962 string basename
= GetBasename ( sourceFilename
);
964 /*string generatedHeaderFilename = PassThruCacheDirectory (
966 backend->intermediateDirectory );
967 CLEAN_FILE(generatedHeaderFilename);
969 string generatedHeaderFilename
= basename
+ "_s.h";
970 CLEAN_FILE(generatedHeaderFilename
);
972 string generatedServerFilename
= PassThruCacheDirectory (
974 backend
->intermediateDirectory
);
975 CLEAN_FILE(generatedServerFilename
);
978 "%s %s: %s $(WIDL_TARGET) | %s\n",
979 generatedServerFilename
.c_str (),
980 generatedHeaderFilename
.c_str (),
981 dependencies
.c_str (),
982 GetDirectory ( generatedServerFilename
).c_str () );
983 fprintf ( fMakefile
, "\t$(ECHO_WIDL)\n" );
985 "\t%s %s -h -H %s -s -S %s %s\n",
986 "$(Q)$(WIDL_TARGET)",
987 widlflagsMacro
.c_str (),
988 generatedHeaderFilename
.c_str (),
989 generatedServerFilename
.c_str (),
990 sourceFilename
.c_str () );
994 MingwModuleHandler::GenerateWidlCommandsClient (
995 const string
& sourceFilename
,
996 const string
& widlflagsMacro
)
998 string dependencies
= sourceFilename
;
999 dependencies
+= " " + NormalizeFilename ( module
.xmlbuildFile
);
1001 string basename
= GetBasename ( sourceFilename
);
1003 /*string generatedHeaderFilename = PassThruCacheDirectory (
1005 backend->intermediateDirectory );
1006 CLEAN_FILE(generatedHeaderFilename);
1008 string generatedHeaderFilename
= basename
+ "_c.h";
1009 CLEAN_FILE(generatedHeaderFilename
);
1011 string generatedClientFilename
= PassThruCacheDirectory (
1013 backend
->intermediateDirectory
);
1014 CLEAN_FILE(generatedClientFilename
);
1016 fprintf ( fMakefile
,
1017 "%s %s: %s $(WIDL_TARGET) | %s\n",
1018 generatedClientFilename
.c_str (),
1019 generatedHeaderFilename
.c_str (),
1020 dependencies
.c_str (),
1021 GetDirectory ( generatedClientFilename
).c_str () );
1022 fprintf ( fMakefile
, "\t$(ECHO_WIDL)\n" );
1023 fprintf ( fMakefile
,
1024 "\t%s %s -h -H %s -c -C %s %s\n",
1025 "$(Q)$(WIDL_TARGET)",
1026 widlflagsMacro
.c_str (),
1027 generatedHeaderFilename
.c_str (),
1028 generatedClientFilename
.c_str (),
1029 sourceFilename
.c_str () );
1033 MingwModuleHandler::GenerateWidlCommands (
1034 const string
& sourceFilename
,
1035 const string
& widlflagsMacro
)
1037 if ( module
.type
== RpcServer
)
1038 GenerateWidlCommandsServer ( sourceFilename
,
1041 GenerateWidlCommandsClient ( sourceFilename
,
1046 MingwModuleHandler::GenerateCommands (
1047 const string
& sourceFilename
,
1050 const string
& cflagsMacro
,
1051 const string
& nasmflagsMacro
,
1052 const string
& windresflagsMacro
,
1053 const string
& widlflagsMacro
)
1055 string extension
= GetExtension ( sourceFilename
);
1056 if ( extension
== ".c" || extension
== ".C" )
1058 GenerateGccCommand ( sourceFilename
,
1063 else if ( extension
== ".cc" || extension
== ".CC" ||
1064 extension
== ".cpp" || extension
== ".CPP" ||
1065 extension
== ".cxx" || extension
== ".CXX" )
1067 GenerateGccCommand ( sourceFilename
,
1072 else if ( extension
== ".s" || extension
== ".S" )
1074 GenerateGccAssemblerCommand ( sourceFilename
,
1079 else if ( extension
== ".asm" || extension
== ".ASM" )
1081 GenerateNasmCommand ( sourceFilename
,
1085 else if ( extension
== ".rc" || extension
== ".RC" )
1087 GenerateWindresCommand ( sourceFilename
,
1088 windresflagsMacro
);
1091 else if ( extension
== ".spec" || extension
== ".SPEC" )
1093 GenerateWinebuildCommands ( sourceFilename
);
1094 GenerateGccCommand ( GetActualSourceFilename ( sourceFilename
),
1099 else if ( extension
== ".idl" || extension
== ".IDL" )
1101 GenerateWidlCommands ( sourceFilename
,
1103 GenerateGccCommand ( GetActualSourceFilename ( sourceFilename
),
1109 throw InvalidOperationException ( __FILE__
,
1111 "Unsupported filename extension '%s' in file '%s'",
1113 sourceFilename
.c_str () );
1117 MingwModuleHandler::GenerateBuildMapCode ()
1119 fprintf ( fMakefile
,
1120 "ifeq ($(ROS_BUILDMAP),full)\n" );
1122 string mapFilename
= PassThruCacheDirectory (
1123 GetBasename ( module
.GetPath () ) + ".map",
1124 backend
->outputDirectory
);
1125 CLEAN_FILE ( mapFilename
);
1127 fprintf ( fMakefile
,
1128 "\t$(ECHO_OBJDUMP)\n" );
1129 fprintf ( fMakefile
,
1130 "\t$(Q)${objdump} -d -S $@ > %s\n",
1131 mapFilename
.c_str () );
1133 fprintf ( fMakefile
,
1135 fprintf ( fMakefile
,
1136 "ifeq ($(ROS_BUILDMAP),yes)\n" );
1138 fprintf ( fMakefile
,
1140 fprintf ( fMakefile
,
1141 "\t$(Q)${nm} --numeric-sort $@ > %s\n",
1142 mapFilename
.c_str () );
1144 fprintf ( fMakefile
,
1147 fprintf ( fMakefile
,
1152 MingwModuleHandler::GenerateLinkerCommand (
1153 const string
& dependencies
,
1154 const string
& linker
,
1155 const string
& linkerParameters
,
1156 const string
& objectsMacro
,
1157 const string
& libsMacro
)
1159 string
target ( GetTargetMacro ( module
) );
1160 string
target_folder ( GetDirectory ( GetTargetFilename ( module
, NULL
) ) );
1162 fprintf ( fMakefile
,
1163 "%s: %s $(RSYM_TARGET) | %s\n",
1165 dependencies
.c_str (),
1166 target_folder
.c_str () );
1167 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
1168 string
targetName ( module
.GetTargetName () );
1169 if ( module
.importLibrary
!= NULL
)
1171 string base_tmp
= ros_temp
+ module
.name
+ ".base.tmp";
1172 CLEAN_FILE ( base_tmp
);
1173 string junk_tmp
= ros_temp
+ module
.name
+ ".junk.tmp";
1174 CLEAN_FILE ( junk_tmp
);
1175 string temp_exp
= ros_temp
+ module
.name
+ ".temp.exp";
1176 CLEAN_FILE ( temp_exp
);
1177 string def_file
= GetDefinitionFilename ();
1179 fprintf ( fMakefile
,
1180 "\t%s %s -Wl,--base-file,%s -o %s %s %s %s\n",
1182 linkerParameters
.c_str (),
1185 objectsMacro
.c_str (),
1187 GetLinkerMacro ().c_str () );
1189 fprintf ( fMakefile
,
1190 "\t-@${rm} %s 2>$(NUL)\n",
1191 junk_tmp
.c_str () );
1193 string killAt
= module
.mangledSymbols
? "" : "--kill-at";
1194 fprintf ( fMakefile
,
1195 "\t${dlltool} --dllname %s --base-file %s --def %s --output-exp %s %s\n",
1196 targetName
.c_str (),
1202 fprintf ( fMakefile
,
1203 "\t-@${rm} %s 2>$(NUL)\n",
1204 base_tmp
.c_str () );
1206 fprintf ( fMakefile
,
1207 "\t%s %s %s -o %s %s %s %s\n",
1209 linkerParameters
.c_str (),
1212 objectsMacro
.c_str (),
1214 GetLinkerMacro ().c_str () );
1216 fprintf ( fMakefile
,
1217 "\t-@${rm} %s 2>$(NUL)\n",
1218 temp_exp
.c_str () );
1222 fprintf ( fMakefile
,
1223 "\t%s %s -o %s %s %s %s\n",
1225 linkerParameters
.c_str (),
1227 objectsMacro
.c_str (),
1229 GetLinkerMacro ().c_str () );
1232 GenerateBuildMapCode ();
1234 fprintf ( fMakefile
,
1235 "\t$(ECHO_RSYM)\n" );
1236 fprintf ( fMakefile
,
1237 "\t$(Q)$(RSYM_TARGET) $@ $@\n\n" );
1241 MingwModuleHandler::GeneratePhonyTarget() const
1243 string
targetMacro ( GetTargetMacro(module
) );
1244 fprintf ( fMakefile
, ".PHONY: %s\n\n",
1245 targetMacro
.c_str ());
1246 fprintf ( fMakefile
, "%s: | %s\n",
1247 targetMacro
.c_str (),
1248 GetDirectory(GetTargetFilename(module
,NULL
)).c_str () );
1252 MingwModuleHandler::GenerateObjectFileTargets (
1253 const IfableData
& data
,
1256 const string
& cflagsMacro
,
1257 const string
& nasmflagsMacro
,
1258 const string
& windresflagsMacro
,
1259 const string
& widlflagsMacro
)
1263 const vector
<File
*>& files
= data
.files
;
1264 for ( i
= 0; i
< files
.size (); i
++ )
1266 string sourceFilename
= files
[i
]->name
;
1267 GenerateCommands ( sourceFilename
,
1274 fprintf ( fMakefile
,
1278 const vector
<If
*>& ifs
= data
.ifs
;
1279 for ( i
= 0; i
< ifs
.size(); i
++ )
1281 GenerateObjectFileTargets ( ifs
[i
]->data
,
1292 MingwModuleHandler::GenerateObjectFileTargets (
1295 const string
& cflagsMacro
,
1296 const string
& nasmflagsMacro
,
1297 const string
& windresflagsMacro
,
1298 const string
& widlflagsMacro
)
1302 const string
& pch_file
= module
.pch
->header
;
1303 string gch_file
= pch_file
+ ".gch";
1304 CLEAN_FILE(gch_file
);
1312 fprintf ( fMakefile
, "\t$(ECHO_PCH)\n" );
1315 "\t%s -o %s %s -g %s\n\n",
1316 ( module
.cplusplus
? cppc
.c_str() : cc
.c_str() ),
1318 cflagsMacro
.c_str(),
1323 GenerateObjectFileTargets ( module
.non_if_data
,
1330 fprintf ( fMakefile
, "\n" );
1334 MingwModuleHandler::GenerateArchiveTarget ( const string
& ar
,
1335 const string
& objs_macro
) const
1337 string
archiveFilename ( GetModuleArchiveFilename () );
1339 fprintf ( fMakefile
,
1341 archiveFilename
.c_str (),
1342 objs_macro
.c_str (),
1343 GetDirectory(archiveFilename
).c_str() );
1345 fprintf ( fMakefile
, "\t$(ECHO_AR)\n" );
1347 fprintf ( fMakefile
,
1348 "\t%s -rc $@ %s\n\n",
1350 objs_macro
.c_str ());
1352 return archiveFilename
;
1356 MingwModuleHandler::GetCFlagsMacro () const
1358 return ssprintf ( "$(%s_CFLAGS)",
1359 module
.name
.c_str () );
1363 MingwModuleHandler::GetObjectsMacro ( const Module
& module
)
1365 return ssprintf ( "$(%s_OBJS)",
1366 module
.name
.c_str () );
1370 MingwModuleHandler::GetLinkingDependenciesMacro () const
1372 return ssprintf ( "$(%s_LINKDEPS)", module
.name
.c_str () );
1376 MingwModuleHandler::GetLibsMacro () const
1378 return ssprintf ( "$(%s_LIBS)", module
.name
.c_str () );
1382 MingwModuleHandler::GetLinkerMacro () const
1384 return ssprintf ( "$(%s_LFLAGS)",
1385 module
.name
.c_str () );
1389 MingwModuleHandler::GetModuleTargets ( const Module
& module
)
1391 if ( ReferenceObjects ( module
) )
1392 return GetObjectsMacro ( module
);
1394 return GetTargetFilename ( module
, NULL
);
1398 MingwModuleHandler::GenerateObjectMacro ()
1400 objectsMacro
= ssprintf ("%s_OBJS", module
.name
.c_str ());
1402 GenerateObjectMacros (
1405 &module
.compilerFlags
,
1406 &module
.linkerFlags
);
1408 // future references to the macro will be to get its values
1409 objectsMacro
= ssprintf ("$(%s)", objectsMacro
.c_str ());
1413 MingwModuleHandler::GenerateTargetMacro ()
1415 fprintf ( fMakefile
,
1417 GetTargetMacro ( module
, false ).c_str (),
1418 GetModuleTargets ( module
).c_str () );
1422 MingwModuleHandler::GenerateOtherMacros ()
1424 cflagsMacro
= ssprintf ("%s_CFLAGS", module
.name
.c_str ());
1425 nasmflagsMacro
= ssprintf ("%s_NASMFLAGS", module
.name
.c_str ());
1426 windresflagsMacro
= ssprintf ("%s_RCFLAGS", module
.name
.c_str ());
1427 widlflagsMacro
= ssprintf ("%s_WIDLFLAGS", module
.name
.c_str ());
1428 linkerflagsMacro
= ssprintf ("%s_LFLAGS", module
.name
.c_str ());
1429 libsMacro
= ssprintf("%s_LIBS", module
.name
.c_str ());
1430 linkDepsMacro
= ssprintf ("%s_LINKDEPS", module
.name
.c_str ());
1435 &module
.compilerFlags
,
1436 &module
.linkerFlags
);
1438 if ( module
.importLibrary
)
1441 const vector
<File
*>& files
= module
.non_if_data
.files
;
1442 for ( size_t i
= 0; i
< files
.size (); i
++ )
1444 File
& file
= *files
[i
];
1445 string extension
= GetExtension ( file
.name
);
1446 if ( extension
== ".spec" || extension
== ".SPEC" )
1447 GetSpecObjectDependencies ( s
, file
.name
);
1449 if ( s
.size () > 0 )
1454 linkDepsMacro
.c_str() );
1455 for ( size_t i
= 0; i
< s
.size(); i
++ )
1456 fprintf ( fMakefile
,
1459 fprintf ( fMakefile
, "\n" );
1463 string globalCflags
= "-g";
1464 if ( backend
->usePipe
)
1465 globalCflags
+= " -pipe";
1466 if ( !module
.enableWarnings
)
1467 globalCflags
+= " -Werror";
1471 "%s += $(PROJECT_CFLAGS) %s\n",
1472 cflagsMacro
.c_str (),
1473 globalCflags
.c_str () );
1477 "%s += $(PROJECT_RCFLAGS)\n",
1478 windresflagsMacro
.c_str () );
1482 "%s += $(PROJECT_WIDLFLAGS)\n",
1483 widlflagsMacro
.c_str () );
1487 "%s_LFLAGS += $(PROJECT_LFLAGS) -g\n",
1488 module
.name
.c_str () );
1493 linkDepsMacro
.c_str (),
1494 libsMacro
.c_str () );
1496 string cflags
= TypeSpecificCFlags();
1497 if ( cflags
.size() > 0 )
1499 fprintf ( fMakefile
,
1501 cflagsMacro
.c_str (),
1505 string nasmflags
= TypeSpecificNasmFlags();
1506 if ( nasmflags
.size () > 0 )
1508 fprintf ( fMakefile
,
1510 nasmflagsMacro
.c_str (),
1511 nasmflags
.c_str () );
1514 fprintf ( fMakefile
, "\n\n" );
1516 // future references to the macros will be to get their values
1517 cflagsMacro
= ssprintf ("$(%s)", cflagsMacro
.c_str ());
1518 nasmflagsMacro
= ssprintf ("$(%s)", nasmflagsMacro
.c_str ());
1519 widlflagsMacro
= ssprintf ("$(%s)", widlflagsMacro
.c_str ());
1523 MingwModuleHandler::GenerateRules ()
1525 string cc
= ( module
.host
== HostTrue
? "${host_gcc}" : "${gcc}" );
1526 string cppc
= ( module
.host
== HostTrue
? "${host_gpp}" : "${gpp}" );
1527 string ar
= ( module
.host
== HostTrue
? "${host_ar}" : "${ar}" );
1529 string targetMacro
= GetTargetMacro ( module
);
1531 CLEAN_FILE ( targetMacro
);
1533 // generate phony target for module name
1534 fprintf ( fMakefile
, ".PHONY: %s\n",
1535 module
.name
.c_str () );
1536 fprintf ( fMakefile
, "%s: %s\n\n",
1537 module
.name
.c_str (),
1538 GetTargetMacro ( module
).c_str () );
1540 if ( !ReferenceObjects ( module
) )
1542 string
ar_target ( GenerateArchiveTarget ( ar
, objectsMacro
) );
1543 if ( targetMacro
!= ar_target
)
1545 CLEAN_FILE ( ar_target
);
1549 GenerateObjectFileTargets ( cc
,
1558 MingwModuleHandler::GetInvocationDependencies (
1559 const Module
& module
,
1560 string_list
& dependencies
)
1562 for ( size_t i
= 0; i
< module
.invocations
.size (); i
++ )
1564 Invoke
& invoke
= *module
.invocations
[i
];
1565 if ( invoke
.invokeModule
== &module
)
1566 /* Protect against circular dependencies */
1568 invoke
.GetTargets ( dependencies
);
1573 MingwModuleHandler::GenerateInvocations () const
1575 if ( module
.invocations
.size () == 0 )
1578 size_t iend
= module
.invocations
.size ();
1579 for ( size_t i
= 0; i
< iend
; i
++ )
1581 const Invoke
& invoke
= *module
.invocations
[i
];
1583 if ( invoke
.invokeModule
->type
!= BuildTool
)
1585 throw InvalidBuildFileException ( module
.node
.location
,
1586 "Only modules of type buildtool can be invoked." );
1589 string invokeTarget
= module
.GetInvocationTarget ( i
);
1590 string_list invoke_targets
;
1591 assert ( invoke_targets
.size() );
1592 invoke
.GetTargets ( invoke_targets
);
1593 fprintf ( fMakefile
,
1595 invokeTarget
.c_str () );
1596 fprintf ( fMakefile
,
1598 invokeTarget
.c_str () );
1599 size_t j
, jend
= invoke_targets
.size();
1600 for ( j
= 0; j
< jend
; j
++ )
1602 fprintf ( fMakefile
,
1604 invoke_targets
[i
].c_str () );
1606 fprintf ( fMakefile
, "\n\n%s", invoke_targets
[0].c_str () );
1607 for ( j
= 1; j
< jend
; j
++ )
1608 fprintf ( fMakefile
,
1610 invoke_targets
[i
].c_str () );
1611 fprintf ( fMakefile
,
1613 NormalizeFilename ( invoke
.invokeModule
->GetPath () ).c_str () );
1614 fprintf ( fMakefile
, "\t$(ECHO_INVOKE)\n" );
1615 fprintf ( fMakefile
,
1617 NormalizeFilename ( invoke
.invokeModule
->GetPath () ).c_str (),
1618 invoke
.GetParameters ().c_str () );
1623 MingwModuleHandler::GetPreconditionDependenciesName () const
1625 return module
.name
+ "_precondition";
1629 MingwModuleHandler::GetDefaultDependencies (
1630 string_list
& dependencies
) const
1632 /* Avoid circular dependency */
1633 if ( module
.type
!= BuildTool
1634 && module
.name
!= "zlib"
1635 && module
.name
!= "hostzlib" )
1637 dependencies
.push_back ( "$(INIT)" );
1641 MingwModuleHandler::GeneratePreconditionDependencies ()
1643 string preconditionDependenciesName
= GetPreconditionDependenciesName ();
1644 string_list sourceFilenames
;
1645 GetSourceFilenamesWithoutGeneratedFiles ( sourceFilenames
);
1646 string_list dependencies
;
1647 GetDefaultDependencies ( dependencies
);
1648 GetModuleDependencies ( dependencies
);
1650 GetInvocationDependencies ( module
, dependencies
);
1652 if ( dependencies
.size() )
1654 fprintf ( fMakefile
,
1656 preconditionDependenciesName
.c_str () );
1657 for ( size_t i
= 0; i
< dependencies
.size(); i
++ )
1658 fprintf ( fMakefile
,
1660 dependencies
[i
].c_str () );
1661 fprintf ( fMakefile
, "\n\n" );
1664 for ( size_t i
= 0; i
< sourceFilenames
.size(); i
++ )
1666 fprintf ( fMakefile
,
1668 sourceFilenames
[i
].c_str(),
1669 preconditionDependenciesName
.c_str ());
1671 fprintf ( fMakefile
, "\n" );
1675 MingwModuleHandler::IsWineModule () const
1677 if ( module
.importLibrary
== NULL
)
1680 size_t index
= module
.importLibrary
->definition
.rfind ( ".spec.def" );
1681 return ( index
!= string::npos
);
1685 MingwModuleHandler::GetDefinitionFilename () const
1687 string defFilename
= module
.GetBasePath () + SSEP
+ module
.importLibrary
->definition
;
1688 if ( IsWineModule () )
1689 return PassThruCacheDirectory ( NormalizeFilename ( defFilename
),
1690 backend
->intermediateDirectory
);
1696 MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ()
1698 if ( module
.importLibrary
!= NULL
)
1700 string
library_target (
1701 GetImportLibraryFilename ( module
, &clean_files
) );
1704 GetDefinitionDependencies ( deps
);
1706 fprintf ( fMakefile
, "# IMPORT LIBRARY RULE:\n" );
1708 fprintf ( fMakefile
, "%s:",
1709 library_target
.c_str () );
1711 size_t i
, iend
= deps
.size();
1712 for ( i
= 0; i
< iend
; i
++ )
1713 fprintf ( fMakefile
, " %s",
1716 fprintf ( fMakefile
, " | %s\n",
1717 GetDirectory ( GetTargetFilename ( module
, NULL
) ).c_str () );
1719 fprintf ( fMakefile
, "\t$(ECHO_DLLTOOL)\n" );
1721 string killAt
= module
.mangledSymbols
? "" : "--kill-at";
1722 fprintf ( fMakefile
,
1723 "\t${dlltool} --dllname %s --def %s --output-lib %s %s\n\n",
1724 module
.GetTargetName ().c_str (),
1725 GetDefinitionFilename ().c_str (),
1726 library_target
.c_str (),
1732 MingwModuleHandler::GetSpecObjectDependencies (
1733 string_list
& dependencies
,
1734 const string
& filename
) const
1736 string basename
= GetBasename ( filename
);
1737 string defDependency
= PassThruCacheDirectory (
1738 NormalizeFilename ( basename
+ ".spec.def" ),
1739 backend
->intermediateDirectory
);
1740 dependencies
.push_back ( defDependency
);
1741 string stubsDependency
= PassThruCacheDirectory (
1742 NormalizeFilename ( basename
+ ".stubs.c" ),
1743 backend
->intermediateDirectory
);
1744 dependencies
.push_back ( stubsDependency
);
1748 MingwModuleHandler::GetWidlObjectDependencies (
1749 string_list
& dependencies
,
1750 const string
& filename
) const
1752 string basename
= GetBasename ( filename
);
1753 string serverDependency
= PassThruCacheDirectory (
1754 NormalizeFilename ( basename
+ "_s.c" ),
1755 backend
->intermediateDirectory
);
1756 dependencies
.push_back ( serverDependency
);
1760 MingwModuleHandler::GetDefinitionDependencies (
1761 string_list
& dependencies
) const
1763 string dkNkmLibNoFixup
= "dk/nkm/lib";
1764 const vector
<File
*>& files
= module
.non_if_data
.files
;
1765 for ( size_t i
= 0; i
< files
.size (); i
++ )
1767 File
& file
= *files
[i
];
1768 string extension
= GetExtension ( file
.name
);
1769 if ( extension
== ".spec" || extension
== ".SPEC" )
1771 GetSpecObjectDependencies ( dependencies
, file
.name
);
1773 if ( extension
== ".idl" || extension
== ".IDL" )
1775 GetWidlObjectDependencies ( dependencies
, file
.name
);
1781 MingwBuildToolModuleHandler::MingwBuildToolModuleHandler ( const Module
& module_
)
1782 : MingwModuleHandler ( module_
)
1787 MingwBuildToolModuleHandler::Process ()
1789 GenerateBuildToolModuleTarget ();
1793 MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ()
1795 string
targetMacro ( GetTargetMacro (module
) );
1796 string objectsMacro
= GetObjectsMacro ( module
);
1797 string linkDepsMacro
= GetLinkingDependenciesMacro ();
1798 string libsMacro
= GetLibsMacro ();
1803 if ( module
.cplusplus
)
1804 linker
= "${host_gpp}";
1806 linker
= "${host_gcc}";
1808 fprintf ( fMakefile
, "%s: %s %s | %s\n",
1809 targetMacro
.c_str (),
1810 objectsMacro
.c_str (),
1811 linkDepsMacro
.c_str (),
1812 GetDirectory(GetTargetFilename(module
,NULL
)).c_str () );
1813 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
1814 fprintf ( fMakefile
,
1815 "\t%s %s -o $@ %s %s\n\n",
1817 GetLinkerMacro ().c_str (),
1818 objectsMacro
.c_str (),
1819 libsMacro
.c_str () );
1823 MingwKernelModuleHandler::MingwKernelModuleHandler (
1824 const Module
& module_
)
1826 : MingwModuleHandler ( module_
)
1831 MingwKernelModuleHandler::Process ()
1833 GenerateKernelModuleTarget ();
1837 MingwKernelModuleHandler::GenerateKernelModuleTarget ()
1839 string
targetName ( module
.GetTargetName () ); // i.e. "ntoskrnl.exe"
1840 string
targetMacro ( GetTargetMacro ( module
) ); // i.e. "$(NTOSKRNL_TARGET)"
1841 string workingDirectory
= GetWorkingDirectory ();
1842 string objectsMacro
= GetObjectsMacro ( module
);
1843 string linkDepsMacro
= GetLinkingDependenciesMacro ();
1844 string libsMacro
= GetLibsMacro ();
1845 string base_tmp
= ros_temp
+ module
.name
+ ".base.tmp";
1846 CLEAN_FILE ( base_tmp
);
1847 string junk_tmp
= ros_temp
+ module
.name
+ ".junk.tmp";
1848 CLEAN_FILE ( junk_tmp
);
1849 string temp_exp
= ros_temp
+ module
.name
+ ".temp.exp";
1850 CLEAN_FILE ( temp_exp
);
1851 string gccOptions
= ssprintf ("-Wl,-T,%s" SSEP
"ntoskrnl.lnk -Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll",
1852 module
.GetBasePath ().c_str (),
1853 module
.entrypoint
.c_str (),
1854 module
.baseaddress
.c_str () );
1858 GenerateImportLibraryTargetIfNeeded ();
1860 fprintf ( fMakefile
, "%s: %s %s $(RSYM_TARGET) | %s\n",
1861 targetMacro
.c_str (),
1862 objectsMacro
.c_str (),
1863 linkDepsMacro
.c_str (),
1864 GetDirectory(GetTargetFilename(module
,NULL
)).c_str () );
1865 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
1866 fprintf ( fMakefile
,
1867 "\t${gcc} %s %s -Wl,--base-file,%s -o %s %s %s\n",
1868 GetLinkerMacro ().c_str (),
1869 gccOptions
.c_str (),
1872 objectsMacro
.c_str (),
1873 linkDepsMacro
.c_str () );
1874 fprintf ( fMakefile
,
1875 "\t-@${rm} %s 2>$(NUL)\n",
1876 junk_tmp
.c_str () );
1877 string killAt
= module
.mangledSymbols
? "" : "--kill-at";
1878 fprintf ( fMakefile
,
1879 "\t${dlltool} --dllname %s --base-file %s --def ntoskrnl/ntoskrnl.def --output-exp %s %s\n",
1880 targetName
.c_str (),
1884 fprintf ( fMakefile
,
1885 "\t-@${rm} %s 2>$(NUL)\n",
1886 base_tmp
.c_str () );
1887 fprintf ( fMakefile
,
1888 "\t${gcc} %s %s -Wl,%s -o $@ %s %s\n",
1889 GetLinkerMacro ().c_str (),
1890 gccOptions
.c_str (),
1892 objectsMacro
.c_str (),
1893 linkDepsMacro
.c_str () );
1894 fprintf ( fMakefile
,
1895 "\t-@${rm} %s 2>$(NUL)\n",
1896 temp_exp
.c_str () );
1897 fprintf ( fMakefile
, "\t$(ECHO_RSYM)\n" );
1898 fprintf ( fMakefile
,
1899 "\t$(Q)$(RSYM_TARGET) $@ $@\n\n" );
1903 MingwStaticLibraryModuleHandler::MingwStaticLibraryModuleHandler (
1904 const Module
& module_
)
1906 : MingwModuleHandler ( module_
)
1911 MingwStaticLibraryModuleHandler::Process ()
1913 GenerateStaticLibraryModuleTarget ();
1917 MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget ()
1923 MingwObjectLibraryModuleHandler::MingwObjectLibraryModuleHandler (
1924 const Module
& module_
)
1926 : MingwModuleHandler ( module_
)
1931 MingwObjectLibraryModuleHandler::Process ()
1933 GenerateObjectLibraryModuleTarget ();
1937 MingwObjectLibraryModuleHandler::GenerateObjectLibraryModuleTarget ()
1943 MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler (
1944 const Module
& module_
)
1946 : MingwModuleHandler ( module_
)
1951 MingwKernelModeDLLModuleHandler::Process ()
1953 GenerateKernelModeDLLModuleTarget ();
1957 MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ()
1959 string
targetMacro ( GetTargetMacro ( module
) );
1960 string workingDirectory
= GetWorkingDirectory ( );
1961 string objectsMacro
= GetObjectsMacro ( module
);
1962 string linkDepsMacro
= GetLinkingDependenciesMacro ();
1963 string libsMacro
= GetLibsMacro ();
1965 GenerateImportLibraryTargetIfNeeded ();
1967 if ( module
.non_if_data
.files
.size () > 0 )
1971 string dependencies
=
1972 objectsMacro
+ " " + linkDepsMacro
;
1974 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll",
1975 module
.entrypoint
.c_str (),
1976 module
.baseaddress
.c_str () );
1977 GenerateLinkerCommand ( dependencies
,
1985 GeneratePhonyTarget();
1990 MingwKernelModeDriverModuleHandler::MingwKernelModeDriverModuleHandler (
1991 const Module
& module_
)
1993 : MingwModuleHandler ( module_
)
1998 MingwKernelModeDriverModuleHandler::Process ()
2000 GenerateKernelModeDriverModuleTarget ();
2005 MingwKernelModeDriverModuleHandler::GenerateKernelModeDriverModuleTarget ()
2007 string
targetMacro ( GetTargetMacro (module
) );
2008 string workingDirectory
= GetWorkingDirectory ();
2009 string objectsMacro
= GetObjectsMacro ( module
);
2010 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2011 string libsMacro
= GetLibsMacro ();
2013 GenerateImportLibraryTargetIfNeeded ();
2015 if ( module
.non_if_data
.files
.size () > 0 )
2019 string dependencies
= objectsMacro
+ " " + linkDepsMacro
;
2021 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll",
2022 module
.entrypoint
.c_str (),
2023 module
.baseaddress
.c_str () );
2024 GenerateLinkerCommand ( dependencies
,
2032 GeneratePhonyTarget();
2037 MingwNativeDLLModuleHandler::MingwNativeDLLModuleHandler (
2038 const Module
& module_
)
2040 : MingwModuleHandler ( module_
)
2045 MingwNativeDLLModuleHandler::Process ()
2047 GenerateNativeDLLModuleTarget ();
2051 MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ()
2053 string
targetMacro ( GetTargetMacro (module
) );
2054 string workingDirectory
= GetWorkingDirectory ( );
2055 string objectsMacro
= GetObjectsMacro ( module
);
2056 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2057 string libsMacro
= GetLibsMacro ();
2059 GenerateImportLibraryTargetIfNeeded ();
2061 if ( module
.non_if_data
.files
.size () > 0 )
2065 string dependencies
=
2066 objectsMacro
+ " " + linkDepsMacro
;
2068 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib -mdll",
2069 module
.entrypoint
.c_str (),
2070 module
.baseaddress
.c_str () );
2071 GenerateLinkerCommand ( dependencies
,
2079 GeneratePhonyTarget();
2084 MingwNativeCUIModuleHandler::MingwNativeCUIModuleHandler (
2085 const Module
& module_
)
2087 : MingwModuleHandler ( module_
)
2092 MingwNativeCUIModuleHandler::Process ()
2094 GenerateNativeCUIModuleTarget ();
2098 MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ()
2100 string
targetMacro ( GetTargetMacro (module
) );
2101 string workingDirectory
= GetWorkingDirectory ( );
2102 string objectsMacro
= GetObjectsMacro ( module
);
2103 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2104 string libsMacro
= GetLibsMacro ();
2106 GenerateImportLibraryTargetIfNeeded ();
2108 if ( module
.non_if_data
.files
.size () > 0 )
2112 string dependencies
=
2113 objectsMacro
+ " " + linkDepsMacro
;
2115 string linkerParameters
= ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib",
2116 module
.entrypoint
.c_str (),
2117 module
.baseaddress
.c_str () );
2118 GenerateLinkerCommand ( dependencies
,
2126 GeneratePhonyTarget();
2131 MingwWin32DLLModuleHandler::MingwWin32DLLModuleHandler (
2132 const Module
& module_
)
2134 : MingwModuleHandler ( module_
)
2139 MingwWin32DLLModuleHandler::Process ()
2141 GenerateExtractWineDLLResourcesTarget ();
2142 GenerateWin32DLLModuleTarget ();
2146 MingwWin32DLLModuleHandler::GenerateExtractWineDLLResourcesTarget ()
2148 fprintf ( fMakefile
, ".PHONY: %s_extractresources\n\n",
2149 module
.name
.c_str () );
2150 fprintf ( fMakefile
, "%s_extractresources: $(BIN2RES_TARGET)\n",
2151 module
.name
.c_str () );
2152 const vector
<File
*>& files
= module
.non_if_data
.files
;
2153 for ( size_t i
= 0; i
< files
.size (); i
++ )
2155 File
& file
= *files
[i
];
2156 string extension
= GetExtension ( file
.name
);
2157 if ( extension
== ".rc" || extension
== ".RC" )
2159 string resource
= NormalizeFilename ( file
.name
);
2160 fprintf ( fMakefile
, "\t$(ECHO_BIN2RES)\n" );
2161 fprintf ( fMakefile
, "\t@:echo ${bin2res} -f -x %s\n",
2162 resource
.c_str () );
2165 fprintf ( fMakefile
, "\n");
2169 MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ()
2171 string
targetMacro ( GetTargetMacro (module
) );
2172 string workingDirectory
= GetWorkingDirectory ( );
2173 string objectsMacro
= GetObjectsMacro ( module
);
2174 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2175 string libsMacro
= GetLibsMacro ();
2177 GenerateImportLibraryTargetIfNeeded ();
2179 if ( module
.non_if_data
.files
.size () > 0 )
2183 string dependencies
= objectsMacro
+ " " + linkDepsMacro
;
2186 if ( module
.cplusplus
)
2191 string linkerParameters
= ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -mdll",
2192 module
.entrypoint
.c_str (),
2193 module
.baseaddress
.c_str () );
2194 GenerateLinkerCommand ( dependencies
,
2202 GeneratePhonyTarget();
2207 MingwWin32CUIModuleHandler::MingwWin32CUIModuleHandler (
2208 const Module
& module_
)
2210 : MingwModuleHandler ( module_
)
2215 MingwWin32CUIModuleHandler::Process ()
2217 GenerateWin32CUIModuleTarget ();
2221 MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ()
2223 string
targetMacro ( GetTargetMacro (module
) );
2224 string workingDirectory
= GetWorkingDirectory ( );
2225 string objectsMacro
= GetObjectsMacro ( module
);
2226 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2227 string libsMacro
= GetLibsMacro ();
2229 GenerateImportLibraryTargetIfNeeded ();
2231 if ( module
.non_if_data
.files
.size () > 0 )
2235 string dependencies
=
2236 objectsMacro
+ " " + linkDepsMacro
;
2239 if ( module
.cplusplus
)
2244 string linkerParameters
= ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
2245 module
.entrypoint
.c_str (),
2246 module
.baseaddress
.c_str () );
2247 GenerateLinkerCommand ( dependencies
,
2255 GeneratePhonyTarget();
2260 MingwWin32GUIModuleHandler::MingwWin32GUIModuleHandler (
2261 const Module
& module_
)
2263 : MingwModuleHandler ( module_
)
2268 MingwWin32GUIModuleHandler::Process ()
2270 GenerateWin32GUIModuleTarget ();
2274 MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ()
2276 string
targetMacro ( GetTargetMacro (module
) );
2277 string workingDirectory
= GetWorkingDirectory ( );
2278 string objectsMacro
= GetObjectsMacro ( module
);
2279 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2280 string libsMacro
= GetLibsMacro ();
2282 GenerateImportLibraryTargetIfNeeded ();
2284 if ( module
.non_if_data
.files
.size () > 0 )
2288 string dependencies
=
2289 objectsMacro
+ " " + linkDepsMacro
;
2292 if ( module
.cplusplus
)
2297 string linkerParameters
= ssprintf ( "-Wl,--subsystem,windows -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
2298 module
.entrypoint
.c_str (),
2299 module
.baseaddress
.c_str () );
2300 GenerateLinkerCommand ( dependencies
,
2308 GeneratePhonyTarget();
2313 MingwBootLoaderModuleHandler::MingwBootLoaderModuleHandler (
2314 const Module
& module_
)
2316 : MingwModuleHandler ( module_
)
2321 MingwBootLoaderModuleHandler::Process ()
2323 GenerateBootLoaderModuleTarget ();
2327 MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ()
2329 string
targetName ( module
.GetTargetName () );
2330 string
targetMacro ( GetTargetMacro (module
) );
2331 string workingDirectory
= GetWorkingDirectory ();
2332 string junk_tmp
= ros_temp
+ module
.name
+ ".junk.tmp";
2333 CLEAN_FILE ( junk_tmp
);
2334 string objectsMacro
= GetObjectsMacro ( module
);
2335 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2336 string libsMacro
= GetLibsMacro ();
2340 fprintf ( fMakefile
, "%s: %s %s | %s\n",
2341 targetMacro
.c_str (),
2342 objectsMacro
.c_str (),
2343 linkDepsMacro
.c_str (),
2344 GetDirectory(GetTargetFilename(module
,NULL
)).c_str () );
2346 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
2348 fprintf ( fMakefile
,
2349 "\t${ld} %s -N -Ttext=0x8000 -o %s %s %s\n",
2350 GetLinkerMacro ().c_str (),
2352 objectsMacro
.c_str (),
2353 linkDepsMacro
.c_str () );
2354 fprintf ( fMakefile
,
2355 "\t${objcopy} -O binary %s $@\n",
2356 junk_tmp
.c_str () );
2357 fprintf ( fMakefile
,
2358 "\t-@${rm} %s 2>$(NUL)\n",
2359 junk_tmp
.c_str () );
2363 MingwBootSectorModuleHandler::MingwBootSectorModuleHandler (
2364 const Module
& module_
)
2366 : MingwModuleHandler ( module_
)
2371 MingwBootSectorModuleHandler::Process ()
2373 GenerateBootSectorModuleTarget ();
2377 MingwBootSectorModuleHandler::GenerateBootSectorModuleTarget ()
2379 string objectsMacro
= GetObjectsMacro ( module
);
2383 fprintf ( fMakefile
, ".PHONY: %s\n\n",
2384 module
.name
.c_str ());
2385 fprintf ( fMakefile
,
2387 module
.name
.c_str (),
2388 objectsMacro
.c_str () );
2392 MingwIsoModuleHandler::MingwIsoModuleHandler (
2393 const Module
& module_
)
2395 : MingwModuleHandler ( module_
)
2400 MingwIsoModuleHandler::Process ()
2402 GenerateIsoModuleTarget ();
2406 MingwIsoModuleHandler::OutputBootstrapfileCopyCommands (
2407 const string
& bootcdDirectory
)
2409 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
2411 const Module
& m
= *module
.project
.modules
[i
];
2412 if ( m
.bootstrap
!= NULL
)
2414 string sourceFilename
= PassThruCacheDirectory (
2415 NormalizeFilename ( m
.GetPath () ),
2416 backend
->outputDirectory
);
2417 string
targetFilenameNoFixup ( bootcdDirectory
+ SSEP
+ m
.bootstrap
->base
+ SSEP
+ m
.bootstrap
->nameoncd
);
2418 string targetFilename
= MingwModuleHandler::PassThruCacheDirectory (
2419 NormalizeFilename ( targetFilenameNoFixup
),
2420 backend
->outputDirectory
);
2421 fprintf ( fMakefile
,
2423 fprintf ( fMakefile
,
2424 "\t${cp} %s %s 1>$(NUL)\n",
2425 sourceFilename
.c_str (),
2426 targetFilename
.c_str () );
2432 MingwIsoModuleHandler::OutputCdfileCopyCommands (
2433 const string
& bootcdDirectory
)
2435 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
2437 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
2438 string targetFilenameNoFixup
= bootcdDirectory
+ SSEP
+ cdfile
.base
+ SSEP
+ cdfile
.nameoncd
;
2439 string targetFilename
= MingwModuleHandler::PassThruCacheDirectory (
2440 NormalizeFilename ( targetFilenameNoFixup
),
2441 backend
->outputDirectory
);
2442 fprintf ( fMakefile
,
2444 fprintf ( fMakefile
,
2445 "\t${cp} %s %s 1>$(NUL)\n",
2446 cdfile
.GetPath ().c_str (),
2447 targetFilename
.c_str () );
2452 MingwIsoModuleHandler::GetBootstrapCdDirectories ( const string
& bootcdDirectory
)
2455 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
2457 const Module
& m
= *module
.project
.modules
[i
];
2458 if ( m
.bootstrap
!= NULL
)
2460 string
targetDirectory ( bootcdDirectory
+ SSEP
+ m
.bootstrap
->base
);
2461 if ( directories
.size () > 0 )
2463 directories
+= PassThruCacheDirectory (
2464 NormalizeFilename ( targetDirectory
),
2465 backend
->outputDirectory
);
2472 MingwIsoModuleHandler::GetNonModuleCdDirectories ( const string
& bootcdDirectory
)
2475 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
2477 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
2478 string
targetDirectory ( bootcdDirectory
+ SSEP
+ cdfile
.base
);
2479 if ( directories
.size () > 0 )
2481 directories
+= PassThruCacheDirectory (
2482 NormalizeFilename ( targetDirectory
),
2483 backend
->outputDirectory
);
2489 MingwIsoModuleHandler::GetCdDirectories ( const string
& bootcdDirectory
)
2491 string directories
= GetBootstrapCdDirectories ( bootcdDirectory
);
2492 directories
+= " " + GetNonModuleCdDirectories ( bootcdDirectory
);
2497 MingwIsoModuleHandler::GetBootstrapCdFiles (
2498 vector
<string
>& out
) const
2500 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
2502 const Module
& m
= *module
.project
.modules
[i
];
2503 if ( m
.bootstrap
!= NULL
)
2505 string filename
= PassThruCacheDirectory (
2506 NormalizeFilename ( m
.GetPath () ),
2507 backend
->outputDirectory
);
2508 out
.push_back ( filename
);
2514 MingwIsoModuleHandler::GetNonModuleCdFiles (
2515 vector
<string
>& out
) const
2517 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
2519 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
2520 out
.push_back ( cdfile
.GetPath () );
2525 MingwIsoModuleHandler::GetCdFiles (
2526 vector
<string
>& out
) const
2528 GetBootstrapCdFiles ( out
);
2529 GetNonModuleCdFiles ( out
);
2533 MingwIsoModuleHandler::GenerateIsoModuleTarget ()
2535 string bootcdDirectory
= "cd";
2536 string bootcd
= PassThruCacheDirectory (
2537 NormalizeFilename ( bootcdDirectory
+ SSEP
),
2538 backend
->outputDirectory
);
2539 string isoboot
= PassThruCacheDirectory (
2540 NormalizeFilename ( "boot" SSEP
"freeldr" SSEP
"bootsect" SSEP
"isoboot.o" ),
2541 backend
->outputDirectory
);
2542 string bootcdReactosNoFixup
= bootcdDirectory
+ SSEP
"reactos";
2543 string bootcdReactos
= PassThruCacheDirectory (
2544 NormalizeFilename ( bootcdReactosNoFixup
) + SSEP
,
2545 backend
->outputDirectory
);
2546 CLEAN_FILE ( bootcdReactos
);
2547 string reactosInf
= PassThruCacheDirectory (
2548 NormalizeFilename ( bootcdReactosNoFixup
+ SSEP
"reactos.inf" ),
2549 backend
->outputDirectory
);
2550 string reactosDff
= NormalizeFilename ( "bootdata" SSEP
"packages" SSEP
"reactos.dff" );
2551 string cdDirectories
= GetCdDirectories ( bootcdDirectory
);
2552 vector
<string
> vCdFiles
;
2553 GetCdFiles ( vCdFiles
);
2554 string cdFiles
= v2s ( vCdFiles
, 5 );
2556 fprintf ( fMakefile
, ".PHONY: %s\n\n",
2557 module
.name
.c_str ());
2558 fprintf ( fMakefile
,
2559 "%s: all %s %s %s %s $(CABMAN_TARGET) $(CDMAKE_TARGET)\n",
2560 module
.name
.c_str (),
2562 bootcdReactos
.c_str (),
2563 cdDirectories
.c_str (),
2565 fprintf ( fMakefile
, "\t$(ECHO_CABMAN)\n" );
2566 fprintf ( fMakefile
,
2567 "\t$(Q)$(CABMAN_TARGET) -C %s -L %s -I -P $(OUTPUT)\n",
2568 reactosDff
.c_str (),
2569 bootcdReactos
.c_str () );
2570 fprintf ( fMakefile
,
2571 "\t$(Q)$(CABMAN_TARGET) -C %s -RC %s -L %s -N -P $(OUTPUT)\n",
2572 reactosDff
.c_str (),
2573 reactosInf
.c_str (),
2574 bootcdReactos
.c_str ());
2575 fprintf ( fMakefile
,
2576 "\t-@${rm} %s 2>$(NUL)\n",
2577 reactosInf
.c_str () );
2578 OutputBootstrapfileCopyCommands ( bootcdDirectory
);
2579 OutputCdfileCopyCommands ( bootcdDirectory
);
2580 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
2581 fprintf ( fMakefile
,
2582 "\t$(Q)$(CDMAKE_TARGET) -v -m -b %s %s REACTOS ReactOS.iso\n",
2585 fprintf ( fMakefile
,
2590 MingwLiveIsoModuleHandler::MingwLiveIsoModuleHandler (
2591 const Module
& module_
)
2593 : MingwModuleHandler ( module_
)
2598 MingwLiveIsoModuleHandler::Process ()
2600 GenerateLiveIsoModuleTarget ();
2604 MingwLiveIsoModuleHandler::CreateDirectory ( const string
& directory
)
2606 string normalizedDirectory
= MingwModuleHandler::PassThruCacheDirectory (
2607 NormalizeFilename ( directory
) + SSEP
,
2608 backend
->outputDirectory
);
2612 MingwLiveIsoModuleHandler::OutputCopyCommand ( const string
& sourceFilename
,
2613 const string
& targetFilename
,
2614 const string
& targetDirectory
)
2616 string normalizedTargetFilename
= MingwModuleHandler::PassThruCacheDirectory (
2617 NormalizeFilename ( targetDirectory
+ SSEP
+ targetFilename
),
2618 backend
->outputDirectory
);
2619 fprintf ( fMakefile
,
2621 fprintf ( fMakefile
,
2622 "\t${cp} %s %s 1>$(NUL)\n",
2623 sourceFilename
.c_str (),
2624 normalizedTargetFilename
.c_str () );
2628 MingwLiveIsoModuleHandler::OutputModuleCopyCommands ( string
& livecdDirectory
,
2629 string
& reactosDirectory
)
2631 for ( size_t i
= 0; i
< module
.project
.modules
.size (); i
++ )
2633 const Module
& m
= *module
.project
.modules
[i
];
2634 if ( m
.installName
.length () > 0 )
2636 string sourceFilename
= MingwModuleHandler::PassThruCacheDirectory (
2637 NormalizeFilename ( m
.GetPath () ),
2638 backend
->outputDirectory
);
2639 OutputCopyCommand ( sourceFilename
,
2641 livecdDirectory
+ SSEP
+ reactosDirectory
+ SSEP
+ m
.installBase
);
2647 MingwLiveIsoModuleHandler::OutputNonModuleCopyCommands ( string
& livecdDirectory
,
2648 string
& reactosDirectory
)
2650 for ( size_t i
= 0; i
< module
.project
.installfiles
.size (); i
++ )
2652 const InstallFile
& installfile
= *module
.project
.installfiles
[i
];
2653 OutputCopyCommand ( installfile
.GetPath (),
2654 installfile
.newname
,
2655 livecdDirectory
+ SSEP
+ reactosDirectory
+ SSEP
+ installfile
.base
);
2660 MingwLiveIsoModuleHandler::OutputProfilesDirectoryCommands ( string
& livecdDirectory
)
2662 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" );
2663 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" SSEP
"All Users") ;
2664 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" SSEP
"All Users" SSEP
"Desktop" );
2665 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" SSEP
"Default User" );
2666 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" SSEP
"Default User" SSEP
"Desktop" );
2667 CreateDirectory ( livecdDirectory
+ SSEP
"Profiles" SSEP
"Default User" SSEP
"My Documents" );
2669 string livecdIni
= "bootdata" SSEP
"livecd.ini";
2670 OutputCopyCommand ( livecdIni
,
2676 MingwLiveIsoModuleHandler::OutputLoaderCommands ( string
& livecdDirectory
)
2678 string setupldr
= PassThruCacheDirectory (
2679 NormalizeFilename ( "boot" SSEP
"freeldr" SSEP
"freeldr" SSEP
"setupldr.sys" ),
2680 backend
->outputDirectory
);
2681 CreateDirectory ( livecdDirectory
+ SSEP
"loader" );
2682 OutputCopyCommand ( setupldr
,
2684 livecdDirectory
+ SSEP
+ "loader" );
2688 MingwLiveIsoModuleHandler::OutputRegistryCommands ( string
& livecdDirectory
)
2690 string system32ConfigDirectory
= NormalizeFilename (
2691 MingwModuleHandler::PassThruCacheDirectory (
2692 livecdDirectory
+ SSEP
"system32" SSEP
"config" SSEP
,
2693 backend
->outputDirectory
) );
2694 fprintf ( fMakefile
,
2695 "\t$(ECHO_MKHIVE)\n" );
2696 fprintf ( fMakefile
,
2697 "\t$(MKHIVE_TARGET) bootdata %s bootdata" SSEP
"livecd.inf bootdata" SSEP
"hiveinst.inf\n",
2698 system32ConfigDirectory
.c_str () );
2702 MingwLiveIsoModuleHandler::GenerateLiveIsoModuleTarget ()
2704 string livecdDirectory
= "livecd";
2705 string livecd
= PassThruCacheDirectory (
2706 NormalizeFilename ( livecdDirectory
+ SSEP
),
2707 backend
->outputDirectory
);
2708 string isoboot
= PassThruCacheDirectory (
2709 NormalizeFilename ( "boot" SSEP
"freeldr" SSEP
"bootsect" SSEP
"isoboot.o" ),
2710 backend
->outputDirectory
);
2711 string reactosDirectory
= "reactos";
2712 string livecdReactosNoFixup
= livecdDirectory
+ SSEP
+ reactosDirectory
;
2713 string livecdReactos
= NormalizeFilename ( PassThruCacheDirectory (
2714 NormalizeFilename ( livecdReactosNoFixup
+ SSEP
),
2715 backend
->outputDirectory
) );
2716 CLEAN_FILE ( livecdReactos
);
2718 fprintf ( fMakefile
, ".PHONY: %s\n\n",
2719 module
.name
.c_str ());
2720 fprintf ( fMakefile
,
2721 "%s: all %s %s $(MKHIVE_TARGET) $(CDMAKE_TARGET)\n",
2722 module
.name
.c_str (),
2724 livecdReactos
.c_str () );
2725 OutputModuleCopyCommands ( livecdDirectory
,
2727 OutputNonModuleCopyCommands ( livecdDirectory
,
2729 OutputProfilesDirectoryCommands ( livecdDirectory
);
2730 OutputLoaderCommands ( livecdDirectory
);
2731 OutputRegistryCommands ( livecdDirectory
);
2732 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
2733 fprintf ( fMakefile
,
2734 "\t$(Q)$(CDMAKE_TARGET) -v -m -j -b %s %s REACTOS ReactOS-LiveCD.iso\n",
2737 fprintf ( fMakefile
,
2742 MingwTestModuleHandler::MingwTestModuleHandler (
2743 const Module
& module_
)
2745 : MingwModuleHandler ( module_
)
2750 MingwTestModuleHandler::Process ()
2752 GenerateTestModuleTarget ();
2756 MingwTestModuleHandler::GenerateTestModuleTarget ()
2758 string
targetMacro ( GetTargetMacro ( module
) );
2759 string workingDirectory
= GetWorkingDirectory ( );
2760 string objectsMacro
= GetObjectsMacro ( module
);
2761 string linkDepsMacro
= GetLinkingDependenciesMacro ();
2762 string libsMacro
= GetLibsMacro ();
2764 GenerateImportLibraryTargetIfNeeded ();
2766 if ( module
.non_if_data
.files
.size () > 0 )
2770 string dependencies
= objectsMacro
+ " " + linkDepsMacro
;
2773 if ( module
.cplusplus
)
2778 string linkerParameters
= ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
2779 module
.entrypoint
.c_str (),
2780 module
.baseaddress
.c_str () );
2781 GenerateLinkerCommand ( dependencies
,
2789 GeneratePhonyTarget();
2794 MingwRpcServerModuleHandler::MingwRpcServerModuleHandler (
2795 const Module
& module_
)
2797 : MingwModuleHandler ( module_
)
2802 MingwRpcServerModuleHandler::Process ()
2807 MingwRpcClientModuleHandler::MingwRpcClientModuleHandler (
2808 const Module
& module_
)
2810 : MingwModuleHandler ( module_
)
2815 MingwRpcClientModuleHandler::Process ()