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 ( module
.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 /* LD automatically exports all symbols by default if -shared is specified. Prevent it from doing
1786 this by adding the option -exclude-all-symbols (available since Binutils 20091017). */
1787 // FIXME: Should only be applied for -shared modules, when there's a smart way to check for them.
1788 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostFalse
&& !module
.importLibrary
)
1789 fprintf ( fMakefile
, "%s_LDFLAGS+=$(LDFLAG_EXCLUDE_ALL_SYMBOLS)\n", module
.name
.c_str() );
1791 fprintf ( fMakefile
, "\n\n" );
1795 MingwModuleHandler::GenerateRules ()
1799 fprintf ( fMakefile
, "# RULES\n" );
1800 string targetMacro
= GetTargetMacro ( module
);
1801 //CLEAN_FILE ( targetMacro );
1802 CLEAN_FILE ( FileLocation ( SourceDirectory
, "", targetMacro
) );
1804 // generate phony target for module name
1805 fprintf ( fMakefile
, ".PHONY: %s\n",
1806 module
.name
.c_str () );
1807 string dependencies
= GetTargetMacro ( module
);
1808 if ( module
.type
== Test
)
1809 dependencies
+= " $(regtests_run_TARGET)";
1810 fprintf ( fMakefile
, "%s: %s\n\n",
1811 module
.name
.c_str (),
1812 dependencies
.c_str () );
1813 if ( module
.type
== Test
)
1815 fprintf ( fMakefile
,
1817 targetMacro
.c_str ());
1820 if ( !ReferenceObjects ( module
) )
1822 const FileLocation
* ar_target
= GenerateArchiveTarget ();
1829 spec
= module
.IsSpecDefinitionFile();
1836 defRule
= &winebuildPRule
;
1838 defRule
= &winebuildRule
;
1840 defRule
->Execute ( fMakefile
, backend
, module
, module
.importLibrary
->source
, clean_files
);
1843 GenerateObjectFileTargets ();
1847 MingwModuleHandler::GetInvocationDependencies (
1848 const Module
& module
,
1849 string_list
& dependencies
)
1851 for ( size_t i
= 0; i
< module
.invocations
.size (); i
++ )
1853 Invoke
& invoke
= *module
.invocations
[i
];
1854 if ( invoke
.invokeModule
== &module
)
1855 /* Protect against circular dependencies */
1857 invoke
.GetTargets ( dependencies
);
1862 MingwModuleHandler::GenerateInvocations () const
1864 if ( module
.invocations
.size () == 0 )
1867 fprintf ( fMakefile
, "# INVOCATIONS\n" );
1869 size_t iend
= module
.invocations
.size ();
1870 for ( size_t i
= 0; i
< iend
; i
++ )
1872 const Invoke
& invoke
= *module
.invocations
[i
];
1874 if ( invoke
.invokeModule
->type
!= BuildTool
)
1876 throw XMLInvalidBuildFileException (
1877 module
.node
.location
,
1878 "Only modules of type buildtool can be invoked." );
1881 string invokeTarget
= module
.GetInvocationTarget ( i
);
1882 string_list invoke_targets
;
1883 assert ( invoke_targets
.size() );
1884 invoke
.GetTargets ( invoke_targets
);
1885 fprintf ( fMakefile
,
1887 invokeTarget
.c_str () );
1888 fprintf ( fMakefile
,
1890 invokeTarget
.c_str () );
1891 size_t j
, jend
= invoke_targets
.size();
1892 for ( j
= 0; j
< jend
; j
++ )
1894 fprintf ( fMakefile
,
1896 invoke_targets
[i
].c_str () );
1898 fprintf ( fMakefile
, "\n\n%s", invoke_targets
[0].c_str () );
1899 for ( j
= 1; j
< jend
; j
++ )
1900 fprintf ( fMakefile
,
1902 invoke_targets
[i
].c_str () );
1903 fprintf ( fMakefile
,
1905 NormalizeFilename ( backend
->GetFullName ( *invoke
.invokeModule
->output
) ).c_str () );
1906 fprintf ( fMakefile
, "\t$(ECHO_INVOKE)\n" );
1907 fprintf ( fMakefile
,
1909 NormalizeFilename ( backend
->GetFullName ( *invoke
.invokeModule
->output
) ).c_str (),
1910 invoke
.GetParameters ().c_str () );
1915 MingwModuleHandler::GetPreconditionDependenciesName () const
1917 return module
.name
+ "_precondition";
1921 MingwModuleHandler::GetDefaultDependencies (
1922 string_list
& dependencies
) const
1924 /* Avoid circular dependency */
1925 if ( ModuleHandlerInformations
[module
.type
].DefaultHost
== HostTrue
)
1928 if (module
.name
!= "psdk" &&
1929 module
.name
!= "dxsdk")
1931 dependencies
.push_back ( "$(psdk_TARGET) $(psdk_HEADERS)" );
1932 dependencies
.push_back ( "$(dxsdk_TARGET) $(dxsdk_HEADERS)" );
1935 if (module
.name
!= "errcodes" &&
1936 module
.name
!= "bugcodes" &&
1937 module
.name
!= "ntstatus")
1939 dependencies
.push_back ( "$(errcodes_TARGET) $(ERRCODES_MCHEADERS)" );
1940 dependencies
.push_back ( "$(bugcodes_TARGET) $(BUGCODES_MCHEADERS)" );
1941 dependencies
.push_back ( "$(ntstatus_TARGET) $(NTSTATUS_MCHEADERS)" );
1944 ///* Check if any dependent library relies on the generated headers */
1945 //for ( size_t i = 0; i < module.project.modules.size (); i++ )
1947 // const Module& m = *module.project.modules[i];
1948 // for ( size_t j = 0; j < m.non_if_data.compilationUnits.size (); j++ )
1950 // CompilationUnit& compilationUnit = *m.non_if_data.compilationUnits[j];
1951 // const FileLocation& sourceFile = compilationUnit.GetFilename ();
1952 // string extension = GetExtension ( sourceFile );
1953 // if (extension == ".mc" || extension == ".MC" )
1955 // string dependency = ssprintf ( "$(%s_MCHEADERS)", m.name.c_str () );
1956 // dependencies.push_back ( dependency );
1963 MingwModuleHandler::GeneratePreconditionDependencies ()
1965 fprintf ( fMakefile
, "# PRECONDITION DEPENDENCIES\n" );
1966 string preconditionDependenciesName
= GetPreconditionDependenciesName ();
1967 string_list dependencies
;
1968 GetDefaultDependencies ( dependencies
);
1969 GetModuleDependencies ( dependencies
);
1971 GetInvocationDependencies ( module
, dependencies
);
1973 if ( dependencies
.size() )
1975 fprintf ( fMakefile
,
1977 preconditionDependenciesName
.c_str () );
1978 for ( size_t i
= 0; i
< dependencies
.size(); i
++ )
1979 fprintf ( fMakefile
,
1981 dependencies
[i
].c_str () );
1982 fprintf ( fMakefile
, "\n\n" );
1985 fprintf ( fMakefile
, "\n" );
1988 /* caller needs to delete the returned object */
1990 MingwModuleHandler::GetDefinitionFilename () const
1992 if ( module
.importLibrary
== NULL
)
1995 if ( module
.IsSpecDefinitionFile () )
1997 return new FileLocation ( IntermediateDirectory
,
1998 module
.importLibrary
->source
->relative_path
,
1999 GetBasename ( module
.importLibrary
->source
->name
) + "_" + module
.name
+ ".auto.def" );
2003 return new FileLocation ( SourceDirectory
,
2004 module
.importLibrary
->source
->relative_path
,
2005 module
.importLibrary
->source
->name
);
2010 MingwModuleHandler::GetSpecObjectDependencies (
2011 vector
<FileLocation
>& dependencies
,
2012 const FileLocation
*file
) const
2014 dependencies
.push_back ( FileLocation ( IntermediateDirectory
,
2015 file
->relative_path
,
2016 GetBasename ( file
->name
) + "_" + module
.name
+ ".stubs.c" ) );
2020 MingwModuleHandler::GetMcObjectDependencies (
2021 vector
<FileLocation
>& dependencies
,
2022 const FileLocation
*file
) const
2024 string basename
= GetBasename ( file
->name
);
2026 FileLocation
defDependency ( IntermediateDirectory
,
2029 dependencies
.push_back ( defDependency
);
2031 FileLocation
stubsDependency ( IntermediateDirectory
,
2032 file
->relative_path
,
2034 dependencies
.push_back ( stubsDependency
);
2038 MingwModuleHandler::GetWidlObjectDependencies (
2039 vector
<FileLocation
>& dependencies
,
2040 const FileLocation
*file
) const
2042 string basename
= GetBasename ( file
->name
);
2043 const FileLocation
*generatedHeaderFilename
= GetRpcServerHeaderFilename ( file
);
2045 FileLocation
serverSourceDependency ( IntermediateDirectory
,
2046 file
->relative_path
,
2047 basename
+ "_s.c" );
2048 dependencies
.push_back ( serverSourceDependency
);
2049 dependencies
.push_back ( *generatedHeaderFilename
);
2051 delete generatedHeaderFilename
;
2055 MingwModuleHandler::GetDefinitionDependencies (
2056 vector
<FileLocation
>& dependencies
) const
2058 const vector
<CompilationUnit
*>& compilationUnits
= module
.non_if_data
.compilationUnits
;
2059 for ( size_t i
= 0; i
< compilationUnits
.size (); i
++ )
2061 const CompilationUnit
& compilationUnit
= *compilationUnits
[i
];
2062 const FileLocation
& sourceFile
= compilationUnit
.GetFilename ();
2063 string extension
= GetExtension ( sourceFile
);
2065 if (extension
== ".spec" || extension
== ".pspec")
2066 GetSpecObjectDependencies ( dependencies
, &sourceFile
);
2068 if (extension
== ".idl")
2070 if ( ( module
.type
== RpcServer
) || ( module
.type
== RpcClient
) || ( module
.type
== RpcProxy
) )
2071 GetWidlObjectDependencies ( dependencies
, &sourceFile
);
2076 enum DebugSupportType
2083 MingwAddDebugSupportLibraries ( Module
& module
, DebugSupportType type
)
2089 case DebugKernelMode
:
2090 pLibrary
= new Library ( module
, "debugsup_ntoskrnl" );
2094 pLibrary
= new Library ( module
, "debugsup_ntdll" );
2101 module
.non_if_data
.libraries
.push_back(pLibrary
);
2105 MingwAddCRTLibrary( Module
&module
)
2107 const char * crtAttr
= module
.CRT
.c_str ();
2108 const char * crtLib
= NULL
;
2110 if ( stricmp ( crtAttr
, "libc" ) == 0 )
2112 else if ( stricmp ( crtAttr
, "msvcrt" ) == 0 )
2114 else if ( stricmp ( crtAttr
, "libcntpr" ) == 0 )
2115 crtLib
= "libcntpr";
2116 else if ( stricmp ( crtAttr
, "ntdll" ) == 0 )
2121 Library
* pLibrary
= new Library ( module
, std::string ( crtLib
) );
2123 if ( pLibrary
->importedModule
== NULL
)
2125 throw XMLInvalidBuildFileException (
2126 module
.node
.location
,
2127 "module '%s' trying to import non-existant C runtime module '%s'",
2128 module
.name
.c_str(),
2132 module
.non_if_data
.libraries
.push_back ( pLibrary
);
2136 MingwBuildToolModuleHandler::MingwBuildToolModuleHandler ( const Module
& module_
)
2137 : MingwModuleHandler ( module_
)
2142 MingwBuildToolModuleHandler::Process ()
2144 GenerateBuildToolModuleTarget ();
2148 MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ()
2150 string
targetMacro ( GetTargetMacro (module
) );
2151 string objectsMacro
= GetObjectsMacro ( module
);
2152 string libsMacro
= GetLibsMacro ();
2156 fprintf ( fMakefile
, "# BUILD TOOL MODULE TARGET\n" );
2159 if ( module
.cplusplus
)
2160 linker
= "${host_gpp}";
2162 linker
= "${host_gcc}";
2164 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
2165 fprintf ( fMakefile
, "%s: %s %s | %s\n",
2166 targetMacro
.c_str (),
2167 objectsMacro
.c_str (),
2169 backend
->GetFullPath ( *target_file
).c_str () );
2170 fprintf ( fMakefile
, "\t$(ECHO_HOSTLD)\n" );
2171 fprintf ( fMakefile
,
2172 "\t%s %s -o $@ %s %s\n\n",
2174 GetLinkerMacro ().c_str (),
2175 objectsMacro
.c_str (),
2176 libsMacro
.c_str () );
2182 MingwKernelModuleHandler::MingwKernelModuleHandler (
2183 const Module
& module_
)
2185 : MingwModuleHandler ( module_
)
2190 MingwKernelModuleHandler::Process ()
2192 GenerateKernelModuleTarget ();
2196 MingwKernelModuleHandler::GenerateKernelModuleTarget ()
2199 GenerateLinkerCommand ();
2203 MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler (
2204 const Module
& module_
)
2206 : MingwModuleHandler ( module_
)
2212 MingwKernelModeDLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2214 MingwAddCRTLibrary ( module
);
2215 MingwAddDebugSupportLibraries ( module
, DebugKernelMode
);
2219 MingwKernelModeDLLModuleHandler::Process ()
2221 GenerateKernelModeDLLModuleTarget ();
2225 MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ()
2228 GenerateLinkerCommand ();
2232 MingwNativeDLLModuleHandler::MingwNativeDLLModuleHandler (
2233 const Module
& module_
)
2235 : MingwModuleHandler ( module_
)
2240 MingwNativeDLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2242 MingwAddCRTLibrary ( module
);
2243 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2247 MingwNativeDLLModuleHandler::Process ()
2249 GenerateNativeDLLModuleTarget ();
2253 MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ()
2256 GenerateLinkerCommand ();
2260 MingwNativeCUIModuleHandler::MingwNativeCUIModuleHandler (
2261 const Module
& module_
)
2263 : MingwModuleHandler ( module_
)
2268 MingwNativeCUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2270 MingwAddCRTLibrary ( module
);
2271 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2275 MingwNativeCUIModuleHandler::Process ()
2277 GenerateNativeCUIModuleTarget ();
2281 MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ()
2284 GenerateLinkerCommand ();
2288 MingwWin32DLLModuleHandler::MingwWin32DLLModuleHandler (
2289 const Module
& module_
)
2291 : MingwModuleHandler ( module_
)
2295 MingwWin32OCXModuleHandler::MingwWin32OCXModuleHandler (
2296 const Module
& module_
)
2298 : MingwModuleHandler ( module_
)
2303 MingwAddImplicitLibraries( Module
&module
)
2307 if ( module
.type
!= Win32DLL
2308 && module
.type
!= Win32OCX
2309 && module
.type
!= Win32CUI
2310 && module
.type
!= Win32GUI
2311 && module
.type
!= Win32SCR
)
2316 if ( module
.isDefaultEntryPoint
)
2318 if ( module
.IsDLL () )
2320 //pLibrary = new Library ( module, "__mingw_dllmain" );
2321 //module.non_if_data.libraries.insert ( module.non_if_data.libraries.begin(), pLibrary );
2325 pLibrary
= new Library ( module
, module
.isUnicode
? "mingw_wmain" : "mingw_main" );
2326 module
.non_if_data
.libraries
.insert ( module
.non_if_data
.libraries
.begin(), pLibrary
);
2330 pLibrary
= new Library ( module
, "mingw_common" );
2331 module
.non_if_data
.libraries
.push_back ( pLibrary
);
2333 MingwAddCRTLibrary ( module
);
2334 MingwAddDebugSupportLibraries ( module
, DebugUserMode
);
2338 MingwWin32DLLModuleHandler::AddImplicitLibraries ( Module
& module
)
2340 MingwAddImplicitLibraries ( module
);
2344 MingwWin32DLLModuleHandler::Process ()
2346 GenerateWin32DLLModuleTarget ();
2350 MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ()
2353 GenerateLinkerCommand ();
2358 MingwWin32OCXModuleHandler::AddImplicitLibraries ( Module
& module
)
2360 MingwAddImplicitLibraries ( module
);
2364 MingwWin32OCXModuleHandler::Process ()
2366 GenerateWin32OCXModuleTarget ();
2370 MingwWin32OCXModuleHandler::GenerateWin32OCXModuleTarget ()
2373 GenerateLinkerCommand ();
2377 MingwWin32CUIModuleHandler::MingwWin32CUIModuleHandler (
2378 const Module
& module_
)
2380 : MingwModuleHandler ( module_
)
2385 MingwWin32CUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2387 MingwAddImplicitLibraries ( module
);
2391 MingwWin32CUIModuleHandler::Process ()
2393 GenerateWin32CUIModuleTarget ();
2397 MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ()
2400 GenerateLinkerCommand ();
2404 MingwWin32GUIModuleHandler::MingwWin32GUIModuleHandler (
2405 const Module
& module_
)
2407 : MingwModuleHandler ( module_
)
2412 MingwWin32GUIModuleHandler::AddImplicitLibraries ( Module
& module
)
2414 MingwAddImplicitLibraries ( module
);
2418 MingwWin32GUIModuleHandler::Process ()
2420 GenerateWin32GUIModuleTarget ();
2424 MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ()
2427 GenerateLinkerCommand ();
2431 MingwBootLoaderModuleHandler::MingwBootLoaderModuleHandler (
2432 const Module
& module_
)
2434 : MingwModuleHandler ( module_
)
2439 MingwBootLoaderModuleHandler::Process ()
2441 GenerateBootLoaderModuleTarget ();
2445 MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ()
2447 fprintf ( fMakefile
, "# BOOT LOADER MODULE TARGET\n" );
2448 string
targetName ( module
.output
->name
);
2449 string
targetMacro ( GetTargetMacro (module
) );
2450 string workingDirectory
= GetWorkingDirectory ();
2451 FileLocation
junk_tmp ( TemporaryDirectory
,
2453 module
.name
+ ".junk.tmp" );
2454 CLEAN_FILE ( junk_tmp
);
2455 string objectsMacro
= GetObjectsMacro ( module
);
2456 string libsMacro
= GetLibsMacro ();
2460 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
2461 fprintf ( fMakefile
, "%s: %s %s | %s\n",
2462 targetMacro
.c_str (),
2463 objectsMacro
.c_str (),
2465 backend
->GetFullPath ( *target_file
).c_str () );
2467 fprintf ( fMakefile
, "\t$(ECHO_LD)\n" );
2469 if (Environment::GetArch() == "arm")
2471 fprintf ( fMakefile
,
2472 "\t${gcc} -Wl,--subsystem,native -o %s %s %s %s -nostartfiles -nostdlib\n",
2473 backend
->GetFullName ( junk_tmp
).c_str (),
2474 objectsMacro
.c_str (),
2476 GetLinkerMacro ().c_str ());
2480 fprintf ( fMakefile
,
2481 "\t${gcc} -Wl,--subsystem,native -Wl,-Ttext,0x8000 -o %s %s %s %s -nostartfiles -nostdlib\n",
2482 backend
->GetFullName ( junk_tmp
).c_str (),
2483 objectsMacro
.c_str (),
2485 GetLinkerMacro ().c_str ());
2487 fprintf ( fMakefile
,
2488 "\t${objcopy} -O binary %s $@\n",
2489 backend
->GetFullName ( junk_tmp
).c_str () );
2490 GenerateBuildMapCode ( &junk_tmp
);
2491 fprintf ( fMakefile
,
2492 "\t-@${rm} %s 2>$(NUL)\n",
2493 backend
->GetFullName ( junk_tmp
).c_str () );
2499 MingwBootProgramModuleHandler::MingwBootProgramModuleHandler (
2500 const Module
& module_
)
2501 : MingwModuleHandler ( module_
)
2506 MingwBootProgramModuleHandler::Process ()
2508 GenerateBootProgramModuleTarget ();
2512 MingwBootProgramModuleHandler::GenerateBootProgramModuleTarget ()
2514 fprintf ( fMakefile
, "# BOOT PROGRAM MODULE TARGET\n" );
2516 string
targetName ( module
.output
->name
);
2517 string
targetMacro ( GetTargetMacro (module
) );
2518 string workingDirectory
= GetWorkingDirectory ();
2519 FileLocation
junk_tmp ( TemporaryDirectory
,
2521 module
.name
+ ".junk.tmp" );
2522 FileLocation
junk_elf ( TemporaryDirectory
,
2524 module
.name
+ ".junk.elf" );
2525 FileLocation
junk_cpy ( TemporaryDirectory
,
2527 module
.name
+ ".junk.elf" );
2528 CLEAN_FILE ( junk_tmp
);
2529 CLEAN_FILE ( junk_elf
);
2530 CLEAN_FILE ( junk_cpy
);
2531 string objectsMacro
= GetObjectsMacro ( module
);
2532 string libsMacro
= GetLibsMacro ();
2533 const Module
*payload
= module
.project
.LocateModule ( module
.payload
);
2537 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
2538 fprintf ( fMakefile
, "%s: %s %s %s | %s\n",
2539 targetMacro
.c_str (),
2540 objectsMacro
.c_str (),
2542 payload
->name
.c_str (),
2543 backend
->GetFullPath ( *target_file
).c_str () );
2545 fprintf ( fMakefile
, "\t$(ECHO_BOOTPROG)\n" );
2547 fprintf ( fMakefile
, "\t$(%s_PREPARE) $(OUTPUT)$(SEP)%s %s\n",
2548 module
.buildtype
.c_str (),
2549 NormalizeFilename( backend
->GetFullName ( *payload
->output
) ).c_str (),
2550 backend
->GetFullName ( junk_cpy
).c_str () );
2552 fprintf ( fMakefile
, "\t${objcopy} $(%s_FLATFORMAT) %s %s\n",
2553 module
.buildtype
.c_str (),
2554 backend
->GetFullName ( junk_cpy
).c_str (),
2555 backend
->GetFullName ( junk_tmp
).c_str () );
2557 fprintf ( fMakefile
, "\t${ld} $(%s_LINKFORMAT) %s %s -o %s\n",
2558 module
.buildtype
.c_str (),
2560 backend
->GetFullName ( junk_tmp
).c_str (),
2561 backend
->GetFullName ( junk_elf
).c_str () );
2563 fprintf ( fMakefile
, "\t${objcopy} $(%s_COPYFORMAT) %s $(INTERMEDIATE)$(SEP)%s\n",
2564 module
.buildtype
.c_str (),
2565 backend
->GetFullName ( junk_elf
).c_str (),
2566 backend
->GetFullName ( *module
.output
) .c_str () );
2568 fprintf ( fMakefile
,
2569 "\t-@${rm} %s %s %s 2>$(NUL)\n",
2570 backend
->GetFullName ( junk_tmp
).c_str (),
2571 backend
->GetFullName ( junk_elf
).c_str (),
2572 backend
->GetFullName ( junk_cpy
).c_str () );
2578 MingwIsoModuleHandler::MingwIsoModuleHandler (
2579 const Module
& module_
)
2581 : MingwModuleHandler ( module_
)
2586 MingwIsoModuleHandler::Process ()
2588 GenerateIsoModuleTarget ();
2592 MingwIsoModuleHandler::OutputBootstrapfileCopyCommands (
2593 const string
& bootcdDirectory
,
2594 vector
<FileLocation
>& destinations
)
2596 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
2598 const Module
& m
= *p
->second
;
2601 if ( m
.bootstrap
!= NULL
)
2603 FileLocation
targetFile ( OutputDirectory
,
2604 m
.bootstrap
->base
.length () > 0
2605 ? bootcdDirectory
+ sSep
+ m
.bootstrap
->base
2607 m
.bootstrap
->nameoncd
);
2608 OutputCopyCommandSingle ( *m
.output
, targetFile
);
2609 destinations
.push_back ( targetFile
);
2615 MingwIsoModuleHandler::OutputCdfileCopyCommands (
2616 const string
& bootcdDirectory
,
2617 std::vector
<FileLocation
>& destinations
)
2619 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
2621 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
2622 FileLocation
targetFile ( OutputDirectory
,
2623 cdfile
.target
->relative_path
.length () > 0
2624 ? bootcdDirectory
+ sSep
+ cdfile
.target
->relative_path
2626 cdfile
.target
->name
);
2627 OutputCopyCommandSingle ( *cdfile
.source
, targetFile
);
2628 destinations
.push_back ( targetFile
);
2630 for ( size_t i
= 0; i
< module
.cdfiles
.size (); i
++ )
2632 const CDFile
& cdfile
= *module
.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
);
2644 MingwIsoModuleHandler::GetBootstrapCdDirectories ( vector
<FileLocation
>& out
,
2645 const string
& bootcdDirectory
)
2647 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
2649 const Module
& m
= *p
->second
;
2652 if ( m
.bootstrap
!= NULL
)
2654 FileLocation
targetDirectory ( OutputDirectory
,
2655 m
.bootstrap
->base
.length () > 0
2656 ? bootcdDirectory
+ sSep
+ m
.bootstrap
->base
2659 out
.push_back ( targetDirectory
);
2665 MingwIsoModuleHandler::GetNonModuleCdDirectories ( vector
<FileLocation
>& out
,
2666 const string
& bootcdDirectory
)
2668 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
2670 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
2671 FileLocation
targetDirectory ( OutputDirectory
,
2672 cdfile
.target
->relative_path
.length () > 0
2673 ? bootcdDirectory
+ sSep
+ cdfile
.target
->relative_path
2676 out
.push_back( targetDirectory
);
2681 MingwIsoModuleHandler::GetCdDirectories ( vector
<FileLocation
>& out
,
2682 const string
& bootcdDirectory
)
2684 GetBootstrapCdDirectories ( out
, bootcdDirectory
);
2685 GetNonModuleCdDirectories ( out
, bootcdDirectory
);
2689 MingwIsoModuleHandler::GetBootstrapCdFiles (
2690 vector
<FileLocation
>& out
) const
2692 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
2694 const Module
& m
= *p
->second
;
2697 if ( m
.bootstrap
!= NULL
)
2699 out
.push_back ( *m
.output
);
2705 MingwIsoModuleHandler::GetNonModuleCdFiles (
2706 vector
<FileLocation
>& out
) const
2708 for ( size_t i
= 0; i
< module
.project
.cdfiles
.size (); i
++ )
2710 const CDFile
& cdfile
= *module
.project
.cdfiles
[i
];
2711 out
.push_back ( *cdfile
.source
);
2716 MingwIsoModuleHandler::GetCdFiles (
2717 vector
<FileLocation
>& out
) const
2719 GetBootstrapCdFiles ( out
);
2720 GetNonModuleCdFiles ( out
);
2724 MingwIsoModuleHandler::GenerateIsoModuleTarget ()
2726 fprintf ( fMakefile
, "# ISO MODULE TARGET\n" );
2727 string bootcdDirectory
= module
.name
;
2728 FileLocation
bootcd ( OutputDirectory
,
2731 FileLocation
bootcdReactos ( OutputDirectory
,
2732 bootcdDirectory
+ sSep
+ Environment::GetCdOutputPath (),
2736 const Module
* bootModule
= module
.bootSector
->bootSectorModule
;
2740 throw InvalidOperationException ( module
.node
.location
.c_str(),
2742 "Invalid bootsector. module '%s' requires <bootsector>",
2743 module
.name
.c_str ());
2746 const FileLocation
*isoboot
= bootModule
->output
;
2748 // prepare reactos.dff and reactos.inf
2749 FileLocation
reactosDff ( IntermediateDirectory
,
2752 FileLocation
reactosInf ( bootcdReactos
.directory
,
2753 bootcdReactos
.relative_path
,
2757 We use only the name and not full FileLocation(ouput) because Iso/LiveIso are an exception to the general rule.
2758 Iso/LiveIso outputs are generated in code base root
2760 string IsoName
= module
.output
->name
;
2762 fprintf ( fMakefile
, ".PHONY: %s_CABINET\n\n",
2763 module
.name
.c_str () );
2764 fprintf ( fMakefile
, "%s_CABINET: all $(cabman_TARGET) %s | %s\n",
2765 module
.name
.c_str (),
2766 backend
->GetFullName ( reactosDff
).c_str (),
2767 backend
->GetFullPath ( bootcdReactos
).c_str () );
2768 fprintf ( fMakefile
,
2769 "\t$(Q)$(cabman_TARGET) -C %s -L %s -I -P $(OUTPUT)\n",
2770 backend
->GetFullName ( reactosDff
).c_str (),
2771 backend
->GetFullPath ( bootcdReactos
).c_str () );
2772 fprintf ( fMakefile
,
2773 "\t$(Q)$(cabman_TARGET) -C %s -RC %s -L %s -N -P $(OUTPUT)\n",
2774 backend
->GetFullName ( reactosDff
).c_str (),
2775 backend
->GetFullName ( reactosInf
).c_str (),
2776 backend
->GetFullPath ( bootcdReactos
).c_str ());
2777 fprintf ( fMakefile
,
2778 "\t-@${rm} %s 2>$(NUL)\n\n",
2779 backend
->GetFullName ( reactosInf
).c_str () );
2781 std::vector
<FileLocation
> sourceFiles
;
2782 OutputBootstrapfileCopyCommands ( bootcdDirectory
, sourceFiles
);
2783 OutputCdfileCopyCommands ( bootcdDirectory
, sourceFiles
);
2786 "\n%s_OBJS := %s\n\n",
2787 module
.name
.c_str (),
2788 v2s ( backend
, sourceFiles
, 5 ).c_str () );
2790 fprintf ( fMakefile
, ".PHONY: %s\n\n",
2791 module
.name
.c_str ());
2792 fprintf ( fMakefile
,
2793 "%s: $(%s_OBJS) %s_CABINET %s $(cdmake_TARGET) | %s\n",
2794 module
.name
.c_str (),
2795 module
.name
.c_str (),
2796 module
.name
.c_str (),
2797 backend
->GetFullName ( *isoboot
).c_str (),
2798 backend
->GetFullPath ( FileLocation ( OutputDirectory
,
2802 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
2803 fprintf ( fMakefile
,
2804 "\t$(Q)$(cdmake_TARGET) -v -j -m -b %s %s REACTOS %s\n",
2805 backend
->GetFullName ( *isoboot
).c_str (),
2806 backend
->GetFullPath ( bootcd
).c_str (),
2808 fprintf ( fMakefile
,
2813 MingwLiveIsoModuleHandler::MingwLiveIsoModuleHandler (
2814 const Module
& module_
)
2816 : MingwModuleHandler ( module_
)
2821 MingwLiveIsoModuleHandler::Process ()
2823 GenerateLiveIsoModuleTarget ();
2827 MingwLiveIsoModuleHandler::CreateDirectory ( const string
& directory
)
2829 FileLocation
dir ( OutputDirectory
,
2832 MingwModuleHandler::PassThruCacheDirectory ( &dir
);
2836 MingwLiveIsoModuleHandler::OutputModuleCopyCommands ( string
& livecdDirectory
,
2837 string
& reactosDirectory
,
2838 std::vector
<FileLocation
>& destinations
)
2840 for ( std::map
<std::string
, Module
*>::const_iterator p
= module
.project
.modules
.begin (); p
!= module
.project
.modules
.end (); ++ p
)
2842 const Module
& m
= *p
->second
;
2847 const Module
& aliasedModule
= backend
->GetAliasedModuleOrModule ( m
);
2848 FileLocation
destination ( OutputDirectory
,
2849 m
.install
->relative_path
.length () > 0
2850 ? livecdDirectory
+ sSep
+ reactosDirectory
+ sSep
+ m
.install
->relative_path
2851 : livecdDirectory
+ sSep
+ reactosDirectory
,
2853 OutputCopyCommandSingle ( *aliasedModule
.output
,
2855 destinations
.push_back ( destination
);
2861 MingwLiveIsoModuleHandler::OutputNonModuleCopyCommands ( string
& livecdDirectory
,
2862 string
& reactosDirectory
,
2863 std::vector
<FileLocation
>& destinations
)
2865 for ( size_t i
= 0; i
< module
.project
.installfiles
.size (); i
++ )
2867 const InstallFile
& installfile
= *module
.project
.installfiles
[i
];
2868 FileLocation
target ( OutputDirectory
,
2869 installfile
.target
->relative_path
.length () > 0
2870 ? livecdDirectory
+ sSep
+ reactosDirectory
+ sSep
+ installfile
.target
->relative_path
2871 : livecdDirectory
+ sSep
+ reactosDirectory
,
2872 installfile
.target
->name
);
2873 OutputCopyCommandSingle ( *installfile
.source
, target
);
2874 destinations
.push_back ( target
);
2879 MingwLiveIsoModuleHandler::OutputProfilesDirectoryCommands ( string
& livecdDirectory
,
2880 vector
<FileLocation
>& destinations
)
2882 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" );
2883 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "All Users") ;
2884 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "All Users" + sSep
+ "Desktop" );
2885 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" );
2886 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" + sSep
+ "Desktop" );
2887 CreateDirectory ( livecdDirectory
+ sSep
+ "Profiles" + sSep
+ "Default User" + sSep
+ "My Documents" );
2889 FileLocation
livecdIni ( SourceDirectory
,
2890 "boot" + sSep
+ "bootdata",
2892 FileLocation
destination ( OutputDirectory
,
2895 OutputCopyCommandSingle ( livecdIni
,
2897 destinations
.push_back ( destination
);
2901 MingwLiveIsoModuleHandler::OutputLoaderCommands ( string
& livecdDirectory
,
2902 std::vector
<FileLocation
>& destinations
)
2904 FileLocation
freeldr ( OutputDirectory
,
2905 "boot" + sSep
+ "freeldr" + sSep
+ "freeldr",
2907 FileLocation
destination ( OutputDirectory
,
2908 livecdDirectory
+ sSep
+ "loader",
2910 OutputCopyCommandSingle ( freeldr
,
2912 destinations
.push_back ( destination
);
2916 MingwLiveIsoModuleHandler::OutputRegistryCommands ( string
& livecdDirectory
)
2918 fprintf ( fMakefile
, "# REGISTRY COMMANDS\n" );
2919 FileLocation
reactosSystem32ConfigDirectory ( OutputDirectory
,
2920 livecdDirectory
+ sSep
+ "reactos" + sSep
+ "system32" + sSep
+ "config",
2922 fprintf ( fMakefile
,
2923 "\t$(ECHO_MKHIVE)\n" );
2924 fprintf ( fMakefile
,
2925 "\t$(mkhive_TARGET) boot%cbootdata %s $(ARCH) boot%cbootdata%clivecd.inf boot%cbootdata%chiveinst_$(ARCH).inf\n",
2926 cSep
, backend
->GetFullPath ( reactosSystem32ConfigDirectory
).c_str (),
2927 cSep
, cSep
, cSep
, cSep
);
2931 MingwLiveIsoModuleHandler::GenerateLiveIsoModuleTarget ()
2933 fprintf ( fMakefile
, "# LIVE ISO MODULE TARGET\n" );
2934 string livecdDirectory
= module
.name
;
2935 FileLocation
livecd ( OutputDirectory
, livecdDirectory
, "" );
2940 const Module
* bootModule
= module
.bootSector
->bootSectorModule
;
2944 throw InvalidOperationException ( module
.node
.location
.c_str(),
2946 "Invalid bootsector. module '%s' requires <bootsector>",
2947 module
.name
.c_str ());
2950 const FileLocation
*isoboot
= bootModule
->output
;
2953 We use only the name and not full FileLocation(ouput) because Iso/LiveIso are an exception to the general rule.
2954 Iso/LiveIso outputs are generated in code base root
2956 IsoName
= module
.output
->name
;
2958 string reactosDirectory
= "reactos";
2959 string livecdReactosNoFixup
= livecdDirectory
+ sSep
+ reactosDirectory
;
2960 FileLocation
livecdReactos ( OutputDirectory
,
2961 livecdReactosNoFixup
,
2963 CLEAN_FILE ( livecdReactos
);
2965 std::vector
<FileLocation
> sourceFiles
;
2966 OutputModuleCopyCommands ( livecdDirectory
,
2969 OutputNonModuleCopyCommands ( livecdDirectory
,
2972 OutputProfilesDirectoryCommands ( livecdDirectory
, sourceFiles
);
2973 OutputLoaderCommands ( livecdDirectory
, sourceFiles
);
2976 "\n%s_OBJS := %s\n\n",
2977 module
.name
.c_str (),
2978 v2s ( backend
, sourceFiles
, 5 ).c_str () );
2980 fprintf ( fMakefile
, ".PHONY: %s\n\n",
2981 module
.name
.c_str ());
2982 fprintf ( fMakefile
,
2983 "%s : $(%s_OBJS) %s %s $(mkhive_TARGET) $(cdmake_TARGET)\n",
2984 module
.name
.c_str (),
2985 module
.name
.c_str (),
2986 backend
->GetFullName ( *isoboot
) .c_str (),
2987 backend
->GetFullPath ( FileLocation ( OutputDirectory
,
2990 OutputRegistryCommands ( livecdDirectory
);
2991 fprintf ( fMakefile
, "\t$(ECHO_CDMAKE)\n" );
2992 fprintf ( fMakefile
,
2993 "\t$(Q)$(cdmake_TARGET) -v -m -j -b %s %s REACTOS %s\n",
2994 backend
->GetFullName( *isoboot
).c_str (),
2995 backend
->GetFullPath ( livecd
).c_str (),
2997 fprintf ( fMakefile
,
3002 MingwTestModuleHandler::MingwTestModuleHandler (
3003 const Module
& module_
)
3005 : MingwModuleHandler ( module_
)
3010 MingwTestModuleHandler::Process ()
3012 GenerateTestModuleTarget ();
3015 /* caller needs to delete the returned object */
3017 MingwTestModuleHandler::GetModuleSpecificCompilationUnits ( vector
<CompilationUnit
*>& compilationUnits
)
3019 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_hooks.c", false, "", false ) ) );
3020 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_stubs.S", false, "", false ) ) );
3021 compilationUnits
.push_back ( new CompilationUnit ( new File ( IntermediateDirectory
, module
.output
->relative_path
+ sSep
+ "..", module
.name
+ "_startup.c", false, "", false ) ) );
3025 MingwTestModuleHandler::GenerateTestModuleTarget ()
3028 GenerateLinkerCommand ();
3032 MingwAliasModuleHandler::MingwAliasModuleHandler (
3033 const Module
& module_
)
3035 : MingwModuleHandler ( module_
)
3040 MingwAliasModuleHandler::Process ()
3045 MingwCabinetModuleHandler::MingwCabinetModuleHandler (
3046 const Module
& module_
)
3048 : MingwModuleHandler ( module_
)
3053 MingwCabinetModuleHandler::Process ()
3055 fprintf ( fMakefile
, "# CABINET MODULE TARGET\n" );
3056 string
targetMacro ( GetTargetMacro (module
) );
3060 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3061 fprintf ( fMakefile
, "%s: $(cabman_TARGET) | %s\n",
3062 targetMacro
.c_str (),
3063 backend
->GetFullPath ( *target_file
).c_str () );
3065 fprintf ( fMakefile
, "\t$(ECHO_CABMAN)\n" );
3066 fprintf ( fMakefile
,
3067 "\t$(Q)$(cabman_TARGET) -M raw -S %s $(%s_SOURCES)\n", // Escape the asterisk for Make
3068 targetMacro
.c_str (),
3069 module
.name
.c_str());
3072 MingwElfExecutableModuleHandler::MingwElfExecutableModuleHandler (
3073 const Module
& module_
)
3075 : MingwModuleHandler ( module_
)
3080 MingwElfExecutableModuleHandler::Process ()
3082 string
targetName ( module
.output
->name
);
3083 string
targetMacro ( GetTargetMacro (module
) );
3084 string workingDirectory
= GetWorkingDirectory ();
3085 string objectsMacro
= GetObjectsMacro ( module
);
3086 string libsMacro
= GetLibsMacro ();
3087 string debugFormat
= GetDebugFormat ();
3089 fprintf ( fMakefile
, "# ELF EXECUTABLE TARGET\n" );
3092 const FileLocation
*target_file
= GetTargetFilename ( module
, NULL
);
3093 fprintf ( fMakefile
, "%s: %s %s | %s\n",
3094 targetMacro
.c_str (),
3095 objectsMacro
.c_str (),
3097 backend
->GetFullPath ( *target_file
).c_str () );
3099 fprintf ( fMakefile
, "\t$(ECHO_BOOTPROG)\n" );
3101 fprintf ( fMakefile
, "\t${gcc} $(%s_LINKFORMAT) %s %s -g%s -o %s\n",
3102 module
.buildtype
.c_str(),
3103 objectsMacro
.c_str(),
3105 debugFormat
.c_str(),
3106 targetMacro
.c_str () );
3109 fprintf ( fMakefile
, "#/ELF EXECUTABLE TARGET\n" );