2 * Copyright (C) 2005 Casper S. Hornstrup
3 * 2007-2008 Hervé Poussineau
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include "../../pch.h"
23 #include "../../rbuild.h"
25 #include "modulehandler.h"
32 #define CLEAN_FILE(f) clean_files.push_back ( (f).name.length () > 0 ? backend->GetFullName ( f ) : backend->GetFullPath ( f ) );
33 #define IsStaticLibrary( module ) ( ( module.type == StaticLibrary ) || ( module.type == HostStaticLibrary ) )
36 MingwModuleHandler::backend
= NULL
;
38 MingwModuleHandler::fMakefile
= NULL
;
42 const string
& filename
,
43 const string
& prefix
)
45 if ( !prefix
.length() )
48 const char* pfilename
= filename
.c_str();
49 const char* p1
= strrchr ( pfilename
, '/' );
50 const char* p2
= strrchr ( pfilename
, '\\' );
55 out
+= string(pfilename
,p1
-pfilename
) + cSep
;
58 out
+= prefix
+ pfilename
;
63 GetTargetMacro ( const Module
& module
, bool with_dollar
)
65 string
s ( module
.name
);
68 return ssprintf ( "$(%s)", s
.c_str() );
72 MingwModuleHandler::MingwModuleHandler (
73 const Module
& module_
)
80 MingwModuleHandler::~MingwModuleHandler()
85 MingwModuleHandler::SetBackend ( MingwBackend
* backend_
)
91 MingwModuleHandler::SetMakefile ( FILE* f
)
97 MingwModuleHandler::EnablePreCompiledHeaderSupport ()
102 /*static*/ const FileLocation
*
103 MingwModuleHandler::PassThruCacheDirectory (const FileLocation
* file
)
105 switch ( file
->directory
)
107 case SourceDirectory
:
109 case IntermediateDirectory
:
110 backend
->AddDirectoryTarget ( file
->relative_path
, backend
->intermediateDirectory
);
112 case OutputDirectory
:
113 backend
->AddDirectoryTarget ( file
->relative_path
, backend
->outputDirectory
);
115 case InstallDirectory
:
116 backend
->AddDirectoryTarget ( file
->relative_path
, backend
->installDirectory
);
119 throw InvalidOperationException ( __FILE__
,
121 "Invalid directory %d.",
128 /* caller needs to delete the returned object */
130 MingwModuleHandler::GetTargetFilename (
131 const Module
& module
,
132 string_list
* pclean_files
)
134 FileLocation
*target
= new FileLocation ( *module
.output
);
137 string_list
& clean_files
= *pclean_files
;
138 CLEAN_FILE ( *target
);
143 /* caller needs to delete the returned object */
145 MingwModuleHandler::GetImportLibraryFilename (
146 const Module
& module
,
147 string_list
* pclean_files
,
150 FileLocation
*target
;
152 if (module
.HasImportLibrary())
156 target
= new FileLocation ( *module
.delayImportLibrary
->target
);
159 target
= new FileLocation ( *module
.importLibrary
->target
);
162 target
= new FileLocation ( *module
.dependency
);
166 string_list
& clean_files
= *pclean_files
;
167 CLEAN_FILE ( *target
);
172 /* caller needs to delete the returned object */
174 MingwModuleHandler::InstanciateHandler (
175 const Module
& module
,
176 MingwBackend
* backend
)
178 MingwModuleHandler
* handler
;
179 switch ( module
.type
)
182 case HostStaticLibrary
:
190 case EmbeddedTypeLib
:
192 handler
= new MingwModuleHandler( module
);
195 handler
= new MingwBuildToolModuleHandler ( module
);
198 handler
= new MingwKernelModuleHandler ( module
);
201 handler
= new MingwNativeCUIModuleHandler ( module
);
204 handler
= new MingwWin32CUIModuleHandler ( module
);
208 handler
= new MingwWin32GUIModuleHandler ( module
);
212 case KernelModeDriver
:
213 handler
= new MingwKernelModeDLLModuleHandler ( module
);
216 handler
= new MingwNativeDLLModuleHandler ( module
);
219 handler
= new MingwWin32DLLModuleHandler ( module
);
222 handler
= new MingwWin32OCXModuleHandler ( module
);
225 handler
= new MingwBootLoaderModuleHandler ( module
);
228 handler
= new MingwBootProgramModuleHandler ( module
);
231 handler
= new MingwIsoModuleHandler ( module
);
234 handler
= new MingwLiveIsoModuleHandler ( module
);
237 handler
= new MingwTestModuleHandler ( module
);
240 handler
= new MingwAliasModuleHandler ( module
);
243 handler
= new MingwCabinetModuleHandler ( module
);
246 handler
= new MingwElfExecutableModuleHandler ( module
);
249 throw UnknownModuleTypeException (
250 module
.node
.location
,
258 MingwModuleHandler::GetWorkingDirectory () const
264 MingwModuleHandler::GetBasename ( const string
& filename
) const
266 size_t index
= filename
.find_last_of ( '.' );
267 if ( index
!= string::npos
)
268 return filename
.substr ( 0, index
);
273 MingwModuleHandler::GetCompilationUnitDependencies (
274 const CompilationUnit
& compilationUnit
) const
276 if ( compilationUnit
.GetFiles ().size () <= 1 )
278 vector
<string
> sourceFiles
;
279 for ( size_t i
= 0; i
< compilationUnit
.GetFiles ().size (); i
++ )
281 const File
& file
= *compilationUnit
.GetFiles ()[i
];
282 sourceFiles
.push_back ( backend
->GetFullName ( file
.file
) );
284 return string ( " " ) + v2s ( sourceFiles
, 10 );
287 /* caller needs to delete the returned object */
289 MingwModuleHandler::GetModuleArchiveFilename () const
291 if ( IsStaticLibrary ( module
) )
292 return GetTargetFilename ( module
, NULL
);
297 MingwModuleHandler::ReferenceObjects (
298 const Module
& module
)
300 if ( module
.type
== ObjectLibrary
)
302 if ( module
.type
== RpcServer
)
304 if ( module
.type
== RpcClient
)
306 if ( module
.type
== RpcProxy
)
308 if ( module
.type
== IdlHeader
)
310 if ( module
.type
== IdlInterface
)
312 if ( module
.type
== MessageHeader
)
318 MingwModuleHandler::OutputCopyCommand ( const FileLocation
& source
,
319 const FileLocation
& destination
)
321 fprintf ( fMakefile
, "# OUTPUT COPY COMMAND\n" );
325 "\t${cp} %s %s 1>$(NUL)\n",
326 backend
->GetFullName ( source
).c_str (),
327 backend
->GetFullName ( *PassThruCacheDirectory ( &destination
) ).c_str () );
331 MingwModuleHandler::OutputCopyCommandSingle ( const FileLocation
& source
,
332 const FileLocation
& destination
)
336 backend
->GetFullName ( *PassThruCacheDirectory ( &destination
) ).c_str (),
337 backend
->GetFullName ( source
).c_str () );
341 "\t${cp} %s %s 1>$(NUL)\n",
342 backend
->GetFullName ( source
).c_str (),
343 backend
->GetFullName ( *PassThruCacheDirectory ( &destination
) ).c_str () );
347 MingwModuleHandler::GetImportLibraryDependency (
348 const Module
& importedModule
,
352 if ( ReferenceObjects ( importedModule
) )
354 const vector
<CompilationUnit
*>& compilationUnits
= importedModule
.non_if_data
.compilationUnits
;
357 dep
= GetTargetMacro ( importedModule
);
358 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
360 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
361 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
362 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, importedModule
);
363 if ( GetExtension ( *objectFilename
) == ".h" )
364 dep
+= ssprintf ( " $(%s_HEADERS)", importedModule
.name
.c_str () );
365 else if ( GetExtension ( *objectFilename
) == ".rc" )
366 dep
+= ssprintf ( " $(%s_MCHEADERS)", importedModule
.name
.c_str () );
371 const FileLocation
*library_target
= GetImportLibraryFilename ( importedModule
, NULL
, delayimp
);
372 dep
= backend
->GetFullName ( *library_target
);
373 delete library_target
;
376 if ( IsStaticLibrary ( importedModule
) || importedModule
.type
== ObjectLibrary
)
378 const std::vector
<Library
*>& libraries
= importedModule
.non_if_data
.libraries
;
380 for ( size_t i
= 0; i
< libraries
.size (); ++ i
)
383 dep
+= GetImportLibraryDependency ( *libraries
[i
]->importedModule
, libraries
[i
]->delayimp
);
391 MingwModuleHandler::GetTargets ( const Module
& dependencyModule
,
392 string_list
& targets
)
394 if ( dependencyModule
.invocations
.size () > 0 )
396 for ( size_t i
= 0; i
< dependencyModule
.invocations
.size (); i
++ )
398 Invoke
& invoke
= *dependencyModule
.invocations
[i
];
399 invoke
.GetTargets ( targets
);
403 targets
.push_back ( GetImportLibraryDependency ( dependencyModule
, false ) );
407 MingwModuleHandler::GetModuleDependencies (
408 string_list
& dependencies
)
410 size_t iend
= module
.dependencies
.size ();
415 for ( size_t i
= 0; i
< iend
; i
++ )
417 const Dependency
& dependency
= *module
.dependencies
[i
];
418 const Module
& dependencyModule
= *dependency
.dependencyModule
;
419 GetTargets ( dependencyModule
,
422 vector
<FileLocation
> v
;
423 GetDefinitionDependencies ( v
);
425 for ( size_t i
= 0; i
< v
.size (); i
++ )
427 const FileLocation
& file
= v
[i
];
428 dependencies
.push_back ( backend
->GetFullName ( file
) );
432 /* caller needs to delete the returned object */
434 MingwModuleHandler::GetObjectFilename (
435 const FileLocation
* sourceFile
,
436 const Module
& module
) const
438 DirectoryLocation destination_directory
;
440 string extension
= GetExtension ( *sourceFile
);
442 if ( module
.type
== BootSector
)
443 return new FileLocation ( *module
.output
);
444 else if (extension
== ".rc")
445 newExtension
= "_" + module
.name
+ ".coff";
446 else if (extension
== ".mc")
447 newExtension
= ".rc";
448 else if (extension
== ".idl")
450 if ( module
.type
== RpcServer
)
451 newExtension
= "_s.o";
452 else if ( module
.type
== RpcClient
)
453 newExtension
= "_c.o";
454 else if ( module
.type
== RpcProxy
)
455 newExtension
= "_p.o";
456 else if ( module
.type
== IdlInterface
)
457 newExtension
= "_i.o";
462 newExtension
= "_" + module
.name
+ ".o";
464 if ( module
.type
== BootSector
)
465 destination_directory
= OutputDirectory
;
467 destination_directory
= IntermediateDirectory
;
469 const FileLocation
*obj_file
= new FileLocation(
470 destination_directory
,
471 sourceFile
->relative_path
,
472 ReplaceExtension ( sourceFile
->name
, newExtension
) );
473 PassThruCacheDirectory ( obj_file
);
479 MingwModuleHandler::GetModuleCleanTarget ( const Module
& module
) const
481 return module
.name
+ "_clean";
485 MingwModuleHandler::GetReferencedObjectLibraryModuleCleanTargets ( vector
<string
>& moduleNames
) const
487 for ( size_t i
= 0; i
< module
.non_if_data
.libraries
.size (); i
++ )
489 Library
& library
= *module
.non_if_data
.libraries
[i
];
490 if ( library
.importedModule
->type
== ObjectLibrary
)
491 moduleNames
.push_back ( GetModuleCleanTarget ( *library
.importedModule
) );
496 MingwModuleHandler::GenerateCleanTarget () const
498 if ( module
.type
== Alias
)
501 fprintf ( fMakefile
, "# CLEAN TARGET\n" );
503 ".PHONY: %s_clean\n",
504 module
.name
.c_str() );
505 vector
<string
> referencedModuleNames
;
506 GetReferencedObjectLibraryModuleCleanTargets ( referencedModuleNames
);
509 GetModuleCleanTarget ( module
).c_str(),
510 v2s ( referencedModuleNames
, 10 ).c_str () );
511 for ( size_t i
= 0; i
< clean_files
.size(); i
++ )
513 if ( ( i
+ 1 ) % 10 == 9 )
514 fprintf ( fMakefile
, " 2>$(NUL)\n\t-@${rm}" );
515 fprintf ( fMakefile
, " %s", clean_files
[i
].c_str() );
517 fprintf ( fMakefile
, " 2>$(NUL)\n" );
519 // Clean files generated by external rules
520 fprintf ( fMakefile
, "\t-@${rm} $(%s_CLEANFILES) 2>$(NUL)\n", module
.name
.c_str() );
522 if( ProxyMakefile::GenerateProxyMakefile(module
) )
524 DirectoryLocation root
;
526 if ( backend
->configuration
.GenerateProxyMakefilesInSourceTree
)
527 root
= SourceDirectory
;
529 root
= OutputDirectory
;
531 FileLocation
proxyMakefile ( root
,
532 module
.output
->relative_path
,
534 fprintf ( fMakefile
, "\t-@${rm} %s 2>$(NUL)\n",
535 backend
->GetFullName ( proxyMakefile
).c_str () );
538 fprintf ( fMakefile
, "clean: %s_clean\n\n", module
.name
.c_str() );
542 MingwModuleHandler::GenerateInstallTarget () const
544 if ( !module
.install
)
546 fprintf ( fMakefile
, "# INSTALL TARGET\n" );
547 fprintf ( fMakefile
, ".PHONY: %s_install\n", module
.name
.c_str() );
550 module
.name
.c_str (),
551 backend
->GetFullName ( *module
.install
).c_str () );
555 MingwModuleHandler::GenerateDependsTarget () const
557 fprintf ( fMakefile
, "# DEPENDS TARGET\n" );
559 ".PHONY: %s_depends\n",
560 module
.name
.c_str() );
562 "%s_depends: $(RBUILD_TARGET)\n",
563 module
.name
.c_str () );
565 "\t$(ECHO_RBUILD)\n" );
567 "\t$(Q)$(RBUILD_TARGET) $(RBUILD_FLAGS) -dm%s mingw\n",
568 module
.name
.c_str () );
572 const char * const CompilerPrefixTable
[ CompilerTypesCount
] =
584 MingwModuleHandler::GenerateParameters (
586 const char* assignmentOperation
,
587 const IfableData
& data
)
589 for ( unsigned type
= CompilerTypeCC
; type
< CompilerTypesCount
; ++ type
)
591 CompilerType compiler
= static_cast < CompilerType
> ( type
);
594 std::string includes
= GenerateIncludeParametersFromVector ( data
.includes
, compiler
);
596 if ( includes
.size() )
599 "%s_%sINCLUDES%s%s\n",
601 CompilerPrefixTable
[ compiler
],
607 std::string defines
= GenerateDefineParametersFromVector ( data
.defines
, compiler
);
609 if ( defines
.size() )
612 "%s_%sDEFINES%s%s\n",
614 CompilerPrefixTable
[ compiler
],
620 std::string flags
= GenerateCompilerParametersFromVector ( data
.compilerFlags
, compiler
);
627 CompilerPrefixTable
[ compiler
],
635 MingwModuleHandler::GenerateGccDefineParametersFromVector (
636 const vector
<Define
*>& defines
,
637 set
<string
>& used_defs
)
641 for ( size_t i
= 0; i
< defines
.size (); i
++ )
643 Define
& define
= *defines
[i
];
644 if (used_defs
.find(define
.name
) != used_defs
.end())
648 if (parameters
.length () > 0)
651 parameters
+= define
.name
;
653 if (parameters
.length () > 0)
655 if (define
.arguments
.length ())
656 parameters
+= "$(QT)";
658 parameters
+= define
.name
;
659 parameters
+= define
.arguments
;
660 if (define
.value
.length () > 0)
663 parameters
+= define
.value
;
665 if (define
.arguments
.length ())
666 parameters
+= "$(QT)";
667 used_defs
.insert(used_defs
.begin(),define
.name
);
673 MingwModuleHandler::GenerateDefineParametersFromVector (
674 const std::vector
<Define
*>& defines
,
675 CompilerType compiler
)
679 for ( size_t i
= 0; i
< defines
.size (); i
++ )
681 Define
& define
= *defines
[i
];
682 if (!define
.IsCompilerSet (compiler
))
686 if (parameters
.length () > 0)
689 parameters
+= define
.name
;
691 if (parameters
.length () > 0)
693 if (define
.arguments
.length ())
694 parameters
+= "$(QT)";
696 parameters
+= define
.name
;
697 parameters
+= define
.arguments
;
698 if (define
.value
.length () > 0)
701 parameters
+= define
.value
;
703 if (define
.arguments
.length ())
704 parameters
+= "$(QT)";
710 MingwModuleHandler::ConcatenatePaths (
712 const string
& path2
) const
714 if ( ( path1
.length () == 0 ) || ( path1
== "." ) || ( path1
== "./" ) )
716 if ( path1
[path1
.length ()] == cSep
)
717 return path1
+ path2
;
719 return path1
+ cSep
+ path2
;
723 MingwModuleHandler::GenerateIncludeParametersFromVector ( const vector
<Include
*>& includes
, const CompilerType type
)
725 string parameters
, path_prefix
;
726 for ( size_t i
= 0; i
< includes
.size (); i
++ )
728 Include
& include
= *includes
[i
];
729 if ( include
.IsCompilerSet( type
) )
730 parameters
+= " -I" + backend
->GetFullPath ( *include
.directory
);
736 MingwModuleHandler::GenerateCompilerParametersFromVector ( const vector
<CompilerFlag
*>& compilerFlags
, const CompilerType type
)
739 for ( size_t i
= 0; i
< compilerFlags
.size (); i
++ )
741 CompilerFlag
& compilerFlag
= *compilerFlags
[i
];
742 if ( compilerFlag
.IsCompilerSet( type
) )
743 parameters
+= " " + compilerFlag
.flag
;
749 MingwModuleHandler::GenerateLinkerParametersFromVector ( const vector
<LinkerFlag
*>& linkerFlags
) const
752 for ( size_t i
= 0; i
< linkerFlags
.size (); i
++ )
754 LinkerFlag
& linkerFlag
= *linkerFlags
[i
];
755 if ( parameters
.length () > 0 )
757 parameters
+= linkerFlag
.flag
;
763 MingwModuleHandler::GenerateImportLibraryDependenciesFromVector (
764 const vector
<Library
*>& libraries
)
766 string
dependencies ( "" );
768 for ( size_t i
= 0; i
< libraries
.size (); i
++ )
770 if ( wrap_count
++ == 5 )
771 dependencies
+= " \\\n\t\t", wrap_count
= 0;
772 else if ( dependencies
.size () > 0 )
774 dependencies
+= GetImportLibraryDependency ( *libraries
[i
]->importedModule
, libraries
[i
]->delayimp
);
780 MingwModuleHandler::GenerateLinkerParameters () const
782 return GenerateLinkerParametersFromVector ( module
.linkerFlags
);
786 MingwModuleHandler::GenerateMacros (
787 const char* assignmentOperation
,
788 const IfableData
& data
,
789 const vector
<LinkerFlag
*>* linkerFlags
,
790 set
<const Define
*>& used_defs
)
792 if ( linkerFlags
!= NULL
)
794 string linkerParameters
= GenerateLinkerParametersFromVector ( *linkerFlags
);
795 if ( linkerParameters
.size () > 0 )
800 linkerflagsMacro
.c_str (),
802 linkerParameters
.c_str() );
806 if ( data
.libraries
.size () > 0 )
808 // Check if host and target modules are not mixed up
809 HostType current
= ModuleHandlerInformations
[module
.type
].DefaultHost
;
810 std::vector
<Library
*>::const_iterator it
;
811 for ( it
= data
.libraries
.begin(); it
!= data
.libraries
.end(); ++it
)
813 HostType imported
= ModuleHandlerInformations
[(*it
)->importedModule
->type
].DefaultHost
;
814 if (current
!= imported
)
816 throw InvalidOperationException ( __FILE__
,
818 "Module '%s' imports module '%s', which is not of the right type",
819 module
.name
.c_str (),
820 (*it
)->importedModule
->name
.c_str () );
824 string deps
= GenerateImportLibraryDependenciesFromVector ( data
.libraries
);
825 if ( deps
.size () > 0 )
838 MingwModuleHandler::CleanupCompilationUnitVector ( vector
<CompilationUnit
*>& compilationUnits
)
840 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
841 delete compilationUnits
[i
];
845 MingwModuleHandler::GetModuleSpecificCompilationUnits ( vector
<CompilationUnit
*>& compilationUnits
)
850 MingwModuleHandler::GenerateSourceMacros (
851 const IfableData
& data
)
855 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
856 vector
<const FileLocation
*> headers
;
857 if ( compilationUnits
.size () > 0 )
862 sourcesMacro
.c_str () );
863 for ( i
= 0; i
< compilationUnits
.size(); i
++ )
865 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
866 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
870 ( i
%10 == 9 ? " \\\n\t" : " " ),
871 backend
->GetFullName ( compilationName
).c_str () );
873 fprintf ( fMakefile
, "\n" );
876 vector
<CompilationUnit
*> sourceCompilationUnits
;
877 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
878 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
880 const FileLocation
& compilationName
= sourceCompilationUnits
[i
]->GetFilename ();
884 sourcesMacro
.c_str(),
885 backend
->GetFullName ( compilationName
).c_str () );
887 CleanupCompilationUnitVector ( sourceCompilationUnits
);
891 MingwModuleHandler::GenerateObjectMacros (
892 const IfableData
& data
)
895 const char* assignmentOperation
= "=";
897 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
898 vector
<const FileLocation
*> headers
;
899 vector
<const FileLocation
*> mcheaders
;
900 vector
<const FileLocation
*> mcresources
;
901 if ( compilationUnits
.size () > 0 )
903 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
905 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
906 if ( compilationUnit
.IsFirstFile () )
908 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
909 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
912 objectsMacro
.c_str(),
913 backend
->GetFullName ( *object_file
).c_str () );
915 assignmentOperation
= "+=";
922 objectsMacro
.c_str (),
923 assignmentOperation
);
924 for ( i
= 0; i
< compilationUnits
.size(); i
++ )
926 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
927 if ( !compilationUnit
.IsFirstFile () )
929 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
930 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, module
);
931 if ( GetExtension ( *objectFilename
) == ".h" )
932 headers
.push_back ( objectFilename
);
933 else if ( GetExtension ( *objectFilename
) == ".rc" )
935 const FileLocation
*headerFilename
= GetMcHeaderFilename ( &compilationUnit
.GetFilename () );
936 mcheaders
.push_back ( headerFilename
);
937 mcresources
.push_back ( objectFilename
);
944 ( i
%10 == 9 ? " \\\n\t" : " " ),
945 backend
->GetFullName ( *objectFilename
).c_str () );
946 delete objectFilename
;
950 fprintf ( fMakefile
, "\n" );
952 if ( headers
.size () > 0 )
957 module
.name
.c_str (),
958 assignmentOperation
);
959 for ( i
= 0; i
< headers
.size (); i
++ )
964 ( i
%10 == 9 ? " \\\n\t" : " " ),
965 backend
->GetFullName ( *headers
[i
] ).c_str () );
968 fprintf ( fMakefile
, "\n" );
971 if ( mcheaders
.size () > 0 )
976 module
.name
.c_str (),
977 assignmentOperation
);
978 for ( i
= 0; i
< mcheaders
.size (); i
++ )
983 ( i
%10 == 9 ? " \\\n\t" : " " ),
984 backend
->GetFullName ( *mcheaders
[i
] ).c_str () );
987 fprintf ( fMakefile
, "\n" );
990 if ( mcresources
.size () > 0 )
995 module
.name
.c_str (),
996 assignmentOperation
);
997 for ( i
= 0; i
< mcresources
.size (); i
++ )
1002 ( i
%10 == 9 ? " \\\n\t" : " " ),
1003 backend
->GetFullName ( *mcresources
[i
] ).c_str () );
1004 delete mcresources
[i
];
1006 fprintf ( fMakefile
, "\n" );
1009 vector
<CompilationUnit
*> sourceCompilationUnits
;
1010 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
1011 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
1013 const FileLocation
& compilationName
= sourceCompilationUnits
[i
]->GetFilename ();
1014 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
1018 objectsMacro
.c_str(),
1019 backend
->GetFullName ( *object_file
).c_str () );
1022 CleanupCompilationUnitVector ( sourceCompilationUnits
);
1024 if ( IsSpecDefinitionFile() )
1026 const FileLocation
*stubs_file
= new FileLocation(
1027 IntermediateDirectory
,
1028 module
.importLibrary
->source
->relative_path
,
1029 ReplaceExtension ( module
.importLibrary
->source
->name
, "_" + module
.name
+ ".stubs.o" ) );
1034 objectsMacro
.c_str(),
1035 backend
->GetFullName ( *stubs_file
).c_str () );
1040 if ( module
.type
== RpcProxy
)
1042 const FileLocation
*dlldata_file
= GetDlldataFilename();
1047 objectsMacro
.c_str(),
1048 ReplaceExtension ( backend
->GetFullName ( *dlldata_file
), ".o" ).c_str() );
1050 delete dlldata_file
;
1055 MingwModuleHandler::GetDlldataFilename() const
1057 std::string dlldata_path
= "";
1058 size_t dlldata_path_len
= module
.xmlbuildFile
.find_last_of(cSep
);
1060 if ( dlldata_path_len
!= std::string::npos
&& dlldata_path_len
!= 0 )
1061 dlldata_path
= module
.xmlbuildFile
.substr(0, dlldata_path_len
);
1063 return new FileLocation( IntermediateDirectory
, dlldata_path
, module
.name
+ ".dlldata.c" );
1067 MingwModuleHandler::GetPrecompiledHeaderPath () const
1069 if ( !module
.pch
|| !use_pch
)
1071 return new FileLocation ( IntermediateDirectory
,
1072 module
.pch
->file
->relative_path
,
1073 ".gch_" + module
.name
);
1077 MingwModuleHandler::GetPrecompiledHeaderFilename () const
1079 if ( !module
.pch
|| !use_pch
)
1081 return new FileLocation ( IntermediateDirectory
,
1082 module
.pch
->file
->relative_path
+ "/.gch_" + module
.name
,
1083 module
.pch
->file
->name
+ ".gch" );
1086 Rule
windresRule ( "$(eval $(call RBUILD_WRC_RULE,$(module_name),$(source),$(dependencies),$(compiler_flags)))\n",
1087 "$(intermediate_path_unique).coff",
1088 "$(intermediate_path_unique).res",
1089 "$(intermediate_path_unique).res.d",
1090 "$(intermediate_dir)$(SEP)", NULL
);
1091 Rule
winebuildPRule ( "$(eval $(call RBUILD_WINEBUILD_WITH_CPP_RULE,$(module_name),$(source),$(dependencies),$(compiler_flags),$(module_dllname)))\n",
1092 "$(intermediate_path_unique).spec",
1093 "$(intermediate_path_unique).spec.d",
1094 "$(intermediate_path_unique).auto.def",
1095 "$(intermediate_path_unique).stubs.c",
1096 "$(intermediate_path_unique).stubs.o",
1097 "$(intermediate_path_unique).stubs.o.d",
1098 "$(intermediate_dir)$(SEP)", NULL
);
1099 Rule
winebuildRule ( "$(eval $(call RBUILD_WINEBUILD_RULE,$(module_name),$(source),$(dependencies),$(compiler_flags),$(module_dllname)))\n",
1100 "$(intermediate_path_unique).auto.def",
1101 "$(intermediate_path_unique).stubs.c",
1102 "$(intermediate_path_unique).stubs.o",
1103 "$(intermediate_path_unique).stubs.o.d",
1104 "$(intermediate_dir)$(SEP)", NULL
);
1105 Rule
gasRule ( "$(eval $(call RBUILD_GAS_RULE,$(module_name),$(source),$(dependencies),$(compiler_flags)))\n",
1106 "$(intermediate_path_unique).o",
1107 "$(intermediate_path_unique).o.d", NULL
);
1108 Rule
gccRule ( "$(eval $(call RBUILD_CC_RULE,$(module_name),$(source),$(dependencies),$(compiler_flags)))\n",
1109 "$(intermediate_path_unique).o",
1110 "$(intermediate_path_unique).o.d", NULL
);
1111 Rule
gccHostRule ( "$(eval $(call RBUILD_HOST_GCC_RULE,$(module_name),$(source),$(dependencies),$(compiler_flags)))\n",
1112 "$(intermediate_path_unique).o", NULL
);
1113 Rule
gppRule ( "$(eval $(call RBUILD_CXX_RULE,$(module_name),$(source),$(dependencies),$(compiler_flags)))\n",
1114 "$(intermediate_path_unique).o",
1115 "$(intermediate_path_unique).o.d", NULL
);
1116 Rule
gppHostRule ( "$(eval $(call RBUILD_HOST_GPP_RULE,$(module_name),$(source),$(dependencies),$(compiler_flags)))\n",
1117 "$(intermediate_path_unique).o", NULL
);
1118 Rule
widlHeaderRule ( "$(eval $(call RBUILD_WIDL_HEADER_RULE,$(module_name),$(source),$(dependencies),$(compiler_flags)))\n",
1119 "$(intermediate_path_noext).h",
1120 "$(intermediate_dir)$(SEP)", NULL
);
1121 Rule
widlServerRule ( "$(eval $(call RBUILD_WIDL_SERVER_RULE,$(module_name),$(source),$(dependencies),$(compiler_flags)))\n",
1122 "$(intermediate_path_noext)_s.h",
1123 "$(intermediate_path_noext)_s.c",
1124 "$(intermediate_path_noext)_s.o",
1125 "$(intermediate_dir)$(SEP)", NULL
);
1126 Rule
widlClientRule ( "$(eval $(call RBUILD_WIDL_CLIENT_RULE,$(module_name),$(source),$(dependencies),$(compiler_flags)))\n",
1127 "$(intermediate_path_noext)_c.h",
1128 "$(intermediate_path_noext)_c.c",
1129 "$(intermediate_path_noext)_c.o",
1130 "$(intermediate_dir)$(SEP)", NULL
);
1131 Rule
widlProxyRule ( "$(eval $(call RBUILD_WIDL_PROXY_RULE,$(module_name),$(source),$(dependencies),$(compiler_flags)))\n",
1132 "$(intermediate_path_noext)_p.h",
1133 "$(intermediate_path_noext)_p.c",
1134 "$(intermediate_path_noext)_p.o",
1135 "$(intermediate_dir)$(SEP)", NULL
);
1136 Rule
widlInterfaceRule ( "$(eval $(call RBUILD_WIDL_INTERFACE_RULE,$(module_name),$(source),$(dependencies),$(compiler_flags)))\n",
1137 "$(intermediate_path_noext)_i.c",
1138 "$(intermediate_path_noext)_i.o",
1139 "$(intermediate_dir)$(SEP)", NULL
);
1140 Rule
widlDlldataRule ( "$(eval $(call RBUILD_WIDL_DLLDATA_RULE,$(module_name),$(source),$(dependencies),$(compiler_flags),$(bare_dependencies)))\n",
1141 "$(intermediate_path_noext).o", NULL
);
1142 Rule
widlTlbRule ( "$(eval $(call RBUILD_WIDL_TLB_RULE,$(module_name),$(source),$(dependencies),$(compiler_flags)))\n",
1143 "$(intermediate_dir)$(SEP)", NULL
);
1144 Rule
pchRule ( "$(eval $(call RBUILD_CC_PCH_RULE,$(module_name),$(source),$(dependencies),$(compiler_flags)))\n",
1145 "$(intermediate_dir)$(SEP).gch_$(module_name)$(SEP)$(source_name).gch",
1146 "$(intermediate_dir)$(SEP).gch_$(module_name)$(SEP)$(source_name).gch.d",
1147 "$(intermediate_dir)$(SEP).gch_$(module_name)$(SEP)", NULL
);
1148 Rule
pchCxxRule ( "$(eval $(call RBUILD_CXX_PCH_RULE,$(module_name),$(source),$(dependencies),$(compiler_flags)))\n",
1149 "$(intermediate_dir)$(SEP).gch_$(module_name)$(SEP)$(source_name).gch",
1150 "$(intermediate_dir)$(SEP).gch_$(module_name)$(SEP)$(source_name).gch.d",
1151 "$(intermediate_dir)$(SEP).gch_$(module_name)$(SEP)", NULL
);
1152 Rule
bootRule ( "$(eval $(call RBUILD_NASM,$(module_name),$(source),$(dependencies),,$(module_output)))\n",
1154 "$(OUTPUT)$(SEP)$(source_dir)$(SEP)", NULL
);
1155 Rule
nasmRule ( "$(eval $(call RBUILD_NASM,$(module_name),$(source),$(dependencies),,$(intermediate_path_unique).o))\n",
1156 "$(intermediate_path_unique).o",
1157 "$(intermediate_dir)$(SEP)", NULL
);
1159 /* TODO: move these to rules.mak */
1160 Rule
wmcRule ( "$(intermediate_path_noext).rc $(INTERMEDIATE)$(SEP)include$(SEP)reactos$(SEP)$(source_name_noext).h: $(wmc_TARGET) $(source) | $(intermediate_dir)\n"
1162 "\t$(Q)$(wmc_TARGET) -i -H $(INTERMEDIATE)$(SEP)include$(SEP)reactos$(SEP)$(source_name_noext).h -o $(intermediate_path_noext).rc $(source)\n",
1163 "$(intermediate_path_noext).rc",
1164 "$(INTERMEDIATE)$(SEP)include$(SEP)reactos$(SEP)$(source_name_noext).h",
1165 "$(intermediate_dir)$(SEP)", NULL
);
1166 /* TODO: if possible, move these to rules.mak */
1167 Rule
arRule1 ( "$(intermediate_path_noext).a: $($(module_name)_OBJS) $(dependencies) | $(intermediate_dir)\n",
1168 "$(intermediate_path_noext).a",
1169 "$(intermediate_dir)$(SEP)", NULL
);
1170 Rule
arRule2 ( "\t$(ECHO_AR)\n"
1171 "\t${ar} -rc $@ $($(module_name)_OBJS)\n",
1173 Rule
arHostRule2 ( "\t$(ECHO_HOSTAR)\n"
1174 "\t${host_ar} -rc $@ $($(module_name)_OBJS)\n",
1177 Rule
emptyRule ( "", NULL
);
1180 MingwModuleHandler::GenerateGccCommand (
1181 const FileLocation
* sourceFile
,
1183 const string
& extraDependencies
)
1185 const FileLocation
*pchFilename
= GetPrecompiledHeaderFilename ();
1186 string dependencies
= extraDependencies
;
1190 dependencies
+= " " + backend
->GetFullName ( *pchFilename
);
1194 /* WIDL generated headers may be used */
1195 vector
<FileLocation
> rpcDependencies
;
1196 GetRpcHeaderDependencies ( rpcDependencies
);
1197 if ( rpcDependencies
.size () > 0 )
1198 dependencies
+= " " + v2s ( backend
, rpcDependencies
, 5 );
1200 rule
->Execute ( fMakefile
, backend
, module
, sourceFile
, clean_files
, dependencies
);
1204 MingwModuleHandler::GetPropertyValue ( const Module
& module
, const std::string
& name
)
1206 const Property
* property
= module
.project
.LookupProperty(name
);
1209 return property
->value
;
1211 return string ( "" );
1214 /* caller needs to delete the returned object */
1216 MingwModuleHandler::GetRpcServerHeaderFilename ( const FileLocation
*base
) const
1218 string newname
= GetBasename ( base
->name
) + "_s.h";
1219 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1222 /* caller needs to delete the returned object */
1224 MingwModuleHandler::GetRpcClientHeaderFilename ( const FileLocation
*base
) const
1226 string newname
= GetBasename ( base
->name
) + "_c.h";
1227 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1230 /* caller needs to delete the returned object */
1232 MingwModuleHandler::GetRpcProxyHeaderFilename ( const FileLocation
*base
) const
1234 string newname
= GetBasename ( base
->name
) + "_p.h";
1235 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1238 /* caller needs to delete the returned object */
1240 MingwModuleHandler::GetIdlHeaderFilename ( const FileLocation
*base
) const
1242 string newname
= GetBasename ( base
->name
) + ".h";
1243 return new FileLocation ( IntermediateDirectory
, base
->relative_path
, newname
);
1246 /* caller needs to delete the returned object */
1248 MingwModuleHandler::GetMcHeaderFilename ( const FileLocation
*base
) const
1250 string newname
= GetBasename ( base
->name
) + ".h";
1251 return new FileLocation ( IntermediateDirectory
, "include/reactos" , newname
);
1255 MingwModuleHandler::GenerateCommands (
1256 const CompilationUnit
& compilationUnit
,
1257 const string
& extraDependencies
)
1259 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
1260 string extension
= GetExtension ( sourceFile
);
1261 std::transform ( extension
.begin (), extension
.end (), extension
.begin (), tolower
);
1270 { HostDontCare
, TypeDontCare
, ".s", &gasRule
},
1271 { HostDontCare
, BootSector
, ".asm", &bootRule
},
1272 { HostDontCare
, TypeDontCare
, ".asm", &nasmRule
},
1273 { HostDontCare
, TypeDontCare
, ".rc", &windresRule
},
1274 { HostDontCare
, TypeDontCare
, ".mc", &wmcRule
},
1275 { HostDontCare
, RpcServer
, ".idl", &widlServerRule
},
1276 { HostDontCare
, RpcClient
, ".idl", &widlClientRule
},
1277 { HostDontCare
, RpcProxy
, ".idl", &widlProxyRule
},
1278 { HostDontCare
, IdlInterface
, ".idl", &widlInterfaceRule
},
1279 { HostDontCare
, EmbeddedTypeLib
, ".idl", &widlTlbRule
},
1280 { HostDontCare
, TypeDontCare
, ".idl", &widlHeaderRule
},
1281 { HostTrue
, TypeDontCare
, ".c", &gccHostRule
},
1282 { HostTrue
, TypeDontCare
, ".cc", &gppHostRule
},
1283 { HostTrue
, TypeDontCare
, ".cpp", &gppHostRule
},
1284 { HostTrue
, TypeDontCare
, ".cxx", &gppHostRule
},
1285 { HostFalse
, TypeDontCare
, ".c", &gccRule
},
1286 { HostFalse
, TypeDontCare
, ".cc", &gppRule
},
1287 { HostFalse
, TypeDontCare
, ".cpp", &gppRule
},
1288 { HostFalse
, TypeDontCare
, ".cxx", &gppRule
},
1289 { HostFalse
, Cabinet
, ".*", &emptyRule
}
1292 Rule
*customRule
= NULL
;
1294 for ( i
= 0; i
< sizeof ( rules
) / sizeof ( rules
[0] ); i
++ )
1296 if ( rules
[i
].host
!= HostDontCare
&& rules
[i
].host
!= ModuleHandlerInformations
[module
.type
].DefaultHost
)
1298 if ( rules
[i
].type
!= TypeDontCare
&& rules
[i
].type
!= module
.type
)
1300 if ( rules
[i
].extension
!= extension
&& rules
[i
].extension
!= ".*")
1302 customRule
= rules
[i
].rule
;
1306 if ( extension
== ".c" || extension
== ".cc" || extension
== ".cpp" || extension
== ".cxx" )
1308 GenerateGccCommand ( &sourceFile
,
1310 GetCompilationUnitDependencies ( compilationUnit
) + extraDependencies
);
1312 else if ( customRule
)
1313 customRule
->Execute ( fMakefile
, backend
, module
, &sourceFile
, clean_files
);
1316 throw InvalidOperationException ( __FILE__
,
1318 "Unsupported filename extension '%s' in file '%s'",
1320 backend
->GetFullName ( sourceFile
).c_str () );
1325 MingwModuleHandler::GenerateBuildMapCode ( const FileLocation
*mapTarget
)
1327 fprintf ( fMakefile
, "# BUILD MAP CODE\n" );
1329 fprintf ( fMakefile
,
1330 "ifeq ($(ROS_BUILDMAP),full)\n" );
1332 FileLocation
mapFilename ( OutputDirectory
,
1333 module
.output
->relative_path
,
1334 GetBasename ( module
.output
->name
) + ".map" );
1335 CLEAN_FILE ( mapFilename
);
1337 fprintf ( fMakefile
,
1338 "\t$(ECHO_OBJDUMP)\n" );
1339 fprintf ( fMakefile
,
1340 "\t$(Q)${objdump} -d -S %s > %s\n",
1341 mapTarget
? backend
->GetFullName ( *mapTarget
).c_str () : "$@",
1342 backend
->GetFullName ( mapFilename
).c_str () );
1344 fprintf ( fMakefile
,
1346 fprintf ( fMakefile
,
1347 "ifeq ($(ROS_BUILDMAP),yes)\n" );
1349 fprintf ( fMakefile
,
1351 fprintf ( fMakefile
,
1352 "\t$(Q)${nm} --numeric-sort %s > %s\n",
1353 mapTarget
? backend
->GetFullName ( *mapTarget
).c_str () : "$@",
1354 backend
->GetFullName ( mapFilename
).c_str () );
1356 fprintf ( fMakefile
,
1359 fprintf ( fMakefile
,
1364 MergeStringVector ( const Backend
* backend
,
1365 const vector
<FileLocation
>& input
,
1366 vector
<string
>& output
)
1370 int wrap_count
= -1;
1371 for ( size_t i
= 0; i
< input
.size (); i
++ )
1373 if ( wrap_count
++ == wrap_at
)
1375 output
.push_back ( s
);
1379 else if ( s
.size () > 0)
1381 s
+= backend
->GetFullName ( input
[i
] );
1383 if ( s
.length () > 0 )
1384 output
.push_back ( s
);
1388 MingwModuleHandler::GetObjectsVector ( const IfableData
& data
,
1389 vector
<FileLocation
>& objectFiles
) const
1391 for ( size_t i
= 0; i
< data
.compilationUnits
.size (); i
++ )
1393 CompilationUnit
& compilationUnit
= *data
.compilationUnits
[i
];
1394 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1395 const FileLocation
*object_file
= GetObjectFilename ( &compilationName
, module
);
1396 objectFiles
.push_back ( *object_file
);
1402 MingwModuleHandler::GenerateCleanObjectsAsYouGoCode () const
1404 if ( backend
->configuration
.CleanAsYouGo
)
1406 vector
<FileLocation
> objectFiles
;
1407 GetObjectsVector ( module
.non_if_data
,
1409 vector
<string
> lines
;
1410 MergeStringVector ( backend
,
1413 for ( size_t i
= 0; i
< lines
.size (); i
++ )
1415 fprintf ( fMakefile
,
1416 "\t-@${rm} %s 2>$(NUL)\n",
1417 lines
[i
].c_str () );
1423 MingwModuleHandler::GenerateLinkerCommand () const
1425 string definitionFilename
;
1427 const FileLocation
*DefinitionFilename
= GetDefinitionFilename ();
1429 if ( DefinitionFilename
) {
1430 definitionFilename
= backend
->GetFullName (*DefinitionFilename
);
1431 delete DefinitionFilename
;
1434 string linkerScriptArgument
;
1435 if ( module
.linkerScript
!= NULL
) {
1436 if ( module
.project
.configuration
.Linker
== GnuLd
)
1437 linkerScriptArgument
= ssprintf ( " -T %s", backend
->GetFullName ( *module
.linkerScript
->file
).c_str () );
1440 "Linker doesn't support linker scripts: linker script %s ignored for module %s\n",
1441 backend
->GetFullName ( *module
.linkerScript
->file
).c_str (),
1442 module
.name
.c_str() );
1445 string extraLibraries
;
1446 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostFalse
) {
1447 if ( module
.cplusplus
) {
1448 switch ( module
.type
)
1455 extraLibraries
= "$$(PROJECT_CXXLIBS)";
1459 extraLibraries
= "$$(PROJECT_CCLIBS)";
1463 extraLibraries
= "$$(PROJECT_CCLIBS)";
1466 delete PassThruCacheDirectory ( new FileLocation ( module
.output
->directory
, module
.output
->relative_path
, "" ) );
1467 delete PassThruCacheDirectory ( new FileLocation ( IntermediateDirectory
, module
.output
->relative_path
, "" ) );
1469 fprintf ( fMakefile
,
1470 "$(eval $(call RBUILD_LINK_RULE,%s,%s,%s,%s,%s,%s,%s))\n",
1471 module
.name
.c_str(),
1472 definitionFilename
.c_str(),
1473 module
.xmlbuildFile
.c_str(),
1474 linkerScriptArgument
.c_str (),
1475 extraLibraries
.c_str(),
1476 module
.GetEntryPoint().c_str(),
1477 module
.baseaddress
.c_str() );
1481 MingwModuleHandler::GenerateObjectFileTargets ( const IfableData
& data
)
1484 string moduleDependencies
;
1486 const vector
<CompilationUnit
*>& compilationUnits
= data
.compilationUnits
;
1487 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
1489 CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
1490 const FileLocation
& compilationName
= compilationUnit
.GetFilename ();
1491 const FileLocation
*objectFilename
= GetObjectFilename ( &compilationName
, module
);
1492 if ( GetExtension ( *objectFilename
) == ".h" )
1493 moduleDependencies
+= ssprintf ( " $(%s_HEADERS)", module
.name
.c_str () );
1494 else if ( GetExtension ( *objectFilename
) == ".rc" )
1495 moduleDependencies
+= ssprintf ( " $(%s_RESOURCES)", module
.name
.c_str () );
1496 delete objectFilename
;
1499 for ( i
= 0; i
< compilationUnits
.size (); i
++ )
1501 GenerateCommands ( *compilationUnits
[i
],
1502 moduleDependencies
);
1505 vector
<CompilationUnit
*> sourceCompilationUnits
;
1506 GetModuleSpecificCompilationUnits ( sourceCompilationUnits
);
1507 for ( i
= 0; i
< sourceCompilationUnits
.size (); i
++ )
1509 GenerateCommands ( *sourceCompilationUnits
[i
],
1510 moduleDependencies
);
1512 CleanupCompilationUnitVector ( sourceCompilationUnits
);
1514 if ( module
.type
== RpcProxy
)
1516 widlDlldataRule
.Execute ( fMakefile
,
1519 GetDlldataFilename(),
1521 ssprintf ( "$(%s_SOURCES)", module
.name
.c_str ()) );
1526 MingwModuleHandler::GenerateObjectFileTargets ()
1528 if ( module
.pch
&& use_pch
)
1531 std::map
<string
, string
> vars
;
1533 /* WIDL generated headers may be used */
1534 string dependencies
;
1535 vector
<FileLocation
> rpcDependencies
;
1536 GetRpcHeaderDependencies ( rpcDependencies
);
1537 if ( rpcDependencies
.size () > 0 )
1538 dependencies
= " " + v2s ( backend
, rpcDependencies
, 5 );
1540 if ( module
.cplusplus
)
1541 pchCxxRule
.Execute ( fMakefile
, backend
, module
, module
.pch
->file
, clean_files
, dependencies
);
1543 pchRule
.Execute ( fMakefile
, backend
, module
, module
.pch
->file
, clean_files
, dependencies
);
1546 GenerateObjectFileTargets ( module
.non_if_data
);
1549 /* caller needs to delete the returned object */
1551 MingwModuleHandler::GenerateArchiveTarget ()
1553 const FileLocation
*archiveFilename
= GetModuleArchiveFilename ();
1555 if ( archiveFilename
== NULL
)
1558 const FileLocation
*definitionFilename
= GetDefinitionFilename ();
1560 fprintf ( fMakefile
, "# ARCHIVE TARGET\n" );
1562 if ( IsStaticLibrary ( module
) && definitionFilename
)
1564 arRule1
.Execute ( fMakefile
,
1569 backend
->GetFullName ( *definitionFilename
).c_str () );
1571 fprintf ( fMakefile
,
1572 "\t${dlltool} --def %s --kill-at --output-lib $@\n",
1573 backend
->GetFullName ( *definitionFilename
).c_str () );
1576 arRule1
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1578 if ( definitionFilename
)
1579 delete definitionFilename
;
1581 if(module
.type
== HostStaticLibrary
)
1582 arHostRule2
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1584 arRule2
.Execute ( fMakefile
, backend
, module
, archiveFilename
, clean_files
);
1586 GenerateCleanObjectsAsYouGoCode ();
1588 fprintf ( fMakefile
, "\n" );
1590 return archiveFilename
;
1594 MingwModuleHandler::GetObjectsMacro ( const Module
& module
)
1596 return ssprintf ( "$(%s_OBJS)",
1597 module
.name
.c_str () );
1601 MingwModuleHandler::GetLibsMacro () const
1603 return ssprintf ( "$(%s_LIBS)", module
.name
.c_str () );
1607 MingwModuleHandler::GetLinkerMacro () const
1609 return ssprintf ( "$(%s_LDFLAGS)",
1610 module
.name
.c_str () );
1614 MingwModuleHandler::GetDebugFormat ()
1616 if (Environment::GetArch() == "amd64")
1624 MingwModuleHandler::GetModuleTargets ( const Module
& module
)
1626 if ( ReferenceObjects ( module
) )
1627 return GetObjectsMacro ( module
);
1630 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
1631 string target
= backend
->GetFullName ( *target_file
).c_str ();
1638 MingwModuleHandler::GenerateSourceMacro ()
1640 sourcesMacro
= ssprintf ( "%s_SOURCES", module
.name
.c_str ());
1642 if ( module
.type
== RpcProxy
|| module
.type
== Cabinet
)
1643 GenerateSourceMacros ( module
.non_if_data
);
1645 // future references to the macro will be to get its values
1646 sourcesMacro
= ssprintf ("$(%s)", sourcesMacro
.c_str ());
1650 MingwModuleHandler::GenerateObjectMacro ()
1652 objectsMacro
= ssprintf ("%s_OBJS", module
.name
.c_str ());
1654 GenerateObjectMacros ( module
.non_if_data
);
1656 // future references to the macro will be to get its values
1657 objectsMacro
= ssprintf ("$(%s)", objectsMacro
.c_str ());
1661 MingwModuleHandler::GenerateTargetMacro ()
1663 fprintf ( fMakefile
,
1665 GetTargetMacro ( module
, false ).c_str (),
1666 GetModuleTargets ( module
).c_str () );
1670 MingwModuleHandler::GetRpcHeaderDependencies (
1671 vector
<FileLocation
>& dependencies
) const
1673 for ( size_t i
= 0; i
< module
.non_if_data
.libraries
.size (); i
++ )
1675 Library
& library
= *module
.non_if_data
.libraries
[i
];
1676 if ( library
.importedModule
->type
== RpcServer
||
1677 library
.importedModule
->type
== RpcClient
||
1678 library
.importedModule
->type
== RpcProxy
||
1679 library
.importedModule
->type
== IdlHeader
)
1681 for ( size_t j
= 0; j
< library
.importedModule
->non_if_data
.compilationUnits
.size (); j
++ )
1683 CompilationUnit
& compilationUnit
= *library
.importedModule
->non_if_data
.compilationUnits
[j
];
1684 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
1685 string extension
= GetExtension ( sourceFile
);
1686 if ( extension
== ".idl" || extension
== ".IDL" )
1688 string basename
= GetBasename ( sourceFile
.name
);
1689 if ( library
.importedModule
->type
== RpcServer
)
1691 const FileLocation
*header
= GetRpcServerHeaderFilename ( &sourceFile
);
1692 dependencies
.push_back ( *header
);
1695 if ( library
.importedModule
->type
== RpcClient
)
1697 const FileLocation
*header
= GetRpcClientHeaderFilename ( &sourceFile
);
1698 dependencies
.push_back ( *header
);
1701 if ( library
.importedModule
->type
== RpcProxy
)
1703 const FileLocation
*header
= GetRpcProxyHeaderFilename ( &sourceFile
);
1704 dependencies
.push_back ( *header
);
1707 if ( library
.importedModule
->type
== IdlHeader
)
1709 const FileLocation
*header
= GetIdlHeaderFilename ( &sourceFile
);
1710 dependencies
.push_back ( *header
);
1720 MingwModuleHandler::GenerateOtherMacros ()
1722 set
<const Define
*> used_defs
;
1724 linkerflagsMacro
= ssprintf ("%s_LDFLAGS", module
.name
.c_str ());
1725 libsMacro
= ssprintf("%s_LIBS", module
.name
.c_str ());
1727 const FileLocation
* pchPath
= GetPrecompiledHeaderPath ();
1731 string pchPathStr
= backend
->GetFullName ( *pchPath
);
1734 fprintf ( fMakefile
,
1735 "%s_%sINCLUDES+= -I%s\n",
1736 module
.name
.c_str(),
1737 CompilerPrefixTable
[CompilerTypeCC
],
1738 pchPathStr
.c_str() );
1740 fprintf ( fMakefile
,
1741 "%s_%sINCLUDES+= -I%s\n",
1742 module
.name
.c_str(),
1743 CompilerPrefixTable
[CompilerTypeCXX
],
1744 pchPathStr
.c_str() );
1747 const char * toolPrefix
= "";
1749 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
)
1750 toolPrefix
= "HOST_";
1752 // FIXME: this is very ugly and generates lots of useless entries
1753 for ( unsigned type
= CompilerTypeCC
; type
< CompilerTypesCount
; ++ type
)
1757 if ( module
.dynamicCRT
)
1758 flags
+= ssprintf ( " $(%s%sFLAG_CRTDLL)", toolPrefix
, CompilerPrefixTable
[type
] );
1760 // FIXME: this duplicates the flag for CPP and C/CXX
1761 if ( !module
.allowWarnings
)
1762 flags
+= ssprintf ( " $(%s%sFLAG_WERROR)", toolPrefix
, CompilerPrefixTable
[type
] );
1764 if ( module
.isUnicode
)
1765 flags
+= ssprintf ( " $(%s%sFLAG_UNICODE)", toolPrefix
, CompilerPrefixTable
[type
] );
1769 fprintf ( fMakefile
,
1771 module
.name
.c_str(),
1772 CompilerPrefixTable
[type
],
1777 GenerateParameters ( module
.name
.c_str(), "+=", module
.non_if_data
);
1782 &module
.linkerFlags
,
1785 fprintf ( fMakefile
, "\n\n" );
1789 MingwModuleHandler::GenerateRules ()
1793 fprintf ( fMakefile
, "# RULES\n" );
1794 string targetMacro
= GetTargetMacro ( module
);
1795 //CLEAN_FILE ( targetMacro );
1796 CLEAN_FILE ( FileLocation ( SourceDirectory
, "", targetMacro
) );
1798 // generate phony target for module name
1799 fprintf ( fMakefile
, ".PHONY: %s\n",
1800 module
.name
.c_str () );
1801 string dependencies
= GetTargetMacro ( module
);
1802 if ( module
.type
== Test
)
1803 dependencies
+= " $(regtests_run_TARGET)";
1804 fprintf ( fMakefile
, "%s: %s\n\n",
1805 module
.name
.c_str (),
1806 dependencies
.c_str () );
1807 if ( module
.type
== Test
)
1809 fprintf ( fMakefile
,
1811 targetMacro
.c_str ());
1814 if ( !ReferenceObjects ( module
) )
1816 const FileLocation
* ar_target
= GenerateArchiveTarget ();
1823 spec
= IsSpecDefinitionFile();
1830 defRule
= &winebuildPRule
;
1832 defRule
= &winebuildRule
;
1834 defRule
->Execute ( fMakefile
, backend
, module
, module
.importLibrary
->source
, clean_files
);
1837 GenerateObjectFileTargets ();
1841 MingwModuleHandler::GetInvocationDependencies (
1842 const Module
& module
,
1843 string_list
& dependencies
)
1845 for ( size_t i
= 0; i
< module
.invocations
.size (); i
++ )
1847 Invoke
& invoke
= *module
.invocations
[i
];
1848 if ( invoke
.invokeModule
== &module
)
1849 /* Protect against circular dependencies */
1851 invoke
.GetTargets ( dependencies
);
1856 MingwModuleHandler::GenerateInvocations () const
1858 if ( module
.invocations
.size () == 0 )
1861 fprintf ( fMakefile
, "# INVOCATIONS\n" );
1863 size_t iend
= module
.invocations
.size ();
1864 for ( size_t i
= 0; i
< iend
; i
++ )
1866 const Invoke
& invoke
= *module
.invocations
[i
];
1868 if ( invoke
.invokeModule
->type
!= BuildTool
)
1870 throw XMLInvalidBuildFileException (
1871 module
.node
.location
,
1872 "Only modules of type buildtool can be invoked." );
1875 string invokeTarget
= module
.GetInvocationTarget ( i
);
1876 string_list invoke_targets
;
1877 assert ( invoke_targets
.size() );
1878 invoke
.GetTargets ( invoke_targets
);
1879 fprintf ( fMakefile
,
1881 invokeTarget
.c_str () );
1882 fprintf ( fMakefile
,
1884 invokeTarget
.c_str () );
1885 size_t j
, jend
= invoke_targets
.size();
1886 for ( j
= 0; j
< jend
; j
++ )
1888 fprintf ( fMakefile
,
1890 invoke_targets
[i
].c_str () );
1892 fprintf ( fMakefile
, "\n\n%s", invoke_targets
[0].c_str () );
1893 for ( j
= 1; j
< jend
; j
++ )
1894 fprintf ( fMakefile
,
1896 invoke_targets
[i
].c_str () );
1897 fprintf ( fMakefile
,
1899 NormalizeFilename ( backend
->GetFullName ( *invoke
.invokeModule
->output
) ).c_str () );
1900 fprintf ( fMakefile
, "\t$(ECHO_INVOKE)\n" );
1901 fprintf ( fMakefile
,
1903 NormalizeFilename ( backend
->GetFullName ( *invoke
.invokeModule
->output
) ).c_str (),
1904 invoke
.GetParameters ().c_str () );
1909 MingwModuleHandler::GetPreconditionDependenciesName () const
1911 return module
.name
+ "_precondition";
1915 MingwModuleHandler::GetDefaultDependencies (
1916 string_list
& dependencies
) const
1918 /* Avoid circular dependency */
1919 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
)
1922 if (module
.name
!= "psdk" &&
1923 module
.name
!= "dxsdk")
1925 dependencies
.push_back ( "$(psdk_TARGET) $(psdk_HEADERS)" );
1926 dependencies
.push_back ( "$(dxsdk_TARGET) $(dxsdk_HEADERS)" );
1929 if (module
.name
!= "errcodes" &&
1930 module
.name
!= "bugcodes" &&
1931 module
.name
!= "ntstatus")
1933 dependencies
.push_back ( "$(errcodes_TARGET) $(ERRCODES_MCHEADERS)" );
1934 dependencies
.push_back ( "$(bugcodes_TARGET) $(BUGCODES_MCHEADERS)" );
1935 dependencies
.push_back ( "$(ntstatus_TARGET) $(NTSTATUS_MCHEADERS)" );
1938 ///* Check if any dependent library relies on the generated headers */
1939 //for ( size_t i = 0; i < module.project.modules.size (); i++ )
1941 // const Module& m = *module.project.modules[i];
1942 // for ( size_t j = 0; j < m.non_if_data.compilationUnits.size (); j++ )
1944 // CompilationUnit& compilationUnit = *m.non_if_data.compilationUnits[j];
1945 // const FileLocation& sourceFile = compilationUnit.GetFilename ();
1946 // string extension = GetExtension ( sourceFile );
1947 // if (extension == ".mc" || extension == ".MC" )
1949 // string dependency = ssprintf ( "$(%s_MCHEADERS)", m.name.c_str () );
1950 // dependencies.push_back ( dependency );
1957 MingwModuleHandler::GeneratePreconditionDependencies ()
1959 fprintf ( fMakefile
, "# PRECONDITION DEPENDENCIES\n" );
1960 string preconditionDependenciesName
= GetPreconditionDependenciesName ();
1961 string_list dependencies
;
1962 GetDefaultDependencies ( dependencies
);
1963 GetModuleDependencies ( dependencies
);
1965 GetInvocationDependencies ( module
, dependencies
);
1967 if ( dependencies
.size() )
1969 fprintf ( fMakefile
,
1971 preconditionDependenciesName
.c_str () );
1972 for ( size_t i
= 0; i
< dependencies
.size(); i
++ )
1973 fprintf ( fMakefile
,
1975 dependencies
[i
].c_str () );
1976 fprintf ( fMakefile
, "\n\n" );
1979 fprintf ( fMakefile
, "\n" );
1983 MingwModuleHandler::IsSpecDefinitionFile () const
1985 if(!module
.importLibrary
)
1988 std::string ext
= GetExtension ( *module
.importLibrary
->source
);
1990 if ( ext
== ".spec" )
1993 if ( ext
== ".pspec" )
1999 /* caller needs to delete the returned object */
2001 MingwModuleHandler::GetDefinitionFilename () const
2003 if ( module
.importLibrary
== NULL
)
2006 if ( IsSpecDefinitionFile () )
2008 return new FileLocation ( IntermediateDirectory
,
2009 module
.importLibrary
->source
->relative_path
,
2010 GetBasename ( module
.importLibrary
->source
->name
) + "_" + module
.name
+ ".auto.def" );
2014 return new FileLocation ( SourceDirectory
,
2015 module
.importLibrary
->source
->relative_path
,
2016 module
.importLibrary
->source
->name
);
2021 MingwModuleHandler::GetSpecObjectDependencies (
2022 vector
<FileLocation
>& dependencies
,
2023 const FileLocation
*file
) const
2025 dependencies
.push_back ( FileLocation ( IntermediateDirectory
,
2026 file
->relative_path
,
2027 GetBasename ( file
->name
) + "_" + module
.name
+ ".stubs.c" ) );
2031 MingwModuleHandler::GetMcObjectDependencies (
2032 vector
<FileLocation
>& dependencies
,
2033 const FileLocation
*file
) const
2035 string basename
= GetBasename ( file
->name
);
2037 FileLocation
defDependency ( IntermediateDirectory
,
2040 dependencies
.push_back ( defDependency
);
2042 FileLocation
stubsDependency ( IntermediateDirectory
,
2043 file
->relative_path
,
2045 dependencies
.push_back ( stubsDependency
);
2049 MingwModuleHandler::GetWidlObjectDependencies (
2050 vector
<FileLocation
>& dependencies
,
2051 const FileLocation
*file
) const
2053 string basename
= GetBasename ( file
->name
);
2054 const FileLocation
*generatedHeaderFilename
= GetRpcServerHeaderFilename ( file
);
2056 FileLocation
serverSourceDependency ( IntermediateDirectory
,
2057 file
->relative_path
,
2058 basename
+ "_s.c" );
2059 dependencies
.push_back ( serverSourceDependency
);
2060 dependencies
.push_back ( *generatedHeaderFilename
);
2062 delete generatedHeaderFilename
;
2066 MingwModuleHandler::GetDefinitionDependencies (
2067 vector
<FileLocation
>& dependencies
) const
2069 const vector
<CompilationUnit
*>& compilationUnits
= module
.non_if_data
.compilationUnits
;
2070 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
2072 const CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
2073 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
2074 string extension
= GetExtension ( sourceFile
);
2076 if (extension
== ".spec" || extension
== ".pspec")
2077 GetSpecObjectDependencies ( dependencies
, &sourceFile
);
2079 if (extension
== ".idl")
2081 if ( ( module
.type
== RpcServer
) || ( module
.type
== RpcClient
) || ( module
.type
== RpcProxy
) )
2082 GetWidlObjectDependencies ( dependencies
, &sourceFile
);
2087 enum DebugSupportType
2094 MingwAddDebugSupportLibraries ( Module
& module
, DebugSupportType type
)
2100 case DebugKernelMode
:
2101 pLibrary
= new Library ( module
, "debugsup_ntoskrnl" );
2105 pLibrary
= new Library ( module
, "debugsup_ntdll" );
2112 module
.non_if_data
.libraries
.push_back(pLibrary
);
2116 MingwAddCRTLibrary( Module
&module
)
2118 const char * crtAttr
= module
.CRT
.c_str ();
2119 const char * crtLib
= NULL
;
2121 if ( stricmp ( crtAttr
, "libc" ) == 0 )
2123 else if ( stricmp ( crtAttr
, "msvcrt" ) == 0 )
2125 else if ( stricmp ( crtAttr
, "libcntpr" ) == 0 )
2126 crtLib
= "libcntpr";
2127 else if ( stricmp ( crtAttr
, "ntdll" ) == 0 )
2132 Library
* pLibrary
= new Library ( module
, std::string ( crtLib
) );
2134 if ( pLibrary
->importedModule
== NULL
)
2136 throw XMLInvalidBuildFileException (
2137 module
.node
.location
,
2138 "module '%s' trying to import non-existant C runtime module '%s'",
2139 module
.name
.c_str(),
2143 module
.non_if_data
.libraries
.push_back ( pLibrary
);
2147 MingwBuildToolModuleHandler::MingwBuildToolModuleHandler ( const Module
& module_
)
2148 : MingwModuleHandler ( module_
)
2153 MingwBuildToolModuleHandler::Process ()
2155 GenerateBuildToolModuleTarget ();
2159 MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ()
2161 string
targetMacro ( GetTargetMacro (module
) );
2162 string objectsMacro
= GetObjectsMacro ( module
);
2163 string libsMacro
= GetLibsMacro ();
2167 fprintf ( fMakefile
, "# BUILD TOOL MODULE TARGET\n" );
2170 if ( module
.cplusplus
)
2171 linker
= "${host_gpp}";
2173 linker
= "${host_gcc}";
2175 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
2176 fprintf ( fMakefile
, "%s: %s %s | %s\n",
2177 targetMacro
.c_str (),
2178 objectsMacro
.c_str (),
2180 backend
->GetFullPath ( *target_file
).c_str () );
2181 fprintf ( fMakefile
, "\t$(ECHO_HOSTLD)\n" );
2182 fprintf ( fMakefile
,
2183 "\t%s %s -o $@ %s %s\n\n",
2185 GetLinkerMacro ().c_str (),
2186 objectsMacro
.c_str (),
2187 libsMacro
.c_str () );
2193 MingwKernelModuleHandler::MingwKernelModuleHandler (
2194 const Module
& module_
)
2196 : MingwModuleHandler ( module_
)
2201 MingwKernelModuleHandler::Process ()
2203 GenerateKernelModuleTarget ();
2207 MingwKernelModuleHandler::GenerateKernelModuleTarget ()
2210 GenerateLinkerCommand ();
2214 MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler (
2215 const Module
& module_
)
2217 : MingwModuleHandler ( module_
)
2223 MingwKernelModeDLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2225 MingwAddCRTLibrary ( module
);
2226 MingwAddDebugSupportLibraries ( module
, DebugKernelMode
);
2230 MingwKernelModeDLLModuleHandler::Process ()
2232 GenerateKernelModeDLLModuleTarget ();
2236 MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ()
2239 GenerateLinkerCommand ();
2243 MingwNativeDLLModuleHandler::MingwNativeDLLModuleHandler (
2244 const Module
& module_
)
2246 : MingwModuleHandler ( module_
)
2251 MingwNativeDLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2253 MingwAddCRTLibrary ( module
);
2254 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2258 MingwNativeDLLModuleHandler::Process ()
2260 GenerateNativeDLLModuleTarget ();
2264 MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ()
2267 GenerateLinkerCommand ();
2271 MingwNativeCUIModuleHandler::MingwNativeCUIModuleHandler (
2272 const Module
& module_
)
2274 : MingwModuleHandler ( module_
)
2279 MingwNativeCUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2281 MingwAddCRTLibrary ( module
);
2282 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2286 MingwNativeCUIModuleHandler::Process ()
2288 GenerateNativeCUIModuleTarget ();
2292 MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ()
2295 GenerateLinkerCommand ();
2299 MingwWin32DLLModuleHandler::MingwWin32DLLModuleHandler (
2300 const Module
& module_
)
2302 : MingwModuleHandler ( module_
)
2306 MingwWin32OCXModuleHandler::MingwWin32OCXModuleHandler (
2307 const Module
& module_
)
2309 : MingwModuleHandler ( module_
)
2314 MingwAddImplicitLibraries( Module
&module
)
2318 if ( module
.type
!= Win32DLL
2319 && module
.type
!= Win32OCX
2320 && module
.type
!= Win32CUI
2321 && module
.type
!= Win32GUI
2322 && module
.type
!= Win32SCR
)
2327 if ( module
.isDefaultEntryPoint
)
2329 if ( module
.IsDLL () )
2331 //pLibrary = new Library ( module, "__mingw_dllmain" );
2332 //module.non_if_data.libraries.insert ( module.non_if_data.libraries.begin(), pLibrary );
2336 pLibrary
= new Library ( module
, module
.isUnicode
? "mingw_wmain" : "mingw_main" );
2337 module
.non_if_data
.libraries
.insert ( module
.non_if_data
.libraries
.begin(), pLibrary
);
2341 pLibrary
= new Library ( module
, "mingw_common" );
2342 module
.non_if_data
.libraries
.push_back ( pLibrary
);
2344 MingwAddCRTLibrary ( module
);
2345 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2349 MingwWin32DLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2351 MingwAddImplicitLibraries ( module
);
2355 MingwWin32DLLModuleHandler::Process ()
2357 GenerateWin32DLLModuleTarget ();
2361 MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ()
2364 GenerateLinkerCommand ();
2369 MingwWin32OCXModuleHandler::AddImplicitLibraries ( Module
& module
)
2371 MingwAddImplicitLibraries ( module
);
2375 MingwWin32OCXModuleHandler::Process ()
2377 GenerateWin32OCXModuleTarget ();
2381 MingwWin32OCXModuleHandler::GenerateWin32OCXModuleTarget ()
2384 GenerateLinkerCommand ();
2388 MingwWin32CUIModuleHandler::MingwWin32CUIModuleHandler (
2389 const Module
& module_
)
2391 : MingwModuleHandler ( module_
)
2396 MingwWin32CUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2398 MingwAddImplicitLibraries ( module
);
2402 MingwWin32CUIModuleHandler::Process ()
2404 GenerateWin32CUIModuleTarget ();
2408 MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ()
2411 GenerateLinkerCommand ();
2415 MingwWin32GUIModuleHandler::MingwWin32GUIModuleHandler (
2416 const Module
& module_
)
2418 : MingwModuleHandler ( module_
)
2423 MingwWin32GUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2425 MingwAddImplicitLibraries ( module
);
2429 MingwWin32GUIModuleHandler::Process ()
2431 GenerateWin32GUIModuleTarget ();
2435 MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ()
2438 GenerateLinkerCommand ();
2442 MingwBootLoaderModuleHandler::MingwBootLoaderModuleHandler (
2443 const Module
& module_
)
2445 : MingwModuleHandler ( module_
)
2450 MingwBootLoaderModuleHandler::Process ()
2452 GenerateBootLoaderModuleTarget ();
2456 MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ()
2458 fprintf ( fMakefile
, "# BOOT LOADER MODULE TARGET\n" );
2459 string
targetName ( module
.output
->name
);
2460 string
targetMacro ( GetTargetMacro (module
) );
2461 string workingDirectory
= GetWorkingDirectory ();
2462 FileLocation
junk_tmp ( TemporaryDirectory
,
2464 module
.name
+ ".junk.tmp" );
2465 CLEAN_FILE ( junk_tmp
);
2466 string objectsMacro
= GetObjectsMacro ( module
);
2467 string libsMacro
= GetLibsMacro ();
2471 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
2472 fprintf ( fMakefile
, "%s: %s %s | %s\n",
2473 targetMacro
.c_str (),
2474 objectsMacro
.c_str (),
2476 backend
->GetFullPath ( *target_file
).c_str () );
2478 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
2480 if (Environment::GetArch() == "arm")
2482 fprintf ( fMakefile
,
2483 "\t${gcc} -Wl,--subsystem,native -o %s %s %s %s -nostartfiles -nostdlib\n",
2484 backend
->GetFullName ( junk_tmp
).c_str (),
2485 objectsMacro
.c_str (),
2487 GetLinkerMacro ().c_str ());
2491 fprintf ( fMakefile
,
2492 "\t${gcc} -Wl,--subsystem,native -Wl,-Ttext,0x8000 -o %s %s %s %s -nostartfiles -nostdlib\n",
2493 backend
->GetFullName ( junk_tmp
).c_str (),
2494 objectsMacro
.c_str (),
2496 GetLinkerMacro ().c_str ());
2498 fprintf ( fMakefile
,
2499 "\t${objcopy} -O binary %s $@\n",
2500 backend
->GetFullName ( junk_tmp
).c_str () );
2501 GenerateBuildMapCode ( &junk_tmp
);
2502 fprintf ( fMakefile
,
2503 "\t-@${rm} %s 2>$(NUL)\n",
2504 backend
->GetFullName ( junk_tmp
).c_str () );
2510 MingwBootProgramModuleHandler::MingwBootProgramModuleHandler (
2511 const Module
& module_
)
2512 : MingwModuleHandler ( module_
)
2517 MingwBootProgramModuleHandler::Process ()
2519 GenerateBootProgramModuleTarget ();
2523 MingwBootProgramModuleHandler::GenerateBootProgramModuleTarget ()
2525 fprintf ( fMakefile
, "# BOOT PROGRAM MODULE TARGET\n" );
2527 string
targetName ( module
.output
->name
);
2528 string
targetMacro ( GetTargetMacro (module
) );
2529 string workingDirectory
= GetWorkingDirectory ();
2530 FileLocation
junk_tmp ( TemporaryDirectory
,
2532 module
.name
+ ".junk.tmp" );
2533 FileLocation
junk_elf ( TemporaryDirectory
,
2535 module
.name
+ ".junk.elf" );
2536 FileLocation
junk_cpy ( TemporaryDirectory
,
2538 module
.name
+ ".junk.elf" );
2539 CLEAN_FILE ( junk_tmp
);
2540 CLEAN_FILE ( junk_elf
);
2541 CLEAN_FILE ( junk_cpy
);
2542 string objectsMacro
= GetObjectsMacro ( module
);
2543 string libsMacro
= GetLibsMacro ();
2544 const Module
*payload
= module
.project
.LocateModule ( module
.payload
);
2548 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
2549 fprintf ( fMakefile
, "%s: %s %s %s | %s\n",
2550 targetMacro
.c_str (),
2551 objectsMacro
.c_str (),
2553 payload
->name
.c_str (),
2554 backend
->GetFullPath ( *target_file
).c_str () );
2556 fprintf ( fMakefile
, "\t$(ECHO_BOOTPROG)\n" );
2558 fprintf ( fMakefile
, "\t$(%s_PREPARE) $(OUTPUT)$(SEP)%s %s\n",
2559 module
.buildtype
.c_str (),
2560 NormalizeFilename( backend
->GetFullName ( *payload
->output
) ).c_str (),
2561 backend
->GetFullName ( junk_cpy
).c_str () );
2563 fprintf ( fMakefile
, "\t${objcopy} $(%s_FLATFORMAT) %s %s\n",
2564 module
.buildtype
.c_str (),
2565 backend
->GetFullName ( junk_cpy
).c_str (),
2566 backend
->GetFullName ( junk_tmp
).c_str () );
2568 fprintf ( fMakefile
, "\t${ld} $(%s_LINKFORMAT) %s %s -o %s\n",
2569 module
.buildtype
.c_str (),
2571 backend
->GetFullName ( junk_tmp
).c_str (),
2572 backend
->GetFullName ( junk_elf
).c_str () );
2574 fprintf ( fMakefile
, "\t${objcopy} $(%s_COPYFORMAT) %s $(INTERMEDIATE)$(SEP)%s\n",
2575 module
.buildtype
.c_str (),
2576 backend
->GetFullName ( junk_elf
).c_str (),
2577 backend
->GetFullName ( *module
.output
) .c_str () );
2579 fprintf ( fMakefile
,
2580 "\t-@${rm} %s %s %s 2>$(NUL)\n",
2581 backend
->GetFullName ( junk_tmp
).c_str (),
2582 backend
->GetFullName ( junk_elf
).c_str (),
2583 backend
->GetFullName ( junk_cpy
).c_str () );
2589 MingwIsoModuleHandler::MingwIsoModuleHandler (
2590 const Module
& module_
)
2592 : MingwModuleHandler ( module_
)
2597 MingwIsoModuleHandler::Process ()
2599 GenerateIsoModuleTarget ();
2603 MingwIsoModuleHandler::OutputBootstrapfileCopyCommands (
2604 const string
& bootcdDirectory
,
2605 vector
<FileLocation
>& destinations
)
2607 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
2609 const Module
& m
= *p
->second
;
2612 if ( m
.bootstrap
!= NULL
)
2614 FileLocation
targetFile ( OutputDirectory
,
2615 m
.bootstrap
->base
.length () > 0
2616 ? bootcdDirectory
+ sSep
+ m
.bootstrap
->base
2618 m
.bootstrap
->nameoncd
);
2619 OutputCopyCommandSingle ( *m
.output
, targetFile
);
2620 destinations
.push_back ( targetFile
);
2626 MingwIsoModuleHandler::OutputCdfileCopyCommands (
2627 const string
& bootcdDirectory
,
2628 std::vector
<FileLocation
>& destinations
)
2630 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
2632 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
2633 FileLocation
targetFile ( OutputDirectory
,
2634 cdfile
.target
->relative_path
.length () > 0
2635 ? bootcdDirectory
+ sSep
+ cdfile
.target
->relative_path
2637 cdfile
.target
->name
);
2638 OutputCopyCommandSingle ( *cdfile
.source
, targetFile
);
2639 destinations
.push_back ( targetFile
);
2641 for ( size_t i
= 0; i
< module
.cdfiles
.size (); i
++ )
2643 const CDFile
& cdfile
= *module
.cdfiles
[i
];
2644 FileLocation
targetFile ( OutputDirectory
,
2645 cdfile
.target
->relative_path
.length () > 0
2646 ? bootcdDirectory
+ sSep
+ cdfile
.target
->relative_path
2648 cdfile
.target
->name
);
2649 OutputCopyCommandSingle ( *cdfile
.source
, targetFile
);
2650 destinations
.push_back ( targetFile
);
2655 MingwIsoModuleHandler::GetBootstrapCdDirectories ( vector
<FileLocation
>& out
,
2656 const string
& bootcdDirectory
)
2658 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
2660 const Module
& m
= *p
->second
;
2663 if ( m
.bootstrap
!= NULL
)
2665 FileLocation
targetDirectory ( OutputDirectory
,
2666 m
.bootstrap
->base
.length () > 0
2667 ? bootcdDirectory
+ sSep
+ m
.bootstrap
->base
2670 out
.push_back ( targetDirectory
);
2676 MingwIsoModuleHandler::GetNonModuleCdDirectories ( vector
<FileLocation
>& out
,
2677 const string
& bootcdDirectory
)
2679 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
2681 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
2682 FileLocation
targetDirectory ( OutputDirectory
,
2683 cdfile
.target
->relative_path
.length () > 0
2684 ? bootcdDirectory
+ sSep
+ cdfile
.target
->relative_path
2687 out
.push_back( targetDirectory
);
2692 MingwIsoModuleHandler::GetCdDirectories ( vector
<FileLocation
>& out
,
2693 const string
& bootcdDirectory
)
2695 GetBootstrapCdDirectories ( out
, bootcdDirectory
);
2696 GetNonModuleCdDirectories ( out
, bootcdDirectory
);
2700 MingwIsoModuleHandler::GetBootstrapCdFiles (
2701 vector
<FileLocation
>& out
) const
2703 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
2705 const Module
& m
= *p
->second
;
2708 if ( m
.bootstrap
!= NULL
)
2710 out
.push_back ( *m
.output
);
2716 MingwIsoModuleHandler::GetNonModuleCdFiles (
2717 vector
<FileLocation
>& out
) const
2719 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
2721 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
2722 out
.push_back ( *cdfile
.source
);
2727 MingwIsoModuleHandler::GetCdFiles (
2728 vector
<FileLocation
>& out
) const
2730 GetBootstrapCdFiles ( out
);
2731 GetNonModuleCdFiles ( out
);
2735 MingwIsoModuleHandler::GenerateIsoModuleTarget ()
2737 fprintf ( fMakefile
, "# ISO MODULE TARGET\n" );
2738 string bootcdDirectory
= module
.name
;
2739 FileLocation
bootcd ( OutputDirectory
,
2742 FileLocation
bootcdReactos ( OutputDirectory
,
2743 bootcdDirectory
+ sSep
+ Environment::GetCdOutputPath (),
2747 const Module
* bootModule
= module
.bootSector
->bootSectorModule
;
2751 throw InvalidOperationException ( module
.node
.location
.c_str(),
2753 "Invalid bootsector. module '%s' requires <bootsector>",
2754 module
.name
.c_str ());
2757 const FileLocation
*isoboot
= bootModule
->output
;
2759 // prepare reactos.dff and reactos.inf
2760 FileLocation
reactosDff ( SourceDirectory
,
2761 "boot" + sSep
+ "bootdata" + sSep
+ "packages",
2763 FileLocation
reactosInf ( bootcdReactos
.directory
,
2764 bootcdReactos
.relative_path
,
2768 We use only the name and not full FileLocation(ouput) because Iso/LiveIso are an exception to the general rule.
2769 Iso/LiveIso outputs are generated in code base root
2771 string IsoName
= module
.output
->name
;
2773 fprintf ( fMakefile
, ".PHONY: %s_CABINET\n\n",
2774 module
.name
.c_str () );
2775 fprintf ( fMakefile
, "%s_CABINET: all $(cabman_TARGET) %s | %s\n",
2776 module
.name
.c_str (),
2777 backend
->GetFullName ( reactosDff
).c_str (),
2778 backend
->GetFullPath ( bootcdReactos
).c_str () );
2779 fprintf ( fMakefile
,
2780 "\t$(Q)$(cabman_TARGET) -C %s -L %s -I -P $(OUTPUT)\n",
2781 backend
->GetFullName ( reactosDff
).c_str (),
2782 backend
->GetFullPath ( bootcdReactos
).c_str () );
2783 fprintf ( fMakefile
,
2784 "\t$(Q)$(cabman_TARGET) -C %s -RC %s -L %s -N -P $(OUTPUT)\n",
2785 backend
->GetFullName ( reactosDff
).c_str (),
2786 backend
->GetFullName ( reactosInf
).c_str (),
2787 backend
->GetFullPath ( bootcdReactos
).c_str ());
2788 fprintf ( fMakefile
,
2789 "\t-@${rm} %s 2>$(NUL)\n\n",
2790 backend
->GetFullName ( reactosInf
).c_str () );
2792 std::vector
<FileLocation
> sourceFiles
;
2793 OutputBootstrapfileCopyCommands ( bootcdDirectory
, sourceFiles
);
2794 OutputCdfileCopyCommands ( bootcdDirectory
, sourceFiles
);
2797 "\n%s_OBJS := %s\n\n",
2798 module
.name
.c_str (),
2799 v2s ( backend
, sourceFiles
, 5 ).c_str () );
2801 fprintf ( fMakefile
, ".PHONY: %s\n\n",
2802 module
.name
.c_str ());
2803 fprintf ( fMakefile
,
2804 "%s: $(%s_OBJS) %s_CABINET %s $(cdmake_TARGET) | %s\n",
2805 module
.name
.c_str (),
2806 module
.name
.c_str (),
2807 module
.name
.c_str (),
2808 backend
->GetFullName ( *isoboot
).c_str (),
2809 backend
->GetFullPath ( FileLocation ( OutputDirectory
,
2813 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
2814 fprintf ( fMakefile
,
2815 "\t$(Q)$(cdmake_TARGET) -v -j -m -b %s %s REACTOS %s\n",
2816 backend
->GetFullName ( *isoboot
).c_str (),
2817 backend
->GetFullPath ( bootcd
).c_str (),
2819 fprintf ( fMakefile
,
2824 MingwLiveIsoModuleHandler::MingwLiveIsoModuleHandler (
2825 const Module
& module_
)
2827 : MingwModuleHandler ( module_
)
2832 MingwLiveIsoModuleHandler::Process ()
2834 GenerateLiveIsoModuleTarget ();
2838 MingwLiveIsoModuleHandler::CreateDirectory ( const string
& directory
)
2840 FileLocation
dir ( OutputDirectory
,
2843 MingwModuleHandler::PassThruCacheDirectory ( &dir
);
2847 MingwLiveIsoModuleHandler::OutputModuleCopyCommands ( string
& livecdDirectory
,
2848 string
& reactosDirectory
,
2849 std::vector
<FileLocation
>& destinations
)
2851 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
2853 const Module
& m
= *p
->second
;
2858 const Module
& aliasedModule
= backend
->GetAliasedModuleOrModule ( m
);
2859 FileLocation
destination ( OutputDirectory
,
2860 m
.install
->relative_path
.length () > 0
2861 ? livecdDirectory
+ sSep
+ reactosDirectory
+ sSep
+ m
.install
->relative_path
2862 : livecdDirectory
+ sSep
+ reactosDirectory
,
2864 OutputCopyCommandSingle ( *aliasedModule
.output
,
2866 destinations
.push_back ( destination
);
2872 MingwLiveIsoModuleHandler::OutputNonModuleCopyCommands ( string
& livecdDirectory
,
2873 string
& reactosDirectory
,
2874 std::vector
<FileLocation
>& destinations
)
2876 for ( size_t i
= 0; i
< module
.project
.installfiles
.size (); i
++ )
2878 const InstallFile
& installfile
= *module
.project
.installfiles
[i
];
2879 FileLocation
target ( OutputDirectory
,
2880 installfile
.target
->relative_path
.length () > 0
2881 ? livecdDirectory
+ sSep
+ reactosDirectory
+ sSep
+ installfile
.target
->relative_path
2882 : livecdDirectory
+ sSep
+ reactosDirectory
,
2883 installfile
.target
->name
);
2884 OutputCopyCommandSingle ( *installfile
.source
, target
);
2885 destinations
.push_back ( target
);
2890 MingwLiveIsoModuleHandler::OutputProfilesDirectoryCommands ( string
& livecdDirectory
,
2891 vector
<FileLocation
>& destinations
)
2893 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" );
2894 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "All Users") ;
2895 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "All Users" + sSep
+ "Desktop" );
2896 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" );
2897 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" + sSep
+ "Desktop" );
2898 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" + sSep
+ "My Documents" );
2900 FileLocation
livecdIni ( SourceDirectory
,
2901 "boot" + sSep
+ "bootdata",
2903 FileLocation
destination ( OutputDirectory
,
2906 OutputCopyCommandSingle ( livecdIni
,
2908 destinations
.push_back ( destination
);
2912 MingwLiveIsoModuleHandler::OutputLoaderCommands ( string
& livecdDirectory
,
2913 std::vector
<FileLocation
>& destinations
)
2915 FileLocation
freeldr ( OutputDirectory
,
2916 "boot" + sSep
+ "freeldr" + sSep
+ "freeldr",
2918 FileLocation
destination ( OutputDirectory
,
2919 livecdDirectory
+ sSep
+ "loader",
2921 OutputCopyCommandSingle ( freeldr
,
2923 destinations
.push_back ( destination
);
2927 MingwLiveIsoModuleHandler::OutputRegistryCommands ( string
& livecdDirectory
)
2929 fprintf ( fMakefile
, "# REGISTRY COMMANDS\n" );
2930 FileLocation
reactosSystem32ConfigDirectory ( OutputDirectory
,
2931 livecdDirectory
+ sSep
+ "reactos" + sSep
+ "system32" + sSep
+ "config",
2933 fprintf ( fMakefile
,
2934 "\t$(ECHO_MKHIVE)\n" );
2935 fprintf ( fMakefile
,
2936 "\t$(mkhive_TARGET) boot%cbootdata %s $(ARCH) boot%cbootdata%clivecd.inf boot%cbootdata%chiveinst_$(ARCH).inf\n",
2937 cSep
, backend
->GetFullPath ( reactosSystem32ConfigDirectory
).c_str (),
2938 cSep
, cSep
, cSep
, cSep
);
2942 MingwLiveIsoModuleHandler::GenerateLiveIsoModuleTarget ()
2944 fprintf ( fMakefile
, "# LIVE ISO MODULE TARGET\n" );
2945 string livecdDirectory
= module
.name
;
2946 FileLocation
livecd ( OutputDirectory
, livecdDirectory
, "" );
2951 const Module
* bootModule
= module
.bootSector
->bootSectorModule
;
2955 throw InvalidOperationException ( module
.node
.location
.c_str(),
2957 "Invalid bootsector. module '%s' requires <bootsector>",
2958 module
.name
.c_str ());
2961 const FileLocation
*isoboot
= bootModule
->output
;
2964 We use only the name and not full FileLocation(ouput) because Iso/LiveIso are an exception to the general rule.
2965 Iso/LiveIso outputs are generated in code base root
2967 IsoName
= module
.output
->name
;
2969 string reactosDirectory
= "reactos";
2970 string livecdReactosNoFixup
= livecdDirectory
+ sSep
+ reactosDirectory
;
2971 FileLocation
livecdReactos ( OutputDirectory
,
2972 livecdReactosNoFixup
,
2974 CLEAN_FILE ( livecdReactos
);
2976 std::vector
<FileLocation
> sourceFiles
;
2977 OutputModuleCopyCommands ( livecdDirectory
,
2980 OutputNonModuleCopyCommands ( livecdDirectory
,
2983 OutputProfilesDirectoryCommands ( livecdDirectory
, sourceFiles
);
2984 OutputLoaderCommands ( livecdDirectory
, sourceFiles
);
2987 "\n%s_OBJS := %s\n\n",
2988 module
.name
.c_str (),
2989 v2s ( backend
, sourceFiles
, 5 ).c_str () );
2991 fprintf ( fMakefile
, ".PHONY: %s\n\n",
2992 module
.name
.c_str ());
2993 fprintf ( fMakefile
,
2994 "%s : $(%s_OBJS) %s %s $(mkhive_TARGET) $(cdmake_TARGET)\n",
2995 module
.name
.c_str (),
2996 module
.name
.c_str (),
2997 backend
->GetFullName ( *isoboot
) .c_str (),
2998 backend
->GetFullPath ( FileLocation ( OutputDirectory
,
3001 OutputRegistryCommands ( livecdDirectory
);
3002 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
3003 fprintf ( fMakefile
,
3004 "\t$(Q)$(cdmake_TARGET) -v -m -j -b %s %s REACTOS %s\n",
3005 backend
->GetFullName( *isoboot
).c_str (),
3006 backend
->GetFullPath ( livecd
).c_str (),
3008 fprintf ( fMakefile
,
3013 MingwTestModuleHandler::MingwTestModuleHandler (
3014 const Module
& module_
)
3016 : MingwModuleHandler ( module_
)
3021 MingwTestModuleHandler::Process ()
3023 GenerateTestModuleTarget ();
3026 /* caller needs to delete the returned object */
3028 MingwTestModuleHandler::GetModuleSpecificCompilationUnits ( vector
<CompilationUnit
*>& compilationUnits
)
3030 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_hooks.c", false, "", false ) ) );
3031 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_stubs.S", false, "", false ) ) );
3032 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_startup.c", false, "", false ) ) );
3036 MingwTestModuleHandler::GenerateTestModuleTarget ()
3039 GenerateLinkerCommand ();
3043 MingwAliasModuleHandler::MingwAliasModuleHandler (
3044 const Module
& module_
)
3046 : MingwModuleHandler ( module_
)
3051 MingwAliasModuleHandler::Process ()
3056 MingwCabinetModuleHandler::MingwCabinetModuleHandler (
3057 const Module
& module_
)
3059 : MingwModuleHandler ( module_
)
3064 MingwCabinetModuleHandler::Process ()
3066 fprintf ( fMakefile
, "# CABINET MODULE TARGET\n" );
3067 string
targetMacro ( GetTargetMacro (module
) );
3071 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3072 fprintf ( fMakefile
, "%s: $(cabman_TARGET) | %s\n",
3073 targetMacro
.c_str (),
3074 backend
->GetFullPath ( *target_file
).c_str () );
3076 fprintf ( fMakefile
, "\t$(ECHO_CABMAN)\n" );
3077 fprintf ( fMakefile
,
3078 "\t$(Q)$(cabman_TARGET) -M raw -S %s $(%s_SOURCES)\n", // Escape the asterisk for Make
3079 targetMacro
.c_str (),
3080 module
.name
.c_str());
3083 MingwElfExecutableModuleHandler::MingwElfExecutableModuleHandler (
3084 const Module
& module_
)
3086 : MingwModuleHandler ( module_
)
3091 MingwElfExecutableModuleHandler::Process ()
3093 string
targetName ( module
.output
->name
);
3094 string
targetMacro ( GetTargetMacro (module
) );
3095 string workingDirectory
= GetWorkingDirectory ();
3096 string objectsMacro
= GetObjectsMacro ( module
);
3097 string libsMacro
= GetLibsMacro ();
3098 string debugFormat
= GetDebugFormat ();
3100 fprintf ( fMakefile
, "# ELF EXECUTABLE TARGET\n" );
3103 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3104 fprintf ( fMakefile
, "%s: %s %s | %s\n",
3105 targetMacro
.c_str (),
3106 objectsMacro
.c_str (),
3108 backend
->GetFullPath ( *target_file
).c_str () );
3110 fprintf ( fMakefile
, "\t$(ECHO_BOOTPROG)\n" );
3112 fprintf ( fMakefile
, "\t${gcc} $(%s_LINKFORMAT) %s %s -g%s -o %s\n",
3113 module
.buildtype
.c_str(),
3114 objectsMacro
.c_str(),
3116 debugFormat
.c_str(),
3117 targetMacro
.c_str () );
3120 fprintf ( fMakefile
, "#/ELF EXECUTABLE TARGET\n" );